/**
 * @license
 * Copyright 2022-2025 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { Metatype } from "../common/index.js";
import { FieldElement } from "../elements/index.js";
import { Model } from "./Model.js";
import { PropertyModel } from "./PropertyModel.js";
import { ValueModel } from "./ValueModel.js";
class FieldModel extends PropertyModel {
  tag = FieldElement.Tag;
  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 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 ValueModel && this.parent.effectiveMetatype === Metatype.bitmap) {
      return this.constraint.toString();
    }
    return super.key;
  }
  static {
    Model.types[FieldElement.Tag] = this;
  }
}
export {
  FieldModel
};
//# sourceMappingURL=FieldModel.js.map
