
    iH5                    f   d Z ddlmZ ddlZddlmZmZmZmZm	Z	m
Z
mZ ddlZddl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 dZer$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
ddd          Z) e
ddd          Z* G d dee*                   Zdddej+        ddddd+d*Z,dS ),a:  
The MIT License (MIT)

Copyright (c) 2015-present Rapptz

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
    )annotationsN)CallableLiteralOptionalTYPE_CHECKINGTupleTypeVarUnion   )ItemContainedItemCallbackType_ItemCallback   )ButtonStyleComponentType)PartialEmoji	_EmojiTag)Button)r   button)Self)BaseView)	ActionRow)	Container)Emoji)ButtonComponentSz%Union[BaseView, Container, ActionRow]T)bound	covariantVr   c            
          e Zd ZU dZdZded<   ej        ddddddddd	d8 fdZe	d9d            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	dAd'            Zej        dBd(            Ze	d9d)            Zej        d:d*            ZedCd.            Ze	dDd0            ZdEd2Zd?d3Zd? fd4ZdFd5ZdGd6ZdGd7Z xZS )Hr   a  Represents a UI button.

    .. versionadded:: 2.0

    Parameters
    ------------
    style: :class:`discord.ButtonStyle`
        The style of the button.
    custom_id: Optional[:class:`str`]
        The ID of the button that gets received during an interaction.
        If this button is for a URL, it does not have a custom ID.
        Can only be up to 100 characters.
    url: Optional[:class:`str`]
        The URL this button sends you to.
    disabled: :class:`bool`
        Whether the button is disabled or not.
    label: Optional[:class:`str`]
        The label of the button, if any.
        Can only be up to 80 characters.
    emoji: Optional[Union[:class:`.PartialEmoji`, :class:`.Emoji`, :class:`str`]]
        The emoji of the button, if available.
    row: Optional[:class:`int`]
        The relative row this button belongs to. A Discord component 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).

        .. note::

            This parameter is ignored when used in a :class:`ActionRow` or v2 component.
    sku_id: Optional[:class:`int`]
        The SKU ID this button sends you to. Can't be combined with ``url``, ``label``, ``emoji``
        nor ``custom_id``.

        .. versionadded:: 2.4
    id: Optional[:class:`int`]
        The ID of this component. This must be unique across the view.

        .. versionadded:: 2.6
    )styleurldisabledlabelemojirowsku_ididzTuple[str, ...]__item_repr_attributes__NF	r!   r$   r#   	custom_idr"   r%   r&   r'   r(   r!   r   r$   Optional[str]r#   boolr+   r"   r%   )Optional[Union[str, Emoji, PartialEmoji]]r&   Optional[int]r'   r(   c       	   
        t                                                       |||t          d          ||t          d          |d u o|d u }
|d u| _        |
r(|&t	          j        d                                          }|1t          |t                    st          d|j	        j
                   |t          j        }|t          j        }|pt          |t                    rt          j        |          }nFt          |t                     r|                                }nt          d|j	        j
                   t%          j        ||||||||	          | _        || _        d S )Nz7cannot mix both url or sku_id and custom_id with Buttonzcannot mix both url and sku_id   z!expected custom_id to be str not z5expected emoji to be str, Emoji, or PartialEmoji not r+   r"   r#   r$   r!   r%   r'   r(   )super__init__	TypeError_provided_custom_idosurandomhex
isinstancestr	__class____name__r   linkpremiumr   from_strr   _to_partialr   _raw_construct_underlyingr&   )selfr!   r$   r#   r+   r"   r%   r&   r'   r(   requires_custom_idr<   s              R/usr/local/lib/hermes-agent/venv/lib/python3.11/site-packages/discord/ui/button.pyr4   zButton.__init__n   s    	 co9KUVVV?v1<=== D[;Vt^#,D#8  	-)"3
2**,,I Is)C)C ^	@S@\^^___?$E'E%%% t$-e44E9-- t))++ rX]XgXp r rsss*9	
 	
 	
     returnc                    | j         j        S )z.Optional[:class:`int`]: The ID of this button.rC   r(   rD   s    rF   r(   z	Button.id   s     ""rG   valueNonec                    || j         _        d S NrJ   rD   rL   s     rF   r(   z	Button.id   s    #rG   c                    | j         j        S )z6:class:`discord.ButtonStyle`: The style of the button.rC   r!   rK   s    rF   r!   zButton.style        %%rG   c                    || j         _        d S rO   rR   rP   s     rF   r!   zButton.style   s    !&rG   c                    | j         j        S )zOptional[:class:`str`]: The ID of the button that gets received during an interaction.

        If this button is for a URL, it does not have a custom ID.
        )rC   r+   rK   s    rF   r+   zButton.custom_id   s     ))rG   c                |    |$t          |t                    st          d          || j        _        |d u| _        d S )Nzcustom_id must be None or str)r:   r;   r5   rC   r+   r6   rP   s     rF   r+   zButton.custom_id   sD    Zs%;%;;<<<%*"#(#4   rG   c                    | j         j        S )z9Optional[:class:`str`]: The URL this button sends you to.)rC   r"   rK   s    rF   r"   z
