
    A'h              	           d dl Zd dl mZ d dlmZmZ d dlmZmZm	Z	 d dl
mZmZ d dlmZ d dlmZ d Z G d	 d
ee   eeeef         Zy)    N)Sequence)CallableGeneric)NotRequiredRequiredSelf)BaseChannelValue)MISSING)EmptyChannelErrorc                     t        | d      rt        | j                        S t        | d      r0| j                  t        t        fv rt        | j
                  d         S | S )z=Strips Annotated, Required and NotRequired from a given type.
__origin__r   )hasattr_strip_extrasr   r   r   __args__)ts    _/home/kushmeetdev/Regenta/Chatbot/venv/lib/python3.12/site-packages/langgraph/channels/binop.pyr   r      sM    q,Q\\**q,ALLX{4K$KQZZ]++H    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 )BinaryOperatorAggregatezStores the result of applying a binary operator to the current value and each new value.

    ```python
    import operator

    total = Channels.BinaryOperatorAggregate(int, operator.add)
    ```
    )value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MutableMappingdictr   	Exceptionr   )selfr   r   	__class__s      r   r   z BinaryOperatorAggregate.__init__#   s      C ;??++[__-L-LMMC;??&&(B(BCCC;??**KOO,J,JKKC	!DJ 	! DJ	!s   C% %C<;C<r   returnc                     t        |t              xrL |j                  j                  dk7  r1| j                  j                  dk7  r|j                  | j                  u S dS )Nz<lambda>T)
isinstancer   r   __name__)r)   r   s     r   __eq__zBinaryOperatorAggregate.__eq__4   sW    %!89 
~~&&*4&&*4 NNdmm+	
 		
r   c                     | j                   S )z,The type of the value stored in the channel.r   r)   s    r   	ValueTypez!BinaryOperatorAggregate.ValueType<        xxr   c                     | j                   S )z/The type of the update received by the channel.r1   r2   s    r   
UpdateTypez"BinaryOperatorAggregate.UpdateTypeA   r4   r   c                     | j                  | j                  | j                        }| j                  |_        | j                  |_        |S )zReturn a copy of the channel.)r*   r   r   keyr   )r)   emptys     r   copyzBinaryOperatorAggregate.copyF   s5    txx7HH	jjr   
checkpointc                     | j                  | j                  | j                        }| j                  |_        |t        ur||_        |S r   )r*   r   r   r8   r   r   )r)   r;   r9   s      r   from_checkpointz'BinaryOperatorAggregate.from_checkpointM   s9    txx7HH	W$$EKr   valuesc                     |sy| j                   t        u r|d   | _         |dd  }|D ]#  }| j                  | j                   |      | _         % y)NFr      T)r   r   r   )r)   r>   r   s      r   updatezBinaryOperatorAggregate.updateT   sR    :: DJABZF 	:Etzz59DJ	:r   c                 R    | j                   t        u r
t               | j                   S r   )r   r   r   r2   s    r   getzBinaryOperatorAggregate.get^   s!    :: #%%zzr   c                 &    | j                   t        uS r   )r   r   r2   s    r   is_availablez$BinaryOperatorAggregate.is_availablec   s    zz((r   c                     | j                   S r   )r   r2   s    r   r;   z"BinaryOperatorAggregate.checkpointf   s    zzr   )r.   
__module____qualname____doc__	__slots__typer
   r   r   objectboolr/   propertyr3   r6   r   r:   r=   r   rA   rC   rE   r;   __classcell__)r*   s   @r   r   r      s     &I!DK !8UENE<Q3R !"
F 
t 
 4;   DK  d % D Xe_  U 
)d )E r   r   )collections.abcr   r   typingr   r   typing_extensionsr   r   r   langgraph.channels.baser	   r
   langgraph.constantsr   langgraph.errorsr   r   r    r   r   <module>rW      sB     $ $ 9 9 6 ' .Pgenk%:M.N Pr   