
    +jc2                    ,   d Z ddlmZ ddlZddlZddl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mZmZmZmZ ddlmZ dd	lmZ dd
lmZ ddlmZmZ ddlmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z& ddl'm(Z( ddl)m*Z* ddl+m,Z,m-Z- ddl.m/Z/ 	 ddlm0Z0 n# e1$ r eZ0Y nw xY w ede2          Z3 ede2          Z4 G d de          Z5 G d de          Z6 G d de          Z7 G d d          Z8eee8f         Z9 G d de          Z: G d de:          Z; G d  d!e          Z< G d" d#e          Z= G d$ d%e          Z> G d& d'e          Z? G d( d)e          Z@ G d* d+e          ZA G d, d-e          ZB G d. d/e          ZC G d0 d1e#          ZD G d2 d3eCe          ZE G d4 d5eCe#          ZFeeEeFf         ZG G d6 d7e-          ZH G d8 d9e-          ZI e             G d: d;eE                      ZJ G d< d=eF          ZK G d> d?          ZL G d@ dAe-          ZM G dB dCe-          ZN G dD dEe-          ZO G dF dGe-          ZP G dH dIe-          ZQ G dJ dKeE          ZR G dL dMeE          ZS G dN dOe-          ZT G dP dQe-          ZU G dR dSe-          ZVdS )TzPydantic data models and other dataclasses. This is the only file that uses Optional[]
typing syntax instead of | None syntax to work with pydantic    )annotationsN)ABCabstractmethod)Iterator)Enumauto)	AnnotatedAnyLiteralNewTypeUnion)Request)ParameterInfo)document)is_file_obj_with_metatraverse)		BaseModel
ConfigDictFieldGetCoreSchemaHandlerGetJsonSchemaHandler	RootModelValidationErrorValidationInfomodel_validator)JsonSchemaValue)core_schema)NotRequired	TypedDict)I18nData)	JsonValueDeveloperPathUserProvidedPathc                  .    e Zd ZU ded<   ded<   ded<   dS )
CancelBodystrsession_hashintfn_indexevent_idN__name__
__module____qualname____annotations__     W/home/wildlama/visual-decline/.venv/lib/python3.11/site-packages/gradio/data_classes.pyr%   r%   2   s.         MMMMMMMMr1   r%   c                  (    e Zd ZU ded<   dZded<   dS )SimplePredictBody	list[Any]dataN
str | Noner'   r,   r-   r.   r/   r'   r0   r1   r2   r4   r4   8   s,         OOO#L######r1   r4   c                  (    e Zd ZU ded<   dZded<   dS )SimplePredictBodyV2dict[str, Any]r6   Nr7   r'   r8   r0   r1   r2   r:   r:   =   s/         #L######r1   r:   c                  >    e Zd Zedd            Zedd            ZdS )#_StarletteRequestPydanticAnnotation_source_typer
   _handlerr   returncore_schema.CoreSchemac                2    dd}t          j        |          S )Nvaluer
   r@   r   c                N    t          | t                    r| S t          d          )Nz(Input must be a Starlette Request object)
isinstancer   
ValueError)rC   s    r2   validate_requestzZ_StarletteRequestPydanticAnnotation.__get_pydantic_core_schema__.<locals>.validate_requestI   s(    %)) GHHHr1   )rC   r
   r@   r   )r    no_info_plain_validator_function)clsr>   r?   rG   s       r2   __get_pydantic_core_schema__z@_StarletteRequestPydanticAnnotation.__get_pydantic_core_schema__C   s.    	I 	I 	I 	I
 ;<LMMMr1   _core_schemahandlerr   r   c                    dddS )NobjectStarletteRequest)typetitler0   )rI   rK   rL   s      r2   __get_pydantic_json_schema__z@_StarletteRequestPydanticAnnotation.__get_pydantic_json_schema__P   s     !+=>>>r1   N)r>   r
   r?   r   r@   rA   )rK   rA   rL   r   r@   r   )r,   r-   r.   classmethodrJ   rR   r0   r1   r2   r=   r=   B   sV        
