#!/usr/bin/env python3
"""
Core module for resizing the active window on macOS.
"""

import subprocess
import sys


def resize_active_window(width: int, height: int):
    """
    Resize the currently active window to the specified dimensions.
    Keeps the window in its current position.
    
    Args:
        width: Target width in pixels
        height: Target height in pixels
    """
    applescript = f'''
    tell application "System Events"
        set frontApp to first application process whose frontmost is true
        tell frontApp
            set size of window 1 to {{{width}, {height}}}
        end tell
    end tell
    '''
    
    try:
        subprocess.run(['osascript', '-e', applescript], check=True, capture_output=True)
        print(f"✓ Resized active window to {width}x{height}")
    except subprocess.CalledProcessError as e:
        print(f"✗ Error resizing window: {e.stderr.decode()}")
        sys.exit(1)