
    ȯei                        U d dl mZ d dlZd dlmZ d dlmZmZmZm	Z	 d dl
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ez  ez  ej.                  z  Zded<   ddZ G d d      Zy)    )annotationsN)Path)TYPE_CHECKINGAny	TypeAliascast)url_util)validate_heightStreamlitAPIException)gather_metrics)DeltaGenerator)HeightWithoutContentr   PdfDatac                 B    	 ddl } | j                  S # t        $ r Y yw xY w)zGet the PDF custom component if available.

    Returns
    -------
    Any | None
        The pdf_viewer function if the streamlit-pdf component is available,
        None otherwise.
    r   N)streamlit_pdf
pdf_viewerImportError)r   s    X/var/www/html/glpi_dashboard/venv/lib/python3.12/site-packages/streamlit/elements/pdf.py_get_pdf_componentr   !   s(    ''' s    	c                  v    e Zd Z ed      ddd	 	 	 	 	 	 	 d	d       Z	 	 	 	 	 	 	 	 	 	 d
dZddZedd       Zy)PdfMixinpdfi  N)heightkeyc               |    |t        d      t               }|| j                         S | j                  ||||      S )a  Display a PDF viewer.

        .. Important::

            You must install |streamlit-pdf|_ to use this command. You can
            install it as an extra with Streamlit:

            .. code-block:: shell

                pip install streamlit[pdf]

        .. |streamlit-pdf| replace:: ``streamlit-pdf``
        .. _streamlit-pdf: https://github.com/streamlit/streamlit-pdf

        Parameters
        ----------
        data : str, Path, BytesIO, or bytes
            The PDF file to show. This can be one of the following:

            - A URL (string) for a hosted PDF file.
            - A path to a local PDF file. If you use a relative path, it must
              be relative to the current working directory.
            - A file-like object. For example, this can be an ``UploadedFile``
              from ``st.file_uploader``, or this can be a local file opened
              with ``open()``.
            - Raw bytes data.

        height : int or "stretch"
            The height of the PDF viewer. This can be one of the following:

            - An integer specifying the height in pixels: The viewer has a
              fixed height. If the content is larger than the specified
              height, scrolling is enabled. This is ``500`` by default.
            - ``"stretch"``: The height of the viewer matches the height of
              its content or the height of the parent container, whichever is
              larger. If the viewer is not in a parent container, the height
              of the viewer matches the height of its content.

        Example
        -------
        >>> st.pdf("https://example.com/sample.pdf")
        >>> st.pdf("https://example.com/sample.pdf", height=600)
        zhThe PDF data cannot be None. Please provide a valid PDF file path, URL, bytes data, or file-like object.)r   r   _show_pdf_warning_call_pdf_component)selfdatar   r   pdf_components        r   r   zPdfMixin.pdf3   sR    h <'3  +, ))++''tVSII    c                   t        |d       t        |t        t        f      rZt        |      j	                         }t        j                  |d      r|}n	 t        |d      5 }|j                         }ddd       n{t        |t              r|}nht        |d	      rt        |d
      r|j                         }n?t        |d	      r|j                         }n"t        dt        |      j                    d      |dk(  rd}	nt        |      }	 ||	|      }
t#        d|
      S # 1 sw Y   xY w# t        t        f$ r}t        d| d|       d}~ww xY w)z5Call the custom PDF component with the provided data.F)allow_content)httphttps)allowed_schemasrbNzUnable to read file 'z': readgetvaluezUnsupported data type for PDF: zy. Please provide a file path (str or Path), URL (str), bytes data, or file-like object (such as BytesIO or UploadedFile).stretch)filer   r   r   )r
   
isinstancestrr   stripr	   is_urlopenr)   FileNotFoundErrorPermissionErrorr   byteshasattrr*   type__name__r   )r   r!   r    r   r   data_str
file_paramr,   ecomponent_heightresults              r   r   zPdfMixin._call_pdf_componentt   sW    	e4
 dS$K(4y(Hx9JK%
h- 1%)YY[
1 e$JT6"wtZ'@JT6"J (1$t*2E2E1F GI J  Y  )"6{#

 $f--K1 1)?; //zQC@ s0   D/ $D#5D/ #D,(D/ /E>EEc                    t        d      )z;Raise an exception that the PDF component is not available.zThe PDF viewer requires the `streamlit-pdf` component to be installed.

Please run `pip install streamlit[pdf]` to install it.

For more information, see the Streamlit PDF documentation at https://docs.streamlit.io/develop/api-reference/media/st.pdf.r   r   s    r   r   zPdfMixin._show_pdf_warning   s    #L
 	
r"   c                    t        d|       S )zGet our DeltaGenerator.r   )r   r>   s    r   dgzPdfMixin.dg   s     $d++r"   )r    r   r   r   r   
str | Nonereturnr   )
r!   r   r    r   r   r   r   rA   rB   r   )rB   r   )	r7   
__module____qualname__r   r   r   r   propertyr@    r"   r   r   r   2   s    E
 (+>J>J %	>J
 >J 
>J >J@;.;. ;. %	;.
 ;. 
;.z
 , ,r"   r   )rB   z
Any | None)
__future__r   iopathlibr   typingr   r   r   r   	streamlitr	   #streamlit.elements.lib.layout_utilsr
   streamlit.errorsr   streamlit.runtime.metrics_utilr   streamlit.delta_generatorr   r   r.   r4   BytesIOr   __annotations__r   r   rF   r"   r   <module>rR      sX    # 	  6 6  ? 2 98H4Z%'"**4 4"L, L,r"   