Ë
    úmxiP  ã                  óf  — U d 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mZmZmZmZmZmZ ddlmZ ddlmZ e	rddlmZ d	Zd
ed<   dZ ed«      Z edd¬«      Zee
df   ee
   z  Z ded<   e!e"e
f   Z#ded<   ed   Z$ded<   ee
gef   Z%ded<   eege
f   Z&ded<   ed   Z'ded<    e( ed ee'«      «      «      Z)d
ed<   ee'dddd d!d"d#d$d%d&d'd(f   Z*ded)<   d7d*„Z+ee
d+ge
f   Z,ded,<    ed¬-«       G d.„ d/ee   «      «       Z- ed¬-«       G d0„ d1ee   «      «       Z.d8d2„Z/d9d3„Z0d9d4„Z1d:d5„Z2y6);zHFunctions and data structures shared by session_state.py and widgets.py.é    )Úannotations)ÚCallable)Ú	dataclassÚfield)
ÚTYPE_CHECKINGÚAnyÚFinalÚGenericÚLiteralÚ	TypeAliasÚ	TypeGuardÚTypeVarÚcastÚget_args)Úutil)ÚStreamlitAPIException)ÚSessionStatez$$IDr	   ÚGENERATED_ELEMENT_ID_PREFIXz $$STREAMLIT_INTERNAL_KEY_TESTINGÚTÚT_coT)Ú	covariant.r   Ú
WidgetArgsÚWidgetKwargs).NÚWidgetCallbackÚWidgetDeserializerÚWidgetSerializer)Údouble_array_valueÚint_array_valueÚstring_array_valueÚArrayValueFieldNameztuple[ArrayValueFieldName, ...]Ú_ARRAY_VALUE_FIELD_NAMESÚarrow_valueÚ
bool_valueÚbytes_valueÚdouble_valueÚfile_uploader_state_valueÚ	int_valueÚ
json_valueÚjson_trigger_valueÚstring_valueÚtrigger_valueÚstring_trigger_valueÚchat_input_valueÚValueFieldNamec                ó   — | t         v S ©N)r!   )Úobjs    úU/home/htdocs/ttos/venv/lib/python3.12/site-packages/streamlit/runtime/state/common.pyÚis_array_value_field_namer3   k   s   € ØÔ*Ð*Ð*ó    r   ÚWidgetValuePresenter)Úfrozenc                  óº   — e Zd ZU dZded<    ed¬«      Zded<    ed¬«      Zded	<   d
ed<   dZded<   dZ	ded<   dZ
ded<   dZded<   dZded<   dZded<   dd„Zy)ÚWidgetMetadataz4Metadata associated with a single widget. Immutable.ÚstrÚidF)ÚreprzWidgetDeserializer[T]ÚdeserializerzWidgetSerializer[T]Ú
serializerr.   Ú
value_typeNzWidgetCallback | NoneÚcallbackz dict[str, WidgetCallback] | NoneÚ	callbackszWidgetArgs | NoneÚcallback_argszWidgetKwargs | NoneÚcallback_kwargsú
str | NoneÚfragment_idzWidgetValuePresenter | NoneÚ	presenterc                ó,   — t        j                  | «      S r0   )r   Úrepr_)Úselfs    r2   Ú__repr__zWidgetMetadata.__repr__–   s   € Ü�z‰z˜$ÓÐr4   )Úreturnr9   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r   r<   r=   r?   r@   rA   rB   rD   rE   rI   © r4   r2   r8   r8   v   s|   … á>àƒGÙ*/°UÔ*;€LÐ'Ó;Ù&+°Ô&7€JÐ#Ó7ØÓð
 '+€HÐ#Ó*ð 37€IÐ/Ó6Ø'+€MÐ$Ó+Ø+/€OÐ(Ó/à"€K�Ó"ð .2€IÐ*Ó1ô r4   r8   c                  ó@   — e Zd ZU dZded<   ded<   e	 	 	 	 dd„«       Zy)	ÚRegisterWidgetResultal  Result returned by the `register_widget` family of functions/methods.

    Should be usable by widget code to determine what value to return, and
    whether to update the UI.

    Parameters
    ----------
    value : T_co
        The widget's current value, or, in cases where the true widget value
        could not be determined, an appropriate fallback value.

        This value should be returned by the widget call.
    value_changed : bool
        True if the widget's value is different from the value most recently
        returned from the frontend.

        Implies an update to the frontend is needed.
    r   ÚvalueÚboolÚvalue_changedc                ó"   —  |  |d«      d¬«      S )z„The canonical way to construct a RegisterWidgetResult in cases
        where the true widget value could not be determined.
        NF)rS   rU   rP   )Úclsr<   s     r2   ÚfailurezRegisterWidgetResult.failure²   s   € ñ ™ dÓ+¸5ÔAÐAr4   N)r<   zWidgetDeserializer[T_co]rJ   zRegisterWidgetResult[T_co])rK   rL   rM   rN   rO   ÚclassmethodrX   rP   r4   r2   rR   rR   š   s:   … ñð& ƒKØÓàðBØ3ðBà	#òBó ñBr4   rR   c                ó@   — | j                  dd¬«      d   }|dk(  rdS |S )aT  Return the user key portion of a element id, or None if the id does not
    have a user key.

    TODO This will incorrectly indicate no user key if the user actually provides
    "None" as a key, but we can't avoid this kind of problem while storing the
    string representation of the no-user-key sentinel as part of the element id.
    ú-é   )ÚmaxsplitéÿÿÿÿÚNoneN)Úsplit)Ú