N 
N 
N [
N ? ? ? [? ? ?r1   r=   c                      e Zd ZU dZded<   dZded<   ded<   dZded<   dZd	ed
<   dZd	ed<   dZ	ded<   dZ
ded<   ed             ZdS )PredictBodyNr7   r'   r*   r5   r6   z
Any | None
event_data
int | Noner)   
trigger_idFboolsimple_formatzbool | Nonebatchedc                J    ddddiddidddidddiddiddiddiddid	d
gdS )NrU   rN   rP   stringarray)rP   itemsintegerboolean)r'   r*   r6   rV   r)   rX   rZ   r[   r6   )rQ   rP   
propertiesrequiredr0   )rI   r   rL   s      r2   rR   z(PredictBody.__get_pydantic_json_schema__f   sr     #!' 2#X.!(FH3EFF%x0#Y/%y1"()!4"I.	 	  
 
 	
r1   )r,   r-   r.   r'   r/   r*   rV   r)   rX   rZ   r[   rS   rR   r0   r1   r2   rU   rU   Z   s         #L####HOOO!J!!!!H!J!!!!M      
 
 [
 
 
r1   rU   c                  "    e Zd ZU dZdZded<   dS )PredictBodyInternalzOSeparate class to avoid exposing PydanticStarletteRequest in the API validationNzPydanticStarletteRequest | Nonerequest)r,   r-   r.   __doc__rf   r/   r0   r1   r2   re   re   y   s:         UU 	       r1   re   c                      e Zd ZU ded<   dS )	ResetBodyr&   r*   Nr+   r0   r1   r2   ri   ri      s         MMMMMr1   ri   c                      e Zd ZU ded<   dS )VibeEditBodyr&   promptNr+   r0   r1   r2   rk   rk      s         KKKKKr1   rk   c                      e Zd ZU ded<   dS )VibeCodeBodyr&   codeNr+   r0   r1   r2   rn   rn      s         IIIIIr1   rn   c                  8    e Zd ZU ded<   ded<   ded<   ded<   dS )	ComponentServerJSONBodyr&   r'   r(   component_idfn_namer
   r6   Nr+   r0   r1   r2   rq   rq      s:         LLLIIIIIr1   rq   c                  $    e Zd ZU ded<   ded<   dS )DataWithFilesr
   r6   zlist[tuple[str, bytes]]filesNr+   r0   r1   r2   ru   ru      s'         III""""""r1   ru   c                  8    e Zd ZU ded<   ded<   ded<   ded<   dS )	ComponentServerBlobBodyr&   r'   r(   rr   rs   ru   r6   Nr+   r0   r1   r2   rx   rx      s?         LLLr1   rx   c                  ^    e Zd Z e            Z e            Z e            Z e            ZdS )InterfaceTypesN)r,   r-   r.   r   STANDARD
INPUT_ONLYOUTPUT_ONLYUNIFIEDr0   r1   r2   rz   rz      s:        tvvHJ$&&KdffGGGr1   rz   c                  >    e Zd ZddZeed	d                        ZdS )
GradioBaseModeldirstr | pathlib.Pathr@   GradioDataModelc                   t          | t          t          f          st          d          t	          j                  dfd}| j                            t          | 	                                |t          j                            S )Nz must be used in a Pydantic modelobjdictc                    t          di | }|                    t          t          j                  t          j        d          z                                                      S )N
   r0   )FileData_copy_to_dirr&   pathlibPathsecrets	token_hex
model_dump)r   r6   r   s     r2   unique_copyz0GradioBaseModel.copy_to_dir.<locals>.unique_copy   sX    ??c??D$$GL%%(9"(=(==>> jllr1   )x)r   r   )rE   r   r   	TypeErrorr   r   	__class__	from_jsonr   r   r   is_file_data)selfr   r   s    ` r2   copy_to_dirzGradioBaseModel.copy_to_dir   s    $I 677 	@>???l3	 	 	 	 	 	 ~''!!%  ( 
 
 	
r1   c                    d S Nr0   rI   r   s     r2   r   zGradioBaseModel.from_json   s	     	r1   N)r   r   r@   r   )r@   r   )r,   r-   r.   r   rS   r   r   r0   r1   r2   r   r      sR        
 
 
 
