o
    d>=                     @   s   d dl Z d dlZd dlZd dlZd dlZd dlZddlmZmZm	Z	 edZ
ed ZG dd dZG dd de jZd	d
 Zdd ZG dd dedZdd ZdS )    N   )patch_collections_abcstringify_id
OrderedSetMutableSequencec                   @   s,   e Zd ZdZe ZeeZ	e
dd ZdS )ComponentRegistryz6Holds a registry of the namespaces used by components.c                 C   s0   g }| j D ]}tj| }|t||g  q|S N)registrysysmodulesextendgetattr)clsresource_name	resourcesmodule_namemodule r   d/var/www/html/visualizacion-main/env/lib/python3.10/site-packages/dash/development/base_component.pyget_resources   s
   

zComponentRegistry.get_resourcesN)__name__
__module____qualname____doc__r   r	   collectionsdefaultdictdictchildren_propsclassmethodr   r   r   r   r   r      s    
r   c                   @   s   e Zd Zdd ZdS )ComponentMetac                 C   sd   t j| |||}|d dd }|dks|dkr|S tj| |dtj|d| |< |S )Nr   .r   	Componentbuiltins_children_props
_namespace)	abcABCMeta__new__splitr   r	   addgetr   )mcsnamebases
attributes	componentr   r   r   r   r'   $   s   zComponentMeta.__new__N)r   r   r   r'   r   r   r   r   r   !   s    r   c                 C   s$   zt |  W dS  ty   Y dS w )NTF)float
ValueError)sr   r   r   	is_number5   s   r3   c                 C   s2   t | drt| jtst| jttfstd S d S )Nchildren)hasattr
isinstancer4   r!   tupler   KeyError)itemr   r   r    _check_if_has_indexable_children=   s   

r:   c                   @   s   e Zd Zg ZdgZG dd dZe ZG dd dZe Zdd Z	dd	 Z
d
d Zd#ddZdd Zdd Zdd Zdd Zedd Zdd Zdd Zdd Zdd  Zd!d" ZdS )$r!   r4   c                   @      e Zd Zdd Zdd ZdS )zComponent._UNDEFINEDc                 C      dS N	undefinedr   selfr   r   r   __repr__K      zComponent._UNDEFINED.__repr__c                 C   r<   r=   r   r?   r   r   r   __str__N   rB   zComponent._UNDEFINED.__str__Nr   r   r   rA   rC   r   r   r   r   
_UNDEFINEDJ       rE   c                   @   r;   )zComponent._REQUIREDc                 C   r<   Nrequiredr   r?   r   r   r   rA   T   rB   zComponent._REQUIRED.__repr__c                 C   r<   rG   r   r?   r   r   r   rC   W   rB   zComponent._REQUIRED.__str__NrD   r   r   r   r   	_REQUIREDS   rF   rI   c              	      s  dd l }t| D ]\ } | jv }t fdd| jD }d|v r+d|d  dnd}z.d}d	d
dd}| j|v rI||| j | j|j	|}n|| j| jt
t| jdd|}W n tym   d| j d| }Y nw |s|sdt| j}	t| d  d|	  | jvrt|trt|d d  d|d d d  dkrt|tr| D ]*\}
}t|
tstdd|
d| t|ttttfstdd|d| qnt|tstd|t|  | q
d S )Nr   c                 3       | ]}  |V  qd S r   
startswith.0wkr   r   	<genexpr>c   s    

z%Component.__init__.<locals>.<genexpr>idz with the ID "" z$The `{}.{}` component (version {}){}htmldcc
dash_table)dash_html_componentsdash_core_componentsrX   __version__unknownzThe `z` component, z+ received an unexpected keyword argument: `z`
Allowed arguments: z7 detected a Component for a prop other than `children`
zProp z has value z

z8Did you forget to wrap multiple `children` in an array?
zNFor example, it must be html.Div(["a", "b", "c"]) not html.Div("a", "b", "c")
zdict id keys must be strings,
zfound z in id z2dict id values must be strings, numbers or bools,
z(`id` prop must be a string or dict, not )dashlistitems_prop_namesany_valid_wildcard_attributesr$   format_typer[   r   
__import__ImportErrorjoinsorted	TypeError_base_nodesr6   r!   r   strintr0   boolsetattr)r@   kwargsr^   vk_in_propnamesk_in_wildcards	id_suffixerror_string_prefixdash_packagesallowed_argsid_keyid_valr   rP   r   __init__\   s   




