{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"hero-launch","type":"registry:component","title":"Product Hero","description":"Product launch hero scene for a SaaS launch video intro. Cinematic product-launch hero — two cards slide into formation as the headline reveals above.","dependencies":["remotion","@remotion/google-fonts"],"docs":"Needs a Remotion project. If a frame renders black, the component is drawing on a transparent layer: put a background behind it, e.g. <AbsoluteFill style={{ background: \"#faf9f6\" }}><Component /></AbsoluteFill>. Pass mode=\"dark\" for dark frames.","registryDependencies":["https://kuchi.kalarislabs.com/r/kuchi-ui.json"],"files":[{"path":"components/kuchi/hero-launch.tsx","type":"registry:component","target":"components/kuchi/hero-launch.tsx","content":"/*! Portions Copyright (c) 2026 Sri Nath (snap-cn). MIT License. See THIRD_PARTY_LICENSES. */\n\"use client\";\r\n\r\nimport { loadFont as loadInter } from \"@remotion/google-fonts/Inter\";\r\nimport { type CSSProperties, useCallback, useState } from \"react\";\r\nimport {\r\n  AbsoluteFill,\r\n  continueRender,\r\n  delayRender,\r\n  Easing,\r\n  getRemotionEnvironment,\r\n  interpolate,\r\n  OffthreadVideo,\r\n  staticFile,\r\n  useCurrentFrame,\r\n  useVideoConfig,\r\n} from \"remotion\";\r\nimport {\r\n  Item,\r\n  mixOklch,\r\n  resolveFont,\r\n  type KuchiTheme,\r\n  useKuchiTheme,\r\n  withAlpha,\r\n} from \"@/lib/kuchi-ui\";\r\n\r\nconst { fontFamily: SANS } = loadInter(\"normal\", {\r\n  weights: [\"500\", \"600\", \"700\"],\r\n  subsets: [\"latin\"],\r\n});\r\n\r\nexport interface HeroLaunchProps {\r\n  /** Reveal caption under the cards. */\r\n  heading?: string;\r\n  /**\r\n   * Left card media. An image URL, a video URL (`.mp4`/`.webm`/`.mov` → plays\r\n   * via <OffthreadVideo>), or a CSS `linear-gradient(...)`. The video editor\r\n   * swaps this for the viewer's own image/clip.\r\n   */\r\n  image1?: string;\r\n  /** Right card media (same rules as `image1`). */\r\n  image2?: string;\r\n  /** Design-system token overrides. */\r\n  theme?: Partial<KuchiTheme>;\r\n  /** Defaults to `\"dark\"` — the scene is a cinematic stage, lit for dark. */\r\n  mode?: \"light\" | \"dark\";\r\n  /**\r\n   * The face this scene paints its words in — a label from `fonts.ts`\r\n   * (\"Inter\", \"Space Grotesk\", \"Instrument Serif\") or a CSS family you have\r\n   * loaded yourself. Unset, the scene keeps the face it was designed around.\r\n   *\r\n   * Overrides `theme.fontFamily`, which is how a brand kit re-skins a whole\r\n   * timeline from one value.\r\n   */\r\n  fontFamily?: string;\r\n}\r\n\r\nconst PERSP = 1000;\r\n// Pure rotateY about each card's INNER edge — no rotateX, so the inner edges\r\n// stay vertical and the centre gap is a clean, even channel top-to-bottom.\r\nconst TILT = 17;\r\nconst GAP = 92;\r\n/** Stand-in for missing media — the page lifted a shade, not a fixed grey. */\r\nconst placeholder = (t: KuchiTheme) =>\r\n  `linear-gradient(135deg,${mixOklch(t.background, t.card, 0.55)},${mixOklch(\r\n    t.background,\r\n    t.card,\r\n    0.2,\r\n  )})`;\r\n\r\n// Sample product-reveal clips. Absolute, because these ship as *defaults* into a\r\n// project that does not have them in its own `public/` — a root-relative default\r\n// becomes `staticFile()` in a render and 404s the first time anyone renders the\r\n// component they just installed. Swap them for your own media, root-relative or\r\n// not; `resolveSrc` handles both.\r\nconst SHOWCASE = [\r\n  \"https://kuchi-media.kalarislabs.com/components/clips/clip-3.mp4\",\r\n  \"https://kuchi-media.kalarislabs.com/components/clips/clip-5.mp4\",\r\n];\r\n\r\nconst isVideo = (src: string) => /\\.(mp4|webm|mov|m4v)(\\?|$)/i.test(src);\r\nconst isGradient = (src: string) => src.startsWith(\"linear-gradient\");\r\n\r\n// easeOutQuint — quick to move, silky to settle, lands exactly on target with\r\n// no asymptotic \"stuck\" tail (the thing overdamped springs get wrong).\r\nconst OUT = Easing.bezier(0.22, 1, 0.36, 1);\r\n// Gravity-ish accelerate for the drop-off.\r\nconst FALL = Easing.bezier(0.5, 0, 0.9, 0.4);\r\n\r\n/**\r\n * A root-relative asset (\"/showcase-assets/..\") is served at the origin root by\r\n * Next in the Player, but Remotion Studio and a render serve `public/` through\r\n * `staticFile()` alone — so rewrite local paths everywhere but the Player, and pass\r\n * http(s)/data/blob URLs straight through.\r\n */\r\nfunction resolveSrc(src: string): string {\r\n  const isLocal = src.startsWith(\"/\") && !src.startsWith(\"//\");\r\n  if (!isLocal || getRemotionEnvironment().isPlayer) return src;\r\n  // A value that already came out of staticFile() carries the static base\r\n  // (`/static-<hash>/…`); running it through again would prefix it twice.\r\n  const base = staticFile(\"_\").slice(0, -2);\r\n  if (base && src.startsWith(`${base}/`)) return src;\r\n  try {\r\n    return staticFile(src.replace(/^\\/+/, \"\"));\r\n  } catch {\r\n    return src;\r\n  }\r\n}\r\n\r\n/**\r\n * Image that holds the server render until it has actually *loaded*, then\r\n * releases. Remotion's <Img> is avoided on purpose: it awaits `img.decode()`,\r\n * which the headless compositor rejects for some progressive JPEGs and hangs the\r\n * export. A plain <img> paints fine — we wait for `onload` ourselves and clear\r\n * on error too, so a bad source degrades gracefully. In the Player this is an\r\n * ordinary, instantly-shown image.\r\n */\r\nfunction HeroImage({ src, style }: { src: string; style: CSSProperties }) {\r\n  const [handle] = useState(() => delayRender(`hero image: ${src}`));\r\n  const release = useCallback(() => continueRender(handle), [handle]);\r\n  return (\r\n    // biome-ignore lint/performance/noImgElement: Remotion frame, not a Next route.\r\n    <img // eslint-disable-line @remotion/warn-native-media-tag -- onLoad releases the frame; <Img> hangs on some JPEGs\r\n      src={resolveSrc(src)}\r\n      alt=\"\"\r\n      style={style}\r\n      onLoad={release}\r\n      onError={release}\r\n    />\r\n  );\r\n}\r\n\r\n/** Fills a card edge-to-edge with an image, a video, or a gradient. */\r\nfunction CardMedia({ src, t }: { src: string; t: KuchiTheme }) {\r\n  const media: CSSProperties = {\r\n    position: \"absolute\",\r\n    inset: 0,\r\n    width: \"100%\",\r\n    height: \"100%\",\r\n    objectFit: \"cover\",\r\n  };\r\n  const effective = src || placeholder(t);\r\n  if (isGradient(effective)) {\r\n    return <div style={{ ...media, background: effective }} />;\r\n  }\r\n  if (isVideo(effective)) {\r\n    return <OffthreadVideo src={resolveSrc(effective)} muted style={media} />;\r\n  }\r\n  return <HeroImage src={effective} style={media} />;\r\n}\r\n\r\n/**\r\n * Cinematic product-launch hero — deterministic Remotion composition\r\n * (1280×720 @30fps). Two image cards, one continuous professionally-eased\r\n * motion, no bounce:\r\n *\r\n *   f0–40    the left image HOLDS full-screen, flat and clear\r\n *   f40      it recedes to its floating size and angles in about its inner edge\r\n *   f60      the right image slides in from the right; the two sit SYMMETRIC\r\n *            about the frame centre with an even, centred gap\r\n *   f100     both breathe with a barely-there float (never dead-static)\r\n *   f122     they fall off the lower edge together\r\n *   f126     the headline reveals and eases forward (\"comes to front\")\r\n *\r\n * Left/right/bottom edges dissolve into black. `image1`/`image2` + `heading`\r\n * are the props the video editor drives.\r\n */\r\nexport function HeroLaunch({\r\n  heading = \"npx shadcn add @kuchi\",\r\n  image1 = SHOWCASE[0],\r\n  image2 = SHOWCASE[1],\r\n  theme,\r\n  mode,\r\n  fontFamily,\r\n}: HeroLaunchProps) {\r\n  const frame = useCurrentFrame();\r\n  const { width, height } = useVideoConfig();\r\n  const t = useKuchiTheme(theme, mode ?? \"dark\");\r\n  const face = resolveFont(fontFamily ?? t.fontFamily) ?? SANS;\r\n  const s = height / 720;\r\n\r\n  const cardW = 1000 * s;\r\n  const cardH = 620 * s;\r\n  const centerLeft = (width - cardW) / 2;\r\n  const cardTop = 0.3 * height;\r\n  // Symmetric about the centre → the gap sits exactly on the frame's midline.\r\n  const restOffset = (cardW + GAP * s) / 2;\r\n  const leftXFinal = -restOffset;\r\n  const rightXFinal = restOffset;\r\n  const rightXStart = 1.08 * width;\r\n  const groupYFinal = 0.16 * height;\r\n\r\n  // A clamped, eased 0→1 segment — the single motion primitive for the whole\r\n  // scene. Easing lands cleanly on the target, so nothing ever \"sticks\".\r\n  const seg = (start: number, dur: number, easing = OUT) =>\r\n    interpolate(frame, [start, start + dur], [0, 1], {\r\n      easing,\r\n      extrapolateLeft: \"clamp\",\r\n      extrapolateRight: \"clamp\",\r\n    });\r\n\r\n  const recede = seg(40, 30); // full-screen → floating\r\n  const angle = seg(46, 36); // flat → angled (rotateY only)\r\n  const slideL = seg(46, 36); // centre → left rest\r\n  const slideR = seg(60, 40); // offscreen right → right rest\r\n  const drop = seg(122, 34, FALL); // settle → fall off bottom\r\n  const title = seg(126, 40); // headline reveal + forward\r\n\r\n  const leftScale = interpolate(recede, [0, 1], [1.5, 1]);\r\n  const leftX = interpolate(slideL, [0, 1], [0, leftXFinal]);\r\n  const leftDeg = interpolate(angle, [0, 1], [0, -TILT]);\r\n  const leftOpacity = interpolate(frame, [2, 12], [0, 1], {\r\n    extrapolateLeft: \"clamp\",\r\n    extrapolateRight: \"clamp\",\r\n  });\r\n\r\n  const rightX = interpolate(slideR, [0, 1], [rightXStart, rightXFinal]);\r\n  const rightOpacity = interpolate(slideR, [0, 0.35], [0, 1], {\r\n    extrapolateRight: \"clamp\",\r\n  });\r\n\r\n  // Barely-there float once settled (fades out into the drop) so the held beat\r\n  // reads as alive, not frozen — the classic \"why does it feel stuck\" fix.\r\n  const floatEnv = seg(94, 22) * (1 - drop);\r\n  const floatY = Math.sin(frame * 0.09) * 3.5 * s * floatEnv;\r\n  const groupY = interpolate(drop, [0, 1], [0, groupYFinal]) + floatY;\r\n\r\n  const titleY = interpolate(title, [0, 1], [40 * s, 0]);\r\n  const titleScale = interpolate(title, [0, 1], [0.82, 1]);\r\n  const titleBlur = interpolate(title, [0, 1], [10, 0]);\r\n\r\n  const vignette = seg(50, 40, Easing.linear);\r\n\r\n  const cardBox = (x: number, opacity: number): CSSProperties => ({\r\n    position: \"absolute\",\r\n    left: centerLeft,\r\n    top: cardTop,\r\n    width: cardW,\r\n    height: cardH,\r\n    opacity,\r\n    transform: `translateX(${x}px)`,\r\n  });\r\n\r\n  // Opening zoom pivots on the centre; the tilt pivots on the inner edge.\r\n  const zoom = (scale: number): CSSProperties => ({\r\n    width: \"100%\",\r\n    height: \"100%\",\r\n    transform: `scale(${scale})`,\r\n    transformOrigin: \"center center\",\r\n  });\r\n  const tilt = (deg: number, origin: string): CSSProperties => ({\r\n    width: \"100%\",\r\n    height: \"100%\",\r\n    transform: `perspective(${PERSP * s}px) rotateY(${deg}deg)`,\r\n    transformOrigin: origin,\r\n  });\r\n  const fade = (gradient: string): CSSProperties => ({\r\n    position: \"absolute\",\r\n    inset: 0,\r\n    background: gradient,\r\n  });\r\n\r\n  return (\r\n    <AbsoluteFill style={{ backgroundColor: t.background, fontFamily: face }}>\r\n      <AbsoluteFill style={{ transform: `translateY(${groupY}px)` }}>\r\n        {/* Each card is its own object to Remotion Studio (see `Item`). */}\r\n        <Item index={0}>\r\n          <div style={cardBox(leftX, leftOpacity)}>\r\n            <div style={zoom(leftScale)}>\r\n              {/* inner edge = right edge → pivot at 100% 50% */}\r\n              <div style={tilt(leftDeg, \"100% 50%\")}>\r\n                <ImageCard s={s} src={image1} t={t} />\r\n              </div>\r\n            </div>\r\n          </div>\r\n        </Item>\r\n        <Item index={1}>\r\n          <div style={cardBox(rightX, rightOpacity)}>\r\n            {/* inner edge = left edge → pivot at 0% 50% */}\r\n            <div style={tilt(TILT, \"0% 50%\")}>\r\n              <ImageCard s={s} src={image2} t={t} />\r\n            </div>\r\n          </div>\r\n        </Item>\r\n      </AbsoluteFill>\r\n\r\n      {/* Wide, clean edge dissolve — fades in after the full-screen opening. */}\r\n      <AbsoluteFill style={{ opacity: vignette, pointerEvents: \"none\" }}>\r\n        <div\r\n          style={fade(\r\n            `linear-gradient(to left, ${t.background} 0%, transparent 30%)`,\r\n          )}\r\n        />\r\n        <div\r\n          style={fade(\r\n            `linear-gradient(to right, ${t.background} 0%, transparent 22%)`,\r\n          )}\r\n        />\r\n        <div\r\n          style={fade(\r\n            `linear-gradient(to top, ${t.background} 0%, transparent 30%)`,\r\n          )}\r\n        />\r\n      </AbsoluteFill>\r\n\r\n      <div\r\n        style={{\r\n          position: \"absolute\",\r\n          left: 0,\r\n          right: 0,\r\n          top: 0.22 * height,\r\n          padding: `0 ${40 * s}px`,\r\n          textAlign: \"center\",\r\n          color: t.foreground,\r\n          fontWeight: 600,\r\n          letterSpacing: \"-0.02em\",\r\n          fontSize: 42 * s,\r\n          opacity: title,\r\n          filter: `blur(${titleBlur}px)`,\r\n          transform: `translateY(${titleY}px) scale(${titleScale})`,\r\n        }}\r\n      >\r\n        {heading}\r\n      </div>\r\n    </AbsoluteFill>\r\n  );\r\n}\r\n\r\n/** A single card: one image (or video/gradient) filling it edge-to-edge. */\r\nfunction ImageCard({ s, src, t }: { s: number; src: string; t: KuchiTheme }) {\r\n  return (\r\n    <div\r\n      style={{\r\n        position: \"relative\",\r\n        width: \"100%\",\r\n        height: \"100%\",\r\n        overflow: \"hidden\",\r\n        borderRadius: 30 * s,\r\n        background: mixOklch(t.background, t.card, 0.35),\r\n        // Drop shadow + a subtle inset hairline ring so the edge reads on both\r\n        // dark and bright media without dominating.\r\n        boxShadow: `0 ${20 * s}px ${52 * s}px -${28 * s}px ${withAlpha(\r\n          mixOklch(t.background, \"#000\", 0.75),\r\n          0.9,\r\n        )}, inset 0 0 0 1px ${withAlpha(t.foreground, 0.22)}`,\r\n      }}\r\n    >\r\n      <CardMedia src={src} t={t} />\r\n      {/* subtle depth: darken the lower edge + a hairline top sheen */}\r\n      <div\r\n        style={{\r\n          position: \"absolute\",\r\n          inset: 0,\r\n          background: `linear-gradient(to top, ${withAlpha(\r\n            mixOklch(t.background, \"#000\", 0.75),\r\n            0.28,\r\n          )} 0%, transparent 32%)`,\r\n        }}\r\n      />\r\n      <div\r\n        style={{\r\n          position: \"absolute\",\r\n          left: 26 * s,\r\n          right: 26 * s,\r\n          top: 0,\r\n          height: 1,\r\n          background: `linear-gradient(90deg,transparent,${withAlpha(\r\n            t.foreground,\r\n            0.5,\r\n          )},transparent)`,\r\n        }}\r\n      />\r\n    </div>\r\n  );\r\n}\r\n"}]}