
    Qi+                        d Z ddlmZ ddlmZ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 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 G d de      Z G d de      Zy)zCThis module contains objects that represent paid media in Telegram.    )Sequence)TYPE_CHECKINGFinalOptional)	constants)	PhotoSize)Video)TelegramObject)User)enum)parse_sequence_arg)JSONDict)Botc            	       4    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<   	 ej                  j                  Zee	   e
d<   	 ddde	d	ee   d
df fdZe	 ddee   ded   d
ed    f fd       Z xZS )	PaidMediaa  Describes the paid media added to a message. Currently, it can be one of:

    * :class:`telegram.PaidMediaPreview`
    * :class:`telegram.PaidMediaPhoto`
    * :class:`telegram.PaidMediaVideo`

    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:: 21.4

    Args:
        type (:obj:`str`): Type of the paid media.

    Attributes:
        type (:obj:`str`): Type of the paid media.
    )typePREVIEWPHOTOVIDEON
api_kwargsr   r   returnc                    t         |   |       t        j                  t        j
                  ||      | _        | j                  f| _        | j                          y Nr   )	super__init__r   
get_memberr   PaidMediaTyper   	_id_attrs_freeze)selfr   r   	__class__s      >/app/.venv/lib/python3.12/site-packages/telegram/_paidmedia.pyr   zPaidMedia.__init__A   sE     	J/)@)@$M	))    databotr   c                 H   | j                  |      }|y|s	| t        u ry| j                  t        | 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:`PaidMedia` 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.

        Nr   r%   r&   )_parse_datar   r   PaidMediaPreviewr   PaidMediaPhotor   PaidMediaVideogetpopde_jsonr   )clsr%   r&   _class_mappingr"   s       r#   r/   zPaidMedia.de_jsonM   s     t$<y( KK)II~II~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   r   r   classmethodr/   __classcell__r"   s   @r#   r   r   %   s    $ I#1199GU3Z9;!//55E5:59!//55E5:59 *.	

 X&	

 

 >B3H%3,4UO3	+	3 3r$   r   c                   b     e Zd ZdZdZ	 	 	 ddddee   dee   dee   dee   d	df
 fd
Z xZ	S )r*   a  The paid media isn't available before the payment.

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

    .. versionadded:: 21.4

    Args:
        type (:obj:`str`): Type of the paid media, always :tg-const:`telegram.PaidMedia.PREVIEW`.
        width (:obj:`int`, optional): Media width as defined by the sender.
        height (:obj:`int`, optional): Media height as defined by the sender.
        duration (:obj:`int`, optional): Duration of the media in seconds as defined by the sender.

    Attributes:
        type (:obj:`str`): Type of the paid media, always :tg-const:`telegram.PaidMedia.PREVIEW`.
        width (:obj:`int`): Optional. Media width as defined by the sender.
        height (:obj:`int`): Optional. Media height as defined by the sender.
        duration (:obj:`int`): Optional. Duration of the media in seconds as defined by the sender.
    )durationheightwidthNr   r@   r?   r>   r   r   c                   t         |   t        j                  |       | j	                         5  || _        || _        || _        | j                  | j
                  | j                  | j                  f| _	        d d d        y # 1 sw Y   y xY wN)r   r   )
r   r   r   r   	_unfrozenr@   r?   r>   r   r   )r!   r@   r?   r>   r   r"   s        r#   r   zPaidMediaPreview.__init__   sh     	i//JG^^(-DJ)/DK+3DM"iiT[[$--PDN s   A	BB)NNN)
r3   r4   r5   r6   r7   r   intr   r   r;   r<   s   @r#   r*   r*   p   sw    * 0I  $ $"&	Q *.Q}Q Q 3-	Q X&Q 
Q Qr$   r*   c            	       ~     e Zd ZdZdZddded   dee   ddf fd	Ze		 dd
ee   ded   ded    f fd       Z
 xZS )r+   a3  
    The paid media is a photo.

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

    .. versionadded:: 21.4

    Args:
        type (:obj:`str`): Type of the paid media, always :tg-const:`telegram.PaidMedia.PHOTO`.
        photo (Sequence[:class:`telegram.PhotoSize`]): The photo.

    Attributes:
        type (:obj:`str`): Type of the paid media, always :tg-const:`telegram.PaidMedia.PHOTO`.
        photo (tuple[:class:`telegram.PhotoSize`]): The photo.
    )photoNr   rF   r   r   r   c                    t         |   t        j                  |       | j	                         5  t        |      | _        | j                  | j                  f| _        d d d        y # 1 sw Y   y xY wrB   )	r   r   r   r   rC   r   rF   r   r   )r!   rF   r   r"   s      r#   r   zPaidMediaPhoto.__init__   sQ     	ioo*E^^0B50IDJ"ii4DN s   .A((A1r%   r&   r   c                     | j                  |      }|sy t        j                  |j                  d      |      |d<   t        |   ||      S )NrF   r&   r(   )r)   r   de_listr-   r   r/   r0   r%   r&   r"   s      r#   r/   zPaidMediaPhoto.de_json   sK     t$!))$((7*;EWwDc22r$   r2   )r3   r4   r5   r6   r7   r   r   r   r   r:   r/   r;   r<   s   @r#   r+   r+      s}    " I *.	5$5 X&	5
 
