"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 Storage_exports = {};
__export(Storage_exports, {
  CloneableStorage: () => CloneableStorage,
  Storage: () => Storage,
  StorageError: () => StorageError
});
module.exports = __toCommonJS(Storage_exports);
var import_MatterError = require("../MatterError.js");
var import_Promises = require("../util/Promises.js");
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
class StorageError extends import_MatterError.MatterError {
}
class Storage {
  /**
   * Checks if a key exists in the storage for the given contexts.
   * Important Note: This default implementation just reads the value for the key and checks if it is undefined.
   * Please implement this method in your storage implementation if you want to optimize it.
   */
  has(contexts, key) {
    const value = this.get(contexts, key);
    if (import_Promises.MaybePromise.is(value)) {
      return import_Promises.MaybePromise.then(value, (v) => v !== void 0);
    }
    return value !== void 0;
  }
}
var CloneableStorage;
((CloneableStorage2) => {
  function is(storage) {
    return "clone" in storage && typeof storage.clone === "function";
  }
  CloneableStorage2.is = is;
  function assert(storage) {
    if (!is(storage)) {
      throw new import_MatterError.ImplementationError("Storage does not support required snapshotting function");
    }
  }
  CloneableStorage2.assert = assert;
})(CloneableStorage || (CloneableStorage = {}));
//# sourceMappingURL=Storage.js.map
