Ë
    òÏjÁ  ã            	       óî   — d dl Zd dl mZmZ d dlmZmZ d dlmZm	Z	m
Z
 d dlmZ d dlmZ d dlmZmZ d dlmZmZmZmZ d d	lmZ d
Zd„ Zdedeeef   fd„Zdededefd„Z G d„ dee   eeeef   «      Zy)é    N)ÚCallableÚSequence)ÚAnyÚGeneric)ÚNotRequiredÚRequiredÚSelf)Ú	OVERWRITE)ÚMISSING)ÚBaseChannelÚValue)ÚEmptyChannelErrorÚ	ErrorCodeÚInvalidUpdateErrorÚcreate_error_message)Ú	Overwrite)ÚBinaryOperatorAggregatec                 ó¨   — t        | d«      rE| j                  t        t        fv rt	        | j
                  d   «      S t	        | j                  «      S | S )z=Strips Annotated, Required and NotRequired from a given type.Ú
__origin__r   )Úhasattrr   r   r   Ú_strip_extrasÚ__args__)Úts    úU/var/www/html/gaurav-v2/venv/lib/python3.12/site-packages/langgraph/channels/binop.pyr   r      sD   € äˆq�,ÔØ�<‰<œH¤kÐ2Ñ2Ü  §¡¨A¡Ó/Ð/Ü˜QŸ\™\Ó*Ð*Ø€Hó    ÚvalueÚreturnc                 óè   — t        | t        «      rd| j                  fS t        | t        «      rDt	        | «      dk(  rt
        | v rd| t
           fS | j                  d«      t
        k(  rd| v rd| d   fS y)a  Inspects the given value and returns (is_overwrite, overwrite_value).

    Recognises three forms:

    * The typed `Overwrite` dataclass instance.
    * The sentinel-keyed `{"__overwrite__": value}` dict form.
    * The dataclass-erased `{"value": ..., "type": "__overwrite__"}` form that
      results from JSON-serialising an `Overwrite` (e.g. an `orjson`-encoded
      state update routed through the LangGraph API server). This keeps the
      `Overwrite` semantics intact across JSON boundaries that strip dataclass
      types.
    Té   Útyper   )FN)Ú
isinstancer   r   ÚdictÚlenr
   Úget©r   s    r   Ú_get_overwriter&      ss   € ô �%œÔ#Ø�U—[‘[Ð Ð Ü�%œÔÜˆu‹:˜Š?œy¨EÑ1Ø˜œyÑ)Ð)Ð)Ø�9‰9�VÓ¤	Ò)¨g¸Ñ.>Ø˜˜w™Ð'Ð'Ør   ÚaÚbc                 óH   — | j                   dk(  s|j                   dk(  ry| |u S )zÍReturn True if two reducer operators should be considered equal.

    Lambdas all share the name '<lambda>' so identity comparison is
    unreliable; treat any pairing that includes a lambda as equal.
    z<lambda>T)Ú__name__)r'   r(   s     r   Ú_operators_equalr+   6   s'   € ð 	‡z�z�ZÒ 1§:¡:°Ò#;ØØ�ˆ6€Mr   c                   óâ   ‡ — e Zd ZdZdZdee   deeegef   fˆ fd„Zde	de
fd„Zedee   fd	„«       Zedee   fd
„«       Zdefd„Zdedefd„Zdee   de
fd„Zdefd„Zde
fd„Zdefd„Zˆ xZS )r   zÉStores the result of applying a binary operator to the current value and each new value.

    ```python
    import operator

    total = Channels.BinaryOperatorAggregate(int, operator.add)
    ```
    )r   ÚoperatorÚtypr-   c                 óþ  •— t         ‰| �  |«       || _        t        |«      }|t        j
                  j                  t        j
                  j                  fv rt        }|t        j
                  j                  t        j
                  j                  fv rt        }|t        j
                  j                  t        j
                  j                  fv rt        }	  |«       | _        y # t         $ r t"        | _        Y y w xY w©N)ÚsuperÚ__init__r-   r   ÚcollectionsÚabcr   ÚMutableSequenceÚlistÚSetÚ