5 >B	3H%	3,4UO	3	"	#	3 	3r$   r+   c            	       x     e Zd ZdZdZdddedee   ddf fdZe		 dd	ee   d
ed   ded    f fd       Z
 xZS )r,   a  
    The paid media is a video.

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

    .. versionadded:: 21.4

    Args:
        type (:obj:`str`): Type of the paid media, always :tg-const:`telegram.PaidMedia.VIDEO`.
        video (:class:`telegram.Video`): The video.

    Attributes:
        type (:obj:`str`): Type of the paid media, always :tg-const:`telegram.PaidMedia.VIDEO`.
        video (:class:`telegram.Video`): The video.
    )videoNr   rM   r   r   c                    t         |   t        j                  |       | j	                         5  || _        | j                  | j
                  f| _        d d d        y # 1 sw Y   y xY wrB   )r   r   r   r   rC   rM   r   r   )r!   rM   r   r"   s      r#   r   zPaidMediaVideo.__init__   sL     	ioo*E^^ %DJ"ii4DN s   %AA(r%   r&   r   c                     | j                  |      }|sy t        j                  |j                  d      |      |d<   t        | 	  ||      S )NrM   rI   r(   )r)   r	   r/   r-   r   rK   s      r#   r/   zPaidMediaVideo.de_json   sI     t$dhhw&7SAWwDc22r$   r2   )r3   r4   r5   r6   r7   r	   r   r   r   r:   r/   r;   r<   s   @r#   r,   r,      sx    " I *.	55 X&	5
 
5 >B	3H%	3,4UO	3	"	#	3 	3r$   r,   c            	            e Zd ZdZdZdddedee   dee	   ddf fd	Z
e	 dd
ee	   ded   ded    f fd       Z xZS )PaidMediaInfoa  
    Describes the paid media added to a message.

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

    .. versionadded:: 21.4

    Args:
        star_count (:obj:`int`): The number of Telegram Stars that must be paid to buy access to
            the media.
        paid_media (Sequence[:class:`telegram.PaidMedia`]): Information about the paid media.

    Attributes:
        star_count (:obj:`int`): The number of Telegram Stars that must be paid to buy access to
            the media.
        paid_media (tuple[:class:`telegram.PaidMedia`]): Information about the paid media.
    )
paid_media
star_countNr   rS   rR   r   r   c                    t         |   |       || _        t        |      | _        | j                  | j                  f| _        | j                          y r   )r   r   rS   r   rR   r   r    )r!   rS   rR   r   r"   s       r#   r   zPaidMediaInfo.__init__  sE     	J/)1CJ1O//4??;r$   r%   r&   r   c                     | j                  |      }|sy t        j                  |j                  d      |      |d<   t        |   ||      S )NrR   rI   r(   )r)   r   rJ   r-   r   r/   rK   s      r#   r/   zPaidMediaInfo.de_json  sO     t$&..txx/E3.O\wDc22r$   r2   )r3   r4   r5   r6   r7   rD   r   r   r   r   r   r:   r/   r;   r<   s   @r#   rQ   rQ      s    & -I *. Y'
 X& 
 >B	3H%	3,4UO	3	/	"	3 	3r$   rQ   c            	       |     e Zd ZdZdZdddddedee   d	df fd
Ze		 ddee   ded   d	ed    f fd       Z
 xZS )PaidMediaPurchaseda  This object contains information about a paid media purchase.

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

    Note:
        In Python :keyword:`from` is a reserved word. Use :paramref:`from_user` instead.

    .. versionadded:: 21.6

    Args:
        from_user (:class:`telegram.User`): User who purchased the media.
        paid_media_payload (:obj:`str`): Bot-specified paid media payload.

    Attributes:
        from_user (:class:`telegram.User`): User who purchased the media.
        paid_media_payload (:obj:`str`): Bot-specified paid media payload.
    )	from_userpaid_media_payloadNr   rX   r   rY   r   r   c                    t         |   |       || _        || _        | j                  | j                  f| _        | j                          y r   )r   r   rX   rY   r   r    )r!   rX   rY   r   r"   s       r#   r   zPaidMediaPurchased.__init__=  sC     	J/('9..$*A*ABr$   r%   r&   r   c                     | j                  |      }|sy t        j                  |j                  d      |      |d<   t        | 	  ||      S )Nfromr(   rX   )r)   r   r/   r.   r   rK   s      r#   r/   zPaidMediaPurchased.de_jsonK  sJ     t$ LLdhhv.>CH[wDc22r$   r2   )r3   r4   r5   r6   r7   r8   r   r   r   r:   r/   r;   r<   s   @r#   rW   rW   '  s    & 4I *.  
 X& 
 >B	3H%	3,4UO	3	&	'	3 	3r$   rW   N)r6   collections.abcr   typingr   r   r   telegramr   telegram._files.photosizer   telegram._files.videor	   telegram._telegramobjectr
   telegram._userr   telegram._utilsr   telegram._utils.argumentparsingr   telegram._utils.typesr   r   r   r*   r+   r,   rQ   rW    r$   r#   <module>rh      s   & J $ 1 1  / ' 3    > *H3 H3V'Qy 'QT+3Y +3\+3Y +3\.3N .3b.3 .3r$   