// SPDX-License-Identifier: Apache-2.0
export class MutableFacadeMap {
    facadeObjectConstructor;
    encapsulatedObjectConstructor;
    encapsulatedMap;
    facadeMap;
    constructor(facadeObjectConstructor, encapsulatedObjectConstructor, encapsulatedMap) {
        this.facadeObjectConstructor = facadeObjectConstructor;
        this.encapsulatedObjectConstructor = encapsulatedObjectConstructor;
        this.encapsulatedMap = encapsulatedMap;
        this.facadeMap = new Map();
        for (const [key, encapsulatedObject] of encapsulatedMap.entries()) {
            const facadeObject = new this.facadeObjectConstructor(encapsulatedObject);
            this.facadeMap.set(key, facadeObject);
        }
    }
    addNew(key) {
        const encapsulatedObject = new this.encapsulatedObjectConstructor();
        const facadeObject = new this.facadeObjectConstructor(encapsulatedObject);
        this.facadeMap.set(key, facadeObject);
        this.encapsulatedMap.set(key, encapsulatedObject);
        return facadeObject;
    }
    get(key) {
        return this.facadeMap.get(key);
    }
    set(key, value) {
        const encapsulatedObject = value.encapsulatedObject;
        this.facadeMap.set(key, value);
        this.encapsulatedMap.set(key, encapsulatedObject);
    }
    has(key) {
        return this.facadeMap.has(key);
    }
    forEach(callback) {
        for (const [key, value] of this.facadeMap.entries()) {
            callback(value, key, this.facadeMap);
        }
    }
    entries() {
        return this.facadeMap.entries();
    }
    keys() {
        return this.facadeMap.keys();
    }
    values() {
        return this.facadeMap.values();
    }
    delete(key) {
        const removed = this.facadeMap.delete(key);
        this.encapsulatedMap.delete(key);
        return removed;
    }
    clear() {
        this.facadeMap.clear();
        this.encapsulatedMap.clear();
    }
    get size() {
        return this.facadeMap.size;
    }
    *[Symbol.iterator]() {
        for (const [key, value] of this.facadeMap.entries()) {
            yield [key, value];
        }
    }
    [Symbol.toStringTag]() {
        return 'MutableFacadeMap';
    }
}
//# sourceMappingURL=mutable-facade-map.js.map