
    ;3h                        d Z ddlmZ ddlZddlZddlmZmZ ddl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 e	rdd
lmZ  e        G d de             Zy)zgr.Slider() component.    )annotationsN)CallableSequence)TYPE_CHECKINGAny)document)	ComponentFormComponent)Events)I18nData)Timerc                      e Zd ZdZej
                  ej                  ej                  gZ	 	 	 dddddddddddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d fdZ	dd	Z
dd
ZddZd ZddZddZ xZS )Sliderz
    Creates a slider that ranges from {minimum} to {maximum} with a step size of {step}.

    Demos: sentence_builder, slider_release, interface_random_slider, blocks_random_slider
    Guides: create-your-own-friends-with-a-gan
    NT   valueF)steplabelinfoeveryinputs
show_label	containerscale	min_widthinteractivevisibleelem_idelem_classesrenderkeypreserved_by_key	randomizeshow_reset_buttonc                  || _         || _        |;||z
  }t        j                  t        j                  |      dz
        }d|z  | _        n|| _        || _        |r| j                  }t        | %  |||||	|
||||||||||       y)a  
        Parameters:
            minimum: minimum value for slider.
            maximum: maximum value for slider.
            value: default value for slider. If a function is provided, the function will be called each time the app loads to set the initial value of this component. Ignored if randomized=True.
            step: increment between slider values.
            label: the label for this component, displayed above the component if `show_label` is `True` and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component corresponds to.
            info: additional component description, appears below the label in smaller font. Supports markdown / HTML syntax.
            every: Continously calls `value` to recalculate it if `value` is a function (has no effect otherwise). Can provide a Timer whose tick resets `value`, or a float that provides the regular interval for the reset Timer.
            inputs: Components that are used as inputs to calculate `value` if `value` is a function (has no effect otherwise). `value` is recalculated any time the inputs change.
            show_label: if True, will display label.
            container: If True, will place the component in a container - providing some extra padding around the border.
            scale: relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.
            min_width: minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.
            interactive: if True, slider will be adjustable; if False, adjusting will be disabled. If not provided, this is inferred based on whether the component is used as an input or output.
            visible: If False, component will be hidden.
            elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
            elem_classes: An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.
            render: If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.
            key: in a gr.render, Components with the same key across re-renders are treated as the same component, not a new component. Properties set in 'preserved_by_key' are not reset across a re-render.
            preserved_by_key: A list of parameters from this component's constructor. Inside a gr.render() function, if a component is re-rendered with the same key, these (and only these) parameters will be preserved in the UI (if they have been changed by the user or an event listener) instead of re-rendered based on the values provided during constructor.
            randomize: If True, the value of the slider when the app loads is taken uniformly at random from the range given by the minimum and maximum.
            show_reset_button: if False, will hide button to reset slider to default value.
        N   
   )r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r   )
minimummaximummathfloorlog10r   r#   get_random_valuesuper__init__)selfr'   r(   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   
differencepower	__class__s                           X/var/www/html/audio-gradio/venv/lib/python3.12/site-packages/gradio/components/slider.pyr.   zSlider.__init__   s    b < 7*JJJtzz*59:EE	DIDI!2))E!#%-! 	 	
    c                @    dd| j                    d| j                   dS )Nnumberznumeric value between z and )typedescription)r'   r(   r/   s    r3   api_infozSlider.api_infon   s'    3DLL>t||nU
 	
r4   c                    | j                   S Nr'   r9   s    r3   example_payloadzSlider.example_payloadt       ||r4   c                    | j                   S r<   r=   r9   s    r3   example_valuezSlider.example_valuew   r?   r4   c                L   t        | j                  | j                  z
  | j                  z        }t	        j
                  d|      }| j                  || j                  z  z   }t        t        | j                        d d d   j                  d      d      }|rt        ||      }|S )Nr   .)
intr(   r'   r   randomrandintmaxstrfindround)r/   n_stepsr   r   
n_decimalss        r3   r,   zSlider.get_random_valuez   s    t||dll2dii?@~~a)tdii//TYY"-2237;
%,Er4   c                "    || j                   S |S )a  
        Parameters:
            value: Expects an {int} or {float} returned from function and sets slider value to it as long as it is within range (otherwise, sets to minimum value).
        Returns:
            The value of the slider within the range.
        r=   )r/   r   s     r3   postprocesszSlider.postprocess   s      %}t||7%7r4   c                    |S )z
        Parameters:
            payload: slider value
        Returns:
            Passes slider value as a {float} into the function.
         )r/   payloads     r3   
preprocesszSlider.preprocess   s	     r4   )r   d   N)*r'   floatr(   rU   r   zfloat | Callable | Noner   float | Noner   str | I18nData | Noner   rW   r   zTimer | float | Noner   z7Component | Sequence[Component] | set[Component] | Noner   bool | Noner   boolr   z
int | Noner   rE   r   rX   r   rY   r   z
str | Noner   list[str] | str | Noner   rY   r    z(int | str | tuple[int | str, ...] | Noner!   rZ   r"   rY   r#   rY   )returnzdict[str, Any])r[   r   )r   rV   r[   rU   )rR   rU   r[   rU   )__name__
__module____qualname____doc__r   changeinputreleaseEVENTSr.   r:   r>   rA   r,   rO   rS   __classcell__)r2   s   @r3   r   r      sv    mmV\\6>>:F )-	M
 "'+&*&*JN"& #'"/38<3:"&/M
M
 M
 '	M
 M
 %M
 $M
 $M
 HM
  M
 M
 M
 M
 !M
  !M
" #M
$ -%M
& 'M
( 6)M
* 1+M
, -M
.  /M
^
8r4   r   )r_   
__future__r   r)   rF   collections.abcr   r   typingr   r   gradio_client.documentationr   gradio.components.baser	   r
   gradio.eventsr   gradio.i18nr   gradio.componentsr   r   rQ   r4   r3   <module>rm      sI     "   . % 0 ;    ' 
]  r4   