Ë
    úmxiV  ã                  óä   — 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	 d dl
mZ d dlmZ d dlmZmZmZ  ed	«      dd
„«       Z ed«      dd„«       Z	 	 	 	 	 	 dd„Z	 	 	 	 	 	 dd„Z	 	 	 	 	 	 dd„Zy)é    )Úannotations)ÚAny)Úparse)ÚStreamlitAPIException)Ú
ForwardMsg)Úgather_metrics)Úget_script_run_ctx)ÚEMBED_OPTIONS_QUERY_PARAMÚEMBED_QUERY_PARAMÚEMBED_QUERY_PARAMS_KEYSÚexperimental_get_query_paramsc                 óž   — t        «       } | €i S | j                  «        t        t        j                  | j
                  d¬«      t        ¬«      S )as  Return the query parameters that is currently showing in the browser's URL bar.

    Returns
    -------
    dict
      The current query parameters as a dict. "Query parameters" are the part of the URL that comes
      after the first "?".

    Example
    -------
    Let's say the user's web browser is at
    `http://localhost:8501/?show_map=True&selected=asia&selected=america`.
    Then, you can get the query parameters using the following:

    >>> import streamlit as st
    >>>
    >>> st.experimental_get_query_params()
    {"show_map": ["True"], "selected": ["asia", "america"]}

    Note that the values in the returned dict are *always* lists. This is
    because we internally use Python's urllib.parse.parse_qs(), which behaves
    this way. And this behavior makes sense when you consider that every item
    in a query string is potentially a 1-element array.

    T©Úkeep_blank_values©Úkeys_to_exclude)r	   Ú#mark_experimental_query_params_usedÚ_exclude_keys_in_dictr   Úparse_qsÚquery_stringr   )Úctxs    úc/home/htdocs/ttos/venv/lib/python3.12/site-packages/streamlit/commands/experimental_query_params.pyÚget_query_paramsr      sF   € ô6 Ó
€CØ
€{Øˆ	Ø×+Ñ+Ô-ä Ü�‰�s×'Ñ'¸4Ô@Ü/ôð ó    Úexperimental_set_query_paramsc                 óô   — t        «       }|€y|j                  «        t        «       }t        | |j                  «      |j
                  _        |j
                  j                  |_        |j                  |«       y)ad  Set the query parameters that are shown in the browser's URL bar.

    .. warning::
        Query param `embed` cannot be set using this method.

    Parameters
    ----------
    **query_params : dict
        The query parameters to set, as key-value pairs.

    Example
    -------

    To point the user's web browser to something like
    "http://localhost:8501/?show_map=True&selected=asia&selected=america",
    you would do the following:

    >>> import streamlit as st
    >>>
    >>> st.experimental_set_query_params(
    ...     show_map=True,
    ...     selected=["asia", "america"],
    ... )

    N)r	   r   r   Ú_ensure_no_embed_paramsr   Úpage_info_changedÚenqueue)Úquery_paramsr   Úmsgs      r   Úset_query_paramsr"   E   sg   € ô6 Ó
€CØ
€{ØØ×+Ñ+Ô-ä
‹,€CÜ)@Ø�c×&Ñ&ó*€C×ÑÔ&ð ×,Ñ,×9Ñ9€CÔØ‡K�K�Õr   c                ó|   — | j                  «       D ��ci c]  \  }}|j                  «       |vsŒ||“Œ c}}S c c}}w )z?Returns new object but without keys defined in keys_to_exclude.)ÚitemsÚlower)Údr   ÚkeyÚvalues       r   r   r   m   s<   € ð
 &'§W¡W£Y÷Ù!�s˜E°#·)±)³+À_Ò2TˆˆU‰
óð ùó s   ”8¯8c           	     ó  — | D ��cg c]G  }|j                  «       |k(  r2| j                  |«      r!| |   D �cg c]  }|j                  «       ‘Œ c}‘ŒI c}}D ��ch c]  }|D ]  }|j                  «       ’Œ Œ c}}S c c}w c c}}w c c}}w )zWExtracts key (case-insensitive) query params from Dict, and returns them as Set of str.)r%   Úget)r    Ú	param_keyr'   r(   ÚsublistÚitems         r   Ú_extract_key_query_paramsr.   v   s�   € ð $÷
àØ�y‰y‹{˜iÒ'¨L×,<Ñ,<¸SÔ,Að )5°SÑ(9Ö:˜uˆU�[‰[�]Ô:ó
÷àð
 òð ð 	�
‰
�ðØóð ùò ;ùó
ùós   †0B ¶A;ÁB ÁBÁ;B c                ó€  — t        | t        ¬«      }| |k7  rt        d«      ‚t        j                  |d¬«      }t        j
                  t        t        t        |t        ¬«      «      t        t        t        |t        ¬«      «      id¬«      }t        j
                  | d¬«      }|r|rdnd}|j                  ||g«      S |S )	z¼Ensures there are no embed params set (raises StreamlitAPIException) if there is a try,
    also makes sure old param values in query_string are preserved. Returns query_string : str.
    r   zcQuery param embed and embed_options (case-insensitive) cannot be set using set_query_params method.Tr   )r+   )Údoseqú&Ú )r   r   r   r   r   Ú	urlencoder   Úlistr.   r
   Újoin)r    r   Úquery_params_without_embedÚall_current_paramsÚcurrent_embed_paramsÚ	separators         r   r   r   …   sÇ   € ô "7ØÔ&=ô"Ðð Ð1Ò1Ü#Øqó
ð 	
ô Ÿ™¨ÈÔMÐÜ Ÿ?™?äœtÜ)Ø&Ô2Côó ô
 &¤tÜ)Ø&Ô2Kôó(ð	
ð ôÐô —?‘? <°tÔ<€LáÙ/‘C°Rˆ	Ø�~‰~˜|Ð-AÐBÓCÐCØÐr   N)Úreturnúdict[str, list[str]])r    r   r:   ÚNone)r&   údict[str, Any]r   z	list[str]r:   r=   )r    r;   r+   Ústrr:   zset[str])r    zdict[str, list[str] | str]r   r>   r:   r>   )Ú
__future__r   Útypingr   Úurllibr   Ústreamlit.errorsr   Ústreamlit.proto.ForwardMsg_pb2r   Ústreamlit.runtime.metrics_utilr   Ú7streamlit.runtime.scriptrunner_utils.script_run_contextr	   Ú$streamlit.runtime.state.query_paramsr
   r   r   r   r"   r   r.   r   © r   r   ú<module>rH      s³   ðõ #å Ý å 2Ý 5Ý 9Ý V÷ñ ñ Ð/Ó0ò"ó 1ð"ñJ Ð/Ó0ò$ó 1ð$ðNØðØ(1ðàóðØ&ðØ36ðàóð$ Ø,ð$ Ø<?ð$ àô$ r   