
    'hQ                     f   d dl Z d dlZd dlZd dlmZmZmZ ed#d       Zedeee	f   de	fd       Zdedee	f   dede	f   fdZed#d       Z
edeee	f   defd	       Z
dedee	f   dedef   fd
Z
 ed      D  ci c]  } |  ed       c} Z ed      ed<   ej                         ZdD ]  Ze ee      =  ej#                  e      Zej#                  e      Zd$dedefdZd%dZd Zde	defdZde	defdZd Zd Zd Zd ZdZdZdZdZdedee   fd Z dedee   fd!Z!defd"Z"yc c} w )&    N)IterableUnionoverloadstr_or_bytesreturnc                      y N r   encode_argss     p/var/www/html/scrapers/gsc/venv/lib/python3.12/site-packages/seleniumwire/thirdparty/mitmproxy/utils/strutils.pyalways_bytesr              c                      y r	   r
   r   s     r   r   r      r   r   c                     | t        | t              r| S t        | t              r | j                  | S t	        dj                  t        |       j                              )N"Expected str or bytes, but got {}.)
isinstancebytesstrencode	TypeErrorformattype__name__r   s     r   r   r      sV    z,>	L#	&"|""K00<CCDDVD_D_`aar   c                      y r	   r
   r   s     r   
always_strr      r   r   c                      y r	   r
   r   s     r   r   r       r   r   c                     | t        | t              r| S t        | t              r | j                  | S t	        dj                  t        |       j                              )z6
    Returns,
        str_or_bytes unmodified, if
    r   )r   r   r   decoder   r   r   r   )r   decode_argss     r   r   r   %   sX    
 z,<	L%	("|""K00<CCDDVD_D_`aar       .   )
	textc                     t        | t              s-t        dj                  t	        |       j
                              |rt        nt        }| j                  |      S )z
    Replace all unicode C1 control characters from the given text with a single "."

    Args:
        keep_spacing: If True, tabs and newlines will not be replaced.
    z#text type must be unicode but is {})	r   r   
ValueErrorr   r   r   _control_char_trans_newline_control_char_trans	translate)r(   keep_spacingtranss      r   escape_control_charactersr0   C   sI     dC >EEd4jFYFYZ[[+7'=PE>>%  r   c                 *   t        | t              s.t        dj                  | j                  j
                              t        d| z         j                  d      dd }|st        j                  dd |      }|rt        j                  dd	 |      }|S )
a8  
    Take bytes and return a safe string that can be displayed to the user.

    Single quotes are always escaped, double quotes are never escaped:
        "'" + bytes_to_escaped_str(...) + "'"
    gives a valid Python string.

    Args:
        keep_spacing: If True, tabs and newlines will not be escaped.
    zdata must be bytes, but is {}   "b   z(?<!\\)(\\\\)*\\'c                 2    | j                  d      xs ddz   S )N    ')groupms    r   <lambda>z&bytes_to_escaped_str.<locals>.<lambda>c   s    aggaj6FB#5M r   z(?<!\\)(\\\\)*\\([nrt])c                 n    | j                  d      xs dt        ddd      | j                  d         z   S )Nr7   r8   r&   r%   r'   )nrtr4   )r:   dictr;   s    r   r=   z&bytes_to_escaped_str.<locals>.<lambda>g   s/    qwwqz'R4$$$+GPQ
+SS r   )
r   r   r*   r   	__class__r   reprlstripresub)datar.   escape_single_quotesrets       r   bytes_to_escaped_strrK   Q   s     dE"8??@W@WXYY td{

