
    AHjT              
          U d Z ddlmZ ddlZddlmZmZ ddlmZ ddl	m
Z
mZmZmZmZ ddlZddlmZ ddlmZ dd	lmZ dd
l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& ddl'm(Z( ddl)m*Z* ddl+m,Z, ddl-m.Z.m/Z/ ddl0m1Z1 ddl2m3Z3 ddl4mZ ddl5m6Z6m7Z7m8Z8 g dZ9ede:f   Z;de<d<   	 edee:f   Z=de<d<   	  e e,ddddd       e,ddddd            Z>	  e       Z?	  ej                  d       ZAg d!ZBd"e<d#<   eBD  ci c]  } | d c} ZCd"e<d$<   eCf	 	 	 	 	 d-d%ZDej                  j                   G d& d'e             ZGej                  j                  e G d( de8                    ZH G d) d*      ZI eHd+      ZJd"e<d,<   yc c} w ).a}  
Content is a container for text, with spans marked up with color / style.
It is equivalent to Rich's Text object, with support for more of Textual features.

Unlike Rich Text, Content is *immutable* so you can't modify it in place, and most methods will return a new Content instance.
This is more like the builtin str, and allows Textual to make some significant optimizations.

    )annotationsN)cached_propertytotal_ordering)
itemgetter)CallableIterable
NamedTupleSequenceUnion)divide_line)set_cell_size)Console)Segment)Style)TerminalTheme)Text)Final	TypeAliascell_len)
active_app)	loop_last)	FIFOCache)Color)	TextAlignTextOverflow)	Selection)Strip)RenderOptionsRulesMapVisual)ContentTypeContentSpanr#   r   r"   ContentText)ansi)
background
foregroundz\s+$)               r   _STRIP_CONTROL_CODES_CONTROL_STRIP_TRANSLATEc                $    | j                  |      S )zRemove control codes from text.

    Args:
        text (str): A string possibly contain control codes.

    Returns:
        str: String with control codes removed.
    )	translate)text_translate_tables     G/root/tools/cai/cai_env/lib/python3.12/site-packages/textual/content.py_strip_control_codesr6   D   s     >>*++    c                  @    e Zd ZU dZded<   ded<   ded<   d
dZddZy	)r$   z0A style applied to a range of character offsets.intstartendStyle | strstylec              #  d   K   | j                    | j                   d| j                  f y w)Nr=   )r:   r;   r=   selfs    r5   __rich_repr__zSpan.__rich_repr__Z   s(     jjhhtzz!!   .0c                6    |r| \  }}}t        |||z   |      S | S )zExtend the span by the given number of cells.

        Args:
            cells (int): Additional space to add to end of span.

        Returns:
            Span: A span.
        )r$   )r@   cellsr:   r;   r=   s        r5   extendzSpan.extend_   s+      $E3sU{E22r7   Nreturnzrich.repr.Result)rD   r9   rG   z'Span')__name__
__module____qualname____doc____annotations__rA   rE    r7   r5   r$   r$   R   s    :J	H"
r7   r$   c            	      "   e Zd ZdZg dZddddZ	 	 	 dM	 	 	 	 	 	 	 dNd	ZdOd
ZedOd       Z	e
dPd       Ze
	 dQ	 	 	 	 	 dRd       Ze
dSd       Ze
	 dT	 	 	 	 	 dUd       Ze
	 	 dV	 	 	 	 	 	 	 dWd       Ze
