"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 FieldId_exports = {};
__export(FieldId_exports, {
  FieldId: () => FieldId,
  TlvFieldId: () => TlvFieldId
});
module.exports = __toCommonJS(FieldId_exports);
var import_ValidationError = require("../common/ValidationError.js");
var import_TlvNumber = require("../tlv/TlvNumber.js");
var import_TlvWrapper = require("../tlv/TlvWrapper.js");
var import_ManufacturerExtensibleIdentifier = require("./ManufacturerExtensibleIdentifier.js");
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
function FieldId(fieldId, validate = true) {
  if (!validate) {
    return fieldId;
  }
  if (fieldId >= 224 && fieldId <= 254) {
    return fieldId;
  }
  const { typeSuffix } = import_ManufacturerExtensibleIdentifier.Mei.fromMei(fieldId);
  if (typeSuffix >= 0 && typeSuffix <= 223) {
    return fieldId;
  }
  throw new import_ValidationError.ValidationOutOfBoundsError(`Invalid field ID: ${fieldId}`);
}
((FieldId2) => {
  FieldId2.isGlobal = (fieldId) => {
    return fieldId >= 224 && fieldId <= 254;
  };
  FieldId2.isValid = (0, import_ValidationError.validatorOf)(FieldId2);
})(FieldId || (FieldId = {}));
const TlvFieldId = new import_TlvWrapper.TlvWrapper(
  import_TlvNumber.TlvUInt32,
  (fieldId) => fieldId,
  (value) => FieldId(value, false)
  // No automatic validation on decode
);
//# sourceMappingURL=FieldId.js.map
