
    ֤i\                        d dl Z d dlZd dlZd dlZd dlmZmZmZmZ  e	ej                  d      rej                  j                  ndZexs dZej                         dvZdZ G d de      Zej&                  d	ej(                  d
ej*                  dej,                  ddd
dd	ddddddddddddddiZej&                  esdndej(                  esdndej*                  esdnd ej,                  esd!nd"iZd#Zd$Z	 	 	 	 d?d%ed&eeeef      d'eeeef      d(ed)ed*efd+Zd@d%ed,ed-ed*efd.ZdAd/ed0ed1ed*efd2Z 	 	 	 dBd3ed4ed&eeef   d'eeeef   eeef   f   d5ed*efd6Z!	 dCd7ed8eeeef      d-ed*efd9Z"dDd:ed;ed*efd<Z#d:ed*efd=Z$d*efd>Z%y)E    N)AnyOptionalTupleUnionencodingascii)utf8zutf-8ANSI_COLORS_DISABLEDc                       e Zd ZdZdZdZdZy)MESSAGESgoodfailwarninfoN)__name__
__module____qualname__GOODFAILWARNINFO     \/var/www/vps2.regionflexible.com/Desarrollo/venv/lib/python3.12/site-packages/wasabi/util.pyr   r      s    DDDDr   r               redgreenyellowbluepink   cyan   white   grey   black   u   ✔z[+]u   ✘z[x]u   ⚠z[!]u   ℹz[i]+-textfgbgbold	underlinereturnc                    t         j                  ||      }t         j                  ||      }t        |||g      s| S g }|r|j                  d       |r|j                  d       |r |j                  dj	                  |             |r |j                  dj	                  |             dj	                  dj                  |      |       S )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)r/   r0   r1   r2   r3   styless         r   colorr@   3   s      
B	B	B	BB~Fcc	i&&r*+	i&&r*+%%chhv&6==r   wrap_maxindentc                 t    |dz  }|t        |      z
  }t        |       } t        j                  | |||dd      S )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)r/   rA   rB   
indent_str
wrap_widths        r   wraprP   S   sG     #JC
O+Jt9D==!$ r   objmax_lenellipsisc                     t        |       }t        |      |k\  r(t        |dz        }dj                  |d| ||| d       S |S )av  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)reprrJ   intr=   )rQ   rR   rS   stringhalfs        r   format_reprrY   h   sO     #YF
6{g7Q;  &$.IIr   abadd_symbolsc           
      J   | j                  d      }|j                  d      }g }t        j                  d||      }|j                         D ]  \  }	}
}}}|	dk(  r||
| D ]  }|j	                  |        |	dk(  s|	dk(  rD||| D ]<  }|rdj                  t        |      n|}|j	                  t        |||d                > |	d	k(  s|	dk(  s||
| D ]<  }|rdj                  t        |      n|}|j	                  t        |||d
                >  dj                  |      S )aO  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   )r0   r1   deleter   )
splitdifflibSequenceMatcherget_opcodesr<   r=   INSERT_SYMBOLr@   DELETE_SYMBOLr>   )rZ   r[   r0   r1   r\   a_listb_listoutputmatcheropcodea0a1b0b1items                  r   diff_stringsrs   y   s8   & WWT]FWWT]FF%%dFF;G")"5"5"7 <BBWr" $d#$X9!4r" <>Iw~~mT:teDRBqE:;< X9!4r" <>Iw~~mT:teDRBqE:;<< 99Vr   descriptiondefaultc                     |rdj                  |      nd}t        dj                  | |      |      }t        |      }|S )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{}{}: )rB   )r=   rP   input)rt   ru   rB   
additionalprompt
user_inputs         r   get_raw_inputr|      s?     6=!((1"J(//+z:6JFvJr   rW   errorsc                 f    t        |       } | j                  t        |      j                  d      } | S )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	   )rK   encodeENCODINGdecode)rW   r}   s     r   locale_escaper      s-     [F]]8V,33F;FMr   c                 N    	 | j                  t               y# t        $ r Y yw xY w)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)rW   s    r   
can_renderr      s(    h s    	$$c                      t        j                  t              ry	 ddlm}   |         y# t
        $ r* t        j                  dk(  rdt         j                  vrY yY yw xY w)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      sX     
yy"##5
 	!"  <<7"y

'B s   * .AA)NNFF)P   r   )2   z...)r+   )r    r   F)Fr   )ra   )&rd   r   r   rL   typingr   r   r   r   hasattrstdoutr   STDOUT_ENCODINGr   lowerNO_UTF8r   objectr   r   r   r   r   r9   ICONSrg   rh   rK   rV   boolr@   rP   rY   rs   r|   r   r   r   r   r   r   <module>r      s    	 
  . .)0Z)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   