ó
    ýÞ jÁ  ã                  óþ   • S SK Jr  S SKJrJrJr  S SKJr  S SKJ	r	  S SK
Jr  S SKJrJr  S SKJr  Sr " S	 S
\5      r " S S\5      r\\-  rSSSSSS.               SS jjrSS.SS jjr      SS jrg)é    )Úannotations)ÚAnyÚLiteralÚcast)Úuuid4)Ú
AnyMessage)Ú	TypedDict)Ú
get_configÚget_stream_writer)ÚCONF)Ú	UIMessageÚRemoveUIMessageÚAnyUIMessageÚpush_ui_messageÚdelete_ui_messageÚui_message_reducerc                  óL   • \ rS rSr% SrS\S'   S\S'   S\S'   S\S	'   S\S
'   Srg)r   é   aÖ  A message type for UI updates in LangGraph.

This TypedDict represents a UI message that can be sent to update the UI state.
It contains information about the UI component to render and its properties.

Attributes:
    type: Literal type indicating this is a UI message.
    id: Unique identifier for the UI message.
    name: Name of the UI component to render.
    props: Properties to pass to the UI component.
    metadata: Additional metadata about the UI message.
zLiteral['ui']ÚtypeÚstrÚidÚnameúdict[str, Any]ÚpropsÚmetadata© N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotations__Ú__static_attributes__r   ó    ÚL/var/www/html/gaurav/venv/lib/python3.13/site-packages/langgraph/graph/ui.pyr   r      s%   ‡ ñð ÓØƒGØ
ƒIØÓØÖr%   r   c                  ó.   • \ rS rSr% SrS\S'   S\S'   Srg)	r   é+   a"  A message type for removing UI components in LangGraph.

This TypedDict represents a message that can be sent to remove a UI component
from the current state.

Attributes:
    type: Literal type indicating this is a remove-ui message.
    id: Unique identifier of the UI message to remove.
