
    /_iY                       U d dl mZ d dlZd dl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mZmZmZmZ d dlmZ d d	lmZmZ d d
lmZmZmZ d dlmZ d dlm Z  d dl!m"Z"m#Z#m$Z$m%Z% d dl&m'Z'm(Z(m)Z) d dl*m+Z+m,Z, d dl-m.Z. d dl/m0Z1 d dl2m3Z4 d dl5m6Z7 d dl8m9Z: d dl;m<Z< d dl=m>Z> d dl?m@Z@ d dlAmBZBmCZC d dlDmEZEmFZFmGZGmHZH d dlImJZJ d dlKmLZL d dlMmNZN d dlOmPZP erd dlQmRZR d dlImSZS d ZTd!eUd"<   eVeWz  ez  ez  ej                  z  eg eVeWz  ez  ez  ej                  z  f   z  ZYd#eUd$<   e G d% d&             ZZ G d' d(      Z[	 d*	 	 	 	 	 	 	 	 	 	 	 d+d)Z\y),    )annotationsN)Callable)	dataclass)Path)dedent)TYPE_CHECKINGBinaryIOFinalLiteralTextIO	TypeAliascast)runtime)current_form_id
is_in_form)LayoutConfigWidthvalidate_width)check_widget_policies)normalize_shortcut)Keycompute_and_register_element_idsave_for_app_testingto_key)StreamlitAPIExceptionStreamlitMissingPageLabelErrorStreamlitPageNotFoundError)get_main_script_directorynormalize_path_join)StreamlitPage)Button)DownloadButton)
LinkButton)PageLink)$convert_data_to_bytes_and_infer_mime)gather_metrics)PagesManager)ScriptRunContextget_script_run_ctx)
WidgetArgsWidgetCallbackWidgetKwargsregister_widget)process_query_params)validate_icon_or_emoji)is_url)
in_sidebar)DeltaGenerator)QueryParamsInputz

