from __future__ import annotations

from typing import Any, TypedDict

class ViewportSize(TypedDict):
    width: int
    height: int

class FloatRect(TypedDict):
    x: float
    y: float
    width: float
    height: float

class BrowserType:
    def launch(self, *, args: list[str] | None = None) -> Browser: ...

class Playwright:
    chromium: BrowserType
    def stop(self) -> None: ...

class PlaywrightContextManager:
    def start(self) -> Playwright: ...

class Browser:
    def close(self) -> None: ...
    def is_connected(self) -> bool: ...
    def new_page(self) -> Page: ...

class BrowserContext:
    def close(self) -> None: ...
    def new_page(self) -> Page: ...

class Page:
    def close(self) -> None: ...
    def evaluate(self, expression: str) -> Any: ...
    def goto(self, url: str) -> None: ...
    def is_closed(self) -> bool: ...
    def screenshot(self, *, clip: FloatRect | None = None) -> bytes: ...
    def set_content(self, html: str) -> None: ...
    def set_viewport_size(self, viewport_size: ViewportSize) -> None: ...
    def wait_for_function(self, expression: str, *, timeout: float | None = None) -> Any: ...

def sync_playwright() -> PlaywrightContextManager: ...
