
    &eA                     v    d dl mZmZmZmZmZmZ d dlmZ d dl	m
Z
 d dlmZ  G d deeef                   ZdS )    )DictIterableIteratorListMutableMappingUnion)gather_metrics)missing_key_error_message)get_session_statec                      e Zd ZdZdee         fdZdefdZ e	d          dedefd            Z
deddfd	Z e	d
          dedeeee         f         ddfd            Z e	d          dedefd            ZdeddfdZ e	d          dedeeee         f         ddfd            Z e	d          dedee         fd            Z e	d          dd            Z e	d          deeef         fd            ZdS )QueryParamsProxyz
    A stateless singleton that proxies ``st.query_params`` interactions
    to the current script thread's QueryParams instance.
    returnc                     t                                                      5 }t          |          cd d d            S # 1 swxY w Y   d S N)r   query_paramsiterselfqps     Jlib/python3.11/site-packages/streamlit/runtime/state/query_params_proxy.py__iter__zQueryParamsProxy.__iter__   s      --// 	288	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   =AAc                     t                                                      5 }t          |          cd d d            S # 1 swxY w Y   d S r   )r   r   lenr   s     r   __len__zQueryParamsProxy.__len__    s      --// 	2r77	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	r   zquery_params.get_itemkeyc                     t                                                      5 }||         cd d d            S # 1 swxY w Y   d S r   r   r   r   r   r   s      r   __getitem__zQueryParamsProxy.__getitem__$   s      --// 	2c7	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   6::Nc                 ~    t                                                      5 }||= d d d            d S # 1 swxY w Y   d S r   r   r   s      r   __delitem__zQueryParamsProxy.__delitem__)   s      --// 	23	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   266zquery_params.set_itemvaluec                     t                                                      5 }|||<   d d d            d S # 1 swxY w Y   d S r   r   r   r   r#   r   s       r   __setitem__zQueryParamsProxy.__setitem__-         --// 	2BsG	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   488zquery_params.get_attrc                     t                                                      5 }	 ||         cd d d            S # t          $ r t          t	          |                    w xY w# 1 swxY w Y   d S r   r   r   KeyErrorAttributeErrorr
   r   s      r   __getattr__zQueryParamsProxy.__getattr__2   s      --// 	E2E#w	E 	E 	E 	E 	E 	E 	E 	E  E E E$%>s%C%CDDDE	E 	E 	E 	E 	E 	E 	E 	E 	E 	Es    A!7'AA!!A%(A%c                     t                                                      5 }	 ||= n*# t          $ r t          t	          |                    w xY w	 d d d            d S # 1 swxY w Y   d S r   r*   r   s      r   __delattr__zQueryParamsProxy.__delattr__:   s      --// 	E2EsGG E E E$%>s%C%CDDDE 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	Es%   A'A'AAA#&A#zquery_params.set_attrc                     t                                                      5 }|||<   d d d            d S # 1 swxY w Y   d S r   r   r%   s       r   __setattr__zQueryParamsProxy.__setattr__A   r'   r(   zquery_params.get_allc                     t                                                      5 }|                    |          cddd           S # 1 swxY w Y   dS )aK  
        Get a list of all query parameter values associated to a given key.

        When a key is repeated as a query parameter within the URL, this method
        allows all values to be obtained. In contrast, dict-like methods only
        retrieve the last value when a key is repeated in the URL.

        Parameters
        ----------
        key: str
            The label of the query parameter in the URL.

        Returns
        -------
        List[str]
            A list of values associated to the given key. May return zero, one,
            or multiple values.
        N)r   r   get_allr   s      r   r3   zQueryParamsProxy.get_allF   s    (   --// 	#2::c??	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#   AA
Azquery_params.clearc                     t                                                      5 }|                                 ddd           dS # 1 swxY w Y   dS )zs
        Clear all query parameters from the URL of the app.

        Returns
        -------
        None
        N)r   r   clearr   s     r   r6   zQueryParamsProxy.clear]   s       --// 	2HHJJJ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	r4   zquery_params.to_dictc                     t                                                      5 }|                                cddd           S # 1 swxY w Y   dS )aI  
        Get all query parameters as a dictionary.

        When a key is repeated as a query parameter within the URL, this method
        will return only the last value of each unique key.

        Returns
        -------
        Dict[str,str]
            A dictionary of the current query paramters in the app's URL.
        N)r   r   to_dictr   s     r   r8   zQueryParamsProxy.to_dicti   s       --// 	 2::<<	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 s   AA	A)r   N)__name__
__module____qualname____doc__r   strr   intr   r	   r    r"   r   r   r&   r-   r/   r1   r   r3   r6   r   r8        r   r   r      s_        
(3-         ^+,,s s    -,s t     ^+,,s 5hsm1C+D     -, ^+,,Es Es E E E -,EEs Et E E E E ^+,,s 5hsm1C+D     -, ^*++#3 #49 # # # ,+#, ^())	 	 	 *)	 ^*++ c3h       ,+     r@   r   N)typingr   r   r   r   r   r   streamlit.runtime.metrics_utilr	   $streamlit.runtime.state.query_paramsr
   +streamlit.runtime.state.session_state_proxyr   r=   r   r?   r@   r   <module>rE      s    I H H H H H H H H H H H H H H H 9 9 9 9 9 9 J J J J J J I I I I I Ia  a  a  a  a ~c3h/ a  a  a  a  a r@   