"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ElementInstrumenter = void 0;
const plugins = __importStar(require("./domtools.plugins"));
class ElementInstrumenter {
    constructor() {
        this.connectedElements = new plugins.lik.ObjectMap();
    }
    instrumentElement(elementArg) {
        const addToConnectedElementsFunc = (eventArg) => {
            this.connectedElements.add(elementArg);
        };
        const removeFromConnectedElementsFunc = eventArg => {
            this.connectedElements.remove(elementArg);
            elementArg.removeEventListener('domtools-connected', addToConnectedElementsFunc);
            elementArg.removeEventListener('domtools-disconnected', removeFromConnectedElementsFunc);
        };
        elementArg.addEventListener('domtools-connected', addToConnectedElementsFunc);
        elementArg.addEventListener('domtools-disconnected', removeFromConnectedElementsFunc);
        if (elementArg.parentElement) {
            this.connectedElements.add(elementArg);
        }
    }
    async forEachelement(eachFuncArg) {
        for (const elementArg of this.connectedElements.getArray()) {
            await eachFuncArg(elementArg);
        }
    }
}
exports.ElementInstrumenter = ElementInstrumenter;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZG9tdG9vbHMuY2xhc3Nlcy5lbGVtZW50aW5zdHJ1bWVudGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvZG9tdG9vbHMuY2xhc3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