"""
This type stub file was generated by pyright.
"""

from dataclasses import dataclass
from enum import Enum
from typing import TYPE_CHECKING
from streamlit.proto.WidgetStates_pb2 import WidgetStates
from streamlit.proto.ClientState_pb2 import ContextInfo

if TYPE_CHECKING:
    ...
class ScriptRequestType(Enum):
    CONTINUE = ...
    STOP = ...
    RERUN = ...


@dataclass(frozen=True)
class RerunData:
    """Data attached to RERUN requests. Immutable."""
    query_string: str = ...
    widget_states: WidgetStates | None = ...
    page_script_hash: str = ...
    page_name: str = ...
    fragment_id: str | None = ...
    fragment_id_queue: list[str] = ...
    is_fragment_scoped_rerun: bool = ...
    is_auto_rerun: bool = ...
    cached_message_hashes: set[str] = ...
    context_info: ContextInfo | None = ...
    def __repr__(self) -> str:
        ...
    


@dataclass(frozen=True)
class ScriptRequest:
    """A STOP or RERUN request and associated data."""
    type: ScriptRequestType
    _rerun_data: RerunData | None = ...
    @property
    def rerun_data(self) -> RerunData:
        ...
    
    def __repr__(self) -> str:
        ...
    


class ScriptRequests:
    """An interface for communicating with a ScriptRunner. Thread-safe.

    AppSession makes requests of a ScriptRunner through this class, and
    ScriptRunner handles those requests.
    """
    def __init__(self) -> None:
        ...
    
    def request_stop(self) -> None:
        """Request that the ScriptRunner stop running. A stopped ScriptRunner
        can't be used anymore. STOP requests succeed unconditionally.
        """
        ...
    
    def request_rerun(self, new_data: RerunData) -> bool:
        """Request that the ScriptRunner rerun its script.

        If the ScriptRunner has been stopped, this request can't be honored:
        return False.

        Otherwise, record the request and return True. The ScriptRunner will
        handle the rerun request as soon as it reaches an interrupt point.
        """
        ...
    
    def on_scriptrunner_yield(self) -> ScriptRequest | None:
        """Called by the ScriptRunner when it's at a yield point.

        If we have no request or a RERUN request corresponding to one or more fragments
        (that is not a fragment-scoped rerun), return None.

        If we have a (full script or fragment-scoped) RERUN request, return the request
        and set our internal state to CONTINUE.

        If we have a STOP request, return the request and remain stopped.
        """
        ...
    
    def on_scriptrunner_ready(self) -> ScriptRequest:
        """Called by the ScriptRunner when it's about to run its script for
        the first time, and also after its script has successfully completed.

        If we have a RERUN request, return the request and set
        our internal state to CONTINUE.

        If we have a STOP request or no request, set our internal state
        to STOP.
        """
        ...
    


