
    ɯei                     T    d Z ddlZddlmZmZmZmZ ddlmZ ddl	m
Z
  G d d      Zy)	z3
Widgets with notification queueing for Streamlit.
    N)AnyCallableLiteralOptional   )NotificationQueue)StatusElementNotificationc            	           e Zd ZdZdedef   ddfdZedefd       Z	ededef   fd       Z
edefd	       Zedefd
       ZddZdededdfdZdededefdZ	 	 	 ddedee   ded   ddfdZdefdZdefdZy)RerunnableStatusElementzJ
    A wrapper for Streamlit widgets to enable notification queueing.
    base_widget.returnNc                     || _         d| j                   j                  j                          d| _        t	        | j                        | _        y)zInitialize the wrapper.
ST_NOTIFY__QUEUEN)_base_widget__name__upper_session_state_keyr   _queue)selfr   s     b/var/www/html/glpi_dashboard/venv/lib/python3.12/site-packages/streamlit_notify/status_elements.py__init__z RerunnableStatusElement.__init__   sH    '**3399;<FC 	 ((?(?@    c                     | j                   S )z5Get the session state key for the notification queue.)r   r   s    r   session_state_keyz)RerunnableStatusElement.session_state_key   s     &&&r   c                     | j                   S )zGet the base widget function.)r   r   s    r   r   z#RerunnableStatusElement.base_widget   s        r   c                 .    | j                   j                  S )z Get the name of the base widget.r   r   r   s    r   namezRerunnableStatusElement.name#   s       )))r   c                     | j                   S )zGet the notification queue.)r   r   s    r   notificationsz%RerunnableStatusElement.notifications(   s     {{r   c                 8    | j                   j                          y)z9Ensure the notification queue is set up in session state.N)r   ensure_queuer   s    r   setup_queuez#RerunnableStatusElement.setup_queue-   s      "r   argskwargsc                 ^     | j                   |i |}| j                  j                  |       y)z Add a notification to the queue.N)create_notificationr   append)r   r&   r'   notifications       r   __call__z RerunnableStatusElement.__call__1   s+    /t//@@<(r   c                     |j                  dd      }|j                  dd      }t        j                  | j                        } |j                  |i |}t        | j                  |j                  ||      S )z5Create a notification without adding it to the queue.priorityr   dataN)r   r&   r.   r/   )popinspect	signaturer   bind_partialr	   	arguments)r   r&   r'   r.   r/   r2   
bound_argss          r   r)   z+RerunnableStatusElement.create_notification6   sv     ::j!,zz&$'%%d&7&78	+Y++T<V<
())%%	
 	
r   remover.   priority_type)leltgegteqc                     | j                   j                  ||      D ]0  }|j                          |s| j                   j                  |       2 y)z
        Display all queued notifications. Will display in order of priority and remove
        from queue if specified.
        )r.   r7   N)r"   get_allnotifyr6   )r   r6   r.   r7   r+   s        r   r?   zRerunnableStatusElement.notifyF   sS     !..66] 7 
 	8L !"")),7	8r   c                 6    d| j                   j                   dS z%String representation of the wrapper.zRerunnableStatusElement()r   r   s    r   __repr__z RerunnableStatusElement.__repr__W       )$*;*;*D*D)EQGGr   c                 6    d| j                   j                   dS rA   r   r   s    r   __str__zRerunnableStatusElement.__str__[   rD   r   )r   N)TNr<   )r   
__module____qualname____doc__r   r   r   propertystrr   r   r    r   r"   r%   r,   r	   r)   boolr   intr   r?   rC   rF    r   r   r   r      s4   AHS#X$6 A4 A '3 ' ' !Xc3h/ ! ! *c * * 0  #)c )S )T )


$'
	"
$ "&?C	88 3-8 ;<	8
 
8"H# HH Hr   r   )rI   r1   typingr   r   r   r   notification_queuer   notification_dataclassr	   r   rN   r   r   <module>rR      s)     3 3 1 =QH QHr   