§
    ®eîi€#  ã                   ó  — d Z ddlZddl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 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 e	 edddd¬¦  «         G d„ d¦  «        ¦   «         ¦   «         ZdS )z[This module contains a class that describes a single parameter of a request to the Bot API.é    N)ÚSequence)Ú	dataclass)Úfinal)ÚInputStoryContent)Ú	InputFile)Ú
InputMediaÚInputPaidMedia)ÚInputProfilePhotoÚInputProfilePhotoStatic)ÚInputSticker)ÚTelegramObject)Úto_timestamp)Ú
StringEnum)ÚUploadFileDictTF)ÚreprÚeqÚorderÚfrozenc                   óì   — e Zd ZU dZdZeed<   eed<   ee	         dz  ed<   e
dedz  fd„¦   «         Ze
dedz  fd	„¦   «         Zededeeee	         f         fd
„¦   «         Zedededd fd„¦   «         ZdS )ÚRequestParameteraÀ  Instances of this class represent a single parameter to be sent along with a request to
    the Bot API.

    .. versionadded:: 20.0

    Warning:
        This class intended is to be used internally by the library and *not* by the user. Changes
        to this class are not considered breaking changes and may not be documented in the
        changelog.

    Args:
        name (:obj:`str`): The name of the parameter.
        value (:obj:`object` | :obj:`None`): The value of the parameter. Must be JSON-dumpable.
        input_files (list[:class:`telegram.InputFile`], optional): A list of files that should be
            uploaded along with this parameter.

    Attributes:
        name (:obj:`str`): The name of the parameter.
        value (:obj:`object` | :obj:`None`): The value of the parameter.
        input_files (list[:class:`telegram.InputFile` | :obj:`None`): A list of files that should
            be uploaded along with this parameter.
    )Úinput_filesÚnameÚvaluer   r   Nr   Úreturnc                 óˆ   — t          | j        t          ¦  «        r| j        S | j        €dS t          j        | j        ¦  «        S )zêThe JSON dumped :attr:`value` or :obj:`None` if :attr:`value` is :obj:`None`.
        The latter can currently only happen if :attr:`input_files` has exactly one element that
        must not be uploaded via an attach:// URI.
        N)Ú
isinstancer   ÚstrÚjsonÚdumps©Úselfs    úf/home/div/.hermes/hermes-agent/venv/lib/python3.11/site-packages/telegram/request/_requestparameter.pyÚ
json_valuezRequestParameter.json_valueF   s?   € õ �d”j¥#Ñ&Ô&ð 	Ø”:ÐØŒ:ÐØ�4ÝŒz˜$œ*Ñ%Ô%Ð%ó    c                 ó<   ‡ — ‰ j         sdS ˆ fd„‰ j         D ¦   «         S )z…A dict with the file data to upload, if any.

        .. versionchanged:: 21.5
            Content may now be a file handle.
        Nc                 ó8   •— i | ]}|j         p‰j        |j        “ŒS © )Úattach_namer   Úfield_tuple)Ú.0Ú
