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

from contextvars import Token
from typing import Callable, Generic, TYPE_CHECKING, TypeVar
from streamlit.delta_generator import DeltaGenerator
from streamlit.elements.lib.dialog import Dialog
from streamlit.elements.lib.mutable_status_container import StatusContainer

"""
The main purpose of this module (right now at least) is to avoid a dependency
cycle between streamlit.delta_generator and some elements.
"""
if TYPE_CHECKING:
    ...
class DeltaGeneratorSingleton:
    """Used to initialize the DeltaGenerator classes and store them as singletons.
    This module allows us to avoid circular imports between DeltaGenerator and elements,
    because elemens can import this singleton module instead of DeltaGenerator directly.
    """
    _instance: DeltaGeneratorSingleton | None = ...
    @classmethod
    def instance(cls) -> DeltaGeneratorSingleton:
        """Return the singleton DeltaGeneratorSingleton instance. Raise an Error if the
        DeltaGeneratorSingleton hasn't been created yet.
        """
        ...
    
    def __init__(self, delta_generator_cls: type[DeltaGenerator], status_container_cls: type[StatusContainer], dialog_container_cls: type[Dialog]) -> None:
        """Registers and initializes all delta-generator classes.

        Parameters
        ----------
        delta_generator_cls : type[DeltaGenerator]
            The main DeltaGenerator class.
        status_container_cls : type[StatusContainer]
            The delta-generator class that is used as return value for `st.status`.
        dialog_container_cls : type[Dialog]
            The delta-generator class used is used as return value for `st.dialog`.

        Raises
        ------
        RuntimeError
            If the DeltaGeneratorSingleton instance already exists.
        """
        ...
    
    @property
    def main_dg(self) -> DeltaGenerator:
        ...
    
    @property
    def sidebar_dg(self) -> DeltaGenerator:
        ...
    
    @property
    def event_dg(self) -> DeltaGenerator:
        ...
    
    @property
    def bottom_dg(self) -> DeltaGenerator:
        ...
    
    @property
    def status_container_cls(self) -> type[StatusContainer]:
        """Stub for StatusContainer. Since StatusContainer inherits from DeltaGenerator,
        this is used to avoid circular imports.
        """
        ...
    
    @property
    def dialog_container_cls(self) -> type[Dialog]:
        """Stub for Dialog. Since Dialog inherits from DeltaGenerator,
        this is used to avoid circular imports.
        """
        ...
    


def get_dg_singleton_instance() -> DeltaGeneratorSingleton:
    """Return the DeltaGeneratorSingleton instance. Raise an Error if the
    DeltaGeneratorSingleton hasn't been created yet.
    """
    ...

_T = TypeVar("_T")
class ContextVarWithLazyDefault(Generic[_T]):
    """The dg_stack tracks the currently active DeltaGenerator, and is pushed to when
    a DeltaGenerator is entered via a `with` block. This is implemented as a ContextVar
    so that different threads or async tasks can have their own stacks.

    We have a wrapper around it because ContextVar default cannot be a function, but
    the default dg (main_dg) might not exist yet when this module is imported.
    """
    def __init__(self, name: str, *, default: Callable[[], _T]) -> None:
        ...
    
    def get(self) -> _T:
        ...
    
    def set(self, value: _T) -> Token[_T]:
        ...
    
    def reset(self, token: Token[_T]) -> None:
        ...
    
    def __hash__(self) -> int:
        ...
    


context_dg_stack: ContextVarWithLazyDefault[tuple[DeltaGenerator, ...]] = ...
def get_default_dg_stack_value() -> tuple[DeltaGenerator, ...]:
    """Get the default dg_stack value with which the dg_stack should
    be initialized and reset if needed.
    """
    ...

def get_last_dg_added_to_context_stack() -> DeltaGenerator | None:
    """Get the last added DeltaGenerator of the stack in the current context.

    Returns None if the stack has only one element or is empty for whatever reason.
    """
    ...

