o
    ,&]ih                  
   @  s  U 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 d dlmZmZ d dlmZ d dlmZ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! d dl"m#Z#m$Z$ d dl%m&Z&m'Z'm(Z(m)Z)m*Z* d dl+m,Z,m-Z-m.Z. d dl/m0Z1 d dl2m3Z3 d dl4m5Z5m6Z6 d dl7m8Z8m9Z9m:Z:m;Z;m<Z< erd dl=m>Z> d dlm?Z? ede@eAZBedeeeZCeDeB eEd B eEeB B eEeBeBf B ZFdeGd< eDeC eEd B eEeC B eEeCeCf B ZHdeGd< eBZIdeGd< e	ZJdeGd< e@eAB e	B ZKdeGd< e@eAB eB eB eB ZLdeGd< ede@eAeeeZMeMeeM B ZNdeGd< eNe@ eNeA B eNe B eNe B eNe B ZOdeGd < eMeEeM B eEeMeMf B ZPdeGd!< ePe@ ePeA B ePe B ePe B ePe B ZQdeGd"< d#ZRd$eGd%< d&eR ZSd$eGd'< ed(d)d)e
jTd*ZUd$eGd+< ee1jVee1jWee1jXee1jYee1jZiZ[d$eGd,< e1jXe1jZe1jYfZ\d$eGd-< dLd2d3Z]dMd6d7Z^dNd;d<Z_dOd>d?Z`dPdCdDZaG dEdF dFeZbeG dGdH dHZcG dIdJ dJZddKS )Q    )annotations)Sequence)	dataclass)datedatetimetime	timedeltatimezonetzinfo)IntegralReal)dedent)TYPE_CHECKINGAnyFinal	TypeAlias	TypedDictTypeVarcastoverload)current_form_id)JSNumberJSNumberBoundsException)LayoutConfigvalidate_width)check_widget_policiesmaybe_raise_label_warnings)KeyLabelVisibilitycompute_and_register_element_id get_label_visibility_proto_valueto_key)StreamlitAPIExceptionStreamlitValueAboveMaxErrorStreamlitValueBelowMinError)Slider)gather_metrics)ScriptRunContextget_script_run_ctx)
WidgetArgsWidgetCallbackWidgetKwargsget_session_stateregister_widget)DeltaGenerator)WidthWithoutContentSliderNumericTSliderDatelikeT r   SliderNumericSpanTSliderDatelikeSpanTStepNumericTStepDatelikeT
SliderStepSliderScalarSliderValueTSliderValueGenericSliderValueSliderReturnGenericSliderReturni@B r   SECONDS_TO_MICROSiQ DAYS_TO_MICROSi     r
   	UTC_EPOCHSUPPORTED_TYPESTIMELIKE_TYPEStime_r   returnr   c                 C  s   t tddd| S )Ni  r@   )r   combiner   )rE   r2   r2   _/var/www/html/IGF-ODF-V3/venv/lib/python3.10/site-packages/streamlit/elements/widgets/slider.py_time_to_datetime{   s   rI   date_r   c                 C  s   t | t S N)r   rG   r   )rJ   r2   r2   rH   _date_to_datetime   s   rL   deltar   intc                 C  s   | j | jt  | jt  S rK   )microsecondssecondsr>   daysr?   )rM   r2   r2   rH   _delta_to_micros   s   rR   dtc                 C  s   | j tjd}t|t S NrA   )replacer	   utcrR   rB   )rS   utc_dtr2   r2   rH   _datetime_to_micros   s   rX   microsorig_tztzinfo | Nonec                 C  s   t t| d }|j|dS )zFRestore times/datetimes to original timezone (dates are always naive).)rO   rA   )rB   r   rU   )rY   rZ   rW   r2   r2   rH   _micros_to_datetime   s   r\   c                   @  s.   e Zd ZU ded< ded< ded< ded< dS )	SliderDefaultValuesr8   	min_value	max_valuer7   stepstrformatN)__name__
__module____qualname____annotations__r2   r2   r2   rH   r]      s
   
 r]   c                   @  sL   e Zd ZU ded< ded< ded< ded< dddZdddZdddZdS )SliderSerdelist[float]valuerN   	data_typeboolsingle_valuer[   rZ   floatrF   r8   c                 C  s~   | j tjkr
t|S | j tjkrtt|| jS | j tjkr(tt|| j S | j tj	kr=tt|| j
 j| jdS |S rT   )rj   SliderProtoINTrN   DATETIMEr\   rZ   DATEr   TIMEr   rU   )selfri   r2   r2   rH   deserialize_single_value   s   z$SliderSerde.deserialize_single_valueui_valuelist[float] | Noner   c                   s<   |d ur|}n j } fdd|D } jr|d S t|S )Nc                   s   g | ]}  |qS r2   )rt   ).0vrs   r2   rH   
<listcomp>   s    z+SliderSerde.deserialize.<locals>.<listcomp>r   )ri   rl   tuple)rs   ru   valdeserialized_valuesr2   ry   rH   deserialize   s   zSliderSerde.deserializerx   	list[Any]c                 C  s|   t |ttf}|rt|n|g}| jtjkrdd |D S | jtjkr*dd |D S | jtjkr7dd |D S dd |D S )Nc                 S     g | ]}t t|qS r2   )rX   rL   rw   r|   r2   r2   rH   rz          z)SliderSerde.serialize.<locals>.<listcomp>c                 S  r   r2   )rX   rI   r   r2   r2   rH   rz      r   c                 S     g | ]}t |qS r2   )rX   r   r2   r2   rH   rz          c                 S  r   r2   )rm   r   r2   r2   rH   rz      r   )
isinstancelistr{   rj   rn   rq   rr   rp   )rs   rx   range_valueprocessed_valuer2   r2   rH   	serialize   s   zSliderSerde.serializeN)ri   rm   rF   r8   )ru   rv   rF   r   )rx   r   rF   r   )rc   rd   re   rf   rt   r~   r   r2   r2   r2   rH   rg      s   
 

rg   c                   @  s   e Zd Ze										dGdddddHd!d"Ze										dGdddddId&d"Ze		dJddddddddddd'
dKd*d"Ze							dLdddddMd+d"Ze									dNdddddOd/d"Ze	dPdddddddddddd0dQd1d"Ze		dJddddddddddd'
dRd2d"Ze		dJddddddddddd'
dSd5d"Ze							dLdddddTd7d"Zed8										dGdddddUd=d"Z										dGddddd>dVdBdCZedWdEdFZdS )XSliderMixinNFvisiblestretch)disabledlabel_visibilitywidthlabelra   r^   Noner_   ri   r`   
int | Nonerb   
str | Nonekey
Key | Nonehelp	on_changeWidgetCallback | NoneargsWidgetArgs | NonekwargsWidgetKwargs | Noner   rk   r   r   r   r/   rF   rN   c                C     d S rK   r2   rs   r   r^   r_   ri   r`   rb   r   r   r   r   r   r   r   r   r2   r2   rH   slider      zSliderMixin.sliderSliderNumericT | None#StepNumericT[SliderNumericT] | Noner0   c                C  r   rK   r2   r   r2   r2   rH   r      r   )
r`   rb   r   r   r   r   r   r   r   r   "SliderNumericSpanT[SliderNumericT]%tuple[SliderNumericT, SliderNumericT]c                C  r   rK   r2   r   r2   r2   rH   r     r   c                C  r   rK   r2   r   r2   r2   rH   r   "  r   r1   SliderDatelikeT | NoneStepDatelikeT | Nonec                C  r   rK   r2   r   r2   r2   rH   r   8  r   )ri   r`   rb   r   r   r   r   r   r   r   r   c                C  r   rK   r2   r   r2   r2   rH   r   N  r   c                C  r   rK   r2   r   r2   r2   rH   r   c  r   Xlist[SliderDatelikeT] | tuple[SliderDatelikeT] | tuple[SliderDatelikeT, SliderDatelikeT]'tuple[SliderDatelikeT, SliderDatelikeT]c                C  r   rK   r2   r   r2   r2   rH   r   y  s   $SliderDatelikeSpanT[SliderDatelikeT]c               C  r   rK   r2   r   r2   r2   rH   r     s   r   SliderScalar | NoneSliderValue | NoneSliderStep | Noner   c                C  s.   t  }| j|||||||||	|
|||||dS )a$  Display a slider widget.

        This supports int, float, date, time, and datetime types.

        This also allows you to render a range slider by passing a two-element
        tuple or list as the ``value``.

        The difference between ``st.slider`` and ``st.select_slider`` is that
        ``slider`` only accepts numerical or date/time data and takes a range as
        input, while ``select_slider`` accepts any datatype and takes an iterable
        set of options.

        .. note::
            Integer values exceeding +/- ``(1<<53) - 1`` cannot be accurately
            stored or returned by the widget due to serialization constraints
            between the Python server and JavaScript client. You must handle
            such numbers as floats, leading to a loss in precision.

        Parameters
        ----------
        label : str
            A short label explaining to the user what this slider 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.

            For accessibility reasons, you should never set an empty label, but
            you can hide it with ``label_visibility`` if needed. In the future,
            we may disallow empty labels by raising an exception.

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

        min_value : a supported type or None
            The minimum permitted value.
            If this is ``None`` (default), the minimum value depends on the
            type as follows:

            - integer: ``0``
            - float: ``0.0``
            - date or datetime: ``value - timedelta(days=14)``
            - time: ``time.min``

        max_value : a supported type or None
            The maximum permitted value.
            If this is ``None`` (default), the maximum value depends on the
            type as follows:

            - integer: ``100``
            - float: ``1.0``
            - date or datetime: ``value + timedelta(days=14)``
            - time: ``time.max``

        value : a supported type or a tuple/list of supported types or None
            The value of the slider when it first renders. If a tuple/list
            of two values is passed here, then a range slider with those lower
            and upper bounds is rendered. For example, if set to `(1, 10)` the
            slider will have a selectable range between 1 and 10.
            This defaults to ``min_value``. If the type is not otherwise
            specified in any of the numeric parameters, the widget will have an
            integer value.

        step : int, float, timedelta, or None
            The stepping interval.
            Defaults to 1 if the value is an int, 0.01 if a float,
            timedelta(days=1) if a date/datetime, timedelta(minutes=15) if a time
            (or if max_value - min_value < 1 day)

        format : str or None
            A printf-style format string controlling how the interface should
            display numbers. This does not impact the return value.

            For information about formatting integers and floats, see
            `sprintf.js
            <https://github.com/alexei/sprintf.js?tab=readme-ov-file#format-specification>`_.
            For example, ``format="%0.1f"`` adjusts the displayed decimal
            precision to only show one digit after the decimal.

            For information about formatting datetimes, dates, and times, see
            `momentJS <https://momentjs.com/docs/#/displaying/format/>`_.
            For example, ``format="ddd ha"`` adjusts the displayed datetime to
            show the day of the week and the hour ("Tue 8pm").

        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 next to the widget label. Streamlit
            only displays the tooltip when ``label_visibility="visible"``. 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_change : callable
            An optional callback invoked when this slider's value changes.

        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.

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

        label_visibility : "visible", "hidden", or "collapsed"
            The visibility of the label. The default is ``"visible"``. If this
            is ``"hidden"``, Streamlit displays an empty spacer instead of the
            label, which can help keep the widget aligned with other widgets.
            If this is ``"collapsed"``, Streamlit displays no label or spacer.

        width : "stretch" or int
            The width of the slider widget. This can be one of the
            following:

            - ``"stretch"`` (default): The width of the widget matches the
              width of the parent container.
            - An integer specifying the width in pixels: The widget has a
              fixed width. If the specified width is greater than the width of
              the parent container, the width of the widget matches the width
              of the parent container.

        Returns
        -------
        int/float/date/time/datetime or tuple of int/float/date/time/datetime
            The current value of the slider widget. The return type will match
            the data type of the value parameter.

        Examples
        --------
        >>> import streamlit as st
        >>>
        >>> age = st.slider("How old are you?", 0, 130, 25)
        >>> st.write("I'm ", age, "years old")

        And here's an example of a range slider:

        >>> import streamlit as st
        >>>
        >>> values = st.slider("Select a range of values", 0.0, 100.0, (25.0, 75.0))
        >>> st.write("Values:", values)

        This is a range time slider:

        >>> import streamlit as st
        >>> from datetime import time
        >>>
        >>> appointment = st.slider(
        ...     "Schedule your appointment:", value=(time(11, 30), time(12, 45))
        ... )
        >>> st.write("You're scheduled for:", appointment)

        Finally, a datetime slider:

        >>> import streamlit as st
        >>> from datetime import datetime
        >>>
        >>> start_time = st.slider(
        ...     "When do you start?",
        ...     value=datetime(2020, 1, 1, 9, 30),
        ...     format="MM/DD/YY - hh:mm",
        ... )
        >>> st.write("Start time:", start_time)

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

        )r   r^   r_   ri   r`   rb   r   r   r   r   r   r   r   r   ctx)r(   _slider)rs   r   r^   r_   ri   r`   rb   r   r   r   r   r   r   r   r   r   r2   r2   rH   r     s&    K)r   r   r   r   r   ScriptRunContext | Noner=   c          0        s  t |}t| j||	|d t|| td|h d| j||||||||d}|d u rcd}t j}|d urD||v rD|| }t|tt	
 }|rO|d urL|nd}n|d urU|nd}|d ur]|nd}||g}t|tt	
 }t|ttfoxt|dv }|s|std	|r|gn|}dHdd dI fdd}||stdttt| t|dkrtjn |d }tj}tj}|tjkrtd|}tjj|d jd}tjj|d jd}|tjtjfv rtd|}|d tdd }|d tdd }tjdddddtjdddd dtj||tddd!dtj||tddd!dtj||td"d#d$di}|d u r4|| d% }|d u r?|| d& }|d u rb|| d' }|tjtjfv rb|| tddk rbtd"d#}|d u rptd(|| d) }|dkrytd*|||g}td+d, |D }td-d, |D }|tv ot|tot|t|u } |s|s| sd.t|j d/t|j d0t|j d1}!t|!|tjko|}"|tjko|}#|tv o| }$|"s|#s|$sd2t|j d3t|j d/t|j d1}!t|!t||}t||}t|dkrt|d |}t|d |}n(t|d4krB|\}%}&|%|&kr7|&|%}%}&|%|&f}t|%|}t|&|}n||g}z&|"rWt !|d5 t !|d6 n|#rgt "|d5 t "|d6 n|$rk	 W n t#y }' ztt$|'d }'~'ww d }(|tjkrtd|}td7|}td7|}ttt%|}t%|}t%|}|tjkrtd8|}td9|}td9|}ttt&|}t&|}t&|}||krtd:| d;| d<|tv rtd|}td=|}td=|}td>|}|tjtjfv r|d jnd }(ttt'|}t'|}t'|}t(|}td?|}t })tj)j*|)_||)_+||)_,||)_-||)j.d d < ||)_||)_td@||)_/||)_0g |)j1d d < t2| j|)_3||)_4t5||)j6_7|d urbt8||)_9t:||||(}*t;|)j+|	|
