
    ^h8              	       >   S SK JrJrJr  S SKJr  SSKJrJrJ	r	  Sr
\" \5      S4\" \\	S   S41-  5      S4\" \\	S   S	4\	S   S
41-  5      S4\" \	S   S4\	S   S4/5      S4\" \	S   S4\	S   S4/5      S4S.r " S S\5      r " S S\5      r " S S\5      rg)    )absolute_importdivisionunicode_literals)	text_type   )scopingElementstableInsertModeElements
namespacesNFhtmlbuttonolultableoptgroupoptionT)Nr   listr   selectc                   X    \ rS rSrSrS rS rS rS rSS jr	S	 r
S
 rS rS rS rSrg)Node   zRepresents an item in the treec                 V    Xl         SU l        SU l        0 U l        / U l        / U l        g)zBCreates a Node

:arg name: The tag name associated with the node

N)nameparentvalue
attributes
childNodes_flags)selfr   s     c/home/james-whalen/.local/lib/python3.13/site-packages/bleach/_vendor/html5lib/treebuilders/base.py__init__Node.__init__   s.     	
     c           
          SR                  U R                  R                  5        VVs/ s H  u  pU< SU< S3PM     snn5      nU(       a  SU R                  < SU< S3$ SU R                  -  $ s  snnf )N z=""<><%s>)joinr   itemsr   )r   r   r   attributesStrs       r   __str__Node.__str__-   sj    "&//"7"7"9";"9 '2d 26u"="9"; <  $		=99TYY''";s   A2
c                      SU R                   -  $ )Nr(   )r   r   s    r   __repr__Node.__repr__6   s    ##r"   c                     [         e)zKInsert node as a child of the current node

:arg node: the node to insert

NotImplementedErrorr   nodes     r   appendChildNode.appendChild9   
     "!r"   Nc                     [         e)a  Insert data as text in the current node, positioned before the
start of node insertBefore or to the end of the node's text.

:arg data: the data to insert

:arg insertBefore: True if you want to insert the text before the node
    and False if you want to insert it after the node

r3   )r   datainsertBefores      r   
insertTextNode.insertTextA   
     "!r"   c                     [         e)zInsert node as a child of the current node, before refNode in the
list of child nodes. Raises ValueError if refNode is not a child of
the current node

:arg node: the node to insert

:arg refNode: the child node to insert the node before

r3   )r   r6   refNodes      r   r<   Node.insertBeforeM   r?   r"   c                     [         e)zXRemove node from the children of the current node

:arg node: the child node to remove

r3   r5   s     r   removeChildNode.removeChildY   r9   r"   c                 Z    U R                    H  nUR                  U5        M     / U l         g)zMove all the children of the current node to newParent.
This is needed so that trees that don't store text as nodes move the
text in the correct way

:arg newParent: the node to move all this node's children to

N)r   r7   )r   	newParentchilds      r   reparentChildrenNode.reparentChildrena   s'     __E!!%( %r"   c                     [         e)zzReturn a shallow copy of the current node i.e. a node with the same
name and attributes but with no parent or child nodes
r3   r/   s    r   	cloneNodeNode.cloneNoden   s
     "!r"   c                     [         e)zFReturn true if the node has children or text, false otherwise
        r3   r/   s    r   
hasContentNode.hasContentt   s
     "!r"   )r   r   r   r   r   r   N)__name__
