/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { ValidationOutOfBoundsError, validatorOf } from "../common/ValidationError.js";
import { TlvUInt32 } from "../tlv/TlvNumber.js";
import { TlvWrapper } from "../tlv/TlvWrapper.js";
import { Mei } from "./ManufacturerExtensibleIdentifier.js";
function AttributeId(attributeId, validate = true) {
  if (!validate) {
    return attributeId;
  }
  if (attributeId >= 61440 && attributeId <= 65534) {
    return attributeId;
  }
  const { typeSuffix } = Mei.fromMei(attributeId);
  if (typeSuffix >= 0 && typeSuffix <= 20479) {
    return attributeId;
  }
  throw new ValidationOutOfBoundsError(`Invalid attribute ID: ${attributeId}`);
}
((AttributeId2) => {
  AttributeId2.isGlobal = (attributeId) => {
    return attributeId >= 61440 && attributeId <= 65534;
  };
  AttributeId2.isValid = validatorOf(AttributeId2);
})(AttributeId || (AttributeId = {}));
const TlvAttributeId = new TlvWrapper(
  TlvUInt32,
  (attributeId) => attributeId,
  (value) => AttributeId(value, false)
  // No automatic validation on decode
);
export {
  AttributeId,
  TlvAttributeId
};
//# sourceMappingURL=AttributeId.js.map
