"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 TestFabric_exports = {};
__export(TestFabric_exports, {
  TestFabric: () => TestFabric
});
module.exports = __toCommonJS(TestFabric_exports);
var import_CertificateAuthority = require("#certificate/CertificateAuthority.js");
var import_general = require("@matter/general");
var import_types = require("@matter/types");
var import_FabricAuthority = require("./FabricAuthority.js");
var import_FabricManager = require("./FabricManager.js");
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
async function TestFabric(options = {}) {
  const authority = await TestFabric.Authority(options);
  const { index } = options;
  return authority.createFabric({
    adminFabricLabel: `mock-fabric-${index}`,
    adminVendorId: (0, import_types.VendorId)(65521),
    adminFabricIndex: index !== void 0 ? (0, import_types.FabricIndex)(index) : void 0,
    adminFabricId: (0, import_types.FabricId)(1)
  });
}
((TestFabric2) => {
  async function Authority(options = {}) {
    let { fabrics } = options;
    if (options.index === void 0) {
      if (fabrics) {
        options.index = fabrics.allocateFabricIndex();
      } else {
        options.index = 1;
      }
    }
    if (options.index < 1 || options.index > 254) {
      throw new import_general.ImplementationError("Test fabric indexes must be in the range 1-254");
    }
    if (!fabrics) {
      fabrics = new import_FabricManager.FabricManager((0, import_general.MockCrypto)(options.index));
    }
    return new import_FabricAuthority.FabricAuthority({
      ca: await import_CertificateAuthority.CertificateAuthority.create(fabrics.crypto),
      fabrics
    });
  }
  TestFabric2.Authority = Authority;
})(TestFabric || (TestFabric = {}));
//# sourceMappingURL=TestFabric.js.map
