
    &eE/                     
   d dl mZ d dlmZ d dlmZmZmZ d dl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 d d	lmZmZmZmZ d d
lmZ d dlmZmZm Z m!Z! erd dl"m#Z# e G d d                      Z$ G d d          Z%dS )    )	dataclass)dedent)TYPE_CHECKINGOptionalcast)current_form_id)check_callback_rulescheck_session_state_rules get_label_visibility_proto_value)Checkbox)gather_metrics)ScriptRunContextget_script_run_ctx)
WidgetArgsWidgetCallbackWidgetKwargsregister_widget)compute_widget_id)KeyLabelVisibilitymaybe_raise_label_warningsto_key)DeltaGeneratorc                   L    e Zd ZU eed<   dedefdZd
dee         dedefdZd	S )CheckboxSerdevaluevreturnc                      t          |          S N)bool)selfr   s     Clib/python3.11/site-packages/streamlit/elements/widgets/checkbox.py	serializezCheckboxSerde.serialize-   s    Aww     ui_value	widget_idc                 2    t          ||n| j                  S r    )r!   r   )r"   r'   r(   s      r#   deserializezCheckboxSerde.deserialize0   s     4HH$*EEEr%   N)r&   )	__name__
__module____qualname__r!   __annotations__r$   r   strr*    r%   r#   r   r   )   s}         KKK4 D    F FHTN Fs FD F F F F F Fr%   r   c                   0   e Zd Z ed          	 	 	 	 	 	 dddddededee         d	ee         d
ee         dee	         dee
         dededefd            Z ed          	 	 	 	 	 	 dddddededee         d	ee         d
ee         dee	         dee
         dededefd            Z	 	 	 	 	 	 dddej        j        dddededee         d	ee         d
ee         dee	         dee
         dededej        j        dee         defdZedd            ZdS )CheckboxMixincheckboxFNvisible)disabledlabel_visibilitylabelr   keyhelp	on_changeargskwargsr5   r6   r   c                |    t                      }
|                     |||||||||	t          j        j        |
          S )a  Display a checkbox widget.

        Parameters
        ----------
        label : str
            A short label explaining to the user what this checkbox is for.
            The label can optionally contain Markdown and supports the following
            elements: Bold, Italics, Strikethroughs, Inline Code, Emojis, and Links.

            This also supports:

            * Emoji shortcodes, such as ``:+1:``  and ``:sunglasses:``.
              For a list of all supported codes,
              see https://share.streamlit.io/streamlit/emoji-shortcodes.

            * LaTeX expressions, by wrapping them in "$" or "$$" (the "$$"
              must be on their own lines). Supported LaTeX functions are listed
              at https://katex.org/docs/supported.html.

            * Colored text, using the syntax ``:color[text to be colored]``,
              where ``color`` needs to be replaced with any of the following
              supported colors: blue, green, orange, red, violet, gray/grey, rainbow.

            Unsupported 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``.

            For accessibility reasons, you should never set an empty label (label="")
            but hide it with label_visibility if needed. In the future, we may disallow
            empty labels by raising an exception.
        value : bool
            Preselect the checkbox when it first renders. This will be
            cast to bool internally.
        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. Multiple widgets of the same type may
            not share the same key.
        help : str
            An optional tooltip that gets displayed next to the checkbox.
        on_change : callable
            An optional callback invoked when this checkbox'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, which disables the checkbox if set to True.
            The default is False.
        label_visibility : "visible", "hidden", or "collapsed"
            The visibility of the label. If "hidden", the label doesn't show but there
            is still empty space for it (equivalent to label="").
            If "collapsed", both the label and the space are removed. Default is
            "visible".

        Returns
        -------
        bool
            Whether or not the checkbox is checked.

        Example
        -------
        >>> import streamlit as st
        >>>
        >>> agree = st.checkbox('I agree')
        >>>
        >>> if agree:
        ...     st.write('Great!')

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

        r7   r   r8   r9   r:   r;   r<   r5   r6   typectx)r   	_checkboxCheckboxProto	StyleTypeDEFAULTr"   r7   r   r8   r9   r:   r;   r<   r5   r6   r@   s              r#   r3   zCheckboxMixin.checkbox5   sR    p !""~~-(0  
 
 	