input_filer!   s     €r"   ú
<dictcomp>z3RequestParameter.multipart_data.<locals>.<dictcomp>[   s8   ø€ ð 
ð 
ð 
àð Ô#Ð0 t¤y°:Ô3Ið
ð 
ð 
r$   )r   r    s   `r"   Úmultipart_datazRequestParameter.multipart_dataR   sC   ø€ ð Ôð 	Ø�4ð
ð 
ð 
ð 
à"Ô.ð
ñ 
ô 
ð 	
r$   c                 ó„  — t          | t          j        ¦  «        rt          | ¦  «        g fS t          | t          j        ¦  «        r=|                      ¦   «         }|                     ¦   «         rt          |¦  «        g fS |g fS t          | t          ¦  «        r	| j	        g fS t          | t          ¦  «        r| j        r
| j        | gfS d| gfS t          | t          t          z  ¦  «        rÈt          | j        t          ¦  «        r®|                      ¦   «         }| j        j        r| j        j        |d<   n|                     dd¦  «         |                     dd¦  «        }t          |t          ¦  «        r3|j        r|j        |d<   n|                     dd¦  «         || j        |gfS || j        gfS t          | t$          ¦  «        rwt          | t&          ¦  «        rdnd}t          t)          | |¦  «        x}t          ¦  «        s|                      ¦   «         g fS |                      ¦   «         }|j        ||<   ||gfS t          | t*          ¦  «        re| j        }t          t)          | |¦  «        x}t          ¦  «        s|                      ¦   «         g fS |                      ¦   «         }|j        ||<   ||gfS t          | t.          ¦  «        rGt          | j        t          ¦  «        r-|                      ¦   «         }| j        j        |d<   || j        gfS t          | t2          ¦  «        r|                      ¦   «         g fS | g fS )aX  Converts `value` into something that we can json-dump. Returns two values:
        1. the JSON-dumpable value. May be `None` in case the value is an InputFile which must
           not be uploaded via an attach:// URI
        2. A list of InputFiles that should be uploaded for this value

        Note that we handle files differently depending on whether attaching them via an URI of the
        form attach://<name> is documented to be allowed or not.
        There was some confusion whether this worked for all files, so that we stick to the
        documented ways for now.
        See https://github.com/tdlib/telegram-bot-api/issues/167 and
        https://github.com/tdlib/telegram-bot-api/issues/259

        This method only does some special casing for our own helper class StringEnum, but not
        for general enums. This is because:
        * tg.constants currently only uses IntEnum as second enum type and json dumping that
          is no problem
        * if a user passes a custom enum, it's unlikely that we can actually properly handle it
          even with some special casing.
        NÚmediaÚ	thumbnailÚphotoÚ	animationÚsticker)r   ÚdtmÚdatetimer   Ú	timedeltaÚtotal_secondsÚ
is_integerÚintr   r   r   Ú
attach_urir   r	   r/   Úto_dictÚpopÚgetr
   r   Úgetattrr   Útyper   r3   r   )r   ÚsecondsÚdatar0   Úattrr/   s         r"   Ú!_value_and_input_files_from_inputz2RequestParameter._value_and_input_files_from_input`   s4  € õ. �e�Sœ\Ñ*Ô*ð 	+Ý Ñ&Ô&¨Ð*Ð*Ý�e�Sœ]Ñ+Ô+ð 	Ø×)Ò)Ñ+Ô+ˆGà×!Ò!Ñ#Ô#ð (Ý˜7‘|”| RÐ'Ð'ð ˜B�;ÐÝ�e�ZÑ(Ô(ð 	#Ø”; �?Ð"Ý�e�YÑ'Ô'ð 	!ØÔð 1ØÔ'¨%¨Ð0Ð0Ø˜%˜�=Ð å�e�Z­.Ñ8Ñ9Ô9ð 	'½jÈÌÕV_Ñ>`Ô>`ð 	'ð —=’=‘?”?ˆDØŒ{Ô%ð (Ø %¤Ô 6��W‘�à—’˜ $Ñ'Ô'Ð'àŸš ¨dÑ3Ô3ˆIÝ˜)¥YÑ/Ô/ð 6ØÔ'ð 0Ø(1Ô(<�D˜Ñ%Ð%à—H’H˜[¨$Ñ/Ô/Ð/Ø˜eœk¨9Ð5Ð5Ð5à˜%œ+˜Ð&Ð&å�eÕ.Ñ/Ô/ð 
	!Ý(¨Õ0GÑHÔHÐY�7�7ÈkˆDÝ¥w¨u°dÑ';Ô';Ð;˜e½YÑGÔGð +à—}’}‘”¨Ð*Ð*ð —=’=‘?”?ˆDØÔ)ˆD�‰JØ˜%˜�=Ð å�eÕ.Ñ/Ô/ð 
	!Ø”:ˆDÝ¥w¨u°dÑ';Ô';Ð;˜e½YÑGÔGð +à—}’}‘”¨Ð*Ð*ð —=’=‘?”?ˆDØÔ)ˆD�‰JØ˜%˜�=Ð å�e�\Ñ*Ô*ð 	)­z¸%¼-ÍÑ/SÔ/Sð 	)ð —=’=‘?”?ˆDØ#œmÔ6ˆD�‰OØ˜%œ-˜Ð(Ð(å�e�^Ñ,Ô,ð 	'à—=’=‘?”? BÐ&Ð&Ø�bˆyÐr$   Úkeyc                 ó€  — t          |t          t          z  ¦  «        svt          |t          ¦  «        rag }g }|D ]F}|                      |¦  «        \  }}|�|                     |¦  «         |                     |¦  «         ŒGt          |||pd¬¦  «        S |                      |¦  «        \  }}t          |||pd¬¦  «        S )z¢Builds an instance of this class for a given key-value pair that represents the raw
        input as passed along from a method of :class:`telegram.Bot`.
        N)r   r   r   )r   r   Úbytesr   rC   ÚappendÚextendr   )ÚclsrD   r   Úparam_valuesr   ÚobjÚparam_valuer+   s           r"   Ú
