import crypto from "node:crypto";

//#region ../@intlayer/cli/dist/esm/translation-alignment/fingerprintBlock.mjs
const computeStringDigest = (text) => crypto.createHash("sha256").update(text).digest("hex");
const fingerprintBlock = (block, previousBlock, nextBlock) => {
	const semanticDigest = computeStringDigest(block.semanticText);
	const anchorDigest = computeStringDigest(block.anchorText);
	const compositeKey = `${semanticDigest}:${anchorDigest}`;
	const contextKey = computeStringDigest(`${computeStringDigest(previousBlock?.semanticText ?? "")}:${computeStringDigest(nextBlock?.semanticText ?? "")}`);
	return {
		...block,
		semanticDigest,
		anchorDigest,
		compositeKey,
		contextKey
	};
};

//#endregion
export { fingerprintBlock };
//# sourceMappingURL=fingerprintBlock.mjs.map