§
    %Qòc¦  ã                   óÈ  — U d dl Z d dlmZ d dlmZmZmZmZ 	 d dlm	Z	 n# e
$ r	 d dlm	Z	 Y nw xY werd dlmZ d dlmZ ddlmZ g d	¢Z G d
„ d¦  «        Z e	d e¦   «         ¬¦  «        Ze	d         ed<   defd„Zdd„Zded         fd„Zeddded         fd„¦   «         Ze	 dded         ded         deeddf         fd„¦   «         Zedeeddf         fd„¦   «         ZdS )é    N)Úcontextmanager)ÚTYPE_CHECKINGÚAnyÚ	GeneratorÚOptional)Ú
ContextVar)ÚInput)ÚOutputé   )ÚApplication)Ú
AppSessionÚget_app_sessionÚget_appÚget_app_or_noneÚset_appÚcreate_app_sessionÚcreate_app_session_from_ttyc                   ó~   — e Zd ZdZ	 dded         ded         ddfd„Zdefd	„Zedd
„¦   «         Z	edd„¦   «         Z
dS )r   aZ  
    An AppSession is an interactive session, usually connected to one terminal.
    Within one such session, interaction with many applications can happen, one
    after the other.

    The input/output device is not supposed to change during one session.

    Warning: Always use the `create_app_session` function to create an
    instance, so that it gets activated correctly.

    :param input: Use this as a default input for all applications
        running in this session, unless an input is passed to the `Application`
        explicitely.
    :param output: Use this as a default output.
    NÚinputr	   Úoutputr
   Úreturnc                 ó0   — || _         || _        d | _        d S ©N)Ú_inputÚ_outputÚapp)Úselfr   r   s      úBlib/python3.11/site-packages/prompt_toolkit/application/current.pyÚ__init__zAppSession.__init__,   s   € ð ˆŒØˆŒð 26ˆŒˆˆó    c                 ó   — d| j         ›dS )NzAppSession(app=ú))r   )r   s    r   Ú__repr__zAppSession.__repr__7   s   € Ø. ¤Ð.Ð.Ð.Ð.r    c                 óH   — | j         €ddlm}  |¦   «         | _         | j         S )Nr   ©Úcreate_input)r   Úprompt_toolkit.input.defaultsr&   )r   r&   s     r   r   zAppSession.input:   s3   € àŒ;ð 	)ØBÐBÐBÐBÐBÐBà&˜,™.œ.ˆDŒKØŒ{Ðr    c                 óH   — | j         €ddlm}  |¦   «         | _         | j         S )Nr   ©Úcreate_output)r   Úprompt_toolkit.output.defaultsr*   )r   r*   s     r   r   zAppSession.outputB   s3   € àŒ<ð 	+ØDÐDÐDÐDÐDÐDà(˜=™?œ?ˆDŒLØŒ|Ðr    ©NN)r   r	   )r   r
   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ústrr#   Úpropertyr   r   © r    r   r   r      s»   € € € € € ðð ð" MQð	6ð 	6Ø˜gÔ&ð	6Ø7?ÀÔ7Ið	6à	ð	6ð 	6ð 	6ð 	6ð/˜#ð /ð /ð /ð /ð ðð ð ñ „Xðð ðð ð ñ „Xðð ð r    r   Ú_current_app_session)Údefaultr   c                  ó4   — t                                ¦   «         S r   )r4   Úgetr3   r    r   r   r   P   s   € Ý×#Ò#Ñ%Ô%Ð%r    úApplication[Any]c                  óp   — t                                ¦   «         } | j        | j        S ddlm}  |¦   «         S )a'  
    Get the current active (running) Application.
    An :class:`.Application` is active during the
    :meth:`.Application.run_async` call.

    We assume that there can only be one :class:`.Application` active at the
    same time. There is only one terminal window, with only one stdin and
    stdout. This makes the code significantly easier than passing around the
    :class:`.Application` everywhere.

    If no :class:`.Application` is running, then return by default a
    :class:`.DummyApplication`. For practical reasons, we prefer to not raise
    an exception. This way, we don't have to check all over the place whether
    an actual `Application` was returned.

    (For applications like pymux where we can have more than one `Application`,
    we'll use a work-around to handle that.)
    Nr   )ÚDummyApplication)r4   r7   r   Údummyr:   )Úsessionr:   s     r   r   r   T   sH   € õ& #×&Ò&Ñ(Ô(€GØ„{ð ØŒ{Ðà'Ð'Ð'Ð'Ð'Ð'àÐÑÔÐr    c                  óB   — t                                ¦   «         } | j        S )zj
    Get the current active (running) Application, or return `None` if no
    application is running.
    ©r4   r7   r   )r<   s    r   r   r   p   s   € õ
 #×&Ò&Ñ(Ô(€GØŒ;Ðr    r   )NNNc              #   óˆ   K  — t                                ¦   «         }|j        }| |_        	 dV — ||_        dS # ||_        w xY w)aµ  
    Context manager that sets the given :class:`.Application` active in an
    `AppSession`.

    This should only be called by the `Application` itself.
    The application will automatically be active while its running. If you want
    the application to be active in other threads/coroutines, where that's not
    the case, use `contextvars.copy_context()`, or use `Application.context` to
    run it in the appropriate context.
    Nr>   )r   r<   Úprevious_apps      r   r   r   y   sS   è è € õ #×&Ò&Ñ(Ô(€Gà”;€LØ€G„Kð#Øˆˆˆà"ˆŒˆˆølˆŒÐ"Ð"Ð"Ð"s	   «8 ¸	Ar   r	   r   r
   c              #   ón  K  — t           j        dk    rt          d¦  «        ‚| €t          ¦   «         j        } |€t          ¦   «         j        }t          | |¬¦  «        }t                               |¦  «        }	 |V — t           	                    |¦  «         dS # t           	                    |¦  «         w xY w)zï
    Create a separate AppSession.

    This is useful if there can be multiple individual `AppSession`s going on.
    Like in the case of an Telnet/SSH server. This functionality uses
    contextvars and requires at least Python 3.7.
    )é   é   z(Application sessions require Python 3.7.N©r   r   )
