
    AHjY                    |   U d Z ddlmZ ddlmZ ddlmZmZmZm	Z	m
Z
mZmZ ddlZddlmZmZ ddlmZmZ ddlmZmZ dd	lmZ dd
lmZ ddlmZ ddlmZm Z  ddl!m"Z" ddl#m$Z$m%Z%m&Z& ddl'm(Z( ddl)m*Z*m+Z+ ddl,m-Z- ddl.m/Z/ erddl0m1Z1m2Z2  e
de3      Z4	  ed      Z5	  ed      Z6	 dZ7de8d<    ejr                  ddi      Z: G d de;      Z< G d de;      Z= G d  d!e;      Z>e G d" d#ee5                Z? G d$ d%ed&         Z@ej                  j                   G d' d(ee5                ZC G d) d*ee5   e-d+      ZDy),zProvides a tree widget.    )annotations)	dataclass)TYPE_CHECKINGClassVarGenericIterableNewTypeTypeVarcastN)
NULL_STYLEStyle)TextTextType)eventson)ImmutableSequenceView)	loop_last)line_pad)BindingBindingType)LRUCache)RegionSizeclamp)Message)reactivevar)
ScrollView)Strip)Self	TypeAliasNodeIDTreeDataTypeEventTreeDataTypeztuple[int | tuple, ...]r!   LineCacheKeytoggleTc                      e Zd ZdZy)RemoveRootErrorzaException raised when trying to remove the root of a [`TreeNode`][textual.widgets.tree.TreeNode].N__name__
__module____qualname____doc__     M/root/tools/cai/cai_env/lib/python3.12/site-packages/textual/widgets/_tree.pyr(   r(   -   s    kr/   r(   c                      e Zd ZdZy)UnknownNodeIDz]Exception raised when referring to an unknown [`TreeNode`][textual.widgets.tree.TreeNode] ID.Nr)   r.   r/   r0   r2   r2   1   s    gr/   r2   c                      e Zd ZdZy)AddNodeErrorzEException raised when there is an error with a request to add a node.Nr)   r.   r/   r0   r4   r4   5   s    Or/   r4   c                  <    e Zd ZU ded<   ded<   edd       Zd	dZy)
	_TreeLinelist[TreeNode[TreeDataType]]pathboollastc                     | j                   d   S )z#The node associated with this line.)r8   selfs    r0   nodez_TreeLine.node>   s     yy}r/   c                    |r't        dt        | j                        dz
        |z  }|S d}t        | j                        dkD  r|t        | j                        dz
  |z  z  }|S )zGet the cell width of the line as rendered.

        Args:
            guide_depth: The guide depth (cells in the indentation).

        Returns:
            Width in cells.
        r      )maxlenr8   )r>   guide_depth	show_rootwidths       r0   _get_guide_widthz_TreeLine._get_guide_widthC   sd     C		NQ./;>E 	 E499~!#dii.1,;;r/   N)returnTreeNode[TreeDataType])rD   intrE   r9   rH   rJ   )r*   r+   r,   __annotations__propertyr?   rG   r.   r/   r0   r6   r6   9   s$    
&&
J r/   r6   c                      e Zd ZdZy)	TreeNodesz&An immutable collection of `TreeNode`.Nr)   r.   r/   r0   rN   rN   V   s    0r/   rN   rI   c                     e Zd ZdZ	 d/ddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d0dZd1dZd2dZed3d       Zed4d	       Z	ed4d
       Z
ed5d       Zed6d       Zej                  d7d       Zed6d       Zej                  d8d       Zed9d       Zed:d       Zed:d       Zed:d       Zed6d       Zed6d       Zed6d       Zed6d       Zed6d       Zej                  d;d       Zd<dZd=dZd=dZd>dZd=dZd=dZd=d Zd=d!Zed?d"       Z e j                  d@d#       Z dAd$Z!	 d/ddd%dd&	 	 	 	 	 	 	 	 	 	 	 	 	 dBd'Z"	 d/ddd(	 	 	 	 	 	 	 	 	 dCd)Z#d2d*Z$d2d+Z%d2d,Z&d2d-Z'd2d.Z(y)DTreeNodez5An object that represents a "node" in a tree control.NT)expandedallow_expandc                   || _         || _        || _        |j                  |      | _        || _        	 || _        g | _        d| _        d| _	        || _
        d| _        d| _        y)a  Initialise the node.

        Args:
            tree: The tree that the node is being attached to.
            parent: The parent node that this node is being attached to.
            id: The ID of the node.
            label: The label for the node.
            data: Optional data to associate with the node.
            expanded: Should the node be attached in an expanded state?
            allow_expand: Should the node allow being expanded by the user?
        Fr   r<   N)_tree_parent_idprocess_label_labeldata	_expanded	_children_hover_
