
    &e                     4   d dl Z d dlZd dlZd dlmZ d dlmZmZmZm	Z	m
Z
mZ d dlmc m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 d d	lmZmZ d d
lm Z  d dl!m"Z" d dl#m$Z$m%Z%m&Z&m'Z' d dl(m)Z) d dl*m+Z+m,Z, d dl-m.Z. d dl/m0Z0 d dl1m2Z2 d dl3m4Z4m5Z5m6Z6 d dl7m8Z8 d dl9m:Z: d dl;m<Z< d dl=m>Z> d dl?m@Z@  eeA          ZBerd dlCmDZD  G d de          ZEdeFfdZG G d d          ZHd'd ZId!e$ddfd"ZJd!e%ddfd#ZKd!e'ddfd$ZLd!ee&e)f         d%eFddfd&ZMdS )(    N)Enum)TYPE_CHECKINGCallableDictListOptionalUnion)configruntimesource_util)to_snake_case)
get_logger)BackMsg)ClientState)FileURLsFileURLsRequest)
ForwardMsg)GitInfo)ConfigCustomThemeConfig
NewSessionUserInfo)PagesChanged)cachinglegacy_caching)ForwardMsgQueue)Installation)
ScriptData)	RerunDataScriptRunnerScriptRunnerEvent)ScriptCache)secrets_singleton)UploadedFileManager)STREAMLIT_VERSION_STRING)LocalSourcesWatcherSessionStatec                       e Zd ZdZdZdZdS )AppSessionStateAPP_NOT_RUNNINGAPP_IS_RUNNINGSHUTDOWN_REQUESTEDN)__name__
__module____qualname__r+   r,   r-        =lib/python3.11/site-packages/streamlit/runtime/app_session.pyr*   r*   4   s         'O%N-r2   r*   returnc                  B    t          t          j                              S )z5Randomly generate a unique ID for a script execution.)struuiduuid4r1   r2   r3   _generate_scriptrun_idr9   :   s    tz||r2   c                      e Zd ZdZ	 d:dedededeeg df                  de	de
eee         f         d	ee         d
dfdZd;dZd;dZd;dZd
ee         fdZd;dZded
dfdZded
dfdZded
dfdZdee         d
dfdZd;dZded
dfdZed<d            Zded
e fdZ!d:dee         d
dfdZ"d;d Z#d;d!Z$d;d"Z%	 	 	 	 d=d#ee&         d$e'd%ee         d&ee         dee         d'ee         d
dfd(Z(	 	 	 	 d=d#ee&         d$e'd%ee         d&ee         dee         d'ee         d
dfd)Z)d
efd*Z*d
efd+Z+d'ed
efd,Z,d-d.d
efd/Z-ded
efd0Z.d;d1Z/	 d:dee         d
dfd2Z0d;d3Z1d;d4Z2d;d5Z3d6e d
dfd7Z4d8e5d
dfd9Z6dS )>
AppSessiona!  
    Contains session data for a single "user" of an active app
    (that is, a connected browser tab).

    Each AppSession has its own ScriptData, root DeltaGenerator, ScriptRunner,
    and widget state.

    An AppSession is attached to each thread involved in running its script.

    Nscript_datauploaded_file_managerscript_cachemessage_enqueued_callbacklocal_sources_watcher	user_infosession_id_overrider4   c                 B   |pt          t          j                              | _        t	          j                    | _        || _        || _        || _	        t                      | _        || _        t          j        | _        t!                      | _        || _        d| _        d| _        |                                  t-          j        d          | _        d| _        ddlm}  |            | _        || _        d| _        t>                               d| j                   dS )ao  Initialize the AppSession.

        Parameters
        ----------
        script_data
            Object storing parameters related to running a script

        uploaded_file_manager
            Used to manage files uploaded by users via the Streamlit web client.

        script_cache
            The app's ScriptCache instance. Stores cached user scripts. ScriptRunner
            uses the ScriptCache to avoid having to reload user scripts from disk
            on each rerun.

        message_enqueued_callback
            After enqueuing a message, this callable notification will be invoked.

        local_sources_watcher
            The file watcher that lets the session know local files have changed.

        user_info
            A dict that contains information about the current user. For now,
            it only contains the user's email address.

            {
                "email": "example@example.com"
            }

            Information about the current user is optionally provided when a
            websocket connection is initialized via the "X-Streamlit-User" header.

        session_id_override
            The ID to assign to this session. Setting this can be useful when the
            service that a Streamlit Runtime is running in wants to tie the lifecycle of
            a Streamlit session to some other session-like object that it manages.
        Nzserver.runOnSaver   r'   zAppSession initialized (id=%s))!r6   r7   r8   idasyncioget_running_loop_event_loop_script_data_uploaded_file_mgr_script_cacher   _browser_queue_message_enqueued_callbackr*   r+   _stater   _client_state_local_sources_watcher_stop_config_listener_stop_pages_listenerregister_file_watchersr
   