(    ^ [  r1   r   c                      e Zd ZU dZded<   dS )JsonDatazHJSON data returned from a component that should not be modified further.r!   rootN)r,   r-   r.   rg   r/   r0   r1   r2   r   r      s         RROOOOOr1   r   c                  &    e Zd Zedd            ZdS )GradioModelr@   c                     | di |S )Nr0   r0   r   s     r2   r   zGradioModel.from_json   s    sxxQxxr1   N)r@   r   r,   r-   r.   rS   r   r0   r1   r2   r   r      s2           [  r1   r   c                  &    e Zd Zedd            ZdS )GradioRootModelr@   c                     | |          S )Nr   r0   r   s     r2   r   zGradioRootModel.from_json   s    s{{{r1   N)r@   r   r   r0   r1   r2   r   r      s2           [  r1   r   c                  V    e Zd ZU ded<   ded<   ded<   ded<   ded<   d	ed
<   ded<   dS )FileDataDictr&   pathNotRequired[str | None]urlzNotRequired[int | None]size	orig_name	mime_typerY   	is_streamzNotRequired[dict]metaNr+   r0   r1   r2   r   r      s`         III    !!!!&&&&&&&&OOOr1   r   c                      e Zd ZU ded<   dS )FileDataMetazLiteral['gradio.FileData']_typeNr+   r0   r1   r2   r   r      s         %%%%%%r1   r   c                     e Zd ZU dZded<   dZded<   dZded<   dZded	<   dZded
<   dZ	ded<    e
d           Zded<    ed          edd                        Zed d            Zed!d            Zd"dZed#d            ZdS )$r   ad  
    The FileData class is a subclass of the GradioModel class that represents a file object within a Gradio interface. It is used to store file data and metadata when a file is uploaded.

    Attributes:
        path: The server file path where the file is stored.
        url: The normalized server URL pointing to the file.
        size: The size of the file in bytes.
        orig_name: The original filename before upload.
        mime_type: The MIME type of the file.
        is_stream: Indicates whether the file is a stream.
        meta: Additional metadata used internally (should not be changed).
    r&   r   Nr7   r   rW   r   r   r   FrY   r   c                 
    ddiS )Nr   gradio.FileDatar0   r0   r1   r2   <lambda>zFileData.<lambda>   s    AR7S r1   )default_factoryr   r   before)modeinfor   c                    |j         r8|j                             d          rt          |          st          d          |S )Nvalidate_metazlThe 'meta' field must be explicitly provided in the input data and be equal to {'_type': 'gradio.FileData'}.)contextgetr   rF   )rI   vr   s      r2   validate_modelzFileData.validate_model   sV     L	  11	 *!,,	
 ~   r1   r@   c                p    t          d | j        | j        | j        | j        | j        fD                       S )z
        Checks if the FileData object is empty, i.e., all attributes are None.

        Returns:
            bool: True if all attributes (except 'is_stream' and 'meta') are None, False otherwise.
        c              3     K   | ]}|d u V  	d S r   r0   ).0fs     r2   	<genexpr>z#FileData.is_none.<locals>.<genexpr>  s:       	
 	
 I	
 	
 	
 	
 	
 	
r1   )allr   r   r   r   r   r   s    r2   is_nonezFileData.is_none	  sO      	
 	
 			
 	
 	
 	
 	
 		
r1   c                     | |          S )z
        Creates a FileData object from a given file path.

        Args:
            path: The file path.

        Returns:
            FileData: An instance of FileData representing the file at the specified path.
        )r   r0   )rI   r   s     r2   	from_pathzFileData.from_path  s     s~~~r1   r   c                    t          j        |                              d           t          |           }| j        st          d          t          j        | j        |          }||d<    | j        di |S )a^  
        Copies the file to a specified directory and returns a new FileData object representing the copied file.

        Args:
            dir: The destination directory.

        Returns:
            FileData: A new FileData object representing the copied file.

        Raises:
            ValueError: If the source file path is not set.
        T)exist_okzSource file path is not setr   r0   )	r   r   mkdirr   r   rF   shutilcopyr   )r   r   new_objnew_names       r2   r   zFileData._copy_to_dir)  s}     	S...t**y 	<:;;;;ty#.."t~(((((r1   r   r
   c                    t          |t                    r+	 t          di |j         S # t          t
          f$ r Y dS w xY wdS )z
        Checks if an object is a valid FileData instance.

        Args:
            obj: The object to check.

        Returns:
            bool: True if the object is a valid FileData instance, False otherwise.
        Fr0   )rE   r   r   r   r   r   )rI   r   s     r2   r   zFileData.is_file_data?  s]     c4   	#??c??222/   uuus   ) >>)r   r   )r@   rY   )r   r&   r@   r   )r   r&   r@   r   )r   r
   r@   rY   )r,   r-   r.   rg   r/   r   r   r   r   r   r   r   r   rS   r   propertyr   r   r   r   r0   r1   r2   r   r      sL          IIICD I     I    I/S/STTTDTTTT_(###	 	 	 [ $#	 
 
 
 X
$ 
 
 
 [
) ) ) ),    [  r1   r   c                  (    e Zd ZU ded<   d ZddZdS )		ListFileszlist[FileData]r   c                    | j         |         S r   r   )r   indexs     r2   __getitem__zListFiles.__getitem__U  s    yr1   r@   Iterator[FileData]c                *    t          | j                  S r   )iterr   r   s    r2   __iter__zListFiles.__iter__X  s    DIr1   N)r@   r   )r,   r-   r.   r/   r   r   r0   r1   r2   r   r   R  sE                   r1   r   c                  4    e Zd ZdZg Zd	dZed             ZdS )
_StaticFilesz3
    Class to hold all static files for an app
    pathslist[str | pathlib.Path]r@   Nonec                6    || _         d |D             | _        d S )Nc                Z    g | ](}t          j        |                                          )S r0   )r   r   resolve)r   ps     r2   
<listcomp>z)_StaticFiles.__init__.<locals>.<listcomp>e  s,    CCC',q//1133CCCr1   )r   	all_paths)r   r   s     r2   __init__z_StaticFiles.__init__c  s"    
CCUCCCr1   c                    g | _         d S r   )r   )rI   s    r2   clearz_StaticFiles.clearg  s    r1   N)r   r   r@   r   )r,   r-   r.   rg   r   r   rS   r   r0   r1   r2   r   r   \  sX          ID D D D   [  r1   r   c                  8    e Zd ZU ded<   ded<   ded<   ded<   dS )BodyCSSr&   body_background_fillbody_text_colorbody_background_fill_darkbody_text_color_darkNr+   r0   r1   r2   r   r   l  sB         """"r1   r   c                  $    e Zd ZU ded<   ded<   dS )Layoutr(   idzNotRequired[list[int | Layout]]childrenNr+   r0   r1   r2   r   r   s  s'         GGG------r1   r   c                  .    e Zd ZU ded<   ded<   ded<   dS )Pagez	list[int]
componentsdependenciesr   layoutNr+   r0   r1   r2   r   r   x  s1         NNNNNr1   r   c                     e Zd ZU ded<   ded<   ded<   ded<   ded	<   ded
<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded <   d!ed"<   ded#<   ded$<   ded%<   d&ed'<   d(ed)<   d*ed+<   d*ed,<   ded-<   d.ed/<   d0ed1<   d2ed3<   d4ed5<   d6ed7<   d.ed8<   d9ed:<   d;S )<BlocksConfigDictr&   versionz0NotRequired[Literal['valid', 'invalid', 'none']]deep_link_stater   r(   app_idrY   dev_mode	vibe_modeanalytics_enabledzlist[dict[str, Any]]r   r7   cssconnect_heartbeatzstr | Literal[True] | Nonejsheadzstr | I18nDatarQ   space_idenable_queue
show_erroris_colabrW   max_file_sizez	list[str]stylesheetsthemez>Literal['ws', 'sse', 'sse_v1', 'sse_v2', 'sse_v2.1', 'sse_v3']protocolr   body_cssfill_height
fill_width
theme_hashzNotRequired[Layout]r   z!NotRequired[list[dict[str, Any]]]r   r   r   username
api_prefixzNotRequired[bool]pwazdict[str, Page]pagezlist[tuple[str, str]]pagesNotRequired[str]current_pagez-NotRequired[dict[str, dict[str, str]] | None]i18n_translations
mcp_serverzlist[str | dict[str, str]]footer_linksNr+   r0   r1   r2   r   r   ~  s        LLLEEEEIIIKKKNNNOOO$$$$OOO""""NNNLLLLOOO3333!!!!%%%%OOO    """"DDDD!!!!,,,,,,r1   r   c                  8    e Zd ZU ded<   ded<   ded<   ded<   d	S )
MediaStreamChunkbytesr6   floatdurationr&   	extensionr  r   Nr+   r0   r1   r2   r  r    s9         KKKOOONNNr1   r  c                     e Zd ZU  edd          Zded<    edd          Zded<    edd          Zd	ed
<    edd          Zded<    edd          Z	ded<    edd          Z
ded<   ddiZded<    eddi          ZdS )	ImageDataNzPath to a local file)defaultdescriptionr7   r   z.Publicly available url or base64 encoded imager   zSize of image in bytesrW   r   zOriginal filenamer   zmime type of imager   FzCan always be set to FalserY   r   r   r   r   r   r%  z+A local filepath or publicly available URL.)json_schema_extra)r,   r-   r.   r   r   r/   r   r   r   r   r   r   r   model_configr0   r1   r2   r#  r#    s        uT7MNNNDNNNNe"R  C     uT7OPPPDPPPP!E$<OPPPIPPPP!E$<PQQQIQQQQeE7STTTITTTT,-D----:(*WX  LLLr1   r#  c                  2    e Zd ZU  ed          Zded<   dS )Base64ImageDatazbase64 encoded image)r%  r&   r   N)r,   r-   r.   r   r   r/   r0   r1   r2   r)  r)    s1         u!7888C888888r1   r)  c                  8    e Zd ZU ded<   ded<   ded<   ded<   dS )	APIReturnInfor&   labelr;   rP   zdict[str, str]python_type	componentNr+   r0   r1   r2   r+  r+    s:         JJJNNNNNr1   r+  c                  8    e Zd ZU ded<   ded<   ded<   ded<   d	S )
APIEndpointInfor  r%  zlist[ParameterInfo]
parameterszlist[APIReturnInfo]returnsz,Literal['public', 'private', 'undocumented']api_visibilityNr+   r0   r1   r2   r0  r0    sB         !!!!####    @@@@@@r1   r0  c                  $    e Zd ZU ded<   ded<   dS )APIInfozdict[str, APIEndpointInfo]named_endpointsunnamed_endpointsNr+   r0   r1   r2   r5  r5    s*         ////111111r1   r5  )Wrg   
__future__r   r   r   r   abcr   r   collections.abcr   enumr   r   typingr	   r
   r   r   r   fastapir   gradio_client.data_classesr   gradio_client.documentationr   gradio_client.utilsr   r   pydanticr   r   r   r   r   r   r   r   r   pydantic.json_schemar   pydantic_corer   typing_extensionsr   r   gradio.i18nr    r!   ImportErrorr&   r"   r#   r%   r4   r:   r=   PydanticStarletteRequestrU   re   ri   rk   rn   rq   ru   rx   rz   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r#  r)  r+  r0  r5  r0   r1   r2   <module>rH     s  @ @ # " " " " "    # # # # # # # # $ $ $ $ $ $                            4 4 4 4 4 4 0 0 0 0 0 0 ? ? ? ? ? ? ? ?
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 1 0 0 0 0 0 % % % % % % 4 4 4 4 4 4 4 4            """""""   III --7-s33        $ $ $ $ $	 $ $ $
$ $ $ $ $) $ $ $
? ? ? ? ? ? ? ?* %W.Q%QR 
 
 
 
 
) 
 
 
>    +       	       9       9       i   # # # # #I # # #
    i       T       c   6    y       /9       oy    _45    9   & & & & &9 & & & 
i i i i i{ i i iX                   i   . . . . .Y . . .
    9   %- %- %- %- %-y %- %- %-P    y           9 9 9 9 9k 9 9 9    I   A A A A Ai A A A2 2 2 2 2i 2 2 2 2 2s   B BB