For more information, refer to the
[documentation for forms](https://docs.streamlit.io/develop/api-reference/execution-flow/st.form).
r
   FORM_DOCS_INFOr   DownloadButtonDataTypec                      e Zd ZddZddZy)ButtonSerdec                    t        |      S N)bool)selfvs     `/var/www/html/land_sniper/venv/lib/python3.12/site-packages/streamlit/elements/widgets/button.py	serializezButtonSerde.serialize\   s    Aw    c                    |xs dS )NF )r;   ui_values     r=   deserializezButtonSerde.deserialize_   s     5 r?   N)r<   r:   returnr:   )rB   bool | NonerD   r:   )__name__
__module____qualname__r>   rC   rA   r?   r=   r7   r7   Z   s    !r?   r7   c            	         e Zd Z ed      	 	 	 	 	 dddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Z ed      	 	 	 	 	 	 	 dddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd	       Z ed
      dddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Z ed      dddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Z	 	 	 	 	 	 	 dddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZdddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ	ddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d dZ
	 	 	 d!ddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d"dZed#d       Zy)$ButtonMixinbuttonN	secondaryFcontent)typeicondisableduse_container_widthwidthshortcutc                   t        |      }t               }|
|
rdnd}|dvrt        d| d      | j                  j	                  |||d||||	|||||      S )u   Display a button widget.

        Parameters
        ----------
        label : str
            A short label explaining to the user what this button is for.
            The label can optionally contain GitHub-flavored Markdown of the
            following types: Bold, Italics, Strikethroughs, Inline Code, Links,
            and Images. Images display like icons, with a max height equal to
            the font height.

            Unsupported Markdown elements are unwrapped so only their children
            (text contents) render. Display unsupported elements as literal
            characters by backslash-escaping them. E.g.,
            ``"1\. Not an ordered list"``.

            See the ``body`` parameter of |st.markdown|_ for additional,
            supported Markdown directives.

            .. |st.markdown| replace:: ``st.markdown``
            .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown

        key : str or int
            An optional string or integer to use as the unique key for the widget.
            If this is omitted, a key will be generated for the widget
            based on its content. No two widgets may have the same key.

        help : str or None
            A tooltip that gets displayed when the button is hovered over. If
            this is ``None`` (default), no tooltip is displayed.

            The tooltip can optionally contain GitHub-flavored Markdown,
            including the Markdown directives described in the ``body``
            parameter of ``st.markdown``.

        on_click : callable
            An optional callback invoked when this button is clicked.

        args : list or tuple
            An optional list or tuple of args to pass to the callback.

        kwargs : dict
            An optional dict of kwargs to pass to the callback.

        type : "primary", "secondary", or "tertiary"
            An optional string that specifies the button type. This can be one
            of the following:

            - ``"primary"``: The button's background is the app's primary color
              for additional emphasis.
            - ``"secondary"`` (default): The button's background coordinates
              with the app's background color for normal emphasis.
            - ``"tertiary"``: The button is plain text without a border or
              background for subtlety.

        icon : str or None
            An optional emoji or icon to display next to the button label. If ``icon``
            is ``None`` (default), no icon is displayed. If ``icon`` is a
            string, the following options are valid:

            - A single-character emoji. For example, you can set ``icon="🚨"``
              or ``icon="🔥"``. Emoji short codes are not supported.

            - An icon from the Material Symbols library (rounded style) in the
              format ``":material/icon_name:"`` where "icon_name" is the name
              of the icon in snake case.

              For example, ``icon=":material/thumb_up:"`` will display the
              Thumb Up icon. Find additional icons in the `Material Symbols \
              <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
              font library.

            - ``"spinner"``: Displays a spinner as an icon.

        disabled : bool
            An optional boolean that disables the button if set to ``True``.
            The default is ``False``.

        use_container_width : bool
            Whether to expand the button's width to fill its parent container.
            If ``use_container_width`` is ``False`` (default), Streamlit sizes
            the button to fit its contents. If ``use_container_width`` is
            ``True``, the width of the button matches its parent container.

            In both cases, if the contents of the button are wider than the
            parent container, the contents will line wrap.

            .. deprecated::
                ``use_container_width`` is deprecated and will be removed in a
                future release. For ``use_container_width=True``, use
                ``width="stretch"``. For ``use_container_width=False``, use
                ``width="content"``.

        width : "content", "stretch", or int
            The width of the button. This can be one of the following:

            - ``"content"`` (default): The width of the button matches the
              width of its content, but doesn't exceed the width of the parent
              container.
            - ``"stretch"``: The width of the button matches the width of the
              parent container.
            - An integer specifying the width in pixels: The button has a
              fixed width. If the specified width is greater than the width of
              the parent container, the width of the button matches the width
              of the parent container.

        shortcut : str or None
            An optional keyboard shortcut that triggers the button. This can be
            one of the following strings:

            - A single alphanumeric key like ``"K"`` or ``"4"``.
            - A function key like ``"F11"``.
            - A special key like ``"Enter"``, ``"Esc"``, or ``"Tab"``.
            - Any of the above combined with modifiers. For example, you can use
              ``"Ctrl+K"`` or ``"Cmd+Shift+O"``.

            .. important::
                The keys ``"C"`` and ``"R"`` are reserved and can't be used,
                even with modifiers. Punctuation keys like ``"."`` and ``","``
                aren't currently supported.

            The following special keys are supported: Backspace, Delete, Down,
            End, Enter, Esc, Home, Left, PageDown, PageUp, Right, Space, Tab,
            and Up.

            The following modifiers are supported: Alt, Ctrl, Cmd, Meta, Mod,
            Option, Shift.

            - Ctrl, Cmd, Meta, and Mod are interchangeable and will display to
              the user to match their platform.
            - Option and Alt are interchangeable and will display to the user
              to match their platform.

        Returns
        -------
        bool
            True if the button was clicked on the last run of the app,
            False otherwise.

        Examples
        --------
        **Example 1: Customize your button type**

        >>> import streamlit as st
        >>>
        >>> st.button("Reset", type="primary")
        >>> if st.button("Say hello"):
        ...     st.write("Why hello there")
        ... else:
        ...     st.write("Goodbye")
        >>>
        >>> if st.button("Aloha", type="tertiary"):
        ...     st.write("Ciao")

        .. output::
           https://doc-buton.streamlit.app/
           height: 300px

        **Example 2: Add icons to your button**

        Although you can add icons to your buttons through Markdown, the
        ``icon`` parameter is a convenient and consistent alternative.

        >>> import streamlit as st
        >>>
        >>> left, middle, right = st.columns(3)
        >>> if left.button("Plain button", width="stretch"):
        ...     left.markdown("You clicked the plain button.")
        >>> if middle.button("Emoji button", icon="😃", width="stretch"):
        ...     middle.markdown("You clicked the emoji button.")
        >>> if right.button("Material button", icon=":material/mood:", width="stretch"):
        ...     right.markdown("You clicked the Material button.")

        .. output::
           https://doc-button-icons.streamlit.app/
           height: 220px

        **Example 3: Use keyboard shortcuts**

        The following example shows how to use keyboard shortcuts to trigger a
        button. If you use any of the platform-dependent modifiers (Ctrl, Cmd,
        or Mod), they are interpreted interchangeably and always displayed to
        the user to match their platform.

        >>> import streamlit as st
        >>>
        >>> with st.container(horizontal=True, horizontal_alignment="distribute"):
        >>>     "`A`" if st.button("A", shortcut="A") else "` `"
        >>>     "`S`" if st.button("S", shortcut="Ctrl+S") else "` `"
        >>>     "`D`" if st.button("D", shortcut="Cmd+Shift+D") else "` `"
        >>>     "`F`" if st.button("F", shortcut="Mod+Alt+Shift+F") else "` `"

        .. output::
           https://doc-button-shortcuts.streamlit.app/
           height: 220px

        stretchrM   primaryrL   tertiaryzhThe type argument to st.button must be "primary", "secondary", or "tertiary". 
The argument passed was "".F)
is_form_submitteron_clickargskwargsrP   rN   rO   ctxrR   rS   )r   r)   r   dg_button)r;   labelkeyhelpr[   r\   r]   rN   rO   rP   rQ   rR   rS   r^   s                 r=   rK   zButtonMixin.buttond   s    l Sk "*!4I)E ;;'..2V27 
 ww#  
 	
r?   download_buttonc
                   t               }||rdnd}|
dvrt        d|
 d      | j                  |||||||||	|
