profclaw 2.0.0 → 2.3.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 (477) hide show
  1. package/.env.example +14 -2
  2. package/CHANGELOG.md +37 -0
  3. package/CONTRIBUTING.md +20 -0
  4. package/Dockerfile +39 -23
  5. package/README.md +174 -40
  6. package/dist/agents/agent-summary.d.ts +44 -0
  7. package/dist/agents/agent-summary.js +176 -0
  8. package/dist/agents/auto-memory.d.ts +59 -0
  9. package/dist/agents/auto-memory.js +310 -0
  10. package/dist/agents/checkpoint-manager.d.ts +76 -0
  11. package/dist/agents/checkpoint-manager.js +156 -0
  12. package/dist/agents/circuit-breaker.d.ts +54 -0
  13. package/dist/agents/circuit-breaker.js +153 -0
  14. package/dist/agents/context-compactor.d.ts +70 -0
  15. package/dist/agents/context-compactor.js +361 -0
  16. package/dist/agents/conversation-branch.d.ts +55 -0
  17. package/dist/agents/conversation-branch.js +115 -0
  18. package/dist/agents/error-recovery.d.ts +44 -0
  19. package/dist/agents/error-recovery.js +197 -0
  20. package/dist/agents/events.d.ts +76 -0
  21. package/dist/agents/events.js +8 -0
  22. package/dist/agents/executor.d.ts +35 -1
  23. package/dist/agents/executor.js +573 -124
  24. package/dist/agents/file-snapshots.d.ts +72 -0
  25. package/dist/agents/file-snapshots.js +182 -0
  26. package/dist/agents/index.d.ts +2 -0
  27. package/dist/agents/orchestrator.d.ts +183 -0
  28. package/dist/agents/orchestrator.js +495 -0
  29. package/dist/agents/permissions.d.ts +63 -0
  30. package/dist/agents/permissions.js +138 -0
  31. package/dist/agents/plan-mode.d.ts +71 -0
  32. package/dist/agents/plan-mode.js +186 -0
  33. package/dist/agents/prompt-suggestions.d.ts +33 -0
  34. package/dist/agents/prompt-suggestions.js +208 -0
  35. package/dist/agents/rate-limit-monitor.d.ts +56 -0
  36. package/dist/agents/rate-limit-monitor.js +224 -0
  37. package/dist/agents/result-store.d.ts +37 -0
  38. package/dist/agents/result-store.js +104 -0
  39. package/dist/agents/session-diff.d.ts +43 -0
  40. package/dist/agents/session-diff.js +258 -0
  41. package/dist/agents/tool-loader.d.ts +65 -0
  42. package/dist/agents/tool-loader.js +273 -0
  43. package/dist/agents/transcript.d.ts +96 -0
  44. package/dist/agents/transcript.js +267 -0
  45. package/dist/agents/worktree-manager.d.ts +80 -0
  46. package/dist/agents/worktree-manager.js +203 -0
  47. package/dist/auth/middleware.js +14 -0
  48. package/dist/chat/agentic-executor.d.ts +7 -0
  49. package/dist/chat/agentic-executor.js +253 -30
  50. package/dist/chat/conversations.d.ts +2 -0
  51. package/dist/chat/conversations.js +8 -0
  52. package/dist/chat/execution/executor.d.ts +8 -0
  53. package/dist/chat/execution/executor.js +157 -103
  54. package/dist/chat/execution/index.js +5 -1
  55. package/dist/chat/execution/tool-router.js +40 -14
  56. package/dist/chat/execution/tools/canvas.d.ts +2 -2
  57. package/dist/chat/execution/tools/code-tools.d.ts +66 -0
  58. package/dist/chat/execution/tools/code-tools.js +353 -0
  59. package/dist/chat/execution/tools/complete-task.d.ts +2 -2
  60. package/dist/chat/execution/tools/cron-tool.d.ts +26 -10
  61. package/dist/chat/execution/tools/cron-tool.js +48 -3
  62. package/dist/chat/execution/tools/decompose-task.d.ts +58 -0
  63. package/dist/chat/execution/tools/decompose-task.js +166 -0
  64. package/dist/chat/execution/tools/exec.d.ts +5 -2
  65. package/dist/chat/execution/tools/exec.js +294 -155
  66. package/dist/chat/execution/tools/feed-tools.d.ts +77 -0
  67. package/dist/chat/execution/tools/feed-tools.js +142 -0
  68. package/dist/chat/execution/tools/file-ops.d.ts +1 -1
  69. package/dist/chat/execution/tools/github.d.ts +2 -2
  70. package/dist/chat/execution/tools/index.d.ts +14 -2
  71. package/dist/chat/execution/tools/index.js +86 -12
  72. package/dist/chat/execution/tools/integrations.d.ts +8 -8
  73. package/dist/chat/execution/tools/multi-patch.d.ts +53 -0
  74. package/dist/chat/execution/tools/multi-patch.js +373 -0
  75. package/dist/chat/execution/tools/openai-image-gen.d.ts +2 -2
  76. package/dist/chat/execution/tools/plan-tools.d.ts +80 -0
  77. package/dist/chat/execution/tools/plan-tools.js +134 -0
  78. package/dist/chat/execution/tools/profclaw-ops.d.ts +6 -6
  79. package/dist/chat/execution/tools/repl-tool.d.ts +46 -0
  80. package/dist/chat/execution/tools/repl-tool.js +207 -0
  81. package/dist/chat/execution/tools/sessions-send.d.ts +2 -2
  82. package/dist/chat/execution/tools/slack-actions.d.ts +2 -2
  83. package/dist/chat/execution/tools/system.d.ts +4 -4
  84. package/dist/chat/execution/tools/todo-tool.d.ts +72 -0
  85. package/dist/chat/execution/tools/todo-tool.js +152 -0
  86. package/dist/chat/execution/tools/tool-search.d.ts +50 -0
  87. package/dist/chat/execution/tools/tool-search.js +155 -0
  88. package/dist/chat/execution/types.d.ts +21 -14
  89. package/dist/chat/execution/workflows/executor.d.ts +11 -0
  90. package/dist/chat/execution/workflows/executor.js +99 -1
  91. package/dist/chat/execution/workflows/types.d.ts +35 -2
  92. package/dist/chat/format/index.d.ts +1 -0
  93. package/dist/chat/format/index.js +1 -0
  94. package/dist/chat/format/markdown-convert.d.ts +23 -0
  95. package/dist/chat/format/markdown-convert.js +149 -0
  96. package/dist/chat/index.d.ts +1 -1
  97. package/dist/chat/index.js +1 -1
  98. package/dist/chat/message-handler.js +58 -6
  99. package/dist/chat/proactive/index.d.ts +62 -0
  100. package/dist/chat/proactive/index.js +147 -0
  101. package/dist/chat/prompt-adapter.js +2 -0
  102. package/dist/chat/providers/irc/index.d.ts +2 -2
  103. package/dist/chat/providers/telegram/index.d.ts +2 -0
  104. package/dist/chat/providers/telegram/index.js +21 -2
  105. package/dist/chat/system-prompts.d.ts +3 -3
  106. package/dist/chat/system-prompts.js +116 -61
  107. package/dist/chat/tools.d.ts +6 -6
  108. package/dist/cli/commands/auth.js +64 -1
  109. package/dist/cli/commands/chat.js +1327 -138
  110. package/dist/cli/commands/doctor.js +222 -16
  111. package/dist/cli/commands/history.d.ts +3 -0
  112. package/dist/cli/commands/history.js +138 -0
  113. package/dist/cli/commands/import.d.ts +44 -0
  114. package/dist/cli/commands/import.js +526 -0
  115. package/dist/cli/commands/init.d.ts +13 -0
  116. package/dist/cli/commands/init.js +381 -0
  117. package/dist/cli/commands/onboard.js +210 -30
  118. package/dist/cli/commands/plan.d.ts +13 -0
  119. package/dist/cli/commands/plan.js +184 -0
  120. package/dist/cli/commands/serve.d.ts +7 -0
  121. package/dist/cli/commands/serve.js +77 -18
  122. package/dist/cli/commands/setup.js +84 -3
  123. package/dist/cli/commands/status.js +54 -0
  124. package/dist/cli/commands/tools.js +13 -13
  125. package/dist/cli/commands/tui.js +26 -1
  126. package/dist/cli/index.js +19 -0
  127. package/dist/cli/ink/App.d.ts +13 -0
  128. package/dist/cli/ink/App.js +6 -0
  129. package/dist/cli/ink/ChatApp.d.ts +60 -0
  130. package/dist/cli/ink/ChatApp.js +325 -0
  131. package/dist/cli/ink/DashboardApp.d.ts +3 -0
  132. package/dist/cli/ink/DashboardApp.js +143 -0
  133. package/dist/cli/ink/components/AgentStatus.d.ts +17 -0
  134. package/dist/cli/ink/components/AgentStatus.js +33 -0
  135. package/dist/cli/ink/components/ChannelList.d.ts +17 -0
  136. package/dist/cli/ink/components/ChannelList.js +33 -0
  137. package/dist/cli/ink/components/ConnectionStatus.d.ts +19 -0
  138. package/dist/cli/ink/components/ConnectionStatus.js +50 -0
  139. package/dist/cli/ink/components/CostBar.d.ts +19 -0
  140. package/dist/cli/ink/components/CostBar.js +35 -0
  141. package/dist/cli/ink/components/HookStatus.d.ts +15 -0
  142. package/dist/cli/ink/components/HookStatus.js +7 -0
  143. package/dist/cli/ink/components/PermissionPrompt.d.ts +21 -0
  144. package/dist/cli/ink/components/PermissionPrompt.js +51 -0
  145. package/dist/cli/ink/components/PlanView.d.ts +23 -0
  146. package/dist/cli/ink/components/PlanView.js +26 -0
  147. package/dist/cli/ink/components/ProviderList.d.ts +16 -0
  148. package/dist/cli/ink/components/ProviderList.js +16 -0
  149. package/dist/cli/ink/components/SessionHeader.d.ts +15 -0
  150. package/dist/cli/ink/components/SessionHeader.js +15 -0
  151. package/dist/cli/ink/components/StreamingMessage.d.ts +20 -0
  152. package/dist/cli/ink/components/StreamingMessage.js +27 -0
  153. package/dist/cli/ink/components/SuggestionBar.d.ts +15 -0
  154. package/dist/cli/ink/components/SuggestionBar.js +28 -0
  155. package/dist/cli/ink/components/SystemHealth.d.ts +20 -0
  156. package/dist/cli/ink/components/SystemHealth.js +39 -0
  157. package/dist/cli/ink/components/TaskList.d.ts +17 -0
  158. package/dist/cli/ink/components/TaskList.js +59 -0
  159. package/dist/cli/ink/components/ToolCall.d.ts +17 -0
  160. package/dist/cli/ink/components/ToolCall.js +43 -0
  161. package/dist/cli/ink/index.d.ts +23 -0
  162. package/dist/cli/ink/index.js +15 -0
  163. package/dist/cli/ink/keybindings.d.ts +35 -0
  164. package/dist/cli/ink/keybindings.js +105 -0
  165. package/dist/cli/ink/markdown-renderer.d.ts +47 -0
  166. package/dist/cli/ink/markdown-renderer.js +380 -0
  167. package/dist/cli/ink/output-styles.d.ts +39 -0
  168. package/dist/cli/ink/output-styles.js +119 -0
  169. package/dist/cli/interactive/auto-serve.d.ts +38 -0
  170. package/dist/cli/interactive/auto-serve.js +209 -0
  171. package/dist/cli/interactive/index.d.ts +25 -0
  172. package/dist/cli/interactive/index.js +23 -0
  173. package/dist/cli/interactive/picker.d.ts +28 -0
  174. package/dist/cli/interactive/picker.js +153 -0
  175. package/dist/cli/interactive/renderer.d.ts +26 -0
  176. package/dist/cli/interactive/renderer.js +555 -0
  177. package/dist/cli/interactive/repl.d.ts +14 -0
  178. package/dist/cli/interactive/repl.js +1516 -0
  179. package/dist/cli/interactive/stream-client.d.ts +59 -0
  180. package/dist/cli/interactive/stream-client.js +506 -0
  181. package/dist/cli/interactive/types.d.ts +121 -0
  182. package/dist/cli/interactive/types.js +10 -0
  183. package/dist/cli/utils/api.d.ts +9 -0
  184. package/dist/cli/utils/api.js +58 -2
  185. package/dist/cron/natural-language.d.ts +54 -0
  186. package/dist/cron/natural-language.js +569 -0
  187. package/dist/cron/scheduler.d.ts +34 -4
  188. package/dist/cron/scheduler.js +141 -9
  189. package/dist/cron/templates.d.ts +1 -1
  190. package/dist/cron/templates.js +219 -0
  191. package/dist/feeds/feed-engine.d.ts +149 -0
  192. package/dist/feeds/feed-engine.js +600 -0
  193. package/dist/feeds/index.d.ts +9 -0
  194. package/dist/feeds/index.js +8 -0
  195. package/dist/gateway/router.js +6 -1
  196. package/dist/hooks/built-in/audit-log.d.ts +11 -0
  197. package/dist/hooks/built-in/audit-log.js +84 -0
  198. package/dist/hooks/built-in/cost-warning.d.ts +10 -0
  199. package/dist/hooks/built-in/cost-warning.js +59 -0
  200. package/dist/hooks/built-in/dangerous-tool.d.ts +32 -0
  201. package/dist/hooks/built-in/dangerous-tool.js +80 -0
  202. package/dist/hooks/built-in/index.d.ts +14 -0
  203. package/dist/hooks/built-in/index.js +20 -0
  204. package/dist/hooks/index.d.ts +3 -0
  205. package/dist/hooks/index.js +6 -0
  206. package/dist/hooks/loader.d.ts +17 -0
  207. package/dist/hooks/loader.js +142 -0
  208. package/dist/hooks/registry.d.ts +62 -0
  209. package/dist/hooks/registry.js +127 -0
  210. package/dist/integrations/web-search.js +6 -3
  211. package/dist/memory/index.d.ts +1 -0
  212. package/dist/memory/index.js +2 -0
  213. package/dist/memory/memory-service.js +14 -13
  214. package/dist/memory/observational.d.ts +62 -0
  215. package/dist/memory/observational.js +396 -0
  216. package/dist/middleware/content-filter.d.ts +22 -0
  217. package/dist/middleware/content-filter.js +69 -0
  218. package/dist/middleware/request-validator.d.ts +159 -0
  219. package/dist/middleware/request-validator.js +93 -0
  220. package/dist/plugins/sdk.d.ts +22 -0
  221. package/dist/plugins/sdk.js +17 -1
  222. package/dist/projects/types.d.ts +10 -10
  223. package/dist/providers/ai-sdk.d.ts +11 -0
  224. package/dist/providers/ai-sdk.js +78 -19
  225. package/dist/providers/core/models.js +67 -1
  226. package/dist/providers/core/types.d.ts +3 -0
  227. package/dist/providers/index.d.ts +1 -0
  228. package/dist/providers/index.js +1 -0
  229. package/dist/providers/smart-router.d.ts +118 -0
  230. package/dist/providers/smart-router.js +685 -0
  231. package/dist/providers/types.d.ts +16 -16
  232. package/dist/routes/agents.js +50 -0
  233. package/dist/routes/auth.js +8 -1
  234. package/dist/routes/chat.js +259 -14
  235. package/dist/routes/costs.js +32 -0
  236. package/dist/routes/cron.js +80 -5
  237. package/dist/routes/feeds.d.ts +10 -0
  238. package/dist/routes/feeds.js +168 -0
  239. package/dist/routes/mcp.js +21 -0
  240. package/dist/routes/memory.js +130 -0
  241. package/dist/routes/skills.js +129 -0
  242. package/dist/routes/teams.d.ts +9 -0
  243. package/dist/routes/teams.js +210 -0
  244. package/dist/routes/tools.js +14 -0
  245. package/dist/routes/users.js +2 -0
  246. package/dist/server/route-loader.js +3 -1
  247. package/dist/server/stream-bridge.d.ts +19 -0
  248. package/dist/server/stream-bridge.js +38 -0
  249. package/dist/server.js +310 -36
  250. package/dist/skills/marketplace.d.ts +87 -0
  251. package/dist/skills/marketplace.js +268 -0
  252. package/dist/storage/index.d.ts +14 -0
  253. package/dist/storage/index.js +64 -3
  254. package/dist/storage/schema.d.ts +4 -4
  255. package/dist/storage/schema.js +1 -1
  256. package/dist/teams/index.d.ts +110 -0
  257. package/dist/teams/index.js +365 -0
  258. package/dist/tickets/types.d.ts +39 -39
  259. package/dist/types/summary.d.ts +5 -5
  260. package/dist/utils/auto-update.d.ts +23 -0
  261. package/dist/utils/auto-update.js +157 -0
  262. package/dist/utils/offline-detect.d.ts +55 -0
  263. package/dist/utils/offline-detect.js +121 -0
  264. package/dist/utils/pid-file.d.ts +36 -0
  265. package/dist/utils/pid-file.js +125 -0
  266. package/dist/utils/prevent-sleep.d.ts +27 -0
  267. package/dist/utils/prevent-sleep.js +95 -0
  268. package/dist/utils/sanitizer.d.ts +57 -0
  269. package/dist/utils/sanitizer.js +174 -0
  270. package/docker-compose.yml +13 -137
  271. package/package.json +31 -6
  272. package/skills/deploy-cloudflare/SKILL.md +62 -0
  273. package/skills/deploy-vercel/SKILL.md +67 -0
  274. package/skills/docker-deploy/SKILL.md +158 -0
  275. package/skills/full-stack-builder/SKILL.md +92 -0
  276. package/skills/humanizer/SKILL.md +488 -0
  277. package/skills/profclaw-assistant/SKILL.md +85 -56
  278. package/ui/dist/assets/ActivityView-Da6HQ8ws.js +1 -0
  279. package/ui/dist/assets/AgentList-H58R0kX3.js +1 -0
  280. package/ui/dist/assets/AnalyticsDashboard-B28AeRsc.js +1 -0
  281. package/ui/dist/assets/AreaChart-DwLzeAQ8.js +1 -0
  282. package/ui/dist/assets/CartesianChart-piKQsTAR.js +36 -0
  283. package/ui/dist/assets/ChatView-Dbj8rxU5.js +10 -0
  284. package/ui/dist/assets/CostsDashboard-C6F5df0F.js +1 -0
  285. package/ui/dist/assets/EstimateSelect-wga0rUKX.js +1 -0
  286. package/ui/dist/assets/FeedDashboard-Ef6FEzEf.js +1 -0
  287. package/ui/dist/assets/FloatingChatbot-0yhkUeCq.js +2 -0
  288. package/ui/dist/assets/InviteCodeManagement-tUXfx4Bc.js +2 -0
  289. package/ui/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  290. package/ui/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  291. package/ui/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  292. package/ui/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  293. package/ui/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  294. package/ui/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  295. package/ui/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  296. package/ui/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  297. package/ui/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  298. package/ui/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  299. package/ui/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  300. package/ui/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  301. package/ui/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  302. package/ui/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  303. package/ui/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  304. package/ui/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  305. package/ui/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  306. package/ui/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  307. package/ui/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  308. package/ui/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  309. package/ui/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  310. package/ui/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  311. package/ui/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  312. package/ui/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  313. package/ui/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  314. package/ui/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  315. package/ui/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  316. package/ui/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  317. package/ui/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  318. package/ui/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  319. package/ui/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  320. package/ui/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  321. package/ui/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  322. package/ui/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  323. package/ui/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  324. package/ui/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  325. package/ui/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  326. package/ui/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  327. package/ui/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  328. package/ui/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  329. package/ui/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  330. package/ui/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  331. package/ui/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  332. package/ui/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  333. package/ui/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  334. package/ui/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  335. package/ui/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  336. package/ui/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  337. package/ui/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  338. package/ui/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  339. package/ui/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  340. package/ui/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  341. package/ui/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  342. package/ui/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  343. package/ui/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  344. package/ui/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  345. package/ui/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  346. package/ui/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  347. package/ui/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  348. package/ui/dist/assets/MarketplacePage-DGrLtolR.js +1 -0
  349. package/ui/dist/assets/{ProjectDetail--gPfvATB.js → ProjectDetail-BgWvA6UP.js} +2 -2
  350. package/ui/dist/assets/ProjectIcon-TDuliqwg.js +1 -0
  351. package/ui/dist/assets/ProjectList-DXgM4187.js +1 -0
  352. package/ui/dist/assets/{Settings-1kaf7VHE.js → Settings-xA8Zhi3p.js} +3 -3
  353. package/ui/dist/assets/StatusIndicator-B8vfFAxg.js +1 -0
  354. package/ui/dist/assets/{SummaryDetail-DV3AmONk.js → SummaryDetail-eedRfTtF.js} +2 -2
  355. package/ui/dist/assets/SummaryList-CLNX2P84.js +1 -0
  356. package/ui/dist/assets/TaskDetail-BtWclNiR.js +1 -0
  357. package/ui/dist/assets/TaskList-JjODAgSc.js +1 -0
  358. package/ui/dist/assets/TeamsPage-CBK5iAyx.js +1 -0
  359. package/ui/dist/assets/TicketBoard-C9aJNNYp.js +1 -0
  360. package/ui/dist/assets/TicketDetail-CV5JmL31.js +1 -0
  361. package/ui/dist/assets/TicketList-68V4lzUz.js +1 -0
  362. package/ui/dist/assets/UserManagement-DKTb6UpE.js +2 -0
  363. package/ui/dist/assets/ViewSwitcher-BvdQht2Y.js +1 -0
  364. package/ui/dist/assets/alert-dialog-O6qBOv_f.js +1 -0
  365. package/ui/dist/assets/{archive-BsLa7brF.js → archive-CX7UvZpf.js} +1 -1
  366. package/ui/dist/assets/badge-BbfnwDJP.js +1 -0
  367. package/ui/dist/assets/{bug-CmZI7jqM.js → bug-3WX0394-.js} +1 -1
  368. package/ui/dist/assets/{calendar-Bf0t2B82.js → calendar-buq77TaS.js} +1 -1
  369. package/ui/dist/assets/{chevron-up-CoUsOvZj.js → chevron-up-4ymsBJRo.js} +1 -1
  370. package/ui/dist/assets/{circle-x-Dgw11LgT.js → circle-x-ByXtwR6Y.js} +1 -1
  371. package/ui/dist/assets/constants-CVdDh7p0.js +1 -0
  372. package/ui/dist/assets/{cpu-DiPMQICV.js → cpu-CiuoCeDY.js} +1 -1
  373. package/ui/dist/assets/{database-BwTfupDi.js → database-BWXSBg5a.js} +1 -1
  374. package/ui/dist/assets/dialog-lDg4NvMV.js +1 -0
  375. package/ui/dist/assets/dollar-sign-Dmijd6DP.js +1 -0
  376. package/ui/dist/assets/{ellipsis-UJx4Xnf6.js → ellipsis-vT-5SVIp.js} +1 -1
  377. package/ui/dist/assets/{ellipsis-vertical-DoULYEKn.js → ellipsis-vertical-B4tAX_bL.js} +1 -1
  378. package/ui/dist/assets/feature-markdown-DBo5Q7uq.js +289 -0
  379. package/ui/dist/assets/{file-code-B2UrJLwi.js → file-code-ChOWdKXf.js} +1 -1
  380. package/ui/dist/assets/{folder-open-BJi577JH.js → folder-open-CkOUbIiP.js} +1 -1
  381. package/ui/dist/assets/{funnel-PkaD_HSR.js → funnel-uZkoSPP-.js} +1 -1
  382. package/ui/dist/assets/{git-branch-C_K30am0.js → git-branch-CwvUxj7C.js} +1 -1
  383. package/ui/dist/assets/{git-commit-horizontal-IT6ecxWQ.js → git-commit-horizontal-lxPzCvhD.js} +1 -1
  384. package/ui/dist/assets/{globe-f-jjCa_g.js → globe-D_WpJdsj.js} +1 -1
  385. package/ui/dist/assets/{hash-DNEv8Elo.js → hash-CA0hJ7vh.js} +1 -1
  386. package/ui/dist/assets/{history-BQSBo_1Q.js → history-CEWMLELs.js} +1 -1
  387. package/ui/dist/assets/inbox-ehtOptTV.js +1 -0
  388. package/ui/dist/assets/{index-nS3EErDg.js → index-C1rhbml4.js} +3 -3
  389. package/ui/dist/assets/index-CR8gfCHv.js +1 -0
  390. package/ui/dist/assets/index-DVXMpWai.js +1 -0
  391. package/ui/dist/assets/index-DaDJMM2v.js +1 -0
  392. package/ui/dist/assets/index-Djdq_0xu.js +1 -0
  393. package/ui/dist/assets/index-M46Gcb8K.css +1 -0
  394. package/ui/dist/assets/index-sEBN7w8J.js +109 -0
  395. package/ui/dist/assets/layers-C6Mhf8Nk.js +1 -0
  396. package/ui/dist/assets/{layout-dashboard-CcKt1hXw.js → layout-dashboard-BRUM0kpT.js} +1 -1
  397. package/ui/dist/assets/{lightbulb-Jhp7FvbU.js → lightbulb-CN2q1O5l.js} +1 -1
  398. package/ui/dist/assets/{link-2-DdO7ostF.js → link-2-CC4E28yJ.js} +1 -1
  399. package/ui/dist/assets/markdown-renderer-C6ENbB0u.js +10 -0
  400. package/ui/dist/assets/markdown-renderer-CfVKi3_s.css +1 -0
  401. package/ui/dist/assets/{message-square-CBgH65X7.js → message-square-Bbb241am.js} +1 -1
  402. package/ui/dist/assets/package-CwT3IzFx.js +1 -0
  403. package/ui/dist/assets/{pencil-CYXCEPQh.js → pencil-CDmiHzoj.js} +1 -1
  404. package/ui/dist/assets/{play-d1ONaH0-.js → play-tjy5jMQX.js} +1 -1
  405. package/ui/dist/assets/popover-CFHZf3pE.js +1 -0
  406. package/ui/dist/assets/progress-BboUHuLf.js +1 -0
  407. package/ui/dist/assets/{rocket-DhvUetsk.js → rocket--8ZHgdXJ.js} +1 -1
  408. package/ui/dist/assets/select-n108rXny.js +1 -0
  409. package/ui/dist/assets/{send-P0r5D7td.js → send-Cu7MR2Qh.js} +1 -1
  410. package/ui/dist/assets/server-DmodxZp-.js +1 -0
  411. package/ui/dist/assets/{settings-2-ocj5uHGx.js → settings-2-CkRNqkxj.js} +1 -1
  412. package/ui/dist/assets/sheet-7aUJkyzU.js +1 -0
  413. package/ui/dist/assets/{shield-check-DfVdE34l.js → shield-check-ViI3nMKE.js} +1 -1
  414. package/ui/dist/assets/{shield-off-8l0J6R-8.js → shield-off-DN3tagkn.js} +1 -1
  415. package/ui/dist/assets/skeleton-C0E1Nfro.js +1 -0
  416. package/ui/dist/assets/{smartphone-77_g3SQn.js → smartphone-5FghiXpA.js} +1 -1
  417. package/ui/dist/assets/{square-Ckzsr3Rn.js → square-DiNSx8K7.js} +1 -1
  418. package/ui/dist/assets/star-DhdFVidS.js +1 -0
  419. package/ui/dist/assets/switch-CIgVbZqQ.js +1 -0
  420. package/ui/dist/assets/table-BC56FVMV.js +1 -0
  421. package/ui/dist/assets/{tag-C35mgoEv.js → tag-CH_vQliw.js} +1 -1
  422. package/ui/dist/assets/textarea-CxDiKFXZ.js +1 -0
  423. package/ui/dist/assets/{timer-DHJBS2w1.js → timer-CdGVTb60.js} +1 -1
  424. package/ui/dist/assets/tooltip-BuW9A5UO.js +1 -0
  425. package/ui/dist/assets/{trash-2-keO5tKPE.js → trash-2-CucZJL0N.js} +1 -1
  426. package/ui/dist/assets/trending-down-BCezC1z2.js +1 -0
  427. package/ui/dist/assets/{trending-up-BBv8KbrY.js → trending-up-C5OYX2k2.js} +1 -1
  428. package/ui/dist/assets/vendor-query-C0p7b53x.js +4 -0
  429. package/ui/dist/assets/vendor-react-Mc5_kfYG.js +12 -0
  430. package/ui/dist/assets/vendor-ui-CXPAUBFv.js +51 -0
  431. package/ui/dist/assets/{wand-sparkles-BusQ52ZK.js → wand-sparkles-BaH6pJnc.js} +1 -1
  432. package/ui/dist/assets/{wrench-02YaOSiK.js → wrench-CjxjP6ok.js} +1 -1
  433. package/ui/dist/index.html +5 -2
  434. package/ui/dist/assets/ActivityView-BeshZXmE.js +0 -1
  435. package/ui/dist/assets/AgentList-QVHeldPi.js +0 -1
  436. package/ui/dist/assets/AnalyticsDashboard-C9R97dXE.js +0 -1
  437. package/ui/dist/assets/AreaChart-B73gaiVQ.js +0 -1
  438. package/ui/dist/assets/CartesianChart-CXYL2R-A.js +0 -36
  439. package/ui/dist/assets/ChatView-qjZErlrp.js +0 -10
  440. package/ui/dist/assets/CostsDashboard-O4DCLy1i.js +0 -1
  441. package/ui/dist/assets/EstimateSelect-1hQf4Osk.js +0 -1
  442. package/ui/dist/assets/FloatingChatbot-BZBzrJxd.js +0 -2
  443. package/ui/dist/assets/InviteCodeManagement-LEoGqYeA.js +0 -2
  444. package/ui/dist/assets/ProjectIcon-Chd_ofsw.js +0 -1
  445. package/ui/dist/assets/ProjectList-BvUfVB6c.js +0 -4
  446. package/ui/dist/assets/StatusIndicator-pRfkNcdV.js +0 -1
  447. package/ui/dist/assets/SummaryList-B6kXiTxL.js +0 -1
  448. package/ui/dist/assets/TaskDetail-CV6CzbOS.js +0 -1
  449. package/ui/dist/assets/TaskList-DL7brQKd.js +0 -1
  450. package/ui/dist/assets/TicketBoard-CrkkFj7C.js +0 -1
  451. package/ui/dist/assets/TicketDetail-hnnYclpD.js +0 -1
  452. package/ui/dist/assets/TicketList-CsDAyQCL.js +0 -1
  453. package/ui/dist/assets/UserManagement-BGFQyTSr.js +0 -2
  454. package/ui/dist/assets/ViewSwitcher-CnL0OqA8.js +0 -1
  455. package/ui/dist/assets/alert-dialog-SKM6Gjz4.js +0 -7
  456. package/ui/dist/assets/badge-CVHH1a-v.js +0 -1
  457. package/ui/dist/assets/brain-6o_RHVpe.js +0 -1
  458. package/ui/dist/assets/constants-Q5Zivl-a.js +0 -1
  459. package/ui/dist/assets/dialog-BUqN9Psj.js +0 -1
  460. package/ui/dist/assets/index-BUmnwPQr.js +0 -1
  461. package/ui/dist/assets/index-BfF5G4Cw.js +0 -1
  462. package/ui/dist/assets/index-C8N375c2.js +0 -1
  463. package/ui/dist/assets/index-CuxnqVVz.css +0 -1
  464. package/ui/dist/assets/index-CzMM3QOk.js +0 -1
  465. package/ui/dist/assets/index-lJlNPFVJ.js +0 -67
  466. package/ui/dist/assets/layers-jFqVrWMD.js +0 -1
  467. package/ui/dist/assets/markdown-renderer-n1ToC4XQ.js +0 -36
  468. package/ui/dist/assets/popover-CrmZgoWu.js +0 -1
  469. package/ui/dist/assets/progress-uv4SPkL5.js +0 -1
  470. package/ui/dist/assets/select-CeQ8AHGy.js +0 -1
  471. package/ui/dist/assets/server-CVHTZB72.js +0 -1
  472. package/ui/dist/assets/sheet-DuQExSho.js +0 -1
  473. package/ui/dist/assets/skeleton-TFiFJ3nB.js +0 -1
  474. package/ui/dist/assets/switch-CAePkd6k.js +0 -1
  475. package/ui/dist/assets/table-ZjAZ7hkt.js +0 -1
  476. package/ui/dist/assets/textarea-DsVPnSgR.js +0 -1
  477. package/ui/dist/assets/tooltip-BYmQ331W.js +0 -1
