
    AHj                        U d Z ddlmZ ddlmZmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZmZmZ dd	lmZ ed
   Zded<   	 e G d ded             Ze G d d             Z G d d      Zy)z8Provides classes for holding and managing notifications.    )annotations)	dataclassfield)time)Iterator)uuid4)Result)LiteralSelf	TypeAlias)Message)informationwarningerrorr   SeverityLevelc                      e Zd ZU dZded<   y)NotifyzMessage to show a notification.NotificationnotificationN)__name__
__module____qualname____doc____annotations__     M/root/tools/cai/cai_env/lib/python3.12/site-packages/textual/notifications.pyr   r      s    )r   r   F)bubblec                      e Zd ZU dZded<   	 dZded<   	 dZded<   	 d	Zd
ed<   	 dZded<   	  e	e
      Zd
ed<   	  e	d       Zded<   	 edd       Zedd       ZddZy)r   z$Holds the details of a notification.strmessage titler   r   severity   floattimeoutFboolmarkup)default_factory	raised_atc                 (    t        t                     S N)r    r   r   r   r   <lambda>zNotification.<lambda>0   s    #eg, r   identityc                J    | j                   | j                  z   t               z
  S )z-The time left until this notification expires)r+   r'   r   selfs    r   	time_leftzNotification.time_left3   s     -77r   c                     | j                   dk  S )zHas the notification expired?r   )r3   r1   s    r   has_expiredzNotification.has_expired8   s     ~~""r   c              #     K   d| j                   f d| j                  df d| j                  f d| j                  f d| j                  f d| j
                  f d| j                  f y w)	Nr!   r#   r"   r$   	raised_itr/   r3   r5   )r!   r#   r$   r+   r/   r3   r5   r1   s    r   __rich_repr__zNotification.__rich_repr__=   ss     %%tzz2%%$--''4>>))$--''4>>))T----s   A3A5N)returnr&   )r9   r(   )r9   r	   )r   r   r   r   r   r#   r$   r'   r)   r   r   r+   r/   propertyr3   r5   r8   r   r   r   r   r      s    .L+E3O)+Hm+2GU8FD<T2Iu2C*>?Hc?28 8 # #.r   r   c                  P    e Zd ZdZddZddZddZddZddZddZ	ddZ
dd	Zy
)Notificationsz1Class for managing a collection of notifications.c                    i | _         y)z'Initialise the notification collection.N)_notificationsr1   s    r   __init__zNotifications.__init__J   s
    79r   c                    t        | j                  j                               D ]&  }|j                  s| j                  |j                  = ( | S )zBRemove any expired notifications from the notification collection.)listr>   valuesr5   r/   r2   r   s     r   _reapzNotifications._reapN   sI     !4!4!;!;!=> 	?L''''(=(=>	? r   c                T    || j                         j                  |j                  <   | S )zAdd the given notification to the collection of managed notifications.

        Args:
            notification: The notification to add.

        Returns:
            Self.
        )rD   r>   r/   rC   s     r   addzNotifications.addU   s&     >J

##L$9$9:r   c                :    | j                   j                          | S )zClear all the notifications.)r>   clearr1   s    r   rH   zNotifications.cleara   s    !!#r   c                H    t        | j                         j                        S )zThe number of notifications.)lenrD   r>   r1   s    r   __len__zNotifications.__len__f   s    4::<..//r   c                d    t        | j                         j                  j                               S r-   )iterrD   r>   rB   r1   s    r   __iter__zNotifications.__iter__j   s"    DJJL//66899r   c                2    |j                   | j                  v S r-   )r/   r>   rC   s     r   __contains__zNotifications.__contains__m   s    $$(;(;;;r   c                n    	 | j                         j                  |j                  = y # t        $ r Y y w xY wr-   )rD   r>   r/   KeyErrorrC   s     r   __delitem__zNotifications.__delitem__p   s5    	

++L,A,AB 	
 	s   %( 	44N)r9   None)r9   r   )r   r   r9   r   )r9   int)r9   zIterator[Notification])r   r   r9   r(   )r   r   r9   rT   )r   r   r   r   r?   rD   rF   rH   rK   rN   rP   rS   r   r   r   r<   r<   G   s-    ;:

0:<r   r<   N)r   
__future__r   dataclassesr   r   r   typingr   uuidr   	rich.reprr	   typing_extensionsr
   r   r   textual.messager   r   r   r   r   r<   r   r   r   <module>r]      sw    > " (     6 6 #"#DEy E , WU   ). ). ).X1 1r   