dd	 	 	 	 	 dXd       ZdPdZdYdZdZdZdZdZd[dZd\dZd]dZd^dZddddddddej4                  f		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d_dZ	 	 	 	 	 	 	 	 	 	 d`d Zdad!Zdbd"Zdad#Zdcd$Z e!ddd%       Z"e!dad&       Z#e!dOd'       Z$e!dPd(       Z%e!dPd)       Z&ded*Z'dfd+Z(dfd,Z)e
dgd-       Z*dhd.Z+didjd/Z,dkd0Z-ddd1	 	 	 	 	 	 	 dld2Z.dmd3Z/ddd4	 	 	 	 	 dnd5Z0dodpd6Z1dodpd7Z2dodpd8Z3dodqd9Z4drdsd:Z5drdsd;Z6dtdud<Z7	 dv	 	 	 	 	 	 	 dwd=Z8	 	 dv	 	 	 	 	 	 	 dwd>Z9 ejt                         d?df	 	 	 	 	 	 	 dxd@Z; ejt                         df	 	 	 	 	 dydAZ<dB Z=dzdCZ>d{dDZ?	 d|dddE	 	 	 	 	 	 	 d}dFZ@dTd~dGZAddHZBddIZCdddJZDddK	 	 	 	 	 	 	 ddLZEy)r#   zText content with marked up spans.

    This object can be considered immutable, although it might update its internal state
    in a way that is consistent with immutability.

    )_text_spans_cell_lengthleftrightfull)r:   r;   justify Nc                    t        |      | _        |g n|| _        || _        d| _        d| _        d| _        d| _        d| _        y)z
        Initialize a Content object.

        Args:
            text: text content.
            spans: Optional list of spans.
            cell_length: Cell length of text if known, otherwise `None`.
        N)Nr   )	r6   rO   rP   rQ   _optimal_width_cache_minimal_width_cache_height_cache_divide_cache_split_cache)r@   r3   spanscell_lengths       r5   __init__zContent.__init__|   sW     /t4
(-"5'04!04!GP  	  	r7   c                    | j                   S NrO   r?   s    r5   __str__zContent.__str__   s    zzr7   c                   ddl m} g }| j                  }dgd | j                  D        d | j                  D        t	        |      ddf}|j                  t        dd      	       d}|j                  }|D ]5  \  }}}	||kD  r | ||||              |}|	s" ||rd
|	 dnd|	 d       7 dj                  |      }
|
S )z~Get content markup to render this Text.

        Returns:
            str: A string potentially creating markup tags.
        r   )escape)r   FNc              3  N   K   | ]  }|j                   d |j                  f  ywFN)r:   r=   .0spans     r5   	<genexpr>z!Content.markup.<locals>.<genexpr>   s     F$tzz5$**-F   #%c              3  N   K   | ]  }|j                   d |j                  f  ywTN)r;   r=   rh   s     r5   rk   z!Content.markup.<locals>.<genexpr>   s     Cttxxtzz*Crl   TN   keyz[/][rV   )	textual.markupre   plainrP   lensortr   appendjoin)r@   re   outputru   markup_spanspositionrx   offsetclosingr=   markups              r5   r   zContent.markup   s     	*


F$++F
 Dt{{C
 Zt$	
 	jA./&2 	C"FGU veHV456!E7!}qq\B	C r7   c                    t         S )zGet an empty (blank) content)EMPTY_CONTENT)clss    r5   emptyzContent.empty   s
     r7   c                    t        |t              r|S t        |t              r|r| j                  |      S  | |      S t        |t              r| j                  |      S t        d      )a  Construct content from Text or str. If the argument is already Content, then
        return it unmodified.

        This method exists to make (Rich) Text and Content interchangeable. While Content
        is preferred, we don't want to make it harder than necessary for apps to use Text.

        Args:
            markup_content_or_text: Value to create Content from.
            markup: If `True`, then str values will be parsed as markup, otherwise they will
                be considered literals.

        Raises:
            TypeError: If the supplied argument is not a valid type.

        Returns:
            A new Content instance.
        zAThis method expects a str, a Text instance, or a Content instance)
isinstancer#   strfrom_markupr   from_rich_text	TypeError)r   markup_content_or_textr   s      r5   	from_textzContent.from_text   sl    * ,g6)).4'=>>122.5%%&<==S r7   c                    d}t        |t              r|rt        d      |S t        |      }ddlm}  |||xs d      }|S )a3  Create content from markup, optionally combined with template variables.

        If `markup` is already a Content instance, it will be returned unmodified.

        See the guide on [Content](../guide/content.md#content-class) for more details.


        Example:
            ```python
            content = Content.from_markup("Hello, [b]$name[/b]!", name="Will")
            ```

        Args:
            markup: Content markup, or Content.
            **variables: Optional template variables used

        Returns:
            New Content instance.
        Tz4A literal string is require to substitute variables.r   )
to_contentN)template_variables)r   r#   
ValueErrorr6   rt   r   )r   r   	variables_rich_traceback_omitr   contents         r5   r   zContent.from_markup   sK    *  $fg& !WXXM%f--V	8ITJr7   c                   t        |t              rt        j                  |      }d}||j                  }n+	 t        j                         }|j                  j                  }|j                  r	 t        j                         j                  }|j                  D cg c]S  \  }}}t        ||t        |t              rt        j                   ||      |      nt        j                  ||            U }	}}}ng }	 | |j                   |	      }
|j"                  rt	 t        j                         j                  }|
j%                  t        |j"                  t              r|j"                  nt        j                  |j"                  |            }
|
S # t        $ r t        j                  }Y Kw xY w# t        $ r d}Y 2w xY wc c}}}w # t        $ r d}Y w xY w)a  Create equivalent Visual Content for str or Text.

        Args:
            text: String or Rich Text.
            console: A Console object to use if parsing Rich Console markup, or `None` to
                use app default.

        Returns:
            New Content.
        N)r   r   r   r   	get_styler   getconsoleLookupError	RichStyleparserP   
ansi_themer$   r   from_rich_styleru   r=   stylize_before)r   r3   r   r   r   appr:   r;   r=   r]   r   s              r5   r   zContent.from_rich_text   s    dC ##D)D+/
))I2 nn&  KK11	;;"'^^-88
 *.  &E3  &eS1 --i.>
K"225*EE  Edjj%(::"'^^-88
 ,,djj#. 

**4::zBG
 I  ,%OO	,  "!
"&  "!
"s<   F /F1 AGG
 F.-F.1G ?G 
GGc           	     p    |st        d      S  | ||rt        dt        |      |      g      }|S d      }|S )a  Create a Content instance from text and an optional style.

        Args:
            text: String content.
            style: Desired style.
            cell_length: Cell length of text if known, otherwise `None`.

        Returns:
            New Content instance.
        rV   r   N)r#   r$   rv   )r   r3   r=   r^   new_contents        r5   styledzContent.styled>  sG    " 2;$uaTE!: ;O KOOr7   r;   c                  g }g }t         }|j                  }d}|D ]  }t        |t              r ||       |t	        |      z  }+t        |t
              rC|\  }	}
 ||	       |
r%|j                   |||t	        |	      z   |
             |t	        |	      z  }~t        |t              s ||j                         |j                  r?|j                  |j                  D cg c]  \  }}} |||z   ||z   |       c}}}       |t	        |j                        z  } r ||        | dj                  |      |      S c c}}}w )a  Construct new content from string, content, or tuples of (TEXT, STYLE).

        This is an efficient way of constructing Content composed of smaller pieces of
        text and / or other Content objects.

        Example:
            ```python
            content = Content.assemble(
                Content.from_markup("[b]assemble[/b]: "),  # Other content
                "pieces of text or content into a",  # Simple string of text
                ("a single Content instance", "underline"),  # A tuple of text and a style
            )
            ```

        Args:
            *parts: Parts to join to gether. A *part* may be a simple string, another Content
            instance, or tuple containing text and a style.
            end: Optional end to the Content.
        r   rV   )r$   rx   r   r   rv   tupler#   ru   r]   rE   ry   )r   r;   partsr3   r]   _Spantext_appendr|   part	part_text
part_styler:   r=   s                r5   assemblezContent.assembleT  s=   . kk 	,D$$D!CI%D%((,%	:I&LLh3y>(A:N C	N*D'*DJJ'::LL 6:ZZ  1sE "%("2C(NEJ C

O++	,, 2774=%((s   #Ec                h   | j                   x}s| S t        ddd      }g }d}|D ]z  }|j                  |j                  k(  rL|j                  |j                  k(  r3t        |j                  |j                  |j                        x}|d<   d}h|j                  |       |}| |r|| j                   dd | S )a  Simplify spans by joining contiguous spans together.

        This can produce faster renders but typically only worth it if you have appended a
        large number of Content instances together.

        Note that this modifies the Content instance in-place, which might appear
        to violate the immutability constraints, but it will not change the rendered output,
        nor its hash.

        Returns:
            Self.
        r&   rV   FTN)rP   r$   r:   r;   r=   rx   )r@   r]   	last_span	new_spanschangedrj   s         r5   simplifyzContent.simplify  s     $$KR$	 "	 	!DzzY]]*tzzY__/L,0$((DJJ,WW	IbM  & 		! &DKKNr7   c                h    |r/t        | j                  g | j                  || j                        S | S )zAdds spans to this Content instance.

        Args:
            spans: A sequence of spans.

        Returns:
            A Content instance.
        )r#   ru   rP   rQ   )r@   r]   s     r5   	add_spanszContent.add_spans  s4     4::'='=u'=t?P?PQQr7   c                    t        |t              r| j                  |k(  S t        |t              r| j                  |j                  k(  S t        S )z:Compares text only, so that markup doesn't effect sorting.r   r   ru   r#   NotImplementedr@   others     r5   __eq__zContent.__eq__  s>    eS!::&&w'::,,r7   c                    t        |t              r| j                  |k  S t        |t              r| j                  |j                  k  S t        S ra   r   r   s     r5   __lt__zContent.__lt__  s>    eS!::%%eW%::++r7   c                r    | |u ry| j                   |j                   k7  ry| j                  |j                  k(  S )a  Compare to another Content object.

        Two Content objects are the same if their text *and* spans match.
        Note that if you use the `==` operator to compare Content instances, it will only consider
        the plain text portion of the content (and not the spans).

        Args:
            content: Content instance.

        Returns:
            `True` if this is identical to `content`, otherwise `False`.
        TF)ru   r]   r@   r   s     r5   is_samezContent.is_same  s4     7?::&zzW]]**r7   c                    | j                   3t        d | j                  j                  d      D              x| _         }n| j                   }||j	                  dd      dz  z   S )a  Get optimal width of the Visual to display its content.

        The exact definition of "optimal width" is dependant on the Visual, but
        will typically be wide enough to display output without cropping or wrapping,
        and without superfluous space.

        Args:
            rules: A mapping of style rules, such as the Widgets `styles` object.

        Returns:
            A width in cells.

        c              3  2   K   | ]  }t        |        y wra   r   )ri   lines     r5   rk   z,Content.get_optimal_width.<locals>.<genexpr>  s      4#'4s   
line_padr      )rX   maxru   splitr   )r@   rulescontainer_widthwidths       r5   get_optimal_widthzContent.get_optimal_width  sh     $$,03 4+/::+;+;D+A4 1 D% --EuyyQ/!333r7   c                    | j                   j                         sy| j                  2t        d | j                   j	                         D              x| _        }n| j                  }||j                  dd      dz  z   S )z)Minimal width is the largest single word.r   c              3  |   K   | ]4  }|j                         D ]  }|j                         rt        |       ! 6 y wra   )r   stripr   )ri   r   words      r5   rk   z,Content.get_minimal_width.<locals>.<genexpr>  s@      4 JJL4 ::< 44s   :<r   r   )ru   r   rY   r   
splitlinesr   )r@   r   r   s      r5   get_minimal_widthzContent.get_minimal_width  sw    zz!$$,03 4 JJ1134 1 D% --EuyyQ/!333r7   c                    |j                   } |dd      dz  } |dd      } |dd      dk(  }||z   ||f}| j                  d   |k(  r| j                  d	   }|S | j                  j                  ||z
  ||
      }	t	        |	      }||f| _        |S )a  Get the height of the Visual if rendered at the given width.

        Args:
            rules: A mapping of style rules, such as the Widgets `styles` object.
            width: Width of visual in cells.

        Returns:
            A height in lines.
        r   r   r   text_overflowfold	text_wrapwrapnowrapro   )overflowno_wrap)r   rZ   without_spans_wrap_and_formatrv   )
r@   r   r   get_ruler   r   r   	cache_keyheightliness
             r5   
get_heightzContent.get_height  s     99J*Q.OV4;/8;X%x9	a I-''*F  &&77 8W 8 E ZF"+V!4Dr7   r   Fr   r+   c                |   g }||j                   }ndd}t        | j                  d            D ]  \  }}|	|j                  |	      }|< ||      x}2|\  }}|dk(  rt	        |j
                        }|j                  |||      }|j                  |      }|r|dk(  rQt        t        d|j                  |            dd }|j                  |      D cg c]  }t        |
||||	       }}n%|j                  ||d
k(        }t        |
||||	      }|g}nt        |
||||	      }t        |j
                  ||dz  z
  |dk(        }|j                  j                  |      }|d
k(  }t        |      D cg c];  \  }}|r|j                  ||      n |j!                         j                  ||      = }}}t#        |dg|      D cg c]5  \  }}t        |
|j%                  |      j'                  ||      ||||      7 }}}d|d   _        |j+                  |        |S c c}w c c}}w c c}}w )a  Wraps the text and applies formatting.

        Args:
            width: Desired width.
            align: Text alignment.
            overflow: Overflow method.
            no_wrap: Disabled wrapping.
            tab_size: Cell with of tabs.
            selection: Selection information or `None` if no selection.
            selection_style: Selection style, or `None` if no selection.

        Returns:
            List of formatted lines.
        Nc                     y ra   rM   )ys    r5   get_spanz*Content._wrap_and_format.<locals>.get_span6  s    r7   T)allow_blankr&   r   r   ro   )r   alignellipsisr   r   )r   )r   )r   r9   rG   ztuple[int, int] | None)r   	enumerater   stylizerv   ru   expand_tabslistranger^   divide_FormattedLinetruncater   r   r   rstripzip
rstrip_endpadline_endrE   )r@   r   r   r   r   r   tab_size	selectionselection_style
post_styler   output_linesr   r   r   rj   r:   r;   cuts	new_linescontent_lineoffsetsdivided_linesr   lastr   r}   s                              r5   r   zContent._wrap_and_format  s   6 .0  ))H !!=> 6	+GAt%||J/*0C/P!
s"9djj/C||OUC@##H-Dv%a)9)95 AB12FD %)KK$5!  'y$%P!I !
  ==Z9O=PD#1!4!5$L ".I-iuQVW%JJ1 48v;M !- 4 4 ; ;G D#z1 '0&>! #d   eh?![[]33EH3MN! !$ ,/}qm7m+L
 ( #!**5155hI#
	 
 *.	"&	*m6	+p S!"!
s   H-;A H2:H8c                ^   |sg S |j                   j                  }| j                  | |dd       |dd       |dd      dk(   |dd	      d
|j                  |j                  |j
                  |j                  
      }||d| }|D cg c]  }t        |j                  |        }}|S c c}w )am  Render the Visual into an iterable of strips. Part of the Visual protocol.

        Args:
            width: Width of desired render.
            height: Height of desired render or `None` for any height.
            style: The base style to render on top of.
            options: Additional render options.

        Returns:
            An list of Strips.
        
text_alignrR   r   r   r   r   r   r   r   r+   )	r   r   r   r   r   r   r   r   r   N)	r   r   r   r   r   r   r   r   to_strip)	r@   r   r   r=   optionsr   r   r   strip_liness	            r5   render_stripszContent.render_stripss  s     I==$$%%<0ov6[&1X=j!,''#33))'' & 
 '6NE@EFudmmE23FF Gs   B*c                ,    t        | j                        S ra   )rv   ru   r?   s    r5   __len__zContent.__len__  s    4::r7   c                     | j                   dk7  S )NrV   rb   r?   s    r5   __bool__zContent.__bool__  s    zzRr7   c                ,    t        | j                        S ra   )hashrO   r?   s    r5   __hash__zContent.__hash__  s    DJJr7   c              #  j   K   	 | j                    d| j                  g f y # t        $ r Y y w xY ww)Nr]   )rO   rP   AttributeErrorr?   s    r5   rA   zContent.__rich_repr__  s7     	**4;;** 		s   3$ 3	0303c                    | j                   S )zA sequence of spans used to markup regions of the content.

        !!! warning
            Never attempt to mutate the spans, as this would certainly break the output--possibly
            in quite subtle ways!

        )rP   r?   s    r5   r]   zContent.spans  s     {{r7   c                f    | j                   t        | j                        | _         | j                   S )zThe cell length of the content.)rQ   r   ru   r?   s    r5   r^   zContent.cell_length  s-     $ ( 4D   r7   c                    | j                   S )z Get the text as a single string.rb   r?   s    r5   ru   zContent.plain  s     zzr7   c                `    | j                   r!t        | j                  g | j                        S | S )zThe content with no spans)rP   r#   ru   rQ   r?   s    r5   r   zContent.without_spans  s)     ;;4::r4+<+<==r7   c                ^    d| j                   vr| S | d| j                   j                  d       S )zThe first line of the content.r   N)ru   indexr?   s    r5   