MutableSetÚsetÚMappingÚMutableMappingr"   r   Ú	Exceptionr   )Úselfr.   r-   Ú	__class__s      €r   r2   z BinaryOperatorAggregate.__init__M   s¹   ø€ Ü‰Ñ˜ÔØ ˆŒô ˜CÓ ˆØ”;—?‘?×+Ñ+¬[¯_©_×-LÑ-LÐMÑMÜˆCØ”;—?‘?×&Ñ&¬¯©×(BÑ(BÐCÑCÜˆCØ”;—?‘?×*Ñ*¬K¯O©O×,JÑ,JÐKÑKÜˆCð	!Ù›ˆD�JøÜò 	!Ü ˆDŽJð	!ús   ÃC% Ã%C<Ã;C<r   r   c                 óf   — t        |t        «      xr  t        | j                  |j                  «      S r0   )r!   r   r+   r-   )r=   r   s     r   Ú__eq__zBinaryOperatorAggregate.__eq__^   s,   € Ü˜%Ô!8Ó9ò 
Ô>NØ�M‰M˜5Ÿ>™>ó?
ð 	
r   c                 ó   — | j                   S )z,The type of the value stored in the channel.©r.   ©r=   s    r   Ú	ValueTypez!BinaryOperatorAggregate.ValueTypec   ó   € ð �x‰xˆr   c                 ó   — | j                   S )z/The type of the update received by the channel.rB   rC   s    r   Ú
UpdateTypez"BinaryOperatorAggregate.UpdateTypeh   rE   r   c                 ó–   — | j                  | j                  | j                  «      }| j                  |_        | j                  |_        |S )zReturn a copy of the channel.)r>   r.   r-   Úkeyr   )r=   Úemptys     r   ÚcopyzBinaryOperatorAggregate.copym   s5   € à—‘˜tŸx™x¨¯©Ó7ˆØ—H‘HˆŒ	Ø—j‘jˆŒØˆr   Ú
checkpointc                 ó’   — | j                  | j                  | j                  «      }| j                  |_        |t        ur||_        |S r0   )r>   r.   r-   rI   r   r   )r=   rL   rJ   s      r   Úfrom_checkpointz'BinaryOperatorAggregate.from_checkpointt   s9   € Ø—‘˜tŸx™x¨¯©Ó7ˆØ—H‘HˆŒ	ØœWÑ$Ø$ˆEŒKØˆr   Úvaluesc                 ó*  — |sy| j                   t        u r|d   | _         |dd  }d}|D ]h  }t        |«      \  }}|r2|r&t        dt        j
                  ¬«      }t        |«      ‚|| _         d}ŒE|rŒH| j                  | j                   |«      | _         Œj y)NFr   r   z4Can receive only one Overwrite value per super-step.)ÚmessageÚ
error_codeT)r   r   r&   r   r   ÚINVALID_CONCURRENT_GRAPH_UPDATEr   r-   )r=   rO   Úseen_overwriter   Úis_overwriteÚoverwrite_valueÚmsgs          r   ÚupdatezBinaryOperatorAggregate.update{   sž   € ÙØØ�:‰:œÑ Ø ™ˆDŒJØ˜A˜B�ZˆFØ$ˆÛˆEÜ,:¸5Ó,AÑ)ˆL˜/ÙÙ!Ü.Ø VÜ#,×#LÑ#Lô�Cô -¨SÓ1Ð1Ø,�”
Ø!%�ØÚ!Ø!Ÿ]™]¨4¯:©:°uÓ=�•
ð ð r   c                 óR   — | j                   t        u r
t        «       ‚| j                   S r0   )r   r   r   rC   s    r   r$   zBinaryOperatorAggregate.get’   s!   € Ø�:‰:œÑ Ü#Ó%Ð%Ø�z‰zÐr   c                 ó&   — | j                   t        uS r0   )r   r   rC   s    r   Úis_availablez$BinaryOperatorAggregate.is_available—   s   € Ø�z‰z¤Ð(Ð(r   c                 ó   — | j                   S r0   r%   rC   s    r   rL   z"BinaryOperatorAggregate.checkpointš   s   € Ø�z‰zÐr   )r*   Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r    r   r   r2   ÚobjectÚboolr@   ÚpropertyrD   rG   r	   rK   rN   r   rX   r$   r[   rL   Ú__classcell__)r>   s   @r   r   r   A   sß   ø„ ñð &€Ið!˜D ™Kð !°8¸UÀE¸NÈEÐ<QÑ3Rõ !ð"
˜Fð 
 tó 
ð
 ð˜4 ™;ò ó ðð ð˜D ™Kò ó ðð�dó ð¨%ð °Dó ð˜X e™_ð °ó ð.�Uó ð
)˜dó )ð˜E÷ r   r   ) Úcollections.abcr3   r   r   Útypingr   r   Útyping_extensionsr   r   r	   Úlanggraph._internal._constantsr
   Úlanggraph._internal._typingr   Úlanggraph.channels.baser   r   Úlanggraph.errorsr   r   r   r   Úlanggraph.typesr   Ú__all__r   Útuplerb   r&   r+   r   © r   r   Ú<module>rp      sŒ   ðÛ ß .ß ç 9Ñ 9å 4Ý /ß 6÷ó õ &à
&€òð˜#ð  %¨¨c¨	Ñ"2ó ð.˜ð  Xð °$ó ôZ˜g e™n¨k¸%ÀÈÐ:MÑ.Nõ Zr   