'use strict';

var index = require('./index-DSiE2De_.js');

const DgaMenu = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.anchorEl = null;
        this.open = false;
        this.onClose = () => { };
        // Method to detect outside click
        this.handleClickOutside = (event) => {
            if (this.anchorEl && !this.anchorEl.contains(event.target)) {
                this.onClose();
            }
        };
    }
    componentDidLoad() {
        // Add event listener to handle clicks outside the menu
        document.addEventListener('click', this.handleClickOutside);
    }
    disconnectedCallback() {
        // Cleanup event listener when the component is destroyed
        document.removeEventListener('click', this.handleClickOutside);
    }
    getMenuStyle() {
        var _a;
        const rect = (_a = this.anchorEl) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
        return {
            position: 'absolute',
            top: `${(rect === null || rect === void 0 ? void 0 : rect.bottom) + window.scrollY}px`,
            left: `${(rect === null || rect === void 0 ? void 0 : rect.left) + window.scrollX}px`,
            zIndex: '1000',
        };
    }
    render() {
        return (index.h(index.Fragment, { key: 'cba56b25063d535cf3660806f3b80822330c0c06' }, this.open && this.anchorEl && (index.h("ul", { key: '1368cf622296d6f04bcaeb75058e278936e15ef4', class: "menu", style: this.getMenuStyle() }, index.h("slot", { key: '56c1ff862b1ff0cac2a7a6bc08235342ed956a00' })))));
    }
};

exports.dga_menu = DgaMenu;
