
    k"ge                        U d dl Zd dlZd dlZd dl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mZmZmZ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  d d	l!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+ d d
l,m-Z- d dl.m/Z/ d dl0m1Z1m2Z2 ddl3m4Z4 ddl5m6Z6 ddl7m8Z8m9Z9 ddl:m;Z;m<Z<m=Z=m>Z> ddl?m@Z@ ddlAmBZB ddlCmDZDmEZE ddlFmZmGZG ddlHmIZI eeJdf   ZK ej                         dk(  ZMdZNi e* e       e+ ed      e" ed      e"j                   ed      e% ed      e%j*                   ed      e(j                   ed       e&j                   ed      e&j                   ed!      e&j                   edd"      e&j                   ed!d"      e&j                   ed      e&j                   ed d#      e&j                   ed$      e&j                   ed$      e&j                   ed      e&j                   ed%      e) ed&      e' ed      e$j                   ed'      e$j                   ed!      e$j                   ed(      e$j                   ed d#      e$j                   ed(      e$jF                   ed'      e# ed$d"      i	Z`eeKef   ead)<   i e* e       e+ ed*      e" ed      e"j                   ed+      e% ed%      e%j*                   ed+      e(j                   ed,      e&j                   ed+      e&j                   ed-      e&j                   ed+d"      e&j                   ed-d"      e&j                   ed+      e&j                   ed,d#      e&j                   ed'      e&j                   ed'      e&j                   ed+      e&j                   ed%      e) ed&      e' ed%      e$j                   ed'      e$j                   ed-      e$j                   ed(      e$j                   ed,d#      e$j                   ed(      e$jF                   ed'      e# ed$d"      i	ZbeeKef   ead.<   e`ebd/Zcd0Zd G d1 d2e      Ze G d3 d4ee      Zf G d5 d6ee      Zgeehehf   Zi G d7 d8e      Zj G d9 d:e@      Zkd;eeh   d<eid=eeh   fd>Zlemd?k(  rd dlnZnd dlZ enj                  d@A      Zpepj                  dBdCdDE       epj                  dFdGdHdIddJK       epj                  dLdMdNdIdOdPK       epj                  dQdRdSdIdTU       epj                  dVdWehdXddYZ       epj                  d[d\d]dIdOd^K       epj                  d_d`dIdadOdbc       epj                  dddedfddgh       epj                  didjdkddlh       epj                  dmdnddodpq       epj                  drdsehd dtduv       epj                  dwehddxdyv       epj                         Zsd dzltm;Z;  e;esj                  esj                  {      Z:esj                  d|k(  rej                  j                         Zz ekezesj                  esj                  esj                  esj                  esj                  esj                   esj                  esj                  h}	      Znyekj	                  esj                  esj                  esj                  esj                  esj                  esj                  esj                   esj                  esj                  h~	      Ze:j                  eesj                         yy)    N)ABCabstractmethod)Path)AnyDictIterableList
NamedTupleOptionalSequenceSetTupleTypeUnion)Lexer)get_lexer_by_nameguess_lexer_for_filename)Style)get_style_by_name)
CommentErrorGenericKeywordNameNumberOperatorStringToken
Whitespace)ClassNotFound)Lines)PaddingPaddingDimensions   )
loop_firstcell_len)Color	blend_rgb)ConsoleConsoleOptionsJustifyMethodRenderResult)JupyterMixin)Measurement)SegmentSegments)r   	StyleType)Text.WindowsmonokaiwhitecolorTdimcyanbluemagentagreen)r8   	underline)r8   boldredbright_blueyellow
bright_red)r@   
ANSI_LIGHTbright_blackbright_cyanbright_magentabright_green	ANSI_DARK)
ansi_light	ansi_dark   c                   @    e Zd ZdZededefd       Zedefd       Zy)SyntaxThemezBase class for a syntax theme.
token_typereturnc                     t         )z'Get a style for a given Pygments token.NotImplementedError)selfrP   s     P/var/www/html/djangosite/lib/python3.12/site-packages/pip/_vendor/rich/syntax.pyget_style_for_tokenzSyntaxTheme.get_style_for_token~   
     "!    c                     t         )zGet the background color.rS   rU   s    rV   get_background_stylez SyntaxTheme.get_background_style   rX   rY   N)	__name__
