// src/core/lib/cid.ts
async function computeCID(content) {
  const { MemoryBlockstore } = await import("blockstore-core/memory");
  const { importer } = await import("ipfs-unixfs-importer");
  let blockstore = new MemoryBlockstore();
  try {
    function* singleFile() {
      yield { path: "file", content };
    }
    let fileCid = null;
    for await (const entry of importer(singleFile(), blockstore, {
      cidVersion: 0,
      rawLeaves: false,
      wrapWithDirectory: false
    })) {
      fileCid = entry.cid.toString();
    }
    if (!fileCid) {
      throw new Error("Failed to compute CID");
    }
    return fileCid;
  } finally {
    blockstore = null;
  }
}
async function computeJsonCID(obj) {
  const json = JSON.stringify(obj);
  const encoder = new TextEncoder();
  return computeCID(encoder.encode(json));
}

export {
  computeCID,
  computeJsonCID
};
//# sourceMappingURL=chunk-VU34HOXM.mjs.map