/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { camelize } from "@matter/general";
import { ApiResource } from "../ApiResource.js";
import { BehaviorResource } from "./BehaviorResource.js";
import { EndpointContainerResource } from "./EndpointContainerResource.js";
class EndpointResource extends ApiResource {
  agent;
  supervisor;
  constructor(agent, parent) {
    super(parent);
    this.agent = agent;
  }
  get valueKind() {
    return "endpoint";
  }
  get id() {
    return this.agent.endpoint.id;
  }
  get dataModelPath() {
    return this.agent.endpoint.path;
  }
  get value() {
    return this.agent.endpoint.state;
  }
  async childFor(name) {
    if (name === "parts") {
      return new EndpointContainerResource(
        this,
        "parts",
        () => this.agent.endpoint.parts.map((part) => part.id),
        (name2) => {
          const part = this.agent.endpoint.parts.get(name2);
          if (part) {
            return new EndpointResource(part.agentFor(this.agent.context), this);
          }
        }
      );
    }
    name = camelize(name);
    const { supported } = this.agent.endpoint.behaviors;
    if (name in supported) {
      const type = supported[name];
      const behavior = this.agent.get(type);
      if (behavior.type.schema === void 0) {
        return;
      }
      return new BehaviorResource(behavior, this);
    }
  }
}
export {
  EndpointResource
};
//# sourceMappingURL=EndpointResource.js.map