__module____qualname____doc__r   	TokenTyper   rW   r\    rY   rV   rO   rO   {   s@    ("i "E " " "e " "rY   rO   c                   L    e Zd ZdZdeeee   f   ddfdZde	de
fdZde
fdZy)	PygmentsSyntaxThemez.Syntax theme that delegates to Pygments theme.themerQ   Nc                    i | _         t        |t              r	 t        |      | _        n|| _        | j                  j                  | _        t        | j                        | _	        y # t
        $ r t        d      | _        Y Rw xY w)Ndefaultbgcolor)
_style_cache
isinstancestrr   _pygments_style_classr    background_color_background_colorr   _background_style)rU   re   s     rV   __init__zPygmentsSyntaxTheme.__init__   sx    46eS!J->u-E* */D&!%!;!;!L!L!&t/E/E!F ! J->y-I*Js   A( (BBrP   c           	      V   	 | j                   |   S # t        $ r 	 | j                  j                  |      }|d   }|d   }t	        |rd|z   nd|rd|z   n| j
                  |d   |d   |d         }n## t        $ r t	        j                         }Y nw xY w|| j                   |<   Y |S w xY w)	z"Get a style from a Pygments class.r8   ri   #z#000000r@   italicr?   )r8   ri   r@   rt   r?   )rj   KeyErrorrm   style_for_tokenr   ro   null)rU   rP   pygments_styler8   ri   styles         rV   rW   z'PygmentsSyntaxTheme.get_style_for_token   s    	2$$Z00 	2!%!;!;!K!KJ!W 'w/(3).#+I-4C'M$:P:P'/)(3,[9  %

% -2Dj)!	2s1    	B(A2<B(2BB(BB('B(c                     | j                   S Nrp   r[   s    rV   r\   z(PygmentsSyntaxTheme.get_background_style       %%%rY   )r]   r^   r_   r`   r   rl   r   PygmentsStylerq   ra   r   rW   r\   rb   rY   rV   rd   rd      sI    8GeCm)<$<= G$ Gi E ,&e &rY   rd   c                   F    e Zd ZdZdeeef   ddfdZdedefdZdefdZ	y)	ANSISyntaxThemez$Syntax theme to use standard colors.	style_maprQ   Nc                     || _         t        j                         | _        t        j                         | _        i | _        y r{   )r   r   rw   _missing_stylerp   rj   )rU   r   s     rV   rq   zANSISyntaxTheme.__init__   s-    "#jjl!&46rY   rP   c                     	 | j                   |   S # t        $ rX | j                  j                  }t	        |      }| j
                  }|r ||      }||}n|dd }|r|| j                   |<   |cY S w xY w)zLook up style in the style map.N)rj   ru   r   gettupler   )rU   rP   	get_styletokenry   _styles         rV   rW   z#ANSISyntaxTheme.get_style_for_token   s    	$$Z00 	 **I*%E''E"5)%"Ecr
  -2Dj)L	s    AA2A21A2c                     | j                   S r{   r|   r[   s    rV   r\   z$ANSISyntaxTheme.get_background_style   r}   rY   )
r]   r^   r_   r`   r   ra   r   rq   rW   r\   rb   rY   rV   r   r      sA    .7$y%'7"8 7T 7i E (&e &rY   r   c                   0    e Zd ZU dZeed<   eed<   eed<   y)_SyntaxHighlightRangez
    A range to highlight in a Syntax object.
    `start` and `end` are 2-integers tuples, where the first integer is the line number
    (starting from 1) and the second integer is the column index (starting from 0).
    ry   startendN)r]   r^   r_   r`   r2   __annotations__SyntaxPositionrb   rY   rV   r   r      s     	rY   r   c            "       
   e Zd ZU dZee   ed<   eed<   ede	e