first_linezContent.first_line  s2     tzz!K,djj&&t,--r7   c                     d fd}t        |t              r ||      S |j                  t         j                              \  }}}|dk(  r j                  ||g      }|d   S t        d      )Nc                    t         }t        j                  |    j                  D cg c]  \  }}}|| cxkD  r|k\  rn n
 |dd|        c}}}      }|S c c}}}w )Nr   ro   )r]   )r$   r#   ru   rP   )r}   r   r:   r;   r=   r   r@   s         r5   get_text_atz(Content.__getitem__.<locals>.get_text_at  sg    E

6" .2[[ )sEV,u, !Q&G Ns   #Aro   z%slices with step!=1 are not supported)r}   r9   rG   z	'Content')r   r9   indicesrv   ru   r   r   )r@   slicer  r:   stopstepr   s   `      r5   __getitem__zContent.__getitem__  sl    
	 eS!u%% %c$**o >E4qyUDM2Qx   GHHr7   c                   t        |t              r#t        | j                  |z   | j                        S t        |t              rt        | j                        }t        | j                  |j                  z   | j                  |j                  D cg c]  \  }}}t        ||z   ||z   |       c}}}z   | j                  |j                  z         }|S t        S c c}}}w ra   )
r   r   r#   rO   rP   rv   ru   r$   r^   r   )r@   r   r}   r:   r;   r=   r   s          r5   __add__zContent.__add__  s    eS!4::-t{{;;eW%_F

