
    h\                     v   S SK r S SKrS SKrS SKrS SKJrJrJrJr  \	" \R                  S5      (       a  \R                  R                  OSr\=(       d    Sr\R                  5       S;  rSr " S S\5      r\R&                  S	\R(                  S
\R*                  S\R,                  SSS
SS	SSSSSSSSSSSSSS0r\R&                  \(       d  SOS\R(                  \(       d  SOS\R*                  \(       d  SOS \R,                  \(       d  S!OS"0rS#rS$r    S?S%\S&\\\\4      S'\\\\4      S(\S)\S*\4S+ jjrS@S%\S,\S-\S*\4S. jjrSAS/\S0\S1\S*\4S2 jjr    SBS3\S4\S&\\\4   S'\\\\4   \\\4   4   S5\S*\4S6 jjr! SCS7\S8\\\\4      S-\S*\4S9 jjr"SDS:\S;\S*\4S< jjr#S:\S*\4S= jr$S*\4S> jr%g)E    N)AnyOptionalTupleUnionencodingascii)utf8zutf-8ANSI_COLORS_DISABLEDc                   $    \ rS rSrSrSrSrSrSrg)MESSAGES   goodfailwarninfo N)	__name__
__module____qualname____firstlineno__GOODFAILWARNINFO__static_attributes__r       E/home/james-whalen/.local/lib/python3.13/site-packages/wasabi/util.pyr   r      s    DDDDr   r               redgreenyellowbluepink   cyan   white   grey   blackr   u   ✔z[+]u   ✘z[x]u   ⚠z[!]u   ℹz[i]+-textfgbgbold	underlinereturnc                    [         R                  X5      n[         R                  X"5      n[        XU/5      (       d  U $ / nU(       a  UR                  S5        U(       a  UR                  S5        U(       a   UR                  SR	                  U5      5        U(       a   UR                  SR	                  U5      5        SR	                  SR                  U5      U 5      $ )a{  Color text by applying ANSI escape sequence.

text (str): The text to be formatted.
fg (Optional[Union[str, int]]): Optional foreground color. String name or 0 - 256 (see COLORS).
bg (Optional[Union[str, int]]): Optional background color. String name or 0 - 256 (see COLORS).
bold (bool): Format text in bold.
underline (bool): Underline text.
RETURNS (str): The formatted text.
14z38;5;{}z48;5;{}z[{}m{}[0m;)COLORSgetanyappendformatjoin)r1   r2   r3   r4   r5   styless         r   colorrB   3   s      
B	B	B	B~Fcc	i&&r*+	i&&r*+%%chhv&6==r   wrap_maxindentc           	      p    US-  nU[        U5      -
  n[        U 5      n [        R                  " U UUUSSS9$ )a  Wrap text at given width using textwrap module.

text (Any): The text to wrap.
wrap_max (int): Maximum line width, including indentation. Defaults to 80.
indent (int): Number of spaces used for indentation. Defaults to 4.
RETURNS (str): The wrapped text with line breaks.
 F)widthinitial_indentsubsequent_indentbreak_long_wordsbreak_on_hyphens)lenstrtextwrapfill)r1   rC   rD   
indent_str
wrap_widths        r   wraprR   S   sG     #JC
O+Jt9D==!$ r   objmax_lenellipsisc                     [        U 5      n[        U5      U:  a'  [        US-  5      nSR                  USU X#U* S 5      $ U$ )a^  Wrapper around `repr()` to print shortened and formatted string version.

obj: The object to represent.
max_len (int): Maximum string length. Longer strings will be cut in the
    middle so only the beginning and end is displayed, separated by ellipsis.
ellipsis (str): Ellipsis character(s), e.g. "...".
RETURNS (str): The formatted representation.
r   z{} {} {}N)reprrL   intr?   )rS   rT   rU   stringhalfs        r   format_reprr[   h   sM     #YF
6{g7Q;  $.IIr   abadd_symbolsc           
      `   U R                  S5      nUR                  S5      n/ n[        R                  " SXV5      nUR                  5        H  u  ppnU	S:X  a  XZU  H  nUR	                  U5        M     U	S:X  d  U	S:X  aF  XlU  H>  nU(       a  SR                  [        U5      OUnUR	                  [        XUS   S95        M@     U	S	:X  d  U	S:X  d  M  XZU  H>  nU(       a  SR                  [        U5      OUnUR	                  [        XUS
   S95        M@     M     SR                  U5      $ )a'  Compare two strings and return a colored diff with red/green background
for deletion and insertions.

a (str): The first string to diff.
b (str): The second string to diff.
fg (Union[str, int]): Foreground color. String name or 0 - 256 (see COLORS).
bg (Union[Tuple[str, str], Tuple[int, int]]): Background colors as
    (insert, delete) tuple of string name or 0 - 256 (see COLORS).
add_symbols (bool): Whether to add symbols before the diff lines. Uses '+'
    for inserts and '-' for deletions. Default is False.
RETURNS (str): The formatted diff.

Nequalinsertreplacez{} {}r   )r2   r3   deleter   )
splitdifflibSequenceMatcherget_opcodesr>   r?   INSERT_SYMBOLrB   DELETE_SYMBOLr@   )r\   r]   r2   r3   r^   a_listb_listoutputmatcheropcodea0a1b0b1items                  r   diff_stringsru   y   s   & WWT]FWWT]FF%%dF;G")"5"5"7BBW"d# &X9!4">Iw~~mT:teDBqE:; & X9!4">Iw~~mT:teDBqE:; & #8 99Vr   descriptiondefaultc                     U(       a  SR                  U5      OSn[        SR                  X5      US9n[        U5      nU$ )a  Get user input from the command line via raw_input / input.

description (str): Text to display before prompt.
default (Optional[Union[str, bool]]): Optional default value to display with prompt.
indent (int): Indentation in spaces.
RETURNS (str): User input.
z (default: {}) z{}{}: )rD   )r?   rR   input)rv   rw   rD   
additionalprompt
user_inputs         r   get_raw_inputr~      s=     6=!((1"J(//+:6JFvJr   rY   errorsc                 f    [        U 5      n U R                  [        U5      R                  S5      n U $ )zMangle non-supported characters, for savages with ASCII terminals.

string (Any): The string to escape.
errors (str): The str.encode errors setting. Defaults to `"replace"`.
RETURNS (str): The escaped string.
r	   )rM   encodeENCODINGdecode)rY   r   s     r   locale_escaper      s-     [F]]8V,33F;FMr   c                 P     U R                  [        5        g! [         a     gf = f)zCheck if terminal can render unicode characters, e.g. special loading
icons. Can be used to display fallbacks for ASCII terminals.

string (str): The string to render.
RETURNS (bool): Whether the terminal can render the text.
TF)r   r   UnicodeEncodeError)rY   s    r   
can_renderr      s(    h s    
%%c                      [         R                  " [        5      (       a  g SSKJn   U " 5         g! [
         a-    [        R                  S:X  a  S[         R                  ;  a   g gf = f)zReturns True if the running system's terminal supports ANSI escape
sequences for color, formatting etc. and False otherwise.

RETURNS (bool): Whether the terminal supports ANSI colors.
Fr   just_fix_windows_consolewin32ANSICONT)	osgetenvENV_ANSI_DISABLEDcoloramar   ImportErrorsysplatformenvironr   s    r   supports_ansir      s[     
yy"###5
 	!"  <<7"y

'B s   0 2A'&A')NNFF)P   r!   )2   z...)r.   )r#   r"   F)Fr!   )rc   )&rf   r   r   rN   typingr   r   r   r   hasattrstdoutr   STDOUT_ENCODINGr   lowerNO_UTF8r   objectr   r   r   r   r   r;   ICONSri   rj   rM   rX   boolrB   rR   r[   ru   r~   r   r   r   r   r   r   <module>r      s    	 
  . .)0Z)H)H#**%%d%g
..
"3
3 + v  MM1MM1MM1MM1	1Qa
A
A
AQ
AR
$ MM78MM78MM78MM78		 
 %)$(>
>sCx!> 	sCx!> 	>
 > 	>@s c  C *S 3 s s ( "2B#
#
# 	c3h# 	eCHouS#X./	#
 # 	#N RS'c4i(89KN 	# 	s 	3 	s t t r   