
    ]h                         d dl mZmZmZmZ d dlZd dlZddlm	Z	 ddl
mZ d dlmZmZmZmZmZ 	 dgZdZd	Zd dlZej,                  d    d
k\  reZneZ G d de	j4                        Zy)    )unicode_literalsdivisionabsolute_importprint_functionN   )cssrule)CSSStyleDeclaration)ProdPreDefSequenceChoice
ProdParser
MarginRulerestructuredtextz$Id$   c                        e Zd ZdZg dZ	 	 d fd	Zd Z ed ed      ZeZ	d Z
d	 Zd
 Z fdZ eeed      Zd Z ed ed      Z ed d      Z ed       Z xZS )r   a  
    A margin at-rule consists of an ATKEYWORD that identifies the margin box
    (e.g. '@top-left') and a block of declarations (said to be in the margin
    context).

    Format::

        margin :
               margin_sym S* '{' declaration [ ';' S* declaration? ]* '}' S*
               ;

        margin_sym :
               TOPLEFTCORNER_SYM |
               TOPLEFT_SYM |
               TOPCENTER_SYM |
               TOPRIGHT_SYM |
               TOPRIGHTCORNER_SYM |
               BOTTOMLEFTCORNER_SYM |
               BOTTOMLEFT_SYM |
               BOTTOMCENTER_SYM |
               BOTTOMRIGHT_SYM |
               BOTTOMRIGHTCORNER_SYM |
               LEFTTOP_SYM |
               LEFTMIDDLE_SYM |
               LEFTBOTTOM_SYM |
               RIGHTTOP_SYM |
               RIGHTMIDDLE_SYM |
               RIGHTBOTTOM_SYM
               ;

    e.g.::

        @top-left {
            content: "123";
            }
    )z@top-left-cornerz	@top-leftz@top-centerz
@top-rightz@top-right-cornerz@bottom-left-cornerz@bottom-leftz@bottom-centerz@bottom-rightz@bottom-right-cornerz	@left-topz@left-middlez@left-bottomz
@right-topz@right-middlez@right-bottomc                     t         t        |   ||       dx| _        | _        |r|| _        |r|| _        || _        yt        |       | _        || _        y)z
        :param atkeyword:
            The margin area, e.g. '@top-left' for this rule
        :param style:
            CSSStyleDeclaration for this MarginRule
        )
parentRuleparentStyleSheetNr   )	superr   __init__
_atkeyword_keywordmarginstyler	   	_readonly)selfr   r   r   r   readonly	__class__s         /home/pod-website-builder.sw7ft.com/pod-website-builder/website-analyzer/venv/lib/python3.12/site-packages/css_parser/css/marginrule.pyr   zMarginRule.__init__K   sa     	j$(J:J 	) 	L +/.$- DKDJ " -=DJ!    c                     | j                  |      }|t        j                  vrF| j                  j	                  d| j
                  d|t        j                  j                         y|| _	        || _
        y)z2Check if new keyword fits the rule it is used for.z!Invalid margin @keyword for this z rule: errorN)
_normalizer   margins_logr%   r   xmldomInvalidModificationErrr   r   )r   r   ns      r!   
_setMarginzMarginRule._setMarginb   s_    OOF#J&&&IIOO![[&2"%''"@"@  B
  DO"DMr"   c                     | j                   S N)r   r   s    r!   <lambda>zMarginRule.<lambda>o   s
    4?? r"   zfMargin area of parent CSSPageRule. `margin` and `atkeyword` are both normalized @keyword of the @rule.)docc                 ~    d| j                   j                  d| j                  d| j                  j                  dS )Nzcss_parser.css.z(margin=z, style=))r    __name__r   r   cssTextr0   s    r!   __repr__zMarginRule.__repr__v   s-    ''djj6H6HJ 	Jr"   c                     d| j                   j                  | j                  | j                  j                  t        |       fz  S )Nz5<css_parser.css.%s object margin=%r style=%r at 0x%x>)r    r5   r   r   r6   idr0   s    r!   __str__zMarginRule.__str__z   s>    !^^44![[!ZZ//X'' 	'r"   c                 @    t         j                  j                  |       S )z#Return serialized property cssText.)
css_parserserdo_MarginRuler0   s    r!   _getCssTextzMarginRule._getCssText   s    ~~++D11r"   c                     t         t           |       t        dd dd      }t	        t        d fdd      t        j                  d	d
      t	        t        t        j                  d      |      d       t        j                  ddd            }t               j                  |d|      \  }}}}|r j                  |       d|v r|d   j                   _        nB j                  j                  d j                  z  t         j"                  j$                         t'                _        d|v r|d    j(                  _        yyy)ad  
        :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.
        styletokensc                     |dk7  S )N} )tvs     r!   r1   z(MarginRule._setCssText.<locals>.<lambda>   s
    a3h r"   T)namematchtoStore
storeTokenz@ marginc                 T    | dk(  xr! j                  |      t        j                  v S )N	ATKEYWORD)r&   r   r'   )rE   rF   r   s     r!   r1   z(MarginRule._setCssText.<locals>.<lambda>   s-    ;. G"ooa0J4F4FF r"   r   )rG   rH   rI   OPEN{@)rI   c                       y)N)r   NrD   rD   r"   r!   r1   z(MarginRule._setCssText.<locals>.<lambda>   s    r"   )minmaxCLOSErC   )stopAndKeepr   z#No margin @keyword for this %s ruler$   r   N)r   r   _setCssTextr
   r   r   charr   unknownruler   parse_setSeqvaluer   r(   r%   r)   r*   r+   r	   r   r6   )	r   r6   rA   prodsokseqstoreunusedr    s	   `       r!   rT   zMarginRule._setCssText   sA    	j$+G4 !6#0&*	 :%G '/	   VS1!&););C)H)4#6):$  WctD  ",!3!3G4@49";C LL5 #Ho33		 E $!,&)gg&D&D   F
 -=DJ%%*=%9

" & r"   z*(DOM) The parsable textual representation.)fgetfsetr2   c                     | j                          t        |t              rt        ||       | _        y| |_        || _        y)zt
        :param style: A string or CSSStyleDeclaration which replaces the
            current style object.
        )r6   r   N)_checkReadonly
isinstancestring_typer	   _style_parentRule)r   r   s     r!   	_setStylezMarginRule._setStyle   s7    
 	e[)-eMDK $EDKr"   c                     | j                   S r/   )re   r0   s    r!   r1   zMarginRule.<lambda>   s
    $++ r"   z-(DOM) The declaration-block of this rule set.c                     | j                   S r/   )MARGIN_RULEr0   s    r!   r1   zMarginRule.<lambda>   s    !1!1 r"   z=The type of this rule, as defined by a CSSRule type constant.c                 ,    t        | j                        S r/   )bool	atkeywordr0   s    r!   r1   zMarginRule.<lambda>   s    tDNN'; r"   )NNNNF)r5   
__module____qualname____doc__r'   r   r-   propertyr   rm   r7   r:   r?   rT   r6   rg   r   type
wellformed__classcell__)r    s   @r!   r   r      s    #HG$ <@16".# 2J34F
 IJ'2?:B KkGIG
  -yHJE 1)*D ;<Jr"   )
__future__r   r   r   r   xml.domr)   r<    r   cssstyledeclarationr	   css_parser.prodparserr
   r   r   r   r   __all____docformat____version__sysversion_infostrrd   
basestringCSSRuler   rD   r"   r!   <module>r      sc    R R    4 L L 7." 
A!KKH= H=r"   