
    ;3h                        d Z ddlmZ ddlZddlmZmZ ddlmZm	Z	 ddl
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.JSON() component.    )annotationsN)CallableSequence)TYPE_CHECKINGAny)document)	Component)JsonData)Events)I18nData)Timerc                       e Zd ZdZ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dZddZddZddZ xZS )JSONz
    Used to display arbitrary JSON output prettily. As this component does not accept user input, it is rarely used as an input component.

    Demos: zip_to_json, blocks_xray
    NT   valueFi  )labeleveryinputs
show_label	containerscale	min_widthvisibleelem_idelem_classesrenderkeypreserved_by_keyopenshow_indicesheight
max_height
min_heightc                   t         |   ||||||||	|
|||||       || _        || _        || _        || _        || _        y)a  
        Parameters:
            value: Default value as a valid JSON `str` -- or a `list` or `dict` that can be serialized to a JSON string. 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. Appears above the component 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 is assigned 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.
            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.
            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.
            open: If True, all JSON nodes will be expanded when rendered. By default, node levels deeper than 3 are collapsed.
            show_indices: Whether to show numerical indices when displaying the elements of a list within the JSON object.
            height: Height of the JSON component in pixels if a number is passed, or in CSS units if a string is passed. Overflow will be scrollable. If None, the height will be automatically adjusted to fit the content.
        )r   r   r   r   r   r   r   r   r   r   r   r   r   r   N)super__init__r    r   r!   r"   r#   )selfr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   	__class__s                       `/var/www/html/audio-gradio/venv/lib/python3.12/site-packages/gradio/components/json_component.pyr&   zJSON.__init__"   sh    V 	!%- 	 	
" )	$$    c                    |S )z
        Parameters:
            payload: JSON value as a `dict` or `list`
        Returns:
            Passes the JSON value as a `dict` or `list` depending on the value.
         r'   payloads     r)   
preprocesszJSON.preprocessd   s	     r*   c           	        |yt        |t              rt        t        j                  |            S t        t        j                  t        j
                  |t        j                  t        j                  z  t                          S )a  
        Parameters:
            value: Expects a valid JSON `str` -- or a `list` or `dict` that can be serialized to a JSON string. The `list` or `dict` value can contain numpy arrays.
        Returns:
            Returns the JSON as a `list` or `dict`.
        N)optiondefault)
isinstancestrr
   orjsonloadsdumpsOPT_SERIALIZE_NUMPYOPT_PASSTHROUGH_DATETIME)r'   r   s     r)   postprocesszJSON.postprocessm   sn     =eS!FLL/00
 LL%99 99 : #		 	r*   c                
    ddiS Nfoobarr,   r'   s    r)   example_payloadzJSON.example_payload       u~r*   c                
    ddiS r<   r,   r?   s    r)   example_valuezJSON.example_value   rA   r*   c                ,    t        j                  |      S N)jsonr6   r-   s     r)   read_from_flagzJSON.read_from_flag   s    zz'""r*   c                    i ddS )Nzany valid json)typedescriptionr,   r?   s    r)   api_infozJSON.api_info   s    +;<<r*   c                L    | j                  |      }|r|j                         }|S rE   )r:   
model_dump)r'   r   vals      r)   
as_examplezJSON.as_example   s&    u%.."C
r*   rE   )&r   z#str | dict | list | Callable | Noner   zstr | I18nData | Noner   zTimer | float | Noner   z7Component | Sequence[Component] | set[Component] | Noner   zbool | Noner   boolr   z
int | Noner   intr   rP   r   z
str | Noner   list[str] | str | Noner   rP   r   z(int | str | tuple[int | str, ...] | Noner   rR   r   rP   r    rP   r!   int | str | Noner"   rS   r#   rS   )r.   dict | list | NonereturnrT   )r   zdict | list | str | NonerU   zJsonData | None)rU   r   )r.   r   )rU   zdict[str, Any])__name__
__module____qualname____doc__r   changeEVENTSr&   r/   r:   r@   rC   rG   rK   rO   __classcell__)r(   s   @r)   r   r      sR    mm_F 6:@% (,&*JN"& "/38<3:"#''*'++@%2@% %	@%
 $@% H@%  @% @% @% @% @% @% -@% @% 6@%  1!@%" #@%$ %@%& !'@%( %)@%* %+@%D4#=r*   r   )rY   
__future__r   rF   collections.abcr   r   typingr   r   r5   gradio_client.documentationr   gradio.components.baser	   gradio.data_classesr
   gradio.eventsr   gradio.i18nr   gradio.componentsr   r   r,   r*   r)   <module>rf      sP     "  .
  0 , (    ' 
~9 ~ ~r*   