
     h                     `    d Z dgZddlZddlZddlmZ ddlmZ  G d dej                        Z
y)z~CSSVariables implements (and only partly) experimental
`CSS Variables <http://disruptive-innovations.com/zoo/cssvariables/>`_
CSSVariablesRule    N   )cssrule)CSSVariablesDeclarationc                        e Zd ZdZ	 	 	 	 	 d fd	Zd Zd Zd Z fdZ e	eed      Z
 e	d	      Zd
 Z e	d ed      Z e	d d      Z e	d d      Z e	d       Z xZS )r   aW  
    The CSSVariablesRule interface represents a @variables rule within a CSS
    style sheet. The @variables rule is used to specify variables.

    cssutils uses a :class:`~cssutils.css.CSSVariablesDeclaration`  to
    represent the variables.

    Format::

        variables
            VARIABLES_SYM S* medium [ COMMA S* medium ]* LBRACE S*
            variableset* '}' S*
            ;

    for variableset see :class:`cssutils.css.CSSVariablesDeclaration`

    **Media are not implemented. Reason is that cssutils is using CSS
    variables in a kind of preprocessing and therefor no media information
    is available at this stage. For now do not use media!**

    Example::

        @variables {
          CorporateLogoBGColor: #fe8d12;
        }

        div.logoContainer {
          background-color: var(CorporateLogoBGColor);
        }
    c                     t         |   ||       d| _        t        j                  j                  ||      | _        |r|| _        || _	        yt        |       | _        || _	        y)zO
        If readonly allows setting of properties in constructor only.
        )
parentRuleparentStyleSheetz
@variables)readonlyr	   N)
super__init__
_atkeywordcssutilsstylesheets	MediaList_media	variablesr   	_readonly)self	mediaTextr   r	   r
   r   	__class__s         ]/var/www/api/v1/venv_getwork_v1/lib/python3.12/site-packages/cssutils/css/cssvariablesrule.pyr   zCSSVariablesRule.__init__/   sf     	JAQR& **44Y4R&DN " 5EDN!    c                     d| j                   j                   d| j                  j                  d| j                  j
                  dS )Nzcssutils.css.z(mediaText=z, variables=))r   __name__r   r   r   cssTextr   s    r   __repr__zCSSVariablesRule.__repr__G   sQ    t~~667{4;;CXCXB[[ghlhvhvh~h~  hB  BC  D  	Dr   c                     d| j                   j                  | j                  j                  | j                  j
                  | j                  t        |       fz  S )NzC<cssutils.css.%s object mediaText=%r variables=%r valid=%r at 0x%x>)r   r   r   r   r   r   valididr   s    r   __str__zCSSVariablesRule.__str__J   sM     ''%%&&

4
	
r   c                 @    t         j                  j                  |       S )z#Return serialized property cssText.)r   serdo_CSSVariablesRuler   s    r   _getCssTextzCSSVariablesRule._getCssTextW   s    ||//55r   c                 d   t         |   |       | j                  |      }| j                  |d      }| j	                  |      | j
                  j                  k7  rH| j                  j                  d| j                  |      z  t        j                  j                         yt        |       }d}| j                  |dd      \  }}| j                  |      dk7  r0d}| j                  j                  d	| j                  |      z  |       d
di}| j!                         }	| j#                  d|	| j                  |      i       \  }
}|xr	 |
xr |d
   }| j                  |dd      \  }}| j                  |      | j	                  |      }}|dk7  r4|dk7  r/d}| j                  j                  d| j                  |      z         | j                  |      }|rd}| j                  j                  d|       d|k(  r|j%                  |       ||_        |r| j)                  |	       || _        yy)ar  
        :exceptions:
            - :exc:`~xml.dom.SyntaxErr`:
              Raised if the specified CSS string value has a syntax error and
              is unparsable.
            - :exc:`~xml.dom.InvalidModificationErr`:
              Raised if the specified CSS string value represents a different
              type of rule than the current one.
            - :exc:`~xml.dom.HierarchyRequestErr`:
              Raised if the rule cannot be inserted at this point in the
              style sheet.
            - :exc:`~xml.dom.NoModificationAllowedErr`:
              Raised if the rule is readonly.

        Format::

            variables
            : VARIABLES_SYM S* medium [ COMMA S* medium ]* LBRACE S*
              variableset* '}' S*
            ;

            variableset
            : LBRACE S* vardeclaration [ ';' S* vardeclaration ]* '}' S*
            ;
        Nz/CSSVariablesRule: No CSSVariablesRule found: %s)errorr   T)blockstartonlyseparateEnd{Fz>CSSVariablesRule: No start { of variable declaration found: %r
wellformed:)expectedseq	tokenizerproductions)blockendonlyr,   }EOFz>CSSVariablesRule: No "}" after variables declaration found: %rz)CSSVariablesRule: Trailing content found.)token)r   _setCssText
_tokenize2
_nexttoken_type_prodsVARIABLES_SYM_logr*   	_valuestrxmldomInvalidModificationErrr   _tokensupto2_tokenvalue_tempSeq_parseappendr   _setSeqr   )r   r   r2   attokennewVariablesokbeforetokensbracenewnewseqbeforewellformedr0   variablestokensbraceorEOFtokenvaltype_	nonetokenr   s                    r   r8   zCSSVariablesRule._setCssText[   s9   4 	G$OOG,	//)T2::g$++";";;IIOOA..)*gg44   3dCLB"&"3"3$D #4 #L% &#-		,.2nnW.EF  &C]]_F)-//,7	 *5 *&h >(>S->B/3/@/@$ 0A 0,O_ ))/:DJJ<WCczeun		,.2nnW.EF
 	2I		?y    ~&&7#2L V$!- r   z7(DOM) The parsable textual representation of this rule.)docz]NOT IMPLEMENTED! As cssutils resolves variables during serializing media information is lost.c                     | j                          t        |t              rt        ||       | _        y| |_        || _        y)zS
        :param variables:
            a CSSVariablesDeclaration or string
        )r   r	   N)_checkReadonly
isinstancestrr   
_variables_parentRule)r   r   s     r   _setVariableszCSSVariablesRule._setVariables   s<    
 	i%5!dDO %)I!'DOr   c                     | j                   S N)r[   r   s    r   <lambda>zCSSVariablesRule.<lambda>   s    T__r   zV(DOM) The variables of this rule set, a :class:`cssutils.css.CSSVariablesDeclaration`.c                     | j                   S r_   )VARIABLES_RULEr   s    r   r`   zCSSVariablesRule.<lambda>   s
    T((r   z=The type of this rule, as defined by a CSSRule type constant.c                      yNT r   s    r   r`   zCSSVariablesRule.<lambda>   s    $r   zNOT IMPLEMTED REALLY (TODO)c                      yrd   re   r   s    r   r`   zCSSVariablesRule.<lambda>   s    tr   )NNNNF)r   
__module____qualname____doc__r   r    r$   r(   r8   propertyr   mediar]   r   typer"   r.   __classcell__)r   s   @r   r   r      s    B "0D
6[.z HG 8E
( $9I (ND
 &,IJE +,Jr   )ri   __all__xml.domr@   r    r   cssvariablesdeclarationr   CSSRuler   re   r   r   <module>rs      s2    
    <Q-w Q-r   