U[[(KK 27 -E3 UV^S6\5A !!E$5$55
G Ns   Cc                D    t        |t        t        f      st        S | |z   S ra   )r   r#   r   r   r   s     r5   __radd__zContent.__radd__  s     %'30!!e|r7   c           
         t        |      }t        }|D cg c]T  }|j                  |k  rC|j                  |k  r|n1 ||j                  t	        ||j                        |j
                        V }}|S c c}w )z=Remove or modify any spans that are over the end of the text.)rv   r$   r:   r;   minr=   )r   r3   r]   
max_offsetr   rj   s         r5   _trim_spanszContent._trim_spans   s~     Y
 
 zzJ&	 88j( 4::s:txx'@$**MN
 
 
s   AA3c                    t        |t              rMt        | j                   | | j                  | j
                  d      S | j
                  t        |      z         S t        d      j                  | |g      S )a!  Append text or content to this content.

        Note this is a little inefficient, if you have many strings to append, consider [`join`][textual.content.Content.join].

        Args:
            content: A content instance, or a string.

        Returns:
            New content.
        NrV   )r   r   r#   ru   rP   rQ   r   ry   r   s     r5   rx   zContent.append  s     gs#::,wi( ((0 	  **Xg->>  r{w00r7   c                L    | j                  t        j                  ||            S )zAppend text give as a string, with an optional style.

        Args:
            text: Text to append.
            style: Optional style for new text.

        Returns:
            New content.
        )rx   r#   r   )r@   r3   r=   s      r5   append_textzContent.append_text'  s     {{7>>$677r7   c                   	
 g }g }d fd}|j                   }|j                   }d
t        	 j                  } |       D ]k  }|s ||j                          |	
fd|j                  D               
t        |j                        z  
|O|j                  dn||j                  z   }m t        dj                  |      ||      S )ax  Join an iterable of content or strings.

        This works much like the join method on `str` objects.
        Self is the separator (which maybe empty) placed between each string or Content.

        Args:
            lines: An iterable of other Content instances or or strings.

        Returns:
            A single Content instance, containing all of the lines.

        c               3     K   j                   r:t              D ]+  \  } }t        |t              r|n
t        |       | r( - yD ]!  }t        |t              r|n
t        |       # yw)z6Iterate the lines, optionally inserting the separator.N)ru   r   r   r#   )r   r   r   r@   s     r5   iter_contentz"Content.join.<locals>.iter_contentC  sk     zz"+E"2 #JD$",T7";$N"
#
 " OD",T7";$NOs   ?A1.A1r   c              3  J   K   | ]  \  }}}|r |z   |z   |        y wra   rM   )ri   r:   r;   r=   r   r}   s       r5   rk   zContent.join.<locals>.<genexpr>Y  s3      %E3 funfslE:s    #NrV   )rG   zIterable[Content])rE   r$   rQ   rO   rP   rv   r#   ry   )r@   r   r3   r]   r)  extend_textextend_spanstotal_cell_lengthr   r   r}   s   ``       @@r5   ry   zContent.join3  s     		O kk||(,(9(9#~ 	G& )0 
 c'--((F , ++3 *W-A-AA "	" rwwt}e->??r7   )r   r   c               h    | j                  |||      }|D cg c]  }|j                   }}|S c c}w )a  Wrap text so that it fits within the given dimensions.

        Note that Textual will automatically wrap Content in widgets.
        This method is only required if you need some additional processing to lines.

        Args:
            width: Maximum width of the line (in cells).
            align: Alignment of lines.
            overflow: Overflow of lines (what happens when the text doesn't fit).

        Returns:
            A list of Content objects, one per line.
        )r   r   )r@   r   r   r   r   r   content_liness          r5   r   zContent.wraph  s:      %%eUH=278$88 9s   /c                    |dk  rt        |       |z   }t               }| j                  D ]  \  }}}||cxkD  r|k\  sn ||z  } |S )zGet the style of a character at give offset.

        Args:
            offset (int): Offset into text (negative indexing supported)

        Returns:
            Style: A Style instance.
        r   )rv   r   rP   )r@   r}   r=   r:   r;   