r%   togglec                |    t                      }
|                     |||||||||	t          j        j        |
          S )a  Display a toggle widget.

        Parameters
        ----------
        label : str
            A short label explaining to the user what this toggle is for.
            The label can optionally contain Markdown and supports the following
            elements: Bold, Italics, Strikethroughs, Inline Code, Emojis, and Links.

            This also supports:

            * Emoji shortcodes, such as ``:+1:``  and ``:sunglasses:``.
              For a list of all supported codes,
              see https://share.streamlit.io/streamlit/emoji-shortcodes.

            * LaTeX expressions, by wrapping them in "$" or "$$" (the "$$"
              must be on their own lines). Supported LaTeX functions are listed
              at https://katex.org/docs/supported.html.

            * Colored text, using the syntax ``:color[text to be colored]``,
              where ``color`` needs to be replaced with any of the following
              supported colors: blue, green, orange, red, violet, gray/grey, rainbow.

            Unsupported 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``.

            For accessibility reasons, you should never set an empty label (label="")
            but hide it with label_visibility if needed. In the future, we may disallow
            empty labels by raising an exception.
        value : bool
            Preselect the toggle when it first renders. This will be
            cast to bool internally.
        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. Multiple widgets of the same type may
            not share the same key.
        help : str
            An optional tooltip that gets displayed next to the toggle.
        on_change : callable
            An optional callback invoked when this toggle'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, which disables the toggle if set to True.
            The default is False.
        label_visibility : "visible", "hidden", or "collapsed"
            The visibility of the label. If "hidden", the label doesn't show but there
            is still empty space for it (equivalent to label="").
            If "collapsed", both the label and the space are removed. Default is
            "visible".

        Returns
        -------
        bool
            Whether or not the toggle is checked.

        Example
        -------
        >>> import streamlit as st
        >>>
        >>> on = st.toggle('Activate feature')
        >>>
        >>> if on:
        ...     st.write('Feature activated!')

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

        r>   )r   rA   rB   rC   TOGGLErE   s              r#   rF   zCheckboxMixin.toggle   sR    p !""~~-(/  
 
 	
r%   )r5   r6   r?   r@   r?   r@   c                *   t          |          }t          | j        |           t          |du rd n||           t	          ||	           t          |
t          j        j        k    rdnd||t          |          ||t          | j                  |r|j        nd           }t                      }||_        ||_        t          |          |_        |
|_        t          | j                  |_        ||_        t%          |	          |j        _        |t+          |          |_        t/          |          }t1          d||||||j        |j        |	  	        }|j        r|j        |_        d|_        | j                            d|           |j        S )NF)default_valuer8   rF   r3   )user_keyr7   r   r8   r9   form_idpage)rK   on_change_handlerr;   r<   deserializer
serializerr@   T)r   r	   dgr
   r   r   rB   rC   rH   r!   r   page_script_hashidr7   defaultr?   rL   r5   r   r6   r   r   r9   r   r   r*   r$   value_changed	set_value_enqueue)r"   r7   r   r8   r9   r:   r;   r<   r5   r6   r?   r@   rS   checkbox_protoserdecheckbox_states                   r#   rA   zCheckboxMixin._checkbox  s    SkkTWi000!"'5..$$e	
 	
 	
 	
 	#5*:;;; 7 >>>HHJu++#DG,,),6%%$	
 	
 	
 '$!%e"!0!9!9"*0P1
 1
'- "(,,Ne$$('*

 

 

 ' 	,#1#7N '+N$^444##r%   r   c                 "    t          d|           S )zGet our DeltaGenerator.r   )r   )r"   s    r#   rQ   zCheckboxMixin.dgH  s     $d+++r%   )FNNNNN)r   r   )r+   r,   r-   r   r/   r!   r   r   r   r   r   r   r3   rF   rB   rC   rD   	ValueTyper   rA   propertyrQ   r0   r%   r#   r2   r2   4   s       ^J !".2%))-d
 ,5d
 d
 d
d
 d
 c]	d

 smd
 N+d
 z"d
 &d
 d
 *d
 
d
 d
 d
  d
L ^H !".2%))-d
 ,5d
 d
 d
d
 d
 c]	d

 smd
 N+d
 z"d
 &d
 d
 *d
 
d
 d
 d
 d
R !".2%))-C$ ,52?2I2Q*.C$ C$ C$C$ C$ c]	C$
 smC$ N+C$ z"C$ &C$ C$ *C$ %/C$ &'C$ 
C$ C$ C$ C$J , , , X, , ,r%   r2   N)&dataclassesr   textwrapr   typingr   r   r   streamlit.elements.formr   streamlit.elements.utilsr	   r
   r   streamlit.proto.Checkbox_pb2r   rB   streamlit.runtime.metrics_utilr   streamlit.runtime.scriptrunnerr   r   streamlit.runtime.stater   r   r   r   streamlit.runtime.state.commonr   streamlit.type_utilr   r   r   r   streamlit.delta_generatorr   r   r2   r0   r%   r#   <module>rj      s   " ! ! ! ! !       0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3         
 C B B B B B 9 9 9 9 9 9 O O O O O O O O            = < < < < < X X X X X X X X X X X X 9888888 F F F F F F F FW, W, W, W, W, W, W, W, W, W,r%   