
    Vf>=                         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j                  d       Z G d d      Z G d de j                        Zd	 Zd
 Z G d de      Zd Zy)    N   )patch_collections_abcstringify_id
OrderedSetMutableSequencec                   R    e Zd ZdZ e       Z ej                  e      Z	e
d        Zy)ComponentRegistryz6Holds a registry of the namespaces used by components.c                     g }| j                   D ]1  }t        j                  |   }|j                  t	        ||g              3 |S N)registrysysmodulesextendgetattr)clsresource_name	resourcesmodule_namemodules        h/var/www/html/software/conda/envs/catlas/lib/python3.12/site-packages/dash/development/base_component.pyget_resourceszComponentRegistry.get_resources   sI    	<< 	AK[[-FWV]B?@	A     N)__name__
__module____qualname____doc__r   r   collectionsdefaultdictdictchildren_propsclassmethodr    r   r   r	   r	      s0    @|H,[,,T2N r   r	   c                       e Zd Zd Zy)ComponentMetac                 8   t         j                  j                  | |||      }|d   j                  d      d   }|dk(  s|dk(  r|S t        j
                  j                  |       |j                  d      t        j                  |j                  d|         |<   |S )Nr   .r   	Componentbuiltins_children_props
_namespace)	abcABCMeta__new__splitr	   r   addgetr    )mcsnamebases
attributes	componentr   s         r   r-   zComponentMeta.__new__$   s    KK''T5*E	L)//4Q7;&J"6 ""&&v. NN,- 	((f)MN	
 r   N)r   r   r   r-   r"   r   r   r$   r$   !   s    r   r$   c                 :    	 t        |        y# t        $ r Y yw xY w)NTF)float
ValueError)ss    r   	is_numberr:   5   s#    a s    	c                     t        | d      r:t        | j                  t              s't        | j                  t        t
        f      st        y y )Nchildren)hasattr
isinstancer<   r'   tupler   KeyError)items    r    _check_if_has_indexable_childrenrB   =   s?    4$t}}i04==5/*BC  D 1r   c                       e Zd Zg ZdgZ G d d      Z e       Z G d d      Z e       Zd Z	d Z
d Zdd
Zd Zd Zd Zd Zed        Zd Zd Zd Zd Zd Zy	)r'   r<   c                       e Zd Zd Zd Zy)Component._UNDEFINEDc                      yN	undefinedr"   selfs    r   __repr__zComponent._UNDEFINED.__repr__K       r   c                      yrG   r"   rI   s    r   __str__zComponent._UNDEFINED.__str__N   rL   r   Nr   r   r   rK   rN   r"   r   r   
_UNDEFINEDrE   J   s    		r   rP   c                       e Zd Zd Zd Zy)Component._REQUIREDc                      yNrequiredr"   rI   s    r   rK   zComponent._REQUIRED.__repr__T       r   c                      yrT   r"   rI   s    r   rN   zComponent._REQUIRED.__str__W   rV   r   NrO   r"   r   r   	_REQUIREDrR   S   s    		r   rX   c           
         dd l }t        |j                               D ]  \  }| j                  v }t	        fd| j
                  D              }d|v r	d|d    dnd}	 d}dd	d
d}| j                  |v r6|j                  || j                     | j                  |j                  |      }nF|j                  | j                  | j                  t        t        | j                        dd      |      }|s9|s7dj                  t        | j                              }	t        | d d|	       | j                   vr.t#        |t$              rt        |dz   d d|dz   dz   dz         dk(  rt#        |t&              rq|j                         D ]]  \  }
}t#        |
t(              st        dd|
d|z         t#        |t(        t*        t,        t.        f      rKt        dd|d|z          nt#        |t(              st        d|      t1        | |        y # t        $ r d| j                   d| }Y Jw xY w)Nr   c              3   @   K   | ]  }j                  |        y wr   
startswith.0wks     r   	<genexpr>z%Component.__init__.<locals>.<genexpr>c   s      !$%Q!   idz with the ID "" z$The `{}.{}` component (version {}){}htmldcc
dash_table)dash_html_componentsdash_core_componentsrh   __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_typerk   r   
__import__ImportErrorjoinsorted	TypeError_base_nodesr>   r'   r   strintr7   boolsetattr)rJ   kwargsrn   vk_in_propnamesk_in_wildcards	id_suffixerror_string_prefixdash_packagesallowed_argsid_keyid_valr`   s               @r   __init__zComponent.__init__\   s    ( H	 DAq$"2"22N  !)-)H)H! N
 =AFN.a8PRIQ&L# -3,1".!
 ??m3*=*D*D%doo6

