
    ;3h0                        d 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 ddlmZ ddlmZ dd	l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.SimpleImage() component.    )annotations)Sequence)Path)TYPE_CHECKINGAnyhandle_file)document)	Component)FileData)Events)I18nData)Timerc                       e Zd ZdZej
                  ej                  ej                  gZe	Z
	 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dZ xZS )SimpleImagezv
    Creates an image component that can be used to upload images (as an input) or display images (as an output).
    NT   value)labeleveryinputs
show_labelshow_download_button	containerscale	min_widthinteractivevisibleelem_idelem_classesrenderkeypreserved_by_keyc               P    || _         t        | 	  |||||||	|
|||||||       y)a  
        Parameters:
            value: A path or URL for the default value that SimpleImage component is going to take. If a function is provided, the function will be called each time the app loads to set the initial value of this component.
            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.
            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.
            show_download_button: If True, will display button to download image.
            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, will allow users to upload and edit an image; if False, can only be used to display images. 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.
        )r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r   N)r   super__init__)selfr   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   	__class__s                    d/var/www/html/audio-gradio/venv/lib/python3.12/site-packages/gradio/_simple_templates/simpleimage.pyr%   zSimpleImage.__init__#   sM    N %9!!#%- 	 	
    c                     |y|j                   S )z
        Parameters:
            payload: A FileData object containing the image data.
        Returns:
            A `str` containing the path to the image.
        N)path)r&   payloads     r(   
preprocesszSimpleImage.preprocess]   s     ?||r)   c                Z    |yt        t        |      t        |      j                        S )z
        Parameters:
            value: Expects a `str` or `pathlib.Path` object containing the path to the image.
        Returns:
            A FileData object containing the image data.
        N)r+   	orig_name)r   strr   name)r&   r   s     r(   postprocesszSimpleImage.postprocessh   s'     =SZ4;3C3CDDr)   c                    t        d      S NzPhttps://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.pngr   r&   s    r(   example_payloadzSimpleImage.example_payloads   s    ^
 	
r)   c                     yr4    r5   s    r(   example_valuezSimpleImage.example_valuex   s    ar)   )N) r   
str | Noner   zstr | I18nData | Noner   zTimer | float | Noner   z7Component | Sequence[Component] | set[Component] | Noner   bool | Noner   boolr   r<   r   z
int | Noner   intr   r;   r   r<   r   r:   r   list[str] | str | Noner    r<   r!   z(int | str | tuple[int | str, ...] | Noner"   r>   )r,   FileData | Nonereturnr:   )r   zstr | Path | Noner@   r?   )r@   r   )__name__
__module____qualname____doc__r   clearchangeuploadEVENTSr   
data_modelr%   r-   r2   r6   r9   __classcell__)r'   s   @r(   r   r      s!   
 	F J !8
 (,&*JN"&%) #'"/38<3:%8
8
 %	8

 $8
 H8
  8
 #8
 8
 8
 8
 !8
 8
 8
 -8
  !8
" 6#8
$ 1%8
t		E

br)   r   N)rD   
__future__r   collections.abcr   pathlibr   typingr   r   gradio_clientr	   gradio_client.documentationr
   gradio.components.baser   gradio.data_classesr   gradio.eventsr   gradio.i18nr   gradio.componentsr   r   r8   r)   r(   <module>rV      sO    ! " $  % % 0 , (    ' 
cb) cb cbr)   