span_styles         r5   get_style_at_offsetzContent.get_style_at_offset|  sX     A:Y'F&*kk 	$"E3
V$u$#	$ r7   )r   r   c               `   | j                   }||k(  r| S | j                  }| j                  }|r||k  r||z
  }| j                   d|z   }nX||kD  rS|r|rt        | j                  |dz
        dz   }nt        | j                  |      }| j	                  || j                        }t        ||      S )a  Truncate the content at a given cell width.

        Args:
            max_width: The maximum width in cells.
            ellipsis: Insert an ellipsis when cropped.
            pad: Pad the content if less than `max_width`.

        Returns:
            New Content.
         ro   u   …)r^   ru   rP   r   r#  r#   )r@   	max_widthr   r   lengthr3   r]   spacess           r5   r   zContent.truncate  s    $ !!YKzz6I%'Fjj\#,0DiI$TZZQ?%G$TZZ;$$T4;;7EtU##r7   c           
     2   t        |      dk(  sJ d       |rx||z   | j                   }t        }| j                  D cg c]  \  }}} |||z   ||z   |       }}}}t	        ||| j
                  d      }	|	S | j
                  |z         }	|	S | S c c}}}w )zPad the left with a given character.

        Args:
            count (int): Number of characters to pad.
            character (str, optional): Character to pad with. Defaults to " ".
        ro   &Character must be a string of length 1Nrv   ru   r$   rP   r#   rQ   )
r@   count	characterr3   r   r:   r;   r=   r]   r   s
             r5   pad_leftzContent.pad_left  s     9~"L$LL"%'(5DE *. %E3 eemS5[%8E  ))1G
 N 8<7H7H57PG
 Ns   Bc           	        |r| j                   }t        |      }t        | ||z   | j                  D cg c]$  }|j                  |k(  r|j                  |      n|& c}| j                  d      S | j                  |z         S | S c c}w )a   Add repeating characters (typically spaces) to the content with the style(s) of the last character.

        Args:
            count: Number of spaces.
            character: Character to add with.

        Returns:
            A Content instance.
        N)ru   rv   r#   rP   r;   rE   rQ   )r@   r;  r<  ru   	plain_lenrj   s         r5   extend_rightzContent.extend_right  s     JJEE
I')e+,- !% ,088y+@T[['dJ ))1  8<7H7H57P  s   )B
c                    t        |      dk(  sJ d       |rGt        | j                   ||z   | j                  | j                  d      S | j                  |z         S | S )zPad the right with a given character.

        Args:
            count (int): Number of characters to pad.
            character (str, optional): Character to pad with. Defaults to " ".
        ro   r9  N)rv   r#   ru   rP   rQ   )r@   r;  r<  s      r5   	pad_rightzContent.pad_right  sx     9~"L$LL"::,y5012))1  8<7H7H57P 
 r7   c           
     d   t        |      dk(  sJ d       |s|r||z   | j                   ||z   }t        }|r0| j                  D cg c]  \  }}} |||z   ||z   |       }	}}}n| j                  }	t	        ||	| j
                  d      }
|
S | j
                  |z   |z         }
|
S | S c c}}}w )a/  Pad both the left and right edges with a given number of characters.

        Args:
            left (int): Number of characters to pad on the left.
            right (int): Number of characters to pad on the right.
            character (str, optional): Character to pad with. Defaults to " ".
        ro   r9  Nr:  )r@   rR   rS   r<  r3   r   r:   r;   r=   r]   r   s              r5   r   zContent.pad  s     9~"L$LL"5$&'

|I4E3FGDE .2[[ )sE %$,d
E: 
 ))1G
 N 8<7H7H47ORW7WG
 Ns   
B+c                    | j                         j                  ||      }||j                  z
  dz  }||z
  }|j                  ||      }|S )zAlign a line to the center.

        Args:
            width: Desired width of output.
            ellipsis: Insert ellipsis if content is truncated.

        Returns:
            New line Content.
        r   r   )r   r   r^   r   )r@   r   r   r   rR   rS   s         r5   centerzContent.center  sR     ++-(((B+++1++dE*r7   c                    | j                         j                  ||      }|j                  ||j                  z
        }|S )zAlign a line to the right.

        Args:
            width: Desired width of output.
            ellipsis: Insert ellipsis if content is truncated.

        Returns:
            New line Content.
        r   )r   r   r=  r^   )r@   r   r   r   s       r5   rS   zContent.right  s?     ++-(((B""57+>+>#>?r7   c           
        t        | j                        |z
  }t        }| j                  D cg c]T  }|j                  |k  rC|j
                  |k  r|n1 ||j                  t        ||j
                        |j                        V }}| j                  d|  }| j                  dn| j                  |z
  }t        |||      S c c}w )zRemove a number of characters from the end of the text.

        Args:
            amount: Number of characters to crop.

        Returns:
            New Content

        N)
rv   ru   r$   rP   r:   r;   r!  r=   rQ   r#   )r@   amountr"  r   rj   r]   r3   r6  s           r5   
right_cropzContent.right_crop+  s     _v-
 
 zzJ&	 88j( 4::s:txx'@$**MN
 
 zz(F7#**28I8IF8RtUF++
s   ACc           	         |s| S t        |       }|dk  r||z   }||}|dk  r||z   }||k\  s||k  r| S t        | j                  | j                  t	        |||k  r|n||      gz         S )az  Apply a style to the text, or a portion of the text.

        Args:
            style (Union[str, Style]): Style instance or style definition to apply.
            start (int): Start offset (negative indexing is supported). Defaults to 0.
            end (Optional[int], optional): End offset (negative indexing is supported), or None for end of text. Defaults to None.
        r   )rv   r#   ru   rP   r$   r@   r=   r:   r;   r6  s        r5   r   zContent.stylizeD  s     KT19UNE;C73,CF?cUlKJJKK4#v3NOO
 	
r7   c                    |s| S t        |       }|dk  r||z   }||}|dk  r||z   }||k\  s||k  r| S t        | j                  t        |||k  r|n||      g| j                        S )a  Apply a style to the text, or a portion of the text.

        Styles applies with this method will be applied *before* other styles already present.

        Args:
            style (Union[str, Style]): Style instance or style definition to apply.
            start (int): Start offset (negative indexing is supported). Defaults to 0.
            end (Optional[int], optional): End offset (negative indexing is supported), or None for end of text. Defaults to None.
        r   )rv   r#   ru   r$   rP   rK  s        r5   r   zContent.stylize_before_  s     KT19UNE;C73,CF?cUlKJJ%6C<S%@O4;;O
 	
