§
    qŠtjf+  ã                  ó¢   — d Z ddlmZ ddlmZmZ ddlZddlmZm	Z	m
Z
mZ ddlmZ  G d„ d	e	¦  «        Z e
d
d¬¦  «        Z G d„ d¦  «        ZdS )zyA tree representation of a linear markdown-it token stream.

This module is not part of upstream JavaScript markdown-it.
é    )Úannotations)Ú	GeneratorÚSequenceN)ÚAnyÚ
NamedTupleÚTypeVarÚoverloadé   )ÚTokenc                  ó$   — e Zd ZU ded<   ded<   dS )Ú_NesterTokensr   ÚopeningÚclosingN)Ú__name__Ú
__module__Ú__qualname__Ú__annotations__© ó    úN/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/markdown_it/tree.pyr   r      s"   € € € € € € Ø€N€N�NØ€N€N�N€N€Nr   r   Ú	_NodeTypeÚSyntaxTreeNode)Úboundc                  ó   — e Zd ZdZ	 dIddœdJd„ZdKd„ZedLd„¦   «         ZedMd„¦   «         ZdNd„ZdOd„Ze	dPd„¦   «         Z
e
j        dQd„¦   «         Z
e	dRd„¦   «         Zej        dSd „¦   «         Ze	dTd!„¦   «         Ze	dTd"„¦   «         Ze	dUd$„¦   «         Ze	dKd%„¦   «         Ze	dRd&„¦   «         Ze	dRd'„¦   «         ZdVd(„ZdVd)„Zd*d+d,d-œdWd1„Zdd2œdXd5„ZdYd7„Ze	dKd8„¦   «         Ze	dZd:„¦   «         Zd[d=„Ze	d\d?„¦   «         Ze	d]d@„¦   «         Ze	dKdA„¦   «         Ze	dKdB„¦   «         Ze	dKdC„¦   «         Ze	d^dE„¦   «         Z e	dTdF„¦   «         Z!e	dTdG„¦   «         Z"dHS )_r   ae  A Markdown syntax tree node.

    A class that can be used to construct a tree representation of a linear
    `markdown-it-py` token stream.

    Each node in the tree represents either:
      - root of the Markdown document
      - a single unnested `Token`
      - a `Token` "_open" and "_close" token pair, and the tokens nested in
          between
    r   T©Úcreate_rootÚtokensúSequence[Token]r   ÚboolÚreturnÚNonec               óÈ  — d| _         d| _        d| _        g | _        |r|                      |¦  «         dS |st          d¦  «        ‚t          |¦  «        dk    rJ|d         }|j        rt          d¦  «        ‚|| _         |j        r|                      |j        ¦  «         dS dS t          |d         |d         ¦  «        | _        |                      |dd…         ¦  «         dS )zƒInitialize a `SyntaxTreeNode` from a token stream.

        If `create_root` is True, create a root node for the document.
        NzGCan only create root from empty token sequence. Set `create_root=True`.r
   r   z;Unequal nesting level at the start and end of token stream.éÿÿÿÿ)
