{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "acronym-expand",
  "title": "Acronym Expand",
  "description": "An acronym expands letter by letter into 'Model Context Protocol' with an eyebrow and subhead.",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "files": [
    {
      "path": "registry/remocn/acronym-expand/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont as loadMono } from \"@remotion/google-fonts/JetBrainsMono\";\nimport { loadFont as loadSora } from \"@remotion/google-fonts/Sora\";\nimport type React from \"react\";\nimport { useEffect, useRef, useState } from \"react\";\nimport {\n  AbsoluteFill,\n  continueRender,\n  delayRender,\n  Easing,\n  interpolate,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\n\nconst sora = loadSora(\"normal\", {\n  weights: [\"400\", \"500\"],\n  subsets: [\"latin\"],\n});\nconst mono = loadMono(\"normal\", { weights: [\"500\"], subsets: [\"latin\"] });\n\nexport interface AcronymExpandProps {\n  short?: string;\n  full?: string;\n  eyebrow?: string;\n  subhead?: string;\n  accent?: string;\n  background?: string;\n  speed?: number;\n  theme?: \"dark\" | \"light\";\n}\n\nconst LIMB = [\"#e9ecff\", \"#8a8bff\", \"#4b2bd6\", \"#160c3a\"] as const;\n\nconst THEMES = {\n  dark: {\n    bg: \"#0A0A0B\",\n    fg: \"#F4F3F0\",\n    muted: \"#8E8D94\",\n    ground: [\n      `radial-gradient(46% 58% at 50% 52%, color-mix(in oklab, ${LIMB[3]} 85%, transparent) 0%, transparent 72%)`,\n      `radial-gradient(30% 34% at 50% 50%, color-mix(in oklab, ${LIMB[2]} 22%, transparent) 0%, transparent 80%)`,\n    ].join(\", \"),\n    init: (a: string) =>\n      `linear-gradient(120deg, ${LIMB[0]} 0%, ${LIMB[1]} 42%, color-mix(in oklab, ${a} 75%, ${LIMB[1]}) 72%, ${LIMB[1]} 100%)`,\n  },\n  light: {\n    bg: \"#F5F4F0\",\n    fg: \"#111113\",\n    muted: \"#6E6C67\",\n    ground: [\n      `radial-gradient(46% 58% at 50% 52%, color-mix(in oklab, ${LIMB[0]} 90%, transparent) 0%, transparent 72%)`,\n      `radial-gradient(30% 34% at 50% 50%, color-mix(in oklab, ${LIMB[1]} 16%, transparent) 0%, transparent 80%)`,\n    ].join(\", \"),\n    init: (a: string) =>\n      `linear-gradient(120deg, ${LIMB[2]} 0%, ${a} 46%, ${LIMB[1]} 100%)`,\n  },\n} as const;\n\nconst TRACK_SHORT = -0.02;\nconst TRACK_FULL = -0.035;\nconst LINE = 1.08;\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\nconst EASE_OUT = Easing.bezier(0.22, 1, 0.36, 1);\nconst EASE_IO = Easing.bezier(0.72, 0, 0.18, 1);\nconst clamp01 = (v: number) => Math.min(1, Math.max(0, v));\n\ntype Measure = ((s: string) => number) & {\n  base: number;\n};\n\nfunction useMeasure(): Measure {\n  const [ready, setReady] = useState(false);\n  const [handle] = useState(() => delayRender(\"acronym-expand: measuring\"));\n  const released = useRef(false);\n  const ctxRef = useRef<CanvasRenderingContext2D | null>(null);\n\n  useEffect(() => {\n    let live = true;\n    const font = `500 100px \"${sora.fontFamily}\"`;\n    Promise.all([sora.waitUntilDone(), document.fonts.load(font)])\n      .catch(() => undefined)\n      .then(() => {\n        if (!live) return;\n        const ctx = document.createElement(\"canvas\").getContext(\"2d\");\n        if (ctx) ctx.font = font;\n        ctxRef.current = ctx;\n        setReady(true);\n        if (!released.current) {\n          released.current = true;\n          continueRender(handle);\n        }\n      });\n    return () => {\n      live = false;\n    };\n  }, [handle]);\n\n  const ctx = ready ? ctxRef.current : null;\n  const fn = (s: string) =>\n    ctx ? ctx.measureText(s).width / 100 : s.length * 0.6;\n  let asc = 0.97;\n  let desc = 0.24;\n  if (ctx) {\n    const m = ctx.measureText(\"Hg\");\n    asc = m.fontBoundingBoxAscent / 100 || asc;\n    desc = m.fontBoundingBoxDescent / 100 || desc;\n  }\n  return Object.assign(fn, { base: (LINE - asc - desc) / 2 + asc });\n}\n\nfunction matchInitials(short: string, full: string) {\n  const lower = full.toLowerCase();\n  const starts = new Set<number>();\n  for (let i = 0; i < full.length; i++) {\n    if (full[i] !== \" \" && (i === 0 || full[i - 1] === \" \")) starts.add(i);\n  }\n  const out: number[] = [];\n  let from = 0;\n  for (const ch of short.toLowerCase()) {\n    if (ch === \" \") {\n      out.push(-1);\n      continue;\n    }\n    let hit = -1;\n    for (let i = from; i < lower.length; i++) {\n      if (lower[i] === ch && starts.has(i)) {\n        hit = i;\n        break;\n      }\n    }\n    if (hit < 0) hit = lower.indexOf(ch, from);\n    out.push(hit);\n    if (hit >= 0) from = hit + 1;\n  }\n  return out;\n}\n\nfunction splitTwo(words: string[], measure: Measure) {\n  let best = { a: words.join(\" \"), b: \"\", w: Number.POSITIVE_INFINITY };\n  for (let k = 1; k < words.length; k++) {\n    const a = words.slice(0, k).join(\" \");\n    const b = words.slice(k).join(\" \");\n    const w = Math.max(measure(a), measure(b));\n    if (w < best.w) best = { a, b, w };\n  }\n  return best;\n}\n\ninterface Glyph {\n  ch: string;\n  x: number;\n  y: number;\n  fs: number;\n  w: number;\n}\n\nfunction placeLine(\n  text: string,\n  measure: Measure,\n  fs: number,\n  track: number,\n  cx: number,\n  top: number,\n): Glyph[] {\n  const total = measure(text) + track * Math.max(0, text.length - 1);\n  const left = cx - (total * fs) / 2;\n  const out: Glyph[] = [];\n  for (let i = 0; i < text.length; i++) {\n    const x = left + (measure(text.slice(0, i)) + track * i) * fs;\n    const w = (measure(text.slice(0, i + 1)) - measure(text.slice(0, i))) * fs;\n    out.push({ ch: text[i], x, y: top, fs, w });\n  }\n  return out;\n}\n\nexport function AcronymExpand({\n  short = \"MCP\",\n  full = \"Model Context Protocol\",\n  eyebrow = \"Now in remocn\",\n  subhead = \"Your agent browses, installs and edits every component.\",\n  accent = \"#3B5BFD\",\n  background,\n  speed = 1,\n  theme = \"dark\",\n}: AcronymExpandProps) {\n  const frame = useCurrentFrame() * speed;\n  const { width, height, durationInFrames } = useVideoConfig();\n  const t = THEMES[theme];\n  const measure = useMeasure();\n\n  const portrait = height > width * 1.1;\n  const s = portrait ? width / 1080 : Math.min(width / 1280, height / 720);\n  const maxW = width * (portrait ? 0.84 : 0.8);\n  const cx = width / 2;\n\n  const words = full.split(/\\s+/).filter(Boolean);\n  const oneEm = measure(full) + TRACK_FULL * Math.max(0, full.length - 1);\n  const capFull = (portrait ? 156 : 112) * s;\n  let lines = [words.join(\" \")];\n  let fsF = Math.min(capFull, maxW / Math.max(oneEm, 0.01));\n  if (words.length > 1) {\n    const two = splitTwo(words, measure);\n    const twoEm = two.w + TRACK_FULL * Math.max(two.a.length, two.b.length);\n    const fsTwo = Math.min(capFull, maxW / Math.max(twoEm, 0.01));\n    if (fsTwo > fsF * 1.3 || portrait) {\n      lines = [two.a, two.b];\n      fsF = fsTwo;\n    }\n  }\n\n  const eyeFs = (portrait ? 26 : 19) * s;\n  const subFs = (portrait ? 34 : 26) * s;\n  const eyeH = eyebrow ? eyeFs * 1.2 + fsF * 0.42 : 0;\n  const fullH = lines.length * LINE * fsF;\n  const subH = subhead ? fsF * 0.34 + subFs * 1.4 * (portrait ? 2 : 1) : 0;\n  const stackTop = height / 2 - (eyeH + fullH + subH) / 2;\n  const fullTop = stackTop + eyeH;\n  const fullCy = fullTop + fullH / 2;\n\n  const fullGlyphs: Glyph[] = [];\n  lines.forEach((ln, i) => {\n    for (const g of placeLine(\n      ln,\n      measure,\n      fsF,\n      TRACK_FULL,\n      cx,\n      fullTop + i * LINE * fsF,\n    )) {\n      fullGlyphs.push(g);\n    }\n    if (i < lines.length - 1)\n      fullGlyphs.push({ ch: \" \", x: 0, y: 0, fs: fsF, w: 0 });\n  });\n  const joined = lines.join(\" \");\n\n  const shortEm = measure(short) + TRACK_SHORT * Math.max(0, short.length - 1);\n  const fsS = Math.min(\n    (portrait ? 330 : 300) * s,\n    (maxW * 0.86) / Math.max(shortEm, 0.01),\n    height * 0.5,\n  );\n  const shortGlyphs = placeLine(\n    short,\n    measure,\n    fsS,\n    TRACK_SHORT,\n    cx,\n    fullCy - (LINE * fsS) / 2,\n  );\n\n  const anchors = matchInitials(short, joined);\n  const anchorOf = new Map<number, number>();\n  anchors.forEach((fi, si) => {\n    if (fi >= 0) anchorOf.set(fi, si);\n  });\n\n  const wordSpans: { a: number; b: number; anchor: number }[] = [];\n  {\n    const re = /\\S+/g;\n    for (let m = re.exec(joined); m; m = re.exec(joined)) {\n      const a = m.index;\n      const b = a + m[0].length;\n      let anchor = -1;\n      for (let i = a; i < b; i++) {\n        if (anchorOf.has(i)) {\n          anchor = i;\n          break;\n        }\n      }\n      wordSpans.push({ a, b, anchor });\n    }\n  }\n\n  const EXPAND = 38;\n  const EXPAND_LEN = 26;\n  const anchorT = (si: number) =>\n    EASE_IO(clamp01((frame - EXPAND - si * 2) / EXPAND_LEN));\n  const drift = interpolate(\n    frame,\n    [0, durationInFrames * speed],\n    [0, 1],\n    CLAMP,\n  );\n\n  type Draw = {\n    id: string;\n    ch: string;\n    x: number;\n    y: number;\n    fs: number;\n    opacity: number;\n    blur: number;\n    init: number;\n    z: number;\n  };\n  const draws: Draw[] = [];\n\n  const mid = (short.length - 1) / 2;\n  shortGlyphs.forEach((g, si) => {\n    if (g.ch === \" \") return;\n    const e = EASE_OUT(clamp01((frame - si * 3) / 18));\n    const spread = (1 - e) * (si - mid) * 0.14 * fsS;\n    const fi = anchors[si];\n    const u = anchorT(si);\n    if (fi < 0) {\n      const out = clamp01((frame - EXPAND) / 12);\n      draws.push({\n        id: `s${si}`,\n        ch: g.ch,\n        x: g.x + spread,\n        y: g.y + (1 - e) * 0.4 * fsS,\n        fs: g.fs,\n        opacity: e * (1 - out),\n        blur: (1 - e) * 0.05 * fsS + out * 0.04 * fsS,\n        init: 1,\n        z: 2,\n      });\n      return;\n    }\n    const f = fullGlyphs[fi];\n    const fs = g.fs + (f.fs - g.fs) * u;\n    const x = g.x + spread + (f.x - g.x) * u;\n    const y = g.y + (1 - e) * 0.4 * fsS + (f.y - g.y) * u;\n    const same = g.ch === f.ch;\n    const c = same ? 0 : interpolate(u, [0.35, 0.75], [0, 1], CLAMP);\n    draws.push({\n      id: `s${si}`,\n      ch: g.ch,\n      x,\n      y,\n      fs,\n      opacity: e * (1 - c),\n      blur: (1 - e) * 0.05 * fsS,\n      init: 1,\n      z: 2,\n    });\n    if (!same) {\n      draws.push({\n        id: `s${si}b`,\n        ch: f.ch,\n        x,\n        y,\n        fs,\n        opacity: c,\n        blur: 0,\n        init: 1,\n        z: 2,\n      });\n    }\n  });\n\n  type Tail = {\n    id: string;\n    text: string;\n    edge: number;\n    dir: 1 | -1;\n    y: number;\n    fs: number;\n    w: number;\n    v: number;\n    max: number;\n  };\n  const tails: Tail[] = [];\n  const runW = (txt: string, fs: number) =>\n    (measure(txt) + TRACK_FULL * txt.length) * fs;\n  const nowX = new Map<number, number>();\n  anchors.forEach((fi, si) => {\n    if (fi < 0) return;\n    const u = anchorT(si);\n    nowX.set(\n      fi,\n      shortGlyphs[si].x + (fullGlyphs[fi].x - shortGlyphs[si].x) * u,\n    );\n  });\n  const lineOf = (i: number) => (fullGlyphs[i].y > fullTop + 1 ? 1 : 0);\n  const room = (from: number, finalRight: number, now: number) => {\n    for (const span of wordSpans) {\n      if (span.a <= from || span.anchor < 0) continue;\n      if (lineOf(span.a) !== lineOf(from)) return Number.POSITIVE_INFINITY;\n      const nx = nowX.get(span.anchor) as number;\n      const head = fullGlyphs[span.anchor].x - fullGlyphs[span.a].x;\n      return nx - head - (fullGlyphs[span.a].x - finalRight) - now;\n    }\n    return Number.POSITIVE_INFINITY;\n  };\n  for (const span of wordSpans) {\n    if (span.anchor < 0) {\n      const v = EASE_OUT(clamp01((frame - EXPAND - 18) / 16));\n      for (let i = span.a; i < span.b; i++) {\n        const f = fullGlyphs[i];\n        draws.push({\n          id: `f${i}`,\n          ch: f.ch,\n          x: f.x,\n          y: f.y + (1 - v) * 0.22 * f.fs,\n          fs: f.fs,\n          opacity: v,\n          blur: (1 - v) * 0.06 * f.fs,\n          init: 0,\n          z: 1,\n        });\n      }\n      continue;\n    }\n    const si = anchorOf.get(span.anchor) as number;\n    const u = anchorT(si);\n    const af = fullGlyphs[span.anchor];\n    const sg = shortGlyphs[si];\n    const ax = sg.x + (af.x - sg.x) * u;\n    const ay = sg.y + (af.y - sg.y) * u;\n    const afs = sg.fs + (af.fs - sg.fs) * u;\n    const aw = af.w * (afs / af.fs);\n    const fs = af.fs;\n    const y = ay + (afs - fs) * measure.base;\n    const v = EASE_OUT(clamp01((frame - EXPAND - si * 2 - 8) / 22));\n    const after = joined.slice(span.anchor + 1, span.b);\n    const before = joined.slice(span.a, span.anchor);\n    if (after) {\n      const next = fullGlyphs[span.anchor + 1];\n      const gap = next.x - (af.x + af.w);\n      const w = runW(after, fs);\n      const edge = ax + aw + gap;\n      const finalRight = next.x + w;\n      tails.push({\n        id: `t${span.anchor}`,\n        text: after,\n        edge,\n        dir: 1,\n        y,\n        fs,\n        w,\n        v,\n        max: room(span.anchor, finalRight, edge),\n      });\n    }\n    if (before) {\n      const first = fullGlyphs[span.a];\n      tails.push({\n        id: `h${span.anchor}`,\n        text: before,\n        edge: ax - (af.x - first.x - runW(before, fs)),\n        dir: -1,\n        y,\n        fs,\n        w: runW(before, fs),\n        v,\n        max: Number.POSITIVE_INFINITY,\n      });\n    }\n  }\n\n  const eyeT = EASE_OUT(clamp01((frame - 60) / 18));\n  const subT = EASE_OUT(clamp01((frame - 66) / 20));\n  const transparent = background === \"transparent\";\n  const initImage = t.init(accent);\n\n  const glyphStyle = (d: Draw): React.CSSProperties => ({\n    position: \"absolute\",\n    left: d.x,\n    top: d.y,\n    fontFamily: sora.fontFamily,\n    fontWeight: 500,\n    fontSize: d.fs,\n    lineHeight: LINE,\n    whiteSpace: \"pre\",\n    opacity: d.opacity,\n    zIndex: d.z,\n    filter: d.blur > 0.05 ? `blur(${d.blur.toFixed(2)}px)` : undefined,\n    ...(d.init\n      ? {\n          backgroundImage: initImage,\n          backgroundSize: `${width}px ${height}px`,\n          backgroundPosition: `${-d.x + (drift - 0.5) * width * 0.08}px ${-d.y}px`,\n          WebkitBackgroundClip: \"text\",\n          backgroundClip: \"text\",\n          color: \"transparent\",\n        }\n      : { color: t.fg }),\n  });\n\n  return (\n    <AbsoluteFill\n      style={{\n        background: transparent ? \"transparent\" : (background ?? t.bg),\n        overflow: \"hidden\",\n      }}\n    >\n      {!transparent && background === undefined ? (\n        <div\n          style={{\n            position: \"absolute\",\n            inset: 0,\n            background: t.ground,\n            transform: `scale(${1.04 + drift * 0.04})`,\n          }}\n        />\n      ) : null}\n\n      {eyebrow ? (\n        <div\n          style={{\n            position: \"absolute\",\n            left: 0,\n            right: 0,\n            top: stackTop + (1 - eyeT) * 10 * s,\n            display: \"flex\",\n            justifyContent: \"center\",\n            alignItems: \"center\",\n            gap: eyeFs * 0.6,\n            fontFamily: mono.fontFamily,\n            fontWeight: 500,\n            fontSize: eyeFs,\n            lineHeight: 1.2,\n            letterSpacing: \"0.12em\",\n            textTransform: \"uppercase\",\n            color: t.muted,\n            opacity: eyeT,\n          }}\n        >\n          <span\n            style={{\n              width: eyeFs * 0.42,\n              height: eyeFs * 0.42,\n              borderRadius: 999,\n              background: accent,\n            }}\n          />\n          {eyebrow}\n        </div>\n      ) : null}\n\n      {tails.map((tl) => {\n        const pad = tl.fs * 0.25;\n        const open = Math.max(\n          0,\n          Math.min(tl.w * tl.v + pad * tl.v, tl.max + pad * 0.2),\n        );\n        return (\n          <div\n            key={tl.id}\n            style={{\n              position: \"absolute\",\n              left: tl.dir === 1 ? tl.edge : tl.edge - open,\n              top: tl.y - pad,\n              width: open,\n              height: LINE * tl.fs + pad * 2,\n              overflow: \"hidden\",\n              zIndex: 1,\n            }}\n          >\n            <span\n              style={{\n                position: \"absolute\",\n                top: pad,\n                ...(tl.dir === 1 ? { left: 0 } : { right: 0 }),\n                fontFamily: sora.fontFamily,\n                fontWeight: 500,\n                fontSize: tl.fs,\n                lineHeight: LINE,\n                letterSpacing: `${TRACK_FULL}em`,\n                whiteSpace: \"pre\",\n                color: t.fg,\n                transform: `translateX(${(-(1 - tl.v) * tl.w * 0.45 * tl.dir).toFixed(2)}px)`,\n                filter:\n                  tl.v < 0.98\n                    ? `blur(${((1 - tl.v) * 0.04 * tl.fs).toFixed(2)}px)`\n                    : undefined,\n              }}\n            >\n              {tl.text}\n            </span>\n          </div>\n        );\n      })}\n\n      {draws.map((d) => (\n        <div key={d.id} style={glyphStyle(d)}>\n          {d.ch}\n        </div>\n      ))}\n\n      {subhead ? (\n        <div\n          style={{\n            position: \"absolute\",\n            left: (width - Math.min(maxW, 820 * s * (portrait ? 1.1 : 1))) / 2,\n            width: Math.min(maxW, 820 * s * (portrait ? 1.1 : 1)),\n            top: fullTop + fullH + fsF * 0.34 + (1 - subT) * 12 * s,\n            textAlign: \"center\",\n            fontFamily: sora.fontFamily,\n            fontWeight: 400,\n            fontSize: subFs,\n            lineHeight: 1.4,\n            letterSpacing: \"-0.01em\",\n            color: t.muted,\n            textWrap: \"balance\",\n            opacity: subT,\n            filter: `blur(${((1 - subT) * 5 * s).toFixed(2)}px)`,\n          }}\n        >\n          {subhead}\n        </div>\n      ) : null}\n    </AbsoluteFill>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/acronym-expand.tsx"
    }
  ],
  "type": "registry:component"
}
