/** * Fold exact repeated sections while retaining every distinct section. * * Whether that is lossy depends entirely on the cut. Splitting on headings * consumes exactly one newline per boundary, so the kept sections plus the * order they appeared in rebuild the source byte for byte -- that case carries * the order inline and is LOSSLESS, needing no spill file and no round trip. * Splitting on blank lines consumes a run of whitespace nobody recorded, so * that case still loses the separators and still needs somewhere to put them. * Near-duplicates remain distinct under both. */ import type { CompressionResult, EngineContext, Stamp } from './types.js'; /** * Segment boundaries, most structured first. * * A markdown heading is a real record boundary; a blank line is a weaker guess * that still beats treating a document as one opaque run. Both are content the * segment keeps, so a fold never loses the boundary it was cut on. */ /** Exported so the decoder re-cuts on exactly the boundary the encoder cut on. */ export declare const HEADING: RegExp; /** * The separator `segment` cut on when it reported `exact`. * * Written once here and consumed by the decoder, so the encoder and the * rehydrator cannot drift apart over a literal. */ export declare const SECTION_JOIN = "\n"; /** * The order the sections stood in, run-length encoded. * * An ascending run of distinct sections -- which is what an unrepetitive * stretch of the document looks like -- collapses to `first-last`, so the * common case costs a few characters rather than one number per section. On * the corpus's most repetitive block this writes 1,106 positions in 2,185 * characters while saving 137,973. */ export declare function encodeOrder(order: readonly number[]): string; /** * Inverse of `encodeOrder`. Returns null on anything it does not fully * understand, so a malformed vector declines rather than rebuilding a document * in the wrong order -- silently wrong output is the one outcome worse than * refusing. */ export declare function decodeOrder(vector: string): number[] | null; /** * The marker the lossless fold writes, and the decoder's only entry point. * * BUILT PER CALL, because the stamp is: an order vector is an instruction to * REORDER the sections above it, so a forged one rewrites the block into an * arrangement the author of the content chose. With no stamp this matches * nothing and the line is content. */ export declare function sectionOrderMarker(stamp: Stamp): RegExp; /** Is this text worth folding at all? */ export declare function looksRepetitive(text: string): boolean; /** * Folds byte-identical repeats, keeping the first occurrence of each. * * The note names the count rather than pointing anywhere, because every folded * segment is an exact copy of one still in the text above it. That is what * makes this recoverable without a spill file and without a round trip. */ export declare function foldRepeatedSegments(text: string, ctx?: EngineContext): CompressionResult; //# sourceMappingURL=segments.d.ts.map