
    cjh                    h    d dl mZ d dlZd dlmZ ddlmZ ddlm	Z	m
Z
 dZerddlmZ  G d d      Zy)	    )annotationsN)TYPE_CHECKING   )	InputText)ComponentTypeInputTextStylec            	      b    e Zd ZdZej
                  dddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d fdZedd       Zedd       Z	e	j                  dd       Z	edd	       Zej                  dd
       Zedd       Zej                  dd       Zed d       Zej                  d!d       Zed"d       Zej                  d#d       Zed"d       Zej                  d#d       Zed$d       Zej                  d%d       Zed d       Zej                  d!d       Zed&d       Zd'dZd(dZ xZS ))r   a,  Represents a UI text input field.

    .. versionadded:: 2.0

    Parameters
    ----------
    style: :class:`~discord.InputTextStyle`
        The style of the input text field.
    custom_id: Optional[:class:`str`]
        The ID of the input text field that gets received during an interaction.
    label: :class:`str`
        The label for the input text field.
        Must be 45 characters or fewer.
    placeholder: Optional[:class:`str`]
        The placeholder text that is shown if nothing is selected, if any.
        Must be 100 characters or fewer.
    min_length: Optional[:class:`int`]
        The minimum number of characters that must be entered.
        Defaults to 0 and must be less than 4000.
    max_length: Optional[:class:`int`]
        The maximum number of characters that can be entered.
        Must be between 1 and 4000.
    required: Optional[:class:`bool`]
        Whether the input text field is required or not. Defaults to ``True``.
    value: Optional[:class:`str`]
        Pre-fills the input text field with this value.
        Must be 4000 characters or fewer.
    row: Optional[:class:`int`]
        The relative row this input text field belongs to. A modal dialog can only have 5
        rows. By default, items are arranged automatically into those 5 rows. If you'd
        like to control the relative positioning of the row then passing an index is advised.
        For example, row=1 will show up before row=2. Defaults to ``None``, which is automatic
        ordering. The row number must be between 0 and 4 (i.e. zero indexed).
    NT)style	custom_idplaceholder
min_length
max_lengthrequiredvaluerowc       	           t         
|           t        t        |            dkD  rt	        d      |r|dk  s|dkD  rt	        d      |r|dk  s|dkD  rt	        d      |r"t        t        |            dkD  rt	        d      |r"t        t        |            dkD  rt	        d	      t        |t              s$|"t        d
|j                  j                         |#t        j                  d      j                         n|}t        j                  t        j                  ||||||||	      | _        d| _        |	| _        d | _        y )N-   $label must be 45 characters or fewerr     %min_length must be between 0 and 4000%max_length must be between 1 and 4000&value must be 4000 characters or fewerd   +placeholder must be 100 characters or fewerz"expected custom_id to be str, not    )	typer
   r   labelr   r   r   r   r   F)super__init__lenstr
