import { p as proxyCustomElement, H, c as createEvent, h } from './p-a53686b3.js';
import { r as randomIdGenerator } from './p-ffe5c0e8.js';
import { d as detectClickOutside } from './p-430607cb.js';

const UtilDetectClickOutside = /*@__PURE__*/ proxyCustomElement(class UtilDetectClickOutside extends H {
    constructor() {
        super();
        this.__registerHost();
        this.afOnClickOutside = createEvent(this, "afOnClickOutside", 7);
        this.afOnClickInside = createEvent(this, "afOnClickInside", 7);
        this.afDataIdentifier = randomIdGenerator('data-digi-util-detect-click-outside');
    }
    componentWillLoad() {
        this.$el.setAttribute(this.afDataIdentifier, '');
    }
    clickHandler(e) {
        const target = e.target;
        const selector = `[${this.afDataIdentifier}]`;
        if (detectClickOutside(target, selector)) {
            this.afOnClickOutside.emit(e);
        }
        else {
            this.afOnClickInside.emit(e);
        }
    }
    render() {
        return h("slot", { key: 'ce56a7fae9872b5f655d72c65a8926b19e1bbdf1' });
    }
    get $el() { return this; }
}, [6, "digi-util-detect-click-outside", {
        "afDataIdentifier": [1, "af-data-identifier"]
    }, [[8, "click", "clickHandler"]]]);
function defineCustomElement$1() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["digi-util-detect-click-outside"];
    components.forEach(tagName => { switch (tagName) {
        case "digi-util-detect-click-outside":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, UtilDetectClickOutside);
            }
            break;
    } });
}

const DigiUtilDetectClickOutside = UtilDetectClickOutside;
const defineCustomElement = defineCustomElement$1;

export { DigiUtilDetectClickOutside, defineCustomElement };
