{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"type-morph","type":"registry:component","title":"Type Morph","description":"Typewriter effect: a headline types with a blinking caret, then morphs letter by letter. A headline that types itself under a glowing caret, sheds its lead, morphs letter by letter, and ends under a colour flood.","dependencies":["remotion","@remotion/google-fonts"],"docs":"Needs a Remotion project. If a frame renders black, the component is drawing on a transparent layer: put a background behind it, e.g. <AbsoluteFill style={{ background: \"#faf9f6\" }}><Component /></AbsoluteFill>. Pass mode=\"dark\" for dark frames.","registryDependencies":["https://kuchi.kalarislabs.com/r/kuchi-ui.json","https://kuchi.kalarislabs.com/r/text-reveal.json"],"files":[{"path":"components/kuchi/type-morph.tsx","type":"registry:component","target":"components/kuchi/type-morph.tsx","content":"/*! Portions Copyright (c) 2026 Sri Nath (snap-cn). MIT License. See THIRD_PARTY_LICENSES. */\n\"use client\";\r\n\r\nimport { loadFont as loadInter } from \"@remotion/google-fonts/Inter\";\r\nimport { type CSSProperties, useLayoutEffect, useRef, useState } from \"react\";\r\nimport {\r\n  AbsoluteFill,\r\n  continueRender,\r\n  delayRender,\r\n  Easing,\r\n  getRemotionEnvironment,\r\n  interpolate,\r\n  useCurrentFrame,\r\n  useVideoConfig,\r\n} from \"remotion\";\r\nimport { TextReveal } from \"@/components/kuchi/text-reveal\";\r\nimport {\r\n  mixOklch,\r\n  resolveFont,\r\n  type KuchiTheme,\r\n  useKuchiTheme,\r\n} from \"@/lib/kuchi-ui\";\r\nimport {\r\n  CUT_AT,\r\n  CUT2_AT,\r\n  EXIT_COEFF,\r\n  EXIT_FROM,\r\n  EXIT_RATIO,\r\n  FLOOD_STAGE_FRAMES,\r\n  MORPH_FROM,\r\n  MORPH_TO,\r\n  SLIDE_BEZIER,\r\n  SLIDE_FROM,\r\n  SLIDE_TO,\r\n} from \"./type-morph-timeline\";\r\n\r\nconst { fontFamily: SANS } = loadInter(\"normal\", {\r\n  weights: [\"400\", \"700\"],\r\n  subsets: [\"latin\"],\r\n});\r\n\r\nexport interface TypeMorphProps {\r\n  /**\r\n   * The line as it is typed. Everything up to and including `lead` is cut away\r\n   * once typing finishes, which is what leaves the emphasis alone on screen.\r\n   */\r\n  lead?: string;\r\n  /** The emphasised tail of the typed line — this is what survives the cut. */\r\n  emphasis?: string;\r\n  /** What the emphasis morphs into, letter by letter. */\r\n  morphTo?: string;\r\n  /**\r\n   * What is left after the second cut. Empty ends the beat on the bare flood.\r\n   */\r\n  finally_?: string;\r\n  /**\r\n   * Whether the final phrase survives into the flood.\r\n   *\r\n   * The reference carries it across; off is the cleaner ending, and it is the\r\n   * default because a word sitting on a full-bleed colour for four frames reads\r\n   * as a leftover rather than as a beat.\r\n   */\r\n  wordOnFlood?: boolean;\r\n  /** Accepted, not drawn: the caret and fresh glyphs take the ink colour. */\r\n  accent?: string;\r\n  /**\r\n   * Two flat colours to flood the frame with at the end, or `false` to end on\r\n   * paper — the default.\r\n   *\r\n   * The reference floods; off is the quieter ending and the one that composes,\r\n   * because a beat that hands the next scene a full-bleed colour has decided\r\n   * what that scene opens on.\r\n   *\r\n   * Two flat colours rather than a ramp: the reference arrives at 99% frame\r\n   * coverage inside a single frame and then steps once. A crossfade between them\r\n   * would put a half-transparent wash over the type for several frames, and\r\n   * there is no reading of that except the screen dimming.\r\n   */\r\n  flood?: [string, string] | false;\r\n  /**\r\n   * The page.\r\n   *\r\n   * Defaults to the theme's background so the component belongs in whatever\r\n   * project installs it. The reference's paper is a plain near-white (#f7f7f7 to\r\n   * #fafafa across the beat), not the warm off-white the token carries, so the\r\n   * preview passes its own.\r\n   */\r\n  background?: string;\r\n  /** The type. Defaults to the theme's foreground. */\r\n  ink?: string;\r\n  /**\r\n   * The opening line is rendered by `text-reveal` itself.\r\n   *\r\n   * Not a reimplementation of it, and not its helper functions rebuilt into a\r\n   * second animator — the component, mounted. Everything in `reveal` is passed\r\n   * to it untouched, so its lead-word push, its recede and its assemble are\r\n   * exactly what that component does anywhere else, and there is nothing here\r\n   * that can drift away from it.\r\n   */\r\n  reveal?: Omit<\r\n    React.ComponentProps<typeof TextReveal>,\r\n    \"text\" | \"theme\" | \"mode\" | \"color\" | \"fontSize\"\r\n  >;\r\n  /**\r\n   * Cap-to-descender height as a fraction of the frame height.\r\n   *\r\n   * 0.1256, not the 0.139 the reference's raw ink height suggests: measured back\r\n   * from the rendered line width against the reference's at the same frame, mine\r\n   * came out 12.7% wide at 0.139 and 4% narrow at 0.1233, because ink height\r\n   * includes the descender and the face's\r\n   * own metrics differ from the reference's.\r\n   */\r\n  size?: number;\r\n  theme?: Partial<KuchiTheme>;\r\n  mode?: \"light\" | \"dark\";\r\n  /**\r\n   * The face this scene paints its words in — a label from `fonts.ts`\r\n   * (\"Inter\", \"Space Grotesk\", \"Instrument Serif\") or a CSS family you have\r\n   * loaded yourself. Unset, the scene keeps the face it was designed around.\r\n   *\r\n   * Overrides `theme.fontFamily`, which is how a brand kit re-skins a whole\r\n   * timeline from one value.\r\n   */\r\n  fontFamily?: string;\r\n}\r\n\r\n/**\r\n * `will-change` is right for the Player and wrong for the render — a render\r\n * draws each frame in a different tab, and a promoted layer hands that tab a\r\n * stale raster from whatever scale it last drew.\r\n */\r\nconst promoted = getRemotionEnvironment().isRendering\r\n  ? null\r\n  : ({ willChange: \"transform\" } as const);\r\n\r\n/**\r\n * Hinting bends each glyph so its stems land on whole pixels, so as anything\r\n * moves the letterforms re-snap and boil. This also forces sub-pixel glyph\r\n * positioning, which Blink otherwise only enables above a device scale factor of\r\n * 1 — and a render is exactly 1, so without it every glyph in the morph would\r\n * land on a whole pixel and the travel would stutter.\r\n */\r\nconst CRISP: CSSProperties = {\r\n  textRendering: \"geometricPrecision\",\r\n  WebkitFontSmoothing: \"antialiased\",\r\n};\r\n\r\n/** Moderate decelerate. Quint/expo spend frames below half a pixel, which rasterise identically. */\r\nconst EASE = Easing.bezier(0.2, 0.6, 0.35, 1);\r\n\r\n/**\r\n * Pair each glyph of `to` with a glyph of `from` that can travel to it.\r\n *\r\n * Greedy nearest-unused match on the character itself. It is not the optimal\r\n * assignment and does not need to be — what the eye reads is *continuity*, that\r\n * some letters persisted rather than the whole line being replaced, and a\r\n * nearest match delivers that while an optimal one costs a matrix and looks the\r\n * same. Unmatched targets fade up in place; unmatched sources fade out in place.\r\n */\r\nfunction pairGlyphs(from: string, to: string): (number | null)[] {\r\n  const used = new Set<number>();\r\n  return [...to].map((ch, ti) => {\r\n    let best: number | null = null;\r\n    let bestDist = Infinity;\r\n    for (let fi = 0; fi < from.length; fi += 1) {\r\n      if (used.has(fi) || from[fi] !== ch) continue;\r\n      const dist = Math.abs(fi - ti);\r\n      if (dist < bestDist) {\r\n        bestDist = dist;\r\n        best = fi;\r\n      }\r\n    }\r\n    if (best !== null) used.add(best);\r\n    return best;\r\n  });\r\n}\r\n\r\n/** Per-glyph x offsets of a string, measured in the real face at the real size. */\r\nfunction useGlyphOffsets(strings: string[], fontSize: number, face: string) {\r\n  const ref = useRef<HTMLDivElement>(null);\r\n  const [offsets, setOffsets] = useState<number[][] | null>(null);\r\n  // Every frame of a render is a fresh mount, so a plain effect + state lets the\r\n  // frame be captured *before* the measurement has re-rendered — the glyphs are\r\n  // then placed with no offsets at all and the frame comes out blank or short.\r\n  // `delayRender` holds the capture until the second render has happened.\r\n  const [handle] = useState(() => delayRender(\"type-morph: measuring glyphs\"));\r\n\r\n  useLayoutEffect(() => {\r\n    const root = ref.current;\r\n    if (!root) return;\r\n    // `offsetLeft` is layout px and unaffected by transforms — which is exactly\r\n    // why it is the right tool for measuring a line that is about to be\r\n    // transformed, which is exactly why it is the right tool for measuring a\r\n    // line that is about to be transformed.\r\n    setOffsets(\r\n      [...root.children].map((line) =>\r\n        [...(line as HTMLElement).children].map(\r\n          (g) => (g as HTMLElement).offsetLeft,\r\n        ),\r\n      ),\r\n    );\r\n  }, []);\r\n\r\n  // Only once the measured offsets are actually in the tree.\r\n  useLayoutEffect(() => {\r\n    if (offsets) continueRender(handle);\r\n  }, [offsets, handle]);\r\n\r\n  const probe = (\r\n    <div\r\n      ref={ref}\r\n      aria-hidden\r\n      style={{\r\n        position: \"absolute\",\r\n        visibility: \"hidden\",\r\n        pointerEvents: \"none\",\r\n        whiteSpace: \"pre\",\r\n        fontFamily: face,\r\n        fontSize,\r\n        letterSpacing: \"-0.035em\",\r\n        ...CRISP,\r\n      }}\r\n    >\r\n      {strings.map((s) => (\r\n        <div key={s} style={{ whiteSpace: \"pre\" }}>\r\n          {[...s].map((ch, i) => (\r\n            // biome-ignore lint/suspicious/noArrayIndexKey: glyph position is the identity here\r\n            <span key={i} style={{ display: \"inline-block\" }}>\r\n              {ch === \" \" ? \" \" : ch}\r\n            </span>\r\n          ))}\r\n        </div>\r\n      ))}\r\n    </div>\r\n  );\r\n\r\n  return { probe, offsets };\r\n}\r\n\r\n/**\r\n * A headline that types itself, sheds its lead, morphs letter by letter, and\r\n * ends under a colour flood.\r\n *\r\n * Four mechanics on one timeline, each measured off a reference frame by frame\r\n * (see `timeline.ts` for the signals and the numbers they produced):\r\n *\r\n * 1. **Typing.** The line is centre-anchored, so it grows in both directions\r\n *    rather than running to the right. Freshly landed glyphs arrive in the\r\n *    accent colour and cool to ink over four frames, which is what gives the\r\n *    typing a moving warm edge instead of a hard cursor.\r\n * 2. **The cut.** The lead is removed in a single frame, not animated out. What\r\n *    *is* animated is the slide back to centre that follows it.\r\n * 3. **The morph.** Glyphs shared between the two phrases travel from where they\r\n *    were to where they belong; the rest cross-fade in place.\r\n * 4. **The flood.** Two flat colours, four frames each.\r\n *\r\n * Every glyph position is measured in the real face at the real size behind a\r\n * hidden probe, because a morph built on estimated advance widths lands each\r\n * letter a pixel or two off and reads as a wobble.\r\n */\r\nexport function TypeMorph({\r\n  lead = \"Not just \",\r\n  emphasis = \"communicator.\",\r\n  morphTo = \"something more.\",\r\n  finally_ = \"more.\",\r\n  wordOnFlood = false,\r\n  background,\r\n  ink,\r\n  reveal,\r\n  flood = false,\r\n  size = 0.1256,\r\n  theme,\r\n  mode,\r\n  fontFamily,\r\n}: TypeMorphProps) {\r\n  const frame = useCurrentFrame();\r\n  const { height, width } = useVideoConfig();\r\n  const t = useKuchiTheme(theme, mode);\r\n  const face = resolveFont(fontFamily ?? t.fontFamily) ?? SANS;\r\n  const paper = background ?? t.background;\r\n  const type = ink ?? t.foreground;\r\n  const fontSize = height * size;\r\n\r\n  const typed = lead + emphasis;\r\n  const { probe, offsets } = useGlyphOffsets(\r\n    [typed, emphasis, morphTo, finally_],\r\n    fontSize,\r\n    face,\r\n  );\r\n\r\n  // ── the timeline ──────────────────────────────────────────────────────────\r\n  //\r\n  // Absolute frame numbers, measured, not derived from each other. Deriving them\r\n  // meant one wrong constant early shifted everything after it.\r\n\r\n  const floodAt = CUT2_AT + 1;\r\n  const floodBAt = floodAt + FLOOD_STAGE_FRAMES;\r\n\r\n  const phase =\r\n    flood && frame >= floodAt\r\n      ? \"flood\"\r\n      : frame >= CUT2_AT\r\n        ? \"final\"\r\n        : frame >= MORPH_FROM\r\n          ? \"morph\"\r\n          : frame >= CUT_AT\r\n            ? \"slide\"\r\n            : \"type\";\r\n\r\n  const floodColor =\r\n    flood && frame >= floodAt\r\n      ? frame >= floodBAt\r\n        ? flood[1]\r\n        : flood[0]\r\n      : null;\r\n\r\n  const centre = width / 2;\r\n\r\n  /**\r\n   * The line's horizontal offset — ONE continuous function of frame.\r\n   *\r\n   * The reference does not cut and then move; it moves continuously and the cut\r\n   * only changes what is drawn. A single 16-frame cubic-bezier fits all 17\r\n   * frames of the re-centring, straight through the cut, to 0.067px. Modelling\r\n   * it as \"drift, cut, slide\" fits the same curve twice and puts a seam where\r\n   * the reference has none.\r\n   *\r\n   * The travel is not a fixed distance — it is however far off-centre the\r\n   * emphasis happens to sit inside the typed line, which the measured probe\r\n   * already knows. On the reference that works out to 184.4px right of centre on\r\n   * a 1400px frame; on any other phrase it is whatever that phrase needs.\r\n   */\r\n  const slideProgress = interpolate(frame, [SLIDE_FROM, SLIDE_TO], [0, 1], {\r\n    easing: Easing.bezier(...SLIDE_BEZIER),\r\n    extrapolateLeft: \"clamp\",\r\n    extrapolateRight: \"clamp\",\r\n  });\r\n\r\n  /** The exit: geometric per-frame velocity. Persists past the cut it precedes. */\r\n  //\r\n  // It stops at the cut. The reference carries the drifted position into what\r\n  // the cut leaves behind, but the final phrase here is centred by choice, and a\r\n  // drift still applied to it would drag a centred phrase off to the left — 300px\r\n  // by the last frame.\r\n  const exitDrift =\r\n    frame <= EXIT_FROM || frame >= CUT2_AT\r\n      ? 0\r\n      : (-EXIT_COEFF * (EXIT_RATIO ** (frame - EXIT_FROM) - 1) * width) / 1400;\r\n\r\n  /** One glyph, absolutely placed, so nothing reflows as the line changes. */\r\n  const glyph = (\r\n    key: string,\r\n    ch: string,\r\n    x: number,\r\n    lineWidth: number,\r\n    style: CSSProperties,\r\n  ) => (\r\n    <span\r\n      key={key}\r\n      style={{\r\n        position: \"absolute\",\r\n        left: centre - lineWidth / 2 + x,\r\n        top: 0,\r\n        whiteSpace: \"pre\",\r\n        ...style,\r\n      }}\r\n    >\r\n      {ch === \" \" ? \" \" : ch}\r\n    </span>\r\n  );\r\n\r\n  let content: React.ReactNode = null;\r\n\r\n  if (offsets) {\r\n    const [typedX, emphX, morphX, finalX] = offsets;\r\n    const widthOf = (xs: number[], str: string) =>\r\n      (xs[str.length - 1] ?? 0) + fontSize * 0.34;\r\n\r\n    const wTyped = widthOf(typedX, typed);\r\n    const wEmph = widthOf(emphX, emphasis);\r\n    const wMorph = widthOf(morphX, morphTo);\r\n\r\n    // Where the emphasis sits inside the typed line. The slide carries the whole\r\n    // line, so both the typed phase and the post-cut phase read the same offset.\r\n    const emphInTyped = typedX[lead.length] - wTyped / 2 + wEmph / 2;\r\n\r\n    if (phase === \"type\") {\r\n      // `text-reveal` owns these frames entirely — see the render below.\r\n      content = null;\r\n    } else if (phase === \"slide\") {\r\n      // From the cut to the end of the slide, this component draws the line —\r\n      // `text-reveal` has already delivered it, centred, and the emphasis now\r\n      // slides on the measured bezier.\r\n      const w = widthOf(emphX, emphasis);\r\n      const dx = -emphInTyped * (1 - slideProgress);\r\n      content = [...emphasis].map((ch, i) =>\r\n        glyph(`e${i}`, ch, emphX[i] + dx, w, {\r\n          color: type,\r\n          fontWeight: 700,\r\n        }),\r\n      );\r\n    } else if (phase === \"morph\") {\r\n      const p = interpolate(frame, [MORPH_FROM, MORPH_TO], [0, 1], {\r\n        easing: EASE,\r\n        extrapolateLeft: \"clamp\",\r\n        extrapolateRight: \"clamp\",\r\n      });\r\n      const w = interpolate(p, [0, 1], [wEmph, wMorph]);\r\n      const pairs = pairGlyphs(emphasis, morphTo);\r\n      const matched = new Set(pairs.filter((x): x is number => x !== null));\r\n      content = [\r\n        ...[...emphasis].map((ch, i) =>\r\n          matched.has(i)\r\n            ? null\r\n            : glyph(`x${i}`, ch, emphX[i] + (wEmph - w) / 2, w, {\r\n                color: type,\r\n                fontWeight: 700,\r\n                opacity: interpolate(p, [0, 0.45], [1, 0], {\r\n                  extrapolateRight: \"clamp\",\r\n                }),\r\n              }),\r\n        ),\r\n        ...[...morphTo].map((ch, i) => {\r\n          const src = pairs[i];\r\n          const to = morphX[i] + (wMorph - w) / 2;\r\n          if (src === null) {\r\n            return glyph(`n${i}`, ch, to, w, {\r\n              color: type,\r\n              fontWeight: 700,\r\n              opacity: interpolate(p, [0.55, 1], [0, 1], {\r\n                extrapolateLeft: \"clamp\",\r\n                extrapolateRight: \"clamp\",\r\n              }),\r\n            });\r\n          }\r\n          const fromX = emphX[src] + (wEmph - w) / 2;\r\n          return glyph(`m${i}`, ch, interpolate(p, [0, 1], [fromX, to]), w, {\r\n            color: type,\r\n            fontWeight: 700,\r\n          });\r\n        }),\r\n      ].filter(Boolean);\r\n    } else {\r\n      // The final phrase, CENTRED — it does not inherit the drifted position.\r\n      const w = widthOf(finalX, finally_);\r\n      const hidden = phase === \"flood\" && !wordOnFlood;\r\n      content = hidden\r\n        ? []\r\n        : [...finally_].map((ch, i) =>\r\n            glyph(`f${i}`, ch, finalX[i], w, {\r\n              fontWeight: 700,\r\n              color: floodColor\r\n                ? mixOklch(floodColor, t.background, 0.92)\r\n                : type,\r\n              opacity: 1,\r\n            }),\r\n          );\r\n    }\r\n  }\r\n\r\n  return (\r\n    <AbsoluteFill\r\n      style={{\r\n        background: floodColor ?? paper,\r\n        fontFamily: face,\r\n        ...CRISP,\r\n      }}\r\n    >\r\n      {probe}\r\n      {frame < CUT_AT ? (\r\n        <TextReveal\r\n          text={typed}\r\n          fontSize={fontSize}\r\n          color={type}\r\n          theme={theme}\r\n          mode={mode}\r\n          {...reveal}\r\n        />\r\n      ) : null}\r\n      <div\r\n        style={{\r\n          position: \"absolute\",\r\n          top: \"50%\",\r\n          left: 0,\r\n          right: 0,\r\n          height: 0,\r\n          fontSize,\r\n          lineHeight: 1,\r\n          letterSpacing: \"-0.035em\",\r\n          transform: `translate(${exitDrift.toFixed(2)}px, ${-fontSize * 0.36}px)`,\r\n          ...promoted,\r\n        }}\r\n      >\r\n        {content}\r\n      </div>\r\n    </AbsoluteFill>\r\n  );\r\n}\r\n\r\nexport default TypeMorph;\r\n"},{"path":"components/kuchi/type-morph-timeline.ts","type":"registry:file","target":"components/kuchi/type-morph-timeline.ts","content":"/*! Portions Copyright (c) 2026 Sri Nath (snap-cn). MIT License. See THIRD_PARTY_LICENSES. */\n/**\r\n * Every number here was measured off the reference recording, frame by frame.\r\n *\r\n * Source: a 30fps screen recording, 89 frames, 1400x762. Frames were cut at\r\n * 30fps and each reduced to signals — the bounding box of ink (a green-channel\r\n * threshold isolates glyph cores and rejects the violet bloom, which a mean-RGB\r\n * threshold does not), the centroid and count of chromatic pixels, and mean\r\n * luminance. Curves were then fitted against exponential, polynomial and\r\n * cubic-bezier families and the residuals compared, rather than a shape being\r\n * assumed.\r\n *\r\n * Frame numbers below are 0-based composition frames. The source's `g001.png` is\r\n * frame 0.\r\n */\r\n\r\nexport const FPS = 30;\r\n\r\n// ── The opening ──────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Frames 0 to `CUT_AT` belong to `text-reveal`, which this component mounts\r\n * rather than reimplements — so its schedule lives there, not here.\r\n *\r\n * What the reference does in those frames is a *typewriter*: a constant\r\n * 1.5467 frames per character with the final full stop held back five frames,\r\n * each glyph landing at 1.178x and settling over five, arriving near-black with\r\n * a violet cast (#292541) rather than at the caret's own light violet. That is\r\n * documented because it was measured and is worth keeping, not because anything\r\n * below consumes it — `text-reveal` assembles word by word instead, which is a\r\n * different animation and a deliberate choice.\r\n */\r\n\r\n// ── The slide ────────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * The re-centring move is ONE continuous curve, and it starts before the cut.\r\n *\r\n * This is the correction that mattered most. The obvious reading is \"the lead is\r\n * cut, then what is left slides back to centre\", which makes the motion start at\r\n * the cut. It does not. The line is already moving five frames earlier, and one\r\n * 16-frame cubic-bezier fits all 17 frames of it — through the cut — to a mean\r\n * error of 0.067px, max 0.23px.\r\n *\r\n * Alternatives on the same data: exponential decay 8.76px, a Remotion spring\r\n * with five free parameters 2.07px, degree-6 polynomial 1.60px, cubic 6.94px.\r\n * The bezier is better by two orders of magnitude, so this is not a close call.\r\n *\r\n * The consequence for the implementation: **the cut is a visibility change, not\r\n * a position change.** Residuals across it are +0.080 (before) and -0.108\r\n * (after) — nothing jumps. Earlier versions modelled a \"pre-cut drift\" and a\r\n * separate slide, which is the same curve described as two and fitted twice.\r\n */\r\nexport const SLIDE_FROM = 39;\r\nexport const SLIDE_TO = 55;\r\nexport const SLIDE_BEZIER = [0.3438, 0.0294, 0.032, 0.9269] as const;\r\n\r\n/** The lead stops being drawn here. Position is unaffected — see `SLIDE_BEZIER`. */\r\nexport const CUT_AT = 44;\r\n\r\n// ── The morph ────────────────────────────────────────────────────────────────\r\n\r\nexport const MORPH_FROM = 56;\r\nexport const MORPH_TO = 67;\r\n\r\n// ── The exit ─────────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * The exit drift: geometric per-frame velocity, i.e. an exponential ease-in.\r\n *\r\n * Starts at frame 72 — the frames before it are static to within 0.005px, and\r\n * frame 73 is the first displaced one at 0.73px. Sub-pixel displacements are\r\n * 0.73, 1.99, 3.70, 6.05, 9.76, 16.28, 30.03, 54.2; the integer bounding box\r\n * reads those as 1,2,3,7,9,16,29,54 because motion blur erodes a thresholded\r\n * edge, which is why an earlier hand-fit had both the start frame and the first\r\n * step wrong.\r\n *\r\n * Fit: 0.36px mean error. Quadratic is 8.60px, cubic 3.42px, easeInQuart 1.72px.\r\n */\r\nexport const EXIT_FROM = 72;\r\nexport const EXIT_RATIO = 1.76456;\r\nexport const EXIT_COEFF = 1.3194;\r\n\r\n/** The cut to the final phrase. */\r\nexport const CUT2_AT = 81;\r\n\r\n// ── The ending ───────────────────────────────────────────────────────────────\r\n\r\n/** Frames the final phrase is held when there is no flood. */\r\nexport const FINAL_HOLD = 12;\r\n/** Each flood stage. Both are single-frame cuts to a flat colour, not ramps. */\r\nexport const FLOOD_STAGE_FRAMES = 4;\r\n\r\n/**\r\n * The reference's own palette. Component defaults come from the design system;\r\n * these are here so the doc and the preview can quote what was measured.\r\n *\r\n * The page is #f7f7f7 for the whole non-flood run and never changes — the\r\n * per-channel median is exactly 247 on 79 of 82 frames, reading 249 only where\r\n * a grain overlay peaks.\r\n */\r\nexport const REFERENCE = {\r\n  page: \"#f7f7f7\",\r\n  ink: \"#1f1f1f\",\r\n  caret: \"#b3a9f9\",\r\n  floodA: \"#8575fa\",\r\n  floodB: \"#4931f2\",\r\n} as const;\r\n\r\n/** Total frames, end to end. */\r\nexport function totalFrames(hasFlood = false): number {\r\n  return CUT2_AT + 1 + (hasFlood ? FLOOD_STAGE_FRAMES * 2 : FINAL_HOLD);\r\n}\r\n"}]}