Ë
    3ýjÞ  ã                  óD  — U d Z ddlmZ ddlmZ ddlmZmZmZm	Z	m
Z
mZ ddlmZ ddlmZ ddlmZmZmZmZmZ dd	lmZmZ dd
lmZmZ erddlmZ  ed«      Z ed«      Z ededef   ¬«      Z ddgZ!ee	e"ef      Z#de$d<    G d„ de«      Z% G d„ d«      Z&	 	 	 	 dd„Z'y)zB
Core functionalities for managing context of the click_repl app.
é    )Úannotations©Úwraps)ÚTYPE_CHECKINGÚAnyÚCallableÚDictÚ	GeneratorÚTypeVar)ÚContext)ÚPromptSession)ÚConcatenateÚFinalÚ	ParamSpecÚ	TypeAliasÚ	TypedDicté   )Ú_pop_contextÚ_push_context)ÚISATTYÚget_current_repl_ctx)ÚAnyFormattedTextÚPÚRÚF.)ÚboundÚReplContextÚpass_contextr   Ú_PromptSessionc                  ó@   — e Zd ZU ded<   ded<   ded<   ded<   d	ed
<   y)ÚReplContextInfoDictr   Ú	group_ctxúdict[str, Any]Úprompt_kwargsz_PromptSession | NoneÚsessionúReplContext | NoneÚparentz	list[str]Ú_historyN)Ú__name__Ú
__module__Ú__qualname__Ú__annotations__© ó    úI/root/telegram-saas/.venv/lib/python3.12/site-packages/click_repl/core.pyr!   r!       s    … ØÓØ!Ó!Ø"Ó"ØÓØÔr.   r!   c                  ó�   — e Zd ZdZdZi df	 	 	 	 	 	 	 dd„Zdd„Zdd„Zedd„«       Z	e	j                  dd„«       Z	dd	„Zdd
„Zdd„Zy)r   a)  
    Context object for the REPL sessions.

    This class tracks the depth of nested REPLs, ensuring seamless navigation
    between different levels. It facilitates nested REPL scenarios, allowing
    multiple levels of interactive REPL sessions.

    Each REPL's properties are stored inside this context class, allowing them to
    be accessed and shared with their parent REPL.

    All the settings for each REPL session persist until the session is terminated.

    Parameters
    ----------
    group_ctx
        The click context object that belong to the CLI/parent Group.

    prompt_kwargs
        Extra keyword arguments for
        :class:`~prompt_toolkit.shortcuts.PromptSession` class.

    parent
        REPL Context object of the parent REPL session, if exists. Otherwise, :obj:`None`.
    )r"   r$   r'   r%   r(   Nc                óz   — t         rt        di |¤Ž}nd}|| _        	 || _        	 g | _        	 || _        	 || _        y)z6
        Initializes the `ReplContext` class.
        Nr-   )r   r   r"   r%   r(   r$   r'   )Úselfr"   r$   r'   r%   s        r/   Ú__init__zReplContext.__init__J   sX   € õ Ü#Ñ4 mÑ4‰Gð ˆGà)2ˆŒØKàˆŒØLà#%ˆŒð	ð +ˆÔð	ð
 28ˆŒð	r.   c                ó   — t        | «       | S ©N)r   ©r2   s    r/   Ú	__enter__zReplContext.__enter__t   s   € Ü�dÔØˆr.   c                ó   — t        «        y r5   )r   )r2   Ú_s     r/   Ú__exit__zReplContext.__exit__x   s   € Ü�r.   c                óT   — t         r"| j                  �| j                  j                  S y)zï
        The prompt text of the REPL.

        Returns
        -------
        prompt_toolkit.formatted_text.AnyFormattedText
            The prompt object if :func:`~sys.stdin.isatty` is :obj:`True`,
            else :obj:`None`.
        N©r   r%   Úmessager6   s    r/   ÚpromptzReplContext.prompt{   s#   € õ �d—l‘lÐ.Ø—<‘<×'Ñ'Ð'Ør.   c                óN   — t         r| j                  �|| j                  _        y y y r5   r<   )r2   Úvalues     r/   r>   zReplContext.promptŠ   s!   € å�d—l‘lÐ.Ø#(ˆD�L‰LÕ ð /ˆ6r.   c                óz   — | j                   | j                  | j                  | j                  | j                  dœ}|S )zÙ
        Provides a dictionary with minimal info about the current REPL.

        Returns
        -------
        ReplContextInfoDict
            A dictionary that has the instance variables and their values.
        ©r"   r$   r%   r'   r(   rB   )r2   Úress     r/   Úto_info_dictzReplContext.to_info_dict�   s7   € ð Ÿ™Ø!×/Ñ/Ø—|‘|Ø—k‘kØŸ™ñ$
ˆð ˆ
r.   c                ó`   — t         r(| j                  �t        di | j                  ¤Ž| _        yyy)zä
        Resets values of :class:`~prompt_toolkit.session.PromptSession` to
        the provided :attr:`~.prompt_kwargs`, discarding any changes done to the
        :class:`~prompt_toolkit.session.PromptSession` object.
        Nr-   )r   r%   r   r$   r6   s    r/   Úsession_resetzReplContext.session_reset£   s,   € õ �d—l‘lÐ.Ü(Ñ>¨4×+=Ñ+=Ñ>ˆD�Lð /ˆ6r.   c              #  óÌ   K  — t         r9| j                  �-| j                  j                  j                  «       E d{  –—†  yt	        | j
                  «      E d{  –—†  y7 Œ#7 Œ­w)zæ
        Generates the history of past executed commands.

        Yields
        ------
        str
            The executed command string from the history,
            in chronological order from most recent to oldest.
        N)r   r%   ÚhistoryÚload_history_stringsÚreversedr(   r6   s    r/   rH   zReplContext.history­   sP   è ø€ õ �d—l‘lÐ.Ø—|‘|×+Ñ+×@Ñ@ÓB×BÑBô   §¡Ó.×.Ñ.ð Cøð /ús!   ‚:A$¼A ½A$ÁA"ÁA$Á"A$)r"   r   r$   r#   r'   r&   ÚreturnÚNone)rK   r   )r9   r   rK   rL   )rK   r   )r@   r   rK   rL   )rK   r!   )rK   rL   )rK   zGenerator[str, None, None])r)   r*   r+   Ú__doc__Ú	__slots__r3   r7   r:   Úpropertyr>   ÚsetterrD   rF   rH   r-   r.   r/   r   r   (   s‡   „ ñð2€Ið )+Ø%)ð	(àð(ð &ð(ð #ð	(ð
 
ó(óTóð òó ðð ‡]�]ò)ó ð)óó(?ô/r.   c                ó0   ‡ — t        ‰ «      dˆ fd„«       }|S )a†  
    Decorator that marks a callback function to receive the current
    REPL context object as its first argument.

    Parameters
    ----------
    func
        The callback function to pass context as its first parameter.

    Returns
    -------
    Callable[P,R]
        The decorated callback function that receives the current REPL
        context object as its first argument.
    c                 ó,   •—  ‰t        «       g| ¢­i |¤ŽS r5   )r   )ÚargsÚkwargsÚfuncs     €r/   Ú	decoratorzpass_context.<locals>.decoratorÒ   s   ø€ áÔ(Ó*Ð<¨TÒ<°VÑ<Ð<r.   )rS   zP.argsrT   zP.kwargsrK   r   r   )rU   rV   s   ` r/   r   r   ¿   s#   ø€ ô& ˆ4ƒ[ô=ó ð=ð Ðr.   N)rU   z/Callable[Concatenate[ReplContext | None, P], R]rK   zCallable[P, R])(rM   Ú
__future__r   Ú	functoolsr   Útypingr   r   r   r	   r
   r   Úclickr   Úprompt_toolkitr   Útyping_extensionsr   r   r   r   r   Ú
_ctx_stackr   r   Úglobals_r   r   Úprompt_toolkit.formatted_textr   r   r   r   Ú__all__Ústrr   r,   r!   r   r   r-   r.   r/   ú<module>rb      s¬   ðòõ #å ß I× Iå Ý (ß QÕ Qç 3ß 2áÝ>ñ ˆcƒN€ÙˆCƒL€ÙˆC�x  S Ñ)Ô*€ð ˜.Ð
)€ð *¨$¨s°C¨x©.Ñ9€�	Ó 9ô˜)ô ÷T/ñ T/ðnØ
9ðàôr.   