r7   r   c           	   #    K   | j                   s| j                  |f |r||f y|dd}|}n|}t        t        | j                   d            }|D ci c]>  \  }}|t	        |j
                  t              r ||j
                        n|j
                  @ c}}|d<   | j                  }	dgd |D        d |D        t        |	      ddf}
|
j                  t        dd      	       g j                  }j                  }i j                  t        j                  dfd
}t!        |
|
dd       D ]4  \  \  }}}\  }}}|r	 ||       n ||       ||kD  s'|	||  |       f 6 |r||f yyc c}}w w)ac  Render Content in to an iterable of strings and styles.

        This is typically called by Textual when displaying Content, but may be used if you want to do more advanced
        processing of the output.

        Args:
            base_style: The style used as a base. This will typically be the style of the widget underneath the content.
            end: Text to end the output, such as a new line.
            parse_style: Method to parse a style. Use `App.parse_style` to apply CSS variables in styles.

        Returns:
            An iterable of string and styles, which make up the content.

        Nc                    t        | t              r| S 	 t        j                  |       }|S # t        $ r t        j                         }Y |S w xY w)zThe default get_style method.)r   r   r   	Exceptionnull)r=   visual_styles     r5   
_get_stylez"Content.render.<locals>._get_style  sN    eU+ L0#(;;u#5L $# ! 0#(::<L##0s   + AAro   r   )r   Fr   c              3  @   K   | ]  \  }}|j                   d |f  ywrg   )r:   ri   r  rj   s      r5   rk   z!Content.render.<locals>.<genexpr>  s     M[UDtzz5%(M   c              3  @   K   | ]  \  }}|j                   d |f  ywrn   r   rT  s      r5   rk   z!Content.render.<locals>.<genexpr>  s     J+%txxu%JrU  Trp   c                 ~    t              }  |       }||S | D cg c]  }	|   	 }} |      }|| <   |S c c}w )z#Construct current style from stack.)r   )
r   cached_style	_style_idstylescurrent_stylecombinestackstyle_cachestyle_cache_get	style_maps
        r5   get_current_stylez)Content.render.<locals>.get_current_style  sY    eI*95L'##<EFyi	*FFF#FOM%2K	"   Gs   :)r=   zstr | StylerG   r   )rG   r   )rP   rO   r   r   r   r=   r   ru   rv   rw   r   rx   remover   r   r\  r   )r@   
base_styler;   parse_stylerR  r   enumerated_spansr  rj   r3   r]   stack_append	stack_popra  r}   leavingstyle_idnext_offset_r\  r]  r^  r_  r`  s                      @@@@@r5   renderzContent.render  s    * {{::z**:o% $ #I $I	$++q 9:
  0	
 t )3DJJ)D	$**%$**U
	 "	!zz 
M<LM
 K9IJ
 Ya 	
 	

z!Q'
(||LL	46%//--		! 		! ADE5QRQS9@U 	D<'VWh)<+q!(#X&V#6+.0A0CCC	D z/! W
s   AFAFCF+ Fc                    t         }| j                  ||      D cg c]  \  }} |||r|j                  nd       }}}|S c c}}w )a  Render the Content in to a list of segments.

        Args:
            base_style: Base style for render (style under the content). Defaults to Style.null().
            end: Character to end the segments with. Defaults to "".

        Returns:
            A list of segments.
        N)r   rl  
rich_style)r@   rc  r;   _Segmentr3   r=   segmentss          r5   render_segmentszContent.render_segments  sT       ${{:s;
e TE,,4A
 
 	
s   !Ac                N    ddl m}  || j                  t               d            S )z-Allow Content to be rendered with rich.print.r   )Segmentsr   )rich.segmentrs  rq  r   )r@   rs  s     r5   __rich__zContent.__rich__  s    ),,UWd;<<r7   c                f   | j                   t        d      | _         | j                   j                  |      x}|S t        t	        ||dd             }t        | j                        }t        |      }g }| j                  D ]  }|\  }}	}
||k\  rt        ||	      }	d}|}||z   dz  }	 ||   \  }}||k  r|dz
  }n||kD  r|dz   }nn	||z   dz  }(|	|k  r|}n/|x}}|}	 ||   \  }}|	|k  r|dz
  }n|	|kD  r|dz   }nn	||z   dz  }(|j                  |||dz   f        || j                   |<   |S )zDivide content from a list of offset to cut.

        Args:
            offsets: A tuple of indices in to the text.

        Returns:
            A list of tuples containing Spans and their line offsets.
        N   ro   r   r   )
r[   r   r   r   r   rv   ru   rP   r!  rx   )r@   r   cached_resultline_rangestext_length
line_countspan_rangesrj   
span_startspan_end_stylelower_boundupper_boundstart_line_no
line_startr   end_line_nos                    r5   _divide_spanszContent._divide_spans  s    %!*1D!//33G<<MI  3w45$**o%
35KK #	GD+/(J&[(;1HK$K(;61<M'2='A$
H
*"/!"3K(*"/!"3K!,{!:q @  ("+,99k(+6{+C(J*,&1Ao!H,&1Ao#.#<"BK  m[1_EFG#	GH '27#r7   c           	     p   |s| gS t        |      }| j                  }t        dg|t        |            }t	        t        ||dd             }|D cg c]
  \  }}|||  }}}|D cg c]  }t        |d       }	}| j                  s|	S |	D cg c]  }|j                  j                   }
}t        }| j                  |      D ]]  \  \  }}}}}t        ||      D ]D  }||   \  }}t        d||z
        }t        ||z
  ||z
        }||kD  s2 |
|    ||||             F _ |	S c c}}w c c}w c c}w )a  Divide the content at the given offsets.

        This will cut the content in to pieces, and return those pieces. Note that the number of pieces
        return will be one greater than the number of cuts.

        Args:
            offsets: Sequence of offsets (in characters) of where to apply the cuts.

        Returns:
            List of Content instances which combined would be equal to the whole.
        r   ro   N)sortedru   r   rv   r   r   r#   rP   rx   r$   r  r   r   r!  )r@   r   r3   divide_offsetsry  r:   r;   	line_textr   r   _line_appendsr   r}  r~  r=   
start_lineend_lineline_nor  r   	new_startnew_ends                         r5   r   zContent.divide-  sn    6M/zz7G7SY783~~ab/ABC7BCT%_C	C5>?TWT4(?	?{{8AB++BB /	
	M 
)Z5 X6 M'27';$
H:
#:;	h3X
5JKY&*M'*5GU+KLM
	M + D?
 Cs   D()D.D3)include_separatorr   c                 
 sJ d       | j                   

vr| gS ||f}| j                  t        d      | _        | j                  j                  |      x}|j	                         S |rU| j                  t        j                  t        j                        
      D cg c]  }|j                          c}      }nBd
fd}| j                  t         |                   D 	cg c]  }	|	j                   k7  r|	 }}	|s!
j                        r|j                          || j                  |<   |S c c}w c c}	w )a  Split rich text into lines, preserving styles.

        Args:
            separator (str, optional): String to split on. Defaults to "\\n".
            include_separator (bool, optional): Include the separator in the lines. Defaults to False.
            allow_blank (bool, optional): Return a blank line if the text ends with a separator. Defaults to False.

        Returns:
            List[Content]: A list of Content, one per line of the original.
        zseparator must not be emptyrw  c               3     K   t        j                  t        j                              D ]  } | j                         E d {     y 7 wra   )refinditerre   rj   )match	separatorr3   s    r5   flatten_spansz$Content.split.<locals>.flatten_spansy  s<     [[9)=tD ,E$zz|++,+s   A AAA)rG   zIterable[int])ru   r\   r   r   copyr   r  r  re   r;   r   endswithpop)r@   r  r  r   r   rx  r  r   r  r   r3   s    `        @r5   r   zContent.splitW  s-   " 777yzzD 6M 1;?	$ )!D!..229==MJ %%''KK*,++bii	6JD*QRRE
