{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "fine-print-up",
  "title": "Fine Print Up",
  "description": "\"No account and no watermark. Ever.\" in a big serif with tiny fine print at the bottom.",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "files": [
    {
      "path": "registry/remocn/fine-print-up/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont } from \"@remotion/google-fonts/Gloock\";\nimport type React from \"react\";\nimport { useEffect, useState } from \"react\";\nimport {\n  AbsoluteFill,\n  continueRender,\n  delayRender,\n  Easing,\n  interpolate,\n  interpolateColors,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\n\nconst gloock = loadFont(\"normal\", { weights: [\"400\"], subsets: [\"latin\"] });\n\nexport interface FinePrintUpProps {\n  lines?: string[];\n  closing?: string;\n  accent?: string;\n  background?: string;\n  speed?: number;\n  theme?: \"dark\" | \"light\";\n}\n\nconst DEFAULT_LINES = [\n  \"Every component you install is a file you own.\",\n  \"Use it in paid client work. It’s MIT.\",\n  \"No account and no watermark. Ever.\",\n];\n\nconst THEMES = {\n  dark: {\n    bg: \"#0A1230\",\n    ink: \"#FFFFFF\",\n    muted: \"rgba(255,255,255,0.58)\",\n    accent: \"#FF4436\",\n  },\n  light: {\n    bg: \"#F7F3EC\",\n    ink: \"#14161F\",\n    muted: \"rgba(20,22,31,0.6)\",\n    accent: \"#D92B1E\",\n  },\n} as const;\n\nconst TRACK = -0.02;\nconst LH = 1.08;\nconst FINE_LH = 1.3;\nconst START = 10;\nconst TRAVEL = 26;\nconst TAIL = 76;\nconst EASE_OUT = Easing.bezier(0.22, 1, 0.36, 1);\nconst EASE_IO = Easing.bezier(0.65, 0, 0.35, 1);\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\nlet measureCtx: CanvasRenderingContext2D | null = null;\n\nfunction em(s: string): number {\n  if (!measureCtx) {\n    measureCtx = document.createElement(\"canvas\").getContext(\"2d\");\n  }\n  if (!measureCtx) return s.length * 0.5;\n  measureCtx.font = `400 100px \"${gloock.fontFamily}\"`;\n  return measureCtx.measureText(s).width / 100 + TRACK * Array.from(s).length;\n}\n\nfunction useFontReady() {\n  const [ready, setReady] = useState(false);\n  const [handle] = useState(() => delayRender(\"fine-print-up: font\"));\n  useEffect(() => {\n    let live = true;\n    gloock\n      .waitUntilDone()\n      .then(() => document.fonts.load(`400 100px \"${gloock.fontFamily}\"`))\n      .catch(() => undefined)\n      .then(() => {\n        if (!live) return;\n        setReady(true);\n        continueRender(handle);\n      });\n    return () => {\n      live = false;\n    };\n  }, [handle]);\n  return ready;\n}\n\ninterface Laid {\n  words: { text: string; x: number; line: number }[];\n  lines: number;\n}\n\nfunction wrapAt(words: string[], maxEm: number, indent = 0): Laid {\n  const space = em(\" \");\n  const out: { text: string; x: number; line: number }[] = [];\n  let line = 0;\n  let x = indent;\n  for (const w of words) {\n    const ww = em(w);\n    if (x > indent && x + ww > maxEm) {\n      line += 1;\n      x = indent;\n    }\n    out.push({ text: w, x, line });\n    x += ww + space;\n  }\n  return { words: out, lines: line + 1 };\n}\n\nfunction balanced(words: string[], maxEm: number): Laid {\n  const base = wrapAt(words, maxEm);\n  let lo = Math.max(...words.map(em), 0.1);\n  let hi = maxEm;\n  for (let i = 0; i < 14; i++) {\n    const mid = (lo + hi) / 2;\n    if (wrapAt(words, mid).lines <= base.lines) hi = mid;\n    else lo = mid;\n  }\n  return wrapAt(words, hi);\n}\n\nfunction fitSize(words: string[], boxW: number, boxH: number, maxF: number) {\n  const widest = Math.max(...words.map(em), 0.1);\n  let lo = 8;\n  let hi = maxF;\n  for (let i = 0; i < 18; i++) {\n    const mid = (lo + hi) / 2;\n    const lay = wrapAt(words, boxW / mid);\n    if (lay.lines * LH * mid <= boxH && widest * mid <= boxW) lo = mid;\n    else hi = mid;\n  }\n  return lo;\n}\n\nexport function FinePrintUp({\n  lines = DEFAULT_LINES,\n  closing = \"That’s all the fine print.\",\n  accent,\n  background,\n  speed = 1,\n  theme = \"dark\",\n}: FinePrintUpProps) {\n  const frame = useCurrentFrame();\n  const t = frame * speed;\n  const { width: W, height: H, durationInFrames } = useVideoConfig();\n  const c = THEMES[theme];\n  const hi = accent ?? c.accent;\n  const stage =\n    background === \"transparent\" ? \"transparent\" : (background ?? c.bg);\n  const ready = useFontReady();\n\n  if (!ready || lines.length === 0) {\n    return (\n      <div style={{ position: \"absolute\", inset: 0, background: stage }} />\n    );\n  }\n\n  const n = lines.length;\n  const portrait = H > W * 1.1;\n  const mx = W * (portrait ? 0.08 : 0.07);\n  const headTop = H * (portrait ? 0.1 : 0.11);\n  const boxW = W * (portrait ? 0.84 : 0.78);\n  const boxH = H * (portrait ? 0.42 : 0.56);\n  const fs = H * (portrait ? 0.017 : 0.028);\n  const fineW = W * (portrait ? 0.62 : 0.34);\n  const fineX = W - mx - fineW;\n  const fineBottom = H - H * (portrait ? 0.07 : 0.09);\n\n  const words = lines.map((l) => l.split(/\\s+/).filter(Boolean));\n  const marks = lines.map((_, i) => \"*\".repeat(i + 1));\n  const markW = em(\"***\") + em(\" \") * 0.6;\n  const fineLays = words.map((ws) => wrapAt(ws, fineW / fs - markW));\n  const fineHeights = fineLays.map((l) => l.lines * FINE_LH * fs);\n  const fineGap = fs * 0.7;\n  const fineTotal =\n    fineHeights.reduce((a, b) => a + b, 0) + fineGap * Math.max(0, n - 1);\n  const fineTops: number[] = [];\n  let acc = fineBottom - fineTotal;\n  for (let i = 0; i < n; i++) {\n    fineTops.push(acc);\n    acc += fineHeights[i] + fineGap;\n  }\n\n  const heads = words.map((ws) => {\n    const F = fitSize(ws, boxW, boxH, H * (portrait ? 0.1 : 0.15));\n    return { F, lay: balanced(ws, boxW / F) };\n  });\n\n  const D = durationInFrames * speed;\n  const per = Math.max(50, (D - START - TAIL) / n);\n  const stepAt = (i: number) => START + i * per;\n  const closeAt = stepAt(n - 1) + TRAVEL + 26;\n\n  const intro = interpolate(t, [0, 12], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n\n  const nodes: React.ReactNode[] = [];\n  const text = (\n    key: string,\n    s: string,\n    x: number,\n    y: number,\n    size: number,\n    renderSize: number,\n    lh: number,\n    color: string,\n    opacity: number,\n  ) => (\n    <div\n      key={key}\n      style={{\n        position: \"absolute\",\n        left: 0,\n        top: 0,\n        fontFamily: gloock.fontFamily,\n        fontWeight: 400,\n        fontSize: renderSize,\n        lineHeight: `${lh * renderSize}px`,\n        letterSpacing: `${TRACK}em`,\n        whiteSpace: \"pre\",\n        color,\n        opacity,\n        transformOrigin: \"0 0\",\n        transform: `translate(${x.toFixed(2)}px, ${y.toFixed(2)}px) scale(${(size / renderSize).toFixed(4)})`,\n      }}\n    >\n      {s}\n    </div>\n  );\n\n  lines.forEach((_, i) => {\n    const s0 = stepAt(i);\n    const u = t - s0;\n    const { F, lay } = heads[i];\n    const fl = fineLays[i];\n    const pick = interpolate(u, [-2, 6], [0, 1], CLAMP);\n    const exit =\n      i < n - 1\n        ? interpolate(t, [stepAt(i + 1), stepAt(i + 1) + 12], [0, 1], {\n            ...CLAMP,\n            easing: Easing.bezier(0.55, 0, 1, 0.45),\n          })\n        : 0;\n    if (exit >= 1) return;\n\n    const markOp = interpolate(u, [4, 14], [1, 0], CLAMP) * intro;\n    if (markOp > 0) {\n      nodes.push(\n        text(\n          `m${i}`,\n          marks[i],\n          fineX,\n          fineTops[i],\n          fs,\n          fs,\n          FINE_LH,\n          interpolateColors(pick, [0, 1], [c.muted, hi]),\n          markOp,\n        ),\n      );\n    }\n\n    const count = lay.words.length;\n    const stagger = Math.min(1.4, 12 / Math.max(1, count));\n    lay.words.forEach((hw, wi) => {\n      const fw = fl.words[wi];\n      const fx = fineX + (markW + fw.x) * fs;\n      const fy = fineTops[i] + fw.line * FINE_LH * fs;\n      const hx = mx + hw.x * F;\n      const hy = headTop + hw.line * LH * F;\n      const move = interpolate(\n        u,\n        [6 + wi * stagger, 6 + wi * stagger + TRAVEL],\n        [0, 1],\n        { ...CLAMP, easing: EASE_IO },\n      );\n      const fyScaled = fy + (FINE_LH - LH) * fs * 0.5;\n      const x = fx + (hx - fx) * move;\n      const y = fyScaled + (hy - fyScaled) * move - exit * F * 0.18;\n      const size = fs + (F - fs) * move;\n      const land = interpolate(move, [0.7, 1], [0, 1], CLAMP);\n      const flyColor = interpolateColors(pick, [0, 1], [c.muted, hi]);\n      const baseColor = interpolateColors(land, [0, 1], [flyColor, c.ink]);\n      nodes.push(\n        text(\n          `w${i}-${wi}`,\n          hw.text,\n          x,\n          y,\n          size,\n          F,\n          LH,\n          baseColor,\n          intro * (1 - exit),\n        ),\n      );\n    });\n  });\n\n  const closeIn = interpolate(t, [closeAt, closeAt + 16], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n  if (closeIn > 0 && closing) {\n    const cl = wrapAt(closing.split(/\\s+/), fineW / fs);\n    const ch = cl.lines * FINE_LH * fs;\n    cl.words.forEach((w, wi) => {\n      nodes.push(\n        text(\n          `c${wi}`,\n          w.text,\n          fineX + w.x * fs,\n          fineBottom - ch + w.line * FINE_LH * fs + (1 - closeIn) * fs * 0.6,\n          fs,\n          fs,\n          FINE_LH,\n          c.muted,\n          closeIn,\n        ),\n      );\n    });\n  }\n\n  return (\n    <AbsoluteFill style={{ background: stage, overflow: \"hidden\" }}>\n      {nodes}\n    </AbsoluteFill>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/fine-print-up.tsx"
    }
  ],
  "type": "registry:component"
}
