{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "replay-wipe",
  "title": "Replay Wipe",
  "description": "Broadcast-style replay wipes cut between two shots under a LIVE frame.",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "files": [
    {
      "path": "registry/remocn/replay-wipe/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont } from \"@remotion/google-fonts/BarlowCondensed\";\nimport type React from \"react\";\nimport { useId } from \"react\";\nimport {\n  AbsoluteFill,\n  Easing,\n  interpolate,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\n\nconst { fontFamily: condensed } = loadFont(\"normal\", {\n  weights: [\"500\"],\n  subsets: [\"latin\"],\n});\n\nconst REMOCN_R_PATH =\n  \"M 0.01 0.81 C 0.01 1.73, 0.36 2.79, 1.09 4.13 C 4.91 11.04, 13.45 17.16, 21.7 18.9 C 22.94 19.16, 23.18 19.16, 51.39 19.27 C 76.07 19.36, 80.02 19.4, 81.32 19.57 C 89.89 20.69, 96.2 24.68, 99.38 31.01 C 103.19 38.56, 102.53 50.1, 97.91 57.07 C 94.66 61.96, 89.68 64.99, 83.26 66 C 82.81 66.07, 70.18 66.83, 55.2 67.69 C 24.82 69.43, 27.03 69.23, 24.18 70.4 C 19.9 72.15, 14.84 75.7, 10.65 79.89 C 4.86 85.68, 1.3 91.91, 0.25 98.13 C 0.12 98.85, 0.08 103.13, 0.04 116.66 L 0 134.26 9.5 134.26 L 19 134.26 19.05 119.41 C 19.1 103.27, 19.08 103.82, 19.82 101.04 C 21.79 93.65, 27.86 88.75, 36.45 87.63 C 37.23 87.53, 39.41 87.5, 43.57 87.53 C 50.12 87.59, 50.75 87.65, 53.22 88.45 C 56.61 89.56, 59.67 91.86, 62.02 95.07 C 62.52 95.76, 69.35 103.85, 77.2 113.07 C 85.04 122.28, 91.63 130.04, 91.85 130.32 C 92.07 130.59, 92.5 131.34, 92.82 131.97 C 93.52 133.35, 94.11 133.93, 95.06 134.13 C 95.5 134.23, 98.97 134.26, 106.36 134.23 L 117.01 134.19 100.82 113.07 C 91.91 101.45, 84.52 91.78, 84.39 91.57 C 83.36 89.89, 83.66 87.53, 85.09 86 C 85.79 85.25, 86.36 84.94, 88.07 84.38 C 96.18 81.72, 104.15 76.62, 109.97 70.36 C 120.59 58.93, 124.06 44.32, 119.44 30.43 C 114.59 15.81, 101.93 4.02, 87.64 0.83 C 83.93 0.01, 88.09 0.08, 41.85 0.04 L 0.01 0 0.01 0.81 Z\";\nconst R_W = 124.06;\nconst R_H = 134.26;\n\n/** The \"R\" mark alone (viewBox 124.06 × 134.26). Fill follows `color`. */\nfunction RemocnR({ height, color }: { height: number; color: string }) {\n  return (\n    <svg\n      viewBox={`0 0 ${R_W} ${R_H}`}\n      height={height}\n      width={(height * R_W) / R_H}\n      style={{ display: \"block\" }}\n      aria-hidden\n    >\n      <path fill={color} d={REMOCN_R_PATH} />\n    </svg>\n  );\n}\n\nexport interface ReplayWipeProps {\n  /** The shot before the first wipe (and after every second one). Defaults to a \"Live\" broadcast frame. */\n  from?: React.ReactNode;\n  /** The shot after the first wipe. Defaults to a slow-mo \"Replay\" frame. */\n  to?: React.ReactNode;\n  /** Frames where a wipe starts. Shots alternate from → to → from… */\n  wipeAt?: number[];\n  /** Frames the R takes to cross the frame. 15–20 reads as a stinger. */\n  wipeLength?: number;\n  /** The live marker in the default \"Live\" shot. */\n  accent?: string;\n  theme?: \"dark\" | \"light\";\n  speed?: number;\n}\n\n// Beat sheet (30fps, speed 1, defaults):\n//   0–26    \"Live\" shot: huge type pans slowly, the clock bug ticks\n//  26–44    stinger: the remocn R spins across on the head of a \"fluted\"\n//           gradient streak; the streak's slanted head wipes Live → Replay,\n//           speed lines run with it, a flash + camera kick at mid-frame\n//  44–84    \"Replay\" shot in slow motion on the gradient ground\n//  84–102   the same stinger back to Live\n// 102–      Live holds\nconst SWEEP = Easing.bezier(0.55, 0, 0.4, 1);\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\n// gradients.sh \"fluted\": bg #050507, #1d2a8f, #2f7bff, #ff7a3d, #ffe2c4.\nconst FLUTED = [\"#1D2A8F\", \"#2F7BFF\", \"#FF7A3D\", \"#FFE2C4\"] as const;\n\nconst THEMES = {\n  dark: {\n    stage: \"#0A0A0B\",\n    ink: \"#F3F2EF\",\n    dim: \"#86858C\",\n    tab: \"#1C1C20\",\n    tabInk: \"#F3F2EF\",\n  },\n  light: {\n    stage: \"#F5F4F0\",\n    ink: \"#121214\",\n    dim: \"#7E7D77\",\n    tab: \"#121214\",\n    tabInk: \"#F5F4F0\",\n  },\n} as const;\n\n/** A short hit: up in 2 frames, eases back over 9. */\nfunction kick(d: number) {\n  if (d < 0) return 0;\n  if (d < 2) return d / 2;\n  const k = Math.max(0, 1 - (d - 2) / 9);\n  return k * k;\n}\n\nfunction LiveShot({\n  theme,\n  accent,\n  speed,\n}: {\n  theme: \"dark\" | \"light\";\n  accent: string;\n  speed: number;\n}) {\n  const t = useCurrentFrame() * speed;\n  const { width: W, height: H } = useVideoConfig();\n  const c = THEMES[theme];\n  const u = Math.min(W / 1280, H / 720);\n  const pan = interpolate(t, [0, 150], [0.025 * W, -0.025 * W], CLAMP);\n  const secs = 12 + Math.floor(t / 30);\n  const clock = `89:${String(secs % 60).padStart(2, \"0\")}`;\n  return (\n    <AbsoluteFill style={{ background: c.stage }}>\n      <div\n        style={{\n          position: \"absolute\",\n          inset: 0,\n          display: \"flex\",\n          alignItems: \"center\",\n          justifyContent: \"center\",\n          transform: `translateX(${pan}px)`,\n          fontFamily: condensed,\n          fontWeight: 500,\n          fontSize: 640 * u,\n          lineHeight: 1,\n          letterSpacing: \"-0.01em\",\n          color: c.ink,\n          paddingTop: 70 * u,\n        }}\n      >\n        LIVE\n      </div>\n      <div\n        style={{\n          position: \"absolute\",\n          left: 48 * u,\n          top: 44 * u,\n          display: \"flex\",\n          height: 46 * u,\n          fontFamily: condensed,\n          fontWeight: 500,\n          fontSize: 26 * u,\n          letterSpacing: \"0.1em\",\n          textTransform: \"uppercase\",\n          lineHeight: 1,\n        }}\n      >\n        <div\n          style={{\n            display: \"flex\",\n            alignItems: \"center\",\n            gap: 10 * u,\n            padding: `0 ${16 * u}px`,\n            background: accent,\n            color: \"#FFFFFF\",\n          }}\n        >\n          <div\n            style={{\n              width: 10 * u,\n              height: 10 * u,\n              background: \"#FFFFFF\",\n              opacity: Math.floor(t / 15) % 2 === 0 ? 1 : 0.35,\n            }}\n          />\n          <span style={{ paddingTop: 2 * u }}>Live</span>\n        </div>\n        <div\n          style={{\n            display: \"flex\",\n            alignItems: \"center\",\n            padding: `0 ${16 * u}px`,\n            background: c.tab,\n            color: c.tabInk,\n            fontVariantNumeric: \"tabular-nums\",\n          }}\n        >\n          <span style={{ paddingTop: 2 * u }}>{clock}</span>\n        </div>\n      </div>\n    </AbsoluteFill>\n  );\n}\n\nfunction ReplayShot({ speed }: { speed: number }) {\n  const t = useCurrentFrame() * speed;\n  const { width: W, height: H } = useVideoConfig();\n  const u = Math.min(W / 1280, H / 720);\n  // Slow motion: the type creeps and the ground barely drifts.\n  const creep = interpolate(t, [0, 150], [-0.012 * W, 0.012 * W], CLAMP);\n  const grow = interpolate(t, [0, 150], [1, 1.03], CLAMP);\n  const drift = interpolate(t, [0, 150], [0, 12], CLAMP);\n  const ground = [\n    `repeating-linear-gradient(90deg, rgba(5,5,7,0.16) 0px, rgba(255,255,255,0.07) ${22 * u}px, rgba(5,5,7,0.16) ${44 * u}px)`,\n    `radial-gradient(60% 80% at ${86 - drift}% 110%, ${FLUTED[3]} 0%, transparent 60%)`,\n    `radial-gradient(70% 90% at ${70 - drift}% 90%, ${FLUTED[2]} 0%, transparent 70%)`,\n    `linear-gradient(125deg, #0B1250 0%, ${FLUTED[0]} 30%, ${FLUTED[1]} 62%, #7A6BD0 100%)`,\n  ].join(\", \");\n  return (\n    <AbsoluteFill style={{ background: ground }}>\n      <div\n        style={{\n          position: \"absolute\",\n          inset: 0,\n          display: \"flex\",\n          alignItems: \"center\",\n          justifyContent: \"center\",\n          transform: `translateX(${creep}px) scale(${grow})`,\n          fontFamily: condensed,\n          fontWeight: 500,\n          fontSize: 420 * u,\n          lineHeight: 1,\n          letterSpacing: \"0.005em\",\n          color: \"#FFFFFF\",\n          paddingTop: 44 * u,\n        }}\n      >\n        REPLAY\n      </div>\n      <div\n        style={{\n          position: \"absolute\",\n          left: 48 * u,\n          top: 44 * u,\n          display: \"flex\",\n          height: 46 * u,\n          fontFamily: condensed,\n          fontWeight: 500,\n          fontSize: 26 * u,\n          letterSpacing: \"0.1em\",\n          textTransform: \"uppercase\",\n          lineHeight: 1,\n        }}\n      >\n        <div\n          style={{\n            display: \"flex\",\n            alignItems: \"center\",\n            gap: 10 * u,\n            padding: `0 ${16 * u}px`,\n            background: \"#FFFFFF\",\n            color: \"#0A0A0B\",\n          }}\n        >\n          <RemocnR height={20 * u} color=\"#0A0A0B\" />\n          <span style={{ paddingTop: 2 * u }}>Replay</span>\n        </div>\n        <div\n          style={{\n            display: \"flex\",\n            alignItems: \"center\",\n            padding: `0 ${16 * u}px`,\n            background: \"rgba(5,5,7,0.55)\",\n            color: \"#FFFFFF\",\n          }}\n        >\n          <span style={{ paddingTop: 2 * u }}>Super slow-mo</span>\n        </div>\n      </div>\n    </AbsoluteFill>\n  );\n}\n\nexport function ReplayWipe({\n  from,\n  to,\n  wipeAt = [26, 84],\n  wipeLength = 18,\n  accent = \"#3B5BFD\",\n  theme = \"dark\",\n  speed = 1,\n}: ReplayWipeProps) {\n  const t = useCurrentFrame() * speed;\n  const { width: W, height: H } = useVideoConfig();\n  const u = Math.min(W / 1280, H / 720);\n  const uid = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n\n  const shots = [\n    from ?? <LiveShot theme={theme} accent={accent} speed={speed} />,\n    to ?? <ReplayShot speed={speed} />,\n  ];\n\n  const len = Math.max(1, wipeLength);\n  const starts = [...wipeAt].sort((a, b) => a - b);\n  const done = starts.filter((w) => t >= w + len).length;\n  const active = starts.find((w) => t >= w && t < w + len);\n  const outgoing = shots[done % 2];\n  const incoming = shots[(done + 1) % 2];\n\n  // Streak geometry: a slanted band whose head (x at mid-height = X) is the\n  // wipe edge. The incoming shot shows left of the head.\n  const slant = 0.3 * H;\n  const tail = 0.62 * W;\n  const x0 = -slant / 2 - 20 * u;\n  const x1 = W + tail + slant / 2 + 20 * u;\n  const p = active === undefined ? 0 : SWEEP((t - active) / len);\n  const X = x0 + (x1 - x0) * p;\n  const edgeTop = X + slant / 2;\n  const edgeBottom = X - slant / 2;\n\n  // Flash and camera kick when the head crosses the middle of the frame.\n  const midAt = starts.map((w) => {\n    // Solve SWEEP(q) ≈ crossing for the head at W/2, sampled on 40 steps.\n    const target = (W / 2 - x0) / (x1 - x0);\n    let q = 0;\n    for (let i = 0; i <= 40; i++) {\n      if (SWEEP(i / 40) >= target) {\n        q = i / 40;\n        break;\n      }\n    }\n    return w + q * len;\n  });\n  const hit = midAt.reduce((a, m) => Math.max(a, kick(t - m)), 0);\n  const flash = midAt.reduce((a, m) => {\n    const d = t - m + 1;\n    if (d < 0 || d > 5) return a;\n    return Math.max(a, d < 1 ? d : 1 - (d - 1) / 4);\n  }, 0);\n  // The flash band: a white slash that opens just ahead of the head.\n  const bandGap = 0.03 * W * (1 - flash) + 6 * u;\n  const bandW = 0.075 * W * flash;\n  const cam = `translateX(${-14 * u * hit}px) scale(${1 + 0.035 * hit})`;\n\n  const leftOf = `polygon(${-W}px 0, ${edgeTop}px 0, ${edgeBottom}px ${H}px, ${-W}px ${H}px)`;\n  const rightOf = `polygon(${edgeTop}px 0, ${2 * W}px 0, ${2 * W}px ${H}px, ${edgeBottom}px ${H}px)`;\n\n  // The R rides on the blue part of the streak, spinning a turn and a half.\n  const rH = 0.5 * H;\n  const rX = X - 0.42 * tail;\n  const spin = (p - 0.5) * 540;\n  const rScale = 0.92 + 0.16 * Math.sin(Math.PI * p);\n\n  // Speed lines that run with the head.\n  const lines = [\n    { y: 0.13, h: 7, lead: 0.05, len: 0.5, color: FLUTED[3] },\n    { y: 0.21, h: 3, lead: -0.08, len: 0.42, color: FLUTED[1] },\n    { y: 0.79, h: 12, lead: 0.02, len: 0.6, color: FLUTED[2] },\n    { y: 0.88, h: 4, lead: 0.09, len: 0.35, color: FLUTED[3] },\n  ];\n\n  return (\n    <AbsoluteFill\n      style={{ background: THEMES[theme].stage, overflow: \"hidden\" }}\n    >\n      <div\n        style={{\n          position: \"absolute\",\n          inset: 0,\n          transform: cam,\n          transformOrigin: \"50% 50%\",\n        }}\n      >\n        <div\n          style={{\n            position: \"absolute\",\n            inset: 0,\n            clipPath: active === undefined ? undefined : rightOf,\n          }}\n        >\n          {outgoing}\n        </div>\n        {active !== undefined ? (\n          <div style={{ position: \"absolute\", inset: 0, clipPath: leftOf }}>\n            {incoming}\n          </div>\n        ) : null}\n      </div>\n\n      {active !== undefined ? (\n        <>\n          <svg\n            width={W}\n            height={H}\n            viewBox={`0 0 ${W} ${H}`}\n            style={{ position: \"absolute\", inset: 0 }}\n            aria-hidden\n          >\n            <defs>\n              <linearGradient\n                id={`${uid}-streak`}\n                gradientUnits=\"userSpaceOnUse\"\n                x1={X - tail}\n                y1={0}\n                x2={X}\n                y2={0}\n              >\n                <stop offset=\"0\" stopColor={FLUTED[0]} stopOpacity={0} />\n                <stop offset=\"0.3\" stopColor={FLUTED[0]} stopOpacity={0.85} />\n                <stop offset=\"0.62\" stopColor={FLUTED[1]} />\n                <stop offset=\"0.76\" stopColor=\"#A9509E\" />\n                <stop offset=\"0.87\" stopColor={FLUTED[2]} />\n                <stop offset=\"0.965\" stopColor={FLUTED[3]} />\n                <stop offset=\"1\" stopColor=\"#FFFFFF\" />\n              </linearGradient>\n            </defs>\n            <polygon\n              points={`${edgeTop - tail},0 ${edgeTop},0 ${edgeBottom},${H} ${edgeBottom - tail},${H}`}\n              fill={`url(#${uid}-streak)`}\n            />\n            {lines.map((l) => {\n              const y = l.y * H;\n              const headX = X + slant * (0.5 - l.y) + l.lead * W;\n              return (\n                <rect\n                  key={l.y}\n                  x={headX - l.len * W}\n                  y={y - (l.h * u) / 2}\n                  width={l.len * W}\n                  height={l.h * u}\n                  fill={l.color}\n                />\n              );\n            })}\n          </svg>\n          <div\n            style={{\n              position: \"absolute\",\n              left: rX - (rH * R_W) / R_H / 2,\n              top: H / 2 - rH / 2,\n              transform: `rotate(${spin}deg) scale(${rScale})`,\n            }}\n          >\n            <RemocnR height={rH} color=\"#FFFFFF\" />\n          </div>\n        </>\n      ) : null}\n\n      {flash > 0 && active !== undefined ? (\n        <svg\n          width={W}\n          height={H}\n          viewBox={`0 0 ${W} ${H}`}\n          style={{ position: \"absolute\", inset: 0 }}\n          aria-hidden\n        >\n          <polygon\n            points={`${edgeTop + bandGap},0 ${edgeTop + bandGap + bandW},0 ${edgeBottom + bandGap + bandW},${H} ${edgeBottom + bandGap},${H}`}\n            fill=\"#FFFFFF\"\n          />\n        </svg>\n      ) : null}\n    </AbsoluteFill>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/replay-wipe.tsx"
    }
  ],
  "type": "registry:component"
}
