@xopcai/xopc 0.0.125 → 0.0.126

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 (326) hide show
  1. package/README.md +56 -102
  2. package/README.zh-CN.md +51 -98
  3. package/dist/browser-ext/manifest.json +1 -1
  4. package/dist/extensions/feishu/src/schema/config-schema.d.ts +6 -6
  5. package/dist/extensions/feishu/src/workflow-progress.js +1 -1
  6. package/dist/extensions/telegram/src/adapters/streaming-adapter.js +1 -1
  7. package/dist/extensions/telegram/src/config-schema.d.ts +8 -8
  8. package/dist/extensions/telegram/src/inbound-processor.js +1 -1
  9. package/dist/extensions/telegram/src/plugin.js +1 -1
  10. package/dist/extensions/telegram/src/routing-integration.js +2 -2
  11. package/dist/extensions/telegram/src/workflow-progress.js +1 -1
  12. package/dist/extensions/telegram/xopc.extension.json +1 -1
  13. package/dist/extensions/weixin/src/api/api.js +1 -1
  14. package/dist/extensions/weixin/src/config-schema.d.ts +3 -3
  15. package/dist/extensions/weixin/src/plugin.js +1 -1
  16. package/dist/extensions/weixin/src/workflow-progress.js +1 -1
  17. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BKDKICZV.js → agent-avatar-dicebear-C70vgt60.js} +1 -1
  18. package/dist/gateway/static/root/assets/agents-DRYVahI-.js +2 -0
  19. package/dist/gateway/static/root/assets/{app-management-settings-panel-DI4BqHKW.js → app-management-settings-panel-D9-HW6cy.js} +1 -1
  20. package/dist/gateway/static/root/assets/{appearance-settings-6_ie3NQ4.js → appearance-settings-BHlahIDL.js} +1 -1
  21. package/dist/gateway/static/root/assets/apps-page-BdJ1eQg3.js +1 -0
  22. package/dist/gateway/static/root/assets/{archive-plugin-kUHEJ1HK.js → archive-plugin-B-aoIt0w.js} +1 -1
  23. package/dist/gateway/static/root/assets/{attachment-load-Dm-9prpU.js → attachment-load-BD0G0FD5.js} +1 -1
  24. package/dist/gateway/static/root/assets/{automation-suggestion-card-OTxQTPnC.js → automation-suggestion-card-iJRVI7aZ.js} +1 -1
  25. package/dist/gateway/static/root/assets/automations-page-D8hYQbkl.js +4 -0
  26. package/dist/gateway/static/root/assets/{binary-plugins-DllA_jQ0.js → binary-plugins-B0mNlVSz.js} +1 -1
  27. package/dist/gateway/static/root/assets/{block-editor-Cm6CWNj1.js → block-editor-CJY9Lu5G.js} +6 -6
  28. package/dist/gateway/static/root/assets/browser-settings-page-CiWEO-Iy.js +8 -0
  29. package/dist/gateway/static/root/assets/{capability-presets-api-VJ89b6I2.js → capability-presets-api-Bgc8ag55.js} +1 -1
  30. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-BaPj8wC2.js → capability-presets-settings-panel-B1nIi0TC.js} +1 -1
  31. package/dist/gateway/static/root/assets/{channel-recipient-api-B5PwBEUx.js → channel-recipient-api-0sauApoC.js} +1 -1
  32. package/dist/gateway/static/root/assets/channels-settings-BddPdqVo.js +1 -0
  33. package/dist/gateway/static/root/assets/connectors-page-Ba2GDhSE.js +2 -0
  34. package/dist/gateway/static/root/assets/{directory-picker-path-field-DySMzOF6.js → directory-picker-path-field-CiEc4KmY.js} +1 -1
  35. package/dist/gateway/static/root/assets/{dreaming-settings-D_AjSnV_.js → dreaming-settings-4bvpk5wr.js} +2 -2
  36. package/dist/gateway/static/root/assets/{extension-debug-page-BaM0FpW7.js → extension-debug-page-BbyczVZ3.js} +1 -1
  37. package/dist/gateway/static/root/assets/{extension-page-DuZWVOGA.js → extension-page-DLN1I3DR.js} +1 -1
  38. package/dist/gateway/static/root/assets/{extension-settings-page-DarVtbmJ.js → extension-settings-page-D9VGHmYJ.js} +1 -1
  39. package/dist/gateway/static/root/assets/{fetch-NFKfkqrd.js → fetch-5V96dUz3.js} +1 -1
  40. package/dist/gateway/static/root/assets/{gateway-config-api-CFEm9rgy.js → gateway-config-api-BtIzObwp.js} +1 -1
  41. package/dist/gateway/static/root/assets/{gateway-settings-BMk2S5td.js → gateway-settings-KFsGGDhg.js} +1 -1
  42. package/dist/gateway/static/root/assets/{gateway-startup-retry-Dtwh_yGg.js → gateway-startup-retry-DEMad2wt.js} +1 -1
  43. package/dist/gateway/static/root/assets/{goal-create-dialog-BKP7ylcG.js → goal-create-dialog-4PcF6Sh6.js} +1 -1
  44. package/dist/gateway/static/root/assets/goal-detail-page-B482PSaG.js +1 -0
  45. package/dist/gateway/static/root/assets/{goals-config-api-DTWZNA_Y.js → goals-config-api-CVN7-pdM.js} +1 -1
  46. package/dist/gateway/static/root/assets/{goals-page-CTmA3hWK.js → goals-page-CUdgJuDn.js} +2 -2
  47. package/dist/gateway/static/root/assets/{goals-settings-Bhct0ZT-.js → goals-settings-IYCH3-Pi.js} +1 -1
  48. package/dist/gateway/static/root/assets/{heartbeat-settings-C-UxSU4a.js → heartbeat-settings-Cf_a2Bmz.js} +1 -1
  49. package/dist/gateway/static/root/assets/index-CA2tR2vm.js +256 -0
  50. package/dist/gateway/static/root/assets/index-Ds3u0LOk.css +1 -0
  51. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DCjy2y4d.js → keyboard-shortcuts-settings-lKTg6St7.js} +1 -1
  52. package/dist/gateway/static/root/assets/logs-page-BCporcNH.js +2 -0
  53. package/dist/gateway/static/root/assets/{markdown-split-BaqxP-GQ.js → markdown-split-Bv4k6iGJ.js} +1 -1
  54. package/dist/gateway/static/root/assets/{media-plugins-DQ_EXloK.js → media-plugins-Bbi8g3N8.js} +1 -1
  55. package/dist/gateway/static/root/assets/messages-C22hxE1N.js +3 -0
  56. package/dist/gateway/static/root/assets/models-hub-panel-D68Pyow7.js +2 -0
  57. package/dist/gateway/static/root/assets/notes-page-CuUMOiyv.js +1 -0
  58. package/dist/gateway/static/root/assets/notes-workbench-Dx2N5zTk.js +2 -0
  59. package/dist/gateway/static/root/assets/{page-tabs-EIZhLppK.js → page-tabs-Cp395RYD.js} +1 -1
  60. package/dist/gateway/static/root/assets/{preview-open-alternatives-r_uB4Epr.js → preview-open-alternatives-DqV5OM4m.js} +1 -1
  61. package/dist/gateway/static/root/assets/project-detail-page-sB8AzZi3.js +1 -0
  62. package/dist/gateway/static/root/assets/projects-page-LBnJqWK2.js +1 -0
  63. package/dist/gateway/static/root/assets/remote-access-hub-Dbj0o6SC.js +1 -0
  64. package/dist/gateway/static/root/assets/{save-bar-controls-B132Uf-2.js → save-bar-controls-BItmzAzI.js} +1 -1
  65. package/dist/gateway/static/root/assets/{schedule-field-B5qshALm.js → schedule-field-BQ8IjjCn.js} +1 -1
  66. package/dist/gateway/static/root/assets/{schema-form-CvLmkdS9.js → schema-form-BRpD6x3d.js} +1 -1
  67. package/dist/gateway/static/root/assets/sessions-page-DhDZKspB.js +1 -0
  68. package/dist/gateway/static/root/assets/settings-advanced-gate-BvXLMNL6.js +1 -0
  69. package/dist/gateway/static/root/assets/{settings-collapsible-section-pRlvqsAf.js → settings-collapsible-section-BKSPQM4R.js} +1 -1
  70. package/dist/gateway/static/root/assets/settings-form-section-BmyfthNQ.js +1 -0
  71. package/dist/gateway/static/root/assets/settings-page-Cfm9UxAr.js +1 -0
  72. package/dist/gateway/static/root/assets/settings-page-layout-Bls5tfbH.js +1 -0
  73. package/dist/gateway/static/root/assets/setup-status-panel-kQEsTGAs.js +1 -0
  74. package/dist/gateway/static/root/assets/{share-preview-page-v6-IOp8t.js → share-preview-page-DbYZNAPb.js} +1 -1
  75. package/dist/gateway/static/root/assets/shares-settings-BtR4B0kn.js +1 -0
  76. package/dist/gateway/static/root/assets/skill-reload-api-CJNVOWoK.js +1 -0
  77. package/dist/gateway/static/root/assets/skills-page-DcWDHrt3.js +2 -0
  78. package/dist/gateway/static/root/assets/{system-settings-panel-HUU2FFjM.js → system-settings-panel-DKDAojWM.js} +1 -1
  79. package/dist/gateway/static/root/assets/{typed-models-lib-AH160QHh.js → typed-models-lib-BCCV4Kkp.js} +1 -1
  80. package/dist/gateway/static/root/assets/{use-channel-catalog-BXzDmjCQ.js → use-channel-catalog-NBqg3iFY.js} +1 -1
  81. package/dist/gateway/static/root/assets/{user-profile-settings-panel-DxwnQvQ3.js → user-profile-settings-panel-suQ2x-LB.js} +1 -1
  82. package/dist/gateway/static/root/assets/{utils-i5POEtqd.js → utils-DPGVr3tS.js} +1 -1
  83. package/dist/gateway/static/root/assets/voice-api-key-field-DaJASKFP.js +1 -0
  84. package/dist/gateway/static/root/assets/{work-item-detail-page-CD6FL_Rs.js → work-item-detail-page-BrCZpAWh.js} +1 -1
  85. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-ClVVMgN-.js → workflow-run-setup-panel-BTkRVNAh.js} +2 -2
  86. package/dist/gateway/static/root/assets/{workflow-start-dialog-Dv4ZA1T0.js → workflow-start-dialog-DAImVtdO.js} +1 -1
  87. package/dist/gateway/static/root/assets/workflows-page-vyJ8wSXm.js +18 -0
  88. package/dist/gateway/static/root/index.html +5 -5
  89. package/dist/package.js +1 -1
  90. package/dist/src/activity/context.d.ts +11 -0
  91. package/dist/src/activity/context.js +36 -0
  92. package/dist/src/activity/context.js.map +1 -0
  93. package/dist/src/activity/emitter.d.ts +6 -0
  94. package/dist/src/activity/emitter.js +43 -0
  95. package/dist/src/activity/emitter.js.map +1 -0
  96. package/dist/src/activity/index.d.ts +3 -0
  97. package/dist/src/activity/index.js +3 -0
  98. package/dist/src/activity/service.d.ts +12 -0
  99. package/dist/src/activity/service.js +59 -0
  100. package/dist/src/activity/service.js.map +1 -0
  101. package/dist/src/activity/types.d.ts +109 -0
  102. package/dist/src/activity/types.js +1 -0
  103. package/dist/src/agent/agent-manager.d.ts +7 -0
  104. package/dist/src/agent/agent-manager.js +7 -4
  105. package/dist/src/agent/agent-manager.js.map +1 -1
  106. package/dist/src/agent/context/project-context.js +2 -2
  107. package/dist/src/agent/context/workspace-seed.js +2 -2
  108. package/dist/src/agent/embedded/run-for-session.js +1 -1
  109. package/dist/src/agent/goals/post-turn.js +2 -2
  110. package/dist/src/agent/ipc/bus.js +1 -1
  111. package/dist/src/agent/mcp/bundle-mcp-materialize.js +1 -1
  112. package/dist/src/agent/mcp/bundle-mcp-runtime.js +1 -1
  113. package/dist/src/agent/mcp/mcp-transport-config.js +1 -1
  114. package/dist/src/agent/mcp/mcp-transport.js +1 -1
  115. package/dist/src/agent/memory/plugin-discovery.js +1 -1
  116. package/dist/src/agent/models/manager.js +1 -1
  117. package/dist/src/agent/orchestration/agent-orchestrator.js +1 -1
  118. package/dist/src/agent/service.js +6 -3
  119. package/dist/src/agent/service.js.map +1 -1
  120. package/dist/src/agent/service.types.d.ts +7 -0
  121. package/dist/src/agent/session/session-inspector.js +1 -1
  122. package/dist/src/agent/skills/hub-pull.js +1 -1
  123. package/dist/src/agent/tool-manuals/index.js +15 -6
  124. package/dist/src/agent/tool-manuals/index.js.map +1 -1
  125. package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -0
  126. package/dist/src/agent/tool-manuals/xopc-use.js +204 -0
  127. package/dist/src/agent/tool-manuals/xopc-use.js.map +1 -0
  128. package/dist/src/agent/tools/factory.d.ts +7 -0
  129. package/dist/src/agent/tools/factory.js +9 -0
  130. package/dist/src/agent/tools/factory.js.map +1 -1
  131. package/dist/src/agent/tools/goal-tool.js +2 -2
  132. package/dist/src/agent/tools/index.d.ts +1 -0
  133. package/dist/src/agent/tools/index.js +2 -1
  134. package/dist/src/agent/tools/workflow-tool.js +1 -1
  135. package/dist/src/agent/tools/xopc-use-tool.d.ts +34 -0
  136. package/dist/src/agent/tools/xopc-use-tool.js +636 -0
  137. package/dist/src/agent/tools/xopc-use-tool.js.map +1 -0
  138. package/dist/src/agent-manifest/schema.d.ts +27 -27
  139. package/dist/src/automations/api/routes.js +1 -1
  140. package/dist/src/automations/domain/validation.d.ts +55 -55
  141. package/dist/src/automations/draft/automation-draft-validator.d.ts +25 -25
  142. package/dist/src/automations/service/action-executor.js +2 -2
  143. package/dist/src/browser/cdp-local-launcher.js +1 -1
  144. package/dist/src/browser/providers/browser-ext-install.js +3 -3
  145. package/dist/src/browser/providers/cloakbrowser.js +2 -2
  146. package/dist/src/browser/providers/playwright-doctor.js +1 -1
  147. package/dist/src/browser/stealth.js +1 -1
  148. package/dist/src/chat-commands/agent-edit.js +1 -1
  149. package/dist/src/chat-commands/builtins/config.js +1 -1
  150. package/dist/src/chat-commands/builtins/goal.js +2 -2
  151. package/dist/src/chat-commands/context.js +1 -1
  152. package/dist/src/cli/commands/agent.js +1 -1
  153. package/dist/src/cli/commands/doctor/checks/database-schema.js +2 -2
  154. package/dist/src/cli/commands/doctor/checks/session-integrity.js +1 -1
  155. package/dist/src/cli/commands/extension-marketplace.js +1 -1
  156. package/dist/src/cli/commands/extension-pack.js +1 -1
  157. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  158. package/dist/src/cli/commands/goal.js +3 -3
  159. package/dist/src/cli/commands/init.js +1 -1
  160. package/dist/src/cli/commands/project.js +4 -4
  161. package/dist/src/config/agent-profile.js +1 -1
  162. package/dist/src/config/gateway-bind.js +1 -1
  163. package/dist/src/config/index.js +1 -1
  164. package/dist/src/config/loader.js +1 -1
  165. package/dist/src/config/models-json.d.ts +14 -14
  166. package/dist/src/config/models-json.js +1 -1
  167. package/dist/src/config/schema.d.ts +60 -60
  168. package/dist/src/daemon/launchd.js +1 -1
  169. package/dist/src/daemon/systemd.js +1 -1
  170. package/dist/src/extensions/discover-extensions.js +1 -1
  171. package/dist/src/extensions/loader.js +2 -2
  172. package/dist/src/gateway/agents-admin.js +1 -1
  173. package/dist/src/gateway/hono/lib/config-payload.d.ts +14 -14
  174. package/dist/src/gateway/hono/lib/static-ui.js +1 -1
  175. package/dist/src/gateway/hono/middleware/log-context.js +8 -1
  176. package/dist/src/gateway/hono/middleware/log-context.js.map +1 -1
  177. package/dist/src/gateway/hono/routes/activity.d.ts +14 -0
  178. package/dist/src/gateway/hono/routes/activity.js +72 -0
  179. package/dist/src/gateway/hono/routes/activity.js.map +1 -0
  180. package/dist/src/gateway/hono/routes/goals.js +1 -1
  181. package/dist/src/gateway/hono/routes/index.js +2 -0
  182. package/dist/src/gateway/hono/routes/index.js.map +1 -1
  183. package/dist/src/gateway/hono/routes/memory.js +2 -2
  184. package/dist/src/gateway/hono/routes/projects.js +65 -15
  185. package/dist/src/gateway/hono/routes/projects.js.map +1 -1
  186. package/dist/src/gateway/hono/routes/sessions.js +101 -2
  187. package/dist/src/gateway/hono/routes/sessions.js.map +1 -1
  188. package/dist/src/gateway/hono/routes/workflows.js +2 -2
  189. package/dist/src/gateway/lock.js +1 -1
  190. package/dist/src/gateway/ports.js +1 -1
  191. package/dist/src/gateway/service/sessions-api.d.ts +10 -0
  192. package/dist/src/gateway/service/sessions-api.js +31 -0
  193. package/dist/src/gateway/service/sessions-api.js.map +1 -1
  194. package/dist/src/gateway/service.js +12 -9
  195. package/dist/src/gateway/service.js.map +1 -1
  196. package/dist/src/goals/goal-store.js +1 -1
  197. package/dist/src/goals/goal-store.js.map +1 -1
  198. package/dist/src/goals/goal-workflow-judge.js +1 -1
  199. package/dist/src/infra/ports.js +1 -1
  200. package/dist/src/infra/ssh-tunnel.js +1 -1
  201. package/dist/src/infra/update-check.js +1 -1
  202. package/dist/src/infra/update-restart.js +1 -1
  203. package/dist/src/mcp/channel-bridge.js +1 -1
  204. package/dist/src/migrations/runner.js +1 -1
  205. package/dist/src/notes/service.js +65 -6
  206. package/dist/src/notes/service.js.map +1 -1
  207. package/dist/src/notes/store.js +1 -1
  208. package/dist/src/projects/project-service.d.ts +2 -1
  209. package/dist/src/projects/project-service.js +59 -2
  210. package/dist/src/projects/project-service.js.map +1 -1
  211. package/dist/src/projects/project-store.d.ts +2 -1
  212. package/dist/src/projects/project-store.js +43 -0
  213. package/dist/src/projects/project-store.js.map +1 -1
  214. package/dist/src/projects/types.d.ts +10 -0
  215. package/dist/src/projects/workspace.js +1 -1
  216. package/dist/src/routing/agent-session-key.js +1 -1
  217. package/dist/src/routing/resolve-route.js +1 -1
  218. package/dist/src/routing/resolve-tui-session-key.js +1 -1
  219. package/dist/src/session/client-history.d.ts +3 -0
  220. package/dist/src/session/client-history.js +24 -9
  221. package/dist/src/session/client-history.js.map +1 -1
  222. package/dist/src/session/init-session-turn.js +1 -1
  223. package/dist/src/session/resolve-session.js +1 -1
  224. package/dist/src/session/session-title.js +2 -2
  225. package/dist/src/session/store.js +1 -1
  226. package/dist/src/session/types.d.ts +4 -0
  227. package/dist/src/session/types.js.map +1 -1
  228. package/dist/src/storage/sqlite/activity-repository.d.ts +8 -0
  229. package/dist/src/storage/sqlite/activity-repository.js +208 -0
  230. package/dist/src/storage/sqlite/activity-repository.js.map +1 -0
  231. package/dist/src/storage/sqlite/connection.js +1 -1
  232. package/dist/src/storage/sqlite/index.d.ts +1 -0
  233. package/dist/src/storage/sqlite/index.js +2 -1
  234. package/dist/src/storage/sqlite/migrations/024_activity_events.sql +62 -0
  235. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  236. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  237. package/dist/src/storage/sqlite/migrations/runner.js.map +1 -1
  238. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  239. package/dist/src/storage/sqlite/row-mappers.js +1 -1
  240. package/dist/src/storage/sqlite/schema.js +1 -1
  241. package/dist/src/storage/sqlite/schema.sql +63 -0
  242. package/dist/src/storage/sqlite/session-repository.js +11 -0
  243. package/dist/src/storage/sqlite/session-repository.js.map +1 -1
  244. package/dist/src/tui/backends/embedded-backend.d.ts +13 -0
  245. package/dist/src/tui/backends/embedded-backend.js +76 -7
  246. package/dist/src/tui/backends/embedded-backend.js.map +1 -1
  247. package/dist/src/tui/backends/gateway-sse-backend.d.ts +13 -0
  248. package/dist/src/tui/backends/gateway-sse-backend.js +53 -0
  249. package/dist/src/tui/backends/gateway-sse-backend.js.map +1 -1
  250. package/dist/src/tui/chat-history.js +16 -3
  251. package/dist/src/tui/chat-history.js.map +1 -1
  252. package/dist/src/tui/clipboard-image.js +1 -1
  253. package/dist/src/tui/components/chat-log.d.ts +23 -3
  254. package/dist/src/tui/components/chat-log.js +68 -9
  255. package/dist/src/tui/components/chat-log.js.map +1 -1
  256. package/dist/src/tui/components/tui-bottom-bar.js +9 -5
  257. package/dist/src/tui/components/tui-bottom-bar.js.map +1 -1
  258. package/dist/src/tui/tui-backend.d.ts +16 -0
  259. package/dist/src/tui/tui-command-formatters.js +2 -2
  260. package/dist/src/tui/tui-commands.d.ts +9 -0
  261. package/dist/src/tui/tui-commands.js +95 -6
  262. package/dist/src/tui/tui-commands.js.map +1 -1
  263. package/dist/src/tui/tui-picker-overlay.d.ts +1 -0
  264. package/dist/src/tui/tui-picker-overlay.js +36 -1
  265. package/dist/src/tui/tui-picker-overlay.js.map +1 -1
  266. package/dist/src/tui/tui-picker-services.d.ts +13 -0
  267. package/dist/src/tui/tui-run-state.js +11 -0
  268. package/dist/src/tui/tui-run-state.js.map +1 -1
  269. package/dist/src/tui/tui-run-status-format.d.ts +3 -0
  270. package/dist/src/tui/tui-run-status-format.js +33 -0
  271. package/dist/src/tui/tui-run-status-format.js.map +1 -0
  272. package/dist/src/tui/tui-session-actions.d.ts +5 -0
  273. package/dist/src/tui/tui-session-actions.js +24 -0
  274. package/dist/src/tui/tui-session-actions.js.map +1 -1
  275. package/dist/src/tui/tui-timeline-picker.d.ts +19 -0
  276. package/dist/src/tui/tui-timeline-picker.js +81 -0
  277. package/dist/src/tui/tui-timeline-picker.js.map +1 -0
  278. package/dist/src/tui/tui-timeline.d.ts +15 -0
  279. package/dist/src/tui/tui-timeline.js +65 -0
  280. package/dist/src/tui/tui-timeline.js.map +1 -0
  281. package/dist/src/tui/tui-types.d.ts +1 -0
  282. package/dist/src/tui/tui-types.js +1 -0
  283. package/dist/src/tui/tui-types.js.map +1 -1
  284. package/dist/src/tui/tui.js +31 -25
  285. package/dist/src/tui/tui.js.map +1 -1
  286. package/dist/src/utils/index.js +1 -1
  287. package/dist/src/utils/logger/index.js +1 -1
  288. package/dist/src/utils/logger/stats.d.ts +3 -3
  289. package/dist/src/utils/logger.js +1 -1
  290. package/dist/src/work-items/agent-context.d.ts +5 -1
  291. package/dist/src/work-items/agent-context.js +39 -3
  292. package/dist/src/work-items/agent-context.js.map +1 -1
  293. package/dist/src/work-items/work-item-service.d.ts +2 -0
  294. package/dist/src/work-items/work-item-service.js +97 -0
  295. package/dist/src/work-items/work-item-service.js.map +1 -1
  296. package/dist/src/workflows/draft/workflow-draft-service.js +1 -1
  297. package/dist/src/workflows/service/workflow-session-bridge.js +1 -1
  298. package/package.json +5 -5
  299. package/dist/gateway/static/root/assets/agents-BnTB7-c5.js +0 -2
  300. package/dist/gateway/static/root/assets/apps-page-B6bG65SW.js +0 -1
  301. package/dist/gateway/static/root/assets/automations-page-1lVbo0dS.js +0 -1
  302. package/dist/gateway/static/root/assets/browser-settings-page-CzDBlOK0.js +0 -8
  303. package/dist/gateway/static/root/assets/channels-settings-Df4m7p1k.js +0 -1
  304. package/dist/gateway/static/root/assets/connectors-page-BMTphmHS.js +0 -2
  305. package/dist/gateway/static/root/assets/goal-detail-page-C2cTxf71.js +0 -1
  306. package/dist/gateway/static/root/assets/index-BNHDd2j1.css +0 -1
  307. package/dist/gateway/static/root/assets/index-BPXLPMuY.js +0 -193
  308. package/dist/gateway/static/root/assets/logs-page-CGc3_CQU.js +0 -2
  309. package/dist/gateway/static/root/assets/messages-CjuIJcZl.js +0 -3
  310. package/dist/gateway/static/root/assets/models-hub-panel-Drz4UQMb.js +0 -2
  311. package/dist/gateway/static/root/assets/notes-page-CY1ylng1.js +0 -1
  312. package/dist/gateway/static/root/assets/notes-workbench-X7IaD--t.js +0 -2
  313. package/dist/gateway/static/root/assets/project-detail-page-DE5adRBE.js +0 -1
  314. package/dist/gateway/static/root/assets/projects-page-CuOb1k6F.js +0 -1
  315. package/dist/gateway/static/root/assets/remote-access-hub-BOxNrUVA.js +0 -1
  316. package/dist/gateway/static/root/assets/sessions-page-CY0IQcGW.js +0 -1
  317. package/dist/gateway/static/root/assets/settings-advanced-gate-D4NBNVCB.js +0 -1
  318. package/dist/gateway/static/root/assets/settings-form-section-BBYUDLVd.js +0 -1
  319. package/dist/gateway/static/root/assets/settings-page-DaO7zYZM.js +0 -1
  320. package/dist/gateway/static/root/assets/settings-page-layout-D8g9PAek.js +0 -1
  321. package/dist/gateway/static/root/assets/setup-status-panel-Bks0CLLT.js +0 -1
  322. package/dist/gateway/static/root/assets/shares-settings-CEZsKm9r.js +0 -1
  323. package/dist/gateway/static/root/assets/skill-reload-api-oTkHbb9W.js +0 -1
  324. package/dist/gateway/static/root/assets/skills-page-DigsbZ6K.js +0 -2
  325. package/dist/gateway/static/root/assets/voice-api-key-field-CEJklEgb.js +0 -1
  326. package/dist/gateway/static/root/assets/workflows-page-OLQiUpoW.js +0 -18