ef   defd       Zedddd	d	d	d
dd	dddde
de	ee
f   de	e
ef   dedededeeee   ee   f      deee      dee   dededee
   dededd	fdZedd	eddd	dd	d	d
dd	ddfde
de
dee	ee
f      de	e
ef   dededeeeef      dedeee      dee   dededee
   dededd f d       Zed6de
dee
   de
fd        Zdefd!Zd"edee   fd#Zedee   fd$       Z	 d6de
deeee   ee   f      defd%Zd&e d'e!d(e!dd	fd)Z"d7d*e#defd+Z$edefd,       Z%d-e&deeeef   fd.Z'	 	 	 	 	 	 d8d0Z(d-e&d/e)de*fd1Z+d-e&d/e)de,e-   fd2Z.d3edd	fd4Z/de
deee
f   fd5Z0y	)9Syntaxa  Construct a Syntax object to render syntax highlighted code.

    Args:
        code (str): Code to highlight.
        lexer (Lexer | str): Lexer to use (see https://pygments.org/docs/lexers/)
        theme (str, optional): Color theme, aka Pygments style (see https://pygments.org/docs/styles/#getting-a-list-of-available-styles). Defaults to "monokai".
        dedent (bool, optional): Enable stripping of initial whitespace. Defaults to False.
        line_numbers (bool, optional): Enable rendering of line numbers. Defaults to False.
        start_line (int, optional): Starting number for line numbers. Defaults to 1.
        line_range (Tuple[int | None, int | None], optional): If given should be a tuple of the start and end line to render.
            A value of None in the tuple indicates the range is open in that direction.
        highlight_lines (Set[int]): A set of line numbers to highlight.
        code_width: Width of code to render (not including line numbers), or ``None`` to use all available width.
        tab_size (int, optional): Size of tabs. Defaults to 4.
        word_wrap (bool, optional): Enable word wrapping.
        background_color (str, optional): Optional background color, or None to use theme color. Defaults to None.
        indent_guides (bool, optional): Show indent guides. Defaults to False.
        padding (PaddingDimensions): Padding to apply around the syntax. Defaults to 0 (no padding).
    rm   _themenamerQ   c                 x    t        |t              r|S |t        v rt        t        |         }|S t	        |      }|S )zGet a syntax theme instance.)rk   rO   RICH_SYNTAX_THEMESr   rd   )clsr   re   s      rV   	get_themezSyntax.get_theme   sD     dK(K%%#$6t$<=E  (-ErY   Fr$   N   r   )re   dedentline_numbers
start_line
line_rangehighlight_lines
code_widthtab_size	word_wraprn   indent_guidespaddingcodelexerre   r   r   r   r   r   r   r   r   rn   r   r   c                F   || _         || _        || _        || _        || _        || _        |xs
 t               | _        |	| _        |
| _	        || _
        || _        |rt        |      n	t               | _        || _        || _        | j!                  |      | _        g | _        y )Nrh   )r   _lexerr   r   r   r   setr   r   r   r   rn   r   background_styler   r   r   r   _stylized_ranges)rU   r   r   re   r   r   r   r   r   r   r   r   rn   r   r   s                  rV   rq   zSyntax.__init__  s    $ 	($$.7#%$ " 0/?E*+UW 	 +nnU+=?rY   zutf-8pathencodingc                     t        |      j                  |      }|s| j                  ||      } | ||||||||	|
|||||      S )a  Construct a Syntax object from a file.

        Args:
            path (str): Path to file to highlight.
            encoding (str): Encoding of file.
            lexer (str | Lexer, optional): Lexer to use. If None, lexer will be auto-detected from path/file content.
            theme (str, optional): Color theme, aka Pygments style (see https://pygments.org/docs/styles/#getting-a-list-of-available-styles). Defaults to "emacs".
            dedent (bool, optional): Enable stripping of initial whitespace. Defaults to True.
            line_numbers (bool, optional): Enable rendering of line numbers. Defaults to False.
            start_line (int, optional): Starting number for line numbers. Defaults to 1.
            line_range (Tuple[int, int], optional): If given should be a tuple of the start and end line to render.
            highlight_lines (Set[int]): A set of line numbers to highlight.
            code_width: Width of code to render (not including line numbers), or ``None`` to use all available width.
            tab_size (int, optional): Size of tabs. Defaults to 4.
            word_wrap (bool, optional): Enable word wrapping of code.
            background_color (str, optional): Optional background color, or None to use theme color. Defaults to None.
            indent_guides (bool, optional): Show indent guides. Defaults to False.
            padding (PaddingDimensions): Padding to apply around the syntax. Defaults to 0 (no padding).

        Returns:
            [Syntax]: A Syntax object that may be printed to the console
        )r   )r   )re   r   r   r   r   r   r   r   r   rn   r   r   )r   	read_textguess_lexer)r   r   r   r   re   r   r   r   r   r   r   r   r   rn   r   r   r   s                    rV   	from_pathzSyntax.from_path-  sh    R Dz##X#6OODtO4E%!!+!-'
 	
