
    AHj2                    h   U d dl mZ d dlmZ d dlmZmZmZmZ d dl	m
Z
 d dlmZ d dlmZmZmZ d dlmZ erd dlmZ d d	lmZ d
ZdZi dddddddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d,d-Zd.ed/<   i dd0dd0dd0dd0dd0dd0dd0dd0dd0dd0dd1dd0d!d0d#d2d%d0d'd0d)d3d3d4d4d-Zd5ed6<   d7d8d9Zd:ed;<   ej;                         D  ci c]  \  } }| |d    d
   |d   d
   f c}} Zd<ed=<    ed> ed?            Z eeef   Z!d@edA<   eee
e
e
f   ee
e
e
f   ee
e
e
f   f   Z"d@edB<   eeeeef   Z#d@edC<    edDE      Z$ edFG      	 	 	 	 	 	 	 	 	 	 dPdH       Z%	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dQdIZ&	 dR	 	 	 	 	 	 	 	 	 	 	 	 	 dSdJZ'dddKZ(dLedM<   dTdNZ)yOc c}} w )U    )annotations)	lru_cache)TYPE_CHECKINGIterableTuplecast)Segment)Color)AlignHorizontal	EdgeStyleEdgeType)Style)	TypeAlias)Content       ) r   r   r   r   ascii)+-r   )|r   r   r   nonehiddenblankround))u   ╭   ─u   ╮   │r   r!   )u   ╰r   u   ╯solid))u   ┌r   u   ┐r    )u   └r   u   ┘double))u   ╔   ═u   ╗)   ║r   r%   )u   ╚r$   u   ╝dashed))   ┏   ╍   ┓)   ╏r   r*   )   ┗r(      ┛heavy))r'      ━r)   )   ┃r   r/   )r+   r.   r,   inner))u   ▗   ▄u   ▖)   ▐r      ▌)u   ▝   ▀u   ▘outer))u   ▛r4   u   ▜)r3   r   r2   )u   ▙r1   u   ▟thick))   █r4   r7   r7   r   r7   )r7   r1   r7   block))r1   r1   r1   r8   )r4   r4   r4   hkey)   ▔r<   r<   r      ▁r>   r>   vkey)u   ▏r   u   ▕r@   r@   tall))   ▊r<      ▎rB   r   rC   rB   r>   rC   ))rB   r7   rC   rD   rE   )r=   )rC   r   rB   r;   )paneltabwidezWdict[EdgeType, tuple[tuple[str, str, str], tuple[str, str, str], tuple[str, str, str]]]BORDER_CHARS)r   r   r   rJ   rJ   )r   r   r   rK   rK   )rK   rJ   rK   )r   r   r   rL   rL   )rK   )r   r      rK   zWdict[EdgeType, tuple[tuple[int, int, int], tuple[int, int, int], tuple[int, int, int]]]BORDER_LOCATIONS)TF)TT)rF   rG   zdict[str, tuple[bool, bool]]BORDER_TITLE_FLIPzdict[EdgeType, tuple[int, int]]BORDER_LABEL_LOCATIONSzfrozenset[EdgeType])r   r   r   r   BorderValueBoxSegmentsBordersTreversei   )maxsizec           	     2   t         }t        |    \  \  }}}\  }}	}
\  }}}t        |    \  \  }}}\  }}}\  }}}||z   }||z   }|j                  |j                  t	        |j
                  |j                  d      j                  t	        |j
                  |j                  d      j                  f} ||||          ||||          ||||         f ||||          ||	||          ||
||         f ||||          ||||          ||||         ffS )a  Get segments used to render a box.

    Args:
        name: Name of the box type.
        inner_style: The inner style (widget background).
        outer_style: The outer style (parent background).
        style: Widget style.

    Returns:
        A tuple of 3 Segment triplets.
    TrT   )r	   rI   rN   
rich_styler   
background
foreground)nameinner_styleouter_stylestyle_Segmenttop1top2top3mid1mid2mid3bottom1bottom2bottom3ltop1ltop2ltop3lmid1lmid2lmid3lbottom1lbottom2lbottom3r0   r5   styless                             G/root/tools/cai/cai_env/lib/python3.12/site-packages/textual/_border.pyget_boxrt   
  sj   $ H
 	T	tTtT#'7 		uu&8X %E%E 	e 0 0$?JJe 0 0$?JJ	F T6%=)T6%=)T6%=)	
 T6%=)T6%=)T6%=)	
 WfX./WfX./WfX./	
     c	              #    K   ||z   }	d|	z  }
