§
    šŠtjÁ  ã            	       ó  — 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dS )é    N)ÚCallableÚSequence)ÚAnyÚGeneric)ÚNotRequiredÚRequiredÚSelf)Ú	OVERWRITE)ÚMISSING)ÚBaseChannelÚValue)ÚEmptyChannelErrorÚ	ErrorCodeÚInvalidUpdateErrorÚcreate_error_message)Ú	Overwrite)ÚBinaryOperatorAggregatec                 ó¬   — t          | d¦  «        rC| 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    úV/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/langgraph/channels/binop.pyr   r      sO   € åˆq�,ÑÔð +ØŒ<�H¥kÐ2Ð2Ð2Ý  ¤¨A¤Ñ/Ô/Ð/Ý˜Qœ\Ñ*Ô*Ð*Ø€Hó    ÚvalueÚreturnc                 ó  — t          | t          ¦  «        r	d| j        fS t          | t          ¦  «        rWt	          | ¦  «        dk    rt
          | v rd| t
                   fS |                      d¦  «        t
          k    rd| v r
d| d         fS dS )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&      s“   € õ �%�Ñ#Ô#ð !Ø�U”[Ð Ð Ý�%�ÑÔð (Ýˆu‰:Œ:˜Š?ˆ?�y¨EÐ1Ð1Ø˜�yÔ)Ð)Ð)Ø�9Š9�VÑÔ¥	Ò)Ð)¨g¸Ð.>Ð.>Ø˜˜wœÐ'Ð'Øˆ;r   ÚaÚbc                 ó:   — | j         dk    s|j         dk    rdS | |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ÒÐ 1¤:°Ò#;Ð#;ØˆtØ�ˆ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          }	  |¦   «         | _        d S # t           $ r t"          | _        Y d S 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ÐMÐMÐMÝˆCØ•;”?Ô&­¬Ô(BÐCÐCÐCÝˆCØ•;”?Ô*­K¬OÔ,JÐKÐKÐKÝˆCð	!Ø˜™œˆDŒJˆJˆJøÝð 	!ð 	!ð 	!Ý ˆDŒJˆJˆJˆJð	!øøøs   Â;C ÃC&Ã%C&r   r   c                 ó`   — t          |t          ¦  «        ot          | j        |j        ¦  «        S r0   )r!   r   r+   r-   )r=   r   s     r   Ú__eq__zBinaryOperatorAggregate.__eq__^   s0   € Ý˜%Õ!8Ñ9Ô9ð 
Õ>NØŒM˜5œ>ñ?
ô ?
ð 	
r   c                 ó   — | j         S )z,The type of the value stored in the channel.©r.   ©r=   s    r   Ú	ValueTypez!BinaryOperatorAggregate.ValueTypec   ó   € ð Œ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                 óv   — |                       | j        | j        ¦  «        }| j        |_        | j        |_        |S )zReturn a copy of the channel.)r>   r.   r-   Úkeyr   )r=   Úemptys     r   ÚcopyzBinaryOperatorAggregate.copym   s0   € à—’˜tœx¨¬Ñ7Ô7ˆØ”HˆŒ	Ø”jˆŒØˆr   Ú
checkpointc                 ó~   — |                       | 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¨¬Ñ7Ô7ˆØ”HˆŒ	Ø�WÐ$Ð$Ø$ˆEŒKØˆr   Úvaluesc                 ó>  — |sdS | j         t          u r|d         | _         |dd …         }d}|D ]n}t          |¦  «        \  }}|r6|r*t          dt          j        ¬¦  «        }t          |¦  «        ‚|| _         d}ŒL|s |                      | j         |¦  «        | _         ŒodS )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Ë   € Øð 	Ø�5ØŒ:�Ð Ð Ø œˆDŒJØ˜A˜B˜B”ZˆFØ$ˆØð 	>ð 	>ˆEÝ,:¸5Ñ,AÔ,AÑ)ˆL˜/Øð 	Ø!ð 2Ý.Ø VÝ#,Ô#Lðñ ô �Cõ -¨SÑ1Ô1Ð1Ø,�”
Ø!%�ØØ!ð >Ø!Ÿ]š]¨4¬:°uÑ=Ô=�”
øØˆtr   c                 óH   — | j         t          u rt          ¦   «         ‚| j         S r0   )r   r   r   rC   s    r   r$   zBinaryOperatorAggregate.get’   s#   € ØŒ:�Ð Ð Ý#Ñ%Ô%Ð%ØŒzÐr   c                 ó   — | j         t          uS r0   )r   r   rC   s    r   Úis_availablez$BinaryOperatorAggregate.is_available—   s   € ØŒz¥Ð(Ð(r   c                 ó   — | j         S r0   r%   rC   s    r   rL   z"BinaryOperatorAggregate.checkpointš   s
   € ØŒ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 œ;ð ð ð ñ „Xðð ð˜D œKð ð ð ñ „Xðð�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Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9à 4Ð 4Ð 4Ð 4Ð 4Ð 4Ø /Ð /Ð /Ð /Ð /Ð /Ø 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6ðð ð ð ð ð ð ð ð ð ð ð ð &Ð %Ð %Ð %Ð %Ð %à
&€ðð ð ð˜#ð  %¨¨c¨	Ô"2ð ð ð ð ð.˜ð  Xð °$ð ð ð ð ðZð Zð Zð Zð Z˜g eœn¨k¸%ÀÈÐ:MÔ.Nñ Zô Zð Zð Zð Zr   