rY   c                 `   d}d}|r	 t        ||      }|sO	 t        j                  j	                  |      \  }}|r*|j                  d      j                         }t        |      }|r)|j                  r|j                  d   }|S |j                  }|S # t        $ r Y w xY w# t        $ r Y Gw xY w)a  Guess the alias of the Pygments lexer to use based on a path and an optional string of code.
        If code is supplied, it will use a combination of the code and the filename to determine the
        best lexer to use. For example, if the file is ``index.html`` and the file contains Django
        templating syntax, then "html+django" will be returned. If the file is ``index.html``, and no
        templating language is used, the "html" lexer will be used. If no string of code
        is supplied, the lexer will be chosen based on the file extension..

        Args:
             path (AnyStr): The path to the file containing the code you wish to know the lexer for.
             code (str, optional): Optional string of code that will be used as a fallback if no lexer
                is found for the supplied path.

        Returns:
            str: The name of the Pygments lexer that best matches the supplied path/code.
        Nrg   .r   )
r   r    osr   splitextlstriplowerr   aliasesr   )r   r   r   r   
lexer_name_ext	extensions           rV   r   zSyntax.guess_lexerl  s    " "&
0t< ))$/3 #

3 5 5 7I-i8E }}"]]1-
  #ZZ
% !  ! s#   B AB! 	BB!	B-,B-c                 T    | j                   j                         | j                  z   }|S )zGet the base style.)r   r\   r   )rU   default_styles     rV   _get_base_stylezSyntax._get_base_style  s%    88:T=R=RRrY   rP   c                 P    | j                   j                  |      }|j                  S )zGet a color (if any) for the given token.

        Args:
            token_type (TokenType): A token type tuple from Pygments.

        Returns:
            Optional[Color]: Color from theme, or None for no color.
        )r   rW   r8   )rU   rP   ry   s      rV   _get_token_colorzSyntax._get_token_color  s"     //
;{{rY   c                     t        | j                  t              r| j                  S 	 t        | j                  dd| j                        S # t
        $ r Y yw xY w)zThe lexer for this syntax, or None if no lexer was found.

        Tries to find the lexer by name if a string was passed to the constructor.
        FT)stripnlensurenltabsizeN)rk   r   r   r   r   r    r[   s    rV   r   zSyntax.lexer  sV     dkk5);;	$	   		s   "A 	AAc                   	
 | j                         }|j                  rdnd}t        ||| j                  | j                         }| j
                  j                  | j                  |j                         n|rg|\  
	dt        t        t        t        f      ffddt        t        t        t        t           f      f	
fd}|j                   |              n)|j                  fdj!                        D               | j"                  |j%                  d| j"                          | j&                  r| j)                  |       |S )	a  Highlight code and return a Text instance.

        Args:
            code (str): Code to highlight.
            line_range(Tuple[int, int], optional): Optional line range to highlight.

        Returns:
            Text: A text instance containing highlighted syntax.
        rg   left)justifyry   r   no_wraprQ   c               3      K   sJ j                        D ])  \  } }|s	|j                  d      \  }}}| ||z   f |r!+ yw)zSplit tokens to one per line.
N)
get_tokens	partition)rP   r   
line_tokennew_liner   r   s       rV   line_tokenizez'Syntax.highlight.<locals>.line_tokenize  s\      L5-2-=-=d-C D)
E#:?//$:O7J%",j8.C"CC $Ds   A AAc               3   <  K   t         	             } d}rdz
  nd}||k  r1	 t        |       \  }}|df |j                  d      r|dz  }||k  r1| D ]2  \  }}| |      f |j                  d      s$|dz  }s,|k\  s2 y y# t        $ r Y Cw xY ww)zConvert tokens to spans.r   r$   Nr   )iternextStopIterationendswith)
tokensline_no_line_start_token_typer   rP   _get_theme_styleline_end
line_startr   s
         rV   tokens_to_spansz)Syntax.highlight.<locals>.tokens_to_spans  s     !-/2FG4>*q.AK "K/"15f.K  %dm+ >>$/#qLG "K/ .4 &)
E$&6z&BCC >>$/#qLG'Gx,? %&  - "!"s?   !BB !B%B;BB	B	BBBBc              3   8   K   | ]  \  }}| |      f  y wr{   rb   ).0rP   r   r   s      rV   	<genexpr>z#Syntax.highlight.<locals>.<genexpr>  s(      #)
E ,Z89#s   zon )r   transparent_backgroundr3   r   r   r   rW   r   appendr   r   r   rl   r   r   append_tokensr   rn   stylizer   _apply_stylized_ranges)rU   r   r   
base_styler   textr   r   r   r   r   r   s    `     @@@@@rV   	highlightzSyntax.highlight  sA    ))+
#::I 	 ]]&	
  ;;::