Button.url   s     ##rG   c                j    |$t          |t                    st          d          || j        _        d S )Nzurl must be None or str)r:   r;   r5   rC   r"   rP   s     rF   r"   z
Button.url   s7    Zs%;%;5666$rG   c                    | j         j        S )z5:class:`bool`: Whether the button is disabled or not.)rC   r#   rK   s    rF   r#   zButton.disabled   s     ((rG   c                8    t          |          | j        _        d S rO   )r-   rC   r#   rP   s     rF   r#   zButton.disabled   s    $(KK!!!rG   c                    | j         j        S )z>Optional[:class:`str`]: The label of the button, if available.)rC   r$   rK   s    rF   r$   zButton.label   rS   rG   c                @    |t          |          n|| j        _        d S rO   )r;   rC   r$   rP   s     rF   r$   zButton.label   s"    /4/@UerG   Optional[PartialEmoji]c                    | j         j        S )zHOptional[:class:`.PartialEmoji`]: The emoji of the button, if available.)rC   r%   rK   s    rF   r%   zButton.emoji   rS   rG   c                0   |t          |t                    r t          j        |          | j        _        d S t          |t                    r |                                | j        _        d S t          d|j	        j
         d          d | j        _        d S )Nz/expected str, Emoji, or PartialEmoji, received z instead)r:   r;   r   r@   rC   r%   r   rA   r5   r<   r=   rP   s     rF   r%   zButton.emoji   s    %%% v)5)>u)E)E &&&E9-- v).):):)<)< &&& tRWRaRj t t tuuu%)D"""rG   c                    | j         j        S )zdOptional[:class:`int`]: The SKU ID this button sends you to.

        .. versionadded:: 2.4
        )rC   r'   rK   s    rF   r'   zButton.sku_id   s     &&rG   c                D    |t           j        | _        || j        _        d S rO   )r   r?   r!   rC   r'   rP   s     rF   r'   zButton.sku_id   s#    $,DJ"'rG   r   r   r   c                z     | |j         |j        |j        |j        |j        |j        d |j        |j        	  	        S )Nr*   )r!   r$   r#   r+   r"   r%   r'   r(   )clsr   s     rF   from_componentzButton.from_component  sG    s,,_&
,=y

 

 

 
	
rG   Literal[ComponentType.button]c                    | j         j        S rO   )rC   typerK   s    rF   rg   zButton.type  s    $$rG   ButtonComponentPayloadc                4    | j                                         S rO   )rC   to_dictrK   s    rF   to_component_dictzButton.to_component_dict  s    '')))rG   c                    | j         d uS rO   )r+   rK   s    rF   is_dispatchablezButton.is_dispatchable  s    ~T))rG   c                |    | j         t          j        u r	| j        d uS t	                                                      S rO   )r!   r   r>   r"   r3   is_persistent)rD   r<   s    rF   ro   zButton.is_persistent  s6    :)))84''ww$$&&&rG   c                    || _         d S rO   )rC   )rD   r   s     rF   _refresh_componentzButton._refresh_component  s    !rG   c           
        t          j         |           }| j        }| j        -| j        s&t          j        d                                          }t          j        || j        | j	        | j
        | j        | j        | j        | j                  |_        t!          |j        t$                    r||j        _        |                    | j                   |S )Nr1   r2   )copyr+   r6   r7   r8   r9   r   rB   r"   r#   r$   r!   r%   r'   r(   rC   r:   callbackr   item_update_viewview)rD   newr+   s      rF   rs   zButton.copy"  s    iooN	>%d.F%
2**,,I)8]***;w	
 	
 	
 clM22 	$ #CL###
rG   c                *    |                                  S rO   )rs   )rD   memos     rF   __deepcopy__zButton.__deepcopy__8  s    yy{{rG   )r!   r   r$   r,   r#   r-   r+   r,   r"   r,   r%   r.   r&   r/   r'   r/   r(   r/   )rH   r/   )rL   r/   rH   rM   )rH   r   )rL   r   rH   rM   )rH   r,   )rL   r,   rH   rM   )rH   r-   )rL   r-   rH   rM   )rH   r]   )rL   r.   rH   rM   )r   r   rH   r   )rH   re   )rH   rh   )r   r   rH   rM   )rH   r   )r=   
__module____qualname____doc__r)   __annotations__r   	secondaryr4   propertyr(   setterr!   r+   r"   r#   r$   r%   r'   classmethodrd   rg   rk   rm   ro   rq   rs   r{   __classcell__)r<   s   @rF   r   r   8   si        ( (T	1 	 	 	 	 )2##'!;?! $ 4 4 4 4 4 4 4 4l # # # X# Y$ $ $ Y$ & & & X& \' ' ' \' * * * X* 5 5 5 5 $ $ $ X$ 	Z% % % Z%
 ) ) ) X) _0 0 0 _0 & & & X& \L L L \L & & & X& \	* 	* 	* \	* ' ' ' X' ]( ( ( ](
 
 
 
 [
 % % % X%* * * ** * * *' ' ' ' ' '
" " " "   ,       rG   r   F)r$   r+   r#   r!   r%   r&   r(   r$   r,   r+   r#   r-   r!   r   r%   r.   r&   r/   r(   rH   5Callable[[ItemCallbackType[S, Button[V]]], Button[V]]c                ,     d fd}|S )a  A decorator that attaches a button to a component.

    The function being decorated should have three parameters, ``self`` representing
    the :class:`discord.ui.View`, the :class:`discord.Interaction` you receive and
    the :class:`discord.ui.Button` being pressed.

    .. note::

        Buttons with a URL or an SKU cannot be created with this function.
        Consider creating a :class:`Button` manually instead.
        This is because these buttons cannot have a callback
        associated with them since Discord does not do any processing
        with them.

    Parameters
    ------------
    label: Optional[:class:`str`]
        The label of the button, if any.
        Can only be up to 80 characters.
    custom_id: Optional[:class:`str`]
        The ID of the button that gets received during an interaction.
        It is recommended not to set this parameter to prevent conflicts.
        Can only be up to 100 characters.
    style: :class:`.ButtonStyle`
        The style of the button. Defaults to :attr:`.ButtonStyle.grey`.
    disabled: :class:`bool`
        Whether the button is disabled or not. Defaults to ``False``.
    emoji: Optional[Union[:class:`str`, :class:`.Emoji`, :class:`.PartialEmoji`]]
        The emoji of the button. This can be in string form or a :class:`.PartialEmoji`
        or a full :class:`.Emoji`.
    row: Optional[:class:`int`]
        The relative row this button belongs to. A Discord component 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).

        .. note::

            This parameter is ignored when used in a :class:`ActionRow` or v2 component.
    id: Optional[:class:`int`]
        The ID of this component. This must be unique across the view.

        .. versionadded:: 2.6
    funcItemCallbackType[S, Button[V]]rH   c           
         t          j        |           st          d          t          | _        d d d	| _        | S )Nz,button function must be a coroutine function)	r!   r+   r"   r#   r$   r%   r&   r'   r(   )inspectiscoroutinefunctionr5   r   __discord_ui_model_type____discord_ui_model_kwargs__)r   r+   r#   r%   r(   r$   r&   r!   s    rF   	decoratorzbutton.<locals>.decoratort  s_    *400 	LJKKK)/&" 
,
 
,
( rG   )r   r   rH   r    )r$   r+   r#   r!   r%   r&   r(   r   s   ``````` rF   r   r   <  sN    p           $ rG   )r$   r,   r+   r,   r#   r-   r!   r   r%   r.   r&   r/   r(   r/   rH   r   )-r~   
__future__r   rs   typingr   r   r   r   r   r	   r
   r   r7   ru   r   r   ItemCallbackTyper   enumsr   r   partial_emojir   r   
componentsr   r   __all__typing_extensionsr   rw   r   
action_rowr   	containerr   r%   r   types.componentsrh   r   r   r   r   r   rG   rF   <module>r      s   0 # " " " " "  T T T T T T T T T T T T T T T T T T  				 U T T T T T T T T T . . . . . . . . 3 3 3 3 3 3 3 3 2 2 2 2 2 2
  M&&&&&&%%%%%%$$$$$$LLLLLLGC>$OOOGCzT222A A A A AT!W A A AL  #$.7;J J J J J J J JrG   