
    ;3h	                       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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y)    )annotationsN)contextmanager)
ContextVar
emscriptenc                      e Zd Zy)WasmUnsupportedErrorN__name__
__module____qualname__     Q/var/www/html/audio-gradio/venv/lib/python3.12/site-packages/gradio/wasm_utils.pyr   r          r   r   app_id)defaultzContextVar[str | None]_app_id_context_varc              #  h   K   t         j                  |       }d  t         j                  |       y wN)r   setreset)r   tokens     r   app_id_contextr   !   s'     ##F+E	e$s   02c                    t         j                         }|t        v r#t        |   }|j                  j	                          | t        |<   y r   )r   getapp_mapblocksclose)_appr   apps      r   register_appr!   +   s:     $$&Ffo

GFOr   c                      e Zd Zy)GradioAppNotFoundErrorNr	   r   r   r   r#   r#   5   r   r   r#   c                X    	 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'   9   s>    v $(0PQ
	s    	)$)c                    |t         | <   y r   )error_traceback_callback_map)r   callbacks     r   !register_error_traceback_callbackr+   E   s    +3 (r   c                $   t         sy | y t        j                         }t        j                  |      }|st        j                  d| d       y dj                  t        j                  t        |       | | j                              } ||       y )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__)errorr   r*   tbs       r   
send_errorr8   I   s     } $$&F+//7H6vh>Z[	
 		++DK@S@ST	UBRLr   )r   str)r6   zException | None)
__future__r   loggingsysr2   
contextlibr   contextvarsr   	getLoggerr
   r/   platformr.   	Exceptionr   r   r   __annotations__r   r!   r#   r'   r)   r+   r8   r   r   r   <module>rC      s    "  
  % "			8	$ ,,,
&	9 	  /94.P + P % %	Y 	  " 4r   