=KK (2$
HDxc3h'@ D&%Xe_8L2M)N & &. ""?#45 "" #-2-=-=d-C#  $$0s4#8#8"9:;  ''-rY   ry   r   r   c                 P    | j                   j                  t        |||             y)a  
        Adds a custom style on a part of the code, that will be applied to the syntax display when it's rendered.
        Line numbers are 1-based, while column indexes are 0-based.

        Args:
            style (StyleType): The style to apply.
            start (Tuple[int, int]): The start of the range, in the form `[line number, column index]`.
            end (Tuple[int, int]): The end of the range, in the form `[line number, column index]`.
        N)r   r   r   )rU   ry   r   r   s       rV   stylize_rangezSyntax.stylize_range  s"     	$$%:5%%MNrY   blendc                    | j                   j                         | j                  z   }|j                  }||j                  rt        j                         S | j                  t        j                        }||j                  r|xs t        j                         S t        |j                         |j                         |      }t        j                  |      S )N)
cross_fade)r   r\   r   ri   is_system_definedr(   rg   r   r   r3   r)   get_truecolorfrom_triplet)rU   r   r   rn   foreground_color	new_colors         rV   _get_line_numbers_colorzSyntax._get_line_numbers_color  s    ;;;;=@U@UU+33#'7'I'I==?"00<#'7'I'I#6u}}6**,**,
	
 !!),,rY   c                     d}| j                   rAt        t        | j                  | j                  j                  d      z               t        z   }|S )z?Get the number of characters used to render the numbers column.r   r   )r   lenrl   r   r   countNUMBERS_COLUMN_DEFAULT_PADDING)rU   column_widths     rV   _numbers_column_widthzSyntax._numbers_column_width,  sJ     C$))//$*??@A01  rY   consolec           
         | j                         }|j                  r3t        j                         t        d      t        j                         fS |j                  dv rt        j
                  || j                  j                  t        j                        t        | j                               | j                        }t        j
                  || j                  j                  t        j                        t        d| j                  d            | j                        }n|t        d      z   }|t        d      z   }|||fS )z>Get background, number, and highlight styles for line numbers.Tr9   )256	truecolorr7   g?)r@   r8   F)r   r   r   rw   color_systemchainr   rW   r   r3   r   r   )rU   r   r   number_stylehighlight_number_styles        rV   _get_number_styleszSyntax._get_number_styles7  s    //122::<4%**,>>#77 ;; //

