import { identifySegmentsToReview, mergeReviewedSegments } from "./rebuildDocument.mjs";
import { alignEnglishAndFrenchBlocks } from "./alignBlocks.mjs";
import { fingerprintBlock } from "./fingerprintBlock.mjs";
import { mapChangedLinesToBlocks } from "./mapChangedLinesToBlocks.mjs";
import { normalizeBlock } from "./normalizeBlock.mjs";
import { planAlignmentActions } from "./planActions.mjs";
import { segmentDocument } from "./segmentDocument.mjs";

//#region ../@intlayer/cli/dist/esm/translation-alignment/pipeline.mjs
const buildAlignmentPlan = ({ englishText, frenchText, changedLines, similarityOptions }) => {
	const englishBlocksRaw = segmentDocument(englishText);
	const frenchBlocksRaw = segmentDocument(frenchText);
	const englishNormalized = englishBlocksRaw.map(normalizeBlock);
	const frenchNormalized = frenchBlocksRaw.map(normalizeBlock);
	const englishBlocks = englishNormalized.map((block, index, array) => fingerprintBlock(block, array[index - 1] ?? null, array[index + 1] ?? null));
	const frenchBlocks = frenchNormalized.map((block, index, array) => fingerprintBlock(block, array[index - 1] ?? null, array[index + 1] ?? null));
	const plan = planAlignmentActions(alignEnglishAndFrenchBlocks(englishBlocks, frenchBlocks), mapChangedLinesToBlocks(englishBlocks, Array.isArray(changedLines) ? changedLines : []), {
		minimumMatchForReuse: similarityOptions?.minimumMatchForReuse ?? .9,
		minimumMatchForNearDuplicate: similarityOptions?.minimumMatchForNearDuplicate ?? .8
	});
	const { segmentsToReview } = identifySegmentsToReview({
		englishBlocks,
		frenchBlocks,
		plan
	});
	return {
		englishBlocks,
		frenchBlocks,
		plan,
		segmentsToReview
	};
};

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