
    Mf>=                         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dS )    N   )patch_collections_abcstringify_id
OrderedSetMutableSequencec                   \    e Zd ZdZ e            Z ej        e          Z	e
d             ZdS )ComponentRegistryz6Holds a registry of the namespaces used by components.c                     g }| j         D ]8}t          j        |         }|                    t	          ||g                      9|S N)registrysysmodulesextendgetattr)clsresource_name	resourcesmodule_namemodules        ^/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/dash/development/base_component.pyget_resourceszComponentRegistry.get_resources   sO    	< 	A 	AK[-FWV]B??@@@@    N)__name__
__module____qualname____doc__r   r   collectionsdefaultdictdictchildren_propsclassmethodr    r   r   r	   r	      sP        @@z||H,[,T22N  [  r   r	   c                       e Zd Zd ZdS )ComponentMetac                 ^   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   s         r   r-   zComponentMeta.__new__$   s    K''T5*EE	L)//44Q7;&J"6"6 "&&v... NN,-- 	(f)M)MN	
 r   N)r   r   r   r-   r"   r   r   r$   r$   !   s#            r   r$   c                 H    	 t          |            dS # t          $ r Y dS w xY w)NTF)float
ValueError)ss    r   	is_numberr:   5   s9    at   uus    
!!c                     t          | d          r;t          | j        t                    s(t          | j        t          t
          f          s	t          d S d S )Nchildren)hasattr
isinstancer<   r'   tupler   KeyError)items    r    _check_if_has_indexable_childrenrB   =   s\    4$$ t}i004=5/*BCC
    r   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d	S )r'   r<   c                       e Zd Zd Zd ZdS )Component._UNDEFINEDc                     dS N	undefinedr"   selfs    r   __repr__zComponent._UNDEFINED.__repr__K       ;r   c                     dS rG   r"   rI   s    r   __str__zComponent._UNDEFINED.__str__N   rL   r   Nr   r   r   rK   rN   r"   r   r   
_UNDEFINEDrE   J   s2        	 	 		 	 	 	 	r   rP   c                       e Zd Zd Zd ZdS )Component._REQUIREDc                     dS Nrequiredr"   rI   s    r   rK   zComponent._REQUIRED.__repr__T       :r   c                     dS rT   r"   rI   s    r   rN   zComponent._REQUIRED.__str__W   rV   r   NrO   r"   r   r   	_REQUIREDrR   S   s2        	 	 		 	 	 	 	r   rX   c           
         dd l }t          |                                          D ]?\  }| j        v }t	          fd| j        D                       }d|v rd|d          dnd}	 d}dd	d
d}| j        |v r.|                    || j                 | j        |j	        |          }nC|                    | j        | j        t          t          | j                  dd          |          }n# t          $ r d| j         d| }Y nw xY w|s@|s>d                    t          | j                            }	t          | d d|	           | j        vr7t#          |t$                    r"t          |dz   d d|dz   dz   dz             dk    rt#          |t&                    r|                                D ]r\  }
}t#          |
t(                    st          dd|
d|z             t#          |t(          t*          t,          t.          f          st          dd|d|z             sn't#          |t(                    st          d|          t1          | |           Ad S )Nr   c              3   B   K   | ]}                     |          V  d S r   
startswith.0wks     r   	<genexpr>z%Component.__init__.<locals>.<genexpr>c   s>       ! !$%Q! ! ! ! ! !r   idz with the ID "" z$The `{}.{}` component (version {}){}htmldcc
dash_table)dash_html_componentsdash_core_componentsrg   __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_typerj   r   
__import__ImportErrorjoinsorted	TypeError_base_nodesr>   r'   r   strintr7   boolsetattr)rJ   kwargsrm   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	  H	 DAq$"22N  ! ! ! !)-)H! ! !  N
 =AFNN88888PRIQ&L# -3,1".! !
 ?m33*=*D*D%do6
