
    -Pha                    "   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZ dd	lmZ dd
lmZ  ee          ZdZdZd5dZ G d de          Z	 d6dddd7d#Zd8d&Zd9d(Zd:d.Zd;d/Zd;d0Zd;d1Z G d2 d3ej                   Z!d4S )<zShared constants and functions.    )annotations)Sequence)final)nodes)
directives)Sphinx)Config)SphinxDirective)	getLoggerdesign)primary	secondarysuccessinfowarningdangerlightmuteddarkwhiteblackappr   configr	   directive_mapdict[str, SdDirective]returnNonec           	     l   |j         }d }t          |t                    s |d           i |_         d S |                                D ]j\  }}t          |t                    s |d|           *t          |t                    s ||d           Nd|vr ||d           a|d         |vr |d| d|d                     ||d                  }d	|v rt          |d	         t                    s |d| d
           d|v r+t          |d         t                    s |d| d           |d	                                         D ]H\  }}	||j        vr |d| d|            t          |	t                    s |d| d| d           HI|                     ||d           ld S )Nc                P    t                               d|  t          d           d S )Nzsd_custom_directives: r   )typesubtype)LOGGERr   WARNING_TYPE)msgs    T/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sphinx_design/shared.py_warnz&setup_custom_directives.<locals>._warn'   s6    *S**x 	 	
 	
 	
 	
 	
    zmust be a dictionaryzkey must be a string: z value must be a dictionaryinheritz! value must have an 'inherit' key'z'.inherit' is an unknown directive key: optionsz$.options' value must be a dictionaryargumentz!.argument' value must be a stringz.options' unknown key z	.options.z' value must be a stringT)override)sd_custom_directives
isinstancedictitemsstroption_specadd_directive)
r   r   r   
conf_valuer&   namedatadirective_clskeyvalues
             r%   setup_custom_directivesr:   "   so    ,J
 
 

 j$'' $%%%&(# &&(( > >
d$$$ 	E3433444$%% 	ET888999D  ET>>>???	?-//ETdTT4	?TTUUU%d9o6d9ot44 D$DDDEEET!!*T*5Es*K*K!A$AAABBB"9o3355  
Um777EAdAA#AABBB!%-- EJdJJSJJJKKK 	$====9> >r'   c                  2    e Zd ZdZedd            ZddZdS )SdDirectivea1  Base class for all sphinx-design directives.

    Having a base class allows for shared functionality to be implemented in one place.
    Namely, we allow for default options to be configured, per directive name.

    This class should be sub-classed by all directives in the sphinx-design extension.
    r   list[nodes.Node]c           
     h   | j         j                            | j                  x}r| j        s,|                    d          x}rt          |          g| _        |                    di                                           D ]\  }}|| j        vr|| j        v r	  | j        |         t          |                    | j        |<   D# t          $ rL}t                              d|d| j        d| t          d| j        j        | j        f           Y d}~d}~ww xY w|                                 S )	zpRun the directive.

        This method should not be overridden, instead override `run_with_defaults`.
        r+   r*   zInvalid default option z for z: 	directive)r    r!   locationN)r   r-   getr5   	argumentsr1   r0   r*   r2   	Exceptionr"   r   r#   envdocnamelinenorun_with_defaults)selfr6   r+   r8   r9   excs         r%   runzSdDirective.run\   se    ;377	BBB4 	N 1TXXj5I5I)I 1"%h--"hhy"55;;== 
 

Udl**sd6F/F/F,AD,<S,A#e**,M,MS))$   VcVV$)VVQTVV!-$/&*h&6%D	 '         %%'''s   +C
DADDc                    t           )zyRun the directive, after default options have been set.

        This method should be overridden by subclasses.
        )NotImplementedError)rH   s    r%   rG   zSdDirective.run_with_defaultsr   s
    
 "!r'   N)r   r=   )__name__