|||||      S )u_7  Display a download button widget.

        This is useful when you would like to provide a way for your users
        to download a file directly from your app.

        If you pass the data directly to the ``data`` parameter, then the data
        is stored in-memory while the user is connected. It's a good idea to
        keep file sizes under a couple hundred megabytes to conserve memory or
        use deferred data generation by passing a callable to the ``data``
        parameter.

        If you want to prevent your app from rerunning when a user clicks the
        download button, wrap the download button in a `fragment
        <https://docs.streamlit.io/develop/concepts/architecture/fragments>`_.

        Parameters
        ----------
        label : str
            A short label explaining to the user what this button is for.
            The label can optionally contain GitHub-flavored Markdown of the
            following types: Bold, Italics, Strikethroughs, Inline Code, Links,
            and Images. Images display like icons, with a max height equal to
            the font height.

            Unsupported Markdown elements are unwrapped so only their children
            (text contents) render. Display unsupported elements as literal
            characters by backslash-escaping them. E.g.,
            ``"1\. Not an ordered list"``.

            See the ``body`` parameter of |st.markdown|_ for additional,
            supported Markdown directives.

            .. |st.markdown| replace:: ``st.markdown``
            .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown

        data : str, bytes, file-like, or callable
            The contents of the file to be downloaded or a callable that
            returns the contents of the file.

            File contents can be a string, bytes, or file-like object.
            File-like objects include ``io.BytesIO``, ``io.StringIO``, or any
            class that implements the abstract base class ``io.RawIOBase``.

            If a callable is passed, it is executed when the user clicks
            the download button and runs on a separate thread from the
            resulting script rerun. This deferred generation is helpful for
            large files to avoid blocking the page script. The callable can't
            accept any arguments. If any Streamlit commands are executed inside
            the callable, they will be ignored.

            To prevent unnecessary recomputation, use caching when converting
            your data for download. For more information, see the Example 1
            below.

        file_name: str
            An optional string to use as the name of the file to be downloaded,
            such as ``"my_file.csv"``. If not specified, the name will be
            automatically generated.

        mime : str or None
            The MIME type of the data. If this is ``None`` (default), Streamlit
            sets the MIME type depending on the value of ``data`` as follows:

            - If ``data`` is a string or textual file (i.e. ``str`` or
              ``io.TextIOWrapper`` object), Streamlit uses the "text/plain"
              MIME type.
            - If ``data`` is a binary file or bytes (i.e. ``bytes``,
              ``io.BytesIO``, ``io.BufferedReader``, or ``io.RawIOBase``
              object), Streamlit uses the "application/octet-stream" MIME type.

            For more information about MIME types, see
            https://www.iana.org/assignments/media-types/media-types.xhtml.

        key : str or int
            An optional string or integer to use as the unique key for the widget.
            If this is omitted, a key will be generated for the widget
            based on its content. No two widgets may have the same key.

        help : str or None
            A tooltip that gets displayed when the button is hovered over. If
            this is ``None`` (default), no tooltip is displayed.

            The tooltip can optionally contain GitHub-flavored Markdown,
            including the Markdown directives described in the ``body``
            parameter of ``st.markdown``.

        on_click : callable, "rerun", "ignore", or None
            How the button should respond to user interaction. This controls
            whether or not the button triggers a rerun and if a callback
            function is called. This can be one of the following values:

            - ``"rerun"`` (default): The user downloads the file and the app
              reruns. No callback function is called.
            - ``"ignore"``: The user downloads the file and the app doesn't
              rerun. No callback function is called.
            - A ``callable``: The user downloads the file and app reruns. The
              callable is called before the rest of the app.
            - ``None``: This is same as ``on_click="rerun"``. This value exists
              for backwards compatibility and shouldn't be used.

        args : list or tuple
            An optional list or tuple of args to pass to the callback.

        kwargs : dict
            An optional dict of kwargs to pass to the callback.

        type : "primary", "secondary", or "tertiary"
            An optional string that specifies the button type. This can be one
            of the following:

            - ``"primary"``: The button's background is the app's primary color
              for additional emphasis.
            - ``"secondary"`` (default): The button's background coordinates
              with the app's background color for normal emphasis.
            - ``"tertiary"``: The button is plain text without a border or
              background for subtlety.

        icon : str or None
            An optional emoji or icon to display next to the button label. If ``icon``
            is ``None`` (default), no icon is displayed. If ``icon`` is a
            string, the following options are valid:

            - A single-character emoji. For example, you can set ``icon="🚨"``
              or ``icon="🔥"``. Emoji short codes are not supported.

            - An icon from the Material Symbols library (rounded style) in the
              format ``":material/icon_name:"`` where "icon_name" is the name
              of the icon in snake case.

              For example, ``icon=":material/thumb_up:"`` will display the
              Thumb Up icon. Find additional icons in the `Material Symbols \
              <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
              font library.

            - ``"spinner"``: Displays a spinner as an icon.

        disabled : bool
            An optional boolean that disables the download button if set to
            ``True``. The default is ``False``.

        use_container_width : bool
            Whether to expand the button's width to fill its parent container.
            If ``use_container_width`` is ``False`` (default), Streamlit sizes
            the button to fit its contents. If ``use_container_width`` is
            ``True``, the width of the button matches its parent container.

            In both cases, if the contents of the button are wider than the
            parent container, the contents will line wrap.

            .. deprecated::
                ``use_container_width`` is deprecated and will be removed in a
                future release. For ``use_container_width=True``, use
                ``width="stretch"``. For ``use_container_width=False``, use
                ``width="content"``.

        width : "content", "stretch", or int
            The width of the download button. This can be one of the following:

            - ``"content"`` (default): The width of the button matches the
              width of its content, but doesn't exceed the width of the parent
              container.
            - ``"stretch"``: The width of the button matches the width of the
              parent container.
            - An integer specifying the width in pixels: The button has a
              fixed width. If the specified width is greater than the width of
              the parent container, the width of the button matches the width
              of the parent container.

        shortcut : str or None
            An optional keyboard shortcut that triggers the button. This can be
            one of the following strings:

            - A single alphanumeric key like ``"K"`` or ``"4"``.
            - A function key like ``"F11"``.
            - A special key like ``"Enter"``, ``"Esc"``, or ``"Tab"``.
            - Any of the above combined with modifiers. For example, you can use
              ``"Ctrl+K"`` or ``"Cmd+Shift+O"``.

            .. important::
                The keys ``"C"`` and ``"R"`` are reserved and can't be used,
                even with modifiers. Punctuation keys like ``"."`` and ``","``
                aren't currently supported.

            For a list of supported keys and modifiers, see the documentation
            for |st.button|_.

            .. |st.button| replace:: ``st.button``
            .. _st.button: https://docs.streamlit.io/develop/api-reference/widgets/st.button

        Returns
        -------
        bool
            True if the button was clicked on the last run of the app,
            False otherwise.

        Examples
        --------
        **Example 1: Download a dataframe as a CSV file**

        When working with a large dataframe, it's recommended to fetch your
        data with a cached function. When working with a download button, it's
        similarly recommended to convert your data into a downloadable format
        with a cached function. Caching ensures that the app reruns
        efficiently.

        >>> import streamlit as st
        >>> import pandas as pd
        >>> import numpy as np
        >>>
        >>> @st.cache_data
        >>> def get_data():
        >>>     df = pd.DataFrame(
        ...         np.random.randn(50, 20), columns=("col %d" % i for i in range(20))
        ...     )
        >>>     return df
        >>>
        >>> @st.cache_data
        >>> def convert_for_download(df):
        >>>     return df.to_csv().encode("utf-8")
        >>>
        >>> df = get_data()
        >>> csv = convert_for_download(df)
        >>>
        >>> st.download_button(
        ...     label="Download CSV",
        ...     data=csv,
        ...     file_name="data.csv",
        ...     mime="text/csv",
        ...     icon=":material/download:",
        ... )

        .. output::
           https://doc-download-button-csv.streamlit.app/
           height: 200px

        **Example 2: Download a string as a text file**

        If you pass a string to the ``data`` argument, Streamlit will
        automatically use the "text/plain" MIME type.

        When you have a widget (like a text area) affecting the value of your
        download, it's recommended to use another button to prepare the
        download. In this case, use ``on_click="ignore"`` in your download
        button to prevent the download button from rerunning your app. This
        turns the download button into a frontend-only element that can be
        nested in another button.

        Without a preparation button, a user can type something into the text
        area and immediately click the download button. Because a download is
        initiated concurrently with the app rerun, this can create a race-like
        condition where the user doesn't see the updated data in their
        download.

        .. important::
           Even when you prevent your download button from triggering a rerun,
           another widget with a pending change can still trigger a rerun. For
           example, if a text area has a pending change when a user clicks a
           download button, the text area will trigger a rerun.

        >>> import streamlit as st
        >>>
        >>> message = st.text_area("Message", value="Lorem ipsum.\nStreamlit is cool.")
        >>>
        >>> if st.button("Prepare download"):
        >>>     st.download_button(
        ...         label="Download text",
        ...         data=message,
        ...         file_name="message.txt",
        ...         on_click="ignore",
        ...         type="primary",
        ...         icon=":material/download:",
        ...     )

        .. output::
           https://doc-download-button-text.streamlit.app/
           height: 250px

        **Example 3: Download a file**

        Use a context manager to open and read a local file on your Streamlit
        server. Pass the ``io.BufferedReader`` object directly to ``data``.
        Remember to specify the MIME type if you don't want the default
        type of ``"application/octet-stream"`` for generic binary data. In the
        example below, the MIME type is set to ``"image/png"`` for a PNG file.

        >>> import streamlit as st
        >>>
        >>> with open("flower.png", "rb") as file:
        ...     st.download_button(
        ...         label="Download image",
        ...         data=file,
        ...         file_name="flower.png",
        ...         mime="image/png",
        ...     )

        .. output::
           https://doc-download-button-file.streamlit.app/
           height: 200px

        **Example 4: Generate the data on-click with a callable**

        Pass a callable to ``data`` to generate the bytes lazily when the user
        clicks the button. Streamlit commands inside this callable are ignored.
        The callable can't accept any arguments and must return a file-like
        object.

        >>> import streamlit as st
        >>> import time
        >>>
        >>> def make_report():
        >>>     time.sleep(1)
        >>>     return "col1,col2\n1,2\n3,4".encode("utf-8")
        >>>
        >>> st.download_button(
        ...     label="Download report",
        ...     data=make_report,
        ...     file_name="report.csv",
        ...     mime="text/csv",
        ... )

        .. output::
           https://doc-download-button-deferred.streamlit.app/
           height: 200px

        rU   rM   rV   zqThe type argument to st.download_button must be "primary", "secondary", or "tertiary". 
The argument passed was "rY   )ra   data	file_namemimerb   rc   r[   r\   r]   rN   rO   rP   r^   rR   rS   )r)   r   _download_button)r;   ra   rf   rg   rh   rb   rc   r[   r\   r]   rN   rO   rP   rQ   rR   rS   r^   s                    r=   rd   zButtonMixin.download_buttonW  s    r
 !"*!4I)E;;',,065 
 $$ % 
 	
r?   link_button)rc   rN   rO   rP   rQ   rR   rS   c          
     j    |dvrt        d| d      ||rdnd}| j                  ||||||||	      S )u  Display a link button element.

        When clicked, a new tab will be opened to the specified URL. This will
        create a new session for the user if directed within the app.

        Parameters
        ----------
        label : str
            A short label explaining to the user what this button is for.
            The label can optionally contain GitHub-flavored Markdown of the
            following types: Bold, Italics, Strikethroughs, Inline Code, Links,
            and Images. Images display like icons, with a max height equal to
            the font height.

            Unsupported Markdown elements are unwrapped so only their children
            (text contents) render. Display unsupported elements as literal
            characters by backslash-escaping them. E.g.,
            ``"1\. Not an ordered list"``.

            See the ``body`` parameter of |st.markdown|_ for additional,
            supported Markdown directives.

            .. |st.markdown| replace:: ``st.markdown``
            .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown

        url : str
            The url to be opened on user click

        help : str or None
            A tooltip that gets displayed when the button is hovered over. If
            this is ``None`` (default), no tooltip is displayed.

            The tooltip can optionally contain GitHub-flavored Markdown,
            including the Markdown directives described in the ``body``
            parameter of ``st.markdown``.

        type : "primary", "secondary", or "tertiary"
            An optional string that specifies the button type. This can be one
            of the following:

            - ``"primary"``: The button's background is the app's primary color
              for additional emphasis.
            - ``"secondary"`` (default): The button's background coordinates
              with the app's background color for normal emphasis.
            - ``"tertiary"``: The button is plain text without a border or
              background for subtlety.

        icon : str or None
            An optional emoji or icon to display next to the button label. If ``icon``
            is ``None`` (default), no icon is displayed. If ``icon`` is a
            string, the following options are valid:

            - A single-character emoji. For example, you can set ``icon="🚨"``
              or ``icon="🔥"``. Emoji short codes are not supported.

            - An icon from the Material Symbols library (rounded style) in the
              format ``":material/icon_name:"`` where "icon_name" is the name
              of the icon in snake case.

              For example, ``icon=":material/thumb_up:"`` will display the
              Thumb Up icon. Find additional icons in the `Material Symbols \
              <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
              font library.

            - ``"spinner"``: Displays a spinner as an icon.

        disabled : bool
            An optional boolean that disables the link button if set to
            ``True``. The default is ``False``.

        use_container_width : bool
            Whether to expand the button's width to fill its parent container.
            If ``use_container_width`` is ``False`` (default), Streamlit sizes
            the button to fit its contents. If ``use_container_width`` is
            ``True``, the width of the button matches its parent container.

            In both cases, if the contents of the button are wider than the
            parent container, the contents will line wrap.

            .. deprecated::
                ``use_container_width`` is deprecated and will be removed in a
                future release. For ``use_container_width=True``, use
                ``width="stretch"``. For ``use_container_width=False``, use
                ``width="content"``.

        width : "content", "stretch", or int
            The width of the link button. This can be one of the following:

            - ``"content"`` (default): The width of the button matches the
              width of its content, but doesn't exceed the width of the parent
              container.
            - ``"stretch"``: The width of the button matches the width of the
              parent container.
            - An integer specifying the width in pixels: The button has a
              fixed width. If the specified width is greater than the width of
              the parent container, the width of the button matches the width
              of the parent container.

        shortcut : str or None
            An optional keyboard shortcut that triggers the button. This can be
            one of the following strings:

            - A single alphanumeric key like ``"K"`` or ``"4"``.
            - A function key like ``"F11"``.
            - A special key like ``"Enter"``, ``"Esc"``, or ``"Tab"``.
            - Any of the above combined with modifiers. For example, you can use
              ``"Ctrl+K"`` or ``"Cmd+Shift+O"``.

            .. important::
                The keys ``"C"`` and ``"R"`` are reserved and can't be used,
                even with modifiers. Punctuation keys like ``"."`` and ``","``
                aren't currently supported.

            For a list of supported keys and modifiers, see the documentation
            for |st.button|_.

            .. |st.button| replace:: ``st.button``
            .. _st.button: https://docs.streamlit.io/develop/api-reference/widgets/st.button

        Example
        -------
        >>> import streamlit as st
        >>>
        >>> st.link_button("Go to gallery", "https://streamlit.io/gallery")

        .. output::
           https://doc-link-button.streamlit.app/
           height: 200px

        rV   zmThe type argument to st.link_button must be "primary", "secondary", or "tertiary". 