((!	+' +>*D*D


4?? ;]IV!	+' ".#yy4++,   *++VWXVY Z,,8>; 
 (((Z9-E'PQaSA556 RR h	h  Dya&*+'') 
)&#6"+ A$*6*GA5"A!B#   *&3UD2IJ"+ U$*6*GA5"A!B# 
 $As+#&Nqe$TUUD!QQH	 B  Q ).djj\YK&P#Qs   "BH  H?>H?c           	      p   t        | d      rt        | d      S d| j                   d| j                   d}t        | dd      rt	        d| d      dt
        j                  v rt	        d	| d      t        t        j                  t        j                  d
ddz                    }t        | d|       |S )Nrc   `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      )r}   )r=   r   r*   ru   RuntimeErrorr   r   r|   uuidUUIDrdrandintr   )rJ   kindr   s      r   _set_random_idzComponent._set_random_id   s    44&&4??#1TZZL24.6
 7;V <  s{{*6 7;V <	 	 		bjjAsF345dAr   c           
      V   | j                   D ci c]  }t        | |      r|t        | |       }}|j                  | j                  D ci c]-  t        fd| j                  D              rt        |       / c}       || j                  | j                  d}|S c c}w c c}w )Nc              3   @   K   | ]  }j                  |        y wr   r[   r]   s     r   ra   z+Component.to_plotly_json.<locals>.<genexpr>   s#        LLOrb   )propstype	namespace)	rq   r=   r   update__dict__rr   rs   ru   r*   )rJ   pr   r`   as_jsons      ` r   to_plotly_jsonzComponent.to_plotly_json   s     %%
tQ wtQ
 
 	   "<<  74##
	
 JJ
 /
s    B!2B&Nc                    t        |        t        | j                  t              rt	        | j                  dd       D| j                  j
                  |k(  r+|dk(  r| j                  S |dk(  r|| _        y |dk(  rd | _        y 	 |dk(  r| j                  j                  |      S |dk(  r| j                  j                  ||       y |dk(  r| j                  j                  |       y 	 t        | j                  t        t        f      rt        | j                        D ]  \  }}t	        |dd       |k(  r4|dk(  r|c S |dk(  r|| j                  |<    y |dk(  s;| j                  |=  y t        |t              s[	 |dk(  r|j                  |      c S |dk(  r|j                  ||        y |dk(  r|j                  |        y  t        |      # t        $ r Y w xY w# t        $ r Y w xY w)Nrc   r0   setdelete)rB   r>   r<   r'   r   rc   __getitem____setitem____delitem__r@   r?   r   	enumerate)rJ   rc   	operationnew_itemirA   s         r   _get_set_or_deletezComponent._get_set_or_delete   s   (. dmmY/t}}dD1===##r) E)#}}, E)(0 H,(,
%==44R88%MM--b(;(MM--b1 ) dmme_%=>$T]]3 44t,2 E)# E)+3a( H, MM!,  i0
$-#'#3#3B#77$- ,,R:"$0 ,,R0" 1+: rlE  : $ s<   G "!G  G 7GG(G	GG	G('G(c                 &    | j                  |d      S )zTRecursively find the element with the given ID through the tree of
        children.r0   r   rJ   rc   s     r   r   zComponent.__getitem__/  s     &&r511r   c                 (    | j                  |d|      S )zSet an element by its ID.r   r   )rJ   rc   rA   s      r   r   zComponent.__setitem__7  s    &&r5$77r   c                 &    | j                  |d      S )z+Delete items by ID in the tree of children.r   r   r   s     r   r   zComponent.__delitem__;  s    &&r844r   c              #   D   K   | j                         D ]	  }|d     yw)zYield each item in the tree.   N)_traverse_with_pathsrJ   ts     r   	_traversezComponent._traverse?  s'     **, 	AA$J	s    c                 D    t        t        | dd            }|xr d|ddS )Nrc   re   z (id=r9   ))r   r   )r5   id_s     r   _id_strzComponent._id_strD  s+    79dB78's1gQ''r   c              #   L  K   t        | dd      }t        |      j                  }|| j                  |      z   }t	        |t
              r<d|z   |f |j                         D ]  \  }}dj                  d|z   |g      |f ! yt	        |t        t        f      rt        |      D ]y  \  }}d|ddt        |      j                  d| j                  |       }||f t	        |t
              sK|j                         D ]  \  }}dj                  ||g      |f  { yyw)	z*Yield each item with its path in the tree.r<   Nz[*] 
[dz] r9   )r   r   r   r   r>   r'   r   rx   r?   r   r   )	rJ   r<   children_typechildren_stringr   r   idxr   	list_paths	            r   r   zComponent._traverse_with_pathsI  s2    4T2X//'$,,x*@@ h	*?*H44 557 B1ii/!91 =>AAB 5/":;#H- ;QAwba)9)9!(<T\\!_<MN	l"a+ ! 6 6 8 ;1"iiA7::;; <s   C.D$13D$c              #   |   K   | j                         D ]%  }t        |t              st        |dd      "| ' yw)z2Yield components with IDs in the tree of children.rc   N)r   r>   r'   r   r   s     r   _traverse_idszComponent._traverse_idsa  s9     ! 	A!Y'GAtT,B,N	s   $<<<c              #   R   K   | j                         D ]  }|j                    yw)z"Yield IDs in the tree of children.N)r   rc   r   s     r   __iter__zComponent.__iter__g  s'     ##% 	A$$J	s   %'c                 J   d}t        | dd      d}|S t        | j                  t              rd}|t	        | j                        z  }|S t        | j                  t
        t        f      r7| j                  D ]&  }|dz  }t        |t              s|t	        |      z  }( |S d}|S )z'Return the number of items in the tree.r   r<   Nr   )r   r>   r<   r'   lenr?   r   )rJ   lengthcs      r   __len__zComponent.__len__l  s     4T*2F  y1Fc$--((F  '?@]] %!a+c!f$F%  Fr   c                      j                   D cg c]  }t         |d       | c} j                  D cg c]"  t        fd j                  D              r$ c}z   }t        d |D              rdj                   fd|D              }nt        t         dd             } j                   d| dS c c}w c c}w )Nc              3   @   K   | ]  }j                  |        y wr   r[   )r^   wc_attrr   s     r   ra   z%Component.__repr__.<locals>.<genexpr>  s     XW1<<(Xrb   c              3   &   K   | ]	  }|d k7    yw)r<   Nr"   )r^   r   s     r   ra   z%Component.__repr__.<locals>.<genexpr>  s     :1qJ:s   rm   c              3   @   K   | ]  }| d t        |        yw)=N)r   )r^   r   rJ   s     r   ra   z%Component.__repr__.<locals>.<genexpr>  s)      %011#QwtQ'*+%rb   r<   (r   )rq   r   r   rr   rs   rx   reprru   )rJ   r   props_with_valuesprops_strings   ``  r   rK   zComponent.__repr__  s     ''
74D+A+MA
 ]]
X8W8WXX 

 :(9::99 %5F% L  j$ ?@L**Q|nA..

s   B:B:'B?r   )r   r   r   r)   r{   rP   	UNDEFINEDrX   REQUIREDr   r   r   r   r   r   r   r   staticmethodr   r   r   r   r   rK   r"   r   r   r'   r'   F   s    O,K  I  {HL \B:>N285
 ( (;0
,/r   r'   )	metaclassc                 V    t         d      r j                  j                  n j                  j                   fd}t        t        d      rWt	        j
                  |      j                  t	        j
                         j                  j                               }||_	        |S )N	func_codec                     d|v rt        d      t        t        t        d t        |              |j	                         D cg c]  \  }}|	 c}}z               |d<   d|d   v r|d   j                  d        | i |S c c}}w )N_explicit_argsz*Variable _explicit_args should not be set.rJ   )	Exceptionro   r   r   rp   remove)argsr   r`   _funcvarnamess       r   wrapperz"_explicitize_args.<locals>.wrapper  s    v%HII#'XkD	*+V\\^.LTQq.LLM$
  V,--#$++F3T$V$$	 /Ms   B	signature)
parameters)
r=   r   co_varnames__code__inspectr   replacer   values__signature__)r   r   new_sigr   s   `  @r   _explicitize_argsr     s    t[!>>-- ==,,% w$##G,44((.99@@B 5 
 !(Nr   )r+   r   r   r   r   random_utilsr   r   r   r   Randomr   r	   r,   r$   r:   rB   r'   r   r"   r   r   <module>r      sp    
   
   D D'(9:V]]1 "CKK (K/- K/\
r   