get_option_run_on_save_scriptrunnerstreamlit.runtime.stater(   _session_state
_user_info_debug_last_backmsg_idLOGGERdebug)	selfr<   r=   r>   r?   r@   rA   rB   r(   s	            r3   __init__zAppSession.__init__K   s   ` &:TZ\\):):"355'"7)
 .//*C'%5 )]] " 	# DH"BF!##%%%"-.@AA59 	988888*lnn#59#5tw?????r2   c                 .    |                                   dS )zGEnsure that we call shutdown() when an AppSession is garbage collected.N)shutdownr\   s    r3   __del__zAppSession.__del__   s    r2   c                 R   | j         t          | j        j                  | _         | j                             | j                   t          j        | j        d          | _        t          j
        | j                  | _        t          j                            | j                   dS )a8  Register handlers to be called when various files are changed.

        Files that we watch include:
          * source files that already exist (for edits)
          * `.py` files in the the main script's `pages/` directory (for file additions
            and deletions)
          * project and user-level config.toml files
          * the project-level secrets.toml files

        This method is called automatically on AppSession construction, but it may be
        called again in the case when a session is disconnected and is being reconnect
        to.
        NT)force_connect)rO   r&   rH   main_script_pathregister_file_change_callback_on_source_file_changedr
   on_config_parsedrP   r   register_pages_changed_callback_on_pages_changedrQ   r#   file_change_listenerconnect_on_secrets_file_changedr`   s    r3   rR   z!AppSession.register_file_watchers   s     &.*=!2+ +D' 	#AA(	
 	
 	
 &,%<(&
 &
 &
" %0$O"%
 %
! 	.66t7TUUUUUr2   c                 $   | j         | j                                          | j        |                                  | j        |                                  t          j                            | j                   d| _         d| _        d| _        dS )zJDisconnect the file watcher handlers registered by register_file_watchers.N)rO   closerP   rQ   r#   rj   
disconnectrl   r`   s    r3   disconnect_file_watchersz#AppSession.disconnect_file_watchers   s    &2'--///%1&&((($0%%'''.99$:WXXX&*#%)"$(!!!r2   c                 4    | j                                         S )ai  Clear the forward message queue and return the messages it contained.

        The Server calls this periodically to deliver new messages
        to the browser connected to this app.

        Returns
        -------
        list[ForwardMsg]
            The messages that were removed from the queue and should
            be delivered to the browser.

        )rK   flushr`   s    r3   flush_browser_queuezAppSession.flush_browser_queue   s     "((***r2   c                    | j         t          j        k    rt                              d| j                   | j                            | j                   t          j	                    rKt          j
                    }|j                            | j                   |j                                         |                                  t          j        | _         |                                  dS dS )ziShut down the AppSession.

        It's an error to use a AppSession after it's been shut down.

        zShutting down (id=%s)N)rM   r*   r-   rZ   r[   rD   rI   remove_session_filesr   existsget_instancemedia_file_mgrclear_session_refsremove_orphaned_filesrequest_script_stoprp   )r\   rts     r3   r_   zAppSession.shutdown   s     ;/<<<LL0$'::: #88AAA~ :)++!44TW===!77999
 $$&&&)<DK ))+++++) =<r2   msgc                     t          j        d          sdS | j        r| j        |_        | j                            |           | j        r|                                  dS dS )zEnqueue a new ForwardMsg to our browser queue.

        This can be called on both the main thread and a ScriptRunner
        run thread.

        Parameters
        ----------
        msg : ForwardMsg
            The message to enqueue

        zclient.displayEnabledN)r
   rS   rY   debug_last_backmsg_idrK   enqueuerL   r\   r}   s     r3   _enqueue_forward_msgzAppSession._enqueue_forward_msg   sx      !899 	F& 	D(,(CC%##C(((* 	.++-----	. 	.r2   c                    	 |                     d          }|dk    r/|j        r|j        | _        |                     |j                   d
S |dk    r|                                  d
S |dk    r|                                  d
S |dk    r|                                  d
S |dk    r|                     |j	                   d
S |dk    r| 
                                 d
S |dk    r|                     |j                   d
S t                              d	|           d
S # t          $ r:}t                              |           |                     |           Y d
}~d
S d
}~ww xY w)zProcess a BackMsg.typererun_scriptload_git_infoclear_cacheapp_heartbeatset_run_on_savestop_scriptfile_urls_requestzNo handler for "%s"N)
WhichOneofr   rY   _handle_rerun_script_requestr   _handle_git_information_request_handle_clear_cache_request_handle_app_heartbeat_request_handle_set_run_on_save_requestr   _handle_stop_script_request_handle_file_urls_requestr   rZ   warning	Exceptionerrorhandle_backmsg_exception)r\   r}   msg_typeexs       r3   handle_backmsgzAppSession.handle_backmsg  s   	.~~f--H>)), L252KD/11#2BCCCCC_,,4466666]**0022222_,,2244444...44S5HIIIII]**0022222000..s/DEEEEE4h????? 	. 	. 	.LL))"---------	.sB   AD D (D D   D D  D  D 
E!'/EE!ec                 (                           j        t          j                                          j        t          j        d                                  j        t          j                    j                             fd           dS )zGHandle an Exception raised while processing a BackMsg from the browser. )page_script_hashc                  T                                                                  S N)r   _create_exception_message)r   r\   s   r3   <lambda>z5AppSession.handle_backmsg_exception.<locals>.<lambda>M  s#    D--d.L.LQ.O.OPP r2   N)_on_scriptrunner_eventrU   r!   SCRIPT_STOPPED_WITH_SUCCESSSCRIPT_STARTEDrG   call_soon_threadsafe)r\   r   s   ``r3   r   z#AppSession.handle_backmsg_exception3  s     	## 1 M	
 	
 	
 	##, 	$ 	
 	
 	

 	## 1 M	
 	
 	
 	--PPPPP	
 	
 	
 	
 	
