
    %e              	          d dl Z d dlZd dlmZmZmZmZmZ d dlm	Z	 d dl
mZ erd dlmZ d  ee	d          D             Z e j        d	d
                    e           d          ZdedefdZdddefdZdedefdZdee         defdZdedeeef         fdZdedefdZ eh d e edd                    dhz
  z            Zd Z de!defdZ" e j        d          Z#d  Z$ e j        d!          Z%d"edefd#Z&dS )$    N)TYPE_CHECKINGAnyOptionalTuplecast)
ALL_EMOJIS)StreamlitAPIException)SupportsStrc                 6    g | ]}t          j        |          S  )reescape).0es     5lib/python3.11/site-packages/streamlit/string_util.py
<listcomp>r      s     HHH!1HHH    T)reversez^(|z)[_ -]*(.*)stringreturnc                 ,    |                      d          S )zDecodes a string as ascii.ascii)decoder   s    r   decode_asciir   !   s    ==!!!r   textr
   c                 h    t          j        t          |                                                     S )z;Convert an object to text, dedent it, and strip whitespace.)textwrapdedentstrstripr   s    r   
clean_textr$   &   s$    ?3t99%%++---r   c                 <    |                      dd          t          v S )z'Check if input string is a valid emoji.u   ️ )replacer   r#   s    r   is_emojir(   +   s    <<b))Z77r   maybe_emojic                 R    | dS t          |           r| S t          d|  d          )Nr&   zThe value "zZ" is not a valid emoji. Shortcodes are not allowed, please use a single character instead.)r(   r	   )r)   s    r   validate_emojir+   0   sO    r	+		 
# B+  B  B  B
 
 	
r   c                     t          j        t          |           }|d| fS t          t          |          }|                    d          |                    d          fS )zReturn a tuple containing the first emoji found in the given string and
    the rest of the string (minus an optional separator between the two).
    Nr&         )r   searchEMOJI_EXTRACTION_REGEXr   r   group)r   re_matchs     r   extract_leading_emojir3   ;   sY     y/66H4x
 #311H>>!hnnQ////r   
raw_stringc                 N    g d}| }|D ]}|                     |d|z             }|S )aI  Returns a new string which escapes all markdown metacharacters.

    Args
    ----
    raw_string : str
        A string, possibly with markdown metacharacters, e.g. "1 * 2"

    Returns
    -------
    A string with all metacharacters escaped.

    Examples
    --------
    ::
        escape_markdown("1 * 2") -> "1 \\* 2"
    )\*-=`!#r   r6   )r'   )r4   metacharactersresult	characters       r   escape_markdownr@   J   sB    " ?>>NF# = =		4)+;<<Mr   >         	   
                      c                 R    t          |                     dt                              S )z8Guess if an input bytesarray can be encoded as a string.N)bool	translate	TEXTCHARS)inps    r   is_binary_stringrP   e   s      dI..///r   numc                 X   t          d                    |                     }d}t          |          dk    r|dz  }|dz  }t          |          dk    d                    d                    |                              d                              d	          g d
|                   S )z9Simplifies number into Human readable format, returns strz{:.2g}r   i  r-   g     @@z{}{}z{:f}0.)r&   kmbt)floatformatabsrstrip)rQ   num_converted	magnitudes      r   simplify_numberr_   k   s    (//#..//MI
m


$
$Q	 m


$
$ ==m$$++C0077<<   +  r   z0^\<[a-zA-Z_]+[a-zA-Z0-9<>._ ]* at 0x[0-9a-f]+\>$c                 >    t                               |           rdS dS )zAReturns True if the string looks like <foo blarg at 0x15ee6f9a0>.TF)_OBJ_MEM_ADDRESSmatchr   s    r   is_mem_address_strrc   {   s"    f%% t5r   z(?:</[^<]+>)|(?:<[^<]+/>)sc                 P    t          t                              |                     S )zReturns True if the given string contains what seem to be HTML tags.

    Note that false positives/negatives are possible, so this function should not be
    used in contexts where complete correctness is required.)rL   _RE_CONTAINS_HTMLr/   )rd   s    r   probably_contains_html_tagsrg      s!    
 !((++,,,r   )'r   r   typingr   r   r   r   r   streamlit.emojisr   streamlit.errorsr	   streamlit.type_utilr
   sortedESCAPED_EMOJIcompilejoinr0   bytesr!   r   r$   rL   r(   r+   r3   r@   	bytearraysetrangerN   rP   intr_   ra   rc   rf   rg   r   r   r   <module>ru      sx   
			  < < < < < < < < < < < < < < ' ' ' ' ' ' 2 2 2 2 2 2 0////// IHvvj$'G'G'GHHH#$M-)@)@$M$M$MNN " "3 " " " "
.] .s . . . .
83 84 8 8 8 8

 
# 
 
 
 
0 0c3h 0 0 0 0     0 I///##eeD%6H6H2I2ITF2RRSS	0 0 0
 
 
 
 
 
 2:QRR    BJ;<< -3 -4 - - - - - -r   