
    :Qg=                        d Z ddlZddlZddlZddlmZmZmZmZm	Z	m
Z
mZmZ ej                  dk  rddlmZmZmZ n
ddlmZmZmZ ddlmZ ddlmZmZmZmZmZmZ g dZd	Zd
Z G d de      Z G d d      Zeefddddfde dee e f   de
ed      de de
e!   de
ee ee ee e f   ge f   f      de fdZ"	 d&de de#de#dee   fdZ$eefdddfde dee e f   de de
e!   de
ee ee ee e f   ge f   f      de fdZ%	 	 d'de dee ee ee e f   ge f   f   de!de fdZ&de de	e   fdZ'de de	e    fd Z(d(de d!e#de)fd"Z*de de#fd#Z+de de#fd$Z,de de!fd%Z-y))z4
emoji.core
~~~~~~~~~~

Core components for emoji.

    N)AnyCallableDictIteratorListOptionalTupleUnion)   	   )LiteralMatch	TypedDict)unicode_codes)Token
EmojiMatchEmojiMatchZWJEmojiMatchZWJNonRGItokenizefilter_tokens)emojizedemojizeanalyzeconfig
emoji_listdistinct_emoji_listemoji_countreplace_emojiis_emojipurely_emojiversionr   r   r   r   :uB   \w\-&.’”“()!#*+,/«»゙ًَُِ̧̀́̂̃̆̈̊ٓٔ・゚ٕc                   ,    e Zd ZU eed<   eed<   eed<   y)_EmojiListReturnemojimatch_start	match_endN)__name__
__module____qualname__str__annotations__int     G/var/www/html/answerous/venv/lib/python3.12/site-packages/emoji/core.pyr$   r$   4   s    JNr/   r$   c                   F    e Zd ZdZdZ	 dZ	 eddeee	   e	df   fd       Z
y)r   zModule-wide configurationTFNlanguagec                     t        | t              r| gn| r| nt        j                  }|D ]  }t        j                  |        y)u  Load one or multiple languages into memory.
        If no language is specified, all languages will be loaded.

        This makes language data accessible in the :data:`EMOJI_DATA` dict.
        For example to access a French emoji name, first load French with

         ``emoji.config.load_language('fr')``

        and then access it with

         ``emoji.EMOJI_DATA['🏄']['fr']``

        Available languages are listed in :data:`LANGUAGES`N)
isinstancer+   r   	LANGUAGESload_from_json)r2   	languageslangs      r0   load_languagezconfig.load_language^   sL    $ (C( J  (( 	  	/D((.	/r/   N)r(   r)   r*   __doc__demojize_keep_zwjreplace_emoji_keep_zwjstaticmethodr
   r   r+   r9   r.   r/   r0   r   r   :   sH    #. # /d3id&: ; / /r/   r   enstring
delimitersvariant)	text_type
emoji_typer2   r!   handle_versionreturnc                 2   t        j                         t        j                  dt        j                  d         dt
        dt        j                  d         d      }dt        t           dt        ffd	}|j                  ||       S )
u/  
    Replace emoji names in a string with Unicode codes.
        >>> import emoji
        >>> print(emoji.emojize("Python is fun :thumbsup:", language='alias'))
        Python is fun 👍
        >>> print(emoji.emojize("Python is fun :thumbs_up:"))
        Python is fun 👍
        >>> print(emoji.emojize("Python is fun {thumbs_up}", delimiters = ("{", "}")))
        Python is fun 👍
        >>> print(emoji.emojize("Python is fun :red_heart:", variant="text_type"))
        Python is fun ❤
        >>> print(emoji.emojize("Python is fun :red_heart:", variant="emoji_type"))
        Python is fun ❤️ # red heart, not black heart

    :param string: String contains emoji names.
    :param delimiters: (optional) Use delimiters other than _DEFAULT_DELIMITER. Each delimiter
        should contain at least one character that is not part of a-zA-Z0-9 and ``_-&.()!?#*+,``.
        See ``emoji.core._EMOJI_NAME_PATTERN`` for the regular expression of unsafe characters.
    :param variant: (optional) Choose variation selector between "base"(None), VS-15 ("text_type") and VS-16 ("emoji_type")
    :param language: Choose language of emoji name: language code 'es', 'de', etc. or 'alias'
        to use English aliases
    :param version: (optional) Max version. If set to an Emoji Version,
        all emoji above this version will be ignored.
    :param handle_version: (optional) Replace the emoji above ``version``
        instead of ignoring it. handle_version can be either a string or a
        callable; If it is a callable, it's passed the Unicode emoji and the
        data dict from :data:`EMOJI_DATA` and must return a replacement string
        to be used::

            handle_version('\U0001F6EB', {
                'en' : ':airplane_departure:',
                'status' : fully_qualified,
                'E' : 1,
                'alias' : [':flight_departure:'],
                'de': ':abflug:',
                'es': ':avión_despegando:',
                ...
            })

    :raises ValueError: if ``variant`` is neither None, 'text_type' or 'emoji_type'

    (r   [z]+   )matchrF   c                    | j                  d      t        d         t        d           }t        j                  t        t        j                  d|      z   t        z         }|| j                  d      S t        j                  |   d   kD  rit              rPt        j                  |   j                         }| j                         |d<   | j                         |d<    ||      S t              S ydt        j                  |   vr|S |d	   d