r2   client_statec                    | j         t          j        k    rt                              d           dS |r't          |j        |j        |j        |j	                  }nt                      }| j
        `t          t          j        d                    r!| j
                                         d| _
        n| j
                            |          }|rdS |                     |           dS )a  Signal that we're interested in running the script.

        If the script is not already running, it will be started immediately.
        Otherwise, a rerun will be requested.

        Parameters
        ----------
        client_state : streamlit.proto.ClientState_pb2.ClientState | None
            The ClientState protobuf to run the script with, or None
            to use previous client state.

        z'Discarding rerun request after shutdownNzrunner.fastReruns)rM   r*   r-   rZ   r   r   query_stringwidget_statesr   	page_namerU   boolr
   rS   request_stoprequest_rerun_create_scriptrunner)r\   r   
rerun_datasuccesss       r3   r   zAppSession.request_rerunP  s     ;/<<<NNDEEEF 	%")*-&	 JJ #J)F%&9::;; 
 "//111%)"" ,:::FF F
 	!!*-----r2   c                 J    | j         | j                                          dS dS )zgRequest that the scriptrunner stop execution.

        Does nothing if no scriptrunner exists.
        N)rU   r   r`   s    r3   r{   zAppSession.request_script_stop  s0    
 )++----- *)r2   initial_rerun_datac           	          t          | j        | j        j        | j        | j        | j        || j                  | _        | j        j	        
                    | j                   | j                                         dS )z;Create and run a new ScriptRunner with the given RerunData.)
