import { MatchStyle, MatchRun } from '@superdoc/document-api'; import { OoxmlResolverParams, ParagraphProperties } from '@superdoc/style-engine/ooxml'; import { CapturedRun } from './style-resolver.js'; /** A PM mark as visible on CapturedRun.marks — minimal shape for style extraction. */ type PmMark = CapturedRun['marks'][number]; /** Context passed to `toMatchStyle` when cascade resolution is available. */ export interface CascadeContext { resolverParams: OoxmlResolverParams; paragraphProperties: ParagraphProperties | null; } /** * Returns true when two mark arrays are structurally identical — same marks * in the same order with the same attrs. Uses PM's own `eq` method which * compares type + attrs. */ export declare function marksEqual(a: readonly PmMark[], b: readonly PmMark[]): boolean; /** * Coalesces adjacent CapturedRuns with identical mark-signatures into merged * runs. Drops zero-width runs. Returns runs in offset order. * * Input: raw PM text node runs within a matched block range. * Output: coalesced runs ready for projection to contract MatchRun[]. */ export declare function coalesceRuns(runs: CapturedRun[]): CapturedRun[]; /** * Projects PM marks into a contract MatchStyle with two-layer model. * * - `direct`: tri-state toggle derived from mark presence and attrs. * - `effective`: boolean visual state. For `on`/`off`, deterministic. * For `clear`, resolved via style-engine cascade when `cascadeContext` is * provided, otherwise falls back to conservative `false`. * * Optional fields use runProperties → textStyle precedence (D15). */ export declare function toMatchStyle(marks: readonly PmMark[], cascadeContext?: CascadeContext): MatchStyle; /** * Extracts the OOXML character style definition ID from a run's marks. * Returns undefined if no runProperties mark or no styleId attr. */ export declare function extractRunStyleId(marks: readonly PmMark[]): string | undefined; /** * Normalizes a color value to 6-digit lowercase hex with `#` prefix. * Returns undefined if the value cannot be parsed. * * Accepts: `#rgb`, `#rrggbb`, `rgb(r,g,b)`, CSS named colors. * Uses a fixed internal lookup table for named colors (D15). */ export declare function normalizeHexColor(raw: string): string | undefined; /** * Parses a font size value to points. Handles: * - Numbers (returned as-is if valid) * - Half-point numbers (detected by being >= 2x what's reasonable; divided by 2) * - Strings like "12pt", "24" (strips unit suffix, parses numeric) * * Returns undefined for unparseable, NaN, Infinity, or negative values. * Rounds to 1 decimal place. */ export declare function parseFontSizePt(raw: unknown): number | undefined; /** * Asserts that runs exactly tile their parent block's range. * Throws INTERNAL_ERROR on violation — this indicates a bug in our code. */ export declare function assertRunTilingInvariant(runs: MatchRun[], blockRange: { start: number; end: number; }, blockId: string): void; export {}; //# sourceMappingURL=match-style-helpers.d.ts.map