_selected__allow_expand_updates_line)r>   treeparentidlabelrY   rQ   rR   s           r0   __init__zTreeNode.__init__^   sg    , 
((/	:!79)
r/   c              #  X   K   | j                   j                   | j                   y wN)rX   plainrY   r=   s    r0   __rich_repr__zTreeNode.__rich_repr__   s     kkiis   (*c                J    d| _         d| _        | xj                  dz  c_        y )NFrA   )r\   r]   r_   r=   s    r0   _resetzTreeNode._reset   s    r/   c                    | j                   S )z'The tree that this node is attached to.)rT   r=   s    r0   ra   zTreeNode.tree        zzr/   c                ,    t        | j                        S )zThe child nodes of a TreeNode.)rN   r[   r=   s    r0   childrenzTreeNode.children   s     ((r/   c                ^    | j                   t        | g      S | j                   j                  S )z*The siblings of this node (includes self).)rb   rN   ro   r=   s    r0   siblingszTreeNode.siblings   s+     ;;dV$$;;'''r/   c                    | j                   S )z<The line number for this node, or -1 if it is not displayed.)r`   r=   s    r0   linezTreeNode.line   rm   r/   c                    | j                   S )z$Check if the mouse is over the node.)r\   r=   s    r0   _hoverzTreeNode._hover        ||r/   c                <    | xj                   dz  c_         || _        y NrA   )r_   r\   )r>   hovers     r0   ru   zTreeNode._hover   s    r/   c                    | j                   S )zCheck if the node is selected.)r]   r=   s    r0   	_selectedzTreeNode._selected   s     r/   c                <    | xj                   dz  c_         || _        y rx   )r_   r]   )r>   selecteds     r0   r{   zTreeNode._selected   s    "r/   c                    | j                   S )zThe ID of the  node.)rV   r=   s    r0   rc   zTreeNode.id   s     xxr/   c                    | j                   S )zThe parent of the node.)rU   r=   s    r0   rb   zTreeNode.parent   rv   r/   c                l    | j                   }|j                  |       dz   }	 ||   S # t        $ r Y yw xY w)z The next sibling below the node.rA   Nrq   index
IndexErrorr>   rq   r   s      r0   next_siblingzTreeNode.next_sibling   sA     ==t$q(	E?" 		s   ' 	33c                x    | j                   }|j                  |       dz
  }|dk  ry	 ||   S # t        $ r Y yw xY w)z$The previous sibling below the node.rA   r   Nr   r   s      r0   previous_siblingzTreeNode.previous_sibling   sK     ==t$q(19	E?" 		s   - 	99c                    | j                   S )zIs the node expanded?rZ   r=   s    r0   is_expandedzTreeNode.is_expanded   s     ~~r/   c                    | j                    S )zIs the node collapsed?r   r=   s    r0   is_collapsedzTreeNode.is_collapsed   s     >>!!r/   c                    | j                   yt        | j                   j                  xr | j                   j                  d   | k(        S )z*Is this the last child node of its parent?Tr<   )rU   r9   r[   r=   s    r0   is_lastzTreeNode.is_last   sD     <<LL""It||'='=b'AT'I
 	
r/   c                4    | | j                   j                  k(  S )z"Is this node the root of the tree?)rT   rootr=   s    r0   is_rootzTreeNode.is_root   s     tzz&&r/   c                    | j                   S )zIs this node allowed to expand?)r^   r=   s    r0   rR   zTreeNode.allow_expand   s     !!!r/   c                <    || _         | xj                  dz  c_        y rx   )r^   r_   )r>   rR   s     r0   rR   zTreeNode.allow_expand   s    )r/   c                   d| _         | xj                  dz  c_        | j                  j                  t        j                  |       j                  | j                               |r#| j                  D ]  }|j                  |        yy)zMark the node as expanded (its children are shown).

        Args:
            expand_all: If `True` expand all offspring at all depths.
        TrA   N)	rZ   r_   rT   post_messageTreeNodeExpanded
set_senderro   _expand)r>   
expand_allchilds      r0   r   zTreeNode._expand   sl     

 1 1$ 7 B B4:: NO *j)* r/   c                \    | j                  d       | j                  j                          | S )zdExpand the node (show its children).

        Returns:
            The `TreeNode` instance.
        Fr   rT   _invalidater=   s    r0   expandzTreeNode.expand  s%     	U

 r/   c                \    | j                  d       | j                  j                          | S )z{Expand the node (show its children) and all those below it.

        Returns:
            The `TreeNode` instance.
        Tr   r=   s    r0   r   zTreeNode.expand_all  s%     	T

 r/   c                   d| _         | xj                  dz  c_        | j                  j                  t        j                  |       j                  | j                               |r#| j                  D ]  }|j                  |        yy)zMark the node as collapsed (its children are hidden).

        Args:
            collapse_all: If `True` collapse all offspring at all depths.
        FrA   N)	rZ   r_   rT   r   r   NodeCollapsedr   ro   	_collapse)r>   collapse_allr   s      r0   r   zTreeNode._collapse  sl     

 2 24 8 C CDJJ OP .-. r/   c                \    | j                  d       | j                  j                          | S )zfCollapse the node (hide its children).

        Returns:
            The `TreeNode` instance.
        Fr   rT   r   r=   s    r0   collapsezTreeNode.collapse'  s%     	u

 r/   c                \    | j                  d       | j                  j                          | S )z}Collapse the node (hide its children) and all those below it.

        Returns:
            The `TreeNode` instance.
        Tr   r=   s    r0   r   zTreeNode.collapse_all1  s%     	t

 r/   c                b    | j                   r| j                          | S | j                          | S )zaToggle the node's expanded state.

        Returns:
            The `TreeNode` instance.
        )rZ   r   r   r=   s    r0   r&   zTreeNode.toggle;  s+     >>MMO  KKMr/   c                b    | j                   r| j                          | S | j                          | S )zToggle the node's expanded state and make all those below it match.

        Returns:
            The `TreeNode` instance.
        )rZ   r   r   r=   s    r0   
toggle_allzTreeNode.toggle_allG  s/     >>  OOr/   c                    | j                   S )zThe label for the node.)rX   r=   s    r0   rd   zTreeNode.labelS  s     {{r/   c                &    | j                  |       y rg   )	set_label)r>   	new_labels     r0   rd   zTreeNode.labelX  s    y!r/   c                    | xj                   dz  c_         | j                  j                  |      }|| _        | j                  j	                  | j                  j
                  |        y)zySet a new label for the node.

        Args:
            label: A ``str`` or ``Text`` object with the new label.
        rA   N)r_   rT   rW   rX   
call_later_refresh_node)r>   rd   
text_labels      r0   r   zTreeNode.set_label\  sK     	ZZ--e4
 

djj66=r/   Fbeforeafterr   rR   c               J   ||t        d      t        | j                        }|Kt        |t              r|}n8t        |t
              r	 | j                  j                  |      }nt        d      |nt        |t              r#|dz   }|dk  rT|t        | j                        z  }n;t        |t
              r 	 | j                  j                  |      dz   }nt        d      | j                  j                  |      }| j                  j                  | ||      }	||	_        ||	_        | xj                  dz  c_        | j                  j!                  ||	       | j                  j#                          |	S # t        $ r t        d      w xY w# t        $ r t        d      w xY w)a  Add a node to the sub-tree.

        Args:
            label: The new node's label.
            data: Data associated with the new node.
            before: Optional index or `TreeNode` to add the node before.
            after: Optional index or `TreeNode` to add the node after.
            expand: Node should be expanded.
            allow_expand: Allow user to expand the node via keyboard or mouse.

        Returns:
            A new Tree node

        Raises:
            AddNodeError: If there is a problem with the addition request.

        Note:
            Only one of `before` or `after` can be provided. If both are
            provided a `AddNodeError` will be raised.
        z1Unable to add a node both before and after a nodez;The node specified for `before` is not a child of this nodezE`before` argument must be an index or a TreeNode object to add beforerA   r   z:The node specified for `after` is not a child of this nodezC`after` argument must be an index or a TreeNode object to add after)r4   rC   ro   
isinstancerJ   rP   r   
ValueError	TypeErrorrT   rW   	_add_noderZ   r^   r_   r[   insertr   )
r>   rd   rY   r   r   r   rR   insert_indexr   r?   s
             r0   addzTreeNode.addg  s   < %"3RSS.&#&%FH-#'==#6#6v#>L  [  %%$qy19 C$66LE8,#'==#6#6u#=#AL  Y  ZZ--e4
zz##D*d;)lD1

 E " &U " " &T s   E5 8F 5F
