
    Cj}                       % S r SSKJr  SSKrSSKrSSKJrJrJrJr  SSK	J
r
  SSKJr  SSKJr  SSKJrJrJrJrJrJrJrJrJr  SS	KJrJr  SS
KJrJrJrJ r   SSK!J"r"  SSK#J$r$  SSK%J&r&J'r'J(r(  SSK%J)r*  SSK%J+r+  SSK,J-r-  SSK.J/r/  SSK0Jr  SSK1J2r2  SSK3J4r4  SSK5J6r6  SSK7J8r8  SSK9J:r:J;r;  SSK<J=r=  SSK>J?r?J@r@  \(       a  SSKAJBrB  SSKCJDrD  SSKEJFrF  SrGS\HS'    " S  S!\I5      rJ " S" S#\I5      rK\" S$S%S&9rL " S' S%\M5      rN " S( S)\NS*9rOg)+z

A `MessagePump` is a base class for any object which processes messages, which includes Widget, Screen, and App.

!!! tip

    Most of the method here are useful in general app development.

    )annotationsN)CancelledError
QueueEmptyTaskcreate_task)contextmanager)partial)perf_counter)	TYPE_CHECKINGAny	AwaitableCallable	GeneratorIterableTypeTypeVarcast)WeakSetref)Loggereventslogmessages)invoke)cached_property)NoActiveAppError
active_appactive_message_pump)message_hook)prevent_message_types_stack)
OnNoWidgetQueue)time)SLOW_THRESHOLD)match)Event)Message)ReactiveTooManyComputesError)Signal)TimerTimerCallback)	TypeAliasApp)SelectorSetz2Callable[..., Any] | Callable[..., Awaitable[Any]]r.   Callbackc                      \ rS rSrSrg)CallbackError;    N__name__
__module____qualname____firstlineno____static_attributes__r6       f/home/rurouni/.local/share/pipx/venvs/strix-agent/lib/python3.13/site-packages/textual/message_pump.pyr4   r4   ;       r=   r4   c                      \ rS rSrSrg)MessagePumpClosed?   r6   Nr7   r6   r=   r>   rA   rA   ?   r?   r=   rA   _MessagePumpMetaSub_MessagePumpMeta)boundc                  H   ^  \ rS rSrSr            SU 4S jjrSrU =r$ )rD   F   zuMetaclass for message pump. This exists to populate a Message inner class of a Widget with the
parent classes' name.
c                \  > UR                  S0 5      nXSS'   UR                  5        Ha  n[        U5      (       d  M  [        US5      (       d  M(  [	        US5      nU H'  u  pUR                  U/ 5      R                  Xi45        M)     Mc     Sn
[        U
5      nUR                  5        Hl  u  pUR                  U
5      (       d  M  [        U5      (       d  M/  XS  nX;   d  M:  [        X=   [        5      (       d  MS  SU 3U;   d  M^  [        SU< S35      e   [        TU ]8  " XX#40 UD6nU$ )N_decorated_handlers_textual_oncompute__z	reactive z can't have two computes.)getvaluescallablehasattrgetattr
setdefaultappendlenitems
startswith
isinstancer)   r*   super__new__)clsnamebases
class_dictkwargshandlersvalue
textual_onmessage_type	selectorsprefix
prefix_len	attr_namereactive_name	class_obj	__class__s                  r>   rY   _MessagePumpMeta.__new__K   s/    NN0"5 	 -5()&&(E75-#@#@ E=1  0:+L''b9@@%AST 0: ) [
 * 0 0 2I##F++ )+ 6!/":#<hGGI;:5.#M#44MN  !3 GOCuKFK	r=   r6   )rZ   zType[_MessagePumpMetaSub]r[   strr\   ztuple[type, ...]r]   zdict[str, Any]r^   r   returnrC   )r8   r9   r:   r;   __doc__rY   r<   __classcell__)ri   s   @r>   rD   rD   F   sJ    %&%%  % #	%
 % 
% %r=   c                  n   \ rS rSrSrS?S@S jjr\SAS j5       r\R                  S@S j5       r\	SBS j5       r
\	SCS j5       r\SDS	 j5       rS
 rSES jrSFS jr\SGS j5       r\SHS j5       r\SIS j5       r\SJS j5       r\S 5       r\(       a  SSKJr  \R3                  \5      rO
\SKS j5       r\SIS j5       r\SIS j5       r\SIS j5       r\SLS j5       rSMS jrSNS jr SOS jr!SPS jr"SPS jr#SQS jr$SRS jr% S?SS S!.         SSS" jjjr& S?SSS S#.           STS$ jjjr'SUS% jr(SIS& jr)SUS' jr*SVS( jr+SWS) jr,SXSYS* jjr-SNS+ jr.SNS, jr/SNS- jr0SIS. jr1S/ r2SNS0 jr3\SZS1 j5       r4S[S2 jr5SNS3 jr6SNS4 jr7S\S5 jr8      S]S6 jr9S^S7 jr:S\S8 jr;SNS9 jr<SOS: jr=SOS; jr>S_S< jr?S`S= jr@S>rAg)aMessagePumps   z)Base class which supplies a message pump.Nc                Z   Xl         SU l        SU l        SU l        [	        5       U l        S U l        S U l        [        5       U l	        [        5       U l        S U l        SU l         / U l        [        R                   " 5       U l        U R$                  S   U l        [)        U S5      U l        g )NFr   )_parent_running_closing_closedset_disabled_messages_pending_message_taskr   _timersr$   
_last_idle	_max_idle_is_mounted_next_callbacks	threading	get_ident
_thread_id_prevent_message_types_stack_prevented_messages_on_mountr+   message_signalselfparents     r>   __init__MessagePump.__init__v   s    ##"69e04"&
'.y!%'+ 	 79(224,0,M,Mb,Q)/5dJ/G	r=   c                @    U R                   c  S$ U R                  5       $ )z)The current parent message pump (if set).N)_MessagePump__parentr   s    r>   rt   MessagePump._parent   s     }},tA$--/Ar=   c                :    Uc  S U l        g [        U5      U l        g N)r   r   r   s     r>   rt   r      s     &CKr=   c                    [        5       $ r   r"   r   s    r>   _message_queueMessagePump._message_queue   s	    wr=   c                ,    [         R                  " 5       $ r   )asyncior'   r   s    r>   _mounted_eventMessagePump._mounted_event   s    }}r=   c                     [         R                  " 5       nU$ ! [         a%    [        5       /n[         R                  " U5         U$ f = f)z*The stack that manages prevented messages.)r    rM   LookupErrorrx   )r   stacks     r>   r   (MessagePump._prevent_message_types_stack   sI    	3/335E   	3UGE'++E2	3s    +AAc                4    U R                     U R                    g)zInitialize threading primitives for the current thread.

Require for Python3.8 https://github.com/Textualize/textual/issues/5845

N)r   r   r   s    r>   _thread_initMessagePump._thread_init   s     	r=   c                     U R                   S   $ )z)A set of all the prevented message types.rs   r   r   s    r>   _get_prevented_messages#MessagePump._get_prevented_messages   s    0044r=   c                $    XR                   S   ;   $ )a  Check if a message type has been prevented via the
[prevent][textual.message_pump.MessagePump.prevent] context manager.