;D88:;%%	L &+[[ //

;4t'C'CC'HI%%	&" ,eo=L%5%8H%H"/EEErY   optionsc                    t        j                  | j                        \  }}}}||z   }| j                  5| j                  | j                  z   |z   dz   }t        | j                  |      S | j                  j                         }| j                  |z   |rt        d |D              ndz   }| j                  r|dz  }t        | j                  |      S )Nr$   c              3   2   K   | ]  }t        |        y wr{   r&   )r   lines     rV   r   z*Syntax.__rich_measure__.<locals>.<genexpr>Z  s     4d8D>4s   r   )
r"   unpackr   r   r   r/   r   
splitlinesmaxr   )	rU   r   r  r   rightr   r   widthliness	            rV   __rich_measure__zSyntax.__rich_measure__N  s     $NN4<<85!T,??&OOd&@&@@7JQNEt995AA		$$&&&8=s4e441F 	
 QJE455u==rY   c              #      K   t        | j                  ||            }| j                  r3t        || j                  j                         | j                         y | y w)Nry   pad)r1   _get_syntaxr   r"   r   r\   )rU   r   r  segmentss       rV   __rich_console__zSyntax.__rich_console__`  sR      D,,Wg>?<< @ @ B  Ns   A A"c              #   |	  K   | j                         j                  }| j                  4| j                  r|j                  | j
                  z
  dz
  n|j                  n| j                  }| j                  | j                        \  }}| j                  || j                        }| j                  s/| j                  s"| j                  s|s|j                  d       | j                         | j                  j                  t              z   t        d      z   | j                   z   }| j"                  r0|j$                  s$|j'                  | j(                  |      }d|_        |j                  r,|j-                  ||j/                  |      	      E d{    y|j1                  ||j/                  |dd
      | j                   dd      }	|	D ]  }
