import { default as default_2 } from 'react'; import { RefObject } from 'react'; /** * Applies the settle page-load animation to an element. * * The algorithm runs five passes: * 1. Reset — restore the element to the original HTML snapshot * 2. Content collection — gather text nodes and atomic elements (img, svg, etc.) * 3. Line grouping — read BCR.top for each word span to detect visual lines * 4. Line span assembly — wrap each line's words in a letter-spacing span with a random offset * 5. Transition trigger — after one rAF, set letter-spacing to the target to trigger CSS transition * * @param element - The live DOM element to animate (must be rendered and visible) * @param originalHTML - HTML snapshot taken before the first applySettle call * @param options - SettleOptions (merged with defaults) */ export declare function applySettle(element: HTMLElement, originalHTML: string, options?: SettleOptions): void; /** * Returns the innerHTML of an element with all settle-injected spans removed, * unwrapping their children in place. Idempotent and safe for complex markup. * * @param el - Element that may contain settle markup */ export declare function getCleanHTML(el: HTMLElement): string; /** * Removes settle markup and restores the element to its original HTML. * * @param element - The element that was previously animated * @param originalHTML - The snapshot passed to the original applySettle call */ export declare function removeSettle(element: HTMLElement, originalHTML: string): void; /** * Resets the element to its original HTML and re-runs the settle animation. * When options.quietReplay is true and stagger > 0, avoids the simultaneous all-lines * flash: instead each line briefly offsets from its settled state and eases back, * staggered across lines. Falls back to normal applySettle when stagger is 0. * * @param element - The live DOM element to animate * @param originalHTML - HTML snapshot taken before the first applySettle call * @param options - SettleOptions (merged with defaults) */ export declare function replaySettle(element: HTMLElement, originalHTML: string, options?: SettleOptions): () => void; /** CSS class names injected by settle — use these to target generated markup */ export declare const SETTLE_CLASSES: { readonly word: "settle-word"; readonly line: "settle-line"; readonly probe: "settle-probe"; }; /** Options for the settle page-load animation */ export declare interface SettleOptions { /** * Line detection method. Default: 'bcr' * * - **'bcr'** (default) — uses `getBoundingClientRect()` on injected word spans. * Ground truth: reads actual browser layout, handles all inline HTML and any font. * * - **'canvas'** — uses `@chenglou/pretext` canvas measurement for arithmetic line * breaking. No forced reflow on resize. Requires `@chenglou/pretext` to be installed. * Falls back to 'bcr' on the first render while pretext loads. * Avoid with `system-ui` font (canvas resolves differently on macOS). */ lineDetection?: 'bcr' | 'canvas'; /** Max initial letter-spacing offset in em (default: 0.04) */ spread?: number; /** Animation duration in ms (default: 800) */ duration?: number; /** CSS easing string (default: 'cubic-bezier(0.25, 0.1, 0.25, 1)') */ easing?: string; /** Delay between lines in ms; 0 means all lines settle together (default: 0) */ stagger?: number; /** When false, skip the animation entirely (default: true) */ active?: boolean; /** * Target letter-spacing value each line settles to. Default: 0em (natural spacing). * * - **omitted** — lines settle to `0em` letter-spacing. * * - **number** — all lines settle to this explicit em value. Positive adds tracking; * negative subtracts it. Useful for a consistent loose or tight equilibrium. * * - **'auto'** — optical density is measured per line via an off-screen canvas. * The target density is the average across all lines. Lines denser than average * receive positive tracking; sparse lines receive negative tracking. Each line * settles to its individual density-equalizing value. Clamped to ±0.05em. * The animation still starts from a random offset — settle becomes double-purposeful: * it animates AND equalizes density simultaneously. */ targetTracking?: number | 'auto'; /** * Animation direction. Default: 'expand' * * - **'expand'** (default) — lines start at a wide letter-spacing and ease to natural. * - **'compress'** — lines start at zero letter-spacing and ease outward to natural. */ direction?: 'expand' | 'compress'; /** When true, re-runs the animation each time the element scrolls into view. Default: false */ intersect?: boolean; /** * When true, `replaySettle` avoids the simultaneous all-lines flash that occurs when * stagger > 0. Instead each line individually offsets from its settled position and * transitions back, staggered by `stagger` ms. Has no effect when stagger is 0. Default: false */ quietReplay?: boolean; } /** * Drop-in component that applies the settle effect to its children. * Forwards the ref to the root DOM element while also wiring the internal settle ref. * Accepts an onReady prop to expose the replay() imperative handle to the parent. */ export declare const SettleText: default_2.ForwardRefExoticComponent>; declare interface SettleTextProps extends SettleOptions { children: default_2.ReactNode; className?: string; style?: default_2.CSSProperties; as?: default_2.ElementType; /** Called once on mount with a replay function the parent can invoke to re-trigger the animation */ onReady?: (replay: () => void) => void; } /** * React hook that applies the settle effect to a ref'd element on mount. * Skips the animation when active=false or when the user prefers reduced motion. * Re-runs on element width changes detected via ResizeObserver. * When intersect=true, re-runs the animation each time the element enters the viewport. * * @param options - UseSettleOptions (all fields optional) * @returns object with ref to attach to the target element and a replay function */ export declare function useSettle(options?: UseSettleOptions): { ref: RefObject; replay: () => void; }; /** Props accepted by useSettle in addition to SettleOptions */ declare interface UseSettleOptions extends SettleOptions { /** When false, the animation is skipped entirely (useful for SSR / reduced-motion overrides). Default: true */ active?: boolean; } export { }