Ë
    EêñiR0  ã                  ób  — d dl mZ d dlZd dl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 d dlZd dlmZ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 erd dlm Z m!Z!  ed«      dd„«       Z"	 	 	 	 	 	 dd„Z#	 	 	 	 	 	 dd„Z$ ed«      ddœ	 	 	 dd„«       Z% ed«      ddœ	 	 	 	 	 dd„«       Z&y)é    )ÚannotationsN)ÚIterableÚMapping)Ú	dropwhile)ÚPath)ÚTYPE_CHECKINGÚLiteralÚNoReturn)ÚNoSessionContextÚStreamlitAPIException)Úget_main_script_directoryÚnormalize_path_join)ÚStreamlitPage)Úgather_metrics)Ú	RerunDataÚScriptRunContextÚget_script_run_ctx)ÚQueryParamsÚQueryParamsInputÚstopc                 ó”   — t        «       } | r<| j                  r/| j                  j                  «        t        j                  «        yyy)a�  Stops execution immediately.

    Streamlit will not run any statements after `st.stop()`.
    We recommend rendering a message to explain why the script has stopped.

    Example
    -------
    >>> import streamlit as st
    >>>
    >>> name = st.text_input("Name")
    >>> if not name:
    >>>   st.warning('Please input a name.')
    >>>   st.stop()
    >>> st.success("Thank you for inputting a name.")

    N)r   Úscript_requestsÚrequest_stopÚstÚempty)Úctxs    úf/var/www/pod-logistic/pod-ai/venv/lib/python3.12/site-packages/streamlit/commands/execution_control.pyr   r   '   s9   € ô$ Ó
€Cá
ˆs×"Ò"Ø×Ñ×(Ñ(Ô*ä
�‰�
ð #€só    c                ó’   ‡ — |dk(  rg S ‰ j                   }|st        d«      ‚t        t        ˆ fd„|«      «      }|st	        d«      ‚|S )NÚappzfscope="fragment" can only be specified from `@st.fragment`-decorated functions during fragment reruns.c                ó"   •— | ‰j                   k7  S )N)Úcurrent_fragment_id)Úxr   s    €r   ú<lambda>z(_new_fragment_id_queue.<locals>.<lambda>b   s   ø€ ¨¨c×.EÑ.EÑ)E€ r   zRCould not find current_fragment_id in fragment_id_queue. This should never happen.)Úfragment_ids_this_runr   Úlistr   ÚRuntimeError)r   ÚscopeÚ
curr_queueÚ	new_queues   `   r   Ú_new_fragment_id_queuer+   A   sd   ø€ ð �‚~Øˆ	ð ×*Ñ*€Jñ& Ü#ð0ó
ð 	
ô
 ”YÓEÀzÓRÓS€IÙÜØ`ó
ð 	
ð Ðr   c                óè   — |€| j                  «        yt        |t        «      s&t        |t        «      r(t        |t        t
        f«      s| j                  |«       yt        dt        |«      › d�«      ‚)z#Set query params for a switch page.NzM`query_params` must be a mapping or an iterable of (key, value) pairs not a `z`.)	ÚclearÚ
isinstancer   r   ÚstrÚbytesÚ	from_dictr   Útype)Úquery_params_stateÚnew_query_paramss     r   Ú_set_query_params_for_switchr5   k   sw   € ð ÐØ× Ñ Ô"ØäÐ"¤GÔ,ÜÐ#¤XÔ.ÜØÜ”%ˆLô
ð
 	×$Ñ$Ð%5Ô6Øä
Ø
WÔX\Ð]mÓXnÐWoÐoqÐróð r   Úrerunr    )r(   c           
     óP  — | dvrt        d| › d�«      ‚t        «       }|r‡|j                  rz|j                  }|j                  }|j
                  }|j                  j                  t        ||t        || «      | dk(  ||j                  ¬«      «       t        j                  «        yyy)a»  Rerun the script immediately.

    When ``st.rerun()`` is called, Streamlit halts the current script run and
    executes no further statements. Streamlit immediately queues the script to
    rerun.

    When using ``st.rerun`` in a fragment, you can scope the rerun to the
    fragment. However, if a fragment is running as part of a full-app rerun,
    a fragment-scoped rerun is not allowed.

    Parameters
    ----------
    scope : "app" or "fragment"
        Specifies what part of the app should rerun. If ``scope`` is ``"app"``
        (default), the full app reruns. If ``scope`` is ``"fragment"``,
        Streamlit only reruns the fragment from which this command is called.

        Setting ``scope="fragment"`` is only valid inside a fragment during a
        fragment rerun. If ``st.rerun(scope="fragment")`` is called during a
        full-app rerun or outside of a fragment, Streamlit will raise a
        ``StreamlitAPIException``.

    >   r    Úfragmentú'zC'is not a valid rerun scope. Valid scopes are 'app' and 'fragment'.r8   )Úquery_stringÚpage_script_hashÚfragment_id_queueÚis_fragment_scoped_rerunÚcached_message_hashesÚcontext_infoN)r   r   r   r:   r;   r>   Úrequest_rerunr   r+   r?   r   r   )r(   r   r:   r;   r>   s        r   r6   r6   „   s±   € ð: Ð'Ñ'Ü#Ø�ˆwÐYÐZó
ð 	
ô Ó
€Cá
ˆs×"Ò"Ø×'Ñ'ˆØ×/Ñ/ÐØ #× 9Ñ 9Ðà×Ñ×)Ñ)ÜØ)Ø!1Ü"8¸¸eÓ"DØ).°*Ñ)<Ø&;Ø ×-Ñ-ôô		
ô 	�‰�
ð! #€sr   Úswitch_page)Úquery_paramsc               óÎ  — t        «       }|r|j                  s
t        «       ‚d}t        | t        «      r$| j
                  rt        d«      ‚| j                  }nÞt        | t        «      rt        | «      } t        |j                  «      }t        j                  j                  t        || «      «      }|j                   j#                  «       j%                  «       }|D �cg c]  }|d   |k(  sŒ|‘Œ }}t'        |«      dk(  r/t        d| › dt        j                  j)                  |«      › d�«      ‚|d   d   }|j*                  j-                  «       5 }	t/        |	|«       t1        j2                  d	«       d