__module____qualname____doc__r   rJ   rG    r'   r%   r<   r<   O   sR          ( ( ( U(*" " " " " "r'   r<   rQ    )rawtextchildrenr5   r1   classesSequence[str]rS   rT   Sequence[nodes.Node]nodes.containerc               v    t          j        |fd| t          |          d|}|                    |           |S )z/Create a container node for a design component.T)is_divdesign_componentrU   )r   	containerlistextend)r5   rU   rS   rT   
attributesnodes         r%   create_componentra   z   sP     ?tT']] NX D 	KKKr'   r`   
nodes.Nodec                X    	 |                      d          |k    S # t          $ r Y dS w xY w)z.Check if a node is a certain design component.r[   F)rA   AttributeError)r`   r5   s     r%   is_componentre      sA    xx*++t33   uus    
))choicesc                      fdS )zCreate a choice validator.c                .    t          j        |           S )Nr   choice)r+   rf   s    r%   <lambda>zmake_choice.<locals>.<lambda>   s    J-h@@ r'   rQ   )rf   s   `r%   make_choicerl      s    @@@@@r'   r+   
str | Noneclass_prefixallowed	list[str]c                J   | t          d          |                                 }|D ]}||vrt          | d|           t          |          dk    r d|d          gS t          |          dk    rfdt          g d	|          D             S t          d
          )zvValidate the margin/padding is one (all) or four (top bottom left right) integers,
    between 0 and 5 or 'auto'.
    Nz#argument required but none suppliedz is not in:    -r      c                (    g | ]\  }} | d | S )rs   rQ   ).0sider9   rn   s      r%   
<listcomp>z-_margin_or_padding_option.<locals>.<listcomp>   s@     
 
 
e +T++E++
 
 
r'   )tblrzCargument must be one (all) or four (top bottom left right) integers)
ValueErrorsplitlenzip)r+   rn   ro   valuesr9   s    `   r%   _margin_or_padding_optionr      s     >???^^F > ><<7<<===  
6{{a--&)--..
6{{a
 
 
 
"#7#7#7@@
 
 
 	
 M  r'   c                $    t          | dd          S )znValidate the margin is one (all) or four (top bottom left right) integers,
    between 0 and 5 or 'auto'.
    zsd-m)auto012345r   r+   s    r%   margin_optionr      s     %&@  r'   c                $    t          | dd          S )zeValidate the padding is one (all) or four (top bottom left right) integers,
    between 0 and 5.
    zsd-p)r   r   r   r   r   r   r   r   s    r%   padding_optionr      s     %Xv7UVVVr'   c                <    t          j        | g d          }d| gS )z:Validate the text align is left, right, center or justify.)leftrightcenterjustifyzsd-text-ri   )r+   r9   s     r%   
text_alignr      s,    h(N(N(NOOEur'   c                      e Zd ZdZdS )PassthroughTextElementa9  A text element which will not render anything.

    This is required for reference node to render correctly outside of paragraphs.
    Since sphinx expects them to be within a ``TextElement``:
    https://github.com/sphinx-doc/sphinx/blob/068f802df90ea790f89319094e407c4d5f6c26ff/sphinx/writers/html5.py#L224
    N)rM   rN   rO   rP   rQ   r'   r%   r   r      s           r'   r   N)r   r   r   r	   r   r   r   r   )rQ   )
r5   r1   rU   rV   rS   r1   rT   rW   r   rX   )r`   rb   r5   r1   )rf   rV   )r+   rm   rn   r1   ro   rV   r   rp   )r+   rm   r   rp   )"rP   
__future__r   collections.abcr   typingr   docutilsr   docutils.parsers.rstr   sphinx.applicationr   sphinx.configr	   sphinx.util.docutilsr
   sphinx.util.loggingr   rM   r"   r#   SEMANTIC_COLORSr:   r<   ra   re   rl   r   r   r   r   TextElementr   rQ   r'   r%   <module>r      s   % % " " " " " " $ $ $ $ $ $             + + + + + + % % % % % %             0 0 0 0 0 0 ) ) ) ) ) )	8		*> *> *> *>Z(" (" (" (" ("/ (" (" ("Z   %'         A A A A
   4   W W W W           U.     r'   