o
    eD                     @  s   d 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
mZmZ ddlmZmZ ed e G d	d
 d
eeee	ZdS )zgr.Code() component    )annotations)Literal)documentset_documentation_group)StringSerializable)IOComponent	_Keywords)
Changeable	Inputable	componentc                   @  st   e Zd ZdZg dZ		d%ddddddddddd
d&ddZdd Zd d! Zee	j
ddddddddf	d'd#d$ZdS )(Codez
    Creates a Code editor for entering, editing or viewing code.
    Preprocessing: passes a {str} of code into the function.
    Postprocessing: expects the function to return a {str} of code or a single-elment {tuple}: (string filepath,)
    )pythonmarkdownjsonhtmlcss
javascript
typescriptyaml
dockerfileshellrNN   T   )
lineslabelinteractive
show_label	containerscale	min_widthvisibleelem_idelem_classesvaluestr | tuple[str] | Nonelanguage{Literal['python', 'markdown', 'json', 'html', 'css', 'javascript', 'typescript', 'yaml', 'dockerfile', 'shell', 'r'] | Noner   intr   
str | Noner   bool | Noner   r   boolr   
int | Noner    r!   r"   r#   list[str] | str | Nonec       
         K  sR   |t jv sJ d| d|| _|| _tj| f||||||	|
|||d
| dS )a  
        Parameters:
            value: Default value to show in the code editor. If callable, the function will be called whenever the app loads to set the initial value of the component.
            language: The language to display the code as. Supported languages listed in `gr.Code.languages`.
            label: component name in interface.
            interactive: Whether user should be able to enter code or only view it.
            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 width compared to adjacent Components in a Row. For example, if Component A has scale=2, and Component B has scale=1, A will be twice as wide as B. Should be an integer.
            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.
        z	Language z not supported.)
r   r   r   r   r   r    r!   r"   r#   r$   N)r   	languagesr&   r   r   __init__)selfr$   r&   r   r   r   r   r   r   r    r!   r"   r#   kwargs r2   FD:\Projects\ConvertPro\env\Lib\site-packages\gradio/components/code.pyr/   '   s&   ,
zCode.__init__c                 C  s   | j | j| jdt| S )N)r$   r&   r   )r$   r&   r   r   
get_config)r0   r2   r2   r3   r4   e   s   zCode.get_configc                 C  sV   |d u rd S t |tr't|d }| W  d    S 1 s w   Y  d S | S )Nr   )
isinstancetupleopenreadstrip)r0   y	file_datar2   r2   r3   postprocessm   s   
$zCode.postprocess5str | tuple[str] | None | Literal[_Keywords.NO_VALUE]c	           	      C  s   ||||||| ||dd
S )Nupdate)
r   r   r   r   r    r!   r$   r&   r   Z__type__r2   )	r$   r   r   r   r   r    r!   r&   r   r2   r2   r3   r>   v   s   zCode.update)NN)r$   r%   r&   r'   r   r(   r   r)   r   r*   r   r*   r   r+   r   r,   r    r(   r!   r+   r"   r)   r#   r-   )r$   r=   r   r)   r   r*   r   r*   r   r,   r    r,   r!   r*   r&   r'   r   r*   )__name__
__module____qualname____doc__r.   r/   r4   r<   staticmethodr   ZNO_VALUEr>   r2   r2   r2   r3   r      s<    >	r   N)rB   
__future__r   typingr   Zgradio_client.documentationr   r   Zgradio_client.serializingr   Zgradio.components.baser   r   Zgradio.eventsr	   r
   r   r2   r2   r2   r3   <module>   s    