d
d
«       |j                  j5                  t7        |j8                  ||j:                  |j<                  ¬«      «       t?        j@                  «        y
c c}w # 1 sw Y   ŒixY w)uF  Programmatically switch the current page in a multipage app.

    When ``st.switch_page`` is called, the current page execution stops and
    the specified page runs as if the user clicked on it in the navigation
    menu. The specified page must be recognized by Streamlit's multipage
    architecture. Arbitrary Python scripts and URLs can't be passed to
    ``st.switch_page``.

    Parameters
    ----------
    page : str, Path, or StreamlitPage
        The page to switch to. This can be one of the following values:

        - Path to a Python file: The path can be a string or ``pathlib.Path``
          object. It can be absolute or relative to the entrypoint file. The
          Python file must be the source of a page in ``st.navigation``.

          If you are using the ``pages/`` directory instead of
          ``st.navigation``, the Python file must be your entrypoint file or
          a file in the ``pages/`` directory.

        - ``StreamlitPage``: The source of the ``StreamlitPage`` and its
          ``url_path`` must match a page defined in ``st.navigation``. The
          ``StreamlitPage`` must be internal and can't be defined by a URL.
          Use ``st.Page`` to create a ``StreamlitPage`` object.

        To switch to a page defined by a ``callable``, you must use a
        ``StreamlitPage`` object.

    query_params : dict, list of tuples, or None
        Query parameters to apply when navigating to the target page.
        This can be a dictionary or an iterable of key-value tuples. Values can
        be strings or iterables of strings (for repeated keys). When this is
        ``None`` (default), all non-embed query parameters are cleared during
        navigation.

    Examples
    --------
    **Example 1: Basic usage**

    The following example shows how to switch to a different page in a
    multipage app that uses the ``pages/`` directory:

    .. code-block:: text

        your-repository/
        â”œâ”€â”€ pages/
        â”‚   â”œâ”€â”€ page_1.py
        â”‚   â””â”€â”€ page_2.py
        â””â”€â”€ your_app.py

    >>> import streamlit as st
    >>>
    >>> if st.button("Home"):
    >>>     st.switch_page("your_app.py")
    >>> if st.button("Page 1"):
    >>>     st.switch_page("pages/page_1.py")
    >>> if st.button("Page 2"):
    >>>     st.switch_page("pages/page_2.py")

    .. output::
        https://doc-switch-page.streamlit.app/
        height: 350px

    **Example 2: Passing query parameters**

    The following example shows how to pass query parameters when switching to a
    different page. This example uses ``st.navigation`` to create a multipage app.

    .. code-block:: text

        your-repository/
        â”œâ”€â”€ page_2.py
        â””â”€â”€ your_app.py

    >>> import streamlit as st
    >>>
    >>> def page_1():
    >>>     st.title("Page 1")
    >>>     if st.button("Switch to Page 2"):
    >>>         st.switch_page("page_2.py", query_params={"utm_source": "page_1"})
    >>>
    >>> pg = st.navigation([page_1, "page_2.py"])
    >>> pg.run()

    .. output::
        https://doc-switch-page-query-params.streamlit.app/
        height: 350px

    Ú zoCannot use st.switch_page with external URL pages. Use st.page_link instead to create a link to external pages.Úscript_pathr   zCould not find page: `zK`. Must be the file path relative to the main script, from the directory: `zL`. Only the main app file and files in the `pages/` directory are supported.r;   g{®Gáz„?N)r:   r;   r>   r?   )!r   r   r   r.   r   Úis_externalr   Ú_script_hashr   r/   r   Úmain_script_pathÚosÚpathÚrealpathr   Úpages_managerÚ	get_pagesÚvaluesÚlenÚbasenameÚsession_staterB   r5   ÚtimeÚsleepr@   r   r:   r>   r?   r   r   )
