"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 ApiResource_exports = {};
__export(ApiResource_exports, {
  ApiResource: () => ApiResource
});
module.exports = __toCommonJS(ApiResource_exports);
var import_RootSupervisor = require("#behavior/supervision/RootSupervisor.js");
var import_general = require("@matter/general");
var import_model = require("@matter/model");
var import_Envelope = require("./Envelope.js");
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
class ApiResource {
  /**
   * The item's owner, if any.
   */
  parent;
  /**
   * Indicates whether this is an RPC endpoint.
   */
  isInvocable = false;
  /**
   * Indicates whether this is an event endpoint.
   */
  isSubscribable = false;
  constructor(parent) {
    this.parent = parent;
  }
  /**
   * Retrieve the body of the item.
   */
  read() {
    if (this.value === void 0) {
      return;
    }
    return new import_Envelope.Envelope({
      supervisor: this.supervisor ?? import_RootSupervisor.RootSupervisor.for(import_model.any),
      js: this.value
    });
  }
  /**
   * Create or replace item.
   */
  write(_request) {
    throw new import_general.NotImplementedError();
  }
  /**
   * Update item using matter.js patch semantics.
   */
  patch(_request) {
    throw new import_general.NotImplementedError();
  }
  /**
   * Add a child item of this item.
   */
  add(_request) {
    throw new import_general.NotImplementedError();
  }
  /**
   * Remove this item.
   */
  delete() {
    throw new import_general.NotImplementedError();
  }
  /**
   * The {@link Schema} for this resource subtree.
   */
  get schema() {
    return this.supervisor?.schema;
  }
  /**
   * Obtain the appropriate {@link ValueSupervisor} for a {@link Schema} in this subtree.
   */
  supervisorFor(schema) {
    return this.rootSupervisor?.get(schema) ?? import_RootSupervisor.RootSupervisor.for(schema);
  }
  /**
   * The {@link RootSupervisor} for this resource subtree.
   */
  get rootSupervisor() {
    return this.parent?.rootSupervisor;
  }
  /**
   * Execute a procedure.
   */
  async invoke(_request) {
    throw new import_general.NotImplementedError();
  }
  /**
   * Subscribe to events.
   */
  // oxlint-disable-next-line require-yield
  async *subscribe(_abort, _request) {
    throw new import_general.NotImplementedError();
  }
  /**
   * Retrieve a child with the specified ID.
   */
  async childFor(_id) {
    return void 0;
  }
}
//# sourceMappingURL=ApiResource.js.map
