
    Yiw                         S r SSKrSSKJr  SSKJr  SSKJr  SSKJrJ	r	  SSK
Jr  SSKJrJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  \	\" SSSSS9 " S S5      5       5       rg)z[This module contains a class that describes a single parameter of a request to the Bot API.    N)Sequence)	dataclass)datetime)Optionalfinal)	InputFile)
InputMediaInputPaidMedia)InputSticker)TelegramObject)to_timestamp)
StringEnum)UploadFileDictTF)repreqorderfrozenc                       \ rS rSr% SrSr\\S'   \\S'   \	\
\      \S'   \S\	\   4S j5       r\S\	\   4S	 j5       r\S\S\\\
\   4   4S
 j5       r\S\S\SS 4S j5       rSrg)RequestParameter#   a|  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   r   returnc                     [        U R                  [        5      (       a  U R                  $ U R                  c  g[        R                  " U R                  5      $ )zThe 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    M/app/.venv/lib/python3.13/site-packages/telegram/request/_requestparameter.py
json_valueRequestParameter.json_valueC   s?     djj#&&::::zz$**%%    c                     U R                   (       d  gU R                    Vs0 s H-  nUR                  =(       d    U R                  UR                  _M/     sn$ s  snf )zmA dict with the file data to upload, if any.

.. versionchanged:: 21.5
    Content may now be a file handle.
N)r   attach_namer   field_tuple)r    
input_files     r!   multipart_dataRequestParameter.multipart_dataO   sW      #..
.
 ##0tyy:3I3II.
 	
 
s   4Ac                 <   [        U [        5      (       a  [        U 5      / 4$ [        U [        5      (       a  U R                  / 4$ [        U [
        5      (       a%  U R                  (       a  U R                  U /4$ SU /4$ [        U [        [        45      (       a  [        U R                  [
        5      (       a  U R                  5       nU R                  R                  (       a  U R                  R                  US'   OUR                  SS5        UR                  SS5      n[        U[
        5      (       aB  UR                  (       a  UR                  US'   OUR                  SS5        XR                  U/4$ XR                  /4$ [        U [        5      (       aV  [        U R                  [
        5      (       a7  U R                  5       nU R                  R                  US'   XR                  /4$ [        U [        5      (       a  U R                  5       / 4$ U / 4$ )a  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sticker)r   r   r   r   r   r   
attach_urir	   r
   r,   to_dictpopgetr   r.   r   )r   datar-   s      r!   !_value_and_input_files_from_input2RequestParameter._value_and_input_files_from_input]   s   . eX&&&**eZ((;;?"eY''''%00%= ej.9::z%++W`?a?a ==?D{{%% % 6 6W$'d3I)Y//''(1(<(<D%HH[$/kk9555++&&e\**z%--/S/S ==?D#mm66DO--((e^,,==?B&&byr$   keyc                 f   [        U[        [        45      (       do  [        U[        5      (       aZ  / n/ nU H;  nU R	                  U5      u  pgUb  UR                  U5        UR                  U5        M=     [        XU(       a  US9$ SS9$ U R	                  U5      u  pd[        XU(       a  US9$ SS9$ )zBuilds 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   r4   appendextendr   )clsr6   r   param_valuesr   objparam_valuer(   s           r!   
from_inputRequestParameter.from_input   s    
 %#u..:eX3N3NLK*-*O*OPS*T'* ''4"":.	 
 $+ Z^  $'#H#H#O K[
 	
UY
 	
r$    N)__name__
__module____qualname____firstlineno____doc__	__slots__r   __annotations__objectr   listr   propertyr"   r   r)   staticmethodtupler4   classmethodr?   __static_attributes__rA   r$   r!   r   r   #   s    . 1I
IM$y/**	&HSM 	& 	& 
 8 
 
 ;;	vtI&	'; ;z 
S 
 
4F 
 
r$   r   )rF   r   collections.abcr   dataclassesr   r   typingr   r   telegram._files.inputfiler   telegram._files.inputmediar	   r
   telegram._files.inputstickerr   telegram._telegramobjectr   telegram._utils.datetimer   telegram._utils.enumr   telegram._utils.typesr   r   rA   r$   r!   <module>rZ      s^   & b  $ !  " / A 5 3 1 + 0 
eD9J
 J
 : J
r$   