{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ai-chat-stream",
  "type": "registry:ui",
  "title": "AI Chat Stream",
  "dependencies": [
    "motion",
    "lucide-react"
  ],
  "files": [
    {
      "path": "components/ui/ai-chat-stream.tsx",
      "content": "\"use client\";\n\nimport React, { useEffect, useState } from \"react\";\nimport { motion } from \"motion/react\";\nimport { Bot, Check, Copy, RotateCcw } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nconst SAMPLE_RESPONSE =\n  \"Motion primitives are ready. Using spring physics with layoutId gives your tabs and cards a tactile, native-like feel without layout thrashing.\";\n\nexport function AiChatStream({ className }: { className?: string }) {\n  const [displayedCount, setDisplayedCount] = useState(0);\n  const [copied, setCopied] = useState(false);\n  const words = SAMPLE_RESPONSE.split(\" \");\n\n  useEffect(() => {\n    if (displayedCount >= words.length) return;\n    const timer = setTimeout(() => {\n      setDisplayedCount((c) => c + 1);\n    }, 65);\n    return () => clearTimeout(timer);\n  }, [displayedCount, words.length]);\n\n  const isDone = displayedCount >= words.length;\n\n  const handleCopy = () => {\n    navigator.clipboard?.writeText(SAMPLE_RESPONSE);\n    setCopied(true);\n    setTimeout(() => setCopied(false), 1500);\n  };\n\n  return (\n    <div\n      className={cn(\n        \"w-full max-w-lg rounded-2xl border border-white/10 bg-zinc-900/80 p-4 backdrop-blur-md\",\n        className\n      )}\n    >\n      <div className=\"flex items-start gap-3\">\n        <div className=\"flex h-7 w-7 shrink-0 items-center justify-center rounded-lg border border-blue-500/30 bg-blue-500/10 text-blue-400\">\n          <Bot className=\"h-4 w-4\" />\n        </div>\n        <div className=\"min-w-0 flex-1 space-y-2\">\n          <div className=\"flex items-center gap-2 text-xs text-zinc-400\">\n            <span className=\"font-medium text-zinc-200\">Assistant</span>\n            {!isDone && (\n              <span className=\"inline-flex items-center gap-1 text-blue-400\">\n                <span className=\"h-1.5 w-1.5 animate-pulse rounded-full bg-blue-400\" />\n                streaming\n              </span>\n            )}\n          </div>\n          <p className=\"text-sm leading-relaxed text-zinc-200\">\n            {words.slice(0, displayedCount).map((word, idx) => (\n              <motion.span\n                key={idx}\n                initial={{ opacity: 0, filter: \"blur(3px)\" }}\n                animate={{ opacity: 1, filter: \"blur(0px)\" }}\n                transition={{ duration: 0.2 }}\n              >\n                {word}{\" \"}\n              </motion.span>\n            ))}\n          </p>\n          <div className=\"flex items-center gap-2 pt-1\">\n            <button\n              onClick={handleCopy}\n              className=\"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-zinc-400 hover:bg-white/5 hover:text-zinc-200 cursor-pointer transition-colors\"\n            >\n              {copied ? (\n                <Check className=\"h-3 w-3 text-emerald-400\" />\n              ) : (\n                <Copy className=\"h-3 w-3\" />\n              )}\n              {copied ? \"Copied\" : \"Copy\"}\n            </button>\n            <button\n              onClick={() => setDisplayedCount(0)}\n              className=\"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-zinc-400 hover:bg-white/5 hover:text-zinc-200 cursor-pointer transition-colors\"\n            >\n              <RotateCcw className=\"h-3 w-3\" />\n              Replay\n            </button>\n          </div>\n        </div>\n      </div>\n    </div>\n  );\n}\n\n",
      "type": "registry:ui"
    }
  ]
}