
    'i6O                     (   d Z ddlZddlmZ ddlmZmZ ddlm	Z	 ddl
mZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZmZmZ ddlmZmZ ddlmZmZ ddl m!Z! erddlm"Z"  G d de      Z# G d de      Z$ G d de#      Z% G d de#      Z&y)z8This module contains objects that represent owned gifts.    N)Sequence)TYPE_CHECKINGFinal)	constants)Gift)MessageEntity)TelegramObject)
UniqueGift)User)enum)de_json_optionalde_list_optionalparse_sequence_arg)extract_tzinfo_from_defaultsfrom_timestamp)parse_message_entitiesparse_message_entity)JSONDict)Botc                        e Zd ZU dZdZej                  j                  Zee	   e
d<   	 ej                  j                  Zee	   e
d<   	 ddde	dedz  d	df fd
Zeddeddd	d f fd       Z xZS )	OwnedGifta  This object describes a gift received and owned by a user or a chat. Currently, it
    can be one of:

    * :class:`telegram.OwnedGiftRegular`
    * :class:`telegram.OwnedGiftUnique`

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`type` is equal.

    .. versionadded:: 22.1

    Args:
        type (:obj:`str`): Type of the owned gift.

    Attributes:
        type (:obj:`str`): Type of the owned gift.
    )typeREGULARUNIQUEN
api_kwargsr   r   returnc                    t         |   |       t        j                  t        j
                  ||      | _        | j                  f| _        | j                          y Nr   )	super__init__r   
get_memberr   OwnedGiftTyper   	_id_attrs_freeze)selfr   r   	__class__s      ]/home/obispo/Crisostomo_bridge/mision_env/lib/python3.12/site-packages/telegram/_ownedgift.pyr!   zOwnedGift.__init__C   sE     	J/)@)@$M	))    databot
Bot | Nonec                    | j                  |      }| j                  t        | j                  t        i}| t
        u r8|j                  d      |v r%||j                  d         j                  ||      S t        | !  ||      S )aX  Converts JSON data to the appropriate :class:`OwnedGift` object, i.e. takes
        care of selecting the correct subclass.

        Args:
            data (dict[:obj:`str`, ...]): The JSON data.
            bot (:class:`telegram.Bot`, optional): The bot associated with this object.

        Returns:
            The Telegram object.

        r   r*   r+   )
_parse_datar   OwnedGiftRegularr   OwnedGiftUniquer   getpopde_jsonr    )clsr*   r+   _class_mappingr'   s       r(   r4   zOwnedGift.de_jsonO   s     t$ KK)JJ6

 ) 0N B!$((6"23;;3;OOwDc22r)   N)__name__
__module____qualname____doc__	__slots__r   r#   r   r   str__annotations__r   r   r!   classmethodr4   __classcell__r'   s   @r(   r   r   )   s    $ I#1199GU3Z9;"0077FE#J7: '+	

 tO	

 

 38 3, 3+ 3 3r)   r   c                   x     e Zd ZdZdZ	 ddddedee   dedz  de	dz  f fd	Z
edd
e	dddd f fd       Z xZS )
OwnedGiftsau  Contains the list of gifts received and owned by a user or a chat.

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`total_count` and :attr:`gifts` are equal.

    .. versionadded:: 22.1

    Args:
        total_count (:obj:`int`): The total number of gifts owned by the user or the chat.
        gifts (Sequence[:class:`telegram.OwnedGift`]): The list of gifts.
        next_offset (:obj:`str`, optional): Offset for the next request. If empty,
            then there are no more results.

    Attributes:
        total_count (:obj:`int`): The total number of gifts owned by the user or the chat.
        gifts (Sequence[:class:`telegram.OwnedGift`]): The list of gifts.
        next_offset (:obj:`str`): Optional. Offset for the next request. If empty,
            then there are no more results.
    )giftsnext_offsettotal_countNr   rF   rD   rE   r   c                    t         |   |       || _        t        |      | _        || _        | j                  | j                  f| _        | j                          y r   )r    r!   rF   r   rD   rE   r$   r%   )r&   rF   rD   rE   r   r'   s        r(   r!   zOwnedGifts.__init__   sP     	J/ +,>u,E