ÚpagerB   r   r;   Úmain_script_directoryÚrequested_pageÚall_app_pagesÚpÚmatched_pagesÚqps
             r   rA   rA   »   sÊ  € ôB Ó
€Cá�c×)Ò)äÓ Ð àÐÜ�$œÔ&Ø×ÒÜ'ðOóð ð  ×,Ñ,Ñô �dœDÔ!Ü�t“9ˆDä 9¸#×:NÑ:NÓ OÐÜŸ™×)Ñ)ÜÐ 5°tÓ<ó
ˆð ×)Ñ)×3Ñ3Ó5×<Ñ<Ó>ˆà$1ÖX˜q°Q°}Ñ5EÈÓ5WšÐXˆÐXäˆ}Ó Ò"Ü'Ø(¨¨ð /(Ü(*¯©×(8Ñ(8Ð9NÓ(OÐ'Pð QEðEóð ð )¨Ñ+Ð,>Ñ?Ðð 
×	Ñ	×	'Ñ	'Ó	)ð ¨RÜ$ R¨Ô6ô
 	�
‰
�4Ô÷ð ×Ñ×%Ñ%ÜØ×)Ñ)Ø-Ø"%×";Ñ";Ø×)Ñ)ô		
ôô ‡H�H…Jùò; Y÷ð ús   ÃGÃ,GÅ"GÇG$)Úreturnr
   )r   r   r(   úLiteral['app', 'fragment']r[   z	list[str])r3   r   r4   úQueryParamsInput | Noner[   ÚNone)r(   r\   r[   r
   )rT   zstr | Path | StreamlitPagerB   r]   r[   r
   )'Ú
__future__r   rI   rR   Úcollections.abcr   r   Ú	itertoolsr   Úpathlibr   Útypingr   r	   r
   Ú	streamlitr   Ústreamlit.errorsr   r   Ústreamlit.file_utilr   r   Ústreamlit.navigation.pager   Ústreamlit.runtime.metrics_utilr   Ústreamlit.runtime.scriptrunnerr   r   r   Ú$streamlit.runtime.state.query_paramsr   r   r   r+   r5   r6   rA   © r   r   ú<module>rl      s  ðõ #ã 	Û ß -Ý Ý ß 3Ñ 3ã ß Dß NÝ 3Ý 9÷ñ ñ ßRñ �Óòó ðð2'Ø	ð'à%ð'ð ó'ðTØ#ðà-ðð 
óñ2 �Óð ).ñ3à%ð3ð ò3ó ð3ñl �Óð -1ñVØ
$ðVð *ðVð ò	Vó ñVr   