
    gK                        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 d dlmZ d dlmZmZmZ erd d	lmZ  G d
 d      ZddZy)    )annotationsN)Path)TYPE_CHECKINGAnycast)Html)gather_metrics)
clean_text)SupportsReprHtmlSupportsStrhas_callable_attr)DeltaGeneratorc                  D    e Zd Z ed      	 	 	 	 dd       Zedd       Zy)	HtmlMixinhtmlc                   t               }t        |d      r$t        t        |      j	                         |_        nst        |t              st        |      r:t        t        t        |      d      5 }|j                         |_        ddd       nt        t        t        |            |_        | j                  j                  d|      S # 1 sw Y   %xY w)a  Insert HTML into your app.

        Adding custom HTML to your app impacts safety, styling, and
        maintainability. We sanitize HTML with `DOMPurify
        <https://github.com/cure53/DOMPurify>`_, but inserting HTML remains a
        developer risk. Passing untrusted code to ``st.html`` or dynamically
        loading external code can increase the risk of vulnerabilities in your
        app.

        ``st.html`` content is **not** iframed. Executing JavaScript is not
        supported at this time.

        Parameters
        ----------
        body : any
            The HTML code to insert. This can be one of the following:

            - A string of HTML code.
            - A path to a local file with HTML code. The path can be a ``str``
              or ``Path`` object. Paths can be absolute or relative to the
              working directory (where you execute ``streamlit run``).
            - Any object. If ``body`` is not a string or path, Streamlit will
              convert the object to a string. ``body._repr_html_()`` takes
              precedence over ``str(body)`` when available.

        Example
        -------
        >>> import streamlit as st
        >>>
        >>> st.html(
        ...     "<p><span style='text-decoration: line-through double red;'>Oops</span>!</p>"
        ... )

        .. output::
           https://doc-html.streamlit.app/
           height: 300px

        _repr_html_zutf-8)encodingNr   )	HtmlProtor   r   r   r   body
isinstancer   _is_fileopenstrreadr
   r   dg_enqueue)selfr   
html_protofs       L/var/www/openai/venv/lib/python3.12/site-packages/streamlit/elements/html.pyr   zHtmlMixin.html   s    V [
 T=1"#3T:FFHJO d#x~d3o8A"#&&(
 98
 )k4)@AJOww
33 98s   1C

Cc                    t        d|       S )zGet our DeltaGenerator.r   )r   )r   s    r!   r   zHtmlMixin.dg[   s     $d++    N)r   z+str | Path | SupportsStr | SupportsReprHtmlreturnr   )r$   r   )__name__
__module____qualname__r	   r   propertyr    r#   r!   r   r      s@    F94994 
94 94v , ,r#   r   c                `    	 t         j                  j                  |       S # t        $ r Y yw xY w)zbChecks if obj is a file, and doesn't throw if not.

    The "not throwing" part is important!
    F)ospathisfile	TypeError)objs    r!   r   r   a   s,    
ww~~c"" s   ! 	--)r/   r   r$   bool)
__future__r   r+   pathlibr   typingr   r   r   streamlit.proto.Html_pb2r   r   streamlit.runtime.metrics_utilr	   streamlit.string_utilr
   streamlit.type_utilr   r   r   streamlit.delta_generatorr   r   r   r)   r#   r!   <module>r9      s=    # 	  + + 6 9 , P P8@, @,Fr#   