{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "uncomment-line",
  "title": "Uncomment Line",
  "description": "Three lines are uncommented one by one in code style: 'Fork the scenes. Change anything. Own the cut.'.",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "files": [
    {
      "path": "registry/remocn/uncomment-line/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont as loadGeist } from \"@remotion/google-fonts/Geist\";\nimport { loadFont as loadGeistMono } from \"@remotion/google-fonts/GeistMono\";\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 geist = loadGeist(\"normal\", {\n  weights: [\"500\"],\n  subsets: [\"latin\"],\n});\nconst geistMono = loadGeistMono(\"normal\", {\n  weights: [\"400\"],\n  subsets: [\"latin\"],\n});\n\nexport interface UncommentLineProps {\n  lines?: string[];\n  marker?: string;\n  highlight?: number;\n  accent?: string;\n  background?: string;\n  speed?: number;\n  theme?: \"dark\" | \"light\";\n}\n\nconst THEMES = {\n  dark: { pink: \"#F472B6\", bg: \"#14151A\", ink: \"#FBF0DF\" },\n  light: { pink: \"#C2185B\", bg: \"#FBF0DF\", ink: \"#14151A\" },\n} as const;\n\nconst TRACK = -0.035;\nconst LEADING = 1.06;\nconst MARK_SCALE = 0.62;\nconst DIM = 0.28;\n\nconst RISE_LEN = 16;\nconst RISE_GAP = 4;\nconst OPEN_AT = 34;\nconst OPEN_GAP = 13;\nconst OPEN_LEN = 14;\n\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\ninterface Metrics {\n  lines: number[];\n  marker: number;\n  cap: number;\n  base: number;\n  baseM: number;\n}\n\nconst baseOf = (asc: number, desc: number) => (1 - (asc + desc)) / 2 + asc;\n\nfunction measure(lines: string[], marker: string): Metrics {\n  const ctx = document.createElement(\"canvas\").getContext(\"2d\");\n  if (!ctx) throw new Error(\"uncomment-line: no 2d context\");\n  ctx.font = `500 100px \"${geist.fontFamily}\"`;\n  const widths = lines.map(\n    (s) =>\n      ctx.measureText(s).width / 100 +\n      TRACK * Math.max(0, Array.from(s).length - 1),\n  );\n  const hm = ctx.measureText(\"H\");\n  ctx.font = `400 100px \"${geistMono.fontFamily}\"`;\n  const mm = ctx.measureText(marker);\n  return {\n    lines: widths,\n    marker: mm.width / 100,\n    cap: hm.actualBoundingBoxAscent / 100,\n    base: baseOf(\n      hm.fontBoundingBoxAscent / 100,\n      hm.fontBoundingBoxDescent / 100,\n    ),\n    baseM: baseOf(\n      mm.fontBoundingBoxAscent / 100,\n      mm.fontBoundingBoxDescent / 100,\n    ),\n  };\n}\n\nfunction useMetrics(lines: string[], marker: string) {\n  const key = [marker, ...lines].join(\"\\u0001\");\n  const [state, setState] = useState<{ key: string; m: Metrics } | null>(null);\n  const [handle] = useState(() => delayRender(\"uncomment-line: measuring\"));\n  const released = useRef(false);\n  useEffect(() => {\n    let live = true;\n    const [mk, ...ls] = key.split(\"\\u0001\");\n    Promise.all([\n      geist.waitUntilDone(),\n      geistMono.waitUntilDone(),\n      document.fonts.load(`500 100px \"${geist.fontFamily}\"`),\n      document.fonts.load(`400 100px \"${geistMono.fontFamily}\"`),\n    ])\n      .catch(() => undefined)\n      .then(() => {\n        if (!live) return;\n        setState({ key, m: measure(ls, mk) });\n        if (!released.current) {\n          released.current = true;\n          continueRender(handle);\n        }\n      });\n    return () => {\n      live = false;\n    };\n  }, [key, handle]);\n  return state && state.key === key ? state.m : null;\n}\n\nexport function UncommentLine({\n  lines = [\"Fork the scenes.\", \"Change anything.\", \"Own the cut.\"],\n  marker = \"// \",\n  highlight = -1,\n  accent,\n  background,\n  speed = 1,\n  theme = \"dark\",\n}: UncommentLineProps) {\n  const t = useCurrentFrame() * speed;\n  const { width: W, height: H } = useVideoConfig();\n  const c = THEMES[theme];\n  const spot = accent ?? c.pink;\n  const list = lines.length > 0 ? lines : [\" \"];\n  const m = useMetrics(list, marker);\n\n  const transparent = background === \"transparent\";\n  const stage = transparent ? \"transparent\" : (background ?? c.bg);\n  if (!m) {\n    return (\n      <div style={{ position: \"absolute\", inset: 0, background: stage }} />\n    );\n  }\n\n  const hl = highlight < 0 ? list.length + highlight : highlight;\n  const portrait = H > W * 1.1;\n  const margin = Math.min(W, H) * (portrait ? 0.08 : 0.085);\n  const measureW = W - 2 * margin;\n  const markEm = m.marker * MARK_SCALE;\n  const widest = Math.max(...m.lines) + markEm;\n  const F = Math.min(\n    (H * (portrait ? 0.4 : 0.7)) / (list.length * LEADING),\n    measureW / widest,\n  );\n  const lineH = F * LEADING;\n  const blockH = lineH * (list.length - 1) + m.cap * F;\n  const firstBase = (H - blockH) / 2 + m.cap * F;\n  const M = F * MARK_SCALE;\n\n  const nodes = list.map((line, i) => {\n    const baseY = firstBase + i * lineH;\n    const r = interpolate(t, [i * RISE_GAP, i * RISE_GAP + RISE_LEN], [0, 1], {\n      ...CLAMP,\n      easing: EASE_OUT,\n    });\n    const at = OPEN_AT + i * OPEN_GAP;\n    const o = interpolate(t, [at, at + OPEN_LEN], [0, 1], {\n      ...CLAMP,\n      easing: EASE_IO,\n    });\n    const lit = interpolate(t, [at + 2, at + OPEN_LEN], [0, 1], {\n      ...CLAMP,\n      easing: EASE_OUT,\n    });\n    const textLeft = margin + markEm * F * (1 - o);\n    const h = F * 1.3;\n    const top = baseY - F * 1.05;\n    const drop = (1 - r) * h;\n    const color = i === hl ? spot : c.ink;\n    const markOpacity = 1 - interpolate(o, [0, 0.6], [0, 1], CLAMP);\n    return (\n      <div key={`l${i}`}>\n        {markOpacity > 0.001 ? (\n          <div\n            style={{\n              position: \"absolute\",\n              left: margin - F * 0.05,\n              top,\n              width: markEm * F + F * 0.1,\n              height: h,\n              overflow: \"hidden\",\n            }}\n          >\n            <div\n              style={{\n                position: \"absolute\",\n                left: F * 0.05 - o * markEm * F * 0.6,\n                top: F * 1.05 - m.baseM * M + drop,\n                height: M,\n                lineHeight: `${M}px`,\n                fontFamily: geistMono.fontFamily,\n                fontWeight: 400,\n                fontSize: M,\n                whiteSpace: \"pre\",\n                color: spot,\n                opacity: markOpacity,\n              }}\n            >\n              {marker}\n            </div>\n          </div>\n        ) : null}\n        <div\n          style={{\n            position: \"absolute\",\n            left: textLeft - F * 0.05,\n            top,\n            width: m.lines[i] * F + F * 0.2,\n            height: h,\n            overflow: \"hidden\",\n          }}\n        >\n          <div\n            style={{\n              position: \"absolute\",\n              left: F * 0.05,\n              top: F * 1.05 - m.base * F + drop,\n              height: F,\n              lineHeight: `${F}px`,\n              fontFamily: geist.fontFamily,\n              fontWeight: 500,\n              fontSize: F,\n              letterSpacing: `${TRACK}em`,\n              whiteSpace: \"pre\",\n              color,\n              opacity: DIM + (1 - DIM) * lit,\n            }}\n          >\n            {line}\n          </div>\n        </div>\n      </div>\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/uncomment-line.tsx"
    }
  ],
  "type": "registry:component"
}
