
    Bh?                        S SK Jr  S/r1 SkrS/S jrS0S jrS rS rS	 rS
 r	S r
S0S jr " S S\5      r " S S5      r " S S5      r " S S5      r " S S5      r " S S5      r " S S5      r " S S5      r " S S5      r " S S 5      r " S! S"5      r " S# S$5      r " S% S&5      r " S' S(5      r " S) S*5      r " S+ S,5      r " S- S.5      rg)1    )parse_component_value_listparse>   afterbeforemarkerprefixshadowcontentpostfix	selectionplaceholder
first-linetarget-textfirst-letterfootnote-callgrammar-errorspelling-errorfootnote-markerfile-selector-buttonNc              #     #    [        U [        5      (       a  [        U 5      n [        U 5      nU=(       d    0 n [	        XAU5      v    UR                  5       nUc  gUS:X  a   [	        XAU5      v   O!U(       d  [        USUR                   S35      eMM  ! [
         a  nU(       a   SnAgUeSnAff = f! [
         a  nU(       d  Ue SnAN:SnAff = f7f)z~Yield tinycss2 selectors found in given ``input``.

:param input:
    A string, or an iterable of tinycss2 component values.

N,unexpected  token.)
isinstancestrr   TokenStreamparse_selectorSelectorErrornexttype)input
namespaces	forgivingrelativetokens	exceptionr   s          C/var/www/html/env/lib/python3.13/site-packages/cssselect2/parser.pyr   r      s      %*51F!rJV::
 {{}<S[$$VBB
 #DK		{'*JKK 	   ! $ #O !$s^   7CB C$B6 2$C
B3 B.'C,B..B33C6
C 	C	CCCc                    U R                  5         U(       aE  U R                  5       nUS;   a  UR                  nU R                  5         OSnU R                  5         [	        X5      u  pV U R                  5       nU R                  5       (       a0  U R                  5       =(       d    UnU R                  5       (       a  M0  [        XV5      nU(       a  [        WU5      nUb  U$ U R                  5       nUb  US:X  a  U$ US;   a  UR                  n	U R                  5         OU(       a  Sn	OU$ [	        X5      u  p[        XYU
5      nM  )N)>+~ r   )
skip_whitespace_and_commentpeekvaluer   parse_compound_selectorskip_whitespaceskip_commentSelectorRelativeSelectorCombinedSelector)r%   r"   r$   r.   initial_combinatorresultpseudo_elementhas_whitespaceselector
combinatorcompounds              r'   r   r   1   s   
&&({{}?"!%KKM!$**,4VHF
//1!!###335GN !!##F3'(:HEH%O{{}<43;O_$JKKMJO#:6#N !&h?)     c                    [        X5      nUb  UO/ n [        X5      u  pEUc  Uc  OUR                  U5        M'  U(       d  X%4S:w  a  [        U5      U4$ U R	                  5       nU(       a  UR
                  OSn[        USU 35      e)NNNEOFz"expected a compound selector, got )parse_type_selectorparse_simple_selectorappendCompoundSelectorr.   r    r   )r%   r"   type_selectorssimple_selectorssimple_selectorr8   r.   	peek_types           r'   r0   r0   S   s    (<N)7)C~
*?+ '%)@0  N;|K 01>AA;;=D!		uI
 B9+N
OOr=   c                     U R                  5         [        X5      nUc  g / nUu  pEUb  UR                  [        U5      5        Ub  UR                  [	        U5      5        U$ N)r1   parse_qualified_namerC   LocalNameSelectorNamespaceSelector)r%   r"   qualified_namerF   	namespace
local_names         r'   rA   rA   e   si    
)&=N*I 1* => 1) <=r=   c                 0   U R                  5       nUc  gUR                  S:X  a8  UR                  (       a'  U R                  5         [	        UR
                  5      S 4$ US:X  aY  U R                  5         U R                  5       nUb  UR                  S:w  a  [        USU 35      e[        UR
                  5      S 4$ UR                  S:X  a3  U R                  5         [        [        UR                  5      U5      nUS 4$ US:X  Ga  U R                  5         U R                  5       nUS:X  a[  U R                  5       nUb  UR                  S:w  a  [        USU 35      eUR                  nU[        ;  a  [        US	U 35      eS U4$ Ub3  UR                  S:X  a#  UR                  nUS
;   a  S U4$ [        U5      S 4$ UbG  UR                  S:X  a7  UR                  nUS;   a  [        X1U5      S 4$ [!        XcR"                  5      S 4$ [        USU S35      eg)Nr?   hash.identzExpected a class name, got z[] block:z$Expected a pseudo-element name, got z)Expected a supported pseudo-element, got )r   r   r   r   function)iswherenothasr   r   )r.   r    is_identifierr   
IDSelectorr/   r   ClassSelectorparse_attribute_selectorr   r
   lower_valueSUPPORTED_PSEUDO_ELEMENTSPseudoClassSelector
lower_nameparse_logical_combinationFunctionalPseudoClassSelector	arguments)r%   r"   r.   r   attrr/   names          r'   rB   rB   t   s   ;;=D|yyFt11$**%t++	{{}<499/(CD6&JKKTZZ($..	j	 'DLL(A:NTz	{{}3;;;=D|tyyG3#D,PQUPV*WXX$$E55#EeWMO O;$))w"6##DHHTz!*40$66$))z"9??D4404H$NN5dNNKTRRD6&ABBr=   c                     SnSnUS:X  a  [         nO*US:X  a  [        nOUS:X  a	  Sn[        nOUS:X  a  Sn[        n[	        U R
                  XU5       Vs/ s H  nUR                  b  M  UPM     nnW" U5      $ s  snf )NTFrW   rX   rY   rZ   )MatchesAnySelectorSpecificityAdjustmentSelectorNegationSelectorRelationalSelectorr   re   r8   )matches_any_tokenr"   rg   r#   r$   selector_classr:   	selectorss           r'   rc   rc      s    IHt|+	6		)	+ 	)):(K,K "" 	K  , )$$	,s   A:*A:c                 N   U R                  5         [        XSS9nUc  U R                  5       n[        USU 35      eUu  pEU R                  5         U R	                  5       nUc  S nS nOUS;   a|  UR
                  nU R                  5         U R                  5         U R                  5       nUb  UR                  S;  a   Uc  SOUR                  n	[        USU	 35      eUR
                  nO[        USU 35      eU R                  5         U R                  5       nS n
Ub{  UR                  S	:X  a!  UR
                  R                  5       S
:X  a  Sn
OJUR                  S	:X  a!  UR
                  R                  5       S:X  a  Sn
O[        USUR                   35      e[        XEXxU
5      $ )NT)is_attributezexpected attribute name, got )=z~=z|=z^=z$=z*=)rT   stringNonezexpected attribute value, got z*expected attribute selector operator, got rT   iFszexpected ], got )	r1   rK   r   r   r.   r/   r    lowerAttributeSelector)r%   r"   rN   r   rO   rP   r.   operatorr/   	next_typecase_sensitives              r'   r^   r^      s   
)&4PN{{}D$A$"HII*I
;;=D|	4	4:: {{}<499,??"&,DIII(Fyk&RSS

D$Ntf"UVV
;;=DN99DJJ$4$4$6#$="NYY'!djj&6&6&8C&?!N(8&DEEYH^TTr=   c                 n   U R                  5       nUc  gUR                  S:X  a  U R                  5       nU R                  5       nUS:w  a4  U(       a  SOUR                  SS5      nXTR                  UR
                  44$ U R                  5         UR                  UR                  5      nUc  [        USUR                   35      eOUS:X  am  U R                  5       nU R                  5       nUS:w  a4  U(       a  [        USUR                   35      eUR                  SS5      S4$ U R                  5         SnOUS:X  a  U R                  5         SnOgU R                  5       nUR                  S:X  a  XVR                  UR
                  44$ US:X  a  U(       d  US4$ [        USUR                   35      e)zReturn ``(namespace, local)`` for given tokens.

Can also return ``None`` for a wildcard.

The empty string for ``namespace`` means "no namespace".

NrT   | zundefined namespace prefix: *zexpected local name, got )r.   r    r   getr/   r_   r   )r%   r"   rq   r.   first_identrO   r   s          r'   rK   rK      s    ;;=D|yyGkkm{{}3;*
tT0JI00+2I2IJJJNN;#4#45	;K<M<M;NOQ Q  
{{}{{}3;#D,Edii[*QRR>>$-t33			 ;;=DyyG::t'7'7888	\$D$=dii["IJJr=   c                       \ rS rSrSrSrg)r   i  z3A specialized ``ValueError`` for invalid selectors. N)__name__
__module____qualname____firstlineno____doc____static_attributes__r   r=   r'   r   r     s    =r=   r   c                   >    \ rS rSrS rS rS rS rS rS r	S r
S	rg
)r   i  c                 2    [        U5      U l        / U l        g rJ   )iterr%   peeked)selfr%   s     r'   __init__TokenStream.__init__  s    6lr=   c                     U R                   (       a  U R                   R                  5       $ [        U R                  S 5      $ rJ   )r   popr   r%   r   s    r'   r   TokenStream.next  s+    ;;;;??$$T**r=   c                     U R                   (       d/  U R                   R                  [        U R                  S 5      5        U R                   S   $ )N)r   rC   r   r%   r   s    r'   r.   TokenStream.peek  s4    {{KKtDKK67{{2r=   c                 |    Sn U R                  5       nUb  UR                  U;  a   U$ U R                  5         SnM:  )NFT)r.   r    r   )r   
skip_typesfoundr.   s       r'   skipTokenStream.skip!  sD    99;D|tyy
:  IIKE r=   c                 &    U R                  S/5      $ )N
whitespacer   r   s    r'   r1   TokenStream.skip_whitespace+  s    yy,((r=   c                 &    U R                  S/5      $ )Ncommentr   r   s    r'   r2   TokenStream.skip_comment.  s    yy)%%r=   c                 (    U R                  SS/5      $ )Nr   r   r   r   s    r'   r-   'TokenStream.skip_whitespace_and_comment1  s    yy)\233r=   )r   r%   N)r   r   r   r   r   r   r.   r   r1   r2   r-   r   r   r=   r'   r   r     s%    +
)&4r=   r   c                   $    \ rS rSrSS jrS rSrg)r3   i5  Nc                 |    Xl         X l        Uc  UR                  U l        g UR                  u  p4nX4US-   4U l        g )N   parsed_treer8   specificity)r   treer8   abcs         r'   r   Selector.__init__6  sA    ,!#//D&&GA! QU{Dr=   c                 h    U R                   (       a  SU R                    3OSnU R                  < U 3$ )Nz::r~   )r8   r   )r   pseudos     r'   __repr__Selector.__repr__@  s5    /3/B/B2d))*+""%fX..r=   r   rJ   )r   r   r   r   r   r   r   r   r=   r'   r3   r3   5  s    +/r=   r3   c                   @    \ rS rSrS r\S 5       r\S 5       rS rSr	g)r4   iE  c                     Xl         X l        g rJ   r;   r:   )r   r;   r:   s      r'   r   RelativeSelector.__init__F  s    $ r=   c                 .    U R                   R                  $ rJ   )r:   r   r   s    r'   r   RelativeSelector.specificityJ  s    }}(((r=   c                 .    U R                   R                  $ rJ   )r:   r8   r   s    r'   r8   RelativeSelector.pseudo_elementN  s    }}+++r=   c                 v    U R                   S:X  a  U R                  < $ U R                    SU R                  < 3$ )Nr,   r   r   s    r'   r   RelativeSelector.__repr__R  s9    $(OOs$:t}}	9OO$Admm%67	9r=   r   N)
r   r   r   r   r   propertyr   r8   r   r   r   r=   r'   r4   r4   E  s4    ! ) ) , ,9r=   r4   c                   0    \ rS rSrS r\S 5       rS rSrg)r5   iX  c                 (    Xl         X l        X0l        g rJ   leftr;   right)r   r   r;   r   s       r'   r   CombinedSelector.__init__Y  s    	$
r=   c                 |    U R                   R                  u  pnU R                  R                  u  pEnX-   X%-   X6-   4$ rJ   )r   r   r   )r   a1b1c1a2b2c2s          r'   r   CombinedSelector.specificitya  s;    YY**
ZZ++
w((r=   c                 R    U R                   < U R                   U R                  < 3$ rJ   r   r   s    r'   r   CombinedSelector.__repr__g  s"    ))t/

~>>r=   )r;   r   r   N	r   r   r   r   r   r   r   r   r   r   r=   r'   r5   r5   X  s      ) )
?r=   r5   c                   0    \ rS rSrS r\S 5       rS rSrg)rD   ik  c                     Xl         g rJ   rF   )r   rF   s     r'   r   CompoundSelector.__init__l  s     0r=   c           	          U R                   (       a0  [        [        [        [	        S U R                    5       6 5      5      $ g)Nc              3   8   #    U  H  oR                   v   M     g 7frJ   r   .0sels     r'   	<genexpr>/CompoundSelector.specificity.<locals>.<genexpr>u  s     C-Bc//-B   r   r   r   )rF   tuplemapsumzipr   s    r'   r   CompoundSelector.specificityo  sA       S#CT-B-BC#E F G G r=   c                 T    SR                  [        [        U R                  5      5      $ )Nr~   )joinr   reprrF   r   s    r'   r   CompoundSelector.__repr__y  s    wws4!6!6788r=   r   Nr   r   r=   r'   rD   rD   k  s     1  9r=   rD   c                   $    \ rS rSrSrS rS rSrg)rL   i}  )r   r   r   c                 "    Uu  U l         U l        g rJ   rP   lower_local_name)r   rP   s     r'   r   LocalNameSelector.__init__  s    1;..r=   c                     U R                   $ rJ   )rP   r   s    r'   r   LocalNameSelector.__repr__  s    r=   r   Nr   r   r   r   r   r   r   r   r   r=   r'   rL   rL   }  s    K<r=   rL   c                   $    \ rS rSrSrS rS rSrg)rM   i  r   c                     Xl         g rJ   rO   )r   rO   s     r'   r   NamespaceSelector.__init__  s	     #r=   c                 F    U R                   S:X  a  S$ SU R                    S3$ )Nr~   r}   {z}|r   r   s    r'   r   NamespaceSelector.__repr__  s&    nn*sH"T^^4DC0HHr=   r   Nr   r   r=   r'   rM   rM     s    K#
Ir=   rM   c                   $    \ rS rSrSrS rS rSrg)r\   i  )r   r   r   c                     Xl         g rJ   rT   )r   rT   s     r'   r   IDSelector.__init__  s    
r=   c                      SU R                    3$ )N#r   r   s    r'   r   IDSelector.__repr__  s    4::,r=   r   Nr   r   r=   r'   r\   r\     s    K r=   r\   c                   $    \ rS rSrSrS rS rSrg)r]   i  r   r   r   c                     Xl         g rJ   
class_name)r   r  s     r'   r   ClassSelector.__init__  s    $r=   c                      SU R                    3$ )NrS   r  r   s    r'   r   ClassSelector.__repr__  s    4??#$$r=   r  Nr   r   r=   r'   r]   r]     s    K%%r=   r]   c                   $    \ rS rSrSrS rS rSrg)rx   i  r   c                 R    Xl         Uu  U l        U l        X0l        X@l        XPl        g rJ   )rO   rg   rb   ry   r/   r{   )r   rO   rg   ry   r/   r{   s         r'   r   AttributeSelector.__init__  s'    "%)"	4? 
 -r=   c                     U R                   c  SOSU R                    S3nU R                  c  SOSU R                  (       a  SOS 3nSU U R                   U R                   U R                  < U S	3$ )