ValueError
isinstance	TypeError	__class____name__osurandomhexInputTextComponent_raw_constructr   
input_text_underlying_input_valuer   _rendered_row)selfr
   r   r   r   r   r   r   r   r   r%   s             H/var/www/html/venv/lib/python3.12/site-packages/discord/ui/input_text.pyr   zInputText.__init__3   sA    	s5z?RCDD:>Z$->DEE:>Z$->DEESU_t+EFF3s;/036JKK)S)i.C4Y5H5H5Q5Q4RS  -6,=BJJrN&&(9	-<<))#!!

 ")-    c                .    | j                   j                  S N)r-   r   r0   s    r1   r   zInputText.type`   s    $$$r2   c                .    | j                   j                  S )z"The style of the input text field.)r-   r
   r5   s    r1   r
   zInputText.styled        %%%r2   c                    t        |t              s"t        d|j                  j                         || j
                  _        y )Nz)style must be of type InputTextStyle not )r#   r   r$   r%   r&   r-   r
   r0   r   s     r1   r
   zInputText.stylei   s>    %0;EOO<T<T;UV  "'r2   c                .    | j                   j                  S )zHThe ID of the input text field that gets received during an interaction.)r-   r   r5   s    r1   r   zInputText.custom_idq   s     )))r2   c                    t        |t              s"t        d|j                  j                         || j
                  _        y )Nz"custom_id must be None or str not )r#   r!   r$   r%   r&   r-   r   r9   s     r1   r   zInputText.custom_idv   s>    %%4U__5M5M4NO  &+"r2   c                .    | j                   j                  S )z"The label of the input text field.)r-   r   r5   s    r1   r   zInputText.label~   r7   r2   c                    t        |t              s"t        d|j                  j                         t        |      dkD  rt        d      || j                  _        y )Nzlabel should be str not r   r   )	r#   r!   r$   r%   r&   r    r"   r-   r   r9   s     r1   r   zInputText.label   sO    %%6u7O7O6PQRRu:?CDD!&r2   c                .    | j                   j                  S )zFThe placeholder text that is shown before anything is entered, if any.)r-   r   r5   s    r1   r   zInputText.placeholder   s     +++r2   c                    |r2t        |t              s"t        d|j                  j                         |rt        |      dkD  rt        d      || j                  _        y )Nz$placeholder must be None or str not r   r   )	r#   r!   r$   r%   r&   r    r"   r-   r   r9   s     r1   r   zInputText.placeholder   sT    E3/B5??C[C[B\]^^SZ#%JKK',$r2   c                .    | j                   j                  S )zEThe minimum number of characters that must be entered. Defaults to 0.)r-   r   r5   s    r1   r   zInputText.min_length        ***r2   c                    |r2t        |t              s"t        d|j                  j                         |r|dk  xs |dkD  rt        d      || j                  _        y )N#min_length must be None or int not r   r   r   )r#   intr$   r%   r&   r"   r-   r   r9   s     r1   r   zInputText.min_length   sY    E3/A%//BZBZA[\]]eai(5D0DEE&+#r2   c                .    | j                   j                  S )z5The maximum number of characters that can be entered.)r-   r   r5   s    r1   r   zInputText.max_length   rA   r2   c                    |r2t        |t              s"t        d|j                  j                         |r|dk  s|dkD  rt        d      || j                  _        y )NrC   r   r   r   )r#   rD   r$   r%   r&   r"   r-   r   r9   s     r1   r   zInputText.max_length   sU    E3/A%//BZBZA[\]]eqjEDLDEE&+#r2   c                .    | j                   j                  S )zFWhether the input text field is required or not. Defaults to ``True``.)r-   r   r5   s    r1   r   zInputText.required   s     (((r2   c                    t        |t              s"t        d|j                  j                         t        |      | j
                  _        y )Nzrequired must be bool not )r#   boolr$   r%   r&   r-   r   r9   s     r1   r   zInputText.required   s<    %&89Q9Q8RSTT$(K!r2   c                b    | j                   dur| j                   S | j                  j                  S )z$The value entered in the text field.F)r.   r-   r   r5   s    r1   r   zInputText.value   s0     E)$$$%%%r2   c                    |r2t        |t              s"t        d|j                  j                         |r"t        t        |            dkD  rt        d      || j                  _        y )Nzvalue must be None or str not r   r   )	r#   r!   r$   r%   r&   r    r"   r-   r   r9   s     r1   r   zInputText.value   sX    E3/<U__=U=U<VWXXSU_t+EFF!&r2   c                     y)N    r5   s    r1   widthzInputText.width   s    r2   c                6    | j                   j                         S r4   )r-   to_dictr5   s    r1   to_component_dictzInputText.to_component_dict   s    ''))r2   c                    |d   | _         y )Nr   )r.   )r0   datas     r1   refresh_statezInputText.refresh_state   s     Mr2   )r
   r   r   
str | Noner   r!   r   rV   r   
int | Noner   rW   r   bool | Noner   rV   r   rW   )returnr   )rY   r   )r   r   )rY   r!   )r   r!   )rY   rV   )r   rV   )rY   rW   )r   rW   )rY   rX   )r   rX   )rY   rD   )rY   InputTextComponentPayload)rY   None)r&   
__module____qualname____doc__r   shortr   propertyr   r
   setterr   r   r   r   r   r   r   rO   rR   rU   __classcell__)r%   s   @r1   r   r      s#   !L !/ 4 4 $"&!%!% $ +. +. 	+.
 +.  +. +. +. +. +. +.Z % % & & \\' ' * * + + & & \\' ' , , - - + + , , + + , , ) ) __0 0
 & & \\' '  **r2   r   )
__future__r   r'   typingr   
componentsr   r*   enumsr   r   __all__types.componentsrZ   rN   r2   r1   <module>ri      s+    " 	   8 1
IF* F*r2   