o
    ,&]i2                     @  sx   d dl mZ d dlmZmZmZ d dlmZmZm	Z	 d dl
mZ d dlmZ er.d dlmZ G dd deeef Zd	S )
    )annotations)IterableIteratorMutableMapping)TYPE_CHECKINGAnyoverload)gather_metrics)get_session_state)SupportsKeysAndGetItemc                   @  s@  e Zd ZdZdAddZdBddZdCd
dZeddDddZdEddZ	eddFddZ
eddDddZdEddZedGd d!ZedHd#d!ZedId%d!ZdJdKd'd!Zed(dFd)d*Zed+dLd-d.Zed/dKd0d1Zed2dMd4d5ZedNd6d7ZedOd8d7Zed9dPd;d7ZedDd<d=ZedDd>d?Zd@S )QQueryParamsProxyz
    A stateless singleton that proxies ``st.query_params`` interactions
    to the current script thread's QueryParams instance.
    returnIterator[str]c                 C  6   t   }t|W  d    S 1 sw   Y  d S N)r
   query_paramsiterselfqp r   h/var/www/html/IGF-ODF-V3/venv/lib/python3.10/site-packages/streamlit/runtime/state/query_params_proxy.py__iter__!      $zQueryParamsProxy.__iter__intc                 C  r   r   )r
   r   lenr   r   r   r   __len__%   r   zQueryParamsProxy.__len__strc                 C  r   r   )r
   r   r   r   r   r   r   __str__)   r   zQueryParamsProxy.__str__zquery_params.get_itemkeyc              	   C  sV   t   }z|| W W  d    S  ty    t| |w 1 s$w   Y  d S r   )r
   r   KeyErrormissing_key_error_messager   r   r   r   r   r   __getitem__-      zQueryParamsProxy.__getitem__Nonec                 C  s6   t   }||= W d    d S 1 sw   Y  d S r   r
   r   r"   r   r   r   __delitem__5   s   "zQueryParamsProxy.__delitem__zquery_params.set_itemvaluer   c                 C  8   t   }|||< W d    d S 1 sw   Y  d S r   r&   r   r   r(   r   r   r   r   __setitem__9      
"zQueryParamsProxy.__setitem__zquery_params.get_attrc              	   C  sV   t   }z|| W W  d    S  ty    t| |w 1 s$w   Y  d S r   )r
   r   r    AttributeErrormissing_attr_error_messager"   r   r   r   __getattr__>   r$   zQueryParamsProxy.__getattr__c              	   C  sX   t   }z||= W n ty   t| |w W d    d S 1 s%w   Y  d S r   )r
   r   r    r-   r!   r"   r   r   r   __delattr__F   s   
"zQueryParamsProxy.__delattr__params0SupportsKeysAndGetItem[str, str | Iterable[str]]kwdsc                K     d S r   r   r   r1   r3   r   r   r   updateM      zQueryParamsProxy.update)Iterable[tuple[str, str | Iterable[str]]]c                K  r4   r   r   r5   r   r   r   r6   R   r7   str | Iterable[str]c                 K  r4   r   r   )r   r3   r   r   r   r6   W      r   c                K  sB   t   }|j|fi | W d   dS 1 sw   Y  dS )a  
        Update one or more values in query_params at once from a dictionary or
        dictionary-like object.

        See `Mapping.update()` from Python's `collections` library.

        Parameters
        ----------
        other: SupportsKeysAndGetItem[str, str] | Iterable[tuple[str, str]]
            A dictionary or mapping of strings to strings.
        **kwds: str
            Additional key/value pairs to update passed as keyword arguments.
        N)r
   r   r6   )r   r1   r3   r   r   r   r   r6   Z   s   "zquery_params.set_attrc                 C  r)   r   r&   r*   r   r   r   __setattr__k   r,   zQueryParamsProxy.__setattr__zquery_params.get_all	list[str]c                 C  8   t   }||W  d   S 1 s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"   r   r   r   r>   p   s   $zQueryParamsProxy.get_allzquery_params.clearc                 C  s8   t   }|  W d   dS 1 sw   Y  dS )zs
        Clear all query parameters from the URL of the app.

        Returns
        -------
        None
        N)r
   r   clearr   r   r   r   r?      s   	
"zQueryParamsProxy.clearzquery_params.to_dictdict[str, str]c                 C  s6   t   }| W  d   S 1 sw   Y  dS )a  
        Get all query parameters as a dictionary.

        This method primarily exists for internal use and is not needed for
        most cases. ``st.query_params`` returns an object that inherits from
        ``dict`` by default.

        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 parameters in the app's URL.
        N)r
   r   to_dictr   r   r   r   rA      s   $zQueryParamsProxy.to_dictc                 C  r4   r   r   r   r1   r   r   r   	from_dict   r:   zQueryParamsProxy.from_dictc                 C  r4   r   r   rB   r   r   r   rC      r7   zquery_params.from_dict\SupportsKeysAndGetItem[str, str | Iterable[str]] | Iterable[tuple[str, str | Iterable[str]]]c                 C  r=   )a  
        Set all of the query parameters from a dictionary or dictionary-like object.

        This method primarily exists for advanced users who want to control
        multiple query parameters in a single update. To set individual query
        parameters, use key or attribute notation instead.

        This method inherits limitations from ``st.query_params`` and can't be
        used to set embedding options as described in `Embed your app         <https://docs.streamlit.io/deploy/streamlit-community-cloud/share-your-app/embed-your-app#embed-options>`_.

        To handle repeated keys, the value in a key-value pair should be a list.

        .. note::
            ``.from_dict()`` is not a direct inverse of ``.to_dict()`` if
            you are working with repeated keys. A true inverse operation is
            ``{key: st.query_params.get_all(key) for key in st.query_params}``.

        Parameters
        ----------
        params: dict
            A dictionary used to replace the current query parameters.

        Example
        -------
        >>> import streamlit as st
        >>>
        >>> st.query_params.from_dict({"foo": "bar", "baz": [1, "two"]})

        N)r
   r   rC   )r   r1   r   r   r   r   rC      s   $$c                 C     d|  dS )z3Returns a formatted error message for missing keys.zst.query_params has no key "".r   r   r   r   r   r!         z*QueryParamsProxy.missing_key_error_messagec                 C  rE   )z9Returns a formatted error message for missing attributes.z"st.query_params has no attribute "rF   r   rG   r   r   r   r.      rH   z+QueryParamsProxy.missing_attr_error_messageN)r   r   )r   r   )r   r   )r   r   r   r   )r   r   r   r%   )r   r   r(   r   r   r%   )r1   r2   r3   r   r   r%   )r1   r8   r3   r   r   r%   )r3   r9   r   r%   )r   )r   r%   )r   r   r   r<   )r   r@   )r1   r8   r   r%   )r1   r2   r   r%   )r1   rD   r   r%   )__name__
__module____qualname____doc__r   r   r   r	   r#   r'   r+   r/   r0   r   r6   r;   r>   r?   rA   rC   staticmethodr!   r.   r   r   r   r   r      sL    




&r   N)
__future__r   collections.abcr   r   r   typingr   r   r   streamlit.runtime.metrics_utilr	   +streamlit.runtime.state.session_state_proxyr
   	_typeshedr   r   r   r   r   r   r   <module>   s   