session_idrd   session_stateuploaded_file_mgrr>   r   rA   N)r    rD   rH   rd   rW   rI   rJ   rX   rU   on_eventrk   r   start)r\   r   s     r3   r   zAppSession._create_scriptrunner  s{    )w!.?-"5+1o
 
 
 	#++D,GHHH  """""r2   r(   c                     | j         S r   )rW   r`   s    r3   r   zAppSession.session_state  s    ""r2   filepathc                     | j         j        }t          j        |          t	          t          fd          d           }|| j        j        }||k    S dS )Nc                 (    |          d         k    S )Nscript_pathr1   )kr   pagess    r3   r   z9AppSession._should_rerun_on_file_change.<locals>.<lambda>  s    U1Xm4@ r2   T)rH   rd   r   	get_pagesnextfilterrN   r   )r\   r   rd   changed_page_script_hashcurrent_page_script_hashr   s    `   @r3   _should_rerun_on_file_changez'AppSession._should_rerun_on_file_change  ss    ,=%&677#'@@@@@%HH$
 $
 
 $/'+'9'J$+/GGGtr2   c                     | j                                          ||                     |          sdS | j        r|                     | j                   dS |                     |                                            dS )zUOne of our source files changed. Clear the cache and schedule a rerun if appropriate.N)rJ   clearr   rT   r   rN   r   _create_file_change_message)r\   r   s     r3   rf   z"AppSession._on_source_file_changed  s      """(I(I((S(SF 	Jt122222%%d&F&F&H&HIIIIIr2   c                 .    |                                   dS )z:Called when `secrets.file_change_listener` emits a Signal.N)rf   )r\   _s     r3   rl   z#AppSession._on_secrets_file_changed  s     	$$&&&&&r2   c                     t                      }t          |j        | j        j                   |                     |           | j        | j                                         d S d S r   )r   _populate_app_pagespages_changedrH   rd   r   rO   update_watched_pages)r\   r   r}   s      r3   ri   zAppSession._on_pages_changed  sd    llC-t/@/QRRR!!#&&&&2'<<>>>>> 32r2   c                 8    | j                                          d S r   )rK   r   r`   s    r3   _clear_queuezAppSession._clear_queue  s    !!#####r2   sendereventforward_msg	exceptionr   c           	      Z      j                              fd           dS )a  Called when our ScriptRunner emits an event.

        This is generally called from the sender ScriptRunner's script thread.
        We forward the event on to _handle_scriptrunner_event_on_event_loop,
        which will be called on the main thread.
        c                  8                                    S r   )(_handle_scriptrunner_event_on_event_loop)r   r   r   r   r   r\   r   s   r3   r   z3AppSession._on_scriptrunner_event.<locals>.<lambda>  s%    DAA{I|EU  r2   N)rG   r   )r\   r   r   r   r   r   r   s   ```````r3   r   z!AppSession._on_scriptrunner_event  sb     	--         	
 	
 	
 	
 	
r2   c                    | j         t          j                    k    s
J d            || j        urt                              d|           dS | j        }|t          j        k    rp| j        t          j
        k    rt          j        | _        |
J d            |                                  |                     |                     |                     n|t          j        k    s|t          j        k    r| j        t          j
        k    rt          j        | _        |t          j        k    }|                     |rt&          j        nt&          j                  }	|                     |	           d| _        |r"| j        r| j                                         nV|