Args:
    message_type: A message type.

Returns:
    `True` if the message has been prevented from sending, or `False` if it will be sent as normal.
rs   r   )r   rb   s     r>   _is_preventedMessagePump._is_prevented   s     @@DDDr=   c              '     #    U(       aE  U R                   nUR                  US   R                  U5      5         Sv   UR                  5         gSv   g! UR                  5         f = f7f)zA context manager to *temporarily* prevent the given message types from being posted.

Example:
    ```python
    input = self.query_one(Input)
    with self.prevent(Input.Changed):
        input.value = "foo"
    ```
rs   N)r   rS   unionpop)r   message_typesprevent_stacks      r>   preventMessagePump.prevent   sY       ==M  r!2!8!8!GH$!!# !!#s   7A)A A)A&&A)c                8    U R                   c   eU R                   $ r   )r{   r   s    r>   taskMessagePump.task   s    zz%%%zzr=   c                    U R                   SL$ )zDoes this object have a parent?Nrt   r   s    r>   
has_parentMessagePump.has_parent   s     ||4''r=   c                6    U R                   R                  5       $ )z&The current size of the message queue.)r   qsizer   s    r>   message_queue_sizeMessagePump.message_queue_size   s     ""((**r=   c                    g)z#Is this a root node (i.e. the App)?Fr6   r   s    r>   is_dom_rootMessagePump.is_dom_root   s     r=   r   )gettersc                     [         R                  " 5       $ ! [         aH    SSKJn  U n[        X!5      (       d+  Uc
  [        5       eUR                  n[        X!5      (       d  M+  Us $ f = f)z
Get the current app.

Returns:
    The current app.

Raises:
    NoActiveAppError: if no active app could be found for the current asyncio context
r   r/   )r   rM   r   textual.appr0   rW   r   rt   )r   r0   nodes      r>   appMessagePump.app   sa    !~~'' 	++/$T//|.00<<D %T//
 	s    AA)$A)(A)c                     U R                   R                  (       a  g U nUR                  =nb#  UR                  (       a  gUR                  =nb  M#  g! [         a     gf = f)z/Is this node linked to the app through the DOM?FT)r   _exitr   rt   r   )r   r   s     r>   is_attachedMessagePump.is_attached  sf    	xx~~  $(||#t0 ||#t0    		s   A 
A! A!c                    U R                   n[        USL=(       a)    UR                  (       + =(       a    UR                  (       + 5      $ )zIs the parent active?N)rt   boolrw   rv   r   s     r>   is_parent_activeMessagePump.is_parent_active  s5     F$&Uv~~+=UfooBUVVr=   c                    U R                   $ )z>Is the message pump running (potentially processing messages)?)ru   r   s    r>   
is_runningMessagePump.is_running!  s     }}r=   c                .    U R                   R                  $ )z6Get a logger for this object.

