Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "ai-answer-sources",
"title": "AI Answer Sources",
"description": "An AI answer streams in with inline citations and source chips below.",
"dependencies": ["remotion", "@remotion/google-fonts"],
"registryDependencies": ["@remocn/gsh"],
"files": [
{
"path": "registry/remocn/ai-answer-sources/index.tsx",
"content": "\"use client\";\n\nimport { loadFont as loadGeist } from \"@remotion/google-fonts/Geist\";\nimport { loadFont as loadNewsreader } from \"@remotion/google-fonts/Newsreader\";\nimport type React from \"react\";\nimport {\n AbsoluteFill,\n Easing,\n interpolate,\n spring,\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 { fontFamily } = loadGeist(\"normal\", {\n weights: [\"300\", \"400\"],\n subsets: [\"latin\"],\n});\nconst { fontFamily: serif } = loadNewsreader(\"normal\", {\n weights: [\"300\", \"400\"],\n subsets: [\"latin\"],\n});\n\nexport interface AnswerSource {\n site: string;\n title: string;\n snippet?: string;\n color?: string;\n}\n\nexport type AnswerBlock =\n | { type: \"p\"; text: string }\n | { type: \"h\"; text: string }\n | { type: \"ul\"; items: string[] };\n\nexport interface AiAnswerSourcesProps {\n query?: string;\n sources?: AnswerSource[];\n answer?: AnswerBlock[];\n related?: string[];\n brand?: string;\n accent?: string;\n speed?: number;\n theme?: \"light\" | \"dark\";\n ground?: GshPresetId;\n groundParams?: Partial<GradientParams>;\n}\n\nconst DEFAULT_SOURCES: AnswerSource[] = [\n {\n site: \"remocn.dev\",\n title: \"Launch-ready motion components for Remotion\",\n snippet:\n \"Install animated scenes, transitions and product UI mockups with one command, then render your launch video straight from code.\",\n color: \"#1C1C1A\",\n },\n {\n site: \"kitebase.io\",\n title: \"How we shipped our launch video in four hours\",\n snippet:\n \"We skipped the editor, stitched five prebuilt scenes together and rendered a 4K cut from CI the night before launch.\",\n color: \"#C2410C\",\n },\n {\n site: \"fernway.studio\",\n title: \"Code-first video: a field guide for solo builders\",\n snippet:\n \"Treat your video like a component tree. Hook, product, proof, CTA: four beats, each a reusable scene with props.\",\n color: \"#3F6B4E\",\n },\n {\n site: \"lumen.news\",\n title: \"The 30-second launch video is the new landing page\",\n color: \"#5B5B9A\",\n },\n {\n site: \"quarry.dev\",\n title: \"Rendering product UI as video\",\n color: \"#2D5F8A\",\n },\n {\n site: \"orbitly.co\",\n title: \"From terminal to 4K in one command\",\n color: \"#9A3B33\",\n },\n {\n site: \"halcyon.fm\",\n title: \"Launch posts that actually converted\",\n snippet:\n \"The best-performing launches opened on the product in the first second and ended on a single URL.\",\n color: \"#8A6A1F\",\n },\n {\n site: \"tessel.design\",\n title: \"Motion that reads at 30fps\",\n color: \"#8A3A5C\",\n },\n { site: \"kitebase.io\", title: \"Our launch checklist\", color: \"#C2410C\" },\n { site: \"quarry.dev\", title: \"Device mockups in React\", color: \"#2D5F8A\" },\n { site: \"lumen.news\", title: \"Why demo videos win\", color: \"#5B5B9A\" },\n { site: \"orbitly.co\", title: \"Rendering in CI\", color: \"#9A3B33\" },\n];\n\nconst DEFAULT_ANSWER: AnswerBlock[] = [\n {\n type: \"p\",\n text: \"The fastest way is to skip the timeline editor and assemble the video from prebuilt motion components. With **remocn** you install animated scenes into a Remotion project and render them straight from code.[0,1,2] Most solo builders ship a 30-second launch video in a single afternoon.[3]\",\n },\n { type: \"h\", text: \"A one-afternoon workflow\" },\n {\n type: \"ul\",\n items: [\n \"**Pick your beats.** Hook, product, proof and call to action, one component each.[2]\",\n \"**Drop in your UI.** Every scene accepts your screenshots or live React.[4]\",\n \"**Render from the terminal.** One command gives you 1080p or 4K, no export dialog.[1,5]\",\n ],\n },\n {\n type: \"p\",\n text: \"If you already have a landing page, start with a device mockup and a URL-bar call to action; that pair alone covers most launch posts.[0,2,6]\",\n },\n];\n\nconst DEFAULT_RELATED = [\n \"How long should a launch video be?\",\n \"Which scenes work best for a SaaS demo?\",\n \"Can I render launch videos in CI?\",\n];\n\nconst LIGHT = {\n main: \"#FBFBF9\",\n card: \"#FFFFFF\",\n tile: \"#F3F3EF\",\n border: \"rgba(20,20,10,0.10)\",\n hair: \"rgba(20,20,10,0.07)\",\n ink: \"#1C1C1A\",\n body: \"#3B3B37\",\n muted: \"#6B6B66\",\n faint: \"#9A9A94\",\n chip: \"rgba(20,20,10,0.055)\",\n share: \"#1C1C1A\",\n shareText: \"#FFFFFF\",\n window:\n \"0 0 0 1px rgba(20,20,10,0.06), 0 2px 4px rgba(20,20,10,0.04), 0 32px 80px -24px rgba(20,24,60,0.3)\",\n raised:\n \"0 0 0 1px rgba(20,20,10,0.06), 0 1px 3px rgba(20,20,10,0.05), 0 16px 40px -12px rgba(20,20,10,0.18)\",\n};\nconst DARK: typeof LIGHT = {\n main: \"#151616\",\n card: \"#1C1E1E\",\n tile: \"#1F2121\",\n border: \"rgba(255,255,255,0.10)\",\n hair: \"rgba(255,255,255,0.07)\",\n ink: \"#ECECE9\",\n body: \"#C9C9C4\",\n muted: \"#A0A09B\",\n faint: \"#6E6E6A\",\n chip: \"rgba(255,255,255,0.07)\",\n share: \"#ECECE9\",\n shareText: \"#151616\",\n window:\n \"0 0 0 1px rgba(255,255,255,0.08), inset 0 1px 0 rgba(255,255,255,0.06), 0 48px 120px -24px rgba(0,0,0,0.85)\",\n raised: \"0 0 0 1px rgba(255,255,255,0.1), 0 18px 40px -10px rgba(0,0,0,0.6)\",\n};\ntype Palette = typeof LIGHT;\n\nconst CL = { extrapolateLeft: \"clamp\", extrapolateRight: \"clamp\" } as const;\nconst ENTER = Easing.bezier(0.32, 0.72, 0, 1);\nconst EXIT = Easing.bezier(0.55, 0, 1, 0.45);\nconst HEAVY = { mass: 1, damping: 26, stiffness: 120 };\nconst CARD = { mass: 0.8, damping: 18, stiffness: 160 };\nconst CHIP = { mass: 0.5, damping: 12, stiffness: 200 };\nconst MORPH = { damping: 200 };\nconst GLIDE = { mass: 0.9, damping: 24, stiffness: 130 };\ntype SpringCfg = typeof CARD | typeof MORPH;\n\nconst TYPE_AT = 10;\nconst SUBMIT = 60;\nconst THREAD = 64;\nconst STEP1 = 76;\nconst STEP2 = 94;\nconst STEPS_DONE = 120;\nconst ANSWER_AT = 132;\nconst RATE = 6;\n\nconst ICONS = {\n plus: \"M12 5v14M5 12h14\",\n globe:\n \"M12 3a9 9 0 100 18 9 9 0 000-18zM3 12h18M12 3c3 3 3 15 0 18M12 3c-3 3-3 15 0 18\",\n clip: \"M20 11.5l-7.8 7.8a5 5 0 01-7-7l8.1-8.2a3.3 3.3 0 014.7 4.7l-8 8.1a1.7 1.7 0 01-2.4-2.4l7.3-7.3\",\n mic: \"M12 3a3 3 0 00-3 3v6a3 3 0 006 0V6a3 3 0 00-3-3zM5.5 11a6.5 6.5 0 0013 0M12 17.5V21\",\n up: \"M12 19V5M6 11l6-6 6 6\",\n search: \"M11 4a7 7 0 100 14 7 7 0 000-14zM20 20l-4-4\",\n check: \"M5 12.5l4.5 4.5L19 7.5\",\n share: \"M12 3v12M7 8l5-5 5 5M5 13v7h14v-7\",\n copy: \"M8 8h11v11H8zM5 16V5h11\",\n redo: \"M4 12a8 8 0 0114-5.3L20 9M20 4v5h-5M20 12a8 8 0 01-14 5.3L4 15M4 20v-5h5\",\n more: \"M5 12h.01M12 12h.01M19 12h.01\",\n related: \"M4 6h16M4 12h10M4 18h7\",\n close: \"M6 6l12 12M18 6L6 18\",\n sift: \"M5 7h14M7.5 12h9M10 17h4\",\n layers: \"M12 3.5l8.5 4.5-8.5 4.5L3.5 8zM3.5 12.5l8.5 4.5 8.5-4.5\",\n link: \"M10 14a4 4 0 005.7 0l3-3a4 4 0 00-5.7-5.7l-1 1M14 10a4 4 0 00-5.7 0l-3 3a4 4 0 005.7 5.7l1-1\",\n image: \"M4 5h16v14H4zM4 16l5-5 4 4 2-2 5 5M15 9h.01\",\n};\n\nfunction Icon({\n d,\n size = 18,\n color,\n sw = 1.5,\n}: {\n d: string;\n size?: number;\n color: string;\n sw?: number;\n}) {\n return (\n <svg\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n style={{ flexShrink: 0 }}\n >\n <path\n d={d}\n stroke={color}\n strokeWidth={sw}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n );\n}\n\nfunction Favicon({\n src,\n size = 16,\n ring,\n}: {\n src: AnswerSource;\n size?: number;\n ring?: string;\n}) {\n return (\n <div\n style={{\n width: size,\n height: size,\n borderRadius: size * 0.28,\n background: src.color ?? \"#6B6B66\",\n color: \"#fff\",\n fontSize: size * 0.6,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n flexShrink: 0,\n boxShadow: ring\n ? `0 0 0 2px ${ring}`\n : \"inset 0 0 0 1px rgba(0,0,0,0.1)\",\n fontFamily,\n }}\n >\n {src.site[0].toUpperCase()}\n </div>\n );\n}\n\nfunction Cursor({\n x,\n y,\n press,\n opacity = 1,\n}: {\n x: number;\n y: number;\n press: number;\n opacity?: number;\n}) {\n return (\n <svg\n width={26}\n height={30}\n viewBox=\"0 0 20 24\"\n style={{\n position: \"absolute\",\n left: x - 2,\n top: y - 2,\n transformOrigin: \"2px 2px\",\n transform: `scale(${1 - 0.04 * press})`,\n opacity,\n filter:\n \"drop-shadow(0 1px 1px rgba(0,0,0,0.25)) drop-shadow(0 6px 10px rgba(0,0,0,0.2))\",\n overflow: \"visible\",\n zIndex: 60,\n pointerEvents: \"none\",\n }}\n >\n <path\n d=\"M2 2 L2 19.5 L6.6 15.4 L9.8 22.4 L12.9 21 L9.8 14.2 L16 14.2 Z\"\n fill=\"#FFFFFF\"\n stroke=\"#1C1C1A\"\n strokeWidth={1.1}\n strokeLinejoin=\"round\"\n />\n </svg>\n );\n}\n\nfunction Spinner({\n f,\n color,\n done,\n size = 18,\n}: {\n f: number;\n color: string;\n done: boolean;\n size?: number;\n}) {\n if (done) return <Icon d={ICONS.check} size={size} color={color} sw={1.8} />;\n return (\n <svg\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n style={{ transform: `rotate(${f * 12}deg)`, flexShrink: 0 }}\n >\n <circle\n cx=\"12\"\n cy=\"12\"\n r=\"9\"\n fill=\"none\"\n stroke={color}\n strokeOpacity={0.2}\n strokeWidth=\"2\"\n />\n <path\n d=\"M12 3a9 9 0 019 9\"\n fill=\"none\"\n stroke={color}\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n />\n </svg>\n );\n}\n\ntype Tok =\n | { t: \"w\"; s: string; b: boolean; at: number }\n | { t: \"c\"; ids: number[]; at: number };\n\nfunction tokenize(text: string) {\n const toks: Tok[] = [];\n let n = 0;\n let bold = false;\n for (const part of text.split(/(\\[\\d+(?:,\\d+)*\\])/)) {\n const m = part.match(/^\\[(\\d+(?:,\\d+)*)\\]$/);\n if (m) {\n toks.push({ t: \"c\", ids: m[1].split(\",\").map(Number), at: n });\n continue;\n }\n part.split(\"**\").forEach((seg, i) => {\n if (i > 0) bold = !bold;\n for (const w of seg.match(/\\S+\\s*|\\s+/g) ?? []) {\n toks.push({ t: \"w\", s: w, b: bold, at: n });\n n += w.length;\n }\n });\n }\n return { toks, len: n };\n}\n\ninterface Unit {\n kind: \"p\" | \"h\" | \"li\";\n toks: Tok[];\n len: number;\n start: number;\n end: number;\n}\n\nfunction plan(answer: AnswerBlock[]) {\n const units: Unit[] = [];\n let t = ANSWER_AT;\n const add = (kind: Unit[\"kind\"], text: string) => {\n const { toks, len } = tokenize(text);\n const end = t + len / RATE;\n units.push({ kind, toks, len, start: t, end });\n t = end + (kind === \"h\" ? 2 : 5);\n };\n for (const b of answer) {\n if (b.type === \"ul\") for (const it of b.items) add(\"li\", it);\n else add(b.type, b.text);\n }\n let hover = { u: -1, k: -1, from: 0 };\n units.forEach((u, ui) => {\n let prev = -1;\n u.toks.forEach((tk, k) => {\n if (tk.t !== \"c\") return;\n hover = { u: ui, k, from: prev + 1 };\n prev = k;\n });\n });\n return { units, end: t, hover };\n}\n\nexport const AI_ANSWER_SOURCES_DURATION =\n Math.ceil(plan(DEFAULT_ANSWER).end) + 150;\n\nfunction tint(color: string, alpha: number, fallback: string) {\n if (!/^#[0-9a-f]{6}$/i.test(color)) return fallback;\n const a = Math.round(alpha * 255)\n .toString(16)\n .padStart(2, \"0\");\n return `${color}${a}`;\n}\n\nfunction arc(\n t: number,\n a: [number, number],\n b: [number, number],\n bend: number,\n) {\n const dx = b[0] - a[0];\n const dy = b[1] - a[1];\n const len = Math.hypot(dx, dy) || 1;\n const cx = (a[0] + b[0]) / 2 + (-dy / len) * bend;\n const cy = (a[1] + b[1]) / 2 + (dx / len) * bend;\n const u = 1 - t;\n return {\n x: u * u * a[0] + 2 * u * t * cx + t * t * b[0],\n y: u * u * a[1] + 2 * u * t * cy + t * t * b[1],\n };\n}\n\nfunction CitePill({\n ids,\n sources,\n pop,\n active,\n c,\n children,\n}: {\n ids: number[];\n sources: AnswerSource[];\n pop: number;\n active: boolean;\n c: Palette;\n children?: React.ReactNode;\n}) {\n const first = sources[ids[0]] ?? sources[0];\n return (\n <span\n style={{\n position: \"relative\",\n display: \"inline-flex\",\n alignItems: \"center\",\n height: 24,\n padding: \"0 8px\",\n marginLeft: 5,\n borderRadius: 7,\n background: active ? c.ink : c.chip,\n fontFamily,\n fontSize: 15,\n color: active ? c.main : c.muted,\n verticalAlign: 2,\n lineHeight: 1,\n whiteSpace: \"nowrap\",\n opacity: Math.min(1, pop * 1.5),\n transform: `scale(${0.8 + 0.2 * pop})`,\n transformOrigin: \"left center\",\n }}\n >\n {first.site}\n {ids.length > 1 ? (\n <span style={{ opacity: 0.6, marginLeft: 4 }}>+{ids.length - 1}</span>\n ) : null}\n {children}\n </span>\n );\n}\n\nfunction HoverCard({\n ids,\n sources,\n c,\n v,\n out,\n}: {\n ids: number[];\n sources: AnswerSource[];\n c: Palette;\n v: number;\n out: number;\n}) {\n const src = sources[ids[0]] ?? sources[0];\n return (\n <span\n style={{\n position: \"absolute\",\n left: -10,\n bottom: 34,\n width: 380,\n display: \"block\",\n padding: \"16px 18px 18px\",\n borderRadius: 16,\n background: c.card,\n boxShadow: c.raised,\n whiteSpace: \"normal\",\n textAlign: \"left\",\n color: c.ink,\n lineHeight: 1.4,\n transformOrigin: \"20px 100%\",\n opacity: Math.min(1, v * 1.6) * out,\n transform: `translateY(${(1 - v) * 10 + (1 - out) * 4}px) scale(${0.92 + 0.08 * v})`,\n zIndex: 50,\n }}\n >\n <span\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: 8,\n fontSize: 15,\n color: c.muted,\n }}\n >\n <Favicon src={src} size={18} />\n <span style={{ flex: 1 }}>{src.site}</span>\n {ids.length > 1 ? (\n <span style={{ fontVariantNumeric: \"tabular-nums\", color: c.faint }}>\n 1 / {ids.length}\n </span>\n ) : null}\n </span>\n <span\n style={{\n display: \"block\",\n marginTop: 10,\n fontSize: 18,\n letterSpacing: \"-0.01em\",\n }}\n >\n {src.title}\n </span>\n {src.snippet ? (\n <span\n style={{\n marginTop: 6,\n fontSize: 15,\n lineHeight: 1.45,\n color: c.muted,\n display: \"-webkit-box\",\n WebkitLineClamp: 2,\n WebkitBoxOrient: \"vertical\",\n overflow: \"hidden\",\n }}\n >\n {src.snippet}\n </span>\n ) : null}\n </span>\n );\n}\n\nexport function AiAnswerSources({\n query = \"What is the fastest way to make a launch video?\",\n sources = DEFAULT_SOURCES,\n answer = DEFAULT_ANSWER,\n related = DEFAULT_RELATED,\n brand = \"sift\",\n accent = \"#20808D\",\n speed = 1,\n theme = \"light\",\n ground,\n groundParams,\n}: AiAnswerSourcesProps) {\n const frame = useCurrentFrame();\n const { fps, width, height } = useVideoConfig();\n const f = frame * speed;\n const dark = theme === \"dark\";\n const c = dark ? DARK : LIGHT;\n const portrait = height > width;\n const stageW = portrait ? 720 : 1280;\n const stageH = portrait ? 1280 : 720;\n const s = Math.min(width / stageW, height / stageH);\n const win = portrait\n ? { x: 28, y: 48, w: 664, h: 1184 }\n : { x: 40, y: 32, w: 1200, h: 656 };\n const AW = win.w;\n const AH = win.h;\n const COL = portrait ? 600 : 700;\n const COL_X = (AW - COL) / 2;\n const PANEL = portrait ? 520 : 360;\n const SHIFT = portrait ? 0 : COL_X - (AW - PANEL - COL) / 2;\n const TOP = 64;\n const FOOT = 132;\n\n const sp = (at: number, config: SpringCfg = CARD) =>\n spring({ frame: f - at, fps, config });\n const ease = (a: number, b: number, e = ENTER) =>\n interpolate(f, [a, b], [0, 1], { ...CL, easing: e });\n const enter = (v: number, dy = 12): React.CSSProperties => ({\n opacity: Math.min(1, v * 1.3),\n transform: `translateY(${(1 - v) * dy}px)`,\n });\n const click = (at: number) =>\n Math.max(\n 0,\n spring({ frame: f - at + 3, fps, config: CHIP }) -\n spring({ frame: f - at, fps, config: CHIP }),\n );\n\n const { units, end, hover } = plan(answer);\n const ACTIONS = end + 4;\n const RELATED = end + 10;\n const BAR = end + 8;\n const HOVER = end + 34;\n const CARD_AT = HOVER + 22;\n const CLICK = HOVER + 50;\n const PANEL_AT = CLICK + 2;\n\n const typed = Math.floor(Math.max(0, (f - TYPE_AT) * 1.5));\n const shown = query.slice(0, typed);\n const home = 1 - ease(SUBMIT + 1, SUBMIT + 7, EXIT);\n const threadIn = ease(SUBMIT + 2, SUBMIT + 12);\n const press = click(SUBMIT);\n const inputTop = AH * 0.4;\n const inputH = 128;\n const sendPt: [number, number] = [COL_X + COL - 34, inputTop + inputH - 32];\n const homeCur = {\n ...arc(Math.min(1, sp(30, GLIDE)), [AW * 0.78, AH * 0.94], sendPt, -80),\n o: interpolate(f, [30, 36, SUBMIT + 4, SUBMIT + 8], [0, 1, 1, 0], CL),\n };\n\n const stepsCollapse = sp(STEPS_DONE + 2, MORPH);\n const panel = sp(PANEL_AT, HEAVY);\n const hoverOn = f >= HOVER + 20;\n const card = sp(CARD_AT, CARD);\n const cardOut = 1 - ease(CLICK, CLICK + 6, EXIT);\n const mark = ease(HOVER + 18, HOVER + 26);\n const citePress = click(CLICK);\n const hoverIds =\n hover.u >= 0\n ? (units[hover.u].toks[hover.k] as { ids: number[] }).ids\n : [0, 1, 2];\n const relCur = {\n ...arc(Math.min(1.02, sp(HOVER, GLIDE)), [300, 170], [34, 14], 60),\n o: ease(HOVER, HOVER + 6),\n };\n\n const bodySize = 19;\n const cplFor = (kind: Unit[\"kind\"]) =>\n Math.floor((kind === \"li\" ? COL - 28 : COL) / (bodySize * 0.46));\n\n const renderUnit = (u: Unit, ui: number) => {\n const r = (f - u.start) * RATE;\n if (r <= 0) return null;\n const lh = u.kind === \"h\" ? 34 : 30;\n const cpl = cplFor(u.kind);\n const done = f > u.end + 8;\n const maxH = done ? 999 : lh * (1 + Math.min(r, u.len) / cpl) + 16;\n return (\n <div\n key={`u${ui}`}\n style={{ maxHeight: maxH, overflow: done ? \"visible\" : \"hidden\" }}\n >\n <div\n style={{\n display: \"flex\",\n gap: 12,\n fontFamily: serif,\n color: c.body,\n fontSize: u.kind === \"h\" ? 25 : bodySize,\n fontWeight: 400,\n letterSpacing: u.kind === \"h\" ? \"-0.015em\" : \"0\",\n lineHeight: `${lh}px`,\n padding:\n u.kind === \"h\"\n ? \"10px 0 8px\"\n : u.kind === \"li\"\n ? \"0 0 8px 4px\"\n : \"0 0 16px\",\n }}\n >\n {u.kind === \"li\" ? (\n <span\n style={{\n width: 5,\n height: 5,\n borderRadius: 3,\n background: c.faint,\n marginTop: 13,\n flexShrink: 0,\n opacity: Math.min(1, r / 4),\n }}\n />\n ) : null}\n <div>\n {u.toks.map((tk, k) => {\n const key = `${ui}-${k}`;\n if (tk.t === \"w\") {\n const cited =\n ui === hover.u && k >= hover.from && k < hover.k && mark > 0;\n return (\n <span\n key={key}\n style={{\n opacity: Math.max(0, Math.min(1, (r - tk.at) / 10)),\n color: tk.b || u.kind === \"h\" ? c.ink : undefined,\n whiteSpace: \"pre-wrap\",\n background: cited\n ? tint(accent, 0.16 * mark, c.chip)\n : undefined,\n borderRadius: 3,\n }}\n >\n {tk.s}\n </span>\n );\n }\n const popAt = u.start + tk.at / RATE + 1;\n const isHover = ui === hover.u && k === hover.k;\n return (\n <CitePill\n key={key}\n ids={tk.ids}\n sources={sources}\n pop={sp(popAt, CHIP)}\n active={isHover && hoverOn}\n c={c}\n >\n {isHover && card > 0.01 && cardOut > 0 ? (\n <HoverCard\n ids={tk.ids}\n sources={sources}\n c={c}\n v={card}\n out={cardOut}\n />\n ) : null}\n {isHover && f >= HOVER ? (\n <Cursor\n x={relCur.x}\n y={relCur.y}\n press={citePress}\n opacity={relCur.o}\n />\n ) : null}\n </CitePill>\n );\n })}\n </div>\n </div>\n </div>\n );\n };\n\n const stepRow = (\n at: number,\n doneAt: number,\n label: string,\n extra: React.ReactNode,\n ) => {\n const v = sp(at);\n return (\n <div style={{ ...enter(v, 8), marginBottom: 12 }}>\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: 10,\n fontSize: 17,\n color: c.ink,\n }}\n >\n <Spinner\n f={f}\n color={f >= doneAt ? c.muted : accent}\n done={f >= doneAt}\n />\n <span>{label}</span>\n </div>\n <div style={{ display: \"flex\", gap: 8, marginTop: 8, marginLeft: 28 }}>\n {extra}\n </div>\n </div>\n );\n };\n const queryChip = (text: string, at: number) => (\n <div\n key={text}\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: 6,\n height: 28,\n padding: \"0 10px\",\n borderRadius: 8,\n background: c.chip,\n fontSize: 15,\n color: c.muted,\n ...enter(sp(at, CHIP), 6),\n }}\n >\n <Icon d={ICONS.search} size={14} color={c.muted} />\n {text}\n </div>\n );\n\n const sourcesRow = sp(STEP2 + 6, MORPH);\n const actionsIn = sp(ACTIONS, MORPH);\n const barIn = sp(BAR, HEAVY);\n const tiles = portrait ? 2 : 3;\n\n const resolvedGround: GshPresetId =\n ground ?? (dark ? \"earthshine\" : \"glasswork\");\n\n return (\n <AbsoluteFill style={{ fontFamily, overflow: \"hidden\" }}>\n <GshGround\n preset={resolvedGround}\n params={groundParams}\n timeOffset={4}\n timeScale={0.35}\n />\n <div\n style={{\n position: \"absolute\",\n left: (width - stageW * s) / 2,\n top: (height - stageH * s) / 2,\n width: stageW,\n height: stageH,\n transform: `scale(${s})`,\n transformOrigin: \"0 0\",\n }}\n >\n <div\n style={{\n position: \"absolute\",\n left: win.x,\n top: win.y,\n width: AW,\n height: AH,\n borderRadius: 24,\n overflow: \"hidden\",\n background: c.main,\n boxShadow: c.window,\n color: c.ink,\n WebkitFontSmoothing: \"antialiased\",\n opacity: ease(0, 12),\n transform: `translateY(${(1 - sp(0, HEAVY)) * 48}px) scale(${0.96 + 0.04 * sp(0, HEAVY)})`,\n }}\n >\n {home > 0 ? (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n opacity: home,\n transform: `translateY(${(1 - home) * -20}px)`,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n left: COL_X,\n width: COL,\n top: inputTop - 96,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n gap: 14,\n ...enter(sp(2), 14),\n }}\n >\n <div\n style={{\n width: 44,\n height: 44,\n borderRadius: 13,\n background: c.ink,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <Icon d={ICONS.sift} size={26} color={c.main} sw={2} />\n </div>\n <span\n style={{\n fontFamily: serif,\n fontSize: 60,\n fontWeight: 300,\n letterSpacing: \"-0.035em\",\n lineHeight: 1,\n }}\n >\n {brand}\n </span>\n </div>\n <div\n style={{\n position: \"absolute\",\n left: COL_X,\n top: inputTop,\n width: COL,\n height: inputH,\n borderRadius: 20,\n background: c.card,\n boxShadow: c.raised,\n boxSizing: \"border-box\",\n padding: \"20px 22px 0\",\n ...enter(sp(5), 18),\n }}\n >\n <div\n style={{\n fontSize: 20,\n color: shown ? c.ink : c.faint,\n height: 28,\n }}\n >\n {shown || \"Ask anything\"}\n {f < SUBMIT && Math.floor(f / 8) % 2 === 0 ? (\n <span\n style={{\n display: \"inline-block\",\n width: 2,\n height: 22,\n marginLeft: 2,\n background: accent,\n verticalAlign: -4,\n }}\n />\n ) : null}\n </div>\n <div\n style={{\n position: \"absolute\",\n left: 16,\n right: 16,\n bottom: 14,\n display: \"flex\",\n alignItems: \"center\",\n gap: 8,\n }}\n >\n <div\n style={{\n display: \"flex\",\n padding: 3,\n gap: 2,\n borderRadius: 11,\n background: c.chip,\n }}\n >\n {[\"Search\", \"Research\"].map((t, i) => (\n <div\n key={t}\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: 6,\n height: 30,\n padding: \"0 12px\",\n borderRadius: 8,\n fontSize: 15,\n color: i === 0 ? c.ink : c.muted,\n background: i === 0 ? c.card : \"transparent\",\n boxShadow:\n i === 0\n ? `0 0 0 1px ${c.hair}, 0 1px 2px ${c.hair}`\n : \"none\",\n }}\n >\n <Icon\n d={i === 0 ? ICONS.search : ICONS.layers}\n size={15}\n color={i === 0 ? c.ink : c.muted}\n />\n {t}\n </div>\n ))}\n </div>\n <div style={{ flex: 1 }} />\n {[ICONS.globe, ICONS.clip, ICONS.mic].map((d) => (\n <div\n key={d}\n style={{\n width: 34,\n display: \"flex\",\n justifyContent: \"center\",\n }}\n >\n <Icon d={d} size={19} color={c.muted} />\n </div>\n ))}\n <div\n style={{\n width: 40,\n height: 40,\n borderRadius: 20,\n background: shown ? accent : c.chip,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n transform: `scale(${1 - 0.06 * press})`,\n }}\n >\n <Icon\n d={ICONS.up}\n size={19}\n color={shown ? \"#fff\" : c.faint}\n sw={1.8}\n />\n </div>\n </div>\n </div>\n <Cursor\n x={homeCur.x}\n y={homeCur.y}\n press={press}\n opacity={homeCur.o}\n />\n </div>\n ) : null}\n\n {threadIn > 0 ? (\n <div style={{ position: \"absolute\", inset: 0, opacity: threadIn }}>\n <div\n style={{\n position: \"absolute\",\n left: 0,\n right: 0,\n top: 0,\n height: TOP,\n background: c.main,\n zIndex: 4,\n display: \"flex\",\n alignItems: \"flex-end\",\n padding: \"0 24px\",\n boxShadow: `inset 0 -1px 0 ${c.hair}`,\n }}\n >\n <div\n style={{\n display: \"flex\",\n gap: 26,\n marginLeft: COL_X - 24 - panel * SHIFT,\n flex: 1,\n }}\n >\n {(\n [\n [\"Answer\", ICONS.sift],\n [\"Links\", ICONS.link],\n [\"Images\", ICONS.image],\n ] as const\n ).map(([t, d], i) => (\n <div\n key={t}\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: 7,\n height: 46,\n fontSize: 16,\n color: i === 0 ? c.ink : c.muted,\n boxShadow:\n i === 0 ? `inset 0 -1.5px 0 ${c.ink}` : \"none\",\n }}\n >\n <Icon d={d} size={16} color={i === 0 ? c.ink : c.muted} />\n {t}\n </div>\n ))}\n </div>\n {portrait ? null : (\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: 8,\n height: 34,\n marginBottom: 6,\n padding: \"0 14px\",\n borderRadius: 10,\n background: c.share,\n color: c.shareText,\n fontSize: 15,\n marginRight: panel * PANEL,\n }}\n >\n <Icon d={ICONS.share} size={15} color={c.shareText} />\n Share\n </div>\n )}\n </div>\n\n <div\n style={{\n position: \"absolute\",\n left: COL_X - panel * SHIFT,\n width: COL,\n top: TOP,\n bottom: FOOT,\n display: \"flex\",\n flexDirection: \"column\",\n justifyContent: \"flex-end\",\n }}\n >\n <div style={{ flexShrink: 0, paddingTop: 28 }}>\n <div\n style={{\n fontFamily: serif,\n fontSize: 34,\n fontWeight: 300,\n lineHeight: 1.18,\n letterSpacing: \"-0.025em\",\n marginBottom: 22,\n ...enter(sp(THREAD), 20),\n }}\n >\n {query}\n </div>\n <div\n style={{\n position: \"relative\",\n height: interpolate(\n stepsCollapse,\n [0, 1],\n [f >= STEP1 ? 122 : 0, 32],\n ),\n overflow: \"hidden\",\n marginBottom: 14,\n }}\n >\n <div style={{ opacity: 1 - stepsCollapse }}>\n {stepRow(STEP1, STEP2 - 2, \"Searching the web\", [\n queryChip(\"fastest launch video workflow\", STEP1 + 4),\n portrait\n ? null\n : queryChip(\"remotion launch templates\", STEP1 + 9),\n ])}\n {stepRow(\n STEP2,\n STEPS_DONE,\n `Reading ${sources.length} sources`,\n [\n <div\n key=\"fav\"\n style={{\n display: \"flex\",\n ...enter(sp(STEP2 + 4, CHIP), 6),\n }}\n >\n {sources.slice(0, 6).map((src, i) => (\n <div\n key={`${src.site}${src.title}`}\n style={{ marginLeft: i ? -5 : 0 }}\n >\n <Favicon src={src} size={22} ring={c.main} />\n </div>\n ))}\n </div>,\n ],\n )}\n </div>\n <div\n style={{\n position: \"absolute\",\n top: 4,\n left: 0,\n display: \"flex\",\n alignItems: \"center\",\n gap: 9,\n fontSize: 16,\n color: c.muted,\n opacity: stepsCollapse,\n }}\n >\n <Icon\n d={ICONS.check}\n size={18}\n color={c.muted}\n sw={1.8}\n />\n Reviewed {sources.length} sources\n </div>\n </div>\n <div\n style={{\n display: \"flex\",\n gap: 10,\n maxHeight: interpolate(sourcesRow, [0, 1], [0, 112]),\n marginBottom: 20 * Math.min(1, sourcesRow),\n }}\n >\n {[...sources.slice(0, tiles), null].map((src, i) => {\n const v = sp(STEP2 + 8 + i * 4, CARD);\n return (\n <div\n key={src ? `${src.site}${i}` : \"more\"}\n style={{\n flex: src ? 1 : 0.7,\n height: 96,\n borderRadius: 12,\n background: c.tile,\n padding: \"12px 14px\",\n boxSizing: \"border-box\",\n display: \"flex\",\n flexDirection: \"column\",\n justifyContent: \"space-between\",\n opacity: Math.min(1, v * 1.5),\n transform: `translateY(${(1 - v) * 14}px) scale(${0.92 + 0.08 * v})`,\n }}\n >\n {src ? (\n <>\n <div\n style={{\n fontSize: 15,\n lineHeight: \"20px\",\n height: 40,\n overflow: \"hidden\",\n display: \"-webkit-box\",\n WebkitLineClamp: 2,\n WebkitBoxOrient: \"vertical\",\n }}\n >\n {src.title}\n </div>\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: 7,\n fontSize: 15,\n color: c.muted,\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n }}\n >\n <Favicon src={src} size={16} />\n <span\n style={{\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n }}\n >\n {src.site}\n </span>\n </div>\n </>\n ) : (\n <>\n <div style={{ display: \"flex\" }}>\n {sources\n .slice(tiles, tiles + 4)\n .map((s2, j) => (\n <div\n key={`${s2.site}${s2.title}`}\n style={{ marginLeft: j ? -4 : 0 }}\n >\n <Favicon\n src={s2}\n size={18}\n ring={c.tile}\n />\n </div>\n ))}\n </div>\n <div style={{ fontSize: 15, color: c.muted }}>\n +{Math.max(0, sources.length - tiles)} more\n </div>\n </>\n )}\n </div>\n );\n })}\n </div>\n {units.map(renderUnit)}\n <div\n style={{\n maxHeight: interpolate(actionsIn, [0, 1], [0, 60]),\n overflow: \"hidden\",\n opacity: actionsIn,\n }}\n >\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: 18,\n padding: \"10px 0 16px\",\n boxShadow: `inset 0 -1px 0 ${c.hair}`,\n }}\n >\n {[ICONS.share, ICONS.copy, ICONS.redo].map((d) => (\n <Icon key={d} d={d} size={18} color={c.muted} />\n ))}\n <div style={{ flex: 1 }} />\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: 8,\n height: 30,\n padding: \"0 12px 0 6px\",\n borderRadius: 15,\n background: c.chip,\n fontSize: 15,\n color: c.muted,\n }}\n >\n <div style={{ display: \"flex\" }}>\n {hoverIds.slice(0, 3).map((id, j) => (\n <div key={id} style={{ marginLeft: j ? -5 : 0 }}>\n <Favicon\n src={sources[id] ?? sources[0]}\n size={18}\n ring={c.main}\n />\n </div>\n ))}\n </div>\n {sources.length} sources\n </div>\n </div>\n </div>\n {related.length > 0 ? (\n <div\n style={{\n maxHeight: interpolate(\n sp(RELATED, MORPH),\n [0, 1],\n [0, 52 + related.length * 52],\n ),\n overflow: \"hidden\",\n }}\n >\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: 9,\n fontSize: 17,\n padding: \"20px 0 8px\",\n ...enter(sp(RELATED), 8),\n }}\n >\n <Icon d={ICONS.related} size={18} color={c.ink} />\n Related\n </div>\n {related.map((q, i) => (\n <div\n key={q}\n style={{\n display: \"flex\",\n alignItems: \"center\",\n height: 52,\n boxShadow: i ? `inset 0 1px 0 ${c.hair}` : \"none\",\n fontSize: 17,\n color: c.body,\n ...enter(sp(RELATED + 4 + i * 4), 10),\n }}\n >\n <span style={{ flex: 1 }}>{q}</span>\n <Icon d={ICONS.plus} size={18} color={accent} />\n </div>\n ))}\n </div>\n ) : null}\n </div>\n </div>\n\n <div\n style={{\n position: \"absolute\",\n left: 0,\n right: 0,\n bottom: 0,\n height: FOOT,\n background: `linear-gradient(transparent, ${c.main} 28%)`,\n zIndex: 3,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n left: COL_X - panel * SHIFT,\n width: COL,\n bottom: 22,\n height: 92,\n borderRadius: 20,\n background: c.card,\n boxShadow: c.raised,\n boxSizing: \"border-box\",\n padding: \"16px 18px\",\n fontSize: 17,\n color: c.faint,\n opacity: Math.min(1, barIn * 1.4),\n transform: `translateY(${(1 - barIn) * 48}px)`,\n }}\n >\n Ask a follow-up\n <div\n style={{\n position: \"absolute\",\n left: 14,\n right: 14,\n bottom: 12,\n display: \"flex\",\n alignItems: \"center\",\n gap: 10,\n }}\n >\n <Icon d={ICONS.plus} size={20} color={c.muted} />\n <div style={{ flex: 1 }} />\n <Icon d={ICONS.mic} size={19} color={c.muted} />\n <div\n style={{\n width: 34,\n height: 34,\n borderRadius: 17,\n background: c.chip,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <Icon d={ICONS.up} size={17} color={c.faint} sw={1.8} />\n </div>\n </div>\n </div>\n </div>\n\n {portrait ? (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n background: dark ? \"#000\" : \"#1C1C1A\",\n opacity: (dark ? 0.3 : 0.08) * panel,\n zIndex: 5,\n }}\n />\n ) : null}\n <div\n style={{\n position: \"absolute\",\n ...(portrait\n ? {\n left: 0,\n right: 0,\n bottom: 0,\n height: 580,\n borderRadius: \"24px 24px 0 0\",\n boxShadow: `0 -1px 0 ${c.border}, 0 -24px 48px -24px rgba(0,0,0,${dark ? 0.6 : 0.2})`,\n transform: `translateY(${(1 - panel) * 620}px)`,\n }\n : {\n top: 0,\n right: 0,\n bottom: 0,\n width: PANEL,\n boxShadow: `-1px 0 0 ${c.border}, -24px 0 48px -24px rgba(0,0,0,${dark ? 0.6 : 0.16})`,\n transform: `translateX(${(1 - panel) * (PANEL + 48)}px)`,\n }),\n background: c.main,\n zIndex: 6,\n padding: \"20px 24px\",\n boxSizing: \"border-box\",\n }}\n >\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n fontSize: 18,\n height: 30,\n }}\n >\n <span style={{ flex: 1 }}>{hoverIds.length} sources</span>\n <Icon d={ICONS.close} size={18} color={c.muted} />\n </div>\n <div\n style={{\n fontSize: 15,\n color: c.muted,\n margin: \"22px 0 16px\",\n }}\n >\n Cited in this answer\n </div>\n {hoverIds.map((id, i) => {\n const src = sources[id] ?? sources[0];\n const v = sp(PANEL_AT + 6 + i * 4);\n return (\n <div\n key={`${id}`}\n style={{\n padding: \"16px 0\",\n boxShadow: i ? `inset 0 1px 0 ${c.hair}` : \"none\",\n ...enter(v, 14),\n }}\n >\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: 8,\n fontSize: 15,\n color: c.muted,\n }}\n >\n <Favicon src={src} size={18} />\n {src.site}\n </div>\n <div\n style={{\n fontSize: 18,\n lineHeight: 1.3,\n marginTop: 8,\n letterSpacing: \"-0.01em\",\n }}\n >\n {src.title}\n </div>\n {src.snippet ? (\n <div\n style={{\n fontSize: 15,\n lineHeight: 1.45,\n color: c.muted,\n marginTop: 6,\n display: \"-webkit-box\",\n WebkitLineClamp: 2,\n WebkitBoxOrient: \"vertical\",\n overflow: \"hidden\",\n }}\n >\n {src.snippet}\n </div>\n ) : null}\n </div>\n );\n })}\n </div>\n </div>\n ) : null}\n </div>\n </div>\n </AbsoluteFill>\n );\n}\n",
"type": "registry:component",
"target": "components/remocn/ai-answer-sources.tsx"
}
],
"type": "registry:component"
}