import { r as registerInstance, d as createEvent, c as getElement } from './core-1db051ba.js';
import { f as debounceEvent } from './utils-3aef1637.js';

const Observer = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.observer = new MutationObserver(this.onChange.bind(this));
        /**
         * Watch attributes
         */
        this.incattrs = true;
        /**
         * How long to delay the event
         */
        this.debounce = 0;
        this.anjContentChange = createEvent(this, "anjContentChange", 7);
    }
    connectedCallback() {
        if (this.debounce) {
            this.anjContentChange = debounceEvent(this.anjContentChange, this.debounce);
        }
        this.observer.observe(this.element, { attributes: this.incattrs, childList: true, subtree: true });
    }
    disconnectedCallback() {
        this.observer.disconnect();
    }
    onChange(mutations) {
        this.anjContentChange.emit(mutations);
    }
    get element() { return getElement(this); }
};

export { Observer as anj_observer };