__module____qualname____firstlineno____doc__r    r,   r0   r7   r=   r<   rD   rI   rL   rO   __static_attributes__ r"   r   r   r      s7    ((($"
"
""""r"   r   c                        \ rS rSrS rS rSrg)ActiveFormattingElementsz   c                     SnU[         :w  aO  U S S S2    HC  nU[         :X  a    O8U R                  X15      (       a  US-  nUS:X  d  M2  U R                  U5          O   [        R	                  X5        g )Nr         )Marker
nodesEqualremover   append)r   r6   
equalCountelements       r   rc   ActiveFormattingElements.append{   sg    
6>":f$??711!OJ?KK( & 	Dr"   c                 p    UR                   UR                   :X  d  gUR                  UR                  :X  d  gg)NFT)	nameTupler   )r   node1node2s      r   ra   #ActiveFormattingElements.nodesEqual   s/    %//15#3#33r"   rX   N)rR   rS   rT   rU   rc   ra   rW   rX   r"   r   rZ   rZ   z   s     r"   rZ   c                       \ rS rSrSrSrSrSrSrSr	S r
S rSS jrS rS rS	 rS
 rS rSS jrS rS rS r\" \\5      rS rS rSS jrS rSS jrS rS rS rSr g)TreeBuilder   zBase treebuilder implementation

* documentClass - the class to use for the bottommost node of a document
* elementClass - the class to use for HTML Elements
* commentClass - the class to use for comments
* doctypeClass - the class to use for doctypes

Nc                 P    U(       a  SU l         OSU l         U R                  5         g)z]Create a TreeBuilder

:arg namespaceHTMLElements: whether or not to namespace HTML elements

zhttp://www.w3.org/1999/xhtmlN)defaultNamespacereset)r   namespaceHTMLElementss     r   r    TreeBuilder.__init__   s      !$BD!$(D!

r"   c                     / U l         [        5       U l        S U l        S U l        SU l        U R                  5       U l        g )NF)openElementsrZ   activeFormattingElementsheadPointerformPointerinsertFromTabledocumentClassdocumentr/   s    r   rq   TreeBuilder.reset   s?    (@(B%  $**,r"   c                 f   [        US5      nU(       d7  [        U[        5      (       a  [        S   U4n[        U[        5      (       d   e[
        U   u  pE[        U R                  5       HB  nU(       a  Xa:X  a    gU(       d  UR                  U:X  a    gXVR                  U;   -  (       d  MB    g    e)Nrh   r   TF)	hasattr
isinstancer   r
   tuplelistElementsMapreversedru   rh   )r   targetvariant	exactNodelistElementsinvertr6   s          r   elementInScopeTreeBuilder.elementInScope   s     FK0	&),,$V,f5fe,,,,.w7T../DT^4>>V#;NNl:;; 0 	ur"   c                 B   U R                   (       d  g [        U R                   5      S-
  nU R                   U   nU[        :X  d  X R                  ;   a  g U[        :w  aG  X R                  ;  a8  US:X  a  SnO/US-  nU R                   U   nU[        :w  a  X R                  ;  a  M8   US-  nU R                   U   nUR	                  5       nU R                  SUR                  UR                  UR                  S.5      nX@R                   U'   X@R                   S   :X  a  g M{  )Nr^   r   r]   StartTag)typer   	namespacer;   )	rv   lenr`   ru   rL   insertElementr   r   r   )r   ientryclonere   s        r   #reconstructActiveFormattingElements/TreeBuilder.reconstructActiveFormattingElements   s%    ,, --.2--a0F?e'8'88 vo%/@/@"@AvFA11!4E vo%/@/@"@ FA 11!4EOO%E ((*27**7<272B2B*D EG 07))!, 77;;' r"   c                     U R                   R                  5       nU R                   (       aD  U[        :w  a9  U R                   R                  5       nU R                   (       a  U[        :w  a  M7  g g g g rQ   )rv   popr`   )r   r   s     r   clearActiveFormattingElements)TreeBuilder.clearActiveFormattingElements  sR    --113++11557E ++++r"   c                 v    U R                   SSS2    H#  nU[        :X  a    gUR                  U:X  d  M!  Us  $    g)zCheck if an element exists between the end of the active
formatting elements and the last marker. If it does, return it, else
return falseNr]   F)rv   r`   r   )r   r   items      r   !elementInActiveFormattingElements-TreeBuilder.elementInActiveFormattingElements  sF    
 11$B$7D v~  d" 8 r"   c                     U R                  U5      nU R                  R                  U5        U R                  R	                  U5        g rQ   )createElementru   rc   r{   r7   )r   tokenre   s      r   
insertRootTreeBuilder.insertRoot  s8    $$U+  )!!'*r"   c                 |    US   nUS   nUS   nU R                  X#U5      nU R                  R                  U5        g )Nr   publicIdsystemId)doctypeClassr{   r7   )r   r   r   r   r   doctypes         r   insertDoctypeTreeBuilder.insertDoctype   sC    V}$$##DH=!!'*r"   c                 n    Uc  U R                   S   nUR                  U R                  US   5      5        g )Nr]   r;   )ru   r7   commentClass)r   r   r   s      r   insertCommentTreeBuilder.insertComment(  s4    >&&r*F4,,U6];<r"   c                 ~    US   nUR                  SU R                  5      nU R                  X#5      nUS   Ul        U$ )z.Create an element but don't insert it anywherer   r   r;   )getrp   elementClassr   r   r   r   r   re   s        r   r   TreeBuilder.createElement-  sB    V}IIk4+@+@A	##D4"6]r"   c                     U R                   $ rQ   )_insertFromTabler/   s    r   _getInsertFromTableTreeBuilder._getInsertFromTable5  s    $$$r"   c                 d    Xl         U(       a  U R                  U l        gU R                  U l        g)zkSwitch the function used to insert an element from the
normal one to the misnested table one and back againN)r   insertElementTabler   insertElementNormal)r   r   s     r   _setInsertFromTableTreeBuilder._setInsertFromTable8  s)     !&!%!8!8D!%!9!9Dr"   c                 .   US   n[        U[        5      (       d
   SU-  5       eUR                  SU R                  5      nU R	                  X#5      nUS   Ul        U R                  S   R                  U5        U R                  R                  U5        U$ )Nr   zElement %s not unicoder   r;   r]   )	r   r   r   rp   r   r   ru   r7   rc   r   s        r   r   TreeBuilder.insertElementNormalC  s    V}$	**K,Dt,KK*IIk4+@+@A	##D4"6]"))'2  )r"   c                 2   U R                  U5      nU R                  S   R                  [        ;  a  U R	                  U5      $ U R                  5       u  p4Uc  UR                  U5        OUR                  X$5        U R                  R                  U5        U$ )z-Create an element and insert it into the treer]   )	r   ru   r   r	   r   getTableMisnestedNodePositionr7   r<   rc   )r   r   re   r   r<   s        r   r   TreeBuilder.insertElementTableM  s    $$U+R %%-DD++E22 $(#E#E#G F#""7+##G:$$W-r"   c                    Uc  U R                   S   nU R                  (       a2  U R                  (       a3  U R                   S   R                  [        ;  a  UR	                  U5        gU R                  5       u  p#UR	                  X5        g)zInsert text data.Nr]   )ru   ry   r   r	   r=   r   )r   r;   r   r<   s       r   r=   TreeBuilder.insertText]  st    >&&r*F$$)=)=)-):):2)>)C)C0G*Hd# $(#E#E#G Fd1r"   c                 <   SnSnSnU R                   SSS2    H  nUR                  S:X  d  M  Un  O   U(       aQ  UR                  (       a  UR                  nUnX#4$ U R                   U R                   R                  U5      S-
     n X#4$ U R                   S   nX#4$ )zkGet the foster parent element, and sibling to insert before
(or None) when inserting a misnested table nodeNr]   r   r^   r   )ru   r   r   index)r   	lastTablefosterParentr<   elms        r   r   )TreeBuilder.getTableMisnestedNodePositionl  s     	$$TrT*Cxx7"	 +  (//( ))	  $00%%++I6: < ))  ,,Q/L))r"   c                     U R                   S   R                  nU[        S5      ;   a2  X!:w  a,  U R                   R                  5         U R	                  U5        g g g )Nr]   )dddtlir   r   prprt)ru   r   	frozensetr   generateImpliedEndTags)r   excluder   s      r   r   "TreeBuilder.generateImpliedEndTags  sX      $))IWXX!!# ''0	   Yr"   c                     U R                   $ )zReturn the final tree)r{   r/   s    r   getDocumentTreeBuilder.getDocument  s    }}r"   c                 b    U R                  5       nU R                  S   R                  U5        U$ )zReturn the final fragmentr   )fragmentClassru   rI   )r   fragments     r   getFragmentTreeBuilder.getFragment  s0     %%'!--h7r"   c                     [         e)zySerialize the subtree of node in the format required by unit tests

:arg node: the node from which to start serializing

r3   r5   s     r   testSerializerTreeBuilder.testSerializer  r9   r"   )	r   rv   rp   r{   rx   rw   r   ry   ru   rQ   )!rR   rS   rT   rU   rV   rz   r   r   r   r   r    rq   r   r   r   r   r   r   r   r   r   r   propertyry   r   r   r=   r   r   r   r   r   rW   rX   r"   r   rm   rm      s     M L L L M

-,,\8
+
+=
%: 24GHO 2*41"r"   rm   )
__future__r   r   r   bleach.six_shimr   	constantsr   r	   r
   r`   r   r   objectr   r   rZ   rm   rX   r"   r   <module>r      s   B B % L L
 
 _%u
-Z-?,J+KKLeT:f+=t*D+5f+=t*D*F F GHMO*V,f5$V,g68 9:?A:f-z:%f-x8: ;<@B	`"6 `"Ft 0O"& O"r"   