
    ՟f                         d Z ddlmZmZmZ ddlmZ ddlmZ de	dede	fdZ
	 dde	d
ee   deee	      deee	f   fdZy	)a.  This module contains auxiliary functionality for parsing MessageEntity objects.

Warning:
    Contents of this module are intended to be used internally by the library and *not* by the
    user. Changes to this module are not considered breaking changes and may not be documented in
    the changelog.
    )DictOptionalSequence)MessageEntity)TextEncodingtextentityreturnc                     | j                  t        j                        }||j                  dz  |j                  |j                  z   dz   }|j                  t        j                        S )a%  Returns the text from a given :class:`telegram.MessageEntity`.

    Args:
        text (:obj:`str`): The text to extract the entity from.
        entity (:class:`telegram.MessageEntity`): The entity to extract the text from.

    Returns:
        :obj:`str`: The text of the given entity.
       )encoder   	UTF_16_LEoffsetlengthdecode)r   r	   entity_texts      S/var/www/cvtools/html/venv/lib/python3.12/site-packages/telegram/_utils/entities.pyparse_message_entityr       sW     ++l445Kfmma/6==6==3PTU2UVKl4455    Nentitiestypesc                     |t         j                  }|D ci c]  }|j                  |v s|t        | |        c}S c c}w )aS  
    Returns a :obj:`dict` that maps :class:`telegram.MessageEntity` to :obj:`str`.
    It contains entities filtered by their ``type`` attribute as
    the key, and the text that each entity belongs to as the value of the :obj:`dict`.

    Args:
        text (:obj:`str`): The text to extract the entity from.
        entities (List[:class:`telegram.MessageEntity`]): The entities to extract the text from.
        types (List[:obj:`str`], optional): List of ``MessageEntity`` types as strings. If the
            ``type`` attribute of an entity is contained in this list, it will be returned.
            Defaults to :attr:`telegram.MessageEntity.ALL_TYPES`.

    Returns:
        Dict[:class:`telegram.MessageEntity`, :obj:`str`]: A dictionary of entities mapped to
        the text that belongs to them, calculated based on UTF-16 codepoints.
    )r   	ALL_TYPEStyper   )r   r   r   r	   s       r   parse_message_entitiesr   0   sN    & }'' BJ7=V[[\aMa$T622  s   ==)N)__doc__typingr   r   r   telegram._messageentityr   telegram._utils.stringsr   strr   r    r   r   <module>r"      sv   & , + 1 06s 6M 6c 6" TX
!-09A(3-9P	-
r   