import { r as registerInstance, c as createEvent, h, g as getElement } from './chunk-82a2445c.js';
import './chunk-d7ac2f15.js';
import { C as Css, D as DomUtil } from './chunk-18ca1c85.js';

class Iframe {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.fullscreenClass = 'iframe-holder-fullscreen';
        this.width = '100%';
        this.height = '420px';
        this.fullscreen = false;
        this.fullscreenMargin = '0 0 0 0';
        this.iframeLoaded = createEvent(this, "iframeLoaded", 7);
    }
    onIframeLoaded() {
        this.iframeLoaded.emit({ src: this.src });
    }
    componentDidLoad() {
        this.postRender();
    }
    componentDidUpdate() {
        this.postRender();
    }
    postRender() {
        let iframe = this.el.getElementsByClassName('ema-iframe-iframe')[0];
        let holderEl = this.el.getElementsByClassName('ema-iframe-holder')[0];
        if (!this.fullscreen) {
            Css.setVar('width', this.width, this.el);
            Css.setVar('height', this.height, this.el);
            iframe.setAttribute('width', Css.getVar('width', this.el));
            iframe.setAttribute('height', Css.getVar('height', this.el));
        }
        if (this.fullscreen) {
            let margins = this.fullscreenMargin.split(' ');
            if (margins.length && margins.length === 1) {
                Css.setVar('top', margins[0], this.el);
                Css.setVar('right', margins[0], this.el);
                Css.setVar('bottom', margins[0], this.el);
                Css.setVar('left', margins[0], this.el);
            }
            if (margins.length && margins.length === 2) {
                Css.setVar('top', margins[0], this.el);
                Css.setVar('right', margins[1], this.el);
                Css.setVar('bottom', margins[0], this.el);
                Css.setVar('left', margins[1], this.el);
            }
            if (margins.length && margins.length === 3) {
                Css.setVar('top', margins[0], this.el);
                Css.setVar('right', margins[1], this.el);
                Css.setVar('bottom', margins[2], this.el);
            }
            if (margins.length && margins.length === 4) {
                Css.setVar('top', margins[0], this.el);
                Css.setVar('right', margins[1], this.el);
                Css.setVar('bottom', margins[2], this.el);
                Css.setVar('left', margins[3], this.el);
            }
            DomUtil.addClass(holderEl, this.fullscreenClass);
        }
        if (this.zIndex)
            Css.setVar('zIndex', this.zIndex, this.el);
        iframe.onload = () => {
            Css.setVar('visibility', 'visible', this.el);
            this.iframeLoaded.emit({ src: this.src, el: this.el });
        };
    }
    render() {
        return (h("div", { class: 'ema-iframe-holder ' }, h("iframe", { src: this.src, frameborder: "0", class: "ema-iframe-iframe" })));
    }
    get el() { return getElement(this); }
    static get style() { return ":root{--ema-color:#343a40;--ema-primary:#007bff;--ema-secondary:#6c757d;--ema-success:#28a745;--ema-info:#17a2b8;--ema-warning:#ffc107;--ema-danger:#dc3545;--ema-light:#f8f9fa;--ema-dark:#343a40;--ema-background:#fff;--ema-background-diap:rgba(29,29,29,0.97);--ema-border-color:#c5c9cd;--ema-border:1px solid #c5c9cd;--ema-border-radius:3px 3px 3px 3px;--ema-box-shadow:1px 1px 10px 1px #ccc;--ema-margin:0.25rem;--ema-margin-sm:0.5rem;--ema-margin-md:1rem;--ema-margin-lg:1.5rem;--ema-margin-xl:2rem;--ema-padding:0.25rem;--ema-padding-sm:0.5rem;--ema-padding-md:1rem;--ema-padding-lg:1.5rem;--ema-padding-xl:2rem;--ema-gray-100:#f8f9fa;--ema-gray-200:#e9ecef;--ema-gray-300:#dee2e6;--ema-gray-400:#ced4da;--ema-gray-500:#adb5bd;--ema-gray-600:#868e96;--ema-gray-700:#495057;--ema-gray-800:#343a40;--ema-gray-900:#212529}ema-iframe{--top:0;--right:0;--bottom:0;--left:0;--visibility:hidden}ema-iframe .ema-iframe-holder{z-index:var(--zIndex);width:var(--width);height:var(--height);visibility:var(--visibility,\"visible\")}ema-iframe .ema-iframe-holder iframe{height:100%;width:100%}ema-iframe .iframe-holder-fullscreen{position:fixed;top:var(--top);right:var(--right);bottom:var(--bottom);left:var(--left);-webkit-overflow-scrolling:touch;overflow-y:scroll}ema-iframe .iframe-holder-fullscreen iframe{height:100%;width:100%}"; }
}

export { Iframe as ema_iframe };
