Ë
    Ñwìi)?  ã                   ó@   — d dl mZ d dlmZ ddlmZmZ  G d„ d«      Zy)é    )Ú
ASSERTIONS)ÚPreOrderIteré   )Ú	LoopErrorÚ	TreeErrorc                   óÐ  — e Zd ZdZddgZdZed„ «       Zej                  d„ «       Zd„ Z	d„ Z
d	„ Zed
„ «       Zed„ «       Zed„ «       Zej                  d„ «       Zej                   d„ «       Zd„ Zd„ Zd„ Zd„ Zed„ «       Zd„ Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Z ed„ «       Z!d „ Z"d!„ Z#d"„ Z$d#„ Z%y$)%ÚLightNodeMixinu¦	  
    The :any:`LightNodeMixin` behaves identical to :any:`NodeMixin`, but uses `__slots__`.

    There are some minor differences in the object behaviour.
    See slots_ for any details.

    .. _slots: https://docs.python.org/3/reference/datamodel.html#slots

    The only tree relevant information is the `parent` attribute.
    If `None` the :any:`LightNodeMixin` is root node.
    If set to another node, the :any:`LightNodeMixin` becomes the child of it.

    The `children` attribute can be used likewise.
    If `None` the :any:`LightNodeMixin` has no children.
    The `children` attribute can be set to any iterable of :any:`LightNodeMixin` instances.
    These instances become children of the node.

    >>> from anytree import LightNodeMixin, RenderTree
    >>> class MyBaseClass():  # Just an example of a base class
    ...     __slots__ = []
    >>> class MyClass(MyBaseClass, LightNodeMixin):  # Add Node feature
    ...     __slots__ = ['name', 'length', 'width']
    ...     def __init__(self, name, length, width, parent=None, children=None):
    ...         super().__init__()
    ...         self.name = name
    ...         self.length = length
    ...         self.width = width
    ...         self.parent = parent
    ...         if children:
    ...             self.children = children

    Construction via `parent`:

    >>> my0 = MyClass('my0', 0, 0)
    >>> my1 = MyClass('my1', 1, 0, parent=my0)
    >>> my2 = MyClass('my2', 0, 2, parent=my0)

    >>> for pre, _, node in RenderTree(my0):
    ...     treestr = u"%s%s" % (pre, node.name)
    ...     print(treestr.ljust(8), node.length, node.width)
    my0      0 0
    â”œâ”€â”€ my1  1 0
    â””â”€â”€ my2  0 2

    Construction via `children`:

    >>> my0 = MyClass('my0', 0, 0, children=[
    ...     MyClass('my1', 1, 0),
    ...     MyClass('my2', 0, 2),
    ... ])

    >>> for pre, _, node in RenderTree(my0):
    ...     treestr = u"%s%s" % (pre, node.name)
    ...     print(treestr.ljust(8), node.length, node.width)
    my0      0 0
    â”œâ”€â”€ my1  1 0
    â””â”€â”€ my2  0 2

    Both approaches can be mixed:

    >>> my0 = MyClass('my0', 0, 0, children=[
    ...     MyClass('my1', 1, 0),
    ... ])
    >>> my2 = MyClass('my2', 0, 2, parent=my0)

    >>> for pre, _, node in RenderTree(my0):
    ...     treestr = u"%s%s" % (pre, node.name)
    ...     print(treestr.ljust(8), node.length, node.width)
    my0      0 0
    â”œâ”€â”€ my1  1 0
    â””â”€â”€ my2  0 2
    Ú