The argument passed was "rY   rU   rM   )ra   urlrc   rP   rN   rO   rR   rS   )r   _link_button)
r;   ra   rl   rc   rN   rO   rP   rQ   rR   rS   s
             r=   rj   zButtonMixin.link_button  sm    b ;;'..2V27 
 *!4I)E   ! 	
 		
r?   	page_link)ra   rO   rc   rP   rQ   rR   query_paramsc          	     p    ||rdnd}t        | j                        rd}| j                  |||||||      S )u  Display a link to another page in a multipage app or to an external page.

        If another page in a multipage app is specified, clicking ``st.page_link``
        stops the current page execution and runs the specified page as if the
        user clicked on it in the sidebar navigation.

        If an external page is specified, clicking ``st.page_link`` opens a new
        tab to the specified page. The current script run will continue if not
        complete.

        Parameters
        ----------
        page : str, Path, or StreamlitPage
            The file path (relative to the main script) or a ``StreamlitPage``
            indicating the page to switch to. Alternatively, this can be the
            URL to an external page (must start with "http://" or "https://").

        label : str
            The label for the page link. Labels are required for external pages.
            The label can optionally contain GitHub-flavored Markdown of the
            following types: Bold, Italics, Strikethroughs, Inline Code, Links,
            and Images. Images display like icons, with a max height equal to
            the font height.

            Unsupported Markdown elements are unwrapped so only their children
            (text contents) render. Display unsupported elements as literal
            characters by backslash-escaping them. E.g.,
            ``"1\. Not an ordered list"``.

            See the ``body`` parameter of |st.markdown|_ for additional,
            supported Markdown directives.

            .. |st.markdown| replace:: ``st.markdown``
            .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown

        icon : str or None
            An optional emoji or icon to display next to the button label. If
            ``icon`` is ``None`` (default), the icon is inferred from the
            ``StreamlitPage`` object or no icon is displayed. If ``icon`` is a
            string, the following options are valid:

            - A single-character emoji. For example, you can set ``icon="🚨"``
              or ``icon="🔥"``. Emoji short codes are not supported.

            - An icon from the Material Symbols library (rounded style) in the
              format ``":material/icon_name:"`` where "icon_name" is the name
              of the icon in snake case.

              For example, ``icon=":material/thumb_up:"`` will display the
              Thumb Up icon. Find additional icons in the `Material Symbols \
              <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
              font library.

            - ``"spinner"``: Displays a spinner as an icon.

        help : str or None
            A tooltip that gets displayed when the link is hovered over. If
            this is ``None`` (default), no tooltip is displayed.

            The tooltip can optionally contain GitHub-flavored Markdown,
            including the Markdown directives described in the ``body``
            parameter of ``st.markdown``.

        disabled : bool
            An optional boolean that disables the page link if set to ``True``.
            The default is ``False``.

        use_container_width : bool
            Whether to expand the link's width to fill its parent container.
            The default is ``True`` for page links in the sidebar and ``False``
            for those in the main app.

            .. deprecated::
                ``use_container_width`` is deprecated and will be removed in a
                future release. For ``use_container_width=True``, use
                ``width="stretch"``. For ``use_container_width=False``, use
                ``width="content"``.

        width : "content", "stretch", or int
            The width of the page-link button. This can be one of the following:

            - ``"content"`` (default): The width of the button matches the
              width of its content, but doesn't exceed the width of the parent
              container.
            - ``"stretch"``: The width of the button matches the width of the
              parent container.
            - An integer specifying the width in pixels: The button has a
              fixed width. If the specified width is greater than the width of
              the parent container, the width of the button matches the width
              of the parent container.

        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.

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

        The following example shows how to create page links 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
        >>>
        >>> st.page_link("your_app.py", label="Home", icon="🏠")
        >>> st.page_link("pages/page_1.py", label="Page 1", icon="1️⃣")
        >>> st.page_link("pages/page_2.py", label="Page 2", icon="2️⃣", disabled=True)
        >>> st.page_link("http://www.google.com", label="Google", icon="🌎")

        The default navigation is shown here for comparison, but you can hide
        the default navigation using the |client.showSidebarNavigation|_
        configuration option. This allows you to create custom, dynamic
        navigation menus for your apps!

        .. |client.showSidebarNavigation| replace:: ``client.showSidebarNavigation``
        .. _client.showSidebarNavigation: https://docs.streamlit.io/develop/api-reference/configuration/config.toml#client

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

        **Example 2: Passing query parameters**

        The following example shows how to pass query parameters when creating a
        page link in 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")
        >>>     st.page_link("page_2.py", query_params={"utm_source": "page_1"})
        >>>
        >>> pg = st.navigation([page_1, "page_2.py"])
        >>> pg.run()

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

        rU   rM   )pagera   rO   rc   rP   rR   ro   )r1   r_   
_page_link)	r;   rq   ra   rO   rc   rP   rQ   rR   ro   s	            r=   rn   zButtonMixin.page_linkr  sP    T *!4I)EdggE%  
 	
r?   )rN   rO   rP   r^   rR   rS   c
               H   t        |      }||dv rd nt        d|      }d }|t        |      }t        | j                  ||d d       t        d|d| j                  ||||||
||      }t        | j                        rt        dt               t               }||_
        ||_        d|_        |
|_        t        | j                  j                         ||||       ||_        |t#        |      |_        |t'        |      |_        |d	k(  rd|_        nd|_        |||_        t/               }t1        |j                  |||	|j2                  |j4                  |d
      }t7        |d       t9        |      }| j                  j;                  d||       |j<                  S )N>   rerunignorer+   F)	on_changedefault_valuewrites_allowedrd   T)user_keykey_as_main_identityr_   ra   rO   rg   rh   rc   rN   rR   rS   z7`st.download_button()` can't be used in an `st.form()`.ru   trigger_valueon_change_handlerr\   r]   deserializer
serializerr^   
value_typeallow_contentrR   layout_config)r   r   r   r   r_   r   r   r   r4   DownloadButtonProtoidra   defaultrN   marshall_file_get_delta_path_strrP   r   rc   r/   rO   ignore_rerunrS   r7   r-   rC   r>   r   r   _enqueuevalue)r;   ra   rf   rg   rh   rb   rc   r[   r\   r]   rN   rO   rP   r^   rR   rS   on_click_callbacknormalized_shortcut
element_iddownload_button_protoserdebutton_stater   s                          r=   ri   zButtonMixin._download_button-  s   & Sk 8/B#B &1 	 +/"4X">GG' 	
 5!%ww(

 dgg'I.IYZ  !4 5#- &+#(-%%)"GG'')41Fi	
 *2&)/!&)?)E!&x15!.16!.*-@!*&!$$/**&	
 	uD1$514M 	 	
 !!!r?   )rN   rO   rP   rR   rS   c                  t               }	d }
|t        |      }
|
%t        dd d| j                  |||||||
      |	_        ||	_        ||	_        ||	_        ||	_        |t        |      |	_
        |t        |      |	_        |
|
|	_        t        |d       t        |      }| j                  j!                  d|	|      S )Nrj   F)
ry   rz   r_   ra   rO   rl   rc   rN   rR   rS   Tr   r   r   )LinkButtonProtor   r   r_   r   ra   rl   rN   rP   r   rc   r/   rO   rS   r   r   r   )r;   ra   rl   rc   rN   rO   rP   rR   rS   link_button_protor   r   s               r=   rm   zButtonMixin._link_button  s     ,-*."4X">* $C%*77,$  #( #!%%-"%+D\"%;D%A"*)<&uD1$51ww,M   
 	
r?   )ra   rO   rc   rP   rR   ro   c                  t               }|rt        |      |_        t        |d       t	               }	|	s*t        |      }
| j                  j                  d||
      S ||_        |||_	        |t        |      |_        |t        |      |_        t        |t              rK|j                   |_        |j$                  |_        ||j(                  |_	        |Y|j                  |_        nFt        |t*              rt-        |      }t/        |      rI||dk(  r
t1               ||_        d|_        t        |      }
| j                  j                  d||
      S d}i }|	j4                  }|	j6                  j9                         }t;        |      }t<        j>                  jA                  tC        ||            }|jE                         D ]2  }|d   }|d   }|d	   }||k(  s|||_	        |d
   |_        ||_         n |j"                  dk(  r%tG        ||tI        tJ        jL                              t        |      }
| j                  j                  d||
      S )NTr   r   rn   r    script_path	page_nameurl_pathnamepage_script_hash)rq   main_script_directoryuses_pages_directory)'PageLinkProtor.   query_stringr   r)   r   r_   r   rP   ra   r/   rO   r   rc   
isinstancer    _script_hashr   url_pathrq   titler   strr0   r   externalmain_script_pathpages_manager	get_pagesr   ospathrealpathr   valuesr   r:   r'   r   )r;   rq   ra   rO   rc   rP   rR   ro   page_link_protor^   r   ctx_main_scriptall_app_pagesr   requested_page	page_data	full_pathr   r   s                      r=   rr   zButtonMixin._page_link  sj    (/+?+MO(uD1 "(u5M77##_M $   $, $)O!#9$#?O #)$<O dM*/3/@/@O,#'==O }(,

%|'+yy$
 $%4y d|=ERK8::'+$+/( ,5 9ww'' (   !OM!22O--779M$=o$N!WW--#$94@N
 +113 		%m4	%k2	(8!Y.}09-7@AS7TO4+7O(	 //250*?)-l.O.O)P  %51ww   
 	
r?   c                  t        |      }d }|t        |      }t        | j                  ||d d|        |rt	        | j                        nd}t        |rdnd|d| j                  ||	|||||      }t        j                         rRt        | j                        r|st        dt               t        | j                        s|rt        d	t               t               }||_        ||_        d|_        ||_        ||_        ||_        |
|_        |t'        |      |_        |	t+        |	      |_        |||_        t1               }t3        |j                  ||||j4                  |j6                  |d
      }|rt9        |||j:                         t=        |d       t?        |      }| j                  jA                  d||       |j:                  S )NF)rw   rx   enable_check_callback_rulesr   form_submit_buttonrK   T)
ry   rz   r_   ra   rO   rc   rZ   rN   rR   rS   z.`st.button()` can't be used in an `st.form()`.z=`st.form_submit_button()` must be used inside an `st.form()`.r{   r|   r   r   r   )!r   r   r   r_   r   r   r   existsr   r   r4   ButtonProtor   ra   r   rZ   form_idrN   rP   r   rc   r/   rO   rS   r7   r-   rC   r>   r   r   r   r   r   )r;   ra   rb   rc   rZ   r[   r\   r]   rN   rO   rP   r^   rR   rS   r   r   r   button_protor   r   r   s                        r=   r`   zButtonMixin._button(  s   " Sk*."4X">GG ,=(=	
 /@/$''*R4$5 8!%ww/(

& >>$''"+<+D^DTU  dgg&+<+STbScd  #}$"$):&&  ( &tL 6t <L*$7L!&OO&**&	
  j,2D2DEuD1$51<}M!!!r?   c                    t        d|       S )zGet our DeltaGenerator.r2   )r   )r;   s    r=   r_   zButtonMixin.dg  s     $d++r?   )NNNNN)ra   r   rb   
