/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { Bytes, DataWriter, hex } from "@matter/general";
const COMPRESSED_FABRIC_ID_INFO = Bytes.fromString("CompressedFabric");
function GlobalFabricId(value) {
  if (Bytes.isBytes(value)) {
    return Bytes.asBigInt(value);
  }
  return BigInt(value);
}
((GlobalFabricId2) => {
  function strOf(id) {
    return hex.fixed(id, 16);
  }
  GlobalFabricId2.strOf = strOf;
  async function compute(crypto, id, caKey) {
    const saltWriter = new DataWriter();
    saltWriter.writeUInt64(id);
    return GlobalFabricId2(
      await crypto.createHkdfKey(
        Bytes.of(caKey).slice(1),
        saltWriter.toByteArray(),
        COMPRESSED_FABRIC_ID_INFO,
        8
      )
    );
  }
  GlobalFabricId2.compute = compute;
})(GlobalFabricId || (GlobalFabricId = {}));
export {
  GlobalFabricId
};
//# sourceMappingURL=GlobalFabricId.js.map