'2**DJJ7r)   r*   r+   r,   r   c                     | j                  |      }t        |j                  d      t        |      |d<   t        |   ||      S )z,See :meth:`telegram.TelegramObject.de_json`.rD   r.   )r/   r   r2   r   r    r4   )r5   r*   r+   r'   s      r(   r4   zOwnedGifts.de_json   sA     t$('):IsKWwDc22r)   r7   )r8   r9   r:   r;   r<   intr   r   r=   r   r!   r?   r4   r@   rA   s   @r(   rC   rC   i   s    (I #'	 '+ 	" 4Z	 tO" 38 3, 3, 3 3r)   rC   c            "       L    e Zd ZdZdZ	 	 	 	 	 	 	 	 	 	 	 	 ddddedej                  dedz  de	dz  d	edz  d
e
e   dz  dedz  dedz  dedz  dedz  dedz  dedz  dedz  dedz  dedz  ddf  fdZeddedddd f fd       ZdedefdZddee   dz  deeef   fdZ xZS ) r0   a  Describes a regular gift owned by a user or a chat.

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`gift` and :attr:`send_date` are equal.

    .. versionadded:: 22.1

    Args:
        gift (:class:`telegram.Gift`): Information about the regular gift.
        owned_gift_id (:obj:`str`, optional): Unique identifier of the gift for the bot; for
            gifts received on behalf of business accounts only.
        sender_user (:class:`telegram.User`, optional): Sender of the gift if it is a known user.
        send_date (:obj:`datetime.datetime`): Date the gift was sent as :class:`datetime.datetime`.
            |datetime_localization|.
        text (:obj:`str`, optional): Text of the message that was added to the gift.
        entities (Sequence[:class:`telegram.MessageEntity`], optional): Special entities that
            appear in the text.
        is_private (:obj:`bool`, optional): :obj:`True`, if the sender and gift text are shown
            only to the gift receiver; otherwise, everyone will be able to see them.
        is_saved (:obj:`bool`, optional): :obj:`True`, if the gift is displayed on the account's
            profile page; for gifts received on behalf of business accounts only.
        can_be_upgraded (:obj:`bool`, optional): :obj:`True`, if the gift can be upgraded to a
            unique gift; for gifts received on behalf of business accounts only.
        was_refunded (:obj:`bool`, optional): :obj:`True`, if the gift was refunded and isn't
            available anymore.
        convert_star_count (:obj:`int`, optional): Number of Telegram Stars that can be
            claimed by the receiver instead of the gift; omitted if the gift cannot be converted
            to Telegram Stars; for gifts received on behalf of business accounts only.
        prepaid_upgrade_star_count (:obj:`int`, optional): Number of Telegram Stars that were
            paid for the ability to upgrade the gift.
        is_upgrade_separate (:obj:`bool`, optional): :obj:`True`, if the gift's upgrade was
            purchased after the gift was sent; for gifts received on behalf of business accounts

            .. versionadded:: 22.6
        unique_gift_number (:obj:`int`, optional): Unique number reserved for this gift when
            upgraded. See the number field in :class:`~telegram.UniqueGift`

            ... versionadded:: 22.6

    Attributes:
        type (:obj:`str`): Type of the gift, always :attr:`~telegram.OwnedGift.REGULAR`.
        gift (:class:`telegram.Gift`): Information about the regular gift.
        owned_gift_id (:obj:`str`): Optional. Unique identifier of the gift for the bot; for
            gifts received on behalf of business accounts only.
        sender_user (:class:`telegram.User`): Optional. Sender of the gift if it is a known user.
        send_date (:obj:`datetime.datetime`): Date the gift was sent as :class:`datetime.datetime`.
            |datetime_localization|.
        text (:obj:`str`): Optional. Text of the message that was added to the gift.
        entities (Sequence[:class:`telegram.MessageEntity`]): Optional. Special entities that
            appear in the text.
        is_private (:obj:`bool`): Optional. :obj:`True`, if the sender and gift text are shown
            only to the gift receiver; otherwise, everyone will be able to see them.
        is_saved (:obj:`bool`): Optional. :obj:`True`, if the gift is displayed on the account's
            profile page; for gifts received on behalf of business accounts only.
        can_be_upgraded (:obj:`bool`): Optional. :obj:`True`, if the gift can be upgraded to a
            unique gift; for gifts received on behalf of business accounts only.
        was_refunded (:obj:`bool`): Optional. :obj:`True`, if the gift was refunded and isn't
            available anymore.
        convert_star_count (:obj:`int`): Optional. Number of Telegram Stars that can be
            claimed by the receiver instead of the gift; omitted if the gift cannot be converted
            to Telegram Stars; for gifts received on behalf of business accounts only.
        prepaid_upgrade_star_count (:obj:`int`): Optional. Number of Telegram Stars that were
            paid for the ability to upgrade the gift.
        is_upgrade_separate (:obj:`bool`): Optional. :obj:`True`, if the gift's upgrade was
            purchased after the gift was sent; for gifts received on behalf of business accounts

            .. versionadded:: 22.6
        unique_gift_number (:obj:`int`): Optional. Unique number reserved for this gift when
            upgraded. See the number field in :class:`~telegram.UniqueGift`

            ... versionadded:: 22.6

    )can_be_upgradedconvert_star_countentitiesgift
