
    &e                     R   U 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mZmZ d dl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 d dlmZmZ d d	lmZ d d
lm Z  erd dl!m"Z" d dlm#Z# dedef         de	e         fdZ$ddde	e         ddfdZ%da&e'e(d<   dZ)	 d+dede	e*         de'ddfdZ+dej,        ddfdZ-ed ee         d!ee         d"e
e         dee         fd#            Z.ed ee          d!ej/        e          d"e
e          dee          fd$            Z.d% Z.ed eee                   d!ej/        e          d"e
e          deee                   fd&            Z0ed eee e f                  d!ej/        e          d"e
e          deee e f                  fd'            Z0d( Z0d)ee         defd*Z1dS ),    )EnumEnumMeta)TYPE_CHECKINGAnyHashableIterableListOptionalSequenceTupleTypeUnioncastoverloadN)configruntime	type_util)
is_in_form)StreamlitAPIException)LabelVisibilityMessage)WidgetCallbackget_session_state)RegisterWidgetResult)T)DeltaGenerator)DataFrameCompatibledatar   returnc                     t          j        |           rDt          j        |           } | j        j        dk    r t          t          | j        d                   S d S )Nr   )r   is_dataframe_compatibleconvert_anything_to_dfindexsizer   r   )r   s    8lib/python3.11/site-packages/streamlit/elements/utils.py last_index_for_melted_dataframesr&   -   sQ     (.. 2/55:?Q$*R.1114    dgr   	on_changec                 t    t          j                    r t          |           r|t          d          d S d S d S )NzWith forms, callbacks can only be defined on the `st.form_submit_button`. Defining callbacks on other widgets inside a form is not allowed.)r   existsr   r   )r(   r)   s     r%   check_callback_rulesr,   9   sX     ~ 
JrNN 
y/D#Q
 
 	

 
 
 
/D/Dr'   F_shown_default_value_warningz
Values for st.button, st.download_button, st.file_uploader, st.data_editor,
st.chat_input, and st.form cannot be set using st.session_state.
Tdefault_valuekeywrites_allowedc                 $   |t          j                    sd S t                      }|                    |          sd S |st	          t
                    | 7t          s2t          j        d          s t          j
        d| d           dad S d S d S d S )Nz+global.disableWidgetStateDuplicationWarningzThe widget with key "zX" was created with a default value but also had its value set via the Session State API.T)r   r+   r   is_new_state_valuer   +SESSION_STATE_WRITES_NOT_ALLOWED_ERROR_TEXTr-   r   
get_option	streamlitwarning)r.   r/   r0   session_states       r%   check_session_state_rulesr8   K   s    
 {'.**{%''M++C00  Q#$OPPP 	!, 	"!"OPP 	" 	AC A A A	
 	
 	
 (,$$$ 	"!!!!!r'   label_visibility_stringz7LabelVisibilityMessage.LabelVisibilityOptions.ValueTypec                     | dk    rt           j        j        S | dk    rt           j        j        S | dk    rt           j        j        S t          d|            )zNReturns one of LabelVisibilityMessage enum constants.py based on string value.visiblehidden	collapsedz Unknown label visibility value: )r   LabelVisibilityOptionsVISIBLEHIDDEN	COLLAPSED
ValueError)r9   s    r%    get_label_visibility_proto_valuerC   f   sa    
 )++%<DD	 H	,	,%<CC	 K	/	/%<FF
Q8OQQ
R
RRr'   register_widget_resultoptionsopt_sequencec                     d S N rD   rE   rF   s      r%   maybe_coerce_enumrK   u   	     Cr'   c                     d S rH   rI   rJ   s      r%   rK   rK   ~   rL   r'   c                     t          | j        t                    s| S t          |t                    r|}nt	          |          }|| S t          t          j        | j        |          | j                  S )zMaybe Coerce a RegisterWidgetResult with an Enum member value to
    RegisterWidgetResult[option] if option is an EnumType, otherwise just return
    the original RegisterWidgetResult.)	
isinstancevaluer   r   _extract_common_class_from_iterr   r   coerce_enumvalue_changedrD   rE   rF   coerce_classs       r%   rK   rK      s     ,2D99 &%% '8$$ *6|DD))4:LII,  r'   c                     d S rH   rI   rJ   s      r%   maybe_coerce_enum_sequencerW      rL   r'   c                     d S rH   rI   rJ   s      r%   rW   rW      rL   r'   c                    t          d | j        D                       s| S t          |t                    r|nt	          |          | S t           t          | j                  fd| j        D                       | j                  S )zMaybe Coerce a RegisterWidgetResult with a sequence of Enum members as value
    to RegisterWidgetResult[Sequence[option]] if option is an EnumType, otherwise just return
    the original RegisterWidgetResult.c              3   @   K   | ]}t          |t                    V  d S rH   )rO   r   ).0vals     r%   	<genexpr>z-maybe_coerce_enum_sequence.<locals>.<genexpr>   s,      MMz#t$$MMMMMMr'   Nc              3   B   K   | ]}t          j        |          V  d S rH   )r   rR   )r[   r\   rU   s     r%   r]   z-maybe_coerce_enum_sequence.<locals>.<genexpr>   sD       +
 +
 !#|44+
 +
 +
 +
 +
 +
r'   )allrP   rO   r   rQ   r   typerS   rT   s      @r%   rW   rW      s     MM0F0LMMMMM &%% '8$$ *6|DD))  *#)** +
 +
 +
 +
-3+
 +
 +
 	
 	
 	,  r'   iterablec                     	 t          |           }t          t          |                    n# t          $ r Y dS w xY wt	          fd|D                       rS dS )zdReturn the common class of all elements in a iterable if they share one.
    Otherwise, return None.Nc              3   :   K   | ]}t          |          u V  d S rH   )r`   )r[   itemfirst_classs     r%   r]   z2_extract_common_class_from_iter.<locals>.<genexpr>   s.      
<
<4::$
<
<
<
<
<
<r'   )iterr`   nextStopIterationr_   )ra   
inner_iterre   s     @r%   rQ   rQ      s|    (^^
4
++,,   tt

<
<
<
<
<
<
<<< 4s   +/ 
==)T)2enumr   r   typingr   r   r   r   r	   r
   r   r   r   r   r   r   r5   r   r   r   streamlit.elements.formr   streamlit.errorsr   *streamlit.proto.LabelVisibilityMessage_pb2r   streamlit.runtime.stater   r   streamlit.runtime.state.commonr   streamlit.type_utilr   streamlit.delta_generatorr   r   r&   r,   r-   bool__annotations__r3   strr8   LabelVisibilityrC   rK   OptionSequencerW   rQ   rI   r'   r%   <module>rx      s3                                            0 0 0 0 0 0 0 0 0 0 . . . . . . 2 2 2 2 2 2 M M M M M M E E E E E E E E ? ? ? ? ? ? ! ! ! ! ! ! 8888888777777	
%s*
+	h	 	 	 	

%-n%=
	
 
 
 
 &+ d * * */ + DH, ,,%c],<@,	, , , ,6S&6S>S S S S 
06$Z 3- $	   
 
03%a( 1+ !	   
  2 
0a9%a( 1+ $q'"	   
 
0q!t=%a( 1+ %1+&	   
  8
hsm 
 
 
 
 
 
 
r'   