U
    ARd                  	   @   sz   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
 G dd dZdeee ee ee ee edd	d
dZdS )    )TYPE_CHECKINGOptionalcast)IFrame)gather_metrics)DeltaGeneratorc                   @   sn   e Zd Zeddeee ee eddddZeddeee ee edd	d
dZ	e
ddddZdS )IframeMixin_iframeNFr   )srcwidthheight	scrollingreturnc                 C   s&   t  }t|||||d | jd|S )a  Load a remote URL in an iframe.

        Parameters
        ----------
        src : str
            The URL of the page to embed.
        width : int
            The width of the frame in CSS pixels. Defaults to the app's
            default element width.
        height : int
            The height of the frame in CSS pixels. Defaults to 150.
        scrolling : bool
            If True, show a scrollbar when the content is larger than the iframe.
            Otherwise, do not show a scrollbar. Defaults to False.

        )r
   r   r   r   iframeIFrameProtomarshalldgZ_enqueue)selfr
   r   r   r   iframe_proto r   =/tmp/pip-unpacked-wheel-b9et7o5g/streamlit/elements/iframe.pyr	      s    zIframeMixin._iframe_html)htmlr   r   r   r   c                 C   s&   t  }t|||||d | jd|S )a"  Display an HTML string in an iframe.

        Parameters
        ----------
        html : str
            The HTML string to embed in the iframe.
        width : int
            The width of the frame in CSS pixels. Defaults to the app's
            default element width.
        height : int
            The height of the frame in CSS pixels. Defaults to 150.
        scrolling : bool
            If True, show a scrollbar when the content is larger than the iframe.
            Otherwise, do not show a scrollbar. Defaults to False.

        )srcdocr   r   r   r   r   )r   r   r   r   r   r   r   r   r   r   ;   s    zIframeMixin._html)r   c                 C   s
   t d| S )zGet our DeltaGenerator.r   )r   )r   r   r   r   r   ]   s    zIframeMixin.dg)NNF)NNF)__name__
__module____qualname__r   strr   intboolr	   r   propertyr   r   r   r   r   r      s0      !   !r   NF)protor
   r   r   r   r   r   c                 C   sP   |dk	r|| _ |dk	r|| _|dk	r0|| _d| _|dk	r@|| _nd| _|| _dS )a  Marshalls data into an IFrame proto.

    These parameters correspond directly to <iframe> attributes, which are
    described in more detail at
    https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe.

    Parameters
    ----------
    proto : IFrame protobuf
        The protobuf object to marshall data into.
    src : str
        The URL of the page to embed.
    srcdoc : str
        Inline HTML to embed. Overrides src.
    width : int
        The width of the frame in CSS pixels. Defaults to the app's
        default element width.
    height : int
        The height of the frame in CSS pixels. Defaults to 150.
    scrolling : bool
        If true, show a scrollbar when the content is larger than the iframe.
        Otherwise, never show a scrollbar.

    NT   )r
   r   r   Z	has_widthr   r   )r"   r
   r   r   r   r   r   r   r   r   c   s     r   )NNNNF)typingr   r   r   Zstreamlit.proto.IFrame_pb2r   r   Zstreamlit.runtime.metrics_utilr   Zstreamlit.delta_generatorr   r   r   r   r    r   r   r   r   r   <module>   s&   M     