, !KK]_(=>::* E  t}}Y7IIK',)$% Ss   %D:,D?c                    | j                   j                  |      }t        || j                  || j                              S )z"Strip characters from end of text.)ru   r   r#   r#  rP   )r@   charsr3   s      r5   r   zContent.rstrip  s4    zz  'tT--dDKK@AAr7   c                    t        |       }||kD  r[||z
  }t        j                  | j                        }|5t        |j	                  d            }| j                  t        ||            S | S )zRemove whitespace beyond a certain width at the end of the text.

        Args:
            size (int): The desired size of the text.
        r   )rv   _re_whitespacesearchru   grouprI  r!  )r@   sizerz  excesswhitespace_matchwhitespace_counts         r5   r   zContent.rstrip_end  sm     $i 4'F-44TZZ@+#&'7'='=a'@#A s+;V'DEEr7   c                ^   |dk  r| S | j                   }d|z  }|rat        |       }|D cg c]$  }|j                  |k\  r|j                  |      n|& }}t	        | j
                  |z   || j                  |z         S t	        | j
                  |z   | j                   | j                        S c c}w )a  Extend the Text given number of spaces where the spaces have the same style as the last character.

        Args:
            spaces (int): Number of spaces to add to the Text.

        Returns:
            New content with additional spaces at the end.
        r   r4  )rP   rv   r;   rE   r#   rO   r^   rQ   )r@   r7  r]   
new_spaces
end_offsetrj   s         r5   extend_stylezContent.extend_style  s     Q;K6\
TJ " (,xx:'=F#4GE  4::
2E4;K;Kf;TUUtzzJ.T=N=NOOs   )B*c                   d| j                   vr| S | j                  s$t        | j                   j                  |            S g }|j                  }| j                  dd      D ]  }d|j                   vr	 ||       d}|j                  dd      }|D ]  }|j                   j                  d      rct        |j                  dd dz   |j                  |j                        }||j                  z  }||z  }|r+||z
  }	|j                  |	      }||	z  }n||j                  z  } ||         t        d	      j                  |      }
|
S )
ztConverts tabs to spaces.

        Args:
            tab_size (int, optional): Size of tabs. Defaults to 8.

        	r   Tr  r   Nr&   r4  rV   )ru   rP   r#   
expandtabsrx   r   r  rO   rQ   r^   r  ry   )r@   r   new_textrx   r   cell_positionr   r   tab_remainderr7  r   s              r5   r   zContent.expand_tabs  sJ    tzz!K{{4::00:;;"$JJttJ< 	!D4::%t !

44
@! !Dzz**40& JJsOc14;;@Q@Q  &)9)99(5(@(%-%=F#'#4#4V#<D)V3M%)9)994L!	!* "+""8,r7   )maximum_highlightsc                  | j                   j                         }|j                  }t        }| j                  }t        |t              rt        j                  |      }n|}d}	|j                  |      D ]9  }
|
j                         \  }}||kD  r | ||||             |.|	dz   x}	|k\  s9 n t        | j                  |      S )aJ  Apply a style to text that matches a regular expression.

        Args:
            highlight_regex: Regular expression as a string, or compiled.
            style: Style to apply.
            maximum_highlights: Maximum number of matches to highlight, or `None` for no maximum.

        Returns:
            new content.
        r   ro   )rP   r  rx   r$   ru   r   r   r  compiler  rj   r#   rO   )r@   highlight_regexr=   r  r]   append_spanr   ru   re_highlightr;  r  r:   r;   s                r5   r  zContent.highlight_regex  s    " !KK,,.ll

os+::o6L*L!**51 	EJE3U{E%e45".#ai'U,>>	 tzz5))r7   )rV   NN)r3   r   r]   zlist[Span] | Noner^   
int | NonerG   NonerG   r   )rG   r#   )T)r   r%   r   boolrG   r#   )r   zstr | Contentr   objectrG   r#   ra   )r3   z
str | Textr   zConsole | NonerG   r#   )rV   N)r3   r   r=   r<   r^   r  rG   r#   )r   z'str | Content | tuple[str, str | Style]r;   r   rG   r#   )r]   Sequence[Span]rG   r#   )r   r  rG   r  )r   r#   rG   r  )r   r    r   r9   rG   r9   )r   r    rG   r9   )r   r    r   r9   rG   r9   )r   r9   r   r   r   r   r   r  r   r9   r   r9   r   zSelection | Noner   Style | Noner   r  r   Callable[[str | Style], Style]rG   zlist[_FormattedLine])
r   r9   r   r  r=   r   r  r   rG   zlist[Strip])rG   r9   )rG   r  rF   )rG   r  )r  zint | slicerG   r#   )r   Content | strrG   r#   )r3   r   r]   
list[Span]rG   r  )r   r  rG   r#   )rV   )r3   r   r=   r<   rG   r#   )r   zIterable[Content | str]rG   r#   )r   r9   r   r   r   r   rG   list[Content])r}   r9   rG   r   )r5  r9   r   r  rG   r#   )r4  )r;  r9   r<  r   rG   r#   )rR   r9   rS   r9   r<  r   rG   r#   )F)r   r9   r   r  rG   r#   )ro   )rH  r9   rG   r#   )r   N)r=   r<   r:   r9   r;   r  rG   r#   )rc  r   r;   r   rd  z%Callable[[str | Style], Style] | NonerG   zIterable[tuple[str, Style]])rc  r   r;   r   rG   list[Segment])r   ztuple[int, ...]rG   zlist[tuple[Span, int, int]])r   zSequence[int]rG   r  )r   )r  r   r  r  r   r  rG   r  )r  z
str | NonerG   r#   )r  r9   rG   r#   )r7  r9   rG   r#   )r+   )r   r9   rG   r#   )r  zre.Pattern[str] | strr=   r<   r  r  rG   r#   )FrH   rI   rJ   rK   	__slots___NORMALIZE_TEXT_ALIGNr_   rc   r   r   classmethodr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r
  rA   propertyr]   r^   ru   r   r  r  r  r  r#  rx   r&  ry   r   r2  r   r=  r@  rB  r   rE  rS   rI  r   r   rP  rl  rq  ru  r  r   r   r   r   r  r   r  rM   r7   r5   r#   r#   n   s    4I&,WP #'"&	

 !
  	

 