|
E d{     y| j                  xs d\  }}d}|rt3        d|dz
        }|j5                  d|      }| j                  r|t7        |      kD  ry||| }| j"                  r|j$                  s| j                         | j                  j                  t              z   t        d      z   | j                   z   }t9        d      j;                  |      j'                  | j(                  |t        d      z         j5                  dd      }| j
                  }|j/                  |      }| j<                  j>                  }t@        } |d      }|jB                  rdnd}| jE                  |      \  }}}tG        || jH                  |z         D ]@  \  }}| j                  r(|j1                  ||j/                  dd
      ||       }nMtK        |j-                  |d            }|jL                  r|g}n!|jO                  ||j                  ||       g}| j                  r |d|z  dz   |      }tQ        |      D ]y  \  }}|r`tS        |      jU                  |dz
        dz   } ||      r! ||t        d              |||       n |d|        |||       n| |E d{    | { ,|D ]  }|E d{    |  C y7 7 7 +7 w)zc
        Get the Segments for the Syntax object, excluding any vertical/horizontal padding
        Nr$   r   Tr9   )ry   crop)r  )r  r   )r  heightr   )ry   r  	new_lines)NNr   )allow_blankF)rt   z> u   ❱ )r  r   r   )r    rM   rA   r7   z  )+r   r   r   r   	max_widthr   _process_coder   r   r   r   remove_suffixr   rW   r   r   r   r   
ascii_onlywith_indent_guidesr   overflowrenderupdaterender_linesr	  splitr   r3   joinr   __contains__r0   legacy_windowsr  	enumerater   listr   adjust_line_lengthr%   rl   rjust) rU   r   r  r   r   
ends_on_nlprocessed_coder   ry   syntax_linessyntax_liner   end_lineline_offsetr  numbers_column_widthrender_optionshighlight_line_Segmentr   line_pointerr   r   r  r   r  wrapped_linesr  wrapped_line_left_padfirstwrapped_lineline_columns                                    rV   r  zSyntax._get_syntaxk  s     "&!5!5!7!N!N & $$ ""T%?%??!C&&  	 &*%7%7		%B"
N~~ndoo>  ""4( $$&++11':;D/" ''(  !!'*<*<..t}}E.J &++">>'..z."B *      '33NND&NQ//"  4   $0 +K***+#>,
Haa0K*.**Tz**R??SZ'+h/Eg&8&8$$&++11':;D/" ''(  T
e##DMMeAT9T#Ut.	   $99 j9--::D>&55t6 ##G,		
" 'udoo.KL *	#MGT~~ ' 4 4"))v)F*22	 !5 !  G <=??%-JM !33$*44"2$: :	 4 %M   (0..46F)% ,6m+D #'E<&)'l&8&89MPQ9Q&RUX&X)'2"*<U9K"LL"*;8N"OO"*41G"HH"*;"EE33+++"N# %2 #L+++"N#Q*	#m +^ , ,sJ   FR<R2AR<R5J4R<R8R<#R:$R<5R<8R<:R<r   c                    |j                   }dgt        j                  d|t        j                        D cg c]  }|j	                         dz    c}t        |      dz   }| j                  D ]Q  }t        ||j                        }t        ||j                        }|2|5|j                  |j                  ||       S yc c}w )z
        Apply stylized ranges to a text instance,
        using the given code to determine the right portion to apply the style to.

        Args:
            text (Text): Text instance to apply the style to.
        r   r   )flagsr$   N)plainrefinditer	MULTILINEr   r   r   #_get_code_index_for_syntax_positionr   r   ry   )rU   r   r   matchnewlines_offsetsstylized_ranger   r   s           rV   r   zSyntax._apply_stylized_ranges  s     zz 	
  [[t2<<H !		
 IM	
 #33 	?N7 ."6"6E 6 ."4"4C  S_^115#>	?s   Cc                     |j                  d      }|r|n|dz   }| j                  rt        j                  |      n|}|j                  | j                        }||fS )a  
        Applies various processing to a raw code string
        (normalises it so it always ends with a line return, dedents it if necessary, etc.)

        Args:
            code (str): The raw code string to process

        Returns:
            Tuple[bool, str]: the boolean indicates whether the raw code ends with a line return,
                while the string is the processed code.
        r   )r   r   textwrap
expandtabsr   )rU   r   r,  r-  s       rV   r  zSyntax._process_code  sY     ]]4(
!+/3{{HOON+ 	 (224==A>))rY   r{   )g333333?)r   r*   r  r+   rQ   r/   )1r]   r^   r_   r`   r   r~   r   rO   classmethodr   rl   r   DEFAULT_THEMEr   boolintr   r   r   r#   rq   r   r   r   r   ra   r(   r   propertyr   r3   r   r2   r   r   floatr   r   r*   r  r  r+   r-   r  r   r0   r  r   r  rb   rY   rV   r   r      s&   (  ..	U3#34 	 	 	  *7"DH.2$(*.#%&!$@$@ UCZ $@
 S+%&$@ $@ $@ $@ U8C=(3-#?@A$@ "#c(+$@ SM$@ $@ $@ #3-$@ $@  #!$@" 
#$@L   -1)6"04.2$(*.#%&!<
<
 <
 eSj)*	<

 S+%&<
 <
 <
 U38_-<
 <
 "#c(+<
 SM<
 <
 <
 #3-<
 <
  #!<
" 
#<
 <
| 's '(3- '3 ' 'R 

9 
% 
 x  * EISS U8C=(3-#?@AS 
	SjOO'5O<JO	O-U -U - s  F' FeE5%<O6P F.> >+;>	>$		)7			D#D#  D# 
'		D#L?4 ?D ?<*# *%c	*: *rY   r   rD  positionrQ   c                     t        |       }|\  }}||kD  st        |       |dz   k  ry|dz
  }| |dz      | |   z
  dz
  }t        ||      }| |   |z   S )a  
    Returns the index of the code string for the given positions.

    Args:
        newlines_offsets (Sequence[int]): The offset of each newline character found in the code snippet.
        position (SyntaxPosition): The position to search for.

    Returns:
        Optional[int]: The index of the code string for this position, or `None`
            if the given position's line number is out of range (if it's the column that is out of range
            we silently clamp its value so that it reaches the end of the line)
    r$   N)r   min)rD  rO  lines_countline_numbercolumn_index