from_inputzRequestParameter.from_input¿   sÞ   € õ
 ˜%¥¥u¡Ñ-Ô-ð 	cµ*¸UÅHÑ2MÔ2Mð 	cØˆLØˆKØð /ð /�Ø*-×*OÒ*OÐPSÑ*TÔ*TÑ'�˜ZØÐ*Ø ×'Ò'¨Ñ4Ô4Ð4Ø×"Ò" :Ñ.Ô.Ð.Ð.Ý#¨°LÈkÐNaÐ]aÐbÑbÔbÐbà#&×#HÒ#HÈÑ#OÔ#OÑ ˆ�[Ý S°ÈÐI\ÐX\Ð]Ñ]Ô]Ð]r$   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   Ú__annotations__ÚobjectÚlistr   Úpropertyr#   r   r-   ÚstaticmethodÚtuplerC   ÚclassmethodrM   r'   r$   r"   r   r   &   s'  € € € € € € ðð ð. 1€Ià
€I€I�IØ€M€M�MØ�i” 4Ñ'Ð'Ð'Ñ'àð	&˜C $™Jð 	&ð 	&ð 	&ñ „Xð	&ð ð
 °Ñ 5ð 
ð 
ð 
ñ „Xð
ð ð\Øð\à	ˆv�t˜I”Ð&Ô	'ð\ð \ð \ñ „\ð\ð| ð^˜Sð ^¨ð ^Ð4Fð ^ð ^ð ^ñ „[ð^ð ^ð ^r$   r   )rQ   r5   r4   r   Úcollections.abcr   Údataclassesr   Útypingr   Ú"telegram._files._inputstorycontentr   Útelegram._files.inputfiler   Útelegram._files.inputmediar   r	   Ú!telegram._files.inputprofilephotor
   r   Útelegram._files.inputstickerr   Útelegram._telegramobjectr   Útelegram._utils.datetimer   Útelegram._utils.enumr   Útelegram._utils.typesr   r   r'   r$   r"   ú<module>rf      sw  ðð& bÐ aà Ð Ð Ð Ø €€€Ø $Ð $Ð $Ð $Ð $Ð $Ø !Ð !Ð !Ð !Ð !Ð !Ø Ð Ð Ð Ð Ð à @Ð @Ð @Ð @Ð @Ð @Ø /Ð /Ð /Ð /Ð /Ð /Ø AÐ AÐ AÐ AÐ AÐ AÐ AÐ AØ XÐ XÐ XÐ XÐ XÐ XÐ XÐ XØ 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø +Ð +Ð +Ð +Ð +Ð +Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0ð Ø
€�˜ e°DÐ9Ñ9Ô9ðg^ð g^ð g^ð g^ð g^ñ g^ô g^ñ :Ô9ñ „ðg^ð g^ð g^r$   