6  :   AE %0 :> 	   D  > 9=;;(6;	; ;z   "&	   	
 
 * IK4)<4)CF4)	4) 4)l:+&4,48 "!'&*(,#'49KK\\ \ 	\
 \ \ \ $\ &\ !\ 2\ 
\|$$",$5:$ER$	$L     ! !     . .I2&
  1.
83@l 17QW$-BN	(. !$!$
 !$ 
!$F0. 8 ,4 EI
 
),
7A
	
< 	

 
 	

 

D 'EJJL=A	Z"Z" Z" ;	Z"
 
%Z"z #-%**,258	&=7r(X 0 #(!00  	0
 0 
0dB
P,&Z *.#*.#* 	#*
 '#* 
#*r7   c                  t    e Zd ZdZ	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZed	d       Zd
dZ	 	 	 	 	 	 ddZy)r   zA line of content with additional formatting information.

    This class is used internally within Content, and you are unlikely to need it an an app.
    Nc	                t    || _         || _        || _        || _        || _        || _        || _        || _        y ra   )r   r   r   xr   r   r   
link_style)	r@   r   r   r   r  r   r   r   r  s	            r5   r_   z_FormattedLine.__init__  s<     #

 $r7   c                .    | j                   j                  S ra   )r   ru   r?   s    r5   ru   z_FormattedLine.plain  s    ||!!!r7   c                h   t         }| j                  }| j                  }dx}}| j                  }| j                  }| j
                  }	| j                  }
|dv s|dk(  r| j                  rn|dk(  r%|| j                  j                  z
  }|dz  }||z
  }n[|dv r|| j                  j                  z
  }n<|dk(  r6|j                  dd	      }t        d
 |D              }t        |      dz
  }dg|z  }d}|rC||z   |k  r;|t        |      |z
  dz
  xx   dz  cc<   |dz  }|dz   t        |      z  }||z   |k  r;g }|j                  }| j                  }t        |      D ]  \  }}|j                  |d|
      D ]8  \  }} | ||||z   j                  ||	                   |t        |      dz   z  }: |t        |      k  sd||   x}sl | |d|z  |z   j                                 ||fS |r$t        d|z  |j"                  j                         gng }|j                  }|j                  |d|
      D ]5  \  }} | ||||z   j                  ||	                   |t        |      z  }7 |r/|j                   |d|z  |j"                  j                                ||j                  |z   |z   fS )Nr   )r:   rR   rU   rE  r   )r;   rS   r4  Fr  c              3  d   K   | ](  }t        |j                  j                  d              * yw)r4  N)r   ru   r   )ri   r   s     r5   rk   z*_FormattedLine.to_strip.<locals>.<genexpr>6  s$     P$Xdjj&7&7&<=PrB   ro   rV   )r;   rd  )r   r   r   r   r  r   r   r   r^   r   sumrv   rx   r   rl  rich_style_with_offsetrn  background_style)r@   r=   ro  r   r   r=  rB  r   r  r   r   excess_spacewords
words_size
num_spacesr7  r  rp  add_segmentr   r3   
text_styler   s                          r5   r   z_FormattedLine.to_strip  s   



  9,,FFFFNN	%%%9*<h 4<<#;#;;L#q(H$x/I&&t||777HiMM#M?EP%PPJUaJS:%FE :-53v;.23q83!OJ"QY#f+5E !:-5
 ')H"//KA(/ Vt(,ry )4 ) '$D*    5:#5"M"MaQR"S
 TQ&A' 3v;&6%=,@C,@sUZ5G4S4S TUV U?"  S8^U%;%;%F%FGH 	
 oo 'u") T 	D*
 2JJ1aPQ TNA		 OOy%*@*@*K*KL '--89DEEr7   c           
         t         }|D cg c]3  \  }}}|+ |||j                  |nd|j                  v r||z   n||      5 }}}}|S c c}}}w )Nz@click)r   _metameta)r@   r  rp  ro  r3   r=   controls          r5   _apply_link_stylez _FormattedLine._apply_link_stylee  sx      )1
 
 %eW   {{* 08EJJ0F%*,E
 
 
s   8A)r   r   rR   FN)r   r  r   r#   r   r9   r  r9   r   r9   r   r   r   r  r  r  rG   r  r  )r=   r   rG   ztuple[list[Segment], int])r  r   rp  r  rG   r  )	rH   rI   rJ   rK   r_   r  ru   r   r  rM   r7   r5   r   r     s     !#'%1% % 	%
 % % % % !% 
%( " "DFL#/<	r7   r   rV   r   )r3   r   r4   zdict[int, None]rG   r   )KrK   
__future__r   r  	functoolsr   r   operatorr   typingr   r   r	   r
   r   	rich.reprrich
rich._wrapr   
rich.cellsr   rich.consoler   rt  r   
rich.styler   r   rich.terminal_themer   	rich.textr   typing_extensionsr   r   textual._cellsr   textual._contextr   textual._loopr   textual.cacher   textual.colorr   textual.css.typesr   r   textual.selectionr   textual.stripr   textual.styletextual.visualr   r    r!   __all__r   r"   rL   r%   ANSI_DEFAULTTRANSPARENT_STYLEr  r  r/   r0   r6   reprautor$   r#   r   r   )
_codepoints   0r5   <module>r     s   # 	 5  B B  " $     ) -  . # ' # #  5 '   : :
,y#~.Y . Py$34Y 4 0Q1ab)Q1ab) :G  G$ e  (<##J# %  4L,
,!0,, :  6 N*f N*  N*b,u up r{u "u1#s   	
F