o
    äe9  ã                   @  s–   d Z ddlmZ ddlZddl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 ddlmZ dd	lmZ e
d
ƒ e	ƒ G dd„ deeeƒƒZdS )zgr.JSON() component.é    )ÚannotationsN)ÚAnyÚCallableÚLiteral)ÚdocumentÚset_documentation_group)ÚJSONSerializable)ÚIOComponentÚ	_Keywords)Úwarn_style_method_deprecation)Ú
ChangeableÚ	componentc                   @  sv   e Zd ZdZ	d(ddddddddddœ	d)dd„Zdd„ Zeejddddddfd*dd„ƒZ	d+d#d$„Z
dd%œd,d&d'„ZdS )-ÚJSONa  
    Used to display arbitrary JSON output prettily.
    Preprocessing: this component does *not* accept input.
    Postprocessing: expects a {str} filepath to a file containing valid JSON -- or a {list} or {dict} that is valid JSON

    Demos: zip_to_json, blocks_xray
    NTé    )	ÚlabelÚeveryÚ
show_labelÚ	containerÚscaleÚ	min_widthÚvisibleÚelem_idÚelem_classesÚvalueú#str | dict | list | Callable | Noner   ú
str | Noner   úfloat | Noner   úbool | Noner   Úboolr   ú
int | Noner   Úintr   r   r   úlist[str] | str | Nonec       	         K  s,   t j| f||||||||	|
|dœ
|¤Ž dS )aª  
        Parameters:
            value: Default value. If callable, the function will be called whenever the app loads to set the initial value of the component.
            label: component name in interface.
            every: If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. Queue must be enabled. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.
            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 width compared to adjacent Components in a Row. For example, if Component A has scale=2, and Component B has scale=1, A will be twice as wide as B. Should be an integer.
            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.
            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.
        )
r   r   r   r   r   r   r   r   r   r   N)r	   Ú__init__)Úselfr   r   r   r   r   r   r   r   r   r   Úkwargs© r%   úPD:\Projects\ConvertPro\env\Lib\site-packages\gradio/components/json_component.pyr"      s    ÿõ
ôzJSON.__init__c                 C  s   d| j it | ¡¥S )Nr   )r   r	   Ú
get_config)r#   r%   r%   r&   r'   I   s   ÿþzJSON.get_configú(Any | Literal[_Keywords.NO_VALUE] | Nonec              	   C  s   ||||||| ddœ}|S )NÚupdate)r   r   r   r   r   r   r   Z__type__r%   )r   r   r   r   r   r   r   Zupdated_configr%   r%   r&   r)   O   s   ø
zJSON.updateÚyúdict | list | str | NoneÚreturnúdict | list | Nonec                 C  s$   |du rdS t |tƒrt |¡S |S )zÓ
        Parameters:
            y: either a string filepath to a JSON file, or a Python list or dict that can be converted to JSON
        Returns:
            JSON output in Python list or dict format
        N)Ú
isinstanceÚstrÚjsonÚloads)r#   r*   r%   r%   r&   Úpostprocesse   s
   

zJSON.postprocess)r   c                K  s   t ƒ  |dur
|| _| S )zc
        This method is deprecated. Please set these arguments in the constructor instead.
        N)r   r   )r#   r   r$   r%   r%   r&   Ústyles   s   z
JSON.style)N)r   r   r   r   r   r   r   r   r   r   r   r   r   r    r   r   r   r   r   r!   )r   r(   r   r   r   r   r   r   r   r   r   r   r   r   )r*   r+   r,   r-   )r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r"   r'   Ústaticmethodr
   ZNO_VALUEr)   r2   r3   r%   r%   r%   r&   r      s4    
þô+ù
r   )r7   Ú
__future__r   r0   Útypingr   r   r   Zgradio_client.documentationr   r   Zgradio_client.serializingr   Zgradio.components.baser	   r
   Zgradio.deprecationr   Zgradio.eventsr   r   r%   r%   r%   r&   Ú<module>   s    