
    i                        d Z ddlmZ ddlmZmZmZmZmZ ddl	m
Z
 ddlmZmZ ddlmZ dd	lmZ dd
lmZ erddlmZ ddlmZ  eddd          Zd
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LiteralOptionalTypeVarUnion   )Item   )FileComponentUnfurledMediaItem)ComponentType)MISSING)File)Self)
LayoutViewVr   T)bound	covariantc                  j    e Zd ZdZdZeddd# fdZed$d            Zej	        d%d            Zd Z
e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d Zed-d"            Z xZS ).r   a  Represents a UI file component.

    This is a top-level layout component that can only be used on :class:`LayoutView`.

    .. versionadded:: 2.6

    Example
    -------

    .. code-block:: python3

        import discord
        from discord import ui

        class MyView(ui.LayoutView):
            file = ui.File('attachment://file.txt')
            # attachment://file.txt points to an attachment uploaded alongside this view

    Parameters
    ----------
    media: Union[:class:`str`, :class:`.UnfurledMediaItem`, :class:`discord.File`]
        This file's media. If this is a string it must point to a local
        file uploaded within the parent view of this item, and must
        meet the ``attachment://<filename>`` format.
    spoiler: :class:`bool`
        Whether to flag this file as a spoiler. Defaults to ``False``.
    id: Optional[:class:`int`]
        The ID of this component. This must be unique across the view.
    mediaspoileridN)r   r   r   +Union[str, UnfurledMediaItem, SendableFile]r   boolr   Optional[int]returnNonec                  t                                                       t          |t                    r@t	          j        t          |j                  |t          u r|j	        n||          | _
        d S t	          j        t          |t                    rt          |          n|t          |          |          | _
        d S Nr   )super__init__
isinstanceSendableFiler   _raw_constructr   urir   r   _underlyingstrr   )selfr   r   r   	__class__s       P/usr/local/lib/hermes-agent/venv/lib/python3.11/site-packages/discord/ui/file.pyr#   zFile.__init__S   s     	e\** 	,;'	22)0G););     D  -;2<UC2H2HS'...eW     D    c                    | j         j        S )z6Optional[:class:`int`]: The ID of this file component.r(   r   r*   s    r,   r   zFile.idh   s     ""r-   valuec                    || j         _        d S Nr/   r*   r1   s     r,   r   zFile.idm   s    #r-   c                    dS )NT r0   s    r,   _is_v2zFile._is_v2q   s    tr-   c                    dS )N   r6   r0   s    r,   widthz
File.widtht   s    qr-   Literal[ComponentType.file]c                    | j         j        S r3   )r(   typer0   s    r,   r=   z	File.typex   s    $$r-   r   c                    | j         j        S )z5:class:`.UnfurledMediaItem`: Returns this file media.)r(   r   r0   s    r,   r   z
File.media|   s     %%r-   +Union[str, SendableFile, UnfurledMediaItem]c                J   t          |t                    rt          |          | j        _        d S t          |t                    r|| j        _        d S t          |t
                    r t          |j                  | j        _        d S t          d|j        j	                  )Nz1expected a str or UnfurledMediaItem or File, not )
r$   r)   r   r(   r   r%   r'   	TypeErrorr+   __name__r4   s     r,   r   z
File.media   s    eS!! 	n%6u%=%=D"""011 	n%*D"""|,, 	n%6uy%A%AD"""lPUP_Phllmmmr-   r)   c                $    | j         j        j        S )z&:class:`str`: Returns this file's url.)r(   r   urlr0   s    r,   rD   zFile.url   s     %))r-   c                8    t          |          | j        _        d S r3   )r   r(   r   r4   s     r,   rD   zFile.url   s    !25!9!9r-   c                    | j         j        S )zH:class:`bool`: Returns whether this file should be flagged as a spoiler.r(   r   r0   s    r,   r   zFile.spoiler   s     ''r-   c                    || j         _        d S r3   rG   r4   s     r,   r   zFile.spoiler   s    #(   r-   c                4    | j                                         S r3   )r(   to_dictr0   s    r,   to_component_dictzFile.to_component_dict   s    '')))r-   	componentr   r   c                <     | |j         |j        |j                  S r!   r   )clsrL   s     r,   from_componentzFile.from_component   s+    s/%|
 
 
 	
r-   )r   r   r   r   r   r   r   r   )r   r   )r1   r   r   r   )r   r;   )r   r   )r1   r?   r   r   )r   r)   )r1   r)   r   r   )r   r   )r1   r   r   r   )rL   r   r   r   )rB   
__module____qualname____doc____item_repr_attributes__r   r#   propertyr   setterr7   r:   r=   r   rD   r   rK   classmethodrO   __classcell__)r+   s   @r,   r   r   .   s        <           * # # # X# Y$ $ $ Y$     X % % % X% & & & X& \n n n \n * * * X* 	Z: : : Z: ( ( ( X( ^) ) ) ^)* * * 
 
 
 [
 
 
 
 
r-   r   N)rR   
__future__r   typingr   r   r   r   r   itemr
   
componentsr   r   enumsr   utilsr   filer   r%   typing_extensionsr   viewr   r   __all__r6   r-   r,   <module>rb      s8   0 # " " " " " C C C C C C C C C C C C C C       9 9 9 9 9 9 9 9 ! ! ! ! ! !       ' ' ' ' ' ' !&&&&&&      GC|t444
y
 y
 y
 y
 y
47 y
 y
 y
 y
 y
r-   