"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 ManufacturerExtensibleIdentifier_exports = {};
__export(ManufacturerExtensibleIdentifier_exports, {
  Mei: () => Mei
});
module.exports = __toCommonJS(ManufacturerExtensibleIdentifier_exports);
var import_ValidationError = require("../common/ValidationError.js");
var import_VendorId = require("./VendorId.js");
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
var Mei;
((Mei2) => {
  Mei2.asMei = (vendorPrefix, typeSuffix) => {
    if (vendorPrefix < 0 || vendorPrefix > 65524) {
      throw new import_ValidationError.ValidationOutOfBoundsError(`Invalid vendor prefix for MEI: ${vendorPrefix}`);
    }
    if (typeSuffix < 0 || typeSuffix > 65534) {
      throw new import_ValidationError.ValidationOutOfBoundsError(`Invalid type suffix for MEI: ${typeSuffix}`);
    }
    return (vendorPrefix << 16) + typeSuffix >>> 0;
  };
  Mei2.fromMei = (mei) => {
    const vendorPrefix = mei >>> 16;
    if (vendorPrefix > 65524) {
      throw new import_ValidationError.ValidationOutOfBoundsError(`Invalid vendor prefix for MEI: ${mei}`);
    }
    const typeSuffix = mei & 65535;
    if (typeSuffix > 65534) {
      throw new import_ValidationError.ValidationOutOfBoundsError(`Invalid type suffix for MEI: ${mei}`);
    }
    return {
      vendorPrefix: (0, import_VendorId.VendorId)(vendorPrefix),
      typeSuffix: mei & 65535
    };
  };
  Mei2.hasCustomMeiPrefix = (mei, vendorPrefix) => {
    if (vendorPrefix === void 0) {
      return mei > 65534;
    }
    return mei >>> 16 === vendorPrefix;
  };
})(Mei || (Mei = {}));
//# sourceMappingURL=ManufacturerExtensibleIdentifier.js.map