element_idÚuser_keys     r2   Úuser_key_from_element_idrc   ¼   s0   € ð &×+Ñ+¨C¸!Ð+Ó<¸RÑ@€HØ˜vÒ%ˆ4Ð3¨8Ð3r4   c                ó,   — | j                  t        «      S )zFTrue if the given session_state key has the structure of a element ID.)Ú
startswithr   ©Úkeys    r2   Úis_element_idrh   È   s   € à�>‰>Ô5Ó6Ð6r4   c                ó@   — t        | «      xr | j                  d«       S )z_True if the given session_state key has the structure of a element ID
    with a user_key.
    z-None)rh   Úendswithrf   s    r2   Úis_keyed_element_idrk   Í   s    € ô ˜ÓÒ; c§l¡l°7Ó&;Ð";Ð;r4   c                ó@   — t        | «      rt        dt        › d�«      ‚y)z4Raise an Exception if the given user_key is invalid.zKeys beginning with z are reserved.N)rh   r   r   rf   s    r2   Úrequire_valid_user_keyrm   Ô   s*   € ä�SÔÜ#Ø"Ô#>Ð"?¸~ÐNó
ð 	
ð r4   N)r1   ÚobjectrJ   zTypeGuard[ArrayValueFieldName])ra   r9   rJ   rC   )rg   r9   rJ   rT   )rg   r9   rJ   r_   )3rN   Ú
__future__r   Úcollections.abcr   Údataclassesr   r   Útypingr   r   r	   r
   r   r   r   r   r   r   Ú	streamlitr   Ústreamlit.errorsr   Ú%streamlit.runtime.state.session_stater   r   rO   ÚTESTING_KEYr   r   ÚtupleÚlistr   Údictr9   r   r   r   r   r    Ú	frozensetr!   r.   r3   r5   r8   rR   rc   rh   rk   rm   rP   r4   r2   ú<module>r{      sÌ  ðò Oå "å $ß (÷÷ ÷ õ õñ ÝBà%+Ð ˜UÓ +Ø0€ñ ˆCƒL€Ùˆv Ô&€ð ˜c 3˜h™¨$¨s©)Ñ3€
ˆIÓ 3Ø˜s C˜x™.€ˆiÓ (Ø$ YÑ/€�	Ó /ð !)¨#¨°¨Ñ 2Ð �IÓ 2Ø&¨ s¨C xÑ0Ð �)Ó 0ð ")ðñ"Ð �Yó ñ #,ÙØ)ñ 	Ð$Ó%ó	ó#Ð ˜%ó ð  $ØØØØØØØØØØØØØðñ€�	ó ó"+ð #+¨C°Ð+@À#Ð+EÑ"FÐ �iÓ Fñ �$Ôô  �W˜Q‘Zó   ó ð  ñF �$ÔôB˜7 4™=ó Bó ðBóB	4ó7ó
<ô
r4   