J d            t'                      }
t3          j        |
j        j        |           |                     |
           n|t          j        k    rU|                     t&          j                  }	|                     |	           | j        r| j                                         n|t          j        k    r`|
J d            | j        t          j
        k    r0tA          j!                    j"        #                    | j$                   || _%        d| _        n1|t          j&        k    r!|
J d            |                     |           |t          j        k    }| j        t          j        k    }||k    r)|                     | '                                           dS dS )a_  Handle a ScriptRunner event.

        This function must only be called on our eventloop thread.

        Parameters
        ----------
        sender : ScriptRunner | None
            The ScriptRunner that emitted the event. (This may be set to
            None when called from `handle_backmsg_exception`, if no
            ScriptRunner was active when the backmsg exception was raised.)

        event : ScriptRunnerEvent
            The event type.

        forward_msg : ForwardMsg | None
            The ForwardMsg to send to the frontend. Set only for the
            ENQUEUE_FORWARD_MSG event.

        exception : BaseException | None
            An exception thrown during compilation. Set only for the
            SCRIPT_STOPPED_WITH_COMPILE_ERROR event.

        client_state : streamlit.proto.ClientState_pb2.ClientState | None
            The ScriptRunner's final ClientState. Set only for the
            SHUTDOWN event.

        page_script_hash : str | None
            A hash of the script path corresponding to the page currently being
            run. Set only for the SCRIPT_STARTED event.
        zXThis function must only be called on the eventloop thread the AppSession was created on.z0Ignoring event from non-current ScriptRunner: %sNz9page_script_hash must be set for the SCRIPT_STARTED eventzEexception must be set for the SCRIPT_STOPPED_WITH_COMPILE_ERROR eventz/client_state must be set for the SHUTDOWN eventz-null forward_msg in ENQUEUE_FORWARD_MSG event)(rG   rE   rF   rU   rZ   r[   rM   r!   r   r*   r-   r,   r   r   _create_new_session_messager   !SCRIPT_STOPPED_WITH_COMPILE_ERRORr+   _create_script_finished_messager   FINISHED_SUCCESSFULLYFINISHED_WITH_COMPILE_ERRORrY   rO   update_watched_modulesexception_utilsmarshallsession_eventscript_compilation_exceptionSCRIPT_STOPPED_FOR_RERUNFINISHED_EARLY_FOR_RERUNSHUTDOWNr   rw   rx   ry   rD   rN   ENQUEUE_FORWARD_MSG&_create_session_status_changed_message)r\   r   r   r   r   r   r   
prev_statescript_succeededscript_finished_msgr}   app_was_runningapp_is_runnings                r3   r   z3AppSession._handle_scriptrunner_event_on_event_loop  sd   R  8 : ::::e ;:: +++ LLKUSSSF[
%444{o@@@-< !,,J -,, %%001ABB   
 &BBB)KKK{o@@@-=$(9(UU"&"F"F#<
00;# #
 %%&9:::*.D' / . I/FFHHH
 ))Z *)) ll(%BI   ))#....'@@@"&"F"F3# # %%&9:::* E+BBDDD'000((@ )(( {o@@@ $&&5HHQQQ!-D!%D';;;''> (''%%k222 %(FF(FF_,,%%d&Q&Q&S&STTTTT -,r2   c                     t                      }| j        |j        _        | j        t
          j        k    |j        _        |S )z6Create and return a session_status_changed ForwardMsg.)r   rT   session_status_changedrun_on_saverM   r*   r,   script_is_runningr   s     r3   r   z1AppSession._create_session_status_changed_messageg  s8    ll151B".K?99 	"4 
r2   c                 :    t                      }d|j        _        |S )z8Create and return a 'script_changed_on_disk' ForwardMsg.T)r   r   script_changed_on_diskr   s     r3   r   z&AppSession._create_file_change_messagep  s    ll370
r2   c                    t                      }t                      |j        _        | j        j        |j        _        | j        j        |j        _        ||j        _        t          |j        | j        j                   t          |j        j
                   t          |j        j                   |j        j        }t          |j                   t           |j        _        d                    t)          t*          t,          j                            |j        _        | j        |j        _        | j        t:          j        k    |j        _        | j        j         |_         | j!        |_"        |S )z+Create and return a new_session ForwardMsg..)#r   r9   new_sessionscript_run_idrH   namerd   r   r   _populate_config_msgr
   _populate_theme_msgcustom_theme
initialize_populate_user_info_msgrA   r%   environment_infostreamlit_versionjoinmapr6   sysversion_infopython_versionrT   session_statusr   rM   r*   r,   r   is_hellorD   r   )r\   r   r}   imsgs       r3   r   z&AppSession._create_new_session_messagev  s   ll(>(@(@%#05+/+<+M(+;(COT->-OPPPS_3444CO8999 )///2J//2xxCAQ8R8R/S/S,*.*;'K?99 	- )2'
r2   statusz)ForwardMsg.ScriptFinishedStatus.ValueTypec                 0    t                      }||_        |S )z/Create and return a script_finished ForwardMsg.)r   script_finished)r\   r  r}   s      r3   r   z*AppSession._create_script_finished_message  s     ll$
r2   c                 j    t                      }t          j        |j        j        j        |           |S )z*Create and return an Exception ForwardMsg.)r   r   r   deltanew_elementr   )r\   r   r}   s      r3   r   z$AppSession._create_exception_message  s+    ll !6!@!DDD
r2   c                    t                      }	 ddlm}  || j        j                  }|                                }|d S |\  }}}|                    d          r
|d d         }||j        _        ||j        _	        ||j        _
        |j        |j        j        d d <   |j        |j        j        d d <   |j        rt          j        j        |j        _        nOt%          |j                  dk    rt          j        j        |j        _        nt          j        j        |j        _        |                     |           d S # t.          $ r'}t0                              d|           Y d }~d S d }~ww xY w)Nr   )GitRepoz.gitz+Obtaining Git information produced an error)exc_info)r   streamlit.git_utilr  rH   rd   get_repo_infoendswithgit_info_changed
repositorybranchmoduleuntracked_filesuncommitted_filesis_head_detachedr   	GitStatesHEAD_DETACHEDstatelenahead_commitsAHEAD_OF_REMOTEDEFAULTr   r   rZ   r[   )	r\   r}   r  repo	repo_inforepository_namer  r  r   s	            r3   r   z*AppSession._handle_git_information_request  s   ll!	U22222274,=>>D**,,I .7+OVV''// 7"1#2#"6.=C +*0C '*0C '6:6JC 038<8NC 21115$ G-4->-L$**T'((1,,-4->-N$**-4->-F$*%%c***** 	U 	U 	U LLFQSLTTTTTTTTT	Us   1E C<E 
E2E--E2c                 0    |                      |           dS )a  Tell the ScriptRunner to re-run its script.

        Parameters
        ----------
        client_state : streamlit.proto.ClientState_pb2.ClientState | None
            The ClientState protobuf to run the script with, or None
            to use previous client state.

        N)r   )r\   r   s     r3   r   z'AppSession._handle_rerun_script_request  s     	<(((((r2   c                 .    |                                   dS )z1Tell the ScriptRunner to stop running its script.N)r{   r`   s    r3   r   z&AppSession._handle_stop_script_request  s      """""r2   c                     t          j                     t          j                                         t          j                                         | j                                         dS )zjClear this app's cache.

        Because this cache is global, it will be cleared for all users.

        N)r   r   r   
cache_datar   cache_resourcerW   r`   s    r3   r   z&AppSession._handle_clear_cache_request  sX     	"$$$  """$$&&&!!#####r2   c                     dS )zHandle an incoming app heartbeat.

        The heartbeat indicates the frontend is active and keeps the
        websocket from going idle and disconnecting.

        The actual handler here is a noop

        Nr1   r`   s    r3   r   z(AppSession._handle_app_heartbeat_request  s	     	r2   	new_valuec                 b    || _         |                     |                                            dS )zChange our run_on_save flag to the given value.

        The browser will be notified of the change.

        Parameters
        ----------
        new_value : bool
            New run_on_save value

        N)rT   r   r   )r\   r,  s     r3   r   z*AppSession._handle_set_run_on_save_request  s2     &!!$"M"M"O"OPPPPPr2   r   c                 >   t                      }|j        |j        _        | j                            | j        |j                  }|D ]@}|j        j        	                    t          |j        |j        |j                             A|                     |           dS )z6Handle a file_urls_request BackMsg sent by the client.)file_id
upload_url
delete_urlN)r   
request_idfile_urls_responseresponse_idrI   get_upload_urlsrD   
file_names	file_urlsappendr   r/  r0  r1  r   )r\   r   r}   upload_url_infosupload_url_infos        r3   r   z$AppSession._handle_file_urls_request  s    ll->-I*2BBG&1
 
  0 	 	O",33+3.9.9      	!!#&&&&&r2   r   )r4   N)r4   r(   )NNNN)7r.   r/   r0   __doc__r   r$   r"   r   r   r&   r   r6   r]   ra   rR   rp   r   r   rs   r_   r   r   r   BaseExceptionr   r   r   r{   r   r   propertyr   r   r   rf   rl   ri   r   r    r!   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r1   r2   r3   r;   r;   ?   s=       	 	& .2W@ W@W@  3W@ "	W@
 $,HRX,>#?W@  3W@ Xc]*+W@ &c]W@ 
W@ W@ W@ W@r   V V V V<) ) ) )+T*%5 + + + +, , , ,8.
 .t . . . .,.' .d . . . .:
- 
D 
 
 
 
:-.(;*? -.D -. -. -. -.^. . . .#y #T # # # # # # # X#S T    
J 
J 
J 
J 
J 
J 
J' ' ' '? ? ? ?$ $ $ $ -1-1.2*.
 
&
 !
 j)	

 M*
 {+
 #3-
 

 
 
 
2 -1-1.2*.GU GU&GU !GU j)	GU
 M*GU {+GU #3-GU 
GU GU GU GUR
    Z     C  J        DA	   = Z    $U $U $U $UN 59) )$[1)	) ) ) )# # # #	$ 	$ 	$ 	$	 	 	 	Q Q$ Q Q Q Q'? 't ' ' ' ' ' 'r2   r;   Config.ToolbarMode.ValueTypec                  4   d} t          j        |           }t          t          j        |                                          }|Sd                    d t          j                                        D                       }t          d| d| d|           |S )Nzclient.toolbarModez, c              3   >   K   | ]}|                                 V  d S r   )lower).0r   s     r3   	<genexpr>z$_get_toolbar_mode.<locals>.<genexpr>#  s*      "P"P17799"P"P"P"P"P"Pr2   zConfig z. expects to have one of the following values: z. Current value: )	r
   rS   getattrr   ToolbarModeupperr   keys
ValueError)
config_keyconfig_value
enum_valueallowed_valuess       r3   _get_toolbar_moderM    s    %J$Z00L;BL..00< <J "P"Pf6H6M6M6O6O"P"P"PPP-j - -%3- -*- -
 
 	

 r2   r}   c                 d   t          j        d          | _        t          j        d          | _        t          j        d          | _        t          j        d          | _        t          j        d          | _        t          j        d          dk    rd| _        t                      | _        d S )	Nzbrowser.gatherUsageStatszglobal.maxCachedMessageAgezserver.allowRunOnSavezui.hideTopBarzui.hideSidebarNavzclient.showSidebarNavigationFT)	r
   rS   gather_usage_statsmax_cached_message_ageallow_run_on_savehide_top_barhide_sidebar_navrM  toolbar_moder}   s    r3   r   r   ,  s    #./IJJC!'!23O!P!PC"-.EFFC(99C!,-@AAC788EAA#(**Cr2   c           	         ddh}t          j        d          }t          |                                          sd S |                                D ])\  }}||vr |t          | t          |          |           *| j        j        | j        j	        d}|d         }|R||vrAt                              d| dt          |                                           d           n||         | _        | j        j        | j        j        | j        j        d}|d         }|U||vrBt                              d| d	t          |                                           d
           d S ||         | _        d S d S )Nbasefonttheme)lightdark"z=" is an invalid value for theme.base. Allowed values include z . Setting theme.base to "light".)z
sans serifserif	monospacez=" is an invalid value for theme.font. Allowed values include z%. Setting theme.font to "sans serif".)r
   get_options_for_sectionanyvaluesitemssetattrr   	BaseThemeLIGHTDARKrZ   r   listrG  rW  
FontFamily
SANS_SERIFSERIF	MONOSPACErX  )	r}   enum_encoded_options
theme_optsoption_name
option_valbase_maprW  font_maprX  s	            r3   r   r   8  s   "F+/88Jz  ""## #-#3#3#5#5 A AZ222z7MC{33Z@@@ $" H fDxNN2D 2 2+/+@+@2 2 2     ~CH n/%^- H
 fDxNN7D 7 7+/+@+@7 7 7      ~CHHH r2   c                 z    t          j                    j        | _        t          j                    j        | _        d S r   )r   instanceinstallation_idinstallation_id_v3rU  s    r3   r   r   g  s0    &/11AC)244GCr2   rd   c                     t          j        |                                          D ]?\  }}| j                                        }||_        |d         |_        |d         |_        @d S )Nr   icon)r   r   rb  	app_pagesaddr   r   rw  )r}   rd   r   	page_info
page_protos        r3   r   r   l  sq     (3'<=M'N'N'T'T'V'V , ,#)]&&((
&6
#(5
#F+
, ,r2   )r4   r>  )NrE   r  r7   enumr   typingr   r   r   r   r   r	   streamlit.elements.exceptionelementsr   r   	streamlitr
   r   r   streamlit.case_convertersr   streamlit.loggerr   streamlit.proto.BackMsg_pb2r   streamlit.proto.ClientState_pb2r   streamlit.proto.Common_pb2r   r   streamlit.proto.ForwardMsg_pb2r   streamlit.proto.GitInfo_pb2r   streamlit.proto.NewSession_pb2r   r   r   r    streamlit.proto.PagesChanged_pb2r   streamlit.runtimer   r   #streamlit.runtime.forward_msg_queuer   streamlit.runtime.metrics_utilr   streamlit.runtime.script_datar   streamlit.runtime.scriptrunnerr   r    r!   +streamlit.runtime.scriptrunner.script_cacher"   streamlit.runtime.secretsr#   'streamlit.runtime.uploaded_file_managerr$   streamlit.versionr%   streamlit.watcherr&   r.   rZ   rV   r(   r*   r6   r9   r;   rM  r   r   r   r   r1   r2   r3   <module>r     s    



        G G G G G G G G G G G G G G G G 6 6 6 6 6 6 6 6 6 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 ' ' ' ' ' ' / / / / / / 7 7 7 7 7 7 @ @ @ @ @ @ @ @ 5 5 5 5 5 5 / / / / / /            : 9 9 9 9 9 5 5 5 5 5 5 5 5 ? ? ? ? ? ? 7 7 7 7 7 7 4 4 4 4 4 4 U U U U U U U U U U C C C C C C 7 7 7 7 7 7 G G G G G G 6 6 6 6 6 6 1 1 1 1 1 1	H		 5444444. . . . .d . . .    
U' U' U' U' U' U' U' U'z    	+f 	+ 	+ 	+ 	+ 	+,&. ,&4 ,& ,& ,& ,&^H Hd H H H H
,	z<'	(,<?,	, , , , , ,r2   