(!	+ +'' +>*D*D

4? ; ;]IVV!	+ +'  Q Q Q 'Qdj&P&PY&P&P###Q
 " . #yy4+,,     * ; ;WX ; ;,8; ;  
 (((Z9-E-E('PQ5a55A5556 RR h	h   Dyya&& V*+'')) 
 
)&#66 "+ A"A6"A"AA"A"A!B# #   *&3UD2IJJ "+ U"A6"A"AA"A"A!B# # 
 $As++ V#$Tq$T$TUUUD!QQH	  H	 s   )BC,,DDc           	         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                              d
ddz                                }t          | d|           |S )Nrb   `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*   rt   RuntimeErrorr   r   r{   uuidUUIDrdrandintr~   )rJ   kindr   s      r   _set_random_idzComponent._set_random_id   s    4 	'4&&&24?22TZ2224.. 		
 7;     s{** 7;  	 	 	 	bjjAsF3344455dAr   c                       fd j         D             }|                     fd j        D                        | j         j        d}|S )Nc                 R    i | ]#}t          |          |t          |          $S r"   )r=   r   r^   prJ   s     r   
<dictcomp>z,Component.to_plotly_json.<locals>.<dictcomp>   sE     
 
 
tQ
wtQ
 
 
r   c                 t    i | ]3t          fd j        D                       "t                    4S )c              3   B   K   | ]}                     |          V  d S r   r[   r]   s     r   ra   z6Component.to_plotly_json.<locals>.<dictcomp>.<genexpr>   sC          LLOO     r   )rq   rr   r   )r^   r`   rJ   s    @r   r   z,Component.to_plotly_json.<locals>.<dictcomp>   sq            "<    74##  r   )propstype	namespace)rp   update__dict__rt   r*   )rJ   r   as_jsons   `  r   to_plotly_jsonzComponent.to_plotly_json   s    
 
 
 
%
 
 
 	     
	
 
	
 
	
 J
 
 r   Nc                    t          |            t          | j        t                    rt	          | j        dd           ;| j        j        |k    r+|dk    r| j        S |dk    r	|| _        d S |dk    r	d | _        d S 	 |dk    r| j                            |          S |dk    r| j                            ||           d S |dk    r| j                            |           d S n# t          $ r Y nw xY wt          | j        t          t          f          rt          | j                  D ]\  }}t	          |dd           |k    r/|dk    r|c S |dk    r|| j        |<    d S |dk    r| j        |=  d S It          |t                    rl	 |dk    r|                    |          c S |dk    r|                    ||            d S |dk    r|                    |            d S # t          $ r Y w xY wt          |          )Nrb   r0   setdelete)rB   r>   r<   r'   r   rb   __getitem____setitem____delitem__r@   r?   r   	enumerate)rJ   rb   	operationnew_itemirA   s         r   _get_set_or_deletezComponent._get_set_or_delete   s   (... dmY// 	t}dD11==#r)) E))#}, E))(0 H,,(,
%%=44R888%%M--b(;;;F((M--b111F )     dme_%=>> 	$T]33  44t,,22 E))# E))+3a( H,, M!, -  i00 
$--#'#3#3B#7#7777$-- ,,R:::"FF$00 ,,R000"FF 1 $    rlls<   <C" !C" ? C" "
C/.C/G!#G!G!!
G.-G.c                 .    |                      |d          S )zTRecursively find the element with the given ID through the tree of
        children.r0   r   rJ   rb   s     r   r   zComponent.__getitem__/  s     &&r5111r   c                 0    |                      |d|          S )zSet an element by its ID.r   r   )rJ   rb   rA   s      r   r   zComponent.__setitem__7  s    &&r5$777r   c                 .    |                      |d          S )z+Delete items by ID in the tree of children.r   r   r   s     r   r   zComponent.__delitem__;  s    &&r8444r   c              #   L   K   |                                  D ]}|d         V  dS )zYield each item in the tree.   N)_traverse_with_pathsrJ   ts     r   	_traversezComponent._traverse?  s:      **,, 	 	AA$JJJJ	 	r   c                 P    t          t          | dd                    }|od|ddS )Nrb   rd   z (id=r9   ))r   r   )r5   id_s     r   _id_strzComponent._id_strD  s5    79dB7788''s'''''r   c              #     K   t          | dd          }t          |          j        }||                     |          z   }t	          |t
                    rCd|z   |fV  |                                D ]#\  }}d                    d|z   |g          |fV  $dS t	          |t          t          f          rt          |          D ]\  }}d|ddt          |          j        d|                     |           }||fV  t	          |t
                    r5|                                D ] \  }}d                    ||g          |fV  !dS dS )	z*Yield each item with its path in the tree.r<   Nz[*] 
