
    cec*                       U d Z ddlmZ dZddlZddlZddlmZm	Z	 ej
        rddlZdZded<   d	Zded
<    G d d          Z G d dej        e                   Z G d de          Z G d d          Z e            Zded<   dS )zNotification utilities.    )annotations)NotificationNotificationListenerNotificationQueueNOTIFICATION_QUEUEN)QObjectSignalzNotification | strztyping_extensions.TypeAliasRawNotificationzBRawNotification | collections.abc.Iterable[RawNotification] | NoneNotificationSourcec                      e Zd ZdZdZ	 	 dddZedd            Zedd            Zedd            Z	ddZ
ddZddZddZdS )r   z"Details on a notification to show.)	__caption	__hashsum	__message__tags messagestrcaptiontags#collections.abc.Iterable[str] | strreturnNonec                   t          |t                    st          |t          j        j                  st          |          f}n/t          t          t          t          |                              }t          |          | _        t          |          | _	        || _
        t          | j        | j	        f|z             | _        dS )z2Initialize new instance of :class:`~Notification`.N)
isinstancer   collectionsabcIterabletuplesortedmap_Notification__caption_Notification__message_Notification__tagshash_Notification__hashsum)selfr   r   r   s       Flib/python3.11/site-packages/anaconda_navigator/utils/notifications.py__init__zNotification.__init__   s     dC   	1D+/:R)S)S 	1II<DDC//00D,/LL,/LL59,0$.$.1QTX1X,Y,Y    c                    | j         S )z$Caption for the notification window.)r!   r&   s    r'   r   zNotification.caption,        ~r)   c                    | j         S )zContent of the notification.r"   r+   s    r'   r   zNotification.message1   r,   r)   tuple[str, ...]c                    | j         S )z Extra tags for the notification.)r#   r+   s    r'   r   zNotification.tags6   s     {r)   other
typing.Anyboolc                    t          |t                    r0| j        |j        k    o| j        |j        k    o| j        |j        k    S t
          S )z*Check if instance is equal to another one.)r   r   r   r   r   NotImplemented)r&   r1   s     r'   __eq__zNotification.__eq__;   sJ    e\** 	uLEM1t8Ut\`\einis\str)   intc                    | j         S )z!Retrieve hash sum of an instance.)r%   r+   s    r'   __hash__zNotification.__hash__A   
    ~r)   c                `    t          |           j         d| j        d| j        d| j        dS )-Prepare string representation of an instance.z	(message=z
, caption=z, tags=))type__name__r"   r!   r#   r+   s    r'   __repr__zNotification.__repr__E   s:    t**%uuuuDNuueiepuuuur)   c                    | j         S r<   r.   r+   s    r'   __str__zNotification.__str__I   r:   r)   Nr   r   )r   r   r   r   r   r   r   r   r   r   )r   r/   )r1   r2   r   r3   r   r7   )r?   
__module____qualname____doc__	__slots__r(   propertyr   r   r   r6   r9   r@   rC   r   r)   r'   r   r      s        ,,AI
 *8:	Z Z Z Z Z"    X    X    X      v v v v     r)   r   c                  (   e Zd ZdZdZd0d1dZe	 	 d2d3d            Zd4dZd5dZ		 	 	 	 d6d7dZ
d8dZd9d!Zej        d:d"            Zej        d;d$            Zd<d&Zd=d(Zd>d)Zd?d*Zej        d5d+            Zej        d@d,            ZdAd.Zd?d/ZdS )BNotificationCollectionz/Collection of :class:`~Notification` instances.)	__contentr   content&collections.abc.Iterable[Notification]r   r   c                .    t          |          | _        dS )z<Initialize new instance of :class:`~NotificationCollection`.N)list _NotificationCollection__content)r&   rO   s     r'   r(   zNotificationCollection.__init__S   s    ;?==r)   r   r   r   r   r   r   #str | collections.abc.Sequence[str]c                ,   g }| g } n>t          | t          t          f          st          | t          j        j                  s| g} | D ]>}t          |t                    st          |||          }|                    |           ?t          |          S )ao  
        Collect notifications from a :class:`~Notification` compatible source.

        :param message: Message text or source (existing :class:`~Notification` or list of them).
        :param caption: Default caption to apply to non :class:`~Notification` source items.
        :param tags: Default tags to apply to non :class:`~Notification` source items.
        N)r   r   r   )r   r   r   r   r   r   appendrM   )r   r   r   resultitems        r'   collectzNotificationCollection.collectW   s     &(?GG,!455 	 jR]RaRj>k>k 	 iG  	  	 DdL11 N#GTMMMMM$%f---r)   items'collections.abc.Container[Notification]c                D    t          fd| j        D                       S )z\Prepare a new :code:`~NotificationCollection` from the current content except :code:`items`.c              3  $   K   | ]
}|v|V  d S Nr   ).0rX   rZ   s     r'   	<genexpr>z1NotificationCollection.exclude.<locals>.<genexpr>u   s:       &
 &
5       &
 &
r)   )rM   rS   )r&   rZ   s    `r'   excludezNotificationCollection.excludes   s=    % &
 &
 &
 &
