o
    沪g;                  
   @  s  U d Z ddlmZ ddlZddlZddlZddl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mZmZmZmZ dd	lmZ dd
lmZ eddZded< e Ze Zded< daded< dZ dZ!dZ"G dd de#e
Z$e fddd Z%dd!d"Z&dd#d$Z'dd'd(Z(dd*d+Z)ddd,d-d,ddde#d,f
dd<d=Z*dd>d?Z+e)d@dA e*dBdCd,e,dD e*dEdFdGe,dD e*dHdIe,dJddKdLZ-e*dMdNdId,e,dO e*dPdQdId,e,dO e*dRdSdId,e,dO e*dTdUdId,e,dO e*dVdWdIdXe.dO e*dYdZdId[e/dO e*d\d]dIdGe,dO e*d^d_dId,e,dO e)d`da e*dbe#dcddddeZ0e*dfe#dcddgdhZ1e*didjd,dIe,dGdk e)dldm e*dndoe$j2e#dGdp e*dqdrdse#dGdp e*dtdudGe,dGdp e)dvdw e*dxdydGe,dD e*dzd{dGe,dId| e*d}d~dGe,dD e*ddd,e,dD e*ddde#dD e)dd e*ddg d e*dddse#dD e*de#dGdej3dddZ4e*de,dcdddZ5e*ddd,e,dD e*dddIdGe,dO e*ddddZ6e*ddde/dD e*ddIdd,e,d e*ddde#dD e*dddGe,dD e*dddGe,dD e*ddde/dD e*ddde/dD e*dddId,dGe,d e*ddd,e,dD e*ddd,e,dD e*ddde/dD e)dd e*ddde#dD e*dddGe,dD e*de/dcdddZ7dgZ8e*dde8 dÝdč e*dde8 dÝdč e)ddȃ e*ddd,e,dId| e)dd̃ e*ddddGdύ e)ddу e*dddId,e,dO e*dddId,e,dO e)dd׃ e*dddč e*dddč e*dddč e*dddč e*dddč e*dddč e)dd e*dde9de:dgd dddZ;dddZ<dddZ=dddZ>dddZ?dddZ@dddZAd ddZBd!ddZCedd ZDe9de:dgZE	d"d#ddZFdddZGddd	ZH	,d$d%ddZIeIeGdGd eIeH dS (&  zLoads the configuration data.    )annotationsN)OrderedDict)Enum)AnyCallable)Signal)config_utildevelopmentenv_util	file_utilutil)ConfigOption)StreamlitAPIExceptionz.Special test section just used for unit tests.)_testzdict[str, str]_section_descriptionsdict[str, ConfigOption]_config_options_templatezdict[str, ConfigOption] | None_config_optionsz<user defined>z-command-line argument or environment variablezenvironment variablec                   @  s<   e Zd ZdZdZdZdZdZeddd	Z	edd
dZ
dS )ShowErrorDetailsConfigOptionsz7Valid options for the "client.showErrorDetails" config.full
stacktracetypenoneval
str | boolc                 C     | dv S )N)trueTrueT r   r   r   L/var/www/html/chatdoc2/venv/lib/python3.10/site-packages/streamlit/config.pyis_true_variationL      z/ShowErrorDetailsConfigOptions.is_true_variationc                 C  r   )N)falseFalseFr   r   r   r   r    is_false_variationP   r"   z0ShowErrorDetailsConfigOptions.is_false_variationN)r   r   )__name__
__module____qualname____doc__FULL
STACKTRACETYPENONEstaticmethodr!   r%   r   r   r   r    r   D   s    r   keystrvaluer   where_definedreturnNonec                 C  s<   t  t  t| || W d   dS 1 sw   Y  dS )a  Set config option.

    Run `streamlit config show` in the terminal to see all available options.

    This is an internal API. The public `st.set_option` API is implemented
    in `set_user_option`.

    Parameters
    ----------
    key : str
        The config option key of the form "section.optionName". To see all
        available options, run `streamlit config show` on a terminal.

    value
        The new value to assign to this config option.

    where_defined : str
        Tells the config system where this was set.
    N)_config_lockget_config_options_set_option)r/   r1   r2   r   r   r    
set_optionY   s   "r8   c              
   C  s^   zt |  }W n ty } ztd|  |d}~ww |jr%t| | dS t|  d|  d)a  Set a configuration option.

    Currently, only ``client`` configuration options can be set within the
    script itself:

        - ``client.showErrorDetails``
        - ``client.showSidebarNavigation``
        - ``client.toolbarMode``

    Calling ``st.set_option`` with any other option will raise a
    ``StreamlitAPIException``. When changing a configuration option in a
    running app, you may need to trigger a rerun after changing the option to
    see the effects.

    Run ``streamlit config show`` in a terminal to see all available options.

    Parameters
    ----------
    key : str
        The config option key of the form "section.optionName". To see all
        available options, run ``streamlit config show`` in a terminal.

    value
        The new value to assign to this config option.

    Example
    -------

    >>> import streamlit as st
    >>>
    >>> st.set_option("client.showErrorDetails", True)

    zUnrecognized config option: NzV cannot be set on the fly. Set as command line option, e.g. streamlit run script.py --z, or in config.toml instead.)r   KeyErrorr   
scriptabler8   )r/   r1   optker   r   r    set_user_options   s   "
r=   c                 C  sP   t  t }| |vrtd|  d||  jW  d   S 1 s!w   Y  dS )a  Return the current value of a given Streamlit configuration option.

    Run ``streamlit config show`` in a terminal to see all available options.

    Parameters
    ----------
    key : str
        The config option key of the form "section.optionName". To see all
        available options, run ``streamlit config show`` in a terminal.

    Example
    -------

    >>> import streamlit as st
    >>>
    >>> color = st.get_option("theme.primaryColor")

    zConfig key "z" not defined.N)r5   r6   RuntimeErrorr1   r/   config_optionsr   r   r    
get_option   s   $rA   sectiondict[str, Any]c                 C  sZ   t ! t }i }| D ]}|j| kr|j||j< q|W  d   S 1 s&w   Y  dS )a  Get all of the config options for the given section.

    Run `streamlit config show` in the terminal to see all available options.

    Parameters
    ----------
    section : str
        The name of the config section to fetch options for.

    Returns
    -------
    dict[str, Any]
        A dict mapping the names of the options in the given section (without
        the section name as a prefix) to their values.
    N)r5   r6   valuesrB   r1   name)rB   r@   options_for_sectionoptionr   r   r    get_options_for_section   s   
$rH   descriptionc                 C  s$   | t vsJ d|  d|t | < dS )z=Create a config section and store it globally in this module.zCannot define section "" twice.N)r   )rB   rI   r   r   r    _create_section   s   

rK   Fvisible
str | Nonedefault_val
Any | Noner:   bool
visibility
deprecateddeprecation_textexpiration_datereplaced_bytype_r   	sensitiver   c                 C  sh   t | |||||||||	|
d}|jtv s"J d|jdt | tvs.J d|  d|t| < |S )a  Create a ConfigOption and store it globally in this module.

    There are two ways to create a ConfigOption:

        (1) Simple, constant config options are created as follows:

            _create_option('section.optionName',
                description = 'Put the description here.',
                default_val = 12345)

        (2) More complex, programmable config options use decorator syntax to
        resolve their values at runtime:

            @_create_option('section.optionName')
            def _section_option_name():
                """Put the description here."""
                return 12345

    To achieve this sugar, _create_option() returns a *callable object* of type
    ConfigObject, which then decorates the function.

    NOTE: ConfigObjects call their evaluation functions *every time* the option
    is requested. To prevent this, use the `streamlit.util.memoize` decorator as
    follows:

            @_create_option('section.memoizedOptionName')
            @util.memoize
            def _section_memoized_option_name():
                """Put the description here."""

                (This function is only called once.)
                """
                return 12345

    )
rI   rN   r:   rQ   rR   rS   rT   rU   rV   rW   zSection "{}" must be one of {}.z, zCannot define option "rJ   )r   rB   r   formatjoinkeysr   )r/   rI   rN   r:   rQ   rR   rS   rT   rU   rV   rW   rG   r   r   r    _create_option   s,   0r[   c                 C  s8   zt | = tdusJ dt| = W dS  ty   Y dS w )zVRemove a ConfigOption by key from the global store.

    Only for use in testing.
    N0_config_options should always be populated here.)r   r   	Exception)r/   r   r   r    _delete_option(  s   
r^   globalz2Global options that apply across all of Streamlit.z+global.disableWidgetStateDuplicationWarninga  
        By default, Streamlit displays a warning when a user sets both a widget
        default value in the function defining the widget and a widget value via
        the widget's key in `st.session_state`.

        If you'd like to turn off this warning, set this to True.
    )rI   rN   rV   z#global.showWarningOnDirectExecutionzu
        If True, will show a warning when you run a Streamlit-enabled script
        via "python my_script.py".
    Tglobal.developmentModehidden)rQ   rV   c                   C  s"   t   odtvodtvodtvS )zzAre we in development mode.

    This option defaults to True if and only if Streamlit wasn't installed
    normally.
    zsite-packageszdist-packages__pypackages__)r
   is_pex__file__r   r   r   r    _global_development_modeV  s   
re   zglobal.e2eTestzUAre we in an e2e (playwright) test? Set automatically when our e2e tests are running.)rI   rQ   rN   rV   zglobal.unitTestzAre we in a unit test?zglobal.appTestzNAre we in an app test? Set automatically when the AppTest framework is runningz"global.suppressDeprecationWarningsz/Hide deprecation warnings in the streamlit app.zglobal.minCachedMessageSizezT
        Only cache ForwardMsgs that are greater than or equal to this minimum.
    g     @zglobal.maxCachedMessageAgez
        Expire cached ForwardMsgs whose age is greater than this
        value. A message's age is defined by how many times its script has
        finished running since the message has been accessed.
       z)global.storeCachedForwardMessagesInMemoryz
        If True, store cached ForwardMsgs in backend memory. This is an
        internal flag to validate a potential removal of the in-memory
        forward message cache.
    z4global.includeFragmentRunsInForwardMessageCacheCountaa  
        If True, the server will include fragment runs in the count for the
        forward message cache. The implication is that apps with fragments may
        see messages being removed from the cache faster. This aligns the server
        count with the frontend count. This is a temporary fix while we assess the
        design of the cache.
    loggerz-Settings to customize Streamlit log messages.zlogger.level)rV   c                   C  s   t drdS dS )zwLevel of logging for Streamlit's internal logger: "error", "warning",
    "info", or "debug".

    Default: "info"
    r`   debuginfo)rA   r   r   r   r    _logger_log_level  s   rj   zlogger.messageFormatc                  C  s   t drddlm}  | S dS )a:  String format for logging messages. If logger.datetimeFormat is set,
    logger messages will default to `%(asctime)s.%(msecs)03d %(message)s`. See
    Python's documentation for available attributes:
    https://docs.python.org/3/library/logging.html#formatter-objects

    Default: "%(asctime)s %(message)s"
    r`   r   DEFAULT_LOG_MESSAGEz%(asctime)s %(message)s)rA   streamlit.loggerrl   rk   r   r   r    _logger_message_format  s   	rn   zlogger.enableRicha~  
        Controls whether uncaught app exceptions are logged via the rich library.

        If True and if rich is installed, exception tracebacks will be logged with syntax highlighting and formatting.
        Rich tracebacks are easier to read and show more code than standard Python tracebacks.

        If set to False, the default Python traceback formatting will be used.
    )rI   rN   rQ   rV   r:   clientz(Settings for scripts that use Streamlit.zclient.showErrorDetailsa  
        Controls whether uncaught app exceptions and deprecation warnings
        are displayed in the browser. This can be one of the following:

        - "full"       : In the browser, Streamlit displays app deprecation
                         warnings and exceptions, including exception types,
                         exception messages, and associated tracebacks.
        - "stacktrace" : In the browser, Streamlit displays exceptions,
                         including exception types, generic exception messages,
                         and associated tracebacks. Deprecation warnings and
                         full exception messages will only print to the
                         console.
        - "type"       : In the browser, Streamlit displays exception types and
                         generic exception messages. Deprecation warnings, full
                         exception messages, and associated tracebacks only
                         print to the console.
        - "none"       : In the browser, Streamlit displays generic exception
                         messages. Deprecation warnings, full exception
                         messages, associated tracebacks, and exception types
                         will only print to the console.
        - True         : This is deprecated. Streamlit displays "full"
                         error details.
        - False        : This is deprecated. Streamlit displays "stacktrace"
                         error details.
    )rI   rN   rV   r:   zclient.toolbarModea  
        Change the visibility of items in the toolbar, options menu,
        and settings dialog (top right of the app).

        Allowed values:
        - "auto"      : Show the developer options if the app is accessed through
                        localhost or through Streamlit Community Cloud as a developer.
                        Hide them otherwise.
        - "developer" : Show the developer options.
        - "viewer"    : Hide the developer options.
        - "minimal"   : Show only options set externally (e.g. through
                        Streamlit Community Cloud) or through st.set_page_config.
                        If there are no options left, hide the menu.
    autozclient.showSidebarNavigationz
        Controls whether to display the default sidebar page navigation in a
        multi-page app. This only applies when app's pages are defined by the
        `pages/` directory.
    runnerz/Settings for how Streamlit executes your scriptzrunner.magicEnabledz
        Allows you to type a variable or string by itself in a single line of
        Python code to write it to the app.
    zrunner.postScriptGCz
        Run the Python Garbage Collector after each script execution. This
        can help avoid excess memory use in Streamlit apps, but could
        introduce delay in rerunning the app script for high-memory-use
        applications.
    )rI   rN   rV   rQ   zrunner.fastRerunsaZ  
        Handle script rerun requests immediately, rather than waiting for script
        execution to reach a yield point. This makes Streamlit much more
        responsive to user interaction, but it can lead to race conditions in
        apps that mutate session_state data outside of explicit session_state
        assignment statements.
    z&runner.enforceSerializableSessionStateaE  
        Raise an exception after adding unserializable data to Session State.
        Some execution environments may require serializing all data in Session
        State, so it may be useful to detect incompatibility during development,
        or when the execution environment will stop supporting it in the future.
    zrunner.enumCoerciona2  
        Adjust how certain 'options' widgets like radio, selectbox, and
        multiselect coerce Enum members when the Enum class gets re-defined
        during a script re-run. For more information, check out the docs:
        https://docs.streamlit.io/develop/concepts/design/custom-classes#enums

        Allowed values:
        - "off": Disables Enum coercion.
        - "nameOnly": Enum classes can be coerced if their member names match.
        - "nameAndValue": Enum classes can be coerced if their member names AND
          member values match.
    nameOnlyserverz!Settings for the Streamlit serverzserver.folderWatchBlacklistz
        List of folders that should not be watched for changes.

        Relative paths will be taken as relative to the current working directory.

        Example: ['/home/user1/env', 'relative/path/to/folder']
    )rI   rN   zserver.fileWatcherTypea  
        Change the type of file watcher used by Streamlit, or turn it off
        completely.

        Allowed values:
        - "auto"     : Streamlit will attempt to use the watchdog module, and
                       falls back to polling if watchdog is not available.
        - "watchdog" : Force Streamlit to use the watchdog module.
        - "poll"     : Force Streamlit to always use polling.
        - "none"     : Streamlit will not watch files.
    zserver.cookieSecret)rV   rW   c                   C  s   t  S )zSymmetric key used to produce signed cookies. If deploying on multiple
    replicas, this should be set to the same value across all replicas to ensure
    they all share the same secret.

    Default: randomly generated secret key.
    )secrets	token_hexr   r   r   r    _server_cookie_secret  s   	rv   zserver.headlessc                   C  s   t jr
tds
dS dS )zIf false, will attempt to open a browser window on start.

    Default: false unless (1) we are on a Linux box where DISPLAY is unset, or
    (2) we are running in the Streamlit Atom plugin.
    DISPLAYTF)r
   IS_LINUX_OR_BSDosgetenvr   r   r   r    _server_headless  s   r{   zserver.runOnSavezK
        Automatically rerun script when the file is modified on disk.
    zserver.allowRunOnSavezF
        Allows users to automatically rerun when app is updated.
    zserver.addressc                   C  s   dS )a  The address where the server will listen for client and browser
    connections. Use this if you want to bind the server to a specific address.
    If set, the server will only be accessible from this address, and not from
    any aliases (like localhost).

    Default: (unset)
    Nr   r   r   r   r    _server_address  s   	r|   server.portz
        The port where the server will listen for browser connections.

        Don't use port 3000 which is reserved for internal development.
    i5!  zserver.scriptHealthCheckEnableda  
        Flag for enabling the script health check endpoint. It's used for checking if
        a script loads successfully. On success, the endpoint will return a 200
        HTTP status code. On failure, the endpoint will return a 503 HTTP status code.

        Note: This is an experimental Streamlit internal API. The API is subject
        to change anytime so this should be used at your own risk
    )rQ   rI   rN   rV   zserver.baseUrlPathzN
        The base path for the URL where Streamlit should be served from.
     server.enableCORSz
        Enables support for Cross-Origin Resource Sharing (CORS) protection,
        for added security.

        If XSRF protection is enabled and CORS protection is disabled at the
        same time, Streamlit will enable them both instead.
    server.enableXsrfProtectionz
        Enables support for Cross-Site Request Forgery (XSRF) protection, for
        added security.

        If XSRF protection is enabled and CORS protection is disabled at the
        same time, Streamlit will enable them both instead.
    zserver.maxUploadSizezP
        Max size, in megabytes, for files uploaded with the file_uploader.
       zserver.maxMessageSizezh
        Max size, in megabytes, of messages that can be sent via the WebSocket
        connection.
    zserver.enableArrowTruncationz
        Enable automatically truncating all data structures that get serialized into Arrow (e.g. DataFrames)
        to ensure that the size is under `server.maxMessageSize`.
    )rI   rQ   rN   r:   rV   z!server.enableWebsocketCompressionz8
        Enables support for websocket compression.
    zserver.enableStaticServingzd
        Enable serving files from a `static` directory in the running app's
        directory.
    zserver.disconnectedSessionTTLa  
        TTL in seconds for sessions whose websockets have been disconnected. The server
        may choose to clean up session state, uploaded files, etc for a given session
        with no active websocket connection at any point after this time has passed.
    x   browserz(Configuration of non-UI browser options.zbrowser.serverAddressa7  
        Internet address where users should point their browsers in order to
        connect to the app. Can be IP address or DNS name and path.

        This is used to:
        - Set the correct URL for CORS and XSRF protection purposes.
        - Show the URL on the terminal
        - Open the browser
    	localhostzbrowser.gatherUsageStatsz<
        Whether to send usage statistics to Streamlit.
    browser.serverPortintc                   C  s   t tdS )a  Port where users should point their browsers in order to connect to the
    app.

    This is used to:
    - Set the correct URL for XSRF protection purposes.
    - Show the URL on the terminal (part of `streamlit run`).
    - Open the browser automatically (part of `streamlit run`).

    This option is for advanced use cases. To change the port of your app, use
    `server.Port` instead. Don't use port 3000 which is reserved for internal
    development.

    Default: whatever value is set in server.port.
    r}   )r   rA   r   r   r   r    _browser_server_portk  s   r   zDO NOT USE THIS OPTION IN A PRODUCTION ENVIRONMENT. It has not gone through security audits or performance tests. For the production environment, we recommend performing SSL termination by the load balancer or the reverse proxy.zserver.sslCertFilez
        Server certificate file for connecting via HTTPS.
        Must be set at the same time as "server.sslKeyFile".

        z	
        )rI   zserver.sslKeyFilez
        Cryptographic key file for connecting via HTTPS.
        Must be set at the same time as "server.sslCertFile".

        uiz6Configuration of UI elements displayed in the browser.zui.hideTopBarz
        Flag to hide most of the UI elements found at the top of a Streamlit app.

        NOTE: This does *not* hide the main menu in the top-right of an app.
    mapboxz2Mapbox configuration that is being used by DeckGL.zmapbox.tokenz
        Configure Streamlit to use a custom Mapbox
        token for elements like st.pydeck_chart and st.map.
        To get a token for yourself, create an account at
        https://mapbox.com. It's free (for moderate usage levels)!
    )rI   rN   rW   magicz4Settings for how Streamlit pre-processes your scriptzmagic.displayRootDocStringa%  
        Streamlit's "magic" parser typically skips strings that appear to be
        docstrings. When this flag is set to True, Streamlit will instead display
        the root-level docstring in the app, just like any other magic string.
        This is useful for things like notebooks.
    z"magic.displayLastExprIfNoSemicolonz
        Make Streamlit's "magic" parser always display the last expression in the
        root file if it has no semicolon at the end. This matches the behavior of
        Jupyter notebooks, for example.
    themez9Settings to define a custom theme for your Streamlit app.z
theme.basezp
        The preset Streamlit theme that your custom theme inherits from.
        One of "light" or "dark".
    ztheme.primaryColorz.Primary accent color for interactive elements.ztheme.backgroundColorz+Background color for the main content area.ztheme.secondaryBackgroundColorzCBackground color used for the sidebar and most interactive widgets.ztheme.textColorzColor used for almost all text.z
theme.fontz|
        Font family for all text in the app, except code blocks. One of "sans serif",
        "serif", or "monospace".
    rt   zSecrets configuration.zsecrets.filesa$  
        List of locations where secrets are searched. An entry can be a path to a
        TOML file or directory path where Kubernetes style secrets are saved.
        Order is important, import is first to last, so secrets in later files
        will take precedence over earlier ones.
    zsecrets.tomlc                 C  sL   t  t }| |vrtd|  ||  jW  d   S 1 sw   Y  dS )zIndicate where (e.g. in which file) this option was defined.

    Parameters
    ----------
    key : str
        The config option key of the form "section.optionName"

    zConfig key "%s" not defined.N)r5   r6   r>   r2   r?   r   r   r    get_where_defined  s   	$r   option_namec                 C  s   t | tjkS )zCheck if a given option has not been set by the user.

    Parameters
    ----------
    option_name : str
        The option to check


    Returns
    -------
    bool
        True if the option has not been set by the user.

    )r   r   DEFAULT_DEFINITIONr   r   r   r    	_is_unset*  s   r   c                 C  s   t | tjtjfvS )zCheck if a given option was actually defined by the user.

    Parameters
    ----------
    option_name : str
        The option to check


    Returns
    -------
    bool
        True if the option has been set by the user.

    )r   r   r   STREAMLIT_DEFINITIONr   r   r   r    is_manually_set<  s   r   c                   C  sF   t  tdusJ dttt W d   dS 1 sw   Y  dS )z)Print all config options to the terminal.Nr\   )r5   r   r   show_configr   r   r   r   r    r   Q  s   
"r   c                 C  sV   t dusJ d| t vr!ddlm} |t}|d|  d dS t |  || dS )a  Set a config option by key / value pair.

    This function assumes that the _config_options dictionary has already been
    populated and thus should only be used within this file and by tests.

    Parameters
    ----------
    key : str
        The key of the option, like "logger.level".
    value
        The value of the option.
    where_defined : str
        Tells the config system where this was set.

    Nr\   r   
get_logger"zg" is not a valid config option. If you previously had this config option set, it may have been removed.)r   rm   r   r&   warning	set_value)r/   r1   r2   r   LOGGERr   r   r    r7   ]  s   

r7   r@   c                 C  sB   |   D ]\}}|jsqtj|j}|du rqt||t qdS )z{Update the config system by parsing the environment variable.

    This should only be called from get_config_options.
    N)itemsrW   ry   environgetenv_varr7   _DEFINED_BY_ENV_VAR)r@   opt_nameopt_valenv_var_valuer   r   r    %_update_config_with_sensitive_env_var  s   r   raw_tomlc                 C  sX   ddl }|| }| D ]\}}| D ]\}}t|}t| d| || qqdS )a)  Update the config system by parsing this string.

    This should only be called from get_config_options.

    Parameters
    ----------
    raw_toml : str
        The TOML file to parse to update the config values.
    where_defined : str
        Tells the config system where this was set.

    r   N.)tomlloadsr   _maybe_read_env_variabler7   )r   r2   r   parsed_config_filerB   optionsrE   r1   r   r   r    _update_config_with_toml  s   
r   c                 C  sh   t | tr2| dr2| tdd }tj|}|du r.ddlm} |t	}|
d| | S t|S | S )aU  If value is "env:foo", return value of environment variable "foo".

    If value is not in the shape above, returns the value right back.

    Parameters
    ----------
    value : any
        The value to check

    Returns
    -------
    any
        Either returns value right back, or the value of the environment
        variable.

    zenv:Nr   r   z!No environment variable called %s)
isinstancer0   
startswithlenry   r   r   rm   r   r&   error_maybe_convert_to_number)r1   var_namer   r   r   r   r   r    r     s   r   vc                 C  s>   zt | W S  ty   Y nw zt| W S  ty   Y | S w )z-Convert v to int or float, or leave it as is.)r   r]   float)r   r   r   r    r     s   

r   z'Emitted when the config file is parsed.)doczconfig.tomloptions_from_flagsdict[str, Any] | Nonec              
   C  s  |si }t }|r| s|S tw t r| st W  d   S t }tta tD ](}tj|s.q%t	|dd}|
 }W d   n1 sCw   Y  t|| q%tt  | D ]
\}}t||t qV|rxt|t rxddlm}	 |	t}
|
d t  t W  d   S 1 sw   Y  dS )a  Create and return a dict mapping config option names to their values,
    returning a cached dict if possible.

    Config option values are sourced from the following locations. Values
    set in locations further down the list overwrite those set earlier.
      1. default values defined in this file
      2. the global `~/.streamlit/config.toml` file
      3. per-project `$CWD/.streamlit/config.toml` files
      4. environment variables such as `STREAMLIT_SERVER_PORT`
      5. command line flags passed to `streamlit run`

    Parameters
    ----------
    force_reparse : bool
        Force config files to be parsed so that we pick up any changes to them.

    options_from_flags : dict[str, any] or None
        Config options that we received via CLI flag.

    Returns
    -------
    dict[str, ConfigOption]
        An ordered dict that maps config option names to their values.
    Nzutf-8)encodingr   r   z{An update to the [server] config option section was detected. To have these changes be reflected, please restart streamlit.)r   r5   copydeepcopyr   CONFIG_FILENAMESry   pathexistsopenreadr   r   r   r7   _DEFINED_BY_FLAGr   server_option_changedrm   r   r&   r   _on_config_parsedsend)force_reparser   r@   old_optionsfilenameinputfile_contentsr   r   r   r   r   r   r    r6     s@   

$r6   c                  C  sj   ddl m}  | t}tdrtdsJ dtdsJ dtdr1td	r*tdr3|d
 d S d S d S )Nr   r   r`   r}   z>server.port does not work when global.developmentMode is true.r   zEbrowser.serverPort does not work when global.developmentMode is true.r   r   a  
