{"version":3,"file":"fingerprintBlock.cjs","names":["crypto"],"sources":["../../../src/docReview/fingerprintBlock.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport type { FingerprintedBlock, NormalizedBlock } from './types';\n\nconst computeStringDigest = (text: string): string =>\n  crypto.createHash('sha256').update(text).digest('hex');\n\n/**\n * Compute content and context digests for a normalized block.\n *\n * The context key (digest of the surrounding blocks) lets the planner tell apart\n * two blocks that share the same content but live in different sections.\n *\n * @param block - The block to fingerprint.\n * @param previousBlock - The block immediately before, or `null` at the start.\n * @param nextBlock - The block immediately after, or `null` at the end.\n * @returns The block enriched with its digests.\n */\nexport const fingerprintBlock = (\n  block: NormalizedBlock,\n  previousBlock: NormalizedBlock | null,\n  nextBlock: NormalizedBlock | null\n): FingerprintedBlock => {\n  const semanticDigest = computeStringDigest(block.semanticText);\n  const anchorDigest = computeStringDigest(block.anchorText);\n  const compositeKey = `${semanticDigest}:${anchorDigest}`;\n\n  const previousDigest = computeStringDigest(previousBlock?.semanticText ?? '');\n  const nextDigest = computeStringDigest(nextBlock?.semanticText ?? '');\n  const contextKey = computeStringDigest(`${previousDigest}:${nextDigest}`);\n\n  return {\n    ...block,\n    semanticDigest,\n    anchorDigest,\n    compositeKey,\n    contextKey,\n  };\n};\n"],"mappings":";;;;;;AAGA,MAAM,uBAAuB,SAC3BA,oBAAO,WAAW,QAAQ,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,KAAK;;;;;;;;;;;;AAavD,MAAa,oBACX,OACA,eACA,cACuB;CACvB,MAAM,iBAAiB,oBAAoB,MAAM,YAAY;CAC7D,MAAM,eAAe,oBAAoB,MAAM,UAAU;CACzD,MAAM,eAAe,GAAG,eAAe,GAAG;CAE1C,MAAM,iBAAiB,oBAAoB,eAAe,gBAAgB,EAAE;CAC5E,MAAM,aAAa,oBAAoB,WAAW,gBAAgB,EAAE;CACpE,MAAM,aAAa,oBAAoB,GAAG,eAAe,GAAG,YAAY;CAExE,OAAO;EACL,GAAG;EACH;EACA;EACA;EACA;CACF;AACF"}