&
 &
 &
 
 
 	
r)   indexr7   valuec                <    | j                             ||           dS )z*Insert new :code:`value` at :code:`index`.N)rS   insertr&   rb   rc   s      r'   re   zNotificationCollection.insert{   s     eU+++++r)   NF
str | None*collections.abc.Iterable[str] | str | Nonestrictr3   c                0   g                      fd                                fd           t          t                    st          t          j        j                  sg|rHt          t          t          t                                                             fd           n:t          t          t                                                   fd           t          fd| j        D                       S )a  
        Filter current collection to only include notifications with particular properties.

        :param message: Expected value of a :attr:`~Notification.message`.
        :param caption: Expected value of a :attr:`~Notification.caption`.
        :param tags: Expected subset of :attr:`~Notification.tags`.
        :param strict: Use :code:`tags` for a full comparison instead of just subset.
        Nc                    | j         k    S r^   )r   )rX   r   s    r'   <lambda>z-NotificationCollection.only.<locals>.<lambda>       4<7+B r)   c                    | j         k    S r^   )r   )rX   r   s    r'   rl   z-NotificationCollection.only.<locals>.<lambda>   rm   r)   c                    | j         k    S r^   )r   rX   r   s    r'   rl   z-NotificationCollection.only.<locals>.<lambda>   s    tyD/@ r)   c                ^    t          j        d                              | j                  S )Nzset[str])typingcastissubsetr   rp   s    r'   rl   z-NotificationCollection.only.<locals>.<lambda>   s%    v{:t/L/L/U/UVZV_/`/` r)   c              3  T   K   | ]!t          fd D                       V  "dS )c              3  .   K   | ]} |          V  d S r^   r   )r_   	conditionrX   s     r'   r`   z8NotificationCollection.only.<locals>.<genexpr>.<genexpr>   s+      ??y99T????????r)   N)all)r_   rX   
conditionss    @r'   r`   z.NotificationCollection.only.<locals>.<genexpr>   s[       &
 &
????J?????&
&
 &
 &
 &
 &
 &
r)   )rV   r   r   r   r   r   r   r   r    setrM   rS   )r&   r   r   r   ri   ry   s    ``` @r'   onlyzNotificationCollection.only   s@    LN
BBBBCCCBBBBCCC$$$ Zko>V-W-W v bVCTNN3344!!"@"@"@"@AAAA3sD>>**!!"`"`"`"`aaa% &
 &
 &
 &
&
 &
 &
 
 
 	