zLiteral['remove-ui']r   r   r   r   Nr   r   r%   r&   r   r   +   s   ‡ ñð ÓØ†Gr%   r   NÚuiF)r   r   ÚmessageÚ	state_keyÚmergec               ó  • SSK Jn  [        5       n[        5       n	Sn
U(       aJ  [	        U[
        5      (       a  SU;   a  UR                  S5      n
O[        US5      (       a  UR                  n
SU=(       d    [        [        5       5      U UUU	R                  SS5      U	R                  SS5      U	R                  SS5      S	.U=(       d    0 EU
(       a  S
U
0O0 ES.nU" U5        U(       a  U	[           U   " X[4/5        U$ )am  Push a new UI message to update the UI state.

This function creates and sends a UI message that will be rendered in the UI.
It also updates the graph state with the new UI message.

Args:
    name: Name of the UI component to render.
    props: Properties to pass to the UI component.
    id: Optional unique identifier for the UI message.
        If not provided, a random UUID will be generated.
    metadata: Optional additional metadata about the UI message.
    message: Optional message object to associate with the UI message.
    state_key: Key in the graph state where the UI messages are stored.
    merge: Whether to merge props with existing UI message (True) or replace
        them (False).

Returns:
    The created UI message.

Example:
    ```python
    push_ui_message(
        name="component-name",
        props={"content": "Hello world"},
    )
    ```

r   ©ÚCONFIG_KEY_SENDNr   r)   Úrun_idÚtagsÚrun_name)r,   r0   r1   r   Ú
message_id)r   r   r   r   r   )Úlanggraph._internal._constantsr/   r   r
   Ú
isinstanceÚdictÚgetÚhasattrr   r   r   r   )r   r   r   r   r*   r+   r,   r/   ÚwriterÚconfigr3   Úevts               r&   r   r   =   sñ   € õL ?äÓ €FÜ‹\€Fà€JÞÜ�gœt×$Ñ$¨°«Ø Ÿ™ TÓ*‰JÜ�W˜d×#Ñ#Ø Ÿ™ˆJð Ø× ”Cœ›“LØØàØ—j‘j ¨4Ó0Ø—J‘J˜v tÓ,Ø—J‘J˜z¨4Ó0ñ	
ð
 �~˜2ð
ö .8�˜jÑ)¸Rð
ñ€Cñ ˆ3„KÞØŒt‰�_Ò%¨	Ð'7Ð&8Ô9à€Jr%   )r+   c               ó|   • SSK Jn  [        5       n[        5       nSU S.nU" U5        U[           U   " X4/5        U$ )aÈ  Delete a UI message by ID from the UI state.

This function creates and sends a message to remove a UI component from the current state.
It also updates the graph state to remove the UI message.

Args:
    id: Unique identifier of the UI component to remove.
    state_key: Key in the graph state where the UI messages are stored. Defaults to "ui".

Returns:
    The remove UI message.

Example:
    ```python
    delete_ui_message("message-123")
    ```

r   r.   ú	remove-ui)r   r   )r4   r/   r   r
   r   )r   r+   r/   r9   r:   r;   s         r&   r   r   …   sC   € õ& ?äÓ €FÜ‹\€Fà$/°rÑ:€Cá
ˆ3„KØ
Œ4�L�Ò! IÐ#3Ð"4Ô5à€Jr%   c                ól  • [        U [        5      (       d  U /n [        U[        5      (       d  U/nU R                  5       n[        U5       VVs0 sH  u  p4UR	                  S5      U_M     nnn[        5       nU GH  nUR	                  S5      nUR	                  U5      =n	b—  UR	                  S5      S:X  a  UR                  U5        MQ  UR                  U5        [        [        U5      R	                  S0 5      R	                  SS5      (       a#  X)   n
UR                  5       n0 U
S   EUS   EUS'   XrU	'   MÀ  UR	                  S5      S:X  a  [        SU S	35      e[        U5      XX'   UR                  U5        GM     U Vs/ sH  oDR	                  S5      U;  d  M  UPM     nnU$ s  snnf s  snf )
a–  Merge two lists of UI messages, supporting removing UI messages.

This function combines two lists of UI messages, handling both regular UI messages
and `remove-ui` messages. When a `remove-ui` message is encountered, it removes any
UI message with the matching ID from the current state.

Args:
    left: First list of UI messages or single UI message.
    right: Second list of UI messages or single UI message.

Returns:
    Combined list of UI messages with removals applied.

Example:
    ```python
    messages = ui_message_reducer(
        [{"type": "ui", "id": "1", "name": "Chat", "props": {}}],
        {"type": "remove-ui", "id": "1"},
    )
    ```

r   r   r=   r   r,   Fr   zCAttempting to delete an UI message with an ID that doesn't exist ('z'))r5   ÚlistÚcopyÚ	enumerater7   ÚsetÚaddÚdiscardr   r   Ú
ValueErrorÚlenÚappend)ÚleftÚrightÚmergedÚiÚmÚmerged_by_idÚids_to_removeÚmsgÚmsg_idÚexisting_idxÚprev_msgs              r&   r   r   ¥   sš  € ô4 �dœD×!Ñ!Øˆvˆä�eœT×"Ñ"Ø�ˆð �Y‰Y‹[€FÜ/8¸Ô/@ÔAÑ/@¡t q�A—E‘E˜$“K ’NÑ/@€LÑAÜ“E€MäˆØ—‘˜“ˆà(×,Ñ,¨VÓ4Ð4ˆLÑAØ�w‰w�v‹ +Ó-Ø×!Ñ! &Ö)à×%Ñ% fÔ-äœ	 3Ó'×+Ñ+¨J¸Ó;×?Ñ?ÀÈ×OÑOØ%Ñ3�HØŸ(™(›*�CØ#H h¨wÑ&7Ð#H¸3¸w¹<Ð#H�C˜‘Là'*�|Ó$à�w‰w�v‹ +Ó-Ü ØYÐZ`ÐYaÐacÐdóð ô $' v£;ˆLÑ Ø�M‰M˜#×ñ- ñ0  ÓD™�A§5¡5¨£;°mÑ#C�a™€FÐDØ€Mùó9 Bùò6 Es   ÁF+ÆF1Æ!F1)r   r   r   r   r   ú
str | Noner   zdict[str, Any] | Noner*   zAnyMessage | Noner+   rS   r,   ÚboolÚreturnr   )r   r   r+   r   rU   r   )rH   ú!list[AnyUIMessage] | AnyUIMessagerI   rV   rU   zlist[AnyUIMessage])Ú
__future__r   Útypingr   r   r   Úuuidr   Úlangchain_core.messagesr   Útyping_extensionsr	   Úlanggraph.configr
   r   Úlanggraph.constantsr   Ú__all__r   r   r   r   r   r   r   r%   r&   Ú<module>r_      sÞ   ðÝ "ç %Ñ %Ý å .Ý 'ç :Ý $ð€ô�	ô ô*�iô ð ˜?Ñ*€ð Ø&*Ø!%Ø ØñEØ
ðEàðEð 	ð	Eð
 $ðEð ðEð ðEð ðEð õEðP 48÷ ð@>Ø
+ð>à,ð>ð õ>r%   