is_privateis_savedis_upgrade_separateowned_gift_idprepaid_upgrade_star_count	send_datesender_usertextunique_gift_numberwas_refundedNr   rN   rT   rR   rU   rV   rM   rO   rP   rK   rX   rL   rS   rQ   rW   r   r   c                   t         |   t        j                  |       | j	                         5  || _        || _        || _        || _        || _	        t        |      | _        || _        || _        |	| _        |
| _        || _        || _        || _        || _        | j(                  | j
                  | j                  f| _        d d d        y # 1 sw Y   y xY wN)r   r   )r    r!   r   r   	_unfrozenrN   rT   rR   rU   rV   r   rM   rO   rP   rK   rX   rL   rS   rQ   rW   r   r$   )r&   rN   rT   rR   rU   rV   rM   rO   rP   rK   rX   rL   rS   rQ   rW   r   r'   s                   r(   r!   zOwnedGiftRegular.__init__   s    & 	i//JG^^ 	D"DI+4DN-:D,7D$(DI7I(7SDM+5DO)1DM0?D -9D2DD#:TD+4GD$2DD#"iiDNNCDN!	D 	D 	Ds   BCCr*   r+   r,   c                 n   | j                  |      }t        |      }t        |j                  d      |      |d<   t	        |j                  d      t
        |      |d<   t	        |j                  d      t        |      |d<   t        |j                  d      t        |      |d<   t        | )  ||      S )'See :meth:`telegram.OwnedGift.de_json`.rT   tzinforU   rN   rM   r.   )r/   r   r   r2   r   r   r   r   r   r    r4   r5   r*   r+   
loc_tzinfor'   s       r(   r4   zOwnedGiftRegular.de_json!  s     t$1#6
*488K+@T[.txx/FcR]'(8$DV+DHHZ,@-QTUZwDc22r)   entityc                 \    | j                   st        d      t        | j                   |      S )a  Returns the text in :attr:`text`
        from a given :class:`telegram.MessageEntity` of :attr:`entities`.

        Note:
            This method is present because Telegram calculates the offset and length in
            UTF-16 codepoint pairs, which some versions of Python don't handle automatically.
            (That is, you can't just slice ``OwnedGiftRegular.text`` with the offset and length.)

        Args:
            entity (:class:`telegram.MessageEntity`): The entity to extract the text from. It must
                be an entity that belongs to :attr:`entities`.

        Returns:
            :obj:`str`: The text of the given entity.

        Raises:
            RuntimeError: If the owned gift has no text.

        $This OwnedGiftRegular has no 'text'.)rV   RuntimeErrorr   )r&   rb   s     r(   parse_entityzOwnedGiftRegular.parse_entity.  s(    ( yyEFF#DIIv66r)   typesc                 r    | j                   st        d      t        | j                   | j                  |      S )aQ  
        Returns a :obj:`dict` that maps :class:`telegram.MessageEntity` to :obj:`str`.
        It contains entities from this owned gift's text filtered by their ``type`` attribute as
        the key, and the text that each entity belongs to as the value of the :obj:`dict`.

        Note:
            This method should always be used instead of the :attr:`entities`
            attribute, since it calculates the correct substring from the message text based on
            UTF-16 codepoints. See :attr:`parse_entity` for more info.

        Args:
            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.

        Raises:
            RuntimeError: If the owned gift has no text.

        rd   )rV   re   r   rM   )r&   rg   s     r(   parse_entitieszOwnedGiftRegular.parse_entitiesG  s.    0 yyEFF%diiFFr)   )NNNNNNNNNNNNr7   )r8   r9   r:   r;   r<   r   dtmdatetimer=   r   r   r   boolrI   r   r!   r?   r4   rf   listdictri   r@   rA   s   @r(   r0   r0      s   HTI* %)#'37"& $'+$()-15+/)-%D" '+#%D%D <<%D Tz	%D
 D[%D Dj%D =)D0%D 4K%D +%D %D Tk%D  $J%D %($J%D "D[%D  $J%D" tO#%D$ 
%%DN 
38 
3, 
3BT 
3 
37= 7S 72GDI$4 G]TWEW@X Gr)   r0   c                        e Zd ZdZdZ	 	 	 	 	 	 ddddedej                  dedz  de	dz  d	e
dz  d
e
dz  dedz  dej                  dz  dedz  ddf fdZeddedddd f fd       Z xZS )r1   ah  
    Describes a unique gift received and owned by a user or a chat.

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`gift` and :attr:`send_date` are equal.

    .. versionadded:: 22.1

    Args:
        gift (:class:`telegram.UniqueGift`): Information about the unique gift.
        owned_gift_id (:obj:`str`, optional): Unique identifier of the received gift for the
            bot; for gifts received on behalf of business accounts only.
        sender_user (:class:`telegram.User`, optional): Sender of the gift if it is a known user.
        send_date (:obj:`datetime.datetime`): Date the gift was sent as :class:`datetime.datetime`.
            |datetime_localization|
        is_saved (:obj:`bool`, optional): :obj:`True`, if the gift is displayed on the account's
            profile page; for gifts received on behalf of business accounts only.
        can_be_transferred (:obj:`bool`, optional): :obj:`True`, if the gift can be transferred to
            another owner; for gifts received on behalf of business accounts only.
        transfer_star_count (:obj:`int`, optional): Number of Telegram Stars that must be paid
            to transfer the gift; omitted if the bot cannot transfer the gift.
        next_transfer_date (:obj:`datetime.datetime`, optional): Date when the gift can be
            transferred. If it's in the past, then the gift can be transferred now.
            |datetime_localization|
            .. versionadded:: 22.3

    Attributes:
        type (:obj:`str`): Type of the owned gift, always :tg-const:`~telegram.OwnedGift.UNIQUE`.
        gift (:class:`telegram.UniqueGift`): Information about the unique gift.
        owned_gift_id (:obj:`str`): Optional. Unique identifier of the received gift for the
            bot; for gifts received on behalf of business accounts only.
        sender_user (:class:`telegram.User`): Optional. Sender of the gift if it is a known user.
        send_date (:obj:`datetime.datetime`): Date the gift was sent as :class:`datetime.datetime`.
            |datetime_localization|
        is_saved (:obj:`bool`): Optional. :obj:`True`, if the gift is displayed on the account's
            profile page; for gifts received on behalf of business accounts only.
        can_be_transferred (:obj:`bool`): Optional. :obj:`True`, if the gift can be transferred to
            another owner; for gifts received on behalf of business accounts only.
        transfer_star_count (:obj:`int`): Optional. Number of Telegram Stars that must be paid
            to transfer the gift; omitted if the bot cannot transfer the gift.
        next_transfer_date (:obj:`datetime.datetime`): Optional. Date when the gift can be
            transferred. If it's in the past, then the gift can be transferred now.
            |datetime_localization|
            .. versionadded:: 22.3
    )can_be_transferredrN   rP   next_transfer_daterR   rT   rU   transfer_star_countNr   rN   rT   rR   rU   rP   rp   rr   rq   r   r   c	                N   t         
