{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "captions",
  "type": "registry:component",
  "title": "Captions",
  "description": "Sequential word-by-word captions driven by a timed array. The active word lifts in --onda-text with a subtle SPRING_SMOOTH scale pulse; surrounding words sit dim in --onda-dim. The data primitive for kinetic transcripts and AI-generated voiceover.",
  "dependencies": [
    "remotion",
    "zod",
    "react"
  ],
  "files": [
    {
      "path": "registry/components/captions/Captions.tsx",
      "type": "registry:component",
      "target": "components/onda/captions/Captions.tsx",
      "content": "import React from 'react';\nimport { useCurrentFrame, useVideoConfig, interpolate, spring } from 'remotion';\nimport { SPRING_SMOOTH } from '../../../lib/motion';\nimport { PlacementBox } from '../../../lib/canvas';\nimport { captionsSchema, type CaptionsProps } from './schema';\n\nexport { captionsSchema, type CaptionsProps };\n\n/**\n * Sequential word-by-word captions driven by a timed array. The active word\n * lifts in `--onda-text` with a subtle `SPRING_SMOOTH` scale pulse; surrounding\n * words sit dim in `--onda-dim`. The data primitive for kinetic transcripts\n * and AI-generated voiceover.\n *\n * @example\n * <Captions captions={[{ text: 'Hi', startMs: 0, endMs: 500 }]} />\n */\nexport const Captions: React.FC<CaptionsProps> = ({\n  captions,\n  delay,\n  color,\n  accentColor,\n  fontSize,\n  fontFamily,\n  fontWeight,\n  letterSpacing,\n  lineHeight,\n  align,\n  placement,\n}) => {\n  const frame = useCurrentFrame();\n  const { fps } = useVideoConfig();\n\n  // Convert the local frame (after `delay`) into milliseconds so the\n  // captions array can be authored in real-world ms — the format every\n  // transcript/STT tool already speaks.\n  const local = Math.max(0, frame - delay);\n  const currentMs = (local / fps) * 1000;\n\n  return (\n    <PlacementBox placement={placement}>\n      <div\n        style={{\n          display: 'flex',\n          gap: '0.3em',\n          flexWrap: 'wrap',\n          // Flex justification mirrors text-alignment intent for the wrapped block.\n          justifyContent: align === 'left' ? 'flex-start' : align === 'right' ? 'flex-end' : 'center',\n          alignItems: 'baseline',\n          color,\n          fontSize,\n          fontFamily,\n          fontWeight,\n          letterSpacing,\n          lineHeight,\n        }}\n      >\n        {captions.map((caption, i) => {\n          const isActive =\n            currentMs >= caption.startMs && currentMs < caption.endMs;\n\n          // Frame at which this word becomes active, expressed in the\n          // component's local frame timeline. Used to drive the activation\n          // pulse — a subtle 0→1 SPRING_SMOOTH ramp over the first frames\n          // of activation. Restrained: only a 4% scale lift, no overshoot.\n          const activationLocalFrame =\n            local - (caption.startMs / 1000) * fps;\n\n          const pulse = spring({\n            frame: activationLocalFrame,\n            fps,\n            config: SPRING_SMOOTH,\n            durationInFrames: 4,\n          });\n\n          const pulseClamped = interpolate(pulse, [0, 1], [0, 1], {\n            extrapolateLeft: 'clamp',\n            extrapolateRight: 'clamp',\n          });\n\n          const scale = isActive ? 1 + 0.04 * pulseClamped : 1;\n          const wordColor = isActive ? accentColor : color;\n          // Active word reads at full opacity; inactive words sit slightly\n          // dimmer than --onda-dim's own value to push focus to the active\n          // one without disappearing the surrounding context.\n          const opacity = isActive ? 1 : 0.7;\n\n          return (\n            <span\n              // Stable key derived from index + the caption boundaries so a\n              // re-ordered captions array doesn't mis-key — deterministic.\n              key={`${i}-${caption.startMs}-${caption.endMs}`}\n              style={{\n                color: wordColor,\n                opacity,\n                transform: `scale(${scale})`,\n                transformOrigin: 'center bottom',\n                display: 'inline-block',\n              }}\n            >\n              {caption.text}\n            </span>\n          );\n        })}\n      </div>\n    </PlacementBox>\n  );\n};\n"
    },
    {
      "path": "registry/components/captions/schema.ts",
      "type": "registry:component",
      "target": "components/onda/captions/schema.ts",
      "content": "import { z } from 'zod';\nimport { placementSchema } from '../../../lib/canvas-schemas';\n\n/** Zod schema for {@link Captions} props. */\nexport const captionsSchema = z.object({\n  /** Discriminator literal — matches this entry's registry slug. Auto-populated when omitted (`schema.parse({})` works as before). Lets consumers build `z.discriminatedUnion('kind', [...])` directly over onda schemas. */\n  kind: z.literal('captions').default('captions'),\n  /**\n   * The transcript timeline. Each entry is a word + its `[startMs, endMs)`\n   * window — the format every STT / transcript tool already speaks.\n   */\n  captions: z\n    .array(\n      z.object({\n        text: z.string(),\n        startMs: z.number(),\n        endMs: z.number(),\n      }),\n    )\n    .default([\n      { text: 'Onda', startMs: 0, endMs: 1500 },\n      { text: 'kinetic', startMs: 1500, endMs: 3000 },\n      { text: 'captions', startMs: 3000, endMs: 4500 },\n    ]),\n  /** Frames before the timeline starts (shifts every `startMs` by this). */\n  delay: z.number().int().min(0).default(0),\n  /** Inactive word color. Defaults to `--onda-dim`. */\n  color: z.string().default('var(--onda-dim, #8E8E98)'),\n  /** Active word color. Defaults to `--onda-text`. */\n  accentColor: z.string().default('var(--onda-text, #F2F2F4)'),\n  /** Pixels. */\n  fontSize: z.number().default(96),\n  /** Onda display font. */\n  fontFamily: z.string().default('var(--onda-font-display, \"Clash Display\", sans-serif)'),\n  /** Font weight (e.g. 500, 600). */\n  fontWeight: z.number().default(600),\n  /** CSS letter-spacing (e.g. `'-0.02em'`). Default `'normal'`. */\n  letterSpacing: z.string().optional(),\n  /** Unitless line height. Default `1.15` for caption stacks. */\n  lineHeight: z.number().optional(),\n  /** Text alignment of the caption block. */\n  align: z.enum(['left', 'center', 'right']).optional(),\n  /** Where on the canvas this sits. Region (`'center'`, `'upper-third'`, ...) or `{ x, y, anchor }` in 0..1 canvas fractions. Coordinates may be negative or >1 for off-canvas. */\n  placement: placementSchema.optional(),\n});\n\n/** Inferred props for {@link Captions}. */\nexport type CaptionsProps = z.infer<typeof captionsSchema>;\n"
    },
    {
      "path": "registry/components/captions/captions.meta.json",
      "type": "registry:file",
      "target": "components/onda/captions/captions.meta.json",
      "content": "{\n  \"name\": \"captions\",\n  \"title\": \"Captions\",\n  \"description\": \"Sequential word-by-word captions driven by a timed array. The active word lifts in --onda-text with a subtle SPRING_SMOOTH scale pulse; surrounding words sit dim in --onda-dim. The data primitive for kinetic transcripts and AI-generated voiceover.\",\n  \"pickWhen\": \"synced subtitles over voiceover or video — transcripts, AI voiceover, talking-head clips. Pass a timed array; not for static text.\",\n  \"category\": \"data\",\n  \"tags\": [\n    \"text\",\n    \"captions\",\n    \"transcript\",\n    \"voiceover\",\n    \"data\",\n    \"spring\"\n  ],\n  \"dependencies\": [\n    \"remotion\",\n    \"zod\",\n    \"react\"\n  ]\n}\n"
    },
    {
      "path": "registry/components/captions/README.md",
      "type": "registry:file",
      "target": "components/onda/captions/README.md",
      "content": "# Captions\n\nSequential word-by-word captions driven by a timed array. Each caption has a `startMs` and `endMs`; the currently-active word sits in `--onda-text` with a subtle `SPRING_SMOOTH` scale pulse on activation, while surrounding words sit dim in `--onda-dim`. The data primitive for kinetic transcripts, AI-generated voiceover, and short-form captions — designed to consume the same `{ text, startMs, endMs }` shape every speech-to-text tool already speaks.\n\n## Props\n\n| Name | Type | Default | Notes |\n| --- | --- | --- | --- |\n| `captions` | `{ text: string; startMs: number; endMs: number }[]` | three-word \"Onda kinetic captions\" sample | Word timing in milliseconds. Authored in ms so transcripts from STT pipelines drop in directly. |\n| `delay` | `integer ≥ 0` | `0` | Frames before the timeline starts (lets a parent `<Sequence>` align the audio bed). |\n| `color` | `string` | `\"#8E8E98\"` | Inactive word color — `--onda-dim`. |\n| `accentColor` | `string` | `\"#F2F2F4\"` | Active word color — `--onda-text`. Note: the contrast moment is brightness, not the rose accent — captions appear in batches and a rose pulse on every word would burn the eye. |\n| `fontSize` | `number` | `96` | Pixels. |\n| `fontFamily` | `string` | `'\"Clash Display\", sans-serif'` | The Onda display font. Never default to Inter / Arial / system. |\n| `fontWeight` | `number` | `600` | Display weight. |\n| `letterSpacing` | `string` | `\"normal\"` | CSS letter-spacing. |\n| `lineHeight` | `number` | `1.15` | Unitless line height. |\n| `align` | `\"left\" \\| \"center\" \\| \"right\"` | `\"center\"` | Caption block alignment. |\n| `placement` | `Placement?` | – | Where on the canvas this sits. Region (`\"center\"`, `\"upper-third\"`, …) or `{ x, y, anchor }` in 0..1 canvas fractions. Coordinates may be negative or >1 for off-canvas. |\n\n## Usage\n\n```tsx\nimport { Composition } from 'remotion';\nimport { Captions, captionsSchema } from './components/onda/captions/Captions';\n\nexport const Root: React.FC = () => (\n  <Composition\n    id=\"MyCaptions\"\n    component={Captions}\n    durationInFrames={150}\n    fps={30}\n    width={1080}\n    height={1920}\n    schema={captionsSchema}\n    defaultProps={{\n      captions: [\n        { text: 'Onda', startMs: 0, endMs: 1500 },\n        { text: 'kinetic', startMs: 1500, endMs: 3000 },\n        { text: 'captions', startMs: 3000, endMs: 4500 },\n      ],\n      delay: 0,\n      color: '#8E8E98',\n      accentColor: '#F2F2F4',\n      fontSize: 96,\n      fontFamily: '\"Clash Display\", sans-serif',\n      fontWeight: 600,\n    }}\n  />\n);\n```\n\n## Motion notes\n\n- Activation pulse is `SPRING_SMOOTH` from `lib/motion.ts` — the Onda house spring. **No overshoot.** The active word lifts by 4% (1.0 → 1.04) over the first 4 frames of activation, then holds.\n- Timing is authored in **milliseconds** and converted via `useVideoConfig().fps` — the component is correct at any framerate.\n- Inactive words sit at `opacity: 0.7` to make the active word read as the focal point without making surrounding context disappear (so the eye still knows the sentence shape).\n- All `interpolate` calls clamp at both ends; the active-word lookup is a pure function of the current ms, so any frame renders correctly without knowing prior frames.\n- Active state is a brightness contrast (`--onda-dim` → `--onda-text`), not a rose-accent flash. Captions arrive constantly; reserving rose here would burn the brand's earned-accent rule.\n"
    }
  ],
  "registryDependencies": [
    "lib-motion"
  ]
}
