{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "looks-like-this",
  "title": "Looks Like This",
  "description": "\"Your next launch looks like this.\" above a Remocn Studio screenshot tile.",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "registryDependencies": ["@remocn/gsh"],
  "files": [
    {
      "path": "registry/remocn/looks-like-this/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont as loadMono } from \"@remotion/google-fonts/GeistMono\";\nimport { loadFont as loadSerif } from \"@remotion/google-fonts/InstrumentSerif\";\nimport { loadFont } from \"@remotion/google-fonts/Onest\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport {\n  AbsoluteFill,\n  continueRender,\n  delayRender,\n  Easing,\n  Img,\n  interpolate,\n  spring,\n  staticFile,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\nimport type { GradientParams } from \"@/lib/remocn/gsh/gradient-engine\";\nimport { GshGround } from \"@/lib/remocn/gsh/gsh-ground\";\nimport type { GshPresetId } from \"@/lib/remocn/gsh/presets\";\n\nconst onest = loadFont(\"normal\", {\n  weights: [\"300\", \"400\"],\n  subsets: [\"latin\"],\n});\nconst serif = loadSerif(\"italic\", { weights: [\"400\"], subsets: [\"latin\"] });\nconst mono = loadMono(\"normal\", { weights: [\"400\"], subsets: [\"latin\"] });\n\nexport interface LooksLikeThisProps {\n  lead?: string;\n  word?: string;\n  end?: string;\n  src?: string;\n  aspect?: number;\n  duration?: string;\n  accent?: string;\n  background?: string;\n  speed?: number;\n  theme?: \"dark\" | \"light\";\n  ground?: GshPresetId;\n  groundParams?: Partial<GradientParams>;\n}\n\nconst THEMES = {\n  dark: {\n    ink: \"#F4F3EF\",\n    accent: \"#B4C3FF\",\n    well: \"#101218\",\n    preset: \"velvet-hour\" as GshPresetId,\n    groundOffset: 6,\n    edge: \"rgba(255,255,255,0.1)\",\n    lift: \"0 2px 6px rgba(0,0,0,0.35), 0 40px 90px -24px rgba(0,0,0,0.75)\",\n  },\n  light: {\n    ink: \"#141519\",\n    accent: \"#2D46D6\",\n    well: \"#dfe2e8\",\n    preset: \"glasswork\" as GshPresetId,\n    groundOffset: 3,\n    edge: \"rgba(0,0,0,0.1)\",\n    lift: \"0 2px 6px rgba(30,30,60,0.08), 0 40px 90px -24px rgba(30,30,70,0.32)\",\n  },\n} as const;\n\nconst WGHT = 400;\nconst TRACK = -0.035;\nconst SERIF_TRACK = -0.01;\nconst PX = 200;\nconst CHIP_H = 0.74;\nconst CHIP_GAP = 0.14;\n\nconst TYPE_IN = Easing.bezier(0.22, 1, 0.36, 1);\nconst MOVE = Easing.bezier(0.65, 0, 0.35, 1);\nconst CARD = { mass: 0.8, damping: 18, stiffness: 160 };\nconst MORPH = { damping: 200 };\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\ntype Measure = { sans: (s: string) => number; serif: (s: string) => number };\n\nfunction buildMetrics(_version: number): Measure {\n  const ctx = document.createElement(\"canvas\").getContext(\"2d\");\n  const make = (font: string, track: number) => {\n    const cache: Record<string, number> = {};\n    return (s: string) => {\n      if (cache[s] === undefined) {\n        if (!ctx) return s.length * 0.5;\n        ctx.font = font;\n        cache[s] = ctx.measureText(s).width / PX + track * Array.from(s).length;\n      }\n      return cache[s];\n    };\n  };\n  return {\n    sans: make(`${WGHT} ${PX}px \"${onest.fontFamily}\"`, TRACK),\n    serif: make(`italic 400 ${PX}px \"${serif.fontFamily}\"`, SERIF_TRACK),\n  };\n}\n\nfunction useMetrics() {\n  const [version, setVersion] = useState(0);\n  const [handle] = useState(() => delayRender(\"looks-like-this: measuring\"));\n  const released = useRef(false);\n  useEffect(() => {\n    let live = true;\n    const bump = () => {\n      if (live) setVersion((v) => v + 1);\n    };\n    document.fonts.addEventListener(\"loadingdone\", bump);\n    Promise.all([\n      onest.waitUntilDone(),\n      serif.waitUntilDone(),\n      document.fonts.load(`${WGHT} 100px \"${onest.fontFamily}\"`),\n      document.fonts.load(`italic 400 100px \"${serif.fontFamily}\"`),\n    ])\n      .catch(() => undefined)\n      .then(() => {\n        bump();\n        if (!released.current) {\n          released.current = true;\n          continueRender(handle);\n        }\n      });\n    return () => {\n      live = false;\n      document.fonts.removeEventListener(\"loadingdone\", bump);\n    };\n  }, [handle]);\n  return useMemo(() => buildMetrics(version), [version]);\n}\n\ninterface Token {\n  w: number;\n  gap: number;\n  glue?: boolean;\n}\n\ninterface Placed {\n  x: number;\n  y: number;\n}\n\nfunction layout(\n  tokens: Token[],\n  size: number,\n  maxW: number,\n  centerX: number,\n  topY: number,\n  leading: number,\n) {\n  const lines: number[][] = [[]];\n  let run = 0;\n  tokens.forEach((t, i) => {\n    const line = lines[lines.length - 1];\n    const add = (line.length > 0 ? t.gap : 0) + t.w;\n    if (line.length > 0 && (run + add) * size > maxW) {\n      if (t.glue && line.length > 1) {\n        const prev = line.pop() as number;\n        lines.push([prev, i]);\n        run = tokens[prev].w + t.gap + t.w;\n      } else {\n        lines.push([i]);\n        run = t.w;\n      }\n    } else {\n      line.push(i);\n      run += add;\n    }\n  });\n  const placed: Placed[] = new Array(tokens.length);\n  lines.forEach((line, li) => {\n    const total = line.reduce(\n      (acc, i, k) => acc + tokens[i].w + (k > 0 ? tokens[i].gap : 0),\n      0,\n    );\n    let x = centerX - (total * size) / 2;\n    line.forEach((i, k) => {\n      if (k > 0) x += tokens[i].gap * size;\n      placed[i] = { x, y: topY + li * leading * size };\n      x += tokens[i].w * size;\n    });\n  });\n  return { placed, lines: lines.length };\n}\n\nfunction PlayGlyph({ size, color }: { size: number; color: string }) {\n  return (\n    <svg width={size} height={size} viewBox=\"0 0 24 24\" aria-hidden>\n      <path\n        d=\"M8 5.8 L18 12 L8 18.2 Z\"\n        fill={color}\n        stroke={color}\n        strokeWidth=\"1.5\"\n        strokeLinejoin=\"round\"\n      />\n    </svg>\n  );\n}\n\nexport function LooksLikeThis({\n  lead = \"Your next launch looks like\",\n  word = \"this\",\n  end = \".\",\n  src,\n  aspect = 16 / 9,\n  duration = \"0:30\",\n  accent,\n  background,\n  speed = 1,\n  theme = \"dark\",\n  ground,\n  groundParams,\n}: LooksLikeThisProps) {\n  const frame = useCurrentFrame();\n  const { width: W, height: H, fps, durationInFrames: D } = useVideoConfig();\n  const c = THEMES[theme];\n  const hi = accent ?? c.accent;\n  const image = src ?? staticFile(\"hero.png\");\n  const m = useMetrics();\n\n  const words = lead.split(/\\s+/).filter(Boolean);\n  const k = Math.min(1.6, Math.max(0.6, D / 150));\n  const t = frame * speed;\n  const portrait = H > W * 1.1;\n  const u = portrait ? W / 1080 : W / 1280;\n  const sp = m.sans(\" \");\n  const chipW = CHIP_H * aspect;\n  const leading = 1.08;\n  const wordW = m.serif(word);\n  const endW = m.sans(end);\n\n  const tokensA: Token[] = [\n    ...words.map((wd) => ({ w: m.sans(wd), gap: sp })),\n    { w: chipW + CHIP_GAP * 2 + endW, gap: sp - CHIP_GAP, glue: true },\n  ];\n  const tokensB: Token[] = [\n    ...words.map((wd) => ({ w: m.sans(wd), gap: sp })),\n    { w: wordW + endW, gap: sp, glue: true },\n  ];\n\n  const maxW = W * (portrait ? 0.84 : 0.8);\n  const lineA = tokensA.reduce(\n    (acc, tk, i) => acc + tk.w + (i > 0 ? tk.gap : 0),\n    0,\n  );\n  const sizeA = Math.max(\n    portrait ? W * 0.095 : H * 0.075,\n    Math.min(portrait ? W * 0.12 : H * 0.12, maxW / lineA),\n  );\n  const sizeB = portrait ? W * 0.085 : H * 0.074;\n\n  const probeA = layout(tokensA, sizeA, maxW, W / 2, 0, leading);\n  const blockA = (probeA.lines - 1) * leading * sizeA + sizeA;\n  const A = layout(tokensA, sizeA, maxW, W / 2, (H - blockA) / 2, leading);\n\n  const probeB = layout(tokensB, sizeB, maxW, W / 2, 0, leading);\n  const blockB = (probeB.lines - 1) * leading * sizeB + sizeB;\n  const gapB = H * (portrait ? 0.035 : 0.05);\n  const heroMaxW = W * (portrait ? 0.86 : 0.72);\n  const heroAspect = portrait ? Math.min(aspect, 1) : aspect;\n  const heroRoom = H * (portrait ? 0.78 : 0.8) - blockB - gapB;\n  const heroH = Math.min(heroRoom, heroMaxW / heroAspect);\n  const heroW = heroH * heroAspect;\n  const topB = portrait ? (H - (blockB + gapB + heroH)) / 2 : H * 0.085;\n  const B = layout(tokensB, sizeB, maxW, W / 2, topB, leading);\n  const hero = {\n    x: (W - heroW) / 2,\n    y: topB + blockB + gapB,\n    w: heroW,\n    h: heroH,\n  };\n\n  const CHIP_AT = 12 * k;\n  const GROW_AT = 48 * k;\n  const GROW_LEN = 30 * k;\n\n  const p = interpolate(t, [GROW_AT, GROW_AT + GROW_LEN], [0, 1], {\n    ...CLAMP,\n    easing: MOVE,\n  });\n  const pChip = spring({\n    frame: t - GROW_AT - 4 * k,\n    fps,\n    config: MORPH,\n    durationInFrames: GROW_LEN + 2 * k,\n  });\n  const lerp = (a: number, b: number, q: number) => a + (b - a) * q;\n  const size = lerp(sizeA, sizeB, p);\n\n  const last = words.length;\n  const slotA = A.placed[last];\n  const chipRect0 = {\n    x: slotA.x + CHIP_GAP * sizeA,\n    y: slotA.y + sizeA * (0.6 - CHIP_H / 2),\n    w: chipW * sizeA,\n    h: CHIP_H * sizeA,\n  };\n  const chipOpen = spring({ frame: t - CHIP_AT, fps, config: CARD });\n  const chipY = lerp(chipRect0.y, hero.y, pChip);\n  const lineFloor = lerp(slotA.y, B.placed[words.length].y, p) + size * 1.14;\n  const leave = interpolate(pChip, [0, 0.14], [0, 1], CLAMP);\n  const chip = {\n    x: lerp(chipRect0.x, hero.x, pChip),\n    y: lerp(chipY, Math.max(chipY, lineFloor), leave),\n    w: lerp(chipRect0.w, hero.w, pChip),\n    h: lerp(chipRect0.h, hero.h, pChip),\n  };\n  const radius = lerp(sizeA * 0.12, 16 * u, pChip);\n  const settle = interpolate(t, [GROW_AT + GROW_LEN, D], [1.04, 1], {\n    ...CLAMP,\n    easing: TYPE_IN,\n  });\n  const imgScale = lerp(1.2, settle, pChip);\n\n  const endA = {\n    x: slotA.x + (CHIP_GAP * 2 + chipW) * sizeA,\n    y: slotA.y,\n  };\n  const slotB = B.placed[last];\n  const endB = { x: slotB.x + wordW * sizeB, y: slotB.y };\n  const endY = lerp(endA.y, endB.y, p);\n\n  const wordIn = interpolate(\n    t,\n    [GROW_AT + GROW_LEN * 0.4, GROW_AT + GROW_LEN + 4 * k],\n    [0, 1],\n    { ...CLAMP, easing: TYPE_IN },\n  );\n\n  const prevA = A.placed[last - 1];\n  const prevB = B.placed[last - 1];\n  const wordX =\n    last > 0\n      ? lerp(prevA.x, prevB.x, p) + (m.sans(words[last - 1]) + sp) * size\n      : lerp(slotA.x, slotB.x, p);\n\n  const endX = lerp(\n    endA.x,\n    wordX + wordW * size,\n    interpolate(p, [0, 0.55], [0, 1], { ...CLAMP, easing: TYPE_IN }),\n  );\n\n  const chrome = interpolate(\n    t,\n    [GROW_AT + GROW_LEN, GROW_AT + GROW_LEN + 12 * k],\n    [0, 1],\n    { ...CLAMP, easing: TYPE_IN },\n  );\n  const play = interpolate(t, [GROW_AT + GROW_LEN, D], [0.04, 0.32], CLAMP);\n  const totalSec = (() => {\n    const [mm, ss] = duration.split(\":\").map((v) => Number.parseInt(v, 10));\n    return (mm || 0) * 60 + (ss || 0);\n  })();\n  const nowSec = Math.floor(play * totalSec);\n  const stamp = `${Math.floor(nowSec / 60)}:${String(nowSec % 60).padStart(2, \"0\")}`;\n  const label = Math.max(17 * u, H * 0.024);\n  const flat = background !== undefined;\n\n  const textStyle = {\n    position: \"absolute\" as const,\n    left: 0,\n    top: 0,\n    fontFamily: onest.fontFamily,\n    fontWeight: WGHT,\n    fontSize: size,\n    lineHeight: 1,\n    letterSpacing: `${TRACK}em`,\n    whiteSpace: \"pre\" as const,\n    color: c.ink,\n  };\n\n  const open = 0.12 + 0.88 * Math.min(1, chipOpen);\n  const visW = chip.w * open;\n\n  return (\n    <AbsoluteFill\n      style={{\n        background:\n          flat && background !== \"transparent\" ? background : undefined,\n        overflow: \"hidden\",\n      }}\n    >\n      {flat ? null : (\n        <GshGround\n          preset={ground ?? (groundParams ? undefined : c.preset)}\n          params={groundParams}\n          timeOffset={c.groundOffset}\n          timeScale={0.4}\n        />\n      )}\n      {words.map((wd, i) => {\n        const a = A.placed[i];\n        const b = B.placed[i];\n        const enter = interpolate(\n          t,\n          [i * 2.5 * k, i * 2.5 * k + 12 * k],\n          [0, 1],\n          { ...CLAMP, easing: TYPE_IN },\n        );\n        const x = lerp(a.x, b.x, p);\n        const y = lerp(a.y, b.y, p) + (1 - enter) * size * 0.32;\n        return (\n          <span\n            key={`${wd}-${i.toString()}`}\n            style={{\n              ...textStyle,\n              transform: `translate(${x}px, ${y}px)`,\n              opacity: enter,\n            }}\n          >\n            {wd}\n          </span>\n        );\n      })}\n      <span\n        style={{\n          ...textStyle,\n          transform: `translate(${endX}px, ${endY}px)`,\n          opacity: interpolate(t, [10 * k, 18 * k], [0, 1], {\n            ...CLAMP,\n            easing: TYPE_IN,\n          }),\n        }}\n      >\n        {end}\n      </span>\n      <span\n        style={{\n          ...textStyle,\n          fontFamily: serif.fontFamily,\n          fontStyle: \"italic\",\n          fontWeight: 400,\n          letterSpacing: `${SERIF_TRACK}em`,\n          color: hi,\n          transform: `translate(${wordX}px, ${lerp(slotA.y, slotB.y, p) + (1 - wordIn) * size * 0.3}px)`,\n          opacity: wordIn,\n        }}\n      >\n        {word}\n      </span>\n      <div\n        style={{\n          position: \"absolute\",\n          left: chip.x + (chip.w - visW) / 2,\n          top: chip.y,\n          width: visW,\n          height: chip.h,\n          borderRadius: radius,\n          overflow: \"hidden\",\n          background: c.well,\n          boxShadow: pChip > 0.3 ? c.lift : \"none\",\n          opacity: interpolate(chipOpen, [0, 0.25], [0, 1], CLAMP),\n        }}\n      >\n        <Img\n          src={image}\n          style={{\n            position: \"absolute\",\n            left: -(chip.w - visW) / 2,\n            top: 0,\n            width: chip.w,\n            height: chip.h,\n            objectFit: \"cover\",\n            transform: `scale(${imgScale})`,\n          }}\n        />\n        <div\n          style={{\n            position: \"absolute\",\n            left: 0,\n            right: 0,\n            bottom: 0,\n            height: \"34%\",\n            backgroundImage:\n              \"linear-gradient(180deg, rgba(6,7,10,0) 0%, rgba(6,7,10,0.18) 40%, rgba(6,7,10,0.55) 100%)\",\n            opacity: chrome,\n          }}\n        />\n        <div\n          style={{\n            position: \"absolute\",\n            left: label * 1.1,\n            right: label * 1.1,\n            bottom: label * 0.95,\n            display: \"flex\",\n            alignItems: \"center\",\n            gap: label * 0.8,\n            opacity: chrome,\n            transform: `translateY(${(1 - chrome) * label * 0.6}px)`,\n            color: \"#ffffff\",\n            fontFamily: mono.fontFamily,\n            fontSize: label,\n            fontVariantNumeric: \"tabular-nums\",\n            whiteSpace: \"nowrap\",\n          }}\n        >\n          <PlayGlyph size={label * 1.05} color=\"#ffffff\" />\n          <div\n            style={{\n              flex: 1,\n              height: Math.max(2, label * 0.14),\n              borderRadius: label,\n              background: \"rgba(255,255,255,0.3)\",\n            }}\n          >\n            <div\n              style={{\n                width: `${play * 100}%`,\n                height: \"100%\",\n                borderRadius: \"inherit\",\n                background: \"#ffffff\",\n              }}\n            />\n          </div>\n          <span>\n            {stamp} / {duration}\n          </span>\n        </div>\n        <div\n          style={{\n            position: \"absolute\",\n            inset: 0,\n            borderRadius: \"inherit\",\n            boxShadow: `inset 0 0 0 1px ${c.edge}`,\n          }}\n        />\n      </div>\n    </AbsoluteFill>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/looks-like-this.tsx"
    }
  ],
  "type": "registry:component"
}