ÚtokenÚnester_tokensÚ_parentÚ	_childrenÚ_set_children_from_tokensÚ
ValueErrorÚlenÚnestingÚchildrenr   )Úselfr   r   Úinline_tokens       r   Ú__init__zSyntaxTreeNode.__init__$   s  € ð $(ˆŒ
ð 48ˆÔð !ˆŒð %'ˆŒàð 	Ø×*Ò*¨6Ñ2Ô2Ð2ØˆFàð 	9Ýð+ñô ð õ �‰[Œ[˜AÒÐØ! !œ9ˆLØÔ#ð Ý ØQñô ð ð &ˆDŒJØÔ$ð FØ×.Ò.¨|Ô/DÑEÔEÐEÐEÐEðFð Fõ "/¨v°a¬y¸&À¼*Ñ!EÔ!EˆDÔØ×*Ò*¨6°!°B°$¬<Ñ8Ô8Ð8Ð8Ð8r   Ústrc                ó@   — t          | ¦  «        j        › d| j         › d�S )Nú(ú))Útyper   ©r-   s    r   Ú__repr__zSyntaxTreeNode.__repr__N   s$   € Ý�t‘*”*Ô%Ð4Ð4¨¬	Ð4Ð4Ð4Ð4r   r-   r   ÚitemÚintc                ó   — d S ©Nr   ©r-   r7   s     r   Ú__getitem__zSyntaxTreeNode.__getitem__Q   s   € Ø>A¸cr   Úsliceúlist[_NodeType]c                ó   — d S r:   r   r;   s     r   r<   zSyntaxTreeNode.__getitem__T   s   € ØFIÀcr   úint | sliceú_NodeType | list[_NodeType]c                ó   — | j         |         S r:   )r,   r;   s     r   r<   zSyntaxTreeNode.__getitem__W   s   € ØŒ}˜TÔ"Ð"r   úlist[Token]c                ó0   ‡— dˆfd„Šg } ‰| |¦  «         |S )	z Recover the linear token stream.Únoder   Ú
token_listrC   r    r!   c                óN  •— | j         dk    r| j        D ]} ‰||¦  «         Œd S | j        r|                     | j        ¦  «         d S | j        sJ ‚|                     | j        j        ¦  «         | j        D ]} ‰||¦  «         Œ|                     | j        j        ¦  «         d S )NÚroot)r4   r,   r$   Úappendr%   r   r   )rE   rF   ÚchildÚrecursive_collect_tokenss      €r   rK   z:SyntaxTreeNode.to_tokens.<locals>.recursive_collect_tokens]   sÝ   ø€ ØŒy˜FÒ"Ð"Ø!œ]ð @ð @�EØ,Ð,¨U°JÑ?Ô?Ð?Ð?ð@ð @à”ð >Ø×!Ò! $¤*Ñ-Ô-Ð-Ð-Ð-àÔ)Ð)Ð)Ð)Ø×!Ò! $Ô"4Ô"<Ñ=Ô=Ð=Ø!œ]ð @ð @�EØ,Ð,¨U°JÑ?Ô?Ð?Ð?Ø×!Ò! $Ô"4Ô"<Ñ=Ô=Ð=Ð=Ð=r   )rE   r   rF   rC   r    r!   r   )r-   r   rK   s     @r   Ú	to_tokenszSyntaxTreeNode.to_tokensZ   s@   ø€ ð	>ð 	>ð 	>ð 	>ð 	>ð 	>ð !ˆØ Ð   vÑ.Ô.Ð.Øˆr   c                ó   — | j         S r:   ©r'   r5   s    r   r,   zSyntaxTreeNode.childrenn   s
   € àŒ~Ðr   Úvaluec                ó   — || _         d S r:   rN   ©r-   rO   s     r   r,   zSyntaxTreeNode.childrenr   s   € àˆŒˆˆr   ú_NodeType | Nonec                ó   — | j         S r:   ©r&   r5   s    r   ÚparentzSyntaxTreeNode.parentv   s
   € àŒ|Ðr   c                ó   — || _         d S r:   rT   rQ   s     r   rU   zSyntaxTreeNode.parentz   s   € àˆŒˆˆr   c                ó    — | j         p| j         S )z Is the node a special root node?)r$   r%   r5   s    r   Úis_rootzSyntaxTreeNode.is_root~   s   € ð ”JÐ4 $Ô"4Ð5Ð5r   c                ó*   — t          | j        ¦  «        S )zùIs this node nested?.

        Returns `True` if the node represents a `Token` pair and tokens in the
        sequence between them, where `Token.nesting` of the first `Token` in
        the pair is 1 and nesting of the other `Token` is -1.
        )r   r%   r5   s    r   Ú	is_nestedzSyntaxTreeNode.is_nestedƒ   s   € õ �DÔ&Ñ'Ô'Ð'r   úSequence[_NodeType]c                ó.   — | j         s| gS | j         j        S )z]Get siblings of the node.

        Gets the whole group of siblings, including self.
        )rU   r,   r5   s    r   ÚsiblingszSyntaxTreeNode.siblings�   s    € ð Œ{ð 	Ø�6ˆMØŒ{Ô#Ð#r   c                ó”   — | j         rdS | j        r| j        j        S | j        sJ ‚| j        j        j                             d¦  «        S )a  Get a string type of the represented syntax.

        - "root" for root nodes
        - `Token.type` if the node represents an unnested token
        - `Token.type` of the opening token, with "_open" suffix stripped, if
            the node represents a nester token pair
        rH   Ú_open)rX   r$   r4   r%   r   Úremovesuffixr5   s    r   r4   zSyntaxTreeNode.type—   sS   € ð Œ<ð 	Ø�6ØŒ:ð 	#Ø”:”?Ð"ØÔ!Ð!Ð!Ð!ØÔ!Ô)Ô.×;Ò;¸GÑDÔDÐDr   c                ó�   — | j                              | ¦  «        }|dz   t          | j         ¦  «        k     r| j         |dz            S dS )zlGet the next node in the sequence of siblings.

        Returns `None` if this is the last sibling.
        r
   N)r]   Úindexr*   ©r-   Ú