line_indexline_lengths          rV   rB  rB  $  sy     &'K (K[ C(8$9[1_$MqJ":>25Ej5QQTUUK{L1LJ',66rY   __main__z&Render syntax to the console with Rich)descriptionr   PATHzpath to file, or - for stdin)metavarhelpz-cz--force-colorforce_color
store_truezforce color for non-terminals)destactionrg   r[  z-iz--indent-guidesr   Fzdisplay indent guidesz-lz--line-numbersr   zrender line numbers)r^  r_  r[  z-wz--widthr  z*width of output (default will auto-detect))typer^  rg   r[  z-rz--wrapr   zword wrap long linesz-sz--soft-wrap	soft_wrapzenable soft wrapping mode)r_  r^  rg   r[  z-tz--themere   zpygments theme)r^  rg   r[  z-bz--background-colorrn   zOverride background colorz-xz--lexerr   z
Lexer name)rg   r^  r[  z-pz	--paddingr   r"   )r`  rg   r^  r[  z--highlight-liner4  z)The line number (not index!) to highlight)r*   )force_terminalr  -)	r   r   r   r   re   rn   r   r   r   )r   r   r   re   rn   r   r   r   )ra  )os.pathr   platformr?  sysrG  abcr   r   pathlibr   typingr   r   r   r	   r
   r   r   r   r   r   r   pip._vendor.pygments.lexerr   pip._vendor.pygments.lexersr   r   pip._vendor.pygments.styler   r~   pip._vendor.pygments.stylesr   pip._vendor.pygments.tokenr   r   r   r   r   r   r   r   r   r   pip._vendor.pygments.utilr    pip._vendor.rich.containersr!   pip._vendor.rich.paddingr"   r#   _loopr%   cellsr'   r8   r(   r)   r   r*   r+   r,   r-   jupyterr.   measurer/   segmentr0   r1   ry   r2   r   r3   rl   ra   systemWINDOWSrJ  PreprocWordBuiltinFunction	NamespaceClass	Exception	DecoratorVariableConstant	AttributeTagDeletedInsertedHeading
SubheadingPromptrE   r   rJ   r   r   rO   rd   r   rL  r   r   r   rB  r]   argparseArgumentParserparseradd_argument
parse_argsargspip._vendor.rich.consoler\  r  r   stdinreadr   r   r   r   re   rn   r   r   r4  syntaxr   printra  rb   rY   rV   <module>r     s     	 
  #     - S = 9   4 - ?   # I I !   & # #s(O	
(//
y
(
&	57&G$& Ut_& OOU(	&
 U & LL%f%& MM5y)& 	LL%f%& 	MM5w'& 	NNE$7& 	JJGt4& 	NNE'& 	NNE	5& 	MM5u%& 	MM5u%&  	NNE'!&" 	HHe-(#&$ E!
EOOU.e'*OOU%ID9NNEt$MM5|,	5u-5&
DE!" :%	57%N+% Ut_% OOU/	%
 U'% LL%m,% MM5/0% 	LL%m,% 	MM5~.% 	NNE>% 	JJNd;% 	NNE.% 	NNE 0t<% 	MM5|,% 	MM5|,%  	NNE.!%" 	HHe-(#%$ E!
E&OOU.e.1OOU%$44@NNEt$MM5|,	5u-5%	4	5 ! : %/YG !" "# "'&+ '&T&k &B sCx	J 	~*\ ~*B7sm7/=7c]76 z$X$$<F +  
 ,   $   "   9   #   (   igy?O   (      kQYY   8   D0T%5%5TZZHGyyCyy~~//**nn**!22,,LL!001

 !!II//**nn**!22,,LL!001 " 

 MM&DNNM3k rY   