Returns:
    A logger.
)r   _loggerr   s    r>   r   MessagePump.log&  s     xxr=   c                    Xl         g)z\Set the parent, and therefore attach this node to the tree.

Args:
    parent: Parent node.
Nr   r   s     r>   _attachMessagePump._attach/  s	     r=   c                    SU l         g)z8Set the parent to None to remove the node from the tree.Nr   r   s    r>   _detachMessagePump._detach7  s	    r=   c                2    [        U5      U R                  ;  $ )zCheck if a given message is enabled (allowed to be sent).

Args:
    message: A message object.

Returns:
    `True` if the message will be sent, or `False` if it is disabled.
)typery   r   messages     r>   check_message_enabled!MessagePump.check_message_enabled;  s     G}D$;$;;;r=   c                :    U R                   R                  U5        g)z+Disable message types from being processed.N)ry   updater   r   s     r>   disable_messagesMessagePump.disable_messagesG  s    &&x0r=   c                :    U R                   R                  U5        g)z$Enable processing of messages types.N)ry   difference_updater   s     r>   enable_messagesMessagePump.enable_messagesK  s    11(;r=   c                  #    U R                   (       a  [        S5      eU R                  b   U R                  SU l        $ U R                  R	                  5       I Sh  vN nUc  SU l         [        S5      eU$ ! SU l        f = f N'7f)zaGet the next event on the queue, or None if queue is closed.

Returns:
    Event object or None.
zThe message pump is closedNTThe message pump is now closed)rw   rA   rz   r   rM   r   s     r>   _get_messageMessagePump._get_messageO  s      <<#$@AA  ,-,,(,%++//11?DL#$DEE )-%1s'   *BA9 %BBB9	BBc                    U R                   c6   U R                  R                  5       nUc  SU l        [	        S5      eXl         U R                   b  U R                   $ g! [
         a     N&f = f)zPeek the message at the head of the queue (does not remove it from the queue),
or return None if the queue is empty.

Returns:
    The message or None.
