o
    h                     @  s   U d dl mZ d dl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 d dlmZ er5d dlmZ eeef Zd	ed
< ddddZdd ZdddZG dd dZdS )     )annotationsN)TYPE_CHECKINGUnioncast)	TypeAlias)StreamlitAPIException)Progress)
clean_text)DeltaGeneratorr   
FloatOrInt              ?valuefloatlowhighreturnboolc                 C  s<   ||   ko	|kn  pt j| |dddpt j| |dddS )a+  
    Checks given value is 'between' the bounds of [low, high],
    considering close values around bounds are acceptable input.

    Notes
    -----
    This check is required for handling values that are slightly above or below the
    acceptable range, for example -0.0000000000021, 1.0000000000000013.
    These values are little off the conventional 0.0 <= x <= 1.0 condition
    due to floating point operations, but should still be considered acceptable input.

    Parameters
    ----------
    value : float
    low : float
    high : float

    g&.>)rel_tolabs_tol)mathisclose)r   r   r    r   O/var/www/vscode/kcb/lib/python3.10/site-packages/streamlit/elements/progress.py_check_float_between#   s
   r   c                 C  sp   t | trd|   krdkr| S  td|  t | tr/t| dddr)t| d S td|  tdt| j )	Nr   d   z-Progress Value has invalid value [0, 100]: %dr   r   )r   r   z/Progress Value has invalid value [0.0, 1.0]: %fz#Progress Value has invalid type: %s)
isinstanceintr   r   r   type__name__)r   r   r   r   
_get_value=   s    

r    text
str | Nonec                 C  s6   | d u rd S t | trt| S tdtt|  d)NzProgress Text is of type zd, which is not an accepted type.Text only accepts: str. Please convert the text to an accepted type.)r   strr	   r   r   )r!   r   r   r   	_get_textS   s   
r$   c                   @  s&   e Zd Zdddd	Zedd
dZdS )ProgressMixinNr   r   r!   r"   r   r
   c                 C  s4   t  }t||_t|}|dur||_| jd|S )a  Display a progress bar.

        Parameters
        ----------
        value : int or float
            0 <= value <= 100 for int

            0.0 <= value <= 1.0 for float

        text : str or None
            A message to display above the progress bar. The text 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

        Example
        -------
        Here is an example of a progress bar increasing over time and disappearing when it reaches completion:

        >>> import streamlit as st
        >>> import time
        >>>
        >>> progress_text = "Operation in progress. Please wait."
        >>> my_bar = st.progress(0, text=progress_text)
        >>>
        >>> for percent_complete in range(100):
        ...     time.sleep(0.01)
        ...     my_bar.progress(percent_complete + 1, text=progress_text)
        >>> time.sleep(1)
        >>> my_bar.empty()
        >>>
        >>> st.button("Rerun")

        .. output::
           https://doc-status-progress.streamlit.app/
           height: 220px

        Nprogress)ProgressProtor    r   r$   r!   dg_enqueue)selfr   r!   progress_protor   r   r   r&   _   s   3
zProgressMixin.progressc                 C  s
   t d| S )zGet our DeltaGenerator.r
   )r   )r*   r   r   r   r(      s   
zProgressMixin.dg)N)r   r   r!   r"   r   r
   )r   r
   )r   
__module____qualname__r&   propertyr(   r   r   r   r   r%   ^   s    :r%   )r   r   )r   r   r   r   r   r   r   r   )r!   r"   r   r"   )
__future__r   r   typingr   r   r   typing_extensionsr   streamlit.errorsr   streamlit.proto.Progress_pb2r   r'   streamlit.string_utilr	   streamlit.delta_generatorr
   r   r   r   __annotations__r   r    r$   r%   r   r   r   r   <module>   s   
