
    wi	                    $   U d dl mZ d dlZd dlZd dlZd dlmZ d dlmZ  ej	        e
          Zej        dk    Z G d de          Zi Z eedz           dd	          Zd
ed<   edd            Zd Z G d de          ZddZi Zd ZddZdS )    )annotationsN)contextmanager)
ContextVar
emscriptenc                      e Zd ZdS )WasmUnsupportedErrorN__name__
__module____qualname__     a/root/.openclaw/workspace/chatterbox_venv_py311/lib/python3.11/site-packages/gradio/wasm_utils.pyr   r              Dr   r   app_id)defaultzContextVar[str | None]_app_id_context_varstrc              #  z   K   t                               |           }d V  t                               |           d S N)r   setreset)r   tokens     r   app_id_contextr   #   s<      ##F++E	EEEe$$$$$r   c                    t                               d           }|t          v r&t          |         }|j                                         | t          |<   d S r   )r   getapp_mapblocksclose)_appr   apps      r   register_appr"   -   sJ     $$T**Ffo
GFOOOr   c                      e Zd ZdS )GradioAppNotFoundErrorNr	   r   r   r   r$   r$   7   r   r   r$   c                j    	 t           |          S # t          $ r}t          d|  d          |d }~ww xY w)NzGradio app not found (ID: z ). Forgot to call demo.launch()?)r   KeyErrorr$   )r   es     r   get_registered_appr(   ;   sS    v   $QQQQ
 
	s    
2-2c                    |t           | <   d S r   )error_traceback_callback_map)r   callbacks     r   !register_error_traceback_callbackr,   G   s    +3 (((r   errorException | Nonec                X   t           sd S | d S t                              d           }t                              |          }|s t                              d| d           d S d                    t          j        t          |           | | j
                            } ||           d S )Nz(Error callback not found for the app ID z. The error will be ignored. )IS_WASMr   r   r*   LOGGERwarningjoin	tracebackformat_exceptiontype__traceback__)r-   r   r+   tbs       r   
send_errorr:   K   s      } $$T**F+//77H [v[[[	
 	
 	
 		+DKK@STT	U	UBHRLLLLLr   )r   r   )r-   r.   )
__future__r   loggingsysr5   
contextlibr   contextvarsr   	getLoggerr
   r2   platformr1   	Exceptionr   r   r   r   __annotations__r   r"   r$   r(   r*   r,   r:   r   r   r   <module>rD      s   " " " " " " "  



     % % % % % % " " " " " "		8	$	$ ,,
&	 	 	 	 	9 	 	 	  /Ejt.Dd/ / /     
 % % % %  	 	 	 	 	Y 	 	 	     " 4 4 4     r   