| \  }}|j                   r||
k  ry|j                  ||
z
  d      }|r|j                  d      }|r|j                  d      }|j	                  |      }t
        |   |rdnd   }t        j                  |d      \  }}||z   }||z   }|dk(  r|}nZ|dk(  r|}nR|dk(  r#t        |j                  |j                  d      }n*|d	k(  r#t        |j                  |j                  d      }nJ |r|s|r0|s.|j                  t        |j                  |j                  
      z   }|j                  |      }|E d{    y7 w)aI  Render a border label (the title or subtitle) with optional markup.

    The styling that may be embedded in the label will be reapplied after taking into
    account the inner, outer, and border-specific, styles.

    Args:
        label: Tuple of label and style to render in the border.
        is_title: Whether we are rendering the title (`True`) or the subtitle (`False`).
        name: Name of the box type.
        width: The width, in cells, of the space available for the whole edge.
            This is the total space that may also be needed for the border corners and
            the whitespace padding around the (sub)title. Thus, the effective space
            available for the border label is:
            - `width` if no corner is needed;
            - `width - 2` if one corner is needed; and
            - `width - 4` if both corners are needed.
        inner_style: The inner style (widget background).
        outer_style: The outer style (parent background).
        style: Widget style.
        console: The console that will render the markup in the label.
        has_left_corner: Whether the border edge will have to render a left corner.
        has_right_corner: Whether the border edge will have to render a right corner.

    Returns:
        A list of segments that represent the full label and surrounding padding.
    r   NT)ellipsisr   r   )FFrT   rM   )rY   rZ   )cell_lengthtruncatepad_left	pad_rightstylize_beforerP   rO   getr   rY   rZ   without_colorrender_segments)labelis_titler[   widthr\   r]   r^   has_left_cornerhas_right_cornercorners_neededcells_reserved
text_labellabel_stylelabel_style_locationflip_topflip_bottomr0   r5   
base_stylesegmentss                       rs   render_border_labelr   F  s|    L %'77N'N#J!!Un%<$$U^%;d$KJ((+
))!,
**;7J1$7X1M-11$GHk%E%E q 
		"
		"5++U-=-=tL
		"5++U-=-=tL
uX;x--!,,!,,1
 


 ))*5Hs   EEEEc              #    K   | \  }}}||z   }	t        |      }
t        d |
D        d      }t        d||	z
  |z
        }|r| |s|
E d{    n%|s&t        |j                  |z  |j
                         n|dk(  s|dk(  rt        |j                  |dz
  z  |j
                        }|dk(  r1t        |j                  |j
                         |
E d{    | n| |
E d{    t        |j                  |j
                         nf|dk(  r_|dz  }||z
  }t        |j                  |z  |j
                         |
E d{    t        |j                  |z  |j
                         nJ |r| yy7 47 7 7 ;w)	a  Compose a box row with its padded label.

    This is the function that actually does the work that `render_row` is intended
    to do, but we have many lists of segments flowing around, so it becomes easier
    to yield the segments bit by bit, and the aggregate everything into a list later.

    Args:
        box_row: Corners and side segments.
        width: Total width of resulting line.
        left: Render left corner.
        right: Render right corner.
        label_segments: The segments that make up the label.
        label_alignment: Where to horizontally align the label.

    Returns:
        An iterable of segments.
    c              3  4   K   | ]  }|j                     y w)N)rx   ).0segments     rs   	<genexpr>zrender_row.<locals>.<genexpr>  s     O++Os   r   Nleftrightr   centerr   )listsummaxr	   textr^   )box_rowr   r   r   label_segmentslabel_alignmentbox1box2box3r   label_segments_listlabel_lengthspace_availableedgelength_on_leftlength_on_rights                   rs   
render_rowr     s    2 D$E\N~.O;NOQRSL!U^3lBCO
&&&dii/14::>>	F	"o&@tyyOa$78$**Ef$$))TZZ00***JJ***$))TZZ00	H	$(A-)N:dii.0$**==&&&dii/14::>>u
 - 	' + + 	'sJ   A	FE?B
FFF)F*A F
F5FFFF)r   r   zdict[EdgeType, EdgeType]_edge_type_normalization_tablec                D    t         j                  | d   | d         | d   fS )Nr   r   )r   r}   )values    rs   normalize_border_valuer     s&    )--eAhaA58KKru   N)
r[   r   r\   r   r]   r   r^   r   returnrR   )r   ztuple[Content, Style]r   boolr[   r   r   intr\   r   r]   r   r^   r   r   r   r   r   r   Iterable[Segment])r   )r   z tuple[Segment, Segment, Segment]r   r   r   r   r   r   r   r   r   r   r   r   )r   rQ   r   rQ   )*
__future__r   	functoolsr   typingr   r   r   r   rich.segmentr	   textual.colorr
   textual.css.typesr   r   r   textual.styler   typing_extensionsr   textual.contentr   INNEROUTERrI   __annotations__rN   rO   itemsrP   	frozensetINVISIBLE_EDGE_TYPESrQ   rR   rS   REVERSE_STYLErt   r   r   r   r   )	edge_type	locationss   00rs   <module>r      s   "  7 7    B B +'		g  	g  g  g$  %g.  /g8  9gB  CgL  MgV  Wg`  agj  kgt  ug~  gH  IgR  Sg\  ]gf  ggp

Eg   i`e 	e  e  e   !e*  +e4  5e>  ?eH  IeR  Se\  ]ef  gep  qez  {eD  EeN  OeX  Yeb  cel

Ae   gZ 3 /  !1 6 6 8;	9 	!Q1a11; 7 
 19=S3TU x/Y /	'7G
#$	'7G
#$	'7G
#$&Y  9iIEF Fd# 48
88 8 	8
 8 8vN NN N 	N
 N N N N N Nn (.<-<< < 	<
 &< %< <D 	<  8 LQ;s   %F.