"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 CommandId_exports = {};
__export(CommandId_exports, {
  CommandId: () => CommandId,
  TlvCommandId: () => TlvCommandId
});
module.exports = __toCommonJS(CommandId_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-2025 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
function CommandId(commandId, validate = true) {
  if (!validate) {
    return commandId;
  }
  const { typeSuffix } = import_ManufacturerExtensibleIdentifier.Mei.fromMei(commandId);
  if (typeSuffix >= 0 && typeSuffix <= 255) {
    return commandId;
  }
  throw new import_ValidationError.ValidationOutOfBoundsError(`Invalid command ID: ${commandId}`);
}
((CommandId2) => {
  CommandId2.isValid = (0, import_ValidationError.validatorOf)(CommandId2);
})(CommandId || (CommandId = {}));
const TlvCommandId = new import_TlvWrapper.TlvWrapper(
  import_TlvNumber.TlvUInt32,
  (commandId) => commandId,
  (value) => CommandId(value, false)
  // No automatic validation on decode
);
//# sourceMappingURL=CommandId.js.map