__childrenÚ__parentÚ/c                 ó4   — t        | d«      r| j                  S y)uD  
        Parent Node.

        On set, the node is detached from any previous parent node and attached
        to the new node.

        >>> from anytree import Node, RenderTree
        >>> udo = Node("Udo")
        >>> marc = Node("Marc")
        >>> lian = Node("Lian", parent=marc)
        >>> print(RenderTree(udo))
        Node('/Udo')
        >>> print(RenderTree(marc))
        Node('/Marc')
        â””â”€â”€ Node('/Marc/Lian')

        **Attach**

        >>> marc.parent = udo
        >>> print(RenderTree(udo))
        Node('/Udo')
        â””â”€â”€ Node('/Udo/Marc')
            â””â”€â”€ Node('/Udo/Marc/Lian')

        **Detach**

        To make a node to a root node, just set this attribute to `None`.

        >>> marc.is_root
        False
        >>> marc.parent = None
        >>> marc.is_root
        True
        Ú_LightNodeMixin__parentN)Úhasattrr   ©Úselfs    úl/workspace/moltex-experiments/.pixi/envs/default/lib/python3.12/site-packages/anytree/node/lightnodemixin.pyÚparentzLightNodeMixin.parentU   s   € ôH �4Ð2Ô3Ø—=‘=Ð Øó    c                 óª   — t        | d«      r| j                  }nd }||ur4| j                  |«       | j                  |«       | j	                  |«       y y )Nr   )r   r   Ú_LightNodeMixin__check_loopÚ_LightNodeMixin__detachÚ_LightNodeMixin__attach)r   Úvaluer   s      r   r   zLightNodeMixin.parent}   sN   € ä�4Ð2Ô3Ø—]‘]‰FàˆFØ˜ÑØ×Ñ˜eÔ$Ø�M‰M˜&Ô!Ø�M‰M˜%Õ ð r   c                 óž   ‡ — |�J|‰ u rd}t        |‰ fz  «      ‚t        ˆ fd„|j                  «       D «       «      rd}t        |‰ |fz  «      ‚y y )Nz1Cannot set parent. %r cannot be parent of itself.c              3   ó&   •K  — | ]  }|‰u –— Œ
 y ­w©N© ©Ú.0Úchildr   s     €r   Ú	<genexpr>z.LightNodeMixin.__check_loop.<locals>.<genexpr>�   s   øè ø€ ÐGÑ.F U�5˜D”=Ñ.Fùó   ƒz&Cannot set parent. %r is parent of %r.)r   ÚanyÚiter_path_reverse)r   ÚnodeÚmsgs   `  r   Ú__check_loopzLightNodeMixin.__check_loopˆ   sa   ø€ ØÐØ�t‰|ØI�Ü  t g¡Ó.Ð.ÜÓG¨d×.DÑ.DÔ.FÓGÔGØ>�Ü  t¨T lÑ 2Ó3Ð3ð Hð	 r   c                 óö   ‡ — |�q‰ j                  |«       |j                  }t        rt        ˆ fd„|D «       «      sJ d«       ‚|D �cg c]	  }|‰ usŒ|‘Œ c}|_        d ‰ _        ‰ j                  |«       y y c c}w )Nc              3   ó&   •K  — | ]  }|‰u –— Œ
 y ­wr   r   r   s     €r   r!   z*LightNodeMixin.__detach.<locals>.<genexpr>—   s   øè ø€ ÐE±n¨U˜5 Dœ=±nùr"   úTree is corrupt.)Ú_pre_detachÚ"_LightNodeMixin__children_or_emptyr   r#   Ú_LightNodeMixin__childrenr   Ú_post_detach)r   r   Úparentchildrenr    s   `   r   Ú__detachzLightNodeMixin.__detach‘   s~   ø€ àÐØ×Ñ˜VÔ$Ø#×7Ñ7ˆNÝÜÓE±nÓEÔEÐYÐGYÓYÐEá4BÓ X±N¨5ÀeÐSWÒFW¢°NÑ XˆFÔØ ˆDŒMà×Ñ˜fÕ%ð ùò !Ys   Á	A6ÁA6c                 óÚ   ‡ — |�h‰ j                  |«       |j                  }t        rt        ˆ fd„|D «       «      rJ d«       ‚|j	                  ‰ «       |‰ _        ‰ j                  |«       y y )Nc              3   ó&   •K  — | ]  }|‰u –— Œ
 y ­wr   r   r   s     €r   r!   z*LightNodeMixin.__attach.<locals>.<genexpr>¤   s   øè ø€ ÐI¹.°˜u¨œ}¹.ùr"   r*   )Ú_pre_attachr,   r   r#   Úappendr   Ú_post_attach)r   r   r/   s   `  r   Ú__attachzLightNodeMixin.__attachž   sg   ø€ àÐØ×Ñ˜VÔ$Ø#×7Ñ7ˆNÝÜÓI¹.ÓIÔIÐ]ÐK]Ó]ÐIà×!Ñ! $Ô'Ø"ˆDŒMà×Ñ˜fÕ%ð r   c                 ó@   — t        | d«      sg | _        | j                  S )Nr-   )r   r-   r   s    r   Ú__children_or_emptyz"LightNodeMixin.__children_or_empty«   s   € ä�tÐ8Ô9Ø ˆDŒOØ�‰Ðr   c                 ó,   — t        | j                  «      S )aÔ  
        All child nodes.

        >>> from anytree import Node
        >>> n = Node("n")
        >>> a = Node("a", parent=n)
        >>> b = Node("b", parent=n)
        >>> c = Node("c", parent=n)
        >>> n.children
        (Node('/n/a'), Node('/n/b'), Node('/n/c'))

        Modifying the children attribute modifies the tree.

        **Detach**

        The children attribute can be updated by setting to an iterable.

        >>> n.children = [a, b]
        >>> n.children
        (Node('/n/a'), Node('/n/b'))

        Node `c` is removed from the tree.
        In case of an existing reference, the node `c` does not vanish and is the root of its own tree.

        >>> c
        Node('/c')

        **Attach**

        >>> d = Node("d")
        >>> d
        Node('/d')
        >>> n.children = [a, b, d]
        >>> n.children
        (Node('/n/a'), Node('/n/b'), Node('/n/d'))
        >>> d
        Node('/n/d')

        **Duplicate**

        A node can just be the children once. Duplicates cause a :any:`TreeError`:

        >>> n.children = [a, b, d, a]
        Traceback (most recent call last):
            ...
        anytree.node.exceptions.TreeError: Cannot add node Node('/n/a') multiple times as child.
        )Útupler,   r   s    r   ÚchildrenzLightNodeMixin.children±   s   € ôb �T×-Ñ-Ó.Ð.r   c                 óˆ   — t        «       }| D ]3  }t        |«      }||vr|j                  |«       Œ$d|›d�}t        |«      ‚ y )NzCannot add node z multiple times as child.)ÚsetÚidÚaddr   )r;   Úseenr    Úchildidr&   s        r   Ú__check_childrenzLightNodeMixin.__check_childrenä   sI   € ä‹uˆÛˆEÜ˜“iˆGØ˜dÑ"Ø—‘˜Õ!à(¨¨	Ð1JÐK�Ü “nÐ$ñ r   c                 ó@  — t        |«      }t        j                  |«       | j                  }| `	 | j	                  |«       |D ]	  }| |_        Œ | j                  |«       t        r$t        | j                  «      t        |«      k(  sJ ‚y y # t        $ r	 || _        ‚ w xY wr   )