zComponent.__init__c                 C   s   t | dr
t| dS d| j d| j d}t| ddr#td| ddtjv r0td	| dttj	t
d
dd d}t| d| |S )NrS   `r    persistenceFa  
                Attempting to use an auto-generated ID with the `persistence` prop.
                This is prohibited because persistence is tied to component IDs and
                auto-generated IDs can easily change.

                Please assign an explicit ID to this z component.
                dash_snapshotsa  
                Attempting to use an auto-generated ID in an app with `dash_snapshots`.
                This is prohibited because snapshots saves the whole app layout,
                including component IDs, and auto-generated IDs can easily change.
                Callbacks referencing the new IDs will not work with old snapshots.

                Please assign an explicit ID to this r   r      )rm   )r5   r   r$   re   RuntimeErrorr
   r   rl   uuidUUIDrdrandintro   )r@   kindrq   r   r   r   _set_random_id   s$   


	zComponent._set_random_idc                    sB    fdd j D }| fdd jD  | j jd}|S )Nc                    s"   i | ]}t  |r|t |qS r   )r5   r   rN   pr?   r   r   
<dictcomp>   s    
z,Component.to_plotly_json.<locals>.<dictcomp>c                    s0   i | ] t  fd djD r t qS )c                 3   rJ   r   rK   rM   rP   r   r   rR      s
    
z6Component.to_plotly_json.<locals>.<dictcomp>.<genexpr>)rb   rc   r   rN   r?   rP   r   r      s    
)propstype	namespace)ra   update__dict__re   r$   )r@   r   as_jsonr   r?   r   to_plotly_json   s   

zComponent.to_plotly_jsonNc              	   C   s  t |  t| jtrdt| jdd d ur2| jj|kr2|dkr | jS |dkr)|| _d S |dkr2d | _d S z(|dkr>| j|W S |dkrL| j|| W d S |dkrY| j| W d S W n	 t	yc   Y nw t| jt
tfrt| jD ]d\}}t|dd |kr|dkr|  S |dkr|| j|<  d S |dkr| j|=  d S qqt|trz)|dkr||W   S |dkr||| W  d S |dkr|| W  d S W qq t	y   Y qqw qqt	|)NrS   r*   setdelete)r:   r6   r4   r!   r   rS   __getitem____setitem____delitem__r8   r7   r   	enumerate)r@   rS   	operationnew_itemir9   r   r   r   _get_set_or_delete   sj   


zComponent._get_set_or_deletec                 C      |  |dS )zTRecursively find the element with the given ID through the tree of
        children.r*   r   r@   rS   r   r   r   r   /  s   zComponent.__getitem__c                 C   s   |  |d|S )zSet an element by its ID.r   r   )r@   rS   r9   r   r   r   r   7  s   zComponent.__setitem__c                 C   r   )z+Delete items by ID in the tree of children.r   r   r   r   r   r   r   ;  s   zComponent.__delitem__c                 c   s    |   D ]}|d V  qdS )zYield each item in the tree.   N)_traverse_with_pathsr@   tr   r   r   	_traverse?  s   zComponent._traversec                 C   s"   t t| dd}|od|ddS )NrS   rU   z (id=r2   ))r   r   )r/   id_r   r   r   _id_strD  s   zComponent._id_strc           	      c   s    t | dd}t|j}|| | }t|tr6d| |fV  | D ]\}}dd| |g|fV  q#dS t|tt	frut
|D ]5\}}d|ddt|jd| | }||fV  t|trt| D ]\}}d||g|fV  qeqAdS dS )	z*Yield each item with its path in the tree.r4   Nz[*] 
[dz] r2   )r   r   r   r   r6   r!   r   rh   r7   r   r   )	r@   r4   children_typechildren_stringr   r   idxr   	list_pathr   r   r   r   I  s&   

$

zComponent._traverse_with_pathsc                 c   s4    |   D ]}t|trt|dddur|V  qdS )z2Yield components with IDs in the tree of children.rS   N)r   r6   r!   r   r   r   r   r   _traverse_idsa  s   zComponent._traverse_idsc                 c   s    |   D ]}|jV  qdS )z"Yield IDs in the tree of children.N)r   rS   r   r   r   r   __iter__g  s   
zComponent.__iter__c                 C   s   d}t | dddu rd}|S t| jtrd}|t| j7 }|S t| jttfr>| jD ]}|d7 }t|tr;|t|7 }q*|S d}|S )z'Return the number of items in the tree.r   r4   Nr   )r   r6   r4   r!   lenr7   r   )r@   lengthcr   r   r   __len__l  s"   	

zComponent.__len__c                    sv    fdd j D  fdd jD  }tdd |D r*d fdd|D }ntt dd } j d	| d
S )Nc                    s    g | ]}t  |d d ur|qS r   r   )rN   r   r?   r   r   
<listcomp>  s
    z&Component.__repr__.<locals>.<listcomp>c                    s(   g | ] t  fd djD r qS )c                 3   rJ   r   rK   )rN   wc_attrr   r   r   rR     s    z0Component.__repr__.<locals>.<listcomp>.<genexpr>)rb   rc   r   r?   r   r   r     s    c                 s   s    | ]}|d kV  qdS )r4   Nr   r   r   r   r   rR     s    z%Component.__repr__.<locals>.<genexpr>r]   c                 3   s$    | ]}| d t  |V  qdS )=Nr   r   r?   r   r   rR     s    
r4   (r   )ra   r   rb   rh   reprr   re   )r@   props_with_valuesprops_stringr   r?   r   rA     s   


zComponent.__repr__r   )r   r   r   r#   rk   rE   	UNDEFINEDrI   REQUIREDrz   r   r   r   r   r   r   r   staticmethodr   r   r   r   r   rA   r   r   r   r   r!   F   s,    N!
G
r!   )	metaclassc                    s\   t  dr
 jjn jj fdd}t tdr,t|jt j d}||_	|S )N	func_codec                     sj   d|v rt dtttd t|  dd | D  |d< d|d v r.|d d  | i |S )N_explicit_argsz*Variable _explicit_args should not be set.c                 S   s   g | ]\}}|qS r   r   )rN   rQ   _r   r   r   r     s    z6_explicitize_args.<locals>.wrapper.<locals>.<listcomp>r@   )	Exceptionr_   r   r   r`   remove)argsrp   funcvarnamesr   r   wrapper  s   (z"_explicitize_args.<locals>.wrapper	signature)
parameters)
r5   r   co_varnames__code__inspectr   replacer   values__signature__)r   r   new_sigr   r   r   _explicitize_args  s   



r   )r%   r   r   r
   r   random_utilsr   r   r   r   Randomr   r   r&   r   r3   r:   r!   r   r   r   r   r   <module>   s"    
	  P