"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var Map_exports = {};
__export(Map_exports, {
  BasicMap: () => BasicMap
});
module.exports = __toCommonJS(Map_exports);
var import_Observable = require("#util/Observable.js");
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
class BasicMap extends Map {
  #added;
  #deleted;
  #changed;
  set(key, value) {
    const existing = this.get(key);
    if (existing !== void 0) {
      if (existing === value) {
        return this;
      }
      this.#changed?.emit(key, value, existing);
    } else {
      this.#added?.emit(key, value);
    }
    return super.set(key, value);
  }
  delete(key) {
    const existing = this.get(key);
    if (existing !== void 0) {
      this.#deleted?.emit(key, existing);
    }
    return super.delete(key);
  }
  get added() {
    if (this.#added === void 0) {
      this.#added = (0, import_Observable.Observable)();
    }
    return this.#added;
  }
  get deleted() {
    if (this.#deleted === void 0) {
      this.#deleted = (0, import_Observable.Observable)();
    }
    return this.#deleted;
  }
  get changed() {
    if (this.#changed === void 0) {
      this.#changed = (0, import_Observable.Observable)();
    }
    return this.#changed;
  }
}
//# sourceMappingURL=Map.js.map