k(  s|d	   dk(  r|dd	 }dk(  r|d
z   S dk(  r|dz   S t        d      )NrJ   r   NFKCEr&   r'    rB   u   ︎u   ️rC   rD   zDParameter 'variant' must be either None, 'text_type' or 'emoji_type')grouplenr   get_emoji_by_name_DEFAULT_DELIMITERunicodedata	normalize
EMOJI_DATAcallablecopystartendr+   
ValueError)	rL   nameemjemj_datarA   rE   r2   rB   r!   s	       r0   replacezemojize.<locals>.replace   sg   {{1~c*Q-0C
14F3FG--##FD12 ! 	
 ;;;q>!=#;#;C#@#E#O'(33C8==?*/++-'(-		%%c844+>**?i}/G/G/LLJr7h#b'X"5a)Ck!>!$>!V r/   )	r   r6   recompileescape_EMOJI_NAME_PATTERNr   r+   sub)r@   rA   rB   r2   r!   rE   patternra   s    `````  r0   r   r   z   sz    f   *jj99Z]#%8"))JqM:R	TG
%uSz %c % %N ;;w''r/   	non_emoji
join_emojic                 6    t        t        | d      | |      S )a  
    Find unicode emoji in a string. Yield each emoji as a named tuple
    :class:`Token` ``(chars, EmojiMatch)`` or :class:`Token` ``(chars, EmojiMatchZWJNonRGI)``.
    If ``non_emoji`` is True, also yield all other characters as
    :class:`Token` ``(char, char)`` .

    :param string: String to analyze
    :param non_emoji: If True also yield all non-emoji characters as Token(char, char)
    :param join_emoji: If True, multiple EmojiMatch are merged into a single
        EmojiMatchZWJNonRGI if they are separated only by a ZWJ.
    Tkeep_zwj
emoji_onlyri   )r   r   )r@   rh   ri   s      r0   r   r      s!     $'	Mj r/   c                     dk(  rddndt        j                         dt        dt        ffdt	        | t
        j                        }d	j                  fd
|D              S )u  
    Replace Unicode emoji in a string with emoji shortcodes. Useful for storage.
        >>> import emoji
        >>> print(emoji.emojize("Python is fun :thumbs_up:"))
        Python is fun 👍
        >>> print(emoji.demojize("Python is fun 👍"))
        Python is fun :thumbs_up:
        >>> print(emoji.demojize("icode is tricky 😯", delimiters=("__", "__")))
        Unicode is tricky __hushed_face__

    :param string: String contains Unicode characters. MUST BE UNICODE.
    :param delimiters: (optional) User delimiters other than ``_DEFAULT_DELIMITER``
    :param language: Choose language of emoji name: language code 'es', 'de', etc. or 'alias'
        to use English aliases
    :param version: (optional) Max version. If set to an Emoji Version,
        all emoji above this version will be removed.
    :param handle_version: (optional) Replace the emoji above ``version``
        instead of removing it. handle_version can be either a string or a
        callable ``handle_version(emj: str, data: dict) -> str``; If it is
        a callable, it's passed the Unicode emoji and the data dict from
        :data:`EMOJI_DATA` and must return a replacement string  to be used.
        The passed data is in the form of::

            handle_version('\U0001F6EB', {
                'en' : ':airplane_departure:',
                'status' : fully_qualified,
                'E' : 1,
                'alias' : [':flight_departure:'],
                'de': ':abflug:',
                'es': ':avión_despegando:',
                ...
            })

    aliasr?   TFemoji_matchrF   c                 |   | j                   J C| j                   d   kD  r1t              r! | j                  | j                               S S y| j                   v rOr/d| j                   v r!d   | j                   d   d   dd z   d   z   S d   | j                      dd z   d   z   S | j                  S )NrO   rP   rp   r   rJ   rQ   )datarY   r%   	data_copy)rq   _use_aliasesrA   rE   r2   r!   s    r0   handlezdemojize.<locals>.handle$  s    +++;#3#3C#87#B'%k&7&79N9N9PQQ+%%)));+;+; ;qMK$4$4W$=a$@2$FFTUV "!}{'7'7'A!B'GG*UV-WW $$$r/   rk   rP   c              3      K   | ]E  }t        |j                  t              rt         |j                              n|j                   G y wr:   r4   valuer   r+   ).0tokenrv   s     r0   	<genexpr>zdemojize.<locals>.<genexpr>9  s=       %/u{{J$GF5;; U[[X   AA)r   r6   r   r+   r   r   r<   join)r@   rA   r2   r!   rE   matchesru   rv   s    ```` @@r0   r   r      su    T 7  *%J %3 % %( v(@(@AG77   r/   ra   c                     dt         dt        ffdt        | t        j                        }t        j                  rt        |dd      }dj                  fd	|D              S )