||*j<|*j=|dAdB}+|+j>r|*=|+j7},|,D ](}-|*?|-}.|-|)jk rt@|.|*?|)jdC|-|)jkrtA|.|*?|)jdDq|,|)j7d d < d|)_BtC| tD|dE}/| jjEd|)|/dF tdG|+j7S )JN)default_valuer   >   r`   r_   r^   )user_keykey_as_main_identitydgr   r^   r_   ri   r`   rb   r   r   Tr   d   )r   r@      zcSlider value should either be an int/float/datetime or a list/tuple of 0 to 2 ints/floats/datetimesrx   r   rF   SliderProto.DataType.ValueTypec                 S  s0   t | tr	tt S t | trtt S tt|  S rK   )r   r   rC   r   type)rx   r2   r2   rH   value_to_generic_type  s
   

z2SliderMixin._slider.<locals>.value_to_generic_typeitemsrk   c                   s   t tt | dk S )Nr   )lensetmap)r   r   r2   rH   all_same_type  s   z*SliderMixin._slider.<locals>.all_same_typezASlider tuple/list components must be of the same type.
But were: zSequence[time]rA   zSequence[datetime]   )rQ   r@   z%d)r^   r_   r`   rb   g        g      ?g{Gz?z%0.2fz
YYYY-MM-DD   )minuteszHH:mmr^   r_   r`   ra   rb   z1Slider components cannot be passed a `step` of 0.c                 s  s    | ]}t |tV  qd S rK   )r   r   rw   ar2   r2   rH   	<genexpr>-  s    z&SliderMixin._slider.<locals>.<genexpr>c                 s  s&    | ]}t |tot |t V  qd S rK   )r   r   r   r   r2   r2   rH   r   .  s    
zBSlider value arguments must be of matching types.
`min_value` has z type.
`max_value` has z type.
`step` has z type.z?Both value and arguments must be of the same type.
`value` has z type.
`min_value` has r   z`min_value`z`max_value`r   zSequence[date]r   zFSlider `min_value` must be less than the `max_value`.
The values were z and .r   r   rh   rm   double_array_value)on_change_handlerr   r   deserializer
serializerr   
value_type)ri   r^   )ri   r_   )r   )layout_configr=   )rx   r   rF   r   )r   r   rF   rk   )Fr!   r   r   r   r   r,   filtered_stater   r{   rC   keysr   r   r"   r   r   rn   ro   r   minmaxrr   r   rU   r
   rp   rq   r   FLOATallrD   rc   r   validate_int_boundsvalidate_float_boundsr   ra   rI   rL   rX   rR   TypeSLIDERidr   rb   defaultr`   rj   optionsr   form_idr   r    r   ri   r   r   rg   r-   r~   r   value_changedrt   r$   r#   	set_valuer   r   _enqueue)0rs   r   r^   r_   ri   r`   rb   r   r   r   r   r   r   r   r   r   
element_idrl   session_statestate_valuemnmxr   prepared_valuer   rj   datetime_mindatetime_maxdefaultsslider_argsint_args
float_argstimelike_argsmsgall_ints
all_floatsall_timelikesstartenderZ   slider_protoserdewidget_stateserialized_valuesserialized_valuedeserialized_valuer   r2   r   rH   r     s  






!
































zSliderMixin._sliderr.   c                 C  s
   t d| S )zGet our DeltaGenerator.r.   )r   ry   r2   r2   rH   r     s   
