@xopcai/xopc 0.0.307 → 0.0.309

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 (261) hide show
  1. package/dist/browser-ext/_locales/en/messages.json +8 -0
  2. package/dist/browser-ext/_locales/zh_CN/messages.json +8 -0
  3. package/dist/browser-ext/dist/assets/{sidepanel-BbSQr-6P.css → sidepanel-DD6GEMvc.css} +16 -0
  4. package/dist/browser-ext/dist/sidepanel.html +1 -1
  5. package/dist/browser-ext/dist/sidepanel.js +537 -96
  6. package/dist/browser-ext/manifest.json +1 -1
  7. package/dist/extensions/telegram/xopc.extension.json +1 -1
  8. package/dist/gateway/static/root/assets/{activity-store-wgSB2HYK.js → activity-store-XKNYlFUI.js} +1 -1
  9. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CZeQo09T.js → agent-avatar-dicebear-1S2TFECE.js} +1 -1
  10. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-f0-YFMUz.js +1 -0
  11. package/dist/gateway/static/root/assets/{agents-BlrHMbRx.js → agents-CPqUMtCL.js} +1 -1
  12. package/dist/gateway/static/root/assets/{api-BKHmTb0w.js → api-BEUEE4f2.js} +1 -1
  13. package/dist/gateway/static/root/assets/api-CN4id43t.js +1 -0
  14. package/dist/gateway/static/root/assets/{app-management-settings-panel-Bzw4fQP8.js → app-management-settings-panel-CgVBSqzu.js} +1 -1
  15. package/dist/gateway/static/root/assets/{appearance-settings-8GZpUXva.js → appearance-settings-CoWdCokb.js} +1 -1
  16. package/dist/gateway/static/root/assets/{apps-page-BkQQtIxH.js → apps-page-CexHOcWg.js} +1 -1
  17. package/dist/gateway/static/root/assets/{archive-plugin-CQ2NaoHb.js → archive-plugin-C3ZA6LRS.js} +1 -1
  18. package/dist/gateway/static/root/assets/{attachment-load-BFi1H7yJ.js → attachment-load-CdgS6_zy.js} +1 -1
  19. package/dist/gateway/static/root/assets/{automations-page-CDBXcii_.js → automations-page-BtHL2hpg.js} +1 -1
  20. package/dist/gateway/static/root/assets/automations-workspace-onJPfmO6.js +6 -0
  21. package/dist/gateway/static/root/assets/{binary-plugins-D07eWmOx.js → binary-plugins-CiDhtq_H.js} +1 -1
  22. package/dist/gateway/static/root/assets/{block-editor-CtVnjyYU.js → block-editor-Br00T83w.js} +3 -3
  23. package/dist/gateway/static/root/assets/{browser-automation-inputs-BzkJog8e.js → browser-automation-inputs-D2tILykA.js} +1 -1
  24. package/dist/gateway/static/root/assets/{browser-automations-page-DyrSbDdG.js → browser-automations-page-BVuEmryB.js} +1 -1
  25. package/dist/gateway/static/root/assets/browser-settings-page-BgVTyPFY.js +3 -0
  26. package/dist/gateway/static/root/assets/capabilities-settings-panel-Dra8wj1S.js +8 -0
  27. package/dist/gateway/static/root/assets/{channels-settings-DAD9qE3J.js → channels-settings-CkxiMDJ4.js} +1 -1
  28. package/dist/gateway/static/root/assets/{channels-status-swr-B2JwuTjG.js → channels-status-swr-Dtder4G_.js} +1 -1
  29. package/dist/gateway/static/root/assets/{chat-terminal-dock-B62SZdAo.js → chat-terminal-dock-JsMtzDao.js} +1 -1
  30. package/dist/gateway/static/root/assets/{computer-settings-page-ClSresNq.js → computer-settings-page-DHerePwo.js} +1 -1
  31. package/dist/gateway/static/root/assets/connector-service-page-DZFNUTiN.js +1 -0
  32. package/dist/gateway/static/root/assets/connectors-page-cl9ZrV4D.js +2 -0
  33. package/dist/gateway/static/root/assets/{cron-expression-CTMi_tql.js → cron-expression-DAhdv_Xv.js} +1 -1
  34. package/dist/gateway/static/root/assets/{date-picker-B71AJK50.js → date-picker-PacO1m3a.js} +1 -1
  35. package/dist/gateway/static/root/assets/{dependency-picker-DlyGK-kA.js → dependency-picker-B-BcuG1y.js} +1 -1
  36. package/dist/gateway/static/root/assets/{desktop-pet-DGkbTE8_.js → desktop-pet-CdBBhhdY.js} +1 -1
  37. package/dist/gateway/static/root/assets/{desktop-pet-settings-BY8r9j66.js → desktop-pet-settings-Gy03NgMI.js} +1 -1
  38. package/dist/gateway/static/root/assets/{device-pairing-wizard-DzRrgd59.js → device-pairing-wizard-aV25nKag.js} +1 -1
  39. package/dist/gateway/static/root/assets/{extension-debug-page-L8Mm1n3A.js → extension-debug-page-BFp5eKtY.js} +1 -1
  40. package/dist/gateway/static/root/assets/{extension-page-CFc4vSNU.js → extension-page-DL3vyyH6.js} +1 -1
  41. package/dist/gateway/static/root/assets/{extension-settings-page-B5zWyHr3.js → extension-settings-page-BXtvdAsY.js} +1 -1
  42. package/dist/gateway/static/root/assets/{gateway-config-swr-B6wHa6ZI.js → gateway-config-swr-xAOGtenO.js} +1 -1
  43. package/dist/gateway/static/root/assets/{gateway-realtime-B53R0CA4.js → gateway-realtime-BuaTsMSi.js} +1 -1
  44. package/dist/gateway/static/root/assets/gateway-realtime-store-BG95uGVW.js +1 -0
  45. package/dist/gateway/static/root/assets/{gateway-settings-D7qmTH4R.js → gateway-settings-Dcr2Ikeh.js} +1 -1
  46. package/dist/gateway/static/root/assets/{gateway-startup-retry-DRzGnEV-.js → gateway-startup-retry-BwDxKHd4.js} +1 -1
  47. package/dist/gateway/static/root/assets/{heartbeat-settings-Glsl3X5b.js → heartbeat-settings-DOy3alvT.js} +1 -1
  48. package/dist/gateway/static/root/assets/home-page-CDm3dGVy.js +1 -0
  49. package/dist/gateway/static/root/assets/{image-generation-api-Ck_pyDom.js → image-generation-api-wGMeI_yW.js} +1 -1
  50. package/dist/gateway/static/root/assets/{imports-page-ByBX7ome.js → imports-page-zexFT5Rq.js} +1 -1
  51. package/dist/gateway/static/root/assets/index-D-vczw_0.css +1 -0
  52. package/dist/gateway/static/root/assets/index-DJo4DimT.js +79 -0
  53. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-C45RlO8a.js → keyboard-shortcuts-settings-CutG9zLh.js} +1 -1
  54. package/dist/gateway/static/root/assets/{local-app-workbench-page-DP0x2jpR.js → local-app-workbench-page-CwLvTwjn.js} +2 -2
  55. package/dist/gateway/static/root/assets/{local-apps-page-C_AQc2bI.js → local-apps-page-CJy6I7Dt.js} +1 -1
  56. package/dist/gateway/static/root/assets/{locale-store-msTfRK8P.js → locale-store-DPZ79W1-.js} +1 -1
  57. package/dist/gateway/static/root/assets/{logs-page-DvM8Pyok.js → logs-page-egGcPHNi.js} +1 -1
  58. package/dist/gateway/static/root/assets/{management-settings-D1uwSutV.js → management-settings-BQhIOELc.js} +1 -1
  59. package/dist/gateway/static/root/assets/{markdown-view-BInabSKf.js → markdown-view-p2P5hP1U.js} +1 -1
  60. package/dist/gateway/static/root/assets/{media-plugins-C4mhf13f.js → media-plugins-CsBylqlN.js} +1 -1
  61. package/dist/gateway/static/root/assets/messages-BiYTyLJr.js +3 -0
  62. package/dist/gateway/static/root/assets/note-detail-panel-c2k5Uz6X.js +5 -0
  63. package/dist/gateway/static/root/assets/notes-page-BLQWJMhf.js +8 -0
  64. package/dist/gateway/static/root/assets/{page-tabs-1go_BtX1.js → page-tabs-ChQ4jJFs.js} +1 -1
  65. package/dist/gateway/static/root/assets/{preview-open-alternatives-DmoSC0j1.js → preview-open-alternatives-9B5W7nVE.js} +1 -1
  66. package/dist/gateway/static/root/assets/{proactive-page-xAjKTIID.js → proactive-page-iOjI0d_e.js} +1 -1
  67. package/dist/gateway/static/root/assets/{product-open-page-gmi5LLwM.js → product-open-page-BADxWEdP.js} +1 -1
  68. package/dist/gateway/static/root/assets/project-detail-page-BcxbQn2M.js +1 -0
  69. package/dist/gateway/static/root/assets/projects-page-BuSvld0O.js +1 -0
  70. package/dist/gateway/static/root/assets/{registry-api-BSWtko7U.js → registry-api-B_e_nZSN.js} +1 -1
  71. package/dist/gateway/static/root/assets/remote-access-hub-CFS8LQKW.js +1 -0
  72. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-ClkOoxDl.js → runtime-tools-settings-panel-D-pwiIyp.js} +1 -1
  73. package/dist/gateway/static/root/assets/{schema-form-BuEmLiaU.js → schema-form-IWmb05DX.js} +1 -1
  74. package/dist/gateway/static/root/assets/sessions-page-DZjc__ok.js +1 -0
  75. package/dist/gateway/static/root/assets/settings-advanced-gate-C1SM5B93.js +1 -0
  76. package/dist/gateway/static/root/assets/{settings-form-section-Dor39QON.js → settings-form-section-B0veRBZs.js} +1 -1
  77. package/dist/gateway/static/root/assets/{settings-page-Xj-yvIc8.js → settings-page-CxRWyWYe.js} +1 -1
  78. package/dist/gateway/static/root/assets/setup-status-panel-D9Rl7Tec.js +1 -0
  79. package/dist/gateway/static/root/assets/{share-preview-page-BFWZoXdm.js → share-preview-page-CirpgkfD.js} +1 -1
  80. package/dist/gateway/static/root/assets/shares-settings-CwCThBs0.js +1 -0
  81. package/dist/gateway/static/root/assets/skill-reload-api-DG6VGbOX.js +1 -0
  82. package/dist/gateway/static/root/assets/skills-page-BdRJ2vnL.js +2 -0
  83. package/dist/gateway/static/root/assets/{skills-page.utils-Ii8qeXhs.js → skills-page.utils-B42mpWKV.js} +1 -1
  84. package/dist/gateway/static/root/assets/{system-settings-panel-Di6OSO-0.js → system-settings-panel-DXIZpAvU.js} +1 -1
  85. package/dist/gateway/static/root/assets/task-detail-page-QXo9LJly.js +1 -0
  86. package/dist/gateway/static/root/assets/{theme-store-1SZ-HFHX.js → theme-store-BFbj_2Tu.js} +1 -1
  87. package/dist/gateway/static/root/assets/{tunnel-api-DDOlOYlj.js → tunnel-api-Db2guRdW.js} +1 -1
  88. package/dist/gateway/static/root/assets/{use-autosave-CQ8uWNnB.js → use-autosave-DDY9qoXZ.js} +1 -1
  89. package/dist/gateway/static/root/assets/user-model-page-CzPmMkaO.js +2 -0
  90. package/dist/gateway/static/root/assets/{voice-api-key-field-COTzshjL.js → voice-api-key-field-BZbKQ8HT.js} +1 -1
  91. package/dist/gateway/static/root/assets/{voice-config-api-DgJML_uM.js → voice-config-api-SKCeQLrH.js} +1 -1
  92. package/dist/gateway/static/root/assets/{work-discovery-overlay-_URrXbi4.js → work-discovery-overlay-BRVTTXNG.js} +1 -1
  93. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-CALs-1nd.js → workflow-run-setup-panel-D2kuwv5e.js} +2 -2
  94. package/dist/gateway/static/root/assets/workflows-page-CQXtiYtq.js +6 -0
  95. package/dist/gateway/static/root/index.html +12 -12
  96. package/dist/package.js +1 -1
  97. package/dist/packages/gateway-contract/src/notifications.js +1 -1
  98. package/dist/packages/gateway-contract/src/sessions.js +6 -1
  99. package/dist/src/agent/agent-manager.js +29 -4
  100. package/dist/src/agent/background-review/prompts.js +3 -1
  101. package/dist/src/agent/child-agent-factory.d.ts +1 -0
  102. package/dist/src/agent/child-agent-factory.js +18 -4
  103. package/dist/src/agent/coding/repository-instructions.d.ts +4 -0
  104. package/dist/src/agent/coding/repository-instructions.js +46 -2
  105. package/dist/src/agent/context/execution-context.js +4 -4
  106. package/dist/src/agent/data-acquisition/git.d.ts +17 -0
  107. package/dist/src/agent/data-acquisition/git.js +100 -0
  108. package/dist/src/agent/data-acquisition/render.d.ts +7 -0
  109. package/dist/src/agent/data-acquisition/render.js +79 -0
  110. package/dist/src/agent/data-acquisition/scheduler.d.ts +12 -0
  111. package/dist/src/agent/data-acquisition/scheduler.js +53 -0
  112. package/dist/src/agent/data-acquisition/schema.d.ts +75 -0
  113. package/dist/src/agent/data-acquisition/schema.js +206 -0
  114. package/dist/src/agent/data-acquisition/service.d.ts +10 -0
  115. package/dist/src/agent/data-acquisition/service.js +292 -0
  116. package/dist/src/agent/data-acquisition/types.d.ts +37 -0
  117. package/dist/src/agent/data-acquisition/types.js +5 -0
  118. package/dist/src/agent/embedded/run-turn.js +16 -4
  119. package/dist/src/agent/embedded/session-runner.d.ts +1 -0
  120. package/dist/src/agent/embedded/session-runner.js +3 -0
  121. package/dist/src/agent/embedded/tool-result-truncation.js +11 -0
  122. package/dist/src/agent/embedded/xopc-tools-bridge.js +2 -1
  123. package/dist/src/agent/external-tools/composio-provider.js +12 -1
  124. package/dist/src/agent/external-tools/gateway-tools.js +2 -1
  125. package/dist/src/agent/external-tools/index.js +8 -1
  126. package/dist/src/agent/external-tools/read-policy.d.ts +6 -0
  127. package/dist/src/agent/external-tools/read-policy.js +21 -0
  128. package/dist/src/agent/external-tools/service.d.ts +1 -0
  129. package/dist/src/agent/external-tools/service.js +4 -1
  130. package/dist/src/agent/external-tools/types.d.ts +2 -0
  131. package/dist/src/agent/memory/compaction-promotion.d.ts +1 -1
  132. package/dist/src/agent/memory/compaction-promotion.js +4 -3
  133. package/dist/src/agent/orchestration/agent-turn-policy.js +25 -10
  134. package/dist/src/agent/orchestration/delegation-scope.d.ts +9 -0
  135. package/dist/src/agent/orchestration/delegation-scope.js +11 -0
  136. package/dist/src/agent/prompt/sections/tooling.js +3 -1
  137. package/dist/src/agent/prompt/subagent-context.js +4 -2
  138. package/dist/src/agent/sandbox/fileAccess.d.ts +2 -0
  139. package/dist/src/agent/sandbox/fileAccess.js +31 -2
  140. package/dist/src/agent/tools/dataBatch.d.ts +4 -0
  141. package/dist/src/agent/tools/dataBatch.js +50 -0
  142. package/dist/src/agent/tools/delegate-tool.d.ts +6 -3
  143. package/dist/src/agent/tools/delegate-tool.js +65 -48
  144. package/dist/src/agent/tools/delegation-parent-policy.d.ts +7 -0
  145. package/dist/src/agent/tools/delegation-parent-policy.js +41 -0
  146. package/dist/src/agent/tools/delegation-policy.d.ts +16 -0
  147. package/dist/src/agent/tools/delegation-policy.js +93 -0
  148. package/dist/src/agent/tools/factory.d.ts +2 -0
  149. package/dist/src/agent/tools/factory.js +42 -3
  150. package/dist/src/agent/tools/fetch-text.d.ts +7 -0
  151. package/dist/src/agent/tools/fetch-text.js +86 -0
  152. package/dist/src/agent/tools/find.js +1 -1
  153. package/dist/src/agent/tools/grep.js +11 -23
  154. package/dist/src/agent/tools/index.d.ts +1 -0
  155. package/dist/src/agent/tools/index.js +2 -1
  156. package/dist/src/agent/tools/knowledge-memory-tool.d.ts +1 -1
  157. package/dist/src/agent/tools/knowledge-memory-tool.js +13 -5
  158. package/dist/src/agent/tools/read.js +7 -5
  159. package/dist/src/agent/tools/repository-search.d.ts +12 -2
  160. package/dist/src/agent/tools/repository-search.js +127 -74
  161. package/dist/src/agent/tools/user-context-tool.js +17 -7
  162. package/dist/src/agent/tools/web.js +19 -28
  163. package/dist/src/agent/workflow/subagent-runner.js +25 -3
  164. package/dist/src/agent/workflow/workflow-child-tools.js +13 -8
  165. package/dist/src/agent-config/schema.d.ts +7 -0
  166. package/dist/src/agent-config/schema.js +2 -0
  167. package/dist/src/chat-commands/builtins/understanding.js +1 -1
  168. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  169. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  170. package/dist/src/config/schema.d.ts +6 -4
  171. package/dist/src/config/schema.js +2 -2
  172. package/dist/src/connectors/connected-source-understanding.d.ts +1 -0
  173. package/dist/src/connectors/connected-source-understanding.js +1 -0
  174. package/dist/src/connectors/learning-coordinator.js +31 -9
  175. package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
  176. package/dist/src/gateway/heartbeat/service.js +2 -2
  177. package/dist/src/gateway/hono/lib/config-payload.d.ts +4 -2
  178. package/dist/src/gateway/hono/routes/connectors.js +1 -1
  179. package/dist/src/gateway/hono/routes/context-sources.js +0 -23
  180. package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
  181. package/dist/src/gateway/hono/routes/projects.js +8 -0
  182. package/dist/src/gateway/hono/routes/sessions.js +141 -13
  183. package/dist/src/gateway/hono/routes/user-model-refresh.d.ts +5 -0
  184. package/dist/src/gateway/hono/routes/user-model-refresh.js +128 -0
  185. package/dist/src/gateway/hono/routes/user-model.js +12 -5
  186. package/dist/src/gateway/hono/routes/work-discovery.js +0 -30
  187. package/dist/src/gateway/service.js +6 -6
  188. package/dist/src/heartbeat/index.js +1 -1
  189. package/dist/src/infra/update-restart.js +1 -1
  190. package/dist/src/knowledge/connected-knowledge-pipeline.js +1 -1
  191. package/dist/src/knowledge-memory/index.js +2 -2
  192. package/dist/src/knowledge-memory/repository.d.ts +7 -0
  193. package/dist/src/knowledge-memory/repository.js +58 -8
  194. package/dist/src/memory-maintenance/service.js +61 -31
  195. package/dist/src/migrations/memory-config.d.ts +2 -0
  196. package/dist/src/migrations/memory-config.js +77 -0
  197. package/dist/src/migrations/runner.js +2 -2
  198. package/dist/src/notifications/planner.js +5 -5
  199. package/dist/src/notifications/service.d.ts +2 -2
  200. package/dist/src/notifications/service.js +1 -1
  201. package/dist/src/storage/sqlite/index.d.ts +1 -0
  202. package/dist/src/storage/sqlite/index.js +2 -1
  203. package/dist/src/storage/sqlite/migrations/184_memory_suppressions.sql +12 -0
  204. package/dist/src/storage/sqlite/migrations/185_understanding_refresh_batches.sql +6 -0
  205. package/dist/src/storage/sqlite/migrations/186_sidebar_layout.sql +16 -0
  206. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  207. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  208. package/dist/src/storage/sqlite/schema.js +1 -1
  209. package/dist/src/storage/sqlite/sidebar-layout-repository.d.ts +12 -0
  210. package/dist/src/storage/sqlite/sidebar-layout-repository.js +53 -0
  211. package/dist/src/user-context/config.d.ts +4 -9
  212. package/dist/src/user-context/config.js +7 -27
  213. package/dist/src/user-context/memory-suppression.d.ts +7 -0
  214. package/dist/src/user-context/memory-suppression.js +23 -0
  215. package/dist/src/user-context/relationship-continuity.js +1 -1
  216. package/dist/src/user-context/sources/refresh-service.d.ts +48 -0
  217. package/dist/src/user-context/sources/refresh-service.js +221 -0
  218. package/dist/src/user-context/sources/repository.js +1 -1
  219. package/dist/src/user-model/bootstrap.js +27 -24
  220. package/dist/src/user-model/capture/executor.d.ts +1 -1
  221. package/dist/src/user-model/capture/executor.js +17 -11
  222. package/dist/src/user-model/capture/semantic.js +1 -1
  223. package/dist/src/user-model/domain.d.ts +6 -2
  224. package/dist/src/user-model/index.js +3 -3
  225. package/dist/src/user-model/profile.js +1 -1
  226. package/dist/src/user-model/repository.d.ts +4 -1
  227. package/dist/src/user-model/repository.js +96 -6
  228. package/dist/src/user-model/usage-policy.d.ts +2 -0
  229. package/dist/src/user-model/usage-policy.js +6 -2
  230. package/dist/src/work-discovery/project-understanding.js +2 -1
  231. package/dist/src/work-discovery/service.d.ts +8 -24
  232. package/dist/src/work-discovery/service.js +138 -180
  233. package/package.json +1 -1
  234. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-BPsRb9Ck.js +0 -1
  235. package/dist/gateway/static/root/assets/api-DFOlahZv.js +0 -1
  236. package/dist/gateway/static/root/assets/automations-workspace-CUpiTTiY.js +0 -6
  237. package/dist/gateway/static/root/assets/browser-settings-page-CqTxLpil.js +0 -3
  238. package/dist/gateway/static/root/assets/capabilities-settings-panel-BZ_-pnS6.js +0 -8
  239. package/dist/gateway/static/root/assets/connector-service-page-CPqVmNvx.js +0 -1
  240. package/dist/gateway/static/root/assets/connectors-page-BUQyg3CW.js +0 -2
  241. package/dist/gateway/static/root/assets/gateway-realtime-store-BLDgrJ30.js +0 -1
  242. package/dist/gateway/static/root/assets/home-page-s9hDQ8Hc.js +0 -1
  243. package/dist/gateway/static/root/assets/index-RBCkv8a_.js +0 -79
  244. package/dist/gateway/static/root/assets/index-cFU4S35z.css +0 -1
  245. package/dist/gateway/static/root/assets/messages-F74LVAiU.js +0 -3
  246. package/dist/gateway/static/root/assets/note-detail-panel-D35sErp2.js +0 -5
  247. package/dist/gateway/static/root/assets/notes-page-8jCDklDn.js +0 -8
  248. package/dist/gateway/static/root/assets/project-detail-page-BUMQHy_N.js +0 -1
  249. package/dist/gateway/static/root/assets/projects-page-DT-Mt7XR.js +0 -1
  250. package/dist/gateway/static/root/assets/remote-access-hub-Clz3byir.js +0 -1
  251. package/dist/gateway/static/root/assets/sessions-page-tQRwktKm.js +0 -1
  252. package/dist/gateway/static/root/assets/settings-advanced-gate-DqWg9XS5.js +0 -1
  253. package/dist/gateway/static/root/assets/setup-status-panel-BB_sMB7P.js +0 -1
  254. package/dist/gateway/static/root/assets/shares-settings-oDALm4b6.js +0 -1
  255. package/dist/gateway/static/root/assets/skill-reload-api-DmwelnfK.js +0 -1
  256. package/dist/gateway/static/root/assets/skills-page-BE9JXz4U.js +0 -2
  257. package/dist/gateway/static/root/assets/task-detail-page-D1AWszc7.js +0 -1
  258. package/dist/gateway/static/root/assets/user-model-page-C00i4ea0.js +0 -2
  259. package/dist/gateway/static/root/assets/workflows-page-BUiBjz6m.js +0 -6
  260. package/dist/src/migrations/knowledge-memory-read-policy-config.d.ts +0 -2
  261. package/dist/src/migrations/knowledge-memory-read-policy-config.js +0 -48