self_indexs     r   Únext_siblingzSyntaxTreeNode.next_sibling§   sH   € ð ”]×(Ò(¨Ñ.Ô.ˆ
Ø˜‰>�C ¤Ñ.Ô.Ò.Ð.Ø”= ¨a¡Ô0Ð0Øˆtr   c                ól   — | j                              | ¦  «        }|dz
  dk    r| j         |dz
           S dS )zqGet the previous node in the sequence of siblings.

        Returns `None` if this is the first sibling.
        r
   r   N)r]   rb   rc   s     r   Úprevious_siblingzSyntaxTreeNode.previous_sibling²   s>   € ð ”]×(Ò(¨Ñ.Ô.ˆ
Ø˜‰>˜QÒÐØ”= ¨a¡Ô0Ð0Øˆtr   c                ó|   —  t          | ¦  «        |d¬¦  «        }| |_        | j                             |¦  «         dS )zMake a child node for `self`.Fr   N)r4   rU   r,   rI   )r-   r   rJ   s      r   Ú
_add_childzSyntaxTreeNode._add_child½   sA   € ð
 •�T‘
”
˜6¨uÐ5Ñ5Ô5ˆØˆŒØŒ×Ò˜UÑ#Ô#Ð#Ð#Ð#r   c                óÀ  — t          t          |¦  «        ¦  «        }|r¿|                     ¦   «         }|j        s|                      |g¦  «         Œ4|j        dk    rt          d¦  «        ‚|g}d}|r9|r7|                     ¦   «         }|                     |¦  «         ||j        z  }|r|°7|rt          d|d         › �¦  «        ‚|                      |¦  «         |°½dS dS )zgConvert the token stream to a tree structure and set the resulting
        nodes as children of `self`.r
   zInvalid token nestingzunclosed tokens starting r   N)ÚlistÚreversedÚpopr+   ri   r)   rI   )r-   r   Úreversed_tokensr$   Únested_tokensr+   s         r   r(   z(SyntaxTreeNode._set_children_from_tokensÆ   s#  € õ �x¨Ñ/Ô/Ñ0Ô0ˆØð 	+Ø#×'Ò'Ñ)Ô)ˆEà”=ð Ø—’  Ñ(Ô(Ð(ØØŒ} Ò!Ð!Ý Ð!8Ñ9Ô9Ð9à"˜GˆMØˆGØ!ð ) gð )Ø'×+Ò+Ñ-Ô-�Ø×$Ò$ UÑ+Ô+Ð+Ø˜5œ=Ñ(�ð "ð ) gð )ð ð QÝ Ð!O¸]È1Ô=MÐ!OÐ!OÑPÔPÐPà�OŠO˜MÑ*Ô*Ð*ð% ð 	+ð 	+ð 	+ð 	+ð 	+r   é   Fr   ©ÚindentÚ	show_textÚ_currentrr   rs   rt   c          	     óœ  — d|z  }|d| j         › �z   }| j        sC| j        r<|dd                     d„ | j                             ¦   «         D ¦   «         ¦  «        z   z  }|dz  }|r=| j        s6| j         dv r-| j        r&|dt          j        | j        |d|z  z   ¦  «        z   z  }| j        D ]#}|d| 	                    ||||z   ¬¦  «        z   z  }Œ$|S )z'Create an XML style string of the tree.ú ú<c              3  ó*   K  — | ]\  }}|› d |›�V — ŒdS )ú=Nr   )Ú.0ÚkÚvs      r   ú	<genexpr>z(SyntaxTreeNode.pretty.<locals>.<genexpr>å   s0   è è € Ð"OÐ"O±D°A°q a < <¨! < <Ð"OÐ"OÐ"OÐ"OÐ"OÐ"Or   ú>)ÚtextÚtext_specialú
rq   )
r4   rX   ÚattrsÚjoinÚitemsÚcontentÚtextwraprr   r,   Úpretty)r-   rr   rs   rt   Úprefixr   rJ   s          r   r‡   zSyntaxTreeNode.prettyÞ   s  € ð �x‘ˆØ˜˜DœI˜˜Ñ'ˆØŒ|ð 	P ¤
ð 	PØ�C˜#Ÿ(š(Ð"OÐ"O¸D¼J×<LÒ<LÑ<NÔ<NÐ"OÑ"OÔ"OÑOÔOÑOÑOˆDØ�‰ˆàð	Pà”Lð	Pð ”	Ð5Ð5Ð5Ø”ð 6ð �D�8œ?¨4¬<¸À#ÈÁ,Ñ9NÑOÔOÑOÑOˆDØ”]ð 	ð 	ˆEØ�D˜5Ÿ<š<Ø¨¸XÈÑ=Nð (ñ ô ñ ñ ˆDˆDð ˆr   ©Úinclude_selfrŠ   ú Generator[_NodeType, None, None]c             #  ób   K  — |r| V — | j         D ]}|                     d¬¦  «        E d{V —† ŒdS )z³Recursively yield all descendant nodes in the tree starting at self.

        The order mimics the order of the underlying linear token
        stream (i.e. depth first).
        Tr‰   N)r,   Úwalk)r-   rŠ   rJ   s      r   r�   zSyntaxTreeNode.walkô   s]   è è € ð ð 	ØˆJˆJˆJØ”]ð 	5ð 	5ˆEØ—z’z¨t�zÑ4Ô4Ð4Ð4Ð4Ð4Ð4Ð4Ð4Ð4ð	5ð 	5r   r   c                ób   — | j         r| j         S | j        r| j        j        S t          d¦  «        ‚)z\Return the `Token` that is used as the data source for the
        properties defined below.z.Root node does not have the accessed attribute)r$   r%   r   ÚAttributeErrorr5   s    r   Ú_attribute_tokenzSyntaxTreeNode._attribute_token
  s<   € ð Œ:ð 	Ø”:ÐØÔð 	.ØÔ%Ô-Ð-ÝÐMÑNÔNÐNr   c                ó4   — |                       ¦   «         j        S )zhtml tag name, e.g. "p")r�   Útagr5   s    r   r’   zSyntaxTreeNode.tag  s   € ð ×$Ò$Ñ&Ô&Ô*Ð*r   údict[str, str | int | float]c                ó4   — |                       ¦   «         j        S )zHtml attributes.)r�   r‚   r5   s    r   r‚   zSyntaxTreeNode.attrs  ó   € ð ×$Ò$Ñ&Ô&Ô,Ð,r   ÚnameúNone | str | int | floatc                óP   — |                       ¦   «                              |¦  «        S )z@Get the value of attribute `name`, or null if it does not exist.)r�   ÚattrGet)r-   r–   s     r   r™   zSyntaxTreeNode.attrGet  s"   € à×$Ò$Ñ&Ô&×.Ò.¨tÑ4Ô4Ð4r   útuple[int, int] | Nonec                óZ   — |                       ¦   «         j        }|rt          |¦  «        S dS )z8Source map info. Format: `tuple[ line_begin, line_end ]`N)r�   ÚmapÚtuple)r-   Úmap_s     r   rœ   zSyntaxTreeNode.map!  s1   € ð ×$Ò$Ñ&Ô&Ô*ˆØð 	å˜‘;”;ÐØˆtr   c                ó4   — |                       ¦   «         j        S )z(nesting level, the same as `state.level`)r�   Úlevelr5   s    r   r    zSyntaxTreeNode.level*  r•   r   c                ó4   — |                       ¦   «         j        S )z]In a case of self-closing tag (code, html, fence, etc.), it
        has contents of this tag.)r�   r…   r5   s    r   r…   zSyntaxTreeNode.content/  s   € ð ×$Ò$Ñ&Ô&Ô.Ð.r   c                ó4   — |                       ¦   «         j        S )z5'*' or '_' for emphasis, fence string for fence, etc.)r�   Úmarkupr5   s    r   r£   zSyntaxTreeNode.markup5  s   € ð ×$Ò$Ñ&Ô&Ô-Ð-r   c                ó4   — |                       ¦   «         j        S )zfence infostring)r�   Úinfor5   s    r   r¥   zSyntaxTreeNode.info:  ó   € ð ×$Ò$Ñ&Ô&Ô+Ð+r   údict[Any, Any]c                ó4   — |                       ¦   «         j        S )z/A place for plugins to store an arbitrary data.)r�   Úmetar5   s    r   r©   zSyntaxTreeNode.meta?  r¦   r   c                ó4   — |                       ¦   «         j        S )z5True for block-level tokens, false for inline tokens.)r�   Úblockr5   s    r   r«   zSyntaxTreeNode.blockD  r•   r   c                ó4   — |                       ¦   «         j        S )zbIf it's true, ignore this element when rendering.
        Used for tight lists to hide paragraphs.)r�   Úhiddenr5   s    r   r­   zSyntaxTreeNode.hiddenI  s   € ð ×$Ò$Ñ&Ô&Ô-Ð-r   N)r   )r   r   r   r   r    r!   )r    r0   )r-   r   r7   r8   r    r   )r-   r   r7   r=   r    r>   )r-   r   r7   r@   r    rA   )r-   r   r    rC   )r-   r   r    r>   )r-   r   rO   r>   r    r!   )r-   r   r    rR   )r-   r   rO   rR   r    r!   )r    r   )r-   r   r    r[   )r   r   r    r!   )rr   r8   rs   r   rt   r8   r    r0   )r-   r   rŠ   r   r    r‹   )r    r   )r    r“   )r–   r0   r    r—   )r    rš   )r    r8   )r    r§   )#r   r   r   Ú__doc__r/   r6   r	   r<   rL   Úpropertyr,   ÚsetterrU   rX   rZ   r]   r4   re   rg   ri   r(   r‡   r�   r�   r’   r‚   r™   rœ   r    r…   r£   r¥   r©   r«   r­   r   r   r   r   r      sÚ  € € € € € ð
