import type { Segment, SegmentKind } from "./core/types"; /** Below this, a run of replaced characters still has a survivor near enough to move from. */ export declare const GROUP_MIN = 6; export type Align = "left" | "center" | "right"; export type Point = { x: number; y: number; }; export type Phase = "initial" | "persist" | "enter" | "exit"; export interface GlyphPlan { id: string; string: string; kind?: SegmentKind; width: number; /** Resting position: the layout slot for a live glyph, the last slot it held for an exiting one. */ x: number; y: number; phase: Phase; /** Live glyphs: where a glyph that mounts this frame starts. Ignored once mounted. */ from?: Point; /** Exiting glyphs: where it drifts while it leaves, following its nearest survivor. */ to?: Point; /** Centre of the run this glyph enters or leaves with, when it goes as part of one. */ group?: Point; /** Exiting glyphs: the frame the exit started in, so a stale removal can't clip a later one. */ exitFrame?: number; } export interface FramePlan { frame: number; glyphs: GlyphPlan[]; width: number; height: number; lineHeight: number; } type Placed = { id: string; string: string; kind?: SegmentKind; width: number; x: number; y: number; }; export declare function isWhitespace(value: string): boolean; /** * Places segments on lines. Lines break at every newline in the value and, when * `wrapWidth` is given, before any word that would run past it. Spaces stay at the * end of the line they ended and are left out of its width, so wrapped lines align * cleanly. A single word wider than `wrapWidth` keeps its own line and overflows. */ export declare function layoutSegments(segments: Segment[], measure: (value: string) => number, lineHeight: number, align?: Align, wrapWidth?: number): { placed: Placed[]; width: number; height: number; }; /** Nearest persisting neighbour by ID. Ported from torph's flip.ts. */ export declare function findNearestAnchor(targetIndex: number, ids: string[], persistentIds: Set, direction?: "backward-first" | "forward-first"): string | null; /** * Maximal stretches of `members` adjacent in `all`, at least GROUP_MIN long. A run * broken by a survivor is no replacement — that survivor is right there to move from. */ export declare function replacedRuns(all: T[], members: Set): T[][]; export interface PlanInput { /** The committed plan this frame morphs from, or null for a first render. */ prev: FramePlan | null; segments: Segment[]; /** Old word IDs the diff cut into per-character segments. */ splits: Map; measure: (value: string) => number; lineHeight: number; align?: Align; /** Break lines at spaces to stay within this width. */ wrapWidth?: number; } export declare function planFrame(input: PlanInput): FramePlan; /** Every distinct string a frame needs a width for, split characters included. */ export declare function requiredStrings(segments: Segment[], splits: Map): Set; export {};