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

const UtilDetectFocusOutside = /*@__PURE__*/ proxyCustomElement(class UtilDetectFocusOutside extends H {
    constructor() {
        super();
        this.__registerHost();
        this.afOnFocusOutside = createEvent(this, "afOnFocusOutside", 7);
        this.afOnFocusInside = createEvent(this, "afOnFocusInside", 7);
        this.afDataIdentifier = randomIdGenerator('data-digi-util-detect-focus-outside');
    }
    componentWillLoad() {
        this.$el.setAttribute(this.afDataIdentifier, '');
    }
    focusinHandler(e) {
        const target = e.target;
        const selector = `[${this.afDataIdentifier}]`;
        if (detectFocusOutside(target, selector)) {
            this.afOnFocusOutside.emit(e);
        }
        else {
            this.afOnFocusInside.emit(e);
        }
    }
    render() {
        return h("slot", { key: '97e05fb2f9c26c26d7705d319a3b404021329bc1' });
    }
    get $el() { return this; }
}, [6, "digi-util-detect-focus-outside", {
        "afDataIdentifier": [1, "af-data-identifier"]
    }, [[4, "focusin", "focusinHandler"]]]);
function defineCustomElement$1() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["digi-util-detect-focus-outside"];
    components.forEach(tagName => { switch (tagName) {
        case "digi-util-detect-focus-outside":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, UtilDetectFocusOutside);
            }
            break;
    } });
}

const DigiUtilDetectFocusOutside = UtilDetectFocusOutside;
const defineCustomElement = defineCustomElement$1;

export { DigiUtilDetectFocusOutside, defineCustomElement };
