import { p as proxyCustomElement, H, c as createEvent, h, d as Host } from './p-AiOs8RvA.js';

const verdocsMenuPanelCss = "@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}#verdocs-menu-panel-overlay{top:0;left:0;width:100%;height:100%;z-index:10000;position:fixed;background-color:rgba(0, 0, 0, 0.4980392157)}#verdocs-menu-panel{opacity:0;z-index:10001;position:fixed;overflow-y:scroll;background-color:#ffffff;font-family:\"Inter\", -apple-system, \"Segoe UI\", \"Roboto\", \"Helvetica Neue\", sans-serif;-webkit-animation:showVerdocsMenuPanel 0.35s;-webkit-animation-fill-mode:forwards}@-webkit-keyframes showVerdocsMenuPanel{0%{opacity:0;right:-300px}100%{right:0;opacity:1}}";

const VerdocsMenuPanel = /*@__PURE__*/ proxyCustomElement(class VerdocsMenuPanel extends H {
    constructor() {
        super();
        this.__registerHost();
        this.close = createEvent(this, "close");
        this.moved = false;
        this.overlayId = `verdocs-menu-panel-overlay`;
        this.panelId = `verdocs-menu-panel`;
        /**
         * Which side of the screen to place the panel.
         */
        this.side = 'right';
        /**
         * Whether to show an overlay over the rest of the page.
         */
        this.overlay = true;
        /**
         * The width of the panel.
         */
        this.width = 300;
    }
    handleClick(e) {
        var _a;
        if (!this.element.contains(e.target)) {
            this.hide();
            (_a = this.close) === null || _a === void 0 ? void 0 : _a.emit();
        }
    }
    componentWillLoad() {
        this.hide();
        if (this.overlay) {
            this.portal = document.createElement('div');
            this.portal.setAttribute('id', this.overlayId);
            document.body.append(this.portal);
        }
        this.portal = document.createElement('div');
        this.portal.setAttribute('id', this.panelId);
        this.portal.style.top = `0px`;
        this.portal.style.bottom = `0px`;
        this.portal.style.width = `${this.width}px`;
        if (this.side === 'left') {
            this.portal.style.left = `0px`;
        }
        else {
            this.portal.style.right = `0px`;
        }
        document.body.append(this.portal);
    }
    componentDidLoad() {
        this.portal.appendChild(this.element);
    }
    disconnectedCallback() {
        this.moved ? this.portal.remove() : (this.moved = true);
    }
    hide() {
        var _a, _b;
        (_a = document.getElementById(this.overlayId)) === null || _a === void 0 ? void 0 : _a.remove();
        (_b = document.getElementById(this.panelId)) === null || _b === void 0 ? void 0 : _b.remove();
    }
    render() {
        return (h(Host, { key: '620b2d96ba41fcd87803da3c3d36436f17da02fd', ref: el => (this.element = el) }, h("slot", { key: '85ac66ee22cf9a5717f4fe5de2644c96c14afd65' })));
    }
    static get style() { return verdocsMenuPanelCss; }
}, [4, "verdocs-menu-panel", {
        "side": [1],
        "overlay": [4],
        "width": [2]
    }, [[4, "click", "handleClick"]]]);
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["verdocs-menu-panel"];
    components.forEach(tagName => { switch (tagName) {
        case "verdocs-menu-panel":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, VerdocsMenuPanel);
            }
            break;
    } });
}

export { VerdocsMenuPanel as V, defineCustomElement as d };
//# sourceMappingURL=p-CXwqfO70.js.map

//# sourceMappingURL=p-CXwqfO70.js.map