r:   r	   Ú_LightNodeMixin__check_childrenr;   Ú_pre_attach_childrenr   Ú_post_attach_childrenr   ÚlenÚ	Exception)r   r;   Úold_childrenr    s       r   r;   zLightNodeMixin.childrenï   s—   € ô ˜“?ˆÜ×'Ñ'¨Ô1à—}‘}ˆØˆMð		Ø×%Ñ% hÔ/Û!�Ø#�•ð "à×&Ñ& xÔ0ÝÜ˜4Ÿ=™=Ó)¬S°«]Ò:Ð:Ñ:ð øäò 	Ø(ˆDŒMØð	ús   °AB ÂBc                 óÐ   — | j                   }| j                  |«       | j                   D ]	  }d |_        Œ t        rt	        | j                   «      dk(  sJ ‚| j                  |«       y )Nr   )r;   Ú_pre_detach_childrenr   r   rG   Ú_post_detach_children)r   r;   r    s      r   r;   zLightNodeMixin.children  sV   € à—=‘=ˆØ×!Ñ! (Ô+Ø—]”]ˆEØˆE�Lð #åÜ�t—}‘}Ó%¨Ò*Ð*Ð*Ø×"Ñ" 8Õ,r   c                  ó   — y)z(Method call before detaching `children`.Nr   ©r   r;   s     r   rK   z#LightNodeMixin._pre_detach_children  ó   � r   c                  ó   — y)z'Method call after detaching `children`.Nr   rN   s     r   rL   z$LightNodeMixin._post_detach_children  rO   r   c                  ó   — y)z(Method call before attaching `children`.Nr   rN   s     r   rE   z#LightNodeMixin._pre_attach_children  rO   r   c                  ó   — y)z'Method call after attaching `children`.Nr   rN   s     r   rF   z$LightNodeMixin._post_attach_children  rO   r   c                 ó   — | j                   S )aœ  
        Path from root node down to this `Node`.

        >>> from anytree import Node
        >>> udo = Node("Udo")
        >>> marc = Node("Marc", parent=udo)
        >>> lian = Node("Lian", parent=marc)
        >>> udo.path
        (Node('/Udo'),)
        >>> marc.path
        (Node('/Udo'), Node('/Udo/Marc'))
        >>> lian.path
        (Node('/Udo'), Node('/Udo/Marc'), Node('/Udo/Marc/Lian'))
        )Ú_pathr   s    r   ÚpathzLightNodeMixin.path  s   € ð  �z‰zÐr   c              #   ó<   K  — | }|�|–— |j                   }|�Œyy­w)ae  
        Iterate up the tree from the current node to the root node.

        >>> from anytree import Node
        >>> udo = Node("Udo")
        >>> marc = Node("Marc", parent=udo)
        >>> lian = Node("Lian", parent=marc)
        >>> for node in udo.iter_path_reverse():
        ...     print(node)
        Node('/Udo')
        >>> for node in marc.iter_path_reverse():
        ...     print(node)
        Node('/Udo/Marc')
        Node('/Udo')
        >>> for node in lian.iter_path_reverse():
        ...     print(node)
        Node('/Udo/Marc/Lian')
        Node('/Udo/Marc')
        Node('/Udo')
        N©r   ©r   r%   s     r   r$   z LightNodeMixin.iter_path_reverse+  s)   è ø€ ð* ˆØÐØŠJØ—;‘;ˆDð Óùs   ‚šc                 óX   — t        t        t        | j                  «       «      «      «      S r   )r:   ÚreversedÚlistr$   r   s    r   rT   zLightNodeMixin._pathE  s    € ä”Xœd 4×#9Ñ#9Ó#;Ó<Ó=Ó>Ð>r   c                 óH   — | j                   €y| j                   j                  S )at  
        All parent nodes and their parent nodes.

        >>> from anytree import Node
        >>> udo = Node("Udo")
        >>> marc = Node("Marc", parent=udo)
        >>> lian = Node("Lian", parent=marc)
        >>> udo.ancestors
        ()
        >>> marc.ancestors
        (Node('/Udo'),)
        >>> lian.ancestors
        (Node('/Udo'), Node('/Udo/Marc'))
        r   )r   rU   r   s    r   Ú	ancestorszLightNodeMixin.ancestorsI  s!   € ð  �;‰;ÐØØ�{‰{×ÑÐr   c                 ó0   — t        t        | «      «      dd S )aj  
        All child nodes and all their child nodes.

        >>> from anytree import Node
        >>> udo = Node("Udo")
        >>> marc = Node("Marc", parent=udo)
        >>> lian = Node("Lian", parent=marc)
        >>> loui = Node("Loui", parent=marc)
        >>> soe = Node("Soe", parent=lian)
        >>> udo.descendants
        (Node('/Udo/Marc'), Node('/Udo/Marc/Lian'), Node('/Udo/Marc/Lian/Soe'), Node('/Udo/Marc/Loui'))
        >>> marc.descendants
        (Node('/Udo/Marc/Lian'), Node('/Udo/Marc/Lian/Soe'), Node('/Udo/Marc/Loui'))
        >>> lian.descendants
        (Node('/Udo/Marc/Lian/Soe'),)
        r   N©r:   r   r   s    r   ÚdescendantszLightNodeMixin.descendants]  s   € ô$ ”\ $Ó'Ó(¨¨Ð,Ð,r   c                 óT   — | }|j                   �|j                   }|j                   �Œ|S )a>  
        Tree Root Node.

        >>> from anytree import Node
        >>> udo = Node("Udo")
        >>> marc = Node("Marc", parent=udo)
        >>> lian = Node("Lian", parent=marc)
        >>> udo.root
        Node('/Udo')
        >>> marc.root
        Node('/Udo')
        >>> lian.root
        Node('/Udo')
        rW   rX   s     r   ÚrootzLightNodeMixin.rootq  s-   € ð  ˆØ�k‰kÐ%Ø—;‘;ˆDð �k‰kÑ%àˆr   c                 ó^   ‡ — ‰ j                   }|€yt        ˆ fd„|j                  D «       «      S )a  
        Tuple of nodes with the same parent.

        >>> from anytree import Node
        >>> udo = Node("Udo")
        >>> marc = Node("Marc", parent=udo)
        >>> lian = Node("Lian", parent=marc)
        >>> loui = Node("Loui", parent=marc)
        >>> lazy = Node("Lazy", parent=marc)
        >>> udo.siblings
        ()
        >>> marc.siblings
        ()
        >>> lian.siblings
        (Node('/Udo/Marc/Loui'), Node('/Udo/Marc/Lazy'))
        >>> loui.siblings
        (Node('/Udo/Marc/Lian'), Node('/Udo/Marc/Lazy'))
        r   c              3   ó,   •K  — | ]  }|‰usŒ|–— Œ y ­wr   r   )r   r%   r   s     €r   r!   z*LightNodeMixin.siblings.<locals>.<genexpr>�  s   øè ø€ ÐJ¡o˜d¸ÀTÒ9I”T¡oùs   ƒ	�)r   r:   r;   ©r   r   s   ` r   ÚsiblingszLightNodeMixin.siblings†  s+   ø€ ð( —‘ˆØˆ>ØÜÓJ f§o¢oÓJÓJÐJr   c                 ó0   — t        t        | d„ ¬«      «      S )aò  
        Tuple of all leaf nodes.

        >>> from anytree import Node
        >>> udo = Node("Udo")
        >>> marc = Node("Marc", parent=udo)
        >>> lian = Node("Lian", parent=marc)
        >>> loui = Node("Loui", parent=marc)
        >>> lazy = Node("Lazy", parent=marc)
        >>> udo.leaves
        (Node('/Udo/Marc/Lian'), Node('/Udo/Marc/Loui'), Node('/Udo/Marc/Lazy'))
        >>> marc.leaves
        (Node('/Udo/Marc/Lian'), Node('/Udo/Marc/Loui'), Node('/Udo/Marc/Lazy'))
        c                 ó   — | j                   S r   )Úis_leaf)r%   s    r   Ú<lambda>z'LightNodeMixin.leaves.<locals>.<lambda>¯  s   € ¸T¿\º\r   )Úfilter_r_   r   s    r   ÚleaveszLightNodeMixin.leavesŸ  s   € ô  ”\ $Ñ0IÔJÓKÐKr   c                 ó2   — t        | j                  «      dk(  S )aI  
        `Node` has no children (External Node).

        >>> from anytree import Node
        >>> udo = Node("Udo")
        >>> marc = Node("Marc", parent=udo)
        >>> lian = Node("Lian", parent=marc)
        >>> udo.is_leaf
        False
        >>> marc.is_leaf
        False
        >>> lian.is_leaf
        True
        r   )rG   r,   r   s    r   ri   zLightNodeMixin.is_leaf±  s   € ô  �4×+Ñ+Ó,°Ñ1Ð1r   c                 ó   — | j                   du S )a6  
        `Node` is tree root.

        >>> from anytree import Node
        >>> udo = Node("Udo")
        >>> marc = Node("Marc", parent=udo)
        >>> lian = Node("Lian", parent=marc)
        >>> udo.is_root
        True
        >>> marc.is_root
        False
        >>> lian.is_root
        False
        NrW   r   s    r   Úis_rootzLightNodeMixin.is_rootÃ  s   € ð  �{‰{˜dÐ"Ð"r   c                 óJ   — | j                   }|rt        d„ |D «       «      dz   S y)aI  
        Number of edges on the longest path to a leaf `Node`.

        >>> from anytree import Node
        >>> udo = Node("Udo")
        >>> marc = Node("Marc", parent=udo)
        >>> lian = Node("Lian", parent=marc)
        >>> udo.height
        2
        >>> marc.height
        1
        >>> lian.height
        0
        c              3   ó4   K  — | ]  }|j                   –— Œ y ­wr   )Úheight)r   r    s     r   r!   z(LightNodeMixin.height.<locals>.<genexpr>ç  s   è ø€ Ð:±¨�u—|•|±ùs   ‚r   r   )r,   ÚmaxrN   s     r   rr   zLightNodeMixin.heightÕ  s+   € ð  ×+Ñ+ˆÙÜÑ:±Ó:Ó:¸QÑ>Ð>Ør   c                 óH   — t        | j                  «       «      D ]  \  }}Œ S )a4  
        Number of edges to the root `Node`.

        >>> from anytree import Node
        >>> udo = Node("Udo")
        >>> marc = Node("Marc", parent=udo)
        >>> lian = Node("Lian", parent=marc)
        >>> udo.depth
        0
        >>> marc.depth
        1
        >>> lian.depth
        2
        )Ú	enumerater$   )r   ÚdepthÚ_s      r   rv   zLightNodeMixin.depthê  s(   € ô$ " $×"8Ñ"8Ó":Ö;‰HˆE�1Øð <àˆr   c                 ó@   — t        t        | «      d«      D ]  \  }}Œ S )aÆ  
        Tree size --- the number of nodes in tree starting at this node.

        >>> from anytree import Node
        >>> udo = Node("Udo")
        >>> marc = Node("Marc", parent=udo)
        >>> lian = Node("Lian", parent=marc)
        >>> loui = Node("Loui", parent=marc)
        >>> soe = Node("Soe", parent=lian)
        >>> udo.size
        5
        >>> marc.size
        4
        >>> lian.size
        2
        >>> loui.size
        1
        r   )ru   r   )r   Úsizerw   s      r   ry   zLightNodeMixin.size   s&   € ô, !¤¨dÓ!3°QÖ7‰GˆD�!Øð 8àˆr   c                  ó   — y)z+Method call before detaching from `parent`.Nr   re   s     r   r+   zLightNodeMixin._pre_detach  rO   r   c                  ó   — y)z*Method call after detaching from `parent`.Nr   re   s     r   r.   zLightNodeMixin._post_detach  rO   r   c                  ó   — y)z)Method call before attaching to `parent`.Nr   re   s     r   r3   zLightNodeMixin._pre_attach   rO   r   c                  ó   — y)z(Method call after attaching to `parent`.Nr   re   s     r   r5   zLightNodeMixin._post_attach#  rO   r   N)&Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__Ú	separatorÚpropertyr   Úsetterr   r   r   r,   r;   ÚstaticmethodrD   ÚdeleterrK   rL   rE   rF   rU   r$   rT   r]   r`   rb   rf   rl   ri   ro   rr   rv   ry   r+   r.   r3   r5   r   r   r   r	   r	      sä  „ ñGðR ˜zÐ*€Ià€Iàñ%ó ð%ðN ‡]�]ñ!ó ð!ò4ò&ò&ð ñó ðð
 ñ0/ó ð0/ðd ñ%ó ð%ð ‡_�_ñó ðð& ×Ññ-ó ð-ò7ò6ò7ò6ð ñó ðò"ð4 ñ?ó ð?ð ñ ó ð ð& ñ-ó ð-ð& ñó ðð( ñKó ðKð0 ñLó ðLð" ñ2ó ð2ð" ñ#ó ð#ð" ñó ðð( ñó ðð* ñó ðò2:ò9ò8ó7r   r	   N)Úanytree.configr   Úanytree.iteratorsr   Ú
exceptionsr   r   r	   r   r   r   Ú<module>r‹      s   ðÝ %Ý *ç ,÷]7ò ]7r   