
    ;3h                        d Z ddl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 dd	lmZ  e        G d
 de             Zy)zgr.State() component.    )annotationsN)Callable)deepcopy)Any)document)FormComponent)Eventsc                       e Zd Zej                  gZ	 dZ	 	 dddd	 	 	 	 	 	 	 d fdZedd       Z	ddZ
ddZddZdd	Zdd
Zed        Z fdZ xZS )StateFN)time_to_livedelete_callbackc                   |t         j                  n|x| _        | _        |xs d | _        	 t	        |      }t        | !  ||       || _	        y# t
        $ r}t        dt        |       d      |d}~ww xY w)a:  
        Parameters:
            value: the initial value (of arbitrary type) of the state. The provided argument is deepcopied. If a callable is provided, the function will be called whenever the app loads to set the initial value of the state.
            render: should always be True, is included for consistency with other components.
            time_to_live: The number of seconds the state should be stored for after it is created or updated. If None, the state will be stored indefinitely. Gradio automatically deletes state variables after a user closes the browser tab or refreshes the page, so this is useful for clearing state for potentially long running sessions.
            delete_callback: A function that is called when the state is deleted. The function should take the state value as an argument.
        Nc                     y N )as    W/var/www/html/audio-gradio/venv/lib/python3.12/site-packages/gradio/components/state.py<lambda>z State.__init__.<locals>.<lambda>.   s        zYThe initial value of `gr.State` must be able to be deepcopied. The initial value of type z cannot be deepcopied.)valuerender)
mathinfr   r   r   	TypeErrortypesuper__init__r   )selfr   r   r   r   err	__class__s         r   r   zState.__init__   s      %,DHH,	
D-  /B>	UOE
 	uV4
  	klpqvlwkx  yO  P	s   A 	A:A55A:c                     yNTr   r   s    r   statefulzState.stateful8       r   c                    |S )z
        Parameters:
            payload: Value
        Returns:
            Passes a value of arbitrary type through.
        r   )r   payloads     r   
preprocesszState.preprocess<   s	     r   c                    |S )z
        Parameters:
            value: Expects a value of arbitrary type, as long as it can be deepcopied.
        Returns:
            Passes a value of arbitrary type through.
        r   )r   r   s     r   postprocesszState.postprocessE   s	     r   c                    i ddS )Nzany valid json)r   descriptionr   r#   s    r   api_infozState.api_infoN   s    +;<<r   c                     y r   r   r#   s    r   example_payloadzState.example_payloadQ       r   c                     y r   r   r#   s    r   example_valuezState.example_valueT   r0   r   c                     yr"   r   r#   s    r   skip_apizState.skip_apiW   r%   r   c                *    t         |          }|d= |S )Nr   )r   
get_config)r   configr    s     r   r6   zState.get_config[   s    #%7Or   r"   )r   r   r   boolr   zint | float | Noner   zCallable[[Any], None] | None)returnr8   )r'   r   r9   r   )r   r   r9   r   )r9   zdict[str, Any])r9   r   )__name__
__module____qualname__r	   changeEVENTSallow_string_shortcutr   propertyr$   r(   r*   r-   r/   r2   r4   r6   __classcell__)r    s   @r   r   r      s    mm_F " 
 ,08< 
 ) 68  =   r   r   )__doc__
__future__r   r   collections.abcr   copyr   typingr   gradio_client.documentationr   gradio.components.baser   gradio.eventsr	   r   r   r   r   <module>rJ      s@     "  $   0 0   
MM M Mr   