r)   c                p    t                                          fd| j        D                        S )zRPrepare a new :class:`~NotificationCollection` that only contains unique elements.c              3  $   K   | ]
}|v|V  d S r^   r   )r_   rX   rW   s     r'   r`   z0NotificationCollection.unique.<locals>.<genexpr>   s-      LLtV9K9Kd9K9K9K9KLLr)   )rM   extendrS   )r&   rW   s    @r'   uniquezNotificationCollection.unique   s<    )?)A)ALLLLt~LLLLLLr)   int | slicec                    | j         |= dS )zRemove item by its index.NrS   r&   rb   s     r'   __delitem__z"NotificationCollection.__delitem__   s    N5!!!r)   c                    dS #Retrieve content from a collection.Nr   r   s     r'   __getitem__z"NotificationCollection.__getitem__         r)   slicec                    dS r   r   r   s     r'   r   z"NotificationCollection.__getitem__   r   r)   %Notification | NotificationCollectionc                z    t          |t                    rt          | j        |                   S | j        |         S )r   )r   r   rM   rS   r   s     r'   r   z"NotificationCollection.__getitem__   s7    eU## 	A)$.*?@@@~e$$r)   &collections.abc.Iterator[Notification]c                *    t          | j                  S )z,Iterate through the content of a collection.)iterrS   r+   s    r'   __iter__zNotificationCollection.__iter__   s    DN###r)   c                *    t          | j                  S )z@Retrieve total number of added :class:`~Notification` instances.)lenrS   r+   s    r'   __len__zNotificationCollection.__len__       4>"""r)   c                Z    t          |           j         dt          | j                   dS )r<   (r=   )r>   r?   reprrS   r+   s    r'   r@   zNotificationCollection.__repr__   s,    t**%??T^(<(<????r)   c                    dS zUpdate value of an item.Nr   rf   s      r'   __setitem__z"NotificationCollection.__setitem__   r   r)   c                    dS r   r   rf   s      r'   r   z"NotificationCollection.__setitem__   r   r)   5Notification | collections.abc.Iterable[Notification]c                    || j         |<   dS r   r   rf   s      r'   r   z"NotificationCollection.__setitem__   s     %ur)   c                *    t          | j                  S rB   )r   rS   r+   s    r'   rC   zNotificationCollection.__str__   r   r)   )r   )rO   rP   r   r   rD   )r   r   r   r   r   rT   r   rM   )rZ   r[   r   rM   )rb   r7   rc   r   r   r   )NNNF)
r   rg   r   rg   r   rh   ri   r3   r   rM   )r   rM   )rb   r   r   r   )rb   r7   r   r   )rb   r   r   rM   )rb   r   r   r   )r   r   rF   rE   )rb   r   rc   rP   r   r   )rb   r   rc   r   r   r   )r?   rG   rH   rI   rJ   r(   staticmethodrY   ra   re   r{   r   r   rr   overloadr   r   r   r@   r   rC   r   r)   r'   rM   rM   N   s       99II I I I I  *8:. . . . \.6
 
 
 
, , , , #'"&?C %
 %
 %
 %
 %
N   " " " " _2 2 2 _2 _2 2 2 _2% % % %$ $ $ $# # # #@ @ @ @ _' ' ' _' _' ' ' _'& & & &# # # # # #r)   rM   c                  0    e Zd ZdZ ee          ZddZdS )	r   z#Dynamic listener for notifications.notificationr   r   r   c                :    | j                             |           dS )z&Push new notification to the listener.N)sig_notificationemit)r&   r   s     r'   pushzNotificationListener.push   s    ""<00000r)   N)r   r   r   r   )r?   rG   rH   rI   r	   r   r   r   r   r)   r'   r   r      s>        --vl++1 1 1 1 1 1r)   r   c                  <    e Zd ZdZdZddZddZ	 	 ddddddZdS )r   zNotification dialogs queue.)	__history
__listener__queuer   r   c                j    t                      | _        d| _        t          j                    | _        dS )z7Initialize new instance of :class:`~NotificationQueue`.N)rz   _NotificationQueue__history_NotificationQueue__listenerr   deque_NotificationQueue__queuer+   s    r'   r(   zNotificationQueue.__init__   s(    :=%%7;FQFWFYFYr)   listenerr   c                    || _         | j        r:| j                             | j                                                   | j        8dS dS )z
        Attach listener to the queue.

        If there are any notifications pending - all of them will be dumped into the :code:`listener`.
        N)r   r   r   popleft)r&   r   s     r'   attachzNotificationQueue.attach   sY     #l 	9O  !5!5!7!7888 l 	9 	9 	9 	9 	9r)   r   r   FT)oncer   r   r   r   r   r   #collections.abc.Sequence[str] | strr   r3   r   rM   c                  t                               |||          }|}|s|r|                                }|r4|                    | j                  }| j                            |           | j        7|r|                    | j                  }| j                            |           n|D ]}| j        	                    |           |S )av  
        Push new notification to the queue.

        :param message: Message text or source (existing :class:`~Notification` or list of them).
        :param caption: Default caption to apply to non :class:`~Notification` source items.
        :param tags: Default tags to apply to non :class:`~Notification` source items.
        :param once: Show each notification only once per application session.
        :param unique: Show each notification only once per :meth:`~NotificationQueue.push` request. May also hide
                       duplicates until the listener is attached via :meth:`~NotificationQueue.attach`.
        )r   r   r   )
rM   rY   r   ra   r   updater   r   r~   r   )	r&   r   r   r   r   r   rW   deltaraws	            r'   r   zNotificationQueue.push   s    & *@)G)GPWahos)G)t)t(. 	#T 	#LLNNE 	)MM$.11EN!!%(((?" 4dl33L&&&& * *$$S))))r)   N)r   r   )r   r   r   r   rD   )r   r   r   r   r   r   r   r3   r   r3   r   rM   )r?   rG   rH   rI   rJ   r(   r   r   r   r)   r'   r   r      s~        %%6IZ Z Z Z9 9 9 9 *8:	$ $ $ $ $ $ $ $ $r)   r   ztyping.Final[NotificationQueue]r   )rI   
__future__r   __all__collections.abcr   rr   qtpy.QtCorer   r	   TYPE_CHECKINGtyping_extensionsr
   __annotations__r   r   MutableSequencerM   r   r   r   r   r)   r'   <module>r      sl      " " " " " "
]      ' ' ' ' ' ' ' '	  0D C C C C2v  v v v v5 5 5 5 5 5 5 5pJ# J# J# J# J#V3LA J# J# J#Z1 1 1 1 17 1 1 19 9 9 9 9 9 9 9x 7H6G6I6I  I I I I I Ir)   