/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { Diagnostic } from "@matter/general";
function DataModelPath(id, type) {
  function identity(includeType) {
    if (this.type && includeType) {
      return `${this.type}#${this.id}`;
    }
    return this.id;
  }
  function toString(includeType) {
    if (this.parent) {
      return `${this.parent}.${identity.call(this, includeType)}`;
    }
    return identity.call(this, includeType).toString();
  }
  function toArray() {
    if (this.parent) {
      return [...this.parent.toArray(), this.id];
    }
    return [this.id];
  }
  function asDiagnostic() {
    const result = Array();
    for (const segment of this.toArray()) {
      if (result.length) {
        result.push(".");
      }
      result.push(Diagnostic.strong(segment));
    }
    return Diagnostic.squash(result);
  }
  function at(id2, type2) {
    return {
      parent: this,
      id: id2,
      type: type2,
      at,
      toString,
      toArray,
      get [Diagnostic.value]() {
        return asDiagnostic.apply(this);
      }
    };
  }
  return {
    id,
    type,
    at,
    toString,
    toArray,
    get [Diagnostic.value]() {
      return asDiagnostic.apply(this);
    }
  };
}
((DataModelPath2) => {
  DataModelPath2.none = DataModelPath2("none");
})(DataModelPath || (DataModelPath = {}));
export {
  DataModelPath
};
//# sourceMappingURL=DataModelPath.js.map
