import { r as registerInstance, c as createEvent, h, g as getElement } from './index-148a7577.js';
import { r as randomIdGenerator } from './randomIdGenerator.util-56406f2e.js';
import { d as detectClickOutside } from './detectClickOutside.util-72594957.js';
import './detectClosest.util-58a7504f.js';

const UtilDetectClickOutside = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        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: '47d24cdbd95d6fc0319eb35bc2d77a5ce04f015e' });
    }
    get $el() { return getElement(this); }
};

export { UtilDetectClickOutside as digi_util_detect_click_outside };