[dz] r9   )r   r   r   r   r>   r'   r   rw   r?   r   r   )	rJ   r<   children_typechildren_stringr   r   idxr   	list_paths	            r   r   zComponent._traverse_with_pathsI  s     4T22X/'$,,x*@*@@ h	** 	;?*H4444 5577 B B1ii/!91 =>>AAAAAB B 5/":;; 	;#H-- ; ;QNNNNa)9NNT\\!__NN	l"""a++ ; ! 6 6 8 8 ; ;1"iiA77:::::	; 	;; ;r   c              #      K   |                                  D ],}t          |t                    rt          |dd          |V  -dS )z2Yield components with IDs in the tree of children.rb   N)r   r>   r'   r   r   s     r   _traverse_idszComponent._traverse_idsa  sV      !! 	 	A!Y'' GAtT,B,B,N	 	r   c              #   J   K   |                                  D ]}|j        V  dS )z"Yield IDs in the tree of children.N)r   rb   r   s     r   __iter__zComponent.__iter__g  s8      ##%% 	 	A$JJJJ	 	r   c                 N   d}t          | dd          d}nt          | j        t                    rd}|t	          | j                  z  }nZt          | j        t
          t          f          r7| j        D ].}|dz  }t          |t                    r|t	          |          z  }/n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FFy11 
	Fc$-(((FF'?@@ 	] % %!a++ %c!ff$F% Fr   c                      fd j         D              fd j        D             z   }t          d |D                       r"d                     fd|D                       }nt	          t           dd                     } j         d| dS )	Nc                 6    g | ]}t          |d           |S r   r   r^   r   rJ   s     r   
<listcomp>z&Component.__repr__.<locals>.<listcomp>  s1     
 
 
74D+A+A+MA+M+M+Mr   c                 V    g | ]$t          fd j        D                       "%S )c              3   B   K   | ]}                     |          V  d S r   r[   )r^   wc_attrr   s     r   ra   z0Component.__repr__.<locals>.<listcomp>.<genexpr>  s/      XXW1<<((XXXXXXr   )rq   rr   r   s    @r   r   z&Component.__repr__.<locals>.<listcomp>  sP     
 
 
XXXX8WXXXXX

 
 
r   c              3   "   K   | ]
}|d k    V  dS )r<   Nr"   )r^   r   s     r   ra   z%Component.__repr__.<locals>.<genexpr>  s&      ::1qJ::::::r   rl   c              3   B   K   | ]}| d t          |          V  dS )=Nr   r   s     r   ra   z%Component.__repr__.<locals>.<genexpr>  sL       % %011++wtQ''++% % % % % %r   r<   (r   )rp   r   rq   rw   reprr   rt   )rJ   props_with_valuesprops_strings   `  r   rK   zComponent.__repr__  s    
 
 
 
'
 
 

 
 
 
]
 
 

 ::(9::::: 	A99 % % % %5F% % %  LL  j$ ? ?@@L*..|....r   r   )r   r   r   r)   rz   rP   	UNDEFINEDrX   REQUIREDr   r   r   r   r   r   r   r   staticmethodr   r   r   r   r   rK   r"   r   r   r'   r'   F   ss       O,K        
I        y{{HL  L  L \  B  :> > > >N2 2 28 8 85 5 5  
 ( ( \(; ; ;0    
  ,/ / / / /r   r'   )	metaclassc                 B    t           d          r j        j        n j        j         fd}t          t          d          rXt	          j        |                              t	          j                   j                                                  }||_	        |S )N	func_codec                  D   d|v rt          d          t          t          t          d t          |                              d |                                D             z                       |d<   d|d         v r|d                             d            | i |S )N_explicit_argsz*Variable _explicit_args should not be set.c                     g | ]\  }}|S r"   r"   )r^   r`   _s      r   r   z6_explicitize_args.<locals>.wrapper.<locals>.<listcomp>  s    .L.L.LTQq.L.L.Lr   rJ   )	Exceptionrn   r   r   ro   remove)argsr   funcvarnamess     r   wrapperz"_explicitize_args.<locals>.wrapper  s    v%%HIII#'XkD		k*++.L.LV\\^^.L.L.LLMM$
 $
  V,---#$++F333tT$V$$$r   	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@@B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      sB   



      



   D D D D D D D D D D''(9::V]1       "    CK   (    K/ K/ K/ K/ K/- K/ K/ K/ K/\
    r   