
    g;                    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 d dlmZ d dlmZmZ d dlmZ d dlmZmZmZ d d	lmZmZ d d
lmZmZmZ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*m+Z+ d dl,m-Z-m.Z.m/Z/m0Z0 d dl1m2Z2 d dl3m4Z4m5Z5 erd dl6m7Z7 d dl8m9Z9 ddZ:e G d de
e4                Z; G d d      Z<y)    )annotations)	dataclass)dedent)TYPE_CHECKINGAnyCallableGenericcastoverload)	TypeGuard)OptionSequenceconvert_anything_to_list)current_form_id)index_maybe_coerce_enummaybe_coerce_enum_sequence)check_widget_policiesmaybe_raise_label_warnings)KeyLabelVisibilitycompute_and_register_element_id get_label_visibility_proto_valuesave_for_app_testingto_key)StreamlitAPIException)Slider)gather_metrics)ScriptRunContextget_script_run_ctx)
WidgetArgsWidgetCallbackWidgetKwargsregister_widget)RegisterWidgetResult)Tcheck_python_comparable)Sequence)DeltaGeneratorc                .    t        | t        t        f      S N)
isinstancelisttuple)values    ]/var/www/openai/venv/lib/python3.12/site-packages/streamlit/elements/widgets/select_slider.py_is_range_valuer0   F   s    edE]++    c                  R    e Zd ZU ded<   ded<   ded<   ddZ	 d	 	 	 	 	 ddZdd	Zy
)SelectSliderSerdezSequence[T]options	list[int]r.   boolis_range_valuec                $    | j                  |      S r*   )_as_index_list)selfvs     r/   	serializezSelectSliderSerde.serializeP   s    ""1%%r1   c                     |s j                   }t        t        t        t        f   t         fd|D                    } j                  r|S |d   S )Nc              3  N   K   | ]  }j                   t        |           y wr*   )r4   int).0xr:   s     r/   	<genexpr>z0SelectSliderSerde.deserialize.<locals>.<genexpr>_   s     91$,,s1v&s   "%r   )r.   r
   r-   r%   r7   )r:   ui_value	widget_idreturn_values   `   r/   deserializezSelectSliderSerde.deserializeS   sO    
 zzH %)!Q$K999%
  $22|GQGr1   c                    t        |      r3|D cg c]  }t        | j                  |       }}|\  }}||kD  r||g}|S t        | j                  |      gS c c}w r*   )r0   r   r4   )r:   r;   valslider_valuestartends         r/   r9   z SelectSliderSerde._as_index_liste   sb    1ABC#F4<<5LC%JE3s{ #U|4<<+,, Ds   ANr;   objectreturnr5   ) )rC   zlist[int] | NonerD   strrN   T | tuple[T, T])__name__
__module____qualname____annotations__r<   rF   r9    r1   r/   r3   r3   J   sH    & H"H H 
	H$-r1   r3   c                     e Zd Zeedddddfddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Zeddedddddfddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Z ed      ddedddddfddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd	       Zddeddddddddf	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd
Zedd       Z	y)SelectSliderMixinNFvisible)disabledlabel_visibilityc
                    y r*   rV   r:   labelr4   r.   format_funckeyhelp	on_changeargskwargsrZ   r[   s               r/   select_sliderzSelectSliderMixin.select_sliderq   s     r1   rV   c
                    y r*   rV   r]   s               r/   re   zSelectSliderMixin.select_slider   s     r1   re   c
               P    t               }| j                  |||||||||	|
||      S )aI  
        Display a slider widget to select items from a list.

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

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

        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

        options : Iterable
            Labels for the select options in an ``Iterable``. This can be a
            ``list``, ``set``, or anything supported by ``st.dataframe``. If
            ``options`` is dataframe-like, the first column will be used. Each
            label will be cast to ``str`` internally by default.

        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.
            Defaults to first option.

        format_func : function
            Function to modify the display of the labels from the options.
            argument. It receives the option as an argument and its output
            will be cast to str.

        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 select_slider's value changes.

        args : tuple
            An optional 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 select 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 alligned with other widgets.
            If this is ``"collapsed"``, Streamlit displays no label or spacer.

        Returns
        -------
        any value or tuple of any value
            The current value of the slider widget. The return type will match
            the data type of the value parameter.

        Examples
        --------
        >>> import streamlit as st
        >>>
        >>> color = st.select_slider(
        ...     "Select a color of the rainbow",
        ...     options=[
        ...         "red",
        ...         "orange",
        ...         "yellow",
        ...         "green",
        ...         "blue",
        ...         "indigo",
        ...         "violet",
        ...     ],
        ... )
        >>> st.write("My favorite color is", color)

        And here's an example of a range select slider:

        >>> import streamlit as st
        >>>
        >>> start_color, end_color = st.select_slider(
        ...     "Select a range of color wavelength",
        ...     options=[
        ...         "red",
        ...         "orange",
        ...         "yellow",
        ...         "green",
        ...         "blue",
        ...         "indigo",
        ...         "violet",
        ...     ],
        ...     value=("red", "blue"),
        ... )
        >>> st.write("You selected wavelengths between", start_color, "and", end_color)

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

        )r^   r4   r.   r_   r`   ra   rb   rc   rd   rZ   r[   ctx)r   _select_slider)r:   r^   r4   r.   r_   r`   ra   rb   rc   rd   rZ   r[   rh   s                r/   re   zSelectSliderMixin.select_slider   sI    l !"""#- # 
 	
r1   c                   t        |      }t        | j                  ||       t        ||       t	        |      t               t              dk(  rt        d      dfd} |      }t        d|t        | j                        |D cg c]  }t         ||             c}||      }t               }||_        t        j                  j                  |_        ||_        d|_        ||j$                  d d  d|_        t              dz
  |_        d|_        t        j,                  |_        D cg c]  }t         ||             c}|j0                  d d  t        | j                        |_        |
|_        t7        |      |j8                  _        |t=        |      |_        tA        |tC                    }tE        |j                  |||	|jF                  |jH                  |d	
      }tK        |j:                  tL              r0tO        tQ        tR        tL        tT        tT        f      |      |      }ntW        ||      }|jX                  r/|jI                  |j:                        |j:                  d d  d|_-        |rt]        |||       | j                  j_                  d|       |j:                  S c c}w c c}w )N)default_valuer   z,The `options` argument needs to be non-emptyc                    t        |       r)| D cg c]  }t        |       }}|\  }}||kD  r||g}|S 	 t        |       gS c c}w # t        $ r	  dgcY S w xY w)Nr   )r0   r   
ValueError)r;   rH   rI   rJ   rK   optr.   s        r/   as_index_listz7SelectSliderMixin._select_slider.<locals>.as_index_listd  s    q!<=>ASsC 0A>)
s3;$'<L##"3N++  ? " (3J	s   AA	 	AAre   )user_keyform_idr^   r4   r.   ra   z%s   double_array_value)on_change_handlerrc   rd   deserializer
serializerrh   
value_typeTsliderrL   )0r   r   dgr   r   r&   lenr   r   r   rP   SliderProtoidTypeSELECT_SLIDERtyper^   formatdefaultminmaxstepINT	data_typer4   rq   rZ   r   r[   r.   r   ra   r3   r0   r#   rF   r<   r+   r-   r   r
   r$   r%   r   value_changed	set_valuer   _enqueue)r:   r^   r4   r.   r_   r`   ra   rb   rc   rd   rZ   r[   rh   ro   rI   option
element_idslider_protoserdewidget_statern   s      `                @r/   ri   z SelectSliderMixin._select_sliderE  s    SkGG		
 	#5*:;&w/$s8q='(VWW	$ %U+4#DGG,<?@C&SV,-C@

 #}$',,::""".Qs8a<!,JM"N#3{6':#;#"NQ.tww7 (.N/
%%+  &tL!#|_U5KL&OO'**+	
 l((%05)%1+6EwPSL -\7CHL%%$)OOL4F4F$GLq!%)L" j+><0!!!g A #Os   J?:Kc                    t        d|       S )zGet our DeltaGenerator.r(   )r
   )r:   s    r/   ry   zSelectSliderMixin.dg  s     $d++r1   )r^   rP   r4   OptionSequence[T]r.   ztuple[T, T] | list[T]r_   Callable[[Any], Any]r`   
Key | Nonera   
str | Nonerb   WidgetCallback | Nonerc   WidgetArgs | Nonerd   WidgetKwargs | NonerZ   r6   r[   r   rN   ztuple[T, T])r^   rP   r4   r   r.   zT | Noner_   r   r`   r   ra   r   rb   r   rc   r   rd   r   rZ   r6   r[   r   rN   r%   )r^   rP   r4   r   r.   T | Sequence[T] | Noner_   r   r`   r   ra   r   rb   r   rc   r   rd   r   rZ   r6   r[   r   rN   rQ   )r^   rP   r4   r   r.   r   r_   r   r`   r   ra   r   rb   r   rc   r   rd   r   rZ   r6   r[   r   rh   zScriptRunContext | NonerN   rQ   )rN   r(   )
rR   rS   rT   r   rP   re   r   ri   propertyry   rV   r1   r/   rX   rX   p   s    -0+/"&&* ,5 # %	
 *   )   $  * 
 8  &(,/+/"&&* ,5 # 	
 *   )   $  * 
   O$ &((,,/+/"&&*c
 ,5c
c
 #c
 &	c

 *c
 c
 c
 )c
  c
 $c
 c
 *c
 
c
 %c
P &((,,/+/"&&*,5'+k"k" #k" &	k"
 *k" k" k" )k"  k" $k" k" *k" %k" 
k"Z , ,r1   rX   N)r.   zT | Sequence[T]rN   zTypeGuard[Sequence[T]])=
__future__r   dataclassesr   textwrapr   typingr   r   r   r	   r
   r   typing_extensionsr   streamlit.dataframe_utilr   r   !streamlit.elements.lib.form_utilsr   -streamlit.elements.lib.options_selector_utilsr   r   r   streamlit.elements.lib.policiesr   r   streamlit.elements.lib.utilsr   r   r   r   r   r   streamlit.errorsr   streamlit.proto.Slider_pb2r   r{   streamlit.runtime.metrics_utilr   streamlit.runtime.scriptrunnerr   r   streamlit.runtime.stater    r!   r"   r#   streamlit.runtime.state.commonr$   streamlit.type_utilr%   r&   collections.abcr'   streamlit.delta_generatorr(   r0   r3   rX   rV   r1   r/   <module>r      s    # !   ( M = 
  3 < 9 O  ;(8, "-
 "- "-JE, E,r1   