a  
    Replace Unicode emoji in a customizable string.

    :param string: String contains Unicode characters. MUST BE UNICODE.
    :param replace: (optional) replace can be either a string or a callable;
        If it is a callable, it's passed the Unicode emoji and the data dict from
        :data:`EMOJI_DATA` and must return a replacement string to be used.
        replace(str, dict) -> str
    :param version: (optional) Max version. If set to an Emoji Version,
        only emoji above this version will be replaced.
    rq   rF   c                 L   dkD  rc| j                   J | j                   d   kD  r7t              r! | j                  | j                               S t	              S | j                  S t              r! | j                  | j                               S S | j                  S )NrQ   rO   )rs   rY   r%   rt   r+   )rq   ra   r!   s    r0   rv   zreplace_emoji.<locals>.handleP  s    R<##///$w.G$";#4#4k6K6K6MNNw<'
    	 g;,,k.C.C.EFF N   r/   rk   FTrm   rP   c              3      K   | ]E  }t        |j                  t              rt         |j                              n|j                   G y wr:   rx   )rz   mrv   s     r0   r|   z replace_emoji.<locals>.<genexpr>a  s<       !+177J ?F177OQWWLr}   )r   r+   r   r   r=   r   r~   )r@   ra   r!   r   rv   s    `` @r0   r   r   ?  s_    "!J !3 ! v(E(EFG$$EdK77   r/   c                     t        | d      D cg c]^  }t        |j                  t              rB|j                  j                  |j                  j
                  |j                  j                  d` c}S c c}w )u   
    Returns the location and emoji in list of dict format.
        >>> emoji.emoji_list("Hi, I am fine. 😁")
        [{'match_start': 15, 'match_end': 16, 'emoji': '😁'}]
    Frk   )r&   r'   r%   )r   r4   ry   r   r[   r\   r%   )r@   r   s     r0   r   r   g  s^     &51 aggz* 77==WW]]	
  s   A#A6c                 Z    t        t        |       D ch c]  }|d   	 c}      }|S c c}w )z0Returns distinct list of emojis from the string.r%   )listr   )r@   edistinct_lists      r0   r   r   y  s,    j.@A!G*ABM Bs   (uniquec                 V    |rt        t        |             S t        t        |             S )zr
    Returns the count of emojis in a string.

    :param unique: (optional) True if count only unique emojis
    )rS   r   r   )r@   r   s     r0   r   r     s(     &v.//z&!""r/   c                 &    | t         j                  v S )z{
    Returns True if the string is a single emoji, and it is "recommended for
    general interchange" by Unicode.org.
    )r   rX   r@   s    r0   r   r     s    
 ]----r/   c                 <    t        d t        | d      D              S )z
    Returns True if the string contains only emojis.
    This might not imply that `is_emoji` for all the characters, for example,
    if the string contains variation selectors.
    c              3   P   K   | ]  }t        |j                  t                 y wr:   )r4   ry   r   )rz   r   s     r0   r|   zpurely_emoji.<locals>.<genexpr>  s     X1z!'':.Xs   $&T)rh   )allr   r   s    r0   r    r      s     XRV8WXXXr/   c                    | t         j                  v rt         j                  |    d   S t        j                  | d      }|r(|t         j                  v rt         j                  |   d   S g dt        dt        t        t
        f   dt        ffd}t        | |d       rd	   S t        | d
d|       rd	   S t         j                  D ]  }t        | |d|       sd	   c S  t        d      )u]  
    Returns the Emoji Version of the emoji.

    See https://www.unicode.org/reports/tr51/#Versioning for more information.
        >>> emoji.version("😁")
        0.6
        >>> emoji.version(":butterfly:")
        3

    :param string: An emoji or a text containing an emoji
    :raises ValueError: if ``string`` does not contain an emoji
    rO   r?   r   
emoji_datarF   c                 .    j                  |d          y)NrO   rP   )append)r   r   r!   s     r0   fzversion.<locals>.f  s    z#'r/   rQ   )ra   r!   r   rp   )r2   r!   rE   zNo emoji found in string)
r   rX   rT   r+   r   r   r   r   r5   r]   )r@   emj_coder   	lang_coder!   s       @r0   r!   r!     s     )))''/44 ..vt<HH 8 88''1#66 GS d38n   &!R0qzFWbCqz",, 	BqI1:
 /
00r/   )FT)rP   rQ   )F).r;   rb   rV   systypingr   r   r   r   r   r   r	   r
   version_infotyping_extensionsr   r   r   r%   r   emoji.tokenizerr   r   r   r   r   r   __all__rU   re   r$   r   r+   floatr   boolr   r   r   r   r   r-   r   r   r    r!   r.   r/   r0   <module>r      s   
  
 N N Nf;;00  $   b y =/ =/D $67I"J<@#QUa(a(c3ha( g789a( 	a(
 e_a( U3#tCH~1F1K(L#LMNa( 	a(J >B 6:e_, $67I"J#QUJJc3hJ J e_	J
 U3#tCH~1F1K(L#LMNJ 	J^ AC%%3#tCH~!6!;<<=% % 		%Ps t$45 $ S	 # #T #c #.S .T .Y Y Y(1C (1E (1r/   