"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 FieldModel_exports = {};
__export(FieldModel_exports, {
  FieldModel: () => FieldModel
});
module.exports = __toCommonJS(FieldModel_exports);
var import_common = require("../common/index.js");
var import_elements = require("../elements/index.js");
var import_PropertyModel = require("./PropertyModel.js");
var import_ValueModel = require("./ValueModel.js");
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
class FieldModel extends import_PropertyModel.PropertyModel {
  tag = import_elements.FieldElement.Tag;
  title;
  get fabricSensitive() {
    return this.effectiveAccess.fabricSensitive;
  }
  /**
   * Fields may omit their ID.  In this case we use their index within the parent as the ID.
   */
  get effectiveId() {
    if (this.id !== void 0) {
      return this.id;
    }
    if (this.parent instanceof import_ValueModel.ValueModel) {
      const index = this.parent.children.indexOf(this);
      if (index !== -1) {
        return index;
      }
    }
  }
  /**
   * The key for bitmap fields is actually the constraint which defines the bit range.  All other datatypes use the
   * default key.
   */
  get key() {
    if (this.parent instanceof import_ValueModel.ValueModel && this.parent.effectiveMetatype === import_common.Metatype.bitmap) {
      return this.constraint.toString();
    }
    return super.key;
  }
  constructor(definition, ...children) {
    super(definition, ...children);
    this.title = definition.title;
  }
  toElement(omitResources = false, extra) {
    return super.toElement(omitResources, {
      title: this.title,
      ...extra
    });
  }
  static Tag = import_elements.FieldElement.Tag;
}
FieldModel.register();
//# sourceMappingURL=FieldModel.js.map
