from .api import get, post, put, delete, head, options, patch, request
from .session import Session
from .cli import install_browser

# 延迟导入 Browser，避免强制依赖 playwright
def Browser(cf_proxies, headless=True, timeout=30):
    """
    创建浏览器实例
    
    Args:
        cf_proxies: Workers 地址，如 "https://ip.kami666.xyz"
        headless: 是否无头模式，默认 True
        timeout: 请求超时时间（秒），默认 30
        
    Returns:
        Browser: 浏览器实例
        
    Example:
        >>> import cfspider
        >>> browser = cfspider.Browser(cf_proxies="https://ip.kami666.xyz")
        >>> html = browser.html("https://example.com")
        >>> browser.close()
    """
    from .browser import Browser as _Browser
    return _Browser(cf_proxies, headless, timeout)


class CFSpiderError(Exception):
    pass


class BrowserNotInstalledError(Exception):
    """浏览器未安装错误"""
    pass


class PlaywrightNotInstalledError(Exception):
    """Playwright 未安装错误"""
    pass


__version__ = "1.1.0"
__all__ = [
    "get", "post", "put", "delete", "head", "options", "patch", "request",
    "Session", "Browser", "install_browser",
    "CFSpiderError", "BrowserNotInstalledError", "PlaywrightNotInstalledError"
]