Warning: the config option 'server.enableCORS=false' is not compatible with 'server.enableXsrfProtection=true'.
As a result, 'server.enableCORS' is being overridden to 'true'.

More information:
In order to protect against CSRF attacks, we send a cookie with each request.
To do so, we must specify allowable origins, which places a restriction on
cross-origin resource sharing.

If cross origin resource sharing is required, please disable server.enableXsrfProtection.
            )rm   r   r&   rA   r   r   )r   r   r   r   r    _check_conflicts-  s    	

r   c                   C  s   t dt_d S )Nr`   )rA   r	   is_development_moder   r   r   r    _set_development_modeU  s   r   funcCallable[[], None]Callable[[], bool]c                   sJ   fddfdd} fdd|st s tjdd |S   |S )	aS  Wait for the config file to be parsed then call func.

    If the config file has already been parsed, just calls func immediately
    unless force_connect is set.

    Parameters
    ----------
    func : Callable[[], None]
        A function to run on config parse.

    force_connect : bool
        Wait until the next config file parse to run func, even if config files
        have already been parsed.

    lock : bool
        If set, grab _config_lock before running func.

    Returns
    -------
    Callable[[], bool]
        A function that the caller can use to deregister func.
    c                   s     S Nr   )_)func_with_lockr   r    receiverx  s   z"on_config_parsed.<locals>.receiverc                     s
   t  S r   )r   
disconnectr   )r   r   r    r   {  s   
z$on_config_parsed.<locals>.disconnectc                     s>   rt     W d    d S 1 sw   Y  d S    d S r   )r5   r   )r   lockr   r    r   ~  s
   "
z(on_config_parsed.<locals>.func_with_lockF)weak)r   r   connect)r   force_connectr   r   r   )r   r   r   r   r    on_config_parsedY  s   r   )r   )r/   r0   r1   r   r2   r0   r3   r4   )r/   r0   r1   r   r3   r4   )r/   r0   r3   r   )rB   r0   r3   rC   )rB   r0   rI   r0   r3   r4   )r/   r0   rI   rM   rN   rO   r:   rP   rQ   r0   rR   rP   rS   rM   rT   rM   rU   rM   rV   r   rW   rP   r3   r   )r/   r0   r3   r4   )r3   rP   )r3   r0   )r3   rM   )r3   r   )r/   r0   r3   r0   )r   r0   r3   rP   )r3   r4   )r@   r   )r   r0   r2   r0   r3   r4   )r1   r   r3   r   )r   r   r3   r   )FN)r   r   r3   r   )FF)r   r   r3   r   )Jr)   
__future__r   r   ry   rt   	threadingcollectionsr   enumr   typingr   r   blinkerr   	streamlitr   r	   r
   r   r   streamlit.config_optionr   streamlit.errorsr   r   __annotations__RLockr5   r   r   _USER_DEFINEDr   r   r0   r   r8   r=   rA   rH   rK   r[   r^   rP   re   r   r   rj   rn   r*   memoizerv   r{   r|   r   _SSL_PRODUCTION_WARNINGget_streamlit_file_pathget_project_streamlit_file_pathr   r   r   r   r7   r   r   r   r   r   r   r6   r   r   r   r   r   r   r    <module>   s  0
H





 




	
	
	

	







	""

N(9