
    i1                    B   d Z ddlmZ ddlmZmZmZmZmZm	Z	m
Z
mZ ddl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 er(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Z' e
ddd          Z( G d dee(                   Z) G d dee(                   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.
    )annotations)TYPE_CHECKINGAnyListLiteralOptionalTupleTypeVarDictN   )MISSING)CheckboxGroupComponentCheckboxComponentCheckboxGroupOption)ComponentType   )Item)Self)Interaction)'ModalSubmitCheckboxGroupInteractionData"ModalSubmitCheckboxInteractionData)r   r   )BaseView)
ResolveKey)CheckboxGroupCheckboxVr   T)bound	covariantc                  :    e Zd ZU dZdZded<   edddedddA fdZedBd            Z	e	j
        dCd            Z	edDd            ZedEd            Zej
        dFd            ZedGd            ZedHd            Zej
        dId            ZedJd!            Zej
        dKd"            ZedJd#            Zej
        dKd$            Zedd%d&dLd+ZdMd.ZedNd/            Zej
        dOd0            ZedJd1            ZdPd3ZdQd6ZdRd=ZedSd?            ZdNd@Z xZS )Tr   a  Represents a checkbox group component within a modal.

    .. versionadded:: 2.7

    Parameters
    ------------
    id: Optional[:class:`int`]
        The ID of the component. This must be unique across the view.
    custom_id: Optional[:class:`str`]
        The custom ID of the component.
    options: List[:class:`discord.CheckboxGroupOption`]
        A list of options that can be selected in this checkbox group.
        Can only contain up to 10 items.
    max_values: Optional[:class:`int`]
        The maximum number of options that can be selected in this component.
        Must be between 1 and 10. Defaults to 1.
    min_values: Optional[:class:`int`]
        The minimum number of options that must be selected in this component.
        Must be between 0 and 10. Defaults to 0.
    required: :class:`bool`
        Whether this component is required to be filled before submitting the modal.
        Defaults to ``True``.
    )id	custom_idoptionsrequiredTuple[str, ...]__item_repr_attributes__TN)r!   r#   
min_values
max_valuesr"   r    r!   strr#   boolr&   Optional[int]r'   r"   List[CheckboxGroupOption]r    returnNonec                  t                                                       |t          u| _        |t          u r&t	          j        d                                          n|}t          |t                    st          d|j
        j                   t          j        ||||pg ||          | _        || _        g | _        d S )N   !expected custom_id to be str not )r    r!   r#   r"   r&   r'   )super__init__r   _provided_custom_idosurandomhex
isinstancer(   	TypeError	__class____name__r   _raw_construct_underlyingr    _values)selfr!   r#   r&   r'   r"   r    r9   s          T/usr/local/lib/hermes-agent/venv/lib/python3.11/site-packages/discord/ui/checkbox.pyr2   zCheckboxGroup.__init__]   s     	#,G#; ,5,@,@BJrNN&&(((i	)S)) 	`^	@S@\^^___3I3XMr!!4
 4
 4
 "$    c                    | j         j        S z1Optional[:class:`int`]: The ID of this component.r<   r    r>   s    r?   r    zCheckboxGroup.idx        ""r@   valuec                    || j         _        d S NrC   r>   rF   s     r?   r    zCheckboxGroup.id}       #r@   	List[str]c                    | j         S )zIList[:class:`str`]: A list of values that have been selected by the user.)r=   rD   s    r?   valueszCheckboxGroup.values   s     |r@   c                    | j         j        S zO:class:`str`: The ID of the component that gets received during an interaction.r<   r!   rD   s    r?   r!   zCheckboxGroup.custom_id        ))r@   c                t    t          |t                    st          d          || j        _        d| _        d S Nzcustom_id must be a strTr7   r(   r8   r<   r!   r3   rI   s     r?   r!   zCheckboxGroup.custom_id   <    %%% 	75666%*"#'   r@   %Literal[ComponentType.checkbox_group]c                    t           j        S z4:class:`.ComponentType`: The type of this component.)r   checkbox_grouprD   s    r?   typezCheckboxGroup.type   s     ++r@   c                    | j         j        S )z`List[:class:`discord.CheckboxGroupOption`]: A list of options that can be selected in this menu.)r<   r"   rD   s    r?   r"   zCheckboxGroup.options        ''r@   c                    t          |t                    rt          d |D                       st          d          || j        _        d S )Nc              3  @   K   | ]}t          |t                    V  d S rH   )r7   r   ).0objs     r?   	<genexpr>z(CheckboxGroup.options.<locals>.<genexpr>   s.      1h1h[^*SBU2V2V1h1h1h1h1h1hr@   z-options must be a list of CheckboxGroupOption)r7   listallr8   r<   r"   rI   s     r?   r"   zCheckboxGroup.options   sU    %&& 	Mc1h1hbg1h1h1h.h.h 	MKLLL#(   r@   intc                    | j         j        S )z^:class:`int`: The minimum number of options that must be selected before submitting the modal.)r<   r&   rD   s    r?   r&   zCheckboxGroup.min_values        **r@   c                8    t          |          | j        _        d S rH   )rd   r<   r&   rI   s     r?   r&   zCheckboxGroup.min_values       &)%jj###r@   c                    | j         j        S )z]:class:`int`: The maximum number of options that can be selected before submitting the modal.)r<   r'   rD   s    r?   r'   zCheckboxGroup.max_values   rf   r@   c                8    t          |          | j        _        d S rH   )rd   r<   r'   rI   s     r?   r'   zCheckboxGroup.max_values   rh   r@   F)rF   descriptiondefaultlabelrk   Optional[str]rl   c               V    t          ||||          }|                     |           dS )am  Adds an option to the checkbox group.

        To append a pre-existing :class:`discord.CheckboxGroupOption` use the
        :meth:`append_option` method instead.

        Parameters
        -----------
        label: :class:`str`
            The label of the option. This is displayed to users.
            Can only be up to 100 characters.
        value: :class:`str`
            The value of the option. This is not displayed to users.
            If not given, defaults to the label.
            Can only be up to 100 characters.
        description: Optional[:class:`str`]
            An additional description of the option, if any.
            Can only be up to 100 characters.
        default: :class:`bool`
            Whether this option is selected by default.

        Raises
        -------
        ValueError
            The number of options exceeds 10.
        )rm   rF   rk   rl   N)r   append_option)r>   rm   rF   rk   rl   options         r?   
