Ë
    úmxi=  ã                  óð   — d dl 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  G d	„ d
e«      Z G d„ de«      Z G d„ de«      Z G d„ dej*                  «      Z G d„ dee«      Zy)é    )ÚannotationsN)Úabstractmethod)ÚTYPE_CHECKINGÚ
NamedTupleÚProtocol)Úutil)ÚStatsProvider)ÚSequence)ÚFileURLsc                  ó:   — e Zd ZU dZded<   ded<   ded<   ded<   y)	ÚUploadedFileRecz7Metadata and raw bytes for an uploaded file. Immutable.ÚstrÚfile_idÚnameÚtypeÚbytesÚdataN©Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__© ó    ú^/home/htdocs/ttos/venv/lib/python3.12/site-packages/streamlit/runtime/uploaded_file_manager.pyr   r      s   … ÙAàƒLØ
ƒIØ
ƒIØ
„Kr   r   c                  ó0   — e Zd ZU dZded<   ded<   ded<   y)ÚUploadFileUrlInfoz:Information we provide for single file in get_upload_urls.r   r   Ú
upload_urlÚ
delete_urlNr   r   r   r   r   r   '   s   … ÙDàƒLØƒOØ„Or   r   c                  ó   — e Zd ZU dZded<   y)ÚDeletedFilea�  Represents a deleted file in deserialized values for st.file_uploader and
    st.camera_input.

    Return this from st.file_uploader and st.camera_input deserialize (so they can
    be used in session_state), when widget value contains file record that is missing
    from the storage.
    DeleteFile instances filtered out before return final value to the user in script,
    or before sending to frontend.
    r   r   Nr   r   r   r   r"   r"   /   s   … ñð „Lr   r"   c                  ó<   ‡ — e Zd ZdZdˆ fd„Zdd„Zdd„Zd	d„Zˆ xZS )
ÚUploadedFilezƒA mutable uploaded file.

    This class extends BytesIO, which has copy-on-write semantics when
    initialized with `bytes`.
    c                óà   •— t         ‰| �  |j                  «       |j                  | _        |j                  | _        |j
                  | _        t        |j                  «      | _        || _        y ©N)	ÚsuperÚ__init__r   r   r   r   ÚlenÚsizeÚ
_file_urls)ÚselfÚrecordÚ	file_urlsÚ	__class__s      €r   r(   zUploadedFile.__init__D   sN   ø€ ô
 	‰Ñ˜Ÿ™Ô%Ø—~‘~ˆŒØ—K‘KˆŒ	Ø—K‘KˆŒ	Ü˜Ÿ™Ó$ˆŒ	Ø#ˆ�r   c                ó`   — t        |t        «      st        S | j                  |j                  k(  S r&   )Ú
isinstancer$   ÚNotImplementedr   )r,   Úothers     r   Ú__eq__zUploadedFile.__eq__P   s%   € Ü˜%¤Ô.Ü!Ð!Ø�|‰|˜uŸ}™}Ñ,Ð,r   c                ó,   — t        | j                  «      S r&   )Úhashr   ©r,   s    r   Ú__hash__zUploadedFile.__hash__U   s   € Ü�D—L‘LÓ!Ð!r   c                ó,   — t        j                  | «      S r&   )r   Úrepr_r7   s    r   Ú__repr__zUploadedFile.__repr__X   s   € Ü�z‰z˜$ÓÐr   )r-   r   r.   ÚFileURLsProtoÚreturnÚNone)r3   Úobjectr=   Úbool)r=   Úint)r=   r   )	r   r   r   r   r(   r4   r8   r;   Ú__classcell__)r/   s   @r   r$   r$   =   s   ø„ ñõ
$ó-ó
"÷ r   r$   c                  óT   — e Zd ZdZe	 	 	 	 	 	 dd„«       Zedd„«       Z	 	 	 	 	 	 dd„Zy)	ÚUploadedFileManageraõ  UploadedFileManager protocol, that should be implemented by the concrete
    uploaded file managers.

    It is responsible for:
        - retrieving files by session_id and file_id for st.file_uploader and
            st.camera_input
        - cleaning up uploaded files associated with session on session end

    It should be created during Runtime initialization.

    Optionally UploadedFileManager could be responsible for issuing URLs which will be
    used by frontend to upload files to.
    c                ó   — t         ‚)aÉ  Return a  list of UploadedFileRec for a given sequence of file_ids.

        Parameters
        ----------
        session_id
            The ID of the session that owns the files.
        file_ids
            The sequence of ids associated with files to retrieve.

        Returns
        -------
        List[UploadedFileRec]
            A list of URL UploadedFileRec instances, each instance contains information
            about uploaded file.
        ©ÚNotImplementedError)r,   Ú
session_idÚfile_idss      r   Ú	get_fileszUploadedFileManager.get_filesk   ó
   € ô& "Ð!r   c                ó   — t         ‚)z1Remove all files associated with a given session.rF   )r,   rH   s     r   Úremove_session_filesz(UploadedFileManager.remove_session_files€   s
   € ô "Ð!r   c                ó   — t         ‚)a!  Return a list of UploadFileUrlInfo for a given sequence of file_names.
        Optional to implement, issuing of URLs could be done by other service.

        Parameters
        ----------
        session_id
            The ID of the session that request URLs.
        file_names
            The sequence of file names for which URLs are requested

        Returns
        -------
        List[UploadFileUrlInfo]
            A list of UploadFileUrlInfo instances, each instance contains information
            about uploaded file URLs.
        rF   )r,   rH   Ú
file_namess      r   Úget_upload_urlsz#UploadedFileManager.get_upload_urls…   rK   r   N)rH   r   rI   úSequence[str]r=   zlist[UploadedFileRec])rH   r   r=   r>   )rH   r   rO   rQ   r=   zlist[UploadFileUrlInfo])r   r   r   r   r   rJ   rM   rP   r   r   r   rD   rD   \   sd   „ ñð ð"Øð"Ø)6ð"à	ò"ó ð"ð( ò"ó ð"ð"Øð"Ø+8ð"à	 ô"r   rD   )Ú
__future__r   ÚioÚabcr   Útypingr   r   r   Ú	streamlitr   Ústreamlit.runtime.statsr	   Úcollections.abcr
   Ústreamlit.proto.Common_pb2r   r<   r   r   r"   ÚBytesIOr$   rD   r   r   r   ú<module>r[      sg   ðõ #ã 	Ý ß 6Ñ 6å Ý 1áÝ(åDô�jô ô˜
ô ô�*ô ô �2—:‘:ô  ô><"˜-¨õ <"r   