o
    h                     @  s\   d dl mZ d dlZd dlmZ d dlmZ erd dlmZ g dZ	dddZ
dddZdS )    )annotationsN)TYPE_CHECKING)StreamlitAPIException)Sequence))z.jpgz.jpeg)z.mpgz.mpeg)z.mp4z.mpeg4)z.tifz.tiff)z.htmz.html	file_typestr | Sequence[str]returnSequence[str]c                 C  sr   t | tr| g} dd | D } dd | D } tD ]\}}|| v r)|| vr)| | || v r6|| vr6| | q| S )Nc                 S  s&   g | ]}|d  dkr|nd| qS )r   . ).0file_type_entryr   r   ^/var/www/vscode/kcb/lib/python3.10/site-packages/streamlit/elements/lib/file_uploader_utils.py
<listcomp>(   s    z.normalize_upload_file_type.<locals>.<listcomp>c                 S  s   g | ]}|  qS r   )lower)r   tr   r   r   r   -   s    )
isinstancestr
TYPE_PAIRSappend)r   xyr   r   r   normalize_upload_file_type"   s   


r   filenamer   allowed_typesNonec                 C  s<   t j| d  }|r||vrtd| d| dS dS )a   Ensure the uploaded file's extension matches the allowed
    types set by the app developer. In theory, this should never happen, since we
    enforce file type check by extension on the frontend, but we check it on backend
    before returning file to the user to protect ourselves.
       zInvalid file extension: `z`. Allowed: N)ospathsplitextr   r   )r   r   	extensionr   r   r   enforce_filename_restriction8   s   r!   )r   r   r   r	   )r   r   r   r	   r   r   )
__future__r   r   typingr   streamlit.errorsr   collections.abcr   r   r   r!   r   r   r   r   <module>   s   
	