"""
CSSL Bridge - Type Stubs for Python API
"""

import threading
from typing import Any, List, Optional, Callable


class CsslLang:
    """
    CSSL Language interface for Python.

    Usage:
        from includecpp import CSSL
        cssl = CSSL.CsslLang()
        result = cssl.exec("script.cssl", arg1, arg2)
        cssl.T_exec("async_script.cssl", arg1)  # Threaded
    """

    def __init__(self, output_callback: Optional[Callable[[str, str], None]] = ...) -> None:
        """
        Initialize CSSL runtime.

        Args:
            output_callback: Optional callback for output (text, level)
        """
        ...

    def exec(self, path_or_code: str, *args: Any) -> Any:
        """
        Execute CSSL code or file.

        Args:
            path_or_code: Path to .cssl file or CSSL code string
            *args: Arguments to pass to the script

        Returns:
            Execution result
        """
        ...

    def T_exec(
        self,
        path_or_code: str,
        *args: Any,
        callback: Optional[Callable[[Any], None]] = ...
    ) -> threading.Thread:
        """
        Execute CSSL code asynchronously in a thread.

        Args:
            path_or_code: Path to .cssl file or CSSL code string
            *args: Arguments to pass to the script
            callback: Optional callback when execution completes

        Returns:
            Thread object
        """
        ...

    def wait_all(self, timeout: Optional[float] = ...) -> None:
        """Wait for all async executions to complete."""
        ...

    def get_output(self) -> List[str]:
        """Get output buffer from last execution."""
        ...

    def clear_output(self) -> None:
        """Clear output buffer."""
        ...

    def set_global(self, name: str, value: Any) -> None:
        """Set a global variable in CSSL runtime."""
        ...

    def get_global(self, name: str) -> Any:
        """Get a global variable from CSSL runtime."""
        ...


def get_cssl() -> CsslLang:
    """Get default CSSL instance."""
    ...


def exec(path_or_code: str, *args: Any) -> Any:
    """
    Execute CSSL code or file.

    Usage:
        from includecpp import CSSL
        CSSL.exec("script.cssl", arg1, arg2)
        CSSL.exec("printl('Hello World');")

    Args:
        path_or_code: Path to .cssl file or CSSL code string
        *args: Arguments to pass to the script

    Returns:
        Execution result
    """
    ...


def T_exec(
    path_or_code: str,
    *args: Any,
    callback: Optional[Callable[[Any], None]] = ...
) -> threading.Thread:
    """
    Execute CSSL code asynchronously in a thread.

    Usage:
        from includecpp import CSSL
        CSSL.T_exec("async_script.cssl", arg1, callback=on_done)

    Args:
        path_or_code: Path to .cssl file or CSSL code string
        *args: Arguments to pass to the script
        callback: Optional callback when execution completes

    Returns:
        Thread object
    """
    ...


def set_global(name: str, value: Any) -> None:
    """Set a global variable in CSSL runtime."""
    ...


def get_global(name: str) -> Any:
    """Get a global variable from CSSL runtime."""
    ...


def get_output() -> List[str]:
    """Get output buffer from last execution."""
    ...


def clear_output() -> None:
    """Clear output buffer."""
    ...


__all__: List[str]