@@ -1,2 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,h as a,t as o}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{n as s,r as c,t as l}from"./popover-select-9i-ZtHXL.js";import{t as u}from"./circle-check-C23XjkUj.js";import{t as d}from"./loader-circle-CifKLtgG.js";import{t as f}from"./plus-Q2yW6OE7.js";import{t as p}from"./x-B_N4OPjy.js";import{t as m}from"./cn-JdwAhgNB.js";import{a as h,c as g,n as _,r as v}from"./locale-store-msTfRK8P.js";import{t as y}from"./messages-F74LVAiU.js";import{a as b,i as x,n as S,o as C,r as w,s as T,t as E}from"./dist-BGTk37IG.js";import{n as D}from"./copy-to-clipboard-HOJ79TWv.js";import{t as O}from"./button-CS04eWY9.js";import{n as k,r as A}from"./gateway-config-swr-B6wHa6ZI.js";import{t as j}from"./skeleton-BwbyijEw.js";import{i as M,o as N}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as P}from"./electron-env-Dit0bHgy.js";import{a as F,i as I,n as L,r as R,t as z}from"./dist-Che_jiQF.js";import{$l as B,$o as V,$s as H,Al as ee,Au as U,Bo as W,Dc as te,Eo as G,G as ne,Go as re,H as ie,Ho as ae,Jo as oe,Ko as se,Ks as ce,Mc as le,Mu as ue,Qo as de,Sn as fe,Tc as pe,U as K,Uo as q,V as me,Vc as he,Vo as ge,W as J,Wo as _e,Xi as ve,Yi as ye,Yo as be,Zc as xe,Zo as Se,_s as Ce,_u as Y,bn as X,cc as we,cu as Te,do as Ee,ds as De,es as Oe,fs as ke,gs as Ae,hs as je,ht as Me,is as Ne,kc as Pe,ku as Fe,ls as Ie,ms as Le,mt as Re,nc as ze,ns as Be,os as Ve,ps as He,pt as Ue,qo as We,rs as Ge,ss as Ke,ts as qe,us as Je,vc as Ye,vs as Xe,wc as Ze,wn as Qe,xc as $e,xl as et,xn as tt,xs as nt,yn as rt,ys as it,yu as at,zc as ot}from"./index-RBCkv8a_.js";import{t as st}from"./page-tabs-1go_BtX1.js";var Z=e(t(),1),Q=n(),$=r();function ct(e){let t=(0,Q.c)(57),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:o}=e,s,c,l,d,f,p;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==o){let e=n.capabilities.filter(lt),h=e.slice(0,2),g=Math.max(0,e.length-h.length),_=o.connect,v;t[11]!==n||t[12]!==o?(v=K(n,o),t[11]=n,t[12]=o,t[13]=v):v=t[13];let y=v,b=n.verificationLevel===`verified`?o.connectorVerified:n.verificationLevel===`beta`?o.connectorBeta:n.verificationLevel===`experimental`?o.connectorExperimental:null,x;t[14]!==_||t[15]!==n||t[16]!==i?(x=e=>(0,$.jsxs)(O,{type:`button`,variant:`primary`,className:m(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:()=>i(n),children:[(0,$.jsx)(xe,{className:`size-4`}),_]}),t[14]=_,t[15]=n,t[16]=i,t[17]=x):x=t[17],s=x,p=`group flex min-h-[8.75rem] flex-col rounded-xl border border-edge bg-surface-panel p-4 transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,c=`flex min-w-0 flex-1 flex-col`;let S;t[18]===n?S=t[19]:(S=(0,$.jsx)(ne,{connector:n}),t[18]=n,t[19]=S);let C;t[20]!==n||t[21]!==a?(C=a?(0,$.jsx)(`button`,{type:`button`,className:`block max-w-full truncate text-left text-sm font-semibold text-fg hover:underline`,onClick:()=>a(n),children:n.displayName}):(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[20]=n,t[21]=a,t[22]=C):C=t[22];let w;t[23]===b?w=t[24]:(w=b?(0,$.jsx)(`span`,{className:`mt-1 inline-flex rounded-full border border-edge px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:b}):null,t[23]=b,t[24]=w);let T;t[25]!==w||t[26]!==C?(T=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[C,w]}),t[25]=w,t[26]=C,t[27]=T):T=t[27];let E;t[28]!==T||t[29]!==S?(E=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[S,T]}),t[28]=T,t[29]=S,t[30]=E):E=t[30];let D;t[31]!==r||t[32]!==s?(D=r?null:(0,$.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 sm:flex`,children:s()}),t[31]=r,t[32]=s,t[33]=D):D=t[33];let k;t[34]!==r||t[35]!==o.connectedBadge?(k=r?(0,$.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,$.jsx)(u,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[34]=r,t[35]=o.connectedBadge,t[36]=k):k=t[36];let A;t[37]!==D||t[38]!==k?(A=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[D,k]}),t[37]=D,t[38]=k,t[39]=A):A=t[39],t[40]!==E||t[41]!==A?(l=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[E,A]}),t[40]=E,t[41]=A,t[42]=l):l=t[42],t[43]===y?d=t[44]:(d=(0,$.jsx)(`p`,{className:`mt-3 line-clamp-2 text-sm leading-6 text-fg-muted`,title:y,children:y}),t[43]=y,t[44]=d),f=h.length>0?(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[h.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:o.connectorCapabilityLabels[e]??e},e)),g>0?(0,$.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,g]}):null]}):null,t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=d,t[9]=f,t[10]=p}else s=t[5],c=t[6],l=t[7],d=t[8],f=t[9],p=t[10];let h;t[45]!==c||t[46]!==l||t[47]!==d||t[48]!==f?(h=(0,$.jsxs)(`div`,{className:c,children:[l,d,f]}),t[45]=c,t[46]=l,t[47]=d,t[48]=f,t[49]=h):h=t[49];let g;t[50]!==r||t[51]!==s?(g=r?null:(0,$.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:s(`w-full`)}),t[50]=r,t[51]=s,t[52]=g):g=t[52];let _;return t[53]!==p||t[54]!==h||t[55]!==g?(_=(0,$.jsxs)(`div`,{className:p,children:[h,g]}),t[53]=p,t[54]=h,t[55]=g,t[56]=_):_=t[56],_}function lt(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var ut=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function dt(e,t){return t.some(t=>t.connectorId===e.id)}var ft=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function pt(){let e=(0,Q.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:m(`size-10 shrink-0 rounded-xl`,ft)}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.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,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:m(`h-4 min-w-0 flex-1`,ft)}),(0,$.jsx)(`div`,{className:m(`h-8 w-[4.5rem] shrink-0 rounded-lg`,ft)})]}),(0,$.jsx)(`div`,{className:m(`h-3 w-full`,ft)}),(0,$.jsx)(`div`,{className:m(`h-3 w-[88%]`,ft)})]})]})}),e[1]=n):n=e[1],n}var mt=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function ht(){let e=(0,Q.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:m(`size-10 shrink-0 rounded-xl`,mt)}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,$.jsx)(`div`,{className:m(`h-4 w-48 max-w-full`,mt)}),(0,$.jsx)(`div`,{className:m(`h-3 w-72 max-w-full`,mt)})]}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-start justify-between gap-3`,children:[n,(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,$.jsx)(`div`,{className:m(`h-9 w-20 rounded-lg`,mt)}),(0,$.jsx)(`div`,{className:m(`h-9 w-20 rounded-lg`,mt)})]})]})]}),e[2]=r):r=e[2];let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:[r,(0,$.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,$.jsx)(`div`,{className:m(`h-8 w-20 rounded-md`,mt)}),(0,$.jsx)(`div`,{className:m(`h-8 w-24 rounded-md`,mt)}),(0,$.jsx)(`div`,{className:m(`h-8 w-28 rounded-md`,mt)})]}),(0,$.jsx)(`div`,{className:m(`mt-3 h-20 rounded-xl`,mt)})]}),e[3]=i):i=e[3],i}var gt=[`understand`,`act`,`reach`];function _t(e){if(e.benefits?.length)return[...new Set(e.benefits)];let t=new Set(e.capabilities),n=[e.id,e.displayName,...e.tags??[]].join(` `).toLowerCase(),r=[];return(t.has(`context`)||t.has(`memory_source`)||t.has(`resources`)||e.category===`docs`||e.category===`data`||/notion|drive|document|confluence|airtable|database|knowledge|wiki/.test(n))&&r.push(`understand`),t.has(`tools`)&&r.push(`act`),(t.has(`channel`)||/slack|telegram|discord|teams|mail|message|wechat|weixin/.test(n))&&r.push(`reach`),r.length?[...new Set(r)]:[`act`]}function vt(e){return _t(e)[0]??`act`}function yt(e,t){let n=t?vt(t):`act`,r=e.connectionStatus===`connected`||e.status===`connected`||e.usage.lastHealthStatus===`ok`,i=e.status===`not_configured`||e.status===`failed`||e.status===`degraded`||e.status===`unauthorized`||e.connectionStatus===`unauthorized`||e.connectionStatus===`error`,a=n===`understand`?e.usage.lastResourceCount:n===`act`?e.usage.lastToolCount:void 0;return{benefit:n,state:r?`ready`:i?`needs_setup`:`checking`,availableCount:a}}function bt(e,t){return t.connectorCapabilityLabels[e]??e}function xt(e,t){if(e.runtime.type===`mcp`)return J(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.type===`composio`?e.runtime.toolkit:e.runtime.sourceKind;return J(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n??e.runtime.type})}function St(e,t){return e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function Ct(e){let t=(0,Q.c)(9),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,$.jsx)(`h4`,{className:`mb-2 text-xs font-medium text-fg-muted`,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]===a?o=t[5]:(o=(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-lg border border-edge bg-surface-panel`,children:a}),t[4]=a,t[5]=o);let s;return t[6]!==i||t[7]!==o?(s=(0,$.jsxs)(`section`,{children:[i,o]}),t[6]=i,t[7]=o,t[8]=s):s=t[8],s}function wt(e){return(0,$.jsxs)(`div`,{className:`px-3 py-2.5`,children:[(0,$.jsx)(`p`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function Tt({connector:e,installed:t,onClose:n,onInstall:r,t:i}){let[a,o]=(0,Z.useState)(!1),s=K(e,i),[c,l]=(0,Z.useState)(null),[f,h]=(0,Z.useState)(null),g=_t(e),_=[...(e.setup.secrets??[]).filter(e=>e.required),...(e.setup.config??[]).filter(e=>e.required)],v=e.capabilities.filter(e=>!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)),y=async()=>{o(!0),h(null);try{l(await Ge(e))}catch(e){l(null),h(e instanceof Error?e.message:String(e))}finally{o(!1)}};return(0,$.jsx)(E,{open:!0,onOpenChange:e=>{e||n()},children:(0,$.jsxs)(C,{children:[(0,$.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(w,{className:m(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,42rem)] w-[min(100%-2rem,min(92vw,44rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-float outline-none dark:border-edge`),children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-5 py-5 sm:px-6`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(ne,{connector:e,size:`lg`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(T,{className:`text-base font-semibold text-fg`,children:e.displayName}),t?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(u,{className:`size-3`,"aria-hidden":!0}),i.connectedBadge]}):null]}),(0,$.jsx)(x,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:s})]})]}),(0,$.jsx)(S,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:m(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,nt.focusRingPanel),"aria-label":i.modalClose,children:(0,$.jsx)(p,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-5 sm:px-6`,children:[g.length?(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.connectorWhyConnect}),(0,$.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:g.map(e=>(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:i.connectorBenefitHeadings[e]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:i.connectorBenefitHints[e]})]},e))})]}):null,(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,$.jsx)(ee,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:i.detailPermissions}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:St(e,i)})]})]}),(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:i.connectorSetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:_.length?J(i.connectorRequiredInputsCount,{count:String(_.length)}):i.connectorSetupNone})]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:i.connectorTechnicalDetails}),(0,$.jsxs)(`div`,{className:`space-y-5 border-t border-edge-subtle px-4 py-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,$.jsx)(pe,{className:`size-3.5`,"aria-hidden":!0}),i.connectorRuntimeTitle]}),(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-subtle`,children:xt(e,i)})]}),v.length?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:v.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:bt(e,i)},e))}):null,(0,$.jsxs)(O,{variant:`secondary`,disabled:a,onClick:()=>void y(),children:[a?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(ce,{className:`size-4`}),i.connectorPreviewButton]}),f?(0,$.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:f}):null,c?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(Ct,{title:i.detailTools,items:c.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,$.jsx)(Ct,{title:i.detailResources,items:c.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description}))}),(0,$.jsx)(Ct,{title:i.detailPrompts,items:c.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description}))})]}):null]})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4 sm:px-6`,children:[(0,$.jsx)(S,{asChild:!0,children:(0,$.jsx)(O,{variant:`secondary`,children:i.modalClose})}),t?null:(0,$.jsxs)(O,{variant:`primary`,onClick:()=>{r(e),n()},children:[(0,$.jsx)(xe,{className:`size-4`}),i.connect]})]})]})]})})}var Et=m(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,G);function Dt(e){let t=(0,Q.c)(58),{open:n,sessionIdleTtlMinutes:r,saving:i,onChange:a,onSave:o,onClose:s,t:c,mcp:l}=e,u;t[0]===s?u=t[1]:(u=e=>{e||s()},t[0]=s,t[1]=u);let f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[2]=f):f=t[2];let h;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(h=m(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(32rem,calc(100vh-2rem))] w-[min(100%-2rem,38rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-float dark:border-edge`),t[3]=h):h=t[3];let g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,$.jsx)(ot,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})}),t[4]=g):g=t[4];let _;t[5]===c.runtimeSettingsTitle?_=t[6]:(_=(0,$.jsx)(T,{className:`text-base font-semibold text-fg`,children:c.runtimeSettingsTitle}),t[5]=c.runtimeSettingsTitle,t[6]=_);let v;t[7]===c.runtimeSettingsHint?v=t[8]:(v=(0,$.jsx)(x,{className:`mt-1 text-sm text-fg-muted`,children:c.runtimeSettingsHint}),t[7]=c.runtimeSettingsHint,t[8]=v);let y;t[9]!==_||t[10]!==v?(y=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[g,(0,$.jsxs)(`div`,{className:`min-w-0`,children:[_,v]})]}),t[9]=_,t[10]=v,t[11]=y):y=t[11];let D;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(D=m(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,nt.focusRingPanel),t[12]=D):D=t[12];let k;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(p,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=k):k=t[13];let A;t[14]===c.modalClose?A=t[15]:(A=(0,$.jsx)(S,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:D,"aria-label":c.modalClose,children:k})}),t[14]=c.modalClose,t[15]=A);let j;t[16]!==A||t[17]!==y?(j=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[y,A]}),t[16]=A,t[17]=y,t[18]=j):j=t[18];let M;t[19]===l.idleTtlLabel?M=t[20]:(M=(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:l.idleTtlLabel}),t[19]=l.idleTtlLabel,t[20]=M);let N;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(N=m(Et,`w-40 flex-none`),t[21]=N):N=t[21];let P=r??``,F;t[22]===a?F=t[23]:(F=e=>{let t=e.currentTarget.value.trim();a(t===``?void 0:Number.parseInt(t,10))},t[22]=a,t[23]=F);let I;t[24]!==l.idleTtlPlaceholder||t[25]!==P||t[26]!==F?(I=(0,$.jsx)(`input`,{type:`number`,min:0,className:N,value:P,placeholder:l.idleTtlPlaceholder,onChange:F}),t[24]=l.idleTtlPlaceholder,t[25]=P,t[26]=F,t[27]=I):I=t[27];let L;t[28]===l.idleTtlHint?L=t[29]:(L=(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:l.idleTtlHint}),t[28]=l.idleTtlHint,t[29]=L);let R;t[30]!==M||t[31]!==I||t[32]!==L?(R=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,$.jsxs)(`label`,{className:`flex max-w-xl flex-col gap-1.5`,children:[M,I,L]})}),t[30]=M,t[31]=I,t[32]=L,t[33]=R):R=t[33];let z;t[34]!==s||t[35]!==i||t[36]!==c.modalCancel?(z=(0,$.jsx)(O,{type:`button`,variant:`secondary`,disabled:i,onClick:s,children:c.modalCancel}),t[34]=s,t[35]=i,t[36]=c.modalCancel,t[37]=z):z=t[37];let B;t[38]===o?B=t[39]:(B=()=>void o(),t[38]=o,t[39]=B);let V;t[40]===i?V=t[41]:(V=i?(0,$.jsx)(d,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[40]=i,t[41]=V);let H;t[42]!==l.save||t[43]!==i||t[44]!==B||t[45]!==V?(H=(0,$.jsxs)(O,{type:`button`,variant:`primary`,disabled:i,onClick:B,children:[V,l.save]}),t[42]=l.save,t[43]=i,t[44]=B,t[45]=V,t[46]=H):H=t[46];let ee;t[47]!==z||t[48]!==H?(ee=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[z,H]}),t[47]=z,t[48]=H,t[49]=ee):ee=t[49];let U;t[50]!==j||t[51]!==R||t[52]!==ee?(U=(0,$.jsxs)(C,{children:[f,(0,$.jsxs)(w,{className:h,children:[j,R,ee]})]}),t[50]=j,t[51]=R,t[52]=ee,t[53]=U):U=t[53];let W;return t[54]!==n||t[55]!==u||t[56]!==U?(W=(0,$.jsx)(E,{open:n,onOpenChange:u,children:U}),t[54]=n,t[55]=u,t[56]=U,t[57]=W):W=t[57],W}var Ot=(0,Z.memo)(function(e){let t=(0,Q.c)(12),{value:n,onChange:r,placeholder:i,className:a}=e,o;t[0]===a?o=t[1]:(o=m(`relative flex min-h-11 sm:min-h-9 min-w-0 flex-1 cursor-text items-center rounded-pill border border-edge bg-surface-panel py-1.5 pl-9 pr-3 focus-within:ring-2 focus-within:ring-accent`,a),t[0]=a,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(te,{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[2]=s):s=t[2];let c;t[3]===r?c=t[4]:(c=e=>r(e.currentTarget.value),t[3]=r,t[4]=c);let l;t[5]!==i||t[6]!==c||t[7]!==n?(l=(0,$.jsx)(`input`,{type:`search`,"aria-label":i,enterKeyHint:`search`,value:n,onChange:c,placeholder:i,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-base sm: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[5]=i,t[6]=c,t[7]=n,t[8]=l):l=t[8];let u;return t[9]!==o||t[10]!==l?(u=(0,$.jsxs)(`label`,{className:o,children:[s,l]}),t[9]=o,t[10]=l,t[11]=u):u=t[11],u}),kt=(0,Z.memo)(function(e){let t=(0,Q.c)(25),{onBrowseCatalog:n,onAddCustomServer:r,addLabel:i,browseLabel:a,customLabel:s}=e,c=_(At)===`zh`?`应用连接服务`:`Connection service`,l;t[0]===c?l=t[1]:(l=(0,$.jsx)(o,{to:`/settings/connector-service`,className:`text-xs text-fg-muted hover:text-fg`,children:c}),t[0]=c,t[1]=l);let u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(f,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=u):u=t[2];let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(ue,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[3]=d):d=t[3];let p;t[4]===i?p=t[5]:(p=(0,$.jsx)(Qe,{asChild:!0,children:(0,$.jsxs)(O,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,children:[u,i,d]})}),t[4]=i,t[5]=p);let h;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(h=m(`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,nt.transition),t[6]=h):h=t[6];let g;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(we,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[7]=g):g=t[7];let v;t[8]!==a||t[9]!==n?(v=(0,$.jsxs)(X,{className:h,onSelect:n,children:[g,a]}),t[8]=a,t[9]=n,t[10]=v):v=t[10];let y;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(y=m(`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,nt.transition),t[11]=y):y=t[11];let b;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(ce,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=b):b=t[12];let x;t[13]!==s||t[14]!==r?(x=(0,$.jsxs)(X,{className:y,onSelect:r,children:[b,s]}),t[13]=s,t[14]=r,t[15]=x):x=t[15];let S;t[16]!==x||t[17]!==v?(S=(0,$.jsx)(tt,{children:(0,$.jsxs)(rt,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[v,x]})}),t[16]=x,t[17]=v,t[18]=S):S=t[18];let C;t[19]!==S||t[20]!==p?(C=(0,$.jsxs)(fe,{children:[p,S]}),t[19]=S,t[20]=p,t[21]=C):C=t[21];let w;return t[22]!==C||t[23]!==l?(w=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[l,C]}),t[22]=C,t[23]=l,t[24]=w):w=t[24],w});function At(e){return e.language}var jt=/^([^:=]+)[:=](.*)$/;function Mt(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=jt.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 Pt(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 Ft(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 It(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)||Ft(t)&&(r[e]=t);return r}function Lt(e){let t=e.trim();if(t)return t.split(/\s+/).filter(Boolean)}function Rt(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 zt(e){if(e.transport===`stdio`){let t={command:e.command.trim()},n=Lt(e.argsText);return n?.length&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envJson.trim()&&(t.env=Rt(e.envJson)),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),e.requestTimeoutMs!=null&&Number.isFinite(e.requestTimeoutMs)&&(t.requestTimeoutMs=e.requestTimeoutMs),t}let t={url:e.url.trim(),transport:e.transport},n=Nt(e.headers);return n&&(t.headers=n),e.transport===`streamable-http`&&e.auth===`oauth`&&(t.auth={type:`oauth`,...e.oauthClientId.trim()?{clientId:e.oauthClientId.trim()}:{}}),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),e.requestTimeoutMs!=null&&Number.isFinite(e.requestTimeoutMs)&&(t.requestTimeoutMs=e.requestTimeoutMs),t}function Bt(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,o=t.auth&&typeof t.auth==`object`&&!Array.isArray(t.auth)?t.auth:void 0,s=o?.type===`oauth`?`oauth`:`none`;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:Pt(a),auth:s,oauthClientId:typeof o?.clientId==`string`?o.clientId:``,connectionTimeoutMs:typeof t.connectionTimeoutMs==`number`&&Number.isFinite(t.connectionTimeoutMs)?t.connectionTimeoutMs:void 0,requestTimeoutMs:typeof t.requestTimeoutMs==`number`&&Number.isFinite(t.requestTimeoutMs)?t.requestTimeoutMs:void 0}}function Vt(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`stdio`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[{key:`Authorization`,value:``}],auth:`none`,oauthClientId:``,connectionTimeoutMs:void 0,requestTimeoutMs:void 0}}function Ht(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)||Ft(t)?[]:[Bt(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 Ut(e){return zt(e)}async function Wt(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]=zt(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 h(v(`/api/config`),{method:`PATCH`,body:JSON.stringify({mcp:r})}),k()}async function Gt(e,t,n=``){let r=await h(v(`/api/mcp/servers/${encodeURIComponent(e)}/oauth${n}`),{method:t});if(!r.payload)throw Error(r.error??`MCP OAuth request failed`);return r.payload}function Kt(e){return Gt(e,`GET`)}function qt(e){return Gt(e,`POST`,`/start`)}function Jt(e){return Gt(e,`DELETE`)}function Yt(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();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 Xt(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 Zt(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 Qt(e,t){let n=await h(v(`/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=Yt(n.payload.tools),i=Xt(n.payload.resources),a=Zt(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 $t(e){return e.connectionTimeoutMs==null||!Number.isFinite(e.connectionTimeoutMs)?``:String(Math.round(e.connectionTimeoutMs/1e3))}function en(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 tn(e){return e.requestTimeoutMs==null||!Number.isFinite(e.requestTimeoutMs)?``:String(Math.round(e.requestTimeoutMs/1e3))}function nn(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);if(!(!Number.isFinite(n)||n<1||n>14400))return n*1e3}function rn(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 an({row:e,t,cs:n,onEdit:r,onRemove:i}){let[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(!1),b=rn(e),x=e.transport===`streamable-http`&&e.auth===`oauth`;(0,Z.useEffect)(()=>{if(!x){_(null);return}let t=!1,n=async()=>{try{let n=await Kt(e.id.trim());t||(_(n),n.status===`error`&&n.session?.error&&h(n.session.error),n.status===`connected`&&h(null))}catch(e){t||h(e instanceof Error?e.message:String(e))}};n();let r=window.setInterval(()=>{g?.status===`authorizing`&&n()},1e3);return()=>{t=!0,window.clearInterval(r)}},[g?.status,e.id,x]);let S=(0,Z.useCallback)(async()=>{y(!0),h(null);let n=Me();try{let r=await qt(e.id.trim());_(r),r.status===`error`&&r.session?.error&&h(r.session.error),r.status===`connected`&&h(null);let i=r.session?.authorizationUrl;i?await Re(i,n)||h(t.oauthOpenFailed):Ue(n)}catch(e){Ue(n),h(e instanceof Error?e.message:String(e))}finally{y(!1)}},[e.id,t.oauthOpenFailed]),C=(0,Z.useCallback)(async()=>{y(!0),h(null);try{_(await Jt(e.id.trim()))}catch(e){h(e instanceof Error?e.message:String(e))}finally{y(!1)}},[e.id]),w=(0,Z.useCallback)(async()=>{o(!0),h(null);try{let t=await Qt(e.id.trim());p({toolCount:t.toolCount,resourceCount:t.resourceCount,promptCount:t.promptCount})}catch(e){h(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.id]),T=(0,Z.useCallback)(async()=>{c(!0),h(null);try{await i()}catch(e){h(e instanceof Error?e.message:String(e)),c(!1)}},[i]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`px-4 py-3.5 hover:bg-surface-hover/50`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`block w-full min-w-0 text-left`,onClick:r,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.id.trim()||t.cardUntitled}),(0,$.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:n.customBadge}),(0,$.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]}),x&&g?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:t.oauthStatus[g.status===`not_configured`?`disconnected`:g.status]}):null]}),b?(0,$.jsx)(`p`,{className:`mt-3 line-clamp-2 break-all font-mono text-xs leading-5 text-fg-subtle`,title:b,children:b}):null,m?(0,$.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:m}):null,f?(0,$.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:J(n.customCapabilitySummary,{tools:String(f.toolCount),resources:String(f.resourceCount),prompts:String(f.promptCount)})}):null]}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[x&&g?.status!==`connected`?(0,$.jsxs)(O,{variant:`secondary`,disabled:v,onClick:()=>void S(),children:[v?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(et,{className:`size-4`}),g?.status===`authorizing`?t.oauthOpenAuthorization:t.oauthConnect]}):(0,$.jsxs)(O,{variant:`secondary`,disabled:a,onClick:()=>void w(),children:[a?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(he,{className:`size-4`}),t.testConnection]}),x&&g?.status===`connected`?(0,$.jsxs)(O,{variant:`ghost`,disabled:v,onClick:()=>void C(),children:[v?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(H,{className:`size-4`}),t.oauthDisconnect]}):null,(0,$.jsxs)(O,{variant:`ghost`,disabled:s,onClick:()=>u(!0),children:[s?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(ze,{className:`size-4`}),t.removeServer]})]})]}),(0,$.jsx)(ve,{open:l,title:n.removeConfirmTitle.replace(`{{name}}`,e.id.trim()||t.cardUntitled),description:n.removeConfirmDescription,confirmLabel:t.removeServer,cancelLabel:n.modalCancel,destructive:!0,onConfirm:()=>{u(!1),T()},onCancel:()=>{s||u(!1)}})]})}function on(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function sn(e,t,n){let r=t.trim().toLowerCase();if(!r)return!0;let i=e.shortName||on(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
2
- `).toLowerCase().includes(r)}function cn(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function ln(e){let t=(0,Q.c)(29),{tools:n,stripPrefix:r,searchPlaceholder:i,searchEmptyLabel:a}=e,[o,s]=(0,Z.useState)(``),c;if(t[0]!==o||t[1]!==r||t[2]!==n){let e;t[4]!==o||t[5]!==r?(e=e=>sn(e,o,r),t[4]=o,t[5]=r,t[6]=e):e=t[6],c=n.filter(e),t[0]=o,t[1]=r,t[2]=n,t[3]=c}else c=t[3];let l=c,u;t[7]===o?u=t[8]:(u=o.trim(),t[7]=o,t[8]=u);let d=u.length>0,f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(te,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=f):f=t[9];let p,h;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(p=m(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg`,`placeholder:text-fg-subtle`,G),h=e=>s(e.target.value),t[10]=p,t[11]=h):(p=t[10],h=t[11]);let g;t[12]!==o||t[13]!==i?(g=(0,$.jsxs)(`div`,{className:`relative`,children:[f,(0,$.jsx)(`input`,{type:`search`,value:o,placeholder:i,"aria-label":i,className:p,onChange:h})]}),t[12]=o,t[13]=i,t[14]=g):g=t[14];let _;t[15]!==l.length||t[16]!==d||t[17]!==n.length?(_=d?(0,$.jsxs)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:[l.length,` / `,n.length]}):null,t[15]=l.length,t[16]=d,t[17]=n.length,t[18]=_):_=t[18];let v;t[19]!==g||t[20]!==_?(v=(0,$.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 y;t[22]!==l||t[23]!==a||t[24]!==r?(y=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:l.length===0?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-2`,children:l.map((e,t)=>{let n=e.shortName||cn(e.name,r)||e.name||`?`,i=e.name||`tool-${t}`;return(0,$.jsxs)(`li`,{className:`min-w-0 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[(0,$.jsx)(`div`,{className:`truncate font-mono text-sm font-medium text-fg`,title:e.name===n?n:e.name,children:n}),e.description?(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs leading-relaxed text-fg-muted`,title:e.description,children:e.description}):null]},i)})})}),t[22]=l,t[23]=a,t[24]=r,t[25]=y):y=t[25];let b;return t[26]!==v||t[27]!==y?(b=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=b):b=t[28],b}function un(e){let t=(0,Q.c)(38),{open:n,onOpenChange:r,serverId:i,title:a,subtitle:o,searchPlaceholder:s,searchEmptyLabel:c,emptyLabel:l,closeLabel:u,tools:d,stripPrefix:f}=e,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(b,{className:m(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,N)}),t[0]=h):h=t[0];let g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=m(`xopc-dialog-content 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`,M,`rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none dark:border-edge`),t[1]=g):g=t[1];let _;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(ce,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[2]=_):_=t[2];let v;t[3]===a?v=t[4]:(v=(0,$.jsxs)(T,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[_,a]}),t[3]=a,t[4]=v);let y;t[5]!==i||t[6]!==o||t[7]!==d.length?(y=o.replace(`{{serverId}}`,i).replace(`{{count}}`,String(d.length)),t[5]=i,t[6]=o,t[7]=d.length,t[8]=y):y=t[8];let D;t[9]===y?D=t[10]:(D=(0,$.jsx)(x,{className:`mt-1 text-sm text-fg-muted`,children:y}),t[9]=y,t[10]=D);let k;t[11]!==v||t[12]!==D?(k=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[v,D]}),t[11]=v,t[12]=D,t[13]=k):k=t[13];let A;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(p,{className:`size-4`,"aria-hidden":!0}),t[14]=A):A=t[14];let j;t[15]===u?j=t[16]:(j=(0,$.jsx)(S,{asChild:!0,children:(0,$.jsx)(O,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":u,children:A})}),t[15]=u,t[16]=j);let P;t[17]!==k||t[18]!==j?(P=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[k,j]}),t[17]=k,t[18]=j,t[19]=P):P=t[19];let F;t[20]!==l||t[21]!==n||t[22]!==c||t[23]!==s||t[24]!==i||t[25]!==f||t[26]!==d?(F=d.length>0?(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,$.jsx)(ln,{tools:d,stripPrefix:f,searchPlaceholder:s,searchEmptyLabel:c},`${i}-${n?`open`:`closed`}`)}):(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l})}),t[20]=l,t[21]=n,t[22]=c,t[23]=s,t[24]=i,t[25]=f,t[26]=d,t[27]=F):F=t[27];let I;t[28]===u?I=t[29]:(I=(0,$.jsx)(`div`,{className:`flex justify-end border-t border-edge px-5 py-3`,children:(0,$.jsx)(S,{asChild:!0,children:(0,$.jsx)(O,{type:`button`,variant:`secondary`,children:u})})}),t[28]=u,t[29]=I);let L;t[30]!==P||t[31]!==F||t[32]!==I?(L=(0,$.jsxs)(C,{children:[h,(0,$.jsxs)(w,{className:g,children:[P,F,I]})]}),t[30]=P,t[31]=F,t[32]=I,t[33]=L):L=t[33];let R;return t[34]!==r||t[35]!==n||t[36]!==L?(R=(0,$.jsx)(E,{open:n,onOpenChange:r,children:L}),t[34]=r,t[35]=n,t[36]=L,t[37]=R):R=t[37],R}function dn(e){let t=e.connectedAt?Date.parse(e.connectedAt):0;return Number.isFinite(t)?t:0}function fn(e,t){return e.status===`active`&&t.status!==`active`?-1:e.status!==`active`&&t.status===`active`?1:e.isCurrentAuthorization===t.isCurrentAuthorization?dn(t)-dn(e):e.isCurrentAuthorization?-1:1}function pn(e){let t=new Map;for(let n of e){let e=n.accountId??n.identityKey??`authorization:${n.id}`;t.set(e,[...t.get(e)??[],n])}return[...t.entries()].map(([e,t])=>{let n=[...t].sort(fn);return{key:e,primary:n[0],authorizations:n}}).sort((e,t)=>fn(e.primary,t.primary))}var mn=m(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,G);function hn(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function gn(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function _n(e,t,n){return e.status===`connected`?J(n.composioHealthConnected,{count:String(t)}):e.status===`reauthorization_required`?n.composioHealthReconnect:e.status===`disconnected`?n.composioHealthDisconnected:e.errorCode===`missing_credential`?n.composioHealthMissingCredential:e.errorCode===`unauthorized`?n.composioHealthUnauthorized:e.errorCode===`forbidden`?n.composioHealthForbidden:e.errorCode===`network`?n.composioHealthNetwork:e.errorCode===`timeout`?n.composioHealthTimeout:n.composioHealthDegraded}function vn(e,t){return e===`active`?t.composioConnectionHealthy:e===`pending`?t.composioConnectionPending:e===`expired`?t.composioConnectionExpired:e===`failed`?t.composioConnectionFailed:e===`revoked`||e===`disabled`?t.composioConnectionRevoked:t.composioConnectionUnknown}function yn(e,t,n){return e.status===`paused`?t?.scanEnabled===!1?n.connectorLearningPausedByPolicy:n.connectorLearningPausedByFailure:e.status===`queued`?n.connectorLearningQueued:e.status===`running`?n.connectorLearningRunning:e.status===`completed`?n.connectorLearningCompleted:n.connectorLearningFailed}function bn({instance:e,t,onChanged:n}){let r=hn(e),i=_(e=>e.language)===`zh`,[a,o]=(0,Z.useState)([]),[l,f]=(0,Z.useState)([]),[p,h]=(0,Z.useState)([]),[g,v]=(0,Z.useState)(null),[y,b]=(0,Z.useState)([]),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)([]),[D,k]=(0,Z.useState)({}),[A,M]=(0,Z.useState)(`read`),[N,F]=(0,Z.useState)(!1),[I,L]=(0,Z.useState)(null),[R,z]=(0,Z.useState)(!1),[B,H]=(0,Z.useState)(null),[U,te]=(0,Z.useState)(null),[G,ne]=(0,Z.useState)(!1),[re,ie]=(0,Z.useState)(!1),[ae,ce]=(0,Z.useState)(!1),ue=(0,Z.useRef)(0),fe=(0,Z.useRef)(0),pe=(0,Z.useMemo)(()=>pn(a),[a]),K=(0,Z.useCallback)(e=>new Promise((t,n)=>{let r=window.setTimeout(()=>n(Error(i?`连接服务响应超时,请重试。`:`The connection service timed out. Please retry.`)),15e3);e.then(t,n).finally(()=>window.clearTimeout(r))}),[i]),q=(0,Z.useCallback)(async()=>{if(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)return;F(!0),L(null);let t=++ue.current;try{let e=(await Promise.allSettled([K(V()).then(e=>{t===ue.current&&(o(e.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),ne(!0))}),K(be(r)).then(e=>{t===ue.current&&M(e)}),K(oe(r)).then(e=>{t===ue.current&&(v(e.policy),b(e.agents))})])).find(e=>e.status===`rejected`);t===ue.current&&e?.status===`rejected`&&L(String(e.reason instanceof Error?e.reason.message:e.reason))}finally{t===ue.current&&F(!1)}},[e.materialized,r,K]);(0,Z.useEffect)(()=>(q(),()=>{ue.current++}),[q]);let me=(0,Z.useCallback)(async()=>{if(!r)return;let e=++fe.current;ce(!0),z(!1);let t=t=>n=>{e===fe.current&&t(n)},n=await Promise.allSettled([K(Oe(r)).then(t(f)),K(qe(20)).then(t(e=>h(e.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())))),K(Se(r)).then(t(w)),K(We(r)).then(t(S))]);e===fe.current&&(z(n.some(e=>e.status===`rejected`)),ce(!1))},[r,K]);(0,Z.useEffect)(()=>(re&&me(),()=>{fe.current++}),[re,me]),(0,Z.useEffect)(()=>{let e=!1,t=pn(a).map(e=>e.primary).filter(e=>e.supportsLearning&&e.accountId);if(t.length)return K(Be()).then(t=>{e||E(t)}).catch(()=>{}),Promise.allSettled(t.map(async e=>[e.accountId,await K(de(e.accountId))])).then(t=>{e||k(Object.fromEntries(t.flatMap(e=>e.status===`fulfilled`?[e.value]:[])))}),()=>{e=!0}},[a,K]);let he=(0,Z.useCallback)(async t=>{if(!r)return;let i=P()?null:window.open(`about:blank`,`_blank`);i&&(i.opener=null),F(!0),L(null);try{if(!P()&&!i)throw Error(`Allow popups to open the authorization page.`);let a=await De(e.connectorId,t);if(!a.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if(P()){let e=await window.electronAPI?.shell?.openExternalUrl(a.authorizationUrl);if(!e?.ok)throw Error(e?.error??`Could not open the system browser.`)}else i.location.href=a.authorizationUrl;let o=await it(r,a.connectionId,12e4,a.attemptId);if(t&&o.accountId!==t)throw Error(`A different account was authorized. The original account and its task bindings were not changed.`);await Promise.all([n?.(),q()])}catch(e){L(e instanceof Error?e.message:String(e))}finally{i?.close(),F(!1)}},[e.connectorId,q,n,r]),ge=(0,Z.useCallback)(async t=>{F(!0),L(null);try{await Ce(e.instanceId,{config:{...e.config??{},authConfigId:t||void 0}}),await Promise.all([n?.(),q()])}catch(e){L(e instanceof Error?e.message:String(e))}finally{F(!1)}},[e.config,e.instanceId,q,n]),_e=async e=>{let t=P()?null:window.open(`about:blank`,`_blank`);t&&(t.opener=null),L(null);try{let n=await se(e.id);if(n.authorizationUrl)if(P())await window.electronAPI?.shell?.openExternalUrl(n.authorizationUrl);else if(t)t.location.href=n.authorizationUrl;else throw Error(`Allow popups to reopen authorization.`);else t?.close(),await q()}catch(e){t?.close(),L(e instanceof Error?e.message:String(e))}},ye=(0,Z.useCallback)(async e=>{if(r){M(e),L(null);try{await Ie(r,e)}catch(e){L(e instanceof Error?e.message:String(e)),await q()}}},[q,r]),xe=(0,Z.useCallback)(async e=>{if(r){L(null);try{v(await Ae(r,e))}catch(e){L(e instanceof Error?e.message:String(e))}}},[r]),Y=(0,Z.useCallback)(e=>{if(!g)return;let t=g.allowedAgentIds.includes(e);t&&g.allowedAgentIds.length===1||xe({allowedAgentIds:t?g.allowedAgentIds.filter(t=>t!==e):[...g.allowedAgentIds,e]})},[xe,g]),X=(0,Z.useCallback)(async e=>{F(!0),L(null);try{await e(),await q()}catch(e){L(e instanceof Error?e.message:String(e))}finally{F(!1)}},[q]);if(!r)return null;if(e.materialized.type===`composio`&&e.materialized.role===`credential`)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioApiKeyStored});let we=pe.filter(e=>e.primary.status===`active`).length,Te=we>0?t.composioAddAccount:t.composioConnectAccount,Ee=G&&we>0,ke=C?.requiresCustomAuthConfig===!0,Me=C?.authConfigs.filter(e=>e.status===`ENABLED`&&e.isEnabledForToolRouter)??[];return(0,$.jsxs)(`div`,{className:`space-y-5`,children:[(0,$.jsxs)(`section`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`span`,{className:m(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,Ee?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:[Ee?(0,$.jsx)(u,{className:`size-3.5`}):(0,$.jsx)(Fe,{className:`size-3.5`}),Ee?t.connectionReady:G||I?t.connectionNeedsSetup:t.connectionChecking]}),G&&(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:J(t.composioAccountCount,{count:String(pe.length)})})]}),(0,$.jsxs)(O,{variant:`primary`,className:`shrink-0`,disabled:N,onClick:()=>void he(),children:[N?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(ee,{className:`size-4`}),Te]})]}),I?(0,$.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center justify-between gap-2 rounded-xl border border-danger/20 bg-danger/5 px-3 py-2 text-sm text-danger`,children:[(0,$.jsx)(`p`,{children:I}),(0,$.jsx)(O,{variant:`secondary`,disabled:N,onClick:()=>void q(),children:t.composioRetry})]}):null,x&&!Ee?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-amber-500/25 bg-amber-500/5 p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:_n(x,we,t)}),x.recovery===`none`?null:(0,$.jsx)(O,{variant:`secondary`,disabled:N,onClick:()=>void(x.recovery===`retry`?q():he()),children:x.recovery===`retry`?t.composioRetry:t.composioReconnectAccount})]}):null,ke&&Me.length===0?(0,$.jsx)(`p`,{className:`rounded-xl border border-amber-500/25 bg-amber-500/5 px-4 py-3 text-sm text-amber-800 dark:text-amber-200`,children:t.composioAuthConfigEmpty}):null,g?(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle px-4 py-4 sm:grid-cols-[minmax(0,1fr)_15rem] sm:items-start`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAccessTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:A===`read`?t.composioAccessReadHint:A===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,$.jsxs)(s,{value:A,onChange:e=>void ye(e.currentTarget.value),children:[(0,$.jsx)(c,{value:`read`,children:t.composioAccessReadOnly}),(0,$.jsx)(c,{value:`write`,children:t.composioAccessReadWrite}),A===`admin`?(0,$.jsx)(c,{value:`admin`,children:t.composioAccessAdminCurrent}):null]})]}),(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm text-fg-muted`,children:t.composioAdvancedSettings}),(0,$.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle px-4 py-4 sm:grid-cols-[minmax(0,1fr)_15rem] sm:items-center`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioConfirmationPolicy}),(0,$.jsxs)(s,{value:g.confirmationPolicy,onChange:e=>void xe({confirmationPolicy:e.currentTarget.value}),children:[(0,$.jsx)(c,{value:`writes`,children:t.composioConfirmWrites}),(0,$.jsx)(c,{value:`always`,children:t.composioConfirmAlways}),g.confirmationPolicy===`never`?(0,$.jsx)(c,{value:`never`,children:t.composioConfirmNever}):null]})]}),(0,$.jsxs)(`div`,{className:`px-4 py-4`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAllowedAgents}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:g.allowedAgentIds.length?t.composioAllowedAgentsSelected:t.composioAllowedAgentsAll}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,className:m(`rounded-full border px-2.5 py-1 text-xs transition-colors`,g.allowedAgentIds.length===0?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>void xe({allowedAgentIds:[]}),children:t.composioAllowedAgentsAllOption}),y.map(e=>(0,$.jsx)(`button`,{type:`button`,className:m(`rounded-full border px-2.5 py-1 text-xs transition-colors`,g.allowedAgentIds.includes(e.id)?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>Y(e.id),children:e.name},e.id))]})]}),(0,$.jsxs)(`fieldset`,{className:`space-y-2 border-t border-edge-subtle p-4 text-xs text-fg-muted`,children:[(0,$.jsx)(`legend`,{children:i?`可用账号范围`:`Available accounts`}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:g.selectedAccountIds===null,disabled:N,onChange:e=>void xe({selectedAccountIds:e.currentTarget.checked?null:[]})}),i?`所有账号(包括以后新增)`:`All accounts, including new ones`]}),g.selectedAccountIds!==null&&pe.map(({primary:e})=>e.accountId&&(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:N,checked:g.selectedAccountIds.includes(e.accountId),onChange:t=>void xe({selectedAccountIds:t.currentTarget.checked?[...g.selectedAccountIds,e.accountId]:g.selectedAccountIds.filter(t=>t!==e.accountId)})}),e.alias??e.accountEmail??e.accountId]},e.accountId)),g.selectedAccountIds?.length===0&&(0,$.jsx)(`p`,{children:i?`未选择账号,Agent 无法使用此应用。`:`No accounts selected. Agents cannot use this app.`})]})]})]}):null,(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.composioConnectedAccounts}),G&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:J(t.composioAccountCount,{count:String(pe.length)})})]}),(0,$.jsxs)(O,{variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:N,onClick:()=>void q(),children:[(0,$.jsx)(le,{className:m(`size-3.5`,N&&`animate-spin`)}),t.refresh]})]}),pe.length?(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:pe.map(e=>{let r=e.primary,a=T.find(e=>r.accountId?e.accountId===r.accountId:e.connectionId===r.id),o=r.accountId?D[r.accountId]:void 0;return(0,$.jsxs)(`article`,{className:`px-4 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-start justify-between gap-3 sm:flex-row`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,$.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:r.alias??r.workspace??r.accountEmail??r.username??t.composioUnnamedAuthorization})}),(0,$.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:r.accountEmail??r.username??r.workspace??r.accountId}),r.backendLabel&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.backendLabel}),(0,$.jsx)(`p`,{className:m(`mt-1 text-xs`,r.status===`active`?`text-emerald-700 dark:text-emerald-300`:`text-amber-700 dark:text-amber-300`),children:r.accountEnabled===!1?i?`已暂停`:`Paused`:vn(r.status,t)}),a?(0,$.jsx)(`p`,{className:m(`mt-1 text-xs`,a.status===`failed`?`text-red-600`:`text-fg-subtle`),children:J(t.connectorLearningStatus,{status:yn(a,o,t),count:String(a.candidatesCreated)})}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[r.status===`pending`&&(0,$.jsx)(O,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,onClick:()=>void _e(r),children:i?`继续授权`:`Continue authorization`}),r.accountId&&(0,$.jsx)(O,{variant:`ghost`,className:`h-8 px-2.5 text-xs text-danger`,disabled:N,onClick:()=>te(r.accountId),children:i?`断开`:`Disconnect`}),r.accountId&&r.status!==`active`&&(0,$.jsx)(O,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:N,onClick:()=>void he(r.accountId),children:t.composioReconnectAccount}),r.accountId&&(0,$.jsx)(O,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:N,onClick:()=>void X(()=>Le(r.accountId,{enabled:r.accountEnabled===!1})),children:r.accountEnabled===!1?i?`启用`:`Enable`:i?`暂停`:`Pause`}),r.supportsLearning&&r.status===`active`&&r.accountEnabled!==!1?(0,$.jsxs)(O,{variant:`secondary`,className:`h-8 shrink-0 px-2.5 text-xs`,disabled:N,onClick:()=>void X(async()=>{if(!r.accountId)throw Error(`Connector account is unavailable.`);await Je(r.accountId),await n?.()}),children:[(0,$.jsx)(le,{className:`size-3.5`}),t.composioSyncNow]}):null]})]}),(0,$.jsxs)(`details`,{className:`mt-3 text-xs text-fg-muted`,children:[(0,$.jsx)(`summary`,{className:`w-fit cursor-pointer font-medium hover:text-fg`,children:t.composioAccountSettings}),(0,$.jsxs)(`div`,{className:`mt-3 space-y-4 rounded-lg bg-surface-panel p-3`,children:[r.accountId&&(0,$.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,$.jsx)(`legend`,{className:`mb-2 font-medium`,children:t.composioAllowedAgents}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:N,checked:r.allowedAgentIds==null,onChange:e=>void X(()=>Le(r.accountId,{allowedAgentIds:e.currentTarget.checked?null:[]}))}),t.composioAllowedAgentsAllOption]}),r.allowedAgentIds!=null&&y.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:N,checked:r.allowedAgentIds.includes(e.id),onChange:t=>{let n=t.currentTarget.checked;X(()=>Le(r.accountId,{allowedAgentIds:n?[...r.allowedAgentIds,e.id]:r.allowedAgentIds.filter(t=>t!==e.id)}))}}),e.name]},e.id)),r.allowedAgentIds?.length===0&&(0,$.jsx)(`p`,{children:i?`未选择 Agent:任何 Agent 都不能使用此账号。`:`No agents selected: this account is unavailable to all agents.`})]}),r.supportsLearning&&o?(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:o.scanEnabled,disabled:N,onChange:e=>void X(()=>Xe(r.accountId,{scanEnabled:e.currentTarget.checked}))}),t.connectorScheduledScan]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:o.proactiveEnabled,disabled:N||!o.scanEnabled,onChange:e=>void X(()=>Xe(r.accountId,{proactiveEnabled:e.currentTarget.checked}))}),t.connectorProactiveUse]}),o.scanEnabled?(0,$.jsxs)(`label`,{className:`sm:col-span-2`,children:[t.connectorScanInterval,(0,$.jsxs)(s,{className:`mt-1`,value:String(o.intervalMinutes??30),disabled:N,onChange:e=>void X(()=>Xe(r.accountId,{intervalMinutes:Number(e.currentTarget.value)})),children:[(0,$.jsxs)(c,{value:`5`,children:[`5 `,t.connectorMinutes]}),(0,$.jsxs)(c,{value:`15`,children:[`15 `,t.connectorMinutes]}),(0,$.jsxs)(c,{value:`30`,children:[`30 `,t.connectorMinutes]}),(0,$.jsxs)(c,{value:`60`,children:[`60 `,t.connectorMinutes]})]})]}):null]}):null,(0,$.jsxs)(`label`,{className:`block`,children:[t.composioAccountAlias,(0,$.jsx)(`input`,{className:m(mn,`mt-1 h-8 py-1 text-xs`),defaultValue:r.alias??``,onBlur:e=>{e.currentTarget.value!==(r.alias??``)&&X(()=>je(r.id,{alias:e.currentTarget.value}))}})]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:e.authorizations.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`p`,{className:`min-w-0 break-all font-mono text-fg-subtle`,children:[t.composioAuthorizationId,`: `,e.providerConnectionId]}),(0,$.jsx)(O,{variant:`ghost`,className:`size-7 shrink-0 p-0 text-danger`,title:t.composioRevoke,disabled:N,onClick:()=>H(e.id),children:(0,$.jsx)(ze,{className:`size-3.5`})})]},e.id))}),(0,$.jsx)(`div`,{className:`flex justify-end gap-1`,children:(0,$.jsx)(O,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:N,onClick:()=>void X(()=>Ne(r.id)),children:(0,$.jsx)(le,{className:`size-4`})})})]})]})]},e.key)})}):N&&!G?(0,$.jsxs)(`div`,{"aria-busy":`true`,"aria-label":t.connectionChecking,className:`space-y-3`,children:[(0,$.jsx)(j,{className:`h-16 w-full`}),(0,$.jsx)(j,{className:`h-16 w-full`})]}):G?(0,$.jsx)(`div`,{className:`rounded-xl border border-dashed border-edge px-4 py-8 text-center`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioConnectionsEmpty})}):null]}),(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-base`,onToggle:e=>ie(e.currentTarget.open),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:t.composioAdvancedSettings}),(0,$.jsxs)(`div`,{className:`space-y-5 border-t border-edge-subtle px-4 py-4`,children:[ae?(0,$.jsx)(j,{"aria-label":t.connectionChecking,className:`h-16 w-full`}):null,R?(0,$.jsxs)(`p`,{className:`rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-200`,children:[t.composioDiagnosticsUnavailable,(0,$.jsx)(O,{variant:`ghost`,disabled:ae,onClick:()=>void me(),children:t.composioRetry})]}):null,C?.mode===`byok`?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAuthConfigTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:ke?t.composioAuthConfigRequiredHint:t.composioAuthConfigOptionalHint})]}),(0,$.jsx)(`a`,{className:`text-xs font-medium text-accent-fg hover:underline`,href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,children:t.composioAuthConfigManage})]}),(0,$.jsxs)(s,{className:`mt-3`,value:typeof e.config?.authConfigId==`string`?e.config.authConfigId:``,disabled:N,onChange:e=>void ge(e.currentTarget.value),children:[ke?null:(0,$.jsx)(c,{value:``,children:t.composioAuthConfigManaged}),ke&&typeof e.config?.authConfigId!=`string`?(0,$.jsx)(c,{value:``,disabled:!0,children:t.composioAuthConfigSelect}):null,Me.map(e=>(0,$.jsxs)(c,{value:e.id,children:[e.name,` · `,e.authScheme??`OAuth`]},e.id))]})]}):null,(0,$.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),(0,$.jsx)(`div`,{className:`space-y-2`,children:l.length?l.slice(0,8).map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:[gn(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),(0,$.jsx)(`div`,{className:`space-y-2`,children:p.length?p.slice(0,5).map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})})]})]})]})]}),(0,$.jsx)(ve,{open:U!==null,title:i?`断开账号`:`Disconnect account`,description:i?`停止此账号的工具使用和学习,并撤销其全部授权。已保存的数据不会删除。`:`Stop tool access and learning for this account and revoke all its authorizations. Saved data will not be deleted.`,confirmLabel:i?`断开`:`Disconnect`,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=U;te(null),e&&X(()=>W(e))},onCancel:()=>te(null)}),(0,$.jsx)(ve,{open:B!==null,title:t.composioRevoke,description:t.composioRevokeConfirm,confirmLabel:t.composioRevoke,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=B;H(null),e&&X(()=>Ke(e))},onCancel:()=>H(null)})]})}var xn=m(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,G);function Sn(e,t){return e?t.healthStatusLabels[e]??e:t.healthNotTested}function Cn(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 wn(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 Tn(e){let t=(0,Q.c)(12),{title:n,description:r,meta:i}=e,a;t[0]===r?a=t[1]:(a=r?(0,$.jsx)(R,{delayDuration:300,skipDelayDuration:100,children:(0,$.jsxs)(I,{children:[(0,$.jsx)(F,{asChild:!0,children:(0,$.jsx)(`p`,{tabIndex:0,title:r,className:m(`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,$.jsx)(L,{children:(0,$.jsx)(z,{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,$.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:r})})})]})}):null,t[0]=r,t[1]=a);let o=a,s;t[2]===n?s=t[3]:(s=(0,$.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]=s);let c;t[4]===i?c=t[5]:(c=i?(0,$.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] leading-4 text-fg-subtle`,children:i}):null,t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;return t[9]!==o||t[10]!==l?(u=(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[l,o]}),t[9]=o,t[10]=l,t[11]=u):u=t[11],u}function En({instance:e,definition:t,onClose:n,onChanged:r,t:i,mcp:a}){let[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),[u,f]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),[y,D]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(`health`),[N,P]=(0,Z.useState)(!1),[F,I]=(0,Z.useState)(()=>Cn(t,e)),[L,R]=(0,Z.useState)(null),z=t?.setup.config??[],V=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&z.length>0&&(t?.setup.secrets??[]).length===0,H=k?k.toolCount:e.usage.lastToolCount,U=e.materialized.type===`mcp`,W=e.materialized.type===`composio`,te=e.materialized.type===`memorySource`,G=t?K(t,i):null,re=(0,Z.useMemo)(()=>{let t=[[`health`,$e,i.detailHealth],[`tools`,ce,`${i.detailTools} ${k?k.toolCount:e.usage.lastToolCount??``}`],[`resources`,Te,`${i.detailResources} ${k?k.resourceCount:e.usage.lastResourceCount??``}`],[`prompts`,B,`${i.detailPrompts} ${k?k.promptCount:e.usage.lastPromptCount??``}`],[`permissions`,ee,i.detailPermissions]];return V?[...t,[`config`,Te,i.connectorConfigLabel]]:t},[k,e.usage.lastPromptCount,e.usage.lastResourceCount,e.usage.lastToolCount,V,i]),ie=(0,Z.useCallback)(async()=>{s(!0),R(null);try{let t=await He(e.instanceId);A(t),t.toolCount>0&&M(`tools`),r()}catch(e){R(e instanceof Error?e.message:String(e))}finally{s(!1)}},[e.instanceId,r]),ae=(0,Z.useCallback)(async()=>{l(!0),R(null);try{await Ve(e.instanceId),await r(),n()}catch(e){R(e instanceof Error?e.message:String(e)),l(!1)}},[e.instanceId,r,n]),oe=(0,Z.useCallback)(async()=>{if(!(!t||!V)){g(!0),R(null);try{let n={};for(let e of t.setup.config??[]){let t=wn(e.type,F[e.key]??``);t!==void 0&&(n[e.key]=t)}await Ce(e.instanceId,{config:n}),await r(),M(`health`)}catch(e){R(e instanceof Error?e.message:String(e))}finally{g(!1)}}},[F,t,e.instanceId,r,V]),se=(0,Z.useCallback)(async()=>{v(!0),D(null),R(null);try{D((await ke(e.connectorId)).recordIds.length),await r()}catch(e){R(e instanceof Error?e.message:String(e))}finally{v(!1)}},[e.connectorId,r]);return(0,$.jsxs)(E,{open:!0,onOpenChange:e=>{e||n()},children:[(0,$.jsxs)(C,{children:[(0,$.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(w,{className:m(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,W?`h-[min(100dvh-2rem,36rem)] w-[min(100%-2rem,40rem)]`:`h-[min(100dvh-2rem,44rem)] w-[min(100%-2rem,min(92vw,54rem))]`,`rounded-2xl border border-edge bg-surface-overlay shadow-float outline-none dark:border-edge`),children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(ne,{connector:t,size:`lg`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(T,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,$.jsx)(x,{className:`mt-1 text-sm text-fg-muted`,children:G??(e.materialized.type===`mcp`?J(i.mcpServerRuntime,{serverId:e.materialized.serverId}):J(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,$.jsx)(S,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:m(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,nt.focusRingPanel),"aria-label":i.modalClose,children:[(0,$.jsx)(p,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[L?(0,$.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:L}):null,U?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:re.map(([e,t,n])=>(0,$.jsxs)(`button`,{type:`button`,className:m(`inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs`,j===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:text-fg`),onClick:()=>M(e),children:[(0,$.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),n]},e))}),(0,$.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[j===`health`?(0,$.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,$.jsxs)(`p`,{children:[i.statusLabel,` `,(0,$.jsx)(`span`,{className:k?.ok?`font-medium text-emerald-700 dark:text-emerald-300`:`font-medium text-fg`,children:Sn(k?.status??e.usage.lastHealthStatus,i)})]}),(0,$.jsxs)(`p`,{children:[i.lastCheckLabel,` `,e.usage.lastHealthCheckAt?new Date(e.usage.lastHealthCheckAt).toLocaleString():i.never]}),k?.action?(0,$.jsx)(`p`,{children:k.action}):null]}):null,j===`tools`?k?.tools.length?(0,$.jsxs)(`div`,{className:`grid gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:J(i.toolsAvailable,{count:String(k.tools.length)})}),(0,$.jsx)(O,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>P(!0),children:a.viewAllTools})]}),(0,$.jsx)(`div`,{className:`grid gap-2`,children:k.tools.slice(0,8).map(e=>(0,$.jsx)(Tn,{title:e.shortName??e.name,description:e.description},e.name))})]}):(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-fg-muted`,children:H?J(i.toolsLastCheckSummary,{count:String(H)}):i.toolsRunTestHint}),(0,$.jsxs)(O,{type:`button`,variant:`secondary`,disabled:o,onClick:()=>void ie(),children:[o?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(he,{className:`size-4`}),i.test]})]}):null,j===`resources`?k?.resources.length?(0,$.jsx)(`div`,{className:`grid gap-2`,children:k.resources.slice(0,8).map(e=>(0,$.jsx)(Tn,{title:e.title??e.name,description:e.uri,meta:e.mimeType},e.uri))}):(0,$.jsx)(`p`,{className:`text-fg-muted`,children:i.resourcesRunTestHint}):null,j===`prompts`?k?.prompts.length?(0,$.jsx)(`div`,{className:`grid gap-2`,children:k.prompts.slice(0,8).map(e=>(0,$.jsx)(Tn,{title:e.title??e.name,description:e.description,meta:e.argumentCount?J(i.promptArgumentCount,{count:String(e.argumentCount)}):void 0},e.name))}):(0,$.jsx)(`p`,{className:`text-fg-muted`,children:i.promptsRunTestHint}):null,j===`permissions`?(0,$.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,$.jsx)(`p`,{children:J(i.secretsConfigured,{count:String(Object.values(e.secretStatus).filter(Boolean).length)})}),(0,$.jsx)(`p`,{children:e.materialized.type===`mcp`?J(i.runtimeServerLabel,{runtime:e.materialized.type.toUpperCase(),serverId:e.materialized.serverId}):J(i.runtimeLabel,{runtime:e.materialized.type.toUpperCase()})}),(0,$.jsx)(`p`,{children:e.materialized.type===`mcp`?i.mcpPolicyHint:i.connectorPolicyHint})]}):null,j===`config`&&V?(0,$.jsx)(`div`,{className:`grid gap-3`,children:z.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,$.jsx)(`input`,{className:xn,value:F[e.key]??``,placeholder:e.placeholder,onChange:t=>I(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]})]}):null,W?(0,$.jsx)(bn,{instance:e,t:i,onChanged:r}):null,te?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl border border-edge bg-surface-base p-4 text-sm`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:i.connectedSourceSync}),G?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:G}):null,y===null?null:(0,$.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:J(i.connectedSourceSynced,{count:String(y)})})]}),(0,$.jsxs)(O,{disabled:_,onClick:()=>void se(),children:[_?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(Te,{className:`size-4`}),i.composioSyncNow]})]}),V?(0,$.jsx)(`div`,{className:`grid gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:z.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,$.jsx)(`input`,{className:xn,value:F[e.key]??``,placeholder:e.placeholder,onChange:t=>I(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}):null,!U&&!W&&!te?(0,$.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:(0,$.jsx)(`p`,{children:i.connectorPolicyHint})}):null,(0,$.jsxs)(`details`,{className:`mt-5 rounded-xl border border-edge`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-danger`,children:i.dangerZone}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 border-t border-danger/15 px-4 py-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:i.removeConnectorHint}),(0,$.jsxs)(O,{variant:`secondary`,className:`shrink-0 border-danger/30 text-danger hover:bg-danger/10`,disabled:c,onClick:()=>f(!0),children:[c?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(ze,{className:`size-4`}),i.remove]})]})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,$.jsx)(O,{variant:`secondary`,onClick:n,children:i.modalClose}),(U&&j===`config`||te)&&V?(0,$.jsxs)(O,{variant:`primary`,disabled:h,onClick:()=>void oe(),children:[h?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(Pe,{className:`size-4`}),i.modalSave]}):null,U?(0,$.jsxs)(O,{variant:`secondary`,disabled:o,onClick:()=>void ie(),children:[o?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(he,{className:`size-4`}),i.test]}):null]})]})]}),e.materialized.type===`mcp`?(0,$.jsx)(un,{open:N,onOpenChange:P,serverId:e.materialized.serverId,title:J(i.installedToolsDialogTitle,{name:e.displayName}),subtitle:i.installedToolsDialogSubtitle,searchPlaceholder:a.toolsDialogSearchPlaceholder,searchEmptyLabel:a.toolsDialogSearchEmpty,emptyLabel:i.toolsRunTestHint,closeLabel:a.toolsDialogClose,tools:k?.tools??[],stripPrefix:`${e.materialized.serverId}__`}):null,(0,$.jsx)(ve,{open:u,title:J(i.removeConfirmTitle,{name:e.displayName}),description:i.removeConfirmDescription,confirmLabel:i.removeConfirmAction,cancelLabel:i.modalCancel,destructive:!0,onConfirm:()=>{f(!1),ae()},onCancel:()=>{c||f(!1)}})]})}function Dn(e){let t=(0,Q.c)(55),{instance:n,definition:r,highlighted:i,onOpenDetails:a,t:o}=e,s=i===void 0?!1:i,c;t[0]!==r||t[1]!==n?(c=yt(n,r),t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c.state,d;t[3]!==r||t[4]!==o?(d=r?K(r,o):null,t[3]=r,t[4]=o,t[5]=d):d=t[5];let f=d,p,h,g,_,v,y,b,x,S;if(t[6]!==l||t[7]!==r||t[8]!==s||t[9]!==n||t[10]!==a||t[11]!==o.connectionChecking||t[12]!==o.connectionNeedsSetup||t[13]!==o.connectionReady){p=l===`ready`?{label:o.connectionReady,Icon:u,className:`text-emerald-700 dark:text-emerald-300`}:l===`needs_setup`?{label:o.connectionNeedsSetup,Icon:Fe,className:`text-amber-700 dark:text-amber-300`}:{label:o.connectionChecking,Icon:Y,className:`text-fg-muted`},x=`button`;let e=s&&`bg-accent-soft`;t[23]===e?S=t[24]:(S=m(`flex w-full items-center gap-3 px-4 py-3.5 text-left hover:bg-surface-hover/60`,`rounded-none first:rounded-t-[calc(var(--radius-xl)-1px)] last:rounded-b-[calc(var(--radius-xl)-1px)]`,nt.transition,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,e),t[23]=e,t[24]=S),t[25]!==n||t[26]!==a?(h=()=>a(n),t[25]=n,t[26]=a,t[27]=h):h=t[27],t[28]===r?g=t[29]:(g=(0,$.jsx)(ne,{connector:r}),t[28]=r,t[29]=g),b=`min-w-0 flex-1`,v=`flex min-w-0 items-center gap-2`,t[30]===n.displayName?y=t[31]:(y=(0,$.jsx)(`h3`,{className:`truncate text-sm font-medium text-fg`,children:n.displayName}),t[30]=n.displayName,t[31]=y),_=m(`inline-flex shrink-0 items-center gap-1 text-xs font-medium`,p.className),t[6]=l,t[7]=r,t[8]=s,t[9]=n,t[10]=a,t[11]=o.connectionChecking,t[12]=o.connectionNeedsSetup,t[13]=o.connectionReady,t[14]=p,t[15]=h,t[16]=g,t[17]=_,t[18]=v,t[19]=y,t[20]=b,t[21]=x,t[22]=S}else p=t[14],h=t[15],g=t[16],_=t[17],v=t[18],y=t[19],b=t[20],x=t[21],S=t[22];let C;t[32]===p.Icon?C=t[33]:(C=(0,$.jsx)(p.Icon,{className:`size-3.5`,"aria-hidden":!0}),t[32]=p.Icon,t[33]=C);let w;t[34]!==p.label||t[35]!==C||t[36]!==_?(w=(0,$.jsxs)(`span`,{className:_,children:[C,p.label]}),t[34]=p.label,t[35]=C,t[36]=_,t[37]=w):w=t[37];let T;t[38]!==w||t[39]!==v||t[40]!==y?(T=(0,$.jsxs)(`div`,{className:v,children:[y,w]}),t[38]=w,t[39]=v,t[40]=y,t[41]=T):T=t[41];let E;t[42]===f?E=t[43]:(E=f?(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:f}):null,t[42]=f,t[43]=E);let D;t[44]!==T||t[45]!==E||t[46]!==b?(D=(0,$.jsxs)(`div`,{className:b,children:[T,E]}),t[44]=T,t[45]=E,t[46]=b,t[47]=D):D=t[47];let O;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(U,{className:`size-4 shrink-0 text-fg-disabled`,"aria-hidden":!0}),t[48]=O):O=t[48];let k;return t[49]!==h||t[50]!==g||t[51]!==D||t[52]!==x||t[53]!==S?(k=(0,$.jsxs)(`button`,{type:x,className:S,onClick:h,children:[g,D,O]}),t[49]=h,t[50]=g,t[51]=D,t[52]=x,t[53]=S,t[54]=k):k=t[54],k}function On(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 Vt(r)}function kn(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 An(){return m(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,G)}function jn({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:i,pasteFailed:a,keyPlaceholder:o,valuePlaceholder:s,headers:c,onChange:l}){let u=(e,t)=>{l(c.map((n,r)=>r===e?{...n,...t}:n))},d=()=>{l([...c,{key:``,value:``}])},f=e=>{let t=c.filter((t,n)=>n!==e);l(t.length>0?t:[{key:``,value:``}])},p=async()=>{try{let e=await D();if(!e){window.alert(a);return}let t=Mt(e);if(!t?.length){window.alert(a);return}l(t)}catch{window.alert(a)}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:e}),t?(0,$.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),(0,$.jsxs)(O,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void p(),children:[(0,$.jsx)(at,{className:`size-3.5`,"aria-hidden":!0}),i]})]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:c.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{className:m(An(),`min-w-0 flex-1 font-mono text-xs`),value:e.key,placeholder:o,onChange:e=>u(t,{key:e.target.value})}),(0,$.jsx)(`input`,{className:m(An(),`min-w-0 flex-[1.4] font-mono text-xs`),value:e.value,placeholder:s,onChange:e=>u(t,{value:e.target.value})}),(0,$.jsx)(O,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:c.length<=1&&!e.key&&!e.value,onClick:()=>f(t),"aria-label":r,children:(0,$.jsx)(ze,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})})]},kn(e,t,c)))}),(0,$.jsxs)(`button`,{type:`button`,className:m(`self-start text-sm text-accent hover:underline`,nt.press),onClick:d,children:[`+ `,n]})]})}var Mn=[`stdio`,`sse`,`streamable-http`],Nn=[`none`,`oauth`];function Pn(e){let t=(0,Q.c)(11),{label:n,description:r,required:i,children:a}=e,o;t[0]===i?o=t[1]:(o=i?(0,$.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,$.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,$.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,$.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 Fn(){return m(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,G)}function In(e){let t=(0,Q.c)(37),{row:n,t:r,onUpdate:i,idConflictMessage:a,variant:o}=e,l=o===void 0?`all`:o,u=l===`all`||l===`basic`,d=l===`all`||l===`advanced`,f;t[0]!==a||t[1]!==i||t[2]!==n.id||t[3]!==n.transport||t[4]!==u||t[5]!==r?(f=u?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Pn,{label:r.transportLabel,required:!0,children:(0,$.jsx)(s,{className:Fn(),value:n.transport,onChange:e=>i({transport:e.target.value}),children:Mn.map(e=>(0,$.jsx)(c,{value:e,children:r.transportLabels[e]},e))})}),(0,$.jsxs)(Pn,{label:r.serverIdLabel,required:!0,children:[(0,$.jsx)(`input`,{className:Fn(),value:n.id,placeholder:r.serverIdPlaceholder,onChange:e=>i({id:e.target.value})}),a?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-300`,children:a}):null]})]}):null,t[0]=a,t[1]=i,t[2]=n.id,t[3]=n.transport,t[4]=u,t[5]=r,t[6]=f):f=t[6];let p;t[7]!==i||t[8]!==n.argsText||t[9]!==n.auth||t[10]!==n.command||t[11]!==n.cwd||t[12]!==n.envJson||t[13]!==n.headers||t[14]!==n.oauthClientId||t[15]!==n.transport||t[16]!==n.url||t[17]!==d||t[18]!==u||t[19]!==r||t[20]!==l?(p=n.transport===`stdio`?(0,$.jsxs)($.Fragment,{children:[u?(0,$.jsx)(`div`,{className:l===`basic`?`md:col-span-2`:void 0,children:(0,$.jsx)(Pn,{label:r.commandLabel,required:!0,children:(0,$.jsx)(`input`,{className:Fn(),value:n.command,onChange:e=>i({command:e.target.value})})})}):null,d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Pn,{label:r.argsLabel,description:r.argsHint,children:(0,$.jsx)(`input`,{className:Fn(),value:n.argsText,onChange:e=>i({argsText:e.target.value})})}),(0,$.jsx)(Pn,{label:r.cwdLabel,children:(0,$.jsx)(`input`,{className:Fn(),value:n.cwd,onChange:e=>i({cwd:e.target.value})})}),(0,$.jsx)(Pn,{label:r.envLabel,description:r.envHint,children:(0,$.jsx)(`textarea`,{className:m(Fn(),`min-h-[4rem] font-mono text-xs`),value:n.envJson,onChange:e=>i({envJson:e.target.value})})})]}):null]}):(0,$.jsxs)($.Fragment,{children:[u?(0,$.jsx)(`div`,{className:`md:col-span-2`,children:(0,$.jsx)(Pn,{label:r.urlLabel,required:!0,children:(0,$.jsx)(`input`,{className:m(Fn(),`font-mono text-xs`),value:n.url,placeholder:`https://example.com/mcp`,onChange:e=>i({url:e.target.value})})})}):null,u&&n.transport===`streamable-http`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Pn,{label:r.authLabel,description:r.authHint,children:(0,$.jsx)(s,{className:Fn(),value:n.auth,onChange:e=>{let t=e.target.value;i({auth:t,headers:t===`oauth`?n.headers.filter(Rn):n.headers})},children:Nn.map(e=>(0,$.jsx)(c,{value:e,children:r.authLabels[e]},e))})}),n.auth===`oauth`?(0,$.jsx)(Pn,{label:r.oauthClientIdLabel,description:r.oauthClientIdHint,children:(0,$.jsx)(`input`,{className:m(Fn(),`font-mono text-xs`),value:n.oauthClientId,placeholder:r.oauthClientIdPlaceholder,onChange:e=>i({oauthClientId:e.target.value})})}):null]}):null,d?(0,$.jsx)(jn,{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=>i({headers:n.auth===`oauth`?e.filter(Ln):e})}):null]}),t[7]=i,t[8]=n.argsText,t[9]=n.auth,t[10]=n.command,t[11]=n.cwd,t[12]=n.envJson,t[13]=n.headers,t[14]=n.oauthClientId,t[15]=n.transport,t[16]=n.url,t[17]=d,t[18]=u,t[19]=r,t[20]=l,t[21]=p):p=t[21];let h;t[22]!==i||t[23]!==n||t[24]!==d||t[25]!==r?(h=d?(0,$.jsx)(Pn,{label:r.timeoutLabel,description:r.timeoutHint,children:(0,$.jsx)(`input`,{type:`number`,min:1,max:600,className:Fn(),value:$t(n),placeholder:r.timeoutPlaceholder,onChange:e=>i({connectionTimeoutMs:en(e.target.value)})})}):null,t[22]=i,t[23]=n,t[24]=d,t[25]=r,t[26]=h):h=t[26];let g;t[27]!==i||t[28]!==n||t[29]!==d||t[30]!==r?(g=d?(0,$.jsx)(Pn,{label:r.requestTimeoutLabel,description:r.requestTimeoutHint,children:(0,$.jsx)(`input`,{type:`number`,min:1,max:14400,className:Fn(),value:tn(n),placeholder:r.requestTimeoutPlaceholder,onChange:e=>i({requestTimeoutMs:nn(e.target.value)})})}):null,t[27]=i,t[28]=n,t[29]=d,t[30]=r,t[31]=g):g=t[31];let _;return t[32]!==f||t[33]!==p||t[34]!==h||t[35]!==g?(_=(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[f,p,h,g]}),t[32]=f,t[33]=p,t[34]=h,t[35]=g,t[36]=_):_=t[36],_}function Ln(e){return e.key.trim().toLowerCase()!==`authorization`}function Rn(e){return e.key.trim().toLowerCase()!==`authorization`}function zn(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 Bn(e){let t=(0,Q.c)(13),{tool:n,serverId:r}=e,i;t[0]!==r||t[1]!==n?(i=zn(n,r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o=n.name===a?a:n.name,s;t[3]===n.description?s=t[4]:(s=n.description?.trim(),t[3]=n.description,t[4]=s);let c=s,l;t[5]!==a||t[6]!==o?(l=(0,$.jsx)(`p`,{className:`break-all font-mono text-xs font-medium leading-5 text-fg`,title:o,children:a}),t[5]=a,t[6]=o,t[7]=l):l=t[7];let u;t[8]===c?u=t[9]:(u=c?(0,$.jsx)(R,{delayDuration:300,skipDelayDuration:100,children:(0,$.jsxs)(I,{children:[(0,$.jsx)(F,{asChild:!0,children:(0,$.jsx)(`p`,{tabIndex:0,title:c,className:m(`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:c})}),(0,$.jsx)(L,{children:(0,$.jsx)(z,{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,$.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:c})})})]})}):null,t[8]=c,t[9]=u);let d;return t[10]!==l||t[11]!==u?(d=(0,$.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[l,u]}),t[10]=l,t[11]=u,t[12]=d):d=t[12],d}function Vn({open:e,mode:t,initialRow:n,existingCustomServers:r,sessionIdleTtlMinutes:i,config:a,managedServerIds:o,t:s,cs:c,onClose:l,onSaved:f}){let[h,g]=(0,Z.useState)(n),[_,v]=(0,Z.useState)(!1),[y,D]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)({status:`idle`}),[F,I]=(0,Z.useState)(null),L=n.id.trim(),R=h.id.trim()!==L&&o.has(h.id.trim())||o.has(h.id.trim())&&t===`add`?s.reservedServerId:void 0,z=h.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===h.id.trim())?c.duplicateServerId:void 0,B=h.id.trim().length>0&&!R&&!z&&(h.transport===`stdio`?h.command.trim().length>0:h.url.trim().length>0),V=!(h.transport===`streamable-http`&&h.auth===`oauth`),H=rn(h),ee=(0,Z.useCallback)(async()=>{if(h.id.trim()){D(!0),A(null),P({status:`loading`});try{P({status:`ok`,tools:(await Qt(h.id.trim(),Ut(h))).tools})}catch(e){P({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{D(!1)}}},[h]),U=(0,Z.useCallback)(async()=>{if(!(!B||_)){v(!0),A(null);try{let e=r.filter(e=>!(t===`edit`&&e.clientKey===n.clientKey));e.push(h),await Wt({sessionIdleTtlMinutes:i,servers:e.sort((e,t)=>e.id.localeCompare(t.id))},It(a)),await f(),l()}catch(e){A(e instanceof Error?e.message:String(e))}finally{v(!1)}}},[B,a,r,n.clientKey,t,l,f,L,h,_,i]);return e?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(E,{open:e,onOpenChange:e=>{e||l()},children:(0,$.jsxs)(C,{children:[(0,$.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(w,{className:m(`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-overlay shadow-float dark:border-edge`),children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(T,{className:`text-base font-semibold text-fg`,children:t===`add`?c.addCustomServerTitle:c.editCustomServerTitle}),(0,$.jsx)(x,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?c.addCustomServerHint:c.editCustomServerHint})]}),(0,$.jsx)(S,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:m(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,nt.focusRingPanel),"aria-label":c.modalClose,children:[(0,$.jsx)(p,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`sr-only`,children:c.modalClose})]})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(pe,{className:`size-4 text-accent`,"aria-hidden":!0}),h.id.trim()||s.cardUntitled]}),(0,$.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs leading-5 text-fg-muted`,children:H||(h.transport===`stdio`?s.commandLabel:s.urlLabel)})]}),(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:s.transportLabels[h.transport]})]})}),(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-3`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.connectorBasicConfigTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:c.connectorBasicConfigHint})]}),(0,$.jsx)(In,{row:h,t:s,variant:`basic`,onUpdate:e=>{g(t=>({...t,...e})),A(null)},idConflictMessage:R??z})]}),N.status===`ok`?(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(ce,{className:`size-4 text-accent`,"aria-hidden":!0}),N.tools.length===0?s.toolsEmpty:s.toolsTitle.replace(`{{count}}`,String(N.tools.length))]}),N.tools.length>0?(0,$.jsx)(O,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>I(N.tools),children:s.viewAllTools}):null]}),N.tools.length>0?(0,$.jsx)(`div`,{className:`mt-3 grid gap-2`,children:N.tools.slice(0,6).map((e,t)=>(0,$.jsx)(Bn,{tool:e,serverId:h.id},e.name||`tool-${t}`))}):null]}):null,N.status===`error`?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:N.message}):null,k?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:k}):null,(0,$.jsxs)(`details`,{open:j,onToggle:e=>M(e.currentTarget.open),className:`group rounded-xl border border-edge bg-surface-base`,children:[(0,$.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,$.jsx)(ue,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`group-open:hidden`,children:c.connectorShowAdvancedConfig}),(0,$.jsx)(`span`,{className:`hidden group-open:inline`,children:c.connectorHideAdvancedConfig})]}),(0,$.jsx)(`div`,{className:`border-t border-edge p-4`,children:(0,$.jsx)(In,{row:h,t:s,variant:`advanced`,onUpdate:e=>{g(t=>({...t,...e})),A(null)}})})]})]})}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,$.jsxs)(O,{variant:`secondary`,disabled:!h.id.trim()||y||!V,title:V?void 0:s.oauthSaveBeforeTest,onClick:()=>void ee(),children:[y?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(he,{className:`size-4`}),s.testConnection]}),(0,$.jsx)(S,{asChild:!0,children:(0,$.jsx)(O,{variant:`secondary`,children:c.modalCancel})}),(0,$.jsxs)(O,{variant:`primary`,disabled:!B||_,onClick:()=>void U(),children:[_?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(u,{className:`size-4`}),_?s.saving:c.modalSave]})]})]})]})}),F?(0,$.jsx)(un,{open:!0,onOpenChange:e=>{e||I(null)},serverId:h.id,title:s.toolsDialogTitle,subtitle:s.toolsDialogSubtitle,searchPlaceholder:s.toolsDialogSearchPlaceholder,searchEmptyLabel:s.toolsDialogSearchEmpty,emptyLabel:s.toolsEmpty,closeLabel:s.toolsDialogClose,tools:F,stripPrefix:`${h.id.trim()}__`}):null]}):null}var Hn=`builtin`,Un=`composio`,Wn=`xopc-store`;function Gn(e){return Hn}function Kn(e){return!(e.runtime.type===`composio`&&e.runtime.role===`credential`)}function qn(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 Jn(e,t,n){return e.filter(e=>qn(e,t)).toSorted((e,t)=>n===`source`&&e.source!==t.source?e.source.localeCompare(t.source):e.displayName.localeCompare(t.displayName))}function Yn(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 Xn(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 Zn(e){let t=e.connectorManifest;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t;if(n.contractVersion!==1||n.id!==e.name)return null;let r=n.runtime,i=n.auth;if(!r||typeof r!=`object`||Array.isArray(r)||!i||typeof i!=`object`||Array.isArray(i))return null;let a=r,o=i;if(a.type!==`mcp`||typeof a.serverId!=`string`)return null;let s=[`code`,`docs`,`browser`,`data`,`automation`,`custom`].includes(String(n.category??``))?n.category:`custom`,c=o.mode===`oauth`?{mode:`oauth`,...typeof o.clientId==`string`?{clientId:o.clientId}:{}}:o.mode===`apiKey`?{mode:`apiKey`}:{mode:`none`};return{id:e.name,version:e.latestVersion??`store`,displayName:typeof n.displayName==`string`?n.displayName:e.name,description:typeof n.description==`string`?n.description:e.description,category:s,kind:`mcp`,source:`store`,capabilities:Array.isArray(n.capabilities)?n.capabilities.filter(e=>typeof e==`string`):[],tags:Array.isArray(n.tags)?n.tags.filter(e=>typeof e==`string`):[`store`],auth:c,setup:n.setup&&typeof n.setup==`object`&&!Array.isArray(n.setup)?n.setup:{},runtime:{type:`mcp`,serverId:a.serverId}}}function Qn(e){return e.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t)}function $n(e){return e?.startsWith(`/`)&&!e.startsWith(`//`)?e:`/user-model`}function er(){let e=y(_(e=>e.language)),t=e.connectorsSettings,n=e.mcpSettings,r=g(e=>e.conversationId),o=!!r,s=i(),[c,u]=a(),f=c.get(`understanding`)===`1`,p=$n(c.get(`returnTo`)),h=c.get(`tab`),[v,b]=(0,Z.useState)(!f&&h===`connected`?`connected`:`discover`),x=(0,Z.useRef)(!1),[S,C]=(0,Z.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null}),[w,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(!1),[k,j]=(0,Z.useState)(1),[M,N]=(0,Z.useState)(void 0),[P,F]=(0,Z.useState)(``),[I,L]=(0,Z.useState)(f?c.get(`connector`)??``:``),[R,z]=(0,Z.useState)(Gn(f?`understanding`:`default`)),[B,V]=(0,Z.useState)(`name`),[H,ee]=(0,Z.useState)(f?`understand`:`all`),[U,W]=(0,Z.useState)(null),[te,G]=(0,Z.useState)(null),[ne,oe]=(0,Z.useState)(null),[se,ce]=(0,Z.useState)(null),[le,ue]=(0,Z.useState)(null),[de,fe]=(0,Z.useState)(null),[pe,K]=(0,Z.useState)(!1),[he,J]=(0,Z.useState)(void 0),[ve,be]=(0,Z.useState)(!1),{data:xe,mutate:Se}=A(o),Ce=xe?.payload?.config,Y=(0,Z.useMemo)(()=>Ce===void 0?null:Ht(Ce),[Ce]),X=Y?.servers??[],we=S.instances.length+X.length;(0,Z.useEffect)(()=>{Y&&J(Y.sessionIdleTtlMinutes)},[Y]);let Te=(0,Z.useCallback)(async()=>{if(!r){C({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null});return}C(e=>({...e,loading:!0,error:null}));try{let[e,t]=await Promise.all([ae(),q()]);C(n=>({catalog:e,registryCatalog:n.registryCatalog,instances:t,loading:!1,error:null}))}catch(e){C({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[r]);(0,Z.useEffect)(()=>{Te()},[Te]),(0,Z.useEffect)(()=>{x.current||S.loading||o&&!Y||(b(f?`discover`:we>0?`connected`:`discover`),x.current=!0)},[o,we,Y,f,S.loading]);let De=(0,Z.useCallback)(e=>{x.current=!0,b(e)},[]),Oe=(0,Z.useMemo)(()=>[{id:Un,displayName:t.composioSourceName},{id:Wn,displayName:t.storeSourceName}],[t.composioSourceName,t.storeSourceName]),ke=(0,Z.useCallback)(async e=>{if(!o||R===`builtin`){C(e=>({...e,registryCatalog:[]})),j(1),N(void 0);return}let t=I.trim(),n=Math.max(e?.page??1,1),r=e?.append??!1,i=R===`all`?Oe:Oe.filter(e=>e.id===R);if(i.length!==0){T(!0),r?C(e=>({...e,error:null})):(j(1),N(void 0),C(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(i.map(async e=>{if(e.id===`composio`){let e=await ge({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let r=await _e({q:t||void 0,page:n,pageSize:24,sort:B===`source`?`newest`:`downloads`});return{connectors:r.items.flatMap(e=>{let t=Zn(e);return t?[t]:[]}),totalPages:r.meta.totalPages}})),a=Qn(e.flatMap(e=>e.connectors)),o=Math.max(1,...e.map(e=>e.totalPages??1));j(n),N(o),C(e=>({...e,registryCatalog:r?Qn([...e.registryCatalog,...a]):a}))}catch(e){C(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{T(!1)}}},[B,I,R,o,Oe]);(0,Z.useEffect)(()=>{if(v!==`discover`||S.loading)return;if(R===`builtin`){C(e=>({...e,registryCatalog:[]})),j(1),N(void 0);return}let e=window.setTimeout(()=>{ke()},I.trim()?350:0);return()=>window.clearTimeout(e)},[I,R,ke,S.loading,v]);let Ae=(0,Z.useMemo)(()=>new Set(S.instances.map(e=>e.connectorId)),[S.instances]),je=(0,Z.useMemo)(()=>new Map([...S.catalog,...S.registryCatalog].map(e=>[e.id,e])),[S.catalog,S.registryCatalog]);(0,Z.useEffect)(()=>{if(S.loading)return;let e=c.get(`connector`),t=c.get(`instance`);if(!e&&!t)return;let n=S.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)x.current=!0,F(``),oe(n.instanceId),ce(n),b(`connected`);else if(e){let t=je.get(e);if(!t)return;x.current=!0,z(Gn(f?`understanding`:`default`)),L(``),G(t),b(`discover`)}let r=new URLSearchParams(c);r.delete(`connector`),r.delete(`instance`),r.set(`tab`,n?`connected`:`discover`),u(r,{replace:!0})},[je,f,c,u,S.instances,S.loading]);let Me=(0,Z.useCallback)(async e=>{D(!0),C(e=>({...e,error:null}));try{let t=await re(e);W(me(t.definition,{packageName:t.packageName,version:t.version,permissions:t.permissions}))}catch(e){C(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{D(!1)}},[]),Ne=(0,Z.useMemo)(()=>new Set(S.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[S.instances]),Pe=(0,Z.useCallback)(async e=>{if(!Y||Ce===void 0)return;let t=X.filter(t=>t.clientKey!==e.clientKey);await Wt({sessionIdleTtlMinutes:Y.sessionIdleTtlMinutes,servers:t},It(Ce)),await Se(),await Te()},[Ce,X,Te,Y,Se]),Fe=(0,Z.useCallback)(()=>{fe({mode:`add`,row:On(X,Ne)})},[X,Ne]),Ie=(0,Z.useCallback)(async()=>{if(!(!Y||Ce===void 0||ve)){be(!0);try{await Wt({sessionIdleTtlMinutes:he,servers:X},It(Ce)),await Se(),K(!1)}finally{be(!1)}}},[Ce,X,n.saved,Y,Se,he,ve]),Le=Ee(e=>e.setPageHeader),Re=Ee(e=>e.clearPageHeader),ze=(0,Z.useMemo)(()=>(0,$.jsx)(kt,{onBrowseCatalog:()=>De(`discover`),onAddCustomServer:Fe,addLabel:t.addConnection,browseLabel:t.addFromCatalog,customLabel:t.addCustomServerAdvanced}),[t,Fe,De]);(0,Z.useLayoutEffect)(()=>(Le({startExtra:null,main:(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title})}),end:ze}),()=>Re()),[Re,t.title,ze,Le]);let Be=(0,Z.useMemo)(()=>S.instances.map(e=>({instance:e,value:yt(e,je.get(e.connectorId))})),[je,S.instances]),Ve=(0,Z.useMemo)(()=>new Map(Be.map(({instance:e,value:t})=>[e.instanceId,t])),[Be]),He=(0,Z.useMemo)(()=>S.instances.filter(e=>Yn(e,P)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=Ve.get(e.instanceId)?.state??`checking`,i=Ve.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[P,Ve,S.instances]),Ue=(0,Z.useMemo)(()=>He.filter(e=>Ve.get(e.instanceId)?.state===`needs_setup`),[Ve,He]),We=(0,Z.useMemo)(()=>He.filter(e=>Ve.get(e.instanceId)?.state!==`needs_setup`),[Ve,He]),Ge=(0,Z.useMemo)(()=>X.filter(e=>Xn(e,P)),[P,X]),Ke=He.length+Ge.length,qe=(0,Z.useMemo)(()=>S.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&Kn(e)),[S.catalog]),Je=(0,Z.useMemo)(()=>R===`builtin`?qe:R===`all`?Qn([...qe,...S.registryCatalog]):S.registryCatalog,[qe,R,S.registryCatalog]),Xe=(0,Z.useMemo)(()=>{let e=f?Je.filter(e=>e.understanding?.mode===`activity`):Je;return Jn(H===`all`?e:e.filter(e=>_t(e).includes(H)),I,B)},[B,I,Je,f,H]),Qe=(0,Z.useMemo)(()=>gt.filter(e=>Je.some(t=>_t(t).includes(e))),[Je]);(0,Z.useEffect)(()=>{H!==`all`&&!Qe.includes(H)&&ee(`all`)},[Qe,H]);let $e=v===`discover`&&R!==`builtin`&&!!(M&&k<M),et=(0,Z.useMemo)(()=>S.instances.find(e=>e.instanceId===ne)??se,[ne,se,S.instances]),tt=(0,Z.useMemo)(()=>[{value:`all`,label:t.discoverSourceAll},{value:Hn,label:t.discoverSourceBuiltin},...Oe.map(e=>({value:e.id,label:e.displayName}))],[t.discoverSourceAll,t.discoverSourceBuiltin,Oe]),nt=[{id:`connected`,label:t.tabConnected,count:we},{id:`discover`,label:t.tabDiscover}];return(0,$.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-6 px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:[o?null:(0,$.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:t.tokenHint}),f?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:t.understandingSetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.understandingSetupHint})]}),(0,$.jsx)(O,{type:`button`,variant:`secondary`,className:`shrink-0`,onClick:()=>s(p),children:t.understandingSetupDone})]}):null,(0,$.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(`div`,{className:`border-b border-edge-subtle pb-3 dark:border-edge-subtle`,children:(0,$.jsx)(st,{items:nt,activeTab:v,onChange:De,ariaLabel:t.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),S.error?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:S.error}):null,v===`connected`&&o?(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[we>5||P?(0,$.jsx)(Ot,{value:P,onChange:F,placeholder:t.connectedSearchPlaceholder,className:`max-w-xl`}):(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsx)(ye,{className:`size-9 shrink-0 p-0`,loading:S.loading,label:t.refreshConnections,title:t.refreshConnections,onClick:Te})]}),S.loading?(0,$.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":t.loading,children:ut.slice(0,3).map(e=>(0,$.jsx)(ht,{},e))}):we===0?(0,$.jsxs)(`div`,{className:`py-14 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.connectionsEmpty}),(0,$.jsx)(O,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>De(`discover`),children:t.addFromCatalog})]}):Ke===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:t.connectionsSearchEmpty}):(0,$.jsxs)(`div`,{className:`space-y-6`,children:[Ue.length?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.needsAttentionTitle}),(0,$.jsx)(`span`,{className:`text-xs tabular-nums text-amber-700 dark:text-amber-300`,children:Ue.length})]}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-amber-500/25 bg-amber-500/5`,children:Ue.map(e=>(0,$.jsx)(Dn,{instance:e,definition:je.get(e.connectorId),highlighted:e.instanceId===le,onOpenDetails:e=>{ue(null),oe(e.instanceId),ce(e)},t},e.instanceId))})]}):null,We.length?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.connectedServicesTitle}),(0,$.jsx)(`span`,{className:`text-xs tabular-nums text-fg-subtle`,children:We.length})]}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:We.map(e=>(0,$.jsx)(Dn,{instance:e,definition:je.get(e.connectorId),highlighted:e.instanceId===le,onOpenDetails:e=>{ue(null),oe(e.instanceId),ce(e)},t},e.instanceId))})]}):null,Ge.length||!P.trim()?(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer px-4 py-3`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.customIntegrationsTitle}),(0,$.jsx)(`span`,{className:`ml-2 text-xs tabular-nums text-fg-subtle`,children:Ge.length}),(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.customIntegrationsHint})]}),(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2 px-4 py-3`,children:[(0,$.jsx)(O,{type:`button`,variant:`secondary`,className:`h-8 text-xs`,onClick:Fe,children:t.addCustomServerAdvanced}),(0,$.jsxs)(O,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>K(!0),children:[(0,$.jsx)(Ze,{className:`size-3.5`}),t.runtimeSettings]})]}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:Ge.map(e=>(0,$.jsx)(an,{row:e,t:n,cs:t,onEdit:()=>fe({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>Pe(e)},e.clientKey))})]})]}):null]})]}):null,v===`discover`&&o?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[f?null:(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":t.taskFilterAria,children:[`all`,...Qe].map(e=>(0,$.jsx)(`button`,{type:`button`,className:m(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,H===e?`border-accent/40 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg-muted hover:bg-surface-hover hover:text-fg`),"aria-pressed":H===e,onClick:()=>ee(e),children:e===`all`?t.taskAll:t.connectorBenefitHeadings[e]},e))}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 lg:flex-row lg:items-center`,children:[(0,$.jsx)(Ot,{value:I,onChange:L,placeholder:t.discoverSearchPlaceholder,className:`max-w-xl`}),(0,$.jsxs)(`details`,{className:`relative shrink-0 lg:ml-auto`,children:[(0,$.jsxs)(`summary`,{className:`flex h-9 cursor-pointer list-none items-center gap-2 rounded-lg border border-edge bg-surface-panel px-3 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,children:[(0,$.jsx)(Ye,{className:`size-3.5`,"aria-hidden":!0}),t.filters]}),(0,$.jsxs)(`div`,{className:m(`mt-2 grid min-w-[15rem] grid-cols-1 gap-2 rounded-xl border border-edge bg-surface-panel p-3 shadow-popover sm:absolute sm:right-0 sm:z-10`,!f&&`sm:min-w-[24rem] sm:grid-cols-2`),children:[f?null:(0,$.jsx)(l,{value:R,options:tt,placeholder:t.discoverSourceAll,allowEmpty:!1,ariaLabel:t.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:z}),(0,$.jsx)(l,{value:B,options:[{value:`name`,label:t.sortName},{value:`source`,label:t.sortSource}],placeholder:t.sortName,allowEmpty:!1,ariaLabel:t.sortAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:e=>V(e)})]})]})]}),(S.loading||w)&&Xe.length===0?(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:ut.map(e=>(0,$.jsx)(pt,{},e))}):Xe.length===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:t.discoverEmpty}):(0,$.jsxs)(`div`,{className:`relative`,children:[w?(0,$.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,$.jsx)(d,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:Xe.map(e=>(0,$.jsx)(ct,{connector:e,installed:Ae.has(e.id)||dt(e,S.instances),onInstall:e=>{if(e.source===`store`){Me(e.id);return}W(me(e))},onOpenDetails:e.source===`store`?void 0:G,t},e.id))}),$e?(0,$.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,$.jsxs)(O,{type:`button`,variant:`secondary`,disabled:w||E,onClick:()=>void ke({page:k+1,append:!0}),children:[w?(0,$.jsx)(d,{className:`size-4 animate-spin`}):null,t.loadMore]})}):null]})]}):null]}),U?(0,$.jsx)(ie,{draft:U,onChange:W,onClose:()=>W(null),t,onInstalled:async e=>{await Te(),await Se(),ue(e.instanceId),De(`connected`)}}):null,te?(0,$.jsx)(Tt,{connector:te,installed:Ae.has(te.id)||dt(te,S.instances),onClose:()=>G(null),onInstall:e=>W(me(e)),t}):null,et?(0,$.jsx)(En,{instance:et,definition:je.get(et.connectorId),onClose:()=>{oe(null),ce(null)},onChanged:Te,t,mcp:n}):null,de?(0,$.jsx)(Vn,{open:!0,mode:de.mode,initialRow:de.row,existingCustomServers:X,sessionIdleTtlMinutes:he,config:Ce,managedServerIds:Ne,t:n,cs:t,onClose:()=>fe(null),onSaved:async()=>{await Se(),await Te(),De(`connected`)}},`${de.mode}-${de.row.clientKey}`):null,(0,$.jsx)(Dt,{open:pe,sessionIdleTtlMinutes:he,saving:ve,onChange:J,onSave:Ie,onClose:()=>K(!1),t,mcp:n})]})})}export{er as ConnectorsPage};
@@ -1 +0,0 @@
1
- import{p as e}from"./locale-store-msTfRK8P.js";var t=e(()=>({connectionState:`idle`,error:null}));function n(e){t.setState(e)}export{t as n,n as t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,t as a}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as o}from"./plus-Q2yW6OE7.js";import{t as s}from"./x-B_N4OPjy.js";import{t as c}from"./cn-JdwAhgNB.js";import{n as l}from"./locale-store-msTfRK8P.js";import{t as u}from"./messages-F74LVAiU.js";import{a as d,i as f,n as p,o as m,r as h,s as g,t as _}from"./dist-BGTk37IG.js";import{i as v}from"./vendor-swr-BIWyz7Rc.js";import{t as y}from"./button-CS04eWY9.js";import{t as b}from"./skeleton-BwbyijEw.js";import{$t as x,Ao as S,Au as C,Bs as w,Cs as T,Ms as E,Ns as D,Pr as O,Pu as k,Qt as A,Yl as j,di as M,do as N,ei as P,en as F,fi as I,gc as ee,ks as te,ku as ne,ll as re,oa as ie,qc as ae,r as oe,ti as se,tn as ce}from"./index-RBCkv8a_.js";import{t as le}from"./api-DFOlahZv.js";import{n as ue}from"./tab-completion-input-D64VNmiA.js";var L=n(),R=r(),z={meeting_preparation:{Icon:k,en:`Next meeting`,zh:`下一场会议`},project_momentum:{Icon:j,en:`Project momentum`,zh:`项目进展`},communication_follow_up:{Icon:re,en:`Waiting on a reply`,zh:`沟通跟进`}},de={needs_decision:{en:`Needs your decision`,zh:`需要你决定`},prepared:{en:`Ready for you`,zh:`已为你准备好`},changed:{en:`Something changed`,zh:`出现了新变化`},following:{en:`Following quietly`,zh:`正在安静跟进`}};function B(e){let t=(0,L.c)(56),{scene:n,zh:r}=e,i=z[n.kind],o=de[n.status],s=n.card?`/assistant-work?item=${encodeURIComponent(n.card.id)}`:n.object?.route??n.manageRoute,c=n.status===`needs_decision`?r?`查看并决定`:`Review and decide`:n.status===`prepared`?r?`查看准备结果`:`Open prepared work`:n.status===`changed`?r?`查看变化`:`Review change`:n.object?r?`打开${n.kind===`project_momentum`?`项目`:`相关内容`}`:`Open context`:r?`查看安排`:`View arrangement`,l;t[0]===i.Icon?l=t[1]:(l=(0,R.jsx)(`span`,{className:`mt-0.5 rounded-xl bg-accent-soft p-2 text-accent`,children:(0,R.jsx)(i.Icon,{className:`size-4`,"aria-hidden":!0})}),t[0]=i.Icon,t[1]=l);let u=r?i.zh:i.en,d;t[2]===u?d=t[3]:(d=(0,R.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:u}),t[2]=u,t[3]=d);let f=n.status===`following`?`text-xs text-fg-subtle`:`text-xs font-medium text-accent`,p=r?o.zh:o.en,m;t[4]!==f||t[5]!==p?(m=(0,R.jsx)(`span`,{className:f,children:p}),t[4]=f,t[5]=p,t[6]=m):m=t[6];let h;t[7]!==d||t[8]!==m?(h=(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[d,m]}),t[7]=d,t[8]=m,t[9]=h):h=t[9];let g;t[10]===n.title?g=t[11]:(g=(0,R.jsx)(`h3`,{className:`mt-1 font-semibold text-fg`,children:n.title}),t[10]=n.title,t[11]=g);let _;t[12]!==h||t[13]!==g?(_=(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[h,g]}),t[12]=h,t[13]=g,t[14]=_):_=t[14];let v;t[15]!==l||t[16]!==_?(v=(0,R.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-edge-subtle px-5 py-4`,children:[l,_]}),t[15]=l,t[16]=_,t[17]=v):v=t[17];let y=r?`现在`:`Now`,b;t[18]===y?b=t[19]:(b=(0,R.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:y}),t[18]=y,t[19]=b);let x;t[20]===n.moment?x=t[21]:(x=(0,R.jsx)(`p`,{className:`mt-1 text-sm font-medium text-fg`,children:n.moment}),t[20]=n.moment,t[21]=x);let S;t[22]!==b||t[23]!==x?(S=(0,R.jsxs)(`div`,{children:[b,x]}),t[22]=b,t[23]=x,t[24]=S):S=t[24];let C=n.status===`following`?r?`跟进要求`:`What the assistant remembers`:r?`为什么值得关注`:`Why it matters`,w;t[25]===C?w=t[26]:(w=(0,R.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:C}),t[25]=C,t[26]=w);let T=n.status===`following`?n.promise:n.relevance,E;t[27]===T?E=t[28]:(E=(0,R.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:T}),t[27]=T,t[28]=E);let D;t[29]!==w||t[30]!==E?(D=(0,R.jsxs)(`div`,{children:[w,E]}),t[29]=w,t[30]=E,t[31]=D):D=t[31];let O=r?`助理已经做了什么`:`What your assistant did`,k;t[32]===O?k=t[33]:(k=(0,R.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:O}),t[32]=O,t[33]=k);let A;t[34]===n.help?A=t[35]:(A=(0,R.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:n.help}),t[34]=n.help,t[35]=A);let j;t[36]!==k||t[37]!==A?(j=(0,R.jsxs)(`div`,{className:`rounded-xl bg-surface-hover px-4 py-3`,children:[k,A]}),t[36]=k,t[37]=A,t[38]=j):j=t[38];let M;t[39]!==c||t[40]!==s?(M=(0,R.jsx)(a,{className:`text-sm font-medium text-accent`,to:s,children:c}),t[39]=c,t[40]=s,t[41]=M):M=t[41];let N=r?`调整助理跟进`:`Adjust arrangement`,P;t[42]!==n.manageRoute||t[43]!==N?(P=(0,R.jsx)(a,{className:`text-xs text-fg-subtle hover:text-fg`,to:n.manageRoute,children:N}),t[42]=n.manageRoute,t[43]=N,t[44]=P):P=t[44];let F;t[45]!==M||t[46]!==P?(F=(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[M,P]}),t[45]=M,t[46]=P,t[47]=F):F=t[47];let I;t[48]!==S||t[49]!==D||t[50]!==j||t[51]!==F?(I=(0,R.jsxs)(`div`,{className:`space-y-4 px-5 py-4`,children:[S,D,j,F]}),t[48]=S,t[49]=D,t[50]=j,t[51]=F,t[52]=I):I=t[52];let ee;return t[53]!==v||t[54]!==I?(ee=(0,R.jsxs)(`article`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[v,I]}),t[53]=v,t[54]=I,t[55]=ee):ee=t[55],ee}function fe(e){let t=(0,L.c)(42),{compact:n}=e,r=n===void 0?!1:n,i=l(V)===`zh`,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={refreshInterval:15e3},t[0]=o):o=t[0];let s=v(`/api/proactive/overview`,le,o);if(s.isLoading){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,R.jsx)(b,{className:`h-44 rounded-2xl`}),t[1]=e):e=t[1],e}if(s.error){let e=String(s.error),n;return t[2]===e?n=t[3]:(n=(0,R.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:e}),t[2]=e,t[3]=n),n}let c;t[4]===s.data?.scenes?c=t[5]:(c=s.data?.scenes??[],t[4]=s.data?.scenes,t[5]=c);let u=c;if(!u.length){let e=r?`px-4 text-center`:`rounded-2xl border border-edge bg-surface-panel p-6`,n=r?`text-sm font-medium text-fg-muted`:`font-medium text-fg`,a=i?`今天没有需要你接手的变化`:`Nothing needs your attention today`,o;t[6]!==n||t[7]!==a?(o=(0,R.jsx)(`h2`,{className:n,children:a}),t[6]=n,t[7]=a,t[8]=o):o=t[8];let s=r?`mx-auto mt-2 max-w-lg text-xs leading-5 text-fg-subtle`:`mt-2 text-sm text-fg-muted`,c=i?`继续工作即可。需要持续关注的事,可以直接在项目或对话里交给助理。`:`Keep working. You can ask the assistant to follow something from its project or conversation.`,l;t[9]!==s||t[10]!==c?(l=(0,R.jsx)(`p`,{className:s,children:c}),t[9]=s,t[10]=c,t[11]=l):l=t[11];let u;return t[12]!==l||t[13]!==e||t[14]!==o?(u=(0,R.jsxs)(`section`,{className:e,children:[o,l]}),t[12]=l,t[13]=e,t[14]=o,t[15]=u):u=t[15],u}let d;t[16]!==r||t[17]!==u?(d=r?u.slice(0,3):u,t[16]=r,t[17]=u,t[18]=d):d=t[18];let f=d,p=i?`正在发生的事`:`What is happening`,m;t[19]===p?m=t[20]:(m=(0,R.jsx)(`h2`,{id:`proactive-scenes-title`,className:`text-sm font-semibold text-fg`,children:p}),t[19]=p,t[20]=m);let h=i?`助理跟进`:`Assistant follow-ups`,g;t[21]===h?g=t[22]:(g=(0,R.jsx)(a,{className:`text-xs text-fg-subtle hover:text-accent`,to:`/assistant-work`,children:h}),t[21]=h,t[22]=g);let _;t[23]!==m||t[24]!==g?(_=(0,R.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3 px-1`,children:[m,g]}),t[23]=m,t[24]=g,t[25]=_):_=t[25];let y;if(t[26]!==f||t[27]!==i){let e;t[29]===i?e=t[30]:(e=e=>(0,R.jsx)(B,{scene:e,zh:i},e.id),t[29]=i,t[30]=e),y=f.map(e),t[26]=f,t[27]=i,t[28]=y}else y=t[28];let x;t[31]===y?x=t[32]:(x=(0,R.jsx)(`div`,{className:`space-y-3`,children:y}),t[31]=y,t[32]=x);let S;t[33]!==r||t[34]!==u.length||t[35]!==f.length||t[36]!==i?(S=r&&u.length>f.length&&(0,R.jsx)(a,{className:`mt-3 block text-sm text-accent`,to:`/assistant-work`,children:i?`还有 ${u.length-f.length} 个场景`:`${u.length-f.length} more scenes`}),t[33]=r,t[34]=u.length,t[35]=f.length,t[36]=i,t[37]=S):S=t[37];let C;return t[38]!==x||t[39]!==S||t[40]!==_?(C=(0,R.jsxs)(`section`,{"aria-labelledby":`proactive-scenes-title`,children:[_,x,S]}),t[38]=x,t[39]=S,t[40]=_,t[41]=C):C=t[41],C}function V(e){return e.language}var H=e(t(),1),pe=12e3;function U(e){let t=(0,L.c)(106),{variant:n,inputId:r,inputRef:i,intent:a,labels:o,attachments:s,isDragging:l,attachmentBusy:u,attachmentsFull:d,voice:f,chat:p,cancelAction:m,onIntentChange:h,onPickFiles:g,onRemoveAttachment:_,onPaste:v,onDragOver:b,onDragLeave:x,onDrop:S,onSubmit:C}=e,w=n===`inline`,T;t[0]!==s||t[1]!==a?(T=!!a.trim()||s.length>0,t[0]=s,t[1]=a,t[2]=T):T=t[2];let E=T,D=f.voiceActive&&f.phase!==`error`,O;t[3]!==C||t[4]!==f.voiceActive?(O=e=>{if(f.voiceActive){e.preventDefault();return}C(e)},t[3]=C,t[4]=f.voiceActive,t[5]=O):O=t[5];let k=w?`mx-auto mt-6 w-full overflow-hidden rounded-xl border border-edge bg-surface-base p-2 text-left shadow-surface transition-colors focus-within:border-accent focus-within:ring-2 focus-within:ring-accent/15 sm:mt-8`:`flex min-h-0 flex-1 flex-col`,A;t[6]===k?A=t[7]:(A=c(`relative`,k),t[6]=k,t[7]=A);let j;t[8]!==w||t[9]!==l||t[10]!==o.dropFiles?(j=l?(0,R.jsx)(`div`,{className:c(`pointer-events-none absolute inset-0 z-10 flex items-center justify-center bg-accent-soft/90 text-sm font-medium text-accent-fg backdrop-blur-[1px]`,w&&`rounded-2xl`),children:o.dropFiles}):null,t[8]=w,t[9]=l,t[10]=o.dropFiles,t[11]=j):j=t[11];let N=!w&&`flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-4`,P;t[12]===N?P=t[13]:(P=c(N),t[12]=N,t[13]=P);let I=w?`sr-only`:`mb-2 shrink-0 text-sm font-medium text-fg`,te;t[14]!==r||t[15]!==o.intentLabel||t[16]!==I?(te=(0,R.jsx)(`label`,{htmlFor:r,className:I,children:o.intentLabel}),t[14]=r,t[15]=o.intentLabel,t[16]=I,t[17]=te):te=t[17];let ne;t[18]!==u||t[19]!==p||t[20]!==f.audioLevel||t[21]!==f.cancelVoiceInput||t[22]!==f.confirmVoiceInput||t[23]!==f.elapsedLabel||t[24]!==f.error||t[25]!==f.finalTranscript||t[26]!==f.partialTranscript||t[27]!==f.phase||t[28]!==f.retryVoiceInput||t[29]!==f.settingsRequired||t[30]!==f.voiceActive?(ne=f.voiceActive?(0,R.jsx)(F,{phase:f.phase,elapsedLabel:f.elapsedLabel,audioLevel:f.audioLevel,partialTranscript:f.partialTranscript,finalTranscript:f.finalTranscript,error:f.error,settingsRequired:f.settingsRequired,disabled:u,chat:p,onCancel:f.cancelVoiceInput,onConfirm:f.confirmVoiceInput,onRetry:f.retryVoiceInput}):null,t[18]=u,t[19]=p,t[20]=f.audioLevel,t[21]=f.cancelVoiceInput,t[22]=f.confirmVoiceInput,t[23]=f.elapsedLabel,t[24]=f.error,t[25]=f.finalTranscript,t[26]=f.partialTranscript,t[27]=f.phase,t[28]=f.retryVoiceInput,t[29]=f.settingsRequired,t[30]=f.voiceActive,t[31]=ne):ne=t[31];let re=D&&`hidden`,ie=w?`min-h-24 bg-transparent px-3 py-2`:`min-h-32 flex-1 rounded-xl border border-edge bg-surface-base p-3 focus:border-accent focus:ring-2 focus:ring-accent/20`,oe;t[32]!==re||t[33]!==ie?(oe=c(`w-full resize-none text-sm font-normal leading-6 text-fg outline-none placeholder:text-fg-subtle`,re,ie),t[32]=re,t[33]=ie,t[34]=oe):oe=t[34];let ce;t[35]===h?ce=t[36]:(ce=e=>h(e.target.value),t[35]=h,t[36]=ce);let le=!w,z;t[37]!==r||t[38]!==i||t[39]!==a||t[40]!==o.intentPlaceholder||t[41]!==o.intentSuggestion||t[42]!==h||t[43]!==v||t[44]!==oe||t[45]!==ce||t[46]!==le?(z=(0,R.jsx)(ue,{ref:i,id:r,className:oe,value:a,onChange:ce,onPaste:v,suggestion:o.intentSuggestion,onAcceptSuggestion:h,onKeyDown:me,placeholder:o.intentPlaceholder,maxLength:pe,autoFocus:le}),t[37]=r,t[38]=i,t[39]=a,t[40]=o.intentPlaceholder,t[41]=o.intentSuggestion,t[42]=h,t[43]=v,t[44]=oe,t[45]=ce,t[46]=le,t[47]=z):z=t[47];let de=w?`border-b-0 bg-transparent px-3 pb-2 pt-0`:`mt-3 border-b-0 bg-transparent px-0 pb-0`,B;t[48]!==s||t[49]!==_||t[50]!==de?(B=(0,R.jsx)(M,{attachments:s,topPadded:!1,onRemove:_,className:de}),t[48]=s,t[49]=_,t[50]=de,t[51]=B):B=t[51];let fe;t[52]!==w||t[53]!==a.length||t[54]!==o.shortcut?(fe=w?null:(0,R.jsxs)(`div`,{className:`mt-2 flex shrink-0 items-center justify-between gap-3 text-[11px] text-fg-subtle`,children:[(0,R.jsx)(`span`,{children:o.shortcut}),(0,R.jsxs)(`span`,{className:`tabular-nums`,children:[a.length.toLocaleString(),` / `,pe.toLocaleString()]})]}),t[52]=w,t[53]=a.length,t[54]=o.shortcut,t[55]=fe):fe=t[55];let V;t[56]!==ne||t[57]!==z||t[58]!==B||t[59]!==fe||t[60]!==P||t[61]!==te?(V=(0,R.jsxs)(`div`,{className:P,children:[te,ne,z,B,fe]}),t[56]=ne,t[57]=z,t[58]=B,t[59]=fe,t[60]=P,t[61]=te,t[62]=V):V=t[62];let H=w?`border-edge-subtle px-1 pt-2`:`border-edge px-5 py-4`,U;t[63]===H?U=t[64]:(U=c(`flex shrink-0 items-center gap-2 border-t`,H),t[63]=H,t[64]=U);let W=!w&&`mr-auto`,he;t[65]===W?he=t[66]:(he=c(`flex items-center gap-1`,W),t[65]=W,t[66]=he);let ge=u||d,_e;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,R.jsx)(ae,{className:`size-4`,"aria-hidden":!0}),t[67]=_e):_e=t[67];let G;t[68]!==o.attachTitle||t[69]!==g||t[70]!==ge?(G=(0,R.jsx)(y,{type:`button`,variant:`ghost`,className:`size-9 rounded-lg p-0`,disabled:ge,title:o.attachTitle,"aria-label":o.attachTitle,onClick:g,children:_e}),t[68]=o.attachTitle,t[69]=g,t[70]=ge,t[71]=G):G=t[71];let K;t[72]!==u||t[73]!==p||t[74]!==f.startVoiceInput||t[75]!==f.voiceActive?(K=f.voiceActive?null:(0,R.jsx)(se,{disabled:u,chat:p,onStart:f.startVoiceInput}),t[72]=u,t[73]=p,t[74]=f.startVoiceInput,t[75]=f.voiceActive,t[76]=K):K=t[76];let q;t[77]!==he||t[78]!==G||t[79]!==K?(q=(0,R.jsxs)(`div`,{className:he,children:[G,K]}),t[77]=he,t[78]=G,t[79]=K,t[80]=q):q=t[80];let J;t[81]!==m||t[82]!==w||t[83]!==o.shortcut?(J=w?(0,R.jsx)(`span`,{className:`hidden text-[11px] text-fg-subtle sm:inline`,children:o.shortcut}):m,t[81]=m,t[82]=w,t[83]=o.shortcut,t[84]=J):J=t[84];let ve=w?`ml-auto h-9 rounded-lg px-3.5 text-xs`:`min-w-32`,Y=!E||u||f.voiceActive,X=w?`size-3.5`:`size-4`,Z;t[85]===X?Z=t[86]:(Z=(0,R.jsx)(ee,{className:X,"aria-hidden":!0}),t[85]=X,t[86]=Z);let Q;t[87]!==o.submit||t[88]!==ve||t[89]!==Y||t[90]!==Z?(Q=(0,R.jsxs)(y,{type:`submit`,variant:`primary`,className:ve,disabled:Y,children:[Z,o.submit]}),t[87]=o.submit,t[88]=ve,t[89]=Y,t[90]=Z,t[91]=Q):Q=t[91];let $;t[92]!==U||t[93]!==q||t[94]!==J||t[95]!==Q?($=(0,R.jsxs)(`div`,{className:U,children:[q,J,Q]}),t[92]=U,t[93]=q,t[94]=J,t[95]=Q,t[96]=$):$=t[96];let ye;return t[97]!==x||t[98]!==b||t[99]!==S||t[100]!==O||t[101]!==V||t[102]!==$||t[103]!==A||t[104]!==j?(ye=(0,R.jsxs)(`form`,{onSubmit:O,onDragOver:b,onDragLeave:x,onDrop:S,className:A,children:[j,V,$]}),t[97]=x,t[98]=b,t[99]=S,t[100]=O,t[101]=V,t[102]=$,t[103]=A,t[104]=j,t[105]=ye):ye=t[105],ye}function me(e){e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}function W(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function he(){let e=(0,L.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,R.jsxs)(`div`,{className:`space-y-8`,"aria-busy":!0,children:[(0,R.jsxs)(`div`,{className:`space-y-3`,children:[(0,R.jsx)(b,{className:`h-10 w-3/5 rounded-xl`}),(0,R.jsx)(b,{className:`h-5 w-4/5 rounded-lg`})]}),(0,R.jsx)(b,{className:`h-64 rounded-2xl`}),(0,R.jsx)(b,{className:`h-32 rounded-xl`})]}),e[0]=t):t=e[0],t}function ge(e){let t=(0,L.c)(33),{item:n,busy:r,recommendationLabel:i,dueLabel:a,failureLabel:o,locale:s,onAction:c}=e,l;t[0]!==a||t[1]!==n.dueAt||t[2]!==s?(l=n.dueAt?`${a} ${O(new Date(n.dueAt),s)}`:null,t[0]=a,t[1]=n.dueAt,t[2]=s,t[3]=l):l=t[3];let u=l,d=n.kind===`failure`?o:u,f;t[4]===d?f=t[5]:(f=d?(0,R.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-xs font-medium text-warning`,children:[(0,R.jsx)(`span`,{className:`size-1.5 rounded-full bg-warning`,"aria-hidden":!0}),(0,R.jsx)(`span`,{children:d})]}):null,t[4]=d,t[5]=f);let p=!n.openAction,m;t[6]!==n.id||t[7]!==n.openAction||t[8]!==c?(m=()=>n.openAction&&c(n.openAction,n.id),t[6]=n.id,t[7]=n.openAction,t[8]=c,t[9]=m):m=t[9];let h;t[10]===n.title?h=t[11]:(h=(0,R.jsx)(`span`,{className:`block text-lg font-semibold leading-7 tracking-tight text-fg`,children:n.title}),t[10]=n.title,t[11]=h);let g;t[12]===n.summary?g=t[13]:(g=(0,R.jsx)(`span`,{className:`mt-1.5 block text-sm leading-6 text-fg-muted`,children:n.summary}),t[12]=n.summary,t[13]=g);let _;t[14]!==p||t[15]!==m||t[16]!==h||t[17]!==g?(_=(0,R.jsxs)(`button`,{type:`button`,className:`block w-full text-left outline-none focus-visible:rounded-md focus-visible:ring-2 focus-visible:ring-accent`,disabled:p,onClick:m,children:[h,g]}),t[14]=p,t[15]=m,t[16]=h,t[17]=g,t[18]=_):_=t[18];let v;t[19]!==n.recommendation||t[20]!==i?(v=n.recommendation?(0,R.jsxs)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:[(0,R.jsxs)(`span`,{className:`font-semibold text-fg`,children:[i,`:`]}),n.recommendation]}):null,t[19]=n.recommendation,t[20]=i,t[21]=v):v=t[21];let b;t[22]!==r||t[23]!==n.id||t[24]!==n.primaryAction||t[25]!==n.secondaryActions||t[26]!==c?(b=n.primaryAction||n.secondaryActions.length>0?(0,R.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[n.primaryAction?(0,R.jsx)(y,{type:`button`,variant:`primary`,className:`h-9 rounded-lg px-3.5 text-xs`,disabled:r,onClick:()=>c(n.primaryAction,n.id),children:n.primaryAction.label}):null,n.secondaryActions.map(e=>(0,R.jsx)(y,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg px-3.5 text-xs shadow-none`,disabled:r,onClick:()=>c(e,n.id),children:e.label},`${e.type}:${e.label}`))]}):null,t[22]=r,t[23]=n.id,t[24]=n.primaryAction,t[25]=n.secondaryActions,t[26]=c,t[27]=b):b=t[27];let x;return t[28]!==f||t[29]!==_||t[30]!==v||t[31]!==b?(x=(0,R.jsxs)(`article`,{className:`px-5 py-5 sm:px-6 sm:py-6`,children:[f,_,v,b]}),t[28]=f,t[29]=_,t[30]=v,t[31]=b,t[32]=x):x=t[32],x}function _e(e){let t=(0,L.c)(26),{item:n,onAction:r}=e,i;t[0]===n.kind?i=t[1]:(i=n.kind===`scheduled`?(0,R.jsx)(k,{className:`size-4`,"aria-hidden":!0}):(0,R.jsx)(`span`,{className:`size-1.5 rounded-full bg-success`,"aria-hidden":!0}),t[0]=n.kind,t[1]=i);let a=i,o=!n.openAction,s;t[2]!==n.id||t[3]!==n.openAction||t[4]!==r?(s=()=>n.openAction&&r(n.openAction,n.id),t[2]=n.id,t[3]=n.openAction,t[4]=r,t[5]=s):s=t[5];let c;t[6]===a?c=t[7]:(c=(0,R.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center text-fg-subtle`,children:a}),t[6]=a,t[7]=c);let l;t[8]===n.title?l=t[9]:(l=(0,R.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:n.title}),t[8]=n.title,t[9]=l);let u;t[10]===n.summary?u=t[11]:(u=(0,R.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.summary}),t[10]=n.summary,t[11]=u);let d;t[12]!==l||t[13]!==u?(d=(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[l,u]}),t[12]=l,t[13]=u,t[14]=d):d=t[14];let f;t[15]===n.statusLabel?f=t[16]:(f=n.statusLabel?(0,R.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:n.statusLabel}):null,t[15]=n.statusLabel,t[16]=f);let p;t[17]===n.openAction?p=t[18]:(p=n.openAction?(0,R.jsx)(C,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}):null,t[17]=n.openAction,t[18]=p);let m;return t[19]!==o||t[20]!==s||t[21]!==c||t[22]!==d||t[23]!==f||t[24]!==p?(m=(0,R.jsxs)(`button`,{type:`button`,className:`flex min-h-16 w-full items-center gap-3 py-3 text-left outline-none hover:text-fg focus-visible:rounded-md focus-visible:ring-2 focus-visible:ring-accent`,disabled:o,onClick:s,children:[c,d,f,p]}),t[19]=o,t[20]=s,t[21]=c,t[22]=d,t[23]=f,t[24]=p,t[25]=m):m=t[25],m}function G(){let e=l(e=>e.language),t=u(e),n=t.projectsPage,r=w(e),a=i(),c=N(e=>e.setPageHeader),b=N(e=>e.clearPageHeader),[C,O]=(0,H.useState)(null),[k,j]=(0,H.useState)(!0),[M,F]=(0,H.useState)(null),[ee,re]=(0,H.useState)(!1),[ae,se]=(0,H.useState)(``),[ue,L]=(0,H.useState)(null),[z,de]=(0,H.useState)(!1),B=P({chat:t.chat}),V=(0,H.useRef)(null),pe=S({disabled:z,chat:t.chat,onTranscript:e=>{se(t=>ce(t,e)),window.setTimeout(()=>V.current?.focus(),0)}}),{phase:me,voiceActive:G,startVoiceInput:K,cancelVoiceInput:q,confirmVoiceInput:J,retryVoiceInput:ve}=pe,Y=(0,H.useCallback)(async(t=!1)=>{t&&j(!0),F(null);try{let t=await te(e);O({...t,needsUser:t.needsUser.filter(e=>e.primaryAction?.type!==`review_judgment`&&e.openAction?.type!==`review_judgment`),background:t.background.filter(e=>e.primaryAction?.type!==`review_judgment`&&e.openAction?.type!==`review_judgment`)})}catch(e){F(e instanceof Error?e.message:String(e))}finally{j(!1)}},[e]);(0,H.useEffect)(()=>{Y(!0)},[Y]),(0,H.useEffect)(()=>{let e,t=t=>{e!==void 0&&window.clearTimeout(e),e=window.setTimeout(()=>{e=void 0,Y()},t)},n=()=>t(100),r=()=>t(750),i=[`session-created`,`agent-run-started`,`agent-run-ended`,`automation-run-completed`,`workflow-run-updated`,`workflow-run-error`],a=[`session-updated`,`session-transcript-updated`];return i.forEach(e=>window.addEventListener(e,n)),a.forEach(e=>window.addEventListener(e,r)),()=>{i.forEach(e=>window.removeEventListener(e,n)),a.forEach(e=>window.removeEventListener(e,r)),e!==void 0&&window.clearTimeout(e)}},[Y]);let X=(0,H.useCallback)(async e=>{if(!(e.length===0||z)){de(!0);try{await B.processFiles(e)}finally{de(!1)}}},[z,B.processFiles]),Z=(0,H.useCallback)(async e=>{let t=I(e.clipboardData);t.length!==0&&(e.preventDefault(),await X(t))},[X]),Q=(0,H.useCallback)(e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,B.setIsDragging(!0))},[B.setIsDragging]),$=(0,H.useCallback)(e=>{let t=e.relatedTarget;(!(t instanceof Node)||!e.currentTarget.contains(t))&&B.setIsDragging(!1)},[B.setIsDragging]),ye=(0,H.useCallback)(async e=>{e.preventDefault(),B.setIsDragging(!1),await X(Array.from(e.dataTransfer.files))},[B.setIsDragging,X]),be=(0,H.useCallback)(e=>{e.preventDefault();let t=B.wireAttachmentsPayload(),n=ie(ae,t.length>0?oe(t):void 0,{projectScope:`none`});n&&(re(!1),se(``),B.clearAttachments(),a(n))},[B.clearAttachments,B.wireAttachmentsPayload,ae,a]),xe=B.attachments.length>=10,Se={attachTitle:xe?W(t.chat.maxAttachmentsReached,{max:10}):`${t.chat.attachFile} (${B.attachments.length}/10)`,dropFiles:t.chat.dropFiles,intentLabel:r.intentLabel,intentPlaceholder:r.intentPlaceholder,intentSuggestion:r.intentSuggestion,shortcut:n.home.submitShortcut,submit:r.newWork},Ce=v(`/api/proactive/overview`,le,{refreshInterval:15e3}),we=!!Ce.data?.scenes.some(e=>e.status===`prepared`),Te=!!Ce.data?.scenes.some(e=>e.status===`changed`),Ee=!!Ce.data?.scenes.some(e=>e.status===`following`),De=!!Ce.data?.scenes.length,Oe=!!(C&&C.needsUser.length===0&&C.backgroundCount===0&&Ce.data&&!De),ke=Oe||ee;(0,H.useEffect)(()=>{!ke&&G&&q()},[q,ke,G]),(0,H.useEffect)(()=>{let e=e=>{let t=e.detail?.target;t&&t!==`chat`||!ke||z||(e.preventDefault(),me===`recording`?J():me===`idle`?(V.current?.focus(),K()):me===`error`&&ve())},t=e=>{let t=e.detail?.target;t&&t!==`chat`||!ke||!G||(e.preventDefault(),q(),V.current?.focus())};return window.addEventListener(x,e),window.addEventListener(A,t),()=>{window.removeEventListener(x,e),window.removeEventListener(A,t)}},[z,q,ke,J,ve,K,G,me]);let Ae=(0,H.useCallback)(e=>{e||q(),re(e)},[q]),je=(0,H.useMemo)(()=>Oe?null:(0,R.jsxs)(y,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>re(!0),children:[(0,R.jsx)(o,{className:`size-4`,"aria-hidden":!0}),r.newWork]}),[r.newWork,Oe]),Me=(0,H.useCallback)((e,t)=>{if(e.type===`open`){a(e.href);return}if(e.type===`review_judgment`){a(`/assistant-work?item=${encodeURIComponent(e.itemId)}`);return}L(t),F(null),(async()=>{try{e.type===`connector_decision`?await E({kind:`connector_approval`,approvalId:e.approvalId},e.decision):e.type===`retry_run`?await D({kind:e.subjectKind,runId:e.runId}):e.type===`acknowledge_run`&&await T({kind:e.subjectKind,runId:e.runId}),await Y()}catch(e){F(e instanceof Error?e.message:String(e))}finally{L(null)}})()},[Y,a]);(0,H.useLayoutEffect)(()=>(c({startExtra:null,main:(0,R.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),end:je}),()=>b()),[b,je,c,n.title]);let Ne=(C?.needsUser.length??0)+(Ce.data?.scenes.filter(e=>e.status===`needs_decision`).length??0),Pe=C?.backgroundCount??0,Fe=Ne>0?W(n.home.attentionTitle,{count:Ne}):we?e===`zh`?`助理准备好了这些`:`Your assistant prepared these`:Te?e===`zh`?`有一些值得知道的变化`:`A few changes are worth knowing`:Pe>0?n.home.clearTitle:Ee?e===`zh`?`助理在跟进你交代的事`:`Your assistant is following through`:Ce.data?n.home.idleTitle:e===`zh`?`今天的工作`:`Your work today`,Ie=Ne>0?Pe>0?W(n.home.attentionIntroWithBackground,{count:Pe}):n.home.attentionIntro:we?e===`zh`?`成果已经整理好,可以直接查看或继续办理。`:`The results are ready to review or continue.`:Te?e===`zh`?`这里是可能影响你当前工作的最新变化。`:`These changes may affect your current work.`:Pe>0?W(n.home.clearIntro,{count:Pe}):Ee?e===`zh`?`助理记着这些事项,有实质进展时会带回来。`:`Your assistant remembers these items and will bring back useful progress.`:Ce.data?n.home.idleIntro:e===`zh`?`正在核对已交代的事项。`:`Checking your delegated work.`;return(0,R.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[920px] flex-1 flex-col px-4 py-8 sm:px-6 lg:px-8 lg:py-12`,children:[(0,R.jsx)(`input`,{ref:B.fileInputRef,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{let t=e.target.files;t&&X(Array.from(t)),e.target.value=``}}),(0,R.jsx)(_,{open:ee,onOpenChange:Ae,children:(0,R.jsxs)(m,{children:[(0,R.jsx)(d,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,R.jsxs)(h,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(31rem,calc(100dvh-1.5rem))] w-[min(36rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,children:[(0,R.jsxs)(`div`,{className:`flex shrink-0 items-start gap-4 border-b border-edge px-5 py-4`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(g,{className:`text-base font-semibold text-fg`,children:r.dialogTitle}),(0,R.jsx)(f,{className:`mt-1 text-sm leading-5 text-fg-muted`,children:r.dialogDescription})]}),(0,R.jsx)(p,{asChild:!0,children:(0,R.jsx)(y,{type:`button`,variant:`ghost`,className:`-mr-2 -mt-1 size-8 shrink-0 rounded-lg p-0`,title:n.cancel,"aria-label":n.cancel,children:(0,R.jsx)(s,{className:`size-4`,"aria-hidden":!0})})})]}),(0,R.jsx)(U,{variant:`dialog`,inputId:`new-conversation-intent`,inputRef:V,intent:ae,labels:{...Se,submit:r.submit},attachments:B.attachments,isDragging:B.isDragging,attachmentBusy:z,attachmentsFull:xe,voice:pe,chat:t.chat,cancelAction:(0,R.jsx)(p,{asChild:!0,children:(0,R.jsx)(y,{type:`button`,variant:`ghost`,children:n.cancel})}),onIntentChange:se,onPickFiles:()=>B.fileInputRef.current?.click(),onRemoveAttachment:B.removeAttachment,onPaste:e=>void Z(e),onDragOver:Q,onDragLeave:$,onDrop:e=>void ye(e),onSubmit:be})]})]})}),M?(0,R.jsxs)(`div`,{className:`mb-6 flex items-center justify-between gap-3 rounded-xl border border-danger/25 bg-danger-soft px-4 py-3 text-sm text-danger`,children:[(0,R.jsx)(`span`,{children:M}),(0,R.jsx)(y,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>void Y(),children:n.home.retry})]}):null,k?(0,R.jsx)(he,{}):C?(0,R.jsxs)(`div`,{className:Oe?`mx-auto my-auto w-full max-w-[640px]`:`w-full`,children:[(0,R.jsxs)(`section`,{className:Oe?`w-full text-center`:`max-w-3xl`,children:[(0,R.jsx)(`h2`,{className:`text-3xl font-semibold leading-tight tracking-[-0.035em] text-fg sm:text-4xl`,children:Fe}),(0,R.jsx)(`p`,{className:Oe?`mx-auto mt-3 max-w-xl text-sm leading-6 text-fg-muted sm:text-base sm:leading-7`:`mt-3 max-w-2xl text-sm leading-6 text-fg-muted sm:text-base sm:leading-7`,children:Ie}),Oe?(0,R.jsx)(U,{variant:`inline`,inputId:`idle-conversation-intent`,inputRef:V,intent:ae,labels:Se,attachments:B.attachments,isDragging:B.isDragging,attachmentBusy:z,attachmentsFull:xe,voice:pe,chat:t.chat,onIntentChange:se,onPickFiles:()=>B.fileInputRef.current?.click(),onRemoveAttachment:B.removeAttachment,onPaste:e=>void Z(e),onDragOver:Q,onDragLeave:$,onDrop:e=>void ye(e),onSubmit:be}):null]}),C.needsUser.length>0?(0,R.jsxs)(`section`,{className:`mt-10`,"aria-labelledby":`home-needs-user-title`,children:[(0,R.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 px-1`,children:[(0,R.jsx)(ne,{className:`size-4 text-warning`,"aria-hidden":!0}),(0,R.jsx)(`h2`,{id:`home-needs-user-title`,className:`text-sm font-semibold text-fg`,children:n.home.needsUserTitle})]}),(0,R.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base`,children:C.needsUser.map(t=>(0,R.jsx)(ge,{item:t,busy:ue===t.id,recommendationLabel:n.home.recommendationLabel,dueLabel:n.home.dueLabel,failureLabel:r.runAttention,locale:e,onAction:Me},t.id))})]}):null,(0,R.jsx)(`section`,{className:Oe?`mt-6 sm:mt-8`:`mt-10`,children:(0,R.jsx)(fe,{compact:!0})}),C.background.length>0?(0,R.jsxs)(`section`,{className:`mt-10`,"aria-labelledby":`home-background-title`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-1`,children:[(0,R.jsx)(`h2`,{id:`home-background-title`,className:`text-sm font-semibold text-fg`,children:n.home.backgroundTitle}),(0,R.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:W(n.home.backgroundCount,{count:C.backgroundCount})})]}),(0,R.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle border-y border-edge-subtle`,children:C.background.map(e=>(0,R.jsx)(_e,{item:e,onAction:Me},e.id))})]}):null]}):null]})}export{G as HomePage};