@@ -0,0 +1,2 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-C22hxE1N.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s,i as c,n as l}from"./fetch-5V96dUz3.js";import{r as u}from"./toast-z0toXu32.js";import{Aa as d,Da as f,Dc as p,Ea as m,Ga as h,Gr as g,Ho as _,Ic as v,Jo as y,Jr as b,Ka as x,Ko as S,Kr as C,Ma as w,Oa as T,Os as E,Ta as D,To as O,Ua as k,Va as A,Vc as j,Vs as M,Wr as N,Zo as P,_s as F,cc as ee,do as I,fl as te,fo as L,gc as ne,ho as re,ja as R,ka as z,ls as B,mo as ie,na as V,nc as ae,oo as H,os as oe,qr as se,ra as ce,ro as le,ss as ue,to as de,ui as fe}from"./index-CA2tR2vm.js";import{n as pe,t as me}from"./settings-form-section-BmyfthNQ.js";import{t as he}from"./page-tabs-Cp395RYD.js";import{i as ge,n as _e,o as ve,r as ye,t as be}from"./dist-By6Rh2ee.js";var U=e(t(),1),W=n(),G=r(),K=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`,xe=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function Se(e,t){return t.some(t=>t.connectorId===e.id)}function q(e,t){return t[e]??e}function J(e,t){return t.connectorCategoryTemplate.replace(`{{category}}`,q(e,t.connectorCategoryLabels))}function Ce(){let e=(0,W.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,G.jsx)(`div`,{className:`flex h-full min-h-[9.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,G.jsx)(`div`,{className:i(`h-4 min-w-0 flex-1`,K)}),(0,G.jsx)(`div`,{className:i(`h-8 w-[4.5rem] shrink-0 rounded-lg`,K)})]}),(0,G.jsx)(`div`,{className:i(`h-3 w-full`,K)}),(0,G.jsx)(`div`,{className:i(`h-3 w-[88%]`,K)})]})})}),e[0]=t):t=e[0],t}function we(){let e=(0,W.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,G.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,G.jsx)(`div`,{className:i(`h-4 w-48 max-w-full`,K)}),(0,G.jsx)(`div`,{className:i(`h-3 w-72 max-w-full`,K)})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[t,(0,G.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,G.jsx)(`div`,{className:i(`h-9 w-20 rounded-lg`,K)}),(0,G.jsx)(`div`,{className:i(`h-9 w-20 rounded-lg`,K)})]})]}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,G.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:[n,(0,G.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,G.jsx)(`div`,{className:i(`h-8 w-20 rounded-md`,K)}),(0,G.jsx)(`div`,{className:i(`h-8 w-24 rounded-md`,K)}),(0,G.jsx)(`div`,{className:i(`h-8 w-28 rounded-md`,K)})]}),(0,G.jsx)(`div`,{className:i(`mt-3 h-20 rounded-xl`,K)})]}),e[2]=r):r=e[2],r}function Te(e){let t=(0,W.c)(69),{connector:n,installed:r,onInstall:a,onOpenDetails:o,t:s}=e,c;t[0]!==n.category||t[1]!==s?(c=J(n.category,s),t[0]=n.category,t[1]=s,t[2]=c):c=t[2];let l=c,u,d,f,p,m,h,g,_,y,b;if(t[3]!==l||t[4]!==n||t[5]!==r||t[6]!==a||t[7]!==o||t[8]!==s.install||t[9]!==s.installedBadge){let e=n.capabilities.slice(0,4),c=Math.max(0,n.capabilities.length-e.length),x;t[20]!==n||t[21]!==a||t[22]!==s.install?(x=e=>(0,G.jsxs)(L,{type:`button`,variant:`primary`,className:i(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:e=>{e.stopPropagation(),a(n)},children:[(0,G.jsx)(F,{className:`size-4`}),s.install]}),t[20]=n,t[21]=a,t[22]=s.install,t[23]=x):x=t[23],u=x;let S;t[24]!==n||t[25]!==o?(S=e=>{!o||e.currentTarget!==e.target||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),o(n))},t[24]=n,t[25]=o,t[26]=S):S=t[26];let C=S,w=o?`cursor-pointer`:null;t[27]===w?g=t[28]:(g=i(`group flex min-h-[9.5rem] flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,w),t[27]=w,t[28]=g),_=o?`button`:void 0,y=o?0:void 0,t[29]!==n||t[30]!==o?(b=()=>o?.(n),t[29]=n,t[30]=o,t[31]=b):b=t[31],d=C,f=`flex min-w-0 flex-1 flex-col`;let T;t[32]===n.displayName?T=t[33]:(T=(0,G.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[32]=n.displayName,t[33]=T);let E;t[34]===l?E=t[35]:(E=(0,G.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:l}),t[34]=l,t[35]=E);let D;t[36]!==T||t[37]!==E?(D=(0,G.jsx)(`div`,{className:`flex min-w-0 items-start gap-3`,children:(0,G.jsxs)(`div`,{className:`min-w-0`,children:[T,E]})}),t[36]=T,t[37]=E,t[38]=D):D=t[38];let O;t[39]!==r||t[40]!==u?(O=r?null:(0,G.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 transition-opacity sm:pointer-events-none sm:flex sm:opacity-0 sm:group-hover:pointer-events-auto sm:group-hover:opacity-100 sm:group-focus-within:pointer-events-auto sm:group-focus-within:opacity-100`,children:u()}),t[39]=r,t[40]=u,t[41]=O):O=t[41];let k;t[42]!==r||t[43]!==s.installedBadge?(k=r?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,G.jsx)(v,{className:`size-3`,"aria-hidden":!0}),s.installedBadge]}):null,t[42]=r,t[43]=s.installedBadge,t[44]=k):k=t[44];let A;t[45]!==O||t[46]!==k?(A=(0,G.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[O,k]}),t[45]=O,t[46]=k,t[47]=A):A=t[47],t[48]!==D||t[49]!==A?(p=(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[D,A]}),t[48]=D,t[49]=A,t[50]=p):p=t[50],t[51]===n.description?m=t[52]:(m=(0,G.jsx)(`p`,{className:`mt-4 line-clamp-2 text-sm leading-6 text-fg-muted`,title:n.description,children:n.description}),t[51]=n.description,t[52]=m),h=e.length>0?(0,G.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-1.5`,children:[e.map(Ee),c>0?(0,G.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,c]}):null]}):null,t[3]=l,t[4]=n,t[5]=r,t[6]=a,t[7]=o,t[8]=s.install,t[9]=s.installedBadge,t[10]=u,t[11]=d,t[12]=f,t[13]=p,t[14]=m,t[15]=h,t[16]=g,t[17]=_,t[18]=y,t[19]=b}else u=t[10],d=t[11],f=t[12],p=t[13],m=t[14],h=t[15],g=t[16],_=t[17],y=t[18],b=t[19];let x;t[53]!==f||t[54]!==p||t[55]!==m||t[56]!==h?(x=(0,G.jsxs)(`div`,{className:f,children:[p,m,h]}),t[53]=f,t[54]=p,t[55]=m,t[56]=h,t[57]=x):x=t[57];let S;t[58]!==r||t[59]!==u?(S=r?null:(0,G.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:u(`w-full`)}),t[58]=r,t[59]=u,t[60]=S):S=t[60];let C;return t[61]!==d||t[62]!==x||t[63]!==S||t[64]!==g||t[65]!==_||t[66]!==y||t[67]!==b?(C=(0,G.jsxs)(`div`,{className:g,role:_,tabIndex:y,onClick:b,onKeyDown:d,children:[x,S]}),t[61]=d,t[62]=x,t[63]=S,t[64]=g,t[65]=_,t[66]=y,t[67]=b,t[68]=C):C=t[68],C}function Ee(e){return(0,G.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:e},e)}function Y(e,t){if(!e.payload)throw Error(e.error??t);return e.payload}async function De(){return Y(await l(c(`/api/connectors/catalog`)),`Could not load connector catalog.`).connectors}async function Oe(){return Y(await l(c(`/api/connectors/catalog`)),`Could not load connector registries.`).registries??[]}async function ke(){return Y(await l(c(`/api/connectors/installed`)),`Could not load installed connectors.`).instances}var X=new Map,Ae=300*1e3;async function je(e,t=`all`,n){let r=e.trim(),i=t.trim()||`all`,a=n?.browse??!1,o=Math.max(n?.page??1,1),s=Math.max(n?.pageSize??24,1),u=`${i}:${r}:${a?`browse`:`search`}:${o}:${s}`,d=Date.now(),f=X.get(u);if(f&&f.expiresAt>d)return f.promise;let p=new URLSearchParams;r&&p.set(`q`,r),i!==`all`&&p.set(`source`,i),a&&p.set(`browse`,`1`),p.set(`page`,String(o)),p.set(`pageSize`,String(s));let m=l(c(`/api/connectors/registry/search?${p.toString()}`)).then(e=>{let t=Y(e,`Could not search connector registries.`),n=Math.max(0,...(t.results??[]).map(e=>e.totalPages??0))||void 0;return{connectors:t.connectors,totalPages:n}});X.set(u,{expiresAt:d+Ae,promise:m});try{return await m}catch(e){throw X.delete(u),e}}async function Me(e){return Y(await l(c(`/api/connectors/${encodeURIComponent(e)}/oauth/start`),{method:`POST`}),`Could not start connector OAuth.`).oauth}async function Ne(e,t){return Y(await l(c(`/api/connectors/${encodeURIComponent(e)}/oauth/complete`),{method:`POST`,body:JSON.stringify({deviceCode:t})}),`Could not complete connector OAuth.`).oauth}async function Pe(e,t){let n=await l(c(`/api/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify(t)});return V(),Y(n,`Could not install connector.`).instance}async function Fe(e,t={}){return Y(await l(c(`/api/connectors/preview`),{method:`POST`,body:JSON.stringify({...t,definition:e})}),`Could not preview connector capabilities.`).preview}async function Ie(e,t){return Y(await l(c(`/api/connectors/${encodeURIComponent(e)}/config`),{method:`POST`,body:JSON.stringify(t)}),`Could not update connector config.`).instance}async function Le(e){await l(c(`/api/connectors/${encodeURIComponent(e)}`),{method:`DELETE`}),V()}async function Re(e){return Y(await l(c(`/api/connectors/${encodeURIComponent(e)}/test`),{method:`POST`}),`Connector test failed.`)}async function ze(){return Y(await l(c(`/api/connectors/composio/connections`)),`Could not load Composio connections.`).connections}async function Be(e){return Y(await l(c(`/api/connectors/composio/${encodeURIComponent(e)}/authorize`),{method:`POST`}),`Could not start Composio authorization.`).oauth}async function Ve(e){return Y(await l(c(`/api/connectors/composio/${encodeURIComponent(e)}/scope`)),`Could not load Composio scope.`).scope}async function He(e,t){let n=await l(c(`/api/connectors/composio/${encodeURIComponent(e)}/scope`),{method:`POST`,body:JSON.stringify({scope:t})});return V(),Y(n,`Could not update Composio scope.`).scope}async function Ue(e){return Y(await l(c(`/api/connectors/composio/${encodeURIComponent(e)}/tools`)),`Could not load Composio tools.`).tools}async function We(e=50){return Y(await l(c(`/api/connectors/composio/triggers?limit=${encodeURIComponent(String(e))}`)),`Could not load Composio trigger events.`).events}function Ge(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function Ke(e,t){return t.connectorCapabilityLabels[e]??e}function qe(e,t){if(e.runtime.type===`mcp`)return Ge(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.id??e.runtime.channelId??e.runtime.toolkit??e.runtime.toolsetId??e.runtime.sourceKind??e.runtime.type;return Ge(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n})}function Je(e,t){return e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function Ye(e){return(e.setup.secrets??[]).filter(e=>e.required).length+(e.setup.config??[]).filter(e=>e.required).length}function Xe(e){let t=(0,W.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,G.jsx)(`div`,{className:`border-b border-edge px-3 py-2 text-xs font-semibold text-fg`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,16).map(Ze),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>16?(0,G.jsxs)(`div`,{className:`px-3 py-2 text-xs text-fg-subtle`,children:[`+`,r.length-16]}):null,t[4]=r.length,t[5]=o);let s;t[6]!==a||t[7]!==o?(s=(0,G.jsxs)(`div`,{className:`max-h-48 overflow-y-auto`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==i||t[10]!==s?(c=(0,G.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base`,children:[i,s]}),t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function Ze(e){return(0,G.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,G.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,G.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function Qe({connector:e,installed:t,onClose:n,onInstall:r,t:a}){let[o,s]=(0,U.useState)(!1),[c,l]=(0,U.useState)(null),[u,p]=(0,U.useState)(null),h=Ye(e),g=e.capabilities.slice(0,8),_=Math.max(0,e.capabilities.length-g.length),y=[...(e.setup.secrets??[]).map(e=>({key:`secret:${e.key}`,label:e.label,description:e.description,required:e.required,kind:a.connectorSetupSecret})),...(e.setup.config??[]).map(e=>({key:`config:${e.key}`,label:e.label,description:e.description,required:!!e.required,kind:a.connectorSetupConfig}))],b=async()=>{s(!0),p(null);try{l(await Fe(e))}catch(e){l(null),p(e instanceof Error?e.message:String(e))}finally{s(!1)}};return(0,G.jsx)(d,{open:!0,onOpenChange:e=>{e||n()},children:(0,G.jsxs)(z,{children:[(0,G.jsx)(T,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,G.jsxs)(m,{className:i(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,52rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float outline-none dark:border-edge`),children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.source}),(0,G.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.kind}),t?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,G.jsx)(v,{className:`size-3`,"aria-hidden":!0}),a.installedBadge]}):null]}),(0,G.jsx)(R,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,G.jsx)(f,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:e.description})]}),(0,G.jsx)(D,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,H.focusRingPanel),"aria-label":a.modalClose,children:[(0,G.jsx)(ie,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,G.jsx)(`span`,{className:`sr-only`,children:a.modalClose})]})})]}),(0,G.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[(0,G.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,G.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,G.jsx)(re,{className:`size-3.5`,"aria-hidden":!0}),a.detailTools]}),(0,G.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:c?Ge(a.connectorPreviewToolsCount,{count:c.toolCount}):a.connectorPreviewUnknown})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,G.jsx)(M,{className:`size-3.5`,"aria-hidden":!0}),a.detailPermissions]}),(0,G.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:Je(e,a)})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,G.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0}),a.connectorRequiredInputs]}),(0,G.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:Ge(a.connectorRequiredInputsCount,{count:h})})]})]}),(0,G.jsxs)(`div`,{className:`mt-5 grid gap-5 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,G.jsxs)(`section`,{children:[(0,G.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.connectorCapabilitiesTitle}),(0,G.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[g.map(e=>(0,G.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-muted`,children:Ke(e,a)},e)),_>0?(0,G.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-subtle`,children:[`+`,_]}):null]}),(0,G.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:a.connectorCapabilitiesHint})]}),u?(0,G.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:u}):null,c?(0,G.jsxs)(`section`,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,G.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.connectorPreviewTitle}),(0,G.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs font-medium`,c.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:c.ok?a.healthStatusHealthy:a.healthStatusLabels[c.status]??c.status})]}),(0,G.jsxs)(`div`,{className:`mb-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,G.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:c.toolCount}),(0,G.jsx)(`div`,{className:`text-fg-muted`,children:a.toolsMetric})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:c.resourceCount}),(0,G.jsx)(`div`,{className:`text-fg-muted`,children:a.resourcesMetric})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:c.promptCount}),(0,G.jsx)(`div`,{className:`text-fg-muted`,children:a.promptsMetric})]})]}),(0,G.jsxs)(`div`,{className:`grid gap-2`,children:[(0,G.jsx)(Xe,{title:a.detailTools,items:c.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,G.jsx)(Xe,{title:a.detailResources,items:c.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,G.jsx)(Xe,{title:a.detailPrompts,items:c.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??Ge(a.promptArgumentCount,{count:e.argumentCount})}))})]}),c.error?(0,G.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:c.error}):null,c.action?(0,G.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-subtle`,children:c.action}):null]}):null]}),(0,G.jsxs)(`aside`,{className:`space-y-3`,children:[(0,G.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,G.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,G.jsx)(M,{className:`size-4 text-accent`,"aria-hidden":!0}),a.detailPermissions]}),(0,G.jsx)(`p`,{className:`mt-2 text-sm font-medium text-fg`,children:Je(e,a)})]}),(0,G.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,G.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,G.jsx)(ne,{className:`size-4 text-accent`,"aria-hidden":!0}),a.connectorSetupTitle]}),y.length>0?(0,G.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-lg border border-edge`,children:y.map(e=>(0,G.jsxs)(`div`,{className:`bg-surface-panel px-3 py-2.5`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),(0,G.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e.kind}),e.required?(0,G.jsx)(`span`,{className:`rounded-md bg-amber-500/10 px-1.5 py-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-300`,children:a.connectorSetupRequired}):null]}),e.description?(0,G.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.key))}):(0,G.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:a.connectorSetupNone})]}),(0,G.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,G.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,G.jsx)(S,{className:`size-4 text-accent`,"aria-hidden":!0}),a.connectorRuntimeTitle]}),(0,G.jsx)(`p`,{className:`mt-2 break-words text-xs leading-5 text-fg-muted`,children:qe(e,a)})]})]})]})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,G.jsx)(D,{asChild:!0,children:(0,G.jsx)(L,{variant:`secondary`,children:a.modalClose})}),(0,G.jsxs)(L,{variant:`secondary`,disabled:o,onClick:()=>void b(),children:[o?(0,G.jsx)(E,{className:`size-4 animate-spin`}):(0,G.jsx)(re,{className:`size-4`}),a.connectorPreviewButton]}),t?(0,G.jsxs)(L,{variant:`secondary`,disabled:!0,children:[(0,G.jsx)(B,{className:`size-4`}),a.installedBadge]}):(0,G.jsxs)(L,{variant:`primary`,onClick:()=>{r(e),n()},children:[(0,G.jsx)(F,{className:`size-4`}),a.install]})]})]})]})})}var $e=(0,U.memo)(function(e){let t=(0,W.c)(19),{loading:n,searchQuery:r,setSearchQuery:i,onReloadClick:a,onAddCustomServer:o,searchPlaceholder:s,addLabel:c,reloadLabel:l}=e,u;t[0]!==n||t[1]!==a||t[2]!==l?(u=(0,G.jsx)(fe,{className:`size-9 shrink-0 p-0`,loading:n,label:l,title:l,onClick:a}),t[0]=n,t[1]=a,t[2]=l,t[3]=u):u=t[3];let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,G.jsx)(y,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),t[4]=d):d=t[4];let f;t[5]===i?f=t[6]:(f=e=>i(e.currentTarget.value),t[5]=i,t[6]=f);let p;t[7]!==s||t[8]!==r||t[9]!==f?(p=(0,G.jsxs)(`label`,{className:`relative flex min-h-9 min-w-0 max-w-sm cursor-text items-center rounded-pill border border-edge bg-surface-panel py-1.5 pl-9 pr-3 shadow-surface dark:bg-surface-hover/40 sm:max-w-md`,children:[d,(0,G.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:r,onChange:f,placeholder:s,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`})]}),t[7]=s,t[8]=r,t[9]=f,t[10]=p):p=t[10];let m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,G.jsx)(oe,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[11]=m):m=t[11];let h;t[12]!==c||t[13]!==o?(h=(0,G.jsxs)(L,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,onClick:o,children:[m,c]}),t[12]=c,t[13]=o,t[14]=h):h=t[14];let g;return t[15]!==u||t[16]!==p||t[17]!==h?(g=(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[u,p,h]}),t[15]=u,t[16]=p,t[17]=h,t[18]=g):g=t[18],g}),et=/^([^:=]+)[:=](.*)$/;function tt(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return Object.entries(e).map(([e,t])=>({key:e,value:t==null?``:String(t)}))}catch{}let n=[];for(let e of t.split(/\r?\n/)){let t=e.trim();if(!t)continue;let r=et.exec(t);r&&n.push({key:r[1].trim(),value:r[2].trim()})}return n.length>0?n:null}function nt(e){let t={};for(let n of e){let e=n.key.trim();e&&(t[e]=n.value)}return Object.keys(t).length>0?t:void 0}function rt(e){if(!e||typeof e!=`object`)return[{key:``,value:``}];let t=Object.entries(e).map(([e,t])=>({key:e,value:t==null?``:String(t)}));return t.length>0?t:[{key:``,value:``}]}function it(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e.xopcConnector;return!!(t&&typeof t==`object`&&!Array.isArray(t)&&t.managed===!0)}function at(e){let t=e&&typeof e==`object`&&`mcp`in e?e.mcp:void 0,n=(t&&typeof t==`object`?t:{}).servers,r={};if(!n||typeof n!=`object`||Array.isArray(n))return r;for(let[e,t]of Object.entries(n))!t||typeof t!=`object`||Array.isArray(t)||it(t)&&(r[e]=t);return r}function ot(e){let t=e.trim();if(t)return t.split(/\s+/).filter(Boolean)}function st(e){let t=e.trim();if(!t)return;let n=JSON.parse(t);if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`Expected a JSON object`);return n}function ct(e){if(e.transport===`stdio`){let t={command:e.command.trim()},n=ot(e.argsText);return n?.length&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envJson.trim()&&(t.env=st(e.envJson)),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}let t={url:e.url.trim(),transport:e.transport},n=nt(e.headers);return n&&(t.headers=n),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}function lt(e,t){let n=typeof t.url==`string`&&t.url.trim().length>0,r=typeof t.transport==`string`?t.transport.trim().toLowerCase():``,i=n?r===`sse`?`sse`:`streamable-http`:`stdio`,a=t.headers&&typeof t.headers==`object`&&!Array.isArray(t.headers)?t.headers:void 0;return{clientKey:e,id:e,transport:i,command:typeof t.command==`string`?t.command:``,argsText:Array.isArray(t.args)?t.args.map(String).join(` `):``,envJson:t.env&&typeof t.env==`object`?JSON.stringify(t.env,null,2):``,cwd:typeof t.cwd==`string`?t.cwd:typeof t.workingDirectory==`string`?t.workingDirectory:``,url:typeof t.url==`string`?t.url:``,headers:rt(a),connectionTimeoutMs:typeof t.connectionTimeoutMs==`number`&&Number.isFinite(t.connectionTimeoutMs)?t.connectionTimeoutMs:void 0}}function ut(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`stdio`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[{key:`Authorization`,value:``}],connectionTimeoutMs:void 0}}function dt(e){let t=e&&typeof e==`object`&&`mcp`in e?e.mcp:void 0,n=t&&typeof t==`object`?t:{},r=n.servers,i=r&&typeof r==`object`&&!Array.isArray(r)?Object.entries(r).flatMap(([e,t])=>!t||typeof t!=`object`||Array.isArray(t)||it(t)?[]:[lt(e,t)]).sort((e,t)=>e.id.localeCompare(t.id)):[],a=typeof n.sessionIdleTtlMs==`number`?n.sessionIdleTtlMs:void 0;return{sessionIdleTtlMinutes:a==null?void 0:a===0?0:Math.round(a/6e4),servers:i}}function ft(e){return ct(e)}async function pt(e,t={}){let n={};for(let r of e.servers){let e=r.id.trim();if(e){if(t[e])throw Error(`Server id "${e}" is reserved by an installed connector.`);n[e]=ct(r)}}let r={servers:{...t,...n}};e.sessionIdleTtlMinutes!=null&&Number.isFinite(e.sessionIdleTtlMinutes)&&(r.sessionIdleTtlMs=e.sessionIdleTtlMinutes===0?0:Math.round(e.sessionIdleTtlMinutes*6e4)),await l(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({mcp:r})}),V()}function mt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n==`string`){let e=n.trim();e&&t.push({name:e});continue}if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.name!=`string`)continue;let r=e.name.trim();if(!r)continue;let i=typeof e.shortName==`string`&&e.shortName.trim()?e.shortName.trim():void 0,a=typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0;t.push({name:r,shortName:i,description:a})}return t}function ht(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.uri!=`string`||typeof e.name!=`string`)continue;let r=e.uri.trim(),i=e.name.trim();!r||!i||t.push({uri:r,name:i,title:typeof e.title==`string`&&e.title.trim()?e.title.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,mimeType:typeof e.mimeType==`string`&&e.mimeType.trim()?e.mimeType.trim():void 0})}return t}function gt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.name!=`string`)continue;let r=e.name.trim();r&&t.push({name:r,title:typeof e.title==`string`&&e.title.trim()?e.title.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,argumentCount:typeof e.argumentCount==`number`?e.argumentCount:0})}return t}async function _t(e,t){let n=await l(c(`/api/mcp/servers/${encodeURIComponent(e)}/test`),{method:`POST`,body:t?JSON.stringify({server:t}):void 0});if(!n.payload)throw Error(n.error??`MCP test failed`);let r=mt(n.payload.tools),i=ht(n.payload.resources),a=gt(n.payload.prompts);return{serverId:n.payload.serverId??e,toolCount:typeof n.payload.toolCount==`number`?n.payload.toolCount:r.length,resourceCount:typeof n.payload.resourceCount==`number`?n.payload.resourceCount:i.length,promptCount:typeof n.payload.promptCount==`number`?n.payload.promptCount:a.length,tools:r,resources:i,prompts:a}}function vt(e){return e.connectionTimeoutMs==null||!Number.isFinite(e.connectionTimeoutMs)?``:String(Math.round(e.connectionTimeoutMs/1e3))}function yt(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);if(!(!Number.isFinite(n)||n<1||n>600))return n*1e3}function bt(e){if(e.transport===`stdio`){let t=e.command.trim();if(!t)return``;let n=e.argsText.trim();return n?`${t} ${n}`:t}return e.url.trim()}function Z(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,n),e)}function xt({row:e,t,cs:n,onEdit:r,onRemove:i}){let[a,o]=(0,U.useState)(!1),[s,c]=(0,U.useState)(!1),[l,u]=(0,U.useState)(null),[d,f]=(0,U.useState)(null),p=bt(e),m=(0,U.useCallback)(async()=>{o(!0),f(null);try{let t=await _t(e.id.trim());u({toolCount:t.toolCount,resourceCount:t.resourceCount,promptCount:t.promptCount})}catch(e){f(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.id]),h=(0,U.useCallback)(async()=>{c(!0),f(null);try{await i()}catch(e){f(e instanceof Error?e.message:String(e)),c(!1)}},[i]);return(0,G.jsxs)(`div`,{className:`flex h-full min-h-[10.5rem] cursor-pointer flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`,onClick:r,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.id.trim()||t.cardUntitled}),(0,G.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:n.customBadge}),(0,G.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.transportLabels[e.transport]})]}),p?(0,G.jsx)(`p`,{className:`mt-3 line-clamp-2 break-all font-mono text-xs leading-5 text-fg-subtle`,title:p,children:p}):null,d?(0,G.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:d}):null,l?(0,G.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:Z(n.customCapabilitySummary,{tools:String(l.toolCount),resources:String(l.resourceCount),prompts:String(l.promptCount)})}):null]}),(0,G.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,G.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.connectorDetails}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(L,{variant:`secondary`,disabled:a,onClick:()=>void m(),children:[a?(0,G.jsx)(E,{className:`size-4 animate-spin`}):(0,G.jsx)(B,{className:`size-4`}),t.testConnection]}),(0,G.jsxs)(L,{variant:`ghost`,disabled:s,onClick:()=>void h(),children:[s?(0,G.jsx)(E,{className:`size-4 animate-spin`}):(0,G.jsx)(O,{className:`size-4`}),t.removeServer]})]})]})]})}function St(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Ct(e,t,n){let r=t.trim().toLowerCase();if(!r)return!0;let i=e.shortName||St(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
2
+ `).toLowerCase().includes(r)}function wt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Tt(e){let t=(0,W.c)(29),{tools:n,stripPrefix:r,searchPlaceholder:a,searchEmptyLabel:o}=e,[s,c]=(0,U.useState)(``),l;if(t[0]!==s||t[1]!==r||t[2]!==n){let e;t[4]!==s||t[5]!==r?(e=e=>Ct(e,s,r),t[4]=s,t[5]=r,t[6]=e):e=t[6],l=n.filter(e),t[0]=s,t[1]=r,t[2]=n,t[3]=l}else l=t[3];let u=l,d;t[7]===s?d=t[8]:(d=s.trim(),t[7]=s,t[8]=d);let f=d.length>0,p;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,G.jsx)(y,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=p):p=t[9];let m,h;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=i(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg`,`placeholder:text-fg-subtle`,I),h=e=>c(e.target.value),t[10]=m,t[11]=h):(m=t[10],h=t[11]);let g;t[12]!==s||t[13]!==a?(g=(0,G.jsxs)(`div`,{className:`relative`,children:[p,(0,G.jsx)(`input`,{type:`search`,value:s,placeholder:a,"aria-label":a,className:m,onChange:h})]}),t[12]=s,t[13]=a,t[14]=g):g=t[14];let _;t[15]!==u.length||t[16]!==f||t[17]!==n.length?(_=f?(0,G.jsxs)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:[u.length,` / `,n.length]}):null,t[15]=u.length,t[16]=f,t[17]=n.length,t[18]=_):_=t[18];let v;t[19]!==g||t[20]!==_?(v=(0,G.jsxs)(`div`,{className:`border-b border-edge px-5 py-3`,children:[g,_]}),t[19]=g,t[20]=_,t[21]=v):v=t[21];let b;t[22]!==u||t[23]!==o||t[24]!==r?(b=(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:u.length===0?(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o}):(0,G.jsx)(`ul`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>{let n=e.shortName||wt(e.name,r)||e.name||`?`,i=e.name||`tool-${t}`;return(0,G.jsxs)(`li`,{className:`min-w-0 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[(0,G.jsx)(`div`,{className:`truncate font-mono text-sm font-medium text-fg`,title:e.name===n?n:e.name,children:n}),e.description?(0,G.jsx)(`p`,{className:`mt-1 truncate text-xs leading-relaxed text-fg-muted`,title:e.description,children:e.description}):null]},i)})})}),t[22]=u,t[23]=o,t[24]=r,t[25]=b):b=t[25];let x;return t[26]!==v||t[27]!==b?(x=(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[v,b]}),t[26]=v,t[27]=b,t[28]=x):x=t[28],x}function Et(e){let t=(0,W.c)(38),{open:n,onOpenChange:r,serverId:a,title:o,subtitle:s,searchPlaceholder:c,searchEmptyLabel:l,emptyLabel:u,closeLabel:p,tools:g,stripPrefix:_}=e,v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,G.jsx)(T,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,x)}),t[0]=v):v=t[0];let y;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(y=i(`fixed left-1/2 top-1/2 flex max-h-[min(88vh,40rem)] w-[min(100%-2rem,min(92vw,36rem))] -translate-x-1/2 -translate-y-1/2 flex-col`,h,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`),t[1]=y):y=t[1];let b;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,G.jsx)(re,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[2]=b):b=t[2];let S;t[3]===o?S=t[4]:(S=(0,G.jsxs)(R,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[b,o]}),t[3]=o,t[4]=S);let C;t[5]!==a||t[6]!==s||t[7]!==g.length?(C=s.replace(`{{serverId}}`,a).replace(`{{count}}`,String(g.length)),t[5]=a,t[6]=s,t[7]=g.length,t[8]=C):C=t[8];let w;t[9]===C?w=t[10]:(w=(0,G.jsx)(f,{className:`mt-1 text-sm text-fg-muted`,children:C}),t[9]=C,t[10]=w);let E;t[11]!==S||t[12]!==w?(E=(0,G.jsxs)(`div`,{className:`min-w-0`,children:[S,w]}),t[11]=S,t[12]=w,t[13]=E):E=t[13];let O;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,G.jsx)(ie,{className:`size-4`,"aria-hidden":!0}),t[14]=O):O=t[14];let k;t[15]===p?k=t[16]:(k=(0,G.jsx)(D,{asChild:!0,children:(0,G.jsx)(L,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":p,children:O})}),t[15]=p,t[16]=k);let A;t[17]!==E||t[18]!==k?(A=(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[E,k]}),t[17]=E,t[18]=k,t[19]=A):A=t[19];let j;t[20]!==u||t[21]!==n||t[22]!==l||t[23]!==c||t[24]!==a||t[25]!==_||t[26]!==g?(j=g.length>0?(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,G.jsx)(Tt,{tools:g,stripPrefix:_,searchPlaceholder:c,searchEmptyLabel:l},`${a}-${n?`open`:`closed`}`)}):(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u})}),t[20]=u,t[21]=n,t[22]=l,t[23]=c,t[24]=a,t[25]=_,t[26]=g,t[27]=j):j=t[27];let M;t[28]===p?M=t[29]:(M=(0,G.jsx)(`div`,{className:`flex justify-end border-t border-edge px-5 py-3`,children:(0,G.jsx)(D,{asChild:!0,children:(0,G.jsx)(L,{type:`button`,variant:`secondary`,children:p})})}),t[28]=p,t[29]=M);let N;t[30]!==A||t[31]!==j||t[32]!==M?(N=(0,G.jsxs)(z,{children:[v,(0,G.jsxs)(m,{className:y,children:[A,j,M]})]}),t[30]=A,t[31]=j,t[32]=M,t[33]=N):N=t[33];let P;return t[34]!==r||t[35]!==n||t[36]!==N?(P=(0,G.jsx)(d,{open:n,onOpenChange:r,children:N}),t[34]=r,t[35]=n,t[36]=N,t[37]=P):P=t[37],P}var Dt=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,I);function Ot(e){return e.materialized.type===`composio`?e.connectorId.replace(/^composio-/,``):null}function kt(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function At({instance:e,t}){let n=Ot(e),[r,a]=(0,U.useState)([]),[o,s]=(0,U.useState)([]),[c,l]=(0,U.useState)([]),[u,d]=(0,U.useState)(`read`),[f,p]=(0,U.useState)(!1),[m,h]=(0,U.useState)(null),g=(0,U.useCallback)(async()=>{if(!(!n||n===`api-key`)){p(!0),h(null);try{let[e,t,r,i]=await Promise.all([ze().catch(()=>[]),Ue(n).catch(()=>[]),We(20).catch(()=>[]),Ve(n).catch(()=>`read`)]);a(e.filter(e=>e.toolkit.toLowerCase()===n.toLowerCase())),s(t),l(r.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===n.toLowerCase())),d(i)}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}},[n]);(0,U.useEffect)(()=>{g()},[g]);let _=(0,U.useCallback)(async()=>{if(n){p(!0),h(null);try{let e=await Be(n);window.open(e.connectUrl,`_blank`,`noopener,noreferrer`)}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}},[n]),v=(0,U.useCallback)(async e=>{if(n){d(e);try{await He(n,e),await g()}catch(e){h(e instanceof Error?e.message:String(e))}}},[g,n]);return n?n===`api-key`?(0,G.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:t.composioApiKeyStored}):(0,G.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-medium text-fg`,children:Z(t.composioToolkitTitle,{toolkit:n})}),(0,G.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioScopeHint})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsxs)(A,{className:i(Dt,`h-9 w-28 py-1`),value:u,onChange:e=>void v(e.currentTarget.value),children:[(0,G.jsx)(k,{value:`read`,children:t.composioScopeRead}),(0,G.jsx)(k,{value:`write`,children:t.composioScopeWrite}),(0,G.jsx)(k,{value:`admin`,children:t.composioScopeAdmin})]}),(0,G.jsxs)(L,{variant:`secondary`,disabled:f,onClick:()=>void _(),children:[f?(0,G.jsx)(E,{className:`size-4 animate-spin`}):(0,G.jsx)(M,{className:`size-4`}),t.connectOAuth]}),(0,G.jsx)(L,{variant:`ghost`,disabled:f,onClick:()=>void g(),children:t.refresh})]})]}),m?(0,G.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:m}):null,(0,G.jsxs)(`div`,{className:`mt-4 grid gap-3 lg:grid-cols-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioConnections}),r.length?r.map(e=>(0,G.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,G.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.accountEmail??e.username??e.workspace??e.id}),(0,G.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.status})]},e.id)):(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioConnectionsEmpty})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),o.length?o.slice(0,8).map(e=>(0,G.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,G.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,G.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[kt(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),c.length?c.slice(0,5).map(e=>(0,G.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,G.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,G.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})]})]})]}):null}var jt=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,I);function Mt(e,t){return e?t.healthStatusLabels[e]??e:t.healthNotTested}function Nt(e,t){let n={};for(let r of e?.setup.config??[]){let e=t.config?.[r.key]??r.defaultValue??``;n[r.key]=typeof e==`string`?e:JSON.stringify(e,null,2)}return n}function Pt(e,t){let n=t.trim();return e===`json`?n?JSON.parse(n):void 0:e===`number`?n?Number(n):void 0:e===`boolean`?n===`true`:n||void 0}function Ft(e){let t=(0,W.c)(12),{title:n,description:r,meta:a}=e,o;t[0]===r?o=t[1]:(o=r?(0,G.jsx)(C,{delayDuration:300,skipDelayDuration:100,children:(0,G.jsxs)(se,{children:[(0,G.jsx)(b,{asChild:!0,children:(0,G.jsx)(`p`,{tabIndex:0,title:r,className:i(`mt-1 line-clamp-3 cursor-help text-xs leading-5 text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:r})}),(0,G.jsx)(g,{children:(0,G.jsx)(N,{side:`top`,align:`start`,sideOffset:6,collisionPadding:12,className:`!z-[10000] max-h-[min(16rem,45vh)] max-w-[min(32rem,calc(100vw-2rem))] overflow-y-auto rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-5 text-fg shadow-popover`,children:(0,G.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:r})})})]})}):null,t[0]=r,t[1]=o);let s=o,c;t[2]===n?c=t[3]:(c=(0,G.jsx)(`p`,{className:`min-w-0 break-all font-mono text-xs font-medium leading-5 text-fg`,children:n}),t[2]=n,t[3]=c);let l;t[4]===a?l=t[5]:(l=a?(0,G.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] leading-4 text-fg-subtle`,children:a}):null,t[4]=a,t[5]=l);let u;t[6]!==c||t[7]!==l?(u=(0,G.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;return t[9]!==s||t[10]!==u?(d=(0,G.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[u,s]}),t[9]=s,t[10]=u,t[11]=d):d=t[11],d}function It({instance:e,definition:t,onClose:n,onChanged:r,t:a,mcp:o}){let[s,c]=(0,U.useState)(!1),[l,u]=(0,U.useState)(!1),[p,h]=(0,U.useState)(!1),[g,v]=(0,U.useState)(null),[y,b]=(0,U.useState)(`health`),[x,S]=(0,U.useState)(!1),[C,w]=(0,U.useState)(()=>Nt(t,e)),[k,A]=(0,U.useState)(null),j=t?.setup.config??[],N=e.materialized.type===`mcp`&&j.length>0&&(t?.setup.secrets??[]).length===0,F=g?g.toolCount:e.usage.lastToolCount,I=(0,U.useMemo)(()=>{let t=[[`health`,_,a.detailHealth],[`tools`,re,`${a.detailTools} ${g?g.toolCount:e.usage.lastToolCount??``}`],[`resources`,ne,`${a.detailResources} ${g?g.resourceCount:e.usage.lastResourceCount??``}`],[`prompts`,ee,`${a.detailPrompts} ${g?g.promptCount:e.usage.lastPromptCount??``}`],[`permissions`,M,a.detailPermissions]];return N?[...t,[`config`,ne,a.tabConfig]]:t},[g,e.usage.lastPromptCount,e.usage.lastResourceCount,e.usage.lastToolCount,N,a]),te=(0,U.useCallback)(async()=>{c(!0),A(null);try{let t=await Re(e.instanceId);v(t),t.toolCount>0&&b(`tools`),r()}catch(e){A(e instanceof Error?e.message:String(e))}finally{c(!1)}},[e.instanceId,r]),V=(0,U.useCallback)(async()=>{u(!0),A(null);try{await Le(e.instanceId),await r(),n()}catch(e){A(e instanceof Error?e.message:String(e)),u(!1)}},[e.instanceId,r,n]),ae=(0,U.useCallback)(async()=>{if(!(!t||!N)){h(!0),A(null);try{let n={};for(let e of t.setup.config??[]){let t=Pt(e.type,C[e.key]??``);t!==void 0&&(n[e.key]=t)}await Ie(e.instanceId,{config:n}),await r(),b(`health`)}catch(e){A(e instanceof Error?e.message:String(e))}finally{h(!1)}}},[C,t,e.instanceId,r,N]);return(0,G.jsxs)(d,{open:!0,onOpenChange:e=>{e||n()},children:[(0,G.jsxs)(z,{children:[(0,G.jsx)(T,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,G.jsxs)(m,{className:i(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,54rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float outline-none dark:border-edge`),children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(R,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,G.jsx)(f,{className:`mt-1 text-sm text-fg-muted`,children:e.materialized.type===`mcp`?Z(a.mcpServerRuntime,{serverId:e.materialized.serverId}):Z(a.runtimeLabel,{runtime:e.materialized.type})})]}),(0,G.jsx)(D,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,H.focusRingPanel),"aria-label":a.modalClose,children:[(0,G.jsx)(ie,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,G.jsx)(`span`,{className:`sr-only`,children:a.modalClose})]})})]}),(0,G.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[k?(0,G.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:k}):null,(0,G.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:I.map(([e,t,n])=>(0,G.jsxs)(`button`,{type:`button`,className:i(`inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs`,y===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:text-fg`),onClick:()=>b(e),children:[(0,G.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),n]},e))}),(0,G.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[y===`health`?(0,G.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,G.jsxs)(`p`,{children:[a.statusLabel,` `,(0,G.jsx)(`span`,{className:g?.ok?`font-medium text-emerald-700 dark:text-emerald-300`:`font-medium text-fg`,children:Mt(g?.status??e.usage.lastHealthStatus,a)})]}),(0,G.jsxs)(`p`,{children:[a.lastCheckLabel,` `,e.usage.lastHealthCheckAt?new Date(e.usage.lastHealthCheckAt).toLocaleString():a.never]}),g?.action?(0,G.jsx)(`p`,{children:g.action}):null]}):null,y===`tools`?g?.tools.length?(0,G.jsxs)(`div`,{className:`grid gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,children:Z(a.toolsAvailable,{count:String(g.tools.length)})}),(0,G.jsx)(L,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>S(!0),children:o.viewAllTools})]}),(0,G.jsx)(`div`,{className:`grid gap-2`,children:g.tools.slice(0,8).map(e=>(0,G.jsx)(Ft,{title:e.shortName??e.name,description:e.description},e.name))})]}):(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,G.jsx)(`p`,{className:`text-fg-muted`,children:F?Z(a.toolsLastCheckSummary,{count:String(F)}):a.toolsRunTestHint}),(0,G.jsxs)(L,{type:`button`,variant:`secondary`,disabled:s,onClick:()=>void te(),children:[s?(0,G.jsx)(E,{className:`size-4 animate-spin`}):(0,G.jsx)(B,{className:`size-4`}),a.test]})]}):null,y===`resources`?g?.resources.length?(0,G.jsx)(`div`,{className:`grid gap-2`,children:g.resources.slice(0,8).map(e=>(0,G.jsx)(Ft,{title:e.title??e.name,description:e.uri,meta:e.mimeType},e.uri))}):(0,G.jsx)(`p`,{className:`text-fg-muted`,children:a.resourcesRunTestHint}):null,y===`prompts`?g?.prompts.length?(0,G.jsx)(`div`,{className:`grid gap-2`,children:g.prompts.slice(0,8).map(e=>(0,G.jsx)(Ft,{title:e.title??e.name,description:e.description,meta:e.argumentCount?Z(a.promptArgumentCount,{count:String(e.argumentCount)}):void 0},e.name))}):(0,G.jsx)(`p`,{className:`text-fg-muted`,children:a.promptsRunTestHint}):null,y===`permissions`?(0,G.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,G.jsx)(`p`,{children:Z(a.secretsConfigured,{count:String(Object.values(e.secretStatus).filter(Boolean).length)})}),(0,G.jsx)(`p`,{children:e.materialized.type===`mcp`?Z(a.runtimeServerLabel,{runtime:e.materialized.type.toUpperCase(),serverId:e.materialized.serverId}):Z(a.runtimeLabel,{runtime:e.materialized.type.toUpperCase()})}),(0,G.jsx)(`p`,{children:e.materialized.type===`mcp`?a.mcpPolicyHint:a.connectorPolicyHint})]}):null,y===`config`&&N?(0,G.jsx)(`div`,{className:`grid gap-3`,children:j.map(e=>(0,G.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,G.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,G.jsx)(`input`,{className:jt,value:C[e.key]??``,placeholder:e.placeholder,onChange:t=>w(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}),e.materialized.type===`composio`?(0,G.jsx)(At,{instance:e,t:a}):null]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,G.jsx)(L,{variant:`secondary`,onClick:n,children:a.modalClose}),y===`config`&&N?(0,G.jsxs)(L,{variant:`primary`,disabled:p,onClick:()=>void ae(),children:[p?(0,G.jsx)(E,{className:`size-4 animate-spin`}):(0,G.jsx)(P,{className:`size-4`}),a.modalSave]}):null,e.materialized.type===`mcp`?(0,G.jsxs)(L,{variant:`secondary`,disabled:s,onClick:()=>void te(),children:[s?(0,G.jsx)(E,{className:`size-4 animate-spin`}):(0,G.jsx)(B,{className:`size-4`}),a.test]}):null,(0,G.jsxs)(L,{variant:`ghost`,disabled:l,onClick:()=>void V(),children:[l?(0,G.jsx)(E,{className:`size-4 animate-spin`}):(0,G.jsx)(O,{className:`size-4`}),a.remove]})]})]})]}),e.materialized.type===`mcp`?(0,G.jsx)(Et,{open:x,onOpenChange:S,serverId:e.materialized.serverId,title:Z(a.installedToolsDialogTitle,{name:e.displayName}),subtitle:a.installedToolsDialogSubtitle,searchPlaceholder:o.toolsDialogSearchPlaceholder,searchEmptyLabel:o.toolsDialogSearchEmpty,emptyLabel:a.toolsRunTestHint,closeLabel:o.toolsDialogClose,tools:g?.tools??[],stripPrefix:`${e.materialized.serverId}__`}):null]})}function Lt({instance:e,definition:t,onOpenDetails:n,onChanged:r,t:i}){let[a,o]=(0,U.useState)(!1),[s,c]=(0,U.useState)(!1),[l,u]=(0,U.useState)(null),d=(0,U.useCallback)(async()=>{o(!0),u(null);try{await Re(e.instanceId),await r()}catch(e){u(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.instanceId,r]),f=(0,U.useCallback)(async()=>{c(!0),u(null);try{await Le(e.instanceId),await r()}catch(e){u(e instanceof Error?e.message:String(e)),c(!1)}},[e.instanceId,r]),p=e.usage.lastHealthStatus?i.healthStatusLabels[e.usage.lastHealthStatus]??e.usage.lastHealthStatus:i.healthNotTested,m=e.usage.lastToolCount??0,h=!!(t?.setup.config?.length&&!t.setup.secrets?.length&&e.materialized.type===`mcp`);return(0,G.jsxs)(`div`,{className:`flex h-full min-h-[10.5rem] cursor-pointer flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`,onClick:()=>n(e),children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.displayName}),(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,G.jsx)(v,{className:`size-3`,"aria-hidden":!0}),i.installedBadge]}),h?(0,G.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:i.tabConfig}):null]}),(0,G.jsx)(`p`,{className:`mt-3 line-clamp-2 break-all text-sm leading-5 text-fg-muted`,children:e.materialized.type===`mcp`?Z(i.mcpServerRuntime,{serverId:e.materialized.serverId}):Z(i.runtimeLabel,{runtime:e.materialized.type})}),(0,G.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs text-fg-muted`,children:[(0,G.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:[i.statusLabel,` `,p]}),(0,G.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:Z(i.toolsAvailable,{count:String(m)})})]}),l?(0,G.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:l}):null]}),(0,G.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,G.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:i.connectorDetails}),(0,G.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[e.materialized.type===`mcp`?(0,G.jsxs)(L,{variant:`secondary`,disabled:a,onClick:()=>void d(),children:[a?(0,G.jsx)(E,{className:`size-4 animate-spin`}):(0,G.jsx)(B,{className:`size-4`}),i.test]}):null,(0,G.jsxs)(L,{variant:`ghost`,disabled:s,onClick:()=>void f(),children:[s?(0,G.jsx)(E,{className:`size-4 animate-spin`}):(0,G.jsx)(O,{className:`size-4`}),i.remove]})]})]})]})}var Rt=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,I),zt=i(Rt,`min-h-28 font-mono`);function Bt(e,t){return e?t.healthStatusLabels[e]??e:t.healthStatusPending}function Vt(e,t){let n=t.trim();return e===`json`?n?JSON.parse(n):void 0:e===`number`?n?Number(n):void 0:e===`boolean`?n===`true`:n||void 0}function Ht(e){let t={};for(let n of e.setup.secrets??[])t[n.key]=``;let n={};for(let t of e.setup.config??[])n[t.key]=t.defaultValue===void 0?``:typeof t.defaultValue==`string`?t.defaultValue:JSON.stringify(t.defaultValue,null,2);return{connector:e,secrets:t,config:n,installing:!1,error:null,result:null,health:null,oauth:{flow:null,connected:e.auth.mode!==`oauth`}}}function Ut(e){let t=(0,W.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,G.jsx)(`div`,{className:`border-b border-edge px-3 py-2 text-xs font-semibold text-fg`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,12).map(Wt),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>12?(0,G.jsxs)(`div`,{className:`px-3 py-2 text-xs text-fg-subtle`,children:[`+`,r.length-12]}):null,t[4]=r.length,t[5]=o);let s;t[6]!==a||t[7]!==o?(s=(0,G.jsxs)(`div`,{className:`max-h-40 overflow-y-auto`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==i||t[10]!==s?(c=(0,G.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel`,children:[i,s]}),t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function Wt(e){return(0,G.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,G.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,G.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function Gt({draft:e,onChange:t,onClose:n,onInstalled:r,t:a}){let{connector:o}=e,s=e.result?`complete`:e.installing?`health`:`configure`,c=[{id:`configure`,label:a.installStepConfigure},{id:`health`,label:a.installStepHealth},{id:`complete`,label:a.installStepComplete}],l=(0,U.useCallback)(async()=>{t({...e,installing:!0,error:null});try{let n=await Me(o.id);window.open(n.verificationUri,`_blank`,`noopener,noreferrer`),t({...e,installing:!1,error:null,oauth:{flow:n,connected:!1}})}catch(n){t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}},[o.id,e,t]),u=(0,U.useCallback)(async()=>{if(e.oauth.flow){t({...e,installing:!0,error:null});try{await Ne(o.id,e.oauth.flow.deviceCode),t({...e,installing:!1,error:null,oauth:{...e.oauth,connected:!0}})}catch(n){t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}}},[o.id,e,t]),p=(0,U.useCallback)(async()=>{t({...e,installing:!0,error:null,result:null,health:null});try{if(o.auth.mode===`oauth`&&!e.oauth.connected)throw Error(a.oauthRequiredBeforeInstall);let n={};for(let t of o.setup.config??[]){let r=Vt(t.type,e.config[t.key]??``);r!==void 0&&(n[t.key]=r)}let i=await Pe(o.id,{secrets:e.secrets,config:n,definition:o.source===`registry`?o:void 0}),s=null;try{s=await Re(i.instanceId)}catch{s=null}t({...e,installing:!1,result:i,health:s}),await r()}catch(n){t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}},[o,e,t,r,a.oauthRequiredBeforeInstall]);return(0,G.jsx)(d,{open:!0,onOpenChange:e=>{e||n()},children:(0,G.jsxs)(z,{children:[(0,G.jsx)(T,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,G.jsxs)(m,{className:i(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex max-h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(R,{className:`text-base font-semibold text-fg`,children:Z(a.installDialogTitle,{name:o.displayName})}),(0,G.jsx)(f,{className:`mt-1 line-clamp-3 text-sm text-fg-muted`,children:o.description})]}),(0,G.jsx)(D,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,H.focusRingPanel),"aria-label":a.modalClose,children:[(0,G.jsx)(ie,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,G.jsx)(`span`,{className:`sr-only`,children:a.modalClose})]})})]}),(0,G.jsxs)(`div`,{className:`min-h-0 overflow-y-auto px-6 py-5`,children:[(0,G.jsx)(`div`,{className:`mb-5 grid grid-cols-3 gap-2`,"aria-label":a.installProgressAria,children:c.map((e,t)=>{let n=c.findIndex(e=>e.id===s);return(0,G.jsxs)(`div`,{className:i(`rounded-xl border px-3 py-2 text-xs font-medium`,t===n?`border-accent bg-accent-soft text-accent-fg`:t<n?`border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-900/40 dark:bg-emerald-950/40 dark:text-emerald-200`:`border-edge bg-surface-base text-fg-muted`),children:[(0,G.jsxs)(`span`,{className:`mr-1 tabular-nums`,children:[t+1,`.`]}),e.label]},e.id)})}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[o.auth.mode===`oauth`?(0,G.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4`,children:[(0,G.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:a.oauthTitle}),(0,G.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.oauthHint}),e.oauth.flow?(0,G.jsxs)(`div`,{className:`mt-3 rounded-xl bg-surface-base p-3 text-sm text-fg-muted`,children:[(0,G.jsx)(`p`,{children:Z(a.oauthOpenCodePrefix,{url:e.oauth.flow.verificationUri})}),(0,G.jsx)(`p`,{className:`mt-2 font-mono text-lg font-semibold tracking-widest text-fg`,children:e.oauth.flow.userCode})]}):null,e.oauth.connected?(0,G.jsx)(`p`,{className:`mt-3 rounded-xl bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700`,children:a.oauthConnected}):null,(0,G.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,G.jsxs)(L,{variant:`secondary`,disabled:e.installing,onClick:()=>void l(),children:[e.installing&&!e.oauth.flow?(0,G.jsx)(E,{className:`size-4 animate-spin`}):(0,G.jsx)(B,{className:`size-4`}),a.oauthConnectButton]}),(0,G.jsxs)(L,{variant:`primary`,disabled:e.installing||!e.oauth.flow,onClick:()=>void u(),children:[e.installing&&e.oauth.flow?(0,G.jsx)(E,{className:`size-4 animate-spin`}):(0,G.jsx)(v,{className:`size-4`}),a.oauthAuthorizedButton]})]})]}):null,(o.setup.secrets??[]).map(n=>(0,G.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.description?(0,G.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.description}):null,(0,G.jsx)(de,{value:e.secrets[n.key]??``,onChange:r=>t({...e,secrets:{...e.secrets,[n.key]:r},error:null}),labels:a.secretInputLabels,placeholder:n.required?a.requiredPlaceholder:a.optionalPlaceholder})]},n.key)),(o.setup.config??[]).map(n=>(0,G.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.type===`json`?(0,G.jsx)(`textarea`,{className:zt,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})}):(0,G.jsx)(`input`,{className:Rt,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})})]},n.key)),e.installing?(0,G.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-fg`,children:[(0,G.jsx)(E,{className:`size-4 animate-spin text-accent`,"aria-hidden":!0}),a.installingTitle]}),(0,G.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:a.installingHint})]}):null,e.error?(0,G.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:e.error}):null,e.result?(0,G.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-medium text-fg`,children:Z(a.installedAs,{target:e.result.materialized.type===`mcp`?e.result.materialized.serverId:e.result.instanceId})}),(0,G.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:Z(a.runtimeLabel,{runtime:e.result.materialized.type.toUpperCase()})})]}),(0,G.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs font-medium`,e.health?.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e.health?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-hover text-fg-muted`),children:e.health?.ok?a.healthStatusHealthy:Bt(e.health?.status,a)})]}),e.health?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,G.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.toolCount}),(0,G.jsx)(`div`,{children:a.toolsMetric})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.resourceCount}),(0,G.jsx)(`div`,{children:a.resourcesMetric})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.promptCount}),(0,G.jsx)(`div`,{children:a.promptsMetric})]})]}),(0,G.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,G.jsx)(Ut,{title:a.detailTools,items:e.health.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,G.jsx)(Ut,{title:a.detailResources,items:e.health.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,G.jsx)(Ut,{title:a.detailPrompts,items:e.health.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??Z(a.promptArgumentCount,{count:String(e.argumentCount)})}))})]})]}):(0,G.jsx)(`p`,{className:`mt-3`,children:a.installedWithoutHealth}),e.health?.action?(0,G.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:e.health.action}):null]}):null]})]}),(0,G.jsx)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:(0,G.jsxs)(L,{variant:`primary`,disabled:!!e.result||e.installing||o.auth.mode===`oauth`&&!e.oauth.connected,onClick:()=>void p(),children:[e.installing?(0,G.jsx)(E,{className:`size-4 animate-spin`}):e.result?(0,G.jsx)(v,{className:`size-4`}):(0,G.jsx)(F,{className:`size-4`}),e.result?a.installedBadge:a.install]})})]})]})})}function Kt(e,t){let n=e.length+1,r=`server-${n}`,i=new Set([...e.map(e=>e.id.trim()),...t]);for(;i.has(r);)n+=1,r=`server-${n}`;return ut(r)}function qt(e,t){let n=t.trim().toLowerCase();return n?[e.displayName,e.description,e.category,e.kind,e.source,...e.tags??[]].some(e=>e.toLowerCase().includes(n)):!0}function Jt(e,t,n){return e.filter(e=>qt(e,t)).toSorted((e,t)=>n===`source`&&e.source!==t.source?e.source.localeCompare(t.source):e.displayName.localeCompare(t.displayName))}function Yt(e,t){let n=t.trim().toLowerCase();return n?[e.displayName,e.connectorId,e.instanceId,e.status,e.connectionStatus??``,e.materialized.type,e.materialized.type===`mcp`?e.materialized.serverId:e.materialized.id].some(e=>e.toLowerCase().includes(n)):!0}function Xt(e,t){let n=t.trim().toLowerCase();return n?[e.id,e.command??``,e.url??``,e.transport].some(e=>e.toLowerCase().includes(n)):!0}function Zt(e,t,n){let r=e.key.trim();if(r)return`key:${r}`;let i=e.value.trim();return i?`value:${i}`:`empty:${n.slice(0,t).filter(e=>!e.key.trim()&&!e.value.trim()).length}`}function Qt(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,I)}function $t({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:a,pasteFailed:o,keyPlaceholder:s,valuePlaceholder:c,headers:l,onChange:u}){let d=(e,t)=>{u(l.map((n,r)=>r===e?{...n,...t}:n))},f=()=>{u([...l,{key:``,value:``}])},m=e=>{let t=l.filter((t,n)=>n!==e);u(t.length>0?t:[{key:``,value:``}])},h=async()=>{try{let e=await le();if(!e){window.alert(o);return}let t=tt(e);if(!t?.length){window.alert(o);return}u(t)}catch{window.alert(o)}};return(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,G.jsx)(`span`,{children:e}),t?(0,G.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),(0,G.jsxs)(L,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void h(),children:[(0,G.jsx)(p,{className:`size-3.5`,"aria-hidden":!0}),a]})]}),(0,G.jsx)(`div`,{className:`flex flex-col gap-2`,children:l.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{className:i(Qt(),`min-w-0 flex-1 font-mono text-xs`),value:e.key,placeholder:s,onChange:e=>d(t,{key:e.target.value})}),(0,G.jsx)(`input`,{className:i(Qt(),`min-w-0 flex-[1.4] font-mono text-xs`),value:e.value,placeholder:c,onChange:e=>d(t,{value:e.target.value})}),(0,G.jsx)(L,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:l.length<=1&&!e.key&&!e.value,onClick:()=>m(t),"aria-label":r,children:(0,G.jsx)(O,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})})]},Zt(e,t,l)))}),(0,G.jsxs)(`button`,{type:`button`,className:i(`self-start text-sm text-accent hover:underline`,H.press),onClick:f,children:[`+ `,n]})]})}var en=[`stdio`,`sse`,`streamable-http`];function Q(e){let t=(0,W.c)(11),{label:n,description:r,required:i,children:a}=e,o;t[0]===i?o=t[1]:(o=i?(0,G.jsx)(`span`,{className:`ml-0.5 text-danger`,children:`*`}):null,t[0]=i,t[1]=o);let s;t[2]!==n||t[3]!==o?(s=(0,G.jsxs)(`div`,{className:`text-sm font-medium text-fg`,children:[n,o]}),t[2]=n,t[3]=o,t[4]=s):s=t[4];let c;t[5]===r?c=t[6]:(c=r?(0,G.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}):null,t[5]=r,t[6]=c);let l;return t[7]!==a||t[8]!==s||t[9]!==c?(l=(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[s,a,c]}),t[7]=a,t[8]=s,t[9]=c,t[10]=l):l=t[10],l}function $(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,I)}function tn(e){let t=(0,W.c)(29),{row:n,t:r,onUpdate:a,idConflictMessage:o,variant:s}=e,c=s===void 0?`all`:s,l=c===`all`||c===`basic`,u=c===`all`||c===`advanced`,d;t[0]!==o||t[1]!==a||t[2]!==n.id||t[3]!==n.transport||t[4]!==l||t[5]!==r?(d=l?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Q,{label:r.transportLabel,required:!0,children:(0,G.jsx)(A,{className:$(),value:n.transport,onChange:e=>a({transport:e.target.value}),children:en.map(e=>(0,G.jsx)(k,{value:e,children:r.transportLabels[e]},e))})}),(0,G.jsxs)(Q,{label:r.serverIdLabel,required:!0,children:[(0,G.jsx)(`input`,{className:$(),value:n.id,placeholder:r.serverIdPlaceholder,onChange:e=>a({id:e.target.value})}),o?(0,G.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-300`,children:o}):null]})]}):null,t[0]=o,t[1]=a,t[2]=n.id,t[3]=n.transport,t[4]=l,t[5]=r,t[6]=d):d=t[6];let f;t[7]!==a||t[8]!==n.argsText||t[9]!==n.command||t[10]!==n.cwd||t[11]!==n.envJson||t[12]!==n.headers||t[13]!==n.transport||t[14]!==n.url||t[15]!==u||t[16]!==l||t[17]!==r||t[18]!==c?(f=n.transport===`stdio`?(0,G.jsxs)(G.Fragment,{children:[l?(0,G.jsx)(`div`,{className:c===`basic`?`md:col-span-2`:void 0,children:(0,G.jsx)(Q,{label:r.commandLabel,required:!0,children:(0,G.jsx)(`input`,{className:$(),value:n.command,onChange:e=>a({command:e.target.value})})})}):null,u?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Q,{label:r.argsLabel,description:r.argsHint,children:(0,G.jsx)(`input`,{className:$(),value:n.argsText,onChange:e=>a({argsText:e.target.value})})}),(0,G.jsx)(Q,{label:r.cwdLabel,children:(0,G.jsx)(`input`,{className:$(),value:n.cwd,onChange:e=>a({cwd:e.target.value})})}),(0,G.jsx)(Q,{label:r.envLabel,description:r.envHint,children:(0,G.jsx)(`textarea`,{className:i($(),`min-h-[4rem] font-mono text-xs`),value:n.envJson,onChange:e=>a({envJson:e.target.value})})})]}):null]}):(0,G.jsxs)(G.Fragment,{children:[l?(0,G.jsx)(`div`,{className:`md:col-span-2`,children:(0,G.jsx)(Q,{label:r.urlLabel,required:!0,children:(0,G.jsx)(`input`,{className:i($(),`font-mono text-xs`),value:n.url,placeholder:`https://example.com/mcp`,onChange:e=>a({url:e.target.value})})})}):null,u?(0,G.jsx)($t,{label:r.headersLabel,optionalLabel:r.optionalSuffix,addLabel:r.addHeader,removeHeaderAria:r.removeHeader,pasteLabel:r.pasteHeaders,pasteFailed:r.pasteHeadersFailed,keyPlaceholder:r.headerKeyPlaceholder,valuePlaceholder:r.headerValuePlaceholder,headers:n.headers,onChange:e=>a({headers:e})}):null]}),t[7]=a,t[8]=n.argsText,t[9]=n.command,t[10]=n.cwd,t[11]=n.envJson,t[12]=n.headers,t[13]=n.transport,t[14]=n.url,t[15]=u,t[16]=l,t[17]=r,t[18]=c,t[19]=f):f=t[19];let p;t[20]!==a||t[21]!==n||t[22]!==u||t[23]!==r?(p=u?(0,G.jsx)(Q,{label:r.timeoutLabel,description:r.timeoutHint,children:(0,G.jsx)(`input`,{type:`number`,min:1,max:600,className:$(),value:vt(n),placeholder:r.timeoutPlaceholder,onChange:e=>a({connectionTimeoutMs:yt(e.target.value)})})}):null,t[20]=a,t[21]=n,t[22]=u,t[23]=r,t[24]=p):p=t[24];let m;return t[25]!==d||t[26]!==f||t[27]!==p?(m=(0,G.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[d,f,p]}),t[25]=d,t[26]=f,t[27]=p,t[28]=m):m=t[28],m}function nn(e,t){if(e.shortName)return e.shortName;let n=`${t.trim()}__`;return n&&e.name.startsWith(n)?e.name.slice(n.length):e.name}function rn(e){let t=(0,W.c)(13),{tool:n,serverId:r}=e,a;t[0]!==r||t[1]!==n?(a=nn(n,r),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o=a,s=n.name===o?o:n.name,c;t[3]===n.description?c=t[4]:(c=n.description?.trim(),t[3]=n.description,t[4]=c);let l=c,u;t[5]!==o||t[6]!==s?(u=(0,G.jsx)(`p`,{className:`break-all font-mono text-xs font-medium leading-5 text-fg`,title:s,children:o}),t[5]=o,t[6]=s,t[7]=u):u=t[7];let d;t[8]===l?d=t[9]:(d=l?(0,G.jsx)(C,{delayDuration:300,skipDelayDuration:100,children:(0,G.jsxs)(se,{children:[(0,G.jsx)(b,{asChild:!0,children:(0,G.jsx)(`p`,{tabIndex:0,title:l,className:i(`mt-1 line-clamp-3 cursor-help text-xs leading-5 text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:l})}),(0,G.jsx)(g,{children:(0,G.jsx)(N,{side:`top`,align:`start`,sideOffset:6,collisionPadding:12,className:`!z-[10000] max-h-[min(16rem,45vh)] max-w-[min(32rem,calc(100vw-2rem))] overflow-y-auto rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-5 text-fg shadow-popover`,children:(0,G.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:l})})})]})}):null,t[8]=l,t[9]=d);let f;return t[10]!==u||t[11]!==d?(f=(0,G.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[u,d]}),t[10]=u,t[11]=d,t[12]=f):f=t[12],f}function an({open:e,mode:t,initialRow:n,existingCustomServers:r,sessionIdleTtlMinutes:a,config:o,managedServerIds:s,t:c,cs:l,onClose:u,onSaved:p}){let[h,g]=(0,U.useState)(n),[_,y]=(0,U.useState)(!1),[b,x]=(0,U.useState)(!1),[C,w]=(0,U.useState)(null),[O,k]=(0,U.useState)(!1),[A,M]=(0,U.useState)({status:`idle`}),[N,P]=(0,U.useState)(null),F=n.id.trim(),ee=h.id.trim()!==F&&s.has(h.id.trim())||s.has(h.id.trim())&&t===`add`?c.reservedServerId:void 0,I=h.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===h.id.trim())?l.duplicateServerId:void 0,te=h.id.trim().length>0&&!ee&&!I&&(h.transport===`stdio`?h.command.trim().length>0:h.url.trim().length>0),ne=bt(h),V=(0,U.useCallback)(async()=>{if(h.id.trim()){x(!0),w(null),M({status:`loading`});try{M({status:`ok`,tools:(await _t(h.id.trim(),ft(h))).tools})}catch(e){M({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{x(!1)}}},[h]),ae=(0,U.useCallback)(async()=>{if(!(!te||_)){y(!0),w(null);try{let e=r.filter(e=>!(t===`edit`&&e.clientKey===n.clientKey));e.push(h),await pt({sessionIdleTtlMinutes:a,servers:e.sort((e,t)=>e.id.localeCompare(t.id))},at(o)),await p(),u()}catch(e){w(e instanceof Error?e.message:String(e))}finally{y(!1)}}},[te,o,r,n.clientKey,t,u,p,F,h,_,a]);return e?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(d,{open:e,onOpenChange:e=>{e||u()},children:(0,G.jsxs)(z,{children:[(0,G.jsx)(T,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,G.jsxs)(m,{className:i(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(R,{className:`text-base font-semibold text-fg`,children:t===`add`?l.addCustomServerTitle:l.editCustomServerTitle}),(0,G.jsx)(f,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?l.addCustomServerHint:l.editCustomServerHint})]}),(0,G.jsx)(D,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,H.focusRingPanel),"aria-label":l.modalClose,children:[(0,G.jsx)(ie,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,G.jsx)(`span`,{className:`sr-only`,children:l.modalClose})]})})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,G.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,G.jsx)(S,{className:`size-4 text-accent`,"aria-hidden":!0}),h.id.trim()||c.cardUntitled]}),(0,G.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs leading-5 text-fg-muted`,children:ne||(h.transport===`stdio`?c.commandLabel:c.urlLabel)})]}),(0,G.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:c.transportLabels[h.transport]})]})}),(0,G.jsxs)(`section`,{children:[(0,G.jsxs)(`div`,{className:`mb-3`,children:[(0,G.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.connectorBasicConfigTitle}),(0,G.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.connectorBasicConfigHint})]}),(0,G.jsx)(tn,{row:h,t:c,variant:`basic`,onUpdate:e=>{g(t=>({...t,...e})),w(null)},idConflictMessage:ee??I})]}),A.status===`ok`?(0,G.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-3`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,G.jsx)(re,{className:`size-4 text-accent`,"aria-hidden":!0}),A.tools.length===0?c.toolsEmpty:c.toolsTitle.replace(`{{count}}`,String(A.tools.length))]}),A.tools.length>0?(0,G.jsx)(L,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>P(A.tools),children:c.viewAllTools}):null]}),A.tools.length>0?(0,G.jsx)(`div`,{className:`mt-3 grid gap-2`,children:A.tools.slice(0,6).map((e,t)=>(0,G.jsx)(rn,{tool:e,serverId:h.id},e.name||`tool-${t}`))}):null]}):null,A.status===`error`?(0,G.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:A.message}):null,C?(0,G.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:C}):null,(0,G.jsxs)(`details`,{open:O,onToggle:e=>k(e.currentTarget.open),className:`group rounded-xl border border-edge bg-surface-base`,children:[(0,G.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg hover:text-fg [&::-webkit-details-marker]:hidden`,children:[(0,G.jsx)(j,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),(0,G.jsx)(`span`,{className:`group-open:hidden`,children:l.connectorShowAdvancedConfig}),(0,G.jsx)(`span`,{className:`hidden group-open:inline`,children:l.connectorHideAdvancedConfig})]}),(0,G.jsx)(`div`,{className:`border-t border-edge px-4 py-4`,children:(0,G.jsx)(tn,{row:h,t:c,variant:`advanced`,onUpdate:e=>{g(t=>({...t,...e})),w(null)}})})]})]})}),(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,G.jsxs)(L,{variant:`secondary`,disabled:!h.id.trim()||b,onClick:()=>void V(),children:[b?(0,G.jsx)(E,{className:`size-4 animate-spin`}):(0,G.jsx)(B,{className:`size-4`}),c.testConnection]}),(0,G.jsx)(D,{asChild:!0,children:(0,G.jsx)(L,{variant:`secondary`,children:l.modalCancel})}),(0,G.jsxs)(L,{variant:`primary`,disabled:!te||_,onClick:()=>void ae(),children:[_?(0,G.jsx)(E,{className:`size-4 animate-spin`}):(0,G.jsx)(v,{className:`size-4`}),_?c.saving:l.modalSave]})]})]})]})}),N?(0,G.jsx)(Et,{open:!0,onOpenChange:e=>{e||P(null)},serverId:h.id,title:c.toolsDialogTitle,subtitle:c.toolsDialogSubtitle,searchPlaceholder:c.toolsDialogSearchPlaceholder,searchEmptyLabel:c.toolsDialogSearchEmpty,emptyLabel:c.toolsEmpty,closeLabel:c.toolsDialogClose,tools:N,stripPrefix:`${h.id.trim()}__`}):null]}):null}var on=`mprov`,sn=`smithery`,cn=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,I);function ln(){let e=a(o(e=>e.language)),t=e.connectorsSettings,n=e.mcpSettings,r=s(e=>e.token),c=!!r,[l,d]=te(),f=l.get(on)?.trim()||sn,[p,m]=(0,U.useState)(`marketplace`),[h,g]=(0,U.useState)({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!0,error:null}),[_,v]=(0,U.useState)(!1),[y,b]=(0,U.useState)(1),[x,S]=(0,U.useState)(void 0),[C,T]=(0,U.useState)(``),[D,O]=(0,U.useState)(f),[k,A]=(0,U.useState)(`name`),[M,N]=(0,U.useState)(null),[P,F]=(0,U.useState)(null),[ee,I]=(0,U.useState)(null),[ne,re]=(0,U.useState)(null),[R,z]=(0,U.useState)(null),[B,ie]=(0,U.useState)(void 0),[V,oe]=(0,U.useState)(!1),[se,le]=(0,U.useState)(!1),{data:de,mutate:fe}=ce(c),W=de?.payload?.config,K=(0,U.useMemo)(()=>W===void 0?null:dt(W),[W]),q=K?.servers??[];(0,U.useEffect)(()=>{K&&ie(K.sessionIdleTtlMinutes)},[K]);let J=(0,U.useCallback)(async()=>{if(!r){g({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!1,error:null});return}g(e=>({...e,loading:!0,error:null}));try{let[e,t,n]=await Promise.all([De(),ke(),Oe()]);g(r=>({catalog:e,registryCatalog:r.registryCatalog,instances:t,registries:n,loading:!1,error:null}))}catch(e){g({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[r]);(0,U.useEffect)(()=>{J()},[J]);let Ee=l.toString(),Y=(0,U.useRef)(Ee);(0,U.useEffect)(()=>{Y.current!==Ee&&(Y.current=Ee,O(l.get(on)?.trim()||sn))},[l,Ee]);let X=(0,U.useMemo)(()=>h.registries.map(e=>e.id),[h.registries]);(0,U.useEffect)(()=>{if(X.length===0||X.includes(D))return;let e=X.includes(sn)?sn:X[0];e&&O(e)},[D,X]),(0,U.useEffect)(()=>{if(!D||D===l.get(on))return;let e=new URLSearchParams(l);e.set(on,D),Y.current=e.toString(),d(e,{replace:!0})},[D,l,d]);let Ae=(0,U.useCallback)(async e=>{let t=C.trim(),n=e?.browse??!1,r=Math.max(e?.page??1,1),i=e?.append??!1;if(!(!c||!t&&!n)){v(!0),i?g(e=>({...e,error:null})):(b(1),S(void 0),g(e=>({...e,registryCatalog:[],error:null})));try{let e=await je(t,D,{browse:n,page:r});b(r),S(e.totalPages),g(t=>({...t,registryCatalog:i?[...t.registryCatalog,...e.connectors].filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t):e.connectors}))}catch(e){g(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{v(!1)}}},[c,C,D]);(0,U.useEffect)(()=>{if(p!==`marketplace`)return;let e=window.setTimeout(()=>{C.trim()?Ae():D&&Ae({browse:!0})},C.trim()?350:0);return()=>window.clearTimeout(e)},[D,C,Ae,h.loading,p]);let Me=(0,U.useMemo)(()=>new Set(h.instances.map(e=>e.connectorId)),[h.instances]),Ne=(0,U.useMemo)(()=>new Map([...h.catalog,...h.registryCatalog].map(e=>[e.id,e])),[h.catalog,h.registryCatalog]),Pe=(0,U.useMemo)(()=>new Set(h.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[h.instances]),Fe=(0,U.useCallback)(async e=>{if(!K||W===void 0)return;let t=q.filter(t=>t.clientKey!==e.clientKey);await pt({sessionIdleTtlMinutes:K.sessionIdleTtlMinutes,servers:t},at(W)),await fe(),await J()},[W,q,J,K,fe]),Ie=(0,U.useCallback)(()=>{z({mode:`add`,row:Kt(q,Pe)})},[q,Pe]),Le=(0,U.useCallback)(async()=>{if(!(!K||W===void 0||V)){oe(!0),le(!1);try{await pt({sessionIdleTtlMinutes:B,servers:q},at(W)),await fe(),le(!0),u({type:`success`,title:n.saved})}finally{oe(!1)}}},[W,q,K,fe,B,V]),Re=w(e=>e.setPageHeader),ze=w(e=>e.clearPageHeader),Be=(0,U.useMemo)(()=>(0,G.jsx)($e,{loading:h.loading||_,searchQuery:C,setSearchQuery:T,onReloadClick:J,onAddCustomServer:Ie,searchPlaceholder:p===`marketplace`?t.marketplaceSearchPlaceholder:p===`builtin`?t.builtinSearchPlaceholder:p===`user`?t.userSearchPlaceholder:t.configSearchPlaceholder,addLabel:t.addCustomServer,reloadLabel:t.reload}),[t,J,Ie,_,C,h.loading,p]);(0,U.useLayoutEffect)(()=>(Re({startExtra:null,main:(0,G.jsx)(`div`,{className:`min-w-0`,children:(0,G.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title})}),end:Be}),()=>ze()),[ze,t.title,Be,Re]);let Ve=h.instances.length+q.length,He=(0,U.useMemo)(()=>Jt(h.catalog.filter(e=>e.source===`builtin`),C,k),[k,C,h.catalog]),Ue=(0,U.useMemo)(()=>Jt(h.registryCatalog,C,k),[k,C,h.registryCatalog]),We=p===`marketplace`&&!!(x&&y<x),Ge=(0,U.useMemo)(()=>h.instances.filter(e=>Yt(e,C)),[C,h.instances]),Ke=(0,U.useMemo)(()=>q.filter(e=>Xt(e,C)),[q,C]),qe=(0,U.useMemo)(()=>h.instances.find(e=>e.instanceId===ee)??ne,[ee,ne,h.instances]),Je=Ge.length+Ke.length,Ye=[{id:`marketplace`,label:t.tabMarketplace},{id:`builtin`,label:t.tabBuiltin,count:He.length},{id:`user`,label:t.tabUser,count:Ve},{id:`config`,label:t.tabConfig}];return(0,G.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,G.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[c?null:(0,G.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:t.tokenHint}),(0,G.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-edge-subtle pb-3 sm:flex-row sm:items-center sm:justify-between dark:border-edge-subtle`,children:[(0,G.jsx)(he,{items:Ye,activeTab:p,onChange:m,ariaLabel:t.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`}),(0,G.jsxs)(`div`,{className:`flex min-h-9 min-w-0 flex-wrap items-center gap-2 sm:justify-end`,children:[p===`marketplace`?(0,G.jsx)(`div`,{className:`inline-flex h-9 max-w-full shrink-0 overflow-x-auto rounded-lg border border-edge bg-surface-panel p-0.5 shadow-surface`,role:`group`,"aria-label":t.registrySourceAria,children:h.registries.map(e=>(0,G.jsx)(`button`,{type:`button`,className:i(`shrink-0 rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors`,H.focusRingPanel,D===e.id?`bg-fg text-surface-panel dark:bg-fg dark:text-surface-base`:`text-fg-muted hover:text-fg`),"aria-pressed":D===e.id,onClick:()=>O(e.id),children:e.displayName},e.id))}):null,p!==`user`&&p!==`config`?(0,G.jsxs)(ge,{children:[(0,G.jsx)(ve,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,className:i(`inline-flex h-9 min-h-9 min-w-[9rem] shrink-0 items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 text-xs font-medium text-fg shadow-surface`,H.transition,H.focusRingPanel),children:[(0,G.jsx)(ae,{className:`size-3.5 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,G.jsx)(`span`,{children:k===`name`?t.sortName:t.sortSource}),(0,G.jsx)(j,{className:`size-3.5 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0})]})}),(0,G.jsx)(ye,{children:(0,G.jsxs)(be,{className:`z-50 min-w-[10rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[(0,G.jsx)(_e,{className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover data-[highlighted]:bg-surface-hover`,onSelect:()=>A(`name`),children:t.sortName}),(0,G.jsx)(_e,{className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover data-[highlighted]:bg-surface-hover`,onSelect:()=>A(`source`),children:t.sortSource})]})})]}):null]})]}),h.error?(0,G.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:h.error}):null,p===`user`&&c?(0,G.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.installedTitle}),(0,G.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.installedHint})]}),h.loading?(0,G.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":t.loading,children:xe.slice(0,3).map(e=>(0,G.jsx)(we,{},e))}):Ve===0||Je===0?(0,G.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:Ve===0?t.installedEmpty:t.userEmpty}):(0,G.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:[Ge.map(e=>(0,G.jsx)(Lt,{instance:e,definition:Ne.get(e.connectorId),onOpenDetails:e=>{I(e.instanceId),re(e)},onChanged:J,t},e.instanceId)),Ke.map(e=>(0,G.jsx)(xt,{row:e,t:n,cs:t,onEdit:()=>z({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>Fe(e)},e.clientKey))]}),(0,G.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.disableHint})]}):null,p===`config`&&c?(0,G.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,G.jsxs)(me,{children:[(0,G.jsx)(pe,{icon:ue,title:n.globalTitle,subtitle:n.globalHint}),(0,G.jsx)(`div`,{className:`max-w-xl`,children:(0,G.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.idleTtlLabel}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`number`,min:0,className:i(cn,`w-40 flex-none`),value:B??``,placeholder:n.idleTtlPlaceholder,onChange:e=>{let t=e.target.value.trim();ie(t===``?void 0:Number.parseInt(t,10)),le(!1)}}),(0,G.jsxs)(L,{variant:`secondary`,disabled:V,onClick:()=>void Le(),children:[V?(0,G.jsx)(E,{className:`size-4 animate-spin`}):null,n.save]})]}),(0,G.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.idleTtlHint})]})})]})}):null,p===`marketplace`&&c?(0,G.jsx)(`div`,{className:`flex flex-col gap-4`,children:_&&Ue.length===0?(0,G.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:xe.map(e=>(0,G.jsx)(Ce,{},e))}):C.trim()&&Ue.length===0?(0,G.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.marketplaceEmpty}):!C.trim()&&Ue.length===0?(0,G.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.marketplaceStartHint}):(0,G.jsxs)(`div`,{className:`relative`,children:[_?(0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1] flex justify-center bg-surface-panel/40 pt-[min(28vh,7.5rem)] backdrop-blur-[1px] motion-reduce:backdrop-blur-none dark:bg-surface-base/35`,"aria-busy":`true`,"aria-label":t.loading,children:(0,G.jsx)(E,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,G.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:Ue.map(e=>(0,G.jsx)(Te,{connector:e,installed:Me.has(e.id)||Se(e,h.instances),onInstall:e=>N(Ht(e)),onOpenDetails:F,t},e.id))}),We?(0,G.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,G.jsxs)(L,{type:`button`,variant:`secondary`,disabled:_,onClick:()=>void Ae({browse:!C.trim(),page:y+1,append:!0}),children:[_?(0,G.jsx)(E,{className:`size-4 animate-spin`}):null,t.loadMore]})}):null]})}):null,p===`builtin`&&c?(0,G.jsx)(`div`,{className:`flex flex-col gap-4`,children:h.loading?(0,G.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:xe.map(e=>(0,G.jsx)(Ce,{},e))}):He.length===0?(0,G.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.builtinEmpty}):(0,G.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:He.map(e=>(0,G.jsx)(Te,{connector:e,installed:Me.has(e.id)||Se(e,h.instances),onInstall:e=>N(Ht(e)),onOpenDetails:F,t},e.id))})}):null]}),M?(0,G.jsx)(Gt,{draft:M,onChange:N,onClose:()=>N(null),t,onInstalled:async()=>{await J(),await fe(),m(`user`)}}):null,P?(0,G.jsx)(Qe,{connector:P,installed:Me.has(P.id)||Se(P,h.instances),onClose:()=>F(null),onInstall:e=>N(Ht(e)),t}):null,qe?(0,G.jsx)(It,{instance:qe,definition:Ne.get(qe.connectorId),onClose:()=>{I(null),re(null)},onChanged:J,t,mcp:n}):null,R?(0,G.jsx)(an,{open:!0,mode:R.mode,initialRow:R.row,existingCustomServers:q,sessionIdleTtlMinutes:B,config:W,managedServerIds:Pe,t:n,cs:t,onClose:()=>z(null),onSaved:async()=>{await fe(),await J(),m(`user`)}},`${R.mode}-${R.row.clientKey}`):null]})})}export{ln as ConnectorsPage};
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-BQ_8x0bT.js";import{Dt as r,Et as i,St as a}from"./index-BPXLPMuY.js";var o=e(),s=t();function c(e){let t=(0,o.c)(37),{value:c,onChange:l,disabled:u,wd:d,placeholder:f,inputClassName:p,trailing:m}=e,h;t[0]!==l||t[1]!==c?(h={initialPath:c,onPicked:l},t[0]=l,t[1]=c,t[2]=h):h=t[2];let g=i(h),_;t[3]===c?_=t[4]:(_=c.trim(),t[3]=c,t[4]=_);let v=_,y=v?`${v}\n${d.chooseFolder}`:`${f??d.notSet}\n${d.selectWorkingDirectory}`,b;t[5]===p?b=t[6]:(b=n(`min-w-0 flex-1`,p),t[5]=p,t[6]=b);let x=u||g.picking,S;t[7]===l?S=t[8]:(S=e=>void l(e.target.value),t[7]=l,t[8]=S);let C=f??d.pathInputPlaceholder,w;t[9]!==b||t[10]!==x||t[11]!==S||t[12]!==C||t[13]!==c?(w=(0,s.jsx)(`input`,{type:`text`,className:b,value:c,disabled:x,onChange:S,placeholder:C,autoComplete:`off`,spellCheck:!1}),t[9]=b,t[10]=x,t[11]=S,t[12]=C,t[13]=c,t[14]=w):w=t[14];let T=u||g.picking,E;t[15]!==y||t[16]!==g.pick||t[17]!==T||t[18]!==c||t[19]!==d.selectWorkingDirectory?(E=(0,s.jsx)(r,{compact:!0,value:c,onPick:g.pick,disabled:T,title:y,"aria-label":d.selectWorkingDirectory}),t[15]=y,t[16]=g.pick,t[17]=T,t[18]=c,t[19]=d.selectWorkingDirectory,t[20]=E):E=t[20];let D;t[21]!==E||t[22]!==m?(D=(0,s.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[E,m]}),t[21]=E,t[22]=m,t[23]=D):D=t[23];let O;t[24]!==D||t[25]!==w?(O=(0,s.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[w,D]}),t[24]=D,t[25]=w,t[26]=O):O=t[26];let k;t[27]!==g.confirmPick||t[28]!==g.hasNativePicker||t[29]!==g.modalOpen||t[30]!==g.setModalOpen||t[31]!==v||t[32]!==d?(k=g.hasNativePicker?null:(0,s.jsx)(a,{open:g.modalOpen,onOpenChange:g.setModalOpen,initialAbsolutePath:v||void 0,onConfirm:g.confirmPick,wd:d}),t[27]=g.confirmPick,t[28]=g.hasNativePicker,t[29]=g.modalOpen,t[30]=g.setModalOpen,t[31]=v,t[32]=d,t[33]=k):k=t[33];let A;return t[34]!==O||t[35]!==k?(A=(0,s.jsxs)(s.Fragment,{children:[O,k]}),t[34]=O,t[35]=k,t[36]=A):A=t[36],A}export{c as t};
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-BQ_8x0bT.js";import{Dt as r,Et as i,St as a}from"./index-CA2tR2vm.js";var o=e(),s=t();function c(e){let t=(0,o.c)(37),{value:c,onChange:l,disabled:u,wd:d,placeholder:f,inputClassName:p,trailing:m}=e,h;t[0]!==l||t[1]!==c?(h={initialPath:c,onPicked:l},t[0]=l,t[1]=c,t[2]=h):h=t[2];let g=i(h),_;t[3]===c?_=t[4]:(_=c.trim(),t[3]=c,t[4]=_);let v=_,y=v?`${v}\n${d.chooseFolder}`:`${f??d.notSet}\n${d.selectWorkingDirectory}`,b;t[5]===p?b=t[6]:(b=n(`min-w-0 flex-1`,p),t[5]=p,t[6]=b);let x=u||g.picking,S;t[7]===l?S=t[8]:(S=e=>void l(e.target.value),t[7]=l,t[8]=S);let C=f??d.pathInputPlaceholder,w;t[9]!==b||t[10]!==x||t[11]!==S||t[12]!==C||t[13]!==c?(w=(0,s.jsx)(`input`,{type:`text`,className:b,value:c,disabled:x,onChange:S,placeholder:C,autoComplete:`off`,spellCheck:!1}),t[9]=b,t[10]=x,t[11]=S,t[12]=C,t[13]=c,t[14]=w):w=t[14];let T=u||g.picking,E;t[15]!==y||t[16]!==g.pick||t[17]!==T||t[18]!==c||t[19]!==d.selectWorkingDirectory?(E=(0,s.jsx)(r,{compact:!0,value:c,onPick:g.pick,disabled:T,title:y,"aria-label":d.selectWorkingDirectory}),t[15]=y,t[16]=g.pick,t[17]=T,t[18]=c,t[19]=d.selectWorkingDirectory,t[20]=E):E=t[20];let D;t[21]!==E||t[22]!==m?(D=(0,s.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[E,m]}),t[21]=E,t[22]=m,t[23]=D):D=t[23];let O;t[24]!==D||t[25]!==w?(O=(0,s.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[w,D]}),t[24]=D,t[25]=w,t[26]=O):O=t[26];let k;t[27]!==g.confirmPick||t[28]!==g.hasNativePicker||t[29]!==g.modalOpen||t[30]!==g.setModalOpen||t[31]!==v||t[32]!==d?(k=g.hasNativePicker?null:(0,s.jsx)(a,{open:g.modalOpen,onOpenChange:g.setModalOpen,initialAbsolutePath:v||void 0,onConfirm:g.confirmPick,wd:d}),t[27]=g.confirmPick,t[28]=g.hasNativePicker,t[29]=g.modalOpen,t[30]=g.setModalOpen,t[31]=v,t[32]=d,t[33]=k):k=t[33];let A;return t[34]!==O||t[35]!==k?(A=(0,s.jsxs)(s.Fragment,{children:[O,k]}),t[34]=O,t[35]=k,t[36]=A):A=t[36],A}export{c as t};
@@ -1,3 +1,3 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-CjuIJcZl.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s,i as c,n as l}from"./fetch-NFKfkqrd.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{$o as d,Ds as f,Es as p,Hs as m,Lo as h,Tt as g,Wo as _,Yo as v,al as y,dl as b,do as x,er as S,ko as C,mo as w,so as T,ss as E,ta as D,vs as O,wo as k}from"./index-BPXLPMuY.js";import{n as A,t as j}from"./settings-form-section-BBYUDLVd.js";import{t as ee}from"./page-tabs-EIZhLppK.js";import{n as M,r as te,t as ne}from"./settings-page-layout-D8g9PAek.js";import{n as N,t as P}from"./schedule-field-B5qshALm.js";import{t as F}from"./format-cron-label-arqgGlVV.js";var I=e(t(),1),L=n();function R(e,t){let n=new URLSearchParams;e&&n.set(`agentId`,e);for(let[e,r]of Object.entries(t??{}))r!==void 0&&n.set(e,String(r));let r=n.toString();return r?`?${r}`:``}function re(e){return c(`/api/dreaming${R(e)}`)}async function ie(e){let t=await l(e?.startsWith(`/api/`)||e?.includes(`/api/dreaming`)?e:re(e));if(!t.payload)throw Error(`Missing payload`);return t.payload}async function ae(e,t){await l(c(`/api/dreaming/action`),{method:`POST`,body:JSON.stringify({action:e,agentId:t})})}async function oe(e=`deep`,t){let n=await l(c(`/api/dreaming/run`),{method:`POST`,body:JSON.stringify({phase:e,agentId:t})});if(n.ok===!1||!n.payload)throw Error(`Failed to run dreaming phase`);let r=n.payload.phase;return{agentId:typeof n.payload.agentId==`string`?n.payload.agentId:void 0,phase:r===`light`||r===`deep`||r===`rem`?r:e,result:n.payload.result}}async function se(e,t){let n=await l(c(`/api/dreaming/preview${R(t,typeof e==`number`&&Number.isFinite(e)?{limit:e}:void 0)}`));if(!n.payload)throw Error(`Missing payload`);return n.payload}async function ce(e=50,t){return(await l(c(`/api/dreaming/events${R(t,{limit:e})}`))).payload?.events??[]}function z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var B={enabled:!0,cron:`0 */6 * * *`,lookbackDays:1,limit:50,dedupeSimilarity:.85},V={enabled:!0,cron:`0 3 * * *`,minScore:.8,minRecallCount:3,minUniqueQueries:3,limit:10,recencyHalfLifeDays:14,maxAgeDays:30},H={enabled:!0,cron:`0 5 * * 0`,lookbackDays:7,limit:20,minPatternStrength:.6},U={enabled:!1,frequency:`0 3 * * *`,timezone:``,deepEnabled:!0,minScore:.8,minRecallCount:3,limit:10,light:B,deep:V,rem:H};function W(e,t){return Number.isFinite(e)?Math.max(0,Math.min(1,e)):t}function G(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?Math.max(0,Math.floor(n)):t}function K(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?n:t}function q(e){let t=z(e)?e:{},n=z(t.memory)?t.memory:{},r=z(t.dreaming)?t.dreaming:{},i=typeof t.enabled==`boolean`||typeof t.frequency==`string`||z(t.phases)?t:{},a=z(n.dreaming)?n.dreaming:Object.keys(r).length>0?r:i,o=z(a.phases)?a.phases:{},s=z(o.light)?o.light:{},c=z(o.deep)?o.deep:{},l=z(o.rem)?o.rem:{};return{enabled:a.enabled===!0,frequency:typeof a.frequency==`string`&&a.frequency.trim()?a.frequency.trim():U.frequency,timezone:typeof a.timezone==`string`?a.timezone:``,deepEnabled:c.enabled!==!1,minScore:W(typeof c.minScore==`number`?c.minScore:Number(c.minScore),U.minScore),minRecallCount:Math.max(1,G(c.minRecallCount,U.minRecallCount)),limit:G(c.limit,U.limit),light:{enabled:s.enabled!==!1,cron:typeof s.cron==`string`&&s.cron.trim()?s.cron.trim():B.cron,lookbackDays:Math.max(1,G(s.lookbackDays,B.lookbackDays)),limit:G(s.limit,B.limit),dedupeSimilarity:W(K(s.dedupeSimilarity,B.dedupeSimilarity),B.dedupeSimilarity)},deep:{enabled:c.enabled!==!1,cron:typeof c.cron==`string`&&c.cron.trim()?c.cron.trim():V.cron,minScore:W(K(c.minScore,V.minScore),V.minScore),minRecallCount:Math.max(1,G(c.minRecallCount,V.minRecallCount)),minUniqueQueries:Math.max(1,G(c.minUniqueQueries,V.minUniqueQueries)),limit:G(c.limit,V.limit),recencyHalfLifeDays:Math.max(1,K(c.recencyHalfLifeDays,V.recencyHalfLifeDays)),maxAgeDays:Math.max(1,K(c.maxAgeDays,V.maxAgeDays))},rem:{enabled:l.enabled!==!1,cron:typeof l.cron==`string`&&l.cron.trim()?l.cron.trim():H.cron,lookbackDays:Math.max(1,G(l.lookbackDays,H.lookbackDays)),limit:G(l.limit,H.limit),minPatternStrength:W(K(l.minPatternStrength,H.minPatternStrength),H.minPatternStrength)}}}async function le(e,t,n){let r=t.frequency.trim(),i=t.timezone.trim();await l(c(`/api/agents/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({memory:{...n??{},mode:t.enabled?`confirmWrite`:typeof n?.mode==`string`?n.mode:`off`,sources:Array.isArray(n?.sources)?n.sources:[`session`,`curated`,`workspace`],writePolicy:z(n?.writePolicy)?n.writePolicy:{curated:`confirm`,workspace:`confirm`},dreaming:{enabled:!!t.enabled,...r?{frequency:r}:{},...i?{timezone:i}:{},phases:{light:{enabled:!!t.light.enabled,...t.light.cron.trim()?{cron:t.light.cron.trim()}:{},lookbackDays:Math.max(1,Math.floor(t.light.lookbackDays)),limit:Math.max(0,Math.floor(t.light.limit)),dedupeSimilarity:W(t.light.dedupeSimilarity,B.dedupeSimilarity)},deep:{enabled:!!t.deep.enabled,...t.deep.cron.trim()?{cron:t.deep.cron.trim()}:{},minScore:W(t.deep.minScore,V.minScore),minRecallCount:Math.max(1,Math.floor(t.deep.minRecallCount)),minUniqueQueries:Math.max(1,Math.floor(t.deep.minUniqueQueries)),limit:Math.max(0,Math.floor(t.deep.limit)),recencyHalfLifeDays:Math.max(1,t.deep.recencyHalfLifeDays),maxAgeDays:Math.max(1,t.deep.maxAgeDays)},rem:{enabled:!!t.rem.enabled,...t.rem.cron.trim()?{cron:t.rem.cron.trim()}:{},lookbackDays:Math.max(1,Math.floor(t.rem.lookbackDays)),limit:Math.max(0,Math.floor(t.rem.limit)),minPatternStrength:W(t.rem.minPatternStrength,H.minPatternStrength)}}}}})}),D()}var J=`p-4 sm:px-5`,ue=`mb-3`,Y=`rounded-xl bg-surface-panel/60 p-3 shadow-surface sm:p-4`,X=i(`mt-1 w-full rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm text-fg`,T);function de(e){return e?e.replace(`T`,` `).replace(`Z`,``):`—`}function fe(e){return e===void 0||!Number.isFinite(e)||e<0?`—`:e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(2)} s`}function pe(e,t){return e.locked?{text:t.lockValueLocked,className:`text-amber-600 dark:text-amber-400`}:{text:t.lockValueUnlocked,className:`text-emerald-600 dark:text-emerald-400`}}var Z=r(),me=`text-xs font-medium text-fg-muted`,he=`text-sm font-medium text-fg`;function Q(e){let t=(0,L.c)(6),{label:n,children:r,className:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`span`,{className:me,children:n}),t[0]=n,t[1]=a);let o;return t[2]!==r||t[3]!==i||t[4]!==a?(o=(0,Z.jsxs)(`div`,{className:i,children:[a,r]}),t[2]=r,t[3]=i,t[4]=a,t[5]=o):o=t[5],o}function $(e){let t=(0,L.c)(11),{label:n,children:r,className:a}=e,o;t[0]===a?o=t[1]:(o=i(`min-w-0`,a),t[0]=a,t[1]=o);let s;t[2]===n?s=t[3]:(s=(0,Z.jsx)(`dt`,{className:me,children:n}),t[2]=n,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=i(he,`mt-0.5`),t[4]=c):c=t[4];let l;t[5]===r?l=t[6]:(l=(0,Z.jsx)(`dd`,{className:c,children:r}),t[5]=r,t[6]=l);let u;return t[7]!==o||t[8]!==s||t[9]!==l?(u=(0,Z.jsxs)(`div`,{className:o,children:[s,l]}),t[7]=o,t[8]=s,t[9]=l,t[10]=u):u=t[10],u}function ge(e){let t=(0,L.c)(5),{label:n,className:r}=e,a;t[0]===r?a=t[1]:(a=i(`text-[0.7rem] font-semibold uppercase tracking-wider text-fg-muted`,r),t[0]=r,t[1]=a);let o;return t[2]!==n||t[3]!==a?(o=(0,Z.jsx)(`h3`,{className:a,children:n}),t[2]=n,t[3]=a,t[4]=o):o=t[4],o}function _e(e){let t=(0,L.c)(39),{icon:n,title:r,hint:i,enabled:a,onEnabledChange:o,cron:s,onCronChange:c,scheduleLabels:l,disabled:u,showEnabledControl:d,actions:f,status:p,enabledLabel:m,onLabel:h,offLabel:g,cronLabel:_,children:v}=e,y=d===void 0?!0:d,b;t[0]===n?b=t[1]:(b=(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:n}),t[0]=n,t[1]=b);let x;t[2]===r?x=t[3]:(x=(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=x);let S;t[4]!==p||t[5]!==x?(S=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[x,p]}),t[4]=p,t[5]=x,t[6]=S):S=t[6];let C;t[7]===i?C=t[8]:(C=(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs leading-snug text-fg-muted`,children:i}),t[7]=i,t[8]=C);let w;t[9]!==S||t[10]!==C?(w=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[S,C]}),t[9]=S,t[10]=C,t[11]=w):w=t[11];let T;t[12]!==b||t[13]!==w?(T=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[b,w]}),t[12]=b,t[13]=w,t[14]=T):T=t[14];let E;t[15]!==f||t[16]!==u||t[17]!==a||t[18]!==m||t[19]!==g||t[20]!==o||t[21]!==h||t[22]!==y?(E=f||y?(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[f,y?(0,Z.jsxs)(`label`,{className:`inline-flex shrink-0 items-center gap-2 text-xs text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:a,disabled:u,onChange:e=>o(e.target.checked)}),(0,Z.jsx)(`span`,{children:m??(a?h:g)})]}):null]}):null,t[15]=f,t[16]=u,t[17]=a,t[18]=m,t[19]=g,t[20]=o,t[21]=h,t[22]=y,t[23]=E):E=t[23];let D;t[24]!==T||t[25]!==E?(D=(0,Z.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-start justify-between gap-2 rounded-lg bg-surface-base/45 px-3 py-2.5`,children:[T,E]}),t[24]=T,t[25]=E,t[26]=D):D=t[26];let O;t[27]!==s||t[28]!==_||t[29]!==u||t[30]!==c||t[31]!==l?(O=(0,Z.jsx)(P,{kind:`cron`,className:`mb-2.5`,label:_,value:s,onChange:c,labels:l,disabled:u}),t[27]=s,t[28]=_,t[29]=u,t[30]=c,t[31]=l,t[32]=O):O=t[32];let k;t[33]===v?k=t[34]:(k=(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4`,children:v}),t[33]=v,t[34]=k);let A;return t[35]!==O||t[36]!==k||t[37]!==D?(A=(0,Z.jsxs)(`div`,{className:Y,children:[D,O,k]}),t[35]=O,t[36]=k,t[37]=D,t[38]=A):A=t[38],A}function ve(e){let t=(0,L.c)(23),{icon:n,label:r,enabled:a,cron:o,scheduleSummary:s,details:c,t:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(Y,`space-y-1`),t[0]=u):u=t[0];let d;t[1]===r?d=t[2]:(d=(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r}),t[1]=r,t[2]=d);let f=a?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`,p;t[3]===f?p=t[4]:(p=i(`ml-auto text-xs font-medium`,f),t[3]=f,t[4]=p);let m=a?l.on:l.off,h;t[5]!==p||t[6]!==m?(h=(0,Z.jsx)(`span`,{className:p,children:m}),t[5]=p,t[6]=m,t[7]=h):h=t[7];let g;t[8]!==n||t[9]!==d||t[10]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n,d,h]}),t[8]=n,t[9]=d,t[10]=h,t[11]=g):g=t[11];let _;t[12]===s?_=t[13]:(_=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:s}),t[12]=s,t[13]=_);let v;t[14]===o?v=t[15]:(v=(0,Z.jsx)(`p`,{className:`truncate font-mono text-[0.65rem] text-fg-subtle`,title:o,children:o}),t[14]=o,t[15]=v);let y;t[16]===c?y=t[17]:(y=(0,Z.jsx)(`p`,{className:`text-[0.65rem] leading-snug text-fg-muted`,children:c}),t[16]=c,t[17]=y);let b;return t[18]!==y||t[19]!==g||t[20]!==_||t[21]!==v?(b=(0,Z.jsxs)(`div`,{className:u,children:[g,_,v,y]}),t[18]=y,t[19]=g,t[20]=_,t[21]=v,t[22]=b):b=t[22],b}function ye(e){let t=(0,L.c)(9),{label:n,lastRun:r,t:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(ge,{label:n,className:`mb-2`}),t[0]=n,t[1]=a);let o;t[2]!==r||t[3]!==i.lastRunRaw||t[4]!==i.phaseLastRunEmpty?(o=r?.exists?(0,Z.jsxs)(`details`,{className:`group rounded-lg bg-surface-panel/70 shadow-surface`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer list-none px-2.5 py-1.5 text-xs font-medium text-fg-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:(0,Z.jsx)(`span`,{className:`underline decoration-edge underline-offset-2 group-open:text-fg`,children:i.lastRunRaw})}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto bg-surface-base/50 p-2.5 text-xs text-fg-muted`,children:JSON.stringify(r.raw,null,2)})]}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.phaseLastRunEmpty}),t[2]=r,t[3]=i.lastRunRaw,t[4]=i.phaseLastRunEmpty,t[5]=o):o=t[5];let s;return t[6]!==a||t[7]!==o?(s=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-base/45 p-3`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8],s}function be(e){let t=(0,L.c)(39),{t:n,r}=e,i=r.deep?.skipped,a=r.ok?`text-emerald-600 dark:text-emerald-400`:`text-amber-600 dark:text-amber-400`,o=r.ok?n.lastRunSuccess:n.lastRunFailure,s;t[0]!==a||t[1]!==o?(s=(0,Z.jsx)(`span`,{className:a,children:o}),t[0]=a,t[1]=o,t[2]=s):s=t[2];let c;t[3]!==n.lastRunStatus||t[4]!==s?(c=(0,Z.jsx)($,{label:n.lastRunStatus,children:s}),t[3]=n.lastRunStatus,t[4]=s,t[5]=c):c=t[5];let l=n.lastRunDuration,u;t[6]===r.durationMs?u=t[7]:(u=fe(r.durationMs),t[6]=r.durationMs,t[7]=u);let d;t[8]!==n.lastRunDuration||t[9]!==u?(d=(0,Z.jsx)($,{label:l,children:u}),t[8]=n.lastRunDuration,t[9]=u,t[10]=d):d=t[10];let f=n.lastRunRanked,p=String(r.deep?.candidatesRanked??`—`),m;t[11]!==n.lastRunRanked||t[12]!==p?(m=(0,Z.jsx)($,{label:f,children:p}),t[11]=n.lastRunRanked,t[12]=p,t[13]=m):m=t[13];let h=n.lastRunApplied,g=String(r.deep?.applied??`—`),_;t[14]!==n.lastRunApplied||t[15]!==g?(_=(0,Z.jsx)($,{label:h,children:g}),t[14]=n.lastRunApplied,t[15]=g,t[16]=_):_=t[16];let v;t[17]===r.reason?v=t[18]:(v=(0,Z.jsx)(`span`,{className:`block text-pretty`,children:r.reason}),t[17]=r.reason,t[18]=v);let y;t[19]!==r.errorMessage||t[20]!==n.lastRunError?(y=r.errorMessage?(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-amber-600 dark:text-amber-400`,children:`${n.lastRunError}: ${r.errorMessage}`}):null,t[19]=r.errorMessage,t[20]=n.lastRunError,t[21]=y):y=t[21];let b;t[22]!==n.lastRunReason||t[23]!==v||t[24]!==y?(b=(0,Z.jsxs)($,{label:n.lastRunReason,className:`col-span-2 sm:col-span-3 lg:col-span-4`,children:[v,y]}),t[22]=n.lastRunReason,t[23]=v,t[24]=y,t[25]=b):b=t[25];let x;t[26]!==i||t[27]!==n.lastRunSkipContaminated||t[28]!==n.lastRunSkipHash||t[29]!==n.lastRunSkipKey||t[30]!==n.lastRunSkipRehydrate?(x=i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:n.lastRunSkipKey,children:String(i.alreadyPromotedKey)}),(0,Z.jsx)($,{label:n.lastRunSkipRehydrate,children:String(i.rehydrateFailed)}),(0,Z.jsx)($,{label:n.lastRunSkipContaminated,children:String(i.contaminated)}),(0,Z.jsx)($,{label:n.lastRunSkipHash,children:String(i.hashDuplicate)})]}):null,t[26]=i,t[27]=n.lastRunSkipContaminated,t[28]=n.lastRunSkipHash,t[29]=n.lastRunSkipKey,t[30]=n.lastRunSkipRehydrate,t[31]=x):x=t[31];let S;return t[32]!==m||t[33]!==_||t[34]!==b||t[35]!==x||t[36]!==c||t[37]!==d?(S=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-3 lg:grid-cols-4`,children:[c,d,m,_,b,x]}),t[32]=m,t[33]=_,t[34]=b,t[35]=x,t[36]=c,t[37]=d,t[38]=S):S=t[38],S}function xe(e){let t=(0,L.c)(56),{t:n,schedulePickerLabels:r,hasToken:a,cfgForm:o,cfgBaseline:s,cfgDirty:c,cfgSaving:l,runPhase:u,runBusy:d,setCfgForm:f,doRunNow:p}=e,g;t[0]!==c||t[1]!==o?.enabled||t[2]!==l||t[3]!==p||t[4]!==a||t[5]!==d||t[6]!==u||t[7]!==n?(g=(e,t)=>o?.enabled?(0,Z.jsx)(we,{t:n,busy:d&&u===e,disabled:!a||l||d||!t||c,title:c?n.runNowSaveFirstHint:n.runNowHint,onClick:()=>{p(e)}}):null,t[0]=c,t[1]=o?.enabled,t[2]=l,t[3]=p,t[4]=a,t[5]=d,t[6]=u,t[7]=n,t[8]=g):g=t[8];let _=g,v;t[9]!==s||t[10]!==o||t[11]!==n.phasePendingSave||t[12]!==n.phaseWillDisable||t[13]!==n.phaseWillEnable?(v=e=>{if(!o||!s)return null;let t=o[e],r=s[e];return JSON.stringify(t)===JSON.stringify(r)?null:t.enabled===r.enabled?n.phasePendingSave:t.enabled?n.phaseWillEnable:n.phaseWillDisable},t[9]=s,t[10]=o,t[11]=n.phasePendingSave,t[12]=n.phaseWillDisable,t[13]=n.phaseWillEnable,t[14]=v):v=t[14];let y=v,b;return t[15]!==c||t[16]!==o||t[17]!==l||t[18]!==a||t[19]!==y||t[20]!==_||t[21]!==r||t[22]!==f||t[23]!==n.configDeepHalfLife||t[24]!==n.configDeepLimit||t[25]!==n.configDeepMaxAge||t[26]!==n.configDeepMinRecallCount||t[27]!==n.configDeepMinScore||t[28]!==n.configDeepMinUniqueQueries||t[29]!==n.configFrequency||t[30]!==n.configLightDedupe||t[31]!==n.configLightLimit||t[32]!==n.configLightLookbackDays||t[33]!==n.configLoading||t[34]!==n.configPhaseCron||t[35]!==n.configPhaseDeep||t[36]!==n.configPhaseDeepHint||t[37]!==n.configPhaseLight||t[38]!==n.configPhaseLightHint||t[39]!==n.configPhaseRem||t[40]!==n.configPhaseRemHint||t[41]!==n.configRemLimit||t[42]!==n.configRemLookbackDays||t[43]!==n.configRemMinStrength||t[44]!==n.configTimezone||t[45]!==n.masterHint||t[46]!==n.masterOff||t[47]!==n.masterOn||t[48]!==n.masterTitle||t[49]!==n.off||t[50]!==n.on||t[51]!==n.phasesTitle||t[52]!==n.scheduleTitle||t[53]!==n.unsavedConfigHint||t[54]!==n.unsavedConfigTitle?(b=(0,Z.jsx)(j,{className:`min-w-0 !p-0`,children:o?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:i(Y,`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`),children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.masterTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.masterHint})]}),(0,Z.jsxs)(`label`,{className:i(`inline-flex w-fit cursor-pointer items-center gap-2 rounded-xl border px-3 py-1.5 text-sm transition-colors`,o.enabled?`border-emerald-500/30 bg-emerald-500/5 text-fg`:`border-edge-subtle bg-surface-panel/50 text-fg-muted`),children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:o.enabled,disabled:!a||l,onChange:e=>f(t=>t&&{...t,enabled:e.target.checked})}),(0,Z.jsx)(`span`,{className:i(`text-xs font-semibold`,o.enabled?`text-emerald-600 dark:text-emerald-400`:``),children:o.enabled?n.masterOn:n.masterOff})]})]}),c?(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-xs text-amber-900 dark:text-amber-100`,children:[(0,Z.jsx)(m,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":!0}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`font-semibold`,children:n.unsavedConfigTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 leading-snug text-amber-800/90 dark:text-amber-100/80`,children:n.unsavedConfigHint})]})]}):null,(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(Se,{title:n.scheduleTitle}),(0,Z.jsx)(`div`,{className:Y,children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 lg:grid-cols-12`,children:[(0,Z.jsx)(`div`,{className:`lg:col-span-9`,children:(0,Z.jsx)(P,{kind:`cron`,label:n.configFrequency,value:o.frequency,onChange:e=>f(t=>t&&{...t,frequency:e}),labels:r,disabled:!a||l})}),(0,Z.jsx)(Q,{label:n.configTimezone,className:`lg:col-span-3`,children:(0,Z.jsx)(`input`,{className:X,value:o.timezone,disabled:!a||l,onChange:e=>f(t=>t&&{...t,timezone:e.target.value}),placeholder:`Asia/Shanghai`})})]})})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(Se,{title:n.phasesTitle}),(0,Z.jsxs)(_e,{icon:(0,Z.jsx)(C,{className:`size-4 text-amber-500`}),title:n.configPhaseLight,hint:n.configPhaseLightHint,enabled:o.light.enabled,onEnabledChange:e=>f(t=>t&&{...t,light:{...t.light,enabled:e}}),cron:o.light.cron,onCronChange:e=>f(t=>t&&{...t,light:{...t.light,cron:e}}),scheduleLabels:r,disabled:!a||l,showEnabledControl:o.enabled,actions:_(`light`,o.light.enabled),status:y(`light`)?(0,Z.jsx)(Ce,{label:y(`light`)??``}):null,enabledLabel:y(`light`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configLightLookbackDays,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.light.lookbackDays,disabled:!a||l,onChange:e=>f(t=>t&&{...t,light:{...t.light,lookbackDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configLightLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:X,value:o.light.limit,disabled:!a||l,onChange:e=>f(t=>t&&{...t,light:{...t.light,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configLightDedupe,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:X,value:o.light.dedupeSimilarity,disabled:!a||l,onChange:e=>f(t=>t&&{...t,light:{...t.light,dedupeSimilarity:Number(e.target.value)}})})})]}),(0,Z.jsxs)(_e,{icon:(0,Z.jsx)(O,{className:`size-4 text-indigo-500`}),title:n.configPhaseDeep,hint:n.configPhaseDeepHint,enabled:o.deep.enabled,onEnabledChange:e=>f(t=>t&&{...t,deep:{...t.deep,enabled:e}}),cron:o.deep.cron,onCronChange:e=>f(t=>t&&{...t,deep:{...t.deep,cron:e}}),scheduleLabels:r,disabled:!a||l,showEnabledControl:o.enabled,actions:_(`deep`,o.deep.enabled),status:y(`deep`)?(0,Z.jsx)(Ce,{label:y(`deep`)??``}):null,enabledLabel:y(`deep`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configDeepMinScore,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:X,value:o.deep.minScore,disabled:!a||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,minScore:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMinRecallCount,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.minRecallCount,disabled:!a||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,minRecallCount:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMinUniqueQueries,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.minUniqueQueries,disabled:!a||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,minUniqueQueries:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:X,value:o.deep.limit,disabled:!a||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepHalfLife,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.recencyHalfLifeDays,disabled:!a||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,recencyHalfLifeDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMaxAge,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.maxAgeDays,disabled:!a||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,maxAgeDays:Number(e.target.value)}})})})]}),(0,Z.jsxs)(_e,{icon:(0,Z.jsx)(h,{className:`size-4 text-purple-500`}),title:n.configPhaseRem,hint:n.configPhaseRemHint,enabled:o.rem.enabled,onEnabledChange:e=>f(t=>t&&{...t,rem:{...t.rem,enabled:e}}),cron:o.rem.cron,onCronChange:e=>f(t=>t&&{...t,rem:{...t.rem,cron:e}}),scheduleLabels:r,disabled:!a||l,showEnabledControl:o.enabled,actions:_(`rem`,o.rem.enabled),status:y(`rem`)?(0,Z.jsx)(Ce,{label:y(`rem`)??``}):null,enabledLabel:y(`rem`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configRemLookbackDays,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.rem.lookbackDays,disabled:!a||l,onChange:e=>f(t=>t&&{...t,rem:{...t.rem,lookbackDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configRemLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:X,value:o.rem.limit,disabled:!a||l,onChange:e=>f(t=>t&&{...t,rem:{...t.rem,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configRemMinStrength,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:X,value:o.rem.minPatternStrength,disabled:!a||l,onChange:e=>f(t=>t&&{...t,rem:{...t.rem,minPatternStrength:Number(e.target.value)}})})})]})]})]}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.configLoading})}),t[15]=c,t[16]=o,t[17]=l,t[18]=a,t[19]=y,t[20]=_,t[21]=r,t[22]=f,t[23]=n.configDeepHalfLife,t[24]=n.configDeepLimit,t[25]=n.configDeepMaxAge,t[26]=n.configDeepMinRecallCount,t[27]=n.configDeepMinScore,t[28]=n.configDeepMinUniqueQueries,t[29]=n.configFrequency,t[30]=n.configLightDedupe,t[31]=n.configLightLimit,t[32]=n.configLightLookbackDays,t[33]=n.configLoading,t[34]=n.configPhaseCron,t[35]=n.configPhaseDeep,t[36]=n.configPhaseDeepHint,t[37]=n.configPhaseLight,t[38]=n.configPhaseLightHint,t[39]=n.configPhaseRem,t[40]=n.configPhaseRemHint,t[41]=n.configRemLimit,t[42]=n.configRemLookbackDays,t[43]=n.configRemMinStrength,t[44]=n.configTimezone,t[45]=n.masterHint,t[46]=n.masterOff,t[47]=n.masterOn,t[48]=n.masterTitle,t[49]=n.off,t[50]=n.on,t[51]=n.phasesTitle,t[52]=n.scheduleTitle,t[53]=n.unsavedConfigHint,t[54]=n.unsavedConfigTitle,t[55]=b):b=t[55],b}function Se(e){let t=(0,L.c)(2),{title:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`px-0.5 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:n}),t[0]=n,t[1]=r),r}function Ce(e){let t=(0,L.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`span`,{className:`inline-flex shrink-0 rounded-md border border-amber-500/25 bg-amber-500/10 px-1.5 py-0.5 text-[0.65rem] font-semibold text-amber-800 dark:text-amber-200`,children:n}),t[0]=n,t[1]=r),r}function we(e){let t=(0,L.c)(8),{t:n,busy:r,disabled:i,title:a,onClick:o}=e,s;t[0]===r?s=t[1]:(s=r?(0,Z.jsx)(f,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(E,{className:`size-3.5`,"aria-hidden":!0}),t[0]=r,t[1]=s);let c;return t[2]!==i||t[3]!==o||t[4]!==n.runNow||t[5]!==s||t[6]!==a?(c=(0,Z.jsxs)(x,{type:`button`,variant:`secondary`,className:`h-7 gap-1.5 rounded-lg px-2 text-xs`,disabled:i,title:a,onClick:o,children:[s,n.runNow]}),t[2]=i,t[3]=o,t[4]=n.runNow,t[5]=s,t[6]=a,t[7]=c):c=t[7],c}function Te(e){let t=(0,L.c)(20),{t:n,hasToken:r,eventsLoading:i,events:a,loadEvents:o}=e,s=!r||i,c;t[0]===o?c=t[1]:(c=()=>void o(),t[0]=o,t[1]=c);let l;t[2]===i?l=t[3]:(l=i?(0,Z.jsx)(f,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=i,t[3]=l);let u;t[4]!==n.eventsLoad||t[5]!==s||t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(x,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:s,onClick:c,children:[l,n.eventsLoad]}),t[4]=n.eventsLoad,t[5]=s,t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]!==n.eventsHint||t[10]!==n.eventsTitle||t[11]!==u?(d=(0,Z.jsx)(A,{className:ue,icon:y,title:n.eventsTitle,subtitle:n.eventsHint,trailing:u}),t[9]=n.eventsHint,t[10]=n.eventsTitle,t[11]=u,t[12]=d):d=t[12];let p;t[13]!==a||t[14]!==n.eventsEmpty||t[15]!==n.eventsNotLoaded?(p=a?a.length>0?(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:a.map(Ee)}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.eventsEmpty}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.eventsNotLoaded}),t[13]=a,t[14]=n.eventsEmpty,t[15]=n.eventsNotLoaded,t[16]=p):p=t[16];let m;return t[17]!==d||t[18]!==p?(m=(0,Z.jsxs)(j,{className:J,children:[d,p]}),t[17]=d,t[18]=p,t[19]=m):m=t[19],m}function Ee(e){let t=e.phase===`light`?`☀️`:e.phase===`rem`?`✨`:`🌙`,n=e.phase===`light`?`scanned=${e.scannedEntries??0} new=${e.newSignals??0} deduped=${e.deduped??0}`:e.phase===`rem`?`patterns=${e.patternsDiscovered??0} analyzed=${e.entriesAnalyzed??0}`:`candidates=${e.candidates??0} applied=${e.applied??0}`;return(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 rounded-lg bg-surface-panel/70 px-3 py-2 text-xs shadow-surface`,children:[(0,Z.jsx)(`span`,{children:t}),(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:e.phase}),(0,Z.jsx)(`span`,{className:i(`font-medium`,e.ok?`text-emerald-600 dark:text-emerald-400`:`text-amber-600 dark:text-amber-400`),children:e.ok?`OK`:`FAIL`}),(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:n}),(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:fe(e.durationMs)}),(0,Z.jsx)(`span`,{className:`ml-auto text-fg-subtle`,children:de(e.timestamp)})]},`${e.timestamp}:${e.phase}`)}function De(e){let t=(0,L.c)(40),{t:n,hasToken:r,agents:i,selectedAgentId:a,onAgentChange:o,cfgForm:s,cfgSaving:c,enableAllBusy:l,cfgDirty:u,saveConfig:p,enableAllAgentsDreaming:m,doRefresh:h}=e,g;t[0]!==i||t[1]!==c||t[2]!==r||t[3]!==o||t[4]!==a?(g=i.length>0?(0,Z.jsx)(`select`,{className:`h-9 max-w-44 rounded-md border border-edge bg-surface-panel px-2 text-sm text-fg outline-none transition focus:border-accent`,value:a,disabled:!r||c,onChange:e=>o(e.currentTarget.value),"aria-label":`Agent`,children:i.map(Oe)}):null,t[0]=i,t[1]=c,t[2]=r,t[3]=o,t[4]=a,t[5]=g):g=t[5];let _=!r||c||l||i.length===0,v;t[6]===m?v=t[7]:(v=()=>void m(),t[6]=m,t[7]=v);let y;t[8]===l?y=t[9]:(y=l?(0,Z.jsx)(f,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[8]=l,t[9]=y);let b;t[10]!==n.enableAllAgentsDreaming||t[11]!==_||t[12]!==v||t[13]!==y?(b=(0,Z.jsxs)(x,{type:`button`,variant:`secondary`,disabled:_,onClick:v,children:[y,n.enableAllAgentsDreaming]}),t[10]=n.enableAllAgentsDreaming,t[11]=_,t[12]=v,t[13]=y,t[14]=b):b=t[14];let S=!r||!s||c||l||!u,C;t[15]===p?C=t[16]:(C=()=>void p(),t[15]=p,t[16]=C);let w;t[17]===c?w=t[18]:(w=c?(0,Z.jsx)(f,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[17]=c,t[18]=w);let T;t[19]!==n.saveConfig||t[20]!==S||t[21]!==C||t[22]!==w?(T=(0,Z.jsxs)(x,{type:`button`,variant:`primary`,disabled:S,onClick:C,children:[w,n.saveConfig]}),t[19]=n.saveConfig,t[20]=S,t[21]=C,t[22]=w,t[23]=T):T=t[23];let E=!r,D;t[24]===h?D=t[25]:(D=()=>void h(),t[24]=h,t[25]=D);let O;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(d,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[26]=O):O=t[26];let k;t[27]!==n.refresh||t[28]!==E||t[29]!==D?(k=(0,Z.jsx)(x,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:E,title:n.refresh,"aria-label":n.refresh,onClick:D,children:O}),t[27]=n.refresh,t[28]=E,t[29]=D,t[30]=k):k=t[30];let A;t[31]!==g||t[32]!==k||t[33]!==b||t[34]!==T?(A=(0,Z.jsxs)(Z.Fragment,{children:[g,b,T,k]}),t[31]=g,t[32]=k,t[33]=b,t[34]=T,t[35]=A):A=t[35];let j;return t[36]!==n.subtitle||t[37]!==n.title||t[38]!==A?(j=(0,Z.jsx)(M,{title:n.title,subtitle:n.subtitle,actions:A}),t[36]=n.subtitle,t[37]=n.title,t[38]=A,t[39]=j):j=t[39],j}function Oe(e){return(0,Z.jsx)(`option`,{value:e.id,children:e.name||e.id},e.id)}function ke(e){let t=(0,L.c)(30),{t:n,disabled:r,actionBusy:a,doAction:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=i(`max-w-2xl`,J),t[0]=s):s=t[0];let c;t[1]!==n.maintenanceHint||t[2]!==n.maintenanceTitle?(c=(0,Z.jsx)(A,{className:ue,icon:w,title:n.maintenanceTitle,subtitle:n.maintenanceHint}),t[1]=n.maintenanceHint,t[2]=n.maintenanceTitle,t[3]=c):c=t[3];let l;t[4]!==o||t[5]!==n.confirmResetStore?(l=()=>{confirm(n.confirmResetStore)&&o(`reset_store`)},t[4]=o,t[5]=n.confirmResetStore,t[6]=l):l=t[6];let u;t[7]===a?u=t[8]:(u=a===`reset_store`?(0,Z.jsx)(f,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(k,{className:`mr-2 size-4`,"aria-hidden":!0}),t[7]=a,t[8]=u);let d;t[9]!==r||t[10]!==n.resetStore||t[11]!==l||t[12]!==u?(d=(0,Z.jsxs)(x,{variant:`secondary`,disabled:r,onClick:l,children:[u,n.resetStore]}),t[9]=r,t[10]=n.resetStore,t[11]=l,t[12]=u,t[13]=d):d=t[13];let m;t[14]!==o||t[15]!==n.confirmClearLock?(m=()=>{confirm(n.confirmClearLock)&&o(`clear_lock`)},t[14]=o,t[15]=n.confirmClearLock,t[16]=m):m=t[16];let h;t[17]===a?h=t[18]:(h=a===`clear_lock`?(0,Z.jsx)(f,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(p,{className:`mr-2 size-4`,"aria-hidden":!0}),t[17]=a,t[18]=h);let g;t[19]!==r||t[20]!==n.clearLock||t[21]!==m||t[22]!==h?(g=(0,Z.jsxs)(x,{variant:`secondary`,disabled:r,onClick:m,children:[h,n.clearLock]}),t[19]=r,t[20]=n.clearLock,t[21]=m,t[22]=h,t[23]=g):g=t[23];let _;t[24]!==d||t[25]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[d,g]}),t[24]=d,t[25]=g,t[26]=_):_=t[26];let v;return t[27]!==c||t[28]!==_?(v=(0,Z.jsxs)(j,{className:s,children:[c,_]}),t[27]=c,t[28]=_,t[29]=v):v=t[29],v}function Ae(e){let t=(0,L.c)(21),{t:n,hasToken:r,previewLoading:i,previewItems:a,loadPreview:o}=e,s=!r||i,c;t[0]===o?c=t[1]:(c=()=>void o(),t[0]=o,t[1]=c);let l;t[2]===i?l=t[3]:(l=i?(0,Z.jsx)(f,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=i,t[3]=l);let u;t[4]!==n.previewLoad||t[5]!==s||t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(x,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:s,onClick:c,children:[l,n.previewLoad]}),t[4]=n.previewLoad,t[5]=s,t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]!==n.previewHint||t[10]!==n.previewTitle||t[11]!==u?(d=(0,Z.jsx)(A,{className:ue,icon:v,title:n.previewTitle,subtitle:n.previewHint,trailing:u}),t[9]=n.previewHint,t[10]=n.previewTitle,t[11]=u,t[12]=d):d=t[12];let p;t[13]!==a||t[14]!==n.previewEligible||t[15]!==n.previewEmpty||t[16]!==n.previewNotLoaded?(p=a?a.length>0?(0,Z.jsx)(`div`,{className:`space-y-2`,children:a.map(e=>{let t=`${e.path}:${e.startLine}-${e.endLine}`,r=e.skippedReason;return(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-2.5 py-2 shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:t}),(0,Z.jsxs)(`span`,{children:[`score=`,e.score.toFixed(3)]}),(0,Z.jsxs)(`span`,{children:[`recalls=`,e.recallCount]}),(0,Z.jsxs)(`span`,{children:[`avg=`,e.avgScore.toFixed(3)]}),(0,Z.jsxs)(`span`,{children:[`decay=`,e.recencyDecay?.toFixed(3)??`—`]}),r?(0,Z.jsx)(`span`,{className:`text-amber-600 dark:text-amber-400`,children:r}):(0,Z.jsx)(`span`,{className:`text-emerald-600 dark:text-emerald-400`,children:n.previewEligible})]}),e.snippet?(0,Z.jsx)(`div`,{className:`mt-2 text-sm text-fg`,children:e.snippet}):null]},`${e.key}:${e.hash}:${t}`)})}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.previewEmpty}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.previewNotLoaded}),t[13]=a,t[14]=n.previewEligible,t[15]=n.previewEmpty,t[16]=n.previewNotLoaded,t[17]=p):p=t[17];let m;return t[18]!==d||t[19]!==p?(m=(0,Z.jsxs)(j,{className:J,children:[d,p]}),t[18]=d,t[19]=p,t[20]=m):m=t[20],m}function je(e,t){switch(e){case 3e4:return t.every30s;case 6e4:return t.every1min;case 3e5:return t.every5min;case 6e5:return t.every10min;case 9e5:return t.every15min;case 18e5:return t.every30min;case 36e5:return t.every1h;case 72e5:return t.every2h;default:return null}}var Me={second:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`second`,unitDisplay:`long`}),minute:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`minute`,unitDisplay:`long`}),hour:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`hour`,unitDisplay:`long`})},Ne={second:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`second`,unitDisplay:`long`}),minute:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`minute`,unitDisplay:`long`}),hour:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`hour`,unitDisplay:`long`})};function Pe(e,t){return e.startsWith(`zh`)?Ne[t]:Me[t]}function Fe(e,t,n){let r=Math.max(1e3,Math.round(e));if(n&&N.has(r)){let e=je(r,n);if(e)return e}let i=Math.max(1,Math.round(r/1e3));if(i<120)return Pe(t,`second`).format(i);let a=Math.round(i/60);if(a<120)return Pe(t,`minute`).format(a);let o=Math.round(a/60);return Pe(t,`hour`).format(o)}function Ie(e){let t=(0,L.c)(12),n;t[0]!==e.expression||t[1]!==e.kind||t[2]!==e.labels||t[3]!==e.locale||t[4]!==e.nextRun||t[5]!==e.presetLabels||t[6]!==e.timezone||t[7]!==e.valueMs?(n=e.kind===`cron`?F(e.expression,e.locale,e.labels,{timezone:e.timezone,nextRun:e.nextRun}):Fe(e.valueMs,e.locale,e.presetLabels),t[0]=e.expression,t[1]=e.kind,t[2]=e.labels,t[3]=e.locale,t[4]=e.nextRun,t[5]=e.presetLabels,t[6]=e.timezone,t[7]=e.valueMs,t[8]=n):n=t[8];let r=n,i;return t[9]!==e.className||t[10]!==r?(i=(0,Z.jsx)(`span`,{className:e.className,children:r}),t[9]=e.className,t[10]=r,t[11]=i):i=t[11],i}function Le(e){let t=(0,L.c)(100),{t:n,data:r,isLoading:a,localeTag:o,scheduleBadgeLabels:s}=e,c;t[0]!==r||t[1]!==n?(c=r?pe(r.lock,n):null,t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c,u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(`min-w-0`,J),t[3]=u):u=t[3];let d;t[4]===a?d=t[5]:(d=a?(0,Z.jsx)(f,{className:`size-4 shrink-0 animate-spin text-fg-muted`,"aria-hidden":!0}):null,t[4]=a,t[5]=d);let p;t[6]!==n.runtimeHint||t[7]!==n.runtimeTitle||t[8]!==d?(p=(0,Z.jsx)(A,{className:ue,icon:y,title:n.runtimeTitle,subtitle:n.runtimeHint,trailing:d}),t[6]=n.runtimeHint,t[7]=n.runtimeTitle,t[8]=d,t[9]=p):p=t[9];let m;t[10]===n.subsectionSchedule?m=t[11]:(m=(0,Z.jsx)(ge,{label:n.subsectionSchedule,className:`mb-2`}),t[10]=n.subsectionSchedule,t[11]=m);let g=r?r.config.enabled?n.on:n.off:`—`,_;t[12]!==n.enabled||t[13]!==g?(_=(0,Z.jsx)($,{label:n.enabled,children:g}),t[12]=n.enabled,t[13]=g,t[14]=_):_=t[14];let v=l?.className,b=l?l.text:`—`,x;t[15]!==v||t[16]!==b?(x=(0,Z.jsx)(`span`,{className:v,children:b}),t[15]=v,t[16]=b,t[17]=x):x=t[17];let S;t[18]!==n.lock||t[19]!==x?(S=(0,Z.jsx)($,{label:n.lock,children:x}),t[18]=n.lock,t[19]=x,t[20]=S):S=t[20];let w=r&&r.config.timezone||`—`,T;t[21]!==n.timezone||t[22]!==w?(T=(0,Z.jsx)($,{label:n.timezone,children:w}),t[21]=n.timezone,t[22]=w,t[23]=T):T=t[23];let E;t[24]!==r||t[25]!==o||t[26]!==s?(E=r?(0,Z.jsx)(Ie,{kind:`cron`,expression:r.config.frequency,locale:o,labels:s,timezone:r.config.timezone||void 0}):`—`,t[24]=r,t[25]=o,t[26]=s,t[27]=E):E=t[27];let D;t[28]===r?D=t[29]:(D=r?.config.frequency?(0,Z.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[0.65rem] text-fg-subtle`,title:r.config.frequency,children:r.config.frequency}):null,t[28]=r,t[29]=D);let k;t[30]!==n.schedule||t[31]!==E||t[32]!==D?(k=(0,Z.jsxs)($,{label:n.schedule,className:`col-span-2 sm:col-span-2`,children:[E,D]}),t[30]=n.schedule,t[31]=E,t[32]=D,t[33]=k):k=t[33];let ee;t[34]!==S||t[35]!==T||t[36]!==k||t[37]!==_?(ee=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[_,S,T,k]}),t[34]=S,t[35]=T,t[36]=k,t[37]=_,t[38]=ee):ee=t[38];let M;t[39]!==ee||t[40]!==m?(M=(0,Z.jsxs)(`div`,{className:Y,children:[m,ee]}),t[39]=ee,t[40]=m,t[41]=M):M=t[41];let te;t[42]===n.subsectionStore?te=t[43]:(te=(0,Z.jsx)(ge,{label:n.subsectionStore,className:`mb-2`}),t[42]=n.subsectionStore,t[43]=te);let ne=r?String(r.store.entryCount):`—`,N;t[44]!==n.storeEntries||t[45]!==ne?(N=(0,Z.jsx)($,{label:n.storeEntries,children:ne}),t[44]=n.storeEntries,t[45]=ne,t[46]=N):N=t[46];let P=r?String(r.store.promotedCount):`—`,I;t[47]!==n.storePromoted||t[48]!==P?(I=(0,Z.jsx)($,{label:n.storePromoted,children:P}),t[47]=n.storePromoted,t[48]=P,t[49]=I):I=t[49];let R;t[50]===r?R=t[51]:(R=r?de(r.store.updatedAt):`—`,t[50]=r,t[51]=R);let re;t[52]!==n.storeUpdatedAt||t[53]!==R?(re=(0,Z.jsx)($,{label:n.storeUpdatedAt,children:R}),t[52]=n.storeUpdatedAt,t[53]=R,t[54]=re):re=t[54];let ie;t[55]===r?ie=t[56]:(ie=r?de(r.store.lastPromotedAt):`—`,t[55]=r,t[56]=ie);let ae;t[57]!==n.storeLastPromotedAt||t[58]!==ie?(ae=(0,Z.jsx)($,{label:n.storeLastPromotedAt,children:ie}),t[57]=n.storeLastPromotedAt,t[58]=ie,t[59]=ae):ae=t[59];let oe;t[60]!==N||t[61]!==I||t[62]!==re||t[63]!==ae?(oe=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[N,I,re,ae]}),t[60]=N,t[61]=I,t[62]=re,t[63]=ae,t[64]=oe):oe=t[64];let se;t[65]!==te||t[66]!==oe?(se=(0,Z.jsxs)(`div`,{className:Y,children:[te,oe]}),t[65]=te,t[66]=oe,t[67]=se):se=t[67];let ce;t[68]!==r||t[69]!==o||t[70]!==s||t[71]!==n?(ce=r?.config?.phases?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(ge,{label:n.subsectionPhases,className:`mb-2`}),(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[(0,Z.jsx)(ve,{icon:(0,Z.jsx)(C,{className:`size-4 text-amber-500`}),label:`Light`,enabled:r.config.phases.light.enabled,cron:r.config.phases.light.cron,scheduleSummary:F(r.config.phases.light.cron,o,s,{timezone:r.config.timezone||void 0}),details:`lookback=${r.config.phases.light.lookbackDays}d, limit=${r.config.phases.light.limit}, dedupe=${r.config.phases.light.dedupeSimilarity}`,t:n}),(0,Z.jsx)(ve,{icon:(0,Z.jsx)(O,{className:`size-4 text-indigo-500`}),label:`Deep`,enabled:r.config.phases.deep.enabled,cron:r.config.phases.deep.cron,scheduleSummary:F(r.config.phases.deep.cron,o,s,{timezone:r.config.timezone||void 0}),details:`minScore=${r.config.phases.deep.minScore}, recalls>=${r.config.phases.deep.minRecallCount}, queries>=${r.config.phases.deep.minUniqueQueries}, limit=${r.config.phases.deep.limit}, halfLife=${r.config.phases.deep.recencyHalfLifeDays}d`,t:n}),(0,Z.jsx)(ve,{icon:(0,Z.jsx)(h,{className:`size-4 text-purple-500`}),label:`REM`,enabled:r.config.phases.rem.enabled,cron:r.config.phases.rem.cron,scheduleSummary:F(r.config.phases.rem.cron,o,s,{timezone:r.config.timezone||void 0}),details:`lookback=${r.config.phases.rem.lookbackDays}d, limit=${r.config.phases.rem.limit}, strength≥${r.config.phases.rem.minPatternStrength}`,t:n})]})]}):null,t[68]=r,t[69]=o,t[70]=s,t[71]=n,t[72]=ce):ce=t[72];let z;t[73]===n.subsectionLastRun?z=t[74]:(z=(0,Z.jsx)(ge,{label:n.subsectionLastRun,className:`mb-2`}),t[73]=n.subsectionLastRun,t[74]=z);let B;t[75]===n.lastRunBlockHint?B=t[76]:(B=(0,Z.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:n.lastRunBlockHint}),t[75]=n.lastRunBlockHint,t[76]=B);let V;t[77]!==r||t[78]!==n?(V=r?.lastRun?.exists?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[r.lastRun.parseError?(0,Z.jsxs)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:[n.lastRunParseError,`: `,r.lastRun.parseError]}):null,r.lastRun.record?(0,Z.jsx)(`div`,{className:`rounded-lg bg-surface-panel/70 p-2.5 shadow-surface`,children:(0,Z.jsx)(be,{t:n,r:r.lastRun.record})}):null,r.lastRun.raw!==void 0&&r.lastRun.raw!==null?(0,Z.jsxs)(`details`,{className:`group rounded-lg bg-surface-panel/70 shadow-surface`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer list-none px-2.5 py-1.5 text-xs font-medium text-fg-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:(0,Z.jsx)(`span`,{className:`underline decoration-edge underline-offset-2 group-open:text-fg`,children:n.lastRunRaw})}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto bg-surface-base/50 p-2.5 text-xs text-fg-muted`,children:JSON.stringify(r.lastRun.raw,null,2)})]}):null]}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.lastRunEmpty}),t[77]=r,t[78]=n,t[79]=V):V=t[79];let H;t[80]!==z||t[81]!==B||t[82]!==V?(H=(0,Z.jsxs)(`div`,{className:Y,children:[z,B,V]}),t[80]=z,t[81]=B,t[82]=V,t[83]=H):H=t[83];let U=r?.lightLastRun,W;t[84]!==n||t[85]!==U?(W=(0,Z.jsx)(ye,{label:n.subsectionLightLastRun,lastRun:U,t:n}),t[84]=n,t[85]=U,t[86]=W):W=t[86];let G=r?.remLastRun,K;t[87]!==n||t[88]!==G?(K=(0,Z.jsx)(ye,{label:n.subsectionRemLastRun,lastRun:G,t:n}),t[87]=n,t[88]=G,t[89]=K):K=t[89];let q;t[90]!==M||t[91]!==se||t[92]!==ce||t[93]!==H||t[94]!==W||t[95]!==K?(q=(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[M,se,ce,H,W,K]}),t[90]=M,t[91]=se,t[92]=ce,t[93]=H,t[94]=W,t[95]=K,t[96]=q):q=t[96];let le;return t[97]!==q||t[98]!==p?(le=(0,Z.jsxs)(j,{className:u,children:[p,q]}),t[97]=q,t[98]=p,t[99]=le):le=t[99],le}var Re=[`config`,`runtime`,`insights`,`maintenance`],ze={config:_,runtime:y,insights:v,maintenance:w};function Be(e){return e&&Re.includes(e)?e:`config`}function Ve(e,t){return t===`config`?e.tabConfig:t===`runtime`?e.tabRuntime:t===`insights`?e.tabInsights:e.tabMaintenance}function He(e,t){return t===`config`?e.configTabHint:t===`runtime`?e.runtimeTabHint:t===`insights`?e.insightsTabHint:e.maintenanceTabHint}function Ue(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:return{form:t.value,baseline:t.value};case`set`:return{...e,form:t.value};case`saved`:return{form:t.value,baseline:t.value}}}var We={actionBusy:null,actionError:null,actionOk:!1,runBusy:!1,runOk:!1,runError:null,runPhase:`deep`,cfgSaving:!1,cfgOk:!1,cfgError:null,enableAllBusy:!1,previewLoading:!1,previewError:null,previewItems:null,eventsLoading:!1,eventsError:null,events:null},Ge=900;function Ke(){return typeof window>`u`||typeof window.requestAnimationFrame!=`function`?new Promise(e=>setTimeout(e,0)):new Promise(e=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>e())})})}function qe(e,t){typeof window>`u`||window.dispatchEvent(new CustomEvent(e,{detail:t}))}function Je(){let e=o(e=>e.language),t=a(e),n=t.dreamingSettings,r=t.cron.schedulePicker,i=t.cron.scheduleBadge,c=e===`zh`?`zh-CN`:`en-US`,l=!!s(e=>e.token),[d,f]=b(),p=Be(d.get(`tab`)),m=d.get(`agentId`)?.trim()||``,h=(0,I.useCallback)(e=>{f(t=>{let n=new URLSearchParams(t);return e===`config`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[f]),[_,v]=(0,I.useReducer)(g,We),{actionBusy:y,actionError:x,runBusy:C,runError:w,runPhase:T,cfgSaving:E,cfgError:D,enableAllBusy:O,previewLoading:k,previewError:A,previewItems:j,eventsLoading:ee,eventsError:M,events:te}=_,[N,P]=(0,I.useReducer)(Ue,{form:null,baseline:null}),F=N.form,L=N.baseline,R=(0,I.useRef)(!1),z=u(l?`dreaming-settings-agents`:null,S,{revalidateOnFocus:!1}),B=z.data?.agents??[],V=m||z.data?.defaultId||``,H=(0,I.useMemo)(()=>B.find(e=>e.id===V),[B,V]),U=(0,I.useCallback)(e=>{R.current=!1,P({type:`reset`}),f(t=>{let n=new URLSearchParams(t);return e?n.set(`agentId`,e):n.delete(`agentId`),n},{replace:!0})},[f]),{data:W,error:G,isLoading:K,mutate:J}=u(l&&V?re(V):null,ie,{revalidateOnFocus:!1}),ue=(0,I.useMemo)(()=>{let e=[];return G&&e.push(G instanceof Error?G.message:String(G)),x&&e.push(x),w&&e.push(w),A&&e.push(A),M&&e.push(M),D&&e.push(D),e},[G,x,w,A,M,D]),Y=(0,I.useCallback)(async()=>{v({type:`patch`,patch:{actionOk:!1,actionError:null,runOk:!1,runError:null,cfgOk:!1,cfgError:null,previewError:null}}),await J()},[J]),X=(0,I.useCallback)(async()=>{v({type:`patch`,patch:{previewLoading:!0,previewError:null}});try{v({type:`patch`,patch:{previewItems:(await se(20,V)).items??[]}})}catch(e){v({type:`patch`,patch:{previewError:e instanceof Error?e.message:String(e)}})}finally{v({type:`patch`,patch:{previewLoading:!1}})}},[V]),de=(0,I.useCallback)(async()=>{v({type:`patch`,patch:{eventsLoading:!0,eventsError:null}});try{v({type:`patch`,patch:{events:await ce(50,V)}})}catch(e){v({type:`patch`,patch:{eventsError:e instanceof Error?e.message:String(e)}})}finally{v({type:`patch`,patch:{eventsLoading:!1}})}},[V]),fe=(0,I.useCallback)(async(e=`deep`)=>{let t=Date.now(),n=B.length>0?B.map(e=>({id:e.id,name:e.name,avatar:e.avatar})):[{id:V,name:H?.name,avatar:H?.avatar}].filter(e=>e.id),r=n.length>0?n:[{id:V}],i=[];v({type:`patch`,patch:{runPhase:e,runBusy:!0,runOk:!1,runError:null}});try{let t=r.map(t=>{let n={phase:e,...t.id?{agentId:t.id}:{},...t.name?{agentName:t.name}:{},...t.avatar?{avatar:t.avatar}:{}};return qe(`dreaming-phase-start`,n),{target:t,detail:n}}).map(async({target:t,detail:n})=>{await Ke();try{await oe(e,t.id||V)}catch(e){let n=t.name||t.id||V||`default`,r=e instanceof Error?e.message:String(e);i.push(`${n}: ${r}`)}finally{qe(`dreaming-phase-end`,n)}});await Promise.all(t),v({type:`patch`,patch:i.length>0?{runError:i.join(`
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-C22hxE1N.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s,i as c,n as l}from"./fetch-5V96dUz3.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{Ao as d,Ds as f,Go as p,Os as m,Ro as h,To as g,Tt as _,Us as v,Xo as y,co as b,cs as x,er as S,es as C,fl as w,fo as T,ho as E,na as D,ol as O,ys as k}from"./index-CA2tR2vm.js";import{n as A,t as j}from"./settings-form-section-BmyfthNQ.js";import{t as ee}from"./page-tabs-Cp395RYD.js";import{n as M,r as te,t as ne}from"./settings-page-layout-Bls5tfbH.js";import{n as N,t as P}from"./schedule-field-BQ8IjjCn.js";import{t as F}from"./format-cron-label-arqgGlVV.js";var I=e(t(),1),L=n();function R(e,t){let n=new URLSearchParams;e&&n.set(`agentId`,e);for(let[e,r]of Object.entries(t??{}))r!==void 0&&n.set(e,String(r));let r=n.toString();return r?`?${r}`:``}function re(e){return c(`/api/dreaming${R(e)}`)}async function ie(e){let t=await l(e?.startsWith(`/api/`)||e?.includes(`/api/dreaming`)?e:re(e));if(!t.payload)throw Error(`Missing payload`);return t.payload}async function ae(e,t){await l(c(`/api/dreaming/action`),{method:`POST`,body:JSON.stringify({action:e,agentId:t})})}async function oe(e=`deep`,t){let n=await l(c(`/api/dreaming/run`),{method:`POST`,body:JSON.stringify({phase:e,agentId:t})});if(n.ok===!1||!n.payload)throw Error(`Failed to run dreaming phase`);let r=n.payload.phase;return{agentId:typeof n.payload.agentId==`string`?n.payload.agentId:void 0,phase:r===`light`||r===`deep`||r===`rem`?r:e,result:n.payload.result}}async function se(e,t){let n=await l(c(`/api/dreaming/preview${R(t,typeof e==`number`&&Number.isFinite(e)?{limit:e}:void 0)}`));if(!n.payload)throw Error(`Missing payload`);return n.payload}async function ce(e=50,t){return(await l(c(`/api/dreaming/events${R(t,{limit:e})}`))).payload?.events??[]}function z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var B={enabled:!0,cron:`0 */6 * * *`,lookbackDays:1,limit:50,dedupeSimilarity:.85},V={enabled:!0,cron:`0 3 * * *`,minScore:.8,minRecallCount:3,minUniqueQueries:3,limit:10,recencyHalfLifeDays:14,maxAgeDays:30},H={enabled:!0,cron:`0 5 * * 0`,lookbackDays:7,limit:20,minPatternStrength:.6},U={enabled:!1,frequency:`0 3 * * *`,timezone:``,deepEnabled:!0,minScore:.8,minRecallCount:3,limit:10,light:B,deep:V,rem:H};function W(e,t){return Number.isFinite(e)?Math.max(0,Math.min(1,e)):t}function G(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?Math.max(0,Math.floor(n)):t}function K(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?n:t}function q(e){let t=z(e)?e:{},n=z(t.memory)?t.memory:{},r=z(t.dreaming)?t.dreaming:{},i=typeof t.enabled==`boolean`||typeof t.frequency==`string`||z(t.phases)?t:{},a=z(n.dreaming)?n.dreaming:Object.keys(r).length>0?r:i,o=z(a.phases)?a.phases:{},s=z(o.light)?o.light:{},c=z(o.deep)?o.deep:{},l=z(o.rem)?o.rem:{};return{enabled:a.enabled===!0,frequency:typeof a.frequency==`string`&&a.frequency.trim()?a.frequency.trim():U.frequency,timezone:typeof a.timezone==`string`?a.timezone:``,deepEnabled:c.enabled!==!1,minScore:W(typeof c.minScore==`number`?c.minScore:Number(c.minScore),U.minScore),minRecallCount:Math.max(1,G(c.minRecallCount,U.minRecallCount)),limit:G(c.limit,U.limit),light:{enabled:s.enabled!==!1,cron:typeof s.cron==`string`&&s.cron.trim()?s.cron.trim():B.cron,lookbackDays:Math.max(1,G(s.lookbackDays,B.lookbackDays)),limit:G(s.limit,B.limit),dedupeSimilarity:W(K(s.dedupeSimilarity,B.dedupeSimilarity),B.dedupeSimilarity)},deep:{enabled:c.enabled!==!1,cron:typeof c.cron==`string`&&c.cron.trim()?c.cron.trim():V.cron,minScore:W(K(c.minScore,V.minScore),V.minScore),minRecallCount:Math.max(1,G(c.minRecallCount,V.minRecallCount)),minUniqueQueries:Math.max(1,G(c.minUniqueQueries,V.minUniqueQueries)),limit:G(c.limit,V.limit),recencyHalfLifeDays:Math.max(1,K(c.recencyHalfLifeDays,V.recencyHalfLifeDays)),maxAgeDays:Math.max(1,K(c.maxAgeDays,V.maxAgeDays))},rem:{enabled:l.enabled!==!1,cron:typeof l.cron==`string`&&l.cron.trim()?l.cron.trim():H.cron,lookbackDays:Math.max(1,G(l.lookbackDays,H.lookbackDays)),limit:G(l.limit,H.limit),minPatternStrength:W(K(l.minPatternStrength,H.minPatternStrength),H.minPatternStrength)}}}async function le(e,t,n){let r=t.frequency.trim(),i=t.timezone.trim();await l(c(`/api/agents/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({memory:{...n??{},mode:t.enabled?`confirmWrite`:typeof n?.mode==`string`?n.mode:`off`,sources:Array.isArray(n?.sources)?n.sources:[`session`,`curated`,`workspace`],writePolicy:z(n?.writePolicy)?n.writePolicy:{curated:`confirm`,workspace:`confirm`},dreaming:{enabled:!!t.enabled,...r?{frequency:r}:{},...i?{timezone:i}:{},phases:{light:{enabled:!!t.light.enabled,...t.light.cron.trim()?{cron:t.light.cron.trim()}:{},lookbackDays:Math.max(1,Math.floor(t.light.lookbackDays)),limit:Math.max(0,Math.floor(t.light.limit)),dedupeSimilarity:W(t.light.dedupeSimilarity,B.dedupeSimilarity)},deep:{enabled:!!t.deep.enabled,...t.deep.cron.trim()?{cron:t.deep.cron.trim()}:{},minScore:W(t.deep.minScore,V.minScore),minRecallCount:Math.max(1,Math.floor(t.deep.minRecallCount)),minUniqueQueries:Math.max(1,Math.floor(t.deep.minUniqueQueries)),limit:Math.max(0,Math.floor(t.deep.limit)),recencyHalfLifeDays:Math.max(1,t.deep.recencyHalfLifeDays),maxAgeDays:Math.max(1,t.deep.maxAgeDays)},rem:{enabled:!!t.rem.enabled,...t.rem.cron.trim()?{cron:t.rem.cron.trim()}:{},lookbackDays:Math.max(1,Math.floor(t.rem.lookbackDays)),limit:Math.max(0,Math.floor(t.rem.limit)),minPatternStrength:W(t.rem.minPatternStrength,H.minPatternStrength)}}}}})}),D()}var J=`p-4 sm:px-5`,ue=`mb-3`,Y=`rounded-xl bg-surface-panel/60 p-3 shadow-surface sm:p-4`,X=i(`mt-1 w-full rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm text-fg`,b);function de(e){return e?e.replace(`T`,` `).replace(`Z`,``):`—`}function fe(e){return e===void 0||!Number.isFinite(e)||e<0?`—`:e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(2)} s`}function pe(e,t){return e.locked?{text:t.lockValueLocked,className:`text-amber-600 dark:text-amber-400`}:{text:t.lockValueUnlocked,className:`text-emerald-600 dark:text-emerald-400`}}var Z=r(),me=`text-xs font-medium text-fg-muted`,he=`text-sm font-medium text-fg`;function Q(e){let t=(0,L.c)(6),{label:n,children:r,className:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`span`,{className:me,children:n}),t[0]=n,t[1]=a);let o;return t[2]!==r||t[3]!==i||t[4]!==a?(o=(0,Z.jsxs)(`div`,{className:i,children:[a,r]}),t[2]=r,t[3]=i,t[4]=a,t[5]=o):o=t[5],o}function $(e){let t=(0,L.c)(11),{label:n,children:r,className:a}=e,o;t[0]===a?o=t[1]:(o=i(`min-w-0`,a),t[0]=a,t[1]=o);let s;t[2]===n?s=t[3]:(s=(0,Z.jsx)(`dt`,{className:me,children:n}),t[2]=n,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=i(he,`mt-0.5`),t[4]=c):c=t[4];let l;t[5]===r?l=t[6]:(l=(0,Z.jsx)(`dd`,{className:c,children:r}),t[5]=r,t[6]=l);let u;return t[7]!==o||t[8]!==s||t[9]!==l?(u=(0,Z.jsxs)(`div`,{className:o,children:[s,l]}),t[7]=o,t[8]=s,t[9]=l,t[10]=u):u=t[10],u}function ge(e){let t=(0,L.c)(5),{label:n,className:r}=e,a;t[0]===r?a=t[1]:(a=i(`text-[0.7rem] font-semibold uppercase tracking-wider text-fg-muted`,r),t[0]=r,t[1]=a);let o;return t[2]!==n||t[3]!==a?(o=(0,Z.jsx)(`h3`,{className:a,children:n}),t[2]=n,t[3]=a,t[4]=o):o=t[4],o}function _e(e){let t=(0,L.c)(39),{icon:n,title:r,hint:i,enabled:a,onEnabledChange:o,cron:s,onCronChange:c,scheduleLabels:l,disabled:u,showEnabledControl:d,actions:f,status:p,enabledLabel:m,onLabel:h,offLabel:g,cronLabel:_,children:v}=e,y=d===void 0?!0:d,b;t[0]===n?b=t[1]:(b=(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:n}),t[0]=n,t[1]=b);let x;t[2]===r?x=t[3]:(x=(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=x);let S;t[4]!==p||t[5]!==x?(S=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[x,p]}),t[4]=p,t[5]=x,t[6]=S):S=t[6];let C;t[7]===i?C=t[8]:(C=(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs leading-snug text-fg-muted`,children:i}),t[7]=i,t[8]=C);let w;t[9]!==S||t[10]!==C?(w=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[S,C]}),t[9]=S,t[10]=C,t[11]=w):w=t[11];let T;t[12]!==b||t[13]!==w?(T=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[b,w]}),t[12]=b,t[13]=w,t[14]=T):T=t[14];let E;t[15]!==f||t[16]!==u||t[17]!==a||t[18]!==m||t[19]!==g||t[20]!==o||t[21]!==h||t[22]!==y?(E=f||y?(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[f,y?(0,Z.jsxs)(`label`,{className:`inline-flex shrink-0 items-center gap-2 text-xs text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:a,disabled:u,onChange:e=>o(e.target.checked)}),(0,Z.jsx)(`span`,{children:m??(a?h:g)})]}):null]}):null,t[15]=f,t[16]=u,t[17]=a,t[18]=m,t[19]=g,t[20]=o,t[21]=h,t[22]=y,t[23]=E):E=t[23];let D;t[24]!==T||t[25]!==E?(D=(0,Z.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-start justify-between gap-2 rounded-lg bg-surface-base/45 px-3 py-2.5`,children:[T,E]}),t[24]=T,t[25]=E,t[26]=D):D=t[26];let O;t[27]!==s||t[28]!==_||t[29]!==u||t[30]!==c||t[31]!==l?(O=(0,Z.jsx)(P,{kind:`cron`,className:`mb-2.5`,label:_,value:s,onChange:c,labels:l,disabled:u}),t[27]=s,t[28]=_,t[29]=u,t[30]=c,t[31]=l,t[32]=O):O=t[32];let k;t[33]===v?k=t[34]:(k=(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4`,children:v}),t[33]=v,t[34]=k);let A;return t[35]!==O||t[36]!==k||t[37]!==D?(A=(0,Z.jsxs)(`div`,{className:Y,children:[D,O,k]}),t[35]=O,t[36]=k,t[37]=D,t[38]=A):A=t[38],A}function ve(e){let t=(0,L.c)(23),{icon:n,label:r,enabled:a,cron:o,scheduleSummary:s,details:c,t:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(Y,`space-y-1`),t[0]=u):u=t[0];let d;t[1]===r?d=t[2]:(d=(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r}),t[1]=r,t[2]=d);let f=a?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`,p;t[3]===f?p=t[4]:(p=i(`ml-auto text-xs font-medium`,f),t[3]=f,t[4]=p);let m=a?l.on:l.off,h;t[5]!==p||t[6]!==m?(h=(0,Z.jsx)(`span`,{className:p,children:m}),t[5]=p,t[6]=m,t[7]=h):h=t[7];let g;t[8]!==n||t[9]!==d||t[10]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n,d,h]}),t[8]=n,t[9]=d,t[10]=h,t[11]=g):g=t[11];let _;t[12]===s?_=t[13]:(_=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:s}),t[12]=s,t[13]=_);let v;t[14]===o?v=t[15]:(v=(0,Z.jsx)(`p`,{className:`truncate font-mono text-[0.65rem] text-fg-subtle`,title:o,children:o}),t[14]=o,t[15]=v);let y;t[16]===c?y=t[17]:(y=(0,Z.jsx)(`p`,{className:`text-[0.65rem] leading-snug text-fg-muted`,children:c}),t[16]=c,t[17]=y);let b;return t[18]!==y||t[19]!==g||t[20]!==_||t[21]!==v?(b=(0,Z.jsxs)(`div`,{className:u,children:[g,_,v,y]}),t[18]=y,t[19]=g,t[20]=_,t[21]=v,t[22]=b):b=t[22],b}function ye(e){let t=(0,L.c)(9),{label:n,lastRun:r,t:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(ge,{label:n,className:`mb-2`}),t[0]=n,t[1]=a);let o;t[2]!==r||t[3]!==i.lastRunRaw||t[4]!==i.phaseLastRunEmpty?(o=r?.exists?(0,Z.jsxs)(`details`,{className:`group rounded-lg bg-surface-panel/70 shadow-surface`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer list-none px-2.5 py-1.5 text-xs font-medium text-fg-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:(0,Z.jsx)(`span`,{className:`underline decoration-edge underline-offset-2 group-open:text-fg`,children:i.lastRunRaw})}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto bg-surface-base/50 p-2.5 text-xs text-fg-muted`,children:JSON.stringify(r.raw,null,2)})]}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.phaseLastRunEmpty}),t[2]=r,t[3]=i.lastRunRaw,t[4]=i.phaseLastRunEmpty,t[5]=o):o=t[5];let s;return t[6]!==a||t[7]!==o?(s=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-base/45 p-3`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8],s}function be(e){let t=(0,L.c)(39),{t:n,r}=e,i=r.deep?.skipped,a=r.ok?`text-emerald-600 dark:text-emerald-400`:`text-amber-600 dark:text-amber-400`,o=r.ok?n.lastRunSuccess:n.lastRunFailure,s;t[0]!==a||t[1]!==o?(s=(0,Z.jsx)(`span`,{className:a,children:o}),t[0]=a,t[1]=o,t[2]=s):s=t[2];let c;t[3]!==n.lastRunStatus||t[4]!==s?(c=(0,Z.jsx)($,{label:n.lastRunStatus,children:s}),t[3]=n.lastRunStatus,t[4]=s,t[5]=c):c=t[5];let l=n.lastRunDuration,u;t[6]===r.durationMs?u=t[7]:(u=fe(r.durationMs),t[6]=r.durationMs,t[7]=u);let d;t[8]!==n.lastRunDuration||t[9]!==u?(d=(0,Z.jsx)($,{label:l,children:u}),t[8]=n.lastRunDuration,t[9]=u,t[10]=d):d=t[10];let f=n.lastRunRanked,p=String(r.deep?.candidatesRanked??`—`),m;t[11]!==n.lastRunRanked||t[12]!==p?(m=(0,Z.jsx)($,{label:f,children:p}),t[11]=n.lastRunRanked,t[12]=p,t[13]=m):m=t[13];let h=n.lastRunApplied,g=String(r.deep?.applied??`—`),_;t[14]!==n.lastRunApplied||t[15]!==g?(_=(0,Z.jsx)($,{label:h,children:g}),t[14]=n.lastRunApplied,t[15]=g,t[16]=_):_=t[16];let v;t[17]===r.reason?v=t[18]:(v=(0,Z.jsx)(`span`,{className:`block text-pretty`,children:r.reason}),t[17]=r.reason,t[18]=v);let y;t[19]!==r.errorMessage||t[20]!==n.lastRunError?(y=r.errorMessage?(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-amber-600 dark:text-amber-400`,children:`${n.lastRunError}: ${r.errorMessage}`}):null,t[19]=r.errorMessage,t[20]=n.lastRunError,t[21]=y):y=t[21];let b;t[22]!==n.lastRunReason||t[23]!==v||t[24]!==y?(b=(0,Z.jsxs)($,{label:n.lastRunReason,className:`col-span-2 sm:col-span-3 lg:col-span-4`,children:[v,y]}),t[22]=n.lastRunReason,t[23]=v,t[24]=y,t[25]=b):b=t[25];let x;t[26]!==i||t[27]!==n.lastRunSkipContaminated||t[28]!==n.lastRunSkipHash||t[29]!==n.lastRunSkipKey||t[30]!==n.lastRunSkipRehydrate?(x=i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:n.lastRunSkipKey,children:String(i.alreadyPromotedKey)}),(0,Z.jsx)($,{label:n.lastRunSkipRehydrate,children:String(i.rehydrateFailed)}),(0,Z.jsx)($,{label:n.lastRunSkipContaminated,children:String(i.contaminated)}),(0,Z.jsx)($,{label:n.lastRunSkipHash,children:String(i.hashDuplicate)})]}):null,t[26]=i,t[27]=n.lastRunSkipContaminated,t[28]=n.lastRunSkipHash,t[29]=n.lastRunSkipKey,t[30]=n.lastRunSkipRehydrate,t[31]=x):x=t[31];let S;return t[32]!==m||t[33]!==_||t[34]!==b||t[35]!==x||t[36]!==c||t[37]!==d?(S=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-3 lg:grid-cols-4`,children:[c,d,m,_,b,x]}),t[32]=m,t[33]=_,t[34]=b,t[35]=x,t[36]=c,t[37]=d,t[38]=S):S=t[38],S}function xe(e){let t=(0,L.c)(56),{t:n,schedulePickerLabels:r,hasToken:a,cfgForm:o,cfgBaseline:s,cfgDirty:c,cfgSaving:l,runPhase:u,runBusy:f,setCfgForm:p,doRunNow:m}=e,g;t[0]!==c||t[1]!==o?.enabled||t[2]!==l||t[3]!==m||t[4]!==a||t[5]!==f||t[6]!==u||t[7]!==n?(g=(e,t)=>o?.enabled?(0,Z.jsx)(we,{t:n,busy:f&&u===e,disabled:!a||l||f||!t||c,title:c?n.runNowSaveFirstHint:n.runNowHint,onClick:()=>{m(e)}}):null,t[0]=c,t[1]=o?.enabled,t[2]=l,t[3]=m,t[4]=a,t[5]=f,t[6]=u,t[7]=n,t[8]=g):g=t[8];let _=g,y;t[9]!==s||t[10]!==o||t[11]!==n.phasePendingSave||t[12]!==n.phaseWillDisable||t[13]!==n.phaseWillEnable?(y=e=>{if(!o||!s)return null;let t=o[e],r=s[e];return JSON.stringify(t)===JSON.stringify(r)?null:t.enabled===r.enabled?n.phasePendingSave:t.enabled?n.phaseWillEnable:n.phaseWillDisable},t[9]=s,t[10]=o,t[11]=n.phasePendingSave,t[12]=n.phaseWillDisable,t[13]=n.phaseWillEnable,t[14]=y):y=t[14];let b=y,x;return t[15]!==c||t[16]!==o||t[17]!==l||t[18]!==a||t[19]!==b||t[20]!==_||t[21]!==r||t[22]!==p||t[23]!==n.configDeepHalfLife||t[24]!==n.configDeepLimit||t[25]!==n.configDeepMaxAge||t[26]!==n.configDeepMinRecallCount||t[27]!==n.configDeepMinScore||t[28]!==n.configDeepMinUniqueQueries||t[29]!==n.configFrequency||t[30]!==n.configLightDedupe||t[31]!==n.configLightLimit||t[32]!==n.configLightLookbackDays||t[33]!==n.configLoading||t[34]!==n.configPhaseCron||t[35]!==n.configPhaseDeep||t[36]!==n.configPhaseDeepHint||t[37]!==n.configPhaseLight||t[38]!==n.configPhaseLightHint||t[39]!==n.configPhaseRem||t[40]!==n.configPhaseRemHint||t[41]!==n.configRemLimit||t[42]!==n.configRemLookbackDays||t[43]!==n.configRemMinStrength||t[44]!==n.configTimezone||t[45]!==n.masterHint||t[46]!==n.masterOff||t[47]!==n.masterOn||t[48]!==n.masterTitle||t[49]!==n.off||t[50]!==n.on||t[51]!==n.phasesTitle||t[52]!==n.scheduleTitle||t[53]!==n.unsavedConfigHint||t[54]!==n.unsavedConfigTitle?(x=(0,Z.jsx)(j,{className:`min-w-0 !p-0`,children:o?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:i(Y,`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`),children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.masterTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.masterHint})]}),(0,Z.jsxs)(`label`,{className:i(`inline-flex w-fit cursor-pointer items-center gap-2 rounded-xl border px-3 py-1.5 text-sm transition-colors`,o.enabled?`border-emerald-500/30 bg-emerald-500/5 text-fg`:`border-edge-subtle bg-surface-panel/50 text-fg-muted`),children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:o.enabled,disabled:!a||l,onChange:e=>p(t=>t&&{...t,enabled:e.target.checked})}),(0,Z.jsx)(`span`,{className:i(`text-xs font-semibold`,o.enabled?`text-emerald-600 dark:text-emerald-400`:``),children:o.enabled?n.masterOn:n.masterOff})]})]}),c?(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-xs text-amber-900 dark:text-amber-100`,children:[(0,Z.jsx)(v,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":!0}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`font-semibold`,children:n.unsavedConfigTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 leading-snug text-amber-800/90 dark:text-amber-100/80`,children:n.unsavedConfigHint})]})]}):null,(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(Se,{title:n.scheduleTitle}),(0,Z.jsx)(`div`,{className:Y,children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 lg:grid-cols-12`,children:[(0,Z.jsx)(`div`,{className:`lg:col-span-9`,children:(0,Z.jsx)(P,{kind:`cron`,label:n.configFrequency,value:o.frequency,onChange:e=>p(t=>t&&{...t,frequency:e}),labels:r,disabled:!a||l})}),(0,Z.jsx)(Q,{label:n.configTimezone,className:`lg:col-span-3`,children:(0,Z.jsx)(`input`,{className:X,value:o.timezone,disabled:!a||l,onChange:e=>p(t=>t&&{...t,timezone:e.target.value}),placeholder:`Asia/Shanghai`})})]})})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(Se,{title:n.phasesTitle}),(0,Z.jsxs)(_e,{icon:(0,Z.jsx)(d,{className:`size-4 text-amber-500`}),title:n.configPhaseLight,hint:n.configPhaseLightHint,enabled:o.light.enabled,onEnabledChange:e=>p(t=>t&&{...t,light:{...t.light,enabled:e}}),cron:o.light.cron,onCronChange:e=>p(t=>t&&{...t,light:{...t.light,cron:e}}),scheduleLabels:r,disabled:!a||l,showEnabledControl:o.enabled,actions:_(`light`,o.light.enabled),status:b(`light`)?(0,Z.jsx)(Ce,{label:b(`light`)??``}):null,enabledLabel:b(`light`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configLightLookbackDays,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.light.lookbackDays,disabled:!a||l,onChange:e=>p(t=>t&&{...t,light:{...t.light,lookbackDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configLightLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:X,value:o.light.limit,disabled:!a||l,onChange:e=>p(t=>t&&{...t,light:{...t.light,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configLightDedupe,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:X,value:o.light.dedupeSimilarity,disabled:!a||l,onChange:e=>p(t=>t&&{...t,light:{...t.light,dedupeSimilarity:Number(e.target.value)}})})})]}),(0,Z.jsxs)(_e,{icon:(0,Z.jsx)(k,{className:`size-4 text-indigo-500`}),title:n.configPhaseDeep,hint:n.configPhaseDeepHint,enabled:o.deep.enabled,onEnabledChange:e=>p(t=>t&&{...t,deep:{...t.deep,enabled:e}}),cron:o.deep.cron,onCronChange:e=>p(t=>t&&{...t,deep:{...t.deep,cron:e}}),scheduleLabels:r,disabled:!a||l,showEnabledControl:o.enabled,actions:_(`deep`,o.deep.enabled),status:b(`deep`)?(0,Z.jsx)(Ce,{label:b(`deep`)??``}):null,enabledLabel:b(`deep`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configDeepMinScore,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:X,value:o.deep.minScore,disabled:!a||l,onChange:e=>p(t=>t&&{...t,deep:{...t.deep,minScore:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMinRecallCount,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.minRecallCount,disabled:!a||l,onChange:e=>p(t=>t&&{...t,deep:{...t.deep,minRecallCount:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMinUniqueQueries,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.minUniqueQueries,disabled:!a||l,onChange:e=>p(t=>t&&{...t,deep:{...t.deep,minUniqueQueries:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:X,value:o.deep.limit,disabled:!a||l,onChange:e=>p(t=>t&&{...t,deep:{...t.deep,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepHalfLife,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.recencyHalfLifeDays,disabled:!a||l,onChange:e=>p(t=>t&&{...t,deep:{...t.deep,recencyHalfLifeDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMaxAge,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.maxAgeDays,disabled:!a||l,onChange:e=>p(t=>t&&{...t,deep:{...t.deep,maxAgeDays:Number(e.target.value)}})})})]}),(0,Z.jsxs)(_e,{icon:(0,Z.jsx)(h,{className:`size-4 text-purple-500`}),title:n.configPhaseRem,hint:n.configPhaseRemHint,enabled:o.rem.enabled,onEnabledChange:e=>p(t=>t&&{...t,rem:{...t.rem,enabled:e}}),cron:o.rem.cron,onCronChange:e=>p(t=>t&&{...t,rem:{...t.rem,cron:e}}),scheduleLabels:r,disabled:!a||l,showEnabledControl:o.enabled,actions:_(`rem`,o.rem.enabled),status:b(`rem`)?(0,Z.jsx)(Ce,{label:b(`rem`)??``}):null,enabledLabel:b(`rem`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configRemLookbackDays,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.rem.lookbackDays,disabled:!a||l,onChange:e=>p(t=>t&&{...t,rem:{...t.rem,lookbackDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configRemLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:X,value:o.rem.limit,disabled:!a||l,onChange:e=>p(t=>t&&{...t,rem:{...t.rem,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configRemMinStrength,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:X,value:o.rem.minPatternStrength,disabled:!a||l,onChange:e=>p(t=>t&&{...t,rem:{...t.rem,minPatternStrength:Number(e.target.value)}})})})]})]})]}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.configLoading})}),t[15]=c,t[16]=o,t[17]=l,t[18]=a,t[19]=b,t[20]=_,t[21]=r,t[22]=p,t[23]=n.configDeepHalfLife,t[24]=n.configDeepLimit,t[25]=n.configDeepMaxAge,t[26]=n.configDeepMinRecallCount,t[27]=n.configDeepMinScore,t[28]=n.configDeepMinUniqueQueries,t[29]=n.configFrequency,t[30]=n.configLightDedupe,t[31]=n.configLightLimit,t[32]=n.configLightLookbackDays,t[33]=n.configLoading,t[34]=n.configPhaseCron,t[35]=n.configPhaseDeep,t[36]=n.configPhaseDeepHint,t[37]=n.configPhaseLight,t[38]=n.configPhaseLightHint,t[39]=n.configPhaseRem,t[40]=n.configPhaseRemHint,t[41]=n.configRemLimit,t[42]=n.configRemLookbackDays,t[43]=n.configRemMinStrength,t[44]=n.configTimezone,t[45]=n.masterHint,t[46]=n.masterOff,t[47]=n.masterOn,t[48]=n.masterTitle,t[49]=n.off,t[50]=n.on,t[51]=n.phasesTitle,t[52]=n.scheduleTitle,t[53]=n.unsavedConfigHint,t[54]=n.unsavedConfigTitle,t[55]=x):x=t[55],x}function Se(e){let t=(0,L.c)(2),{title:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`px-0.5 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:n}),t[0]=n,t[1]=r),r}function Ce(e){let t=(0,L.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`span`,{className:`inline-flex shrink-0 rounded-md border border-amber-500/25 bg-amber-500/10 px-1.5 py-0.5 text-[0.65rem] font-semibold text-amber-800 dark:text-amber-200`,children:n}),t[0]=n,t[1]=r),r}function we(e){let t=(0,L.c)(8),{t:n,busy:r,disabled:i,title:a,onClick:o}=e,s;t[0]===r?s=t[1]:(s=r?(0,Z.jsx)(m,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(x,{className:`size-3.5`,"aria-hidden":!0}),t[0]=r,t[1]=s);let c;return t[2]!==i||t[3]!==o||t[4]!==n.runNow||t[5]!==s||t[6]!==a?(c=(0,Z.jsxs)(T,{type:`button`,variant:`secondary`,className:`h-7 gap-1.5 rounded-lg px-2 text-xs`,disabled:i,title:a,onClick:o,children:[s,n.runNow]}),t[2]=i,t[3]=o,t[4]=n.runNow,t[5]=s,t[6]=a,t[7]=c):c=t[7],c}function Te(e){let t=(0,L.c)(20),{t:n,hasToken:r,eventsLoading:i,events:a,loadEvents:o}=e,s=!r||i,c;t[0]===o?c=t[1]:(c=()=>void o(),t[0]=o,t[1]=c);let l;t[2]===i?l=t[3]:(l=i?(0,Z.jsx)(m,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=i,t[3]=l);let u;t[4]!==n.eventsLoad||t[5]!==s||t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(T,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:s,onClick:c,children:[l,n.eventsLoad]}),t[4]=n.eventsLoad,t[5]=s,t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]!==n.eventsHint||t[10]!==n.eventsTitle||t[11]!==u?(d=(0,Z.jsx)(A,{className:ue,icon:O,title:n.eventsTitle,subtitle:n.eventsHint,trailing:u}),t[9]=n.eventsHint,t[10]=n.eventsTitle,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==a||t[14]!==n.eventsEmpty||t[15]!==n.eventsNotLoaded?(f=a?a.length>0?(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:a.map(Ee)}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.eventsEmpty}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.eventsNotLoaded}),t[13]=a,t[14]=n.eventsEmpty,t[15]=n.eventsNotLoaded,t[16]=f):f=t[16];let p;return t[17]!==d||t[18]!==f?(p=(0,Z.jsxs)(j,{className:J,children:[d,f]}),t[17]=d,t[18]=f,t[19]=p):p=t[19],p}function Ee(e){let t=e.phase===`light`?`☀️`:e.phase===`rem`?`✨`:`🌙`,n=e.phase===`light`?`scanned=${e.scannedEntries??0} new=${e.newSignals??0} deduped=${e.deduped??0}`:e.phase===`rem`?`patterns=${e.patternsDiscovered??0} analyzed=${e.entriesAnalyzed??0}`:`candidates=${e.candidates??0} applied=${e.applied??0}`;return(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 rounded-lg bg-surface-panel/70 px-3 py-2 text-xs shadow-surface`,children:[(0,Z.jsx)(`span`,{children:t}),(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:e.phase}),(0,Z.jsx)(`span`,{className:i(`font-medium`,e.ok?`text-emerald-600 dark:text-emerald-400`:`text-amber-600 dark:text-amber-400`),children:e.ok?`OK`:`FAIL`}),(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:n}),(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:fe(e.durationMs)}),(0,Z.jsx)(`span`,{className:`ml-auto text-fg-subtle`,children:de(e.timestamp)})]},`${e.timestamp}:${e.phase}`)}function De(e){let t=(0,L.c)(40),{t:n,hasToken:r,agents:i,selectedAgentId:a,onAgentChange:o,cfgForm:s,cfgSaving:c,enableAllBusy:l,cfgDirty:u,saveConfig:d,enableAllAgentsDreaming:f,doRefresh:p}=e,h;t[0]!==i||t[1]!==c||t[2]!==r||t[3]!==o||t[4]!==a?(h=i.length>0?(0,Z.jsx)(`select`,{className:`h-9 max-w-44 rounded-md border border-edge bg-surface-panel px-2 text-sm text-fg outline-none transition focus:border-accent`,value:a,disabled:!r||c,onChange:e=>o(e.currentTarget.value),"aria-label":`Agent`,children:i.map(Oe)}):null,t[0]=i,t[1]=c,t[2]=r,t[3]=o,t[4]=a,t[5]=h):h=t[5];let g=!r||c||l||i.length===0,_;t[6]===f?_=t[7]:(_=()=>void f(),t[6]=f,t[7]=_);let v;t[8]===l?v=t[9]:(v=l?(0,Z.jsx)(m,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[8]=l,t[9]=v);let y;t[10]!==n.enableAllAgentsDreaming||t[11]!==g||t[12]!==_||t[13]!==v?(y=(0,Z.jsxs)(T,{type:`button`,variant:`secondary`,disabled:g,onClick:_,children:[v,n.enableAllAgentsDreaming]}),t[10]=n.enableAllAgentsDreaming,t[11]=g,t[12]=_,t[13]=v,t[14]=y):y=t[14];let b=!r||!s||c||l||!u,x;t[15]===d?x=t[16]:(x=()=>void d(),t[15]=d,t[16]=x);let S;t[17]===c?S=t[18]:(S=c?(0,Z.jsx)(m,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[17]=c,t[18]=S);let w;t[19]!==n.saveConfig||t[20]!==b||t[21]!==x||t[22]!==S?(w=(0,Z.jsxs)(T,{type:`button`,variant:`primary`,disabled:b,onClick:x,children:[S,n.saveConfig]}),t[19]=n.saveConfig,t[20]=b,t[21]=x,t[22]=S,t[23]=w):w=t[23];let E=!r,D;t[24]===p?D=t[25]:(D=()=>void p(),t[24]=p,t[25]=D);let O;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(C,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[26]=O):O=t[26];let k;t[27]!==n.refresh||t[28]!==E||t[29]!==D?(k=(0,Z.jsx)(T,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:E,title:n.refresh,"aria-label":n.refresh,onClick:D,children:O}),t[27]=n.refresh,t[28]=E,t[29]=D,t[30]=k):k=t[30];let A;t[31]!==h||t[32]!==k||t[33]!==y||t[34]!==w?(A=(0,Z.jsxs)(Z.Fragment,{children:[h,y,w,k]}),t[31]=h,t[32]=k,t[33]=y,t[34]=w,t[35]=A):A=t[35];let j;return t[36]!==n.subtitle||t[37]!==n.title||t[38]!==A?(j=(0,Z.jsx)(M,{title:n.title,subtitle:n.subtitle,actions:A}),t[36]=n.subtitle,t[37]=n.title,t[38]=A,t[39]=j):j=t[39],j}function Oe(e){return(0,Z.jsx)(`option`,{value:e.id,children:e.name||e.id},e.id)}function ke(e){let t=(0,L.c)(30),{t:n,disabled:r,actionBusy:a,doAction:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=i(`max-w-2xl`,J),t[0]=s):s=t[0];let c;t[1]!==n.maintenanceHint||t[2]!==n.maintenanceTitle?(c=(0,Z.jsx)(A,{className:ue,icon:E,title:n.maintenanceTitle,subtitle:n.maintenanceHint}),t[1]=n.maintenanceHint,t[2]=n.maintenanceTitle,t[3]=c):c=t[3];let l;t[4]!==o||t[5]!==n.confirmResetStore?(l=()=>{confirm(n.confirmResetStore)&&o(`reset_store`)},t[4]=o,t[5]=n.confirmResetStore,t[6]=l):l=t[6];let u;t[7]===a?u=t[8]:(u=a===`reset_store`?(0,Z.jsx)(m,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(g,{className:`mr-2 size-4`,"aria-hidden":!0}),t[7]=a,t[8]=u);let d;t[9]!==r||t[10]!==n.resetStore||t[11]!==l||t[12]!==u?(d=(0,Z.jsxs)(T,{variant:`secondary`,disabled:r,onClick:l,children:[u,n.resetStore]}),t[9]=r,t[10]=n.resetStore,t[11]=l,t[12]=u,t[13]=d):d=t[13];let p;t[14]!==o||t[15]!==n.confirmClearLock?(p=()=>{confirm(n.confirmClearLock)&&o(`clear_lock`)},t[14]=o,t[15]=n.confirmClearLock,t[16]=p):p=t[16];let h;t[17]===a?h=t[18]:(h=a===`clear_lock`?(0,Z.jsx)(m,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(f,{className:`mr-2 size-4`,"aria-hidden":!0}),t[17]=a,t[18]=h);let _;t[19]!==r||t[20]!==n.clearLock||t[21]!==p||t[22]!==h?(_=(0,Z.jsxs)(T,{variant:`secondary`,disabled:r,onClick:p,children:[h,n.clearLock]}),t[19]=r,t[20]=n.clearLock,t[21]=p,t[22]=h,t[23]=_):_=t[23];let v;t[24]!==d||t[25]!==_?(v=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[d,_]}),t[24]=d,t[25]=_,t[26]=v):v=t[26];let y;return t[27]!==c||t[28]!==v?(y=(0,Z.jsxs)(j,{className:s,children:[c,v]}),t[27]=c,t[28]=v,t[29]=y):y=t[29],y}function Ae(e){let t=(0,L.c)(21),{t:n,hasToken:r,previewLoading:i,previewItems:a,loadPreview:o}=e,s=!r||i,c;t[0]===o?c=t[1]:(c=()=>void o(),t[0]=o,t[1]=c);let l;t[2]===i?l=t[3]:(l=i?(0,Z.jsx)(m,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=i,t[3]=l);let u;t[4]!==n.previewLoad||t[5]!==s||t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(T,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:s,onClick:c,children:[l,n.previewLoad]}),t[4]=n.previewLoad,t[5]=s,t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]!==n.previewHint||t[10]!==n.previewTitle||t[11]!==u?(d=(0,Z.jsx)(A,{className:ue,icon:y,title:n.previewTitle,subtitle:n.previewHint,trailing:u}),t[9]=n.previewHint,t[10]=n.previewTitle,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==a||t[14]!==n.previewEligible||t[15]!==n.previewEmpty||t[16]!==n.previewNotLoaded?(f=a?a.length>0?(0,Z.jsx)(`div`,{className:`space-y-2`,children:a.map(e=>{let t=`${e.path}:${e.startLine}-${e.endLine}`,r=e.skippedReason;return(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-2.5 py-2 shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:t}),(0,Z.jsxs)(`span`,{children:[`score=`,e.score.toFixed(3)]}),(0,Z.jsxs)(`span`,{children:[`recalls=`,e.recallCount]}),(0,Z.jsxs)(`span`,{children:[`avg=`,e.avgScore.toFixed(3)]}),(0,Z.jsxs)(`span`,{children:[`decay=`,e.recencyDecay?.toFixed(3)??`—`]}),r?(0,Z.jsx)(`span`,{className:`text-amber-600 dark:text-amber-400`,children:r}):(0,Z.jsx)(`span`,{className:`text-emerald-600 dark:text-emerald-400`,children:n.previewEligible})]}),e.snippet?(0,Z.jsx)(`div`,{className:`mt-2 text-sm text-fg`,children:e.snippet}):null]},`${e.key}:${e.hash}:${t}`)})}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.previewEmpty}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.previewNotLoaded}),t[13]=a,t[14]=n.previewEligible,t[15]=n.previewEmpty,t[16]=n.previewNotLoaded,t[17]=f):f=t[17];let p;return t[18]!==d||t[19]!==f?(p=(0,Z.jsxs)(j,{className:J,children:[d,f]}),t[18]=d,t[19]=f,t[20]=p):p=t[20],p}function je(e,t){switch(e){case 3e4:return t.every30s;case 6e4:return t.every1min;case 3e5:return t.every5min;case 6e5:return t.every10min;case 9e5:return t.every15min;case 18e5:return t.every30min;case 36e5:return t.every1h;case 72e5:return t.every2h;default:return null}}var Me={second:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`second`,unitDisplay:`long`}),minute:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`minute`,unitDisplay:`long`}),hour:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`hour`,unitDisplay:`long`})},Ne={second:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`second`,unitDisplay:`long`}),minute:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`minute`,unitDisplay:`long`}),hour:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`hour`,unitDisplay:`long`})};function Pe(e,t){return e.startsWith(`zh`)?Ne[t]:Me[t]}function Fe(e,t,n){let r=Math.max(1e3,Math.round(e));if(n&&N.has(r)){let e=je(r,n);if(e)return e}let i=Math.max(1,Math.round(r/1e3));if(i<120)return Pe(t,`second`).format(i);let a=Math.round(i/60);if(a<120)return Pe(t,`minute`).format(a);let o=Math.round(a/60);return Pe(t,`hour`).format(o)}function Ie(e){let t=(0,L.c)(12),n;t[0]!==e.expression||t[1]!==e.kind||t[2]!==e.labels||t[3]!==e.locale||t[4]!==e.nextRun||t[5]!==e.presetLabels||t[6]!==e.timezone||t[7]!==e.valueMs?(n=e.kind===`cron`?F(e.expression,e.locale,e.labels,{timezone:e.timezone,nextRun:e.nextRun}):Fe(e.valueMs,e.locale,e.presetLabels),t[0]=e.expression,t[1]=e.kind,t[2]=e.labels,t[3]=e.locale,t[4]=e.nextRun,t[5]=e.presetLabels,t[6]=e.timezone,t[7]=e.valueMs,t[8]=n):n=t[8];let r=n,i;return t[9]!==e.className||t[10]!==r?(i=(0,Z.jsx)(`span`,{className:e.className,children:r}),t[9]=e.className,t[10]=r,t[11]=i):i=t[11],i}function Le(e){let t=(0,L.c)(100),{t:n,data:r,isLoading:a,localeTag:o,scheduleBadgeLabels:s}=e,c;t[0]!==r||t[1]!==n?(c=r?pe(r.lock,n):null,t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c,u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(`min-w-0`,J),t[3]=u):u=t[3];let f;t[4]===a?f=t[5]:(f=a?(0,Z.jsx)(m,{className:`size-4 shrink-0 animate-spin text-fg-muted`,"aria-hidden":!0}):null,t[4]=a,t[5]=f);let p;t[6]!==n.runtimeHint||t[7]!==n.runtimeTitle||t[8]!==f?(p=(0,Z.jsx)(A,{className:ue,icon:O,title:n.runtimeTitle,subtitle:n.runtimeHint,trailing:f}),t[6]=n.runtimeHint,t[7]=n.runtimeTitle,t[8]=f,t[9]=p):p=t[9];let g;t[10]===n.subsectionSchedule?g=t[11]:(g=(0,Z.jsx)(ge,{label:n.subsectionSchedule,className:`mb-2`}),t[10]=n.subsectionSchedule,t[11]=g);let _=r?r.config.enabled?n.on:n.off:`—`,v;t[12]!==n.enabled||t[13]!==_?(v=(0,Z.jsx)($,{label:n.enabled,children:_}),t[12]=n.enabled,t[13]=_,t[14]=v):v=t[14];let y=l?.className,b=l?l.text:`—`,x;t[15]!==y||t[16]!==b?(x=(0,Z.jsx)(`span`,{className:y,children:b}),t[15]=y,t[16]=b,t[17]=x):x=t[17];let S;t[18]!==n.lock||t[19]!==x?(S=(0,Z.jsx)($,{label:n.lock,children:x}),t[18]=n.lock,t[19]=x,t[20]=S):S=t[20];let C=r&&r.config.timezone||`—`,w;t[21]!==n.timezone||t[22]!==C?(w=(0,Z.jsx)($,{label:n.timezone,children:C}),t[21]=n.timezone,t[22]=C,t[23]=w):w=t[23];let T;t[24]!==r||t[25]!==o||t[26]!==s?(T=r?(0,Z.jsx)(Ie,{kind:`cron`,expression:r.config.frequency,locale:o,labels:s,timezone:r.config.timezone||void 0}):`—`,t[24]=r,t[25]=o,t[26]=s,t[27]=T):T=t[27];let E;t[28]===r?E=t[29]:(E=r?.config.frequency?(0,Z.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[0.65rem] text-fg-subtle`,title:r.config.frequency,children:r.config.frequency}):null,t[28]=r,t[29]=E);let D;t[30]!==n.schedule||t[31]!==T||t[32]!==E?(D=(0,Z.jsxs)($,{label:n.schedule,className:`col-span-2 sm:col-span-2`,children:[T,E]}),t[30]=n.schedule,t[31]=T,t[32]=E,t[33]=D):D=t[33];let ee;t[34]!==S||t[35]!==w||t[36]!==D||t[37]!==v?(ee=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[v,S,w,D]}),t[34]=S,t[35]=w,t[36]=D,t[37]=v,t[38]=ee):ee=t[38];let M;t[39]!==ee||t[40]!==g?(M=(0,Z.jsxs)(`div`,{className:Y,children:[g,ee]}),t[39]=ee,t[40]=g,t[41]=M):M=t[41];let te;t[42]===n.subsectionStore?te=t[43]:(te=(0,Z.jsx)(ge,{label:n.subsectionStore,className:`mb-2`}),t[42]=n.subsectionStore,t[43]=te);let ne=r?String(r.store.entryCount):`—`,N;t[44]!==n.storeEntries||t[45]!==ne?(N=(0,Z.jsx)($,{label:n.storeEntries,children:ne}),t[44]=n.storeEntries,t[45]=ne,t[46]=N):N=t[46];let P=r?String(r.store.promotedCount):`—`,I;t[47]!==n.storePromoted||t[48]!==P?(I=(0,Z.jsx)($,{label:n.storePromoted,children:P}),t[47]=n.storePromoted,t[48]=P,t[49]=I):I=t[49];let R;t[50]===r?R=t[51]:(R=r?de(r.store.updatedAt):`—`,t[50]=r,t[51]=R);let re;t[52]!==n.storeUpdatedAt||t[53]!==R?(re=(0,Z.jsx)($,{label:n.storeUpdatedAt,children:R}),t[52]=n.storeUpdatedAt,t[53]=R,t[54]=re):re=t[54];let ie;t[55]===r?ie=t[56]:(ie=r?de(r.store.lastPromotedAt):`—`,t[55]=r,t[56]=ie);let ae;t[57]!==n.storeLastPromotedAt||t[58]!==ie?(ae=(0,Z.jsx)($,{label:n.storeLastPromotedAt,children:ie}),t[57]=n.storeLastPromotedAt,t[58]=ie,t[59]=ae):ae=t[59];let oe;t[60]!==N||t[61]!==I||t[62]!==re||t[63]!==ae?(oe=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[N,I,re,ae]}),t[60]=N,t[61]=I,t[62]=re,t[63]=ae,t[64]=oe):oe=t[64];let se;t[65]!==te||t[66]!==oe?(se=(0,Z.jsxs)(`div`,{className:Y,children:[te,oe]}),t[65]=te,t[66]=oe,t[67]=se):se=t[67];let ce;t[68]!==r||t[69]!==o||t[70]!==s||t[71]!==n?(ce=r?.config?.phases?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(ge,{label:n.subsectionPhases,className:`mb-2`}),(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[(0,Z.jsx)(ve,{icon:(0,Z.jsx)(d,{className:`size-4 text-amber-500`}),label:`Light`,enabled:r.config.phases.light.enabled,cron:r.config.phases.light.cron,scheduleSummary:F(r.config.phases.light.cron,o,s,{timezone:r.config.timezone||void 0}),details:`lookback=${r.config.phases.light.lookbackDays}d, limit=${r.config.phases.light.limit}, dedupe=${r.config.phases.light.dedupeSimilarity}`,t:n}),(0,Z.jsx)(ve,{icon:(0,Z.jsx)(k,{className:`size-4 text-indigo-500`}),label:`Deep`,enabled:r.config.phases.deep.enabled,cron:r.config.phases.deep.cron,scheduleSummary:F(r.config.phases.deep.cron,o,s,{timezone:r.config.timezone||void 0}),details:`minScore=${r.config.phases.deep.minScore}, recalls>=${r.config.phases.deep.minRecallCount}, queries>=${r.config.phases.deep.minUniqueQueries}, limit=${r.config.phases.deep.limit}, halfLife=${r.config.phases.deep.recencyHalfLifeDays}d`,t:n}),(0,Z.jsx)(ve,{icon:(0,Z.jsx)(h,{className:`size-4 text-purple-500`}),label:`REM`,enabled:r.config.phases.rem.enabled,cron:r.config.phases.rem.cron,scheduleSummary:F(r.config.phases.rem.cron,o,s,{timezone:r.config.timezone||void 0}),details:`lookback=${r.config.phases.rem.lookbackDays}d, limit=${r.config.phases.rem.limit}, strength≥${r.config.phases.rem.minPatternStrength}`,t:n})]})]}):null,t[68]=r,t[69]=o,t[70]=s,t[71]=n,t[72]=ce):ce=t[72];let z;t[73]===n.subsectionLastRun?z=t[74]:(z=(0,Z.jsx)(ge,{label:n.subsectionLastRun,className:`mb-2`}),t[73]=n.subsectionLastRun,t[74]=z);let B;t[75]===n.lastRunBlockHint?B=t[76]:(B=(0,Z.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:n.lastRunBlockHint}),t[75]=n.lastRunBlockHint,t[76]=B);let V;t[77]!==r||t[78]!==n?(V=r?.lastRun?.exists?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[r.lastRun.parseError?(0,Z.jsxs)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:[n.lastRunParseError,`: `,r.lastRun.parseError]}):null,r.lastRun.record?(0,Z.jsx)(`div`,{className:`rounded-lg bg-surface-panel/70 p-2.5 shadow-surface`,children:(0,Z.jsx)(be,{t:n,r:r.lastRun.record})}):null,r.lastRun.raw!==void 0&&r.lastRun.raw!==null?(0,Z.jsxs)(`details`,{className:`group rounded-lg bg-surface-panel/70 shadow-surface`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer list-none px-2.5 py-1.5 text-xs font-medium text-fg-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:(0,Z.jsx)(`span`,{className:`underline decoration-edge underline-offset-2 group-open:text-fg`,children:n.lastRunRaw})}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto bg-surface-base/50 p-2.5 text-xs text-fg-muted`,children:JSON.stringify(r.lastRun.raw,null,2)})]}):null]}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.lastRunEmpty}),t[77]=r,t[78]=n,t[79]=V):V=t[79];let H;t[80]!==z||t[81]!==B||t[82]!==V?(H=(0,Z.jsxs)(`div`,{className:Y,children:[z,B,V]}),t[80]=z,t[81]=B,t[82]=V,t[83]=H):H=t[83];let U=r?.lightLastRun,W;t[84]!==n||t[85]!==U?(W=(0,Z.jsx)(ye,{label:n.subsectionLightLastRun,lastRun:U,t:n}),t[84]=n,t[85]=U,t[86]=W):W=t[86];let G=r?.remLastRun,K;t[87]!==n||t[88]!==G?(K=(0,Z.jsx)(ye,{label:n.subsectionRemLastRun,lastRun:G,t:n}),t[87]=n,t[88]=G,t[89]=K):K=t[89];let q;t[90]!==M||t[91]!==se||t[92]!==ce||t[93]!==H||t[94]!==W||t[95]!==K?(q=(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[M,se,ce,H,W,K]}),t[90]=M,t[91]=se,t[92]=ce,t[93]=H,t[94]=W,t[95]=K,t[96]=q):q=t[96];let le;return t[97]!==q||t[98]!==p?(le=(0,Z.jsxs)(j,{className:u,children:[p,q]}),t[97]=q,t[98]=p,t[99]=le):le=t[99],le}var Re=[`config`,`runtime`,`insights`,`maintenance`],ze={config:p,runtime:O,insights:y,maintenance:E};function Be(e){return e&&Re.includes(e)?e:`config`}function Ve(e,t){return t===`config`?e.tabConfig:t===`runtime`?e.tabRuntime:t===`insights`?e.tabInsights:e.tabMaintenance}function He(e,t){return t===`config`?e.configTabHint:t===`runtime`?e.runtimeTabHint:t===`insights`?e.insightsTabHint:e.maintenanceTabHint}function Ue(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:return{form:t.value,baseline:t.value};case`set`:return{...e,form:t.value};case`saved`:return{form:t.value,baseline:t.value}}}var We={actionBusy:null,actionError:null,actionOk:!1,runBusy:!1,runOk:!1,runError:null,runPhase:`deep`,cfgSaving:!1,cfgOk:!1,cfgError:null,enableAllBusy:!1,previewLoading:!1,previewError:null,previewItems:null,eventsLoading:!1,eventsError:null,events:null},Ge=900;function Ke(){return typeof window>`u`||typeof window.requestAnimationFrame!=`function`?new Promise(e=>setTimeout(e,0)):new Promise(e=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>e())})})}function qe(e,t){typeof window>`u`||window.dispatchEvent(new CustomEvent(e,{detail:t}))}function Je(){let e=o(e=>e.language),t=a(e),n=t.dreamingSettings,r=t.cron.schedulePicker,i=t.cron.scheduleBadge,c=e===`zh`?`zh-CN`:`en-US`,l=!!s(e=>e.token),[d,f]=w(),p=Be(d.get(`tab`)),m=d.get(`agentId`)?.trim()||``,h=(0,I.useCallback)(e=>{f(t=>{let n=new URLSearchParams(t);return e===`config`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[f]),[g,v]=(0,I.useReducer)(_,We),{actionBusy:y,actionError:b,runBusy:x,runError:C,runPhase:T,cfgSaving:E,cfgError:D,enableAllBusy:O,previewLoading:k,previewError:A,previewItems:j,eventsLoading:ee,eventsError:M,events:te}=g,[N,P]=(0,I.useReducer)(Ue,{form:null,baseline:null}),F=N.form,L=N.baseline,R=(0,I.useRef)(!1),z=u(l?`dreaming-settings-agents`:null,S,{revalidateOnFocus:!1}),B=z.data?.agents??[],V=m||z.data?.defaultId||``,H=(0,I.useMemo)(()=>B.find(e=>e.id===V),[B,V]),U=(0,I.useCallback)(e=>{R.current=!1,P({type:`reset`}),f(t=>{let n=new URLSearchParams(t);return e?n.set(`agentId`,e):n.delete(`agentId`),n},{replace:!0})},[f]),{data:W,error:G,isLoading:K,mutate:J}=u(l&&V?re(V):null,ie,{revalidateOnFocus:!1}),ue=(0,I.useMemo)(()=>{let e=[];return G&&e.push(G instanceof Error?G.message:String(G)),b&&e.push(b),C&&e.push(C),A&&e.push(A),M&&e.push(M),D&&e.push(D),e},[G,b,C,A,M,D]),Y=(0,I.useCallback)(async()=>{v({type:`patch`,patch:{actionOk:!1,actionError:null,runOk:!1,runError:null,cfgOk:!1,cfgError:null,previewError:null}}),await J()},[J]),X=(0,I.useCallback)(async()=>{v({type:`patch`,patch:{previewLoading:!0,previewError:null}});try{v({type:`patch`,patch:{previewItems:(await se(20,V)).items??[]}})}catch(e){v({type:`patch`,patch:{previewError:e instanceof Error?e.message:String(e)}})}finally{v({type:`patch`,patch:{previewLoading:!1}})}},[V]),de=(0,I.useCallback)(async()=>{v({type:`patch`,patch:{eventsLoading:!0,eventsError:null}});try{v({type:`patch`,patch:{events:await ce(50,V)}})}catch(e){v({type:`patch`,patch:{eventsError:e instanceof Error?e.message:String(e)}})}finally{v({type:`patch`,patch:{eventsLoading:!1}})}},[V]),fe=(0,I.useCallback)(async(e=`deep`)=>{let t=Date.now(),n=B.length>0?B.map(e=>({id:e.id,name:e.name,avatar:e.avatar})):[{id:V,name:H?.name,avatar:H?.avatar}].filter(e=>e.id),r=n.length>0?n:[{id:V}],i=[];v({type:`patch`,patch:{runPhase:e,runBusy:!0,runOk:!1,runError:null}});try{let t=r.map(t=>{let n={phase:e,...t.id?{agentId:t.id}:{},...t.name?{agentName:t.name}:{},...t.avatar?{avatar:t.avatar}:{}};return qe(`dreaming-phase-start`,n),{target:t,detail:n}}).map(async({target:t,detail:n})=>{await Ke();try{await oe(e,t.id||V)}catch(e){let n=t.name||t.id||V||`default`,r=e instanceof Error?e.message:String(e);i.push(`${n}: ${r}`)}finally{qe(`dreaming-phase-end`,n)}});await Promise.all(t),v({type:`patch`,patch:i.length>0?{runError:i.join(`
2
2
  `)}:{runOk:!0}}),await J()}catch(e){v({type:`patch`,patch:{runError:e instanceof Error?e.message:String(e)}})}finally{let e=Ge-(Date.now()-t);e>0&&await new Promise(t=>setTimeout(t,e)),v({type:`patch`,patch:{runBusy:!1}})}},[B,J,H?.avatar,H?.name,V]),pe=(0,I.useCallback)(async e=>{v({type:`patch`,patch:{actionBusy:e,actionError:null,actionOk:!1}});try{await ae(e,V),v({type:`patch`,patch:{actionOk:!0}}),await J()}catch(e){v({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{v({type:`patch`,patch:{actionBusy:null}})}},[J,V]),me=!l||K||!!y,he=(0,I.useMemo)(()=>{let e=W?.config;return q(e??{})},[W]),Q=W?.agentId||V||`main`,$=W?.memory;(0,I.useEffect)(()=>{if(!l){P({type:`reset`}),R.current=!1;return}R.current||P({type:`sync`,value:he})},[he,l]);let ge=(0,I.useMemo)(()=>!F||!L?!1:JSON.stringify(F)!==JSON.stringify(L),[F,L]);return(0,Z.jsxs)(ne,{children:[(0,Z.jsx)(De,{t:n,hasToken:l,agents:B,selectedAgentId:V,onAgentChange:U,cfgForm:F,cfgSaving:E,enableAllBusy:O,cfgDirty:ge,saveConfig:(0,I.useCallback)(async()=>{if(F){v({type:`patch`,patch:{cfgSaving:!0,cfgOk:!1,cfgError:null}});try{await le(Q,F,$),P({type:`saved`,value:F}),R.current=!1,v({type:`patch`,patch:{cfgOk:!0}}),await J()}catch(e){v({type:`patch`,patch:{cfgError:e instanceof Error?e.message:String(e)}})}finally{v({type:`patch`,patch:{cfgSaving:!1}})}}},[Q,$,F,J]),enableAllAgentsDreaming:(0,I.useCallback)(async()=>{let e=B.length>0?B:V?[{id:V,name:H?.name,avatar:H?.avatar}]:[];if(e.length===0)return;v({type:`patch`,patch:{enableAllBusy:!0,cfgOk:!1,cfgError:null}});let t=[];try{for(let n of e)try{let e=await ie(n.id),t=q(e.config);await le(n.id,{...t,enabled:!0,light:{...t.light,enabled:!0},deep:{...t.deep,enabled:!0},rem:{...t.rem,enabled:!0}},e.memory)}catch(e){let r=n.name||n.id;t.push(`${r}: ${e instanceof Error?e.message:String(e)}`)}t.length>0?v({type:`patch`,patch:{cfgError:t.join(`
3
- `)}}):v({type:`patch`,patch:{cfgOk:!0}}),await J()}finally{v({type:`patch`,patch:{enableAllBusy:!1}})}},[B,J,H?.avatar,H?.name,V]),doRefresh:Y}),ue.length>0?(0,Z.jsx)(`div`,{className:`space-y-1.5 rounded-2xl border border-amber-500/20 bg-amber-500/5 px-4 py-3`,role:`alert`,children:ue.map(e=>(0,Z.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200/90`,children:e},e))}):null,(0,Z.jsx)(Ye,{t:n,activeTab:p,onChange:h}),(0,Z.jsx)(Xe,{t:n,id:`config`,activeTab:p,children:(0,Z.jsx)(xe,{t:n,schedulePickerLabels:r,hasToken:l,cfgForm:F,cfgBaseline:L,cfgDirty:ge,cfgSaving:E,runPhase:T,runBusy:C,setCfgForm:e=>{R.current=!0;let t=typeof e==`function`?e(F):e;t&&P({type:`set`,value:t})},doRunNow:fe})}),(0,Z.jsx)(Xe,{t:n,id:`runtime`,activeTab:p,children:(0,Z.jsx)(Le,{t:n,data:W,isLoading:K,localeTag:c,scheduleBadgeLabels:i})}),(0,Z.jsx)(Xe,{t:n,id:`insights`,activeTab:p,children:(0,Z.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,Z.jsx)(Ae,{t:n,hasToken:l,previewLoading:k,previewItems:j,loadPreview:X}),(0,Z.jsx)(Te,{t:n,hasToken:l,eventsLoading:ee,events:te,loadEvents:de})]})}),(0,Z.jsx)(Xe,{t:n,id:`maintenance`,activeTab:p,children:(0,Z.jsx)(ke,{t:n,disabled:me,actionBusy:y,doAction:pe})})]})}function Ye(e){let t=(0,L.c)(7),{t:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=Re.map(e=>({id:e,label:Ve(n,e),icon:ze[e]})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,Z.jsx)(ee,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`dreaming-settings-tab`,panelIdPrefix:`dreaming-settings-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function Xe(e){let t=(0,L.c)(13),{t:n,id:r,activeTab:i,children:a}=e,o=r!==`config`,s;t[0]!==r||t[1]!==n?(s=Ve(n,r),t[0]=r,t[1]=n,t[2]=s):s=t[2];let c;t[3]!==r||t[4]!==n?(c=He(n,r),t[3]=r,t[4]=n,t[5]=c):c=t[5];let l;return t[6]!==i||t[7]!==a||t[8]!==r||t[9]!==o||t[10]!==s||t[11]!==c?(l=(0,Z.jsx)(te,{id:r,activeTab:i,tabIdPrefix:`dreaming-settings-tab`,panelIdPrefix:`dreaming-settings-panel`,title:s,hint:c,showHeading:o,children:a}),t[6]=i,t[7]=a,t[8]=r,t[9]=o,t[10]=s,t[11]=c,t[12]=l):l=t[12],l}export{Je as DreamingSettingsPanel};
3
+ `)}}):v({type:`patch`,patch:{cfgOk:!0}}),await J()}finally{v({type:`patch`,patch:{enableAllBusy:!1}})}},[B,J,H?.avatar,H?.name,V]),doRefresh:Y}),ue.length>0?(0,Z.jsx)(`div`,{className:`space-y-1.5 rounded-2xl border border-amber-500/20 bg-amber-500/5 px-4 py-3`,role:`alert`,children:ue.map(e=>(0,Z.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200/90`,children:e},e))}):null,(0,Z.jsx)(Ye,{t:n,activeTab:p,onChange:h}),(0,Z.jsx)(Xe,{t:n,id:`config`,activeTab:p,children:(0,Z.jsx)(xe,{t:n,schedulePickerLabels:r,hasToken:l,cfgForm:F,cfgBaseline:L,cfgDirty:ge,cfgSaving:E,runPhase:T,runBusy:x,setCfgForm:e=>{R.current=!0;let t=typeof e==`function`?e(F):e;t&&P({type:`set`,value:t})},doRunNow:fe})}),(0,Z.jsx)(Xe,{t:n,id:`runtime`,activeTab:p,children:(0,Z.jsx)(Le,{t:n,data:W,isLoading:K,localeTag:c,scheduleBadgeLabels:i})}),(0,Z.jsx)(Xe,{t:n,id:`insights`,activeTab:p,children:(0,Z.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,Z.jsx)(Ae,{t:n,hasToken:l,previewLoading:k,previewItems:j,loadPreview:X}),(0,Z.jsx)(Te,{t:n,hasToken:l,eventsLoading:ee,events:te,loadEvents:de})]})}),(0,Z.jsx)(Xe,{t:n,id:`maintenance`,activeTab:p,children:(0,Z.jsx)(ke,{t:n,disabled:me,actionBusy:y,doAction:pe})})]})}function Ye(e){let t=(0,L.c)(7),{t:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=Re.map(e=>({id:e,label:Ve(n,e),icon:ze[e]})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,Z.jsx)(ee,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`dreaming-settings-tab`,panelIdPrefix:`dreaming-settings-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function Xe(e){let t=(0,L.c)(13),{t:n,id:r,activeTab:i,children:a}=e,o=r!==`config`,s;t[0]!==r||t[1]!==n?(s=Ve(n,r),t[0]=r,t[1]=n,t[2]=s):s=t[2];let c;t[3]!==r||t[4]!==n?(c=He(n,r),t[3]=r,t[4]=n,t[5]=c):c=t[5];let l;return t[6]!==i||t[7]!==a||t[8]!==r||t[9]!==o||t[10]!==s||t[11]!==c?(l=(0,Z.jsx)(te,{id:r,activeTab:i,tabIdPrefix:`dreaming-settings-tab`,panelIdPrefix:`dreaming-settings-panel`,title:s,hint:c,showHeading:o,children:a}),t[6]=i,t[7]=a,t[8]=r,t[9]=o,t[10]=s,t[11]=c,t[12]=l):l=t[12],l}export{Je as DreamingSettingsPanel};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./messages-CjuIJcZl.js";import{n as a}from"./locale-store-Ba72bFmP.js";import{aa as o}from"./index-BPXLPMuY.js";var s=n(),c=e(t(),1),l=r(),u=`xopc.extensionUiGrants.v1`;function d(){let e=(0,s.c)(59),t=a(h),n;e[0]===t?n=e[1]:(n=i(t),e[0]=t,e[1]=n);let r=n.extensionDebug,u=o(),[d,_]=(0,c.useState)(m),v;e[2]===u?v=e[3]:(v=u.toSorted(p),e[2]=u,e[3]=v);let y=v,b;e[4]===r.title?b=e[5]:(b=(0,l.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:r.title}),e[4]=r.title,e[5]=b);let x;e[6]===r.subtitle?x=e[7]:(x=(0,l.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle}),e[6]=r.subtitle,e[7]=x);let S;e[8]!==b||e[9]!==x?(S=(0,l.jsxs)(`div`,{children:[b,x]}),e[8]=b,e[9]=x,e[10]=S):S=e[10];let C;e[11]===r.grantsHeading?C=e[12]:(C=(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.grantsHeading}),e[11]=r.grantsHeading,e[12]=C);let w;e[13]===r.grantsHint?w=e[14]:(w=(0,l.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.grantsHint}),e[13]=r.grantsHint,e[14]=w);let T;e[15]===d?T=e[16]:(T=(0,l.jsx)(`pre`,{className:`mt-3 max-h-48 overflow-auto rounded-lg border border-edge-subtle bg-surface-muted p-3 font-mono text-xs text-fg`,children:d}),e[15]=d,e[16]=T);let E;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>_(g()),e[17]=E):E=e[17];let D;e[18]===r.refresh?D=e[19]:(D=(0,l.jsx)(`button`,{type:`button`,className:`mt-3 rounded-lg border border-edge px-3 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,onClick:E,children:r.refresh}),e[18]=r.refresh,e[19]=D);let O;e[20]!==C||e[21]!==w||e[22]!==T||e[23]!==D?(O=(0,l.jsxs)(`section`,{className:`rounded-xl bg-surface-base p-4`,children:[C,w,T,D]}),e[20]=C,e[21]=w,e[22]=T,e[23]=D,e[24]=O):O=e[24];let k;e[25]===r.listHeading?k=e[26]:(k=(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.listHeading}),e[25]=r.listHeading,e[26]=k);let A;e[27]===r.colId?A=e[28]:(A=(0,l.jsx)(`th`,{className:`py-2 pr-2`,children:r.colId}),e[27]=r.colId,e[28]=A);let j;e[29]===r.colName?j=e[30]:(j=(0,l.jsx)(`th`,{className:`py-2 pr-2`,children:r.colName}),e[29]=r.colName,e[30]=j);let M;e[31]===r.colPermissions?M=e[32]:(M=(0,l.jsx)(`th`,{className:`py-2`,children:r.colPermissions}),e[31]=r.colPermissions,e[32]=M);let N;e[33]!==A||e[34]!==j||e[35]!==M?(N=(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{className:`border-b border-edge text-xs uppercase text-fg-muted`,children:[A,j,M]})}),e[33]=A,e[34]=j,e[35]=M,e[36]=N):N=e[36];let P;e[37]===y?P=e[38]:(P=y.map(f),e[37]=y,e[38]=P);let F;e[39]===P?F=e[40]:(F=(0,l.jsx)(`tbody`,{children:P}),e[39]=P,e[40]=F);let I;e[41]!==N||e[42]!==F?(I=(0,l.jsx)(`div`,{className:`mt-3 overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full min-w-[32rem] border-collapse text-left text-sm`,children:[N,F]})}),e[41]=N,e[42]=F,e[43]=I):I=e[43];let L;e[44]!==k||e[45]!==I?(L=(0,l.jsxs)(`section`,{className:`rounded-xl bg-surface-base p-4`,children:[k,I]}),e[44]=k,e[45]=I,e[46]=L):L=e[46];let R;e[47]===r.futureHeading?R=e[48]:(R=(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.futureHeading}),e[47]=r.futureHeading,e[48]=R);let z;e[49]===r.futureBody?z=e[50]:(z=(0,l.jsx)(`p`,{className:`mt-2`,children:r.futureBody}),e[49]=r.futureBody,e[50]=z);let B;e[51]!==R||e[52]!==z?(B=(0,l.jsxs)(`section`,{className:`rounded-xl bg-surface-muted/50 p-4 text-sm text-fg-muted shadow-surface`,children:[R,z]}),e[51]=R,e[52]=z,e[53]=B):B=e[53];let V;return e[54]!==O||e[55]!==L||e[56]!==B||e[57]!==S?(V=(0,l.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-8 sm:px-5 xl:px-6`,children:[S,O,L,B]}),e[54]=O,e[55]=L,e[56]=B,e[57]=S,e[58]=V):V=e[58],V}function f(e){return(0,l.jsxs)(`tr`,{className:`border-b border-edge-subtle`,children:[(0,l.jsx)(`td`,{className:`py-2 pr-2 font-mono text-xs text-fg`,children:e.id}),(0,l.jsx)(`td`,{className:`py-2 pr-2 text-fg`,children:e.name}),(0,l.jsx)(`td`,{className:`py-2 font-mono text-xs text-fg-muted`,children:(e.ui?.permissions??[]).join(`, `)||`—`})]},e.id)}function p(e,t){return e.id.localeCompare(t.id)}function m(){return g()}function h(e){return e.language}function g(){try{let e=localStorage.getItem(u);if(!e)return`{}`;let t=JSON.parse(e);return JSON.stringify(t,null,2)}catch(e){return e instanceof Error?e.message:String(e)}}export{d as ExtensionDebugPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./messages-C22hxE1N.js";import{n as a}from"./locale-store-Ba72bFmP.js";import{oa as o}from"./index-CA2tR2vm.js";var s=n(),c=e(t(),1),l=r(),u=`xopc.extensionUiGrants.v1`;function d(){let e=(0,s.c)(59),t=a(h),n;e[0]===t?n=e[1]:(n=i(t),e[0]=t,e[1]=n);let r=n.extensionDebug,u=o(),[d,_]=(0,c.useState)(m),v;e[2]===u?v=e[3]:(v=u.toSorted(p),e[2]=u,e[3]=v);let y=v,b;e[4]===r.title?b=e[5]:(b=(0,l.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:r.title}),e[4]=r.title,e[5]=b);let x;e[6]===r.subtitle?x=e[7]:(x=(0,l.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle}),e[6]=r.subtitle,e[7]=x);let S;e[8]!==b||e[9]!==x?(S=(0,l.jsxs)(`div`,{children:[b,x]}),e[8]=b,e[9]=x,e[10]=S):S=e[10];let C;e[11]===r.grantsHeading?C=e[12]:(C=(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.grantsHeading}),e[11]=r.grantsHeading,e[12]=C);let w;e[13]===r.grantsHint?w=e[14]:(w=(0,l.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.grantsHint}),e[13]=r.grantsHint,e[14]=w);let T;e[15]===d?T=e[16]:(T=(0,l.jsx)(`pre`,{className:`mt-3 max-h-48 overflow-auto rounded-lg border border-edge-subtle bg-surface-muted p-3 font-mono text-xs text-fg`,children:d}),e[15]=d,e[16]=T);let E;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>_(g()),e[17]=E):E=e[17];let D;e[18]===r.refresh?D=e[19]:(D=(0,l.jsx)(`button`,{type:`button`,className:`mt-3 rounded-lg border border-edge px-3 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,onClick:E,children:r.refresh}),e[18]=r.refresh,e[19]=D);let O;e[20]!==C||e[21]!==w||e[22]!==T||e[23]!==D?(O=(0,l.jsxs)(`section`,{className:`rounded-xl bg-surface-base p-4`,children:[C,w,T,D]}),e[20]=C,e[21]=w,e[22]=T,e[23]=D,e[24]=O):O=e[24];let k;e[25]===r.listHeading?k=e[26]:(k=(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.listHeading}),e[25]=r.listHeading,e[26]=k);let A;e[27]===r.colId?A=e[28]:(A=(0,l.jsx)(`th`,{className:`py-2 pr-2`,children:r.colId}),e[27]=r.colId,e[28]=A);let j;e[29]===r.colName?j=e[30]:(j=(0,l.jsx)(`th`,{className:`py-2 pr-2`,children:r.colName}),e[29]=r.colName,e[30]=j);let M;e[31]===r.colPermissions?M=e[32]:(M=(0,l.jsx)(`th`,{className:`py-2`,children:r.colPermissions}),e[31]=r.colPermissions,e[32]=M);let N;e[33]!==A||e[34]!==j||e[35]!==M?(N=(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{className:`border-b border-edge text-xs uppercase text-fg-muted`,children:[A,j,M]})}),e[33]=A,e[34]=j,e[35]=M,e[36]=N):N=e[36];let P;e[37]===y?P=e[38]:(P=y.map(f),e[37]=y,e[38]=P);let F;e[39]===P?F=e[40]:(F=(0,l.jsx)(`tbody`,{children:P}),e[39]=P,e[40]=F);let I;e[41]!==N||e[42]!==F?(I=(0,l.jsx)(`div`,{className:`mt-3 overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full min-w-[32rem] border-collapse text-left text-sm`,children:[N,F]})}),e[41]=N,e[42]=F,e[43]=I):I=e[43];let L;e[44]!==k||e[45]!==I?(L=(0,l.jsxs)(`section`,{className:`rounded-xl bg-surface-base p-4`,children:[k,I]}),e[44]=k,e[45]=I,e[46]=L):L=e[46];let R;e[47]===r.futureHeading?R=e[48]:(R=(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.futureHeading}),e[47]=r.futureHeading,e[48]=R);let z;e[49]===r.futureBody?z=e[50]:(z=(0,l.jsx)(`p`,{className:`mt-2`,children:r.futureBody}),e[49]=r.futureBody,e[50]=z);let B;e[51]!==R||e[52]!==z?(B=(0,l.jsxs)(`section`,{className:`rounded-xl bg-surface-muted/50 p-4 text-sm text-fg-muted shadow-surface`,children:[R,z]}),e[51]=R,e[52]=z,e[53]=B):B=e[53];let V;return e[54]!==O||e[55]!==L||e[56]!==B||e[57]!==S?(V=(0,l.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-8 sm:px-5 xl:px-6`,children:[S,O,L,B]}),e[54]=O,e[55]=L,e[56]=B,e[57]=S,e[58]=V):V=e[58],V}function f(e){return(0,l.jsxs)(`tr`,{className:`border-b border-edge-subtle`,children:[(0,l.jsx)(`td`,{className:`py-2 pr-2 font-mono text-xs text-fg`,children:e.id}),(0,l.jsx)(`td`,{className:`py-2 pr-2 text-fg`,children:e.name}),(0,l.jsx)(`td`,{className:`py-2 font-mono text-xs text-fg-muted`,children:(e.ui?.permissions??[]).join(`, `)||`—`})]},e.id)}function p(e,t){return e.id.localeCompare(t.id)}function m(){return g()}function h(e){return e.language}function g(){try{let e=localStorage.getItem(u);if(!e)return`{}`;let t=JSON.parse(e);return JSON.stringify(t,null,2)}catch(e){return e instanceof Error?e.message:String(e)}}export{d as ExtensionDebugPage};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{aa as i,ca as a,ja as o,rt as s,ul as c}from"./index-BPXLPMuY.js";var l=n(),u=e(t(),1),d=r();function f(){let e=(0,l.c)(26),{extensionId:t,pageId:n}=c(),r=i(),f=o(m),g=o(p),_,v,y;e[0]!==t||e[1]!==r||e[2]!==n?(_=t?r.find(e=>e.id===t&&a(e)):void 0,v=_?.ui?.contributions?.pages,y=t&&v?.length?n?v.find(e=>e.id===n||e.id===`${t}.${n}`):v[0]:void 0,e[0]=t,e[1]=r,e[2]=n,e[3]=_,e[4]=v,e[5]=y):(_=e[3],v=e[4],y=e[5]);let b=y,x,S;if(e[6]!==g||e[7]!==_||e[8]!==t||e[9]!==b||e[10]!==f?(x=()=>{if(!t||!_||!b)return g(),()=>g();let e=b.title?.trim()||_.name||t;return f({startExtra:null,main:(0,d.jsx)(`div`,{className:`w-full min-w-0 px-3 sm:px-5 xl:px-6`,children:(0,d.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,title:e,children:e})}),end:null}),()=>g()},S=[g,_,t,b,f],e[6]=g,e[7]=_,e[8]=t,e[9]=b,e[10]=f,e[11]=x,e[12]=S):(x=e[11],S=e[12]),(0,u.useLayoutEffect)(x,S),!t){let t;return e[13]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,d.jsx)(h,{message:`No extension ID provided.`}),e[13]=t):t=e[13],t}if(!_){let n=`Extension "${t}" not found or has no UI.`,r;return e[14]===n?r=e[15]:(r=(0,d.jsx)(h,{message:n}),e[14]=n,e[15]=r),r}if(!v?.length){let n=`Extension "${t}" has no page contributions.`,r;return e[16]===n?r=e[17]:(r=(0,d.jsx)(h,{message:n}),e[16]=n,e[17]=r),r}if(!b){let r=`Page "${n}" not found in extension "${t}".`,i;return e[18]===r?i=e[19]:(i=(0,d.jsx)(h,{message:r}),e[18]=r,e[19]=i),i}let C=_.ui?.permissions,w;return e[20]!==_.name||e[21]!==t||e[22]!==b.entrypoint||e[23]!==b.title||e[24]!==C?(w=(0,d.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,d.jsx)(s,{extensionId:t,extensionName:_.name,entrypoint:b.entrypoint,permissions:C,title:b.title,className:`min-h-0 flex-1`,fixedHeight:void 0,maxHeight:99999})}),e[20]=_.name,e[21]=t,e[22]=b.entrypoint,e[23]=b.title,e[24]=C,e[25]=w):w=e[25],w}function p(e){return e.clearPageHeader}function m(e){return e.setPageHeader}function h(e){let t=(0,l.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,d.jsx)(`div`,{className:`flex min-h-[min(40vh,16rem)] flex-1 items-center justify-center`,children:(0,d.jsx)(`div`,{className:`text-center`,children:(0,d.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})})}),t[0]=n,t[1]=r),r}export{f as ExtensionPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{Ma as i,dl as a,la as o,oa as s,rt as c}from"./index-CA2tR2vm.js";var l=n(),u=e(t(),1),d=r();function f(){let e=(0,l.c)(26),{extensionId:t,pageId:n}=a(),r=s(),f=i(m),g=i(p),_,v,y;e[0]!==t||e[1]!==r||e[2]!==n?(_=t?r.find(e=>e.id===t&&o(e)):void 0,v=_?.ui?.contributions?.pages,y=t&&v?.length?n?v.find(e=>e.id===n||e.id===`${t}.${n}`):v[0]:void 0,e[0]=t,e[1]=r,e[2]=n,e[3]=_,e[4]=v,e[5]=y):(_=e[3],v=e[4],y=e[5]);let b=y,x,S;if(e[6]!==g||e[7]!==_||e[8]!==t||e[9]!==b||e[10]!==f?(x=()=>{if(!t||!_||!b)return g(),()=>g();let e=b.title?.trim()||_.name||t;return f({startExtra:null,main:(0,d.jsx)(`div`,{className:`w-full min-w-0 px-3 sm:px-5 xl:px-6`,children:(0,d.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,title:e,children:e})}),end:null}),()=>g()},S=[g,_,t,b,f],e[6]=g,e[7]=_,e[8]=t,e[9]=b,e[10]=f,e[11]=x,e[12]=S):(x=e[11],S=e[12]),(0,u.useLayoutEffect)(x,S),!t){let t;return e[13]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,d.jsx)(h,{message:`No extension ID provided.`}),e[13]=t):t=e[13],t}if(!_){let n=`Extension "${t}" not found or has no UI.`,r;return e[14]===n?r=e[15]:(r=(0,d.jsx)(h,{message:n}),e[14]=n,e[15]=r),r}if(!v?.length){let n=`Extension "${t}" has no page contributions.`,r;return e[16]===n?r=e[17]:(r=(0,d.jsx)(h,{message:n}),e[16]=n,e[17]=r),r}if(!b){let r=`Page "${n}" not found in extension "${t}".`,i;return e[18]===r?i=e[19]:(i=(0,d.jsx)(h,{message:r}),e[18]=r,e[19]=i),i}let C=_.ui?.permissions,w;return e[20]!==_.name||e[21]!==t||e[22]!==b.entrypoint||e[23]!==b.title||e[24]!==C?(w=(0,d.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,d.jsx)(c,{extensionId:t,extensionName:_.name,entrypoint:b.entrypoint,permissions:C,title:b.title,className:`min-h-0 flex-1`,fixedHeight:void 0,maxHeight:99999})}),e[20]=_.name,e[21]=t,e[22]=b.entrypoint,e[23]=b.title,e[24]=C,e[25]=w):w=e[25],w}function p(e){return e.clearPageHeader}function m(e){return e.setPageHeader}function h(e){let t=(0,l.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,d.jsx)(`div`,{className:`flex min-h-[min(40vh,16rem)] flex-1 items-center justify-center`,children:(0,d.jsx)(`div`,{className:`text-center`,children:(0,d.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})})}),t[0]=n,t[1]=r),r}export{f as ExtensionPage};