ÚsysÚversion_infoÚRuntimeErrorr   r   r   r   r4   ÚsetÚreset)r   r   r<   Útokens       r   r   r      sÀ   è è € õ Ô˜6Ò!ð GÝÐEÑFÔFÐFð ð (ÝÑ!Ô!Ô'ˆØð *Ý Ñ"Ô"Ô)ˆõ ˜u¨VÐ4Ñ4Ô4€Gå ×$Ò$ WÑ-Ô-€Eð*Øˆˆˆå×"Ò" 5Ñ)Ô)Ð)Ð)Ð)øÕ×"Ò" 5Ñ)Ô)Ð)Ð)øøøs   Á8B ÂB4c               #   ó®   K  — ddl m}  ddlm}  | d¬¦  «        } |d¬¦  «        }t	          ||¬¦  «        5 }|V — ddd¦  «         dS # 1 swxY w Y   dS )a‘  
    Create `AppSession` that always prefers the TTY input/output.

    Even if `sys.stdin` and `sys.stdout` are connected to input/output pipes,
    this will still use the terminal for interaction (because `sys.stderr` is
    still connected to the terminal).

    Usage::

        from prompt_toolkit.shortcuts import prompt

        with create_app_session_from_tty():
            prompt('>')
    r   r%   r)   T)Úalways_prefer_ttyrD   N)r'   r&   r+   r*   r   )r&   r*   r   r   Úapp_sessions        r   r   r   ®   sÐ   è è € ð  ;Ð:Ð:Ð:Ð:Ð:Ø<Ð<Ð<Ð<Ð<Ð<àˆL¨4Ð0Ñ0Ô0€EØˆ]¨TÐ2Ñ2Ô2€Få	 %°Ð	7Ñ	7Ô	7ð ¸;ØÐÐÐðð ð ñ ô ð ð ð ð ð ð ð øøøð ð ð ð ð ð s   ¸A
Á
AÁA)r   r8   r,   )rE   Ú
contextlibr   Útypingr   r   r   r   Úcontextvarsr   ÚImportErrorÚ*prompt_toolkit.eventloop.dummy_contextvarsÚprompt_toolkit.input.baser	   Úprompt_toolkit.output.baser
   Úapplicationr   Ú__all__r   r4   Ú__annotations__r   r   r   r   r   r   r3   r    r   ú<module>rX      sd  ðØ 
€
€
€
€
Ø %Ð %Ð %Ð %Ð %Ð %Ø :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :ðFØ&Ð&Ð&Ð&Ð&Ð&Ð&øØð Fð Fð FØEÐEÐEÐEÐEÐEÐEÐEðFøøøð ð )Ø/Ð/Ð/Ð/Ð/Ð/Ø1Ð1Ð1Ð1Ð1Ð1à(Ð(Ð(Ð(Ð(Ð(ðð ð €ð-ð -ð -ð -ð -ñ -ô -ð -ð` 2<°Ø J J¡L¤Lð2ñ 2ô 2Ð j Ô.ð ð ñ ð
&˜ð &ð &ð &ð &ðð ð ð ð8˜Ð"4Ô5ð ð ð ð ð ð#Ð#ð #¨	Ð2BÔ(Cð #ð #ð #ñ „ð#ð* àBFð*ð *ØGÔð*Ø-5°hÔ-?ð*àˆz˜4 Ð%Ô&ð*ð *ð *ñ „ð*ð< ð Y¨z¸4ÀÐ/EÔ%Fð ð ð ñ „ðð ð s   ™   .­.