F")r   r   c               4    | j                  ||||dd      }|S )a1  Add a 'leaf' node (a node that can not expand).

        Args:
            label: Label for the node.
            data: Optional data.
            before: Optional index or `TreeNode` to add the node before.
            after: Optional index or `TreeNode` to add the node after.

        Returns:
            New node.

        Raises:
            AddNodeError: If there is a problem with the addition request.

        Note:
            Only one of `before` or `after` can be provided. If both are
            provided a `AddNodeError` will be raised.
        Fr   )r   )r>   rd   rY   r   r   r?   s         r0   add_leafzTreeNode.add_leaf  s0    4 xx  
 r/   c                X    t        | j                        D ]  }|j                           y)zRemove child nodes of this node.

        Note:
            This is the internal support method for `remove_children`. Call
            `remove_children` to ensure the tree gets refreshed.
        N)reversedr[   _remove)r>   r   s     r0   _remove_childrenzTreeNode._remove_children  s%     dnn- 	EMMO	r/   c                    | j                          | j                  J | j                  j                  | j                  j                  j                  |       = | j                  j
                  | j                  = y)zRemove the current node and all its children.

        Note:
            This is the internal support method for `remove`. Call `remove`
            to ensure the tree gets refreshed.
        N)r   rU   r[   r   rT   _tree_nodesrc   r=   s    r0   r   zTreeNode._remove  s]     	||'''LL""4<<#9#9#?#?#EFJJ""477+r/   c                    | j                   rt        d      | j                          | j                  j	                          y)zRemove this node from the tree.

        Raises:
            RemoveRootError: If there is an attempt to remove the root.
        z*Attempt to remove the root node of a Tree.N)r   r(   r   rT   r   r=   s    r0   removezTreeNode.remove  s0     <<!"NOO

 r/   c                X    | j                          | j                  j                          y)z$Remove any child nodes of this node.N)r   rT   r   r=   s    r0   remove_childrenzTreeNode.remove_children  s    

 r/   c                x    | xj                   dz  c_         | j                  j                  | j                         y)z*Initiate a refresh (repaint) of this node.rA   N)r_   rT   _refresh_liner`   r=   s    r0   refreshzTreeNode.refresh  s&    

  ,r/   rg   )ra   Tree[TreeDataType]rb   TreeNode[TreeDataType] | Nonerc   r"   rd   r   rY   TreeDataType | NonerQ   r9   rR   r9   rH   None)rH   zrich.repr.ResultrH   r   )rH   r   )rH   zTreeNodes[TreeDataType]rH   rJ   )rH   r9   )ry   r9   rH   r   )r}   r9   rH   r   rH   r"   rH   r   )rR   r9   rH   r   )r   r9   rH   r   rH   r    )r   r9   rH   r   )rH   r   )r   r   rH   r   )rd   r   rH   r   )rd   r   rY   r   r   #int | TreeNode[TreeDataType] | Noner   r   r   r9   rR   r9   rH   rI   )
rd   r   rY   r   r   r   r   r   rH   rI   ))r*   r+   r,   r-   re   ri   rk   rL   ra   ro   rq   rs   ru   setterr{   rc   rb   r   r   r   r   r   r   rR   r   r   r   r   r   r   r&   r   rd   r   r   r   r   r   r   r   r   r.   r/   r0   rP   rP   Z   s   ? %)# !# # .# 	#
 # "# # # 
#J
   ) ) ( (     ]]    # #       	 	   " " 
 
 ' ' " "  *.

   \\" "	> %)K
 7;59!KK "K
 4K 3K K K 
 K` %)"
 7;59"" ""
 4" 3" 
 "H
,	!!
-r/   rP   c                      e Zd ZU dZdZ	 dZ	  edddd       ed	d
dd       edddd       edddd       edddd       edddd       edddd       edddd       eddd d      g	Zd!ed"<   	 h d#Z	d$ed%<   	 d&Z
 ed'      Z	  ed(      Z	  ed(d')      Z	  ed'      Z	  ed*d+      Z	  ed'      Z	  ed      Z	 d,d-d.d/Zd0ed1<    G d2 d3ee   e      Z G d4 d5ee   e      Z G d6 d7ee   e      Z G d8 d9ee   e      Z	 dvd:d:d:dd;	 	 	 	 	 	 	 	 	 	 	 	 	 dw fd<Zdvdxd=Zedyd>       Zedzd?       Z d{d@Z!	 d|	 	 	 	 	 	 	 	 	 d}dAZ"	 	 	 	 	 	 	 	 d~dBZ#ddCZ$ddDZ%ddEZ&dvddFZ'	 d|	 	 	 	 	 ddGZ(d|ddHZ)ddIZ*ddJZ+ e,e      ddK       Z-ddLZ.ddMZ/ddNZ0ddOZ1ddPZ2ddQZ3ddRZ4ddSZ5ddTZ6ddUZ7ddVZ8ddWZ9ddXZ:ddYZ;dddZZ<	 d	 	 	 	 	 dd[Z=dd\Z>dd]Z?dd^Z@edd_       ZAdd`ZBddaZCd fdbZDddcZEdddZFddeZGddfZHddgZId fdhZJddiZKddjZLddkZMddlZNddmZOddnZPddoZQddpZRddqZSddrZTddsZUddtZVdduZW xZXS )r   z6A widget for displaying and navigating data in a tree.u   ▶ u   ▼ z
shift+leftcursor_parentzCursor to parentF)showzshift+rightcursor_parent_next_siblingzCursor to next ancestorzshift+upcursor_previous_siblingzCursor to previous siblingz
shift+downcursor_next_siblingzCursor to next siblingenterselect_cursorSelectspacetoggle_nodeTogglezshift+spacetoggle_expand_allzExpand or collapse allup	cursor_upz	Cursor Updowncursor_downzCursor DownzClassVar[list[BindingType]]BINDINGS>   tree--labeltree--cursortree--guidestree--highlighttree--guides-hovertree--highlight-linetree--guides-selectedzClassVar[set[str]]COMPONENT_CLASSESa  
    Tree {
        background: $surface;
        color: $foreground;

        & > .tree--label {}
        & > .tree--guides {
            color: $surface-lighten-2;
        }
        & > .tree--guides-hover {
            color: $surface-lighten-2;
        }
        & > .tree--guides-selected {
            color: $block-cursor-blurred-background;
        }
        & > .tree--cursor {
            text-style: $block-cursor-blurred-text-style;
            background: $block-cursor-blurred-background;
        }
        & > .tree--highlight {}
        & > .tree--highlight-line {
            background: $block-hover-background;
        }

        &:focus {
            background-tint: $foreground 5%;
            & > .tree--cursor {
                color: $block-cursor-foreground;
                background: $block-cursor-background;
                text-style: $block-cursor-text-style;
            }
            & > .tree--guides {
                color: $surface-lighten-3;
            }
            & > .tree--guides-hover {
                color: $surface-lighten-3;
            }
            & > .tree--guides-selected {
                color: $block-cursor-background;
            }
        }

        &:light {
            /* In light mode the guides are darker*/
            & > .tree--guides {
                color: $surface-darken-1;
            }
            & > .tree--guides-hover {
                color: $block-cursor-background;
            }
            & > .tree--guides-selected {
                color: $block-cursor-background;
            }
        }

        &:ansi {
            color: ansi_default;
            & > .tree--guides {
                color: ansi_green;
            }
            &:nocolor > .tree--cursor{
                text-style: reverse;
            }
        }
    }

    Tr<   )always_update   )init)  u   │ u   └─u   ├─)r   u   ┃ u   ┗━u   ┣━)r   u   ║ u   ╚═u   ╠═)defaultbolddoublez$dict[str, tuple[str, str, str, str]]LINESc                  6     e Zd ZdZd fdZedd       Z xZS )Tree.NodeCollapsedzEvent sent when a node is collapsed.

        Can be handled using `on_tree_node_collapsed` in a subclass of `Tree` or in a
        parent node in the DOM.
        c                2    || _         	 t        | 	          y rg   r?   superre   r>   r?   	__class__s     r0   re   zTree.NodeCollapsed.__init__  s    59DI.Gr/   c                .    | j                   j                  S zThe tree that sent the message.r?   ra   r=   s    r0   controlzTree.NodeCollapsed.control       99>>!r/   r?   zTreeNode[EventTreeDataType]rH   r   rH   zTree[EventTreeDataType]r*   r+   r,   r-   re   rL   r  __classcell__r  s   @r0   r   r     !    		
 
	" 
	"r/   r   c                  6     e Zd ZdZd fdZedd       Z xZS )Tree.NodeExpandedzEvent sent when a node is expanded.

        Can be handled using `on_tree_node_expanded` in a subclass of `Tree` or in a
        parent node in the DOM.
        c                2    || _         	 t        | 	          y rg   r   r   s     r0   re   zTree.NodeExpanded.__init__      59DI-Gr/   c                .    | j                   j                  S r  r  r=   s    r0   r  zTree.NodeExpanded.control  r  r/   r  r  r	  r  s   @r0   r   r    r  r/   r   c                  6     e Zd ZdZd fdZedd       Z xZS )Tree.NodeHighlightedzEvent sent when a node is highlighted.

        Can be handled using `on_tree_node_highlighted` in a subclass of `Tree` or in a
        parent node in the DOM.
        c                2    || _         	 t        | 	          y rg   r   r   s     r0   re   zTree.NodeHighlighted.__init__  s    59DI0Gr/   c                .    | j                   j                  S r  r  r=   s    r0   r  zTree.NodeHighlighted.control  r  r/   r  r  r	  r  s   @r0   NodeHighlightedr    r  r/   r  c                  6     e Zd ZdZd fdZedd       Z xZS )Tree.NodeSelectedzEvent sent when a node is selected.

        Can be handled using `on_tree_node_selected` in a subclass of `Tree` or in a
        parent node in the DOM.
        c                2    || _         	 t        | 	          y rg   r   r   s     r0   re   zTree.NodeSelected.__init__  r  r/   c                .    | j                   j                  S r  r  r=   s    r0   r  zTree.NodeSelected.control  r  r/   r  r  r	  r  s   @r0   NodeSelectedr    r  r/   r  Nnamerc   classesdisabledc                   | j                  |      }d| _        i | _        d| _        | j	                  d||      | _        	 t        d      | _        d| _        d| _	        t        | -  ||||       y)az  Initialise a Tree.

        Args:
            label: The label of the root node of the tree.
            data: The optional data to associate with the root node of the tree.
            name: The name of the Tree.
            id: The ID of the tree in the DOM.
            classes: The CSS classes of the tree.
            disabled: Whether the tree is disabled or not.
        r   Ni   r  )rW   r_   r   _current_idr   r   r   _line_cache_tree_lines_cached_cursor_noder   re   )	r>   rd   rY   r  rc   r  r  r   r  s	           r0   re   zTree.__init__  su    * ''.
ACNN4T:	(:B4.HL;?dr7XNr/   c                `    || j                   }ddlm}  |       dfd d||       y)zAdds JSON data to a node.

        Args:
            json_data: An object decoded from JSON.
            node: Node to add data to.

        Nr   )ReprHighlighterc                h   t        |t              rQ|j                  t        d|               |j	                         D ]   \  }}|j                  d      } |||       " yt        |t              rU|j                  t        d|               t        |      D ])  \  }}|j                  d      } t        |      ||       + yd|_	        | r=t        j                  t        j                  d|  d       	t        |                  }nt        t        |            }|j                  |       y)zAdds a node to the tree.

            Args:
                name: Name of the node.
                node: Parent node.
                data: Data associated with the node.
            z{}  z[] Fz[b]z[/b]=N)r   dictr   r   itemsr   list	enumeratestrrR   assemblefrom_markuprepr)
r  r?   rY   keyvaluenew_noder   rd   add_nodehighlighters
           r0   r4  zTree.add_json.<locals>.add_node$  s    $%teD6N34"&**, 3JC#xx|HS(E23 D$'tc$L12$-dO :LE5#xx|HSZ59: %*! MM((3tfE):;[d=TE !d,Eu%r/   r(  )r  r-  r?   rP   rY   objectrH   r   )r   rich.highlighterr&  )r>   	json_datar?   r&  r4  r5  s       @@r0   add_jsonzTree.add_json  s1     <99D4%'	&8 	T9%r/   c                    | j                   S )z9The currently selected node, or ``None`` if no selection.)r$  r=   s    r0   cursor_nodezTree.cursor_nodeB  s        r/   c                2    t        | j                        dz
  S )zThe index of the last line.rA   )rC   _tree_linesr=   s    r0   	last_linezTree.last_lineG  s     4##$q((r/   c                |    t        |t              rt        j                  |      }n|}|j	                         d   }|S )zProcess a `str` or `Text` value into a label.

        May be overridden in a subclass to change how labels are rendered.

        Args:
            label: Label.

        Returns:
            A Rich Text object.
        r   )r   r-  r   r/  split)r>   rd   r   
first_lines       r0   rW   zTree.process_labelL  s<     eS!))%0JJ%%'*
r/   c                    t        | || j                         |||      }|| j                  |j                  <   | xj                  dz  c_        |S )NrQ   rA   )rP   _new_idr   rV   r_   )r>   rb   rd   rY   r   r?   s         r0   r   zTree._add_node^  sE     fdllneTFS%)"r/   c                   |j                   j                         }|j                  |       |j                  r.|j                  r| j
                  n| j                  |t        z   f}nd|f}t        j                  ||      }|S )a>  Render a label for the given node. Override this to modify how labels are rendered.

        Args:
            node: A tree node.
            base_style: The base style of the widget.
            style: The additional style for the label.

        Returns:
            A Rich Text object containing the label.
        r(  )
rX   copystylizer^   r   ICON_NODE_EXPANDED	ICON_NODETOGGLE_STYLEr   r.  )r>   r?   
base_stylestyle
node_labelprefixtexts          r0   render_labelzTree.render_labelj  st     [[%%'
5!+/+;+;''\)F
 *%F}}VZ0r/   c                P    | j                  |t        t              }|j                  S )a.  Get the width of the nodes label.

        The default behavior is to call `render_label` and return the cell length. This method may be
        overridden in a sub-class if it can be done more efficiently.

        Args:
            node: A node.

        Returns:
            Width in cells.
        )rP  r   cell_len)r>   r?   rd   s      r0   get_label_widthzTree.get_label_width  s"     !!$
J?~~r/   c                F    | j                   j                          d| _        y)zClear line cache.N)r"  clearr#  r=   s    r0   _clear_line_cachezTree._clear_line_cache  s     "&r/   c                J   | j                          d| _        | j                  j                  }| j                  j                  }| j                  j
                  }t        | d| j                         |||      | _        | xj                  dz  c_        | j                          | S )zWClear all nodes under root.

        Returns:
            The `Tree` instance.
        r   NrC  rA   )
rV  r!  r   rX   rY   r   rP   rD  r_   r   )r>   
root_label	root_dataroot_expandeds       r0   rU  z
Tree.clear  s     	 YY%%
IINN			--LLN"
	 	r/   c                j    | j                          || j                  _        || j                  _        | S )zClear the tree and reset the root node.

        Args:
            label: The label for the root node.
            data: Optional data for the root node.

        Returns:
            The `Tree` instance.
        )rU  r   rd   rY   )r>   rd   rY   s      r0   resetz
Tree.reset  s(     	

				r/   c                    | j                   }|dn|j                  | _         |H| j                  ;| j                  | j                  |xr t	        | j                   |z
        dkD         yyy)zMove the cursor to the given node, or reset cursor.

        Args:
            node: A tree node, or None to reset cursor.
            animate: Enable animation
        Nr<   rA   animate)cursor_liner`   r;  scroll_to_nodeabs)r>   r?   r_  previous_cursor_lines       r0   move_cursorzTree.move_cursor  sv      $//!%24:: 0 0 <  TC(8(8;O(O$PST$T    !=r/   c                    | j                   |k(  ry	 | j                  |   j                  }| j	                  ||       y# t        $ r t        d| d      w xY w)a  Move the cursor to the given line.

        Args:
            line: The line number (negative indexes are offsets from the last line).
            animate: Enable scrolling animation.

        Raises:
            IndexError: If the line doesn't exist.
        NzNo line no. z in the treer^  )r`  r=  r?   r   rd  )r>   rs   r_  r?   s       r0   move_cursor_to_linezTree.move_cursor_to_line  sm     t#	@##D)..D 	w/  	@|D6>??	@s	   ? Ac                t    | j                  |       |%| j                  t        j                  |             yy)zMove the cursor to the given node and select it, or reset cursor.

        Args:
            node: A tree node to move the cursor to and select, or None to reset cursor.
        N)rd  r   r   r  r>   r?   s     r0   select_nodezTree.select_node  s6     	d//56 r/   c                d    | j                  t        j                  d       | j                          y)zHide and reset the cursor.r<   N)set_reactiver   r`  r   r=   s    r0   unselectzTree.unselect  s$    $**B/r/   c                X    |j                   }| j                  r| j                  |       yy)zDWhen the node is selected, expand the node if `auto_expand` is True.N)r?   auto_expand_toggle_node)r>   eventr?   s      r0   _expand_node_on_selectzTree._expand_node_on_select  s)     zzd# r/   c                X    	 | j                   |   }|j                  S # t        $ r Y yw xY w)zGet the node for a given line.

        Args:
            line_no: A line number.

        Returns:
            A tree node, or ``None`` if there is no node at that line.
        Nr=  r?   r   )r>   line_nors   s      r0   get_node_at_linezTree.get_node_at_line  s7    	##G,D 99  		s    	))c                \    	 | j                   |   S # t        $ r t        d| d      dw xY w)zGet a tree node by its ID.

        Args:
            node_id: The ID of the node to get.

        Returns:
            The node associated with that ID.

        Raises:
            UnknownNodeID: Raised if the `TreeNode` ID is unknown.
        zUnknown NodeID (z	) in treeN)r   KeyErrorr2   )r>   node_ids     r0   get_node_by_idzTree.get_node_by_id  sA    	Q##G,, 	Q"27)9 EFDP	Qs    +c                H    t        |dt        | j                        dz
        S )zPrevent cursor line from going outside of range.

        Args:
            value: The value to test.

        Return:
            A valid version of the given value.
        r   rA   )r   rC   r=  r>   r2  s     r0   validate_cursor_linezTree.validate_cursor_line  s#     UAs4#3#34q899r/   c                    t        |dd      S )zRestrict guide depth to reasonable range.

        Args:
            value: The value to test.

        Return:
            A valid version of the given value.
           
   )r   r{  s     r0   validate_guide_depthzTree.validate_guide_depth$  s     UAr""r/   c                    | j                          | xj                  dz  c_        | j                  j                          | j	                  d       y)zInvalidate caches.rA   T)layoutN)rV  r_   r   rk   r   r=   s    r0   r   zTree._invalidate/  s:     		D!r/   c                `    |j                   j                  }|rd|v r|d   | _        y d| _        y )Nrs   r<   )rL  meta
hover_line)r>   rp  r  s      r0   _on_mouse_movezTree._on_mouse_move6  s,    {{FdN"6lDO DOr/   c                    d| _         y Nr<   )r  )r>   _s     r0   	_on_leavezTree._on_leave=  s	    r/   c                Z    | j                   }| xj                   dz  c_         t        |      S )zNCreate a new node ID.

        Returns:
            A unique node ID.
        rA   )r!  r"   )r>   rc   s     r0   rD  zTree._new_idA  s*     Abzr/   c                d    |dk(  ry 	 | j                   |   }|j                  S # t        $ r Y y w xY wr  rs  )r>   rs   	tree_lines      r0   	_get_nodezTree._get_nodeK  sA    2:	"((.I >>!  		s   # 	//c                    	 | j                   |   }|j                  | j                  | j                        }| j                  |j                        }t        |||d      S # t        $ r Y yw xY w)ai  Returns the region occupied by the label of the node at line `line`.

        This can be used, e.g., when scrolling to that line such that the label
        is visible after the scroll.

        Args:
            line: A line number.

        Returns:
            The region occupied by the label, or `None` if the
            line is not in the tree.
        NrA   )r=  r   rG   rD   rE   rS  r?   r   )r>   rs   r  region_xregion_widths        r0   _get_label_regionzTree._get_label_regionU  sn    	((.I --d.>.>O++INN;hlA66	  		s   A   	A,+A,c                    | j                  |      }|| j                  |       d|_        | j                  |      }|| j                  |       d|_        y y NFT)r  r   ru   )r>   previous_hover_liner  previous_noder?   s        r0   watch_hover_linezTree.watch_hover_linej  s[    ':;$}-#(M ~~j)t$DK r/   c                j   | j                  |      }| j                  |      }| j                  d| j                  _        |d|_        |d|_        || _        nd | _        ||k(  ry || j	                  |       |8| j	                  |       ||k7  r!| j                  | j                  |             y y y r  )r  r;  r{   r$  r   r   r  )r>   previous_liners   r  r?   s        r0   watch_cursor_linezTree.watch_cursor_lineu  s    }5~~d#').D&$&+M#!DN $D $DD  $}- t$$!!$"6"6t"<= % r/   c                $    | j                          y rg   )r   )r>   rD   s     r0   watch_guide_depthzTree.watch_guide_depth  s    r/   c                2    d| _         | j                          y r  )r`  r   )r>   rE   s     r0   watch_show_rootzTree.watch_show_root  s    r/   c                n    | j                  |      }|"| j                  ||d| j                  dd       yy)zyScroll to the given line.

        Args:
            line: A line number.
            animate: Enable animation.
        NTF)r_  forcecenterorigin_visiblex_axis)r  scroll_to_regioncenter_scroll)r>   rs   r_  regions       r0   scroll_to_linezTree.scroll_to_line  sJ     ''-!!))$ "  r/   c                N    |j                   }|dk7  r| j                  ||       yy)zScroll to the given node.

        Args:
            node: Node to scroll into view.
            animate: Animate scrolling.
        r<   r^  N)r`   r  )r>   r?   r_  rs   s       r0   ra  zTree.scroll_to_node  s,     zz2:g6 r/   c                    t        d|| j                  j                  z
  | j                  j                  d      }| j                  |       y)zbRefresh (repaint) a given line in the tree.

        Args:
            line: Line number.
        r   rA   N)r   scroll_offsetysizerF   r   )r>   rs   r  s      r0   r   zTree._refresh_line  s9     4$"4"4"6"66		KVr/   c                N    | j                  |      }|| j                  |       y y rg   )r  r   r>   rs   r?   s      r0   _refresh_node_linezTree._refresh_node_line  s)    ~~d#t$ r/   c                    | j                   j                  }| j                  j                  }| j                  |||z    }t        ||      D ]%  \  }}||j                  v s| j                  |       ' y)z[Refresh a node and all its children.

        Args:
            node: A tree node.
        N)r  r  r  heightr=  r,  r8   r   )r>   r?   scroll_yr  visible_linesrt  rs   s          r0   r   zTree._refresh_node  so     %%''!!((Hv4EF&}h? 	,MGTtyy ""7+	,r/   c                n    | j                   | j                          | j                   J | j                   S rg   )r#  _buildr=   s    r0   r=  zTree._tree_lines  s5    ""*KKM&&222&&&r/   c                   K   | j                   4 d{    | j                   ddd      d{    y7 !7 # 1 d{  7  sw Y   yxY ww)z#Check tree needs a rebuild on idle.N)lockr=  r>   rp  s     r0   _on_idlezTree._on_idle  sG      99 	 		 	 	 	 	 	 	s;   A5A9A7AAAA AAc                  	
 t         g j                  | j                  }	 	 	 	 	 	 	 	 dfd| j                  r g |d       n%| j                  j                  D ]  } g |d        | _        | j                  
| j                  | j                  	d	
fd}r t        D cg c]
  } ||       c}      }n| j                  j                  }t        |t                    | _        | j                  dk7  rH| j                  | j                  j                   | _        | j                  t              k\  rd| _        yyyc c}w )z=Builds the tree by traversing nodes, and creating tree lines.c                    g | |}t              |_          ||             |j                  r(t        |j                        D ]  \  }} |||        y y rg   )rC   r`   rZ   r   r[   )	r8   r?   r:   
child_pathr   TreeLineadd_liner4  liness	        r0   r4  zTree._build.<locals>.add_node  s`     '4JUDJXj$/0~~#,T^^#< 6KD%Z56 r/   Tc                N     | j                         | j                        z   S rg   )r?   rG   )rs   rS  rD   rE   s    r0   get_line_widthz#Tree._build.<locals>.get_line_width  s+    "499-0E0EY1  r/   r<   N)r8   r7   r?   rI   r:   r9   rH   r   )rs   z_TreeLine[TreeDataType]rH   rJ   )r6   appendr   rE   r[   r#  rD   rS  rB   r  rF   r   rC   virtual_sizer`  r;  r`   )r>   r   r?   r  rs   rF   r  r  r4  rS  rD   r  rE   s         @@@@@@@r0   r  zTree._build  sH    /1<<yy	6.	66L	6TX	6	6 	6 >>Rt$		++ )T4()"'&&NN	..	
 %@$-@AEIIOOE E
3r!+#'#3#3#9#9 3u:-#%  . " As   3Ec                L    | j                         | _        t        |   |      S rg   )get_pseudo_class_state_pseudo_class_stater   render_lines)r>   cropr  s     r0   r  zTree.render_lines  s$    #'#>#>#@ w#D))r/   c                    | j                   j                  }| j                  \  }}| j                  }| j	                  ||z   |||z   |      S rg   )r  rF   r  
rich_style_render_line)r>   r  rF   scroll_xr  rL  s         r0   render_linezTree.render_line  sP    		!//(  Lu	
 	
r/   c           	          j                   } j                  j                  }|t        |      k\  rt	        j
                  ||      S ||   } j                  dk\  xr t        d |j                  D              }||| j                   j                  t        d |j                  D              f}	|	 j                  v r j                  |	   }
ns j                  d      j                  j                  dk(  } j                  d      j                  j                  dk(  } j                  d      j                  j                  dk(  } j!                  dd      }| j!                  dd      z   }| j!                  dd      z   }|j                  d   j"                  }|j                  d   j$                  xr  j&                  }d fd	}|r j!                  d
      }n|}|t)        d|i      z  }t+        |      }|j,                  }|}d}|j                  dd  D ]x  }|}|r|}|}|r|}|} |||      \  }}}}|j.                  r|n|}||j                  d   k7  r
 |||       |xs |j"                  }|xs |j$                  xr  j&                  }z t        |j                        dkD  rA |||      \  }}}}|j0                  r|j-                  ||       n|j-                  ||        j!                  dd      }  j                  |k(  r|  j!                  dd      z  }  j2                  |k(  r|  j!                  dd      z  }  j5                  |j                  d   ||       j7                         }!|!j9                  t)        d|j:                  j<                  i             |j-                  |!       t?        |jA                   jB                  jD                              }"tG         jH                  j                  |      }#tK        |"d|#|jL                  z
  |      }"t	        |"      x}
 j                  |	<   |
jO                  ||      }
|
S )Nr   c              3  4   K   | ]  }|j                     y wrg   )ru   .0r?   s     r0   	<genexpr>z$Tree._render_line.<locals>.<genexpr>(  s     /R/R   c              3  4   K   | ]  }|j                     y wrg   )r_   r  s     r0   r  z$Tree._render_line.<locals>.<genexpr>0  s     6D$--6r  r   r   r   T)partialc                &   j                   rI|sGj                  d   }| j                  rj                  d   }n| j                  rj                  d   }nd}t	        dj
                  dz
        t        fd|D              }t        d|      S )	a%  Get the guide strings for a given style.

                Args:
                    style: A Style object.
                    hidden: Switch to hide guides (make them invisible).

                Returns:
                    Strings for space, vertical, terminator and cross.
                r   r   r   )r   r   r   r   r   r~  c              3  >   K   | ]  }|d     |d   z   d  yw)r   rA    Nr.   )r  
charactersrD   s     r0   r  z8Tree._render_line.<locals>.get_guides.<locals>.<genexpr>^  s2      $" "!}ojmk&A%B!D$s   tuple[str, str, str, str])show_guidesr   r   
underline2rB   rD   tupler   )rL  hiddenr  guide_linesrD   r>   s       @r0   
get_guidesz%Tree._render_line.<locals>.get_guidesI  s     ##F JJy1Ezz $

6 2)) $

8 44E!!T%5%5%9:# $&+$  7EEr/   r   rs   )r  )rL  rA   r<   r   r   r   Fr?   )rL  r   r  r9   rH   r  )(r=  r  rF   rC   r   blankr  anyr8   r_   r  r  r"  get_component_stylescoloraget_component_rich_styleru   r{   	has_focusr   r   r  r   r:   r`  rP  rF  rG  r?   rV   r+  renderappconsolerB   r  r   rR  r  )$r>   r  x1x2rK  
tree_linesrF   rs   is_hover	cache_keystripbase_hiddenhover_hiddenselected_hiddenbase_guide_styleguide_hover_styleguide_selected_stylery   r}   r  
line_styleguidesguides_appendguide_styler  r?   r   verticalr  guide
terminatorcrosslabel_stylerd   segments	pad_widths$   `                                   r0   r  zTree._render_line  s4   %%
		J;;uj11!}??a'RC/R		/R,R MM$$6DII66
	 ((($$Y/E 33NCIIKKqPK445IJPPRRVWWL))*ABHHJJaO   $<<  =   !143P3P$d 4Q 4 ! $4d6S6S' 7T 7 $  IIaL''Eyy|--@$..HF6 !::;QR
'
%fa[11J
+F"MMM*KF		!" K$"3K)F"6K,F(2;(G%xA!%8499R=(!%{;,$6JDNNK  499~!*4[&*I'1j%99MM*KM@MM%{M;77t7TK!#t<<%t  =    1$t<<"E  =    %%diimZMRRTEMM%fdiimm%<=>MM% FMM$((*:*:;<HD--33U;I!Y-H*UH27/AED$$Y/

2r"r/   c                    | j                   j                  |j                  j                         | j	                          y rg   )r"  growr  r  r   r  s     r0   
_on_resizezTree._on_resize  s,    ejj//0r/   c                x    |j                   sy |j                  r|j                          y |j                          y rg   )rR   r   r   r   rh  s     r0   ro  zTree._toggle_node  s)      MMOKKMr/   c                x  K   | j                   4 d {    |j                  j                  }d|v r\|d   }|j                  dd      r%| j	                  |      }|2| j                  |       n || _        | j                  d       d {    d d d       d {    y 7 7 7 	# 1 d {  7  sw Y   y xY ww)Nrs   r&   Fr   )r  rL  r  getru  ro  r`  
run_action)r>   rp  r  r`  r?   s        r0   	_on_clickzTree._on_click  s     99 	; 	;;;##D~"6l88He,00=D'))$/ (3D$///:::	; 	; 	; ;	; 	; 	; 	;sW   B:BB:A2B%	B!
B%B:B#B:!B%#B:%B7+B.,B73B:c                B    t         |           | j                          y rg   )r   notify_style_updater   )r>   r  s    r0   r  zTree.notify_style_update  s    #%r/   c                    | j                   dk(  r| j                  | _         n| xj                   dz  c_         | j                  | j                   d       y)zMove the cursor up one node.r<   rA   Fr^  N)r`  r>  r  r=   s    r0   action_cursor_upzTree.action_cursor_up  sF    r!#~~D!D,,e<r/   c                    | j                   dk(  rd| _         n| xj                   dz  c_         | j                  | j                   d       y)zMove the cursor down one node.r<   r   rA   Fr^  Nr`  r  r=   s    r0   action_cursor_downzTree.action_cursor_down  sB    r! D!D,,e<r/   c                    | j                   dk(  rd| _         | xj                   | j                  j                  dz
  z  c_         | j                  | j                          y)z-Move the cursor down a page's-worth of nodes.r<   r   rA   N)r`  scrollable_content_regionr  r  r=   s    r0   action_page_downzTree.action_page_down  sN    r! DD::AAAEED,,-r/   c                    | j                   dk(  r| j                  | _         | xj                   | j                  j                  dz
  z  c_         | j	                  | j                          y)z+Move the cursor up a page's-worth of nodes.r<   rA   N)r`  r>  r  r  r  r=   s    r0   action_page_upzTree.action_page_up  sR    r!#~~DD::AAAEED,,-r/   c                H    d| _         | j                  | j                          y)z'Move the cursor to the top of the tree.r   Nr  r=   s    r0   action_scroll_homezTree.action_scroll_home  s    D,,-r/   c                \    | j                   | _        | j                  | j                         y)z~Move the cursor to the bottom of the tree.

        Note:
            Here bottom means vertically, not branch depth.
        N)r>  r`  r  r=   s    r0   action_scroll_endzTree.action_scroll_end  s$      >>D,,-r/   c                    	 | j                   | j                     }| j                  |j                  d          y# t        $ r Y yw xY w)z-Toggle the expanded state of the target node.r<   N)r=  r`  ro  r8   r   )r>   rs   s     r0   action_toggle_nodezTree.action_toggle_node  sI    	-##D$4$45D diim,  		s   : 	AAc                    | j                   dk  ry	 | j                  | j                      }|j                  d   }| j                  t        j                  |             y# t        $ r Y yw xY w)zCause a select event for the target node.

        Note:
            If `auto_expand` is `True` use of this action on a non-leaf node
            will cause both an expand/collapse event to occur, as well as a
            selected event.
        r   Nr<   )r`  r=  r8   r   r   r  r   r  s      r0   action_select_cursorzTree.action_select_cursor  sl     a	7##D$4$45D 99R=Dd//56	  		s   A 	A+*A+c                v    | j                   }|+|j                  | j                  |j                  d       yyy)z#Move the cursor to the parent node.NTr^  )r;  rb   rd  r>   r;  s     r0   action_cursor_parentzTree.action_cursor_parent  s@    &&"{'9'9'E[//> (F"r/   c                    | j                   }|5|j                  (| j                  |j                  j                  d       yyy)z-Move the cursor to the parent's next sibling.NTr^  )r;  rb   rd  r   r  s     r0   !action_cursor_parent_next_siblingz&Tree.action_cursor_parent_next_sibling	  sF    &&"{'9'9'E[//<<dK (F"r/   c                    | j                   }|@|j                  }|| j                  |j                  d       y| j                  |d       yy)zTMove the cursor to previous sibling, or to the parent if there are no more siblings.NTr^  )r;  r   rd  rb   )r>   r;  r   s      r0   action_cursor_previous_siblingz#Tree.action_cursor_previous_sibling  sW    &&"*;;'  !3!3T B  !14 @ #r/   c                    | j                   }|Y|j                  }|7|j                  *|j                  j                  }| j                  |d       yy| j                  |d       yy)z]Move the cursor to the next sibling, or to the paren't sibling if there are no more siblings.NTr^  )r;  r   rb   rd  )r>   r;  r   parent_siblings       r0   action_cursor_next_siblingzTree.action_cursor_next_sibling  ss    &&"&33L#%%1%0%7%7%D%DN$$^T$B 2   t < #r/   c                   | j                   | j                   j                  y| j                   j                  }| j                   }t        d |D              r%|D ]  }|j                  s|j                          ! n$|D ]  }|j                  s|j                          ! | j                  | j                  |d       y)zExpand or collapse all siblings.

        If all the siblings are collapsed then they will be expanded.
        Otherwise they will all be collapsed.

        Nc              3  4   K   | ]  }|j                     y wrg   )r   )r  r   s     r0   r  z0Tree.action_toggle_expand_all.<locals>.<genexpr>4  s     8eu!!8r  Fr^  )	r;  rb   rq   allrR   r   r   call_after_refreshrd  )r>   rq   r;  r   s       r0   action_toggle_expand_allzTree.action_toggle_expand_all%  s     #t'7'7'>'>'F##,,&& 8x88! #%%LLN#
 " %%%NN$% 	 0 0+uMr/   rg   )rd   r   rY   r   r  
str | Nonerc   r-  r  r-  r  r9   rH   r   )r8  r6  r?   zTreeNode | NonerH   r   r   r   )rd   r   rH   r   )F)
rb   r   rd   r   rY   r   r   r9   rH   rI   )r?   rI   rK  r   rL  r   rH   r   )r?   rI   rH   rJ   r   r   )rd   r   rY   r   rH   r    )r?   r   r_  r9   rH   r   )rs   rJ   rH   r   )r?   r   rH   r   )rp  zNodeSelected[TreeDataType]rH   r   )rt  rJ   rH   r   )rx  r"   rH   rI   )r2  rJ   rH   rJ   )rp  zevents.MouseMoverH   r   )r  zevents.LeaverH   r   r   )rs   rJ   rH   r   )rs   rJ   rH   zRegion | None)r  rJ   r  rJ   rH   r   )r  rJ   rs   rJ   rH   r   )rD   rJ   rH   r   )rE   r9   rH   r   )T)rs   rJ   r_  r9   rH   r   )r?   rI   r_  r9   rH   r   )r?   rI   rH   r   )rH   zlist[_TreeLine[TreeDataType]])rp  zevents.IdlerH   r   )r  r   rH   zlist[Strip])r  rJ   rH   r   )
r  rJ   r  rJ   r  rJ   rK  r   rH   r   )rp  zevents.ResizerH   r   )rp  zevents.ClickrH   r   )Yr*   r+   r,   r-   rI  rH  r   r   rK   r   DEFAULT_CSSr   rE   r   r  r`  r  rD   rn  r  r   r   r$   r   r   r   r  r  re   r9  rL   r;  r>  rW   r   rP  rS  rV  rU  r\  rd  rf  ri  rl  r   rq  ru  ry  r|  r  r   r  r  rD  r  r  r  r  r  r  r  ra  r   r  r   r=  r  r  r  r  r  r  ro  r	  r  r  r  r  r  r  r  r  r  r   r"  r$  r'  r,  r
  r  s   @r0   r   r     s   @I75 	o/AN(%		
 	%(		
 	!$		
 	(?u=.0Hu	
 	k;U;}5A5-H) 8-) 
BKH I$RJXb-K74.K-15)K)d)K8JMJ


3E/ *" 12G """w017 """'"34g """w017 "( %) O
  " O O " O
  O  O  O  O 
 OD,&\ ! ! ) ). 
-
 
 "	

 
 
 
*8=FK	6'
.  DI1<@	"0$7
 $ $ Q"	:	#"!"7*	><& =A7*7597	7%
, ' '-&^*	
}~;==...
.-7$?LA
=Nr/   r   )	can_focus)Er-   
__future__r   dataclassesr   typingr   r   r   r   r	   r
   r   	rich.reprrich
rich.styler   r   	rich.textr   r   textualr   r    textual._immutable_sequence_viewr   textual._loopr   textual._segment_toolsr   textual.bindingr   r   textual.cacher   textual.geometryr   r   r   textual.messager   textual.reactiver   r   textual.scroll_viewr   textual.stripr   typing_extensionsr    r!   rJ   r"   r#   r$   r%   rK   	from_metarJ  	Exceptionr(   r2   r4   r6   rN   r0  autorP   r   r.   r/   r0   <module>rF     s:    " ! U U U  ( $  B # + 0 " 0 0 # * * 1	3	 P~& R/0  4i 3u$/0li lhI hP9 P %  81%&>? 1 f-w|$ f- f-RzN7< * zNr/   