"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 ScopeModel_exports = {};
__export(ScopeModel_exports, {
  ScopeModel: () => ScopeModel
});
module.exports = __toCommonJS(ScopeModel_exports);
var import_errors = require("#common/errors.js");
var import_ModelTraversal = require("#logic/ModelTraversal.js");
var import_Scope = require("#logic/Scope.js");
var import_Model = require("./Model.js");
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
class ScopeModel extends import_Model.Model {
  #operationalScope;
  isScope = true;
  /**
   * Obtain the {@link Scope} for this model.
   */
  get scope() {
    if (this.#operationalScope !== void 0) {
      return this.#operationalScope;
    }
    return (0, import_Scope.Scope)(this);
  }
  finalize() {
    if (!this.#operationalScope) {
      this.#operationalScope = (0, import_Scope.Scope)(this);
    }
    super.finalize();
    return this;
  }
  static is(model) {
    return !!model.isScope;
  }
  static of(model) {
    if (model.isScope) {
      return model;
    }
    const scope = new import_ModelTraversal.ModelTraversal().findScope(model);
    if (scope === void 0) {
      throw new import_errors.SchemaImplementationError(model, `No parent scope`);
    }
    return scope;
  }
}
//# sourceMappingURL=ScopeModel.js.map
