import type { Box } from "../../interface.js";
import type { RecognitionResult } from "../base-recognition.service.js";
import type { CanvasOps, CoreCanvas } from "../platform.js";
/**
 * Groups detected boxes into lines based on vertical proximity.
 *
 * Boxes within 50% of the average line height are placed on the same line,
 * then each line is sorted left-to-right.
 */
export declare function groupBoxesIntoLines(boxes: Array<{
    box: Box;
    index: number;
}>): Array<Array<{
    box: Box;
    index: number;
}>>;
/**
 * Merges multiple same-line boxes into a single stitched canvas.
 *
 * All crops are stretched to a common height so character sizes are uniform.
 */
export declare function mergeLineCrop(sourceCanvas: CoreCanvas, lineBoxes: Array<{
    box: Box;
    index: number;
}>, createCanvas: (width: number, height: number) => CoreCanvas, canvasOps: CanvasOps): {
    mergedCanvas: CoreCanvas;
    mergedBox: Box;
};
/**
 * Splits recognized text proportionally across stitched line crops by pixel width.
 *
 * Characters are assigned proportionally to each crop's share of total width.
 */
export declare function splitBatchTextByWidths(text: string, cropWidths: number[]): string[];
/**
 * Packs sized items into width-bounded batches (first-fit-decreasing).
 *
 * A batch accepts an item while its running width plus a per-item separator gap
 * stays within `targetWidth`; otherwise a new batch is opened.
 */
export declare function packIntoBatches<T>(items: T[], widthOf: (item: T) => number, targetWidth: number, separatorGap: number): T[][];
/**
 * Distributes one recognized line's text across its source boxes.
 *
 * A single box takes the whole text; multiple boxes split the words by each
 * box's share of the total width.
 */
export declare function distributeLineText(boxes: Array<{
    box: Box;
    index: number;
}>, lineText: string, confidence: number): RecognitionResult[];