zSliderMixin.dg)
NNNNNNNNNN)r   ra   r^   r   r_   r   ri   r   r`   r   rb   r   r   r   r   r   r   r   r   r   r   r   r   rk   r   r   r   r/   rF   rN   )r   ra   r^   r   r_   r   ri   r   r`   r   rb   r   r   r   r   r   r   r   r   r   r   r   r   rk   r   r   r   r/   rF   r0   )NN)r   ra   r^   r   r_   r   ri   r   r`   r   rb   r   r   r   r   r   r   r   r   r   r   r   r   rk   r   r   r   r/   rF   r   )NNNNNNN)r   ra   r^   r0   r_   r0   ri   r   r`   r   rb   r   r   r   r   r   r   r   r   r   r   r   r   rk   r   r   r   r/   rF   r   )	NNNNNNNNN)r   ra   r^   r1   r_   r   ri   r   r`   r   rb   r   r   r   r   r   r   r   r   r   r   r   r   rk   r   r   r   r/   rF   r1   rK   )r   ra   r^   r   r_   r1   ri   r   r`   r   rb   r   r   r   r   r   r   r   r   r   r   r   r   rk   r   r   r   r/   rF   r1   )r   ra   r^   r   r_   r   ri   r1   r`   r   rb   r   r   r   r   r   r   r   r   r   r   r   r   rk   r   r   r   r/   rF   r1   )r   ra   r^   r   r_   r   ri   r   r`   r   rb   r   r   r   r   r   r   r   r   r   r   r   r   rk   r   r   r   r/   rF   r   )r`   r   rb   r   r   r   r   r   r   r   r   r   r   r   r   ra   r^   r1   r_   r1   ri   r   r   rk   r   r   r   r/   rF   r   )r   ra   r^   r   r_   r   ri   r   r`   r   rb   r   r   r   r   r   r   r   r   r   r   r   r   rk   r   r   r   r/   rF   r   ) r   ra   r^   r   r_   r   ri   r   r`   r   rb   r   r   r   r   r   r   r   r   r   r   r   r   rk   r   r   r   r/   r   r   rF   r=   )rF   r.   )	rc   rd   re   r   r   r&   r   propertyr   r2   r2   r2   rH   r      sV   	 `  hr   N)rE   r   rF   r   )rJ   r   rF   r   )rM   r   rF   rN   )rS   r   rF   rN   )rY   rN   rZ   r[   rF   r   )e
__future__r   collections.abcr   dataclassesr   r   r   r   r   r	   r
   numbersr   r   textwrapr   typingr   r   r   r   r   r   r   r   !streamlit.elements.lib.form_utilsr    streamlit.elements.lib.js_numberr   r   #streamlit.elements.lib.layout_utilsr   r   streamlit.elements.lib.policiesr   r   streamlit.elements.lib.utilsr   r   r   r    r!   streamlit.errorsr"   r#   r$   streamlit.proto.Slider_pb2r%   rn   streamlit.runtime.metrics_utilr&   streamlit.runtime.scriptrunnerr'   r(   streamlit.runtime.stater)   r*   r+   r,   r-   streamlit.delta_generatorr.   r/   rN   rm   r0   r1   r   r{   r3   rf   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   rV   rB   ro   r   rp   rq   rr   rC   rD   rI   rL   rR   rX   r\   r]   rg   r   r2   r2   r2   rH   <module>   s    (












5