@@ -0,0 +1,10 @@
1
+ import{j as e,L as _s,r as i,u as As,e as Ms}from"./vendor-react-Mc5_kfYG.js";import{b as oe,u as qt,c as Ie}from"./vendor-query-C0p7b53x.js";import{c as re,S as Ue,G as Ke,h as m,ab as Nt,i as V,D as Rs,o as Es,p as Ds,q as Ye,ah as kt,V as Ls,ai as Gt,B as Me,Z as Ht,a as it,F as Xe,u as le,g as ie,T as Qe,H as Ze,n as Ne,Y as ke,w as lt,x as ct,y as dt,j as Ce,aj as Jt,R as ut,ag as Ps,X as mt,a6 as Os,L as ce,ak as Ct,al as St,I as $s,P as Tt,am as Fs,an as zs,ao as Vs,ap as Us,aq as Ks,ar as qs,as as Gs,at as Hs,au as Js,ad as Bs,O as Ws,Q as Ys,E as Qs,m as xt,C as Re,K as ht,z as Xs,k as Q,t as F}from"./index-sEBN7w8J.js";import{S as et,a as tt,b as st,c as rt,d as _e}from"./select-n108rXny.js";import{T as ue,a as me,b as xe}from"./tooltip-BuW9A5UO.js";import{B as pt}from"./badge-BbfnwDJP.js";import{C as Zs}from"./cpu-CiuoCeDY.js";import{M as er,a as Bt,b as Ae}from"./markdown-renderer-C6ENbB0u.js";import{H as Fe}from"./history-CEWMLELs.js";import{c as tr,C as It,e as sr,M as Wt,V as rr,b as ar,T as nr,S as Yt}from"./constants-CVdDh7p0.js";import{S as at}from"./settings-2-CkRNqkxj.js";import{T as ze}from"./trash-2-CucZJL0N.js";import{C as or,R as ir}from"./rocket--8ZHgdXJ.js";import{C as Qt}from"./smartphone-5FghiXpA.js";import{a as lr,B as Xt}from"./bug-3WX0394-.js";import{W as qe}from"./wrench-CjxjP6ok.js";import{L as cr}from"./lightbulb-CN2q1O5l.js";import{D as nt}from"./database-BWXSBg5a.js";import{F as Z}from"./file-code-ChOWdKXf.js";import{G as ot}from"./globe-D_WpJdsj.js";import{T as dr,S as ur,a as mr,b as xr,c as hr,d as pr}from"./sheet-7aUJkyzU.js";import{G as _t}from"./git-branch-CwvUxj7C.js";import{T as gr}from"./textarea-CxDiKFXZ.js";import{S as Zt}from"./send-Cu7MR2Qh.js";import{A as fr,h as br,a as vr,b as yr,c as jr,d as wr,e as Nr,f as kr,g as Cr}from"./alert-dialog-O6qBOv_f.js";import{F as At}from"./folder-open-CkOUbIiP.js";import{D as Sr,b as Tr,c as Ir,d as _r,e as Ar}from"./dialog-lDg4NvMV.js";import{C as Ve}from"./circle-x-ByXtwR6Y.js";import{S as es}from"./shield-check-ViI3nMKE.js";import{S as Mr}from"./shield-off-DN3tagkn.js";import"./vendor-ui-CXPAUBFv.js";import"./chevron-up-4ymsBJRo.js";import"./feature-markdown-DBo5Q7uq.js";import"./defineProperty-CoXUr7_6.js";import"./tag-CH_vQliw.js";const Rr=[["path",{d:"M5 21v-6",key:"1hz6c0"}],["path",{d:"M12 21V3",key:"1lcnhd"}],["path",{d:"M19 21V9",key:"unv183"}]],Er=re("chart-no-axes-column",Rr);const Dr=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Lr=re("circle-dot",Dr);const Pr=[["path",{d:"M6 8.5a6.5 6.5 0 1 1 13 0c0 6-6 6-6 10a3.5 3.5 0 1 1-7 0",key:"1dfaln"}],["path",{d:"M15 8.5a2.5 2.5 0 0 0-5 0v1a2 2 0 1 1 0 4",key:"1qnva7"}]],Mt=re("ear",Pr);const Or=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],$r=re("folder",Or);const Fr=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]],zr=re("git-pull-request",Fr);const Vr=[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],Ur=re("image-plus",Vr);const Kr=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],qr=re("image",Kr);const Gr=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M12 8v6",key:"1ib9pf"}],["path",{d:"M9 11h6",key:"1fldmi"}]],fe=re("message-square-plus",Gr);const Hr=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M15 9.34V5a3 3 0 0 0-5.68-1.33",key:"1gzdoj"}],["path",{d:"M16.95 16.95A7 7 0 0 1 5 12v-2",key:"cqa7eg"}],["path",{d:"M18.89 13.23A7 7 0 0 0 19 12v-2",key:"16hl24"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12",key:"r2i35w"}]],Jr=re("mic-off",Hr);const Br=[["path",{d:"M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z",key:"nt11vn"}],["path",{d:"m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18",key:"15qc1e"}],["path",{d:"m2.3 2.3 7.286 7.286",key:"1wuzzi"}],["circle",{cx:"11",cy:"11",r:"2",key:"xmgehs"}]],Wr=re("pen-tool",Br),Yr={essential:8,standard:30,full:72},Qr={basic:{label:"Basic",description:"Standard instruction following, suitable for most conversational tasks.",colorClass:"bg-amber-500/15 text-amber-600 border-amber-500/25",Icon:Zs},instruction:{label:"Instruction",description:"Advanced instruction following with multi-step reasoning capabilities.",colorClass:"bg-blue-500/15 text-blue-600 border-blue-500/25",Icon:Ke},reasoning:{label:"Reasoning",description:"Full agentic reasoning with planning, reflection, and complex tool use.",colorClass:"bg-green-500/15 text-green-600 border-green-500/25",Icon:Ue}};function Xr({modelId:t,toolTier:s,capabilityLevel:a,className:n}){const r=Qr[a],l=Yr[s],{Icon:c}=r;return e.jsxs(ue,{children:[e.jsx(me,{asChild:!0,children:e.jsxs(pt,{variant:"outline",className:m("flex items-center gap-1.5 px-2 py-0.5 text-xs font-medium cursor-default select-none border",r.colorClass,n),children:[e.jsx(c,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:r.label}),e.jsx("span",{className:"opacity-60",children:"·"}),e.jsxs("span",{className:"opacity-70",children:[l," tools"]})]})}),e.jsx(xe,{side:"bottom",children:e.jsxs("div",{className:"space-y-1.5 max-w-56",children:[e.jsx("div",{className:"font-semibold text-xs",children:t}),e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:r.description}),e.jsxs("div",{className:"flex items-center gap-2 pt-0.5 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"capitalize",children:[s," tier"]}),e.jsx("span",{children:"-"}),e.jsxs("span",{children:[l," tools available"]})]})]})})]})}const Zr={bot:Me,code:Qt,"clipboard-list":or,"bar-chart-2":Er,"pen-tool":Wr};function Rt({icon:t,className:s}){if(t==="bot")return e.jsx(Gt,{className:s});const a=Zr[t]||Me;return e.jsx(a,{className:s})}function ea({currentPreset:t,presets:s,selectedPreset:a,selectedModel:n,aliases:r,providers:l,healthyProviders:c,memoryStats:d,conversationId:w,enabledPlugins:p=0,focusedView:v=!1,modelCapability:y,onPresetChange:N,onModelChange:$,onNewChat:A,onOpenHistory:I,onOpenProviderSetup:K,onClearChat:h,onExport:M,onToggleFocusedView:R}){const g=d?.stats.usagePercentage??0;return e.jsx("div",{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("div",{className:"h-9 w-9 rounded-xl glass-heavy flex items-center justify-center shrink-0 border-primary/10 shadow-lg shadow-primary/5",children:e.jsx(Ue,{className:"h-4.5 w-4.5 text-primary"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-sm font-semibold truncate",children:"Chat"}),e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[c.length>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-green-500 shrink-0"}),e.jsxs("span",{className:"truncate",children:[c.length," active"]})]}):e.jsx("button",{onClick:K,className:"text-amber-500 hover:underline truncate",children:"Configure provider"}),w&&d&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted-foreground/40",children:"·"}),e.jsxs(ue,{children:[e.jsx(me,{asChild:!0,children:e.jsxs("button",{className:"flex items-center gap-1 hover:text-foreground transition-colors","aria-label":`Context usage: ${Math.round(g)}%`,children:[e.jsx(Ke,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),e.jsx("div",{className:"w-8 h-1 bg-muted rounded-full overflow-hidden","aria-hidden":"true",children:e.jsx("div",{className:m("h-full rounded-full transition-all duration-300",g<=50&&"bg-green-500",g>50&&g<=70&&"bg-primary",g>70&&g<=90&&"bg-amber-500",g>90&&"bg-red-500"),style:{width:`${Math.min(g,100)}%`}})})]})}),e.jsx(xe,{side:"bottom",children:e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"font-medium text-sm",children:"Context Memory"}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5",children:[e.jsxs("p",{children:[d.stats.messageCount," messages · ~",d.stats.estimatedTokens.toLocaleString()," tokens"]}),e.jsxs("p",{children:["Using ",Math.round(g),"% of ",(d.stats.contextWindow/1e3).toFixed(0),"k window"]}),d.stats.needsCompaction&&e.jsx("p",{className:"text-amber-500",children:"Will compact on next message"})]})]})})]})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsxs("div",{className:"hidden sm:flex items-center bg-muted/40 rounded-xl p-0.5",children:[e.jsxs(et,{value:a,onValueChange:N,children:[e.jsxs(tt,{className:"h-7 w-auto border-0 bg-transparent shadow-none text-xs gap-1 px-2 hover:bg-muted/60 rounded-lg","aria-label":"Select chat preset",children:[e.jsx(Rt,{icon:t?.icon||"bot",className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"hidden md:inline max-w-[80px] truncate",children:e.jsx(st,{})})]}),e.jsx(rt,{className:"glass-dropdown",children:s.map(j=>e.jsx(_e,{value:j.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rt,{icon:j.icon,className:"h-4 w-4"}),e.jsx("span",{children:j.name})]})},j.id))})]}),e.jsx("div",{className:"w-px h-4 bg-border/50"}),e.jsxs(et,{value:n,onValueChange:$,children:[e.jsx(tt,{className:"h-7 w-auto border-0 bg-transparent shadow-none text-xs gap-1.5 px-2 hover:bg-muted/60 rounded-lg","aria-label":"Select AI model",children:e.jsx(st,{})}),e.jsxs(rt,{className:"glass-dropdown min-w-45",children:[(()=>{const j=new Set(l.map(P=>P.type)),u=r.filter(P=>j.has(P.provider)),T=u.filter(P=>P.provider!=="ollama").reduce((P,X)=>{const q=X.provider;return(!P[q]||X.alias.length<P[q].alias.length)&&(P[q]=X),P},{}),x=u.filter(P=>P.provider==="ollama"&&P.alias!=="local"),C=Object.entries(T).sort(([,P],[,X])=>{const q=l.find(se=>se.type===P.provider)?.healthy?1:0;return(l.find(se=>se.type===X.provider)?.healthy?1:0)-q||P.provider.localeCompare(X.provider)}),Y=l.find(P=>P.type==="ollama")?.healthy;return e.jsxs(e.Fragment,{children:[C.map(([P,X])=>{const te=l.find(se=>se.type===P)?.healthy;return e.jsx(_e,{value:X.alias,className:"py-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:m("h-1.5 w-1.5 rounded-full shrink-0",te?"bg-green-500":"bg-amber-400")}),e.jsx("span",{className:"capitalize font-medium",children:X.alias}),e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:X.provider})]})},X.alias)}),x.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-2 py-1 text-[10px] font-medium text-muted-foreground uppercase tracking-wider border-t border-border/50 mt-1 pt-1.5",children:"Local Models"}),x.map(P=>e.jsx(_e,{value:P.alias,className:"py-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:m("h-1.5 w-1.5 rounded-full shrink-0",Y?"bg-green-500":"bg-amber-400")}),e.jsx("span",{className:"capitalize font-medium",children:P.alias}),e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"Free"})]})},P.alias))]})]})})(),e.jsx("div",{className:"border-t border-border/50 mt-1 pt-1",children:e.jsxs("button",{type:"button",onClick:j=>{j.preventDefault(),j.stopPropagation(),K()},className:"w-full flex items-center gap-2 px-2 py-1.5 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/50 rounded-sm transition-colors",children:[e.jsx(Nt,{className:"h-3 w-3"}),e.jsx("span",{children:"Manage Providers..."})]})})]})]})]}),y&&e.jsx(Xr,{modelId:n,toolTier:y.toolTier,capabilityLevel:y.capabilityLevel,className:"hidden sm:flex"}),R&&e.jsxs(ue,{children:[e.jsx(me,{asChild:!0,children:e.jsx(V,{variant:"ghost",size:"icon",onClick:R,className:m("h-8 w-8 shrink-0",v&&"bg-primary/10 text-primary"),"aria-label":v?"Exit focused view":"Enter focused view","aria-pressed":v,children:v?e.jsx(er,{className:"h-4 w-4","aria-hidden":"true"}):e.jsx(Bt,{className:"h-4 w-4","aria-hidden":"true"})})}),e.jsx(xe,{children:v?"Exit focused view":"Focused view"})]}),e.jsxs(ue,{children:[e.jsx(me,{asChild:!0,children:e.jsx(V,{variant:"ghost",size:"icon",onClick:A,className:"h-8 w-8 shrink-0","aria-label":"New chat",children:e.jsx(fe,{className:"h-4 w-4","aria-hidden":"true"})})}),e.jsx(xe,{children:"New chat"})]}),e.jsxs(ue,{children:[e.jsx(me,{asChild:!0,children:e.jsx(V,{variant:"ghost",size:"icon",onClick:I,className:"h-8 w-8 shrink-0","aria-label":"View history",children:e.jsx(Fe,{className:"h-4 w-4","aria-hidden":"true"})})}),e.jsx(xe,{children:"History"})]}),e.jsxs(ue,{children:[e.jsx(me,{asChild:!0,children:e.jsx(V,{variant:"ghost",size:"icon",onClick:K,className:"h-8 w-8 shrink-0","aria-label":"Manage API keys",children:e.jsx(Nt,{className:"h-4 w-4","aria-hidden":"true"})})}),e.jsx(xe,{children:"API Keys"})]}),e.jsxs(ue,{children:[e.jsx(me,{asChild:!0,children:e.jsx(V,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0 relative",asChild:!0,"aria-label":`Plugins and Tools (${p} enabled)`,children:e.jsxs(_s,{to:"/settings/plugins",children:[e.jsx(tr,{className:"h-4 w-4","aria-hidden":"true"}),p>0&&e.jsx("span",{className:"absolute -top-0.5 -right-0.5 h-3.5 w-3.5 rounded-full bg-primary text-[9px] font-medium text-primary-foreground flex items-center justify-center","aria-hidden":"true",children:p})]})})}),e.jsx(xe,{children:"Plugins & Tools"})]}),e.jsxs(Rs,{children:[e.jsx(Es,{asChild:!0,children:e.jsx(V,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0","aria-label":"Chat settings",children:e.jsx(at,{className:"h-4 w-4","aria-hidden":"true"})})}),e.jsxs(Ds,{align:"end",className:"w-44 glass-dropdown",children:[e.jsxs(Ye,{onClick:A,children:[e.jsx(fe,{className:"h-4 w-4 mr-2"}),"New Chat"]}),M&&w&&e.jsxs(e.Fragment,{children:[e.jsx(kt,{}),e.jsxs(Ye,{onClick:M,children:[e.jsx(Ls,{className:"h-4 w-4 mr-2"}),"Export Chat"]})]}),e.jsx(kt,{}),e.jsxs(Ye,{onClick:h,className:"text-destructive focus:text-destructive",children:[e.jsx(ze,{className:"h-4 w-4 mr-2"}),"Clear Chat"]})]})]})]})]})})}const Et={urgent:"bg-red-500",critical:"bg-red-500",high:"bg-orange-500",medium:"bg-yellow-500",low:"bg-blue-400",none:"bg-muted-foreground/30"},ta={bug:Xt,feature:cr,improvement:qe,task:it,epic:Ht,story:lr,subtask:Lr},Dt={backlog:"bg-muted-foreground/10 text-muted-foreground",todo:"bg-blue-500/10 text-blue-400",in_progress:"bg-primary/10 text-primary",in_review:"bg-purple-500/10 text-purple-400",done:"bg-green-500/10 text-green-400",cancelled:"bg-red-500/10 text-red-400"};function sa(t){return t.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function Lt({ticketKey:t,title:s,status:a,type:n,priority:r,labels:l,url:c}){const d=ta[n]||it,w=Et[r]||Et.none,p=Dt[a]||Dt.backlog,v=e.jsxs("div",{className:"flex items-center gap-3 py-2.5 px-3 rounded-xl recessed-card overflow-hidden relative group/ticket",children:[e.jsx("div",{className:m("absolute left-0 top-0 bottom-0 w-1 rounded-l-xl",w)}),e.jsx("div",{className:"h-8 w-8 flex items-center justify-center rounded-lg bg-foreground/5 shrink-0 ml-1",children:e.jsx(d,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] font-bold text-primary/70 shrink-0",children:t}),e.jsx("span",{className:"text-[13px] font-medium truncate",children:s})]}),l&&l.length>0&&e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[l.slice(0,3).map(y=>e.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-foreground/5 text-muted-foreground/70 font-medium",children:y},y)),l.length>3&&e.jsxs("span",{className:"text-[9px] text-muted-foreground/50",children:["+",l.length-3]})]})]}),e.jsx("span",{className:m("text-[10px] font-bold uppercase tracking-wider px-2 py-1 rounded-md shrink-0",p),children:sa(a)})]});return c?e.jsx("a",{href:c,className:"block hover:opacity-90 transition-opacity",target:"_blank",rel:"noopener noreferrer",children:v}):v}function Pt({name:t,projectKey:s,icon:a,color:n,ticketCount:r,description:l}){return e.jsxs("div",{className:"flex items-center gap-3 py-2.5 px-3 rounded-xl recessed-card overflow-hidden",children:[e.jsx("div",{className:m("h-9 w-9 flex items-center justify-center rounded-lg shrink-0 text-lg",n?"":"bg-primary/10"),style:n?{backgroundColor:`${n}20`,color:n}:void 0,children:a||e.jsx(Xe,{className:"h-4.5 w-4.5 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[13px] font-semibold truncate",children:t}),e.jsx("span",{className:"text-[10px] font-bold text-muted-foreground/50 uppercase tracking-wider shrink-0",children:s})]}),l&&e.jsx("div",{className:"text-[11px] text-muted-foreground/60 truncate mt-0.5",children:l})]}),r!==void 0&&e.jsx("div",{className:"flex items-center gap-1 shrink-0",children:e.jsxs("span",{className:"text-[11px] font-bold text-muted-foreground/70 bg-foreground/5 px-2 py-0.5 rounded-full",children:[r," ticket",r!==1?"s":""]})})]})}function ra(t){if(!t||typeof t!="object")return;const s=t;return s.data&&typeof s.data=="object"?s.data:s}function Ot(t){const s=t.key,a=t.title;return!s||!a?null:{ticketKey:s,title:a,status:t.status||"todo",type:t.type||"task",priority:t.priority||"medium",labels:t.labels}}function $t(t){const s=t.name,a=t.key;return!s||!a?null:{name:s,projectKey:a,icon:t.icon,color:t.color,ticketCount:t.ticketCount,description:t.description}}function aa({toolName:t,result:s,output:a}){const n=ra(s);if((t==="create_ticket"||t==="update_ticket"||t==="get_ticket")&&n){const r=Ot(n);if(r)return e.jsxs("div",{className:"space-y-2",children:[e.jsx(Lt,{...r}),a&&e.jsx("div",{className:"text-[11px] text-muted-foreground/60 mt-1",children:e.jsx(Ae,{content:a})})]})}if(t==="list_tickets"&&n){const r=n.tickets??[];if(r.length>0){const l=r.slice(0,5),c=r.length-l.length;return e.jsxs("div",{className:"space-y-1.5",children:[l.map((d,w)=>{const p=Ot(d);return p?e.jsx(Lt,{...p},p.ticketKey||w):null}),c>0&&e.jsxs("div",{className:"text-[11px] text-muted-foreground/50 text-center py-1",children:["and ",c," more ticket",c!==1?"s":""]})]})}}if(t==="create_project"&&n){const r=$t(n);if(r)return e.jsxs("div",{className:"space-y-2",children:[e.jsx(Pt,{...r}),a&&e.jsx("div",{className:"text-[11px] text-muted-foreground/60 mt-1",children:e.jsx(Ae,{content:a})})]})}if(t==="list_projects"&&n){const r=n.projects??[];if(r.length>0)return e.jsx("div",{className:"space-y-1.5",children:r.map((l,c)=>{const d=$t(l);return d?e.jsx(Pt,{...d},d.projectKey||c):null})})}if(a)return e.jsx(Ae,{content:a});if(s!=null){const r=typeof s=="string"?s:JSON.stringify(s,null,2);return!r||r==="{}"||r==="[]"||r==='""'?e.jsx("div",{className:"text-[12px] text-muted-foreground/50 italic py-2",children:"No output returned"}):e.jsx("pre",{className:"text-[12px] font-mono bg-black/20 rounded-xl p-4 overflow-x-auto max-h-80 overflow-y-auto whitespace-pre-wrap break-all border border-white/5 scrollbar-glass",children:r})}return e.jsx("div",{className:"text-[12px] text-muted-foreground/50 italic py-2",children:"No output returned"})}const Ft={exec:le,bash:le,shell:le,read_file:Z,write_file:Z,edit_file:Z,search_files:Ne,grep:Ne,glob:Ne,web_fetch:ot,web_search:ot,system_info:Ze,env_vars:Ze,git_status:Z,git_diff:Z,git_log:Z,git_commit:Z,database:nt,query:nt,create_ticket:Qe,update_ticket:Qe,get_ticket:Qe,list_tickets:it,create_project:Xe,list_projects:Xe,cron_create:ie,cron_list:ie,cron_trigger:ie,cron_pause:ie,cron_delete:ie,cron_archive:ie,cron_history:ie,default:le};function na(t){return{exec:"Run Command",bash:"Bash",shell:"Shell",read_file:"Read File",write_file:"Write File",edit_file:"Edit File",search_files:"Search Files",grep:"Search Content",glob:"Find Files",web_fetch:"Fetch URL",web_search:"Web Search",system_info:"System Info",env_vars:"Environment",git_status:"Git Status",git_diff:"Git Diff",git_log:"Git Log",git_commit:"Git Commit",create_ticket:"Create Ticket",update_ticket:"Update Ticket",get_ticket:"Get Ticket",list_tickets:"List Tickets",create_project:"Create Project",list_projects:"List Projects",cron_create:"Create Job",cron_list:"List Jobs",cron_trigger:"Trigger Job",cron_pause:"Pause/Resume Job",cron_delete:"Delete Job",cron_archive:"Archive Job",cron_history:"Job History"}[t]||t.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase())}function oa(t){const s=Object.entries(t);if(s.length===0)return"";if(s.length===1){const[a,n]=s[0];if(a==="command"||a==="path"||a==="query"||a==="url")return String(n)}return s.map(([a,n])=>{const r=typeof n=="string"?n:JSON.stringify(n),l=r.length>50?r.slice(0,50)+"...":r;return`${a}: ${l}`}).join(", ")}function ts(t){if(!t||typeof t!="object")return{hasSmartOutput:!1};const s=t,a=typeof s.output=="string"?s.output:void 0,n=s.data!==void 0?s.data:void 0;return{output:a,data:n,hasSmartOutput:!!a}}function ia(t){const{output:s,data:a}=ts(t.result);if(s){const n=s.match(/^#{1,3}\s+(.+)/m);if(n)return n[1].trim();const r=s.split(`
2
+ `).find(l=>l.trim());if(r){const l=r.replace(/^[#*\s]+/,"").replace(/\*\*/g,"").trim();return l.length>80?l.slice(0,80)+"...":l}}if(a&&typeof a=="object"){const n=a;if(n.key&&n.title)return`${n.key}: ${n.title}`;if(n.name&&n.key)return`${n.name} (${n.key})`;if(n.total!==void 0)return`${n.total} result(s)`}return""}function la(t,s){if(t.status)return t.status;if(s){if(t.result&&typeof t.result=="object"){const a=t.result;if(a.pending===!0)return"pending";if(a.success===!1||a.error)return"error"}return"success"}}function zt({tool:t,className:s}){const[a,n]=i.useState(!1),[r,l]=i.useState("summary"),[c,d]=i.useState(!1),w=Ft[t.name]||Ft.default,p=na(t.name),v=oa(t.arguments),y=t.result!==void 0&&t.result!==null,{output:N,hasSmartOutput:$}=ts(t.result),I=$||["create_ticket","update_ticket","get_ticket","list_tickets","create_project","list_projects"].includes(t.name),K=y?ia(t):"",h=la(t,y),M=h==="success",R=h==="error",g=h==="pending"||h==="running",j=async()=>{let u;r==="summary"&&N?u=N:u=y?typeof t.result=="string"?t.result:JSON.stringify(t.result,null,2):"",await navigator.clipboard.writeText(u),d(!0),setTimeout(()=>d(!1),2e3)};return e.jsxs("div",{className:m("my-3 premium-card overflow-hidden group/card",R&&"border-red-500/20",s),children:[e.jsxs("button",{onClick:()=>n(!a),"aria-expanded":a,"aria-label":`${a?"Collapse":"Expand"} ${p} tool results`,className:"w-full px-4 py-3 flex items-center gap-3 hover:bg-foreground/[0.02] transition-colors text-left",children:[e.jsx("div",{className:m("h-10 w-10 flex items-center justify-center rounded-xl transition-all duration-300",R?"bg-red-500/10 text-red-500 shadow-[0_0_15px_-3px_rgba(239,68,68,0.3)]":g?"bg-blue-500/10 text-blue-500":"bg-primary/10 text-primary shadow-[0_0_15px_-3px_var(--primary-glow)]"),children:e.jsx(w,{className:m("h-5 w-5",g&&"animate-pulse"),"aria-hidden":"true"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[e.jsx("span",{className:"font-semibold text-[14px] leading-tight tracking-tight",children:p}),e.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[g&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-primary animate-pulse status-glow-info"}),e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-widest text-primary",children:"Running"})]}),M&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-green-500 status-glow-success"}),e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-widest text-green-500",children:"Success"})]}),R&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-red-500 status-glow-destructive"}),e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-widest text-red-500",children:"Failed"})]})]})]}),K?e.jsx("div",{className:"text-[11px] text-muted-foreground/80 truncate opacity-70 group-hover/card:opacity-100 transition-opacity",children:K}):v?e.jsx("div",{className:"text-[11px] text-muted-foreground/80 font-mono truncate opacity-60 group-hover/card:opacity-100 transition-opacity",children:v}):null]}),e.jsxs("div",{className:"ml-2 flex items-center gap-2",children:[t.duration!=null&&e.jsx("span",{className:"text-[10px] font-mono font-medium text-muted-foreground/40",children:t.duration>=1e3?`${(t.duration/1e3).toFixed(1)}s`:`${t.duration}ms`}),y&&e.jsx("div",{className:m("p-1 rounded-md transition-transform duration-200",a&&"rotate-180"),children:e.jsx(ke,{className:"h-4 w-4 text-muted-foreground/50"})})]})]}),g&&e.jsx("div",{className:"px-4 pb-3",children:e.jsx("div",{className:"h-2 rounded-full overflow-hidden bg-muted/30",children:e.jsx("div",{className:"h-full w-full skeleton-shimmer rounded-full bg-blue-500/20"})})}),!a&&y&&!I&&v&&e.jsx("div",{className:"px-4 pb-3",children:e.jsx("div",{className:"recessed-card p-2 rounded-lg",children:e.jsxs("div",{className:"text-[11px] text-muted-foreground/90 font-mono line-clamp-2 leading-relaxed",children:[typeof t.result=="string"?t.result.slice(0,100):JSON.stringify(t.result,null,2).slice(0,100),JSON.stringify(t.result).length>100?"...":""]})})}),a&&y&&e.jsxs("div",{className:"border-t border-border/10",children:[e.jsxs("div",{className:"px-4 py-2 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[I&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:u=>{u.stopPropagation(),l("summary")},className:m("flex items-center gap-1 px-2 py-1 rounded-md text-[10px] font-bold uppercase tracking-wider transition-all",r==="summary"?"bg-primary/10 text-primary":"text-muted-foreground/50 hover:text-muted-foreground hover:bg-foreground/5"),"aria-label":"Show summary view",children:[e.jsx(lt,{className:"h-3 w-3"}),"Summary"]}),e.jsxs("button",{onClick:u=>{u.stopPropagation(),l("json")},className:m("flex items-center gap-1 px-2 py-1 rounded-md text-[10px] font-bold uppercase tracking-wider transition-all",r==="json"?"bg-primary/10 text-primary":"text-muted-foreground/50 hover:text-muted-foreground hover:bg-foreground/5"),"aria-label":"Show JSON view",children:[e.jsx(Qt,{className:"h-3 w-3"}),"JSON"]})]}),!I&&e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:"Output"})]}),e.jsx("button",{onClick:u=>{u.stopPropagation(),j()},className:"p-1.5 rounded-lg hover:bg-white/5 transition-all text-muted-foreground hover:text-foreground","aria-label":"Copy tool output",children:c?e.jsx(ct,{className:"h-3.5 w-3.5 text-green-400","aria-hidden":"true"}):e.jsx(dt,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}),e.jsx("div",{className:"px-4 pb-4",children:r==="summary"?e.jsx("div",{className:"prose prose-sm prose-invert max-w-none rounded-xl bg-black/10 p-4 border border-white/5 overflow-y-auto max-h-80 scrollbar-glass",children:e.jsx(aa,{toolName:t.name,result:t.result,output:N})}):e.jsx("pre",{className:"text-[12px] font-mono bg-black/20 rounded-xl p-4 overflow-x-auto max-h-80 overflow-y-auto whitespace-pre-wrap break-all border border-white/5 scrollbar-glass",children:typeof t.result=="string"?t.result:JSON.stringify(t.result,null,2)})})]})]})}function ca({tools:t,className:s}){const[a,n]=i.useState(t.length<3);return t.length===0?null:t.length<3?e.jsx("div",{className:s,children:t.map(r=>e.jsx(zt,{tool:r},r.id))}):e.jsx("div",{className:s,children:a?e.jsxs(e.Fragment,{children:[t.map(r=>e.jsx(zt,{tool:r},r.id)),e.jsxs("button",{onClick:()=>n(!1),className:"w-full text-center py-1.5 text-[11px] text-muted-foreground/60 hover:text-muted-foreground transition-colors",children:["Collapse ",t.length," tools"]})]}):e.jsxs("button",{onClick:()=>n(!0),className:"w-full flex items-center justify-center gap-2 py-2.5 px-4 rounded-xl border border-border/20 bg-card/30 hover:bg-card/50 transition-colors",children:[e.jsx(le,{className:"h-3.5 w-3.5 text-muted-foreground/60"}),e.jsxs("span",{className:"text-[12px] font-medium text-muted-foreground/80",children:["Show ",t.length," tool calls"]})]})})}function da({thinking:t,isStreaming:s=!1,className:a,defaultOpen:n}){const[r,l]=i.useState(n??s);if(i.useEffect(()=>{s&&l(!0)},[s]),!t)return null;const c=t.split(/\s+/).length;return e.jsxs("div",{className:m("mb-3",a),children:[e.jsxs("button",{onClick:()=>l(!r),className:m("flex items-center gap-3 w-full px-4 py-3 rounded-2xl transition-all duration-300 group text-left","premium-card",s&&"bg-primary/5"),"aria-expanded":r,"aria-label":r?"Collapse thinking":"Expand thinking",children:[e.jsxs("div",{className:m("relative flex items-center justify-center h-8 w-8 rounded-xl shadow-inner transition-all duration-300",s?"bg-primary/20 shadow-[0_0_15px_-3px_var(--primary-glow)]":"bg-muted shadow-sm"),children:[e.jsx(Ke,{className:m("h-4 w-4 transition-all duration-500",s?"text-primary animate-pulse":"text-muted-foreground",r&&!s?"text-foreground":"",r?"scale-110 rotate-[15deg]":"scale-100")}),s&&e.jsx("span",{className:"absolute -top-1 -right-1 h-2.5 w-2.5 rounded-full bg-primary animate-ping shadow-[0_0_8px_var(--primary-glow)]"})]}),e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsx("span",{className:m("text-[13px] font-bold tracking-tight transition-colors",s?"text-primary":"text-foreground/80"),children:s?e.jsxs("span",{className:"flex items-center gap-1.5 uppercase text-[10px] tracking-widest font-black",children:["Thinking",e.jsxs("span",{className:"inline-flex gap-0.5",children:[e.jsx("span",{className:"animate-bounce",style:{animationDelay:"0ms"},children:"."}),e.jsx("span",{className:"animate-bounce",style:{animationDelay:"150ms"},children:"."}),e.jsx("span",{className:"animate-bounce",style:{animationDelay:"300ms"},children:"."})]})]}):r?"Analytic Reasoning":"View Process Trace"}),!s&&e.jsxs("span",{className:"text-[10px] uppercase font-bold tracking-widest text-muted-foreground/60",children:[c," tokens distilled"]})]}),e.jsx("div",{className:m("h-6 w-6 flex items-center justify-center rounded-lg transition-all duration-300",r?"rotate-90 bg-zinc-100 dark:bg-zinc-800":"bg-transparent"),children:e.jsx(Ce,{className:m("h-3.5 w-3.5",r?"text-zinc-900 dark:text-zinc-100":"text-zinc-400")})})]}),e.jsx("div",{className:m("grid transition-all duration-500 cubic-bezier(0.4, 0, 0.2, 1)",r?"grid-rows-[1fr] opacity-100 mt-2":"grid-rows-[0fr] opacity-0"),children:e.jsx("div",{className:"overflow-hidden",children:e.jsx("div",{className:m("px-5 py-4 rounded-2xl glass","max-h-[32rem] overflow-y-auto scrollbar-glass"),children:e.jsx("pre",{className:"whitespace-pre-wrap font-mono text-[12px] text-muted-foreground leading-relaxed",children:t})})})})]})}function ua({jsonBlocks:t,className:s}){const[a,n]=i.useState(!1);return!t||t.length===0?null:e.jsxs("div",{className:m("mb-3",s),children:[e.jsxs("button",{onClick:()=>n(!a),"aria-expanded":a,"aria-label":a?"Collapse raw output":"Expand raw output",className:m("flex items-center gap-2 px-3 py-1.5 rounded-lg","bg-amber-100 dark:bg-amber-500/15","hover:bg-amber-200 dark:hover:bg-amber-500/25","border border-amber-300 dark:border-amber-500/30","transition-colors text-left text-xs"),children:[e.jsxs("span",{className:"text-amber-700 dark:text-amber-400",children:[t.length," raw output",t.length>1?"s":""," filtered"]}),e.jsx(Ce,{className:m("h-3 w-3 text-amber-600 dark:text-amber-400/70 transition-transform",a&&"rotate-90")})]}),e.jsx("div",{className:m("grid transition-all duration-200",a?"grid-rows-[1fr] opacity-100 mt-2":"grid-rows-[0fr] opacity-0"),children:e.jsx("div",{className:"overflow-hidden",children:e.jsx("div",{className:"px-3 py-2 rounded-lg bg-amber-50 dark:bg-amber-500/10 border border-amber-200 dark:border-amber-500/20",children:t.map((r,l)=>e.jsx("pre",{className:"text-xs text-amber-800 dark:text-amber-300/80 font-mono whitespace-pre-wrap",children:r},l))})})})]})}const ma=[/<thinking>([\s\S]*?)<\/thinking>/gi,/^(Since there's no specific prompt.*?(?=\n\n|$))/gim,/^(I'll create a hypothetical.*?(?=\n\n|$))/gim,/^(Let me think about.*?(?=\n\n|$))/gim,/^(Thinking about this.*?(?=\n\n|$))/gim],xa=[/\{\s*"name"\s*:\s*"[^"]+"\s*,\s*"parameters"\s*:\s*\{[^}]*\}\s*\}/g,/\{\s*"function"\s*:\s*"[^"]+"\s*,\s*"args"\s*:\s*\{[^}]*\}\s*\}/g,/\{\s*["']?name["']?\s*:\s*["'][^"']+["']\s*,\s*["']?parameters["']?\s*:\s*\{[^}]*\}\s*\}/gi];function ha(t){let s=t,a=[];const n=[];let r=!1;for(const l of ma){const c=s.matchAll(l);for(const d of c)d[1]&&(a.push(d[1].trim()),r=!0);s=s.replace(l,"")}for(const l of xa){const c=s.matchAll(l);for(const d of c)n.push(d[0]),r=!0;s=s.replace(l,"")}return s=s.replace(/\n{3,}/g,`
3
+
4
+ `).trim(),!s&&(a.length>0||n.length>0)&&(s="I'm processing your request. Check my reasoning below for details."),{content:s,thinking:a.length>0?a.join(`
5
+
6
+ `):null,filteredJson:n,wasProcessed:r}}const pa={code:{label:"Code",Icon:It,colorClass:"text-violet-400 bg-violet-500/10"},html:{label:"HTML",Icon:It,colorClass:"text-orange-400 bg-orange-500/10"},markdown:{label:"Markdown",Icon:lt,colorClass:"text-blue-400 bg-blue-500/10"},mermaid:{label:"Mermaid",Icon:_t,colorClass:"text-emerald-400 bg-emerald-500/10"},diagram:{label:"Diagram",Icon:_t,colorClass:"text-emerald-400 bg-emerald-500/10"},svg:{label:"SVG",Icon:qr,colorClass:"text-pink-400 bg-pink-500/10"},table:{label:"Table",Icon:dr,colorClass:"text-cyan-400 bg-cyan-500/10"},chart:{label:"Chart",Icon:Jt,colorClass:"text-yellow-400 bg-yellow-500/10"}};function ga(t){return t.replace(/<script[\s\S]*?<\/script>/gi,"")}function fa(t){try{const s=JSON.parse(t);return Array.isArray(s)&&s.length>0&&typeof s[0]=="object"?s:null}catch{return null}}function ba({content:t,language:s}){return e.jsx("pre",{className:m("text-[12px] font-mono leading-relaxed bg-black/20 rounded-xl p-4 overflow-x-auto","border border-white/5 scrollbar-glass whitespace-pre-wrap break-all max-h-96",s&&`language-${s}`),children:e.jsx("code",{children:t})})}function va({content:t}){return e.jsx("iframe",{srcDoc:t,sandbox:"allow-scripts",title:"HTML artifact",className:"w-full rounded-xl border border-border/20 bg-white",style:{minHeight:"200px",maxHeight:"480px"},"aria-label":"Rendered HTML content"})}function ya({content:t}){const s=ga(t);return e.jsx("div",{className:"flex items-center justify-center rounded-xl border border-border/20 bg-white/5 p-4 overflow-auto max-h-96",dangerouslySetInnerHTML:{__html:s},"aria-label":"SVG artifact"})}function ja({content:t}){const s=fa(t);if(!s)return e.jsx("pre",{className:"text-[12px] font-mono bg-black/20 rounded-xl p-4 overflow-x-auto border border-white/5 whitespace-pre-wrap break-all max-h-96",children:t});const a=Object.keys(s[0]);return e.jsx("div",{className:"overflow-auto max-h-96 rounded-xl border border-border/20",children:e.jsxs("table",{className:"w-full text-[13px] border-collapse",children:[e.jsx("thead",{children:e.jsx("tr",{className:"bg-muted/40 border-b border-border/30",children:a.map(n=>e.jsx("th",{className:"px-3 py-2 text-left font-semibold text-muted-foreground tracking-tight",children:n},n))})}),e.jsx("tbody",{children:s.map((n,r)=>e.jsx("tr",{className:"border-b border-border/10 hover:bg-foreground/[0.02] transition-colors",children:a.map(l=>e.jsx("td",{className:"px-3 py-2 text-foreground/80",children:String(n[l]??"")},l))},r))})]})})}function wa({content:t}){return e.jsxs("div",{className:"rounded-xl border border-border/20 bg-muted/20 p-4",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/60 mb-3",children:"Mermaid source (rendered on load)"}),e.jsx("div",{className:"mermaid text-[13px] font-mono text-foreground/80 whitespace-pre-wrap",children:t})]})}function Na(){return e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 rounded-xl border border-border/20 bg-muted/20 p-10",children:[e.jsx(Jt,{className:"h-12 w-12 text-muted-foreground/30","aria-hidden":"true"}),e.jsx("p",{className:"text-sm text-muted-foreground/60",children:"Chart rendering coming soon"})]})}function ka({artifact:t,highlighted:s=!1}){const[a,n]=i.useState(!1),[r,l]=i.useState(!1),c=pa[t.type],{Icon:d,label:w,colorClass:p}=c,v=t.title||`Untitled ${w}`,y=async $=>{$.stopPropagation(),await navigator.clipboard.writeText(t.content),l(!0),setTimeout(()=>l(!1),2e3)},N=()=>{switch(t.type){case"code":return e.jsx(ba,{content:t.content,language:t.language});case"html":return e.jsx(va,{content:t.content});case"markdown":return e.jsx("div",{className:"prose prose-sm prose-invert max-w-none rounded-xl bg-black/10 p-4 border border-white/5",children:e.jsx(Ae,{content:t.content})});case"mermaid":case"diagram":return e.jsx(wa,{content:t.content});case"svg":return e.jsx(ya,{content:t.content});case"table":return e.jsx(ja,{content:t.content});case"chart":return e.jsx(Na,{});default:return e.jsx("pre",{className:"text-[12px] font-mono bg-black/20 rounded-xl p-4 overflow-x-auto border border-white/5 whitespace-pre-wrap break-all max-h-96",children:t.content})}};return e.jsxs("div",{id:`canvas-artifact-${t.id}`,className:m("my-3 rounded-2xl border overflow-hidden transition-all duration-300","bg-card/60 backdrop-blur-sm shadow-sm",s?"border-primary/40 shadow-primary/10 shadow-md":"border-border/20"),children:[e.jsxs("button",{onClick:()=>n(!a),"aria-expanded":a,"aria-controls":`canvas-content-${t.id}`,"aria-label":`${a?"Collapse":"Expand"} ${w} artifact: ${v}`,className:"w-full flex items-center gap-3 px-4 py-3 hover:bg-foreground/[0.02] transition-colors text-left",children:[e.jsx("div",{className:m("h-8 w-8 rounded-lg flex items-center justify-center shrink-0",p),children:e.jsx(d,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-semibold text-[13px] leading-tight truncate",children:v}),e.jsxs("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50 mt-0.5",children:[w,t.language?` · ${t.language}`:""]})]}),e.jsxs("div",{className:"flex items-center gap-1 ml-auto shrink-0",children:[e.jsx("button",{onClick:y,"aria-label":"Copy artifact content",className:"p-1.5 rounded-lg hover:bg-white/5 transition-all text-muted-foreground/50 hover:text-foreground",children:r?e.jsx(ct,{className:"h-3.5 w-3.5 text-green-400","aria-hidden":"true"}):e.jsx(dt,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),a?e.jsx(ke,{className:"h-4 w-4 text-muted-foreground/40","aria-hidden":"true"}):e.jsx(Ce,{className:"h-4 w-4 text-muted-foreground/40","aria-hidden":"true"})]})]}),a&&e.jsxs("div",{id:`canvas-content-${t.id}`,className:"border-t border-border/10 px-4 pb-4 pt-3",children:[(t.type==="html"||t.type==="svg")&&e.jsxs("div",{className:"flex items-center gap-1.5 mb-2 text-[10px] text-muted-foreground/50",children:[e.jsx(Bt,{className:"h-3 w-3","aria-hidden":"true"}),e.jsx("span",{children:"Sandboxed preview"})]}),N()]})]})}function Ca({className:t}){return e.jsx(Me,{className:t})}function Sa(t,s){return i.useMemo(()=>s||!t?{content:t,thinking:null,filteredJson:[],wasProcessed:!1}:ha(t),[t,s])}function Ta({messages:t,currentPreset:s,quickActions:a,healthyProviders:n,copiedId:r,onCopy:l,onRetry:c,onDelete:d,onQuickAction:w,onOpenProviderSetup:p}){const v=i.useRef(null);return i.useEffect(()=>{v.current?.scrollIntoView({behavior:"smooth"})},[t]),t.length===0?e.jsx("div",{className:"flex-1 premium-card rounded-[2rem] p-8 overflow-y-auto",children:e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center max-w-lg mx-auto",children:[e.jsx("div",{className:"h-24 w-24 rounded-3xl glass-heavy flex items-center justify-center mb-8 shadow-xl shadow-primary/10 border-primary/5",children:!s?.icon||s.icon==="bot"?e.jsx(Gt,{className:"h-14 w-14"}):e.jsx(Ca,{icon:s.icon,className:"h-12 w-12 text-primary/60"})}),e.jsx("h2",{className:"text-3xl font-bold mb-4 tracking-tighter text-foreground font-heading graduate-text-gradient",children:s?.name||"Start a conversation"}),e.jsx("p",{className:"text-base leading-relaxed text-muted-foreground mb-10 opacity-80",children:s?.description||"Ask me anything about profClaw, your tasks, or get help with coding."}),n>0&&a.length>0&&e.jsx("div",{className:"grid grid-cols-2 gap-4 w-full",children:a.slice(0,4).map(y=>e.jsxs("button",{onClick:()=>w(y.prompt),className:"px-5 py-4 rounded-xl glass hover:bg-primary/5 border-primary/5 hover:border-primary/20 text-sm font-semibold transition-all duration-300 hover:-translate-y-1 active:scale-[0.98] text-left group shadow-lg","aria-label":`Quick action: ${y.label}`,children:[e.jsx("p",{className:"truncate group-hover:text-primary transition-colors",children:y.label}),e.jsx("div",{className:"h-0.5 w-6 bg-primary/20 mt-2 rounded-full group-hover:bg-primary group-hover:w-12 transition-all duration-500"})]},y.id))}),n===0&&e.jsxs("button",{onClick:p,className:"group flex items-center gap-2 px-8 py-3.5 rounded-full bg-primary text-primary-foreground hover:brightness-110 active:scale-95 transition-all font-bold shadow-xl shadow-primary/25","aria-label":"Configure a provider to start chatting",children:[e.jsx(ut,{className:"h-4 w-4 group-hover:rotate-180 transition-transform duration-700 ease-in-out"}),"Configure Provider"]})]})}):e.jsxs("div",{className:"flex-1 glass rounded-2xl p-4 overflow-y-auto overflow-x-hidden space-y-4",role:"log","aria-live":"polite","aria-relevant":"additions",children:[t.map(y=>e.jsx(Ia,{message:y,copiedId:r,onCopy:l,onRetry:c,onDelete:d,onQuickAction:w},y.id)),e.jsx("div",{ref:v})]})}function Ia({message:t,copiedId:s,onCopy:a,onRetry:n,onDelete:r,onQuickAction:l}){const c=Sa(t.content,t.isLoading??!1);return e.jsxs("div",{className:m("flex gap-3",t.role==="user"?"flex-row-reverse":""),children:[e.jsx("div",{className:m("h-9 w-9 rounded-xl flex items-center justify-center shrink-0 border transition-all duration-300 shadow-sm",t.role==="user"?"bg-primary/10 border-primary/20 text-primary hidden sm:flex":"bg-muted/50 border-border/50 text-muted-foreground"),children:t.role==="user"?e.jsx(Ps,{className:"h-5 w-5"}):e.jsx(Me,{className:"h-5 w-5"})}),e.jsxs("div",{className:m("max-w-[92%] sm:max-w-[75%] rounded-2xl px-3 py-2 sm:px-5 sm:py-3 group relative transition-all duration-300",t.role==="user"?"bg-primary text-primary-foreground shadow-lg shadow-primary/10 ml-auto rounded-tr-sm":"premium-card text-foreground shadow-sm rounded-tl-sm",t.error&&"border border-destructive/50 bg-destructive/5"),children:[t.role==="user"&&e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-white/10 to-transparent rounded-[2rem] pointer-events-none"}),t.isLoading?e.jsxs("div",{className:"flex flex-col gap-3 py-2 px-1 min-w-[200px]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-primary/60 animate-pulse"}),e.jsx("div",{className:"h-3 rounded-full bg-muted-foreground/10 animate-pulse w-3/4",style:{animationDuration:"1.5s"}})]}),e.jsx("div",{className:"h-3 rounded-full bg-muted-foreground/8 animate-pulse w-full ml-5",style:{animationDuration:"1.5s",animationDelay:"200ms"}}),e.jsx("div",{className:"h-3 rounded-full bg-muted-foreground/6 animate-pulse w-2/3 ml-5",style:{animationDuration:"1.5s",animationDelay:"400ms"}}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-muted-foreground/40 ml-5 mt-1",children:"Generating response..."})]}):e.jsxs(e.Fragment,{children:[t.images&&t.images.length>0&&e.jsx("div",{className:"flex gap-2 mb-2 flex-wrap",children:t.images.map((d,w)=>e.jsx("img",{src:d,alt:`Attached image ${w+1}`,className:"h-20 w-20 object-cover rounded-lg"},w))}),t.role==="assistant"&&c.thinking&&e.jsx(da,{thinking:c.thinking,isStreaming:!1}),t.role==="assistant"&&c.filteredJson.length>0&&e.jsx(ua,{jsonBlocks:c.filteredJson}),t.toolCalls&&t.toolCalls.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mb-2",children:[e.jsx(le,{className:"h-3 w-3"}),e.jsxs("span",{children:["Used ",t.toolCalls.length," tool",t.toolCalls.length>1?"s":""]})]}),e.jsx(ca,{tools:t.toolCalls})]}),t.toolCalls?.filter(d=>d.name==="canvas_render").map((d,w)=>{let p=null;try{const v=typeof d.result=="string"?JSON.parse(d.result):d.result;if(v?.artifact&&typeof v.artifact=="object")p=v.artifact;else if(v?.data&&typeof v.data=="object"){const y=v.data;y.artifactId&&y.type&&(p={id:String(y.artifactId),type:y.type,title:y.title,content:String(y.preview??"")})}}catch{}return p?e.jsx(ka,{artifact:p},`canvas-${w}`):null}),e.jsx("div",{className:m("text-[15px] leading-relaxed overflow-x-auto",t.role==="user"?"font-medium selection:bg-white/30":"selection:bg-primary/20",t.role==="user"&&"text-shadow-sm"),children:t.role==="assistant"?e.jsx(Ae,{content:c.content}):e.jsx("p",{className:"whitespace-pre-wrap",children:t.content})}),t.error&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-destructive",children:t.error}),e.jsxs(V,{variant:"ghost",size:"sm",onClick:()=>n(t.id),className:"h-6 px-2","aria-label":"Retry message",children:[e.jsx(ut,{className:"h-3 w-3 mr-1","aria-hidden":"true"}),"Retry"]})]}),t.usage&&e.jsx("div",{className:"mt-2 pt-2 border-t border-border/10 text-[10px] text-muted-foreground/60 flex items-center gap-3",children:e.jsxs("div",{className:"flex items-center gap-2 bg-muted/30 rounded-md px-2 py-0.5 border border-border/20",children:[e.jsxs("span",{children:[t.usage.totalTokens.toLocaleString()," tokens"]}),t.usage.cost&&t.usage.cost>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"opacity-30",children:"|"}),e.jsxs("span",{children:["$",t.usage.cost.toFixed(4)]})]})]})}),t.role==="assistant"&&t.routing&&!t.isLoading&&e.jsxs("div",{className:"mt-1.5 flex items-center gap-1 text-[10px] text-emerald-600/70 dark:text-emerald-400/60",children:[e.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-emerald-400 dark:bg-emerald-500"}),e.jsxs("span",{children:["Routed to ",t.routing.modelLabel,t.routing.savingsPercent!==void 0&&t.routing.savingsPercent>0?` (saved ${t.routing.savingsPercent.toFixed(0)}%)`:""]})]}),t.role==="assistant"&&t.suggestions&&t.suggestions.length>0&&!t.isLoading&&e.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:t.suggestions.slice(0,3).map(d=>e.jsxs("button",{onClick:()=>{d.action?.command&&l(d.action.command)},className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs bg-primary/10 text-primary hover:bg-primary/20 border border-primary/20 transition-colors",title:d.message,children:[e.jsx("span",{className:"h-1 w-1 rounded-full bg-primary/60"}),d.action?.label??d.message.slice(0,40)]},d.id))}),!t.isLoading&&e.jsxs("div",{className:"opacity-0 group-hover:opacity-100 absolute top-2 right-2 flex items-center gap-1 transition-all duration-300",children:[t.role==="assistant"&&e.jsx("button",{onClick:()=>a(c.content,t.id),className:"p-2 rounded-xl glass-heavy hover:bg-primary/10 border-primary/10 transition-all duration-300 hover:scale-110 active:scale-95","aria-label":"Copy message content",children:s===t.id?e.jsx(ct,{className:"h-3.5 w-3.5 text-success shadow-[0_0_8px_var(--success)]","aria-hidden":"true"}):e.jsx(dt,{className:"h-3.5 w-3.5 text-muted-foreground/60","aria-hidden":"true"})}),e.jsx("button",{onClick:()=>r(t.id),className:"p-2 rounded-xl glass-heavy hover:bg-destructive/10 border-destructive/10 transition-all duration-300 hover:scale-110 active:scale-95","aria-label":"Delete message",children:e.jsx(ze,{className:"h-3.5 w-3.5 text-muted-foreground/60 hover:text-destructive transition-colors","aria-hidden":"true"})})]})]})]})]})}function _a({value:t,onChange:s,onSend:a,isPending:n,disabled:r,placeholder:l="Type a message...",pendingImages:c,onImageSelect:d,onImageRemove:w,isRecording:p,onStartRecording:v,onStopRecording:y,agentMode:N=!1,onToggleAgentMode:$,talkModeState:A="idle",onToggleTalkMode:I,voiceAvailable:K}){const h=K?.stt??!0,M=i.useRef(null),R=i.useRef(null);i.useEffect(()=>{M.current&&(M.current.style.height="auto",M.current.style.height=`${Math.min(M.current.scrollHeight,200)}px`)},[t]);const g=j=>{j.key==="Enter"&&!j.shiftKey&&(j.preventDefault(),a())};return e.jsxs("div",{className:"mt-2 w-full space-y-2",children:[c.length>0&&e.jsx("div",{className:"flex gap-2 flex-wrap px-1",children:c.map((j,u)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:j,alt:`Pending upload ${u+1}`,className:"h-16 w-16 object-cover rounded-xl shadow-md transition-all"}),e.jsx("button",{onClick:()=>w(u),className:"absolute -top-1.5 -right-1.5 h-6 w-6 rounded-full bg-background border border-border flex items-center justify-center text-muted-foreground hover:text-destructive transition-all shadow-md active:scale-90 z-10 opacity-0 group-hover:opacity-100","aria-label":"Remove image",children:e.jsx(mt,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]},u))}),e.jsxs("div",{className:m("relative rounded-[1.5rem] px-3 py-2 flex items-end gap-3 transition-all duration-300","field-recessed shadow-none",N&&"bg-primary/5 border-primary/20"),children:[e.jsx("input",{ref:R,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:d}),e.jsxs("div",{className:"flex items-center gap-1 relative z-10 pb-0.5 pl-1",children:[$&&e.jsx(V,{variant:"ghost",size:"icon",className:m("h-9 w-9 shrink-0 rounded-xl transition-all",N?"bg-primary/20 text-primary":"text-muted-foreground hover:bg-muted"),onClick:$,disabled:n||r,"aria-label":N?"Agent mode (tools enabled)":"Chat mode (click for tools)","aria-pressed":N,children:N?e.jsx(Me,{className:"h-5 w-5","aria-hidden":"true"}):e.jsx(sr,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx(V,{variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0 rounded-xl text-muted-foreground hover:bg-muted transition-all",onClick:()=>R.current?.click(),disabled:n||r,"aria-label":"Add image",children:e.jsx(Ur,{className:"h-5 w-5","aria-hidden":"true"})}),A==="idle"&&e.jsxs("div",{className:"relative hidden min-[480px]:block",children:[e.jsx(V,{variant:"ghost",size:"icon",className:m("h-9 w-9 shrink-0 rounded-xl transition-all",p?"bg-destructive/10 text-destructive animate-pulse":h?"text-muted-foreground hover:bg-muted":"opacity-40 cursor-not-allowed text-muted-foreground"),onClick:p?y:v,disabled:n||r,title:h?void 0:"Voice input unavailable - configure STT in Settings > Voice","aria-label":p?"Stop recording":h?"Start recording":"Voice input unavailable","aria-pressed":p,children:p?e.jsx(Jr,{className:"h-5 w-5","aria-hidden":"true"}):e.jsx(Wt,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("span",{className:m("absolute top-0.5 right-0.5 h-2 w-2 rounded-full",h?"bg-green-500":"bg-red-500"),"aria-hidden":"true"})]}),I&&e.jsxs("div",{className:"relative hidden min-[480px]:block",children:[e.jsx(V,{variant:"ghost",size:"icon",className:m("h-9 w-9 shrink-0 rounded-xl transition-all",A!=="idle"?"bg-green-500/20 text-green-500":h?"text-muted-foreground hover:bg-muted":"opacity-40 cursor-not-allowed text-muted-foreground"),onClick:I,disabled:n||r,title:!h&&A==="idle"?"Talk Mode unavailable - configure STT in Settings > Voice":void 0,"aria-label":A!=="idle"?"Stop Talk Mode":h?"Start Talk Mode":"Talk Mode unavailable","aria-pressed":A!=="idle",children:e.jsx(Os,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("span",{className:m("absolute top-0.5 right-0.5 h-2 w-2 rounded-full",h?"bg-green-500":"bg-red-500"),"aria-hidden":"true"})]})]}),e.jsx(gr,{ref:M,value:t,onChange:j=>s(j.target.value),onKeyDown:g,placeholder:N?"Give me a task to work on...":l,"aria-label":N?"Give me a task to work on":l,className:m("min-h-[3rem] max-h-48 resize-none border-0 bg-transparent text-[15px]","focus-visible:ring-0 focus-visible:ring-offset-0 py-3 px-2 relative z-10 leading-relaxed font-medium","placeholder:text-[var(--muted-foreground)]/50 transition-colors",N&&"placeholder:text-primary/40"),disabled:n||r}),e.jsx(V,{onClick:a,disabled:!t.trim()||n||r,size:"icon","aria-label":"Send message",variant:"black",className:m("h-9 w-9 shrink-0 rounded-xl transition-all mb-0.5 mr-0.5","hover:scale-105 active:scale-95"),children:n?e.jsx(ce,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}):e.jsx(Zt,{className:"h-4 w-4","aria-hidden":"true"})})]})]})}function Aa({open:t,onOpenChange:s,conversations:a,currentConversationId:n,onSelectConversation:r,onNewChat:l}){return e.jsx(ur,{open:t,onOpenChange:s,children:e.jsx(mr,{className:"glass border-l-0 p-0 w-[280px]",children:e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"p-4 border-b border-border/50",children:e.jsxs(xr,{children:[e.jsxs(hr,{className:"flex items-center gap-2 text-sm",children:[e.jsx(Fe,{className:"h-4 w-4"}),"History"]}),e.jsx(pr,{className:"text-xs",children:"Recent conversations"})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto p-2 space-y-1",children:a.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-40 text-center px-4",children:[e.jsx(fe,{className:"h-8 w-8 text-muted-foreground/30 mb-2"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No conversations yet"}),e.jsx("p",{className:"text-xs text-muted-foreground/70 mt-1",children:"Start a new chat to see history"})]}):a.map(c=>e.jsx("button",{onClick:()=>r(c.id),"aria-label":`Select conversation: ${c.title}`,className:m("w-full text-left px-3 py-2.5 rounded-xl transition-all group",n===c.id?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(fe,{className:"h-4 w-4 mt-0.5 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:c.title}),e.jsx("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:c.preview||"No messages"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 text-xs text-muted-foreground/70",children:[e.jsxs("span",{children:[c.messageCount," msgs"]}),e.jsx("span",{children:"·"}),e.jsx("span",{children:new Date(c.updatedAt).toLocaleDateString()})]})]})]})},c.id))}),e.jsx("div",{className:"p-3 border-t border-border/50",children:e.jsxs(V,{variant:"outline",size:"sm",className:"w-full text-xs",onClick:()=>{l(),s(!1)},children:[e.jsx(fe,{className:"h-3.5 w-3.5 mr-1.5","aria-hidden":"true"}),"New Conversation"]})})]})})})}function Ma({isOpen:t,onToggle:s,title:a,subtitle:n,icon:r,width:l=280,position:c="left",children:d,headerActions:w,footer:p,className:v,showCollapsedToggle:y=!0}){const N=y?48:0;return e.jsxs("div",{className:m("relative shrink-0 transition-all duration-300 ease-out h-full",v),style:{width:t?l:N},children:[!t&&y&&e.jsxs("div",{className:"group h-full flex flex-col items-center py-3 bg-card/60 backdrop-blur-sm hover:bg-card/80 transition-colors",children:[e.jsx(V,{variant:"ghost",size:"icon",onClick:s,className:"h-10 w-10 rounded-xl bg-primary/10 hover:bg-primary/20 text-primary transition-all group-hover:scale-105",title:`Open ${a||"sidebar"}`,children:c==="left"?e.jsx(Ct,{className:"h-5 w-5"}):e.jsx(St,{className:"h-5 w-5"})}),a&&e.jsx("div",{className:"absolute left-12 top-3 bg-popover/95 backdrop-blur-sm text-popover-foreground px-2.5 py-1.5 rounded-lg text-xs font-medium shadow-lg border border-border/50 opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none whitespace-nowrap z-50",children:a}),e.jsx("div",{className:"flex-1 flex items-center justify-center mt-4",children:e.jsx("div",{className:"w-1 h-16 rounded-full bg-primary/20 group-hover:bg-primary/40 transition-colors"})})]}),t&&e.jsxs("div",{className:m("relative flex flex-col h-full overflow-hidden","bg-card/90 backdrop-blur-xl","border-r border-border/20","animate-in slide-in-from-left-2 duration-200",c==="right"&&"border-l border-r-0 slide-in-from-right-2"),style:{width:l},children:[(a||w)&&e.jsxs("div",{className:"flex items-center justify-between px-3 py-2.5 border-b border-border/30",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r&&e.jsx("span",{className:"text-muted-foreground/70 shrink-0",children:r}),e.jsxs("div",{className:"min-w-0",children:[a&&e.jsx("h3",{className:"text-[13px] font-semibold truncate",children:a}),n&&e.jsx("p",{className:"text-[9px] text-muted-foreground/60 truncate",children:n})]})]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[w,e.jsx(V,{variant:"ghost",size:"icon",onClick:s,className:"h-6 w-6 rounded hover:bg-muted/60 shrink-0",title:"Collapse sidebar",children:c==="left"?e.jsx(St,{className:"h-3 w-3 text-muted-foreground"}):e.jsx(Ct,{className:"h-3 w-3 text-muted-foreground"})})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:d}),p&&e.jsx("div",{className:"border-t border-border/30 px-3 py-2.5",children:p})]})]})}const Ra="chat-sidebar-open",Vt={today:"Today",yesterday:"Yesterday",last7days:"Last 7 Days",last30days:"Last 30 Days",older:"Older"};function Ea(t){const a=new Date().getTime()-t.getTime(),n=Math.floor(a/1e3),r=Math.floor(n/60),l=Math.floor(r/60),c=Math.floor(l/24);return n<60?"just now":r<60?`${r}m ago`:l<24?`${l}h ago`:c===1?"yesterday":c<7?`${c}d ago`:c<30?`${Math.floor(c/7)}w ago`:c<365?`${Math.floor(c/30)}mo ago`:`${Math.floor(c/365)}y ago`}function Da(t){const s=new Date,a=new Date(s.getFullYear(),s.getMonth(),s.getDate()),n=new Date(a.getTime()-1440*60*1e3),r=new Date(a.getTime()-10080*60*1e3),l=new Date(a.getTime()-720*60*60*1e3);return t>=a?"today":t>=n?"yesterday":t>=r?"last7days":t>=l?"last30days":"older"}function La(t){const s={today:[],yesterday:[],last7days:[],last30days:[],older:[]};return t.forEach(a=>{const n=new Date(a.updatedAt),r=Da(n);s[r].push(a)}),s}function Pa({isOpen:t,onToggle:s,conversations:a,currentConversationId:n,onSelectConversation:r,onNewChat:l,onDeleteConversation:c,projects:d=[],width:w=300,persistState:p=!0}){const[v,y]=i.useState(""),[N,$]=i.useState(new Set),[A,I]=i.useState("time");i.useEffect(()=>{p&&localStorage.setItem(Ra,JSON.stringify(t))},[t,p]);const{filteredConversations:K,groupedByTime:h,groupedByProject:M}=i.useMemo(()=>{const u=v.trim()?a.filter(x=>x.title.toLowerCase().includes(v.toLowerCase())||x.preview?.toLowerCase().includes(v.toLowerCase())):a,T={_none:[]};return d.forEach(x=>{T[x.id]=[]}),u.forEach(x=>{const C=x.projectId;C&&T[C]?T[C].push(x):T._none.push(x)}),{filteredConversations:u,groupedByTime:La(u),groupedByProject:T}},[a,v,d]),R=i.useCallback(u=>{$(T=>{const x=new Set(T);return x.has(u)?x.delete(u):x.add(u),x})},[]),g=["today","yesterday","last7days","last30days","older"],j=["_none",...d.map(u=>u.id)];return e.jsxs(Ma,{isOpen:t,onToggle:s,title:"Chats",subtitle:`${a.length} conversation${a.length!==1?"s":""}`,icon:e.jsx(Fe,{className:"h-4 w-4"}),width:w,headerActions:e.jsxs("div",{className:"flex items-center",children:[d.length>0&&e.jsx(V,{variant:"ghost",size:"icon",onClick:()=>I(A==="time"?"project":"time"),className:"h-6 w-6 rounded hover:bg-muted/60","aria-label":A==="time"?"Group by project":"Group by time",children:A==="time"?e.jsx(At,{className:"h-3 w-3 text-muted-foreground","aria-hidden":"true"}):e.jsx(Fe,{className:"h-3 w-3 text-muted-foreground","aria-hidden":"true"})}),e.jsx(V,{variant:"ghost",size:"icon",onClick:l,className:"h-6 w-6 rounded hover:bg-muted/60","aria-label":"New chat",children:e.jsx(Tt,{className:"h-3 w-3 text-muted-foreground","aria-hidden":"true"})})]}),footer:e.jsxs(V,{variant:"outline",size:"sm",className:"w-full text-xs border-dashed border-border/50 hover:border-primary/30 hover:bg-primary/5",onClick:l,"aria-label":"Start new chat",children:[e.jsx(Tt,{className:"h-3 w-3 mr-1.5","aria-hidden":"true"}),"New Chat"]}),children:[e.jsx("div",{className:"px-3 py-3 border-b border-white/[0.03]",children:e.jsxs("div",{className:"relative group/search",children:[e.jsx(Ne,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground/30 group-focus-within/search:text-primary transition-colors","aria-hidden":"true"}),e.jsx($s,{placeholder:"Search conversations...","aria-label":"Search chat history",value:v,onChange:u=>y(u.target.value),className:"h-9 pl-10 pr-10 text-xs"}),v&&e.jsx("button",{onClick:()=>y(""),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 rounded-lg hover:bg-white/10 transition-colors","aria-label":"Clear search",children:e.jsx(mt,{className:"h-3.5 w-3.5 text-muted-foreground/40","aria-hidden":"true"})})]})}),e.jsx("div",{className:"flex-1 px-2 pb-2",children:K.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-60 text-center px-6",children:[e.jsx("div",{className:"w-16 h-16 rounded-[1.25rem] bg-gradient-to-br from-muted/20 to-muted/5 flex items-center justify-center mb-4 shadow-inner border border-white/5",children:e.jsx(fe,{className:"h-8 w-8 text-muted-foreground/20"})}),e.jsx("p",{className:"text-sm font-semibold text-muted-foreground/90 tracking-tight",children:v?"No results found":"Empty history"}),e.jsx("p",{className:"text-xs text-muted-foreground/60 mt-1.5 leading-relaxed",children:v?`We couldn't find any chats matching "${v}"`:"Start your first conversation to see it here."})]}):A==="time"?e.jsx("div",{className:"py-1 space-y-0.5",children:g.map(u=>{const T=h[u];if(T.length===0)return null;const x=N.has(u);return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>R(u),"aria-expanded":!x,"aria-label":`${x?"Expand":"Collapse"} ${Vt[u]} group`,className:"w-full flex items-center gap-2 px-3 py-2 text-[10px] font-bold uppercase tracking-[0.1em] text-muted-foreground/60 hover:text-muted-foreground/90 transition-colors",children:[e.jsx("div",{className:m("transition-transform duration-300",x?"-rotate-90":"rotate-0"),children:e.jsx(ke,{className:"h-3 w-3","aria-hidden":"true"})}),e.jsx("span",{className:"nav-group-label",children:Vt[u]}),e.jsx("div",{className:"flex-1 h-px bg-white/[0.03] mx-2"}),e.jsx("span",{className:"text-[10px] tabular-nums opacity-60",children:T.length})]}),!x&&e.jsx("div",{className:"space-y-0.5",children:T.map(C=>e.jsx(Ut,{conversation:C,isActive:n===C.id,onSelect:()=>r(C.id),onDelete:c?()=>c(C.id):void 0},C.id))})]},u)})}):e.jsx("div",{className:"py-1 space-y-0.5",children:j.map(u=>{const T=M[u]||[];if(T.length===0)return null;const x=N.has(u),C=d.find(Y=>Y.id===u),H=u==="_none"?"No Project":C?.name||"Unknown";return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>R(u),"aria-expanded":!x,"aria-label":`${x?"Expand":"Collapse"} ${H} group`,className:"w-full flex items-center gap-1.5 px-2 py-1.5 text-xs font-medium text-muted-foreground/50 hover:text-muted-foreground/70 rounded-md hover:bg-muted/30 transition-colors",children:[x?e.jsx($r,{className:"h-3 w-3"}):e.jsx(At,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:H}),e.jsx("span",{className:"ml-auto text-xs text-muted-foreground/40",children:T.length})]}),!x&&e.jsx("div",{className:"space-y-0.5",children:T.map(Y=>e.jsx(Ut,{conversation:Y,isActive:n===Y.id,onSelect:()=>r(Y.id),onDelete:c?()=>c(Y.id):void 0},Y.id))})]},u)})})})]})}function Ut({conversation:t,isActive:s,onSelect:a,onDelete:n}){const r=i.useMemo(()=>Ea(new Date(t.updatedAt)),[t.updatedAt]);return e.jsxs("div",{className:m("group relative flex items-center gap-3 px-3 py-3 rounded-xl transition-all duration-300 cursor-pointer mx-1",s?"bg-[#0a0a0b] text-white shadow-lg shadow-black/20 nav-item-active z-10":"text-muted-foreground hover:nav-item-hover"),onClick:a,children:[e.jsx("div",{className:m("w-9 h-9 rounded-xl flex items-center justify-center shrink-0 shadow-sm border transition-all duration-300",s?"bg-white/10 border-white/20 shadow-md text-white":"bg-white/[0.03] border-white/5"),children:e.jsx(fe,{className:m("h-4 w-4 transition-transform duration-500",s?"text-white scale-110":"text-muted-foreground/40 group-hover:scale-110")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:m("text-[13px] font-semibold truncate leading-tight tracking-tight",s?"text-white":"text-foreground/80"),children:t.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 text-[10px] font-medium tracking-wide",children:[e.jsxs("span",{className:m(s?"text-white/70":"text-muted-foreground/40"),children:[t.messageCount," messages"]}),e.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-current opacity-20"}),e.jsx("span",{className:m(s?"text-white/70":"text-muted-foreground/40"),children:r})]})]}),n&&e.jsxs(fr,{children:[e.jsx(br,{asChild:!0,children:e.jsx("button",{className:m("absolute right-1.5 top-1/2 -translate-y-1/2 p-1 rounded transition-all","opacity-0 group-hover:opacity-100","hover:bg-destructive/15 hover:text-destructive","focus:opacity-100 focus:outline-none"),onClick:l=>l.stopPropagation(),"aria-label":`Delete conversation ${t.title}`,children:e.jsx(ze,{className:"h-3 w-3","aria-hidden":"true"})})}),e.jsxs(vr,{onClick:l=>l.stopPropagation(),children:[e.jsxs(yr,{children:[e.jsxs(jr,{className:"flex items-center gap-2",children:[e.jsx(ze,{className:"h-5 w-5 text-destructive"}),"Delete Conversation"]}),e.jsxs(wr,{className:"pt-2",children:["Are you sure you want to delete ",e.jsxs("span",{className:"font-medium text-foreground",children:['"',t.title,'"']}),"? This will permanently remove all ",t.messageCount," messages and cannot be undone."]})]}),e.jsxs(Nr,{className:"mt-4",children:[e.jsx(kr,{className:"rounded-xl",children:"Cancel"}),e.jsx(Cr,{onClick:l=>{l.stopPropagation(),n()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90 rounded-xl",children:"Delete"})]})]})]})]})}const Oa=[{type:"anthropic",name:"Anthropic",description:"Claude Opus, Sonnet, Haiku",Logo:Fs,setupUrl:"https://console.anthropic.com/settings/keys",envVar:"ANTHROPIC_API_KEY",placeholder:"sk-ant-...",status:"stable"},{type:"openai",name:"OpenAI",description:"GPT-4.5, o1, o3-mini",Logo:zs,setupUrl:"https://platform.openai.com/api-keys",envVar:"OPENAI_API_KEY",placeholder:"sk-...",status:"stable"},{type:"azure",name:"Azure OpenAI",description:"Enterprise GPT-4, GPT-4o",Logo:Vs,setupUrl:"https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/OpenAI",envVar:"AZURE_OPENAI_API_KEY",placeholder:"Enter API key...",status:"stable"},{type:"google",name:"Google AI",description:"Gemini 2.5 Pro, Flash",Logo:Us,setupUrl:"https://makersuite.google.com/app/apikey",envVar:"GOOGLE_API_KEY",placeholder:"AIza...",status:"stable"},{type:"xai",name:"xAI (Grok)",description:"Grok 2, Grok 3",Logo:Ks,setupUrl:"https://console.x.ai/",envVar:"XAI_API_KEY",placeholder:"xai-...",status:"beta"},{type:"groq",name:"Groq",description:"Ultra-fast inference",Logo:qs,setupUrl:"https://console.groq.com/keys",envVar:"GROQ_API_KEY",placeholder:"gsk_...",status:"stable"},{type:"deepseek",name:"DeepSeek",description:"DeepSeek R1, Chat, Coder",Logo:Gs,setupUrl:"https://platform.deepseek.com/api_keys",envVar:"DEEPSEEK_API_KEY",placeholder:"sk-...",status:"beta"},{type:"openrouter",name:"OpenRouter",description:"300+ models, one API",Logo:Hs,setupUrl:"https://openrouter.ai/keys",envVar:"OPENROUTER_API_KEY",placeholder:"sk-or-...",status:"stable"},{type:"ollama",name:"Ollama",description:"Local models, free",Logo:Js,setupUrl:"https://ollama.ai/download",envVar:"OLLAMA_BASE_URL",placeholder:"http://localhost:11434",status:"stable"}];function $a({open:t,onOpenChange:s,providers:a,onSaveApiKey:n}){const r=As(),[l,c]=i.useState({}),[d,w]=i.useState({}),[p,v]=i.useState(null),[y,N]=i.useState(null),A=a.filter(h=>h.healthy).length,I=async h=>{const M=l[h];if(M){v(h);try{await n(h,M),c(R=>({...R,[h]:""})),N(null)}finally{v(null)}}},K=()=>{s(!1),r("/settings/ai-providers")};return e.jsx(Sr,{open:t,onOpenChange:s,children:e.jsxs(Tr,{className:"sm:max-w-lg p-0 gap-0 overflow-hidden",children:[e.jsx(Ir,{className:"p-6 pb-4 bg-gradient-to-b from-primary/5 to-transparent",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary/10 flex items-center justify-center",children:e.jsx(Ue,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(_r,{className:"text-lg",children:"Connect AI Providers"}),e.jsx(Ar,{className:"text-sm",children:A>0?e.jsxs("span",{className:"text-green-500",children:[A," connected"]}):"Add API keys to get started"})]})]})}),e.jsx("div",{className:"px-6 pb-4",children:e.jsx("div",{className:"grid grid-cols-2 gap-2",children:Oa.map(h=>{const R=a.find(j=>j.type===h.type)?.healthy,g=y===h.type;return e.jsxs("div",{className:m("relative rounded-xl border transition-all cursor-pointer",R?"border-green-500/40 bg-green-500/5":"border-border hover:border-primary/30 hover:bg-muted/30",g&&"col-span-2 bg-muted/50"),children:[e.jsxs("div",{role:"button",tabIndex:0,"aria-label":`Configure ${h.name}`,"aria-expanded":g,className:"flex items-center gap-3 p-3 focus-visible:ring-2 focus-visible:ring-primary outline-none",onClick:()=>N(g?null:h.type),onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),N(g?null:h.type))},children:[e.jsx("div",{className:m("h-9 w-9 rounded-lg flex items-center justify-center shrink-0",R?"bg-green-500/10":"bg-muted"),children:e.jsx(h.Logo,{className:m("h-5 w-5",R&&"text-green-600"),"aria-hidden":"true"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:h.name}),h.status==="beta"&&e.jsx("span",{className:"text-xs font-semibold px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-600 dark:text-amber-400 uppercase tracking-wide shrink-0",children:"Beta"}),h.status==="experimental"&&e.jsx("span",{className:"text-xs font-semibold px-1.5 py-0.5 rounded bg-indigo-500/20 text-indigo-600 dark:text-indigo-400 uppercase tracking-wide shrink-0",children:"Exp"}),R&&e.jsx(Bs,{className:"h-3.5 w-3.5 text-green-500 shrink-0","aria-hidden":"true"})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:h.description})]})]}),g&&e.jsx("div",{className:"px-3 pb-3 pt-1 border-t border-border/50",children:h.type==="azure"?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Azure OpenAI requires endpoint URL, deployment name, and API key."}),e.jsxs(V,{size:"sm",variant:"outline",onClick:j=>{j.stopPropagation(),s(!1),r("/settings/ai-providers")},className:"w-full gap-2",children:[e.jsx(at,{className:"h-3.5 w-3.5"}),"Configure in Settings"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx("input",{type:d[h.type]?"text":"password",placeholder:h.placeholder,value:l[h.type]||"",onChange:j=>c(u=>({...u,[h.type]:j.target.value})),onClick:j=>j.stopPropagation(),className:"w-full field pr-9",autoFocus:!0}),e.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),w(u=>({...u,[h.type]:!u[h.type]}))},className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground","aria-label":d[h.type]?"Hide API key":"Show API key",children:d[h.type]?e.jsx(Ws,{className:"h-4 w-4","aria-hidden":"true"}):e.jsx(Ys,{className:"h-4 w-4","aria-hidden":"true"})})]}),e.jsx(V,{size:"sm",onClick:j=>{j.stopPropagation(),I(h.type)},disabled:!l[h.type]||p===h.type,className:"px-3",children:p===h.type?e.jsx(ce,{className:"h-4 w-4 animate-spin"}):"Save"})]}),e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsxs("a",{href:h.setupUrl,target:"_blank",rel:"noopener noreferrer",onClick:j=>j.stopPropagation(),className:"text-xs text-primary hover:underline flex items-center gap-1",children:["Get API Key",e.jsx(Qs,{className:"h-3 w-3"})]}),h.type==="ollama"&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Run: ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ollama serve"})]})]})]})})]},h.type)})})}),e.jsxs("div",{className:"px-6 py-4 border-t bg-muted/30 flex items-center justify-between",children:[e.jsxs(V,{variant:"ghost",size:"sm",onClick:K,className:"text-muted-foreground hover:text-foreground gap-2",children:[e.jsx(at,{className:"h-4 w-4"}),"Manage All Providers"]}),e.jsx(V,{onClick:()=>s(!1),size:"sm",children:"Done"})]})]})})}function Fa({events:t,isActive:s,className:a}){const[n,r]=i.useState(!0),[l,c]=i.useState(!1),[d,w]=i.useState([]),[p,v]=i.useState(null),[y,N]=i.useState(null),[$,A]=i.useState(0),[I,K]=i.useState(null),h=typeof window<"u"&&localStorage.getItem("profclaw-dev-mode")==="true";if(i.useEffect(()=>{const g=[];let j=0;const u=new Map;for(const T of t)switch(T.type){case"thinking:start":case"thinking:update":v(T.data.message||"Thinking...");break;case"thinking:end":v(null);break;case"step:start":{j=T.data.step,g.find(C=>C.step===j)||g.push({step:j,toolCalls:[],complete:!1});break}case"step:complete":{const x=T.data,C=g.find(H=>H.step===x.step);C&&(C.complete=!0);break}case"tool:call":{const x=T.data,C={id:x.id,name:x.name,args:x.args,startTime:T.timestamp,status:"pending"};u.set(x.id,C);const H=g.find(Y=>Y.step===x.step);H&&H.toolCalls.push(C);break}case"tool:result":{const x=T.data,C=u.get(x.id);C&&(C.result=x.result,C.status=x.status==="executed"?"success":"error",C.error=x.error,C.duration=x.duration);break}case"summary":{const x=T.data;N(x.summary);break}case"complete":{const x=T.data;A(x.totalTokens);break}case"error":{const x=T.data;K(x.message);break}}w(g)},[t]),i.useEffect(()=>{if(!s&&(y||I)){const g=setTimeout(()=>r(!1),2e3);return()=>clearTimeout(g)}},[s,y,I]),t.length===0&&!s)return null;const M=d.reduce((g,j)=>g+j.toolCalls.length,0),R=d.filter(g=>g.complete).length;return e.jsxs("div",{className:m("rounded-xl bg-card/50 backdrop-blur-sm overflow-hidden transition-all duration-300",s?"ring-1 ring-blue-500/30 shadow-sm shadow-blue-500/10":I?"ring-1 ring-destructive/30":"bg-muted/30",a),children:[e.jsxs("button",{onClick:()=>r(!n),className:m("w-full flex items-center gap-3 text-left hover:bg-muted/30 transition-colors",s?"p-3 animate-pulse":h?"p-3":"px-3 py-2"),children:[n?e.jsx(ke,{className:"h-4 w-4 text-muted-foreground shrink-0"}):e.jsx(Ce,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:s?e.jsxs(e.Fragment,{children:[e.jsx(Ke,{className:"h-4 w-4 text-blue-500 animate-pulse shrink-0"}),e.jsx("span",{className:"text-sm font-medium truncate",children:p||`Executing step ${R+1}...`})]}):I?e.jsxs(e.Fragment,{children:[e.jsx(xt,{className:"h-4 w-4 text-destructive shrink-0"}),e.jsx("span",{className:"text-sm font-medium text-destructive truncate",children:"Execution failed"})]}):h?e.jsxs(e.Fragment,{children:[e.jsx(Ue,{className:"h-4 w-4 text-green-400 shrink-0"}),e.jsxs("span",{className:"text-sm font-medium truncate",children:["Completed in ",R," step",R!==1?"s":""]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-green-500 shrink-0"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Done"})]})}),(h||s)&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground shrink-0",children:[M>0&&e.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-full bg-muted/50",children:[e.jsx(qe,{className:"h-3 w-3"}),M]}),$>0&&e.jsxs("span",{className:"px-2 py-0.5 rounded-full bg-muted/50",children:[$.toLocaleString()," tokens"]})]})]}),n&&e.jsxs("div",{className:"border-t border-border/20 p-3 space-y-3",children:[I&&e.jsx("div",{className:"p-3 rounded-lg bg-destructive/10 border border-destructive/20 text-sm text-destructive",children:I}),y&&!I&&e.jsx("div",{className:"p-3 rounded-lg bg-green-500/10 border border-green-500/20 text-sm",children:y}),d.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(V,{variant:"ghost",size:"sm",className:"text-xs h-6 px-2",onClick:()=>c(!l),children:l?"Hide details":"Show details"}),l&&e.jsx("div",{className:"space-y-2 pl-2 border-l-2 border-blue-500/20",children:d.map(g=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[g.complete?e.jsx(Re,{className:"h-3.5 w-3.5 text-green-400"}):e.jsx(ce,{className:"h-3.5 w-3.5 text-blue-500 animate-spin"}),e.jsxs("span",{className:"font-medium",children:["Step ",g.step]}),e.jsxs("span",{className:"text-muted-foreground text-xs",children:[g.toolCalls.length," tool call",g.toolCalls.length!==1?"s":""]})]}),g.toolCalls.length>0&&e.jsx("div",{className:"ml-5 space-y-1",children:g.toolCalls.map(j=>e.jsx(za,{toolCall:j},j.id))})]},g.step))})]}),s&&!p&&d.length===0&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ce,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:"Initializing agent..."})]})]})]})}function za({toolCall:t}){const[s,a]=i.useState(!1);return e.jsxs("div",{className:"rounded-lg bg-muted/30 overflow-hidden",children:[e.jsxs("button",{onClick:()=>a(!s),className:"w-full flex items-center gap-2 p-2 text-left hover:bg-muted/50 transition-colors",children:[s?e.jsx(ke,{className:"h-3 w-3 text-muted-foreground"}):e.jsx(Ce,{className:"h-3 w-3 text-muted-foreground"}),e.jsx(qe,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-mono flex-1 truncate",children:t.name}),t.status==="pending"?e.jsx(ce,{className:"h-3 w-3 text-blue-500 animate-spin"}):t.status==="success"?e.jsx(Re,{className:"h-3 w-3 text-green-400"}):e.jsx(xt,{className:"h-3 w-3 text-destructive"}),t.duration&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.duration,"ms"]})]}),s&&e.jsxs("div",{className:"border-t border-border/20 p-2 space-y-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Arguments"}),e.jsx("pre",{className:"text-xs bg-background/50 rounded p-2 overflow-x-auto",children:JSON.stringify(t.args,null,2)})]}),t.result!==void 0&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Result"}),e.jsx("pre",{className:"text-xs bg-background/50 rounded p-2 overflow-x-auto max-h-32 overflow-y-auto",children:typeof t.result=="string"?t.result:JSON.stringify(t.result,null,2)})]}),t.error&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium text-destructive mb-1",children:"Error"}),e.jsx("pre",{className:"text-xs bg-destructive/10 rounded p-2 overflow-x-auto text-destructive",children:t.error})]})]})]})}const Va={idle:"Idle",listening:"Listening...",recording:"Recording...",transcribing:"Transcribing...",sending:"Sending...",speaking:"Speaking..."};function Ua({state:t,isCalibrating:s}){if(s)return e.jsx(ce,{className:"h-5 w-5 animate-spin text-amber-500"});switch(t){case"listening":return e.jsx(Mt,{className:"h-5 w-5 text-green-500"});case"recording":return e.jsx(Wt,{className:"h-5 w-5 text-red-500"});case"transcribing":return e.jsx(ce,{className:"h-5 w-5 animate-spin text-muted-foreground"});case"sending":return e.jsx(Zt,{className:"h-5 w-5 text-primary"});case"speaking":return e.jsx(rr,{className:"h-5 w-5 animate-pulse text-blue-500"});default:return e.jsx(Mt,{className:"h-5 w-5 text-muted-foreground"})}}function Ka({energy:t,isRecording:s}){const a=Math.min(1,Math.max(0,t)),n=s?"bg-red-500":"bg-green-500",r=a>.005;return e.jsx("div",{className:"flex items-end justify-center gap-1 h-5",children:[1,2,3].map(l=>e.jsx("div",{className:m("w-1 rounded-full transition-all duration-75 origin-bottom",n,r?"opacity-100":"opacity-30"),style:{height:`${Math.max(4,a*20)}px`,animation:r?`eq-bounce-${l} ${.4+l*.1}s ease-in-out infinite`:"none"}},l))})}function qa({state:t,energy:s,lastTranscription:a,isCalibrating:n,noiseFloor:r,selectedVoice:l,onVoiceChange:c,onStop:d,ttsAvailable:w=!0}){const p=t==="recording",[v,y]=i.useState(!1),[N,$]=i.useState(!0),{data:A}=oe({queryKey:["talk-mode-voices"],queryFn:async()=>{const M=await fetch(`${ar}/api/voice/voices`);return M.ok?M.json():{voices:[]}},staleTime:300*1e3,retry:1}),I=A?.voices??[];i.useEffect(()=>{if(!a)return;$(!0);const M=setTimeout(()=>$(!1),5e3);return()=>clearTimeout(M)},[a]);const K=i.useCallback(()=>{y(!0),setTimeout(()=>d(),200)},[d]),h=/mac/i.test(navigator.platform)?"⌘":"Ctrl";return e.jsxs("div",{className:m("fixed bottom-24 right-6 z-50","w-72 rounded-2xl border border-border/60 bg-background/80 p-4 shadow-xl","backdrop-blur-md",v?"animate-[talk-mode-out_0.2s_ease-in_forwards]":"animate-[talk-mode-in_0.3s_ease-out]"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:m("relative flex items-center justify-center",p&&"animate-[recording-ring_1.5s_ease-in-out_infinite]"),style:{borderRadius:"50%"},children:e.jsx(Ua,{state:t,isCalibrating:n})}),e.jsx("span",{className:"text-sm font-medium",children:n?"Calibrating...":Va[t]})]}),e.jsx("button",{type:"button",onClick:K,className:m("flex h-7 w-7 items-center justify-center rounded-full","bg-muted text-muted-foreground transition-colors","hover:bg-destructive/10 hover:text-destructive","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":"Stop Talk Mode",children:e.jsx(mt,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[e.jsx(Ka,{energy:s,isRecording:p}),e.jsx("div",{className:"h-2 flex-1 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:m("h-full rounded-full transition-all duration-75",p?"bg-red-500":"bg-green-500"),style:{width:`${Math.min(1,Math.max(0,s))*100}%`}})})]}),!w&&e.jsx("p",{className:"mt-2 text-[11px] text-amber-400/80 bg-amber-500/10 rounded-lg px-2 py-1",children:"TTS not configured - responses won't be spoken"}),!n&&r>0&&e.jsxs("p",{className:"mt-1 text-[10px] text-muted-foreground/60",children:["Noise floor: ",r.toFixed(4)]}),a.length>0&&e.jsx("p",{className:m("mt-3 line-clamp-2 text-xs text-muted-foreground transition-opacity duration-500",N?"opacity-100":"opacity-0"),children:a}),I.length>0&&e.jsx("div",{className:"mt-3 border-t border-border/40 pt-3",children:e.jsxs(et,{value:l,onValueChange:c,children:[e.jsx(tt,{className:"h-8 text-xs",children:e.jsx(st,{placeholder:"Default voice"})}),e.jsxs(rt,{children:[e.jsx(_e,{value:"default",children:"Default voice"}),I.map(M=>e.jsx(_e,{value:M.id,children:M.name},M.id))]})]})}),e.jsxs("p",{className:"mt-2 text-[10px] text-muted-foreground/40 text-right",children:[h,"+Shift+V"]})]})}const Ga=[{id:"deploy",label:"Deploy",Icon:ir},{id:"review",label:"Review",Icon:zr},{id:"debug",label:"Debug",Icon:Xt},{id:"research",label:"Research",Icon:Ne},{id:"test",label:"Test",Icon:nr},{id:"refactor",label:"Refactor",Icon:ut}];function Ha({onWorkflowSelect:t,disabled:s=!1,className:a}){return e.jsx("div",{className:m("hidden md:flex items-center gap-1.5 overflow-x-auto scrollbar-none py-1",a),children:Ga.map(({id:n,label:r,Icon:l})=>e.jsxs(V,{variant:"outline",size:"sm",disabled:s,onClick:()=>t(n),className:m("flex items-center gap-1.5 h-7 px-3 rounded-full text-xs font-medium shrink-0","text-muted-foreground hover:text-foreground","border-border/50 hover:border-border","transition-colors duration-150"),children:[e.jsx(l,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:r})]},n))})}function Ja(t){const s=t.toLowerCase();return s.includes("search")||s.includes("find")?Ne:s.includes("web")||s.includes("http")||s.includes("fetch")?ot:s.includes("file")||s.includes("read")||s.includes("write")?lt:s.includes("run")||s.includes("exec")||s.includes("bash")?le:s.includes("db")||s.includes("query")||s.includes("sql")?nt:qe}function Ba(t,s){const n=(s??Date.now())-t;return n<1e3?`${n}ms`:`${(n/1e3).toFixed(1)}s`}function Wa({status:t}){return t==="running"?e.jsxs("span",{className:"relative flex h-3 w-3 shrink-0 mt-0.5",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-blue-400 opacity-60"}),e.jsx("span",{className:"relative inline-flex rounded-full h-3 w-3 bg-blue-500"})]}):t==="completed"?e.jsx(Re,{className:"h-3.5 w-3.5 text-green-400 shrink-0 mt-0.5"}):t==="failed"?e.jsx(Ve,{className:"h-3.5 w-3.5 text-destructive shrink-0 mt-0.5"}):t==="retried"?e.jsx(Ve,{className:"h-3.5 w-3.5 text-amber-400 shrink-0 mt-0.5"}):e.jsx("span",{className:"h-3 w-3 rounded-full border-2 border-muted-foreground/40 shrink-0 mt-0.5"})}function Ya({call:t,isLast:s}){const a=Ja(t.toolName),n=t.status==="running",r=t.status==="failed";return e.jsxs("li",{className:"relative flex gap-3 pb-3 last:pb-0",children:[!s&&e.jsx("span",{className:"absolute left-[5px] top-4 bottom-0 w-px bg-border/40","aria-hidden":"true"}),e.jsx(Wa,{status:t.status}),e.jsxs("div",{className:"flex-1 min-w-0 -mt-0.5",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(a,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),e.jsx("span",{className:m("text-xs font-mono truncate",r&&"text-destructive",n&&"text-foreground font-medium"),children:t.toolName}),e.jsxs("span",{className:"flex items-center gap-1 text-xs text-muted-foreground shrink-0",children:[e.jsx(ie,{className:"h-3 w-3"}),Ba(t.startedAt,t.completedAt)]}),t.retryCount!==void 0&&t.retryCount>0&&e.jsxs(pt,{variant:"outline",className:"h-4 px-1.5 text-[10px] border-amber-500/30 text-amber-500 bg-amber-500/10",children:["retry ",t.retryCount]})]}),r&&t.error&&e.jsx("p",{className:"mt-0.5 text-xs text-destructive/80 truncate",children:t.error})]})]})}function Qa({toolCalls:t,isExecuting:s,className:a}){const[n,r]=i.useState(!1);if(t.length===0&&!s)return null;const l=t.filter(w=>w.status==="completed").length,c=t.filter(w=>w.status==="failed").length,d=t.find(w=>w.status==="running");return e.jsxs("div",{className:m("rounded-xl border border-border/40 bg-card/40 backdrop-blur-sm overflow-hidden",s&&"ring-1 ring-blue-500/20",a),children:[e.jsxs("button",{type:"button",onClick:()=>r(w=>!w),className:"w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-muted/20 transition-colors",children:[n?e.jsx(ke,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}):e.jsx(Ce,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),s?e.jsx(ce,{className:"h-3.5 w-3.5 text-blue-500 animate-spin shrink-0"}):c>0?e.jsx(Ve,{className:"h-3.5 w-3.5 text-destructive shrink-0"}):e.jsx(Re,{className:"h-3.5 w-3.5 text-green-400 shrink-0"}),e.jsx("span",{className:"text-xs font-medium flex-1 truncate",children:s&&d?`Running ${d.toolName}...`:s?"Executing tools...":`${t.length} tool call${t.length!==1?"s":""}`}),e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground shrink-0",children:[l>0&&e.jsxs("span",{className:"text-green-500",children:[l," done"]}),c>0&&e.jsxs("span",{className:"text-destructive",children:[c," failed"]})]})]}),n&&t.length>0&&e.jsx("div",{className:"border-t border-border/30 px-3 pt-3 pb-2",children:e.jsx("ul",{className:"space-y-0",children:t.map((w,p)=>e.jsx(Ya,{call:w,isLast:p===t.length-1},w.id))})}),n&&t.length===0&&s&&e.jsx("div",{className:"border-t border-border/30 px-3 py-3",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}),e.jsx("span",{children:"Waiting for tool calls..."})]})}),n&&e.jsx("div",{className:"px-3 pb-2",children:e.jsx(V,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs text-muted-foreground",onClick:()=>r(!1),children:"Collapse"})})]})}const Xa=[{id:"ask-everything",label:"Ask Everything",description:"Approve every tool call before execution.",Icon:ht,iconClass:"text-muted-foreground",activeClass:"bg-muted text-foreground border-border"},{id:"ask-dangerous",label:"Ask Dangerous",description:"Auto-approve safe tools. Prompt before write, delete, or network operations.",Icon:es,iconClass:"text-blue-500",activeClass:"bg-blue-500/10 text-blue-600 border-blue-500/30"},{id:"semi-autonomous",label:"Semi-Autonomous",description:"Auto-approve most tools. Only prompt for irreversible or high-impact actions.",Icon:Yt,iconClass:"text-amber-500",activeClass:"bg-amber-500/10 text-amber-600 border-amber-500/30"},{id:"full-autonomous",label:"Full Autonomous",description:"No approval prompts. The agent executes all tools without interruption.",Icon:Mr,iconClass:"text-destructive",activeClass:"bg-destructive/10 text-destructive border-destructive/30",warn:!0}];function Za({level:t,onChange:s,disabled:a=!1,className:n}){return e.jsxs("div",{className:m("space-y-2",n),children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground select-none",children:[e.jsx(ht,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Autonomy Level"})]}),e.jsx("div",{role:"radiogroup","aria-label":"Autonomy level",className:"flex gap-1.5 flex-wrap",children:Xa.map(r=>{const l=t===r.id,{Icon:c}=r;return e.jsxs(ue,{children:[e.jsx(me,{asChild:!0,children:e.jsxs("button",{type:"button",role:"radio","aria-checked":l,disabled:a,onClick:()=>s(r.id),className:m("flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-medium","border transition-all duration-150 select-none outline-none","focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1","disabled:opacity-50 disabled:cursor-not-allowed",l?r.activeClass:"bg-transparent text-muted-foreground border-border/50 hover:border-border hover:text-foreground"),children:[e.jsx(c,{className:m("h-3.5 w-3.5 shrink-0",l?"":r.iconClass)}),e.jsx("span",{children:r.label}),r.warn&&l&&e.jsx(pt,{variant:"outline",className:"ml-0.5 h-4 px-1.5 text-[10px] border-destructive/40 text-destructive bg-destructive/10",children:"Caution"})]})}),e.jsx(xe,{side:"top",children:e.jsx("p",{className:"text-xs max-w-48",children:r.description})})]},r.id)})})]})}const ss="profclaw-talk-mode-config",rs="profclaw-talk-mode-voice",en=300*1e3,tn="/audio-worklets/vad-processor.js",$e={enabled:!1,autoSend:!0,autoTts:!0,continuous:!0,speechThreshold:.01,silenceDuration:1500};function sn(){try{const t=localStorage.getItem(ss);if(!t)return $e;const s=JSON.parse(t);return typeof s!="object"||s===null?$e:{...$e,...s}}catch{return $e}}function rn(t){try{localStorage.setItem(ss,JSON.stringify(t))}catch{}}function an(){try{return localStorage.getItem(rs)??""}catch{return""}}function nn(){return/mac/i.test(navigator.platform)}function on(t={}){const{onTranscription:s,onSend:a}=t,[n,r]=i.useState("idle"),[l,c]=i.useState(0),[d,w]=i.useState(""),[p,v]=i.useState(!1),[y,N]=i.useState(0),[$,A]=i.useState(an),[I,K]=i.useState(sn),h=i.useRef(null),M=i.useRef(null),R=i.useRef(null),g=i.useRef(null),j=i.useRef(null),u=i.useRef([]),T=i.useRef(null),x=i.useRef(null),C=i.useRef(I);C.current=I;const H=i.useRef(n);H.current=n;const Y=i.useRef($);Y.current=$;const P=i.useCallback(k=>{K(_=>{const G={..._,...k};return rn(G),G})},[]),X=i.useCallback(k=>{A(k);try{localStorage.setItem(rs,k)}catch{}},[]),q=i.useCallback(()=>{T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{H.current==="listening"&&z()},en)},[]),te=i.useCallback(()=>{T.current&&(clearTimeout(T.current),T.current=null)},[]),se=i.useCallback(async k=>{if(k.trim()){R.current&&R.current.disconnect(),r("speaking");try{const _=Y.current,G={text:k};_&&_!=="default"&&(G.voice=_);const J=await fetch("/api/voice/synthesize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(G)});if(!J.ok)throw new Error(`Synthesize failed: ${J.status}`);const ae=await J.blob(),Ee=URL.createObjectURL(ae),ye=new Audio(Ee);x.current=ye,await new Promise(de=>{ye.onended=()=>de(),ye.onerror=()=>de(),ye.play().catch(()=>de())}),URL.revokeObjectURL(Ee),x.current=null}finally{g.current&&R.current&&h.current&&g.current.connect(R.current),C.current.continuous&&H.current==="speaking"?(r("listening"),q()):r("idle")}}},[q]),be=i.useCallback(async k=>{r("transcribing");try{const _=new FormData;_.append("audio",k,"recording.webm");const G=await fetch("/api/voice/transcribe",{method:"POST",body:_});if(!G.ok)throw new Error(`Transcribe failed: ${G.status}`);const J=await G.json();if(typeof J!="object"||J===null||!("text"in J)||typeof J.text!="string")throw new Error("Invalid transcription response");const ae=J.text.trim();if(!ae){r("listening"),q();return}if(w(ae),s?.(ae),C.current.autoSend&&a){r("sending");try{await a(ae)}finally{r("listening"),q()}}else r("listening"),q()}catch{r("listening"),q()}},[s,a,q]),ve=i.useCallback(()=>{if(!M.current)return;u.current=[];const k=new MediaRecorder(M.current,{mimeType:MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":"audio/webm"});k.ondataavailable=_=>{_.data.size>0&&u.current.push(_.data)},k.onstop=()=>{const _=new Blob(u.current,{type:k.mimeType});u.current=[],be(_)},k.start(),j.current=k,r("recording")},[be]),Se=i.useCallback(()=>{const k=j.current;k&&k.state!=="inactive"&&k.stop(),j.current=null},[]),ee=i.useCallback(k=>{const _=k.data;if(typeof _!="object"||_===null)return;const{type:G}=_;if(G==="energy"){const J=_.value;typeof J=="number"&&c(J)}else if(G==="calibrated"){const J=_.noiseFloor;typeof J=="number"&&N(J),v(!1)}else G==="speech-start"?H.current==="listening"&&(te(),ve()):G==="speech-end"&&H.current==="recording"&&(Se(),q())},[ve,Se,te,q]),z=i.useCallback(()=>{te(),x.current&&(x.current.pause(),x.current.onended=null,x.current.onerror=null,x.current=null);const k=j.current;k&&k.state!=="inactive"&&k.stop(),j.current=null,u.current=[],R.current&&(R.current.port.onmessage=null,R.current.disconnect(),R.current=null),g.current&&(g.current.disconnect(),g.current=null),h.current&&(h.current.close(),h.current=null),M.current&&(M.current.getTracks().forEach(_=>_.stop()),M.current=null),c(0),v(!1),N(0),r("idle")},[te]),Te=i.useCallback(async()=>{if(H.current==="idle")try{const k=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0}});M.current=k;const _=new AudioContext;h.current=_,await _.audioWorklet.addModule(tn),R.current?.port&&(R.current.port.onmessage=null),v(!0),N(0);const G=new AudioWorkletNode(_,"vad-processor",{processorOptions:{speechThreshold:C.current.speechThreshold,silenceDuration:C.current.silenceDuration}});G.port.onmessage=ee,R.current=G;const J=_.createMediaStreamSource(k);g.current=J,J.connect(G),r("listening"),q(),window.dispatchEvent(new CustomEvent("profclaw:talk-mode",{detail:{state:"listening"}}))}catch{z()}},[ee,q,z]),he=i.useCallback(()=>{H.current==="idle"?Te():z()},[Te,z]);return i.useEffect(()=>{const k=_=>{(nn()?_.metaKey:_.ctrlKey)&&_.shiftKey&&_.key.toLowerCase()==="v"&&(_.preventDefault(),he())};return window.addEventListener("keydown",k),()=>{window.removeEventListener("keydown",k)}},[he]),i.useEffect(()=>{const k=()=>he(),_=()=>z();return window.addEventListener("profclaw:talk-mode-toggle",k),window.addEventListener("profclaw:talk-mode-stop",_),()=>{window.removeEventListener("profclaw:talk-mode-toggle",k),window.removeEventListener("profclaw:talk-mode-stop",_)}},[he,z]),i.useEffect(()=>{window.dispatchEvent(new CustomEvent("profclaw:talk-mode",{detail:{state:n}}))},[n]),i.useEffect(()=>()=>{z()},[]),{state:n,energy:l,lastTranscription:d,isCalibrating:p,noiseFloor:y,selectedVoice:$,config:I,updateConfig:P,setSelectedVoice:X,start:Te,stop:z,toggle:he,speakResponse:se}}const Kt={exec:le,read_file:Z,write_file:Z,search_files:Z,grep:Z,git_status:Z,git_commit:Z,git_push:Z,system_info:Ze,default:le};function ln({approval:t,onDecision:s,isLoading:a=!1}){const[n,r]=i.useState(null),[l,c]=i.useState(null);i.useEffect(()=>{if(!t.expiresAt)return;const N=()=>{const A=Math.max(0,t.expiresAt-Date.now());r(A),A===0&&s(t.id,"deny")};N();const $=setInterval(N,1e3);return()=>clearInterval($)},[t.expiresAt,t.id,s]);const d=N=>{c(N),s(t.id,N)},w=Kt[t.toolName]||Kt.default,p=t.securityLevel==="dangerous",v=N=>{const $=Math.floor(N/1e3),A=Math.floor($/60),I=$%60;return`${A}:${I.toString().padStart(2,"0")}`},y=N=>Object.entries(N).map(([$,A])=>{const I=typeof A=="string"?A:JSON.stringify(A),K=I.length>100?I.slice(0,100)+"...":I;return`${$}: ${K}`}).join(`
7
+ `);return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"w-full max-w-lg mx-4 glass-heavy rounded-2xl shadow-2xl overflow-hidden",children:[e.jsxs("div",{className:m("px-6 py-4 border-b border-gray-200 dark:border-border flex items-center gap-3",p?"bg-red-50 dark:bg-red-500/10":"bg-yellow-50 dark:bg-yellow-500/10"),children:[p?e.jsx(Yt,{className:"h-6 w-6 text-red-500"}):e.jsx(ht,{className:"h-6 w-6 text-yellow-500"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-foreground",children:"Tool Approval Required"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-muted-foreground",children:p?"This tool requires explicit approval":"Review before executing"})]}),n!==null&&e.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-muted-foreground",children:[e.jsx(ie,{className:"h-4 w-4"}),e.jsx("span",{className:m(n<3e4&&"text-red-500 font-medium"),children:v(n)})]})]}),e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:m("p-3 rounded-lg",p?"bg-red-100 dark:bg-red-500/10":"bg-yellow-100 dark:bg-yellow-500/10"),children:e.jsx(w,{className:m("h-6 w-6",p?"text-red-500":"text-yellow-500")})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold text-gray-900 dark:text-foreground",children:t.toolName}),e.jsx("span",{className:m("px-2 py-0.5 text-xs font-medium rounded-full",p?"bg-red-100 dark:bg-red-500/20 text-red-600 dark:text-red-500":"bg-yellow-100 dark:bg-yellow-500/20 text-yellow-700 dark:text-yellow-400"),children:t.securityLevel})]}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-muted-foreground mt-1",children:p?"This tool can modify files, execute commands, or access sensitive data.":"This tool may access files or execute commands."})]})]}),(t.command||Object.keys(t.params).length>0)&&e.jsxs("div",{className:"bg-gray-100 dark:bg-muted/50 rounded-lg p-4 border border-gray-200 dark:border-border",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2",children:t.command?"Command":"Parameters"}),e.jsx("pre",{className:"text-sm font-mono whitespace-pre-wrap break-all text-gray-800 dark:text-foreground",children:t.command||y(t.params)})]}),p&&e.jsxs("div",{className:"flex items-start gap-3 p-3 bg-red-50 dark:bg-red-500/10 rounded-lg border border-red-200 dark:border-red-500/20",children:[e.jsx(Xs,{className:"h-5 w-5 text-red-500 shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-medium text-red-600 dark:text-red-500",children:"Security Warning"}),e.jsx("p",{className:"text-gray-600 dark:text-muted-foreground mt-1",children:"This operation could potentially harm your system or expose sensitive data. Only approve if you trust the source."})]})]})]}),e.jsxs("div",{className:"px-6 py-4 bg-gray-50 dark:bg-muted/30 border-t border-gray-200 dark:border-border flex items-center justify-between gap-3",children:[e.jsxs(V,{variant:"ghost",onClick:()=>d("deny"),disabled:a,className:"text-red-600 dark:text-red-500 hover:text-red-700 dark:hover:text-red-600 hover:bg-red-100 dark:hover:bg-red-500/10",children:[e.jsx(Ve,{className:"h-4 w-4 mr-2"}),"Deny"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(V,{variant:"outline",onClick:()=>d("allow-always"),disabled:a,className:"border-green-300 dark:border-green-500/30 hover:bg-green-100 dark:hover:bg-green-500/10 text-green-700 dark:text-foreground",children:[e.jsx(es,{className:"h-4 w-4 mr-2 text-green-600 dark:text-green-500"}),"Allow Always"]}),e.jsx(V,{onClick:()=>d("allow-once"),disabled:a,className:m(p?"bg-red-500 hover:bg-red-600 text-white":"bg-yellow-500 hover:bg-yellow-600 text-gray-900"),children:a&&l==="allow-once"?e.jsx("span",{className:"animate-pulse",children:"Processing..."}):e.jsxs(e.Fragment,{children:[e.jsx(Re,{className:"h-4 w-4 mr-2"}),"Allow Once"]})})]})]})]})})}function cn(){const[t,s]=i.useState([]),[a,n]=i.useState(null),r=i.useCallback(async(l,c)=>{await navigator.clipboard.writeText(l),n(c),setTimeout(()=>n(null),2e3)},[]);return{messages:t,setMessages:s,copiedId:a,handleCopy:r}}function dn({onMessagesLoaded:t,onNewChat:s,selectedPreset:a,onPresetChange:n}){const r=qt(),[l,c]=Ms(),[d,w]=i.useState(null),p=i.useRef(null),v=i.useCallback(u=>{w(u),p.current=u,u?c({c:u},{replace:!0}):c({},{replace:!0})},[c]),{data:y,refetch:N}=oe({queryKey:["chat","conversations","recent"],queryFn:()=>Q.chat.conversations.recent(10),staleTime:1e4}),$=y?.conversations||[],A=Ie({mutationFn:u=>Q.chat.conversations.create(u),onSuccess:u=>{v(u.conversation.id),N()}}),I=i.useCallback(async u=>{try{const T=await Q.chat.conversations.get(u);w(u),p.current=u,n(T.conversation.presetId),t(T.messages.map(x=>({id:x.id,role:x.role,content:x.content,timestamp:x.createdAt,usage:x.tokenUsage?{promptTokens:x.tokenUsage.prompt,completionTokens:x.tokenUsage.completion,totalTokens:x.tokenUsage.total,cost:x.cost}:void 0,toolCalls:x.toolCalls?.map(C=>({id:C.id,name:C.name,arguments:C.arguments||{},result:C.result,status:C.status||"success",duration:C.duration}))})))}catch{F.error("Failed to load conversation")}},[t,n]),K=i.useCallback(()=>{v(null),s(),F.success("Started new chat")},[v,s]),h=i.useCallback(u=>{I(u)},[I]),M=i.useCallback(async u=>{try{await Q.chat.conversations.delete(u),N(),d===u&&K(),F.success("Conversation deleted")}catch{F.error("Failed to delete conversation")}},[d,N,K]),R=i.useCallback(async()=>{if(d)try{const u=await Q.chat.conversations.exportConversation(d),T=new Blob([JSON.stringify(u,null,2)],{type:"application/json"}),x=URL.createObjectURL(T),C=document.createElement("a");C.href=x,C.download=`chat-${u.conversation.title.replace(/[^a-z0-9]/gi,"-").toLowerCase()}-${new Date().toISOString().slice(0,10)}.json`,C.click(),URL.revokeObjectURL(x),F.success("Conversation exported")}catch{F.error("Failed to export conversation")}},[d]),g=i.useCallback(async()=>d||(await A.mutateAsync({presetId:a})).conversation.id,[d,A,a]),j=i.useCallback(()=>{N(),r.invalidateQueries({queryKey:["chat","memory"]})},[N,r]);return{conversationId:d,setConversationId:v,conversations:$,refetchConversations:N,createConversation:A,loadConversation:I,handleNewChat:K,handleSelectConversation:h,handleDeleteConversation:M,handleExportConversation:R,ensureConversation:g,invalidateAfterSend:j,urlConversationIdRef:p,searchParams:l}}function Hn(){const t=qt(),s={model:"profclaw-chat-model",preset:"profclaw-chat-preset",sidebarOpen:"profclaw-chat-sidebar-open",agentMode:"profclaw-chat-agent-mode"},[a,n]=i.useState(""),[r,l]=i.useState(()=>typeof window<"u"&&localStorage.getItem(s.model)||""),[c,d]=i.useState(()=>typeof window<"u"&&localStorage.getItem(s.preset)||"profclaw-assistant"),[w,p]=i.useState(!1),[v,y]=i.useState(!1),[N,$]=i.useState(!1),[A,I]=i.useState([]),[K,h]=i.useState([]),[M,R]=i.useState(()=>{if(typeof window<"u"){const o=localStorage.getItem(s.sidebarOpen);return o!==null?JSON.parse(o):!0}return!0}),[g,j]=i.useState(()=>{if(typeof window<"u"){const o=localStorage.getItem(s.agentMode);return o!==null?JSON.parse(o):!1}return!1}),[u,T]=i.useState("ask-dangerous"),[x,C]=i.useState(!1),[H,Y]=i.useState([]),[P,X]=i.useState(!1),[q,te]=i.useState(!1),se=i.useMemo(()=>{const o=new Map;for(const f of H){if(f.type==="tool:call"){const b=f.data,S=b.id??b.toolCallId??crypto.randomUUID(),E=b.name??b.toolName??"unknown";o.set(S,{id:S,toolName:E,status:"running",startedAt:Date.now()})}if(f.type==="tool:result"){const b=f.data,S=b.id??b.toolCallId??"",E=o.get(S);E&&(E.status=b.success===!1?"failed":"completed",E.completedAt=Date.now(),b.error&&(E.error=b.error))}}return Array.from(o.values())},[H]),be=i.useRef(null),ve=i.useRef([]),Se=i.useRef(null),{messages:ee,setMessages:z,copiedId:Te,handleCopy:he}=cn(),{conversationId:k,conversations:_,loadConversation:G,handleNewChat:J,handleSelectConversation:ae,handleDeleteConversation:Ee,handleExportConversation:ye,ensureConversation:de,invalidateAfterSend:je,urlConversationIdRef:gt,searchParams:Ge}=dn({onMessagesLoaded:z,onNewChat:i.useCallback(()=>{z([]),h([])},[z]),selectedPreset:c,onPresetChange:d}),De=i.useCallback(()=>{J()},[J]),as=i.useCallback(async o=>{if(k)try{await Q.chat.conversations.deleteMessage(k,o),z(f=>f.filter(b=>b.id!==o)),je()}catch{F.error("Failed to delete message")}},[k,z,je]),{data:Le}=oe({queryKey:["chat","models"],queryFn:()=>Q.chat.models(),staleTime:6e4}),{data:Pe,refetch:ns}=oe({queryKey:["chat","providers"],queryFn:()=>Q.chat.providers(),refetchInterval:3e4,staleTime:25e3}),{data:os}=oe({queryKey:["chat","presets"],queryFn:()=>Q.chat.presets(),staleTime:6e4}),{data:is}=oe({queryKey:["chat","quickActions"],queryFn:()=>Q.chat.quickActions(),staleTime:6e4}),{data:ls}=oe({queryKey:["chat","memory",k],queryFn:()=>Q.chat.conversations.getMemoryStats(k,r),enabled:!!k,refetchInterval:6e4,staleTime:55e3}),{data:He}=oe({queryKey:["model-capability",r],queryFn:async()=>{if(!r)return{capability:"reasoning",tier:"full",maxSchemaTokens:2e4};const o=await fetch(`/api/chat/model-capability?model=${encodeURIComponent(r)}`);return o.ok?o.json():{capability:"reasoning",tier:"full",maxSchemaTokens:2e4}},staleTime:3e5,enabled:!!r}),{data:ft}=oe({queryKey:["voice-status"],queryFn:async()=>{const o=await fetch("/api/voice/status");return o.ok?o.json():{available:!1,stt:{provider:null},tts:{provider:null}}},staleTime:6e4,retry:1}),Oe=ft?.stt?.provider!=null,bt=ft?.tts?.provider!=null,cs=Ie({mutationFn:({type:o,apiKey:f})=>Q.chat.configure(o,{apiKey:f,enabled:!0}),onSuccess:()=>{F.success("Provider configured successfully"),ns(),t.invalidateQueries({queryKey:["chat","providers"]})},onError:o=>{F.error(o instanceof Error?o.message:"Failed to configure provider")}}),pe=Ie({mutationFn:({conversationId:o,content:f,model:b})=>Q.chat.conversations.sendMessage(o,{content:f,model:b}),onSuccess:o=>{const f={id:o.assistantMessage.id,role:"assistant",content:o.assistantMessage.content,timestamp:o.assistantMessage.createdAt,usage:o.usage};z(b=>[...b.filter(E=>!E.isLoading),f]),je(),o.compaction&&F.info(`Memory compacted: ${o.compaction.originalCount} → ${o.compaction.compactedCount} messages`,{duration:4e3})},onError:o=>{z(f=>{const b=f.filter(E=>!E.isLoading),S=b[b.length-1];return S&&S.role==="user"?[...b.slice(0,-1),{...S,error:o instanceof Error?o.message:"Failed to send message"}]:b}),F.error("Failed to send message")}}),ge=Ie({mutationFn:({conversationId:o,content:f,model:b})=>Q.chat.conversations.sendMessageWithTools(o,{content:f,model:b,enableTools:!0}),onSuccess:o=>{const f={id:o.assistantMessage.id,role:"assistant",content:o.assistantMessage.content,timestamp:o.assistantMessage.createdAt,usage:o.usage,toolCalls:o.toolCalls};z(b=>[...b.filter(E=>!E.isLoading),f]),je(),o.pendingApprovals&&o.pendingApprovals.length>0&&h(b=>{const S=o.pendingApprovals.filter(E=>!b.some(O=>O.id===E.id));return[...b,...S]}),o.compaction&&F.info(`Memory compacted: ${o.compaction.originalCount} → ${o.compaction.compactedCount} messages`,{duration:4e3}),o.toolCalls&&o.toolCalls.length>0&&F.success(`Used ${o.toolCalls.length} tool(s)`,{duration:3e3}),o.toolSupport?.requested&&!o.toolSupport.supported&&F.warning(o.toolSupport.recommendation||"Model doesn't support tools. Using normal conversation mode.",{duration:6e3})},onError:o=>{z(f=>{const b=f.filter(E=>!E.isLoading),S=b[b.length-1];return S&&S.role==="user"?[...b.slice(0,-1),{...S,error:o instanceof Error?o.message:"Failed to send message"}]:b}),F.error("Failed to send message")}}),Je=Ie({mutationFn:({approvalId:o,decision:f})=>Q.chat.tools.approve({conversationId:k,approvalId:o,decision:f}),onSuccess:(o,{approvalId:f,decision:b})=>{if(h(S=>S.filter(E=>E.id!==f)),b==="deny")F.info("Tool execution denied");else if(F.success(b==="allow-always"?"Tool allowed (always)":"Tool executed"),o.result){const S={id:crypto.randomUUID(),role:"assistant",content:typeof o.result=="string"?o.result:`Tool completed:
8
+ \`\`\`json
9
+ ${JSON.stringify(o.result,null,2)}
10
+ \`\`\``,timestamp:new Date().toISOString()};z(E=>[...E,S])}},onError:o=>{F.error(o instanceof Error?o.message:"Failed to process approval")}}),ds=i.useCallback((o,f)=>{Je.mutate({approvalId:o,decision:f})},[Je]);i.useEffect(()=>{const o=Ge.get("c");o&&o!==gt.current&&(gt.current=o,G(o).then(()=>y(!1)))},[Ge]),i.useEffect(()=>{if(!Ge.get("c")&&!k&&_?.length){const f=_[0];f?.id&&G(f.id).then(()=>y(!1))}},[_]),i.useEffect(()=>{if(!Pe?.providers||!Le?.aliases)return;const o=Le.aliases,b=Pe.providers.filter(E=>E.healthy);if(!(r&&(E=>{const O=o.find(L=>L.alias===E);return O?b.some(L=>L.type===O.provider):!1})(r))&&b.length>0){const E={anthropic:"sonnet",openai:"gpt",google:"gemini",azure:"azure",groq:"groq",xai:"grok",ollama:"local"},O=b[0],L=E[O.type]||"local";l(L)}},[Pe,Le,r]);const us=i.useCallback(o=>{l(o),localStorage.setItem(s.model,o)},[s.model]),ms=i.useCallback(o=>{d(o),localStorage.setItem(s.preset,o)},[s.preset]),Be=async()=>{const o=pe.isPending||ge.isPending||P||q;if(!a.trim()||o)return;const f={id:crypto.randomUUID(),role:"user",content:a.trim(),timestamp:new Date().toISOString(),images:A.length>0?[...A]:void 0},b={id:"loading",role:"assistant",content:"",isLoading:!0,timestamp:new Date().toISOString()};z(O=>[...O,f,b]);const S=a.trim();if(n(""),I([]),g){Y([]),X(!0);try{const O=await de();for await(const L of Q.chat.agentic.sendMessage(O,{content:S,model:r||void 0,showThinking:!0})){if(Y(D=>[...D,L]),L.type==="summary"){const D=L.data;z(U=>[...U.filter(ne=>!ne.isLoading),{id:crypto.randomUUID(),role:"assistant",content:D.summary,timestamp:new Date().toISOString()}])}if(L.type==="complete"){const D=L.data;F.success(`Task completed in ${D.totalSteps} step${D.totalSteps!==1?"s":""} with ${D.toolCalls?.length||0} tool call${(D.toolCalls?.length||0)!==1?"s":""}`,{duration:4e3}),D.suggestions&&D.suggestions.length>0&&z(U=>{const W=U.length-1;if(W>=0&&U[W].role==="assistant"){const ne=[...U];return ne[W]={...ne[W],suggestions:D.suggestions},ne}return U})}if(L.type==="error"){const D=L.data;z(U=>{const W=U.filter(Is=>!Is.isLoading),ne=W[W.length-1];return ne&&ne.role==="user"?[...W.slice(0,-1),{...ne,error:D.message}]:W}),F.error(D.message)}}je()}catch(O){z(L=>{const D=L.filter(W=>!W.isLoading),U=D[D.length-1];return U&&U.role==="user"?[...D.slice(0,-1),{...U,error:O instanceof Error?O.message:"Agentic execution failed"}]:D}),F.error("Agentic execution failed")}finally{X(!1)}return}const E=await de();te(!0);try{for await(const O of Q.chat.conversations.sendMessageStream(E,{content:S,model:r||void 0}))if(O.type==="content")z(L=>{const D=[...L],U=D.findIndex(W=>W.id==="loading");return U>=0&&(D[U]={...D[U],content:(D[U].content||"")+O.data,isLoading:!1}),D});else if(O.type==="done")z(L=>{const D=[...L],U=D.findIndex(W=>W.id==="loading"||W.isLoading);return U>=0&&(D[U]={...D[U],id:O.data.messageId,isLoading:!1,usage:O.data.usage}),D}),je(),O.data.compaction&&F.info(`Memory compacted: ${O.data.compaction.originalCount} → ${O.data.compaction.compactedCount} messages`,{duration:4e3});else if(O.type==="error")throw new Error(O.data)}catch(O){z(L=>{const D=L.filter(W=>!W.isLoading),U=D[D.length-1];return U&&U.role==="user"?[...D.slice(0,-1),{...U,error:O instanceof Error?O.message:"Failed to send message"}]:D}),F.error("Failed to send message")}finally{te(!1)}},xs=i.useCallback(async o=>{const f=pe.isPending||ge.isPending||P||q;if(!o.trim()||f)return;const b={id:crypto.randomUUID(),role:"user",content:o.trim(),timestamp:new Date().toISOString()},S={id:"loading",role:"assistant",content:"",isLoading:!0,timestamp:new Date().toISOString()};z(L=>[...L,b,S]);const E=g?ge:pe,O=await de();E.mutate({conversationId:O,content:o.trim(),model:r||void 0})},[pe.isPending,ge.isPending,P,q,g,r,pe,ge,de]),B=on({onTranscription:i.useCallback(o=>{n(f=>f?`${f} ${o}`:o)},[]),onSend:xs});i.useEffect(()=>{if(B.state==="idle"||!B.config.autoTts)return;const o=ee[ee.length-1];o&&o.role==="assistant"&&!o.isLoading&&o.content&&o.id!==Se.current&&(Se.current=o.id,B.speakResponse(o.content))},[ee,B.state,B.config.autoTts,B.speakResponse]);const hs=i.useCallback(()=>{if(!Oe&&B.state==="idle"){F.error("Talk Mode requires an STT provider. Go to Settings > Voice to configure.",{id:"voice-unavailable"});return}B.toggle()},[Oe,B.state,B.toggle]),ps=o=>{const f=ee.findIndex(L=>L.id===o);if(f===-1||!k)return;const b=ee[f];let S;if(b.role==="assistant"&&b.error){for(let L=f-1;L>=0;L--)if(ee[L].role==="user"){S=ee[L];break}}else b.role==="user"&&b.error&&(S=b);if(!S){F.error("Could not find message to retry");return}const E={id:"loading",role:"assistant",content:"",isLoading:!0,timestamp:new Date().toISOString()};z(L=>{const D=L.findIndex(U=>U.id===S.id);return[...L.slice(0,D+1),E]}),(g?ge:pe).mutate({conversationId:k,content:S.content,model:r||void 0}),F.info("Retrying message...")},gs=o=>{n(o)},fs=i.useCallback(o=>{const b={deploy:"Run the deploy workflow for this project. Check build status, run tests, and deploy if everything passes.",review:"Run a thorough code review on the recent changes. Check for bugs, security issues, and suggest improvements.",debug:"Help me debug the current issue. Analyze logs, check error patterns, and suggest fixes.",research:"Research this topic thoroughly. Search for latest information, compare approaches, and summarize findings.",test:"Run the test suite, analyze results, and fix any failing tests.",refactor:"Analyze the current code for refactoring opportunities. Suggest improvements for readability, performance, and maintainability."}[o]||`Run the ${o} workflow`;n(b),setTimeout(()=>{Be()},100)},[Be]),bs=o=>{const f=o.target.files;f&&Array.from(f).forEach(b=>{const S=new FileReader;S.onload=()=>{I(E=>[...E,S.result])},S.readAsDataURL(b)})},vs=o=>{I(f=>f.filter((b,S)=>S!==o))},ys=async()=>{if(!Oe){F.error("Voice input requires an STT provider. Go to Settings > Voice to configure.",{id:"voice-unavailable"});return}try{const o=await navigator.mediaDevices.getUserMedia({audio:!0}),f=new MediaRecorder(o);be.current=f,ve.current=[],f.ondataavailable=b=>{b.data.size>0&&ve.current.push(b.data)},f.onstop=async()=>{o.getTracks().forEach(S=>S.stop());const b=new Blob(ve.current,{type:"audio/webm"});if(b.size!==0)try{const S=new FormData;S.append("audio",b,"recording.webm");const E=await fetch("/api/voice/transcribe",{method:"POST",body:S});if(!E.ok)throw new Error("Transcription failed");const O=await E.json();O.text&&(n(L=>L?`${L} ${O.text}`:O.text??""),F.success("Voice transcribed"))}catch{F.error("Voice transcription failed")}},f.start(),$(!0),F.success("Recording started")}catch{F.error("Microphone access denied")}},js=()=>{be.current&&N&&(be.current.stop(),$(!1))},ws=async(o,f)=>{await cs.mutateAsync({type:o,apiKey:f})},Ns=i.useCallback(()=>{R(o=>{const f=!o;return localStorage.setItem(s.sidebarOpen,JSON.stringify(f)),f})},[s.sidebarOpen]),ks=i.useCallback(()=>{j(o=>{const f=!o;return localStorage.setItem(s.agentMode,JSON.stringify(f)),F.info(f?"Agent mode enabled (autonomous)":"Chat mode enabled (conversational)",{id:"agent-mode-toggle"}),f})},[s.agentMode]),Cs=i.useCallback(()=>{C(o=>{const f=!o;return f?document.documentElement.classList.add("chat-fullscreen"):document.documentElement.classList.remove("chat-fullscreen"),f})},[]);i.useEffect(()=>()=>{document.documentElement.classList.remove("chat-fullscreen")},[]);const Ss=Le?.aliases||[],We=Pe?.providers||[],we=We.filter(o=>o.healthy),vt=os?.presets||[],Ts=is?.actions||[],yt=vt.find(o=>o.id===c),jt=pe.isPending||ge.isPending||P||q,wt=K[0];return e.jsxs("div",{className:m("flex overflow-hidden transition-all duration-300",x?"h-screen rounded-none border-0 shadow-none mx-0 my-0 bg-background":"rounded-2xl border border-border/30 bg-card/40 backdrop-blur-xl shadow-[0_8px_30px_rgba(0,0,0,0.12)] dark:shadow-[0_8px_30px_rgba(0,0,0,0.3)] -mx-2 -my-2 sm:-mx-4 sm:-my-3 h-[calc(100vh-6.5rem)]"),children:[!x&&e.jsx("aside",{className:"shrink-0",children:e.jsx(Pa,{isOpen:M,onToggle:Ns,conversations:_,currentConversationId:k,onSelectConversation:ae,onNewChat:De,onDeleteConversation:Ee,width:260})}),e.jsxs("main",{className:"flex-1 flex flex-col min-w-0 bg-background/30",role:"main",children:[e.jsx("header",{className:"border-b border-border/20 bg-card/30",role:"banner",children:e.jsx(ea,{currentPreset:yt,presets:vt,selectedPreset:c,selectedModel:r,aliases:Ss,providers:We,healthyProviders:we,memoryStats:ls,conversationId:k,onPresetChange:ms,onModelChange:us,onNewChat:De,onOpenHistory:()=>y(!0),onOpenProviderSetup:()=>p(!0),onClearChat:De,onExport:ye,focusedView:x,onToggleFocusedView:Cs,modelCapability:He?{toolTier:He.tier,capabilityLevel:He.capability}:void 0})}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden px-3 py-2",children:[we.length===0&&e.jsxs("div",{className:"mb-4 p-4 rounded-2xl bg-amber-500/10 border border-amber-500/20 flex items-start gap-3",children:[e.jsx(xt,{className:"h-5 w-5 text-amber-500 shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium text-amber-200",children:"No AI providers connected"}),e.jsx("p",{className:"text-sm text-amber-300/80 mt-1",children:"Connect at least one provider to start chatting."})]}),e.jsxs(V,{variant:"outline",size:"sm",className:"border-amber-500/30 hover:bg-amber-500/10",onClick:()=>p(!0),children:[e.jsx(Ht,{className:"h-4 w-4 mr-1"}),"Setup"]})]}),g&&e.jsx(Za,{level:u,onChange:T,className:"mb-3"}),g&&(H.length>0||P)&&e.jsx(Fa,{events:H,isActive:P,className:"mb-3"}),g&&(se.length>0||P)&&e.jsx(Qa,{toolCalls:se,isExecuting:P,className:"mb-3"}),e.jsx(Ta,{messages:ee,currentPreset:yt,quickActions:Ts,healthyProviders:we.length,copiedId:Te,onCopy:he,onRetry:ps,onDelete:as,onQuickAction:gs,onOpenProviderSetup:()=>p(!0)}),B.state!=="idle"&&e.jsx(qa,{state:B.state,energy:B.energy,lastTranscription:B.lastTranscription,isCalibrating:B.isCalibrating,noiseFloor:B.noiseFloor,selectedVoice:B.selectedVoice,onVoiceChange:B.setSelectedVoice,onStop:B.stop,ttsAvailable:bt}),e.jsx(_a,{value:a,onChange:n,onSend:Be,isPending:jt,disabled:we.length===0,placeholder:we.length>0?g?"Give the agent a task...":"Type a message...":"Configure a provider to start chatting...",pendingImages:A,onImageSelect:bs,onImageRemove:vs,isRecording:N,onStartRecording:ys,onStopRecording:js,agentMode:g,onToggleAgentMode:ks,talkModeState:B.state,onToggleTalkMode:hs,voiceAvailable:{stt:Oe,tts:bt}}),g&&e.jsx(Ha,{onWorkflowSelect:fs,disabled:jt||we.length===0,className:"px-3 pb-2"})]}),e.jsx(Aa,{open:v,onOpenChange:y,conversations:_,currentConversationId:k,onSelectConversation:ae,onNewChat:De}),e.jsx($a,{open:w,onOpenChange:p,providers:We,onSaveApiKey:ws}),wt&&e.jsx(ln,{approval:wt,onDecision:ds,isLoading:Je.isPending})]})]})}export{Hn as ChatView};
@@ -0,0 +1 @@
1
+ import{j as e}from"./vendor-react-Mc5_kfYG.js";import{b as m}from"./vendor-query-C0p7b53x.js";import{Z as C,v as b,b as c,a5 as w,z as g,ad as S,S as j,E as $,k as u}from"./index-sEBN7w8J.js";import{S as x}from"./skeleton-C0E1Nfro.js";import{D as v}from"./dollar-sign-Dmijd6DP.js";import{T as p}from"./trending-up-C5OYX2k2.js";import{R as N,C as L,X as T,Y as F,T as y,a as A,L as q}from"./CartesianChart-piKQsTAR.js";import{A as D,a as R,P as I,b as O}from"./AreaChart-DwLzeAQ8.js";import{T as z}from"./trending-down-BCezC1z2.js";import"./vendor-ui-CXPAUBFv.js";function K({summary:r,analytics:n}){const s=r.taskCount>0?r.totalCost/r.taskCount:0,a=n&&n.daily.length>0?n.daily.slice(-7).reduce((l,i)=>l+i.cost,0)/7*30:r.totalCost*30,t=[{label:"Total Spend",value:`$${r.totalCost.toFixed(4)}`,icon:v,subtext:`${r.taskCount} tasks`,color:"text-green-500"},{label:"Total Tokens",value:r.totalTokens.toLocaleString(),icon:C,subtext:`${r.inputTokens.toLocaleString()} in / ${r.outputTokens.toLocaleString()} out`,color:"text-blue-500"},{label:"Avg Cost/Task",value:`$${s.toFixed(4)}`,icon:b,subtext:r.taskCount>0?"Per task average":"No tasks yet",color:"text-indigo-500"},{label:"Projected Monthly",value:`$${a.toFixed(2)}`,icon:p,subtext:"Based on recent usage",color:"text-orange-500"}];return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:t.map(l=>e.jsx(c,{className:"glass p-6 rounded-2xl hover-lift transition-liquid",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:l.label}),e.jsx("p",{className:"text-2xl font-bold text-foreground mb-1",children:l.value}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l.subtext})]}),e.jsx("div",{className:`p-3 rounded-xl bg-muted/50 ${l.color}`,children:e.jsx(l.icon,{className:"w-5 h-5"})})]})},l.label))})}function M({data:r}){const n=r.map(s=>({...s,displayDate:new Date(s.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}));return e.jsxs(c,{className:"glass p-6 rounded-2xl",children:[e.jsxs("div",{className:"mb-4",children:[e.jsxs("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(p,{className:"w-5 h-5 text-primary"}),"Daily Costs"]}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["Cost trend over the last ",r.length," days"]})]}),e.jsx(N,{width:"100%",height:300,children:e.jsxs(D,{data:n,margin:{top:10,right:10,left:0,bottom:0},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"costGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"hsl(var(--primary))",stopOpacity:.3}),e.jsx("stop",{offset:"95%",stopColor:"hsl(var(--primary))",stopOpacity:0})]})}),e.jsx(L,{strokeDasharray:"3 3",stroke:"hsl(var(--border))",opacity:.3}),e.jsx(T,{dataKey:"displayDate",stroke:"hsl(var(--muted-foreground))",fontSize:12,tickLine:!1}),e.jsx(F,{stroke:"hsl(var(--muted-foreground))",fontSize:12,tickLine:!1,tickFormatter:s=>`$${s.toFixed(2)}`}),e.jsx(y,{content:({active:s,payload:a})=>s&&a&&a.length?e.jsxs("div",{className:"glass-heavy p-3 rounded-xl shadow-float border border-border/50",children:[e.jsx("p",{className:"text-sm font-semibold mb-1",children:a[0].payload.displayDate}),e.jsxs("p",{className:"text-sm text-primary font-medium",children:["$",a[0].value?.toFixed(4)]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[a[0].payload.tokens.toLocaleString()," tokens"]})]}):null}),e.jsx(R,{type:"monotone",dataKey:"cost",stroke:"hsl(var(--primary))",strokeWidth:2,fill:"url(#costGradient)"})]})})]})}const f=["hsl(var(--primary))","hsl(var(--chart-1))","hsl(var(--chart-2))","hsl(var(--chart-3))","hsl(var(--chart-4))","hsl(var(--chart-5))"];function P({data:r}){const n=Object.entries(r).map(([s,a],t)=>({name:s,value:a.cost,tokens:a.tokens,color:f[t%f.length]})).sort((s,a)=>a.value-s.value);return e.jsxs(c,{className:"glass p-6 rounded-2xl",children:[e.jsxs("div",{className:"mb-4",children:[e.jsxs("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(w,{className:"w-5 h-5 text-primary"}),"Costs by Agent"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Cost distribution across AI agents"})]}),e.jsx(N,{width:"100%",height:300,children:e.jsxs(I,{children:[e.jsx(O,{data:n,cx:"50%",cy:"50%",innerRadius:60,outerRadius:100,paddingAngle:2,dataKey:"value",children:n.map((s,a)=>e.jsx(A,{fill:s.color},`cell-${a}`))}),e.jsx(y,{content:({active:s,payload:a})=>s&&a&&a.length?e.jsxs("div",{className:"glass-heavy p-3 rounded-xl shadow-float border border-border/50",children:[e.jsx("p",{className:"text-sm font-semibold mb-1",children:a[0].payload.name}),e.jsxs("p",{className:"text-sm text-primary font-medium",children:["$",a[0].value?.toFixed(4)]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[a[0].payload.tokens.toLocaleString()," tokens"]})]}):null}),e.jsx(q,{verticalAlign:"bottom",height:36,iconType:"circle",formatter:(s,a)=>{const t=n.reduce((d,o)=>d+o.value,0),i=((a&&a.payload&&typeof a.payload.value=="number"?a.payload.value:0)/(t||1)*100).toFixed(1);return e.jsxs("span",{className:"text-sm text-foreground",children:[s," (",i,"%)"]})}})]})}),e.jsx("div",{className:"mt-6 space-y-2",children:n.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg hover:bg-muted/50 transition-liquid",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:s.color}}),e.jsx("span",{className:"text-sm font-medium",children:s.name})]}),e.jsxs("span",{className:"text-sm text-primary font-semibold",children:["$",s.value.toFixed(4)]})]},s.name))})]})}function B({budget:r}){const n=r?.limit??0,s=r?.spent??0,a=r?.remaining??0,t=r?.percentage??0,l=()=>t>=100?"text-red-500":t>=80?"text-orange-500":t>=50?"text-yellow-500":"text-green-500",i=()=>t>=100?"bg-red-500":t>=80?"bg-orange-500":t>=50?"bg-yellow-500":"bg-green-500",o=t>=100?g:t>=80?g:S,h=l(),k=i();return e.jsxs(c,{className:"glass p-6 rounded-2xl",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(p,{className:"w-5 h-5 text-primary"}),"Budget Tracker"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Current spending vs budget limit"})]}),e.jsx("div",{className:`p-2 rounded-lg bg-muted/50 ${h}`,children:e.jsx(o,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4 mb-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Budget Limit"}),e.jsxs("p",{className:"text-lg font-bold text-foreground",children:["$",n.toFixed(2)]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Spent"}),e.jsxs("p",{className:`text-lg font-bold ${h}`,children:["$",s.toFixed(2)]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Remaining"}),e.jsxs("p",{className:"text-lg font-bold text-foreground",children:["$",a.toFixed(2)]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Usage"}),e.jsxs("span",{className:`font-semibold ${h}`,children:[t.toFixed(1),"%"]})]}),e.jsx("div",{className:"w-full h-3 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full ${k} transition-all duration-500 ease-out rounded-full`,style:{width:`${Math.min(t,100)}%`}})})]}),t>=100&&e.jsx("div",{className:"mt-4 p-3 rounded-xl bg-red-500/10 border border-red-500/20",children:e.jsxs("p",{className:"text-sm text-red-500 font-medium flex items-center gap-2",children:[e.jsx(g,{className:"w-4 h-4"}),"Budget exceeded! Consider increasing the limit or pausing tasks."]})}),t>=80&&t<100&&e.jsx("div",{className:"mt-4 p-3 rounded-xl bg-orange-500/10 border border-orange-500/20",children:e.jsxs("p",{className:"text-sm text-orange-500 font-medium flex items-center gap-2",children:[e.jsx(g,{className:"w-4 h-4"}),"Approaching budget limit. ",t.toFixed(0),"% used."]})})]})}function U(){const{data:r}=m({queryKey:["costs","routing"],queryFn:u.costs.routing,refetchInterval:3e4}),{data:n}=m({queryKey:["costs","optimize"],queryFn:u.costs.optimize,refetchInterval:6e4}),s=r?.data,a=n?.data;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(c,{className:"p-6 bg-gradient-to-br from-emerald-50 to-teal-50 dark:from-emerald-950/30 dark:to-teal-950/30 border-emerald-200 dark:border-emerald-800",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(j,{className:"h-5 w-5 text-emerald-600"}),e.jsx("h3",{className:"font-semibold text-emerald-900 dark:text-emerald-100",children:"Smart Routing"})]}),e.jsx("p",{className:"text-sm text-emerald-700 dark:text-emerald-300",children:s?.message??"Smart routing automatically picks the cheapest model for each query."})]}),s&&s.totalRouted>0&&e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-2xl font-bold text-emerald-700 dark:text-emerald-300",children:s.totalSaved}),e.jsxs("div",{className:"text-xs text-emerald-600 dark:text-emerald-400",children:["saved (",s.avgSavingsPercent," avg)"]})]})]}),s&&s.totalRouted>0&&e.jsx("div",{className:"mt-4 grid grid-cols-3 gap-3",children:["trivial","standard","complex"].map(t=>{const l=s.byTier[t]??0,i=s.totalRouted>0?Math.round(l/s.totalRouted*100):0,d={trivial:"bg-green-100 text-green-800 dark:bg-green-900/40 dark:text-green-300",standard:"bg-blue-100 text-blue-800 dark:bg-blue-900/40 dark:text-blue-300",complex:"bg-purple-100 text-purple-800 dark:bg-purple-900/40 dark:text-purple-300"};return e.jsxs("div",{className:`rounded-lg p-2 text-center ${d[t]}`,children:[e.jsxs("div",{className:"text-lg font-semibold",children:[i,"%"]}),e.jsx("div",{className:"text-xs capitalize",children:t}),e.jsxs("div",{className:"text-xs opacity-70",children:[l," queries"]})]},t)})})]}),a&&a.recommendations.length>0&&!a.optimalSetup&&e.jsxs(c,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(z,{className:"h-4 w-4 text-amber-500"}),e.jsx("h4",{className:"font-medium text-sm",children:"Cost Optimization Tips"})]}),e.jsx("div",{className:"space-y-2",children:a.recommendations.slice(0,3).map((t,l)=>e.jsxs("div",{className:`flex items-start gap-2 p-2 rounded-lg text-sm ${t.priority==="high"?"bg-amber-50 dark:bg-amber-950/20":"bg-neutral-50 dark:bg-neutral-900/30"}`,children:[e.jsx("span",{className:`mt-0.5 shrink-0 rounded px-1.5 py-0.5 text-xs font-medium ${t.priority==="high"?"bg-amber-200 text-amber-800":t.priority==="medium"?"bg-blue-200 text-blue-800":"bg-neutral-200 text-neutral-700"}`,children:t.priority}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium",children:t.action}),e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:t.reason}),e.jsxs("div",{className:"text-xs text-emerald-600 dark:text-emerald-400 mt-0.5",children:["Est. savings: ",t.estimatedMonthlySavings]})]}),t.signupUrl&&e.jsx("a",{href:t.signupUrl,target:"_blank",rel:"noopener noreferrer",className:"shrink-0 p-1 hover:bg-neutral-200 dark:hover:bg-neutral-700 rounded",children:e.jsx($,{className:"h-3.5 w-3.5 text-muted-foreground"})})]},l))})]}),a?.optimalSetup&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-emerald-50 dark:bg-emerald-950/20 rounded-lg text-sm text-emerald-700 dark:text-emerald-300",children:[e.jsx(j,{className:"h-4 w-4"}),"Your provider setup is cost-optimal"]})]})}function J(){const{data:r,isLoading:n}=m({queryKey:["costs","summary"],queryFn:u.costs.summary,refetchInterval:3e4}),{data:s,isLoading:a}=m({queryKey:["costs","analytics"],queryFn:u.costs.analytics,refetchInterval:3e4}),{data:t,isLoading:l}=m({queryKey:["costs","budget"],queryFn:u.costs.budget,refetchInterval:3e4});return n||a||l?e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxs("div",{children:[e.jsx(x,{className:"h-8 w-48 mb-2"}),e.jsx(x,{className:"h-4 w-64"})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[1,2,3,4].map(d=>e.jsx(x,{className:"h-32 rounded-2xl"},d))}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsx(x,{className:"h-80 rounded-2xl"}),e.jsx(x,{className:"h-80 rounded-2xl"})]})]}):e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold text-foreground mb-2",children:"Cost Analytics"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Track token usage, costs, and budget across all AI agents"})]}),r&&e.jsx(K,{summary:r,analytics:s}),e.jsx(U,{}),t&&e.jsx(B,{budget:t}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[s&&s.daily.length>0&&e.jsx(M,{data:s.daily}),s&&Object.keys(s.byAgent).length>0&&e.jsx(P,{data:s.byAgent})]}),s&&Object.keys(s.byModel).length>0&&e.jsxs(c,{className:"glass p-6 rounded-2xl",children:[e.jsxs("h3",{className:"text-lg font-semibold mb-4 flex items-center gap-2",children:[e.jsx(b,{className:"w-5 h-5 text-primary"}),"Costs by Model"]}),e.jsx("div",{className:"space-y-3",children:Object.entries(s.byModel).sort(([,d],[,o])=>o.cost-d.cost).map(([d,o])=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-xl bg-muted/50 hover:bg-muted/70 transition-liquid",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:d}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[o.tokens.toLocaleString()," tokens"]})]}),e.jsx("div",{className:"text-right",children:e.jsxs("div",{className:"font-semibold text-primary",children:["$",o.cost.toFixed(4)]})})]},d))})]}),(!s||s.daily.length===0)&&e.jsxs(c,{className:"glass p-12 rounded-2xl text-center",children:[e.jsx(v,{className:"w-12 h-12 mx-auto mb-4 text-muted-foreground opacity-50"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Cost Data Yet"}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-md mx-auto",children:"Cost analytics will appear here once AI agents start processing tasks. Create a task to get started!"})]})]})}export{J as CostsDashboard};
@@ -0,0 +1 @@
1
+ import{j as r}from"./vendor-react-Mc5_kfYG.js";import{h as n}from"./index-sEBN7w8J.js";import{S as f,a as h,b,c as o,d as x}from"./select-n108rXny.js";import{H as l}from"./hash-CA0hJ7vh.js";const j=[0,1,2,3,5,8,13,21];function S({value:t,onChange:s,disabled:c=!1,className:d,compact:m=!1,placeholder:a="Estimate"}){const i=e=>{s(e==="__none__"?null:parseInt(e,10))},g=e=>e===0?"0 pts (trivial)":e===1?"1 pt (tiny)":e===2?"2 pts (small)":e===3?"3 pts (medium)":e===5?"5 pts (large)":e===8?"8 pts (x-large)":e===13?"13 pts (huge)":e===21?"21 pts (epic)":`${e} pts`,u=e=>e==null?null:`${e} pts`;return r.jsxs(f,{value:t!=null?String(t):"__none__",onValueChange:i,disabled:c,children:[r.jsx(h,{className:n("bg-white/5 border-white/10 rounded-xl",m&&"w-[100px]",d),children:r.jsx(b,{placeholder:a,children:t!=null?r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx(l,{className:"h-3.5 w-3.5 text-muted-foreground"}),r.jsx("span",{children:u(t)})]}):r.jsxs("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[r.jsx(l,{className:"h-3.5 w-3.5"}),r.jsx("span",{children:a})]})})}),r.jsxs(o,{className:"glass-heavy rounded-xl border-white/10",children:[r.jsx(x,{value:"__none__",children:r.jsx("span",{className:"text-muted-foreground",children:"No estimate"})}),j.map(e=>r.jsx(x,{value:String(e),children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{className:n("w-5 h-5 rounded-md flex items-center justify-center text-xs font-medium",e===0&&"bg-zinc-500/20 text-zinc-400",e===1&&"bg-green-500/20 text-green-400",e===2&&"bg-emerald-500/20 text-emerald-400",e===3&&"bg-blue-500/20 text-blue-400",e===5&&"bg-yellow-500/20 text-yellow-400",e===8&&"bg-orange-500/20 text-orange-400",e===13&&"bg-red-500/20 text-red-400",e===21&&"bg-purple-500/20 text-purple-400"),children:e}),r.jsx("span",{children:g(e)})]})},e))]})]})}function y({value:t,className:s}){return t==null?null:r.jsxs("span",{className:n("inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md text-xs font-medium",t===0&&"bg-zinc-500/20 text-zinc-400",t===1&&"bg-green-500/20 text-green-400",t===2&&"bg-emerald-500/20 text-emerald-400",t===3&&"bg-blue-500/20 text-blue-400",t===5&&"bg-yellow-500/20 text-yellow-400",t===8&&"bg-orange-500/20 text-orange-400",t===13&&"bg-red-500/20 text-red-400",t>=21&&"bg-purple-500/20 text-purple-400",s),children:[r.jsx(l,{className:"h-3 w-3"}),t]})}export{y as E,S as a};
@@ -0,0 +1 @@
1
+ import{r as t,j as e}from"./vendor-react-Mc5_kfYG.js";import{u as W,b as B,c as N}from"./vendor-query-C0p7b53x.js";import{c as X,k as l,a$ as S,i as r,L as i,R as J,b as d,d as n,e as c,af as o,f as m,E as O,g as Y,P as F,l as v,I as y,n as I,ad as E}from"./index-sEBN7w8J.js";import{B as Z}from"./badge-BbfnwDJP.js";import{P as ee}from"./package-CwT3IzFx.js";import{C as Q}from"./circle-x-ByXtwR6Y.js";import"./vendor-ui-CXPAUBFv.js";const se=[["path",{d:"M15 18h-5",key:"95g1m2"}],["path",{d:"M18 14h-8",key:"sponae"}],["path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-4 0v-9a2 2 0 0 1 2-2h2",key:"39pd36"}],["rect",{width:"8",height:"4",x:"10",y:"6",rx:"1",key:"aywv1n"}]],K=X("newspaper",se),ae=[{id:"ai-news",label:"AI News",icon:"🤖"},{id:"dev-news",label:"Dev News",icon:"💻"},{id:"security",label:"Security",icon:"🔒"}];function oe(){const b=W(),[x,L]=t.useState(""),[h,w]=t.useState(""),[D,P]=t.useState(""),[u,R]=t.useState(""),[g,A]=t.useState(null),[j,$]=t.useState(!1),{data:z,isLoading:U}=B({queryKey:["feeds","list"],queryFn:()=>l.feeds.list()}),{data:H,isLoading:M}=B({queryKey:["feeds","digest"],queryFn:()=>l.feeds.digest(24),enabled:j}),p=N({mutationFn:s=>l.feeds.installBundle(s),onSuccess:()=>{b.invalidateQueries({queryKey:["feeds"]})}}),k=N({mutationFn:()=>l.feeds.add(x,h,D||void 0),onSuccess:()=>{b.invalidateQueries({queryKey:["feeds"]}),L(""),w(""),P("")}}),C=N({mutationFn:()=>l.feeds.poll(),onSuccess:()=>{b.invalidateQueries({queryKey:["feeds"]})}}),f=N({mutationFn:s=>l.feeds.discover(s),onSuccess:s=>{A(s.data?.feedUrl??null)}}),a=z?.data??[],q=H?.data??[],T=()=>{!x.trim()||!h.trim()||k.mutate()},_=()=>{u.trim()&&f.mutate(u.trim())},G=()=>{g&&(w(g),A(null),R(""))},V=s=>{try{return new Date(s).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return s}};return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[e.jsx(S,{className:"h-6 w-6 text-orange-500"}),"News Feeds"]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:U?"Loading...":`${a.length} feed${a.length!==1?"s":""} configured`})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(r,{variant:"outline",size:"sm",onClick:()=>C.mutate(),disabled:C.isPending,className:"gap-2",children:[C.isPending?e.jsx(i,{className:"h-4 w-4 animate-spin"}):e.jsx(J,{className:"h-4 w-4"}),"Poll All"]}),e.jsxs(r,{variant:j?"default":"outline",size:"sm",onClick:()=>$(!j),className:"gap-2",children:[e.jsx(K,{className:"h-4 w-4"}),"Get Digest"]})]})]}),e.jsxs(d,{children:[e.jsxs(n,{className:"pb-3",children:[e.jsxs(c,{className:"flex items-center gap-2 text-base",children:[e.jsx(ee,{className:"h-4 w-4"}),"Quick Install Bundles"]}),e.jsx(o,{children:"Install curated sets of feeds in one click"})]}),e.jsx(m,{children:e.jsx("div",{className:"flex flex-wrap gap-3",children:ae.map(s=>e.jsxs(r,{variant:"outline",onClick:()=>p.mutate(s.id),disabled:p.isPending,className:"gap-2",children:[e.jsx("span",{children:s.icon}),s.label,p.isPending&&p.variables===s.id&&e.jsx(i,{className:"h-3 w-3 animate-spin ml-1"})]},s.id))})})]}),j&&e.jsxs(d,{children:[e.jsxs(n,{className:"pb-3",children:[e.jsxs(c,{className:"flex items-center gap-2 text-base",children:[e.jsx(K,{className:"h-4 w-4"}),"Latest Articles",M&&e.jsx(i,{className:"h-4 w-4 animate-spin ml-1"})]}),e.jsx(o,{children:"Articles from the last 24 hours"})]}),e.jsx(m,{children:M?e.jsx("div",{className:"text-muted-foreground text-sm",children:"Fetching articles..."}):q.length===0?e.jsx("div",{className:"text-muted-foreground text-sm",children:"No recent articles found. Try polling your feeds first."}):e.jsx("div",{className:"space-y-3",children:q.slice(0,10).map(s=>e.jsx("div",{className:"flex items-start gap-3 rounded-lg border border-border/50 p-3 hover:bg-muted/30 transition-colors",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm font-medium hover:text-primary transition-colors line-clamp-2 flex items-start gap-1",children:[s.title,e.jsx(O,{className:"h-3 w-3 mt-0.5 shrink-0 opacity-60"})]}),s.summary&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:s.summary}),e.jsxs("p",{className:"text-xs text-muted-foreground/60 mt-1 flex items-center gap-1",children:[e.jsx(Y,{className:"h-3 w-3"}),V(s.publishedAt)]})]})},s.id))})})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsxs(d,{children:[e.jsxs(n,{className:"pb-3",children:[e.jsxs(c,{className:"flex items-center gap-2 text-base",children:[e.jsx(F,{className:"h-4 w-4"}),"Add Feed"]}),e.jsx(o,{children:"Manually add an RSS or Atom feed"})]}),e.jsxs(m,{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{htmlFor:"feed-name",children:"Name"}),e.jsx(y,{id:"feed-name",placeholder:"The Hacker News",value:x,onChange:s=>L(s.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{htmlFor:"feed-url",children:"RSS URL"}),e.jsx(y,{id:"feed-url",placeholder:"https://news.ycombinator.com/rss",value:h,onChange:s=>w(s.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{htmlFor:"feed-category",children:"Category (optional)"}),e.jsx(y,{id:"feed-category",placeholder:"tech",value:D,onChange:s=>P(s.target.value)})]}),e.jsxs(r,{onClick:T,disabled:!x.trim()||!h.trim()||k.isPending,className:"w-full gap-2",children:[k.isPending?e.jsx(i,{className:"h-4 w-4 animate-spin"}):e.jsx(F,{className:"h-4 w-4"}),"Add Feed"]})]})]}),e.jsxs(d,{children:[e.jsxs(n,{className:"pb-3",children:[e.jsxs(c,{className:"flex items-center gap-2 text-base",children:[e.jsx(I,{className:"h-4 w-4"}),"Discover Feed"]}),e.jsx(o,{children:"Paste any URL to auto-detect its RSS feed"})]}),e.jsxs(m,{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{htmlFor:"discover-url",children:"Website URL"}),e.jsx(y,{id:"discover-url",placeholder:"https://blog.example.com",value:u,onChange:s=>R(s.target.value)})]}),e.jsxs(r,{variant:"outline",onClick:_,disabled:!u.trim()||f.isPending,className:"w-full gap-2",children:[f.isPending?e.jsx(i,{className:"h-4 w-4 animate-spin"}):e.jsx(I,{className:"h-4 w-4"}),"Detect RSS Feed"]}),g&&e.jsxs("div",{className:"rounded-lg bg-emerald-50 dark:bg-emerald-950/20 border border-emerald-200 dark:border-emerald-800 p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-emerald-700 dark:text-emerald-400 font-medium",children:[e.jsx(E,{className:"h-4 w-4 shrink-0"}),"Feed detected"]}),e.jsx("p",{className:"text-xs font-mono text-muted-foreground break-all",children:g}),e.jsxs(r,{size:"sm",onClick:G,className:"w-full gap-1",children:[e.jsx(F,{className:"h-3 w-3"}),"Use this URL"]})]}),f.isError&&e.jsxs("div",{className:"rounded-lg bg-destructive/10 border border-destructive/20 p-3 flex items-center gap-2 text-sm text-destructive",children:[e.jsx(Q,{className:"h-4 w-4 shrink-0"}),"No RSS feed found at that URL"]})]})]})]}),e.jsxs(d,{children:[e.jsxs(n,{className:"pb-3",children:[e.jsxs(c,{className:"flex items-center gap-2 text-base",children:[e.jsx(S,{className:"h-4 w-4"}),"All Feeds"]}),e.jsx(o,{children:a.length===0?"No feeds yet":`${a.filter(s=>s.enabled).length} of ${a.length} enabled`})]}),e.jsx(m,{children:U?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm py-4",children:[e.jsx(i,{className:"h-4 w-4 animate-spin"}),"Loading feeds..."]}):a.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(S,{className:"h-8 w-8 mx-auto mb-3 opacity-30"}),e.jsx("p",{className:"text-sm",children:"No feeds configured yet."}),e.jsx("p",{className:"text-xs mt-1",children:"Install a bundle or add a feed manually above."})]}):e.jsx("div",{className:"space-y-2",children:a.map(s=>e.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border/50 p-3 hover:bg-muted/30 transition-colors",children:[s.enabled?e.jsx(E,{className:"h-4 w-4 text-emerald-500 shrink-0"}):e.jsx(Q,{className:"h-4 w-4 text-muted-foreground/40 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-medium",children:s.name}),s.category&&e.jsx(Z,{variant:"outline",className:"text-xs",children:s.category})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:s.url})]}),e.jsxs("div",{className:"text-right shrink-0",children:[e.jsx("div",{className:"text-sm font-medium tabular-nums",children:s.articleCount}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"articles"})]})]},s.id))})})]})]})}export{oe as FeedDashboard};
@@ -0,0 +1,2 @@
1
+ import{f as Z,r,j as e}from"./vendor-react-Mc5_kfYG.js";import{u as ce,b as M,c as Q}from"./vendor-query-C0p7b53x.js";import{S as W,D as de,o as me,h as x,Y as pe,p as ue,ah as he,q as fe,i as I,X as xe,R as ge,B as ee,ag as ye,L as te,T as U,F as J,a as we,w as be,b1 as ke,Z as je,H as ve,ac as Ne,z as Ce,G as Se,g as Ae,k as g,ad as Me}from"./index-sEBN7w8J.js";import{M as Ie,a as qe,b as De}from"./markdown-renderer-C6ENbB0u.js";import{C as X}from"./cpu-CiuoCeDY.js";import{T as He}from"./trash-2-CucZJL0N.js";import{S as ze}from"./send-Cu7MR2Qh.js";import{M as Te}from"./message-square-Bbb241am.js";import{L as We}from"./layout-dashboard-BRUM0kpT.js";import{W as Ee}from"./wrench-CjxjP6ok.js";import{C as Le}from"./circle-x-ByXtwR6Y.js";import"./vendor-ui-CXPAUBFv.js";import"./feature-markdown-DBo5Q7uq.js";import"./defineProperty-CoXUr7_6.js";const Y="profclaw_chatbot_conversation_";function Pe(n,a){return a?`${Y}${n}_${a}`:`${Y}${n}`}const o={dashboard:{type:"dashboard",name:"Dashboard",icon:We,description:"Overview of your workspace with stats and recent activity",capabilities:["View workspace statistics and metrics","See recent tickets and tasks","Check team activity and progress","Get insights on productivity trends"],quickActions:[{label:"Status report",prompt:"Give me a status report of my workspace. What are the key metrics and any items needing attention?"},{label:"What's new?",prompt:"What's happened recently in my workspace? Any updates I should know about?"},{label:"Productivity tips",prompt:"Based on my current workload, what productivity tips do you have?"}]},tickets:{type:"tickets",name:"Tickets",icon:U,description:"Manage and track your tickets",capabilities:["Create new tickets","Search and filter tickets","Update ticket status and priority","Add comments and checklists","Assign tickets to team members"],quickActions:[{label:"Create ticket",prompt:"Help me create a new ticket. Ask me what it should be about."},{label:"Find tickets",prompt:"Help me find tickets. What would you like to search for?"},{label:"Ticket overview",prompt:"Give me an overview of my tickets - how many are open, in progress, and done?"}]},ticketDetail:{type:"ticket-detail",name:"Ticket Details",icon:U,description:"Viewing a specific ticket",capabilities:["Update this ticket (status, priority, description)","Add comments to this ticket","Create checklists and subtasks","Link related tickets","Generate AI summaries"],quickActions:[{label:"Summarize",prompt:"Summarize this ticket and its current status for me."},{label:"Suggest next steps",prompt:"Based on this ticket, what should be the next steps to resolve it?"},{label:"Draft comment",prompt:"Help me draft a status update comment for this ticket."}]},projects:{type:"projects",name:"Projects",icon:J,description:"Manage your projects and sprints",capabilities:["Create new projects","View project progress","Manage sprints and iterations","See project analytics"],quickActions:[{label:"Create project",prompt:"Help me create a new project. What should it be called and what prefix should it use?"},{label:"Project status",prompt:"Give me a status update on all my projects."},{label:"Sprint planning",prompt:"Help me plan a new sprint. What tickets should be included?"}]},projectDetail:{type:"project-detail",name:"Project Details",icon:J,description:"Viewing a specific project",capabilities:["View project metrics and progress","Manage sprints for this project","See all tickets in this project","Update project settings"],quickActions:[{label:"Project summary",prompt:"Give me a summary of this project - progress, blockers, and upcoming work."},{label:"Sprint status",prompt:"What's the status of the current sprint in this project?"},{label:"Create ticket",prompt:"Help me create a new ticket for this project."}]},tasks:{type:"tasks",name:"Tasks",icon:we,description:"View and manage AI agent tasks",capabilities:["View pending and completed tasks","Retry failed tasks","See task execution details","Monitor agent activity"],quickActions:[{label:"Task status",prompt:"Give me an overview of my task queue - pending, running, and completed."},{label:"Failed tasks",prompt:"Are there any failed tasks that need attention?"},{label:"Agent activity",prompt:"What are my AI agents currently working on?"}]},summaries:{type:"summaries",name:"Summaries",icon:be,description:"AI-generated session summaries",capabilities:["Browse past session summaries","Search for specific work","Review completed work history"],quickActions:[{label:"Recent work",prompt:"What work has been completed recently? Show me recent summaries."},{label:"Find summary",prompt:"Help me find a summary about a specific topic or task."}]},costs:{type:"costs",name:"Cost Dashboard",icon:ke,description:"Track AI usage and costs",capabilities:["View token usage statistics","Monitor cost trends","See cost breakdown by model","Set usage alerts"],quickActions:[{label:"Cost summary",prompt:"What's my AI usage and cost this month?"},{label:"Compare models",prompt:"Compare the costs between different AI models I use."}]},gateway:{type:"gateway",name:"AI Gateway",icon:je,description:"Manage AI agent workflows",capabilities:["Execute AI workflows","Configure agents","Monitor gateway status"],quickActions:[{label:"Run workflow",prompt:"Help me run an AI workflow. What task should I execute?"},{label:"Gateway status",prompt:"What's the status of the AI gateway?"}]},agents:{type:"agents",name:"Agents",icon:ee,description:"Configure AI agents",capabilities:["View available agents","Configure agent settings","Monitor agent health"],quickActions:[{label:"Agent status",prompt:"Show me the status of all AI agents."},{label:"Configure agent",prompt:"Help me configure an AI agent."}]},settings:{type:"settings",name:"Settings",icon:ve,description:"Configure profClaw settings",capabilities:["Configure AI providers","Manage integrations","Update preferences"],quickActions:[{label:"Setup help",prompt:"Help me set up and configure profClaw."},{label:"Provider config",prompt:"Help me configure an AI provider."}]},webhooks:{type:"webhooks",name:"Webhooks",icon:Ne,description:"Manage webhook integrations",capabilities:["View webhook status","Test webhook connections","Configure webhook endpoints"],quickActions:[{label:"Webhook status",prompt:"Show me the status of all webhooks."},{label:"Setup webhook",prompt:"Help me set up a new webhook integration."}]},failed:{type:"failed",name:"Failed Tasks",icon:Ce,description:"Review and retry failed tasks",capabilities:["View failed task details","Retry failed tasks","Analyze failure patterns"],quickActions:[{label:"Analyze failures",prompt:"Analyze the failed tasks and tell me what went wrong."},{label:"Retry all",prompt:"Help me retry the failed tasks."}]},memory:{type:"memory",name:"Memory",icon:Se,description:"AI memory and context",capabilities:["Search memory for past context","View memory statistics","Manage memory files"],quickActions:[{label:"Search memory",prompt:"Search my memory for information about..."},{label:"Memory stats",prompt:"What's stored in my AI memory?"}]},cron:{type:"cron",name:"Scheduled Jobs",icon:Ae,description:"Manage automated scheduled tasks",capabilities:["Create new scheduled jobs","View job status and history","Trigger jobs manually","Pause and resume jobs","Monitor execution logs"],quickActions:[{label:"Job status",prompt:"Show me the status of all my scheduled jobs. How many are active, paused, or failed?"},{label:"Recent failures",prompt:"Are there any failed scheduled jobs? Show me the recent failures and what went wrong."},{label:"Create job",prompt:"Help me create a new scheduled job. What task should it automate and how often should it run?"},{label:"Job history",prompt:"Show me the execution history of my scheduled jobs. Which ones ran recently?"}]},default:{type:"default",name:"profClaw",icon:W,description:"AI-powered task management",capabilities:["Answer questions about profClaw","Help with navigation","Provide general assistance"],quickActions:[{label:"Help",prompt:"What can you help me with in profClaw?"},{label:"Navigate",prompt:"Help me find what I need in profClaw."}]}};function Re(){const a=Z().pathname;return r.useMemo(()=>{if(a==="/"||a==="/chat")return{context:o.default};if(a==="/analytics")return{context:o.dashboard};const i=a.match(/^\/tickets\/([^/]+)$/);if(i&&i[1]!=="board")return{context:o.ticketDetail,entityId:i[1]};if(a==="/tickets"||a==="/tickets/board")return{context:o.tickets};const m=a.match(/^\/projects\/([^/]+)$/);if(m)return{context:o.projectDetail,entityId:m[1]};if(a==="/projects")return{context:o.projects};const p=a.match(/^\/tasks\/([^/]+)$/);return p?{context:o.tasks,entityId:p[1]}:a==="/tasks"?{context:o.tasks}:a.startsWith("/summaries")?{context:o.summaries}:a==="/costs"?{context:o.costs}:a==="/gateway"?{context:o.gateway}:a==="/agents"?{context:o.agents}:a.startsWith("/settings")?{context:o.settings}:a==="/webhooks"?{context:o.webhooks}:a==="/failed"?{context:o.failed}:a==="/memory"?{context:o.memory}:a==="/cron"?{context:o.cron}:{context:o.default}},[a])}function Fe({toolCall:n}){const[a,i]=r.useState(!1);return e.jsxs("div",{className:"mt-2 p-2 rounded-lg bg-muted/50 border border-border/50 text-xs",children:[e.jsxs("button",{onClick:()=>i(!a),className:"flex items-center gap-2 w-full text-left",children:[e.jsx(Ee,{className:"h-3 w-3 text-blue-500"}),e.jsx("span",{className:"font-medium",children:n.name}),n.status==="success"&&e.jsx(Me,{className:"h-3 w-3 text-green-500 ml-auto"}),n.status==="error"&&e.jsx(Le,{className:"h-3 w-3 text-red-500 ml-auto"}),n.status==="pending"&&e.jsx(te,{className:"h-3 w-3 animate-spin text-yellow-500 ml-auto"})]}),a&&e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsxs("div",{className:"text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Args:"}),e.jsx("pre",{className:"mt-1 p-1 bg-background rounded text-[10px] overflow-x-auto",children:JSON.stringify(n.arguments,null,2)})]}),n.result!==void 0&&n.result!==null&&e.jsxs("div",{className:"text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Result:"}),e.jsx("pre",{className:"mt-1 p-1 bg-background rounded text-[10px] overflow-x-auto max-h-24 overflow-y-auto",children:typeof n.result=="string"?n.result:JSON.stringify(n.result,null,2)})]})]})]})}function tt(){const n=Z(),a=ce(),{context:i,entityId:m}=Re(),[p,E]=r.useState(!1),[C,se]=r.useState(!1),[w,f]=r.useState([]),[b,q]=r.useState(""),[D,k]=r.useState(null),[L,H]=r.useState(null),[j,P]=r.useState(!1),R=r.useRef(null),z=r.useRef(null),ae=n.pathname==="/"||n.pathname==="/chat"||n.pathname.startsWith("/chat/"),{data:F}=M({queryKey:["ticket",m],queryFn:()=>g.tickets.get(m,!1),enabled:i.type==="ticket-detail"&&!!m}),{data:$}=M({queryKey:["project",m],queryFn:()=>g.projects.get(m),enabled:i.type==="project-detail"&&!!m}),{data:S}=M({queryKey:["chat-providers"],queryFn:()=>g.chat.providers(),staleTime:6e4}),{data:K}=M({queryKey:["chat","models"],queryFn:()=>g.chat.models(),staleTime:6e4}),[y,V]=r.useState(()=>typeof window<"u"&&localStorage.getItem("profclaw-floating-chat-model")||""),re=t=>{V(t),localStorage.setItem("profclaw-floating-chat-model",t)},T=r.useMemo(()=>K?.aliases||[],[K]),h=r.useMemo(()=>S?.providers||[],[S]),_=r.useMemo(()=>new Set(h.map(t=>t.type)),[h]),G=r.useMemo(()=>T.filter(t=>_.has(t.provider)).reduce((t,s)=>{const c=s.provider;return(!t[c]||s.alias.length<t[c].alias.length)&&(t[c]=s),t},{}),[T,_]),v=r.useMemo(()=>Object.values(G).sort((t,s)=>{const c=h.find(u=>u.type===t.provider)?.healthy?1:0;return(h.find(u=>u.type===s.provider)?.healthy?1:0)-c||t.provider.localeCompare(s.provider)}),[G,h]);r.useEffect(()=>{if(!y&&v.length>0){const t=v.find(s=>h.find(c=>c.type===s.provider)?.healthy);t&&V(t.alias)}},[y,v,h]);const N=Pe(i.type,m);r.useEffect(()=>{p&&(async()=>{const s=localStorage.getItem(N);if(s){P(!0);try{const c=await g.chat.conversations.get(s);k(s);const d=c.messages.filter(l=>l.role!=="system").map(l=>({id:l.id,role:l.role,content:l.content,timestamp:new Date(l.createdAt),model:l.model,provider:l.provider,toolCalls:l.toolCalls?.map(le=>({...le,status:"success"}))}));f(d);const u=d.filter(l=>l.role==="assistant").pop();u?.model&&H(u.model)}catch{localStorage.removeItem(N),k(null),f([])}finally{P(!1)}}else k(null),f([])})()},[N,p]),r.useEffect(()=>{R.current?.scrollIntoView({behavior:"smooth"})},[w]),r.useEffect(()=>{p&&!j&&setTimeout(()=>z.current?.focus(),100)},[p,j]);const ie=Q({mutationFn:async()=>{const t=`${i.name} Chat`;return(await g.chat.conversations.create({title:t,presetId:"profclaw-assistant",ticketId:i.type==="ticket-detail"?m:void 0,projectId:i.type==="project-detail"?m:void 0})).conversation.id},onSuccess:t=>{k(t),localStorage.setItem(N,t)}}),A=Q({mutationFn:async t=>{let s=D;s||(s=await ie.mutateAsync());const c={id:`user-${Date.now()}`,role:"user",content:t,timestamp:new Date};f(l=>[...l,c]);const d=`assistant-${Date.now()}`;f(l=>[...l,{id:d,role:"assistant",content:"",timestamp:new Date,isLoading:!0}]);const u=await g.chat.conversations.sendMessageWithTools(s,{content:t,enableTools:!0,model:y||void 0});return{loadingId:d,response:u}},onSuccess:({loadingId:t,response:s})=>{s.assistantMessage.model&&H(s.assistantMessage.model),f(c=>c.map(d=>d.id===t?{...d,id:s.assistantMessage.id,content:s.assistantMessage.content,isLoading:!1,model:s.assistantMessage.model,provider:s.assistantMessage.provider,toolCalls:s.assistantMessage.toolCalls?.map(u=>({...u,status:"success"}))}:d)),s.assistantMessage.toolCalls?.length&&(a.invalidateQueries({queryKey:["tickets"]}),a.invalidateQueries({queryKey:["projects"]}),a.invalidateQueries({queryKey:["tasks"]}))},onError:t=>{f(s=>[...s.filter(d=>!d.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${t instanceof Error?t.message:"Unknown error"}`,timestamp:new Date}])}}),O=()=>{if(!b.trim()||A.isPending)return;const t=b.trim();q(""),A.mutate(t)},ne=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),O())},oe=async()=>{if(D){try{await g.chat.conversations.delete(D)}catch{}localStorage.removeItem(N),k(null)}f([]),H(null)},B=i.icon;return ae?null:e.jsxs(e.Fragment,{children:[p&&e.jsxs("div",{className:x("fixed z-50 flex flex-col overflow-hidden transition-all duration-300 ease-out","bottom-24 right-4 sm:right-6","glass-heavy","rounded-[2rem] shadow-2xl shadow-primary/10",C?"w-[calc(100vw-2rem)] sm:w-130 md:w-150 lg:w-170 h-[72vh] sm:h-155 md:h-180":"w-[calc(100vw-2rem)] sm:w-105 md:w-120 h-[62vh] sm:h-140 md:h-155"),children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 bg-primary/5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative h-9 w-9 rounded-xl glass-heavy flex items-center justify-center shadow-lg shadow-primary/5",children:[e.jsx(W,{className:"h-5 w-5 text-primary"}),e.jsx("span",{className:"absolute -top-1.5 -right-1.5 px-1.5 py-0.5 text-[8px] font-black uppercase rounded-lg bg-primary text-primary-foreground leading-none shadow-sm",children:"Beta"})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-black tracking-tight uppercase tracking-[0.1em]",children:"profClaw Assistant"}),e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground font-semibold",children:[e.jsx(B,{className:"h-3 w-3"}),e.jsx("span",{className:"uppercase tracking-widest",children:i.name}),m&&F&&e.jsxs("span",{className:"text-sky-600 dark:text-sky-400",children:["• ",F.sequence]}),m&&$&&e.jsxs("span",{className:"text-sky-600 dark:text-sky-400",children:["• ",$.key]})]})]})]}),v.length>0&&e.jsxs(de,{children:[e.jsx(me,{asChild:!0,children:e.jsxs("button",{className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-xl text-[10px] font-bold bg-primary/10 hover:bg-primary/20 transition-all shadow-sm",children:[e.jsx("span",{className:x("h-1.5 w-1.5 rounded-full",h.find(t=>t.type===T.find(s=>s.alias===y)?.provider)?.healthy?"bg-emerald-500 shadow-[0_0_8px_var(--success)]":"bg-amber-400 shadow-[0_0_8px_var(--warning)]")}),e.jsx(X,{className:"h-3.5 w-3.5 text-primary"}),e.jsx("span",{className:"capitalize max-w-20 truncate text-primary font-black",children:y||L||"Model"}),e.jsx(pe,{className:"h-3 w-3 text-primary opacity-50"})]})}),e.jsxs(ue,{align:"end",className:"w-52 glass-heavy shadow-2xl",children:[e.jsx("div",{className:"px-2 py-1.5 text-[9px] font-medium text-muted-foreground uppercase tracking-wider",children:"Select Model"}),e.jsx(he,{}),v.map(t=>{const c=h.find(l=>l.type===t.provider)?.healthy,d=(y||L)===t.alias,u=t.provider==="ollama";return e.jsxs(fe,{onClick:()=>re(t.alias),className:x("flex items-center justify-between cursor-pointer text-xs py-2",d&&"bg-primary/20"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:x("h-1.5 w-1.5 rounded-full",c?"bg-emerald-500":"bg-amber-400")}),e.jsx("span",{className:x("capitalize font-bold",d&&"text-primary"),children:t.alias})]}),e.jsx("span",{className:"text-[9px] text-muted-foreground",children:u?"Local":t.provider})]},t.alias)})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[w.length>0&&e.jsx(I,{variant:"ghost",size:"sm",onClick:oe,className:"h-7 w-7 p-0",title:"Clear chat",children:e.jsx(He,{className:"h-3.5 w-3.5"})}),e.jsx(I,{variant:"ghost",size:"sm",onClick:()=>se(!C),className:"h-7 w-7 p-0",title:C?"Minimize":"Expand",children:C?e.jsx(Ie,{className:"h-3.5 w-3.5"}):e.jsx(qe,{className:"h-3.5 w-3.5"})}),e.jsx(I,{variant:"ghost",size:"sm",onClick:()=>E(!1),className:"h-7 w-7 p-0",title:"Close",children:e.jsx(xe,{className:"h-3.5 w-3.5"})})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-3.5 scrollbar-none liquid-fade-y",children:[j?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[e.jsx(ge,{className:"h-6 w-6 animate-spin text-sky-500 mb-2"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Loading conversation..."})]}):w.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center px-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-xl bg-sky-500/10 flex items-center justify-center mb-3",children:e.jsx(B,{className:"h-6 w-6 text-sky-500"})}),e.jsxs("h4",{className:"text-sm font-medium mb-1",children:[i.name," Assistant"]}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-4 max-w-70",children:[i.description,". How can I help?"]}),e.jsxs("div",{className:"w-full space-y-2",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Quick Actions"}),e.jsx("div",{className:"flex flex-col gap-2",children:i.quickActions.map(t=>e.jsx("button",{onClick:()=>{q(t.prompt),setTimeout(()=>z.current?.focus(),0)},className:"px-3 py-2 text-xs text-left rounded-lg bg-muted/50 hover:bg-muted transition-colors border border-transparent hover:border-border",children:t.label},t.label))})]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-border w-full",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide mb-2",children:"I can help you"}),e.jsx("ul",{className:"text-[11px] text-muted-foreground text-left space-y-1",children:i.capabilities.slice(0,3).map((t,s)=>e.jsxs("li",{className:"flex items-start gap-1.5",children:[e.jsx("span",{className:"text-sky-500 mt-0.5",children:"•"}),t]},s))})]}),S?.default&&e.jsxs("div",{className:"mt-4 pt-2 text-[10px] text-muted-foreground/70 flex items-center gap-1",children:[e.jsx(X,{className:"h-3 w-3"}),e.jsxs("span",{children:["Powered by ",S.default]})]})]}):w.map(t=>e.jsxs("div",{className:x("flex gap-3",t.role==="user"?"justify-end":"justify-start"),children:[t.role==="assistant"&&e.jsx("div",{className:"h-7 w-7 rounded-full bg-zinc-100 dark:bg-zinc-800 flex items-center justify-center shrink-0",children:e.jsx(ee,{className:"h-4 w-4 text-zinc-500"})}),e.jsx("div",{className:x("max-w-[85%] rounded-[1.5rem] px-5 py-3.5 text-[14px] leading-relaxed shadow-lg transition-all",t.role==="user"?"bg-primary text-primary-foreground rounded-tr-sm ml-auto shadow-primary/10":"glass text-foreground rounded-tl-sm shadow-sm",t.role==="assistant"&&"mr-auto"),children:t.isLoading?e.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-zinc-400 dark:bg-zinc-600 animate-bounce delay-0"}),e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-zinc-400 dark:bg-zinc-600 animate-bounce delay-150"}),e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-zinc-400 dark:bg-zinc-600 animate-bounce delay-300"})]}):t.role==="assistant"?e.jsxs(e.Fragment,{children:[e.jsx(De,{content:t.content}),t.toolCalls&&t.toolCalls.length>0&&e.jsx("div",{className:"mt-2 space-y-1",children:t.toolCalls.map(s=>e.jsx(Fe,{toolCall:s},s.id))})]}):e.jsx("p",{className:"whitespace-pre-wrap",children:t.content})}),t.role==="user"&&e.jsx("div",{className:"h-8 w-8 rounded-xl glass-heavy flex items-center justify-center shrink-0 shadow-lg",children:e.jsx(ye,{className:"h-4.5 w-4.5 text-primary"})})]},t.id)),e.jsx("div",{ref:R})]}),e.jsxs("div",{className:"p-4 bg-primary/5",children:[e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("textarea",{ref:z,value:b,onChange:t=>q(t.target.value),onKeyDown:ne,placeholder:`Ask about ${i.name.toLowerCase()}...`,rows:1,disabled:j,className:"flex-1 px-4 py-3 text-sm glass rounded-[1.5rem] resize-none focus:outline-none focus:ring-1 focus:ring-primary/20 focus:bg-white/50 dark:focus:bg-black/50 min-h-11 max-h-32 placeholder:text-muted-foreground/50 disabled:opacity-50 transition-all font-medium",style:{height:"auto",overflow:b.split(`
2
+ `).length>3?"auto":"hidden"},onInput:t=>{const s=t.target;s.style.height="auto",s.style.height=Math.min(s.scrollHeight,120)+"px"}}),e.jsx(I,{onClick:O,disabled:!b.trim()||A.isPending||j,size:"sm",className:"h-11 w-11 p-0 rounded-2xl bg-primary hover:bg-primary-hover text-primary-foreground shadow-xl shadow-primary/20 hover:scale-110 active:scale-95 transition-all",children:A.isPending?e.jsx(te,{className:"h-4 w-4 animate-spin"}):e.jsx(ze,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground text-center mt-2 font-medium opacity-60",children:["Press Enter to send • Shift+Enter for new line",w.length>0&&" • Session auto-saved"]})]})]}),e.jsx("button",{onClick:()=>E(!p),className:x("fixed bottom-6 right-6 z-50 h-[60px] w-[60px] rounded-[1.5rem] flex items-center justify-center transition-all duration-300 ease-out hover:scale-110 active:scale-90 shadow-2xl",p?"glass-heavy text-primary shadow-primary/10":"bg-primary text-primary-foreground shadow-primary/30"),title:p?"Close chat":`Open profClaw Assistant (${i.name})`,children:p?e.jsx(Te,{className:"h-6 w-6"}):e.jsx(W,{className:"h-6 w-6"})})]})}export{tt as FloatingChatbot,tt as default};
@@ -0,0 +1,2 @@
1
+ import{r as a,j as e}from"./vendor-react-Mc5_kfYG.js";import{u as ge,b as P,c as C}from"./vendor-query-C0p7b53x.js";import{c as je,t as r,z as O,a7 as fe,i as n,R as Ne,h as B,P as F,L as D,n as we,g as ve,D as be,o as ye,p as Ce,aX as De,ah as Q,q as $,y as k,C as S,x as K}from"./index-sEBN7w8J.js";import{A as H,a as U,b as _,c as J,d as X,e as V,f as Y,g as W}from"./alert-dialog-O6qBOv_f.js";import{G as Z}from"./globe-D_WpJdsj.js";import{E as ke}from"./ellipsis-vT-5SVIp.js";import{T as Se}from"./trash-2-CucZJL0N.js";import{C as Ae}from"./circle-x-ByXtwR6Y.js";import"./vendor-ui-CXPAUBFv.js";const Me=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],ee=je("lock",Me),Te="http://localhost:3000";async function m(t,l={}){const i=await fetch(`${Te}/api/users${t}`,{...l,headers:{"Content-Type":"application/json",...l.headers},credentials:"include"});if(!i.ok){const p=await i.json().catch(()=>({error:"Unknown error"}));throw new Error(p.error||`HTTP ${i.status}`)}return i.json()}const x={list:()=>m("/admin/invites"),generate:t=>m("/admin/invites",{method:"POST",body:JSON.stringify(t)}),delete:t=>m(`/admin/invites/${t}`,{method:"DELETE"}),getRegistrationMode:()=>m("/admin/registration-mode"),setRegistrationMode:t=>m("/admin/registration-mode",{method:"PATCH",body:JSON.stringify({mode:t})})};function Be(){const t=ge(),[l,i]=a.useState(""),[p,g]=a.useState(!1),[se,A]=a.useState(!1),[u,te]=a.useState([]),[M,T]=a.useState(1),[I,L]=a.useState(""),[j,E]=a.useState(""),[G,R]=a.useState(null),[f,N]=a.useState(null),[ae,w]=a.useState(!1),{data:c,isLoading:v,error:z,refetch:ne}=P({queryKey:["admin","inviteCodes"],queryFn:()=>x.list()}),{data:d}=P({queryKey:["admin","registrationMode"],queryFn:()=>x.getRegistrationMode()}),b=C({mutationFn:x.generate,onSuccess:s=>{te(s.codes),g(!1),A(!0),T(1),L(""),E(""),t.invalidateQueries({queryKey:["admin","inviteCodes"]}),r.success(`Generated ${s.codes.length} invite code(s)`)},onError:s=>r.error(s.message)}),le=C({mutationFn:x.delete,onSuccess:()=>{t.invalidateQueries({queryKey:["admin","inviteCodes"]}),r.success("Invite code deleted")},onError:s=>r.error(s.message)}),h=C({mutationFn:s=>x.setRegistrationMode(s),onSuccess:s=>{t.invalidateQueries({queryKey:["admin","registrationMode"]}),r.success(`Registration mode set to ${s.mode}`)},onError:s=>r.error(s.message)}),y=(s,o)=>{navigator.clipboard.writeText(s),R(o),setTimeout(()=>R(null),2e3),r.success(`${o} copied`)},re=s=>s.usedBy?{label:"Used",color:"bg-zinc-500/10 text-zinc-500",icon:S}:s.expiresAt&&new Date>new Date(s.expiresAt)?{label:"Expired",color:"bg-red-500/10 text-red-500",icon:Ae}:{label:"Available",color:"bg-green-500/10 text-green-500",icon:S},q=c?.invites?.filter(s=>(s.label||"").toLowerCase().includes(l.toLowerCase())||s.id.toLowerCase().includes(l.toLowerCase())||(s.createdBy||"").toLowerCase().includes(l.toLowerCase()))||[],ie=()=>{b.mutate({count:M,label:I||void 0,expiresInDays:j?parseInt(j,10):void 0})},de=s=>{N(s)},oe=()=>{f&&(le.mutate(f.id),N(null))},ce=()=>{const s=d?.mode==="invite"?"open":"invite";if(s==="open"){w(!0);return}h.mutate(s)},me=()=>{h.mutate("open"),w(!1)},xe=c?.invites?.filter(s=>!s.usedBy&&(!s.expiresAt||new Date<=new Date(s.expiresAt))).length||0,ue=c?.invites?.filter(s=>s.usedBy).length||0,he=c?.invites?.filter(s=>!s.usedBy&&s.expiresAt&&new Date>new Date(s.expiresAt)).length||0;return z?e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(O,{className:"h-12 w-12 text-destructive mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Access Denied"}),e.jsx("p",{className:"text-muted-foreground",children:z.message})]})}):e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-3",children:[e.jsx(fe,{className:"h-6 w-6"}),"Invite Codes"]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Generate and manage invite codes for user registration"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(n,{variant:"outline",onClick:()=>ne(),disabled:v,className:"rounded-xl",children:[e.jsx(Ne,{className:B("h-4 w-4 mr-2",v&&"animate-spin")}),"Refresh"]}),e.jsxs(n,{onClick:()=>g(!0),className:"rounded-xl",children:[e.jsx(F,{className:"h-4 w-4 mr-2"}),"Generate Codes"]})]})]}),e.jsxs("div",{className:"rounded-2xl glass shadow-lg p-4 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[d?.mode==="invite"?e.jsx("div",{className:"h-10 w-10 rounded-full bg-amber-500/10 flex items-center justify-center",children:e.jsx(ee,{className:"h-5 w-5 text-amber-500"})}):e.jsx("div",{className:"h-10 w-10 rounded-full bg-green-500/10 flex items-center justify-center",children:e.jsx(Z,{className:"h-5 w-5 text-green-500"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:["Registration Mode: ",e.jsx("span",{className:"capitalize",children:d?.mode||"..."})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d?.mode==="invite"?"New users need an invite code to sign up":"Anyone can sign up without an invite code"})]})]}),e.jsxs(n,{variant:"outline",onClick:ce,disabled:h.isPending,className:"rounded-xl",children:[h.isPending?e.jsx(D,{className:"h-4 w-4 animate-spin mr-2"}):d?.mode==="invite"?e.jsx(Z,{className:"h-4 w-4 mr-2"}):e.jsx(ee,{className:"h-4 w-4 mr-2"}),"Switch to ",d?.mode==="invite"?"Open":"Invite"]})]}),e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(we,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx("input",{type:"text",placeholder:"Search by label or ID...",value:l,onChange:s=>i(s.target.value),className:"w-full pl-10 pr-4 py-2 field-lg"})]}),e.jsx("div",{className:"rounded-2xl glass shadow-lg overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5 bg-muted/30",children:[e.jsx("th",{className:"text-left p-4 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Label"}),e.jsx("th",{className:"text-left p-4 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Status"}),e.jsx("th",{className:"text-left p-4 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Expires"}),e.jsx("th",{className:"text-left p-4 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Created"}),e.jsx("th",{className:"text-right p-4 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Actions"})]})}),e.jsx("tbody",{children:v?e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"p-8 text-center",children:e.jsx(D,{className:"h-6 w-6 animate-spin mx-auto text-muted-foreground"})})}):q.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"p-8 text-center text-muted-foreground",children:l?"No matching invite codes":"No invite codes yet. Generate some to get started."})}):q.map(s=>{const o=re(s),pe=o.icon;return e.jsxs("tr",{className:"border-b border-white/5 last:border-0 hover:bg-muted/20 transition-colors",children:[e.jsx("td",{className:"p-4",children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:s.label||e.jsx("span",{className:"text-muted-foreground",children:"No label"})}),e.jsxs("p",{className:"text-xs text-muted-foreground font-mono",children:[s.id.slice(0,8),"..."]})]})}),e.jsx("td",{className:"p-4",children:e.jsxs("span",{className:B("inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-semibold",o.color),children:[e.jsx(pe,{className:"h-3 w-3"}),o.label]})}),e.jsx("td",{className:"p-4 text-sm text-muted-foreground",children:s.expiresAt?e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(ve,{className:"h-3.5 w-3.5"}),new Date(s.expiresAt).toLocaleDateString()]}):e.jsx("span",{className:"text-muted-foreground/50",children:"Never"})}),e.jsx("td",{className:"p-4 text-sm text-muted-foreground",children:s.createdAt?new Date(s.createdAt).toLocaleDateString():"-"}),e.jsx("td",{className:"p-4",children:e.jsx("div",{className:"flex items-center justify-end gap-2",children:e.jsxs(be,{children:[e.jsx(ye,{asChild:!0,children:e.jsx(n,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 rounded-lg",children:e.jsx(ke,{className:"h-4 w-4"})})}),e.jsxs(Ce,{align:"end",className:"w-48",children:[e.jsx(De,{children:"Actions"}),e.jsx(Q,{}),e.jsxs($,{onClick:()=>y(s.id,"ID"),children:[e.jsx(k,{className:"h-4 w-4 mr-2"}),"Copy ID"]}),e.jsx(Q,{}),e.jsxs($,{onClick:()=>de(s),className:"text-destructive focus:text-destructive",children:[e.jsx(Se,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})})]},s.id)})})]})})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"p-4 rounded-2xl glass shadow-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total"}),e.jsx("p",{className:"text-2xl font-bold",children:c?.total||0})]}),e.jsxs("div",{className:"p-4 rounded-2xl glass shadow-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Available"}),e.jsx("p",{className:"text-2xl font-bold text-green-500",children:xe})]}),e.jsxs("div",{className:"p-4 rounded-2xl glass shadow-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Used"}),e.jsx("p",{className:"text-2xl font-bold text-zinc-500",children:ue})]}),e.jsxs("div",{className:"p-4 rounded-2xl glass shadow-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Expired"}),e.jsx("p",{className:"text-2xl font-bold text-red-500",children:he})]})]}),p&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"glass-heavy rounded-2xl shadow-2xl w-full max-w-md mx-4 p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(F,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold",children:"Generate Invite Codes"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Create new codes for user registration"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Number of codes"}),e.jsx("input",{type:"number",min:1,max:50,value:M,onChange:s=>T(Math.min(50,Math.max(1,parseInt(s.target.value,10)||1))),className:"w-full field-lg"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Label (optional)"}),e.jsx("input",{type:"text",value:I,onChange:s=>L(s.target.value),placeholder:'e.g., "For onboarding batch 2"',className:"w-full field-lg"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Expires in (days, optional)"}),e.jsx("input",{type:"number",min:1,max:365,value:j,onChange:s=>E(s.target.value),placeholder:"e.g., 7",className:"w-full field-lg"})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(n,{variant:"outline",className:"flex-1 rounded-xl",onClick:()=>g(!1),children:"Cancel"}),e.jsx(n,{className:"flex-1 rounded-xl",onClick:ie,disabled:b.isPending,children:b.isPending?e.jsx(D,{className:"h-4 w-4 animate-spin"}):"Generate"})]})]})]})}),e.jsx(H,{open:!!f,onOpenChange:s=>!s&&N(null),children:e.jsxs(U,{children:[e.jsxs(_,{children:[e.jsx(J,{children:"Delete Invite Code"}),e.jsx(X,{children:"Are you sure you want to delete this invite code? This action cannot be undone."})]}),e.jsxs(V,{children:[e.jsx(Y,{className:"rounded-xl",children:"Cancel"}),e.jsx(W,{onClick:oe,className:"rounded-xl bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),e.jsx(H,{open:ae,onOpenChange:w,children:e.jsxs(U,{children:[e.jsxs(_,{children:[e.jsx(J,{children:"Switch to Open Registration?"}),e.jsx(X,{children:"Anyone will be able to sign up without an invite code. You can switch back to invite-only at any time."})]}),e.jsxs(V,{children:[e.jsx(Y,{className:"rounded-xl",children:"Cancel"}),e.jsx(W,{onClick:me,className:"rounded-xl",children:"Switch to Open"})]})]})}),se&&u.length>0&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"glass-heavy rounded-2xl shadow-2xl w-full max-w-md mx-4 p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-green-500/10 flex items-center justify-center",children:e.jsx(S,{className:"h-6 w-6 text-green-500"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold",children:"Invite Codes Generated"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[u.length," code(s) ready to share"]})]})]}),e.jsx("div",{className:"space-y-2 max-h-64 overflow-y-auto",children:u.map(s=>e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-xl bg-muted/30",children:[e.jsx("code",{className:"flex-1 font-mono text-sm font-semibold",children:s.code}),e.jsx(n,{size:"sm",variant:"ghost",className:"h-8 w-8 p-0",onClick:()=>y(s.code,s.id),children:G===s.id?e.jsx(K,{className:"h-4 w-4 text-green-500"}):e.jsx(k,{className:"h-4 w-4"})})]},s.id))}),e.jsxs(n,{size:"sm",variant:"outline",className:"w-full mt-3 rounded-xl",onClick:()=>y(u.map(s=>s.code).join(`
2
+ `),"all-codes"),children:[G==="all-codes"?e.jsx(K,{className:"h-4 w-4 mr-2 text-green-500"}):e.jsx(k,{className:"h-4 w-4 mr-2"}),"Copy All"]}),e.jsxs("p",{className:"text-xs text-amber-500 flex items-start gap-2 mt-3",children:[e.jsx(O,{className:"h-4 w-4 flex-shrink-0 mt-0.5"}),"Save these codes now. They cannot be retrieved later."]}),e.jsx(n,{className:"w-full rounded-xl mt-3",onClick:()=>A(!1),children:"Done"})]})})]})}export{Be as InviteCodeManagement};