"
"3
'"
-Cff)+MsSff&S

 Jr   c                     t        | t              s.t        dj                  | j                  j
                              t        j                  |       d   S )z
    Take an escaped string and return the unescaped bytes equivalent.

    Raises:
        ValueError, if the escape sequence is invalid.
    zdata must be str, but is {}r   )r   r   r*   r   rC   r   codecsescape_decoderH   s    r   escaped_str_to_bytesrP   m   sG     dC 6==dnn>U>UVWW %a((r   sc                 r    | rt        |       dk(  ryt        d | d d D              t        | d d       z  dkD  S )Nr   Fc              3   X   K   | ]"  }|d k  xs d|cxk  xr dk  nc xs d|k   $ yw)	      r"   ~   Nr
   .0is     r   	<genexpr>z is_mostly_bin.<locals>.<genexpr>   s5       	
A'a"'a's   (*d   g333333?)lensumrQ   s    r   is_mostly_binr_   |   sP    A! 4C  	AdsG  r   c                 @    | j                         j                  d      S )N   <)strip
startswithr^   s    r   is_xmlrd      s    779%%r   c                 $    | r| d   dk(  r| dd S | S )a  
        Many editors will silently add a newline to the final line of a
        document (I'm looking at you, Vim). This function fixes this common
        problem at the risk of removing a hanging newline in the rare cases
        where the user actually intends it.
    r5   r&   Nr
   )rA   s    r   clean_hanging_newlinerf      s!     	QrUd]"vHr   c           	   #   >  K   t        dt        |       d      D ]  }dj                  |      }| ||dz    }dj                  d |D              }|j	                  d      }t        t        |j                  dd      j                  d	d
      d            }|||f  yw)zK
        Returns:
            A generator of (offset, hex, str) tuples
    r      z{:0=10x} c              3   >   K   | ]  }d j                  |        yw)z{:0=2x}N)r   rW   s     r   rZ   zhexdump.<locals>.<genexpr>   s     7QY%%a(7s   /   asciireplaceu   �r#   FN)	ranger\   r   joinljustr   r0   r    rm   )rQ   rY   offsetpartx	part_reprs         r   hexdumpru      s     
 1c!fb! 	%""1%1r6{HH7$77GGBK8KK+33ItD 
 	 q)$$	%s   BBc                 N    t        t        | j                  d            dz         S Nr   i   chrordr:   matchobjs    r   _move_to_private_code_planer}           s8>>!$%.//r   c                 N    t        t        | j                  d            dz
        S rw   rx   r{   s    r    _restore_from_private_code_planer      r~   r   z(?<!\\)(?:\\\\)*z[\s\S]*?z.*?z(?:.|(?<=\\)\n)*?rH   area_delimiterc                     t        j                  dj                  dj                  |            | t         j                        S )an  
    Split a string of code into a [code, special area, code, special area, ..., code] list.

    For example,

    >>> split_special_areas(
    >>>     "test /* don't modify me */ foo",
    >>>     [r"/\*[\s\S]*?\*/"])  # (regex matching comments)
    ["test ", "/* don't modify me */", " foo"]

    "".join(split_special_areas(x, ...)) == x always holds true.
    z({})|)flags)rF   splitr   ro   	MULTILINE)rH   r   s     r   split_special_areasr      s4      88chh~./ll r   c                 (   t        j                         }t        | |      }t        j                  dj                  |            }t        |      D ]1  \  }}|dz  r|j                  t        |      }|j                  |       3 |j                         S )u  
    Escape all control characters present in special areas with UTF8 symbols
    in the private use plane (U+E000 t+ ord(char)).
    This is useful so that one can then use regex replacements on the resulting string without
    interfering with special areas.

    control_characters must be 0 < ord(x) < 256.

    Example:

    >>> print(x)
    if (true) { console.log('{}'); }
    >>> x = escape_special_areas(x, "{", ["'" + SINGLELINE_CONTENT + "'"])
    >>> print(x)
    if (true) { console.log('�}'); }
    >>> x = re.sub(r"\s*{\s*", " {
    ", x)
    >>> x = unescape_special_areas(x)
    >>> print(x)
    if (true) {
        console.log('{}'); }
    z[{}]r4   )ioStringIOr   rF   compiler   	enumeraterG   r}   writegetvalue)rH   r   control_charactersbufpartsrexrY   rs   s           r   escape_special_areasr      s|    4 ++-Cn5E
**W^^$67
8C%  1q53Q7A		! <<>r   c                 8    t        j                  dt        |       S )zs
    Invert escape_special_areas.

    x == unescape_special_areas(escape_special_areas(x)) always holds true.
    z[\ue000-\ue0ff])rF   rG   r   rO   s    r   unescape_special_areasr      s     66$&FMMr   )r   Nr   N)T)FF)#rM   r   rF   typingr   r   r   r   r   r   r   rn   rz   r,   copyr+   rs   	maketransr0   rK   rP   boolr_   rd   rf   ru   r}   r   	NO_ESCAPEMULTILINE_CONTENTSINGLELINE_CONTENT#MULTILINE_CONTENT_LINE_CONTINUATIONr   r   r   )rs   s   0r   <module>r      s%    	 	 , , 
 
 
uS%Z0 5  
buT3%56 btUZ{I[ b 
 
 
U3:.   

bU4e#34 
buTSVYGW 
b& 2Y	 s3xK  s8 C 1668 	 ,A#CF+, mm$78 !mm,GH !C !s !8)U t &e & &	%"00  	  &: # .!! !HN Nus   =D.