@agent-relay/dashboard-server 2.0.82 → 2.0.84

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 (393) hide show
  1. package/dist/index.d.ts +3 -21
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +3 -23
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/attachment-storage.d.ts +10 -0
  6. package/dist/lib/attachment-storage.d.ts.map +1 -0
  7. package/dist/lib/attachment-storage.js +53 -0
  8. package/dist/lib/attachment-storage.js.map +1 -0
  9. package/dist/lib/broadcast.d.ts +18 -0
  10. package/dist/lib/broadcast.d.ts.map +1 -0
  11. package/dist/lib/broadcast.js +118 -0
  12. package/dist/lib/broadcast.js.map +1 -0
  13. package/dist/lib/channel-state.d.ts +32 -0
  14. package/dist/lib/channel-state.d.ts.map +1 -0
  15. package/dist/lib/channel-state.js +146 -0
  16. package/dist/lib/channel-state.js.map +1 -0
  17. package/dist/lib/cli-auth.d.ts +40 -0
  18. package/dist/lib/cli-auth.d.ts.map +1 -0
  19. package/dist/lib/cli-auth.js +144 -0
  20. package/dist/lib/cli-auth.js.map +1 -0
  21. package/dist/lib/cloud-persistence.d.ts +6 -0
  22. package/dist/lib/cloud-persistence.d.ts.map +1 -0
  23. package/dist/lib/cloud-persistence.js +130 -0
  24. package/dist/lib/cloud-persistence.js.map +1 -0
  25. package/dist/lib/data-assembly.d.ts +136 -0
  26. package/dist/lib/data-assembly.d.ts.map +1 -0
  27. package/dist/lib/data-assembly.js +550 -0
  28. package/dist/lib/data-assembly.js.map +1 -0
  29. package/dist/lib/file-search.d.ts +8 -0
  30. package/dist/lib/file-search.d.ts.map +1 -0
  31. package/dist/lib/file-search.js +90 -0
  32. package/dist/lib/file-search.js.map +1 -0
  33. package/dist/lib/identity.d.ts +54 -0
  34. package/dist/lib/identity.d.ts.map +1 -0
  35. package/dist/lib/identity.js +124 -0
  36. package/dist/lib/identity.js.map +1 -0
  37. package/dist/lib/log-line-cleaner.d.ts +20 -0
  38. package/dist/lib/log-line-cleaner.d.ts.map +1 -0
  39. package/dist/lib/log-line-cleaner.js +117 -0
  40. package/dist/lib/log-line-cleaner.js.map +1 -0
  41. package/dist/lib/log-reader.d.ts +14 -0
  42. package/dist/lib/log-reader.d.ts.map +1 -0
  43. package/dist/lib/log-reader.js +80 -0
  44. package/dist/lib/log-reader.js.map +1 -0
  45. package/dist/lib/message-id.d.ts +30 -0
  46. package/dist/lib/message-id.d.ts.map +1 -0
  47. package/dist/lib/message-id.js +50 -0
  48. package/dist/lib/message-id.js.map +1 -0
  49. package/dist/lib/process-metrics.d.ts +11 -0
  50. package/dist/lib/process-metrics.d.ts.map +1 -0
  51. package/dist/lib/process-metrics.js +252 -0
  52. package/dist/lib/process-metrics.js.map +1 -0
  53. package/dist/lib/proxy-route-table.d.ts +16 -0
  54. package/dist/lib/proxy-route-table.d.ts.map +1 -0
  55. package/dist/lib/proxy-route-table.js +73 -0
  56. package/dist/lib/proxy-route-table.js.map +1 -0
  57. package/dist/lib/send-strategy.d.ts +61 -0
  58. package/dist/lib/send-strategy.d.ts.map +1 -0
  59. package/dist/lib/send-strategy.js +134 -0
  60. package/dist/lib/send-strategy.js.map +1 -0
  61. package/dist/lib/server-state.d.ts +115 -0
  62. package/dist/lib/server-state.d.ts.map +1 -0
  63. package/dist/lib/server-state.js +138 -0
  64. package/dist/lib/server-state.js.map +1 -0
  65. package/dist/lib/spawned-agents.d.ts +35 -0
  66. package/dist/lib/spawned-agents.d.ts.map +1 -0
  67. package/dist/lib/spawned-agents.js +323 -0
  68. package/dist/lib/spawned-agents.js.map +1 -0
  69. package/dist/lib/types.d.ts +117 -0
  70. package/dist/lib/types.d.ts.map +1 -0
  71. package/dist/lib/types.js +12 -0
  72. package/dist/lib/types.js.map +1 -0
  73. package/dist/lib/utils.d.ts +71 -0
  74. package/dist/lib/utils.d.ts.map +1 -0
  75. package/dist/lib/utils.js +332 -0
  76. package/dist/lib/utils.js.map +1 -0
  77. package/dist/lib/websocket-runtime.d.ts +17 -0
  78. package/dist/lib/websocket-runtime.d.ts.map +1 -0
  79. package/dist/lib/websocket-runtime.js +76 -0
  80. package/dist/lib/websocket-runtime.js.map +1 -0
  81. package/dist/mocks/fixtures.d.ts +2 -2
  82. package/dist/mocks/fixtures.js +1 -1
  83. package/dist/mocks/routes.d.ts.map +1 -1
  84. package/dist/mocks/routes.js +30 -3
  85. package/dist/mocks/routes.js.map +1 -1
  86. package/dist/mocks/types.d.ts +1 -1
  87. package/dist/mocks/types.js +1 -1
  88. package/dist/proxy-server.d.ts +7 -33
  89. package/dist/proxy-server.d.ts.map +1 -1
  90. package/dist/proxy-server.js +292 -200
  91. package/dist/proxy-server.js.map +1 -1
  92. package/dist/relaycast-provider-helpers.d.ts +40 -0
  93. package/dist/relaycast-provider-helpers.d.ts.map +1 -0
  94. package/dist/relaycast-provider-helpers.js +284 -0
  95. package/dist/relaycast-provider-helpers.js.map +1 -0
  96. package/dist/relaycast-provider-types.d.ts +116 -0
  97. package/dist/relaycast-provider-types.d.ts.map +1 -0
  98. package/dist/relaycast-provider-types.js +6 -0
  99. package/dist/relaycast-provider-types.js.map +1 -0
  100. package/dist/relaycast-provider.d.ts +42 -0
  101. package/dist/relaycast-provider.d.ts.map +1 -0
  102. package/dist/relaycast-provider.js +277 -0
  103. package/dist/relaycast-provider.js.map +1 -0
  104. package/dist/routes/agents.d.ts +7 -0
  105. package/dist/routes/agents.d.ts.map +1 -0
  106. package/dist/routes/agents.js +180 -0
  107. package/dist/routes/agents.js.map +1 -0
  108. package/dist/routes/auth.d.ts +45 -0
  109. package/dist/routes/auth.d.ts.map +1 -0
  110. package/dist/routes/auth.js +261 -0
  111. package/dist/routes/auth.js.map +1 -0
  112. package/dist/routes/broker-proxy.d.ts +7 -0
  113. package/dist/routes/broker-proxy.d.ts.map +1 -0
  114. package/dist/routes/broker-proxy.js +114 -0
  115. package/dist/routes/broker-proxy.js.map +1 -0
  116. package/dist/routes/channels-integrated.d.ts +84 -0
  117. package/dist/routes/channels-integrated.d.ts.map +1 -0
  118. package/dist/routes/channels-integrated.js +644 -0
  119. package/dist/routes/channels-integrated.js.map +1 -0
  120. package/dist/routes/channels.d.ts +7 -0
  121. package/dist/routes/channels.d.ts.map +1 -0
  122. package/dist/routes/channels.js +453 -0
  123. package/dist/routes/channels.js.map +1 -0
  124. package/dist/routes/data.d.ts +7 -0
  125. package/dist/routes/data.d.ts.map +1 -0
  126. package/dist/routes/data.js +108 -0
  127. package/dist/routes/data.js.map +1 -0
  128. package/dist/routes/decisions.d.ts +31 -0
  129. package/dist/routes/decisions.d.ts.map +1 -0
  130. package/dist/routes/decisions.js +109 -0
  131. package/dist/routes/decisions.js.map +1 -0
  132. package/dist/routes/fleet.d.ts +24 -0
  133. package/dist/routes/fleet.d.ts.map +1 -0
  134. package/dist/routes/fleet.js +131 -0
  135. package/dist/routes/fleet.js.map +1 -0
  136. package/dist/routes/health.d.ts +7 -0
  137. package/dist/routes/health.d.ts.map +1 -0
  138. package/dist/routes/health.js +55 -0
  139. package/dist/routes/health.js.map +1 -0
  140. package/dist/routes/history-relaycast.d.ts +8 -0
  141. package/dist/routes/history-relaycast.d.ts.map +1 -0
  142. package/dist/routes/history-relaycast.js +165 -0
  143. package/dist/routes/history-relaycast.js.map +1 -0
  144. package/dist/routes/history.d.ts +13 -0
  145. package/dist/routes/history.d.ts.map +1 -0
  146. package/dist/routes/history.js +205 -0
  147. package/dist/routes/history.js.map +1 -0
  148. package/dist/routes/messaging.d.ts +31 -0
  149. package/dist/routes/messaging.d.ts.map +1 -0
  150. package/dist/routes/messaging.js +182 -0
  151. package/dist/routes/messaging.js.map +1 -0
  152. package/dist/routes/metrics.d.ts +26 -0
  153. package/dist/routes/metrics.d.ts.map +1 -0
  154. package/dist/routes/metrics.js +276 -0
  155. package/dist/routes/metrics.js.map +1 -0
  156. package/dist/routes/reactions.d.ts +9 -0
  157. package/dist/routes/reactions.d.ts.map +1 -0
  158. package/dist/routes/reactions.js +76 -0
  159. package/dist/routes/reactions.js.map +1 -0
  160. package/dist/routes/relay-config.d.ts +4 -0
  161. package/dist/routes/relay-config.d.ts.map +1 -0
  162. package/dist/routes/relay-config.js +50 -0
  163. package/dist/routes/relay-config.js.map +1 -0
  164. package/dist/routes/settings.d.ts +6 -0
  165. package/dist/routes/settings.d.ts.map +1 -0
  166. package/dist/routes/settings.js +119 -0
  167. package/dist/routes/settings.js.map +1 -0
  168. package/dist/routes/spawn.d.ts +74 -0
  169. package/dist/routes/spawn.d.ts.map +1 -0
  170. package/dist/routes/spawn.js +520 -0
  171. package/dist/routes/spawn.js.map +1 -0
  172. package/dist/routes/system.d.ts +21 -0
  173. package/dist/routes/system.d.ts.map +1 -0
  174. package/dist/routes/system.js +186 -0
  175. package/dist/routes/system.js.map +1 -0
  176. package/dist/routes/tasks.d.ts +27 -0
  177. package/dist/routes/tasks.d.ts.map +1 -0
  178. package/dist/routes/tasks.js +103 -0
  179. package/dist/routes/tasks.js.map +1 -0
  180. package/dist/routes/ui.d.ts +6 -0
  181. package/dist/routes/ui.d.ts.map +1 -0
  182. package/dist/routes/ui.js +114 -0
  183. package/dist/routes/ui.js.map +1 -0
  184. package/dist/server.d.ts.map +1 -1
  185. package/dist/server.js +337 -6072
  186. package/dist/server.js.map +1 -1
  187. package/dist/services/broker-spawn-reader.d.ts +40 -0
  188. package/dist/services/broker-spawn-reader.d.ts.map +1 -0
  189. package/dist/services/broker-spawn-reader.js +155 -0
  190. package/dist/services/broker-spawn-reader.js.map +1 -0
  191. package/dist/services/health-worker-manager.d.ts +9 -60
  192. package/dist/services/health-worker-manager.d.ts.map +1 -1
  193. package/dist/services/health-worker-manager.js +18 -148
  194. package/dist/services/health-worker-manager.js.map +1 -1
  195. package/dist/services/index.d.ts +3 -3
  196. package/dist/services/index.d.ts.map +1 -1
  197. package/dist/services/index.js +3 -3
  198. package/dist/services/index.js.map +1 -1
  199. package/dist/services/metrics.d.ts +11 -104
  200. package/dist/services/metrics.d.ts.map +1 -1
  201. package/dist/services/metrics.js +21 -190
  202. package/dist/services/metrics.js.map +1 -1
  203. package/dist/services/needs-attention.d.ts +21 -22
  204. package/dist/services/needs-attention.d.ts.map +1 -1
  205. package/dist/services/needs-attention.js +46 -71
  206. package/dist/services/needs-attention.js.map +1 -1
  207. package/dist/services/user-bridge.d.ts +0 -3
  208. package/dist/services/user-bridge.d.ts.map +1 -1
  209. package/dist/services/user-bridge.js +0 -5
  210. package/dist/services/user-bridge.js.map +1 -1
  211. package/dist/start.d.ts +4 -4
  212. package/dist/start.js +96 -89
  213. package/dist/start.js.map +1 -1
  214. package/dist/types/index.d.ts +13 -16
  215. package/dist/types/index.d.ts.map +1 -1
  216. package/dist/websocket/bridge.d.ts +12 -0
  217. package/dist/websocket/bridge.d.ts.map +1 -0
  218. package/dist/websocket/bridge.js +33 -0
  219. package/dist/websocket/bridge.js.map +1 -0
  220. package/dist/websocket/logs.d.ts +30 -0
  221. package/dist/websocket/logs.d.ts.map +1 -0
  222. package/dist/websocket/logs.js +577 -0
  223. package/dist/websocket/logs.js.map +1 -0
  224. package/dist/websocket/main.d.ts +15 -0
  225. package/dist/websocket/main.d.ts.map +1 -0
  226. package/dist/websocket/main.js +84 -0
  227. package/dist/websocket/main.js.map +1 -0
  228. package/dist/websocket/mock.d.ts +6 -0
  229. package/dist/websocket/mock.d.ts.map +1 -0
  230. package/dist/websocket/mock.js +49 -0
  231. package/dist/websocket/mock.js.map +1 -0
  232. package/dist/websocket/presence.d.ts +74 -0
  233. package/dist/websocket/presence.d.ts.map +1 -0
  234. package/dist/websocket/presence.js +330 -0
  235. package/dist/websocket/presence.js.map +1 -0
  236. package/dist/websocket/proxy.d.ts +6 -0
  237. package/dist/websocket/proxy.d.ts.map +1 -0
  238. package/dist/websocket/proxy.js +39 -0
  239. package/dist/websocket/proxy.js.map +1 -0
  240. package/dist/websocket/standalone.d.ts +17 -0
  241. package/dist/websocket/standalone.d.ts.map +1 -0
  242. package/dist/websocket/standalone.js +268 -0
  243. package/dist/websocket/standalone.js.map +1 -0
  244. package/out/404.html +1 -1
  245. package/out/_next/static/chunks/1028-da5d75e35d1420f1.js +1 -0
  246. package/out/_next/static/chunks/1528-78b17000a7e10bc6.js +2 -0
  247. package/out/_next/static/chunks/1695-4a5d33ba715e09b4.js +1 -0
  248. package/out/_next/static/chunks/1705-36c2180d00a4a569.js +1 -0
  249. package/out/_next/static/chunks/1dd3208c-e1f87c7b3dc1a820.js +1 -0
  250. package/out/_next/static/chunks/3663-47290254b8f6f5dd.js +1 -0
  251. package/out/_next/static/chunks/3677-4b225baf4801d9b9.js +73 -0
  252. package/out/_next/static/chunks/5118-7e8ada2df38eef07.js +1 -0
  253. package/out/_next/static/chunks/5888-15cbe97c90ed5fae.js +1 -0
  254. package/out/_next/static/chunks/6773-a45343a98df3abb5.js +1 -0
  255. package/out/_next/static/chunks/6940-b824612b605e79b3.js +9 -0
  256. package/out/_next/static/chunks/7894-f4a15249082a680d.js +1 -0
  257. package/out/_next/static/chunks/9175-b3617c1e5cbfed0e.js +1 -0
  258. package/out/_next/static/chunks/9372-1a804b8d08c7a236.js +1 -0
  259. package/out/_next/static/chunks/{ab6c8a12-0a58072fbb505134.js → ab6c8a12-91438a812d94ecf0.js} +1 -1
  260. package/out/_next/static/chunks/app/_not-found/page-8e8842f82d204726.js +1 -0
  261. package/out/_next/static/chunks/app/about/page-b78577a7da8fa459.js +1 -0
  262. package/out/_next/static/chunks/app/app/[[...slug]]/page-3dffd65b6344f53e.js +1 -0
  263. package/out/_next/static/chunks/app/app/onboarding/page-b89be9aa6264a5e1.js +1 -0
  264. package/out/_next/static/chunks/app/blog/go-to-bed-wake-up-to-a-finished-product/page-fbd00893ef69e499.js +1 -0
  265. package/out/_next/static/chunks/app/blog/let-them-cook-multi-agent-orchestration/page-de2ea13649d0b6d3.js +1 -0
  266. package/out/_next/static/chunks/app/blog/page-a08e263c57a156fa.js +1 -0
  267. package/out/_next/static/chunks/app/careers/page-02228e1d6969b232.js +1 -0
  268. package/out/_next/static/chunks/app/changelog/page-1b5c1d79efc6e53a.js +1 -0
  269. package/out/_next/static/chunks/app/cloud/link/page-99654edffffb3af2.js +1 -0
  270. package/out/_next/static/chunks/app/complete-profile/page-59d146e5ddeafc5c.js +1 -0
  271. package/out/_next/static/chunks/app/connect-repos/page-995e16a976a6632c.js +1 -0
  272. package/out/_next/static/chunks/app/contact/page-273396a5ad57bcee.js +1 -0
  273. package/out/_next/static/chunks/app/dev/cli-tools/page-a71b80dcb2d5fc8d.js +1 -0
  274. package/out/_next/static/chunks/app/dev/log-viewer/page-46a6151ae1be0796.js +1 -0
  275. package/out/_next/static/chunks/app/docs/page-7c7cb603b24b7c40.js +1 -0
  276. package/out/_next/static/chunks/app/history/page-0c5cab1dab4e8886.js +1 -0
  277. package/out/_next/static/chunks/app/layout-96d72ba8ef8a43a0.js +1 -0
  278. package/out/_next/static/chunks/app/login/page-0ccbab34213df842.js +1 -0
  279. package/out/_next/static/chunks/app/metrics/page-8616272aeab9c8b0.js +1 -0
  280. package/out/_next/static/chunks/app/page-09ce10603ad9a251.js +1 -0
  281. package/out/_next/static/chunks/app/pricing/page-91c975079120c941.js +1 -0
  282. package/out/_next/static/chunks/app/privacy/{page-c21d51ac2dee3a88.js → page-a49ab271cc686644.js} +1 -1
  283. package/out/_next/static/chunks/app/providers/{page-59114505f4353512.js → page-d775d6eb5bc29e96.js} +1 -1
  284. package/out/_next/static/chunks/app/providers/setup/[provider]/page-ec4ef3cd80de807e.js +1 -0
  285. package/out/_next/static/chunks/app/security/page-d9da9bd9191e8f95.js +1 -0
  286. package/out/_next/static/chunks/app/signup/page-930eca0bf5fd299d.js +1 -0
  287. package/out/_next/static/chunks/app/terms/page-3e4827620b98613c.js +1 -0
  288. package/out/_next/static/chunks/framework-648e1ae7da590300.js +1 -0
  289. package/out/_next/static/chunks/{main-acb1b24265295d6a.js → main-2b1990080c292d92.js} +1 -1
  290. package/out/_next/static/chunks/main-app-9f6b7ff9e754a8f5.js +1 -0
  291. package/out/_next/static/chunks/pages/_app-a077b72e02273ab1.js +1 -0
  292. package/out/_next/static/chunks/pages/_error-84001666436a04e4.js +1 -0
  293. package/out/_next/static/chunks/{webpack-dd93b81e2659669c.js → webpack-7586035f1585f2db.js} +1 -1
  294. package/out/_next/static/css/eb9fc69d1e3d2bed.css +1 -0
  295. package/out/_next/static/{IxfA6RZu4trcsEMYlkQra → g3G0LMdB7lxcrU5mdM54m}/_buildManifest.js +1 -1
  296. package/out/about.html +2 -2
  297. package/out/about.txt +2 -2
  298. package/out/app/onboarding.html +1 -1
  299. package/out/app/onboarding.txt +2 -2
  300. package/out/app.html +1 -1
  301. package/out/app.txt +2 -2
  302. package/out/blog/go-to-bed-wake-up-to-a-finished-product.html +3 -3
  303. package/out/blog/go-to-bed-wake-up-to-a-finished-product.txt +1 -1
  304. package/out/blog/let-them-cook-multi-agent-orchestration.html +2 -2
  305. package/out/blog/let-them-cook-multi-agent-orchestration.txt +2 -2
  306. package/out/blog.html +2 -2
  307. package/out/blog.txt +1 -1
  308. package/out/careers.html +2 -2
  309. package/out/careers.txt +2 -2
  310. package/out/changelog.html +2 -2
  311. package/out/changelog.txt +2 -2
  312. package/out/cloud/link.html +1 -1
  313. package/out/cloud/link.txt +2 -2
  314. package/out/complete-profile.html +2 -2
  315. package/out/complete-profile.txt +2 -2
  316. package/out/connect-repos.html +1 -1
  317. package/out/connect-repos.txt +2 -2
  318. package/out/contact.html +2 -2
  319. package/out/contact.txt +2 -2
  320. package/out/dev/cli-tools.html +1 -0
  321. package/out/dev/cli-tools.txt +7 -0
  322. package/out/dev/log-viewer.html +23 -0
  323. package/out/dev/log-viewer.txt +7 -0
  324. package/out/docs.html +2 -2
  325. package/out/docs.txt +2 -2
  326. package/out/history.html +1 -1
  327. package/out/history.txt +2 -2
  328. package/out/index.html +1 -1
  329. package/out/index.txt +2 -2
  330. package/out/login.html +2 -2
  331. package/out/login.txt +2 -2
  332. package/out/metrics.html +1 -1
  333. package/out/metrics.txt +2 -2
  334. package/out/pricing.html +2 -2
  335. package/out/pricing.txt +2 -2
  336. package/out/privacy.html +2 -2
  337. package/out/privacy.txt +2 -2
  338. package/out/providers/setup/claude.html +1 -1
  339. package/out/providers/setup/claude.txt +2 -2
  340. package/out/providers/setup/codex.html +1 -1
  341. package/out/providers/setup/codex.txt +2 -2
  342. package/out/providers/setup/cursor.html +1 -1
  343. package/out/providers/setup/cursor.txt +2 -2
  344. package/out/providers.html +1 -1
  345. package/out/providers.txt +2 -2
  346. package/out/security.html +2 -2
  347. package/out/security.txt +2 -2
  348. package/out/signup.html +2 -2
  349. package/out/signup.txt +2 -2
  350. package/out/terms.html +2 -2
  351. package/out/terms.txt +2 -2
  352. package/package.json +10 -11
  353. package/out/_next/static/chunks/11-9a2993a37266dcb3.js +0 -9
  354. package/out/_next/static/chunks/118-ae2b650136a5a5fc.js +0 -1
  355. package/out/_next/static/chunks/1dd3208c-40ab0fc0f60392b8.js +0 -1
  356. package/out/_next/static/chunks/202-fc0763dd7488e58f.js +0 -1
  357. package/out/_next/static/chunks/259-83b77fa1b91ba5aa.js +0 -1
  358. package/out/_next/static/chunks/407-0c82986cf79c8ecb.js +0 -1
  359. package/out/_next/static/chunks/528-f5f676996d613c25.js +0 -2
  360. package/out/_next/static/chunks/663-ddb04081febc3678.js +0 -1
  361. package/out/_next/static/chunks/687-88b6b139a6bb0e2e.js +0 -1
  362. package/out/_next/static/chunks/695-51d25b1988644374.js +0 -1
  363. package/out/_next/static/chunks/773-54a2641043c81e55.js +0 -1
  364. package/out/_next/static/chunks/app/_not-found/page-6da9b72091e5b511.js +0 -1
  365. package/out/_next/static/chunks/app/about/page-fff7c6457683f243.js +0 -1
  366. package/out/_next/static/chunks/app/app/[[...slug]]/page-f7eca1b66fb4249b.js +0 -1
  367. package/out/_next/static/chunks/app/app/onboarding/page-129abc5da2e67971.js +0 -1
  368. package/out/_next/static/chunks/app/blog/go-to-bed-wake-up-to-a-finished-product/page-5d5f28fd126b692f.js +0 -1
  369. package/out/_next/static/chunks/app/blog/let-them-cook-multi-agent-orchestration/page-b194f207fbd91862.js +0 -1
  370. package/out/_next/static/chunks/app/blog/page-b9bd9d8703fca76a.js +0 -1
  371. package/out/_next/static/chunks/app/careers/page-a4bd8d5f4de8f4eb.js +0 -1
  372. package/out/_next/static/chunks/app/changelog/page-9a1f6ad1743d63c5.js +0 -1
  373. package/out/_next/static/chunks/app/cloud/link/page-0844c5699b027c3b.js +0 -1
  374. package/out/_next/static/chunks/app/complete-profile/page-39ed5a67916beb87.js +0 -1
  375. package/out/_next/static/chunks/app/connect-repos/page-297eddee0c39f2a3.js +0 -1
  376. package/out/_next/static/chunks/app/contact/page-3c1dd8690217fade.js +0 -1
  377. package/out/_next/static/chunks/app/docs/page-1875e981f2c3fd13.js +0 -1
  378. package/out/_next/static/chunks/app/history/page-2d5c5695c9e8b40c.js +0 -1
  379. package/out/_next/static/chunks/app/layout-0a4b99656da25511.js +0 -1
  380. package/out/_next/static/chunks/app/login/page-f69c076f5a6fc520.js +0 -1
  381. package/out/_next/static/chunks/app/metrics/page-bebbee055669a17e.js +0 -1
  382. package/out/_next/static/chunks/app/page-0ee604f7070d14c0.js +0 -1
  383. package/out/_next/static/chunks/app/pricing/page-eeae7d594af333b6.js +0 -1
  384. package/out/_next/static/chunks/app/providers/setup/[provider]/page-daf9b3e05e77ae19.js +0 -1
  385. package/out/_next/static/chunks/app/security/page-cd562730fe84a0a2.js +0 -1
  386. package/out/_next/static/chunks/app/signup/page-c242ca08101a84ff.js +0 -1
  387. package/out/_next/static/chunks/app/terms/page-c7001720e7941dc6.js +0 -1
  388. package/out/_next/static/chunks/framework-3664cab31236a9fa.js +0 -1
  389. package/out/_next/static/chunks/main-app-7f73a939a312a228.js +0 -1
  390. package/out/_next/static/chunks/pages/_app-10a93ab5b7c32eb3.js +0 -1
  391. package/out/_next/static/chunks/pages/_error-2d792b2a41857be4.js +0 -1
  392. package/out/_next/static/css/8968d98ed4c4d33f.css +0 -1
  393. /package/out/_next/static/{IxfA6RZu4trcsEMYlkQra → g3G0LMdB7lxcrU5mdM54m}/_ssgManifest.js +0 -0
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1028],{1028:function(e,t,n){n.d(t,{fM:function(){return rY},gV:function(){return r2}});var r=n(7573),s=n(7653);function a(e){let{event:t,onClick:n}=e,s=function(e){switch(e){case"agent_spawned":return"\uD83D\uDE80";case"agent_released":return"\uD83D\uDED1";case"agent_online":return"\uD83D\uDFE2";case"agent_offline":return"⚫";case"user_joined":case"user_left":return"\uD83D\uDC4B";case"broadcast":return"\uD83D\uDCE2";case"error":return"⚠️";default:return"\uD83D\uDCCC"}}(t.type),a=function(e){switch(e){case"agent_spawned":case"agent_online":return"text-green-400";case"agent_released":return"text-red-400";case"agent_offline":case"user_left":return"text-gray-400";case"user_joined":return"text-cyan-400";case"broadcast":return"text-yellow-400";case"error":return"text-red-500";default:return"text-text-muted"}}(t.type);return(0,r.jsxs)("div",{className:"flex items-start gap-3 p-3 rounded-lg hover:bg-bg-hover transition-colors ".concat(n?"cursor-pointer":""),onClick:n,children:[(0,r.jsx)("div",{className:"flex-shrink-0 w-8 h-8 flex items-center justify-center",children:t.actorAvatarUrl?(0,r.jsx)("img",{src:t.actorAvatarUrl,alt:t.actor,className:"w-8 h-8 rounded-full"}):(0,r.jsx)("span",{className:"text-lg",children:s})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"font-medium ".concat(a),children:t.actor}),(0,r.jsx)("span",{className:"text-text-muted text-sm",children:t.title})]}),t.description&&(0,r.jsx)("p",{className:"text-text-muted text-sm mt-1 line-clamp-2",children:t.description}),t.metadata&&Object.keys(t.metadata).length>0&&(()=>{let e=t.metadata.cli,n=t.metadata.task;return(0,r.jsxs)("div",{className:"flex flex-wrap gap-1 mt-2",children:[null!=e&&(0,r.jsx)("span",{className:"px-2 py-0.5 bg-bg-secondary rounded text-xs text-text-muted",children:String(e)}),null!=n&&(0,r.jsx)("span",{className:"px-2 py-0.5 bg-bg-secondary rounded text-xs text-text-muted truncate max-w-[200px]",children:String(n)})]})})()]}),(0,r.jsx)("div",{className:"flex-shrink-0 text-xs text-text-muted",children:function(e){let t=new Date,n=new Date(e),r=Math.floor((t.getTime()-n.getTime())/1e3),s=Math.floor(r/60),a=Math.floor(s/60),l=Math.floor(a/24);return r<60?"just now":s<60?"".concat(s,"m ago"):a<24?"".concat(a,"h ago"):l<7?"".concat(l,"d ago"):n.toLocaleDateString()}(t.timestamp)})]})}function l(){return(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-center p-8",children:[(0,r.jsx)("div",{className:"text-4xl mb-4",children:"\uD83D\uDCCB"}),(0,r.jsx)("h3",{className:"text-lg font-medium text-text-primary mb-2",children:"No activity yet"}),(0,r.jsx)("p",{className:"text-text-muted text-sm max-w-xs",children:"Activity will appear here as agents spawn, users join, and broadcasts are sent."})]})}function i(e){let{events:t,maxEvents:n=100,onEventClick:i}=e,o=(0,s.useMemo)(()=>[...t].sort((e,t)=>new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime()).slice(0,n),[t,n]);return 0===o.length?(0,r.jsx)(l,{}):(0,r.jsxs)("div",{className:"flex flex-col h-full",children:[(0,r.jsxs)("div",{className:"flex-shrink-0 px-4 py-3 border-b border-border-subtle",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold text-text-primary",children:"Activity"}),(0,r.jsxs)("p",{className:"text-sm text-text-muted",children:[o.length," event",1!==o.length?"s":""]})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto px-2 py-2",children:(0,r.jsx)("div",{className:"space-y-1",children:o.map(e=>(0,r.jsx)(a,{event:e,onClick:i?()=>i(e):void 0},e.id))})})]})}let o="agent-relay-pinned-agents";var c=n(5493);function d(e){let t=new Map;for(let n of e){let e=n.team||(0,c.oU)(n.name),r=(0,c.GW)(n.name),s=t.get(e);s||(s={prefix:e,displayName:h(e),color:r,agents:[],isExpanded:!0},t.set(e,s)),s.agents.push(n)}let n=Array.from(t.values()).sort((e,t)=>e.prefix.localeCompare(t.prefix));for(let e of n)e.agents.sort((e,t)=>e.name.localeCompare(t.name));return n}function u(e){let t=e.split("-").filter(Boolean);return 0===t.length?e:h(t[t.length-1])}function x(e){return e.split("-").filter(Boolean).map(h).join(" > ")}function m(e,t){return t?e.filter(e=>(function(e,t){if(!t)return!0;let n=t.toLowerCase(),r=e.toLowerCase();return!!r.includes(n)||r.split("-").some(e=>e.includes(n))})(e.name,t)):e}function h(e){return e?e.charAt(0).toUpperCase()+e.slice(1):e}function p(e){let t=0,n=0,r=0;for(let s of e)"online"===s.status?t++:"offline"===s.status&&n++,s.needsAttention&&r++;return{total:e.length,online:t,offline:n,needsAttention:r}}var g=n(3318);function f(e){if(e<6e4)return"<1m";let t=Math.floor(e/6e4);if(t<60)return"".concat(t,"m");let n=Math.floor(t/60),r=t%60;return 0===r?"".concat(n,"h"):"".concat(n,"h ").concat(r,"m")}function b(e){var t,n,s,a,l,i;let{agent:o,isSelected:d=!1,showBreadcrumb:m=!1,compact:h=!1,displayNameOverride:p,isPinned:b=!1,isMaxPinned:C=!1,onClick:S,onMessageClick:M,onReleaseClick:L,onLogsClick:D,onProfileClick:A,onPinToggle:E}=e,T=(0,c.GW)(o.name),W=(0,c.hP)(o.name),P=p||u(o.name),I=!o.lastMessageReceivedAt||o.lastOutputAt&&o.lastOutputAt>=o.lastMessageReceivedAt?0:Date.now()-o.lastMessageReceivedAt,B=o.isStuck||I>0,_=B?c.yh.stuck:c.yh[o.status]||c.yh.offline,R="online"===o.status,F=function(e,t,n,r){if(n&&r)return"Stuck - Agent received message ".concat(f(r)," ago but hasn't responded");if(t)return"Processing - Agent is actively working";switch(e){case"online":return"Connected - Agent is online and ready";case"offline":return"Disconnected - Agent is not connected";case"busy":return"Busy - Agent is occupied with a task";case"processing":return"Processing - Agent is actively working";case"error":return"Error - Agent encountered an error";case"attention":return"Attention - Agent requires user input";case"stuck":return"Stuck - Agent may be blocked or unresponsive";default:return"Status: ".concat(e)}}(o.status,o.isProcessing,B,I),U=()=>{null==S||S(o)},O=e=>{e.stopPropagation(),null==L||L(o)},H=e=>{e.stopPropagation(),null==D||D(o)},z=e=>{e.stopPropagation(),null==A||A(o)},G=e=>{e.stopPropagation(),null==E||E(o)};return h?(0,r.jsxs)("div",{className:"\n group relative flex items-start gap-3 py-2.5 px-3 rounded-lg cursor-pointer\n transition-all duration-300 ease-out\n hover:bg-bg-hover\n ".concat(d?"bg-bg-active":"","\n "),onClick:U,style:{borderLeft:d?"2px solid ".concat(T.primary):"2px solid transparent",boxShadow:d?"inset 4px 0 12px -4px ".concat(T.primary,"40"):"none"},children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsxs)("div",{className:"\n w-8 h-8 rounded-lg flex items-center justify-center font-bold text-[11px] tracking-wide\n transition-all duration-300 relative overflow-hidden\n ".concat(R?"shadow-lg":"opacity-60","\n "),style:{background:"linear-gradient(135deg, ".concat(T.primary,", ").concat(T.primary,"99)"),boxShadow:R?"0 2px 12px ".concat(T.primary,"50"):"none"},children:[(0,r.jsx)("div",{className:"absolute inset-0 opacity-30",style:{background:"linear-gradient(135deg, rgba(255,255,255,0.3) 0%, transparent 50%)"}}),(0,r.jsx)("span",{className:"relative z-10",style:{color:T.text},children:W})]}),R&&(0,r.jsx)("div",{className:"absolute -bottom-0.5 -right-0.5 w-3 h-3 rounded-full border-2 border-bg-primary",style:{backgroundColor:_,boxShadow:"0 0 8px ".concat(_)},title:F})]}),(0,r.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col",children:[(0,r.jsxs)("div",{className:"flex items-start gap-1.5 flex-wrap",children:[(0,r.jsx)("span",{className:"\n text-[13px] font-semibold tracking-tight transition-colors duration-200\n whitespace-normal break-words leading-snug\n ".concat(R?"text-text-primary":"text-text-secondary","\n "),children:P}),o.isLocal&&(0,r.jsx)("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[9px] font-medium uppercase tracking-wider bg-warning-light text-warning border border-warning/30",title:"Local agent from ".concat(o.brokerName||"linked broker"),children:"Local"}),b&&(0,r.jsx)("span",{className:"inline-flex items-center text-amber-400",title:"Pinned to top",children:(0,r.jsx)(k,{size:12,filled:!0})})]}),o.cli&&(0,r.jsx)("span",{className:"text-[10px] text-text-muted truncate font-mono opacity-70 mt-0.5",children:o.cli}),(o.model||(null===(a=o.profile)||void 0===a?void 0:a.model))&&(0,r.jsx)("span",{className:"text-[9px] text-accent-muted font-mono opacity-80 mt-0.5",title:"Model: ".concat(o.model||(null===(l=o.profile)||void 0===l?void 0:l.model)),children:o.model||(null===(i=o.profile)||void 0===i?void 0:i.model)}),(0,r.jsxs)("div",{className:"mt-2 flex items-center flex-wrap gap-2",children:[E&&(0,r.jsx)("button",{className:"\n relative bg-transparent border border-transparent p-1.5 cursor-pointer\n flex items-center justify-center rounded-md transition-all duration-200\n ".concat(b?"text-amber-400 hover:bg-amber-400/10 hover:border-amber-400/30":"text-text-dim hover:bg-amber-400/10 hover:border-amber-400/30 hover:text-amber-400","\n ").concat(!b&&C?"opacity-40 cursor-not-allowed":"","\n "),onClick:G,title:b?"Unpin from top":C?"Maximum pins reached (5)":"Pin to top",disabled:!b&&C,children:(0,r.jsx)(k,{size:16,filled:b})}),A&&(0,r.jsx)("button",{className:"relative bg-transparent border border-transparent text-text-dim p-1.5 cursor-pointer flex items-center justify-center rounded-md transition-all duration-200 opacity-100 hover:bg-accent-purple/10 hover:border-accent-purple/30 hover:text-accent-purple",onClick:z,title:"View profile",children:(0,r.jsx)(N,{})}),D&&(0,r.jsx)("button",{className:"relative bg-transparent border border-transparent text-text-dim p-1.5 cursor-pointer flex items-center justify-center rounded-md transition-all duration-200 opacity-100 hover:bg-accent-cyan/10 hover:border-accent-cyan/30 hover:text-accent-cyan",onClick:H,title:"View logs",children:(0,r.jsx)(j,{})}),o.isSpawned&&L&&(0,r.jsx)("button",{className:"relative bg-transparent border border-transparent text-text-dim p-1.5 cursor-pointer flex items-center justify-center rounded-md transition-all duration-200 opacity-100 hover:bg-error/10 hover:border-error/30 hover:text-error",onClick:O,title:"Kill agent",children:(0,r.jsx)(y,{})}),o.isProcessing?(0,r.jsx)("div",{title:F,children:(0,r.jsx)(g.sv,{isProcessing:!0})}):(0,r.jsx)("div",{className:"\n w-2 h-2 rounded-full transition-all duration-300\n ".concat(R?"animate-pulse":"","\n "),style:{backgroundColor:_,boxShadow:R?"0 0 6px ".concat(_):"none"},title:F}),B&&(0,r.jsxs)("div",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded bg-warning-light text-warning text-[10px] font-medium animate-pulse",title:F,children:[(0,r.jsx)(w,{}),(0,r.jsx)("span",{children:f(I)})]})]})]})]}):(0,r.jsxs)("div",{className:"\n rounded-lg p-3 cursor-pointer transition-all duration-200\n hover:shadow-md hover:-translate-y-px\n ".concat(d?"border-2 shadow-[0_0_0_2px_rgba(74,158,255,0.15)]":"border","\n "),onClick:U,style:{backgroundColor:T.light,borderColor:T.primary},children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsxs)("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center font-semibold text-sm relative",style:{backgroundColor:T.primary},children:[(0,r.jsx)("span",{style:{color:T.text},children:W}),(0,r.jsx)("div",{className:"absolute -bottom-0.5 -right-0.5 w-3 h-3 rounded-full border-2 border-bg-secondary",style:{backgroundColor:_},title:F})]}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"font-semibold text-sm text-text-primary",children:P}),o.isLocal&&(0,r.jsx)("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[9px] font-medium uppercase tracking-wider bg-warning-light text-warning border border-warning/30",title:"Local agent from ".concat(o.brokerName||"linked broker"),children:"Local"}),b&&(0,r.jsx)("span",{className:"inline-flex items-center text-amber-400",title:"Pinned to top",children:(0,r.jsx)(k,{size:14,filled:!0})}),o.needsAttention&&(0,r.jsx)("span",{className:"bg-error text-white text-[10px] font-bold w-4 h-4 rounded-full flex items-center justify-center",title:"Needs Attention - Agent requires user input or has pending decisions",children:"!"}),B&&(0,r.jsxs)("span",{className:"bg-warning text-white text-[10px] font-bold px-1.5 py-0.5 rounded flex items-center gap-1",title:F,children:[(0,r.jsx)(w,{})," ",f(I)]})]}),m?(0,r.jsx)("span",{className:"text-xs text-text-muted truncate block",children:o.isLocal?o.brokerName||o.machineId:x(o.name)}):(0,r.jsx)("span",{className:"text-xs text-text-muted truncate block",children:o.isLocal?o.brokerName||o.machineId:o.name}),o.agentId&&(0,r.jsxs)("span",{className:"text-[10px] text-text-muted font-mono opacity-70",title:"Agent ID (use to resume)",children:["ID: ",o.agentId]})]})]}),o.isProcessing&&(0,r.jsxs)("div",{className:"mt-2 p-2 bg-accent-light rounded flex items-center gap-2 border border-accent/20",children:[(0,r.jsx)(g.Fw,{isProcessing:!0,processingStartedAt:o.processingStartedAt,size:"medium",showElapsed:!0}),(0,r.jsx)("span",{className:"text-xs text-accent font-medium",children:"Thinking..."})]}),o.currentTask&&!o.isProcessing&&(0,r.jsxs)("div",{className:"mt-2 p-2 bg-bg-hover rounded text-xs",children:[(0,r.jsx)("span",{className:"text-text-muted mr-1",children:"Working on:"}),(0,r.jsx)("span",{className:"text-text-primary line-clamp-2",title:o.currentTask,children:o.currentTask})]}),(0,r.jsxs)("div",{className:"mt-3 flex justify-between items-center",children:[(0,r.jsxs)("div",{className:"flex gap-2 text-xs text-text-muted flex-wrap",children:[o.cli&&(0,r.jsx)("span",{className:"bg-bg-hover py-0.5 px-1.5 rounded",children:o.cli}),(o.model||(null===(t=o.profile)||void 0===t?void 0:t.model))&&(0,r.jsx)("span",{className:"bg-accent-cyan/10 text-accent-cyan py-0.5 px-1.5 rounded font-mono text-[10px]",title:"Model: ".concat(o.model||(null===(n=o.profile)||void 0===n?void 0:n.model)),children:o.model||(null===(s=o.profile)||void 0===s?void 0:s.model)}),void 0!==o.messageCount&&o.messageCount>0&&(0,r.jsxs)("span",{style:{color:T.primary},children:[o.messageCount," msgs"]}),o.isSpawned&&(0,r.jsx)("span",{className:"bg-accent-light text-accent text-[10px] py-0.5 px-1.5 rounded uppercase font-medium",children:"spawned"})]}),(0,r.jsxs)("div",{className:"flex gap-1.5",children:[E&&(0,r.jsx)("button",{className:"\n rounded-md py-1.5 px-2.5 cursor-pointer flex items-center justify-center gap-1 transition-all duration-200\n border\n ".concat(b?"bg-amber-500/10 text-amber-400 border-amber-500/30 hover:bg-amber-500/20":"bg-bg-tertiary text-text-muted border-border hover:bg-amber-500/10 hover:text-amber-400 hover:border-amber-500/30","\n ").concat(!b&&C?"opacity-40 cursor-not-allowed":"hover:scale-105","\n active:scale-[0.98]\n "),onClick:G,title:b?"Unpin from top":C?"Maximum pins reached (5)":"Pin to top",disabled:!b&&C,children:(0,r.jsx)(k,{size:16,filled:b})}),A&&(0,r.jsx)("button",{className:"bg-accent-purple/10 text-accent-purple border border-accent-purple/30 rounded-md py-1.5 px-2.5 cursor-pointer flex items-center justify-center gap-1 transition-all duration-200 hover:bg-accent-purple/20 hover:scale-105 active:scale-[0.98]",onClick:z,title:"View profile",children:(0,r.jsx)(N,{})}),D&&(0,r.jsx)("button",{className:"bg-accent-cyan/10 text-accent-cyan border border-accent-cyan/30 rounded-md py-1.5 px-2.5 cursor-pointer flex items-center justify-center gap-1 transition-all duration-200 hover:bg-accent-cyan/20 hover:scale-105 active:scale-[0.98]",onClick:H,title:"View logs",children:(0,r.jsx)(j,{})}),o.isSpawned&&L&&(0,r.jsx)("button",{className:"bg-error/10 text-error border border-error/30 rounded-md py-1.5 px-2.5 cursor-pointer flex items-center justify-center gap-1 transition-all duration-200 hover:bg-error/20 hover:scale-105 active:scale-[0.98]",onClick:O,title:"Release agent",children:(0,r.jsx)(y,{})}),M&&(0,r.jsx)("button",{className:"text-white border-none rounded py-1 px-2 cursor-pointer flex items-center justify-center transition-opacity duration-200 hover:opacity-90",style:{backgroundColor:T.primary},onClick:e=>{e.stopPropagation(),null==M||M(o)},title:"Send message",children:(0,r.jsx)(v,{})})]})]})]})}function v(){return(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function y(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",className:"release-icon",children:[(0,r.jsx)("path",{d:"M12 22c5.523 0 10-4.477 10-10a9.96 9.96 0 0 0-3-7.141",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),(0,r.jsx)("path",{d:"M12 22C6.477 22 2 17.523 2 12a9.96 9.96 0 0 1 3-7.141",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),(0,r.jsx)("line",{x1:"12",y1:"2",x2:"12",y2:"12",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"})]})}function j(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("polyline",{points:"4 17 10 11 4 5"}),(0,r.jsx)("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function w(){return(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,r.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}function N(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),(0,r.jsx)("circle",{cx:"12",cy:"7",r:"4"})]})}function k(e){let{size:t=16,filled:n=!1}=e;return(0,r.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:n?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M12 17v5"}),(0,r.jsx)("path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4.76Z"})]})}function C(e){let{agents:t,selectedAgent:n,searchQuery:a="",pinnedAgents:l=[],isMaxPinned:i=!1,onAgentSelect:o,onAgentMessage:c,onReleaseClick:u,onLogsClick:x,onProfileClick:h,onPinToggle:p,compact:g=!1,showGroupStats:f=!0}=e,[v,y]=(0,s.useState)(new Set),[j,w]=(0,s.useState)(!0),[N,k]=(0,s.useState)(!1),C=(0,s.useMemo)(()=>m(t.filter(e=>!e.name.startsWith("__setup__")&&"Dashboard"!==e.name),a),[t,a]),{pinnedAgentsList:M,unpinnedAgents:T}=(0,s.useMemo)(()=>{let e=[],t=[];for(let n of C)l.includes(n.name)?e.push(n):t.push(n);return e.sort((e,t)=>l.indexOf(e.name)-l.indexOf(t.name)),{pinnedAgentsList:e,unpinnedAgents:t}},[C,l]),W=(0,s.useMemo)(()=>d(T),[T]),P=(0,s.useRef)(!1);(0,s.useEffect)(()=>{!P.current&&W.length>0&&(y(new Set(W.map(e=>e.prefix))),P.current=!0)},[W]);let I=e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return 0===t.length?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-10 px-5 text-text-muted text-center",children:[(0,r.jsx)(L,{}),(0,r.jsx)("p",{children:"No agents connected"})]}):0===C.length?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-10 px-5 text-text-muted text-center",children:[(0,r.jsx)(D,{}),(0,r.jsxs)("p",{children:['No agents match "',a,'"']})]}):(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center py-2 px-3 text-xs text-text-muted",children:[(0,r.jsxs)("span",{children:[C.length," ",1===C.length?"agent":"agents"]}),(0,r.jsx)("button",{className:"bg-transparent border-none text-accent cursor-pointer text-xs hover:underline",onClick:()=>{N?(k(!1),y(new Set(W.map(e=>e.prefix))),w(!0)):k(!0)},children:N?"Expand all":"Collapse all"})]}),!N&&(0,r.jsxs)(r.Fragment,{children:[M.length>0&&(0,r.jsxs)("div",{className:"mb-2",children:[(0,r.jsxs)("button",{className:"flex items-center gap-2 w-full py-2 px-3 bg-transparent border-none cursor-pointer text-sm text-left rounded transition-colors duration-200 relative hover:bg-amber-400/5",onClick:()=>w(!j),children:[(0,r.jsx)("div",{className:"absolute left-0 top-1 bottom-1 w-[3px] rounded-sm bg-amber-400"}),(0,r.jsx)(A,{expanded:j}),(0,r.jsx)(E,{}),(0,r.jsx)("span",{className:"font-semibold text-amber-400",children:"Pinned"}),(0,r.jsxs)("span",{className:"text-text-muted font-normal",children:["(",M.length,")"]})]}),j&&(0,r.jsx)("div",{className:"py-1 pl-4 flex flex-col gap-1",children:M.map(e=>(0,r.jsx)(b,{agent:e,isSelected:e.name===n,compact:g,isPinned:!0,isMaxPinned:i,onClick:o,onMessageClick:c,onReleaseClick:u,onLogsClick:x,onProfileClick:h,onPinToggle:p},e.name))})]}),W.map(e=>(0,r.jsx)(S,{group:e,isExpanded:v.has(e.prefix),selectedAgent:n,compact:g,showStats:f,pinnedAgents:l,isMaxPinned:i,onToggle:()=>I(e.prefix),onAgentSelect:o,onAgentMessage:c,onReleaseClick:u,onLogsClick:x,onProfileClick:h,onPinToggle:p},e.prefix))]})]})}function S(e){let{group:t,isExpanded:n,selectedAgent:s,compact:a,showStats:l,pinnedAgents:i=[],isMaxPinned:o=!1,onToggle:d,onAgentSelect:x,onAgentMessage:m,onReleaseClick:h,onLogsClick:g,onProfileClick:f,onPinToggle:v}=e,y=l?p(t.agents):null;if(1===t.agents.length&&t.agents[0].name.toLowerCase()===t.prefix.toLowerCase()){let e=t.agents[0];return(0,r.jsx)("div",{className:"mb-1 py-1 px-2",children:(0,r.jsx)(b,{agent:e,isSelected:e.name===s,compact:a,isPinned:i.includes(e.name),isMaxPinned:o,onClick:x,onMessageClick:m,onReleaseClick:h,onLogsClick:g,onProfileClick:f,onPinToggle:v},e.name)})}return(0,r.jsxs)("div",{className:"mb-1",children:[(0,r.jsxs)("button",{className:"flex items-center gap-2 w-full py-2 px-3 bg-transparent border-none cursor-pointer text-sm text-left rounded transition-colors duration-200 relative hover:bg-[var(--group-light)]",onClick:d,style:{"--group-color":t.color.primary,"--group-light":t.color.light},children:[(0,r.jsx)("div",{className:"absolute left-0 top-1 bottom-1 w-[3px] rounded-sm",style:{backgroundColor:t.color.primary}}),(0,r.jsx)(M,{expanded:n}),(0,r.jsx)("span",{className:"font-semibold text-text-primary",children:t.displayName}),(0,r.jsxs)("span",{className:"text-text-muted font-normal",children:["(",t.agents.length,")"]}),l&&y&&(0,r.jsxs)("div",{className:"ml-auto flex gap-2",children:[y.online>0&&(0,r.jsxs)("span",{className:"flex items-center gap-1 text-xs text-text-muted",title:"".concat(y.online," agent").concat(y.online>1?"s":""," online"),children:[(0,r.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:c.yh.online}}),y.online]}),y.needsAttention>0&&(0,r.jsxs)("span",{className:"flex items-center gap-1 text-xs text-text-muted",title:"".concat(y.needsAttention," agent").concat(y.needsAttention>1?"s":""," need").concat(1===y.needsAttention?"s":""," attention"),children:[(0,r.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:c.yh.attention}}),y.needsAttention]})]})]}),n&&(0,r.jsx)("div",{className:"py-1 pl-4 flex flex-col gap-1",children:t.agents.map(e=>(0,r.jsx)(b,{agent:e,isSelected:e.name===s,compact:a,displayNameOverride:u(e.name),isPinned:i.includes(e.name),isMaxPinned:o,onClick:x,onMessageClick:m,onReleaseClick:h,onLogsClick:g,onProfileClick:f,onPinToggle:v},e.name))})]})}function M(e){let{expanded:t}=e;return(0,r.jsx)("svg",{className:"text-text-muted transition-transform duration-200 ".concat(t?"rotate-90":""),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("polyline",{points:"9 18 15 12 9 6"})})}function L(){return(0,r.jsxs)("svg",{className:"mb-3 opacity-50",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[(0,r.jsx)("circle",{cx:"12",cy:"8",r:"5"}),(0,r.jsx)("path",{d:"M20 21a8 8 0 1 0-16 0"})]})}function D(){return(0,r.jsxs)("svg",{className:"mb-3 opacity-50",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[(0,r.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,r.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function A(e){let{expanded:t}=e;return(0,r.jsx)("svg",{className:"text-amber-400 transition-transform duration-200 ".concat(t?"rotate-90":""),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("polyline",{points:"9 18 15 12 9 6"})})}function E(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-amber-400",children:[(0,r.jsx)("path",{d:"M12 17v5"}),(0,r.jsx)("path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4.76Z"})]})}function T(e){return e.split(/[-_]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" ")}function W(e){let{projects:t,localAgents:n=[],bridgeAgents:a=[],currentProject:l,selectedAgent:i,searchQuery:o="",pinnedAgents:c=[],isMaxPinned:d=!1,onProjectSelect:u,onAgentSelect:x,onReleaseClick:m,onLogsClick:h,onProfileClick:p,onPinToggle:g,compact:f=!1}=e,[b,v]=(0,s.useState)(()=>new Set(t.map(e=>e.id))),[y,j]=(0,s.useState)(!1),w=e=>e.filter(e=>!e.name.startsWith("__setup__")&&"Dashboard"!==e.name&&!e.isHuman&&"dashboard"!==e.cli),N=(0,s.useMemo)(()=>{let e=o.toLowerCase().trim(),r=w(n),s=w(a),l=t.map(e=>({...e,agents:w(e.agents)}));if(!e)return{projects:l,localAgents:r,bridgeAgents:s};let i=r.filter(t=>{var n;return t.name.toLowerCase().includes(e)||(null===(n=t.currentTask)||void 0===n?void 0:n.toLowerCase().includes(e))}),c=s.filter(t=>{var n;return t.name.toLowerCase().includes(e)||(null===(n=t.currentTask)||void 0===n?void 0:n.toLowerCase().includes(e))});return{projects:l.map(t=>{var n;let r=(null===(n=t.name)||void 0===n?void 0:n.toLowerCase().includes(e))||t.path.toLowerCase().includes(e),s=t.agents.filter(t=>{var n;return t.name.toLowerCase().includes(e)||(null===(n=t.currentTask)||void 0===n?void 0:n.toLowerCase().includes(e))});return r||s.length>0?{...t,agents:r?t.agents:s}:null}).filter(Boolean),localAgents:i,bridgeAgents:c}},[t,n,a,o]),k=e=>{v(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},C=N.localAgents.length+N.bridgeAgents.length+N.projects.reduce((e,t)=>e+t.agents.length,0);if(0===C&&0===t.length&&0===n.length)return(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-10 px-5 text-text-muted text-center",children:[(0,r.jsx)(U,{}),(0,r.jsx)("p",{children:"No projects or agents"})]});if(0===C&&o)return(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-10 px-5 text-text-muted text-center",children:[(0,r.jsx)(O,{}),(0,r.jsxs)("p",{children:['No results for "',o,'"']})]});let S=N.projects.length>1;return(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center py-2 px-3 text-xs text-text-muted",children:[(0,r.jsxs)("span",{children:[C," ",1===C?"agent":"agents"]}),(0,r.jsx)("button",{className:"bg-transparent border-none text-accent cursor-pointer text-xs hover:underline",onClick:()=>{if(y){j(!1);let e=new Set(N.projects.map(e=>e.id));N.localAgents.length>0&&e.add("__local__"),v(e)}else j(!0)},children:y?"Expand all":"Collapse all"})]}),!y&&(0,r.jsxs)(r.Fragment,{children:[S&&N.bridgeAgents.length>0&&(0,r.jsx)(I,{agents:N.bridgeAgents,selectedAgent:i,compact:f,pinnedAgents:c,isMaxPinned:d,onAgentSelect:e=>null==x?void 0:x(e),onReleaseClick:m,onLogsClick:h,onProfileClick:p,onPinToggle:g}),!S&&N.localAgents.length>0&&(0,r.jsx)(P,{project:{id:"__local__",path:"",name:"Local",agents:N.localAgents},isExpanded:b.has("__local__"),isCurrentProject:!0,selectedAgent:i,compact:f,pinnedAgents:c,isMaxPinned:d,onToggle:()=>k("__local__"),onAgentSelect:e=>null==x?void 0:x(e),onReleaseClick:m,onLogsClick:h,onProfileClick:p,onPinToggle:g}),N.projects.map(e=>(0,r.jsx)(P,{project:e,isExpanded:b.has(e.id),isCurrentProject:e.id===l,selectedAgent:i,compact:f,isBridgeMode:S,pinnedAgents:c,isMaxPinned:d,onToggle:()=>k(e.id),onProjectSelect:()=>null==u?void 0:u(e),onAgentSelect:t=>null==x?void 0:x(t,e),onReleaseClick:m,onLogsClick:h,onProfileClick:p,onPinToggle:g},e.id))]})]})}function P(e){var t;let{project:n,isExpanded:a,isCurrentProject:l,selectedAgent:i,compact:o,isBridgeMode:d=!1,pinnedAgents:u=[],isMaxPinned:x=!1,onToggle:m,onProjectSelect:h,onAgentSelect:p,onReleaseClick:g,onLogsClick:f,onProfileClick:v,onPinToggle:y}=e,[j,w]=(0,s.useState)(new Set),N=(0,s.useMemo)(()=>{let e=0,t=0;for(let r of n.agents)"online"===r.status&&e++,r.needsAttention&&t++;return{online:e,needsAttention:t,total:n.agents.length}},[n.agents]),{teams:k,ungroupedAgents:C}=(0,s.useMemo)(()=>{let e=new Map,t=[];for(let r of n.agents)if(r.team){let t=e.get(r.team)||[];t.push(r),e.set(r.team,t)}else t.push(r);return{teams:Array.from(e.entries()).map(e=>{let[t,n]=e;return{name:t,agents:n}}).sort((e,t)=>e.name.localeCompare(t.name)),ungroupedAgents:t}},[n.agents]),S=e=>{w(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};(0,s.useEffect)(()=>{a&&0===j.size&&k.length>0&&w(new Set(k.map(e=>e.name)))},[a,k,j]);let M=(0,c.GW)(n.name||n.id),L=n.name||n.path.split("/").pop()||n.id;return(0,r.jsxs)("div",{className:"mb-1",children:[(0,r.jsxs)("button",{className:"group flex items-center gap-2 w-full py-2.5 px-3 bg-none border-none cursor-pointer text-[13px] text-left rounded-md transition-colors duration-200 relative text-text-primary hover:bg-bg-hover ".concat(l?"bg-success-light":""),onClick:m,onDoubleClick:h,style:{"--project-color":M.primary,"--project-light":M.light},children:[(0,r.jsx)("div",{className:"absolute left-0 top-1 bottom-1 w-[3px] rounded-sm",style:{background:M.primary}}),(0,r.jsx)(_,{expanded:a}),(0,r.jsx)(R,{color:M.primary}),(0,r.jsx)("span",{className:"font-semibold text-text-primary whitespace-nowrap overflow-hidden text-ellipsis",children:L}),(0,r.jsxs)("span",{className:"text-text-muted font-normal flex-shrink-0",children:["(",N.total,")"]}),(0,r.jsxs)("div",{className:"ml-auto flex gap-2 flex-shrink-0",children:[N.online>0&&(0,r.jsxs)("span",{className:"flex items-center gap-1 text-[11px] text-text-dim",children:[(0,r.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:c.yh.online}}),N.online]}),N.needsAttention>0&&(0,r.jsxs)("span",{className:"flex items-center gap-1 text-[11px] text-text-dim",children:[(0,r.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:c.yh.attention}}),N.needsAttention]})]}),(null===(t=n.lead)||void 0===t?void 0:t.connected)&&(0,r.jsx)("span",{className:"text-[#ffd700] text-xs ml-1",title:"Lead: ".concat(n.lead.name),children:"★"}),d&&!l&&h&&(0,r.jsx)("span",{role:"button",tabIndex:0,className:"ml-2 py-1 px-2 text-[10px] font-medium bg-accent-cyan/20 text-accent-cyan rounded cursor-pointer opacity-0 group-hover:opacity-100 transition-opacity hover:bg-accent-cyan/30",onClick:e=>{e.stopPropagation(),h()},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),e.stopPropagation(),h())},title:"Switch to this project",children:"Switch"})]}),a&&(0,r.jsxs)("div",{className:"py-1 pl-5 flex flex-col gap-1",children:[k.map(e=>(0,r.jsxs)("div",{className:"mb-0.5",children:[(0,r.jsxs)("button",{className:"flex items-center gap-1.5 w-full py-1.5 px-2 bg-none border-none cursor-pointer text-xs text-left rounded transition-colors duration-200 text-text-secondary hover:bg-bg-hover",onClick:()=>S(e.name),children:[(0,r.jsx)(_,{expanded:j.has(e.name)}),(0,r.jsx)(F,{}),(0,r.jsx)("span",{className:"font-medium text-text-secondary",children:e.name}),(0,r.jsxs)("span",{className:"text-text-muted font-normal",children:["(",e.agents.length,")"]})]}),j.has(e.name)&&(0,r.jsx)("div",{className:"py-0.5 pl-4 flex flex-col gap-1",children:e.agents.map(t=>(0,r.jsx)(b,{agent:t,isSelected:t.name===i,compact:o,displayNameOverride:function(e,t){let n=e.toLowerCase(),r=t.toLowerCase().replace(/-?team$/i,"");if(r&&n.startsWith(r+"-")||r&&n.startsWith(r+"_"))return T(e.substring(r.length+1));let s=e.split("-");return s.length>1?T(s[s.length-1]):T(e)}(t.name,e.name),isPinned:u.includes(t.name),isMaxPinned:x,onClick:p,onReleaseClick:g,onLogsClick:f,onProfileClick:v,onPinToggle:y},t.name))})]},e.name)),C.map(e=>(0,r.jsx)(b,{agent:e,isSelected:e.name===i,compact:o,isPinned:u.includes(e.name),isMaxPinned:x,onClick:p,onReleaseClick:g,onLogsClick:f,onProfileClick:v,onPinToggle:y},e.name))]})]})}function I(e){let{agents:t,selectedAgent:n,compact:a,pinnedAgents:l=[],isMaxPinned:i=!1,onAgentSelect:o,onReleaseClick:c,onLogsClick:d,onProfileClick:u,onPinToggle:x}=e,[m,h]=(0,s.useState)(!0);return(0,r.jsxs)("div",{className:"mb-2",children:[(0,r.jsxs)("button",{className:"flex items-center gap-2 w-full py-2.5 px-3 bg-none border-none cursor-pointer text-[13px] text-left rounded-md transition-colors duration-200 relative text-text-primary hover:bg-accent-purple/10",onClick:()=>h(!m),children:[(0,r.jsx)("div",{className:"absolute left-0 top-1 bottom-1 w-[3px] rounded-sm bg-accent-purple"}),(0,r.jsx)(_,{expanded:m}),(0,r.jsx)(B,{}),(0,r.jsx)("span",{className:"font-semibold text-text-primary",children:"Bridge"}),(0,r.jsxs)("span",{className:"text-text-muted font-normal flex-shrink-0",children:["(",t.length,")"]})]}),m&&(0,r.jsx)("div",{className:"py-1 pl-5 flex flex-col gap-1",children:t.map(e=>(0,r.jsx)(b,{agent:e,isSelected:e.name===n,compact:a,isPinned:l.includes(e.name),isMaxPinned:i,onClick:o,onReleaseClick:c,onLogsClick:d,onProfileClick:u,onPinToggle:x},e.name))})]})}function B(){return(0,r.jsxs)("svg",{className:"flex-shrink-0 text-accent-purple",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,r.jsx)("circle",{cx:"5",cy:"5",r:"2"}),(0,r.jsx)("circle",{cx:"19",cy:"5",r:"2"}),(0,r.jsx)("circle",{cx:"5",cy:"19",r:"2"}),(0,r.jsx)("circle",{cx:"19",cy:"19",r:"2"}),(0,r.jsx)("line",{x1:"9.5",y1:"9.5",x2:"6.5",y2:"6.5"}),(0,r.jsx)("line",{x1:"14.5",y1:"9.5",x2:"17.5",y2:"6.5"}),(0,r.jsx)("line",{x1:"9.5",y1:"14.5",x2:"6.5",y2:"17.5"}),(0,r.jsx)("line",{x1:"14.5",y1:"14.5",x2:"17.5",y2:"17.5"})]})}function _(e){let{expanded:t}=e;return(0,r.jsx)("svg",{className:"transition-transform duration-200 text-text-muted flex-shrink-0 ".concat(t?"rotate-90":""),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("polyline",{points:"9 18 15 12 9 6"})})}function R(e){let{color:t}=e;return(0,r.jsx)("svg",{className:"flex-shrink-0",style:{color:t},width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function F(){return(0,r.jsxs)("svg",{className:"text-text-muted flex-shrink-0",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),(0,r.jsx)("circle",{cx:"9",cy:"7",r:"4"}),(0,r.jsx)("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),(0,r.jsx)("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}function U(){return(0,r.jsx)("svg",{className:"mb-3 opacity-50",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",children:(0,r.jsx)("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function O(){return(0,r.jsxs)("svg",{className:"mb-3 opacity-50",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[(0,r.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,r.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function H(e){let{threads:t,currentThread:n,onThreadSelect:s,totalUnreadCount:a=0,isCollapsed:l=!1,onToggleCollapse:i}=e;return 0===t.length?null:(0,r.jsxs)("div",{className:"px-2 py-2",children:[(0,r.jsxs)("button",{className:"w-full flex items-center justify-between px-2 py-2 mb-1.5 bg-transparent border-none cursor-pointer rounded-lg transition-all duration-200 hover:bg-gradient-to-r hover:from-[rgba(255,255,255,0.03)] hover:to-transparent",onClick:i,"aria-expanded":!l,"aria-label":l?"Expand threads":"Collapse threads",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(V,{isCollapsed:l}),(0,r.jsx)("span",{className:"text-xs font-semibold uppercase tracking-wider text-text-muted",children:"Threads"}),(0,r.jsxs)("span",{className:"text-xs text-text-dim font-mono",children:["(",t.length,")"]})]}),a>0&&(0,r.jsx)("span",{className:"min-w-[18px] h-[18px] flex items-center justify-center text-[10px] font-bold bg-accent-cyan text-bg-deep rounded-full px-1.5",style:{boxShadow:"0 0 8px rgba(0, 217, 255, 0.5)"},children:a>99?"99+":a})]}),!l&&(0,r.jsx)("div",{className:"space-y-1",children:t.map(e=>(0,r.jsx)(z,{thread:e,isSelected:n===e.id,onClick:()=>s(e.id)},e.id))})]})}function z(e){let{thread:t,isSelected:n,onClick:s}=e,a=t.unreadCount>0,l=function(e){let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4),s=Math.floor(n/36e5),a=Math.floor(n/864e5);return r<1?"now":r<60?"".concat(r,"m"):s<24?"".concat(s,"h"):a<7?"".concat(a,"d"):t.toLocaleDateString([],{month:"short",day:"numeric"})}(t.lastMessage.timestamp);return(0,r.jsxs)("button",{className:"\n group w-full flex items-center gap-3 px-2.5 py-2.5 rounded-lg text-left transition-all duration-200 cursor-pointer border-none\n hover:bg-gradient-to-r hover:from-[rgba(255,255,255,0.03)] hover:to-transparent\n ".concat(n?"bg-gradient-to-r from-[rgba(255,255,255,0.06)] to-transparent":"bg-transparent","\n "),onClick:s,style:{borderLeft:n?"2px solid #00d9ff":"2px solid transparent",boxShadow:n?"inset 4px 0 12px -4px rgba(0, 217, 255, 0.25)":"none"},children:[(0,r.jsxs)("div",{className:"\n relative shrink-0 w-8 h-8 rounded-lg flex items-center justify-center overflow-hidden transition-all duration-200\n ".concat(a?"text-accent-cyan":"text-text-muted","\n "),style:{background:a?"linear-gradient(135deg, rgba(0, 217, 255, 0.2), rgba(0, 217, 255, 0.1))":"rgba(255, 255, 255, 0.03)",boxShadow:a?"0 0 8px rgba(0, 217, 255, 0.2)":"none"},children:[(0,r.jsx)("div",{className:"absolute inset-0 opacity-20",style:{background:"linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%)"}}),(0,r.jsx)(G,{})]}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"\n text-[13px] truncate transition-colors duration-200\n ".concat(a?"font-semibold text-text-primary":"text-text-secondary group-hover:text-text-primary","\n "),children:t.name}),a&&(0,r.jsx)("span",{className:"shrink-0 min-w-[16px] h-[16px] flex items-center justify-center text-[9px] font-bold bg-accent-cyan text-bg-deep rounded-full px-1",style:{boxShadow:"0 0 6px rgba(0, 217, 255, 0.4)"},children:t.unreadCount>99?"99+":t.unreadCount})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-text-muted font-mono",children:[(0,r.jsx)("span",{className:"truncate",children:t.participants.slice(0,2).join(", ")}),t.participants.length>2&&(0,r.jsxs)("span",{className:"text-text-dim",children:["+",t.participants.length-2]}),(0,r.jsx)("span",{className:"text-text-dim opacity-50",children:"\xb7"}),(0,r.jsx)("span",{className:"text-text-dim",children:l})]})]})]})}function G(){return(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function V(e){let{isCollapsed:t}=e;return(0,r.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-text-muted transition-transform duration-200 ".concat(t?"":"rotate-90"),children:(0,r.jsx)("polyline",{points:"9 18 15 12 9 6"})})}var Z=n(5634);let K="agent-relay-threads-collapsed",q="agent-relay-sidebar-tab",J="agent-relay-channels-collapsed";function $(e){let{agents:t,bridgeAgents:n=[],projects:a=[],currentUserName:l,humanUnreadCounts:i={},currentProject:c,selectedAgent:d,viewMode:u,isFleetAvailable:x,isConnected:m,isOpen:h=!1,activeThreads:p=[],currentThread:g,totalUnreadThreadCount:f=0,isActivitySelected:b=!1,activityUnreadCount:v=0,onActivitySelect:y,channels:j=[],archivedChannels:w=[],selectedChannelId:N,onChannelSelect:k,onArchiveChannel:S,onUnarchiveChannel:M,onCreateChannel:L,onInviteToChannel:D,onAgentSelect:A,onHumanSelect:E,onProjectSelect:T,onViewModeChange:P,onSpawnClick:I,onReleaseClick:B,onLogsClick:_,onProfileClick:R,onThreadSelect:F,onClose:U,onSettingsClick:O,onTrajectoryClick:z,hasActiveTrajectory:G,onFleetClick:V,isFleetViewActive:$}=e,[eg,ef]=(0,s.useState)(""),[eb,ev]=(0,s.useState)(()=>{try{let e=localStorage.getItem(q);return"team"===e?"team":"agents"}catch(e){return"agents"}}),[ey,ej]=(0,s.useState)(()=>{try{let e=localStorage.getItem(K);return"true"===e}catch(e){return!1}}),[ew,eN]=(0,s.useState)(()=>{try{let e=localStorage.getItem(J);return null===e||"true"===e}catch(e){return!0}});(0,s.useEffect)(()=>{try{localStorage.setItem(q,eb)}catch(e){}},[eb]),(0,s.useEffect)(()=>{try{localStorage.setItem(K,String(ey))}catch(e){}},[ey]),(0,s.useEffect)(()=>{try{localStorage.setItem(J,String(ew))}catch(e){}},[ew]);let ek=j.reduce((e,t)=>e+t.unreadCount,0),eC=j.length>0,eS=!!eC&&ew,eM=w.length>0,[eL,eD]=(0,s.useState)(!0),[eA,eE]=(0,s.useState)(null);(0,s.useEffect)(()=>{eE(null)},[N]);let eT=t.filter(e=>!e.isHuman&&"Dashboard"!==e.name),eW=t.filter(e=>e.isHuman&&"Dashboard"!==e.name&&(!l||e.name.toLowerCase()!==l.toLowerCase())),eP=eW.filter(e=>!eg||e.name.toLowerCase().includes(eg.toLowerCase())),{pinnedAgents:eI,togglePin:eB,isMaxPinned:e_}=function(){let[e,t]=(0,s.useState)(()=>(function(){try{if("undefined"==typeof localStorage)return[];let e=localStorage.getItem(o);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t.slice(0,5)}}catch(e){}return[]})());(0,s.useEffect)(()=>{!function(e){try{if("undefined"==typeof localStorage)return;localStorage.setItem(o,JSON.stringify(e))}catch(e){}}(e)},[e]);let n=(0,s.useCallback)(t=>e.includes(t),[e]),r=(0,s.useCallback)(n=>{let{newPinned:r,success:s}=e.includes(n)?{newPinned:e,success:!0}:e.length>=5?{newPinned:e,success:!1}:{newPinned:[...e,n],success:!0};return r!==e&&t(r),s},[e]),a=(0,s.useCallback)(e=>{t(t=>t.filter(t=>t!==e))},[]),l=(0,s.useCallback)(e=>{n(e)?a(e):r(e)},[n,r,a]),i=(0,s.useMemo)(()=>e.length>=5,[e]);return{pinnedAgents:e,isPinned:n,togglePin:l,pin:r,unpin:a,isMaxPinned:i,maxPinned:5}}(),eR=a.length>0;return(0,r.jsxs)("aside",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,r.jsx)("div",{className:"p-3 sm:p-4 border-b border-border-subtle",children:(0,r.jsxs)("div",{className:"flex items-center gap-2 sm:gap-3",children:[(0,r.jsx)(Z.K7,{size:24,withGlow:!0}),(0,r.jsx)("h1",{className:"text-base sm:text-lg font-display font-semibold m-0 text-text-primary",children:"Agent Relay"}),(0,r.jsx)(Y,{isConnected:m}),(0,r.jsx)("button",{className:"md:hidden ml-auto p-2 -mr-1 sm:-mr-2 bg-transparent border-none text-text-muted cursor-pointer rounded-lg transition-colors hover:bg-bg-hover hover:text-text-primary active:bg-bg-hover",onClick:U,"aria-label":"Close sidebar",children:(0,r.jsx)(eo,{})})]})}),eW.length>0&&(0,r.jsxs)("div",{className:"flex bg-bg-tertiary rounded-lg p-1 mx-3 mt-3",children:[(0,r.jsxs)("button",{className:"\n flex-1 py-2 px-4 bg-transparent border-none text-xs font-medium cursor-pointer rounded-md transition-all duration-150 flex items-center justify-center gap-1.5\n ".concat("agents"===eb?"bg-bg-elevated text-accent-cyan shadow-sm":"text-text-muted hover:text-text-secondary","\n "),onClick:()=>ev("agents"),children:[(0,r.jsx)(ed,{}),"Agents",eT.length>0&&(0,r.jsxs)("span",{className:"text-[10px] opacity-70",children:["(",eT.length,")"]})]}),(0,r.jsxs)("button",{className:"\n flex-1 py-2 px-4 bg-transparent border-none text-xs font-medium cursor-pointer rounded-md transition-all duration-150 flex items-center justify-center gap-1.5\n ".concat("team"===eb?"bg-bg-elevated text-accent-cyan shadow-sm":"text-text-muted hover:text-text-secondary","\n "),onClick:()=>ev("team"),children:[(0,r.jsx)(eu,{}),"Team",eW.length>0&&(0,r.jsxs)("span",{className:"text-[10px] opacity-70",children:["(",eW.length,")"]})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 py-2 sm:py-2.5 px-2 sm:px-3 bg-bg-tertiary m-2 sm:m-3 rounded-lg border border-border-subtle focus-within:border-accent-cyan/50 transition-colors",children:[(0,r.jsx)(X,{}),(0,r.jsx)("input",{type:"text",placeholder:"agents"===eb?"Search agents...":"Search team...",value:eg,onChange:e=>ef(e.target.value),className:"flex-1 bg-transparent border-none text-text-primary text-sm outline-none placeholder:text-text-muted"}),eg&&(0,r.jsx)("button",{className:"bg-transparent border-none text-text-muted cursor-pointer p-1 flex items-center justify-center hover:text-text-secondary rounded transition-colors active:text-text-secondary",onClick:()=>ef(""),children:(0,r.jsx)(Q,{})})]}),p.length>0&&(0,r.jsx)("div",{className:"border-b border-border-subtle",children:(0,r.jsx)(H,{threads:p,currentThread:g,onThreadSelect:e=>null==F?void 0:F(e),totalUnreadCount:f,isCollapsed:ey,onToggleCollapse:()=>ej(!ey)})}),(0,r.jsx)("div",{className:"border-b border-border-subtle px-2 py-2",children:(0,r.jsxs)("button",{onClick:y,className:"\n w-full flex items-center gap-2 px-2 py-2 rounded-lg text-left text-sm transition-colors\n ".concat(b?"bg-accent-cyan/10 text-text-primary border border-accent-cyan/30":"hover:bg-bg-hover text-text-secondary hover:text-text-primary border border-transparent","\n "),children:[(0,r.jsx)(ep,{}),(0,r.jsx)("span",{className:"flex-1 ".concat(v>0?"font-semibold text-text-primary":""),children:"Activity"}),v>0&&(0,r.jsx)("span",{className:"text-[11px] font-semibold px-1.5 py-0.5 rounded-full bg-accent-cyan/20 text-accent-cyan",children:v})]})}),(0,r.jsxs)("div",{className:"border-b border-border-subtle",children:[(0,r.jsxs)("button",{className:"w-full flex items-center justify-between px-3 py-2 text-xs font-semibold text-text-muted uppercase tracking-wide hover:bg-bg-hover transition-colors",onClick:()=>eN(!ew),children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)(ea,{}),"Channels",ek>0&&(0,r.jsx)("span",{className:"text-[10px] font-semibold px-1.5 py-0.5 rounded-full bg-accent-cyan/20 text-accent-cyan",children:ek})]}),(0,r.jsx)(el,{className:"transition-transform ".concat(eS?"":"rotate-180")})]}),!eS&&(0,r.jsxs)("div",{className:"px-2 pb-2 space-y-0.5 max-h-40 md:max-h-none overflow-y-auto",children:[j.map(e=>(0,r.jsxs)("div",{className:"group relative",children:[(0,r.jsxs)("button",{onClick:()=>null==k?void 0:k(e),className:"\n w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-left text-sm transition-colors\n ".concat(N===e.id?"bg-accent-cyan/10 text-text-primary":"hover:bg-bg-hover text-text-secondary hover:text-text-primary","\n "),children:[(0,r.jsx)("span",{className:"text-text-muted",children:"#"}),(0,r.jsx)("span",{className:"flex-1 truncate ".concat(e.unreadCount>0?"font-semibold text-text-primary":""),children:e.name}),e.unreadCount>0&&(0,r.jsx)("span",{className:"\n text-[11px] font-semibold px-1.5 py-0.5 rounded-full min-w-[18px] text-center\n ".concat(e.hasMentions?"bg-red-500/20 text-red-400":"bg-accent-cyan/20 text-accent-cyan","\n "),children:e.unreadCount})]}),(D||S)&&(0,r.jsx)("button",{onClick:t=>{t.stopPropagation(),eE(eA===e.id?null:e.id)},title:"Channel actions",className:"absolute right-1 top-1/2 -translate-y-1/2 p-1 rounded opacity-0 group-hover:opacity-100 hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-all",children:(0,r.jsx)(ei,{})}),eA===e.id&&(0,r.jsxs)("div",{className:"absolute right-0 top-full mt-1 z-30 bg-bg-elevated border border-border-subtle rounded-lg shadow-lg py-1 min-w-[160px]",children:[D&&(0,r.jsxs)(ee,{onClick:()=>{D(e),eE(null)},children:[(0,r.jsx)(en,{}),(0,r.jsx)("span",{children:"Invite members"})]}),S&&(0,r.jsxs)(ee,{onClick:()=>{S(e),eE(null)},children:[(0,r.jsx)(er,{}),(0,r.jsx)("span",{children:"Archive"})]})]})]},e.id)),L&&(0,r.jsxs)("button",{onClick:L,className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-left text-sm text-text-muted hover:bg-bg-hover hover:text-text-secondary transition-colors",children:[(0,r.jsx)(et,{}),(0,r.jsx)("span",{children:eC?"Add channel":"Create your first channel"})]})]}),eM&&(0,r.jsxs)("div",{className:"mt-1 border-t border-border-subtle",children:[(0,r.jsxs)("button",{className:"w-full flex items-center justify-between px-3 py-2 text-xs font-semibold text-text-muted uppercase tracking-wide hover:bg-bg-hover transition-colors",onClick:()=>eD(!eL),children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)(er,{}),"Archived",(0,r.jsxs)("span",{className:"text-[10px] opacity-80",children:["(",w.length,")"]})]}),(0,r.jsx)(el,{className:"transition-transform ".concat(eL?"":"rotate-180")})]}),!eL&&(0,r.jsx)("div",{className:"px-2 pb-2 space-y-0.5 max-h-32 md:max-h-none overflow-y-auto",children:w.map(e=>(0,r.jsxs)("div",{className:"group relative",children:[(0,r.jsxs)("button",{onClick:()=>null==k?void 0:k(e),className:"\n w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-left text-sm transition-colors\n ".concat(N===e.id?"bg-bg-tertiary text-text-primary":"hover:bg-bg-hover text-text-secondary hover:text-text-primary","\n "),children:[(0,r.jsx)("span",{className:"text-text-muted",children:"#"}),(0,r.jsx)("span",{className:"flex-1 truncate",children:e.name}),(0,r.jsx)("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full bg-border-subtle text-text-muted",children:"Archived"})]}),M&&(0,r.jsxs)("button",{onClick:t=>{t.stopPropagation(),M(e)},title:"Unarchive channel",className:"absolute right-1 top-1/2 -translate-y-1/2 px-2 py-1 rounded-md bg-bg-tertiary text-text-secondary hover:text-text-primary hover:bg-bg-hover transition-colors text-xs flex items-center gap-1",children:[(0,r.jsx)(es,{}),(0,r.jsx)("span",{children:"Unarchive"})]})]},e.id))})]})]}),(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto px-2",children:["team"===eb&&eW.length>0?(0,r.jsxs)("div",{className:"flex flex-col gap-1 py-2",children:[eP.map(e=>(0,r.jsxs)("button",{onClick:()=>E?E(e):null==A?void 0:A(e),className:"\n flex items-center gap-3 p-3 rounded-lg border transition-all duration-150 text-left w-full\n ".concat(d===e.name?"bg-accent-cyan/10 border-accent-cyan/30":"bg-bg-tertiary border-border-subtle hover:border-accent-cyan/30 hover:bg-bg-hover","\n "),children:[e.avatarUrl?(0,r.jsx)("img",{src:e.avatarUrl,alt:e.name,className:"w-9 h-9 rounded-full object-cover"}):(0,r.jsx)("div",{className:"w-9 h-9 rounded-full bg-gradient-to-br from-purple-500 to-pink-500 flex items-center justify-center text-white font-medium text-sm",children:e.name.charAt(0).toUpperCase()}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-text-primary truncate",children:e.name}),(0,r.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.role||"Team Member"})]}),i[e.name]>0&&(0,r.jsx)("span",{className:"text-[11px] font-semibold px-2 py-0.5 rounded-full bg-accent-cyan/20 text-accent-cyan",children:i[e.name]}),(0,r.jsx)("div",{className:"w-2 h-2 rounded-full ".concat("online"===e.status?"bg-success":"bg-text-dim")})]},e.name)),0===eP.length&&(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-10 px-5 text-text-muted text-center",children:[(0,r.jsx)(X,{}),(0,r.jsxs)("p",{className:"mt-3",children:['No team members match "',eg,'"']})]})]}):eR?(0,r.jsx)(W,{projects:a,localAgents:eT,bridgeAgents:n,currentProject:c,selectedAgent:d,searchQuery:eg,pinnedAgents:eI,isMaxPinned:e_,onProjectSelect:T,onAgentSelect:A,onReleaseClick:B,onLogsClick:_,onProfileClick:R,onPinToggle:e=>eB(e.name),compact:!0}):(0,r.jsx)(C,{agents:eT,selectedAgent:d,searchQuery:eg,pinnedAgents:eI,isMaxPinned:e_,onAgentSelect:e=>null==A?void 0:A(e),onReleaseClick:B,onLogsClick:_,onProfileClick:R,onPinToggle:e=>eB(e.name),compact:!0,showGroupStats:!0}),"agents"===eb&&eW.length>0&&(0,r.jsxs)("div",{className:"mt-4 mb-2 pt-3 border-t border-border-subtle",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-1 pb-2",children:[(0,r.jsx)("p",{className:"text-xs uppercase tracking-wide text-text-muted font-semibold m-0",children:"Direct messages"}),(0,r.jsxs)("span",{className:"text-[11px] text-text-muted",children:[eP.length," member",1===eP.length?"":"s"]})]}),(0,r.jsx)("div",{className:"flex flex-col gap-1",children:eP.length>0?eP.map(e=>(0,r.jsxs)("button",{onClick:()=>E?E(e):null==A?void 0:A(e),className:"\n flex items-center gap-3 p-2.5 rounded-lg border transition-all duration-150 text-left w-full\n ".concat(d===e.name?"bg-accent-cyan/10 border-accent-cyan/30":"bg-bg-tertiary border-border-subtle hover:border-accent-cyan/30 hover:bg-bg-hover","\n "),children:[e.avatarUrl?(0,r.jsx)("img",{src:e.avatarUrl,alt:e.name,className:"w-8 h-8 rounded-full object-cover"}):(0,r.jsx)("div",{className:"w-8 h-8 rounded-full bg-gradient-to-br from-purple-500 to-pink-500 flex items-center justify-center text-white font-medium text-xs",children:e.name.charAt(0).toUpperCase()}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-text-primary truncate",children:e.name}),(0,r.jsx)("p",{className:"text-[11px] text-text-muted truncate",children:e.role||"Team Member"})]}),i[e.name]>0&&(0,r.jsx)("span",{className:"text-[11px] font-semibold px-2 py-0.5 rounded-full bg-accent-cyan/20 text-accent-cyan",children:i[e.name]}),(0,r.jsx)("div",{className:"w-2 h-2 rounded-full ".concat("online"===e.status?"bg-success":"bg-text-dim")})]},e.name)):(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-6 px-3 text-text-muted text-center",children:[(0,r.jsx)(X,{}),(0,r.jsxs)("p",{className:"mt-2 text-xs",children:['No team members match "',eg,'"']})]})})]})]}),(0,r.jsxs)("div",{className:"md:hidden border-t border-border-subtle p-3",children:[(0,r.jsx)("p",{className:"text-xs text-text-muted font-medium mb-2 px-1",children:"Quick Actions"}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[V&&(0,r.jsxs)("button",{className:"flex items-center gap-2 p-2.5 rounded-lg border text-sm transition-all duration-150 ".concat($?"bg-accent-cyan/20 border-accent-cyan text-accent-cyan":"bg-bg-tertiary border-border-subtle text-text-secondary hover:bg-bg-hover hover:text-text-primary"),onClick:()=>{V(),null==U||U()},children:[(0,r.jsx)(ex,{}),(0,r.jsx)("span",{children:"Fleet"})]}),z&&(0,r.jsxs)("button",{className:"flex items-center gap-2 p-2.5 rounded-lg border text-sm transition-all duration-150 relative ".concat(G?"bg-accent-cyan/20 border-accent-cyan text-accent-cyan":"bg-bg-tertiary border-border-subtle text-text-secondary hover:bg-bg-hover hover:text-text-primary"),onClick:()=>{z(),null==U||U()},children:[(0,r.jsx)(em,{}),(0,r.jsx)("span",{children:"Trajectory"}),G&&(0,r.jsx)("span",{className:"absolute top-1 right-1 w-2 h-2 bg-accent-cyan rounded-full animate-pulse"})]}),(0,r.jsxs)("a",{href:"/metrics",className:"flex items-center gap-2 p-2.5 bg-bg-tertiary border border-border-subtle rounded-lg text-text-secondary text-sm transition-all duration-150 hover:bg-bg-hover hover:text-accent-orange no-underline",onClick:()=>null==U?void 0:U(),children:[(0,r.jsx)(eh,{}),(0,r.jsx)("span",{children:"Metrics"})]})]})]}),(0,r.jsxs)("div",{className:"p-3 sm:p-4 border-t border-border-subtle space-y-2",children:[(0,r.jsxs)("button",{className:"w-full py-2.5 sm:py-3 px-3 sm:px-4 bg-gradient-to-r from-accent-cyan to-[#00b8d9] text-bg-deep font-semibold text-sm cursor-pointer flex items-center justify-center gap-2 rounded-lg transition-all duration-150 hover:shadow-glow-cyan hover:-translate-y-0.5 active:scale-[0.98]",onClick:I,children:[(0,r.jsx)(et,{}),"Spawn Agent"]}),(0,r.jsxs)("button",{className:"w-full py-2 sm:py-2.5 px-3 sm:px-4 bg-bg-tertiary text-text-secondary text-sm cursor-pointer flex items-center justify-center gap-2 rounded-lg border border-border-subtle transition-all duration-150 hover:bg-bg-hover hover:text-text-primary hover:border-border-subtle active:bg-bg-hover",onClick:O,children:[(0,r.jsx)(ec,{}),"Settings"]})]})]})}function Y(e){let{isConnected:t}=e;return(0,r.jsxs)("div",{className:"flex items-center gap-1.5 ml-auto",children:[(0,r.jsx)("div",{className:"w-2 h-2 rounded-full ".concat(t?"bg-success animate-pulse-glow":"bg-text-dim")}),(0,r.jsx)("span",{className:"text-xs text-text-muted",children:t?"Live":"Offline"})]})}function X(){return(0,r.jsxs)("svg",{className:"text-text-muted",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,r.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function Q(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,r.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function ee(e){let{onClick:t,children:n}=e;return(0,r.jsx)("button",{onClick:t,className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-text-secondary hover:bg-bg-hover hover:text-text-primary transition-colors",children:n})}function et(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,r.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,r.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function en(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),(0,r.jsx)("circle",{cx:"8.5",cy:"7",r:"4"}),(0,r.jsx)("line",{x1:"20",y1:"8",x2:"20",y2:"14"}),(0,r.jsx)("line",{x1:"23",y1:"11",x2:"17",y2:"11"})]})}function er(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M3 7h18"}),(0,r.jsx)("path",{d:"M5 7v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7"}),(0,r.jsx)("rect",{x:"3",y:"3",width:"18",height:"4",rx:"1"}),(0,r.jsx)("line",{x1:"10",y1:"12",x2:"14",y2:"12"})]})}function es(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M3 7h18"}),(0,r.jsx)("path",{d:"M5 7v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7"}),(0,r.jsx)("rect",{x:"3",y:"3",width:"18",height:"4",rx:"1"}),(0,r.jsx)("path",{d:"M12 11v6"}),(0,r.jsx)("path",{d:"M9 14l3-3 3 3"})]})}function ea(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("line",{x1:"4",y1:"9",x2:"20",y2:"9"}),(0,r.jsx)("line",{x1:"4",y1:"15",x2:"20",y2:"15"}),(0,r.jsx)("line",{x1:"10",y1:"3",x2:"8",y2:"21"}),(0,r.jsx)("line",{x1:"16",y1:"3",x2:"14",y2:"21"})]})}function el(e){let{className:t}=e;return(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:(0,r.jsx)("polyline",{points:"6 9 12 15 18 9"})})}function ei(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("circle",{cx:"5",cy:"12",r:"1"}),(0,r.jsx)("circle",{cx:"12",cy:"12",r:"1"}),(0,r.jsx)("circle",{cx:"19",cy:"12",r:"1"})]})}function eo(){return(0,r.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,r.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function ec(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,r.jsx)("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}function ed(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("rect",{x:"3",y:"11",width:"18",height:"10",rx:"2"}),(0,r.jsx)("circle",{cx:"12",cy:"5",r:"2"}),(0,r.jsx)("path",{d:"M12 7v4"}),(0,r.jsx)("line",{x1:"8",y1:"16",x2:"8",y2:"16"}),(0,r.jsx)("line",{x1:"16",y1:"16",x2:"16",y2:"16"})]})}function eu(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),(0,r.jsx)("circle",{cx:"9",cy:"7",r:"4"}),(0,r.jsx)("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),(0,r.jsx)("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}function ex(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2"}),(0,r.jsx)("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),(0,r.jsx)("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]})}function em(){return(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M3 12h4l3 9 4-18 3 9h4"})})}function eh(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M3 3v18h18"}),(0,r.jsx)("path",{d:"M18 17V9"}),(0,r.jsx)("path",{d:"M13 17V5"}),(0,r.jsx)("path",{d:"M8 17v-3"})]})}function ep(){return(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M22 12h-4l-3 9L9 3l-3 9H2"})})}function eg(e){let{projects:t,recentProjects:n=[],currentProject:a,onProjectChange:l}=e,[i,o]=(0,s.useState)(!1),[c,d]=(0,s.useState)(-1),u=(0,s.useRef)(null),x=(0,s.useRef)([]),m=t.length>1,h=new Set(n.map(e=>e.id)),p=t.filter(e=>!h.has(e.id)),g=[...n,...p],f=e=>{if(!e)return"No project";if(e.name)return e.name;let t=e.path.split("/").filter(Boolean);return t.length>=2?"".concat(t[t.length-2],"/").concat(t[t.length-1]):t[t.length-1]||e.id};return((0,s.useEffect)(()=>{let e=e=>{u.current&&!u.current.contains(e.target)&&o(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,s.useEffect)(()=>{let e=e=>{if(i)switch(e.key){case"Escape":o(!1),d(-1);break;case"ArrowDown":e.preventDefault(),d(e=>{var t;let n=e<g.length-1?e+1:0;return null===(t=x.current[n])||void 0===t||t.focus(),n});break;case"ArrowUp":e.preventDefault(),d(e=>{var t;let n=e>0?e-1:g.length-1;return null===(t=x.current[n])||void 0===t||t.focus(),n});break;case"Enter":c>=0&&c<g.length&&(l(g[c]),o(!1),d(-1))}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[i,c,g,l]),(0,s.useEffect)(()=>{if(i){let e=g.findIndex(e=>e.id===(null==a?void 0:a.id));d(e>=0?e:0)}else d(-1)},[i,g,a]),0===t.length)?null:(0,r.jsxs)("div",{className:"relative",ref:u,children:[(0,r.jsxs)("button",{className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm font-medium transition-all duration-150 border ".concat(m?"bg-bg-tertiary/80 border-border-subtle hover:bg-bg-elevated hover:border-border-medium cursor-pointer":"bg-transparent border-transparent cursor-default"),onClick:()=>m&&o(!i),disabled:!m,"aria-expanded":i,"aria-haspopup":"listbox",children:[(0,r.jsx)(ev,{}),(0,r.jsx)("span",{className:"text-text-primary truncate max-w-[200px]",children:f(a)}),m&&(0,r.jsx)(ey,{isOpen:i})]}),i&&m&&(0,r.jsxs)("div",{className:"absolute top-[calc(100%+4px)] left-0 min-w-[280px] bg-bg-primary border border-border-subtle rounded-xl shadow-[0_10px_40px_rgba(0,0,0,0.4)] z-[1000] overflow-hidden",children:[(0,r.jsx)("div",{className:"px-3 py-2 border-b border-border-subtle",children:(0,r.jsx)("span",{className:"text-xs font-medium text-text-muted uppercase tracking-wider",children:"Switch Project"})}),(0,r.jsxs)("div",{className:"max-h-[300px] overflow-y-auto",role:"listbox",children:[n.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"px-3 py-1.5 bg-bg-tertiary/50",children:(0,r.jsxs)("span",{className:"text-[10px] font-medium text-text-muted uppercase tracking-wider flex items-center gap-1.5",children:[(0,r.jsx)(eb,{}),"Recent"]})}),(0,r.jsx)("div",{className:"py-1",children:n.map((e,t)=>(0,r.jsx)(ef,{project:e,index:t,isActive:(null==a?void 0:a.id)===e.id,isFocused:c===t,formatProjectName:f,buttonRefs:x,onSelect:()=>{l(e),o(!1)}},e.id))})]}),p.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"px-3 py-1.5 bg-bg-tertiary/50",children:(0,r.jsx)("span",{className:"text-[10px] font-medium text-text-muted uppercase tracking-wider",children:n.length>0?"All Projects":"Projects"})}),(0,r.jsx)("div",{className:"py-1",children:p.map((e,t)=>{let s=n.length+t;return(0,r.jsx)(ef,{project:e,index:s,isActive:(null==a?void 0:a.id)===e.id,isFocused:c===s,formatProjectName:f,buttonRefs:x,onSelect:()=>{l(e),o(!1)}},e.id)})})]})]})]})]})}function ef(e){var t,n;let{project:s,index:a,isActive:l,isFocused:i,formatProjectName:o,buttonRefs:c,onSelect:d}=e,u=o(s),x=(null===(t=s.agents)||void 0===t?void 0:t.length)||0;return(0,r.jsxs)("button",{ref:e=>{c.current[a]=e},className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-colors border-none cursor-pointer ".concat(l?"bg-accent-cyan/10 text-accent-cyan":i?"bg-bg-hover text-text-primary":"bg-transparent text-text-primary hover:bg-bg-hover"),onClick:d,role:"option","aria-selected":l,tabIndex:i?0:-1,children:[(0,r.jsx)(ev,{className:l?"text-accent-cyan":"text-text-muted"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("div",{className:"font-medium text-sm truncate",children:u}),(0,r.jsx)("div",{className:"text-xs text-text-muted truncate",children:s.path})]}),(0,r.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded-full ".concat(l?"bg-accent-cyan/20 text-accent-cyan":"bg-bg-tertiary text-text-muted"),children:[x," ",1===x?"agent":"agents"]}),(null===(n=s.lead)||void 0===n?void 0:n.connected)&&(0,r.jsx)("span",{className:"w-2 h-2 rounded-full bg-success animate-pulse",title:"Lead: ".concat(s.lead.name)}),l&&(0,r.jsx)(ej,{})]})}function eb(){return(0,r.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("polyline",{points:"12 6 12 12 16 14"})]})}function ev(e){let{className:t="text-text-muted"}=e;return(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:(0,r.jsx)("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function ey(e){let{isOpen:t}=e;return(0,r.jsx)("svg",{className:"text-text-muted transition-transform duration-150 ".concat(t?"rotate-180":""),width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:(0,r.jsx)("polyline",{points:"6 9 12 15 18 9"})})}function ej(){return(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-accent-cyan",children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})})}function ew(e){let{currentChannel:t,selectedAgent:n,projects:s=[],currentProject:a,recentProjects:l=[],viewMode:i,selectedChannelName:o,onProjectChange:d,onCommandPaletteOpen:u,onSettingsClick:m,onHistoryClick:h,onNewConversationClick:p,onFleetClick:g,isFleetViewActive:f,onTrajectoryClick:b,hasActiveTrajectory:v,onMenuClick:y,hasUnreadNotifications:j}=e,w=n?(0,c.GW)(n.name):null;return(0,r.jsxs)("header",{className:"h-[52px] bg-bg-secondary border-b border-border-subtle flex items-center justify-between px-2 sm:px-4",children:[(0,r.jsxs)("button",{className:"flex md:hidden items-center justify-center w-10 h-10 sm:w-11 sm:h-11 bg-transparent border-none text-text-primary cursor-pointer rounded-lg transition-colors hover:bg-bg-hover active:bg-bg-hover relative flex-shrink-0",onClick:y,"aria-label":"Open menu",children:[(0,r.jsx)(eA,{}),j&&(0,r.jsx)("span",{className:"absolute top-1 right-1 sm:top-1.5 sm:right-1.5 w-2.5 h-2.5 bg-error rounded-full animate-pulse shadow-[0_0_8px_rgba(239,68,68,0.6)]"})]}),s.length>0&&d&&(0,r.jsx)("div",{className:"max-md:hidden mr-3",children:(0,r.jsx)(eg,{projects:s,recentProjects:l,currentProject:null!=a?a:null,onProjectChange:d})}),s.length>0&&d&&(0,r.jsx)("div",{className:"w-px h-6 bg-border-subtle mr-3 max-md:hidden"}),(0,r.jsx)("div",{className:"flex items-center gap-2 sm:gap-3 flex-1 min-w-0",children:n&&!n.isHuman&&"dashboard"!==n.cli?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"w-7 h-7 sm:w-8 sm:h-8 rounded-lg flex items-center justify-center font-semibold text-[10px] sm:text-xs border-2 flex-shrink-0",style:{backgroundColor:null==w?void 0:w.primary,borderColor:null==w?void 0:w.primary,boxShadow:"0 0 12px ".concat(null==w?void 0:w.primary,"40")},children:(0,r.jsx)("span",{style:{color:null==w?void 0:w.text},children:(0,c.hP)(n.name)})}),(0,r.jsxs)("div",{className:"flex flex-col min-w-0",children:[(0,r.jsx)("span",{className:"font-display font-semibold text-sm sm:text-base text-text-primary truncate",children:n.name}),(0,r.jsx)("span",{className:"text-text-muted text-xs font-mono hidden md:block truncate",children:x(n.name)})]}),n.status&&(0,r.jsx)("span",{className:"hidden sm:inline text-xs py-1 px-2.5 rounded-full font-medium ml-2 flex-shrink-0 truncate max-w-[80px] ".concat("online"===n.status?"bg-success/20 text-success":"bg-bg-tertiary text-text-muted"),title:n.status,children:n.status})]}):n&&(n.isHuman||"dashboard"===n.cli)?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-accent-cyan text-base sm:text-lg font-mono",children:"@"}),(0,r.jsx)("span",{className:"font-display font-semibold text-sm sm:text-base text-text-primary truncate",children:t})]})}),(0,r.jsxs)("div",{className:"flex items-center gap-1 sm:gap-2",children:[(0,r.jsxs)("button",{className:"flex items-center gap-1 sm:gap-2 py-1.5 sm:py-2 px-2 sm:px-4 bg-gradient-to-r from-accent-cyan to-[#00b8d9] text-bg-deep font-semibold border-none rounded-lg text-xs sm:text-sm cursor-pointer transition-all duration-150 hover:shadow-glow-cyan hover:-translate-y-0.5",onClick:p,title:"Start new conversation (⌘N)",children:[(0,r.jsx)(eN,{}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"New"}),(0,r.jsx)("span",{className:"hidden md:inline",children:"Message"})]}),(0,r.jsxs)("button",{className:"flex items-center gap-1 sm:gap-2 py-1.5 sm:py-2 px-2 sm:px-3 bg-bg-tertiary border border-border-subtle rounded-lg text-text-secondary text-xs sm:text-sm cursor-pointer transition-all duration-150 hover:bg-bg-elevated hover:border-border-medium hover:text-text-primary",onClick:u,title:"Command Palette (⌘K)",children:[(0,r.jsx)(ek,{}),(0,r.jsx)("span",{className:"hidden md:inline",children:"Search"}),(0,r.jsx)("kbd",{className:"hidden md:inline bg-bg-card border border-border-subtle rounded px-1.5 py-0.5 text-xs text-text-muted font-mono",children:"⌘K"})]}),(0,r.jsx)("button",{className:"hidden sm:flex items-center justify-center p-1.5 sm:p-2 bg-bg-tertiary border border-border-subtle rounded-lg text-text-secondary cursor-pointer transition-all duration-150 hover:bg-bg-elevated hover:border-border-medium hover:text-accent-cyan",onClick:h,title:"Message History",children:(0,r.jsx)(eC,{})}),g&&(0,r.jsx)("button",{className:"hidden sm:flex items-center justify-center p-1.5 sm:p-2 border rounded-lg cursor-pointer transition-all duration-150 ".concat(f?"bg-accent-cyan/20 border-accent-cyan text-accent-cyan":"bg-bg-tertiary border-border-subtle text-text-secondary hover:bg-bg-elevated hover:border-border-medium hover:text-accent-cyan"),onClick:g,title:f?"Back to Chat":"Fleet Overview",children:(0,r.jsx)(eM,{})}),b&&(0,r.jsxs)("button",{className:"hidden md:flex items-center justify-center p-2 border rounded-lg cursor-pointer transition-all duration-150 relative ".concat(v?"bg-accent-cyan/20 border-accent-cyan text-accent-cyan":"bg-bg-tertiary border-border-subtle text-text-secondary hover:bg-bg-elevated hover:border-border-medium hover:text-accent-cyan"),onClick:b,title:"Trajectory Viewer",children:[(0,r.jsx)(eL,{}),v&&(0,r.jsx)("span",{className:"absolute -top-1 -right-1 w-2 h-2 bg-accent-cyan rounded-full animate-pulse"})]}),(0,r.jsx)("a",{href:"/metrics",className:"hidden sm:flex items-center justify-center p-1.5 sm:p-2 bg-bg-tertiary border border-border-subtle rounded-lg text-text-secondary cursor-pointer transition-all duration-150 hover:bg-bg-elevated hover:border-border-medium hover:text-accent-orange no-underline",title:"Fleet Metrics",children:(0,r.jsx)(eS,{})}),m&&(0,r.jsx)("button",{className:"flex items-center justify-center p-1.5 sm:p-2 bg-bg-tertiary border border-border-subtle rounded-lg text-text-secondary cursor-pointer transition-all duration-150 hover:bg-bg-elevated hover:border-border-medium hover:text-accent-purple",onClick:m,title:"Settings",children:(0,r.jsx)(eD,{})})]})]})}function eN(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,r.jsx)("path",{d:"M12 20h9"}),(0,r.jsx)("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"})]})}function ek(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,r.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function eC(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("polyline",{points:"12 6 12 12 16 14"})]})}function eS(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M3 3v18h18"}),(0,r.jsx)("path",{d:"M18 17V9"}),(0,r.jsx)("path",{d:"M13 17V5"}),(0,r.jsx)("path",{d:"M8 17v-3"})]})}function eM(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2"}),(0,r.jsx)("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),(0,r.jsx)("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]})}function eL(){return(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M3 12h4l3 9 4-18 3 9h4"})})}function eD(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,r.jsx)("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}function eA(){return(0,r.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),(0,r.jsx)("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),(0,r.jsx)("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]})}function eE(e){let{status:t,size:n="small"}=e;if(!t)return null;let s={small:"w-3.5 h-3.5",medium:"w-4 h-4"}[n];return"sending"===t||"unread"===t?(0,r.jsx)("span",{className:"inline-flex items-center justify-center ".concat(s," text-text-muted"),title:"Sending...",children:(0,r.jsx)(eT,{className:s})}):"acked"===t||"read"===t?(0,r.jsx)("span",{className:"inline-flex items-center justify-center ".concat(s," text-success"),title:"Delivered",children:(0,r.jsx)(eW,{className:s})}):"failed"===t?(0,r.jsx)("span",{className:"inline-flex items-center justify-center ".concat(s," text-error"),title:"Delivery failed",children:(0,r.jsx)(eP,{className:s})}):null}function eT(e){let{className:t}=e;return(0,r.jsxs)("svg",{className:"animate-pulse ".concat(t),viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6"}),(0,r.jsx)("path",{d:"M8 5v3l2 1",strokeLinecap:"round",strokeLinejoin:"round"})]})}function eW(e){let{className:t}=e;return(0,r.jsx)("svg",{className:t,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("path",{d:"M3 8l3 3 7-7",strokeLinecap:"round",strokeLinejoin:"round"})})}function eP(e){let{className:t}=e;return(0,r.jsxs)("svg",{className:t,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6"}),(0,r.jsx)("line",{x1:"8",y1:"5",x2:"8",y2:"8",strokeLinecap:"round"}),(0,r.jsx)("circle",{cx:"8",cy:"11",r:"0.5",fill:"currentColor",stroke:"none"})]})}function eI(e){let{displayName:t,color:n,isCurrentUser:a=!1,agent:l,userPresence:i,onAgentClick:o,onUserClick:c,className:d=""}=e,u=(0,s.useCallback)(()=>{l&&o?o(l):i&&c&&c(i)},[l,i,o,c]);return l&&o||i&&c?(0,r.jsx)("button",{type:"button",onClick:u,className:"\n font-display font-semibold text-sm\n bg-transparent border-none p-0 m-0\n cursor-pointer\n transition-all duration-150\n hover:underline hover:decoration-current hover:decoration-1 hover:underline-offset-2\n focus:outline-none focus:ring-2 focus:ring-offset-1 focus:ring-accent-cyan/50 focus:rounded-sm\n ".concat(d,"\n "),style:{color:n},title:"View ".concat(l?"agent":"user"," profile: ").concat(t),children:t}):(0,r.jsx)("span",{className:"font-display font-semibold text-sm ".concat(d),style:{color:n},children:t})}var eB=n(1832),e_=n(8065);let eR=0;function eF(){return"log-".concat(Date.now(),"-").concat(++eR)}function eU(e){let{agentName:t,maxLines:n=5e3,autoConnect:r=!0,reconnect:a=!0,maxReconnectAttempts:l=1/0}=e,i=(0,e_._c)("/ws/logs/".concat(encodeURIComponent(t))),[o,c]=(0,s.useState)([]),[d,u]=(0,s.useState)(!1),[x,m]=(0,s.useState)(!1),[h,p]=(0,s.useState)("disconnected"),[g,f]=(0,s.useState)(null),b=(0,s.useRef)(null),v=(0,s.useRef)(0),y=(0,s.useRef)(null),j=(0,s.useRef)(t),w=(0,s.useRef)(!0),N=(0,s.useRef)(!1),k=(0,s.useRef)(new WeakMap),C=(0,s.useRef)(new WeakMap),S=(0,s.useRef)(null),M=(0,s.useRef)(!1),L=(0,s.useRef)(new Set);j.current=t;let D=(0,s.useCallback)((e,t)=>"".concat(t,":").concat(e.slice(0,100)),[]),A=(0,s.useCallback)(()=>{var e,t;if(w.current=!0,(null===(e=b.current)||void 0===e?void 0:e.readyState)!==WebSocket.OPEN&&(null===(t=b.current)||void 0===t?void 0:t.readyState)!==WebSocket.CONNECTING&&!N.current){M.current&&p("reconnecting"),N.current=!0,m(!0),f(null);try{let e=new WebSocket(i);b.current=e,k.current.set(e,!1),C.current.set(e,!1),e.onopen=()=>{N.current=!1,u(!0),m(!1),p("connected"),f(null),v.current=0,M.current&&null!==S.current&&(console.log("[WS:Logs] Requesting replay from timestamp ".concat(S.current)),e.send(JSON.stringify({type:"replay",agent:j.current,lastTimestamp:S.current}))),M.current=!0,c(e=>[...e,{id:eF(),timestamp:Date.now(),content:"Connected to ".concat(j.current," log stream"),type:"system",agentName:j.current}])},e.onclose=t=>{var n,r;let s=null!==(n=k.current.get(e))&&void 0!==n&&n,i=null!==(r=C.current.get(e))&&void 0!==r&&r;if(N.current=!1,u(!1),m(!1),b.current=null,y.current&&(clearTimeout(y.current),y.current=null),s||4404===t.code){p("disconnected");return}if(!t.wasClean&&i){let e=w.current&&a&&v.current<l;c(n=>[...n,{id:eF(),timestamp:Date.now(),content:e?"Lost connection to log stream (code: ".concat(t.code,"). Reconnecting..."):"Disconnected from log stream (code: ".concat(t.code,")"),type:"system",agentName:j.current}])}if(w.current&&a&&v.current<l){p("reconnecting");let e=Math.min(500*Math.pow(2,v.current),15e3);v.current++,console.log("[WS:Logs] Reconnecting (attempt ".concat(v.current,")...")),y.current=setTimeout(()=>{A()},Math.round(e*(.5+.5*Math.random())))}else p("disconnected")},e.onerror=()=>{N.current=!1,f(Error("WebSocket connection error")),m(!1)},e.onmessage=t=>{try{let r=JSON.parse(t.data);if("error"===r.type){f(Error(r.error||"Failed to stream logs for ".concat(r.agent||j.current))),c(e=>[...e,{id:eF(),timestamp:Date.now(),content:"Error: ".concat(r.error||"Unknown error"),type:"system",agentName:r.agent||j.current}]);return}if("subscribed"===r.type){console.log("[useAgentLogs] Subscribed to ".concat(r.agent));return}if("replay"===r.type&&Array.isArray(r.entries)){C.current.set(e,!0),c(e=>{let t=[];for(let e of r.entries){var s;let n=e.content||"",r=e.timestamp||Date.now(),a=D(n,r);!L.current.has(a)&&(L.current.add(a),t.push({id:eF(),timestamp:r,content:n,type:"stdout",agentName:j.current}),r>(null!==(s=S.current)&&void 0!==s?s:0)&&(S.current=r))}return 0===t.length?e:[...e,...t].slice(-n)});return}if("history"===r.type&&Array.isArray(r.lines)){r.lines.length>0&&C.current.set(e,!0),c(e=>{let t=r.lines.map(e=>{let t=Date.now(),n=D(e,t);return L.current.add(n),S.current=t,{id:eF(),timestamp:t,content:e,type:"stdout",agentName:r.agent||j.current}});return[...e,...t].slice(-n)});return}if("string"==typeof r){C.current.set(e,!0);let t=Date.now();S.current=t;let s=D(r,t);L.current.add(s),c(e=>[...e,{id:eF(),timestamp:t,content:r,type:"stdout",agentName:j.current}].slice(-n))}else if("log"===r.type||"output"===r.type){C.current.set(e,!0);let t=r.timestamp||Date.now(),s=r.content||r.data||r.message||"";S.current=t;let a=D(s,t);L.current.add(a),c(e=>{let a="stderr"===r.stream?"stderr":"stdout";return[...e,{id:eF(),timestamp:t,content:s,type:a,agentName:r.agentName||j.current}].slice(-n)})}else r.lines&&Array.isArray(r.lines)&&(C.current.set(e,!0),c(e=>{let t=r.lines.map(e=>{let t="object"==typeof e&&"stderr"===e.type?"stderr":"stdout",n="string"==typeof e?e:e.content,r=Date.now();S.current=r;let s=D(n,r);return L.current.add(s),{id:eF(),timestamp:r,content:n,type:t,agentName:j.current}});return[...e,...t].slice(-n)}));if(L.current.size>2e3){let e=Array.from(L.current);L.current=new Set(e.slice(-1e3))}}catch(r){if("string"==typeof t.data){C.current.set(e,!0);let r=Date.now();S.current=r,c(e=>[...e,{id:eF(),timestamp:r,content:t.data,type:"stdout",agentName:j.current}].slice(-n))}}}}catch(e){N.current=!1,f(e instanceof Error?e:Error("Failed to create WebSocket")),m(!1)}}},[i,n,a,l,D]),E=(0,s.useCallback)(()=>{w.current=!1,y.current&&(clearTimeout(y.current),y.current=null),b.current&&(k.current.set(b.current,!0),b.current.close(),b.current=null),N.current=!1,u(!1),m(!1),p("disconnected")},[]),T=(0,s.useCallback)(()=>{c([]),L.current.clear()},[]);return(0,s.useEffect)(()=>(r&&t&&A(),()=>{E()}),[t,r,A,E]),(0,s.useEffect)(()=>{let e=()=>{"visible"!==document.visibilityState||b.current&&b.current.readyState!==WebSocket.CLOSED||(console.log("[WS:Logs] Tab visible, reconnecting..."),v.current=0,A())};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[A]),{logs:o,isConnected:d,isConnecting:x,connectionState:h,error:g,connect:A,disconnect:E,clear:T}}var eO=n(8906);function eH(e){let{agentName:t,lines:n=2,compact:a=!1,onExpand:l,className:i=""}=e,{logs:o,isConnected:d,isConnecting:u,error:x}=eU({agentName:t,autoConnect:!0,maxLines:50}),m=(0,c.GW)(t),h=(0,s.useMemo)(()=>{let e=[];for(let t of o)if("system"!==t.type)for(let n of(0,eO.hL)(t.content).split("\n")){let t=n.trim();0!==t.length&&((0,eO.ED)(t)||e.push(n.replace(/\s+$/g,"")))}return e.slice(-Math.max(1,n))},[o,n]),p=u?{label:"connecting",cls:"bg-[#d29922]/15 text-[#d29922]"}:d?{label:"live",cls:"bg-[#238636]/15 text-[#3fb950]"}:x?{label:"error",cls:"bg-[#f85149]/15 text-[#f85149]"}:{label:"offline",cls:"bg-[#484f58]/15 text-[#8b949e]"};return(0,r.jsxs)("div",{className:"mt-2 rounded-lg border ".concat(i),style:{borderColor:"".concat(m.primary,"35"),background:"linear-gradient(180deg, rgba(13,15,20,0.9) 0%, rgba(18,21,28,0.9) 100%)",boxShadow:"inset 0 1px 0 rgba(255,255,255,0.02)"},children:[(0,r.jsxs)("div",{className:"flex items-center justify-between ".concat(a?"px-2 py-1":"px-2.5 py-1.5"," border-b border-[#2a2d35]/70"),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.jsx)(ez,{}),(0,r.jsx)("span",{className:"text-[11px] font-medium truncate",style:{color:m.primary},children:"Logs"}),(0,r.jsx)("span",{className:"px-1.5 py-0.5 rounded-full text-[10px] uppercase tracking-wider font-medium ".concat(p.cls),children:p.label})]}),l&&(0,r.jsx)("button",{type:"button",className:"p-1.5 rounded-lg hover:bg-[#21262d] text-[#8b949e] hover:text-accent-cyan transition-all duration-200",onClick:l,title:"Expand logs",children:(0,r.jsx)(eG,{})})]}),(0,r.jsx)("div",{className:"".concat(a?"px-2 py-1.5":"px-2.5 py-2"," font-mono text-[11px] leading-4"),children:h.length>0?h.map((e,t)=>(0,r.jsx)("div",{className:"text-[#c9d1d9] truncate",children:e},t)):(0,r.jsx)("div",{className:"text-[#8b949e] italic",children:(null==x?void 0:x.message)||"Waiting for output..."})})]})}function ez(e){let{size:t=14}=e;return(0,r.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#8b949e]",children:[(0,r.jsx)("polyline",{points:"4 17 10 11 4 5"}),(0,r.jsx)("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function eG(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("polyline",{points:"15 3 21 3 21 9"}),(0,r.jsx)("polyline",{points:"9 21 3 21 3 15"}),(0,r.jsx)("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),(0,r.jsx)("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]})}var eV=n(1722);let eZ={claude:{icon:"◈",color:"#00d9ff"},codex:{icon:"⬡",color:"#ff6b35"},gemini:{icon:"◇",color:"#a855f7"},openai:{icon:"◆",color:"#10a37f"},default:{icon:"●",color:"#00d9ff"}};function eK(e){let t=e.toLowerCase();if(t.includes("claude")||t.includes("anthropic"))return eZ.claude;if(t.includes("codex")||t.includes("openai")||t.includes("gpt"))return eZ.codex;if(t.includes("gemini")||t.includes("google")||t.includes("bard"))return eZ.gemini;let n=e.split("").reduce((e,t)=>e+t.charCodeAt(0),0),r=Object.keys(eZ).filter(e=>"default"!==e);return eZ[r[n%r.length]]}function eq(e){let{messages:t,currentChannel:n,onThreadClick:a,highlightedMessageId:l,currentThread:i,agents:o=[],currentUser:c,skipChannelFilter:d=!1,autoScrollDefault:u=!0,showTimestamps:x=!0,compactMode:m=!1,onAgentClick:h,onUserClick:p,onLogsClick:g,onlineUsers:f=[],onReaction:b}=e,v=new Map;for(let e of o)e.isProcessing&&v.set(e.name,{isProcessing:!0,processingStartedAt:e.processingStartedAt});let y=new Map,j=(0,s.useRef)(null),w=(0,s.useRef)(null),[N,k]=(0,s.useState)(u),C=(0,s.useRef)(0),S=(0,s.useRef)(n),M=(0,s.useRef)(!1),L=(0,s.useRef)(!1),D=(0,s.useRef)(null);(0,s.useEffect)(()=>{k(u)},[u]);let A=t.filter(e=>i?e.id===i||e.thread===i:!!d||n!==rY&&("#general"===n?"general"===e.channel||"#general"===e.channel||"#general"===e.to:e.from===n||e.to===n));for(let e of A)("Dashboard"===e.from||c&&e.from===c.displayName)&&"*"!==e.to&&y.set(e.to,e.id);let E=A.length;if(E>C.current){let e=A[A.length-1],t=(null==e?void 0:e.from)==="Dashboard"||c&&(null==e?void 0:e.from)===c.displayName;u&&(t||N)&&(M.current=!0,t&&!N&&k(!0))}C.current=E;let T=(0,s.useCallback)(()=>{if(!j.current||L.current||!u)return;let e=j.current,t=e.scrollHeight-e.scrollTop-e.clientHeight;t<50&&!N?k(!0):t>150&&N&&k(!1)},[N]);return((0,s.useEffect)(()=>{if(!u||!N||"undefined"==typeof ResizeObserver)return;let e=w.current;if(!e)return;let t=new ResizeObserver(()=>{N&&j.current&&null===D.current&&(D.current=requestAnimationFrame(()=>{if(D.current=null,!N||!j.current)return;L.current=!0;let e=j.current;e.scrollTop=e.scrollHeight,requestAnimationFrame(()=>{setTimeout(()=>{L.current=!1},50)})}))});return t.observe(e),()=>{t.disconnect(),null!==D.current&&(cancelAnimationFrame(D.current),D.current=null)}},[N,u]),(0,s.useLayoutEffect)(()=>{if(M.current&&j.current){M.current=!1,L.current=!0;let e=j.current;e.scrollTop=e.scrollHeight,requestAnimationFrame(()=>{setTimeout(()=>{L.current=!1},50)})}},[A.length]),(0,s.useLayoutEffect)(()=>{if(n!==S.current&&(S.current=n,C.current=A.length,k(!0),j.current)){L.current=!0;let e=j.current;e.scrollTop=e.scrollHeight,requestAnimationFrame(()=>{setTimeout(()=>{L.current=!1},50)})}},[n,A.length]),0===A.length)?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-text-muted text-center",children:[(0,r.jsx)(eY,{}),(0,r.jsx)("h3",{className:"m-0 mb-2 text-base font-display text-text-secondary",children:"No messages yet"}),(0,r.jsx)("p",{className:"m-0 text-sm",children:"Messages in ".concat(n," will appear here")})]}):(0,r.jsx)("div",{className:"bg-bg-secondary h-full overflow-y-auto",ref:j,onScroll:T,children:(0,r.jsx)("div",{ref:w,className:"flex flex-col ".concat(m?"gap-0 p-1 sm:p-1.5":"gap-2 p-3 sm:p-4"),children:A.map(e=>{let t=("Dashboard"===e.from||c&&e.from===c.displayName)&&"*"!==e.to&&y.get(e.to)===e.id?v.get(e.to):void 0;return(0,r.jsx)(eJ,{message:e,isHighlighted:e.id===l,onThreadClick:a,recipientProcessing:t,currentUser:c,showTimestamps:x,compactMode:m,agents:o,onlineUsers:f,onAgentClick:h,onUserClick:p,onLogsClick:g,onReaction:b},e.id)})})})}function eJ(e){var t,n,s;let{message:a,isHighlighted:l,onThreadClick:i,recipientProcessing:o,currentUser:c,showTimestamps:d=!0,compactMode:u=!1,agents:x=[],onlineUsers:m=[],onAgentClick:h,onUserClick:p,onLogsClick:f,onReaction:b}=e,v=function(e){let t=new Date(e),n=new Date;if(t.toDateString()===n.toDateString())return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});let r=new Date(n);return(r.setDate(r.getDate()-1),t.toDateString()===r.toDateString())?"Yesterday ".concat(t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})):t.toLocaleDateString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}(a.timestamp),y="Dashboard"===a.from||c&&a.from===c.displayName,j=y&&c?{icon:"",color:"#a855f7"}:eK(a.from),w=y&&c?c.displayName:a.from,N=null!==(s=null!==(n=null===(t=a.threadSummary)||void 0===t?void 0:t.replyCount)&&void 0!==n?n:a.replyCount)&&void 0!==s?s:0,k=N>0,C=x.find(e=>e.name.toLowerCase()===a.from.toLowerCase()&&!e.isHuman),S=m.find(e=>e.username.toLowerCase()===a.from.toLowerCase()),M="*"!==a.to?x.find(e=>e.name.toLowerCase()===a.to.toLowerCase()&&!e.isHuman):void 0,L="*"!==a.to?m.find(e=>e.username.toLowerCase()===a.to.toLowerCase()):void 0,D=M?eK(a.to):void 0,A=y&&("acked"===a.status||"read"===a.status)&&(null==o?void 0:o.isProcessing);return(0,r.jsxs)("div",{className:"\n group flex rounded-xl transition-all duration-150\n ".concat(u?"gap-1.5 py-1 px-1.5":"gap-3 sm:gap-4 py-2.5 sm:py-3 px-3 sm:px-4","\n hover:bg-bg-card/50\n ").concat(l?"bg-warning-light/20 border-l-2 border-l-warning pl-2 sm:pl-3":"","\n "),children:[y&&(null==c?void 0:c.avatarUrl)?(0,r.jsx)("img",{src:c.avatarUrl,alt:w,className:"shrink-0 rounded-lg sm:rounded-xl border-2 object-cover ".concat(u?"w-6 h-6 sm:w-7 sm:h-7":"w-9 h-9 sm:w-10 sm:h-10"),style:{borderColor:j.color,boxShadow:"0 0 16px ".concat(j.color,"30")}}):(null==S?void 0:S.avatarUrl)?(0,r.jsx)("img",{src:S.avatarUrl,alt:w,className:"shrink-0 rounded-lg sm:rounded-xl border-2 object-cover ".concat(u?"w-6 h-6 sm:w-7 sm:h-7":"w-9 h-9 sm:w-10 sm:h-10"),style:{borderColor:j.color,boxShadow:"0 0 16px ".concat(j.color,"30")}}):(0,r.jsx)("div",{className:"shrink-0 rounded-lg sm:rounded-xl flex items-center justify-center font-medium border-2 ".concat(u?"w-6 h-6 sm:w-7 sm:h-7 text-xs sm:text-sm":"w-9 h-9 sm:w-10 sm:h-10 text-base sm:text-lg"),style:{backgroundColor:"".concat(j.color,"15"),borderColor:j.color,color:j.color,boxShadow:"0 0 16px ".concat(j.color,"30")},children:j.icon}),(0,r.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-wrap ".concat(u?"mb-0.5":"mb-1.5"),children:[(0,r.jsx)(eI,{displayName:w,color:j.color,isCurrentUser:y,agent:C,userPresence:S,onAgentClick:h,onUserClick:p}),"*"!==a.to&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-text-dim text-xs",children:"→"}),(0,r.jsx)(eI,{displayName:a.to,color:(null==D?void 0:D.color)||"#00d9ff",agent:M,userPresence:L,onAgentClick:h,onUserClick:p})]}),a.thread&&(0,r.jsx)("span",{className:"text-xs py-0.5 px-2 rounded-full font-mono font-medium bg-accent-purple/20 text-accent-purple",children:a.thread}),"*"===a.to&&(0,r.jsx)("span",{className:"text-xs py-0.5 px-2 rounded-full uppercase font-medium bg-warning/20 text-warning",children:"broadcast"}),d&&(0,r.jsx)("span",{className:"text-text-dim text-xs ml-auto font-mono",children:v}),y&&(0,r.jsx)(eE,{status:a.status,size:"small"}),A&&(0,r.jsx)(g.Fw,{isProcessing:!0,processingStartedAt:null==o?void 0:o.processingStartedAt,size:"small",showLabel:!0}),(0,r.jsxs)("button",{className:"\n inline-flex items-center gap-1.5 p-1.5 rounded-lg transition-all duration-150 cursor-pointer border-none\n ".concat(k||a.thread?"text-accent-cyan bg-accent-cyan/10 hover:bg-accent-cyan/20":"text-text-muted bg-transparent opacity-0 group-hover:opacity-100 hover:text-accent-cyan hover:bg-accent-cyan/10","\n "),onClick:()=>null==i?void 0:i(a.thread||a.id),title:a.thread?"View thread: ".concat(a.thread):k?"".concat(N," ").concat(1===N?"reply":"replies"):"Reply in thread",children:[(0,r.jsx)(eX,{}),k&&(0,r.jsx)("span",{className:"text-xs font-medium",children:N})]})]}),(0,r.jsx)("div",{className:"text-sm leading-relaxed text-text-primary whitespace-pre-wrap break-words",children:(0,eB.y)(a.content)}),a.attachments&&a.attachments.length>0&&(0,r.jsx)(e$,{attachments:a.attachments}),b&&(0,r.jsx)(eV.s,{reactions:a.reactions||[],messageId:a.id,currentUser:(null==c?void 0:c.displayName)||"user",onToggleReaction:b}),A&&M&&(0,r.jsx)(eH,{agentName:M.name,lines:5,compact:u,onExpand:f?()=>f(M):void 0})]})]})}function e$(e){let{attachments:t}=e,[n,a]=(0,s.useState)(null),l=t.filter(e=>e.mimeType.startsWith("image/"));return 0===l.length?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"flex flex-wrap gap-2 mt-2",children:l.map(e=>(0,r.jsxs)("button",{type:"button",onClick:()=>a(e),className:"relative group cursor-pointer bg-transparent border-0 p-0",title:"View ".concat(e.filename),children:[(0,r.jsx)("img",{src:e.data||e.url,alt:e.filename,className:"max-h-48 max-w-xs rounded-lg border border-border-subtle object-cover transition-all duration-150 group-hover:border-accent-cyan/50 group-hover:shadow-[0_0_8px_rgba(0,217,255,0.2)]",loading:"lazy"}),(0,r.jsx)("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/10 rounded-lg transition-colors flex items-center justify-center opacity-0 group-hover:opacity-100",children:(0,r.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",className:"drop-shadow-lg",children:[(0,r.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,r.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),(0,r.jsx)("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),(0,r.jsx)("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})})]},e.id))}),n&&(0,r.jsx)("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/80 backdrop-blur-sm",onClick:()=>a(null),children:(0,r.jsxs)("div",{className:"relative max-w-[90vw] max-h-[90vh]",children:[(0,r.jsx)("img",{src:n.data||n.url,alt:n.filename,className:"max-w-full max-h-[90vh] rounded-lg shadow-2xl",onClick:e=>e.stopPropagation()}),(0,r.jsx)("button",{type:"button",onClick:()=>a(null),className:"absolute -top-3 -right-3 w-8 h-8 bg-bg-tertiary border border-border-subtle rounded-full flex items-center justify-center text-text-muted hover:text-text-primary hover:bg-bg-card transition-colors shadow-lg",title:"Close",children:(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,r.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),(0,r.jsx)("div",{className:"absolute bottom-0 left-0 right-0 p-3 bg-gradient-to-t from-black/60 to-transparent rounded-b-lg",children:(0,r.jsx)("p",{className:"text-white text-sm truncate",children:n.filename})})]})})]})}function eY(){return(0,r.jsx)("svg",{className:"mb-4 opacity-50 text-text-muted",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:(0,r.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function eX(){return(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function eQ(e){let{originalMessage:t,replies:n,onClose:a,onReply:l,isSending:i=!1,currentUser:o,showTimestamps:c=!0,isLoading:d=!1,hasMore:u=!1,onLoadMore:x}=e,[m,h]=(0,s.useState)(""),p=(0,s.useRef)(null),g=(0,s.useRef)(null);(0,s.useEffect)(()=>{requestAnimationFrame(()=>{var e;null===(e=p.current)||void 0===e||e.scrollIntoView({behavior:"smooth"})})},[null==n?void 0:n.length]),(0,s.useEffect)(()=>{var e;null===(e=g.current)||void 0===e||e.focus()},[null==t?void 0:t.id]);let f=async e=>{e.preventDefault(),m.trim()&&!i&&await l(m.trim())&&h("")};return t?(0,r.jsxs)("div",{className:"flex flex-col h-full bg-bg-primary border-l border-border",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-bg-secondary",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(e2,{}),(0,r.jsx)("span",{className:"font-semibold text-sm text-text-primary",children:"Thread"}),(0,r.jsxs)("span",{className:"text-text-muted text-xs",children:[(null==n?void 0:n.length)||0," ",(null==n?void 0:n.length)===1?"reply":"replies"]})]}),(0,r.jsx)("button",{onClick:a,className:"p-1.5 rounded hover:bg-bg-hover transition-colors text-text-muted hover:text-text-primary",title:"Close thread",children:(0,r.jsx)(e5,{})})]}),(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto",children:[(0,r.jsx)("div",{className:"p-4 border-b border-border",children:(0,r.jsx)(e0,{message:t,isOriginal:!0,currentUser:o,showTimestamps:c})}),(0,r.jsxs)("div",{className:"p-4 space-y-3",children:[u&&(0,r.jsx)("div",{className:"text-center pb-2",children:(0,r.jsx)("button",{type:"button",onClick:x,disabled:d,className:"text-xs text-accent-cyan hover:text-accent-cyan/80 transition-colors cursor-pointer bg-transparent border-none disabled:opacity-50",children:d?"Loading...":"Load earlier replies"})}),d&&0===n.length?(0,r.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"Loading thread..."}):0===n.length?(0,r.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No replies yet. Be the first to reply!"}):n.map(e=>(0,r.jsx)(e0,{message:e,currentUser:o,showTimestamps:c},e.id)),(0,r.jsx)("div",{ref:p})]})]}),(0,r.jsx)("div",{className:"p-4 border-t border-border bg-bg-secondary",children:(0,r.jsxs)("form",{onSubmit:f,className:"flex gap-2",children:[(0,r.jsx)("textarea",{ref:g,value:m,onChange:e=>h(e.target.value),onKeyDown:e=>{if("Enter"===e.key&&e.altKey){e.preventDefault();let t=e.currentTarget,n=t.selectionStart,r=t.selectionEnd;h(m.slice(0,n)+"\n"+m.slice(r)),setTimeout(()=>{t.selectionStart=t.selectionEnd=n+1},0);return}"Enter"!==e.key||e.shiftKey||e.altKey||(e.preventDefault(),f(e))},placeholder:"Reply to thread...",disabled:i,rows:1,className:"flex-1 py-2 px-3 bg-bg-primary border border-border rounded-md text-sm text-text-primary resize-none min-h-[40px] max-h-[100px] overflow-y-auto focus:outline-none focus:border-accent transition-colors placeholder:text-text-muted"}),(0,r.jsx)("button",{type:"submit",disabled:!m.trim()||i,className:"px-4 py-2 bg-accent text-white rounded-md text-sm font-medium transition-colors hover:bg-accent-hover disabled:opacity-50 disabled:cursor-not-allowed",children:i?"Sending...":"Reply"})]})})]}):(0,r.jsxs)("div",{className:"flex flex-col h-full bg-bg-primary border-l border-border",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-bg-secondary",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(e2,{}),(0,r.jsx)("span",{className:"font-semibold text-sm text-text-primary",children:"Thread"})]}),(0,r.jsx)("button",{onClick:a,className:"p-1.5 rounded hover:bg-bg-hover transition-colors text-text-muted hover:text-text-primary",title:"Close thread",children:(0,r.jsx)(e5,{})})]}),(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center text-text-muted text-sm",children:d?"Loading thread...":"Thread not found"})]})}function e0(e){let{message:t,isOriginal:n,currentUser:s,showTimestamps:a=!0}=e,l=(0,c.GW)(t.from),i=function(e){if(!e)return"";let t=new Date(e);if(isNaN(t.getTime()))return"";let n=new Date;return t.toDateString()===n.toDateString()?t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):t.toLocaleDateString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}(t.timestamp),o="Dashboard"===t.from||s&&t.from===s.displayName,d=o&&s?s.displayName:t.from;return(0,r.jsxs)("div",{className:"flex gap-3 ".concat(n?"":"pl-2"),children:[o&&(null==s?void 0:s.avatarUrl)?(0,r.jsx)("img",{src:s.avatarUrl,alt:d,className:"shrink-0 w-8 h-8 rounded-lg object-cover"}):(0,r.jsx)("div",{className:"shrink-0 w-8 h-8 rounded-lg flex items-center justify-center font-semibold text-xs",style:{backgroundColor:l.primary,color:l.text},children:(0,c.hP)(t.from)}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,r.jsx)("span",{className:"font-semibold text-sm text-text-primary",children:d}),"*"!==t.to&&!n&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-text-muted text-xs",children:"→"}),(0,r.jsx)("span",{className:"text-sm text-accent",children:t.to})]}),a&&(0,r.jsx)("span",{className:"text-text-muted text-xs",children:i}),n&&(0,r.jsx)("span",{className:"text-[10px] py-0.5 px-1.5 rounded bg-accent-light text-accent font-medium",children:"Original"})]}),(0,r.jsx)("div",{className:"text-sm leading-relaxed text-text-primary whitespace-pre-wrap break-words",children:(0,eB.y)(t.content)}),t.attachments&&t.attachments.length>0&&(0,r.jsx)(e1,{attachments:t.attachments})]})]})}function e1(e){let{attachments:t}=e,[n,a]=(0,s.useState)(null),l=t.filter(e=>e.mimeType.startsWith("image/"));return 0===l.length?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"flex flex-wrap gap-2 mt-2",children:l.map(e=>(0,r.jsxs)("button",{type:"button",onClick:()=>a(e),className:"relative group cursor-pointer bg-transparent border-0 p-0",title:"View ".concat(e.filename),children:[(0,r.jsx)("img",{src:e.data||e.url,alt:e.filename,className:"max-h-32 max-w-[200px] rounded-lg border border-border object-cover transition-all duration-150 group-hover:border-accent/50 group-hover:shadow-md",loading:"lazy"}),(0,r.jsx)("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/10 rounded-lg transition-colors flex items-center justify-center opacity-0 group-hover:opacity-100",children:(0,r.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",className:"drop-shadow-lg",children:[(0,r.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,r.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),(0,r.jsx)("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),(0,r.jsx)("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})})]},e.id))}),n&&(0,r.jsx)("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/80 backdrop-blur-sm",onClick:()=>a(null),children:(0,r.jsxs)("div",{className:"relative max-w-[90vw] max-h-[90vh]",children:[(0,r.jsx)("img",{src:n.data||n.url,alt:n.filename,className:"max-w-full max-h-[90vh] rounded-lg shadow-2xl",onClick:e=>e.stopPropagation()}),(0,r.jsx)("button",{type:"button",onClick:()=>a(null),className:"absolute -top-3 -right-3 w-8 h-8 bg-bg-primary border border-border rounded-full flex items-center justify-center text-text-muted hover:text-text-primary hover:bg-bg-secondary transition-colors shadow-lg",title:"Close",children:(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,r.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),(0,r.jsx)("div",{className:"absolute bottom-0 left-0 right-0 p-3 bg-gradient-to-t from-black/60 to-transparent rounded-b-lg",children:(0,r.jsx)("p",{className:"text-white text-sm truncate",children:n.filename})})]})})]})}function e2(){return(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-text-primary",children:(0,r.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function e5(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,r.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}let e4=["projects","agents","actions","channels","navigation","settings"],e3={critical:{label:"Critical",beadsPriority:0,color:"#ef4444"},high:{label:"High",beadsPriority:1,color:"#f97316"},medium:{label:"Medium",beadsPriority:2,color:"#f59e0b"},low:{label:"Low",beadsPriority:3,color:"#6366f1"}};function e6(e){return e.isOpen?(0,r.jsx)(e8,{...e}):null}function e8(e){let{onClose:t,agents:n,projects:a=[],currentProject:l,onAgentSelect:i,onProjectSelect:o,onSpawnClick:d,onTaskCreate:u,onSettingsClick:x,onGeneralClick:m,customCommands:h=[]}=e,[p,g]=(0,s.useState)(""),[f,b]=(0,s.useState)(0),[v,y]=(0,s.useState)(null),j=(0,s.useRef)(f),w=(0,s.useRef)(null),N=(0,s.useRef)(null),k=(0,s.useRef)([]),[C,S]=(0,s.useState)("search"),[M,L]=(0,s.useState)(null),[D,A]=(0,s.useState)(""),[E,T]=(0,s.useState)("medium"),[W,P]=(0,s.useState)(!1),I=(0,s.useMemo)(()=>n.filter(e=>"offline"!==e.status&&"error"!==e.status),[n]),B=(0,s.useMemo)(()=>{if(!p.trim())return I;let e=p.toLowerCase();return I.filter(t=>t.name.toLowerCase().includes(e))},[I,p]),_=(0,s.useCallback)(()=>{S("task-select-agent"),g(""),b(0),L(null),A(""),T("medium")},[]),R=(0,s.useCallback)(async()=>{if(M&&D.trim()&&u){P(!0);try{await u({agentName:M.name,title:D.trim(),priority:E}),t()}catch(e){console.error("Failed to create task:",e)}finally{P(!1)}}},[M,D,E,u,t]);(0,s.useEffect)(()=>{j.current=f},[f]);let F=(0,s.useMemo)(()=>[...[...a].sort((e,t)=>{let n=e.id===l,r=t.id===l;if(n&&!r)return -1;if(!n&&r)return 1;let s=e.name||e.path.split("/").pop()||e.id,a=t.name||t.path.split("/").pop()||t.id;return s.localeCompare(a)}).map(e=>{let n=e.name||e.path.split("/").pop()||e.id,s=e.id===l;return{id:"project-".concat(e.id),label:n,description:s?"Current project • ".concat(e.agents.length," agents"):"".concat(e.agents.length," agents"),category:"projects",icon:s?(0,r.jsx)(ta,{}):(0,r.jsx)(ts,{}),action:()=>{null==o||o(e),t()}}}),...n.map(e=>({id:"agent-".concat(e.name),label:e.name,description:e.currentTask||e.status,category:"agents",icon:(0,r.jsx)(e9,{name:e.name}),action:()=>{i(e),t()}})),{id:"spawn-agent",label:"Spawn Agent",description:"Launch a new agent instance",category:"actions",icon:(0,r.jsx)(te,{}),shortcut:"⌘⇧S",action:()=>{d(),t()}},{id:"broadcast",label:"Broadcast Message",description:"Send message to all agents",category:"actions",icon:(0,r.jsx)(tt,{}),action:()=>{t()}},...u?[{id:"assign-task",label:"Assign Task",description:"Create a task for an agent (creates bead)",category:"actions",icon:(0,r.jsx)(tl,{}),shortcut:"⌘⇧T",action:()=>{_()}}]:[],{id:"nav-general",label:"Go to #general",description:"General discussion channel",category:"navigation",icon:(0,r.jsx)(tn,{}),action:()=>{null==m||m(),t()}},...x?[{id:"settings",label:"Settings",description:"Configure dashboard preferences",category:"settings",icon:(0,r.jsx)(tr,{}),shortcut:"⌘,",action:()=>{x(),t()}}]:[],...h],[n,a,l,i,o,d,x,m,t,h]),U=(0,s.useMemo)(()=>{let e=F;if(v&&(e=e.filter(e=>e.category===v)),p.trim()){let t=p.toLowerCase();e=e.filter(e=>{var n;return e.label.toLowerCase().includes(t)||(null===(n=e.description)||void 0===n?void 0:n.toLowerCase().includes(t))||e.category.toLowerCase().includes(t)})}return e},[F,p,v]),O=(0,s.useMemo)(()=>{let e={};for(let t of U)e[t.category]||(e[t.category]=[]),e[t.category].push(t);return e},[U]),H=(0,s.useMemo)(()=>e4.flatMap(e=>O[e]||[]),[O]);(0,s.useEffect)(()=>{b(0)},[p]),(0,s.useEffect)(()=>{g(""),b(0),y(null),S("search"),L(null),A(""),T("medium")},[]),(0,s.useEffect)(()=>{let e=k.current[f];e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})},[f]),(0,s.useEffect)(()=>{let e=e=>{if("task-details"===C){"Escape"===e.key?(e.preventDefault(),S("task-select-agent"),g("")):"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),R());return}if("task-select-agent"===C){switch(e.key){case"ArrowDown":e.preventDefault(),b(e=>Math.min(e+1,B.length-1));break;case"ArrowUp":e.preventDefault(),b(e=>Math.max(e-1,0));break;case"Enter":e.preventDefault(),B[j.current]&&(L(B[j.current]),S("task-details"),g(""));break;case"Escape":e.preventDefault(),S("search"),g("")}return}switch(e.key){case"ArrowDown":e.preventDefault(),b(e=>Math.min(e+1,H.length-1));break;case"ArrowUp":e.preventDefault(),b(e=>Math.max(e-1,0));break;case"Enter":e.preventDefault(),H[j.current]&&H[j.current].action();break;case"Tab":e.preventDefault(),y(t=>{if(null===t)return e4[0];let n=e4.indexOf(t);return e.shiftKey?0===n?null:e4[n-1]:n===e4.length-1?null:e4[n+1]}),b(0);break;case"Escape":e.preventDefault(),v?(y(null),b(0)):t()}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[H,B,C,f,v,t,R]);let z={projects:"Projects",agents:"Agents",actions:"Actions",navigation:"Navigation",settings:"Settings"},G=0;if("task-select-agent"===C)return(0,r.jsx)("div",{className:"fixed inset-0 bg-black/60 flex items-start justify-center pt-[15vh] z-[1000] animate-fade-in",onClick:()=>{S("search"),g("")},children:(0,r.jsxs)("div",{className:"bg-sidebar-bg border border-sidebar-border rounded-xl w-[560px] max-w-[90vw] max-h-[60vh] flex flex-col shadow-modal animate-slide-down",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 p-4 border-b border-sidebar-border",children:[(0,r.jsx)("button",{className:"p-1 rounded hover:bg-sidebar-border text-text-muted",onClick:()=>{S("search"),g("")},children:(0,r.jsx)(ti,{})}),(0,r.jsx)(tl,{}),(0,r.jsx)("input",{ref:w,autoFocus:!0,type:"text",className:"flex-1 border-none text-base font-sans outline-none bg-transparent text-text-primary placeholder:text-text-muted",placeholder:"Select agent to assign task...",value:p,onChange:e=>{g(e.target.value),b(0)}}),(0,r.jsx)("kbd",{className:"bg-sidebar-border border border-sidebar-hover rounded px-1.5 py-0.5 text-xs text-text-muted font-sans",children:"ESC"})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto p-2",ref:N,children:0===B.length?(0,r.jsx)("div",{className:"py-8 text-center text-text-muted text-sm",children:p?'No agents matching "'.concat(p,'"'):"No available agents"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider py-2 px-3",children:"Select Agent"}),B.map((e,t)=>{let n=(0,c.GW)(e.name);return(0,r.jsxs)("button",{ref:e=>{k.current[t]=e},className:"\n flex items-center gap-3 w-full py-2.5 px-3 border-none rounded-lg cursor-pointer text-left font-sans transition-colors duration-100\n ".concat(t===f?"bg-accent-light border border-accent/30":"bg-transparent hover:bg-sidebar-border","\n "),onClick:()=>{L(e),S("task-details"),g("")},onMouseEnter:()=>b(t),children:[(0,r.jsx)("div",{className:"w-7 h-7 rounded-md flex items-center justify-center text-xs font-semibold",style:{backgroundColor:n.primary,color:n.text},children:(0,c.hP)(e.name)}),(0,r.jsxs)("span",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-text-primary",children:e.name}),(0,r.jsx)("span",{className:"text-xs text-text-muted truncate",children:e.currentTask||e.status})]})]},e.name)})]})})]})});if("task-details"===C&&M){let e=(0,c.GW)(M.name);return(0,r.jsx)("div",{className:"fixed inset-0 bg-black/60 flex items-start justify-center pt-[15vh] z-[1000] animate-fade-in",onClick:()=>{S("task-select-agent"),g("")},children:(0,r.jsxs)("div",{className:"bg-sidebar-bg border border-sidebar-border rounded-xl w-[560px] max-w-[90vw] flex flex-col shadow-modal animate-slide-down",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 p-4 border-b border-sidebar-border",children:[(0,r.jsx)("button",{className:"p-1 rounded hover:bg-sidebar-border text-text-muted",onClick:()=>{S("task-select-agent"),g("")},children:(0,r.jsx)(ti,{})}),(0,r.jsx)("div",{className:"w-7 h-7 rounded-md flex items-center justify-center text-xs font-semibold",style:{backgroundColor:e.primary,color:e.text},children:(0,c.hP)(M.name)}),(0,r.jsxs)("span",{className:"text-base font-medium text-text-primary",children:["Assign task to ",M.name]})]}),(0,r.jsxs)("div",{className:"p-4 flex flex-col gap-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1.5",children:"Task Title"}),(0,r.jsx)("input",{autoFocus:!0,type:"text",value:D,onChange:e=>A(e.target.value),placeholder:"What needs to be done?",className:"w-full px-3 py-2 text-sm bg-bg-tertiary border border-sidebar-border rounded-md text-text-primary placeholder:text-text-dim focus:outline-none focus:border-accent-cyan"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1.5",children:"Priority"}),(0,r.jsx)("div",{className:"flex gap-2",children:Object.keys(e3).map(e=>{let t=e3[e],n=E===e;return(0,r.jsx)("button",{type:"button",className:"px-3 py-1.5 text-xs font-medium rounded-md border transition-all ".concat(n?"border-transparent text-white":"border-sidebar-border text-text-muted hover:border-sidebar-hover"),style:{backgroundColor:n?t.color:"transparent"},onClick:()=>T(e),children:t.label},e)})}),(0,r.jsxs)("p",{className:"text-xs text-text-dim mt-1.5",children:["Maps to beads priority P",e3[E].beadsPriority]})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 pt-2 border-t border-sidebar-border",children:[(0,r.jsx)("button",{type:"button",className:"px-4 py-2 text-sm text-text-muted hover:text-text-primary transition-colors",onClick:()=>{S("task-select-agent"),g("")},children:"Back"}),(0,r.jsx)("button",{type:"button",disabled:!D.trim()||W,onClick:R,className:"px-4 py-2 text-sm font-medium bg-accent-cyan text-bg-deep rounded-md hover:bg-accent-cyan/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:W?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(to,{}),"Creating..."]}):(0,r.jsxs)(r.Fragment,{children:["Create Task",(0,r.jsx)("kbd",{className:"bg-black/20 rounded px-1 py-0.5 text-[10px]",children:"⌘↵"})]})})]})]})]})})}return(0,r.jsx)("div",{className:"fixed inset-0 bg-black/60 flex items-start justify-center pt-[15vh] z-[1000] animate-fade-in",onClick:t,children:(0,r.jsxs)("div",{className:"bg-sidebar-bg border border-sidebar-border rounded-xl w-[560px] max-w-[90vw] max-h-[60vh] flex flex-col shadow-modal animate-slide-down",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 p-4 border-b border-sidebar-border",children:[(0,r.jsx)(e7,{}),v&&(0,r.jsxs)("button",{onClick:()=>{y(null),b(0)},className:"flex items-center gap-1 px-2 py-0.5 text-xs font-medium bg-accent-cyan/20 text-accent-cyan rounded-md hover:bg-accent-cyan/30 transition-colors",children:[z[v],(0,r.jsx)("span",{className:"text-accent-cyan/60",children:"\xd7"})]}),(0,r.jsx)("input",{ref:w,autoFocus:!0,type:"text",className:"flex-1 border-none text-base font-sans outline-none bg-transparent text-text-primary placeholder:text-text-muted",placeholder:v?"Search ".concat(z[v].toLowerCase(),"..."):"Search commands, agents...",value:p,onChange:e=>g(e.target.value)}),(0,r.jsx)("kbd",{className:"bg-sidebar-border border border-sidebar-hover rounded px-1.5 py-0.5 text-xs text-text-muted font-sans",title:"Cycle categories",children:"Tab"}),(0,r.jsx)("kbd",{className:"bg-sidebar-border border border-sidebar-hover rounded px-1.5 py-0.5 text-xs text-text-muted font-sans",children:"ESC"})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto p-2",ref:N,children:0===H.length?(0,r.jsxs)("div",{className:"py-8 text-center text-text-muted text-sm",children:['No results for "',p,'"']}):e4.map(e=>{let t=O[e];return(null==t?void 0:t.length)?(0,r.jsxs)("div",{className:"mb-2",children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider py-2 px-3",children:z[e]||e}),t.map(e=>{let t=G++;return(0,r.jsxs)("button",{ref:e=>{k.current[t]=e},className:"\n flex items-center gap-3 w-full py-2.5 px-3 border-none rounded-lg cursor-pointer text-left font-sans transition-colors duration-100\n ".concat(t===f?"bg-accent-light border border-accent/30":"bg-transparent hover:bg-sidebar-border","\n "),onClick:e.action,onMouseEnter:()=>b(t),children:[(0,r.jsx)("span",{className:"flex items-center justify-center w-7 h-7 text-text-muted",children:e.icon}),(0,r.jsxs)("span",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-text-primary",children:e.label}),e.description&&(0,r.jsx)("span",{className:"text-xs text-text-muted truncate",children:e.description})]}),e.shortcut&&(0,r.jsx)("kbd",{className:"bg-sidebar-border border border-sidebar-hover rounded px-1.5 py-0.5 text-xs text-text-muted font-sans",children:e.shortcut})]},e.id)})]},e):null})})]})})}function e9(e){let{name:t}=e,n=(0,c.GW)(t);return(0,r.jsx)("div",{className:"w-7 h-7 rounded-md flex items-center justify-center text-xs font-semibold",style:{backgroundColor:n.primary,color:n.text},children:(0,c.hP)(t)})}function e7(){return(0,r.jsxs)("svg",{className:"text-text-muted shrink-0",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,r.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function te(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,r.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function tt(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"2"}),(0,r.jsx)("path",{d:"M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14"})]})}function tn(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("line",{x1:"4",y1:"9",x2:"20",y2:"9"}),(0,r.jsx)("line",{x1:"4",y1:"15",x2:"20",y2:"15"}),(0,r.jsx)("line",{x1:"10",y1:"3",x2:"8",y2:"21"}),(0,r.jsx)("line",{x1:"16",y1:"3",x2:"14",y2:"21"})]})}function tr(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,r.jsx)("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}function ts(){return(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function ta(){return(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-accent-cyan",children:(0,r.jsx)("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})}),(0,r.jsx)("svg",{className:"absolute -bottom-0.5 -right-0.5 text-accent-cyan bg-sidebar-bg rounded-full",width:"10",height:"10",viewBox:"0 0 24 24",fill:"currentColor",children:(0,r.jsx)("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})})]})}function tl(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-text-muted",children:[(0,r.jsx)("path",{d:"M9 11l3 3L22 4"}),(0,r.jsx)("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})}function ti(){return(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("polyline",{points:"15 18 9 12 15 6"})})}function to(){return(0,r.jsx)("svg",{className:"animate-spin",width:"14",height:"14",viewBox:"0 0 24 24",children:(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}var tc=n(2907);let td=[],tu={claude:[{value:"sonnet",label:"Sonnet"},{value:"opus",label:"Opus"},{value:"haiku",label:"Haiku"}],cursor:[{value:"opus-4.5-thinking",label:"Claude 4.5 Opus (Thinking)"},{value:"opus-4.5",label:"Claude 4.5 Opus"},{value:"sonnet-4.5",label:"Claude 4.5 Sonnet"},{value:"sonnet-4.5-thinking",label:"Claude 4.5 Sonnet (Thinking)"},{value:"gpt-5.2-codex",label:"GPT-5.2 Codex"},{value:"gpt-5.2-codex-high",label:"GPT-5.2 Codex High"},{value:"gpt-5.2-codex-low",label:"GPT-5.2 Codex Low"},{value:"gpt-5.2-codex-xhigh",label:"GPT-5.2 Codex Extra High"},{value:"gpt-5.2-codex-fast",label:"GPT-5.2 Codex Fast"},{value:"gpt-5.2-codex-high-fast",label:"GPT-5.2 Codex High Fast"},{value:"gpt-5.2-codex-low-fast",label:"GPT-5.2 Codex Low Fast"},{value:"gpt-5.2-codex-xhigh-fast",label:"GPT-5.2 Codex Extra High Fast"},{value:"gpt-5.1-codex-max",label:"GPT-5.1 Codex Max"},{value:"gpt-5.1-codex-max-high",label:"GPT-5.1 Codex Max High"},{value:"gpt-5.2",label:"GPT-5.2"},{value:"gpt-5.2-high",label:"GPT-5.2 High"},{value:"gpt-5.1-high",label:"GPT-5.1 High"},{value:"gemini-3-pro",label:"Gemini 3 Pro"},{value:"gemini-3-flash",label:"Gemini 3 Flash"},{value:"composer-1",label:"Composer 1"},{value:"grok",label:"Grok"}],codex:[{value:"gpt-5.2-codex",label:"GPT-5.2 Codex — Frontier agentic coding model"},{value:"gpt-5.3-codex",label:"GPT-5.3 Codex — Latest frontier agentic coding model"},{value:"gpt-5.3-codex-spark",label:"GPT-5.3 Codex Spark — Ultra-fast coding model"},{value:"gpt-5.1-codex-max",label:"GPT-5.1 Codex Max — Deep and fast reasoning"},{value:"gpt-5.2",label:"GPT-5.2 — Frontier model, knowledge & reasoning"},{value:"gpt-5.1-codex-mini",label:"GPT-5.1 Codex Mini — Cheaper, faster"}],gemini:[{value:"gemini-3-pro-preview",label:"Gemini 3 Pro Preview"},{value:"gemini-2.5-pro",label:"Gemini 2.5 Pro"},{value:"gemini-2.5-flash",label:"Gemini 2.5 Flash"},{value:"gemini-2.5-flash-lite",label:"Gemini 2.5 Flash Lite"}]},tx=[{id:"claude",name:"Claude",command:"claude",description:"Claude Code CLI agent",icon:"\uD83E\uDD16",providerId:"anthropic",supportsModelSelection:!0},{id:"codex",name:"Codex",command:"codex",description:"OpenAI Codex agent",icon:"⚡",providerId:"codex",supportsModelSelection:!0},{id:"gemini",name:"Gemini",command:"gemini",description:"Google Gemini CLI agent",icon:"\uD83D\uDC8E",providerId:"google",supportsModelSelection:!0},{id:"opencode",name:"OpenCode",command:"opencode",description:"OpenCode AI agent",icon:"\uD83D\uDD37",providerId:"opencode",comingSoon:!0},{id:"droid",name:"Droid",command:"droid",description:"Factory Droid agent",icon:"\uD83E\uDD16",providerId:"droid",comingSoon:!0},{id:"cursor",name:"Cursor",command:"cursor",description:"Cursor AI agent",icon:"\uD83D\uDCDD",providerId:"cursor",supportsModelSelection:!0},{id:"custom",name:"Custom",command:"",description:"Custom command",icon:"\uD83D\uDD27",providerId:null}];function tm(e){var t,n,a,l,i,o,d,u,x,m,h,p,g,f,b,v,y,j,w,N,k,C,S,M;let{isOpen:L,onClose:D,onSpawn:A,existingAgents:E,isSpawning:T=!1,error:W,workspaceId:P,agentDefaults:I,repos:B,activeRepoId:_,connectedProviders:R,modelOptions:F}=e,{features:U}=(0,tc.u0)(),O=U.workspaces,H=O&&!!(null==B?void 0:B.length),z=null!==(m=null!==(x=null==F?void 0:F.claude)&&void 0!==x?x:tu.claude)&&void 0!==m?m:td,G=null!==(p=null!==(h=null==F?void 0:F.cursor)&&void 0!==h?h:tu.cursor)&&void 0!==p?p:td,V=null!==(f=null!==(g=null==F?void 0:F.codex)&&void 0!==g?g:tu.codex)&&void 0!==f?f:td,Z=null!==(v=null!==(b=null==F?void 0:F.gemini)&&void 0!==b?b:tu.gemini)&&void 0!==v?v:td,[K,q]=(0,s.useState)(tx[0]),[J,$]=(0,s.useState)(""),[Y,X]=(0,s.useState)(""),[Q,ee]=(0,s.useState)(null!==(j=null!==(y=null==I?void 0:null===(t=I.defaultModels)||void 0===t?void 0:t.claude)&&void 0!==y?y:null===(n=z[0])||void 0===n?void 0:n.value)&&void 0!==j?j:""),[et,en]=(0,s.useState)(null!==(N=null!==(w=null==I?void 0:null===(a=I.defaultModels)||void 0===a?void 0:a.cursor)&&void 0!==w?w:null===(l=G[0])||void 0===l?void 0:l.value)&&void 0!==N?N:""),[er,es]=(0,s.useState)(null!==(C=null!==(k=null==I?void 0:null===(i=I.defaultModels)||void 0===i?void 0:i.codex)&&void 0!==k?k:null===(o=V[0])||void 0===o?void 0:o.value)&&void 0!==C?C:""),[ea,el]=(0,s.useState)(null!==(M=null!==(S=null==I?void 0:null===(d=I.defaultModels)||void 0===d?void 0:d.gemini)&&void 0!==S?S:null===(u=Z[0])||void 0===u?void 0:u.value)&&void 0!==M?M:""),[ei,eo]=(0,s.useState)(""),[ec,ed]=(0,s.useState)(_),[eu,ex]=(0,s.useState)(""),[em,eh]=(0,s.useState)(!1),[ep,eg]=(0,s.useState)(!1),[ef,eb]=(0,s.useState)(""),[ev,ey]=(0,s.useState)(""),[ej,ew]=(0,s.useState)(["EXPLICIT_ASK"]),[eN,ek]=(0,s.useState)(null),eC=(0,s.useRef)(null),eS=(0,s.useMemo)(()=>"custom"===K.id?Y:"claude"===K.id?"".concat(K.command," --model ").concat(Q):"cursor"===K.id?"".concat(K.command," --model ").concat(et):"codex"===K.id?"".concat(K.command," --model ").concat(er):"gemini"===K.id?"".concat(K.command," --model ").concat(ea):K.command,[K,Y,Q,et,er,ea]),eM=(0,s.useMemo)(()=>(function(e){let t=e.trim().split(" ")[0].toLowerCase();return t.startsWith("claude")||"codex"===t||"opencode"===t||"gemini"===t||"droid"===t||"cursor"===t?"subagent":"process"})(eS),[eS]),eL=(0,s.useCallback)(()=>{let e="claude"===K.id?"claude":K.id,t=1;for(;E.includes("".concat(e,"-").concat(t));)t++;return"".concat(e,"-").concat(t)},[K,E]);(0,s.useEffect)(()=>{if(L){var e,t,n,r,s,a,l,i,o,c,d,u,x,m,h,p,g,f,b;let v=e=>(!e.comingSoon||!O)&&(!R||!e.providerId||!!R.includes(e.providerId)),y=null==I?void 0:I.defaultCliType;q(y?null!==(c=null!==(o=tx.find(e=>e.id===y&&v(e)))&&void 0!==o?o:tx.find(e=>v(e)))&&void 0!==c?c:tx[0]:null!==(d=tx.find(e=>v(e)))&&void 0!==d?d:tx[0]),$(""),X(""),ee(null!==(x=null!==(u=null==I?void 0:null===(e=I.defaultModels)||void 0===e?void 0:e.claude)&&void 0!==u?u:null===(t=z[0])||void 0===t?void 0:t.value)&&void 0!==x?x:""),en(null!==(h=null!==(m=null==I?void 0:null===(n=I.defaultModels)||void 0===n?void 0:n.cursor)&&void 0!==m?m:null===(r=G[0])||void 0===r?void 0:r.value)&&void 0!==h?h:""),es(null!==(g=null!==(p=null==I?void 0:null===(s=I.defaultModels)||void 0===s?void 0:s.codex)&&void 0!==p?p:null===(a=V[0])||void 0===a?void 0:a.value)&&void 0!==g?g:""),el(null!==(b=null!==(f=null==I?void 0:null===(l=I.defaultModels)||void 0===l?void 0:l.gemini)&&void 0!==f?f:null===(i=Z[0])||void 0===i?void 0:i.value)&&void 0!==b?b:""),eo(""),ed(_),ex(""),eh(!1),eg(!1),eb(""),ey(""),ew(["EXPLICIT_ASK"]),ek(null),setTimeout(()=>{var e;return null===(e=eC.current)||void 0===e?void 0:e.focus()},100)}},[L,I,_,B,R,O,z,G,V,Z]);let eD=(0,s.useCallback)(e=>e.trim()?/^[a-zA-Z][a-zA-Z0-9-]*$/.test(e)?E.includes(e)?"An agent with this name already exists":null:"Name must start with a letter and contain only letters, numbers, and hyphens":"Name is required",[E]),eA=async e=>{let t;e.preventDefault();let n=J.trim()||eL(),r=eD(n);if(r){ek(r);return}if(!eS.trim()){ek("Command is required");return}if(ep&&!ef){ek("Please select an agent to shadow");return}if(ek(null),H&&ec){if("__all__"===ec)t=void 0;else{let e=B.find(e=>e.id===ec);e&&(t=e.githubFullName.split("/").pop())}}else t=ei.trim()||void 0;await A({name:n,command:eS.trim(),cwd:t,team:eu.trim()||void 0,shadowMode:eM,shadowOf:ep?ef:void 0,shadowAgent:ev.trim()||void 0,shadowTriggers:ep?ej:void 0,shadowSpeakOn:ep?ej:void 0,continueFrom:em?n:void 0})&&D()};if(!L)return null;let eE=J?(0,c.GW)(J):(0,c.GW)(eL()),eT=W||eN;return(0,r.jsx)("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[1000] animate-fade-in",onClick:D,children:(0,r.jsxs)("div",{className:"relative bg-bg-primary border border-border rounded-xl w-[480px] max-w-[90vw] max-h-[90vh] overflow-y-auto shadow-modal animate-slide-up",onClick:e=>e.stopPropagation(),onKeyDown:e=>{"Escape"===e.key&&(e.preventDefault(),D())},children:[T&&(0,r.jsx)(tb,{agentName:J.trim()||eL(),colors:eE}),(0,r.jsxs)("div",{className:"flex items-center justify-between p-5 border-b border-border",children:[(0,r.jsx)("h2",{className:"m-0 text-lg font-semibold text-text-primary",children:"Spawn New Agent"}),(0,r.jsx)("button",{className:"flex items-center justify-center w-8 h-8 bg-transparent border-none rounded-md text-text-muted cursor-pointer transition-all duration-150 hover:bg-bg-hover hover:text-text-primary",onClick:D,"aria-label":"Close",children:(0,r.jsx)(th,{})})]}),(0,r.jsxs)("form",{onSubmit:eA,className:"p-6",children:[R&&0===R.length&&(0,r.jsxs)("div",{className:"mb-5 p-4 rounded-lg border border-red-400/30 bg-red-400/10",children:[(0,r.jsx)("p",{className:"text-sm text-red-400 font-medium mb-1",children:"No AI providers connected"}),(0,r.jsxs)("p",{className:"text-xs text-text-muted",children:["Connect an AI provider in your"," ",(0,r.jsx)("a",{href:P?"/app?workspace=".concat(P,"&tab=providers"):"/providers",className:"text-accent underline",children:"workspace settings"})," ","to spawn agents."]})]}),(0,r.jsxs)("div",{className:"mb-5",children:[(0,r.jsx)("label",{className:"block text-sm font-semibold text-text-primary mb-2",children:"Agent Type"}),(0,r.jsx)("div",{className:"grid grid-cols-3 gap-2",children:tx.map(e=>{let t=e.comingSoon&&O,n=!!R&&!!e.providerId&&!R.includes(e.providerId),s=t||n;return(0,r.jsxs)("button",{type:"button",disabled:s,className:"\n flex flex-col items-center gap-1 py-3 px-2 border-2 rounded-lg font-sans transition-all duration-150 relative\n ".concat(s?"opacity-50 cursor-not-allowed bg-bg-hover border-transparent":K.id===e.id?"bg-accent/10 border-accent cursor-pointer":"bg-bg-hover border-transparent hover:bg-bg-active cursor-pointer","\n "),onClick:()=>!s&&q(e),children:[t&&(0,r.jsx)("span",{className:"absolute top-1 right-1 px-1.5 py-0.5 bg-amber-400/20 text-amber-400 text-[10px] font-medium rounded",children:"Soon"}),n&&!t&&(0,r.jsx)("span",{className:"absolute top-1 right-1 px-1.5 py-0.5 bg-red-400/20 text-red-400 text-[10px] font-medium rounded",children:"Not Connected"}),(0,r.jsx)("span",{className:"text-2xl ".concat(s?"grayscale":""),children:e.icon}),(0,r.jsx)("span",{className:"text-sm font-semibold text-text-primary",children:e.name}),(0,r.jsx)("span",{className:"text-xs text-text-muted text-center",children:e.description})]},e.id)})})]}),"claude"===K.id&&(0,r.jsxs)("div",{className:"mb-5",children:[(0,r.jsx)("label",{className:"block text-sm font-semibold text-text-primary mb-2",htmlFor:"claude-model",children:"Model"}),(0,r.jsx)("select",{id:"claude-model",className:"w-full py-2.5 px-3.5 border border-border rounded-md text-sm font-sans outline-none bg-bg-primary text-text-primary transition-colors duration-150 focus:border-accent disabled:bg-bg-hover disabled:text-text-muted",value:Q,onChange:e=>ee(e.target.value),disabled:T,children:z.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label},e.value))})]}),"cursor"===K.id&&(0,r.jsxs)("div",{className:"mb-5",children:[(0,r.jsx)("label",{className:"block text-sm font-semibold text-text-primary mb-2",htmlFor:"cursor-model",children:"Model"}),(0,r.jsx)("select",{id:"cursor-model",className:"w-full py-2.5 px-3.5 border border-border rounded-md text-sm font-sans outline-none bg-bg-primary text-text-primary transition-colors duration-150 focus:border-accent disabled:bg-bg-hover disabled:text-text-muted",value:et,onChange:e=>en(e.target.value),disabled:T,children:G.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label},e.value))})]}),"codex"===K.id&&(0,r.jsxs)("div",{className:"mb-5",children:[(0,r.jsx)("label",{className:"block text-sm font-semibold text-text-primary mb-2",htmlFor:"codex-model",children:"Model"}),(0,r.jsx)("select",{id:"codex-model",className:"w-full py-2.5 px-3.5 border border-border rounded-md text-sm font-sans outline-none bg-bg-primary text-text-primary transition-colors duration-150 focus:border-accent disabled:bg-bg-hover disabled:text-text-muted",value:er,onChange:e=>es(e.target.value),disabled:T,children:V.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label},e.value))})]}),"gemini"===K.id&&(0,r.jsxs)("div",{className:"mb-5",children:[(0,r.jsx)("label",{className:"block text-sm font-semibold text-text-primary mb-2",htmlFor:"gemini-model",children:"Model"}),(0,r.jsx)("select",{id:"gemini-model",className:"w-full py-2.5 px-3.5 border border-border rounded-md text-sm font-sans outline-none bg-bg-primary text-text-primary transition-colors duration-150 focus:border-accent disabled:bg-bg-hover disabled:text-text-muted",value:ea,onChange:e=>el(e.target.value),disabled:T,children:Z.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label},e.value))})]}),(0,r.jsxs)("div",{className:"mb-5",children:[(0,r.jsx)("label",{className:"block text-sm font-semibold text-text-primary mb-2",htmlFor:"agent-name",children:"Agent Name"}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("div",{className:"shrink-0 w-10 h-10 rounded-lg flex items-center justify-center text-sm font-semibold",style:{backgroundColor:eE.primary,color:eE.text},children:(0,c.hP)(J||eL())}),(0,r.jsx)("input",{ref:eC,id:"agent-name",type:"text",className:"flex-1 py-2.5 px-3.5 border border-border rounded-md text-sm font-sans outline-none bg-transparent text-text-primary transition-colors duration-150 focus:border-accent disabled:bg-bg-hover disabled:text-text-muted placeholder:text-text-muted",placeholder:eL(),value:J,onChange:e=>{$(e.target.value),ek(null)},disabled:T})]})]}),(0,r.jsxs)("div",{className:"mb-5",children:[(0,r.jsxs)("label",{className:"block text-sm font-semibold text-text-primary mb-2",htmlFor:"agent-team",children:["Team ",(0,r.jsx)("span",{className:"font-normal text-text-muted",children:"(optional)"})]}),(0,r.jsx)("input",{id:"agent-team",type:"text",className:"w-full py-2.5 px-3.5 border border-border rounded-md text-sm font-sans outline-none bg-transparent text-text-primary transition-colors duration-150 focus:border-accent disabled:bg-bg-hover disabled:text-text-muted placeholder:text-text-muted",placeholder:"e.g., frontend, backend, infra",value:eu,onChange:e=>ex(e.target.value),disabled:T})]}),"custom"===K.id&&(0,r.jsxs)("div",{className:"mb-5",children:[(0,r.jsx)("label",{className:"block text-sm font-semibold text-text-primary mb-2",htmlFor:"agent-command",children:"Command"}),(0,r.jsx)("input",{id:"agent-command",type:"text",className:"w-full py-2.5 px-3.5 border border-border rounded-md text-sm font-sans outline-none bg-transparent text-text-primary transition-colors duration-150 focus:border-accent disabled:bg-bg-hover disabled:text-text-muted placeholder:text-text-muted",placeholder:"e.g., python agent.py",value:Y,onChange:e=>X(e.target.value),disabled:T})]}),H?(0,r.jsxs)("div",{className:"mb-5",children:[(0,r.jsx)("label",{className:"block text-sm font-semibold text-text-primary mb-2",htmlFor:"agent-repo",children:"Repository"}),(0,r.jsxs)("select",{id:"agent-repo",className:"w-full py-2.5 px-3.5 border border-border rounded-md text-sm font-sans outline-none bg-transparent text-text-primary transition-colors duration-150 focus:border-accent disabled:bg-bg-hover disabled:text-text-muted",value:ec||"",onChange:e=>ed(e.target.value),disabled:T,children:[B.length>1&&(0,r.jsx)("option",{value:"__all__",children:"All Repositories (Coordinator)"}),B.map(e=>(0,r.jsx)("option",{value:e.id,children:e.githubFullName},e.id))]}),"__all__"===ec&&(0,r.jsx)("p",{className:"mt-1.5 text-xs text-accent-purple",children:"Agent will have access to all repositories in this workspace"})]}):(0,r.jsxs)("div",{className:"mb-5",children:[(0,r.jsxs)("label",{className:"block text-sm font-semibold text-text-primary mb-2",htmlFor:"agent-cwd",children:["Working Directory ",(0,r.jsx)("span",{className:"font-normal text-text-muted",children:"(optional)"})]}),(0,r.jsx)("input",{id:"agent-cwd",type:"text",className:"w-full py-2.5 px-3.5 border border-border rounded-md text-sm font-sans outline-none bg-transparent text-text-primary transition-colors duration-150 focus:border-accent disabled:bg-bg-hover disabled:text-text-muted placeholder:text-text-muted",placeholder:"Current directory",value:ei,onChange:e=>eo(e.target.value),disabled:T})]}),(0,r.jsx)("div",{className:"mb-5 p-4 border border-border rounded-lg bg-bg-hover/50",children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-semibold text-text-primary",children:"Resume Previous Session"}),(0,r.jsx)("span",{className:"text-xs text-text-muted",children:"Inject context from this agent's last session"})]}),(0,r.jsx)("button",{type:"button",className:"\n relative w-11 h-6 rounded-full transition-colors duration-200\n ".concat(em?"bg-accent":"bg-bg-active","\n "),onClick:()=>eh(!em),disabled:T,"aria-pressed":em,children:(0,r.jsx)("span",{className:"\n absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full transition-transform duration-200 shadow-sm\n ".concat(em?"translate-x-5":"translate-x-0","\n ")})})]})}),(0,r.jsxs)("div",{className:"mb-5 p-4 border border-border rounded-lg bg-bg-hover/50",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-semibold text-text-primary",children:"Shadow Mode"}),(0,r.jsxs)("span",{className:"text-xs text-text-muted",children:["Shadow execution: ","subagent"===eM?"Subagent (in-process)":"Process (separate)"]})]}),(0,r.jsx)("button",{type:"button",className:"\n relative w-11 h-6 rounded-full transition-colors duration-200\n ".concat(ep?"bg-accent":"bg-bg-active","\n "),onClick:()=>eg(!ep),disabled:T,"aria-pressed":ep,children:(0,r.jsx)("span",{className:"\n absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full transition-transform duration-200 shadow-sm\n ".concat(ep?"translate-x-5":"translate-x-0","\n ")})})]}),ep&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"mb-4",children:[(0,r.jsx)("label",{className:"block text-sm font-medium text-text-secondary mb-2",htmlFor:"shadow-of",children:"Shadow Agent"}),(0,r.jsxs)("select",{id:"shadow-of",className:"w-full py-2.5 px-3.5 border border-border rounded-md text-sm font-sans outline-none bg-bg-primary text-text-primary transition-colors duration-150 focus:border-accent disabled:bg-bg-hover disabled:text-text-muted",value:ef,onChange:e=>eb(e.target.value),disabled:T,children:[(0,r.jsx)("option",{value:"",children:"Select an agent to shadow..."}),E.map(e=>(0,r.jsx)("option",{value:e,children:e},e))]})]}),(0,r.jsxs)("div",{className:"mb-4",children:[(0,r.jsxs)("label",{className:"block text-sm font-medium text-text-secondary mb-2",htmlFor:"shadow-agent",children:["Shadow Agent Profile ",(0,r.jsx)("span",{className:"font-normal text-text-muted",children:"(optional)"})]}),(0,r.jsx)("input",{id:"shadow-agent",type:"text",className:"w-full py-2.5 px-3.5 border border-border rounded-md text-sm font-sans outline-none bg-bg-primary text-text-primary transition-colors duration-150 focus:border-accent disabled:bg-bg-hover disabled:text-text-muted placeholder:text-text-muted",placeholder:"e.g., shadow-reviewer",value:ev,onChange:e=>ey(e.target.value),disabled:T})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium text-text-secondary mb-2",children:"Speak When"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2",children:[{value:"EXPLICIT_ASK",label:"Explicit Ask",description:"When directly asked"},{value:"SESSION_END",label:"Session End",description:"When session ends"},{value:"CODE_WRITTEN",label:"Code Written",description:"When code is written"},{value:"REVIEW_REQUEST",label:"Review Request",description:"When review requested"},{value:"ALL_MESSAGES",label:"All Messages",description:"On every message"}].map(e=>(0,r.jsx)("button",{type:"button",className:"\n py-1.5 px-3 rounded-md text-xs font-medium transition-all duration-150 border\n ".concat(ej.includes(e.value)?"bg-accent/20 border-accent text-accent":"bg-bg-primary border-border text-text-secondary hover:bg-bg-active hover:text-text-primary","\n "),onClick:()=>{ej.includes(e.value)?ew(ej.filter(t=>t!==e.value)):ew([...ej,e.value])},disabled:T,title:e.description,children:e.label},e.value))})]})]})]}),eT&&(0,r.jsxs)("div",{className:"flex items-center gap-2 p-3 bg-error/10 border border-error/30 rounded-md text-error text-sm mb-5",children:[(0,r.jsx)(tp,{}),(0,r.jsx)("span",{children:eT})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 pt-2 border-t border-border",children:[(0,r.jsx)("button",{type:"button",className:"flex items-center gap-1.5 py-2.5 px-4 border-none rounded-md text-sm font-medium cursor-pointer font-sans transition-all duration-150 bg-bg-hover text-text-secondary hover:bg-bg-active hover:text-text-primary disabled:opacity-50 disabled:cursor-not-allowed",onClick:D,disabled:T,children:"Cancel"}),(0,r.jsxs)("button",{type:"submit",className:"flex items-center gap-1.5 py-2.5 px-4 border-none rounded-md text-sm font-medium cursor-pointer font-sans transition-all duration-150 bg-accent text-white hover:bg-accent-hover disabled:opacity-50 disabled:cursor-not-allowed",disabled:T,children:[(0,r.jsx)(tg,{}),"Spawn Agent"]})]})]})]})})}function th(){return(0,r.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,r.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function tp(){return(0,r.jsxs)("svg",{className:"shrink-0",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,r.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}function tg(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z"}),(0,r.jsx)("path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z"}),(0,r.jsx)("path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0"}),(0,r.jsx)("path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5"})]})}let tf=["Initializing agent environment...","Loading model configuration...","Establishing communication channel...","Preparing workspace...","Almost ready..."];function tb(e){let{agentName:t,colors:n}=e,[a,l]=(0,s.useState)(0),[i,o]=(0,s.useState)("");(0,s.useEffect)(()=>{let e=setInterval(()=>{l(e=>(e+1)%tf.length)},2400);return()=>clearInterval(e)},[]),(0,s.useEffect)(()=>{let e=setInterval(()=>{o(e=>e.length>=3?"":e+".")},500);return()=>clearInterval(e)},[]);let d=(0,c.hP)(t);return(0,r.jsxs)("div",{className:"absolute inset-0 bg-bg-primary/95 backdrop-blur-sm flex flex-col items-center justify-center z-10 rounded-xl",children:[(0,r.jsxs)("div",{className:"relative mb-6",children:[(0,r.jsx)("div",{className:"absolute inset-0 rounded-full animate-ping opacity-20",style:{backgroundColor:n.primary}}),(0,r.jsx)("div",{className:"relative w-16 h-16 rounded-full flex items-center justify-center text-xl font-bold animate-pulse",style:{backgroundColor:n.primary,color:n.text},children:d})]}),(0,r.jsxs)("div",{className:"text-lg font-semibold text-text-primary mb-2",children:["Spawning ",t,i]}),(0,r.jsx)("div",{className:"text-sm text-text-muted transition-opacity duration-300 mb-6",style:{animation:"fadeInUp 0.3s ease-out"},children:tf[a]},a),(0,r.jsx)("div",{className:"w-48 h-1 bg-bg-hover rounded-full overflow-hidden",children:(0,r.jsx)("div",{className:"h-full rounded-full",style:{backgroundColor:n.primary,animation:"spawningProgress 2.4s ease-in-out infinite"}})}),(0,r.jsx)("style",{children:"\n @keyframes fadeInUp {\n from { opacity: 0; transform: translateY(4px); }\n to { opacity: 1; transform: translateY(0); }\n }\n @keyframes spawningProgress {\n 0% { width: 0%; margin-left: 0%; }\n 50% { width: 60%; margin-left: 20%; }\n 100% { width: 0%; margin-left: 100%; }\n }\n "})]})}function tv(e){let{isOpen:t,onClose:n,onSend:a,agents:l,isSending:i=!1,error:o,preselectedAgent:d}=e,[u,x]=(0,s.useState)(""),[m,h]=(0,s.useState)(""),[p,g]=(0,s.useState)(""),[f,b]=(0,s.useState)(null),v=(0,s.useRef)(null),y=(0,s.useRef)(null),j=(0,s.useMemo)(()=>{if(!p.trim())return l;let e=p.toLowerCase();return l.filter(t=>{var n,r;return t.name.toLowerCase().includes(e)||(null===(n=t.role)||void 0===n?void 0:n.toLowerCase().includes(e))||(null===(r=t.team)||void 0===r?void 0:r.toLowerCase().includes(e))})},[l,p]);(0,s.useEffect)(()=>{t&&(x(d||""),h(""),g(""),b(null),setTimeout(()=>{var e,t;d?null===(e=v.current)||void 0===e||e.focus():null===(t=y.current)||void 0===t||t.focus()},100))},[t,d]);let w=async e=>{if(e.preventDefault(),!u){b("Please select an agent");return}if(!m.trim()){b("Please enter a message");return}b(null),await a(u,m.trim())&&n()},N=(0,s.useCallback)(e=>{x(e),b(null),setTimeout(()=>{var e;return null===(e=v.current)||void 0===e?void 0:e.focus()},50)},[]);if(!t)return null;let k=o||f,C=l.find(e=>e.name===u),S=C?(0,c.GW)(C.name):null;return(0,r.jsx)("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[1000] animate-fade-in",onClick:n,children:(0,r.jsxs)("div",{className:"bg-bg-primary border border-border rounded-xl w-[520px] max-w-[90vw] max-h-[85vh] overflow-hidden shadow-modal animate-slide-up flex flex-col",onClick:e=>e.stopPropagation(),onKeyDown:e=>{"Escape"===e.key&&(e.preventDefault(),n())},children:[(0,r.jsxs)("div",{className:"flex items-center justify-between p-5 border-b border-border shrink-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("div",{className:"w-9 h-9 rounded-lg bg-accent/10 flex items-center justify-center",children:(0,r.jsx)(ty,{})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"m-0 text-lg font-semibold text-text-primary",children:"New Conversation"}),(0,r.jsx)("p",{className:"m-0 text-xs text-text-muted",children:"Start a direct message with an agent"})]})]}),(0,r.jsx)("button",{className:"flex items-center justify-center w-8 h-8 bg-transparent border-none rounded-md text-text-muted cursor-pointer transition-all duration-150 hover:bg-bg-hover hover:text-text-primary",onClick:n,"aria-label":"Close",children:(0,r.jsx)(tj,{})})]}),(0,r.jsxs)("form",{onSubmit:w,className:"flex flex-col flex-1 overflow-hidden",children:[(0,r.jsxs)("div",{className:"p-5 border-b border-border",children:[(0,r.jsx)("label",{className:"block text-sm font-semibold text-text-primary mb-2",children:"To"}),u?(0,r.jsxs)("div",{className:"flex items-center gap-3 p-3 bg-bg-hover rounded-lg",children:[(0,r.jsx)("div",{className:"shrink-0 w-10 h-10 rounded-lg flex items-center justify-center text-sm font-semibold",style:{backgroundColor:null==S?void 0:S.primary,color:null==S?void 0:S.text},children:(0,c.hP)(u)}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("div",{className:"font-semibold text-text-primary",children:u}),(null==C?void 0:C.role)&&(0,r.jsx)("div",{className:"text-xs text-text-muted truncate",children:C.role})]}),(0,r.jsx)("button",{type:"button",className:"flex items-center justify-center w-8 h-8 bg-bg-active border-none rounded-md text-text-muted cursor-pointer transition-all duration-150 hover:bg-bg-tertiary hover:text-text-primary",onClick:()=>{x(""),setTimeout(()=>{var e;return null===(e=y.current)||void 0===e?void 0:e.focus()},50)},"aria-label":"Change agent",children:(0,r.jsx)(tN,{})})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"relative mb-3",children:[(0,r.jsx)("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-text-muted",children:(0,r.jsx)(tw,{})}),(0,r.jsx)("input",{ref:y,type:"text",className:"w-full py-2.5 pl-10 pr-3.5 border border-border rounded-md text-sm font-sans outline-none bg-transparent text-text-primary transition-colors duration-150 focus:border-accent placeholder:text-text-muted",placeholder:"Search agents...",value:p,onChange:e=>g(e.target.value)})]}),(0,r.jsx)("div",{className:"max-h-[200px] overflow-y-auto border border-border rounded-lg",children:0===j.length?(0,r.jsx)("div",{className:"p-4 text-center text-text-muted text-sm",children:p?"No agents found":"No agents available"}):(0,r.jsxs)("div",{className:"divide-y divide-border",children:[(0,r.jsxs)("button",{type:"button",className:"w-full flex items-center gap-3 p-3 bg-transparent border-none cursor-pointer transition-colors duration-150 hover:bg-bg-hover text-left",onClick:()=>N("*"),children:[(0,r.jsx)("div",{className:"shrink-0 w-9 h-9 rounded-lg bg-warning/20 flex items-center justify-center",children:(0,r.jsx)(tk,{})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("div",{className:"font-semibold text-text-primary",children:"Everyone"}),(0,r.jsx)("div",{className:"text-xs text-text-muted",children:"Broadcast to all agents"})]})]}),j.map(e=>{let t=(0,c.GW)(e.name);return(0,r.jsxs)("button",{type:"button",className:"w-full flex items-center gap-3 p-3 bg-transparent border-none cursor-pointer transition-colors duration-150 hover:bg-bg-hover text-left",onClick:()=>N(e.name),children:[(0,r.jsx)("div",{className:"shrink-0 w-9 h-9 rounded-lg flex items-center justify-center text-xs font-semibold",style:{backgroundColor:t.primary,color:t.text},children:(0,c.hP)(e.name)}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"font-semibold text-text-primary",children:e.name}),(0,r.jsx)("span",{className:"w-2 h-2 rounded-full ".concat("online"===e.status?"bg-success":"bg-text-muted")})]}),(e.role||e.team)&&(0,r.jsxs)("div",{className:"text-xs text-text-muted truncate",children:[e.role,e.role&&e.team&&" - ",e.team]})]})]},e.name)})]})})]})]}),(0,r.jsxs)("div",{className:"p-5 flex-1 overflow-hidden flex flex-col",children:[(0,r.jsx)("label",{className:"block text-sm font-semibold text-text-primary mb-2",htmlFor:"message",children:"Message"}),(0,r.jsx)("textarea",{ref:v,id:"message",className:"flex-1 min-h-[120px] w-full py-3 px-3.5 border border-border rounded-md text-sm font-sans outline-none bg-transparent text-text-primary transition-colors duration-150 focus:border-accent resize-none placeholder:text-text-muted",placeholder:"*"===u?"Write a message to all agents...":u?"Write a message to ".concat(u,"..."):"Select an agent first...",value:m,onChange:e=>{h(e.target.value),b(null)},disabled:i||!u})]}),k&&(0,r.jsxs)("div",{className:"flex items-center gap-2 mx-5 mb-4 p-3 bg-error/10 border border-error/30 rounded-md text-error text-sm",children:[(0,r.jsx)(tS,{}),(0,r.jsx)("span",{children:k})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 p-5 pt-0 border-t border-border",children:[(0,r.jsx)("button",{type:"button",className:"flex items-center gap-1.5 py-2.5 px-4 border-none rounded-md text-sm font-medium cursor-pointer font-sans transition-all duration-150 bg-bg-hover text-text-secondary hover:bg-bg-active hover:text-text-primary disabled:opacity-50 disabled:cursor-not-allowed",onClick:n,disabled:i,children:"Cancel"}),(0,r.jsx)("button",{type:"submit",className:"flex items-center gap-1.5 py-2.5 px-4 border-none rounded-md text-sm font-medium cursor-pointer font-sans transition-all duration-150 bg-accent text-white hover:bg-accent-hover disabled:opacity-50 disabled:cursor-not-allowed",disabled:i||!u||!m.trim(),children:i?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(tM,{}),"Sending..."]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(tC,{}),"Send Message"]})})]})]})]})})}function ty(){return(0,r.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-accent",children:[(0,r.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"}),(0,r.jsx)("line",{x1:"9",y1:"10",x2:"15",y2:"10"})]})}function tj(){return(0,r.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,r.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function tw(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,r.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function tN(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("polyline",{points:"1 4 1 10 7 10"}),(0,r.jsx)("path",{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"})]})}function tk(){return(0,r.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-warning",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"2"}),(0,r.jsx)("path",{d:"M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14"})]})}function tC(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),(0,r.jsx)("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})}function tS(){return(0,r.jsxs)("svg",{className:"shrink-0",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,r.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}function tM(){return(0,r.jsx)("svg",{className:"animate-spin",width:"16",height:"16",viewBox:"0 0 24 24",children:(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}function tL(e,t){return"workspace"===e?t.workspaces:"team"===e?t.teams:"billing"!==e||t.billing}let tD=[];function tA(e){var t,n,a,l,i,o,c,d,u,x,m,h,p,g,f,b,v,y,j,w,N,k,C,S,M,L,D,A,E,T,W,P;let{initialTab:I="dashboard",onClose:B,settings:_,onUpdateSettings:R,activeWorkspaceId:F,modelOptions:U}=e,{features:O,api:H,settingsSlots:z}=(0,tc.u0)(),G=null!==(v=null!==(b=null==U?void 0:U.claude)&&void 0!==b?b:tu.claude)&&void 0!==v?v:tD,V=null!==(j=null!==(y=null==U?void 0:U.cursor)&&void 0!==y?y:tu.cursor)&&void 0!==j?j:tD,Z=null!==(N=null!==(w=null==U?void 0:U.codex)&&void 0!==w?w:tu.codex)&&void 0!==N?N:tD,K=null!==(C=null!==(k=null==U?void 0:U.gemini)&&void 0!==k?k:tu.gemini)&&void 0!==C?C:tD,[q,J]=(0,s.useState)(()=>tL(I,O)?I:"dashboard"),[$,Y]=(0,s.useState)([]),[X,Q]=(0,s.useState)(null!=F?F:null),[ee,et]=(0,s.useState)(!0);(0,s.useEffect)(()=>{tL(q,O)||J("dashboard")},[q,O.billing,O.teams,O.workspaces]),(0,s.useEffect)(()=>{F&&Q(F)},[F]),(0,s.useEffect)(()=>{if(!O.workspaces||!H){et(!1),Y([]);return}let e=!1;return async function(){et(!0);let t=await H.getWorkspaceSummary();if(!e){if(t.success&&t.data.workspaces.length>0){let e=t.data.workspaces.map(e=>({id:e.id,name:e.name,status:e.status}));Y(e),Q(t=>null!=t?t:e[0].id)}else Y([]);et(!1)}}(),()=>{e=!0}},[H,O.workspaces]);let en=(0,s.useCallback)(e=>{R(e)},[R]),er=(0,s.useCallback)(e=>{en(t=>{let n={...t.notifications,...e};return{...t,notifications:{...n,enabled:n.sound||n.desktop||n.mentionsOnly}}})},[en]),es=[{id:"dashboard",label:"Dashboard",icon:(0,r.jsx)(t_,{})},{id:"workspace",label:"Workspace",icon:(0,r.jsx)(tR,{})},{id:"team",label:"Team",icon:(0,r.jsx)(tF,{})},{id:"billing",label:"Billing",icon:(0,r.jsx)(tU,{})}].filter(e=>tL(e.id,O)),ea=null==z?void 0:z.BillingPanel,el=null==z?void 0:z.TeamPanel,ei=null==z?void 0:z.WorkspacePanel;return(0,r.jsxs)("div",{className:"fixed inset-0 z-[1100] bg-bg-deep",children:[(0,r.jsxs)("div",{className:"absolute inset-0 opacity-30",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top_right,_rgba(0,217,255,0.08)_0%,_transparent_50%)]"}),(0,r.jsx)("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_bottom_left,_rgba(168,85,247,0.06)_0%,_transparent_50%)]"})]}),(0,r.jsxs)("div",{className:"relative h-full flex flex-col",children:[(0,r.jsxs)("header",{className:"h-14 md:h-16 px-4 md:px-6 flex items-center justify-between border-b border-border-subtle bg-bg-secondary/80 backdrop-blur-sm",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 md:gap-4",children:[(0,r.jsx)("div",{className:"w-8 h-8 md:w-10 md:h-10 rounded-xl bg-gradient-to-br from-accent-cyan to-accent-purple flex items-center justify-center shadow-lg shadow-accent-cyan/20",children:(0,r.jsx)(tB,{className:"text-white w-4 h-4 md:w-[18px] md:h-[18px]"})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"text-base md:text-lg font-bold text-text-primary tracking-tight",children:"Settings"}),(0,r.jsx)("p",{className:"text-[10px] md:text-xs text-text-muted hidden sm:block",children:"Manage your workspace and preferences"})]})]}),(0,r.jsx)("button",{onClick:B,className:"w-9 h-9 md:w-10 md:h-10 rounded-lg bg-bg-tertiary border border-border-subtle flex items-center justify-center text-text-muted hover:text-text-primary hover:bg-bg-hover transition-colors",children:(0,r.jsx)(tO,{})})]}),(0,r.jsx)("div",{className:"border-b border-border-subtle bg-bg-secondary/50",children:(0,r.jsx)("div",{className:"flex sm:justify-center overflow-x-auto scrollbar-hide scroll-smooth snap-x snap-mandatory touch-pan-x",style:{WebkitOverflowScrolling:"touch"},children:es.map(e=>(0,r.jsxs)("button",{onClick:()=>J(e.id),className:"flex items-center gap-2 px-4 sm:px-6 py-3 text-sm font-medium transition-all whitespace-nowrap shrink-0 snap-start ".concat(q===e.id?"text-accent-cyan border-b-2 border-accent-cyan bg-accent-cyan/5":"text-text-muted border-b-2 border-transparent hover:text-text-secondary"),children:[(0,r.jsx)("span",{className:q===e.id?"text-accent-cyan":"text-text-muted",children:e.icon}),e.label]},e.id))})}),("workspace"===q||"team"===q)&&$.length>0&&(0,r.jsx)("div",{className:"px-4 py-2 border-b border-border-subtle bg-bg-tertiary/50",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"w-2 h-2 rounded-full shrink-0 ".concat((null===(t=$.find(e=>e.id===X))||void 0===t?void 0:t.status)==="running"?"bg-success":(null===(n=$.find(e=>e.id===X))||void 0===n?void 0:n.status)==="stopped"?"bg-amber-400":"bg-text-muted")}),1===$.length?(0,r.jsx)("span",{className:"text-sm text-text-primary",children:$[0].name}):(0,r.jsx)("select",{value:X||"",onChange:e=>Q(e.target.value),className:"flex-1 px-3 py-2 bg-bg-card border border-border-subtle rounded-lg text-sm text-text-primary focus:outline-none focus:border-accent-cyan",children:$.map(e=>(0,r.jsx)("option",{value:e.id,children:e.name},e.id))})]})}),(0,r.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,r.jsx)("main",{className:"h-full w-full overflow-y-auto",children:(0,r.jsxs)("div",{className:"w-full max-w-4xl mx-auto p-4 md:p-8",children:["dashboard"===q&&(0,r.jsxs)("div",{className:"space-y-8",children:[(0,r.jsx)(tE,{title:"Dashboard Settings",subtitle:"Customize your dashboard experience"}),(0,r.jsxs)(tT,{title:"Appearance",icon:(0,r.jsx)(tH,{}),children:[(0,r.jsx)(tW,{label:"Theme",description:"Choose your preferred color scheme",children:(0,r.jsxs)("select",{value:_.theme,onChange:e=>en(t=>({...t,theme:e.target.value})),className:"px-4 py-2 bg-bg-tertiary border border-border-subtle rounded-lg text-sm text-text-primary focus:outline-none focus:border-accent-cyan",children:[(0,r.jsx)("option",{value:"dark",children:"Dark"}),(0,r.jsx)("option",{value:"light",children:"Light"}),(0,r.jsx)("option",{value:"system",children:"System"})]})}),(0,r.jsx)(tW,{label:"Compact Mode",description:"Reduce spacing and show more content",children:(0,r.jsx)(tP,{checked:_.display.compactMode,onChange:e=>en(t=>({...t,display:{...t.display,compactMode:e}}))})}),(0,r.jsx)(tW,{label:"Show Timestamps",description:"Display timestamps on messages",children:(0,r.jsx)(tP,{checked:_.display.showTimestamps,onChange:e=>en(t=>({...t,display:{...t.display,showTimestamps:e}}))})})]}),(0,r.jsxs)(tT,{title:"Notifications",icon:(0,r.jsx)(tz,{}),children:[(0,r.jsx)(tW,{label:"Sound Effects",description:"Play sounds for new messages",children:(0,r.jsx)(tP,{checked:_.notifications.sound,onChange:e=>er({sound:e})})}),(0,r.jsx)(tW,{label:"Browser Notifications",description:"Show desktop notifications",children:(0,r.jsx)(tP,{checked:_.notifications.desktop,onChange:e=>er({desktop:e})})})]}),(0,r.jsx)(tT,{title:"Behavior",icon:(0,r.jsx)(tB,{}),children:(0,r.jsx)(tW,{label:"Auto-scroll Messages",description:"Automatically scroll to new messages",children:(0,r.jsx)(tP,{checked:_.messages.autoScroll,onChange:e=>en(t=>({...t,messages:{...t.messages,autoScroll:e}}))})})}),(0,r.jsxs)(tT,{title:"Agent Defaults",icon:(0,r.jsx)(tG,{}),children:[(0,r.jsx)(tW,{label:"Default Agent Type",description:"Pre-select an agent type when spawning",children:(0,r.jsxs)("select",{value:null!==(S=null===(a=_.agentDefaults)||void 0===a?void 0:a.defaultCliType)&&void 0!==S?S:"",onChange:e=>en(t=>({...t,agentDefaults:{...t.agentDefaults,defaultCliType:""===e.target.value?null:e.target.value}})),className:"px-4 py-2 bg-bg-tertiary border border-border-subtle rounded-lg text-sm text-text-primary focus:outline-none focus:border-accent-cyan",children:[(0,r.jsx)("option",{value:"",children:"None (show all templates)"}),(0,r.jsx)("option",{value:"claude",children:"Claude"}),(0,r.jsx)("option",{value:"codex",children:"Codex"}),(0,r.jsx)("option",{value:"gemini",children:"Gemini"}),(0,r.jsx)("option",{value:"cursor",children:"Cursor"}),(0,r.jsx)("option",{value:"custom",children:"Custom"})]})}),(0,r.jsx)(tW,{label:"Default Claude Model",description:"Default model when spawning Claude agents",children:(0,r.jsx)("select",{value:null!==(L=null!==(M=null===(i=_.agentDefaults)||void 0===i?void 0:null===(l=i.defaultModels)||void 0===l?void 0:l.claude)&&void 0!==M?M:null===(o=G[0])||void 0===o?void 0:o.value)&&void 0!==L?L:"",onChange:e=>en(t=>{var n;return{...t,agentDefaults:{...t.agentDefaults,defaultModels:{...null===(n=t.agentDefaults)||void 0===n?void 0:n.defaultModels,claude:e.target.value}}}}),className:"px-4 py-2 bg-bg-tertiary border border-border-subtle rounded-lg text-sm text-text-primary focus:outline-none focus:border-accent-cyan",children:G.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label},e.value))})}),(0,r.jsx)(tW,{label:"Default Cursor Model",description:"Default model when spawning Cursor agents",children:(0,r.jsx)("select",{value:null!==(A=null!==(D=null===(d=_.agentDefaults)||void 0===d?void 0:null===(c=d.defaultModels)||void 0===c?void 0:c.cursor)&&void 0!==D?D:null===(u=V[0])||void 0===u?void 0:u.value)&&void 0!==A?A:"",onChange:e=>en(t=>{var n;return{...t,agentDefaults:{...t.agentDefaults,defaultModels:{...null===(n=t.agentDefaults)||void 0===n?void 0:n.defaultModels,cursor:e.target.value}}}}),className:"px-4 py-2 bg-bg-tertiary border border-border-subtle rounded-lg text-sm text-text-primary focus:outline-none focus:border-accent-cyan",children:V.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label},e.value))})}),(0,r.jsx)(tW,{label:"Default Codex Model",description:"Default model when spawning Codex agents",children:(0,r.jsx)("select",{value:null!==(T=null!==(E=null===(m=_.agentDefaults)||void 0===m?void 0:null===(x=m.defaultModels)||void 0===x?void 0:x.codex)&&void 0!==E?E:null===(h=Z[0])||void 0===h?void 0:h.value)&&void 0!==T?T:"",onChange:e=>en(t=>{var n;return{...t,agentDefaults:{...t.agentDefaults,defaultModels:{...null===(n=t.agentDefaults)||void 0===n?void 0:n.defaultModels,codex:e.target.value}}}}),className:"px-4 py-2 bg-bg-tertiary border border-border-subtle rounded-lg text-sm text-text-primary focus:outline-none focus:border-accent-cyan",children:Z.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label},e.value))})}),(0,r.jsx)(tW,{label:"Default Gemini Model",description:"Default model when spawning Gemini agents",children:(0,r.jsx)("select",{value:null!==(P=null!==(W=null===(g=_.agentDefaults)||void 0===g?void 0:null===(p=g.defaultModels)||void 0===p?void 0:p.gemini)&&void 0!==W?W:null===(f=K[0])||void 0===f?void 0:f.value)&&void 0!==P?P:"",onChange:e=>en(t=>{var n;return{...t,agentDefaults:{...t.agentDefaults,defaultModels:{...null===(n=t.agentDefaults)||void 0===n?void 0:n.defaultModels,gemini:e.target.value}}}}),className:"px-4 py-2 bg-bg-tertiary border border-border-subtle rounded-lg text-sm text-text-primary focus:outline-none focus:border-accent-cyan",children:K.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label},e.value))})})]})]}),"workspace"===q&&(0,r.jsx)(r.Fragment,{children:ee?(0,r.jsxs)("div",{className:"flex items-center justify-center h-64",children:[(0,r.jsx)("div",{className:"relative",children:(0,r.jsx)("div",{className:"w-12 h-12 rounded-full border-2 border-accent-cyan/20 border-t-accent-cyan animate-spin"})}),(0,r.jsx)("span",{className:"ml-4 text-text-muted",children:"Loading workspaces..."})]}):ei?(0,r.jsx)(ei,{}):(0,r.jsx)(tI,{icon:(0,r.jsx)(tR,{}),title:"Workspace Settings Unavailable",description:"A workspace settings panel has not been provided for this mode."})}),"team"===q&&(0,r.jsx)(r.Fragment,{children:el?(0,r.jsxs)("div",{className:"space-y-8",children:[(0,r.jsx)(tE,{title:"Team Settings",subtitle:"Manage workspace members and permissions"}),(0,r.jsx)(el,{})]}):(0,r.jsx)(tI,{icon:(0,r.jsx)(tF,{}),title:"Team Settings Unavailable",description:"A team settings panel has not been provided for this mode."})}),"billing"===q&&(0,r.jsxs)("div",{className:"space-y-8",children:[(0,r.jsx)(tE,{title:"Billing & Subscription",subtitle:"Manage your plan and payment methods"}),ea?(0,r.jsx)(ea,{}):(0,r.jsx)(tI,{icon:(0,r.jsx)(tU,{}),title:"Billing Settings Unavailable",description:"A billing settings panel has not been provided for this mode."})]})]})})})]})]})}function tE(e){let{title:t,subtitle:n}=e;return(0,r.jsxs)("div",{className:"mb-6 sm:mb-8",children:[(0,r.jsx)("h2",{className:"text-xl sm:text-2xl font-bold text-text-primary",children:t}),(0,r.jsx)("p",{className:"text-sm text-text-muted mt-1",children:n})]})}function tT(e){let{title:t,icon:n,children:s}=e;return(0,r.jsxs)("div",{className:"bg-bg-tertiary rounded-xl border border-border-subtle overflow-hidden",children:[(0,r.jsxs)("div",{className:"px-4 sm:px-6 py-3 sm:py-4 border-b border-border-subtle bg-bg-secondary/50 flex items-center gap-3",children:[(0,r.jsx)("span",{className:"text-accent-cyan",children:n}),(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-primary uppercase tracking-wide",children:t})]}),(0,r.jsx)("div",{className:"divide-y divide-border-subtle",children:s})]})}function tW(e){let{label:t,description:n,children:s}=e;return(0,r.jsxs)("div",{className:"px-4 sm:px-6 py-3 sm:py-4 flex items-center justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium text-text-primary",children:t}),(0,r.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:n})]}),s]})}function tP(e){let{checked:t,onChange:n}=e;return(0,r.jsx)("button",{onClick:()=>n(!t),className:"relative w-12 h-6 rounded-full transition-colors ".concat(t?"bg-accent-cyan":"bg-bg-hover"),children:(0,r.jsx)("span",{className:"absolute top-1 w-4 h-4 bg-white rounded-full shadow transition-transform ".concat(t?"translate-x-7":"translate-x-1")})})}function tI(e){let{icon:t,title:n,description:s,action:a}=e;return(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center h-64 text-center",children:[(0,r.jsx)("div",{className:"w-16 h-16 rounded-2xl bg-bg-tertiary flex items-center justify-center text-text-muted mb-4",children:t}),(0,r.jsx)("h3",{className:"text-lg font-semibold text-text-primary mb-2",children:n}),(0,r.jsx)("p",{className:"text-sm text-text-muted max-w-sm mb-6",children:s}),a]})}function tB(e){let{className:t=""}=e;return(0,r.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,r.jsx)("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}function t_(){return(0,r.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("rect",{x:"3",y:"3",width:"7",height:"9"}),(0,r.jsx)("rect",{x:"14",y:"3",width:"7",height:"5"}),(0,r.jsx)("rect",{x:"14",y:"12",width:"7",height:"9"}),(0,r.jsx)("rect",{x:"3",y:"16",width:"7",height:"5"})]})}function tR(){return(0,r.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function tF(){return(0,r.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),(0,r.jsx)("circle",{cx:"9",cy:"7",r:"4"}),(0,r.jsx)("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),(0,r.jsx)("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}function tU(){return(0,r.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("rect",{x:"1",y:"4",width:"22",height:"16",rx:"2",ry:"2"}),(0,r.jsx)("line",{x1:"1",y1:"10",x2:"23",y2:"10"})]})}function tO(){return(0,r.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,r.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function tH(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("circle",{cx:"13.5",cy:"6.5",r:"2.5"}),(0,r.jsx)("circle",{cx:"19",cy:"13.5",r:"2.5"}),(0,r.jsx)("circle",{cx:"6",cy:"12",r:"2.5"}),(0,r.jsx)("circle",{cx:"11",cy:"19",r:"2.5"}),(0,r.jsx)("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.555C21.965 6.012 17.461 2 12 2z"})]})}function tz(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),(0,r.jsx)("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})}function tG(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z"}),(0,r.jsx)("path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z"}),(0,r.jsx)("path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0"}),(0,r.jsx)("path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5"})]})}let tV={theme:"system",notifications:{enabled:!0,sound:!0,desktop:!1,mentionsOnly:!1},display:{compactMode:!1,showTimestamps:!0,showAvatars:!0,animationsEnabled:!0},messages:{autoScroll:!0},connection:{autoReconnect:!0,reconnectDelay:3e3,keepAliveInterval:3e4},agentDefaults:{defaultCliType:null,defaultModels:{claude:"sonnet",cursor:"opus-4.5-thinking",codex:"gpt-5.2-codex",gemini:"gemini-2.5-pro"}}};var tZ=n(5118);function tK(e){let{isOpen:t,onClose:n}=e,[a,l]=(0,s.useState)("conversations"),[i,o]=(0,s.useState)([]),[c,d]=(0,s.useState)([]),[u,x]=(0,s.useState)([]),[m,h]=(0,s.useState)(null),[p,g]=(0,s.useState)(!1),[f,b]=(0,s.useState)(null),[v,y]=(0,s.useState)(""),[j,w]=(0,s.useState)(""),[N,k]=(0,s.useState)(null);(0,s.useEffect)(()=>{t&&(async()=>{let e=await tZ.api.getHistoryStats();e.success&&e.data&&h(e.data)})()},[t]),(0,s.useEffect)(()=>{t&&(async()=>{g(!0),b(null);try{if("conversations"===a){let e=await tZ.api.getHistoryConversations();e.success&&e.data?o(e.data.conversations):b(e.error||"Failed to fetch conversations")}else if("sessions"===a){let e=await tZ.api.getHistorySessions({agent:j||void 0,limit:50});e.success&&e.data?d(e.data.sessions):b(e.error||"Failed to fetch sessions")}else if("messages"===a){let n={limit:100,order:"desc"};if(v&&(n.search=v),N){let[r,s]=N.participants,a=await tZ.api.getHistoryMessages({...n,from:r,to:s}),l=await tZ.api.getHistoryMessages({...n,from:s,to:r});if(a.success&&l.success){var e,t;let n=[...(null===(e=a.data)||void 0===e?void 0:e.messages)||[],...(null===(t=l.data)||void 0===t?void 0:t.messages)||[]].sort((e,t)=>new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime());x(n)}}else{let e=await tZ.api.getHistoryMessages(n);e.success&&e.data?x(e.data.messages):b(e.error||"Failed to fetch messages")}}}catch(e){b("Failed to load data")}finally{g(!1)}})()},[t,a,j,v,N]);let C=(0,s.useCallback)(e=>{k(e),l("messages")},[]),S=(0,s.useCallback)(()=>{k(null),l("conversations")},[]);return t?(0,r.jsx)("div",{className:"fixed inset-0 z-[1000] flex items-center justify-center bg-black/50",children:(0,r.jsxs)("div",{className:"bg-bg-primary rounded-lg shadow-xl w-[90vw] max-w-4xl h-[80vh] flex flex-col",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[(0,r.jsxs)("div",{className:"flex items-center gap-4",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold text-text-primary",children:"Conversation History"}),m&&"number"==typeof m.messageCount&&(0,r.jsxs)("div",{className:"flex gap-4 text-sm text-text-muted",children:[(0,r.jsxs)("span",{children:[m.messageCount," messages"]}),(0,r.jsxs)("span",{children:[m.sessionCount," sessions"]}),(0,r.jsxs)("span",{children:[m.uniqueAgents," agents"]})]})]}),(0,r.jsx)("button",{onClick:n,className:"p-2 text-text-muted hover:text-text-primary rounded transition-colors","aria-label":"Close",children:(0,r.jsx)(t0,{})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-4 p-4 border-b border-border",children:[(0,r.jsxs)("div",{className:"flex gap-1 bg-bg-secondary rounded-md p-1",children:[(0,r.jsx)(tq,{active:"conversations"===a,onClick:()=>{k(null),l("conversations")},children:"Conversations"}),(0,r.jsx)(tq,{active:"sessions"===a,onClick:()=>l("sessions"),children:"Sessions"}),(0,r.jsx)(tq,{active:"messages"===a,onClick:()=>l("messages"),children:"Messages"})]}),"messages"===a&&(0,r.jsx)("div",{className:"flex-1 max-w-xs",children:(0,r.jsx)("input",{type:"text",placeholder:"Search messages...",value:v,onChange:e=>y(e.target.value),className:"w-full px-3 py-2 bg-bg-secondary border border-border rounded-md text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:border-accent"})}),"sessions"===a&&(0,r.jsx)("div",{className:"flex-1 max-w-xs",children:(0,r.jsx)("input",{type:"text",placeholder:"Filter by agent...",value:j,onChange:e=>w(e.target.value),className:"w-full px-3 py-2 bg-bg-secondary border border-border rounded-md text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:border-accent"})}),N&&(0,r.jsxs)("button",{onClick:S,className:"flex items-center gap-1 px-3 py-2 text-sm text-text-muted hover:text-text-primary",children:[(0,r.jsx)(t1,{})," Back to conversations"]})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:p?(0,r.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,r.jsx)(t2,{})}):f?(0,r.jsx)("div",{className:"flex items-center justify-center h-full text-error",children:f}):"conversations"===a?(0,r.jsx)(tJ,{conversations:i,onConversationClick:C}):"sessions"===a?(0,r.jsx)(t$,{sessions:c}):(0,r.jsx)(tX,{messages:u,conversationTitle:N?"".concat(N.participants[0]," & ").concat(N.participants[1]):void 0})})]})}):null}function tq(e){let{active:t,onClick:n,children:s}=e;return(0,r.jsx)("button",{onClick:n,className:"px-3 py-1.5 text-sm rounded transition-colors ".concat(t?"bg-accent text-white":"text-text-muted hover:text-text-primary hover:bg-bg-primary"),children:s})}function tJ(e){let{conversations:t,onConversationClick:n}=e;return 0===t.length?(0,r.jsx)("div",{className:"flex items-center justify-center h-full text-text-muted",children:"No conversations found"}):(0,r.jsx)("div",{className:"space-y-2",children:t.map((e,t)=>(0,r.jsxs)("div",{onClick:()=>n(e),className:"p-4 bg-bg-secondary rounded-lg cursor-pointer hover:bg-bg-tertiary transition-colors",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"font-medium text-text-primary",children:e.participants.join(" & ")}),(0,r.jsxs)("span",{className:"text-xs px-2 py-0.5 bg-accent/10 text-accent rounded-full",children:[e.messageCount," messages"]})]}),(0,r.jsx)("span",{className:"text-xs text-text-muted",children:tQ(e.lastTimestamp)})]}),(0,r.jsx)("p",{className:"text-sm text-text-muted truncate",children:e.lastMessage})]},t))})}function t$(e){let{sessions:t}=e;return 0===t.length?(0,r.jsx)("div",{className:"flex items-center justify-center h-full text-text-muted",children:"No sessions found"}):(0,r.jsx)("div",{className:"space-y-2",children:t.map(e=>(0,r.jsxs)("div",{className:"p-4 bg-bg-secondary rounded-lg",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"font-medium text-text-primary",children:e.agentName}),e.cli&&(0,r.jsx)("span",{className:"text-xs px-2 py-0.5 bg-bg-tertiary text-text-muted rounded",children:e.cli}),(0,r.jsx)(tY,{isActive:e.isActive,closedBy:e.closedBy})]}),(0,r.jsx)("span",{className:"text-xs text-text-muted",children:e.duration})]}),(0,r.jsxs)("div",{className:"flex items-center gap-4 text-sm text-text-muted",children:[(0,r.jsx)("span",{children:new Date(e.startedAt).toLocaleString()}),(0,r.jsxs)("span",{children:[e.messageCount," messages"]})]}),e.summary&&(0,r.jsx)("p",{className:"mt-2 text-sm text-text-muted truncate",children:e.summary})]},e.id))})}function tY(e){let{isActive:t,closedBy:n}=e;if(t)return(0,r.jsx)("span",{className:"text-xs px-2 py-0.5 bg-success/10 text-success rounded-full",children:"Active"});let s={agent:"bg-text-muted/10 text-text-muted",disconnect:"bg-warning/10 text-warning",error:"bg-error/10 text-error"},a=n?s[n]:s.agent;return(0,r.jsx)("span",{className:"text-xs px-2 py-0.5 rounded-full ".concat(a),children:n?({agent:"Closed",disconnect:"Disconnected",error:"Error"})[n]:"Ended"})}function tX(e){let{messages:t,conversationTitle:n}=e;return 0===t.length?(0,r.jsx)("div",{className:"flex items-center justify-center h-full text-text-muted",children:"No messages found"}):(0,r.jsxs)("div",{className:"space-y-4",children:[n&&(0,r.jsx)("h3",{className:"text-lg font-medium text-text-primary mb-4",children:n}),t.map(e=>(0,r.jsxs)("div",{className:"p-4 bg-bg-secondary rounded-lg",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"font-medium text-accent",children:e.from}),(0,r.jsx)("span",{className:"text-text-muted",children:"to"}),(0,r.jsx)("span",{className:"font-medium text-text-primary",children:"*"===e.to?"Everyone":e.to}),e.isBroadcast&&(0,r.jsx)("span",{className:"text-xs px-2 py-0.5 bg-accent/10 text-accent rounded-full",children:"Broadcast"}),e.isUrgent&&(0,r.jsx)("span",{className:"text-xs px-2 py-0.5 bg-error/10 text-error rounded-full",children:"Urgent"})]}),(0,r.jsx)("span",{className:"text-xs text-text-muted",children:tQ(e.timestamp)})]}),(0,r.jsx)("p",{className:"text-sm text-text-primary whitespace-pre-wrap",children:e.content}),e.thread&&(0,r.jsxs)("div",{className:"mt-2 text-xs text-text-muted",children:["Thread: ",e.thread.slice(0,8),"..."]})]},e.id))]})}function tQ(e){let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4),s=Math.floor(n/36e5),a=Math.floor(n/864e5);return r<1?"just now":r<60?"".concat(r,"m ago"):s<24?"".concat(s,"h ago"):a<7?"".concat(a,"d ago"):t.toLocaleDateString()}function t0(){return(0,r.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,r.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function t1(){return(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("polyline",{points:"15 18 9 12 15 6"})})}function t2(){return(0,r.jsx)("svg",{className:"animate-spin text-accent",width:"24",height:"24",viewBox:"0 0 24 24",children:(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}function t5(e){let{toasts:t,onDismiss:n,position:s="top-right",maxVisible:a=5}=e,l=t.slice(0,a);return(0,r.jsx)("div",{className:"toast-container toast-".concat(s),children:l.map(e=>(0,r.jsx)(t4,{toast:e,onDismiss:n},e.id))})}function t4(e){let{toast:t,onDismiss:n}=e,[a,l]=(0,s.useState)(!1),i=(0,s.useCallback)(()=>{l(!0),setTimeout(()=>n(t.id),200)},[t.id,n]);(0,s.useEffect)(()=>{if(0===t.duration)return;let e=setTimeout(i,t.duration||5e3);return()=>clearTimeout(e)},[t.duration,i]);let o=t.agentName?(0,c.GW)(t.agentName):null,d=function(e){switch(e){case"success":return t6;case"warning":return t8;case"error":return t9;case"message":return t7;default:return t3}}(t.type);return(0,r.jsxs)("div",{className:"toast toast-".concat(t.type," ").concat(a?"toast-exit":""),role:"alert",children:[(0,r.jsx)("div",{className:"toast-icon-wrapper",children:t.agentName?(0,r.jsx)("div",{className:"toast-agent-avatar",style:{backgroundColor:null==o?void 0:o.primary,color:null==o?void 0:o.text},children:(0,c.hP)(t.agentName)}):(0,r.jsx)("div",{className:"toast-icon toast-icon-".concat(t.type),children:(0,r.jsx)(d,{})})}),(0,r.jsxs)("div",{className:"toast-content",children:[(0,r.jsxs)("div",{className:"toast-header",children:[(0,r.jsx)("span",{className:"toast-title",children:t.title}),t.agentName&&(0,r.jsxs)("span",{className:"toast-agent",children:["@",t.agentName]})]}),t.message&&(0,r.jsx)("p",{className:"toast-message",children:t.message}),t.action&&(0,r.jsx)("button",{className:"toast-action",onClick:()=>{var e;null===(e=t.action)||void 0===e||e.onClick(),i()},children:t.action.label})]}),(0,r.jsx)("button",{className:"toast-close",onClick:i,"aria-label":"Dismiss",children:(0,r.jsx)(ne,{})}),0!==t.duration&&(0,r.jsx)("div",{className:"toast-progress",style:{animationDuration:"".concat(t.duration||5e3,"ms")}})]})}function t3(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),(0,r.jsx)("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]})}function t6(){return(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})})}function t8(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),(0,r.jsx)("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),(0,r.jsx)("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}function t9(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),(0,r.jsx)("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}function t7(){return(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function ne(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,r.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function nt(e){let{workspaces:t,activeWorkspaceId:n,onSelect:a,onAddWorkspace:l,onWorkspaceSettings:i,isLoading:o=!1}=e,[c,d]=(0,s.useState)(!1),u=(0,s.useRef)(null),x=t.find(e=>e.id===n);return(0,s.useEffect)(()=>{let e=e=>{u.current&&!u.current.contains(e.target)&&d(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,s.useEffect)(()=>{let e=e=>{"Escape"===e.key&&d(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[]),(0,r.jsxs)("div",{className:"relative w-full",ref:u,children:[(0,r.jsxs)("button",{className:"w-full flex items-center gap-2 px-3 py-2.5 bg-bg-secondary border border-border rounded-lg text-text-primary text-sm cursor-pointer transition-all hover:bg-bg-tertiary hover:border-border-medium disabled:opacity-60 disabled:cursor-not-allowed",onClick:()=>d(!c),disabled:o,children:[o?(0,r.jsx)("span",{className:"flex-1 text-left text-text-muted",children:"Loading..."}):x?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(nn,{provider:x.provider}),(0,r.jsx)("span",{className:"flex-1 text-left font-medium",children:x.name}),x.gitBranch&&(0,r.jsxs)("span",{className:"flex items-center gap-1 text-xs text-text-muted bg-bg-hover px-1.5 py-0.5 rounded",children:[(0,r.jsx)(na,{}),x.gitBranch]})]}):(0,r.jsx)("span",{className:"flex-1 text-left text-text-muted",children:"Select workspace..."}),(0,r.jsx)(ns,{isOpen:c})]}),c&&(0,r.jsxs)("div",{className:"absolute top-[calc(100%+4px)] left-0 right-0 bg-bg-card border border-border rounded-lg shadow-modal z-[1000] overflow-hidden",children:[(0,r.jsx)("div",{className:"max-h-[300px] overflow-y-auto",children:0===t.length?(0,r.jsxs)("div",{className:"py-6 px-4 text-center text-text-muted text-[13px] leading-relaxed",children:["No workspaces added yet.",(0,r.jsx)("br",{}),"Add a repository to get started."]}):t.map(e=>(0,r.jsxs)("button",{className:"w-full flex items-center gap-2.5 px-3 py-2.5 bg-transparent border-none text-text-primary text-sm cursor-pointer transition-colors text-left hover:bg-bg-hover ".concat(e.id===n?"bg-success-light":""),onClick:()=>{a(e),d(!1)},children:[(0,r.jsx)(nn,{provider:e.provider}),(0,r.jsxs)("div",{className:"flex-1 flex flex-col gap-0.5 min-w-0",children:[(0,r.jsx)("span",{className:"font-medium",children:e.name}),(0,r.jsx)("span",{className:"text-[11px] text-text-muted overflow-hidden text-ellipsis whitespace-nowrap",children:e.path})]}),(0,r.jsx)(nr,{status:e.status})]},e.id))}),(0,r.jsxs)("div",{className:"p-2 border-t border-border space-y-1.5",children:[i&&x&&(0,r.jsxs)("button",{className:"w-full flex items-center justify-center gap-1.5 px-3 py-2 bg-transparent border border-border rounded-md text-text-muted text-[13px] cursor-pointer transition-all hover:bg-bg-hover hover:border-border-medium hover:text-text-primary",onClick:()=>{i(),d(!1)},children:[(0,r.jsx)(ni,{}),"Workspace Settings"]}),(0,r.jsxs)("button",{className:"w-full flex items-center justify-center gap-1.5 px-3 py-2 bg-transparent border border-dashed border-border rounded-md text-text-muted text-[13px] cursor-pointer transition-all hover:bg-bg-hover hover:border-border-medium hover:text-text-primary",onClick:l,children:[(0,r.jsx)(nl,{}),"Add Workspace"]})]})]})]})}function nn(e){let{provider:t}=e,n={claude:"\uD83E\uDD16",codex:"\uD83E\uDDE0",gemini:"✨",generic:"\uD83D\uDCC1"};return(0,r.jsx)("span",{className:"text-base",title:t,children:n[t]||n.generic})}function nr(e){let{status:t}=e,n={active:"bg-green-500",inactive:"bg-gray-500",error:"bg-red-500"};return(0,r.jsx)("span",{className:"w-2 h-2 rounded-full flex-shrink-0 ".concat(n[t]||n.inactive),title:t})}function ns(e){let{isOpen:t}=e;return(0,r.jsx)("svg",{className:"text-text-muted transition-transform ".concat(t?"rotate-180":""),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("polyline",{points:"6 9 12 15 18 9"})})}function na(){return(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,r.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,r.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,r.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]})}function nl(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,r.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function ni(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,r.jsx)("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}function no(e){let{isOpen:t,onClose:n,onAdd:a,isAdding:l=!1,error:i}=e,[o,c]=(0,s.useState)(""),[d,u]=(0,s.useState)(""),[x,m]=(0,s.useState)(null),h=(0,s.useRef)(null);(0,s.useEffect)(()=>{t&&h.current&&h.current.focus()},[t]),(0,s.useEffect)(()=>{t||(c(""),u(""),m(null))},[t]);let p=async e=>{if(e.preventDefault(),!o.trim()){m("Path is required");return}try{await a(o.trim(),d.trim()||void 0),n()}catch(e){m(e instanceof Error?e.message:"Failed to add workspace")}};if(!t)return null;let g=i||x;return(0,r.jsx)("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[9999] backdrop-blur-sm",onClick:n,onKeyDown:e=>{"Escape"===e.key&&n()},children:(0,r.jsxs)("div",{className:"bg-[#1a1a2e] border border-[#3a3a4e] rounded-xl p-6 min-w-[450px] max-w-[90vw] shadow-[0_20px_60px_rgba(0,0,0,0.5)]",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,r.jsx)("h2",{className:"m-0 text-lg font-semibold text-[#e8e8e8]",children:"Add Workspace"}),(0,r.jsx)("button",{className:"bg-transparent border-none text-[#666] cursor-pointer p-1 flex items-center justify-center rounded transition-all hover:bg-white/10 hover:text-[#e8e8e8]",onClick:n,children:(0,r.jsx)(nc,{})})]}),(0,r.jsxs)("form",{onSubmit:p,children:[(0,r.jsxs)("div",{className:"mb-5",children:[(0,r.jsx)("label",{htmlFor:"workspace-path",className:"block mb-2 text-[13px] font-medium text-[#e8e8e8]",children:"Repository Path"}),(0,r.jsx)("input",{ref:h,id:"workspace-path",type:"text",value:o,onChange:e=>{c(e.target.value),m(null)},placeholder:"/path/to/repository",disabled:l,autoComplete:"off",className:"w-full px-3 py-2.5 bg-[#2a2a3e] border border-[#3a3a4e] rounded-md text-[#e8e8e8] text-sm outline-none transition-colors box-border focus:border-[#00c896] placeholder:text-[#666] disabled:opacity-60 disabled:cursor-not-allowed"}),(0,r.jsx)("p",{className:"mt-1.5 text-xs text-[#666] leading-relaxed",children:"Enter the full path to your repository. Use ~ for home directory."})]}),(0,r.jsxs)("div",{className:"mb-5",children:[(0,r.jsx)("label",{htmlFor:"workspace-name",className:"block mb-2 text-[13px] font-medium text-[#e8e8e8]",children:"Display Name (optional)"}),(0,r.jsx)("input",{id:"workspace-name",type:"text",value:d,onChange:e=>u(e.target.value),placeholder:"My Project",disabled:l,autoComplete:"off",className:"w-full px-3 py-2.5 bg-[#2a2a3e] border border-[#3a3a4e] rounded-md text-[#e8e8e8] text-sm outline-none transition-colors box-border focus:border-[#00c896] placeholder:text-[#666] disabled:opacity-60 disabled:cursor-not-allowed"}),(0,r.jsx)("p",{className:"mt-1.5 text-xs text-[#666] leading-relaxed",children:"A friendly name for this workspace. Defaults to the folder name."})]}),g&&(0,r.jsx)("div",{className:"px-3 py-2.5 bg-red-500/10 border border-red-500/30 rounded-md text-red-500 text-[13px] mb-5",children:g}),(0,r.jsxs)("div",{className:"flex gap-3 justify-end mt-6",children:[(0,r.jsx)("button",{type:"button",className:"px-5 py-2.5 rounded-md text-sm font-medium cursor-pointer transition-all bg-transparent border border-[#3a3a4e] text-[#e8e8e8] hover:bg-white/5 disabled:opacity-50 disabled:cursor-not-allowed",onClick:n,disabled:l,children:"Cancel"}),(0,r.jsx)("button",{type:"submit",className:"px-5 py-2.5 rounded-md text-sm font-medium cursor-pointer transition-all bg-[#00c896] border-none text-[#1a1a2e] hover:bg-[#00a87d] disabled:opacity-50 disabled:cursor-not-allowed",disabled:l||!o.trim(),children:l?"Adding...":"Add Workspace"})]})]})]})})}function nc(){return(0,r.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,r.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}var nd=n(1705);function nu(e){let{agentName:t,mode:n="panel",maxHeight:a="500px",showHeader:l=!0,autoScrollDefault:i=!0,onClose:o,onExpand:d,className:u=""}=e,[x,m]=(0,s.useState)(i),h=(0,s.useRef)(null),{logs:p,isConnected:g,isConnecting:f}=eU({agentName:t,autoConnect:!0}),b=(0,c.GW)(t),v=(0,s.useMemo)(()=>p.filter(e=>{let t=(0,eO.hL)(e.content).trim();return!(0===t.length||(0,eO.ED)(t))}),[p]);(0,s.useEffect)(()=>{if(x&&h.current){let e=h.current;e.scrollTop=e.scrollHeight}},[p,x]);let y=(0,s.useCallback)(()=>{if(!h.current)return;let e=h.current,t=e.scrollHeight-e.scrollTop-e.clientHeight<50;t&&!x?m(!0):!t&&x&&m(!1)},[x]);return"inline"===n?(0,r.jsxs)("div",{className:"log-viewer-inline rounded-lg overflow-hidden border border-[#2a2d35] ".concat(u),style:{background:"linear-gradient(180deg, #0d0f14 0%, #12151c 100%)",boxShadow:"inset 0 1px 0 rgba(255,255,255,0.02), 0 4px 12px rgba(0,0,0,0.3)"},children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-[#2a2d35]",style:{background:"linear-gradient(180deg, #161b22 0%, #0d1117 100%)"},children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(nh,{}),(0,r.jsx)("span",{className:"text-xs font-medium",style:{color:b.primary},children:"Live logs"}),(0,r.jsx)(nm,{isConnected:g,isConnecting:f})]}),(0,r.jsx)("div",{className:"flex items-center gap-1",children:(0,r.jsx)("button",{className:"p-1.5 rounded-lg hover:bg-[#21262d] text-[#8b949e] hover:text-accent-cyan transition-all duration-200 hover:shadow-[0_0_8px_rgba(0,217,255,0.15)]",onClick:d,title:"Expand",children:(0,r.jsx)(np,{})})})]}),(0,r.jsxs)("div",{className:"font-mono text-xs leading-relaxed p-3 overflow-y-auto touch-pan-y",style:{maxHeight:"150px",WebkitOverflowScrolling:"touch",overscrollBehavior:"contain",touchAction:"pan-y"},ref:h,onScroll:y,children:[v.slice(-20).map(e=>(0,r.jsx)(nx,{log:e,compact:!0},e.id)),0===v.length&&(0,r.jsxs)("div",{className:"text-[#484f58] italic flex items-center gap-2",children:[(0,r.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[#484f58] animate-pulse"}),"Waiting for output..."]})]})]}):(0,r.jsx)(nd.L,{agentName:t,maxHeight:a,showHeader:l,onClose:o,className:u})}function nx(e){let{log:t,compact:n=!1}=e,s=(0,eO.hL)(t.content);return(0,r.jsx)("div",{className:"".concat((()=>{switch(t.type){case"stderr":return"text-[#f85149]";case"system":return"text-[#58a6ff] italic";case"input":return"text-[#d29922]";default:return"text-[#c9d1d9]"}})()," leading-5 whitespace-pre-wrap break-all min-w-0 overflow-hidden"),children:s})}function nm(e){let{isConnected:t,isConnecting:n}=e;return n?(0,r.jsxs)("span",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded-full bg-[#d29922]/20 text-[10px] text-[#d29922] uppercase tracking-wider",children:[(0,r.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[#d29922] animate-pulse"}),"connecting"]}):t?(0,r.jsxs)("span",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded-full bg-[#238636]/20 text-[10px] text-[#3fb950] uppercase tracking-wider",children:[(0,r.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[#3fb950] shadow-[0_0_4px_rgba(63,185,80,0.5)]"}),"live"]}):(0,r.jsxs)("span",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded-full bg-[#484f58]/20 text-[10px] text-[#484f58] uppercase tracking-wider",children:[(0,r.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[#484f58]"}),"offline"]})}function nh(e){let{size:t=16}=e;return(0,r.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#8b949e]",children:[(0,r.jsx)("polyline",{points:"4 17 10 11 4 5"}),(0,r.jsx)("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function np(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("polyline",{points:"15 3 21 3 21 9"}),(0,r.jsx)("polyline",{points:"9 21 3 21 3 15"}),(0,r.jsx)("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),(0,r.jsx)("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]})}function ng(e){let{agent:t,position:n="right",isOpen:a,onClose:l,onAgentChange:i,availableAgents:o=[]}=e,d=(0,c.GW)(t.name),[u,x]=(0,s.useState)(!1),m=(0,s.useCallback)(async()=>{if(!u){x(!0);try{let e=await tZ.api.interruptAgent(t.name);e.success||console.error("Failed to interrupt agent:",e.error)}catch(e){console.error("Error interrupting agent:",e)}finally{setTimeout(()=>x(!1),500)}}},[t.name,u]);return((0,s.useEffect)(()=>{let e=e=>{"Escape"===e.key&&a&&l()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a,l]),(0,s.useEffect)(()=>{if(!a)return;let e=document.body.style.overflow,t=document.body.style.overscrollBehavior;return document.body.style.overflow="hidden",document.body.style.overscrollBehavior="none",()=>{document.body.style.overflow=e,document.body.style.overscrollBehavior=t}},[a]),a)?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"fixed inset-0 bg-black/60 z-[1099] animate-fade-in",onClick:l}),(0,r.jsxs)("div",{className:"flex flex-col ".concat((()=>{switch(n){case"right":return"animate-slide-in-right";case"bottom":return"animate-slide-in-bottom";case"fullscreen":return"animate-fade-in"}})()),style:(()=>{let e={position:"fixed",zIndex:1100,background:"linear-gradient(180deg, #0d0f14 0%, #0a0c10 100%)"};switch(n){case"right":return{...e,top:0,right:0,bottom:0,width:"600px",maxWidth:"100vw",borderLeft:"1px solid #21262d",boxShadow:"-20px 0 60px rgba(0, 0, 0, 0.5)"};case"bottom":return{...e,left:0,right:0,bottom:0,height:"400px",maxHeight:"60vh",borderTop:"1px solid #21262d",boxShadow:"0 -20px 60px rgba(0, 0, 0, 0.5)"};case"fullscreen":return{...e,inset:0}}})(),children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 border-b border-[#21262d] px-4 py-3 sm:px-5 sm:py-4",style:{background:"linear-gradient(180deg, #161b22 0%, #0d1117 100%)"},children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsxs)("div",{className:"relative shrink-0 rounded-xl flex items-center justify-center font-bold overflow-hidden w-9 h-9 text-sm sm:w-11 sm:h-11",style:{backgroundColor:d.primary,color:d.text,boxShadow:"0 0 20px ".concat(d.primary,"50, inset 0 1px 0 rgba(255,255,255,0.2)")},children:[(0,r.jsx)("div",{className:"absolute inset-0 opacity-30",style:{background:"linear-gradient(135deg, rgba(255,255,255,0.35) 0%, transparent 50%)"}}),(0,r.jsx)("span",{className:"relative z-10",children:(0,c.hP)(t.name)})]}),(0,r.jsxs)("div",{className:"flex flex-col min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2.5 flex-wrap",children:[(0,r.jsx)("h2",{className:"text-base sm:text-lg font-semibold m-0",style:{color:d.primary},title:t.name,children:t.name}),(0,r.jsx)("span",{className:"px-2 py-0.5 rounded-md text-[10px] uppercase tracking-wider font-medium shrink-0 ".concat("online"===t.status?"bg-[#3fb950]/15 text-[#3fb950]":"busy"===t.status?"bg-[#d29922]/15 text-[#d29922]":"bg-[#484f58]/15 text-[#484f58]"),style:{boxShadow:"online"===t.status?"0 0 8px rgba(63,185,80,0.2)":"none"},children:t.status})]}),t.currentTask&&(0,r.jsx)("span",{className:"text-xs sm:text-sm text-[#8b949e] truncate mt-0.5",title:t.currentTask,children:t.currentTask})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[o.length>1&&i&&(0,r.jsx)(nf,{agents:o,currentAgent:t,onSelect:i}),(0,r.jsxs)("div",{className:"flex items-center gap-1 bg-[#21262d]/80 rounded-lg p-1 border border-[#30363d]/50",children:[(0,r.jsx)("button",{className:"p-1.5 rounded-md transition-all duration-200 ".concat("right"===n?"bg-accent-cyan/15 text-accent-cyan shadow-[0_0_8px_rgba(0,217,255,0.15)]":"text-[#8b949e] hover:text-[#c9d1d9] hover:bg-[#30363d]"),title:"Sidebar view",children:(0,r.jsx)(ny,{})}),(0,r.jsx)("button",{className:"p-1.5 rounded-md transition-all duration-200 ".concat("bottom"===n?"bg-accent-cyan/15 text-accent-cyan shadow-[0_0_8px_rgba(0,217,255,0.15)]":"text-[#8b949e] hover:text-[#c9d1d9] hover:bg-[#30363d]"),title:"Bottom panel",children:(0,r.jsx)(nj,{})}),(0,r.jsx)("button",{className:"p-1.5 rounded-md transition-all duration-200 ".concat("fullscreen"===n?"bg-accent-cyan/15 text-accent-cyan shadow-[0_0_8px_rgba(0,217,255,0.15)]":"text-[#8b949e] hover:text-[#c9d1d9] hover:bg-[#30363d]"),title:"Fullscreen",children:(0,r.jsx)(nw,{})})]}),(0,r.jsx)("div",{className:"flex-1"}),(0,r.jsx)("button",{className:"p-2 rounded-lg transition-all duration-200 ".concat(u?"bg-[#d29922]/20 text-[#d29922] animate-pulse":"text-[#8b949e] hover:text-[#d29922] hover:bg-[#d29922]/10 hover:shadow-[0_0_8px_rgba(210,153,34,0.2)]"),onClick:m,disabled:u,title:"Send ESC to agent - interrupt current operation",children:(0,r.jsx)(nb,{})}),(0,r.jsx)("button",{className:"p-2 rounded-lg text-[#8b949e] hover:text-[#f85149] hover:bg-[#f85149]/10 transition-all duration-200 hover:shadow-[0_0_8px_rgba(248,81,73,0.2)]",onClick:l,children:(0,r.jsx)(nv,{})})]})]}),(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:(0,r.jsx)(nu,{agentName:t.name,mode:"panel",showHeader:!1,maxHeight:"100%",className:"h-full rounded-none border-none"})})]}),(0,r.jsx)("style",{children:"\n @keyframes slideInRight {\n from {\n transform: translateX(100%);\n opacity: 0;\n }\n to {\n transform: translateX(0);\n opacity: 1;\n }\n }\n\n @keyframes slideInBottom {\n from {\n transform: translateY(100%);\n opacity: 0;\n }\n to {\n transform: translateY(0);\n opacity: 1;\n }\n }\n\n .animate-slide-in-right {\n animation: slideInRight 0.3s cubic-bezier(0.32, 0.72, 0, 1);\n }\n\n .animate-slide-in-bottom {\n animation: slideInBottom 0.3s cubic-bezier(0.32, 0.72, 0, 1);\n }\n "})]}):null}function nf(e){let{agents:t,currentAgent:n,onSelect:a}=e,[l,i]=s.useState(!1),o=s.useRef(null);return(0,s.useEffect)(()=>{let e=e=>{o.current&&!o.current.contains(e.target)&&i(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,r.jsxs)("div",{className:"relative",ref:o,children:[(0,r.jsxs)("button",{className:"flex items-center gap-2 px-3 py-1.5 bg-[#21262d] hover:bg-[#30363d] rounded-lg text-sm text-[#c9d1d9] transition-colors",onClick:()=>i(!l),children:[(0,r.jsx)("span",{children:"Switch agent"}),(0,r.jsx)(nN,{})]}),l&&(0,r.jsx)("div",{className:"absolute right-0 top-full mt-2 w-64 bg-[#161b22] border border-[#30363d] rounded-lg shadow-xl overflow-hidden z-10",children:(0,r.jsx)("div",{className:"max-h-64 overflow-y-auto",children:t.map(e=>{let t=(0,c.GW)(e.name),s=e.name===n.name;return(0,r.jsxs)("button",{className:"w-full flex items-center gap-3 px-3 py-2 text-left transition-colors ".concat(s?"bg-[#238636]/20":"hover:bg-[#21262d]"),onClick:()=>{a(e),i(!1)},children:[(0,r.jsx)("div",{className:"w-8 h-8 rounded flex items-center justify-center text-xs font-semibold shrink-0",style:{backgroundColor:t.primary,color:t.text},children:(0,c.hP)(e.name)}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("div",{className:"text-sm text-[#c9d1d9] truncate",children:e.name}),(0,r.jsx)("div",{className:"text-xs text-[#8b949e]",children:e.status})]}),s&&(0,r.jsx)(nk,{})]},e.name)})})})]})}function nb(){return(0,r.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),(0,r.jsx)("text",{x:"12",y:"15",textAnchor:"middle",fill:"currentColor",stroke:"none",fontSize:"8",fontWeight:"600",fontFamily:"system-ui",children:"ESC"})]})}function nv(){return(0,r.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,r.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function ny(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),(0,r.jsx)("line",{x1:"15",y1:"3",x2:"15",y2:"21"})]})}function nj(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),(0,r.jsx)("line",{x1:"3",y1:"15",x2:"21",y2:"15"})]})}function nw(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("polyline",{points:"15 3 21 3 21 9"}),(0,r.jsx)("polyline",{points:"9 21 3 21 3 15"}),(0,r.jsx)("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),(0,r.jsx)("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]})}function nN(){return(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("polyline",{points:"6 9 12 15 18 9"})})}function nk(){return(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#3fb950",strokeWidth:"2",children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})})}function nC(e){let{agentName:t,steps:n,history:a=[],selectedTrajectoryId:l,onSelectTrajectory:i,isLoading:o=!1,onStepClick:c,compact:d=!1}=e,[u,x]=(0,s.useState)(new Set),[m,h]=(0,s.useState)("all"),[p,g]=(0,s.useState)(""),f=null===l&&a.length>0;(0,s.useEffect)(()=>{h("all")},[l]);let b=(0,s.useMemo)(()=>"all"===m?n:n.filter(e=>e.type===m),[n,m]),v=(0,s.useMemo)(()=>{let e=p.trim().toLowerCase();return e?a.filter(t=>{var n,r,s,a,l;let i=null===(n=t.title)||void 0===n?void 0:n.toLowerCase().includes(e),o=null===(r=t.summary)||void 0===r?void 0:r.toLowerCase().includes(e),c=null===(s=t.agents)||void 0===s?void 0:s.some(t=>t.toLowerCase().includes(e)),d=null===(a=t.status)||void 0===a?void 0:a.toLowerCase().includes(e),u=null===(l=t.id)||void 0===l?void 0:l.toLowerCase().includes(e);return i||o||c||d||u}):a},[a,p]),y=e=>{x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},j=[{value:"all",label:"All",icon:(0,r.jsx)(nD,{})},{value:"tool_call",label:"Tools",icon:(0,r.jsx)(nA,{})},{value:"decision",label:"Decisions",icon:(0,r.jsx)(nE,{})},{value:"message",label:"Messages",icon:(0,r.jsx)(nT,{})},{value:"state_change",label:"State",icon:(0,r.jsx)(nW,{})},{value:"phase_transition",label:"Phases",icon:(0,r.jsx)(nP,{})},{value:"error",label:"Errors",icon:(0,r.jsx)(nI,{})}],w=(0,s.useMemo)(()=>{let e=n.filter(e=>e.phase).reduce((e,t)=>(t.phase&&(e[t.phase]=(e[t.phase]||0)+1),e),{}),t=Object.values(e).reduce((e,t)=>e+t,0);return{phases:e,total:t}},[n]);return(0,r.jsxs)("div",{className:"h-full flex flex-col bg-gradient-to-b from-bg-card to-bg-tertiary rounded-xl border border-border/50 overflow-hidden shadow-lg backdrop-blur-sm",children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("div",{className:"absolute top-0 left-0 right-0 h-[2px] bg-gradient-to-r from-blue-500 via-accent-cyan to-blue-500 opacity-60"}),(0,r.jsxs)("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border/30",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[l&&i&&(0,r.jsxs)("button",{onClick:()=>i(null),className:"flex items-center gap-1.5 px-2 py-1.5 text-[11px] font-medium text-text-muted hover:text-accent-cyan bg-bg-elevated/50 hover:bg-bg-elevated rounded-lg border border-border/30 hover:border-accent-cyan/30 transition-all duration-200",title:"Back to trajectory list",children:[(0,r.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:(0,r.jsx)("path",{d:"M19 12H5M12 19l-7-7 7-7",strokeLinecap:"round",strokeLinejoin:"round"})}),(0,r.jsx)("span",{children:"List"})]}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("div",{className:"w-9 h-9 rounded-lg bg-gradient-to-br from-blue-500/20 to-accent-cyan/20 flex items-center justify-center border border-blue-500/30",children:(0,r.jsx)(nL,{})}),n.some(e=>"running"===e.status)&&(0,r.jsx)("span",{className:"absolute -top-1 -right-1 w-3 h-3 bg-accent-cyan rounded-full animate-pulse shadow-[0_0_8px_rgba(0,217,255,0.6)]"})]}),(0,r.jsxs)("div",{className:"flex flex-col",children:[(0,r.jsx)("span",{className:"font-semibold text-sm text-text-primary tracking-wide",children:"Trajectory"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("span",{className:"text-[11px] text-text-muted font-mono",children:[n.length," ",1===n.length?"step":"steps"]}),t&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-text-dim",children:"|"}),(0,r.jsx)("span",{className:"text-[11px] text-accent-cyan/80 font-medium truncate max-w-[120px]",children:t})]})]})]})]}),w.total>0&&!d&&(0,r.jsx)("div",{className:"flex items-center gap-1.5",children:["plan","design","execute","review","observe"].map(e=>{let t=w.phases[e]||0,n=nM(e);return t>0?(0,r.jsx)("div",{className:"h-1.5 rounded-full transition-all duration-300",style:{width:"".concat(Math.max(8,t/w.total*48),"px"),backgroundColor:n||"var(--color-border)"},title:"".concat(e,": ").concat(t)},e):null})})]}),!d&&!f&&(0,r.jsx)("div",{className:"flex items-center gap-1 px-4 py-2 bg-bg-elevated/50 border-b border-border/20 overflow-x-auto scrollbar-thin",children:j.map(e=>(0,r.jsxs)("button",{className:"flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-lg transition-all duration-200 whitespace-nowrap ".concat(m===e.value?"bg-blue-500/20 text-blue-500 border border-blue-500/30 shadow-[0_0_12px_rgba(59,130,246,0.15)]":"text-text-muted hover:text-text-secondary hover:bg-bg-hover/50"),onClick:()=>h(e.value),children:[(0,r.jsx)("span",{className:"opacity-70",children:e.icon}),e.label]},e.value))})]}),(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 py-3 scrollbar-thin scrollbar-thumb-border scrollbar-track-transparent",children:o?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4 py-12 text-text-muted",children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(nR,{}),(0,r.jsx)("div",{className:"absolute inset-0 bg-accent-cyan/10 rounded-full blur-xl"})]}),(0,r.jsx)("span",{className:"text-sm font-medium",children:"Loading trajectory..."})]}):f?(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 px-2",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-text-secondary uppercase tracking-wider",children:"All Trajectories"}),(0,r.jsx)("input",{type:"search",value:p,onChange:e=>g(e.target.value),placeholder:"Search trajectories...",className:"text-[11px] text-text-secondary bg-bg-elevated/60 border border-border/30 rounded-md px-2 py-1 w-40 focus:outline-none focus:border-accent-cyan/40"})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[v.map(e=>(0,r.jsxs)("button",{onClick:()=>null==i?void 0:i(e.id),className:"w-full text-left px-3 py-2.5 rounded-lg transition-all duration-200 border ".concat("active"===e.status?"bg-blue-500/10 border-blue-500/30 hover:bg-blue-500/20":"bg-bg-tertiary/50 border-transparent hover:bg-bg-elevated/60 hover:border-border/40"),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-[13px] font-medium text-text-primary truncate flex-1",children:e.title}),(0,r.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium flex-shrink-0 ".concat("completed"===e.status?"bg-green-500/15 text-green-500":"active"===e.status?"bg-blue-500/15 text-blue-500":"bg-amber-500/15 text-amber-500"),children:e.status})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,r.jsx)("span",{className:"text-[10px] text-text-dim",children:function(e){let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4),s=Math.floor(n/36e5),a=Math.floor(n/864e5);return r<1?"just now":r<60?"".concat(r,"m ago"):s<24?"".concat(s,"h ago"):a<7?"".concat(a,"d ago"):t.toLocaleDateString()}(e.startedAt)}),e.confidence&&(0,r.jsxs)("span",{className:"text-[10px] text-text-dim",children:["• ",Math.round(100*e.confidence),"% confidence"]})]}),e.summary&&(0,r.jsx)("p",{className:"text-[11px] text-text-muted mt-1 line-clamp-2",children:e.summary})]},e.id)),0===v.length&&(0,r.jsx)("div",{className:"px-3 py-4 text-[11px] text-text-muted",children:"No matching trajectories. Try a different search."})]})]}):0===b.length?(0,r.jsx)("div",{className:"flex flex-col gap-4 py-4 text-text-muted",children:0===n.length?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4 py-8",children:[(0,r.jsx)("div",{className:"w-16 h-16 rounded-2xl bg-bg-elevated/50 flex items-center justify-center border border-border/30",children:(0,r.jsx)(n_,{})}),(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-text-secondary",children:"No steps recorded"}),(0,r.jsx)("p",{className:"text-xs text-text-dim mt-1",children:"Steps will appear here as the agent works"})]})]}):(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4 py-8",children:[(0,r.jsx)("div",{className:"w-16 h-16 rounded-2xl bg-bg-elevated/50 flex items-center justify-center border border-border/30",children:(0,r.jsx)(n_,{})}),(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-text-secondary",children:"No matching steps"}),(0,r.jsx)("p",{className:"text-xs text-text-dim mt-1",children:'Try a different filter or select "All"'})]})]})}):(0,r.jsx)("div",{className:"flex flex-col gap-0.5",children:b.map((e,t)=>(0,r.jsx)(nS,{step:e,isExpanded:u.has(e.id),isLast:t===b.length-1,isFirst:0===t,compact:d,onToggle:()=>y(e.id),onClick:c?()=>c(e):void 0},e.id))})})]})}function nS(e){var t;let{step:n,isExpanded:s,isLast:a,isFirst:l=!1,compact:i=!1,onToggle:o,onClick:c}=e,d=new Date(n.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}),u=function(e){switch(e){case"tool_call":return(0,r.jsx)(nA,{});case"decision":return(0,r.jsx)(nE,{});case"message":return(0,r.jsx)(nT,{});case"state_change":return(0,r.jsx)(nW,{});case"phase_transition":return(0,r.jsx)(nP,{});case"error":return(0,r.jsx)(nI,{});default:return null}}(n.type),x=function(e){switch(e){case"running":return"#ff6b35";case"success":return"#00ffc8";case"error":return"#ff4757";default:return null}}(n.status),m=nM(n.phase),h=function(e){switch(e){case"tool_call":return"#00d9ff";case"decision":case"message":return"#3b82f6";case"state_change":return"#10b981";case"phase_transition":return"#f59e0b";case"error":return"#ef4444";default:return"#6b7280"}}(n.type),p=n.metadata&&Object.keys(n.metadata).length>0,g=!!n.description||p||!!c;return(0,r.jsxs)("div",{className:"flex gap-3 group",children:[(0,r.jsxs)("div",{className:"flex flex-col items-center w-7 relative",children:[!l&&(0,r.jsx)("div",{className:"absolute top-0 w-px h-2 transition-colors",style:{backgroundColor:m?"".concat(m,"40"):"var(--color-border)"}}),(0,r.jsx)("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center flex-shrink-0 z-10 mt-2 transition-all duration-200 ".concat("running"===n.status?"animate-pulse shadow-[0_0_12px_rgba(0,217,255,0.4)]":"group-hover:scale-110"),style:{background:x?"linear-gradient(135deg, ".concat(x,"40, ").concat(x,"20)"):m?"linear-gradient(135deg, ".concat(m,"30, ").concat(m,"10)"):"linear-gradient(135deg, ".concat(h,"30, ").concat(h,"10)"),borderWidth:"1px",borderStyle:"solid",borderColor:x||m||h||"var(--color-border)",color:x||m||h||"var(--color-text-secondary)"},children:u}),!a&&(0,r.jsx)("div",{className:"w-px flex-1 mt-1 transition-colors",style:{background:"linear-gradient(to bottom, ".concat(m||h||"var(--color-border)","40, transparent)")}})]}),(0,r.jsxs)("div",{className:"flex-1 min-w-0 pt-1 ".concat(a?"pb-1":"pb-3"),children:[(0,r.jsxs)("button",{className:"w-full flex items-center justify-between gap-3 px-3 py-2.5 rounded-lg transition-all duration-200 text-left border ".concat(s?"bg-bg-elevated/80 border-border/60 shadow-sm":"bg-bg-tertiary/50 border-transparent hover:bg-bg-elevated/60 hover:border-border/40"),onClick:o,children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[(0,r.jsx)("span",{className:"text-[13px] font-medium text-text-primary truncate",children:n.title}),(0,r.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium flex-shrink-0",style:{backgroundColor:"".concat(h,"15"),color:h},children:{tool_call:"Tool",decision:"Decision",message:"Message",state_change:"State",phase_transition:"Phase",error:"Error"}[n.type]}),n.phase&&m&&(0,r.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium flex-shrink-0",style:{backgroundColor:"".concat(m,"15"),color:m},children:n.phase})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[void 0!==n.duration&&(0,r.jsx)("span",{className:"text-[10px] font-mono text-text-muted px-1.5 py-0.5 bg-bg-elevated/50 rounded",children:(t=n.duration)<1e3?"".concat(t,"ms"):t<6e4?"".concat((t/1e3).toFixed(1),"s"):"".concat((t/6e4).toFixed(1),"m")}),(0,r.jsx)("span",{className:"text-[10px] text-text-dim",children:d}),!i&&(0,r.jsx)(nB,{isExpanded:s})]})]}),s&&!i&&g&&(0,r.jsxs)("div",{className:"mt-2 ml-1 pl-3 border-l-2 border-border/30",children:[n.description&&(0,r.jsx)("p",{className:"text-[13px] text-text-secondary mb-3 leading-relaxed",children:n.description}),p&&(0,r.jsx)("div",{className:"bg-bg-elevated/50 rounded-lg p-3 mb-3 overflow-x-auto border border-border/20",children:(0,r.jsx)("pre",{className:"text-[11px] font-mono text-text-muted whitespace-pre-wrap break-words leading-relaxed",children:JSON.stringify(n.metadata,null,2)})}),c&&(0,r.jsxs)("button",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium text-accent-cyan bg-accent-cyan/10 border border-accent-cyan/20 rounded-md hover:bg-accent-cyan/20 hover:border-accent-cyan/30 transition-colors",onClick:e=>{e.stopPropagation(),c()},children:[(0,r.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,r.jsx)("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),(0,r.jsx)("polyline",{points:"15 3 21 3 21 9"}),(0,r.jsx)("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),"View Details"]})]})]})]})}function nM(e){switch(e){case"plan":return"#3b82f6";case"design":return"#00d9ff";case"execute":return"#ff6b35";case"review":return"#00ffc8";case"observe":return"#fbbf24";default:return null}}function nL(){return(0,r.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-blue-500",children:(0,r.jsx)("path",{d:"M3 12h4l3 9 4-18 3 9h4",strokeLinecap:"round",strokeLinejoin:"round"})})}function nD(){return(0,r.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,r.jsx)("path",{d:"M12 2v4m0 12v4m-7.07-14.93l2.83 2.83m8.48 8.48l2.83 2.83M2 12h4m12 0h4M4.93 19.07l2.83-2.83m8.48-8.48l2.83-2.83"})]})}function nA(){return(0,r.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})})}function nE(){return(0,r.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("path",{d:"M12 2l2.4 7.4H22l-6 4.6 2.3 7-6.3-4.6L5.7 21l2.3-7-6-4.6h7.6z"})})}function nT(){return(0,r.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function nW(){return(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),(0,r.jsx)("path",{d:"M9 12h6m-3-3v6"})]})}function nP(){return(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("path",{d:"M12 6v6l4 2"})]})}function nI(){return(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,r.jsx)("circle",{cx:"12",cy:"16",r:"0.5",fill:"currentColor"})]})}function nB(e){let{isExpanded:t}=e;return(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-text-muted transition-transform duration-200 ".concat(t?"rotate-180":""),children:(0,r.jsx)("polyline",{points:"6 9 12 15 18 9"})})}function n_(){return(0,r.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-text-dim",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("line",{x1:"8",y1:"12",x2:"16",y2:"12"})]})}function nR(){return(0,r.jsx)("svg",{className:"animate-spin",width:"20",height:"20",viewBox:"0 0 24 24",children:(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round",className:"text-accent"})})}function nF(e){let{decisions:t,onApprove:n,onReject:a,onDismiss:l,isProcessing:i={}}=e,[o,c]=(0,s.useState)(null),[d,u]=(0,s.useState)({}),x=(0,s.useMemo)(()=>{let e={critical:0,high:1,medium:2,low:3};return[...t].sort((t,n)=>{let r=e[t.priority]-e[n.priority];return 0!==r?r:new Date(t.timestamp).getTime()-new Date(n.timestamp).getTime()})},[t]),m=(0,s.useMemo)(()=>t.reduce((e,t)=>(e[t.priority]=(e[t.priority]||0)+1,e),{}),[t]),h=async(e,t)=>{await (null==n?void 0:n(e.id,t))},p=async e=>{await (null==a?void 0:a(e.id,d[e.id])),u(t=>{let n={...t};return delete n[e.id],n})};return 0===t.length?(0,r.jsxs)("div",{className:"decision-queue decision-queue-empty",children:[(0,r.jsx)(nz,{}),(0,r.jsx)("span",{children:"No pending decisions"})]}):(0,r.jsxs)("div",{className:"decision-queue",children:[(0,r.jsxs)("div",{className:"decision-queue-header",children:[(0,r.jsxs)("div",{className:"decision-queue-title",children:[(0,r.jsx)(nH,{}),(0,r.jsx)("span",{children:"Pending Decisions"}),(0,r.jsx)("span",{className:"decision-queue-count",children:t.length})]}),(0,r.jsxs)("div",{className:"decision-queue-summary",children:[m.critical&&(0,r.jsxs)("span",{className:"decision-priority-badge critical",children:[m.critical," critical"]}),m.high&&(0,r.jsxs)("span",{className:"decision-priority-badge high",children:[m.high," high"]})]})]}),(0,r.jsx)("div",{className:"decision-queue-list",children:x.map(e=>(0,r.jsx)(nU,{decision:e,isExpanded:o===e.id,isProcessing:i[e.id]||!1,rejectReason:d[e.id]||"",onToggle:()=>c(t=>t===e.id?null:e.id),onApprove:t=>h(e,t),onReject:()=>p(e),onRejectReasonChange:t=>u(n=>({...n,[e.id]:t})),onDismiss:()=>null==l?void 0:l(e.id)},e.id))})]})}function nU(e){let{decision:t,isExpanded:n,isProcessing:s,rejectReason:a,onToggle:l,onApprove:i,onReject:o,onRejectReasonChange:d,onDismiss:u}=e,x=(0,c.GW)(t.agentName),m=function(e){let t=new Date(e),n=Math.floor((new Date().getTime()-t.getTime())/6e4);return n<1?"just now":n<60?"".concat(n,"m ago"):n<1440?"".concat(Math.floor(n/60),"h ago"):t.toLocaleDateString()}(t.timestamp),h=t.expiresAt?function(e){let t=new Date(e),n=new Date,r=t.getTime()-n.getTime();if(r<=0)return{text:"Expired",urgent:!0};let s=Math.floor(r/6e4);return s<5?{text:"".concat(s,"m left"),urgent:!0}:s<60?{text:"".concat(s,"m left"),urgent:!1}:{text:"".concat(Math.floor(s/60),"h left"),urgent:!1}}(t.expiresAt):null;return(0,r.jsxs)("div",{className:"decision-card ".concat(t.priority),children:[(0,r.jsxs)("div",{className:"decision-card-header",onClick:l,children:[(0,r.jsx)("div",{className:"decision-card-avatar",style:{backgroundColor:x.primary,color:x.text},children:(0,c.hP)(t.agentName)}),(0,r.jsxs)("div",{className:"decision-card-info",children:[(0,r.jsxs)("div",{className:"decision-card-title",children:[(0,r.jsx)("span",{className:"decision-card-agent",children:t.agentName}),(0,r.jsx)("span",{className:"decision-card-type",children:{approval:"Approval",choice:"Choice",confirmation:"Confirm",input:"Input"}[t.type]}),(0,r.jsx)(nO,{priority:t.priority})]}),(0,r.jsx)("div",{className:"decision-card-subtitle",children:t.title})]}),(0,r.jsxs)("div",{className:"decision-card-meta",children:[h&&(0,r.jsx)("span",{className:"decision-card-expires ".concat(h.urgent?"urgent":""),children:h.text}),(0,r.jsx)("span",{className:"decision-card-time",children:m}),(0,r.jsx)(nV,{isExpanded:n})]})]}),n&&(0,r.jsxs)("div",{className:"decision-card-body",children:[(0,r.jsx)("p",{className:"decision-card-desc",children:t.description}),t.context&&Object.keys(t.context).length>0&&(0,r.jsxs)("div",{className:"decision-card-context",children:[(0,r.jsx)("span",{className:"decision-card-context-label",children:"Context"}),(0,r.jsx)("pre",{children:JSON.stringify(t.context,null,2)})]}),"choice"===t.type&&t.options&&(0,r.jsx)("div",{className:"decision-card-options",children:t.options.map(e=>(0,r.jsxs)("button",{className:"decision-card-option",onClick:()=>i(e.id),disabled:s,children:[(0,r.jsx)("span",{className:"decision-option-label",children:e.label}),e.description&&(0,r.jsx)("span",{className:"decision-option-desc",children:e.description})]},e.id))}),"choice"!==t.type&&(0,r.jsxs)("div",{className:"decision-card-actions",children:[(0,r.jsxs)("button",{className:"decision-btn decision-btn-approve",onClick:()=>i(),disabled:s,children:[s?(0,r.jsx)(nZ,{}):(0,r.jsx)(nz,{}),"confirmation"===t.type?"Confirm":"Approve"]}),(0,r.jsxs)("div",{className:"decision-reject-group",children:[(0,r.jsx)("input",{type:"text",className:"decision-reject-input",placeholder:"Reason (optional)",value:a,onChange:e=>d(e.target.value),disabled:s}),(0,r.jsxs)("button",{className:"decision-btn decision-btn-reject",onClick:o,disabled:s,children:[(0,r.jsx)(nG,{}),"Reject"]})]})]}),(0,r.jsx)("button",{className:"decision-card-dismiss",onClick:u,disabled:s,children:"Dismiss without action"})]})]})}function nO(e){let{priority:t}=e;return(0,r.jsx)("span",{className:"decision-priority-badge ".concat(t),children:t})}function nH(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,r.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}function nz(){return(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})})}function nG(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,r.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function nV(e){let{isExpanded:t}=e;return(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:t?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s"},children:(0,r.jsx)("polyline",{points:"6 9 12 15 18 9"})})}function nZ(){return(0,r.jsx)("svg",{className:"decision-spinner",width:"14",height:"14",viewBox:"0 0 24 24",children:(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}function nK(e){var t;let{server:n,isSelected:s=!1,onClick:a,onReconnect:l,compact:i=!1}=e,o=function(e){switch(e){case"online":return"#10b981";case"offline":return"#ef4444";case"degraded":return"#f59e0b";case"connecting":return"#6366f1";default:return"#888888"}}(n.status),c=function(e){switch(e){case"online":return"Online";case"offline":return"Offline";case"degraded":return"Degraded";case"connecting":return"Connecting...";default:return"Unknown"}}(n.status);return i?(0,r.jsxs)("button",{className:"\n flex items-center gap-2 py-2 px-3 bg-bg-tertiary border border-border-subtle rounded-md cursor-pointer font-inherit transition-all duration-150\n hover:bg-bg-hover\n ".concat(s?"bg-bg-elevated border-accent-cyan":"","\n ").concat("offline"===n.status?"opacity-70":"","\n "),onClick:a,children:[(0,r.jsx)("div",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:o}}),(0,r.jsx)("span",{className:"flex-1 text-sm font-medium text-text-primary text-left",children:n.name}),(0,r.jsx)("span",{className:"text-xs text-text-muted bg-bg-tertiary px-1.5 py-0.5 rounded-full",children:n.agentCount})]}):(0,r.jsxs)("div",{className:"\n bg-bg-card border border-border-subtle rounded-lg p-4 cursor-pointer transition-all duration-150\n hover:border-border-hover hover:shadow-md\n ".concat(s?"border-accent-cyan bg-bg-elevated":"","\n ").concat("offline"===n.status?"opacity-70":"","\n ").concat("degraded"===n.status?"border-l-[3px] border-l-warning":"","\n "),onClick:a,role:a?"button":void 0,tabIndex:a?0:void 0,children:[(0,r.jsxs)("div",{className:"flex items-start justify-between mb-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(nq,{}),(0,r.jsxs)("div",{className:"flex flex-col",children:[(0,r.jsx)("span",{className:"font-semibold text-sm text-text-primary",children:n.name}),n.region&&(0,r.jsx)("span",{className:"text-xs text-text-muted",children:n.region})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 text-xs font-medium",style:{color:o},children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full flex-shrink-0 ".concat("connecting"===n.status?"animate-pulse":""),style:{backgroundColor:o}}),(0,r.jsx)("span",{children:c})]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(60px,1fr))] gap-3 mb-4",children:[(0,r.jsxs)("div",{className:"flex flex-col items-center text-center",children:[(0,r.jsx)("span",{className:"text-lg font-semibold text-text-primary",children:n.agentCount}),(0,r.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wide",children:"Agents"})]}),void 0!==n.messageRate&&(0,r.jsxs)("div",{className:"flex flex-col items-center text-center",children:[(0,r.jsxs)("span",{className:"text-lg font-semibold text-text-primary",children:[n.messageRate,"/s"]}),(0,r.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wide",children:"Messages"})]}),void 0!==n.latency&&(0,r.jsxs)("div",{className:"flex flex-col items-center text-center",children:[(0,r.jsxs)("span",{className:"text-lg font-semibold text-text-primary",children:[n.latency,"ms"]}),(0,r.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wide",children:"Latency"})]}),void 0!==n.uptime&&(0,r.jsxs)("div",{className:"flex flex-col items-center text-center",children:[(0,r.jsx)("span",{className:"text-lg font-semibold text-text-primary",children:(t=n.uptime)<60?"".concat(t,"s"):t<3600?"".concat(Math.floor(t/60),"m"):t<86400?"".concat(Math.floor(t/3600),"h"):"".concat(Math.floor(t/86400),"d")}),(0,r.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wide",children:"Uptime"})]})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between pt-3 border-t border-border-subtle",children:[(0,r.jsx)("span",{className:"text-[11px] text-text-muted font-mono",children:n.url}),n.version&&(0,r.jsxs)("span",{className:"text-[11px] text-text-muted bg-bg-tertiary px-1.5 py-0.5 rounded",children:["v",n.version]})]}),"offline"===n.status&&l&&(0,r.jsxs)("button",{className:"flex items-center justify-center gap-1.5 w-full mt-3 py-2 px-3 bg-error/10 border border-error/30 rounded-md text-error text-xs font-medium cursor-pointer font-inherit transition-all duration-150 hover:bg-error/20 hover:border-error/50",onClick:e=>{e.stopPropagation(),l()},children:[(0,r.jsx)(nJ,{}),"Reconnect"]})]})}function nq(){return(0,r.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("rect",{x:"2",y:"2",width:"20",height:"8",rx:"2",ry:"2"}),(0,r.jsx)("rect",{x:"2",y:"14",width:"20",height:"8",rx:"2",ry:"2"}),(0,r.jsx)("line",{x1:"6",y1:"6",x2:"6.01",y2:"6"}),(0,r.jsx)("line",{x1:"6",y1:"18",x2:"6.01",y2:"18"})]})}function nJ(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("polyline",{points:"23 4 23 10 17 10"}),(0,r.jsx)("polyline",{points:"1 20 1 14 7 14"}),(0,r.jsx)("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]})}function n$(e){let{servers:t,agents:n,selectedServerId:a,onServerSelect:l,onServerReconnect:i,isLoading:o=!1}=e,[d,u]=(0,s.useState)("grid"),x=(0,s.useMemo)(()=>{let e=t.filter(e=>"online"===e.status).length,n=t.reduce((e,t)=>e+t.agentCount,0),r=t.filter(e=>void 0!==e.latency).length>0?Math.round(t.reduce((e,t)=>e+(t.latency||0),0)/t.filter(e=>void 0!==e.latency).length):null,s=t.reduce((e,t)=>e+(t.messageRate||0),0);return{online:e,total:t.length,totalAgents:n,avgLatency:r,totalMessages:s}},[t]),m=(0,s.useMemo)(()=>{let e={};return t.forEach(t=>{e[t.id]=[]}),n.forEach((n,r)=>{let s=r%t.length;t[s]&&e[t[s].id].push(n)}),e},[t,n]);return o?(0,r.jsxs)("div",{className:"bg-bg-card rounded-lg border border-border-subtle overflow-hidden flex flex-col items-center justify-center p-12 text-text-muted text-center",children:[(0,r.jsx)(n1,{}),(0,r.jsx)("span",{className:"mt-3 text-sm",children:"Loading fleet data..."})]}):0===t.length?(0,r.jsxs)("div",{className:"bg-bg-card rounded-lg border border-border-subtle overflow-hidden flex flex-col items-center justify-center p-12 text-text-muted text-center",children:[(0,r.jsx)(n0,{}),(0,r.jsx)("h3",{className:"mt-4 mb-2 text-base font-semibold text-text-primary",children:"No Fleet Servers"}),(0,r.jsx)("p",{className:"text-sm",children:"Connect to peer servers to enable fleet view"})]}):(0,r.jsxs)("div",{className:"bg-bg-card rounded-lg border border-border-subtle overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center gap-6 p-4 border-b border-border-subtle bg-bg-secondary",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 font-semibold text-sm text-text-primary",children:[(0,r.jsx)(nY,{}),(0,r.jsx)("span",{children:"Fleet Overview"})]}),(0,r.jsxs)("div",{className:"flex gap-6 flex-1",children:[(0,r.jsxs)("div",{className:"flex flex-col items-center",children:[(0,r.jsxs)("span",{className:"text-base font-semibold text-text-primary",children:[x.online,"/",x.total]}),(0,r.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wide",children:"Servers"})]}),(0,r.jsxs)("div",{className:"flex flex-col items-center",children:[(0,r.jsx)("span",{className:"text-base font-semibold text-text-primary",children:x.totalAgents}),(0,r.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wide",children:"Agents"})]}),null!==x.avgLatency&&(0,r.jsxs)("div",{className:"flex flex-col items-center",children:[(0,r.jsxs)("span",{className:"text-base font-semibold text-text-primary",children:[x.avgLatency,"ms"]}),(0,r.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wide",children:"Avg Latency"})]}),(0,r.jsxs)("div",{className:"flex flex-col items-center",children:[(0,r.jsxs)("span",{className:"text-base font-semibold text-text-primary",children:[x.totalMessages,"/s"]}),(0,r.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wide",children:"Messages"})]})]}),(0,r.jsxs)("div",{className:"flex gap-1 bg-bg-tertiary rounded-md p-0.5",children:[(0,r.jsx)("button",{className:"flex items-center justify-center w-7 h-7 bg-transparent border-none rounded cursor-pointer transition-all duration-150 ".concat("grid"===d?"bg-bg-card text-text-primary shadow-sm":"text-text-muted hover:text-text-secondary"),onClick:()=>u("grid"),title:"Grid view",children:(0,r.jsx)(nX,{})}),(0,r.jsx)("button",{className:"flex items-center justify-center w-7 h-7 bg-transparent border-none rounded cursor-pointer transition-all duration-150 ".concat("list"===d?"bg-bg-card text-text-primary shadow-sm":"text-text-muted hover:text-text-secondary"),onClick:()=>u("list"),title:"List view",children:(0,r.jsx)(nQ,{})})]})]}),(0,r.jsx)("div",{className:"flex h-1 bg-bg-tertiary",children:t.map(e=>(0,r.jsx)("div",{className:"transition-all duration-300 ".concat({online:"bg-success",offline:"bg-error",degraded:"bg-warning",connecting:"bg-accent-purple"}[e.status]||"bg-text-dim"),style:{flex:e.agentCount||1},title:"".concat(e.name,": ").concat(e.agentCount," agents")},e.id))}),(0,r.jsx)("div",{className:"p-4 ".concat("grid"===d?"grid grid-cols-[repeat(auto-fill,minmax(280px,1fr))] gap-4":"flex flex-col gap-2"),children:t.map(e=>{var t;return(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsx)(nK,{server:e,isSelected:e.id===a,onClick:()=>null==l?void 0:l(e.id),onReconnect:()=>null==i?void 0:i(e.id),compact:"list"===d}),"grid"===d&&(null===(t=m[e.id])||void 0===t?void 0:t.length)>0&&(0,r.jsxs)("div",{className:"flex gap-1 px-2",children:[m[e.id].slice(0,5).map((e,t)=>{let n=(0,c.GW)(e.name);return(0,r.jsx)("div",{className:"w-6 h-6 rounded-md flex items-center justify-center text-[9px] font-semibold border-2 border-bg-card",style:{backgroundColor:n.primary,color:n.text,marginLeft:t>0?"-4px":0},title:e.name,children:(0,c.hP)(e.name)},e.name)}),m[e.id].length>5&&(0,r.jsxs)("div",{className:"w-6 h-6 rounded-md flex items-center justify-center text-[9px] font-semibold bg-bg-tertiary text-text-muted border-2 border-bg-card",style:{marginLeft:"-4px"},children:["+",m[e.id].length-5]})]})]},e.id)})})]})}function nY(){return(0,r.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2"}),(0,r.jsx)("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),(0,r.jsx)("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]})}function nX(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("rect",{x:"3",y:"3",width:"7",height:"7"}),(0,r.jsx)("rect",{x:"14",y:"3",width:"7",height:"7"}),(0,r.jsx)("rect",{x:"3",y:"14",width:"7",height:"7"}),(0,r.jsx)("rect",{x:"14",y:"14",width:"7",height:"7"})]})}function nQ(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("line",{x1:"8",y1:"6",x2:"21",y2:"6"}),(0,r.jsx)("line",{x1:"8",y1:"12",x2:"21",y2:"12"}),(0,r.jsx)("line",{x1:"8",y1:"18",x2:"21",y2:"18"}),(0,r.jsx)("line",{x1:"3",y1:"6",x2:"3.01",y2:"6"}),(0,r.jsx)("line",{x1:"3",y1:"12",x2:"3.01",y2:"12"}),(0,r.jsx)("line",{x1:"3",y1:"18",x2:"3.01",y2:"18"})]})}function n0(){return(0,r.jsxs)("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("rect",{x:"2",y:"2",width:"20",height:"8",rx:"2",ry:"2"}),(0,r.jsx)("rect",{x:"2",y:"14",width:"20",height:"8",rx:"2",ry:"2"}),(0,r.jsx)("line",{x1:"6",y1:"6",x2:"6.01",y2:"6"}),(0,r.jsx)("line",{x1:"6",y1:"18",x2:"6.01",y2:"18"})]})}function n1(){return(0,r.jsx)("svg",{className:"animate-spin",width:"24",height:"24",viewBox:"0 0 24 24",children:(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}function n2(e){let{typingUsers:t}=e;return 0===t.length?null:(0,r.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 text-sm text-[#8d8d8e]",children:[(0,r.jsx)("div",{className:"flex -space-x-1.5",children:t.slice(0,3).map(e=>(0,r.jsx)("div",{className:"relative",title:e.username,children:e.avatarUrl?(0,r.jsx)("img",{src:e.avatarUrl,alt:e.username,className:"w-5 h-5 rounded-full border border-[#1a1d21]"}):(0,r.jsx)("div",{className:"w-5 h-5 rounded-full bg-[#a855f7] border border-[#1a1d21] flex items-center justify-center text-[9px] text-white font-medium",children:e.username.charAt(0).toUpperCase()})},e.username))}),(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[1===t.length?"".concat(t[0].username," is typing"):2===t.length?"".concat(t[0].username," and ").concat(t[1].username," are typing"):"".concat(t[0].username," and ").concat(t.length-1," others are typing"),(0,r.jsxs)("span",{className:"flex gap-0.5",children:[(0,r.jsx)("span",{className:"w-1 h-1 bg-[#8d8d8e] rounded-full animate-bounce",style:{animationDelay:"0ms"}}),(0,r.jsx)("span",{className:"w-1 h-1 bg-[#8d8d8e] rounded-full animate-bounce",style:{animationDelay:"150ms"}}),(0,r.jsx)("span",{className:"w-1 h-1 bg-[#8d8d8e] rounded-full animate-bounce",style:{animationDelay:"300ms"}})]})]})]})}var n5=n(3910);function n4(e){let{onlineUsers:t,onUserClick:n,maxAvatars:a=4}=e,[l,i]=(0,s.useState)(!1),o=(0,s.useRef)(null);if((0,s.useEffect)(()=>{let e=e=>{o.current&&!o.current.contains(e.target)&&i(!1)};return l&&document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[l]),0===t.length)return null;let c=t.slice(0,a),d=Math.max(0,t.length-a);return(0,r.jsxs)("div",{className:"relative",ref:o,children:[(0,r.jsxs)("button",{onClick:()=>i(!l),className:"flex items-center gap-1.5 px-2 py-1 rounded-md hover:bg-white/[0.05] transition-colors",title:"".concat(t.length," user").concat(1!==t.length?"s":""," online"),children:[(0,r.jsx)("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),(0,r.jsxs)("div",{className:"flex -space-x-1.5",children:[c.map(e=>(0,r.jsx)("div",{className:"relative ring-2 ring-[#1a1d21] rounded-full",title:e.username,children:e.avatarUrl?(0,r.jsx)("img",{src:e.avatarUrl,alt:e.username,className:"w-6 h-6 rounded-full object-cover"}):(0,r.jsx)("div",{className:"w-6 h-6 rounded-full bg-[#a855f7] flex items-center justify-center text-[10px] text-white font-medium",children:e.username.charAt(0).toUpperCase()})},e.username)),d>0&&(0,r.jsxs)("div",{className:"w-6 h-6 rounded-full bg-[#3d4043] ring-2 ring-[#1a1d21] flex items-center justify-center text-[10px] text-[#d1d2d3] font-medium",children:["+",d]})]}),(0,r.jsxs)("span",{className:"text-xs text-[#8d8d8e]",children:[t.length," online"]})]}),l&&(0,r.jsxs)("div",{className:"absolute right-0 top-full mt-1 w-64 bg-[#1a1d21] border border-white/10 rounded-lg shadow-xl z-50 max-h-[300px] overflow-y-auto",children:[(0,r.jsx)("div",{className:"p-2 border-b border-white/10",children:(0,r.jsx)("h3",{className:"text-sm font-medium text-[#d1d2d3]",children:"Online Users"})}),(0,r.jsx)("div",{className:"py-1",children:t.map(e=>(0,r.jsxs)("button",{onClick:()=>{null==n||n(e),i(!1)},className:"w-full flex items-center gap-3 px-3 py-2 hover:bg-white/[0.05] transition-colors text-left",children:[(0,r.jsxs)("div",{className:"relative",children:[e.avatarUrl?(0,r.jsx)("img",{src:e.avatarUrl,alt:e.username,className:"w-8 h-8 rounded-full object-cover"}):(0,r.jsx)("div",{className:"w-8 h-8 rounded-full bg-[#a855f7] flex items-center justify-center text-xs text-white font-medium",children:e.username.charAt(0).toUpperCase()}),(0,r.jsx)("div",{className:"absolute -bottom-0.5 -right-0.5 w-3 h-3 bg-green-500 rounded-full border-2 border-[#1a1d21]"})]}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("div",{className:"text-sm font-medium text-[#d1d2d3] truncate",children:e.username}),(0,r.jsxs)("div",{className:"text-xs text-[#8d8d8e]",children:["Online since ",function(e){let t=new Date(e),n=new Date;return t.toDateString()===n.toDateString()?t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):t.toLocaleDateString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}(e.connectedAt)]})]})]},e.username))})]})]})}function n3(e){let{user:t,onClose:n,onMention:a,onSendMessage:l}=e,i=(0,s.useRef)(null);(0,s.useEffect)(()=>{let e=e=>{"Escape"===e.key&&n()};return t&&window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,n]);let o=(0,s.useRef)(!1);if((0,s.useEffect)(()=>{t&&(o.current=!0)},[t]),(0,s.useEffect)(()=>{let e=e=>{if(o.current){o.current=!1;return}i.current&&!i.current.contains(e.target)&&n()};if(t)return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[t,n]),!t)return null;let c="https://github.com/".concat(t.username);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"fixed inset-0 bg-black/50 z-40"}),(0,r.jsxs)("div",{ref:i,className:"fixed right-0 top-0 h-full w-80 bg-[#1a1d21] border-l border-white/10 shadow-2xl z-50 flex flex-col animate-slide-in-right",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-white/10",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold text-[#d1d2d3]",children:"Profile"}),(0,r.jsx)("button",{onClick:n,className:"p-1 hover:bg-white/10 rounded-md transition-colors",title:"Close",children:(0,r.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),(0,r.jsxs)("div",{className:"flex flex-col items-center p-6 border-b border-white/10",children:[(0,r.jsxs)("div",{className:"relative mb-4",children:[t.avatarUrl?(0,r.jsx)("img",{src:t.avatarUrl,alt:t.username,className:"w-24 h-24 rounded-full object-cover border-4 border-[#a855f7]/30"}):(0,r.jsx)("div",{className:"w-24 h-24 rounded-full bg-[#a855f7] flex items-center justify-center text-3xl text-white font-bold border-4 border-[#a855f7]/30",children:t.username.charAt(0).toUpperCase()}),(0,r.jsx)("div",{className:"absolute bottom-1 right-1 w-5 h-5 bg-green-500 rounded-full border-4 border-[#1a1d21]"})]}),(0,r.jsx)("h3",{className:"text-xl font-semibold text-[#d1d2d3] mb-1",children:t.username}),(0,r.jsxs)("span",{className:"text-sm text-green-400 flex items-center gap-1.5",children:[(0,r.jsx)("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),"Online"]})]}),(0,r.jsx)("div",{className:"flex-1 p-4 overflow-y-auto",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"Online Since"}),(0,r.jsx)("p",{className:"text-sm text-[#d1d2d3] mt-1",children:n6(t.connectedAt)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"Last Active"}),(0,r.jsx)("p",{className:"text-sm text-[#d1d2d3] mt-1",children:n6(t.lastSeen)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"GitHub"}),(0,r.jsxs)("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 mt-1 text-sm text-[#a855f7] hover:text-[#c084fc] transition-colors",children:[(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:(0,r.jsx)("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"})}),"@",t.username,(0,r.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("path",{d:"M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6M15 3h6v6M10 14L21 3"})})]})]})]})}),(0,r.jsxs)("div",{className:"p-4 border-t border-white/10 space-y-2",children:[(0,r.jsxs)("button",{onClick:()=>{null==l||l(t),n()},className:"w-full flex items-center justify-center gap-2 py-2.5 bg-[#00d4aa] hover:bg-[#00bfa0] text-[#0a0e14] font-medium rounded-lg transition-colors",children:[(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),"Send Message"]}),(0,r.jsxs)("button",{onClick:()=>{null==a||a(t.username),n()},className:"w-full flex items-center justify-center gap-2 py-2.5 bg-[#a855f7] hover:bg-[#9333ea] text-white font-medium rounded-lg transition-colors",children:[(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"4"}),(0,r.jsx)("path",{d:"M16 8v5a3 3 0 006 0v-1a10 10 0 10-3.92 7.94"})]}),"Mention @",t.username]}),(0,r.jsxs)("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"w-full flex items-center justify-center gap-2 py-2.5 border border-white/20 text-[#d1d2d3] hover:bg-white/5 font-medium rounded-lg transition-colors",children:[(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:(0,r.jsx)("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"})}),"View on GitHub"]})]})]})]})}function n6(e){return new Date(e).toLocaleString([],{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}let n8={claude:{label:"Claude",color:"#00d9ff",icon:"\uD83E\uDD16"},codex:{label:"Codex",color:"#10a37f",icon:"\uD83E\uDDE0"},gemini:{label:"Gemini",color:"#4285f4",icon:"✨"},droid:{label:"Droid",color:"#ff6b35",icon:"\uD83E\uDD16"},opencode:{label:"OpenCode",color:"#a855f7",icon:"\uD83D\uDCBB"},cursor:{label:"Cursor",color:"#00b4d8",icon:"\uD83D\uDDB1️"},other:{label:"AI Agent",color:"#8d8d8e",icon:"\uD83E\uDD16"}},n9={agent:"cursor"};function n7(e){var t;let{agent:n,onClose:a,onMessage:l,onLogs:i,onRelease:o,summary:d}=e,m=(0,s.useRef)(null),[h,p]=(0,s.useState)(!1),[g,f]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let e=e=>{"Escape"===e.key&&a()};return n&&window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[n,a]);let b=(0,s.useRef)(!1);if((0,s.useEffect)(()=>{n&&(b.current=!0,p(!1),f(!1))},[n]),(0,s.useEffect)(()=>{let e=e=>{if(b.current){b.current=!1;return}m.current&&!m.current.contains(e.target)&&a()};if(n)return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[n,a]),!n)return null;let v=(0,c.GW)(n.name),y=(0,c.hP)(n.name),j=u(n.name),w=x(n.name),N=c.yh[n.status]||c.yh.offline,k="online"===n.status,C=n.profile;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"fixed inset-0 bg-black/50 z-40"}),(0,r.jsxs)("div",{ref:m,className:"fixed right-0 top-0 h-full w-96 bg-[#1a1d21] border-l border-white/10 shadow-2xl z-50 flex flex-col animate-slide-in-right",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-white/10",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold text-[#d1d2d3]",children:"Agent Profile"}),(0,r.jsx)("button",{onClick:a,className:"p-1 hover:bg-white/10 rounded-md transition-colors text-[#d1d2d3]",title:"Close",children:(0,r.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),(0,r.jsxs)("div",{className:"flex flex-col items-center p-6 border-b border-white/10",children:[(0,r.jsxs)("div",{className:"relative mb-4",children:[(0,r.jsx)("div",{className:"w-24 h-24 rounded-2xl flex items-center justify-center text-3xl font-bold shadow-lg",style:{background:"linear-gradient(135deg, ".concat(v.primary,", ").concat(v.primary,"99)"),boxShadow:k?"0 4px 20px ".concat(v.primary,"50"):"none"},children:(0,r.jsx)("span",{style:{color:v.text},children:y})}),(0,r.jsx)("div",{className:"absolute bottom-1 right-1 w-5 h-5 rounded-full border-4 border-[#1a1d21] ".concat(k?"animate-pulse":""),style:{backgroundColor:N,boxShadow:k?"0 0 8px ".concat(N):"none"}})]}),(0,r.jsx)("h3",{className:"text-xl font-semibold text-[#d1d2d3] mb-1",children:j}),w&&(0,r.jsx)("span",{className:"text-sm text-[#8d8d8e] font-mono mb-2",children:w}),(null==C?void 0:C.title)&&(0,r.jsx)("span",{className:"text-sm text-[#a855f7] font-medium mb-2",children:C.title}),(0,r.jsxs)("span",{className:"text-sm flex items-center gap-1.5",style:{color:N},children:[(0,r.jsx)("div",{className:"w-2 h-2 rounded-full ".concat(k?"animate-pulse":""),style:{backgroundColor:N}}),n.status.charAt(0).toUpperCase()+n.status.slice(1),n.isProcessing&&" - Thinking..."]}),n.cli&&(()=>{let e=n.cli.toLowerCase(),t=n8[n9[e]||e]||n8.other;return(0,r.jsxs)("div",{className:"flex items-center gap-3 mt-3 px-3 py-2.5 rounded-lg border",style:{borderColor:"".concat(t.color,"40"),backgroundColor:"".concat(t.color,"10")},children:[(0,r.jsx)("span",{className:"text-lg",children:t.icon}),(0,r.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,r.jsx)("span",{className:"text-sm font-medium",style:{color:t.color},children:t.label}),(n.model||(null==C?void 0:C.model))&&(0,r.jsx)("span",{className:"text-[11px] font-mono px-1.5 py-0.5 rounded w-fit",style:{color:t.color,backgroundColor:"".concat(t.color,"15")},children:n.model||(null==C?void 0:C.model)})]})]})})(),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2 mt-3",children:[n.isSpawned&&(0,r.jsx)("span",{className:"text-xs bg-[#a855f7]/20 text-[#a855f7] px-2 py-1 rounded uppercase font-medium",children:"Spawned"}),n.team&&(0,r.jsx)("span",{className:"text-xs bg-[#00d9ff]/20 text-[#00d9ff] px-2 py-1 rounded",children:n.team}),(null==C?void 0:C.personaName)&&(0,r.jsx)("span",{className:"text-xs bg-[#10b981]/20 text-[#10b981] px-2 py-1 rounded",children:C.personaName})]})]}),(0,r.jsx)("div",{className:"flex-1 p-4 overflow-y-auto",children:(0,r.jsxs)("div",{className:"space-y-4",children:[d&&((null===(t=d.completedTasks)||void 0===t?void 0:t.length)||d.currentTask||d.context)&&(0,r.jsxs)("div",{className:"bg-[#1e2024] border border-[#00d9ff]/20 rounded-lg p-3",children:[(0,r.jsxs)("label",{className:"text-xs text-[#00d9ff] uppercase tracking-wide font-medium flex items-center gap-1.5 mb-2",children:[(0,r.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("path",{d:"M3 12h4l3 9 4-18 3 9h4"})}),"Recent Work"]}),d.currentTask&&(0,r.jsxs)("div",{className:"mb-2",children:[(0,r.jsx)("span",{className:"text-xs text-[#8d8d8e]",children:"Working on:"}),(0,r.jsx)("p",{className:"text-sm text-[#d1d2d3] mt-0.5 bg-[#2a2d31] p-2 rounded",children:d.currentTask})]}),d.completedTasks&&d.completedTasks.length>0&&(0,r.jsxs)("div",{className:"mb-2",children:[(0,r.jsx)("span",{className:"text-xs text-[#8d8d8e]",children:"Completed:"}),(0,r.jsxs)("ul",{className:"mt-1 space-y-1",children:[d.completedTasks.slice(0,5).map((e,t)=>(0,r.jsxs)("li",{className:"text-xs text-[#d1d2d3] flex items-start gap-1.5",children:[(0,r.jsx)("span",{className:"text-[#10b981] mt-0.5",children:"✓"}),(0,r.jsx)("span",{children:e})]},t)),d.completedTasks.length>5&&(0,r.jsxs)("li",{className:"text-xs text-[#8d8d8e]",children:["+",d.completedTasks.length-5," more..."]})]})]}),d.context&&(0,r.jsxs)("div",{className:"mb-2",children:[(0,r.jsx)("span",{className:"text-xs text-[#8d8d8e]",children:"Context:"}),(0,r.jsx)("p",{className:"text-xs text-[#a0a0b0] mt-0.5 italic",children:d.context})]}),d.files&&d.files.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-xs text-[#8d8d8e]",children:"Files:"}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-1 mt-1",children:[d.files.slice(0,6).map((e,t)=>(0,r.jsx)("span",{className:"text-[10px] font-mono bg-[#2a2d31] text-[#a855f7] px-1.5 py-0.5 rounded",title:e,children:e.split("/").pop()},t)),d.files.length>6&&(0,r.jsxs)("span",{className:"text-[10px] text-[#8d8d8e]",children:["+",d.files.length-6]})]})]}),d.lastUpdated&&(0,r.jsx)("div",{className:"mt-2 pt-2 border-t border-[#2a2d31]",children:(0,r.jsxs)("span",{className:"text-[10px] text-[#606070]",children:["Updated ",function(e){let t=new Date(e),n=Math.floor((new Date().getTime()-t.getTime())/1e3),r=Math.floor(n/60),s=Math.floor(r/60),a=Math.floor(s/24);return n<60?"just now":r<60?"".concat(r," min ago"):s<24?"".concat(s," hr ago"):a<7?"".concat(a," day").concat(a>1?"s":""," ago"):re(e)}(d.lastUpdated)]})})]}),(null==C?void 0:C.description)&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"Description"}),(0,r.jsx)("p",{className:"text-sm text-[#d1d2d3] mt-1",children:C.description})]}),n.currentTask&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"Current Task"}),(0,r.jsx)("p",{className:"text-sm text-[#d1d2d3] mt-1 bg-[#2a2d31] p-2 rounded",children:n.currentTask})]}),(null==C?void 0:C.spawnPrompt)&&(0,r.jsxs)("div",{children:[(0,r.jsxs)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide flex items-center justify-between",children:[(0,r.jsx)("span",{children:"Spawn Prompt"}),C.spawnPrompt.length>200&&(0,r.jsx)("button",{onClick:()=>p(!h),className:"text-[#a855f7] hover:text-[#c084fc] text-xs font-normal",children:h?"Show less":"Show more"})]}),(0,r.jsx)("pre",{className:"text-sm text-[#d1d2d3] mt-1 bg-[#2a2d31] p-3 rounded font-mono whitespace-pre-wrap ".concat(!h&&C.spawnPrompt.length>200?"line-clamp-4":""),children:C.spawnPrompt})]}),(null==C?void 0:C.personaPrompt)&&(0,r.jsxs)("div",{children:[(0,r.jsxs)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide flex items-center justify-between",children:[(0,r.jsx)("span",{children:"Agent Persona"}),C.personaPrompt.length>200&&(0,r.jsx)("button",{onClick:()=>f(!g),className:"text-[#a855f7] hover:text-[#c084fc] text-xs font-normal",children:g?"Show less":"Show more"})]}),(0,r.jsx)("pre",{className:"text-sm text-[#d1d2d3] mt-1 bg-[#2a2d31] p-3 rounded font-mono whitespace-pre-wrap ".concat(!g&&C.personaPrompt.length>200?"line-clamp-4":""),children:C.personaPrompt})]}),(n.model||(null==C?void 0:C.model))&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"Model"}),(0,r.jsx)("p",{className:"text-sm text-[#d1d2d3] mt-1 font-mono",children:n.model||(null==C?void 0:C.model)})]}),(null==C?void 0:C.workingDirectory)&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"Working Directory"}),(0,r.jsx)("p",{className:"text-sm text-[#d1d2d3] mt-1 font-mono bg-[#2a2d31] p-2 rounded truncate",title:C.workingDirectory,children:C.workingDirectory})]}),n.agentId&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"Agent ID"}),(0,r.jsx)("p",{className:"text-sm text-[#d1d2d3] mt-1 font-mono bg-[#2a2d31] p-2 rounded",children:n.agentId})]}),(null==C?void 0:C.capabilities)&&C.capabilities.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"Capabilities"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-1",children:C.capabilities.map((e,t)=>(0,r.jsx)("span",{className:"text-xs bg-[#2a2d31] text-[#d1d2d3] px-2 py-1 rounded",children:e},t))})]}),n.lastSeen&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"Last Seen"}),(0,r.jsx)("p",{className:"text-sm text-[#d1d2d3] mt-1",children:re(n.lastSeen)})]}),(null==C?void 0:C.firstSeen)&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"First Seen"}),(0,r.jsx)("p",{className:"text-sm text-[#d1d2d3] mt-1",children:re(C.firstSeen)})]}),void 0!==n.messageCount&&n.messageCount>0&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"Messages"}),(0,r.jsxs)("p",{className:"text-sm text-[#d1d2d3] mt-1",children:[n.messageCount," messages sent"]})]})]})}),(0,r.jsxs)("div",{className:"p-4 border-t border-white/10 space-y-2",children:[l&&(0,r.jsxs)("button",{onClick:()=>{l(n),a()},className:"w-full flex items-center justify-center gap-2 py-2.5 bg-[#a855f7] hover:bg-[#9333ea] text-white font-medium rounded-lg transition-colors",children:[(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),"Send Message"]}),n.isSpawned&&i&&(0,r.jsxs)("button",{onClick:()=>{i(n),a()},className:"w-full flex items-center justify-center gap-2 py-2.5 border border-[#00d9ff]/30 text-[#00d9ff] hover:bg-[#00d9ff]/10 font-medium rounded-lg transition-colors",children:[(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("polyline",{points:"4 17 10 11 4 5"}),(0,r.jsx)("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]}),"View Logs"]}),n.isSpawned&&o&&(0,r.jsxs)("button",{onClick:()=>{confirm("Are you sure you want to release ".concat(j,"?"))&&(o(n),a())},className:"w-full flex items-center justify-center gap-2 py-2.5 border border-[#ff6b6b]/30 text-[#ff6b6b] hover:bg-[#ff6b6b]/10 font-medium rounded-lg transition-colors",children:[(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),(0,r.jsx)("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),"Release Agent"]})]})]})]})}function re(e){return new Date(e).toLocaleString([],{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function rt(e){let{isOpen:t,onClose:n,projects:a,hasArchitect:l=!1,onArchitectSpawned:i}=e,{features:o}=(0,tc.u0)(),c=o.workspaces,[d,u]=(0,s.useState)([]),[x,m]=(0,s.useState)([]),[h,p]=(0,s.useState)(!1),[g,f]=(0,s.useState)(null),[b,v]=(0,s.useState)(!1),[y,j]=(0,s.useState)(""),[w,N]=(0,s.useState)(""),[k,C]=(0,s.useState)(new Set),[S,M]=(0,s.useState)(!1),[L,D]=(0,s.useState)("claude"),[A,E]=(0,s.useState)(null),[T,W]=(0,s.useState)(null),[P,I]=(0,s.useState)(new Set),B=()=>{let e=(0,tZ._V)();return e?{"X-CSRF-Token":e}:{}};(0,s.useEffect)(()=>{t&&c&&_()},[t,c]);let _=async()=>{if(c){p(!0),f(null);try{let e=await fetch("/api/project-groups");if(e.ok){let t=await e.json();u(t.groups||[]),m(t.ungroupedRepositories||[])}else{let t=await e.json().catch(()=>({}));f(t.error||"Failed to load project groups")}}catch(e){f("Failed to load project groups")}finally{p(!1)}}},R=async()=>{if(y.trim()&&0!==k.size){p(!0),f(null);try{let e=await fetch("/api/project-groups",{method:"POST",headers:{"Content-Type":"application/json",...B()},body:JSON.stringify({name:y.trim(),description:w.trim()||void 0,repositoryIds:Array.from(k)})});if(e.ok){let t=await e.json();t.group&&(u(e=>[...e,t.group]),m(e=>e.filter(e=>!k.has(e.id))),v(!1),j(""),N(""),C(new Set))}else{let t=await e.json().catch(()=>({}));f(t.error||"Failed to create project group")}}catch(e){f("Failed to create project group")}finally{p(!1)}}},F=async(e,t)=>{f(null);try{let n=await fetch("/api/project-groups/".concat(e),{method:"PATCH",headers:{"Content-Type":"application/json",...B()},body:JSON.stringify(t)});if(n.ok){let t=await n.json();t.group&&(u(n=>n.map(n=>n.id===e?{...n,...t.group}:n)),E(null))}else{let e=await n.json().catch(()=>({}));f(e.error||"Failed to update project group")}}catch(e){f("Failed to update project group")}},U=async(e,t)=>{f(null);try{let n="/api/project-groups/".concat(e,"/coordinator/").concat(t?"enable":"disable"),r=await fetch(n,{method:"POST",headers:B()});if(r.ok){let n=await r.json();u(r=>r.map(r=>{var s,a;return r.id===e?{...r,coordinatorAgent:{...r.coordinatorAgent,enabled:t,name:(null===(s=n.coordinator)||void 0===s?void 0:s.name)||(null===(a=r.coordinatorAgent)||void 0===a?void 0:a.name)}}:r}))}else{let e=await r.json().catch(()=>({}));402===r.status&&e.upgrade?f("".concat(e.error,". Go to Settings > Billing to upgrade.")):f(e.error||"Failed to ".concat(t?"enable":"disable"," coordinator"))}}catch(e){f("Failed to ".concat(t?"enable":"disable"," coordinator"))}},O=async e=>{if(window.confirm("Delete this project group? The coordinator will be stopped and repositories will be ungrouped."))try{let t=d.find(t=>t.id===e),n=await fetch("/api/project-groups/".concat(e),{method:"DELETE",headers:B()});if(n.ok)u(t=>t.filter(t=>t.id!==e)),(null==t?void 0:t.repositories)&&m(e=>[...e,...t.repositories]);else{let e=await n.json().catch(()=>({}));f(e.error||"Failed to delete project group")}}catch(e){f("Failed to delete project group")}},H=async(e,t)=>{try{let n=await fetch("/api/project-groups/".concat(e,"/repositories/").concat(t),{method:"DELETE",headers:B()});if(n.ok){let n=d.find(t=>t.id===e),r=null==n?void 0:n.repositories.find(e=>e.id===t);u(n=>n.map(n=>n.id===e?{...n,repositories:n.repositories.filter(e=>e.id!==t),repositoryCount:n.repositoryCount-1}:n)),r&&m(e=>[...e,r])}else{let e=await n.json().catch(()=>({}));f(e.error||"Failed to remove repository from group")}}catch(e){f("Failed to remove repository from group")}},z=async(e,t)=>{if(0!==t.length)try{let n=await fetch("/api/project-groups/".concat(e,"/repositories"),{method:"POST",headers:{"Content-Type":"application/json",...B()},body:JSON.stringify({repositoryIds:t})});if(n.ok)await _(),W(null),I(new Set);else{let e=await n.json().catch(()=>({}));f(e.error||"Failed to add repositories to group")}}catch(e){f("Failed to add repositories to group")}},G=e=>{I(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},V=e=>{C(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};if(!t)return null;let Z=async()=>{M(!0),f(null);try{let e=await fetch("/api/spawn/architect",{method:"POST",headers:{"Content-Type":"application/json",...B()},body:JSON.stringify({cli:L})}),t=await e.json();e.ok&&t.success?(null==i||i(),n()):f(t.error||"Failed to spawn Architect")}catch(e){f("Failed to spawn Architect")}finally{M(!1)}};if(!c){let e=a.length>1;return(0,r.jsx)("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[1000] animate-fade-in",onClick:n,children:(0,r.jsxs)("div",{className:"bg-bg-secondary rounded-xl w-[500px] max-w-[90vw] max-h-[80vh] flex flex-col shadow-modal animate-slide-up",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between py-5 px-6 border-b border-border-subtle",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(rs,{}),(0,r.jsx)("h2",{className:"m-0 text-lg font-semibold text-text-primary",children:"Coordinator Agent"})]}),(0,r.jsx)("button",{className:"flex items-center justify-center w-8 h-8 bg-transparent border-none rounded-md text-text-secondary cursor-pointer transition-all duration-150 hover:bg-bg-hover hover:text-text-primary",onClick:n,children:(0,r.jsx)(ra,{})})]}),(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto p-6",children:[g&&(0,r.jsx)("div",{className:"bg-error/10 border border-error/30 rounded-lg p-3 mb-4 text-error text-sm",children:g}),e&&(0,r.jsxs)("div",{className:"bg-gradient-to-r from-accent-purple/10 to-accent-cyan/10 border border-accent-purple/30 rounded-lg p-4 mb-4",children:[(0,r.jsxs)("h3",{className:"text-sm font-semibold text-text-primary mb-3 flex items-center gap-2",children:[(0,r.jsx)(rs,{}),"Spawn Architect"]}),l?(0,r.jsxs)("div",{className:"flex items-center gap-2 text-sm text-success",children:[(0,r.jsx)(rd,{}),"Architect is running"]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("p",{className:"text-sm text-text-secondary mb-4",children:["Spawn an Architect agent to coordinate across your ",a.length," connected projects."]}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsxs)("select",{className:"flex-1 py-2 px-3 bg-bg-card border border-border-subtle rounded-md text-sm text-text-primary outline-none focus:border-accent-purple/50",value:L,onChange:e=>D(e.target.value),children:[(0,r.jsx)("option",{value:"claude",children:"Claude (default)"}),(0,r.jsx)("option",{value:"claude:opus",children:"Claude Opus"}),(0,r.jsx)("option",{value:"claude:sonnet",children:"Claude Sonnet"}),(0,r.jsx)("option",{value:"codex",children:"Codex"})]}),(0,r.jsx)("button",{className:"py-2 px-4 bg-gradient-to-r from-accent-purple to-accent-cyan text-bg-deep rounded-md text-sm font-semibold hover:shadow-lg transition-all disabled:opacity-50",onClick:Z,disabled:S,children:S?"Spawning...":"Spawn"})]})]})]}),!e&&(0,r.jsxs)("div",{className:"bg-bg-tertiary rounded-lg p-4 mb-4 border border-border-subtle",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-primary mb-2",children:"Not in Bridge Mode"}),(0,r.jsx)("p",{className:"text-sm text-text-secondary",children:"The Architect coordinates multiple projects. Start bridge mode to enable:"}),(0,r.jsxs)("div",{className:"bg-bg-card rounded-lg p-3 font-mono text-sm mt-3",children:[(0,r.jsx)("span",{className:"text-text-muted",children:"$"})," ",(0,r.jsx)("span",{className:"text-accent-cyan",children:"relay bridge"})," ",(0,r.jsx)("span",{className:"text-accent-orange",children:"~/project1 ~/project2"})]})]}),(0,r.jsxs)("div",{className:"bg-bg-tertiary rounded-lg p-4 mb-4",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-text-primary mb-2",children:"CLI Alternative"}),(0,r.jsxs)("p",{className:"text-sm text-text-secondary mb-3",children:["You can also spawn the Architect via CLI with the ",(0,r.jsx)("code",{className:"bg-bg-card px-1.5 py-0.5 rounded text-accent-cyan",children:"--architect"})," flag:"]}),(0,r.jsxs)("div",{className:"bg-bg-card rounded-lg p-3 font-mono text-sm",children:[(0,r.jsx)("span",{className:"text-text-muted",children:"$"})," ",(0,r.jsx)("span",{className:"text-accent-cyan",children:"relay bridge"})," ",(0,r.jsx)("span",{className:"text-accent-orange",children:"~/project1 ~/project2"})," ",(0,r.jsx)("span",{className:"text-accent-purple",children:"--architect"})]})]})]}),(0,r.jsx)("div",{className:"flex justify-end py-4 px-6 border-t border-border-subtle",children:(0,r.jsx)("button",{className:"py-2 px-5 bg-bg-tertiary border border-border-subtle rounded-md text-sm text-text-secondary cursor-pointer transition-colors duration-150 hover:bg-bg-hover",onClick:n,children:"Close"})})]})})}return(0,r.jsx)("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[1000] animate-fade-in",onClick:n,children:(0,r.jsxs)("div",{className:"bg-bg-secondary rounded-xl w-[600px] max-w-[90vw] max-h-[80vh] flex flex-col shadow-modal animate-slide-up",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between py-5 px-6 border-b border-border-subtle",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(rs,{}),(0,r.jsx)("h2",{className:"m-0 text-lg font-semibold text-text-primary",children:"Coordinator Agents"})]}),(0,r.jsx)("button",{className:"flex items-center justify-center w-8 h-8 bg-transparent border-none rounded-md text-text-secondary cursor-pointer transition-all duration-150 hover:bg-bg-hover hover:text-text-primary",onClick:n,children:(0,r.jsx)(ra,{})})]}),(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto p-6",children:[g&&(0,r.jsx)("div",{className:"bg-error/10 border border-error/30 rounded-lg p-3 mb-4 text-error text-sm",children:g}),h&&0===d.length?(0,r.jsx)("div",{className:"flex items-center justify-center py-12 text-text-muted",children:(0,r.jsx)(rr,{})}):(0,r.jsxs)(r.Fragment,{children:[d.length>0&&(0,r.jsxs)("div",{className:"space-y-3 mb-6",children:[(0,r.jsx)("h4",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"Project Groups"}),d.map(e=>{var t,n,s,a;return(0,r.jsxs)("div",{className:"bg-bg-tertiary rounded-lg p-4 border border-border-subtle",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"font-semibold text-text-primary",children:e.name}),(0,r.jsxs)("span",{className:"text-xs text-text-muted",children:[e.repositoryCount," ",1===e.repositoryCount?"repo":"repos"]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("button",{className:"text-text-muted hover:text-accent-cyan transition-colors p-1",onClick:()=>E(e),title:"Edit group",children:(0,r.jsx)(rl,{})}),(0,r.jsx)("button",{className:"text-text-muted hover:text-error transition-colors p-1",onClick:()=>O(e.id),title:"Delete group",children:(0,r.jsx)(ro,{})})]})]}),e.repositories.length>0&&(0,r.jsx)("div",{className:"mb-3 space-y-1",children:e.repositories.map(t=>(0,r.jsxs)("div",{className:"flex items-center justify-between py-1 px-2 bg-bg-card/50 rounded text-xs",children:[(0,r.jsx)("span",{className:"text-text-secondary font-mono",children:t.githubFullName}),(0,r.jsx)("button",{className:"text-text-muted hover:text-error transition-colors p-0.5",onClick:()=>H(e.id,t.id),title:"Remove from group",children:(0,r.jsx)(ra,{size:12})})]},t.id))}),e.description&&(0,r.jsx)("p",{className:"text-xs text-text-muted mb-3",children:e.description}),T===e.id?(0,r.jsxs)("div",{className:"mb-3 p-3 bg-bg-card rounded-lg border border-border-subtle",children:[(0,r.jsx)("div",{className:"text-xs font-medium text-text-muted mb-2",children:"Select repositories to add:"}),(0,r.jsx)("div",{className:"space-y-1 max-h-[150px] overflow-y-auto mb-3",children:x.length>0?x.map(e=>(0,r.jsxs)("label",{className:"flex items-center gap-2 p-1.5 rounded cursor-pointer hover:bg-bg-hover",children:[(0,r.jsx)("input",{type:"checkbox",className:"accent-accent-cyan",checked:P.has(e.id),onChange:()=>G(e.id)}),(0,r.jsx)("span",{className:"text-xs text-text-primary font-mono",children:e.githubFullName})]},e.id)):(0,r.jsx)("p",{className:"text-xs text-text-muted py-2 text-center",children:"No ungrouped repositories available"})}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)("button",{className:"py-1 px-3 text-xs bg-transparent border border-border-subtle rounded text-text-secondary hover:bg-bg-hover",onClick:()=>{W(null),I(new Set)},children:"Cancel"}),(0,r.jsx)("button",{className:"py-1 px-3 text-xs bg-accent-cyan text-bg-deep rounded font-medium hover:bg-accent-cyan/90 disabled:opacity-50",onClick:()=>z(e.id,Array.from(P)),disabled:0===P.size,children:"Add Selected"})]})]}):x.length>0?(0,r.jsxs)("button",{className:"mb-3 w-full py-1.5 text-xs border border-dashed border-border-subtle rounded text-text-muted hover:border-accent-cyan/50 hover:text-accent-cyan transition-colors flex items-center justify-center gap-1",onClick:()=>{W(e.id),I(new Set)},children:[(0,r.jsx)(ri,{}),"Add repositories"]}):null,(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(rn,{status:(null===(t=e.coordinatorAgent)||void 0===t?void 0:t.enabled)?"running":"stopped"}),(null===(n=e.coordinatorAgent)||void 0===n?void 0:n.name)&&(0,r.jsx)("span",{className:"text-sm text-text-secondary",children:e.coordinatorAgent.name})]}),(0,r.jsxs)("button",{className:"py-1.5 px-3 rounded-md text-xs font-medium transition-colors ".concat((null===(s=e.coordinatorAgent)||void 0===s?void 0:s.enabled)?"bg-error/20 text-error hover:bg-error/30":"bg-accent-cyan/20 text-accent-cyan hover:bg-accent-cyan/30"," ").concat(0===e.repositoryCount?"opacity-50 cursor-not-allowed":""),onClick:()=>{var t;return e.repositoryCount>0&&U(e.id,!(null===(t=e.coordinatorAgent)||void 0===t?void 0:t.enabled))},disabled:0===e.repositoryCount,title:0===e.repositoryCount?"Add repositories first":void 0,children:[(null===(a=e.coordinatorAgent)||void 0===a?void 0:a.enabled)?"Stop":"Start"," Coordinator"]})]})]},e.id)})]}),A&&(0,r.jsxs)("div",{className:"bg-bg-tertiary rounded-lg p-4 border border-accent-cyan/30 mb-4",children:[(0,r.jsx)("h4",{className:"text-sm font-semibold text-text-primary mb-4",children:"Edit Project Group"}),(0,r.jsx)(ru,{group:A,onSave:e=>F(A.id,e),onCancel:()=>E(null)})]}),b?(0,r.jsxs)("div",{className:"bg-bg-tertiary rounded-lg p-4 border border-accent-cyan/30",children:[(0,r.jsx)("h4",{className:"text-sm font-semibold text-text-primary mb-4",children:"Create Project Group"}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1.5",children:"Group Name"}),(0,r.jsx)("input",{type:"text",className:"w-full py-2 px-3 bg-bg-card border border-border-subtle rounded-md text-sm text-text-primary outline-none focus:border-accent-cyan/50",placeholder:"e.g., Frontend Team",value:y,onChange:e=>j(e.target.value)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1.5",children:"Description (optional)"}),(0,r.jsx)("input",{type:"text",className:"w-full py-2 px-3 bg-bg-card border border-border-subtle rounded-md text-sm text-text-primary outline-none focus:border-accent-cyan/50",placeholder:"e.g., All frontend repositories",value:w,onChange:e=>N(e.target.value)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1.5",children:"Select Repositories"}),(0,r.jsxs)("div",{className:"space-y-2 max-h-[200px] overflow-y-auto",children:[x.map(e=>(0,r.jsxs)("label",{className:"flex items-center gap-2 p-2 bg-bg-card rounded-md cursor-pointer hover:bg-bg-hover",children:[(0,r.jsx)("input",{type:"checkbox",className:"accent-accent-cyan",checked:k.has(e.id),onChange:()=>V(e.id)}),(0,r.jsx)("span",{className:"text-sm text-text-primary font-mono",children:e.githubFullName}),e.isPrivate&&(0,r.jsx)("span",{className:"text-xs text-text-muted",children:"\uD83D\uDD12"})]},e.id)),0===x.length&&(0,r.jsx)("p",{className:"text-sm text-text-muted py-4 text-center",children:"No ungrouped repositories. Add repositories in Settings or ungroup existing ones."})]})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)("button",{className:"py-2 px-4 bg-transparent border border-border-subtle rounded-md text-sm text-text-secondary hover:bg-bg-hover",onClick:()=>{v(!1),j(""),N(""),C(new Set)},children:"Cancel"}),(0,r.jsx)("button",{className:"py-2 px-4 bg-accent-cyan text-bg-deep rounded-md text-sm font-medium hover:bg-accent-cyan/90 disabled:opacity-50",onClick:R,disabled:!y.trim()||0===k.size||h,children:h?"Creating...":"Create Group"})]})]})]}):(0,r.jsxs)("button",{className:"w-full py-3 px-4 border-2 border-dashed border-border-subtle rounded-lg text-text-muted hover:border-accent-cyan/50 hover:text-accent-cyan transition-colors flex items-center justify-center gap-2",onClick:()=>v(!0),disabled:!!A,children:[(0,r.jsx)(ri,{}),"Create Project Group"]}),(0,r.jsxs)("div",{className:"mt-6 p-4 bg-bg-tertiary/50 rounded-lg border border-border-subtle",children:[(0,r.jsxs)("h4",{className:"text-sm font-semibold text-text-primary mb-2 flex items-center gap-2",children:[(0,r.jsx)(rc,{}),"What is a Coordinator?"]}),(0,r.jsx)("p",{className:"text-sm text-text-secondary",children:"A coordinator is a high-level AI agent that oversees multiple projects. It can delegate tasks to project leads, ensure consistency across codebases, and manage cross-project dependencies."})]})]})]})]})})}function rn(e){let{status:t}=e,n={stopped:"bg-text-muted/20 text-text-muted",starting:"bg-accent-orange/20 text-accent-orange",running:"bg-success/20 text-success",error:"bg-error/20 text-error"};return(0,r.jsx)("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium ".concat(n[t]||n.stopped),children:t})}function rr(){return(0,r.jsx)("svg",{className:"animate-spin h-6 w-6 text-accent-cyan",viewBox:"0 0 24 24",children:(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}function rs(){return(0,r.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-accent-cyan",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,r.jsx)("circle",{cx:"5",cy:"5",r:"2"}),(0,r.jsx)("circle",{cx:"19",cy:"5",r:"2"}),(0,r.jsx)("circle",{cx:"5",cy:"19",r:"2"}),(0,r.jsx)("circle",{cx:"19",cy:"19",r:"2"}),(0,r.jsx)("line",{x1:"9.5",y1:"9.5",x2:"6.5",y2:"6.5"}),(0,r.jsx)("line",{x1:"14.5",y1:"9.5",x2:"17.5",y2:"6.5"}),(0,r.jsx)("line",{x1:"9.5",y1:"14.5",x2:"6.5",y2:"17.5"}),(0,r.jsx)("line",{x1:"14.5",y1:"14.5",x2:"17.5",y2:"17.5"})]})}function ra(e){let{size:t=20}=e;return(0,r.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,r.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function rl(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),(0,r.jsx)("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})}function ri(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,r.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function ro(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,r.jsx)("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})}function rc(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-accent-cyan",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),(0,r.jsx)("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]})}function rd(){return(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"text-success",children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})})}function ru(e){let{group:t,onSave:n,onCancel:a}=e,[l,i]=(0,s.useState)(t.name),[o,c]=(0,s.useState)(t.description||"");return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1.5",children:"Group Name"}),(0,r.jsx)("input",{type:"text",className:"w-full py-2 px-3 bg-bg-card border border-border-subtle rounded-md text-sm text-text-primary outline-none focus:border-accent-cyan/50",value:l,onChange:e=>i(e.target.value)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1.5",children:"Description"}),(0,r.jsx)("input",{type:"text",className:"w-full py-2 px-3 bg-bg-card border border-border-subtle rounded-md text-sm text-text-primary outline-none focus:border-accent-cyan/50",placeholder:"Optional description",value:o,onChange:e=>c(e.target.value)})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)("button",{className:"py-2 px-4 bg-transparent border border-border-subtle rounded-md text-sm text-text-secondary hover:bg-bg-hover",onClick:a,children:"Cancel"}),(0,r.jsx)("button",{className:"py-2 px-4 bg-accent-cyan text-bg-deep rounded-md text-sm font-medium hover:bg-accent-cyan/90 disabled:opacity-50",onClick:()=>{let e={};l.trim()!==t.name&&(e.name=l.trim()),o.trim()!==(t.description||"")&&(e.description=o.trim()),Object.keys(e).length>0?n(e):a()},disabled:!l.trim(),children:"Save Changes"})]})]})}function rx(e){let{apiBaseUrl:t="",onUpgradeClick:n}=e,[a,l]=(0,s.useState)(null),[i,o]=(0,s.useState)(!0),[c,d]=(0,s.useState)(null),[u,x]=(0,s.useState)(!1);if((0,s.useEffect)(()=>{async function e(){try{let e=await fetch("".concat(t,"/api/usage"),{credentials:"include"});if(!e.ok){if(401===e.status){o(!1);return}throw Error("Failed to fetch usage")}let n=await e.json();l(n)}catch(e){d(e instanceof Error?e.message:"Unknown error")}finally{o(!1)}}e();let n=setInterval(e,3e5);return()=>clearInterval(n)},[t]),i||c||!a||"free"!==a.plan||u)return null;let{computeHoursThisMonth:m}=a.usage,{computeHoursPerMonth:h}=a.limits,p=a.percentUsed.computeHours,g=Math.max(0,h-m),f=g<=0,b=p>=80&&!f,v=a.introBonus,y=(null==v?void 0:v.isActive)&&v.daysRemaining>0,j=new Date().toLocaleDateString("en-US",{month:"long"}),w="bg-bg-tertiary border-border-subtle",N="text-text-secondary",k="text-accent-cyan";return f?(w="bg-error/10 border-error/30",N="text-error",k="text-error"):b?(w="bg-warning/10 border-warning/30",N="text-warning",k="text-warning"):y&&(w="bg-accent-cyan/10 border-accent-cyan/30",N="text-accent-cyan",k="text-accent-cyan"),(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b ".concat(w),children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[y?(0,r.jsx)(rp,{className:k}):(0,r.jsx)(rm,{className:k}),(0,r.jsx)("span",{className:"text-sm ".concat(N),children:f?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("strong",{children:"Compute limit reached"})," — Your free tier compute hours for ",j," have been used. Workspaces are paused until next month."]}):b?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("strong",{children:[g.toFixed(1),"h remaining"]})," — You've used ",p,"% of your free tier compute hours for ",j,"."]}):y?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("strong",{children:"Intro Bonus Active"})," — ",v.resources.cpus," CPU / ",v.resources.memoryGb,"GB RAM."," ",(0,r.jsxs)("span",{className:"text-text-secondary",children:[v.daysRemaining," day",1!==v.daysRemaining?"s":""," remaining before auto-resize to 1 CPU / 2GB."]})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("strong",{children:[g.toFixed(1)," of ",h,"h"]})," compute hours remaining this month"]})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(f||b||y)&&(0,r.jsx)("button",{onClick:n||(()=>window.location.href="/pricing"),className:"px-3 py-1.5 bg-gradient-to-r from-accent-cyan to-[#00b8d9] text-bg-deep font-semibold border-none rounded-md text-xs cursor-pointer transition-all duration-150 hover:shadow-glow-cyan hover:-translate-y-0.5",children:y?"Keep Pro Resources":"Upgrade Plan"}),!f&&(0,r.jsx)("button",{onClick:()=>x(!0),className:"p-1 text-text-muted hover:text-text-primary transition-colors","aria-label":"Dismiss",children:(0,r.jsx)(rh,{})})]})]})}function rm(e){let{className:t}=e;return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("polyline",{points:"12 6 12 12 16 14"})]})}function rh(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,r.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function rp(e){let{className:t}=e;return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[(0,r.jsx)("path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z"}),(0,r.jsx)("path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z"}),(0,r.jsx)("path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0"}),(0,r.jsx)("path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5"})]})}var rg=n(2446);let rf={url:"",autoConnect:!0,reconnect:!0,maxReconnectAttempts:10,reconnectDelay:500,onEvent:void 0};function rb(e,t){var n,r,s,a;switch(e||(e={agents:[],messages:[]}),t.kind){case"relay_inbound":{if(!t.from||!t.target||!t.body||t.target.startsWith("#"))return e;let s=t.event_id||"broker_".concat(Date.now(),"_").concat(Math.random().toString(36).slice(2));if(t.event_id&&e.messages.some(e=>e.id===t.event_id))return e;let a={id:s,from:t.from,to:t.target,content:t.body,timestamp:new Date().toISOString(),thread:null!==(n=t.thread_id)&&void 0!==n?n:void 0,isBroadcast:"*"===t.target},l=e.agents.some(e=>e.name===t.from&&e.isProcessing),i=[...e.messages,a];if(t.thread_id){let e=i.findIndex(e=>e.id===t.thread_id);-1!==e&&(i[e]={...i[e],replyCount:(null!==(r=i[e].replyCount)&&void 0!==r?r:0)+1})}return{...e,messages:i,agents:l?e.agents.map(e=>e.name===t.from?{...e,isProcessing:!1,processingStartedAt:void 0,lastLogLine:void 0}:e):e.agents}}case"agent_spawned":if(!t.name)return e;if(e.agents.some(e=>e.name===t.name))return{...e,agents:e.agents.map(e=>{var n,r;return e.name===t.name?{...e,status:"online",cli:null!==(n=t.cli)&&void 0!==n?n:e.cli,model:null!==(r=t.model)&&void 0!==r?r:e.model}:e})};return{...e,agents:[...e.agents,{name:t.name,status:"online",cli:null!==(s=t.cli)&&void 0!==s?s:void 0,model:null!==(a=t.model)&&void 0!==a?a:void 0,isSpawned:!0}]};case"agent_exited":if(!t.name)return e;return{...e,agents:e.agents.filter(e=>e.name!==t.name)};case"agent_released":if(!t.name)return e;return{...e,agents:e.agents.filter(e=>e.name!==t.name)};case"worker_ready":if(!t.name)return e;return{...e,agents:e.agents.map(e=>{var n,r;return e.name===t.name?{...e,status:"online",cli:null!==(n=t.cli)&&void 0!==n?n:e.cli,model:null!==(r=t.model)&&void 0!==r?r:e.model}:e})};case"agent_idle":if(!t.name)return e;return{...e,agents:e.agents.map(e=>e.name===t.name?{...e,isProcessing:!1,processingStartedAt:void 0,lastLogLine:void 0}:e)};case"agent_restarting":if(!t.name)return e;return{...e,agents:e.agents.map(e=>e.name===t.name?{...e,status:"busy"}:e)};case"agent_restarted":if(!t.name)return e;return{...e,agents:e.agents.map(e=>e.name===t.name?{...e,status:"online"}:e)};case"agent_permanently_dead":if(!t.name)return e;return{...e,agents:e.agents.map(e=>e.name===t.name?{...e,status:"offline"}:e)};case"delivery_verified":if(!t.event_id)return e;return{...e,messages:e.messages.map(e=>e.id===t.event_id?{...e,status:"acked"}:e)};case"delivery_failed":if(!t.event_id)return e;return{...e,messages:e.messages.map(e=>e.id===t.event_id?{...e,status:"failed"}:e)};case"delivery_ack":case"delivery_active":if(!t.name)return e;return{...e,agents:e.agents.map(e=>e.name===t.name?{...e,isProcessing:!0,processingStartedAt:Date.now()}:e)};case"worker_stream":if(!t.name)return e;return{...e,agents:e.agents.map(e=>e.name===t.name?{...e,lastLogLine:t.chunk}:e)};default:return e}}function rv(e){let t=e.replace(/^\//,"").split("/").filter(Boolean);if(0===t.length||"app"===t[0])return"app"===t[0]&&t.length>1?rv("/"+t.slice(1).join("/")):{type:"activity"};switch(t[0]){case"channel":return{type:"channel",id:t[1]||void 0};case"dm":return{type:"dm",id:t[1]||void 0};case"agent":return{type:"agent",id:t[1]||void 0};case"settings":return{type:"settings",tab:t[1]&&["dashboard","workspace","team","billing"].includes(t[1])?t[1]:"dashboard"};default:return{type:"activity"}}}function ry(e){let t="/app";switch(e.type){case"channel":return e.id?"".concat(t,"/channel/").concat(encodeURIComponent(e.id)):t;case"dm":return e.id?"".concat(t,"/dm/").concat(encodeURIComponent(e.id)):t;case"agent":return e.id?"".concat(t,"/agent/").concat(encodeURIComponent(e.id)):t;case"settings":return e.tab&&"dashboard"!==e.tab?"".concat(t,"/settings/").concat(e.tab):"".concat(t,"/settings");default:return t}}var rj=n(608);let rw="dashboard-settings",rN=(0,s.createContext)(null);function rk(e){let{children:t}=e,[n,a]=(0,s.useState)(()=>(function(){try{let n=localStorage.getItem(rw);if(!n)return tV;let r=JSON.parse(n);if(!r||"object"!=typeof r)return tV;if("notifications"in r&&"display"in r){var e,t;let n={...tV,...r,notifications:{...tV.notifications,...r.notifications},display:{...tV.display,...r.display},messages:{...tV.messages,...r.messages},connection:{...tV.connection,...r.connection},agentDefaults:{...tV.agentDefaults,...r.agentDefaults,defaultModels:{...null===(e=tV.agentDefaults)||void 0===e?void 0:e.defaultModels,...null===(t=r.agentDefaults)||void 0===t?void 0:t.defaultModels}}};return n.notifications.enabled=n.notifications.sound||n.notifications.desktop||n.notifications.mentionsOnly,n}if("notificationsEnabled"in r||"soundEnabled"in r||"autoScrollMessages"in r)return function(e){var t,n,r,s,a;let l=e.theme&&["dark","light","system"].includes(e.theme)?e.theme:tV.theme,i=null!==(t=e.soundEnabled)&&void 0!==t?t:tV.notifications.sound,o=null!==(n=e.notificationsEnabled)&&void 0!==n?n:tV.notifications.desktop;return{...tV,theme:l,display:{...tV.display,compactMode:null!==(r=e.compactMode)&&void 0!==r?r:tV.display.compactMode,showTimestamps:null!==(s=e.showTimestamps)&&void 0!==s?s:tV.display.showTimestamps},notifications:{...tV.notifications,sound:i,desktop:o,enabled:i||o||tV.notifications.mentionsOnly},messages:{...tV.messages,autoScroll:null!==(a=e.autoScrollMessages)&&void 0!==a?a:tV.messages.autoScroll}}}(r)}catch(e){}return tV})()),l=(0,s.useCallback)(e=>{a(t=>e(t))},[]);return(0,s.useEffect)(()=>{!function(e){try{localStorage.setItem(rw,JSON.stringify(e))}catch(e){}}(n)},[n]),(0,s.useEffect)(()=>{let e=e=>{let t;t="system"===e?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e;let n=document.documentElement;n.classList.remove("theme-light","theme-dark"),n.classList.add("theme-".concat(t)),n.style.colorScheme=t};if(e(n.theme),"system"===n.theme){let t=window.matchMedia("(prefers-color-scheme: dark)"),n=()=>e("system");return t.addEventListener("change",n),()=>t.removeEventListener("change",n)}},[n.theme]),(0,s.useEffect)(()=>{if(n.notifications.desktop&&"Notification"in window&&"granted"!==Notification.permission){if("denied"===Notification.permission){l(e=>({...e,notifications:{...e.notifications,desktop:!1,enabled:e.notifications.sound||e.notifications.mentionsOnly}}));return}Notification.requestPermission().then(e=>{"granted"!==e&&l(e=>({...e,notifications:{...e.notifications,desktop:!1,enabled:e.notifications.sound||e.notifications.mentionsOnly}}))}).catch(()=>void 0)}},[n.notifications.desktop,n.notifications.sound,n.notifications.mentionsOnly,l]),(0,r.jsx)(rN.Provider,{value:{settings:n,updateSettings:l},children:t})}function rC(){let e=(0,s.useContext)(rN);if(!e)throw Error("useSettings must be used within a SettingsProvider");return e}let rS=(0,s.createContext)(null);function rM(e){let{children:t,orchestratorUrl:n}=e,{features:a,api:l,auth:i}=(0,tc.u0)(),{workspaces:o,activeWorkspaceId:c,agents:d,isConnected:u,isLoading:x,switchWorkspace:m,addWorkspace:h,removeWorkspace:p,spawnAgent:g,stopAgent:f}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{apiUrl:t="http://localhost:3456",enabled:n=!1}=e,[r,a]=(0,s.useState)([]),[l,i]=(0,s.useState)(),[o,c]=(0,s.useState)([]),[d,u]=(0,s.useState)(!1),[x,m]=(0,s.useState)(n),[h,p]=(0,s.useState)(null),g=(0,s.useRef)(null),f=(0,s.useRef)(),b=t.replace(/^http/,"ws"),v=(0,s.useCallback)(async()=>{if(n)try{m(!0),p(null);let e=await fetch("".concat(t,"/workspaces"));if(!e.ok)throw Error("Failed to fetch workspaces: ".concat(e.statusText));let n=await e.json();if(a(n.workspaces.map(e=>({...e,lastActiveAt:new Date(e.lastActiveAt)}))),i(n.activeWorkspaceId),n.activeWorkspaceId){let e=await fetch("".concat(t,"/workspaces/").concat(n.activeWorkspaceId,"/agents"));if(e.ok){let t=await e.json(),r=t.workspaceId||n.activeWorkspaceId;c(t.agents.map(e=>({...e,workspaceId:e.workspaceId||r,spawnedAt:new Date(e.spawnedAt)})))}}}catch(e){p(e instanceof Error?e:Error(String(e)))}finally{m(!1)}},[t,n]),y=(0,s.useRef)(0);(0,s.useEffect)(()=>{if(!n)return;let e=()=>{try{let t=new WebSocket(b);t.onopen=()=>{u(!0),p(null),y.current=0},t.onmessage=e=>{try{let n=JSON.parse(e.data);if("init"===n.type){var t;a(n.data.workspaces.map(e=>({...e,lastActiveAt:new Date(e.lastActiveAt)}))),i(n.data.activeWorkspaceId);let e=n.data.activeWorkspaceId;c((null===(t=n.data.agents)||void 0===t?void 0:t.map(t=>({...t,workspaceId:t.workspaceId||e,spawnedAt:new Date(t.spawnedAt)})))||[]),m(!1)}else"event"===n.type&&j(n.data)}catch(e){console.error("Failed to parse WebSocket message:",e)}},t.onclose=()=>{u(!1),g.current=null;let t=Math.min(500*Math.pow(2,y.current),15e3);y.current++,console.log("[WS:Orchestrator] Reconnecting (attempt ".concat(y.current,")...")),f.current=setTimeout(e,Math.round(t*(.5+.5*Math.random())))},t.onerror=e=>{console.error("WebSocket error:",e),t.close()},g.current=t}catch(n){p(n instanceof Error?n:Error(String(n)));let t=Math.min(500*Math.pow(2,y.current),15e3);y.current++,f.current=setTimeout(e,Math.round(t*(.5+.5*Math.random())))}};v().then(e);let t=()=>{"visible"!==document.visibilityState||g.current&&g.current.readyState!==WebSocket.CLOSED||(console.log("[WS:Orchestrator] Tab visible, reconnecting..."),y.current=0,e())};return document.addEventListener("visibilitychange",t),()=>{document.removeEventListener("visibilitychange",t),f.current&&clearTimeout(f.current),g.current&&g.current.close()}},[b,v,n]);let j=(0,s.useCallback)(e=>{switch(e.type){case"workspace:added":a(t=>[...t,e.data]);break;case"workspace:removed":a(t=>t.filter(t=>t.id!==e.workspaceId));break;case"workspace:updated":a(t=>t.map(t=>t.id===e.workspaceId?{...t,...e.data}:t));break;case"workspace:switched":i(e.data.currentId);break;case"agent:spawned":{let t=e.data;c(n=>[...n,{...t,workspaceId:t.workspaceId||e.workspaceId||l||""}]);break}case"agent:stopped":case"agent:crashed":c(t=>t.filter(t=>t.name!==e.data.name));break;case"agent:restarted":c(t=>t.map(t=>t.name===e.data.name?{...t,status:"running",restartCount:t.restartCount+1}:t))}},[l]),w=(0,s.useCallback)(async e=>{let n=await fetch("".concat(t,"/workspaces/").concat(e,"/switch"),{method:"POST"});if(!n.ok)throw Error("Failed to switch workspace: ".concat(n.statusText));let r=await fetch("".concat(t,"/workspaces/").concat(e,"/agents"));r.ok&&c((await r.json()).agents.map(e=>({...e,spawnedAt:new Date(e.spawnedAt)})))},[t]),N=(0,s.useCallback)(async(e,n)=>{let r=await fetch("".concat(t,"/workspaces"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e,name:n})});if(!r.ok)throw Error((await r.json()).error||"Failed to add workspace");return r.json()},[t]),k=(0,s.useCallback)(async e=>{let n=await fetch("".concat(t,"/workspaces/").concat(e),{method:"DELETE"});if(!n.ok)throw Error("Failed to remove workspace: ".concat(n.statusText))},[t]),C=(0,s.useCallback)(async(e,n,r,s)=>{if(!l)throw Error("No active workspace");let a=await fetch("".concat(t,"/workspaces/").concat(l,"/agents"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,task:n,provider:r,cwd:s})});if(!a.ok)throw Error((await a.json()).error||"Failed to spawn agent");let i=await a.json(),o=await fetch("".concat(t,"/workspaces/").concat(l,"/agents"));if(o.ok){let e=await o.json(),t=e.workspaceId||l;c(e.agents.map(e=>({...e,workspaceId:e.workspaceId||t,spawnedAt:new Date(e.spawnedAt)})))}return i},[t,l]),S=(0,s.useCallback)(async e=>{if(!l)throw Error("No active workspace");let n=await fetch("".concat(t,"/workspaces/").concat(l,"/agents/").concat(e),{method:"DELETE"});if(!n.ok)throw Error("Failed to stop agent: ".concat(n.statusText))},[t,l]);return{workspaces:r,activeWorkspaceId:l,agents:o,isConnected:d,isLoading:x,error:h,switchWorkspace:w,addWorkspace:N,removeWorkspace:k,spawnAgent:C,stopAgent:S,refresh:v}}({apiUrl:n}),[b,v]=(0,s.useState)(null);(0,s.useEffect)(()=>{if(!a.auth||!i){v(null);return}let e=!1,t=async()=>{try{let t=await i.getUser();if(e)return;v(t.success?t.data:null)}catch(t){e||v(null)}};t();let n=setInterval(()=>{t()},3e4);return()=>{e=!0,clearInterval(n)}},[a.auth,i]);let y=b?{displayName:b.githubUsername||b.displayName||"",avatarUrl:b.avatarUrl}:void 0,j=a.workspaces&&!!l,w=a.workspaces,N=a.workspaces,k=a.auth||a.billing||a.teams||a.workspaces,[C,S]=(0,s.useState)([]),[M,L]=(0,s.useState)(()=>(0,tZ.J$)()),[D,A]=(0,s.useState)(!1),[E,T]=(0,s.useState)([]);(0,s.useEffect)(()=>{if(!j||!l){S([]),A(!1);return}let e=!1,t=async t=>{t&&A(!0);try{let t=await l.getAccessibleWorkspaces();if(e)return;if(t.success&&t.data.workspaces){S(t.data.workspaces);let e=new Set(t.data.workspaces.map(e=>e.id));if(M&&!e.has(M)){if(t.data.workspaces.length>0){let e=t.data.workspaces[0].id;L(e),(0,tZ.hc)(e)}else L(null),(0,tZ.hc)(null)}else if(!M&&t.data.workspaces.length>0){let e=t.data.workspaces[0].id;L(e),(0,tZ.hc)(e)}}}catch(t){if(e)return;console.error("Failed to fetch cloud workspaces:",t)}finally{t&&!e&&A(!1)}};t(!0);let n=setInterval(()=>{t(!1)},3e4);return()=>{e=!0,clearInterval(n)}},[j,l,M]),(0,s.useEffect)(()=>{if(!M){T([]);return}let e=j&&!!l,t=async()=>{try{if(e&&l){var t;let e=await l.getAgents(M);if(e.success&&(null===(t=e.data)||void 0===t?void 0:t.agents)){let t=e.data.agents.map(e=>({name:e.name,status:"online"===e.status?"online":"offline",isLocal:!1,isSpawned:!0}));T(t)}}else{let e=await tZ.api.get("/api/brokers/workspace/".concat(M,"/agents"));if(e.agents){let t=e.agents.map(e=>{let t=e.brokerStatus,n=null!=t?t:e.status,r=e.brokerName;return{name:e.name,status:"online"===n?"online":"offline",isLocal:!e.isHuman,isHuman:e.isHuman,avatarUrl:e.avatarUrl,brokerName:e.isHuman?void 0:r,machineId:e.isHuman?void 0:e.machineId,lastSeen:e.lastSeenAt||void 0}});T(t)}}}catch(e){(e instanceof Error?e.message:String(e)).includes("HTTP 404")?console.error("BREAKING CHANGE: daemon agent endpoints were removed. Dashboard now requires /api/brokers/workspace/:id/agents.",e):console.error("Failed to fetch agents:",e),T([])}};t();let n=setInterval(t,e?5e3:15e3);return()=>clearInterval(n)},[j,l,M]);let W=(0,s.useMemo)(()=>w&&C.length>0?C.map(e=>({id:e.id,name:e.name,path:e.publicUrl||"/workspace/".concat(e.name),status:"running"===e.status?"active":"inactive",provider:"claude",lastActiveAt:new Date})):o,[w,C,o]),P=w?M:null!=c?c:"default",I=w?D:x;(0,s.useEffect)(()=>{w&&M?(0,tZ.hc)(M):w&&!M?(0,tZ.hc)(null):w||(0,tZ.hc)(null)},[w,M]);let B=(0,s.useCallback)(async e=>{w?(L(e.id),(0,tZ.hc)(e.id)):await m(e.id)},[w,m]);(0,s.useEffect)(()=>{(null==y?void 0:y.displayName)?localStorage.setItem("relay_username",y.displayName):w||localStorage.removeItem("relay_username")},[null==y?void 0:y.displayName,w]);let _=(0,s.useCallback)(async(e,t)=>{await h(e,t)},[h]),R=(0,s.useMemo)(()=>({cloudUser:b,currentUser:y,isWorkspaceFeaturesEnabled:w,canOpenHeaderSettings:k,canOpenWorkspaceSettings:N,cloudWorkspaces:C,effectiveWorkspaces:W,effectiveActiveWorkspaceId:P,effectiveIsLoading:I,activeCloudWorkspaceId:M,orchestratorWorkspaces:o,orchestratorAgents:d,activeWorkspaceId:c,isOrchestratorConnected:u,orchestratorSpawnAgent:g,orchestratorStopAgent:f,handleEffectiveWorkspaceSelect:B,switchWorkspace:m,addWorkspace:_,removeWorkspace:p,setCloudWorkspaces:S,setActiveCloudWorkspaceId:L,localAgents:E,features:a,apiAdapter:l,authAdapter:i}),[b,y,w,k,N,C,W,P,I,M,o,d,c,u,g,f,B,m,_,p,E,a,l,i]);return(0,r.jsx)(rS.Provider,{value:R,children:t})}function rL(){let e=(0,s.useContext)(rS);if(!e)throw Error("useCloudWorkspace must be used within a CloudWorkspaceProvider");return e}var rD=n(9325);let rA=(0,s.createContext)({configured:!1,loading:!0,agentName:null});function rE(){return(0,s.useContext)(rA)}function rT(e){var t;let{children:n}=e,[a,l]=(0,s.useState)(null),[i,o]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let e=!1;return fetch("/api/relay-config",{credentials:"include"}).then(async e=>e.ok?e.json():null).then(t=>{!e&&(null==t?void 0:t.success)&&t.baseUrl&&t.apiKey&&t.agentToken&&l(t)}).catch(()=>{}).finally(()=>{e||o(!0)}),()=>{e=!0}},[]);let c=!!((null==a?void 0:a.baseUrl)&&a.apiKey&&a.agentToken),d=(0,s.useMemo)(()=>c?{baseUrl:a.baseUrl,apiKey:a.apiKey,agentToken:a.agentToken}:{baseUrl:window.location.origin,apiKey:"__relay_disabled__",agentToken:"__relay_disabled__"},[c,a]);return(0,r.jsx)(rA.Provider,{value:{configured:c,loading:!i,agentName:null!==(t=null==a?void 0:a.agentName)&&void 0!==t?t:null},children:(0,r.jsx)(rD.nh,{baseUrl:d.baseUrl,apiKey:d.apiKey,agentToken:d.agentToken,children:n})})}let rW="relay:recentRepos";function rP(e){try{localStorage.setItem(rW,JSON.stringify(e))}catch(e){}}let rI=(0,s.createContext)(null),rB=["architect"];function r_(e){var t,n;let{children:a,data:l,isConnected:i}=e,{cloudUser:o,effectiveActiveWorkspaceId:u,isWorkspaceFeaturesEnabled:x,orchestratorWorkspaces:h,orchestratorAgents:g,activeWorkspaceId:f,orchestratorSpawnAgent:b,orchestratorStopAgent:v,localAgents:y,activeCloudWorkspaceId:j,features:w,apiAdapter:N,setCloudWorkspaces:k}=rL(),C=w.workspaces&&!!N,S=(0,s.useMemo)(()=>(function(e){let{agents:t=[],users:n=[],localAgents:r=[]}=e,s=[...t,...n,...r].filter(e=>"dashboard"!==e.name.toLowerCase()),a=new Map;for(let e of s){let t=e.name.toLowerCase(),n=a.get(t);if(n){let r=!n.isLocal&&e.isLocal;a.set(t,{...n,...e,isLocal:!r&&!!e.isLocal})}else a.set(t,e)}return Array.from(a.values())})({agents:null==l?void 0:l.agents,users:null==l?void 0:l.users,localAgents:y}),[null==l?void 0:l.agents,null==l?void 0:l.users,y]),{agents:M,groups:L,selectedAgent:D,selectAgent:A,searchQuery:E,setSearchQuery:T,totalCount:W,onlineCount:P,needsAttentionCount:I}=function(e){let{agents:t,initialSelected:n,initialSearchQuery:r=""}=e,[a,l]=(0,s.useState)(null!=n?n:null),[i,o]=(0,s.useState)(r),u=(0,s.useMemo)(()=>m(t,i),[t,i]),x=(0,s.useMemo)(()=>d(u),[u]),h=(0,s.useMemo)(()=>[...u].sort((e,t)=>e.name.localeCompare(t.name)),[u]),g=(0,s.useMemo)(()=>{var e;return null!==(e=t.find(e=>e.name===a))&&void 0!==e?e:null},[t,a]),f=(0,s.useMemo)(()=>{let e=p(t);return{totalCount:e.total,onlineCount:e.online,needsAttentionCount:e.needsAttention}},[t]),b=(0,s.useCallback)(e=>{l(e)},[]),v=(0,s.useCallback)(e=>t.find(t=>t.name===e),[t]),y=(0,s.useCallback)(e=>({...e,color:(0,c.GW)(e.name)}),[]);return{agents:u,groups:x,sortedAgents:h,selectedAgent:g,selectAgent:b,searchQuery:i,setSearchQuery:o,...f,getAgentByName:v,getAgentWithColor:y}}({agents:S}),B=(0,s.useMemo)(()=>{var e;let t=new Map;for(let n of null!==(e=null==l?void 0:l.summaries)&&void 0!==e?e:[])t.set(n.agentName.toLowerCase(),n);return t},[null==l?void 0:l.summaries]),[_,R]=(0,s.useState)([]),F=(0,s.useCallback)(e=>{let t={...e,id:"activity-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,9)),timestamp:new Date().toISOString()};R(e=>[t,...e].slice(0,200))},[]),U=(0,s.useRef)(new Map);(0,s.useEffect)(()=>{if(!S||0===S.length)return;let e=new Map(S.map(e=>[e.name,e])),t=U.current;if(t.size>0){for(let[n,r]of e)t.has(n)?t.get(n).status!==r.status&&("online"===r.status||"busy"===r.status?F({type:"agent_online",actor:n,actorType:"agent",title:"came online",metadata:{cli:r.cli}}):"offline"===r.status&&F({type:"agent_offline",actor:n,actorType:"agent",title:"went offline"})):F({type:"agent_spawned",actor:n,actorType:"agent",title:"came online",description:r.currentTask,metadata:{cli:r.cli,task:r.currentTask}});for(let[n]of t)e.has(n)||F({type:"agent_released",actor:n,actorType:"agent",title:"went offline"})}U.current=e},[S,F]);let[O,H]=(0,s.useState)([]),[z,G]=(0,s.useState)(),{recentRepos:V,addRecentRepo:Z,getRecentProjects:K}=function(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=null!==(e=t.maxRecent)&&void 0!==e?e:5,[r,a]=(0,s.useState)([]);(0,s.useEffect)(()=>{a(function(){try{let e=localStorage.getItem(rW);if(!e)return[];let t=JSON.parse(e);if(!Array.isArray(t))return[];return t}catch(e){return[]}}())},[]);let l=(0,s.useCallback)(e=>{a(t=>{let r=t.filter(t=>t.id!==e.id),s=[{id:e.id,path:e.path,name:e.name,lastAccessed:Date.now()},...r].slice(0,n);return rP(s),s})},[n]),i=(0,s.useCallback)(e=>{a(t=>{let n=t.filter(t=>t.id!==e);return rP(n),n})},[]),o=(0,s.useCallback)(()=>{a([]),rP([])},[]),c=(0,s.useCallback)(e=>{let t=new Map(e.map(e=>[e.id,e]));return r.map(e=>t.get(e.id)).filter(e=>void 0!==e)},[r]);return{recentRepos:r,addRecentRepo:l,removeRecentRepo:i,clearRecentRepos:o,getRecentProjects:c}}(),{repos:q,refetch:J}=function(e){let{workspaceId:t,apiBaseUrl:n="/api",enabled:r=!0}=e,[a,l]=(0,s.useState)([]),[i,o]=(0,s.useState)(!1),[c,d]=(0,s.useState)(null),u=(0,s.useCallback)(async()=>{if(t&&r){o(!0),d(null);try{let e=await fetch("".concat(n,"/workspaces/").concat(t,"/repos"),{credentials:"include"});if(!e.ok)throw Error("Failed to fetch workspace repos");let r=await e.json();l(r.repositories||[])}catch(e){d(e instanceof Error?e.message:"Failed to fetch repos"),console.error("Error fetching workspace repos:",e)}finally{o(!1)}}},[t,n,r]);return(0,s.useEffect)(()=>{u()},[u]),{repos:a,isLoading:i,error:c,refetch:u}}({workspaceId:null!=u?u:void 0,apiBaseUrl:"/api",enabled:x&&!!u}),{bridgeAgents:$,projectAgents:Y}=(0,s.useMemo)(()=>{let e=[],t=[];for(let n of M)n.isHuman||"dashboard"===n.cli||(rB.includes(n.name.toLowerCase())?e.push(n):t.push(n));return{bridgeAgents:e,projectAgents:t}},[M]),X=(x?rL().effectiveWorkspaces:h).length>0,Q=rL().effectiveWorkspaces,ee=(0,s.useRef)(!1);(0,s.useEffect)(()=>{if(X){if(ee.current=!1,q.length>1&&u){let t=q.map(e=>{let t=e.githubFullName.split("/").pop()||e.githubFullName;return{id:e.id,path:e.githubFullName,name:t,agents:[],lead:void 0}});if(H(t),!z||!t.find(e=>e.id===z)){var e;G(null===(e=t[0])||void 0===e?void 0:e.id)}}else if(h.length>0)H(h.map(e=>({id:e.id,path:e.path,name:e.name,agents:g.filter(t=>t.workspaceId===e.id).map(e=>({name:e.name,status:"running"===e.status?"online":"offline",isSpawned:!0,cli:e.provider,cwd:e.cwd})),lead:void 0}))),G(f);else if(x&&u){let e=Q.find(e=>e.id===u);e&&(H([{id:e.id,path:e.path,name:e.name,agents:[],lead:void 0}]),G(e.id))}}},[X,h,g,f,q,u,z,x,Q]),(0,s.useEffect)(()=>{if(X)return;let e=!1,t=async()=>{let t=await tZ.api.getBridgeData();if(!e&&t.success&&t.data){let e=t.data;if(e.projects&&e.projects.length>0){let t=e.projects.map(e=>({id:e.id,path:e.path,name:e.name||e.path.split("/").pop(),agents:(e.agents||[]).filter(e=>"dashboard"!==e.cli).map(e=>({name:e.name,status:"online"===e.status||"active"===e.status?"online":"offline",currentTask:e.task,cli:e.cli,model:e.model,cwd:e.cwd})),lead:e.lead}));H(t),G(e=>{var n;return e||(null===(n=t[0])||void 0===n?void 0:n.id)||e})}}};if(ee.current||(ee.current=!0,t()),i)return()=>{e=!0};t();let n=setInterval(t,5e3);return()=>{e=!0,clearInterval(n)}},[X,i]);let et=(0,s.useMemo)(()=>{if(0===O.length)return O;if(q.length>1){let e=[...Y],t=new Set(Y.map(e=>e.name.toLowerCase()));for(let n of g)t.has(n.name.toLowerCase())||(t.add(n.name.toLowerCase()),e.push({name:n.name,status:"running"===n.status?"online":"offline",isSpawned:!0,cli:n.provider,cwd:n.cwd}));if(0===e.length)return O;let n=new Set(O.map(e=>e.name)),r=O.map(t=>{let n=t.name,r=e.filter(e=>e.cwd===n);return{...t,agents:[...t.agents,...r]}}),s=new Set(r.flatMap(e=>e.agents.map(e=>e.name.toLowerCase()))),a=e.filter(e=>!s.has(e.name.toLowerCase())&&(!e.cwd||!n.has(e.cwd)));return a.length>0?[{id:"__workspace__",path:"/workspace",name:"Workspace",agents:a},...r]:r}return 0===Y.length?O:O.map((e,t)=>{if(0===t||e.id===z){let t=new Set(e.agents.map(e=>e.name.toLowerCase())),n=Y.filter(e=>!t.has(e.name.toLowerCase()));return{...e,agents:[...e.agents,...n]}}return e})},[O,Y,g,z,q.length]),en=(0,s.useMemo)(()=>{let e=M.filter(e=>e.isHuman);return et.length>0?e:[...Y.filter(e=>!e.isHuman),...e]},[et,Y,M]),[er,es]=(0,s.useState)(()=>{{let e=new URLSearchParams(window.location.search);if("true"===e.get("spawn")){e.delete("spawn");let t=e.toString()?"".concat(window.location.pathname,"?").concat(e.toString()):window.location.pathname;return window.history.replaceState({},"",t),!0}}return!1}),[ea,el]=(0,s.useState)(!1),[ei,eo]=(0,s.useState)(null),ec=(0,s.useCallback)(async e=>{el(!0),eo(null);try{let t=e.command.trim().split(/\s+/),n=t[0],r=t.indexOf("--model"),s=-1!==r&&t[r+1]?t[r+1]:void 0;if(C&&N&&j){let t=await N.spawnAgent(j,{name:e.name,provider:n,model:s,cwd:e.cwd});if(!t.success)return eo(t.error||"Failed to spawn agent"),!1;return!0}if(h.length>0&&f)return await b(e.name,void 0,e.command,e.cwd),!0;let a=await tZ.api.spawnAgent({name:e.name,cli:e.command,cwd:e.cwd,team:e.team,shadowMode:e.shadowMode,shadowOf:e.shadowOf,shadowAgent:e.shadowAgent,shadowTriggers:e.shadowTriggers,shadowSpeakOn:e.shadowSpeakOn,continueFrom:e.continueFrom});if(!a.success)return eo(a.error||"Failed to spawn agent"),!1;return!0}catch(e){return eo(e instanceof Error?e.message:"Failed to spawn agent"),!1}finally{el(!1)}},[C,N,j,h.length,f,b]),ed=(0,s.useCallback)(async e=>{if(e.isSpawned&&window.confirm('Are you sure you want to release agent "'.concat(e.name,'"?')))try{if(C&&N&&j){await N.stopAgent(j,e.name);return}if(h.length>0&&f){await v(e.name);return}let t=await tZ.api.releaseAgent(e.name);t.success||console.error("Failed to release agent:",t.error)}catch(e){console.error("Failed to release agent:",e)}},[C,N,j,h.length,f,v]),eu=!!(null==l?void 0:null===(n=l.fleet)||void 0===n?void 0:null===(t=n.servers)||void 0===t?void 0:t.length)||h.length>0,[ex,em]=(0,s.useState)(!1),[eh,ep]=(0,s.useState)([]),[eg,ef]=(0,s.useState)();(0,s.useEffect)(()=>{if(!ex)return;let e=async()=>{let e=await tZ.api.getFleetServers();e.success&&e.data&&ep(e.data.servers.map(e=>({id:e.id,name:e.name,url:"local"===e.id?window.location.origin:"http://".concat(e.id),status:"healthy"===e.status?"online":"degraded"===e.status?"degraded":"offline",agentCount:e.agents.length,uptime:e.uptime,lastSeen:e.lastHeartbeat})))};e();let t=setInterval(e,5e3);return()=>clearInterval(t)},[ex]);let eb=(0,s.useCallback)(async e=>{if(C&&N)try{let t=await N.restartWorkspace(e);t.success?(ep(t=>t.map(t=>t.id===e?{...t,status:"connecting"}:t)),setTimeout(async()=>{try{let e=await N.getWorkspaceSummary();e.success&&e.data.workspaces&&k(e.data.workspaces)}catch(e){console.error("Failed to refresh workspaces after reconnect:",e)}},2e3)):console.error("Failed to restart workspace:",t.error)}catch(e){console.error("Failed to reconnect to server:",e)}else console.warn("Server reconnect not fully supported in orchestrator mode")},[C,N,k]),[ev,ey]=(0,s.useState)(!1),[ej,ew]=(0,s.useState)([]),[eN,ek]=(0,s.useState)({});(0,s.useEffect)(()=>{if(!ev)return;let e=async()=>{let e=await tZ.api.getDecisions();e.success&&e.data&&ew(e.data.decisions.map(tZ.XP))};e();let t=setInterval(e,5e3);return()=>clearInterval(t)},[ev]);let eC=(0,s.useCallback)(async(e,t)=>{ek(t=>({...t,[e]:!0}));try{let n=await tZ.api.approveDecision(e,t);n.success?ew(t=>t.filter(t=>t.id!==e)):console.error("Failed to approve decision:",n.error)}catch(e){console.error("Failed to approve decision:",e)}finally{ek(t=>({...t,[e]:!1}))}},[]),eS=(0,s.useCallback)(async(e,t)=>{ek(t=>({...t,[e]:!0}));try{let n=await tZ.api.rejectDecision(e,t);n.success?ew(t=>t.filter(t=>t.id!==e)):console.error("Failed to reject decision:",n.error)}catch(e){console.error("Failed to reject decision:",e)}finally{ek(t=>({...t,[e]:!1}))}},[]),eM=(0,s.useCallback)(async e=>{(await tZ.api.dismissDecision(e)).success&&ew(t=>t.filter(t=>t.id!==e))},[]),[eL,eD]=(0,s.useState)(!1),eA=(0,s.useCallback)(async e=>{eD(!0);try{var t;let n=e3[e.priority].beadsPriority,r=await tZ.api.createBead({title:e.title,assignee:e.agentName,priority:n,type:"task"});if(r.success&&(null===(t=r.data)||void 0===t?void 0:t.bead))await tZ.api.sendRelayMessage({to:e.agentName,content:'New task assigned: "'.concat(e.title,'" (P').concat(n,")\nCheck `bd ready` for details.")}),console.log("Task created:",r.data.bead.id);else throw console.error("Failed to create task bead:",r.error),Error(r.error||"Failed to create task")}catch(e){throw console.error("Failed to create task:",e),e}finally{eD(!1)}},[]),[eE,eT]=(0,s.useState)(null),[eW,eP]=(0,s.useState)(null),eI=(0,s.useMemo)(()=>({agents:M,combinedAgents:S,groups:L,selectedAgent:D,selectAgent:A,searchQuery:E,setSearchQuery:T,totalCount:W,onlineCount:P,needsAttentionCount:I,agentSummariesMap:B,projects:O,mergedProjects:et,currentProject:z,setCurrentProject:G,bridgeAgents:$,projectAgents:Y,localAgentsForSidebar:en,recentRepos:V,addRecentRepo:Z,getRecentProjects:K,workspaceRepos:q,refetchWorkspaceRepos:J,handleSpawn:ec,handleReleaseAgent:ed,isSpawnModalOpen:er,setIsSpawnModalOpen:es,isSpawning:ea,spawnError:ei,setSpawnError:eo,isFleetAvailable:eu,isFleetViewActive:ex,setIsFleetViewActive:em,fleetServers:eh,selectedServerId:eg,setSelectedServerId:ef,handleServerReconnect:eb,isDecisionQueueOpen:ev,setIsDecisionQueueOpen:ey,decisions:ej,decisionProcessing:eN,handleDecisionApprove:eC,handleDecisionReject:eS,handleDecisionDismiss:eM,handleTaskCreate:eA,isCreatingTask:eL,activityEvents:_,addActivityEvent:F,logViewerAgent:eE,setLogViewerAgent:eT,selectedAgentProfile:eW,setSelectedAgentProfile:eP}),[M,S,L,D,A,E,T,W,P,I,B,O,et,z,$,Y,en,V,Z,K,q,J,ec,ed,er,ea,ei,eu,ex,eh,eg,eb,ev,ej,eN,eC,eS,eM,eA,eL,_,F,eE,eW]);return(0,r.jsx)(rI.Provider,{value:eI,children:a})}function rR(){let e=(0,s.useContext)(rI);if(!e)throw Error("useAgentContext must be used within an AgentProvider");return e}function rF(e){var t,n,r,s;return{id:e.id,from:null!==(t=e.agentName)&&void 0!==t?t:"",to:"*",content:e.text,timestamp:null!==(n=e.createdAt)&&void 0!==n?n:new Date().toISOString(),replyCount:null!==(r=e.replyCount)&&void 0!==r?r:0,reactions:null!==(s=e.reactions)&&void 0!==s?s:[],isRead:!0}}var rU=n(7880),rO=n(3862);function rH(e){var t,n,r,s;let a=e.name;return{id:"#".concat(a),name:a,description:null!==(t=e.topic)&&void 0!==t?t:void 0,topic:null!==(n=e.topic)&&void 0!==n?n:void 0,visibility:"public",status:e.isArchived?"archived":"active",createdAt:null!==(r=e.createdAt)&&void 0!==r?r:new Date().toISOString(),createdBy:"relay",memberCount:null!==(s=e.memberCount)&&void 0!==s?s:0,unreadCount:0,hasMentions:!1,isDm:!1}}let rz=(0,s.createContext)(null),rG=["#general","#engineering"];function rV(e){let{children:t}=e,{effectiveActiveWorkspaceId:a,isWorkspaceFeaturesEnabled:l}=rL(),{configured:i}=rE(),o=(0,rD.lB)(),c=(0,s.useMemo)(()=>o.channels.map(rH),[o.channels]),[d,u]=(0,s.useState)([]),[x,m]=(0,s.useState)([]),[h,p]=(0,s.useState)(!1),[g,f]=(0,s.useState)(l?"__activity__":"#general"),[b,v]=(0,s.useState)(!1),[y,j]=(0,s.useState)(!1),[w,N]=(0,s.useState)(!1),[k,C]=(0,s.useState)(null),[S,M]=(0,s.useState)(!1),[L,D]=(0,s.useState)(!1),[A,E]=(0,s.useState)([]),T=(0,s.useCallback)(e=>{let t=[...e.archivedChannels||[],...e.channels.filter(e=>"archived"===e.status)],n=e.channels.filter(e=>"archived"!==e.status),r=new Set(n.map(e=>e.id));u([...rG.filter(e=>!r.has(e)).map(e=>({id:e,name:e.replace("#",""),description:"#general"===e?"General discussion for all agents":"Engineering discussion",visibility:"public",memberCount:0,unreadCount:0,hasMentions:!1,createdAt:new Date().toISOString(),status:"active",createdBy:"system",isDm:!1})),...n]),m(t)},[]),W=(0,s.useMemo)(()=>{if(g)return d.find(e=>e.id===g)||x.find(e=>e.id===g)},[g,d,x]),P=(0,s.useMemo)(()=>[{id:"#general",name:"general",description:"General discussion for all agents",visibility:"public",memberCount:0,unreadCount:0,hasMentions:!1,createdAt:"2024-01-01T00:00:00.000Z",status:"active",createdBy:"system",isDm:!1},{id:"#engineering",name:"engineering",description:"Engineering discussion",visibility:"public",memberCount:0,unreadCount:0,hasMentions:!1,createdAt:"2024-01-01T00:00:00.000Z",status:"active",createdBy:"system",isDm:!1}],[]);(0,s.useEffect)(()=>{f(void 0)},[a]),(0,s.useEffect)(()=>{if(i){T({channels:c.filter(e=>"archived"!==e.status),archivedChannels:c.filter(e=>"archived"===e.status)}),p(o.loading);return}if(!l||!a){u(P),m([]);return}u(P),m([]),p(!0),(async()=>{try{let e=await (0,rj.Gn)(a);T(e)}catch(e){console.error("Failed to fetch channels:",e)}finally{p(!1)}})()},[i,o,c,a,l,P,T]);let I=(0,s.useCallback)(async e=>{f(e.id);try{let{joinChannel:t}=await Promise.resolve().then(n.bind(n,608));await t(a||"local",e.id)}catch(e){console.error("Failed to join channel:",e)}},[a]),B=(0,s.useCallback)(()=>{v(!0)},[]),_=(0,s.useCallback)(async e=>{if(a){j(!0);try{var t;let n=await (0,rj.mi)(a,e),r=await (0,rj.Gn)(a);T(r),(null===(t=n.channel)||void 0===t?void 0:t.id)&&f(n.channel.id),v(!1)}catch(e){console.error("Failed to create channel:",e)}finally{j(!1)}}},[a,T]),R=(0,s.useCallback)(e=>{C(e),N(!0)},[]),F=(0,s.useCallback)(async e=>{if(k){M(!0);try{let t=(0,tZ._V)(),n={"Content-Type":"application/json"};t&&(n["X-CSRF-Token"]=t);let r=e.map(e=>({id:e,type:"agent"}));if(!(await fetch("/api/channels/invite",{method:"POST",headers:n,credentials:"include",body:JSON.stringify({channel:k.name,invites:r,workspaceId:a})})).ok)throw Error("Failed to invite members");N(!1),C(null)}catch(e){console.error("Failed to invite to channel:",e)}finally{M(!1)}}},[k,a]),U=(0,s.useCallback)(async e=>{if(a)try{let{joinChannel:t}=await Promise.resolve().then(n.bind(n,608));await t(a,e);let r=await (0,rj.Gn)(a);T(r)}catch(e){console.error("Failed to join channel:",e)}},[a,T]),O=(0,s.useCallback)(async e=>{if(a)try{let{leaveChannel:t}=await Promise.resolve().then(n.bind(n,608));await t(a,e.id),g===e.id&&f(void 0);let r=await (0,rj.Gn)(a);T(r)}catch(e){console.error("Failed to leave channel:",e)}},[a,g,T]),H=(0,s.useCallback)(async()=>{if(W&&a)try{let e=await (0,rj.Fk)(a,W.id);E(e),D(!0)}catch(e){console.error("Failed to load channel members:",e)}},[W,a]),z=(0,s.useCallback)(async(e,t)=>{if(W&&a)try{await (0,rj.Ah)(a,W.id,e,t);let n=await (0,rj.Fk)(a,W.id);E(n)}catch(e){console.error("Failed to remove member:",e)}},[W,a]),G=(0,s.useCallback)(async(e,t,n)=>{if(W&&a)try{let n=(0,tZ._V)(),r={"Content-Type":"application/json"};if(n&&(r["X-CSRF-Token"]=n),!(await fetch("/api/channels/invite",{method:"POST",headers:r,credentials:"include",body:JSON.stringify({channel:W.name,invites:[{id:e,type:t}],workspaceId:a})})).ok)throw Error("Failed to add member");let s=await (0,rj.Fk)(a,W.id);E(s)}catch(e){console.error("Failed to add member:",e)}},[W,a]),V=(0,s.useCallback)(async e=>{if(a)try{let{archiveChannel:t}=await Promise.resolve().then(n.bind(n,608));await t(a,e.id),g===e.id&&f(void 0);let r=await (0,rj.Gn)(a);T(r)}catch(e){console.error("Failed to archive channel:",e)}},[a,g,T]),Z=(0,s.useCallback)(async e=>{if(a)try{let{unarchiveChannel:t}=await Promise.resolve().then(n.bind(n,608));await t(a,e.id);let r=await (0,rj.Gn)(a);T(r)}catch(e){console.error("Failed to unarchive channel:",e)}},[a,T]),K=(0,s.useMemo)(()=>({channelsList:d,archivedChannelsList:x,isChannelsLoading:h,selectedChannelId:g,setSelectedChannelId:f,selectedChannel:W,handleSelectChannel:I,handleCreateChannel:B,handleCreateChannelSubmit:_,handleInviteToChannel:R,handleInviteSubmit:F,handleJoinChannel:U,handleLeaveChannel:O,handleShowMembers:H,handleRemoveMember:z,handleAddMember:G,handleArchiveChannel:V,handleUnarchiveChannel:Z,isCreateChannelOpen:b,setIsCreateChannelOpen:v,isCreatingChannel:y,isInviteChannelOpen:w,setIsInviteChannelOpen:N,inviteChannelTarget:k,setInviteChannelTarget:C,isInvitingToChannel:S,showMemberPanel:L,setShowMemberPanel:D,channelMembers:A,setChannelsList:u,relayMappedChannels:c}),[d,x,h,g,W,I,B,_,R,F,U,O,H,z,G,V,Z,b,y,w,k,S,L,A,c]);return(0,r.jsx)(rz.Provider,{value:K,children:t})}function rZ(){let e=(0,s.useContext)(rz);if(!e)throw Error("useChannelContext must be used within a ChannelProvider");return e}function rK(e){let t=Date.parse(e.timestamp);return Number.isFinite(t)?t:0}function rq(e){return[...e].sort((e,t)=>{let n=rK(e)-rK(t);return 0!==n?n:e.id.localeCompare(t.id)})}let rJ=(0,s.createContext)(null);function r$(e){let{children:t,localMessages:a,localUsername:l}=e,{currentUser:i,effectiveActiveWorkspaceId:o,isWorkspaceFeaturesEnabled:c}=rL(),{configured:d,agentName:u}=rE(),{channelsList:x,setChannelsList:m,selectedChannelId:h}=rZ(),[p,g]=s.useState([]),[f,b]=s.useState({}),v=(0,s.useRef)(new Set),[y,j]=s.useState(!1),[w,N]=s.useState(),k=(0,s.useRef)(!1),C=(null==h?void 0:h.startsWith("#"))?h.slice(1):"general",S=(0,rD.y_)(C),M=(0,rD.$3)(),L=(0,rD.jD)(),D=(0,rD.kh)(),A=(0,s.useMemo)(()=>d&&(null==h?void 0:h.startsWith("#"))?(0,rD.zW)(S.messages).map(e=>(0,rO.t2)(h,e,null==i?void 0:i.displayName)):[],[h,S.messages,null==i?void 0:i.displayName,d]),E=!!(d&&(null==h?void 0:h.startsWith("#"))),T=(0,s.useMemo)(()=>o||!h?[]:a.filter(e=>"__activity__"!==h&&(e.to===h||e.channel===h||e.thread===h)).map(e=>{var t;return{id:e.id,channelId:h,from:e.from,fromEntityType:"Dashboard"===e.from||e.from===u||e.from===(null==i?void 0:i.displayName)?"user":"agent",content:e.content,timestamp:e.timestamp,isRead:null===(t=e.isRead)||void 0===t||t,threadId:e.thread!==h?e.thread:void 0}}),[a,h,o,null==i?void 0:i.displayName,u]),W=(0,s.useMemo)(()=>rq(E?A:p.length>0?p:T),[E,A,p,T]);(0,s.useEffect)(()=>{k.current=d},[d]);let P=(0,s.useCallback)((e,t)=>e.some(e=>e.id===t.id||e.from===t.from&&e.content===t.content&&e.threadId===t.threadId&&2e3>Math.abs(new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime())),[]),I=(0,s.useCallback)((e,t,n)=>{var r;let s=null===(r=null==n?void 0:n.incrementUnread)||void 0===r||r;b(n=>{var r;let s=null!==(r=n[e])&&void 0!==r?r:[];if(P(s,t))return n;let a=[...s,t].sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime());return{...n,[e]:a}}),h===e?(g(e=>P(e,t)?e:[...e,t].sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime())),N(void 0)):s&&m(t=>t.find(t=>t.id===e)?t.map(t=>{var n;return t.id===e?{...t,unreadCount:(null!==(n=t.unreadCount)&&void 0!==n?n:0)+1}:t}):[...t,{id:e,name:e.startsWith("#")?e.slice(1):e,visibility:"public",status:"active",createdAt:new Date().toISOString(),createdBy:(null==i?void 0:i.displayName)||u||"Dashboard",memberCount:1,unreadCount:1,hasMentions:!1,isDm:e.startsWith("dm:")}])},[null==i?void 0:i.displayName,h,P,m,u]);(0,s.useEffect)(()=>{b({}),g([]),v.current.clear()},[o]),(0,s.useEffect)(()=>{var e;if(!h||"__activity__"===h||c&&!o)return;if(d&&h.startsWith("#")){g(A),j(!1),N(void 0),m(e=>e.map(e=>e.id===h?{...e,unreadCount:0,hasMentions:!1}:e));return}let t=rq(null!==(e=f[h])&&void 0!==e?e:[]);t.length>0?(g(t),j(!1)):v.current.has(h)?(g([]),j(!1)):(v.current.add(h),(async()=>{try{let{getMessages:e}=await Promise.resolve().then(n.bind(n,608)),t=await e(o||"local",h,{limit:200}),r=rq(t.messages);b(e=>({...e,[h]:r})),g(r),j(t.hasMore)}catch(e){console.error("Failed to fetch channel messages:",e),v.current.delete(h),g([]),j(!1)}})()),N(void 0),m(e=>e.map(e=>e.id===h?{...e,unreadCount:0,hasMentions:!1}:e))},[h,o,d,S,A,f,c,m]);let B=(0,s.useCallback)(async(e,t,n)=>{if(!h)return!1;let r=(null==i?void 0:i.displayName)||l||u||localStorage.getItem("relay_username")||"You",s={id:"local-".concat(Date.now()),channelId:h,from:r,fromEntityType:"user",content:e,timestamp:new Date().toISOString(),threadId:t,isRead:!0};I(h,s,{incrementUnread:!1});try{let r=d&&h.startsWith("#"),s=!!(n&&n.length>0),a=!!t&&A.some(e=>e.id===t);return r&&!s?t&&a?await D.reply(t,e):t?await (0,rj.bG)(o||"local",h,{content:e,threadId:t,attachmentIds:n}):await M.send(h.slice(1),e):await (0,rj.bG)(o||"local",h,{content:e,threadId:t,attachmentIds:n}),!0}catch(e){return console.error("Failed to send channel message:",e),!1}},[o,h,null==i?void 0:i.displayName,I,d,A,D,M.send,l,u]),_=(0,s.useCallback)(async()=>{d&&(null==h?void 0:h.startsWith("#"))&&await S.fetchMore()},[d,S.fetchMore,h]),R=(0,s.useRef)(null),F=(0,s.useCallback)(e=>{o&&(R.current&&clearTimeout(R.current),R.current=setTimeout(async()=>{try{await (0,rj.Qh)(o,e),N(void 0),m(t=>t.map(t=>t.id===e?{...t,unreadCount:0,hasMentions:!1}:t))}catch(e){console.error("Failed to mark channel as read:",e)}},500))},[o,m]);(0,s.useEffect)(()=>{h&&w&&0!==w.count&&F(h)},[h,w,F]),(0,s.useEffect)(()=>()=>{R.current&&clearTimeout(R.current)},[]);let U=(0,s.useCallback)(async(e,t,n)=>{try{if(d){n?await L.unreact(e,t):await L.react(e,t);return}n?await tZ.api.removeReaction(e,t):await tZ.api.addReaction(e,t)}catch(e){console.error("Failed to update reaction:",e)}},[d,L]),O=(0,s.useMemo)(()=>({handleSendChannelMessage:B,handleLoadMoreMessages:_,handleMarkChannelRead:F,handleReaction:U,channelMessages:p,hasMoreMessages:y,channelUnreadState:w,effectiveChannelMessages:W,appendChannelMessage:I,relayMappedChannelMessages:A}),[B,_,F,U,p,y,w,W,I,A]);return(0,r.jsx)(rJ.Provider,{value:O,children:t})}let rY="__activity__",rX=(0,s.createContext)(null);function rQ(e){var t;let{children:n,data:a,rawData:l,enableReactions:i=!1}=e,{currentUser:o,effectiveActiveWorkspaceId:c,isWorkspaceFeaturesEnabled:d}=rL(),{agents:u,combinedAgents:x,addActivityEvent:m}=rR(),{configured:h,agentName:p}=rE(),{settings:g}=rC(),f=rZ(),b=function(){let e=(0,s.useContext)(rJ);if(!e)throw Error("useSendContext must be used within a SendProvider");return e}(),[v,y]=(0,s.useState)(localStorage.getItem("relay_username"));(0,s.useEffect)(()=>{let e=localStorage.getItem("relay_username");if(e&&e!==v){y(e);return}v||fetch("/api/health").then(e=>e.ok?e.json():null).then(e=>{(null==e?void 0:e.projectName)&&(localStorage.setItem("relay_username",e.projectName),y(e.projectName))}).catch(()=>{})});let[j,w]=(0,s.useState)(d?"local":"channels"),[N,k]=(0,s.useState)({}),[C,S]=(0,s.useState)({}),[M,L]=(0,s.useState)(new Map),[D,A]=(0,s.useState)(null),[E,T]=(0,s.useState)(),[W,P]=(0,s.useState)(!1),I=(0,s.useRef)(0),B=(0,s.useRef)(null),_=(0,s.useRef)(!1),R=(0,s.useCallback)(e=>{var t,n,r,s;if((null==e?void 0:e.type)==="presence_join"&&e.user){let t=e.user;t.username!==(null==o?void 0:o.displayName)&&m({type:"user_joined",actor:t.username,actorAvatarUrl:t.avatarUrl,actorType:"user",title:"came online"})}else if((null==e?void 0:e.type)==="presence_leave"&&e.username)e.username!==(null==o?void 0:o.displayName)&&m({type:"user_left",actor:e.username,actorType:"user",title:"went offline"});else if((null==e?void 0:e.type)==="agent_spawned"&&e.agent)m({type:"agent_spawned",actor:e.agent.name||e.agent,actorType:"agent",title:"was spawned",description:e.task,metadata:{cli:e.cli,task:e.task,spawnedBy:e.spawnedBy}});else if((null==e?void 0:e.type)==="agent_released"&&e.agent)m({type:"agent_released",actor:e.agent.name||e.agent,actorType:"agent",title:"was released",metadata:{releasedBy:e.releasedBy}});else if((null==e?void 0:e.type)==="channel_created"){let t=e.channel;if(!t||!t.id)return;f.setChannelsList(e=>{if(e.some(e=>e.id===t.id))return e;let n={id:t.id,name:t.name||t.id,description:t.description,visibility:t.visibility||"public",status:t.status||"active",createdAt:t.createdAt||new Date().toISOString(),createdBy:t.createdBy||"unknown",memberCount:t.memberCount||1,unreadCount:t.unreadCount||0,hasMentions:t.hasMentions||!1,isDm:t.isDm||!1};return console.log("[MessageProvider] Channel created via WebSocket:",n.id),[...e,n]})}else if((null==e?void 0:e.type)==="channel_message"){if(_.current)return;let r=e.channel;if(!r)return;let s=e.from||"unknown",a=e.fromEntityType||((null==o?void 0:o.displayName)&&s===o.displayName?"user":"agent"),l={id:null!==(t=e.id)&&void 0!==t?t:"ws-".concat(Date.now()),channelId:r,from:s,fromEntityType:a,fromAvatarUrl:e.fromAvatarUrl,content:null!==(n=e.body)&&void 0!==n?n:"",timestamp:e.timestamp||new Date().toISOString(),threadId:e.thread,isRead:f.selectedChannelId===r};b.appendChannelMessage(r,l,{incrementUnread:f.selectedChannelId!==r})}else if((null==e?void 0:e.type)==="direct_message"){if(_.current)return;let t=e.from||"unknown",n=[t,(null==o?void 0:o.displayName)||e.targetUser||p||"Dashboard"].sort(),a="dm:".concat(n.join(":")),l=e.fromEntityType||"agent",i={id:null!==(r=e.id)&&void 0!==r?r:"dm-".concat(Date.now()),channelId:a,from:t,fromEntityType:l,fromAvatarUrl:e.fromAvatarUrl,content:null!==(s=e.body)&&void 0!==s?s:"",timestamp:e.timestamp||new Date().toISOString(),threadId:e.thread,isRead:f.selectedChannelId===a};b.appendChannelMessage(a,i,{incrementUnread:f.selectedChannelId!==a})}},[m,b.appendChannelMessage,null==o?void 0:o.displayName,f.selectedChannelId,f.setChannelsList,p]),{onlineUsers:F,typingUsers:U,sendTyping:O,isConnected:H}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{currentUser:t,wsUrl:n,autoConnect:r=!0,onEvent:a,workspaceId:l}=e,i=(0,rD.oO)(),{configured:o}=rE(),[c,d]=(0,s.useState)([]),[u,x]=(0,s.useState)([]),[m,h]=(0,s.useState)(!1),[p,g]=(0,s.useState)("disconnected"),f=(0,s.useRef)(null),b=(0,s.useRef)(null),v=(0,s.useRef)(0),y=(0,s.useRef)(null),j=(0,s.useRef)(!1),w=(0,s.useRef)(!1),N=(0,s.useRef)(t);N.current=t;let k=(0,s.useRef)(l);k.current=l;let C=(0,s.useRef)(a);C.current=a;let S=(0,s.useMemo)(()=>i.agents.filter(e=>"online"===e.status&&"human"===e.type).map(e=>{var t;return{username:e.name,connectedAt:null!==(t=e.createdAt)&&void 0!==t?t:e.lastSeen,lastSeen:e.lastSeen}}),[i]);(0,s.useEffect)(()=>{let e=setInterval(()=>{let e=Date.now();x(t=>t.filter(t=>e-t.startedAt<3e3))},1e3);return()=>clearInterval(e)},[]);let M=(0,s.useCallback)(()=>{var e;if(o||!N.current||(null===(e=f.current)||void 0===e?void 0:e.readyState)===WebSocket.OPEN||j.current)return;w.current&&g("reconnecting"),j.current=!0;let t=n||(0,rg.HE)("/ws/presence");try{let e=new WebSocket(t);e.onopen=()=>{j.current=!1,h(!0),g("connected"),v.current=0,w.current=!0;let t=N.current;if(t){e.send(JSON.stringify({type:"presence",action:"join",user:{username:t.username,avatarUrl:t.avatarUrl}}));let n=k.current;n&&e.send(JSON.stringify({type:"subscribe_channels",workspaceId:n}))}},e.onclose=()=>{if(j.current=!1,h(!1),f.current=null,N.current){g("reconnecting");let e=Math.min(500*Math.pow(2,v.current),15e3);v.current++,console.log("[WS:Presence] Reconnecting (attempt ".concat(v.current,")...")),b.current=setTimeout(()=>{M()},Math.round(e*(.5+.5*Math.random())))}else g("disconnected")},e.onerror=e=>{console.error("[usePresence] Error:",e)},e.onmessage=e=>{try{var t,n,r,s;let a=JSON.parse(e.data);switch(a.type){case"presence_list":d(a.users||[]);break;case"presence_join":d(e=>[...e.filter(e=>e.username!==a.user.username),a.user]),null===(t=C.current)||void 0===t||t.call(C,a);break;case"presence_leave":d(e=>e.filter(e=>e.username!==a.username)),x(e=>e.filter(e=>e.username!==a.username)),null===(n=C.current)||void 0===n||n.call(C,a);break;case"typing":if(a.username===(null===(r=N.current)||void 0===r?void 0:r.username))break;a.isTyping?x(e=>[...e.filter(e=>e.username!==a.username),{username:a.username,avatarUrl:a.avatarUrl,startedAt:Date.now()}]):x(e=>e.filter(e=>e.username!==a.username));break;default:null===(s=C.current)||void 0===s||s.call(C,a)}}catch(e){console.error("[usePresence] Failed to parse message:",e)}},f.current=e}catch(e){console.error("[usePresence] Failed to create WebSocket:",e)}},[n,o]),L=(0,s.useCallback)(()=>{if(b.current&&(clearTimeout(b.current),b.current=null),j.current=!1,f.current){let e=f.current;e.onclose=null,e.onerror=null;let t=N.current;e.readyState===WebSocket.OPEN&&t&&e.send(JSON.stringify({type:"presence",action:"leave",username:t.username})),e.close(),f.current=null}h(!1),g("disconnected")},[]),D=(0,s.useCallback)(e=>{if(o||!f.current||f.current.readyState!==WebSocket.OPEN)return;let t=N.current;t&&(y.current&&(clearTimeout(y.current),y.current=null),f.current.send(JSON.stringify({type:"typing",isTyping:e,username:t.username,avatarUrl:t.avatarUrl})),e&&(y.current=setTimeout(()=>{y.current=null,D(!1)},3e3)))},[o]);return((0,s.useEffect)(()=>{if(!o&&r&&N.current&&(!f.current||f.current.readyState===WebSocket.CLOSED))return M(),()=>{L()}},[r,null==t?void 0:t.username,M,L,o]),(0,s.useEffect)(()=>{if(o)return;let e=()=>{var e;let t=N.current;(null===(e=f.current)||void 0===e?void 0:e.readyState)===WebSocket.OPEN&&t&&f.current.send(JSON.stringify({type:"presence",action:"leave",username:t.username}))};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[o]),(0,s.useEffect)(()=>{if(o)return;let e=()=>{"visible"===document.visibilityState&&N.current&&(!f.current||f.current.readyState===WebSocket.CLOSED)&&(console.log("[WS:Presence] Tab visible, reconnecting..."),v.current=0,M())};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[M,o]),(0,s.useEffect)(()=>{o&&L()},[L,o]),o)?{onlineUsers:S,typingUsers:[],sendTyping:()=>void 0,isConnected:!i.loading&&!i.error,connectionState:i.loading?"reconnecting":i.error?"disconnected":"connected"}:{onlineUsers:c,typingUsers:u,sendTyping:D,isConnected:m,connectionState:p}}({currentUser:(0,s.useMemo)(()=>o?{username:o.displayName,avatarUrl:o.avatarUrl}:void 0,[null==o?void 0:o.displayName,null==o?void 0:o.avatarUrl]),onEvent:R,workspaceId:null!=c?c:void 0}),z=(0,rD.ZV)(),G=(0,s.useMemo)(()=>{var e;let t=null!==(e=null==a?void 0:a.messages)&&void 0!==e?e:[];return h&&0!==z.conversations.length?(0,rO.ug)(t,z.conversations):t},[null==a?void 0:a.messages,h,z.conversations]),{messages:V,threadMessages:Z,currentChannel:K,setCurrentChannel:q,currentThread:J,setCurrentThread:$,activeThreads:Y,totalUnreadThreadCount:X,sendMessage:Q,isSending:ee,sendError:et}=function(e){let{messages:t,currentChannel:n="general",senderName:r}=e,[a,l]=(0,s.useState)(n),[i,o]=(0,s.useState)(null),[c,d]=(0,s.useState)(!1),[u,x]=(0,s.useState)(null),[m,h]=(0,s.useState)(new Map),p=r||localStorage.getItem("relay_username")||"You",[g,f]=(0,s.useState)([]);(0,s.useEffect)(()=>{if(0===g.length)return;let e=new Set(t.slice(-50).map(e=>"".concat(e.to,":").concat(e.content.slice(0,100))));f(t=>t.filter(t=>{let n="".concat(t.to,":").concat(t.content.slice(0,100));return!e.has(n)}))},[t,g.length]);let b=(0,s.useMemo)(()=>0===g.length?t:[...t,...g].sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime()),[t,g]),v=(0,s.useMemo)(()=>{let e=new Set(b.map(e=>e.id)),t=b.filter(t=>!t.thread||!e.has(t.thread));return"general"===a?t:t.filter(e=>e.from===a||e.to===a)},[b,a]),y=(0,s.useCallback)(e=>b.filter(t=>t.thread===e),[b]),j=(0,s.useMemo)(()=>{let e=new Map,t=new Set(b.map(e=>e.id));for(let t of b)if(t.thread){let n=e.get(t.thread)||[];n.push(t),e.set(t.thread,n)}let n=[];for(let[r,s]of e.entries()){let e=[...s].sort((e,t)=>new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime()),a=[...new Set(s.flatMap(e=>[e.from,e.to]))].filter(e=>"*"!==e),l=m.get(r),i=s.filter(e=>e.from!==p&&!e.isRead&&(!l||new Date(e.timestamp).getTime()>l)).length,o=r;if(t.has(r)){let e=b.find(e=>e.id===r);if(e){let t=e.content.split("\n")[0];o=t.length>30?t.substring(0,30)+"...":t}}n.push({id:r,name:o,lastMessage:e[0],messageCount:s.length,unreadCount:i,participants:a})}return n.sort((e,t)=>new Date(t.lastMessage.timestamp).getTime()-new Date(e.lastMessage.timestamp).getTime())},[b,m]),w=(0,s.useCallback)(e=>{o(e),e&&h(t=>{let n=new Map(t);return n.set(e,Date.now()),n})},[]),N=(0,s.useMemo)(()=>j.filter(e=>e.unreadCount>0).length,[j]),k=(0,s.useMemo)(()=>{let e=b.filter(e=>!e.isRead).length;return{totalCount:b.length,unreadCount:e}},[b]);return{messages:v,threadMessages:y,currentChannel:a,setCurrentChannel:l,currentThread:i,setCurrentThread:w,activeThreads:j,totalUnreadThreadCount:N,sendMessage:(0,s.useCallback)(async(e,t,n,s)=>{d(!0),x(null);let a="optimistic-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,9)),l={id:a,from:p,to:e,content:t,timestamp:new Date().toISOString(),status:"sending",thread:n,isRead:!0};f(e=>[...e,l]);try{let l={to:e,message:t,thread:n,attachments:s};r&&(l.from=r);let o=await tZ.api.sendMessage(l);if(o.success){var i;let e=null===(i=o.data)||void 0===i?void 0:i.messageId;return e&&f(t=>t.map(t=>t.id===a?{...t,id:e}:t)),!0}return f(e=>e.filter(e=>e.id!==a)),x(o.error||"Failed to send message"),!1}catch(e){return f(e=>e.filter(e=>e.id!==a)),x("Network error"),!1}finally{d(!1)}},[p,r]),isSending:c,sendError:u,...k}}({messages:G,senderName:(null==o?void 0:o.displayName)||v||void 0}),en=function(e){var t,n,r;let{threadId:a,fallbackMessages:l}=e,{configured:i}=rE(),o=(0,rD.nn)(null!=a?a:""),{reply:c}=(0,rD.lo)(),[d,u]=(0,s.useState)(null),[x,m]=(0,s.useState)([]),[h,p]=(0,s.useState)(!1),[g,f]=(0,s.useState)(!1),[b,v]=(0,s.useState)(),[y,j]=(0,s.useState)(!1),w=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(w.current=a,!a||i){u(null),m([]),f(!1),v(void 0),j(!1),p(!1);return}u(null),m([]),f(!1),v(void 0),j(!1);let e=!1;return p(!0),(async()=>{let t=await tZ.api.getThread(a,{limit:50});if(!e){if(p(!1),t.success&&t.data){j(!1);let{parent:e,replies:n,nextCursor:r}=t.data;u(e),m(n),f(!!r),v(r)}else j(!0)}})(),()=>{e=!0}},[a,i]);let N=i&&!!a,k=N&&o.parent?rF(o.parent):null,C=N?o.replies.map(rF):[],S=y&&null!==(n=null!==(t=null==l?void 0:l.find(e=>e.id===a))&&void 0!==t?t:null==l?void 0:l.filter(e=>e.thread===a).sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime())[0])&&void 0!==n?n:null,M=y&&null!==(r=null==l?void 0:l.filter(e=>e.thread===a&&e.id!==(null==S?void 0:S.id)))&&void 0!==r?r:[],L=N?k:y?S:d,D=N?C:y?M:x,A=N?o.loading:h,E=(0,s.useCallback)(async()=>{if(i||!a||!g||!b||y)return;p(!0);let e=await tZ.api.getThread(a,{cursor:b,limit:50});w.current===a&&(p(!1),e.success&&e.data&&(m(t=>[...e.data.replies,...t]),f(!!e.data.nextCursor),v(e.data.nextCursor)))},[a,g,b,y,i]);return{parentMessage:L,replies:D,isLoading:A,hasMore:!y&&!N&&g,loadMore:E,sendReply:(0,s.useCallback)(async e=>{if(!a)return!1;if(i)try{return await c(a,e),!0}catch(e){}let t=await tZ.api.postReply(a,e);return!!t.success&&!!t.data&&(m(e=>[...e,t.data]),!0)},[a,i,c]),addReply:(0,s.useCallback)(e=>{m(t=>t.some(t=>t.id===e.id)?t:[...t,e])},[])}}({threadId:"channels"===j?h?J:null:J,fallbackMessages:V}),er=(0,s.useMemo)(()=>K&&x.find(e=>e.isHuman&&e.name.toLowerCase()===K.toLowerCase())||null,[x,K]),es=(0,s.useMemo)(()=>{var e;return er&&null!==(e=N[er.name])&&void 0!==e?e:[]},[er,N]),ea=(0,s.useMemo)(()=>{var e;return er&&null!==(e=C[er.name])&&void 0!==e?e:[]},[er,C]),{visibleMessages:el,participantAgents:ei}=function(e){let{currentHuman:t,currentUserName:n,messages:r,agents:a,selectedDmAgents:l,removedDmAgents:i}=e,o=(0,s.useMemo)(()=>new Set(a.map(e=>e.name)),[a]),c=(0,s.useMemo)(()=>{if(!t)return[];let e=t.name,n=new Set;for(let t of r){let{from:r,to:s}=t;r&&s&&(r===e&&o.has(s)&&n.add(s),s===e&&o.has(r)&&n.add(r),l.includes(r)&&o.has(s)&&n.add(s),l.includes(s)&&o.has(r)&&n.add(r))}let s=new Set([...l,...n]);return i.forEach(e=>s.delete(e)),Array.from(s)},[o,t,r,i,l]),d=(0,s.useMemo)(()=>{if(!t)return r;let e=new Set([t.name,...c]),s=n||"Dashboard";e.add(s),console.log("[DM Filter] currentHuman:",t.name,"currentUser:",n,"agents:",c,"participants:",Array.from(e));let a=r.filter(t=>{var n,r;if(!t.from||!t.to)return!1;let s=e.has(t.from),a=e.has(t.to),l=s&&a;return((null===(n=t.from)||void 0===n?void 0:n.includes("Agent"))||(null===(r=t.to)||void 0===r?void 0:r.includes("Agent")))&&console.log("[DM Filter] msg:",t.from,"->",t.to,"hasFrom:",s,"hasTo:",a,"passes:",l),l});return console.log("[DM Filter] filtered count:",a.length),a},[t,n,c,r]);return{visibleMessages:(0,s.useMemo)(()=>{var e,n,r,s,a,l;if(!t)return d;let i=e=>(null!=e?e:"").trim().replace(/\s+/g," "),o=e=>"sending"===e.status?1:0,c=(e,t)=>{let n=o(e),r=o(t),s=new Date(e.timestamp).getTime(),a=new Date(t.timestamp).getTime();return r<n?t:r>n?e:a>=s?t:e},u=[...d].sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime()),x=new Map,m=new Map;for(let t of u){if(t.id){let e=x.get(t.id);x.set(t.id,e?c(e,t):t);continue}let r=null!==(n=null===(e=t.from)||void 0===e?void 0:e.toLowerCase())&&void 0!==n?n:"",s=Math.floor(new Date(t.timestamp).getTime()/5e3),a="".concat(r,"|").concat(s,"|").concat(i(t.content)),l=m.get(a);m.set(a,l?c(l,t):t)}let h=[...x.values(),...m.values()],p=new Map;for(let e of h){let t=null!==(a=null===(r=e.from)||void 0===r?void 0:r.toLowerCase())&&void 0!==a?a:"",n=null!==(l=null===(s=e.to)||void 0===s?void 0:s.toLowerCase())&&void 0!==l?l:"",o="".concat(t,"|").concat(n,"|").concat(i(e.content)),d=p.get(o);p.set(o,d?c(d,e):e)}return Array.from(p.values()).sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime())},[t,d]),participantAgents:c}}({currentHuman:er,currentUserName:null!==(t=null==o?void 0:o.displayName)&&void 0!==t?t:null,messages:V,agents:u,selectedDmAgents:es,removedDmAgents:ea});(0,s.useEffect)(()=>{_.current=h},[h]);let eo=(0,s.useMemo)(()=>{let e=new Set(u.filter(e=>!e.isHuman).map(e=>e.name.toLowerCase())),t=new Map;if(o&&t.set(o.displayName.toLowerCase(),{username:o.displayName,avatarUrl:o.avatarUrl}),h&&z.conversations.length>0){let n=null==o?void 0:o.displayName.toLowerCase();for(let r of z.conversations)for(let s of r.participants){let r="string"==typeof s?s:s.agentName;if(!r)continue;let a=r.toLowerCase();(!n||a!==n)&&(e.has(a)||t.has(a)||t.set(a,{username:r}))}}for(let n of G){let r=n.from;!r||(0,rU.RY)(r)||p&&r===p||"*"===r||e.has(r.toLowerCase())||t.has(r.toLowerCase())||t.set(r.toLowerCase(),{username:r})}return Array.from(t.values())},[G,u,o,z.conversations,h,p]),ec=(0,s.useMemo)(()=>{if(!o)return{};if(h&&z.conversations.length>0){let e={},t=o.displayName.toLowerCase(),n=new Set(u.filter(e=>!e.isHuman).map(e=>e.name.toLowerCase()));for(let r of z.conversations){if(!r.unreadCount)continue;let s=r.participants.find(e=>{let r="string"==typeof e?e:e.agentName;if(!r)return!1;let s=r.toLowerCase();return s!==t&&!n.has(s)}),a=s?"string"==typeof s?s:s.agentName:null;a&&(e[a]=(e[a]||0)+r.unreadCount)}return e}let e={},t=new Set(x.filter(e=>e.isHuman).map(e=>e.name.toLowerCase()));for(let r of G){var n;let s=r.from,a=r.to;if(!s||!a)continue;let l=a===o.displayName,i=t.has(s.toLowerCase());if(!l||!i)continue;let c=null!==(n=M.get(s.toLowerCase()))&&void 0!==n?n:0;new Date(r.timestamp).getTime()>c&&(e[s]=(e[s]||0)+1)}return e},[x,o,G,M,z.conversations,u,h]),ed=(0,s.useCallback)(e=>{L(t=>{let n=new Map(t);return n.set(e.toLowerCase(),Date.now()),n})},[]),eu=(0,s.useCallback)(e=>{var t;if(!er)return;let n=er.name,r=(null!==(t=N[n])&&void 0!==t?t:[]).includes(e);k(t=>{var s;let a=null!==(s=t[n])&&void 0!==s?s:[],l=r?a.filter(t=>t!==e):[...a,e];return{...t,[n]:l}}),S(t=>{var s;let a=null!==(s=t[n])&&void 0!==s?s:[];return r?a.includes(e)?t:{...t,[n]:[...a,e]}:{...t,[n]:a.filter(t=>t!==e)}})},[er,N]),ex=(0,s.useCallback)(async(e,t)=>{if(!er)return!1;let n=er.name;if(await Q(n,e,void 0,t),es.length>0)for(let n of es)await Q(n,e,void 0,t);return!0},[er,es,Q]),em=(0,s.useCallback)(async(e,t)=>er?ex(e,t):Q(K,e,void 0,t),[K,er,ex,Q]);(0,s.useEffect)(()=>{if(!G||0===G.length){B.current=null;return}let e=G[G.length-1];if(!g.notifications.enabled){var t;B.current=null!==(t=null==e?void 0:e.id)&&void 0!==t?t:null;return}if(!B.current){B.current=e.id;return}let n=G.findIndex(e=>e.id===B.current);if(-1===n){B.current=e.id;return}let r=G.slice(n+1);if(0===r.length)return;B.current=e.id;let s=e=>"Dashboard"===e.from||e.from===p||o&&e.from===o.displayName,a=e=>e.from===K||e.to===K,l=e=>!(s(e)||g.notifications.mentionsOnly&&(null==o?void 0:o.displayName)&&!e.content.includes("@".concat(o.displayName))||"undefined"!=typeof document&&!document.hidden&&a(e)),i=!1;for(let e of r)if(l(e)){if(g.notifications.desktop&&"Notification"in window&&"granted"===Notification.permission){let t=e.to,n=e.content.split("\n")[0].slice(0,160),r=new Notification("".concat(e.from," -> ").concat(t),{body:n});r.onclick=()=>{window.focus(),q(e.from),r.close()}}g.notifications.sound&&(i=!0)}i&&function(){let e=window.AudioContext||window.webkitAudioContext;if(e)try{let t=new e,n=t.createOscillator(),r=t.createGain();n.type="sine",n.frequency.value=880,r.gain.value=.03,n.connect(r),r.connect(t.destination),n.start(),n.stop(t.currentTime+.12),n.onended=()=>{t.close().catch(()=>void 0)}}catch(e){}}()},[G,g.notifications,K,o,q,p]),(0,s.useEffect)(()=>{I.current=V.length},[]);let eh=(0,s.useMemo)(()=>({messages:V,threadMessages:Z,currentChannel:K,setCurrentChannel:q,currentThread:J,setCurrentThread:$,activeThreads:Y,totalUnreadThreadCount:X,sendMessage:Q,isSending:ee,sendError:et,thread:en,viewMode:j,setViewMode:w,channelsList:f.channelsList,archivedChannelsList:f.archivedChannelsList,selectedChannelId:f.selectedChannelId,setSelectedChannelId:f.setSelectedChannelId,selectedChannel:f.selectedChannel,isChannelsLoading:f.isChannelsLoading,channelMessages:b.channelMessages,hasMoreMessages:b.hasMoreMessages,channelUnreadState:b.channelUnreadState,effectiveChannelMessages:b.effectiveChannelMessages,handleSelectChannel:f.handleSelectChannel,handleCreateChannel:f.handleCreateChannel,handleCreateChannelSubmit:f.handleCreateChannelSubmit,handleInviteToChannel:f.handleInviteToChannel,handleInviteSubmit:f.handleInviteSubmit,handleJoinChannel:f.handleJoinChannel,handleLeaveChannel:f.handleLeaveChannel,handleShowMembers:f.handleShowMembers,handleRemoveMember:f.handleRemoveMember,handleAddMember:f.handleAddMember,handleArchiveChannel:f.handleArchiveChannel,handleUnarchiveChannel:f.handleUnarchiveChannel,handleSendChannelMessage:b.handleSendChannelMessage,handleLoadMoreMessages:b.handleLoadMoreMessages,handleMarkChannelRead:b.handleMarkChannelRead,handleReaction:b.handleReaction,isCreateChannelOpen:f.isCreateChannelOpen,setIsCreateChannelOpen:f.setIsCreateChannelOpen,isCreatingChannel:f.isCreatingChannel,isInviteChannelOpen:f.isInviteChannelOpen,setIsInviteChannelOpen:f.setIsInviteChannelOpen,inviteChannelTarget:f.inviteChannelTarget,setInviteChannelTarget:f.setInviteChannelTarget,isInvitingToChannel:f.isInvitingToChannel,showMemberPanel:f.showMemberPanel,setShowMemberPanel:f.setShowMemberPanel,channelMembers:f.channelMembers,currentHuman:er,selectedDmAgents:es,removedDmAgents:ea,dedupedVisibleMessages:el,dmParticipantAgents:ei,dmSelectedAgentsByHuman:N,handleDmAgentToggle:eu,handleDmSend:ex,handleMainComposerSend:em,onlineUsers:F,typingUsers:U,sendTyping:O,isPresenceConnected:H,humanUsers:eo,humanUnreadCounts:ec,markDmSeen:ed,selectedUserProfile:D,setSelectedUserProfile:A,pendingMention:E,setPendingMention:T,hasUnreadMessages:W,handlePresenceEvent:R,setChannelsList:f.setChannelsList,appendChannelMessage:b.appendChannelMessage}),[V,Z,K,q,J,$,Y,X,Q,ee,et,en,j,f,b,er,es,ea,el,ei,N,eu,ex,em,F,U,O,H,eo,ec,ed,D,E,W,R]);return(0,r.jsx)(rX.Provider,{value:eh,children:n})}function r0(e){let{children:t,data:n,rawData:s,enableReactions:a=!1}=e;return(0,r.jsx)(rV,{children:(0,r.jsx)(r1,{data:n,rawData:s,enableReactions:a,children:t})})}function r1(e){let{children:t,data:n,rawData:a,enableReactions:l}=e,{configured:i}=rE(),o=(0,rD.ZV)(),{currentUser:c}=rL(),d=(0,s.useMemo)(()=>{var e;let t=null!==(e=null==n?void 0:n.messages)&&void 0!==e?e:[];return i&&0!==o.conversations.length?(0,rO.ug)(t,o.conversations):t},[null==n?void 0:n.messages,i,o.conversations]),[u]=(0,s.useState)(localStorage.getItem("relay_username"));return(0,r.jsx)(r$,{localMessages:d,localUsername:u,children:(0,r.jsx)(rQ,{data:n,rawData:a,enableReactions:l,children:t})})}function r2(e){let{wsUrl:t,orchestratorUrl:a,enableReactions:l=!1}=e,i=(0,s.useRef)(void 0),{data:o,isConnected:c,error:d}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t={...rf,...e},[n,r]=(0,s.useState)(null),[a,l]=(0,s.useState)(!1),[i,o]=(0,s.useState)("disconnected"),[c,d]=(0,s.useState)(null),u=(0,s.useRef)(null),x=(0,s.useRef)(0),m=(0,s.useRef)(null),h=(0,s.useRef)(t.onEvent);h.current=t.onEvent;let p=(0,s.useRef)(null),g=(0,s.useRef)(!1),f=(0,s.useRef)(new Set),b=(0,s.useRef)(!1),v=(0,s.useCallback)(e=>{let t="number"==typeof e.seq?e.seq:null;if(null!==t&&f.current.has(t))return!1;if(null!==t&&(f.current.add(t),p.current=t,f.current.size>1e3)){let e=Array.from(f.current).sort((e,t)=>e-t);for(let t of e.slice(0,e.length-500))f.current.delete(t)}let{seq:n,...s}=e;if(s&&"object"==typeof s&&"type"in s&&"string"==typeof s.type){if("broker_event"===s.type&&s.payload&&"object"==typeof s.payload&&"kind"in s.payload)r(e=>rb(e,s.payload));else{var a;null===(a=h.current)||void 0===a||a.call(h,s)}}else s&&"object"==typeof s&&"kind"in s&&"string"==typeof s.kind?r(e=>rb(e,s)):r(s);return!0},[]),y=(0,s.useCallback)(()=>{var e;if((null===(e=u.current)||void 0===e?void 0:e.readyState)===WebSocket.OPEN)return;let n=t.url||(0,rg.HE)("/ws");b.current&&o("reconnecting");try{let e=new WebSocket(n);e.onopen=()=>{l(!0),o("connected"),d(null),x.current=0,b.current&&null!==p.current&&g.current&&(console.log("[WS] Requesting replay from seq ".concat(p.current)),e.send(JSON.stringify({type:"replay",lastSequenceId:p.current}))),b.current=!0},e.onclose=()=>{if(l(!1),u.current=null,t.reconnect&&x.current<t.maxReconnectAttempts){o("reconnecting");let e=Math.min(t.reconnectDelay*Math.pow(2,x.current),15e3);x.current++,console.log("[WS] Reconnecting (attempt ".concat(x.current,")...")),m.current=setTimeout(()=>{y()},Math.round(e*(.5+.5*Math.random())))}else o("disconnected")},e.onerror=e=>{d(Error("WebSocket connection error")),console.error("[useWebSocket] Error:",e)},e.onmessage=e=>{try{let t=JSON.parse(e.data);if(t&&"sync"===t.type&&"number"==typeof t.sequenceId){g.current=!0,null===p.current&&(p.current=t.sequenceId);return}if(t&&"replay"===t.type&&Array.isArray(t.messages)){for(let e of t.messages)v(e);return}v(t)}catch(e){console.error("[useWebSocket] Failed to parse message:",e)}},u.current=e}catch(e){d(e instanceof Error?e:Error("Failed to create WebSocket"))}},[t.url,t.reconnect,t.maxReconnectAttempts,t.reconnectDelay,v]),j=(0,s.useCallback)(()=>{m.current&&(clearTimeout(m.current),m.current=null),u.current&&(u.current.close(),u.current=null),l(!1),o("disconnected")},[]);return(0,s.useEffect)(()=>(t.autoConnect&&y(),()=>{j()}),[t.autoConnect,y,j]),(0,s.useEffect)(()=>{let e=()=>{"visible"!==document.visibilityState||u.current&&u.current.readyState!==WebSocket.CLOSED||(console.log("[WS] Tab visible, reconnecting..."),x.current=0,y())};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[y]),{data:n,isConnected:a,connectionState:i,error:c,connect:y,disconnect:j}}({url:t,onEvent:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.call(i,e)}}),[u,x]=(0,s.useState)(null),[m,h]=(0,s.useState)(!1);(0,s.useEffect)(()=>{if(d&&!o&&!u){let e=!1;return h(!1),(async()=>{try{let{api:t}=await Promise.resolve().then(n.bind(n,5118)),r=await t.getData();if(e)return;r.success&&r.data?x(r.data):h(!0)}catch(t){e||h(!0)}})(),()=>{e=!0}}},[d,o,u]);let p=o||u||(t?{agents:[],messages:[]}:null);return(0,r.jsx)(rk,{children:(0,r.jsx)(e_.W5,{wsUrl:t,children:(0,r.jsx)(rM,{orchestratorUrl:a,children:(0,r.jsx)(rT,{children:(0,r.jsx)(r_,{data:p,isConnected:c,children:(0,r.jsx)(r0,{data:p,rawData:p,enableReactions:l,children:(0,r.jsx)(r5,{wsUrl:t,data:p,rawData:p,isConnected:c,wsError:d,restFallbackFailed:m,enableReactions:l,wsEventHandlerRef:i})})})})})})})}function r5(e){var t,n,a,l,o;let{data:c,isConnected:d,wsError:u,restFallbackFailed:x,enableReactions:m,wsEventHandlerRef:h}=e,{settings:p,updateSettings:g}=rC(),{cloudUser:f,currentUser:b,isWorkspaceFeaturesEnabled:v,canOpenHeaderSettings:y,canOpenWorkspaceSettings:j,effectiveWorkspaces:w,effectiveActiveWorkspaceId:N,effectiveIsLoading:k,isOrchestratorConnected:C,orchestratorWorkspaces:S,handleEffectiveWorkspaceSelect:M,features:L,apiAdapter:D}=rL(),{agents:A,combinedAgents:E,selectedAgent:T,selectAgent:W,agentSummariesMap:P,mergedProjects:I,currentProject:B,setCurrentProject:_,bridgeAgents:R,localAgentsForSidebar:F,addRecentRepo:U,getRecentProjects:O,workspaceRepos:H,refetchWorkspaceRepos:z,handleSpawn:G,handleReleaseAgent:V,isSpawnModalOpen:Z,setIsSpawnModalOpen:K,isSpawning:q,spawnError:J,setSpawnError:Y,isFleetAvailable:X,isFleetViewActive:Q,setIsFleetViewActive:ee,fleetServers:et,selectedServerId:en,setSelectedServerId:er,handleServerReconnect:es,isDecisionQueueOpen:ea,setIsDecisionQueueOpen:el,decisions:ei,decisionProcessing:eo,handleDecisionApprove:ec,handleDecisionReject:ed,handleDecisionDismiss:eu,handleTaskCreate:ex,activityEvents:em,logViewerAgent:eh,setLogViewerAgent:ep,selectedAgentProfile:eg,setSelectedAgentProfile:ef}=rR(),{messages:eb,currentChannel:ev,setCurrentChannel:ey,currentThread:ej,setCurrentThread:eN,activeThreads:ek,totalUnreadThreadCount:eC,sendMessage:eS,isSending:eM,sendError:eL,thread:eD,viewMode:eA,setViewMode:eE,channelsList:eT,archivedChannelsList:eW,channelMessages:eP,selectedChannelId:eI,setSelectedChannelId:eB,selectedChannel:e_,hasMoreMessages:eR,channelUnreadState:eF,effectiveChannelMessages:eU,handleSelectChannel:eO,handleCreateChannel:eH,handleCreateChannelSubmit:ez,handleInviteToChannel:eG,handleInviteSubmit:eV,handleLeaveChannel:eZ,handleShowMembers:eK,handleRemoveMember:eJ,handleAddMember:e$,handleArchiveChannel:eY,handleUnarchiveChannel:eX,handleSendChannelMessage:e0,handleLoadMoreMessages:e1,isCreateChannelOpen:e2,setIsCreateChannelOpen:e5,isCreatingChannel:e4,isInviteChannelOpen:e3,setIsInviteChannelOpen:e8,inviteChannelTarget:e9,setInviteChannelTarget:e7,isInvitingToChannel:te,showMemberPanel:tt,setShowMemberPanel:tn,channelMembers:tr,currentHuman:ts,selectedDmAgents:ta,dedupedVisibleMessages:tl,dmSelectedAgentsByHuman:ti,handleDmAgentToggle:to,handleMainComposerSend:tc,onlineUsers:td,typingUsers:tu,sendTyping:tx,humanUsers:th,humanUnreadCounts:tp,handleReaction:tg,markDmSeen:tf,selectedUserProfile:tb,setSelectedUserProfile:ty,pendingMention:tj,setPendingMention:tw,hasUnreadMessages:tN,handlePresenceEvent:tk}=function(){let e=(0,s.useContext)(rX);if(!e)throw Error("useMessageContext must be used within a MessageProvider");return e}();h.current=tk;let[tC,tS]=(0,s.useState)(!1),[tM,tL]=(0,s.useState)(!1),[tD,tE]=(0,s.useState)(!1),[tT,tW]=(0,s.useState)(null),[tP,tI]=(0,s.useState)(!1),[tB,t_]=(0,s.useState)(!1),[tR,tF]=(0,s.useState)("dashboard"),[tU,tO]=(0,s.useState)(!1),[tH,tz]=(0,s.useState)(!1),[tG,tV]=(0,s.useState)(!1),[tq,tJ]=(0,s.useState)(!1),{toasts:t$,addToast:tY,dismissToast:tX}=function(){let[e,t]=(0,s.useState)([]),n=(0,s.useCallback)(e=>{let n=Math.random().toString(36).substring(2,9);return t(t=>[...t,{...e,id:n}]),n},[]),r=(0,s.useCallback)(e=>{t(t=>t.filter(t=>t.id!==e))},[]),a=(0,s.useCallback)(()=>{t([])},[]),l=(0,s.useCallback)((e,t)=>n({type:"info",title:e,message:t}),[n]),i=(0,s.useCallback)((e,t)=>n({type:"success",title:e,message:t}),[n]),o=(0,s.useCallback)((e,t)=>n({type:"warning",title:e,message:t}),[n]),c=(0,s.useCallback)((e,t)=>n({type:"error",title:e,message:t}),[n]),d=(0,s.useCallback)((e,t,r)=>n({type:"message",title:"New Message",message:t,agentName:e,action:r}),[n]);return{toasts:e,addToast:n,dismissToast:r,clearToasts:a,info:l,success:i,warning:o,error:c,message:d}}(),[tQ,t0]=(0,s.useState)(new Set),{steps:t1,status:t2,history:t4,isLoading:t3,selectTrajectory:t6,selectedTrajectoryId:t8}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{pollInterval:t=2e3,autoPoll:n=!0,trajectoryId:r,apiBaseUrl:a=""}=e,[l,i]=(0,s.useState)([]),[o,c]=(0,s.useState)(null),[d,u]=(0,s.useState)([]),[x,m]=(0,s.useState)(!0),[h,p]=(0,s.useState)(null),[g,f]=(0,s.useState)(r||null),b=(0,s.useRef)(null),v=(0,s.useRef)(!1),y=(0,s.useRef)(!1),j=(0,s.useRef)(g),w=(0,s.useRef)(0),N=(0,s.useCallback)(async()=>{try{let e=a?"".concat(a,"/api/trajectory"):(0,tZ.kG)("/api/trajectory"),t=await fetch(e,{credentials:"include"}),n=await t.json();!1!==n.success&&c({active:n.active,trajectoryId:n.trajectoryId,phase:n.phase,task:n.task})}catch(e){console.error("[useTrajectory] Status fetch error:",e)}},[a]),k=(0,s.useCallback)(async()=>{try{let e=a?"".concat(a,"/api/trajectory/history"):(0,tZ.kG)("/api/trajectory/history"),t=await fetch(e,{credentials:"include"}),n=await t.json(),r=function(e){if(!e||"object"!=typeof e)return{success:!1,trajectories:[],error:"Invalid history response"};let t=Object.prototype.hasOwnProperty.call(e,"success");if(Array.isArray(e.trajectories)){let n=e.trajectories,r=!t||!0===e.success;return{success:!!r,trajectories:r?n:[]}}return Array.isArray(e)?{success:!0,trajectories:e}:{success:!1,trajectories:[],error:"History payload missing trajectories"}}(n);r.success&&u(r.trajectories||[])}catch(e){console.error("[useTrajectory] History fetch error:",e)}},[a]),C=(0,s.useCallback)(async()=>{let e=++w.current;try{let t=g?"/api/trajectory/steps?trajectoryId=".concat(encodeURIComponent(g)):"/api/trajectory/steps",n=a?"".concat(a).concat(t):(0,tZ.kG)(t),r=await fetch(n,{credentials:"include"}),s=await r.json(),l=function(e){if(!e||"object"!=typeof e)return{success:!1,steps:[],error:"Invalid steps response"};let t=Object.prototype.hasOwnProperty.call(e,"success");if(Array.isArray(e.steps)){var n;let r=!t||!0===e.success,s=null!==(n=e.steps)&&void 0!==n?n:[];return{success:!!r,steps:r?s:[],error:r?void 0:e.error}}return Array.isArray(e)?{success:!0,steps:e}:{success:!1,steps:[],error:"Steps payload missing steps"}}(s);if(e!==w.current){console.log("[useTrajectory] Ignoring superseded fetch (request",e,"current",w.current,")");return}if(g!==j.current){console.log("[useTrajectory] Ignoring stale fetch for",g,"current is",j.current);return}l.success?(i(l.steps||[]),p(null)):p(l.error||"Failed to fetch trajectory steps")}catch(t){e===w.current&&g===j.current&&(console.error("[useTrajectory] Steps fetch error:",t),p(t.message))}},[a,g]),S=(0,s.useCallback)(e=>{let t=""===e?null:e;t!==g&&(w.current++,j.current=t,i([]),null!==t&&m(!0),f(t))},[g]),M=(0,s.useCallback)(async()=>{m(!0),await Promise.all([N(),C(),k()]),m(!1)},[N,C,k]);return(0,s.useEffect)(()=>{j.current=g},[g]),(0,s.useEffect)(()=>{y.current||(y.current=!0,M())},[M]),(0,s.useEffect)(()=>{if(!v.current){v.current=!0;return}let e=!1;return m(!0),C().finally(()=>{e||m(!1)}),()=>{e=!0}},[g,C]),(0,s.useEffect)(()=>{if(!n)return;b.current=setInterval(()=>{C(),N()},t);let e=setInterval(k,1e4);return()=>{b.current&&clearInterval(b.current),clearInterval(e)}},[n,t,C,N,k]),{steps:l,status:o,history:d,isLoading:x,error:h,refresh:M,selectTrajectory:S,selectedTrajectoryId:g}}({autoPoll:tq}),t9=(0,s.useMemo)(()=>{var e,t;return t8&&null!==(t=null===(e=t4.find(e=>e.id===t8))||void 0===e?void 0:e.title)&&void 0!==t?t:null},[t8,t4]),{navigateToChannel:t7,navigateToDm:ne,navigateToAgent:nn,navigateToSettings:nr,navigateToActivity:ns,closeSettings:na}=function(e){let{onRouteChange:t}=e,n=(0,s.useRef)(!1),r=(0,s.useRef)(""),a=(0,s.useCallback)(function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],s=ry(e);s!==window.location.pathname&&(n.current=!0,r.current=s,t?window.history.replaceState({route:e},"",s):window.history.pushState({route:e},"",s),setTimeout(()=>{n.current=!1},0))},[]),l=(0,s.useCallback)(e=>{a({type:"channel",id:e})},[a]),i=(0,s.useCallback)(e=>{a({type:"dm",id:e})},[a]),o=(0,s.useCallback)(e=>{a({type:"agent",id:e})},[a]),c=(0,s.useCallback)(e=>{a({type:"settings",tab:e})},[a]),d=(0,s.useCallback)(()=>{a({type:"activity"})},[a]),u=(0,s.useCallback)(()=>{window.history.length>1?window.history.back():a({type:"activity"})},[a]);return(0,s.useEffect)(()=>{let e=e=>{let n=rv(window.location.pathname);r.current=window.location.pathname,t(n)};return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)},[t]),(0,s.useEffect)(()=>{let e=window.location.pathname;if(e!==r.current){r.current=e;let n=rv(e);("activity"!==n.type||e.includes("/app"))&&t(n)}},[t]),{navigate:a,navigateToChannel:l,navigateToDm:i,navigateToAgent:o,navigateToSettings:c,navigateToActivity:d,closeSettings:u,parseRoute:rv,buildPath:ry}}({onRouteChange:(0,s.useCallback)(e=>{switch(e.type){case"channel":e.id&&(eE("channels"),eB("activity"===e.id?rY:e.id));break;case"dm":case"agent":e.id&&(eE("local"),eB(void 0),ey(e.id));break;case"settings":tF(e.tab||"dashboard"),t_(!0);break;case"activity":eE("channels"),eB(rY)}},[ey,eE,eB])}),nl=(0,s.useCallback)(()=>{window.innerWidth<=768&&tS(!1)},[]),ni=(0,s.useCallback)(e=>{eE("local"),eB(void 0),W(e.name),ey(e.name),nn(e.name),nl()},[W,ey,nl,nn,eE,eB]),{addWorkspace:nc,switchWorkspace:nd}=rL(),nu=(0,s.useCallback)(e=>{_(e.id),eE("local"),eB(void 0),U(e),S.length>0&&nd(e.id).catch(e=>{console.error("Failed to switch workspace:",e)}),e.agents.length>0&&(W(e.agents[0].name),ey(e.agents[0].name)),nl()},[W,ey,nl,S.length,U,eE,eB,_,nd]),nx=(0,s.useCallback)(e=>{eE("local"),eB(void 0),ey(e.name),tf(e.name),ne(e.name),nl()},[nl,tf,ey,ne,eE,eB]),nm=(0,s.useCallback)(()=>{Y(null),K(!0)},[Y,K]),nh=(0,s.useCallback)(()=>{tF("dashboard"),t_(!0),nr("dashboard")},[nr]),np=(0,s.useCallback)(()=>{tF("workspace"),t_(!0),nr("workspace")},[nr]),nf=(0,s.useCallback)(()=>{tF("billing"),t_(!0),nr("billing")},[nr]),nb=(0,s.useCallback)(e=>{ep(e)},[ep]),nv=(0,s.useCallback)((e,t)=>{e!==(null==b?void 0:b.displayName)&&(eE("local"),eB(void 0),"agent"===t&&W(e),ey(e),nl())},[null==b?void 0:b.displayName,W,ey,nl,eE,eB]),ny=(0,s.useCallback)(async(e,t)=>{let n=await eS(e,t);if(n){let t=A.find(t=>t.name===e);t?(W(t.name),ey(t.name)):ey(e)}return n},[eS,W,ey,A]),nj=(0,s.useCallback)(async(e,t)=>{tE(!0),tW(null);try{await nc(e,t),tL(!1)}catch(e){throw tW(e instanceof Error?e.message:"Failed to add workspace"),e}finally{tE(!1)}},[nc]);(0,s.useEffect)(()=>{if(null==c?void 0:c.messages)for(let s of c.messages){var e,t,n,r;if((null===(e=s.content)||void 0===e?void 0:e.includes("auth_revoked"))||(null===(t=s.content)||void 0===t?void 0:t.includes("authentication_error")))try{let e=JSON.parse(s.content);if("auth_revoked"===e.type&&e.agent){let t=e.agent;tQ.has(t)||(t0(e=>new Set([...e,t])),tY({type:"error",title:"Authentication Expired",message:"".concat(t,"'s API credentials have expired. Please reconnect."),agentName:t,duration:0,action:{label:"Reconnect",onClick:()=>{window.location.href="/providers"}}}))}}catch(e){if((null===(n=s.content)||void 0===n?void 0:n.includes("OAuth token"))&&(null===(r=s.content)||void 0===r?void 0:r.includes("expired"))){let e=s.from;e&&!tQ.has(e)&&(t0(t=>new Set([...t,e])),tY({type:"error",title:"Authentication Expired",message:"".concat(e,"'s API credentials have expired. Please reconnect."),agentName:e,duration:0,action:{label:"Reconnect",onClick:()=>{window.location.href="/providers"}}}))}}}},[null==c?void 0:c.messages,tQ,tY]),(0,s.useEffect)(()=>{b&&ev&&new Set(E.filter(e=>e.isHuman).map(e=>e.name.toLowerCase())).has(ev.toLowerCase())&&tf(ev)},[E,ev,b,tf]);let nw=(0,s.useMemo)(()=>ts?A.filter(e=>!e.isHuman).map(e=>{var t;let n=(null!==(t=ti[ts.name])&&void 0!==t?t:[]).includes(e.name);return{id:"dm-toggle-".concat(ts.name,"-").concat(e.name),label:"".concat(n?"Remove":"Invite"," ").concat(e.name," in DM"),description:"DM with ".concat(ts.name),category:"actions",action:()=>to(e.name)}}):[],[A,ts,ti,to]),nN=(0,s.useMemo)(()=>{let e=[];return e.push({id:"channels-view",label:"Go to Channels",description:"Switch to channel messaging view",category:"channels",shortcut:"Cmd+Shift+C",action:()=>eE("channels")}),e.push({id:"channels-create",label:"Create Channel",description:"Create a new messaging channel",category:"channels",action:()=>{eE("channels"),eH()}}),eT.forEach(t=>{let n=t.unreadCount>0?" (".concat(t.unreadCount," unread)"):"";e.push({id:"channel-switch-".concat(t.id),label:t.isDm?"@".concat(t.name):"#".concat(t.name),description:t.description||"Switch to ".concat(t.isDm?"DM":"channel").concat(n),category:"channels",action:()=>{eE("channels"),eB(t.id)}})}),e},[eT,eH,eE,eB]);return(0,s.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"k"===e.key&&(e.preventDefault(),tI(!0)),(e.metaKey||e.ctrlKey)&&e.shiftKey&&"s"===e.key&&(e.preventDefault(),nm()),(e.metaKey||e.ctrlKey)&&e.shiftKey&&"c"===e.key&&(e.preventDefault(),eE("channels")),(e.metaKey||e.ctrlKey)&&"n"===e.key&&(e.preventDefault(),tz(!0)),"Escape"===e.key&&(tI(!1),K(!1),tz(!1),tJ(!1),tB&&(t_(!1),na()))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[nm,tB,na,K,eE]),(0,r.jsxs)("div",{className:"flex h-screen bg-bg-deep font-sans text-text-primary",children:[(0,r.jsx)("div",{className:"\n fixed inset-0 bg-black/60 backdrop-blur-sm z-[999] transition-opacity duration-200\n md:hidden\n ".concat(tC?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none","\n "),onClick:()=>tS(!1)}),(0,r.jsxs)("div",{className:"\n flex flex-col w-[280px] max-md:w-[85vw] max-md:max-w-[280px] h-screen bg-bg-primary border-r border-border-subtle\n fixed left-0 top-0 z-[1000] transition-transform duration-200\n md:relative md:translate-x-0 md:flex-shrink-0\n ".concat(tC?"translate-x-0":"-translate-x-full","\n "),children:[(0,r.jsx)("div",{className:"p-3 border-b border-sidebar-border",children:(0,r.jsx)(nt,{workspaces:w,activeWorkspaceId:null!=N?N:void 0,onSelect:M,onAddWorkspace:()=>{L.workspaces?(localStorage.removeItem("agentrelay_workspace_id"),window.location.href="/app?select=true"):tL(!0)},onWorkspaceSettings:j?np:void 0,isLoading:k})}),(0,r.jsx)($,{agents:F,bridgeAgents:R,projects:I,currentUserName:null==b?void 0:b.displayName,humanUnreadCounts:tp,currentProject:B,selectedAgent:null==T?void 0:T.name,viewMode:eA,isFleetAvailable:X,isConnected:d||C,isOpen:tC,activeThreads:ek,currentThread:ej,totalUnreadThreadCount:eC,channels:eT.filter(e=>!e.isDm&&!e.id.startsWith("dm:")).map(e=>({id:e.id,name:e.name,unreadCount:e.unreadCount,hasMentions:e.hasMentions})),archivedChannels:eW.filter(e=>!e.isDm&&!e.id.startsWith("dm:")).map(e=>{var t;return{id:e.id,name:e.name,unreadCount:null!==(t=e.unreadCount)&&void 0!==t?t:0,hasMentions:e.hasMentions}}),selectedChannelId:eI,isActivitySelected:eI===rY,activityUnreadCount:0,onActivitySelect:()=>{eB(rY),W(null),eE("channels"),ns()},onChannelSelect:e=>{let t=eT.find(t=>t.id===e.id)||eW.find(t=>t.id===e.id);t&&(eO(t),eE("channels"))},onCreateChannel:eH,onInviteToChannel:e=>{let t=eT.find(t=>t.id===e.id);t&&eG(t)},onArchiveChannel:e=>{let t=eT.find(t=>t.id===e.id);t&&eY(t)},onUnarchiveChannel:e=>{let t=eW.find(t=>t.id===e.id)||eT.find(t=>t.id===e.id);t&&eX(t)},onAgentSelect:ni,onHumanSelect:nx,onProjectSelect:nu,onViewModeChange:eE,onSpawnClick:nm,onReleaseClick:V,onLogsClick:nb,onProfileClick:ef,onThreadSelect:eN,onClose:()=>tS(!1),onSettingsClick:nh,onTrajectoryClick:()=>tJ(!0),hasActiveTrajectory:null==t2?void 0:t2.active,onFleetClick:()=>ee(!Q),isFleetViewActive:Q})]}),(0,r.jsxs)("main",{className:"flex-1 flex flex-col min-w-0 bg-bg-secondary/50 overflow-hidden",children:[(0,r.jsxs)("div",{className:"fixed top-0 left-0 right-0 z-50 md:sticky md:top-0 md:left-auto md:right-auto bg-bg-secondary",children:[(0,r.jsx)(ew,{currentChannel:ev,selectedAgent:T,projects:I,currentProject:I.find(e=>e.id===B)||null,recentProjects:O(I),viewMode:eA,selectedChannelName:null==e_?void 0:e_.name,onProjectChange:nu,onCommandPaletteOpen:()=>tI(!0),onSettingsClick:y?nh:void 0,onHistoryClick:()=>tO(!0),onNewConversationClick:()=>tz(!0),onFleetClick:()=>ee(!Q),isFleetViewActive:Q,onTrajectoryClick:()=>tJ(!0),hasActiveTrajectory:null==t2?void 0:t2.active,onMenuClick:()=>tS(!0),hasUnreadNotifications:tN}),(0,r.jsx)(rx,{onUpgradeClick:nf})]}),(0,r.jsx)("div",{className:"h-[52px] flex-shrink-0 md:hidden"}),b&&td.length>0&&(0,r.jsx)("div",{className:"flex items-center justify-end px-4 py-1 bg-bg-tertiary/80 border-b border-border-subtle flex-shrink-0",children:(0,r.jsx)(n4,{onlineUsers:td,onUserClick:ty})}),(0,r.jsxs)("div",{className:"flex-1 flex overflow-hidden min-h-0",children:[(0,r.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto ".concat(ej?"hidden md:block md:flex-[2]":""),children:[ts&&(0,r.jsxs)("div",{className:"px-4 py-2 border-b border-border-subtle bg-bg-secondary flex flex-col gap-2 sticky top-0 z-10",children:[(0,r.jsxs)("div",{className:"text-xs text-text-muted",children:["DM with ",(0,r.jsx)("span",{className:"font-semibold text-text-primary",children:ts.name}),". Invite agents:"]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[A.filter(e=>!e.isHuman).map(e=>{var t;let n=(null!==(t=ti[ts.name])&&void 0!==t?t:[]).includes(e.name);return(0,r.jsxs)("button",{onClick:()=>to(e.name),className:"px-3 py-1.5 text-xs font-medium rounded-lg transition-colors ".concat(n?"bg-accent-cyan text-bg-deep":"bg-bg-tertiary text-text-secondary hover:bg-bg-tertiary/80"),title:e.name,children:[n?"v ":"",e.name]},e.name)}),0===A.filter(e=>!e.isHuman).length&&(0,r.jsx)("span",{className:"text-xs text-text-muted",children:"No agents available"})]})]}),u&&!c&&x?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-text-muted text-center px-4",children:[(0,r.jsx)(r3,{}),(0,r.jsx)("h2",{className:"m-0 mb-2 font-display text-text-primary",children:"Connection Error"}),(0,r.jsx)("p",{className:"text-text-secondary",children:u.message}),(0,r.jsx)("button",{className:"mt-6 py-3 px-6 bg-gradient-to-r from-accent-cyan to-[#00b8d9] text-bg-deep font-semibold border-none rounded-xl cursor-pointer transition-all duration-150 hover:shadow-glow-cyan hover:-translate-y-0.5",onClick:()=>window.location.reload(),children:"Retry Connection"})]}):c?Q?(0,r.jsx)("div",{className:"p-4 h-full overflow-y-auto",children:(0,r.jsx)(n$,{servers:et,agents:A,selectedServerId:en,onServerSelect:er,onServerReconnect:es,isLoading:!c})}):eI===rY?(0,r.jsx)(i,{events:em,maxEvents:100}):"channels"===eA&&e_?(0,r.jsx)(rj.F,{channel:e_,messages:eU,currentUser:(null==b?void 0:b.displayName)||"Anonymous",currentUserInfo:b?{displayName:b.displayName,avatarUrl:b.avatarUrl}:void 0,onlineUsers:td,agents:A,humanUsers:th,isLoadingMore:!1,hasMoreMessages:eR&&!!N,unreadState:eF,onSendMessage:(e,t)=>e0(e,void 0,t),onLoadMore:e1,onThreadClick:e=>eN(e),onShowMembers:eK,onMemberClick:nv,onReaction:m?tg:void 0}):"channels"===eA?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-text-muted text-center px-4",children:[(0,r.jsx)(r6,{}),(0,r.jsx)("h2",{className:"m-0 mb-2 font-display text-text-primary",children:"Select a channel"}),(0,r.jsx)("p",{className:"text-text-secondary",children:"Choose a channel from the sidebar to start messaging"})]}):(0,r.jsx)(eq,{messages:tl,currentChannel:ev,currentThread:ej,onThreadClick:e=>eN(e),highlightedMessageId:null!=ej?ej:void 0,agents:E,currentUser:b,skipChannelFilter:null!==ts,showTimestamps:p.display.showTimestamps,autoScrollDefault:p.messages.autoScroll,compactMode:p.display.compactMode,onAgentClick:ef,onUserClick:ty,onLogsClick:nb,onlineUsers:td,onReaction:m?tg:void 0}):(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-text-muted text-center",children:[(0,r.jsx)(r4,{}),(0,r.jsx)("p",{className:"font-display text-text-secondary",children:"Connecting to dashboard..."})]})]}),ej&&(()=>{let e;let t="channels"===eA,n=e=>{var t;return{id:e.id,from:e.from,to:e.channelId,content:e.content,timestamp:e.timestamp,thread:e.threadId,isRead:e.isRead,replyCount:null===(t=e.threadSummary)||void 0===t?void 0:t.replyCount,threadSummary:e.threadSummary}},s=null,a=[],l=!1,i=!1;if(t&&(eD.isLoading||eD.parentMessage))s=eD.parentMessage,a=eD.replies,l=eD.isLoading,i=eD.hasMore,e=eD.loadMore;else if(t){let e=eU.find(e=>e.id===ej);if(e)s=n(e);else{let e=eU.filter(e=>e.threadId===ej).sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime());e[0]&&(s=n(e[0]))}a=eU.filter(e=>e.threadId===ej).map(n)}else s=eD.parentMessage,a=eD.replies,l=eD.isLoading,i=eD.hasMore,e=eD.loadMore;return(0,r.jsx)("div",{className:"w-full md:w-[400px] md:min-w-[320px] md:max-w-[500px] flex-shrink-0 h-full overflow-hidden",children:(0,r.jsx)(eQ,{originalMessage:s,replies:a,onClose:()=>eN(null),showTimestamps:p.display.showTimestamps,isLoading:l,hasMore:i,onLoadMore:e,onReply:async e=>t&&e_?e0(e,ej):eD.sendReply(e),isSending:eM,currentUser:b})})})()]}),tu.length>0&&(0,r.jsx)("div",{className:"px-4 bg-bg-tertiary border-t border-border-subtle",children:(0,r.jsx)(n2,{typingUsers:tu})}),"channels"!==eA&&(0,r.jsx)("div",{className:"p-2 sm:p-4 bg-bg-tertiary border-t border-border-subtle",children:(0,r.jsx)(n5.M,{agents:A,humanUsers:th,onSend:tc,onTyping:tx,isSending:eM,error:eL,insertMention:tj,onMentionInserted:()=>tw(void 0),enableFileAutocomplete:!0,placeholder:"Message @".concat(ev,"...")})})]}),(0,r.jsx)(e6,{isOpen:tP,onClose:()=>tI(!1),agents:A,projects:I,currentProject:B,onAgentSelect:ni,onProjectSelect:nu,onSpawnClick:nm,onTaskCreate:ex,onGeneralClick:()=>{W(null),eB("#general"),eE("channels")},customCommands:[...nw,...nN]}),(0,r.jsx)(tm,{isOpen:Z,onClose:()=>K(!1),onSpawn:G,existingAgents:A.map(e=>e.name),isSpawning:q,error:J,workspaceId:null!=N?N:void 0,agentDefaults:p.agentDefaults,repos:H,activeRepoId:null!==(o=null===(t=H.find(e=>e.id===B))||void 0===t?void 0:t.id)&&void 0!==o?o:null===(n=H[0])||void 0===n?void 0:n.id,connectedProviders:null==f?void 0:null===(a=f.connectedProviders)||void 0===a?void 0:a.map(e=>{var t;return null!==(t=({openai:"codex"})[e.provider])&&void 0!==t?t:e.provider})}),(0,r.jsx)(no,{isOpen:tM,onClose:()=>{tL(!1),tW(null)},onAdd:nj,isAdding:tD,error:tT}),(0,r.jsx)(rj.hG,{isOpen:e2,onClose:()=>e5(!1),onCreate:ez,isLoading:e4,existingChannels:eT.map(e=>e.name),availableMembers:A.map(e=>e.name),workspaceId:null!=N?N:void 0}),(0,r.jsx)(rj.PC,{isOpen:e3,channelName:(null==e9?void 0:e9.name)||"",onClose:()=>{e8(!1),e7(null)},onInvite:eV,isLoading:te,availableMembers:A.map(e=>e.name)}),e_&&(0,r.jsx)(rj.pw,{channel:e_,members:tr,isOpen:tt,onClose:()=>tn(!1),onAddMember:e$,onRemoveMember:eJ,onUpdateRole:()=>{},currentUserId:null==b?void 0:b.displayName,availableAgents:A.map(e=>({name:e.name})),workspaceId:null!=N?N:void 0}),(0,r.jsx)(tK,{isOpen:tU,onClose:()=>tO(!1)}),(0,r.jsx)(tv,{isOpen:tH,onClose:()=>tz(!1),onSend:ny,agents:A,isSending:eM,error:eL}),eh&&(0,r.jsx)(ng,{agent:eh,isOpen:!0,onClose:()=>ep(null),availableAgents:A,onAgentChange:ep}),tq&&(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex bg-black/50 backdrop-blur-sm",onClick:()=>tJ(!1),children:(0,r.jsxs)("div",{className:"ml-auto w-full max-w-3xl h-full bg-bg-primary shadow-2xl animate-in slide-in-from-right duration-300 flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border-subtle bg-bg-secondary",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-blue-500/20 to-accent-cyan/20 flex items-center justify-center border border-blue-500/30",children:(0,r.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-blue-500",children:(0,r.jsx)("path",{d:"M3 12h4l3 9 4-18 3 9h4",strokeLinecap:"round",strokeLinejoin:"round"})})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"text-lg font-semibold text-text-primary m-0",children:"Trajectory Viewer"}),(0,r.jsx)("p",{className:"text-xs text-text-muted m-0",children:(null==t2?void 0:t2.active)?"Active: ".concat(t2.task||"Working..."):"Browse past trajectories"})]})]}),(0,r.jsx)("button",{onClick:()=>tJ(!1),className:"w-10 h-10 rounded-lg bg-bg-tertiary border border-border-subtle flex items-center justify-center text-text-muted hover:text-text-primary hover:bg-bg-hover hover:border-blue-500/50 transition-all",title:"Close (Esc)",children:(0,r.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),(0,r.jsx)("div",{className:"flex-1 overflow-hidden p-6",children:(0,r.jsx)(nC,{agentName:(null==t9?void 0:t9.slice(0,30))||(null==t2?void 0:null===(l=t2.task)||void 0===l?void 0:l.slice(0,30))||"Trajectories",steps:t1,history:t4,selectedTrajectoryId:t8,onSelectTrajectory:t6,isLoading:t3})})]})}),ea&&(0,r.jsx)("div",{className:"fixed left-4 bottom-4 w-[400px] max-h-[500px] z-50 shadow-modal",children:(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("button",{onClick:()=>el(!1),className:"absolute -top-2 -right-2 w-6 h-6 bg-bg-elevated border border-border rounded-full flex items-center justify-center text-text-muted hover:text-text-primary hover:bg-bg-hover z-10",title:"Close decisions",children:(0,r.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("path",{d:"M18 6L6 18M6 6l12 12"})})}),(0,r.jsx)(nF,{decisions:ei,onApprove:ec,onReject:ed,onDismiss:eu,isProcessing:eo})]})}),!ea&&ei.length>0&&(0,r.jsxs)("button",{onClick:()=>el(!0),className:"fixed left-4 bottom-4 w-12 h-12 bg-warning text-bg-deep rounded-full shadow-[0_0_20px_rgba(255,107,53,0.4)] flex items-center justify-center hover:scale-105 transition-transform z-50",title:"".concat(ei.length," pending decision").concat(ei.length>1?"s":""),children:[(0,r.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,r.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),ei.length>0&&(0,r.jsx)("span",{className:"absolute -top-1 -right-1 w-5 h-5 bg-error text-white text-[10px] font-bold rounded-full flex items-center justify-center",children:ei.length})]}),(0,r.jsx)(n3,{user:tb,onClose:()=>ty(null),onMention:e=>{tw(e),ty(null)},onSendMessage:e=>{ey(e.username),tf(e.username),ty(null)}}),(0,r.jsx)(n7,{agent:eg,onClose:()=>ef(null),onMessage:e=>{W(e.name),ey(e.name),ef(null)},onLogs:nb,onRelease:V,summary:eg?P.get(eg.name.toLowerCase()):null}),(0,r.jsx)(rt,{isOpen:tG,onClose:()=>tV(!1),projects:I,hasArchitect:R.some(e=>"architect"===e.name.toLowerCase()),onArchitectSpawned:()=>tV(!1)}),tB&&(0,r.jsx)(tA,{currentUserId:null==f?void 0:f.id,initialTab:tR,onClose:()=>{t_(!1),na()},settings:p,onUpdateSettings:g,activeWorkspaceId:N,onReposChanged:z}),(0,r.jsx)(t5,{toasts:t$,onDismiss:tX,position:"top-right"})]})}function r4(){return(0,r.jsx)("svg",{className:"animate-spin mb-4 text-accent-cyan",width:"28",height:"28",viewBox:"0 0 24 24",children:(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}function r3(){return(0,r.jsxs)("svg",{className:"text-error mb-4",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,r.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}function r6(){return(0,r.jsxs)("svg",{className:"text-text-muted mb-4",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("line",{x1:"4",y1:"9",x2:"20",y2:"9"}),(0,r.jsx)("line",{x1:"4",y1:"15",x2:"20",y2:"15"}),(0,r.jsx)("line",{x1:"10",y1:"3",x2:"8",y2:"21"}),(0,r.jsx)("line",{x1:"16",y1:"3",x2:"14",y2:"21"})]})}},3910:function(e,t,n){n.d(t,{M:function(){return h}});var r=n(7573),s=n(7653),a=n(5118),l=n(5493);function i(e,t){let n=e.substring(0,t).match(/(?:^|[\s(])@(\S*)$/);return n?n[1]:null}function o(e,t,n){let r=e.substring(0,n),s=e.substring(n),a=r.match(/(?:^|[\s(])@(\S*)$/);if(a){let n=a.index||0,r=a[0].charAt(0),l=e.substring(0,"@"===r?n:n+1),i="@".concat(t," "),o=l.length+i.length;return{value:l+i+s,cursorPosition:o}}return{value:e,cursorPosition:n}}function c(e){let{agents:t,humanUsers:n=[],inputValue:a,cursorPosition:c,onSelect:d,onClose:u,isVisible:x}=e,[m,h]=(0,s.useState)(0),p=(0,s.useRef)(null),g=(0,s.useMemo)(()=>i(a,c),[a,c]),f=(0,s.useMemo)(()=>{let e=new Map;return t.forEach(t=>{if(t.team){let n=e.get(t.team)||[];n.push(t),e.set(t.team,n)}}),e},[t]),b=(0,s.useMemo)(()=>{if(null===g)return[];let e=g.toLowerCase(),r=[];("*".includes(e)||"everyone".includes(e)||"all".includes(e)||"broadcast".includes(e)||""===e)&&r.push({name:"*",displayName:"@everyone",description:"Broadcast to all agents",isBroadcast:!0});let s=e.startsWith("team:")||e.startsWith("team"),a=e.startsWith("team:")?e.substring(5):e.replace(/^team/,"");(s||""===e)&&f.forEach((t,n)=>{let s=n.toLowerCase();(""===a||s.includes(a)||"team:".concat(s).includes(e))&&r.push({name:"team:".concat(n),displayName:"@team:".concat(n),description:"".concat(t.length," agent").concat(1!==t.length?"s":"",": ").concat(t.map(e=>e.name).join(", ")),isTeam:!0,memberCount:t.length})});let l=new Set(t.map(e=>e.name.toLowerCase()));return n.filter(t=>{let n=t.username.toLowerCase();return n.includes(e)&&!l.has(n)}).forEach(e=>{r.push({name:e.username,displayName:"@".concat(e.username),description:"Human user",isHuman:!0,avatarUrl:e.avatarUrl})}),t.filter(t=>t.name.toLowerCase().includes(e)).forEach(e=>{r.push({name:e.name,displayName:"@".concat(e.name),description:e.team?"".concat(e.status||"Agent"," \xb7 ").concat(e.team):e.status||"Agent"})}),r},[g,t,n,f]);(0,s.useEffect)(()=>{h(0)},[b.length]),(0,s.useEffect)(()=>{if(!p.current)return;let e=p.current.querySelector('[data-selected="true"]');e&&e.scrollIntoView({block:"nearest"})},[m]);let v=(0,s.useCallback)(e=>{if(x&&0!==b.length)switch(e.key){case"ArrowDown":e.preventDefault(),h(e=>(e+1)%b.length);break;case"ArrowUp":e.preventDefault(),h(e=>(e-1+b.length)%b.length);break;case"Enter":case"Tab":e.preventDefault();let t=b[m];if(t){let e=o(a,t.name,c);d(t.name,e.value)}break;case"Escape":e.preventDefault(),u()}},[x,b,m,a,c,d,u]);(0,s.useEffect)(()=>{if(x)return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[x,v]);let y=(0,s.useCallback)(e=>{let t=o(a,e.name,c);d(e.name,t.value)},[a,c,d]);return x&&0!==b.length?(0,r.jsx)("div",{className:"absolute bottom-full left-0 right-0 max-h-[200px] overflow-y-auto bg-bg-card border border-border rounded-lg shadow-modal z-[100] mb-1",ref:p,children:b.map((e,t)=>(0,r.jsxs)("div",{"data-selected":t===m,className:"flex items-center gap-2.5 py-2 px-3 cursor-pointer transition-colors duration-150 ".concat(t===m?"bg-bg-hover":"hover:bg-bg-hover"),onClick:()=>y(e),onMouseEnter:()=>h(t),children:[e.isHuman&&e.avatarUrl?(0,r.jsx)("img",{src:e.avatarUrl,alt:e.name,className:"w-7 h-7 rounded-md object-cover"}):(0,r.jsx)("div",{className:"w-7 h-7 rounded-md flex items-center justify-center text-white text-[11px] font-semibold",style:{background:e.isBroadcast?"var(--color-warning, #f59e0b)":e.isTeam?"var(--color-accent-purple, #a855f7)":e.isHuman?"#a855f7":(0,l.GW)(e.name).primary},children:e.isBroadcast?"*":e.isTeam?(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),(0,r.jsx)("circle",{cx:"9",cy:"7",r:"4"}),(0,r.jsx)("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),(0,r.jsx)("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}):e.isHuman?(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),(0,r.jsx)("circle",{cx:"12",cy:"7",r:"4"})]}):(0,l.hP)(e.name)}),(0,r.jsxs)("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-text-primary",children:e.displayName}),(0,r.jsx)("span",{className:"text-xs text-text-muted truncate",children:e.description})]})]},e.name))}):null}function d(e,t){let n=e.substring(0,t).match(/(?:^|[\s(])@(\S*)$/);if(n){let e=n[1];if(e.includes("/")||/\.[a-zA-Z0-9]{1,10}$/.test(e))return e}return null}function u(e,t,n){let r=e.substring(0,n),s=e.substring(n),a=r.match(/(?:^|[\s(])@(\S*)$/);if(a){let n=a.index||0,r=a[0].charAt(0);return e.substring(0,"@"===r?n:n+1)+"@".concat(t," ")+s}return e}let x=new Map;function m(e){let{inputValue:t,cursorPosition:n,onSelect:l,onClose:i,isVisible:o,apiBase:c=""}=e,[m,h]=(0,s.useState)(0),[p,g]=(0,s.useState)([]),[f,b]=(0,s.useState)(!1),[v,y]=(0,s.useState)(null),j=(0,s.useRef)(null),w=(0,s.useRef)(null),N=(0,s.useMemo)(()=>d(t,n),[t,n]);(0,s.useEffect)(()=>{if(!o||null===N){g([]);return}let e=N||"__root__",t=x.get(e);if(t&&Date.now()-t.timestamp<3e4){g(t.files),y(null);return}w.current&&w.current.abort();let n=new AbortController;w.current=n;let r=setTimeout(async()=>{b(!0),y(null);try{let t=N||"",r=c?"".concat(c,"/api/files?q=").concat(encodeURIComponent(t),"&limit=15"):(0,a.kG)("/api/files?q=".concat(encodeURIComponent(t),"&limit=15")),s=await fetch(r,{signal:n.signal});if(!s.ok)throw Error("Failed to fetch files");let l=((await s.json()).files||[]).map(e=>({path:e.path,name:e.name,isDirectory:e.isDirectory||!1}));x.set(e,{files:l,timestamp:Date.now()}),g(l)}catch(e){if(e instanceof Error&&"AbortError"===e.name)return;y("Failed to load files"),g([])}finally{b(!1)}},150);return()=>{clearTimeout(r),n.abort()}},[o,N,c]),(0,s.useEffect)(()=>{h(0)},[p.length]),(0,s.useEffect)(()=>{if(!j.current)return;let e=j.current.querySelector('[data-selected="true"]');e&&e.scrollIntoView({block:"nearest"})},[m]);let k=(0,s.useCallback)(e=>{if(o&&0!==p.length)switch(e.key){case"ArrowDown":e.preventDefault(),h(e=>(e+1)%p.length);break;case"ArrowUp":e.preventDefault(),h(e=>(e-1+p.length)%p.length);break;case"Enter":case"Tab":e.preventDefault();let r=p[m];if(r){let e=u(t,r.path,n);l(r.path,e)}break;case"Escape":e.preventDefault(),i()}},[o,p,m,t,n,l,i]);(0,s.useEffect)(()=>{if(o)return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[o,k]);let C=(0,s.useCallback)(e=>{let r=u(t,e.path,n);l(e.path,r)},[t,n,l]);return o&&(0!==p.length||f||v)?(0,r.jsxs)("div",{className:"absolute bottom-full left-0 right-0 max-h-[240px] overflow-y-auto bg-bg-card border border-border rounded-lg shadow-modal z-[100] mb-1",ref:j,children:[(0,r.jsxs)("div",{className:"px-3 py-1.5 text-[10px] uppercase tracking-wider text-text-muted border-b border-border-subtle flex items-center gap-2",children:[(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("path",{d:"M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"}),(0,r.jsx)("polyline",{points:"13 2 13 9 20 9"})]}),"Files ",N&&(0,r.jsxs)("span",{className:"text-text-dim",children:['matching "',N,'"']})]}),f&&0===p.length&&(0,r.jsxs)("div",{className:"px-3 py-4 text-sm text-text-muted text-center",children:[(0,r.jsx)("svg",{className:"animate-spin mx-auto mb-2",width:"16",height:"16",viewBox:"0 0 24 24",children:(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})}),"Searching files..."]}),v&&(0,r.jsx)("div",{className:"px-3 py-4 text-sm text-red-400 text-center",children:v}),p.map((e,t)=>(0,r.jsxs)("div",{"data-selected":t===m,className:"flex items-center gap-2.5 py-2 px-3 cursor-pointer transition-colors duration-150 ".concat(t===m?"bg-bg-hover":"hover:bg-bg-hover"),onClick:()=>C(e),onMouseEnter:()=>h(t),children:[(0,r.jsx)("div",{className:"w-7 h-7 rounded-md flex items-center justify-center text-text-muted",style:{background:e.isDirectory?"rgba(251, 191, 36, 0.15)":"rgba(96, 165, 250, 0.15)"},children:e.isDirectory?(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#fbbf24",strokeWidth:"2",children:(0,r.jsx)("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})}):(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#60a5fa",strokeWidth:"2",children:[(0,r.jsx)("path",{d:"M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"}),(0,r.jsx)("polyline",{points:"13 2 13 9 20 9"})]})}),(0,r.jsxs)("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-text-primary truncate",children:e.name}),(0,r.jsx)("span",{className:"text-xs text-text-dim truncate",children:e.path})]})]},e.path)),!f&&!v&&0===p.length&&N&&(0,r.jsxs)("div",{className:"px-3 py-4 text-sm text-text-muted text-center",children:['No files found matching "',N,'"']})]}):null}function h(e){let{onSend:t,onTyping:n,isSending:l=!1,disabled:o=!1,placeholder:u="Type a message...",error:x,agents:h=[],humanUsers:p=[],enableFileAutocomplete:g=!1,insertMention:f,onMentionInserted:b,className:v=""}=e,[y,j]=(0,s.useState)(""),[w,N]=(0,s.useState)(0),[k,C]=(0,s.useState)(!1),[S,M]=(0,s.useState)(!1),[L,D]=(0,s.useState)([]),A=(0,s.useRef)(null),E=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(f&&b){let e="@".concat(f," "),t=A.current;if(t){let n=t.selectionStart||y.length;j(y.slice(0,n)+e+y.slice(n)),setTimeout(()=>{t.focus();let r=n+e.length;t.setSelectionRange(r,r)},0)}else j(t=>t+e);b()}},[f,b,y]);let T=(0,s.useCallback)(async e=>{for(let t of e){let e=crypto.randomUUID(),n=URL.createObjectURL(t);D(r=>[...r,{id:e,file:t,preview:n,isUploading:!0}]);try{let n=await a.api.uploadAttachment(t);n.success&&n.data?D(t=>t.map(t=>t.id===e?{...t,isUploading:!1,uploadedId:n.data.attachment.id}:t)):D(t=>t.map(t=>t.id===e?{...t,isUploading:!1,error:n.error||"Upload failed"}:t))}catch(t){D(t=>t.map(t=>t.id===e?{...t,isUploading:!1,error:"Upload failed"}:t))}}},[]),W=(0,s.useCallback)(e=>{if(!e||0===e.length)return;let t=Array.from(e).filter(e=>e.type.startsWith("image/"));t.length>0&&T(t)},[T]),P=(0,s.useCallback)(e=>{let t=e.clipboardData;if(!t)return;let n=[];if(t.files&&t.files.length>0&&(n=Array.from(t.files).filter(e=>e.type.startsWith("image/"))),0===n.length&&t.items){for(let e of Array.from(t.items))if("file"===e.kind&&e.type.startsWith("image/")){let t=e.getAsFile();t&&n.push(t)}}n.length>0&&(e.preventDefault(),T(n))},[T]),I=(0,s.useCallback)(e=>{D(t=>{let n=t.find(t=>t.id===e);return n&&URL.revokeObjectURL(n.preview),t.filter(t=>t.id!==e)})},[]),B=async e=>{e.preventDefault();let n=y.trim().length>0,r=L.length>0;if(!n&&!r||l||o||L.some(e=>e.isUploading))return;let s=L.filter(e=>e.uploadedId).map(e=>e.uploadedId),a=y.trim();!a&&s.length>0&&(a="[Screenshot attached]"),await t(a,s.length>0?s:void 0)&&(L.forEach(e=>URL.revokeObjectURL(e.preview)),j(""),D([]),C(!1),M(!1))},_=(y.trim()||L.length>0)&&!l&&!o&&!L.some(e=>e.isUploading);return(0,r.jsxs)("form",{className:"flex flex-col gap-1.5 sm:gap-2 ".concat(v),onSubmit:B,children:[L.length>0&&(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5 sm:gap-2 p-1.5 sm:p-2 bg-bg-card rounded-lg border border-border-subtle",children:L.map(e=>(0,r.jsxs)("div",{className:"relative group",children:[(0,r.jsx)("img",{src:e.preview,alt:e.file.name,className:"h-16 w-auto rounded-lg object-cover ".concat(e.isUploading?"opacity-50":""," ").concat(e.error?"border-2 border-error":"")}),e.isUploading&&(0,r.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,r.jsx)("svg",{className:"animate-spin h-5 w-5 text-accent-cyan",viewBox:"0 0 24 24",children:(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}),e.error&&(0,r.jsx)("div",{className:"absolute bottom-0 left-0 right-0 bg-error/90 text-white text-[10px] px-1 py-0.5 truncate",children:e.error}),(0,r.jsx)("button",{type:"button",onClick:()=>I(e.id),className:"absolute -top-1.5 -right-1.5 w-5 h-5 bg-bg-tertiary border border-border-subtle rounded-full flex items-center justify-center text-text-muted hover:text-error hover:border-error transition-colors opacity-0 group-hover:opacity-100",title:"Remove",children:(0,r.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:[(0,r.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,r.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},e.id))}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 sm:gap-3",children:[(0,r.jsx)("input",{ref:E,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>W(e.target.files)}),(0,r.jsx)("button",{type:"button",onClick:()=>{var e;return null===(e=E.current)||void 0===e?void 0:e.click()},disabled:o,className:"p-2 sm:p-2.5 bg-bg-card border border-border-subtle rounded-lg sm:rounded-xl text-text-muted hover:text-accent-cyan hover:border-accent-cyan/50 transition-colors flex-shrink-0 disabled:opacity-50 disabled:cursor-not-allowed",title:"Attach screenshot (or paste from clipboard)",children:(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"sm:w-[18px] sm:h-[18px]",children:[(0,r.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),(0,r.jsx)("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),(0,r.jsx)("polyline",{points:"21 15 16 10 5 21"})]})}),(0,r.jsxs)("div",{className:"flex-1 relative min-w-0",children:[(h.length>0||p.length>0)&&(0,r.jsx)(c,{agents:h,humanUsers:p,inputValue:y,cursorPosition:w,onSelect:(e,t)=>{j(t),C(!1),M(!1),setTimeout(()=>{if(A.current){A.current.focus();let e=t.indexOf(" ")+1;A.current.setSelectionRange(e,e)}},0)},onClose:()=>C(!1),isVisible:k}),g&&(0,r.jsx)(m,{inputValue:y,cursorPosition:w,onSelect:(e,t)=>{j(t),M(!1),C(!1),setTimeout(()=>{if(A.current){A.current.focus();let e=t.indexOf(" ",1)+1;A.current.setSelectionRange(e,e)}},0)},onClose:()=>M(!1),isVisible:S}),(0,r.jsx)("textarea",{ref:A,className:"w-full py-2 sm:py-3 px-3 sm:px-4 bg-bg-card border border-border-subtle rounded-lg sm:rounded-xl text-sm font-sans text-text-primary outline-none transition-all duration-200 resize-none min-h-[40px] sm:min-h-[44px] max-h-[100px] sm:max-h-[120px] overflow-y-auto focus:border-accent-cyan/50 focus:shadow-[0_0_0_3px_rgba(0,217,255,0.1)] placeholder:text-text-muted disabled:opacity-50 disabled:cursor-not-allowed",placeholder:u,value:y,onChange:e=>{let t=e.target.value,r=e.target.selectionStart||0;if(j(t),N(r),null==n||n(t.trim().length>0),g&&null!==d(t,r)){M(!0),C(!1);return}if((h.length>0||p.length>0)&&null!==i(t,r)){C(!0),M(!1);return}C(!1),M(!1)},onKeyDown:e=>{if(!k&&!S||"ArrowDown"!==e.key&&"ArrowUp"!==e.key&&"Tab"!==e.key){if("Enter"===e.key&&e.altKey&&!k&&!S){e.preventDefault();let t=e.currentTarget,n=t.selectionStart,r=t.selectionEnd;j(y.slice(0,n)+"\n"+y.slice(r)),setTimeout(()=>{t.selectionStart=t.selectionEnd=n+1},0);return}"Enter"!==e.key||e.shiftKey||e.altKey||k||S||(e.preventDefault(),(y.trim()||L.length>0)&&!l&&!o&&B(e))}},onPaste:P,onSelect:e=>N(e.target.selectionStart||0),disabled:o||l,rows:1})]}),(0,r.jsx)("button",{type:"submit",className:"py-2 sm:py-3 px-3 sm:px-5 bg-gradient-to-r from-accent-cyan to-[#00b8d9] text-bg-deep font-semibold border-none rounded-lg sm:rounded-xl text-xs sm:text-sm cursor-pointer transition-all duration-150 hover:shadow-glow-cyan hover:-translate-y-0.5 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:translate-y-0 disabled:hover:shadow-none flex-shrink-0",disabled:!_,title:l?"Sending...":L.some(e=>e.isUploading)?"Uploading...":"Send message",children:l?(0,r.jsx)("span",{className:"hidden sm:inline",children:"Sending..."}):L.some(e=>e.isUploading)?(0,r.jsx)("span",{className:"hidden sm:inline",children:"Uploading..."}):(0,r.jsxs)("span",{className:"flex items-center gap-1 sm:gap-2",children:[(0,r.jsx)("span",{className:"hidden sm:inline",children:"Send"}),(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),(0,r.jsx)("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})]})}),x&&(0,r.jsx)("span",{className:"text-error text-xs ml-2",children:x})]}),(0,r.jsxs)("p",{className:"text-xs text-text-muted px-1",children:[(0,r.jsx)("kbd",{className:"px-1 py-0.5 bg-bg-tertiary rounded text-[10px]",children:"Enter"})," to send,"," ",(0,r.jsx)("kbd",{className:"px-1 py-0.5 bg-bg-tertiary rounded text-[10px]",children:"Shift/Option+Enter"})," for new line",(h.length>0||p.length>0)&&(0,r.jsxs)(r.Fragment,{children:[", ",(0,r.jsx)("kbd",{className:"px-1 py-0.5 bg-bg-tertiary rounded text-[10px]",children:"@"})," to mention"]})]})]})}},1722:function(e,t,n){n.d(t,{s:function(){return c}});var r=n(7573),s=n(7653),a=n(4199),l=n(3458);let i=["\uD83D\uDC4D","\uD83D\uDC4E","❤️","\uD83D\uDD25","\uD83D\uDC40","\uD83C\uDF89","\uD83D\uDE02","\uD83E\uDD14","✅","❌","\uD83D\uDE80","\uD83D\uDCAF","⚡","\uD83D\uDE4F","\uD83D\uDC4F","\uD83E\uDD16"];function o(e){var t,n;let{onSelect:a,onClose:o,anchorRef:c}=e,d=(0,s.useRef)(null);(0,s.useEffect)(()=>{function e(e){var t;!d.current||d.current.contains(e.target)||(null==c?void 0:null===(t=c.current)||void 0===t?void 0:t.contains(e.target))||o()}function t(e){"Escape"===e.key&&o()}return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[o]);let[u,x]=s.useState(null),m=s.useCallback(()=>{if(!(null==c?void 0:c.current))return;let e=c.current.getBoundingClientRect();x({top:e.top>88?e.top-80-4:e.bottom+4,left:e.left})},[c]);return(0,s.useEffect)(()=>(m(),window.addEventListener("scroll",m,!0),window.addEventListener("resize",m),()=>{window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m)}),[m]),(0,l.createPortal)((0,r.jsx)("div",{ref:d,style:{position:"fixed",top:null!==(t=null==u?void 0:u.top)&&void 0!==t?t:0,left:null!==(n=null==u?void 0:u.left)&&void 0!==n?n:0,zIndex:9999,visibility:u?"visible":"hidden",background:"var(--color-bg-elevated, #202030)",border:"1px solid var(--color-border-subtle, rgba(255,255,255,0.06))",borderRadius:8,padding:8,boxShadow:"0 10px 25px rgba(0,0,0,0.5)"},children:(0,r.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(8, 1fr)",gap:2},children:i.map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>{a(e),o()},style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:6,fontSize:18,cursor:"pointer",border:"none",background:"transparent",transition:"background 150ms"},onMouseEnter:e=>{e.currentTarget.style.background="var(--color-bg-hover, rgba(255,255,255,0.08))"},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},children:e},e))})}),document.body)}function c(e){let{reactions:t,messageId:n,currentUser:l,onToggleReaction:i}=e,[c,d]=(0,s.useState)(!1),u=(0,s.useRef)(null),x=t&&t.length>0;return(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1 mt-1.5",children:[x&&t.map(e=>{let t=!!l&&(e.agents||[]).includes(l);return(0,r.jsxs)("button",{type:"button",onClick:()=>i(n,e.emoji,t),className:"\n inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs border cursor-pointer transition-colors\n ".concat(t?"bg-accent-cyan/15 border-accent-cyan/40 text-accent-cyan":"bg-bg-tertiary border-border-subtle text-text-muted hover:bg-bg-hover","\n "),children:[(0,r.jsx)("span",{children:(0,a.pT)(e.emoji)}),(0,r.jsx)("span",{className:"font-medium",children:e.count})]},e.emoji)}),(0,r.jsx)("button",{ref:u,type:"button",onClick:()=>d(!c),className:"inline-flex items-center justify-center w-6 h-6 rounded-full text-xs text-text-muted bg-transparent border border-border-subtle hover:bg-bg-hover cursor-pointer transition-colors",title:"Add reaction",children:"+"}),c&&(0,r.jsx)(o,{anchorRef:u,onSelect:e=>{let r=t.find(t=>t.emoji===e);i(n,e,!!(l&&(null==r?void 0:r.agents.includes(l))))},onClose:()=>d(!1)})]})}},3318:function(e,t,n){n.d(t,{Fw:function(){return a},sv:function(){return l}});var r=n(7573),s=n(7653);function a(e){let{isProcessing:t,processingStartedAt:n,size:a="medium",showElapsed:l=!1,showLabel:i=!1}=e,[o,c]=(0,s.useState)(0);if((0,s.useEffect)(()=>{if(!t||!n){c(0);return}let e=()=>{c(Date.now()-n)};e();let r=setInterval(e,1e3);return()=>clearInterval(r)},[t,n]),!t)return null;let d={small:"w-1 h-1",medium:"w-1.5 h-1.5",large:"w-2 h-2"};return(0,r.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-accent-purple",title:"Processing...",children:[(0,r.jsxs)("span",{className:"inline-flex items-center ".concat({small:"gap-0.5",medium:"gap-1",large:"gap-1.5"}[a]),children:[(0,r.jsx)("span",{className:"".concat(d[a]," rounded-full bg-accent-purple animate-bounce"),style:{animationDelay:"0ms",animationDuration:"800ms"}}),(0,r.jsx)("span",{className:"".concat(d[a]," rounded-full bg-accent-purple animate-bounce"),style:{animationDelay:"150ms",animationDuration:"800ms"}}),(0,r.jsx)("span",{className:"".concat(d[a]," rounded-full bg-accent-purple animate-bounce"),style:{animationDelay:"300ms",animationDuration:"800ms"}})]}),i&&(0,r.jsx)("span",{className:"text-xs font-medium text-accent-purple",children:"thinking"}),l&&o>0&&(0,r.jsx)("span",{className:"text-xs text-accent-purple/70",children:(e=>{let t=Math.floor(e/1e3);return t<60?"".concat(t,"s"):"".concat(Math.floor(t/60),"m ").concat(t%60,"s")})(o)})]})}function l(e){let{isProcessing:t}=e;return t?(0,r.jsx)("span",{className:"thinking-dot-inline",title:"Processing...",children:(0,r.jsx)("span",{className:"thinking-dot-pulse"})}):null}},608:function(e,t,n){n.d(t,{F:function(){return Z},hG:function(){return K},PC:function(){return q},pw:function(){return en},archiveChannel:function(){return x},mi:function(){return o},Fk:function(){return f},getMessages:function(){return i},joinChannel:function(){return d},leaveChannel:function(){return u},Gn:function(){return l},Qh:function(){return h},Ah:function(){return g},bG:function(){return c},unarchiveChannel:function(){return m}}),new Date().toISOString(),new Date(Date.now()-3e5).toISOString(),new Date(Date.now()-36e5).toISOString(),new Date(Date.now()-18e5).toISOString(),new Date(Date.now()-72e5).toISOString(),new Date(Date.now()-6e6).toISOString(),Date.now(),new Date(Date.now()-36e5).toISOString(),new Date(Date.now()-18e5).toISOString(),new Date(Date.now()-3e5).toISOString();var r=n(5118);function s(){return localStorage.getItem("relay_username")||"Dashboard"}class a extends Error{constructor(e,t,n){super(e),this.status=t,this.body=n,this.name="ApiError"}}async function l(e){(0,r.$3)();let t=new URLSearchParams;e&&t.set("workspaceId",e);let n=(0,r.kG)("/api/channels?".concat(t.toString()));try{var s,l;let e=await fetch(n,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"});if(!e.ok)throw new a("Failed to fetch channels",e.status);let t=await e.json();return{channels:null!==(s=t.channels)&&void 0!==s?s:[],archivedChannels:null!==(l=t.archivedChannels)&&void 0!==l?l:[]}}catch(e){if(e instanceof a)throw e;throw new a("Network error fetching channels",0)}}async function i(e,t,n){var s;if("__activity__"===t)return{messages:[],hasMore:!1,unread:{count:0}};(0,r.$3)();let l=new URLSearchParams;if((null==n?void 0:n.limit)&&l.set("limit",String(n.limit)),null==n?void 0:n.before){let e=Date.parse(n.before);Number.isNaN(e)||l.set("before",String(e))}e&&l.set("workspaceId",e);let i="/api/channels/".concat(encodeURIComponent(t),"/messages").concat(l.toString()?"?".concat(l.toString()):""),o=await fetch((0,r.kG)(i),{method:"GET",headers:{"Content-Type":"application/json"}});if(!o.ok)throw new a("Failed to fetch channel messages",o.status);let c=await o.json();return{messages:null!==(s=c.messages)&&void 0!==s?s:[],hasMore:!!c.hasMore,unread:{count:0}}}async function o(e,t){(0,r.$3)();try{let n=(0,r._V)(),s={"Content-Type":"application/json"};n&&(s["X-CSRF-Token"]=n);let l=await fetch((0,r.kG)("/api/channels"),{method:"POST",headers:s,credentials:"include",body:JSON.stringify({name:t.name,description:t.description,isPrivate:"private"===t.visibility,invites:t.members,workspaceId:e})});if(!l.ok){let e=await l.json().catch(()=>({error:"Unknown error"}));throw new a(e.error||"Failed to create channel",l.status)}let i=await l.json();return{channel:{id:i.channel.id,name:i.channel.name,description:i.channel.description,visibility:i.channel.visibility,status:i.channel.status,createdAt:i.channel.createdAt,createdBy:i.channel.createdBy,memberCount:1,unreadCount:0,hasMentions:!1,isDm:!1}}}catch(e){if(e instanceof a)throw e;throw new a("Network error creating channel",0)}}async function c(e,t,n){(0,r.$3)();let l=s();try{let s=await fetch((0,r.kG)("/api/channels/message"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:l,channel:t,body:n.content,thread:n.threadId,attachmentIds:n.attachmentIds,workspaceId:e})});if(!s.ok){let e=await s.json().catch(()=>({error:"Unknown error"}));throw new a(e.error||"Failed to send message",s.status)}return{message:{id:"pending-".concat(Date.now()),channelId:t,from:l,fromEntityType:"user",content:n.content,timestamp:new Date().toISOString(),threadId:n.threadId,isRead:!0}}}catch(e){if(e instanceof a)throw e;throw new a("Network error sending message",0)}}async function d(e,t){(0,r.$3)();let n=s();try{let s=await fetch((0,r.kG)("/api/channels/join"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:n,channel:t,workspaceId:e})});if(!s.ok){let e=await s.json().catch(()=>({error:"Unknown error"}));throw new a(e.error||"Failed to join channel",s.status)}return{id:t,name:t.startsWith("#")?t.slice(1):t,visibility:"public",status:"active",createdAt:new Date().toISOString(),createdBy:n,memberCount:1,unreadCount:0,hasMentions:!1,isDm:t.startsWith("dm:")}}catch(e){if(e instanceof a)throw e;throw new a("Network error joining channel",0)}}async function u(e,t){(0,r.$3)();let n=s();try{let s=await fetch((0,r.kG)("/api/channels/leave"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:n,channel:t,workspaceId:e})});if(!s.ok){let e=await s.json().catch(()=>({error:"Unknown error"}));throw new a(e.error||"Failed to leave channel",s.status)}}catch(e){if(e instanceof a)throw e;throw new a("Network error leaving channel",0)}}async function x(e,t){(0,r.$3)();let n=await fetch((0,r.kG)("/api/channels/archive"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({channel:t,workspaceId:e})});if(!n.ok)throw new a("Failed to archive channel",n.status);return{id:t,name:t.startsWith("#")?t.slice(1):t,visibility:"public",status:"archived",createdAt:new Date().toISOString(),createdBy:s(),memberCount:0,unreadCount:0,hasMentions:!1,isDm:t.startsWith("dm:")}}async function m(e,t){(0,r.$3)();let n=await fetch((0,r.kG)("/api/channels/unarchive"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({channel:t,workspaceId:e})});if(!n.ok)throw new a("Failed to unarchive channel",n.status);return{id:t,name:t.startsWith("#")?t.slice(1):t,visibility:"public",status:"active",createdAt:new Date().toISOString(),createdBy:s(),memberCount:0,unreadCount:0,hasMentions:!1,isDm:t.startsWith("dm:")}}async function h(e,t,n){}async function p(e){(0,r.$3)();let t=new URLSearchParams;e&&t.set("workspaceId",e);try{var n,s;let e=(0,r.kG)("/api/channels/available-members?".concat(t.toString())),a=await fetch(e,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"});if(!a.ok)return console.error("[ChannelsAPI] Failed to fetch available members:",a.status),{members:[],agents:[]};let l=await a.json();return{members:null!==(n=l.members)&&void 0!==n?n:[],agents:null!==(s=l.agents)&&void 0!==s?s:[]}}catch(e){return console.error("[ChannelsAPI] Error fetching available members:",e),{members:[],agents:[]}}}async function g(e,t,n,s){let l=(0,r.kG)("/api/channels/admin-remove"),i=await fetch(l,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({channel:t.startsWith("#")?t:"#".concat(t),member:n})});if(!i.ok)throw new a((await i.json().catch(()=>({}))).error||"Failed to remove member",i.status)}async function f(e,t){try{let e=(0,r.kG)("/api/channels/".concat(encodeURIComponent(t),"/members")),n=await fetch(e,{method:"GET",headers:{"Content-Type":"application/json"}});if(!n.ok)return console.warn("[ChannelsAPI] Failed to get channel members:",n.statusText),[{id:s(),displayName:s(),entityType:"user",role:"owner",status:"online",joinedAt:new Date().toISOString()}];return(await n.json()).members||[]}catch(e){return console.error("[ChannelsAPI] Error getting channel members:",e),[{id:s(),displayName:s(),entityType:"user",role:"owner",status:"online",joinedAt:new Date().toISOString()}]}}var b=n(7573),v=n(7653);function y(e){let{channel:t,members:n=[],canEdit:r=!1,onEditChannel:s,onShowMembers:a,onShowPinned:l,onSearch:i}=e,[o,c]=(0,v.useState)(!1),d=t.isDm,u=d?t.name:"".concat(t.name),x=n.filter(e=>"online"===e.status).length;return(0,b.jsxs)("div",{className:"flex-shrink-0 border-b border-border-subtle bg-bg-primary",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-3",children:[(0,b.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,b.jsx)("div",{className:"\n flex-shrink-0 w-8 h-8 rounded-lg flex items-center justify-center\n ".concat(d?"bg-purple-500/10":"bg-accent-cyan/10","\n "),children:d?(0,b.jsx)(N,{className:"w-4 h-4 text-purple-400"}):(0,b.jsx)(w,{className:"w-4 h-4 text-accent-cyan"})}),(0,b.jsxs)("div",{className:"min-w-0",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("h1",{className:"text-base font-semibold text-text-primary truncate",children:u}),"archived"===t.status&&(0,b.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-warning/20 text-warning rounded",children:"Archived"}),"private"===t.visibility&&!d&&(0,b.jsx)(k,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"})]}),t.topic&&(0,b.jsx)("p",{className:"text-xs text-text-muted truncate mt-0.5",children:t.topic})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1",children:[(0,b.jsxs)("button",{onClick:a,className:"flex items-center gap-1.5 px-2 py-1.5 rounded-md text-text-muted hover:text-text-primary hover:bg-bg-hover transition-colors",title:"View members",children:[(0,b.jsx)(C,{className:"w-4 h-4"}),(0,b.jsxs)("span",{className:"text-xs",children:[t.memberCount,x>0&&(0,b.jsxs)("span",{className:"text-success ml-1",children:["(",x," online)"]})]})]}),(0,b.jsx)("div",{className:"w-px h-5 bg-border-subtle mx-1"}),i&&(0,b.jsx)("button",{onClick:i,className:"p-2 rounded-md text-text-muted hover:text-text-primary hover:bg-bg-hover transition-colors",title:"Search in channel",children:(0,b.jsx)(S,{className:"w-4 h-4"})}),l&&(0,b.jsx)("button",{onClick:l,className:"p-2 rounded-md text-text-muted hover:text-text-primary hover:bg-bg-hover transition-colors",title:"Pinned messages",children:(0,b.jsx)(M,{className:"w-4 h-4"})}),(0,b.jsx)("button",{onClick:()=>c(!o),className:"p-2 rounded-md transition-colors ".concat(o?"text-accent-cyan bg-accent-cyan/10":"text-text-muted hover:text-text-primary hover:bg-bg-hover"),title:"Channel details",children:(0,b.jsx)(L,{className:"w-4 h-4"})}),r&&s&&(0,b.jsx)("button",{onClick:s,className:"p-2 rounded-md text-text-muted hover:text-text-primary hover:bg-bg-hover transition-colors",title:"Channel settings",children:(0,b.jsx)(D,{className:"w-4 h-4"})})]})]}),o&&(0,b.jsx)("div",{className:"px-4 pb-3 border-t border-border-subtle pt-3 bg-bg-secondary/50",children:(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[t.description&&(0,b.jsxs)("div",{children:[(0,b.jsx)("h3",{className:"text-xs font-semibold text-text-muted uppercase tracking-wide mb-1",children:"Description"}),(0,b.jsx)("p",{className:"text-sm text-text-secondary",children:t.description})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("h3",{className:"text-xs font-semibold text-text-muted uppercase tracking-wide mb-1",children:"Created"}),(0,b.jsxs)("p",{className:"text-sm text-text-secondary",children:[new Date(t.createdAt).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})," by ",t.createdBy]})]}),n.length>0&&(0,b.jsxs)("div",{className:"sm:col-span-2",children:[(0,b.jsxs)("h3",{className:"text-xs font-semibold text-text-muted uppercase tracking-wide mb-2",children:["Members (",t.memberCount,")"]}),(0,b.jsxs)("div",{className:"flex flex-wrap gap-2",children:[n.slice(0,10).map(e=>(0,b.jsx)(j,{member:e},e.id)),t.memberCount>10&&(0,b.jsxs)("button",{onClick:a,className:"text-xs text-accent-cyan hover:underline",children:["+",t.memberCount-10," more"]})]})]})]})})]})}function j(e){let{member:t}=e;return(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 bg-bg-tertiary rounded-full text-sm",children:[t.avatarUrl?(0,b.jsx)("img",{src:t.avatarUrl,alt:t.displayName||t.id,className:"w-4 h-4 rounded-full object-cover"}):(0,b.jsx)("div",{className:"\n w-4 h-4 rounded-full flex items-center justify-center text-[9px] font-medium\n ".concat("user"===t.entityType?"bg-purple-500/30 text-purple-300":"bg-accent-cyan/30 text-accent-cyan","\n "),children:(t.displayName||t.id).charAt(0).toUpperCase()}),(0,b.jsx)("span",{className:"text-text-secondary truncate max-w-[100px]",children:t.displayName||t.id}),(0,b.jsx)("span",{className:"w-1.5 h-1.5 rounded-full ".concat("online"===t.status?"bg-success":"away"===t.status?"bg-warning":"bg-text-dim")})]})}function w(e){let{className:t}=e;return(0,b.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,b.jsx)("line",{x1:"4",y1:"9",x2:"20",y2:"9"}),(0,b.jsx)("line",{x1:"4",y1:"15",x2:"20",y2:"15"}),(0,b.jsx)("line",{x1:"10",y1:"3",x2:"8",y2:"21"}),(0,b.jsx)("line",{x1:"16",y1:"3",x2:"14",y2:"21"})]})}function N(e){let{className:t}=e;return(0,b.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,b.jsx)("circle",{cx:"12",cy:"12",r:"4"}),(0,b.jsx)("path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-3.92 7.94"})]})}function k(e){let{className:t}=e;return(0,b.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,b.jsx)("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),(0,b.jsx)("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}function C(e){let{className:t}=e;return(0,b.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,b.jsx)("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),(0,b.jsx)("circle",{cx:"9",cy:"7",r:"4"}),(0,b.jsx)("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),(0,b.jsx)("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}function S(e){let{className:t}=e;return(0,b.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,b.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,b.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function M(e){let{className:t}=e;return(0,b.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,b.jsx)("line",{x1:"12",y1:"17",x2:"12",y2:"22"}),(0,b.jsx)("path",{d:"M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z"})]})}function L(e){let{className:t}=e;return(0,b.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,b.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,b.jsx)("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),(0,b.jsx)("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]})}function D(e){let{className:t}=e;return(0,b.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,b.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,b.jsx)("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}var A=n(1722),E=n(3318),T=n(1832),W=n(3862);function P(e){let{messages:t,unreadState:n,currentUser:r,currentUserInfo:s,onlineUsers:a=[],agents:l=[],humanUsers:i=[],isLoadingMore:o=!1,hasMore:c=!1,onLoadMore:d,onThreadClick:u,onMemberClick:x,onReaction:m}=e,h=(0,v.useRef)(null),p=(0,v.useRef)(null),[g,f]=(0,v.useState)(!0),[y,j]=(0,v.useState)(!1),w=(0,v.useMemo)(()=>{let e=[],n="";return t.forEach(t=>{let r=new Date(t.timestamp).toDateString();r!==n?(n=r,e.push({date:r,messages:[t]})):e[e.length-1].messages.push(t)}),e},[t]),N=(0,v.useCallback)(()=>{let e=h.current;if(!e)return;let{scrollTop:t,scrollHeight:n,clientHeight:r}=e,s=n-t-r,a=s<100;f(a),j(!a&&s>500),t<100&&c&&!o&&d&&d()},[c,o,d]);(0,v.useEffect)(()=>{g&&p.current&&p.current.scrollIntoView({behavior:"smooth"})},[t.length,g]),(0,v.useEffect)(()=>{p.current&&p.current.scrollIntoView()},[]);let k=(0,v.useCallback)(()=>{var e;null===(e=p.current)||void 0===e||e.scrollIntoView({behavior:"smooth"})},[]);return(0,b.jsxs)("div",{className:"relative flex-1 overflow-hidden",children:[(0,b.jsxs)("div",{ref:h,onScroll:N,className:"h-full overflow-y-auto px-4 py-2",children:[o&&(0,b.jsx)("div",{className:"flex justify-center py-4",children:(0,b.jsx)(U,{})}),c&&!o&&(0,b.jsx)("div",{className:"flex justify-center py-4",children:(0,b.jsx)("button",{onClick:d,className:"text-sm text-accent-cyan hover:underline",children:"Load earlier messages"})}),0===t.length&&!o&&(0,b.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-center py-12",children:[(0,b.jsx)("div",{className:"text-4xl mb-3",children:(0,b.jsx)(O,{className:"w-12 h-12 text-text-muted"})}),(0,b.jsx)("h3",{className:"text-lg font-medium text-text-primary mb-1",children:"No messages yet"}),(0,b.jsx)("p",{className:"text-sm text-text-muted",children:"Be the first to send a message in this channel"})]}),w.map(e=>{let{date:t,messages:o}=e;return(0,b.jsxs)("div",{children:[(0,b.jsx)(R,{date:t}),o.map((e,t)=>{let c=(null==n?void 0:n.firstUnreadMessageId)===e.id&&n&&n.count>0;return(0,b.jsxs)(v.Fragment,{children:[c&&(0,b.jsx)(F,{count:n.count}),(0,b.jsx)(I,{message:e,isOwn:e.from===r,onThreadClick:u,onMemberClick:x,onReaction:m,currentUser:r,currentUserInfo:s,onlineUsers:a,agents:l,humanUsers:i,showAvatar:function(e,t){if(0===t)return!0;let n=e[t],r=e[t-1];return n.from!==r.from||new Date(n.timestamp).getTime()-new Date(r.timestamp).getTime()>3e5}(o,t)})]},e.id)})]},t)}),l.filter(e=>e.isProcessing).map(e=>(0,b.jsxs)("div",{className:"flex gap-3 py-1 mt-3",children:[(0,b.jsx)("div",{className:"w-9 flex-shrink-0",children:(0,b.jsx)(B,{name:e.name,avatarUrl:e.avatarUrl,entityType:"agent"})}),(0,b.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,b.jsx)("div",{className:"flex items-center gap-2 mb-0.5",children:(0,b.jsx)("span",{className:"text-sm font-semibold text-text-primary",children:e.name})}),(0,b.jsx)(E.Fw,{isProcessing:!0,processingStartedAt:e.processingStartedAt,size:"small",showLabel:!0})]})]},"thinking-".concat(e.name))),(0,b.jsx)("div",{ref:p})]}),y&&(0,b.jsx)("button",{onClick:k,className:"absolute bottom-4 right-4 p-3 bg-bg-elevated border border-border-subtle rounded-full shadow-lg hover:bg-bg-hover transition-colors",title:"Scroll to bottom",children:(0,b.jsx)(z,{className:"w-5 h-5 text-text-primary"})})]})}function I(e){var t,n,r,s,a,l;let{message:i,isOwn:o,onThreadClick:c,onMemberClick:d,onReaction:u,currentUser:x,currentUserInfo:m,onlineUsers:h=[],agents:p=[],humanUsers:g=[],showAvatar:f}=e,v=i.threadSummary&&i.threadSummary.replyCount>0,y=null!==(a=null===(t=i.threadSummary)||void 0===t?void 0:t.replyCount)&&void 0!==a?a:0,j=(0,W.IG)(y),w=i.from.toLowerCase(),N=i.fromAvatarUrl||(o?null==m?void 0:m.avatarUrl:void 0)||(null===(n=h.find(e=>e.username.toLowerCase()===w))||void 0===n?void 0:n.avatarUrl)||(null===(r=g.find(e=>e.username.toLowerCase()===w))||void 0===r?void 0:r.avatarUrl)||(null===(s=p.find(e=>e.name.toLowerCase()===w))||void 0===s?void 0:s.avatarUrl);return(0,b.jsx)("div",{className:"group relative py-1 ".concat(f?"mt-3":""),children:(0,b.jsxs)("div",{className:"flex gap-3",children:[(0,b.jsx)("div",{className:"w-9 flex-shrink-0",children:f&&(0,b.jsx)(B,{name:i.from,avatarUrl:N,entityType:i.fromEntityType||"agent"})}),(0,b.jsxs)("div",{className:"flex-1 min-w-0",children:[f&&(0,b.jsxs)("div",{className:"flex items-center gap-2 mb-0.5",children:[(0,b.jsx)("button",{type:"button",onClick:()=>{!o&&d&&d(i.from,i.fromEntityType||"agent")},disabled:o||!d,className:"text-sm font-semibold ".concat(o?"text-accent-cyan cursor-default":"text-text-primary hover:underline cursor-pointer"," disabled:cursor-default disabled:hover:no-underline"),children:i.from}),(0,b.jsx)("span",{className:"text-xs text-text-muted",children:new Date(i.timestamp).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}),i.editedAt&&(0,b.jsx)("span",{className:"text-xs text-text-muted",children:"(edited)"}),(0,b.jsxs)("button",{className:"\n inline-flex items-center gap-1.5 p-1.5 rounded-lg transition-all duration-150 cursor-pointer border-none\n ".concat(v||i.threadId?"text-accent-cyan bg-accent-cyan/10 hover:bg-accent-cyan/20":"text-text-muted bg-transparent opacity-0 group-hover:opacity-100 hover:text-accent-cyan hover:bg-accent-cyan/10","\n "),onClick:()=>null==c?void 0:c(i.threadId||i.id),title:i.threadId?"View thread":v?j:"Reply in thread",children:[(0,b.jsx)(H,{className:"w-3.5 h-3.5"}),v&&(0,b.jsx)("span",{className:"text-xs font-medium",children:j})]})]}),(0,b.jsx)("div",{className:"text-sm text-text-primary whitespace-pre-wrap break-words",children:(0,T.y)(i.content,{mentions:i.mentions})}),i.attachments&&i.attachments.length>0&&(0,b.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:i.attachments.map(e=>(0,b.jsx)(_,{attachment:e},e.id))}),u&&(0,b.jsx)(A.s,{reactions:(l=i.reactions)?Object.entries(l).map(e=>{let[t,n]=e;return{emoji:t,count:n.length,agents:n}}):[],messageId:i.id,currentUser:x,onToggleReaction:u})]})]})})}function B(e){let{name:t,avatarUrl:n,entityType:r}=e;return n?(0,b.jsx)("img",{src:n,alt:t,className:"w-9 h-9 rounded-full object-cover"}):(0,b.jsx)("div",{className:"\n w-9 h-9 rounded-full flex items-center justify-center text-sm font-medium\n ".concat("user"===r?"bg-purple-500/30 text-purple-300":"bg-accent-cyan/30 text-accent-cyan","\n "),children:t.charAt(0).toUpperCase()})}function _(e){var t;let{attachment:n}=e;return n.mimeType.startsWith("image/")?(0,b.jsx)("a",{href:n.url,target:"_blank",rel:"noopener noreferrer",className:"block max-w-xs rounded-lg overflow-hidden border border-border-subtle hover:border-accent-cyan/30 transition-colors",children:(0,b.jsx)("img",{src:n.thumbnailUrl||n.url,alt:n.filename,className:"max-w-full max-h-48 object-cover"})}):(0,b.jsxs)("a",{href:n.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-3 py-2 bg-bg-tertiary rounded-lg border border-border-subtle hover:border-accent-cyan/30 transition-colors",children:[(0,b.jsx)(G,{className:"w-5 h-5 text-text-muted"}),(0,b.jsxs)("div",{className:"min-w-0",children:[(0,b.jsx)("p",{className:"text-sm text-text-primary truncate",children:n.filename}),(0,b.jsx)("p",{className:"text-xs text-text-muted",children:(t=n.size)<1024?"".concat(t," B"):t<1048576?"".concat((t/1024).toFixed(1)," KB"):"".concat((t/1048576).toFixed(1)," MB")})]})]})}function R(e){let{date:t}=e;return(0,b.jsxs)("div",{className:"flex items-center gap-3 py-3",children:[(0,b.jsx)("div",{className:"flex-1 h-px bg-border-subtle"}),(0,b.jsx)("span",{className:"text-xs font-medium text-text-muted px-2",children:function(e){let t=new Date(e),n=new Date,r=new Date(n);return(r.setDate(r.getDate()-1),t.toDateString()===n.toDateString())?"Today":t.toDateString()===r.toDateString()?"Yesterday":t.toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric"})}(t)}),(0,b.jsx)("div",{className:"flex-1 h-px bg-border-subtle"})]})}function F(e){let{count:t}=e;return(0,b.jsxs)("div",{className:"flex items-center gap-3 py-2 my-2",children:[(0,b.jsx)("div",{className:"flex-1 h-px bg-red-500/50"}),(0,b.jsxs)("span",{className:"text-xs font-semibold text-red-400 px-2 flex items-center gap-1",children:[(0,b.jsx)("span",{className:"w-2 h-2 bg-red-500 rounded-full"}),t," new ",1===t?"message":"messages"]}),(0,b.jsx)("div",{className:"flex-1 h-px bg-red-500/50"})]})}function U(){return(0,b.jsx)("div",{className:"w-5 h-5 border-2 border-accent-cyan/30 border-t-accent-cyan rounded-full animate-spin"})}function O(e){let{className:t}=e;return(0,b.jsx)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,b.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function H(e){let{className:t}=e;return(0,b.jsx)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,b.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function z(e){let{className:t}=e;return(0,b.jsx)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,b.jsx)("polyline",{points:"6 9 12 15 18 9"})})}function G(e){let{className:t}=e;return(0,b.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,b.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,b.jsx)("polyline",{points:"14 2 14 8 20 8"})]})}var V=n(3910);function Z(e){let{channel:t,members:n=[],messages:r,unreadState:s,currentUser:a,canEditChannel:l=!1,isLoadingMore:i=!1,hasMoreMessages:o=!1,agents:c=[],humanUsers:d=[],currentUserInfo:u,onlineUsers:x=[],onLoadMore:m,onSendMessage:h,onEditChannel:p,onShowMembers:g,onShowPinned:f,onSearch:j,onThreadClick:w,onTyping:N,onMarkRead:k,onMemberClick:C,onReaction:S}=e,M=(0,v.useCallback)((e,t)=>h(e,t),[h]),L=(0,v.useMemo)(()=>t.isDm?"Message ".concat(t.name):"Message #".concat(t.name),[t]),D="archived"===t.status;return(0,b.jsxs)("div",{className:"flex flex-col h-full bg-bg-primary",children:[(0,b.jsx)(y,{channel:t,members:n,canEdit:l,onEditChannel:p,onShowMembers:g,onShowPinned:f,onSearch:j}),(0,b.jsx)(P,{messages:r,unreadState:s,currentUser:a,currentUserInfo:u,onlineUsers:x,agents:c,humanUsers:d,isLoadingMore:i,hasMore:o,onLoadMore:m,onThreadClick:w,onMemberClick:C,onReaction:S}),D?(0,b.jsx)("div",{className:"px-4 py-3 bg-bg-secondary border-t border-border-subtle text-center",children:(0,b.jsx)("p",{className:"text-sm text-text-muted",children:"This channel is archived. Unarchive it to send messages."})}):(0,b.jsx)(V.M,{placeholder:L,onSend:M,onTyping:N,agents:c,humanUsers:d,enableFileAutocomplete:!0})]})}function K(e){let{isOpen:t,onClose:n,onCreate:r,isLoading:s=!1,existingChannels:a=[],availableMembers:l=[],workspaceId:i}=e,[o,c]=(0,v.useState)(""),[d,u]=(0,v.useState)(""),[x,m]=(0,v.useState)("public"),[h,g]=(0,v.useState)(""),[f,y]=(0,v.useState)([]),[j,w]=(0,v.useState)([]),[N,k]=(0,v.useState)([]),[C,S]=(0,v.useState)(!1);(0,v.useEffect)(()=>{t&&(S(!0),p(i).then(e=>{let{members:t,agents:n}=e;w(t),k(n)}).catch(e=>{console.error("[CreateChannelModal] Failed to fetch available members:",e)}).finally(()=>{S(!1)}))},[t,i]);let M=[...j,...N,...l.filter(e=>!N.some(t=>t.id===e)&&!j.some(t=>t.id===e)).map(e=>({id:e,displayName:e,type:"agent"}))],L=(0,v.useCallback)(()=>{c(""),u(""),m("public"),g(""),y([]),n()},[n]),D=(0,v.useCallback)(e=>{f.some(t=>t.id===e.id)||(y(t=>[...t,{id:e.id,type:e.type}]),g(""))},[f]),A=(0,v.useCallback)(e=>{y(t=>t.filter(t=>t.id!==e))},[]),E=(0,v.useCallback)(e=>{e.preventDefault(),o.trim()&&r({name:o.trim().toLowerCase().replace(/\s+/g,"-"),description:d.trim()||void 0,visibility:x,members:f.length>0?f:void 0})},[o,d,x,f,r]),T=M.filter(e=>{var t;return((null===(t=e.displayName)||void 0===t?void 0:t.toLowerCase().includes(h.toLowerCase()))||e.id.toLowerCase().includes(h.toLowerCase()))&&!f.some(t=>t.id===e.id)}).slice(0,8);if(!t)return null;let W=o.trim().toLowerCase().replace(/\s+/g,"-"),P=a.includes("#".concat(W)),I=W.length>=2&&W.length<=80&&/^[a-z0-9-]+$/.test(W),B=o.trim()&&I&&!P;return(0,b.jsx)(J,{onClose:L,children:(0,b.jsxs)("form",{onSubmit:E,className:"p-6 w-[400px] max-w-full",children:[(0,b.jsx)("h2",{className:"text-lg font-semibold text-text-primary mb-6",children:"Create a channel"}),(0,b.jsxs)("div",{className:"mb-4",children:[(0,b.jsx)("label",{className:"block text-sm font-medium text-text-primary mb-1.5",children:"Channel name"}),(0,b.jsxs)("div",{className:"relative",children:[(0,b.jsx)("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-text-muted",children:"#"}),(0,b.jsx)("input",{type:"text",value:o,onChange:e=>c(e.target.value),placeholder:"e.g., engineering",className:"w-full pl-7 pr-3 py-2 bg-bg-tertiary border border-border-subtle rounded-lg text-text-primary text-sm focus:outline-none focus:border-accent-cyan/50",autoFocus:!0})]}),o&&!I&&(0,b.jsx)("p",{className:"mt-1 text-xs text-red-400",children:"Channel names must be 2-80 characters, lowercase letters, numbers, and hyphens only"}),P&&(0,b.jsx)("p",{className:"mt-1 text-xs text-red-400",children:"A channel with this name already exists"})]}),(0,b.jsxs)("div",{className:"mb-4",children:[(0,b.jsxs)("label",{className:"block text-sm font-medium text-text-primary mb-1.5",children:["Description ",(0,b.jsx)("span",{className:"text-text-muted font-normal",children:"(optional)"})]}),(0,b.jsx)("textarea",{value:d,onChange:e=>u(e.target.value),placeholder:"What's this channel about?",rows:2,className:"w-full px-3 py-2 bg-bg-tertiary border border-border-subtle rounded-lg text-text-primary text-sm focus:outline-none focus:border-accent-cyan/50 resize-none"})]}),(0,b.jsxs)("div",{className:"mb-4",children:[(0,b.jsxs)("label",{className:"block text-sm font-medium text-text-primary mb-1.5",children:["Invite members ",(0,b.jsx)("span",{className:"text-text-muted font-normal",children:"(optional)"}),C&&(0,b.jsx)("span",{className:"ml-2 text-text-muted text-xs",children:"Loading..."})]}),(0,b.jsxs)("div",{className:"relative",children:[(0,b.jsx)("input",{type:"text",value:h,onChange:e=>g(e.target.value),placeholder:M.length>0?"Type agent or user name...":"No members available",className:"w-full px-3 py-2 bg-bg-tertiary border border-border-subtle rounded-lg text-text-primary text-sm focus:outline-none focus:border-accent-cyan/50"}),h&&T.length>0&&(0,b.jsx)("div",{className:"absolute z-10 w-full mt-1 bg-bg-secondary border border-border-subtle rounded-lg shadow-lg max-h-48 overflow-y-auto",children:T.map(e=>(0,b.jsxs)("button",{type:"button",onClick:()=>D(e),className:"w-full px-3 py-2 text-left text-sm text-text-primary hover:bg-bg-hover transition-colors flex items-center justify-between",children:[(0,b.jsx)("span",{children:e.displayName||e.id}),(0,b.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded ".concat("agent"===e.type?"bg-purple-500/20 text-purple-400":"bg-accent-cyan/20 text-accent-cyan"),children:"agent"===e.type?"Agent":"User"})]},e.id))}),!h&&M.length>0&&(0,b.jsxs)("div",{className:"mt-2 text-xs text-text-muted",children:[j.length>0&&(0,b.jsxs)("span",{children:[j.length," user",1!==j.length?"s":""]}),j.length>0&&N.length>0&&(0,b.jsx)("span",{children:", "}),N.length>0&&(0,b.jsxs)("span",{children:[N.length," agent",1!==N.length?"s":""]}),(0,b.jsx)("span",{children:" available"})]})]}),f.length>0&&(0,b.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-2",children:f.map(e=>(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs rounded-full ".concat("agent"===e.type?"bg-purple-500/10 text-purple-400":"bg-accent-cyan/10 text-accent-cyan"),children:[e.id,(0,b.jsxs)("span",{className:"text-[10px] opacity-70",children:["(","agent"===e.type?"Agent":"User",")"]}),(0,b.jsx)("button",{type:"button",onClick:()=>A(e.id),className:"hover:text-red-400 transition-colors",children:(0,b.jsx)(et,{className:"w-3 h-3"})})]},e.id))})]}),(0,b.jsxs)("div",{className:"mb-6",children:[(0,b.jsx)("label",{className:"block text-sm font-medium text-text-primary mb-2",children:"Visibility"}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("label",{className:"\n flex items-start gap-3 p-3 rounded-lg border cursor-pointer transition-colors\n ".concat("public"===x?"border-accent-cyan/30 bg-accent-cyan/5":"border-border-subtle hover:bg-bg-hover","\n "),children:[(0,b.jsx)("input",{type:"radio",name:"visibility",value:"public",checked:"public"===x,onChange:()=>m("public"),className:"mt-1"}),(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(Y,{className:"w-4 h-4 text-text-primary"}),(0,b.jsx)("span",{className:"text-sm font-medium text-text-primary",children:"Public"})]}),(0,b.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:"Anyone can join and view messages"})]})]}),(0,b.jsxs)("label",{className:"\n flex items-start gap-3 p-3 rounded-lg border cursor-pointer transition-colors\n ".concat("private"===x?"border-accent-cyan/30 bg-accent-cyan/5":"border-border-subtle hover:bg-bg-hover","\n "),children:[(0,b.jsx)("input",{type:"radio",name:"visibility",value:"private",checked:"private"===x,onChange:()=>m("private"),className:"mt-1"}),(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(X,{className:"w-4 h-4 text-text-primary"}),(0,b.jsx)("span",{className:"text-sm font-medium text-text-primary",children:"Private"})]}),(0,b.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:"Only invited members can join"})]})]})]})]}),(0,b.jsxs)("div",{className:"flex justify-end gap-3",children:[(0,b.jsx)("button",{type:"button",onClick:L,disabled:s,className:"px-4 py-2 text-sm font-medium text-text-secondary bg-bg-tertiary hover:bg-bg-hover rounded-lg transition-colors disabled:opacity-50",children:"Cancel"}),(0,b.jsxs)("button",{type:"submit",disabled:!B||s,className:"px-4 py-2 text-sm font-medium bg-accent-cyan text-bg-deep hover:bg-accent-cyan/90 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:[s&&(0,b.jsx)($,{className:"w-4 h-4"}),"Create Channel"]})]})]})})}function q(e){let{isOpen:t,channelName:n,onClose:r,onInvite:s,isLoading:a=!1,availableMembers:l=[]}=e,[i,o]=(0,v.useState)(""),[c,d]=(0,v.useState)([]),u=(0,v.useCallback)(()=>{o(""),d([]),r()},[r]),x=(0,v.useCallback)(e=>{let t=e.trim();t&&!c.includes(t)&&(d(e=>[...e,t]),o(""))},[c]),m=(0,v.useCallback)(e=>{d(t=>t.filter(t=>t!==e))},[]),h=(0,v.useCallback)(e=>{e.preventDefault(),0!==c.length&&s(c)},[c,s]),p=l.filter(e=>e.toLowerCase().includes(i.toLowerCase())&&!c.includes(e)).slice(0,5);return t?(0,b.jsx)(J,{onClose:u,children:(0,b.jsxs)("form",{onSubmit:h,className:"p-6 w-[400px] max-w-full",children:[(0,b.jsxs)("h2",{className:"text-lg font-semibold text-text-primary mb-2",children:["Invite to #",n]}),(0,b.jsx)("p",{className:"text-sm text-text-muted mb-6",children:"Add agents or users to this channel"}),(0,b.jsxs)("div",{className:"mb-4",children:[(0,b.jsx)("label",{className:"block text-sm font-medium text-text-primary mb-1.5",children:"Members to invite"}),(0,b.jsxs)("div",{className:"relative",children:[(0,b.jsx)("input",{type:"text",value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{"Enter"===e.key&&i.trim()&&(e.preventDefault(),x(i))},placeholder:"Type agent or user name...",className:"w-full px-3 py-2 bg-bg-tertiary border border-border-subtle rounded-lg text-text-primary text-sm focus:outline-none focus:border-accent-cyan/50",autoFocus:!0}),i&&p.length>0&&(0,b.jsx)("div",{className:"absolute z-10 w-full mt-1 bg-bg-secondary border border-border-subtle rounded-lg shadow-lg max-h-40 overflow-y-auto",children:p.map(e=>(0,b.jsx)("button",{type:"button",onClick:()=>x(e),className:"w-full px-3 py-2 text-left text-sm text-text-primary hover:bg-bg-hover transition-colors",children:e},e))})]}),c.length>0&&(0,b.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-2",children:c.map(e=>(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-accent-cyan/10 text-accent-cyan text-xs rounded-full",children:[e,(0,b.jsx)("button",{type:"button",onClick:()=>m(e),className:"hover:text-red-400 transition-colors",children:(0,b.jsx)(et,{className:"w-3 h-3"})})]},e))})]}),(0,b.jsxs)("div",{className:"flex justify-end gap-3",children:[(0,b.jsx)("button",{type:"button",onClick:u,disabled:a,className:"px-4 py-2 text-sm font-medium text-text-secondary bg-bg-tertiary hover:bg-bg-hover rounded-lg transition-colors disabled:opacity-50",children:"Cancel"}),(0,b.jsxs)("button",{type:"submit",disabled:0===c.length||a,className:"px-4 py-2 text-sm font-medium bg-accent-cyan text-bg-deep hover:bg-accent-cyan/90 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:[a&&(0,b.jsx)($,{className:"w-4 h-4"}),"Invite ",c.length>0?"(".concat(c.length,")"):""]})]})]})}):null}function J(e){let{children:t,onClose:n}=e;return(0,b.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:n,children:[(0,b.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,b.jsx)("div",{className:"relative bg-bg-elevated border border-border-subtle rounded-xl shadow-2xl animate-in fade-in zoom-in-95 duration-150",onClick:e=>e.stopPropagation(),children:t})]})}function $(e){let{className:t}=e;return(0,b.jsxs)("svg",{className:"animate-spin ".concat(t),viewBox:"0 0 24 24",fill:"none",children:[(0,b.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,b.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}function Y(e){let{className:t}=e;return(0,b.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,b.jsx)("line",{x1:"4",y1:"9",x2:"20",y2:"9"}),(0,b.jsx)("line",{x1:"4",y1:"15",x2:"20",y2:"15"}),(0,b.jsx)("line",{x1:"10",y1:"3",x2:"8",y2:"21"}),(0,b.jsx)("line",{x1:"16",y1:"3",x2:"14",y2:"21"})]})}function X(e){let{className:t}=e;return(0,b.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,b.jsx)("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),(0,b.jsx)("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}function Q(e){let{className:t}=e;return(0,b.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,b.jsx)("path",{d:"M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),(0,b.jsx)("circle",{cx:"8.5",cy:"7",r:"4"}),(0,b.jsx)("line",{x1:"20",y1:"8",x2:"20",y2:"14"}),(0,b.jsx)("line",{x1:"23",y1:"11",x2:"17",y2:"11"})]})}function ee(e){let{className:t}=e;return(0,b.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,b.jsx)("path",{d:"M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),(0,b.jsx)("circle",{cx:"8.5",cy:"7",r:"4"}),(0,b.jsx)("line",{x1:"23",y1:"11",x2:"17",y2:"11"})]})}function et(e){let{className:t}=e;return(0,b.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,b.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,b.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function en(e){let{channel:t,members:n,isOpen:r,onClose:s,onAddMember:a,onRemoveMember:l,onUpdateRole:i,currentUserId:o,isLoading:c=!1,availableUsers:d=[],availableAgents:u=[],workspaceId:x}=e,[m,h]=(0,v.useState)(!1),[g,f]=(0,v.useState)("user"),[y,j]=(0,v.useState)(""),[w,N]=(0,v.useState)("member"),[k,C]=(0,v.useState)([]),[S,M]=(0,v.useState)([]),[L,D]=(0,v.useState)(!1);(0,v.useEffect)(()=>{r&&(D(!0),p(x).then(e=>{let{members:t,agents:n}=e;C(t),M(n)}).catch(e=>{console.error("[MemberManagementPanel] Failed to fetch available members:",e)}).finally(()=>{D(!1)}))},[r,x]);let A=k.length>0?k.map(e=>({id:e.id,name:e.displayName||e.id})):d,E=S.length>0?S.map(e=>({name:e.displayName||e.id})):u;if(!r)return null;let T=n.filter(e=>"user"===e.entityType),W=n.filter(e=>"agent"===e.entityType),P=n.find(e=>e.id===o),I=(null==P?void 0:P.role)==="owner"||(null==P?void 0:P.role)==="admin",B=n.filter(e=>"owner"===e.role||"admin"===e.role).length,_=new Set(n.map(e=>e.id)),R=A.filter(e=>!_.has(e.id)),F=E.filter(e=>!n.some(t=>t.displayName===e.name&&"agent"===t.entityType)),U=e=>"owner"!==e.role&&("admin"!==e.role||!(B<=1))&&e.id!==o&&I,O=e=>"owner"!==e.role&&("admin"!==e.role||!(B<=1))&&I;return(0,b.jsx)(J,{onClose:s,children:(0,b.jsxs)("div",{className:"p-6 w-[500px] max-w-full max-h-[80vh] overflow-hidden flex flex-col",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[(0,b.jsx)("div",{className:"w-10 h-10 rounded-full bg-accent-cyan/10 flex items-center justify-center",children:(0,b.jsx)(Q,{className:"w-5 h-5 text-accent-cyan"})}),(0,b.jsxs)("div",{children:[(0,b.jsx)("h2",{className:"text-lg font-semibold text-text-primary",children:"Members"}),(0,b.jsxs)("p",{className:"text-sm text-text-muted",children:["#",t.name," \xb7 ",n.length," ",1===n.length?"member":"members"]})]})]}),I&&(0,b.jsx)("button",{onClick:()=>h(!m),className:"px-3 py-1.5 text-sm font-medium bg-accent-cyan/20 text-accent-cyan hover:bg-accent-cyan/30 rounded-lg transition-colors",children:m?"Cancel":"Add Member"})]}),m&&I&&(0,b.jsxs)("div",{className:"mb-4 p-4 bg-bg-tertiary rounded-lg border border-border-subtle",children:[(0,b.jsxs)("div",{className:"flex gap-2 mb-3",children:[(0,b.jsx)("button",{onClick:()=>f("user"),className:"px-3 py-1.5 text-sm rounded-lg transition-colors ".concat("user"===g?"bg-accent-cyan text-bg-deep":"bg-bg-hover text-text-secondary hover:text-text-primary"),children:"User"}),(0,b.jsx)("button",{onClick:()=>f("agent"),className:"px-3 py-1.5 text-sm rounded-lg transition-colors ".concat("agent"===g?"bg-accent-cyan text-bg-deep":"bg-bg-hover text-text-secondary hover:text-text-primary"),children:"Agent"})]}),(0,b.jsxs)("div",{className:"flex gap-2 mb-3",children:[(0,b.jsxs)("select",{value:y,onChange:e=>j(e.target.value),className:"flex-1 px-3 py-2 bg-bg-deep border border-border-subtle rounded-lg text-text-primary text-sm focus:outline-none focus:border-accent-cyan/50",disabled:L,children:[(0,b.jsx)("option",{value:"",children:L?"Loading...":"Select ".concat(g,"...")}),"user"===g?R.map(e=>(0,b.jsx)("option",{value:e.id,children:e.name},e.id)):F.map(e=>(0,b.jsx)("option",{value:e.name,children:e.name},e.name))]}),(0,b.jsxs)("select",{value:w,onChange:e=>N(e.target.value),className:"px-3 py-2 bg-bg-deep border border-border-subtle rounded-lg text-text-primary text-sm focus:outline-none focus:border-accent-cyan/50",children:[(0,b.jsx)("option",{value:"member",children:"Member"}),(0,b.jsx)("option",{value:"admin",children:"Admin"}),(0,b.jsx)("option",{value:"read_only",children:"Read Only"})]})]}),(0,b.jsxs)("button",{onClick:()=>{y&&(a(y,g,w),j(""),h(!1))},disabled:!y||c,className:"w-full px-3 py-2 text-sm font-medium bg-accent-cyan text-bg-deep hover:bg-accent-cyan/90 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:["Add ","user"===g?"User":"Agent"]})]}),(0,b.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-4",children:[T.length>0&&(0,b.jsxs)("div",{children:[(0,b.jsxs)("h3",{className:"text-xs font-medium text-text-muted uppercase mb-2",children:["Users (",T.length,")"]}),(0,b.jsx)("div",{className:"space-y-1",children:T.map(e=>(0,b.jsx)(er,{member:e,canChangeRole:O(e),canRemove:U(e),onChangeRole:t=>i(e.id,"user",t),onRemove:()=>l(e.id,"user"),isCurrentUser:e.id===o},e.id))})]}),W.length>0&&(0,b.jsxs)("div",{children:[(0,b.jsxs)("h3",{className:"text-xs font-medium text-text-muted uppercase mb-2",children:["Agents (",W.length,")"]}),(0,b.jsx)("div",{className:"space-y-1",children:W.map(e=>(0,b.jsx)(er,{member:e,canChangeRole:O(e),canRemove:U(e),onChangeRole:t=>i(e.id,"agent",t),onRemove:()=>l(e.id,"agent"),isAgent:!0},e.id))})]})]}),(0,b.jsx)("div",{className:"mt-4 pt-4 border-t border-border-subtle",children:(0,b.jsx)("button",{onClick:s,className:"w-full px-4 py-2 text-sm font-medium text-text-secondary bg-bg-tertiary hover:bg-bg-hover rounded-lg transition-colors",children:"Done"})})]})})}function er(e){let{member:t,canChangeRole:n,canRemove:r,onChangeRole:s,onRemove:a,isCurrentUser:l,isAgent:i}=e;return(0,b.jsxs)("div",{className:"flex items-center justify-between p-2 rounded-lg hover:bg-bg-tertiary group",children:[(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[(0,b.jsx)("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-xs font-medium ".concat(i?"bg-purple-500/20 text-purple-400":"bg-accent-cyan/20 text-accent-cyan"),children:(t.displayName||t.id)[0].toUpperCase()}),(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("span",{className:"text-sm font-medium text-text-primary",children:t.displayName||t.id}),l&&(0,b.jsx)("span",{className:"text-xs text-text-muted",children:"(you)"}),i&&(0,b.jsx)("span",{className:"text-xs px-1.5 py-0.5 bg-purple-500/20 text-purple-400 rounded",children:"Agent"})]}),(0,b.jsx)("span",{className:"text-xs capitalize ".concat("owner"===t.role?"text-yellow-400":"admin"===t.role?"text-accent-cyan":"text-text-muted"),children:t.role})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2 opacity-0 group-hover:opacity-100 transition-opacity",children:[n&&(0,b.jsxs)("select",{value:"owner"===t.role?"admin":t.role,onChange:e=>s(e.target.value),className:"px-2 py-1 text-xs bg-bg-tertiary border border-border-subtle rounded text-text-primary focus:outline-none focus:border-accent-cyan/50",children:[(0,b.jsx)("option",{value:"admin",children:"Admin"}),(0,b.jsx)("option",{value:"member",children:"Member"}),(0,b.jsx)("option",{value:"read_only",children:"Read Only"})]}),r&&(0,b.jsx)("button",{onClick:a,className:"p-1.5 text-red-400 hover:bg-red-500/20 rounded transition-colors",title:"Remove member",children:(0,b.jsx)(ee,{className:"w-4 h-4"})})]})]})}},1832:function(e,t,n){n.d(t,{y:function(){return k}});var r=n(7573),s=n(7653),a=n(47),l=n(5756),i=n(9363),o=n(9355),c=n(9425),d=n(3534),u=n(9714),x=n(890),m=n(2810),h=n(4583),p=n(6732),g=n(6047),f=n(4585),b=n(8864),v=n(9242),y=n(126);a.Z.registerLanguage("javascript",i.Z),a.Z.registerLanguage("typescript",o.Z),a.Z.registerLanguage("python",c.Z),a.Z.registerLanguage("bash",d.Z),a.Z.registerLanguage("shell",d.Z),a.Z.registerLanguage("json",u.Z),a.Z.registerLanguage("markdown",x.Z),a.Z.registerLanguage("yaml",m.Z),a.Z.registerLanguage("css",h.Z),a.Z.registerLanguage("go",p.Z),a.Z.registerLanguage("rust",g.Z),a.Z.registerLanguage("sql",f.Z),a.Z.registerLanguage("ruby",b.Z),a.Z.registerLanguage("java",v.Z),a.Z.registerLanguage("docker",y.Z),a.Z.registerLanguage("dockerfile",y.Z);let j={...l.Z,'pre[class*="language-"]':{...l.Z['pre[class*="language-"]'],background:"rgba(15, 23, 42, 0.8)",margin:"0.5rem 0",padding:"1rem",borderRadius:"0.5rem",border:"1px solid rgba(148, 163, 184, 0.1)",fontSize:"0.75rem",lineHeight:"1.5"},'code[class*="language-"]':{...l.Z['code[class*="language-"]'],background:"transparent",fontSize:"0.75rem"}};function w(e){let{code:t,language:n}=e,[l,i]=(0,s.useState)(!1),o=(0,s.useCallback)(async()=>{try{await navigator.clipboard.writeText(t),i(!0),setTimeout(()=>i(!1),2e3)}catch(e){console.error("Failed to copy:",e)}},[t]),c=n.toLowerCase().replace(/^(js|jsx)$/,"javascript").replace(/^(ts|tsx)$/,"typescript").replace(/^(py)$/,"python").replace(/^(rb)$/,"ruby").replace(/^(sh|shell|zsh)$/,"bash");return(0,r.jsxs)("div",{className:"relative group my-2",children:[(0,r.jsxs)("div",{className:"absolute top-2 right-2 flex items-center gap-2 z-10",children:[n&&"text"!==n&&(0,r.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-accent-cyan/20 text-accent-cyan font-mono",children:n}),(0,r.jsx)("button",{onClick:o,className:"opacity-0 group-hover:opacity-100 transition-opacity text-xs px-2 py-1 rounded bg-bg-tertiary hover:bg-bg-card text-text-muted hover:text-text-primary border border-border-subtle",title:"Copy code",children:l?"✓ Copied":"Copy"})]}),(0,r.jsx)(a.Z,{language:c,style:j,customStyle:{margin:0,background:"rgba(15, 23, 42, 0.8)"},showLineNumbers:t.split("\n").length>3,lineNumberStyle:{minWidth:"2.5em",paddingRight:"1em",color:"rgba(148, 163, 184, 0.4)",userSelect:"none"},children:t.trim()})]})}function N(e){let t=e.split("\n"),n=[],r=null;for(let e of t){let t;let s=e;e.trimStart().startsWith(">")?(t="quote",s=function(e){let t=e.trimStart();return t.startsWith("> ")?t.slice(2):t.startsWith(">")?t.slice(1):e}(e)):t=(e.match(/\|/g)||[]).length>=2||e.trim().startsWith("|")&&e.trim().endsWith("|")||/^[\s|:-]+$/.test(e)&&e.includes("-")&&e.includes("|")?"table":"text",r&&r.type===t?r.content+="\n"+s:(r&&n.push(r),r={type:t,content:s})}return r&&n.push(r),n}function k(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.replace(/\\n/g,"\n").replace(/\r\n/g,"\n").replace(/\r/g,"\n"),a=function(e){let t;let n=[],r=/```(\w*)\n([\s\S]*?)```/g,s=0;for(;null!==(t=r.exec(e));){if(t.index>s){let r=N(e.slice(s,t.index));n.push(...r)}n.push({type:"code",language:t[1]||"text",content:t[2]}),s=t.index+t[0].length}if(s<e.length){let t=N(e.slice(s));n.push(...t)}return 0===n.length?N(e):n}(n);return 1===a.length&&"text"===a[0].type?n.split("\n").map((e,n)=>(0,r.jsxs)(s.Fragment,{children:[n>0&&(0,r.jsx)("br",{}),S(e,t.mentions)]},n)):a.map((e,n)=>{if("code"===e.type)return(0,r.jsx)(w,{code:e.content,language:e.language||"text"},n);if("table"===e.type)return(0,r.jsx)("pre",{className:"font-mono text-xs leading-relaxed whitespace-pre overflow-x-auto my-2 p-3 bg-bg-tertiary/50 rounded-lg border border-border-subtle",children:e.content},n);if("quote"===e.type){let a=e.content.split("\n");return(0,r.jsx)("blockquote",{className:"my-2 pl-3 py-1 border-l-2 border-accent-cyan/50 bg-bg-tertiary/30 rounded-r text-text-secondary italic",children:a.map((e,n)=>(0,r.jsxs)(s.Fragment,{children:[n>0&&(0,r.jsx)("br",{}),S(e,t.mentions)]},n))},n)}let a=e.content.split("\n");return(0,r.jsx)("span",{children:a.map((e,n)=>(0,r.jsxs)(s.Fragment,{children:[n>0&&(0,r.jsx)("br",{}),S(e,t.mentions)]},n))},n)})}function C(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",s=[],a=e,l=0,i=[{regex:/`([^`]+)`/,render:(e,t)=>(0,r.jsx)("code",{className:"px-1.5 py-0.5 mx-0.5 rounded bg-bg-elevated/80 text-accent-cyan font-mono text-[0.85em] border border-border-subtle/50",children:e[1]},t)},{regex:/\[([^\]]+)\]\(([^)]+)\)/,render:(e,t)=>(0,r.jsx)("a",{href:e[2],target:"_blank",rel:"noopener noreferrer",className:"text-accent-cyan no-underline hover:underline",children:e[1]},t)},{regex:/\*\*([^*]+)\*\*/,render:(e,n)=>(0,r.jsx)("strong",{className:"font-semibold text-text-primary",children:C(e[1],t,"".concat(n,"-inner"))},n)},{regex:/__([^_]+)__/,render:(e,n)=>(0,r.jsx)("strong",{className:"font-semibold text-text-primary",children:C(e[1],t,"".concat(n,"-inner"))},n)},{regex:/_([^_]+)_/,render:(e,n)=>(0,r.jsx)("em",{className:"italic",children:C(e[1],t,"".concat(n,"-inner"))},n)},{regex:/\*([^*]+)\*/,render:(e,n)=>(0,r.jsx)("em",{className:"italic",children:C(e[1],t,"".concat(n,"-inner"))},n)},{regex:/~~([^~]+)~~/,render:(e,t)=>(0,r.jsx)("del",{className:"line-through text-text-muted",children:e[1]},t)},{regex:/https?:\/\/[^\s]+/,render:(e,t)=>(0,r.jsx)("a",{href:e[0],target:"_blank",rel:"noopener noreferrer",className:"text-accent-cyan no-underline hover:underline",children:e[0]},t)}];for(;a.length>0;){let e=null;for(let t of i){let n=a.match(t.regex);n&&void 0!==n.index&&(!e||n.index<e.index)&&(e={pattern:t,match:n,index:n.index})}if(!e){s.push(L(a,t,"".concat(n,"-text-").concat(l)));break}if(e.index>0){let r=a.slice(0,e.index);s.push(L(r,t,"".concat(n,"-pre-").concat(l))),l++}s.push(e.pattern.render(e.match,"".concat(n,"-el-").concat(l))),l++,a=a.slice(e.index+e.match[0].length)}return 1===s.length?s[0]:s}function S(e,t){let n=function(e){let t=e.match(/^(#{1,6})\s+/);return t?t[1].length:0}(e);if(n>0){let s=e.replace(/^#{1,6}\s+/,""),a={1:{className:"font-bold text-text-primary mt-4 mb-2 pb-1 border-b border-border-subtle",style:{fontSize:"1.5rem",lineHeight:"2rem"}},2:{className:"font-bold text-text-primary mt-3 mb-2",style:{fontSize:"1.25rem",lineHeight:"1.75rem"}},3:{className:"font-semibold text-text-primary mt-2.5 mb-1.5",style:{fontSize:"1.125rem",lineHeight:"1.5rem"}},4:{className:"font-semibold text-text-primary mt-2 mb-1",style:{fontSize:"1rem",lineHeight:"1.5rem"}},5:{className:"font-medium text-text-secondary mt-1.5 mb-1",style:{fontSize:"0.875rem",lineHeight:"1.25rem"}},6:{className:"font-medium text-text-muted mt-1 mb-0.5 uppercase tracking-wide",style:{fontSize:"0.75rem",lineHeight:"1rem"}}},{className:l,style:i}=a[n]||a[3];return(0,r.jsx)("div",{className:l,style:i,children:C(s,t,"heading")})}let s=function(e){let t=e.match(/^(\s*)([-*])\s+(.*)$/);if(t)return{type:"bullet",content:t[3],indent:t[1].length};let n=e.match(/^(\s*)(\d+\.)\s+(.*)$/);return n?{type:"numbered",content:n[3],indent:n[1].length}:{type:null,content:e,indent:0}}(e);if(s.type){var a;let n={marginLeft:"".concat(.5*s.indent+.5,"rem")};return(0,r.jsxs)("div",{className:"flex items-start gap-2 my-0.5",style:n,children:[(0,r.jsx)("span",{className:"text-accent-cyan flex-shrink-0 w-4 text-center",children:"bullet"===s.type?"•":null===(a=e.match(/^\s*(\d+\.)/))||void 0===a?void 0:a[1]}),(0,r.jsx)("span",{children:C(s.content,t,"list")})]})}return C(e,t,"line")}function M(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function L(e,t,n){let s;if(!t||0===t.length)return e;let a=t.map(M).filter(Boolean);if(0===a.length)return e;let l=RegExp("@(".concat(a.join("|"),")\\b"),"g"),i=[],o=0;for(;null!==(s=l.exec(e));)s.index>o&&i.push(e.slice(o,s.index)),i.push((0,r.jsxs)("span",{className:"px-1 py-0.5 bg-accent-cyan/20 text-accent-cyan rounded",children:["@",s[1]]},"".concat(n,"-mention-").concat(s.index))),o=s.index+s[0].length;return o<e.length&&i.push(e.slice(o)),i.length>0?i:e}},7880:function(e,t,n){n.d(t,{Ll:function(){return a},RY:function(){return s}});let r=/^dashboard(-[0-9a-f]{6,}|-reader)?$/i;function s(e){if(!(null==e?void 0:e.trim()))return!1;let t=e.trim().toLowerCase();return"dashboard"===t||"human:dashboard"===t||r.test(e.trim())}function a(e,t){return(null==e?void 0:e.trim())?s(e.trim())?function(e){if(null==e?void 0:e.trim())return e.trim();let t=window.localStorage;if(t)try{let e=t.getItem("relay_username");if(null==e?void 0:e.trim())return e.trim()}catch(e){}return"Dashboard"}(t):e.trim():e}},3862:function(e,t,n){n.d(t,{IG:function(){return i},t2:function(){return l},ug:function(){return o}});var r=n(9325),s=n(7880);function a(e){let t=e.trim();return t?(0,s.Ll)(t):""}function l(e,t,n){return(0,r.Jh)(e,t,{currentUserName:n})}function i(e){return(0,r.Xi)(e)}function o(e,t){if(0===e.length)return e;let n=new Map;for(let e of t){var r;n.set(e.id,null!==(r=e.participants)&&void 0!==r?r:[])}let s=!1,l=e.map(e=>{var t;let r=null===(t=e.to)||void 0===t?void 0:t.trim();if(!r)return e;let l=a(r);if(r.startsWith("dm_")){let t=n.get(r);if(t){let n=function(e,t){let n=a(t).toLowerCase();for(let t of e){if("string"!=typeof t)continue;let e=a(t);if(e&&e.toLowerCase()!==n)return e}for(let t of e){if("string"!=typeof t)continue;let e=a(t);if(e)return e}return null}(t,e.from);n&&n!==r&&(l=n)}}return l&&l!==r?(s=!0,{...e,to:l}):e});return s?l:e}},8906:function(e,t,n){n.d(t,{ED:function(){return i},hL:function(){return s}});let r="✳✢✶✻✺✹✸✷⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏⣾⣽⣻⢿⡿⣟⣯⣷◐◓◑◒●○◉◎◉\xb7⎿⎽⎾⎷⏺⏵⏢✢✣";function s(e){if(!e)return"";let t=e;t=(t=(t=(t=(t=(t=(t=(t=t.replace(RegExp("\\x1b\\].*?(?:\\x07|\\x1b\\\\)","gs"),"")).replace(RegExp("\\x1bP.*?\\x1b\\\\","gs"),"")).replace(/\x1b\[[0-9;?]*[ -/]*[@-~]/g,"")).replace(/\x1b[@-Z\\-_]/g,"")).replace(/^\[\??\d+[hlKJHfABCDGPXsu]/gm,"")).replace(/\[\d+(?:;\d+)*m/g,"")).replace(/\r\n/g,"\n")).split("\n").map(e=>{if(!e.includes("\r"))return e;let t=e.split("\r");return t[t.length-1]}).join("\n");let n="";for(;n!==t;)n=t,t=t.replace(/[^\x08]\x08/g,"");return(t=(t=t.replace(/\x08+/g,"")).replace(/\x1b/g,"")).replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"")}RegExp("[".concat(r,"]"),"g"),new RegExp("[".concat(r,"]"));let a=/^[⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏⣾⣽⣻⢿⡿⣟⣯⣷◐◓◑◒●○◉◎✳✢✶✻✺✹✸✷⏢|\\\/\-*.\u2800-\u28FF]+$/,l=/^[✳✢✶✻✺✹✸✷⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏●○*]?\s*(?:Nebulizing|Simmering|Percolating|Brewing|Distilling|Crystallizing|Synthesizing|Composing|Weaving|Forging|Manifesting|Conjuring|Materializing|Transmuting|Catalyzing|Combobulating|Orbiting|Bypassing|Bypass|Thinking|Thinking…|Running|Working)\s*…?\s*$/i;function i(e){return!!(e.length<=2&&a.test(e)||l.test(e))}}}]);