agor-live 0.23.1 → 0.23.2

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 (469) hide show
  1. package/dist/core/claude/index.cjs +51 -27
  2. package/dist/core/claude/index.js +51 -27
  3. package/dist/core/claude-cli/index.cjs +13 -0
  4. package/dist/core/claude-cli/index.js +13 -0
  5. package/dist/core/claude-cli/pricing.d.ts.map +1 -1
  6. package/dist/core/client/index.cjs +17 -0
  7. package/dist/core/client/index.js +16 -0
  8. package/dist/core/db/index.cjs +618 -421
  9. package/dist/core/db/index.js +550 -353
  10. package/dist/core/db/repositories/boards.d.ts +27 -0
  11. package/dist/core/db/repositories/boards.d.ts.map +1 -1
  12. package/dist/core/db/repositories/branches.d.ts +11 -1
  13. package/dist/core/db/repositories/branches.d.ts.map +1 -1
  14. package/dist/core/db/repositories/gateway-channels.d.ts +9 -0
  15. package/dist/core/db/repositories/gateway-channels.d.ts.map +1 -1
  16. package/dist/core/db/repositories/sessions.d.ts +7 -0
  17. package/dist/core/db/repositories/sessions.d.ts.map +1 -1
  18. package/dist/core/environment/render-snapshot.cjs +6 -2
  19. package/dist/core/environment/render-snapshot.d.ts +2 -0
  20. package/dist/core/environment/render-snapshot.d.ts.map +1 -1
  21. package/dist/core/environment/render-snapshot.js +6 -2
  22. package/dist/core/environment/variable-resolver.cjs +3 -1
  23. package/dist/core/environment/variable-resolver.js +3 -1
  24. package/dist/core/index.cjs +684 -486
  25. package/dist/core/index.js +684 -486
  26. package/dist/core/lib/feathers-validation.cjs +3 -0
  27. package/dist/core/lib/feathers-validation.d.ts +1 -0
  28. package/dist/core/lib/feathers-validation.d.ts.map +1 -1
  29. package/dist/core/lib/feathers-validation.js +3 -0
  30. package/dist/core/local-actions/index.cjs +123 -56
  31. package/dist/core/local-actions/index.js +121 -54
  32. package/dist/core/mcp/index.cjs +21 -3
  33. package/dist/core/mcp/index.d.ts +1 -1
  34. package/dist/core/mcp/index.d.ts.map +1 -1
  35. package/dist/core/mcp/index.js +18 -3
  36. package/dist/core/mcp/template-patterns.d.ts +15 -0
  37. package/dist/core/mcp/template-patterns.d.ts.map +1 -0
  38. package/dist/core/mcp/template-resolver.d.ts +13 -0
  39. package/dist/core/mcp/template-resolver.d.ts.map +1 -1
  40. package/dist/core/models/browser.cjs +6 -0
  41. package/dist/core/models/browser.js +6 -0
  42. package/dist/core/models/claude.d.ts.map +1 -1
  43. package/dist/core/models/index.cjs +6 -0
  44. package/dist/core/models/index.js +6 -0
  45. package/dist/core/seed/index.cjs +360 -216
  46. package/dist/core/seed/index.js +329 -185
  47. package/dist/core/templates/handlebars-helpers.cjs +3 -1
  48. package/dist/core/templates/handlebars-helpers.d.ts +5 -0
  49. package/dist/core/templates/handlebars-helpers.d.ts.map +1 -1
  50. package/dist/core/templates/handlebars-helpers.js +3 -1
  51. package/dist/core/tools/mcp/auth-secrets.cjs +3460 -3
  52. package/dist/core/tools/mcp/auth-secrets.d.ts.map +1 -1
  53. package/dist/core/tools/mcp/auth-secrets.js +3477 -3
  54. package/dist/core/tools/mcp/http-headers.cjs +17 -1
  55. package/dist/core/tools/mcp/http-headers.d.ts.map +1 -1
  56. package/dist/core/tools/mcp/http-headers.js +15 -1
  57. package/dist/core/tools/mcp/oauth-refresh.cjs +67 -43
  58. package/dist/core/tools/mcp/oauth-refresh.js +65 -41
  59. package/dist/core/types/board.d.ts +12 -0
  60. package/dist/core/types/board.d.ts.map +1 -1
  61. package/dist/core/types/gateway.d.ts +14 -0
  62. package/dist/core/types/gateway.d.ts.map +1 -1
  63. package/dist/core/types/index.cjs +17 -0
  64. package/dist/core/types/index.js +16 -0
  65. package/dist/core/unix/index.cjs +67 -0
  66. package/dist/core/unix/index.js +67 -0
  67. package/dist/daemon/auth/executor-runtime-scope.d.ts.map +1 -1
  68. package/dist/daemon/auth/executor-runtime-scope.js +19 -5
  69. package/dist/daemon/auth/executor-session-token.d.ts +15 -0
  70. package/dist/daemon/auth/executor-session-token.d.ts.map +1 -0
  71. package/dist/daemon/auth/executor-session-token.js +17 -0
  72. package/dist/daemon/auth/issue-browser-tokens-hook.d.ts +24 -0
  73. package/dist/daemon/auth/issue-browser-tokens-hook.d.ts.map +1 -0
  74. package/dist/daemon/auth/issue-browser-tokens-hook.js +95 -0
  75. package/dist/daemon/auth/service-jwt-strategy.d.ts.map +1 -1
  76. package/dist/daemon/auth/service-jwt-strategy.js +14 -2
  77. package/dist/daemon/declarations.d.ts +1 -0
  78. package/dist/daemon/declarations.d.ts.map +1 -1
  79. package/dist/daemon/index.js +1365 -418
  80. package/dist/daemon/main.js +1365 -418
  81. package/dist/daemon/mcp/server.js +294 -31
  82. package/dist/daemon/mcp/tools/analytics.js +73 -24
  83. package/dist/daemon/mcp/tools/artifacts.js +73 -24
  84. package/dist/daemon/mcp/tools/boards.js +73 -24
  85. package/dist/daemon/mcp/tools/branches.js +73 -24
  86. package/dist/daemon/mcp/tools/card-types.js +73 -24
  87. package/dist/daemon/mcp/tools/cards.js +73 -24
  88. package/dist/daemon/mcp/tools/environment.js +73 -24
  89. package/dist/daemon/mcp/tools/gateway-channels.d.ts.map +1 -1
  90. package/dist/daemon/mcp/tools/gateway-channels.js +190 -38
  91. package/dist/daemon/mcp/tools/knowledge.js +73 -24
  92. package/dist/daemon/mcp/tools/mcp-servers.js +73 -24
  93. package/dist/daemon/mcp/tools/messages.js +73 -24
  94. package/dist/daemon/mcp/tools/proxies.js +73 -24
  95. package/dist/daemon/mcp/tools/repos.js +73 -24
  96. package/dist/daemon/mcp/tools/schedules.js +73 -24
  97. package/dist/daemon/mcp/tools/search.js +73 -24
  98. package/dist/daemon/mcp/tools/sessions.js +73 -24
  99. package/dist/daemon/mcp/tools/tasks.js +73 -24
  100. package/dist/daemon/mcp/tools/users.js +76 -27
  101. package/dist/daemon/mcp/tools/widgets.d.ts.map +1 -1
  102. package/dist/daemon/mcp/tools/widgets.js +257 -99
  103. package/dist/daemon/oauth-auth-helpers.d.ts +35 -0
  104. package/dist/daemon/oauth-auth-helpers.d.ts.map +1 -0
  105. package/dist/daemon/oauth-auth-helpers.js +14 -0
  106. package/dist/daemon/register-hooks.d.ts +1 -0
  107. package/dist/daemon/register-hooks.d.ts.map +1 -1
  108. package/dist/daemon/register-hooks.js +304 -53
  109. package/dist/daemon/register-routes.d.ts.map +1 -1
  110. package/dist/daemon/register-routes.js +738 -288
  111. package/dist/daemon/register-services.d.ts.map +1 -1
  112. package/dist/daemon/register-services.js +386 -155
  113. package/dist/daemon/services/boards.d.ts +5 -0
  114. package/dist/daemon/services/boards.d.ts.map +1 -1
  115. package/dist/daemon/services/boards.js +7 -0
  116. package/dist/daemon/services/branches.d.ts.map +1 -1
  117. package/dist/daemon/services/branches.js +31 -2
  118. package/dist/daemon/services/claude-models.d.ts.map +1 -1
  119. package/dist/daemon/services/claude-models.js +4 -1
  120. package/dist/daemon/services/gateway.d.ts +15 -0
  121. package/dist/daemon/services/gateway.d.ts.map +1 -1
  122. package/dist/daemon/services/gateway.js +34 -0
  123. package/dist/daemon/services/health-monitor.d.ts.map +1 -1
  124. package/dist/daemon/services/health-monitor.js +10 -7
  125. package/dist/daemon/services/session-streams.d.ts +29 -0
  126. package/dist/daemon/services/session-streams.d.ts.map +1 -0
  127. package/dist/daemon/services/session-streams.js +84 -0
  128. package/dist/daemon/services/session-token-service.d.ts.map +1 -1
  129. package/dist/daemon/services/session-token-service.js +8 -4
  130. package/dist/daemon/setup/index.js +43 -11
  131. package/dist/daemon/setup/socketio.d.ts.map +1 -1
  132. package/dist/daemon/setup/socketio.js +43 -11
  133. package/dist/daemon/startup.d.ts.map +1 -1
  134. package/dist/daemon/startup.js +37 -16
  135. package/dist/daemon/utils/authorization.js +19 -5
  136. package/dist/daemon/utils/emit-service-event.d.ts +56 -0
  137. package/dist/daemon/utils/emit-service-event.d.ts.map +1 -0
  138. package/dist/daemon/utils/emit-service-event.js +23 -0
  139. package/dist/daemon/utils/mcp-header-secrets.d.ts +3 -5
  140. package/dist/daemon/utils/mcp-header-secrets.d.ts.map +1 -1
  141. package/dist/daemon/utils/mcp-header-secrets.js +31 -2
  142. package/dist/daemon/utils/realtime-access-cache.d.ts +9 -0
  143. package/dist/daemon/utils/realtime-access-cache.d.ts.map +1 -1
  144. package/dist/daemon/utils/realtime-access-cache.js +24 -0
  145. package/dist/daemon/utils/realtime-publish.d.ts +24 -0
  146. package/dist/daemon/utils/realtime-publish.d.ts.map +1 -1
  147. package/dist/daemon/utils/realtime-publish.js +120 -2
  148. package/dist/daemon/utils/session-queue-tenant-scope.d.ts +24 -0
  149. package/dist/daemon/utils/session-queue-tenant-scope.d.ts.map +1 -0
  150. package/dist/daemon/utils/session-queue-tenant-scope.js +133 -0
  151. package/dist/daemon/widgets/gateway-token/index.d.ts +114 -0
  152. package/dist/daemon/widgets/gateway-token/index.d.ts.map +1 -0
  153. package/dist/daemon/widgets/gateway-token/index.js +14711 -0
  154. package/dist/daemon/widgets/index.d.ts.map +1 -1
  155. package/dist/daemon/widgets/index.js +190 -16
  156. package/dist/daemon/widgets/registry.d.ts +7 -0
  157. package/dist/daemon/widgets/registry.d.ts.map +1 -1
  158. package/dist/daemon/widgets/submissions.js +12 -9
  159. package/dist/executor/commands/git.d.ts.map +1 -1
  160. package/dist/executor/commands/git.js +2 -0
  161. package/dist/executor/db/feathers-repositories.d.ts +19 -1
  162. package/dist/executor/db/feathers-repositories.d.ts.map +1 -1
  163. package/dist/executor/db/feathers-repositories.js +31 -1
  164. package/dist/executor/handlers/sdk/claude.d.ts.map +1 -1
  165. package/dist/executor/handlers/sdk/claude.js +1 -1
  166. package/dist/executor/handlers/sdk/codex.d.ts.map +1 -1
  167. package/dist/executor/handlers/sdk/codex.js +1 -1
  168. package/dist/executor/handlers/sdk/copilot.d.ts.map +1 -1
  169. package/dist/executor/handlers/sdk/copilot.js +1 -1
  170. package/dist/executor/handlers/sdk/cursor.d.ts.map +1 -1
  171. package/dist/executor/handlers/sdk/cursor.js +1 -0
  172. package/dist/executor/handlers/sdk/gemini.d.ts.map +1 -1
  173. package/dist/executor/handlers/sdk/gemini.js +1 -1
  174. package/dist/executor/handlers/sdk/opencode.d.ts.map +1 -1
  175. package/dist/executor/handlers/sdk/opencode.js +1 -1
  176. package/dist/executor/payload-types.d.ts +5 -5
  177. package/dist/executor/sdk-handlers/base/mcp-scoping.d.ts +8 -1
  178. package/dist/executor/sdk-handlers/base/mcp-scoping.d.ts.map +1 -1
  179. package/dist/executor/sdk-handlers/base/mcp-scoping.js +58 -6
  180. package/dist/executor/sdk-handlers/claude/claude-tool.d.ts +2 -2
  181. package/dist/executor/sdk-handlers/claude/claude-tool.d.ts.map +1 -1
  182. package/dist/executor/sdk-handlers/claude/claude-tool.js +2 -2
  183. package/dist/executor/sdk-handlers/claude/prompt-service.d.ts +13 -3
  184. package/dist/executor/sdk-handlers/claude/prompt-service.d.ts.map +1 -1
  185. package/dist/executor/sdk-handlers/claude/prompt-service.js +16 -3
  186. package/dist/executor/sdk-handlers/claude/query-builder.d.ts +2 -1
  187. package/dist/executor/sdk-handlers/claude/query-builder.d.ts.map +1 -1
  188. package/dist/executor/sdk-handlers/claude/query-builder.js +2 -1
  189. package/dist/executor/sdk-handlers/codex/codex-tool.d.ts +2 -2
  190. package/dist/executor/sdk-handlers/codex/codex-tool.d.ts.map +1 -1
  191. package/dist/executor/sdk-handlers/codex/codex-tool.js +2 -2
  192. package/dist/executor/sdk-handlers/codex/prompt-service.d.ts +3 -2
  193. package/dist/executor/sdk-handlers/codex/prompt-service.d.ts.map +1 -1
  194. package/dist/executor/sdk-handlers/codex/prompt-service.js +70 -6
  195. package/dist/executor/sdk-handlers/copilot/copilot-tool.d.ts +2 -2
  196. package/dist/executor/sdk-handlers/copilot/copilot-tool.d.ts.map +1 -1
  197. package/dist/executor/sdk-handlers/copilot/copilot-tool.js +2 -2
  198. package/dist/executor/sdk-handlers/copilot/prompt-service.d.ts +3 -2
  199. package/dist/executor/sdk-handlers/copilot/prompt-service.d.ts.map +1 -1
  200. package/dist/executor/sdk-handlers/copilot/prompt-service.js +4 -1
  201. package/dist/executor/sdk-handlers/gemini/gemini-tool.d.ts +2 -2
  202. package/dist/executor/sdk-handlers/gemini/gemini-tool.d.ts.map +1 -1
  203. package/dist/executor/sdk-handlers/gemini/gemini-tool.js +2 -2
  204. package/dist/executor/sdk-handlers/gemini/prompt-service.d.ts +3 -2
  205. package/dist/executor/sdk-handlers/gemini/prompt-service.d.ts.map +1 -1
  206. package/dist/executor/sdk-handlers/gemini/prompt-service.js +4 -1
  207. package/dist/executor/sdk-handlers/opencode/opencode-tool.d.ts +3 -2
  208. package/dist/executor/sdk-handlers/opencode/opencode-tool.d.ts.map +1 -1
  209. package/dist/executor/sdk-handlers/opencode/opencode-tool.js +4 -1
  210. package/dist/executor/services/feathers-client.d.ts.map +1 -1
  211. package/dist/executor/services/feathers-client.js +119 -20
  212. package/dist/ui/assets/AgorEmojiPickerInner-leeNywMc.js +1 -0
  213. package/dist/ui/assets/App-Dpl4Cc0U.js +4 -0
  214. package/dist/ui/assets/App-Dpl4Cc0U.js.gz +0 -0
  215. package/dist/ui/assets/AppNode-wN3UZlFK.js +1 -0
  216. package/dist/ui/assets/AppNode-wN3UZlFK.js.gz +0 -0
  217. package/dist/ui/assets/{ArtifactConsentModal-oMMzRn8L.js → ArtifactConsentModal-DjzXcP_L.js} +1 -1
  218. package/dist/ui/assets/ArtifactConsentModal-DjzXcP_L.js.gz +0 -0
  219. package/dist/ui/assets/ArtifactFullscreenPage-B3b_EZ0F.js +9 -0
  220. package/dist/ui/assets/ArtifactFullscreenPage-B3b_EZ0F.js.gz +0 -0
  221. package/dist/ui/assets/ArtifactNode-DISy2T-6.js +9 -0
  222. package/dist/ui/assets/ArtifactNode-DISy2T-6.js.gz +0 -0
  223. package/dist/ui/assets/AutocompleteTextarea-DUpsoEGr.js +19 -0
  224. package/dist/ui/assets/AutocompleteTextarea-DUpsoEGr.js.gz +0 -0
  225. package/dist/ui/assets/BoardObjectNodes-BakeGpIX.js +34 -0
  226. package/dist/ui/assets/BoardObjectNodes-BakeGpIX.js.gz +0 -0
  227. package/dist/ui/assets/{CodeEditor.inner-Cuj6RuLL.js → CodeEditor.inner-HmSdTLW5.js} +1 -1
  228. package/dist/ui/assets/CodeEditor.inner-HmSdTLW5.js.gz +0 -0
  229. package/dist/ui/assets/ConversationView-mWaA-B1f.js +1 -0
  230. package/dist/ui/assets/ConversationView-mWaA-B1f.js.gz +0 -0
  231. package/dist/ui/assets/{EmbeddedTerminal-Lx5I9EOJ.js → EmbeddedTerminal-NNoyPA81.js} +1 -1
  232. package/dist/ui/assets/EmbeddedTerminal-NNoyPA81.js.gz +0 -0
  233. package/dist/ui/assets/KnowledgePage-CkxVnRvz.js +24 -0
  234. package/dist/ui/assets/KnowledgePage-CkxVnRvz.js.gz +0 -0
  235. package/dist/ui/assets/{MarketingScreenshotPage-CmDPBHOl.js → MarketingScreenshotPage-B86Gs8jx.js} +2 -2
  236. package/dist/ui/assets/MarketingScreenshotPage-B86Gs8jx.js.gz +0 -0
  237. package/dist/ui/assets/MobileApp-BPs-SXvz.js +1 -0
  238. package/dist/ui/assets/MobileApp-BPs-SXvz.js.gz +0 -0
  239. package/dist/ui/assets/SessionCanvas-xVfDoEtz.js +13 -0
  240. package/dist/ui/assets/SessionCanvas-xVfDoEtz.js.gz +0 -0
  241. package/dist/ui/assets/{StreamdownDemoPage-okKKR2QH.js → StreamdownDemoPage-CvWLzVsv.js} +2 -2
  242. package/dist/ui/assets/StreamdownDemoPage-CvWLzVsv.js.gz +0 -0
  243. package/dist/ui/assets/{TerminalModal-D9jMGZXv.js → TerminalModal-ExOgsuOP.js} +2 -2
  244. package/dist/ui/assets/TerminalModal-ExOgsuOP.js.gz +0 -0
  245. package/dist/ui/assets/ThemeSwitcher-Cgyp5ruu.js +1 -0
  246. package/dist/ui/assets/ThemeSwitcher-Cgyp5ruu.js.gz +0 -0
  247. package/dist/ui/assets/{ThemedSyntaxHighlighter.inner-C1FdIHn0.js → ThemedSyntaxHighlighter.inner-rpCN9S6K.js} +1 -1
  248. package/dist/ui/assets/{antd-DT5ackd0.js → antd-BCqimh1J.js} +5 -5
  249. package/dist/ui/assets/{antd-DT5ackd0.js.gz → antd-BCqimh1J.js.gz} +0 -0
  250. package/dist/ui/assets/architecture-U656AL7Q-BxSQIjrE.js +1 -0
  251. package/dist/ui/assets/{architectureDiagram-VXUJARFQ-DwTJGGoj.js → architectureDiagram-VXUJARFQ-pDpGHSqT.js} +1 -1
  252. package/dist/ui/assets/architectureDiagram-VXUJARFQ-pDpGHSqT.js.gz +0 -0
  253. package/dist/ui/assets/{blockDiagram-VD42YOAC-Dh1_TVW2.js → blockDiagram-VD42YOAC-uP8JTJpK.js} +1 -1
  254. package/dist/ui/assets/blockDiagram-VD42YOAC-uP8JTJpK.js.gz +0 -0
  255. package/dist/ui/assets/{c4Diagram-YG6GDRKO-B1e96AcB.js → c4Diagram-YG6GDRKO-qQe72Mm7.js} +1 -1
  256. package/dist/ui/assets/c4Diagram-YG6GDRKO-qQe72Mm7.js.gz +0 -0
  257. package/dist/ui/assets/channel-CoUBs6Zn.js +1 -0
  258. package/dist/ui/assets/{chunk-4BX2VUAB-BODpCjJx.js → chunk-4BX2VUAB-sz-YE8Nt.js} +1 -1
  259. package/dist/ui/assets/chunk-4ZMWKKQ3-3oKtfWXp.js +3 -0
  260. package/dist/ui/assets/chunk-4ZMWKKQ3-3oKtfWXp.js.gz +0 -0
  261. package/dist/ui/assets/chunk-55IACEB6-BS04dgKF.js +1 -0
  262. package/dist/ui/assets/{chunk-ABZYJK2D-DCTXWSzV.js → chunk-ABZYJK2D-t3Gkphds.js} +3 -3
  263. package/dist/ui/assets/chunk-ABZYJK2D-t3Gkphds.js.gz +0 -0
  264. package/dist/ui/assets/{chunk-AGHRB4JF-CbNphBjE.js → chunk-AGHRB4JF-D_QmWxbY.js} +1 -1
  265. package/dist/ui/assets/chunk-AGHRB4JF-D_QmWxbY.js.gz +0 -0
  266. package/dist/ui/assets/{chunk-ATLVNIR6-rWg3qxof.js → chunk-ATLVNIR6-Bmg7-Ufz.js} +1 -1
  267. package/dist/ui/assets/chunk-ATLVNIR6-Bmg7-Ufz.js.gz +0 -0
  268. package/dist/ui/assets/{chunk-B4BG7PRW-CgtLCbpE.js → chunk-B4BG7PRW-dnSEE1u-.js} +1 -1
  269. package/dist/ui/assets/chunk-B4BG7PRW-dnSEE1u-.js.gz +0 -0
  270. package/dist/ui/assets/{chunk-CVBHYZKI-DTL6Zgr0.js → chunk-CVBHYZKI-BStaYnF0.js} +1 -1
  271. package/dist/ui/assets/{chunk-DI55MBZ5-Dwvx2Kva.js → chunk-DI55MBZ5-28dvx6o3.js} +1 -1
  272. package/dist/ui/assets/chunk-DI55MBZ5-28dvx6o3.js.gz +0 -0
  273. package/dist/ui/assets/chunk-EXTU4WIE-X-FURkEh.js +1 -0
  274. package/dist/ui/assets/{chunk-FMBD7UC4-BogA_9CV.js → chunk-FMBD7UC4-C_63gC9S.js} +1 -1
  275. package/dist/ui/assets/{chunk-HN2XXSSU-2blQO3Gb.js → chunk-HN2XXSSU-UFD374KI.js} +1 -1
  276. package/dist/ui/assets/chunk-HN2XXSSU-UFD374KI.js.gz +0 -0
  277. package/dist/ui/assets/{chunk-JA3XYJ7Z-Cr1rmOui.js → chunk-JA3XYJ7Z-B60hLNeR.js} +1 -1
  278. package/dist/ui/assets/chunk-JA3XYJ7Z-B60hLNeR.js.gz +0 -0
  279. package/dist/ui/assets/{chunk-JZLCHNYA-BsgZ79Fa.js → chunk-JZLCHNYA-ButC6pwN.js} +1 -1
  280. package/dist/ui/assets/chunk-JZLCHNYA-ButC6pwN.js.gz +0 -0
  281. package/dist/ui/assets/{chunk-MI3HLSF2-dwYeUy5S.js → chunk-MI3HLSF2-BivYzoSV.js} +1 -1
  282. package/dist/ui/assets/chunk-MI3HLSF2-BivYzoSV.js.gz +0 -0
  283. package/dist/ui/assets/chunk-N4CR4FBY-mVWzo5wJ.js +2 -0
  284. package/dist/ui/assets/chunk-N4CR4FBY-mVWzo5wJ.js.gz +0 -0
  285. package/dist/ui/assets/{chunk-QN33PNHL-DxdIDCAa.js → chunk-QN33PNHL-tXtHZpaG.js} +1 -1
  286. package/dist/ui/assets/{chunk-QXUST7PY-BCK2V0i-.js → chunk-QXUST7PY-DATib_Vv.js} +1 -1
  287. package/dist/ui/assets/chunk-QXUST7PY-DATib_Vv.js.gz +0 -0
  288. package/dist/ui/assets/chunk-QZHKN3VN-y6l249e5.js +1 -0
  289. package/dist/ui/assets/{chunk-S3R3BYOJ-GP3zIxrB.js → chunk-S3R3BYOJ-BEtfmflI.js} +1 -1
  290. package/dist/ui/assets/chunk-S3R3BYOJ-BEtfmflI.js.gz +0 -0
  291. package/dist/ui/assets/{chunk-TZMSLE5B-dX5RaM6g.js → chunk-TZMSLE5B-BY1ZtogK.js} +1 -1
  292. package/dist/ui/assets/chunk-TZMSLE5B-BY1ZtogK.js.gz +0 -0
  293. package/dist/ui/assets/classDiagram-2ON5EDUG-BYvq-uPY.js +1 -0
  294. package/dist/ui/assets/classDiagram-v2-WZHVMYZB-BYvq-uPY.js +1 -0
  295. package/dist/ui/assets/constants-CYzQKfD1.js +1 -0
  296. package/dist/ui/assets/{cose-bilkent-S5V4N54A-Dx0BJVDl.js → cose-bilkent-S5V4N54A-DPvYrqGG.js} +1 -1
  297. package/dist/ui/assets/cose-bilkent-S5V4N54A-DPvYrqGG.js.gz +0 -0
  298. package/dist/ui/assets/{dagre-6UL2VRFP-DiQSUxqN.js → dagre-6UL2VRFP-D800J6qb.js} +1 -1
  299. package/dist/ui/assets/dagre-6UL2VRFP-D800J6qb.js.gz +0 -0
  300. package/dist/ui/assets/{dagre-Bekd9Vdj.js → dagre-TNc4wezg.js} +1 -1
  301. package/dist/ui/assets/dagre-TNc4wezg.js.gz +0 -0
  302. package/dist/ui/assets/{diagram-PSM6KHXK-DtJnDQjc.js → diagram-PSM6KHXK-CGdP9F-X.js} +1 -1
  303. package/dist/ui/assets/diagram-PSM6KHXK-CGdP9F-X.js.gz +0 -0
  304. package/dist/ui/assets/{diagram-QEK2KX5R-CobkCRdj.js → diagram-QEK2KX5R-BD5lOCe5.js} +1 -1
  305. package/dist/ui/assets/diagram-QEK2KX5R-BD5lOCe5.js.gz +0 -0
  306. package/dist/ui/assets/{diagram-S2PKOQOG-DHEZYivc.js → diagram-S2PKOQOG-cp3l22vN.js} +1 -1
  307. package/dist/ui/assets/diagram-S2PKOQOG-cp3l22vN.js.gz +0 -0
  308. package/dist/ui/assets/editor-Cr0W5BQI.js +39 -0
  309. package/dist/ui/assets/editor-Cr0W5BQI.js.gz +0 -0
  310. package/dist/ui/assets/{emoji-B0hLmSLZ.js → emoji-Bv3m24sO.js} +1 -1
  311. package/dist/ui/assets/emoji-Bv3m24sO.js.gz +0 -0
  312. package/dist/ui/assets/{erDiagram-Q2GNP2WA-BVNeTZPQ.js → erDiagram-Q2GNP2WA-CQSXRgqr.js} +1 -1
  313. package/dist/ui/assets/erDiagram-Q2GNP2WA-CQSXRgqr.js.gz +0 -0
  314. package/dist/ui/assets/{flowDiagram-NV44I4VS-C73VFdyk.js → flowDiagram-NV44I4VS-CKcKpkph.js} +1 -1
  315. package/dist/ui/assets/flowDiagram-NV44I4VS-CKcKpkph.js.gz +0 -0
  316. package/dist/ui/assets/{ganttDiagram-LVOFAZNH-B_RosuD1.js → ganttDiagram-LVOFAZNH-DlAHzXO5.js} +1 -1
  317. package/dist/ui/assets/ganttDiagram-LVOFAZNH-DlAHzXO5.js.gz +0 -0
  318. package/dist/ui/assets/{gitGraph-F6HP7TQM-DMFIqn4h.js → gitGraph-F6HP7TQM-DeuXy4B1.js} +1 -1
  319. package/dist/ui/assets/{gitGraphDiagram-NY62KEGX-hxbgwNA1.js → gitGraphDiagram-NY62KEGX-aB-AI4Vq.js} +1 -1
  320. package/dist/ui/assets/gitGraphDiagram-NY62KEGX-aB-AI4Vq.js.gz +0 -0
  321. package/dist/ui/assets/index-B-qHc0o5.js +63 -0
  322. package/dist/ui/assets/index-B-qHc0o5.js.gz +0 -0
  323. package/dist/ui/assets/{info-NVLQJR56-DZ3K-w48.js → info-NVLQJR56-B9PG7xsc.js} +1 -1
  324. package/dist/ui/assets/{infoDiagram-ER5ION4S-CxnBJQu6.js → infoDiagram-ER5ION4S-C5Wpoqim.js} +1 -1
  325. package/dist/ui/assets/{journeyDiagram-XKPGCS4Q-CHYNj-f8.js → journeyDiagram-XKPGCS4Q-CHLziqfS.js} +1 -1
  326. package/dist/ui/assets/journeyDiagram-XKPGCS4Q-CHLziqfS.js.gz +0 -0
  327. package/dist/ui/assets/{kanban-definition-3W4ZIXB7-DQPCCsj2.js → kanban-definition-3W4ZIXB7-Dq7GzQE_.js} +1 -1
  328. package/dist/ui/assets/kanban-definition-3W4ZIXB7-Dq7GzQE_.js.gz +0 -0
  329. package/dist/ui/assets/{line-DBRjKmfa.js → line-DHKNg83I.js} +1 -1
  330. package/dist/ui/assets/{linear-DFao5Wyp.js → linear-BvUfn0I8.js} +1 -1
  331. package/dist/ui/assets/linear-BvUfn0I8.js.gz +0 -0
  332. package/dist/ui/assets/{mermaid-parser.core-DYCfacHj.js → mermaid-parser.core-C6d9tKoo.js} +2 -2
  333. package/dist/ui/assets/mermaid-parser.core-C6d9tKoo.js.gz +0 -0
  334. package/dist/ui/assets/{mermaid.core-C6xGFSdE.js → mermaid.core-CxE5KezR.js} +3 -3
  335. package/dist/ui/assets/mermaid.core-CxE5KezR.js.gz +0 -0
  336. package/dist/ui/assets/{mindmap-definition-VGOIOE7T-L3Pw-YM7.js → mindmap-definition-VGOIOE7T-DmPoQ48w.js} +1 -1
  337. package/dist/ui/assets/mindmap-definition-VGOIOE7T-DmPoQ48w.js.gz +0 -0
  338. package/dist/ui/assets/{packet-BFZMPI3H-CpL6iNoa.js → packet-BFZMPI3H-JZEkVZxU.js} +1 -1
  339. package/dist/ui/assets/{particles-CT8hcJOA.js → particles-CxMmUw86.js} +1 -1
  340. package/dist/ui/assets/particles-CxMmUw86.js.gz +0 -0
  341. package/dist/ui/assets/{pie-7BOR55EZ-hTqChbTo.js → pie-7BOR55EZ-_1II5pYQ.js} +1 -1
  342. package/dist/ui/assets/{pieDiagram-ADFJNKIX-Bf4Nou75.js → pieDiagram-ADFJNKIX-DrNkH33i.js} +1 -1
  343. package/dist/ui/assets/pieDiagram-ADFJNKIX-DrNkH33i.js.gz +0 -0
  344. package/dist/ui/assets/{quadrantDiagram-AYHSOK5B-DpjUTLB1.js → quadrantDiagram-AYHSOK5B-DOpC-HEF.js} +1 -1
  345. package/dist/ui/assets/quadrantDiagram-AYHSOK5B-DOpC-HEF.js.gz +0 -0
  346. package/dist/ui/assets/{radar-NHE76QYJ-myy7OENC.js → radar-NHE76QYJ-DDmqhzEZ.js} +1 -1
  347. package/dist/ui/assets/{reactflow-Cubtnk8i.js → reactflow-D98uPOMq.js} +1 -1
  348. package/dist/ui/assets/reactflow-D98uPOMq.js.gz +0 -0
  349. package/dist/ui/assets/{requirementDiagram-UZGBJVZJ-Bfrfh-0-.js → requirementDiagram-UZGBJVZJ-Bzx0iEPP.js} +1 -1
  350. package/dist/ui/assets/requirementDiagram-UZGBJVZJ-Bzx0iEPP.js.gz +0 -0
  351. package/dist/ui/assets/{sandpack-C58bwfIS.js → sandpack-059Z4UWP.js} +1 -1
  352. package/dist/ui/assets/sandpack-059Z4UWP.js.gz +0 -0
  353. package/dist/ui/assets/sandpackDefaults-CPMNDsw7.js +1 -0
  354. package/dist/ui/assets/sandpackDefaults-CPMNDsw7.js.gz +0 -0
  355. package/dist/ui/assets/{sankeyDiagram-TZEHDZUN-ClZAZ6va.js → sankeyDiagram-TZEHDZUN-Do9pvfDv.js} +1 -1
  356. package/dist/ui/assets/sankeyDiagram-TZEHDZUN-Do9pvfDv.js.gz +0 -0
  357. package/dist/ui/assets/{sequenceDiagram-WL72ISMW-CNgly63p.js → sequenceDiagram-WL72ISMW-CN8neUTA.js} +1 -1
  358. package/dist/ui/assets/sequenceDiagram-WL72ISMW-CN8neUTA.js.gz +0 -0
  359. package/dist/ui/assets/{src-DAeyG22O.js → src-DEbsv3pp.js} +2 -2
  360. package/dist/ui/assets/src-DEbsv3pp.js.gz +0 -0
  361. package/dist/ui/assets/{stateDiagram-FKZM4ZOC-BrEAoDpE.js → stateDiagram-FKZM4ZOC-BluWJi8n.js} +1 -1
  362. package/dist/ui/assets/stateDiagram-FKZM4ZOC-BluWJi8n.js.gz +0 -0
  363. package/dist/ui/assets/stateDiagram-v2-4FDKWEC3-DeyqBMDR.js +1 -0
  364. package/dist/ui/assets/{streamdown-BdAVfkeF.js → streamdown-BT1twtFc.js} +5 -5
  365. package/dist/ui/assets/streamdown-BT1twtFc.js.gz +0 -0
  366. package/dist/ui/assets/{syntax-BOfTnQiy.js → syntax-CBu6nLfm.js} +1 -1
  367. package/dist/ui/assets/syntax-CBu6nLfm.js.gz +0 -0
  368. package/dist/ui/assets/{timeline-definition-IT6M3QCI-CaRH3k4l.js → timeline-definition-IT6M3QCI-WdUNkiRj.js} +1 -1
  369. package/dist/ui/assets/timeline-definition-IT6M3QCI-WdUNkiRj.js.gz +0 -0
  370. package/dist/ui/assets/{treemap-KMMF4GRG-CUaLOV_B.js → treemap-KMMF4GRG-CoriU4Jl.js} +1 -1
  371. package/dist/ui/assets/{useUserLocalStorage-C8sgXgXR.js → useUserLocalStorage-GidNiOPC.js} +1 -1
  372. package/dist/ui/assets/useUserLocalStorage-GidNiOPC.js.gz +0 -0
  373. package/dist/ui/assets/{xychartDiagram-PRI3JC2R-BlhkI9T_.js → xychartDiagram-PRI3JC2R-CgBAKNt2.js} +1 -1
  374. package/dist/ui/assets/xychartDiagram-PRI3JC2R-CgBAKNt2.js.gz +0 -0
  375. package/dist/ui/index.html +9 -8
  376. package/dist/ui/index.html.gz +0 -0
  377. package/package.json +2 -2
  378. package/dist/ui/assets/AgorEmojiPickerInner-DQjr8M3_.js +0 -1
  379. package/dist/ui/assets/App-hJtcOxHv.js +0 -5
  380. package/dist/ui/assets/App-hJtcOxHv.js.gz +0 -0
  381. package/dist/ui/assets/AppNode-BhuMpn8O.js +0 -1
  382. package/dist/ui/assets/AppNode-BhuMpn8O.js.gz +0 -0
  383. package/dist/ui/assets/ArtifactConsentModal-oMMzRn8L.js.gz +0 -0
  384. package/dist/ui/assets/ArtifactFullscreenPage-B3wT8t8f.js +0 -9
  385. package/dist/ui/assets/ArtifactFullscreenPage-B3wT8t8f.js.gz +0 -0
  386. package/dist/ui/assets/ArtifactNode-BzQcrwFS.js +0 -9
  387. package/dist/ui/assets/ArtifactNode-BzQcrwFS.js.gz +0 -0
  388. package/dist/ui/assets/AutocompleteTextarea-Dau-V_30.js +0 -19
  389. package/dist/ui/assets/AutocompleteTextarea-Dau-V_30.js.gz +0 -0
  390. package/dist/ui/assets/BoardObjectNodes-DdKWv_ZT.js +0 -34
  391. package/dist/ui/assets/BoardObjectNodes-DdKWv_ZT.js.gz +0 -0
  392. package/dist/ui/assets/CodeEditor.inner-Cuj6RuLL.js.gz +0 -0
  393. package/dist/ui/assets/ConversationView-9-3ma1u-.js +0 -1
  394. package/dist/ui/assets/ConversationView-9-3ma1u-.js.gz +0 -0
  395. package/dist/ui/assets/EmbeddedTerminal-Lx5I9EOJ.js.gz +0 -0
  396. package/dist/ui/assets/KnowledgePage-Dz8YAMYC.js +0 -24
  397. package/dist/ui/assets/KnowledgePage-Dz8YAMYC.js.gz +0 -0
  398. package/dist/ui/assets/MarketingScreenshotPage-CmDPBHOl.js.gz +0 -0
  399. package/dist/ui/assets/MobileApp-BpgSG_gz.js +0 -1
  400. package/dist/ui/assets/MobileApp-BpgSG_gz.js.gz +0 -0
  401. package/dist/ui/assets/SessionCanvas-B6_mtlxK.js +0 -13
  402. package/dist/ui/assets/SessionCanvas-B6_mtlxK.js.gz +0 -0
  403. package/dist/ui/assets/StreamdownDemoPage-okKKR2QH.js.gz +0 -0
  404. package/dist/ui/assets/TerminalModal-D9jMGZXv.js.gz +0 -0
  405. package/dist/ui/assets/ThemeSwitcher-D9HgT37l.js +0 -1
  406. package/dist/ui/assets/ThemeSwitcher-D9HgT37l.js.gz +0 -0
  407. package/dist/ui/assets/architecture-U656AL7Q-DMnxkQRZ.js +0 -1
  408. package/dist/ui/assets/architectureDiagram-VXUJARFQ-DwTJGGoj.js.gz +0 -0
  409. package/dist/ui/assets/blockDiagram-VD42YOAC-Dh1_TVW2.js.gz +0 -0
  410. package/dist/ui/assets/c4Diagram-YG6GDRKO-B1e96AcB.js.gz +0 -0
  411. package/dist/ui/assets/channel-Jv4dT4S5.js +0 -1
  412. package/dist/ui/assets/chunk-55IACEB6-lJXvUquf.js +0 -1
  413. package/dist/ui/assets/chunk-ABZYJK2D-DCTXWSzV.js.gz +0 -0
  414. package/dist/ui/assets/chunk-AGHRB4JF-CbNphBjE.js.gz +0 -0
  415. package/dist/ui/assets/chunk-ATLVNIR6-rWg3qxof.js.gz +0 -0
  416. package/dist/ui/assets/chunk-B4BG7PRW-CgtLCbpE.js.gz +0 -0
  417. package/dist/ui/assets/chunk-DI55MBZ5-Dwvx2Kva.js.gz +0 -0
  418. package/dist/ui/assets/chunk-EXTU4WIE-DHyaqTsP.js +0 -1
  419. package/dist/ui/assets/chunk-HN2XXSSU-2blQO3Gb.js.gz +0 -0
  420. package/dist/ui/assets/chunk-JA3XYJ7Z-Cr1rmOui.js.gz +0 -0
  421. package/dist/ui/assets/chunk-JZLCHNYA-BsgZ79Fa.js.gz +0 -0
  422. package/dist/ui/assets/chunk-MI3HLSF2-dwYeUy5S.js.gz +0 -0
  423. package/dist/ui/assets/chunk-N4CR4FBY-DEMgSRVe.js +0 -2
  424. package/dist/ui/assets/chunk-N4CR4FBY-DEMgSRVe.js.gz +0 -0
  425. package/dist/ui/assets/chunk-QXUST7PY-BCK2V0i-.js.gz +0 -0
  426. package/dist/ui/assets/chunk-QZHKN3VN-CALjGrEE.js +0 -1
  427. package/dist/ui/assets/chunk-S3R3BYOJ-GP3zIxrB.js.gz +0 -0
  428. package/dist/ui/assets/chunk-TZMSLE5B-dX5RaM6g.js.gz +0 -0
  429. package/dist/ui/assets/classDiagram-2ON5EDUG-C3_RVP70.js +0 -1
  430. package/dist/ui/assets/classDiagram-v2-WZHVMYZB-C3_RVP70.js +0 -1
  431. package/dist/ui/assets/constants-GjIDNVyt.js +0 -1
  432. package/dist/ui/assets/cose-bilkent-S5V4N54A-Dx0BJVDl.js.gz +0 -0
  433. package/dist/ui/assets/dagre-6UL2VRFP-DiQSUxqN.js.gz +0 -0
  434. package/dist/ui/assets/dagre-Bekd9Vdj.js.gz +0 -0
  435. package/dist/ui/assets/diagram-PSM6KHXK-DtJnDQjc.js.gz +0 -0
  436. package/dist/ui/assets/diagram-QEK2KX5R-CobkCRdj.js.gz +0 -0
  437. package/dist/ui/assets/diagram-S2PKOQOG-DHEZYivc.js.gz +0 -0
  438. package/dist/ui/assets/editor-DQIG-JYZ.js +0 -43
  439. package/dist/ui/assets/editor-DQIG-JYZ.js.gz +0 -0
  440. package/dist/ui/assets/emoji-B0hLmSLZ.js.gz +0 -0
  441. package/dist/ui/assets/erDiagram-Q2GNP2WA-BVNeTZPQ.js.gz +0 -0
  442. package/dist/ui/assets/flowDiagram-NV44I4VS-C73VFdyk.js.gz +0 -0
  443. package/dist/ui/assets/ganttDiagram-LVOFAZNH-B_RosuD1.js.gz +0 -0
  444. package/dist/ui/assets/gitGraphDiagram-NY62KEGX-hxbgwNA1.js.gz +0 -0
  445. package/dist/ui/assets/index-DTz1Dif6.js +0 -64
  446. package/dist/ui/assets/index-DTz1Dif6.js.gz +0 -0
  447. package/dist/ui/assets/journeyDiagram-XKPGCS4Q-CHYNj-f8.js.gz +0 -0
  448. package/dist/ui/assets/kanban-definition-3W4ZIXB7-DQPCCsj2.js.gz +0 -0
  449. package/dist/ui/assets/linear-DFao5Wyp.js.gz +0 -0
  450. package/dist/ui/assets/mermaid-parser.core-DYCfacHj.js.gz +0 -0
  451. package/dist/ui/assets/mermaid.core-C6xGFSdE.js.gz +0 -0
  452. package/dist/ui/assets/mindmap-definition-VGOIOE7T-L3Pw-YM7.js.gz +0 -0
  453. package/dist/ui/assets/particles-CT8hcJOA.js.gz +0 -0
  454. package/dist/ui/assets/pieDiagram-ADFJNKIX-Bf4Nou75.js.gz +0 -0
  455. package/dist/ui/assets/quadrantDiagram-AYHSOK5B-DpjUTLB1.js.gz +0 -0
  456. package/dist/ui/assets/reactflow-Cubtnk8i.js.gz +0 -0
  457. package/dist/ui/assets/requirementDiagram-UZGBJVZJ-Bfrfh-0-.js.gz +0 -0
  458. package/dist/ui/assets/sandpack-C58bwfIS.js.gz +0 -0
  459. package/dist/ui/assets/sandpackDefaults-Bkga8XAE.js +0 -1
  460. package/dist/ui/assets/sankeyDiagram-TZEHDZUN-ClZAZ6va.js.gz +0 -0
  461. package/dist/ui/assets/sequenceDiagram-WL72ISMW-CNgly63p.js.gz +0 -0
  462. package/dist/ui/assets/src-DAeyG22O.js.gz +0 -0
  463. package/dist/ui/assets/stateDiagram-FKZM4ZOC-BrEAoDpE.js.gz +0 -0
  464. package/dist/ui/assets/stateDiagram-v2-4FDKWEC3-BNL52_oN.js +0 -1
  465. package/dist/ui/assets/streamdown-BdAVfkeF.js.gz +0 -0
  466. package/dist/ui/assets/syntax-BOfTnQiy.js.gz +0 -0
  467. package/dist/ui/assets/timeline-definition-IT6M3QCI-CaRH3k4l.js.gz +0 -0
  468. package/dist/ui/assets/useUserLocalStorage-C8sgXgXR.js.gz +0 -0
  469. package/dist/ui/assets/xychartDiagram-PRI3JC2R-BlhkI9T_.js.gz +0 -0
@@ -1,64 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AgorEmojiPickerInner-DQjr8M3_.js","assets/editor-DQIG-JYZ.js","assets/rolldown-runtime--c01j_DQ.js","assets/antd-DT5ackd0.js","assets/emoji-B0hLmSLZ.js","assets/CodeEditor.inner-Cuj6RuLL.js","assets/ThemedSyntaxHighlighter.inner-C1FdIHn0.js","assets/syntax-BOfTnQiy.js","assets/streamdown-BdAVfkeF.js","assets/sandpack-C58bwfIS.js","assets/App-hJtcOxHv.js","assets/BoardObjectNodes-DdKWv_ZT.js","assets/AutocompleteTextarea-Dau-V_30.js","assets/src-DAeyG22O.js","assets/__vite-browser-external-BBPYNvOp.js","assets/AutocompleteTextarea-x1XGuNl0.css","assets/reactflow-Cubtnk8i.js","assets/reactflow-8hax8RNO.css","assets/SessionCanvas-B6_mtlxK.js","assets/ThemeSwitcher-D9HgT37l.js","assets/SessionCanvas-Bh7Yg5dZ.css","assets/ConversationView-9-3ma1u-.js","assets/constants-GjIDNVyt.js","assets/useUserLocalStorage-C8sgXgXR.js","assets/KnowledgePage-Dz8YAMYC.js","assets/ArtifactFullscreenPage-B3wT8t8f.js","assets/ArtifactConsentModal-oMMzRn8L.js","assets/sandpackDefaults-Bkga8XAE.js","assets/MobileApp-BpgSG_gz.js","assets/StreamdownDemoPage-okKKR2QH.js","assets/MarketingScreenshotPage-CmDPBHOl.js","assets/MarketingScreenshotPage-9Qd7eZsm.css"])))=>i.map(i=>d[i]);
2
- import{o as e,r as t,t as n}from"./rolldown-runtime--c01j_DQ.js";import{$ as r,$n as i,$t as a,A as o,An as s,At as c,Bn as l,Bt as u,C as d,Cn as f,Ct as p,Dn as m,E as h,En as g,F as _,Ft as v,G as y,Gn as b,Gt as x,H as S,Hn as C,Ht as w,In as T,It as E,J as D,Jt as O,K as k,Kn as A,Kt as j,L as M,Ln as N,Lt as P,M as F,N as I,Nt as ee,On as L,Ot as te,Pn as R,Q as ne,Qn as z,Qt as B,R as V,Rn as H,Rt as re,St as ie,Tn as U,U as ae,Un as oe,Ut as se,V as ce,Vn as le,Vt as ue,W as de,Wn as fe,X as pe,Xn as me,Xt as he,Yn as ge,Yt as _e,Z as ve,Zn as ye,_n as be,a as xe,an as Se,b as Ce,cn as we,d as W,er as Te,fn as G,gt as Ee,h as De,hn as Oe,i as ke,in as Ae,ir as je,it as Me,jn as Ne,jt as Pe,k as Fe,kn as K,kt as Ie,l as Le,ln as Re,lt as ze,m as Be,mn as q,n as Ve,nn as He,nr as Ue,nt as We,o as Ge,pn as Ke,pt as qe,qt as Je,rn as J,s as Ye,sn as Y,st as Xe,tn as Ze,tt as Qe,u as $e,un as et,ut as tt,v as nt,vn as rt,vt as it,w as at,wn as ot,xt as st,y as ct,yn as lt,yt as ut,z as dt,zn as ft,zt as X}from"./antd-DT5ackd0.js";import{C as pt,D as mt,E as ht,K as gt,M as _t,O as vt,S as yt,T as bt,X as xt,Y as St,_ as Ct,a as wt,at as Tt,b as Et,c as Dt,ct as Ot,d as kt,dt as At,et as jt,f as Mt,ft as Nt,g as Pt,h as Ft,i as It,it as Lt,j as Rt,k as zt,l as Bt,lt as Vt,m as Ht,n as Ut,nt as Wt,o as Gt,ot as Kt,p as qt,q as Jt,r as Yt,rt as Xt,s as Zt,st as Qt,t as $t,ut as en,v as tn,w as nn,x as rn,y as an}from"./src-DAeyG22O.js";import{c as on,o as sn,s as cn}from"./sandpack-C58bwfIS.js";import{N as ln}from"./editor-DQIG-JYZ.js";import{n as un,r as dn,t as fn}from"./particles-CT8hcJOA.js";import{k as pn}from"./reactflow-Cubtnk8i.js";import{n as mn,t as hn}from"./streamdown-BdAVfkeF.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var gn={session:(e=>[e.title,e.description,e.agentic_tool]),branch:(e=>[e.name,e.ref,e.notes,e.issue_url,e.pull_request_url,Wt(e)?.displayName]),artifact:(e=>[e.name,e.description]),board:(e=>[e.name,e.description]),mcp:(e=>[e.name,e.display_name,e.description])};function _n(e,t){let n=e.map(e=>e.trim().toLowerCase()).filter(Boolean);if(n.length===0)return!1;let r=t.filter(e=>!!e).join(`
3
- `).toLowerCase();return n.every(e=>r.includes(e))}function vn(e){return e.trim().toLowerCase().split(/\s+/).filter(Boolean)}var Z=e(je(),1),yn=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,bn=/^[\\/]{2}/;function xn(e,t){return t+e.replace(/\\/g,`/`)}var Sn=`popstate`;function Cn(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function wn(e={}){function t(e,t){let n=t.state?.masked,{pathname:r,search:i,hash:a}=n||e.location;return kn(``,{pathname:r,search:i,hash:a},t.state&&t.state.usr||null,t.state&&t.state.key||`default`,n?{pathname:e.location.pathname,search:e.location.search,hash:e.location.hash}:void 0)}function n(e,t){return typeof t==`string`?t:An(t)}return Mn(t,n,null,e)}function Tn(e,t){if(e===!1||e==null)throw Error(t)}function En(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function Dn(){return Math.random().toString(36).substring(2,10)}function On(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function kn(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?jn(t):t,state:n,key:t&&t.key||r||Dn(),mask:i}}function An({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function jn(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function Mn(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=Cn(e)?e:kn(h.location,e,t);n&&n(r,e),l=u()+1;let d=On(r,l),f=h.createHref(r.mask||r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=Cn(e)?e:kn(h.location,e,t);n&&n(r,e),l=u();let i=On(r,l),d=h.createHref(r.mask||r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return Nn(i,e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(Sn,d),c=e,()=>{i.removeEventListener(Sn,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function Nn(e,t,n=!1){let r=`http://localhost`;e&&(r=e.location.origin===`null`?e.location.href:e.location.origin),Tn(r,`No window.location.(origin|href) available to create URL`);let i=typeof t==`string`?t:An(t);return i=i.replace(/ $/,`%20`),!n&&bn.test(i)&&(i=r+i),new URL(i,r)}function Pn(e,t,n=`/`){return Fn(e,t,n,!1)}function Fn(e,t,n,r,i){let a=tr((typeof t==`string`?jn(t):t).pathname||`/`,n);if(a==null)return null;let o=i??Ln(e),s=null,c=er(a);for(let e=0;s==null&&e<o.length;++e)s=Xn(o[e],c,r);return s}function In(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function Ln(e){let t=Rn(e);return Bn(t),t}function Rn(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;Tn(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=lr([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(Tn(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),Rn(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:Jn(l,e.index),routesMeta:u.map((e,t)=>{let[n,r]=$n(e.relativePath,e.caseSensitive,t===u.length-1);return{...e,matcher:n,compiledParams:r}})})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of zn(e.path))a(e,t,!0,n)}),t}function zn(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=zn(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function Bn(e){e.sort((e,t)=>e.score===t.score?Yn(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var Vn=/^:[\w-]+$/,Hn=3,Un=2,Wn=1,Gn=10,Kn=-2,qn=e=>e===`*`;function Jn(e,t){let n=e.split(`/`),r=n.length;return n.some(qn)&&(r+=Kn),t&&(r+=Un),n.filter(e=>!qn(e)).reduce((e,t)=>e+(Vn.test(t)?Hn:t===``?Wn:Gn),r)}function Yn(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function Xn(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u={path:s.relativePath,caseSensitive:s.caseSensitive,end:c},d=s.matcher&&s.compiledParams?Qn(u,l,s.matcher,s.compiledParams):Zn(u,l),f=s.route;if(!d&&c&&n&&!r[r.length-1].route.index&&(d=Zn({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!d)return null;Object.assign(i,d.params),o.push({params:i,pathname:lr([a,d.pathname]),pathnameBase:dr(lr([a,d.pathnameBase])),route:f}),d.pathnameBase!==`/`&&(a=lr([a,d.pathnameBase]))}return o}function Zn(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=$n(e.path,e.caseSensitive,e.end);return Qn(e,t,n,r)}function Qn(e,t,n,r){let i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function $n(e,t=!1,n=!0){En(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n,i,a)=>{if(r.push({paramName:t,isOptional:n!=null}),n){let t=a.charAt(i+e.length);return t&&t!==`/`?`/([^\\/]*)`:`(?:/([^\\/]*))?`}return`/([^\\/]+)`}).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function er(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return En(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function tr(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}function nr(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?jn(e):e,a;return n?(n=cr(n),a=n.startsWith(`/`)?rr(n.substring(1),`/`):rr(n,t)):a=t,{pathname:a,search:fr(r),hash:pr(i)}}function rr(e,t){let n=ur(t).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function ir(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function ar(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function or(e){let t=ar(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function sr(e,t,n,r=!1){let i;typeof e==`string`?i=jn(e):(i={...e},Tn(!i.pathname||!i.pathname.includes(`?`),ir(`?`,`pathname`,`search`,i)),Tn(!i.pathname||!i.pathname.includes(`#`),ir(`#`,`pathname`,`hash`,i)),Tn(!i.search||!i.search.includes(`#`),ir(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=nr(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var cr=e=>e.replace(/[\\/]{2,}/g,`/`),lr=e=>cr(e.join(`/`)),ur=e=>e.replace(/\/+$/,``),dr=e=>ur(e).replace(/^\/*/,`/`),fr=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,pr=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,mr=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function hr(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function gr(e){return lr(e.map(e=>e.route.path).filter(Boolean))||`/`}var _r=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function vr(e,t){let n=e;if(typeof n!=`string`||!yn.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(_r)try{let e=new URL(window.location.href),r=bn.test(n)?new URL(xn(n,e.protocol)):new URL(n),a=tr(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{En(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var yr=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(yr);var br=[`GET`,...yr];new Set(br);var xr=[`about:`,`blob:`,`chrome:`,`chrome-untrusted:`,`content:`,`data:`,`devtools:`,`file:`,`filesystem:`,`javascript:`];function Sr(e){try{return xr.includes(new URL(e).protocol)}catch{return!1}}var Cr=Z.createContext(null);Cr.displayName=`DataRouter`;var wr=Z.createContext(null);wr.displayName=`DataRouterState`;var Tr=Z.createContext(!1);function Er(){return Z.useContext(Tr)}var Dr=Z.createContext({isTransitioning:!1});Dr.displayName=`ViewTransition`;var Or=Z.createContext(new Map);Or.displayName=`Fetchers`;var kr=Z.createContext(null);kr.displayName=`Await`;var Ar=Z.createContext(null);Ar.displayName=`Navigation`;var jr=Z.createContext(null);jr.displayName=`Location`;var Mr=Z.createContext({outlet:null,matches:[],isDataRoute:!1});Mr.displayName=`Route`;var Nr=Z.createContext(null);Nr.displayName=`RouteError`;var Pr=`REACT_ROUTER_ERROR`,Fr=`REDIRECT`,Ir=`ROUTE_ERROR_RESPONSE`;function Lr(e){if(e.startsWith(`${Pr}:${Fr}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function Rr(e){if(e.startsWith(`${Pr}:${Ir}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new mr(t.status,t.statusText,t.data)}catch{}}function zr(e,{relative:t}={}){Tn(Br(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=Z.useContext(Ar),{hash:i,pathname:a,search:o}=qr(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:lr([n,a])),r.createHref({pathname:s,search:o,hash:i})}function Br(){return Z.useContext(jr)!=null}function Vr(){return Tn(Br(),`useLocation() may be used only in the context of a <Router> component.`),Z.useContext(jr).location}var Hr=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function Ur(e){Z.useContext(Ar).static||Z.useLayoutEffect(e)}function Wr(){let{isDataRoute:e}=Z.useContext(Mr);return e?fi():Gr()}function Gr(){Tn(Br(),`useNavigate() may be used only in the context of a <Router> component.`);let e=Z.useContext(Cr),{basename:t,navigator:n}=Z.useContext(Ar),{matches:r}=Z.useContext(Mr),{pathname:i}=Vr(),a=JSON.stringify(or(r)),o=Z.useRef(!1);return Ur(()=>{o.current=!0}),Z.useCallback((r,s={})=>{if(En(o.current,Hr),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=sr(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:lr([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}Z.createContext(null);function Kr(){let{matches:e}=Z.useContext(Mr);return e[e.length-1]?.params??{}}function qr(e,{relative:t}={}){let{matches:n}=Z.useContext(Mr),{pathname:r}=Vr(),i=JSON.stringify(or(n));return Z.useMemo(()=>sr(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function Jr(e,t){return Yr(e,t)}function Yr(e,t,n){Tn(Br(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:r}=Z.useContext(Ar),{matches:i}=Z.useContext(Mr),a=i[i.length-1],o=a?a.params:{},s=a?a.pathname:`/`,c=a?a.pathnameBase:`/`,l=a&&a.route;{let e=l&&l.path||``;mi(s,!l||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${s}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
4
-
5
- Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let u=Vr(),d;if(t){let e=typeof t==`string`?jn(t):t;Tn(c===`/`||e.pathname?.startsWith(c),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${e.pathname}" was given in the \`location\` prop.`),d=e}else d=u;let f=d.pathname||`/`,p=f;if(c!==`/`){let e=c.replace(/^\//,``).split(`/`);p=`/`+f.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let m=n&&n.state.matches.length?n.state.matches.map(e=>Object.assign(e,{route:n.manifest[e.route.id]||e.route})):Pn(e,{pathname:p});En(l||m!=null,`No routes matched location "${d.pathname}${d.search}${d.hash}" `),En(m==null||m[m.length-1].route.element!==void 0||m[m.length-1].route.Component!==void 0||m[m.length-1].route.lazy!==void 0,`Matched leaf route at location "${d.pathname}${d.search}${d.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let h=ni(m&&m.map(e=>Object.assign({},e,{params:Object.assign({},o,e.params),pathname:lr([c,r.encodeLocation?r.encodeLocation(e.pathname.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?c:lr([c,r.encodeLocation?r.encodeLocation(e.pathnameBase.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),i,n);return t&&h?Z.createElement(jr.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,mask:void 0,...d},navigationType:`POP`}},h):h}function Xr(){let e=di(),t=hr(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r=`rgba(200,200,200, 0.5)`,i={padding:`0.5rem`,backgroundColor:r},a={padding:`2px 4px`,backgroundColor:r},o=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),o=Z.createElement(Z.Fragment,null,Z.createElement(`p`,null,`💿 Hey developer 👋`),Z.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,Z.createElement(`code`,{style:a},`ErrorBoundary`),` or`,` `,Z.createElement(`code`,{style:a},`errorElement`),` prop on your route.`)),Z.createElement(Z.Fragment,null,Z.createElement(`h2`,null,`Unexpected Application Error!`),Z.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?Z.createElement(`pre`,{style:i},n):null,o)}var Zr=Z.createElement(Xr,null),Qr=class extends Z.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error(`React Router caught the following error during render`,e)}render(){let e=this.state.error;if(this.context&&typeof e==`object`&&e&&`digest`in e&&typeof e.digest==`string`){let t=Rr(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:Z.createElement(Mr.Provider,{value:this.props.routeContext},Z.createElement(Nr.Provider,{value:e,children:this.props.component}));return this.context?Z.createElement(ei,{error:e},t):t}};Qr.contextType=Tr;var $r=new WeakMap;function ei({children:e,error:t}){let{basename:n}=Z.useContext(Ar);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=Lr(t.digest);if(e){let r=$r.get(t);if(r)throw r;let i=vr(e.location,n),a=i.absoluteURL||i.to;if(Sr(a))throw Error(`Invalid redirect location`);if(_r&&!$r.get(t))if(i.isExternal||e.reloadDocument)window.location.href=a;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:e.replace}));throw $r.set(t,n),n}return Z.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${a}`})}}return e}function ti({routeContext:e,match:t,children:n}){let r=Z.useContext(Cr);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),Z.createElement(Mr.Provider,{value:e},n)}function ni(e,t=[],n){let r=n?.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let i=e,a=r?.errors;if(a!=null){let e=i.findIndex(e=>e.route.id&&a?.[e.route.id]!==void 0);Tn(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(`,`)}`),i=i.slice(0,Math.min(i.length,e+1))}let o=!1,s=-1;if(n&&r){o=r.renderFallback;for(let e=0;e<i.length;e++){let t=i[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(s=e),t.route.id){let{loaderData:e,errors:a}=r,c=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!a||a[t.route.id]===void 0);if(t.route.lazy||c){n.isStatic&&(o=!0),i=s>=0?i.slice(0,s+1):[i[0]];break}}}}let c=n?.onError,l=r&&c?(e,t)=>{c(e,{location:r.location,params:r.matches?.[0]?.params??{},pattern:gr(r.matches),errorInfo:t})}:void 0;return i.reduceRight((e,n,c)=>{let u,d=!1,f=null,p=null;r&&(u=a&&n.route.id?a[n.route.id]:void 0,f=n.route.errorElement||Zr,o&&(s<0&&c===0?(mi(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),d=!0,p=null):s===c&&(d=!0,p=n.route.hydrateFallbackElement||null)));let m=t.concat(i.slice(0,c+1)),h=()=>{let t;return t=u?f:d?p:n.route.Component?Z.createElement(n.route.Component,null):n.route.element?n.route.element:e,Z.createElement(ti,{match:n,routeContext:{outlet:e,matches:m,isDataRoute:r!=null},children:t})};return r&&(n.route.ErrorBoundary||n.route.errorElement||c===0)?Z.createElement(Qr,{location:r.location,revalidation:r.revalidation,component:f,error:u,children:h(),routeContext:{outlet:null,matches:m,isDataRoute:!0},onError:l}):h()},null)}function ri(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ii(e){let t=Z.useContext(Cr);return Tn(t,ri(e)),t}function ai(e){let t=Z.useContext(wr);return Tn(t,ri(e)),t}function oi(e){let t=Z.useContext(Mr);return Tn(t,ri(e)),t}function si(e){let t=oi(e),n=t.matches[t.matches.length-1];return Tn(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function ci(){return si(`useRouteId`)}function li(){let e=ai(`useNavigation`);return Z.useMemo(()=>{let{matches:t,historyAction:n,...r}=e.navigation;return r},[e.navigation])}function ui(){let{matches:e,loaderData:t}=ai(`useMatches`);return Z.useMemo(()=>e.map(e=>In(e,t)),[e,t])}function di(){let e=Z.useContext(Nr),t=ai(`useRouteError`),n=si(`useRouteError`);return e===void 0?t.errors?.[n]:e}function fi(){let{router:e}=ii(`useNavigate`),t=si(`useNavigate`),n=Z.useRef(!1);return Ur(()=>{n.current=!0}),Z.useCallback(async(r,i={})=>{En(n.current,Hr),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var pi={};function mi(e,t,n){!t&&!pi[e]&&(pi[e]=!0,En(!1,n))}Z.memo(hi);function hi({routes:e,manifest:t,future:n,state:r,isStatic:i,onError:a}){return Yr(e,void 0,{manifest:t,state:r,isStatic:i,onError:a,future:n})}function gi(e){Tn(!1,`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`)}function _i({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,useTransitions:o}){Tn(!Br(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let s=e.replace(/^\/*/,`/`),c=Z.useMemo(()=>({basename:s,navigator:i,static:a,useTransitions:o,future:{}}),[s,i,a,o]);typeof n==`string`&&(n=jn(n));let{pathname:l=`/`,search:u=``,hash:d=``,state:f=null,key:p=`default`,mask:m}=n,h=Z.useMemo(()=>{let e=tr(l,s);return e==null?null:{location:{pathname:e,search:u,hash:d,state:f,key:p,mask:m},navigationType:r}},[s,l,u,d,f,p,r,m]);return En(h!=null,`<Router basename="${s}"> is not able to match the URL "${l}${u}${d}" because it does not start with the basename, so the <Router> won't render anything.`),h==null?null:Z.createElement(Ar.Provider,{value:c},Z.createElement(jr.Provider,{children:t,value:h}))}function vi({children:e,location:t}){return Jr(yi(e),t)}Z.Component;function yi(e,t=[]){let n=[];return Z.Children.forEach(e,(e,r)=>{if(!Z.isValidElement(e))return;let i=[...t,r];if(e.type===Z.Fragment){n.push.apply(n,yi(e.props.children,i));return}Tn(e.type===gi,`[${typeof e.type==`string`?e.type:e.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Tn(!e.props.index||!e.props.children,`An index route cannot have child routes.`);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.hasErrorBoundary===!0||e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=yi(e.props.children,i)),n.push(a)}),n}var bi=`get`,xi=`application/x-www-form-urlencoded`;function Si(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function Ci(e){return Si(e)&&e.tagName.toLowerCase()===`button`}function wi(e){return Si(e)&&e.tagName.toLowerCase()===`form`}function Ti(e){return Si(e)&&e.tagName.toLowerCase()===`input`}function Ei(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Di(e,t){return e.button===0&&(!t||t===`_self`)&&!Ei(e)}function Oi(e=``){return new URLSearchParams(typeof e==`string`||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(e=>[n,e]):[[n,r]])},[]))}function ki(e,t){let n=Oi(e);return t&&t.forEach((e,r)=>{n.has(r)||t.getAll(r).forEach(e=>{n.append(r,e)})}),n}var Ai=null;function ji(){if(Ai===null)try{new FormData(document.createElement(`form`),0),Ai=!1}catch{Ai=!0}return Ai}var Mi=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function Ni(e){return e!=null&&!Mi.has(e)?(En(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${xi}"`),null):e}function Pi(e,t){let n,r,i,a,o;if(wi(e)){let o=e.getAttribute(`action`);r=o?tr(o,t):null,n=e.getAttribute(`method`)||bi,i=Ni(e.getAttribute(`enctype`))||xi,a=new FormData(e)}else if(Ci(e)||Ti(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a <button> or <input type="submit"> without a <form>`);let s=e.getAttribute(`formaction`)||o.getAttribute(`action`);if(r=s?tr(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||bi,i=Ni(e.getAttribute(`formenctype`))||Ni(o.getAttribute(`enctype`))||xi,a=new FormData(o,e),!ji()){let{name:t,type:n,value:r}=e;if(n===`image`){let e=t?`${t}.`:``;a.append(`${e}x`,`0`),a.append(`${e}y`,`0`)}else t&&a.append(t,r)}}else if(Si(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=bi,r=null,i=xi,o=e;return a&&i===`text/plain`&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var Fi={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},Ii=/[&><\u2028\u2029]/g;function Li(e){return e.replace(Ii,e=>Fi[e])}function Ri(e,t){if(e===!1||e==null)throw Error(t)}function zi(e,t,n,r){let i=typeof e==`string`?new URL(e,typeof window>`u`?`server://singlefetch/`:window.location.origin):e;return n?i.pathname.endsWith(`/`)?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname===`/`?i.pathname=`_root.${r}`:t&&tr(i.pathname,t)===`/`?i.pathname=`${ur(t)}/_root.${r}`:i.pathname=`${ur(i.pathname)}.${r}`,i}async function Bi(e,t){if(e.id in t)return t[e.id];try{let n=await on(()=>import(e.module),[]);return t[e.id]=n,n}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Vi(e){return e!=null&&typeof e.page==`string`}function Hi(e){return e==null?!1:e.href==null?e.rel===`preload`&&typeof e.imageSrcSet==`string`&&typeof e.imageSizes==`string`:typeof e.rel==`string`&&typeof e.href==`string`}async function Ui(e,t,n){return Ji((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await Bi(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(Hi).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function Wi(e,t,n,r,i,a){let o=(e,t)=>n[t]?e.route.id!==n[t].route.id:!0,s=(e,t)=>n[t].pathname!==e.pathname||n[t].route.path?.endsWith(`*`)&&n[t].params[`*`]!==e.params[`*`];return a===`assets`?t.filter((e,t)=>o(e,t)||s(e,t)):a===`data`?t.filter((t,a)=>{let c=r.routes[t.route.id];if(!c||!c.hasLoader)return!1;if(o(t,a)||s(t,a))return!0;if(t.route.shouldRevalidate){let r=t.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if(typeof r==`boolean`)return r}return!0}):[]}function Gi(e,t,{includeHydrateFallback:n}={}){return Ki(e.map(e=>{let r=t.routes[e.route.id];if(!r)return[];let i=[r.module];return r.clientActionModule&&(i=i.concat(r.clientActionModule)),r.clientLoaderModule&&(i=i.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(i=i.concat(r.hydrateFallbackModule)),r.imports&&(i=i.concat(r.imports)),i}).flat(1))}function Ki(e){return[...new Set(e)]}function qi(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function Ji(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!Vi(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(qi(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function Yi(){let e=Z.useContext(Cr);return Ri(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function Xi(){let e=Z.useContext(wr);return Ri(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var Zi=Z.createContext(void 0);Zi.displayName=`FrameworkContext`;function Qi(){let e=Z.useContext(Zi);return Ri(e,`You must render this element inside a <HydratedRouter> element`),e}function $i(e,t){let n=Z.useContext(Zi),[r,i]=Z.useState(!1),[a,o]=Z.useState(!1),{onFocus:s,onBlur:c,onMouseEnter:l,onMouseLeave:u,onTouchStart:d}=t,f=Z.useRef(null);Z.useEffect(()=>{if(e===`render`&&o(!0),e===`viewport`){let e=new IntersectionObserver(e=>{e.forEach(e=>{o(e.isIntersecting)})},{threshold:.5});return f.current&&e.observe(f.current),()=>{e.disconnect()}}},[e]),Z.useEffect(()=>{if(r){let e=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(e)}}},[r]);let p=()=>{i(!0)},m=()=>{i(!1),o(!1)};return n?e===`intent`?[a,f,{onFocus:ea(s,p),onBlur:ea(c,m),onMouseEnter:ea(l,p),onMouseLeave:ea(u,m),onTouchStart:ea(d,p)}]:[a,f,{}]:[!1,f,{}]}function ea(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function ta({page:e,...t}){let n=Er(),{nonce:r}=Qi(),{router:i}=Yi(),a=Z.useMemo(()=>Pn(i.routes,e,i.basename),[i.routes,e,i.basename]);return a?(t.nonce==null&&r&&(t={...t,nonce:r}),n?Z.createElement(ra,{page:e,matches:a,...t}):Z.createElement(ia,{page:e,matches:a,...t})):null}function na(e){let{manifest:t,routeModules:n}=Qi(),[r,i]=Z.useState([]);return Z.useEffect(()=>{let r=!1;return Ui(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function ra({page:e,matches:t,...n}){let r=Vr(),{future:i}=Qi(),{basename:a}=Yi(),o=Z.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=zi(e,a,i.v8_trailingSlashAwareDataRequests,`rsc`),o=!1,s=[];for(let e of t)typeof e.route.shouldRevalidate==`function`?o=!0:s.push(e.route.id);return o&&s.length>0&&n.searchParams.set(`_routes`,s.join(`,`)),[n.pathname+n.search]},[a,i.v8_trailingSlashAwareDataRequests,e,r,t]);return Z.createElement(Z.Fragment,null,o.map(e=>Z.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})))}function ia({page:e,matches:t,...n}){let r=Vr(),{future:i,manifest:a,routeModules:o}=Qi(),{basename:s}=Yi(),{loaderData:c,matches:l}=Xi(),u=Z.useMemo(()=>Wi(e,t,l,a,r,`data`),[e,t,l,a,r]),d=Z.useMemo(()=>Wi(e,t,l,a,r,`assets`),[e,t,l,a,r]),f=Z.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=new Set,l=!1;if(t.forEach(e=>{let t=a.routes[e.route.id];!t||!t.hasLoader||(!u.some(t=>t.route.id===e.route.id)&&e.route.id in c&&o[e.route.id]?.shouldRevalidate||t.hasClientLoader?l=!0:n.add(e.route.id))}),n.size===0)return[];let d=zi(e,s,i.v8_trailingSlashAwareDataRequests,`data`);return l&&n.size>0&&d.searchParams.set(`_routes`,t.filter(e=>n.has(e.route.id)).map(e=>e.route.id).join(`,`)),[d.pathname+d.search]},[s,i.v8_trailingSlashAwareDataRequests,c,r,a,u,t,e,o]),p=Z.useMemo(()=>Gi(d,a),[d,a]),m=na(d);return Z.createElement(Z.Fragment,null,f.map(e=>Z.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),p.map(e=>Z.createElement(`link`,{key:e,rel:`modulepreload`,href:e,...n})),m.map(({key:e,link:t})=>Z.createElement(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function aa(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}Z.Component;var oa=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{oa&&(window.__reactRouterVersion=`7.18.0`)}catch{}function sa({basename:e,children:t,useTransitions:n,window:r}){let i=Z.useRef();i.current??=wn({window:r,v5Compat:!0});let a=i.current,[o,s]=Z.useState({action:a.action,location:a.location}),c=Z.useCallback(e=>{n===!1?s(e):Z.startTransition(()=>s(e))},[n]);return Z.useLayoutEffect(()=>a.listen(c),[a,c]),Z.createElement(_i,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:a,useTransitions:n})}function ca({basename:e,children:t,history:n,useTransitions:r}){let[i,a]=Z.useState({action:n.action,location:n.location}),o=Z.useCallback(e=>{r===!1?a(e):Z.startTransition(()=>a(e))},[r]);return Z.useLayoutEffect(()=>n.listen(o),[n,o]),Z.createElement(_i,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:n,useTransitions:r})}ca.displayName=`unstable_HistoryRouter`;var la=Z.forwardRef(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:r,reloadDocument:i,replace:a,mask:o,state:s,target:c,to:l,preventScrollReset:u,viewTransition:d,defaultShouldRevalidate:f,...p},m){let{basename:h,navigator:g,useTransitions:_}=Z.useContext(Ar),v=typeof l==`string`&&yn.test(l),y=vr(l,h);l=y.to;let b=zr(l,{relative:r}),x=Vr(),S=null;if(o){let e=sr(o,[],x.mask?x.mask.pathname:`/`,!0);h!==`/`&&(e.pathname=e.pathname===`/`?h:lr([h,e.pathname])),S=g.createHref(e)}let[C,w,T]=$i(n,p),E=ga(l,{replace:a,mask:o,state:s,target:c,preventScrollReset:u,relative:r,viewTransition:d,defaultShouldRevalidate:f,useTransitions:_});function D(t){e&&e(t),t.defaultPrevented||E(t)}let O=!(y.isExternal||i),k=Z.createElement(`a`,{...p,...T,href:(O?S:void 0)||y.absoluteURL||b,onClick:O?D:e,ref:aa(m,w),target:c,"data-discover":!v&&t===`render`?`true`:void 0});return C&&!v?Z.createElement(Z.Fragment,null,k,Z.createElement(ta,{page:b})):k});la.displayName=`Link`;var ua=Z.forwardRef(function({"aria-current":e=`page`,caseSensitive:t=!1,className:n=``,end:r=!1,style:i,to:a,viewTransition:o,children:s,...c},l){let u=qr(a,{relative:c.relative}),d=Vr(),f=Z.useContext(wr),{navigator:p,basename:m}=Z.useContext(Ar),h=f!=null&&Da(u)&&o===!0,g=p.encodeLocation?p.encodeLocation(u).pathname:u.pathname,_=d.pathname,v=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;t||(_=_.toLowerCase(),v=v?v.toLowerCase():null,g=g.toLowerCase()),v&&m&&(v=tr(v,m)||v);let y=g!==`/`&&g.endsWith(`/`)?g.length-1:g.length,b=_===g||!r&&_.startsWith(g)&&_.charAt(y)===`/`,x=v!=null&&(v===g||!r&&v.startsWith(g)&&v.charAt(g.length)===`/`),S={isActive:b,isPending:x,isTransitioning:h},C=b?e:void 0,w;w=typeof n==`function`?n(S):[n,b?`active`:null,x?`pending`:null,h?`transitioning`:null].filter(Boolean).join(` `);let T=typeof i==`function`?i(S):i;return Z.createElement(la,{...c,"aria-current":C,className:w,ref:l,style:T,to:a,viewTransition:o},typeof s==`function`?s(S):s)});ua.displayName=`NavLink`;var da=Z.forwardRef(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:a,method:o=bi,action:s,onSubmit:c,relative:l,preventScrollReset:u,viewTransition:d,defaultShouldRevalidate:f,...p},m)=>{let{useTransitions:h}=Z.useContext(Ar),g=ba(),_=xa(s,{relative:l}),v=o.toLowerCase()===`get`?`get`:`post`,y=typeof s==`string`&&yn.test(s);return Z.createElement(`form`,{ref:m,method:v,action:_,onSubmit:r?c:e=>{if(c&&c(e),e.defaultPrevented)return;e.preventDefault();let r=e.nativeEvent.submitter,s=r?.getAttribute(`formmethod`)||o,p=()=>g(r||e.currentTarget,{fetcherKey:t,method:s,navigate:n,replace:i,state:a,relative:l,preventScrollReset:u,viewTransition:d,defaultShouldRevalidate:f});h&&n!==!1?Z.startTransition(()=>p()):p()},...p,"data-discover":!y&&e===`render`?`true`:void 0})});da.displayName=`Form`;function fa({getKey:e,storageKey:t,...n}){let r=Z.useContext(Zi),{basename:i}=Z.useContext(Ar),a=Vr(),o=ui();Ta({getKey:e,storageKey:t});let s=Z.useMemo(()=>{if(!r||!e)return null;let t=wa(a,o,i,e);return t===a.key?null:t},[]);if(!r||r.isSpaMode)return null;let c=((e,t)=>{if(!window.history.state||!window.history.state.key){let e=Math.random().toString(32).slice(2);window.history.replaceState({key:e},``)}try{let n=JSON.parse(sessionStorage.getItem(e)||`{}`)[t||window.history.state.key];typeof n==`number`&&window.scrollTo(0,n)}catch(t){console.error(t),sessionStorage.removeItem(e)}}).toString();return n.nonce==null&&r?.nonce&&(n.nonce=r.nonce),Z.createElement(`script`,{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${c})(${Li(JSON.stringify(t||Sa))}, ${Li(JSON.stringify(s))})`}})}fa.displayName=`ScrollRestoration`;function pa(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ma(e){let t=Z.useContext(Cr);return Tn(t,pa(e)),t}function ha(e){let t=Z.useContext(wr);return Tn(t,pa(e)),t}function ga(e,{target:t,replace:n,mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,defaultShouldRevalidate:c,useTransitions:l}={}){let u=Wr(),d=Vr(),f=qr(e,{relative:o});return Z.useCallback(p=>{if(Di(p,t)){p.preventDefault();let t=n===void 0?An(d)===An(f):n,m=()=>u(e,{replace:t,mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,defaultShouldRevalidate:c});l?Z.startTransition(()=>m()):m()}},[d,u,f,n,r,i,t,e,a,o,s,c,l])}function _a(e){En(typeof URLSearchParams<`u`,"You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=Z.useRef(Oi(e)),n=Z.useRef(!1),r=Vr(),i=Z.useMemo(()=>ki(r.search,n.current?null:t.current),[r.search]),a=Wr();return[i,Z.useCallback((e,t)=>{let r=Oi(typeof e==`function`?e(new URLSearchParams(i)):e);n.current=!0,a(`?`+r,t)},[a,i])]}var va=0,ya=()=>`__${String(++va)}__`;function ba(){let{router:e}=ma(`useSubmit`),{basename:t}=Z.useContext(Ar),n=ci(),r=e.fetch,i=e.navigate;return Z.useCallback(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=Pi(e,t);a.navigate===!1?await r(a.fetcherKey||ya(),n,a.action||o,{defaultShouldRevalidate:a.defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,flushSync:a.flushSync}):await i(a.action||o,{defaultShouldRevalidate:a.defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[r,i,t,n])}function xa(e,{relative:t}={}){let{basename:n}=Z.useContext(Ar),r=Z.useContext(Mr);Tn(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...qr(e||`.`,{relative:t})},o=Vr();if(e==null){a.search=o.search;let e=new URLSearchParams(a.search),t=e.getAll(`index`);if(t.some(e=>e===``)){e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();a.search=n?`?${n}`:``}}return(!e||e===`.`)&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,`?index&`):`?index`),n!==`/`&&(a.pathname=a.pathname===`/`?n:lr([n,a.pathname])),An(a)}var Sa=`react-router-scroll-positions`,Ca={};function wa(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:tr(e.pathname,n)||e.pathname},t)),i??=e.key,i}function Ta({getKey:e,storageKey:t}={}){let{router:n}=ma(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=ha(`useScrollRestoration`),{basename:a}=Z.useContext(Ar),o=Vr(),s=ui(),c=li();Z.useEffect(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),Ea(Z.useCallback(()=>{if(c.state===`idle`){let t=wa(o,s,a,e);Ca[t]=window.scrollY}try{sessionStorage.setItem(t||Sa,JSON.stringify(Ca))}catch(e){En(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${e}).`)}window.history.scrollRestoration=`auto`},[c.state,e,a,o,s,t])),typeof document<`u`&&(Z.useLayoutEffect(()=>{try{let e=sessionStorage.getItem(t||Sa);e&&(Ca=JSON.parse(e))}catch{}},[t]),Z.useLayoutEffect(()=>{let t=n?.enableScrollRestoration(Ca,()=>window.scrollY,e?(t,n)=>wa(t,n,a,e):void 0);return()=>t&&t()},[n,a,e]),Z.useLayoutEffect(()=>{if(r!==!1){if(typeof r==`number`){window.scrollTo(0,r);return}try{if(o.hash){let e=document.getElementById(decodeURIComponent(o.hash.slice(1)));if(e){e.scrollIntoView();return}}}catch{En(!1,`"${o.hash.slice(1)}" is not a decodable element ID. The view will not scroll to it.`)}i!==!0&&window.scrollTo(0,0)}},[o,r,i]))}function Ea(e,t){let{capture:n}=t||{};Z.useEffect(()=>{let t=n==null?void 0:{capture:n};return window.addEventListener(`pagehide`,e,t),()=>{window.removeEventListener(`pagehide`,e,t)}},[e,n])}function Da(e,{relative:t}={}){let n=Z.useContext(Dr);Tn(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=ma(`useViewTransitionState`),i=qr(e,{relative:t});if(!n.isTransitioning)return!1;let a=tr(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=tr(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Zn(i.pathname,o)!=null||Zn(i.pathname,a)!=null}var Oa=Ue(),Q=ln(),ka=(0,Z.forwardRef)(({variant:e=`outlined`,...t},n)=>(0,Q.jsx)(u,{ref:n,variant:e,...t}));ka.displayName=`Tag`,u.CheckableTag;var Aa=Object.assign(ka,{CheckableTag:u.CheckableTag}),ja=`/ui/assets/cc-CYmbalCD.png`,Ma=`/ui/assets/claude-code-cli-D5DHHf2_.png`,Na=`/ui/assets/codex-4sLD1mVS.png`,Pa=`/ui/assets/copilot-CI1k0esO.png`,Fa=`/ui/assets/cursor-QEb7m-rN.png`,Ia=`/ui/assets/gemini-ajOb7iAl.png`,La=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAADWklEQVR4nGKRktJjGEyAaaAdgA5GHUQIjDqIEBh1ECEw6iBCYNRBhMCgcxALkeoc7C3zchK5ubnIsOP48bMNzf1EKmYkprYXEhI4enA9Hx/PxUvXDh859f//f+JdE+jvwcvLraXnTKR6okKoqCCVj4/n/v1HAUEpv37/Jt41/Hy8oSE+fRNmE6+FcBpSU1WKjQ5mYGC4fPUmSa5hYGCoqy188eLV/IWriNdCOIQa6gpZWJhJcgcE2NmaBwW4e/jE/f37j2oOcnW2tbezwCrFz8+XEB8qyM+HS6+Pj8uPHz8jw/0YYEnu379/O3YdOHX6IvkOqq7MxSU1a3q7srLC2nXbfvz4iVXB0mXr0UT0dDWXLJxkYOLx7dt3chzEwcGuqqqIVSrA393czNDVI+r2nQd4TEADQoL8ly/sERTgx+MgfImakZERqzg3N2dNVd6yFRtJcg0DAwMxiYmEklpIkB/CyMtJ4uPlmTBxDkmuIRIQW1IzMDBYWZqkpURdvnIjLSX6zNmLIiJCIiJCBHX9Z2C4d+/hz5+/iLQFX0nNyclx58ZhZJF/IPD/P8P////+MzD8hwEoC5chp05fCA5Lh5ST1y7vM7P0ffrsBS5LiQ2hHz9+5hfVb9+xn6RChYGBYeWyaSRVNfgchJyoG5r6tmzdS5JTGBgYHB0sLcwN3b1iiNdCVKJet3774qXrSHUNGxtrU33xvAUrb9y8CxFhZmYCpyp8AYYvhP7+/csADu2qmk40KStLYxNj/M0ERhtrUyUlee0Xr/NyEiFChgY6//79//zpC5kO+vnz17adB7w8HPfsXP7l61dkKSVFudNnLl2/cRuP9us3bkMUCAsLMjAw8HBzu7nYXrl26/OXr/j8gb89xMjIaKCvxcrKiizY1lz29dv3oNBUkhK4sLDg2ZPbCoobNmzciUcZgVz2////8xeuIosE+LvLykq5ekaTmt0a6grPX7iC3zWkFYwMDAwiwoItjSWNzRMePXpKkkZrKxN/P3dv3ziCKklzUFFh2rdvP46fPKugIEu8LilJ8e6O6tWrt1y+cpPKDrp+/ba7q926VbNI0vXnz9+jx07XNfYSo5ioRj49waDrl406iBAYdRAhMOogQmDUQYTAqIMIgUHnIEAAAAD//xjiMCmHkZcfAAAAAElFTkSuQmCC`,{useToken:Ra}=X,za={"claude-code":ja,"claude-code-cli":Ma,codex:Na,gemini:Ia,opencode:La,copilot:Pa,cursor:Fa},Ba=new Set([`claude-code-cli`]),Va=({tool:e,size:t=32,className:n=``})=>{let{token:r}=Ra(),i=za[e],a=Ba.has(e)?`#fff`:`#000`;return i?(0,Q.jsx)(`div`,{className:`tool-icon ${n}`,style:{width:t,height:t,borderRadius:`50%`,background:a,border:`1px solid ${r.colorBorder}`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:t*.1,flexShrink:0,overflow:`hidden`},children:(0,Q.jsx)(`img`,{src:i,alt:`${e} logo`,style:{width:`100%`,height:`100%`,objectFit:`contain`}})}):(0,Q.jsx)(`div`,{className:`tool-icon ${n}`,style:{width:t,height:t,borderRadius:`50%`,background:a,border:`1px solid ${r.colorBorder}`,display:`flex`,alignItems:`center`,justifyContent:`center`,fontSize:t*.6,flexShrink:0},children:{"claude-code":`🤖`,codex:`💻`,gemini:`💎`,opencode:`🌐`,copilot:`✈️`,cursor:`⌘`}[e]||`🤖`})},Ha=({agent:e,selected:t=!1,onClick:n})=>(0,Q.jsx)(g,{hoverable:!0,onClick:n,style:{borderColor:t?`#1890ff`:void 0,borderWidth:t?2:1,cursor:`pointer`},styles:{body:{padding:12}},children:(0,Q.jsxs)(G,{orientation:`vertical`,style:{width:`100%`},size:4,children:[(0,Q.jsx)(G,{style:{width:`100%`,justifyContent:`space-between`},size:8,children:(0,Q.jsxs)(G,{size:8,children:[(0,Q.jsx)(Va,{tool:e.id,size:24}),(0,Q.jsx)(v.Text,{strong:!0,style:{fontSize:`14px`},children:e.name}),e.beta&&(0,Q.jsx)(Aa,{color:`warning`,children:`BETA`})]})}),e.version&&(0,Q.jsxs)(v.Text,{type:`secondary`,style:{fontSize:`11px`},children:[`Version: `,e.version]}),e.description&&(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:`12px`},children:e.description})]})}),{Text:Ua}=v,Wa=({agents:e,selectedAgentId:t,onSelect:n,variant:r=`cards`,columns:i=3,showHelperText:a=!1,helperText:o=`Click on an agent card to select it`,showComparisonLink:s=!1})=>r===`select`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(l,{value:t??void 0,onChange:e=>n(e),style:{width:`100%`},options:e.map(e=>({value:e.id,label:(0,Q.jsxs)(G,{size:8,children:[(0,Q.jsx)(Va,{tool:e.id,size:16}),(0,Q.jsx)(`span`,{children:e.name}),e.beta&&(0,Q.jsx)(Aa,{color:`warning`,children:`BETA`})]})}))}),s&&(0,Q.jsx)(Ga,{})]}):(0,Q.jsxs)(Q.Fragment,{children:[a&&!t&&(0,Q.jsx)(Ua,{type:`secondary`,style:{fontSize:12,marginBottom:8,display:`block`},children:o}),(0,Q.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(${i}, 1fr)`,gap:8,marginTop:8},children:e.map(e=>(0,Q.jsx)(Ha,{agent:e,selected:t===e.id,onClick:()=>n(e.id)},e.id))}),s&&(0,Q.jsx)(Ga,{})]}),Ga=()=>(0,Q.jsxs)(Ua,{type:`secondary`,style:{fontSize:11,marginTop:8,display:`block`,textAlign:`center`},children:[`Compare features:`,` `,(0,Q.jsx)(`a`,{href:`https://agor.live/guide/sdk-comparison`,target:`_blank`,rel:`noopener noreferrer`,children:`SDK Comparison Guide`})]}),Ka=[{id:`claude-code`,name:`Claude Code`,icon:`🤖`,description:`Anthropic Claude coding agent`},{id:`codex`,name:`Codex`,icon:`💻`,description:`OpenAI Codex coding agent`},{id:`gemini`,name:`Gemini`,icon:`💎`,description:`Google Gemini coding agent`},{id:`opencode`,name:`OpenCode`,icon:`🌐`,description:`Open-source terminal AI with 75+ LLM providers`,beta:!0},{id:`cursor`,name:`Cursor SDK`,icon:`⌘`,description:`Cursor agentic runtime via the Cursor SDK`,beta:!0},{id:`copilot`,name:`GitHub Copilot`,icon:`✈️`,description:`GitHub Copilot agentic runtime`,beta:!0},{id:`claude-code-cli`,name:`Claude Code CLI`,icon:`🤖`,description:`Anthropic Claude CLI, billed to your Pro/Max subscription`,beta:!0}],qa={buildSha:null,userEmail:null};function Ja(e){qa={...qa,...e}}function Ya(){return qa}async function Xa(e){if(globalThis.isSecureContext===!1&&Za(e))return!0;if(navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(e),!0}catch{}return Za(e)}function Za(e){let t;try{if(t=document.createElement(`textarea`),t.value=e,t.style.position=`fixed`,t.style.left=`-999999px`,t.style.top=`-999999px`,document.body.appendChild(t),t.focus(),t.select(),document.execCommand(`copy`))return!0}catch(e){console.error(`Failed to copy to clipboard:`,e)}finally{t?.remove()}return!1}function Qa(e=2e3){let[t,n]=Z.useState(!1),r=Z.useRef(null);return Z.useEffect(()=>()=>{r.current&&clearTimeout(r.current)},[]),[t,async t=>{r.current&&clearTimeout(r.current);let i=await Xa(t);return i&&(n(!0),r.current=setTimeout(()=>{n(!1)},e)),i}]}var $a=`https://github.com/preset-io/agor/issues/new`,eo=4e3;function to(e){return e?e.match(/in\s+([A-Za-z0-9_$.]+)/)?.[1]??`unknown component`:`unknown component`}function no(e,t,n={}){let{buildSha:r,userEmail:i}=Ya(),a=(n.now??new Date).toISOString(),o=n.href??(typeof window<`u`?window.location.href:`unknown`),s=n.userAgent??(typeof navigator<`u`?navigator.userAgent:`unknown`),c=to(t?.componentStack);return[`## UI crash report`,``,`- **When:** ${a}`,`- **Where:** ${o}`,`- **Component:** ${c}`,`- **User:** ${i??`(not signed in)`}`,`- **Build:** ${r??`unknown`}`,`- **Browser:** ${s}`,`- **Error:** ${e.message||String(e)}`,``,`### Component stack`,"```",(t?.componentStack??`(unavailable)`).trim(),"```",``,`### Error stack`,"```",(e.stack??`(unavailable)`).trim(),"```",``].join(`
6
- `)}function ro(e,t,n={}){let r=`UI crash: ${to(t?.componentStack)} — ${e.message?.slice(0,80)??`unknown error`}`,i=no(e,t,n);return i.length>4e3&&(i=`${i.slice(0,eo)}\n\n_(truncated — see full report copied to clipboard)_`),`${$a}?${new URLSearchParams({title:r,body:i,labels:`bug`}).toString()}`}var{Title:io,Paragraph:ao,Text:oo}=v;function so({error:e,errorInfo:t}){let{token:n}=X.useToken(),[i,a]=(0,Z.useState)(!1),o=async()=>{await Xa(no(e,t))&&(a(!0),setTimeout(()=>a(!1),2e3))},c=()=>{window.location.reload()},l=ro(e,t),u=to(t?.componentStack);return(0,Q.jsx)(`div`,{style:{minHeight:`100vh`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`2rem`,backgroundColor:n.colorBgLayout},children:(0,Q.jsxs)(g,{style:{maxWidth:640,width:`100%`,textAlign:`center`},styles:{body:{padding:`2.5rem 2rem`}},children:[(0,Q.jsx)(Qe,{style:{fontSize:96,color:n.colorTextTertiary,marginBottom:n.marginLG}}),(0,Q.jsx)(io,{level:2,style:{marginTop:0,marginBottom:n.marginXS},children:`Well, that wasn't supposed to happen.`}),(0,Q.jsx)(ao,{style:{color:n.colorTextSecondary,marginBottom:n.marginLG},children:`The UI hit an unexpected error and couldn't finish rendering. Reloading usually gets you going again. If it keeps happening, the report below will help us fix it.`}),(0,Q.jsxs)(G,{wrap:!0,style:{justifyContent:`center`,marginBottom:n.marginLG},children:[(0,Q.jsx)(s,{icon:(0,Q.jsx)(E,{}),onClick:o,children:i?`Copied!`:`Copy error details`}),(0,Q.jsx)(s,{icon:(0,Q.jsx)(r,{}),href:l,target:`_blank`,rel:`noopener noreferrer`,children:`Report on GitHub`}),(0,Q.jsx)(s,{type:`primary`,icon:(0,Q.jsx)(he,{}),onClick:c,children:`Reload page`})]}),(0,Q.jsx)(A,{ghost:!0,items:[{key:`details`,label:(0,Q.jsx)(oo,{type:`secondary`,children:`Show technical details`}),children:(0,Q.jsxs)(`div`,{style:{textAlign:`left`},children:[(0,Q.jsxs)(ao,{style:{marginBottom:n.marginSM},children:[(0,Q.jsx)(oo,{strong:!0,children:`Component:`}),` `,(0,Q.jsx)(oo,{code:!0,children:u}),(0,Q.jsx)(`br`,{}),(0,Q.jsx)(oo,{strong:!0,children:`Error:`}),` `,(0,Q.jsx)(oo,{code:!0,children:e.message||String(e)})]}),(0,Q.jsx)(`pre`,{style:{maxHeight:240,overflow:`auto`,fontSize:12,padding:n.paddingSM,backgroundColor:n.colorBgContainerDisabled,borderRadius:n.borderRadiusSM,margin:0},children:(t?.componentStack??e.stack??`(no stack available)`).trim()})]})}]})]})})}var co=class extends Z.Component{state={error:null,errorInfo:null,resetKey:this.props.resetKey};static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return e.resetKey===t.resetKey?null:{error:null,errorInfo:null,resetKey:e.resetKey}}componentDidCatch(e,t){console.error(`ErrorBoundary caught render error:`,e,t.componentStack),this.setState({errorInfo:t})}render(){let{error:e,errorInfo:t}=this.state,{variant:n=`scoped`,fallbackTitle:r,children:i}=this.props;return e?n===`global`?(0,Q.jsx)(so,{error:e,errorInfo:t}):(0,Q.jsx)(z,{type:`error`,showIcon:!0,title:r??`Something went wrong rendering this view.`,description:e.message||String(e)}):i}},{Text:lo}=v;function uo({open:e,user:t,onChangePassword:n,onLogout:r}){let[i]=Y.useForm(),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(null),{token:u}=X.useToken();return(0,Q.jsxs)(a,{title:(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(Ve,{style:{color:u.colorWarning,marginRight:8}}),`Password Change Required`]}),open:e,onOk:async()=>{if(t)try{let e=await i.validateFields();s(!0),l(null),await n(t.user_id,e.newPassword),i.resetFields()}catch(e){e instanceof Error&&l(e.message)}finally{s(!1)}},okText:`Change Password`,cancelText:`Logout`,onCancel:r,confirmLoading:o,closable:!1,mask:{closable:!1},keyboard:!1,width:400,children:[(0,Q.jsx)(z,{type:`warning`,title:`Your administrator requires you to change your password before continuing.`,style:{marginBottom:24},showIcon:!0}),c&&(0,Q.jsx)(z,{type:`error`,title:c,style:{marginBottom:16},showIcon:!0,closable:!0,onClose:()=>l(null)}),(0,Q.jsxs)(Y,{form:i,layout:`vertical`,children:[(0,Q.jsx)(Y.Item,{name:`newPassword`,label:`New Password`,rules:[{required:!0,message:`Please enter a new password`},{min:8,message:`Password must be at least 8 characters`}],children:(0,Q.jsx)(J.Password,{prefix:(0,Q.jsx)(S,{style:{color:u.colorTextQuaternary}}),placeholder:`Enter new password`,autoComplete:`new-password`})}),(0,Q.jsx)(Y.Item,{name:`confirmPassword`,label:`Confirm Password`,dependencies:[`newPassword`],rules:[{required:!0,message:`Please confirm your password`},({getFieldValue:e})=>({validator(t,n){return!n||e(`newPassword`)===n?Promise.resolve():Promise.reject(Error(`Passwords do not match`))}})],children:(0,Q.jsx)(J.Password,{prefix:(0,Q.jsx)(S,{style:{color:u.colorTextQuaternary}}),placeholder:`Confirm new password`,autoComplete:`new-password`})})]}),(0,Q.jsx)(lo,{type:`secondary`,style:{fontSize:12},children:`After changing your password, you will be able to continue using the application.`})]})}var fo=new Set([`sessions`,`branches`,`boards`,`repos`,`users`]);function po({phase:e=`loading`,connecting:t=!1,loadingStage:n=`fetching`,items:r=[],message:i}){let{token:a}=X.useToken(),[o,c]=(0,Z.useState)(!1),l=i??(t?`Connecting to daemon…`:n===`indexing`?`Indexing workspace data…`:`Loading workspace data…`),u=!t&&r.length>0,d=r.filter(e=>fo.has(e.key)),f=r.filter(e=>!fo.has(e.key)),p=f.filter(e=>e.done).length,m=f.length-p,h=m>0?`Show details (${m} pending)`:`Show details (${p}/${f.length} loaded)`,g=({key:e,label:t,done:n,count:r})=>(0,Q.jsxs)(et,{align:`center`,justify:`space-between`,gap:a.sizeSM,children:[(0,Q.jsxs)(et,{align:`center`,gap:a.sizeSM,children:[(0,Q.jsx)(et,{align:`center`,justify:`center`,style:{width:a.sizeMD},children:n?(0,Q.jsx)(Te,{style:{color:a.colorSuccess}}):(0,Q.jsx)(Ze,{size:`small`})}),(0,Q.jsx)(v.Text,{type:n?`secondary`:void 0,disabled:!n,children:t})]}),(0,Q.jsx)(Aa,{color:n?`success`:void 0,variant:`filled`,style:{marginInlineEnd:0,minWidth:28,textAlign:`center`},children:r})]},e);return(0,Q.jsxs)(et,{vertical:!0,align:`center`,justify:`center`,style:{minHeight:`100vh`,backgroundColor:a.colorBgLayout,opacity:e===`fading`?0:1,transition:`opacity 280ms ease-out`},children:[(0,Q.jsx)(Ze,{size:`large`}),(0,Q.jsx)(v.Text,{type:`secondary`,style:{marginTop:a.marginMD},children:l}),u&&(0,Q.jsxs)(et,{vertical:!0,gap:a.sizeXXS,style:{marginTop:a.marginLG,minWidth:200},children:[d.map(g),f.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(s,{type:`link`,size:`small`,onClick:()=>c(e=>!e),style:{alignSelf:`center`,paddingInline:0},children:o?`Hide details`:h}),o&&f.map(g)]})]})]})}var mo={name:`Agor`,markFile:`favicon.png`,titleSeparator:` · `};function ho(e=`/ui/`){return`${e}${mo.markFile}`}function go(e){return e?`${e}${mo.titleSeparator}${mo.name}`:mo.name}var _o={1:`43px`,2:`34px`,3:`27px`,4:`23px`,5:`18px`},vo=({level:e=3,style:t,className:n})=>(0,Q.jsx)(`h1`,{className:n,style:{margin:0,fontSize:_o[e],lineHeight:1.35,background:`linear-gradient(90deg, #2e9a92 0%, #7fe8df 50%, #a8f5ed 100%)`,WebkitBackgroundClip:`text`,WebkitTextFillColor:`transparent`,backgroundClip:`text`,fontWeight:700,width:`fit-content`,...t},children:`agor`}),yo={background:{color:{value:`transparent`}},fpsLimit:60,interactivity:{events:{onHover:{enable:!0,mode:`attract`},resize:{enable:!0}},modes:{attract:{distance:200,duration:.4,speed:3}}},particles:{color:{value:`#2e9a92`},links:{color:`#2e9a92`,distance:150,enable:!0,opacity:.2,width:1},move:{direction:`none`,enable:!0,outModes:{default:`bounce`},random:!1,speed:1,straight:!1},number:{density:{enable:!0,width:1920,height:1080},value:150},opacity:{value:.4},shape:{type:`circle`},size:{value:{min:1,max:3}}},detectRetina:!0},bo=t({ParticleBackground:()=>xo}),xo=(0,Z.memo)(function(){let e=(0,Z.useId)(),[t,n]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{un(async e=>{await fn(e)}).then(()=>{n(!0)})},[]),t?(0,Q.jsx)(dn,{id:e,particlesLoaded:async e=>{},options:yo,style:{position:`absolute`,width:`100%`,height:`100%`,top:0,left:0,zIndex:0}}):null}),{Text:So}=v;function Co(){return typeof window>`u`?null:`${window.location.pathname.startsWith(`//`)?`/`:window.location.pathname}${window.location.search}${window.location.hash}`}function wo(e){let t=Co();if(!t)return e;try{let n=new URL(e);return n.searchParams.set(`return_to`,t),n.toString()}catch{return e}}function To({onLogin:e,loading:t=!1,error:n,externalLaunchLoginRedirectUrl:r}){let[i]=Y.useForm(),[a,o]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),{token:u}=X.useToken(),d=!!r,p=r?wo(r):void 0,m=!d||c,h=n?.startsWith(`Launch sign-in failed`)??!1;return(0,Q.jsxs)(`div`,{style:{minHeight:`100dvh`,width:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`,background:`linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 50%, #0f1f1e 100%)`,padding:`16px`,position:`relative`,overflow:`auto`},children:[(0,Q.jsx)(xo,{}),(0,Q.jsx)(`a`,{href:`https://particles.js.org`,target:`_blank`,rel:`noopener noreferrer`,style:{position:`fixed`,bottom:16,right:16,fontSize:10,color:`rgba(46, 154, 146, 0.3)`,textDecoration:`none`,zIndex:0,transition:`color 0.3s`},onMouseEnter:e=>{e.currentTarget.style.color=`rgba(46, 154, 146, 0.6)`},onMouseLeave:e=>{e.currentTarget.style.color=`rgba(46, 154, 146, 0.3)`},children:`🤍 tsparticles`}),(0,Q.jsxs)(g,{style:{width:`100%`,maxWidth:420,borderRadius:12,boxShadow:`0 8px 32px rgba(0, 0, 0, 0.4)`,position:`relative`,zIndex:1,margin:`auto`},variant:`borderless`,children:[(0,Q.jsx)(G,{orientation:`vertical`,size:`large`,style:{width:`100%`,marginBottom:24},children:(0,Q.jsxs)(`div`,{style:{textAlign:`center`},children:[(0,Q.jsx)(`img`,{src:ho(),alt:mo.name,style:{width:72,height:72,marginBottom:16,objectFit:`cover`,borderRadius:`50%`,display:`block`,margin:`0 auto 16px`}}),(0,Q.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,marginBottom:12},children:(0,Q.jsx)(vo,{level:1})}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(So,{type:`secondary`,children:`Team command center for all things agentic`})}),(0,Q.jsx)(f,{style:{margin:`16px 0 0 0`}})]})}),n&&(0,Q.jsx)(z,{type:`error`,title:h?`Launch sign-in failed`:`Login Failed`,description:n,showIcon:!0,closable:!0,style:{marginBottom:24}}),d&&(0,Q.jsxs)(G,{orientation:`vertical`,size:`middle`,style:{width:`100%`,marginBottom:24},children:[!n&&(0,Q.jsx)(z,{type:`info`,title:`Open from your workspace`,description:`This runtime is configured for external launch sign-in. Return to your workspace to open a fresh launch link.`,showIcon:!0}),(0,Q.jsx)(s,{type:`primary`,href:p,block:!0,"data-testid":`external-launch-return`,children:`Return to workspace`}),!c&&(0,Q.jsx)(s,{type:`link`,block:!0,onClick:()=>l(!0),children:`Use local login instead`})]}),m&&(0,Q.jsxs)(Q.Fragment,{children:[d&&(0,Q.jsx)(f,{style:{margin:`0 0 24px 0`},children:`Local login`}),(0,Q.jsxs)(Y,{form:i,name:`login`,layout:`vertical`,onFinish:async t=>{o(!0);try{await e(t.email,t.password)}finally{o(!1)}},autoComplete:`off`,children:[(0,Q.jsx)(Y.Item,{name:`email`,rules:[{required:!0,message:`Please enter your email`},{type:`email`,message:`Please enter a valid email`}],children:(0,Q.jsx)(J,{prefix:(0,Q.jsx)(dt,{style:{color:u.colorTextQuaternary}}),placeholder:`Email address`,autoComplete:`email`})}),(0,Q.jsx)(Y.Item,{name:`password`,rules:[{required:!0,message:`Please enter your password`}],children:(0,Q.jsx)(J.Password,{prefix:(0,Q.jsx)(S,{style:{color:u.colorTextQuaternary}}),placeholder:`Password`,autoComplete:`current-password`})}),(0,Q.jsx)(Y.Item,{style:{marginBottom:8},children:(0,Q.jsx)(s,{type:`primary`,htmlType:`submit`,loading:a||t,block:!0,children:`Sign In`})})]})]})]})]})}var Eo=`preset-io/agor-assistant`,Do=`https://github.com/preset-io/agor-assistant.git`;function Oo(e){let t,n;for(let r of e){if(r.slug?.includes(`agor-assistant-private`)||r.remote_url?.includes(`agor-assistant-private`))return r;!t&&r.slug===`preset-io/agor-assistant`&&(t=r),!n&&(r.remote_url?.includes(`agor-assistant`)||r.remote_url?.includes(`agor-openclaw`))&&(n=r)}return t||n}function ko(e){return(0,Z.useMemo)(()=>Oo(e),[e])}function Ao(e,t){let n=[],r=new Map;for(let i of e){let e=i[1];t?.readyOnly&&e.clone_status!==`ready`&&e.clone_status!==void 0||t?.excludeFailed&&e.clone_status===`failed`||(n.push(e),r.set(e.repo_id,i))}let i=Oo(n);if(i)return r.get(i.repo_id)}var jo=Symbol.for(`immer-nothing`),Mo=Symbol.for(`immer-draftable`),No=Symbol.for(`immer-state`);function Po(e,...t){throw Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Fo=Object,Io=Fo.getPrototypeOf,Lo=`constructor`,Ro=`prototype`,zo=`configurable`,Bo=`enumerable`,Vo=`writable`,Ho=`value`,Uo=e=>!!e&&!!e[No];function Wo(e){return e?qo(e)||es(e)||!!e[Mo]||!!e[Lo]?.[Mo]||ts(e)||ns(e):!1}var Go=Fo[Ro][Lo].toString(),Ko=new WeakMap;function qo(e){if(!e||!rs(e))return!1;let t=Io(e);if(t===null||t===Fo[Ro])return!0;let n=Fo.hasOwnProperty.call(t,Lo)&&t[Lo];if(n===Object)return!0;if(!is(n))return!1;let r=Ko.get(n);return r===void 0&&(r=Function.toString.call(n),Ko.set(n,r)),r===Go}function Jo(e,t,n=!0){Yo(e)===0?(n?Reflect.ownKeys(e):Fo.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function Yo(e){let t=e[No];return t?t.type_:es(e)?1:ts(e)?2:ns(e)?3:0}var Xo=(e,t,n=Yo(e))=>n===2?e.has(t):Fo[Ro].hasOwnProperty.call(e,t),Zo=(e,t,n=Yo(e))=>n===2?e.get(t):e[t],Qo=(e,t,n,r=Yo(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function $o(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}var es=Array.isArray,ts=e=>e instanceof Map,ns=e=>e instanceof Set,rs=e=>typeof e==`object`,is=e=>typeof e==`function`,as=e=>typeof e==`boolean`;function os(e){let t=+e;return Number.isInteger(t)&&String(t)===e}var ss=e=>rs(e)?e?.[No]:null,cs=e=>e.copy_||e.base_,ls=e=>{let t=ss(e);return t?t.copy_??t.base_:e},us=e=>e.modified_?e.copy_:e.base_;function ds(e,t){if(ts(e))return new Map(e);if(ns(e))return new Set(e);if(es(e))return Array[Ro].slice.call(e);let n=qo(e);if(t===!0||t===`class_only`&&!n){let t=Fo.getOwnPropertyDescriptors(e);delete t[No];let n=Reflect.ownKeys(t);for(let r=0;r<n.length;r++){let i=n[r],a=t[i];a[Vo]===!1&&(a[Vo]=!0,a[zo]=!0),(a.get||a.set)&&(t[i]={[zo]:!0,[Vo]:!0,[Bo]:a[Bo],[Ho]:e[i]})}return Fo.create(Io(e),t)}else{let t=Io(e);if(t!==null&&n)return{...e};let r=Fo.create(t);return Fo.assign(r,e)}}function fs(e,t=!1){return hs(e)||Uo(e)||!Wo(e)?e:(Yo(e)>1&&Fo.defineProperties(e,{set:ms,add:ms,clear:ms,delete:ms}),Fo.freeze(e),t&&Jo(e,(e,t)=>{fs(t,!0)},!1),e)}function ps(){Po(2)}var ms={[Ho]:ps};function hs(e){return e===null||!rs(e)?!0:Fo.isFrozen(e)}var gs=`MapSet`,_s=`Patches`,vs=`ArrayMethods`,ys={};function bs(e){let t=ys[e];return t||Po(0,e),t}var xs=e=>!!ys[e];function Ss(e,t){ys[e]||(ys[e]=t)}var Cs,ws=()=>Cs,Ts=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:xs(gs)?bs(gs):void 0,arrayMethodsPlugin_:xs(vs)?bs(vs):void 0});function Es(e,t){t&&(e.patchPlugin_=bs(_s),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Ds(e){Os(e),e.drafts_.forEach(As),e.drafts_=null}function Os(e){e===Cs&&(Cs=e.parent_)}var ks=e=>Cs=Ts(Cs,e);function As(e){let t=e[No];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function js(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];if(e!==void 0&&e!==n){n[No].modified_&&(Ds(t),Po(4)),Wo(e)&&(e=Ms(t,e));let{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(n[No].base_,e,t)}else e=Ms(t,n);return Ns(t,e,!0),Ds(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e===jo?void 0:e}function Ms(e,t){if(hs(t))return t;let n=t[No];if(!n)return Vs(t,e.handledSet_,e);if(!Fs(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){let{callbacks_:t}=n;if(t)for(;t.length>0;)t.pop()(e);zs(n,e)}return n.copy_}function Ns(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&fs(t,n)}function Ps(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Fs=(e,t)=>e.scope_===t,Is=[];function Ls(e,t,n,r){let i=cs(e),a=e.type_;if(r!==void 0&&Zo(i,r,a)===t){Qo(i,r,n,a);return}if(!e.draftLocations_){let t=e.draftLocations_=new Map;Jo(i,(e,n)=>{if(Uo(n)){let r=t.get(n)||[];r.push(e),t.set(n,r)}})}let o=e.draftLocations_.get(t)??Is;for(let e of o)Qo(i,e,n,a)}function Rs(e,t,n){e.callbacks_.push(function(r){let i=t;if(!i||!Fs(i,r))return;r.mapSetPlugin_?.fixSetContents(i);let a=us(i);Ls(e,i.draft_??i,a,n),zs(i,r)})}function zs(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){let{patchPlugin_:n}=t;if(n){let r=n.getPath(e);r&&n.generatePatches_(e,r,t)}Ps(e)}}function Bs(e,t,n){let{scope_:r}=e;if(Uo(n)){let i=n[No];Fs(i,r)&&i.callbacks_.push(function(){Ys(e),Ls(e,n,us(i),t)})}else Wo(n)&&e.callbacks_.push(function(){let i=cs(e);e.type_===3?i.has(n)&&Vs(n,r.handledSet_,r):Zo(i,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&Vs(Zo(e.copy_,t,e.type_),r.handledSet_,r)})}function Vs(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Uo(e)||t.has(e)||!Wo(e)||hs(e)?e:(t.add(e),Jo(e,(r,i)=>{if(Uo(i)){let t=i[No];Fs(t,n)&&(Qo(e,r,us(t),e.type_),Ps(t))}else Wo(i)&&Vs(i,t,n)}),e)}function Hs(e,t){let n=es(e),r={type_:+!!n,scope_:t?t.scope_:ws(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0},i=r,a=Us;n&&(i=[r],a=Ws);let{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var Us={get(e,t){if(t===No)return e;let n=e.scope_.arrayMethodsPlugin_,r=e.type_===1&&typeof t==`string`;if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);let i=cs(e);if(!Xo(i,t,e.type_))return Ks(e,i,t);let a=i[t];if(e.finalized_||!Wo(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&os(t))return a;if(a===Gs(e.base_,t)){Ys(e);let n=e.type_===1?+t:t,r=Zs(e.scope_,a,e,n);return e.copy_[n]=r}return a},has(e,t){return t in cs(e)},ownKeys(e){return Reflect.ownKeys(cs(e))},set(e,t,n){let r=qs(cs(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let r=Gs(cs(e),t),i=r?.[No];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if($o(n,r)&&(n!==void 0||Xo(e.base_,t,e.type_)))return!0;Ys(e),Js(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])?!0:(e.copy_[t]=n,e.assigned_.set(t,!0),Bs(e,t,n),!0)},deleteProperty(e,t){return Ys(e),Gs(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),Js(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=cs(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[Vo]:!0,[zo]:e.type_!==1||t!==`length`,[Bo]:r[Bo],[Ho]:n[t]}},defineProperty(){Po(11)},getPrototypeOf(e){return Io(e.base_)},setPrototypeOf(){Po(12)}},Ws={};for(let e in Us){let t=Us[e];Ws[e]=function(){let e=arguments;return e[0]=e[0][0],t.apply(this,e)}}Ws.deleteProperty=function(e,t){return Ws.set.call(this,e,t,void 0)},Ws.set=function(e,t,n){return Us.set.call(this,e[0],t,n,e[0])};function Gs(e,t){let n=e[No];return(n?cs(n):e)[t]}function Ks(e,t,n){let r=qs(t,n);return r?Ho in r?r[Ho]:r.get?.call(e.draft_):void 0}function qs(e,t){if(!(t in e))return;let n=Io(e);for(;n;){let e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Io(n)}}function Js(e){e.modified_||(e.modified_=!0,e.parent_&&Js(e.parent_))}function Ys(e){e.copy_||=(e.assigned_=new Map,ds(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Xs=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,n)=>{if(is(e)&&!is(t)){let n=t;t=e;let r=this;return function(e=n,...i){return r.produce(e,e=>t.call(this,e,...i))}}is(t)||Po(6),n!==void 0&&!is(n)&&Po(7);let r;if(Wo(e)){let i=ks(this),a=Zs(i,e,void 0),o=!0;try{r=t(a),o=!1}finally{o?Ds(i):Os(i)}return Es(i,n),js(r,i)}else if(!e||!rs(e)){if(r=t(e),r===void 0&&(r=e),r===jo&&(r=void 0),this.autoFreeze_&&fs(r,!0),n){let t=[],i=[];bs(_s).generateReplacementPatches_(e,r,{patches_:t,inversePatches_:i}),n(t,i)}return r}else Po(1,e)},this.produceWithPatches=(e,t)=>{if(is(e))return(t,...n)=>this.produceWithPatches(t,t=>e(t,...n));let n,r;return[this.produce(e,t,(e,t)=>{n=e,r=t}),n,r]},as(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),as(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),as(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Wo(e)||Po(8),Uo(e)&&(e=Qs(e));let t=ks(this),n=Zs(t,e,void 0);return n[No].isManual_=!0,Os(t),n}finishDraft(e,t){let n=e&&e[No];(!n||!n.isManual_)&&Po(9);let{scope_:r}=n;return Es(r,t),js(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){let r=t[n];if(r.path.length===0&&r.op===`replace`){e=r.value;break}}n>-1&&(t=t.slice(n+1));let r=bs(_s).applyPatches_;return Uo(e)?r(e,t):this.produce(e,e=>r(e,t))}};function Zs(e,t,n,r){let[i,a]=ts(t)?bs(gs).proxyMap_(t,n):ns(t)?bs(gs).proxySet_(t,n):Hs(t,n);return(n?.scope_??ws()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?Rs(n,a,r):a.callbacks_.push(function(e){e.mapSetPlugin_?.fixSetContents(a);let{patchPlugin_:t}=e;a.modified_&&t&&t.generatePatches_(a,[],e)}),i}function Qs(e){return Uo(e)||Po(10,e),$s(e)}function $s(e){if(!Wo(e)||hs(e))return e;let t=e[No],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=ds(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=ds(e,!0);return Jo(n,(e,t)=>{Qo(n,e,$s(t))},r),t&&(t.finalized_=!1),n}function ec(){class e extends Map{constructor(e,t){super(),this[No]={type_:2,parent_:t,scope_:t?t.scope_:ws(),modified_:!1,finalized_:!1,copy_:void 0,assigned_:void 0,base_:e,draft_:this,isManual_:!1,revoked_:!1,callbacks_:[]}}get size(){return cs(this[No]).size}has(e){return cs(this[No]).has(e)}set(e,t){let r=this[No];return o(r),(!cs(r).has(e)||cs(r).get(e)!==t)&&(n(r),Js(r),r.assigned_.set(e,!0),r.copy_.set(e,t),r.assigned_.set(e,!0),Bs(r,e,t)),this}delete(e){if(!this.has(e))return!1;let t=this[No];return o(t),n(t),Js(t),t.base_.has(e)?t.assigned_.set(e,!1):t.assigned_.delete(e),t.copy_.delete(e),!0}clear(){let e=this[No];o(e),cs(e).size&&(n(e),Js(e),e.assigned_=new Map,Jo(e.base_,t=>{e.assigned_.set(t,!1)}),e.copy_.clear())}forEach(e,t){let n=this[No];cs(n).forEach((n,r,i)=>{e.call(t,this.get(r),r,this)})}get(e){let t=this[No];o(t);let r=cs(t).get(e);if(t.finalized_||!Wo(r)||r!==t.base_.get(e))return r;let i=Zs(t.scope_,r,t,e);return n(t),t.copy_.set(e,i),i}keys(){return cs(this[No]).keys()}values(){let e=this.keys();return{[Symbol.iterator]:()=>this.values(),next:()=>{let t=e.next();return t.done?t:{done:!1,value:this.get(t.value)}}}}entries(){let e=this.keys();return{[Symbol.iterator]:()=>this.entries(),next:()=>{let t=e.next();if(t.done)return t;let n=this.get(t.value);return{done:!1,value:[t.value,n]}}}}[Symbol.iterator](){return this.entries()}}function t(t,n){let r=new e(t,n);return[r,r[No]]}function n(e){e.copy_||=(e.assigned_=new Map,new Map(e.base_))}class r extends Set{constructor(e,t){super(),this[No]={type_:3,parent_:t,scope_:t?t.scope_:ws(),modified_:!1,finalized_:!1,copy_:void 0,base_:e,draft_:this,drafts_:new Map,revoked_:!1,isManual_:!1,assigned_:void 0,callbacks_:[]}}get size(){return cs(this[No]).size}has(e){let t=this[No];return o(t),t.copy_?!!(t.copy_.has(e)||t.drafts_.has(e)&&t.copy_.has(t.drafts_.get(e))):t.base_.has(e)}add(e){let t=this[No];return o(t),this.has(e)||(a(t),Js(t),t.copy_.add(e),Bs(t,e,e)),this}delete(e){if(!this.has(e))return!1;let t=this[No];return o(t),a(t),Js(t),t.copy_.delete(e)||(t.drafts_.has(e)?t.copy_.delete(t.drafts_.get(e)):!1)}clear(){let e=this[No];o(e),cs(e).size&&(a(e),Js(e),e.copy_.clear())}values(){let e=this[No];return o(e),a(e),e.copy_.values()}entries(){let e=this[No];return o(e),a(e),e.copy_.entries()}keys(){return this.values()}[Symbol.iterator](){return this.values()}forEach(e,t){let n=this.values(),r=n.next();for(;!r.done;)e.call(t,r.value,r.value,this),r=n.next()}}function i(e,t){let n=new r(e,t);return[n,n[No]]}function a(e){e.copy_||(e.copy_=new Set,e.base_.forEach(t=>{if(Wo(t)){let n=Zs(e.scope_,t,e,t);e.drafts_.set(t,n),e.copy_.add(n)}else e.copy_.add(t)}))}function o(e){e.revoked_&&Po(3,JSON.stringify(cs(e)))}function s(e){if(e.type_===3&&e.copy_){let t=new Set(e.copy_);e.copy_.clear(),t.forEach(t=>{e.copy_.add(ls(t))})}}Ss(gs,{proxyMap_:t,proxySet_:i,fixSetContents:s})}var tc=new Xs().produce,nc=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},rc=(e=>e?nc(e):nc),ic=e=>e;function ac(e,t=ic){let n=Z.useSyncExternalStore(e.subscribe,Z.useCallback(()=>t(e.getState()),[e,t]),Z.useCallback(()=>t(e.getInitialState()),[e,t]));return Z.useDebugValue(n),n}var oc=e=>(t,n,r)=>(r.setState=(e,n,...r)=>t(typeof e==`function`?tc(e):e,n,...r),e(r.setState,n,r));function sc(e,t){if(e===t)return!0;if(e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.hasOwn(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var cc={sessionById:new Map,sessionsByBranch:new Map,boardById:new Map,boardObjectById:new Map,boardObjectsByBoardId:new Map,boardObjectByBranchId:new Map,boardObjectByCardId:new Map,commentById:new Map,cardById:new Map,cardTypeById:new Map,repoById:new Map,branchById:new Map,userById:new Map,mcpServerById:new Map,gatewayChannelById:new Map,artifactById:new Map,sessionMcpServerIds:new Map,userAuthenticatedMcpServerIds:new Set},lc=Object.keys(cc);function uc(e){let t={};for(let n of lc)t[n]=e[n];return t}function dc(e,t,n){let r=e.get(t);if(r&&sc(r,n))return e;let i=new Map(e);return i.set(t,n),i}function fc(e,t){let n=new Map;for(let r of e)n.set(r[t],r);return n}function pc(e){let t=new Map;for(let n of e){let e=t.get(n.session_id);e?e.push(n.mcp_server_id):t.set(n.session_id,[n.mcp_server_id])}return t}function mc(e){let t=new Map,n=new Map,r=new Map,i=new Map;for(let a of e){t.set(a.object_id,a);let e=n.get(a.board_id);e?e.push(a):n.set(a.board_id,[a]),a.branch_id&&r.set(a.branch_id,a),a.card_id&&i.set(a.card_id,a)}return{boardObjectById:t,boardObjectsByBoardId:n,boardObjectByBranchId:r,boardObjectByCardId:i}}function hc(e){let t=new Map,n=new Map;for(let r of e){if(t.set(r.session_id,r),r.archived)continue;let e=r.branch_id;n.has(e)||n.set(e,[]),n.get(e).push(r)}for(let r of e)if(!r.archived)for(let e of r.remote_relationships?.as_source??[]){if(e.relationship_type!==`remote_create`)continue;let i=t.get(e.target_session_id);if(!i)continue;let a=n.get(r.branch_id)??[];if(a.some(e=>e.session_id===i.session_id))continue;let o=bc(r,i,e);o&&n.set(r.branch_id,[...a,o])}return{sessionById:t,sessionsByBranch:n}}function gc(e,t){let n=e.get(t.board_id);if(!n?.some(e=>e.object_id===t.object_id))return e;let r=new Map(e),i=n.filter(e=>e.object_id!==t.object_id);return i.length>0?r.set(t.board_id,i):r.delete(t.board_id),r}function _c(e,t,n){let r=e.boardObjectById.get(t.object_id);if(n===`create`&&r||n===`patch`&&r&&sc(r,t))return e;let i=new Map(e.boardObjectById);i.set(t.object_id,t);let a=e.boardObjectsByBoardId;r&&r.board_id!==t.board_id&&(a=gc(a,r));let o=a.get(t.board_id)??[],s=o.findIndex(e=>e.object_id===t.object_id);if(s===-1||o[s]!==t||!sc(o[s],t)){let e=new Map(a);if(s===-1)e.set(t.board_id,[...o,t]);else{let n=[...o];n[s]=t,e.set(t.board_id,n)}a=e}let c=e.boardObjectByBranchId;if(r?.branch_id&&r.branch_id!==t.branch_id&&(c=new Map(c),c.delete(r.branch_id)),t.branch_id){let n=c.get(t.branch_id);(!n||!sc(n,t))&&(c=c===e.boardObjectByBranchId?new Map(c):c,c.set(t.branch_id,t))}let l=e.boardObjectByCardId;if(r?.card_id&&r.card_id!==t.card_id&&(l=new Map(l),l.delete(r.card_id)),t.card_id){let n=l.get(t.card_id);(!n||!sc(n,t))&&(l=l===e.boardObjectByCardId?new Map(l):l,l.set(t.card_id,t))}return{...e,boardObjectById:i,boardObjectsByBoardId:a,boardObjectByBranchId:c,boardObjectByCardId:l}}function vc(e,t){let n=e.boardObjectById.get(t.object_id);if(!n)return e;let r=new Map(e.boardObjectById);r.delete(n.object_id);let i=e.boardObjectByBranchId;n.branch_id&&i.get(n.branch_id)?.object_id===n.object_id&&(i=new Map(i),i.delete(n.branch_id));let a=e.boardObjectByCardId;return n.card_id&&a.get(n.card_id)?.object_id===n.object_id&&(a=new Map(a),a.delete(n.card_id)),{...e,boardObjectById:r,boardObjectsByBoardId:gc(e.boardObjectsByBoardId,n),boardObjectByBranchId:i,boardObjectByCardId:a}}function yc(e,t){if(!t)return e;let n=e.remote_relationships??t.remote_relationships,r=e.remote_surrogate??t.remote_surrogate;return n===e.remote_relationships&&r===e.remote_surrogate?e:{...e,...n!==void 0&&{remote_relationships:n},...r!==void 0&&{remote_surrogate:r}}}function bc(e,t,n){return n.relationship_type!==`remote_create`||t.archived||t.branch_id===e.branch_id?null:{...t,branch_id:e.branch_id,genealogy:{...t.genealogy??{},parent_session_id:e.session_id},remote_surrogate:{relationship:n,source_session_id:e.session_id,source_branch_id:e.branch_id,target_branch_id:t.branch_id}}}function xc(e,t){for(let n of e.values()){let e=n.find(e=>e.session_id===t);if(e&&!e.remote_surrogate)return e}}var Sc=e=>Symbol.iterator in e,Cc=e=>`entries`in e,wc=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},Tc=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function Ec(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:Sc(e)&&Sc(t)?Cc(e)&&Cc(t)?wc(e,t):Tc(e,t):wc({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}var{useSyncExternalStoreWithSelector:Dc}=e(pn(),1).default,Oc=e=>e;function kc(e,t=Oc,n){let r=Dc(e.subscribe,e.getState,e.getInitialState,t,n);return Z.useDebugValue(r),r}ec();var Ac={loading:!0,loadingStage:`idle`,error:null,itemCounts:{}},$=rc()(oc((e,t)=>({...cc,...Ac,reset:()=>e({...cc,...Ac}),resetMaps:()=>e({...cc}),setLoading:n=>{n!==t().loading&&e({loading:n})},setLoadingStage:n=>{n!==t().loadingStage&&e({loadingStage:n})},setError:n=>{n!==t().error&&e({error:n})},setItemCounts:n=>{let r=typeof n==`function`?n(t().itemCounts):n;Object.is(r,t().itemCounts)||e({itemCounts:r})},setMap:(n,r)=>{let i=t()[n],a=typeof r==`function`?r(i):r;Object.is(a,i)||e({[n]:a})},replaceMaps:n=>{let r=t(),i={};for(let e of Object.keys(n)){let t=n[e];t!==void 0&&!Object.is(t,r[e])&&(i[e]=t)}Object.keys(i).length!==0&&e(i)},applyMaps:n=>{let r=uc(t()),i=n(r);if(i===r)return;let a={};for(let e of lc)Object.is(i[e],r[e])||(a[e]=i[e]);Object.keys(a).length!==0&&e(a)},evictBranchAndSessions:t=>e(e=>{e.branchById.has(t)&&e.branchById.delete(t),e.sessionsByBranch.has(t)&&e.sessionsByBranch.delete(t);let n=[];for(let[r,i]of e.sessionById)i.branch_id===t&&n.push(r);for(let t of n)e.sessionById.delete(t)})})));function jc(e){return ac($,e)}var Mc=e=>e.sessionById,Nc=e=>e.sessionsByBranch,Pc=e=>e.repoById,Fc=e=>e.branchById,Ic=e=>e.boardById,Lc=e=>e.boardObjectById,Rc=e=>e.boardObjectsByBoardId,zc=e=>e.commentById,Bc=e=>e.cardById,Vc=e=>e.cardTypeById,Hc=e=>e.userById,Uc=e=>e.mcpServerById,Wc=e=>e.gatewayChannelById,Gc=e=>e.userAuthenticatedMcpServerIds,Kc=e=>e.artifactById,qc=e=>e.sessionMcpServerIds;function Jc(e){return t=>e?t.boardObjectsByBoardId.get(e):void 0}function Yc(e){return t=>t.sessionsByBranch.get(e)}function Xc(e){let t=[`### First boot instructions for Agor Assistant`,``,`Context:`,`- Assistant: ${e.assistant.displayName} ${e.assistant.emoji}`];return e.assistant.description&&t.push(`- Assistant description: ${e.assistant.description}`),e.user?.name?t.push(`- User: ${e.user.name}${e.user.email?` <${e.user.email}>`:``}`):e.user?.email&&t.push(`- User email: ${e.user.email}`),t.push(``),t.push(`Read BOOTSTRAP.md, then say hello and ask only the next useful questions to shape this assistant.`),t.join(`
7
- `)}function Zc({displayName:e,emoji:t,description:n,userName:r,userEmail:i}){let a=r?.trim(),o=i?.trim();return{assistant:{displayName:e.trim()||`My Assistant`,emoji:t?.trim()||`🤖`,...n?.trim()?{description:n.trim()}:{}},...a||o?{user:{...a?{name:a}:{},...o?{email:o}:{}}}:{},firstSession:!0}}function Qc(e){return Xc(Zc(e))}async function $c({client:e,boardId:t,assistantName:n,assistantEmoji:r}){if(!(!e||!t))try{await e.service(`boards`).ensureAssistantWelcomeNote({boardId:t,assistantName:n,assistantEmoji:r})}catch(e){console.warn(`Failed to create assistant welcome note:`,e)}}function el(e){if(!e)return``;let t=e.replace(/\\/g,`/`).split(`/`).filter(Boolean),n=t[t.length-1]||``;if(!n)return``;let r=n.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^-+|-+$/g,``);return r?`local/${r}`:``}function tl(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``)}var nl=e=>new Promise(t=>setTimeout(t,e));async function rl(e,t,{timeoutMs:n=3e4,intervalMs:r=500}={}){if(!e)return;let i=Date.now()+n,a;for(;Date.now()<i;){let n=await e.service(`branches`).get(t);if(a=n.filesystem_status,!a||a===`ready`)return;if(a===`failed`)throw Error(n.error_message||`Branch filesystem creation failed`);if(a===`deleted`||a===`cleaned`||a===`preserved`)throw Error(`Branch filesystem is ${a}`);await nl(r)}throw Error(`Timed out waiting for branch filesystem to become ready (${a})`)}async function il({client:e,branchId:t,boardId:n,sessionConfig:r,onCreateSession:i,onStatusChange:a}){a?.(`Preparing assistant worktree…`),await rl(e,t),a?.(`Starting first session…`);let o=await i(r,n);if(!o)throw Error(`First assistant session could not be created.`);return o}var al=(0,Z.lazy)(()=>on(()=>import(`./AgorEmojiPickerInner-DQjr8M3_.js`),__vite__mapDeps([0,1,2,3,4]))),ol=()=>(0,Q.jsx)(`div`,{style:{width:350,height:400,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`var(--ant-color-text-secondary, #888)`,fontSize:12},children:`Loading…`}),sl=({onEmojiClick:e})=>(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(ol,{}),children:(0,Q.jsx)(al,{onEmojiClick:e})}),cl=({value:e,onChange:t,defaultEmoji:n=`📋`,disabled:r=!1})=>{let[i,a]=(0,Z.useState)(!1);return(0,Q.jsxs)(`div`,{style:{display:`flex`,gap:0},children:[(0,Q.jsx)(J,{prefix:(0,Q.jsx)(`span`,{style:{fontSize:14},children:e||n}),readOnly:!0,disabled:r,style:{cursor:`default`,width:40,borderTopRightRadius:0,borderBottomRightRadius:0}}),(0,Q.jsx)(N,{content:(0,Q.jsx)(sl,{onEmojiClick:e=>{t?.(e.emoji),a(!1)}}),trigger:r?[]:`click`,open:r?!1:i,onOpenChange:e=>{r||a(e)},placement:`right`,children:(0,Q.jsx)(s,{icon:(0,Q.jsx)(nt,{}),disabled:r,style:{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeft:`none`}})})]})},ll=({fieldName:e,defaultEmoji:t})=>(0,Q.jsx)(Y.Item,{name:e,noStyle:!0,initialValue:t,children:(0,Q.jsx)(cl,{defaultEmoji:t})}),{Text:ul,Title:dl,Paragraph:fl}=v,{useToken:pl}=X,ml=12e4;function hl(e){return e.toLowerCase().replace(/[^a-z0-9-]/g,`-`).replace(/-{2,}/g,`-`).replace(/^-|-$/g,``)}function gl(e){return hl(`private-${tl(e.trim()||`My Assistant`)||`my-assistant`}`)}function _l(e){return Ao(e,{readyOnly:!0})}function vl(e){return new Map(e.map(e=>[e.repo_id,e]))}function yl(e,t=`api-key`){return e===`claude-code`&&t===`claude-subscription-token`?`CLAUDE_CODE_OAUTH_TOKEN`:jt[e]??`ANTHROPIC_API_KEY`}function bl(e,t=`api-key`){return e===`claude-code`&&t===`claude-subscription-token`?`sk-ant-oat01-...`:e===`codex`?`sk-...`:e===`gemini`?`AIza...`:e===`copilot`?`ghp_...`:e===`cursor`?`key_...`:`sk-ant-...`}var xl={"claude-code":`Claude Code`,"claude-code-cli":`Claude Code CLI`,codex:`Codex`,gemini:`Gemini`,opencode:`OpenCode`,copilot:`GitHub Copilot`,cursor:`Cursor SDK`},Sl=[{value:`claude-code`,title:`Claude Code`,eyebrow:`Recommended`},{value:`codex`,title:`Codex`,eyebrow:`Recommended`}],Cl=[{value:`gemini`,label:`Gemini`},{value:`copilot`,label:`GitHub Copilot`},{value:`opencode`,label:`OpenCode`},{value:`cursor`,label:`Cursor SDK (Beta)`}],wl=new Set(Sl.map(e=>e.value)),Tl={"claude-code":{label:`platform.claude.com/settings/keys`,url:`https://platform.claude.com/settings/keys`},"claude-code-cli":{label:`platform.claude.com/settings/keys`,url:`https://platform.claude.com/settings/keys`},codex:{label:`platform.openai.com/api-keys`,url:`https://platform.openai.com/api-keys`},gemini:{label:`aistudio.google.com`,url:`https://aistudio.google.com/apikey`},copilot:{label:`github.com/features/copilot`,url:`https://github.com/features/copilot`},cursor:{label:`cursor.com`,url:`https://cursor.com`},opencode:null};function El(e){return e===`codex`?`codex-cli-auth`:`api-key`}function Dl(e){if(e?.model)return{mode:e.mode??`exact`,model:e.model,...e.advisorModel?{advisorModel:e.advisorModel}:{}}}function Ol(e){return e===`claude-code`?[{value:`claude-subscription-token`,label:`Subscription`},{value:`api-key`,label:`API key`}]:e===`codex`?[{value:`codex-cli-auth`,label:`CLI sign-in`},{value:`api-key`,label:`API key`}]:null}function kl({open:e,onComplete:t,user:n,client:r,onCreateRepo:i,onCreateBranch:o,onCreateSession:c,onUpdateUser:d,onCheckAuth:f,frameworkRepoUrl:p}){let m=jc(Pc),h=jc(Fc),_=jc(Ic),{token:y}=pl(),[b,x]=(0,Z.useState)(`identity`),[S,C]=(0,Z.useState)(`My Assistant`),[w,T]=(0,Z.useState)(`🤖`),[E,D]=(0,Z.useState)(`claude-code`),[O,k]=(0,Z.useState)(`claude-code`),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(`api-key`),[P,F]=(0,Z.useState)(``),[I,ee]=(0,Z.useState)(!1),[L,te]=(0,Z.useState)(null),[R,ne]=(0,Z.useState)(!1),[V,H]=(0,Z.useState)(`idle`),[re,ie]=(0,Z.useState)(``),[ae,oe]=(0,Z.useState)(null),se=(0,Z.useRef)(null),ce=(0,Z.useRef)(null),le=(0,Z.useRef)(null),ue=(0,Z.useRef)(new Set),fe=p||`https://github.com/preset-io/agor-assistant.git`,pe=(0,Z.useMemo)(()=>gl(S),[S]),me=(0,Z.useCallback)(e=>{if(!n)return;let t=n.preferences?.onboarding||{},r={...n.preferences,onboarding:{...t,...e}};e.boardId&&(r.mainBoardId=e.boardId),d(n.user_id,{preferences:r})},[d,n]);(0,Z.useEffect)(()=>{if(!e||!n)return;let t=n.preferences?.onboarding;typeof t?.assistantDisplayName==`string`&&C(t.assistantDisplayName||`My Assistant`),typeof t?.assistantEmoji==`string`&&T(t.assistantEmoji||`🤖`)},[e,n]),(0,Z.useEffect)(()=>()=>{se.current&&clearTimeout(se.current),ce.current&&clearTimeout(ce.current)},[]);let he=(0,Z.useCallback)(e=>{let t=n?.agentic_tools?.[`claude-code`],r=n?.agentic_tools?.codex,i=n?.agentic_tools?.gemini,a=n?.agentic_tools?.copilot,o=n?.agentic_tools?.cursor,s=!!(t?.ANTHROPIC_API_KEY||t?.CLAUDE_CODE_OAUTH_TOKEN||n?.env_vars?.ANTHROPIC_API_KEY),c=!!(r?.OPENAI_API_KEY||n?.env_vars?.OPENAI_API_KEY),l=!!(i?.GEMINI_API_KEY||n?.env_vars?.GEMINI_API_KEY),u=!!(a?.COPILOT_GITHUB_TOKEN||n?.env_vars?.COPILOT_GITHUB_TOKEN),d=!!(o?.CURSOR_API_KEY||n?.env_vars?.CURSOR_API_KEY);return e===`claude-code`?s:e===`codex`?c:e===`gemini`?l:e===`copilot`?u:e===`cursor`?d:e===`opencode`?s||c||l:!1},[n]),ge=(0,Z.useCallback)(()=>{F(``),oe(null),te(null),ee(!1)},[]),ve=(0,Z.useCallback)((e,t={})=>{D(e),N(El(e)),wl.has(e)&&k(e),j(t.useDifferentProvider??!wl.has(e)),ge()},[ge]),ye=(0,Z.useCallback)(e=>{let t=n?.default_agentic_config?.[E],r=t?.permissionMode??_t(E),i={branch_id:e,agent:E,initialPrompt:Qc({displayName:S.trim()||`My Assistant`,emoji:w||`🤖`,userName:n?.name,userEmail:n?.email}),modelConfig:Dl(t?.modelConfig),effort:t?.modelConfig?.effort,mcpServerIds:t?.mcpServerIds,permissionMode:r};if(E===`codex`){let e=yt(r);i.codexSandboxMode=t?.codexSandboxMode??e.sandboxMode,i.codexApprovalPolicy=t?.codexApprovalPolicy??e.approvalPolicy,i.codexNetworkAccess=t?.codexNetworkAccess??e.networkAccess}return i},[S,w,E,n]),be=(0,Z.useMemo)(()=>Array.from(h.values()),[h]),xe=(0,Z.useCallback)(async(e,t)=>{for(let n of be)if(n.repo_id===e&&n.name===t&&!n.archived&&n.filesystem_status!==`failed`)return n;try{let n=await r?.service(`branches`).find({query:{repo_id:e,name:t,archived:!1,filesystem_status:{$ne:`failed`},$limit:1}});return(Array.isArray(n)?n:n?.data??[])[0]??null}catch{return null}},[be,r]),Se=(0,Z.useCallback)(async e=>{try{let t=await r?.service(`sessions`).find({query:{branch_id:e,archived:!1,$limit:1,$sort:{created_at:-1}}}),n=(Array.isArray(t)?t:t?.data??[])[0]?.session_id;return typeof n==`string`?n:null}catch{return null}},[r]),Ce=(0,Z.useCallback)(async()=>{try{let e=await r?.service(`repos`).find({query:{slug:Eo,$limit:1}}),t=Ao(vl(Array.isArray(e)?e:e?.data??[]),{excludeFailed:!0});if(t)return t[1];let n=await r?.service(`repos`).find({query:{$limit:50}});return Ao(vl(Array.isArray(n)?n:n?.data??[]),{excludeFailed:!0})?.[1]??null}catch{return null}},[r]),we=(0,Z.useCallback)(async(e,i)=>{if(le.current!==e){le.current=e,se.current&&=(clearTimeout(se.current),null),ce.current&&=(clearTimeout(ce.current),null);try{oe(null),me({repoId:e}),H(`board`),ie(`Creating your assistant board…`);let a=n?.preferences?.mainBoardId,s=a&&n&&_.get(a)?.created_by===n.user_id?a:null;if(s||=(await r?.service(`boards`).create({name:`${S.trim()||`My Assistant`}'s Board`,icon:w||`🤖`}))?.board_id??null,!s)throw Error(`Failed to create assistant board.`);me({boardId:s}),await $c({client:r,boardId:s,assistantName:S.trim()||`My Assistant`,assistantEmoji:w}),H(`branch`),ie(`Creating the default assistant branch…`);let l=i?.default_branch||m.get(e)?.default_branch||`main`,u={kind:`assistant`,displayName:S.trim()||`My Assistant`,emoji:w||void 0,frameworkRepo:Eo,createdViaOnboarding:!0},d=[hl(`${pe}-${n?.user_id?Jt(n.user_id):Date.now().toString(36).slice(-6)}`),pe],f=null,p=null,h;for(let t of d){if(p=await xe(e,t),p){f=p;break}try{if(f=await o(e,{name:t,ref:t,createBranch:!0,sourceBranch:l,pullLatest:!0,boardId:s,custom_context:{assistant:u}}),f?.branch_id)break}catch(e){h=e;let t=e instanceof Error?e.message:String(e);if(!t.includes(`already exists`)&&!t.includes(`in use by another branch`))throw e}}if(!f?.branch_id)throw h instanceof Error?h:Error(`Failed to create assistant branch.`);p?.board_id&&p.board_id!==s&&(s=p.board_id,me({boardId:s})),me({branchId:f.branch_id}),await r?.service(`boards`).setPrimaryAssistant({boardId:s,branchId:f.branch_id}),H(`session`),ie(`Starting your assistant…`);let g=await Se(f.branch_id)??await il({client:r,branchId:f.branch_id,boardId:s,sessionConfig:ye(f.branch_id),onCreateSession:c,onStatusChange:ie});H(`done`),ie(`Opening your assistant…`),t({branchId:f.branch_id,sessionId:g,boardId:s,path:`assistant`})}catch(e){le.current=null,H(`error`),oe(e instanceof Error?e.message:String(e))}}},[S,w,_,ye,r,pe,xe,Se,t,o,c,m,me,n]),W=(0,Z.useCallback)(e=>{let t=async()=>{if(le.current!==e){try{let t=await r?.service(`repos`).get(e);if(!t)return;if(t.clone_status===`failed`){H(`error`),oe(t.clone_error?.message??`Clone failed (exit ${t.clone_error?.exit_code??`?`}).`),se.current&&=(clearTimeout(se.current),null);return}if(t.clone_status===`ready`||t.clone_status===void 0){await we(t.repo_id,t);return}}catch{}ce.current=setTimeout(t,1e3)}};ce.current&&clearTimeout(ce.current),ce.current=setTimeout(t,0)},[r,we]),Te=(0,Z.useCallback)(async()=>{x(`loading`),H(`cloning`),ie(`Cloning assistant framework…`),oe(null),le.current=null;let e=_l(m);if(e){ie(`Preparing assistant workspace…`),we(e[0],e[1]);return}ue.current=new Set(Array.from(m.values()).filter(e=>e.clone_status===`failed`).map(e=>e.repo_id));let t=()=>{se.current&&clearTimeout(se.current),se.current=setTimeout(()=>{H(`error`),oe(`Clone is taking longer than expected. Please check the repository connection and try again.`)},ml)};try{let e=await i({url:fe,slug:Eo,default_branch:`main`},{silent:!0});if(e?.status===`exists`&&ie(`Preparing assistant workspace…`),e?.repo_id){W(e.repo_id),t();return}let n=await Ce();if(n?.repo_id){n.clone_status===`cloning`?(W(n.repo_id),t()):(ie(`Preparing assistant workspace…`),we(n.repo_id,n));return}t()}catch(e){let n=await Ce();if(n?.repo_id){ie(`Preparing assistant workspace…`),n.clone_status===`cloning`?(W(n.repo_id),t()):we(n.repo_id,n);return}H(`error`),oe(e instanceof Error?e.message:String(e))}},[fe,Ce,we,i,W,m]);(0,Z.useEffect)(()=>{if(b!==`loading`||V!==`cloning`)return;let e=_l(m);e&&we(e[0],e[1])},[b,we,m,V]),(0,Z.useEffect)(()=>{if(!(b!==`loading`||V!==`cloning`)){for(let e of m.values())if(e.clone_status===`failed`&&!ue.current.has(e.repo_id)&&!(e.slug!==`preset-io/agor-assistant`&&!e.remote_url?.includes(`agor-assistant`))){H(`error`),oe(e.clone_error?.message??`Clone failed (exit ${e.clone_error?.exit_code??`?`}).`),se.current&&=(clearTimeout(se.current),null);return}}},[b,m,V]),(0,Z.useEffect)(()=>{if(!r?.io)return;let e=e=>{b!==`loading`||V!==`cloning`||e.slug!==`preset-io/agor-assistant`&&!e.url?.includes(`agor-assistant`)||(H(`error`),oe(e.error),se.current&&=(clearTimeout(se.current),null))};return r.io.on(`repo:cloneError`,e),()=>r.io.off(`repo:cloneError`,e)},[r,b,V]);let Ee=(0,Z.useCallback)(()=>{let e=S.trim()||`My Assistant`;C(e),me({path:`assistant`,assistantDisplayName:e,assistantEmoji:w||`🤖`}),oe(null),x(`llm`)},[S,w,me]),De=(0,Z.useCallback)(async()=>{if(!n||!P.trim())return;oe(null);let e=yl(E,M),t=E===`opencode`?`claude-code`:E;try{await d(n.user_id,{agentic_tools:{[t]:{[e]:P.trim()}}}),await Te()}catch(e){oe(`Failed to save API key: ${e instanceof Error?e.message:String(e)}`)}},[P,M,d,E,Te,n]),Oe=(0,Z.useCallback)(async()=>{if(!f)return;ne(!0),te(null);let e=await f(E,M===`codex-cli-auth`?void 0:P.trim()||void 0);ne(!1),te(e)},[P,M,f,E]),ke=(0,Z.useCallback)(()=>{n&&t({branchId:``,sessionId:``,boardId:``,path:`assistant`})},[t,n]),Ae=()=>(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(dl,{level:4,style:{marginBottom:8},children:`Welcome to Agor ✨`}),(0,Q.jsxs)(fl,{style:{marginBottom:14},children:[`Start by creating your`,` `,(0,Q.jsx)(v.Link,{strong:!0,href:`https://agor.live/guide/assistants`,target:`_blank`,rel:`noopener noreferrer`,children:`Agor assistant`}),`: a persistent agent that can help set up your workspace and keep things moving.`]}),(0,Q.jsxs)(`div`,{style:{background:y.colorPrimaryBg,border:`1px solid ${y.colorPrimaryBorder}`,borderRadius:8,padding:`12px 14px`,marginBottom:16},children:[(0,Q.jsx)(ul,{strong:!0,children:`Your assistant can help:`}),(0,Q.jsxs)(`ul`,{style:{margin:`8px 0 0`,paddingLeft:20,color:y.colorTextSecondary},children:[(0,Q.jsx)(`li`,{children:`🧰 Connect tools and credentials`}),(0,Q.jsx)(`li`,{children:`🗺️ Set up your board and workflow`}),(0,Q.jsx)(`li`,{children:`🤝 Coordinate agents and sessions`}),(0,Q.jsx)(`li`,{children:`💬 Show you around and answer questions`})]})]}),(0,Q.jsx)(Y,{layout:`vertical`,children:(0,Q.jsx)(Y.Item,{label:`Name and emoji`,required:!0,children:(0,Q.jsxs)(G.Compact,{style:{display:`flex`},children:[(0,Q.jsx)(cl,{value:w,onChange:T,defaultEmoji:`🤖`}),(0,Q.jsx)(J,{placeholder:`My Assistant`,value:S,onChange:e=>C(e.target.value),autoFocus:!0,style:{flex:1}})]})})}),ae&&(0,Q.jsx)(z,{type:`error`,message:ae,showIcon:!0,style:{marginBottom:16}}),(0,Q.jsx)(s,{type:`primary`,onClick:Ee,disabled:!S.trim(),children:`Continue`})]}),je=()=>{if(E===`claude-code`)return M===`claude-subscription-token`?(0,Q.jsx)(z,{type:`info`,showIcon:!0,style:{marginBottom:16,textAlign:`left`},description:(0,Q.jsxs)(`span`,{children:[`Run `,(0,Q.jsx)(ul,{code:!0,children:`claude setup-token`}),`, then paste the token below.`]})}):(0,Q.jsxs)(fl,{type:`secondary`,style:{marginBottom:16},children:[`Paste an `,(0,Q.jsx)(ul,{code:!0,children:`ANTHROPIC_API_KEY`}),` from`,` `,(0,Q.jsx)(v.Link,{href:`https://platform.claude.com/settings/keys`,target:`_blank`,children:`Claude Console`}),`.`]});if(E===`codex`)return M===`codex-cli-auth`?(0,Q.jsx)(z,{type:`info`,showIcon:!0,style:{marginBottom:16,textAlign:`left`},description:(0,Q.jsxs)(`span`,{children:[`Run `,(0,Q.jsx)(ul,{code:!0,children:`codex login --device-auth`}),`; Agor will use that local auth.`]})}):(0,Q.jsxs)(fl,{type:`secondary`,style:{marginBottom:16},children:[`Paste an `,(0,Q.jsx)(ul,{code:!0,children:`OPENAI_API_KEY`}),` from`,` `,(0,Q.jsx)(v.Link,{href:`https://platform.openai.com/api-keys`,target:`_blank`,children:`OpenAI Platform`}),`.`]});let e=Tl[E];return e?(0,Q.jsxs)(fl,{type:`secondary`,style:{marginBottom:16},children:[`Paste your `,yl(E,M),` from`,` `,(0,Q.jsx)(v.Link,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:e.label}),`.`]}):null};return(0,Q.jsxs)(a,{open:e,closable:!1,mask:{closable:!1},keyboard:!1,footer:b===`loading`?null:(0,Q.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,width:`100%`,textAlign:`left`},children:[(0,Q.jsxs)(ul,{type:`secondary`,style:{fontSize:12},children:[`Step `,b===`identity`?`1`:`2`,` of 2`]}),(0,Q.jsxs)(G,{size:`small`,children:[b===`llm`&&(0,Q.jsx)(s,{type:`link`,onClick:()=>x(`identity`),children:`← Back`}),(0,Q.jsx)(B,{title:`Skip setup?`,description:(0,Q.jsxs)(`div`,{style:{maxWidth:250},children:[`Are you sure? Your assistant has been waiting their whole life to meet you.`,(0,Q.jsx)(`br`,{}),(0,Q.jsx)(`br`,{}),(0,Q.jsx)(ul,{type:`secondary`,style:{fontSize:12},children:`(You can always come back via Settings)`})]}),okText:`Skip anyway`,cancelText:`Go back`,onConfirm:ke,children:(0,Q.jsx)(s,{type:`text`,size:`small`,style:{color:y.colorTextTertiary},children:`Skip setup`})})]})]}),width:680,styles:{body:{minHeight:440,maxHeight:640,overflowY:`auto`,padding:`28px 36px`}},children:[b===`identity`&&Ae(),b===`llm`&&(()=>{let e=he(E)&&!I,t=Ol(E),n=E===`codex`&&M===`codex-cli-auth`,r=yl(E,M);return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(dl,{level:4,children:`Choose your LLM`}),(0,Q.jsx)(fl,{type:`secondary`,style:{marginBottom:16},children:`Pick what powers your assistant.`}),(0,Q.jsxs)(G,{orientation:`vertical`,size:`middle`,style:{width:`100%`,marginBottom:16},children:[(0,Q.jsx)(`div`,{role:`radiogroup`,"aria-label":`Recommended LLM providers`,style:{display:`grid`,gridTemplateColumns:`repeat(2, minmax(0, 1fr))`,gap:12},children:Sl.map(e=>{let t=E===e.value;return(0,Q.jsx)(g,{size:`small`,style:{borderColor:t?y.colorPrimary:y.colorBorder,background:t?y.colorPrimaryBg:void 0},styles:{body:{padding:0}},children:(0,Q.jsx)(`label`,{style:{display:`block`,cursor:`pointer`,padding:14},children:(0,Q.jsxs)(G,{align:`center`,size:10,style:{width:`100%`},children:[(0,Q.jsx)(Va,{tool:e.value,size:32}),(0,Q.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,Q.jsx)(ul,{strong:!0,children:e.title}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(u,{color:t?`blue`:`default`,children:e.eyebrow})})]}),(0,Q.jsx)(`input`,{type:`radio`,name:`recommended-agent`,value:e.value,checked:t,onChange:()=>ve(e.value,{useDifferentProvider:!1}),style:{accentColor:y.colorPrimary}})]})})},e.value)})}),(0,Q.jsx)(U,{checked:A,onChange:e=>{let t=e.target.checked;ve(t?Cl[0].value:O,{useDifferentProvider:t})},children:`Use a different provider`}),A&&(0,Q.jsx)(Y,{layout:`vertical`,children:(0,Q.jsx)(Y.Item,{label:`Other LLM providers`,style:{marginBottom:0},children:(0,Q.jsx)(l,{value:wl.has(E)?void 0:E,onChange:e=>ve(e,{useDifferentProvider:!0}),options:Cl,style:{width:`100%`}})})})]}),e?(0,Q.jsxs)(`div`,{style:{textAlign:`center`},children:[(0,Q.jsx)(_e,{style:{padding:`8px 0 12px`},icon:(0,Q.jsx)(st,{style:{color:y.colorSuccess}}),title:`${xl[E]} is configured`,subTitle:`You're all set to use ${xl[E]}.`}),(0,Q.jsxs)(G,{orientation:`vertical`,size:`small`,children:[(0,Q.jsx)(s,{type:`primary`,onClick:Te,children:`Continue`}),(0,Q.jsx)(s,{type:`link`,onClick:()=>ee(!0),children:`Use a different API key instead`})]})]}):(0,Q.jsxs)(Q.Fragment,{children:[I&&(0,Q.jsx)(s,{type:`link`,onClick:()=>{ee(!1),F(``)},style:{padding:0,marginBottom:12},children:`← Back to detected authentication`}),t&&(0,Q.jsx)(K.Group,{value:M,onChange:e=>{N(e.target.value),F(``),te(null)},style:{width:`100%`,marginBottom:16},children:(0,Q.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(2, minmax(0, 1fr))`,gap:8},children:t.map(e=>(0,Q.jsx)(K,{value:e.value,style:{border:`1px solid ${y.colorBorder}`,borderRadius:8,marginInlineEnd:0,padding:`8px 12px`},children:(0,Q.jsx)(ul,{strong:M===e.value,children:e.label})},e.value))})}),je(),E===`opencode`&&(0,Q.jsx)(fl,{type:`secondary`,style:{marginBottom:16},children:`OpenCode supports many LLM providers. Configure the key for your provider below.`}),!n&&(0,Q.jsx)(Y,{layout:`vertical`,children:(0,Q.jsx)(Y.Item,{label:r,children:(0,Q.jsx)(J.Password,{placeholder:bl(E,M),value:P,onChange:e=>{F(e.target.value),te(null)}})})}),ae&&(0,Q.jsx)(z,{type:`error`,message:ae,showIcon:!0,style:{marginBottom:16}}),L&&(0,Q.jsx)(z,{type:L.authenticated?`success`:`warning`,showIcon:!0,style:{marginBottom:16,textAlign:`left`},message:L.authenticated?`Connection works`:`Not authenticated`,description:L.hint}),(0,Q.jsxs)(G,{wrap:!0,children:[n?(0,Q.jsx)(s,{type:`primary`,onClick:Te,children:`Continue with Codex CLI auth`}):(0,Q.jsx)(s,{type:`primary`,onClick:De,disabled:!P.trim(),icon:(0,Q.jsx)(de,{}),children:`Save & Continue`}),f&&(0,Q.jsx)(s,{onClick:Oe,loading:R,children:`Test Connection`}),!n&&(0,Q.jsx)(s,{onClick:Te,children:`Continue without key`})]})]})]})})(),b===`loading`&&(0,Q.jsx)(`div`,{style:{textAlign:`center`,padding:`48px 0`},children:V===`error`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(z,{type:`error`,message:`Setup failed`,description:ae,showIcon:!0,style:{marginBottom:16,textAlign:`left`}}),(0,Q.jsx)(s,{type:`primary`,onClick:Te,children:`Retry`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ze,{size:`large`}),(0,Q.jsx)(dl,{level:4,style:{marginTop:20,marginBottom:8},children:`Setting up Agor`}),(0,Q.jsx)(fl,{type:`secondary`,style:{marginBottom:0},children:re})]})})]})}var Al=5e3,jl=(0,Z.createContext)(null);function Ml({children:e}){let t=(0,Z.useRef)(null),n=(0,Z.useRef)(null),r=(0,Z.useRef)(null),i=(0,Z.useMemo)(()=>({recenterRef:t,boardSwitcherRef:n,pendingRef:r}),[]);return(0,Q.jsx)(jl.Provider,{value:i,children:e})}function Nl(e,t){(0,Z.useEffect)(()=>{if(e)return e.current=t,()=>{e.current===t&&(e.current=null)}},[e,t])}function Pl(e){Nl((0,Z.useContext)(jl)?.recenterRef,e)}function Fl(e){Nl((0,Z.useContext)(jl)?.boardSwitcherRef,e)}function Il(){let e=(0,Z.useContext)(jl);return(0,Z.useCallback)(()=>{let t=e?.pendingRef.current;return t?Date.now()>t.expiresAt?(e.pendingRef.current=null,null):(e.pendingRef.current=null,t.nodeId):null},[e])}function Ll(){let e=(0,Z.useContext)(jl);return(0,Z.useCallback)((t,n)=>e?e.recenterRef.current?.(t)?!0:n?.boardId&&e.boardSwitcherRef.current?(e.pendingRef.current={nodeId:t,expiresAt:Date.now()+Al},e.boardSwitcherRef.current(n.boardId),!0):!1:!1,[e])}var Rl=(0,Z.createContext)({connected:!1,connecting:!1,outOfSync:!1,capturedSha:null,currentSha:null}),zl=Rl.Provider;function Bl(){return!Hl().canMutate}function Vl(){return(0,Z.useContext)(Rl)}function Hl(){let{connected:e,connecting:t,outOfSync:n}=(0,Z.useContext)(Rl);return n?{canMutate:!1,reason:`out-of-sync`,message:`Daemon was upgraded — refresh the page to continue.`}:t?{canMutate:!1,reason:`reconnecting`,message:`Reconnecting to daemon…`}:e?{canMutate:!0,reason:null,message:null}:{canMutate:!1,reason:`disconnected`,message:`Disconnected from daemon. Action unavailable.`}}var Ul=(0,Z.createContext)(void 0),{darkAlgorithm:Wl,defaultAlgorithm:Gl}=X,Kl=(0,Z.createContext)(void 0),ql=`agor:themeMode`,Jl=`agor:customTheme`,Yl=({children:e})=>{let[t,n]=(0,Z.useState)(()=>localStorage.getItem(ql)||`dark`),[r,i]=(0,Z.useState)(()=>{let e=localStorage.getItem(Jl);if(e)try{return JSON.parse(e)}catch(e){return console.error(`Failed to parse custom theme from localStorage:`,e),null}return null}),a=e=>{n(e),localStorage.setItem(ql,e)},o=e=>{if(e){let{algorithm:t,...n}=e;i(n),localStorage.setItem(Jl,JSON.stringify(n))}else i(null),localStorage.removeItem(Jl)},s=(0,Z.useMemo)(()=>{let e={token:{colorPrimary:`#2e9a92`,colorSuccess:`#52c41a`,colorWarning:`#faad14`,colorError:`#ff4d4f`,colorInfo:`#2e9a92`,colorLink:`#2e9a92`,borderRadius:8,fontFamily:`'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif`}};return t===`custom`&&r?{...e,...r,token:{...e.token,...r.token},algorithm:Wl}:{...e,algorithm:t===`dark`?Wl:Gl}},[t,r]),c=(0,Z.useCallback)(()=>s,[s]),l=t!==`light`;return(0,Z.useEffect)(()=>{c(),document.body.style.backgroundColor=l?`#141414`:`#f0f2f5`,l?document.documentElement.classList.add(`dark`):document.documentElement.classList.remove(`dark`)},[l,c]),(0,Q.jsx)(Kl.Provider,{value:{themeMode:t,setThemeMode:a,customTheme:r,setCustomTheme:o,getCurrentThemeConfig:c,isDark:l},children:e})},Xl=()=>{let e=(0,Z.useContext)(Kl);if(!e)throw Error(`useTheme must be used within a ThemeProvider`);return e};function Zl(e,t){return e===t||e.startsWith(`${t}/`)}function Ql({baseUrl:e,pathname:t,uiMountPath:n=`/ui`}){return e===`${n}/`?{mode:`bundled-daemon-ui`,baseUrl:e,pathname:t,uiMountPath:n}:e===`/`&&Zl(t,n)?{mode:`canonical-dev-deeplink`,baseUrl:e,pathname:t,uiMountPath:n}:{mode:`root-vite-dev`,baseUrl:e,pathname:t,uiMountPath:n}}function $l(e){return e.mode===`bundled-daemon-ui`||e.mode===`canonical-dev-deeplink`?e.uiMountPath:``}function eu(e){return e.mode===`bundled-daemon-ui`}function tu(e,t,n){if(eu(e))return t;let r=new URL(t);return`${r.protocol}//${r.hostname}:${n}`}function nu(){if(typeof window<`u`){let e=window.AGOR_DAEMON_URL;if(e)return e}let e=3031;return typeof window<`u`?tu(Ql({baseUrl:`/ui/`,pathname:window.location.pathname}),window.location.origin,e):`http://${At.DEFAULT_HOST}:${e}`}nu();function ru(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.code==`number`)return t.code;if(typeof t.statusCode==`number`)return t.statusCode;if(typeof t.status==`number`)return t.status}function iu(e){let t=ru(e);if(t===401||t===403)return!0;if(!e||typeof e!=`object`)return!1;let n=e;return n.name===`NotAuthenticated`||n.className===`not-authenticated`}function au(e){if(iu(e))return!1;let t=ru(e);if(t===0||t===408||t===429||t!==void 0&&t>=500)return!0;if(!e||typeof e!=`object`)return!1;let n=e,r=typeof n.message==`string`?n.message.toLowerCase():``,i=e instanceof Error?e.constructor.name:``;return i===`TypeError`&&r.includes(`fetch`)?!0:r.includes(`connection`)||r.includes(`timeout`)||r.includes(`websocket`)||r.includes(`transport`)||r.includes(`failed to fetch`)||r.includes(`networkerror`)||r.includes(`network error`)||r.includes(`load failed`)||i===`TransportError`||i===`WebSocketError`}var ou=`agor-access-token`,su=`agor-refresh-token`;async function cu(e,t){return await e.service(`authentication/refresh`).create({refreshToken:t})}function lu(e,t){localStorage.setItem(ou,e),t&&localStorage.setItem(su,t)}function uu(){return localStorage.getItem(su)}function du(){return localStorage.getItem(ou)}function fu(){localStorage.removeItem(ou),localStorage.removeItem(su)}async function pu(e,t){let n=await cu(e,t);return lu(n.accessToken,n.refreshToken),n}var mu=`agor:tokens-refreshed`;function hu(e){typeof window>`u`||window.dispatchEvent(new CustomEvent(mu,{detail:e}))}var gu=`agor:tokens-refresh-unrecoverable`,_u=null,vu=!1,yu=class extends Error{constructor(e=`Refresh token is invalid or expired`,t){super(e,t),this.name=`RefreshUnrecoverableError`}};function bu(){vu=!1}function xu(e,t){return vu?Promise.reject(new yu):_u||(_u=pu(e,t).then(e=>(vu=!1,hu(e),e)).catch(e=>{throw iu(e)?(vu=!0,typeof window<`u`&&window.dispatchEvent(new CustomEvent(gu)),new yu(void 0,{cause:e})):e}).finally(()=>{_u=null}),_u)}async function Su(e){let t=uu();if(!t)return null;let n=await xu(e,t);return await e.authenticate({strategy:`jwt`,accessToken:n.accessToken}),n}function Cu(e={}){let{url:t=nu(),accessToken:n}=e,[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!!n),[s,c]=(0,Z.useState)(null),l=(0,Z.useRef)(null),u=(0,Z.useRef)(n);u.current=n;let d=!!n;return(0,Z.useEffect)(()=>{let e=!0,n=null,r=!1,a=0,s=null,f=()=>{s!==null&&(clearTimeout(s),s=null)},p=null,m=()=>{p!==null&&(clearTimeout(p),p=null)},h=()=>{p===null&&(p=setTimeout(()=>{p=null,e&&i(!1)},1500))};async function g(){if(!d){o(!1),i(!1),c(null),l.current=null;return}i(!1),o(!0),c(null),n=$t(t,!1),l.current=n;let p=new Set([`authentication`,`authentication/refresh`]);n.hooks({around:{all:[async(e,t)=>{let r=e.path;if(typeof r==`string`&&p.has(r)){await t();return}try{await t()}catch(t){if(!iu(t)||(e.params??{})._refreshRetried||!n)throw t;try{if(!await Su(n))throw t}catch{throw t}let i=e.arguments?[...e.arguments]:[],a=i.length-1,o=i[a],s=typeof o==`object`&&!!o&&!Array.isArray(o),c={...s?o:{},_refreshRetried:!0};s?i[a]=c:i.push(c);let l=n.service(r),u=l[e.method];if(typeof u!=`function`)throw t;e.result=await u.call(l,...i)}}]}}),typeof window<`u`&&(window.__agorClient=n),n.io.on(`connect`,async()=>{if(e){let e=r;if(r=!0,a=0,f(),m(),!e)return;let t=u.current;try{if(t)try{await n.authenticate({strategy:`jwt`,accessToken:t}),i(!0),o(!1),c(null);return}catch{try{if(await Su(n)){i(!0),o(!1),c(null);return}}catch(e){if(console.error(`❌ Refresh failed on reconnect:`,e),e instanceof yu||iu(e)){o(!1),i(!1),c(`Session expired. Please log in again.`);return}i(!1),o(!0);return}}console.error(`❌ Re-authentication failed after reconnect - all tokens expired`),o(!1),i(!1),c(`Session expired. Please log in again.`)}catch(e){console.error(`❌ Re-authentication failed after reconnect:`,e),o(!1),i(!1)}}}),n.io.on(`disconnect`,t=>{if(e)if(r?h():i(!1),t===`io server disconnect`){if(a>=10){o(!1),m(),i(!1),c(`Lost connection to daemon after multiple attempts. Please reload the page.`);return}o(!0);let t=a++,r=Math.min(500*2**t,3e4);f(),s=setTimeout(()=>{s=null,e&&n?.io.connect()},r)}else (t===`transport close`||t===`transport error`||t===`ping timeout`)&&o(!0)}),n.io.on(`connect_error`,t=>{e&&(r?(o(!0),i(!1)):(c(`Daemon is not running. Start it with: cd apps/agor-daemon && pnpm dev`),o(!1),i(!1)))}),n.io.connect();try{await new Promise((e,t)=>{let r=setTimeout(()=>{t(Error(`Connection timeout`))},5e3);if(n.io.connected){clearTimeout(r),e();return}n.io.once(`connect`,()=>{clearTimeout(r),e()}),n.io.once(`connect_error`,e=>{clearTimeout(r),t(e)})})}catch{e&&(c(`Failed to connect to daemon. Make sure it is running on :3030`),o(!1),i(!1));return}let g=u.current;try{g&&await n.authenticate({strategy:`jwt`,accessToken:g})}catch{e&&(c(`Authentication failed. Please log in again.`),o(!1),i(!1));return}e&&(i(!0),o(!1),c(null))}g();let _=t=>{if(!e)return;let r=t.detail;!r||!n||n.io.connected&&n.authenticate({strategy:`jwt`,accessToken:r.accessToken}).then(()=>{e&&(i(!0),o(!1),c(null))}).catch(e=>{console.error(`In-place re-authentication failed after token replacement:`,e)})};return window.addEventListener(mu,_),()=>{e=!1,f(),m(),window.removeEventListener(mu,_),n?.io&&(n.io.removeAllListeners(),n.io.close()),typeof window<`u`&&window.__agorClient===n&&delete window.__agorClient}},[t,d]),{client:l.current,connected:r,connecting:a,error:s,retryConnection:()=>{let e=l.current;e?.io&&(e.io.connected&&e.io.disconnect(),o(!0),c(null),e.io.connect())}}}var wu=4,Tu=200,Eu=5e3,Du=[`sessions`,`branches`,`boards`,`boardObjects`,`cards`,`comments`],Ou=()=>({sessions:0,branches:0,boards:0,boardObjects:0,cards:0,comments:0,mcpServers:0,sessionMcp:0,gatewayChannels:0,artifacts:0,oauth:0}),ku=Ou(),Au=Ou(),ju=e=>{ku[e]+=1},Mu=()=>{for(let e of Du)ku[e]+=1},Nu=()=>{ku=Ou()},Pu=()=>{for(let e of Object.keys(Au))Au[e]+=1},Fu=()=>{for(let e of Object.keys(Au))Au[e]+=1,ku[e]+=1};async function Iu(e,t,n,r){let i=t.map(e=>Au[e]+=1),a=()=>t.every((e,t)=>Au[e]===i[t]),o=e=>e<wu?0:Math.min(Tu*2**(e-wu),Eu);for(let i=0;;i++){let s=o(i);if(s>0&&(await new Promise(e=>setTimeout(e,s)),!a()))return;let c=t.map(e=>ku[e]),l;try{l=await n()}catch(t){if(console.warn(`[useAgorData] background ${e} fetch failed:`,t),!a())return;continue}if(!a())return;if(!t.some((e,t)=>ku[e]!==c[t])){r(l);return}}}var Lu=(e,t)=>$.getState().setMap(e,t),Ru=e=>$.getState().applyMaps(e),zu=e=>$.getState().evictBranchAndSessions(e);function Bu(e){ju(`sessions`),!e.archived&&(Lu(`sessionById`,t=>{if(t.has(e.session_id))return t;let n=new Map(t);return n.set(e.session_id,e),n}),Lu(`sessionsByBranch`,t=>{let n=t.get(e.branch_id)||[];if(n.some(t=>t.session_id===e.session_id))return t;let r=new Map(t);return r.set(e.branch_id,[...n,e]),r}))}function Vu(e){ju(`sessions`);let t=e.archived===!0,n=null;Lu(`sessionById`,r=>{let i=r.get(e.session_id);if(n=i?.branch_id||null,t){if(!i)return r;let t=new Map(r);return t.delete(e.session_id),t}let a=yc(e,i);if(i&&sc(i,a))return r;let o=new Map(r);return o.set(e.session_id,a),o}),Lu(`sessionsByBranch`,r=>{let i=!1,a=new Map(r),o=e.branch_id,s=t=>{let n=a.get(t)||[],r=n.filter(t=>t.session_id!==e.session_id);r.length!==n.length&&(i=!0,r.length>0?a.set(t,r):a.delete(t))};if(t){for(let[t,n]of a)n.some(t=>t.session_id===e.session_id)&&s(t);return i?a:r}n&&n!==o&&s(n);let c=a.get(o)||[],l=c.findIndex(t=>t.session_id===e.session_id),u=e;if(l===-1)a.set(o,[...c,e]);else{let t=yc(e,c[l]);if(u=t,c[l]===t||sc(c[l],t))return i?a:r;let n=[...c];n[l]=t,a.set(o,n);for(let[t,n]of a){if(t===o)continue;let r=!1,i=n.map(t=>t.session_id===e.session_id?(r=!0,{...yc(e,t),branch_id:t.branch_id,genealogy:t.genealogy,remote_surrogate:t.remote_surrogate}):t);r&&a.set(t,i)}}for(let e of u.remote_relationships?.as_source??[]){if(e.relationship_type!==`remote_create`)continue;let t=xc(a,e.target_session_id);if(!t)continue;let n=a.get(u.branch_id)??[];if(n.some(e=>e.session_id===t.session_id))continue;let r=bc(u,t,e);r&&a.set(u.branch_id,[...n,r])}return a})}function Hu(e){ju(`sessions`),Lu(`sessionById`,t=>{if(!t.has(e.session_id))return t;let n=new Map(t);return n.delete(e.session_id),n}),Lu(`sessionsByBranch`,t=>{let n=t.get(e.branch_id);if(!n?.some(t=>t.session_id===e.session_id))return t;let r=new Map(t),i=n.filter(t=>t.session_id!==e.session_id);return i.length>0?r.set(e.branch_id,i):r.delete(e.branch_id),r})}function Uu(e){ju(`boards`),Lu(`boardById`,t=>{if(t.has(e.board_id))return t;let n=new Map(t);return n.set(e.board_id,e),n})}function Wu(e){ju(`boards`),Lu(`boardById`,t=>dc(t,e.board_id,e))}function Gu(e){ju(`boards`),Lu(`boardById`,t=>{if(!t.has(e.board_id))return t;let n=new Map(t);return n.delete(e.board_id),n})}function Ku(e){ju(`boardObjects`),Ru(t=>_c(t,e,`create`))}function qu(e){ju(`boardObjects`),Ru(t=>_c(t,e,`patch`))}function Ju(e){ju(`boardObjects`),Ru(t=>vc(t,e))}function Yu(e){Lu(`repoById`,t=>{if(t.has(e.repo_id))return t;let n=new Map(t);return n.set(e.repo_id,e),n})}function Xu(e){Lu(`repoById`,t=>dc(t,e.repo_id,e))}function Zu(e){Lu(`repoById`,t=>{if(!t.has(e.repo_id))return t;let n=new Map(t);return n.delete(e.repo_id),n})}function Qu(e){ju(`branches`),!e.archived&&Lu(`branchById`,t=>{if(t.has(e.branch_id))return t;let n=new Map(t);return n.set(e.branch_id,e),n})}function $u(e){if(ju(`branches`),e.archived){ju(`sessions`),zu(e.branch_id);return}Lu(`branchById`,t=>dc(t,e.branch_id,e))}function ed(e){ju(`branches`),ju(`sessions`),zu(e.branch_id)}function td(e){Lu(`userById`,t=>{if(t.has(e.user_id))return t;let n=new Map(t);return n.set(e.user_id,e),n})}function nd(e){Lu(`userById`,t=>dc(t,e.user_id,e))}function rd(e){Lu(`userById`,t=>{if(!t.has(e.user_id))return t;let n=new Map(t);return n.delete(e.user_id),n})}function id(e){ju(`mcpServers`),Lu(`mcpServerById`,t=>{if(t.has(e.mcp_server_id))return t;let n=new Map(t);return n.set(e.mcp_server_id,e),n})}function ad(e){ju(`mcpServers`),Lu(`mcpServerById`,t=>dc(t,e.mcp_server_id,e))}function od(e){ju(`mcpServers`),Lu(`mcpServerById`,t=>{if(!t.has(e.mcp_server_id))return t;let n=new Map(t);return n.delete(e.mcp_server_id),n})}function sd(e){ju(`gatewayChannels`),Lu(`gatewayChannelById`,t=>{if(t.has(e.id))return t;let n=new Map(t);return n.set(e.id,e),n})}function cd(e){ju(`gatewayChannels`),Lu(`gatewayChannelById`,t=>dc(t,e.id,e))}function ld(e){ju(`gatewayChannels`),Lu(`gatewayChannelById`,t=>{if(!t.has(e.id))return t;let n=new Map(t);return n.delete(e.id),n})}function ud(e){ju(`cards`),Lu(`cardById`,t=>{if(t.has(e.card_id))return t;let n=new Map(t);return n.set(e.card_id,e),n})}function dd(e){ju(`cards`),Lu(`cardById`,t=>dc(t,e.card_id,e))}function fd(e){ju(`cards`),Lu(`cardById`,t=>{if(!t.has(e.card_id))return t;let n=new Map(t);return n.delete(e.card_id),n})}function pd(e){Lu(`cardTypeById`,t=>{if(t.has(e.card_type_id))return t;let n=new Map(t);return n.set(e.card_type_id,e),n})}function md(e){Lu(`cardTypeById`,t=>dc(t,e.card_type_id,e))}function hd(e){Lu(`cardTypeById`,t=>{if(!t.has(e.card_type_id))return t;let n=new Map(t);return n.delete(e.card_type_id),n})}function gd(e){ju(`artifacts`),Lu(`artifactById`,t=>{if(t.has(e.artifact_id))return t;let n=new Map(t);return n.set(e.artifact_id,e),n})}function _d(e){ju(`artifacts`),Lu(`artifactById`,t=>dc(t,e.artifact_id,e)),window.dispatchEvent(new CustomEvent(`agor:artifact-patched`,{detail:{artifactId:e.artifact_id,contentHash:e.content_hash}}))}function vd(e){ju(`artifacts`),Lu(`artifactById`,t=>{if(!t.has(e.artifact_id))return t;let n=new Map(t);return n.delete(e.artifact_id),n})}function yd(e){ju(`sessionMcp`),Lu(`sessionMcpServerIds`,t=>{let n=t.get(e.session_id)||[];if(n.includes(e.mcp_server_id))return t;let r=new Map(t);return r.set(e.session_id,[...n,e.mcp_server_id]),r})}function bd(e){ju(`sessionMcp`),Lu(`sessionMcpServerIds`,t=>{let n=t.get(e.session_id)||[],r=n.filter(t=>t!==e.mcp_server_id);if(r.length===n.length)return t;let i=new Map(t);return r.length>0?i.set(e.session_id,r):i.delete(e.session_id),i})}function xd(e){ju(`comments`),Lu(`commentById`,t=>{if(t.has(e.comment_id))return t;let n=new Map(t);return n.set(e.comment_id,e),n})}function Sd(e){ju(`comments`),Lu(`commentById`,t=>dc(t,e.comment_id,e))}function Cd(e){ju(`comments`),Lu(`commentById`,t=>{if(!t.has(e.comment_id))return t;let n=new Map(t);return n.delete(e.comment_id),n})}var wd=`agor.debug.initialLoad`;function Td(){return typeof window>`u`?null:window}function Ed(){return typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now()}function Dd(e){return Math.round(e*10)/10}function Od(e){return e instanceof Error?e.message:String(e)}function kd(e=Td()){if(!e)return!1;let t=null;try{t=new URLSearchParams(e.location.search).get(`debugLoad`)}catch{t=null}try{return t===`1`?e.localStorage.setItem(wd,`1`):t===`0`&&e.localStorage.removeItem(wd),e.localStorage.getItem(wd)===`1`}catch{return t===`1`}}function Ad(){return kd()}function jd(e){let t=Ed(),n=new Date().toISOString(),r=new Map(e.map(e=>[e.key,e.label])),i=[],a=[],o=null,s=null,c=null,l=null;return{markStage:e=>{a.push({stage:e,atMs:Dd(Ed()-t)})},startFetchPhase(){o=Ed()},endFetchPhase(){s=Ed()},startIndexing(){c=Ed()},endIndexing(){l=Ed()},track(e,t){let n=Ed();return t.then(t=>(i.push({key:e,label:r.get(e)??e,durationMs:Dd(Ed()-n),count:t.length,status:`success`}),t),t=>{throw i.push({key:e,label:r.get(e)??e,durationMs:Dd(Ed()-n),count:null,status:`error`,error:Od(t)}),t})},finish(e,r){let u={label:`Agor initial load`,startedAt:n,totalMs:Dd(Ed()-t),fetchPhaseMs:o===null?null:Dd((s??Ed())-o),indexingMs:c===null?null:Dd((l??Ed())-c),status:e,error:r===void 0?void 0:Od(r),fetches:[...i].sort((e,t)=>e.key.localeCompare(t.key)),stageTransitions:[...a]},d=Td();return d&&(d.__AGOR_INITIAL_LOAD_TIMINGS__=u),typeof console<`u`&&((console.groupCollapsed??console.group)?.call(console,`[Agor initial load]`,{status:u.status,totalMs:u.totalMs,fetchPhaseMs:u.fetchPhaseMs,indexingMs:u.indexingMs}),console.table?.(u.fetches),u.stageTransitions.length>0&&console.log(`stageTransitions`,u.stageTransitions),u.error&&console.warn(`[Agor initial load] failed`,u.error),console.log(`Copy from window.__AGOR_INITIAL_LOAD_TIMINGS__`,u),console.groupEnd?.()),u}}}function Md(e,t,n,r){let i=gt(e,Array.from(t,e=>({id:n(e)})));return i.length===0?null:i.length===1?i[0].id:(r?.(e,i.length),null)}function Nd(e,t,n){for(let n of t.values())if(n.slug===e)return n.board_id;return Md(e,t.values(),e=>e.board_id,n)}function Pd(e,t,n){return Md(e,t.values(),e=>e.session_id,n)}function Fd(e,t,n){return Md(e,t.values(),e=>e.branch_id,n)}function Id(e,t,n){return Md(e,t.values(),e=>e.artifact_id,n)}var Ld=[{key:`sessions`,label:`Sessions`},{key:`boards`,label:`Boards`},{key:`board-objects`,label:`Board objects`},{key:`board-comments`,label:`Board comments`},{key:`branches`,label:`Branches`},{key:`repos`,label:`Repos`},{key:`users`,label:`Users`},{key:`cards`,label:`Cards`},{key:`card-types`,label:`Card types`}],Rd=50,zd=RegExp(`/(${Ft.board}|${Ft.session}|${Ft.branch}|${Ft.artifact})/([^/]+)`);function Bd(e){let t=e.match(zd);if(!t)return null;let[,n,r]=t;return{kind:n===Ft.board?`board`:n===Ft.session?`session`:n===Ft.branch?`branch`:`artifact`,token:r}}var Vd=/\/m\/comments\/([^/]+)/;function Hd(e,t,n,r){let i=e.match(Vd);if(i)return Nd(i[1],t);let a=Bd(e);if(!a)return null;switch(a.kind){case`board`:return Nd(a.token,t);case`session`:{let e=Pd(a.token,r);if(!e)return null;let t=r.get(e);if(!t)return null;if(t.branch_board_id)return t.branch_board_id;let i=t.branch_id;return i?n.get(i)?.board_id??null:null}case`branch`:{let e=Fd(a.token,n);return e?n.get(e)?.board_id??null:null}default:return null}}function Ud(e,t,n){return gt(e,Array.from(t,e=>({id:n(e)}))).length>0}function Wd(e,t){let n=t?.enabled??!0,r=t?.directSessionId??null;(0,Z.useState)(()=>($.getState().reset(),Nu(),Pu(),null));let i=kc($,e=>({loadingStage:e.loadingStage,loading:e.loading,error:e.error,itemCounts:e.itemCounts}),Ec),[a,o]=(0,Z.useState)(!1),s=(0,Z.useRef)(!1),c=(0,Z.useRef)(!1),l=(0,Z.useCallback)(async({silent:t=!1}={})=>{if(!e||!n)return;let i=!t&&Ad()?jd(Ld):null,a=null,o;try{t||($.getState().setLoading(!0),$.getState().setLoadingStage(`fetching`),i?.markStage(`fetching`),$.getState().setError(null),$.getState().setItemCounts({}));let n=(e,n)=>(i?.track(e,n)??n).then(n=>(t||$.getState().setItemCounts(t=>({...t,[e]:n.length})),n));Iu(`mcp-servers`,[`mcpServers`],()=>e.service(`mcp-servers`).findAll({query:{$limit:Nt.DEFAULT_LIMIT}}),e=>$.getState().applyMaps(t=>({...t,mcpServerById:fc(e,`mcp_server_id`)}))),Iu(`session-mcp-servers`,[`sessionMcp`],()=>e.service(`session-mcp-servers`).findAll({query:{$limit:Nt.DEFAULT_LIMIT}}),e=>$.getState().applyMaps(t=>({...t,sessionMcpServerIds:pc(e)}))),Iu(`gateway-channels`,[`gatewayChannels`],()=>e.service(`gateway-channels`).findAll({query:{$limit:Nt.DEFAULT_LIMIT}}),e=>$.getState().applyMaps(t=>({...t,gatewayChannelById:fc(e,`id`)}))),Iu(`artifacts`,[`artifacts`],()=>e.service(`artifacts`).findAll({query:{$limit:Nt.DEFAULT_LIMIT,$select:[`artifact_id`,`branch_id`,`source_session_id`,`board_id`,`name`,`description`,`path`,`template`,`build_status`,`build_errors`,`content_hash`,`public`,`created_by`,`created_at`,`updated_at`,`archived`,`archived_at`,`fullscreen_url`,`url`]}}),e=>$.getState().applyMaps(t=>({...t,artifactById:fc(e,`artifact_id`)}))),Iu(`oauth-status`,[`oauth`],()=>e.service(`mcp-servers/oauth-status`).find(),e=>{let t=e?.authenticated_server_ids??[];$.getState().applyMaps(e=>({...e,userAuthenticatedMcpServerIds:new Set(t)}))}),i?.startFetchPhase();let[o,s,l,u,d]=await Promise.all([n(`sessions`,t?e.service(`sessions`).findAll({query:{archived:!1,$limit:Nt.DEFAULT_LIMIT,$sort:{updated_at:-1}}}):e.service(`sessions`).find({query:{archived:!1,$limit:Rd,$sort:{updated_at:-1}}}).then(e=>Array.isArray(e)?e:e.data)),n(`boards`,e.service(`boards`).findAll({query:{...t?{}:{lean:!0},$limit:Nt.DEFAULT_LIMIT}})),n(`card-types`,e.service(`card-types`).findAll({query:{$limit:Nt.DEFAULT_LIMIT}})),n(`repos`,e.service(`repos`).findAll({query:{$limit:Nt.DEFAULT_LIMIT}})),n(`users`,e.service(`users`).findAll({query:{$limit:Nt.DEFAULT_LIMIT}}))]),f=[];if(r&&!Ud(r,o,e=>e.session_id))try{let t=await e.service(`sessions`).get(r);if(o.some(e=>e.session_id===t.session_id)||o.push(t),!t.archived&&t.branch_id)try{let n=await e.service(`branches`).get(t.branch_id);n.archived||f.push(n)}catch{}}catch{}let p=typeof window<`u`?window.location.pathname:``;if(!t){let t=Bd(p);if(t?.kind===`branch`&&!Ud(t.token,f,e=>e.branch_id))try{let n=await e.service(`branches`).get(t.token);n.archived||f.push(n)}catch{}}let m=new Map;for(let e of s)m.set(e.board_id,e);let h=new Map;for(let e of l)h.set(e.card_type_id,e);let g=new Map;for(let e of u)g.set(e.repo_id,e);let _=new Map;for(let e of d)_.set(e.user_id,e);let v=new Map;for(let e of f)v.set(e.branch_id,e);let y=hc(o).sessionById,b=t?void 0:Hd(p,m,v,y)??void 0,[x,S,C,w,T,E]=await Promise.all([n(`branches`,t?e.service(`branches`).findAll({query:{archived:!1,$limit:Nt.DEFAULT_LIMIT}}):b?e.service(`branches`).findAll({query:{archived:!1,board_id:b,$limit:Nt.DEFAULT_LIMIT}}):Promise.resolve([])),!t&&b?e.service(`sessions`).findAll({query:{archived:!1,board_id:b,$limit:Nt.DEFAULT_LIMIT,$sort:{updated_at:-1}}}):Promise.resolve([]),n(`board-objects`,e.service(`board-objects`).findAll({query:{$limit:Nt.DEFAULT_LIMIT,...b?{board_id:b}:{}}})),n(`board-comments`,e.service(`board-comments`).findAll({query:{$limit:Nt.DEFAULT_LIMIT,...b?{board_id:b}:{}}})),n(`cards`,e.service(`cards`).findAll({query:{$limit:Nt.DEFAULT_LIMIT,...b?{board_id:b}:{}}})),!t&&b?e.service(`boards`).get(b).catch(()=>null):Promise.resolve(null)]);i?.endFetchPhase(),t||($.getState().setLoadingStage(`indexing`),i?.markStage(`indexing`),i?.startIndexing(),await new Promise(e=>{if(typeof window>`u`||typeof window.requestAnimationFrame!=`function`){e();return}window.requestAnimationFrame(()=>e())}));let{boardObjectById:D,boardObjectsByBoardId:O,boardObjectByBranchId:k,boardObjectByCardId:A}=mc(C),j=new Map;for(let e of w)j.set(e.comment_id,e);let M=new Map;for(let e of T)M.set(e.card_id,e);E&&m.set(E.board_id,E);let N=new Map;for(let e of o)N.set(e.session_id,e);for(let e of S)N.has(e.session_id)||N.set(e.session_id,e);let{sessionById:P,sessionsByBranch:F}=hc([...N.values()]),I=new Map;for(let e of x)I.set(e.branch_id,e);for(let e of f)I.has(e.branch_id)||I.set(e.branch_id,e);$.getState().applyMaps(e=>({...e,sessionById:P,sessionsByBranch:F,boardById:m,boardObjectById:D,boardObjectsByBoardId:O,boardObjectByBranchId:k,boardObjectByCardId:A,commentById:j,cardById:M,cardTypeById:h,repoById:g,branchById:I,userById:_})),Mu(),i?.endIndexing(),a=`success`,t||(Iu(`sessions`,[`sessions`],()=>e.service(`sessions`).findAll({query:{archived:!1,$limit:Nt.DEFAULT_LIMIT,$sort:{updated_at:-1}}}),e=>$.getState().applyMaps(t=>{let n=new Map;for(let t of e)n.set(t.session_id,t);for(let[e,r]of t.sessionById)r.archived&&!n.has(e)&&n.set(e,r);let{sessionById:r,sessionsByBranch:i}=hc([...n.values()]);return{...t,sessionById:r,sessionsByBranch:i}})),Iu(`branches`,[`branches`],()=>e.service(`branches`).findAll({query:{archived:!1,$limit:Nt.DEFAULT_LIMIT}}),e=>$.getState().applyMaps(t=>({...t,branchById:fc(e,`branch_id`)})))),b&&(Iu(`board-objects`,[`boardObjects`],()=>e.service(`board-objects`).findAll({query:{$limit:Nt.DEFAULT_LIMIT}}),e=>$.getState().applyMaps(t=>{let n=mc(e);return{...t,boardObjectById:n.boardObjectById,boardObjectsByBoardId:n.boardObjectsByBoardId,boardObjectByBranchId:n.boardObjectByBranchId,boardObjectByCardId:n.boardObjectByCardId}})),Iu(`cards`,[`cards`],()=>e.service(`cards`).findAll({query:{$limit:Nt.DEFAULT_LIMIT}}),e=>$.getState().applyMaps(t=>({...t,cardById:fc(e,`card_id`)}))),Iu(`board-comments`,[`comments`],()=>e.service(`board-comments`).findAll({query:{$limit:Nt.DEFAULT_LIMIT}}),e=>$.getState().applyMaps(t=>({...t,commentById:fc(e,`comment_id`)})))),t||Iu(`boards`,[`boards`],()=>e.service(`boards`).findAll({query:{$limit:Nt.DEFAULT_LIMIT}}),e=>$.getState().applyMaps(t=>({...t,boardById:fc(e,`board_id`)}))),t&&(c.current=!1)}catch(e){t?(console.warn(`[useAgorData] silent refetch failed:`,e),c.current=!0):(a=`error`,o=e,$.getState().setError(e instanceof Error?e.message:`Failed to fetch data`))}finally{t||($.getState().setLoading(!1),$.getState().setLoadingStage(`idle`),i?.markStage(`idle`),a&&i?.finish(a,o))}},[e,r,n]);return(0,Z.useEffect)(()=>{e||(Fu(),$.getState().resetMaps(),o(!1))},[e]),(0,Z.useEffect)(()=>()=>Pu(),[]),(0,Z.useEffect)(()=>{if(!e||!n||!a||!r)return;let{sessionById:t}=$.getState();if(t.has(r)||Ud(r,t.values(),e=>e.session_id))return;let i=!1;return(async()=>{try{let t=await e.service(`sessions`).get(r);if(i)return;if(ju(`sessions`),$.getState().setMap(`sessionById`,e=>{if(e.has(t.session_id))return e;let n=new Map(e);return n.set(t.session_id,t),n}),t.archived||$.getState().setMap(`sessionsByBranch`,e=>{let n=e.get(t.branch_id)||[];if(n.some(e=>e.session_id===t.session_id))return e;let r=new Map(e);return r.set(t.branch_id,[...n,t]),r}),!t.archived&&t.branch_id&&!$.getState().branchById.has(t.branch_id))try{let n=await e.service(`branches`).get(t.branch_id);if(i)return;ju(`branches`),$.getState().setMap(`branchById`,e=>{if(n.archived||e.has(n.branch_id))return e;let t=new Map(e);return t.set(n.branch_id,n),t})}catch{}}catch{}})(),()=>{i=!0}},[e,r,n,a]),(0,Z.useEffect)(()=>{if(!e||!n){$.getState().setLoading(!1),$.getState().setLoadingStage(`idle`);return}let t=e.service(`sessions`);t.on(`created`,Bu),t.on(`patched`,Vu),t.on(`updated`,Vu),t.on(`removed`,Hu);let r=e.service(`boards`);r.on(`created`,Uu),r.on(`patched`,Wu),r.on(`updated`,Wu),r.on(`removed`,Gu);let i=e.service(`board-objects`);i.on(`created`,Ku),i.on(`patched`,qu),i.on(`updated`,qu),i.on(`removed`,Ju);let u=e.service(`repos`);u.on(`created`,Yu),u.on(`patched`,Xu),u.on(`updated`,Xu),u.on(`removed`,Zu);let d=e.service(`branches`);d.on(`created`,Qu),d.on(`patched`,$u),d.on(`updated`,$u),d.on(`removed`,ed);let f=e.service(`users`);f.on(`created`,td),f.on(`patched`,nd),f.on(`updated`,nd),f.on(`removed`,rd);let p=e.service(`mcp-servers`);p.on(`created`,id),p.on(`patched`,ad),p.on(`updated`,ad),p.on(`removed`,od);let m=e.service(`gateway-channels`);m.on(`created`,sd),m.on(`patched`,cd),m.on(`updated`,cd),m.on(`removed`,ld);let h=e.service(`cards`);h.on(`created`,ud),h.on(`patched`,dd),h.on(`updated`,dd),h.on(`removed`,fd);let g=e.service(`card-types`);g.on(`created`,pd),g.on(`patched`,md),g.on(`updated`,md),g.on(`removed`,hd);let _=e.service(`artifacts`);_.on(`created`,gd),_.on(`patched`,_d),_.on(`updated`,_d),_.on(`removed`,vd);let v=e=>{window.dispatchEvent(new CustomEvent(`agor:artifact-runtime-query`,{detail:e}))};_.on(`agor-query`,v);let y=e.service(`session-mcp-servers`);y.on(`created`,yd),y.on(`removed`,bd);let b=e.service(`board-comments`);b.on(`created`,xd),b.on(`patched`,Sd),b.on(`updated`,Sd),b.on(`removed`,Cd);let x=async t=>{if(!(!t.success||!t.mcp_server_id)){ju(`oauth`),(t.oauth_mode||`per_user`)===`per_user`&&$.getState().setMap(`userAuthenticatedMcpServerIds`,e=>{if(e.has(t.mcp_server_id))return e;let n=new Set(e);return n.add(t.mcp_server_id),n});try{let n=await e.service(`mcp-servers`).get(t.mcp_server_id);ju(`mcpServers`),$.getState().setMap(`mcpServerById`,e=>dc(e,n.mcp_server_id,n))}catch(e){console.warn(`[OAuth] Failed to refetch MCP server after re-auth:`,e)}}};e.io.on(`oauth:completed`,x);let S=async t=>{if(t.mcp_server_id){ju(`oauth`),ju(`mcpServers`),$.getState().setMap(`userAuthenticatedMcpServerIds`,e=>{if(!e.has(t.mcp_server_id))return e;let n=new Set(e);return n.delete(t.mcp_server_id),n}),$.getState().setMap(`mcpServerById`,e=>{let n=e.get(t.mcp_server_id);if(!n?.auth?.oauth_access_token)return e;let r=new Map(e);return r.set(t.mcp_server_id,{...n,auth:{...n.auth,oauth_access_token:void 0,oauth_token_expires_at:void 0}}),r});try{let n=await e.service(`mcp-servers`).get(t.mcp_server_id);$.getState().setMap(`mcpServerById`,e=>dc(e,n.mcp_server_id,n))}catch(e){console.warn(`[OAuth] Failed to refetch MCP server after disconnect:`,e)}}};e.io.on(`oauth:disconnected`,S);let C=async()=>{if(a&&!s.current){s.current=!0;try{await l({silent:!0})}finally{s.current=!1}}};e.io.on(`connect`,C);let w=()=>{c.current&&C()};return window.addEventListener(mu,w),a||l().then(()=>o(!0)),()=>{e.io.off(`oauth:completed`,x),e.io.off(`oauth:disconnected`,S),e.io.off(`connect`,C),window.removeEventListener(mu,w),t.removeListener(`created`,Bu),t.removeListener(`patched`,Vu),t.removeListener(`updated`,Vu),t.removeListener(`removed`,Hu),r.removeListener(`created`,Uu),r.removeListener(`patched`,Wu),r.removeListener(`updated`,Wu),r.removeListener(`removed`,Gu),i.removeListener(`created`,Ku),i.removeListener(`patched`,qu),i.removeListener(`updated`,qu),i.removeListener(`removed`,Ju),u.removeListener(`created`,Yu),u.removeListener(`patched`,Xu),u.removeListener(`updated`,Xu),u.removeListener(`removed`,Zu),d.removeListener(`created`,Qu),d.removeListener(`patched`,$u),d.removeListener(`updated`,$u),d.removeListener(`removed`,ed),f.removeListener(`created`,td),f.removeListener(`patched`,nd),f.removeListener(`updated`,nd),f.removeListener(`removed`,rd),p.removeListener(`created`,id),p.removeListener(`patched`,ad),p.removeListener(`updated`,ad),p.removeListener(`removed`,od),y.removeListener(`created`,yd),y.removeListener(`removed`,bd),b.removeListener(`created`,xd),b.removeListener(`patched`,Sd),b.removeListener(`updated`,Sd),b.removeListener(`removed`,Cd),m.removeListener(`created`,sd),m.removeListener(`patched`,cd),m.removeListener(`updated`,cd),m.removeListener(`removed`,ld),h.removeListener(`created`,ud),h.removeListener(`patched`,dd),h.removeListener(`updated`,dd),h.removeListener(`removed`,fd),g.removeListener(`created`,pd),g.removeListener(`patched`,md),g.removeListener(`updated`,md),g.removeListener(`removed`,hd),_.removeListener(`created`,gd),_.removeListener(`patched`,_d),_.removeListener(`updated`,_d),_.removeListener(`removed`,vd),_.removeListener(`agor-query`,v)}},[e,n,l,a]),{initialLoadItems:(0,Z.useMemo)(()=>Ld.map(({key:e,label:t})=>{let n=i.itemCounts[e];return{key:e,label:t,done:n!==void 0,count:n??0}}),[i.itemCounts]),initialLoadComplete:Ld.every(({key:e})=>i.itemCounts[e]!==void 0),loadingStage:i.loadingStage,loading:i.loading,error:i.error,refetch:l}}function Gd(e){let t=e.split(`.`);if(t.length!==3)return null;let n=t[1];if(!n)return null;try{let e=Yd(n),t=JSON.parse(e);if(t&&typeof t==`object`&&`exp`in t){let e=t.exp;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return e}return null}catch{return null}}function Kd(e){let t=Gd(e);return t===null?null:t*1e3}function qd(e,t=Date.now()){let n=Kd(e);return n===null?null:n-t}function Jd(e,t){let n=qd(e);return n===null?!0:n<=t}function Yd(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t+`=`.repeat((4-t.length%4)%4);if(typeof Buffer<`u`)return Buffer.from(n,`base64`).toString(`utf8`);let r=globalThis.atob(n),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e);return new TextDecoder().decode(i)}var Xd=`launch_code`;function Zd(e){let t=new URLSearchParams(e).get(Xd);return t?.trim()?t:null}function Qd(){if(typeof window>`u`)return;let e=new URL(window.location.href);e.searchParams.has(`launch_code`)&&(e.searchParams.delete(Xd),window.history.replaceState(window.history.state,document.title,`${e.pathname}${e.search}${e.hash}`))}async function $d(e,t){let n=await e.service(`auth/launch`).create({launchCode:t});return lu(n.accessToken,n.refreshToken),n}var ef=`The Agor server returned an unexpected response while signing in. Check that the daemon URL is correct and the server is reachable, then try again.`;function tf(e){if(!e||typeof e!=`object`)return!1;let t=e instanceof Error?e.message:String(e.message??``);return/json parsing error/i.test(t)||/unexpected token.*json/i.test(t)}function nf(e){return tf(e)?ef:au(e)?`Unable to reach the Agor server. Check your connection and try again.`:e instanceof Error?e.message:`Login failed`}function rf(){let[e,t]=(0,Z.useState)({user:null,accessToken:null,authenticated:!1,loading:!0,error:null}),n=(0,Z.useCallback)(async(e=0,r)=>{t(e=>({...e,loading:!0,error:null}));let i=du(),a=uu(),o=!!i||!!a,s=r||(typeof window<`u`?Zd(window.location.search):null),c=!1,l=!1;async function u(e){if(!i&&!a)return!1;if(i)try{let n=await e.authenticate({strategy:`jwt`,accessToken:i});return t({user:n.user,accessToken:n.accessToken,authenticated:!0,loading:!1,error:null}),!0}catch(e){if(!iu(e))throw e}if(a)try{let n=await xu(e,a);return t({user:n.user,accessToken:n.accessToken,authenticated:!0,loading:!1,error:null}),!0}catch(e){if(!iu(e)&&!(e instanceof yu))throw e}return!1}try{let r=await Ut(nu());if(s){c=!0,Qd();try{let e=await $d(r,s);bu(),t({user:e.user,accessToken:e.accessToken,authenticated:!0,loading:!1,error:null}),hu(e);return}catch(t){if(au(t)&&e<5){let t=Math.min(2e3*1.5**e,1e4);return await new Promise(e=>setTimeout(e,t)),n(e+1,s)}if(l=!0,!o)throw t;console.warn(`Launch sign-in failed; falling back to stored auth tokens:`,t)}}if(!o){t({user:null,accessToken:null,authenticated:!1,loading:!1,error:l?`Launch sign-in failed. The one-time launch code may have expired or already been used.`:null});return}if(await u(r))return;fu(),t({user:null,accessToken:null,authenticated:!1,loading:!1,error:l?`Launch sign-in failed. The one-time launch code may have expired or already been used.`:null})}catch(r){let i=au(r);if(i&&e<5){let t=Math.min(2e3*1.5**e,1e4);return await new Promise(e=>setTimeout(e,t)),n(e+1,c&&s||void 0)}if(iu(r)&&!i&&!(c&&o)&&(console.error(`Authentication failure, clearing tokens:`,r),fu()),c&&o)try{if(await u(await Ut(nu())))return}catch(e){console.warn(`Stored-token fallback after launch sign-in failure also failed:`,e)}t({user:null,accessToken:null,authenticated:!1,loading:!1,error:i?`Connection lost - waiting for daemon...`:c?`Launch sign-in failed. The one-time launch code may have expired or already been used.`:null})}},[]);(0,Z.useEffect)(()=>{n()},[n]),(0,Z.useEffect)(()=>{let t=async()=>{if(document.visibilityState!==`visible`)return;if(!e.authenticated){(du()||uu())&&n();return}let t=du();if(!t||!Jd(t,6e4))return;let r=uu();if(r)try{await xu(await Ut(nu()),r)}catch(e){if(e instanceof yu)return;au(e)||n()}};return document.addEventListener(`visibilitychange`,t),()=>document.removeEventListener(`visibilitychange`,t)},[e.authenticated,n]),(0,Z.useEffect)(()=>{if(e.authenticated||e.loading||!(du()||uu()))return;let t=setInterval(()=>{n()},3e3);return()=>clearInterval(t)},[e.authenticated,e.loading,n]),(0,Z.useEffect)(()=>{if(!e.authenticated||!e.accessToken)return;let n=qd(e.accessToken),r=n===null?3e5:Math.max(1e3,n-6e4),i=setTimeout(async()=>{let e=uu();if(e)try{await xu(await Ut(nu()),e)}catch(e){if(e instanceof yu)return;console.error(`Failed to auto-refresh token:`,e),au(e)?t(e=>({...e,error:`Connection lost - waiting for daemon...`})):(fu(),t({user:null,accessToken:null,authenticated:!1,loading:!1,error:`Session expired, please login again`}))}},r);return()=>clearTimeout(i)},[e.authenticated,e.accessToken]),(0,Z.useEffect)(()=>{let e=e=>{let n=e.detail;n&&t(e=>({...e,accessToken:n.accessToken,user:n.user,authenticated:!0}))};return window.addEventListener(mu,e),()=>window.removeEventListener(mu,e)},[]),(0,Z.useEffect)(()=>{let e=()=>{fu(),t({user:null,accessToken:null,authenticated:!1,loading:!1,error:`Session expired, please login again`})};return window.addEventListener(gu,e),()=>window.removeEventListener(gu,e)},[]);let r=async(e,n)=>{t(e=>({...e,loading:!0,error:null}));try{let r=await(await Ut(nu())).authenticate({strategy:`local`,email:e,password:n});return lu(r.accessToken,r.refreshToken),bu(),t({user:r.user,accessToken:r.accessToken,authenticated:!0,loading:!1,error:null}),hu(r),!0}catch(e){console.error(`❌ Login failed:`,e);let n=nf(e),r=e instanceof Error?e.message:`Login failed`;return console.error(`❌ Error message:`,r),t(e=>({...e,loading:!1,error:n})),!1}},i=async()=>{fu(),t({user:null,accessToken:null,authenticated:!1,loading:!1,error:null})};return{...e,login:r,logout:i,reAuthenticate:n}}function af(){let[e,t]=(0,Z.useState)(null),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(void 0),[c,l]=(0,Z.useState)(void 0),[u,d]=(0,Z.useState)(!0),[f,p]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{async function e(){try{let e=await fetch(`${nu()}/health`);if(!e.ok)throw Error(`Failed to fetch auth config: ${e.statusText}`);let n=await e.json();t(n.auth),r(n.instance??null),a(n.onboarding??null),s(n.services),l(n.features),p(null)}catch(e){p(e instanceof Error?e:Error(String(e))),t({requireAuth:!0}),r(null),a(null),s(void 0),l(void 0)}finally{d(!1)}}e()},[]),{config:e,instanceConfig:n,onboardingConfig:i,servicesConfig:o,featuresConfig:c,loading:u,error:f}}var of=({children:e,textContent:t})=>{let{token:n}=X.useToken(),[r,i]=Z.useState(`idle`),a=Z.useRef(null);Z.useEffect(()=>()=>{a.current&&clearTimeout(a.current)},[]);let o=async e=>{e.stopPropagation(),i(await Xa(t)?`copied`:`failed`),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(`idle`),1500)},s={cursor:`pointer`,marginLeft:n.marginSM,transition:`opacity 0.2s`,fontSize:n.fontSizeSM},c;return c=r===`copied`?(0,Q.jsx)(oe,{style:{...s,color:n.colorSuccess,opacity:1},title:`Copied!`}):r===`failed`?(0,Q.jsx)(ut,{style:{...s,color:n.colorError,opacity:1},title:`Copy failed`}):(0,Q.jsx)(E,{onClick:o,style:{...s,opacity:.65},onMouseEnter:e=>{e.currentTarget.style.opacity=`1`},onMouseLeave:e=>{e.currentTarget.style.opacity=`0.65`},title:`Copy to clipboard`}),(0,Q.jsxs)(G,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,width:`100%`},children:[(0,Q.jsx)(`span`,{style:{flex:1},children:e}),c]})};function sf(e){return typeof e==`string`?e:typeof e==`number`?String(e):Z.isValidElement(e)&&e.props.children?sf(e.props.children):Array.isArray(e)?e.map(sf).join(` `):String(e)}function cf(){let{message:e}=b.useApp(),t=(0,Z.useCallback)((t,n)=>e.success({content:(0,Q.jsx)(of,{textContent:sf(t),children:t}),duration:n?.duration??3,key:n?.key,onClose:n?.onClose}),[e]),n=(0,Z.useCallback)((t,n)=>e.error({content:(0,Q.jsx)(of,{textContent:sf(t),children:t}),duration:n?.duration??6,key:n?.key,onClose:n?.onClose}),[e]),r=(0,Z.useCallback)((t,n)=>e.warning({content:(0,Q.jsx)(of,{textContent:sf(t),children:t}),duration:n?.duration??4,key:n?.key,onClose:n?.onClose}),[e]),i=(0,Z.useCallback)((t,n)=>e.info({content:(0,Q.jsx)(of,{textContent:sf(t),children:t}),duration:n?.duration??3,key:n?.key,onClose:n?.onClose}),[e]),a=(0,Z.useCallback)((t,n)=>e.loading({content:(0,Q.jsx)(of,{textContent:sf(t),children:t}),duration:n?.duration??0,key:n?.key,onClose:n?.onClose}),[e]),o=(0,Z.useCallback)(t=>e.destroy(t),[e]);return(0,Z.useMemo)(()=>({showSuccess:t,showError:n,showWarning:r,showInfo:i,showLoading:a,destroy:o}),[t,n,r,i,a,o])}function lf(e){let[t,n]=(0,Z.useState)(!1),{showError:r}=cf();return{createBoard:async t=>{if(!e)return null;try{return n(!0),await e.service(`boards`).create(t)}catch(e){return r(`Failed to create board: ${e instanceof Error?e.message:String(e)}`),null}finally{n(!1)}},updateBoard:async(t,i)=>{if(!e)return null;try{return n(!0),await e.service(`boards`).patch(t,i)}catch(e){return r(`Failed to update board: ${e instanceof Error?e.message:String(e)}`),null}finally{n(!1)}},deleteBoard:async t=>{if(!e)return!1;try{return n(!0),await e.service(`boards`).remove(t),!0}catch(e){return r(`Failed to delete board: ${e instanceof Error?e.message:String(e)}`),!1}finally{n(!1)}},archiveBoard:async t=>{if(!e)return null;try{return n(!0),await e.service(`boards/${t}/archive`).create({})}catch(e){return r(`Failed to archive board: ${e instanceof Error?e.message:String(e)}`),null}finally{n(!1)}},unarchiveBoard:async t=>{if(!e)return null;try{return n(!0),await e.service(`boards/${t}/unarchive`).create({})}catch(e){return r(`Failed to unarchive board: ${e instanceof Error?e.message:String(e)}`),null}finally{n(!1)}},loading:t}}function uf(){let{modal:e}=b.useApp();return{confirm:t=>e.confirm(t),info:t=>e.info(t),warning:t=>e.warning(t),error:t=>e.error(t),success:t=>e.success(t)}}function df(){let{confirm:e}=uf(),{token:t}=X.useToken();return n=>e({title:`Nuke environment?`,icon:(0,Q.jsx)(Me,{style:{color:t.colorError}}),content:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{children:(0,Q.jsx)(`strong`,{children:`This is a destructive operation.`})}),(0,Q.jsx)(`p`,{children:`This typically removes all Docker volumes, databases, and other environment state. Source files in the branch are not deleted, but anything stored inside containers or volumes may be lost.`})]}),okText:`Nuke environment`,okType:`danger`,cancelText:`Cancel`,onOk:n})}function ff({connecting:e,loading:t,dataError:n,mustChangePassword:r,initialLoadComplete:i}){let[a,o]=(0,Z.useState)(`loading`);return(0,Z.useEffect)(()=>{!e&&!t&&a===`loading`&&(n||r?o(`done`):i&&o(`complete`))},[e,t,a,n,r,i]),(0,Z.useEffect)(()=>{if(a===`complete`){let e=setTimeout(()=>o(`fading`),250);return()=>clearTimeout(e)}if(a===`fading`){let e=setTimeout(()=>o(`done`),280);return()=>clearTimeout(e)}},[a]),a}function pf(e,t){if(typeof window>`u`)return t;try{let n=window.localStorage.getItem(e);return n?JSON.parse(n):t}catch(n){return console.error(`Error reading localStorage key "${e}":`,n),t}}function mf(e,t){if(!(typeof window>`u`))try{window.localStorage.setItem(e,JSON.stringify(t))}catch(t){console.error(`Error setting localStorage key "${e}":`,t)}}var hf=`agor-local-storage-change`;function gf(e,t){let n=(0,Z.useCallback)(()=>pf(e,t),[t,e]),[r,i]=(0,Z.useState)(n),a=(0,Z.useRef)(e);a.current=e;let o=(0,Z.useRef)(r);o.current=r;let s=(0,Z.useCallback)(e=>{try{let t=e instanceof Function?e(o.current):e;mf(a.current,t),i(t),typeof window<`u`&&window.dispatchEvent(new CustomEvent(hf,{detail:{key:a.current,value:t}}))}catch(e){console.error(`Error setting localStorage key "${a.current}":`,e)}},[]);return(0,Z.useEffect)(()=>{if(typeof window>`u`)return;let t=t=>{t.key===e&&i(n())},r=t=>{let n=t;n.detail?.key===e&&i(n.detail.value)};return window.addEventListener(`storage`,t),window.addEventListener(hf,r),()=>{window.removeEventListener(`storage`,t),window.removeEventListener(hf,r)}},[e,n]),[r,s]}function _f(){let{user:e}=rf(),t=e?.role;return(0,Z.useMemo)(()=>({role:t,isAdmin:mt(t,bt.ADMIN),isSuperAdmin:mt(t,bt.SUPERADMIN),hasRole:e=>mt(t,e)}),[t])}var vf=`agor:recentBoardIds`,yf=10;function bf(e,t){let[n,r]=gf(vf,[]),i=(0,Z.useCallback)(e=>{r(t=>[e,...t.filter(t=>t!==e)].slice(0,yf))},[r]);return{recentBoards:(0,Z.useMemo)(()=>{let r=new Map(e.map(e=>[e.board_id,e]));return n.filter(e=>e!==t&&r.has(e)).map(e=>r.get(e)).slice(0,3)},[n,t,e]),recentBoardIds:n,trackBoardVisit:i}}var xf=6e4;function Sf(e,t){return!e||!t||e===`dev`||t===`dev`?!1:e!==t}function Cf(e,t=nu(),n=xf){let[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),s=(0,Z.useRef)(null),c=(0,Z.useCallback)(e=>{e&&(o(e),s.current===null&&(s.current=e,i(e)))},[]);return(0,Z.useEffect)(()=>{let e=new AbortController,r=t.replace(/\/$/,``),i=()=>{fetch(`${r}/health`,{signal:e.signal}).then(e=>e.ok?e.json():null).then(e=>{typeof e?.buildSha==`string`&&c(e.buildSha)}).catch(()=>{})};i();let a=n>0?setInterval(i,n):null;return()=>{e.abort(),a!==null&&clearInterval(a)}},[t,n,c]),(0,Z.useEffect)(()=>{if(!e?.io)return;let t=e=>{typeof e?.buildSha==`string`&&c(e.buildSha)};return e.io.on(`server-info`,t),()=>{e.io.off(`server-info`,t)}},[e,c]),{capturedSha:r,currentSha:a,outOfSync:Sf(r,a)}}function wf(){return(0,Z.useContext)(Ul)}function Tf(e){return St(wf(),e)}function Ef(e){return xt(wf(),e)}function Df(e){let[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(null),a=async t=>{if(!e)return i(`Client not connected`),null;try{if(n(!0),i(null),!t.branch_id)throw Error(`Branch ID is required`);let r=t.agent,a=t.permissionMode||_t(r),o={mode:a};if(r===`codex`){let e=yt(a);o.codex={sandboxMode:t.codexSandboxMode??e.sandboxMode,approvalPolicy:t.codexApprovalPolicy??e.approvalPolicy,networkAccess:t.codexNetworkAccess??e.networkAccess}}return await e.service(`sessions`).create({agentic_tool:r,status:Rt.IDLE,title:t.title||void 0,description:t.initialPrompt||void 0,branch_id:t.branch_id,model_config:t.modelConfig?{...t.modelConfig,...t.effort&&{effort:t.effort},updated_at:new Date().toISOString()}:t.effort?{effort:t.effort,updated_at:new Date().toISOString()}:void 0,permission_config:o})}catch(e){return i(e instanceof Error?e.message:`Failed to create session`),console.error(`Failed to create session:`,e),null}finally{n(!1)}},o=async(t,r)=>{if(!e)throw i(`Client not connected`),Error(`Client not connected`);try{n(!0),i(null);let a=await e.service(`sessions/${t}/fork`).create({prompt:r});return r.trim()&&await e.sessions.prompt(a.session_id,r,{messageSource:`agor`}),a}catch(e){let t=e instanceof Error?e.message:`Failed to fork session`;throw i(t),console.error(`Failed to fork session:`,e),e instanceof Error?e:Error(t)}finally{n(!1)}},s=async(t,r)=>{if(!e)throw i(`Client not connected`),Error(`Client not connected`);try{n(!0),i(null);let a=await e.service(`sessions/${t}/fork`).create({prompt:r});return await e.service(`sessions`).patch(a.session_id,{fork_origin:`btw`}),r.trim()&&await e.sessions.prompt(a.session_id,r,{messageSource:`agor`}),a}catch(e){let t=e instanceof Error?e.message:`Failed to create btw fork`;throw i(t),console.error(`Failed to create btw fork:`,e),e instanceof Error?e:Error(t)}finally{n(!1)}},c=async(t,r)=>{if(!e)throw i(`Client not connected`),Error(`Client not connected`);try{n(!0),i(null);let a=await e.service(`sessions/${t}/spawn`).create(r);return r.prompt?.trim()&&await e.sessions.prompt(a.session_id,r.prompt,{messageSource:`agor`}),a}catch(e){let t=e instanceof Error?e.message:`Failed to spawn session`;throw i(t),console.error(`Failed to spawn session:`,e),e instanceof Error?e:Error(t)}finally{n(!1)}},l=async(t,n)=>{if(!e)return i(`Client not connected`),null;try{return i(null),await e.service(`sessions`).patch(t,n)}catch(e){return i(e instanceof Error?e.message:`Failed to update session`),console.error(`Failed to update session:`,e),null}};return{createSession:a,updateSession:l,deleteSession:async t=>{if(!e)return i(`Client not connected`),!1;try{return i(null),await e.service(`sessions`).remove(t),!0}catch(e){return i(e instanceof Error?e.message:`Failed to delete session`),console.error(`Failed to delete session:`,e),!1}},archiveSession:async e=>l(e,{archived:!0,archived_reason:`manual`}),unarchiveSession:async e=>l(e,{archived:!1,archived_reason:void 0}),forkSession:o,btwForkSession:s,spawnSession:c,creating:t,error:r}}var Of=[`boards`,`repos`,`branches`,`assistants`,`cards`,`artifacts`,`mcp`,`agentic-tools`,`gateway`,`groups`,`users`,`about`];function kf(){let e=Vr(),t=Wr(),n=e.state?.settingsBackgroundPath??null,r=(0,Z.useMemo)(()=>{let t=e.pathname.match(/\/settings(?:\/([^/]+))?(?:\/([^/]+))?\/?$/);if(!t)return{isOpen:!1,section:`boards`,itemId:null};let[,n,r]=t;return{isOpen:!0,section:Of.includes(n)?n:`boards`,itemId:r||null}},[e.pathname]),i=(0,Z.useCallback)((r=`boards`,i)=>{t(i?`/settings/${r}/${i}/`:`/settings/${r}/`,{state:{settingsBackgroundPath:e.pathname.startsWith(`/settings`)?n||`/`:`${e.pathname}${e.search}${e.hash}`}})},[e.hash,e.pathname,e.search,t,n]),a=(0,Z.useCallback)(()=>{t(n||`/`)},[t,n]),o=(0,Z.useCallback)(e=>{t(`/settings/${e}/`,{state:n?{settingsBackgroundPath:n}:void 0})},[t,n]),s=(0,Z.useCallback)(e=>{t(`/settings/${r.section}/${e}/`,{state:n?{settingsBackgroundPath:n}:void 0})},[t,r.section,n]),c=(0,Z.useCallback)(()=>{t(`/settings/${r.section}/`,{state:n?{settingsBackgroundPath:n}:void 0})},[t,r.section,n]);return{...r,openSettings:i,closeSettings:a,setSection:o,openItem:s,closeItem:c}}function Af(e,t,n={}){let{enabled:r=!0,reactiveOptions:i}=n,a=i?.taskHydration??`lazy`,[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{if(!e||!t||!r){s(null),l(null);return}let n=Ht(e,t,{taskHydration:a});s(n);let i=!1,o=()=>{i||l(n.state)};o();let c=n.subscribe(o);return n.ready().then(o).catch(o),()=>{i=!0,c(),qt(e,t,{taskHydration:a})}},[e,t,r,a]),(0,Z.useEffect)(()=>{if(!o)return;let e=()=>{let e=o.state;!e.error||e.terminal||o.resync()},t=()=>{document.visibilityState===`visible`&&e()},n=()=>{e()};return document.addEventListener(`visibilitychange`,t),window.addEventListener(mu,n),()=>{document.removeEventListener(`visibilitychange`,t),window.removeEventListener(mu,n)}},[o]),{handle:o,state:c}}function jf(e,t){return t.get(e)?.slug}function Mf(e,t){return tn(e,jf(e,t))}function Nf(e){let{currentBoardId:t,currentSessionId:n,boardById:r,sessionById:i,branchById:a,artifactById:o,onBoardChange:s,onSessionChange:c,onActiveUrlTargetChange:l}=e,u=Wr(),d=Vr(),f=Kr(),p=Ll(),m=(0,Z.useRef)(!1),h=(0,Z.useRef)(null),g=(0,Z.useRef)(t),_=(0,Z.useRef)(n),v=(0,Z.useRef)(null),y=(0,Z.useRef)(null),b=(0,Z.useRef)(null),x=(0,Z.useRef)(null),S=(0,Z.useRef)({board:!1,session:!1,branch:!1,artifact:!1}),C=(0,Z.useRef)(null),w=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{g.current=t,_.current=n},[t,n]),(0,Z.useEffect)(()=>()=>{C.current&&=(clearTimeout(C.current),null)},[]);let T=f.boardParam||null,E=f.sessionShortId||null,D=f.branchShortId||null,O=f.artifactShortId||null,k=d.pathname.startsWith(`/settings`),A=(0,Z.useCallback)((e,t)=>t?rn(t):e?Mf(e,r):`/`,[r]),j=(0,Z.useCallback)(()=>{if(m.current||n===null&&[Ft.branch,Ft.artifact].some(e=>d.pathname.startsWith(`/${e}/`)))return;let e=A(t,n),r=`${(d.pathname+d.search).replace(/\/$/,``)}/`;`${e.replace(/\/$/,``)}/`!==r&&e!==h.current&&(h.current=e,u(e,{replace:!0}))},[t,n,A,d.pathname,d.search,u]),M=(0,Z.useCallback)((e,t,n)=>{},[]),N=(0,Z.useCallback)(e=>Nd(e,r,(e,t)=>M(`board`,e,t)),[r,M]),P=(0,Z.useCallback)(e=>Pd(e,i,(e,t)=>M(`session`,e,t)),[i,M]),F=(0,Z.useCallback)(e=>Fd(e,a,(e,t)=>M(`branch`,e,t)),[a,M]),I=(0,Z.useCallback)(e=>Id(e,o,(e,t)=>M(`artifact`,e,t)),[o,M]);(0,Z.useEffect)(()=>{let e=T!==v.current||E!==y.current||D!==b.current||O!==x.current;e&&(S.current={board:!1,session:!1,branch:!1,artifact:!1},v.current=T,y.current=E,b.current=D,x.current=O,C.current&&=(clearTimeout(C.current),null));let t=S.current.board&&S.current.session&&S.current.branch&&S.current.artifact;if(!e&&t)return;if(!T&&!E&&!D&&!O){let e=d.pathname===`/`||d.pathname===``;if(!k&&!e){m.current=!0,u(`/`,{replace:!0}),setTimeout(()=>{m.current=!1},0);return}!k&&g.current&&(m.current=!0,s(``),_.current&&c(null),setTimeout(()=>{m.current=!1},0)),l&&w.current!==null&&(w.current=null,l(null));return}if(T&&r.size===0||E&&i.size===0||D&&a.size===0||O&&o.size===0)return;let n=null,f=null,h=null,A=null;if(T?(n=N(T),n&&(S.current.board=!0)):S.current.board=!0,E){if(f=P(E),f){S.current.session=!0;let e=i.get(f),t=e?.branch_id?a.get(e.branch_id):void 0;t?.board_id&&(n=t.board_id,h=t.branch_id)}}else S.current.session=!0;if(D){let e=F(D);if(e){S.current.branch=!0,A={kind:`branch`,id:e};let t=a.get(e);t?.board_id&&(n=t.board_id,h=e)}}else S.current.branch=!0;if(O){let e=I(O);if(e){S.current.artifact=!0,A={kind:`artifact`,id:e};let t=o.get(e);t?.board_id&&(n=t.board_id,h=e)}}else S.current.artifact=!0;if(l){let e=w.current;(e===null!=(A===null)||e!==null&&A!==null&&(e.kind!==A.kind||e.id!==A.id))&&(w.current=A,l(A))}let j=n&&n!==g.current,M=E?f:null,ee=M!==_.current;if((j||ee)&&(m.current=!0,j&&n&&s(n),ee&&c(M),setTimeout(()=>{m.current=!1},0)),e&&h&&n){let e=h,t=n;C.current=setTimeout(()=>{C.current=null,p(e,{boardId:t})},50)}},[T,E,D,O,r.size,i,a,o,N,P,F,I,s,c,l,k,p,d.pathname,u]),(0,Z.useEffect)(()=>{m.current||k||!T&&!E&&!D&&!O&&d.pathname!==`/`&&d.pathname!==``||r.size!==0&&(T&&!S.current.board||E&&!S.current.session||D&&!S.current.branch||O&&!S.current.artifact||j())},[r.size,T,E,D,O,k,j,d.pathname])}function Pf(e){(0,Z.useEffect)(()=>{if(e.branding===`dynamic`)return;let t=document.querySelector(`link[rel~='icon']`);t&&(t.href=ho()),document.title=e.branding},[e])}function Ff(e){return Array.from(e.values())}function If(e,t){let n=Array.from(e.values());return t?n.sort(t):n}function Lf(e){return vn(e).map(e=>e.trim().toLowerCase()).filter(Boolean)}function Rf(e){return e==null?[]:Array.isArray(e)?e.flatMap(Rf):[String(e)]}function zf(e,t,n){let r=Lf(t);return r.length===0?!0:_n(r,n.flatMap(t=>Rf(t(e))))}function Bf(e,t,n){return Lf(t).length===0?e:e.filter(e=>zf(e,t,n))}function Vf(e,t=2){let n=e.trim().toLowerCase(),r=Hf(vn(e).filter(e=>e.length>=t)),i=n.split(/\s+/).filter(Boolean);return n.length>=t&&i.length>0&&i.every(e=>e.length>=t)&&!r.includes(n)&&r.unshift(n),r.sort((e,t)=>t.length-e.length)}function Hf(e){let t=new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n}var Uf=({text:e,query:t=``,terms:n,minTermLength:r=2})=>{let{token:i}=X.useToken(),a=n??Vf(t,r);if(!e||a.length===0)return(0,Q.jsx)(Q.Fragment,{children:e});let o=a.map(Wf).filter(Boolean);if(o.length===0)return(0,Q.jsx)(Q.Fragment,{children:e});let s=RegExp(`(${o.join(`|`)})`,`gi`);return(0,Q.jsx)(Q.Fragment,{children:e.split(s).map((e,t)=>e?a.some(t=>t.toLowerCase()===e.toLowerCase())?(0,Q.jsx)(`mark`,{style:{backgroundColor:i.colorWarning,color:`rgba(0, 0, 0, 0.88)`,padding:`0 ${i.paddingXXS}px`,borderRadius:i.borderRadiusSM,fontWeight:600},children:e},t):(0,Q.jsx)(`span`,{children:e},t):null)})};function Wf(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}var Gf=new Set([`authorization`,`connection`,`content-length`,`cookie`,`host`,`mcp-session-id`,`te`,`trailer`,`transfer-encoding`,`upgrade`]),Kf=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function qf(e){return Kf.test(e)}function Jf(e){return Gf.has(e.toLowerCase())}function Yf(e){return e?e.includes(`{{`)&&e.includes(`}}`):!1}function Xf(e){let t={};return e.oauth_authorization_url&&typeof e.oauth_authorization_url==`string`&&(t.oauth_authorization_url=e.oauth_authorization_url),e.oauth_token_url&&typeof e.oauth_token_url==`string`&&(t.oauth_token_url=e.oauth_token_url),e.oauth_client_id&&typeof e.oauth_client_id==`string`&&(t.oauth_client_id=e.oauth_client_id),e.oauth_client_secret&&typeof e.oauth_client_secret==`string`&&(t.oauth_client_secret=e.oauth_client_secret),e.oauth_scope&&typeof e.oauth_scope==`string`&&(t.oauth_scope=e.oauth_scope),t.oauth_grant_type=typeof e.oauth_grant_type==`string`?e.oauth_grant_type:`client_credentials`,t.oauth_mode=e.oauth_mode===`shared`?`shared`:`per_user`,t}function Zf(e){if(!e.url||typeof e.url!=`string`)return null;let t={mcp_url:e.url};return e.oauth_token_url&&typeof e.oauth_token_url==`string`&&(t.token_url=e.oauth_token_url),e.oauth_client_id&&typeof e.oauth_client_id==`string`&&!Yf(e.oauth_client_id)&&(t.client_id=e.oauth_client_id),e.oauth_client_secret&&typeof e.oauth_client_secret==`string`&&!Yf(e.oauth_client_secret)&&(t.client_secret=e.oauth_client_secret),e.oauth_scope&&typeof e.oauth_scope==`string`&&(t.scope=e.oauth_scope),e.oauth_grant_type&&typeof e.oauth_grant_type==`string`&&(t.grant_type=e.oauth_grant_type),t}function Qf(e){let t=e.auth_type;if(t!==`bearer`&&t!==`jwt`&&t!==`oauth`)return;let n={type:t};return t===`bearer`?typeof e.auth_token==`string`&&(n.token=e.auth_token):t===`jwt`?(typeof e.jwt_api_url==`string`&&(n.api_url=e.jwt_api_url),typeof e.jwt_api_token==`string`&&(n.api_token=e.jwt_api_token),typeof e.jwt_api_secret==`string`&&(n.api_secret=e.jwt_api_secret)):Object.assign(n,Xf(e)),n}function $f(e){if(!(typeof e!=`string`||!e.trim()))try{return JSON.parse(e)}catch{return}}function ep(e){if(!(typeof e!=`string`||!e.trim()))try{let t=JSON.parse(e),n={};for(let[e,r]of Object.entries(t))e.toLowerCase()!==`authorization`&&typeof r==`string`&&(n[e]=r);return n}catch{return}}function tp(e){if(typeof e!=`string`||!e.trim())return;let t;try{t=JSON.parse(e)}catch{return`Custom HTTP headers must be valid JSON`}if(!t||typeof t!=`object`||Array.isArray(t))return`Custom HTTP headers must be a JSON object`;for(let[e,n]of Object.entries(t)){let t=e.trim();if(!t)return`Custom HTTP header names cannot be empty`;if(!qf(t))return`Invalid custom HTTP header name: ${e}`;if(Jf(t))return`Custom HTTP header ${t} is reserved and cannot be configured here`;if(typeof n!=`string`)return`Custom HTTP header values must be strings`}}var{TextArea:np}=J;function rp(e){return e!==`stdio`}var ip=({mode:e,transport:t,onTransportChange:n,authType:r=`none`,onAuthTypeChange:i,form:o,client:c,serverId:d,onTestConnection:f,testing:p=!1,testResult:m,onSaveFirst:h})=>{let{showSuccess:g,showError:_,showWarning:y,showInfo:b}=cf(),[x,S]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(!1),[k,M]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)(!1),F=(0,Z.useRef)(null);(0,Z.useEffect)(()=>()=>{F.current?.()},[]);let[I,ee]=(0,Z.useState)(d);(0,Z.useEffect)(()=>{ee(d)},[d]);let L=Y.useWatch(`oauth_authorization_url`,o),te=Y.useWatch(`oauth_token_url`,o),ne=Y.useWatch(`oauth_scope`,o),B=Y.useWatch(`oauth_client_id`,o),V=Y.useWatch(`oauth_client_secret`,o),re=Y.useWatch(`oauth_mode`,o),ie=Y.useWatch(`env`,o),U=Y.useWatch(`headers`,o),ae=typeof ie==`string`&&ie.trim().length>0,oe=rp(t)&&typeof U==`string`&&U.trim().length>0,se=[L,te,ne,B,V].some(e=>typeof e==`string`&&e.trim().length>0)||typeof re==`string`&&re!==`per_user`,ce=async()=>{if(!c){_(`Client not available`);return}let e=I;if(!e&&h){b(`Saving MCP server before testing...`);let t=await h();if(!t){_(`Failed to save MCP server`);return}e=t,ee(t)}let t=Zf(o.getFieldsValue(!0));if(!t){_(`MCP URL is required`);return}D(!0);let n=({authUrl:e})=>{window.open(e,`_blank`,`noopener,noreferrer`)};c.io.on(`oauth:open_browser`,n);try{b(`Starting OAuth authentication flow...`);let n=await c.service(`mcp-servers/oauth-start`).create({mcp_url:t.mcp_url,mcp_server_id:e,client_id:t.client_id});if(n.success&&n.state){M(!0),b(`Authenticating... complete sign-in in the new tab.`);let e=e=>{e.state===n.state&&e.success&&(g(`OAuth authentication successful!`),M(!1),T(!1),t())},t=()=>{c.io.off(`oauth:completed`,e),F.current=null};F.current?.(),F.current=t,c.io.on(`oauth:completed`,e)}else _(n.error||`Failed to start OAuth flow`)}catch(e){_(`OAuth flow error: ${e instanceof Error?e.message:String(e)}`)}finally{c.io.off(`oauth:open_browser`,n),D(!1)}},le=async()=>{if(!c){_(`Client not available`);return}if(!I){_(`Cannot disconnect: MCP server must be saved first`);return}P(!0);try{let e=await c.service(`mcp-servers/oauth-disconnect`).create({mcp_server_id:I});e.success?(g(e.message||`OAuth connection removed`),T(!0)):_(e.error||`Failed to disconnect OAuth`)}catch(e){_(`Disconnect error: ${e instanceof Error?e.message:String(e)}`)}finally{P(!1)}},ue=async()=>{if(!c){_(`Client not available`);return}let e=o.getFieldsValue(!0),t=e.auth_type||r;S(!0);try{if(t===`jwt`){let t=e.jwt_api_url,n=e.jwt_api_token,r=e.jwt_api_secret;if(!t||!n||!r){_(`Please fill in all JWT authentication fields`);return}let i=await c.service(`mcp-servers/test-jwt`).create({api_url:t,api_token:n,api_secret:r});i.success?g(`JWT authentication successful - token received`):_(i.error||`JWT authentication failed`)}else if(t===`oauth`){let t=Zf(e);if(!t){y(`Please enter MCP URL first to test OAuth authentication`);return}let n=await c.service(`mcp-servers/test-oauth`).create(t);if(n.success)if(n.requiresBrowserFlow)T(!0),b(n.message||`OAuth 2.1 detected. Click "Start OAuth Flow" to authenticate in browser.`);else if(n.oauthType===`none`)T(!1),g(`MCP server accessible without authentication`);else{let e=n.message||`OAuth authentication successful`;n.tokenUrlSource===`auto-detected`&&(e+=` (token URL auto-detected)`),n.mcpStatus!==void 0&&(e+=` | MCP server responded with ${n.mcpStatus}`),g(e)}else{let e=n.error||`OAuth authentication failed`;n.hint&&(e+=`\n\nHint: ${n.hint}`),_(e)}}else t===`bearer`?e.auth_token?g(`Bearer token configured`):y(`No bearer token provided`):b(`No authentication required - ready to use`)}catch(e){_(`Connection test failed: ${e instanceof Error?e.message:`Unknown error`}`)}finally{S(!1)}},de=rp(t),fe=de&&r===`oauth`,pe=e===`create`,me=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(O,{gutter:16,children:[(0,Q.jsx)(ot,{span:12,children:pe?(0,Q.jsx)(Y.Item,{label:`Name (Internal ID)`,name:`name`,rules:[{required:!0,message:`Please enter a server name`},{pattern:/^[a-z][a-z0-9_-]*$/,message:`Lowercase letters, digits, _ or - only; must start with a letter`},{max:64,message:`Maximum 64 characters`}],tooltip:`Internal identifier - lowercase, no spaces (e.g., filesystem, sentry, context7)`,children:(0,Q.jsx)(J,{placeholder:`context7`})}):(0,Q.jsx)(Y.Item,{label:`Name (Internal ID)`,name:`name`,tooltip:`Internal identifier - cannot be changed after creation`,children:(0,Q.jsx)(J,{disabled:!0})})}),(0,Q.jsx)(ot,{span:12,children:(0,Q.jsx)(Y.Item,{label:pe?`Display Name (Optional)`:`Display Name`,name:`display_name`,tooltip:`User-friendly name shown in UI (e.g., Context7 MCP)`,children:(0,Q.jsx)(J,{placeholder:pe?`Context7 MCP`:`Filesystem Access`})})})]}),(0,Q.jsxs)(O,{gutter:16,children:[(0,Q.jsx)(ot,{span:12,children:(0,Q.jsx)(Y.Item,{label:`Scope`,name:`scope`,initialValue:pe?`session`:`global`,tooltip:`Where this server is available`,children:(0,Q.jsxs)(l,{children:[(0,Q.jsx)(l.Option,{value:`global`,children:`Global (all sessions)`}),(0,Q.jsx)(l.Option,{value:`session`,children:`Session`})]})})}),(0,Q.jsx)(ot,{span:12,children:(0,Q.jsx)(Y.Item,{label:`Enabled`,name:`enabled`,valuePropName:`checked`,initialValue:!0,children:(0,Q.jsx)(j,{})})})]}),(0,Q.jsx)(Y.Item,{label:`Description`,name:`description`,children:(0,Q.jsx)(np,{placeholder:`Optional description...`,rows:2})})]}),he=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(z,{title:(0,Q.jsxs)(Q.Fragment,{children:[`Use `,(0,Q.jsx)(v.Text,{code:!0,children:`{{ user.env.VAR }}`}),` to inject your environment variables.`]}),type:`info`,showIcon:!0,style:{marginBottom:16}}),(0,Q.jsx)(Y.Item,{label:`Transport`,name:`transport`,rules:e===`create`?[{required:!0}]:[],initialValue:e===`create`?`stdio`:void 0,tooltip:`Connection method: stdio for local processes, HTTP/SSE for remote servers`,children:(0,Q.jsxs)(l,{onChange:e=>n?.(e),children:[(0,Q.jsx)(l.Option,{value:`stdio`,children:`stdio (Local process)`}),(0,Q.jsx)(l.Option,{value:`http`,children:`HTTP`}),(0,Q.jsx)(l.Option,{value:`sse`,children:`SSE (Server-Sent Events)`})]})}),t===`stdio`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y.Item,{label:`Command`,name:`command`,rules:e===`create`?[{required:!0,message:`Please enter a command`}]:[],tooltip:`Command to execute (e.g., npx, node, python)`,children:(0,Q.jsx)(J,{placeholder:`npx`})}),(0,Q.jsx)(Y.Item,{label:`Arguments`,name:`args`,tooltip:`Comma-separated arguments. Each argument will be passed separately to the command. Example: -y, @modelcontextprotocol/server-filesystem, /allowed/path`,children:(0,Q.jsx)(J,{placeholder:`-y, @modelcontextprotocol/server-filesystem, /allowed/path`})})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y.Item,{label:`URL`,name:`url`,rules:e===`create`?[{required:!0,message:`Please enter a URL`}]:[],tooltip:`Server URL. Supports templates like {{ user.env.MCP_URL }}`,children:(0,Q.jsx)(J,{placeholder:`https://mcp.example.com`})}),(0,Q.jsx)(Y.Item,{label:`Auth Type`,name:`auth_type`,initialValue:`none`,tooltip:`Authentication method for the MCP server`,children:(0,Q.jsxs)(l,{onChange:e=>{T(!1),e!==`jwt`&&o.setFieldsValue({jwt_api_url:void 0,jwt_api_token:void 0,jwt_api_secret:void 0}),e!==`bearer`&&o.setFieldsValue({auth_token:void 0}),e!==`oauth`&&o.setFieldsValue({oauth_authorization_url:void 0,oauth_token_url:void 0,oauth_client_id:void 0,oauth_client_secret:void 0,oauth_scope:void 0}),i?.(e)},children:[(0,Q.jsx)(l.Option,{value:`none`,children:`None`}),(0,Q.jsx)(l.Option,{value:`bearer`,children:`Bearer Token`}),(0,Q.jsx)(l.Option,{value:`jwt`,children:`JWT`}),(0,Q.jsx)(l.Option,{value:`oauth`,children:`OAuth 2.1`})]})}),r===`bearer`&&(0,Q.jsx)(Y.Item,{label:`Token`,name:`auth_token`,rules:[{required:!0,message:`Please enter a bearer token`}],tooltip:`Bearer token. Supports templates like {{ user.env.API_TOKEN }}`,children:(0,Q.jsx)(J.Password,{placeholder:`{{ user.env.API_TOKEN }} or raw token`})}),r===`jwt`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y.Item,{label:`API URL`,name:`jwt_api_url`,rules:[{required:!0,message:`Please enter the API URL`}],tooltip:`JWT auth API URL. Supports templates.`,children:(0,Q.jsx)(J,{placeholder:`https://auth.example.com/token`})}),(0,Q.jsx)(Y.Item,{label:`API Token`,name:`jwt_api_token`,rules:[{required:!0,message:`Please enter the API token`}],tooltip:`JWT API token. Supports templates like {{ user.env.JWT_TOKEN }}`,children:(0,Q.jsx)(J.Password,{placeholder:`{{ user.env.JWT_TOKEN }} or raw token`})}),(0,Q.jsx)(Y.Item,{label:`API Secret`,name:`jwt_api_secret`,rules:[{required:!0,message:`Please enter the API secret`}],tooltip:`JWT API secret. Supports templates like {{ user.env.JWT_SECRET }}`,children:(0,Q.jsx)(J.Password,{placeholder:`{{ user.env.JWT_SECRET }} or raw secret`})})]})]}),(r!==`none`||de)&&(0,Q.jsx)(Y.Item,{label:`Actions`,style:{marginBottom:16},children:(0,Q.jsxs)(G,{wrap:!0,children:[r!==`none`&&(0,Q.jsx)(s,{type:`default`,loading:x,onClick:ue,children:`Test Authentication`}),r===`oauth`&&w&&(0,Q.jsx)(s,{type:`primary`,loading:E,onClick:ce,children:`Start OAuth Flow`}),r===`oauth`&&I&&!w&&(0,Q.jsx)(s,{type:`default`,danger:!0,loading:N,onClick:le,children:`Disconnect OAuth`}),de&&(0,Q.jsx)(s,{type:`default`,icon:(0,Q.jsx)(Ie,{}),onClick:f,loading:p,children:p?`Testing...`:`Test Connection`})]})}),m?.success&&(0,Q.jsxs)(`div`,{style:{marginBottom:16},children:[(0,Q.jsx)(z,{type:`success`,title:`Connected: ${m.toolCount} tools, ${m.resourceCount} resources, ${m.promptCount} prompts`,showIcon:!0,style:{marginBottom:8}}),m.tools&&m.tools.length>0&&(0,Q.jsxs)(`div`,{style:{marginTop:8},children:[(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:4},children:`Tools:`}),(0,Q.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:4},children:m.tools.map(e=>(0,Q.jsx)(H,{title:e.description||`No description`,placement:`top`,children:(0,Q.jsx)(u,{color:`blue`,style:{marginBottom:4,cursor:`help`},children:e.name})},e.name))})]}),m.resources&&m.resources.length>0&&(0,Q.jsxs)(`div`,{style:{marginTop:8},children:[(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:4},children:`Resources:`}),(0,Q.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:4},children:m.resources.map(e=>(0,Q.jsx)(H,{title:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{children:e.uri}),e.mimeType&&(0,Q.jsx)(`div`,{style:{opacity:.7,fontSize:11},children:e.mimeType})]}),placement:`top`,children:(0,Q.jsx)(u,{color:`cyan`,style:{marginBottom:4,cursor:`help`},children:e.name})},e.uri))})]}),m.prompts&&m.prompts.length>0&&(0,Q.jsxs)(`div`,{style:{marginTop:8},children:[(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:4},children:`Prompts:`}),(0,Q.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:4},children:m.prompts.map(e=>(0,Q.jsx)(H,{title:e.description||`No description`,placement:`top`,children:(0,Q.jsx)(u,{color:`purple`,style:{marginBottom:4,cursor:`help`},children:e.name})},e.name))})]})]}),m&&!m.success&&(0,Q.jsx)(z,{type:`error`,title:`Connection failed`,description:m.error,showIcon:!0,style:{marginBottom:16}}),fe&&(0,Q.jsx)(A,{ghost:!0,destroyOnHidden:!1,expandIcon:({isActive:e})=>(0,Q.jsx)(C,{rotate:e?180:0}),items:[{key:`advanced-oauth`,forceRender:!0,label:(0,Q.jsxs)(G,{size:8,children:[(0,Q.jsx)(v.Text,{strong:!0,children:`Advanced — OAuth settings`}),(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12},children:`(auto-discovered when blank)`}),se&&(0,Q.jsx)(H,{title:`Customized — one or more values overridden`,children:(0,Q.jsx)(R,{color:`orange`})})]}),children:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(z,{title:`OAuth defaults are usually fine`,description:(0,Q.jsxs)(`ul`,{style:{margin:0,paddingLeft:20,fontSize:12},children:[(0,Q.jsx)(`li`,{children:`Modern OAuth 2.1 servers support discovery (RFC 8414 / RFC 9728) and Dynamic Client Registration — leave everything here blank.`}),(0,Q.jsx)(`li`,{children:`Set Client ID / Client Secret only for servers that require a pre-registered OAuth app (e.g. Figma, GitHub).`}),(0,Q.jsx)(`li`,{children:`Override the URLs only if the server doesn't expose a discovery document or you need a non-default endpoint.`})]}),type:`info`,showIcon:!0,style:{marginBottom:16}}),(0,Q.jsx)(Y.Item,{label:`Client ID`,name:`oauth_client_id`,tooltip:`Required for servers that don't support Dynamic Client Registration (e.g. Figma, GitHub). Register an OAuth app with the provider and paste the client ID here. Leave blank to use DCR.`,children:(0,Q.jsx)(J,{placeholder:`Enter client ID or {{ user.env.OAUTH_CLIENT_ID }}`,allowClear:!0})}),(0,Q.jsx)(Y.Item,{label:`Client Secret`,name:`oauth_client_secret`,tooltip:`Required for servers that use confidential clients (e.g. Figma). The secret is sent via HTTP Basic Auth during token exchange.`,children:(0,Q.jsx)(J.Password,{placeholder:`Enter client secret or {{ user.env.OAUTH_CLIENT_SECRET }}`,allowClear:!0})}),(0,Q.jsx)(Y.Item,{label:`OAuth Mode`,name:`oauth_mode`,initialValue:`per_user`,tooltip:`Per User: Each user authenticates separately (recommended). Shared: One token for all users.`,children:(0,Q.jsxs)(l,{children:[(0,Q.jsx)(l.Option,{value:`per_user`,children:`Per User (each user authenticates) - Recommended`}),(0,Q.jsx)(l.Option,{value:`shared`,children:`Shared (single token for all users)`})]})}),(0,Q.jsx)(Y.Item,{label:`Authorization URL`,name:`oauth_authorization_url`,tooltip:`OAuth authorization endpoint for browser-based login. Leave empty for auto-discovery (RFC 8414).`,children:(0,Q.jsx)(J,{placeholder:`https://auth.example.com/oauth/authorize`,allowClear:!0})}),(0,Q.jsx)(Y.Item,{label:`Token URL`,name:`oauth_token_url`,tooltip:`OAuth token endpoint. Leave empty for auto-discovery (OAuth 2.1 RFC 9728)`,children:(0,Q.jsx)(J,{placeholder:`Auto-detect or {{ user.env.OAUTH_TOKEN_URL }}`,allowClear:!0})}),(0,Q.jsx)(Y.Item,{label:`Scope`,name:`oauth_scope`,tooltip:`Optional: OAuth scopes (space-separated, e.g., 'read write')`,children:(0,Q.jsx)(J,{placeholder:`Leave empty or specify scopes`,allowClear:!0})}),(0,Q.jsx)(Y.Item,{label:`Grant Type`,name:`oauth_grant_type`,initialValue:`client_credentials`,tooltip:`OAuth grant type for Client Credentials flow. OAuth 2.1 auto-discovery uses Authorization Code with PKCE instead.`,children:(0,Q.jsx)(l,{disabled:!0,children:(0,Q.jsx)(l.Option,{value:`client_credentials`,children:`Client Credentials`})})})]})}]})]});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(A,{ghost:!0,destroyOnHidden:!1,defaultActiveKey:[`basic`,`connection`],expandIcon:({isActive:e})=>(0,Q.jsx)(C,{rotate:e?180:0}),items:[{key:`basic`,label:(0,Q.jsx)(v.Text,{strong:!0,children:`Basic Information`}),children:me},{key:`connection`,label:(0,Q.jsx)(v.Text,{strong:!0,children:`Connection`}),children:he},{key:`advanced-config`,label:(0,Q.jsxs)(G,{size:8,children:[(0,Q.jsx)(v.Text,{strong:!0,children:`Advanced Configuration`}),(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12},children:`(headers and environment variables)`}),(oe||ae)&&(0,Q.jsx)(H,{title:`Advanced configuration set`,children:(0,Q.jsx)(R,{color:`orange`})})]}),children:(0,Q.jsxs)(Q.Fragment,{children:[de&&(0,Q.jsx)(Y.Item,{label:`Custom HTTP Headers`,name:`headers`,tooltip:`JSON object of additional headers for HTTP/SSE transports. Values support templates like {{ user.env.DATADOG_API_KEY }}. Authorization is configured via Auth Type, not here.`,rules:[{validator:async(e,t)=>{let n=tp(t);if(n)throw Error(n)}}],children:(0,Q.jsx)(np,{placeholder:`{"DD-API-KEY": "{{ user.env.DATADOG_API_KEY }}", "X-Datadog-Parent-Org-Id": "123"}`,rows:3})}),(0,Q.jsx)(Y.Item,{label:`Environment Variables`,name:`env`,tooltip:`JSON object of environment variables. Values support templates like {{ user.env.VAR_NAME }}`,children:(0,Q.jsx)(np,{placeholder:`{"GITHUB_TOKEN": "{{ user.env.GITHUB_TOKEN }}", "ALLOWED_PATHS": "/path"}`,rows:3})})]})}]}),(0,Q.jsx)(a,{title:`OAuth Authentication`,open:k,onCancel:()=>{M(!1),F.current?.()},footer:[(0,Q.jsx)(s,{onClick:()=>{M(!1),F.current?.()},children:`Cancel`},`cancel`)],children:(0,Q.jsxs)(G,{orientation:`vertical`,style:{width:`100%`},children:[(0,Q.jsx)(v.Paragraph,{children:`Waiting for authentication to complete in the browser tab...`}),(0,Q.jsx)(v.Paragraph,{children:`This dialog will close automatically once sign-in is complete.`})]})})]})},ap=({server:e,open:t,client:n,onClose:r})=>{let{showSuccess:i,showError:o}=cf(),[s]=Y.useForm(),[c,l]=(0,Z.useState)(`stdio`),[u,d]=(0,Z.useState)(`none`),[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{if(!t||!e)return;h(null);let n=e.auth?.type||`none`;d(n),l(e.transport||(e.url?`http`:`stdio`)),s.resetFields();let r={name:e.name,display_name:e.display_name,description:e.description,transport:e.transport||(e.url?`http`:`stdio`),command:e.command,args:e.args?.join(`, `),url:e.url,scope:e.scope,enabled:e.enabled,env:e.env?JSON.stringify(e.env,null,2):void 0,headers:e.headers?JSON.stringify(e.headers,null,2):void 0,auth_type:n};n===`bearer`?r.auth_token=e.auth?.token:n===`jwt`?(r.jwt_api_url=e.auth?.api_url,r.jwt_api_token=e.auth?.api_token,r.jwt_api_secret=e.auth?.api_secret):n===`oauth`&&(r.oauth_authorization_url=e.auth?.oauth_authorization_url,r.oauth_token_url=e.auth?.oauth_token_url,r.oauth_client_id=e.auth?.oauth_client_id,r.oauth_client_secret=e.auth?.oauth_client_secret,r.oauth_scope=e.auth?.oauth_scope,r.oauth_grant_type=e.auth?.oauth_grant_type||`client_credentials`,r.oauth_mode=e.auth?.oauth_mode||`per_user`),s.setFieldsValue(r)},[t,e?.mcp_server_id,s]);let g=()=>{s.resetFields(),l(`stdio`),d(`none`),h(null),r()};return(0,Q.jsx)(a,{title:`Edit MCP Server`,open:t,onOk:async()=>{if(!(!e||!n))try{await s.validateFields();let t=s.getFieldsValue(!0),r={display_name:t.display_name,description:t.description,scope:t.scope,enabled:t.enabled,transport:t.transport};t.transport===`stdio`?(r.command=t.command,r.args=t.args?.split(`,`).map(e=>e.trim())||[]):(r.url=t.url,r.headers=ep(t.headers));let a=$f(t.env);a&&(r.env=a),r.auth=Qf(t),await n.service(`mcp-servers`).patch(e.mcp_server_id,r),i(`MCP server updated successfully`),g()}catch(e){o(e instanceof Error?e.message:`Failed to update server`)}},onCancel:g,okText:`Save`,width:600,destroyOnHidden:!0,children:(0,Q.jsx)(Y,{form:s,layout:`vertical`,style:{marginTop:16},children:(0,Q.jsx)(ip,{mode:`edit`,transport:c,onTransportChange:l,authType:u,onAuthTypeChange:d,form:s,client:n,serverId:e?.mcp_server_id,onTestConnection:async()=>{if(!n||!e){o(`Client not available`);return}let t=s.getFieldsValue(!0);if(!t.url){o(`URL is required to test connection`);return}if(t.transport===`stdio`){o(`Connection test is not available for stdio transport`);return}try{await s.validateFields([`headers`])}catch{o(`Please fix custom HTTP headers before testing`);return}p(!0),h(null);try{let r=await n.service(`mcp-servers/discover`).create({mcp_server_id:e.mcp_server_id,url:t.url,transport:t.transport||`http`,auth:Qf(t),headers:ep(t.headers)});r.success&&r.capabilities?h({success:!0,toolCount:r.capabilities.tools,resourceCount:r.capabilities.resources,promptCount:r.capabilities.prompts,tools:r.tools,resources:r.resources,prompts:r.prompts}):h({success:!1,toolCount:0,resourceCount:0,promptCount:0,error:r.error||`Connection test failed`})}catch(e){h({success:!1,toolCount:0,resourceCount:0,promptCount:0,error:e instanceof Error?e.message:`Unknown error`})}finally{p(!1)}},testing:f,testResult:m})})})};function op(e){let t=typeof e==`string`?new Date(e):e,n=new Date().getTime()-t.getTime(),r=Math.floor(n/1e3),i=Math.floor(r/60),a=Math.floor(i/60),o=Math.floor(a/24);return r<60?`just now`:i<60?`${i}m ago`:a<24?`${a}h ago`:o<7?`${o}d ago`:o<30?`${Math.floor(o/7)}w ago`:o<365?`${Math.floor(o/30)}mo ago`:`${Math.floor(o/365)}y ago`}function sp(e){if(!e)return;let t=typeof e==`string`?new Date(e):e;if(!Number.isNaN(t.getTime()))return op(t)}function cp(e){let t=typeof e==`string`?new Date(e):e;return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)} ${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}:${String(t.getSeconds()).padStart(2,`0`)}`}function lp(e,t){let n=op(e),r=cp(e);return t===void 0?`${n}\n${r}`:`${n}\n${r}\nMessage index: ${t}`}var up=({id:e,label:t,icon:n,color:r,copyLabel:i,metadataCard:a})=>{let{showSuccess:o,showError:s}=cf(),c=(0,Q.jsx)(Aa,{icon:(0,Q.jsx)(n,{}),color:r,style:{margin:0,fontSize:10,cursor:`pointer`,fontFamily:`monospace`},onClick:a?void 0:async()=>{await Xa(e)?o(`${i} copied: ${e}`):s(`Failed to copy to clipboard`)},children:t??Jt(e)});return a?(0,Q.jsx)(N,{content:a,title:null,trigger:`click`,placement:`left`,children:c}):c};function dp(e){return e<50?`rgba(82, 196, 26, 0.12)`:e<80?`rgba(250, 173, 20, 0.12)`:`rgba(255, 77, 79, 0.12)`}function fp(e){return Number.isFinite(e)?Math.max(0,Math.min(100,e)):0}function pp(e,t,n){return n&&Number.isFinite(n.percentage)?fp(n.percentage):!e||!t?0:fp(e/t*100)}function mp(e,t,n){if(!n&&(!e||!t))return;let r=pp(e,t,n);return`linear-gradient(to right, ${dp(r)} ${r}%, transparent ${r}%)`}var hp=`-dirty`;function gp(e){return e?e.endsWith(hp)?{cleanSha:e.slice(0,-6),isDirty:!0}:{cleanSha:e,isDirty:!1}:{cleanSha:``,isDirty:!1}}var _p=({label:e,id:t})=>{let{token:n}=X.useToken();return(0,Q.jsxs)(`div`,{style:{display:`flex`,alignItems:`baseline`,gap:8,padding:`2px 0`},children:[(0,Q.jsx)(`span`,{style:{minWidth:84,flexShrink:0,color:n.colorTextSecondary,fontSize:`0.85em`},children:e}),(0,Q.jsx)(v.Text,{copyable:{text:t,tooltips:[`Copy`,`Copied!`]},style:{fontFamily:n.fontFamilyCode,fontSize:`0.85em`,wordBreak:`break-all`},children:t})]})},vp=({session:e})=>(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(_p,{label:`Agor`,id:e.session_id}),e.sdk_session_id&&(0,Q.jsx)(_p,{label:e.agentic_tool||`SDK`,id:e.sdk_session_id})]});function yp(e){if(e.includes(`sonnet`)){let t=e.match(/sonnet-(\d)-(\d)/);return t?`sonnet-${t[1]}.${t[2]}`:`sonnet`}if(e.includes(`haiku`)){let t=e.match(/haiku-(\d)-(\d)/);return t?`haiku-${t[1]}.${t[2]}`:`haiku`}if(e.includes(`opus`)){let t=e.match(/opus-(\d)-(\d)/);return t?`opus-${t[1]}.${t[2]}`:`opus`}return e}function bp(e){return e?.trim().replace(/\.git$/,``).replace(/^\/+|\/+$/g,``).toLowerCase()||void 0}function xp(e){try{return new URL(e).hostname.toLowerCase()}catch{return e.match(/^[^@]+@([^:]+):/)?.[1]?.toLowerCase()}}function Sp(e){if(!(!e||xp(e)!==`github.com`))try{return bp(en(e))}catch{return}}function Cp(e){let t=e.pathname.split(`/`).filter(Boolean);if(!(e.hostname!==`github.com`||t.length<2))return bp(`${t[0]}/${t[1]}`)}function wp(e){return Sp(e?.remote_url)}function Tp(e,t={}){try{let n=new URL(e),r=n.pathname.split(`/`).filter(Boolean);if(n.hostname===`github.com`&&r.length>=4){let[e,i,a,o]=r,s=`${e}/${i}`;return(a===`issues`||a===`pull`)&&Cp(n)===wp(t.currentRepo)?`#${o}`:`${s}#${o}`}if(n.hostname===`app.shortcut.com`&&r.length>=3)return`${r[1]}/${r[2]}`;if(n.hostname.includes(`atlassian.net`)||n.hostname.includes(`jira`))return r[r.length-1]||n.hostname;if(n.hostname===`linear.app`){let e=r.indexOf(`issue`);return e!==-1&&r[e+1]?r[e+1]:r[r.length-1]||n.hostname}return r[r.length-1]||n.hostname}catch{return e.split(`/`).pop()||`?`}}function Ep(e){try{let{hostname:t}=new URL(e);return t===`github.com`||t.endsWith(`.github.com`)}catch{return!1}}var Dp={branch:`cyan`,session:`default`,board:`blue`,assistant:`geekblue`,mcp:`purple`,user:`orange`,artifact:`gold`,repo:`default`},Op={message:`default`,tool:`default`,token:`default`,model:`default`,git:`default`,session:Dp.session,success:`green`,error:`red`,warning:`orange`,processing:`cyan`,fork:`cyan`,spawn:`purple`,report:`green`,concept:`geekblue`,branch:Dp.branch},kp=({icon:e,color:t=`default`,children:n,onClick:r,tooltip:i})=>{let{token:a}=X.useToken(),o=(0,Q.jsx)(Aa,{icon:e,color:t,style:{cursor:r?`pointer`:`default`},onClick:r,children:(0,Q.jsx)(`span`,{style:{fontFamily:a.fontFamilyCode,lineHeight:1},children:n})});return i?(0,Q.jsx)(`span`,{title:i,children:o}):o},Ap=({count:e,estimatedCost:t,inputTokens:n,outputTokens:r,cacheReadTokens:i,cacheCreationTokens:a,style:o})=>{let s=n!==void 0||r!==void 0?(0,Q.jsxs)(`div`,{children:[n!==void 0&&(0,Q.jsxs)(`div`,{children:[`Input: `,n.toLocaleString()]}),r!==void 0&&(0,Q.jsxs)(`div`,{children:[`Output: `,r.toLocaleString()]}),i!==void 0&&i>0&&(0,Q.jsxs)(`div`,{children:[`Cache Read: `,i.toLocaleString()]}),a!==void 0&&a>0&&(0,Q.jsxs)(`div`,{children:[`Cache Creation: `,a.toLocaleString()]}),t!==void 0&&(0,Q.jsxs)(`div`,{children:[`Est. Cost: $`,t.toFixed(4)]})]}):t===void 0?void 0:`Est. Cost: $${t.toFixed(4)}`,c=(0,Q.jsx)(Aa,{icon:(0,Q.jsx)($e,{}),color:Op.token,style:o,children:e.toLocaleString()});return s?(0,Q.jsx)(H,{title:s,children:c}):c},jp=({used:e,limit:t,percentage:n,taskMetadata:r})=>{let{token:i}=X.useToken(),a=[],o=r?.raw_sdk_response,s=r?.normalized_sdk_response,c=s?.contextUsageSnapshot??null;return c&&a.push({key:`sdk-context-usage`,label:`Context Window (SDK)`,children:(0,Q.jsxs)(`div`,{style:{fontSize:`0.9em`,color:i.colorTextSecondary},children:[(0,Q.jsxs)(`div`,{children:[`Used: `,(0,Q.jsx)(`strong`,{children:c.totalTokens.toLocaleString()}),` tokens`]}),(0,Q.jsxs)(`div`,{children:[`Limit: `,(0,Q.jsx)(`strong`,{children:c.maxTokens.toLocaleString()}),` tokens`]}),(0,Q.jsxs)(`div`,{children:[`Percentage: `,(0,Q.jsxs)(`strong`,{children:[c.percentage,`%`]})]}),(0,Q.jsx)(`div`,{style:{fontSize:`0.85em`,color:i.colorTextTertiary,marginTop:4},children:`Authoritative snapshot reported by the agent (Claude SDK getContextUsage() or Codex CLI token_count event).`})]})}),o&&typeof o==`object`&&o&&`modelUsage`in o&&o.modelUsage&&a.push({key:`per-model`,label:`Per-Model Usage`,children:(0,Q.jsx)(`div`,{style:{fontSize:`0.9em`},children:Object.entries(o.modelUsage).map(([e,t])=>((t.inputTokens||0)+(t.outputTokens||0),(0,Q.jsxs)(`div`,{style:{marginBottom:12},children:[(0,Q.jsx)(`div`,{style:{fontWeight:500,marginBottom:4},children:e}),(0,Q.jsxs)(`div`,{style:{marginLeft:12,fontSize:`0.95em`,color:i.colorTextSecondary},children:[(0,Q.jsxs)(`div`,{children:[`Input: `,t.inputTokens?.toLocaleString()||0]}),(0,Q.jsxs)(`div`,{children:[`Output: `,t.outputTokens?.toLocaleString()||0]}),t.cacheCreationInputTokens!==void 0&&t.cacheCreationInputTokens>0&&(0,Q.jsxs)(`div`,{children:[`Cache creation: `,t.cacheCreationInputTokens.toLocaleString()]}),t.cacheReadInputTokens!==void 0&&t.cacheReadInputTokens>0&&(0,Q.jsxs)(`div`,{children:[`Cache read: `,t.cacheReadInputTokens.toLocaleString()]}),(0,Q.jsxs)(`div`,{style:{marginTop:4,fontWeight:500,color:i.colorText},children:[`Context limit: `,t.contextWindow?.toLocaleString()||0]})]})]},e)))})}),o&&a.push({key:`raw-sdk-response`,label:`🔍 Raw SDK Response`,children:(0,Q.jsx)(`pre`,{style:{fontSize:`0.75em`,fontFamily:i.fontFamilyCode,background:i.colorBgContainer,padding:8,borderRadius:4,overflowX:`auto`,maxHeight:300,margin:0,border:`1px solid ${i.colorBorder}`},children:JSON.stringify(o,null,2)})}),(0,Q.jsxs)(`div`,{style:{width:400,maxWidth:`90vw`},children:[(0,Q.jsxs)(`div`,{style:{marginBottom:16},children:[(0,Q.jsx)(`div`,{style:{fontWeight:600,fontSize:`1.05em`,marginBottom:8},children:`Context Window Usage`}),(0,Q.jsxs)(`div`,{style:{fontSize:`1.1em`,fontFamily:i.fontFamilyCode},children:[e.toLocaleString(),t>0?` / ${t.toLocaleString()}`:``,` `,t>0&&(0,Q.jsxs)(`span`,{style:{color:i.colorTextSecondary},children:[`(`,n,`%)`]})]}),(0,Q.jsx)(`div`,{style:{fontSize:`0.85em`,color:i.colorTextTertiary,marginTop:6},children:t>0?`Current context window snapshot`:`Current context window snapshot (limit unknown)`})]}),s&&(0,Q.jsxs)(`div`,{style:{marginBottom:16},children:[(0,Q.jsx)(`div`,{style:{fontWeight:500,marginBottom:6},children:`Token Breakdown`}),(0,Q.jsxs)(`div`,{style:{fontSize:`0.9em`,marginLeft:12,color:i.colorTextSecondary},children:[(0,Q.jsxs)(`div`,{children:[`Input: `,s.tokenUsage.inputTokens.toLocaleString()]}),(0,Q.jsxs)(`div`,{children:[`Output: `,s.tokenUsage.outputTokens.toLocaleString()]}),(s.tokenUsage.cacheCreationTokens??0)>0&&(0,Q.jsxs)(`div`,{children:[`Cache creation: `,s.tokenUsage.cacheCreationTokens?.toLocaleString()]}),(s.tokenUsage.cacheReadTokens??0)>0&&(0,Q.jsxs)(`div`,{children:[`Cache read: `,s.tokenUsage.cacheReadTokens?.toLocaleString()]}),(0,Q.jsxs)(`div`,{style:{marginTop:4,fontWeight:500,color:i.colorText},children:[`Total: `,s.tokenUsage.totalTokens.toLocaleString()]})]})]}),(r?.model||r?.duration_ms!==void 0)&&(0,Q.jsxs)(`div`,{style:{fontSize:`0.85em`,color:i.colorTextSecondary,paddingTop:12,borderTop:`1px solid ${i.colorBorderSecondary}`,marginBottom:16},children:[r?.model&&(0,Q.jsxs)(`div`,{children:[`Model: `,(0,Q.jsx)(`span`,{style:{fontFamily:i.fontFamilyCode},children:r.model})]}),r?.duration_ms!==void 0&&(0,Q.jsxs)(`div`,{children:[`Duration: `,(r.duration_ms/1e3).toFixed(2),`s`]})]}),a.length>0&&(0,Q.jsx)(A,{size:`small`,ghost:!0,items:a,style:{fontSize:`0.9em`}})]})},Mp=({used:e,limit:t,taskMetadata:n,style:r})=>{let i=n?.normalized_sdk_response?.contextUsageSnapshot,a=i?.totalTokens??e,o=i?.maxTokens??t,s=o>0,c=s?Math.round(pp(a,o,i)):0,l=(0,Q.jsx)(Aa,{icon:(0,Q.jsx)(I,{}),color:s?c<50?`green`:c<80?`orange`:`red`:`blue`,style:r,children:s?`${c}%`:`?`});return(0,Q.jsx)(N,{content:(0,Q.jsx)(jp,{used:a,limit:o,percentage:c,taskMetadata:n}),title:null,trigger:`hover`,placement:`top`,mouseEnterDelay:.3,children:l})},Np=({model:e,style:t})=>(0,Q.jsx)(Aa,{icon:(0,Q.jsx)(h,{}),color:Op.model,style:t,children:yp(e)}),Pp=()=>(0,Q.jsx)(`span`,{"aria-hidden":`true`,style:{display:`inline-flex`,flexShrink:0,marginLeft:6},children:(0,Q.jsx)(R,{status:`warning`})}),Fp=({branch:e,sha:t,branchName:n,showDirtyIndicator:r=!0,style:i})=>{let{token:a}=X.useToken(),{cleanSha:o,isDirty:s}=gp(t),c=o.substring(0,7),l=s&&r,u=e&&e!==n,d=l?`Git commit SHA (working tree has uncommitted changes) · click to copy`:`Git commit SHA · click to copy`,f=async e=>{e.stopPropagation(),await Xa(o)};return(0,Q.jsx)(H,{title:d,children:(0,Q.jsxs)(Aa,{icon:(0,Q.jsx)(We,{}),color:Op.git,style:{...i,cursor:`pointer`},onClick:f,children:[u&&(0,Q.jsxs)(`span`,{children:[e,` : `]}),(0,Q.jsx)(`span`,{style:{fontFamily:a.fontFamilyCode},children:c}),l&&(0,Q.jsx)(Pp,{})]})})},Ip=({status:e,style:t})=>{let n={completed:{icon:(0,Q.jsx)(st,{}),color:Op.success,text:`Completed`},failed:{icon:(0,Q.jsx)(ut,{}),color:Op.error,text:`Failed`},running:{icon:(0,Q.jsx)(Le,{}),color:Op.processing,text:`Running`},timed_out:{icon:(0,Q.jsx)(Oe,{}),color:Op.warning,text:`Timed Out`},idle:{icon:(0,Q.jsx)(Le,{}),color:Op.session,text:`Idle`},pending:{icon:(0,Q.jsx)(Le,{}),color:Op.session,text:`Pending`}}[e];return n?(0,Q.jsx)(Aa,{icon:n.icon,color:n.color,style:t,children:n.text}):(0,Q.jsx)(Aa,{icon:(0,Q.jsx)(Le,{}),color:Op.session,style:t,children:e})},Lp=({fromSessionId:e,taskId:t,messageIndex:n,style:r})=>{let i=t=>{t.stopPropagation(),Xa(e)};return(0,Q.jsx)(H,{title:(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{children:[`Forked from session `,Jt(e)]}),n!==void 0&&(0,Q.jsxs)(`div`,{children:[`Message index: `,n]}),(0,Q.jsx)(`div`,{style:{marginTop:4,fontSize:`0.9em`,opacity:.8},children:`Click to copy session ID`})]}),children:(0,Q.jsxs)(Aa,{icon:(0,Q.jsx)(We,{}),color:Op.fork,style:{...r,cursor:`pointer`},onClick:i,children:[`FORKED from `,Jt(e),n!==void 0&&` as of message ${n}`]})})},Rp=({fromSessionId:e,taskId:t,messageIndex:n,style:r})=>{let i=t=>{t.stopPropagation(),Xa(e)};return(0,Q.jsx)(H,{title:(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{children:[`Spawned from session `,Jt(e)]}),n!==void 0&&(0,Q.jsxs)(`div`,{children:[`Message index: `,n]}),(0,Q.jsx)(`div`,{style:{marginTop:4,fontSize:`0.9em`,opacity:.8},children:`Click to copy session ID`})]}),children:(0,Q.jsxs)(Aa,{icon:(0,Q.jsx)(p,{}),color:Op.spawn,style:{...r,cursor:`pointer`},onClick:i,children:[`SPAWNED from `,Jt(e),n!==void 0&&` as of message ${n}`]})})},zp=({icon:e,color:t,label:n,emoji:r,compact:i=!1,title:a,onClick:o,maxWidth:s=220,code:c=!1,ariaLabel:l,"aria-label":u,style:d})=>{let{token:f}=X.useToken(),p=n!=null&&n!==``,m=!!o,h=u??l;return(0,Q.jsx)(Aa,{icon:r?void 0:e,color:t,title:a,"aria-label":h,role:m?`button`:void 0,tabIndex:m?0:void 0,onKeyDown:e=>{!o||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),o(e))},style:{maxWidth:i?`100%`:void 0,marginInlineEnd:i?0:void 0,cursor:m?`pointer`:`default`,...d},onClick:o,children:p&&(0,Q.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:r?4:void 0,maxWidth:i?s:void 0,overflow:i?`hidden`:void 0,textOverflow:i?`ellipsis`:void 0,whiteSpace:i?`nowrap`:void 0,verticalAlign:i?`bottom`:void 0,fontFamily:c?f.fontFamilyCode:f.fontFamily},children:[r&&(0,Q.jsx)(`span`,{style:{fontFamily:f.fontFamily},children:r}),n]})})},Bp=({branch:e,compact:t=!1,title:n,emoji:r,onClick:i,style:a})=>(0,Q.jsx)(zp,{icon:(0,Q.jsx)(p,{}),color:Dp.branch,label:e,emoji:r,compact:t,title:n,onClick:i,code:!0,style:a}),Vp=({board:e,compact:t=!1,title:n,onClick:r,style:i})=>(0,Q.jsx)(zp,{icon:(0,Q.jsx)(c,{}),color:Dp.board,label:e.name,emoji:e.icon,compact:t,title:n??e.name,onClick:r,style:i}),Hp=({user:e,compact:t=!1,title:n,onClick:r,style:i})=>{let a=e.name||e.email||`Someone`;return(0,Q.jsx)(zp,{icon:(0,Q.jsx)(ke,{}),color:Dp.user,label:a,emoji:e.emoji,compact:t,title:n??a,onClick:r,maxWidth:180,style:i})},Up=({name:e,emoji:t,compact:n=!1,title:r,onClick:i,style:a})=>(0,Q.jsx)(zp,{icon:(0,Q.jsx)(h,{}),color:Dp.assistant,label:e,emoji:t,compact:n,title:r??e,onClick:i,code:!0,style:a}),Wp=({label:e,compact:t=!1,title:n,ariaLabel:r,"aria-label":i,onClick:a,style:o})=>(0,Q.jsx)(zp,{icon:(0,Q.jsx)(Ge,{}),color:Dp.session,label:e,compact:t,title:n,ariaLabel:i??r,onClick:a,style:o}),Gp=({namespace:e,style:t})=>(0,Q.jsx)(zp,{color:`default`,label:e,compact:!0,title:e,style:t}),Kp=({repoName:e,branchName:t,onClick:n,color:r=`cyan`,size:i,style:a})=>{let{token:o}=X.useToken();return(0,Q.jsx)(Aa,{icon:(0,Q.jsx)(p,{}),color:r,style:{...a,cursor:n?`pointer`:`default`},onClick:n,children:(0,Q.jsxs)(`span`,{style:{fontFamily:o.fontFamilyCode},children:[e,t&&(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(c,{style:{fontSize:`0.85em`,opacity:.7}}),` `,t]})]})})};function qp(e){return Ep(e)?(0,Q.jsx)(r,{}):(0,Q.jsx)(ae,{})}function Jp(e){return Ep(e)?(0,Q.jsx)(r,{}):(0,Q.jsx)(p,{})}var Yp={maxWidth:160,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,display:`inline-block`,verticalAlign:`middle`},Xp=({issueUrl:e,issueNumber:t,currentRepo:n,style:r})=>{let i=t||Tp(e,{currentRepo:n});return(0,Q.jsx)(H,{title:e,children:(0,Q.jsx)(Aa,{icon:qp(e),color:Op.git,style:{...r,cursor:`pointer`,maxWidth:220},onClick:()=>window.open(e,`_blank`),children:(0,Q.jsxs)(`span`,{style:Yp,children:[`Issue: `,i]})})})},Zp=({prUrl:e,prNumber:t,currentRepo:n,style:r})=>{let i=t||Tp(e,{currentRepo:n});return(0,Q.jsx)(H,{title:e,children:(0,Q.jsx)(Aa,{icon:Jp(e),color:Op.git,style:{...r,cursor:`pointer`,maxWidth:220},onClick:()=>window.open(e,`_blank`),children:(0,Q.jsxs)(`span`,{style:Yp,children:[`PR: `,i]})})})},Qp=({scheduledRunAt:e,style:t})=>{let n=new Date(e),r=n.toLocaleTimeString(`en-US`,{hour:`2-digit`,minute:`2-digit`,hour12:!1}),i=`Scheduled run at ${n.toLocaleString(`en-US`,{dateStyle:`medium`,timeStyle:`medium`})}\nRun ID: ${e}`;return(0,Q.jsx)(kp,{icon:(0,Q.jsx)(Oe,{}),color:Op.processing,tooltip:i,children:r})},$p=({channelType:e,channelName:t,style:n})=>(0,Q.jsx)(Aa,{icon:(()=>{switch((e||``).toLowerCase()){case`slack`:return(0,Q.jsx)(ct,{});case`discord`:return(0,Q.jsx)(V,{});default:return(0,Q.jsx)(V,{})}})(),color:Op.success,style:n,children:t});function em(e,t={}){let{fallbackChars:n=200,includeAgentFallback:r=!1,includeIdFallback:i=!1}=t;return e.title?e.title:e.description?e.description.length>n?`${e.description.substring(0,n)}...`:e.description:r?e.agentic_tool:i?`Session ${Jt(e.session_id)}`:`Untitled Session`}function tm(e=2,t=1.5){return{display:`-webkit-box`,WebkitLineClamp:e,WebkitBoxOrient:`vertical`,overflow:`hidden`,textOverflow:`ellipsis`,maxHeight:`${e*t}em`,lineHeight:t}}function nm(e){return e?.avatar_url||void 0}function rm(e){return Math.max(5,Math.round(e*.2))}var im=({user:e,size:t=40,fontSize:n,style:r,...i})=>{let{token:a}=X.useToken(),o=e?.preferences?.use_slack_avatar!==!1,s=nm(e),c=e?.avatar_source===`slack`&&!o?void 0:s;return(0,Q.jsx)(T,{...i,src:c,shape:`square`,size:t,style:{borderRadius:rm(t),backgroundColor:c?a.colorBgContainer:a.colorPrimaryBg,color:a.colorText,fontSize:n??`${Math.round(t*.6)}px`,lineHeight:`${t}px`,overflow:`hidden`,...r},children:e?.emoji||`👤`})},am={small:{avatar:18,font:12},default:{avatar:22,font:14},large:{avatar:28,font:18}},om=({user:e,showName:t=!0,size:n=`default`})=>{let r=am[n],{token:i}=X.useToken();return(0,Q.jsx)(H,{title:`${e.name||e.email} (${e.role})`,children:(0,Q.jsxs)(G,{size:4,children:[(0,Q.jsx)(im,{user:e,size:r.avatar,fontSize:`${r.font}px`}),t&&(0,Q.jsx)(`span`,{style:{backgroundColor:i.colorBgTextHover,borderRadius:`3px`,padding:`0 2px`,fontWeight:600},children:e.name||e.email.split(`@`)[0]})]})})},sm=({createdBy:e,currentUserId:t,userById:n,prefix:r=`Created by`})=>{if(e===t)return null;let i=n.get(e);return!i||e===`anonymous`?(0,Q.jsx)(Aa,{color:`default`,style:{fontSize:11},children:e===`anonymous`?`Anonymous`:`Unknown User`}):(0,Q.jsx)(Aa,{color:`blue`,style:{fontSize:11},children:(0,Q.jsx)(om,{user:i,showName:!0,size:`small`})})},{Text:cm}=v,lm=({session:e,branch:t,repo:n,userById:r=new Map,currentUserId:i,compact:a=!0})=>{let{token:o}=X.useToken();return(0,Q.jsxs)(`div`,{style:{width:400,maxWidth:`90vw`},children:[(0,Q.jsxs)(`div`,{style:{marginBottom:16},children:[(0,Q.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:12},children:[(0,Q.jsx)(Va,{tool:e.agentic_tool,size:24}),(0,Q.jsx)(`div`,{style:{flex:1,minWidth:0},children:(0,Q.jsx)(cm,{strong:!0,style:{fontSize:`1.05em`,display:`block`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:em(e,{fallbackChars:60,includeAgentFallback:!0})})})]}),(0,Q.jsx)(`div`,{style:{marginBottom:8},children:(0,Q.jsxs)(G,{size:4,children:[(0,Q.jsx)(cm,{type:`secondary`,style:{fontSize:`0.85em`},children:`Status:`}),(0,Q.jsx)(Ip,{status:e.status})]})})]}),(0,Q.jsx)(`div`,{style:{marginBottom:12,paddingTop:12,borderTop:`1px solid ${o.colorBorderSecondary}`},children:(0,Q.jsx)(vp,{session:e})}),(e.genealogy.forked_from_session_id||e.genealogy.parent_session_id)&&(0,Q.jsxs)(`div`,{style:{marginBottom:12},children:[(0,Q.jsx)(`div`,{style:{fontWeight:600,fontSize:`0.85em`,marginBottom:8},children:`Genealogy`}),(0,Q.jsxs)(G,{size:4,children:[e.genealogy.forked_from_session_id&&(0,Q.jsx)(Lp,{fromSessionId:e.genealogy.forked_from_session_id}),e.genealogy.parent_session_id&&(0,Q.jsx)(Rp,{fromSessionId:e.genealogy.parent_session_id})]})]}),t&&n&&(0,Q.jsxs)(`div`,{style:{marginBottom:12},children:[(0,Q.jsx)(`div`,{style:{fontWeight:600,fontSize:`0.85em`,marginBottom:8},children:`Branch`}),(0,Q.jsxs)(G,{size:4,wrap:!0,children:[(0,Q.jsx)(Kp,{repoName:n.slug}),(0,Q.jsx)(Aa,{icon:(0,Q.jsx)(se,{}),color:Op.branch,children:(0,Q.jsx)(`span`,{style:{fontFamily:o.fontFamilyCode},children:t.name})})]})]}),(0,Q.jsxs)(`div`,{style:{fontSize:`0.85em`,color:o.colorTextSecondary,paddingTop:12,borderTop:`1px solid ${o.colorBorderSecondary}`},children:[e.created_by&&(0,Q.jsx)(`div`,{style:{marginBottom:4},children:(0,Q.jsx)(sm,{createdBy:e.created_by,currentUserId:i,userById:r,prefix:`Created by`})}),(0,Q.jsxs)(`div`,{style:{marginBottom:4},children:[(0,Q.jsx)(cm,{type:`secondary`,children:`Created: `}),new Date(e.created_at).toLocaleString()]}),(0,Q.jsxs)(`div`,{style:{marginBottom:4},children:[(0,Q.jsx)(cm,{type:`secondary`,children:`Agent: `}),e.agentic_tool]}),e.permission_config?.mode&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(cm,{type:`secondary`,children:`Permission mode: `}),e.permission_config.mode]})]})]})},um=[vt.RUNNING,vt.STOPPING,vt.AWAITING_PERMISSION,vt.AWAITING_INPUT],dm={[vt.RUNNING]:{icon:(0,Q.jsx)(D,{}),color:Op.processing},[vt.STOPPING]:{icon:(0,Q.jsx)(_,{}),color:Op.warning},[vt.AWAITING_PERMISSION]:{icon:(0,Q.jsx)(_,{}),color:Op.warning},[vt.AWAITING_INPUT]:{icon:(0,Q.jsx)(we,{}),color:Op.processing},[vt.COMPLETED]:{icon:(0,Q.jsx)(st,{}),color:Op.success},[vt.FAILED]:{icon:(0,Q.jsx)(ut,{}),color:Op.error},[vt.STOPPED]:{icon:(0,Q.jsx)(Be,{}),color:Op.warning},[Rt.IDLE]:{icon:(0,Q.jsx)(D,{}),color:Op.session},[vt.TIMED_OUT]:{icon:(0,Q.jsx)(Oe,{}),color:Op.warning},[vt.CREATED]:{icon:(0,Q.jsx)(D,{}),color:Op.session,label:`00:00`},[vt.QUEUED]:{icon:(0,Q.jsx)(Oe,{}),color:Op.session,label:`Queued`},pending:{icon:(0,Q.jsx)(D,{}),color:Op.session}};function fm(e){if(!e)return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:e.getTime();if(typeof e==`number`)return Number.isFinite(e)?e:null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function pm(e){if(!Number.isFinite(e)||e<=0)return`00:00`;let t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60,a=n.toString().padStart(2,`0`),o=r.toString().padStart(2,`0`),s=i.toString().padStart(2,`0`);return n>0?`${a}:${o}:${s}`:`${o}:${s}`}var mm=({status:e,startedAt:t,endedAt:n,durationMs:r,lastExecutorHeartbeatAt:i,style:a})=>{let{token:o}=X.useToken(),s=(0,Z.useMemo)(()=>fm(t),[t]),c=(0,Z.useMemo)(()=>fm(n),[n]),l=(0,Z.useMemo)(()=>fm(i??void 0),[i]),u=(0,Z.useMemo)(()=>typeof r==`number`&&r>=0?r:s&&c&&c>=s?c-s:null,[r,s,c]),[d,f]=(0,Z.useState)(()=>u===null?s?Math.max(0,Date.now()-s):0:u);(0,Z.useEffect)(()=>{if(u!==null){f(u);return}if(!s){f(0);return}f(Math.max(0,Date.now()-s))},[u,s]),(0,Z.useEffect)(()=>{if(!s||!um.includes(e))return;let t=window.setInterval(()=>{f(Math.max(0,Date.now()-s))},1e3);return()=>window.clearInterval(t)},[s,e]);let p=um.includes(e),m=(0,Z.useMemo)(()=>{let e={color:o.colorTextSecondary,minWidth:60},t={fontFamily:o.fontFamilyCode,color:o.colorText},n={display:`flex`,gap:8,alignItems:`baseline`},r=l?Math.max(0,Date.now()-l):null;return(0,Q.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4,fontSize:12},children:[s&&(0,Q.jsxs)(`div`,{style:n,children:[(0,Q.jsx)(`span`,{style:e,children:`Started`}),(0,Q.jsx)(`span`,{style:t,children:cp(new Date(s))})]}),(0,Q.jsxs)(`div`,{style:n,children:[(0,Q.jsx)(`span`,{style:e,children:`Ended`}),(0,Q.jsx)(`span`,{style:t,children:p?`In progress...`:c?cp(new Date(c)):`—`})]}),(0,Q.jsxs)(`div`,{style:n,children:[(0,Q.jsx)(`span`,{style:e,children:`Duration`}),(0,Q.jsx)(`span`,{style:t,children:pm(d)})]}),l&&(0,Q.jsxs)(`div`,{style:n,children:[(0,Q.jsx)(`span`,{style:e,children:`Heartbeat`}),(0,Q.jsxs)(`span`,{style:t,children:[(0,Q.jsx)(ve,{style:{marginRight:4}}),r===null?`—`:`${pm(r)} ago`,(0,Q.jsx)(`span`,{style:{color:o.colorTextSecondary,marginLeft:6},children:cp(new Date(l))})]})]})]})},[s,c,p,d,l,o]);if(!s&&u===null)return null;let h=dm[e]||dm.pending,g=h.label??pm(d);return(0,Q.jsx)(N,{content:m,placement:`bottom`,children:(0,Q.jsx)(Aa,{icon:h.icon,color:h.color,style:a,children:(0,Q.jsx)(`span`,{style:{fontFamily:o.fontFamilyCode,lineHeight:1},children:g})})})};function hm(e){let t=e-Date.now(),n=Math.floor(Math.abs(t)/1e3),r=Math.floor(n/60),i=Math.floor(r/60),a=Math.floor(i/24),o=n<60?`${n}s`:r<60?`${r}m`:i<24?`${i}h`:`${a}d`;return t>=0?{verb:`Expires`,phrase:`in ${o}`}:{verb:`Expired`,phrase:`${o} ago`}}function gm(e){switch(e){case`missing_token_endpoint`:return`missing OAuth token endpoint — re-authenticate, or ask an admin to save the token URL in this MCP server’s OAuth settings`;case`missing_client_id`:return`missing OAuth client ID for this grant — re-authenticate, or ask an admin to check the MCP server OAuth settings`;case`needs_reauth`:return`refresh token is no longer valid — sign in again`;case`token_refresh_failed`:return`provider token refresh failed — try again, or sign in again if it keeps failing`;default:return e||`unknown error`}}var _m=({server:e,needsAuth:t,client:n})=>{let{showSuccess:r,showInfo:i,showWarning:a,showError:o}=cf(),{isAdmin:s}=_f(),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(void 0),m=e.auth?.type===`oauth`,h=f??e.auth?.oauth_token_expires_at,g=async()=>{if(n)try{let t=await n.service(`mcp-servers/oauth-start`).create({mcp_url:e.url,mcp_server_id:e.mcp_server_id,client_id:e.auth?.oauth_client_id});if(t.success&&t.authorizationUrl){if(window.open(t.authorizationUrl,`_blank`,`noopener,noreferrer`),i(`Complete sign-in in the new tab.`),t.state){let i=a=>{a.state===t.state&&a.success&&(r(`${e.display_name||e.name} authenticated!`),n.io.off(`oauth:completed`,i))};n.io.on(`oauth:completed`,i),setTimeout(()=>n.io.off(`oauth:completed`,i),300*1e3)}}else t.success||o(t.error||`Failed to start OAuth flow`)}catch(e){o(`OAuth error: ${e instanceof Error?e.message:String(e)}`)}},_=async()=>{if(!(!n||c)){l(!0);try{let t=await n.service(`mcp-servers/oauth-refresh`).create({mcp_server_id:e.mcp_server_id});t.success?(p(t.expires_at),r(t.expires_at?`${e.display_name||e.name} refreshed — expires ${hm(t.expires_at).phrase}`:`${e.display_name||e.name} refreshed`)):t.error===`needs_reauth`||t.error===`missing_client_id`?(a(gm(t.error)),await g()):o(`Refresh failed: ${gm(t.error)}`)}catch(e){o(`Refresh error: ${e instanceof Error?e.message:String(e)}`)}finally{l(!1)}}},v;if(!m)v=`${e.transport.toUpperCase()} MCP server`;else if(h){let e=new Date(h),{verb:t,phrase:n}=hm(h);v=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{children:[t,` `,n]}),(0,Q.jsx)(`div`,{style:{opacity:.75,fontSize:12},children:cp(e)}),(0,Q.jsx)(`div`,{style:{opacity:.75,fontSize:12,marginTop:4},children:`Click to refresh now`})]})}else v=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{children:`Expires in: unknown`}),(0,Q.jsx)(`div`,{style:{opacity:.75,fontSize:12},children:`Provider returned no expiry. Token is used until it stops working.`}),(0,Q.jsx)(`div`,{style:{opacity:.75,fontSize:12,marginTop:4},children:`Click to refresh now`})]});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(H,{title:t?`Click to authenticate`:v,children:(0,Q.jsxs)(Aa,{color:t?`orange`:Dp.mcp,icon:t?(0,Q.jsx)(ce,{}):c?(0,Q.jsx)(he,{spin:!0}):(0,Q.jsx)(Ie,{}),style:{cursor:c?`wait`:m?`pointer`:`default`},onClick:t?g:m?_:void 0,children:[e.display_name||e.name,s&&(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Edit MCP server`,title:`Edit MCP server`,onClick:e=>{e.stopPropagation(),d(!0)},style:{marginLeft:8,padding:0,background:`transparent`,border:`none`,color:`inherit`,fontSize:11,lineHeight:1,opacity:.55,cursor:`pointer`},onMouseEnter:e=>{e.currentTarget.style.opacity=`1`},onMouseLeave:e=>{e.currentTarget.style.opacity=`0.55`},onFocus:e=>{e.currentTarget.style.opacity=`1`},onBlur:e=>{e.currentTarget.style.opacity=`0.55`},children:(0,Q.jsx)(P,{})})]})}),s&&(0,Q.jsx)(ap,{server:e,open:u,client:n,onClose:()=>d(!1)})]})};function vm({children:e,size:t,...n}){let{token:r}=X.useToken();return(0,Q.jsx)(G,{size:t??r.sizeUnit,...n,children:e})}var ym=({mcpServerById:e,client:t,onCreate:n,onDelete:r})=>{let{showError:i}=cf(),[o,c]=(0,Z.useState)(!1),[l,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(null),[y]=Y.useForm(),[b,x]=(0,Z.useState)(`stdio`),[S,C]=(0,Z.useState)(`none`),[w,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(``);(0,Z.useEffect)(()=>{if(m&&e.has(m.mcp_server_id)){let t=e.get(m.mcp_server_id);t&&t!==m&&h(t)}},[e,m]);let M=e=>{let t={name:e.name,display_name:e.display_name,description:e.description,transport:e.transport,scope:e.scope||`global`,enabled:e.enabled??!0,source:`user`};if(e.transport===`stdio`)t.command=e.command,t.args=e.args?.split(`,`).map(e=>e.trim())||[];else{t.url=e.url;let n=ep(e.headers);n&&(t.headers=n)}let n=Qf(e);n&&(t.auth=n);let r=$f(e.env);return r&&(t.env=r),t},N=async()=>{if(!t)return null;try{await y.validateFields();let e=M(y.getFieldsValue(!0)),n=await t.service(`mcp-servers`).create(e);return D(!0),n.mcp_server_id||null}catch{return null}},F=()=>{y.resetFields(),c(!1),x(`stdio`),C(`none`),k(null),D(!1)},I=()=>{if(E){F();return}y.validateFields().then(()=>{let e=M(y.getFieldsValue(!0));n?.(e),F()}).catch(e=>{if(console.error(`Form validation failed:`,e),e.errorFields&&e.errorFields.length>0){let t=e.errorFields[0];i(t.errors[0]||`Please fill in required fields`)}})},ee=async()=>{if(!t){i(`Client not available`);return}let e=y.getFieldsValue(!0);if(!e.url){i(`URL is required to test connection`);return}if(e.transport===`stdio`){i(`Connection test is not available for stdio transport`);return}try{await y.validateFields([`headers`])}catch{i(`Please fix custom HTTP headers before testing`);return}T(!0),k(null);try{let n=await t.service(`mcp-servers/discover`).create({url:e.url,transport:e.transport||`http`,auth:Qf(e),headers:ep(e.headers)});n.success&&n.capabilities?k({success:!0,toolCount:n.capabilities.tools,resourceCount:n.capabilities.resources,promptCount:n.capabilities.prompts,tools:n.tools,resources:n.resources,prompts:n.prompts}):k({success:!1,toolCount:0,resourceCount:0,promptCount:0,error:n.error||`Connection test failed`})}catch(e){k({success:!1,toolCount:0,resourceCount:0,promptCount:0,error:e instanceof Error?e.message:`Unknown error`})}finally{T(!1)}},te=e=>{h(e),d(!0)},ne=()=>{d(!1),h(null)},z=e=>{_(e),p(!0)},V=e=>{r?.(e)},H=e=>{let t=e.tools?.length||0;return(e.transport||(e.url?`http`:`stdio`))===`stdio`?{status:`default`,text:`Local process`,color:`#8c8c8c`}:t>0?{status:`success`,text:`${t} tools`,color:`#52c41a`}:{status:`default`,text:`Not tested`,color:`#8c8c8c`}},ie=[{title:`Name`,dataIndex:`name`,key:`name`,width:180,render:(e,t)=>(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{children:(0,Q.jsx)(Uf,{text:t.display_name||t.name,query:A})}),(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12},children:(0,Q.jsx)(Uf,{text:t.name,query:A})})]})},{title:`Transport`,dataIndex:`transport`,key:`transport`,width:100,render:e=>(0,Q.jsx)(u,{color:e===`stdio`?`blue`:`green`,children:e.toUpperCase()})},{title:`Scope`,dataIndex:`scope`,key:`scope`,width:100,render:e=>(0,Q.jsx)(u,{color:{global:`purple`,repo:`cyan`,session:`magenta`}[e],children:e})},{title:`Status`,dataIndex:`enabled`,key:`enabled`,width:80,render:e=>e?(0,Q.jsx)(R,{status:`success`,text:`Enabled`}):(0,Q.jsx)(R,{status:`default`,text:`Disabled`})},{title:`Health`,key:`health`,width:120,render:(e,t)=>{let n=H(t);return(0,Q.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,Q.jsx)(R,{status:n.status}),(0,Q.jsx)(v.Text,{style:{fontSize:12,color:n.color},children:n.text})]})}},{title:`Source`,dataIndex:`source`,key:`source`,width:100,render:e=>(0,Q.jsx)(v.Text,{type:`secondary`,children:(0,Q.jsx)(Uf,{text:e,query:A})})},{title:`Actions`,key:`actions`,width:96,render:(e,t)=>(0,Q.jsxs)(vm,{children:[(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(Ae,{}),onClick:()=>z(t),title:`View details`}),(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(P,{}),onClick:()=>te(t),title:`Edit`}),(0,Q.jsx)(B,{title:`Delete MCP server?`,description:`Are you sure you want to delete "${t.display_name||t.name}"?`,onConfirm:()=>V(t.mcp_server_id),okText:`Delete`,cancelText:`Cancel`,okButtonProps:{danger:!0},children:(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(re,{}),danger:!0,title:`Delete`})})]})}],U=(0,Z.useMemo)(()=>Bf(If(e,(e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:`base`})),A,[e=>e.name,e=>e.display_name,e=>e.description,e=>e.transport,e=>e.scope,e=>e.source,e=>e.url,e=>e.command,e=>e.args,e=>e.enabled,e=>e.tools?.flatMap(e=>[e.name,e.description])]),[e,A]);return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{style:{marginBottom:16,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,Q.jsx)(v.Text,{type:`secondary`,children:`Configure Model Context Protocol servers for enhanced AI capabilities.`}),(0,Q.jsxs)(G,{children:[(0,Q.jsx)(J,{allowClear:!0,placeholder:`Search name, URL, command, tools, transport, or scope`,value:A,onChange:e=>j(e.target.value),style:{width:360}}),(0,Q.jsx)(s,{type:`primary`,icon:(0,Q.jsx)(L,{}),onClick:()=>c(!0),children:`New MCP Server`})]})]}),(0,Q.jsx)(ue,{dataSource:U,columns:ie,rowKey:`mcp_server_id`,pagination:{pageSize:10,showSizeChanger:!0},size:`small`}),(0,Q.jsx)(a,{title:`Add MCP Server`,open:o,onOk:I,onCancel:F,okText:E?`Done`:`Create`,width:600,children:(0,Q.jsx)(Y,{form:y,layout:`vertical`,style:{marginTop:16},children:(0,Q.jsx)(ip,{mode:`create`,transport:b,onTransportChange:x,authType:S,onAuthTypeChange:C,form:y,client:t,onTestConnection:ee,testing:w,testResult:O,onSaveFirst:N})})}),(0,Q.jsx)(ap,{server:m,open:l,client:t,onClose:ne}),(0,Q.jsx)(a,{title:`MCP Server Details`,open:f,onCancel:()=>{p(!1),_(null)},footer:[(0,Q.jsx)(s,{onClick:()=>p(!1),children:`Close`},`close`)],width:700,children:g&&(0,Q.jsxs)(q,{bordered:!0,column:1,size:`small`,style:{marginTop:16},children:[(0,Q.jsx)(q.Item,{label:`ID`,children:Jt(g.mcp_server_id)}),(0,Q.jsx)(q.Item,{label:`Name`,children:g.name}),g.display_name&&(0,Q.jsx)(q.Item,{label:`Display Name`,children:g.display_name}),g.description&&(0,Q.jsx)(q.Item,{label:`Description`,children:g.description}),(0,Q.jsx)(q.Item,{label:`Transport`,children:(0,Q.jsx)(u,{color:g.transport===`stdio`?`blue`:`green`,children:g.transport.toUpperCase()})}),(0,Q.jsx)(q.Item,{label:`Scope`,children:(0,Q.jsx)(u,{children:g.scope})}),(0,Q.jsx)(q.Item,{label:`Source`,children:g.source}),(0,Q.jsx)(q.Item,{label:`Status`,children:g.enabled?(0,Q.jsx)(R,{status:`success`,text:`Enabled`}):(0,Q.jsx)(R,{status:`default`,text:`Disabled`})}),g.command&&(0,Q.jsx)(q.Item,{label:`Command`,children:g.command}),g.args&&g.args.length>0&&(0,Q.jsx)(q.Item,{label:`Arguments`,children:g.args.join(`, `)}),g.url&&(0,Q.jsx)(q.Item,{label:`URL`,children:g.url}),g.headers&&Object.keys(g.headers).length>0&&(0,Q.jsx)(q.Item,{label:`Custom HTTP Headers`,children:(0,Q.jsx)(`pre`,{style:{margin:0,fontSize:12},children:JSON.stringify(g.headers,null,2)})}),g.env&&Object.keys(g.env).length>0&&(0,Q.jsx)(q.Item,{label:`Environment Variables`,children:(0,Q.jsx)(`pre`,{style:{margin:0,fontSize:12},children:JSON.stringify(g.env,null,2)})}),g.tools&&g.tools.length>0&&(0,Q.jsxs)(q.Item,{label:`Tools`,children:[g.tools.length,` tools`]}),g.resources&&g.resources.length>0&&(0,Q.jsxs)(q.Item,{label:`Resources`,children:[g.resources.length,` resources`]}),g.prompts&&g.prompts.length>0&&(0,Q.jsxs)(q.Item,{label:`Prompts`,children:[g.prompts.length,` prompts`]}),(0,Q.jsx)(q.Item,{label:`Created`,children:new Date(g.created_at).toLocaleString()}),g.updated_at&&(0,Q.jsx)(q.Item,{label:`Updated`,children:new Date(g.updated_at).toLocaleString()})]})})]})},bm=({branch:e,canEdit:t,state:n,setField:r})=>{let i=Wt(e);return i?(0,Q.jsx)(`div`,{style:{width:`100%`,maxHeight:`70vh`,overflowY:`auto`},children:(0,Q.jsxs)(G,{orientation:`vertical`,size:`large`,style:{width:`100%`},children:[(0,Q.jsxs)(G,{children:[i.emoji?(0,Q.jsx)(`span`,{style:{fontSize:20},children:i.emoji}):(0,Q.jsx)(h,{style:{fontSize:20}}),(0,Q.jsx)(v.Text,{strong:!0,style:{fontSize:16},children:`Assistant Configuration`})]}),(0,Q.jsxs)(Y,{layout:`horizontal`,colon:!1,children:[(0,Q.jsx)(Y.Item,{label:`Display Name`,labelCol:{span:6},wrapperCol:{span:18},children:(0,Q.jsx)(J,{value:n.displayName,onChange:e=>r(`displayName`,e.target.value),placeholder:`Assistant display name`,disabled:!t})}),(0,Q.jsx)(Y.Item,{label:`Icon`,labelCol:{span:6},wrapperCol:{span:18},children:(0,Q.jsx)(cl,{value:n.emoji,onChange:e=>r(`emoji`,e),defaultEmoji:`🤖`,disabled:!t})}),(0,Q.jsx)(Y.Item,{label:`Description`,labelCol:{span:6},wrapperCol:{span:18},tooltip:`What does this assistant do? Visible to other agents via MCP.`,children:(0,Q.jsx)(J.TextArea,{value:n.description,onChange:e=>r(`description`,e.target.value),placeholder:`What does this assistant do?`,rows:2,disabled:!t})})]}),(0,Q.jsxs)(q,{column:1,bordered:!0,size:`small`,children:[i.frameworkRepo&&(0,Q.jsx)(q.Item,{label:`Framework Repo`,children:(0,Q.jsx)(v.Text,{code:!0,children:i.frameworkRepo})}),i.frameworkVersion&&(0,Q.jsx)(q.Item,{label:`Framework Version`,children:(0,Q.jsx)(v.Text,{code:!0,children:i.frameworkVersion})}),(0,Q.jsx)(q.Item,{label:`Created via`,children:i.createdViaOnboarding?(0,Q.jsx)(Aa,{color:`blue`,children:`Onboarding Wizard`}):(0,Q.jsx)(Aa,{children:`Manual`})})]})]})}):null},xm=[`start`,`stop`,`nuke`,`logs`],Sm=/^https?:\/\//i;function Cm(e){return Sm.test(e.trim())}function wm(e,t){return e===t||e.endsWith(`.${t}`)}function Tm(e){let t=e.split(`.`);if(t.length!==4)return!1;let n=t.map(e=>Number(e));if(n.some(e=>!Number.isInteger(e)||e<0||e>255))return!1;let[r,i]=n;return r===0||r===10||r===127||r===169&&i===254||r===172&&i>=16&&i<=31||r===192&&i===168||r>=224}function Em(e){let t=e.replace(/^\[|\]$/g,``).toLowerCase();if(!t.includes(`:`))return!1;let n=t.match(/:ffff:(\d+\.\d+\.\d+\.\d+)$/);if(n)return Tm(n[1]);let r=t.split(`:`).filter(Boolean),i=r.lastIndexOf(`ffff`);if(i>=0&&r.length-i===3){let e=Number.parseInt(r[i+1],16),t=Number.parseInt(r[i+2],16);if(Number.isInteger(e)&&Number.isInteger(t)&&e>=0&&e<=65535&&t>=0&&t<=65535)return Tm(`${e>>8}.${e&255}.${t>>8}.${t&255}`)}let a=Number.parseInt(r[0]??``,16);return t===`::1`||t===`::`||Number.isInteger(a)&&a>=65152&&a<=65215||Number.isInteger(a)&&a>=64512&&a<=65023}function Dm(e){let t;try{t=Et(e,`managed environment webhook`)}catch{return!1}if(!t)return!1;let n=new URL(t),r=n.hostname.toLowerCase();return!(n.username||n.password||r===`localhost`||wm(r,`localhost`)||r===`metadata.google.internal`||wm(r,`internal`)||r.endsWith(`.local`)||Tm(r)||Em(r))}function Om(e,t=`environment webhook`){let n=Et(e,t);if(!n)throw Error(`${t} must be a valid http(s) URL`);let r=new URL(n);if(r.username||r.password)throw Error(`${t} must not include URL credentials`);if(!Dm(n))throw Error(`${t} is blocked by Agor's managed-environment webhook policy`);return n}function km(e,t,n=`managed environment`){for(let r of xm){let i=e[r];if(i?.trim()){if(Cm(i)){Om(i,`${n} ${r} webhook`);continue}if(t===`webhook-only`)throw Error(`${n} ${r} must render to an http(s) URL webhook on this Agor instance`)}}}function Am(e,t,n=`repo environment`){for(let r of Object.keys(e.variants)){let i=Lt(e,r);if(!i)continue;let a={start:i.start,stop:i.stop,nuke:i.nuke,logs:i.logs};for(let e of xm){let i=a[e];i?.includes(`{{`)||km({[e]:i},t,`${n} variant "${r}"`)}}}function jm(e){if(!e)return`stopped`;if(e.status===`running`){let t=e.last_health_check?.status;return t===`healthy`?`healthy`:t===`unhealthy`?`unhealthy`:`running`}return e.status}function Mm(e){switch(e){case`stopped`:return`Stopped`;case`starting`:return`Starting...`;case`healthy`:return`Healthy`;case`unhealthy`:return`Unhealthy`;case`running`:return`Running`;case`stopping`:return`Stopping...`;case`error`:return`Error`;default:return`Unknown`}}var Nm=({value:e,onChange:t,readOnly:n=!1,placeholder:r,rows:i=14,height:a,minHeight:o,maxHeight:s})=>(0,Q.jsx)(`textarea`,{value:e,onChange:e=>t?.(e.target.value),readOnly:n,placeholder:r,rows:i,style:{width:`100%`,boxSizing:`border-box`,fontFamily:`monospace`,fontSize:12,height:a,minHeight:o??`${i*20}px`,maxHeight:s,padding:8,margin:0,border:`1px solid var(--ant-color-border, #424242)`,borderRadius:6,background:`var(--ant-color-fill-alter, transparent)`,color:`var(--ant-color-text)`,overflow:`auto`,resize:s?`none`:`vertical`}}),Pm=(0,Z.lazy)(async()=>{try{return await on(()=>import(`./CodeEditor.inner-Cuj6RuLL.js`),__vite__mapDeps([5,2,3,1]))}catch(e){return console.error(`Failed to load CodeMirror editor; falling back to plain text editor.`,e),{default:Nm}}}),Fm=e=>(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Nm,{...e,readOnly:!0}),children:(0,Q.jsx)(Pm,{...e})}),Im=n(((e,t)=>{t.exports=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/})),Lm=n(((e,t)=>{t.exports=/[\0-\x1F\x7F-\x9F]/})),Rm=n(((e,t)=>{t.exports=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/})),zm=n(((e,t)=>{t.exports=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4E\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDF55-\uDF59]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDF3C-\uDF3E]|\uD806[\uDC3B\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/})),Bm=n(((e,t)=>{t.exports=function(e){var t={};t.src_Any=Im().source,t.src_Cc=Lm().source,t.src_Z=Rm().source,t.src_P=zm().source,t.src_ZPCc=[t.src_Z,t.src_P,t.src_Cc].join(`|`),t.src_ZCc=[t.src_Z,t.src_Cc].join(`|`);var n=`[><|]`;return t.src_pseudo_letter=`(?:(?!`+n+`|`+t.src_ZPCc+`)`+t.src_Any+`)`,t.src_ip4=`(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)`,t.src_auth=`(?:(?:(?!`+t.src_ZCc+`|[@/\\[\\]()]).)+@)?`,t.src_port=`(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?`,t.src_host_terminator=`(?=$|`+n+`|`+t.src_ZPCc+`)(?!-|_|:\\d|\\.-|\\.(?!$|`+t.src_ZPCc+`))`,t.src_path=`(?:[/?#](?:(?!`+t.src_ZCc+`|`+n+`|[()[\\]{}.,"'?!\\-;]).|\\[(?:(?!`+t.src_ZCc+`|\\]).)*\\]|\\((?:(?!`+t.src_ZCc+`|[)]).)*\\)|\\{(?:(?!`+t.src_ZCc+`|[}]).)*\\}|\\"(?:(?!`+t.src_ZCc+`|["]).)+\\"|\\'(?:(?!`+t.src_ZCc+`|[']).)+\\'|\\'(?=`+t.src_pseudo_letter+`|[-]).|\\.{2,}[a-zA-Z0-9%/&]|\\.(?!`+t.src_ZCc+`|[.]).|`+(e&&e[`---`]?`\\-(?!--(?:[^-]|$))(?:-*)|`:`\\-+|`)+`,(?!`+t.src_ZCc+`).|;(?!`+t.src_ZCc+`).|\\!+(?!`+t.src_ZCc+`|[!]).|\\?(?!`+t.src_ZCc+`|[?]).)+|\\/)?`,t.src_email_name=`[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*`,t.src_xn=`xn--[a-z0-9\\-]{1,59}`,t.src_domain_root=`(?:`+t.src_xn+`|`+t.src_pseudo_letter+`{1,63})`,t.src_domain=`(?:`+t.src_xn+`|(?:`+t.src_pseudo_letter+`)|(?:`+t.src_pseudo_letter+`(?:-|`+t.src_pseudo_letter+`){0,61}`+t.src_pseudo_letter+`))`,t.src_host=`(?:(?:(?:(?:`+t.src_domain+`)\\.)*`+t.src_domain+`))`,t.tpl_host_fuzzy=`(?:`+t.src_ip4+`|(?:(?:(?:`+t.src_domain+`)\\.)+(?:%TLDS%)))`,t.tpl_host_no_ip_fuzzy=`(?:(?:(?:`+t.src_domain+`)\\.)+(?:%TLDS%))`,t.src_host_strict=t.src_host+t.src_host_terminator,t.tpl_host_fuzzy_strict=t.tpl_host_fuzzy+t.src_host_terminator,t.src_host_port_strict=t.src_host+t.src_port+t.src_host_terminator,t.tpl_host_port_fuzzy_strict=t.tpl_host_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_port_no_ip_fuzzy_strict=t.tpl_host_no_ip_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_fuzzy_test=`localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:`+t.src_ZPCc+`|>|$))`,t.tpl_email_fuzzy=`(^|`+n+`|"|\\(|`+t.src_ZCc+`)(`+t.src_email_name+`@`+t.tpl_host_fuzzy_strict+`)`,t.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+t.src_ZPCc+"))((?![$+<=>^`||])"+t.tpl_host_port_fuzzy_strict+t.src_path+`)`,t.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+t.src_ZPCc+"))((?![$+<=>^`||])"+t.tpl_host_port_no_ip_fuzzy_strict+t.src_path+`)`,t}})),Vm=n(((e,t)=>{function n(e){return Array.prototype.slice.call(arguments,1).forEach(function(t){t&&Object.keys(t).forEach(function(n){e[n]=t[n]})}),e}function r(e){return Object.prototype.toString.call(e)}function i(e){return r(e)===`[object String]`}function a(e){return r(e)===`[object Object]`}function o(e){return r(e)===`[object RegExp]`}function s(e){return r(e)===`[object Function]`}function c(e){return e.replace(/[.?*+^$[\]\\(){}|-]/g,`\\$&`)}var l={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function u(e){return Object.keys(e||{}).reduce(function(e,t){return e||l.hasOwnProperty(t)},!1)}var d={"http:":{validate:function(e,t,n){var r=e.slice(t);return n.re.http||(n.re.http=RegExp(`^\\/\\/`+n.re.src_auth+n.re.src_host_port_strict+n.re.src_path,`i`)),n.re.http.test(r)?r.match(n.re.http)[0].length:0}},"https:":`http:`,"ftp:":`http:`,"//":{validate:function(e,t,n){var r=e.slice(t);return n.re.no_http||(n.re.no_http=RegExp(`^`+n.re.src_auth+`(?:localhost|(?:(?:`+n.re.src_domain+`)\\.)+`+n.re.src_domain_root+`)`+n.re.src_port+n.re.src_host_terminator+n.re.src_path,`i`)),n.re.no_http.test(r)?t>=3&&e[t-3]===`:`||t>=3&&e[t-3]===`/`?0:r.match(n.re.no_http)[0].length:0}},"mailto:":{validate:function(e,t,n){var r=e.slice(t);return n.re.mailto||(n.re.mailto=RegExp(`^`+n.re.src_email_name+`@`+n.re.src_host_strict,`i`)),n.re.mailto.test(r)?r.match(n.re.mailto)[0].length:0}}},f=`a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]`,p=`biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф`.split(`|`);function m(e){e.__index__=-1,e.__text_cache__=``}function h(e){return function(t,n){var r=t.slice(n);return e.test(r)?r.match(e)[0].length:0}}function g(){return function(e,t){t.normalize(e)}}function _(e){var t=e.re=Bm()(e.__opts__),n=e.__tlds__.slice();e.onCompile(),e.__tlds_replaced__||n.push(f),n.push(t.src_xn),t.src_tlds=n.join(`|`);function r(e){return e.replace(`%TLDS%`,t.src_tlds)}t.email_fuzzy=RegExp(r(t.tpl_email_fuzzy),`i`),t.link_fuzzy=RegExp(r(t.tpl_link_fuzzy),`i`),t.link_no_ip_fuzzy=RegExp(r(t.tpl_link_no_ip_fuzzy),`i`),t.host_fuzzy_test=RegExp(r(t.tpl_host_fuzzy_test),`i`);var l=[];e.__compiled__={};function u(e,t){throw Error(`(LinkifyIt) Invalid schema "`+e+`": `+t)}Object.keys(e.__schemas__).forEach(function(t){var n=e.__schemas__[t];if(n!==null){var r={validate:null,link:null};if(e.__compiled__[t]=r,a(n)){o(n.validate)?r.validate=h(n.validate):s(n.validate)?r.validate=n.validate:u(t,n),s(n.normalize)?r.normalize=n.normalize:n.normalize?u(t,n):r.normalize=g();return}if(i(n)){l.push(t);return}u(t,n)}}),l.forEach(function(t){e.__compiled__[e.__schemas__[t]]&&(e.__compiled__[t].validate=e.__compiled__[e.__schemas__[t]].validate,e.__compiled__[t].normalize=e.__compiled__[e.__schemas__[t]].normalize)}),e.__compiled__[``]={validate:null,normalize:g()};var d=Object.keys(e.__compiled__).filter(function(t){return t.length>0&&e.__compiled__[t]}).map(c).join(`|`);e.re.schema_test=RegExp(`(^|(?!_)(?:[><|]|`+t.src_ZPCc+`))(`+d+`)`,`i`),e.re.schema_search=RegExp(`(^|(?!_)(?:[><|]|`+t.src_ZPCc+`))(`+d+`)`,`ig`),e.re.pretest=RegExp(`(`+e.re.schema_test.source+`)|(`+e.re.host_fuzzy_test.source+`)|@`,`i`),m(e)}function v(e,t){var n=e.__index__,r=e.__last_index__,i=e.__text_cache__.slice(n,r);this.schema=e.__schema__.toLowerCase(),this.index=n+t,this.lastIndex=r+t,this.raw=i,this.text=i,this.url=i}function y(e,t){var n=new v(e,t);return e.__compiled__[n.schema].normalize(n,e),n}function b(e,t){if(!(this instanceof b))return new b(e,t);t||u(e)&&(t=e,e={}),this.__opts__=n({},l,t),this.__index__=-1,this.__last_index__=-1,this.__schema__=``,this.__text_cache__=``,this.__schemas__=n({},d,e),this.__compiled__={},this.__tlds__=p,this.__tlds_replaced__=!1,this.re={},_(this)}b.prototype.add=function(e,t){return this.__schemas__[e]=t,_(this),this},b.prototype.set=function(e){return this.__opts__=n(this.__opts__,e),this},b.prototype.test=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return!1;var t,n,r,i,a,o,s,c,l;if(this.re.schema_test.test(e)){for(s=this.re.schema_search,s.lastIndex=0;(t=s.exec(e))!==null;)if(i=this.testSchemaAt(e,t[2],s.lastIndex),i){this.__schema__=t[2],this.__index__=t.index+t[1].length,this.__last_index__=t.index+t[0].length+i;break}}return this.__opts__.fuzzyLink&&this.__compiled__[`http:`]&&(c=e.search(this.re.host_fuzzy_test),c>=0&&(this.__index__<0||c<this.__index__)&&(n=e.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy))!==null&&(a=n.index+n[1].length,(this.__index__<0||a<this.__index__)&&(this.__schema__=``,this.__index__=a,this.__last_index__=n.index+n[0].length))),this.__opts__.fuzzyEmail&&this.__compiled__[`mailto:`]&&(l=e.indexOf(`@`),l>=0&&(r=e.match(this.re.email_fuzzy))!==null&&(a=r.index+r[1].length,o=r.index+r[0].length,(this.__index__<0||a<this.__index__||a===this.__index__&&o>this.__last_index__)&&(this.__schema__=`mailto:`,this.__index__=a,this.__last_index__=o))),this.__index__>=0},b.prototype.pretest=function(e){return this.re.pretest.test(e)},b.prototype.testSchemaAt=function(e,t,n){return this.__compiled__[t.toLowerCase()]?this.__compiled__[t.toLowerCase()].validate(e,n,this):0},b.prototype.match=function(e){var t=0,n=[];this.__index__>=0&&this.__text_cache__===e&&(n.push(y(this,t)),t=this.__last_index__);for(var r=t?e.slice(t):e;this.test(r);)n.push(y(this,t)),r=r.slice(this.__last_index__),t+=this.__last_index__;return n.length?n:null},b.prototype.tlds=function(e,t){return e=Array.isArray(e)?e:[e],t?(this.__tlds__=this.__tlds__.concat(e).sort().filter(function(e,t,n){return e!==n[t-1]}).reverse(),_(this),this):(this.__tlds__=e.slice(),this.__tlds_replaced__=!0,_(this),this)},b.prototype.normalize=function(e){e.schema||(e.url=`http://`+e.url),e.schema===`mailto:`&&!/^mailto:/i.test(e.url)&&(e.url=`mailto:`+e.url)},b.prototype.onCompile=function(){},t.exports=b})),Hm=e(n((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},e(t)};return function(r){if(r&&r.__esModule)return r;var i={};if(r!=null)for(var a=e(r),o=0;o<a.length;o++)a[o]!=="default"&&t(i,r,a[o]);return n(i,r),i}})(),i=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=h;var a=i(cn()),o=sn(),s=i(Vm()),c=r(je());function l(e,t=!1){return e=(0,o.escapeCarriageReturn)(g(e)),a.default.ansiToJson(e,{json:!0,remove_empty:!0,use_classes:t})}function u(e){let t=``;return e.bg&&(t+=`${e.bg}-bg `),e.fg&&(t+=`${e.fg}-fg `),e.decoration&&(t+=`ansi-${e.decoration} `),t===``?null:(t=t.substring(0,t.length-1),t)}function d(e){let t={};switch(e.bg&&(t.backgroundColor=`rgb(${e.bg})`),e.fg&&(t.color=`rgb(${e.fg})`),e.decoration){case`bold`:t.fontWeight=`bold`;break;case`dim`:t.opacity=`0.5`;break;case`italic`:t.fontStyle=`italic`;break;case`hidden`:t.visibility=`hidden`;break;case`strikethrough`:t.textDecoration=`line-through`;break;case`underline`:t.textDecoration=`underline`;break;case`blink`:t.textDecoration=`blink`;break;default:break}return t}function f(e,t,n,r){let i=t?null:d(n),a=t?u(n):null;return e?e===`fuzzy`?m(n,r,i,a):p(n,r,i,a):c.createElement(`span`,{style:i,key:r,className:a},n.content)}function p(e,t,n,r){let i=[],a=/(\s|^)(https?:\/\/(?:www\.|(?!www))[^\s.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/g,o=0,s;for(;(s=a.exec(e.content))!==null;){let[,t,n]=s,r=s.index+t.length;r>o&&i.push(e.content.substring(o,r));let l=n.startsWith(`www.`)?`http://${n}`:n;i.push(c.createElement(`a`,{key:o,href:l,target:`_blank`},`${n}`)),o=a.lastIndex}return o<e.content.length&&i.push(e.content.substring(o)),c.createElement(`span`,{style:n,key:t,className:r},i)}function m(e,t,n,r){let i=(0,s.default)({fuzzyEmail:!1}).tlds([`io`],!0);if(!i.pretest(e.content))return c.createElement(`span`,{style:n,key:t,className:r},e.content);let a=i.match(e.content);if(!a)return c.createElement(`span`,{style:n,key:t,className:r},e.content);let o=[e.content.substring(0,a[0]?.index)];return a.forEach((t,n)=>{o.push(c.createElement(`a`,{href:t.url,target:`_blank`,key:n},e.content.substring(t.index,t.lastIndex))),a[n+1]&&o.push(e.content.substring(a[n].lastIndex,a[n+1]?.index))}),a[a.length-1].lastIndex!==e.content.length&&o.push(e.content.substring(a[a.length-1].lastIndex,e.content.length)),c.createElement(`span`,{style:n,key:t,className:r},o)}function h(e){let{className:t,useClasses:n,children:r,linkify:i}=e;return c.createElement(`code`,{className:t},l(r??``,n??!1).map(f.bind(null,i??!1,n??!1)))}function g(e){let t=e;do e=t,t=e.replace(/[^\n]\x08/gm,``);while(t.length<e.length);return e}}))(),1),Um=Hm.default.default,Wm=typeof Hm.default==`function`?Hm.default:Um??Hm.default,{Text:Gm}=v,Km=1e4,qm=({open:e,onClose:t,branch:n,client:r})=>{let{token:i}=X.useToken(),[o,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!0),p=(0,Z.useRef)(null),m=(0,Z.useRef)(null),h=(0,Z.useRef)(null),g=(0,Z.useRef)(!1),_=(0,Z.useCallback)(async(e=!1,t=!1)=>{if(!r||g.current)return;g.current=!0;let i=p.current,a=i&&Math.abs(i.scrollHeight-i.scrollTop-i.clientHeight)<10;t&&u(!0);try{let t=await r.service(`branches/logs`).find({query:{branch_id:n.branch_id}});c(t),m.current=t;let o=!!m.current;e&&(a||!o)&&setTimeout(()=>{i?.scrollTo({top:i.scrollHeight,behavior:`smooth`})},100)}catch(e){let t={logs:``,timestamp:new Date().toISOString(),error:e instanceof Error?e.message:`Failed to fetch logs`};c(t),m.current=t}finally{g.current=!1,t&&u(!1)}},[r,n.branch_id]);return(0,Z.useEffect)(()=>{e?_(!0,!0):(c(null),m.current=null)},[e,_]),(0,Z.useEffect)(()=>(h.current&&=(clearInterval(h.current),null),d&&e&&(h.current=setInterval(()=>{_(!0)},Km)),()=>{h.current&&=(clearInterval(h.current),null)}),[d,e,_]),(0,Q.jsx)(a,{title:`Environment Logs - ${n.name}`,open:e,onCancel:t,width:900,style:{top:20},footer:[(0,Q.jsx)(U,{checked:d,onChange:e=>f(e.target.checked),children:`Auto-refresh`},`auto-refresh`),(0,Q.jsx)(s,{icon:(0,Q.jsx)(he,{}),onClick:()=>_(!1,!0),loading:l,children:`Refresh`},`refresh`),(0,Q.jsx)(s,{onClick:t,children:`Close`},`close`)],children:(0,Q.jsx)(co,{fallbackTitle:`Couldn't render the logs viewer.`,resetKey:o?.timestamp,children:(0,Q.jsxs)(G,{orientation:`vertical`,size:`middle`,style:{width:`100%`},children:[o&&!o.error&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(Gm,{type:`secondary`,style:{fontSize:12},children:[`Fetched at: `,(e=>new Date(e).toLocaleString())(o.timestamp)]}),o.truncated&&(0,Q.jsx)(z,{title:`Logs truncated (showing last 500 lines)`,type:`warning`,showIcon:!0,style:{marginTop:8},banner:!0})]}),o?.error&&(0,Q.jsx)(z,{title:`Error fetching logs`,description:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{children:o.error}),o.error.includes(`No logs command`)&&(0,Q.jsx)(`div`,{style:{marginTop:8,fontSize:12},children:`Configure a 'logs' command in .env-config.yaml to view logs.`})]}),type:`error`,showIcon:!0}),o&&!o.error&&(0,Q.jsx)(`div`,{ref:p,style:{backgroundColor:`#000`,border:`1px solid ${i.colorBorder}`,borderRadius:i.borderRadius,padding:16,height:`60vh`,overflowY:`auto`,fontFamily:`monospace`,fontSize:12,whiteSpace:`pre-wrap`,wordBreak:`break-word`,color:`#fff`},children:o.logs?(0,Q.jsx)(Wm,{children:String(o.logs)}):`(no logs)`}),l&&!o&&(0,Q.jsx)(`div`,{style:{textAlign:`center`,padding:40,color:i.colorTextSecondary,height:`60vh`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:`Loading logs...`})]})})})},Jm=`https://agor.live/guide/environment-configuration`;function Ym(e){return{start:e.start_command||void 0,stop:e.stop_command||void 0,nuke:e.nuke_command||void 0,logs:e.logs_command||void 0,health:e.health_check_url||void 0,app:e.app_url||void 0}}function Xm(e){try{return Kt(e,{indent:2,lineWidth:100,noRefs:!0})}catch{return``}}var Zm=({branch:e,repo:t,client:n,onUpdateRepo:r,onUpdateBranch:i,canControlEnvironment:a})=>{let{token:c}=X.useToken(),{showSuccess:f,showError:p}=cf(),{confirm:m}=uf(),h=df(),{isAdmin:_}=_f(),{featuresConfig:y}=af(),b=y?.managedEnvsExecutionMode??`hybrid`,x=b===`webhook-only`,S=a??_,C=S?void 0:`Requires branch 'all' permission or admin access`,w=x?`This instance uses webhook-managed environments. Use public http(s) URLs for start, stop, nuke, and logs.`:`This instance supports shell commands and URL webhooks for start, stop, nuke, and logs.`,T=x?`version: 2
8
- default: remote
9
- variants:
10
- remote:
11
- start: https://env.example.com/start?branch={{branch.name}}
12
- stop: https://env.example.com/stop?branch={{branch.name}}
13
- health: https://apps.example.com/{{branch.name}}/health
14
- app: https://apps.example.com/{{branch.name}}
15
- `:`version: 2
16
- default: lean
17
- variants:
18
- lean:
19
- start: docker compose up -d
20
- stop: docker compose down
21
- `,[E,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)(()=>t.environment?Xm(t.environment):``),[A,j]=(0,Z.useState)(null),[M,N]=(0,Z.useState)(!1),[I,L]=(0,Z.useState)(()=>Xm(Ym(e))),[te,R]=(0,Z.useState)(null),ne=t.environment?Object.keys(t.environment.variants):[],[B,V]=(0,Z.useState)(e.environment_variant??t.environment?.default??ne[0]??``),[re,ie]=(0,Z.useState)(!1),[U,ae]=(0,Z.useState)(e.environment_instance?.status||`stopped`),[oe,se]=(0,Z.useState)(e.environment_instance?.last_health_check),[ce,le]=(0,Z.useState)(e.environment_instance?.last_error),[ue,de]=(0,Z.useState)(!1),[fe,pe]=(0,Z.useState)(!1),[ge,_e]=(0,Z.useState)(!1),[ve,ye]=(0,Z.useState)(!1),[be,Se]=(0,Z.useState)(!1),Ce=(0,Z.useRef)(e),we=(0,Z.useRef)(t);(0,Z.useEffect)(()=>{ae(e.environment_instance?.status||`stopped`),se(e.environment_instance?.last_health_check),le(e.environment_instance?.last_error);let t=Ce.current!==e;Ce.current=e,t&&!M&&(L(Xm(Ym(e))),R(null)),t&&e.environment_variant&&V(e.environment_variant)},[e,M]),(0,Z.useEffect)(()=>{let e=we.current!==t;we.current=t,e&&!E&&(k(t.environment?Xm(t.environment):``),j(null))},[t,E]),(0,Z.useEffect)(()=>{if(!n)return;let t=t=>{let n=t;n.branch_id===e.branch_id&&(ae(n.environment_instance?.status||`stopped`),se(n.environment_instance?.last_health_check),le(n.environment_instance?.last_error))};return n.service(`branches`).on(`patched`,t),()=>n.service(`branches`).removeListener(`patched`,t)},[n,e.branch_id]);let W=async()=>{if(n){de(!0);try{await n.service(`branches/${e.branch_id}/start`).create({}),f(`Environment start requested`)}catch(e){p(e instanceof Error?e.message:`Failed to start environment`)}finally{de(!1)}}},Te=async()=>{if(n){pe(!0);try{await n.service(`branches/${e.branch_id}/stop`).create({}),f(`Environment stop requested`)}catch(e){p(e instanceof Error?e.message:`Failed to stop environment`)}finally{pe(!1)}}},Ee=async()=>{if(n){_e(!0);try{await n.service(`branches/${e.branch_id}/restart`).create({}),f(`Environment restart requested`)}catch(e){p(e instanceof Error?e.message:`Failed to restart environment`)}finally{_e(!1)}}},De=()=>{n&&h(async()=>{ye(!0);try{await n.service(`branches/${e.branch_id}/nuke`).create({}),f(`Environment nuke requested`)}catch(e){p(e instanceof Error?e.message:`Failed to nuke environment`)}finally{ye(!1)}})},Oe=B!==e.environment_variant,ke=U===`running`||U===`starting`,Ae=!S||!t.environment||!B||Oe&&ke||re,je=S?t.environment?Oe&&ke?`Stop the environment before switching variants (currently ${U})`:void 0:`Configure repo environment variants first`:C,Ne=async()=>{if(n){ie(!0);try{let t=await n.service(`branches/${e.branch_id}/render-environment`).create({variant:B});f(Oe?`Rendered variant "${B}" to branch`:`Re-rendered branch environment`),L(Xm(Ym(t))),R(null),t.environment_variant&&V(t.environment_variant)}catch(e){p(e instanceof Error?e.message:`Failed to render environment`)}finally{ie(!1)}}},Pe=()=>{if(!Ae){if(_&&I.trim()!==Xm(Ym(e)).trim()){m({title:`Discard local snapshot edits?`,content:`The branch has unsaved manual edits in the snapshot editor. Rendering will overwrite them.`,okText:`Render anyway`,okType:`danger`,cancelText:`Cancel`,onOk:Ne});return}Ne()}},Fe=e=>{if(!e.trim())return j(`Empty — paste or write a RepoEnvironment YAML document`),null;let t;try{t=Qt(e)}catch(e){return j(e instanceof Error?e.message:`Invalid YAML`),null}try{let e=Tt(t);if(x)try{Am(e,b)}catch(e){return j(e instanceof Error?e.message:`Invalid webhook lifecycle URL`),null}return j(null),e}catch(e){return j(e instanceof Error?e.message:`Invalid RepoEnvironment`),null}},K=()=>{if(!r)return;let e=Fe(O);e&&(r(t.repo_id,{environment:e}),D(!1))},Ie=()=>{k(t.environment?Xm(t.environment):``),j(null),D(!1)},Le=e=>{if(!e.trim())return R("Empty — provide at least `start` and `stop`"),null;let t;try{t=Qt(e)}catch(e){return R(e instanceof Error?e.message:`Invalid YAML`),null}if(typeof t!=`object`||!t)return R(`Expected a YAML mapping (object)`),null;let n=t;if(!n.start||typeof n.start!=`string`)return R("`start` is required and must be a string"),null;if(!n.stop||typeof n.stop!=`string`)return R("`stop` is required and must be a string"),null;if(x)try{km({start:n.start,stop:n.stop,nuke:n.nuke,logs:n.logs},b,`branch environment`)}catch(e){return R(e instanceof Error?e.message:`Invalid webhook lifecycle URL`),null}return R(null),n},ze=()=>{if(!i)return;let t=Le(I);t&&(i(e.branch_id,{start_command:t.start||void 0,stop_command:t.stop||void 0,nuke_command:t.nuke||void 0,logs_command:t.logs||void 0,health_check_url:t.health||void 0,app_url:t.app||void 0}),N(!1))},Be=()=>{L(Xm(Ym(e))),R(null),N(!1)},q=()=>{if(!n||!r)return;let i=t.environment?Object.keys(t.environment.variants):[];m({title:`Import .agor.yml?`,icon:(0,Q.jsx)(ee,{}),content:(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`p`,{children:[`This will replace your repo-level variants with the contents of `,(0,Q.jsx)(`code`,{children:`.agor.yml`}),` `,`in this branch.`]}),i.length>0&&(0,Q.jsxs)(`p`,{style:{marginBottom:4},children:[`Current variants that will be replaced:`,` `,i.map(e=>(0,Q.jsx)(u,{style:{marginBottom:4},children:e},e))]}),(0,Q.jsxs)(`p`,{style:{marginTop:8},children:[`Your `,(0,Q.jsx)(`code`,{children:`template_overrides`}),` and branch-level snapshots are preserved.`]})]}),okText:`Import`,cancelText:`Cancel`,onOk:async()=>{try{let i=await n.service(`repos/${t.repo_id}/import-agor-yml`).create({branch_id:e.branch_id});i.environment&&k(Xm(i.environment)),r(t.repo_id,{environment:i.environment}),f(`Imported .agor.yml`)}catch(e){p(e instanceof Error?e.message:`Failed to import .agor.yml`)}}})},He=()=>{n&&m({title:`Export to .agor.yml?`,icon:(0,Q.jsx)(xe,{}),content:(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`p`,{children:[`This will overwrite `,(0,Q.jsx)(`code`,{children:`.agor.yml`}),` in the repo root (this branch's working copy).`]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`code`,{children:`template_overrides`}),` stays local and will not be written.`]})]}),okText:`Export`,cancelText:`Cancel`,onOk:async()=>{try{await n.service(`repos/${t.repo_id}/export-agor-yml`).create({branch_id:e.branch_id}),f(`Environment configuration exported to .agor.yml`)}catch(e){p(e instanceof Error?e.message:`Failed to export .agor.yml`)}}})},Ue=jm(e.environment_instance),We=!!t.environment,Ge=!We,Ke=M,qe=E,Je=(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:11},children:(0,Q.jsx)(`a`,{href:Jm,target:`_blank`,rel:`noopener noreferrer`,children:`Documentation`})}),J=(0,Z.useMemo)(()=>{let e=Mm(Ue);switch(Ue){case`healthy`:return(0,Q.jsx)(v.Text,{strong:!0,style:{color:c.colorSuccess},children:e});case`unhealthy`:return(0,Q.jsx)(v.Text,{strong:!0,style:{color:c.colorError},children:e});case`running`:return(0,Q.jsx)(v.Text,{strong:!0,style:{color:c.colorInfo},children:e});case`starting`:case`stopping`:return(0,Q.jsx)(v.Text,{strong:!0,children:e});case`error`:return(0,Q.jsx)(v.Text,{strong:!0,type:`danger`,children:e});default:return(0,Q.jsx)(v.Text,{type:`secondary`,children:e})}},[Ue,c]),Ye=oe?oe.status===`healthy`?(0,Q.jsx)(st,{style:{color:c.colorSuccess}}):oe.status===`unhealthy`?(0,Q.jsx)(ut,{style:{color:c.colorError}}):(0,Q.jsx)(Ve,{style:{color:c.colorWarning}}):null,Y=ne.map(e=>{let n=t.environment?.variants[e]?.description,r=t.environment?.default===e;return{value:e,label:(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`strong`,{children:e}),r&&(0,Q.jsx)(u,{color:`blue`,style:{marginLeft:6,fontSize:10},children:`default`}),n&&(0,Q.jsx)(v.Text,{type:`secondary`,style:{marginLeft:8,fontSize:11},children:n})]})}});return(0,Q.jsxs)(`div`,{style:{width:`100%`,maxHeight:`70vh`,overflowY:`auto`},children:[(0,Q.jsxs)(G,{orientation:`vertical`,size:`large`,style:{width:`100%`},children:[We&&(0,Q.jsxs)(g,{size:`small`,children:[(0,Q.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,flexWrap:`wrap`},children:[U===`running`&&(0,Q.jsx)(Ze,{size:`small`}),Ye,J,(0,Q.jsx)(`div`,{style:{flex:1}}),(0,Q.jsx)(s,{type:`primary`,size:`small`,icon:ue?(0,Q.jsx)(me,{}):(0,Q.jsx)(F,{}),onClick:W,loading:ue,disabled:!S||U===`running`||U===`starting`||ue||fe||ge,title:C,children:`Start`}),(0,Q.jsx)(s,{size:`small`,icon:fe?(0,Q.jsx)(me,{}):(0,Q.jsx)(o,{}),onClick:Te,loading:fe,disabled:!S,title:C,danger:!0,children:`Stop`}),(0,Q.jsx)(s,{size:`small`,icon:ge?(0,Q.jsx)(me,{}):(0,Q.jsx)(he,{}),onClick:Ee,disabled:!S||ue||fe||ge,loading:ge,title:C,children:`Restart`}),e.nuke_command&&(0,Q.jsx)(s,{size:`small`,icon:ve?(0,Q.jsx)(me,{}):(0,Q.jsx)(Me,{}),onClick:De,disabled:!S||ue||fe||ge||ve,loading:ve,danger:!0,title:C??`Nuke environment (destructive - removes all data and volumes)`,children:`Nuke`}),(0,Q.jsx)(s,{size:`small`,icon:(0,Q.jsx)(Re,{}),onClick:()=>Se(!0),disabled:!S||!e.logs_command,title:S?e.logs_command?void 0:`Configure a logs command in the variant to enable`:C,children:`View Logs`})]}),U===`error`&&(oe?.message||ce)&&(0,Q.jsx)(z,{style:{marginTop:12,fontSize:11},type:`error`,showIcon:!0,title:oe?.message||`Environment Error`,description:ce&&(0,Q.jsx)(`pre`,{style:{maxHeight:200,overflow:`auto`,margin:0,fontSize:11,whiteSpace:`pre-wrap`,wordBreak:`break-word`},children:ce})})]}),Ge&&(0,Q.jsx)(z,{type:`info`,showIcon:!0,title:`No environment variants configured`,description:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{style:{marginBottom:8},children:_?`Import from an existing .agor.yml or add variants in the repo editor below.`:`Ask an admin to set up environment commands in the repo editor below.`}),_&&(0,Q.jsx)(G,{children:(0,Q.jsx)(s,{size:`small`,icon:(0,Q.jsx)(ee,{}),onClick:q,children:`Import from .agor.yml`})}),(0,Q.jsx)(`div`,{style:{marginTop:8},children:(0,Q.jsx)(`a`,{href:Jm,target:`_blank`,rel:`noopener noreferrer`,children:`Documentation: environment variants`})})]})}),(0,Q.jsx)(g,{size:`small`,title:(0,Q.jsxs)(G,{children:[(0,Q.jsx)(it,{}),(0,Q.jsx)(`span`,{children:`Repository environment (shared)`}),(0,Q.jsx)(u,{color:`orange`,style:{fontSize:10},children:`Affects all branches on this repo`})]}),extra:(0,Q.jsxs)(G,{size:`small`,children:[(0,Q.jsx)(H,{title:_?`Replace variants with contents of .agor.yml in this branch`:`Only admins can import .agor.yml`,children:(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(ee,{}),onClick:q,disabled:!_,children:`Import`})}),(0,Q.jsx)(H,{title:We?_?`Write variants + default to .agor.yml (template_overrides stripped)`:`Only admins can export .agor.yml`:`No configuration to export`,children:(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(xe,{}),onClick:He,disabled:!_||!We,children:`Export`})}),!E&&(0,Q.jsx)(H,{title:_?Ke?`Finish editing the branch snapshot first`:void 0:`Only admins can edit repo environment`,children:(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(P,{}),onClick:()=>D(!0),disabled:!_||Ke,children:`Edit`})})]}),children:(0,Q.jsxs)(G,{orientation:`vertical`,size:`small`,style:{width:`100%`},children:[(0,Q.jsx)(z,{type:`info`,showIcon:!0,message:x?`Webhook-managed environments`:`Managed environments`,description:w,style:{fontSize:12}}),(0,Q.jsxs)(v.Text,{type:`secondary`,style:{fontSize:11},children:[`YAML representation of `,(0,Q.jsx)(`code`,{children:`repo.environment`}),`. Includes `,(0,Q.jsx)(`code`,{children:`version`}),`,`,` `,(0,Q.jsx)(`code`,{children:`default`}),`, `,(0,Q.jsx)(`code`,{children:`variants`}),`, and optional`,` `,(0,Q.jsx)(`code`,{children:`template_overrides`}),`. `,Je]}),(0,Q.jsx)(Fm,{value:O,onChange:e=>{k(e),A&&j(null)},language:`yaml`,placeholder:Ge&&_?T:``,readOnly:!E,rows:10,maxHeight:`480px`}),A&&(0,Q.jsx)(z,{type:`error`,showIcon:!0,title:`Invalid repo environment: ${A}`}),E&&(0,Q.jsxs)(G,{children:[(0,Q.jsx)(s,{type:`primary`,size:`small`,icon:(0,Q.jsx)(d,{}),onClick:K,children:`Save`}),(0,Q.jsx)(s,{size:`small`,onClick:Ie,children:`Cancel`})]})]})}),(0,Q.jsx)(g,{size:`small`,children:(0,Q.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,flexWrap:`wrap`},children:[(0,Q.jsx)(v.Text,{strong:!0,style:{fontSize:13},children:`Variant:`}),(0,Q.jsx)(l,{value:B||void 0,onChange:V,style:{minWidth:260},size:`small`,options:Y,disabled:!We,placeholder:Ge?`No variants configured — ask an admin`:`Select a variant`}),Oe&&(0,Q.jsx)(u,{color:`gold`,style:{fontSize:10},children:`will replace snapshot`}),(0,Q.jsx)(`div`,{style:{flex:1}}),(0,Q.jsx)(H,{title:je,children:(0,Q.jsx)(s,{type:`primary`,size:`small`,icon:re?(0,Q.jsx)(me,{}):(0,Q.jsx)($e,{}),onClick:Pe,loading:re,disabled:Ae,children:`Render`})})]})}),(0,Q.jsx)(g,{size:`small`,title:(0,Q.jsxs)(G,{children:[(0,Q.jsx)(F,{}),(0,Q.jsxs)(`span`,{children:[`Branch environment: `,e.name]}),e.environment_variant&&(0,Q.jsxs)(u,{color:`blue`,style:{fontSize:10},children:[`rendered from: `,e.environment_variant]})]}),extra:!M&&(0,Q.jsx)(H,{title:_?qe?`Finish editing the repo environment first`:`Edit the rendered commands for this branch only`:`Only admins can edit the rendered snapshot directly`,children:(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(P,{}),onClick:()=>N(!0),disabled:!_||qe,children:`Edit`})}),children:(0,Q.jsxs)(G,{orientation:`vertical`,size:`small`,style:{width:`100%`},children:[(0,Q.jsxs)(v.Text,{type:`secondary`,style:{fontSize:11},children:[`Rendered snapshot persisted on this branch (fields: `,(0,Q.jsx)(`code`,{children:`start`}),`,`,` `,(0,Q.jsx)(`code`,{children:`stop`}),`, `,(0,Q.jsx)(`code`,{children:`nuke`}),`, `,(0,Q.jsx)(`code`,{children:`logs`}),`, `,(0,Q.jsx)(`code`,{children:`health`}),`,`,` `,(0,Q.jsx)(`code`,{children:`app`}),`). `,w,` Click Render above to regenerate from the variant.`]}),(0,Q.jsx)(Fm,{value:I,onChange:e=>{L(e),te&&R(null)},language:`yaml`,readOnly:!M,rows:10,maxHeight:`480px`}),te&&(0,Q.jsx)(z,{type:`error`,showIcon:!0,title:`Invalid snapshot: ${te}`}),M&&(0,Q.jsxs)(G,{children:[(0,Q.jsx)(s,{type:`primary`,size:`small`,icon:(0,Q.jsx)(d,{}),onClick:ze,children:`Save`}),(0,Q.jsx)(s,{size:`small`,onClick:Be,children:`Cancel`})]})]})})]}),(0,Q.jsx)(qm,{open:be,onClose:()=>Se(!1),branch:e,client:n})]})},Qm=(0,Z.lazy)(()=>on(()=>import(`./ThemedSyntaxHighlighter.inner-C1FdIHn0.js`),__vite__mapDeps([6,3,2,7,8,9,1]))),$m=({children:e,customStyle:t,PreTag:n=`pre`})=>{let{token:r}=X.useToken();return(0,Q.jsx)(n,{style:{margin:0,borderRadius:r.borderRadius,fontFamily:`ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace`,whiteSpace:`pre`,...t},children:e})},eh=e=>(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)($m,{...e}),children:(0,Q.jsx)(Qm,{...e})}),th={js:`javascript`,cjs:`javascript`,mjs:`javascript`,ts:`typescript`,jsx:`jsx`,tsx:`tsx`,py:`python`,rb:`ruby`,go:`go`,rs:`rust`,java:`java`,c:`c`,cpp:`cpp`,h:`c`,hpp:`cpp`,css:`css`,scss:`scss`,html:`html`,xml:`xml`,json:`json`,yaml:`yaml`,yml:`yaml`,sh:`bash`,bash:`bash`,sql:`sql`,graphql:`graphql`,proto:`protobuf`,toml:`toml`,vue:`vue`,svelte:`svelte`,md:`markdown`,markdown:`markdown`,env:`bash`};function nh(e){return th[e.split(`.`).pop()?.toLowerCase()??``]??`text`}var rh=({file:e,open:t,onClose:n,loading:r})=>{let{showSuccess:i}=cf();if(!e)return null;let o=nh(e.path);return(0,Q.jsx)(a,{title:e.path,open:t,onCancel:n,width:900,styles:{body:{maxHeight:`70vh`,overflow:`auto`}},footer:[(0,Q.jsx)(s,{icon:(0,Q.jsx)(E,{}),onClick:async()=>{await Xa(e.path),i(`Path copied to clipboard!`)},children:`Copy Path`},`copy-path`),(0,Q.jsx)(s,{type:`primary`,icon:(0,Q.jsx)(E,{}),onClick:async()=>{await Xa(e.content),i(`Content copied to clipboard!`)},children:`Copy Content`},`copy-content`),(0,Q.jsx)(s,{onClick:n,children:`Close`},`close`)],children:r?(0,Q.jsx)(Ze,{style:{display:`block`,padding:`2rem`},description:`Loading file…`}):(0,Q.jsx)(eh,{language:o,showLineNumbers:!0,children:e.content})})},{Search:ih}=J,ah=300;function oh(e,t,n,r){let i=t?e.filter(e=>e.title.toLowerCase().includes(t.toLowerCase())||e.path.toLowerCase().includes(t.toLowerCase())):e,a=new Map;for(let e of i){let t=e.path.split(`/`),i=``;for(let e=0;e<t.length-1;e++){let n=t[e],r=i;if(i=i?`${i}/${n}`:n,!a.has(i)&&(a.set(i,{key:i,title:(0,Q.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:8},children:[(0,Q.jsx)(se,{}),(0,Q.jsx)(`strong`,{children:n})]}),isLeaf:!1,children:[]}),r&&a.has(r))){let e=a.get(r);e.children=e.children||[],e.children.push(a.get(i))}}let o=e.path.endsWith(`.md`)?Xe:x,c=t[t.length-1],l=(e=>e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`)(e.size),u=`${e.path} (${l})`,d={key:e.path,title:(0,Q.jsx)(H,{title:u,mouseEnterDelay:.5,children:(0,Q.jsxs)(`div`,{style:{display:`inline-flex`,justifyContent:`space-between`,alignItems:`center`,width:`100%`},children:[(0,Q.jsxs)(`span`,{style:{flex:1,minWidth:0,display:`inline-flex`,alignItems:`center`,gap:8},children:[(0,Q.jsx)(o,{}),c]}),(0,Q.jsxs)(`span`,{style:{marginLeft:8,whiteSpace:`nowrap`,display:`inline-flex`,gap:4},children:[(0,Q.jsx)(H,{title:`Copy path`,children:(0,Q.jsx)(s,{size:`small`,type:`text`,icon:(0,Q.jsx)(E,{}),onClick:t=>{t.stopPropagation(),r&&r(e)}})}),n&&(0,Q.jsx)(H,{title:`Download file`,children:(0,Q.jsx)(s,{size:`small`,type:`text`,icon:(0,Q.jsx)(ee,{}),onClick:t=>{t.stopPropagation(),n(e)}})})]})]})}),isLeaf:!0,file:e};if(i&&a.has(i)){let e=a.get(i);e.children=e.children||[],e.children.push(d)}else a.set(e.path,d)}let o=[],c=new Set(a.keys());for(let[e,t]of a.entries()){let n=e.split(`/`).slice(0,-1).join(`/`);(!n||!c.has(n))&&o.push(t)}let l=e=>{let t=e.filter(e=>!e.isLeaf),n=e.filter(e=>e.isLeaf);return t.sort((e,t)=>e.key.localeCompare(t.key)),n.sort((e,t)=>e.key.localeCompare(t.key)),t.forEach(e=>{e.children&&=l(e.children)}),[...t,...n]};return l(o)}var sh=(0,Z.memo)(({files:e,onFileClick:t,onDownload:n,loading:r=!1,emptyMessage:i=`No files found`})=>{let[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)([]),{showSuccess:d}=cf(),f=(0,Z.useRef)(n);f.current=n;let p=(0,Z.useRef)(t);p.current=t;let m=(0,Z.useRef)(null),h=(0,Z.useRef)(null),g=(0,Z.useCallback)(async e=>{await Xa(e.path),d(`Path copied to clipboard!`)},[d]),_=(0,Z.useCallback)(e=>{f.current?.(e)},[]),v=(0,Z.useMemo)(()=>oh(e,a,_,g),[e,a,_,g]),y=(0,Z.useCallback)((e,t)=>{t.node.isLeaf&&t.node.file&&p.current(t.node.file)},[]),b=(0,Z.useCallback)(e=>{let t=[],n=e=>{e.isLeaf||t.push(e.key),e.children&&e.children.forEach(n)};return e.forEach(n),t},[]),x=(0,Z.useCallback)(e=>{let t=e.target.value;c(t),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{o(t),h.current=t},ah)},[]),S=(0,Z.useCallback)(e=>{m.current&&clearTimeout(m.current),c(e),o(e),h.current=e},[]);(0,Z.useEffect)(()=>()=>{m.current&&clearTimeout(m.current)},[]);let C=(0,Z.useRef)(v);(0,Z.useEffect)(()=>{if(C.current!==v&&h.current!==null){let e=h.current;if(h.current=null,e){let e=b(v);u(t=>e.length!==t.length||!e.every(e=>t.includes(e))?e:t)}else u(e=>e.length>0?[]:e)}C.current=v},[v,b]);let T=(0,Z.useCallback)(e=>{u(e)},[]);return r?(0,Q.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,Q.jsx)(Ze,{size:`large`})}):!r&&e.length===0?(0,Q.jsx)(`div`,{style:{padding:48},children:(0,Q.jsx)(fe,{description:i})}):(0,Q.jsxs)(`div`,{style:{padding:`0 24px`},children:[(0,Q.jsx)(`div`,{style:{marginBottom:16},children:(0,Q.jsx)(ih,{placeholder:`Search files...`,allowClear:!0,value:s,onSearch:S,onChange:x,style:{width:`100%`}})}),(0,Q.jsx)(w,{className:`agor-flat-tree`,treeData:v,onSelect:y,showIcon:!1,expandedKeys:l,onExpand:T,style:{background:`transparent`,borderRadius:0,padding:0},virtual:!0,height:600})]})},(e,t)=>e.loading===t.loading&&e.emptyMessage===t.emptyMessage&&e.files===t.files),ch=/^h[1-6]$/;function lh(e){return e.trim().toLowerCase().normalize(`NFKD`).replace(/[\u0300-\u036f]/g,``).replace(/[^\p{Letter}\p{Number}\s_-]/gu,``).replace(/[\s_]+/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``)||`heading`}function uh(){let e={seen:new Map};return t=>{let n=lh(t),r=e.seen.get(n)??0;return e.seen.set(n,r+1),r===0?n:`${n}-${r}`}}function dh(e){return e?e.type===`text`||e.type===`inlineCode`?typeof e.value==`string`?e.value:``:(e.children??[]).map(dh).join(``):``}function fh(e,t){t(e);for(let n of e.children??[])fh(n,t)}function ph(){return e=>{let t=uh();fh(e,e=>{if(e.type!==`element`||!e.tagName||!ch.test(e.tagName))return;let n=dh(e),r=t(n);e.properties={...e.properties??{},id:r},e.children=[...e.children??[],{type:`element`,tagName:`a`,properties:{className:[`markdown-heading-anchor`],href:`#${r}`,ariaLabel:`Link to ${n||`heading`}`},children:[{type:`text`,value:`#`}]}]})}}function mh(e){let t=/@(?:"[^"]*"|[^\s]+)/g,n=[],r=/^ {0,3}```[\s\S]*?^ {0,3}```|^ {0,3}~~~[\s\S]*?^ {0,3}~~~/gm,i=r.exec(e);for(;i!==null;)n.push({start:i.index,end:i.index+i[0].length}),i=r.exec(e);let a=/`[^`\n]+`|``[^`\n]+``/g;for(i=a.exec(e);i!==null;)n.push({start:i.index,end:i.index+i[0].length}),i=a.exec(e);n.sort((e,t)=>e.start-t.start);let o=e=>n.some(t=>e>=t.start&&e<t.end);return e.replace(t,(e,t)=>o(t)?e:`<span style="background-color: rgba(22, 119, 255, 0.15); border-radius: 3px; padding: 0 2px; font-weight: 600;">${e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#039;`)}</span>`)}var hh=e=>e.colorBgLayout?.startsWith?.(`#0`)||e.colorBgLayout?.startsWith?.(`rgb(0`)||e.colorBgLayout?.startsWith?.(`rgba(0`)||!1,gh=(e,t,n=50,r=50)=>{try{let i=Math.max(0,Math.min(100,n)),a=Math.max(0,Math.min(100,r)),o=new ge(e),s=o.toHsb();return t&&s.b<i?(s.b=i,new ge(s).toHexString()):!t&&s.b>a?(s.b=a,new ge(s).toHexString()):o.toHexString()}catch{return t?`#ffffff`:`#000000`}},_h=Z.memo(({content:e,inline:t=!1,style:n,isStreaming:r=!1,compact:i=!1,showControls:a=!0,headingAnchors:o=!1})=>{let{token:s}=X.useToken(),c=Array.isArray(e)?e.filter(e=>e.trim()).join(`
22
-
23
- `):e,l=c;l=mh(l);let u={theme:hh(s)?`dark`:`default`},d=i?{maxHeight:`200px`,overflowY:`auto`,fontSize:`12px`,lineHeight:`1.5`}:{},f={...n,...d},p=(0,Z.useMemo)(()=>o?[...Object.values(mn),ph]:void 0,[o]),m=(0,Z.useMemo)(()=>o?{a:bh}:void 0,[o]);return(0,Q.jsx)(v,{style:f,className:i?`markdown-compact`:void 0,children:(0,Q.jsx)(hn,{parseIncompleteMarkdown:r,className:t?`inline-markdown`:`markdown-content`,isAnimating:r,controls:a,mermaidConfig:u,components:m,rehypePlugins:p,parseMarkdownIntoBlocksFn:o?yh:void 0,children:l},r?void 0:vh(c,{headingAnchors:o}))})});_h.displayName=`MarkdownRenderer`;function vh(e,t={}){let n=2166136261;for(let t=0;t<e.length;t+=1)n^=e.charCodeAt(t),n=Math.imul(n,16777619);return`${t.headingAnchors?`anchors`:`plain`}:${e.length}:${(n>>>0).toString(36)}`}var yh=e=>[e];function bh({children:e,className:t,href:n,node:r,...i}){return t?.split(/\s+/).includes(`markdown-heading-anchor`)&&n?.startsWith(`#`)?(0,Q.jsx)(`a`,{className:t,href:n,...i,children:e}):(0,Q.jsx)(`a`,{className:[`wrap-anywhere font-medium text-primary underline`,t].filter(Boolean).join(` `),"data-streamdown":`link`,href:n,rel:`noreferrer`,target:`_blank`,...i,children:e})}function xh(e){return e.split(`/`).map(e=>({title:e}))}var Sh=({open:e,onClose:t,title:n,content:r,filePath:i})=>{xh(i);let{showSuccess:o}=cf();return(0,Q.jsx)(a,{title:n,open:e,onCancel:t,width:900,styles:{body:{maxHeight:`70vh`,overflowY:`auto`,padding:`24px`}},footer:[(0,Q.jsx)(s,{icon:(0,Q.jsx)(E,{}),onClick:async()=>{await Xa(i),o(`Path copied to clipboard!`)},children:`Copy Path`},`copy-path`),(0,Q.jsx)(s,{type:`primary`,icon:(0,Q.jsx)(E,{}),onClick:async()=>{await Xa(r),o(`Content copied to clipboard!`)},children:`Copy Content`},`copy-content`),(0,Q.jsx)(s,{onClick:t,children:`Close`},`close`)],children:(0,Q.jsx)(_h,{content:r})})},Ch=5e4,wh=(0,Z.memo)(({branch:e,client:t})=>{let[n,r]=(0,Z.useState)([]),[i,a]=(0,Z.useState)(!0),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),m=(0,Z.useRef)(t);m.current=t;let h=(0,Z.useRef)(e.branch_id);h.current=e.branch_id;let{showLoading:g,showSuccess:_,showError:v}=cf();(0,Z.useEffect)(()=>{if(!t){a(!1);return}(async()=>{try{a(!0),s(null),r(await t.service(`file`).findAll({query:{branch_id:e.branch_id}}))}catch(e){console.error(`Failed to fetch files:`,e),s(e instanceof Error?e.message:String(e))}finally{a(!1)}})()},[t,e.branch_id]);let y=(0,Z.useCallback)(async e=>{let t=m.current;if(t)try{g(`Downloading file...`,{key:`download`});let n=await t.service(`file`).get(e.path,{query:{branch_id:h.current}}),r,i=`mimeType`in e?e.mimeType:void 0;if(n.encoding===`base64`){let e=atob(n.content),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);r=new Blob([t],{type:i||`application/octet-stream`})}else r=new Blob([n.content],{type:i||`text/plain`});let a=URL.createObjectURL(r),o=document.createElement(`a`);o.href=a,o.download=e.path.split(`/`).pop()||`download`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a),_(`Downloaded!`,{key:`download`})}catch(e){console.error(`Failed to download file:`,e),v(`Failed to download file`,{key:`download`})}},[g,_,v]),b=(0,Z.useCallback)(async e=>{let t=m.current;if(t)if(`isText`in e&&e.isText&&e.size<1024*1024)try{p(!0),d(!0),l(await t.service(`file`).get(e.path,{query:{branch_id:h.current}}))}catch(e){console.error(`Failed to fetch file detail:`,e),v(`Failed to load file`),d(!1)}finally{p(!1)}else y(e)},[y,v]),x=(0,Z.useCallback)(()=>{d(!1),l(null)},[]),S=c?.path.endsWith(`.md`),C=n.length>=Ch;return(0,Q.jsx)(`div`,{style:{width:`100%`,maxHeight:`70vh`,overflowY:`auto`},children:(0,Q.jsxs)(G,{orientation:`vertical`,size:`large`,style:{width:`100%`},children:[C&&(0,Q.jsx)(z,{type:`warning`,title:`Woah! Big repo alert!`,description:`Only ${Ch.toLocaleString()} files were loaded to prevent your browser from crashing. Use git/IDE for full repo browsing.`,showIcon:!0}),!C&&n.length>1e4&&(0,Q.jsx)(z,{type:`info`,title:`Large repository: ${n.length.toLocaleString()} files loaded.`,description:`Use search to find files quickly.`,showIcon:!0}),o&&(0,Q.jsx)(z,{title:`Error`,description:o,type:`error`,showIcon:!0}),(0,Q.jsx)(sh,{files:n,loading:i,onFileClick:b,onDownload:y,emptyMessage:`No files found in branch`}),S?(0,Q.jsx)(Sh,{open:u,title:c?.title||``,content:c?.content||``,filePath:c?.path||``,onClose:x}):(0,Q.jsx)(rh,{file:c,open:u,onClose:x,loading:f})]})})},(e,t)=>{let n=e.client===null!=(t.client===null);return e.branch.branch_id===t.branch.branch_id&&!n}),Th=e=>(0,Q.jsx)(k,{...e}),Eh=e=>typeof e==`string`&&e.trim().length>0?e:void 0,Dh=({archived:e,loading:t=!1,onToggle:n,tooltip:r,stopPropagation:i=!0,ariaLabel:a,"aria-label":o,size:c=`small`,type:l=`text`,...u})=>{let d=r??(e?`Archived • Click to unarchive`:`Archive`),f=Eh(d),p=o??a;return(0,Q.jsx)(H,{title:d,children:(0,Q.jsx)(s,{...u,type:l,size:c,icon:(0,Q.jsx)(Th,{}),loading:t,"aria-label":p??f,title:u.title??f,onClick:t=>{i&&t.stopPropagation(),n(!e)}})})},Oh=({tooltip:e,stopPropagation:t=!0,ariaLabel:n,"aria-label":r,size:i=`small`,type:a=`text`,onClick:o,onMouseEnter:c,onMouseLeave:l,children:u,...d})=>{let f=u==null,p=e??(f?`Archive`:void 0),m=Eh(p),h=r??n,g=(0,Q.jsx)(s,{...d,type:a,size:i,icon:(0,Q.jsx)(Th,{}),"aria-label":h??(f?m:void 0),title:d.title??(f?m:void 0),onMouseEnter:c,onMouseLeave:l,onClick:e=>{t&&e.stopPropagation(),o?.(e)},children:u});return p?(0,Q.jsx)(H,{title:p,children:g}):g},{Text:kh}=v,Ah=({open:e,branch:t,sessionCount:n=0,environmentRunning:r=!1,initialMetadataAction:i=`archive`,onConfirm:o,onCancel:s})=>{let[c,l]=(0,Z.useState)(`cleaned`),[u,d]=(0,Z.useState)(i);return(0,Z.useEffect)(()=>{e&&d(i)},[i,e]),(0,Q.jsx)(a,{title:`Archive or Delete Branch`,open:e,onOk:()=>{o({metadataAction:u,filesystemAction:c})},onCancel:s,okText:u===`archive`?`Archive Branch`:`Delete Permanently`,okButtonProps:u===`delete`?{danger:!0}:{},cancelText:`Cancel`,width:600,children:(0,Q.jsxs)(G,{orientation:`vertical`,size:`large`,style:{width:`100%`},children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(kh,{strong:!0,children:`Name: `}),(0,Q.jsx)(kh,{code:!0,children:t.name}),(0,Q.jsx)(`br`,{}),(0,Q.jsx)(kh,{strong:!0,children:`Git ref: `}),(0,Q.jsx)(kh,{children:t.ref})]}),r&&(0,Q.jsx)(z,{title:`Environment is running and will be stopped`,type:`warning`,showIcon:!0,style:{marginBottom:0}}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(kh,{strong:!0,style:{display:`block`,marginBottom:8},children:`Filesystem`}),(0,Q.jsx)(K.Group,{value:c,onChange:e=>l(e.target.value),children:(0,Q.jsxs)(G,{orientation:`vertical`,children:[(0,Q.jsx)(K,{value:`preserved`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{children:`Leave untouched`}),(0,Q.jsx)(kh,{type:`secondary`,style:{fontSize:12},children:`No changes to disk`})]})}),(0,Q.jsx)(K,{value:`cleaned`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{children:`Clean workspace (git clean -fdx)`}),(0,Q.jsx)(kh,{type:`secondary`,style:{fontSize:12},children:`Removes node_modules, builds, untracked files`})]})}),(0,Q.jsx)(K,{value:`deleted`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{children:`Delete completely`}),(0,Q.jsx)(kh,{type:`secondary`,style:{fontSize:12},children:`Removes entire branch directory from disk`})]})})]})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(kh,{strong:!0,style:{display:`block`,marginBottom:8},children:`Metadata & Sessions`}),(0,Q.jsx)(K.Group,{value:u,onChange:e=>d(e.target.value),children:(0,Q.jsxs)(G,{orientation:`vertical`,children:[(0,Q.jsx)(K,{value:`archive`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{children:`Archive (recommended)`}),(0,Q.jsx)(kh,{type:`secondary`,style:{fontSize:12},children:`Hidden from board, data preserved for analytics and history`})]})}),(0,Q.jsx)(K,{value:`delete`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{children:`Delete permanently`}),(0,Q.jsx)(kh,{type:`secondary`,style:{fontSize:12},children:`All data deleted - no undo`})]})})]})})]}),u===`delete`&&(0,Q.jsx)(z,{title:`Warning`,description:(0,Q.jsxs)(G,{orientation:`vertical`,size:`small`,style:{width:`100%`},children:[(0,Q.jsxs)(kh,{children:[`• All `,n,` session(s), messages, and history will be permanently deleted`]}),(0,Q.jsx)(kh,{children:`• Token usage data will be lost - prevents analytics and cost tracking`}),(0,Q.jsx)(kh,{children:`• Links to issues/PRs will be removed forever`}),(0,Q.jsx)(kh,{children:`• This action cannot be undone`}),(0,Q.jsx)(kh,{strong:!0,style:{marginTop:8,display:`block`},children:`💡 Consider archiving instead - keeps data for history but hides from board`})]}),type:`error`,showIcon:!0}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(kh,{type:`secondary`,style:{fontSize:12},children:[`Path:`,` `]}),(0,Q.jsx)(kh,{code:!0,copyable:!0,style:{fontSize:11},children:t.path})]})]})})},jh=({mcpServers:e,value:t,onChange:n,placeholder:r=`Select MCP servers...`,filterByScope:i,...a})=>(0,Q.jsx)(l,{mode:`multiple`,placeholder:r,allowClear:!0,showSearch:!0,optionFilterProp:`label`,value:t,onChange:n,options:(i?e.filter(e=>e.scope===i):e).filter(e=>e.enabled).map(e=>{let t=e.display_name||e.name,n=e.auth?.type===`oauth`?` · OAuth ${e.auth.oauth_mode===`shared`?`(shared)`:`(per-user)`}`:e.auth?.type===`bearer`||e.auth?.token?` · Token`:``;return{label:`${t} (${e.transport})${n}`,value:e.mcp_server_id,disabled:!e.enabled}}).sort((e,t)=>e.label.localeCompare(t.label)),...a}),Mh=({mcpServerById:e,showHelpText:t=!1})=>Ef(`mcp_servers`)?(0,Q.jsx)(Y.Item,{name:`mcpServerIds`,label:`MCP Servers`,help:t?`Select MCP servers to make available in this session`:void 0,children:(0,Q.jsx)(jh,{mcpServers:Ff(e),placeholder:`No MCP servers attached`})}):null,{TextArea:Nh}=J,Ph=({branch:e,repo:t,sessions:n,boards:r=[],mcpServers:i=[],canEdit:a,state:o,setField:s,onArchiveOrDelete:c})=>{let[u,d]=(0,Z.useState)(!1),f=t=>{c?.(e.branch_id,t)},p=Xt(e);return(0,Q.jsx)(`div`,{style:{width:`100%`,maxHeight:`70vh`,overflowY:`auto`},children:(0,Q.jsxs)(G,{orientation:`vertical`,size:`large`,style:{width:`100%`},children:[(0,Q.jsxs)(q,{column:1,bordered:!0,size:`small`,children:[(0,Q.jsxs)(q.Item,{label:`Name`,children:[(0,Q.jsx)(v.Text,{strong:!0,children:e.name}),e.new_branch&&(0,Q.jsx)(Aa,{color:`green`,style:{marginLeft:8,fontSize:11},children:`New Branch`})]}),(0,Q.jsx)(q.Item,{label:`Repository`,children:(0,Q.jsxs)(G,{children:[(0,Q.jsx)(se,{}),(0,Q.jsx)(v.Text,{children:t.name})]})}),(0,Q.jsx)(q.Item,{label:`Branch`,children:(0,Q.jsx)(v.Text,{code:!0,children:e.ref})}),e.base_ref&&(0,Q.jsx)(q.Item,{label:e.ref_type===`tag`?`Base Tag`:`Base Branch`,children:(0,Q.jsxs)(v.Text,{code:!0,children:[e.base_ref,e.base_sha&&` (${e.base_sha.substring(0,7)})`]})}),e.tracking_branch&&(0,Q.jsx)(q.Item,{label:`Tracking`,children:(0,Q.jsx)(v.Text,{code:!0,children:e.tracking_branch})}),e.last_commit_sha&&(0,Q.jsx)(q.Item,{label:`Current SHA`,children:(0,Q.jsx)(v.Text,{code:!0,children:e.last_commit_sha.substring(0,7)})}),(0,Q.jsx)(q.Item,{label:`Path`,children:(0,Q.jsx)(v.Text,{code:!0,style:{fontSize:11},copyable:{text:e.path,tooltips:[`Copy path`,`Copied!`]},children:e.path})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(v.Text,{strong:!0,style:{fontSize:14,display:`block`,marginBottom:16},children:`Work Context`}),(0,Q.jsxs)(Y,{layout:`horizontal`,colon:!1,children:[(0,Q.jsx)(Y.Item,{label:`Board`,labelCol:{span:6},wrapperCol:{span:18},children:(0,Q.jsx)(l,{value:o.boardId,onChange:e=>s(`boardId`,e),placeholder:`Select board (optional)...`,allowClear:!0,disabled:!a,options:r.sort((e,t)=>e.name.localeCompare(t.name)).map(e=>({value:e.board_id,label:`${e.icon||`📋`} ${e.name}`}))})}),(0,Q.jsx)(Y.Item,{label:`Issue`,labelCol:{span:6},wrapperCol:{span:18},children:(0,Q.jsx)(J,{value:o.issueUrl,onChange:e=>s(`issueUrl`,e.target.value),placeholder:`https://github.com/user/repo/issues/42`,prefix:(0,Q.jsx)(ae,{}),disabled:!a})}),(0,Q.jsx)(Y.Item,{label:`Pull Request`,labelCol:{span:6},wrapperCol:{span:18},children:(0,Q.jsx)(J,{value:o.prUrl,onChange:e=>s(`prUrl`,e.target.value),placeholder:`https://github.com/user/repo/pull/43`,prefix:(0,Q.jsx)(ae,{}),disabled:!a})}),!p&&(0,Q.jsx)(Y.Item,{label:(0,Q.jsxs)(G,{size:4,children:[(0,Q.jsx)(`span`,{children:`Notes`}),(0,Q.jsx)(H,{title:`Markdown formatting supported (headings, bold, italic, lists, code blocks, etc.)`,children:(0,Q.jsx)(`span`,{style:{fontSize:`10px`,fontWeight:`bold`,fontFamily:`monospace`,opacity:.6,cursor:`help`},children:`MD`})})]}),labelCol:{span:6},wrapperCol:{span:18},children:(0,Q.jsx)(Nh,{value:o.notes,onChange:e=>s(`notes`,e.target.value),placeholder:`Freeform notes about this branch...`,rows:4,disabled:!a})}),(0,Q.jsx)(Y.Item,{label:`MCP Servers`,labelCol:{span:6},wrapperCol:{span:18},extra:`Default MCP servers for new sessions in this branch`,children:(0,Q.jsx)(jh,{mcpServers:i,value:o.mcpServerIds,onChange:e=>s(`mcpServerIds`,e),placeholder:`Select default MCP servers...`,disabled:!a})})]})]}),(0,Q.jsxs)(q,{column:2,bordered:!0,size:`small`,children:[(0,Q.jsx)(q.Item,{label:`Created`,children:new Date(e.created_at).toLocaleString()}),(0,Q.jsx)(q.Item,{label:`Last Used`,children:e.last_used?new Date(e.last_used).toLocaleString():`Never`})]}),(0,Q.jsx)(G,{children:(0,Q.jsx)(Oh,{tooltip:``,size:`middle`,onClick:()=>d(!0),disabled:!a,children:`Archive or Delete Branch`})}),(0,Q.jsx)(Ah,{open:u,branch:e,sessionCount:n.length,environmentRunning:e.environment_instance?.status===`running`,onConfirm:e=>{f(e),d(!1)},onCancel:()=>d(!1)})]})})},Fh=[{label:`No access`,value:`none`},{label:`Read`,value:`read`},{label:`Write`,value:`write`}],Ih=new Set([`write`,`own`]);function Lh(){return{memory_path_template:`memory/{{YYYY-MM-DD}}.md`,default_visibility:`public`,global_access:`write`,grants:[]}}function Rh(e){return e.namespace_id||e.namespace_slug}function zh(e){let t=e.effective_permission??`unknown`;return`${e.display_name} (${e.slug}) · ${t}`}function Bh(e,t){return{custom_context:{[e.custom_context?.assistant?`assistant`:`agent`]:{kb:t}}}}var Vh=({branch:e,client:t,canEdit:n})=>{let{showSuccess:r,showError:i}=cf(),a=(0,Z.useMemo)(()=>Wt(e),[e]),o=a?.kb,[c,d]=(0,Z.useState)(o??Lh()),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)([]),[_,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{d(o??Lh())},[o]),(0,Z.useEffect)(()=>{let e=!1;return(async()=>{if(p(null),T(null),t){y(!0);try{let n=await t.service(`kb/namespaces`).find({query:{archived:!1,$limit:1e3}});if(e||h(Array.isArray(n)?n:n.data??[]),c.primary_namespace_id){let n=await t.service(`kb/namespaces`).get(c.primary_namespace_id);e||p(n)}}catch(t){e||T(t instanceof Error?t.message:String(t))}finally{e||y(!1)}}})(),()=>{e=!0}},[t,c.primary_namespace_id]);let E=(0,Z.useMemo)(()=>(c.grants??[]).map(e=>({...e,key:Rh(e)})),[c.grants]),D=(0,Z.useMemo)(()=>new Map(m.map(e=>[String(e.namespace_id),e])),[m]),O=async()=>{if(t){x(!0),T(null);try{let n=await t.service(`branches`).ensureAssistantKnowledgeNamespace({branchId:e.branch_id});p(n.namespace),d(Wt(n.branch)?.kb??c),r(`Assistant Knowledge namespace is ready`)}catch(e){let t=e instanceof Error?e.message:String(e);T(t),i(t)}finally{x(!1)}}},k=async n=>{if(t){C(!0);try{d(Wt(await t.service(`branches`).patch(e.branch_id,Bh(e,n)))?.kb??n),r(`Assistant Knowledge policy saved`)}catch(e){i(e instanceof Error?e.message:String(e))}finally{C(!1)}}},A=e=>{let t=D.get(e);t&&(d(e=>({...e,primary_namespace_id:t.namespace_id,primary_namespace_slug:t.slug,default_visibility:t.visibility_default,memory_path_template:e.memory_path_template??`memory/{{YYYY-MM-DD}}.md`})),p(t))},j=(e,t)=>{d(n=>({...n,grants:(n.grants??[]).map(n=>Rh(n)===e?{...n,...t}:n)}))},M=e=>{let t=D.get(e);t&&d(e=>{let n=e.grants??[];return n.some(e=>e.namespace_id===t.namespace_id)?e:{...e,grants:[...n,{namespace_id:t.namespace_id,namespace_slug:t.slug,access:`read`}]}})},N=e=>{d(t=>({...t,grants:(t.grants??[]).filter(t=>Rh(t)!==e)}))};if(!a)return(0,Q.jsx)(fe,{description:`Knowledge memory is only available for assistant branches.`});let P=!f&&(!c.primary_namespace_id||w),F=new Set((c.grants??[]).map(e=>e.namespace_id));return c.primary_namespace_id&&F.add(c.primary_namespace_id),(0,Q.jsx)(`div`,{style:{padding:16},children:(0,Q.jsxs)(G,{direction:`vertical`,size:`middle`,style:{width:`100%`},children:[(0,Q.jsx)(z,{type:`info`,showIcon:!0,message:`Assistant Knowledge`,description:`Assistant tools always use the home namespace for memory. Beyond that, this policy controls which Knowledge namespaces assistant-specific MCP tools may search. Effective access is still limited by the current user's namespace permissions.`}),(0,Q.jsx)(g,{title:`Home namespace`,extra:(0,Q.jsxs)(G,{children:[f?.slug&&(0,Q.jsx)(s,{href:`/kb/${encodeURIComponent(f.slug)}/`,target:`_blank`,children:`Open in Knowledge`}),n&&(0,Q.jsx)(s,{onClick:O,loading:b,disabled:!t,children:c.primary_namespace_id?`Repair namespace`:`Create namespace`})]}),children:(0,Q.jsxs)(G,{direction:`vertical`,size:`middle`,style:{width:`100%`},children:[(0,Q.jsx)(v.Paragraph,{type:`secondary`,style:{marginBottom:0},children:`The home namespace is where this assistant stores its memory and where assistant-specific Knowledge tools start by default. Choose a namespace you can write to.`}),n&&(0,Q.jsxs)(G.Compact,{style:{width:`100%`},children:[(0,Q.jsx)(l,{showSearch:!0,"aria-label":`Home Knowledge namespace`,placeholder:`Select home Knowledge namespace`,value:c.primary_namespace_id,loading:_,disabled:!t||b,optionFilterProp:`label`,onChange:A,style:{minWidth:360,flex:1},options:m.map(e=>{let t=Ih.has(e.effective_permission??`none`);return{label:zh(e),value:e.namespace_id,disabled:!t&&e.namespace_id!==c.primary_namespace_id}})}),(0,Q.jsx)(s,{type:`primary`,onClick:()=>k(c),loading:S,disabled:!t||!c.primary_namespace_id,children:`Save home`})]}),_?(0,Q.jsx)(Ze,{}):P?(0,Q.jsx)(z,{type:`warning`,showIcon:!0,message:`Home namespace is missing or unavailable`,description:w||`namespace for this agent is not set up`}):(0,Q.jsxs)(q,{column:1,size:`small`,children:[(0,Q.jsx)(q.Item,{label:`Name`,children:f?.display_name}),(0,Q.jsx)(q.Item,{label:`Slug`,children:(0,Q.jsx)(v.Text,{code:!0,children:f?.slug??c.primary_namespace_slug})}),(0,Q.jsx)(q.Item,{label:`Your permission`,children:(0,Q.jsx)(u,{children:f?.effective_permission??`unknown`})}),(0,Q.jsx)(q.Item,{label:`Default document visibility`,children:(0,Q.jsx)(u,{children:f?.visibility_default??c.default_visibility})}),(0,Q.jsx)(q.Item,{label:`Others can`,children:(0,Q.jsx)(u,{children:f?.others_can??`unknown`})}),(0,Q.jsx)(q.Item,{label:`Memory path`,children:(0,Q.jsx)(v.Text,{code:!0,children:c.memory_path_template??`memory/{{YYYY-MM-DD}}.md`})})]})]})}),(0,Q.jsx)(g,{title:`Assistant Knowledge access`,extra:n?(0,Q.jsx)(s,{type:`primary`,onClick:()=>k(c),loading:S,disabled:!t||!c.primary_namespace_id,children:`Save policy`}):null,children:(0,Q.jsxs)(G,{direction:`vertical`,size:`middle`,style:{width:`100%`},children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(v.Text,{strong:!0,children:`Entire Knowledge Base fallback`}),(0,Q.jsx)(v.Paragraph,{type:`secondary`,style:{marginBottom:8},children:`Applies to any namespace that is not listed below. Choose none for a locked-down assistant, read for broad context, or write for assistant tools that may update any namespace the current user can write.`}),(0,Q.jsx)(l,{value:c.global_access??`write`,options:Fh,disabled:!n,style:{width:220},onChange:e=>d(t=>({...t,global_access:e}))})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(v.Text,{strong:!0,children:`Per-namespace overrides`}),(0,Q.jsx)(v.Paragraph,{type:`secondary`,style:{marginBottom:8},children:`Add namespaces to narrow or expand the fallback policy for specific spaces. The home namespace is always available to assistant memory tools.`}),n&&(0,Q.jsx)(l,{showSearch:!0,placeholder:`Add namespace override`,style:{minWidth:320,marginBottom:12},disabled:!t,value:void 0,optionFilterProp:`label`,onChange:M,options:m.filter(e=>!F.has(e.namespace_id)).map(e=>({label:`${e.display_name} (${e.slug})`,value:e.namespace_id}))}),(0,Q.jsx)(ue,{size:`small`,pagination:!1,rowKey:`key`,dataSource:E,locale:{emptyText:`No per-namespace overrides`},columns:[{title:`Namespace`,dataIndex:`namespace_slug`,render:(e,t)=>{let n=D.get(t.namespace_id);return(0,Q.jsxs)(G,{direction:`vertical`,size:0,children:[(0,Q.jsx)(v.Text,{children:n?.display_name??t.namespace_slug}),(0,Q.jsx)(v.Text,{type:`secondary`,code:!0,children:t.namespace_slug})]})}},{title:`Access`,dataIndex:`access`,width:150,render:(e,t)=>(0,Q.jsx)(l,{value:t.access,options:Fh,disabled:!n,style:{width:130},onChange:e=>j(t.key,{access:e})})},{title:`Effective now`,width:150,render:(e,t)=>(0,Q.jsx)(u,{children:D.get(t.namespace_id)?.effective_permission??`unknown`})},{title:``,width:90,render:(e,t)=>n?(0,Q.jsx)(s,{type:`link`,danger:!0,onClick:()=>N(t.key),children:`Remove`}):null}]})]})]})})]})})},Hh=e=>String(e??``).trim().toLowerCase(),Uh=e=>e.filter(Boolean).join(` `).toLowerCase(),Wh=e=>{let t=e.name?.trim();return t&&t!==e.email?`${t} (${e.email})`:e.email},Gh=e=>{let t=e.slug?.trim();return t&&t!==e.name?`${e.name} (${t})`:e.name},Kh=e=>Hh(e),qh=e=>{let t=Wh(e);return{value:e.user_id,label:t,searchText:Kh(t)}},Jh=e=>{let t=Gh(e);return{value:e.group_id,label:t,searchText:Kh(t)}},Yh={showSearch:!0,optionFilterProp:`searchText`,optionLabelProp:`label`,filterOption:(e,t)=>{let n=Hh(e);if(!n)return!0;let r=typeof t?.label==`string`?t.label:``;return Uh([t?.searchText,r]).includes(n)}},Xh={none:`No access`,view:`View only`,session:`Create and prompt own sessions`,prompt:`Prompt any session`,all:`Full control`},Zh={none:`No filesystem access`,read:`Read-only`,write:`Read/write`},Qh=e=>e===`none`?`private`:`shared`,$h=(e,t)=>e===`private`?`none`:t===`none`?`session`:t||`session`,eg=({value:e,onChange:t,allUsers:n,allGroups:r,currentUser:i,canEdit:a,canEditOwners:o=a,canEditGroups:s=a,loadingOwners:c=!1,groupGrantsLoading:u=!1,groupGrantsUnavailable:d=!1,groupGrantsError:f,ownersLoadError:p,ownerHelp:m=`Full access`,groupsHelp:h=`Group access`,visibilityLabel:g=`Visibility`,othersCanLabel:_=`Others Can`,othersFsAccessLabel:y=`Filesystem Access`,showLegacySessionSharing:b=!0})=>{let{showError:x}=cf(),[S,C]=(0,Z.useState)(0),w=i?.user_id,T=e.visibility===`shared`,E=e.ownerIds.length===1?`Private (${(e=>{let t=n.find(t=>t.user_id===e),r=t?.name||t?.email||e;return e===w?`${r} (You)`:r})(e.ownerIds[0])})`:`Private`,D=e=>{if(e.length===0){x(`At least one owner is required`),C(e=>e+1);return}t(`ownerIds`,e)},O=n=>{if(t(`visibility`,n),t(`othersCan`,$h(n,e.othersCan)),n===`private`){let n=e.ownerIds.length===1?e.ownerIds[0]:w&&e.ownerIds.includes(w)?w:e.ownerIds[0]||w;n&&t(`ownerIds`,[n]),t(`groupGrants`,[]),t(`othersFsAccess`,`none`),t(`allowSessionSharing`,!1)}};return(0,Q.jsxs)(Q.Fragment,{children:[p&&(0,Q.jsx)(z,{type:`error`,showIcon:!0,message:`Permissions unavailable`,description:`${p.message}. Close and reopen the modal to retry.`,style:{marginBottom:16}}),(0,Q.jsx)(Y.Item,{label:g,labelCol:{span:8},wrapperCol:{span:16},help:T?`Group and fallback access.`:`Owner-only access.`,children:(0,Q.jsx)(K.Group,{value:e.visibility,disabled:!a,onChange:e=>O(e.target.value),options:[{value:`private`,label:E},{value:`shared`,label:`Shared`}]})}),T&&(0,Q.jsx)(Y.Item,{label:`Owners`,labelCol:{span:8},wrapperCol:{span:16},help:m,children:(0,Q.jsx)(l,{mode:`multiple`,style:{width:`100%`},placeholder:`Select owners...`,value:e.ownerIds,onChange:D,loading:c,disabled:!o,...Yh,options:n.map(e=>{let t=e.user_id===w,n=qh(e),r=t?`${n.label} (You)`:n.label;return{...n,label:r,searchText:Kh(r)}}).sort((e,t)=>e.label.localeCompare(t.label)),tagRender:e=>{let t=n.find(t=>t.user_id===e.value)?.user_id===w;return(0,Q.jsx)(Aa,{...e,color:t?`green`:`default`,closable:e.closable,onClose:e.onClose,style:{marginRight:3},children:(0,Q.jsxs)(G,{size:4,children:[(0,Q.jsx)(ke,{style:{fontSize:11}}),(0,Q.jsx)(`span`,{children:e.label})]})})}},S)}),T&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y.Item,{label:`Groups`,labelCol:{span:8},wrapperCol:{span:16},help:h,children:(0,Q.jsxs)(G,{direction:`vertical`,style:{width:`100%`},children:[d&&(0,Q.jsx)(z,{type:`warning`,showIcon:!0,message:`Group permissions unavailable`,description:f?.message?`Group permissions could not be loaded: ${f.message}`:`Group grants may not be enabled.`}),(0,Q.jsx)(l,{mode:`multiple`,style:{width:`100%`},placeholder:`Select groups...`,value:e.groupGrants.map(e=>e.group_id),loading:u,disabled:!s,options:r.map(Jh).sort((e,t)=>e.label.localeCompare(t.label)),...Yh,onChange:n=>{let r=new Map(e.groupGrants.map(e=>[e.group_id,e]));t(`groupGrants`,n.map(e=>r.get(e)||{group_id:e,can:`view`}))}}),e.groupGrants.map(n=>{let i=r.find(e=>e.group_id===n.group_id);return(0,Q.jsxs)(G,{style:{width:`100%`,justifyContent:`space-between`},children:[(0,Q.jsx)(v.Text,{children:i?.name||n.group_id}),(0,Q.jsxs)(G,{children:[(0,Q.jsx)(l,{size:`small`,style:{width:140},value:n.can,disabled:!s,options:[{value:`view`,label:`View`},{value:`session`,label:`Own Sessions`},{value:`prompt`,label:`Prompt`},{value:`all`,label:`All`}],onChange:r=>t(`groupGrants`,e.groupGrants.map(e=>e.group_id===n.group_id?{...e,can:r}:e))}),(0,Q.jsx)(l,{size:`small`,style:{width:110},value:n.fs_access||`read`,disabled:!s,options:[{value:`none`,label:`No FS`},{value:`read`,label:`Read FS`},{value:`write`,label:`Write FS`}],onChange:r=>t(`groupGrants`,e.groupGrants.map(e=>e.group_id===n.group_id?{...e,fs_access:r}:e))})]})]},n.group_id)})]})}),(0,Q.jsx)(Y.Item,{label:_,labelCol:{span:8},wrapperCol:{span:16},help:Xh[e.othersCan],children:(0,Q.jsx)(l,{value:e.othersCan,onChange:e=>t(`othersCan`,e),disabled:!a,options:[{value:`view`,label:`View`},{value:`session`,label:`Own Sessions`},{value:`prompt`,label:`Prompt`},{value:`all`,label:`All`}]})}),e.othersCan===`prompt`&&(0,Q.jsx)(Y.Item,{wrapperCol:{offset:8,span:16},children:(0,Q.jsx)(z,{type:`warning`,showIcon:!0,icon:(0,Q.jsx)(Ve,{}),message:`Unix identity risk`,description:`Allows prompting sessions created by others; use only with trusted collaborators.`})}),(0,Q.jsx)(Y.Item,{label:y,labelCol:{span:8},wrapperCol:{span:16},help:Zh[e.othersFsAccess],children:(0,Q.jsx)(l,{value:e.othersFsAccess,onChange:e=>t(`othersFsAccess`,e),disabled:!a,options:[{value:`none`,label:`None`},{value:`read`,label:`Read`},{value:`write`,label:`Write`}]})}),b&&(0,Q.jsx)(Y.Item,{label:`Allow legacy session sharing`,labelCol:{span:8},wrapperCol:{span:16},help:`When on, spawned/forked sessions keep the original creator's identity.`,children:(0,Q.jsx)(j,{checked:e.allowSessionSharing,onChange:e=>t(`allowSessionSharing`,e),disabled:!a})}),b&&e.allowSessionSharing&&(0,Q.jsx)(Y.Item,{wrapperCol:{offset:8,span:16},children:(0,Q.jsx)(z,{type:`error`,showIcon:!0,icon:(0,Q.jsx)(Ve,{}),message:`Dangerous: identity borrowing`,description:`Use only for trusted collaborators or legacy automation.`})})]})]})},tg=({loadingOwners:e,canEdit:t,allUsers:n,allGroups:r=[],groupGrantsStatus:i=`loaded`,groupGrantsError:a,currentUser:o,client:s,board:c,state:l,setField:u,ownersLoadError:d})=>{let[f,p]=(0,Z.useState)([]),[m,h]=(0,Z.useState)([]),[g,_]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),x=l.permissionSource??`override`,S=t&&x===`override`,C={visibility:Qh(l.othersCan),ownerIds:l.selectedOwnerIds,groupGrants:l.groupGrants??[],othersCan:l.othersCan,othersFsAccess:l.othersFsAccess,allowSessionSharing:l.allowSessionSharing},w=(e,t)=>{e===`ownerIds`&&u(`selectedOwnerIds`,t),e===`groupGrants`&&u(`groupGrants`,t),e===`othersCan`&&u(`othersCan`,t),e===`othersFsAccess`&&u(`othersFsAccess`,t),e===`allowSessionSharing`&&u(`allowSessionSharing`,t)};(0,Z.useEffect)(()=>{if(!s||!c?.board_id||x!==`board`){p([]),h([]),b(null);return}let e=!1;return _(!0),b(null),Promise.all([s.service(`boards/:id/owners`).find({route:{id:c.board_id}}),s.service(`boards/:id/group-grants`).find({route:{id:c.board_id}})]).then(([t,n])=>{e||(p(t),h(n))}).catch(t=>{e||(p([]),h([]),b(t instanceof Error?t:Error(String(t))))}).finally(()=>{e||_(!1)}),()=>{e=!0}},[s,c?.board_id,x]);let T=f.map(e=>e.name||e.email||e.user_id),E=m.map(e=>{let t=r.find(t=>t.group_id===e.group_id),n=e.group?.name||t?.name||e.group_id,i=e.fs_access?`, FS: ${e.fs_access}`:``;return`${n}: ${e.can}${i}`});return(0,Q.jsx)(`div`,{style:{width:`100%`,maxHeight:`70vh`,overflowY:`auto`},children:(0,Q.jsxs)(Y,{layout:`horizontal`,colon:!1,children:[(0,Q.jsx)(Y.Item,{label:`Permission Mode`,labelCol:{span:8},wrapperCol:{span:16},help:x===`board`?`Uses board-level defaults for non-owner access.`:`Uses branch-level permission overrides.`,children:(0,Q.jsx)(K.Group,{value:x,disabled:!t,onChange:e=>u(`permissionSource`,e.target.value),options:[{value:`board`,label:`Align with board permissions`},{value:`override`,label:`Override board-level permissions`}]})}),x===`board`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y.Item,{wrapperCol:{offset:8,span:16},children:(0,Q.jsx)(z,{type:`info`,showIcon:!0,message:`Aligned with board permissions`,description:`This branch inherits board-level visibility, board owners, board groups, and board fallback permissions. Switch to Override to edit branch-level private/shared permissions directly.`})}),(0,Q.jsx)(Y.Item,{label:`Board defaults`,labelCol:{span:8},wrapperCol:{span:16},children:c?(0,Q.jsxs)(q,{size:`small`,column:1,bordered:!0,style:{width:`100%`},children:[(0,Q.jsx)(q.Item,{label:`Visibility`,children:c.access_mode===`private`?`Private`:`Shared`}),(0,Q.jsx)(q.Item,{label:`Owners`,children:g?`Loading…`:T.length>0?T.join(`, `):`None`}),y&&(0,Q.jsx)(q.Item,{label:`Owner/group details`,children:(0,Q.jsxs)(v.Text,{type:`danger`,children:[`Could not load: `,y.message]})}),c.access_mode!==`private`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q.Item,{label:`Groups`,children:g?`Loading…`:E.length>0?E.join(`, `):`None`}),(0,Q.jsx)(q.Item,{label:`Others can`,children:c.default_others_can||`session`}),(0,Q.jsx)(q.Item,{label:`Filesystem access`,children:c.default_others_fs_access||`read`}),(0,Q.jsx)(q.Item,{label:`Legacy session sharing`,children:c.default_dangerously_allow_session_sharing?`Allowed`:`Off`})]})]}):(0,Q.jsx)(v.Text,{type:`secondary`,children:`Board defaults are unavailable for this branch.`})})]}),x===`override`&&(0,Q.jsx)(eg,{value:C,onChange:w,allUsers:n,allGroups:r,currentUser:o,canEdit:S,canEditGroups:S&&i===`loaded`,loadingOwners:e,groupGrantsLoading:i===`loading`,groupGrantsUnavailable:i===`unavailable`,groupGrantsError:a,ownersLoadError:d,groupsHelp:`Grant explicit branch access to user groups`})]})})},ng=function(){return ng=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},ng.apply(this,arguments)};function rg(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function ig(e,t,n){if(n||arguments.length===2)for(var r,i=0,a=t.length;i<a;i++)!r&&i in t||(r||=Array.prototype.slice.call(t,0,i),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}var ag=[{name:`@yearly`,value:`0 0 1 1 *`},{name:`@annually`,value:`0 0 1 1 *`},{name:`@monthly`,value:`0 0 1 * *`},{name:`@weekly`,value:`0 0 * * 0`},{name:`@daily`,value:`0 0 * * *`},{name:`@midnight`,value:`0 0 * * *`},{name:`@hourly`,value:`0 * * * *`}],og=[{type:`minutes`,min:0,max:59,total:60},{type:`hours`,min:0,max:23,total:24},{type:`month-days`,min:1,max:31,total:31},{type:`months`,min:1,max:12,total:12,alt:[`JAN`,`FEB`,`MAR`,`APR`,`MAY`,`JUN`,`JUL`,`AUG`,`SEP`,`OCT`,`NOV`,`DEC`]},{type:`week-days`,min:0,max:6,total:7,alt:[`SUN`,`MON`,`TUE`,`WED`,`THU`,`FRI`,`SAT`]}],sg={everyText:`every`,emptyMonths:`every month`,emptyMonthDays:`every day of the month`,emptyMonthDaysShort:`day of the month`,emptyWeekDays:`every day of the week`,emptyWeekDaysShort:`day of the week`,emptyHours:`every hour`,emptyMinutes:`every minute`,emptyMinutesForHourPeriod:`every`,yearOption:`year`,monthOption:`month`,weekOption:`week`,dayOption:`day`,hourOption:`hour`,minuteOption:`minute`,rebootOption:`reboot`,prefixPeriod:`Every`,prefixMonths:`in`,prefixMonthDays:`on`,prefixWeekDays:`on`,prefixWeekDaysForMonthAndYearPeriod:`and`,prefixHours:`at`,prefixMinutes:`:`,prefixMinutesForHourPeriod:`at`,suffixMinutesForHourPeriod:`minute(s)`,errorInvalidCron:`Invalid cron expression`,clearButtonText:`Clear`,weekDays:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],months:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],altWeekDays:[`SUN`,`MON`,`TUE`,`WED`,`THU`,`FRI`,`SAT`],altMonths:[`JAN`,`FEB`,`MAR`,`APR`,`MAY`,`JUN`,`JUL`,`AUG`,`SEP`,`OCT`,`NOV`,`DEC`]};function cg(e,t){for(var n=[],r=e;r<=t;r++)n.push(r);return n}function lg(e){return e.sort((function(e,t){return e-t})),e}function ug(e){var t=[];return e.forEach((function(e){t.indexOf(e)<0&&t.push(e)})),t}function dg(e){return Object.entries(e).filter((function(e){var t=e[0],n=e[1];return t&&n})).map((function(e){return e[0]})).join(` `)}function fg(e,t){e&&e({type:`invalid_cron`,description:t.errorInvalidCron||sg.errorInvalidCron})}function pg(e){var t=parseInt(e,10),n=Number(e);return t===n?n:NaN}function mg(e,t,n,r,i,a,o,s,c,l,u,d,f,p){n&&n(void 0),t(!1);var m=!1;if(!e){if(r===`always`||a&&r===`for-default-value`)return;m=!0}if(!m){if(s&&(!0===s||s.includes(e))){if(e===`@reboot`)return void p(`reboot`);var h=ag.find((function(t){return t.name===e}));h&&(e=h.value)}try{var g=yg(e);p(function(e){return e[3].length>0?`year`:e[2].length>0?`month`:e[4].length>0?`week`:e[1].length>0?`day`:e[0].length>0?`hour`:`minute`}(g)),c(g[0]),l(g[1]),u(g[2]),d(g[3]),f(g[4])}catch{m=!0}}m&&(i.current=e,t(!0),fg(n,o))}function hg(e,t,n,r,i,a,o,s){return e===`reboot`?`@reboot`:function(e,t,n){return e.map((function(e,r){var i=og[r],a=vg(e,i),o=n?.[i.type];return gg(a,i,o?.humanizeValue??t)}))}([e!==`minute`&&a?a:[],e!==`minute`&&e!==`hour`&&i?i:[],e!==`year`&&e!==`month`||!n?[]:n,e===`year`&&t?t:[],e!==`year`&&e!==`month`&&e!==`week`||!r?[]:r],o,s).join(` `)}function gg(e,t,n,r,i){var a=``;if(function(e,t){return e.length===t.max-t.min+1}(e,t)||e.length===0)a=`*`;else{var o=function(e){if(e.length>2){var t=e[1]-e[0];if(t>1)return t}}(e);a=o&&function(e,t){for(var n=1;n<e.length;n++){var r=e[n-1];if(e[n]-r!==t)return!1}return!0}(e,o)?function(e,t,n){var r=Sg(e),i=Cg(e),a=e.length===(i-r)/n+1;return!!(r===t.min&&i+n>t.max&&a)}(e,t,o)?`*/${o}`:`${_g(Sg(e),t,n,r,i)}-${_g(Cg(e),t,n,r,i)}/${o}`:function(e){var t=[],n=null;return e.forEach((function(e,r,i){e===i[r+1]-1?n===null&&(n=e):n===null?t.push(e):(t.push([n,e]),n=null)})),t}(e).map((function(e){return Array.isArray(e)?`${_g(e[0],t,n,r,i)}-${_g(e[1],t,n,r,i)}`:_g(e,t,n,r,i)})).join(`,`)}return a}function _g(e,t,n,r,i){var a=e.toString(),o=t.type,s=t.alt,c=t.min,l=r&&(!0===r||r.includes(o));if(n&&o===`week-days`||n&&o===`months`?a=s[e-c]:e<10&&(l||i===`24-hour-clock`&&(o===`hours`||o===`minutes`))&&(a=a.padStart(2,`0`)),o===`hours`&&i===`12-hour-clock`){var u=e>=12?`PM`:`AM`,d=e%12||12;d<10&&l&&(d=d.toString().padStart(2,`0`)),a=`${d}${u}`}return a}function vg(e,t){var n=lg(ug(bg(e,t)));if(n.length===0)return n;var r=xg(n,t);if(r!==void 0)throw Error(`Value "${r}" out of range for ${t.type}`);return n}function yg(e){if(typeof e!=`string`)throw Error(`Invalid cron string`);var t=e.replace(/\s+/g,` `).trim().split(` `);if(t.length===5)return t.map((function(e,t){return function(e,t){if(e===`*`||e===`*/1`)return[];var n=lg(ug(bg(function(e,t,n){if(n){e=e.toUpperCase();for(var r=0;r<n.length;r++)e=e.replace(n[r],`${r+t}`)}return e}(e,t.min,t.alt).split(`,`).map((function(n){var r,i=n.split(`/`);if(i.length>2)throw Error(`Invalid value "${e} for "${t.type}"`);var a=i[0],o=i[1];r=a===`*`?cg(t.min,t.max):function(e,t,n){var r=e.split(`-`);if(r.length===1){var i=pg(r[0]);if(isNaN(i))throw Error(`Invalid value "${t}" for ${n.type}`);return[i]}if(r.length===2){var a=pg(r[0]),o=pg(r[1]);if(isNaN(a)||isNaN(o))throw Error(`Invalid value "${t}" for ${n.type}`);if(o<a)throw Error(`Max range is less than min range in "${e}" for ${n.type}`);return cg(a,o)}throw Error(`Invalid value "${e}" for ${n.type}`)}(a,e,t);var s=function(e,t){if(e!==void 0){var n=pg(e);if(isNaN(n)||n<1)throw Error(`Invalid interval step value "${e}" for ${t.type}`);return n}}(o,t);return function(e,t){if(t){var n=e[0];e=e.filter((function(e){return e%t==n%t||e===n}))}return e}(r,s)})).flat(),t))),r=xg(n,t);if(r!==void 0)throw Error(`Value "${r}" out of range for ${t.type}`);return n.length===t.total?[]:n}(e,og[t])}));throw Error(`Invalid cron string format`)}function bg(e,t){return t.type===`week-days`&&(e=e.map((function(e){return e===7?0:e}))),e}function xg(e,t){var n=e[0],r=e[e.length-1];return n<t.min?n:r>t.max?r:void 0}function Sg(e){return e[0]}function Cg(e){return e[e.length-1]}Object.freeze({__proto__:null,setValuesFromCronString:mg,getCronStringFromValues:hg,partToString:gg,formatValue:_g,parsePartArray:vg,parseCronString:yg});function wg(e){var t=e.value,n=e.grid,r=n===void 0||n,i=e.optionsList,a=e.setValue,o=e.locale,s=e.className,c=e.humanizeLabels,u=e.disabled,d=e.readOnly,f=e.leadingZero,p=e.clockFormat,m=e.period,h=e.unit,g=e.periodicityOnDoubleClick,_=e.mode,v=e.allowClear,y=e.filterOption,b=y===void 0?function(){return!0}:y,x=e.getPopupContainer,S=rg(e,[`value`,`grid`,`optionsList`,`setValue`,`locale`,`className`,`humanizeLabels`,`disabled`,`readOnly`,`leadingZero`,`clockFormat`,`period`,`unit`,`periodicityOnDoubleClick`,`mode`,`allowClear`,`filterOption`,`getPopupContainer`]),C=(0,Z.useMemo)((function(){if(t&&Array.isArray(t))return t.map((function(e){return e.toString()}))}),[t]),w=(0,Z.useMemo)((function(){return i?i.map((function(e,t){return{value:(h.min===0?t:t+1).toString(),label:e}})).filter(b):ig([],Array(h.total),!0).map((function(e,t){var n=h.min===0?t:t+1;return{value:n.toString(),label:_g(n,h,c,f,p)}})).filter(b)}),[i,f,c,p]),T=(0,Z.useCallback)((function(e){var n=e.value;if(!t||t[0]!==Number(n))return(0,Q.jsx)(Q.Fragment,{});var r=gg(vg(t,h),h,c,f,p),i=r.match(/^\*\/([0-9]+),?/)||[];return(0,Q.jsx)(`div`,{children:i[1]?`${o.everyText||sg.everyText} ${i[1]}`:r})}),[t,JSON.stringify(o),c,f,p]),E=(0,Z.useCallback)((function(e){var n=Array.isArray(e)?lg(e):[e],r=n;t&&(r=_===`single`?[]:ig([],t,!0),n.forEach((function(e){var n=Number(e);r=t.some((function(e){return e===n}))?r.filter((function(e){return e!==n})):lg(ig(ig([],r,!0),[n],!1))}))),r.length===h.total?a([]):a(r)}),[a,t]),D=(0,Z.useCallback)((function(e){if(e!==0&&e!==1){for(var n=h.total+h.min,r=[],i=h.min;i<n;i++)i%e==0&&r.push(i);var o=t&&r&&t.length===r.length&&t.every((function(e,t){return e===r[t]}));a(r.length===w.length||o?[]:r)}else a([])}),[t,w,a]),O=(0,Z.useRef)([]),k=(0,Z.useCallback)((function(e){if(!d){var t=O.current;t.push({time:new Date().getTime(),value:Number(e)});var n=window.setTimeout((function(){g&&t.length>1&&t[t.length-1].time-t[t.length-2].time<300?t[t.length-1].value===t[t.length-2].value?D(Number(e)):E([t[t.length-2].value,t[t.length-1].value]):E(Number(e)),O.current=[]}),300);return function(){window.clearTimeout(n)}}}),[O,E,D,d,g]),A=(0,Z.useCallback)((function(){d||a([])}),[a,d]),j=(0,Z.useMemo)((function(){var e;return dg(((e={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})[`${s}-select`]=!!s,e))}),[s]),M=(0,Z.useMemo)((function(){var e;return dg(((e={"react-js-cron-select-dropdown":!0})[`react-js-cron-select-dropdown-${h.type}`]=!0,e[`react-js-cron-custom-select-dropdown`]=!0,e[`react-js-cron-custom-select-dropdown-${h.type}`]=!0,e[`react-js-cron-custom-select-dropdown-minutes-large`]=h.type===`minutes`&&m!==`hour`&&m!==`day`,e[`react-js-cron-custom-select-dropdown-minutes-medium`]=h.type===`minutes`&&(m===`day`||m===`hour`),e[`react-js-cron-custom-select-dropdown-hours-twelve-hour-clock`]=h.type===`hours`&&p===`12-hour-clock`,e[`react-js-cron-custom-select-dropdown-grid`]=!!r,e[`${s}-select-dropdown`]=!!s,e[`${s}-select-dropdown-${h.type}`]=!!s,e))}),[s,r,p,m]);return(0,Q.jsx)(l,ng({mode:_!==`single`||g?`multiple`:void 0,allowClear:v??!d,virtual:!1,open:!d&&void 0,value:C,onClear:A,tagRender:T,className:j,popupClassName:M,options:w,showSearch:!1,suffixIcon:d?null:void 0,menuItemSelectedIcon:null,popupMatchSelectWidth:!1,onSelect:k,onDeselect:k,disabled:u,dropdownAlign:h.type!==`minutes`&&h.type!==`hours`||m===`day`||m===`hour`?void 0:{points:[`tr`,`br`]},"data-testid":`custom-select-${h.type}`,getPopupContainer:x},S))}function Tg(e){var t=e.value,n=e.setValue,r=e.locale,i=e.className,a=e.disabled,o=e.readOnly,s=e.leadingZero,c=e.clockFormat,l=e.period,u=e.periodicityOnDoubleClick,d=e.mode,f=e.allowClear,p=e.filterOption,m=e.getPopupContainer,h=(0,Z.useMemo)((function(){var e;return dg(((e={"react-js-cron-field":!0,"react-js-cron-hours":!0})[`${i}-field`]=!!i,e[`${i}-hours`]=!!i,e))}),[i]);return(0,Q.jsxs)(`div`,ng({className:h},{children:[r.prefixHours!==``&&(0,Q.jsx)(`span`,{children:r.prefixHours||sg.prefixHours}),(0,Q.jsx)(wg,{placeholder:r.emptyHours||sg.emptyHours,value:t,unit:og[1],setValue:n,locale:r,className:i,disabled:a,readOnly:o,leadingZero:s,clockFormat:c,period:l,periodicityOnDoubleClick:u,mode:d,allowClear:f,filterOption:p,getPopupContainer:m})]}))}function Eg(e){var t=e.value,n=e.setValue,r=e.locale,i=e.className,a=e.disabled,o=e.readOnly,s=e.leadingZero,c=e.clockFormat,l=e.period,u=e.periodicityOnDoubleClick,d=e.mode,f=e.allowClear,p=e.filterOption,m=e.getPopupContainer,h=(0,Z.useMemo)((function(){var e;return dg(((e={"react-js-cron-field":!0,"react-js-cron-minutes":!0})[`${i}-field`]=!!i,e[`${i}-minutes`]=!!i,e))}),[i]);return(0,Q.jsxs)(`div`,ng({className:h},{children:[l===`hour`?r.prefixMinutesForHourPeriod!==``&&(0,Q.jsx)(`span`,{children:r.prefixMinutesForHourPeriod||sg.prefixMinutesForHourPeriod}):r.prefixMinutes!==``&&(0,Q.jsx)(`span`,{children:r.prefixMinutes||sg.prefixMinutes}),(0,Q.jsx)(wg,{placeholder:l===`hour`?r.emptyMinutesForHourPeriod||sg.emptyMinutesForHourPeriod:r.emptyMinutes||sg.emptyMinutes,value:t,unit:og[0],setValue:n,locale:r,className:i,disabled:a,readOnly:o,leadingZero:s,clockFormat:c,period:l,periodicityOnDoubleClick:u,mode:d,allowClear:f,filterOption:p,getPopupContainer:m}),l===`hour`&&r.suffixMinutesForHourPeriod!==``&&(0,Q.jsx)(`span`,{children:r.suffixMinutesForHourPeriod||sg.suffixMinutesForHourPeriod})]}))}function Dg(e){var t=e.value,n=e.setValue,r=e.locale,i=e.className,a=e.weekDays,o=e.disabled,s=e.readOnly,c=e.leadingZero,l=e.period,u=e.periodicityOnDoubleClick,d=e.mode,f=e.allowClear,p=e.filterOption,m=e.getPopupContainer,h=!a||a.length===0,g=(0,Z.useMemo)((function(){var e;return dg(((e={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!h})[`${i}-field`]=!!i,e[`${i}-month-days`]=!!i,e))}),[i,h]),_=(0,Z.useMemo)((function(){return h?r.emptyMonthDays||sg.emptyMonthDays:r.emptyMonthDaysShort||sg.emptyMonthDaysShort}),[h,JSON.stringify(r)]);return!s||t&&t.length>0||(!t||t.length===0)&&(!a||a.length===0)?(0,Q.jsxs)(`div`,ng({className:g},{children:[r.prefixMonthDays!==``&&(0,Q.jsx)(`span`,{children:r.prefixMonthDays||sg.prefixMonthDays}),(0,Q.jsx)(wg,{placeholder:_,value:t,setValue:n,unit:og[2],locale:r,className:i,disabled:o,readOnly:s,leadingZero:c,period:l,periodicityOnDoubleClick:u,mode:d,allowClear:f,filterOption:p,getPopupContainer:m})]})):null}function Og(e){var t=e.value,n=e.setValue,r=e.locale,i=e.className,a=e.humanizeLabels,o=e.disabled,s=e.readOnly,c=e.period,l=e.periodicityOnDoubleClick,u=e.mode,d=e.allowClear,f=e.filterOption,p=e.getPopupContainer,m=r.months||sg.months,h=(0,Z.useMemo)((function(){var e;return dg(((e={"react-js-cron-field":!0,"react-js-cron-months":!0})[`${i}-field`]=!!i,e[`${i}-months`]=!!i,e))}),[i]);return(0,Q.jsxs)(`div`,ng({className:h},{children:[r.prefixMonths!==``&&(0,Q.jsx)(`span`,{children:r.prefixMonths||sg.prefixMonths}),(0,Q.jsx)(wg,{placeholder:r.emptyMonths||sg.emptyMonths,optionsList:m,grid:!1,value:t,unit:ng(ng({},og[3]),{alt:r.altMonths||sg.altMonths}),setValue:n,locale:r,className:i,humanizeLabels:a,disabled:o,readOnly:s,period:c,periodicityOnDoubleClick:l,mode:u,allowClear:d,filterOption:f,getPopupContainer:p})]}))}function kg(e){var t=e.value,n=e.setValue,r=e.locale,i=e.className,a=e.disabled,o=e.readOnly,s=e.shortcuts,c=e.allowedPeriods,u=e.allowClear,d=e.getPopupContainer,f=[];c.includes(`year`)&&f.push({value:`year`,label:r.yearOption||sg.yearOption}),c.includes(`month`)&&f.push({value:`month`,label:r.monthOption||sg.monthOption}),c.includes(`week`)&&f.push({value:`week`,label:r.weekOption||sg.weekOption}),c.includes(`day`)&&f.push({value:`day`,label:r.dayOption||sg.dayOption}),c.includes(`hour`)&&f.push({value:`hour`,label:r.hourOption||sg.hourOption}),c.includes(`minute`)&&f.push({value:`minute`,label:r.minuteOption||sg.minuteOption}),c.includes(`reboot`)&&s&&(!0===s||s.includes(`@reboot`))&&f.push({value:`reboot`,label:r.rebootOption||sg.rebootOption});var p=(0,Z.useCallback)((function(e){o||n(e)}),[n,o]),m=(0,Z.useMemo)((function(){var e;return dg(((e={"react-js-cron-field":!0,"react-js-cron-period":!0})[`${i}-field`]=!!i,e[`${i}-period`]=!!i,e))}),[i]),h=(0,Z.useMemo)((function(){var e;return dg(((e={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":r.prefixPeriod===``})[`${i}-select`]=!!i,e))}),[i,r.prefixPeriod]),g=(0,Z.useMemo)((function(){var e;return dg(((e={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})[`${i}-select-dropdown`]=!!i,e[`${i}-select-dropdown-period`]=!!i,e))}),[i]);return(0,Q.jsxs)(`div`,ng({className:m},{children:[r.prefixPeriod!==``&&(0,Q.jsx)(`span`,{children:r.prefixPeriod||sg.prefixPeriod}),(0,Q.jsx)(l,{defaultValue:t,value:t,onChange:p,options:f,className:h,popupClassName:g,disabled:a,suffixIcon:o?null:void 0,open:!o&&void 0,"data-testid":`select-period`,allowClear:u,getPopupContainer:d},JSON.stringify(r))]}))}function Ag(e){var t=e.value,n=e.setValue,r=e.locale,i=e.className,a=e.humanizeLabels,o=e.monthDays,s=e.disabled,c=e.readOnly,l=e.period,u=e.periodicityOnDoubleClick,d=e.mode,f=e.allowClear,p=e.filterOption,m=e.getPopupContainer,h=r.weekDays||sg.weekDays,g=l===`week`||!o||o.length===0,_=(0,Z.useMemo)((function(){var e;return dg(((e={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!g})[`${i}-field`]=!!i,e[`${i}-week-days`]=!!i,e))}),[i,g]),v=(0,Z.useMemo)((function(){return g?r.emptyWeekDays||sg.emptyWeekDays:r.emptyWeekDaysShort||sg.emptyWeekDaysShort}),[g,JSON.stringify(r)]),y=l===`week`||!c||t&&t.length>0||(!t||t.length===0)&&(!o||o.length===0),b=!c||o&&o.length>0||(!o||o.length===0)&&(!t||t.length===0);return y?(0,Q.jsxs)(`div`,ng({className:_},{children:[r.prefixWeekDays!==``&&(l===`week`||!b)&&(0,Q.jsx)(`span`,{children:r.prefixWeekDays||sg.prefixWeekDays}),r.prefixWeekDaysForMonthAndYearPeriod!==``&&l!==`week`&&b&&(0,Q.jsx)(`span`,{children:r.prefixWeekDaysForMonthAndYearPeriod||sg.prefixWeekDaysForMonthAndYearPeriod}),(0,Q.jsx)(wg,{placeholder:v,optionsList:h,grid:!1,value:t,unit:ng(ng({},og[4]),{alt:r.altWeekDays||sg.altWeekDays}),setValue:n,locale:r,className:i,humanizeLabels:a,disabled:s,readOnly:c,period:l,periodicityOnDoubleClick:u,mode:d,allowClear:f,filterOption:p,getPopupContainer:m})]})):null}function jg(e){var t=e.clearButton,n=t===void 0||t,r=e.clearButtonProps,i=r===void 0?{}:r,a=e.clearButtonAction,o=a===void 0?`fill-with-every`:a,c=e.locale,l=c===void 0?sg:c,u=e.value,d=u===void 0?``:u,f=e.setValue,p=e.displayError,m=p===void 0||p,h=e.onError,g=e.className,_=e.defaultPeriod,v=_===void 0?`day`:_,y=e.allowEmpty,b=y===void 0?`for-default-value`:y,x=e.humanizeLabels,S=x===void 0||x,C=e.humanizeValue,w=C!==void 0&&C,T=e.disabled,E=T!==void 0&&T,D=e.readOnly,O=D!==void 0&&D,k=e.leadingZero,A=k!==void 0&&k,j=e.shortcuts,M=j===void 0?[`@yearly`,`@annually`,`@monthly`,`@weekly`,`@daily`,`@midnight`,`@hourly`]:j,N=e.clockFormat,P=e.periodicityOnDoubleClick,F=P===void 0||P,I=e.mode,ee=I===void 0?`multiple`:I,L=e.allowedDropdowns,te=L===void 0?[`period`,`months`,`month-days`,`week-days`,`hours`,`minutes`]:L,R=e.allowedPeriods,ne=R===void 0?[`year`,`month`,`week`,`day`,`hour`,`minute`,`reboot`]:R,z=e.allowClear,B=e.dropdownsConfig,V=e.getPopupContainer,H=(0,Z.useRef)(d),re=(0,Z.useRef)(v),ie=(0,Z.useState)(),U=ie[0],ae=ie[1],oe=(0,Z.useState)(),se=oe[0],ce=oe[1],le=(0,Z.useState)(),ue=le[0],de=le[1],fe=(0,Z.useState)(),pe=fe[0],me=fe[1],he=(0,Z.useState)(),ge=he[0],_e=he[1],ve=(0,Z.useState)(),ye=ve[0],be=ve[1],xe=(0,Z.useState)(!1),Se=xe[0],Ce=xe[1],we=(0,Z.useState)(!1),W=we[0],Te=we[1],G=function(e){var t=(0,Z.useRef)(e);return(0,Z.useEffect)((function(){t.current=e}),[e]),t.current}(W),Ee=JSON.stringify(l);(0,Z.useEffect)((function(){mg(d,Ce,h,b,H,!0,l,M,be,_e,ce,de,me,ae)}),[]),(0,Z.useEffect)((function(){d!==H.current&&mg(d,Ce,h,b,H,!1,l,M,be,_e,ce,de,me,ae)}),[d,H,Ee,b,M]),(0,Z.useEffect)((function(){if(!(U||ye||ue||se||pe||ge)||W||G)W&&Te(!1);else{var e=U||re.current,t=hg(e,ue,se,pe,ge,ye,w,B);f(t,{selectedPeriod:e}),H.current=t,h&&h(void 0),Ce(!1)}}),[U,se,ue,pe,ge,ye,w,W,B]);var De=(0,Z.useCallback)((function(){ce(void 0),de(void 0),me(void 0),_e(void 0),be(void 0);var e=``,t=U!==`reboot`&&U?U:re.current;(t!==U&&ae(t),o===`fill-with-every`)&&(e=hg(t,void 0,void 0,void 0,void 0,void 0,void 0,void 0)),f(e,{selectedPeriod:t}),H.current=e,Te(!0),b===`never`&&o===`empty`?(Ce(!0),fg(h,l)):(h&&h(void 0),Ce(!1))}),[U,f,h,o]),Oe=(0,Z.useMemo)((function(){var e;return dg(((e={"react-js-cron":!0,"react-js-cron-error":Se&&m,"react-js-cron-disabled":E,"react-js-cron-read-only":O})[`${g}`]=!!g,e[`${g}-error`]=Se&&m&&!!g,e[`${g}-disabled`]=E&&!!g,e[`${g}-read-only`]=O&&!!g,e))}),[g,Se,m,E,O]),ke=i.className,Ae=rg(i,[`className`]),je=(0,Z.useMemo)((function(){var e;return dg(((e={"react-js-cron-clear-button":!0})[`${g}-clear-button`]=!!g,e[`${ke}`]=!!ke,e))}),[g,ke]),Me=(0,Z.useMemo)((function(){return n&&!O?(0,Q.jsx)(s,ng({className:je,danger:!0,type:`primary`,disabled:E},Ae,{onClick:De},{children:l.clearButtonText||sg.clearButtonText})):null}),[n,O,Ee,je,E,JSON.stringify(Ae),De]),Ne=U||re.current;return(0,Q.jsxs)(`div`,ng({className:Oe},{children:[te.includes(`period`)&&(0,Q.jsx)(kg,{value:Ne,setValue:ae,locale:l,className:g,disabled:B?.period?.disabled??E,readOnly:B?.period?.readOnly??O,shortcuts:M,allowedPeriods:ne,allowClear:B?.period?.allowClear??z,getPopupContainer:V}),Ne===`reboot`?Me:(0,Q.jsxs)(Q.Fragment,{children:[Ne===`year`&&te.includes(`months`)&&(0,Q.jsx)(Og,{value:ue,setValue:de,locale:l,className:g,humanizeLabels:B?.months?.humanizeLabels??S,disabled:B?.months?.disabled??E,readOnly:B?.months?.readOnly??O,period:Ne,periodicityOnDoubleClick:B?.months?.periodicityOnDoubleClick??F,mode:B?.months?.mode??ee,allowClear:B?.months?.allowClear??z,filterOption:B?.months?.filterOption,getPopupContainer:V}),(Ne===`year`||Ne===`month`)&&te.includes(`month-days`)&&(0,Q.jsx)(Dg,{value:se,setValue:ce,locale:l,className:g,weekDays:pe,disabled:B?.[`month-days`]?.disabled??E,readOnly:B?.[`month-days`]?.readOnly??O,leadingZero:B?.[`month-days`]?.leadingZero??A,period:Ne,periodicityOnDoubleClick:B?.[`month-days`]?.periodicityOnDoubleClick??F,mode:B?.[`month-days`]?.mode??ee,allowClear:B?.[`month-days`]?.allowClear??z,filterOption:B?.[`month-days`]?.filterOption,getPopupContainer:V}),(Ne===`year`||Ne===`month`||Ne===`week`)&&te.includes(`week-days`)&&(0,Q.jsx)(Ag,{value:pe,setValue:me,locale:l,className:g,humanizeLabels:B?.[`week-days`]?.humanizeLabels??S,monthDays:se,disabled:B?.[`week-days`]?.disabled??E,readOnly:B?.[`week-days`]?.readOnly??O,period:Ne,periodicityOnDoubleClick:B?.[`week-days`]?.periodicityOnDoubleClick??F,mode:B?.[`week-days`]?.mode??ee,allowClear:B?.[`week-days`]?.allowClear??z,filterOption:B?.[`week-days`]?.filterOption,getPopupContainer:V}),(0,Q.jsxs)(`div`,{children:[Ne!==`minute`&&Ne!==`hour`&&te.includes(`hours`)&&(0,Q.jsx)(Tg,{value:ge,setValue:_e,locale:l,className:g,disabled:B?.hours?.disabled??E,readOnly:B?.hours?.readOnly??O,leadingZero:B?.hours?.leadingZero??A,clockFormat:N,period:Ne,periodicityOnDoubleClick:B?.hours?.periodicityOnDoubleClick??F,mode:B?.hours?.mode??ee,allowClear:B?.hours?.allowClear??z,filterOption:B?.hours?.filterOption,getPopupContainer:V}),Ne!==`minute`&&te.includes(`minutes`)&&(0,Q.jsx)(Eg,{value:ye,setValue:be,locale:l,period:Ne,className:g,disabled:B?.minutes?.disabled??E,readOnly:B?.minutes?.readOnly??O,leadingZero:B?.minutes?.leadingZero??A,clockFormat:N,periodicityOnDoubleClick:B?.minutes?.periodicityOnDoubleClick??F,mode:B?.minutes?.mode??ee,allowClear:B?.minutes?.allowClear??z,filterOption:B?.minutes?.filterOption,getPopupContainer:V}),Me]})]})]}))}var Mg=({value:e,checked:t,onChange:n,showWarning:r=!0})=>{let i=typeof t==`boolean`?t:!!e;return(0,Q.jsxs)(G,{orientation:`vertical`,style:{width:`100%`},children:[(0,Q.jsxs)(G,{children:[(0,Q.jsx)(j,{checked:i,onChange:n,checkedChildren:(0,Q.jsx)(ne,{}),unCheckedChildren:(0,Q.jsx)(ne,{})}),(0,Q.jsx)(v.Text,{strong:!0,children:`Enable Network Access`}),(0,Q.jsx)(v.Text,{type:`secondary`,children:`(workspace-write sandbox only)`})]}),(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12,display:`block`},children:i?`Allows outbound HTTP/HTTPS requests for package installation and API calls`:`Network access disabled (default, most secure)`}),r&&i&&(0,Q.jsx)(z,{title:`Security Warning`,description:(0,Q.jsxs)(`div`,{children:[`Enabling network access exposes your environment to:`,(0,Q.jsxs)(`ul`,{style:{marginTop:8,marginBottom:0,paddingLeft:20},children:[(0,Q.jsx)(`li`,{children:`Prompt injection attacks`}),(0,Q.jsx)(`li`,{children:`Data exfiltration of code/secrets`}),(0,Q.jsx)(`li`,{children:`Inclusion of malware or vulnerable dependencies`})]}),`Only enable for trusted tasks.`]}),type:`warning`,icon:(0,Q.jsx)(Ve,{}),showIcon:!0,style:{marginTop:8}})]})},Ng=[{value:`low`,shortLabel:`Lo`,label:`Low`,description:`Minimal thinking, fastest responses`},{value:`medium`,shortLabel:`Md`,label:`Medium`,description:`Moderate thinking`},{value:`high`,shortLabel:`Hi`,label:`High`,description:`Deep reasoning (default)`},{value:`xhigh`,shortLabel:`Xh`,label:`X-High`,description:`Extra reasoning depth, below maximum`},{value:`max`,shortLabel:`Mx`,label:`Max`,description:`Highest effort level (model-dependent)`}],Pg=({value:e=`high`,onChange:t,size:n=`middle`,compact:r=!1,plain:i=!1,fullWidth:a=!1})=>{let{token:o}=X.useToken();return(0,Q.jsx)(H,{title:`Reasoning effort level`,children:(0,Q.jsx)(l,{value:e,onChange:t,size:n,style:{width:a?`100%`:r?void 0:160,fontSize:r?o.fontSizeSM:void 0},popupMatchSelectWidth:!1,optionLabelProp:`label`,options:Ng.map(e=>({value:e.value,label:i?e.label:r?(0,Q.jsxs)(`span`,{style:{fontSize:o.fontSizeSM},children:[(0,Q.jsx)(ie,{style:{fontSize:o.fontSizeSM-1,marginRight:2}}),e.shortLabel]}):(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(ie,{style:{fontSize:12,marginRight:6}}),e.label,` effort`]})})),optionRender:e=>{let t=Ng.find(t=>t.value===e.value);return(0,Q.jsxs)(G,{size:6,align:`start`,children:[(0,Q.jsx)(ie,{style:{marginTop:3}}),(0,Q.jsxs)(`div`,{style:{lineHeight:1.3},children:[(0,Q.jsx)(`div`,{children:t?.label}),(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:11},children:t?.description})]})]})}})})};function Fg(e,t,n){return!t||e.some(e=>e.id===t)?e:[n(t),...e]}function Ig(e,t,n={}){return e===`cursor`?n.cursorDefaultModel||`composer-latest`:e===`copilot`?n.copilotDefaultModel||Yt(e)||`claude-sonnet-4.6`:Yt(e)||t[0]?.id||``}var{Text:Lg}=v,Rg=({value:e,onChange:t})=>{let[n,r]=(0,Z.useState)([]),[i,a]=(0,Z.useState)(!0),[o,s]=(0,Z.useState)(null),[c,u]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{(async()=>{try{a(!0),s(null),r((await(await Ut(nu())).service(`opencode/models`).find()).providers||[])}catch(e){console.error(`Failed to fetch OpenCode models:`,e),s(e instanceof Error?e.message:`Failed to fetch models. Is OpenCode server running?`)}finally{a(!1)}})()},[]),(0,Z.useEffect)(()=>{if(!e&&n.length>0&&!c&&t){let e=n[0],r=e.models?.[0];e&&r&&(t({provider:e.id,model:r.id}),u(!0))}},[e,n,c,t]);let d=n.find(t=>t.id===e?.provider),f=d?.models||[],p=e=>{let r=n.find(t=>t.id===e);r&&r.models.length>0&&t&&t({provider:e,model:r.models[0].id})},m=n=>{t&&e?.provider&&t({provider:e.provider,model:n})};return i?(0,Q.jsxs)(G,{children:[(0,Q.jsx)(Ze,{size:`small`}),(0,Q.jsx)(Lg,{type:`secondary`,children:`Loading OpenCode models...`})]}):o?(0,Q.jsx)(z,{title:`OpenCode Unavailable`,description:o,type:`warning`,showIcon:!0,icon:(0,Q.jsx)(y,{}),action:(0,Q.jsxs)(Lg,{type:`secondary`,style:{fontSize:12},children:[`Start OpenCode server: `,(0,Q.jsx)(`code`,{children:`opencode serve --port 4096`})]})}):n.length===0?(0,Q.jsx)(z,{title:`No Providers Available`,description:`OpenCode server returned no providers. Check your OpenCode installation.`,type:`info`,showIcon:!0}):(0,Q.jsxs)(G,{orientation:`vertical`,style:{width:`100%`},children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(Lg,{strong:!0,style:{display:`block`,marginBottom:8},children:`Provider`}),(0,Q.jsx)(l,{style:{width:`100%`},value:e?.provider,onChange:p,placeholder:`Select provider`,children:[...n].sort((e,t)=>e.name.localeCompare(t.name)).map(e=>(0,Q.jsx)(l.Option,{value:e.id,children:(0,Q.jsxs)(G,{children:[(0,Q.jsx)(`span`,{children:e.name}),(0,Q.jsxs)(Lg,{type:`secondary`,style:{fontSize:12},children:[`(`,e.models.length,` models)`]})]})},e.id))})]}),d&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(Lg,{strong:!0,style:{display:`block`,marginBottom:8},children:`Model`}),(0,Q.jsx)(l,{style:{width:`100%`},value:e?.model,onChange:m,placeholder:`Select model`,showSearch:!0,optionFilterProp:`children`,children:[...f].sort((e,t)=>e.name.localeCompare(t.name)).map(e=>(0,Q.jsx)(l.Option,{value:e.id,children:e.name},e.id))})]}),(0,Q.jsxs)(Lg,{type:`secondary`,style:{fontSize:12},children:[(0,Q.jsx)(y,{}),` Models available based on your OpenCode configuration`]})]})},zg=Object.entries(Bt).map(([e,t])=>({id:e,label:t.name,description:t.description})),Bg=Object.entries(It).map(([e,t])=>({id:e,label:t.name,description:t.description})),Vg=Object.entries(Zt).map(([e,t])=>({id:e,label:t.name,description:t.description})),Hg=[{id:Gt,label:wt[Gt].displayName,description:wt[Gt].description}];function Ug(e,t){let n=e.findIndex(e=>e.id===t);return n<=0?e:[e[n],...e.slice(0,n),...e.slice(n+1)]}var Wg=({value:e,onChange:t,agent:n,agentic_tool:r,client:i,compact:a=!1})=>{let{token:o}=X.useToken(),s=r||n||`claude-code`,[c,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(Dt),[w,T]=(0,Z.useState)(Gt);(0,Z.useEffect)(()=>{if(s!==`claude-code`&&s!==`claude-code-cli`||!i)return;let e=!1;return(async()=>{try{let t=await i.service(`claude-models`).find();if(e||!t?.models?.length)return;u(t.models.map(e=>({id:e.id,label:e.displayName,description:e.description}))),f(t.source)}catch{}})(),()=>{e=!0}},[s,i]),(0,Z.useEffect)(()=>{if(s!==`copilot`||!i)return;let e=!1;return(async()=>{try{let t=await i.service(`copilot-models`).find();if(e||!t?.models?.length)return;let n=t.default||`claude-sonnet-4.6`;m(Ug(Fg(t.models.map(e=>({id:e.id,label:e.displayName,description:e.description})),n,e=>({id:e,label:e,description:`Default model`})),n)),C(n),g(t.source)}catch{}})(),()=>{e=!0}},[s,i]),(0,Z.useEffect)(()=>{if(s!==`cursor`||!i)return;let e=!1;return(async()=>{try{let t=await i.service(`cursor-models`).find();if(e||!t?.models?.length)return;let n=t.default||`composer-latest`;v(Ug(Fg(t.models.map(e=>({id:e.id,label:e.displayName,description:e.description})),n,e=>({id:e,label:e,description:`Default model`})),n)),T(n),x(t.source)}catch{}})(),()=>{e=!0}},[s,i]);let E=s===`codex`?zg:s===`gemini`?Bg:s===`opencode`?[]:s===`copilot`?p??Vg:s===`cursor`?Ug(_??Hg,w):c??kt,D=e?.model?E.some(t=>t.id===e.model):!0,[O,k]=(0,Z.useState)(e?.mode||(D?`alias`:`exact`));if(s===`opencode`)return(0,Q.jsx)(Rg,{value:e?.provider||e?.model?{provider:e.provider||``,model:e.model||``}:void 0,onChange:e=>{t&&t({mode:`exact`,model:e.model,provider:e.provider})}});let A=Ig(s,E,{copilotDefaultModel:S,cursorDefaultModel:w}),j=n=>{k(n),t&&t({...e,mode:n,model:e?.model||A})},M=n=>{t&&t({...e,mode:O,model:n})},N=n=>{t&&t({...e,mode:O,model:e?.model||A,advisorModel:n})};if(a){let t=e?.model||A,n=E.map(e=>({value:e.id,label:e.id}));t&&!n.some(e=>e.value===t)&&n.unshift({value:t,label:t});let r=(0,Q.jsx)(l,{value:t,onChange:M,size:`small`,showSearch:!0,optionFilterProp:`label`,popupMatchSelectWidth:!1,style:{width:`100%`,fontSize:o.fontSizeSM},options:n});return s===`claude-code`||s===`claude-code-cli`?(0,Q.jsxs)(G,{orientation:`vertical`,size:6,style:{width:`100%`},children:[r,(0,Q.jsx)(l,{allowClear:!0,showSearch:!0,size:`small`,optionFilterProp:`label`,placeholder:`Advisor model: off`,value:e?.advisorModel,onChange:N,popupMatchSelectWidth:!1,style:{width:`100%`,fontSize:o.fontSizeSM},options:(c??kt).map(e=>({value:e.id,label:`Advisor: ${e.id}`}))})]}):r}return(0,Q.jsxs)(G,{orientation:`vertical`,style:{width:`100%`},children:[(0,Q.jsx)(K.Group,{value:O,onChange:e=>j(e.target.value),children:(0,Q.jsxs)(G,{orientation:`vertical`,children:[(0,Q.jsx)(K,{value:`alias`,children:(0,Q.jsxs)(G,{children:[`Use model alias (recommended)`,(0,Q.jsx)(H,{title:`Automatically uses the latest version of the model`,children:(0,Q.jsx)(y,{})})]})}),O===`alias`&&(0,Q.jsxs)(`div`,{style:{marginLeft:24,marginTop:8},children:[(0,Q.jsx)(l,{showSearch:!0,optionFilterProp:`label`,value:e?.model||A,onChange:M,style:{width:`100%`,minWidth:400},options:E.map(e=>({value:e.id,label:e.id}))}),(s===`claude-code`||s===`claude-code-cli`)&&d&&(0,Q.jsx)(`div`,{style:{marginTop:6,fontSize:12,color:o.colorTextTertiary},children:d===`dynamic`?(0,Q.jsx)(Q.Fragment,{children:`Live list from the Anthropic Models API.`}):(0,Q.jsxs)(Q.Fragment,{children:[`Showing static fallback. Set `,(0,Q.jsx)(`code`,{children:`ANTHROPIC_API_KEY`}),` to see the live model list.`]})}),s===`copilot`&&h&&(0,Q.jsx)(`div`,{style:{marginTop:6,fontSize:12,color:o.colorTextTertiary},children:h===`dynamic`?(0,Q.jsxs)(Q.Fragment,{children:[`Live list from your Copilot account (via SDK `,(0,Q.jsx)(`code`,{children:`listModels()`}),`).`]}):(0,Q.jsxs)(Q.Fragment,{children:[`Showing static fallback. Set `,(0,Q.jsx)(`code`,{children:`COPILOT_GITHUB_TOKEN`}),` on the daemon to see your account's live list (including BYOK models).`]})}),s===`cursor`&&b&&(0,Q.jsx)(`div`,{style:{marginTop:6,fontSize:12,color:o.colorTextTertiary},children:b===`dynamic`?(0,Q.jsxs)(Q.Fragment,{children:[`Live list from your Cursor account (via SDK `,(0,Q.jsx)(`code`,{children:`Cursor.models.list()`}),`).`]}):(0,Q.jsxs)(Q.Fragment,{children:[`Showing static fallback. Set `,(0,Q.jsx)(`code`,{children:`CURSOR_API_KEY`}),` to see your account's live Cursor model list.`]})})]}),(0,Q.jsx)(K,{value:`exact`,children:(0,Q.jsxs)(G,{children:[`Specify exact model ID`,(0,Q.jsx)(H,{title:`Pin to a specific model release for reproducibility`,children:(0,Q.jsx)(y,{})})]})}),O===`exact`&&(0,Q.jsxs)(`div`,{style:{marginLeft:24,marginTop:8},children:[(0,Q.jsx)(J,{value:e?.model,onChange:e=>M(e.target.value),placeholder:s===`codex`?`e.g., gpt-5.5`:s===`gemini`?`e.g., gemini-2.5-pro`:s===`copilot`?`e.g., gpt-4o or claude-3.5-sonnet`:s===`cursor`?`e.g., composer-latest`:`e.g., claude-opus-4-20250514`,style:{width:`100%`,minWidth:400}}),(0,Q.jsxs)(`div`,{style:{marginTop:8,fontSize:12,color:o.colorTextTertiary},children:[`Enter any model ID to pin to a specific version.`,` `,(0,Q.jsx)(`a`,{href:s===`codex`?`https://platform.openai.com/docs/models`:s===`gemini`?`https://ai.google.dev/gemini-api/docs/models`:s===`copilot`?`https://github.com/features/copilot`:s===`cursor`?`https://cursor.com/docs/api/sdk/typescript`:`https://platform.claude.com/docs/en/about-claude/models`,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),style:{fontSize:12,color:`#1677ff`},children:`View available models`})]})]})]})}),(s===`claude-code`||s===`claude-code-cli`)&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(G,{size:4,children:[(0,Q.jsx)(`span`,{children:`Advisor model`}),(0,Q.jsx)(H,{title:`Optional Claude Code advisor tool model. Leave unset to use existing Claude settings or disable session-level override.`,children:(0,Q.jsx)(y,{})})]}),(0,Q.jsx)(l,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,placeholder:`Not set`,value:e?.advisorModel,onChange:N,style:{width:`100%`,minWidth:400,marginTop:8},options:(c??kt).map(e=>({value:e.id,label:e.id}))})]})]})},Gg=[{mode:`default`,label:`default`,description:`Prompt for each tool use (most restrictive)`,icon:(0,Q.jsx)(S,{}),color:`#f5222d`},{mode:`acceptEdits`,label:`acceptEdits`,description:`Auto-accept file edits, ask for other tools (recommended)`,icon:(0,Q.jsx)(P,{}),color:`#52c41a`},{mode:`auto`,label:`auto`,description:`Model classifier approves/denies prompts, asks only when unsure`,icon:(0,Q.jsx)(at,{}),color:`#13c2c2`},{mode:`bypassPermissions`,label:`bypassPermissions`,description:`Allow all operations without prompting`,icon:(0,Q.jsx)(Ye,{}),color:`#faad14`},{mode:`plan`,label:`plan`,description:`Generate plan without executing`,icon:(0,Q.jsx)(tt,{}),color:`#1890ff`}],Kg=[{mode:`ask`,label:`untrusted`,description:`Only run trusted commands (ls, cat, sed) without approval`,icon:(0,Q.jsx)(S,{}),color:`#f5222d`},{mode:`auto`,label:`on-request`,description:`Model decides when to ask for approval`,icon:(0,Q.jsx)(at,{}),color:`#52c41a`},{mode:`on-failure`,label:`on-failure`,description:`Run all commands, ask only when they fail`,icon:(0,Q.jsx)(P,{}),color:`#faad14`},{mode:`allow-all`,label:`never`,description:`Never ask for approval, failures returned to model`,icon:(0,Q.jsx)(Ye,{}),color:`#722ed1`}],qg=[{mode:`default`,label:`default`,description:`Prompt for each tool use (most restrictive)`,icon:(0,Q.jsx)(S,{}),color:`#f5222d`},{mode:`autoEdit`,label:`autoEdit`,description:`Auto-approve file edits, ask for shell/web tools`,icon:(0,Q.jsx)(P,{}),color:`#52c41a`},{mode:`yolo`,label:`yolo`,description:`Allow all operations without prompting`,icon:(0,Q.jsx)(Ye,{}),color:`#faad14`}],Jg=[{mode:`default`,label:`default`,description:`Proxy all permission requests to Agor UI for approval`,icon:(0,Q.jsx)(S,{}),color:`#f5222d`},{mode:`acceptEdits`,label:`acceptEdits`,description:`Auto-approve read/write operations, ask for shell/MCP (recommended)`,icon:(0,Q.jsx)(P,{}),color:`#52c41a`},{mode:`bypassPermissions`,label:`bypassPermissions`,description:`Auto-approve all operations without prompting`,icon:(0,Q.jsx)(Ye,{}),color:`#faad14`}],Yg=[{mode:`bypassPermissions`,label:`Autonomous`,description:`Cursor SDK runs autonomously; Agor cannot intercept permission requests yet`,icon:(0,Q.jsx)(Ye,{}),color:`#faad14`}],Xg=[{mode:`default`,label:`default`,description:`Prompt for approval before each operation`,icon:(0,Q.jsx)(S,{}),color:`#f5222d`},{mode:`autoEdit`,label:`autoEdit`,description:`Auto-approve all operations (recommended)`,icon:(0,Q.jsx)(P,{}),color:`#52c41a`},{mode:`yolo`,label:`yolo`,description:`Fully bypass all permission checks`,icon:(0,Q.jsx)(Ye,{}),color:`#faad14`}],Zg=[{value:`read-only`,label:`read-only`,description:`No filesystem writes`},{value:`workspace-write`,label:`workspace-write`,description:`Workspace files only (blocks .git/)`},{value:`danger-full-access`,label:`full-access`,description:`Full filesystem (including .git/)`}],Qg=[{value:`untrusted`,label:`untrusted`,description:`Ask for every operation`},{value:`on-request`,label:`on-request`,description:`Model decides when to ask`},{value:`on-failure`,label:`on-failure`,description:`Ask only on failures`},{value:`never`,label:`never`,description:`Auto-approve everything`}],$g=e=>{switch(e){case`codex`:return Kg;case`gemini`:return qg;case`opencode`:return Xg;case`copilot`:return Jg;case`cursor`:return Yg;default:return Gg}},e_=({value:e,onChange:t,agentic_tool:n=`claude-code`,compact:r=!1,iconOnly:i=!1,plain:a=!1,fullWidth:o=!1,size:s=`middle`,codexSandboxMode:c,codexApprovalPolicy:u,onCodexChange:d})=>{let{token:f}=X.useToken(),p=$g(n),m=n===`cursor`?`bypassPermissions`:e||_t(n),h=yt(m),g=c??h.sandboxMode,_=u??h.approvalPolicy;if(r){if(n===`codex`&&d)return(0,Q.jsxs)(G,{size:4,direction:o?`vertical`:`horizontal`,style:{width:`100%`},children:[(0,Q.jsx)(l,{value:g,onChange:e=>d(e,_),size:s,placeholder:`Sandbox`,popupMatchSelectWidth:!1,style:{minWidth:70,width:o?`100%`:void 0,fontSize:f.fontSizeSM},optionLabelProp:`label`,options:Zg.map(({value:e,label:t,description:n})=>({label:t,value:e,title:n})),optionRender:e=>(0,Q.jsxs)(`div`,{style:{lineHeight:1.3},children:[(0,Q.jsx)(`div`,{children:e.label}),(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:11},children:e.data.title})]})}),(0,Q.jsx)(l,{value:_,onChange:e=>d(g,e),size:s,placeholder:`Approval`,popupMatchSelectWidth:!1,style:{minWidth:70,width:o?`100%`:void 0,fontSize:f.fontSizeSM},optionLabelProp:`label`,options:Qg.map(({value:e,label:t,description:n})=>({label:t,value:e,title:n})),optionRender:e=>(0,Q.jsxs)(`div`,{style:{lineHeight:1.3},children:[(0,Q.jsx)(`div`,{children:e.label}),(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:11},children:e.data.title})]})})]});let e=p.find(e=>e.mode===m);return(0,Q.jsx)(H,{title:e?`${e.label} — ${e.description}`:`Permission mode`,children:(0,Q.jsx)(l,{value:m,onChange:t,style:{fontSize:f.fontSizeSM,width:o?`100%`:void 0},size:s,popupMatchSelectWidth:!1,optionLabelProp:`label`,options:p.map(({mode:e,label:t,description:n,icon:r,color:o})=>({label:a?t:i?(0,Q.jsx)(`span`,{style:{color:o,fontSize:f.fontSizeSM},children:r}):(0,Q.jsxs)(G,{size:4,style:{fontSize:f.fontSizeSM},children:[(0,Q.jsx)(`span`,{style:{color:o},children:r}),(0,Q.jsx)(`span`,{children:t})]}),value:e,title:n,icon:r,color:o})),optionRender:e=>{let t=p.find(t=>t.mode===e.value);return(0,Q.jsxs)(G,{size:6,align:`start`,children:[t&&(0,Q.jsx)(`span`,{style:{color:t.color},children:t.icon}),(0,Q.jsxs)(`div`,{style:{lineHeight:1.3},children:[(0,Q.jsx)(`div`,{children:t?.label}),(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:11},children:t?.description})]})]})}})})}return(0,Q.jsx)(K.Group,{value:m,onChange:e=>t?.(e.target.value),children:(0,Q.jsx)(G,{orientation:`vertical`,style:{width:`100%`},children:p.map(({mode:e,label:t,description:n,icon:r,color:i})=>(0,Q.jsx)(K,{value:e,children:(0,Q.jsxs)(G,{children:[(0,Q.jsx)(`span`,{style:{color:i},children:r}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(v.Text,{strong:!0,children:t}),(0,Q.jsx)(`br`,{}),(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12},children:n})]})]})},e))})})},t_={codex:`Codex Model`,gemini:`Gemini Model`,opencode:`OpenCode LLM Provider`,copilot:`Copilot Model`,cursor:`Cursor Model`},n_=({agenticTool:e,mcpServerById:t,showHelpText:n=!0,compact:r=!1,hideMcpServers:i=!1,client:a})=>{let o=t_[e]??`Claude Model`,s=e===`codex`&&!r;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y.Item,{name:`modelConfig`,label:o,help:n&&e===`claude-code`?`Choose which Claude model to use (defaults to ${Mt})`:void 0,children:(0,Q.jsx)(Wg,{agentic_tool:e,client:a})}),(0,Q.jsx)(Y.Item,{name:`permissionMode`,label:`Permission Mode`,help:n?`Control how the agent handles tool execution approvals`:void 0,children:(0,Q.jsx)(e_,{agentic_tool:e,compact:r})}),(e===`claude-code`||e===`claude-code-cli`)&&(0,Q.jsx)(Y.Item,{name:`effort`,label:`Reasoning Effort`,help:n?`Control how much reasoning Claude applies (low = fast, high = thorough, max = Opus only)`:void 0,children:(0,Q.jsx)(Pg,{})}),s&&(0,Q.jsx)(Y.Item,{name:`codexSandboxMode`,label:`Sandbox Mode`,help:n?`Controls where Codex can write files (workspace vs. full access)`:void 0,children:(0,Q.jsx)(l,{placeholder:`Select sandbox mode`,options:Zg.map(({value:e,label:t,description:n})=>({value:e,label:`${t} · ${n}`}))})}),s&&(0,Q.jsx)(Y.Item,{name:`codexApprovalPolicy`,label:`Approval Policy`,help:n?`Controls whether Codex must ask before executing commands`:void 0,children:(0,Q.jsx)(l,{placeholder:`Select approval policy`,options:Qg.map(({value:e,label:t,description:n})=>({value:e,label:`${t} · ${n}`}))})}),s&&(0,Q.jsx)(Y.Item,{name:`codexNetworkAccess`,label:`Network Access`,help:n?`Allow outbound HTTP/HTTPS requests (workspace-write sandbox only)`:void 0,valuePropName:`checked`,children:(0,Q.jsx)(Mg,{showWarning:n})}),!i&&(0,Q.jsx)(Mh,{mcpServerById:t,showHelpText:n})]})};function r_(e,t){return t?{modelConfig:t.modelConfig,effort:t.modelConfig?.effort,permissionMode:t.permissionMode||_t(e),mcpServerIds:t.mcpServerIds||[],...e===`codex`&&{codexSandboxMode:t.codexSandboxMode,codexApprovalPolicy:t.codexApprovalPolicy,codexNetworkAccess:t.codexNetworkAccess}}:{permissionMode:_t(e),mcpServerIds:[]}}function i_(e,t){return{modelConfig:t.modelConfig?{...t.modelConfig,effort:t.effort}:t.effort?{effort:t.effort}:void 0,permissionMode:t.permissionMode,mcpServerIds:t.mcpServerIds,...e===`codex`&&{codexSandboxMode:t.codexSandboxMode,codexApprovalPolicy:t.codexApprovalPolicy,codexNetworkAccess:t.codexNetworkAccess}}}function a_(e){if(e)return{modelConfig:e.model_config,permissionMode:e.permission_mode,mcpServerIds:e.mcp_server_ids,...e.agentic_tool===`codex`&&{codexSandboxMode:e.codex_sandbox_mode,codexApprovalPolicy:e.codex_approval_policy,codexNetworkAccess:e.codex_network_access}}}function o_(e,t,n){let r=i_(e,t);return{...n,agentic_tool:e,permission_mode:r.permissionMode,model_config:r.modelConfig,mcp_server_ids:r.mcpServerIds,context_files:n?.context_files,codex_sandbox_mode:e===`codex`?r.codexSandboxMode:void 0,codex_approval_policy:e===`codex`?r.codexApprovalPolicy:void 0,codex_network_access:e===`codex`?r.codexNetworkAccess:void 0}}function s_(e){return{modelConfig:void 0,effort:void 0,permissionMode:_t(e),mcpServerIds:[],...e===`codex`&&{codexSandboxMode:void 0,codexApprovalPolicy:void 0,codexNetworkAccess:void 0}}}var{TextArea:c_}=J,{Text:l_}=v,u_=[`America/Los_Angeles`,`America/Denver`,`America/Chicago`,`America/New_York`,`America/Sao_Paulo`,`Europe/London`,`Europe/Paris`,`Europe/Berlin`,`Asia/Dubai`,`Asia/Kolkata`,`Asia/Shanghai`,`Asia/Tokyo`,`Australia/Sydney`,`Pacific/Auckland`];function d_(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}catch{return`UTC`}}var f_=`0 * * * *`,p_=({open:e,onClose:t,branchId:n,branchName:r,schedule:i,mcpServerById:o,client:c,onSaved:l})=>{let u=!!i?.schedule_id,{showError:d,showSuccess:f}=cf(),[p]=Y.useForm(),[m,h]=(0,Z.useState)(i?.agentic_tool_config?.agentic_tool??`claude-code`),[g,_]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{if(!e)return;let t=i?.agentic_tool_config?.agentic_tool??`claude-code`,n=r_(t,a_(i?.agentic_tool_config));h(t),_(!1),p.resetFields(),p.setFieldsValue({name:i?.name??``,description:i?.description??``,prompt:i?.prompt??``,cron_expression:i?.cron_expression??f_,timezone_mode:i?.timezone_mode??`local`,timezone:i?.timezone??d_(),agenticTool:t,enabled:i?.enabled??!0,retention:i?.retention??5,allow_concurrent_runs:i?.allow_concurrent_runs??!1,...n})},[e,i,p]);let x=e=>{if(e===m)return;h(e);let t=r_(e);p.setFieldsValue({...t,agenticTool:e,...e!==`codex`&&{codexSandboxMode:void 0,codexApprovalPolicy:void 0,codexNetworkAccess:void 0}})},S=Y.useWatch(`cron_expression`,p)??f_,w=Y.useWatch(`timezone_mode`,p)??`local`,T=(0,Z.useMemo)(()=>{try{return pt(S)}catch{return null}},[S]);return(0,Q.jsx)(a,{title:u?`Edit schedule — ${i?.name}`:`New schedule for ${r}`,open:e,onCancel:t,width:760,destroyOnClose:!0,footer:[(0,Q.jsx)(s,{onClick:t,disabled:y,children:`Cancel`},`cancel`),(0,Q.jsx)(s,{type:`primary`,loading:y,onClick:async()=>{if(!c){d(`Not connected to daemon`);return}let e;try{e=await p.validateFields()}catch{return}if(e.timezone_mode===`local`&&!e.timezone){d(`Timezone is required when mode is 'local'`);return}let r={...p.getFieldsValue(!0),...e};b(!0);try{let e={branch_id:n,name:(r.name??``).trim(),description:r.description?.trim()||void 0,prompt:(r.prompt??``).trim(),cron_expression:r.cron_expression??f_,timezone_mode:r.timezone_mode??`local`,timezone:r.timezone_mode===`local`?r.timezone:void 0,agentic_tool_config:o_(m,{modelConfig:r.modelConfig,effort:r.effort,permissionMode:r.permissionMode,mcpServerIds:r.mcpServerIds,codexSandboxMode:r.codexSandboxMode,codexApprovalPolicy:r.codexApprovalPolicy,codexNetworkAccess:r.codexNetworkAccess},i?.agentic_tool_config),enabled:r.enabled??!0,retention:r.retention??5,allow_concurrent_runs:r.allow_concurrent_runs??!1},a;a=u&&i?.schedule_id?await c.service(`schedules`).patch(i.schedule_id,e):await c.service(`schedules`).create(e),f(u?`Schedule updated`:`Schedule created`),l?.(a),t()}catch(e){d(e instanceof Error?e.message:`Failed to save schedule`)}finally{b(!1)}},children:u?`Save`:`Create`},`save`)],children:(0,Q.jsxs)(Y,{form:p,layout:`vertical`,preserve:!1,style:{marginTop:16},children:[(0,Q.jsx)(Y.Item,{name:`enabled`,label:`Enabled`,valuePropName:`checked`,children:(0,Q.jsx)(j,{})}),(0,Q.jsx)(Y.Item,{name:`name`,label:`Name`,rules:[{required:!0,message:`Name is required`}],children:(0,Q.jsx)(J,{placeholder:`Hourly heartbeat`})}),(0,Q.jsx)(Y.Item,{name:`description`,label:`Description (optional)`,children:(0,Q.jsx)(J,{placeholder:`What this schedule does`})}),(0,Q.jsx)(Y.Item,{name:`prompt`,label:`Prompt template`,rules:[{required:!0,message:`Prompt is required`}],help:(0,Q.jsxs)(l_,{type:`secondary`,style:{fontSize:12},children:[`Handlebars: `,(0,Q.jsx)(`code`,{children:`{{branch.*}}`}),` `,(0,Q.jsx)(`code`,{children:`{{schedule.*}}`})]}),children:(0,Q.jsx)(c_,{placeholder:`Review the current state of {{branch.name}} and post a status update.`,rows:6})}),(0,Q.jsx)(Y.Item,{name:`cron_expression`,label:`Cron expression`,rules:[{required:!0,message:`Cron is required`}],extra:(0,Q.jsxs)(Q.Fragment,{children:[T&&(0,Q.jsxs)(l_,{type:`secondary`,style:{fontSize:12},children:[`ⓘ `,T]}),g&&(0,Q.jsx)(`div`,{style:{marginTop:12},children:(0,Q.jsx)(jg,{value:S,setValue:e=>p.setFieldValue(`cron_expression`,e),clearButton:!1})})]}),children:(0,Q.jsxs)(G.Compact,{style:{width:`100%`},children:[(0,Q.jsx)(J,{value:S,onChange:e=>p.setFieldValue(`cron_expression`,e.target.value),placeholder:`0 * * * *`}),(0,Q.jsx)(s,{onClick:()=>_(e=>!e),children:g?`Hide picker`:`Edit visually`})]})}),(0,Q.jsx)(Y.Item,{name:`timezone_mode`,label:`Timezone mode`,children:(0,Q.jsxs)(K.Group,{children:[(0,Q.jsx)(K,{value:`local`,children:`Local time`}),(0,Q.jsx)(K,{value:`utc`,children:`UTC`})]})}),w===`local`&&(0,Q.jsx)(Y.Item,{name:`timezone`,label:`Timezone`,rules:[{required:!0,message:`Timezone is required in local mode`}],children:(0,Q.jsx)(ft,{options:u_.map(e=>({value:e,label:e})),filterOption:(e,t)=>(t?.value??``).toLowerCase().includes(e.toLowerCase()),placeholder:`Type or pick an IANA zone (e.g. America/Los_Angeles, Asia/Bangkok)`})}),(0,Q.jsx)(Y.Item,{label:`Agentic tool`,children:(0,Q.jsx)(Wa,{agents:Ka,selectedAgentId:m,onSelect:e=>x(e),variant:`select`})}),(0,Q.jsx)(Mh,{mcpServerById:o}),(0,Q.jsx)(A,{ghost:!0,destroyOnHidden:!1,expandIcon:({isActive:e})=>(0,Q.jsx)(C,{rotate:e?180:0}),items:[{key:`agentic-tool-config`,label:(0,Q.jsx)(v.Text,{strong:!0,children:`Agentic Tool Configuration`}),children:(0,Q.jsx)(n_,{agenticTool:m,mcpServerById:o,hideMcpServers:!0,client:c})},{key:`schedule-settings`,label:(0,Q.jsx)(v.Text,{strong:!0,children:`Schedule Settings`}),children:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y.Item,{name:`retention`,label:`Retention (sessions to keep; 0 = keep all)`,children:(0,Q.jsx)(lt,{min:0})}),(0,Q.jsx)(Y.Item,{name:`allow_concurrent_runs`,label:`Concurrency`,extra:`Controls overlap for this schedule only; sibling schedules on the same branch are independent.`,children:(0,Q.jsxs)(K.Group,{children:[(0,Q.jsx)(K,{value:!1,children:`Block overlapping runs from this schedule (default)`}),(0,Q.jsx)(K,{value:!0,children:`Allow overlapping runs from this schedule`})]})})]})}],style:{marginTop:16}}),!u&&(0,Q.jsx)(z,{style:{marginTop:16},type:`info`,showIcon:!0,message:`Catchup is disabled by default.`,description:`If the daemon is down when a fire is due, only the most recent missed run within the 2-minute grace window will fire. No backfill.`})]})})},m_=20,h_=e=>{switch(e){case`completed`:return`green`;case`failed`:case`timed_out`:return`red`;case`running`:case`stopping`:case`awaiting_permission`:case`awaiting_input`:return`blue`;default:return`default`}},g_=e=>e?new Date(e).toLocaleString():`—`,__=e=>{let t=e.scheduled_run_at,n=e.last_updated?Date.parse(e.last_updated):null;if(!t||!n||n<=t)return`—`;let r=Math.round((n-t)/1e3);return r<60?`${r}s`:`${Math.floor(r/60)}m ${r%60}s`},v_=({open:e,onClose:t,schedule:n,client:r,onOpenSession:i})=>{let[a,o]=(0,Z.useState)([]),[c,l]=(0,Z.useState)(!1),d=(0,Z.useCallback)(async()=>{if(!(!r||!n?.schedule_id)){l(!0);try{let e=await r.service(`sessions`).find({query:{schedule_id:n.schedule_id,$sort:{scheduled_run_at:-1},$limit:m_}});o(Array.isArray(e)?e:e.data)}catch(e){console.error(`Failed to load schedule runs:`,e)}finally{l(!1)}}},[r,n?.schedule_id]);return(0,Z.useEffect)(()=>{e&&d()},[e,d]),(0,Q.jsx)(Ke,{title:n?`Runs — ${n.name}`:`Runs`,open:e,onClose:t,width:640,destroyOnClose:!0,children:c?(0,Q.jsx)(Ze,{}):a.length===0?(0,Q.jsx)(fe,{description:`No runs yet.`}):(0,Q.jsx)(ue,{rowKey:`session_id`,dataSource:a,columns:[{title:`Scheduled`,key:`scheduled_run_at`,render:e=>g_(e.scheduled_run_at)},{title:`Status`,key:`status`,render:e=>(0,Q.jsx)(u,{color:h_(e.status),children:e.status})},{title:`Duration`,key:`duration`,render:e=>__(e)},{title:``,key:`open`,render:e=>i?(0,Q.jsx)(s,{type:`link`,size:`small`,onClick:()=>i(e.session_id),children:`Open`}):null}],pagination:!1,size:`small`})})},{Text:y_}=v,b_=e=>e?new Date(e).toLocaleString():`—`,x_=e=>{try{return pt(e)}catch{return e}},S_={display:`block`,maxWidth:`100%`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},C_=({children:e,title:t,type:n,code:r,ariaLabel:i})=>(0,Q.jsx)(H,{title:t,mouseEnterDelay:.4,children:(0,Q.jsx)(y_,{"aria-label":i,code:r,type:n,style:S_,title:typeof e==`string`?e:void 0,children:e})}),w_=(e,t,n)=>{if(!e)return`—`;let r=t.get(e),i=r?.email??r?.name??Jt(e);return n?.user_id===e?`${i} (you)`:i},T_=({schedule:e,humanizedCron:t,userById:n,currentUser:r})=>(0,Q.jsxs)(G,{direction:`vertical`,size:2,style:{maxWidth:360},children:[(0,Q.jsx)(y_,{strong:!0,children:e.name||`Untitled schedule`}),e.description?(0,Q.jsx)(y_,{children:e.description}):null,(0,Q.jsxs)(y_,{children:[(0,Q.jsx)(y_,{strong:!0,children:`Schedule:`}),` `,t]}),(0,Q.jsxs)(y_,{children:[(0,Q.jsx)(y_,{strong:!0,children:`Cron:`}),` `,(0,Q.jsx)(y_,{code:!0,children:e.cron_expression})]}),(0,Q.jsxs)(y_,{children:[(0,Q.jsx)(y_,{strong:!0,children:`Timezone:`}),` `,e.timezone_mode===`utc`?`UTC`:e.timezone||`local`]}),(0,Q.jsxs)(y_,{children:[(0,Q.jsx)(y_,{strong:!0,children:`Next:`}),` `,b_(e.next_run_at)]}),(0,Q.jsxs)(y_,{children:[(0,Q.jsx)(y_,{strong:!0,children:`Last:`}),` `,b_(e.last_run_at)]}),(0,Q.jsxs)(y_,{children:[(0,Q.jsx)(y_,{strong:!0,children:`Runs as:`}),` `,w_(e.created_by,n,r)]})]}),E_=({branch:e,client:t,mcpServerById:n=new Map,currentUser:r,userById:i=new Map,onOpenSession:a})=>{let{showError:o,showSuccess:c}=cf(),[l,u]=(0,Z.useState)([]),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(null),S=(0,Z.useCallback)(async()=>{if(t){f(!0);try{let n=await t.service(`schedules`).find({query:{branch_id:e.branch_id,$sort:{created_at:-1}}});u(Array.isArray(n)?n:n.data)}catch(e){console.error(`Failed to load schedules:`,e),o(`Failed to load schedules`)}finally{f(!1)}}},[t,e.branch_id,o]);(0,Z.useEffect)(()=>{S()},[S]),(0,Z.useEffect)(()=>{if(!t)return;let n=t.service(`schedules`),r=t=>t.branch_id===e.branch_id,i=e=>{r(e)&&u(t=>[e,...t])},a=e=>{r(e)&&u(t=>t.map(t=>t.schedule_id===e.schedule_id?e:t))},o=e=>{u(t=>t.filter(t=>t.schedule_id!==e.schedule_id))};return n.on(`created`,i),n.on(`patched`,a),n.on(`removed`,o),()=>{n.off(`created`,i),n.off(`patched`,a),n.off(`removed`,o)}},[t,e.branch_id]);let C=()=>{g(null),m(!0)},w=e=>{g(e),m(!0)},T=async e=>{if(t)try{await t.service(`schedules`).remove(e.schedule_id),c(`Schedule "${e.name}" deleted`)}catch(e){o(e instanceof Error?e.message:`Failed to delete schedule`)}},E=async e=>{if(t){x(e.schedule_id);try{await t.service(`schedules/${e.schedule_id}/run-now`).create({}),c(`Triggered "${e.name}"`)}catch(e){o(e instanceof Error?e.message:`Failed to trigger run`)}finally{x(null)}}},D=async(e,n)=>{if(t)try{await t.service(`schedules`).patch(e.schedule_id,{enabled:n})}catch(e){o(e instanceof Error?e.message:`Failed to update schedule`)}},O=(0,Z.useCallback)((e,t)=>(0,Q.jsx)(T_,{schedule:e,humanizedCron:t,userById:i,currentUser:r}),[r,i]);return(0,Q.jsxs)(`div`,{style:{padding:16,minWidth:0},children:[(0,Q.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,gap:12,marginBottom:12,minWidth:0},children:[(0,Q.jsxs)(C_,{title:`Schedules for ${e.name}`,ariaLabel:`Schedules for ${e.name}`,children:[`Schedules for `,e.name]}),(0,Q.jsx)(s,{type:`primary`,icon:(0,Q.jsx)(L,{}),onClick:C,style:{flex:`0 0 auto`},children:`New`})]}),d?(0,Q.jsx)(Ze,{}):l.length===0?(0,Q.jsx)(fe,{description:(0,Q.jsx)(`span`,{children:`No schedules yet. Schedule a prompt to fire on a cadence — hourly heartbeats, daily summaries, weekly retros.`}),children:(0,Q.jsx)(s,{type:`primary`,icon:(0,Q.jsx)(L,{}),onClick:C,children:`New schedule`})}):(0,Q.jsx)(ue,{rowKey:`schedule_id`,dataSource:l,columns:[{title:`On`,key:`enabled`,width:50,render:(e,t)=>(0,Q.jsx)(H,{title:t.enabled?`Disable schedule`:`Enable schedule`,children:(0,Q.jsx)(j,{"aria-label":`${t.enabled?`Disable`:`Enable`} schedule ${t.name}`,checked:t.enabled,onChange:e=>D(t,e),size:`small`})})},{title:`Title`,key:`name`,width:220,render:(e,t)=>{let n=O(t,x_(t.cron_expression));return(0,Q.jsxs)(G,{direction:`vertical`,size:0,style:{display:`flex`,minWidth:0},children:[(0,Q.jsx)(C_,{title:n,ariaLabel:`Schedule title: ${t.name}`,children:t.name||`Untitled schedule`}),t.description?(0,Q.jsx)(C_,{title:n,type:`secondary`,children:t.description}):null]})}},{title:`Schedule`,key:`cron`,width:240,render:(e,t)=>{let n=x_(t.cron_expression),r=O(t,n);return(0,Q.jsxs)(G,{direction:`vertical`,size:0,style:{display:`flex`,minWidth:0},children:[(0,Q.jsx)(C_,{title:r,children:n}),(0,Q.jsx)(C_,{title:r,type:`secondary`,code:!0,children:t.cron_expression})]})}},{title:`Next`,key:`next_run_at`,width:130,render:(e,t)=>(0,Q.jsx)(C_,{title:(0,Q.jsxs)(G,{direction:`vertical`,size:2,children:[(0,Q.jsx)(y_,{strong:!0,children:`Next run`}),(0,Q.jsx)(y_,{children:b_(t.next_run_at)}),(0,Q.jsx)(y_,{type:`secondary`,children:t.timezone_mode===`utc`?`UTC`:t.timezone||`local`})]}),children:b_(t.next_run_at)})},{title:``,key:`details`,width:32,render:(e,t)=>(0,Q.jsx)(H,{title:O(t,x_(t.cron_expression)),children:(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(y,{}),"aria-label":`Details for schedule ${t.name}`})})},{title:`Actions`,key:`actions`,width:150,render:(e,t)=>(0,Q.jsxs)(G,{size:2,wrap:!1,children:[(0,Q.jsx)(H,{title:`Run now`,children:(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(F,{}),loading:b===t.schedule_id,disabled:b===t.schedule_id,onClick:()=>E(t),"aria-label":`Run schedule ${t.name} now`})}),t.last_run_session_id&&a?(0,Q.jsx)(H,{title:`View last run — ${b_(t.last_run_at)}`,children:(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(pe,{}),onClick:()=>a(t.last_run_session_id),"aria-label":`View last run for schedule ${t.name}`})}):null,(0,Q.jsx)(H,{title:`View runs`,children:(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(Ge,{}),onClick:()=>v(t),"aria-label":`View runs for schedule ${t.name}`})}),(0,Q.jsx)(H,{title:`Edit`,children:(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(P,{}),onClick:()=>w(t),"aria-label":`Edit schedule ${t.name}`})}),(0,Q.jsx)(B,{title:`Delete schedule?`,description:`Are you sure you want to delete "${t.name}"?`,onConfirm:()=>T(t),okText:`Delete`,cancelText:`Cancel`,okButtonProps:{danger:!0},children:(0,Q.jsx)(H,{title:`Delete`,children:(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(re,{}),danger:!0,"aria-label":`Delete schedule ${t.name}`})})})]})}],pagination:!1,size:`small`,tableLayout:`fixed`,style:{width:`100%`}}),(0,Q.jsx)(p_,{open:p,onClose:()=>m(!1),branchId:e.branch_id,branchName:e.name,schedule:h,mcpServerById:n,client:t,onSaved:()=>S()}),(0,Q.jsx)(v_,{open:_!==null,onClose:()=>v(null),schedule:_,client:t,onOpenSession:a})]})};function D_(e){switch(e){case`running`:case`awaiting_input`:return`processing`;case`stopping`:case`awaiting_permission`:case`timed_out`:return`warning`;case`failed`:return`error`;case`completed`:return`success`;default:return`default`}}var O_=({status:e,size:t=16})=>{let{token:n}=X.useToken(),r={fontSize:t},i=t<=14?`small`:t>=24?`large`:`default`;switch(e){case vt.COMPLETED:case`completed`:return(0,Q.jsx)(st,{style:{...r,color:n.colorSuccess}});case vt.RUNNING:case`running`:return(0,Q.jsx)(Ze,{size:i});case vt.STOPPING:case`stopping`:return(0,Q.jsx)(me,{style:{...r,color:n.colorWarning}});case vt.AWAITING_PERMISSION:case`awaiting_permission`:return(0,Q.jsx)(_,{style:{...r,color:n.colorWarning}});case vt.AWAITING_INPUT:case`awaiting_input`:return(0,Q.jsx)(we,{style:{...r,color:n.colorPrimary}});case vt.FAILED:case`failed`:return(0,Q.jsx)(ut,{style:{...r,color:n.colorError}});case vt.STOPPED:return(0,Q.jsx)(M,{style:{...r,color:n.colorWarning}});case vt.TIMED_OUT:case`timed_out`:return(0,Q.jsx)(Oe,{style:{...r,color:n.colorWarning}});case`idle`:return(0,Q.jsx)(Oe,{style:{...r,color:n.colorTextDisabled}});default:return(0,Q.jsx)(Oe,{style:{...r,color:n.colorTextDisabled}})}},k_=({branch:e,sessions:t,client:n,onSessionClick:r})=>{let{token:i}=X.useToken(),{showSuccess:a,showError:o}=cf(),[s,c]=(0,Z.useState)(``),[l,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)([]),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)([]),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(new Set),T=(0,Z.useMemo)(()=>t.filter(e=>!e.archived),[t]),E=(0,Z.useRef)(n);E.current=n;let D=(0,Z.useCallback)((e,t)=>{let n=e.findIndex(e=>e.session_id===t.session_id);if(n===-1)return[t,...e];if(e[n]===t)return e;let r=[...e];return r[n]=t,r},[]),O=(0,Z.useCallback)(async()=>{let t=E.current;if(t){h(!0);try{p(await t.service(`sessions`).findAll({query:{branch_id:e.branch_id,archived:!1,$limit:1e3,$sort:{created_at:-1}}}))}catch{}finally{h(!1)}}},[e.branch_id]),k=(0,Z.useCallback)(async()=>{let t=E.current;if(t){S(!0);try{_(await t.service(`sessions`).findAll({query:{branch_id:e.branch_id,archived:!0,$limit:1e3,$sort:{created_at:-1}}})),b(!0)}catch{}finally{S(!1)}}},[e.branch_id]);(0,Z.useEffect)(()=>{p(T),h(!1),d(e.archived),_([]),b(!1),S(!1),O()},[T,O,e.archived]),(0,Z.useEffect)(()=>{l&&!y&&!x&&k()},[l,y,x,k]),(0,Z.useEffect)(()=>{if(!n)return;let t=n.service(`sessions`),r=t=>{t.branch_id===e.branch_id&&(t.archived?_(e=>D(e,t)):p(e=>D(e,t)))},i=t=>{t.branch_id===e.branch_id&&(p(e=>e.filter(e=>e.session_id!==t.session_id)),_(e=>e.filter(e=>e.session_id!==t.session_id)),t.archived?_(e=>D(e,t)):p(e=>D(e,t)))},a=t=>{t.branch_id===e.branch_id&&(p(e=>e.filter(e=>e.session_id!==t.session_id)),_(e=>e.filter(e=>e.session_id!==t.session_id)))};return t.on(`created`,r),t.on(`patched`,i),t.on(`updated`,i),t.on(`removed`,a),()=>{t.removeListener(`created`,r),t.removeListener(`patched`,i),t.removeListener(`updated`,i),t.removeListener(`removed`,a)}},[n,D,e.branch_id]);let A=(0,Z.useCallback)(async(e,t)=>{let n=E.current;if(n){w(t=>new Set(t).add(e));try{if(await n.service(`sessions`).patch(e,{archived:t,archived_reason:t?`manual`:void 0}),t){let t=f.find(t=>t.session_id===e);t?(p(t=>t.filter(t=>t.session_id!==e)),_(n=>n.some(t=>t.session_id===e)?n:[{...t,archived:!0},...n])):l&&k()}else{let t=g.find(t=>t.session_id===e);t&&p(e=>D(e,{...t,archived:!1})),_(t=>t.filter(t=>t.session_id!==e))}a(t?`Session archived`:`Session unarchived`)}catch(e){o(e instanceof Error?e.message:`Failed to update session`)}finally{w(t=>{let n=new Set(t);return n.delete(e),n})}}},[f,g,k,l,a,o,D]),M=(0,Z.useMemo)(()=>{if(!l)return f;let e=new Set,t=[];for(let n of f)e.add(n.session_id),t.push(n);for(let n of g)e.has(n.session_id)||t.push(n);return t},[f,g,l]),N=(0,Z.useMemo)(()=>{let e=M;if(l||(e=e.filter(e=>!e.archived)),s.trim()){let t=s.toLowerCase();e=e.filter(e=>em(e,{includeAgentFallback:!0}).toLowerCase().includes(t)||e.session_id.toLowerCase().includes(t)||e.agentic_tool.toLowerCase().includes(t)||e.status.toLowerCase().includes(t))}return[...e].sort((e,t)=>{let n=+(e.status===`running`||e.status===`stopping`),r=+(t.status===`running`||t.status===`stopping`);return n===r?new Date(t.created_at).getTime()-new Date(e.created_at).getTime():r-n})},[M,l,s]),P=f.length,F=g.length;return(0,Q.jsx)(`div`,{style:{width:`100%`,maxHeight:`70vh`,overflowY:`auto`},children:(0,Q.jsxs)(G,{orientation:`vertical`,size:`middle`,style:{width:`100%`},children:[(0,Q.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,gap:12,flexWrap:`wrap`},children:[(0,Q.jsx)(J,{placeholder:`Search sessions...`,prefix:(0,Q.jsx)(le,{}),value:s,onChange:e=>c(e.target.value),allowClear:!0,style:{maxWidth:300}}),(0,Q.jsxs)(G,{size:12,children:[(0,Q.jsxs)(G,{size:4,children:[(0,Q.jsx)(R,{count:P,showZero:!0,style:{backgroundColor:i.colorPrimary}}),(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12},children:`active`})]}),F>0&&(0,Q.jsxs)(G,{size:4,children:[(0,Q.jsx)(R,{count:F,showZero:!0,style:{backgroundColor:i.colorTextQuaternary}}),(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12},children:`archived`})]}),(0,Q.jsxs)(G,{size:4,children:[(0,Q.jsx)(j,{size:`small`,checked:l,onChange:d,loading:x||m,checkedChildren:(0,Q.jsx)(Ae,{}),unCheckedChildren:(0,Q.jsx)(Se,{})}),(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12},children:`Show archived`})]})]})]}),(0,Q.jsx)(ue,{columns:[{title:`Session`,key:`title`,ellipsis:!0,render:(e,t)=>(0,Q.jsxs)(G,{size:8,align:`center`,style:{minWidth:0},children:[(0,Q.jsx)(Va,{tool:t.agentic_tool,size:18}),(0,Q.jsx)(v.Link,{onClick:e=>{e.stopPropagation(),r?.(t.session_id)},style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,display:`block`},children:em(t,{includeAgentFallback:!0})}),t.archived&&(0,Q.jsx)(u,{color:`default`,style:{fontSize:10,lineHeight:`16px`,padding:`0 4px`},children:`archived`})]})},{title:`Status`,key:`status`,width:130,render:(e,t)=>(0,Q.jsxs)(G,{size:4,children:[(0,Q.jsx)(O_,{status:t.status,size:14}),(0,Q.jsx)(u,{color:D_(t.status),style:{margin:0,fontSize:11},children:t.status})]}),filters:[{text:`Idle`,value:`idle`},{text:`Running`,value:`running`},{text:`Completed`,value:`completed`},{text:`Failed`,value:`failed`},{text:`Awaiting Permission`,value:`awaiting_permission`},{text:`Awaiting Input`,value:`awaiting_input`},{text:`Timed Out`,value:`timed_out`}],onFilter:(e,t)=>t.status===e},{title:`Created`,key:`created_at`,width:150,render:(e,t)=>(0,Q.jsx)(H,{title:new Date(t.created_at).toLocaleString(),children:(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12},children:A_(t.created_at)})}),sorter:(e,t)=>new Date(e.created_at).getTime()-new Date(t.created_at).getTime()},{title:``,key:`actions`,width:40,render:(e,t)=>(0,Q.jsx)(Dh,{archived:t.archived,loading:C.has(t.session_id),tooltip:t.archived?`Archived • Click to unarchive`:`Archive session`,onToggle:e=>A(t.session_id,e)})}],dataSource:N,rowKey:`session_id`,size:`small`,pagination:N.length>20?{pageSize:20,showSizeChanger:!1}:!1,locale:{emptyText:l?`No sessions match your search`:M.length>0?`All sessions are archived. Toggle "Show archived" to see them.`:`No sessions yet`},onRow:e=>({style:{cursor:r?`pointer`:void 0,opacity:e.archived?.6:1},onClick:()=>r?.(e.session_id)})})]})})};function A_(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/1e3);if(n<60)return`just now`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);if(a<30)return`${a}d ago`;let o=Math.floor(a/30);return o<12?`${o}mo ago`:`${Math.floor(a/365)}y ago`}var j_=(0,Z.memo)(k_,(e,t)=>{let n=e.client===null!=(t.client===null);return e.branch.branch_id===t.branch.branch_id&&e.sessions===t.sessions&&!n}),M_=e=>({boardId:e?.board_id||void 0,issueUrl:e?.issue_url||``,prUrl:e?.pull_request_url||``,notes:e?.notes||``,mcpServerIds:e?.mcp_server_ids||[]}),N_=e=>{let t=e?Wt(e):null;return{displayName:t?.displayName||``,emoji:t?.emoji||``,description:e?.notes||``}},P_=(e,t)=>({permissionSource:e?.permission_source||`override`,selectedOwnerIds:t.length>0?t.map(e=>e.user_id):e?.created_by?[e.created_by]:[],othersCan:e?.others_can||`session`,othersFsAccess:e?.others_fs_access||`read`,allowSessionSharing:!!e?.dangerously_allow_session_sharing,groupGrants:[]}),F_=e=>JSON.stringify([...e].sort());function I_({branch:e,client:t,currentUser:n,open:r}){let[i,a]=(0,Z.useState)([]),[o,s]=(0,Z.useState)([]),[c,l]=(0,Z.useState)([]),[u,d]=(0,Z.useState)(!0),[f,p]=(0,Z.useState)(!0),[m,h]=(0,Z.useState)(`loading`),[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(()=>M_(e)),[E,D]=(0,Z.useState)(()=>N_(e)),[O,k]=(0,Z.useState)(()=>P_(e,[])),A=(0,Z.useRef)(null),j=(0,Z.useRef)(!1),M=(0,Z.useRef)(!1),N=(0,Z.useRef)(!1),P=(0,Z.useCallback)((e,t)=>{j.current=!0,T(n=>({...n,[e]:t}))},[]),F=(0,Z.useCallback)((e,t)=>{M.current=!0,D(n=>({...n,[e]:t}))},[]),I=(0,Z.useCallback)((e,t)=>{N.current=!0,k(n=>({...n,[e]:t}))},[]);(0,Z.useEffect)(()=>{if(!r||!e){A.current=null,j.current=!1,M.current=!1,N.current=!1;return}if(A.current!==e.branch_id){A.current=e.branch_id,j.current=!1,M.current=!1,N.current=!1,T(M_(e)),D(N_(e)),k(P_(e,[])),a([]),s([]),l([]),d(!0),h(`loading`),_(null),p(!0);return}j.current||T(M_(e)),M.current||D(N_(e)),N.current||k(t=>({...t,othersCan:e.others_can||`session`,othersFsAccess:e.others_fs_access||`read`,allowSessionSharing:!!e.dangerously_allow_session_sharing}))},[r,e]),(0,Z.useEffect)(()=>{if(!r||!t||!e)return;let n=e.branch_id,i=!1;return(async()=>{try{p(!0),x(null),h(`loading`),_(null),y(null);let r=t.service(`branches/:id/effective-access`).find({route:{id:n}}).catch(e=>(console.warn(`Failed to load effective branch access:`,e),null)),o=await t.service(`branches/:id/owners`).find({route:{id:n}});if(i)return;let c=await r;if(i)return;y(c);let u=o;if(a(u),d(!0),!N.current){let t=u.length>0?u.map(e=>e.user_id):e.created_by?[e.created_by]:[];k(e=>({...e,selectedOwnerIds:t}))}try{let e=await t.service(`users`).findAll({});i||s(e)}catch(e){i||console.warn(`Failed to load users for branch permissions:`,e)}i||p(!1);try{let[e,r]=await Promise.all([t.service(`groups`).findAll({query:{archived:!1}}),t.service(`branches/:id/group-grants`).find({route:{id:n}})]);if(i)return;l(e);let a=r.map(e=>({group_id:e.group_id,can:e.can,fs_access:e.fs_access}));h(`loaded`),_(null),N.current||k(e=>({...e,groupGrants:a}))}catch(e){i||(l([]),h(`unavailable`),_(e instanceof Error?e:Error(String(e))),console.warn(`Failed to load branch group permissions:`,e))}}catch(e){if(i)return;if(e?.code===404||e?.message?.includes(`not found`))d(!1),a([]),s([]),l([]),h(`unavailable`),_(e instanceof Error?e:Error(String(e)));else{let t=e instanceof Error?e:Error(String(e));console.error(`Failed to load branch owners:`,t),x(t),l([]),h(`unavailable`),_(t)}}i||p(!1)})(),()=>{i=!0}},[r,t,e]);let ee=e?Xt(e):!1,L=(0,Z.useMemo)(()=>{if(!e)return!1;let t=!ee&&w.notes!==(e.notes||``);return w.boardId!==(e.board_id||void 0)||w.issueUrl!==(e.issue_url||``)||w.prUrl!==(e.pull_request_url||``)||t||F_(w.mcpServerIds)!==F_(e.mcp_server_ids||[])},[e,w,ee]),te=(0,Z.useMemo)(()=>{if(!e||!ee)return!1;let t=Wt(e);return t?E.displayName.trim()!==t.displayName||E.emoji!==(t.emoji||``)||E.description.trim()!==(e.notes||``):!1},[e,E,ee]),R=(0,Z.useMemo)(()=>{if(!e||!u)return!1;let t=i.map(e=>e.user_id);return O.selectedOwnerIds.length!==t.length||O.selectedOwnerIds.some(e=>!t.includes(e))},[e,u,i,O.selectedOwnerIds]),ne=(0,Z.useMemo)(()=>!e||!u?!1:O.othersCan!==(e.others_can||`session`)||O.othersFsAccess!==(e.others_fs_access||`read`)||O.allowSessionSharing!==!!e.dangerously_allow_session_sharing||O.permissionSource!==(e.permission_source||`override`),[e,u,O]),z=!!(e&&u&&m===`loaded`&&N.current),B=R||ne||z,V=L||te||B,H=n?.user_id,re=mt(n?.role,bt.ADMIN),ie=mt(n?.role,bt.SUPERADMIN),U=i.some(e=>e.user_id===H),ae=e?.created_by===H,oe=re||v?.can===`all`||U||e?.others_can===`all`||!u&&ae,se=u&&(re||f||U),ce=f?ie:!u||ie||U,le=ie||!f&&U,ue=(0,Z.useCallback)(()=>{T(M_(e)),D(N_(e)),k(P_(e,i)),j.current=!1,M.current=!1,N.current=!1},[e,i]);return{general:w,setGeneral:P,generalChanged:L,assistant:E,setAssistant:F,assistantChanged:te,permissions:O,setPermissions:I,permissionsChanged:B,owners:i,allUsers:o,allGroups:c,groupGrantsStatus:m,groupGrantsError:g,rbacEnabled:u,loadingOwners:f,canViewPermissions:se,ownersLoadError:b,canEditGeneral:ce,canEditPermissions:le,canControlEnvironment:oe,hasChanges:V,saving:S,save:(0,Z.useCallback)(async()=>{if(!e||!t)return{ok:!1,error:Error(`Modal not ready`)};C(!0);try{let n=i.map(e=>e.user_id),r=O.selectedOwnerIds.filter(e=>!n.includes(e)),o=n.filter(e=>!O.selectedOwnerIds.includes(e));if(u&&R&&O.selectedOwnerIds.length===0)throw Error(`At least one owner is required`);if(u&&O.permissionSource===`override`&&O.othersCan===`none`&&O.selectedOwnerIds.length!==1)throw Error(`Private branches must have exactly one private user`);if(u&&R&&le)for(let n of r)await t.service(`branches/:id/owners`).create({user_id:n},{route:{id:e.branch_id}});let s={};if(L&&ce&&(s.board_id=w.boardId||void 0,s.issue_url=w.issueUrl.trim()===``?null:w.issueUrl,s.pull_request_url=w.prUrl.trim()===``?null:w.prUrl,ee||(s.notes=w.notes.trim()===``?null:w.notes),F_(w.mcpServerIds)!==F_(e.mcp_server_ids||[])&&(s.mcp_server_ids=w.mcpServerIds)),te&&ee&&ce){let t=Wt(e);t&&(s.custom_context={assistant:{...t,kind:`assistant`,displayName:E.displayName.trim(),emoji:E.emoji||void 0}},s.notes=E.description.trim()||null)}if(u&&ne&&le&&(s.others_can=O.othersCan,s.others_fs_access=O.othersFsAccess,s.dangerously_allow_session_sharing=O.allowSessionSharing,s.permission_source=O.permissionSource),Object.keys(s).length>0&&await t.service(`branches`).patch(e.branch_id,s),u&&le&&m===`loaded`){let n=await t.service(`branches/:id/group-grants`).find({route:{id:e.branch_id}}),r=O.groupGrants,i=new Set(r.map(e=>e.group_id));for(let i of r){let r=n.find(e=>e.group_id===i.group_id);(!r||r.can!==i.can||(r.fs_access||void 0)!==(i.fs_access||void 0))&&await t.service(`branches/:id/group-grants`).create({group_id:i.group_id,can:i.can,fs_access:i.fs_access},{route:{id:e.branch_id}})}for(let r of n)i.has(r.group_id)||await t.service(`branches/:id/group-grants`).remove(r.group_id,{route:{id:e.branch_id}})}if(u&&R&&le)for(let n of o)await t.service(`branches/:id/owners`).remove(n,{route:{id:e.branch_id}});if(te&&ee&&ce&&e.board_id){let n=Wt(e);if(n&&E.emoji!==(n.emoji||``))try{await t.service(`boards`).patch(e.board_id,{icon:E.emoji||`🤖`})}catch(e){console.error(`Failed to update board icon:`,e)}}if(u&&B)try{let n=await t.service(`branches/:id/owners`).find({route:{id:e.branch_id}});a(n),k(e=>({...e,selectedOwnerIds:n.map(e=>e.user_id)}))}catch(e){console.error(`Failed to reload owners after save:`,e)}return j.current=!1,M.current=!1,N.current=!1,{ok:!0}}catch(e){return{ok:!1,error:e instanceof Error?e:Error(String(e))}}finally{C(!1)}},[e,t,u,R,ne,B,le,m,i,O,L,ce,w,ee,te,E]),reset:ue}}var L_=({open:e,onClose:t,branch:n,repo:r,sessions:i,boardObjects:o=[],client:c,currentUser:l,onUpdateBranch:u,onUpdateRepo:d,onArchiveOrDelete:f,onOpenSettings:p,onSessionClick:h,onExecuteScheduleNow:g,defaultTab:_})=>{let v=jc(Ic),y=jc(Uc),{token:b}=X.useToken(),{showSuccess:x,showError:S}=cf(),[C,w]=(0,Z.useState)(`general`),T=I_({branch:n,client:c,currentUser:l,open:e}),E=(0,Z.useMemo)(()=>new Map(T.allUsers.map(e=>[e.user_id,e])),[T.allUsers]),D=v.get(T.general.boardId||n?.board_id||``);(0,Z.useEffect)(()=>{e&&w(_||`general`)},[e,_]),(0,Z.useEffect)(()=>{T.ownersLoadError&&S(`Failed to load branch permissions: ${T.ownersLoadError.message}`)},[T.ownersLoadError,S]);let O=n?Xt(n):!1,k=(0,Z.useMemo)(()=>n?Wt(n):null,[n]);if(!n||!r)return null;let A=O?`Assistant: ${k?.displayName??n.name}`:`Branch: ${n.name}`,j=async()=>{let e=await T.save();e.ok?(x(O?`Assistant updated`:`Branch updated`),t()):S(e.error.message||`Failed to save changes`)},M=[...O?[{key:`assistant`,label:`Assistant`,children:(0,Q.jsx)(bm,{branch:n,canEdit:T.canEditGeneral,state:T.assistant,setField:T.setAssistant})}]:[],{key:`general`,label:`General`,children:(0,Q.jsx)(Ph,{branch:n,repo:r,sessions:i,boards:Ff(v),mcpServers:Ff(y),canEdit:T.canEditGeneral,state:T.general,setField:T.setGeneral,onArchiveOrDelete:f})},{key:`sessions`,label:(0,Q.jsxs)(`span`,{children:[`Sessions`,` `,(0,Q.jsx)(R,{count:i.length,showZero:!0,size:`small`,style:{backgroundColor:b.colorPrimaryBgHover}})]}),children:(0,Q.jsx)(j_,{branch:n,sessions:i,client:c,onSessionClick:e=>{h?.(e),t()}})},{key:`environment`,label:`Environment`,children:(0,Q.jsx)(Zm,{branch:n,repo:r,client:c,onUpdateRepo:d,onUpdateBranch:u,canControlEnvironment:T.canControlEnvironment})},{key:`files`,label:`Files`,children:(0,Q.jsx)(wh,{branch:n,client:c})},...T.canViewPermissions?[{key:`permissions`,label:`Permissions`,children:(0,Q.jsx)(tg,{loadingOwners:T.loadingOwners,canEdit:T.canEditPermissions,allUsers:T.allUsers,allGroups:T.allGroups,groupGrantsStatus:T.groupGrantsStatus,groupGrantsError:T.groupGrantsError,currentUser:l,client:c,board:D,state:T.permissions,setField:T.setPermissions,ownersLoadError:T.ownersLoadError})}]:[],{key:`schedule`,label:`Schedules`,children:(0,Q.jsx)(E_,{branch:n,client:c,mcpServerById:y,currentUser:l,userById:E,onOpenSession:e=>{h?.(e),t()}})},...O?[{key:`knowledge`,label:`Knowledge`,children:(0,Q.jsx)(Vh,{branch:n,client:c,canEdit:T.canEditGeneral})}]:[]],N=(T.canEditGeneral||T.canEditPermissions)&&T.hasChanges&&!T.saving;return(0,Q.jsx)(a,{title:A,open:e,onCancel:t,footer:(0,Q.jsxs)(G,{children:[T.hasChanges&&(0,Q.jsx)(s,{onClick:T.reset,disabled:T.saving,"aria-label":`Reset changes`,children:`Reset`}),(0,Q.jsx)(s,{onClick:t,disabled:T.saving,children:`Close`}),(0,Q.jsx)(s,{type:`primary`,onClick:j,loading:T.saving,disabled:!N,"aria-label":`Save changes`,children:`Save Changes`})]}),width:900,mask:{closable:!1},styles:{body:{padding:0,maxHeight:`80vh`,overflowY:`auto`}},children:(0,Q.jsx)(m,{activeKey:C,onChange:e=>w(e),items:M})})},R_=(0,Z.lazy)(()=>on(()=>Promise.resolve().then(()=>bo).then(e=>({default:e.ParticleBackground})),void 0));function z_(){throw Error(`Crash test: this is a synthetic render-phase error from About → Crash Test. If you're seeing the friendly crash screen, the global ErrorBoundary works.`)}var B_=({client:e,connected:t,connectionError:n,isAdmin:r=!1})=>{let i=nu(),a=Ql({baseUrl:`/ui/`,pathname:typeof window>`u`?`/`:window.location.pathname}),[o,c]=(0,Z.useState)(``),[l,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(!1),{capturedSha:m}=Vl();return(0,Z.useEffect)(()=>{window.AGOR_DAEMON_URL?c(`Runtime injection (window.AGOR_DAEMON_URL)`):a.mode===`bundled-daemon-ui`?c(`Bundled UI (same-origin daemon)`):a.mode===`canonical-dev-deeplink`?c(`Dev canonical /ui deep link (daemon port)`):c(`Dev mode (explicit port)`),e&&e.service(`health`).find().then(e=>{d(e)}).catch(e=>console.error(`Failed to fetch health info:`,e))},[e,a.mode]),(0,Q.jsxs)(`div`,{style:{position:`relative`,minHeight:500,padding:`24px 0`},children:[(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(R_,{})}),(0,Q.jsx)(`div`,{style:{position:`relative`,zIndex:1},children:(0,Q.jsxs)(G,{orientation:`vertical`,size:`large`,style:{width:`100%`},children:[(0,Q.jsx)(g,{title:`Connection Info`,variant:`borderless`,style:{maxWidth:800,margin:`0 auto`},children:(0,Q.jsxs)(q,{column:1,bordered:!0,size:`small`,children:[(0,Q.jsx)(q.Item,{label:`Status`,children:t?(0,Q.jsx)(`span`,{style:{color:`#52c41a`},children:`✓ Connected`}):(0,Q.jsx)(`span`,{style:{color:`#ff4d4f`},children:`✗ Disconnected`})}),n&&(0,Q.jsx)(q.Item,{label:`Error`,children:(0,Q.jsx)(v.Text,{type:`danger`,children:n})}),l?.version&&(0,Q.jsx)(q.Item,{label:`Version`,children:l.version}),l?.buildSha&&(0,Q.jsxs)(q.Item,{label:`Daemon Build`,children:[(0,Q.jsx)(`code`,{children:l.buildSha}),l.builtAt&&(0,Q.jsxs)(v.Text,{type:`secondary`,style:{marginLeft:8},children:[`built `,l.builtAt]})]}),m&&(0,Q.jsxs)(q.Item,{label:`Tab Captured`,children:[(0,Q.jsx)(`code`,{children:m}),Sf(m,l?.buildSha)&&(0,Q.jsx)(v.Text,{type:`warning`,style:{marginLeft:8},children:`⚠️ out of sync — refresh to load the latest UI`})]}),l?.encryption&&(0,Q.jsx)(q.Item,{label:`Encryption`,children:l.encryption.enabled?(0,Q.jsxs)(`span`,{style:{color:`#52c41a`},children:[`🔐 Enabled (`,l.encryption.method,`)`]}):(0,Q.jsx)(`span`,{style:{color:`#faad14`},children:`🔓 Disabled`})})]})}),r&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(g,{title:`Daemon Config (Admin Only)`,variant:`borderless`,style:{maxWidth:800,margin:`0 auto`},children:(0,Q.jsxs)(q,{column:1,bordered:!0,size:`small`,children:[(0,Q.jsx)(q.Item,{label:`Daemon URL`,children:(0,Q.jsx)(`code`,{children:i})}),(0,Q.jsx)(q.Item,{label:`Detection Method`,children:o}),l?.database&&(typeof l.database==`string`?(0,Q.jsx)(q.Item,{label:`Database`,children:(0,Q.jsx)(`code`,{children:l.database})}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q.Item,{label:`Database Type`,children:l.database.dialect===`postgresql`?(0,Q.jsx)(`span`,{children:`🐘 PostgreSQL`}):(0,Q.jsx)(`span`,{children:`💾 SQLite`})}),l.database.dialect===`postgresql`&&l.database.url&&(0,Q.jsx)(q.Item,{label:`Database URL`,children:(0,Q.jsx)(`code`,{children:l.database.url})}),l.database.dialect===`sqlite`&&l.database.path&&(0,Q.jsx)(q.Item,{label:`Database Path`,children:(0,Q.jsx)(`code`,{children:l.database.path})})]})),l?.auth&&(0,Q.jsx)(q.Item,{label:`Authentication`,children:`🔐 Required`}),l?.execution&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q.Item,{label:`Branch RBAC`,children:l.execution.branchRbac?(0,Q.jsx)(`span`,{style:{color:`#52c41a`},children:`🛡️ Enabled`}):(0,Q.jsx)(`span`,{style:{color:`#faad14`},children:`⚠️ Disabled (open access)`})}),(0,Q.jsxs)(q.Item,{label:`Unix User Mode`,children:[(0,Q.jsx)(`code`,{children:l.execution.unixUserMode}),l.execution.unixUserMode===`simple`&&(0,Q.jsx)(v.Text,{type:`secondary`,style:{marginLeft:8},children:`(no OS isolation)`}),l.execution.unixUserMode===`insulated`&&(0,Q.jsx)(v.Text,{type:`secondary`,style:{marginLeft:8},children:`(branch groups)`}),l.execution.unixUserMode===`strict`&&(0,Q.jsx)(v.Text,{type:`secondary`,style:{marginLeft:8},children:`(per-user impersonation)`})]})]})]})}),l?.security&&(0,Q.jsxs)(g,{title:`Security Headers (Admin Only)`,variant:`borderless`,style:{maxWidth:800,margin:`0 auto`},children:[(0,Q.jsxs)(q,{column:1,bordered:!0,size:`small`,children:[(0,Q.jsxs)(q.Item,{label:`CSP`,children:[l.security.csp.enabled?l.security.csp.reportOnly?(0,Q.jsx)(u,{color:`warning`,children:`Report-Only`}):(0,Q.jsx)(u,{color:`success`,children:`Enforced`}):(0,Q.jsx)(u,{color:`error`,children:`Disabled`}),l.security.csp.reportUri&&(0,Q.jsxs)(v.Text,{type:`secondary`,style:{marginLeft:8},children:[`Reports → `,(0,Q.jsx)(`code`,{children:l.security.csp.reportUri})]})]}),(0,Q.jsx)(q.Item,{label:`CSP Header`,children:(0,Q.jsx)(H,{title:`Full Content-Security-Policy header the daemon is emitting. If a resource is blocked, check which directive matches.`,children:(0,Q.jsx)(v.Paragraph,{copyable:{text:l.security.csp.header},style:{margin:0,fontFamily:`monospace`,fontSize:12,whiteSpace:`pre-wrap`,wordBreak:`break-all`},children:l.security.csp.header})})}),(0,Q.jsxs)(q.Item,{label:`CORS Mode`,children:[(0,Q.jsx)(`code`,{children:l.security.cors.mode}),l.security.cors.mode===`wildcard`&&(0,Q.jsx)(v.Text,{type:`danger`,style:{marginLeft:8},children:`⚠️ Any origin accepted`}),l.security.cors.mode===`reflect`&&(0,Q.jsx)(v.Text,{type:`warning`,style:{marginLeft:8},children:`⚠️ Origin header echoed`})]}),(0,Q.jsx)(q.Item,{label:`CORS Credentials`,children:l.security.cors.credentials?(0,Q.jsx)(u,{color:`success`,children:`Enabled`}):(0,Q.jsx)(u,{color:`default`,children:`Disabled`})}),(0,Q.jsxs)(q.Item,{label:`Allowed Origins`,children:[l.security.cors.originCount,` configured`,` `,(0,Q.jsxs)(v.Text,{type:`secondary`,children:[`(+ localhost dev ports`,l.security.cors.allowSandpack&&`, + Sandpack`,`)`]})]})]}),(0,Q.jsxs)(v.Paragraph,{type:`secondary`,style:{marginTop:12,marginBottom:0,fontSize:12},children:[`Configure via `,(0,Q.jsx)(`code`,{children:`security.csp`}),` and `,(0,Q.jsx)(`code`,{children:`security.cors`}),` in`,` `,(0,Q.jsx)(`code`,{children:`~/.agor/config.yaml`}),`. See`,` `,(0,Q.jsx)(`a`,{href:`https://github.com/preset-io/agor/blob/main/context/concepts/security.md`,target:`_blank`,rel:`noopener noreferrer`,children:`context/concepts/security.md`}),`.`]})]}),(0,Q.jsx)(g,{title:`System Debug Info (Admin Only)`,variant:`borderless`,style:{maxWidth:800,margin:`0 auto`},children:(0,Q.jsxs)(q,{column:1,bordered:!0,size:`small`,children:[(0,Q.jsx)(q.Item,{label:`Mode`,children:a.mode===`bundled-daemon-ui`?(0,Q.jsx)(`span`,{children:`npm package (agor-live)`}):(0,Q.jsx)(`span`,{children:`Source code (dev)`})}),(0,Q.jsx)(q.Item,{label:`URL Runtime`,children:(0,Q.jsx)(`code`,{children:a.mode})}),(0,Q.jsx)(q.Item,{label:`UI Location`,children:(0,Q.jsx)(`code`,{children:window.location.href})}),(0,Q.jsx)(q.Item,{label:`Origin`,children:(0,Q.jsx)(`code`,{children:window.location.origin})}),(0,Q.jsx)(q.Item,{label:`Path`,children:(0,Q.jsx)(`code`,{children:window.location.pathname})}),(0,Q.jsxs)(q.Item,{label:`Crash Test`,children:[(0,Q.jsxs)(G,{children:[(0,Q.jsx)(s,{danger:!0,size:`small`,onClick:()=>p(!0),children:`Trigger render crash`}),(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12},children:`Throws during render to verify the global error boundary. Reload to recover.`})]}),f&&(0,Q.jsx)(z_,{})]})]})})]}),(0,Q.jsx)(g,{variant:`borderless`,style:{maxWidth:800,margin:`0 auto`,textAlign:`center`},children:(0,Q.jsxs)(G,{size:`large`,children:[(0,Q.jsx)(`a`,{href:`https://github.com/preset-io/agor`,target:`_blank`,rel:`noopener noreferrer`,children:`GitHub`}),(0,Q.jsx)(`a`,{href:`https://agor.live`,target:`_blank`,rel:`noopener noreferrer`,children:`Documentation`})]})})]})})]})},{Text:V_,Link:H_}=v,U_={"claude-code":[{field:`ANTHROPIC_API_KEY`,label:`Anthropic API Key`,description:`(pay-as-you-go / Console)`,placeholder:`sk-ant-api03-...`,docUrl:`https://platform.claude.com/settings/keys`,helper:(0,Q.jsx)(V_,{type:`secondary`,style:{fontSize:12},children:`If you use a Claude subscription, use the Claude Subscription Token below instead.`})},{field:`CLAUDE_CODE_OAUTH_TOKEN`,label:`Claude Subscription Token`,description:`(Pro / Max plan)`,placeholder:`sk-ant-oat01-...`,docUrl:`https://docs.claude.com/en/docs/claude-code/setup`},{field:`ANTHROPIC_AUTH_TOKEN`,label:`Anthropic Auth Token`,description:`(optional — proxy / enterprise)`,placeholder:`token...`},{field:`ANTHROPIC_BASE_URL`,label:`Anthropic Base URL`,description:`(optional — gateway / proxy)`,placeholder:`https://api.anthropic.com`,type:`text`}],codex:[{field:`OPENAI_API_KEY`,label:`OpenAI API Key`,description:`(Codex)`,placeholder:`sk-proj-...`,docUrl:`https://platform.openai.com/api-keys`,helper:(0,Q.jsxs)(V_,{type:`secondary`,style:{fontSize:12},children:[`Alternative: on the machine Agor runs sessions on, run`,` `,(0,Q.jsx)(V_,{code:!0,style:{fontSize:12},children:`codex login --device-auth`}),` `,`to use Codex CLI account auth without storing an OpenAI key in Agor.`,` `,(0,Q.jsx)(H_,{href:`https://agor.live/guide/extended-install#authentication`,target:`_blank`,children:`Learn more →`})]})},{field:`OPENAI_BASE_URL`,label:`OpenAI Base URL`,description:`(optional — gateway / proxy / self-hosted)`,placeholder:`https://api.openai.com/v1`,type:`text`}],gemini:[{field:`GEMINI_API_KEY`,label:`Gemini API Key`,placeholder:`AIza...`,docUrl:`https://aistudio.google.com/app/apikey`}],copilot:[{field:`COPILOT_GITHUB_TOKEN`,label:`GitHub Token`,description:`(Copilot)`,placeholder:`ghp_...`,docUrl:`https://github.com/settings/tokens`}],cursor:[{field:`CURSOR_API_KEY`,label:`Cursor API Key`,description:`(experimental SDK)`,placeholder:`key_...`,docUrl:`https://cursor.com/dashboard/integrations`}],opencode:[],"claude-code-cli":[{field:`ANTHROPIC_API_KEY`,label:`Anthropic API Key`,description:`(pay-as-you-go / Console)`,placeholder:`sk-ant-api03-...`,docUrl:`https://platform.claude.com/settings/keys`,helper:(0,Q.jsx)(V_,{type:`secondary`,style:{fontSize:12},children:`If you use a Claude subscription, use the Claude Subscription Token below instead.`})},{field:`CLAUDE_CODE_OAUTH_TOKEN`,label:`Claude Subscription Token`,description:`(Pro / Max plan)`,placeholder:`sk-ant-oat01-...`,docUrl:`https://docs.claude.com/en/docs/claude-code/setup`}]},W_=({tool:e,fieldStatus:t,onSave:n,onClear:r,saving:i={},disabled:a=!1,fields:o,publicValues:c})=>{let{token:l}=X.useToken(),[u,d]=(0,Z.useState)({}),f=o??U_[e]??[],p=async e=>{let t=u[e]?.trim();t&&(await n(e,t),d(t=>({...t,[e]:``})))},m=n=>{let{field:o,label:f,description:m,placeholder:h,docUrl:g,helper:_,type:v=`password`}=n,b=!!t[o],x=v===`password`?J.Password:J,S=v===`text`&&b?c?.[o]:void 0;return(0,Q.jsx)(`div`,{style:{marginBottom:l.marginLG},children:(0,Q.jsxs)(G,{orientation:`vertical`,size:`small`,style:{width:`100%`},children:[(0,Q.jsxs)(G,{wrap:!0,children:[(0,Q.jsx)(V_,{strong:!0,children:f}),m&&(0,Q.jsx)(V_,{type:`secondary`,children:m}),(0,Q.jsx)(H,{title:(0,Q.jsxs)(`span`,{children:[`Passed to the `,e,` SDK as `,(0,Q.jsx)(`code`,{children:o})]}),children:(0,Q.jsx)(y,{style:{color:l.colorTextSecondary,cursor:`help`}})}),b?(0,Q.jsx)(Aa,{icon:(0,Q.jsx)(st,{}),color:`success`,children:`Set`}):(0,Q.jsx)(Aa,{icon:(0,Q.jsx)(ut,{}),color:`default`,children:`Not Set`})]}),b?(0,Q.jsxs)(G,{wrap:!0,size:`small`,style:{width:`100%`},children:[S&&(0,Q.jsx)(V_,{code:!0,copyable:!0,style:{fontSize:l.fontSizeSM,wordBreak:`break-all`},children:S}),(0,Q.jsx)(s,{danger:!0,icon:(0,Q.jsx)(re,{}),onClick:()=>r(o),loading:i[o],disabled:a,children:`Clear`})]}):(0,Q.jsxs)(G.Compact,{style:{width:`100%`},children:[(0,Q.jsx)(x,{placeholder:h,value:u[o]||``,onChange:e=>d(t=>({...t,[o]:e.target.value})),onPressEnter:()=>p(o),style:{flex:1},disabled:a}),(0,Q.jsx)(s,{type:`primary`,onClick:()=>p(o),loading:i[o],disabled:a||!u[o]?.trim(),children:`Save`})]}),g&&(0,Q.jsxs)(V_,{type:`secondary`,style:{fontSize:l.fontSizeSM},children:[`Get your key at:`,` `,(0,Q.jsx)(H_,{href:g,target:`_blank`,children:g})]}),_,o===`CLAUDE_CODE_OAUTH_TOKEN`&&!b&&(0,Q.jsxs)(V_,{type:`secondary`,style:{fontSize:l.fontSizeSM},children:[`On the machine Agor runs sessions on, run`,` `,(0,Q.jsx)(V_,{code:!0,style:{fontSize:l.fontSizeSM},children:`claude setup-token`}),` `,`and paste the printed token here. This uses Claude subscription auth instead of a raw API key.`]}),o===`ANTHROPIC_AUTH_TOKEN`&&(0,Q.jsx)(V_,{type:`secondary`,style:{fontSize:l.fontSizeSM},children:`Alternative to the API key for token-based auth (AWS Bedrock, OAuth proxies, custom auth flows). Leave empty unless your gateway requires it.`}),o===`ANTHROPIC_BASE_URL`&&(0,Q.jsx)(V_,{type:`secondary`,style:{fontSize:l.fontSizeSM},children:`Override only when routing Claude Code through an internal gateway, proxy, or regional endpoint. Leave empty to use Anthropic's default API.`}),o===`OPENAI_BASE_URL`&&(0,Q.jsx)(V_,{type:`secondary`,style:{fontSize:l.fontSizeSM},children:`Point Codex at any OpenAI-compatible endpoint (internal gateway, corporate proxy, or a localhost server like vLLM / Ollama / LM Studio). Leave empty to use OpenAI's default API. The OpenAI API Key above is sent as the bearer token.`}),o===`COPILOT_GITHUB_TOKEN`&&(0,Q.jsxs)(V_,{type:`secondary`,style:{fontSize:l.fontSizeSM},children:[`Falls back to`,` `,(0,Q.jsx)(V_,{code:!0,style:{fontSize:l.fontSizeSM},children:`GH_TOKEN`}),` `,`/`,` `,(0,Q.jsx)(V_,{code:!0,style:{fontSize:l.fontSizeSM},children:`GITHUB_TOKEN`}),` `,`if unset. Set this explicitly to point Copilot at a different account (e.g. one with an active Copilot subscription) or to limit blast radius — the global git token often has broader scopes than Copilot needs.`]})]})},o)};return f.length===0?null:(0,Q.jsx)(G,{orientation:`vertical`,size:`large`,style:{width:`100%`},children:f.map(e=>m(e))})},G_={"claude-code":U_[`claude-code`].filter(e=>e.field!==`CLAUDE_CODE_OAUTH_TOKEN`),"claude-code-cli":U_[`claude-code-cli`].filter(e=>e.field!==`CLAUDE_CODE_OAUTH_TOKEN`),codex:U_.codex.filter(e=>e.field!==`OPENAI_BASE_URL`),gemini:U_.gemini,copilot:U_.copilot,cursor:U_.cursor,opencode:U_.opencode},K_=({tool:e,fieldStatus:t,keysError:n,savingKeys:r,onSave:i,onClear:a,onClearError:o})=>{let{token:s}=X.useToken();return(0,Q.jsxs)(`div`,{style:{paddingTop:s.paddingMD},children:[(0,Q.jsx)(z,{title:(0,Q.jsxs)(`span`,{children:[`This is the `,(0,Q.jsx)(`strong`,{children:`global API key`}),` fallback for users without their own credentials. CLI login alternatives are configured on the machine Agor runs sessions on.`,` `,(0,Q.jsx)(`a`,{href:`https://agor.live/guide/extended-install#authentication`,target:`_blank`,rel:`noopener noreferrer`,children:`Learn more →`})]}),type:`info`,showIcon:!0,style:{marginBottom:s.marginLG}}),n&&(0,Q.jsx)(z,{title:n,type:`error`,icon:(0,Q.jsx)(Ve,{}),showIcon:!0,closable:!0,onClose:o,style:{marginBottom:s.marginLG}}),(0,Q.jsx)(W_,{tool:e,fields:G_[e],fieldStatus:t,onSave:i,onClear:a,saving:r})]})},q_=({client:e})=>{let{token:t}=X.useToken(),{showSuccess:n,showError:r}=cf(),[i,a]=(0,Z.useState)(!0),[o,c]=(0,Z.useState)({}),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)({}),[p]=Y.useForm(),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(`http://localhost:4096`),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(!0);(0,Z.useEffect)(()=>{e&&(async()=>{try{a(!0),u(null);let t=await e.service(`config`).get(`credentials`),n={};for(let e of Object.values(G_))for(let{field:r}of e)n[r]=!!t?.[r];f(n)}catch(e){console.error(`Failed to load API keys:`,e),u(e instanceof Error?e.message:`Failed to load API keys`)}finally{a(!1)}})()},[e]),(0,Z.useEffect)(()=>{e&&(async()=>{try{T(!0);let t=await e.service(`config`).get(`opencode`);t&&(g(t.enabled||!1),v(t.serverUrl||`http://localhost:4096`))}catch(e){console.error(`Failed to load OpenCode config:`,e)}finally{T(!1)}})()},[e]);let E=async(t,n)=>{if(e)try{c(e=>({...e,[t]:!0})),u(null),await e.service(`config`).patch(null,{credentials:{[t]:n}}),f(e=>({...e,[t]:!0}))}catch(e){throw console.error(`Failed to save ${t}:`,e),u(e instanceof Error?e.message:`Failed to save ${t}`),e}finally{c(e=>({...e,[t]:!1}))}},D=async t=>{if(e)try{c(e=>({...e,[t]:!0})),u(null),await e.service(`config`).patch(null,{credentials:{[t]:null}}),f(e=>({...e,[t]:!1}))}catch(e){throw console.error(`Failed to clear ${t}:`,e),u(e instanceof Error?e.message:`Failed to clear ${t}`),e}finally{c(e=>({...e,[t]:!1}))}};return i||w?(0,Q.jsx)(`div`,{style:{textAlign:`center`,padding:t.paddingLG},children:(0,Q.jsx)(Ze,{size:`large`})}):(0,Q.jsx)(`div`,{style:{padding:t.paddingMD},children:(0,Q.jsx)(m,{defaultActiveKey:`claude-code`,items:[{key:`claude-code`,label:`Claude Code`,children:(0,Q.jsx)(K_,{tool:`claude-code`,fieldStatus:d,keysError:l,savingKeys:o,onSave:E,onClear:D,onClearError:()=>u(null)})},{key:`codex`,label:`Codex`,children:(0,Q.jsx)(K_,{tool:`codex`,fieldStatus:d,keysError:l,savingKeys:o,onSave:E,onClear:D,onClearError:()=>u(null)})},{key:`gemini`,label:`Gemini`,children:(0,Q.jsx)(K_,{tool:`gemini`,fieldStatus:d,keysError:l,savingKeys:o,onSave:E,onClear:D,onClearError:()=>u(null)})},{key:`copilot`,label:`GitHub Copilot`,children:(0,Q.jsx)(K_,{tool:`copilot`,fieldStatus:d,keysError:l,savingKeys:o,onSave:E,onClear:D,onClearError:()=>u(null)})},{key:`cursor`,label:`Cursor SDK`,children:(0,Q.jsx)(K_,{tool:`cursor`,fieldStatus:d,keysError:l,savingKeys:o,onSave:E,onClear:D,onClearError:()=>u(null)})},{key:`opencode`,label:`OpenCode`,children:(0,Q.jsxs)(`div`,{style:{paddingTop:t.paddingMD},children:[(0,Q.jsx)(z,{title:`OpenCode.ai Integration`,description:(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`p`,{style:{marginBottom:t.marginXS},children:[`OpenCode provides access to `,(0,Q.jsx)(`strong`,{children:`75+ LLM providers`}),` including local models, custom endpoints, and privacy-focused options.`]}),(0,Q.jsxs)(`p`,{style:{marginBottom:0},children:[`To use OpenCode sessions, you must run the OpenCode server separately.`,` `,(0,Q.jsx)(`a`,{href:`https://agor.live/guide/opencode-setup`,target:`_blank`,rel:`noopener noreferrer`,children:`Setup Guide →`})]})]}),type:`info`,icon:(0,Q.jsx)(y,{}),showIcon:!0,style:{marginBottom:t.marginLG}}),(0,Q.jsxs)(Y,{form:p,layout:`vertical`,children:[(0,Q.jsx)(Y.Item,{label:`Enable OpenCode Integration`,children:(0,Q.jsxs)(G,{children:[(0,Q.jsx)(j,{checked:h,onChange:g,checkedChildren:`Enabled`,unCheckedChildren:`Disabled`}),(0,Q.jsx)(`span`,{style:{color:t.colorTextSecondary,fontSize:12},children:`Enable OpenCode as an agentic tool option in Agor`})]})}),h&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y.Item,{label:`OpenCode Server URL`,help:`URL where OpenCode server is running (started with 'opencode serve')`,children:(0,Q.jsxs)(G.Compact,{style:{width:`100%`},children:[(0,Q.jsx)(J,{placeholder:`http://localhost:4096`,value:_,onChange:e=>v(e.target.value)}),(0,Q.jsx)(H,{title:`Test connection to OpenCode server`,children:(0,Q.jsx)(s,{loading:S,icon:S?(0,Q.jsx)(me,{}):void 0,onClick:async()=>{if(e){C(!0);try{x((await e.service(`opencode/health`).find()).connected===!0)}catch(e){console.error(`[OpenCode] Health check error:`,e),x(!1)}finally{C(!1)}}},children:`Test`})})]})}),b!==null&&(0,Q.jsx)(z,{title:b?(0,Q.jsxs)(G,{children:[(0,Q.jsx)(st,{style:{color:t.colorSuccess}}),(0,Q.jsx)(`span`,{children:`Connected to OpenCode server`})]}):(0,Q.jsxs)(G,{children:[(0,Q.jsx)(ut,{style:{color:t.colorError}}),(0,Q.jsx)(`span`,{children:`Cannot connect to OpenCode server`})]}),type:b?`success`:`error`,showIcon:!1,style:{marginBottom:t.marginLG}}),b===!1&&(0,Q.jsx)(z,{title:`Server Not Running`,description:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{style:{marginBottom:t.marginXS},children:`Start OpenCode server in a separate terminal:`}),(0,Q.jsx)(`pre`,{style:{background:t.colorBgContainer,padding:t.paddingXS,borderRadius:t.borderRadius,border:`1px solid ${t.colorBorder}`,overflowX:`auto`,marginBottom:t.marginXS,fontSize:12},children:`opencode serve --port 4096`}),(0,Q.jsxs)(`p`,{style:{marginBottom:0,fontSize:12},children:[`Don't have OpenCode?`,` `,(0,Q.jsx)(`a`,{href:`https://opencode.ai/docs`,target:`_blank`,rel:`noopener noreferrer`,children:`Installation Guide →`})]})]}),type:`warning`,showIcon:!0,style:{marginBottom:t.marginLG}}),b===!0&&(0,Q.jsx)(z,{title:`Ready to use!`,description:`You can now create sessions with OpenCode as the agentic tool.`,type:`success`,showIcon:!0,style:{marginBottom:t.marginLG}})]}),(0,Q.jsx)(Y.Item,{children:(0,Q.jsx)(s,{type:`primary`,onClick:async()=>{if(e)try{await e.service(`config`).patch(null,{opencode:{enabled:h,serverUrl:_}}),n(`OpenCode settings saved successfully`)}catch(e){r(e instanceof Error?e.message:`Failed to save OpenCode settings`),console.error(`Failed to save OpenCode settings:`,e)}},children:`Save OpenCode Settings`})})]}),(0,Q.jsxs)(`div`,{style:{marginTop:t.marginLG},children:[(0,Q.jsx)(`h4`,{children:`About OpenCode`}),(0,Q.jsxs)(`ul`,{style:{fontSize:12,lineHeight:1.8,color:t.colorTextSecondary},children:[(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`strong`,{children:`Multi-Provider Support:`}),` Access Claude, GPT-4, Gemini, and 70+ other models`]}),(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`strong`,{children:`Privacy-First:`}),` All code and context stays local - no cloud storage`]}),(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`strong`,{children:`Local Models:`}),` Support for Ollama, LM Studio, and custom endpoints`]}),(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`strong`,{children:`Open Source:`}),` 30K+ GitHub stars, active community`]})]})]})]})}]})})};function J_(){return typeof window>`u`?`/`:window.location.pathname}function Y_(e=`/ui/`,t=J_()){return $l(Ql({baseUrl:e,pathname:t}))}function X_(e,t=`/ui/`){return`${Y_(t)}${e.startsWith(`/`)?e:`/${e}`}`}function Z_(e){return`${e.replace(/\/$/,``)}/`}var Q_=new Map;function $_({boardById:e,sessionById:t,branchById:n,artifactById:r}){let i=Wr(),a=Vr(),o=Ll(),s=(0,Z.useRef)(t??Q_);s.current=t??Q_;let c=(0,Z.useRef)(n??Q_);c.current=n??Q_;let l=(0,Z.useRef)(r??Q_);l.current=r??Q_;let u=(0,Z.useRef)(e);u.current=e;let d=(0,Z.useRef)(a.pathname);d.current=a.pathname;let f=(0,Z.useCallback)((e,t)=>Z_(e)===Z_(d.current)?!1:(i(e,{replace:t?.replace??!1}),!0),[i]),p=(0,Z.useCallback)((e,t)=>{f(Mf(e,u.current),t)},[f]),m=(0,Z.useCallback)(e=>{f(`/`,e)},[f]),h=(0,Z.useCallback)((e,t)=>{if(!f(rn(e),t)){let t=s.current.get(e),n=t?.branch_id?c.current.get(t.branch_id):void 0;n?.board_id&&o(n.branch_id,{boardId:n.board_id})}},[f,o]),g=(0,Z.useCallback)((e,t)=>{if(!f(an(e),t)){let t=c.current.get(e);t?.board_id&&o(e,{boardId:t.board_id})}},[f,o]),_=(0,Z.useCallback)((e,t)=>{if(!f(Ct(e),t)){let t=l.current.get(e);t?.board_id&&o(e,{boardId:t.board_id})}},[f,o]);return(0,Z.useMemo)(()=>({goToSession:h,goToBranch:g,goToArtifact:_,goToBoard:p,goHome:m}),[h,g,_,p,m])}var ev={react:`cyan`,"react-ts":`blue`,vanilla:`green`,"vanilla-ts":`geekblue`},tv={display:`block`,maxWidth:`100%`},nv=({artifactById:e,branchById:t,boardById:n,onUpdate:r,onDelete:i,onClose:o})=>{let[c,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(``),[g]=Y.useForm(),{token:_}=X.useToken(),y=$_({boardById:n,artifactById:e}),b=(0,Z.useCallback)(e=>{o?.(),y.goToArtifact(e.artifact_id)},[o,y]),x=e=>{p(e),g.setFieldsValue({name:e.name,description:e.description||``,board_id:e.board_id}),d(!0)},S=()=>{f&&g.validateFields().then(e=>{let t={},n=e.name,i=e.description||void 0,a=f.description||void 0;n!==f.name&&(t.name=n),i!==a&&(t.description=i),e.board_id&&e.board_id!==f.board_id&&(t.board_id=e.board_id),Object.keys(t).length>0&&r?.(f.artifact_id,t),g.resetFields(),d(!1),p(null)})},C=Ff(n).slice().sort((e,t)=>e.name.localeCompare(t.name)).map(e=>({value:e.board_id,label:`${e.icon||`📋`} ${e.name}`})),w=[{title:`Name`,dataIndex:`name`,key:`name`,width:`38%`,render:(e,t)=>{let n=e||Jt(t.artifact_id);return(0,Q.jsxs)(G,{orientation:`vertical`,size:0,style:{width:`100%`},children:[(0,Q.jsx)(v.Text,{strong:!0,ellipsis:{tooltip:n},style:tv,children:(0,Q.jsx)(Uf,{text:n,query:m})}),t.description&&(0,Q.jsx)(v.Text,{type:`secondary`,ellipsis:{tooltip:t.description},style:{...tv,fontSize:_.fontSizeSM},children:(0,Q.jsx)(Uf,{text:t.description,query:m})}),(0,Q.jsxs)(v.Text,{type:`secondary`,style:{fontSize:_.fontSizeSM},children:[`Created `,new Date(t.created_at).toLocaleDateString()]})]})}},{title:`Status`,key:`status`,width:150,render:(e,t)=>{let n={success:{status:`success`,text:`Success`},error:{status:`error`,text:`Error`},checking:{status:`processing`,text:`Checking`},unknown:{status:`default`,text:`Unknown`}},r=n[t.build_status]||n.unknown;return(0,Q.jsxs)(G,{orientation:`vertical`,size:0,children:[(0,Q.jsx)(R,{status:r.status,text:r.text}),(0,Q.jsx)(u,{color:ev[t.template]||`default`,style:{marginInlineEnd:0},children:(0,Q.jsx)(Uf,{text:t.template,query:m})})]})}},{title:`Location`,key:`location`,width:`32%`,render:(e,r)=>{let i=r.branch_id?t.get(r.branch_id):void 0,a=r.branch_id?i?.name||Jt(r.branch_id):`—`,o=n.get(r.board_id),s=o?`${o.icon||``} ${o.name}`.trim():Jt(r.board_id);return(0,Q.jsxs)(G,{orientation:`vertical`,size:0,style:{width:`100%`},children:[(0,Q.jsxs)(v.Text,{type:`secondary`,ellipsis:{tooltip:`Board: ${s}`},style:tv,children:[`Board: `,(0,Q.jsx)(Uf,{text:s,query:m})]}),(0,Q.jsxs)(v.Text,{type:`secondary`,ellipsis:{tooltip:`Branch: ${a}`},style:tv,children:[`Branch: `,(0,Q.jsx)(Uf,{text:a,query:m})]})]})}},{title:`Actions`,key:`actions`,width:124,render:(e,t)=>(0,Q.jsxs)(vm,{children:[t.board_id&&(0,Q.jsx)(H,{title:`Center map on artifact`,children:(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(Pe,{}),onClick:e=>{e.stopPropagation(),b(t)}})}),(0,Q.jsx)(H,{title:`Open fullscreen`,children:(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(ze,{}),href:X_(Pt(t.artifact_id)),target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation()})}),(0,Q.jsx)(H,{title:`Edit artifact`,children:(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(P,{}),onClick:()=>x(t)})}),(0,Q.jsx)(B,{title:`Delete artifact?`,description:`This will remove "${t.name}" and its files.`,onConfirm:()=>i?.(t.artifact_id),okText:`Delete`,cancelText:`Cancel`,okButtonProps:{danger:!0},children:(0,Q.jsx)(H,{title:`Delete artifact`,children:(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(re,{}),danger:!0})})})]})}],T=(0,Z.useMemo)(()=>Bf(If(e,(e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:`base`})).filter(e=>!e.archived),m,[e=>e.name,e=>e.description,e=>e.template,e=>e.build_status,e=>e.artifact_id,e=>{let n=e.branch_id?t.get(e.branch_id):void 0;return[n?.name,n?.ref,e.branch_id]},e=>{let t=n.get(e.board_id);return[t?.name,t?.slug,e.board_id]}]),[e,m,t,n]);return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{style:{marginBottom:16,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,Q.jsx)(v.Text,{type:`secondary`,children:`Live web application artifacts created by agents via MCP tools.`}),(0,Q.jsx)(J,{allowClear:!0,placeholder:`Search name, description, template, branch, or board`,value:m,onChange:e=>h(e.target.value),style:{width:360}})]}),T.length===0?(0,Q.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`center`,minHeight:400},children:(0,Q.jsx)(fe,{description:`No artifacts yet`,children:(0,Q.jsxs)(v.Text,{type:`secondary`,children:[`Artifacts are created by agents using the `,(0,Q.jsx)(`code`,{children:`agor_artifacts_publish`}),` MCP tool.`]})})}):(0,Q.jsx)(ue,{dataSource:T,columns:w,rowKey:`artifact_id`,pagination:!1,size:`small`,tableLayout:`fixed`,scroll:{x:760}}),(0,Q.jsx)(a,{title:`Edit Artifact`,open:c,onOk:S,onCancel:()=>{g.resetFields(),d(!1),p(null)},okText:`Save`,children:(0,Q.jsxs)(Y,{form:g,layout:`vertical`,style:{marginTop:16},children:[(0,Q.jsx)(Y.Item,{label:`Name`,name:`name`,rules:[{required:!0,message:`Please enter a name`}],children:(0,Q.jsx)(J,{placeholder:`My Artifact`})}),(0,Q.jsx)(Y.Item,{label:`Description`,name:`description`,children:(0,Q.jsx)(J.TextArea,{rows:3,placeholder:`Optional description`})}),(0,Q.jsx)(Y.Item,{label:`Board`,name:`board_id`,tooltip:`Move this artifact to a different board. Its position on the board is preserved.`,rules:[{required:!0,message:`Please select a board`}],children:(0,Q.jsx)(l,{showSearch:!0,placeholder:`Select board...`,options:C,filterOption:(e,t)=>(t?.label?.toString()??``).toLowerCase().includes(e.toLowerCase())})})]})})]})},rv=({branchById:e,repoById:t,boardById:n,sessionsByBranch:r,userById:i,onArchiveOrDelete:a,onRowClick:o,onCreateAssistant:c,onClose:l})=>{let u=$_({boardById:n,branchById:e}),d=(0,Z.useCallback)(e=>{l?.(),u.goToBranch(e.branch_id)},[l,u]),{token:f}=X.useToken(),[p,m]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),x=(0,Z.useMemo)(()=>{let n=p.trim().toLowerCase(),r=Array.from(e.values()).filter(e=>!e.archived&&Xt(e)).sort((e,t)=>{let n=Wt(e)?.displayName??e.name,r=Wt(t)?.displayName??t.name;return n.localeCompare(r,void 0,{sensitivity:`base`})});return n?r.filter(e=>{let r=Wt(e),a=t.get(e.repo_id),o=i.get(e.created_by);return[r?.displayName,e.name,e.notes,o?.name,o?.email,a?.name,a?.slug].some(e=>e?.toLowerCase().includes(n))}):r},[e,t,i,p]);return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(G,{orientation:`vertical`,size:f.sizeUnit*2,style:{marginBottom:f.sizeUnit*2,width:`100%`},children:[(0,Q.jsx)(v.Text,{type:`secondary`,children:`Assistants are persistent AI companions backed by a framework repo. They maintain memory, orchestrate work across branches, and run on scheduled heartbeats.`}),(0,Q.jsxs)(G,{style:{width:`100%`,display:`flex`,justifyContent:`space-between`},children:[(0,Q.jsx)(J,{allowClear:!0,placeholder:`Search assistants...`,value:p,onChange:e=>m(e.target.value),style:{maxWidth:f.sizeUnit*40}}),(0,Q.jsx)(s,{type:`primary`,icon:(0,Q.jsx)(L,{}),onClick:c,disabled:!c,children:`Create Assistant`})]})]}),x.length===0&&!p&&(0,Q.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`center`,minHeight:300},children:(0,Q.jsx)(fe,{image:(0,Q.jsx)(h,{style:{fontSize:48,color:f.colorTextDisabled}}),description:`No assistants yet`,children:(0,Q.jsx)(v.Text,{type:`secondary`,children:`Create an assistant to get started, or use the onboarding wizard.`})})}),(x.length>0||p)&&(0,Q.jsx)(ue,{dataSource:x,columns:[{title:`Assistant`,key:`assistant`,width:220,render:(e,t)=>{let n=Wt(t);return(0,Q.jsxs)(G,{children:[n?.emoji?(0,Q.jsx)(`span`,{style:{fontSize:18},children:n.emoji}):(0,Q.jsx)(h,{style:{color:f.colorInfo}}),(0,Q.jsx)(v.Text,{strong:!0,children:(0,Q.jsx)(Uf,{text:n?.displayName??t.name,query:p})})]})}},{title:`Description`,key:`description`,render:(e,t)=>{let n=(t.notes??``).trim();if(!n)return(0,Q.jsx)(v.Text,{type:`secondary`,italic:!0,style:{fontSize:12},children:`No description`});let r=n.split(`
24
- `).find(e=>e.trim().length>0)??n;return(0,Q.jsx)(N,{content:(0,Q.jsx)(`div`,{className:`markdown-compact`,style:{maxWidth:480,maxHeight:400,overflowY:`auto`,fontSize:12,lineHeight:1.5},children:(0,Q.jsx)(_h,{content:n,showControls:!1})}),trigger:`hover`,placement:`topLeft`,mouseEnterDelay:.3,children:(0,Q.jsx)(v.Text,{type:`secondary`,ellipsis:!0,style:{display:`block`,maxWidth:480,fontSize:12,cursor:`help`},children:(0,Q.jsx)(Uf,{text:r,query:p})})})}},{title:`Creator`,key:`creator`,width:160,render:(e,t)=>{let n=i.get(t.created_by);return!n||t.created_by===`anonymous`?(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12},children:t.created_by===`anonymous`?`Anonymous`:`Unknown User`}):(0,Q.jsx)(om,{user:n,showName:!0,size:`small`})}},{title:`Actions`,key:`actions`,width:104,render:(e,t)=>(0,Q.jsxs)(vm,{children:[t.board_id&&(0,Q.jsx)(H,{title:`Center map on assistant`,children:(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(Pe,{}),onClick:e=>{e.stopPropagation(),d(t)}})}),(0,Q.jsx)(H,{title:`Edit assistant`,children:(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(P,{}),onClick:e=>{e.stopPropagation(),o?.(t)}})}),(0,Q.jsx)(Oh,{tooltip:`Archive or delete assistant`,onClick:()=>{b(t),_(!0)}})]})}],rowKey:`branch_id`,pagination:{pageSize:10},size:`small`,onRow:e=>({onClick:()=>o?.(e),style:{cursor:o?`pointer`:`default`}})}),y&&(0,Q.jsx)(Ah,{open:g,branch:y,sessionCount:(r.get(y.branch_id)||[]).length,environmentRunning:y.environment_instance?.status===`running`,onConfirm:e=>{a?.(y.branch_id,e),_(!1),b(null)},onCancel:()=>{_(!1),b(null)}})]})},iv=[{label:`Rainbow (7 colors)`,value:`linear-gradient(to right, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #9400d3)`},{label:`Multi-color gradient`,value:`linear-gradient(124deg, #ff2400, #e81d1d, #e8b71d, #e3e81d, #1de840, #1ddde8, #2b1de8, #dd00f3, #dd00f3)`},{label:`Pink to blue gradient`,value:`linear-gradient(180deg, #f093fb 0%, #f5576c 25%, #4facfe 50%, #00f2fe 75%, #43e97b 100%)`},{label:`Gold shimmer`,value:`linear-gradient(135deg, #f5af19 0%, #f12711 30%, #f5af19 60%, #f12711 100%)`},{label:`Cyan/magenta grid`,value:`repeating-linear-gradient(0deg, transparent, transparent 2px, #0ff 2px, #0ff 4px), repeating-linear-gradient(90deg, transparent, transparent 2px, #f0f 2px, #f0f 4px), linear-gradient(180deg, #000, #001a1a)`},{label:`Diagonal stripes (colorful)`,value:`repeating-linear-gradient(45deg, #ff006e 0px, #ff006e 10px, #ffbe0b 10px, #ffbe0b 20px, #8338ec 20px, #8338ec 30px, #3a86ff 30px, #3a86ff 40px)`},{label:`Conic gradient (warm colors)`,value:`conic-gradient(from 45deg, #ff0080, #ff8c00, #40e0d0, #ff0080, #ff8c00, #40e0d0, #ff0080)`},{label:`Dark with purple/pink spots`,value:`radial-gradient(ellipse at top, #1b2735 0%, #090a0f 100%), radial-gradient(circle at 20% 50%, rgba(120, 0, 255, 0.3) 0%, transparent 50%), radial-gradient(circle at 80% 80%, rgba(255, 0, 120, 0.3) 0%, transparent 50%)`},{label:`Quadrant blocks (conic)`,value:`repeating-conic-gradient(from 0deg at 50% 50%, #ff006e 0deg 90deg, #8338ec 90deg 180deg, #3a86ff 180deg 270deg, #fb5607 270deg 360deg)`},{label:`RGB stripes`,value:`linear-gradient(90deg, #000 0%, #f00 20%, #000 21%, #0f0 40%, #000 41%, #00f 60%, #000 61%, #fff 80%, #000 81%)`},{label:`Fine diagonal lines (B&W)`,value:`repeating-linear-gradient(45deg, #000, #000 1px, #fff 1px, #fff 2px)`},{label:`Dark with magenta/cyan glow`,value:`radial-gradient(circle at 30% 50%, rgba(255, 0, 255, 0.5), transparent 50%), radial-gradient(circle at 70% 70%, rgba(0, 255, 255, 0.5), transparent 50%), linear-gradient(180deg, #0a0a0a, #1a1a2e)`},{label:`Sunburst (conic)`,value:`conic-gradient(from 0deg, #ffbe0b 0deg, #fb5607 60deg, #ff006e 120deg, #8338ec 180deg, #3a86ff 240deg, #ffbe0b 300deg, #fb5607 360deg)`},{label:`Checkerboard (purple)`,value:`repeating-linear-gradient(45deg, #606dbc, #606dbc 10px, #465298 10px, #465298 20px)`}],av=[{label:`Slow gradient shift (12s)`,value:`background-size: 400% 400%;
25
- animation: agorGradientShift 12s ease infinite;
26
-
27
- @keyframes agorGradientShift {
28
- 0%, 100% { background-position: 0% 50%; }
29
- 50% { background-position: 100% 50%; }
30
- }`},{label:`Fast gradient shift (4s)`,value:`background-size: 400% 400%;
31
- animation: agorGradientFast 4s ease infinite;
32
-
33
- @keyframes agorGradientFast {
34
- 0%, 100% { background-position: 0% 50%; }
35
- 50% { background-position: 100% 50%; }
36
- }`},{label:`Diagonal sweep (8s)`,value:`background-size: 400% 400%;
37
- animation: agorDiagonalSweep 8s linear infinite;
38
-
39
- @keyframes agorDiagonalSweep {
40
- 0% { background-position: 0% 0%; }
41
- 50% { background-position: 100% 100%; }
42
- 100% { background-position: 0% 0%; }
43
- }`},{label:`Pulse zoom (6s)`,value:`background-size: 200% 200%;
44
- animation: agorPulse 6s ease-in-out infinite;
45
-
46
- @keyframes agorPulse {
47
- 0%, 100% { background-size: 200% 200%; background-position: center; }
48
- 50% { background-size: 300% 300%; background-position: center; }
49
- }`},{label:`Horizontal scroll (20s)`,value:`background-size: 200% 100%;
50
- animation: agorHScroll 20s linear infinite;
51
-
52
- @keyframes agorHScroll {
53
- 0% { background-position: 0% 50%; }
54
- 100% { background-position: 200% 50%; }
55
- }`},{label:`Rotate (conic, 10s)`,value:`animation: agorRotate 10s linear infinite;
56
-
57
- @keyframes agorRotate {
58
- 0% { filter: hue-rotate(0deg); }
59
- 100% { filter: hue-rotate(360deg); }
60
- }`}];function ov(e){return e?!e.match(/^#[0-9a-fA-F]{3,8}$/)&&!e.match(/^rgba?\(/):!1}function sv(e){let t=e.getFieldsValue(!0),n=t.background_color;return{name:t.name,icon:t.icon||`📋`,description:t.description,background_color:n?typeof n==`string`?n:n.toHexString():null,custom_css:t.custom_css||null,access_mode:t.access_mode||`shared`,default_others_can:t.access_mode===`private`?`none`:t.default_others_can||`session`,default_others_fs_access:t.default_others_fs_access||`read`,default_dangerously_allow_session_sharing:!!t.default_dangerously_allow_session_sharing,custom_context:t.custom_context?JSON.parse(t.custom_context):null}}var cv=({form:e,autoFocus:t,extra:n,initialCustomCSS:r=!1,rbacEnabled:i=!1,allUsers:a=[],allGroups:o=[]})=>{let[s,c]=(0,Z.useState)(r),u=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y.Item,{label:`Name`,required:!0,style:{marginBottom:24},children:(0,Q.jsxs)(G.Compact,{style:{display:`flex`},children:[(0,Q.jsx)(ll,{form:e,fieldName:`icon`,defaultEmoji:`📋`}),(0,Q.jsx)(Y.Item,{name:`name`,noStyle:!0,rules:[{required:!0,message:`Please enter a board name`}],children:(0,Q.jsx)(J,{placeholder:`My Board`,style:{flex:1},autoFocus:t})})]})}),(0,Q.jsx)(Y.Item,{label:`Description`,name:`description`,children:(0,Q.jsx)(J.TextArea,{placeholder:`Optional description...`,rows:3})})]}),d={form:e,preserve:!0},f=Y.useWatch(`access_mode`,d)||`shared`,p=Y.useWatch(`owner_ids`,d)||[],h=Y.useWatch(`board_group_grants`,d)||[],g=Y.useWatch(`default_others_can`,d)||`session`,_=Y.useWatch(`default_others_fs_access`,d)||`read`,y=!!Y.useWatch(`default_dangerously_allow_session_sharing`,d),b={visibility:f,ownerIds:p,groupGrants:h,othersCan:f===`private`?`none`:g,othersFsAccess:_,allowSessionSharing:y},x=(0,Q.jsxs)(Y,{layout:`horizontal`,colon:!1,component:!1,children:[(0,Q.jsx)(z,{type:`info`,showIcon:!0,description:`Default branch permissions apply to new/aligned branches; branch overrides can still share individual branches.`,style:{marginBottom:24}}),(0,Q.jsx)(eg,{value:b,onChange:(t,n)=>{t===`visibility`&&e.setFieldsValue({access_mode:n}),t===`ownerIds`&&e.setFieldsValue({owner_ids:n}),t===`groupGrants`&&e.setFieldsValue({board_group_grants:n}),t===`othersCan`&&e.setFieldsValue({default_others_can:n}),t===`othersFsAccess`&&e.setFieldsValue({default_others_fs_access:n}),t===`allowSessionSharing`&&e.setFieldsValue({default_dangerously_allow_session_sharing:n})},allUsers:a,allGroups:o,canEdit:!0,canEditOwners:i,canEditGroups:i,ownerHelp:`Manage board owners`,groupsHelp:`Inherited by aligned branches`,visibilityLabel:`Default branch permissions`,othersCanLabel:`Default others can`,othersFsAccessLabel:`Default filesystem access`}),!i&&(0,Q.jsx)(Y.Item,{wrapperCol:{offset:8,span:16},children:(0,Q.jsx)(v.Text,{type:`secondary`,children:`Enable execution.branch_rbac to manage board owners and group grants.`})})]}),S=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(G,{direction:`vertical`,style:{width:`100%`,marginBottom:16},children:[(0,Q.jsx)(U,{checked:s,onChange:t=>{if(c(t.target.checked),t.target.checked){let t=e.getFieldValue(`background_color`);t&&typeof t!=`string`&&e.setFieldsValue({background_color:t.toHexString()})}},children:`Use custom CSS background`}),s?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(l,{placeholder:`Load a preset...`,style:{width:`100%`,marginBottom:8},allowClear:!0,showSearch:!0,options:iv,onChange:t=>{t&&e.setFieldsValue({background_color:t})}}),(0,Q.jsx)(Y.Item,{name:`background_color`,noStyle:!0,children:(0,Q.jsx)(J.TextArea,{placeholder:`Enter custom CSS background value (gradients, patterns, etc.)`,rows:3,style:{fontFamily:`monospace`,fontSize:`12px`}})})]}):(0,Q.jsx)(Y.Item,{name:`background_color`,noStyle:!0,children:(0,Q.jsx)(be,{showText:!0,format:`hex`,allowClear:!0})})]}),s&&(0,Q.jsxs)(G,{direction:`vertical`,style:{width:`100%`},children:[(0,Q.jsx)(v.Text,{strong:!0,style:{fontSize:`13px`},children:`Animation CSS`}),(0,Q.jsx)(l,{placeholder:`Load an animation preset...`,style:{width:`100%`,marginBottom:8},allowClear:!0,showSearch:!0,options:av,onChange:t=>{t&&e.setFieldsValue({custom_css:t})}}),(0,Q.jsx)(Y.Item,{name:`custom_css`,noStyle:!0,children:(0,Q.jsx)(J.TextArea,{rows:6,style:{fontFamily:`monospace`,fontSize:`12px`}})})]})]});return(0,Q.jsx)(m,{items:[{key:`general`,label:`General`,children:u},{key:`permissions`,label:`Permissions`,children:x},{key:`css`,label:`CSS`,children:S},...n?[{key:`advanced`,label:`Advanced`,children:n}]:[]]})},lv=({value:e,onChange:t,placeholder:n=`{"key": "value"}`,rows:r=4})=>(0,Q.jsx)(Fm,{value:e??``,onChange:t,language:`json`,placeholder:n,rows:r}),uv=(e,t)=>{if(!t||t.trim()===``)return Promise.resolve();try{return JSON.parse(t),Promise.resolve()}catch{return Promise.reject(Error(`Invalid JSON`))}},dv=({client:e,boardById:t,sessionsByBranch:n,branchById:r,onCreate:i,onUpdate:o,onDelete:c,onArchive:u,onUnarchive:d})=>{let{modal:f}=b.useApp(),{showSuccess:p,showError:m}=cf(),[h,g]=(0,Z.useState)(!1),[_,y]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!1),[T,D]=(0,Z.useState)([]),[O,k]=(0,Z.useState)([]),[A,j]=(0,Z.useState)(`active`),[M,N]=(0,Z.useState)(``),[F]=Y.useForm(),I=(0,Z.useMemo)(()=>{let e=new Map;for(let i of t.values()){let t=[];for(let e of r.values())e.board_id===i.board_id&&t.push(e.branch_id);let a=t.flatMap(e=>n.get(e)||[]).length;e.set(i.board_id,a)}return e},[t,n,r]),te=async t=>{if(!e||!C)return;let n=t,r=F.getFieldsValue(!0),i=r.access_mode===`private`,a=r.owner_ids||[],o=i?[]:r.board_group_grants||[],s=(await e.service(`boards/:id/owners`).find({route:{id:n}})).map(e=>e.user_id);await Promise.all([...a.filter(e=>!s.includes(e)).map(t=>e.service(`boards/:id/owners`).create({user_id:t},{route:{id:n}})),...s.filter(e=>!a.includes(e)).map(t=>e.service(`boards/:id/owners`).remove(t,{route:{id:n}}))]);let c=await e.service(`boards/:id/group-grants`).find({route:{id:n}}),l=new Map(o.map(e=>[e.group_id,e]));await Promise.all([...o.map(t=>e.service(`boards/:id/group-grants`).create(t,{route:{id:n}})),...c.filter(e=>!l.has(e.group_id)).map(t=>e.service(`boards/:id/group-grants`).remove(t.group_id,{route:{id:n}}))])},R=()=>{F.validateFields().then(()=>{i?.(sv(F)),F.resetFields(),g(!1)}).catch(()=>{})},ne=async t=>{S(t);let n=[],r=[];if(e)try{let[i,a,o,s]=await Promise.all([e.service(`users`).findAll({}),e.service(`groups`).findAll({query:{archived:!1}}),e.service(`boards/:id/owners`).find({route:{id:t.board_id}}),e.service(`boards/:id/group-grants`).find({route:{id:t.board_id}})]);w(!0),D(i),k(a),n=o.map(e=>e.user_id),n.length===0&&t.created_by&&(n=[t.created_by]),r=s.map(e=>({group_id:e.group_id,can:e.can,fs_access:e.fs_access}))}catch(e){w(!1),D([]),k([]),console.warn(`Board RBAC metadata unavailable:`,e)}F.setFieldsValue({name:t.name,icon:t.icon,description:t.description,background_color:t.background_color,custom_css:t.custom_css,access_mode:t.access_mode||`shared`,default_others_can:t.default_others_can||`session`,default_others_fs_access:t.default_others_fs_access||`read`,default_dangerously_allow_session_sharing:!!t.default_dangerously_allow_session_sharing,owner_ids:n,board_group_grants:r,custom_context:t.custom_context?JSON.stringify(t.custom_context,null,2):``}),y(!0)},z=()=>{x&&F.validateFields().then(()=>{let e=F.getFieldsValue(!0);if(e.access_mode===`private`&&(e.owner_ids||[]).length!==1){m(`Private boards must have exactly one private user`);return}o?.(x.board_id,sv(F)),te(x.board_id).catch(e=>{m(`Failed to update board permissions: ${e.message}`)}),F.resetFields(),y(!1),S(null)}).catch(()=>{})},V=e=>{c?.(e)},ie=t=>{let n=`${t.name} (Copy)`,r=n;f.confirm({title:`Clone Board`,content:(0,Q.jsx)(J,{placeholder:`New board name`,defaultValue:n,onChange:e=>{r=e.target.value},onPressEnter:e=>{e.preventDefault()}}),onOk:()=>e?e.service(`boards`).clone({id:t.board_id,name:r}).then(e=>{p(`Board cloned: ${e.name}`),i?.(e)}).catch(e=>(m(`Clone failed: ${e instanceof Error?e.message:String(e)}`),Promise.reject(e))):(m(`Not connected to daemon`),Promise.reject(Error(`Not connected to daemon`)))})},U=async t=>{if(!e){m(`Not connected to daemon`);return}try{let n=await e.service(`boards`).toYaml({id:t.board_id}),r=new Blob([n],{type:`text/yaml`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`${t.slug||t.name.toLowerCase().replace(/\s+/g,`-`)}.agor-board.yaml`,a.click(),URL.revokeObjectURL(i),p(`Board exported`)}catch(e){m(`Export failed: ${e instanceof Error?e.message:String(e)}`)}},ae=()=>{let e=document.createElement(`input`);e.type=`file`,e.accept=`.yaml,.yml,.json`,e.onchange=e=>oe(e.target.files?.[0]),e.click()},oe=async t=>{if(!t)return;if(!e){m(`Not connected to daemon`);return}let n=await t.text();try{let r=e.service(`boards`),a;a=t.name.endsWith(`.json`)?await r.fromBlob(JSON.parse(n)):await r.fromYaml({yaml:n}),p(`Board imported: ${a.name}`),i?.(a)}catch(e){m(`Import failed: ${e instanceof Error?e.message:String(e)}`)}},se=(0,Q.jsx)(Y.Item,{label:`Custom Context (JSON)`,name:`custom_context`,help:`Add custom fields for use in zone trigger templates (e.g., {{ board.context.yourField }})`,rules:[{validator:uv}],children:(0,Q.jsx)(lv,{placeholder:`{"team": "Backend", "sprint": 42}`,rows:4})}),ce=(0,Z.useMemo)(()=>Bf(If(t,(e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:`base`})).filter(e=>A===`active`?!e.archived:A===`archived`?e.archived:!0),M,[e=>e.name,e=>e.slug,e=>e.description,e=>e.board_id]),[t,A,M]);return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{style:{marginBottom:16,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,Q.jsx)(v.Text,{type:`secondary`,children:`Create and manage boards for organizing sessions.`}),(0,Q.jsxs)(G,{children:[(0,Q.jsx)(l,{value:A,onChange:e=>j(e),style:{width:120},options:[{value:`active`,label:`Active`},{value:`all`,label:`All`},{value:`archived`,label:`Archived`}]}),(0,Q.jsx)(J,{allowClear:!0,placeholder:`Search name, slug, description, or ID`,value:M,onChange:e=>N(e.target.value),style:{width:300}}),(0,Q.jsx)(s,{icon:(0,Q.jsx)(xe,{}),onClick:ae,children:`Import Board`}),(0,Q.jsx)(s,{type:`primary`,icon:(0,Q.jsx)(L,{}),onClick:()=>g(!0),children:`New Board`})]})]}),(0,Q.jsx)(ue,{dataSource:ce,columns:[{title:`Icon`,dataIndex:`icon`,key:`icon`,width:80,render:e=>(0,Q.jsx)(`span`,{style:{fontSize:24},children:e||`📋`})},{title:`Name`,dataIndex:`name`,key:`name`,render:e=>(0,Q.jsx)(Uf,{text:e,query:M})},{title:`Description`,dataIndex:`description`,key:`description`,render:e=>(0,Q.jsx)(v.Text,{type:`secondary`,children:e?(0,Q.jsx)(Uf,{text:e,query:M}):`—`})},{title:`Sessions`,key:`sessions`,width:100,render:(e,t)=>I.get(t.board_id)||0},{title:`Actions`,key:`actions`,width:184,render:(e,t)=>(0,Q.jsxs)(vm,{children:[(0,Q.jsx)(Dh,{archived:!!t.archived,tooltip:t.archived?`Archived • Click to unarchive`:`Archive board`,stopPropagation:!1,onToggle:e=>{e?u?.(t.board_id):d?.(t.board_id)}}),(0,Q.jsx)(H,{title:`Clone board (zones, configuration, and positions only)`,children:(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(E,{}),onClick:()=>ie(t)})}),(0,Q.jsx)(H,{title:`Export board to YAML (zones, configuration, and positions only)`,children:(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(ee,{}),onClick:()=>U(t)})}),(0,Q.jsx)(H,{title:`Edit board settings`,children:(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(P,{}),onClick:()=>ne(t)})}),(0,Q.jsx)(B,{title:`Delete board?`,description:`Are you sure you want to delete "${t.name}"? Sessions will not be deleted.`,onConfirm:()=>V(t.board_id),okText:`Delete`,cancelText:`Cancel`,okButtonProps:{danger:!0},children:(0,Q.jsx)(H,{title:`Delete board (sessions will not be deleted)`,children:(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(re,{}),danger:!0})})})]})}],rowKey:`board_id`,pagination:!1,size:`small`,onRow:e=>({style:e.archived?{opacity:.5}:void 0})}),(0,Q.jsx)(a,{title:`Create Board`,open:h,width:760,onOk:R,onCancel:()=>{F.resetFields(),g(!1)},okText:`Create`,children:(0,Q.jsx)(Y,{form:F,layout:`vertical`,preserve:!0,style:{marginTop:16},children:(0,Q.jsx)(cv,{form:F,extra:se})})}),(0,Q.jsx)(a,{title:`Edit Board`,open:_,width:760,onOk:z,onCancel:()=>{F.resetFields(),y(!1),S(null)},okText:`Save`,children:(0,Q.jsx)(Y,{form:F,layout:`vertical`,preserve:!0,style:{marginTop:16},children:(0,Q.jsx)(cv,{form:F,extra:se,initialCustomCSS:ov(x?.background_color)||!!x?.custom_css,rbacEnabled:C,allUsers:T,allGroups:O},x?.board_id)})})]})};function fv(e){return typeof e==`string`&&Ot.includes(e)}function pv(e){let t=Array.isArray(e?.allowedModes)?e.allowedModes.filter(fv):[...Ot],n=t.length>0?t:[...Ot],r=fv(e?.defaultMode)?e.defaultMode:Vt;return{defaultMode:n.includes(r)?r:n[0],allowedModes:n}}function mv(e,t){let n=pv(t);return fv(e)&&n.allowedModes.includes(e)?e:n.defaultMode}function hv(e){return e===`worktree`?`Worktree`:`Clone`}var gv=100,_v=({repoById:e,boardById:t=new Map,selectedRepoId:n,onRepoChange:r,defaultBranch:i,fieldPrefix:a=``,showUrlFields:o=!1,showBoardSelector:s=!1,requireBoard:c=!1,onFormChange:u,useSameBranchName:d,onUseSameBranchNameChange:f,branchStorageConfig:p})=>{let[m,h]=(0,Z.useState)(!0),[g,_]=(0,Z.useState)(`branch`),y=d??m,b=f??h,x=Y.useFormInstance(),S=`${a}storage_mode`,{defaultMode:C,allowedModes:w}=(0,Z.useMemo)(()=>pv(p),[p]),T=(0,Z.useRef)(void 0);(0,Z.useEffect)(()=>{let e=x.getFieldValue(S),t=T.current;(!e||!w.includes(e)||t!==void 0&&e===t&&e!==C)&&x.setFieldValue(S,C),T.current=C},[w,C,x,S]);let E=e=>{b(e),e&&x.setFieldValue(`${a}branchName`,void 0),u?.()};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y.Item,{name:`${a}repoId`,label:`Repository`,rules:[{required:!0,message:`Please select a repository`}],validateTrigger:[`onBlur`,`onChange`],children:(0,Q.jsx)(l,{placeholder:`Select repository...`,showSearch:!0,filterOption:(e,t)=>String(t?.label??``).toLowerCase().includes(e.toLowerCase()),options:Ff(e).sort((e,t)=>(e.name||e.slug).localeCompare(t.name||t.slug)).map(e=>({value:e.repo_id,label:e.name||e.slug})),onChange:r})}),s&&(0,Q.jsx)(Y.Item,{name:`${a}boardId`,label:`Board`,tooltip:`Branches are created on a board and align with that board's default permissions`,rules:c?[{required:!0,message:`Please select a board`}]:void 0,validateTrigger:[`onBlur`,`onChange`],children:(0,Q.jsx)(l,{placeholder:`Select board...`,allowClear:!c,showSearch:!0,filterOption:(e,t)=>String(t?.label??``).toLowerCase().includes(e.toLowerCase()),options:Ff(t).sort((e,t)=>e.name.localeCompare(t.name)).map(e=>({value:e.board_id,label:`${e.icon||`📋`} ${e.name}`})),onChange:u})}),(0,Q.jsx)(Y.Item,{name:`${a}refType`,label:`Source Type`,initialValue:`branch`,children:(0,Q.jsxs)(K.Group,{onChange:e=>{_(e.target.value),e.target.value===`tag`?x.setFieldValue(`${a}sourceBranch`,void 0):x.setFieldValue(`${a}sourceBranch`,i),u?.()},children:[(0,Q.jsx)(K,{value:`branch`,children:`Branch`}),(0,Q.jsx)(K,{value:`tag`,children:`Tag`})]})}),(0,Q.jsx)(Y.Item,{name:`${a}sourceBranch`,label:g===`branch`?`Source Branch`:`Source Tag`,rules:[{required:!0,message:`Please enter source ${g}`}],validateTrigger:[`onBlur`,`onChange`],tooltip:`${g} to use as base for the new branch`,initialValue:i,children:(0,Q.jsx)(J,{placeholder:g===`branch`?i:`v1.0.0`})}),(0,Q.jsx)(Y.Item,{name:`${a}name`,label:`Branch Name`,rules:[{required:!0,message:`Please enter a branch name`},{pattern:/^[a-z0-9-]+$/,message:`Only lowercase letters, numbers, and hyphens allowed`}],validateTrigger:[`onBlur`,`onChange`],tooltip:`URL-friendly name (e.g., 'feat-auth', 'fix-cors')`,children:(0,Q.jsx)(J,{placeholder:`feat-auth`,autoFocus:!0})}),(0,Q.jsx)(Y.Item,{children:(0,Q.jsx)(U,{checked:y,onChange:e=>E(e.target.checked),children:g===`tag`?`Use the same name for the git branch (new branch from tag)`:`Use the same name for the git branch`})}),!y&&(0,Q.jsx)(Y.Item,{name:`${a}branchName`,label:`Git Branch Name`,rules:[{required:!0,message:`Please enter a git branch name`}],validateTrigger:[`onBlur`,`onChange`],children:(0,Q.jsx)(J,{placeholder:`feature/auth`})}),(0,Q.jsx)(Y.Item,{name:S,label:`Storage`,initialValue:C,tooltip:`How the branch is materialised on disk. "Worktree" uses git's native shared-base model (legacy default). "Clone" gives this branch its own .git/ directory via a real git clone — credentials and config are isolated from sibling branches. See context/explorations/clone-redesign.md.`,extra:w.length===1?`${hv(w[0])} is the only storage mode enabled on this Agor instance. Administrators configure this with execution.branch_storage.allowed_modes.`:`Default on this Agor instance: ${hv(C)}.`,children:(0,Q.jsx)(K.Group,{onChange:()=>u?.(),children:Ot.map(e=>{let t=!w.includes(e),n=e===C?` (default)`:``,r=`${hv(e)}${n}`;return(0,Q.jsx)(H,{title:t?`${hv(e)} storage is disabled on this Agor instance by execution.branch_storage.allowed_modes.`:void 0,children:(0,Q.jsx)(`span`,{children:(0,Q.jsx)(K,{value:e,disabled:t,children:r})})},e)})})}),(0,Q.jsx)(Y.Item,{shouldUpdate:(e,t)=>e[`${a}storage_mode`]!==t[`${a}storage_mode`],noStyle:!0,children:({getFieldValue:e})=>e(`${a}storage_mode`)===`clone`?(0,Q.jsx)(Y.Item,{name:`${a}clone_depth`,label:`Depth`,initialValue:gv,tooltip:"Number of commits to keep (`git clone --depth N`). Defaults to 100 — usually plenty for a feature branch. Leave empty for a full clone with complete history.",rules:[{validator:(e,t)=>t==null||t===``||Number.isInteger(t)&&t>0?Promise.resolve():Promise.reject(Error(`Depth must be a positive integer, or empty for a full clone`))}],children:(0,Q.jsx)(lt,{min:1,placeholder:`100`,style:{width:160},onChange:()=>u?.()})}):null}),o&&(0,Q.jsxs)(G,{orientation:`vertical`,style:{width:`100%`},children:[(0,Q.jsx)(Y.Item,{name:`${a}issue_url`,label:`Issue URL (optional)`,rules:[{type:`url`,message:`Please enter a valid URL`}],validateTrigger:[`onBlur`,`onChange`],children:(0,Q.jsx)(J,{placeholder:`https://github.com/org/repo/issues/123`})}),(0,Q.jsx)(Y.Item,{name:`${a}pull_request_url`,label:`Pull Request URL (optional)`,rules:[{type:`url`,message:`Please enter a valid URL`}],validateTrigger:[`onBlur`,`onChange`],children:(0,Q.jsx)(J,{placeholder:`https://github.com/org/repo/pull/123`})})]}),(0,Q.jsxs)(v.Paragraph,{type:`secondary`,style:{marginTop:16},children:[(0,Q.jsx)(`strong`,{children:`What will happen:`}),(0,Q.jsx)(`br`,{}),`• Fetch latest from origin`,(0,Q.jsx)(`br`,{}),`• Create new branch`,` `,(0,Q.jsx)(v.Text,{code:!0,children:y?`<name>`:`<git-branch-name>`}),` `,`based on `,g===`tag`?`tag`:`branch`,` `,(0,Q.jsx)(v.Text,{code:!0,children:x.getFieldValue(`${a}sourceBranch`)||(g===`tag`?`<tag-name>`:i)}),(0,Q.jsx)(`br`,{}),`• Branch location:`,` `,(0,Q.jsxs)(v.Text,{code:!0,children:[`~/.agor/worktrees/`,`<repo>`,`/`,(0,Q.jsx)(v.Text,{italic:!0,children:`<name>`})]})]})]})};function vv(e){if(e.environment){let t=Lt(e.environment,e.environment.default);if(t)return{start:t.start,stop:t.stop,nuke:t.nuke,logs:t.logs,health:t.health,app:t.app,hasConfig:!!(t.start||t.stop)}}let t=e.environment_config;return t?{start:t.up_command,stop:t.down_command,nuke:t.nuke_command,logs:t.logs_command,health:t.health_check?.url_template,app:t.app_url_template,hasConfig:!!(t.up_command||t.down_command)}:{hasConfig:!1}}function yv(e,t){let n=e.environment_instance?.status,r=e.environment_instance?.last_health_check?.status;return!n||n===`stopped`?(0,Q.jsx)(H,{title:`Environment stopped`,children:(0,Q.jsx)(M,{style:{color:t.colorTextDisabled}})}):n===`starting`||n===`stopping`?(0,Q.jsx)(H,{title:`Environment ${n}`,children:(0,Q.jsx)(me,{style:{color:t.colorPrimary}})}):n===`error`?(0,Q.jsx)(H,{title:`Error: ${e.environment_instance?.last_health_check?.message||`Unknown`}`,children:(0,Q.jsx)(ut,{style:{color:t.colorError}})}):n===`running`?r===`healthy`?(0,Q.jsx)(H,{title:`Running (healthy)`,children:(0,Q.jsx)(st,{style:{color:t.colorSuccess}})}):r===`unhealthy`?(0,Q.jsx)(H,{title:`Running (unhealthy): ${e.environment_instance?.last_health_check?.message||``}`,children:(0,Q.jsx)(Ve,{style:{color:t.colorWarning}})}):(0,Q.jsx)(H,{title:`Running`,children:(0,Q.jsx)(R,{status:`processing`})}):null}function bv(e,t,n,r){let i=e.environment_instance?.status,a=e.environment_instance?.last_health_check?.status,c=!!(t?vv(t):void 0)?.hasConfig,l=i===`running`||i===`starting`||a===`healthy`,u=e.health_check_url;return(0,Q.jsxs)(G,{size:4,children:[yv(e,n),c&&t&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(F,{}),disabled:l,onClick:t=>{t.stopPropagation(),r.onStartEnvironment?.(e.branch_id)},style:{padding:`0 4px`}}),(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(o,{}),onClick:t=>{t.stopPropagation(),r.onStopEnvironment?.(e.branch_id)},style:{padding:`0 4px`}}),u&&(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(ne,{}),onClick:e=>{e.stopPropagation(),window.open(u,`_blank`)},style:{padding:`0 4px`}})]})]})}var xv=({client:e,branchById:t,repoById:n,boardById:r,sessionsByBranch:i,onArchiveOrDelete:o,onUnarchive:c,onCreate:u,onRowClick:d,onStartEnvironment:f,onStopEnvironment:m,onClose:g,branchStorageConfig:_})=>{let y=Ff(n),b=Ff(r),{token:x}=X.useToken(),S=$_({boardById:r,branchById:t}),C=(0,Z.useCallback)(e=>{g?.(),S.goToBranch(e.branch_id)},[g,S]),[w,T]=(0,Z.useState)(!1),[E]=Y.useForm(),[D,O]=(0,Z.useState)(!0),[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(!1),[N,F]=(0,Z.useState)(``),[I,ee]=(0,Z.useState)(`active`),[te,R]=(0,Z.useState)(!1),[ne,z]=(0,Z.useState)(null),[B,V]=(0,Z.useState)(`archive`),[ie,U]=(0,Z.useState)([]),[ae,oe]=(0,Z.useState)(!1),[ce,le]=(0,Z.useState)(!1),de=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{if(I!==`archived`&&I!==`all`||ae||de.current||!e)return;let t=!1;return de.current=!0,le(!0),e.service(`branches`).findAll({query:{archived:!0,$limit:1e3,$sort:{created_at:-1}}}).then(e=>{t||(U(e),oe(!0))}).catch(()=>{}).finally(()=>{de.current=!1,t||le(!1)}),()=>{t=!0}},[I,ae,e]);let pe=(0,Z.useCallback)(()=>{let e=E.getFieldsValue(),t=!!e.repoId,n=!!e.sourceBranch,r=!!e.name&&/^[a-z0-9-]+$/.test(e.name),i=D||!!e.branchName,a=!!e.boardId;M(t&&n&&r&&i&&a)},[E,D]),me=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{if(!w){me.current=!1;return}if(me.current||y.length===0)return;me.current=!0;let e=localStorage.getItem(`agor:lastUsedRepoId`),t=localStorage.getItem(`agor:lastUsedBoardId`),n=e&&y.find(t=>t.repo_id===e)?e:y[0].repo_id,r=t&&b.find(e=>e.board_id===t)?t:b.length>0?b[0].board_id:void 0;E.setFieldsValue({repoId:n,boardId:r,sourceBranch:y.find(e=>e.repo_id===n)?.default_branch||`main`}),A(n),pe()},[w,y,b,E,pe]);let he=e=>n.get(e)?.name||`Unknown Repo`,ge=()=>k&&y.find(e=>e.repo_id===k)?.default_branch||`main`,_e=e=>{A(e);let t=y.find(t=>t.repo_id===e)?.default_branch||`main`;E.setFieldValue(`sourceBranch`,t)},ve=async(e,n)=>{try{await o?.(e,n)}catch{return}if(n.metadataAction===`archive`){let n=t.get(e)||ie.find(t=>t.branch_id===e);if(n){let t={...n,archived:!0,archived_at:new Date().toISOString()};U(n=>{let r=n.findIndex(t=>t.branch_id===e);if(r===-1)return[t,...n];let i=[...n];return i[r]=t,i})}return}U(t=>t.filter(t=>t.branch_id!==e))},ye=async()=>{try{let e=await E.validateFields(),t=D?e.name:e.branchName;localStorage.setItem(`agor:lastUsedRepoId`,e.repoId),e.boardId&&localStorage.setItem(`agor:lastUsedBoardId`,e.boardId);let n=mv(e.storage_mode,_),r=n===`clone`&&typeof e.clone_depth==`number`&&e.clone_depth>0?e.clone_depth:void 0;u?.(e.repoId,{name:e.name,ref:t,createBranch:!0,sourceBranch:e.sourceBranch,pullLatest:!0,boardId:e.boardId,storage_mode:n,...r===void 0?{}:{clone_depth:r}}),T(!1),E.resetFields(),O(!0),A(null)}catch(e){console.error(`Validation failed:`,e)}},be=()=>{T(!1),E.resetFields(),O(!0),A(null),M(!1)},xe=[{title:`Branch`,dataIndex:`name`,key:`branch`,render:(e,t)=>{let n=e===t.ref;return(0,Q.jsxs)(G,{style:{minWidth:0,width:`100%`},children:[Xt(t)?(0,Q.jsx)(h,{style:{color:x.colorInfo}}):(0,Q.jsx)(p,{}),(0,Q.jsxs)(G,{orientation:`vertical`,size:0,style:{minWidth:0,flex:1},children:[(0,Q.jsx)(v.Text,{strong:!0,ellipsis:{tooltip:e},style:{display:`block`,maxWidth:`100%`},children:(0,Q.jsx)(Uf,{text:e,query:N})}),!n&&(0,Q.jsx)(v.Text,{code:!0,type:`secondary`,ellipsis:{tooltip:t.ref},style:{display:`block`,maxWidth:`100%`},children:(0,Q.jsx)(Uf,{text:t.ref,query:N})})]})]})}},{title:`Env`,key:`env`,width:120,align:`center`,render:(e,t)=>bv(t,y.find(e=>e.repo_id===t.repo_id),x,{onStartEnvironment:f,onStopEnvironment:m})},{title:`Repo`,dataIndex:`repo_id`,key:`repo_id`,render:e=>(0,Q.jsxs)(G,{children:[(0,Q.jsx)(se,{}),(0,Q.jsx)(v.Text,{children:(0,Q.jsx)(Uf,{text:he(e),query:N})})]})},{title:`Sessions`,key:`sessions`,width:100,render:(e,t)=>{let n=(i.get(t.branch_id)||[]).length;return(0,Q.jsxs)(v.Text,{type:`secondary`,children:[n,` `,n===1?`session`:`sessions`]})}},{title:`Path`,key:`path`,width:60,align:`center`,render:(e,t)=>(0,Q.jsx)(v.Text,{copyable:{text:t.path,tooltips:[`Copy path: ${t.path}`,`Copied!`]}})},{title:`Actions`,key:`actions`,width:144,render:(e,t)=>(0,Q.jsxs)(vm,{children:[!t.archived&&t.board_id&&(0,Q.jsx)(H,{title:`Center map on branch`,children:(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(Pe,{}),onClick:e=>{e.stopPropagation(),C(t)}})}),(0,Q.jsx)(Dh,{archived:t.archived,onToggle:e=>{if(!e){Promise.resolve(c?.(t.branch_id,t.board_id?{boardId:t.board_id}:void 0)).then(()=>{U(e=>e.map(e=>e.branch_id===t.branch_id?{...e,archived:!1,archived_at:void 0,archived_by:void 0}:e))}).catch(()=>{});return}z(t),V(`archive`),R(!0)}}),(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(P,{}),onClick:e=>{e.stopPropagation(),d?.(t)}}),(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(re,{}),danger:!0,onClick:e=>{e.stopPropagation(),z(t),V(`delete`),R(!0)}})]})}],Se=(0,Z.useMemo)(()=>{let e=N.trim().toLowerCase(),r=Array.from(t.values()),i=new Map;for(let e of r)i.set(e.branch_id,e);for(let e of ie)i.has(e.branch_id)||i.set(e.branch_id,e);let a=Array.from(i.values()).sort((e,t)=>new Date(t.created_at).getTime()-new Date(e.created_at).getTime()),o=a;return I===`active`?o=a.filter(e=>!e.archived):I===`archived`?o=a.filter(e=>e.archived):I===`assistants`&&(o=a.filter(e=>!e.archived&&Xt(e))),e?o.filter(t=>{let r=n.get(t.repo_id);return[t.name,t.ref,t.path,String(t.branch_unique_id),r?.name,r?.slug].some(t=>t==null?!1:t.toString().toLowerCase().includes(e))}):o},[I,ie,n,N,t]),Ce=t.size>0||ie.length>0;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(G,{orientation:`vertical`,size:x.sizeUnit*2,style:{marginBottom:x.sizeUnit*2,width:`100%`},children:[(0,Q.jsx)(v.Text,{type:`secondary`,children:`Manage git branches for isolated development contexts across sessions.`}),(0,Q.jsxs)(G,{style:{width:`100%`,display:`flex`,justifyContent:`space-between`},children:[(0,Q.jsxs)(G,{children:[(0,Q.jsx)(J,{allowClear:!0,placeholder:`Search by name, repo, slug, path, or ID`,value:N,onChange:e=>F(e.target.value),style:{maxWidth:x.sizeUnit*40}}),(0,Q.jsx)(l,{value:I,onChange:e=>ee(e),loading:ce&&(I===`archived`||I===`all`),style:{width:120},options:[{value:`active`,label:`Active`},{value:`assistants`,label:`Assistants`},{value:`all`,label:`All`},{value:`archived`,label:`Archived`}]})]}),(0,Q.jsx)(s,{type:`primary`,icon:(0,Q.jsx)(L,{}),onClick:()=>T(!0),disabled:y.length===0,children:`Create Branch`})]})]}),y.length===0&&(0,Q.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`center`,minHeight:400},children:(0,Q.jsx)(fe,{description:`No repositories configured`,children:(0,Q.jsx)(v.Text,{type:`secondary`,children:`Create a repository first in the Repositories tab to enable branches.`})})}),y.length>0&&!Ce&&(0,Q.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`center`,minHeight:400},children:(0,Q.jsx)(fe,{description:`No branches yet`,children:(0,Q.jsx)(v.Text,{type:`secondary`,children:`Branches will appear here once created from sessions or the CLI.`})})}),Ce&&(0,Q.jsx)(ue,{dataSource:Se,columns:xe,rowKey:`branch_id`,pagination:{pageSize:10},size:`small`,onRow:e=>({onClick:()=>d?.(e),style:{cursor:d?`pointer`:`default`}})}),(0,Q.jsx)(a,{title:`Create Branch`,open:w,onOk:ye,onCancel:be,okText:`Create`,okButtonProps:{disabled:!j},children:(0,Q.jsx)(Y,{form:E,layout:`vertical`,onFieldsChange:pe,children:(0,Q.jsx)(_v,{repoById:n,boardById:r,selectedRepoId:k,onRepoChange:_e,defaultBranch:ge(),showBoardSelector:!0,requireBoard:!0,onFormChange:pe,useSameBranchName:D,onUseSameBranchNameChange:O,branchStorageConfig:_})})}),ne&&(0,Q.jsx)(Ah,{open:te,branch:ne,sessionCount:(i.get(ne.branch_id)||[]).length,environmentRunning:ne.environment_instance?.status===`running`,initialMetadataAction:B,onConfirm:e=>{ve(ne.branch_id,e),R(!1),z(null),V(`archive`)},onCancel:()=>{R(!1),z(null),V(`archive`)}})]})};function Sv(e){try{let t=new URL(e);return[`http:`,`https:`,`mailto:`].includes(t.protocol)}catch{return!1}}var{TextArea:Cv}=J,wv=Z.memo(({open:e,card:t,board:n,zoneName:r,zoneColor:i,client:o,onClose:c,onCardUpdated:l,onCardDeleted:f})=>{let{token:p}=X.useToken(),{showSuccess:m,showError:h}=cf(),[g,_]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(``),[T,E]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{t&&(S(t.note||``),w(t.description||``),_(!1),b(!1))},[t]);let D=x!==(t?.note||``)||C!==(t?.description||``),O=(0,Z.useCallback)(async()=>{if(!(!t||!o||!D)){E(!0);try{let e=await o.service(`cards`).patch(t.card_id,{note:x,description:C});l?.(e),_(!1),b(!1),m(`Card saved`)}catch(e){console.error(`Failed to save card:`,e),h(`Failed to save card`)}finally{E(!1)}}},[t,o,x,C,D,l,m,h]),k=(0,Z.useCallback)(async()=>{!t||!o||a.confirm({title:`Archive card?`,content:`This will hide "${t.title}" from the board while preserving its data.`,okText:`Archive`,onOk:async()=>{try{let e=await o.service(`cards`).patch(t.card_id,{archived:!0,archived_at:new Date().toISOString()});l?.(e),c(),m(`Card archived`)}catch(e){console.error(`Failed to archive card:`,e),h(`Failed to archive card`)}}})},[t,o,l,c,m,h]),j=(0,Z.useCallback)(async()=>{!t||!o||a.confirm({title:`Delete card?`,content:`This will permanently delete "${t.title}".`,okText:`Delete`,okType:`danger`,onOk:async()=>{try{await o.service(`cards`).remove(t.card_id),f?.(t.card_id),c(),m(`Card deleted`)}catch(e){console.error(`Failed to delete card:`,e),h(`Failed to delete card`)}}})},[t,o,f,c,m,h]);if(!t)return null;let M=t.effective_emoji,N=t.effective_color||p.colorBorder;return(0,Q.jsxs)(a,{open:e,onCancel:c,width:560,footer:(0,Q.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`},children:[(0,Q.jsxs)(G,{children:[(0,Q.jsx)(Oh,{tooltip:``,size:`middle`,onClick:k,children:`Archive`}),(0,Q.jsx)(s,{danger:!0,icon:(0,Q.jsx)(re,{}),onClick:j,children:`Delete`})]}),(0,Q.jsx)(s,{type:`primary`,icon:(0,Q.jsx)(d,{}),onClick:O,disabled:!D,loading:T,children:`Save`})]}),title:null,styles:{body:{padding:0}},children:[(0,Q.jsxs)(`div`,{style:{padding:`16px 24px`,borderBottom:`1px solid ${p.colorBorderSecondary}`,borderLeft:`4px solid ${N}`,display:`flex`,alignItems:`center`,gap:10},children:[M&&(0,Q.jsx)(`span`,{style:{fontSize:20},children:M}),(0,Q.jsx)(v.Title,{level:5,style:{margin:0,flex:1},children:t.title}),t.url&&Sv(t.url)&&(0,Q.jsxs)(`a`,{href:t.url,target:`_blank`,rel:`noopener noreferrer`,style:{color:p.colorLink},children:[`Open `,(0,Q.jsx)(ae,{})]})]}),(0,Q.jsxs)(`div`,{style:{padding:`12px 24px`,borderBottom:`1px solid ${p.colorBorderSecondary}`,display:`flex`,flexWrap:`wrap`,gap:8},children:[t.card_type&&(0,Q.jsxs)(u,{children:[t.card_type.emoji&&`${t.card_type.emoji} `,t.card_type.name]}),n&&(0,Q.jsxs)(u,{children:[n.icon?`${n.icon} `:``,n.name]}),r&&(0,Q.jsx)(u,{icon:(0,Q.jsx)(Fe,{style:i?{color:i}:void 0}),children:r})]}),(0,Q.jsxs)(`div`,{style:{padding:`12px 24px`,borderBottom:`1px solid ${p.colorBorderSecondary}`},children:[(0,Q.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:8},children:[(0,Q.jsx)(v.Text,{strong:!0,style:{fontSize:12,color:p.colorTextSecondary},children:`Note`}),(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(P,{}),onClick:()=>_(!g),children:g?`Preview`:`Edit`})]}),g?(0,Q.jsx)(Cv,{value:x,onChange:e=>S(e.target.value),placeholder:`Agent's live commentary...`,autoSize:{minRows:2,maxRows:8},style:{background:p.colorFillQuaternary}}):x?(0,Q.jsx)(`div`,{style:{background:p.colorFillQuaternary,borderRadius:p.borderRadiusSM,padding:`8px 12px`},children:(0,Q.jsx)(_h,{content:x,compact:!0,showControls:!1})}):(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12,fontStyle:`italic`},children:`No note`})]}),(0,Q.jsxs)(`div`,{style:{padding:`12px 24px`,borderBottom:`1px solid ${p.colorBorderSecondary}`},children:[(0,Q.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:8},children:[(0,Q.jsx)(v.Text,{strong:!0,style:{fontSize:12,color:p.colorTextSecondary},children:`Description`}),(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(P,{}),onClick:()=>b(!y),children:y?`Preview`:`Edit`})]}),y?(0,Q.jsx)(Cv,{value:C,onChange:e=>w(e.target.value),placeholder:`Stable context about this entity...`,autoSize:{minRows:3,maxRows:12}}):C?(0,Q.jsx)(_h,{content:C,compact:!0,showControls:!1}):(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12,fontStyle:`italic`},children:`No description`})]}),t.data&&Object.keys(t.data).length>0&&(0,Q.jsx)(`div`,{style:{padding:`0 24px 12px`},children:(0,Q.jsx)(A,{ghost:!0,items:[{key:`data`,label:(0,Q.jsx)(v.Text,{strong:!0,style:{fontSize:12,color:p.colorTextSecondary},children:`Data`}),children:(0,Q.jsx)(`pre`,{style:{background:p.colorFillQuaternary,borderRadius:p.borderRadiusSM,padding:`8px 12px`,fontSize:11,overflow:`auto`,maxHeight:300,margin:0},children:JSON.stringify(t.data,null,2)})}]})}),(0,Q.jsxs)(`div`,{style:{padding:`8px 24px 12px`,color:p.colorTextTertiary,fontSize:11},children:[t.created_by&&`Created by: ${t.created_by}`,t.created_at&&` • ${new Date(t.created_at).toLocaleString()}`]})]})}),Tv=({avatar:e,title:t,description:n,style:r})=>(0,Q.jsxs)(`div`,{style:{display:`flex`,flex:1,alignItems:`flex-start`,maxWidth:`100%`,...r},children:[e!=null&&(0,Q.jsx)(`div`,{style:{marginInlineEnd:16,flexShrink:0},children:e}),(0,Q.jsxs)(`div`,{style:{flex:`1 0`,minWidth:0},children:[t!=null&&(0,Q.jsx)(`div`,{style:{marginBottom:4},children:t}),n!=null&&(0,Q.jsx)(`div`,{children:n})]})]}),{Sider:Ev,Content:Dv}=He,Ov=({client:e,cardById:t,cardTypeById:n,boardById:r,boardObjects:i})=>{let{token:o}=X.useToken(),{showSuccess:c,showError:l}=cf(),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(null),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(``),[T]=Y.useForm(),E=(0,Z.useMemo)(()=>Ff(n).sort((e,t)=>e.name.localeCompare(t.name)),[n]),D=(0,Z.useMemo)(()=>Bf(E,x,[e=>e.name,e=>e.emoji,e=>JSON.stringify(e.json_schema??{})]),[E,x]),O=(0,Z.useMemo)(()=>{let e=new Map;if(!i)return e;for(let t of i){if(!t.card_id||!t.zone_id)continue;let n=r.get(t.board_id)?.objects?.[t.zone_id];n&&n.type===`zone`&&e.set(t.card_id,{zoneName:n.label||`Unknown Zone`,zoneColor:n.borderColor||n.color})}return e},[i,r]),k=u?n.get(u)??null:null,A=(0,Z.useMemo)(()=>u?Bf(Ff(t).filter(e=>e.card_type_id===u&&!e.archived).sort((e,t)=>e.title.localeCompare(t.title)),C,[e=>e.title,e=>{let t=r.get(e.board_id);return[t?.name,t?.slug,e.board_id]},e=>O.get(e.card_id)?.zoneName,e=>JSON.stringify(e.data??{})]):[],[t,u,C,r,O]),j=async()=>{if(e)try{let t=await T.validateFields(),n=typeof t.color==`string`?t.color:t.color?.toHexString?.()??void 0;await e.service(`card-types`).create({name:t.name,emoji:t.emoji||void 0,color:n||void 0,json_schema:t.json_schema?JSON.parse(t.json_schema):void 0}),T.resetFields(),p(!1),c(`Card type created`)}catch(e){if(e&&typeof e==`object`&&`errorFields`in e)return;console.error(`Failed to create card type:`,e),l(`Failed to create card type`)}},M=async()=>{if(!(!e||!g))try{let t=await T.validateFields(),n=typeof t.color==`string`?t.color:t.color?.toHexString?.()??void 0;await e.service(`card-types`).patch(g.card_type_id,{name:t.name,emoji:t.emoji||void 0,color:n||void 0,json_schema:t.json_schema?JSON.parse(t.json_schema):void 0}),T.resetFields(),h(!1),_(null),c(`Card type updated`)}catch(e){if(e&&typeof e==`object`&&`errorFields`in e)return;console.error(`Failed to update card type:`,e),l(`Failed to update card type`)}},N=async t=>{if(e)try{await e.service(`card-types`).remove(t),u===t&&d(null),c(`Card type deleted`)}catch(e){console.error(`Failed to delete card type:`,e),l(`Failed to delete card type`)}},F=e=>{_(e),T.setFieldsValue({name:e.name,emoji:e.emoji,color:e.color,json_schema:e.json_schema?JSON.stringify(e.json_schema,null,2):``}),h(!0)},I=[{title:`Title`,dataIndex:`title`,key:`title`,render:(e,t)=>(0,Q.jsxs)(G,{children:[t.effective_emoji&&(0,Q.jsx)(`span`,{children:t.effective_emoji}),(0,Q.jsx)(v.Text,{children:(0,Q.jsx)(Uf,{text:e,query:C})})]})},{title:`Board`,dataIndex:`board_id`,key:`board`,width:180,render:e=>{let t=r.get(e);return(0,Q.jsx)(v.Text,{type:`secondary`,children:t?(0,Q.jsx)(Uf,{text:`${t.icon?`${t.icon} `:``}${t.name}`,query:C}):`—`})}},{title:`Zone`,key:`zone`,width:180,render:(e,t)=>{let n=O.get(t.card_id);return n?(0,Q.jsxs)(G,{size:4,children:[n.zoneColor&&(0,Q.jsx)(Fe,{style:{color:n.zoneColor,fontSize:12}}),(0,Q.jsx)(v.Text,{style:{fontSize:13},children:(0,Q.jsx)(Uf,{text:n.zoneName,query:C})})]}):(0,Q.jsx)(v.Text,{type:`secondary`,children:`—`})}}],ee=y?r.get(y.board_id)??null:null,te=e=>{b(e)},R=e=>{b(null)},ne=(0,Q.jsxs)(Y,{form:T,layout:`vertical`,style:{marginTop:16},children:[(0,Q.jsx)(Y.Item,{label:`Name`,style:{marginBottom:24},children:(0,Q.jsxs)(et,{gap:8,children:[(0,Q.jsx)(Y.Item,{name:`emoji`,noStyle:!0,children:(0,Q.jsx)(ll,{form:T,fieldName:`emoji`,defaultEmoji:`📋`})}),(0,Q.jsx)(Y.Item,{name:`name`,noStyle:!0,rules:[{required:!0,message:`Name is required`}],children:(0,Q.jsx)(J,{placeholder:`e.g. Support Ticket`,style:{flex:1}})})]})}),(0,Q.jsx)(Y.Item,{name:`color`,label:`Color`,children:(0,Q.jsx)(be,{showText:!0,format:`hex`,allowClear:!0})}),(0,Q.jsx)(Y.Item,{name:`json_schema`,label:`JSON Schema (optional)`,help:`Define a JSON Schema to validate card data`,rules:[{validator:uv}],children:(0,Q.jsx)(lv,{placeholder:`{"type": "object", "properties": {...}}`,rows:4})})]});return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{style:{marginBottom:16,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,Q.jsxs)(G,{children:[(0,Q.jsx)(v.Title,{level:5,style:{margin:0},children:`Cards`}),(0,Q.jsx)(`span`,{style:{fontSize:11,fontWeight:600,padding:`1px 6px`,borderRadius:4,background:o.colorWarningBg,color:o.colorWarningText,border:`1px solid ${o.colorWarningBorder}`},children:`Beta`})]}),(0,Q.jsx)(v.Text,{type:`secondary`,children:`Manage card types and view cards across all boards`})]}),(0,Q.jsxs)(He,{style:{background:`transparent`,height:`calc(100% - 60px)`,minHeight:400},children:[(0,Q.jsxs)(Ev,{width:260,style:{background:o.colorBgElevated,borderRadius:o.borderRadiusLG,border:`1px solid ${o.colorBorderSecondary}`,overflow:`auto`,marginRight:16},children:[(0,Q.jsxs)(`div`,{style:{padding:`12px 16px`,borderBottom:`1px solid ${o.colorBorderSecondary}`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,Q.jsx)(v.Text,{strong:!0,children:`Card Types`}),(0,Q.jsx)(s,{type:`primary`,size:`small`,icon:(0,Q.jsx)(L,{}),onClick:()=>{T.resetFields(),p(!0)},children:`New`})]}),E.length>0&&(0,Q.jsx)(`div`,{style:{padding:`8px 12px`},children:(0,Q.jsx)(J,{allowClear:!0,size:`small`,placeholder:`Search types`,value:x,onChange:e=>S(e.target.value)})}),E.length===0?(0,Q.jsx)(`div`,{style:{padding:24,textAlign:`center`},children:(0,Q.jsx)(fe,{image:fe.PRESENTED_IMAGE_SIMPLE,description:`No card types yet`})}):D.map(e=>(0,Q.jsxs)(`div`,{onClick:()=>d(e.card_type_id),style:{padding:`8px 16px`,cursor:`pointer`,display:`flex`,alignItems:`center`,gap:16,background:u===e.card_type_id?o.colorBgTextHover:`transparent`,borderLeft:u===e.card_type_id?`3px solid ${e.color||o.colorPrimary}`:`3px solid transparent`},children:[(0,Q.jsx)(Tv,{avatar:(0,Q.jsx)(`span`,{style:{fontSize:18},children:e.emoji||`📋`}),title:(0,Q.jsx)(v.Text,{style:{fontSize:13},ellipsis:!0,children:(0,Q.jsx)(Uf,{text:e.name,query:x})})}),(0,Q.jsxs)(vm,{onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(P,{}),onClick:t=>{t.stopPropagation(),F(e)}}),(0,Q.jsx)(B,{title:`Delete card type?`,description:`Cards using this type will become untyped.`,onConfirm:t=>{t?.stopPropagation(),N(e.card_type_id)},onCancel:e=>e?.stopPropagation(),children:(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(re,{}),danger:!0,onClick:e=>e.stopPropagation()})})]})]},e.card_type_id))]}),(0,Q.jsx)(Dv,{style:{minWidth:0},children:k?(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{style:{marginBottom:12,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,Q.jsxs)(G,{children:[(0,Q.jsx)(`span`,{style:{fontSize:20},children:k.emoji||`📋`}),(0,Q.jsx)(v.Title,{level:5,style:{margin:0},children:k.name}),(0,Q.jsxs)(v.Text,{type:`secondary`,children:[`(`,A.length,` card`,A.length===1?``:`s`,`)`]})]}),(0,Q.jsx)(J,{allowClear:!0,placeholder:`Search title, board, zone, or data`,value:C,onChange:e=>w(e.target.value),style:{width:300}})]}),(0,Q.jsx)(ue,{dataSource:A,columns:I,rowKey:`card_id`,size:`small`,pagination:{pageSize:20,hideOnSinglePage:!0},onRow:e=>({onClick:()=>b(e),style:{cursor:`pointer`}}),locale:{emptyText:(0,Q.jsx)(fe,{image:fe.PRESENTED_IMAGE_SIMPLE,description:`No cards of this type yet`})}})]}):(0,Q.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`center`,height:`100%`,minHeight:300},children:(0,Q.jsx)(fe,{image:fe.PRESENTED_IMAGE_SIMPLE,description:E.length===0?`Create a card type to get started`:`Select a card type to view its cards`})})})]}),(0,Q.jsx)(a,{title:`Create Card Type`,open:f,onOk:j,onCancel:()=>{T.resetFields(),p(!1)},okText:`Create`,children:ne}),(0,Q.jsx)(a,{title:`Edit Card Type`,open:m,onOk:M,onCancel:()=>{T.resetFields(),h(!1),_(null)},okText:`Save`,children:ne}),(0,Q.jsx)(wv,{open:!!y,card:y,board:ee,client:e,onClose:()=>b(null),onCardUpdated:te,onCardDeleted:R})]})};function kv(e){return e.publicChannels||e.privateChannels||e.groupDms}function Av(e){return[...new Set(e)].sort()}function jv(e){let t=[`chat:write`,`im:history`,`im:read`,`users:read`];return kv(e)&&t.push(`app_mentions:read`),e.publicChannels&&t.push(`channels:history`,`channels:read`),e.privateChannels&&t.push(`groups:history`,`groups:read`),e.groupDms&&t.push(`mpim:history`,`mpim:read`),e.alignUsers&&t.push(`users:read.email`),e.outbound&&t.push(`chat:write.public`,`channels:read`,`groups:read`,`im:write`,`users:read.email`),Av(t)}function Mv(e){let t=[`message.im`];return kv(e)&&t.push(`app_mention`),Av(t)}function Nv(e){return{display_information:{name:e.appName},features:{bot_user:{display_name:e.botDisplayName??e.appName,always_online:!0},app_home:{messages_tab_enabled:!0,messages_tab_read_only_enabled:!1,home_tab_enabled:!1}},oauth_config:{scopes:{bot:jv(e)}},settings:{event_subscriptions:{bot_events:Mv(e)},interactivity:{is_enabled:!1},org_deploy_enabled:!1,socket_mode_enabled:!0,token_rotation_enabled:!1}}}var Pv=({branchById:e,value:t,onChange:n,placeholder:r=`Select a branch`,disabled:i=!1,includeArchivedLabel:a=!0})=>(0,Q.jsx)(l,{value:t,onChange:n,placeholder:r,disabled:i,showSearch:!0,optionFilterProp:`label`,options:(0,Z.useMemo)(()=>Array.from(e.values()).sort((e,t)=>(e.name||e.ref||e.branch_id).localeCompare(t.name||t.ref||t.branch_id)).map(e=>({value:e.branch_id,label:`${e.name||e.ref||e.branch_id}${a&&e.archived?` (archived)`:``}`})),[a,e])}),Fv=({userById:e,placeholder:t=`Select a user`,...n})=>(0,Q.jsx)(l,{...n,placeholder:t,showSearch:!0,optionFilterProp:`children`,children:Array.from(e.values()).sort((e,t)=>(e.name||e.email||e.user_id).localeCompare(t.name||t.email||t.user_id)).map(e=>(0,Q.jsx)(l.Option,{value:e.user_id,children:e.name||e.email||e.user_id},e.user_id))}),Iv=[{value:`slack`,label:`Slack`,icon:(0,Q.jsx)(ct,{})},{value:`github`,label:`GitHub`,icon:(0,Q.jsx)(r,{})},{value:`teams`,label:`Microsoft Teams`,icon:(0,Q.jsx)(W,{})},{value:`discord`,label:`Discord`,icon:(0,Q.jsx)(V,{})},{value:`whatsapp`,label:`WhatsApp`,icon:(0,Q.jsx)(V,{})},{value:`telegram`,label:`Telegram`,icon:(0,Q.jsx)(V,{})}];function Lv(e){switch(e){case`slack`:return(0,Q.jsx)(ct,{});case`github`:return(0,Q.jsx)(r,{});case`teams`:return(0,Q.jsx)(W,{});default:return(0,Q.jsx)(V,{})}}function Rv(e){switch(e){case`slack`:return`purple`;case`github`:return`default`;case`teams`:return`geekblue`;case`discord`:return`blue`;case`whatsapp`:return`green`;case`telegram`:return`cyan`;default:return`default`}}var zv=({icon:e,title:t,subtitle:n})=>(0,Q.jsxs)(G,{size:`small`,children:[e,(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(v.Text,{strong:!0,children:t}),n&&(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12,marginLeft:8},children:n})]})]}),Bv=e=>e?`align users`:`run as selected user`,Vv=({alignFieldName:e,alignLabel:t,alignDescription:n,alignUsers:r,alignedContent:i,userById:a})=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:12},children:`Choose which Agor user identity gateway-created sessions run as.`}),(0,Q.jsx)(Y.Item,{name:e,initialValue:!1,children:(0,Q.jsx)(K.Group,{style:{width:`100%`},children:(0,Q.jsxs)(G,{orientation:`vertical`,style:{width:`100%`},children:[(0,Q.jsx)(K,{value:!0,children:(0,Q.jsxs)(G,{orientation:`vertical`,size:0,children:[(0,Q.jsx)(v.Text,{children:t}),(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12},children:n})]})}),(0,Q.jsx)(K,{value:!1,children:(0,Q.jsxs)(G,{orientation:`vertical`,size:0,children:[(0,Q.jsx)(v.Text,{children:`Run as selected user`}),(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12},children:`Every message uses one configured Agor user.`})]})})]})})}),r?i:(0,Q.jsx)(Y.Item,{label:`Run as`,name:`agor_user_id`,rules:[{required:!0,message:`Please select a user`}],tooltip:`All sessions from this channel will run as this Agor user`,children:(0,Q.jsx)(Fv,{userById:a})})]}),Hv=({value:e=[],onChange:t})=>{let n=(0,Z.useRef)(0),r=(0,Z.useRef)([]);for(;r.current.length<e.length;)r.current.push(n.current++);r.current.length>e.length&&(r.current.length=e.length);let i=()=>{r.current.push(n.current++),t?.([...e,{key:``,value:``,forceOverride:!1}])},a=(n,r,i)=>{let a=e.map((e,t)=>t===n?{...e,[r]:i}:e);t?.(a)},o=n=>{r.current.splice(n,1),t?.(e.filter((e,t)=>t!==n))};return(0,Q.jsxs)(`div`,{children:[e.map((e,t)=>(0,Q.jsxs)(`div`,{style:{display:`flex`,gap:8,marginBottom:8,alignItems:`flex-start`},children:[(0,Q.jsx)(J,{placeholder:`KEY_NAME`,value:e.key,onChange:e=>a(t,`key`,e.target.value),style:{flex:`0 0 160px`,fontFamily:`monospace`,fontSize:12}}),e.value===`••••••••`?(0,Q.jsx)(J,{placeholder:`click to replace value`,value:``,onFocus:()=>a(t,`value`,``),readOnly:!0,style:{flex:1,fontFamily:`monospace`,fontSize:12,color:`transparent`,textShadow:`0 0 6px rgba(255,255,255,0.5)`}}):(0,Q.jsx)(J.Password,{placeholder:`value`,value:e.value,onChange:e=>a(t,`value`,e.target.value),style:{flex:1,fontFamily:`monospace`,fontSize:12}}),(0,Q.jsx)(H,{title:`Force override: always use this value, even if the user has their own`,children:(0,Q.jsx)(U,{checked:e.forceOverride,onChange:e=>a(t,`forceOverride`,e.target.checked),style:{marginTop:5},children:(0,Q.jsx)(v.Text,{style:{fontSize:11,whiteSpace:`nowrap`},children:`Force`})})}),(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(re,{}),danger:!0,onClick:()=>o(t),style:{marginTop:2}})]},r.current[t])),(0,Q.jsx)(s,{type:`dashed`,size:`small`,icon:(0,Q.jsx)(L,{}),onClick:i,block:!0,children:`Add Variable`}),e.length>0&&(0,Q.jsxs)(v.Text,{type:`secondary`,style:{fontSize:11,display:`block`,marginTop:8},children:[(0,Q.jsx)(S,{style:{marginRight:4}}),(0,Q.jsx)(`strong`,{children:`Fallback`}),` (default): used only when the user hasn't set this key.`,` `,(0,Q.jsx)(`strong`,{children:`Force`}),`: always overrides the user's value.`]})]})};function Uv(e){switch(e){case`slack`:return[{title:`Channel`},{title:`Options`},{title:`Create app`},{title:`Tokens & test`}];case`github`:return[{title:`Channel`},{title:`Create app`},{title:`Credentials`},{title:`Configure`}];case`teams`:return[{title:`Channel`},{title:`Setup`}];default:return[{title:`Channel`}]}}function Wv(e,t,n){if(t===0){let t=[`name`,`target_branch_id`,`channel_type`];return e!==`slack`&&e!==`github`&&t.push(`agor_user_id`),t}if(e===`slack`&&t===1){let e=[`slack_app_name`];return n||e.push(`agor_user_id`),e}return e===`github`&&t===2?[`github_app_id`,`github_private_key`]:[]}var Gv=new Set([`bot_token`,`app_token`,`slack_app_name`,`enable_channels`,`enable_groups`,`enable_mpim`,`align_slack_users`,`outbound_enabled`,`slack_public_scope`,`allowed_channel_ids`]);async function Kv(e){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.focus(),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}var qv=({result:e})=>{let t=e.failures.length>0||e.notVerifiable.length>0;return(0,Q.jsxs)(`div`,{style:{marginBottom:16},children:[(0,Q.jsx)(z,{type:e.ok?`success`:`error`,showIcon:!0,icon:e.ok?(0,Q.jsx)(st,{}):(0,Q.jsx)(ut,{}),title:e.ok?`Connection succeeded`:`Connection failed`,description:(0,Q.jsxs)(`div`,{style:{fontSize:12},children:[e.team&&(0,Q.jsxs)(`div`,{children:[`Team: `,(0,Q.jsx)(`strong`,{children:e.team.name}),` (`,e.team.id,`)`]}),e.bot&&(0,Q.jsxs)(`div`,{children:[`Bot: `,(0,Q.jsx)(`strong`,{children:e.bot.name}),` (`,e.bot.userId,`)`]}),(0,Q.jsxs)(`div`,{children:[`App token (Socket Mode):`,` `,(0,Q.jsx)(`strong`,{children:e.appTokenValid?`valid`:`not verified`})]}),e.channelAccess&&e.channelAccess.length>0&&(0,Q.jsxs)(`div`,{style:{marginTop:4},children:[`Sampled channel access:`,(0,Q.jsx)(`ul`,{style:{margin:`4px 0 0`,paddingLeft:18},children:e.channelAccess.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`code`,{children:e.channelId}),`: `,e.ok?`ok`:`no access`]},e.channelId))})]})]}),style:{marginBottom:t?12:0}}),e.failures.length>0&&(0,Q.jsx)(z,{type:`error`,showIcon:!0,title:`Failures`,description:(0,Q.jsx)(`ul`,{style:{margin:`4px 0 0`,paddingLeft:18,fontSize:12},children:e.failures.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`strong`,{children:e.capability}),`: `,e.reason,e.needed?` (needs ${e.needed})`:``]},`${e.capability}:${e.reason}`))}),style:{marginBottom:e.notVerifiable.length>0?12:0}}),e.notVerifiable.length>0&&(0,Q.jsx)(z,{type:`warning`,showIcon:!0,icon:(0,Q.jsx)(qe,{}),title:`Not verifiable from here`,description:(0,Q.jsxs)(`div`,{style:{fontSize:12},children:[(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12},children:`A green result does not guarantee these — confirm them in Slack:`}),(0,Q.jsx)(`ul`,{style:{margin:`4px 0 0`,paddingLeft:18},children:e.notVerifiable.map(e=>(0,Q.jsx)(`li`,{children:e},e))})]}),style:{fontSize:12}})]})},Jv=({options:e})=>{let{token:t}=X.useToken(),{showError:n}=cf(),[r,i]=(0,Z.useState)(!1),a=(0,Z.useMemo)(()=>JSON.stringify(Nv(e),null,2),[e]);return(0,Z.useEffect)(()=>{i(!1)},[a]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(v.Text,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:12},children:[`The recommended manifest for this channel's current options — the desired Slack app configuration, not a readout of your app's live settings. Paste it into`,` `,(0,Q.jsx)(`strong`,{children:`App Manifest`}),` in your Slack app to align its scopes and events.`]}),(0,Q.jsx)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,marginBottom:8},children:(0,Q.jsx)(s,{size:`small`,icon:r?(0,Q.jsx)(st,{}):(0,Q.jsx)(E,{}),onClick:async()=>{await Kv(a)?i(!0):n(`Copy failed — select the manifest text and copy it manually.`)},children:r?`Copied`:`Copy app manifest`})}),(0,Q.jsx)(`pre`,{style:{background:t.colorBgContainer,border:`1px solid ${t.colorBorder}`,borderRadius:t.borderRadius,padding:12,margin:0,maxHeight:280,overflow:`auto`,fontSize:11,lineHeight:1.5,fontFamily:`monospace`},children:a})]})};function Yv(e,t){let n=e?.[t];return n===`••••••••`||typeof n==`string`&&n.length>0}var Xv=({stored:e})=>e?(0,Q.jsx)(u,{color:`green`,icon:(0,Q.jsx)(st,{}),style:{marginInlineStart:8},children:`Stored`}):(0,Q.jsx)(u,{style:{marginInlineStart:8},children:`Not set`}),Zv=({form:e,userById:t,mcpServerById:n,selectedAgent:r,onAgentChange:i,step:a,testResult:o,testLoading:c,onTest:d})=>{let{token:f}=X.useToken(),{showError:p}=cf(),[m,h]=(0,Z.useState)(!1),g=Y.useWatch(`slack_app_name`,e)??``,_=Y.useWatch(`enable_channels`,e)??!1,y=Y.useWatch(`enable_groups`,e)??!1,b=Y.useWatch(`enable_mpim`,e)??!1,x=Y.useWatch(`align_slack_users`,e)??!1,C=Y.useWatch(`outbound_enabled`,e)??!1,w=Y.useWatch(`slack_public_scope`,e)??`all`,T=(0,Z.useMemo)(()=>({appName:g||`Agor`,publicChannels:_,privateChannels:y,groupDms:b,alignUsers:x,outbound:C}),[g,_,y,b,x,C]),D=(0,Z.useMemo)(()=>JSON.stringify(Nv(T),null,2),[T]),O=(0,Z.useMemo)(()=>jv(T),[T]),k=(0,Z.useMemo)(()=>Mv(T),[T]);(0,Z.useEffect)(()=>{h(!1)},[D]);let M=(0,Q.jsx)(`pre`,{style:{background:f.colorBgContainer,border:`1px solid ${f.colorBorder}`,borderRadius:f.borderRadius,padding:12,margin:`0 0 16px`,maxHeight:280,overflow:`auto`,fontSize:11,lineHeight:1.5,fontFamily:`monospace`},children:D}),N=(0,Q.jsxs)(`div`,{style:{marginBottom:16},children:[(0,Q.jsxs)(v.Text,{strong:!0,style:{fontSize:12},children:[`Bot scopes (`,O.length,`)`]}),(0,Q.jsx)(`div`,{style:{marginTop:6},children:O.map(e=>(0,Q.jsx)(u,{style:{marginBottom:4,fontFamily:`monospace`,fontSize:11},children:e},e))}),(0,Q.jsxs)(v.Text,{strong:!0,style:{fontSize:12,display:`block`,marginTop:8},children:[`Event subscriptions (`,k.length,`)`]}),(0,Q.jsx)(`div`,{style:{marginTop:6},children:k.map(e=>(0,Q.jsx)(u,{color:`blue`,style:{marginBottom:4,fontFamily:`monospace`,fontSize:11},children:e},e))})]});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{style:{display:a===0?void 0:`none`},children:[(0,Q.jsx)(v.Paragraph,{type:`secondary`,style:{fontSize:13},children:`Choose what the bot can do. Your selections build a Slack app manifest below — paste it into Slack in the next step so every scope and event is preconfigured for you.`}),(0,Q.jsx)(Y.Item,{label:`App Name`,name:`slack_app_name`,initialValue:`Agor`,rules:[{required:!0,message:`Enter a name for the Slack app`}],tooltip:`Display name for the Slack app created from the manifest`,children:(0,Q.jsx)(J,{placeholder:`Agor`})}),(0,Q.jsxs)(`div`,{style:{marginBottom:16},children:[(0,Q.jsx)(v.Text,{strong:!0,style:{fontSize:13},children:`Surfaces`}),(0,Q.jsx)(v.Paragraph,{type:`secondary`,style:{fontSize:12,margin:`4px 0 12px`},children:`Where the bot listens for messages.`}),(0,Q.jsxs)(`div`,{style:{marginBottom:8},children:[(0,Q.jsx)(U,{checked:!0,disabled:!0,children:`Direct messages`}),(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12,marginLeft:8},children:`always on`})]}),(0,Q.jsx)(`div`,{style:{marginBottom:8},children:(0,Q.jsx)(Y.Item,{name:`enable_channels`,valuePropName:`checked`,initialValue:!1,noStyle:!0,children:(0,Q.jsx)(U,{children:`Public channels`})})}),_&&(0,Q.jsxs)(`div`,{style:{margin:`0 0 8px 24px`},children:[(0,Q.jsx)(Y.Item,{name:`slack_public_scope`,initialValue:`all`,noStyle:!0,children:(0,Q.jsx)(K.Group,{children:(0,Q.jsxs)(G,{orientation:`vertical`,size:4,children:[(0,Q.jsx)(K,{value:`all`,children:`All public channels the bot is added to`}),(0,Q.jsx)(K,{value:`specific`,children:`Specific channels only`})]})})}),w===`specific`&&(0,Q.jsx)(Y.Item,{name:`allowed_channel_ids`,style:{marginTop:8,marginBottom:0},tooltip:`Slack channel IDs (e.g., C01ABC123XY). Press Enter to add each ID.`,children:(0,Q.jsx)(l,{mode:`tags`,placeholder:`C01ABC123XY`,style:{width:`100%`},tokenSeparators:[`,`,` `]})})]}),(0,Q.jsx)(`div`,{style:{marginBottom:8},children:(0,Q.jsx)(Y.Item,{name:`enable_groups`,valuePropName:`checked`,initialValue:!1,noStyle:!0,children:(0,Q.jsx)(U,{children:`Private channels`})})}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(Y.Item,{name:`enable_mpim`,valuePropName:`checked`,initialValue:!1,noStyle:!0,children:(0,Q.jsx)(U,{children:`Group DMs`})})})]}),(0,Q.jsx)(Y.Item,{label:`Align Slack users`,name:`align_slack_users`,valuePropName:`checked`,initialValue:!1,tooltip:`Match each Slack profile email to an Agor user. Unmatched users are rejected.`,children:(0,Q.jsx)(j,{})}),x?(0,Q.jsx)(z,{type:`info`,showIcon:!0,title:`Requires users:read.email scope`,description:`Added to the manifest automatically so Agor can match Slack profiles by email.`,style:{fontSize:12,marginBottom:16}}):(0,Q.jsx)(Y.Item,{label:`Run as`,name:`agor_user_id`,rules:[{required:!0,message:`Please select a user`}],tooltip:`All sessions from this channel run as this Agor user`,children:(0,Q.jsx)(Fv,{userById:t})}),(0,Q.jsx)(Y.Item,{label:`Enable outbound sends`,name:`outbound_enabled`,valuePropName:`checked`,initialValue:!1,tooltip:`Allow authorized agents to send proactive Slack messages through this gateway.`,children:(0,Q.jsx)(j,{})}),C&&(0,Q.jsx)(Y.Item,{label:`Default outbound target`,name:`default_outbound_target`,tooltip:`Optional. Used when the agent omits a target. Examples: #project-updates, channel:C01ABC123, user@example.com.`,children:(0,Q.jsx)(J,{placeholder:`#project-updates, channel:C01ABC123, or user@example.com`})}),(0,Q.jsx)(v.Text,{strong:!0,style:{fontSize:13,display:`block`,marginBottom:8},children:`Manifest preview`}),M,N]}),(0,Q.jsxs)(`div`,{style:{display:a===1?void 0:`none`},children:[(0,Q.jsx)(v.Paragraph,{type:`secondary`,style:{fontSize:13},children:`Create the Slack app from this manifest. Slack preconfigures every scope and event for you — no manual scope entry needed.`}),(0,Q.jsx)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,marginBottom:8},children:(0,Q.jsx)(s,{size:`small`,icon:m?(0,Q.jsx)(st,{}):(0,Q.jsx)(E,{}),onClick:async()=>{await Kv(D)?h(!0):p(`Copy failed — select the manifest text and copy it manually.`)},children:m?`Copied`:`Copy manifest`})}),M,(0,Q.jsxs)(`ol`,{style:{paddingLeft:20,margin:`0 0 16px`,fontSize:13},children:[(0,Q.jsxs)(`li`,{children:[`Open`,` `,(0,Q.jsx)(v.Link,{href:`https://api.slack.com/apps?new_app=1`,target:`_blank`,rel:`noopener noreferrer`,children:`api.slack.com/apps`}),` `,`→ `,(0,Q.jsx)(`strong`,{children:`Create New App`}),` → `,(0,Q.jsx)(`strong`,{children:`From a manifest`}),`.`]}),(0,Q.jsxs)(`li`,{children:[`Pick your workspace, paste the manifest above, and click `,(0,Q.jsx)(`strong`,{children:`Create`}),`.`]}),(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`strong`,{children:`Install`}),` the app to your workspace when prompted.`]}),(0,Q.jsxs)(`li`,{children:[`Go to `,(0,Q.jsx)(`strong`,{children:`Basic Information → App-Level Tokens`}),` and generate a token with the `,(0,Q.jsx)(`code`,{children:`connections:write`}),` scope — this is your `,(0,Q.jsx)(`code`,{children:`xapp-`}),` token.`]})]})]}),(0,Q.jsxs)(`div`,{style:{display:a===2?void 0:`none`},children:[(0,Q.jsx)(z,{type:`info`,showIcon:!0,title:`Where to find these tokens`,description:(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`strong`,{children:`Bot token (xoxb-)`}),`: OAuth & Permissions → Bot User OAuth Token.`,(0,Q.jsx)(`br`,{}),(0,Q.jsx)(`strong`,{children:`App token (xapp-)`}),`: Basic Information → App-Level Tokens.`]}),style:{marginBottom:16,fontSize:12}}),(0,Q.jsx)(Y.Item,{label:`Bot Token`,name:`bot_token`,rules:[{required:!0,message:`Bot token is required`}],tooltip:`OAuth & Permissions → Bot User OAuth Token (xoxb-...)`,children:(0,Q.jsx)(J.Password,{placeholder:`xoxb-...`})}),(0,Q.jsx)(Y.Item,{label:`App Token`,name:`app_token`,rules:[{required:!0,message:`App token is required`}],tooltip:`Basic Information → App-Level Tokens (xapp-...)`,children:(0,Q.jsx)(J.Password,{placeholder:`xapp-...`})}),(0,Q.jsx)(s,{icon:(0,Q.jsx)($e,{}),loading:c,onClick:async()=>{try{await e.validateFields([`bot_token`,`app_token`])}catch{return}d()},style:{marginBottom:12},children:`Test connection`}),o&&(0,Q.jsx)(qv,{result:o}),!o?.ok&&(0,Q.jsx)(z,{type:`warning`,showIcon:!0,title:`Testing is optional`,description:`Slack can't be fully verified up front. You can save now and confirm by sending the bot a message — but an untested channel may not work.`,style:{marginBottom:16,fontSize:12}}),(0,Q.jsx)(A,{ghost:!0,destroyOnHidden:!1,style:{marginLeft:-16,marginRight:-16},items:[{key:`agentic-tool-config`,label:(0,Q.jsx)(zv,{icon:(0,Q.jsx)($e,{}),title:`Agent Configuration`,subtitle:r}),children:(0,Q.jsxs)(G,{orientation:`vertical`,size:`middle`,style:{width:`100%`},children:[(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12},children:`Configure which agent and settings to use for sessions created from this channel.`}),(0,Q.jsx)(Wa,{agents:Ka,selectedAgentId:r,onSelect:i,columns:2,showHelperText:!1,showComparisonLink:!1}),(0,Q.jsx)(n_,{agenticTool:r,mcpServerById:n,showHelpText:!1})]})},{key:`env-vars`,label:(0,Q.jsx)(zv,{icon:(0,Q.jsx)(S,{}),title:`Environment Variables`,subtitle:`channel-level secrets`}),children:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:12},children:`Define environment variables for sessions created from this channel. Useful for service account tokens or API keys for MCP servers.`}),(0,Q.jsx)(Y.Item,{name:`envVars`,noStyle:!0,children:(0,Q.jsx)(Hv,{})})]})}]})]})]})},Qv=({form:e,mode:t,channelType:n,onChannelTypeChange:i,branchById:a,userById:o,mcpServerById:c,selectedAgent:d,onAgentChange:f,editingChannel:p,createStep:m,githubLoading:h,githubError:g,slackTestResult:_,slackTestLoading:y,onSlackTest:b})=>{let{showError:x}=cf(),C=p?.config,w=!!(Y.useWatch(`enable_channels`,e)??C?.enable_channels),T=!!(Y.useWatch(`enable_groups`,e)??C?.enable_groups),E=!!(Y.useWatch(`enable_mpim`,e)??C?.enable_mpim),D=!!(Y.useWatch(`align_slack_users`,e)??C?.align_slack_users),O=!!(Y.useWatch(`outbound_enabled`,e)??C?.outbound_enabled),k=Y.useWatch(`github_align_users`,e)??!1,M=Y.useWatch(`name`,e)??p?.name,N=w||T||E,P=(0,Z.useMemo)(()=>({appName:M||`Agor`,publicChannels:w,privateChannels:T,groupDms:E,alignUsers:D,outbound:O}),[M,w,T,E,D,O]),F=(0,Z.useMemo)(()=>jv(P),[P]),I=(0,Z.useMemo)(()=>Mv(P),[P]),ee=Yv(C,`bot_token`),L=Yv(C,`app_token`);return(0,Q.jsxs)(Q.Fragment,{children:[t===`create`&&(0,Q.jsx)(Je,{current:m,size:`small`,items:Uv(n),style:{marginBottom:16,flexShrink:0}}),(0,Q.jsxs)(`div`,{style:t===`create`?{maxHeight:`56vh`,overflowY:`auto`,overflowX:`hidden`,paddingInline:16,marginInline:-16}:void 0,children:[(0,Q.jsxs)(`div`,{style:{display:t===`create`&&m!==0?`none`:void 0},children:[(0,Q.jsx)(Y.Item,{label:`Channel Type`,name:`channel_type`,initialValue:t===`create`?`slack`:void 0,rules:[{required:!0}],children:(0,Q.jsx)(l,{onChange:e=>i(e),children:Iv.map(e=>(0,Q.jsx)(l.Option,{value:e.value,children:(0,Q.jsxs)(G,{children:[e.icon,e.label]})},e.value))})}),(0,Q.jsx)(Y.Item,{label:`Name`,name:`name`,rules:[{required:!0,message:`Please enter a channel name`}],children:(0,Q.jsx)(J,{placeholder:`e.g., Team Slack, Personal Discord`})}),(0,Q.jsx)(Y.Item,{label:`Target Branch`,name:`target_branch_id`,rules:[{required:!0,message:`Please select a target branch`}],tooltip:t===`create`?`New sessions from this channel will be created in this branch`:void 0,children:(0,Q.jsx)(Pv,{branchById:a})}),n!==`slack`&&n!==`github`&&(0,Q.jsx)(Y.Item,{label:`Post messages as`,name:`agor_user_id`,rules:[{required:!0,message:`Please select a user`}],tooltip:`Sessions from this channel will run as this Agor user`,children:(0,Q.jsx)(Fv,{userById:o})}),(0,Q.jsx)(Y.Item,{label:`Enabled`,name:`enabled`,valuePropName:`checked`,initialValue:t===`create`?!0:void 0,children:(0,Q.jsx)(j,{})}),n!==`slack`&&n!==`github`&&n!==`teams`&&(0,Q.jsx)(z,{title:`${n.charAt(0).toUpperCase()+n.slice(1)} support coming soon`,description:`This platform integration is not yet available. Slack, GitHub, and Microsoft Teams are currently supported.`,type:`info`,showIcon:!0,style:{marginBottom:16}})]}),n===`github`&&(0,Q.jsxs)(Q.Fragment,{children:[h&&(0,Q.jsxs)(`div`,{style:{textAlign:`center`,padding:`24px 0`},children:[(0,Q.jsx)(Ze,{indicator:(0,Q.jsx)(me,{spin:!0})}),(0,Q.jsx)(v.Text,{type:`secondary`,style:{display:`block`,marginTop:8},children:`Loading GitHub App data...`})]}),g&&(0,Q.jsx)(z,{type:`error`,showIcon:!0,title:`GitHub Setup Error`,description:g,style:{marginBottom:16}}),t===`create`&&m===1&&!h&&(0,Q.jsxs)(`div`,{style:{marginBottom:16},children:[(0,Q.jsx)(v.Paragraph,{type:`secondary`,style:{fontSize:13},children:`Create a GitHub App to connect Agor to your repositories. This uses GitHub's URL-parameters registration flow — you'll be redirected to GitHub with the form pre-filled, then brought back here to complete setup.`}),(0,Q.jsx)(Y.Item,{label:`App Name`,name:`github_app_name`,children:(0,Q.jsx)(J,{placeholder:`Agor (optional — defaults to 'Agor')`})}),(0,Q.jsx)(Y.Item,{label:`Target Organization`,name:`github_org`,tooltip:`Leave empty to create the app under your personal GitHub account`,children:(0,Q.jsx)(J,{placeholder:`my-org (optional)`})}),(0,Q.jsx)(s,{type:`primary`,icon:(0,Q.jsx)(r,{}),block:!0,onClick:async()=>{let t=nu(),n=new URLSearchParams,r=e.getFieldValue(`github_app_name`),i=e.getFieldValue(`github_org`);r&&n.set(`name`,r),i&&n.set(`org`,i);try{let e=localStorage.getItem(`agor-access-token`);if(!e){x(`You must be logged in as an admin to install the GitHub App.`);return}let r=await fetch(`${t}/api/github/setup/state`,{method:`POST`,headers:{Authorization:`Bearer ${e}`,"Content-Type":`application/json`}});if(!r.ok){let e=await r.json().catch(()=>({}));x(typeof e?.error==`string`?e.error:`Failed to start GitHub App install (HTTP ${r.status})`);return}let{state:i}=await r.json();if(!i){x(`Daemon did not return an install state token.`);return}n.set(`state`,i),window.open(`${t}/api/github/setup/new?${n.toString()}`,`_blank`)}catch(e){x(e instanceof Error?e.message:`Failed to initiate GitHub App install`)}},children:`Create GitHub App on GitHub`}),(0,Q.jsxs)(v.Paragraph,{type:`secondary`,style:{fontSize:12,margin:`12px 0 0`},children:[`Already created the app? Click `,(0,Q.jsx)(`strong`,{children:`Continue`}),` below to enter its credentials.`]})]}),t===`create`&&m===2&&!h&&(0,Q.jsxs)(`div`,{style:{marginBottom:16},children:[(0,Q.jsx)(z,{type:`info`,showIcon:!0,title:`Enter your GitHub App credentials`,description:(0,Q.jsxs)(`span`,{children:[`On your GitHub App's settings page:`,(0,Q.jsx)(`br`,{}),`1. Copy the `,(0,Q.jsx)(`strong`,{children:`App ID`}),` (shown at the top under "About")`,(0,Q.jsx)(`br`,{}),`2. Scroll to "Private keys" and click`,` `,(0,Q.jsx)(`strong`,{children:`"Generate a private key"`}),(0,Q.jsx)(`br`,{}),`3. Paste the downloaded .pem file contents below`]}),style:{marginBottom:16}}),(0,Q.jsx)(Y.Item,{label:`App ID`,name:`github_app_id`,rules:[{required:!0,message:`Enter your GitHub App ID`}],tooltip:`Found on your GitHub App's settings page (General → About)`,children:(0,Q.jsx)(J,{placeholder:`123456`})}),(0,Q.jsx)(Y.Item,{label:`Private Key (PEM)`,name:`github_private_key`,rules:[{required:!0,message:`Paste your GitHub App private key`}],tooltip:`Generate a private key on your GitHub App's settings page, then paste the .pem file contents`,children:(0,Q.jsx)(J.TextArea,{rows:4,placeholder:`-----BEGIN RSA PRIVATE KEY-----
61
- ...`,style:{fontFamily:`monospace`,fontSize:11}})}),(0,Q.jsx)(Y.Item,{label:`Installation ID`,name:`github_installation_id`,tooltip:`Set automatically via the setup callback, or paste from your GitHub App's installation URL`,children:(0,Q.jsx)(J,{placeholder:`123456789`})}),g&&(0,Q.jsx)(z,{type:`error`,showIcon:!0,title:g,style:{marginBottom:12}})]}),(t===`create`&&m===3||t===`edit`)&&!h&&(0,Q.jsx)(A,{ghost:!0,destroyOnHidden:!1,defaultActiveKey:t===`create`?[`identity`,`github-config`]:[],style:{marginLeft:-16,marginRight:-16},items:[...t===`edit`?[{key:`github-credentials`,label:(0,Q.jsx)(zv,{icon:(0,Q.jsx)(r,{}),title:`App Credentials`,subtitle:p?.config&&p.config.private_key?`configured`:`not set`}),children:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y.Item,{label:`App ID`,name:`github_app_id`,tooltip:`Found on your GitHub App's settings page (General → About)`,children:(0,Q.jsx)(J,{placeholder:`123456`})}),(0,Q.jsx)(Y.Item,{label:`Private Key (PEM)`,name:`github_private_key`,tooltip:`Leave empty to keep the existing key. Paste a new .pem to replace it.`,children:(0,Q.jsx)(J.TextArea,{rows:3,placeholder:p?.config&&p.config.private_key?`(private key is set — paste new key to replace)`:`-----BEGIN RSA PRIVATE KEY-----
62
- ...`,style:{fontFamily:`monospace`,fontSize:11}})}),(0,Q.jsx)(Y.Item,{label:`Installation ID`,name:`github_installation_id`,tooltip:`Set automatically via the setup callback, or paste from your GitHub App's installation URL`,children:(0,Q.jsx)(J,{placeholder:`123456789`})})]})}]:[],{key:`github-config`,label:(0,Q.jsx)(zv,{icon:(0,Q.jsx)(r,{}),title:`GitHub Settings`,subtitle:`polling & mentions`}),children:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y.Item,{label:`Watch Repos`,name:`github_watch_repos`,rules:[{required:!0,message:`At least one repo is required`}],tooltip:`Repos to watch for @mentions, in owner/repo format`,children:(0,Q.jsx)(l,{mode:`tags`,placeholder:`preset-io/agor`,tokenSeparators:[`,`,` `]})}),(0,Q.jsx)(Y.Item,{label:`Require @mention`,name:`github_require_mention`,valuePropName:`checked`,initialValue:!0,tooltip:`Only respond to PR/issue comments that @mention the bot`,children:(0,Q.jsx)(j,{})}),(0,Q.jsx)(Y.Item,{label:`Mention Name`,name:`github_mention_name`,tooltip:`The name users type to trigger the bot (e.g., 'agor' for @agor)`,initialValue:`agor`,children:(0,Q.jsx)(J,{prefix:`@`,placeholder:`agor`})}),(0,Q.jsx)(Y.Item,{label:`Poll Interval (seconds)`,name:`github_poll_interval_s`,initialValue:30,tooltip:`How frequently to poll the GitHub API for new mentions`,children:(0,Q.jsx)(lt,{min:10,max:300,style:{width:`100%`}})})]})},{key:`identity`,label:(0,Q.jsx)(zv,{icon:(0,Q.jsx)(ke,{}),title:`Identity`,subtitle:Bv(k)}),children:(0,Q.jsx)(Vv,{alignFieldName:`github_align_users`,alignLabel:`Align GitHub users`,alignDescription:`Map GitHub logins to Agor users. Unmapped users are rejected.`,alignUsers:k,userById:o,alignedContent:(0,Q.jsx)(Y.Item,{label:`User Map`,name:`github_user_map`,tooltip:`JSON object mapping GitHub logins to Agor email addresses`,rules:[{validator:uv}],children:(0,Q.jsx)(lv,{rows:4,placeholder:`{
63
- "octocat": "user@example.com"
64
- }`})})})},{key:`agentic-tool-config`,label:(0,Q.jsx)(zv,{icon:(0,Q.jsx)($e,{}),title:`Agent Configuration`,subtitle:d}),children:(0,Q.jsxs)(G,{orientation:`vertical`,size:`middle`,style:{width:`100%`},children:[(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12},children:`Configure which agent and settings to use for sessions created from this channel.`}),(0,Q.jsx)(Wa,{agents:Ka,selectedAgentId:d,onSelect:f,columns:2,showHelperText:!1,showComparisonLink:!1}),(0,Q.jsx)(n_,{agenticTool:d,mcpServerById:c,showHelpText:!1})]})},{key:`env-vars`,label:(0,Q.jsx)(zv,{icon:(0,Q.jsx)(S,{}),title:`Environment Variables`,subtitle:`channel-level secrets`}),children:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:12},children:`Define environment variables for sessions created from this channel. Useful for service account tokens or API keys for MCP servers.`}),(0,Q.jsx)(Y.Item,{name:`envVars`,noStyle:!0,children:(0,Q.jsx)(Hv,{})})]})}]})]}),n===`teams`&&(t===`edit`||m===1)&&(0,Q.jsx)(A,{ghost:!0,destroyOnHidden:!1,defaultActiveKey:t===`create`?[`teams-credentials`]:[],style:{marginLeft:-16,marginRight:-16},items:[{key:`teams-credentials`,label:(0,Q.jsx)(zv,{icon:(0,Q.jsx)(de,{}),title:`Azure Bot Credentials`,subtitle:t===`edit`?`leave blank to keep current`:void 0}),children:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y.Item,{label:`App ID`,name:`teams_app_id`,rules:t===`create`?[{required:!0,message:`Azure Bot App ID is required`}]:[],tooltip:`Azure Bot Registration Application (client) ID`,children:(0,Q.jsx)(J,{placeholder:`00000000-0000-0000-0000-000000000000`})}),(0,Q.jsx)(Y.Item,{label:`App Password`,name:`teams_app_password`,rules:t===`create`?[{required:!0,message:`Azure Bot App Password is required`}]:[],tooltip:`Azure Bot Registration client secret (value, not the secret ID)`,children:(0,Q.jsx)(J.Password,{placeholder:t===`edit`?`••••••••`:`Client secret value`})}),(0,Q.jsx)(Y.Item,{label:`Tenant ID`,name:`teams_tenant_id`,rules:[{required:!0,message:`Tenant ID is required for Teams bots`}],tooltip:`Azure AD Tenant ID. Required so the bot can acquire tokens to send replies.`,children:(0,Q.jsx)(J,{placeholder:`00000000-0000-0000-0000-000000000000`})}),(0,Q.jsx)(z,{type:`info`,showIcon:!0,message:`Azure Bot Setup`,description:(0,Q.jsxs)(`span`,{children:[`Create an Azure Bot resource in the`,` `,(0,Q.jsx)(v.Link,{href:`https://portal.azure.com/#create/Microsoft.AzureBotService`,target:`_blank`,rel:`noopener noreferrer`,children:`Azure Portal`}),`. Both single-tenant and multi-tenant bots are supported. The`,` `,(0,Q.jsx)(`strong`,{children:`Tenant ID`}),` is required so the bot can send replies. Then sideload the bot as a Teams app via a custom manifest.`]}),style:{fontSize:12}})]})},{key:`teams-message-sources`,label:(0,Q.jsx)(zv,{icon:(0,Q.jsx)(V,{}),title:`Message Sources`,subtitle:`DMs & channels`}),children:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:16},children:`Configure how the bot responds in Teams channels vs 1:1 chats. Direct messages are always enabled.`}),(0,Q.jsx)(Y.Item,{label:`Require @mention in channels`,name:`teams_require_mention`,valuePropName:`checked`,initialValue:!0,tooltip:`When enabled, bot only responds when @mentioned in Teams channels (recommended)`,children:(0,Q.jsx)(j,{})})]})},{key:`teams-webhook`,label:(0,Q.jsx)(zv,{icon:(0,Q.jsx)(Le,{}),title:`Webhook Configuration`,subtitle:`port & path`}),children:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:12},children:`The Teams connector runs an HTTP server for the Bot Framework messaging endpoint. Configure the port and path to match your Azure Bot's messaging endpoint URL.`}),(0,Q.jsx)(Y.Item,{label:`Webhook Port`,name:`teams_webhook_port`,initialValue:3978,tooltip:`Port for the Bot Framework HTTP endpoint`,children:(0,Q.jsx)(lt,{min:1024,max:65535,style:{width:`100%`}})}),(0,Q.jsx)(Y.Item,{label:`Webhook Path`,name:`teams_webhook_path`,initialValue:`/api/messages`,tooltip:`URL path for the Bot Framework messaging endpoint`,children:(0,Q.jsx)(J,{placeholder:`/api/messages`})})]})},{key:`agentic-tool-config`,label:(0,Q.jsx)(zv,{icon:(0,Q.jsx)($e,{}),title:`Agent Configuration`,subtitle:d}),children:(0,Q.jsxs)(G,{orientation:`vertical`,size:`middle`,style:{width:`100%`},children:[(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12},children:`Configure which agent and settings to use for sessions created from this channel.`}),(0,Q.jsx)(Wa,{agents:Ka,selectedAgentId:d,onSelect:f,columns:2,showHelperText:!1,showComparisonLink:!1}),(0,Q.jsx)(n_,{agenticTool:d,mcpServerById:c,showHelpText:!1})]})},{key:`env-vars`,label:(0,Q.jsx)(zv,{icon:(0,Q.jsx)(S,{}),title:`Environment Variables`,subtitle:`channel-level secrets`}),children:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:12},children:`Define environment variables for sessions created from this channel. Useful for service account tokens or API keys for MCP servers.`}),(0,Q.jsx)(Y.Item,{name:`envVars`,noStyle:!0,children:(0,Q.jsx)(Hv,{})})]})}]}),n===`slack`&&t===`create`&&m>=1&&(0,Q.jsx)(Zv,{form:e,userById:o,mcpServerById:c,selectedAgent:d,onAgentChange:f,step:m-1,testResult:_,testLoading:y,onTest:b}),n===`slack`&&t===`edit`&&(0,Q.jsx)(A,{ghost:!0,destroyOnHidden:!1,defaultActiveKey:[],style:{marginLeft:-16,marginRight:-16},items:[{key:`identity`,label:(0,Q.jsx)(zv,{icon:(0,Q.jsx)(W,{}),title:`Identity`,subtitle:Bv(D)}),children:(0,Q.jsx)(Vv,{alignFieldName:`align_slack_users`,alignLabel:`Align Slack users`,alignDescription:`Match Slack profile email to an Agor user. Unmatched users are rejected.`,alignUsers:D,userById:o,alignedContent:(0,Q.jsx)(z,{type:`info`,showIcon:!0,title:`Requires users:read.email scope`,description:(0,Q.jsxs)(`span`,{children:[`Add `,(0,Q.jsx)(`code`,{children:`users:read.email`}),` to your Slack app so Agor can match Slack profiles by email.`]}),style:{fontSize:12}})})},{key:`credentials`,label:(0,Q.jsx)(zv,{icon:(0,Q.jsx)(de,{}),title:`Credentials`,subtitle:`blank keeps stored values`}),children:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y.Item,{label:(0,Q.jsxs)(`span`,{children:[`Bot Token `,(0,Q.jsx)(Xv,{stored:ee})]}),name:`bot_token`,tooltip:`Slack Bot User OAuth Token (xoxb-...)`,extra:ee?`A token is stored. Leave blank to keep it; enter a value to overwrite it.`:`No token stored yet. Enter the bot token (xoxb-...).`,children:(0,Q.jsx)(J.Password,{placeholder:ee?`••••••••`:`xoxb-...`})}),(0,Q.jsx)(Y.Item,{label:(0,Q.jsxs)(`span`,{children:[`App Token `,(0,Q.jsx)(Xv,{stored:L})]}),name:`app_token`,tooltip:`Slack App-Level Token for Socket Mode (xapp-...)`,extra:L?`A token is stored. Leave blank to keep it; enter a value to overwrite it.`:`No token stored yet. Enter the app token (xapp-...).`,children:(0,Q.jsx)(J.Password,{placeholder:L?`••••••••`:`xapp-...`})}),(0,Q.jsx)(z,{type:`info`,showIcon:!0,title:`Socket Mode Required`,description:`Enable Socket Mode in your Slack app settings and generate an app-level token with connections:write scope.`,style:{fontSize:12,marginBottom:12}}),(0,Q.jsx)(s,{icon:(0,Q.jsx)($e,{}),loading:y,onClick:b,style:{marginBottom:12},children:`Test connection`}),(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12,marginLeft:8},children:`Tests the stored credentials against your Slack workspace.`}),_&&(0,Q.jsx)(qv,{result:_})]})},{key:`manifest`,label:(0,Q.jsx)(zv,{icon:(0,Q.jsx)(ct,{}),title:`App Manifest`,subtitle:`recommended scopes & events`}),children:(0,Q.jsx)(Jv,{options:P})},{key:`message-sources`,label:(0,Q.jsx)(zv,{icon:(0,Q.jsx)(V,{}),title:`Message Sources`,subtitle:`DMs always enabled`}),children:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:16},children:`Choose where the bot listens for messages. Direct messages are always enabled.`}),(0,Q.jsx)(Y.Item,{label:`Public Channels`,name:`enable_channels`,valuePropName:`checked`,initialValue:!1,tooltip:`Bot will respond to messages in public channels it's added to`,children:(0,Q.jsx)(j,{})}),(0,Q.jsx)(Y.Item,{label:`Private Channels`,name:`enable_groups`,valuePropName:`checked`,initialValue:!1,tooltip:`Bot will respond to messages in private channels it's added to`,children:(0,Q.jsx)(j,{})}),(0,Q.jsx)(Y.Item,{label:`Group DMs`,name:`enable_mpim`,valuePropName:`checked`,initialValue:!1,tooltip:`Bot will respond to messages in multi-person direct messages`,children:(0,Q.jsx)(j,{})}),N&&(0,Q.jsx)(z,{type:`info`,showIcon:!0,title:`Slack mentions are always required`,description:`Agor only starts or continues Slack channel threads when this bot is explicitly @mentioned. Missed thread replies are included as catch-up context on the next mention.`,style:{marginBottom:12}}),(0,Q.jsx)(z,{type:`info`,showIcon:!0,title:`Required Slack Scopes & Events`,description:(0,Q.jsxs)(`div`,{style:{fontSize:12},children:[(0,Q.jsxs)(v.Text,{type:`secondary`,style:{fontSize:12},children:[`Derived from the selected surfaces — channel-like surfaces trigger on`,` `,(0,Q.jsx)(`code`,{children:`app_mention`}),`, not `,(0,Q.jsx)(`code`,{children:`message.*`}),` channel events. Copy the full manifest from the App Manifest section.`]}),(0,Q.jsxs)(`div`,{style:{marginTop:8},children:[(0,Q.jsxs)(v.Text,{strong:!0,style:{fontSize:12},children:[`Bot scopes (`,F.length,`)`]}),(0,Q.jsx)(`div`,{style:{marginTop:6},children:F.map(e=>(0,Q.jsx)(u,{style:{marginBottom:4,fontFamily:`monospace`,fontSize:11},children:e},e))})]}),(0,Q.jsxs)(`div`,{style:{marginTop:8},children:[(0,Q.jsxs)(v.Text,{strong:!0,style:{fontSize:12},children:[`Event subscriptions (`,I.length,`)`]}),(0,Q.jsx)(`div`,{style:{marginTop:6},children:I.map(e=>(0,Q.jsx)(u,{color:`blue`,style:{marginBottom:4,fontFamily:`monospace`,fontSize:11},children:e},e))})]})]}),style:{fontSize:12}})]})},{key:`outbound`,label:(0,Q.jsx)(zv,{icon:(0,Q.jsx)(V,{}),title:`Outbound`,subtitle:`proactive sends`}),children:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:12},children:`Allow authorized agents to send proactive Slack messages through this gateway. Targets can be Slack channel IDs, channel names, or Slack user emails.`}),(0,Q.jsx)(Y.Item,{label:`Enable outbound sends`,name:`outbound_enabled`,valuePropName:`checked`,initialValue:!1,tooltip:`When enabled, branch admins/owners with full branch access can send proactive Slack messages through this gateway.`,children:(0,Q.jsx)(j,{})}),(0,Q.jsx)(Y.Item,{label:`Default outbound target`,name:`default_outbound_target`,tooltip:`Optional. Used when the agent omits a target. Examples: #project-updates, channel:C01ABC123, user@example.com.`,children:(0,Q.jsx)(J,{placeholder:`#project-updates, channel:C01ABC123, or user@example.com`})}),(0,Q.jsx)(z,{type:`info`,showIcon:!0,title:`Slack scopes`,description:(0,Q.jsxs)(`span`,{children:[`Channel-name targets require `,(0,Q.jsx)(`code`,{children:`channels:read`}),` and, for private channels, `,(0,Q.jsx)(`code`,{children:`groups:read`}),`. Email targets require`,` `,(0,Q.jsx)(`code`,{children:`users:read.email`}),` and open a DM with that Slack user.`]}),style:{fontSize:12}})]})},{key:`advanced`,label:(0,Q.jsx)(zv,{icon:(0,Q.jsx)(Le,{}),title:`Advanced`,subtitle:`channel whitelist`}),children:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:12},children:`Restrict the bot to specific Slack channels by ID. Leave empty to allow all channels. Find channel IDs: right-click channel → View channel details → scroll to bottom.`}),(0,Q.jsx)(Y.Item,{name:`allowed_channel_ids`,tooltip:`Slack channel IDs (e.g., C01ABC123XY). Press Enter to add each ID.`,children:(0,Q.jsx)(l,{mode:`tags`,placeholder:`Add channel IDs... (e.g., C01ABC123XY)`,style:{width:`100%`},tokenSeparators:[`,`,` `]})})]})},{key:`agentic-tool-config`,label:(0,Q.jsx)(zv,{icon:(0,Q.jsx)($e,{}),title:`Agent Configuration`,subtitle:d}),children:(0,Q.jsxs)(G,{orientation:`vertical`,size:`middle`,style:{width:`100%`},children:[(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12},children:`Configure which agent and settings to use for sessions created from this channel.`}),(0,Q.jsx)(Wa,{agents:Ka,selectedAgentId:d,onSelect:f,columns:2,showHelperText:!1,showComparisonLink:!1}),(0,Q.jsx)(n_,{agenticTool:d,mcpServerById:c,showHelpText:!1})]})},{key:`env-vars`,label:(0,Q.jsx)(zv,{icon:(0,Q.jsx)(S,{}),title:`Environment Variables`,subtitle:`channel-level secrets`}),children:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:12},children:`Define environment variables for sessions created from this channel. Useful for service account tokens or API keys for MCP servers.`}),(0,Q.jsx)(Y.Item,{name:`envVars`,noStyle:!0,children:(0,Q.jsx)(Hv,{})})]})}]})]})]})},$v=({client:e,gatewayChannelById:t,branchById:n,userById:r,mcpServerById:i,currentUser:o,onCreate:c,onUpdate:l,onDelete:d})=>{let{showSuccess:f,showError:p}=cf(),{token:m}=X.useToken(),[h,g]=(0,Z.useState)(!1),[_,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(`slack`),[w,T]=(0,Z.useState)(`claude-code`),[E,D]=(0,Z.useState)(``),[O]=Y.useForm(),[k]=Y.useForm(),[A,M]=(0,Z.useState)(()=>new Map),N=(0,Z.useRef)(new Set),F=(0,Z.useRef)(new Map),[I,ee]=(0,Z.useState)(0),[te,ne]=(0,Z.useState)(!1),[H,ie]=(0,Z.useState)(!1),[U,ae]=(0,Z.useState)(null),[oe,se]=(0,Z.useState)(!1),[ce,le]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{F.current=A},[A]),(0,Z.useEffect)(()=>{if(!e)return;let r=new Set;for(let e of t.values())e.target_branch_id&&r.add(e.target_branch_id);let i=Array.from(r).filter(e=>!n.has(e)&&!F.current.has(e));if(i.length===0)return;let a=!1;return Promise.all(i.map(async t=>{if(N.current.has(t))return null;N.current.add(t);try{return await e.service(`branches`).get(t)}catch{return null}finally{N.current.delete(t)}})).then(e=>{if(a)return;let t=e.filter(e=>e!==null);t.length!==0&&M(e=>{let n=new Map(e);for(let e of t)n.set(e.branch_id,e);return n})}),()=>{a=!0}},[e,t,n]);let de=(0,Z.useMemo)(()=>{let e=new Map;for(let t of n.values())e.set(t.branch_id,t);for(let t of A.values())e.has(t.branch_id)||e.set(t.branch_id,t);return e},[A,n]),fe=(0,Z.useCallback)(()=>{ie(!1),ae(null)},[]),pe=(0,Z.useCallback)(()=>{se(!1),le(null)},[]),me=(0,Z.useCallback)(()=>{ee(0),fe(),pe()},[fe,pe]),he=(0,Z.useCallback)(()=>{le(null)},[]),ge=(0,Z.useCallback)(e=>{Object.keys(e).some(e=>Gv.has(e))&&he()},[he]),_e=(0,Z.useCallback)(e=>{C(e),me()},[me]),ve=(0,Z.useCallback)(async()=>{if(!e){p(`Not connected to server`);return}let t=O.getFieldsValue(!0),n={bot_token:t.bot_token,app_token:t.app_token,enable_channels:t.enable_channels??!1,enable_groups:t.enable_groups??!1,enable_mpim:t.enable_mpim??!1,align_slack_users:t.align_slack_users??!1,allowed_channel_ids:t.allowed_channel_ids??[],outbound_enabled:t.outbound_enabled??!1};se(!0),le(null);try{le(await e.service(`gateway-channels/test`).create({config:n}))}catch(e){le({ok:!1,failures:[{capability:`connection`,reason:e instanceof Error?e.message:String(e)}],notVerifiable:[]})}finally{se(!1)}},[e,O,p]),ye=(0,Z.useCallback)(async()=>{if(!e){p(`Not connected to server`);return}if(b){se(!0),le(null);try{le(await e.service(`gateway-channels/test`).create({gatewayChannelId:b.id}))}catch(e){le({ok:!1,failures:[{capability:`connection`,reason:e instanceof Error?e.message:String(e)}],notVerifiable:[]})}finally{se(!1)}}},[e,b,p]);(0,Z.useEffect)(()=>{let e=o?.default_agentic_config?.[w];e&&(_?k:O).setFieldsValue({permissionMode:e.permissionMode,modelConfig:e.modelConfig,mcpServerIds:e.mcpServerIds,codexSandboxMode:e.codexSandboxMode,codexApprovalPolicy:e.codexApprovalPolicy,codexNetworkAccess:e.codexNetworkAccess})},[w,o,O,k,_]);let be=(e,t,n)=>{let r=[`bot_token`,`app_token`,`signing_secret`,`private_key`,`app_password`],i={...t||{}};for(let e of r)delete i[e];let a={...i};if(e.channel_type===`github`){if(e.github_app_id&&(a.app_id=Number(e.github_app_id)),e.github_private_key&&(a.private_key=e.github_private_key),e.github_installation_id&&(a.installation_id=Number(e.github_installation_id)),a.watch_repos=e.github_watch_repos??[],a.require_mention=e.github_require_mention??!0,a.mention_name=e.github_mention_name||`agor`,a.poll_interval_ms=(e.github_poll_interval_s??30)*1e3,a.align_github_users=e.github_align_users??!1,e.github_user_map)try{a.user_map=JSON.parse(e.github_user_map)}catch{}}else e.channel_type===`teams`?(e.teams_app_id&&(a.app_id=e.teams_app_id),e.teams_app_password&&(a.app_password=e.teams_app_password),a.tenant_id=e.teams_tenant_id,a.webhook_port=e.teams_webhook_port??3978,a.webhook_path=e.teams_webhook_path||`/api/messages`,a.require_mention=e.teams_require_mention??!0):e.channel_type===`slack`&&(e.bot_token&&(a.bot_token=e.bot_token),e.app_token&&(a.app_token=e.app_token),e.connection_mode&&(a.connection_mode=e.connection_mode),a.enable_channels=e.enable_channels??!1,a.enable_groups=e.enable_groups??!1,a.enable_mpim=e.enable_mpim??!1,a.require_mention=!0,a.align_slack_users=e.align_slack_users??!1,a.allowed_channel_ids=e.allowed_channel_ids??[],a.outbound_enabled=e.outbound_enabled??!1,a.default_outbound_target=e.default_outbound_target||null);let o={agent:n||`claude-code`,...e.permissionMode?{permissionMode:e.permissionMode}:{},...e.modelConfig?{modelConfig:e.modelConfig}:{},...e.mcpServerIds?{mcpServerIds:e.mcpServerIds}:{},...e.codexSandboxMode?{codexSandboxMode:e.codexSandboxMode}:{},...e.codexApprovalPolicy?{codexApprovalPolicy:e.codexApprovalPolicy}:{},...e.codexNetworkAccess===void 0?{}:{codexNetworkAccess:e.codexNetworkAccess},...e.envVars===void 0?{}:{envVars:e.envVars.filter(e=>e.key.trim()!==``)}};return{name:e.name,channel_type:e.channel_type,target_branch_id:e.target_branch_id,agor_user_id:e.agor_user_id,config:a,agentic_config:o,enabled:e.enabled??!0}},xe=async()=>{ne(!0);try{await O.validateFields();let t=O.getFieldsValue(!0);t.channel_type===`slack`&&(t.slack_public_scope!==`specific`||!t.enable_channels)&&(t.allowed_channel_ids=[]);let n=be(t,void 0,w);if(!e){p(`Not connected to server`);return}await e.service(`gateway-channels`).create(n),f(`Gateway channel created!`),O.resetFields(),g(!1),C(`slack`),me()}catch(e){let t=e;t.errorFields?.length?p(t.errorFields[0].errors[0]||`Please fill in required fields`):p(`Failed to create channel: ${t.message||String(e)}`)}finally{ne(!1)}},Se=I>=Uv(S).length-1,Ce=async()=>{if(Se){await xe();return}let e=Wv(S,I,O.getFieldValue(`align_slack_users`)??!1);if(e.length>0)try{await O.validateFields(e)}catch{return}ee(e=>e+1)},we=()=>{O.resetFields(),g(!1),C(`slack`),T(`claude-code`),me()},W=e=>{x(e),C(e.channel_type),T(e.agentic_config?.agent||`claude-code`),pe(),k.resetFields();let t=e.config,n={name:e.name,channel_type:e.channel_type,target_branch_id:e.target_branch_id,agor_user_id:e.agor_user_id,enabled:e.enabled,permissionMode:e.agentic_config?.permissionMode,modelConfig:e.agentic_config?.modelConfig,mcpServerIds:e.agentic_config?.mcpServerIds,codexSandboxMode:e.agentic_config?.codexSandboxMode,codexApprovalPolicy:e.agentic_config?.codexApprovalPolicy,codexNetworkAccess:e.agentic_config?.codexNetworkAccess,envVars:e.agentic_config?.envVars??[]};if(e.channel_type===`slack`)n.connection_mode=t?.connection_mode||`socket`,n.enable_channels=t?.enable_channels??!1,n.enable_groups=t?.enable_groups??!1,n.enable_mpim=t?.enable_mpim??!1,n.require_mention=!0,n.align_slack_users=t?.align_slack_users??!1,n.allowed_channel_ids=t?.allowed_channel_ids??[],n.outbound_enabled=t?.outbound_enabled??!1,n.default_outbound_target=t?.default_outbound_target;else if(e.channel_type===`github`){n.github_app_id=t?.app_id,n.github_installation_id=t?.installation_id,n.github_watch_repos=t?.watch_repos??[],n.github_require_mention=t?.require_mention??!0,n.github_mention_name=t?.mention_name||`agor`,n.github_poll_interval_s=(t?.poll_interval_ms??3e4)/1e3,n.github_align_users=t?.align_github_users??!1;let e=t?.user_map;e&&typeof e==`object`&&Object.keys(e).length>0&&(n.github_user_map=JSON.stringify(e,null,2))}else e.channel_type===`teams`&&(n.teams_app_id=t?.app_id,n.teams_tenant_id=t?.tenant_id,n.teams_webhook_port=t?.webhook_port??3978,n.teams_webhook_path=t?.webhook_path||`/api/messages`,n.teams_require_mention=t?.require_mention??!0);k.setFieldsValue(n),y(!0)},Te=()=>{b&&k.validateFields().then(()=>{let e=be(k.getFieldsValue(!0),b.config,w);l?.(b.id,e),k.resetFields(),y(!1),x(null),C(`slack`)}).catch(e=>{console.error(`Form validation failed:`,e),e.errorFields?.length>0&&p(e.errorFields[0].errors[0]||`Please fill in required fields`)})},Ee=e=>{l?.(e.id,{enabled:!e.enabled})},De=e=>{d?.(e)},Oe=[{title:``,key:`status`,width:40,render:(e,t)=>(0,Q.jsx)(R,{status:t.enabled?`success`:`default`,title:t.enabled?`Enabled`:`Disabled`})},{title:`Name`,dataIndex:`name`,key:`name`,width:180,render:e=>(0,Q.jsx)(Uf,{text:e,query:E})},{title:`Type`,dataIndex:`channel_type`,key:`channel_type`,width:120,render:e=>(0,Q.jsx)(u,{icon:Lv(e),color:Rv(e),children:e.charAt(0).toUpperCase()+e.slice(1)})},{title:`Target Branch`,dataIndex:`target_branch_id`,key:`target_branch_id`,width:180,render:e=>{let t=de.get(e);return(0,Q.jsx)(v.Text,{type:`secondary`,children:(0,Q.jsx)(Uf,{text:t?`${t.name||t.ref||e}${t.archived?` (archived)`:``}`:e,query:E})})}},{title:`Last Message`,dataIndex:`last_message_at`,key:`last_message_at`,width:160,render:e=>e?(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12},children:new Date(e).toLocaleString()}):(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12},children:`Never`})},{title:`Actions`,key:`actions`,width:96,render:(e,t)=>(0,Q.jsxs)(vm,{children:[(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(P,{}),onClick:()=>W(t),title:`Edit`}),(0,Q.jsx)(j,{size:`small`,checked:t.enabled,onChange:()=>Ee(t),title:t.enabled?`Disable`:`Enable`}),(0,Q.jsx)(B,{title:`Delete gateway channel?`,description:`Are you sure you want to delete "${t.name}"? All thread mappings will be lost.`,onConfirm:()=>De(t.id),okText:`Delete`,cancelText:`Cancel`,okButtonProps:{danger:!0},children:(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(re,{}),danger:!0,title:`Delete`})})]})}],ke=(0,Z.useMemo)(()=>Bf(If(t,(e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:`base`})),E,[e=>e.name,e=>e.channel_type,e=>e.channel_key,e=>e.enabled?`enabled`:`disabled`,e=>e.last_message_at,e=>{let t=de.get(e.target_branch_id);return[t?.name,t?.ref,e.target_branch_id]},e=>JSON.stringify(e.config??{})]),[t,E,de]);return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{style:{marginBottom:16,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,Q.jsx)(v.Text,{type:`secondary`,children:`Route messages from Slack, GitHub, Microsoft Teams, and other platforms to Agor sessions.`}),(0,Q.jsxs)(G,{children:[(0,Q.jsx)(J,{allowClear:!0,placeholder:`Search name, type, target branch, key, or config`,value:E,onChange:e=>D(e.target.value),style:{width:360}}),(0,Q.jsx)(s,{type:`primary`,icon:(0,Q.jsx)(L,{}),onClick:()=>g(!0),children:`Add Channel`})]})]}),(0,Q.jsx)(z,{type:`warning`,showIcon:!0,style:{marginBottom:16},title:`Beta Feature — Security Notice`,description:(0,Q.jsxs)(Q.Fragment,{children:[`The Message Gateway is a `,(0,Q.jsx)(`strong`,{children:`beta feature`}),`. Connecting external messaging platforms grants anyone who can message your bot potential access to Agor sessions and the underlying branch environment.`,` `,(0,Q.jsx)(v.Link,{href:`https://agor.live/guide/message-gateway`,target:`_blank`,rel:`noopener noreferrer`,children:`Read the full security guidance`}),` `,`before enabling channels in production.`]})}),ke.length===0?(0,Q.jsxs)(`div`,{style:{padding:`60px 20px`,textAlign:`center`,color:m.colorTextTertiary},children:[(0,Q.jsx)(V,{style:{fontSize:48,marginBottom:16,display:`block`}}),(0,Q.jsx)(v.Text,{type:`secondary`,style:{display:`block`,marginBottom:8},children:`No channels configured.`}),(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12},children:`Add a channel to route messages from Slack, Teams, or other platforms to Agor sessions.`})]}):(0,Q.jsx)(ue,{dataSource:ke,columns:Oe,rowKey:`id`,pagination:{pageSize:10,showSizeChanger:!0},size:`small`}),(0,Q.jsx)(a,{title:`Add Gateway Channel`,open:h,onCancel:we,width:600,footer:(0,Q.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`},children:[(0,Q.jsx)(s,{type:`link`,disabled:I===0,onClick:()=>ee(e=>Math.max(0,e-1)),style:{paddingLeft:0},children:`Back`}),(0,Q.jsxs)(G,{style:{marginLeft:`auto`},children:[(0,Q.jsx)(s,{onClick:we,children:`Cancel`}),(0,Q.jsx)(s,{type:`primary`,loading:te,onClick:Ce,children:Se?`Create channel`:`Continue`})]})]}),children:(0,Q.jsx)(Y,{form:O,layout:`vertical`,preserve:!0,onValuesChange:ge,style:{marginTop:16},children:(0,Q.jsx)(Qv,{form:O,mode:`create`,channelType:S,onChannelTypeChange:_e,branchById:de,userById:r,mcpServerById:i,selectedAgent:w,onAgentChange:T,createStep:I,githubLoading:H,githubError:U,slackTestResult:ce,slackTestLoading:oe,onSlackTest:ve})})}),(0,Q.jsx)(a,{title:`Edit Gateway Channel`,open:_,onOk:Te,onCancel:()=>{k.resetFields(),y(!1),x(null),C(`slack`),T(`claude-code`),pe()},okText:`Save`,width:600,children:(0,Q.jsx)(Y,{form:k,layout:`vertical`,preserve:!0,style:{marginTop:16},children:(0,Q.jsx)(Qv,{form:k,mode:`edit`,channelType:S,onChannelTypeChange:C,branchById:de,userById:r,mcpServerById:i,selectedAgent:w,onAgentChange:T,editingChannel:b,createStep:0,githubLoading:!1,githubError:null,slackTestResult:ce,slackTestLoading:oe,onSlackTest:ye})})})]})};function ey(e,t){let n=new Set(e),r=new Set(t);return{add:t.filter(e=>!n.has(e)),remove:e.filter(e=>!r.has(e))}}async function ty(e,t,n,r){let i=ey(e,t);await Promise.all([...i.add.map(e=>n(e)),...i.remove.map(e=>r(e))])}async function ny(e,t,n,r){await ty(n,r,n=>e.service(`group-memberships`).create({group_id:t,user_id:n}),n=>e.service(`group-memberships`).remove(n,{query:{group_id:t}}))}async function ry(e,t,n,r){await ty(n,r,n=>e.service(`group-memberships`).create({group_id:n,user_id:t}),n=>e.service(`group-memberships`).remove(t,{query:{group_id:n}}))}var iy=({client:e,currentUser:t,userById:n})=>{let{showError:r,showSuccess:i}=cf(),[o,c]=(0,Z.useState)([]),[d,f]=(0,Z.useState)([]),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)([]),[_,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(``),[S]=Y.useForm(),[C]=Y.useForm(),w=(0,Z.useRef)(!1),T=(0,Z.useRef)(!1),E=mt(t?.role,bt.ADMIN),D=(0,Z.useCallback)(async()=>{if(!e||!E){c([]),f([]);return}let[t,n]=await Promise.all([e.service(`groups`).findAll({query:{archived:!1}}),e.service(`group-memberships`).findAll({})]);c(t),f(n)},[e,E]);(0,Z.useEffect)(()=>{D().catch(e=>r(`Failed to load groups: ${e instanceof Error?e.message:String(e)}`))},[D,r]);let O=(0,Z.useMemo)(()=>{let e=new Map;for(let t of d){let n=e.get(t.group_id)||[];n.push(t.user_id),e.set(t.group_id,n)}return e},[d]),k=async()=>{if(!e)return;let t=await S.validateFields();await e.service(`groups`).create(t),j(),i(`Group created`),await D()},A=()=>{w.current=!1,S.resetFields(),y(!0)},j=()=>{w.current=!1,S.resetFields(),y(!1)},M=e=>{if(Object.hasOwn(e,`slug`)){w.current=!0;return}Object.hasOwn(e,`name`)&&!w.current&&S.setFieldsValue({slug:tl(e.name||``)})},N=e=>{if(Object.hasOwn(e,`slug`)){T.current=!0;return}Object.hasOwn(e,`name`)&&!T.current&&!C.getFieldValue(`slug`)&&C.setFieldsValue({slug:tl(e.name||``)})},F=async()=>{if(!e||!p)return;let t=await C.validateFields();await e.service(`groups`).patch(p.group_id,t),await ee(p,h),m(null),g([]),i(`Group updated`),await D()},I=async t=>{e&&(await e.service(`groups`).patch(t.group_id,{archived:!0}),i(`Group archived`),await D())},ee=async(t,n)=>{e&&await ny(e,t.group_id,O.get(t.group_id)||[],n)},te=async(e,t)=>{await ee(e,t),await D()};if(!E)return(0,Q.jsx)(v.Text,{type:`secondary`,children:`Only admins can manage groups.`});let R=If(n,(e,t)=>e.email.localeCompare(t.email)).map(qh),ne=Bf([...o].sort((e,t)=>e.name.localeCompare(t.name)),b,[e=>e.name,e=>e.slug,e=>e.description,e=>(O.get(e.group_id)||[]).map(e=>n.get(e)).filter(e=>!!e).flatMap(e=>[e.name,e.email,e.unix_username])]);return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{style:{marginBottom:16,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,Q.jsx)(v.Text,{type:`secondary`,children:`Manage groups and user memberships.`}),(0,Q.jsxs)(G,{children:[(0,Q.jsx)(J,{allowClear:!0,placeholder:`Search name, slug, description, or members`,value:b,onChange:e=>x(e.target.value),style:{width:320}}),(0,Q.jsx)(s,{type:`primary`,icon:(0,Q.jsx)(L,{}),onClick:A,children:`New Group`})]})]}),(0,Q.jsx)(ue,{rowKey:`group_id`,size:`small`,pagination:!1,dataSource:ne,columns:[{title:`Group`,dataIndex:`name`,render:(e,t)=>(0,Q.jsxs)(G,{children:[(0,Q.jsx)(W,{}),(0,Q.jsx)(`span`,{children:(0,Q.jsx)(Uf,{text:t.name,query:b})}),(0,Q.jsx)(u,{children:(0,Q.jsx)(Uf,{text:t.slug||``,query:b})})]})},{title:`Description`,dataIndex:`description`,render:e=>e?(0,Q.jsx)(Uf,{text:e,query:b}):`—`},{title:`Members`,render:(e,t)=>(0,Q.jsx)(l,{mode:`multiple`,style:{minWidth:320},value:O.get(t.group_id)||[],options:R,...Yh,onChange:e=>te(t,e)})},{title:`Actions`,width:76,render:(e,t)=>(0,Q.jsxs)(vm,{children:[(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(P,{}),onClick:()=>{T.current=!1,m(t),g(O.get(t.group_id)||[]),C.setFieldsValue(t)}}),(0,Q.jsx)(B,{title:`Archive group?`,onConfirm:()=>I(t),children:(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(re,{}),danger:!0})})]})}]}),(0,Q.jsx)(a,{title:`Create Group`,open:_,onOk:k,onCancel:j,children:(0,Q.jsxs)(Y,{form:S,layout:`vertical`,onValuesChange:M,children:[(0,Q.jsx)(Y.Item,{name:`name`,label:`Name`,rules:[{required:!0}],children:(0,Q.jsx)(J,{})}),(0,Q.jsx)(Y.Item,{name:`slug`,label:`Slug`,extra:`Auto-filled from name; editable.`,children:(0,Q.jsx)(J,{placeholder:`engineering`})}),(0,Q.jsx)(Y.Item,{name:`description`,label:`Description`,children:(0,Q.jsx)(J.TextArea,{rows:3})})]})}),(0,Q.jsx)(a,{title:`Edit Group`,open:!!p,onOk:F,onCancel:()=>{m(null),g([])},children:(0,Q.jsxs)(Y,{form:C,layout:`vertical`,onValuesChange:N,children:[(0,Q.jsx)(Y.Item,{name:`name`,label:`Name`,rules:[{required:!0}],children:(0,Q.jsx)(J,{})}),(0,Q.jsx)(Y.Item,{name:`slug`,label:`Slug`,extra:`Editable stable key used in URLs and APIs.`,children:(0,Q.jsx)(J,{})}),(0,Q.jsx)(Y.Item,{name:`description`,label:`Description`,children:(0,Q.jsx)(J.TextArea,{rows:3})}),(0,Q.jsx)(Y.Item,{label:`Members`,children:(0,Q.jsx)(l,{mode:`multiple`,style:{width:`100%`},value:h,options:R,...Yh,onChange:g,placeholder:`Select users...`})})]})})]})},ay=({form:e,mode:t,repoMode:n,onRepoModeChange:r})=>{let i=t===`edit`,a=n===`local`;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y.Item,{label:`Repository Type`,children:(0,Q.jsxs)(K.Group,{value:n,onChange:r,disabled:i,buttonStyle:`solid`,children:[(0,Q.jsx)(K.Button,{value:`remote`,children:`Remote (clone)`}),(0,Q.jsx)(K.Button,{value:`local`,children:`Local (existing)`})]})}),!i&&!a&&(0,Q.jsx)(Y.Item,{label:`Repository URL`,name:`url`,rules:[{required:!0,message:`Please enter a git repository URL`},{pattern:/^((ssh:\/\/)?git@[\w.-]+(:\d+)?[:/][\w./-]+|https?:\/\/[\w.-]+(:\d+)?\/[\w./-]+)$/,message:`Please enter a valid git URL`}],extra:`HTTPS or SSH URL (e.g., git@github.com:org/repo.git)`,children:(0,Q.jsx)(J,{placeholder:`https://github.com/apache/superset.git`,onChange:t=>{let n=t.target.value;if(n)try{let t=en(n);t&&e.setFieldsValue({slug:t})}catch{}},autoFocus:!0})}),!i&&a&&(0,Q.jsx)(Y.Item,{label:`Local Repository Path`,name:`path`,rules:[{required:!0,message:`Please enter an absolute path`}],extra:`Absolute path on this machine (supports ~/ expansion)`,children:(0,Q.jsx)(J,{placeholder:`~/code/my-app`,onChange:t=>{let n=t.target.value;if(n){let t=el(n);t&&e.setFieldsValue({slug:t})}},autoFocus:!0})}),(0,Q.jsx)(Y.Item,{label:`Repository Slug`,name:`slug`,rules:[{required:!a||i,message:`Please enter a slug`},{pattern:/^[a-zA-Z0-9._-]+\/[a-zA-Z0-9._-]+$/,message:`Slug must be in org/repo format`}],extra:a?`Provide org/repo format (e.g., local/myapp)`:`Auto-detected from URL (editable)`,children:(0,Q.jsx)(J,{placeholder:`apache/superset`,disabled:i})}),!a&&(0,Q.jsx)(Y.Item,{label:`Default Branch`,name:`default_branch`,rules:[{required:!0,message:`Please enter the default branch`}],extra:`The main branch to base new branches on`,children:(0,Q.jsx)(J,{placeholder:`main`})}),!i&&(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12},children:a?`Link an existing git clone on this machine.`:`The repository will be cloned to the server.`})]})},oy=({repoById:e,onCreate:t,onCreateLocal:n,onUpdate:r,onDelete:i})=>{let o=(0,Z.useMemo)(()=>Ff(e).sort((e,t)=>e.name.localeCompare(t.name)),[e]),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(`remote`),[_]=Y.useForm(),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(null),C=!!f,w=(0,Z.useMemo)(()=>Bf(o,c,[e=>e.name,e=>e.slug,e=>e.remote_url,e=>e.local_path,e=>e.default_branch,e=>e.repo_type]),[o,c]),T=e=>{S(e),b(!0)},E=e=>{x&&(i?.(x.repo_id,e),b(!1),S(null))},D=()=>{p(null),h(`remote`),_.resetFields(),_.setFieldsValue({default_branch:`main`}),d(!0)},O=e=>{p(e),h(e.repo_type??`remote`),_.setFieldsValue({slug:e.slug,default_branch:e.default_branch||`main`}),d(!0)},k=()=>{_.validateFields().then(e=>{if(C&&f){let t={slug:e.slug};e.default_branch&&(t.default_branch=e.default_branch),r?.(f.repo_id,t)}else m===`local`?n?.({path:e.path,slug:e.slug||void 0}):t?.({url:e.url,slug:e.slug,default_branch:e.default_branch});_.resetFields(),p(null),d(!1)})},A=()=>{_.resetFields(),p(null),h(`remote`),d(!1)},j=e=>{let t=e.target.value;h(t),_.resetFields(),_.setFieldsValue({url:void 0,path:void 0,slug:void 0,default_branch:t===`remote`?`main`:void 0})},M=C?`Edit Repository`:m===`local`?`Add Local Repository`:`Clone Repository`,N=C?`Save`:m===`local`?`Add`:`Clone`;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{style:{marginBottom:16,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,Q.jsx)(v.Text,{type:`secondary`,children:`Connect remote or local git repositories for your sessions.`}),(0,Q.jsxs)(G,{children:[(0,Q.jsx)(J,{allowClear:!0,placeholder:`Search name, slug, URL, path, type, or branch`,value:c,onChange:e=>l(e.target.value),style:{width:340}}),(0,Q.jsx)(s,{type:`primary`,icon:(0,Q.jsx)(L,{}),onClick:D,children:`New Repository`})]})]}),o.length===0&&(0,Q.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`center`,minHeight:400},children:(0,Q.jsx)(fe,{description:`No repositories yet`,children:(0,Q.jsxs)(v.Text,{type:`secondary`,children:[`Click "New Repository" to clone a remote repo or switch to "Local" mode to link an existing clone. You can also run `,(0,Q.jsx)(`code`,{children:`agor repo add-local <path>`}),` from the CLI.`]})})}),o.length>0&&(0,Q.jsx)(G,{orientation:`vertical`,size:16,style:{width:`100%`},children:w.map(e=>{let t=e.repo_type===`local`,n=t?`green`:`blue`,r=t?`Local`:`Remote`;return(0,Q.jsx)(g,{size:`small`,title:(0,Q.jsxs)(G,{children:[(0,Q.jsx)(se,{}),(0,Q.jsx)(v.Text,{strong:!0,children:(0,Q.jsx)(Uf,{text:e.name,query:c})}),(0,Q.jsx)(Aa,{color:n,style:{marginLeft:8},children:(0,Q.jsx)(Uf,{text:r,query:c})})]}),extra:(0,Q.jsxs)(G,{children:[(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(P,{}),onClick:()=>O(e)}),(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(re,{}),danger:!0,onClick:()=>T(e)})]}),children:(0,Q.jsxs)(G,{orientation:`vertical`,size:8,style:{width:`100%`},children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(v.Text,{type:`secondary`,style:{fontSize:12},children:[`Slug:`,` `]}),(0,Q.jsx)(v.Text,{code:!0,style:{fontSize:12},children:(0,Q.jsx)(Uf,{text:e.slug,query:c})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(v.Text,{type:`secondary`,style:{fontSize:12},children:[`Type:`,` `]}),(0,Q.jsx)(v.Text,{code:!0,style:{fontSize:11},children:(0,Q.jsx)(Uf,{text:r.toLowerCase(),query:c})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(v.Text,{type:`secondary`,style:{fontSize:12},children:[`Remote:`,` `]}),(0,Q.jsx)(v.Text,{code:!0,style:{fontSize:11},children:e.remote_url?(0,Q.jsx)(Uf,{text:e.remote_url,query:c}):`—`})]}),e.local_path&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(v.Text,{type:`secondary`,style:{fontSize:12},children:[`Path:`,` `]}),(0,Q.jsx)(v.Text,{code:!0,style:{fontSize:11},children:(0,Q.jsx)(Uf,{text:e.local_path,query:c})})]})]})},e.repo_id)})}),(0,Q.jsx)(a,{title:M,open:u,onOk:k,onCancel:A,okText:N,children:(0,Q.jsx)(Y,{form:_,layout:`vertical`,style:{marginTop:16},children:(0,Q.jsx)(ay,{form:_,mode:C?`edit`:`create`,repoMode:m,onRepoModeChange:j})})}),(0,Q.jsx)(a,{title:`Delete Repository`,open:y,onCancel:()=>{b(!1),S(null)},footer:null,children:x&&(0,Q.jsxs)(G,{orientation:`vertical`,size:16,style:{width:`100%`},children:[(0,Q.jsxs)(v.Text,{children:[`How would you like to delete`,` `,(0,Q.jsxs)(v.Text,{strong:!0,children:[`"`,x.name,`"`]}),`?`]}),x.repo_type===`local`?(0,Q.jsx)(g,{style:{marginBottom:8},styles:{body:{padding:16}},children:(0,Q.jsxs)(G,{orientation:`vertical`,size:8,style:{width:`100%`},children:[(0,Q.jsx)(v.Text,{strong:!0,children:`Remove from Agor`}),(0,Q.jsxs)(v.Text,{type:`secondary`,style:{fontSize:12},children:[`Remove this repository from Agor's database only. Your local files at`,` `,(0,Q.jsx)(v.Text,{code:!0,children:x.local_path}),` will remain untouched.`]}),(0,Q.jsx)(s,{danger:!0,onClick:()=>E(!1),style:{marginTop:8},children:`Remove from Agor`})]})}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(g,{style:{marginBottom:8},styles:{body:{padding:16}},children:(0,Q.jsxs)(G,{orientation:`vertical`,size:8,style:{width:`100%`},children:[(0,Q.jsx)(v.Text,{strong:!0,children:`Remove from Agor (Keep Files)`}),(0,Q.jsxs)(v.Text,{type:`secondary`,style:{fontSize:12},children:[`Remove from database only. Repository and branch directories in`,` `,(0,Q.jsx)(v.Text,{code:!0,children:`~/.agor/repos/`}),` and`,` `,(0,Q.jsx)(v.Text,{code:!0,children:`~/.agor/worktrees/`}),` will remain on disk.`]}),(0,Q.jsx)(s,{onClick:()=>E(!1),style:{marginTop:8},children:`Keep Files`})]})}),(0,Q.jsx)(g,{styles:{body:{padding:16}},children:(0,Q.jsxs)(G,{orientation:`vertical`,size:8,style:{width:`100%`},children:[(0,Q.jsx)(v.Text,{strong:!0,children:`Delete Completely (Remove Files)`}),(0,Q.jsx)(v.Text,{type:`secondary`,style:{fontSize:12},children:`⚠️ Remove from database AND delete all filesystem directories (repository + branches). This will free up disk space but cannot be undone.`}),(0,Q.jsx)(s,{danger:!0,onClick:()=>E(!0),style:{marginTop:8},children:`Delete Files`})]})})]})]})})]})};function sy(e){return e.service(`users`)}var cy={enabled:!1,provider:null,gateway_channel_id:null},ly=({client:e,gatewayChannelById:t})=>{let{showSuccess:n,showError:r}=cf(),[i,a]=(0,Z.useState)(cy),[o,c]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(!1),[_,y]=(0,Z.useState)(null),b=(0,Z.useMemo)(()=>If(t,(e,t)=>e.name.localeCompare(t.name)).filter(e=>e.channel_type===`slack`),[t]);(0,Z.useEffect)(()=>{e&&(p(!0),sy(e).getAvatarSettings({}).then(e=>{let t=e;a(t),c(t.enabled),d(t.gateway_channel_id),y(t.last_sync_result??null)}).catch(e=>r(`Failed to load avatar settings: ${e.message}`)).finally(()=>p(!1)))},[e,r]);let x=async(t=o,n=u)=>{if(!e)return;let r=await sy(e).updateAvatarSettings({enabled:t,provider:t?`slack`:null,gateway_channel_id:t?n:null});a(r),c(r.enabled),d(r.gateway_channel_id)},S=async e=>{let t=o;if(c(e),!(e&&!u))try{await x(e,u)}catch(e){c(t),r(`Failed to update avatar settings: ${e instanceof Error?e.message:String(e)}`)}};return(0,Q.jsxs)(G,{direction:`vertical`,size:`large`,style:{width:`100%`},children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(v.Title,{level:4,style:{margin:0},children:`User Slack avatars`}),(0,Q.jsx)(v.Text,{type:`secondary`,children:`Use a Slack gateway bot token to sync Slack profile image URLs onto Agor users by email. Agor prefers avatar_url when present and falls back to each user’s emoji tile.`})]}),(0,Q.jsx)(g,{loading:f,size:`small`,children:(0,Q.jsxs)(G,{direction:`vertical`,size:`middle`,style:{width:`100%`},children:[(0,Q.jsx)(U,{checked:o,onChange:e=>S(e.target.checked),children:`Enable Slack-synced avatars`}),(0,Q.jsx)(v.Text,{type:`secondary`,children:`Disabling this stops Slack avatar refreshes and removes only Slack-synced avatar URLs. Manually/provider-set avatar URLs are preserved.`}),(0,Q.jsxs)(et,{gap:12,align:`center`,wrap:`wrap`,children:[(0,Q.jsx)(l,{style:{minWidth:320},placeholder:`Select Slack gateway`,value:u??void 0,onChange:async e=>{let t=u;if(d(e),o)try{await x(!0,e)}catch(e){d(t),r(`Failed to update avatar settings: ${e instanceof Error?e.message:String(e)}`)}},options:b.map(e=>({value:e.id,label:`${e.name}${e.enabled?``:` (disabled)`}`}))}),(0,Q.jsx)(s,{type:`primary`,disabled:!o||!u,loading:m,onClick:async()=>{if(!(!e||!u)){h(!0);try{await x(!0,u);let t=await sy(e).syncAvatars({gateway_channel_id:u});y(t),n(`Synced Slack avatars: ${t.updated} updated, ${t.skipped} skipped, ${t.failed} failed`)}catch(e){r(`Slack avatar sync failed: ${e instanceof Error?e.message:String(e)}`)}finally{h(!1)}}},children:`Sync now`})]}),_&&(0,Q.jsxs)(v.Text,{type:_.failed?`warning`:`secondary`,children:[`Last sync: `,_.updated,` updated, `,_.skipped,` skipped,`,` `,_.failed,` failed at `,new Date(_.finished_at).toLocaleString(),`.`]}),_?.failures?.length?(0,Q.jsx)(z,{type:`warning`,showIcon:!0,message:`Avatar sync failures`,description:(0,Q.jsxs)(G,{direction:`vertical`,size:4,children:[_.failures.slice(0,5).map(e=>(0,Q.jsxs)(v.Text,{type:`secondary`,children:[e.email||e.user_id,`: `,e.reason]},`${e.user_id}-${e.reason}`)),_.failures.length>5&&(0,Q.jsxs)(v.Text,{type:`secondary`,children:[`…and `,_.failures.length-5,` more.`]})]})}):null,i.last_sync_at&&!_&&(0,Q.jsxs)(v.Text,{type:`secondary`,children:[`Last sync: `,new Date(i.last_sync_at).toLocaleString(),`.`]})]})})]})},uy={"gentle-chime":`gentle-chime.mp3`,"notification-bell":`notification-bell.mp3`,"8bit-coin":`8bit-coin.mp3`,"retro-coin":`retro-coin.mp3`,"power-up":`power-up.mp3`,"you-got-mail":`you-got-mail.mp3`,"success-tone":`success-tone.mp3`};function dy(e){let t=e;(e===`bell`||e==="default")&&(t=`notification-bell`),uy[t]||(t=`gentle-chime`);let n=uy[t],r=`/ui/`,i=`${r.endsWith(`/`)?r.slice(0,-1):r}/sounds/${n}`;return typeof window<`u`?new URL(i,window.location.origin).href:i}var fy={enabled:!1,chime:`gentle-chime`,volume:.5,minDurationSeconds:30},py=!1;function my(){if(py)return;let e=()=>{py=!0,document.removeEventListener(`click`,e),document.removeEventListener(`keydown`,e),document.removeEventListener(`touchstart`,e)};document.addEventListener(`click`,e,{once:!0}),document.addEventListener(`keydown`,e,{once:!0}),document.addEventListener(`touchstart`,e,{once:!0})}function hy(){return new Promise(e=>{let t=new Audio(`data:audio/mp3;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4Ljc2LjEwMAAAAAAAAAAAAAAA//tQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWGluZwAAAA8AAAACAAADhAC7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7//////////////////////////////////////////////////////////////////8AAAAATGF2YzU4LjEzAAAAAAAAAAAAAAAAJAAAAAAAAAAAA4T0rBiNAAAAAAD/+xDEAAPAAAGkAAAAIAAANIAAAARMQU1FMy4xMDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/+xDEDwPAAAGkAAAAIAAANIAAAARMQU1FMy4xMDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/+xDEHwPAAAGkAAAAIAAANIAAAARMQU1FMy4xMDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==`);t.volume=0;let n=t.play();n===void 0?e(!1):n.then(()=>{t.pause(),e(!1)}).catch(t=>{t instanceof Error&&t.name===`NotAllowedError`?e(!0):e(!1)})})}function gy(e,t){if(t===0)return!0;if(e.duration_ms!=null)return e.duration_ms/1e3>=t;if(e.started_at&&e.completed_at){let n=new Date(e.started_at).getTime();return(new Date(e.completed_at).getTime()-n)/1e3>=t}return!0}async function _y(e,t){let n=t||fy;if(!n.enabled||!gy(e,n.minDurationSeconds)||!zt(e.status))return;let r=dy(n.chime);if(!r){console.warn(`Unknown chime sound: ${n.chime}`);return}try{let e=new Audio(r);e.volume=Math.max(0,Math.min(1,n.volume));let t=e.play();t!==void 0&&await t}catch(e){if(e instanceof Error){let t=e.name;t===`NotAllowedError`?console.debug(`🔇 Audio chime blocked by browser autoplay policy. User needs to interact with the page first.`):t===`NotSupportedError`?console.warn(`🔇 Audio format not supported:`,r):console.debug(`Could not play task completion chime:`,e)}}}async function vy(e,t=.5){let n=dy(e);if(!n){console.warn(`Unknown chime sound: ${e}`);return}try{let e=n+`?t=${Date.now()}`,r=new Audio(e);r.volume=Math.max(0,Math.min(1,t)),await r.play()}catch(e){throw console.error(`Failed to preview chime:`,e),e}}function yy(e){return{"gentle-chime":`Gentle Chime`,"notification-bell":`Notification Bell`,"8bit-coin":`8-Bit Coin`,"retro-coin":`Retro Coin`,"power-up":`Power Up`,"you-got-mail":`You've Got Mail`,"success-tone":`Success Tone`}[e]||e}function by(){return[`gentle-chime`,`notification-bell`,`8bit-coin`,`retro-coin`,`power-up`,`you-got-mail`,`success-tone`]}var{Text:xy}=v;function Sy(e){return typeof e==`boolean`?{set:e,scope:`global`}:{set:!!e.set,scope:e.scope}}var Cy={global:`Global`,session:`Session`,repo:`Repo`,mcp_server:`MCP server`,artifact_feature:`Artifact feature`,executor:`Executor`},wy={global:`blue`,session:`purple`,repo:`default`,mcp_server:`default`,artifact_feature:`default`,executor:`default`},Ty=nn.map(e=>({value:e,label:Cy[e]})),Ey=({envVars:e,onSave:t,onScopeChange:n,onDelete:r,loading:i={},disabled:a=!1})=>{let[o,c]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(`global`),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(null),b=async()=>{if(!(!o.trim()||!u.trim()))try{y(null),await t(o.trim(),u.trim(),f),c(``),d(``),p(`global`)}catch(e){y(e instanceof Error?e.message:`Failed to save environment variable`)}},x=async(e,n)=>{if(g.trim())try{y(null),await t(e,g.trim(),n),h(null),_(``)}catch(e){y(e instanceof Error?e.message:`Failed to update environment variable`)}},S=async(e,t)=>{if(n)try{y(null),await n(e,t)}catch(e){y(e instanceof Error?e.message:`Failed to update scope`)}},C=async e=>{try{y(null),await r(e)}catch(e){y(e instanceof Error?e.message:`Failed to delete environment variable`)}},w=[{title:`Variable Name`,dataIndex:`key`,key:`key`,width:`30%`,ellipsis:!0,render:e=>(0,Q.jsx)(`code`,{children:e})},{title:`Scope`,dataIndex:`scope`,key:`scope`,width:140,render:(e,t)=>n?(0,Q.jsx)(l,{value:e,size:`small`,style:{width:`100%`,minWidth:0},popupMatchSelectWidth:!1,disabled:a||i[t.key],onChange:e=>S(t.key,e),options:Ty}):(0,Q.jsx)(Aa,{color:wy[e],children:Cy[e]})},{title:`Value`,dataIndex:`isSet`,key:`value`,render:(e,t)=>m===t.key?(0,Q.jsxs)(G.Compact,{style:{width:`100%`},children:[(0,Q.jsx)(J.Password,{placeholder:`Enter new value`,value:g,onChange:e=>_(e.target.value),onPressEnter:()=>x(t.key,t.scope),autoFocus:!0,disabled:a,style:{flex:1,minWidth:180}}),(0,Q.jsx)(s,{type:`primary`,onClick:()=>x(t.key,t.scope),loading:i[t.key],disabled:a||!g.trim(),children:`Save`}),(0,Q.jsx)(s,{onClick:()=>h(null),disabled:a,children:`Cancel`})]}):(0,Q.jsxs)(G,{children:[(0,Q.jsx)(Aa,{color:e?`success`:`default`,children:e?`Set (encrypted)`:`Not Set`}),e&&(0,Q.jsx)(s,{type:`link`,size:`small`,onClick:()=>{h(t.key),_(``)},disabled:a,children:`Update`})]})},{title:`Actions`,key:`actions`,width:72,align:`center`,render:(e,t)=>(0,Q.jsx)(H,{title:`Delete`,children:(0,Q.jsx)(s,{danger:!0,type:`text`,size:`small`,icon:(0,Q.jsx)(re,{}),onClick:()=>C(t.key),loading:i[t.key],disabled:a,"aria-label":`Delete ${t.key}`})})}],T=(0,Z.useMemo)(()=>Object.entries(e).map(([e,t])=>{let n=Sy(t);return{key:e,isSet:n.set,scope:n.scope}}).sort((e,t)=>e.key.localeCompare(t.key,void 0,{sensitivity:`base`})),[e]);return(0,Q.jsxs)(G,{orientation:`vertical`,size:`middle`,style:{width:`100%`},children:[(0,Q.jsxs)(xy,{type:`secondary`,children:[`Environment variables are encrypted at rest. `,(0,Q.jsx)(`b`,{children:`Global`}),` vars are exported to every session you own. `,(0,Q.jsx)(`b`,{children:`Session`}),` vars are only exported to sessions where you explicitly select them (configure per-session under Session → Settings → Env vars).`]}),v&&(0,Q.jsx)(`div`,{style:{color:`#ff4d4f`,padding:`8px`,borderRadius:`4px`,background:`#fff1f0`},children:(0,Q.jsx)(xy,{type:`danger`,children:v})}),(0,Q.jsx)(ue,{columns:w,dataSource:T,pagination:!1,size:`small`,locale:{emptyText:`No environment variables configured`},style:{width:`100%`}}),(0,Q.jsxs)(G,{orientation:`vertical`,size:`small`,style:{width:`100%`},children:[(0,Q.jsx)(xy,{strong:!0,children:`Add New Variable`}),(0,Q.jsxs)(G.Compact,{style:{width:`100%`},children:[(0,Q.jsx)(J,{placeholder:`Variable name (e.g., GITHUB_TOKEN)`,value:o,onChange:e=>c(e.target.value),onPressEnter:b,style:{width:`30%`},disabled:a}),(0,Q.jsx)(l,{value:f,onChange:p,style:{width:140},disabled:a,options:Ty}),(0,Q.jsx)(J.Password,{placeholder:`Value`,value:u,onChange:e=>d(e.target.value),onPressEnter:b,style:{flex:1},disabled:a}),(0,Q.jsx)(s,{type:`primary`,icon:(0,Q.jsx)(L,{}),onClick:b,disabled:a||!o.trim()||!u.trim(),children:`Add`})]})]})]})},{Text:Dy,Paragraph:Oy}=v,ky=({user:e,form:t})=>{let{showError:n,showWarning:r,showInfo:i}=cf(),[a,o]=(0,Z.useState)(!1),[c,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(!1),p=e?.preferences?.audio||fy;(0,Z.useEffect)(()=>{hy().then(u)},[]);let m=async()=>{let e=t.getFieldValue(`chime`),r=t.getFieldValue(`volume`);o(!0),f(!1);try{await vy(e,r),u(!1)}catch{u(!0),f(!0),n(`Audio blocked by browser. See instructions below to enable.`)}finally{setTimeout(()=>o(!1),2e3)}};return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{style:{marginBottom:16},children:[(0,Q.jsxs)(Dy,{strong:!0,style:{fontSize:16},children:[(0,Q.jsx)(De,{}),` Task Completion Chimes`]}),(0,Q.jsx)(Oy,{type:`secondary`,style:{marginTop:8,marginBottom:0},children:`Play a sound when agent tasks finish executing. Perfect for long-running tasks!`})]}),d&&c&&(0,Q.jsx)(z,{type:`warning`,showIcon:!0,icon:(0,Q.jsx)(y,{}),title:`Browser Audio Permissions Required`,description:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{style:{marginBottom:8},children:`Your browser is blocking audio playback. To enable chimes:`}),(0,Q.jsxs)(`ol`,{style:{marginLeft:16,marginBottom:8},children:[(0,Q.jsxs)(`li`,{children:[`Click the `,(0,Q.jsx)(`strong`,{children:`lock icon`}),` (🔒) or `,(0,Q.jsx)(`strong`,{children:`site info icon`}),` in your browser's address bar`]}),(0,Q.jsxs)(`li`,{children:[`Find `,(0,Q.jsx)(`strong`,{children:`"Sound"`}),` or `,(0,Q.jsx)(`strong`,{children:`"Autoplay"`}),` permissions`]}),(0,Q.jsxs)(`li`,{children:[`Change the setting to `,(0,Q.jsx)(`strong`,{children:`"Allow"`})]}),(0,Q.jsx)(`li`,{children:`Refresh the page and click the Preview button again`})]}),(0,Q.jsxs)(`p`,{style:{marginBottom:0,fontSize:`0.9em`,opacity:.8},children:[(0,Q.jsx)(`strong`,{children:`Chrome/Edge:`}),` Click lock icon → Site settings → Sound → Allow`,(0,Q.jsx)(`br`,{}),(0,Q.jsx)(`strong`,{children:`Firefox:`}),` Click lock icon → Permissions → Autoplay → Allow Audio and Video`,(0,Q.jsx)(`br`,{}),(0,Q.jsx)(`strong`,{children:`Safari:`}),` Safari → Settings for this Website → Auto-Play → Allow All Auto-Play`]})]}),closable:!0,onClose:()=>f(!1),style:{marginBottom:16}}),(0,Q.jsxs)(Y,{form:t,layout:`vertical`,initialValues:{enabled:p.enabled,chime:p.chime,volume:p.volume,minDurationSeconds:p.minDurationSeconds},children:[(0,Q.jsxs)(O,{gutter:16,children:[(0,Q.jsx)(ot,{span:12,children:(0,Q.jsx)(Y.Item,{name:`enabled`,label:`Enable Chimes`,valuePropName:`checked`,children:(0,Q.jsx)(j,{onChange:async e=>{if(e){let e=await hy();u(e),e?(f(!0),r(`Audio may be blocked. Click Preview to test and grant permissions.`)):i(`Audio notifications enabled. Use the preview button to test.`)}else f(!1)}})})}),(0,Q.jsx)(ot,{span:12,children:(0,Q.jsx)(Y.Item,{noStyle:!0,shouldUpdate:(e,t)=>e.enabled!==t.enabled,children:()=>(0,Q.jsx)(Y.Item,{name:`volume`,label:`Volume`,children:(0,Q.jsx)(rt,{min:0,max:1,step:.1,marks:{0:`0%`,.5:`50%`,1:`100%`},disabled:!t.getFieldValue(`enabled`),tooltip:{formatter:e=>`${Math.round((e||0)*100)}%`}})})})})]}),(0,Q.jsxs)(O,{gutter:16,children:[(0,Q.jsx)(ot,{span:12,children:(0,Q.jsx)(Y.Item,{noStyle:!0,shouldUpdate:(e,t)=>e.enabled!==t.enabled,children:()=>{let e=t.getFieldValue(`enabled`);return(0,Q.jsx)(Y.Item,{label:`Chime Sound`,tooltip:`Choose your preferred notification sound`,children:(0,Q.jsxs)(G.Compact,{style:{width:`100%`},children:[(0,Q.jsx)(Y.Item,{name:`chime`,noStyle:!0,children:(0,Q.jsx)(l,{style:{flex:1},disabled:!e,options:by().map(e=>({label:yy(e),value:e})).sort((e,t)=>e.label.localeCompare(t.label))})}),(0,Q.jsx)(s,{icon:(0,Q.jsx)(F,{}),onClick:m,disabled:!e||a,loading:a,children:`Preview`})]})})}})}),(0,Q.jsx)(ot,{span:12,children:(0,Q.jsx)(Y.Item,{noStyle:!0,shouldUpdate:(e,t)=>e.enabled!==t.enabled,children:()=>(0,Q.jsx)(Y.Item,{label:`Minimum Task Duration`,tooltip:`Only play chime for tasks that take longer than this. Set to 0 to always play.`,children:(0,Q.jsxs)(G.Compact,{style:{width:`100%`},children:[(0,Q.jsx)(Y.Item,{name:`minDurationSeconds`,noStyle:!0,children:(0,Q.jsx)(lt,{min:0,max:300,step:1,style:{width:`100%`},disabled:!t.getFieldValue(`enabled`)})}),(0,Q.jsx)(J,{value:`seconds`,disabled:!0,style:{width:80,textAlign:`center`,pointerEvents:`none`}})]})})})})]})]}),(0,Q.jsx)(g,{type:`inner`,size:`small`,style:{marginTop:16},children:(0,Q.jsxs)(Dy,{type:`secondary`,children:[(0,Q.jsx)(`strong`,{children:`Note:`}),` Chimes will only play for tasks that complete naturally (finished or failed), not for tasks you manually stop. Make sure your browser allows audio playback - click the Preview button to test!`]})})]})},Ay=({client:e})=>{let[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(!1),[o,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),[_,y]=(0,Z.useState)(``),{token:b}=X.useToken(),{showSuccess:x,showError:S}=cf(),C=(0,Z.useCallback)(async()=>{if(e){i(!0);try{n(await e.service(`api/v1/user/api-keys`).findAll({}))}catch(e){console.error(`Failed to fetch API keys:`,e)}finally{i(!1)}}},[e]);(0,Z.useEffect)(()=>{C()},[C]);let w=async()=>{if(!(!e||!l.trim())){c(!0);try{m((await e.service(`api/v1/user/api-keys`).create({name:l.trim()})).rawKey),u(``),await C()}catch(e){S(e?.message||`Failed to create API key`)}finally{c(!1)}}},T=async t=>{if(e){g(t);try{await e.service(`api/v1/user/api-keys`).remove(t),x(`API key revoked`),await C()}catch(e){S(e?.message||`Failed to delete API key`)}finally{g(null)}}},D=async e=>{await Xa(e)?x(`Copied to clipboard`):S(`Failed to copy to clipboard`)},O=[{title:`Name`,dataIndex:`name`,key:`name`,render:e=>(0,Q.jsx)(Uf,{text:e,query:_})},{title:`Key`,dataIndex:`prefix`,key:`prefix`,render:e=>(0,Q.jsxs)(v.Text,{code:!0,style:{fontSize:12},children:[(0,Q.jsx)(Uf,{text:e,query:_}),`...`]})},{title:`Created`,dataIndex:`created_at`,key:`created_at`,render:e=>new Date(e).toLocaleDateString()},{title:`Last Used`,dataIndex:`last_used_at`,key:`last_used_at`,render:e=>e?new Date(e).toLocaleDateString():`Never`},{title:``,key:`actions`,width:80,render:(e,t)=>(0,Q.jsx)(B,{title:`Revoke this API key?`,description:`Any applications using this key will lose access.`,onConfirm:()=>T(t.id),okText:`Revoke`,okType:`danger`,children:(0,Q.jsx)(s,{type:`text`,danger:!0,size:`small`,icon:(0,Q.jsx)(re,{}),loading:h===t.id})})}],k=(0,Z.useMemo)(()=>Bf(t,_,[e=>e.name,e=>e.prefix,e=>e.id,e=>e.created_at,e=>e.last_used_at]),[t,_]);return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(v.Paragraph,{type:`secondary`,style:{marginBottom:16},children:`Agor API tokens allow you to authenticate with the Agor API from scripts, CI pipelines, and external tools. Tokens have the same permissions as your user account.`}),(0,Q.jsxs)(G,{style:{marginBottom:16,display:`flex`,justifyContent:`space-between`},children:[(0,Q.jsx)(J,{allowClear:!0,placeholder:`Search name, prefix, or dates`,value:_,onChange:e=>y(e.target.value),style:{width:300}}),(0,Q.jsx)(s,{type:`primary`,icon:(0,Q.jsx)(L,{}),onClick:()=>f(!0),children:`Create New Key`})]}),(0,Q.jsx)(ue,{dataSource:k,columns:O,rowKey:`id`,loading:r,pagination:!1,size:`small`,locale:{emptyText:`No API keys yet`}}),(0,Q.jsxs)(a,{title:`Create API Key`,open:d&&!p,onOk:w,onCancel:()=>{f(!1),u(``)},okText:`Create`,okButtonProps:{disabled:!l.trim(),loading:o},children:[(0,Q.jsx)(v.Paragraph,{type:`secondary`,children:`Give your key a descriptive name so you can identify it later.`}),(0,Q.jsx)(J,{placeholder:`e.g., CI Pipeline, Local Development`,value:l,onChange:e=>u(e.target.value),onPressEnter:w,maxLength:100,autoFocus:!0})]}),(0,Q.jsxs)(a,{title:(0,Q.jsxs)(G,{children:[(0,Q.jsx)(de,{}),`API Key Created`]}),open:!!p,onOk:()=>{m(null),f(!1)},onCancel:()=>{m(null),f(!1)},okText:`Done`,cancelButtonProps:{style:{display:`none`}},children:[(0,Q.jsx)(z,{type:`warning`,showIcon:!0,title:`Copy your API key now`,description:`This is the only time the full key will be shown. Store it securely.`,style:{marginBottom:16}}),(0,Q.jsx)(J.TextArea,{value:p||``,readOnly:!0,autoSize:{minRows:2},style:{fontFamily:`monospace`,fontSize:13,marginBottom:8,background:b.colorBgContainer}}),(0,Q.jsx)(s,{icon:(0,Q.jsx)(E,{}),onClick:()=>p&&D(p),block:!0,children:`Copy to Clipboard`})]})]})},{Sider:jy,Content:My}=He,Ny=[`claude-code`,`claude-code-cli`,`codex`,`gemini`,`opencode`,`copilot`,`cursor`],Py=e=>Ny.includes(e),Fy=({open:e,onClose:t,user:n,client:r,currentUser:o,onUpdate:c,onRestartOnboarding:d})=>{let f=jc(Uc),[p]=Y.useForm(),[g,_]=(0,Z.useState)(`general`),y=(0,Z.useRef)(null),b=mt(o?.role,bt.ADMIN),[x]=Y.useForm(),[S]=Y.useForm(),[C]=Y.useForm(),[w]=Y.useForm(),[T]=Y.useForm(),[E]=Y.useForm(),[D]=Y.useForm(),[O]=Y.useForm(),k=(0,Z.useMemo)(()=>({"claude-code":x,"claude-code-cli":S,codex:C,gemini:w,opencode:T,copilot:E,cursor:D}),[S,x,C,E,D,w,T]),[A,M]=(0,Z.useState)({"claude-code":{},"claude-code-cli":{},codex:{},gemini:{},opencode:{},copilot:{},cursor:{}}),[N,P]=(0,Z.useState)({}),[F,I]=(0,Z.useState)({}),[ee,L]=(0,Z.useState)({}),[te,R]=(0,Z.useState)([]),[ne,V]=(0,Z.useState)([]),[H,re]=(0,Z.useState)(!1),[ie,ae]=(0,Z.useState)(!1),oe=(0,Z.useMemo)(()=>[...te].sort((e,t)=>e.name.localeCompare(t.name)).map(Jh),[te]),[se,ce]=(0,Z.useState)({"claude-code":!1,"claude-code-cli":!1,codex:!1,gemini:!1,opencode:!1,copilot:!1,cursor:!1}),[le,ue]=(0,Z.useState)(()=>new Set),[de,fe]=(0,Z.useState)({}),pe=(0,Z.useCallback)(e=>{ue(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})},[]),me=(0,Z.useCallback)(e=>{_(`general`),ue(new Set),fe({}),p.setFieldsValue({email:e.email,name:e.name,emoji:e.emoji,role:e.role,unix_username:e.unix_username,groupIds:[],eventStreamEnabled:e.preferences?.eventStream?.enabled??!0,useSlackAvatar:e.preferences?.use_slack_avatar!==!1,must_change_password:e.must_change_password??!1})},[p]),he=(0,Z.useCallback)(async()=>{let e=n?.user_id;if(!r||!e||!b){R([]),V([]),ae(!1),p.setFieldValue(`groupIds`,[]);return}re(!0),ae(!1);try{let[t,n]=await Promise.all([r.service(`groups`).findAll({query:{archived:!1}}),r.service(`group-memberships`).findAll({query:{user_id:e}})]),i=n.map(e=>e.group_id);R(t),V(i),ae(!0),p.setFieldValue(`groupIds`,i)}catch(e){console.error(`Failed to load user groups:`,e)}finally{re(!1)}},[r,p,b,n?.user_id]);(0,Z.useEffect)(()=>{if(!e){y.current=null;return}let t=n?.user_id;!n||!t||y.current===t||(y.current=t,me(n),he())},[e,n,me,he]),(0,Z.useEffect)(()=>{if(!(!e||!n)){if(Py(g)){k[g].setFieldsValue(de[g]??r_(g,n.default_agentic_config?.[g]));return}if(g===`audio`){let e=n.preferences?.audio;O.setFieldsValue({enabled:e?.enabled??fy.enabled,chime:e?.chime??fy.chime,volume:e?.volume??fy.volume,minDurationSeconds:e?.minDurationSeconds??fy.minDurationSeconds})}}},[g,de,O,k,e,n]),(0,Z.useEffect)(()=>{if(!e)return;let t={"claude-code":{},"claude-code-cli":{},codex:{},gemini:{},opencode:{},copilot:{},cursor:{}},r=n?.agentic_tools;if(r)for(let e of Object.keys(t)){let n=r[e];n&&(t[e]={...n})}M(t),n?.env_vars?I(n.env_vars):I({})},[e,n]);let ge=()=>{p.resetFields(),R([]),V([]),ae(!1),ue(new Set),fe({}),_(`general`),t()},_e=async e=>{!r||!n||!b||!ie||(await ry(r,n.user_id,ne,e),V(e))},ve=e=>[...new Set([...le,...e?[e]:[]])],ye=async e=>{if(!n||e.length===0)return;let t={...n.default_agentic_config??{}};for(let n of e)t[n]=i_(n,de[n]??k[n].getFieldsValue());await c?.(n.user_id,{default_agentic_config:t}),ue(t=>{if(t.size===0)return t;let n=new Set(t);for(let t of e)n.delete(t);return n}),fe(t=>{let n={...t};for(let t of e)delete n[t];return n})},be=async()=>{await ye(ve())},xe=async()=>{if(n)try{await p.validateFields([`email`,`name`,`emoji`,`role`,`unix_username`]);let e=p.getFieldsValue(),t={...n.preferences,eventStream:{enabled:e.eventStreamEnabled??!0}};e.useSlackAvatar===!1?t.use_slack_avatar=!1:delete t.use_slack_avatar;let r={email:e.email,name:e.name,emoji:e.emoji,role:e.role,unix_username:e.unix_username,preferences:t};e.password?.trim()&&(r.password=e.password),mt(o?.role,bt.ADMIN)&&n.user_id!==o?.user_id&&(r.must_change_password=e.must_change_password),await c?.(n.user_id,r),p.setFieldValue(`password`,``),await _e(e.groupIds||[]),await be()}catch(e){console.error(`Validation failed:`,e)}},Se=async(e,t,r)=>{if(!n)return;let i=`${e}.${t}`;try{P(e=>({...e,[i]:!0})),await c?.(n.user_id,{agentic_tools:{[e]:{[t]:r}}}),M(n=>({...n,[e]:{...n[e]??{},[t]:!0}}))}catch(n){throw console.error(`Failed to save ${e}.${t}:`,n),n}finally{P(e=>({...e,[i]:!1}))}},we=async(e,t)=>{if(!n)return;let r=`${e}.${t}`;try{P(e=>({...e,[r]:!0})),await c?.(n.user_id,{agentic_tools:{[e]:{[t]:null}}}),M(n=>{let r={...n[e]??{}};return delete r[t],{...n,[e]:r}})}catch(n){throw console.error(`Failed to clear ${e}.${t}:`,n),n}finally{P(e=>({...e,[r]:!1}))}},Te=async(e,t,r)=>{if(n)try{L(t=>({...t,[e]:!0})),await c?.(n.user_id,{env_vars:{[e]:t},env_var_scopes:{[e]:r}}),I(t=>({...t,[e]:{set:!0,scope:r,resource_id:null}}))}catch(t){throw console.error(`Failed to save ${e}:`,t),t}finally{L(t=>({...t,[e]:!1}))}},Ee=async(e,t)=>{if(n)try{L(t=>({...t,[e]:!0})),await c?.(n.user_id,{env_var_scopes:{[e]:t}}),I(n=>({...n,[e]:{...n[e]??{set:!0},set:!0,scope:t,resource_id:null}}))}catch(t){throw console.error(`Failed to update scope for ${e}:`,t),t}finally{L(t=>({...t,[e]:!1}))}},Oe=async e=>{if(n)try{L(t=>({...t,[e]:!0})),await c?.(n.user_id,{env_vars:{[e]:null}}),I(t=>{let n={...t};return delete n[e],n})}catch(t){throw console.error(`Failed to delete ${e}:`,t),t}finally{L(t=>({...t,[e]:!1}))}},ke=async e=>{if(!n)return;let t=ve(e);try{ce(e=>{let n={...e};for(let e of t)n[e]=!0;return n}),await ye(t)}catch(t){throw console.error(`Failed to save ${e} config:`,t),t}finally{ce(e=>{let n={...e};for(let e of t)n[e]=!1;return n})}},Ae=e=>{let t=s_(e);k[e].setFieldsValue(t),fe(n=>({...n,[e]:t})),pe(e)},je=async()=>{if(!(!n||!c))try{let e=O.getFieldsValue(),t={...n.preferences,audio:{enabled:e.enabled,chime:e.chime,volume:e.volume,minDurationSeconds:e.minDurationSeconds}};await c(n.user_id,{preferences:t}),await be()}catch(e){console.error(`Failed to save audio settings:`,e)}},Me=async()=>{if(n)switch(g){case`general`:await xe();break;case`env-vars`:case`personal-api-keys`:await be();break;case`groups`:await _e(p.getFieldValue(`groupIds`)||[]),await be();break;case`audio`:await je();break;case`claude-code`:case`claude-code-cli`:case`codex`:case`gemini`:case`opencode`:case`copilot`:case`cursor`:await ke(g);break}},{token:Pe}=X.useToken(),Fe=[{key:`profile`,label:`Profile`,type:`group`,children:[{key:`general`,label:`General`,icon:(0,Q.jsx)(Ce,{})},{key:`env-vars`,label:`Env Vars`,icon:(0,Q.jsx)($e,{})},{key:`audio`,label:`Audio`,icon:(0,Q.jsx)(De,{})},...b?[{key:`groups`,label:`Groups`,icon:(0,Q.jsx)(W,{})}]:[],{key:`personal-api-keys`,label:`Agor API Tokens`,icon:(0,Q.jsx)(Ie,{})}]},{key:`agentic-tools`,label:`Agentic Tools`,type:`group`,children:[{key:`claude-code`,label:`Claude Code`,icon:(0,Q.jsx)(h,{})},{key:`codex`,label:`Codex`,icon:(0,Q.jsx)(h,{})},{key:`gemini`,label:`Gemini`,icon:(0,Q.jsx)(h,{})},{key:`opencode`,label:`OpenCode`,icon:(0,Q.jsx)(h,{})},{key:`cursor`,label:`Cursor SDK`,icon:(0,Q.jsx)(h,{})},{key:`copilot`,label:`GitHub Copilot`,icon:(0,Q.jsx)(h,{})}]}];return(0,Q.jsxs)(a,{title:null,open:e,onCancel:ge,footer:(0,Q.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8,padding:`12px 24px`,background:Pe.colorBgContainer},children:[(0,Q.jsx)(s,{onClick:ge,children:`Close`}),(0,Q.jsx)(s,{type:`primary`,onClick:Me,loading:g in se?se[g]:!1,children:`Save`})]}),closable:!0,width:`min(1050px, calc(100vw - 32px))`,style:{top:40},styles:{wrapper:{padding:0,overflow:`hidden`},container:{padding:0,borderRadius:8,overflow:`hidden`},header:{display:`none`},body:{padding:0,height:`calc(100vh - 280px)`,minHeight:450,maxHeight:650},footer:{padding:0,margin:0,background:Pe.colorBgContainer,borderTop:`1px solid ${Pe.colorBorderSecondary}`}},closeIcon:(0,Q.jsx)(i,{}),children:[(0,Q.jsxs)(`div`,{hidden:!0,"aria-hidden":`true`,children:[g!==`audio`&&(0,Q.jsx)(Y,{component:!1,form:O}),Ny.map(e=>g===e?null:(0,Q.jsx)(Y,{component:!1,form:k[e]},e))]}),(0,Q.jsxs)(He,{style:{height:`100%`,background:Pe.colorBgContainer},children:[(0,Q.jsxs)(jy,{width:200,style:{background:Pe.colorBgElevated,borderRight:`1px solid ${Pe.colorBorderSecondary}`,overflow:`auto`,padding:`20px 0`},children:[(0,Q.jsx)(`div`,{style:{padding:`0 24px 16px`,fontWeight:600,fontSize:18,color:Pe.colorText},children:`User Settings`}),(0,Q.jsx)(Ne,{mode:`inline`,selectedKeys:[g],onClick:({key:e})=>_(e),items:Fe,style:{border:`none`,background:`transparent`}})]}),(0,Q.jsxs)(My,{style:{padding:`24px 32px`,overflow:`auto`},children:[(0,Q.jsx)(v.Title,{level:4,style:{marginTop:0,marginBottom:20},children:{general:`General`,"env-vars":`Environment Variables`,audio:`Audio`,groups:`Groups`,"personal-api-keys":`Agor API Tokens`,"claude-code":`Claude Code`,codex:`Codex`,gemini:`Gemini`,opencode:`OpenCode`,cursor:`Cursor SDK`,copilot:`GitHub Copilot`}[g]||`User Settings`}),(()=>{switch(g){case`general`:return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(Y,{form:p,layout:`vertical`,children:[(0,Q.jsx)(Y.Item,{label:`Name`,style:{marginBottom:24},children:(0,Q.jsxs)(et,{gap:8,children:[(0,Q.jsx)(Y.Item,{name:`emoji`,noStyle:!0,children:(0,Q.jsx)(ll,{form:p,fieldName:`emoji`,defaultEmoji:`👤`})}),(0,Q.jsx)(Y.Item,{name:`name`,noStyle:!0,style:{flex:1},children:(0,Q.jsx)(J,{placeholder:`John Doe`,style:{flex:1}})})]})}),(0,Q.jsx)(Y.Item,{label:`Email`,name:`email`,rules:[{required:!0,message:`Please enter an email`},{type:`email`,message:`Please enter a valid email`}],children:(0,Q.jsx)(J,{placeholder:`user@example.com`})}),(0,Q.jsx)(Y.Item,{label:`Unix Username`,name:`unix_username`,help:mt(o?.role,bt.ADMIN)?`Unix user for process impersonation (alphanumeric, hyphens, underscores only)`:`Maintained by administrators`,rules:[{pattern:/^[a-z0-9_-]+$/,message:`Only lowercase letters, numbers, hyphens, and underscores allowed`},{max:32,message:`Unix username must be 32 characters or less`}],children:(0,Q.jsx)(J,{placeholder:`johnsmith`,maxLength:32,disabled:!mt(o?.role,bt.ADMIN)})}),(0,Q.jsx)(Y.Item,{label:`Password`,name:`password`,help:`Leave blank to keep current password`,children:(0,Q.jsx)(J.Password,{placeholder:`••••••••`})}),(0,Q.jsx)(Y.Item,{label:(0,Q.jsxs)(G,{size:4,children:[`Enable Live Event Stream`,(0,Q.jsx)(u,{color:Pe.colorPrimary,style:{fontSize:10,marginLeft:4},children:`BETA`})]}),name:`eventStreamEnabled`,valuePropName:`checked`,tooltip:`Show/hide the event stream icon in the navbar. When enabled, you can view live WebSocket events for debugging.`,children:(0,Q.jsx)(j,{})}),(0,Q.jsx)(Y.Item,{label:`Use Slack avatar when available`,name:`useSlackAvatar`,valuePropName:`checked`,tooltip:`When enabled, Agor shows your Slack-synced profile image. Turn this off to keep using your emoji tile.`,children:(0,Q.jsx)(j,{})}),(0,Q.jsx)(Y.Item,{label:`Role`,name:`role`,rules:[{required:!0,message:`Please select a role`}],help:mt(o?.role,bt.ADMIN)?void 0:`Maintained by administrators`,children:(0,Q.jsx)(l,{disabled:!mt(o?.role,bt.ADMIN),options:ht.map(e=>({value:e.value,label:e.label,title:e.description}))})}),b&&(0,Q.jsx)(Y.Item,{label:`Groups`,name:`groupIds`,help:`Group memberships affect group-aware branch permissions.`,children:(0,Q.jsx)(l,{mode:`multiple`,loading:H,disabled:!ie&&!H,placeholder:`Select groups...`,options:oe,...Yh})}),mt(o?.role,bt.ADMIN)&&n&&n.user_id!==o?.user_id&&(0,Q.jsx)(Y.Item,{name:`must_change_password`,valuePropName:`checked`,children:(0,Q.jsx)(U,{children:`Force password change on next login`})})]}),d&&n?.user_id===o?.user_id&&(0,Q.jsxs)(`div`,{style:{marginTop:24,paddingTop:20,borderTop:`1px solid ${Pe.colorBorderSecondary}`},children:[(0,Q.jsx)(v.Title,{level:5,style:{marginTop:0},children:`Onboarding`}),(0,Q.jsx)(v.Paragraph,{type:`secondary`,children:`Reopen the assistant setup wizard from the beginning. Existing repos, boards, branches, and credentials stay in place.`}),(0,Q.jsx)(B,{title:`Restart onboarding?`,description:`This clears saved wizard progress and opens onboarding again.`,okText:`Restart`,cancelText:`Cancel`,onConfirm:d,children:(0,Q.jsx)(s,{children:`Restart onboarding`})})]})]});case`env-vars`:return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(v.Paragraph,{type:`secondary`,style:{marginBottom:16},children:`Environment variables are encrypted at rest and available to all sessions for this user.`}),(0,Q.jsx)(z,{type:`info`,showIcon:!0,style:{marginBottom:16},title:`Looking for SDK credentials?`,description:(0,Q.jsxs)(`span`,{children:[`API keys and SDK config (Anthropic, OpenAI, Gemini, Copilot) live under each tool's screen in the `,(0,Q.jsx)(`strong`,{children:`Agentic Tools`}),` section. Per-tool config takes precedence over global env vars and is scoped so credentials never leak across SDKs.`]})}),(0,Q.jsx)(Ey,{envVars:F,onSave:Te,onScopeChange:Ee,onDelete:Oe,loading:ee})]});case`audio`:return(0,Q.jsx)(ky,{user:n,form:O});case`groups`:return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(v.Paragraph,{type:`secondary`,style:{marginBottom:16},children:`Add or remove this user from admin-managed groups.`}),(0,Q.jsx)(Y,{form:p,layout:`vertical`,children:(0,Q.jsx)(Y.Item,{label:`Groups`,name:`groupIds`,help:`Group memberships affect group-aware branch permissions.`,children:(0,Q.jsx)(l,{mode:`multiple`,loading:H,disabled:!ie&&!H,placeholder:`Select groups...`,options:oe,...Yh})})})]});case`personal-api-keys`:return(0,Q.jsx)(Ay,{client:r});case`claude-code`:case`claude-code-cli`:case`codex`:case`gemini`:case`opencode`:case`copilot`:case`cursor`:{let e=g,t=k[e],r={"claude-code":`Claude Code`,"claude-code-cli":`Claude Code CLI`,codex:`Codex`,gemini:`Gemini`,opencode:`OpenCode`,copilot:`Copilot`,cursor:`Cursor SDK`},i=U_[e]??[],a=A[e]??{},o=Object.fromEntries(i.map(t=>[t.field,!!N[`${e}.${t.field}`]])),c=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(v.Paragraph,{type:`secondary`,style:{marginBottom:16},children:[`Configure default settings for `,r[e],`. These will prepopulate session creation forms.`]}),(0,Q.jsx)(Y,{form:t,layout:`vertical`,onValuesChange:(t,n)=>{fe(t=>({...t,[e]:n})),pe(e)},children:(0,Q.jsx)(n_,{agenticTool:e,mcpServerById:f,showHelpText:!1})},e),(0,Q.jsx)(`div`,{style:{marginTop:16},children:(0,Q.jsx)(s,{onClick:()=>Ae(e),children:`Clear Defaults`})})]});return i.length===0?c:(0,Q.jsx)(m,{defaultActiveKey:`auth`,items:[{key:`auth`,label:`Authentication`,children:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(v.Paragraph,{type:`secondary`,style:{marginBottom:16},children:[`Per-user credentials and config for `,r[e],`. Encrypted at rest; injected into the agent runtime, not the prompt transcript; and preferred over daemon globals and env vars.`]}),(0,Q.jsx)(W_,{tool:e,fieldStatus:a,onSave:(t,n)=>Se(e,t,n),onClear:t=>we(e,t),saving:o,publicValues:n?.agentic_tools_public_values?.[e]})]})},{key:`defaults`,label:`Defaults`,children:c}]})}default:return null}})()]})]})]})},Iy=({userById:e,gatewayChannelById:t=new Map,client:n,currentUser:r,onCreate:i,onUpdate:o,onDelete:c})=>{let{showError:d}=cf(),[f,p]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(null),[_,y]=(0,Z.useState)([]),[b,x]=(0,Z.useState)([]),[S,C]=(0,Z.useState)(``),[w]=Y.useForm(),T=mt(r?.role,bt.ADMIN),E=(0,Z.useCallback)(async()=>{if(!n||!T){y([]),x([]);return}let[e,t]=await Promise.all([n.service(`groups`).findAll({query:{archived:!1}}),n.service(`group-memberships`).findAll({})]);y(e),x(t)},[n,T]);(0,Z.useEffect)(()=>{E().catch(e=>d(`Failed to load user groups: ${e instanceof Error?e.message:String(e)}`))},[E,d]);let D=(0,Z.useMemo)(()=>{let e=new Map;for(let t of b){let n=e.get(t.user_id)||[];n.push(t.group_id),e.set(t.user_id,n)}return e},[b]),O=(0,Z.useMemo)(()=>new Map(_.map(e=>[e.group_id,e])),[_]),k=(0,Z.useMemo)(()=>Bf(If(e,(e,t)=>e.email.localeCompare(t.email,void 0,{sensitivity:`base`})),S,[e=>e.email,e=>e.name,e=>e.unix_username,e=>e.role,e=>(D.get(e.user_id)||[]).map(e=>O.get(e)).filter(e=>!!e).flatMap(e=>[e.name,e.slug])]),[e,S,D,O]),A=e=>{c?.(e)},j=()=>{w.validateFields().then(e=>{i?.({email:e.email,password:e.password,name:e.name,emoji:e.emoji||`👤`,role:e.role||bt.MEMBER,unix_username:e.unix_username,must_change_password:e.must_change_password||!1}),w.resetFields(),p(!1)}).catch(()=>{})},M=e=>{switch(e){case`superadmin`:return`purple`;case`admin`:return`red`;case`member`:return`blue`;case`viewer`:return`default`;default:return`default`}};return(0,Q.jsx)(m,{defaultActiveKey:`users`,items:[{key:`users`,label:`Users`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{style:{marginBottom:16,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,Q.jsx)(v.Text,{type:`secondary`,children:`Manage user accounts and permissions.`}),(0,Q.jsxs)(G,{children:[(0,Q.jsx)(J,{allowClear:!0,placeholder:`Search name, email, username, role, or groups`,value:S,onChange:e=>C(e.target.value),style:{width:320}}),(0,Q.jsx)(s,{type:`primary`,icon:(0,Q.jsx)(L,{}),onClick:()=>p(!0),children:`New User`})]})]}),(0,Q.jsx)(ue,{dataSource:k,columns:[{title:`User`,dataIndex:`email`,key:`email`,render:(e,t)=>(0,Q.jsxs)(G,{children:[(0,Q.jsx)(im,{user:t,size:28,fontSize:`20px`}),(0,Q.jsx)(`span`,{children:(0,Q.jsx)(Uf,{text:e,query:S})})]})},{title:`Name`,dataIndex:`name`,key:`name`,render:e=>(0,Q.jsx)(v.Text,{children:e?(0,Q.jsx)(Uf,{text:e,query:S}):`—`})},{title:`Role`,dataIndex:`role`,key:`role`,width:120,render:e=>(0,Q.jsx)(u,{color:M(e),children:e.toUpperCase()})},{title:`Groups`,key:`groups`,width:280,render:(e,t)=>{let n=D.get(t.user_id)||[];return n.length===0?(0,Q.jsx)(v.Text,{type:`secondary`,children:`—`}):(0,Q.jsx)(G,{size:[4,4],wrap:!0,children:n.map(e=>O.get(e)).filter(e=>!!e).sort((e,t)=>e.name.localeCompare(t.name)).map(e=>(0,Q.jsx)(u,{children:(0,Q.jsx)(Uf,{text:e.name,query:S})},e.group_id))})}},{title:`Actions`,key:`actions`,width:88,render:(e,t)=>(0,Q.jsxs)(vm,{children:[(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(P,{}),onClick:()=>g(t)}),(0,Q.jsx)(B,{title:`Delete user?`,description:`Are you sure you want to delete user "${t.email}"?`,onConfirm:()=>A(t.user_id),okText:`Delete`,cancelText:`Cancel`,okButtonProps:{danger:!0},children:(0,Q.jsx)(s,{type:`text`,size:`small`,icon:(0,Q.jsx)(re,{}),danger:!0})})]})}],rowKey:`user_id`,pagination:!1,size:`small`}),(0,Q.jsx)(a,{title:`Create User`,open:f,onOk:j,onCancel:()=>{w.resetFields(),p(!1)},okText:`Create`,width:800,children:(0,Q.jsxs)(Y,{form:w,layout:`vertical`,style:{marginTop:16},children:[(0,Q.jsx)(Y.Item,{label:`Name`,style:{marginBottom:24},children:(0,Q.jsxs)(et,{gap:8,children:[(0,Q.jsx)(Y.Item,{name:`emoji`,initialValue:`👤`,noStyle:!0,children:(0,Q.jsx)(ll,{form:w,fieldName:`emoji`,defaultEmoji:`👤`})}),(0,Q.jsx)(Y.Item,{name:`name`,noStyle:!0,style:{flex:1},children:(0,Q.jsx)(J,{placeholder:`John Doe`,style:{flex:1}})})]})}),(0,Q.jsx)(Y.Item,{label:`Email`,name:`email`,rules:[{required:!0,message:`Please enter an email`},{type:`email`,message:`Please enter a valid email`}],children:(0,Q.jsx)(J,{placeholder:`user@example.com`})}),(0,Q.jsx)(Y.Item,{label:`Unix Username`,name:`unix_username`,help:`Optional. Unix user for process impersonation (alphanumeric, hyphens, underscores only)`,rules:[{pattern:/^[a-z0-9_-]+$/,message:`Only lowercase letters, numbers, hyphens, and underscores allowed`},{max:32,message:`Unix username must be 32 characters or less`}],children:(0,Q.jsx)(J,{placeholder:`johnsmith`,maxLength:32})}),(0,Q.jsx)(Y.Item,{label:`Password`,name:`password`,rules:[{required:!0,message:`Please enter a password`},{min:8,message:`Password must be at least 8 characters`}],children:(0,Q.jsx)(J.Password,{placeholder:`••••••••`})}),(0,Q.jsx)(Y.Item,{label:`Role`,name:`role`,initialValue:bt.MEMBER,rules:[{required:!0,message:`Please select a role`}],children:(0,Q.jsx)(l,{options:ht.map(e=>({value:e.value,label:e.label,title:e.description}))})}),(0,Q.jsx)(Y.Item,{name:`must_change_password`,valuePropName:`checked`,initialValue:!1,children:(0,Q.jsx)(U,{children:`Force password change on first login`})})]})}),(0,Q.jsx)(Fy,{open:!!h,onClose:()=>{g(null),E()},user:h,client:n,currentUser:r,onUpdate:o})]})},...T?[{key:`avatars`,label:`Avatars`,children:(0,Q.jsx)(ly,{client:n,gatewayChannelById:t})}]:[]]})},{Sider:Ly,Content:Ry}=He,zy=({open:e,onClose:t,client:n,currentUser:r,boardById:o,boardObjects:s,repoById:c,branchById:l,sessionsByBranch:u,userById:d,mcpServerById:f,cardById:m=new Map,cardTypeById:g=new Map,activeTab:_=`boards`,onTabChange:v,onCreateBoard:b,onUpdateBoard:x,onDeleteBoard:S,onArchiveBoard:C,onUnarchiveBoard:w,onCreateRepo:T,onCreateLocalRepo:E,onUpdateRepo:D,onDeleteRepo:O,onArchiveOrDeleteBranch:k,onUnarchiveBranch:A,onUpdateBranch:j,onCreateBranch:M,onStartEnvironment:N,onStopEnvironment:P,onCreateUser:F,onUpdateUser:I,onDeleteUser:ee,onCreateMCPServer:L,onDeleteMCPServer:R,gatewayChannelById:ne=new Map,onCreateGatewayChannel:z,onUpdateGatewayChannel:B,onDeleteGatewayChannel:H,artifactById:re=new Map,onUpdateArtifact:ie,onDeleteArtifact:U,onCreateAssistant:ae,branchStorageConfig:oe})=>{let[ce,le]=(0,Z.useState)(null),[ue,de]=(0,Z.useState)(null),[fe,pe]=(0,Z.useState)([]),[me,he]=(0,Z.useState)(!1),ge=e=>{le(e),de(c.get(e.repo_id)||null),pe(u.get(e.branch_id)||[]),he(!0)},_e=()=>{he(!1),le(null),de(null),pe([])},ve=async(e,t)=>{await k?.(e,t),_e()},{token:ye}=X.useToken(),be=(0,Z.useMemo)(()=>new Set(Of),[]),xe=Tf(`gateway`),Se=Tf(`mcp_servers`),Ce=Tf(`artifacts`),we=Tf(`cards`),Te=mt(r?.role,bt.ADMIN),G=(0,Z.useMemo)(()=>[{key:`workspace`,label:`Workspace`,type:`group`,children:[{key:`boards`,label:`Boards`,icon:(0,Q.jsx)(te,{})},{key:`repos`,label:`Repositories`,icon:(0,Q.jsx)(se,{})},{key:`branches`,label:`Branches`,icon:(0,Q.jsx)(p,{})},{key:`assistants`,label:`Assistants`,icon:(0,Q.jsx)(h,{})},...we?[{key:`cards`,label:(0,Q.jsxs)(`span`,{children:[`Cards`,` `,(0,Q.jsx)(`span`,{style:{fontSize:10,fontWeight:600,padding:`0 4px`,borderRadius:3,background:ye.colorWarningBg,color:ye.colorWarningText,border:`1px solid ${ye.colorWarningBorder}`,marginLeft:4},children:`Beta`})]}),icon:(0,Q.jsx)(Ee,{})}]:[],...Ce?[{key:`artifacts`,label:`Artifacts`,icon:(0,Q.jsx)(tt,{})}]:[]]},{key:`integrations`,label:`Integrations`,type:`group`,children:[{key:`agentic-tools`,label:`Agentic Tools`,icon:(0,Q.jsx)($e,{})},...Se&&Te?[{key:`mcp`,label:`MCP Servers`,icon:(0,Q.jsx)(Ie,{})}]:[],...xe&&Te?[{key:`gateway`,label:`Gateway Channels`,icon:(0,Q.jsx)(V,{})}]:[]]},{key:`admin`,label:`Admin`,type:`group`,children:[...Te?[{key:`groups`,label:`Groups`,icon:(0,Q.jsx)(W,{})}]:[],{key:`users`,label:`Users`,icon:(0,Q.jsx)(W,{})}]},{key:`system`,label:`System`,type:`group`,children:[{key:`about`,label:`About`,icon:(0,Q.jsx)(y,{})}]}],[xe,Se,Ce,we,Te,ye]);return(0,Q.jsxs)(a,{title:null,open:e,onCancel:t,footer:null,closable:!0,width:1200,style:{top:40},styles:{wrapper:{padding:0,overflow:`hidden`},container:{padding:0,borderRadius:8,overflow:`hidden`},header:{display:`none`},body:{padding:0,height:`calc(100vh - 200px)`,minHeight:500,maxHeight:800}},closeIcon:(0,Q.jsx)(i,{}),children:[(0,Q.jsxs)(He,{style:{height:`100%`,background:ye.colorBgContainer},children:[(0,Q.jsxs)(Ly,{width:240,style:{background:ye.colorBgElevated,borderRight:`1px solid ${ye.colorBorderSecondary}`,overflow:`auto`,padding:`20px 0`},children:[(0,Q.jsx)(`div`,{style:{padding:`0 24px 16px`,fontWeight:600,fontSize:18,color:ye.colorText},children:`Settings`}),(0,Q.jsx)(Ne,{mode:`inline`,selectedKeys:[_],onClick:({key:e})=>{be.has(e)&&v?.(e)},items:G,style:{border:`none`,background:`transparent`}})]}),(0,Q.jsx)(Ry,{style:{padding:`40px 32px 32px`,overflow:`auto`},children:(()=>{switch(_){case`boards`:return(0,Q.jsx)(dv,{client:n,boardById:o,sessionsByBranch:u,branchById:l,onCreate:b,onUpdate:x,onDelete:S,onArchive:C,onUnarchive:w});case`repos`:return(0,Q.jsx)(oy,{repoById:c,onCreate:T,onCreateLocal:E,onUpdate:D,onDelete:O});case`branches`:return(0,Q.jsx)(xv,{client:n,branchById:l,repoById:c,boardById:o,sessionsByBranch:u,onArchiveOrDelete:k,onUnarchive:A,onCreate:M,onRowClick:ge,onStartEnvironment:N,onStopEnvironment:P,onClose:t,branchStorageConfig:oe});case`assistants`:return(0,Q.jsx)(rv,{branchById:l,repoById:c,boardById:o,sessionsByBranch:u,userById:d,onArchiveOrDelete:k,onRowClick:ge,onCreateAssistant:ae,onClose:t});case`cards`:return(0,Q.jsx)(Ov,{client:n,cardById:m,cardTypeById:g,boardById:o,boardObjects:s});case`artifacts`:return(0,Q.jsx)(nv,{artifactById:re,branchById:l,boardById:o,onUpdate:ie,onDelete:U,onClose:t});case`mcp`:return(0,Q.jsx)(ym,{mcpServerById:f,client:n,onCreate:L,onDelete:R});case`agentic-tools`:return(0,Q.jsx)(q_,{client:n});case`gateway`:return(0,Q.jsx)($v,{client:n,gatewayChannelById:ne,branchById:l,userById:d,mcpServerById:f,currentUser:r,onCreate:z,onUpdate:B,onDelete:H});case`groups`:return(0,Q.jsx)(iy,{client:n,currentUser:r,userById:d});case`users`:return(0,Q.jsx)(Iy,{userById:d,gatewayChannelById:ne,client:n,currentUser:r,onCreate:F,onUpdate:I,onDelete:ee});case`about`:return(0,Q.jsx)(B_,{client:n,connected:n?.io?.connected??!1,connectionError:void 0,isAdmin:mt(r?.role,bt.ADMIN)});default:return null}})()})]}),(0,Q.jsx)(L_,{open:me,onClose:_e,branch:ce,repo:ue,sessions:fe,boardObjects:s,client:n,currentUser:r,onUpdateBranch:j,onUpdateRepo:D,onArchiveOrDelete:ve,onOpenSettings:t})]})},By=({open:e,user:t,client:n,onClose:r,onUpdateUser:i,onRefreshCurrentUser:a,onRestartOnboarding:o})=>(0,Q.jsx)(Fy,{open:e,onClose:r,user:t,currentUser:t,client:n,onUpdate:async(e,t)=>{await i(e,t),await a()},onRestartOnboarding:o}),Vy=e=>e.startsWith(`/`)?e:`/${e}`;function Hy(e,t){return Zn({path:t,end:!0},Vy(e))!==null}function Uy(e,t){return e.routePaths.some(e=>Hy(t,e))}function Wy(e){return e}var Gy=[`/knowledge`,`/knowledge/:namespaceSlug/*`,`/kb`,`/kb/:namespaceSlug/*`],Ky=Wy({id:`knowledge`,label:`Knowledge`,routePaths:Gy,startsWorkspaceRuntime:!1,usesDeviceRouter:!1,usesSharedUserSettings:!0,branding:go(`Knowledge`)}),qy=[`/a/:artifactShortId/fullscreen`],Jy=Wy({id:`artifact-fullscreen`,label:`Artifact fullscreen`,routePaths:qy,startsWorkspaceRuntime:!1,usesDeviceRouter:!1,usesSharedUserSettings:!0,branding:go(`Artifact`)}),Yy=Wy({id:`demo`,label:`Demo`,routePaths:[`/demo/streamdown`,`/demo/marketing-screenshots`],startsWorkspaceRuntime:!1,usesDeviceRouter:!1,usesSharedUserSettings:!1,branding:go(`Demo`)}),Xy=Wy({id:`workspace`,label:`Workspace`,routePaths:[`/*`],startsWorkspaceRuntime:!0,usesDeviceRouter:!0,usesSharedUserSettings:!1,branding:`dynamic`}),Zy=[Ky,Jy,Yy,Xy];function Qy(e){return Zy.find(t=>Uy(t,e))??Xy}function $y(e){return Qy(e).usesDeviceRouter}function eb(e){let t=Qy(e),n=t.startsWorkspaceRuntime,[r,i]=(0,Z.useState)(n);return(0,Z.useEffect)(()=>{n&&i(!0)},[n]),{currentSurface:t,routeRequiresWorkspaceSurface:n,workspaceSurfaceStarted:r,workspaceSurfaceShouldRun:n||r}}function tb(){return typeof window<`u`&&window.innerWidth<768?!0:typeof navigator<`u`?/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent):!1}async function nb({client:e,userId:t,email:n,newPassword:r,login:i,logout:a}){await e.service(`users`).patch(t,{password:r});let o=await i(n,r);return o||await a(),o}async function rb(e,t,n,r){let i=new Set(n),a=new Set(r);await Promise.all([...r.filter(e=>!i.has(e)).map(n=>e.service(`sessions/${t}/mcp-servers`).create({mcpServerId:n})),...n.filter(e=>!a.has(e)).map(n=>e.service(`sessions/${t}/mcp-servers`).remove(n))])}var ib={start:{present:`start`,gerund:`Starting`},stop:{present:`stop`,gerund:`Stopping`},nuke:{present:`nuke`,gerund:`Nuking`}},ab=new Set;function ob(e,t,n){let r=null;return()=>(r??=t().then(t=>(ab.add(e),n(t))),r)}var sb=ob(`workspace`,()=>on(()=>import(`./App-hJtcOxHv.js`),__vite__mapDeps([10,2,9,3,1,11,12,13,14,15,16,17,18,19,20,21,22,23])),e=>({default:e.App})),cb=ob(`knowledge`,()=>on(()=>import(`./KnowledgePage-Dz8YAMYC.js`),__vite__mapDeps([24,2,12,9,3,1,13,14,15,19,23,16,17])),e=>({default:e.KnowledgePage})),lb=ob(`artifact-fullscreen`,()=>on(()=>import(`./ArtifactFullscreenPage-B3wT8t8f.js`),__vite__mapDeps([25,2,9,3,1,26,19,27,13,14])),e=>({default:e.ArtifactFullscreenPage})),ub=ob(`mobile`,()=>on(()=>import(`./MobileApp-BpgSG_gz.js`),__vite__mapDeps([28,2,12,9,3,1,13,14,15,21,11,16,17])),e=>({default:e.MobileApp})),db=ob(`demo`,()=>on(()=>import(`./StreamdownDemoPage-okKKR2QH.js`),__vite__mapDeps([29,3,2,1])),e=>({default:e.StreamdownDemoPage})),fb=(0,Z.lazy)(()=>on(()=>import(`./MarketingScreenshotPage-CmDPBHOl.js`).then(e=>({default:e.MarketingScreenshotPage})),__vite__mapDeps([30,2,18,9,3,1,11,12,13,14,15,16,17,19,20,31]))),pb=(0,Z.lazy)(sb),mb=(0,Z.lazy)(cb),hb=(0,Z.lazy)(lb),gb=(0,Z.lazy)(ub),_b=(0,Z.lazy)(db),vb={workspace:sb,knowledge:cb,"artifact-fullscreen":lb,demo:db,mobile:ub};function yb(e,t){return t.startsWith(`/m`)?`mobile`:e}function bb(e){return ab.has(e)?Promise.resolve():vb[e]()}function xb(){let e=Vr(),t=Wr();return(0,Z.useEffect)(()=>{if(!$y(e.pathname))return;let n=()=>{let n=tb(),r=e.pathname.startsWith(`/m`);n&&!r?t(`/m`,{replace:!0}):!n&&r&&t(`/`,{replace:!0})};n();let r,i=()=>{clearTimeout(r),r=setTimeout(n,200)};return window.addEventListener(`resize`,i),()=>{window.removeEventListener(`resize`,i),clearTimeout(r)}},[e.pathname,t]),null}function Sb(){let{showSuccess:e,showError:t,showWarning:n,showLoading:r,destroy:i}=cf(),a=Wr(),o=Vr(),{currentSurface:s,workspaceSurfaceShouldRun:c}=eb(o.pathname);Pf(s);let l=s.usesSharedUserSettings,u=yb(s.id,o.pathname),[d,f]=(0,Z.useState)(()=>ab.has(u));(0,Z.useEffect)(()=>{let e=!1;return ab.has(u)||f(!1),bb(u).catch(()=>{}).finally(()=>{e||f(!0)}),()=>{e=!0}},[u]);let{config:p,instanceConfig:m,onboardingConfig:h,servicesConfig:g,featuresConfig:_,loading:v,error:y}=af(),{user:b,authenticated:x,loading:S,error:C,accessToken:w,login:T,logout:E,reAuthenticate:D}=rf(),{client:O,connected:k,connecting:A,error:j,retryConnection:M}=Cu({accessToken:x?w:null}),N=(0,Z.useRef)(new Map);(0,Z.useEffect)(()=>{if(!O)return;let n=O.service(`branches`),r=n=>{let r=N.current.get(n.branch_id);if(!r)return;let i=n.environment_instance?.last_command;if(!i||i.action!==r.action)return;let a=Date.parse(i.timestamp);if(Number.isFinite(a)&&a+1e3<r.requestedAt)return;let o=ib[r.action];if(i.status===`succeeded`)e(`Environment ${o.present} command executed successfully`,{key:r.key}),N.current.delete(n.branch_id);else if(i.status===`failed`){let e=i.message?`: ${i.message}`:``;t(`Environment ${o.present} command failed${e}`,{key:r.key}),N.current.delete(n.branch_id)}};return n.on(`patched`,r),()=>{n.removeListener(`patched`,r)}},[O,t,e]);let{capturedSha:P,currentSha:F,outOfSync:I}=Cf(O),ee=o.pathname.match(/^\/s\/([^/]+)\/?$/)?.[1]??null,{initialLoadItems:L,initialLoadComplete:te,loadingStage:R,loading:ne,error:B}=Wd(O,{enabled:c&&!b?.must_change_password,directSessionId:ee}),{createSession:V,forkSession:H,btwForkSession:re,spawnSession:ie,updateSession:U,deleteSession:ae}=Df(O),{createBoard:oe,updateBoard:se,deleteBoard:ce,archiveBoard:le,unarchiveBoard:ue}=lf(O),[de,fe]=(0,Z.useState)(null),[pe,me]=(0,Z.useState)(!1),[he,ge]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{o.pathname===`/gateway/github/setup`&&o.search.includes(`installation_id`)&&fe(`gateway`)},[o.pathname,o.search]);let[_e,ve]=(0,Z.useState)(new Map),[ye,be]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{!ne&&!B&&te&&be(!0)},[ne,te,B]);let xe=ff({connecting:A,loading:ne,dataError:B,mustChangePassword:!!b?.must_change_password,initialLoadComplete:te&&d}),Se=(0,Q.jsx)(po,{phase:xe===`done`?`fading`:xe,connecting:A,loadingStage:R,items:L}),Ce=c?Se:(0,Q.jsx)(po,{message:`Loading surface…`}),we=jc(e=>b?e.userById.get(b.user_id)??null:null),W=b?we||b:null;(0,Z.useEffect)(()=>{Ja({buildSha:P,userEmail:W?.email??null})},[P,W?.email]);let[Te,G]=(0,Z.useState)(!1),[Ee,De]=(0,Z.useState)(0);(0,Z.useEffect)(()=>{W&&W.onboarding_completed===!1&&!W.must_change_password&&k&&c&&s.startsWorkspaceRuntime&&!ne&&G(!0)},[W,k,c,s.startsWorkspaceRuntime,ne]);let Oe=async e=>{if(G(!1),W){if(ze(W.user_id,{onboarding_completed:!0,preferences:{...W.preferences,mainBoardId:e.boardId||W.preferences?.mainBoardId,onboarding:{path:e.path,branchId:e.branchId,boardId:e.boardId}}},{silent:!0}).catch(()=>{}),e.path===`assistant`&&O)try{await O.service(`config`).patch(null,{onboarding:{assistantPending:!1}})}catch{}e.sessionId?a(rn(e.sessionId)):e.boardId?a(tn(e.boardId,$.getState().boardById.get(e.boardId)?.slug)):a(`/`)}};if(v)return(0,Q.jsx)(po,{message:`Loading…`});if(y&&!p)return(0,Q.jsx)(`div`,{style:{height:`100vh`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`2rem`},children:(0,Q.jsx)(z,{type:`warning`,title:`Could not fetch daemon configuration`,description:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{children:y.message}),(0,Q.jsx)(`p`,{children:`Defaulting to requiring authentication. Start the daemon with:`}),(0,Q.jsx)(`p`,{children:(0,Q.jsx)(`code`,{children:`cd apps/agor-daemon && pnpm dev`})})]}),showIcon:!0})});let ke=typeof window<`u`&&!!(localStorage.getItem(`agor-access-token`)||localStorage.getItem(`agor-refresh-token`));if(!S&&!x&&!ke)return(0,Q.jsx)(To,{onLogin:T,error:C,externalLaunchLoginRedirectUrl:p?.externalLaunch?.enabled?p.externalLaunch.loginRedirectUrl:void 0});if(ke&&(!k||!x)&&c&&!ye)return(0,Q.jsx)(po,{message:`Reconnecting to daemon…`});if(S)return(0,Q.jsx)(po,{message:`Authenticating…`});if(j)return(0,Q.jsx)(`div`,{style:{height:`100vh`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`2rem`},children:(0,Q.jsx)(z,{type:`error`,title:`Failed to connect to Agor daemon`,description:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{children:j}),(0,Q.jsxs)(`p`,{children:[`Start the daemon with: `,(0,Q.jsx)(`code`,{children:`cd apps/agor-daemon && pnpm dev`})]})]}),showIcon:!0})});if(c&&(xe!==`done`||!d))return Se;if(c&&B&&!b?.must_change_password)return(0,Q.jsx)(`div`,{style:{height:`100vh`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`2rem`},children:(0,Q.jsx)(z,{type:`error`,title:`Failed to load data`,description:B,showIcon:!0})});let Ae=async(n,r)=>{try{let r=n.branch_id;if(!r)throw Error(`Branch ID is required to create a session`);let i=await V({...n,branch_id:r});if(i){if(n.mcpServerIds&&n.mcpServerIds.length>0)for(let e of n.mcpServerIds)try{await O?.service(`sessions/${i.session_id}/mcp-servers`).create({mcpServerId:e})}catch(t){console.error(`Failed to associate MCP server ${e}:`,t)}return n.envVarNames&&n.envVarNames.length>0&&await ut(i.session_id,n.envVarNames),e(`Session created!`),n.initialPrompt?.trim()&&await K(i.session_id,n.initialPrompt,n.permissionMode),i.session_id}else return t(`Failed to create session`),null}catch(e){return t(`Failed to create session: ${e instanceof Error?e.message:String(e)}`),null}},je=(e,t)=>{ve(n=>{let r=new Map(n);return t.trim()?r.set(e,t):r.delete(e),r})},Me=e=>{ve(t=>{let n=new Map(t);return n.delete(e),n})},Ne=async(n,r)=>{try{let t=await H(n,r);e(`Session forked successfully!`),je(t.session_id,r),Me(n)}catch(e){throw t(`Failed to fork session: ${e instanceof Error?e.message:`Failed to fork session`}`),e}},Pe=async(n,r)=>{try{let t=await re(n,r);e(`Side question sent via btw fork`),je(t.session_id,r),Me(n)}catch(e){throw t(`Failed to create btw fork: ${e instanceof Error?e.message:`Failed to create btw fork`}`),e}},Fe=async(n,r)=>{let i=typeof r==`string`?{prompt:r}:r;try{let t=await ie(n,i);e(`Subsession session spawned successfully!`),i.prompt?.trim()&&je(t.session_id,i.prompt),Me(n)}catch(e){throw t(`Failed to spawn session: ${e instanceof Error?e.message:`Failed to spawn session`}`),e}},K=async(e,n,r)=>{if(!O)return!1;try{return await O.sessions.prompt(e,n,{permissionMode:r,messageSource:`agor`}),Me(e),!0}catch(e){return t(`Failed to send prompt: ${e instanceof Error?e.message:String(e)}`),console.error(`Prompt error:`,e),!1}},Ie=async(n,r)=>{await U(n,r)?e(`Session updated successfully!`):t(`Failed to update session`)},Le=async n=>{await ae(n)?e(`Session deleted successfully!`):t(`Failed to delete session`)},Re=async n=>{if(O)try{await O.service(`users`).create(n),e(`User created successfully!`)}catch(e){t(`Failed to create user: ${e instanceof Error?e.message:String(e)}`)}},ze=async(n,r,i={})=>{if(O)try{await O.service(`users`).patch(n,r),i.silent||e(`User updated successfully!`)}catch(e){throw i.silent||t(`Failed to update user: ${e instanceof Error?e.message:String(e)}`),e}},Be=async()=>{if(!W)return;let e={...W.preferences??{}};delete e.onboarding;try{await ze(W.user_id,{preferences:e},{silent:!0})}catch(e){t(`Failed to restart onboarding: ${e instanceof Error?e.message:String(e)}`);return}me(!1),De(e=>e+1),G(!0)},q=async n=>{if(O)try{await O.service(`users`).remove(n),e(`User deleted successfully!`)}catch(e){t(`Failed to delete user: ${e instanceof Error?e.message:String(e)}`)}},Ve=async(t,n)=>{if(!O)throw Error(`Not connected`);if(!W?.email)throw Error(`Current user is unavailable`);e(await nb({client:O,userId:t,email:W.email,newPassword:n,login:T,logout:E})?`Password changed successfully!`:`Password changed successfully. Please sign in again.`)},He=async t=>{if(t.board_id)return t;let n=await oe(t);return n&&e(`Board created successfully!`),n},Ue=async(t,n)=>{await se(t,n)&&e(`Board updated successfully!`)},We=async t=>{await ce(t)&&e(`Board deleted successfully!`)},Ge=async t=>{await le(t)&&e(`Board archived successfully!`)},Ke=async t=>{await ue(t)&&e(`Board unarchived successfully!`)},qe=async(i,a={})=>{if(!O){t(`Not connected to daemon — cannot clone repository`);return}let o=`clone-repo-${i.slug}`;a.silent||r(`Cloning ${i.slug}...`,{key:o});let s=O.service(`repos`),c=!1,l=()=>{s.removeListener(`created`,u),s.removeListener(`patched`,d),O.io.off(`repo:cloneError`,f),clearTimeout(p)},u=t=>{c||t.slug!==i.slug||t.clone_status!==`cloning`&&(c=!0,a.silent||e(`Cloned ${i.slug}`,{key:o}),l())},d=n=>{if(!(c||n.slug!==i.slug)){if(n.clone_status===`ready`)c=!0,a.silent||e(`Cloned ${i.slug}`,{key:o}),l();else if(n.clone_status===`failed`){c=!0;let e=n.clone_error,r=e?.category===`auth_failed`?` — configure GITHUB_TOKEN in Settings → API Keys for private repos`:``;a.silent||t(`Failed to clone ${i.slug}: ${e?.message??`unknown error`}${r}`,{key:o}),l()}}},f=e=>{c||e.slug!==i.slug&&e.url!==i.url||(c=!0,a.silent||t(`Failed to clone ${i.slug}: ${e.error??`unknown error`}`,{key:o}),l())},p=setTimeout(()=>{c||(c=!0,a.silent||t(`Clone of ${i.slug} timed out after 2 minutes. Check daemon logs.`,{key:o}),l())},12e4);s.on(`created`,u),s.on(`patched`,d),O.io.on(`repo:cloneError`,f);try{let e=await O.service(`repos/clone`).create({url:i.url,slug:i.slug,default_branch:i.default_branch});return e?.status===`exists`&&!c&&(c=!0,a.silent||n(`Repository "${i.slug}" is already added`,{key:o}),l()),e}catch(e){throw c||(c=!0,a.silent||t(`Failed to clone repository: ${e instanceof Error?e.message:String(e)}`,{key:o}),l()),e}},Je=async n=>{if(!O){t(`Not connected to daemon — cannot add local repository`);return}try{r(`Adding local repository...`,{key:`add-local-repo`}),await O.service(`repos/local`).create({path:n.path,slug:n.slug}),e(`Local repository added successfully!`,{key:`add-local-repo`})}catch(e){throw t(`Failed to add local repository: ${e instanceof Error?e.message:String(e)}`,{key:`add-local-repo`}),e}},J=async(n,r)=>{if(O)try{await O.service(`repos`).patch(n,r),e(`Repository updated successfully!`)}catch(e){t(`Failed to update repository: ${e instanceof Error?e.message:String(e)}`)}},Ye=async(n,r)=>{if(O)try{await O.service(`repos`).remove(n,{query:{cleanup:r}}),e(r?`Repository and files deleted successfully!`:`Repository removed from Agor (files preserved)`)}catch(e){let n=e instanceof Error?e.message:String(e);n.includes(`Partial deletion occurred:`)?t(`⚠️ PARTIAL DELETION: Some files were permanently deleted. ${n}`):n.includes(`No files were deleted`)?t(`Deletion failed, but no files were removed. ${n}`):t(`Failed to delete repository: ${n}`)}},Y=async(n,i)=>{if(!O)throw Error(`Not connected to daemon`);try{let t=i.metadataAction===`archive`?`archived`:`deleted`;r(`${i.metadataAction===`archive`?`Archiving`:`Deleting`} branch...`,{key:`archive-delete`}),await O.service(`branches/${n}/archive-or-delete`).create(i),e(`Branch ${t} successfully!`,{key:`archive-delete`})}catch(e){throw t(`Failed to ${i.metadataAction} branch: ${e instanceof Error?e.message:String(e)}`,{key:`archive-delete`}),e}},Xe=async(n,i)=>{if(!O)throw Error(`Not connected to daemon`);try{r(`Unarchiving branch...`,{key:`unarchive`}),await O.service(`branches/${n}/unarchive`).create(i||{}),e(`Branch unarchived successfully!`,{key:`unarchive`})}catch(e){throw t(`Failed to unarchive branch: ${e instanceof Error?e.message:String(e)}`,{key:`unarchive`}),e}},Ze=async(n,r,i={})=>{if(O)try{await O.service(`branches`).patch(n,r),i.silent||e(`Branch updated successfully!`)}catch(e){t(`Failed to update branch: ${e instanceof Error?e.message:String(e)}`)}},Qe=async(e,n)=>{if(!O)return null;try{r(`Creating branch...`,{key:`create-branch`});let t=await O.service(`repos/${e}/branches`).create({name:n.name,ref:n.ref,refType:n.refType,createBranch:n.createBranch,pullLatest:n.pullLatest,sourceBranch:n.sourceBranch,issue_url:n.issue_url,pull_request_url:n.pull_request_url,boardId:n.boardId,custom_context:n.custom_context,notes:n.notes,position:n.position,storage_mode:n.storage_mode,clone_depth:n.clone_depth});return i(`create-branch`),t}catch(e){return t(`Failed to create branch: ${e instanceof Error?e.message:String(e)}`,{key:`create-branch`}),null}},$e=async n=>{if(!O)return;let i=`start-env-${n}`;try{N.current.set(n,{action:`start`,key:i,requestedAt:Date.now()}),r(`Starting environment...`,{key:i}),await O.service(`branches/${n}/start`).create({}),e(`Environment start requested`,{key:i})}catch(e){N.current.delete(n),t(`Failed to start environment: ${e instanceof Error?e.message:String(e)}`,{key:i})}},et=async n=>{if(!O)return;let i=`stop-env-${n}`;try{N.current.set(n,{action:`stop`,key:i,requestedAt:Date.now()}),r(`Stopping environment...`,{key:i}),await O.service(`branches/${n}/stop`).create({}),e(`Environment stop requested`,{key:i})}catch(e){N.current.delete(n),t(`Failed to stop environment: ${e instanceof Error?e.message:String(e)}`,{key:i})}},tt=async n=>{if(!O)return;let i=`nuke-env-${n}`;try{N.current.set(n,{action:`nuke`,key:i,requestedAt:Date.now()}),r(`Nuking environment...`,{key:i}),await O.service(`branches/${n}/nuke`).create({}),e(`Environment nuke requested`,{key:i})}catch(e){N.current.delete(n),t(`Failed to nuke environment: ${e instanceof Error?e.message:String(e)}`,{key:i})}},nt=async n=>{if(O)try{r(`Starting scheduled run...`,{key:`execute-now`}),await O.service(`branches/${n}/execute-schedule-now`).create({}),e(`Scheduled run started!`,{key:`execute-now`})}catch(e){throw t(`Failed to start scheduled run: ${e instanceof Error?e.message:String(e)}`,{key:`execute-now`}),e}},rt=async n=>{if(O)try{await O.service(`mcp-servers`).create(n),e(`MCP server added successfully!`)}catch(e){t(`Failed to add MCP server: ${e instanceof Error?e.message:String(e)}`)}},it=async n=>{if(O)try{await O.service(`mcp-servers`).remove(n),e(`MCP server deleted successfully!`)}catch(e){t(`Failed to delete MCP server: ${e instanceof Error?e.message:String(e)}`)}},at=async n=>{if(O)try{await O.service(`gateway-channels`).create(n),e(`Gateway channel created!`)}catch(e){t(`Failed to create gateway channel: ${e instanceof Error?e.message:String(e)}`)}},ot=async(n,r)=>{if(O)try{await O.service(`gateway-channels`).patch(n,r),e(`Gateway channel updated!`)}catch(e){t(`Failed to update gateway channel: ${e instanceof Error?e.message:String(e)}`)}},st=async n=>{if(O)try{await O.service(`gateway-channels`).remove(n),e(`Gateway channel deleted!`)}catch(e){t(`Failed to delete gateway channel: ${e instanceof Error?e.message:String(e)}`)}},ct=async(n,r)=>{if(O)try{await O.service(`artifacts`).patch(n,r),e(`Artifact updated!`)}catch(e){t(`Failed to update artifact: ${e instanceof Error?e.message:String(e)}`)}},lt=async n=>{if(O)try{await O.service(`artifacts`).remove(n),e(`Artifact deleted!`)}catch(e){t(`Failed to delete artifact: ${e instanceof Error?e.message:String(e)}`)}},ut=async(e,n)=>{if(O)try{await O.service(`sessions/${e}/env-selections`).patch(null,{envVarNames:n})}catch(e){t(`Failed to update session env var selections: ${e instanceof Error?e.message:String(e)}`)}},dt=async(e,n)=>{if(O)try{await rb(O,e,$.getState().sessionMcpServerIds.get(e)||[],n)}catch(e){t(`Failed to update MCP servers: ${e instanceof Error?e.message:String(e)}`)}},ft=async(e,n)=>{if(O)try{await O.service(`board-comments`).create({board_id:e,created_by:b?.user_id||`unknown`,content:n,content_preview:n.slice(0,200)})}catch(e){t(`Failed to send comment: ${e instanceof Error?e.message:String(e)}`)}},X=async e=>{if(O)try{let t=$.getState().commentById.get(e);await O.service(`board-comments`).patch(e,{resolved:!t?.resolved})}catch(e){t(`Failed to resolve comment: ${e instanceof Error?e.message:String(e)}`)}},pt=async n=>{if(O)try{await O.service(`board-comments`).remove(n),e(`Comment deleted`)}catch(e){t(`Failed to delete comment: ${e instanceof Error?e.message:String(e)}`)}},mt=async(e,n)=>{if(O)try{await O.service(`board-comments/${e}/reply`).create({content:n,created_by:b?.user_id||`unknown`})}catch(e){t(`Failed to send reply: ${e instanceof Error?e.message:String(e)}`)}},ht=async(e,n)=>{if(O)try{await O.service(`board-comments/${e}/toggle-reaction`).create({user_id:b?.user_id||`unknown`,emoji:n})}catch(e){t(`Failed to toggle reaction: ${e instanceof Error?e.message:String(e)}`)}},gt=()=>{fe(null)},_t=()=>{me(!1)},vt=()=>{ge(!1)},yt=(0,Q.jsx)(mb,{client:O,currentUser:W,onUserSettingsClick:()=>me(!0),onLogout:E}),bt=(0,Q.jsx)(hb,{client:O,currentUser:W,onUserSettingsClick:()=>me(!0),onLogout:E}),xt=(0,Q.jsx)(pb,{client:O,user:W,connected:k,connecting:A,availableAgents:Ka,openSettingsTab:de,onSettingsClose:gt,openUserSettings:pe,onUserSettingsClose:_t,openNewBranchModal:he,onNewBranchModalClose:vt,suppressLeftPanel:Te,onCreateSession:Ae,onForkSession:Ne,onBtwForkSession:Pe,onSpawnSession:Fe,onSendPrompt:K,onUpdateSession:Ie,onDeleteSession:Le,onCreateBoard:He,onUpdateBoard:Ue,onDeleteBoard:We,onArchiveBoard:Ge,onUnarchiveBoard:Ke,onCreateRepo:qe,onCreateLocalRepo:Je,onUpdateRepo:J,onDeleteRepo:Ye,onArchiveOrDeleteBranch:Y,onUnarchiveBranch:Xe,onUpdateBranch:Ze,onCreateBranch:Qe,onStartEnvironment:$e,onStopEnvironment:et,onNukeEnvironment:tt,onExecuteScheduleNow:nt,onCreateUser:Re,onUpdateUser:ze,onDeleteUser:q,onCreateMCPServer:rt,onDeleteMCPServer:it,onCreateGatewayChannel:at,onUpdateGatewayChannel:ot,onDeleteGatewayChannel:st,onUpdateArtifact:ct,onDeleteArtifact:lt,onUpdateSessionMcpServers:dt,onUpdateSessionEnvSelections:ut,onSendComment:ft,onReplyComment:mt,onResolveComment:X,onToggleReaction:ht,onDeleteComment:pt,onLogout:E,onRetryConnection:M,instanceLabel:m?.label,instanceDescription:m?.description,webTerminalEnabled:_?.webTerminal===!0,branchStorageConfig:_?.branchStorage,onRestartOnboarding:Be});return(0,Q.jsx)(Ul.Provider,{value:g,children:(0,Q.jsxs)(zl,{value:{connected:k,connecting:A,outOfSync:I,capturedSha:P,currentSha:F},children:[(0,Q.jsx)(uo,{open:!!W?.must_change_password,user:W,onChangePassword:Ve,onLogout:E}),l&&(0,Q.jsx)(By,{open:pe,onClose:()=>me(!1),user:W,client:O,onUpdateUser:ze,onRefreshCurrentUser:D,onRestartOnboarding:Be}),(0,Q.jsx)(kl,{open:Te,onComplete:Oe,user:W,client:O,onCreateRepo:qe,onCreateLocalRepo:Je,onCreateBranch:Qe,onCreateSession:Ae,onUpdateUser:(e,t)=>ze(e,t,{silent:!0}),onUpdateBranch:(e,t)=>Ze(e,t,{silent:!0}),onCheckAuth:async(e,t)=>{if(!O)return{authenticated:!1,method:`none`};try{return await O.service(`check-auth`).create({tool:e,apiKey:t})}catch{return{authenticated:!1,method:`none`,hint:`Connection check failed.`}}},assistantPending:h?.assistantPending??h?.persistedAgentPending,frameworkRepoUrl:h?.frameworkRepoUrl},`${W?.user_id??`__anon__`}:${Ee}`),(0,Q.jsx)(xb,{}),(0,Q.jsx)(Z.Suspense,{fallback:Ce,children:(0,Q.jsxs)(vi,{children:[(0,Q.jsx)(gi,{path:`/demo/streamdown`,element:(0,Q.jsx)(_b,{})}),(0,Q.jsx)(gi,{path:`/demo/marketing-screenshots`,element:(0,Q.jsx)(fb,{})}),Gy.map(e=>(0,Q.jsx)(gi,{path:e,element:yt},e)),qy.map(e=>(0,Q.jsx)(gi,{path:e,element:bt},e)),(0,Q.jsx)(gi,{path:`/m/*`,element:(0,Q.jsx)(gb,{client:O,user:b,onSendPrompt:K,onSendComment:ft,onReplyComment:mt,onResolveComment:X,onToggleReaction:ht,onDeleteComment:pt,onLogout:E,promptDrafts:_e,onUpdateDraft:je})}),(0,Q.jsx)(gi,{path:`/${Ft.board}/:boardParam/`,element:xt}),(0,Q.jsx)(gi,{path:`/${Ft.session}/:sessionShortId/`,element:xt}),(0,Q.jsx)(gi,{path:`/${Ft.branch}/:branchShortId/`,element:xt}),(0,Q.jsx)(gi,{path:`/${Ft.artifact}/:artifactShortId/`,element:xt}),(0,Q.jsx)(gi,{path:`/*`,element:xt})]})})]})})}function Cb(){let{getCurrentThemeConfig:e}=Xl(),t=Vr().pathname===`/demo/marketing-screenshots`;return(0,Q.jsx)(ye,{theme:e(),children:(0,Q.jsx)(b,{children:(0,Q.jsx)(co,{variant:`global`,children:(0,Q.jsx)(Ml,{children:t?(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(po,{message:`Loading demo fixture…`}),children:(0,Q.jsx)(fb,{})}):(0,Q.jsx)(Sb,{})})})})})}function wb(){return(0,Q.jsx)(sa,{basename:Y_(),children:(0,Q.jsx)(Yl,{children:(0,Q.jsx)(Cb,{})})})}function Tb(e){return new Promise((t,n)=>{let r=document.createElement(`textarea`);r.value=e,r.style.position=`fixed`,r.style.left=`-999999px`,r.style.top=`-999999px`,document.body.appendChild(r),r.focus(),r.select();try{let e=document.execCommand(`copy`);document.body.removeChild(r),e?t():n(Error(`execCommand copy failed`))}catch(e){document.body.removeChild(r),n(e)}})}function Eb(){navigator.clipboard?.writeText||Object.defineProperty(navigator,"clipboard",{value:{writeText:Tb,readText:()=>Promise.reject(Error(`Reading clipboard not supported`))},writable:!1,configurable:!0})}Eb(),(0,Oa.createRoot)(document.getElementById(`root`)).render((0,Q.jsx)(wb,{}));export{Bp as $,$c as $t,Mh as A,Qa as An,gf as At,qm as B,Wr as Bn,Xl as Bt,Qg as C,ko as Cn,Ff as Ct,Pg as D,go as Dn,Df as Dt,Wg as E,ho as En,kf as Et,gh as F,la as Fn,cf as Ft,lm as G,vn as Gn,Il as Gt,jm as H,_a as Hn,Bl as Ht,hh as I,gi as In,af as It,rm as J,Pl as Jt,sm as K,Ll as Kt,sh as L,vi as Ln,ou as Lt,Ah as M,Wa as Mn,mf as Mt,Oh as N,Va as Nn,df as Nt,Mg as O,co as On,Tf as Ot,_h as P,Aa as Pn,uf as Pt,Vp as Q,tl as Qt,nh as R,zr as Rn,du as Rt,n_ as S,Do as Sn,Uf as St,e_ as T,mo as Tn,Af as Tt,_m as U,gn as Un,Vl as Ut,Wm as V,Kr as Vn,zl as Vt,mm as W,_n as Wn,Hl as Wt,tm as X,ll as Xt,em as Y,sl as Yt,Up as Z,il as Zt,X_ as _,Gc as _n,pp as _t,_y as a,Lc as an,Gp as at,D_ as b,jc as bn,sp as bt,wv as c,Bc as cn,Qp as ct,mv as d,Wc as dn,Hp as dt,Qc as en,$p as et,lv as f,Uc as fn,Tp as ft,$_ as g,Nc as gn,mp as gt,sv as h,qc as hn,gp as ht,my as i,Ic as in,Xp as it,jh as j,Ka as jn,pf as jt,Yh as k,Xa as kn,bf as kt,vv as l,Vc as ln,Wp as lt,cv as m,Mc as mn,vp as mt,zy as n,Yc as nn,Dp as nt,ay as o,Rc as on,Np as ot,uv as p,Pc as pn,yp as pt,im as q,Fl as qt,Fy as r,Kc as rn,Fp as rt,Tv as s,Fc as sn,Zp as st,rb as t,Jc as tn,Mp as tt,_v as u,zc as un,Ap as ut,L_ as v,Hc as vn,up as vt,Zg as w,vo as wn,Nf as wt,r_ as x,Eo as xn,lp as xt,O_ as y,$ as yn,op as yt,eh as z,Vr as zn,nu as zt};