ð 
ð )+ð(9ØCGð(9ð (9ð (9ð (9ð (9ð (9ðT5ð 5ð 5ð 5ð ØAÐAÐAñ „XØAàØIÐIÐIñ „XØIð#ð #ð #ð #ðð ð ð ð( ðð ð ñ „Xðð „_ðð ð ñ „_ðð ðð ð ñ „Xðð „]ðð ð ñ „]ðð ð6ð 6ð 6ñ „Xð6ð ð(ð (ð (ñ „Xð(ð ð$ð $ð $ñ „Xð$ð ðEð Eð Eñ „XðEð ðð ð ñ „Xðð ðð ð ñ „Xðð$ð $ð $ð $ð+ð +ð +ð +ð2  !°EÈ1ðð ð ð ð ð ð. 26ð5ð 5ð 5ð 5ð 5ð 5ð,Oð Oð Oð Oð ð+ð +ð +ñ „Xð+ð ð-ð -ð -ñ „Xð-ð5ð 5ð 5ð 5ð ðð ð ñ „Xðð ð-ð -ð -ñ „Xð-ð ð/ð /ð /ñ „Xð/ð
 ð.ð .ð .ñ „Xð.ð ð,ð ,ð ,ñ „Xð,ð ð,ð ,ð ,ñ „Xð,ð ð-ð -ð -ñ „Xð-ð ð.ð .ð .ñ „Xð.ð .ð .r   )r®   Ú
__future__r   Úcollections.abcr   r   r†   Útypingr   r   r   r	   r$   r   r   r   r   r   r   r   ú<module>r´      s÷   ððð ð
 #Ð "Ð "Ð "Ð "Ð "à /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ø €€€Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5à Ð Ð Ð Ð Ð ðð ð ð ð �Jñ ô ð ð
 ˆG�KÐ'7Ð8Ñ8Ô8€	ðv.ð v.ð v.ð v.ð v.ñ v.ô v.ð v.ð v.ð v.r   