Key | Nonerc   
str | Noner[   WidgetCallback | Noner\   WidgetArgs | Noner]   WidgetKwargs | NonerN   +Literal['primary', 'secondary', 'tertiary']rO   r   rP   r:   rQ   rE   rR   r   rS   r   rD   r:   )NNNNrt   NN) ra   r   rf   r5   rg   r   rh   r   rb   r   rc   r   r[   2WidgetCallback | Literal['rerun', 'ignore'] | Noner\   r   r]   r   rN   r   rO   r   rP   r:   rQ   rE   rR   r   rS   r   rD   r:   )ra   r   rl   r   rc   r   rN   r   rO   r   rP   r:   rQ   rE   rR   r   rS   r   rD   r2   )rq   str | Path | StreamlitPagera   r   rO   r   rc   r   rP   r:   rQ   rE   rR   r   ro   QueryParamsInput | NonerD   r2   ) ra   r   rf   r5   rg   r   rh   r   rb   r   rc   r   r[   r   r\   r   r]   r   rN   r   rO   r   rP   r:   r^   ScriptRunContext | NonerR   r   rS   r   rD   r:   )ra   r   rl   r   rc   r   rN   r   rO   r   rP   r:   rR   r   rS   r   rD   r2   )rq   r   ra   r   rO   r   rc   r   rP   r:   rR   r   ro   r   rD   r2   )NNN)ra   r   rb   r   rc   r   rZ   r:   r[   r   r\   r   r]   r   rN   r   rO   r   rP   r:   r^   r   rR   r   rS   r   rD   r:   )rD   r2   )rF   rG   rH   r&   rK   rd   rj   rn   ri   rm   rr   r`   propertyr_   rA   r?   r=   rJ   rJ   c   s   H *."&&*p
 =H+/ #p
p
 p
 	p

 (p
  p
 $p
 :p
 p
 p
 )p
 p
 p
 
p
 p
d %&
 !%GN"&&*s
 =H+/ ##s
s
 %s
 	s

 s
 s
 s
 Es
  s
 $s
 :s
 s
 s
 )s
  !s
" #s
$ 
%s
 's
j M"  <G+/ #b
b
 b

 b
 :b
 b
 b
 )b
 b
 b
 
b
 #b
H K 
 !+/ 04x
(x
 	x

 x
 x
 x
 )x
 x
 .x
 
x
 !x
| !%GN"&&*e" =H'+ ##e"e" %e" 	e"
 e" e" e" Ee"  e" $e" :e" e" e" %e"  !e"" #e"$ 
%e"Z =H #4
4
 4
 	4
 :4
 4
 4
 4
 4
 
4
t ! 04\
(\
 	\

 \
 \
 \
 \
 .\
 
\
H +/"&&*e" =H'+ #e"e" e" 	e"
  e" (e"  e" $e" :e" e" e" %e" e" e"  
!e"N , ,r?   rJ   c           	        t        |      r\t        j                         sd|_        y t        j                         j
                  j                  ||| |      }||_        d|_        y t        |t        dt        |                   \  }}||}t        j                         r:t        j                         j
                  j                  ||| |d      }||_        y d}||_        y )Nr   )rg   zInvalid binary data format: )unsupported_errorT)rg   is_for_static_download)callabler   r   rl   get_instancemedia_file_mgradd_deferreddeferred_file_idr%   r   rN   add)	coordinatesrf   proto_download_buttonmimetyperg   file_iddata_as_bytesinferred_mime_typefile_urls	            r=   r   r     s     ~~~(*!% &&(77DD	 E 
 29.$&! )M/*4:,7
)%M% %~~'')88<<#' = 
 !)  (r?   r9   )r   r   rf   r5   r   r   r   r   rg   r   rD   None)]
__future__r   ior   collections.abcr   dataclassesr   pathlibr   textwrapr   typingr   r	   r
   r   r   r   r   	streamlitr   !streamlit.elements.lib.form_utilsr   r   #streamlit.elements.lib.layout_utilsr   r   r   streamlit.elements.lib.policiesr   %streamlit.elements.lib.shortcut_utilsr   streamlit.elements.lib.utilsr   r   r   r   streamlit.errorsr   r   r   streamlit.file_utilr   r   streamlit.navigation.pager    streamlit.proto.Button_pb2r!   r   "streamlit.proto.DownloadButton_pb2r"   r   streamlit.proto.LinkButton_pb2r#   r   streamlit.proto.PageLink_pb2r$   r   $streamlit.runtime.download_data_utilr%   streamlit.runtime.metrics_utilr&   streamlit.runtime.pages_managerr'   streamlit.runtime.scriptrunnerr(   r)   streamlit.runtime.stater*   r+   r,   r-   $streamlit.runtime.state.query_paramsr.   streamlit.string_utilr/   streamlit.url_utilr0   streamlit.utilr1   streamlit.delta_generatorr2   r3   r4   __annotations__r   bytes	RawIOBaser5   r7   rJ   r   rA   r?   r=   <module>r      sq   # 	 	 $ !      I S S A D  
 O 3 < T H B U 9 8 O  F 8 % %8E    	ll	
 r3;'(2R\\AABC 	  ! ! !o, o,n) !/)/)
 /) //) 	/)
 /) 
/)r?   