NTr   )rz   r   
get_nowaitrw   rA   r   r   s     r>   _peek_messageMessagePump._peek_messaged  sx       (0--88: ?#'DL+,LMM(/%  ,(((  s   A 
A+*A+F)r[   pausec          	         [        U UU=(       d    S[         R                   3Uc  SO[        U R                  U5      SUS9nUR	                  5         U R
                  R                  U5        U$ )a  Call a function after a delay.

Example:
    ```python
    def ready():
        self.notify("Your soft boiled egg is ready!")
    # Call ready() after 3 minutes
    self.set_timer(3 * 60, ready)
    ```

Args:
    delay: Time (in seconds) to wait before invoking callback.
    callback: Callback to call after time has expired.
    name: Name of the timer (for debug).
    pause: Start timer paused.

Returns:
    A timer object.
z
set_timer#Nr   r[   callbackrepeatr   )r,   _timer_countr	   	call_next_startr|   add)r   delayr   r[   r   timers         r>   	set_timerMessagePump.set_timerz  sg    8 ::e&8&8%9:%-T74>>83T
 	r=   )r[   r   r   c          	         [        U UU=(       d    S[         R                   3UU=(       d    SUS9nUR                  5         U R                  R	                  U5        U$ )a&  Call a function at periodic intervals.

Args:
    interval: Time (in seconds) between calls.
    callback: Function to call.
    name: Name of the timer object.
    repeat: Number of times to repeat the call or 0 for continuous.
    pause: Start the timer paused.

Returns:
    A timer object.
zset_interval#Nr   )r,   r   r   r|   r   )r   intervalr   r[   r   r   r   s          r>   set_intervalMessagePump.set_interval  sY    * ==););(<=>T
 	r=   c                j    [         R                  " [        U/UQ70 UD65      nU R                  U5      $ )ac  Schedule a callback to run after all messages are processed and the screen
has been refreshed. Positional and keyword arguments are passed to the callable.

Args:
    callback: A callable.

Returns:
    `True` if the callback was scheduled, or `False` if the callback could not be
        scheduled (may occur if the message pump was closed or closing).

)r   InvokeLaterr	   post_messager   r   argsr^   r   s        r>   call_after_refreshMessagePump.call_after_refresh  s4     &&wx'I$'I&'IJ  ))r=   c                  #    U R                   c   S5       e[        R                  " 5       U R                   L a  g[        R                  " 5       nU R	                  UR
                  5        UR                  5       I Sh  vN   g N7f)ae  Wait for the next refresh.

This method should only be called from a task other than the one running this widget.
If called from the same task, it will return immediately to avoid blocking the event loop.

Returns:
    `True` if waiting for refresh was successful, or `False` if the call was a null-op
        due to calling it within the node's own task.

Nz4Node must be running before calling wait_for_refreshFT)r{   r   current_taskr'   r  rx   wait)r   refreshed_events     r>   wait_for_refreshMessagePump.wait_for_refresh  st      JJ"	BA	B"!TZZ/!--/ 3 34""$$$ 	%s   A;B=B>Bc                f    [         R                  " [        U/UQ70 UD6S9nU R                  U5      $ )a  Schedule a callback to run after all messages are processed in this object.
Positional and keywords arguments are passed to the callable.

Args:
    callback: Callable to call next.
    *args: Positional arguments to pass to the callable.
    **kwargs: Keyword arguments to pass to the callable.

Returns:
    `True` if the callback was scheduled, or `False` if the callback could not be
        scheduled (may occur if the message pump was closed or closing).

r   )r   r2   r	   r   r  s        r>   
call_laterMessagePump.call_later  s2     //78+Md+Mf+MN  ))r=   c                   Uc   S5       e[         R                  " [        U/UQ70 UD6S9nUR                  R	                  U R                  5       5        U R                  R                  U5        U R                  5         g)zSchedule a callback to run immediately after processing the current message.

Args:
    callback: Callable to run after current event.
    *args: Positional arguments to pass to the callable.
    **kwargs: Keyword arguments to pass to the callable.
NzCallback must not be Noner  )	r   r2   r	   _preventr   r   r   rS   
check_idle)r   r   r  r^   callback_messages        r>   r   MessagePump.call_next  sp     #@%@@#!??GH4Vt4Vv4VW!!(()E)E)GH##$45r=   c                    U R                   R                  (       aW  U R                   R                  R                  UR                  UR
                  =(       d    [        R                  " 5       5        g g r   )r   ru   screen_invoke_laterr   _senderr   rM   r   s     r>   _on_invoke_laterMessagePump._on_invoke_later	  sH    88HHOO))  '//"N5H5L5L5N r=   c                  #    U R                   (       d  U R                  (       a  gSU l        U R                  (       aB  [        R                  " U R                  5      I Sh  vN   U R                  R                  5         [        R                  " U 5        U R                  R                  S5        U(       af  U R                  bX  [        R                  " 5       U R                  :w  a4   [        R                  " 5       nUb  X La   U R                  I Sh  vN   ggggg N! [         a    Sn N1f = f N! [          a     gf = f7f)zHClose message queue, and optionally wait for queue to finish processing.NT)rw   rv   r|   r,   	_stop_allclearr)   _reset_objectr   
put_nowaitr{   r   r  r   rM   r   r   )r   r  running_widgets      r>   _close_messagesMessagePump._close_messages  s     <<4==<<//$,,///LL t$&&t,DJJ*w/C/C/E/S&!4!8!8!: %)C**$$ *D 0T*4	 0  &!%&
 %% sm   AE!D"BE)D! >ED5 D3D5 E!D0-E/D00E3D5 5
E?EEEc                    U R                  5         U R                  R                  (       a!  [        U R	                  5       SU  3S9U l        gSU l        SU l        g)zStart messages task.zmessage pump )r[   TN)r   r   ru   r   _process_messagesr{   rv   rw   r   s    r>   _start_messagesMessagePump._start_messages&  sL    88$&&(tf/EDJ !DMDLr=   c                  #    SU l         U R                  5          U R                  5       I S h  vN (       d  SU l          S S S 5        g  U R                  5       I S h  vN   SU l          U R
                  (       aB  [        R                  " U R
                  5      I S h  vN   U R
                  R                  5         [        R                  " U 5        U R                  5       I S h  vN    S S S 5        S U l        g  N N! [         a     Nf = f Nq N+! U R                  5       I S h  vN    f = f! SU l          U R
                  (       aC  [        R                  " U R
                  5      I S h  vN    U R
                  R                  5         [        R                  " U 5        U R                  5       I S h  vN    f ! U R                  5       I S h  vN    f = f= f! , (       d  f       N= f7f)NTF)ru   _context_pre_process_process_messages_loopr   r|   r,   r  r  r)   _clear_watchers_message_loop_exitr{   r   s    r>   r#  MessagePump._process_messages2  sf    ]]_**,,, % _
411333 !&4||#oodll;;;**,,,T211333# $ 
# -
 4!  < 4$11333 !&4||#oodll;;;**,,,T211333$11333# _s   G1G C<G  	G1
D C>D "G *4DD4DG &D'G ,G1<G >D  
D
D2DD2DG D/(D+
)D//G 2G;4F?/E2
05F?%G8F;
9G?G	GG	GG  
G.*G1c                   #    g7f)z+Called when the message loop has completed.Nr6   r   s    r>   r+  MessagePump._message_loop_exitI  s     s   c                  #     U R                  [        R                  " 5       5      I Sh  vN   U R                  (       aO  U R                  " U R                  6    U R                  [        R
                  " 5       5      I Sh  vN   SSS5        O,U R                  [        R
                  " 5       5      I Sh  vN   U R                  5          U R                  R                  5         SU l        g N Nn! , (       d  f       NE= f NL! [         aF  nU R                  R                  U5         SnAU R                  R                  5         SU l        gSnAff = f! U R                  R                  5         SU l        f = f7f)zxProcedure to run before processing messages.

Returns:
    `True` if successful, or `False` if any exception occurred.

NTF)_dispatch_messager   Composer   r   Mount_post_mount	Exceptionr   _handle_exceptionr   rx   r   )r   errors     r>   r(  MessagePump._pre_processL  s!    	$(()9:::00\\4#D#DE00@@@ FE ,,V\\^<<< ##%#D ; A FE = 	HH&&u- ##%#D	
 ##%#Ds   E?'D C/.D (C3C1C30D 7D8D "E?/D 1C33
D=D 
EE+E /"E?EE #E<<E?c                    g)z)Called after the object has been mounted.Nr6   r   s    r>   r3  MessagePump._post_mountg  s    r=   c                `    U R                   R                  [        R                  " 5       5        g)z.Request the message queue to immediately exit.N)r   r  r   CloseMessagesr   s    r>   _close_messages_no_wait#MessagePump._close_messages_no_waitj  s    &&x'='='?@r=   c              #     #    [         R                  " U 5      n Sv   [         R                  " U5        g! [         R                  " U5        f = f7f)z#Context manager to set ContextVars.N)r   rx   reset)r   reset_tokens     r>   r'  MessagePump._contextn  s<      *--d3	3%%k2%%k2s   A5 AAAc                @   #    U R                  5       I S h  vN   g  N7fr   )r   r   s     r>   _on_close_messagesMessagePump._on_close_messagesw  s     ""$$$s   c                
  #    Sn[         R                  " 5       U l        [        R                  " S5      I Sh  vN   U R
                  (       Gd   U R                  5       I Sh  vN nU R
                  (       dy  U R                  (       dh   U R                  5       nUb  UR                  U5      (       d  O= U R                  5       I Sh  vN nU R
                  (       d  U R                  (       d  Mh   U R                  U5      I Sh  vN    U R&                  R)                  U5        U R*                  R-                  5         [/        5       nU R*                  R1                  5       (       d)  U R2                  b  XPR4                  -
  U R2                  :  as  XPl        U R
                  (       dD  [6        R8                  " 5       nU R;                  SU5       H  u  px [=        X5      I Sh  vN   M     U R?                  5       I Sh  vN   U R
                  (       d  GM  gg GN GN! [         a     g[         a    e [         a  nUSeSnAff = f! [         a     GMi  f = f GN! [         a     GM~  f = f GNm! [         a    e [         Gaw  nU R                  R                  5         SU l        U R"                  R%                  U5         SnAU R&                  R)                  U5        U R*                  R-                  5         [/        5       nU R*                  R1                  5       (       d)  U R2                  b  XPR4                  -
  U R2                  :  a  XPl        U R
                  (       dx  [6        R8                  " 5       nU R;                  SU5       HM  u  px [=        X5      I Sh  vN    M  ! [         a&  nU R"                  R%                  U5         SnA  O
SnAff = f   U R?                  5       I Sh  vN    gggSnAff = f GN ! [         a(  nU R"                  R%                  U5         SnA  GMG  SnAff = f GN<! U R&                  R)                  U5        U R*                  R-                  5         [/        5       nU R*                  R1                  5       (       d)  U R2                  b  XPR4                  -
  U R2                  :  a  XPl        U R
                  (       dx  [6        R8                  " 5       nU R;                  SU5       HM  u  px [=        X5      I Sh  vN    M  ! [         a&  nU R"                  R%                  U5         SnA  O
SnAff = f   U R?                  5       I Sh  vN    f f f = f7f)z+Process messages until the queue is closed.Tr   Non_idle) r   r   r   r   sleeprw   r   rA   r   r4  rv   r   can_replacer0  r   rx   r   r   r5  r   publishr   	task_doner$   emptyr~   r}   r   Idle_get_dispatch_methodsr   _flush_next_callbacks)	r   _rich_traceback_guardr   r6  pendingcurrent_timeevent_clsmethods	            r>   r)  "MessagePump._process_messages_loopz  sJ     $#--/mmA,,,& $ 1 1 33 ||t}}"002G ?'*=*=g*F*F$($5$5$77G ||t}}}7,,W555 ##++G4##--/#v &&,,..NN.$6G&2O<< &,0,F,F%u-LD&&,V&; ; ;	- 44666m ,,, 	 4$ !  &%& ) 
 8(  6!  ##'')#' **51##++G4##--/#v &&,,..NN.$6G&2O<< &,0,F,F%u-LD&&,V&; ; ;#, & $ : :5 A %&- 44666 H /. !<#, & $ : :5 A %& 7+ ##++G4##--/#v &&,,..NN.$6G&2O<< &,0,F,F%u-LD&&,V&; ; ;#, & $ : :5 A %&- 44666 H /s  6U7HU7H# #H $H# ("U7I U76I" 	I
I" "U73I7 I4I7 C
U7P	&P'P	+U7P>U7U7 H# #
I
-U7/I
II

U7
IU7IU7I" "
I1,U70I11U74I7 7P<O>Q C
U7N-%N(&N-+U7-
O7OU7OU75O86U7>PQ P		
P;P6.U76P;;U7CU4T#T
T#!U4#
U	-U	U4U	U4+U.,U44U7c                  #    U R                   R                  5       nU R                   R                  5         U HC  n U R                  " UR                  6    [        UR                  5      I Sh  vN   SSS5        ME     g N! , (       d  f       MY  = f! [         a&  nU R                  R                  U5         SnA  gSnAff = f7f)z1Invoke pending callbacks in next callbacks queue.N)
r   copyr  r   r  r   r   r4  r   r5  )r   	callbacksr   r6  s       r>   rN  !MessagePump._flush_next_callbacks  s     ((--/	""$!H\\8#4#45 !2!2333 65 " 4 65 **51sd   :CBB/B0B4B<CB
B	BCB
CC :C CCc                   #    SnUR                   (       a  g [        R                  " 5       nU" U5        U R                  " UR
                  6    [        U[        5      (       a  U R                  U5      I Sh  vN   OSU R                  R                  ;   a  [        5       nU R                  U5      I Sh  vN   [        5       U-
  [        S-  :  aE  [        R                  " SU R                   R"                   SUR$                   S3S[         S	3S
5        OU R                  U5      I Sh  vN   U R&                  (       a  U R)                  5       I Sh  vN   SSS5        g! [         a     GN<f = f N N NK N$! , (       d  f       g= f7f)zYDispatch a message received from the message queue.

Args:
    message: A message object
TNdebugi  method=<.>z
Took over zms to process.z2
To avoid screen freezes, consider using a worker.)no_dispatchmessage_hook_context_varrM   r   r   r  rW   r'   on_eventr   featuresr
   _on_messager%   r   warningri   r8   handler_namer   rN  )r   r   rO  r   starts        r>   r0  MessagePump._dispatch_message  sS     !%	"3779L !\\7++,'5))mmG,,,DHH---$&&w///>E)NT,AAKK"4>>#:#:";1"//03$^$4NCM	 &&w///##00222# -,  		 - 0 02# -,s   FE$ !F*E=8E59=E=6E77A6E=-E9.(E=E;E=	F$
E2.F1E22F5E=7E=9E=;E==
FFc           	   #  *  #    SSK Jn  [        5       nUR                  R                   Vs/ s H  n[        U[        5      (       d  M  UPM     nnU R                  R                   GH  nUR                  (       a    g[        SUR                  R                  S5      5      nU(       a  U H  n	UR                  U	/ 5      n
U
 H  u  pX;   a  M  U(       d'  X{R                  X5      4v   UR                  U5        M:  UR                  (       d  MM  UR                  5        HI  u  p[        X-5      nUc    Ms  [!        X5      (       d  [#        SU< S35      e[%        X5      (       a  MH    M     X{R                  X5      4v   UR                  U5        M     M     UR                  R                  SU 35      =(       d    UR                  R                  U5      nUc  GMy  [        US	S5      (       a  GM  X{R                  X5      4v   GM     gs  snf 7f)
zeGets handlers from the MRO

Args:
    method_name: Handler method name.
    message: Message object.
r   )WidgetzUdict[type[Message], list[tuple[Callable, dict[str, tuple[SelectorSet, ...]]]]] | NonerI   Nz!on decorator can't match against z as it is not a widget.rL   rJ   )textual.widgetri  rx   ri   __mro__
issubclassr(   _no_default_actionr   __dict__rM   __get__r   r  rU   rQ   rW   r!   r&   )r   method_namer   ri  methods_dispatched_typemessage_mrorZ   decorated_handlersmessage_classr_   rT  rc   	attributeselectorr   s                   r>   rM  !MessagePump._get_dispatch_methods  s     	*,/E&0088
8eJug<VE8 	 
 >>))C))!%g  !67"
 "%0M155mRHH-5)!7$("%~~d'@"@@.226:#*?? (7@7H 3	'.w'B#'<$)'1$'?'?*4*KI=Xo(p+& %& (-X'<'<$) 8I '*>>$+D&D D 2 6 6v >+ .6 &18 \\%%+&78 CLL<L<L=F !'&-*N*N>>$444U *
s*   )HHHDH'A3HH4Hc                B   #    U R                  U5      I Sh  vN   g N7f)z?Called to process an event.

Args:
    event: An Event object.
N)rc  r   rR  s     r>   ra  MessagePump.on_event"  s      u%%%s   c                  #    SnUR                   nSnU R                  X15       H]  u  pV[        R                  R	                  UR
                  5      " USU SUR                   SU S35        Sn[        Xa5      I Sh  vN   M_     U(       d2  [        R                  R	                  UR
                  5      " USU S5        UR                  (       a  U R                  (       a  UR                  (       dw  UR                  b*  UR                  U R                  :X  a  UR                  5         U R                  (       a.  U R                  (       a  UR                  U R                  5        gggggg N7f)	zCCalled to process a message.

Args:
    message: A Message object.
TFz>>>r\  r]  r^  Nzmethod=None)re  rM  r   rR  	verbosityverboser8   r   bubblert   _stop_propagationr  stopr   r   
_bubble_to)r   r   rO  re  
dispatchedrZ   rT  s          r>   rc  MessagePump._on_message*  s     !%++ 
55lLKCII03<<.,q9	 J))) M II0%}U >>dll73L3L*w$,,/N$$)9)9""4<<0 *:$	 4Ml> *s   A:E-<E+=C/E-c                    U R                   (       aE  U R                  R                  5       (       a%  U R                  [        R
                  " 5       5        ggg)z;Prompt the message pump to call idle if the queue is empty.N)ru   r   rK  r   r   Promptr   s    r>   r  MessagePump.check_idleI  s9    ==T006688hoo/0 9=r=   c                ,   #    U R                  U5      $ 7f)a<  Post a message or an event to this message pump.

This is an internal method for use where a coroutine is required.

Args:
    message: A message object.

Returns:
    True if the messages was posted successfully, False if the message was not posted
        (because the message pump was in the process of closing).
)r   r   s     r>   _post_messageMessagePump._post_messageN  s        ))s   c                *   Sn[        US5      (       d  [        S5      eU R                  (       d  U R                  (       a  gU R	                  U5      (       d  gUR
                  R                  U R                  5       5        U R                  [        R                  " 5       :w  aT  U R                  R                  b=  U R                  R                  nUR                  U R                  R                  U5        gU R                  R                  U5        g)zPosts a message on to this widget's queue.

Args:
    message: A message (including Event).

Returns:
    `True` if the message was queued for processing, otherwise `False`.
Tr  zJMessage is missing attributes; did you forget to call super().__init__() ?F)rP   RuntimeErrorrv   rw   r   r  r   r   r   r   r   r   _loopcall_soon_threadsafer   r  )r   r   _rich_traceback_omitloops       r>   r   MessagePump.post_message\  s      $w
++\  ==DLL))'22 	 < < >???i11338R88>>D%%d&9&9&D&DgN  **73r=   c                $  #    U R                   R                  (       a  g  U R                   R                    [        UR                  5      I S h  vN   g ! [         a-    U R                  R                  SUR                  < S35         g f = f N?7f)NNot invoking timer callback  because there is no screen.)r   rv   r  r4  r   rd  r   r   rz  s     r>   on_callbackMessagePump.on_callbackz  sx     88	HHOO U^^$$$  	HH.u~~.@@\] 		
 	%s3   BA BBB4BB
BBc                  #    U R                   R                  (       d  g UR                  5         UR                  5         UR                  b6   U R                   R
                     [        UR                  5      I S h  vN   g g ! [         a-    U R                  R                  SUR                  < S35         g f = f N@! [         a!  n[        SUR                  < SU 35      eS nAff = f7f)Nr  r  zunable to run callback z; )r   ru   prevent_defaultr  r   r  r4  r   rd  r   r4   )r   rR  r6  s      r>   on_timerMessagePump.on_timer  s     xx  

>>%U^^,,, &    25>>2DD`a 	 - #-enn-?r%I sZ   A
C-B $B? <B==B? C-4B:7C-9B::C-=B? ?
C*	C%%C**C-)__parentrw   rv   ry   r   r}   r~   r   rt   rz   r   ru   r{   r   r|   r   r   )r   MessagePump | Nonerl   None)rl   r  )rl   zQueue[Message | None])rl   zasyncio.Event)rl   zlist[set[type[Message]]])rl   zset[type[Message]])rb   type[Message]rl   r   )r   r  rl   Generator[None, None, None])rl   r   )rl   r   )rl   int)rl   z'App[object]')rl   r   )r   rp   rl   r  )rl   r  )r   r(   rl   r   )r   r  rl   r  )rl   r(   )rl   zMessage | None)
r   floatr   TimerCallback | Noner[   
str | Noner   r   rl   r,   )r   r  r   r  r[   r  r   r  r   r   rl   r,   )r   r2   r  r   r^   r   rl   r   )r   r2   r  r   r^   r   rl   r  )r   zmessages.InvokeLaterrl   r  )T)r  r   rl   r  )rl   r  )r   zmessages.CloseMessagesrl   r  )r   r(   rl   r  )rp  rk   r   r(   rl   z5Iterable[tuple[type, Callable[[Message], Awaitable]]])rR  zevents.Eventrl   r  )rR  zevents.Callbackrl   r  )rR  zevents.Timerrl   r  )Br8   r9   r:   r;   rm   r   propertyrt   setterr   r   r   r   r   r   r   r   r   r   r   r   r   r   textualr   r   r0   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r	  r  r   r  r   r$  r#  r+  r(  r3  r<  r'  rC  r)  rN  r0  rM  ra  rc  r  r  r   r  r  r<   r6   r=   r>   rp   rp   s   s   38 B B ^^@ @      5
E  (   ( ( + +   #kk# 
	 
	.   W W
      
<1<*2 *.&
  && '&
 & & 
&V *.
   '
    
B*$**",
 .:68A 3 3%;7z
"3H9595)095	>95v&1>1
*<
%r=   rp   )	metaclass)Prm   
__future__r   r   r   r   r   r   r   
contextlibr   	functoolsr	   r$   r
   typingr   r   r   r   r   r   r   r   r   weakrefr   r   r  r   r   r   r   textual._callbackr   textual._compatr   textual._contextr   r   r   r   r`  r    textual._onr!   textual._queuer#   textual._timetextual.constantsr%   textual.css.matchr&   textual.eventsr'   textual.messager(   textual.reactiver)   r*   textual.signalr+   textual.timerr,   r-   typing_extensionsr.   r   r0   textual.css.modelr1   r2   __annotations__r4  r4   rA   rC   r   rD   rp   r6   r=   r>   <module>r     s    #   A A %  
 
 
 ! 1 1 $ + N N E 8 "    , #   # ; ! .+- K) J	I 			 	 3;MN *t *Ze, er=   