ai-schadcn-chat 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +307 -0
  3. package/dist/ChatPanel-Cyq7boWQ.js +3468 -0
  4. package/dist/ChatPanel-Cyq7boWQ.js.map +1 -0
  5. package/dist/ChatPanel-D3VL5Vdq.cjs +10 -0
  6. package/dist/ChatPanel-D3VL5Vdq.cjs.map +1 -0
  7. package/dist/ChatProvider-DcrNbVMh.cjs +2 -0
  8. package/dist/ChatProvider-DcrNbVMh.cjs.map +1 -0
  9. package/dist/ChatProvider-DoD4jj4M.js +128 -0
  10. package/dist/ChatProvider-DoD4jj4M.js.map +1 -0
  11. package/dist/chat-engine-BaFdimfx.cjs +8 -0
  12. package/dist/chat-engine-BaFdimfx.cjs.map +1 -0
  13. package/dist/chat-engine-Cja0KtWE.js +520 -0
  14. package/dist/chat-engine-Cja0KtWE.js.map +1 -0
  15. package/dist/components/chat/AgentManager.d.ts +11 -0
  16. package/dist/components/chat/AgentManager.d.ts.map +1 -0
  17. package/dist/components/chat/AgentManager.js +110 -0
  18. package/dist/components/chat/Attachment.d.ts +34 -0
  19. package/dist/components/chat/Attachment.d.ts.map +1 -0
  20. package/dist/components/chat/Attachment.js +59 -0
  21. package/dist/components/chat/AttachmentPreview.d.ts +8 -0
  22. package/dist/components/chat/AttachmentPreview.d.ts.map +1 -0
  23. package/dist/components/chat/AttachmentPreview.js +43 -0
  24. package/dist/components/chat/ChatComposer.d.ts +11 -0
  25. package/dist/components/chat/ChatComposer.d.ts.map +1 -0
  26. package/dist/components/chat/ChatComposer.js +10 -0
  27. package/dist/components/chat/ChatHeader.d.ts +5 -0
  28. package/dist/components/chat/ChatHeader.d.ts.map +1 -0
  29. package/dist/components/chat/ChatHeader.js +132 -0
  30. package/dist/components/chat/ChatPanel.d.ts +36 -0
  31. package/dist/components/chat/ChatPanel.d.ts.map +1 -0
  32. package/dist/components/chat/ChatPanel.js +55 -0
  33. package/dist/components/chat/ChatProvider.d.ts +58 -0
  34. package/dist/components/chat/ChatProvider.d.ts.map +1 -0
  35. package/dist/components/chat/ChatProvider.js +145 -0
  36. package/dist/components/chat/Chatbubble.d.ts +30 -0
  37. package/dist/components/chat/Chatbubble.d.ts.map +1 -0
  38. package/dist/components/chat/Chatbubble.js +50 -0
  39. package/dist/components/chat/Markdown.d.ts +35 -0
  40. package/dist/components/chat/Markdown.d.ts.map +1 -0
  41. package/dist/components/chat/Markdown.js +130 -0
  42. package/dist/components/chat/Message.d.ts +22 -0
  43. package/dist/components/chat/Message.d.ts.map +1 -0
  44. package/dist/components/chat/Message.js +21 -0
  45. package/dist/components/chat/MessageInput.d.ts +24 -0
  46. package/dist/components/chat/MessageInput.d.ts.map +1 -0
  47. package/dist/components/chat/MessageInput.js +255 -0
  48. package/dist/components/chat/MessageList.d.ts +9 -0
  49. package/dist/components/chat/MessageList.d.ts.map +1 -0
  50. package/dist/components/chat/MessageList.js +249 -0
  51. package/dist/components/chat/MessageMarker.d.ts +25 -0
  52. package/dist/components/chat/MessageMarker.d.ts.map +1 -0
  53. package/dist/components/chat/MessageMarker.js +31 -0
  54. package/dist/components/chat/MessageScroller.d.ts +12 -0
  55. package/dist/components/chat/MessageScroller.d.ts.map +1 -0
  56. package/dist/components/chat/MessageScroller.js +48 -0
  57. package/dist/components/chat/MessageScrollerPrimitives.d.ts +76 -0
  58. package/dist/components/chat/MessageScrollerPrimitives.d.ts.map +1 -0
  59. package/dist/components/chat/MessageScrollerPrimitives.js +438 -0
  60. package/dist/components/chat/ProviderManager.d.ts +10 -0
  61. package/dist/components/chat/ProviderManager.d.ts.map +1 -0
  62. package/dist/components/chat/ProviderManager.js +110 -0
  63. package/dist/components/chat/ReasoningPanel.d.ts +15 -0
  64. package/dist/components/chat/ReasoningPanel.d.ts.map +1 -0
  65. package/dist/components/chat/ReasoningPanel.js +40 -0
  66. package/dist/components/chat/ThemeToggle.d.ts +4 -0
  67. package/dist/components/chat/ThemeToggle.d.ts.map +1 -0
  68. package/dist/components/chat/ThemeToggle.js +59 -0
  69. package/dist/components/index.d.ts +44 -0
  70. package/dist/components/index.d.ts.map +1 -0
  71. package/dist/components/index.js +49 -0
  72. package/dist/components/ui/avatar.d.ts +11 -0
  73. package/dist/components/ui/avatar.d.ts.map +1 -0
  74. package/dist/components/ui/avatar.js +33 -0
  75. package/dist/components/ui/badge.d.ts +10 -0
  76. package/dist/components/ui/badge.d.ts.map +1 -0
  77. package/dist/components/ui/badge.js +19 -0
  78. package/dist/components/ui/button.d.ts +12 -0
  79. package/dist/components/ui/button.d.ts.map +1 -0
  80. package/dist/components/ui/button.js +34 -0
  81. package/dist/components/ui/card.d.ts +8 -0
  82. package/dist/components/ui/card.d.ts.map +1 -0
  83. package/dist/components/ui/card.js +15 -0
  84. package/dist/components/ui/checkbox.d.ts +5 -0
  85. package/dist/components/ui/checkbox.d.ts.map +1 -0
  86. package/dist/components/ui/checkbox.js +8 -0
  87. package/dist/components/ui/collapsible.d.ts +6 -0
  88. package/dist/components/ui/collapsible.d.ts.map +1 -0
  89. package/dist/components/ui/collapsible.js +5 -0
  90. package/dist/components/ui/dialog.d.ts +24 -0
  91. package/dist/components/ui/dialog.d.ts.map +1 -0
  92. package/dist/components/ui/dialog.js +30 -0
  93. package/dist/components/ui/dropdown-menu.d.ts +17 -0
  94. package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
  95. package/dist/components/ui/dropdown-menu.js +20 -0
  96. package/dist/components/ui/input.d.ts +4 -0
  97. package/dist/components/ui/input.d.ts.map +1 -0
  98. package/dist/components/ui/input.js +7 -0
  99. package/dist/components/ui/label.d.ts +6 -0
  100. package/dist/components/ui/label.d.ts.map +1 -0
  101. package/dist/components/ui/label.js +10 -0
  102. package/dist/components/ui/popover.d.ts +6 -0
  103. package/dist/components/ui/popover.d.ts.map +1 -0
  104. package/dist/components/ui/popover.js +9 -0
  105. package/dist/components/ui/scroll-area.d.ts +3 -0
  106. package/dist/components/ui/scroll-area.d.ts.map +1 -0
  107. package/dist/components/ui/scroll-area.js +8 -0
  108. package/dist/components/ui/select.d.ts +14 -0
  109. package/dist/components/ui/select.d.ts.map +1 -0
  110. package/dist/components/ui/select.js +26 -0
  111. package/dist/components/ui/separator.d.ts +3 -0
  112. package/dist/components/ui/separator.d.ts.map +1 -0
  113. package/dist/components/ui/separator.js +6 -0
  114. package/dist/components/ui/switch.d.ts +3 -0
  115. package/dist/components/ui/switch.d.ts.map +1 -0
  116. package/dist/components/ui/switch.js +6 -0
  117. package/dist/components/ui/tabs.d.ts +6 -0
  118. package/dist/components/ui/tabs.d.ts.map +1 -0
  119. package/dist/components/ui/tabs.js +11 -0
  120. package/dist/components/ui/tooltip.d.ts +6 -0
  121. package/dist/components/ui/tooltip.d.ts.map +1 -0
  122. package/dist/components/ui/tooltip.js +9 -0
  123. package/dist/components.cjs +2 -0
  124. package/dist/components.cjs.map +1 -0
  125. package/dist/components.js +129 -0
  126. package/dist/components.js.map +1 -0
  127. package/dist/hooks/index.d.ts +2 -0
  128. package/dist/hooks/index.d.ts.map +1 -0
  129. package/dist/hooks/index.js +3 -0
  130. package/dist/hooks/useChat.d.ts +6 -0
  131. package/dist/hooks/useChat.d.ts.map +1 -0
  132. package/dist/hooks/useChat.js +5 -0
  133. package/dist/hooks.cjs +2 -0
  134. package/dist/hooks.cjs.map +1 -0
  135. package/dist/hooks.js +8 -0
  136. package/dist/hooks.js.map +1 -0
  137. package/dist/index-Ci4qkGOp.cjs +20 -0
  138. package/dist/index-Ci4qkGOp.cjs.map +1 -0
  139. package/dist/index-NhYr-cEJ.js +567 -0
  140. package/dist/index-NhYr-cEJ.js.map +1 -0
  141. package/dist/index.cjs +2 -0
  142. package/dist/index.cjs.map +1 -0
  143. package/dist/index.d.ts +33 -0
  144. package/dist/index.d.ts.map +1 -0
  145. package/dist/index.js +32 -0
  146. package/dist/index.js.map +1 -0
  147. package/dist/lib/agents.d.ts +29 -0
  148. package/dist/lib/agents.d.ts.map +1 -0
  149. package/dist/lib/agents.js +145 -0
  150. package/dist/lib/attachments.d.ts +40 -0
  151. package/dist/lib/attachments.d.ts.map +1 -0
  152. package/dist/lib/attachments.js +152 -0
  153. package/dist/lib/chat-engine.d.ts +109 -0
  154. package/dist/lib/chat-engine.d.ts.map +1 -0
  155. package/dist/lib/chat-engine.js +505 -0
  156. package/dist/lib/index.d.ts +8 -0
  157. package/dist/lib/index.d.ts.map +1 -0
  158. package/dist/lib/index.js +7 -0
  159. package/dist/lib/persistence.d.ts +30 -0
  160. package/dist/lib/persistence.d.ts.map +1 -0
  161. package/dist/lib/persistence.js +104 -0
  162. package/dist/lib/providers.d.ts +40 -0
  163. package/dist/lib/providers.d.ts.map +1 -0
  164. package/dist/lib/providers.js +0 -0
  165. package/dist/lib/tw-merge.d.ts +9 -0
  166. package/dist/lib/tw-merge.d.ts.map +1 -0
  167. package/dist/lib/tw-merge.js +8 -0
  168. package/dist/lib/utils.d.ts +69 -0
  169. package/dist/lib/utils.d.ts.map +1 -0
  170. package/dist/lib/utils.js +166 -0
  171. package/dist/lib/voice.d.ts +57 -0
  172. package/dist/lib/voice.d.ts.map +1 -0
  173. package/dist/lib/voice.js +103 -0
  174. package/dist/lib.cjs +2 -0
  175. package/dist/lib.cjs.map +1 -0
  176. package/dist/lib.js +59 -0
  177. package/dist/lib.js.map +1 -0
  178. package/dist/marker.css +68 -0
  179. package/dist/package.json +6 -0
  180. package/dist/presets-BxnbImSM.cjs +2 -0
  181. package/dist/presets-BxnbImSM.cjs.map +1 -0
  182. package/dist/presets-D8VQTD8n.js +193 -0
  183. package/dist/presets-D8VQTD8n.js.map +1 -0
  184. package/dist/providers/anthropic.d.ts +30 -0
  185. package/dist/providers/anthropic.d.ts.map +1 -0
  186. package/dist/providers/anthropic.js +251 -0
  187. package/dist/providers/base.d.ts +55 -0
  188. package/dist/providers/base.d.ts.map +1 -0
  189. package/dist/providers/base.js +272 -0
  190. package/dist/providers/index.d.ts +15 -0
  191. package/dist/providers/index.d.ts.map +1 -0
  192. package/dist/providers/index.js +24 -0
  193. package/dist/providers/openai.d.ts +31 -0
  194. package/dist/providers/openai.d.ts.map +1 -0
  195. package/dist/providers/openai.js +192 -0
  196. package/dist/providers-BuaGy2tX.cjs +4 -0
  197. package/dist/providers-BuaGy2tX.cjs.map +1 -0
  198. package/dist/providers-kp-avTNl.js +324 -0
  199. package/dist/providers-kp-avTNl.js.map +1 -0
  200. package/dist/providers.cjs +2 -0
  201. package/dist/providers.cjs.map +1 -0
  202. package/dist/providers.js +14 -0
  203. package/dist/providers.js.map +1 -0
  204. package/dist/scroller.css +278 -0
  205. package/dist/style.css +1 -0
  206. package/dist/types/chat.d.ts +342 -0
  207. package/dist/types/chat.d.ts.map +1 -0
  208. package/dist/types/chat.js +4 -0
  209. package/dist/types/index.d.ts +9 -0
  210. package/dist/types/index.d.ts.map +1 -0
  211. package/dist/types/index.js +14 -0
  212. package/dist/types/presets.d.ts +25 -0
  213. package/dist/types/presets.d.ts.map +1 -0
  214. package/dist/types/presets.js +207 -0
  215. package/dist/types.cjs +2 -0
  216. package/dist/types.cjs.map +1 -0
  217. package/dist/types.js +16 -0
  218. package/dist/types.js.map +1 -0
  219. package/dist/typeset-presets.css +56 -0
  220. package/dist/typeset.css +505 -0
  221. package/package.json +158 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatPanel-Cyq7boWQ.js","sources":["../src/components/ui/button.tsx","../src/components/ui/input.tsx","../src/components/ui/card.tsx","../src/components/ui/scroll-area.tsx","../src/components/ui/avatar.tsx","../src/components/ui/dropdown-menu.tsx","../src/components/ui/popover.tsx","../src/components/ui/tooltip.tsx","../src/components/ui/switch.tsx","../src/components/ui/dialog.tsx","../src/components/ui/separator.tsx","../src/components/ui/badge.tsx","../src/components/ui/tabs.tsx","../src/components/ui/select.tsx","../src/components/ui/label.tsx","../src/components/ui/checkbox.tsx","../src/components/ui/collapsible.tsx","../src/components/chat/AgentManager.tsx","../src/components/chat/ThemeToggle.tsx","../src/components/chat/ChatHeader.tsx","../src/lib/voice.ts","../src/components/chat/ProviderManager.tsx","../src/components/chat/Attachment.tsx","../src/components/chat/AttachmentPreview.tsx","../src/components/chat/MessageInput.tsx","../src/components/chat/Chatbubble.tsx","../src/components/chat/Message.tsx","../src/components/chat/MessageScrollerPrimitives.tsx","../src/components/chat/MessageScroller.tsx","../src/components/chat/MessageMarker.tsx","../src/components/chat/Markdown.tsx","../src/components/chat/ReasoningPanel.tsx","../src/components/chat/MessageList.tsx","../src/components/chat/ChatPanel.tsx"],"sourcesContent":["import { forwardRef, type ButtonHTMLAttributes } from \"react\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport { cn } from \"../../lib/utils.js\";\n\nconst buttonVariants = cva(\n \"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0\",\n {\n variants: {\n variant: {\n default: \"bg-primary text-primary-foreground hover:bg-primary/90\",\n destructive:\n \"bg-destructive text-destructive-foreground hover:bg-destructive/90\",\n outline:\n \"border border-input bg-background hover:bg-accent hover:text-accent-foreground\",\n secondary:\n \"bg-secondary text-secondary-foreground hover:bg-secondary/80\",\n ghost: \"hover:bg-accent hover:text-accent-foreground\",\n link: \"text-primary underline-offset-4 hover:underline\",\n },\n size: {\n default: \"h-10 px-4 py-2\",\n sm: \"h-9 rounded-md px-3\",\n lg: \"h-11 rounded-md px-8\",\n icon: \"h-10 w-10\",\n \"icon-sm\": \"h-8 w-8\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"default\",\n },\n },\n);\n\nexport interface ButtonProps\n extends ButtonHTMLAttributes<HTMLButtonElement>,\n VariantProps<typeof buttonVariants> {\n asChild?: boolean;\n}\n\nconst Button = forwardRef<HTMLButtonElement, ButtonProps>(\n ({ className, variant, size, asChild = false, ...props }, ref) => {\n const Comp = asChild ? Slot : \"button\";\n return (\n <Comp\n className={cn(buttonVariants({ variant, size, className }))}\n ref={ref}\n {...props}\n />\n );\n },\n);\nButton.displayName = \"Button\";\n\nexport { Button, buttonVariants };","import { forwardRef, type InputHTMLAttributes, type TextareaHTMLAttributes } from \"react\";\nimport { cn } from \"../../lib/utils.js\";\n\nexport const Input = forwardRef<HTMLInputElement, InputHTMLAttributes<HTMLInputElement>>(\n ({ className, type, ...props }, ref) => (\n <input\n type={type}\n className={cn(\n \"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50\",\n className,\n )}\n ref={ref}\n {...props}\n />\n ),\n);\nInput.displayName = \"Input\";\n\nexport const Textarea = forwardRef<HTMLTextAreaElement, TextareaHTMLAttributes<HTMLTextAreaElement>>(\n ({ className, ...props }, ref) => (\n <textarea\n className={cn(\n \"flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50\",\n className,\n )}\n ref={ref}\n {...props}\n />\n ),\n);\nTextarea.displayName = \"Textarea\";","import { forwardRef, type HTMLAttributes } from \"react\";\nimport { cn } from \"../../lib/utils.js\";\n\nexport const Card = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(\n ({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn(\"rounded-lg border bg-card text-card-foreground shadow-sm\", className)}\n {...props}\n />\n ),\n);\nCard.displayName = \"Card\";\n\nexport const CardHeader = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={cn(\"flex flex-col space-y-1.5 p-4\", className)} {...props} />\n ),\n);\nCardHeader.displayName = \"CardHeader\";\n\nexport const CardTitle = forwardRef<HTMLHeadingElement, HTMLAttributes<HTMLHeadingElement>>(\n ({ className, ...props }, ref) => (\n <h3\n ref={ref}\n className={cn(\"text-base font-semibold leading-none tracking-tight\", className)}\n {...props}\n />\n ),\n);\nCardTitle.displayName = \"CardTitle\";\n\nexport const CardDescription = forwardRef<HTMLParagraphElement, HTMLAttributes<HTMLParagraphElement>>(\n ({ className, ...props }, ref) => (\n <p ref={ref} className={cn(\"text-sm text-muted-foreground\", className)} {...props} />\n ),\n);\nCardDescription.displayName = \"CardDescription\";\n\nexport const CardContent = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={cn(\"p-4 pt-0\", className)} {...props} />\n ),\n);\nCardContent.displayName = \"CardContent\";\n\nexport const CardFooter = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={cn(\"flex items-center p-4 pt-0\", className)} {...props} />\n ),\n);\nCardFooter.displayName = \"CardFooter\";","import * as ScrollAreaPrimitive from \"@radix-ui/react-scroll-area\";\nimport { forwardRef, type ComponentPropsWithoutRef, type ElementRef } from \"react\";\nimport { cn } from \"../../lib/utils.js\";\n\nexport const ScrollArea = forwardRef<\n ElementRef<typeof ScrollAreaPrimitive.Root>,\n ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root>\n>(({ className, children, ...props }, ref) => (\n <ScrollAreaPrimitive.Root\n ref={ref}\n className={cn(\"relative overflow-hidden\", className)}\n {...props}\n >\n <ScrollAreaPrimitive.Viewport className=\"h-full w-full rounded-[inherit]\">\n {children}\n </ScrollAreaPrimitive.Viewport>\n <ScrollBar />\n <ScrollAreaPrimitive.Corner />\n </ScrollAreaPrimitive.Root>\n));\nScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;\n\nconst ScrollBar = forwardRef<\n ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,\n ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>\n>(({ className, orientation = \"vertical\", ...props }, ref) => (\n <ScrollAreaPrimitive.ScrollAreaScrollbar\n ref={ref}\n orientation={orientation}\n className={cn(\n \"flex touch-none select-none transition-colors\",\n orientation === \"vertical\" && \"h-full w-2.5 border-l border-l-transparent p-[1px]\",\n orientation === \"horizontal\" && \"h-2.5 flex-col border-t border-t-transparent p-[1px]\",\n className,\n )}\n {...props}\n >\n <ScrollAreaPrimitive.ScrollAreaThumb className=\"relative flex-1 rounded-full bg-border\" />\n </ScrollAreaPrimitive.ScrollAreaScrollbar>\n));\nScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;","import * as AvatarPrimitive from \"@radix-ui/react-avatar\";\nimport { forwardRef, type ComponentPropsWithoutRef, type ElementRef } from \"react\";\nimport { cn } from \"../../lib/utils.js\";\n\nexport const avatarClasses = \"relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full\";\nexport const avatarImageClasses = \"aspect-square h-full w-full\";\nexport const avatarFallbackClasses =\n \"flex h-full w-full items-center justify-center rounded-full bg-muted text-xs font-medium uppercase\";\n\nexport const avatarLetter = (name: string): string =>\n name\n .trim()\n .split(/\\s+/)\n .slice(0, 2)\n .map((s) => s[0]?.toUpperCase() ?? \"\")\n .join(\"\") || \"·\";\n\nexport const avatarHue = (seed?: string): string => {\n const text = (seed ?? \"x\").trim();\n let hash = 0;\n for (let i = 0; i < text.length; i++) hash = (hash * 31 + text.charCodeAt(i)) >>> 0;\n return `hsl(${hash % 360}deg 70% 88%)`;\n};\n\nexport const avatarForeground = (seed?: string): string => {\n const text = (seed ?? \"x\").trim();\n let hash = 0;\n for (let i = 0; i < text.length; i++) hash = (hash * 17 + text.charCodeAt(i)) >>> 0;\n return `hsl(${hash % 360}deg 40% 25%)`;\n};\n\nexport const AvatarRoot = forwardRef<\n ElementRef<typeof AvatarPrimitive.Root>,\n ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>\n>(({ className, ...props }, ref) => (\n <AvatarPrimitive.Root\n ref={ref}\n className={cn(avatarClasses, className)}\n {...props}\n />\n));\nAvatarRoot.displayName = \"AvatarRoot\";\n\nexport const AvatarImage = forwardRef<\n ElementRef<typeof AvatarPrimitive.Image>,\n ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>\n>(({ className, ...props }, ref) => (\n <AvatarPrimitive.Image\n ref={ref}\n className={cn(avatarImageClasses, className)}\n {...props}\n />\n));\nAvatarImage.displayName = \"AvatarImage\";\n\nexport const AvatarFallback = forwardRef<\n ElementRef<typeof AvatarPrimitive.Fallback>,\n ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>\n>(({ className, ...props }, ref) => (\n <AvatarPrimitive.Fallback\n ref={ref}\n className={cn(avatarFallbackClasses, className)}\n {...props}\n />\n));\nAvatarFallback.displayName = \"AvatarFallback\";","import * as DropdownMenuPrimitive from \"@radix-ui/react-dropdown-menu\";\nimport { forwardRef, type ComponentPropsWithoutRef, type ElementRef } from \"react\";\nimport { cn } from \"../../lib/utils.js\";\n\nexport const DropdownMenu = DropdownMenuPrimitive.Root;\nexport const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;\nexport const DropdownMenuGroup = DropdownMenuPrimitive.Group;\nexport const DropdownMenuPortal = DropdownMenuPrimitive.Portal;\nexport const DropdownMenuSub = DropdownMenuPrimitive.Sub;\nexport const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;\n\nexport const DropdownMenuContent = forwardRef<\n ElementRef<typeof DropdownMenuPrimitive.Content>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>\n>(({ className, sideOffset = 4, ...props }, ref) => (\n <DropdownMenuPrimitive.Portal>\n <DropdownMenuPrimitive.Content\n ref={ref}\n sideOffset={sideOffset}\n className={cn(\n \"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md\",\n className,\n )}\n {...props}\n />\n </DropdownMenuPrimitive.Portal>\n));\nDropdownMenuContent.displayName = \"DropdownMenuContent\";\n\nexport const DropdownMenuItem = forwardRef<\n ElementRef<typeof DropdownMenuPrimitive.Item>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & { inset?: boolean }\n>(({ className, inset, ...props }, ref) => (\n <DropdownMenuPrimitive.Item\n ref={ref}\n className={cn(\n \"relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:size-4\",\n inset && \"pl-8\",\n className,\n )}\n {...props}\n />\n));\nDropdownMenuItem.displayName = \"DropdownMenuItem\";\n\nexport const DropdownMenuLabel = forwardRef<\n ElementRef<typeof DropdownMenuPrimitive.Label>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & { inset?: boolean }\n>(({ className, inset, ...props }, ref) => (\n <DropdownMenuPrimitive.Label\n ref={ref}\n className={cn(\n \"px-2 py-1.5 text-xs font-semibold uppercase text-muted-foreground\",\n inset && \"pl-8\",\n className,\n )}\n {...props}\n />\n));\nDropdownMenuLabel.displayName = \"DropdownMenuLabel\";\n\nexport const DropdownMenuSeparator = forwardRef<\n ElementRef<typeof DropdownMenuPrimitive.Separator>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <DropdownMenuPrimitive.Separator\n ref={ref}\n className={cn(\"-mx-1 my-1 h-px bg-muted\", className)}\n {...props}\n />\n));\nDropdownMenuSeparator.displayName = \"DropdownMenuSeparator\";\n\nexport const DropdownMenuCheckboxItem = forwardRef<\n ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>\n>(({ className, children, checked, ...props }, ref) => (\n <DropdownMenuPrimitive.CheckboxItem\n ref={ref}\n checked={checked}\n className={cn(\n \"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50\",\n className,\n )}\n {...props}\n >\n {children}\n </DropdownMenuPrimitive.CheckboxItem>\n));\nDropdownMenuCheckboxItem.displayName = \"DropdownMenuCheckboxItem\";","import * as PopoverPrimitive from \"@radix-ui/react-popover\";\nimport { forwardRef, type ComponentPropsWithoutRef, type ElementRef } from \"react\";\nimport { cn } from \"../../lib/utils.js\";\n\nexport const Popover = PopoverPrimitive.Root;\nexport const PopoverTrigger = PopoverPrimitive.Trigger;\nexport const PopoverAnchor = PopoverPrimitive.Anchor;\n\nexport const PopoverContent = forwardRef<\n ElementRef<typeof PopoverPrimitive.Content>,\n ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>\n>(({ className, align = \"center\", sideOffset = 4, ...props }, ref) => (\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n ref={ref}\n align={align}\n sideOffset={sideOffset}\n className={cn(\n \"z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none\",\n className,\n )}\n {...props}\n />\n </PopoverPrimitive.Portal>\n));\nPopoverContent.displayName = \"PopoverContent\";","import * as TooltipPrimitive from \"@radix-ui/react-tooltip\";\nimport { forwardRef, type ComponentPropsWithoutRef, type ElementRef } from \"react\";\nimport { cn } from \"../../lib/utils.js\";\n\nexport const TooltipProvider = TooltipPrimitive.Provider;\nexport const Tooltip = TooltipPrimitive.Root;\nexport const TooltipTrigger = TooltipPrimitive.Trigger;\n\nexport const TooltipContent = forwardRef<\n ElementRef<typeof TooltipPrimitive.Content>,\n ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>\n>(({ className, sideOffset = 4, ...props }, ref) => (\n <TooltipPrimitive.Portal>\n <TooltipPrimitive.Content\n ref={ref}\n sideOffset={sideOffset}\n className={cn(\n \"z-50 overflow-hidden rounded-md bg-foreground px-3 py-1.5 text-xs text-background shadow\",\n className,\n )}\n {...props}\n />\n </TooltipPrimitive.Portal>\n));\nTooltipContent.displayName = \"TooltipContent\";","import * as SwitchPrimitive from \"@radix-ui/react-switch\";\nimport { forwardRef, type ComponentPropsWithoutRef, type ElementRef } from \"react\";\nimport { cn } from \"../../lib/utils.js\";\n\nexport const Switch = forwardRef<\n ElementRef<typeof SwitchPrimitive.Root>,\n ComponentPropsWithoutRef<typeof SwitchPrimitive.Root>\n>(({ className, ...props }, ref) => (\n <SwitchPrimitive.Root\n ref={ref}\n className={cn(\n \"peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input\",\n className,\n )}\n {...props}\n >\n <SwitchPrimitive.Thumb\n className={cn(\n \"pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0\",\n )}\n />\n </SwitchPrimitive.Root>\n));\nSwitch.displayName = \"Switch\";","import * as DialogPrimitive from \"@radix-ui/react-dialog\";\nimport { X } from \"lucide-react\";\nimport {\n forwardRef,\n type ComponentPropsWithoutRef,\n type ElementRef,\n type HTMLAttributes,\n} from \"react\";\nimport { cn } from \"../../lib/utils.js\";\n\nexport const Dialog = DialogPrimitive.Root;\nexport const DialogTrigger = DialogPrimitive.Trigger;\nexport const DialogPortal = DialogPrimitive.Portal;\nexport const DialogClose = DialogPrimitive.Close;\n\nexport const DialogOverlay = forwardRef<\n ElementRef<typeof DialogPrimitive.Overlay>,\n ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n className={cn(\n \"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\",\n className,\n )}\n {...props}\n />\n));\nDialogOverlay.displayName = \"DialogOverlay\";\n\nexport const dialogContentClasses =\n \"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg\";\n\nexport const DialogContent = forwardRef<\n ElementRef<typeof DialogPrimitive.Content>,\n ComponentPropsWithoutRef<typeof DialogPrimitive.Content>\n>(({ className, children, ...props }, ref) => (\n <DialogPortal>\n <DialogOverlay />\n <DialogPrimitive.Content\n ref={ref}\n className={cn(dialogContentClasses, className)}\n {...props}\n >\n {children}\n <DialogPrimitive.Close className=\"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none\">\n <X className=\"h-4 w-4\" />\n <span className=\"sr-only\">Close</span>\n </DialogPrimitive.Close>\n </DialogPrimitive.Content>\n </DialogPortal>\n));\nDialogContent.displayName = \"DialogContent\";\n\nexport const dialogHeaderClasses =\n \"flex flex-col space-y-1.5 text-center sm:text-left\";\n\nexport function DialogHeader({ className, ...props }: HTMLAttributes<HTMLDivElement>) {\n return <div className={cn(dialogHeaderClasses, className)} {...props} />;\n}\nDialogHeader.displayName = \"DialogHeader\";\n\nexport const dialogFooterClasses =\n \"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2\";\n\nexport function DialogFooter({ className, ...props }: HTMLAttributes<HTMLDivElement>) {\n return <div className={cn(dialogFooterClasses, className)} {...props} />;\n}\nDialogFooter.displayName = \"DialogFooter\";\n\nexport const dialogTitleClasses =\n \"text-lg font-semibold leading-none tracking-tight\";\n\nexport const DialogTitle = forwardRef<\n ElementRef<typeof DialogPrimitive.Title>,\n ComponentPropsWithoutRef<typeof DialogPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n className={cn(dialogTitleClasses, className)}\n {...props}\n />\n));\nDialogTitle.displayName = \"DialogTitle\";\n\nexport const dialogDescriptionClasses = \"text-sm text-muted-foreground\";\n\nexport const DialogDescription = forwardRef<\n ElementRef<typeof DialogPrimitive.Description>,\n ComponentPropsWithoutRef<typeof DialogPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n ref={ref}\n className={cn(dialogDescriptionClasses, className)}\n {...props}\n />\n));\nDialogDescription.displayName = \"DialogDescription\";","import * as SeparatorPrimitive from \"@radix-ui/react-separator\";\nimport { forwardRef, type ComponentPropsWithoutRef, type ElementRef } from \"react\";\nimport { cn } from \"../../lib/utils.js\";\n\nexport const Separator = forwardRef<\n ElementRef<typeof SeparatorPrimitive.Root>,\n ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>\n>(({ className, orientation = \"horizontal\", decorative = true, ...props }, ref) => (\n <SeparatorPrimitive.Root\n ref={ref}\n decorative={decorative}\n orientation={orientation}\n className={cn(\n \"shrink-0 bg-border\",\n orientation === \"horizontal\" ? \"h-px w-full\" : \"h-full w-px\",\n className,\n )}\n {...props}\n />\n));\nSeparator.displayName = \"Separator\";","import { cva, type VariantProps } from \"class-variance-authority\";\nimport { forwardRef, type HTMLAttributes } from \"react\";\nimport { cn } from \"../../lib/utils.js\";\n\nconst badgeVariants = cva(\n \"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2\",\n {\n variants: {\n variant: {\n default: \"border-transparent bg-primary text-primary-foreground\",\n secondary: \"border-transparent bg-secondary text-secondary-foreground\",\n destructive: \"border-transparent bg-destructive text-destructive-foreground\",\n outline: \"text-foreground\",\n success:\n \"border-transparent bg-emerald-500/15 text-emerald-700 dark:text-emerald-300\",\n warning:\n \"border-transparent bg-amber-500/15 text-amber-700 dark:text-amber-300\",\n },\n },\n defaultVariants: { variant: \"default\" },\n },\n);\n\nexport interface BadgeProps\n extends HTMLAttributes<HTMLDivElement>,\n VariantProps<typeof badgeVariants> {}\n\nexport const Badge = forwardRef<HTMLDivElement, BadgeProps>(\n ({ className, variant, ...props }, ref) => (\n <div ref={ref} className={cn(badgeVariants({ variant }), className)} {...props} />\n ),\n);\nBadge.displayName = \"Badge\";","import * as TabsPrimitive from \"@radix-ui/react-tabs\";\nimport { forwardRef, type ComponentPropsWithoutRef, type ElementRef } from \"react\";\nimport { cn } from \"../../lib/utils.js\";\n\nexport const Tabs = TabsPrimitive.Root;\n\nexport const TabsList = forwardRef<\n ElementRef<typeof TabsPrimitive.List>,\n ComponentPropsWithoutRef<typeof TabsPrimitive.List>\n>(({ className, ...props }, ref) => (\n <TabsPrimitive.List\n ref={ref}\n className={cn(\n \"inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground\",\n className,\n )}\n {...props}\n />\n));\nTabsList.displayName = \"TabsList\";\n\nexport const TabsTrigger = forwardRef<\n ElementRef<typeof TabsPrimitive.Trigger>,\n ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>\n>(({ className, ...props }, ref) => (\n <TabsPrimitive.Trigger\n ref={ref}\n className={cn(\n \"inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm\",\n className,\n )}\n {...props}\n />\n));\nTabsTrigger.displayName = \"TabsTrigger\";\n\nexport const TabsContent = forwardRef<\n ElementRef<typeof TabsPrimitive.Content>,\n ComponentPropsWithoutRef<typeof TabsPrimitive.Content>\n>(({ className, ...props }, ref) => (\n <TabsPrimitive.Content\n ref={ref}\n className={cn(\n \"mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2\",\n className,\n )}\n {...props}\n />\n));\nTabsContent.displayName = \"TabsContent\";","import * as React from \"react\"\nimport * as SelectPrimitive from \"@radix-ui/react-select\"\nimport { Check, ChevronDown, ChevronUp } from \"lucide-react\"\n\nimport { cn } from \"../../lib/utils.js\"\n\nconst Select = SelectPrimitive.Root\n\nconst SelectGroup = SelectPrimitive.Group\n\nconst SelectValue = SelectPrimitive.Value\n\nconst SelectTrigger = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Trigger>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>\n>(({ className, children, ...props }, ref) => (\n <SelectPrimitive.Trigger\n ref={ref}\n className={cn(\n \"flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1\",\n className\n )}\n {...props}\n >\n {children}\n <SelectPrimitive.Icon asChild>\n <ChevronDown className=\"h-4 w-4 opacity-50\" />\n </SelectPrimitive.Icon>\n </SelectPrimitive.Trigger>\n))\nSelectTrigger.displayName = SelectPrimitive.Trigger.displayName\n\nconst SelectScrollUpButton = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.ScrollUpButton\n ref={ref}\n className={cn(\n \"flex cursor-default items-center justify-center py-1\",\n className\n )}\n {...props}\n >\n <ChevronUp className=\"h-4 w-4\" />\n </SelectPrimitive.ScrollUpButton>\n))\nSelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName\n\nconst SelectScrollDownButton = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.ScrollDownButton\n ref={ref}\n className={cn(\n \"flex cursor-default items-center justify-center py-1\",\n className\n )}\n {...props}\n >\n <ChevronDown className=\"h-4 w-4\" />\n </SelectPrimitive.ScrollDownButton>\n))\nSelectScrollDownButton.displayName =\n SelectPrimitive.ScrollDownButton.displayName\n\nconst SelectContent = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>\n>(({ className, children, position = \"popper\", ...props }, ref) => (\n <SelectPrimitive.Portal>\n <SelectPrimitive.Content\n ref={ref}\n className={cn(\n \"relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]\",\n position === \"popper\" &&\n \"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1\",\n className\n )}\n position={position}\n {...props}\n >\n <SelectScrollUpButton />\n <SelectPrimitive.Viewport\n className={cn(\n \"p-1\",\n position === \"popper\" &&\n \"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]\"\n )}\n >\n {children}\n </SelectPrimitive.Viewport>\n <SelectScrollDownButton />\n </SelectPrimitive.Content>\n </SelectPrimitive.Portal>\n))\nSelectContent.displayName = SelectPrimitive.Content.displayName\n\nconst SelectLabel = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Label>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.Label\n ref={ref}\n className={cn(\"px-2 py-1.5 text-sm font-semibold\", className)}\n {...props}\n />\n))\nSelectLabel.displayName = SelectPrimitive.Label.displayName\n\nconst SelectItem = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Item>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>\n>(({ className, children, ...props }, ref) => (\n <SelectPrimitive.Item\n ref={ref}\n className={cn(\n \"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50\",\n className\n )}\n {...props}\n >\n <span className=\"absolute right-2 flex h-3.5 w-3.5 items-center justify-center\">\n <SelectPrimitive.ItemIndicator>\n <Check className=\"h-4 w-4\" />\n </SelectPrimitive.ItemIndicator>\n </span>\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n </SelectPrimitive.Item>\n))\nSelectItem.displayName = SelectPrimitive.Item.displayName\n\nconst SelectSeparator = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Separator>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.Separator\n ref={ref}\n className={cn(\"-mx-1 my-1 h-px bg-muted\", className)}\n {...props}\n />\n))\nSelectSeparator.displayName = SelectPrimitive.Separator.displayName\n\nexport {\n Select,\n SelectGroup,\n SelectValue,\n SelectTrigger,\n SelectContent,\n SelectLabel,\n SelectItem,\n SelectSeparator,\n SelectScrollUpButton,\n SelectScrollDownButton,\n}\n","\"use client\"\n\nimport * as React from \"react\"\nimport * as LabelPrimitive from \"@radix-ui/react-label\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\n\nimport { cn } from \"../../lib/utils.js\"\n\nconst labelVariants = cva(\n \"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70\"\n)\n\nconst Label = React.forwardRef<\n React.ElementRef<typeof LabelPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &\n VariantProps<typeof labelVariants>\n>(({ className, ...props }, ref) => (\n <LabelPrimitive.Root\n ref={ref}\n className={cn(labelVariants(), className)}\n {...props}\n />\n))\nLabel.displayName = LabelPrimitive.Root.displayName\n\nexport { Label }\n","import * as React from \"react\"\nimport * as CheckboxPrimitive from \"@radix-ui/react-checkbox\"\nimport { Check } from \"lucide-react\"\n\nimport { cn } from \"../../lib/utils.js\"\n\nconst Checkbox = React.forwardRef<\n React.ElementRef<typeof CheckboxPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>\n>(({ className, ...props }, ref) => (\n <CheckboxPrimitive.Root\n ref={ref}\n className={cn(\n \"grid place-content-center peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground\",\n className\n )}\n {...props}\n >\n <CheckboxPrimitive.Indicator\n className={cn(\"grid place-content-center text-current\")}\n >\n <Check className=\"h-4 w-4\" />\n </CheckboxPrimitive.Indicator>\n </CheckboxPrimitive.Root>\n))\nCheckbox.displayName = CheckboxPrimitive.Root.displayName\n\nexport { Checkbox }\n","import * as CollapsiblePrimitive from \"@radix-ui/react-collapsible\"\n\nconst Collapsible = CollapsiblePrimitive.Root\n\nconst CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger\n\nconst CollapsibleContent = CollapsiblePrimitive.CollapsibleContent\n\nexport { Collapsible, CollapsibleTrigger, CollapsibleContent }\n","/**\n * AgentManager — a dialog to create, read, update, and delete switchable\n * assistant \"agents\". Built-in agents are read-only (but can be duplicated);\n * user agents persist to localStorage via `lib/agents`. Picking an agent\n * calls `onApply`, which the header maps onto the live chat config.\n */\nimport {\n ArrowLeft,\n Check,\n Copy,\n Pencil,\n Plus,\n Trash2,\n} from \"lucide-react\";\nimport { useEffect, useState } from \"react\";\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n} from \"../ui/dialog.js\";\nimport { Button } from \"../ui/button.js\";\nimport { Input, Textarea } from \"../ui/input.js\";\nimport { Label } from \"../ui/label.js\";\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from \"../ui/select.js\";\nimport { Badge } from \"../ui/badge.js\";\nimport {\n deleteAgent as removeAgent,\n duplicateAgent,\n listAgents,\n saveAgent,\n} from \"../../lib/agents.js\";\nimport { cn } from \"../../lib/utils.js\";\nimport type { Agent } from \"../../types/chat.js\";\n\nconst TONES = [\n \"friendly\",\n \"professional\",\n \"casual\",\n \"concise\",\n \"playful\",\n \"academic\",\n] as const;\n\nexport interface AgentManagerProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n activeAgentId?: string | null;\n onApply: (agent: Agent) => void;\n /** Open straight into the create form. */\n startInCreate?: boolean;\n}\n\ntype Draft = {\n id?: string;\n name: string;\n description: string;\n icon: string;\n systemPrompt: string;\n tone: string;\n suggestions: string;\n};\n\nconst EMPTY_DRAFT: Draft = {\n name: \"\",\n description: \"\",\n icon: \"🤖\",\n systemPrompt: \"\",\n tone: \"friendly\",\n suggestions: \"\",\n};\n\nfunction toDraft(a: Agent): Draft {\n return {\n id: a.id,\n name: a.name,\n description: a.description ?? \"\",\n icon: a.icon ?? \"🤖\",\n systemPrompt: a.systemPrompt,\n tone: (a.tone as string) ?? \"friendly\",\n suggestions: (a.suggestions ?? []).join(\"\\n\"),\n };\n}\n\nexport function AgentManager({\n open,\n onOpenChange,\n activeAgentId,\n onApply,\n startInCreate = false,\n}: AgentManagerProps) {\n const [agents, setAgents] = useState<Agent[]>([]);\n const [view, setView] = useState<\"list\" | \"edit\">(\"list\");\n const [draft, setDraft] = useState<Draft>(EMPTY_DRAFT);\n\n const refresh = () => setAgents(listAgents());\n\n useEffect(() => {\n if (open) {\n refresh();\n setView(startInCreate ? \"edit\" : \"list\");\n setDraft(EMPTY_DRAFT);\n }\n }, [open, startInCreate]);\n\n const startCreate = () => {\n setDraft(EMPTY_DRAFT);\n setView(\"edit\");\n };\n const startEdit = (a: Agent) => {\n setDraft(toDraft(a));\n setView(\"edit\");\n };\n\n const canSave = draft.name.trim().length > 0 && draft.systemPrompt.trim().length > 0;\n\n const onSave = () => {\n if (!canSave) return;\n const saved = saveAgent({\n id: draft.id,\n name: draft.name,\n description: draft.description,\n icon: draft.icon,\n systemPrompt: draft.systemPrompt,\n tone: draft.tone,\n suggestions: draft.suggestions.split(\"\\n\"),\n });\n refresh();\n onApply(saved);\n onOpenChange(false);\n };\n\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent className=\"max-w-lg gap-0 overflow-hidden p-0\">\n {view === \"list\" ? (\n <ListView\n agents={agents}\n activeAgentId={activeAgentId}\n onCreate={startCreate}\n onEdit={startEdit}\n onApply={(a) => {\n onApply(a);\n onOpenChange(false);\n }}\n onDuplicate={(id) => {\n duplicateAgent(id);\n refresh();\n }}\n onDelete={(id) => {\n removeAgent(id);\n refresh();\n }}\n />\n ) : (\n <EditView\n draft={draft}\n setDraft={setDraft}\n canSave={canSave}\n onBack={() => setView(\"list\")}\n onSave={onSave}\n />\n )}\n </DialogContent>\n </Dialog>\n );\n}\n\nfunction ListView({\n agents,\n activeAgentId,\n onCreate,\n onEdit,\n onApply,\n onDuplicate,\n onDelete,\n}: {\n agents: Agent[];\n activeAgentId?: string | null;\n onCreate: () => void;\n onEdit: (a: Agent) => void;\n onApply: (a: Agent) => void;\n onDuplicate: (id: string) => void;\n onDelete: (id: string) => void;\n}) {\n return (\n <>\n <DialogHeader className=\"border-b border-border/60 p-5 pb-4\">\n <DialogTitle>Agents</DialogTitle>\n <DialogDescription>\n Switch, create, edit, or remove your assistant agents.\n </DialogDescription>\n </DialogHeader>\n\n <div className=\"max-h-[55vh] space-y-1.5 overflow-y-auto p-3 scrollbar-thin\">\n {agents.map((a) => {\n const active = a.id === activeAgentId;\n return (\n <div\n key={a.id}\n className={cn(\n \"group/agent flex items-center gap-3 rounded-xl border p-2.5 transition-colors\",\n active\n ? \"border-primary/40 bg-primary/5\"\n : \"border-border/60 hover:bg-accent/50\",\n )}\n >\n <span className=\"grid size-9 shrink-0 place-items-center rounded-lg bg-muted text-lg\">\n {a.icon ?? \"🤖\"}\n </span>\n <Button\n type=\"button\"\n variant=\"ghost\"\n onClick={() => onApply(a)}\n className=\"h-auto min-w-0 flex-1 flex-col items-stretch justify-start gap-0 p-0 text-left hover:bg-transparent\"\n >\n <span className=\"flex items-center gap-1.5\">\n <span className=\"truncate text-sm font-medium\">{a.name}</span>\n {active && (\n <Check className=\"size-3.5 shrink-0 text-primary\" />\n )}\n {a.builtIn && (\n <Badge variant=\"secondary\" className=\"text-[9px]\">\n built-in\n </Badge>\n )}\n </span>\n {a.description && (\n <span className=\"block truncate text-xs font-normal text-muted-foreground\">\n {a.description}\n </span>\n )}\n </Button>\n <div className=\"flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity group-hover/agent:opacity-100 focus-within:opacity-100\">\n <IconBtn label=\"Duplicate\" onClick={() => onDuplicate(a.id)}>\n <Copy className=\"size-3.5\" />\n </IconBtn>\n {!a.builtIn && (\n <>\n <IconBtn label=\"Edit\" onClick={() => onEdit(a)}>\n <Pencil className=\"size-3.5\" />\n </IconBtn>\n <IconBtn\n label=\"Delete\"\n destructive\n onClick={() => onDelete(a.id)}\n >\n <Trash2 className=\"size-3.5\" />\n </IconBtn>\n </>\n )}\n </div>\n </div>\n );\n })}\n </div>\n\n <DialogFooter className=\"border-t border-border/60 p-4\">\n <Button onClick={onCreate} className=\"w-full gap-2 sm:w-auto\">\n <Plus className=\"size-4\" />\n New agent\n </Button>\n </DialogFooter>\n </>\n );\n}\n\nfunction EditView({\n draft,\n setDraft,\n canSave,\n onBack,\n onSave,\n}: {\n draft: Draft;\n setDraft: (d: Draft) => void;\n canSave: boolean;\n onBack: () => void;\n onSave: () => void;\n}) {\n const set = <K extends keyof Draft>(k: K, v: Draft[K]) =>\n setDraft({ ...draft, [k]: v });\n\n return (\n <>\n <DialogHeader className=\"border-b border-border/60 p-5 pb-4\">\n <DialogTitle className=\"flex items-center gap-2\">\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n onClick={onBack}\n aria-label=\"Back to list\"\n className=\"text-muted-foreground hover:text-foreground\"\n >\n <ArrowLeft className=\"size-4\" />\n </Button>\n {draft.id ? \"Edit agent\" : \"New agent\"}\n </DialogTitle>\n </DialogHeader>\n\n <div className=\"max-h-[55vh] space-y-4 overflow-y-auto p-5 scrollbar-thin\">\n <div className=\"flex gap-3\">\n <Field label=\"Icon\" className=\"w-20\">\n <Input\n value={draft.icon}\n onChange={(e) => set(\"icon\", e.target.value.slice(0, 2))}\n className=\"text-center text-lg\"\n maxLength={2}\n />\n </Field>\n <Field label=\"Name\" className=\"flex-1\">\n <Input\n value={draft.name}\n onChange={(e) => set(\"name\", e.target.value)}\n placeholder=\"e.g. SQL expert\"\n />\n </Field>\n </div>\n\n <Field label=\"Description\">\n <Input\n value={draft.description}\n onChange={(e) => set(\"description\", e.target.value)}\n placeholder=\"One-line summary (optional)\"\n />\n </Field>\n\n <Field label=\"System prompt\">\n <Textarea\n value={draft.systemPrompt}\n onChange={(e) => set(\"systemPrompt\", e.target.value)}\n placeholder=\"You are a helpful assistant that…\"\n className=\"min-h-28 resize-y\"\n />\n </Field>\n\n <Field label=\"Tone\">\n <Select value={draft.tone} onValueChange={(v) => set(\"tone\", v)}>\n <SelectTrigger className=\"capitalize\">\n <SelectValue placeholder=\"Select a tone\" />\n </SelectTrigger>\n <SelectContent>\n {TONES.map((t) => (\n <SelectItem key={t} value={t} className=\"capitalize\">\n {t}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </Field>\n\n <Field label=\"Starter suggestions\" hint=\"one per line\">\n <Textarea\n value={draft.suggestions}\n onChange={(e) => set(\"suggestions\", e.target.value)}\n placeholder={\"Explain a concept\\nReview my code\"}\n className=\"min-h-20 resize-y\"\n />\n </Field>\n </div>\n\n <DialogFooter className=\"gap-2 border-t border-border/60 p-4\">\n <Button variant=\"ghost\" onClick={onBack}>\n Cancel\n </Button>\n <Button onClick={onSave} disabled={!canSave} className=\"gap-2\">\n <Check className=\"size-4\" />\n Save &amp; use\n </Button>\n </DialogFooter>\n </>\n );\n}\n\nfunction Field({\n label,\n hint,\n className,\n children,\n}: {\n label: string;\n hint?: string;\n className?: string;\n children: React.ReactNode;\n}) {\n return (\n <div className={cn(\"space-y-1.5\", className)}>\n <Label className=\"flex items-center gap-1.5 text-xs font-medium text-muted-foreground\">\n {label}\n {hint && <span className=\"text-muted-foreground/60\">· {hint}</span>}\n </Label>\n {children}\n </div>\n );\n}\n\nfunction IconBtn({\n label,\n destructive,\n onClick,\n children,\n}: {\n label: string;\n destructive?: boolean;\n onClick: () => void;\n children: React.ReactNode;\n}) {\n return (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n aria-label={label}\n onClick={onClick}\n className={cn(\n \"text-muted-foreground hover:bg-foreground/10\",\n destructive ? \"hover:text-destructive\" : \"hover:text-foreground\",\n )}\n >\n {children}\n </Button>\n );\n}\n","/**\n * ThemeToggle — a small, dependency-free light/dark switch.\n *\n * Toggles the `.dark` class on <html>, persists the choice to localStorage\n * (key: `ai-schadcn-theme`), and falls back to the OS preference on first\n * load. Animated sun/moon crossfade. Safe to render anywhere; it manages the\n * document class itself so it works without a theme provider.\n */\nimport { Moon, Sun } from \"lucide-react\";\nimport { useCallback, useEffect, useState } from \"react\";\nimport { Button } from \"../ui/button.js\";\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"../ui/tooltip.js\";\n\nconst STORAGE_KEY = \"ai-schadcn-theme\";\n\ntype Theme = \"light\" | \"dark\";\n\nfunction getInitialTheme(): Theme {\n if (typeof document === \"undefined\") return \"light\";\n if (document.documentElement.classList.contains(\"dark\")) return \"dark\";\n try {\n const stored = localStorage.getItem(STORAGE_KEY);\n if (stored === \"light\" || stored === \"dark\") return stored;\n } catch {\n /* ignore */\n }\n return window.matchMedia?.(\"(prefers-color-scheme: dark)\").matches\n ? \"dark\"\n : \"light\";\n}\n\nfunction applyTheme(theme: Theme) {\n const root = document.documentElement;\n root.classList.toggle(\"dark\", theme === \"dark\");\n root.style.colorScheme = theme;\n}\n\nexport function ThemeToggle({ className }: { className?: string }) {\n const [theme, setTheme] = useState<Theme>(\"light\");\n\n useEffect(() => {\n const initial = getInitialTheme();\n setTheme(initial);\n applyTheme(initial);\n }, []);\n\n const toggle = useCallback(() => {\n setTheme((prev) => {\n const next: Theme = prev === \"dark\" ? \"light\" : \"dark\";\n applyTheme(next);\n try {\n localStorage.setItem(STORAGE_KEY, next);\n } catch {\n /* ignore */\n }\n return next;\n });\n }, []);\n\n const isDark = theme === \"dark\";\n\n return (\n <Tooltip>\n <TooltipTrigger asChild>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n onClick={toggle}\n aria-label={isDark ? \"Switch to light mode\" : \"Switch to dark mode\"}\n className={[\"relative\", className].filter(Boolean).join(\" \")}\n >\n <Sun\n className=\"size-4 rotate-0 scale-100 transition-all duration-300 dark:-rotate-90 dark:scale-0\"\n />\n <Moon\n className=\"absolute size-4 rotate-90 scale-0 transition-all duration-300 dark:rotate-0 dark:scale-100\"\n />\n </Button>\n </TooltipTrigger>\n <TooltipContent>{isDark ? \"Light mode\" : \"Dark mode\"}</TooltipContent>\n </Tooltip>\n );\n}\n","/**\n * Chat header — brand mark, title/subtitle, and the control cluster\n * (personality, context documents, conversation history, theme toggle,\n * overflow). Rendered on a translucent, blurred bar that floats above the\n * message stream.\n */\nimport {\n Check,\n ChevronDown,\n FileText,\n History,\n MessageSquarePlus,\n MoreHorizontal,\n Plus,\n Settings2,\n Sparkles,\n Trash2,\n Wrench,\n} from \"lucide-react\";\nimport { useState } from \"react\";\nimport { useChat } from \"../../hooks/useChat.js\";\nimport {\n getActiveAgentId,\n listAgents,\n setActiveAgentId,\n} from \"../../lib/agents.js\";\nimport { Badge } from \"../ui/badge.js\";\nimport { Button } from \"../ui/button.js\";\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from \"../ui/dropdown-menu.js\";\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"../ui/tooltip.js\";\nimport { AgentManager } from \"./AgentManager.js\";\nimport { ThemeToggle } from \"./ThemeToggle.js\";\nimport { cn } from \"../../lib/utils.js\";\nimport type { Agent, PromptDocument } from \"../../types/chat.js\";\n\nexport interface ChatHeaderProps {\n className?: string;\n}\n\nexport function ChatHeader({ className }: ChatHeaderProps) {\n const chat = useChat();\n const cfg = chat.config;\n const ui = cfg.ui ?? {};\n const [agentsOpen, setAgentsOpen] = useState(false);\n const [docsOpen, setDocsOpen] = useState(false);\n const [managerOpen, setManagerOpen] = useState(false);\n const [managerCreate, setManagerCreate] = useState(false);\n const [activeAgentId, setActiveAgent] = useState<string | null>(() =>\n getActiveAgentId(),\n );\n\n const agents = listAgents();\n const activeAgent =\n agents.find((a) => a.id === activeAgentId) ??\n agents.find((a) => a.name === cfg.personality?.name);\n\n // ui.* visibility flags the user can toggle from the playground form.\n // Default every chip to visible so out-of-the-box behaviour matches the\n // previous always-render header. Setting any of these to false hides the\n // corresponding control cluster; the brand mark, new-chat button, theme\n // toggle, and overflow menu stay always-on.\n const showModelSelector = ui.showModelSelector ?? true;\n const showDocumentPicker = ui.showDocumentPicker ?? true;\n const showToolCalls = ui.showToolCalls ?? true;\n const enableConversationHistory = ui.enableConversationHistory ?? true;\n\n const applyAgent = (agent: Agent) => {\n chat.updateConfig({\n systemPrompt: agent.systemPrompt,\n personality: {\n ...cfg.personality,\n name: agent.name,\n tone: agent.tone,\n avatar: agent.icon,\n ...(agent.locale ? { locale: agent.locale } : {}),\n },\n ui: {\n ...ui,\n title: agent.name,\n ...(agent.suggestions && agent.suggestions.length > 0\n ? { suggestions: agent.suggestions }\n : {}),\n },\n });\n setActiveAgentId(agent.id);\n setActiveAgent(agent.id);\n setAgentsOpen(false);\n };\n\n const openManager = (create: boolean) => {\n setManagerCreate(create);\n setManagerOpen(true);\n setAgentsOpen(false);\n };\n\n const toggleDoc = (doc: PromptDocument) => {\n const current: PromptDocument[] = cfg.documents ?? [];\n const next = current.find((d: PromptDocument) => d.id === doc.id)\n ? current.filter((d: PromptDocument) => d.id !== doc.id)\n : [...current, doc];\n chat.updateConfig({ documents: next });\n };\n\n const builtInDocs: PromptDocument[] = [\n {\n id: \"built-in:web\",\n name: \"Web search guidance\",\n description: \"Cites sources and flags primary vs. aggregated info.\",\n alwaysOn: false,\n body: \"When unsure, prefer citing authoritative web sources and link to them. Distinguish between primary sources and aggregators.\",\n },\n {\n id: \"built-in:code\",\n name: \"Code reviewer\",\n description: \"Checks bugs, security, perf, readability & test coverage.\",\n alwaysOn: false,\n body: \"When reviewing code, point out: 1) correctness bugs, 2) security implications, 3) performance, 4) readability, 5) test coverage. Suggest minimal patches.\",\n },\n {\n id: \"built-in:sql\",\n name: \"SQL guardrails\",\n description: \"Blocks unsafe SQL; requires WHERE clauses & parameters.\",\n alwaysOn: false,\n body: \"Never write destructive SQL without a WHERE clause. Prefer parameterized queries. Always state the table schema when joining.\",\n },\n ];\n\n const docCount = cfg.documents?.length ?? 0;\n const conversations = chat.listConversationsMeta();\n\n return (\n <header\n className={cn(\n \"relative z-20 flex items-center justify-between gap-2 border-b border-border/60 bg-background/70 px-3 py-2.5 backdrop-blur-xl supports-[backdrop-filter]:bg-background/55 sm:px-4\",\n className,\n )}\n >\n <div className=\"flex min-w-0 items-center gap-3\">\n <span className=\"relative grid size-9 shrink-0 place-items-center rounded-xl grad-primary text-primary-foreground shadow-sm glow-primary\">\n {activeAgent?.icon ? (\n <span className=\"text-lg leading-none\">{activeAgent.icon}</span>\n ) : (\n <Sparkles className=\"size-[18px]\" />\n )}\n </span>\n <div className=\"min-w-0\">\n <p className=\"truncate text-sm font-semibold tracking-tight\">\n {ui.title ?? \"Assistant\"}\n </p>\n <p className=\"flex items-center gap-1.5 truncate text-xs text-muted-foreground\">\n <span className=\"inline-block size-1.5 shrink-0 rounded-full bg-success shadow-[0_0_6px_currentColor]\" />\n <span className=\"truncate\">\n {ui.subtitle ?? (cfg.model.label || cfg.model.id || \"Ready\")}\n </span>\n </p>\n </div>\n </div>\n\n <div className=\"flex items-center gap-0.5\">\n {/* Agents menu */}\n {showModelSelector && (\n <DropdownMenu open={agentsOpen} onOpenChange={setAgentsOpen}>\n <DropdownMenuTrigger asChild>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n className=\"hidden h-8 max-w-[180px] gap-1.5 rounded-lg px-2.5 text-xs font-medium text-muted-foreground hover:text-foreground sm:inline-flex\"\n >\n <span className=\"text-sm leading-none\">\n {activeAgent?.icon ?? \"✨\"}\n </span>\n <span className=\"truncate\">\n {activeAgent?.name ?? cfg.personality?.name ?? \"Agent\"}\n </span>\n <ChevronDown className=\"size-3 shrink-0 opacity-50\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\" className=\"w-64\">\n <DropdownMenuLabel>Agents</DropdownMenuLabel>\n <div className=\"max-h-64 overflow-y-auto\">\n {agents.map((a) => (\n <DropdownMenuItem\n key={a.id}\n onClick={() => applyAgent(a)}\n className=\"gap-2\"\n >\n <span className=\"text-base leading-none\">\n {a.icon ?? \"🤖\"}\n </span>\n <span className=\"min-w-0 flex-1 truncate\">{a.name}</span>\n {a.id === activeAgent?.id && (\n <Check className=\"size-3.5 shrink-0 text-primary\" />\n )}\n </DropdownMenuItem>\n ))}\n </div>\n <DropdownMenuSeparator />\n <DropdownMenuItem onClick={() => openManager(true)}>\n <Plus className=\"size-3.5\" />\n New agent\n </DropdownMenuItem>\n <DropdownMenuItem onClick={() => openManager(false)}>\n <Settings2 className=\"size-3.5\" />\n Manage agents…\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n )}\n\n {/* Documents menu */}\n {showDocumentPicker && (\n <DropdownMenu open={docsOpen} onOpenChange={setDocsOpen}>\n <Tooltip>\n <TooltipTrigger asChild>\n <DropdownMenuTrigger asChild>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n className=\"h-8 gap-1.5 rounded-lg px-2.5 text-xs font-medium text-muted-foreground hover:text-foreground\"\n >\n <FileText className=\"size-3.5\" />\n <span className=\"hidden sm:inline\">Docs</span>\n {docCount > 0 && (\n <Badge\n variant=\"secondary\"\n className=\"ml-0.5 h-4 min-w-4 justify-center rounded-full px-1 text-[9px] tabular-nums\"\n >\n {docCount}\n </Badge>\n )}\n </Button>\n </DropdownMenuTrigger>\n </TooltipTrigger>\n <TooltipContent>\n Context documents — extra instructions prepended to the\n model&apos;s system prompt\n </TooltipContent>\n </Tooltip>\n <DropdownMenuContent align=\"end\" className=\"w-72\">\n <DropdownMenuLabel>Context documents</DropdownMenuLabel>\n {builtInDocs.map((d) => {\n const active = (cfg.documents ?? []).some(\n (x: PromptDocument) => x.id === d.id,\n );\n return (\n <DropdownMenuItem\n key={d.id}\n onClick={() => toggleDoc(d)}\n className=\"items-start gap-2\"\n >\n <div className=\"min-w-0 flex-1\">\n <span className=\"flex items-center gap-2 truncate\">\n {d.name}\n {active && (\n <Badge\n variant=\"secondary\"\n className=\"ml-auto text-[9px]\"\n >\n on\n </Badge>\n )}\n </span>\n {d.description && (\n <p className=\"mt-0.5 truncate text-xs text-muted-foreground\">\n {d.description}\n </p>\n )}\n </div>\n </DropdownMenuItem>\n );\n })}\n <DropdownMenuSeparator />\n <p className=\"px-2 py-1.5 text-xs text-muted-foreground\">\n Toggle a doc to prepend it to the model&apos;s context.\n </p>\n </DropdownMenuContent>\n </DropdownMenu>\n )}\n\n <span className=\"mx-1 hidden h-5 w-px bg-border/70 sm:block\" />\n\n {/* New chat — direct action */}\n <Tooltip>\n <TooltipTrigger asChild>\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n className=\"rounded-lg text-muted-foreground hover:text-foreground\"\n aria-label=\"New chat\"\n onClick={() => chat.newConversation()}\n >\n <MessageSquarePlus className=\"size-4\" />\n </Button>\n </TooltipTrigger>\n <TooltipContent>New chat</TooltipContent>\n </Tooltip>\n\n {/* Conversation history */}\n {enableConversationHistory && (\n <DropdownMenu>\n <Tooltip>\n <TooltipTrigger asChild>\n <DropdownMenuTrigger asChild>\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n className=\"rounded-lg text-muted-foreground hover:text-foreground\"\n aria-label=\"Conversation history\"\n >\n <History className=\"size-4\" />\n </Button>\n </DropdownMenuTrigger>\n </TooltipTrigger>\n <TooltipContent>History</TooltipContent>\n </Tooltip>\n <DropdownMenuContent align=\"end\" className=\"w-72\">\n <DropdownMenuLabel>Conversation history</DropdownMenuLabel>\n <DropdownMenuSeparator />\n {conversations.length === 0 ? (\n <p className=\"px-2 py-6 text-center text-xs text-muted-foreground\">\n No conversations yet.\n <br />\n Send a message to start one.\n </p>\n ) : (\n <div className=\"max-h-72 overflow-y-auto\">\n {conversations.map((c) => {\n const active = c.id === chat.conversationId;\n return (\n <div\n key={c.id}\n className={cn(\n \"group/conv flex items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors\",\n active ? \"bg-accent\" : \"hover:bg-accent/60\",\n )}\n >\n <Button\n type=\"button\"\n variant=\"ghost\"\n onClick={() => chat.setConversationId(c.id)}\n className=\"h-auto min-w-0 flex-1 justify-start gap-2 p-0 text-left font-normal hover:bg-transparent\"\n >\n {active ? (\n <Check className=\"size-3.5 shrink-0 text-primary\" />\n ) : (\n <span className=\"size-3.5 shrink-0\" />\n )}\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate font-medium\">\n {c.title}\n </span>\n <span className=\"block truncate text-[11px] text-muted-foreground\">\n {c.messageCount} msg\n {c.updatedAt ? ` · ${relativeTime(c.updatedAt)}` : \"\"}\n </span>\n </span>\n </Button>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n aria-label=\"Delete conversation\"\n onClick={(e) => {\n e.stopPropagation();\n chat.deleteConversation(c.id);\n }}\n className=\"size-7 shrink-0 text-muted-foreground opacity-0 transition-opacity hover:bg-foreground/10 hover:text-destructive group-hover/conv:opacity-100\"\n >\n <Trash2 className=\"size-3.5\" />\n </Button>\n </div>\n );\n })}\n </div>\n )}\n </DropdownMenuContent>\n </DropdownMenu>\n )}\n\n <ThemeToggle className=\"rounded-lg text-muted-foreground hover:text-foreground\" />\n\n {/* Tool-calls badge. Reads from the engine via getActiveToolCallCount()\n (defaults to 0 today). The badge only renders when the count is\n non-zero so the header stays quiet for chat configs that don't\n use tool calls at all. */}\n {showToolCalls && chat.getActiveToolCallCount() > 0 && (\n <Tooltip>\n <TooltipTrigger asChild>\n <div\n className=\"inline-flex h-7 items-center gap-1 rounded-lg border border-border/60 bg-card/60 px-2 text-xs font-medium text-muted-foreground\"\n aria-label={`${chat.getActiveToolCallCount()} tool calls in progress`}\n >\n <Wrench className=\"size-3.5 animate-pulse\" />\n <span className=\"font-mono\">{chat.getActiveToolCallCount()}</span>\n </div>\n </TooltipTrigger>\n <TooltipContent>\n {chat.getActiveToolCallCount()} tool call\n {chat.getActiveToolCallCount() === 1 ? \"\" : \"s\"} in progress\n </TooltipContent>\n </Tooltip>\n )}\n\n {/* Overflow */}\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n className=\"rounded-lg text-muted-foreground hover:text-foreground\"\n aria-label=\"More\"\n >\n <MoreHorizontal className=\"size-4\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n <DropdownMenuItem onClick={() => openManager(false)}>\n <Settings2 className=\"size-3.5\" />\n Manage agents…\n </DropdownMenuItem>\n <DropdownMenuSeparator />\n <DropdownMenuItem\n onClick={() => chat.clear()}\n className=\"text-destructive focus:text-destructive\"\n >\n <Trash2 className=\"size-3.5\" />\n Clear this conversation\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n </div>\n\n <AgentManager\n open={managerOpen}\n onOpenChange={setManagerOpen}\n activeAgentId={activeAgent?.id ?? null}\n onApply={applyAgent}\n startInCreate={managerCreate}\n />\n </header>\n );\n}\n\nfunction relativeTime(ts: number): string {\n const diff = Date.now() - ts;\n const min = Math.round(diff / 60000);\n if (min < 1) return \"just now\";\n if (min < 60) return `${min}m ago`;\n const hr = Math.round(min / 60);\n if (hr < 24) return `${hr}h ago`;\n const day = Math.round(hr / 24);\n if (day < 7) return `${day}d ago`;\n try {\n return new Date(ts).toLocaleDateString(undefined, {\n month: \"short\",\n day: \"numeric\",\n });\n } catch {\n return \"\";\n }\n}\n","/**\n * useVoiceInput — small React hook around the Web Speech API\n * (`SpeechRecognition` / `webkitSpeechRecognition`) for voice-to-text\n * in the message composer.\n *\n * Why a separate module: `MessageInput` already imports a lot; isolating\n * the browser-only globals (window, navigator) behind a hook keeps the\n * composer's main render path clean. The hook returns plain booleans\n * and a small handler pair so the consumer doesn't need to know about\n * the underlying API.\n *\n * Browser support: `SpeechRecognition` ships in Chrome and Edge.\n * `webkitSpeechRecognition` is the prefixed variant Safari uses. Firefox\n * has none as of writing — `supported` will be `false` and the Mic\n * button should hide. The hook never throws on construction; it just\n * reports `supported: false` when the API is missing.\n *\n * SSR safety: every `window` / `navigator` access is inside a feature\n * check, so importing this module from a server component is safe.\n */\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\ntype RecognitionInstance = {\n lang: string;\n continuous: boolean;\n interimResults: boolean;\n onresult: ((event: { results: ArrayLike<{ 0: { transcript: string }; isFinal: boolean }>; resultIndex: number }) => void) | null;\n onerror: ((event: { error?: string; message?: string }) => void) | null;\n onend: (() => void) | null;\n start: () => void;\n stop: () => void;\n abort: () => void;\n};\n\ntype RecognitionCtor = new () => RecognitionInstance;\n\ndeclare global {\n interface Window {\n SpeechRecognition?: RecognitionCtor;\n webkitSpeechRecognition?: RecognitionCtor;\n }\n}\n\nfunction getCtor(): RecognitionCtor | null {\n if (typeof window === \"undefined\") return null;\n return window.SpeechRecognition ?? window.webkitSpeechRecognition ?? null;\n}\n\nexport interface UseVoiceInputResult {\n /** True if the host browser exposes a usable SpeechRecognition. */\n supported: boolean;\n /** True between `start()` and the next natural `end` (or `stop()`). */\n listening: boolean;\n /** The most recent error from permission denial or the recognition API. */\n error: string | null;\n /** Begin a recognition session. No-op when already listening or unsupported. */\n start: () => void;\n /** End the current session. No-op when not listening. */\n stop: () => void;\n /**\n * Most recent interim or final transcript. Subscribe via the parameter\n * callback for streaming results. Cleared when a new session starts.\n */\n transcript: string;\n}\n\nexport interface UseVoiceInputOptions {\n /** Language hint for the recognizer, e.g. \"es-ES\" or \"en-US\". */\n lang?: string;\n /** Whether the recognizer should keep listening after each pause. */\n continuous?: boolean;\n /** Receives every interim and final transcript as it arrives. */\n onResult?: (transcript: string, isFinal: boolean) => void;\n}\n\nexport function useVoiceInput(options: UseVoiceInputOptions = {}): UseVoiceInputResult {\n const ctorRef = useRef<RecognitionCtor | null>(null);\n const instanceRef = useRef<RecognitionInstance | null>(null);\n const [supported, setSupported] = useState<boolean>(false);\n const [listening, setListening] = useState<boolean>(false);\n const [error, setError] = useState<string | null>(null);\n const [transcript, setTranscript] = useState<string>(\"\");\n\n // Resolve the constructor once on mount (client-only).\n useEffect(() => {\n const ctor = getCtor();\n ctorRef.current = ctor;\n setSupported(ctor !== null);\n return () => {\n instanceRef.current?.abort();\n instanceRef.current = null;\n };\n }, []);\n\n const start = useCallback(() => {\n const ctor = ctorRef.current;\n if (!ctor) {\n setError(\"Speech recognition is not supported in this browser.\");\n return;\n }\n if (instanceRef.current) return; // already running\n setError(null);\n setTranscript(\"\");\n const inst = new ctor();\n inst.lang = options.lang ?? (typeof navigator !== \"undefined\" ? navigator.language : \"en-US\");\n inst.continuous = options.continuous ?? false;\n inst.interimResults = true;\n inst.onresult = (event) => {\n let buffer = \"\";\n for (let i = event.resultIndex; i < event.results.length; i++) {\n const res = event.results[i];\n if (res && res[0]) buffer += res[0].transcript;\n }\n if (buffer) {\n setTranscript(buffer);\n const isFinal =\n event.results[event.results.length - 1]?.isFinal ?? false;\n options.onResult?.(buffer, isFinal);\n }\n };\n inst.onerror = (event) => {\n const message = event.error ?? event.message ?? \"Voice recognition error\";\n setError(message);\n setListening(false);\n instanceRef.current = null;\n };\n inst.onend = () => {\n setListening(false);\n instanceRef.current = null;\n };\n try {\n inst.start();\n instanceRef.current = inst;\n setListening(true);\n } catch (err) {\n setError(err instanceof Error ? err.message : String(err));\n setListening(false);\n instanceRef.current = null;\n }\n }, [options.lang, options.continuous, options.onResult]);\n\n const stop = useCallback(() => {\n if (!instanceRef.current) return;\n try {\n instanceRef.current.stop();\n } catch {\n // Some browsers throw if stop() is called too soon. Swallow.\n }\n }, []);\n\n return { supported, listening, error, start, stop, transcript };\n}","/**\n * ProviderManager — a dialog to create, read, update, and delete LLM provider\n * profiles (connection details + model list + API key). Profiles persist to\n * localStorage via `lib/providers`. Picking a provider calls `onApply`, which\n * the composer/header maps onto the live chat config via `updateConfig`.\n */\nimport {\n ArrowLeft,\n Check,\n Copy,\n Pencil,\n Plus,\n RotateCcw,\n Trash2,\n} from \"lucide-react\";\nimport { useEffect, useState } from \"react\";\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n} from \"../ui/dialog.js\";\nimport { Button } from \"../ui/button.js\";\nimport { Input, Textarea } from \"../ui/input.js\";\nimport { Label } from \"../ui/label.js\";\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from \"../ui/select.js\";\nimport {\n deleteProvider as removeProvider,\n duplicateProvider,\n listProviders,\n modelsToText,\n parseModelsText,\n resetProviders,\n saveProvider,\n} from \"../../lib/providers.js\";\nimport { cn } from \"../../lib/utils.js\";\nimport type { ProviderKind, ProviderProfile } from \"../../types/chat.js\";\n\nconst KINDS: { value: ProviderKind; label: string }[] = [\n { value: \"anthropic\", label: \"Anthropic (native)\" },\n { value: \"openai\", label: \"OpenAI (native)\" },\n { value: \"openai-compatible\", label: \"OpenAI-compatible\" },\n];\n\nexport interface ProviderManagerProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n activeProviderId?: string | null;\n onApply: (profile: ProviderProfile) => void;\n startInCreate?: boolean;\n}\n\ntype Draft = {\n id?: string;\n name: string;\n icon: string;\n kind: ProviderKind;\n baseUrl: string;\n apiKey: string;\n models: string;\n};\n\nconst EMPTY_DRAFT: Draft = {\n name: \"\",\n icon: \"🔌\",\n kind: \"openai-compatible\",\n baseUrl: \"\",\n apiKey: \"\",\n models: \"\",\n};\n\nfunction toDraft(p: ProviderProfile): Draft {\n return {\n id: p.id,\n name: p.name,\n icon: p.icon ?? \"🔌\",\n kind: p.kind,\n baseUrl: p.baseUrl,\n apiKey: p.apiKey,\n models: modelsToText(p.models),\n };\n}\n\nexport function ProviderManager({\n open,\n onOpenChange,\n activeProviderId,\n onApply,\n startInCreate = false,\n}: ProviderManagerProps) {\n const [providers, setProviders] = useState<ProviderProfile[]>([]);\n const [view, setView] = useState<\"list\" | \"edit\">(\"list\");\n const [draft, setDraft] = useState<Draft>(EMPTY_DRAFT);\n\n const refresh = () => setProviders(listProviders());\n\n useEffect(() => {\n if (open) {\n refresh();\n setView(startInCreate ? \"edit\" : \"list\");\n setDraft(EMPTY_DRAFT);\n }\n }, [open, startInCreate]);\n\n const canSave = draft.name.trim().length > 0 && draft.baseUrl.trim().length > 0;\n\n const onSave = () => {\n if (!canSave) return;\n const saved = saveProvider({\n id: draft.id,\n name: draft.name,\n icon: draft.icon,\n kind: draft.kind,\n baseUrl: draft.baseUrl,\n apiKey: draft.apiKey,\n models: parseModelsText(draft.models, draft.kind),\n });\n refresh();\n onApply(saved);\n onOpenChange(false);\n };\n\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent className=\"max-w-lg gap-0 overflow-hidden p-0\">\n {view === \"list\" ? (\n <ListView\n providers={providers}\n activeProviderId={activeProviderId}\n onCreate={() => {\n setDraft(EMPTY_DRAFT);\n setView(\"edit\");\n }}\n onEdit={(p) => {\n setDraft(toDraft(p));\n setView(\"edit\");\n }}\n onApply={(p) => {\n onApply(p);\n onOpenChange(false);\n }}\n onDuplicate={(id) => {\n duplicateProvider(id);\n refresh();\n }}\n onDelete={(id) => {\n removeProvider(id);\n refresh();\n }}\n onReset={() => {\n resetProviders();\n refresh();\n }}\n />\n ) : (\n <EditView\n draft={draft}\n setDraft={setDraft}\n canSave={canSave}\n onBack={() => setView(\"list\")}\n onSave={onSave}\n />\n )}\n </DialogContent>\n </Dialog>\n );\n}\n\nfunction ListView({\n providers,\n activeProviderId,\n onCreate,\n onEdit,\n onApply,\n onDuplicate,\n onDelete,\n onReset,\n}: {\n providers: ProviderProfile[];\n activeProviderId?: string | null;\n onCreate: () => void;\n onEdit: (p: ProviderProfile) => void;\n onApply: (p: ProviderProfile) => void;\n onDuplicate: (id: string) => void;\n onDelete: (id: string) => void;\n onReset: () => void;\n}) {\n const active = providers.find((p) => p.id === activeProviderId);\n const others = providers.filter((p) => p.id !== active?.id);\n\n return (\n <>\n <DialogHeader className=\"border-b border-border/60 p-5 pb-3\">\n <DialogTitle>Providers &amp; models</DialogTitle>\n <DialogDescription className=\"text-xs\">\n Any OpenAI / Anthropic-compatible API. Keys stay in your browser.\n </DialogDescription>\n </DialogHeader>\n\n <div className=\"max-h-[58vh] overflow-y-auto p-2 scrollbar-thin\">\n {active && (\n <>\n <SectionLabel>Active</SectionLabel>\n <ProviderRow\n p={active}\n active\n onApply={onApply}\n onEdit={onEdit}\n onDuplicate={onDuplicate}\n onDelete={onDelete}\n />\n <div className=\"h-2\" />\n </>\n )}\n <SectionLabel>{active ? \"Available\" : \"Providers\"}</SectionLabel>\n {others.map((p) => (\n <ProviderRow\n key={p.id}\n p={p}\n onApply={onApply}\n onEdit={onEdit}\n onDuplicate={onDuplicate}\n onDelete={onDelete}\n />\n ))}\n </div>\n\n <DialogFooter className=\"flex-row items-center justify-between border-t border-border/60 p-4 sm:justify-between\">\n <Button variant=\"ghost\" size=\"sm\" onClick={onReset} className=\"gap-1.5 text-muted-foreground\">\n <RotateCcw className=\"size-3.5\" />\n Reset defaults\n </Button>\n <Button onClick={onCreate} className=\"gap-2\">\n <Plus className=\"size-4\" />\n New provider\n </Button>\n </DialogFooter>\n </>\n );\n}\n\nfunction EditView({\n draft,\n setDraft,\n canSave,\n onBack,\n onSave,\n}: {\n draft: Draft;\n setDraft: (d: Draft) => void;\n canSave: boolean;\n onBack: () => void;\n onSave: () => void;\n}) {\n const set = <K extends keyof Draft>(k: K, v: Draft[K]) => setDraft({ ...draft, [k]: v });\n\n return (\n <>\n <DialogHeader className=\"border-b border-border/60 p-5 pb-4\">\n <DialogTitle className=\"flex items-center gap-2\">\n <Button type=\"button\" variant=\"ghost\" size=\"icon-sm\" onClick={onBack} aria-label=\"Back to list\" className=\"text-muted-foreground hover:text-foreground\">\n <ArrowLeft className=\"size-4\" />\n </Button>\n {draft.id ? \"Edit provider\" : \"New provider\"}\n </DialogTitle>\n </DialogHeader>\n\n <div className=\"max-h-[55vh] space-y-4 overflow-y-auto p-5 scrollbar-thin\">\n <div className=\"flex gap-3\">\n <Field label=\"Icon\" className=\"w-20\">\n <Input value={draft.icon} onChange={(e) => set(\"icon\", e.target.value.slice(0, 2))} className=\"text-center text-lg\" maxLength={2} />\n </Field>\n <Field label=\"Name\" className=\"flex-1\">\n <Input value={draft.name} onChange={(e) => set(\"name\", e.target.value)} placeholder=\"e.g. Groq\" />\n </Field>\n </div>\n\n <Field label=\"Protocol\">\n <Select value={draft.kind} onValueChange={(v) => set(\"kind\", v as ProviderKind)}>\n <SelectTrigger>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {KINDS.map((k) => (\n <SelectItem key={k.value} value={k.value}>\n {k.label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </Field>\n\n <Field label=\"Base URL\">\n <Input value={draft.baseUrl} onChange={(e) => set(\"baseUrl\", e.target.value)} placeholder=\"https://api.example.com/v1\" className=\"font-mono text-xs\" />\n </Field>\n\n <Field label=\"API key\" hint=\"stored in your browser\">\n <Input type=\"password\" value={draft.apiKey} onChange={(e) => set(\"apiKey\", e.target.value)} placeholder=\"sk-…\" className=\"font-mono text-xs\" autoComplete=\"off\" />\n </Field>\n\n <Field label=\"Models\" hint=\"one per line · id | Label\">\n <Textarea\n value={draft.models}\n onChange={(e) => set(\"models\", e.target.value)}\n placeholder={\"gpt-4o | GPT-4o\\ngpt-4o-mini | GPT-4o mini\"}\n className=\"min-h-24 resize-y font-mono text-xs\"\n />\n </Field>\n </div>\n\n <DialogFooter className=\"gap-2 border-t border-border/60 p-4\">\n <Button variant=\"ghost\" onClick={onBack}>\n Cancel\n </Button>\n <Button onClick={onSave} disabled={!canSave} className=\"gap-2\">\n <Check className=\"size-4\" />\n Save &amp; use\n </Button>\n </DialogFooter>\n </>\n );\n}\n\nfunction SectionLabel({ children }: { children: React.ReactNode }) {\n return (\n <p className=\"px-2 pb-1 pt-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/70\">\n {children}\n </p>\n );\n}\n\nfunction hostLabel(baseUrl: string): string {\n return baseUrl.replace(/^https?:\\/\\//, \"\");\n}\n\nfunction ProviderRow({\n p,\n active,\n onApply,\n onEdit,\n onDuplicate,\n onDelete,\n}: {\n p: ProviderProfile;\n active?: boolean;\n onApply: (p: ProviderProfile) => void;\n onEdit: (p: ProviderProfile) => void;\n onDuplicate: (id: string) => void;\n onDelete: (id: string) => void;\n}) {\n return (\n <div\n className={cn(\n \"group/prov flex items-center gap-2.5 rounded-lg px-2 py-1.5 transition-colors\",\n active ? \"bg-primary/8 ring-1 ring-primary/20\" : \"hover:bg-accent/50\",\n )}\n >\n <span className=\"grid size-8 shrink-0 place-items-center rounded-md bg-muted text-base\">\n {p.icon ?? \"🔌\"}\n </span>\n <Button\n type=\"button\"\n variant=\"ghost\"\n onClick={() => onApply(p)}\n className=\"h-auto min-w-0 flex-1 flex-col items-stretch justify-start gap-0.5 p-0 text-left hover:bg-transparent\"\n >\n <span className=\"flex items-center gap-1.5\">\n <span className=\"truncate text-sm font-medium\">{p.name}</span>\n {active && <Check className=\"size-3.5 shrink-0 text-primary\" />}\n </span>\n <span className=\"flex items-center gap-1.5 truncate text-[11px] font-normal text-muted-foreground\">\n <span\n className={cn(\n \"size-1.5 shrink-0 rounded-full\",\n p.apiKey ? \"bg-success\" : \"bg-muted-foreground/40\",\n )}\n title={p.apiKey ? \"API key set\" : \"No API key\"}\n />\n <span className=\"truncate font-mono\">{hostLabel(p.baseUrl)}</span>\n <span className=\"shrink-0 text-muted-foreground/60\">\n · {p.models.length} model{p.models.length === 1 ? \"\" : \"s\"}\n </span>\n </span>\n </Button>\n <div className=\"flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity focus-within:opacity-100 group-hover/prov:opacity-100\">\n <Button variant=\"ghost\" size=\"icon-sm\" aria-label=\"Duplicate\" onClick={() => onDuplicate(p.id)} className=\"text-muted-foreground hover:text-foreground\">\n <Copy className=\"size-3.5\" />\n </Button>\n <Button variant=\"ghost\" size=\"icon-sm\" aria-label=\"Edit\" onClick={() => onEdit(p)} className=\"text-muted-foreground hover:text-foreground\">\n <Pencil className=\"size-3.5\" />\n </Button>\n <Button variant=\"ghost\" size=\"icon-sm\" aria-label=\"Delete\" onClick={() => onDelete(p.id)} className=\"text-muted-foreground hover:text-destructive\">\n <Trash2 className=\"size-3.5\" />\n </Button>\n </div>\n </div>\n );\n}\n\nfunction Field({\n label,\n hint,\n className,\n children,\n}: {\n label: string;\n hint?: string;\n className?: string;\n children: React.ReactNode;\n}) {\n return (\n <div className={cn(\"space-y-1.5\", className)}>\n <Label className=\"flex items-center gap-1.5 text-xs font-medium text-muted-foreground\">\n {label}\n {hint && <span className=\"text-muted-foreground/60\">· {hint}</span>}\n </Label>\n {children}\n </div>\n );\n}\n","/**\n * Attachment — sourced from `apps/v4/styles/radix-rhea/ui/attachment.tsx` in\n * the official `shadcn-ui/ui` repo (https://github.com/shadcn-ui/ui).\n *\n * Source paths in the original module were remapped:\n * - `@/lib/utils` → `../../lib/utils.js`\n * - `radix-ui` (Slot.Root) → `@radix-ui/react-slot`\n * - `@/styles/radix-rhea/ui/button` → `../ui/button.js`\n */\nimport * as React from \"react\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport { Slot } from \"@radix-ui/react-slot\";\n\nimport { cn } from \"../../lib/utils.js\";\nimport { Button } from \"../ui/button.js\";\n\nconst attachmentVariants = cva(\n \"group/attachment relative flex w-fit max-w-full min-w-0 shrink-0 flex-wrap rounded-2xl border bg-card text-card-foreground transition-colors focus-within:ring-1 focus-within:ring-ring/30 has-[>a,>button]:hover:bg-muted/50 data-[state=error]:border-destructive/30 data-[state=idle]:border-dashed\",\n {\n variants: {\n size: {\n default:\n \"gap-2 text-sm has-data-[slot=attachment-content]:px-2.5 has-data-[slot=attachment-content]:py-2 has-data-[slot=attachment-media]:p-2\",\n sm: \"gap-2.5 text-xs has-data-[slot=attachment-content]:px-2 has-data-[slot=attachment-content]:py-1.5 has-data-[slot=attachment-media]:p-1.5\",\n xs: \"gap-1.5 rounded-xl text-xs has-data-[slot=attachment-content]:px-1.5 has-data-[slot=attachment-content]:py-1 has-data-[slot=attachment-media]:p-1\",\n },\n orientation: {\n horizontal: \"min-w-40 items-center\",\n vertical: \"w-24 flex-col has-data-[slot=attachment-content]:w-30\",\n },\n },\n },\n);\n\nfunction Attachment({\n className,\n state = \"done\",\n size = \"default\",\n orientation = \"horizontal\",\n ...props\n}: React.ComponentProps<\"div\"> &\n VariantProps<typeof attachmentVariants> & {\n state?: \"idle\" | \"uploading\" | \"processing\" | \"error\" | \"done\";\n }) {\n const resolvedOrientation = orientation ?? \"horizontal\";\n\n return (\n <div\n data-slot=\"attachment\"\n data-state={state}\n data-size={size}\n data-orientation={resolvedOrientation}\n className={cn(attachmentVariants({ size, orientation }), className)}\n {...props}\n />\n );\n}\n\nconst attachmentMediaVariants = cva(\n \"relative flex aspect-square w-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted text-foreground group-data-[orientation=vertical]/attachment:w-full group-data-[size=sm]/attachment:w-8 group-data-[size=xs]/attachment:w-7 group-data-[size=xs]/attachment:rounded-md group-data-[state=error]/attachment:bg-destructive/10 group-data-[state=error]/attachment:text-destructive group-data-[orientation=vertical]/attachment:*:data-[slot=spinner]:size-6! [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 group-data-[orientation=vertical]/attachment:[&_svg:not([class*='size-'])]:size-6 group-data-[size=xs]/attachment:[&_svg:not([class*='size-'])]:size-3.5\",\n {\n variants: {\n variant: {\n icon: \"\",\n image:\n \"opacity-60 group-data-[state=done]/attachment:opacity-100 group-data-[state=idle]/attachment:opacity-100 *:[img]:aspect-square *:[img]:w-full *:[img]:object-cover\",\n },\n },\n defaultVariants: {\n variant: \"icon\",\n },\n },\n);\n\nfunction AttachmentMedia({\n className,\n variant = \"icon\",\n ...props\n}: React.ComponentProps<\"div\"> & VariantProps<typeof attachmentMediaVariants>) {\n return (\n <div\n data-slot=\"attachment-media\"\n data-variant={variant}\n className={cn(attachmentMediaVariants({ variant }), className)}\n {...props}\n />\n );\n}\n\nfunction AttachmentContent({\n className,\n ...props\n}: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"attachment-content\"\n className={cn(\n \"max-w-full min-w-0 flex-1 leading-tight group-data-[orientation=vertical]/attachment:px-1\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction AttachmentTitle({\n className,\n ...props\n}: React.ComponentProps<\"span\">) {\n return (\n <span\n data-slot=\"attachment-title\"\n className={cn(\n \"block max-w-full min-w-0 truncate font-medium group-data-[state=processing]/attachment:shimmer group-data-[state=uploading]/attachment:shimmer\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction AttachmentDescription({\n className,\n ...props\n}: React.ComponentProps<\"span\">) {\n return (\n <span\n data-slot=\"attachment-description\"\n className={cn(\n \"mt-0.5 block min-w-0 truncate text-xs text-muted-foreground group-data-[state=error]/attachment:text-destructive/80\",\n \"max-w-full\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction AttachmentActions({\n className,\n ...props\n}: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"attachment-actions\"\n className={cn(\n \"relative z-20 flex shrink-0 items-center group-data-[orientation=vertical]/attachment:absolute group-data-[orientation=vertical]/attachment:top-3 group-data-[orientation=vertical]/attachment:right-3 group-data-[orientation=vertical]/attachment:gap-1\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction AttachmentAction({\n className,\n variant,\n size = \"icon-sm\",\n ...props\n}: React.ComponentProps<typeof Button>) {\n return (\n <Button\n data-slot=\"attachment-action\"\n variant={variant ?? \"ghost\"}\n size={size}\n className={cn(className)}\n {...props}\n />\n );\n}\n\nfunction AttachmentTrigger({\n className,\n asChild = false,\n type,\n ...props\n}: React.ComponentProps<\"button\"> & {\n asChild?: boolean;\n}) {\n const Comp = asChild ? Slot : \"button\";\n\n return (\n <Comp\n data-slot=\"attachment-trigger\"\n type={asChild ? undefined : (type ?? \"button\")}\n className={cn(\"absolute inset-0 z-10 outline-none\", className)}\n {...props}\n />\n );\n}\n\nfunction AttachmentGroup({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"attachment-group\"\n className={cn(\n \"flex min-w-0 scroll-fade-x snap-x snap-mandatory scroll-px-1 scrollbar-none gap-3 overflow-x-auto overscroll-x-contain py-1 *:data-[slot=attachment]:flex-none *:data-[slot=attachment]:snap-start\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport {\n Attachment,\n AttachmentGroup,\n AttachmentMedia,\n AttachmentContent,\n AttachmentTitle,\n AttachmentDescription,\n AttachmentActions,\n AttachmentAction,\n AttachmentTrigger,\n};","/**\n * AttachmentPreview — a single attachment chip built on the official shadcn\n * `Attachment` block. Renders an image thumbnail (`AttachmentMedia\n * variant=\"image\"`) for image files and a type-specific icon otherwise.\n *\n * Used by both the composer (with a remove action) and the message list\n * (read-only). The `state` prop drives the official component's visuals —\n * `uploading`/`processing` trigger the shimmer on the title.\n */\nimport {\n File as FileIcon,\n FileCode,\n FileJson,\n FileText,\n FileType,\n X,\n} from \"lucide-react\";\nimport type { ComponentType } from \"react\";\nimport {\n Attachment,\n AttachmentAction,\n AttachmentActions,\n AttachmentContent,\n AttachmentDescription,\n AttachmentMedia,\n AttachmentTitle,\n} from \"./Attachment.js\";\nimport { formatBytes } from \"../../lib/utils.js\";\nimport type { AttachmentMeta } from \"../../types/chat.js\";\n\nfunction iconFor(mime: string): ComponentType<{ className?: string }> {\n if (mime === \"application/pdf\") return FileType;\n if (mime === \"application/json\") return FileJson;\n if (mime.startsWith(\"text/csv\") || mime === \"text/csv\") return FileCode;\n if (mime.startsWith(\"text/\")) return FileText;\n return FileIcon;\n}\n\nfunction shortType(mime: string): string {\n if (!mime || mime === \"application/octet-stream\") return \"file\";\n if (mime.startsWith(\"image/\")) return mime.slice(6).toUpperCase();\n if (mime === \"application/pdf\") return \"PDF\";\n if (mime === \"application/json\") return \"JSON\";\n if (mime.startsWith(\"text/\")) return mime.slice(5).toUpperCase();\n return mime;\n}\n\nexport interface AttachmentPreviewProps {\n att: AttachmentMeta;\n state?: \"idle\" | \"uploading\" | \"processing\" | \"error\" | \"done\";\n onRemove?: () => void;\n}\n\nexport function AttachmentPreview({\n att,\n state = \"done\",\n onRemove,\n}: AttachmentPreviewProps) {\n const mime = att.mimeType ?? att.mime ?? \"\";\n const isImage = mime.startsWith(\"image/\") && Boolean(att.dataUrl);\n const Icon = iconFor(mime);\n\n return (\n <Attachment\n size=\"default\"\n state={state}\n className=\"w-56 max-w-full bg-background/60\"\n >\n {isImage ? (\n <AttachmentMedia\n variant=\"image\"\n className=\"size-11 rounded-lg ring-1 ring-border/60\"\n >\n {/* eslint-disable-next-line @next/next/no-img-element */}\n <img src={att.dataUrl} alt={att.name} loading=\"lazy\" />\n </AttachmentMedia>\n ) : (\n <AttachmentMedia className=\"size-11 rounded-lg text-primary\">\n <Icon className=\"size-5\" />\n </AttachmentMedia>\n )}\n <AttachmentContent>\n <AttachmentTitle>{att.name}</AttachmentTitle>\n <AttachmentDescription>\n {formatBytes(att.size)} · {shortType(mime)}\n </AttachmentDescription>\n </AttachmentContent>\n {onRemove && (\n <AttachmentActions>\n <AttachmentAction aria-label=\"Remove attachment\" onClick={onRemove}>\n <X className=\"size-3.5\" />\n </AttachmentAction>\n </AttachmentActions>\n )}\n </Attachment>\n );\n}\n","/**\n * MessageInput — thin local adapter built on top of the official shadcn\n * `Attachment` component (from `radix-rhea`).\n *\n * The official `shadcn-ui/ui` repo does not ship a `message-input` block\n * itself; instead, the radix docs (message.mdx, attachment.mdx) show\n * consumers composing `Input` + `InputGroup` + `Button` + `Attachment`.\n * This component is the same composition, themed for ai-schadcn-chat:\n *\n * <textarea> (autosize)\n * + paperclip trigger → file input → Attachment chips\n * + send/stop button (calls chat.send / chat.abort)\n *\n * The component is intentionally framework-agnostic at the seams: it\n * accepts `onSend(content, attachments)` for headless use, but also reads\n * from the package's `useChat()` hook when no callback is provided so the\n * demo / one-shot wiring stays trivial.\n */\nimport {\n Check,\n ChevronDown,\n FileText,\n Loader2,\n Mic,\n MicOff,\n Paperclip,\n Send,\n Settings2,\n Square,\n X,\n} from \"lucide-react\";\nimport {\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type ChangeEvent,\n type DragEvent as ReactDragEvent,\n type KeyboardEvent,\n type ReactNode,\n} from \"react\";\nimport { useChat } from \"../../hooks/useChat.js\";\nimport { useVoiceInput } from \"../../lib/voice.js\";\nimport {\n getActiveProviderId,\n listProviders,\n profileToConfig,\n setActiveProviderId,\n} from \"../../lib/providers.js\";\nimport { ProviderManager } from \"./ProviderManager.js\";\nimport { Button } from \"../ui/button.js\";\nimport { Input, Textarea } from \"../ui/input.js\";\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"../ui/tooltip.js\";\nimport {\n Popover,\n PopoverContent,\n PopoverTrigger,\n} from \"../ui/popover.js\";\nimport {\n Attachment,\n AttachmentContent,\n AttachmentDescription,\n AttachmentMedia,\n AttachmentTitle,\n} from \"./Attachment.js\";\nimport { AttachmentPreview } from \"./AttachmentPreview.js\";\nimport { filesToAttachments } from \"../../lib/attachments.js\";\nimport type {\n AttachmentMeta,\n ModelDescriptor,\n ProviderProfile,\n} from \"../../types/chat.js\";\nimport { cn } from \"../../lib/utils.js\";\n\nexport interface MessageInputProps {\n /** Optional headless submit handler. When omitted, the input calls\n * `useChat().send(text, attachments)`. */\n onSend?: (content: string, attachments: AttachmentMeta[]) => void | Promise<void>;\n /** Streaming state — toggles the trailing button between \"send\" and \"stop\". */\n streaming?: boolean;\n /** Disable the input entirely (e.g. while uploading). */\n disabled?: boolean;\n /** Override the trailing button render. */\n renderSendButton?: (props: {\n disabled: boolean;\n onClick: () => void;\n }) => ReactNode;\n /** Extra className on the form. */\n className?: string;\n /** Extra className on the inner content wrapper (the composer card and hint\n * text), merged over the default `max-w-3xl` via tailwind-merge. Use this\n * to let the composer use more horizontal space in wide layouts. */\n contentClassName?: string;\n}\n\nexport function MessageInput(props: MessageInputProps) {\n const { onSend, streaming, disabled, renderSendButton, className, contentClassName } = props;\n\n const chat = useChat();\n const cfg = chat.config;\n const ui = cfg.ui ?? {};\n\n const [text, setText] = useState(\"\");\n const [attachments, setAttachments] = useState<AttachmentMeta[]>([]);\n const [uploadingCount, setUploadingCount] = useState(0);\n const [fileError, setFileError] = useState<string | null>(null);\n const fileErrorTimerRef = useRef<number | null>(null);\n\n const flashFileError = (msg: string) => {\n setFileError(msg);\n if (fileErrorTimerRef.current !== null) {\n window.clearTimeout(fileErrorTimerRef.current);\n }\n fileErrorTimerRef.current = window.setTimeout(() => setFileError(null), 4000);\n };\n useEffect(\n () => () => {\n if (fileErrorTimerRef.current !== null) {\n window.clearTimeout(fileErrorTimerRef.current);\n }\n },\n [],\n );\n const [dragOver, setDragOver] = useState(false);\n const fileInputRef = useRef<HTMLInputElement>(null);\n const formRef = useRef<HTMLFormElement>(null);\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const lastHeightRef = useRef(0);\n\n // Autosize: grow with content up to a max (then scroll), and collapse back to\n // the single-row height whenever the text is cleared (e.g. after sending).\n // Runs on every `text` change so programmatic resets are handled too. To let\n // the CSS height transition animate, we measure against `auto`, then restore\n // the previous height and force a reflow so the browser tweens prev → next\n // instead of committing the measured `auto` height as the start value.\n const MAX_TEXTAREA_HEIGHT = 200;\n useLayoutEffect(() => {\n const el = textareaRef.current;\n if (!el) return;\n const prev = lastHeightRef.current;\n el.style.height = \"auto\";\n const next = Math.min(el.scrollHeight, MAX_TEXTAREA_HEIGHT);\n if (prev && prev !== next) {\n el.style.height = `${prev}px`;\n void el.offsetHeight; // commit the base height so the transition has a start\n }\n el.style.height = `${next}px`;\n lastHeightRef.current = next;\n }, [text]);\n\n const isStreaming = streaming ?? chat.isStreaming;\n const canSend =\n !isStreaming &&\n !disabled &&\n (text.trim().length > 0 || attachments.length > 0);\n const enableFileUpload = ui.enableFileUpload ?? true;\n const enableVoiceInput = ui.enableVoiceInput ?? false;\n\n // Voice input: append interim transcripts to the textarea as the user\n // speaks. When the user clicks the Mic button a second time we stop and\n // the final transcript is committed to the text state. Errors (no mic\n // permission, browser unsupported) are surfaced through `voice.error`\n // and logged; the textarea stays usable.\n const voice = useVoiceInput({\n onResult: (transcript) => {\n // Append the latest transcript to whatever the user has already\n // typed. This keeps repeated sessions additive (the user can edit\n // freely between presses) without losing what the recognizer just\n // produced.\n setText((prev) => {\n const sep = prev.length > 0 && !prev.endsWith(\" \") ? \" \" : \"\";\n return prev + sep + transcript;\n });\n },\n });\n\n const [providerMgrOpen, setProviderMgrOpen] = useState(false);\n const [providerMgrCreate, setProviderMgrCreate] = useState(false);\n const [activeProviderId, setActiveProvider] = useState<string | null>(() =>\n getActiveProviderId(),\n );\n\n const applyProvider = (profile: ProviderProfile, model?: ModelDescriptor) => {\n // Don't clobber a working key with an empty one: if the profile has no key\n // but points at the same endpoint that's already configured (e.g. the key\n // came from env), reuse the live credentials.\n const current = chat.config.provider;\n const effectiveKey =\n profile.apiKey ||\n (current.baseUrl === profile.baseUrl\n ? (current.credentials?.apiKey ?? \"\")\n : \"\");\n chat.updateConfig(\n profileToConfig({ ...profile, apiKey: effectiveKey }, model),\n );\n setActiveProviderId(profile.id);\n setActiveProvider(profile.id);\n };\n\n const submit = async () => {\n if (!canSend) return;\n const t = text.trim();\n setText(\"\");\n const att = attachments;\n setAttachments([]);\n if (onSend) {\n await onSend(t, att);\n } else {\n await chat.send(t, att);\n }\n };\n\n const onKeyDown = (e: KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.key === \"Enter\" && !e.shiftKey && !e.nativeEvent.isComposing) {\n e.preventDefault();\n void submit();\n }\n };\n\n const onFiles = useCallback(\n async (files: FileList | File[]) => {\n const list = Array.from(files);\n const maxMb = ui.maxFileSizeMb ?? 10;\n const acceptedTypes = ui.acceptedFileTypes ?? [];\n const oversized = list.filter((f) => f.size > maxMb * 1024 * 1024);\n const rejected = oversized.length > 0;\n const filtered = oversized.length > 0\n ? list.filter((f) => f.size <= maxMb * 1024 * 1024)\n : list;\n const filteredByType =\n acceptedTypes.length > 0\n ? filtered.filter((f) =>\n acceptedTypes.some((t) => f.type === t || f.type.startsWith(`${t}/`)),\n )\n : filtered;\n const mimeRejected = filtered.length - filteredByType.length;\n if (rejected || mimeRejected > 0) {\n const reasons: string[] = [];\n if (rejected) {\n reasons.push(\n `${oversized.length} file${oversized.length === 1 ? \"\" : \"s\"} over ${maxMb} MB`,\n );\n }\n if (mimeRejected > 0) {\n reasons.push(\n `${mimeRejected} file${mimeRejected === 1 ? \"\" : \"s\"} with unsupported type`,\n );\n }\n const msg = `Rejected ${reasons.join(\" and \")}.`;\n // eslint-disable-next-line no-console\n console.warn(`[MessageInput] ${msg}`, { maxMb, acceptedTypes });\n flashFileError(msg);\n if (filteredByType.length === 0) return;\n }\n setUploadingCount((n) => n + filteredByType.length);\n try {\n const atts = await filesToAttachments(filteredByType, cfg);\n setAttachments((prev) => [...prev, ...atts]);\n } catch (err) {\n chat.config.onError?.(\n {\n code: \"bad_request\",\n message:\n (err instanceof Error ? err.message : String(err)) ??\n \"File upload failed\",\n retryable: false,\n },\n { conversationId: chat.conversationId },\n );\n } finally {\n setUploadingCount((n) => Math.max(0, n - filteredByType.length));\n }\n },\n [\n cfg,\n chat.config,\n chat.conversationId,\n ui.maxFileSizeMb,\n ui.acceptedFileTypes,\n ],\n );\n\n const onFileInput = (e: ChangeEvent<HTMLInputElement>) => {\n if (e.target.files) void onFiles(e.target.files);\n e.target.value = \"\";\n };\n\n const onDrop = (e: ReactDragEvent<HTMLFormElement>) => {\n e.preventDefault();\n setDragOver(false);\n if (e.dataTransfer.files) void onFiles(e.dataTransfer.files);\n };\n\n const onDragOver = (e: ReactDragEvent<HTMLFormElement>) => {\n if (!enableFileUpload) return;\n e.preventDefault();\n setDragOver(true);\n };\n\n const removeAttachment = (att: AttachmentMeta) => {\n setAttachments((prev) => prev.filter((a) => a.id !== att.id));\n };\n\n const openProviderMgr = (create: boolean) => {\n setProviderMgrCreate(create);\n setProviderMgrOpen(true);\n };\n\n return (\n <form\n ref={formRef}\n onSubmit={(e) => {\n e.preventDefault();\n void submit();\n }}\n className={cn(\n \"relative z-10 px-3 pb-3 pt-2 sm:px-4 sm:pb-4\",\n className,\n )}\n onDragOver={onDragOver}\n onDragLeave={() => setDragOver(false)}\n onDrop={onDrop}\n >\n <div\n className={cn(\n \"mx-auto w-full max-w-3xl rounded-2xl border bg-card/80 p-2 backdrop-blur-xl transition-[box-shadow,border-color] duration-200\",\n \"border-border/70 shadow-[0_2px_8px_-4px_oklch(var(--foreground)/0.1)]\",\n \"focus-within:border-primary/50 focus-within:shadow-[0_0_0_1px_oklch(var(--primary)/0.35),0_10px_30px_-12px_oklch(var(--glow)/0.5)]\",\n dragOver && \"border-primary/60 ring-2 ring-primary/30\",\n contentClassName,\n )}\n >\n {(attachments.length > 0 || uploadingCount > 0) && (\n <div className=\"flex max-h-44 flex-wrap gap-2 overflow-y-auto px-1 pb-2 pt-1 scrollbar-thin\">\n {attachments.map((att) => (\n <AttachmentPreview\n key={att.id}\n att={att}\n onRemove={() => removeAttachment(att)}\n />\n ))}\n {Array.from({ length: uploadingCount }).map((_, i) => (\n <Attachment key={`uploading-${i}`} size=\"sm\" state=\"uploading\">\n <AttachmentMedia>\n <Loader2 className=\"size-4 animate-spin\" />\n </AttachmentMedia>\n <AttachmentContent>\n <AttachmentTitle>Uploading…</AttachmentTitle>\n <AttachmentDescription>reading file</AttachmentDescription>\n </AttachmentContent>\n </Attachment>\n ))}\n </div>\n )}\n\n <div className=\"flex items-end gap-1.5\">\n {enableFileUpload && (\n <>\n <input\n ref={fileInputRef}\n type=\"file\"\n hidden\n multiple\n onChange={onFileInput}\n accept={(ui.acceptedFileTypes ?? []).join(\",\")}\n />\n <Tooltip>\n <TooltipTrigger asChild>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon\"\n className=\"size-9 shrink-0 rounded-xl text-muted-foreground hover:text-foreground\"\n onClick={() => fileInputRef.current?.click()}\n aria-label=\"Attach files\"\n disabled={disabled}\n >\n <Paperclip className=\"size-[18px]\" />\n </Button>\n </TooltipTrigger>\n <TooltipContent>\n Attach files (images, PDFs, text)\n </TooltipContent>\n </Tooltip>\n </>\n )}\n\n {enableVoiceInput && voice.supported && (\n <Tooltip>\n <TooltipTrigger asChild>\n <Button\n type=\"button\"\n variant={voice.listening ? \"destructive\" : \"ghost\"}\n size=\"icon\"\n className={cn(\n \"size-9 shrink-0 rounded-xl text-muted-foreground hover:text-foreground\",\n voice.listening && \"ring-2 ring-primary/60 animate-pulse\",\n )}\n onClick={() => {\n if (voice.listening) voice.stop();\n else voice.start();\n }}\n aria-label={voice.listening ? \"Stop dictation\" : \"Start dictation\"}\n disabled={disabled}\n >\n {voice.listening ? (\n <MicOff className=\"size-[18px]\" />\n ) : (\n <Mic className=\"size-[18px]\" />\n )}\n </Button>\n </TooltipTrigger>\n <TooltipContent>\n {voice.listening ? \"Stop dictation\" : \"Start dictation\"}\n </TooltipContent>\n </Tooltip>\n )}\n\n <Textarea\n ref={textareaRef}\n value={text}\n onChange={(e) => setText(e.target.value)}\n onKeyDown={onKeyDown}\n placeholder={ui.placeholder ?? \"Ask anything…\"}\n rows={1}\n disabled={disabled}\n className=\"max-h-[200px] min-h-[40px] flex-1 resize-none overflow-y-auto border-0 bg-transparent px-1 py-2 text-[0.9375rem] shadow-none scrollbar-thin transition-[height] duration-150 ease-out focus-visible:ring-0 focus-visible:ring-offset-0 motion-reduce:transition-none\"\n />\n\n <ModelSwitcher\n currentModelId={cfg.model.id}\n activeProviderId={activeProviderId}\n onPick={applyProvider}\n onManage={() => openProviderMgr(false)}\n />\n\n {isStreaming ? (\n <Button\n type=\"button\"\n variant=\"destructive\"\n size=\"icon\"\n className=\"size-9 shrink-0 rounded-xl\"\n onClick={() => chat.abort()}\n aria-label=\"Stop generating\"\n >\n <Square className=\"size-3.5 fill-current\" />\n </Button>\n ) : renderSendButton ? (\n renderSendButton({\n disabled: !canSend,\n onClick: () => void submit(),\n })\n ) : (\n <Button\n type=\"submit\"\n size=\"icon\"\n disabled={!canSend}\n aria-label=\"Send message\"\n className={cn(\n \"size-9 shrink-0 rounded-xl border-0 text-primary-foreground transition-all\",\n canSend\n ? \"grad-primary glow-primary hover:brightness-110\"\n : \"bg-muted text-muted-foreground\",\n )}\n >\n <Send className=\"size-4\" />\n </Button>\n )}\n </div>\n </div>\n\n <p className={cn(\"mx-auto mt-2 max-w-3xl px-1 text-center text-[11px] text-muted-foreground/70\", contentClassName)}>\n Press{\" \"}\n <kbd className=\"rounded border border-border/70 bg-muted/60 px-1 font-sans text-[10px]\">\n Enter\n </kbd>{\" \"}\n to send ·{\" \"}\n <kbd className=\"rounded border border-border/70 bg-muted/60 px-1 font-sans text-[10px]\">\n Shift+Enter\n </kbd>{\" \"}\n for a new line\n </p>\n\n {fileError && (\n <p\n role=\"status\"\n className=\"mx-auto mt-1 max-w-3xl px-1 text-center text-[11px] text-destructive\"\n >\n {fileError}\n </p>\n )}\n\n {dragOver && (\n <div className=\"pointer-events-none absolute inset-2 flex items-center justify-center gap-2 rounded-2xl border-2 border-dashed border-primary/50 bg-primary/5 text-sm font-medium text-primary backdrop-blur-sm\">\n <FileText className=\"size-4\" />\n Drop files to attach\n </div>\n )}\n\n <ProviderManager\n open={providerMgrOpen}\n onOpenChange={setProviderMgrOpen}\n activeProviderId={activeProviderId}\n onApply={(p) => applyProvider(p)}\n startInCreate={providerMgrCreate}\n />\n </form>\n );\n}\n\nfunction ModelSwitcher({\n currentModelId,\n activeProviderId,\n onPick,\n onManage,\n}: {\n currentModelId: string;\n activeProviderId: string | null;\n onPick: (profile: ProviderProfile, model: ModelDescriptor) => void;\n onManage: () => void;\n}) {\n const [open, setOpen] = useState(false);\n const [filter, setFilter] = useState(\"\");\n const providers = useMemo(() => (open ? listProviders() : []), [open]);\n\n const f = filter.toLowerCase();\n const groups = providers\n .map((p) => ({\n provider: p,\n models: p.models.filter(\n (m) =>\n !f ||\n m.id.toLowerCase().includes(f) ||\n (m.label ?? \"\").toLowerCase().includes(f) ||\n p.name.toLowerCase().includes(f),\n ),\n }))\n .filter((g) => g.models.length > 0);\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n className=\"hidden h-9 shrink-0 gap-1 rounded-xl border border-border/60 px-2.5 text-xs font-medium text-muted-foreground hover:text-foreground sm:inline-flex\"\n aria-label=\"Select model\"\n >\n <span className=\"max-w-[120px] truncate font-mono text-[11px]\">\n {currentModelId || \"Select model\"}\n </span>\n <ChevronDown className=\"size-3 opacity-60\" />\n </Button>\n </PopoverTrigger>\n <PopoverContent align=\"end\" className=\"w-80 p-0\">\n <div className=\"border-b p-2\">\n <Input\n type=\"text\"\n placeholder=\"Search providers & models…\"\n value={filter}\n onChange={(e) => setFilter(e.target.value)}\n className=\"h-8 text-xs\"\n />\n </div>\n <div className=\"max-h-72 overflow-y-auto p-1\">\n {groups.length === 0 ? (\n <div className=\"p-4 text-center text-xs text-muted-foreground\">\n No models found\n </div>\n ) : (\n groups.map(({ provider, models }) => (\n <div key={provider.id} className=\"mb-1\">\n <p className=\"flex items-center gap-1.5 px-2 py-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground\">\n <span className=\"text-sm leading-none\">{provider.icon}</span>\n {provider.name}\n {!provider.apiKey && (\n <span className=\"rounded bg-muted px-1 text-[8px] normal-case text-muted-foreground/70\">\n no key\n </span>\n )}\n </p>\n {models.map((m) => {\n const active =\n m.id === currentModelId && provider.id === activeProviderId;\n return (\n <Button\n key={`${provider.id}:${m.id}`}\n type=\"button\"\n variant=\"ghost\"\n onClick={() => {\n onPick(provider, m);\n setOpen(false);\n }}\n className={cn(\n \"h-auto w-full justify-between gap-2 rounded-sm px-2 py-1.5 text-left text-xs font-normal\",\n active && \"bg-accent/50\",\n )}\n >\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate font-medium\">\n {m.label ?? m.id}\n </span>\n <span className=\"block truncate font-mono text-[10px] text-muted-foreground\">\n {m.id}\n </span>\n </span>\n {active && <Check className=\"size-3.5 shrink-0 text-primary\" />}\n </Button>\n );\n })}\n </div>\n ))\n )}\n </div>\n <div className=\"border-t p-1\">\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => {\n setOpen(false);\n onManage();\n }}\n className=\"h-8 w-full justify-start gap-2 rounded-sm px-2 text-xs font-normal text-muted-foreground hover:text-foreground\"\n >\n <Settings2 className=\"size-3.5\" />\n Manage providers &amp; models…\n </Button>\n </div>\n </PopoverContent>\n </Popover>\n );\n}","/**\n * Chatbubble — sourced from `apps/v4/styles/radix-rhea/ui/bubble.tsx` in\n * the official `shadcn-ui/ui` repo (https://github.com/shadcn-ui/ui).\n *\n * File renamed `bubble.tsx` → `Chatbubble.tsx` so the import paths in\n * this package line up with the kebab-case file naming convention used\n * throughout (`Message.tsx`, `MessageMarker.tsx`, etc.).\n *\n * Source paths in the original module were remapped:\n * - `@/lib/utils` → `../../lib/utils.js`\n * - `radix-ui` (Slot) → `@radix-ui/react-slot`\n */\nimport * as React from \"react\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport { Slot } from \"@radix-ui/react-slot\";\n\nimport { cn } from \"../../lib/utils.js\";\n\nfunction BubbleGroup({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"bubble-group\"\n className={cn(\"flex min-w-0 flex-col gap-2\", className)}\n {...props}\n />\n );\n}\n\nconst bubbleVariants = cva(\n \"group/bubble relative flex w-fit max-w-[80%] min-w-0 flex-col gap-1 group-data-[align=end]/message:self-end data-[align=end]:self-end data-[variant=ghost]:max-w-full\",\n {\n variants: {\n variant: {\n default:\n \"*:data-[slot=bubble-content]:bg-primary *:data-[slot=bubble-content]:text-primary-foreground [&>[data-slot=bubble-content]:is(button,a):hover]:bg-primary/80\",\n secondary:\n \"*:data-[slot=bubble-content]:bg-secondary *:data-[slot=bubble-content]:text-secondary-foreground [&>[data-slot=bubble-content]:is(button,a):hover]:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)]\",\n muted:\n \"*:data-[slot=bubble-content]:bg-muted [&>[data-slot=bubble-content]:is(button,a):hover]:bg-[color-mix(in_oklch,var(--muted),var(--foreground)_5%)]\",\n tinted:\n \"*:data-[slot=bubble-content]:bg-[oklch(from_var(--primary)_0.93_calc(c*0.4)_h)] *:data-[slot=bubble-content]:text-foreground dark:*:data-[slot=bubble-content]:bg-[oklch(from_var(--primary)_0.3_calc(c*0.4)_h)] [&>[data-slot=bubble-content]:is(button,a):hover]:bg-[oklch(from_var(--primary)_0.88_calc(c*0.5)_h)] dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-[oklch(from_var(--primary)_0.35_calc(c*0.5)_h)]\",\n outline:\n \"*:data-[slot=bubble-content]:border-border *:data-[slot=bubble-content]:bg-background [&>[data-slot=bubble-content]:is(button,a):hover]:bg-muted [&>[data-slot=bubble-content]:is(button,a):hover]:text-foreground dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-input/30\",\n ghost:\n \"border-none *:data-[slot=bubble-content]:rounded-none *:data-[slot=bubble-content]:bg-transparent *:data-[slot=bubble-content]:p-0 [&>[data-slot=bubble-content]:is(button,a):hover]:bg-muted [&>[data-slot=bubble-content]:is(button,a):hover]:text-foreground dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-muted/50\",\n destructive:\n \"*:data-[slot=bubble-content]:bg-destructive/10 *:data-[slot=bubble-content]:text-destructive dark:*:data-[slot=bubble-content]:bg-destructive/20 [&>[data-slot=bubble-content]:is(button,a):hover]:bg-destructive/20 dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-destructive/30\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n },\n },\n);\n\nfunction Bubble({\n variant = \"default\",\n align = \"start\",\n className,\n ...props\n}: React.ComponentProps<\"div\"> &\n VariantProps<typeof bubbleVariants> & {\n align?: \"start\" | \"end\";\n }) {\n return (\n <div\n data-slot=\"bubble\"\n data-variant={variant}\n data-align={align}\n className={cn(bubbleVariants({ variant }), className)}\n {...props}\n />\n );\n}\n\nfunction BubbleContent({\n asChild = false,\n className,\n ...props\n}: React.ComponentProps<\"div\"> & {\n asChild?: boolean;\n}) {\n const Comp = asChild ? Slot : \"div\";\n\n return (\n <Comp\n data-slot=\"bubble-content\"\n className={cn(\n \"w-fit max-w-full min-w-0 overflow-hidden rounded-3xl border border-transparent px-3 py-2.5 text-sm leading-relaxed wrap-break-word group-data-[align=end]/bubble:self-end [button]:text-left [button,a]:transition-colors [button,a]:outline-none [button,a]:focus-visible:border-ring [button,a]:focus-visible:ring-3 [button,a]:focus-visible:ring-ring/30\",\n className,\n )}\n {...props}\n />\n );\n}\n\nconst bubbleReactionsVariants = cva(\n \"absolute z-10 flex w-fit shrink-0 items-center justify-center gap-1 rounded-full bg-muted px-1.5 py-0.5 text-sm ring-3 ring-card has-[button]:p-0\",\n {\n variants: {\n side: {\n top: \"top-0 -translate-y-3/4\",\n bottom: \"bottom-0 translate-y-3/4\",\n },\n align: {\n start: \"left-3\",\n end: \"right-3\",\n },\n },\n defaultVariants: {\n side: \"bottom\",\n align: \"end\",\n },\n },\n);\n\nfunction BubbleReactions({\n side = \"bottom\",\n align = \"end\",\n className,\n ...props\n}: React.ComponentProps<\"div\"> & {\n align?: \"start\" | \"end\";\n side?: \"top\" | \"bottom\";\n}) {\n return (\n <div\n data-slot=\"bubble-reactions\"\n data-align={align}\n data-side={side}\n className={cn(bubbleReactionsVariants({ side, align }), className)}\n {...props}\n />\n );\n}\n\nexport {\n BubbleGroup,\n Bubble,\n BubbleContent,\n BubbleReactions,\n type VariantProps as BubbleVariantProps,\n};","/**\n * Message — sourced from `apps/v4/styles/radix-rhea/ui/message.tsx` in\n * the official `shadcn-ui/ui` repo (https://github.com/shadcn-ui/ui).\n *\n * Source paths in the original module were remapped:\n * - `@/lib/utils` → `../../lib/utils.js`\n *\n * The component is a presentational frame that the consumer composes with\n * `Bubble` (text), `Attachment` (files), `Marker` (tool calls, errors), and\n * `MessageAvatar` (icon / image).\n */\nimport * as React from \"react\";\n\nimport { cn } from \"../../lib/utils.js\";\n\nfunction MessageGroup({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"message-group\"\n className={cn(\"flex min-w-0 flex-col gap-2\", className)}\n {...props}\n />\n );\n}\n\nfunction Message({\n className,\n align = \"start\",\n ...props\n}: React.ComponentProps<\"div\"> & { align?: \"start\" | \"end\" }) {\n return (\n <div\n data-slot=\"message\"\n data-align={align}\n className={cn(\n \"group/message relative flex w-full min-w-0 gap-2 text-sm data-[align=end]:flex-row-reverse\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction MessageAvatar({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"message-avatar\"\n className={cn(\n \"flex w-fit min-w-8 shrink-0 items-center justify-center self-end overflow-hidden rounded-full bg-muted group-has-data-[slot=message-footer]/message:-translate-y-8\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction MessageContent({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"message-content\"\n className={cn(\n \"flex w-full min-w-0 flex-col gap-2.5 wrap-break-word group-data-[align=end]/message:*:data-slot:self-end\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction MessageHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"message-header\"\n className={cn(\n \"flex max-w-full min-w-0 items-center px-3 text-xs font-medium text-muted-foreground group-has-data-[variant=ghost]/message:px-0\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction MessageFooter({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"message-footer\"\n className={cn(\n \"flex max-w-full min-w-0 items-center px-3 text-xs font-medium text-muted-foreground group-has-data-[variant=ghost]/message:px-0 group-data-[align=end]/message:justify-end\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport {\n MessageGroup,\n Message,\n MessageAvatar,\n MessageContent,\n MessageFooter,\n MessageHeader,\n};","/**\n * Local MessageScroller primitives — API-compatible with the radix-rhea\n * wrapper that consumes `@shadcn/react/message-scroller`.\n *\n * The upstream `@shadcn/react` package is a workspace-only package in the\n * `shadcn-ui/ui` monorepo and is not published to npm. To keep this library\n * installable without forcing consumers to run the unpublished dep, we\n * inline a minimal subset of the primitives here:\n *\n * - `Provider` — owns the scroll state for the subtree\n * - `Root` — outer flex container\n * - `Viewport` — scrollable area (sticky-bottom auto-scroll)\n * - `Content` — flex column of items\n * - `Item` — registers each row + scroll-anchor slot\n * - `Button` — jump-to-start / jump-to-end button (visibility via `active`)\n * - hooks: `useMessageScroller`, `useMessageScrollerScrollable`,\n * `useMessageScrollerVisibility`\n *\n * This implementation intentionally covers only the behaviours the radix-rhea\n * styled components rely on (auto-scroll, jump-to-end, scroll-anchor on last\n * item, viewport visibility). Anything more advanced is left to consumers.\n */\n\"use client\";\n\nimport * as React from \"react\";\n\n/* -------------------------------------------------------------------------- */\n/* Types */\n/* -------------------------------------------------------------------------- */\n\nexport type MessageScrollerDefaultScrollPosition = \"start\" | \"end\";\n\nexport type MessageScrollerScrollAlign = \"start\" | \"center\" | \"end\";\n\nexport interface MessageScrollerScrollOptions {\n align?: MessageScrollerScrollAlign;\n behavior?: ScrollBehavior;\n}\n\nexport interface MessageScrollerVisibilityState {\n /** True when the last registered item is in view at the bottom edge. */\n atEnd: boolean;\n /** True when the first registered item is in view at the top edge. */\n atStart: boolean;\n}\n\nexport interface MessageScrollerProviderProps {\n autoScroll?: boolean;\n defaultScrollPosition?: MessageScrollerDefaultScrollPosition;\n scrollEdgeThreshold?: number;\n scrollPreviousItemPeek?: number;\n scrollMargin?: number;\n /**\n * Opaque signal that changes whenever the last message's content\n * changes (new token, edit, or appended child). The provider uses\n * it as the dep for the auto-scroll effect so that streaming\n * re-runs the effect without a global store subscription.\n *\n * Most callers pass `messages.at(-1)?.id ?? \"\"` (or any\n * monotonically-changing value) — anything that React can compare\n * with Object.is.\n */\n contentSignal?: string | number;\n children?: React.ReactNode;\n}\n\nexport interface MessageScrollerProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\"> {\n children?: React.ReactNode;\n}\n\nexport interface MessageScrollerViewportProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\"> {\n children?: React.ReactNode;\n}\n\nexport interface MessageScrollerContentProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\"> {\n children?: React.ReactNode;\n}\n\nexport interface MessageScrollerItemProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\"> {\n id?: string;\n scrollAnchor?: boolean;\n children?: React.ReactNode;\n}\n\nexport interface MessageScrollerButtonProps\n extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, \"children\"> {\n direction?: \"start\" | \"end\";\n render?: React.ReactElement;\n children?: React.ReactNode;\n}\n\ninterface RegisteredMessage {\n id: string;\n element: HTMLElement | null;\n scrollAnchor?: boolean;\n}\n\ninterface MessageScrollerState {\n viewportEl: HTMLElement | null;\n scrollHeight: number;\n scrollTop: number;\n viewportHeight: number;\n autoScroll: boolean;\n}\n\ntype Listener = () => void;\n\nclass ScrollerStore {\n private state: MessageScrollerState = {\n viewportEl: null,\n scrollHeight: 0,\n scrollTop: 0,\n viewportHeight: 0,\n autoScroll: false,\n };\n private listeners = new Set<Listener>();\n\n getState = (): MessageScrollerState => this.state;\n\n subscribe = (listener: Listener): (() => void) => {\n this.listeners.add(listener);\n return () => {\n this.listeners.delete(listener);\n };\n };\n\n setState = (partial: Partial<MessageScrollerState>): void => {\n this.state = { ...this.state, ...partial };\n for (const l of this.listeners) l();\n };\n}\n\nconst VisibilityContext = React.createContext<{\n registerMessage: (msg: RegisteredMessage) => () => void;\n stateStore: ScrollerStore;\n scrollToIndex: (index: number, opts?: MessageScrollerScrollOptions) => void;\n scrollToEnd: (opts?: MessageScrollerScrollOptions) => void;\n scrollToStart: (opts?: MessageScrollerScrollOptions) => void;\n scrollToMessage: (id: string, opts?: MessageScrollerScrollOptions) => void;\n} | null>(null);\n\nfunction useScrollerContext() {\n const ctx = React.useContext(VisibilityContext);\n if (!ctx) {\n throw new Error(\n \"MessageScroller primitives must be used within MessageScrollerProvider.\",\n );\n }\n return ctx;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Provider */\n/* -------------------------------------------------------------------------- */\n\nexport function MessageScrollerProvider(props: MessageScrollerProviderProps) {\n const {\n autoScroll = false,\n defaultScrollPosition = \"end\",\n scrollEdgeThreshold = 4,\n contentSignal = \"\",\n children,\n } = props;\n\n const stateStoreRef = React.useRef<ScrollerStore | null>(null);\n if (stateStoreRef.current === null) stateStoreRef.current = new ScrollerStore();\n\n const messagesRef = React.useRef<RegisteredMessage[]>([]);\n const initialScrollDoneRef = React.useRef(false);\n\n const registerMessage = React.useCallback((msg: RegisteredMessage) => {\n messagesRef.current = [...messagesRef.current, msg];\n return () => {\n messagesRef.current = messagesRef.current.filter((m) => m.id !== msg.id);\n };\n }, []);\n\n const scrollToIndex = React.useCallback(\n (index: number, opts: MessageScrollerScrollOptions = {}) => {\n const vp = stateStoreRef.current!.getState().viewportEl;\n if (!vp) return;\n const item = messagesRef.current[index];\n if (!item?.element) return;\n const top = item.element.offsetTop;\n const align = opts.align ?? \"start\";\n let target = top;\n if (align === \"end\") target = top + item.element.offsetHeight - vp.clientHeight;\n else if (align === \"center\")\n target = top + item.element.offsetHeight / 2 - vp.clientHeight / 2;\n target = Math.max(0, target);\n // Use the modern scrollTo() when available (real browsers, jsdom\n // for testing). Fall back to setting scrollTop directly because\n // jsdom's pre-24 implementations did not implement scrollTo.\n if (typeof vp.scrollTo === \"function\") {\n vp.scrollTo({ top: target, behavior: opts.behavior ?? \"smooth\" });\n } else {\n vp.scrollTop = target;\n }\n },\n [],\n );\n\n const scrollToEnd = React.useCallback(\n (opts?: MessageScrollerScrollOptions) =>\n scrollToIndex(messagesRef.current.length - 1, {\n align: \"end\",\n ...opts,\n }),\n [scrollToIndex],\n );\n\n const scrollToStart = React.useCallback(\n (opts?: MessageScrollerScrollOptions) =>\n scrollToIndex(0, { align: \"start\", ...opts }),\n [scrollToIndex],\n );\n\n const scrollToMessage = React.useCallback(\n (id: string, opts?: MessageScrollerScrollOptions) => {\n const idx = messagesRef.current.findIndex((m) => m.id === id);\n if (idx >= 0) scrollToIndex(idx, opts);\n },\n [scrollToIndex],\n );\n\n // Initial scroll to default position on mount + once the viewport is set.\n React.useEffect(() => {\n const store = stateStoreRef.current!;\n const unsubscribe = store.subscribe(() => {\n const s = store.getState();\n if (!s.viewportEl || initialScrollDoneRef.current) return;\n // Wait one frame for content to layout.\n requestAnimationFrame(() => {\n if (initialScrollDoneRef.current) return;\n if (defaultScrollPosition === \"end\") scrollToEnd({ behavior: \"auto\" });\n else scrollToStart({ behavior: \"auto\" });\n initialScrollDoneRef.current = true;\n });\n });\n return unsubscribe;\n }, [defaultScrollPosition, scrollToEnd, scrollToStart]);\n\n // Track autoScroll toggle in store so the Viewport effect can re-evaluate.\n React.useEffect(() => {\n stateStoreRef.current!.setState({ autoScroll });\n }, [autoScroll]);\n\n // Content-driven auto-scroll. When the parent signals that the\n // last message's content changed (new token, edit, or a new\n // message appended), and the user is currently at the bottom edge\n // of the viewport, snap to the new bottom. The threshold is\n // configurable via `scrollEdgeThreshold` (default 4px — \"I was\n // at the edge\"); a wider threshold feels jumpy. Critically, this\n // effect is content-driven (deps: `contentSignal`, `autoScroll`)\n // and does NOT subscribe to the global state store, so other\n // consumers' state changes cannot trigger scroll-to-bottom.\n const scrollToEndRef = React.useRef(scrollToEnd);\n React.useEffect(() => {\n scrollToEndRef.current = scrollToEnd;\n }, [scrollToEnd]);\n\n React.useEffect(() => {\n if (!autoScroll) return;\n const store = stateStoreRef.current!;\n // Use rAF so we read scrollHeight after the new content has\n // been laid out. Without this, scrollHeight is from the\n // previous render and we under-scroll.\n const raf = requestAnimationFrame(() => {\n const s = store.getState();\n if (!s.viewportEl) return;\n const distance = s.scrollHeight - s.scrollTop - s.viewportHeight;\n if (distance > scrollEdgeThreshold) return;\n scrollToEndRef.current({ behavior: \"auto\" });\n });\n return () => cancelAnimationFrame(raf);\n }, [autoScroll, contentSignal, scrollEdgeThreshold, stateStoreRef]);\n\n const ctxValue = React.useMemo(\n () => ({\n registerMessage,\n stateStore: stateStoreRef.current!,\n scrollToIndex,\n scrollToEnd,\n scrollToStart,\n scrollToMessage,\n }),\n [registerMessage, scrollToIndex, scrollToEnd, scrollToStart, scrollToMessage],\n );\n\n return (\n <VisibilityContext.Provider value={ctxValue}>\n {children}\n </VisibilityContext.Provider>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Public hooks */\n/* -------------------------------------------------------------------------- */\n\nexport function useMessageScroller() {\n const { scrollToEnd, scrollToStart, scrollToMessage } = useScrollerContext();\n return React.useMemo(\n () => ({\n scrollToEnd,\n scrollToStart,\n scrollToMessage,\n }),\n [scrollToEnd, scrollToStart, scrollToMessage],\n );\n}\n\nexport function useMessageScrollerScrollable(): MessageScrollerState {\n const { stateStore } = useScrollerContext();\n return React.useSyncExternalStore(\n stateStore.subscribe,\n stateStore.getState,\n stateStore.getState,\n );\n}\n\nexport function useMessageScrollerVisibility(): MessageScrollerVisibilityState {\n const { stateStore } = useScrollerContext();\n // Cached snapshot — useSyncExternalStore requires stable refs between\n // calls when the underlying state hasn't changed.\n const cachedRef = React.useRef<MessageScrollerVisibilityState>({\n atEnd: false,\n atStart: true,\n });\n return React.useSyncExternalStore(\n stateStore.subscribe,\n () => {\n const s = stateStore.getState();\n const distance = s.scrollHeight - s.scrollTop - s.viewportHeight;\n const atEnd = distance < 32;\n const atStart = s.scrollTop < 32;\n const prev = cachedRef.current;\n if (prev.atEnd === atEnd && prev.atStart === atStart) return prev;\n const next = { atEnd, atStart };\n cachedRef.current = next;\n return next;\n },\n () => ({ atEnd: false, atStart: true }),\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Root */\n/* -------------------------------------------------------------------------- */\n\nconst Root = React.forwardRef<HTMLDivElement, MessageScrollerProps>(function (\n { children, ...rest },\n ref,\n) {\n return (\n <div ref={ref} {...rest}>\n {children}\n </div>\n );\n});\n\n/* -------------------------------------------------------------------------- */\n/* Viewport */\n/* -------------------------------------------------------------------------- */\n\nconst Viewport = React.forwardRef<HTMLDivElement, MessageScrollerViewportProps>(\n function ({ children, onScroll, ...rest }, ref) {\n const internalRef = React.useRef<HTMLDivElement | null>(null);\n const setRefs = React.useCallback(\n (node: HTMLDivElement | null) => {\n internalRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) {\n (ref as React.MutableRefObject<HTMLDivElement | null>).current = node;\n }\n },\n [ref],\n );\n const { stateStore } = useScrollerContext();\n\n // Register viewport in store.\n React.useEffect(() => {\n const node = internalRef.current;\n if (!node) return;\n stateStore.setState({\n viewportEl: node,\n scrollHeight: node.scrollHeight,\n scrollTop: node.scrollTop,\n viewportHeight: node.clientHeight,\n });\n return () => stateStore.setState({ viewportEl: null });\n }, [stateStore]);\n\n // Observe scroll + resize. The Content component is responsible\n // for content-driven events (new messages, streaming deltas);\n // the MutationObserver on the viewport was removed in the\n // scroll-flicker fix because it fired on every character\n // appended during streaming, which re-rendered all\n // useSyncExternalStore consumers (Header, JumpButton) and\n // caused visible scroll position drift.\n React.useLayoutEffect(() => {\n const node = internalRef.current;\n if (!node) return;\n\n const update = () =>\n stateStore.setState({\n scrollHeight: node.scrollHeight,\n scrollTop: node.scrollTop,\n viewportHeight: node.clientHeight,\n });\n\n node.addEventListener(\"scroll\", update, { passive: true });\n const ro = new ResizeObserver(update);\n ro.observe(node);\n\n // Initial measurement.\n update();\n\n return () => {\n node.removeEventListener(\"scroll\", update);\n ro.disconnect();\n };\n }, [stateStore]);\n\n return (\n <div\n ref={setRefs}\n onScroll={(e) => {\n onScroll?.(e);\n }}\n {...rest}\n >\n {children}\n </div>\n );\n },\n);\n\n/* -------------------------------------------------------------------------- */\n/* Content */\n/* -------------------------------------------------------------------------- */\n\nconst Content = React.forwardRef<HTMLDivElement, MessageScrollerContentProps>(\n function Content({ children, ...rest }, ref) {\n const internalRef = React.useRef<HTMLDivElement | null>(null);\n const { stateStore } = useScrollerContext();\n // The most recent scrollTop we saw while the user was at the\n // top edge. When new content is prepended, we bump scrollTop by\n // the height delta so the previously-first visible item stays in\n // the same visual position.\n const lastTopEdgeRef = React.useRef<{ scrollTop: number; scrollHeight: number } | null>(\n null,\n );\n const previousChildrenRef = React.useRef<React.ReactNode>(children);\n\n const setRefs = React.useCallback(\n (node: HTMLDivElement | null) => {\n internalRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) {\n (ref as React.MutableRefObject<HTMLDivElement | null>).current = node;\n }\n },\n [ref],\n );\n\n // When the children change (e.g. a prepend or a re-keyed swap),\n // detect a height delta and bump scrollTop so the user keeps\n // their reading position. This is the standard \"infinite scroll\"\n // pattern: capture scrollTop + scrollHeight before, after the\n // children have laid out, restore scrollTop + delta.\n //\n // We only preserve position when the user was near the top\n // (within 8px). At the bottom we don't need preservation because\n // the auto-scroll effect already handles that case; in the\n // middle of the transcript we also skip — a mid-scroll prepend\n // is a layout choice the consumer made deliberately, and\n // preserving position there is more confusing than helpful.\n React.useEffect(() => {\n const node = internalRef.current;\n if (!node) return;\n const prev = lastTopEdgeRef.current;\n const prevChildren = previousChildrenRef.current;\n // Update the ref BEFORE measurement so a strict-mode\n // double-invocation in dev doesn't apply the delta twice.\n previousChildrenRef.current = children;\n // Skip the very first render — lastTopEdgeRef is null and we\n // have no baseline to compare against.\n if (!prev || prevChildren === children) {\n return;\n }\n const newHeight = node.scrollHeight;\n const delta = newHeight - prev.scrollHeight;\n if (delta <= 0) {\n // Height shrank or stayed the same — nothing to do.\n return;\n }\n // Only preserve when the user was at the top edge. A small\n // tolerance (8px) covers the \"I scrolled to the very top\"\n // case without false positives for users a few pixels off.\n if (prev.scrollTop > 8) return;\n // Defer to the next frame so the new content has actually\n // laid out before we measure newHeight. Without rAF, scrollHeight\n // reflects the stale content and the delta is 0.\n const raf = requestAnimationFrame(() => {\n if (!internalRef.current) return;\n // Re-read after the frame to capture the actual final height.\n const finalHeight = internalRef.current.scrollHeight;\n const finalDelta = finalHeight - prev.scrollHeight;\n if (finalDelta > 0) {\n internalRef.current.scrollTop = prev.scrollTop + finalDelta;\n // Tell the store so the viewport's height readers see the\n // new value on the next render.\n stateStore.setState({\n scrollTop: prev.scrollTop + finalDelta,\n scrollHeight: finalHeight,\n });\n }\n });\n return () => cancelAnimationFrame(raf);\n }, [children, stateStore]);\n\n // Track the most recent top-edge sample. We update on scroll\n // (via a passive listener) and on the initial mount, but only\n // capture the sample when the user is near the top. The next\n // prepend effect then uses the last sample to restore.\n React.useLayoutEffect(() => {\n const node = internalRef.current;\n if (!node) return;\n const sample = () => {\n lastTopEdgeRef.current = {\n scrollTop: node.scrollTop,\n scrollHeight: node.scrollHeight,\n };\n };\n // Initial sample once layout is done.\n const raf = requestAnimationFrame(sample);\n node.addEventListener(\"scroll\", sample, { passive: true });\n return () => {\n cancelAnimationFrame(raf);\n node.removeEventListener(\"scroll\", sample);\n };\n }, []);\n\n return (\n <div ref={setRefs} {...rest}>\n {children}\n </div>\n );\n },\n);\n\n/* -------------------------------------------------------------------------- */\n/* Item */\n/* -------------------------------------------------------------------------- */\n\nconst Item = React.forwardRef<HTMLDivElement, MessageScrollerItemProps>(\n function ({ id, scrollAnchor, children, ...rest }, ref) {\n const { registerMessage } = useScrollerContext();\n const internalRef = React.useRef<HTMLDivElement | null>(null);\n const generatedId = React.useId();\n const itemId = id ?? generatedId;\n const setRefs = React.useCallback(\n (node: HTMLDivElement | null) => {\n internalRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) {\n (ref as React.MutableRefObject<HTMLDivElement | null>).current = node;\n }\n },\n [ref],\n );\n\n React.useEffect(() => {\n return registerMessage({\n id: itemId,\n element: internalRef.current,\n scrollAnchor,\n });\n }, [itemId, scrollAnchor, registerMessage]);\n\n return (\n <div ref={setRefs} {...rest}>\n {children}\n </div>\n );\n },\n);\n\n/* -------------------------------------------------------------------------- */\n/* Button (jump-to-start / jump-to-end) */\n/* -------------------------------------------------------------------------- */\n\nconst Button = React.forwardRef<HTMLButtonElement, MessageScrollerButtonProps>(\n function (\n { direction = \"end\", render, onClick, children, ...rest },\n ref,\n ) {\n const { stateStore, scrollToEnd, scrollToStart } = useScrollerContext();\n const active = useMessageScrollerVisibility();\n const isEnd = direction === \"end\";\n const isActive = isEnd ? !active.atEnd : !active.atStart;\n // Touch stateStore to ensure re-render when scroll position changes.\n useMessageScrollerScrollable();\n\n const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {\n onClick?.(e);\n if (isEnd) scrollToEnd();\n else scrollToStart();\n };\n\n if (render) {\n // Slot pattern — clone `render` and inject our props.\n return React.cloneElement(render as React.ReactElement<any>, {\n ref,\n onClick: handleClick,\n \"data-active\": isActive,\n \"data-direction\": direction,\n ...rest,\n children: children ?? (render as React.ReactElement<any>).props.children,\n });\n }\n\n return (\n <button\n ref={ref}\n type=\"button\"\n data-active={isActive}\n data-direction={direction}\n onClick={handleClick}\n {...rest}\n >\n {children}\n </button>\n );\n },\n);\n\n/* -------------------------------------------------------------------------- */\n/* Public surface (mirror of `@shadcn/react/message-scroller`) */\n/* -------------------------------------------------------------------------- */\n\nexport const MessageScroller = {\n Provider: MessageScrollerProvider,\n Root,\n Viewport,\n Content,\n Item,\n Button,\n};","/**\n * MessageScroller — styled wrapper that mirrors\n * `apps/v4/styles/radix-rhea/ui/message-scroller.tsx` from the official\n * `shadcn-ui/ui` repo (https://github.com/shadcn-ui/ui).\n *\n * Instead of consuming the upstream `@shadcn/react/message-scroller` package\n * (which is a workspace-only package in the monorepo and not published to\n * npm), this wrapper renders our local primitives from\n * `./MessageScrollerPrimitives`. The styled surface — class names,\n * `data-slot` attributes, ARIA behaviour — is identical to the upstream\n * radix-rhea version, so consumers see the same API and DOM shape.\n *\n * Source paths in the original module were remapped:\n * - `@shadcn/react/message-scroller` → `./MessageScrollerPrimitives`\n * - `@/lib/utils` → `../../lib/utils.js`\n * - `@/styles/radix-rhea/ui/button` → `../ui/button.js`\n */\n\"use client\";\n\nimport * as React from \"react\";\nimport { ArrowDownIcon } from \"lucide-react\";\n\nimport { cn } from \"../../lib/utils.js\";\nimport { Button } from \"../ui/button.js\";\nimport {\n MessageScroller as MessageScrollerPrimitive,\n useMessageScroller,\n useMessageScrollerScrollable,\n useMessageScrollerVisibility,\n} from \"./MessageScrollerPrimitives.js\";\n// Side-effect import: load the scroll-fade + scrollbar utilities so\n// consumers do not have to wire the CSS by hand. The MessageScroller\n// viewport relies on `scroll-fade-b`, `scrollbar-thin`,\n// `scrollbar-gutter-stable`, `overscroll-contain`, and\n// `data-autoscrolling:scrollbar-none` to look right.\nimport \"../../styles/scroller.css\";\n\nfunction MessageScrollerProvider(\n props: React.ComponentProps<typeof MessageScrollerPrimitive.Provider>,\n) {\n return <MessageScrollerPrimitive.Provider {...props} />;\n}\n\nfunction MessageScroller({\n className,\n ...props\n}: React.ComponentProps<typeof MessageScrollerPrimitive.Root>) {\n return (\n <MessageScrollerPrimitive.Root\n data-slot=\"message-scroller\"\n className={cn(\n \"group/message-scroller relative flex size-full min-h-0 flex-col overflow-hidden\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction MessageScrollerViewport({\n className,\n ...props\n}: React.ComponentProps<typeof MessageScrollerPrimitive.Viewport>) {\n return (\n <MessageScrollerPrimitive.Viewport\n data-slot=\"message-scroller-viewport\"\n className={cn(\n \"size-full min-h-0 min-w-0 scroll-fade-b scrollbar-thin scrollbar-gutter-stable overflow-y-auto overscroll-contain contain-content data-autoscrolling:scrollbar-none\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction MessageScrollerContent({\n className,\n ...props\n}: React.ComponentProps<typeof MessageScrollerPrimitive.Content>) {\n return (\n <MessageScrollerPrimitive.Content\n data-slot=\"message-scroller-content\"\n className={cn(\"flex h-max min-h-full flex-col gap-8\", className)}\n {...props}\n />\n );\n}\n\nfunction MessageScrollerItem({\n className,\n scrollAnchor = false,\n ...props\n}: React.ComponentProps<typeof MessageScrollerPrimitive.Item>) {\n return (\n <MessageScrollerPrimitive.Item\n data-slot=\"message-scroller-item\"\n scrollAnchor={scrollAnchor}\n className={cn(\n \"min-w-0 shrink-0 [contain-intrinsic-size:auto_10rem] [content-visibility:auto]\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction MessageScrollerButton({\n direction = \"end\",\n className,\n children,\n render,\n variant = \"secondary\",\n size = \"icon-sm\",\n ...props\n}: React.ComponentProps<typeof MessageScrollerPrimitive.Button> &\n Pick<React.ComponentProps<typeof Button>, \"variant\" | \"size\">) {\n return (\n <MessageScrollerPrimitive.Button\n data-slot=\"message-scroller-button\"\n data-direction={direction}\n data-variant={variant}\n data-size={size}\n direction={direction}\n className={cn(\n \"absolute left-1/2 -translate-x-1/2 border-border bg-background text-foreground transition-[translate,scale,opacity] duration-200 hover:bg-muted hover:text-foreground data-[active=false]:pointer-events-none data-[active=false]:scale-95 data-[active=false]:opacity-0 data-[active=false]:duration-400 data-[active=false]:ease-[cubic-bezier(0.7,0,0.84,0)] data-[active=true]:translate-y-0 data-[active=true]:scale-100 data-[active=true]:opacity-100 data-[active=true]:ease-[cubic-bezier(0.23,1,0.32,1)] data-[direction=end]:bottom-4 data-[direction=end]:data-[active=false]:translate-y-full data-[direction=start]:top-4 data-[direction=start]:data-[active=false]:-translate-y-full rtl:translate-x-1/2 data-[direction=start]:[&_svg]:rotate-180\",\n className,\n )}\n render={render ?? <Button variant={variant} size={size} />}\n {...props}\n >\n {children ?? (\n <>\n <ArrowDownIcon />\n <span className=\"sr-only\">\n {direction === \"end\" ? \"Scroll to end\" : \"Scroll to start\"}\n </span>\n </>\n )}\n </MessageScrollerPrimitive.Button>\n );\n}\n\nexport {\n MessageScrollerProvider,\n MessageScroller,\n MessageScrollerViewport,\n MessageScrollerContent,\n MessageScrollerItem,\n MessageScrollerButton,\n useMessageScroller,\n useMessageScrollerScrollable,\n useMessageScrollerVisibility,\n};","/**\n * MessageMarker — sourced from `apps/v4/styles/radix-rhea/ui/marker.tsx` in\n * the official `shadcn-ui/ui` repo (https://github.com/shadcn-ui/ui).\n *\n * File renamed `marker.tsx` → `MessageMarker.tsx` so the public API of this\n * package lines up with the kebab-case file naming convention used\n * throughout (`Message.tsx`, `Chatbubble.tsx`, etc.).\n *\n * Source paths in the original module were remapped:\n * - `@/lib/utils` → `../../lib/utils.js`\n * - `radix-ui` (Slot) → `@radix-ui/react-slot`\n */\nimport * as React from \"react\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport { Slot } from \"@radix-ui/react-slot\";\n\nimport { cn } from \"../../lib/utils.js\";\n// Side-effect: load the shimmer + marker CSS so consumers do not have\n// to wire it manually. Vendored in src/styles/marker.css and shipped\n// from dist/marker.css. Resolved relative to the package source so\n// the import works whether consumers consume via the package's exports\n// map (which sets `sideEffects: [\"**/*.css\"]`) or via the demo's\n// direct import of the source.\nimport \"../../styles/marker.css\";\n\nconst markerVariants = cva(\n \"group/marker relative flex min-h-4 w-full items-center gap-2 text-left text-sm text-muted-foreground [&_svg:not([class*='size-'])]:size-4 [a]:underline [a]:underline-offset-3 [a]:hover:text-foreground\",\n {\n variants: {\n variant: {\n default: \"\",\n separator:\n \"before:mr-1 before:h-px before:min-w-0 before:flex-1 before:bg-border after:ml-1 after:h-px after:min-w-0 after:flex-1 after:bg-border\",\n border: \"border-b border-border pb-2\",\n },\n },\n },\n);\n\nfunction Marker({\n className,\n variant = \"default\",\n asChild = false,\n ...props\n}: React.ComponentProps<\"div\"> &\n VariantProps<typeof markerVariants> & {\n asChild?: boolean;\n }) {\n const Comp = asChild ? Slot : \"div\";\n\n return (\n <Comp\n data-slot=\"marker\"\n data-variant={variant}\n className={cn(markerVariants({ variant, className }))}\n {...props}\n />\n );\n}\n\nfunction MarkerIcon({ className, ...props }: React.ComponentProps<\"span\">) {\n return (\n <span\n data-slot=\"marker-icon\"\n aria-hidden=\"true\"\n className={cn(\n \"size-4 shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction MarkerContent({ className, ...props }: React.ComponentProps<\"span\">) {\n return (\n <span\n data-slot=\"marker-content\"\n className={cn(\n \"min-w-0 wrap-break-word group-data-[variant=separator]/marker:flex-none group-data-[variant=separator]/marker:text-center *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport { Marker, MarkerIcon, MarkerContent, markerVariants };","/**\n * Markdown — renders assistant/tool message content as rich GitHub-flavored\n * Markdown with syntax-highlighted code blocks (copy + language label),\n * tables, links, and lists.\n *\n * Pipeline: react-markdown + remark-gfm (tables/strikethrough/autolinks) +\n * rehype-raw (inline HTML) + rehype-highlight (highlight.js token classes,\n * themed in globals.css). The renderer is memoized so re-renders during\n * streaming only re-parse when the text actually changes.\n *\n * Styling: when `typeset` is set, the container gets `typeset` + the chosen\n * preset class + CSS variables for any rhythm overrides. When omitted or\n * `enabled === false`, we fall back to `ai-prose` so existing consumers see\n * no change. Either way, the per-element classes in `components` below still\n * apply — Tailwind utilities win specificity over typeset's `:where()` rules.\n */\nimport { Check, Copy } from \"lucide-react\";\nimport { memo, useState, type CSSProperties, type ReactNode } from \"react\";\nimport ReactMarkdown from \"react-markdown\";\nimport rehypeHighlight from \"rehype-highlight\";\nimport rehypeRaw from \"rehype-raw\";\nimport remarkGfm from \"remark-gfm\";\nimport { Button } from \"../ui/button.js\";\nimport { cn } from \"../../lib/utils.js\";\nimport type { TypesetConfig } from \"../../types/chat.js\";\n\nfunction CopyButton({ getText }: { getText: () => string }) {\n const [copied, setCopied] = useState(false);\n return (\n <Button\n type=\"button\"\n variant=\"ghost\"\n aria-label=\"Copy code\"\n onClick={() => {\n try {\n void navigator.clipboard?.writeText(getText());\n setCopied(true);\n setTimeout(() => setCopied(false), 1600);\n } catch {\n /* ignore */\n }\n }}\n className=\"h-7 gap-1.5 px-2 text-[11px] font-medium text-muted-foreground hover:bg-foreground/10 hover:text-foreground\"\n >\n {copied ? (\n <>\n <Check className=\"size-3 text-success\" /> Copied\n </>\n ) : (\n <>\n <Copy className=\"size-3\" /> Copy\n </>\n )}\n </Button>\n );\n}\n\nfunction nodeToText(node: ReactNode): string {\n if (node == null || typeof node === \"boolean\") return \"\";\n if (typeof node === \"string\" || typeof node === \"number\") return String(node);\n if (Array.isArray(node)) return node.map(nodeToText).join(\"\");\n if (typeof node === \"object\" && \"props\" in node) {\n const props = (node as { props?: { children?: ReactNode } }).props;\n return nodeToText(props?.children);\n }\n return \"\";\n}\n\nexport interface MarkdownProps {\n children: string;\n className?: string;\n /**\n * Optional typeset styling. When provided, the container becomes a\n * `.typeset` element with the chosen preset + rhythm overrides. When\n * undefined, the container falls back to the package's `ai-prose` class\n * (the look every chat shipped with before this feature).\n *\n * The consumer app typically wires this from `config.ui.typeset` via the\n * parent component. Passing it directly is supported for callers that\n * want to bypass config plumbing (custom renderers, tests).\n */\n typeset?: TypesetConfig;\n /**\n * When false, the syntax-highlight plugin is skipped. Defaults to true\n * (highlights are on). Consumers wire this from `config.ui.enableCodeHighlight`.\n */\n enableCodeHighlight?: boolean;\n /**\n * When false, the per-code-block Copy button is omitted. Defaults to\n * true. Consumers wire this from `config.ui.enableCopyButtons`.\n */\n enableCopyButtons?: boolean;\n}\n\n/**\n * Resolves which CSS class + inline style the markdown container should use.\n * Pure function, exported for unit tests.\n */\nexport function typesetClassName(typeset: TypesetConfig | undefined): string {\n if (!typeset || typeset.enabled === false) {\n // Legacy look. Keep the same class so existing snapshots stay stable.\n return cn(\"ai-prose\", \"text-[0.9375rem] leading-relaxed\");\n }\n const presetClass =\n typeset.preset && typeset.preset !== \"default\" ? `typeset-${typeset.preset}` : \"typeset\";\n return cn(presetClass, \"text-[var(--typeset-size)]\");\n}\n\nexport function typesetInlineStyle(typeset: TypesetConfig | undefined): CSSProperties | undefined {\n if (!typeset || typeset.enabled === false) return undefined;\n const vars: Record<string, string | number> = {};\n if (typeset.size) vars[\"--typeset-size\"] = typeset.size;\n if (typeof typeset.leading === \"number\") vars[\"--typeset-leading\"] = typeset.leading;\n if (typeset.flow) vars[\"--typeset-flow\"] = typeset.flow;\n if (typeset.fontBody) vars[\"--typeset-font-body\"] = typeset.fontBody;\n if (typeset.fontHeading) vars[\"--typeset-font-heading\"] = typeset.fontHeading;\n if (typeset.fontMono) vars[\"--typeset-font-mono\"] = typeset.fontMono;\n return Object.keys(vars).length > 0 ? (vars as CSSProperties) : undefined;\n}\n\nexport const Markdown = memo(function Markdown({\n children,\n className,\n typeset,\n enableCodeHighlight = true,\n enableCopyButtons = true,\n}: MarkdownProps) {\n const containerClass = typesetClassName(typeset);\n const containerStyle = typesetInlineStyle(typeset);\n // rehypePlugins: omit `rehype-highlight` when `enableCodeHighlight` is off.\n// react-markdown's Pluggable[] type is `[Plugin, ...params]`; we cast so we\n// can branch at runtime without TypeScript narrowing the array shape.\nconst rehypePlugins = (\n enableCodeHighlight\n ? [rehypeRaw, [rehypeHighlight, { detect: true, ignoreMissing: true }]]\n : [rehypeRaw]\n) as Parameters<typeof ReactMarkdown>[0][\"rehypePlugins\"];\n return (\n <div\n className={cn(containerClass, className)}\n style={containerStyle}\n >\n <ReactMarkdown\n remarkPlugins={[remarkGfm]}\n rehypePlugins={rehypePlugins}\n components={{\n p: ({ children }) => <p className=\"my-2.5\">{children}</p>,\n a: ({ children, href }) => (\n <a\n href={href}\n target=\"_blank\"\n rel=\"noreferrer noopener\"\n className=\"font-medium text-primary underline decoration-primary/30 underline-offset-2 transition-colors hover:decoration-primary\"\n >\n {children}\n </a>\n ),\n img: ({ src, alt }) => (\n // eslint-disable-next-line @next/next/no-img-element\n <img\n src={typeof src === \"string\" ? src : undefined}\n alt={alt ?? \"\"}\n loading=\"lazy\"\n className=\"my-2 h-auto max-h-80 max-w-full rounded-xl border border-border object-contain\"\n />\n ),\n ul: ({ children }) => (\n <ul className=\"my-2.5 list-disc space-y-1 pl-5 marker:text-muted-foreground\">\n {children}\n </ul>\n ),\n ol: ({ children }) => (\n <ol className=\"my-2.5 list-decimal space-y-1 pl-5 marker:text-muted-foreground\">\n {children}\n </ol>\n ),\n li: ({ children }) => <li className=\"pl-1\">{children}</li>,\n h1: ({ children }) => (\n <h1 className=\"mb-2 mt-4 text-lg font-semibold tracking-tight\">\n {children}\n </h1>\n ),\n h2: ({ children }) => (\n <h2 className=\"mb-2 mt-4 text-base font-semibold tracking-tight\">\n {children}\n </h2>\n ),\n h3: ({ children }) => (\n <h3 className=\"mb-1.5 mt-3 text-sm font-semibold tracking-tight\">\n {children}\n </h3>\n ),\n blockquote: ({ children }) => (\n <blockquote className=\"my-3 rounded-r-md border-l-2 border-primary/40 bg-primary/5 py-1 pl-3 text-muted-foreground\">\n {children}\n </blockquote>\n ),\n hr: () => <hr className=\"my-4 border-border\" />,\n table: ({ children }) => (\n <div className=\"my-3 overflow-x-auto rounded-lg border border-border\">\n <table className=\"w-full border-collapse text-sm\">{children}</table>\n </div>\n ),\n thead: ({ children }) => (\n <thead className=\"bg-muted/60\">{children}</thead>\n ),\n th: ({ children }) => (\n <th className=\"border-b border-border px-3 py-2 text-left font-semibold\">\n {children}\n </th>\n ),\n td: ({ children }) => (\n <td className=\"border-b border-border/60 px-3 py-2 align-top\">\n {children}\n </td>\n ),\n code: ({ className: cls, children, ...props }) => {\n const isBlock = /language-/.test(cls ?? \"\");\n if (!isBlock) {\n return (\n <code\n className=\"rounded-md border border-border/70 bg-muted/70 px-1.5 py-0.5 font-mono text-[0.85em] text-foreground\"\n {...props}\n >\n {children}\n </code>\n );\n }\n return (\n <code className={cls} {...props}>\n {children}\n </code>\n );\n },\n pre: ({ children }) => {\n const lang = extractLang(children);\n return (\n <div className=\"group/code my-3 overflow-hidden rounded-xl border border-border bg-[oklch(0.16_0.02_285)] shadow-sm\">\n <div className=\"flex items-center justify-between border-b border-white/10 bg-white/[0.03] px-3 py-1.5\">\n <span className=\"font-mono text-[11px] font-medium uppercase tracking-wide text-white/50\">\n {lang || \"code\"}\n </span>\n {enableCopyButtons && (\n <CopyButton getText={() => nodeToText(children)} />\n )}\n </div>\n <pre className=\"overflow-x-auto px-4 py-3 text-[0.8125rem] leading-relaxed text-white/90 [&_code]:bg-transparent [&_code]:p-0\">\n {children}\n </pre>\n </div>\n );\n },\n }}\n >\n {children}\n </ReactMarkdown>\n </div>\n );\n});\n\nfunction extractLang(children: ReactNode): string {\n // <pre><code class=\"hljs language-ts\">…\n const child = Array.isArray(children) ? children[0] : children;\n const cls =\n (child &&\n typeof child === \"object\" &&\n \"props\" in child &&\n (child as { props?: { className?: string } }).props?.className) ||\n \"\";\n const m = /language-([\\w-]+)/.exec(cls);\n return m ? m[1] : \"\";\n}\n","/**\n * ReasoningPanel — a collapsible \"thinking\" disclosure that surfaces a model's\n * chain-of-thought (from structured reasoning deltas or inline <think> tags).\n * Auto-expands while the model is actively reasoning, then collapses once the\n * answer arrives; users can toggle it any time.\n */\nimport { ChevronRight, Lightbulb } from \"lucide-react\";\nimport { useEffect, useState } from \"react\";\nimport {\n Collapsible,\n CollapsibleContent,\n CollapsibleTrigger,\n} from \"../ui/collapsible.js\";\nimport { Button } from \"../ui/button.js\";\nimport { cn } from \"../../lib/utils.js\";\n\nexport interface ReasoningPanelProps {\n reasoning: string;\n /** True while this message is still streaming (model is thinking live). */\n active?: boolean;\n}\n\nexport function ReasoningPanel({ reasoning, active }: ReasoningPanelProps) {\n const [open, setOpen] = useState(Boolean(active));\n\n // Follow the live state: open while thinking, collapse when done.\n useEffect(() => {\n setOpen(Boolean(active));\n }, [active]);\n\n if (!reasoning.trim()) return null;\n\n return (\n <Collapsible open={open} onOpenChange={setOpen} className=\"w-fit max-w-full\">\n <CollapsibleTrigger asChild>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n className=\"group/think h-7 gap-1.5 rounded-lg px-2 text-xs font-medium text-muted-foreground hover:bg-foreground/5 hover:text-foreground\"\n >\n <Lightbulb className={cn(\"size-3.5\", active && \"text-primary\")} />\n {active ? (\n <span className=\"shimmer\">Thinking…</span>\n ) : (\n \"Thought process\"\n )}\n <ChevronRight className=\"size-3 opacity-60 transition-transform group-data-[state=open]/think:rotate-90\" />\n </Button>\n </CollapsibleTrigger>\n <CollapsibleContent>\n <div className=\"mt-1 max-h-72 overflow-y-auto whitespace-pre-wrap rounded-xl bg-muted/40 p-3 text-xs leading-relaxed text-muted-foreground scrollbar-thin\">\n {reasoning.trim()}\n </div>\n </CollapsibleContent>\n </Collapsible>\n );\n}\n\n/**\n * Split assistant content into inline reasoning (`<think>` / `<thinking>`\n * blocks, including an unclosed one mid-stream) and the visible answer.\n */\nexport function splitReasoning(content: string): { think: string; answer: string } {\n let think = \"\";\n let answer = content.replace(\n /<think(?:ing)?>([\\s\\S]*?)<\\/think(?:ing)?>/gi,\n (_m, inner: string) => {\n think += (think ? \"\\n\" : \"\") + inner;\n return \"\";\n },\n );\n // Unclosed (streaming) block: everything after the last opening tag.\n const open = /<think(?:ing)?>/i.exec(answer);\n if (open) {\n think += (think ? \"\\n\" : \"\") + answer.slice(open.index + open[0].length);\n answer = answer.slice(0, open.index);\n }\n return { think: think.trim(), answer: answer.trim() };\n}\n","/**\n * MessageList — the scrolling conversation surface.\n *\n * Built on the radix-rhea `MessageScroller` primitives (off-screen rows use\n * `content-visibility: auto` so long threads stay fast). Each row composes an\n * avatar + bubble; assistant/tool content renders as rich Markdown with\n * highlighted code, while user content stays plain text. Empty threads show a\n * welcome screen with quick-start suggestions.\n */\nimport {\n AlertTriangle,\n ArrowDown,\n Bot,\n Check,\n Clock,\n Copy,\n Gauge,\n Hash,\n KeyRound,\n Loader2,\n type LucideIcon,\n Pencil,\n RotateCcw,\n ServerCrash,\n Sparkles,\n Trash2,\n User,\n WifiOff,\n Wrench,\n} from \"lucide-react\";\nimport { useState } from \"react\";\nimport { useChat } from \"../../hooks/useChat.js\";\nimport { Bubble, BubbleContent } from \"./Chatbubble.js\";\nimport {\n Message,\n MessageAvatar,\n MessageContent,\n MessageFooter,\n} from \"./Message.js\";\nimport {\n MessageScroller,\n MessageScrollerButton,\n MessageScrollerContent,\n MessageScrollerItem,\n MessageScrollerProvider,\n MessageScrollerViewport,\n} from \"./MessageScroller.js\";\nimport { Marker, MarkerContent, MarkerIcon } from \"./MessageMarker.js\";\nimport { AttachmentPreview } from \"./AttachmentPreview.js\";\nimport { Button } from \"../ui/button.js\";\nimport {\n Collapsible,\n CollapsibleContent,\n CollapsibleTrigger,\n} from \"../ui/collapsible.js\";\nimport { Markdown } from \"./Markdown.js\";\nimport { useOptionalChat } from \"./ChatProvider.js\";\nimport { ReasoningPanel, splitReasoning } from \"./ReasoningPanel.js\";\nimport { Textarea } from \"../ui/input.js\";\nimport { extractMessageText } from \"../../lib/attachments.js\";\nimport { cn, estimateTokens } from \"../../lib/utils.js\";\nimport type { ChatError, ChatMessage, Role } from \"../../types/chat.js\";\n\nexport interface MessageListProps {\n className?: string;\n /** Extra className on the inner content wrapper, merged over the default\n * `max-w-3xl` via tailwind-merge. Use this to let the conversation use\n * more horizontal space in wide layouts. */\n contentClassName?: string;\n}\n\nconst DEFAULT_SUGGESTIONS = [\n \"Explain a tricky concept simply\",\n \"Write and review a code snippet\",\n \"Brainstorm ideas with me\",\n \"Summarize a long document\",\n];\n\nexport function MessageList({ className, contentClassName }: MessageListProps) {\n const chat = useChat();\n const messages = chat.messages;\n\n // contentSignal fires the provider's auto-scroll effect whenever\n // the last message identity changes OR a streaming token arrives.\n // We use a tuple of (lastId, lastContentLength) so the signal\n // bumps on both new messages and incremental token deltas.\n const lastMessage = messages.at(-1);\n const contentSignal = lastMessage\n ? `${lastMessage.id}:${lastMessage.content?.length ?? 0}`\n : \"\";\n\n return (\n <MessageScrollerProvider\n autoScroll\n defaultScrollPosition=\"end\"\n contentSignal={contentSignal}\n >\n <MessageScroller className={cn(\"relative flex-1\", className)}>\n {messages.length === 0 ? (\n <MessageScrollerViewport>\n <WelcomeScreen />\n </MessageScrollerViewport>\n ) : (\n <MessageScrollerViewport>\n <MessageScrollerContent className={cn(\"mx-auto w-full max-w-3xl gap-5 px-3 py-6 sm:px-5\", contentClassName)}>\n {messages.map((msg, idx) => (\n <MessageScrollerItem\n key={msg.id}\n id={msg.id}\n scrollAnchor={idx === messages.length - 1}\n >\n <MessageItem\n message={msg}\n isStreaming={chat.isStreaming && idx === messages.length - 1}\n />\n </MessageScrollerItem>\n ))}\n </MessageScrollerContent>\n </MessageScrollerViewport>\n )}\n <MessageScrollerButton\n direction=\"end\"\n className=\"size-9 rounded-full surface-elevated text-foreground/80 backdrop-blur\"\n >\n <ArrowDown className=\"size-4\" />\n </MessageScrollerButton>\n </MessageScroller>\n </MessageScrollerProvider>\n );\n}\n\nfunction WelcomeScreen() {\n const chat = useChat();\n const cfg = chat.config;\n const ui = cfg.ui ?? {};\n\n const greeting = ui.greeting ?? \"How can I help you today?\";\n const suggestions = ui.suggestions ?? DEFAULT_SUGGESTIONS;\n\n if (ui.emptyState) {\n return (\n <div className=\"flex h-full items-center justify-center p-8 text-center\">\n {ui.emptyState as React.ReactNode}\n </div>\n );\n }\n\n return (\n <div className=\"mx-auto flex h-full w-full max-w-2xl flex-col items-center justify-center px-4 py-10 text-center\">\n <div className=\"animate-message-in relative mb-6 grid size-16 place-items-center rounded-2xl grad-primary text-primary-foreground glow-primary-strong\">\n <Sparkles className=\"size-7\" />\n <span className=\"ring-conic absolute -inset-px -z-10 rounded-2xl opacity-40 blur-md\" />\n </div>\n <h2 className=\"text-balance text-2xl font-semibold tracking-tight sm:text-3xl\">\n {greeting}\n </h2>\n <p className=\"mt-2 max-w-md text-pretty text-sm text-muted-foreground\">\n Ask anything, or start with one of these. Powered by{\" \"}\n <span className=\"font-medium text-foreground\">\n {cfg.model.label ?? cfg.model.id}\n </span>\n .\n </p>\n\n <div className=\"mt-8 grid w-full grid-cols-1 gap-2.5 sm:grid-cols-2\">\n {suggestions.map((s, i) => (\n <Button\n key={s}\n type=\"button\"\n variant=\"outline\"\n onClick={() => void chat.send(s)}\n style={{ animationDelay: `${i * 60}ms` }}\n className=\"animate-message-in group h-auto justify-start gap-3 whitespace-normal rounded-xl border-border/70 bg-card/60 px-4 py-3 text-left text-sm font-normal transition-all hover:-translate-y-0.5 hover:border-primary/40 hover:bg-card hover:shadow-[0_8px_24px_-12px_oklch(var(--glow)/0.4)]\"\n >\n <span className=\"grid size-7 shrink-0 place-items-center rounded-lg bg-primary/10 text-primary transition-colors group-hover:bg-primary/15\">\n <Sparkles className=\"size-3.5\" />\n </span>\n <span className=\"text-pretty text-foreground/90\">{s}</span>\n </Button>\n ))}\n </div>\n </div>\n );\n}\n\ninterface MessageItemProps {\n message: ChatMessage;\n isStreaming: boolean;\n}\n\nfunction MessageItem({ message, isStreaming }: MessageItemProps) {\n const chat = useChat();\n const cfg = chat.config;\n const ui = cfg.ui ?? {};\n const [editing, setEditing] = useState(false);\n const isError = message.status === \"error\";\n // Errors are system feedback — always render them on the assistant (left)\n // side with the error card, never as a right-aligned user bubble.\n const align: \"start\" | \"end\" =\n !isError && message.role === \"user\" ? \"end\" : \"start\";\n const isUser = !isError && message.role === \"user\";\n const variant = bubbleVariantForRole(message.role, message.status);\n // User turns with attachments store an `ai-chat-blocks` JSON marker as\n // content; surface only the typed text (images render as chips above).\n const raw = isUser ? extractMessageText(message.content) : message.content;\n // Separate the model's reasoning (structured `reasoning` field + inline\n // <think> tags) from the visible answer.\n const { think, answer } = isUser\n ? { think: \"\", answer: raw }\n : splitReasoning(raw);\n const reasoning = isUser\n ? \"\"\n : [message.reasoning, think].filter(Boolean).join(\"\\n\").trim();\n const displayText = isUser ? raw : answer;\n const showThinking =\n message.status === \"streaming\" &&\n displayText.trim().length === 0 &&\n reasoning.length === 0;\n\n return (\n <Message align={align} className=\"animate-message-in\">\n {!isUser && (\n <MessageAvatar className=\"bg-transparent\">\n <AvatarFor role={isError ? \"assistant\" : message.role} />\n </MessageAvatar>\n )}\n <MessageContent>\n {message.attachments && message.attachments.length > 0 && (\n <div\n className={cn(\n \"flex flex-wrap gap-2\",\n align === \"end\" && \"justify-end\",\n )}\n >\n {message.attachments.map((att) => (\n <AttachmentPreview key={att.id} att={att} />\n ))}\n </div>\n )}\n\n {reasoning.length > 0 && (\n <ReasoningPanel\n reasoning={reasoning}\n active={message.status === \"streaming\"}\n />\n )}\n\n {editing ? (\n <MessageEditor\n initial={displayText}\n onCancel={() => setEditing(false)}\n onSave={(next) => {\n setEditing(false);\n if (next.trim() && next.trim() !== displayText.trim()) {\n void chat.editAndResend(message.id, next.trim());\n }\n }}\n />\n ) : (\n (displayText.trim().length > 0 || showThinking) && (\n <Bubble variant={variant} align={align}>\n <BubbleContent\n className={cn(isUser ? \"surface-tinted text-foreground\" : \"surface-elevated\")}\n >\n {showThinking ? (\n <ThinkingDots />\n ) : (\n <MessageBody message={message} isUser={isUser} text={displayText} />\n )}\n {message.status === \"streaming\" && !showThinking && (\n <span className=\"ml-0.5 inline-block h-4 w-[3px] translate-y-0.5 animate-pulse rounded-full bg-current align-text-bottom\" />\n )}\n </BubbleContent>\n </Bubble>\n )\n )}\n\n {/* Tool calls render as Markers. */}\n {message.toolCalls && message.toolCalls.length > 0 && (\n <div className=\"flex flex-col gap-1\">\n {message.toolCalls.map((tc) => (\n <Marker key={tc.id} variant=\"default\">\n <MarkerIcon>\n {tc.status === \"error\" ? (\n <AlertTriangle />\n ) : tc.status === \"complete\" ? (\n <Check />\n ) : (\n <Loader2 className=\"animate-spin\" />\n )}\n </MarkerIcon>\n <MarkerContent>\n <span className=\"font-mono\">{tc.name}</span>\n {tc.status === \"error\"\n ? \" failed\"\n : tc.status === \"complete\"\n ? \"\"\n : \" …\"}\n </MarkerContent>\n </Marker>\n ))}\n </div>\n )}\n\n {isError && (\n <div className=\"self-start\">\n <ErrorCard error={message.error} onRetry={() => void chat.regenerate()} />\n </div>\n )}\n\n {/* Generation stats (assistant, completed). */}\n {!isUser && message.status === \"complete\" && (\n <MessageStats message={message} answer={displayText} />\n )}\n\n {/* Hover actions + timestamp. */}\n {!editing && !showThinking && displayText.trim().length > 0 && (\n <MessageActions\n message={message}\n copyText={displayText}\n align={align}\n isUser={isUser}\n showTimestamp={ui.showTimestamps ?? true}\n onEdit={isUser ? () => setEditing(true) : undefined}\n onDelete={() => chat.deleteMessage(message.id)}\n showActions={ui.enableMessageActions ?? true}\n showRegenerate={ui.enableRegenerate ?? true}\n showEdit={isUser && (ui.enableEditAndResend ?? true)}\n />\n )}\n\n {isStreaming && !showThinking && (\n <MessageFooter>\n <span className=\"inline-flex items-center gap-1.5 text-primary\">\n <Loader2 className=\"size-3 animate-spin\" />\n Generating…\n </span>\n </MessageFooter>\n )}\n\n {message.role === \"tool\" && message.name && (\n <MessageFooter>\n <span className=\"inline-flex items-center gap-1\">\n <Wrench className=\"size-3\" />\n tool · <span className=\"font-mono\">{message.name}</span>\n </span>\n </MessageFooter>\n )}\n </MessageContent>\n </Message>\n );\n}\n\nfunction MessageActions({\n message,\n copyText,\n align,\n isUser,\n showTimestamp,\n onEdit,\n onDelete,\n showActions = true,\n showRegenerate = true,\n showEdit = true,\n}: {\n message: ChatMessage;\n copyText: string;\n align: \"start\" | \"end\";\n isUser: boolean;\n showTimestamp: boolean;\n onEdit?: () => void;\n onDelete?: () => void;\n showActions?: boolean;\n showRegenerate?: boolean;\n showEdit?: boolean;\n}) {\n const chat = useChat();\n const [copied, setCopied] = useState(false);\n const isAssistant = message.role === \"assistant\";\n\n const copy = () => {\n try {\n void navigator.clipboard?.writeText(copyText);\n setCopied(true);\n setTimeout(() => setCopied(false), 1600);\n } catch {\n /* ignore */\n }\n };\n\n const btn = \"size-7 text-muted-foreground hover:bg-foreground/10 hover:text-foreground\";\n\n if (!showActions) return null;\n\n return (\n <MessageFooter\n className={cn(\n \"w-fit gap-0.5 opacity-0 transition-opacity duration-150 focus-within:opacity-100 group-hover/message:opacity-100\",\n align === \"end\" && \"flex-row-reverse self-end\",\n )}\n >\n <Button type=\"button\" variant=\"ghost\" size=\"icon-sm\" onClick={copy} aria-label=\"Copy message\" className={btn}>\n {copied ? <Check className=\"size-3.5 text-success\" /> : <Copy className=\"size-3.5\" />}\n </Button>\n {isAssistant && showRegenerate && (\n <Button type=\"button\" variant=\"ghost\" size=\"icon-sm\" onClick={() => void chat.regenerate()} aria-label=\"Regenerate response\" className={btn}>\n <RotateCcw className=\"size-3.5\" />\n </Button>\n )}\n {isUser && onEdit && showEdit && (\n <Button type=\"button\" variant=\"ghost\" size=\"icon-sm\" onClick={onEdit} aria-label=\"Edit message\" className={btn}>\n <Pencil className=\"size-3.5\" />\n </Button>\n )}\n {onDelete && (\n <Button type=\"button\" variant=\"ghost\" size=\"icon-sm\" onClick={onDelete} aria-label=\"Delete message\" className=\"size-7 text-muted-foreground hover:bg-foreground/10 hover:text-destructive\">\n <Trash2 className=\"size-3.5\" />\n </Button>\n )}\n {showTimestamp && (\n <span className=\"px-1.5 text-[11px] tabular-nums text-muted-foreground/70\">\n {formatTime(message.createdAt)}\n </span>\n )}\n </MessageFooter>\n );\n}\n\nfunction MessageStats({\n message,\n answer,\n}: {\n message: ChatMessage;\n answer: string;\n}) {\n const tokens = message.usage?.completionTokens ?? estimateTokens(answer);\n const durMs =\n message.startedAt && message.completedAt\n ? message.completedAt - message.startedAt\n : undefined;\n const secs = durMs ? durMs / 1000 : undefined;\n const tps = tokens && secs && secs > 0 ? tokens / secs : undefined;\n if (!tokens && !secs && !message.model) return null;\n\n return (\n <div className=\"flex flex-wrap items-center gap-3 px-3 text-[11px] text-muted-foreground/70\">\n {message.model && (\n <span\n className=\"inline-flex items-center gap-1\"\n title={`Generated by ${message.model}`}\n >\n <Bot className=\"size-3\" />\n {message.model}\n </span>\n )}\n {tps !== undefined && (\n <span className=\"inline-flex items-center gap-1\">\n <Gauge className=\"size-3\" />\n {tps.toFixed(1)} tok/s\n </span>\n )}\n {tokens > 0 && (\n <span className=\"inline-flex items-center gap-1 tabular-nums\">\n <Hash className=\"size-3\" />\n {tokens} tokens\n </span>\n )}\n {secs !== undefined && (\n <span className=\"inline-flex items-center gap-1 tabular-nums\">\n <Clock className=\"size-3\" />\n {secs.toFixed(2)}s\n </span>\n )}\n </div>\n );\n}\n\nfunction MessageEditor({\n initial,\n onSave,\n onCancel,\n}: {\n initial: string;\n onSave: (next: string) => void;\n onCancel: () => void;\n}) {\n const [value, setValue] = useState(initial);\n return (\n <div className=\"w-full max-w-[80%] self-end\">\n <Textarea\n autoFocus\n value={value}\n onChange={(e) => setValue(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" && !e.shiftKey) {\n e.preventDefault();\n onSave(value);\n }\n if (e.key === \"Escape\") onCancel();\n }}\n className=\"min-h-16 w-full resize-y rounded-2xl surface-tinted text-sm text-foreground\"\n />\n <div className=\"mt-1.5 flex justify-end gap-2\">\n <Button type=\"button\" variant=\"ghost\" size=\"sm\" onClick={onCancel}>\n Cancel\n </Button>\n <Button type=\"button\" size=\"sm\" onClick={() => onSave(value)} className=\"gap-1.5\">\n <Check className=\"size-3.5\" />\n Save &amp; resend\n </Button>\n </div>\n </div>\n );\n}\n\nfunction ThinkingDots() {\n return (\n <span\n className=\"flex items-center gap-1 py-1\"\n aria-label=\"Assistant is typing\"\n >\n {[0, 1, 2].map((i) => (\n <span\n key={i}\n className=\"size-2 rounded-full bg-primary\"\n style={{\n animation: \"typing-bounce 1.2s ease-in-out infinite\",\n animationDelay: `${i * 0.18}s`,\n }}\n />\n ))}\n </span>\n );\n}\n\nfunction MessageBody({\n message,\n isUser,\n text,\n}: {\n message: ChatMessage;\n isUser: boolean;\n text: string;\n}) {\n // Pull the active config (if any) so markdown can pick up the per-chat\n // typeset styling without changing this component's prop signature.\n // useOptionalChat returns null when the MessageList renders outside a\n // ChatProvider (e.g. in tests) — we fall back to the legacy look in that case.\n const chatCtx = useOptionalChat();\n const typeset = chatCtx?.config.ui?.typeset;\n const ui = chatCtx?.config.ui ?? {};\n const enableCodeHighlight = ui.enableCodeHighlight ?? true;\n const enableCopyButtons = ui.enableCopyButtons ?? true;\n if (message.role === \"tool\") {\n return (\n <pre className=\"max-w-full overflow-x-auto whitespace-pre-wrap break-words font-mono text-xs\">\n {truncate(text, 1200)}\n </pre>\n );\n }\n if (isUser) {\n return <span className=\"whitespace-pre-wrap break-words\">{text}</span>;\n }\n return (\n <Markdown\n typeset={typeset}\n enableCodeHighlight={enableCodeHighlight}\n enableCopyButtons={enableCopyButtons}\n >\n {text}\n </Markdown>\n );\n}\n\nfunction humanizeError(error?: ChatError): {\n title: string;\n body: string;\n Icon: LucideIcon;\n} {\n switch (error?.code) {\n case \"rate_limit\":\n return {\n title: \"You've hit the rate limit\",\n body: \"This model's plan is out of quota right now. Wait a moment and try again, or upgrade your plan for more usage.\",\n Icon: Gauge,\n };\n case \"auth\":\n return {\n title: \"Couldn't authenticate\",\n body: \"The API key was rejected. Double-check that it's correct and has access to this model.\",\n Icon: KeyRound,\n };\n case \"network\":\n return {\n title: \"Connection problem\",\n body: \"I couldn't reach the model. Check your internet connection and try again.\",\n Icon: WifiOff,\n };\n case \"server\":\n return {\n title: \"The model service had a problem\",\n body: \"The provider returned an error. This is usually temporary — try again in a moment.\",\n Icon: ServerCrash,\n };\n case \"context_overflow\":\n return {\n title: \"This conversation got too long\",\n body: \"It exceeded the model's context window. Start a new chat or remove some earlier messages.\",\n Icon: AlertTriangle,\n };\n case \"aborted\":\n return {\n title: \"Generation stopped\",\n body: \"You stopped this response. Send again to retry.\",\n Icon: AlertTriangle,\n };\n case \"parse\":\n return {\n title: \"I couldn't read the reply\",\n body: \"The model's response came back malformed. Trying again usually fixes it.\",\n Icon: AlertTriangle,\n };\n default:\n return {\n title: \"Something went wrong\",\n body: \"An unexpected error stopped this response. Let's try again.\",\n Icon: AlertTriangle,\n };\n }\n}\n\nfunction ErrorCard({\n error,\n onRetry,\n}: {\n error?: ChatError;\n onRetry: () => void;\n}) {\n const { title, body, Icon } = humanizeError(error);\n const technical = error?.message?.trim();\n\n return (\n <div className=\"w-fit max-w-[85%] rounded-3xl surface-elevated p-3 text-sm\">\n <div className=\"flex gap-2.5\">\n <span className=\"grid size-8 shrink-0 place-items-center rounded-lg bg-destructive/10 text-destructive\">\n <Icon className=\"size-4\" />\n </span>\n <div className=\"min-w-0 flex-1\">\n <p className=\"font-medium text-destructive\">{title}</p>\n <p className=\"mt-0.5 text-pretty text-muted-foreground\">{body}</p>\n\n <div className=\"mt-2.5 flex flex-wrap items-center gap-2\">\n <Button\n type=\"button\"\n size=\"sm\"\n onClick={onRetry}\n className=\"h-8 gap-1.5 rounded-lg text-xs\"\n >\n <RotateCcw className=\"size-3.5\" />\n Try again\n </Button>\n {technical && (\n <Collapsible className=\"min-w-0\">\n <CollapsibleTrigger asChild>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n className=\"h-8 gap-1 rounded-lg px-2 text-xs font-normal text-muted-foreground hover:bg-foreground/5 hover:text-foreground\"\n >\n <AlertTriangle className=\"size-3\" />\n Technical details\n </Button>\n </CollapsibleTrigger>\n <CollapsibleContent>\n <pre className=\"mt-2 max-h-40 max-w-full overflow-auto whitespace-pre-wrap break-all rounded-lg bg-muted/60 p-2.5 font-mono text-[11px] leading-relaxed text-muted-foreground\">\n {error?.code\n ? `${error.code}${error.status ? ` · ${error.status}` : \"\"}\\n`\n : \"\"}\n {technical}\n </pre>\n </CollapsibleContent>\n </Collapsible>\n )}\n </div>\n </div>\n </div>\n </div>\n );\n}\n\nfunction bubbleVariantForRole(\n role: Role,\n status: ChatMessage[\"status\"],\n): \"default\" | \"secondary\" | \"muted\" | \"destructive\" {\n if (status === \"error\") return \"destructive\";\n if (role === \"user\") return \"default\";\n if (role === \"assistant\") return \"secondary\";\n return \"muted\";\n}\n\nfunction AvatarFor({ role }: { role: Role }) {\n if (role === \"user\") {\n return (\n <div className=\"flex size-8 items-center justify-center rounded-full bg-muted text-muted-foreground ring-1 ring-border/70\">\n <User className=\"size-4\" />\n </div>\n );\n }\n if (role === \"assistant\") {\n return (\n <div className=\"flex size-8 items-center justify-center rounded-full grad-primary text-primary-foreground shadow-sm glow-primary\">\n <Sparkles className=\"size-4\" />\n </div>\n );\n }\n return (\n <div className=\"flex size-8 items-center justify-center rounded-full bg-muted text-muted-foreground\">\n <Wrench className=\"size-4\" />\n </div>\n );\n}\n\nfunction formatTime(ts: number): string {\n try {\n return new Date(ts).toLocaleTimeString(undefined, {\n hour: \"2-digit\",\n minute: \"2-digit\",\n });\n } catch {\n return \"\";\n }\n}\n\nfunction truncate(s: string, n: number): string {\n return s.length > n ? `${s.slice(0, n)}…` : s;\n}\n","/**\n * The full chat panel — header + virtualized message list + composer.\n * Drop this into any layout and you get a complete chat experience.\n */\nimport type { CSSProperties, ReactNode } from \"react\";\nimport { TooltipProvider } from \"../ui/tooltip.js\";\nimport { ChatHeader } from \"./ChatHeader.js\";\nimport { ChatComposer } from \"./ChatComposer.js\";\nimport { MessageList } from \"./MessageList.js\";\nimport { cn } from \"../../lib/utils.js\";\nimport type { ChatConfig } from \"../../types/chat.js\";\nimport { ChatProvider, useOptionalChat } from \"./ChatProvider.js\";\n\nexport interface ChatPanelProps {\n /** Inline config. Mutate at runtime via `useChat().updateConfig`. */\n config: ChatConfig;\n /** Layout. `panel` (default) is a card; `floating` is a fixed corner widget. */\n layout?: \"panel\" | \"floating\" | \"fullpage\";\n /** Override the default header render. */\n renderHeader?: () => ReactNode;\n /** Override the default footer render (above the composer). */\n renderFooter?: () => ReactNode;\n /** Extra className on the outer container. */\n className?: string;\n /** Extra className on the inner content wrapper of both the message list\n * and composer (merged over the default `max-w-3xl` via tailwind-merge).\n * Use this to let the conversation use more horizontal space in wide\n * layouts, e.g. `contentClassName=\"max-w-5xl\"`. */\n contentClassName?: string;\n /** Extra style. */\n style?: CSSProperties;\n /** Hide the header entirely. */\n hideHeader?: boolean;\n /** Hide the composer entirely (render a read-only viewer). */\n hideComposer?: boolean;\n}\n\n/**\n * One-shot: ChatProvider + TooltipProvider + layout shell + Header +\n * MessageList + Composer. For full control, compose the primitives\n * yourself and only wrap with <ChatProvider config={…} />.\n */\nexport function ChatPanel(props: ChatPanelProps): ReactNode {\n const {\n config,\n layout = \"panel\",\n renderHeader,\n renderFooter,\n className,\n contentClassName,\n style,\n hideHeader = false,\n hideComposer = false,\n } = props;\n\n const containerClasses =\n layout === \"floating\"\n ? \"fixed bottom-5 right-5 z-40 flex w-[min(420px,calc(100vw-2.5rem))] h-[min(660px,calc(100vh-2.5rem))] flex-col overflow-hidden rounded-2xl surface-elevated app-mesh\"\n : layout === \"fullpage\"\n ? \"flex h-full w-full flex-col app-mesh\"\n : \"flex h-full w-full flex-col overflow-hidden rounded-2xl surface-elevated app-mesh\";\n\n // If a parent already provided a ChatProvider (we are nested), use it\n // and skip the internal one — otherwise the form mutates the outer\n // engine but the header/list/composer inside this panel read from the\n // inner engine, and the two would silently diverge. When there's no\n // parent provider we create one so the panel works standalone too.\n const outer = useOptionalChat();\n const tree = (\n <TooltipProvider delayDuration={200}>\n <ChatSurface\n layout={layout}\n className={className}\n style={style}\n renderHeader={renderHeader}\n renderFooter={renderFooter}\n contentClassName={contentClassName}\n hideHeader={hideHeader}\n hideComposer={hideComposer}\n />\n </TooltipProvider>\n );\n if (outer) return tree;\n return <ChatProvider config={config}>{tree}</ChatProvider>;\n}\n\n/**\n * ChatSurface — the inner panel tree. Reads `useOptionalChat` so it can\n * apply density/theme/accent/font CSS hooks to its root div based on the\n * active config. Lives in the same file as ChatPanel because it has no\n * value as a standalone component.\n */\nfunction ChatSurface({\n layout,\n className,\n style,\n renderHeader,\n renderFooter,\n contentClassName,\n hideHeader,\n hideComposer,\n}: {\n layout: \"panel\" | \"floating\" | \"fullpage\";\n className?: string;\n style?: CSSProperties;\n renderHeader?: () => ReactNode;\n renderFooter?: () => ReactNode;\n contentClassName?: string;\n hideHeader: boolean;\n hideComposer: boolean;\n}) {\n const chat = useOptionalChat();\n const ui = chat?.config.ui ?? {};\n const density = ui.density ?? \"comfortable\";\n const theme = ui.theme ?? \"system\";\n const accentColor = ui.accentColor ?? \"\";\n const fontFamily = ui.fontFamily ?? \"\";\n\n const containerClasses =\n layout === \"floating\"\n ? \"fixed bottom-5 right-5 z-40 flex w-[min(420px,calc(100vw-2.5rem))] h-[min(660px,calc(100vh-2.5rem))] flex-col overflow-hidden rounded-2xl surface-elevated app-mesh\"\n : layout === \"fullpage\"\n ? \"flex h-full w-full flex-col app-mesh\"\n : \"flex h-full w-full flex-col overflow-hidden rounded-2xl surface-elevated app-mesh\";\n\n const inlineVars: Record<string, string> = {};\n if (accentColor) inlineVars[\"--chat-accent\"] = accentColor;\n if (fontFamily) inlineVars[\"--chat-font-family\"] = fontFamily;\n\n return (\n <div\n className={cn(containerClasses, className)}\n style={{ ...style, ...inlineVars } as CSSProperties}\n data-density={density}\n data-theme={theme}\n >\n {renderHeader ? (\n renderHeader()\n ) : hideHeader ? null : (\n <ChatHeader />\n )}\n <MessageList contentClassName={contentClassName} />\n {renderFooter ? renderFooter() : null}\n {hideComposer ? null : <ChatComposer contentClassName={contentClassName} />}\n </div>\n );\n}\n"],"names":["buttonVariants","cva","Button","forwardRef","className","variant","size","asChild","props","ref","jsx","Slot","cn","Input","type","Textarea","Card","CardHeader","CardTitle","CardDescription","CardContent","CardFooter","ScrollArea","children","jsxs","ScrollAreaPrimitive","ScrollBar","orientation","avatarClasses","avatarImageClasses","avatarFallbackClasses","avatarLetter","name","s","avatarHue","seed","text","hash","i","avatarForeground","AvatarRoot","AvatarPrimitive","AvatarImage","AvatarFallback","DropdownMenu","DropdownMenuPrimitive","DropdownMenuTrigger","DropdownMenuGroup","DropdownMenuPortal","DropdownMenuSub","DropdownMenuRadioGroup","DropdownMenuContent","sideOffset","DropdownMenuItem","inset","DropdownMenuLabel","DropdownMenuSeparator","DropdownMenuCheckboxItem","checked","Popover","PopoverPrimitive","PopoverTrigger","PopoverAnchor","PopoverContent","align","TooltipProvider","TooltipPrimitive","Tooltip","TooltipTrigger","TooltipContent","Switch","SwitchPrimitive","Dialog","DialogPrimitive","DialogTrigger","DialogPortal","DialogClose","DialogOverlay","dialogContentClasses","DialogContent","X","dialogHeaderClasses","DialogHeader","dialogFooterClasses","DialogFooter","dialogTitleClasses","DialogTitle","dialogDescriptionClasses","DialogDescription","Separator","decorative","SeparatorPrimitive","badgeVariants","Badge","Tabs","TabsPrimitive","TabsList","TabsTrigger","TabsContent","Select","SelectPrimitive","SelectGroup","SelectValue","SelectTrigger","React","ChevronDown","SelectScrollUpButton","ChevronUp","SelectScrollDownButton","SelectContent","position","SelectLabel","SelectItem","Check","SelectSeparator","labelVariants","Label","LabelPrimitive","Checkbox","CheckboxPrimitive","Collapsible","CollapsiblePrimitive","CollapsibleTrigger","CollapsibleContent","TONES","EMPTY_DRAFT","toDraft","a","AgentManager","open","onOpenChange","activeAgentId","onApply","startInCreate","agents","setAgents","useState","view","setView","draft","setDraft","refresh","listAgents","useEffect","startCreate","startEdit","canSave","ListView","id","duplicateAgent","removeAgent","EditView","saved","saveAgent","onCreate","onEdit","onDuplicate","onDelete","Fragment","active","IconBtn","Copy","Pencil","Trash2","Plus","onBack","onSave","set","k","v","ArrowLeft","Field","e","t","label","hint","destructive","onClick","STORAGE_KEY","getInitialTheme","stored","applyTheme","theme","root","ThemeToggle","setTheme","initial","toggle","useCallback","prev","next","isDark","Sun","Moon","ChatHeader","chat","useChat","cfg","ui","agentsOpen","setAgentsOpen","docsOpen","setDocsOpen","managerOpen","setManagerOpen","managerCreate","setManagerCreate","setActiveAgent","getActiveAgentId","activeAgent","showModelSelector","showDocumentPicker","showToolCalls","enableConversationHistory","applyAgent","agent","setActiveAgentId","openManager","create","toggleDoc","doc","current","d","builtInDocs","docCount","conversations","Sparkles","Settings2","FileText","x","MessageSquarePlus","History","c","relativeTime","Wrench","MoreHorizontal","ts","diff","min","hr","day","getCtor","useVoiceInput","options","ctorRef","useRef","instanceRef","supported","setSupported","listening","setListening","error","setError","transcript","setTranscript","ctor","start","inst","event","buffer","res","isFinal","message","err","stop","KINDS","p","modelsToText","ProviderManager","activeProviderId","providers","setProviders","listProviders","duplicateProvider","removeProvider","resetProviders","saveProvider","parseModelsText","onReset","others","SectionLabel","ProviderRow","RotateCcw","hostLabel","baseUrl","attachmentVariants","Attachment","state","attachmentMediaVariants","AttachmentMedia","AttachmentContent","AttachmentTitle","AttachmentDescription","AttachmentActions","AttachmentAction","AttachmentTrigger","AttachmentGroup","iconFor","mime","FileType","FileJson","FileCode","FileIcon","shortType","AttachmentPreview","att","onRemove","isImage","Icon","formatBytes","MessageInput","onSend","streaming","disabled","renderSendButton","contentClassName","setText","attachments","setAttachments","uploadingCount","setUploadingCount","fileError","setFileError","fileErrorTimerRef","flashFileError","msg","dragOver","setDragOver","fileInputRef","formRef","textareaRef","lastHeightRef","MAX_TEXTAREA_HEIGHT","useLayoutEffect","el","isStreaming","canSend","enableFileUpload","enableVoiceInput","voice","sep","providerMgrOpen","setProviderMgrOpen","providerMgrCreate","setProviderMgrCreate","setActiveProvider","getActiveProviderId","applyProvider","profile","model","effectiveKey","profileToConfig","setActiveProviderId","submit","onKeyDown","onFiles","files","list","maxMb","acceptedTypes","oversized","f","rejected","filtered","filteredByType","mimeRejected","reasons","n","atts","filesToAttachments","onFileInput","onDrop","onDragOver","removeAttachment","openProviderMgr","_","Loader2","Paperclip","MicOff","Mic","ModelSwitcher","Square","Send","currentModelId","onPick","onManage","setOpen","filter","setFilter","useMemo","groups","m","g","provider","models","BubbleGroup","bubbleVariants","Bubble","BubbleContent","bubbleReactionsVariants","BubbleReactions","side","MessageGroup","Message","MessageAvatar","MessageContent","MessageHeader","MessageFooter","ScrollerStore","listener","partial","l","VisibilityContext","useScrollerContext","ctx","MessageScrollerProvider","autoScroll","defaultScrollPosition","scrollEdgeThreshold","contentSignal","stateStoreRef","messagesRef","initialScrollDoneRef","registerMessage","scrollToIndex","index","opts","vp","item","top","target","scrollToEnd","scrollToStart","scrollToMessage","idx","store","scrollToEndRef","raf","ctxValue","useMessageScroller","useMessageScrollerScrollable","stateStore","useMessageScrollerVisibility","cachedRef","atEnd","atStart","Root","rest","Viewport","onScroll","internalRef","setRefs","node","update","ro","Content","lastTopEdgeRef","previousChildrenRef","prevChildren","finalHeight","finalDelta","sample","Item","scrollAnchor","generatedId","itemId","direction","render","isEnd","isActive","handleClick","MessageScroller","MessageScrollerPrimitive","MessageScrollerViewport","MessageScrollerContent","MessageScrollerItem","MessageScrollerButton","ArrowDownIcon","markerVariants","Marker","MarkerIcon","MarkerContent","CopyButton","getText","copied","setCopied","nodeToText","typesetClassName","typeset","presetClass","typesetInlineStyle","vars","Markdown","memo","enableCodeHighlight","enableCopyButtons","containerClass","containerStyle","rehypePlugins","rehypeRaw","rehypeHighlight","ReactMarkdown","remarkGfm","href","src","alt","cls","lang","extractLang","child","ReasoningPanel","reasoning","Lightbulb","ChevronRight","splitReasoning","content","think","answer","_m","inner","DEFAULT_SUGGESTIONS","MessageList","messages","lastMessage","WelcomeScreen","MessageItem","ArrowDown","greeting","suggestions","editing","setEditing","isError","isUser","bubbleVariantForRole","raw","extractMessageText","displayText","showThinking","AvatarFor","MessageEditor","ThinkingDots","MessageBody","tc","AlertTriangle","ErrorCard","MessageStats","MessageActions","copyText","showTimestamp","showActions","showRegenerate","showEdit","isAssistant","copy","btn","formatTime","tokens","estimateTokens","durMs","secs","tps","Bot","Gauge","Hash","Clock","onCancel","value","setValue","chatCtx","useOptionalChat","truncate","humanizeError","KeyRound","WifiOff","ServerCrash","onRetry","title","body","technical","role","status","User","ChatPanel","config","layout","renderHeader","renderFooter","style","hideHeader","hideComposer","outer","tree","ChatSurface","ChatProvider","density","accentColor","fontFamily","containerClasses","inlineVars","ChatComposer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAMA,KAAiBC;AAAA,EACrB;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,SAAS;AAAA,QACP,SAAS;AAAA,QACT,aACE;AAAA,QACF,SACE;AAAA,QACF,WACE;AAAA,QACF,OAAO;AAAA,QACP,MAAM;AAAA,MAAA;AAAA,MAER,MAAM;AAAA,QACJ,SAAS;AAAA,QACT,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,WAAW;AAAA,MAAA;AAAA,IACb;AAAA,IAEF,iBAAiB;AAAA,MACf,SAAS;AAAA,MACT,MAAM;AAAA,IAAA;AAAA,EACR;AAEJ,GAQMC,IAASC;AAAA,EACb,CAAC,EAAE,WAAAC,GAAW,SAAAC,GAAS,MAAAC,GAAM,SAAAC,IAAU,IAAO,GAAGC,EAAA,GAASC,MAGtD,gBAAAC;AAAA,IAFWH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