
    g                    (   U d 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 ddlmZmZ ddlmZ ddlmZ dZd	ed
<   dZ ed      Z edd      Zeedf   Zded<   eeef   Zded<   ed   Z ded<   e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%f   Z&ded&<   d2d'Z' ed(       G d) d*e
e                Z( ed(       G d+ d,e
e                Z)d3d-Z*d4d.Z+d4d/Z,d5d0Z-y1)6zGFunctions and data structures shared by session_state.py and widgets.py    )annotations)	dataclassfield)AnyCallableFinalGenericLiteralTypeVarcastget_args)	TypeAlias	TypeGuard)util)StreamlitAPIExceptionz$$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string_valuetrigger_valuestring_trigger_valueValueFieldNamec                    | t         v S N)r   )objs    S/var/www/openai/venv/lib/python3.12/site-packages/streamlit/runtime/state/common.pyis_array_value_field_namer/   e   s    ***    )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dZy)WidgetMetadataz4Metadata associated with a single widget. Immutable.stridF)reprzWidgetDeserializer[T]deserializerzWidgetSerializer[T]
serializerr*   
value_typeNzWidgetCallback | NonecallbackzWidgetArgs | Nonecallback_argszWidgetKwargs | Nonecallback_kwargs
str | Nonefragment_idc                ,    t        j                  |       S r,   )r   repr_)selfs    r.   __repr__zWidgetMetadata.__repr__{   s    zz$r0   )returnr4   )__name__
__module____qualname____doc____annotations__r   r7   r8   r:   r;   r<   r>   rB    r0   r.   r3   r3   i   sb    >G*/U*;L';&+&7J#7
 '+H#*'+M$++/O(/"K" r0   r3   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      d      S )zThe canonical way to construct a RegisterWidgetResult in cases
        where the true widget value could not be determined.
        N F)rL   rN   rI   )clsr7   s     r.   failurezRegisterWidgetResult.failure   s     dB/uEEr0   N)r7   zWidgetDeserializer[T_co]rC   zRegisterWidgetResult[T_co])rD   rE   rF   rG   rH   classmethodrR   rI   r0   r.   rK   rK      s:    & KF3F	#F Fr0   rK   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     r.   user_key_from_element_idr]      s0     &++C!+<R@Hv%4383r0   c                ,    | j                  t              S )zFTrue if the given session_state key has the structure of a element ID.)
startswithr   keys    r.   is_element_idrb      s    >>566r0   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)rb   endswithr`   s    r.   is_keyed_element_idre      s      ;cll7&;";;r0   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)rb   r   r   r`   s    r.   require_valid_user_keyrg      s*    S#"#>"?~N
 	
 r0   N)r-   objectrC   zTypeGuard[ArrayValueFieldName])r[   r4   rC   r=   )ra   r4   rC   rM   )ra   r4   rC   rY   ).rG   
__future__r   dataclassesr   r   typingr   r   r   r	   r
   r   r   r   typing_extensionsr   r   	streamlitr   streamlit.errorsr   r   rH   TESTING_KEYr   r   tupler   dictr4   r   r   r   r   r   	frozensetr   r*   r/   r3   rK   r]   rb   re   rg   rI   r0   r.   <module>rs      s   N " (	 	 	 3  &, U +0 CLv& c3h
I 'sCx.i ($Y/	 / !)#sQ 7 I 7&sCx0 ) 0 ")" Y  #,) 	$%	# %   $
	 + $ WQZ    * $F74= F FB	47
<
r0   