Ë
    >—Öj-  ã                   ó‚   — d dl Z d dlmZ d dlmZ d dlmZ d dlmZ erd dlmZ d dlm	Z	  G d„ d	«      Z
 G d
„ de
«      Zy)é    N)ÚTYPE_CHECKING)ÚList)ÚOptional)ÚTuple)ÚPreparedRequest)ÚBaseResponsec                   ó„   — e Zd Zdd„Zeded   fd„«       Zdd„Zdddee	d   ee
   f   fd	„Zdd„Zd
dded   fd„Zdd„Zy)ÚFirstMatchRegistryÚreturnNc                 ó   — g | _         y ©N©Ú
_responses©Úselfs    úQ/var/www/photos/backend/venv/lib/python3.12/site-packages/responses/registries.pyÚ__init__zFirstMatchRegistry.__init__   s	   € Ø02ˆ�ó    r   c                 ó   — | j                   S r   r   r   s    r   Ú
registeredzFirstMatchRegistry.registered   s   € à�‰Ðr   c                 ó   — g | _         y r   r   r   s    r   ÚresetzFirstMatchRegistry.reset   s	   € Øˆ�r   Úrequestr   c                 óf  — d }d }g }t        | j                  «      D ]�  \  }}|j                  |«      \  }}|rd|€|}|}Œ#| j                  |   j                  dkD  r"| j                  j	                  |«       |} ||fS | j                  j	                  |«      |fc S |j                  |«       Œ’ ||fS )Nr   )Ú	enumerater   ÚmatchesÚ
call_countÚpopÚappend)	r   r   ÚfoundÚfound_matchÚmatch_failed_reasonsÚiÚresponseÚmatch_resultÚreasons	            r   ÚfindzFirstMatchRegistry.find   sÏ   € ð ˆØˆØ!ÐÜ$ T§_¡_Ó5ò 	4‰KˆAˆxØ#+×#3Ñ#3°GÓ#<Ñ ˆL˜&ÙØ�=Ø�EØ"*‘Kà—‘ uÑ-×8Ñ8¸1Ò<àŸ™×+Ñ+¨EÔ2Ø&.˜Øð
 Ð0Ð0Ð0ð  Ÿ?™?×.Ñ.¨uÓ5Ð7KÐKÒKà$×+Ñ+¨FÕ3ð	4ð  Ð0Ð0Ð0r   r$   c                 ó¤   ‡— t        ˆfd„| j                  D «       «      rt        j                  ‰«      Š| j                  j	                  ‰«       ‰S )Nc              3   ó&   •K  — | ]  }‰|u –— Œ
 y ­wr   © )Ú.0Úrespr$   s     €r   ú	<genexpr>z)FirstMatchRegistry.add.<locals>.<genexpr>2   s   øè ø€ Ò< Dˆx˜4ÔÑ<ùs   ƒ)Úanyr   ÚcopyÚdeepcopyr   )r   r$   s    `r   ÚaddzFirstMatchRegistry.add1   s<   ø€ ÜÓ<¨D¯O©OÔ<Ô<ô —}‘} XÓ.ˆHà�‰×Ñ˜xÔ(Øˆr   c                 óœ   — g }|| j                   v r;| j                   j                  |«       |j                  |«       || j                   v rŒ;|S r   )r   Úremover   )r   r$   Úremoved_responsess      r   r3   zFirstMatchRegistry.remove;   sJ   € ØÐØ˜$Ÿ/™/Ñ)Ø�O‰O×"Ñ" 8Ô,Ø×$Ñ$ XÔ.ð ˜$Ÿ/™/Ò)ð !Ð r   c                 ó¦   — 	 | j                   j                  |«      }|| j                   |<   |S # t        $ r t        d|j                  › �«      ‚w xY w)Nz#Response is not registered for URL )r   ÚindexÚ
ValueErrorÚurl)r   r$   r6   s      r   ÚreplacezFirstMatchRegistry.replaceB   s[   € ð	SØ—O‘O×)Ñ)¨(Ó3ˆEð "*ˆ�‰˜ÑØˆøô ò 	SÜÐBÀ8Ç<Á<À.ÐQÓRÐRð	Sús	   ‚. ®"A)r   N)r$   r   r   r   )Ú__name__Ú
__module__Ú__qualname__r   Úpropertyr   r   r   r   r   Ústrr'   r1   r3   r9   r*   r   r   r
   r
      sv   „ ó3ð ð˜D Ñ0ò ó ðóð1Ø(ð1à	ˆx˜Ñ'¨¨c©Ð2Ñ	3ó1ó0ð!˜~ð !°$°~Ñ2Fó !ôr   r
   c                   ó6   — e Zd ZdZdddeed   ee   f   fd„Zy)ÚOrderedRegistrya  Registry where `Response` objects are dependent on the insertion order and invocation index.

    OrderedRegistry applies the rule of first in - first out. Responses should be invoked in
    the same order in which they were added to the registry. Otherwise, an error is returned.
    r   r   r   r   c                 óæ   — | j                   sddgfS | j                   j                  d«      }|j                  |«      \  }}|s,| j                  «        | j	                  |«       d|› d�}d|gfS |g fS )aR  Find the next registered `Response` and check if it matches the request.

        Search is performed by taking the first element of the registered responses list
        and removing this object (popping from the list).

        Parameters
        ----------
        request : PreparedRequest
            Request that was caught by the custom adapter.

        Returns
        -------
        Tuple[Optional["BaseResponse"], List[str]]
            Matched `Response` object and empty list in case of match.
            Otherwise, None and a list with reasons for not finding a match.

        NzNo more registered responsesr   zHNext 'Response' in the order doesn't match due to the following reason: ú.)r   r   r   r   r1   )r   r   r$   r%   r&   s        r   r'   zOrderedRegistry.findR   s‰   € ð* �ŠØÐ8Ð9Ð9Ð9à—?‘?×&Ñ& qÓ)ˆØ'×/Ñ/°Ó8Ñˆ�fÙØ�J‰JŒLØ�H‰H�XÔð0Ø06¨x°qð:ð ð ˜&˜�>Ð!à˜ˆ|Ðr   N)	r:   r;   r<   Ú__doc__r   r   r   r>   r'   r*   r   r   r@   r@   K   s/   „ ñð#Ø(ð#à	ˆx˜Ñ'¨¨c©Ð2Ñ	3ô#r   r@   )r/   Útypingr   r   r   r   Úrequestsr   Ú	responsesr   r
   r@   r*   r   r   ú<module>rG      s5   ðÛ Ý  Ý Ý Ý áå(å&÷:ñ :ôz*Ð(õ *r   