Nz*|r   }r~   r,   rv   ru   [])rO   r{   rg   ry   r/   )r   rO   r{   s      r'   r   AttributeSelector.__repr__  s{     NN2D"T^^<LB8O	%%-Bt**45 	 	{499+dmm_TZZNa!	"r=   )r{   rb   rg   rO   ry   r/   Nr   r   r=   r'   rx   rx     s    K	-"r=   rx   c                   $    \ rS rSrSrS rS rSrg)ra   i  r   c                     Xl         g rJ   rg   )r   rg   s     r'   r   PseudoClassSelector.__init__  s    	r=   c                      SU R                   -   $ NrU   r  r   s    r'   r   PseudoClassSelector.__repr__  s    TYYr=   r  Nr   r   r=   r'   ra   ra     s    Kr=   ra   c                   $    \ rS rSrSrS rS rSrg)rd   i  r   c                     Xl         X l        g rJ   )rg   re   )r   rg   re   s      r'   r   &FunctionalPseudoClassSelector.__init__  s    	"r=   c                 L    SU R                    [        U R                  5      < 3$ r  )rg   r   re   r   s    r'   r   &FunctionalPseudoClassSelector.__repr__  s!    499+eDNN3677r=   )re   rg   Nr   r   r=   r'   rd   rd     s    K#8r=   rd   c                   0    \ rS rSrS r\S 5       rS rSrg)rk   i  c                     Xl         g rJ   selector_listr   r  s     r'   r   NegationSelector.__init__      *r=   c                 ^    U R                   (       a  [        S U R                    5       5      $ g)Nc              3   8   #    U  H  oR                   v   M     g 7frJ   r   r   r:   s     r'   r   /NegationSelector.specificity.<locals>.<genexpr>       O<N++<Nr   r   r  maxr   s    r'   r   NegationSelector.specificity  %    OD<N<NOOOr=   c                 N    SSR                  S U R                   5       5       S3$ )Nz:not(, c              3   8   #    U  H  n[        U5      v   M     g 7frJ   r   r   s     r'   r   ,NegationSelector.__repr__.<locals>.<genexpr>        I6Hsc6Hr   )r   r  r   s    r'   r   NegationSelector.__repr__  '    tyy Id6H6H IIJ!LLr=   r  Nr   r   r=   r'   rk   rk     !    +  Mr=   rk   c                   0    \ rS rSrS r\S 5       rS rSrg)rl   i  c                     Xl         g rJ   r  r  s     r'   r   RelationalSelector.__init__  r   r=   c                 ^    U R                   (       a  [        S U R                    5       5      $ g)Nc              3   8   #    U  H  oR                   v   M     g 7frJ   r   r#  s     r'   r   1RelationalSelector.specificity.<locals>.<genexpr>  r%  r   r   r&  r   s    r'   r   RelationalSelector.specificity  r)  r=   c                 N    SSR                  S U R                   5       5       S3$ )Nz:has(r+  c              3   8   #    U  H  n[        U5      v   M     g 7frJ   r-  r   s     r'   r   .RelationalSelector.__repr__.<locals>.<genexpr>  r/  r   r0  r1  r   s    r'   r   RelationalSelector.__repr__  r3  r=   r  Nr   r   r=   r'   rl   rl     r4  r=   rl   c                   0    \ rS rSrS r\S 5       rS rSrg)ri   i  c                     Xl         g rJ   r  r  s     r'   r   MatchesAnySelector.__init__  r   r=   c                 ^    U R                   (       a  [        S U R                    5       5      $ g)Nc              3   8   #    U  H  oR                   v   M     g 7frJ   r   r#  s     r'   r   1MatchesAnySelector.specificity.<locals>.<genexpr>  r%  r   r   r&  r   s    r'   r   MatchesAnySelector.specificity  r)  r=   c                 N    SSR                  S U R                   5       5       S3$ )Nz:is(r+  c              3   8   #    U  H  n[        U5      v   M     g 7frJ   r-  r   s     r'   r   .MatchesAnySelector.__repr__.<locals>.<genexpr>  s     H5GcS		5Gr   r0  r1  r   s    r'   r   MatchesAnySelector.__repr__  s'    diiHT5G5GHHIKKr=   r  Nr   r   r=   r'   ri   ri     s!    +  Lr=   ri   c                   0    \ rS rSrS r\S 5       rS rSrg)rj   i  c                     Xl         g rJ   r  r  s     r'   r   &SpecificityAdjustmentSelector.__init__  r   r=   c                     g)Nr   r   r   s    r'   r   )SpecificityAdjustmentSelector.specificity  s    r=   c                 N    SSR                  S U R                   5       5       S3$ )Nz:where(r+  c              3   8   #    U  H  n[        U5      v   M     g 7frJ   r-  r   s     r'   r   9SpecificityAdjustmentSelector.__repr__.<locals>.<genexpr>
  s     "K8J4998Jr   r0  r1  r   s    r'   r   &SpecificityAdjustmentSelector.__repr__	  s'    "K8J8J"KKLANNr=   r  Nr   r   r=   r'   rj   rj     s!    +  Or=   rj   )NFF)F)tinycss2r   __all__r`   r   r   r0   rA   rB   rc   r^   rK   
ValueErrorr   r   r3   r4   r5   rD   rL   rM   r\   r]   rx   ra   rd   rk   rl   ri   rj   r   r=   r'   <module>rW     s    /)	 L@@DP$,^%*#UL,K^>J >!4 !4H/ / 9 9&? ?&9 9$ 	I 	I   % %" "0 8 8M MM ML L	O 	Or=   