|   t        j                  |	       | j	                         5  || _        || _        || _        || _        || _	        || _
        || _        || _        | j                  | j
                  | j                  f| _        d d d        y # 1 sw Y   y xY wrZ   )r    r!   r   r   r[   rN   rT   rR   rU   rP   rp   rr   rq   r   r$   )r&   rN   rT   rR   rU   rP   rp   rr   rq   r   r'   s             r(   r!   zOwnedGiftUnique.__init__  s     	i..:F^^ 
	D$(DI+4DN-:D,7D)1DM3ED#3FD$;MD#"iiDNNCDN
	D 
	D 
	Ds   A!BB$r*   r+   r,   c                 f   | j                  |      }t        |      }t        |j                  d      |      |d<   t	        |j                  d      t
        |      |d<   t	        |j                  d      t        |      |d<   t        |j                  d      |      |d<   t        | !  ||      S )r]   rT   r^   rU   rN   rq   r.   )	r/   r   r   r2   r   r   r
   r    r4   r`   s       r(   r4   zOwnedGiftUnique.de_json  s     t$1#6
*488K+@T[.txx/FcR]'(8*cJV%3HH)*:&
!" wDc22r)   )NNNNNNr7   )r8   r9   r:   r;   r<   r
   rj   rk   r=   r   rl   rI   r   r!   r?   r4   r@   rA   s   @r(   r1   r1   e  s    ,\	I %)#' $*.*.26D '+DD <<D Tz	D
 D[D +D !4KD !4ZD  LL4/D tOD 
D6 38 3, 3BS 3 3r)   r1   )'r;   rk   rj   collections.abcr   typingr   r   telegramr   telegram._giftsr   telegram._messageentityr   telegram._telegramobjectr	   telegram._uniquegiftr
   telegram._userr   telegram._utilsr   telegram._utils.argumentparsingr   r   r   telegram._utils.datetimer   r   telegram._utils.entitiesr   r   telegram._utils.typesr   r   r   rC   r0   r1    r)   r(   <module>r      sv   & ?  $ '    1 3 +    b b Q Q *=3 =3@23 23jDGy DGNb3i b3r)   