/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { SchemaImplementationError } from "#common/errors.js";
import { ModelTraversal } from "#logic/ModelTraversal.js";
import { Scope } from "#logic/Scope.js";
import { Model } from "./Model.js";
class ScopeModel extends Model {
  #operationalScope;
  isScope = true;
  /**
   * Obtain the {@link Scope} for this model.
   */
  get scope() {
    if (this.#operationalScope !== void 0) {
      return this.#operationalScope;
    }
    return Scope(this);
  }
  finalize() {
    if (!this.#operationalScope) {
      this.#operationalScope = Scope(this);
    }
    super.finalize();
    return this;
  }
  static is(model) {
    return !!model.isScope;
  }
  static of(model) {
    if (model.isScope) {
      return model;
    }
    const scope = new ModelTraversal().findScope(model);
    if (scope === void 0) {
      throw new SchemaImplementationError(model, `No parent scope`);
    }
    return scope;
  }
}
export {
  ScopeModel
};
//# sourceMappingURL=ScopeModel.js.map