add_optionzCheckboxGroup.add_option   sA    D %#	
 
 
 	6"""""r@   rq   r   c                    t          | j        j                  dk    rt          d          | j        j                            |           dS )a'  Appends an option to the checkbox group.

        Parameters
        -----------
        option: :class:`discord.CheckboxGroupOption`
            The option to append to the checkbox group.

        Raises
        -------
        ValueError
            The number of options exceeds 10.
        
   z/maximum number of options already provided (10)N)lenr<   r"   
ValueErrorappend)r>   rq   s     r?   rp   zCheckboxGroup.append_option   sL     t'((B..NOOO ''/////r@   c                    | j         j        S )z8:class:`bool`: Whether the component is required or not.)r<   r#   rD   s    r?   r#   zCheckboxGroup.required   s     ((r@   c                8    t          |          | j        _        d S rH   )r)   r<   r#   rI   s     r?   r#   zCheckboxGroup.required   s    $(KK!!!r@   c                    dS N    rD   s    r?   widthzCheckboxGroup.width       qr@   CheckboxGroupComponentPayloadc                4    | j                                         S rH   r<   to_dictrD   s    r?   to_component_dictzCheckboxGroup.to_component_dict       '')))r@   	componentr   c                    || _         d S rH   r<   r>   r   s     r?   _refresh_componentz CheckboxGroup._refresh_component      $r@   interactionr   data.ModalSubmitCheckboxGroupInteractionDataPayloadresolvedDict[ResolveKey, Any]c                <    |                     dg           | _        d S )NrM   )getr=   r>   r   r   r   s       r?   _handle_submitzCheckboxGroup._handle_submit  s     xx"--r@   r   c                d     | |j         |j        |j        |j        |j        |j                  }|S )Nr    r!   r"   r#   r&   r'   r   clsr   r>   s      r?   from_componentzCheckboxGroup.from_component  sB    s|)%' + +
 
 
 r@   c                    dS NFr}   rD   s    r?   is_dispatchablezCheckboxGroup.is_dispatchable      ur@   )r!   r(   r#   r)   r&   r*   r'   r*   r"   r+   r    r*   r,   r-   r,   r*   rF   r*   r,   r-   )r,   rK   r,   r(   rF   r(   r,   r-   )r,   rV   )r,   r+   )rF   r+   r,   r-   r,   rd   )rF   rd   r,   r-   )
rm   r(   rF   r(   rk   rn   rl   r)   r,   r-   )rq   r   r,   r-   r,   r)   rF   r)   r,   r-   )r,   r   )r   r   r,   r-   )r   r   r   r   r   r   r,   r-   )r   r   r,   r   )r:   
__module____qualname____doc__r%   __annotations__r   r2   propertyr    setterrM   r!   rZ   r"   r&   r'   rr   rp   r#   r~   r   r   r   classmethodr   r   __classcell__r9   s   @r?   r   r   =   s#         01     !$($(-4 % % % % % % % %6 # # # X# Y$ $ $ Y$    X * * * X* ( ( ( ( , , , X, ( ( ( X( ^) ) ) ^)
 + + + X+ 1 1 1 1 + + + X+ 1 1 1 1 %))# )# )# )# )# )#V0 0 0 0& ) ) ) X) _0 0 0 _0    X* * * *% % % %. . . .
 	 	 	 [	       r@   r   c                  l    e Zd ZU dZdZded<   edddd, fdZed-d            Z	e	j
        d.d            Z	ed/d            Zed0d            Zej
        d1d            Zed2d            Zed/d            Zej
        d3d            Zed4d            Zd5dZd6d!Zd7d(Zed8d*            Zd/d+Z xZS )9r   at  Represents a checkbox component within a modal.

    .. versionadded:: 2.7

    Parameters
    ------------
    id: Optional[:class:`int`]
        The ID of the component. This must be unique across the view.
    custom_id: Optional[:class:`str`]
        The custom ID of the component.
    default: :class:`bool`
        Whether this checkbox is selected by default.
    r    r!   rl   r$   r%   FN)r!   rl   r    r!   r(   rl   r)   r    r*   r,   r-   c               |   t                                                       |t          u| _        |t          u r&t	          j        d                                          n|}t          |t                    st          d|j
        j                   t          j        |||          | _        || _        || _        d S )Nr/   r0   r   )r1   r2   r   r3   r4   r5   r6   r7   r(   r8   r9   r:   r   r;   r<   r    _value)r>   r!   rl   r    r9   s       r?   r2   zCheckbox.__init__0  s     	#,G#; ,5,@,@BJrNN&&(((i	)S)) 	`^	@S@\^^___.?.N/
 /
 /

 #r@   c                    | j         j        S rB   rC   rD   s    r?   r    zCheckbox.idE  rE   r@   rF   c                    || j         _        d S rH   rC   rI   s     r?   r    zCheckbox.idJ  rJ   r@   c                    | j         S )zK:class:`bool`: ``True`` if this checkbox was selected, otherwise ``False``.)r   rD   s    r?   rF   zCheckbox.valueN  s     {r@   c                    | j         j        S rO   rP   rD   s    r?   r!   zCheckbox.custom_idS  rQ   r@   c                t    t          |t                    st          d          || j        _        d| _        d S rS   rT   rI   s     r?   r!   zCheckbox.custom_idX  rU   r@   Literal[ComponentType.checkbox]c                    t           j        S rX   )r   checkboxrD   s    r?   rZ   zCheckbox.type`  s     %%r@   c                    | j         j        S )z<:class:`bool`: Whether this checkbox is selected by default.)r<   rl   rD   s    r?   rl   zCheckbox.defaulte  r\   r@   c                8    t          |          | j        _        d S rH   )r)   r<   rl   rI   s     r?   rl   zCheckbox.defaultj  s    #';;   r@   rd   c                    dS r{   r}   rD   s    r?   r~   zCheckbox.widthn  r   r@   CheckboxComponentPayloadc                4    | j                                         S rH   r   rD   s    r?   r   zCheckbox.to_component_dictr  r   r@   r   r   c                    || _         d S rH   r   r   s     r?   r   zCheckbox._refresh_componentu  r   r@   r   r   r   )ModalSubmitCheckboxInteractionDataPayloadr   r   c                <    |                     dd          | _        d S )NrF   F)r   r   r   s       r?   r   zCheckbox._handle_submitx  s     hhw..r@   r   c                @     | |j         |j        |j                  }|S )Nr   r   r   s      r?   r   zCheckbox.from_component}  s0    s|)%
 
 

 r@   c                    dS r   r}   rD   s    r?   r   zCheckbox.is_dispatchable  r   r@   )r!   r(   rl   r)   r    r*   r,   r-   r   r   r   r   r   )r,   r   r   r   )r,   r   )r   r   r,   r-   )r   r   r   r   r   r   r,   r-   )r   r   r,   r   )r:   r   r   r   r%   r   r   r2   r   r    r   rF   r!   rZ   rl   r~   r   r   r   r   r   r   r   r   s   @r?   r   r     s         1     ! $ $ $ $ $ $ $ $* # # # X# Y$ $ $ Y$    X * * * X* ( ( ( ( & & & X& ( ( ( X( ^/ / / ^/    X* * * *% % % %/ / / /
    [       r@   r   )+r   
__future__r   typingr   r   r   r   r   r	   r
   r   r4   utilsr   
componentsr   r   r   enumsr   itemr   typing_extensionsr   interactionsr   types.interactionsr   r   r   r   types.componentsr   r   viewr   app_commands.namespacer   __all__r   r   r   r}   r@   r?   <module>r      s   0 # " " " " " T T T T T T T T T T T T T T T T T T T T 				       W W W W W W W W W W ! ! ! ! ! !       4&&&&&&******               333333 GCzT222[ [ [ [ [DG [ [ [|l l l l ltAw l l l l lr@   