@xopcai/xopc 0.0.179 → 0.0.180

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 (221) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-A5FUMjeV.js → activity-store-DFKtQDgE.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-NghNiDWx.js → agent-avatar-dicebear-CcTvB_4W.js} +1 -1
  5. package/dist/gateway/static/root/assets/{agents-Baq8Shzy.js → agents-DgGj9bu6.js} +1 -1
  6. package/dist/gateway/static/root/assets/{api-Bmzslx0Z.js → api-CUClAvuL.js} +1 -1
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-DDWS_BBJ.js → app-management-settings-panel-Ib-cWKHM.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-C6znvVtX.js → appearance-settings-CRSN8WuA.js} +1 -1
  9. package/dist/gateway/static/root/assets/{apps-page-d-Y0Jbe1.js → apps-page-B5xahuT-.js} +1 -1
  10. package/dist/gateway/static/root/assets/{archive-plugin-fvTZhPUr.js → archive-plugin-BBF9zspN.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-BFEgvg-Q.js → attachment-load-D3QQfA7w.js} +1 -1
  12. package/dist/gateway/static/root/assets/automations-page-BUYrvMmD.js +6 -0
  13. package/dist/gateway/static/root/assets/{binary-plugins-CuI2bOc7.js → binary-plugins-D78XOjJ3.js} +1 -1
  14. package/dist/gateway/static/root/assets/{block-editor-Z_k8W0al.js → block-editor-D_VVXlYX.js} +1 -1
  15. package/dist/gateway/static/root/assets/{browser-settings-page-CGApoYPr.js → browser-settings-page-Cjw07q9h.js} +1 -1
  16. package/dist/gateway/static/root/assets/{browser-workflow-inputs-gs6b5e9-.js → browser-workflow-inputs-_gu08MA4.js} +1 -1
  17. package/dist/gateway/static/root/assets/{browser-workflows-page-Cq5qXStp.js → browser-workflows-page-58DBMXgG.js} +1 -1
  18. package/dist/gateway/static/root/assets/{capabilities-settings-panel-BC-8n4Hl.js → capabilities-settings-panel-D_dfVxHY.js} +1 -1
  19. package/dist/gateway/static/root/assets/{capability-presets-api-BTKhPoDC.js → capability-presets-api-DhCn9rPv.js} +1 -1
  20. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-D7WQ0oBN.js → capability-presets-settings-panel-LWWIYUT7.js} +1 -1
  21. package/dist/gateway/static/root/assets/{channel-recipient-api-TwMak0SE.js → channel-recipient-api-DYtoNV5A.js} +1 -1
  22. package/dist/gateway/static/root/assets/{channels-settings-DysELlO_.js → channels-settings-Cyj5OunL.js} +1 -1
  23. package/dist/gateway/static/root/assets/channels-status-swr-TEFnV0IG.js +1 -0
  24. package/dist/gateway/static/root/assets/{connector-logo-DBKotvNr.js → connector-logo-CxIXnifA.js} +1 -1
  25. package/dist/gateway/static/root/assets/{connectors-page-QH-0WnOo.js → connectors-page-0TobCpBB.js} +2 -2
  26. package/dist/gateway/static/root/assets/{desktop-pet-Dwml8znf.js → desktop-pet-CwVSLL6N.js} +1 -1
  27. package/dist/gateway/static/root/assets/{desktop-pet-settings-CyIg2jJp.js → desktop-pet-settings-BOIp4q0Z.js} +1 -1
  28. package/dist/gateway/static/root/assets/{directory-picker-path-field-B6fc_7SL.js → directory-picker-path-field-C8_lsW6S.js} +1 -1
  29. package/dist/gateway/static/root/assets/{dreaming-settings-CUQxGnDf.js → dreaming-settings-Da9FeWQl.js} +1 -1
  30. package/dist/gateway/static/root/assets/{extension-debug-page-AbRNi2ON.js → extension-debug-page-CMNnSJP6.js} +1 -1
  31. package/dist/gateway/static/root/assets/{extension-page-ClYfiLXC.js → extension-page-t0pJqLvM.js} +1 -1
  32. package/dist/gateway/static/root/assets/{extension-settings-page-BGVP2hw1.js → extension-settings-page-aiR-tKnW.js} +1 -1
  33. package/dist/gateway/static/root/assets/{gateway-config-api-B7GqtklK.js → gateway-config-api-CkyQBD6r.js} +1 -1
  34. package/dist/gateway/static/root/assets/{gateway-settings-BMeK8igT.js → gateway-settings-BIZfAgfB.js} +1 -1
  35. package/dist/gateway/static/root/assets/{gateway-startup-retry-CKKL96r_.js → gateway-startup-retry-CSU7UvzG.js} +1 -1
  36. package/dist/gateway/static/root/assets/{goals-settings-Dj0ao2qA.js → goals-settings-Dx9uTyWF.js} +1 -1
  37. package/dist/gateway/static/root/assets/{heartbeat-settings-CTI2nPKa.js → heartbeat-settings-Cnr5ORXL.js} +1 -1
  38. package/dist/gateway/static/root/assets/{image-generation-api-BY3VQ5Mv.js → image-generation-api-BR6Kb77X.js} +1 -1
  39. package/dist/gateway/static/root/assets/{index-BDzspHrg.js → index-BA56bQ68.js} +8 -8
  40. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CELtDFz3.js → keyboard-shortcuts-settings-D76uYKeQ.js} +1 -1
  41. package/dist/gateway/static/root/assets/{local-app-workbench-page-m8CTSGix.js → local-app-workbench-page-DSUNtLHg.js} +1 -1
  42. package/dist/gateway/static/root/assets/{local-apps-page-CF5uUd1n.js → local-apps-page-BsLnojTh.js} +1 -1
  43. package/dist/gateway/static/root/assets/{locale-store-DIVc0AQs.js → locale-store-BNC8HUCI.js} +1 -1
  44. package/dist/gateway/static/root/assets/{logs-page-DmH7Tk4k.js → logs-page-yI8kpQtO.js} +1 -1
  45. package/dist/gateway/static/root/assets/{markdown-split-CN85EdB8.js → markdown-split-D6smTQWD.js} +1 -1
  46. package/dist/gateway/static/root/assets/{media-plugins-CxYEc-b8.js → media-plugins-D1TmMF0A.js} +1 -1
  47. package/dist/gateway/static/root/assets/{messages-DYqBwJAK.js → messages-H_iJjnEM.js} +3 -3
  48. package/dist/gateway/static/root/assets/{notes-page-Goab4781.js → notes-page-Vt-diFf0.js} +1 -1
  49. package/dist/gateway/static/root/assets/{notes-workbench-C4jDBVBN.js → notes-workbench-BD297EZt.js} +2 -2
  50. package/dist/gateway/static/root/assets/{outcome-detail-page-DNRfeLZp.js → outcome-detail-page-C5i_ZR9a.js} +1 -1
  51. package/dist/gateway/static/root/assets/{page-tabs-tQNQcAts.js → page-tabs-BnSzIjH0.js} +1 -1
  52. package/dist/gateway/static/root/assets/{preview-open-alternatives-BSTlgsDB.js → preview-open-alternatives-CF12Eqi4.js} +1 -1
  53. package/dist/gateway/static/root/assets/{product-open-page-iQ5gTCip.js → product-open-page-Du0TE_CU.js} +1 -1
  54. package/dist/gateway/static/root/assets/{project-detail-page-D7anK-eu.js → project-detail-page-D1HGz7Dy.js} +1 -1
  55. package/dist/gateway/static/root/assets/{projects-page-BePESKWy.js → projects-page-CqP2TnW-.js} +1 -1
  56. package/dist/gateway/static/root/assets/{remote-access-hub-CHrzBKIs.js → remote-access-hub-BXdVJLS3.js} +1 -1
  57. package/dist/gateway/static/root/assets/{save-bar-controls-BsPf5Gkk.js → save-bar-controls-B53UNtDM.js} +1 -1
  58. package/dist/gateway/static/root/assets/{schedule-field-kAytH7mq.js → schedule-field-C3dIMN5q.js} +1 -1
  59. package/dist/gateway/static/root/assets/{schema-form-Bbw8l2ri.js → schema-form-BKvpxqof.js} +1 -1
  60. package/dist/gateway/static/root/assets/{sessions-page-He5YAczL.js → sessions-page-CPAwDdl5.js} +1 -1
  61. package/dist/gateway/static/root/assets/settings-advanced-gate-C-jGsoft.js +1 -0
  62. package/dist/gateway/static/root/assets/{settings-form-section-BqbibcnJ.js → settings-form-section-kt6GIS32.js} +1 -1
  63. package/dist/gateway/static/root/assets/{settings-loading-skeleton-DNLNCEGT.js → settings-loading-skeleton-85eUPcKz.js} +1 -1
  64. package/dist/gateway/static/root/assets/{settings-page-BR6Ss0bK.js → settings-page-Di5x6Xrc.js} +1 -1
  65. package/dist/gateway/static/root/assets/{settings-page-layout-Cdb1e2Cz.js → settings-page-layout-CkkCee_x.js} +1 -1
  66. package/dist/gateway/static/root/assets/{setup-status-panel-moT-D-ia.js → setup-status-panel-uxEE6gAB.js} +1 -1
  67. package/dist/gateway/static/root/assets/{share-preview-page-CkrASny2.js → share-preview-page-BtLEstaI.js} +1 -1
  68. package/dist/gateway/static/root/assets/{shares-settings-X49zY21H.js → shares-settings-2mcsMWgn.js} +1 -1
  69. package/dist/gateway/static/root/assets/skill-reload-api-ocDwsrEt.js +1 -0
  70. package/dist/gateway/static/root/assets/skills-page-9_jfsFU5.js +2 -0
  71. package/dist/gateway/static/root/assets/{skills-page.utils-BG5dGkyA.js → skills-page.utils-C2SHvq8V.js} +1 -1
  72. package/dist/gateway/static/root/assets/{system-settings-panel-XdY8eyYf.js → system-settings-panel-CIJ66cUy.js} +1 -1
  73. package/dist/gateway/static/root/assets/{theme-store-DtwI_VLT.js → theme-store-ClDa_Bci.js} +1 -1
  74. package/dist/gateway/static/root/assets/{time-picker-UghsQu_I.js → time-picker-D0zAsHOo.js} +1 -1
  75. package/dist/gateway/static/root/assets/{typed-models-lib-DOnpwsrE.js → typed-models-lib-GsmwmB40.js} +1 -1
  76. package/dist/gateway/static/root/assets/{use-channel-catalog-BWDtfNvQ.js → use-channel-catalog-BQz3K7xj.js} +1 -1
  77. package/dist/gateway/static/root/assets/{user-context-page-BtNBEtKj.js → user-context-page-Bn4BLg4W.js} +1 -1
  78. package/dist/gateway/static/root/assets/{voice-api-key-field-DP80jW-W.js → voice-api-key-field-Blaxsbb3.js} +1 -1
  79. package/dist/gateway/static/root/assets/{work-copy-hQmivDgT.js → work-copy-Cwyan9Sn.js} +1 -1
  80. package/dist/gateway/static/root/assets/{work-discovery-page-CkDOVZBr.js → work-discovery-page-iJ9RBSpu.js} +1 -1
  81. package/dist/gateway/static/root/assets/{work-item-detail-page-CqvkcFcR.js → work-item-detail-page-CqTH7PQX.js} +1 -1
  82. package/dist/gateway/static/root/assets/{work-page-BL8TZW4Z.js → work-page-H3m99ccS.js} +1 -1
  83. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BLlVqKdA.js → workflow-run-setup-panel-CTG4RpRE.js} +1 -1
  84. package/dist/gateway/static/root/assets/{workflows-page-BgsdRu3_.js → workflows-page-BxZSKMfv.js} +1 -1
  85. package/dist/gateway/static/root/index.html +6 -6
  86. package/dist/package.js +1 -1
  87. package/dist/src/agent/agent-manager.d.ts +4 -1
  88. package/dist/src/agent/agent-manager.js +21 -7
  89. package/dist/src/agent/bootstrap/filter-bootstrap-files.js +1 -1
  90. package/dist/src/agent/embedded/model-runtime.js +1 -1
  91. package/dist/src/agent/embedded/run-for-session.d.ts +2 -0
  92. package/dist/src/agent/embedded/run-for-session.js +3 -1
  93. package/dist/src/agent/goals/post-turn.js +1 -1
  94. package/dist/src/agent/image/tool-model-config.js +1 -1
  95. package/dist/src/agent/inbound/turn-dispatcher.d.ts +6 -1
  96. package/dist/src/agent/inbound/turn-dispatcher.js +5 -2
  97. package/dist/src/agent/ipc/inbox.js +1 -1
  98. package/dist/src/agent/lifecycle/timeout-wrapper.d.ts +2 -0
  99. package/dist/src/agent/lifecycle/timeout-wrapper.js +39 -9
  100. package/dist/src/agent/mcp/bundle-mcp-materialize.js +2 -2
  101. package/dist/src/agent/mcp/bundle-mcp-runtime.js +6 -1
  102. package/dist/src/agent/mcp/bundle-mcp-types.d.ts +1 -1
  103. package/dist/src/agent/mcp/mcp-transport-config.d.ts +2 -0
  104. package/dist/src/agent/mcp/mcp-transport-config.js +10 -3
  105. package/dist/src/agent/mcp/mcp-transport.d.ts +1 -0
  106. package/dist/src/agent/mcp/mcp-transport.js +5 -2
  107. package/dist/src/agent/memory/dreaming/config.js +1 -1
  108. package/dist/src/agent/orchestration/run-agent-turn-with-timeout.d.ts +1 -1
  109. package/dist/src/agent/orchestration/run-agent-turn-with-timeout.js +6 -2
  110. package/dist/src/agent/service/direct-turn-helpers.d.ts +1 -0
  111. package/dist/src/agent/service/direct-turn-helpers.js +1 -0
  112. package/dist/src/agent/service/process-direct-one-shot.d.ts +3 -0
  113. package/dist/src/agent/service/process-direct-one-shot.js +4 -1
  114. package/dist/src/agent/service.d.ts +1 -0
  115. package/dist/src/agent/service.js +5 -2
  116. package/dist/src/agent/session/session-inspector.js +1 -1
  117. package/dist/src/agent/skills/config.js +6 -0
  118. package/dist/src/agent/skills/filesystem-watcher.d.ts +4 -0
  119. package/dist/src/agent/skills/filesystem-watcher.js +16 -7
  120. package/dist/src/agent/skills/hub-lock.js +1 -1
  121. package/dist/src/agent/skills/index.d.ts +10 -7
  122. package/dist/src/agent/skills/index.js +56 -47
  123. package/dist/src/agent/skills/skill-manage-ops.js +1 -1
  124. package/dist/src/agent/skills/skill-manager.d.ts +5 -2
  125. package/dist/src/agent/skills/skill-manager.js +10 -5
  126. package/dist/src/agent/skills/skill-sources.d.ts +18 -0
  127. package/dist/src/agent/skills/skill-sources.js +143 -0
  128. package/dist/src/agent/skills/types.d.ts +25 -2
  129. package/dist/src/agent/tools/delegate-tool.js +2 -1
  130. package/dist/src/agent/tools/executor.d.ts +2 -0
  131. package/dist/src/agent/tools/executor.js +18 -11
  132. package/dist/src/agent/tools/factory.js +2 -0
  133. package/dist/src/agent/tools/index.d.ts +1 -0
  134. package/dist/src/agent/tools/index.js +2 -1
  135. package/dist/src/agent/tools/managed-job-tool.d.ts +2 -0
  136. package/dist/src/agent/tools/managed-job-tool.js +160 -0
  137. package/dist/src/agent/workspace-runtime/registry.d.ts +3 -0
  138. package/dist/src/agent/workspace-runtime/registry.js +3 -1
  139. package/dist/src/agent-runtime/index.js +1 -1
  140. package/dist/src/agent-runtime/runtime-profile.js +1 -1
  141. package/dist/src/auth/credentials.d.ts +9 -1
  142. package/dist/src/auth/credentials.js +112 -56
  143. package/dist/src/auth/model-credential-store.js +7 -22
  144. package/dist/src/auth/oauth-provider-lock.d.ts +5 -0
  145. package/dist/src/auth/oauth-provider-lock.js +91 -0
  146. package/dist/src/auth/profiles/store.js +1 -1
  147. package/dist/src/auth/sync-provider-auth.js +2 -2
  148. package/dist/src/automations/domain/defaults.d.ts +8 -1
  149. package/dist/src/automations/domain/defaults.js +9 -2
  150. package/dist/src/automations/domain/index.js +2 -2
  151. package/dist/src/automations/domain/types.d.ts +33 -7
  152. package/dist/src/automations/domain/validation.d.ts +8 -0
  153. package/dist/src/automations/domain/validation.js +2 -0
  154. package/dist/src/automations/draft/automation-draft-validator.d.ts +2 -1
  155. package/dist/src/automations/index.js +2 -2
  156. package/dist/src/automations/service/action-executor.d.ts +2 -2
  157. package/dist/src/automations/service/action-executor.js +144 -34
  158. package/dist/src/automations/service/automation-service.d.ts +4 -0
  159. package/dist/src/automations/service/automation-service.js +197 -18
  160. package/dist/src/automations/storage/automation-run-repository.d.ts +1 -0
  161. package/dist/src/automations/storage/automation-run-repository.js +37 -7
  162. package/dist/src/automations/storage/index.js +2 -2
  163. package/dist/src/browser/providers/browser-ext-install.js +1 -1
  164. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  165. package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
  166. package/dist/src/cli/commands/models.js +1 -1
  167. package/dist/src/cli/utils/oauth-login.js +1 -7
  168. package/dist/src/config/agent-profile.js +1 -1
  169. package/dist/src/config/index.js +4 -4
  170. package/dist/src/config/loader.js +1 -1
  171. package/dist/src/config/models-json.js +1 -1
  172. package/dist/src/config/schema.d.ts +3 -0
  173. package/dist/src/config/schema.js +2 -1
  174. package/dist/src/extensions/lockfile.js +1 -1
  175. package/dist/src/gateway/agents-admin.js +2 -2
  176. package/dist/src/gateway/file-path-classifier.js +1 -1
  177. package/dist/src/gateway/heartbeat/service.js +1 -1
  178. package/dist/src/gateway/hono/lib/config-payload.js +1 -1
  179. package/dist/src/gateway/hono/oauth-async.js +1 -7
  180. package/dist/src/gateway/hono/oauth.js +1 -7
  181. package/dist/src/gateway/hono/routes/models.js +1 -1
  182. package/dist/src/gateway/hono/routes/you.js +1 -1
  183. package/dist/src/gateway/service/config-coordinator.js +1 -1
  184. package/dist/src/gateway/service.js +3 -3
  185. package/dist/src/goals/goal-workflow-judge.js +1 -1
  186. package/dist/src/heartbeat/index.js +1 -1
  187. package/dist/src/notes/service.js +1 -1
  188. package/dist/src/projects/project-loop.js +3 -3
  189. package/dist/src/providers/auth-runtime/oauth.js +12 -0
  190. package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
  191. package/dist/src/providers/index.js +2 -2
  192. package/dist/src/providers/model-registry.js +1 -1
  193. package/dist/src/providers/register-runtime-providers.js +1 -1
  194. package/dist/src/storage/sqlite/migrations/088_automation_execution_deadlines.sql +5 -0
  195. package/dist/src/storage/sqlite/migrations/089_automation_run_leases.sql +8 -0
  196. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  197. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  198. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  199. package/dist/src/storage/sqlite/schema.js +1 -1
  200. package/dist/src/tui/backends/embedded-backend.d.ts +2 -0
  201. package/dist/src/tui/backends/embedded-backend.js +11 -7
  202. package/dist/src/tui/tui-backend.d.ts +2 -0
  203. package/dist/src/tui/tui-oauth-login.js +1 -7
  204. package/dist/src/tui/tui-picker-overlay.js +1 -0
  205. package/dist/src/tui/tui-picker-services.d.ts +1 -0
  206. package/dist/src/tui/tui-skills-autocomplete.d.ts +6 -2
  207. package/dist/src/tui/tui-skills-autocomplete.js +10 -6
  208. package/dist/src/tui/tui-startup-resources.d.ts +3 -1
  209. package/dist/src/tui/tui-startup-resources.js +4 -3
  210. package/dist/src/tui/tui.js +4 -1
  211. package/dist/src/work/home-query-service.d.ts +31 -2
  212. package/dist/src/work/home-query-service.js +4 -4
  213. package/dist/src/work/index.js +2 -2
  214. package/dist/src/workflows/service/workflow-run-service.js +1 -1
  215. package/dist/src/workflows/service/workflow-run-service.types.d.ts +3 -1
  216. package/package.json +1 -1
  217. package/dist/gateway/static/root/assets/automations-page-CFYOCBlQ.js +0 -6
  218. package/dist/gateway/static/root/assets/channels-status-swr-BAC-R8IK.js +0 -1
  219. package/dist/gateway/static/root/assets/settings-advanced-gate-2eAC9GCP.js +0 -1
  220. package/dist/gateway/static/root/assets/skill-reload-api-CjpnFfOH.js +0 -1
  221. package/dist/gateway/static/root/assets/skills-page-DEwfSOUE.js +0 -2
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-JdwAhgNB.js";import{r as a,s as o}from"./locale-store-DIVc0AQs.js";import{Qa as s,Uc as c}from"./index-BDzspHrg.js";function l(e,t){if(!e.payload)throw Error(e.error??t);return e.payload}async function u(){return l(await o(a(`/api/connectors/catalog`)),`Could not load connector catalog.`).connectors}async function d(e){let t=new URLSearchParams;return e?.q?.trim()&&t.set(`q`,e.q.trim()),e?.page&&t.set(`page`,String(e.page)),e?.pageSize&&t.set(`pageSize`,String(e.pageSize)),e?.refresh&&t.set(`refresh`,`1`),e?.verification&&t.set(`verification`,e.verification),l(await o(a(`/api/connectors/composio/catalog${t.size?`?${t.toString()}`:``}`)),`Could not load Composio catalog.`)}async function f(e){let t=new URLSearchParams;return e?.q?.trim()&&t.set(`q`,e.q.trim()),e?.page&&t.set(`page`,String(e.page)),e?.pageSize&&t.set(`pageSize`,String(e.pageSize)),e?.category?.trim()&&t.set(`category`,e.category.trim()),e?.sort&&t.set(`sort`,e.sort),l(await o(a(`/api/capabilities/connectors${t.size?`?${t.toString()}`:``}`)),`Could not load Store connector capabilities.`)}async function p(e,t){return l(await o(a(`/api/capabilities/connectors/${encodeURIComponent(e)}/install-plan`),{method:`POST`,body:JSON.stringify({version:t})}),`Could not prepare connector installation.`).plan}async function m(e,t,n){let r=await o(a(`/api/capabilities/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify({...t,version:n})});return s(),l(r,`Could not install Store connector.`).instance}async function h(){return l(await o(a(`/api/connectors/installed`)),`Could not load installed connectors.`).instances}async function g(e){return l(await o(a(`/api/connectors/${encodeURIComponent(e)}/auth/start`),{method:`POST`}),`Could not start connector authorization.`).authorization}async function _(){return l(await o(a(`/api/connectors/composio/setup-status`)),`Could not check the connection service.`)}async function v(e){l(await o(a(`/api/connectors/composio/setup`),{method:`POST`,body:JSON.stringify({apiKey:e})}),`Could not enable the connection service.`)}async function y(e,t){let n=await o(a(`/api/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify(t)});return s(),l(n,`Could not install connector.`).instance}async function b(e,t={}){return l(await o(a(`/api/connectors/preview`),{method:`POST`,body:JSON.stringify({...t,definition:e})}),`Could not preview connector capabilities.`).preview}async function x(e,t){return l(await o(a(`/api/connectors/${encodeURIComponent(e)}/config`),{method:`POST`,body:JSON.stringify(t)}),`Could not update connector config.`).instance}async function S(e){await o(a(`/api/connectors/${encodeURIComponent(e)}`),{method:`DELETE`}),s()}async function C(e){return l(await o(a(`/api/connectors/${encodeURIComponent(e)}/test`),{method:`POST`}),`Connector test failed.`)}async function w(){return l(await o(a(`/api/connectors/composio/connections`)),`Could not load Composio connections.`).connections}async function T(e,t,n=12e4){let r=Date.now()+n;for(;Date.now()<r;){let n=(await w().catch(()=>[])).find(n=>n.toolkit.toLowerCase()===e.toLowerCase()&&n.status===`active`&&(!t||n.providerConnectionId===t));if(n)return n;await new Promise(e=>window.setTimeout(e,2e3))}throw Error(`Connection authorization timed out.`)}async function E(e,t){return l(await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(t)}),`Could not update Composio connection.`).connection}async function D(e){return l(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/health`)),`Could not check Composio connector health.`).health}async function O(e){await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}/refresh`),{method:`POST`})}async function k(e){await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}`),{method:`DELETE`})}async function A(e){return l(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/scope`)),`Could not load Composio scope.`).scope}async function j(e,t){let n=await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/scope`),{method:`POST`,body:JSON.stringify({scope:t})});return s(),l(n,`Could not update Composio scope.`).scope}async function M(e){return l(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/policy`)),`Could not load Composio policy.`)}async function N(e,t){return l(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/policy`),{method:`PATCH`,body:JSON.stringify(t)}),`Could not update Composio policy.`).policy}async function P(e){return l(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/tools`)),`Could not load Composio tools.`).tools}async function F(e=50){return l(await o(a(`/api/connectors/composio/triggers?limit=${encodeURIComponent(String(e))}`)),`Could not load Composio trigger events.`).events}async function I(e){return l(await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}/learning`),{method:`POST`}),`Could not start learning from this connection.`).job}async function L(){return l(await o(a(`/api/connectors/learning`)),`Could not load connector learning jobs.`).jobs}async function R(e){return l(await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}/sync-policy`)),`Could not load connector sync policy.`).policy}async function z(e,t){return l(await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}/sync-policy`),{method:`PATCH`,body:JSON.stringify(t)}),`Could not update connector sync policy.`).policy}async function B(e,t){let n=t?`pause`:`resume`;l(await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}/learning/${n}`),{method:`POST`}),`Could not ${n} connector learning.`)}async function V(e){return l(await o(a(`/api/connectors/${encodeURIComponent(e)}/source-sync`),{method:`POST`}),`Could not sync connector source.`)}async function H(e=``,t=100){return l(await o(a(`/api/connectors/people?${new URLSearchParams({q:e,limit:String(t)}).toString()}`)),`Could not load the connected people graph.`)}async function U(e=`pending`){return l(await o(a(`/api/connectors/approvals?status=${encodeURIComponent(e)}`)),`Could not load connector approvals.`).approvals}async function W(e,t){return l(await o(a(`/api/connectors/approvals/respond`),{method:`POST`,body:JSON.stringify({id:e,decision:t})}),`Could not update connector approval.`).approval}var G=n(),K=e(t(),1),q=r(),J={sm:{frame:`size-9 rounded-lg`,image:`size-6`,fallback:`size-4`},md:{frame:`size-10 rounded-xl`,image:`size-7`,fallback:`size-5`},lg:{frame:`size-12 rounded-xl`,image:`size-8`,fallback:`size-5`}};function Y(e){let t=(0,G.c)(18),{connector:n,size:r,className:a}=e,o=r===void 0?`md`:r,s=n?.branding?.logoUrl,[l,u]=(0,K.useState)(!1),d=J[o],f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{u(!1)},t[0]=f):f=t[0];let p;t[1]===s?p=t[2]:(p=[s],t[1]=s,t[2]=p),(0,K.useEffect)(f,p);let m;t[3]!==a||t[4]!==d.frame?(m=i(`flex shrink-0 items-center justify-center overflow-hidden border border-edge bg-surface-base`,d.frame,a),t[3]=a,t[4]=d.frame,t[5]=m):m=t[5];let h;t[6]===n?h=t[7]:(h=n?.branding?.backgroundColor?{backgroundColor:n.branding.backgroundColor}:void 0,t[6]=n,t[7]=h);let g=n?.displayName,_;t[8]!==d.fallback||t[9]!==d.image||t[10]!==l||t[11]!==s?(_=s&&!l?(0,q.jsx)(`img`,{src:s,alt:``,loading:`lazy`,draggable:!1,className:i(`object-contain`,d.image),onError:()=>u(!0)}):(0,q.jsx)(c,{className:i(`text-fg-muted`,d.fallback),"aria-hidden":!0}),t[8]=d.fallback,t[9]=d.image,t[10]=l,t[11]=s,t[12]=_):_=t[12];let v;return t[13]!==m||t[14]!==h||t[15]!==g||t[16]!==_?(v=(0,q.jsx)(`span`,{className:m,style:h,title:g,children:_}),t[13]=m,t[14]=h,t[15]=g,t[16]=_,t[17]=v):v=t[17],v}export{V as A,S as C,B as D,j as E,z as F,T as I,E as M,N,I as O,x as P,O as S,k as T,P as _,u as a,L as b,p as c,A as d,_ as f,w as g,m as h,H as i,C as j,g as k,D as l,y as m,v as n,h as o,R as p,d as r,f as s,Y as t,M as u,F as v,W as w,b as x,U as y};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-JdwAhgNB.js";import{r as a,s as o}from"./locale-store-BNC8HUCI.js";import{Qa as s,Uc as c}from"./index-BA56bQ68.js";function l(e,t){if(!e.payload)throw Error(e.error??t);return e.payload}async function u(){return l(await o(a(`/api/connectors/catalog`)),`Could not load connector catalog.`).connectors}async function d(e){let t=new URLSearchParams;return e?.q?.trim()&&t.set(`q`,e.q.trim()),e?.page&&t.set(`page`,String(e.page)),e?.pageSize&&t.set(`pageSize`,String(e.pageSize)),e?.refresh&&t.set(`refresh`,`1`),e?.verification&&t.set(`verification`,e.verification),l(await o(a(`/api/connectors/composio/catalog${t.size?`?${t.toString()}`:``}`)),`Could not load Composio catalog.`)}async function f(e){let t=new URLSearchParams;return e?.q?.trim()&&t.set(`q`,e.q.trim()),e?.page&&t.set(`page`,String(e.page)),e?.pageSize&&t.set(`pageSize`,String(e.pageSize)),e?.category?.trim()&&t.set(`category`,e.category.trim()),e?.sort&&t.set(`sort`,e.sort),l(await o(a(`/api/capabilities/connectors${t.size?`?${t.toString()}`:``}`)),`Could not load Store connector capabilities.`)}async function p(e,t){return l(await o(a(`/api/capabilities/connectors/${encodeURIComponent(e)}/install-plan`),{method:`POST`,body:JSON.stringify({version:t})}),`Could not prepare connector installation.`).plan}async function m(e,t,n){let r=await o(a(`/api/capabilities/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify({...t,version:n})});return s(),l(r,`Could not install Store connector.`).instance}async function h(){return l(await o(a(`/api/connectors/installed`)),`Could not load installed connectors.`).instances}async function g(e){return l(await o(a(`/api/connectors/${encodeURIComponent(e)}/auth/start`),{method:`POST`}),`Could not start connector authorization.`).authorization}async function _(){return l(await o(a(`/api/connectors/composio/setup-status`)),`Could not check the connection service.`)}async function v(e){l(await o(a(`/api/connectors/composio/setup`),{method:`POST`,body:JSON.stringify({apiKey:e})}),`Could not enable the connection service.`)}async function y(e,t){let n=await o(a(`/api/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify(t)});return s(),l(n,`Could not install connector.`).instance}async function b(e,t={}){return l(await o(a(`/api/connectors/preview`),{method:`POST`,body:JSON.stringify({...t,definition:e})}),`Could not preview connector capabilities.`).preview}async function x(e,t){return l(await o(a(`/api/connectors/${encodeURIComponent(e)}/config`),{method:`POST`,body:JSON.stringify(t)}),`Could not update connector config.`).instance}async function S(e){await o(a(`/api/connectors/${encodeURIComponent(e)}`),{method:`DELETE`}),s()}async function C(e){return l(await o(a(`/api/connectors/${encodeURIComponent(e)}/test`),{method:`POST`}),`Connector test failed.`)}async function w(){return l(await o(a(`/api/connectors/composio/connections`)),`Could not load Composio connections.`).connections}async function T(e,t,n=12e4){let r=Date.now()+n;for(;Date.now()<r;){let n=(await w().catch(()=>[])).find(n=>n.toolkit.toLowerCase()===e.toLowerCase()&&n.status===`active`&&(!t||n.providerConnectionId===t));if(n)return n;await new Promise(e=>window.setTimeout(e,2e3))}throw Error(`Connection authorization timed out.`)}async function E(e,t){return l(await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(t)}),`Could not update Composio connection.`).connection}async function D(e){return l(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/health`)),`Could not check Composio connector health.`).health}async function O(e){await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}/refresh`),{method:`POST`})}async function k(e){await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}`),{method:`DELETE`})}async function A(e){return l(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/scope`)),`Could not load Composio scope.`).scope}async function j(e,t){let n=await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/scope`),{method:`POST`,body:JSON.stringify({scope:t})});return s(),l(n,`Could not update Composio scope.`).scope}async function M(e){return l(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/policy`)),`Could not load Composio policy.`)}async function N(e,t){return l(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/policy`),{method:`PATCH`,body:JSON.stringify(t)}),`Could not update Composio policy.`).policy}async function P(e){return l(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/tools`)),`Could not load Composio tools.`).tools}async function F(e=50){return l(await o(a(`/api/connectors/composio/triggers?limit=${encodeURIComponent(String(e))}`)),`Could not load Composio trigger events.`).events}async function I(e){return l(await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}/learning`),{method:`POST`}),`Could not start learning from this connection.`).job}async function L(){return l(await o(a(`/api/connectors/learning`)),`Could not load connector learning jobs.`).jobs}async function R(e){return l(await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}/sync-policy`)),`Could not load connector sync policy.`).policy}async function z(e,t){return l(await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}/sync-policy`),{method:`PATCH`,body:JSON.stringify(t)}),`Could not update connector sync policy.`).policy}async function B(e,t){let n=t?`pause`:`resume`;l(await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}/learning/${n}`),{method:`POST`}),`Could not ${n} connector learning.`)}async function V(e){return l(await o(a(`/api/connectors/${encodeURIComponent(e)}/source-sync`),{method:`POST`}),`Could not sync connector source.`)}async function H(e=``,t=100){return l(await o(a(`/api/connectors/people?${new URLSearchParams({q:e,limit:String(t)}).toString()}`)),`Could not load the connected people graph.`)}async function U(e=`pending`){return l(await o(a(`/api/connectors/approvals?status=${encodeURIComponent(e)}`)),`Could not load connector approvals.`).approvals}async function W(e,t){return l(await o(a(`/api/connectors/approvals/respond`),{method:`POST`,body:JSON.stringify({id:e,decision:t})}),`Could not update connector approval.`).approval}var G=n(),K=e(t(),1),q=r(),J={sm:{frame:`size-9 rounded-lg`,image:`size-6`,fallback:`size-4`},md:{frame:`size-10 rounded-xl`,image:`size-7`,fallback:`size-5`},lg:{frame:`size-12 rounded-xl`,image:`size-8`,fallback:`size-5`}};function Y(e){let t=(0,G.c)(18),{connector:n,size:r,className:a}=e,o=r===void 0?`md`:r,s=n?.branding?.logoUrl,[l,u]=(0,K.useState)(!1),d=J[o],f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{u(!1)},t[0]=f):f=t[0];let p;t[1]===s?p=t[2]:(p=[s],t[1]=s,t[2]=p),(0,K.useEffect)(f,p);let m;t[3]!==a||t[4]!==d.frame?(m=i(`flex shrink-0 items-center justify-center overflow-hidden border border-edge bg-surface-base`,d.frame,a),t[3]=a,t[4]=d.frame,t[5]=m):m=t[5];let h;t[6]===n?h=t[7]:(h=n?.branding?.backgroundColor?{backgroundColor:n.branding.backgroundColor}:void 0,t[6]=n,t[7]=h);let g=n?.displayName,_;t[8]!==d.fallback||t[9]!==d.image||t[10]!==l||t[11]!==s?(_=s&&!l?(0,q.jsx)(`img`,{src:s,alt:``,loading:`lazy`,draggable:!1,className:i(`object-contain`,d.image),onError:()=>u(!0)}):(0,q.jsx)(c,{className:i(`text-fg-muted`,d.fallback),"aria-hidden":!0}),t[8]=d.fallback,t[9]=d.image,t[10]=l,t[11]=s,t[12]=_):_=t[12];let v;return t[13]!==m||t[14]!==h||t[15]!==g||t[16]!==_?(v=(0,q.jsx)(`span`,{className:m,style:h,title:g,children:_}),t[13]=m,t[14]=h,t[15]=g,t[16]=_,t[17]=v):v=t[17],v}export{V as A,S as C,B as D,j as E,z as F,T as I,E as M,N,I as O,x as P,O as S,k as T,P as _,u as a,L as b,p as c,A as d,_ as f,w as g,m as h,H as i,C as j,g as k,D as l,y as m,v as n,h as o,R as p,d as r,f as s,Y as t,M as u,F as v,W as w,b as x,U as y};
@@ -1,2 +1,2 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./cn-JdwAhgNB.js";import{n as s}from"./copy-to-clipboard-HOJ79TWv.js";import{t as c}from"./messages-DYqBwJAK.js";import{l,n as u,r as d,s as f}from"./locale-store-DIVc0AQs.js";import{$a as p,As as m,Bi as h,Ci as g,Do as _,Ei as v,Fs as y,Gl as b,Go as x,Hi as S,Ho as C,Jo as w,Js as T,Ko as E,Mc as D,Pc as O,Ps as k,Qa as A,Si as j,Ss as M,Ts as N,Uc as P,Ui as F,Uo as I,Vi as L,Vo as ee,Wi as R,Wo as te,Xl as z,_l as B,as as V,au as H,bc as ne,ds as re,fc as ie,gc as ae,gu as oe,hc as se,ic as ce,is as le,iu as ue,jc as de,js as U,mu as W,nl as G,oa as fe,qo as pe,rs as me,tc as he,us as ge,vc as _e,wc as ve,wi as K,xi as q,yu as J,zl as ye,zs as be}from"./index-BDzspHrg.js";import{t as xe}from"./page-tabs-tQNQcAts.js";import{A as Y,C as Se,E as Ce,F as we,I as Te,M as Ee,N as De,O as Oe,P as ke,S as Ae,T as je,_ as Me,a as Ne,b as Pe,c as Fe,d as Ie,f as Le,g as Re,h as ze,i as Be,j as Ve,k as He,l as Ue,m as We,n as Ge,o as Ke,p as qe,r as Je,s as Ye,t as Xe,u as Ze,v as Qe,w as $e,x as et,y as tt}from"./connector-logo-DBKotvNr.js";var X=e(t(),1),Z=n(),Q=r();function nt(e){let t=(0,Z.c)(74),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:s}=e,c,l,u,d,f,p,m,h,g,_;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==s.connect||t[5]!==s.connectedBadge||t[6]!==s.connectorBeta||t[7]!==s.connectorCapabilityLabels||t[8]!==s.connectorExperimental||t[9]!==s.connectorVerified){let e=n.capabilities.filter(rt),v=e.slice(0,3),y=Math.max(0,e.length-v.length),b=s.connect,x=n.verificationLevel===`verified`?s.connectorVerified:n.verificationLevel===`beta`?s.connectorBeta:n.verificationLevel===`experimental`?s.connectorExperimental:null,S;t[20]!==b||t[21]!==n||t[22]!==i?(S=e=>(0,Q.jsxs)(U,{type:`button`,variant:`primary`,className:o(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:e=>{e.stopPropagation(),i(n)},children:[(0,Q.jsx)(P,{className:`size-4`}),b]}),t[20]=b,t[21]=n,t[22]=i,t[23]=S):S=t[23],c=S;let C;t[24]!==n||t[25]!==a?(C=e=>{!a||e.currentTarget!==e.target||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),a(n))},t[24]=n,t[25]=a,t[26]=C):C=t[26];let w=C,T=a?`cursor-pointer`:null;t[27]===T?p=t[28]:(p=o(`group flex min-h-[9.5rem] flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,T),t[27]=T,t[28]=p),m=a?`button`:void 0,h=a?0:void 0,t[29]!==n||t[30]!==a?(g=()=>a?.(n),t[29]=n,t[30]=a,t[31]=g):g=t[31],_=w,l=`flex min-w-0 flex-1 flex-col`;let E;t[32]===n?E=t[33]:(E=(0,Q.jsx)(Xe,{connector:n}),t[32]=n,t[33]=E);let D;t[34]===n.displayName?D=t[35]:(D=(0,Q.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[34]=n.displayName,t[35]=D);let O;t[36]===x?O=t[37]:(O=x?(0,Q.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:x}):null,t[36]=x,t[37]=O);let k;t[38]!==D||t[39]!==O?(k=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[D,O]}),t[38]=D,t[39]=O,t[40]=k):k=t[40];let A;t[41]!==E||t[42]!==k?(A=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[E,k]}),t[41]=E,t[42]=k,t[43]=A):A=t[43];let j;t[44]!==r||t[45]!==c?(j=r?null:(0,Q.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 transition-opacity sm:pointer-events-none sm:flex sm:opacity-0 sm:group-hover:pointer-events-auto sm:group-hover:opacity-100 sm:group-focus-within:pointer-events-auto sm:group-focus-within:opacity-100`,children:c()}),t[44]=r,t[45]=c,t[46]=j):j=t[46];let M;t[47]!==r||t[48]!==s.connectedBadge?(M=r?(0,Q.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,Q.jsx)(W,{className:`size-3`,"aria-hidden":!0}),s.connectedBadge]}):null,t[47]=r,t[48]=s.connectedBadge,t[49]=M):M=t[49];let N;t[50]!==j||t[51]!==M?(N=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[j,M]}),t[50]=j,t[51]=M,t[52]=N):N=t[52],t[53]!==A||t[54]!==N?(u=(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[A,N]}),t[53]=A,t[54]=N,t[55]=u):u=t[55],t[56]===n.description?d=t[57]:(d=(0,Q.jsx)(`p`,{className:`mt-4 line-clamp-2 text-sm leading-6 text-fg-muted`,title:n.description,children:n.description}),t[56]=n.description,t[57]=d),f=v.length>0?(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-1.5`,children:[v.map(e=>(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:s.connectorCapabilityLabels[e]??e},e)),y>0?(0,Q.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,y]}):null]}):null,t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=s.connect,t[5]=s.connectedBadge,t[6]=s.connectorBeta,t[7]=s.connectorCapabilityLabels,t[8]=s.connectorExperimental,t[9]=s.connectorVerified,t[10]=c,t[11]=l,t[12]=u,t[13]=d,t[14]=f,t[15]=p,t[16]=m,t[17]=h,t[18]=g,t[19]=_}else c=t[10],l=t[11],u=t[12],d=t[13],f=t[14],p=t[15],m=t[16],h=t[17],g=t[18],_=t[19];let v;t[58]!==l||t[59]!==u||t[60]!==d||t[61]!==f?(v=(0,Q.jsxs)(`div`,{className:l,children:[u,d,f]}),t[58]=l,t[59]=u,t[60]=d,t[61]=f,t[62]=v):v=t[62];let y;t[63]!==r||t[64]!==c?(y=r?null:(0,Q.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:c(`w-full`)}),t[63]=r,t[64]=c,t[65]=y):y=t[65];let b;return t[66]!==v||t[67]!==y||t[68]!==p||t[69]!==m||t[70]!==h||t[71]!==g||t[72]!==_?(b=(0,Q.jsxs)(`div`,{className:p,role:m,tabIndex:h,onClick:g,onKeyDown:_,children:[v,y]}),t[66]=v,t[67]=y,t[68]=p,t[69]=m,t[70]=h,t[71]=g,t[72]=_,t[73]=b):b=t[73],b}function rt(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var it=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function at(e,t){return t.some(t=>t.connectorId===e.id)}var ot=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function st(){let e=(0,Z.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(`div`,{className:o(`size-10 shrink-0 rounded-xl`,ot)}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.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,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:[t,(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Q.jsx)(`div`,{className:o(`h-4 min-w-0 flex-1`,ot)}),(0,Q.jsx)(`div`,{className:o(`h-8 w-[4.5rem] shrink-0 rounded-lg`,ot)})]}),(0,Q.jsx)(`div`,{className:o(`h-3 w-full`,ot)}),(0,Q.jsx)(`div`,{className:o(`h-3 w-[88%]`,ot)})]})]})}),e[1]=n):n=e[1],n}var ct=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function lt(){let e=(0,Z.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(`div`,{className:o(`size-10 shrink-0 rounded-xl`,ct)}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,Q.jsx)(`div`,{className:o(`h-4 w-48 max-w-full`,ct)}),(0,Q.jsx)(`div`,{className:o(`h-3 w-72 max-w-full`,ct)})]}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-start justify-between gap-3`,children:[n,(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Q.jsx)(`div`,{className:o(`h-9 w-20 rounded-lg`,ct)}),(0,Q.jsx)(`div`,{className:o(`h-9 w-20 rounded-lg`,ct)})]})]})]}),e[2]=r):r=e[2];let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:[r,(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,Q.jsx)(`div`,{className:o(`h-8 w-20 rounded-md`,ct)}),(0,Q.jsx)(`div`,{className:o(`h-8 w-24 rounded-md`,ct)}),(0,Q.jsx)(`div`,{className:o(`h-8 w-28 rounded-md`,ct)})]}),(0,Q.jsx)(`div`,{className:o(`mt-3 h-20 rounded-xl`,ct)})]}),e[3]=i):i=e[3],i}function ut(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function dt(e,t){return t.connectorCapabilityLabels[e]??e}function ft(e,t){if(e.runtime.type===`mcp`)return ut(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.type===`composio`?e.runtime.toolkit:e.runtime.type===`channel`?e.runtime.channelId:e.runtime.type===`nativeTool`?e.runtime.toolsetId:e.runtime.sourceKind;return ut(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n??e.runtime.type})}function pt(e,t){return e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function mt(e){return(e.setup.secrets??[]).filter(e=>e.required).length+(e.setup.config??[]).filter(e=>e.required).length}function ht(e){let t=(0,Z.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,Q.jsx)(`div`,{className:`border-b border-edge px-3 py-2 text-xs font-semibold text-fg`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,16).map(gt),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>16?(0,Q.jsxs)(`div`,{className:`px-3 py-2 text-xs text-fg-subtle`,children:[`+`,r.length-16]}):null,t[4]=r.length,t[5]=o);let s;t[6]!==a||t[7]!==o?(s=(0,Q.jsxs)(`div`,{className:`max-h-48 overflow-y-auto`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==i||t[10]!==s?(c=(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base`,children:[i,s]}),t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function gt(e){return(0,Q.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,Q.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,Q.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function _t({connector:e,installed:t,onClose:n,onInstall:r,t:i}){let[a,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(null),[u,d]=(0,X.useState)(null),f=mt(e),p=e.capabilities.slice(0,8),m=Math.max(0,e.capabilities.length-p.length),h=[...(e.setup.secrets??[]).map(e=>({key:`secret:${e.key}`,label:e.label,description:e.description,required:e.required,kind:i.connectorSetupSecret})),...(e.setup.config??[]).map(e=>({key:`config:${e.key}`,label:e.label,description:e.description,required:!!e.required,kind:i.connectorSetupConfig}))],g=async()=>{s(!0),d(null);try{l(await et(e))}catch(e){l(null),d(e instanceof Error?e.message:String(e))}finally{s(!1)}};return(0,Q.jsx)(ee,{open:!0,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(E,{children:[(0,Q.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(I,{className:o(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,52rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float outline-none dark:border-edge`),children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Q.jsx)(Xe,{connector:e,size:`lg`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[t?(0,Q.jsx)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,Q.jsx)(W,{className:`size-3`,"aria-hidden":!0}),i.connectedBadge]})}):null,(0,Q.jsx)(pe,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,Q.jsx)(te,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:e.description})]})]}),(0,Q.jsx)(C,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:o(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,N.focusRingPanel),"aria-label":i.modalClose,children:[(0,Q.jsx)(k,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,Q.jsx)(y,{className:`size-3.5`,"aria-hidden":!0}),i.detailTools]}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:c?ut(i.connectorPreviewToolsCount,{count:c.toolCount}):i.connectorPreviewUnknown})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,Q.jsx)(B,{className:`size-3.5`,"aria-hidden":!0}),i.detailPermissions]}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:pt(e,i)})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,Q.jsx)(z,{className:`size-3.5`,"aria-hidden":!0}),i.connectorRequiredInputs]}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:ut(i.connectorRequiredInputsCount,{count:f})})]})]}),(0,Q.jsxs)(`div`,{className:`mt-5 grid gap-5 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.connectorCapabilitiesTitle}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[p.map(e=>(0,Q.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-muted`,children:dt(e,i)},e)),m>0?(0,Q.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-subtle`,children:[`+`,m]}):null]})]}),u?(0,Q.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:u}):null,c?(0,Q.jsxs)(`section`,{children:[(0,Q.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.connectorPreviewTitle}),(0,Q.jsx)(`span`,{className:o(`rounded-full px-2 py-0.5 text-xs font-medium`,c.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:c.ok?i.healthStatusHealthy:i.healthStatusLabels[c.status]??c.status})]}),(0,Q.jsxs)(`div`,{className:`mb-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:c.toolCount}),(0,Q.jsx)(`div`,{className:`text-fg-muted`,children:i.toolsMetric})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:c.resourceCount}),(0,Q.jsx)(`div`,{className:`text-fg-muted`,children:i.resourcesMetric})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:c.promptCount}),(0,Q.jsx)(`div`,{className:`text-fg-muted`,children:i.promptsMetric})]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(ht,{title:i.detailTools,items:c.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,Q.jsx)(ht,{title:i.detailResources,items:c.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,Q.jsx)(ht,{title:i.detailPrompts,items:c.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??ut(i.promptArgumentCount,{count:e.argumentCount})}))})]}),c.error?(0,Q.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:c.error}):null,c.action?(0,Q.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-subtle`,children:c.action}):null]}):null]}),(0,Q.jsxs)(`aside`,{className:`space-y-3`,children:[(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(B,{className:`size-4 text-accent`,"aria-hidden":!0}),i.detailPermissions]}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-medium text-fg`,children:pt(e,i)})]}),(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(z,{className:`size-4 text-accent`,"aria-hidden":!0}),i.connectorSetupTitle]}),h.length>0?(0,Q.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-lg border border-edge`,children:h.map(e=>(0,Q.jsxs)(`div`,{className:`bg-surface-panel px-3 py-2.5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e.kind}),e.required?(0,Q.jsx)(`span`,{className:`rounded-md bg-amber-500/10 px-1.5 py-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-300`,children:i.connectorSetupRequired}):null]}),e.description?(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.key))}):(0,Q.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:i.connectorSetupNone})]}),(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(ae,{className:`size-4 text-accent`,"aria-hidden":!0}),i.connectorRuntimeTitle]}),(0,Q.jsx)(`p`,{className:`mt-2 break-words text-xs leading-5 text-fg-muted`,children:ft(e,i)})]})]})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,Q.jsx)(C,{asChild:!0,children:(0,Q.jsx)(U,{variant:`secondary`,children:i.modalClose})}),(0,Q.jsxs)(U,{variant:`secondary`,disabled:a,onClick:()=>void g(),children:[a?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):(0,Q.jsx)(y,{className:`size-4`}),i.connectorPreviewButton]}),t?(0,Q.jsxs)(U,{variant:`secondary`,disabled:!0,children:[(0,Q.jsx)(O,{className:`size-4`}),i.connectedBadge]}):(0,Q.jsxs)(U,{variant:`primary`,onClick:()=>{r(e),n()},children:[(0,Q.jsx)(P,{className:`size-4`}),i.connect]})]})]})]})})}var vt=o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,m);function yt(e){let t=(0,Z.c)(58),{open:n,sessionIdleTtlMinutes:r,saving:i,onChange:a,onSave:s,onClose:c,t:l,mcp:u}=e,d;t[0]===c?d=t[1]:(d=e=>{e||c()},t[0]=c,t[1]=d);let f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Q.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[2]=f):f=t[2];let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=o(`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-panel shadow-float dark:border-edge`),t[3]=p):p=t[3];let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,Q.jsx)(D,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})}),t[4]=m):m=t[4];let h;t[5]===l.runtimeSettingsTitle?h=t[6]:(h=(0,Q.jsx)(pe,{className:`text-base font-semibold text-fg`,children:l.runtimeSettingsTitle}),t[5]=l.runtimeSettingsTitle,t[6]=h);let g;t[7]===l.runtimeSettingsHint?g=t[8]:(g=(0,Q.jsx)(te,{className:`mt-1 text-sm text-fg-muted`,children:l.runtimeSettingsHint}),t[7]=l.runtimeSettingsHint,t[8]=g);let _;t[9]!==h||t[10]!==g?(_=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[m,(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[h,g]})]}),t[9]=h,t[10]=g,t[11]=_):_=t[11];let v;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(v=o(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,N.focusRingPanel),t[12]=v):v=t[12];let y;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(k,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=y):y=t[13];let b;t[14]===l.modalClose?b=t[15]:(b=(0,Q.jsx)(C,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:v,"aria-label":l.modalClose,children:y})}),t[14]=l.modalClose,t[15]=b);let S;t[16]!==b||t[17]!==_?(S=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[_,b]}),t[16]=b,t[17]=_,t[18]=S):S=t[18];let w;t[19]===u.idleTtlLabel?w=t[20]:(w=(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:u.idleTtlLabel}),t[19]=u.idleTtlLabel,t[20]=w);let T;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(T=o(vt,`w-40 flex-none`),t[21]=T):T=t[21];let O=r??``,A;t[22]===a?A=t[23]:(A=e=>{let t=e.currentTarget.value.trim();a(t===``?void 0:Number.parseInt(t,10))},t[22]=a,t[23]=A);let j;t[24]!==u.idleTtlPlaceholder||t[25]!==O||t[26]!==A?(j=(0,Q.jsx)(`input`,{type:`number`,min:0,className:T,value:O,placeholder:u.idleTtlPlaceholder,onChange:A}),t[24]=u.idleTtlPlaceholder,t[25]=O,t[26]=A,t[27]=j):j=t[27];let M;t[28]===u.idleTtlHint?M=t[29]:(M=(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:u.idleTtlHint}),t[28]=u.idleTtlHint,t[29]=M);let P;t[30]!==w||t[31]!==j||t[32]!==M?(P=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,Q.jsxs)(`label`,{className:`flex max-w-xl flex-col gap-1.5`,children:[w,j,M]})}),t[30]=w,t[31]=j,t[32]=M,t[33]=P):P=t[33];let F;t[34]!==c||t[35]!==i||t[36]!==l.modalCancel?(F=(0,Q.jsx)(U,{type:`button`,variant:`secondary`,disabled:i,onClick:c,children:l.modalCancel}),t[34]=c,t[35]=i,t[36]=l.modalCancel,t[37]=F):F=t[37];let L;t[38]===s?L=t[39]:(L=()=>void s(),t[38]=s,t[39]=L);let R;t[40]===i?R=t[41]:(R=i?(0,Q.jsx)(G,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[40]=i,t[41]=R);let z;t[42]!==u.save||t[43]!==i||t[44]!==L||t[45]!==R?(z=(0,Q.jsxs)(U,{type:`button`,variant:`primary`,disabled:i,onClick:L,children:[R,u.save]}),t[42]=u.save,t[43]=i,t[44]=L,t[45]=R,t[46]=z):z=t[46];let B;t[47]!==F||t[48]!==z?(B=(0,Q.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[F,z]}),t[47]=F,t[48]=z,t[49]=B):B=t[49];let V;t[50]!==S||t[51]!==P||t[52]!==B?(V=(0,Q.jsxs)(E,{children:[f,(0,Q.jsxs)(I,{className:p,children:[S,P,B]})]}),t[50]=S,t[51]=P,t[52]=B,t[53]=V):V=t[53];let H;return t[54]!==n||t[55]!==d||t[56]!==V?(H=(0,Q.jsx)(ee,{open:n,onOpenChange:d,children:V}),t[54]=n,t[55]=d,t[56]=V,t[57]=H):H=t[57],H}var bt=(0,X.memo)(function(e){let t=(0,Z.c)(12),{value:n,onChange:r,placeholder:i,className:a}=e,s;t[0]===a?s=t[1]:(s=o(`relative flex 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 shadow-surface`,a),t[0]=a,t[1]=s);let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(_e,{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]=c):c=t[2];let l;t[3]===r?l=t[4]:(l=e=>r(e.currentTarget.value),t[3]=r,t[4]=l);let u;t[5]!==i||t[6]!==l||t[7]!==n?(u=(0,Q.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:n,onChange:l,placeholder:i,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`}),t[5]=i,t[6]=l,t[7]=n,t[8]=u):u=t[8];let d;return t[9]!==s||t[10]!==u?(d=(0,Q.jsxs)(`label`,{className:s,children:[c,u]}),t[9]=s,t[10]=u,t[11]=d):d=t[11],d}),xt=(0,X.memo)(function(e){let t=(0,Z.c)(30),{onBrowseCatalog:n,onAddCustomServer:r,onOpenRuntimeSettings:i,addLabel:a,browseLabel:s,customLabel:c,settingsLabel:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(se,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=u):u=t[0];let d;t[1]===l?d=t[2]:(d=(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:l}),t[1]=l,t[2]=d);let f;t[3]!==i||t[4]!==l||t[5]!==d?(f=(0,Q.jsxs)(U,{type:`button`,variant:`secondary`,className:`shrink-0 gap-2`,"aria-label":l,title:l,onClick:i,children:[u,d]}),t[3]=i,t[4]=l,t[5]=d,t[6]=f):f=t[6];let p;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Q.jsx)(de,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[7]=p):p=t[7];let m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(J,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[8]=m):m=t[8];let h;t[9]===a?h=t[10]:(h=(0,Q.jsx)(v,{asChild:!0,children:(0,Q.jsxs)(U,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,children:[p,a,m]})}),t[9]=a,t[10]=h);let _;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(_=o(`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,N.transition),t[11]=_):_=t[11];let b;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Q.jsx)(he,{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]!==n?(x=(0,Q.jsxs)(j,{className:_,onSelect:n,children:[b,s]}),t[13]=s,t[14]=n,t[15]=x):x=t[15];let S;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(S=o(`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,N.transition),t[16]=S):S=t[16];let C;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Q.jsx)(y,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[17]=C):C=t[17];let w;t[18]!==c||t[19]!==r?(w=(0,Q.jsxs)(j,{className:S,onSelect:r,children:[C,c]}),t[18]=c,t[19]=r,t[20]=w):w=t[20];let T;t[21]!==w||t[22]!==x?(T=(0,Q.jsx)(g,{children:(0,Q.jsxs)(q,{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:[x,w]})}),t[21]=w,t[22]=x,t[23]=T):T=t[23];let E;t[24]!==T||t[25]!==h?(E=(0,Q.jsxs)(K,{children:[h,T]}),t[24]=T,t[25]=h,t[26]=E):E=t[26];let D;return t[27]!==E||t[28]!==f?(D=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[f,E]}),t[27]=E,t[28]=f,t[29]=D):D=t[29],D}),St=/^([^:=]+)[:=](.*)$/;function Ct(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=St.exec(t);r&&n.push({key:r[1].trim(),value:r[2].trim()})}return n.length>0?n:null}function wt(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 Tt(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 Et(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 Dt(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)||Et(t)&&(r[e]=t);return r}function Ot(e){let t=e.trim();if(t)return t.split(/\s+/).filter(Boolean)}function kt(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 At(e){if(e.transport===`stdio`){let t={command:e.command.trim()},n=Ot(e.argsText);return n?.length&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envJson.trim()&&(t.env=kt(e.envJson)),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}let t={url:e.url.trim(),transport:e.transport},n=wt(e.headers);return n&&(t.headers=n),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}function jt(e,t){let n=typeof t.url==`string`&&t.url.trim().length>0,r=typeof t.transport==`string`?t.transport.trim().toLowerCase():``,i=n?r===`sse`?`sse`:`streamable-http`:`stdio`,a=t.headers&&typeof t.headers==`object`&&!Array.isArray(t.headers)?t.headers:void 0;return{clientKey:e,id:e,transport:i,command:typeof t.command==`string`?t.command:``,argsText:Array.isArray(t.args)?t.args.map(String).join(` `):``,envJson:t.env&&typeof t.env==`object`?JSON.stringify(t.env,null,2):``,cwd:typeof t.cwd==`string`?t.cwd:typeof t.workingDirectory==`string`?t.workingDirectory:``,url:typeof t.url==`string`?t.url:``,headers:Tt(a),connectionTimeoutMs:typeof t.connectionTimeoutMs==`number`&&Number.isFinite(t.connectionTimeoutMs)?t.connectionTimeoutMs:void 0}}function Mt(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`stdio`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[{key:`Authorization`,value:``}],connectionTimeoutMs:void 0}}function Nt(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)||Et(t)?[]:[jt(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 Pt(e){return At(e)}async function Ft(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]=At(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 f(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({mcp:r})}),A()}function It(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n==`string`){let e=n.trim();e&&t.push({name:e});continue}if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.name!=`string`)continue;let r=e.name.trim();if(!r)continue;let i=typeof e.shortName==`string`&&e.shortName.trim()?e.shortName.trim():void 0,a=typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0;t.push({name:r,shortName:i,description:a})}return t}function Lt(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 Rt(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 zt(e,t){let n=await f(d(`/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=It(n.payload.tools),i=Lt(n.payload.resources),a=Rt(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 Bt(e){return e.connectionTimeoutMs==null||!Number.isFinite(e.connectionTimeoutMs)?``:String(Math.round(e.connectionTimeoutMs/1e3))}function Vt(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 Ht(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 $(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,n),e)}function Ut({row:e,t,cs:n,onEdit:r,onRemove:i}){let[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(null),[d,f]=(0,X.useState)(null),p=Ht(e),m=(0,X.useCallback)(async()=>{o(!0),f(null);try{let t=await zt(e.id.trim());u({toolCount:t.toolCount,resourceCount:t.resourceCount,promptCount:t.promptCount})}catch(e){f(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.id]),h=(0,X.useCallback)(async()=>{c(!0),f(null);try{await i()}catch(e){f(e instanceof Error?e.message:String(e)),c(!1)}},[i]);return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-[10.5rem] cursor-pointer flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`,onClick:r,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.id.trim()||t.cardUntitled}),(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:n.customBadge}),(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.transportLabels[e.transport]})]}),p?(0,Q.jsx)(`p`,{className:`mt-3 line-clamp-2 break-all font-mono text-xs leading-5 text-fg-subtle`,title:p,children:p}):null,d?(0,Q.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:d}):null,l?(0,Q.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:$(n.customCapabilitySummary,{tools:String(l.toolCount),resources:String(l.resourceCount),prompts:String(l.promptCount)})}):null]}),(0,Q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.connectorDetails}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(U,{variant:`secondary`,disabled:a,onClick:()=>void m(),children:[a?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):(0,Q.jsx)(O,{className:`size-4`}),t.testConnection]}),(0,Q.jsxs)(U,{variant:`ghost`,disabled:s,onClick:()=>void h(),children:[s?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):(0,Q.jsx)(T,{className:`size-4`}),t.removeServer]})]})]})]})}function Wt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Gt(e,t,n){let r=t.trim().toLowerCase();if(!r)return!0;let i=e.shortName||Wt(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
2
- `).toLowerCase().includes(r)}function Kt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function qt(e){let t=(0,Z.c)(29),{tools:n,stripPrefix:r,searchPlaceholder:i,searchEmptyLabel:a}=e,[s,c]=(0,X.useState)(``),l;if(t[0]!==s||t[1]!==r||t[2]!==n){let e;t[4]!==s||t[5]!==r?(e=e=>Gt(e,s,r),t[4]=s,t[5]=r,t[6]=e):e=t[6],l=n.filter(e),t[0]=s,t[1]=r,t[2]=n,t[3]=l}else l=t[3];let u=l,d;t[7]===s?d=t[8]:(d=s.trim(),t[7]=s,t[8]=d);let f=d.length>0,p;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Q.jsx)(_e,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=p):p=t[9];let h,g;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(h=o(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg`,`placeholder:text-fg-subtle`,m),g=e=>c(e.target.value),t[10]=h,t[11]=g):(h=t[10],g=t[11]);let _;t[12]!==s||t[13]!==i?(_=(0,Q.jsxs)(`div`,{className:`relative`,children:[p,(0,Q.jsx)(`input`,{type:`search`,value:s,placeholder:i,"aria-label":i,className:h,onChange:g})]}),t[12]=s,t[13]=i,t[14]=_):_=t[14];let v;t[15]!==u.length||t[16]!==f||t[17]!==n.length?(v=f?(0,Q.jsxs)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:[u.length,` / `,n.length]}):null,t[15]=u.length,t[16]=f,t[17]=n.length,t[18]=v):v=t[18];let y;t[19]!==_||t[20]!==v?(y=(0,Q.jsxs)(`div`,{className:`border-b border-edge px-5 py-3`,children:[_,v]}),t[19]=_,t[20]=v,t[21]=y):y=t[21];let b;t[22]!==u||t[23]!==a||t[24]!==r?(b=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:u.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a}):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>{let n=e.shortName||Kt(e.name,r)||e.name||`?`,i=e.name||`tool-${t}`;return(0,Q.jsxs)(`li`,{className:`min-w-0 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[(0,Q.jsx)(`div`,{className:`truncate font-mono text-sm font-medium text-fg`,title:e.name===n?n:e.name,children:n}),e.description?(0,Q.jsx)(`p`,{className:`mt-1 truncate text-xs leading-relaxed text-fg-muted`,title:e.description,children:e.description}):null]},i)})})}),t[22]=u,t[23]=a,t[24]=r,t[25]=b):b=t[25];let x;return t[26]!==y||t[27]!==b?(x=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[y,b]}),t[26]=y,t[27]=b,t[28]=x):x=t[28],x}function Jt(e){let t=(0,Z.c)(38),{open:n,onOpenChange:r,serverId:i,title:a,subtitle:s,searchPlaceholder:c,searchEmptyLabel:l,emptyLabel:u,closeLabel:d,tools:f,stripPrefix:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(x,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,re)}),t[0]=m):m=t[0];let h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=o(`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`,ge,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`),t[1]=h):h=t[1];let g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Q.jsx)(y,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[2]=g):g=t[2];let _;t[3]===a?_=t[4]:(_=(0,Q.jsxs)(pe,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[g,a]}),t[3]=a,t[4]=_);let v;t[5]!==i||t[6]!==s||t[7]!==f.length?(v=s.replace(`{{serverId}}`,i).replace(`{{count}}`,String(f.length)),t[5]=i,t[6]=s,t[7]=f.length,t[8]=v):v=t[8];let b;t[9]===v?b=t[10]:(b=(0,Q.jsx)(te,{className:`mt-1 text-sm text-fg-muted`,children:v}),t[9]=v,t[10]=b);let S;t[11]!==_||t[12]!==b?(S=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[_,b]}),t[11]=_,t[12]=b,t[13]=S):S=t[13];let w;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Q.jsx)(k,{className:`size-4`,"aria-hidden":!0}),t[14]=w):w=t[14];let T;t[15]===d?T=t[16]:(T=(0,Q.jsx)(C,{asChild:!0,children:(0,Q.jsx)(U,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":d,children:w})}),t[15]=d,t[16]=T);let D;t[17]!==S||t[18]!==T?(D=(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[S,T]}),t[17]=S,t[18]=T,t[19]=D):D=t[19];let O;t[20]!==u||t[21]!==n||t[22]!==l||t[23]!==c||t[24]!==i||t[25]!==p||t[26]!==f?(O=f.length>0?(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,Q.jsx)(qt,{tools:f,stripPrefix:p,searchPlaceholder:c,searchEmptyLabel:l},`${i}-${n?`open`:`closed`}`)}):(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u})}),t[20]=u,t[21]=n,t[22]=l,t[23]=c,t[24]=i,t[25]=p,t[26]=f,t[27]=O):O=t[27];let A;t[28]===d?A=t[29]:(A=(0,Q.jsx)(`div`,{className:`flex justify-end border-t border-edge px-5 py-3`,children:(0,Q.jsx)(C,{asChild:!0,children:(0,Q.jsx)(U,{type:`button`,variant:`secondary`,children:d})})}),t[28]=d,t[29]=A);let j;t[30]!==D||t[31]!==O||t[32]!==A?(j=(0,Q.jsxs)(E,{children:[m,(0,Q.jsxs)(I,{className:h,children:[D,O,A]})]}),t[30]=D,t[31]=O,t[32]=A,t[33]=j):j=t[33];let M;return t[34]!==r||t[35]!==n||t[36]!==j?(M=(0,Q.jsx)(ee,{open:n,onOpenChange:r,children:j}),t[34]=r,t[35]=n,t[36]=j,t[37]=M):M=t[37],M}var Yt=o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,m);function Xt(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function Zt(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function Qt(e,t){return e.errorCode===`missing_credential`?t.composioHealthMissingCredential:e.errorCode===`unauthorized`?t.composioHealthUnauthorized:e.errorCode===`forbidden`?t.composioHealthForbidden:e.errorCode===`network`?t.composioHealthNetwork:e.errorCode===`timeout`?t.composioHealthTimeout:t.composioHealthDegraded}function $t({instance:e,t,onChanged:n}){let r=Xt(e),[i,s]=(0,X.useState)([]),[c,l]=(0,X.useState)([]),[u,d]=(0,X.useState)([]),[f,p]=(0,X.useState)([]),[m,h]=(0,X.useState)(null),[g,_]=(0,X.useState)([]),[v,y]=(0,X.useState)(null),[b,x]=(0,X.useState)([]),[S,C]=(0,X.useState)({}),[E,D]=(0,X.useState)(`read`),[O,A]=(0,X.useState)(!1),[j,M]=(0,X.useState)(null),N=(0,X.useCallback)(async()=>{if(!(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)){A(!0),M(null);try{let[t,n,i,a,o,c,u,f]=await Promise.all([Re().catch(()=>[]),Me(r).catch(()=>[]),Qe(20).catch(()=>[]),Ie(r).catch(()=>`read`),tt().catch(()=>[]),Ze(r).catch(()=>null),Ue(r).catch(()=>null),Pe().catch(()=>[])]);s(t.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),l(n),d(i.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())),D(a),p(o.filter(t=>t.connectorId===e.connectorId)),h(c?.policy??null),_(c?.agents??[]),y(u),x(f);let m=t.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase()),g=await Promise.all(m.map(async e=>[e.id,await qe(e.id)]).map(e=>e.catch(()=>null)));C(Object.fromEntries(g.filter(e=>e!==null)))}catch(e){M(e instanceof Error?e.message:String(e))}finally{A(!1)}}},[e.connectorId,e.materialized,r]);(0,X.useEffect)(()=>{N()},[N]);let P=(0,X.useCallback)(async()=>{if(r){A(!0),M(null);try{let t=await He(e.connectorId);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if(w()){let e=await window.electronAPI?.shell?.openExternalUrl(t.authorizationUrl);if(!e?.ok)throw Error(e?.error??`Could not open the system browser.`)}else window.open(t.authorizationUrl,`_blank`,`noopener,noreferrer`);await Oe((await Te(r,t.connectionId)).id),await n?.(),await N()}catch(e){M(e instanceof Error?e.message:String(e))}finally{A(!1)}}},[e.connectorId,N,n,r]),F=(0,X.useCallback)(async e=>{if(r){D(e);try{await Ce(r,e),await N()}catch(e){M(e instanceof Error?e.message:String(e))}}},[N,r]),I=(0,X.useCallback)(async(e,t)=>{A(!0),M(null);try{await $e(e,t),await N()}catch(e){M(e instanceof Error?e.message:String(e))}finally{A(!1)}},[N]),L=(0,X.useCallback)(async e=>{if(r){M(null);try{h(await De(r,e))}catch(e){M(e instanceof Error?e.message:String(e))}}},[e.connectorId,r]),ee=(0,X.useCallback)(e=>{m&&L({allowedAgentIds:m.allowedAgentIds.includes(e)?m.allowedAgentIds.filter(t=>t!==e):[...m.allowedAgentIds,e]})},[L,m]),R=(0,X.useCallback)(async e=>{A(!0),M(null);try{await e(),await N()}catch(e){M(e instanceof Error?e.message:String(e))}finally{A(!1)}},[N]);return r?e.materialized.type===`composio`&&e.materialized.role===`credential`?(0,Q.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:t.composioApiKeyStored}):(0,Q.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`font-medium text-fg`,children:$(t.composioToolkitTitle,{toolkit:r})}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioScopeHint})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsxs)(U,{variant:`secondary`,disabled:O,onClick:()=>void P(),children:[O?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):(0,Q.jsx)(B,{className:`size-4`}),t.connectOAuth]}),(0,Q.jsx)(U,{variant:`ghost`,disabled:O,onClick:()=>void N(),children:t.refresh})]})]}),j?(0,Q.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:j}):null,v?(0,Q.jsxs)(`div`,{className:o(`mt-3 flex flex-wrap items-center justify-between gap-2 rounded-lg border px-3 py-2 text-xs`,v.status===`connected`?`border-emerald-500/30 bg-emerald-500/5 text-emerald-700`:`border-amber-500/30 bg-amber-500/5 text-amber-700`),children:[(0,Q.jsx)(`span`,{children:v.status===`connected`?$(t.composioHealthConnected,{count:String(v.activeConnections)}):v.status===`reauthorization_required`?t.composioHealthReconnect:v.status===`degraded`?Qt(v,t):t.composioHealthDisconnected}),v.recovery===`none`?null:(0,Q.jsx)(U,{variant:`ghost`,disabled:O,onClick:()=>void(v.recovery===`retry`?N():P()),children:v.recovery===`retry`?t.composioRetry:t.connectOAuth}),v.status===`degraded`&&v.message?(0,Q.jsx)(`p`,{className:`basis-full break-words text-[11px] opacity-80`,children:v.message}):null]}):null,m?(0,Q.jsxs)(`div`,{className:`mt-4 grid gap-3 rounded-lg border border-edge bg-surface-panel p-3 md:grid-cols-3`,children:[(0,Q.jsxs)(`label`,{className:`text-xs font-medium text-fg-subtle`,children:[t.composioAccessTitle,(0,Q.jsxs)(le,{className:o(Yt,`mt-1 h-9 py-1`),value:E,onChange:e=>void F(e.currentTarget.value),children:[(0,Q.jsx)(V,{value:`read`,children:t.composioAccessReadOnly}),(0,Q.jsx)(V,{value:`write`,children:t.composioAccessReadWrite}),E===`admin`?(0,Q.jsx)(V,{value:`admin`,children:t.composioAccessAdminCurrent}):null]}),(0,Q.jsx)(`span`,{className:`mt-1 block font-normal leading-4 text-fg-muted`,children:E===`read`?t.composioAccessReadHint:E===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,Q.jsxs)(`label`,{className:`text-xs font-medium text-fg-subtle`,children:[t.composioConfirmationPolicy,(0,Q.jsxs)(le,{className:o(Yt,`mt-1 h-9 py-1`),value:m.confirmationPolicy,onChange:e=>void L({confirmationPolicy:e.currentTarget.value}),children:[(0,Q.jsx)(V,{value:`writes`,children:t.composioConfirmWrites}),(0,Q.jsx)(V,{value:`always`,children:t.composioConfirmAlways}),m.confirmationPolicy===`never`?(0,Q.jsx)(V,{value:`never`,children:t.composioConfirmNever}):null]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:t.composioAllowedAgents}),(0,Q.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:m.allowedAgentIds.length?t.composioAllowedAgentsSelected:t.composioAllowedAgentsAll}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:g.map(e=>(0,Q.jsx)(`button`,{type:`button`,className:o(`rounded-full border px-2.5 py-1 text-xs transition-colors`,m.allowedAgentIds.includes(e.id)?`border-accent bg-accent/10 text-accent`:`border-edge text-fg-muted hover:text-fg`),onClick:()=>ee(e.id),children:e.name},e.id))})]})]}):null,f.length?(0,Q.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioPendingApprovals}),f.map(e=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-amber-500/30 bg-amber-500/5 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`truncate font-mono text-xs font-medium text-fg`,children:e.actionId}),(0,Q.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs text-fg-subtle`,children:JSON.stringify(e.argumentsPreview)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:$(t.composioApprovalExpires,{time:new Date(e.expiresAt).toLocaleTimeString()})})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Q.jsxs)(U,{variant:`secondary`,disabled:O,onClick:()=>void I(e.id,`denied`),children:[(0,Q.jsx)(k,{className:`size-4`}),t.composioDeny]}),(0,Q.jsxs)(U,{disabled:O,onClick:()=>void I(e.id,`approved`),children:[(0,Q.jsx)(a,{className:`size-4`}),t.approve]})]})]},e.id))]}):null,(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioConnections}),i.length?i.map(e=>(0,Q.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-edge bg-surface-panel p-2`,children:[(()=>{let n=b.find(t=>t.connectionId===e.id);return n?(0,Q.jsx)(`p`,{className:o(`text-xs`,n.status===`failed`?`text-red-600`:`text-fg-subtle`),children:$(t.connectorLearningStatus,{status:n.status,count:String(n.candidatesCreated)})}):null})(),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.accountEmail??e.username??e.workspace??e.providerConnectionId}),(0,Q.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[e.status,e.isDefault?` · ${t.composioDefaultAccount}`:``]})]}),S[e.id]?(0,Q.jsxs)(`div`,{className:`grid gap-2 rounded-lg border border-edge bg-surface-base p-2 sm:grid-cols-3`,children:[(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-subtle`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:S[e.id].scanEnabled,disabled:O,onChange:t=>void R(()=>we(e.id,{scanEnabled:t.currentTarget.checked}))}),t.connectorScheduledScan]}),(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-subtle`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:S[e.id].proactiveEnabled,disabled:O||!S[e.id].scanEnabled,onChange:t=>void R(()=>we(e.id,{proactiveEnabled:t.currentTarget.checked}))}),t.connectorProactiveUse]}),(0,Q.jsxs)(`label`,{className:`text-xs text-fg-subtle`,children:[t.connectorScanInterval,(0,Q.jsxs)(le,{className:o(Yt,`mt-1 h-8 py-1 text-xs`),value:String(S[e.id].intervalMinutes??30),disabled:O||!S[e.id].scanEnabled,onChange:t=>void R(()=>we(e.id,{intervalMinutes:Number(t.currentTarget.value)})),children:[(0,Q.jsxs)(V,{value:`5`,children:[`5 `,t.connectorMinutes]}),(0,Q.jsxs)(V,{value:`15`,children:[`15 `,t.connectorMinutes]}),(0,Q.jsxs)(V,{value:`30`,children:[`30 `,t.connectorMinutes]}),(0,Q.jsxs)(V,{value:`60`,children:[`60 `,t.connectorMinutes]})]})]})]}):null,(0,Q.jsx)(`input`,{className:o(Yt,`h-8 py-1 text-xs`),defaultValue:e.alias??``,placeholder:t.composioAccountAlias,onBlur:t=>{t.currentTarget.value!==(e.alias??``)&&R(()=>Ee(e.id,{alias:t.currentTarget.value}))}}),(0,Q.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Q.jsx)(U,{variant:`ghost`,className:`size-8 p-0`,title:t.composioMakeDefault,disabled:O||e.isDefault,onClick:()=>void R(async()=>{await Ee(e.id,{isDefault:!0}),r&&await De(r,{selectedConnectionIds:[e.id]})}),children:(0,Q.jsx)(ce,{className:o(`size-4`,e.isDefault&&`fill-current`)})}),(0,Q.jsx)(U,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:O,onClick:()=>void R(()=>Ae(e.id)),children:(0,Q.jsx)(ve,{className:`size-4`})}),(0,Q.jsx)(U,{variant:`ghost`,className:`size-8 p-0`,title:t.composioRevoke,disabled:O,onClick:()=>{window.confirm(t.composioRevokeConfirm)&&R(()=>je(e.id))},children:(0,Q.jsx)(T,{className:`size-4 text-red-500`})})]}),e.status===`active`?(0,Q.jsx)(`div`,{children:(0,Q.jsxs)(U,{variant:`secondary`,className:`w-full`,disabled:O,onClick:()=>void R(async()=>{await Oe(e.id),await n?.()}),children:[O?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):(0,Q.jsx)(ve,{className:`size-4`}),t.composioSyncNow]})}):null]},e.id)):(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioConnectionsEmpty})]})}),(0,Q.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge bg-surface-panel p-3`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted`,children:t.composioAdvancedSettings}),(0,Q.jsxs)(`div`,{className:`mt-4 grid gap-4 lg:grid-cols-2`,children:[(0,Q.jsx)(`div`,{className:`space-y-3`,children:(0,Q.jsxs)(`label`,{className:`block text-xs text-fg-subtle`,children:[t.composioAdvancedScope,(0,Q.jsxs)(le,{className:o(Yt,`mt-1 h-9 py-1`),value:E,onChange:e=>void F(e.currentTarget.value),children:[(0,Q.jsx)(V,{value:`read`,children:t.composioScopeRead}),(0,Q.jsx)(V,{value:`write`,children:t.composioScopeWrite}),(0,Q.jsx)(V,{value:`admin`,children:t.composioScopeAdmin})]})]})}),(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),c.length?c.slice(0,8).map(e=>(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-2`,children:[(0,Q.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,Q.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[Zt(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),u.length?u.slice(0,5).map(e=>(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-2`,children:[(0,Q.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})]})]})]})]})]}):null}var en=o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,m);function tn(e,t){return e?t.healthStatusLabels[e]??e:t.healthNotTested}function nn(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 rn(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 an(e){let t=(0,Z.c)(12),{title:n,description:r,meta:i}=e,a;t[0]===r?a=t[1]:(a=r?(0,Q.jsx)(S,{delayDuration:300,skipDelayDuration:100,children:(0,Q.jsxs)(F,{children:[(0,Q.jsx)(R,{asChild:!0,children:(0,Q.jsx)(`p`,{tabIndex:0,title:r,className:o(`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,Q.jsx)(L,{children:(0,Q.jsx)(h,{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,Q.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:r})})})]})}):null,t[0]=r,t[1]=a);let s=a,c;t[2]===n?c=t[3]:(c=(0,Q.jsx)(`p`,{className:`min-w-0 break-all font-mono text-xs font-medium leading-5 text-fg`,children:n}),t[2]=n,t[3]=c);let l;t[4]===i?l=t[5]:(l=i?(0,Q.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]=l);let u;t[6]!==c||t[7]!==l?(u=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;return t[9]!==s||t[10]!==u?(d=(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[u,s]}),t[9]=s,t[10]=u,t[11]=d):d=t[11],d}function on({instance:e,definition:t,onClose:n,onChanged:r,t:i,mcp:a}){let[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(null),[_,v]=(0,X.useState)(null),[b,S]=(0,X.useState)(e.materialized.type===`mcp`?`health`:`permissions`),[w,D]=(0,X.useState)(!1),[A,j]=(0,X.useState)(()=>nn(t,e)),[M,P]=(0,X.useState)(null),F=t?.setup.config??[],L=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&F.length>0&&(t?.setup.secrets??[]).length===0,R=_?_.toolCount:e.usage.lastToolCount,V=(0,X.useMemo)(()=>{let t=e.materialized.type===`mcp`?[[`health`,ie,i.detailHealth],[`tools`,y,`${i.detailTools} ${_?_.toolCount:e.usage.lastToolCount??``}`],[`resources`,z,`${i.detailResources} ${_?_.resourceCount:e.usage.lastResourceCount??``}`],[`prompts`,ye,`${i.detailPrompts} ${_?_.promptCount:e.usage.lastPromptCount??``}`],[`permissions`,B,i.detailPermissions]]:[[`permissions`,B,i.detailPermissions]];return L?[...t,[`config`,z,i.connectorConfigLabel]]:t},[_,e.materialized.type,e.usage.lastPromptCount,e.usage.lastResourceCount,e.usage.lastToolCount,L,i]),H=(0,X.useCallback)(async()=>{c(!0),P(null);try{let t=await Ve(e.instanceId);v(t),t.toolCount>0&&S(`tools`),r()}catch(e){P(e instanceof Error?e.message:String(e))}finally{c(!1)}},[e.instanceId,r]),re=(0,X.useCallback)(async()=>{u(!0),P(null);try{await Se(e.instanceId),await r(),n()}catch(e){P(e instanceof Error?e.message:String(e)),u(!1)}},[e.instanceId,r,n]),ae=(0,X.useCallback)(async()=>{if(!(!t||!L)){f(!0),P(null);try{let n={};for(let e of t.setup.config??[]){let t=rn(e.type,A[e.key]??``);t!==void 0&&(n[e.key]=t)}await ke(e.instanceId,{config:n}),await r(),S(`health`)}catch(e){P(e instanceof Error?e.message:String(e))}finally{f(!1)}}},[A,t,e.instanceId,r,L]),oe=(0,X.useCallback)(async()=>{m(!0),g(null),P(null);try{g((await Y(e.connectorId)).recordIds.length),await r()}catch(e){P(e instanceof Error?e.message:String(e))}finally{m(!1)}},[e.connectorId,r]);return(0,Q.jsxs)(ee,{open:!0,onOpenChange:e=>{e||n()},children:[(0,Q.jsxs)(E,{children:[(0,Q.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(I,{className:o(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,54rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float outline-none dark:border-edge`),children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Q.jsx)(Xe,{connector:t,size:`lg`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(pe,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,Q.jsx)(te,{className:`mt-1 text-sm text-fg-muted`,children:t?.description??(e.materialized.type===`mcp`?$(i.mcpServerRuntime,{serverId:e.materialized.serverId}):$(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,Q.jsx)(C,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:o(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,N.focusRingPanel),"aria-label":i.modalClose,children:[(0,Q.jsx)(k,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[M?(0,Q.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:M}):null,(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:V.map(([e,t,n])=>(0,Q.jsxs)(`button`,{type:`button`,className:o(`inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs`,b===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:text-fg`),onClick:()=>S(e),children:[(0,Q.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),n]},e))}),(0,Q.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[b===`health`?(0,Q.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,Q.jsxs)(`p`,{children:[i.statusLabel,` `,(0,Q.jsx)(`span`,{className:_?.ok?`font-medium text-emerald-700 dark:text-emerald-300`:`font-medium text-fg`,children:tn(_?.status??e.usage.lastHealthStatus,i)})]}),(0,Q.jsxs)(`p`,{children:[i.lastCheckLabel,` `,e.usage.lastHealthCheckAt?new Date(e.usage.lastHealthCheckAt).toLocaleString():i.never]}),_?.action?(0,Q.jsx)(`p`,{children:_.action}):null]}):null,b===`tools`?_?.tools.length?(0,Q.jsxs)(`div`,{className:`grid gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:$(i.toolsAvailable,{count:String(_.tools.length)})}),(0,Q.jsx)(U,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>D(!0),children:a.viewAllTools})]}),(0,Q.jsx)(`div`,{className:`grid gap-2`,children:_.tools.slice(0,8).map(e=>(0,Q.jsx)(an,{title:e.shortName??e.name,description:e.description},e.name))})]}):(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-fg-muted`,children:R?$(i.toolsLastCheckSummary,{count:String(R)}):i.toolsRunTestHint}),(0,Q.jsxs)(U,{type:`button`,variant:`secondary`,disabled:s,onClick:()=>void H(),children:[s?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):(0,Q.jsx)(O,{className:`size-4`}),i.test]})]}):null,b===`resources`?_?.resources.length?(0,Q.jsx)(`div`,{className:`grid gap-2`,children:_.resources.slice(0,8).map(e=>(0,Q.jsx)(an,{title:e.title??e.name,description:e.uri,meta:e.mimeType},e.uri))}):(0,Q.jsx)(`p`,{className:`text-fg-muted`,children:i.resourcesRunTestHint}):null,b===`prompts`?_?.prompts.length?(0,Q.jsx)(`div`,{className:`grid gap-2`,children:_.prompts.slice(0,8).map(e=>(0,Q.jsx)(an,{title:e.title??e.name,description:e.description,meta:e.argumentCount?$(i.promptArgumentCount,{count:String(e.argumentCount)}):void 0},e.name))}):(0,Q.jsx)(`p`,{className:`text-fg-muted`,children:i.promptsRunTestHint}):null,b===`permissions`?(0,Q.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,Q.jsx)(`p`,{children:$(i.secretsConfigured,{count:String(Object.values(e.secretStatus).filter(Boolean).length)})}),(0,Q.jsx)(`p`,{children:e.materialized.type===`mcp`?$(i.runtimeServerLabel,{runtime:e.materialized.type.toUpperCase(),serverId:e.materialized.serverId}):$(i.runtimeLabel,{runtime:e.materialized.type.toUpperCase()})}),(0,Q.jsx)(`p`,{children:e.materialized.type===`mcp`?i.mcpPolicyHint:i.connectorPolicyHint})]}):null,b===`config`&&L?(0,Q.jsx)(`div`,{className:`grid gap-3`,children:F.map(e=>(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,Q.jsx)(`input`,{className:en,value:A[e.key]??``,placeholder:e.placeholder,onChange:t=>j(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}),e.materialized.type===`composio`?(0,Q.jsx)($t,{instance:e,t:i,onChanged:r}):null,e.materialized.type===`memorySource`?(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-between gap-3 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`font-medium text-fg`,children:i.connectedSourceSync}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t?.description}),h===null?null:(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:$(i.connectedSourceSynced,{count:String(h)})})]}),(0,Q.jsxs)(U,{disabled:p,onClick:()=>void oe(),children:[p?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):(0,Q.jsx)(z,{className:`size-4`}),i.composioSyncNow]})]}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,Q.jsx)(U,{variant:`secondary`,onClick:n,children:i.modalClose}),b===`config`&&L?(0,Q.jsxs)(U,{variant:`primary`,disabled:d,onClick:()=>void ae(),children:[d?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):(0,Q.jsx)(ne,{className:`size-4`}),i.modalSave]}):null,e.materialized.type===`mcp`?(0,Q.jsxs)(U,{variant:`secondary`,disabled:s,onClick:()=>void H(),children:[s?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):(0,Q.jsx)(O,{className:`size-4`}),i.test]}):null,(0,Q.jsxs)(U,{variant:`ghost`,disabled:l,onClick:()=>void re(),children:[l?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):(0,Q.jsx)(T,{className:`size-4`}),i.remove]})]})]})]}),e.materialized.type===`mcp`?(0,Q.jsx)(Jt,{open:w,onOpenChange:D,serverId:e.materialized.serverId,title:$(i.installedToolsDialogTitle,{name:e.displayName}),subtitle:i.installedToolsDialogSubtitle,searchPlaceholder:a.toolsDialogSearchPlaceholder,searchEmptyLabel:a.toolsDialogSearchEmpty,emptyLabel:i.toolsRunTestHint,closeLabel:a.toolsDialogClose,tools:_?.tools??[],stripPrefix:`${e.materialized.serverId}__`}):null]})}var sn=[`understand`,`act`,`reach`];function cn(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 ln(e){return cn(e)[0]??`act`}function un(e,t){let n=t?ln(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 dn({instance:e,definition:t,highlighted:n=!1,onOpenDetails:r,onChanged:i,t:a}){let[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(null),p=(0,X.useCallback)(async()=>{c(!0),f(null);try{await Ve(e.instanceId),await i()}catch(e){f(e instanceof Error?e.message:String(e))}finally{c(!1)}},[e.instanceId,i]),m=(0,X.useCallback)(async()=>{u(!0),f(null);try{await Se(e.instanceId),await i()}catch(e){f(e instanceof Error?e.message:String(e)),u(!1)}},[e.instanceId,i]),h=e.usage.lastHealthStatus?a.healthStatusLabels[e.usage.lastHealthStatus]??e.usage.lastHealthStatus:a.healthNotTested,g=e.usage.lastToolCount??0,_=!!(t?.setup.config?.length&&!t.setup.secrets?.length&&e.materialized.type===`mcp`),v=un(e,t).state,y=v===`ready`?{label:a.connectionReady,Icon:W,className:`border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`}:v===`needs_setup`?{label:a.connectionNeedsSetup,Icon:oe,className:`border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300`}:{label:a.connectionChecking,Icon:ue,className:`border-edge bg-surface-base text-fg-muted`};return(0,Q.jsxs)(`div`,{className:o(`flex h-full min-h-[10.5rem] cursor-pointer flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`,n&&`ring-2 ring-accent/45 ring-offset-2 ring-offset-surface-panel`),onClick:()=>r(e),children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3`,children:[(0,Q.jsx)(Xe,{connector:t}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.displayName}),(0,Q.jsxs)(`span`,{className:o(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium`,y.className),children:[(0,Q.jsx)(y.Icon,{className:`size-3`,"aria-hidden":!0}),y.label]}),_?(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:a.connectorConfigLabel}):null]}),t?.description?(0,Q.jsx)(`p`,{className:`mt-3 line-clamp-2 text-sm leading-5 text-fg-muted`,children:t.description}):null,(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs text-fg-muted`,children:[(0,Q.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:[a.statusLabel,` `,h]}),(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:$(a.toolsAvailable,{count:String(g)})})]}),d?(0,Q.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:d}):null]})]}),(0,Q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:a.connectorDetails}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[v===`needs_setup`?(0,Q.jsxs)(U,{variant:`primary`,onClick:()=>r(e),children:[(0,Q.jsx)(oe,{className:`size-4`}),a.connectionResolveAction]}):null,e.materialized.type===`mcp`?(0,Q.jsxs)(U,{variant:`secondary`,disabled:s,onClick:()=>void p(),children:[s?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):(0,Q.jsx)(O,{className:`size-4`}),a.test]}):null,(0,Q.jsxs)(U,{variant:`ghost`,disabled:l,onClick:()=>void m(),children:[l?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):(0,Q.jsx)(T,{className:`size-4`}),a.remove]})]})]})]})}var fn=o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,m),pn=o(fn,`min-h-28 font-mono`);function mn(e,t){return e?t.healthStatusLabels[e]??e:t.healthStatusPending}function hn(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 gn(e){let t=(0,Z.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,Q.jsx)(`div`,{className:`border-b border-edge px-3 py-2 text-xs font-semibold text-fg`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,12).map(_n),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>12?(0,Q.jsxs)(`div`,{className:`px-3 py-2 text-xs text-fg-subtle`,children:[`+`,r.length-12]}):null,t[4]=r.length,t[5]=o);let s;t[6]!==a||t[7]!==o?(s=(0,Q.jsxs)(`div`,{className:`max-h-40 overflow-y-auto`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==i||t[10]!==s?(c=(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel`,children:[i,s]}),t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function _n(e){return(0,Q.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,Q.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,Q.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function vn({draft:e,onChange:t,onClose:n,onInstalled:r,t:i}){let{connector:a}=e,s=a.runtime.type===`composio`&&a.runtime.role===`toolkit`,c=a.runtime.type===`composio`&&a.runtime.role===`toolkit`?a.runtime.toolkit:null,[l,u]=(0,X.useState)(!s),[d,f]=(0,X.useState)(s),[p,m]=(0,X.useState)(``),[h,g]=(0,X.useState)(null),[_,v]=(0,X.useState)(!0);(0,X.useEffect)(()=>{if(!s)return;let e=!1;return Le().then(({configured:t})=>{e||u(t)}).catch(t=>{e||g(t instanceof Error?t.message:String(t))}).finally(()=>{e||f(!1)}),()=>{e=!0}},[a.id,s]);let y=e.result?`complete`:e.installing?`health`:`configure`,S=[{id:`configure`,label:i.connectStepConfigure},{id:`health`,label:i.connectStepVerify},{id:`complete`,label:i.connectStepReady}],T=(0,X.useCallback)(async()=>{let n=w(),i=s&&!n?window.open(``,`_blank`):null;i&&(i.opener=null),g(null),t({...e,installing:!0,error:null,result:null,health:null});try{s&&!l&&(await Ge(p),u(!0));let o={};for(let t of a.setup.config??[]){let n=hn(t.type,e.config[t.key]??``);n!==void 0&&(o[t.key]=n)}let d=e.store?await ze(e.store.packageName,{secrets:e.secrets,config:o},e.store.version):await We(a.id,{secrets:e.secrets,config:o,definition:a.source===`registry`?a:void 0}),f=null;try{if(s)if((c?await Ue(c).catch(()=>null):null)?.status===`connected`){i?.close();let e=await Te(c);_&&await Oe(e.id)}else{let e=await He(a.id);if(!e.authorizationUrl)throw Error(`The connection service did not return an authorization URL.`);if(n){let t=await window.electronAPI?.shell?.openExternalUrl(e.authorizationUrl);if(!t?.ok)throw Error(t?.error??`Could not open the system browser.`)}else i?i.location.href=e.authorizationUrl:window.open(e.authorizationUrl,`_blank`,`noopener,noreferrer`);let t=await Te(c,e.connectionId);i?.close(),_&&await Oe(t.id)}}catch(n){i?.close(),t({...e,installing:!1,result:d,health:null,error:n instanceof Error?n.message:String(n)}),await r(d);return}if(!s)try{f=await Ve(d.instanceId)}catch{f=null}t({...e,installing:!1,result:d,health:f}),await r(d)}catch(n){i?.close(),t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}},[p,l,c,a,e,s,_,t,r]);return(0,Q.jsx)(ee,{open:!0,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(E,{children:[(0,Q.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(I,{className:o(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Q.jsx)(Xe,{connector:a,size:`lg`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(pe,{className:`text-base font-semibold text-fg`,children:$(i.connectDialogTitle,{name:a.displayName})}),(0,Q.jsx)(te,{className:`mt-1 line-clamp-3 text-sm text-fg-muted`,children:a.description})]})]}),(0,Q.jsx)(C,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:o(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,N.focusRingPanel),"aria-label":i.modalClose,children:[(0,Q.jsx)(k,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 overflow-y-auto px-6 py-5`,children:[(0,Q.jsx)(`div`,{className:`mb-5 grid grid-cols-3 gap-2`,"aria-label":i.connectProgressAria,children:S.map((e,t)=>{let n=S.findIndex(e=>e.id===y);return(0,Q.jsxs)(`div`,{className:o(`rounded-xl border px-3 py-2 text-xs font-medium`,t===n?`border-accent bg-accent-soft text-accent-fg`:t<n?`border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-900/40 dark:bg-emerald-950/40 dark:text-emerald-200`:`border-edge bg-surface-base text-fg-muted`),children:[(0,Q.jsxs)(`span`,{className:`mr-1 tabular-nums`,children:[t+1,`.`]}),e.label]},e.id)})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[s&&!l?(0,Q.jsxs)(`section`,{className:`rounded-2xl border border-accent/25 bg-accent-soft/50 p-4`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.composioSetupTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:i.composioSetupHint}),(0,Q.jsxs)(`ol`,{className:`mt-3 list-inside list-decimal space-y-1 text-xs text-fg-muted`,children:[(0,Q.jsx)(`li`,{children:i.composioSetupStepProject}),(0,Q.jsx)(`li`,{children:i.composioSetupStepKey}),(0,Q.jsx)(`li`,{children:i.composioSetupStepPaste})]}),(0,Q.jsxs)(`a`,{className:`mt-3 inline-flex items-center gap-1 text-xs font-medium text-accent-fg hover:underline`,href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,children:[i.composioSetupOpenDashboard,(0,Q.jsx)(b,{className:`size-3.5`,"aria-hidden":!0})]}),(0,Q.jsx)(M,{className:`mt-3`,value:p,onChange:m,labels:i.secretInputLabels,placeholder:i.composioSetupKeyPlaceholder}),(0,Q.jsx)(`p`,{className:`mt-2 text-[11px] text-fg-subtle`,children:i.composioSetupStorageHint})]}):null,s?(0,Q.jsxs)(`label`,{className:`flex items-start gap-3 rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 accent-accent`,checked:_,onChange:e=>v(e.currentTarget.checked)}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:i.learnAfterConnect}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:i.learnAfterConnectHint})]})]}):null,e.store?(0,Q.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.detailPermissions}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[(e.store.permissions.data??[]).map(e=>(0,Q.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:e},e)),(e.store.permissions.networkDomains??[]).map(e=>(0,Q.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:e},e)),(0,Q.jsx)(`span`,{className:`rounded-md border border-emerald-500/30 bg-emerald-500/10 px-2 py-1 text-xs text-emerald-700 dark:text-emerald-300`,children:i.storeLocalExecDenied})]})]}):null,(a.setup.secrets??[]).map(n=>(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.description?(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.description}):null,(0,Q.jsx)(M,{value:e.secrets[n.key]??``,onChange:r=>t({...e,secrets:{...e.secrets,[n.key]:r},error:null}),labels:i.secretInputLabels,placeholder:n.required?i.requiredPlaceholder:i.optionalPlaceholder})]},n.key)),(a.setup.config??[]).map(n=>(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.type===`json`?(0,Q.jsx)(`textarea`,{className:pn,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})}):(0,Q.jsx)(`input`,{className:fn,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})})]},n.key)),e.installing?(0,Q.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-fg`,children:[(0,Q.jsx)(G,{className:`size-4 animate-spin text-accent`,"aria-hidden":!0}),i.connectingTitle]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i.connectingHint})]}):null,e.error?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:e.error}):null,h?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:h}):null,e.result?(0,Q.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsx)(`div`,{children:(0,Q.jsx)(`p`,{className:`font-medium text-fg`,children:i.connectedBadge})}),(0,Q.jsx)(`span`,{className:o(`rounded-full px-2 py-0.5 text-xs font-medium`,e.health?.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e.health?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-hover text-fg-muted`),children:e.health?.ok?i.healthStatusHealthy:mn(e.health?.status,i)})]}),e.health?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.toolCount}),(0,Q.jsx)(`div`,{children:i.toolsMetric})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.resourceCount}),(0,Q.jsx)(`div`,{children:i.resourcesMetric})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.promptCount}),(0,Q.jsx)(`div`,{children:i.promptsMetric})]})]}),(0,Q.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,Q.jsx)(gn,{title:i.detailTools,items:e.health.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,Q.jsx)(gn,{title:i.detailResources,items:e.health.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,Q.jsx)(gn,{title:i.detailPrompts,items:e.health.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??$(i.promptArgumentCount,{count:String(e.argumentCount)})}))})]})]}):(0,Q.jsx)(`p`,{className:`mt-3`,children:i.installedWithoutHealth}),e.health?.action?(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:e.health.action}):null]}):null]})]}),(0,Q.jsx)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:(0,Q.jsxs)(U,{variant:`primary`,disabled:!!e.result||e.installing||d||s&&!l&&!p.trim(),onClick:()=>void T(),children:[e.installing?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):e.result?(0,Q.jsx)(W,{className:`size-4`}):(0,Q.jsx)(P,{className:`size-4`}),e.result?i.connectedBadge:i.connect]})})]})]})})}function yn(e,t){let n={};for(let t of e.setup.secrets??[])n[t.key]=``;let r={};for(let t of e.setup.config??[])r[t.key]=t.defaultValue===void 0?``:typeof t.defaultValue==`string`?t.defaultValue:JSON.stringify(t.defaultValue,null,2);return{connector:e,secrets:n,config:r,installing:!1,error:null,result:null,health:null,...t?{store:t}:{}}}function bn(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 Mt(r)}function xn(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 Sn(){return o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,m)}function Cn({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:i,pasteFailed:a,keyPlaceholder:c,valuePlaceholder:l,headers:u,onChange:d}){let f=(e,t)=>{d(u.map((n,r)=>r===e?{...n,...t}:n))},p=()=>{d([...u,{key:``,value:``}])},m=e=>{let t=u.filter((t,n)=>n!==e);d(t.length>0?t:[{key:``,value:``}])},h=async()=>{try{let e=await s();if(!e){window.alert(a);return}let t=Ct(e);if(!t?.length){window.alert(a);return}d(t)}catch{window.alert(a)}};return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,Q.jsx)(`span`,{children:e}),t?(0,Q.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),(0,Q.jsxs)(U,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void h(),children:[(0,Q.jsx)(H,{className:`size-3.5`,"aria-hidden":!0}),i]})]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{className:o(Sn(),`min-w-0 flex-1 font-mono text-xs`),value:e.key,placeholder:c,onChange:e=>f(t,{key:e.target.value})}),(0,Q.jsx)(`input`,{className:o(Sn(),`min-w-0 flex-[1.4] font-mono text-xs`),value:e.value,placeholder:l,onChange:e=>f(t,{value:e.target.value})}),(0,Q.jsx)(U,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:u.length<=1&&!e.key&&!e.value,onClick:()=>m(t),"aria-label":r,children:(0,Q.jsx)(T,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})})]},xn(e,t,u)))}),(0,Q.jsxs)(`button`,{type:`button`,className:o(`self-start text-sm text-accent hover:underline`,N.press),onClick:p,children:[`+ `,n]})]})}var wn=[`stdio`,`sse`,`streamable-http`];function Tn(e){let t=(0,Z.c)(11),{label:n,description:r,required:i,children:a}=e,o;t[0]===i?o=t[1]:(o=i?(0,Q.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,Q.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,Q.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,Q.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 En(){return o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,m)}function Dn(e){let t=(0,Z.c)(29),{row:n,t:r,onUpdate:i,idConflictMessage:a,variant:s}=e,c=s===void 0?`all`:s,l=c===`all`||c===`basic`,u=c===`all`||c===`advanced`,d;t[0]!==a||t[1]!==i||t[2]!==n.id||t[3]!==n.transport||t[4]!==l||t[5]!==r?(d=l?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Tn,{label:r.transportLabel,required:!0,children:(0,Q.jsx)(le,{className:En(),value:n.transport,onChange:e=>i({transport:e.target.value}),children:wn.map(e=>(0,Q.jsx)(V,{value:e,children:r.transportLabels[e]},e))})}),(0,Q.jsxs)(Tn,{label:r.serverIdLabel,required:!0,children:[(0,Q.jsx)(`input`,{className:En(),value:n.id,placeholder:r.serverIdPlaceholder,onChange:e=>i({id:e.target.value})}),a?(0,Q.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]=l,t[5]=r,t[6]=d):d=t[6];let f;t[7]!==i||t[8]!==n.argsText||t[9]!==n.command||t[10]!==n.cwd||t[11]!==n.envJson||t[12]!==n.headers||t[13]!==n.transport||t[14]!==n.url||t[15]!==u||t[16]!==l||t[17]!==r||t[18]!==c?(f=n.transport===`stdio`?(0,Q.jsxs)(Q.Fragment,{children:[l?(0,Q.jsx)(`div`,{className:c===`basic`?`md:col-span-2`:void 0,children:(0,Q.jsx)(Tn,{label:r.commandLabel,required:!0,children:(0,Q.jsx)(`input`,{className:En(),value:n.command,onChange:e=>i({command:e.target.value})})})}):null,u?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Tn,{label:r.argsLabel,description:r.argsHint,children:(0,Q.jsx)(`input`,{className:En(),value:n.argsText,onChange:e=>i({argsText:e.target.value})})}),(0,Q.jsx)(Tn,{label:r.cwdLabel,children:(0,Q.jsx)(`input`,{className:En(),value:n.cwd,onChange:e=>i({cwd:e.target.value})})}),(0,Q.jsx)(Tn,{label:r.envLabel,description:r.envHint,children:(0,Q.jsx)(`textarea`,{className:o(En(),`min-h-[4rem] font-mono text-xs`),value:n.envJson,onChange:e=>i({envJson:e.target.value})})})]}):null]}):(0,Q.jsxs)(Q.Fragment,{children:[l?(0,Q.jsx)(`div`,{className:`md:col-span-2`,children:(0,Q.jsx)(Tn,{label:r.urlLabel,required:!0,children:(0,Q.jsx)(`input`,{className:o(En(),`font-mono text-xs`),value:n.url,placeholder:`https://example.com/mcp`,onChange:e=>i({url:e.target.value})})})}):null,u?(0,Q.jsx)(Cn,{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:e})}):null]}),t[7]=i,t[8]=n.argsText,t[9]=n.command,t[10]=n.cwd,t[11]=n.envJson,t[12]=n.headers,t[13]=n.transport,t[14]=n.url,t[15]=u,t[16]=l,t[17]=r,t[18]=c,t[19]=f):f=t[19];let p;t[20]!==i||t[21]!==n||t[22]!==u||t[23]!==r?(p=u?(0,Q.jsx)(Tn,{label:r.timeoutLabel,description:r.timeoutHint,children:(0,Q.jsx)(`input`,{type:`number`,min:1,max:600,className:En(),value:Bt(n),placeholder:r.timeoutPlaceholder,onChange:e=>i({connectionTimeoutMs:Vt(e.target.value)})})}):null,t[20]=i,t[21]=n,t[22]=u,t[23]=r,t[24]=p):p=t[24];let m;return t[25]!==d||t[26]!==f||t[27]!==p?(m=(0,Q.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[d,f,p]}),t[25]=d,t[26]=f,t[27]=p,t[28]=m):m=t[28],m}function On(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 kn(e){let t=(0,Z.c)(13),{tool:n,serverId:r}=e,i;t[0]!==r||t[1]!==n?(i=On(n,r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,s=n.name===a?a:n.name,c;t[3]===n.description?c=t[4]:(c=n.description?.trim(),t[3]=n.description,t[4]=c);let l=c,u;t[5]!==a||t[6]!==s?(u=(0,Q.jsx)(`p`,{className:`break-all font-mono text-xs font-medium leading-5 text-fg`,title:s,children:a}),t[5]=a,t[6]=s,t[7]=u):u=t[7];let d;t[8]===l?d=t[9]:(d=l?(0,Q.jsx)(S,{delayDuration:300,skipDelayDuration:100,children:(0,Q.jsxs)(F,{children:[(0,Q.jsx)(R,{asChild:!0,children:(0,Q.jsx)(`p`,{tabIndex:0,title:l,className:o(`mt-1 line-clamp-3 cursor-help text-xs leading-5 text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:l})}),(0,Q.jsx)(L,{children:(0,Q.jsx)(h,{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,Q.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:l})})})]})}):null,t[8]=l,t[9]=d);let f;return t[10]!==u||t[11]!==d?(f=(0,Q.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[u,d]}),t[10]=u,t[11]=d,t[12]=f):f=t[12],f}function An({open:e,mode:t,initialRow:n,existingCustomServers:r,sessionIdleTtlMinutes:i,config:a,managedServerIds:s,t:c,cs:l,onClose:u,onSaved:d}){let[f,p]=(0,X.useState)(n),[m,h]=(0,X.useState)(!1),[g,_]=(0,X.useState)(!1),[v,b]=(0,X.useState)(null),[S,w]=(0,X.useState)(!1),[T,D]=(0,X.useState)({status:`idle`}),[A,j]=(0,X.useState)(null),M=n.id.trim(),P=f.id.trim()!==M&&s.has(f.id.trim())||s.has(f.id.trim())&&t===`add`?c.reservedServerId:void 0,F=f.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===f.id.trim())?l.duplicateServerId:void 0,L=f.id.trim().length>0&&!P&&!F&&(f.transport===`stdio`?f.command.trim().length>0:f.url.trim().length>0),R=Ht(f),z=(0,X.useCallback)(async()=>{if(f.id.trim()){_(!0),b(null),D({status:`loading`});try{D({status:`ok`,tools:(await zt(f.id.trim(),Pt(f))).tools})}catch(e){D({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{_(!1)}}},[f]),B=(0,X.useCallback)(async()=>{if(!(!L||m)){h(!0),b(null);try{let e=r.filter(e=>!(t===`edit`&&e.clientKey===n.clientKey));e.push(f),await Ft({sessionIdleTtlMinutes:i,servers:e.sort((e,t)=>e.id.localeCompare(t.id))},Dt(a)),await d(),u()}catch(e){b(e instanceof Error?e.message:String(e))}finally{h(!1)}}},[L,a,r,n.clientKey,t,u,d,M,f,m,i]);return e?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ee,{open:e,onOpenChange:e=>{e||u()},children:(0,Q.jsxs)(E,{children:[(0,Q.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(I,{className:o(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(pe,{className:`text-base font-semibold text-fg`,children:t===`add`?l.addCustomServerTitle:l.editCustomServerTitle}),(0,Q.jsx)(te,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?l.addCustomServerHint:l.editCustomServerHint})]}),(0,Q.jsx)(C,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:o(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,N.focusRingPanel),"aria-label":l.modalClose,children:[(0,Q.jsx)(k,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`sr-only`,children:l.modalClose})]})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(ae,{className:`size-4 text-accent`,"aria-hidden":!0}),f.id.trim()||c.cardUntitled]}),(0,Q.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs leading-5 text-fg-muted`,children:R||(f.transport===`stdio`?c.commandLabel:c.urlLabel)})]}),(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:c.transportLabels[f.transport]})]})}),(0,Q.jsxs)(`section`,{children:[(0,Q.jsxs)(`div`,{className:`mb-3`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.connectorBasicConfigTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.connectorBasicConfigHint})]}),(0,Q.jsx)(Dn,{row:f,t:c,variant:`basic`,onUpdate:e=>{p(t=>({...t,...e})),b(null)},idConflictMessage:P??F})]}),T.status===`ok`?(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,Q.jsx)(y,{className:`size-4 text-accent`,"aria-hidden":!0}),T.tools.length===0?c.toolsEmpty:c.toolsTitle.replace(`{{count}}`,String(T.tools.length))]}),T.tools.length>0?(0,Q.jsx)(U,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>j(T.tools),children:c.viewAllTools}):null]}),T.tools.length>0?(0,Q.jsx)(`div`,{className:`mt-3 grid gap-2`,children:T.tools.slice(0,6).map((e,t)=>(0,Q.jsx)(kn,{tool:e,serverId:f.id},e.name||`tool-${t}`))}):null]}):null,T.status===`error`?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:T.message}):null,v?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:v}):null,(0,Q.jsxs)(`details`,{open:S,onToggle:e=>w(e.currentTarget.open),className:`group rounded-xl border border-edge bg-surface-base`,children:[(0,Q.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,Q.jsx)(J,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`group-open:hidden`,children:l.connectorShowAdvancedConfig}),(0,Q.jsx)(`span`,{className:`hidden group-open:inline`,children:l.connectorHideAdvancedConfig})]}),(0,Q.jsx)(`div`,{className:`border-t border-edge p-4`,children:(0,Q.jsx)(Dn,{row:f,t:c,variant:`advanced`,onUpdate:e=>{p(t=>({...t,...e})),b(null)}})})]})]})}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,Q.jsxs)(U,{variant:`secondary`,disabled:!f.id.trim()||g,onClick:()=>void z(),children:[g?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):(0,Q.jsx)(O,{className:`size-4`}),c.testConnection]}),(0,Q.jsx)(C,{asChild:!0,children:(0,Q.jsx)(U,{variant:`secondary`,children:l.modalCancel})}),(0,Q.jsxs)(U,{variant:`primary`,disabled:!L||m,onClick:()=>void B(),children:[m?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):(0,Q.jsx)(W,{className:`size-4`}),m?c.saving:l.modalSave]})]})]})]})}),A?(0,Q.jsx)(Jt,{open:!0,onOpenChange:e=>{e||j(null)},serverId:f.id,title:c.toolsDialogTitle,subtitle:c.toolsDialogSubtitle,searchPlaceholder:c.toolsDialogSearchPlaceholder,searchEmptyLabel:c.toolsDialogSearchEmpty,emptyLabel:c.toolsEmpty,closeLabel:c.toolsDialogClose,tools:A,stripPrefix:`${f.id.trim()}__`}):null]}):null}function jn(e){return!(e.runtime.type===`composio`&&e.runtime.role===`credential`)}function Mn(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 Nn(e,t,n){return e.filter(e=>Mn(e,t)).toSorted((e,t)=>n===`source`&&e.source!==t.source?e.source.localeCompare(t.source):e.displayName.localeCompare(t.displayName))}function Pn(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 Fn(e,t){let n=t.trim().toLowerCase();return n?[e.id,e.command??``,e.url??``,e.transport].some(e=>e.toLowerCase().includes(n)):!0}var In=`all`,Ln=`builtin`,Rn=`composio`,zn=`xopc-store`;function Bn(e){let t=[`code`,`docs`,`browser`,`data`,`automation`,`custom`].includes(e.category??``)?e.category:`custom`;return{id:e.name,version:e.latestVersion??`store`,displayName:e.name,description:e.description,category:t,kind:`mcp`,source:`store`,capabilities:[`tools`,`runtime.mcp.streamableHttp`],tags:[`store`],auth:{mode:`none`},setup:{},runtime:{type:`mcp`,serverId:`store-${e.name}`.slice(0,64)}}}function Vn(e){return e.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t)}function Hn(){let e=c(u(e=>e.language)),t=e.connectorsSettings,n=e.mcpSettings,r=l(e=>e.token),a=!!r,[s,d]=i(),[f,m]=(0,X.useState)(s.get(`tab`)===`connected`?`connected`:`discover`),h=(0,X.useRef)(!1),[g,v]=(0,X.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null,peopleGraph:null}),[y,b]=(0,X.useState)(!1),[x,S]=(0,X.useState)(!1),[C,w]=(0,X.useState)(1),[T,E]=(0,X.useState)(void 0),[D,O]=(0,X.useState)(``),[k,A]=(0,X.useState)(``),[j,M]=(0,X.useState)(!1),[N,P]=(0,X.useState)(``),[F,I]=(0,X.useState)(Ln),[L,ee]=(0,X.useState)(`name`),[R,te]=(0,X.useState)(`all`),[z,B]=(0,X.useState)(null),[V,H]=(0,X.useState)(null),[ne,re]=(0,X.useState)(null),[ie,ae]=(0,X.useState)(null),[oe,se]=(0,X.useState)(null),[ce,le]=(0,X.useState)(null),[ue,de]=(0,X.useState)(!1),[W,pe]=(0,X.useState)(void 0),[he,ge]=(0,X.useState)(!1),{data:_e,mutate:ve}=p(a),K=_e?.payload?.config,q=(0,X.useMemo)(()=>K===void 0?null:Nt(K),[K]),J=q?.servers??[],ye=g.instances.length+J.length;(0,X.useEffect)(()=>{q&&pe(q.sessionIdleTtlMinutes)},[q]);let Y=(0,X.useCallback)(async()=>{if(!r){v({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null,peopleGraph:null});return}v(e=>({...e,loading:!0,error:null}));try{let[e,t,n]=await Promise.all([Ne(),Ke(),Be(``,12).catch(()=>null)]);v(r=>({catalog:e,registryCatalog:r.registryCatalog,instances:t,loading:!1,error:null,peopleGraph:n}))}catch(e){v({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e),peopleGraph:null})}},[r]);(0,X.useEffect)(()=>{Y()},[Y]),(0,X.useEffect)(()=>{if(!a||f!==`connected`)return;let e=!1,t=window.setTimeout(()=>{M(!0),Be(k,50).then(t=>{e||v(e=>({...e,peopleGraph:t}))}).catch(()=>{}).finally(()=>{e||M(!1)})},250);return()=>{e=!0,window.clearTimeout(t)}},[a,k,f]),(0,X.useEffect)(()=>{h.current||g.loading||a&&!q||(m(ye>0?`connected`:`discover`),h.current=!0)},[a,ye,q,g.loading]);let Se=(0,X.useCallback)(e=>{h.current=!0,m(e)},[]),Ce=(0,X.useMemo)(()=>[{id:Rn,displayName:t.composioSourceName},{id:zn,displayName:t.storeSourceName}],[t.composioSourceName,t.storeSourceName]),we=(0,X.useCallback)(async e=>{if(!a||F===Ln){v(e=>({...e,registryCatalog:[]})),w(1),E(void 0);return}let t=N.trim(),n=Math.max(e?.page??1,1),r=e?.append??!1,i=F===In?Ce:Ce.filter(e=>e.id===F);if(i.length!==0){b(!0),r?v(e=>({...e,error:null})):(w(1),E(void 0),v(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(i.map(async e=>{if(e.id===Rn){let e=await Je({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let r=await Ye({q:t||void 0,page:n,pageSize:24,sort:L===`source`?`newest`:`downloads`});return{connectors:r.items.map(Bn),totalPages:r.meta.totalPages}})),a=Vn(e.flatMap(e=>e.connectors)),o=Math.max(1,...e.map(e=>e.totalPages??1));w(n),E(o),v(e=>({...e,registryCatalog:r?Vn([...e.registryCatalog,...a]):a}))}catch(e){v(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{b(!1)}}},[L,N,F,a,Ce]);(0,X.useEffect)(()=>{if(f!==`discover`||g.loading)return;if(F===Ln){v(e=>({...e,registryCatalog:[]})),w(1),E(void 0);return}let e=window.setTimeout(()=>{we()},N.trim()?350:0);return()=>window.clearTimeout(e)},[N,F,we,g.loading,f]);let Te=(0,X.useMemo)(()=>new Set(g.instances.map(e=>e.connectorId)),[g.instances]),Ee=(0,X.useMemo)(()=>new Map([...g.catalog,...g.registryCatalog].map(e=>[e.id,e])),[g.catalog,g.registryCatalog]);(0,X.useEffect)(()=>{if(g.loading)return;let e=s.get(`connector`),t=s.get(`instance`);if(!e&&!t)return;let n=g.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)h.current=!0,O(``),re(n.instanceId),ae(n),m(`connected`);else if(e){let t=Ee.get(e);if(!t)return;h.current=!0,I(Ln),P(``),H(t),m(`discover`)}let r=new URLSearchParams(s);r.delete(`connector`),r.delete(`instance`),r.delete(`personalContext`),r.set(`tab`,n?`connected`:`discover`),d(r,{replace:!0})},[Ee,s,d,g.instances,g.loading]);let De=(0,X.useCallback)(async e=>{S(!0),v(e=>({...e,error:null}));try{let t=await Fe(e);B(yn(t.definition,{packageName:t.packageName,version:t.version,permissions:t.permissions}))}catch(e){v(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{S(!1)}},[]),Oe=(0,X.useMemo)(()=>new Set(g.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[g.instances]),ke=(0,X.useCallback)(async e=>{if(!q||K===void 0)return;let t=J.filter(t=>t.clientKey!==e.clientKey);await Ft({sessionIdleTtlMinutes:q.sessionIdleTtlMinutes,servers:t},Dt(K)),await ve(),await Y()},[K,J,Y,q,ve]),Ae=(0,X.useCallback)(()=>{le({mode:`add`,row:bn(J,Oe)})},[J,Oe]),je=(0,X.useCallback)(async()=>{if(!(!q||K===void 0||he)){ge(!0);try{await Ft({sessionIdleTtlMinutes:W,servers:J},Dt(K)),await ve(),de(!1)}finally{ge(!1)}}},[K,J,n.saved,q,ve,W,he]),Me=_(e=>e.setPageHeader),Pe=_(e=>e.clearPageHeader),Ie=(0,X.useMemo)(()=>(0,Q.jsx)(xt,{onBrowseCatalog:()=>Se(`discover`),onAddCustomServer:Ae,onOpenRuntimeSettings:()=>de(!0),addLabel:t.addConnection,browseLabel:t.addFromCatalog,customLabel:t.addCustomServerAdvanced,settingsLabel:t.runtimeSettings}),[t,Ae,Se]);(0,X.useLayoutEffect)(()=>(Me({startExtra:null,main:(0,Q.jsx)(`div`,{className:`min-w-0`,children:(0,Q.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title})}),end:Ie}),()=>Pe()),[Pe,t.title,Ie,Me]);let Le=(0,X.useMemo)(()=>g.instances.map(e=>({instance:e,value:un(e,Ee.get(e.connectorId))})),[Ee,g.instances]),Re=(0,X.useMemo)(()=>new Map(Le.map(({instance:e,value:t})=>[e.instanceId,t])),[Le]),ze=(0,X.useMemo)(()=>g.instances.filter(e=>Pn(e,D)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=Re.get(e.instanceId)?.state??`checking`,i=Re.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[D,Re,g.instances]),Ve=(0,X.useMemo)(()=>J.filter(e=>Fn(e,D)),[D,J]),He=ze.length+Ve.length,Ue=(0,X.useMemo)(()=>g.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&jn(e)),[g.catalog]),We=(0,X.useMemo)(()=>F===Ln?Ue:F===In?Vn([...Ue,...g.registryCatalog]):g.registryCatalog,[Ue,F,g.registryCatalog]),Ge=(0,X.useMemo)(()=>Nn(R===`all`?We:We.filter(e=>cn(e).includes(R)),N,L),[L,N,We,R]),qe=(0,X.useMemo)(()=>sn.filter(e=>We.some(t=>cn(t).includes(e))),[We]);(0,X.useEffect)(()=>{R!==`all`&&!qe.includes(R)&&te(`all`)},[qe,R]);let Xe=f===`discover`&&F!==Ln&&!!(T&&C<T),Ze=(0,X.useMemo)(()=>g.instances.find(e=>e.instanceId===ne)??ie,[ne,ie,g.instances]),Qe=(0,X.useMemo)(()=>[{value:In,label:t.discoverSourceAll},{value:Ln,label:t.discoverSourceBuiltin},...Ce.map(e=>({value:e.id,label:e.displayName}))],[t.discoverSourceAll,t.discoverSourceBuiltin,Ce]),$e=[{id:`connected`,label:t.tabConnected,count:ye},{id:`discover`,label:t.tabDiscover}];return(0,Q.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,Q.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[a?null:(0,Q.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:t.tokenHint}),(0,Q.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(`div`,{className:`border-b border-edge-subtle pb-3 dark:border-edge-subtle`,children:(0,Q.jsx)(xe,{items:$e,activeTab:f,onChange:Se,ariaLabel:t.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),g.error?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:g.error}):null,f===`connected`&&a?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,Q.jsx)(bt,{value:D,onChange:O,placeholder:t.connectedSearchPlaceholder,className:`max-w-xl`}),(0,Q.jsx)(fe,{className:`size-9 shrink-0 p-0`,loading:g.loading,label:t.refreshConnections,title:t.refreshConnections,onClick:Y})]}),g.peopleGraph&&(g.peopleGraph.people.length>0||k)?(0,Q.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`div`,{className:`rounded-lg bg-accent-soft p-2 text-accent-fg`,children:(0,Q.jsx)(be,{className:`size-4`,"aria-hidden":!0})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.peopleGraphTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.peopleGraphHint.replace(`{{people}}`,String(g.peopleGraph.people.length)).replace(`{{sources}}`,String(new Set(g.peopleGraph.sourceEdges.map(e=>e.sourceInstanceId)).size))})]})]}),(0,Q.jsxs)(`div`,{className:`relative w-full max-w-xs`,children:[(0,Q.jsx)(bt,{value:k,onChange:A,placeholder:t.peopleGraphSearchPlaceholder}),j?(0,Q.jsx)(G,{className:`absolute right-3 top-2.5 size-4 animate-spin text-fg-subtle`,"aria-hidden":!0}):null]})]}),g.peopleGraph.people.length?(0,Q.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:g.peopleGraph.people.slice(0,10).map(e=>{let t=[...new Set(g.peopleGraph.sourceEdges.filter(t=>t.personId===e.id).map(e=>e.toolkit??e.connectorId??e.sourceInstanceId))];return(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel px-3 py-2.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.label}),(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:e.mentionCount})]}),(0,Q.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:e.emails[0]??e.usernames[0]??e.roles.join(` · `)}),(0,Q.jsx)(`p`,{className:`mt-1 truncate text-[11px] text-fg-subtle`,children:t.join(` · `)})]},e.id)})}):(0,Q.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:t.peopleGraphSearchEmpty})]}):null,g.loading?(0,Q.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":t.loading,children:it.slice(0,3).map(e=>(0,Q.jsx)(lt,{},e))}):ye===0?(0,Q.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.connectionsEmpty}),(0,Q.jsx)(U,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>Se(`discover`),children:t.addFromCatalog})]}):He===0?(0,Q.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.connectionsSearchEmpty}):(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:[ze.map(e=>(0,Q.jsx)(dn,{instance:e,definition:Ee.get(e.connectorId),highlighted:e.instanceId===oe,onOpenDetails:e=>{se(null),re(e.instanceId),ae(e)},onChanged:Y,t},e.instanceId)),Ve.map(e=>(0,Q.jsx)(Ut,{row:e,t:n,cs:t,onEdit:()=>le({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>ke(e)},e.clientKey))]})]}):null,f===`discover`&&a?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":t.outcomeFilterAria,children:[`all`,...qe].map(e=>(0,Q.jsx)(`button`,{type:`button`,className:o(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,R===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":R===e,onClick:()=>te(e),children:e===`all`?t.outcomeAll:t.connectorBenefitHeadings[e]},e))}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 lg:flex-row lg:items-center`,children:[(0,Q.jsx)(bt,{value:N,onChange:P,placeholder:t.discoverSearchPlaceholder,className:`max-w-xl`}),(0,Q.jsxs)(`div`,{className:`grid min-w-0 grid-cols-1 gap-2 sm:grid-cols-2 lg:ml-auto lg:w-[26rem]`,children:[(0,Q.jsx)(me,{value:F,options:Qe,placeholder:t.discoverSourceAll,allowEmpty:!1,ariaLabel:t.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:I}),(0,Q.jsx)(me,{value:L,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=>ee(e)})]})]}),(g.loading||y)&&Ge.length===0?(0,Q.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:it.map(e=>(0,Q.jsx)(st,{},e))}):Ge.length===0?(0,Q.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.discoverEmpty}):(0,Q.jsxs)(`div`,{className:`relative`,children:[y?(0,Q.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,Q.jsx)(G,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,Q.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:Ge.map(e=>(0,Q.jsx)(nt,{connector:e,installed:Te.has(e.id)||at(e,g.instances),onInstall:e=>{if(e.source===`store`){De(e.id);return}B(yn(e))},onOpenDetails:e.source===`store`?void 0:H,t},e.id))}),Xe?(0,Q.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,Q.jsxs)(U,{type:`button`,variant:`secondary`,disabled:y||x,onClick:()=>void we({page:C+1,append:!0}),children:[y?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):null,t.loadMore]})}):null]})]}):null]}),z?(0,Q.jsx)(vn,{draft:z,onChange:B,onClose:()=>B(null),t,onInstalled:async e=>{await Y(),await ve(),se(e.instanceId),Se(`connected`)}}):null,V?(0,Q.jsx)(_t,{connector:V,installed:Te.has(V.id)||at(V,g.instances),onClose:()=>H(null),onInstall:e=>B(yn(e)),t}):null,Ze?(0,Q.jsx)(on,{instance:Ze,definition:Ee.get(Ze.connectorId),onClose:()=>{re(null),ae(null)},onChanged:Y,t,mcp:n}):null,ce?(0,Q.jsx)(An,{open:!0,mode:ce.mode,initialRow:ce.row,existingCustomServers:J,sessionIdleTtlMinutes:W,config:K,managedServerIds:Oe,t:n,cs:t,onClose:()=>le(null),onSaved:async()=>{await ve(),await Y(),Se(`connected`)}},`${ce.mode}-${ce.row.clientKey}`):null,(0,Q.jsx)(yt,{open:ue,sessionIdleTtlMinutes:W,saving:he,onChange:pe,onSave:je,onClose:()=>de(!1),t,mcp:n})]})})}export{Hn as ConnectorsPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./cn-JdwAhgNB.js";import{n as s}from"./copy-to-clipboard-HOJ79TWv.js";import{t as c}from"./messages-H_iJjnEM.js";import{l,n as u,r as d,s as f}from"./locale-store-BNC8HUCI.js";import{$a as p,As as m,Bi as h,Ci as g,Do as _,Ei as v,Fs as y,Gl as b,Go as x,Hi as S,Ho as C,Jo as w,Js as T,Ko as E,Mc as D,Pc as O,Ps as k,Qa as A,Si as j,Ss as M,Ts as N,Uc as P,Ui as F,Uo as I,Vi as L,Vo as ee,Wi as R,Wo as te,Xl as z,_l as B,as as V,au as H,bc as ne,ds as re,fc as ie,gc as ae,gu as oe,hc as se,ic as ce,is as le,iu as ue,jc as de,js as U,mu as W,nl as G,oa as fe,qo as pe,rs as me,tc as he,us as ge,vc as _e,wc as ve,wi as K,xi as q,yu as J,zl as ye,zs as be}from"./index-BA56bQ68.js";import{t as xe}from"./page-tabs-BnSzIjH0.js";import{A as Y,C as Se,E as Ce,F as we,I as Te,M as Ee,N as De,O as Oe,P as ke,S as Ae,T as je,_ as Me,a as Ne,b as Pe,c as Fe,d as Ie,f as Le,g as Re,h as ze,i as Be,j as Ve,k as He,l as Ue,m as We,n as Ge,o as Ke,p as qe,r as Je,s as Ye,t as Xe,u as Ze,v as Qe,w as $e,x as et,y as tt}from"./connector-logo-CxIXnifA.js";var X=e(t(),1),Z=n(),Q=r();function nt(e){let t=(0,Z.c)(74),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:s}=e,c,l,u,d,f,p,m,h,g,_;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==s.connect||t[5]!==s.connectedBadge||t[6]!==s.connectorBeta||t[7]!==s.connectorCapabilityLabels||t[8]!==s.connectorExperimental||t[9]!==s.connectorVerified){let e=n.capabilities.filter(rt),v=e.slice(0,3),y=Math.max(0,e.length-v.length),b=s.connect,x=n.verificationLevel===`verified`?s.connectorVerified:n.verificationLevel===`beta`?s.connectorBeta:n.verificationLevel===`experimental`?s.connectorExperimental:null,S;t[20]!==b||t[21]!==n||t[22]!==i?(S=e=>(0,Q.jsxs)(U,{type:`button`,variant:`primary`,className:o(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:e=>{e.stopPropagation(),i(n)},children:[(0,Q.jsx)(P,{className:`size-4`}),b]}),t[20]=b,t[21]=n,t[22]=i,t[23]=S):S=t[23],c=S;let C;t[24]!==n||t[25]!==a?(C=e=>{!a||e.currentTarget!==e.target||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),a(n))},t[24]=n,t[25]=a,t[26]=C):C=t[26];let w=C,T=a?`cursor-pointer`:null;t[27]===T?p=t[28]:(p=o(`group flex min-h-[9.5rem] flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,T),t[27]=T,t[28]=p),m=a?`button`:void 0,h=a?0:void 0,t[29]!==n||t[30]!==a?(g=()=>a?.(n),t[29]=n,t[30]=a,t[31]=g):g=t[31],_=w,l=`flex min-w-0 flex-1 flex-col`;let E;t[32]===n?E=t[33]:(E=(0,Q.jsx)(Xe,{connector:n}),t[32]=n,t[33]=E);let D;t[34]===n.displayName?D=t[35]:(D=(0,Q.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[34]=n.displayName,t[35]=D);let O;t[36]===x?O=t[37]:(O=x?(0,Q.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:x}):null,t[36]=x,t[37]=O);let k;t[38]!==D||t[39]!==O?(k=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[D,O]}),t[38]=D,t[39]=O,t[40]=k):k=t[40];let A;t[41]!==E||t[42]!==k?(A=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[E,k]}),t[41]=E,t[42]=k,t[43]=A):A=t[43];let j;t[44]!==r||t[45]!==c?(j=r?null:(0,Q.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 transition-opacity sm:pointer-events-none sm:flex sm:opacity-0 sm:group-hover:pointer-events-auto sm:group-hover:opacity-100 sm:group-focus-within:pointer-events-auto sm:group-focus-within:opacity-100`,children:c()}),t[44]=r,t[45]=c,t[46]=j):j=t[46];let M;t[47]!==r||t[48]!==s.connectedBadge?(M=r?(0,Q.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,Q.jsx)(W,{className:`size-3`,"aria-hidden":!0}),s.connectedBadge]}):null,t[47]=r,t[48]=s.connectedBadge,t[49]=M):M=t[49];let N;t[50]!==j||t[51]!==M?(N=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[j,M]}),t[50]=j,t[51]=M,t[52]=N):N=t[52],t[53]!==A||t[54]!==N?(u=(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[A,N]}),t[53]=A,t[54]=N,t[55]=u):u=t[55],t[56]===n.description?d=t[57]:(d=(0,Q.jsx)(`p`,{className:`mt-4 line-clamp-2 text-sm leading-6 text-fg-muted`,title:n.description,children:n.description}),t[56]=n.description,t[57]=d),f=v.length>0?(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-1.5`,children:[v.map(e=>(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:s.connectorCapabilityLabels[e]??e},e)),y>0?(0,Q.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,y]}):null]}):null,t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=s.connect,t[5]=s.connectedBadge,t[6]=s.connectorBeta,t[7]=s.connectorCapabilityLabels,t[8]=s.connectorExperimental,t[9]=s.connectorVerified,t[10]=c,t[11]=l,t[12]=u,t[13]=d,t[14]=f,t[15]=p,t[16]=m,t[17]=h,t[18]=g,t[19]=_}else c=t[10],l=t[11],u=t[12],d=t[13],f=t[14],p=t[15],m=t[16],h=t[17],g=t[18],_=t[19];let v;t[58]!==l||t[59]!==u||t[60]!==d||t[61]!==f?(v=(0,Q.jsxs)(`div`,{className:l,children:[u,d,f]}),t[58]=l,t[59]=u,t[60]=d,t[61]=f,t[62]=v):v=t[62];let y;t[63]!==r||t[64]!==c?(y=r?null:(0,Q.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:c(`w-full`)}),t[63]=r,t[64]=c,t[65]=y):y=t[65];let b;return t[66]!==v||t[67]!==y||t[68]!==p||t[69]!==m||t[70]!==h||t[71]!==g||t[72]!==_?(b=(0,Q.jsxs)(`div`,{className:p,role:m,tabIndex:h,onClick:g,onKeyDown:_,children:[v,y]}),t[66]=v,t[67]=y,t[68]=p,t[69]=m,t[70]=h,t[71]=g,t[72]=_,t[73]=b):b=t[73],b}function rt(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var it=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function at(e,t){return t.some(t=>t.connectorId===e.id)}var ot=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function st(){let e=(0,Z.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(`div`,{className:o(`size-10 shrink-0 rounded-xl`,ot)}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.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,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:[t,(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Q.jsx)(`div`,{className:o(`h-4 min-w-0 flex-1`,ot)}),(0,Q.jsx)(`div`,{className:o(`h-8 w-[4.5rem] shrink-0 rounded-lg`,ot)})]}),(0,Q.jsx)(`div`,{className:o(`h-3 w-full`,ot)}),(0,Q.jsx)(`div`,{className:o(`h-3 w-[88%]`,ot)})]})]})}),e[1]=n):n=e[1],n}var ct=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function lt(){let e=(0,Z.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(`div`,{className:o(`size-10 shrink-0 rounded-xl`,ct)}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,Q.jsx)(`div`,{className:o(`h-4 w-48 max-w-full`,ct)}),(0,Q.jsx)(`div`,{className:o(`h-3 w-72 max-w-full`,ct)})]}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-start justify-between gap-3`,children:[n,(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Q.jsx)(`div`,{className:o(`h-9 w-20 rounded-lg`,ct)}),(0,Q.jsx)(`div`,{className:o(`h-9 w-20 rounded-lg`,ct)})]})]})]}),e[2]=r):r=e[2];let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:[r,(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,Q.jsx)(`div`,{className:o(`h-8 w-20 rounded-md`,ct)}),(0,Q.jsx)(`div`,{className:o(`h-8 w-24 rounded-md`,ct)}),(0,Q.jsx)(`div`,{className:o(`h-8 w-28 rounded-md`,ct)})]}),(0,Q.jsx)(`div`,{className:o(`mt-3 h-20 rounded-xl`,ct)})]}),e[3]=i):i=e[3],i}function ut(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function dt(e,t){return t.connectorCapabilityLabels[e]??e}function ft(e,t){if(e.runtime.type===`mcp`)return ut(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.type===`composio`?e.runtime.toolkit:e.runtime.type===`channel`?e.runtime.channelId:e.runtime.type===`nativeTool`?e.runtime.toolsetId:e.runtime.sourceKind;return ut(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n??e.runtime.type})}function pt(e,t){return e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function mt(e){return(e.setup.secrets??[]).filter(e=>e.required).length+(e.setup.config??[]).filter(e=>e.required).length}function ht(e){let t=(0,Z.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,Q.jsx)(`div`,{className:`border-b border-edge px-3 py-2 text-xs font-semibold text-fg`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,16).map(gt),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>16?(0,Q.jsxs)(`div`,{className:`px-3 py-2 text-xs text-fg-subtle`,children:[`+`,r.length-16]}):null,t[4]=r.length,t[5]=o);let s;t[6]!==a||t[7]!==o?(s=(0,Q.jsxs)(`div`,{className:`max-h-48 overflow-y-auto`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==i||t[10]!==s?(c=(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base`,children:[i,s]}),t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function gt(e){return(0,Q.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,Q.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,Q.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function _t({connector:e,installed:t,onClose:n,onInstall:r,t:i}){let[a,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(null),[u,d]=(0,X.useState)(null),f=mt(e),p=e.capabilities.slice(0,8),m=Math.max(0,e.capabilities.length-p.length),h=[...(e.setup.secrets??[]).map(e=>({key:`secret:${e.key}`,label:e.label,description:e.description,required:e.required,kind:i.connectorSetupSecret})),...(e.setup.config??[]).map(e=>({key:`config:${e.key}`,label:e.label,description:e.description,required:!!e.required,kind:i.connectorSetupConfig}))],g=async()=>{s(!0),d(null);try{l(await et(e))}catch(e){l(null),d(e instanceof Error?e.message:String(e))}finally{s(!1)}};return(0,Q.jsx)(ee,{open:!0,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(E,{children:[(0,Q.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(I,{className:o(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,52rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float outline-none dark:border-edge`),children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Q.jsx)(Xe,{connector:e,size:`lg`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[t?(0,Q.jsx)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,Q.jsx)(W,{className:`size-3`,"aria-hidden":!0}),i.connectedBadge]})}):null,(0,Q.jsx)(pe,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,Q.jsx)(te,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:e.description})]})]}),(0,Q.jsx)(C,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:o(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,N.focusRingPanel),"aria-label":i.modalClose,children:[(0,Q.jsx)(k,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,Q.jsx)(y,{className:`size-3.5`,"aria-hidden":!0}),i.detailTools]}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:c?ut(i.connectorPreviewToolsCount,{count:c.toolCount}):i.connectorPreviewUnknown})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,Q.jsx)(B,{className:`size-3.5`,"aria-hidden":!0}),i.detailPermissions]}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:pt(e,i)})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,Q.jsx)(z,{className:`size-3.5`,"aria-hidden":!0}),i.connectorRequiredInputs]}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:ut(i.connectorRequiredInputsCount,{count:f})})]})]}),(0,Q.jsxs)(`div`,{className:`mt-5 grid gap-5 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.connectorCapabilitiesTitle}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[p.map(e=>(0,Q.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-muted`,children:dt(e,i)},e)),m>0?(0,Q.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-subtle`,children:[`+`,m]}):null]})]}),u?(0,Q.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:u}):null,c?(0,Q.jsxs)(`section`,{children:[(0,Q.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.connectorPreviewTitle}),(0,Q.jsx)(`span`,{className:o(`rounded-full px-2 py-0.5 text-xs font-medium`,c.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:c.ok?i.healthStatusHealthy:i.healthStatusLabels[c.status]??c.status})]}),(0,Q.jsxs)(`div`,{className:`mb-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:c.toolCount}),(0,Q.jsx)(`div`,{className:`text-fg-muted`,children:i.toolsMetric})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:c.resourceCount}),(0,Q.jsx)(`div`,{className:`text-fg-muted`,children:i.resourcesMetric})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:c.promptCount}),(0,Q.jsx)(`div`,{className:`text-fg-muted`,children:i.promptsMetric})]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(ht,{title:i.detailTools,items:c.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,Q.jsx)(ht,{title:i.detailResources,items:c.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,Q.jsx)(ht,{title:i.detailPrompts,items:c.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??ut(i.promptArgumentCount,{count:e.argumentCount})}))})]}),c.error?(0,Q.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:c.error}):null,c.action?(0,Q.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-subtle`,children:c.action}):null]}):null]}),(0,Q.jsxs)(`aside`,{className:`space-y-3`,children:[(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(B,{className:`size-4 text-accent`,"aria-hidden":!0}),i.detailPermissions]}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-medium text-fg`,children:pt(e,i)})]}),(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(z,{className:`size-4 text-accent`,"aria-hidden":!0}),i.connectorSetupTitle]}),h.length>0?(0,Q.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-lg border border-edge`,children:h.map(e=>(0,Q.jsxs)(`div`,{className:`bg-surface-panel px-3 py-2.5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e.kind}),e.required?(0,Q.jsx)(`span`,{className:`rounded-md bg-amber-500/10 px-1.5 py-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-300`,children:i.connectorSetupRequired}):null]}),e.description?(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.key))}):(0,Q.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:i.connectorSetupNone})]}),(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(ae,{className:`size-4 text-accent`,"aria-hidden":!0}),i.connectorRuntimeTitle]}),(0,Q.jsx)(`p`,{className:`mt-2 break-words text-xs leading-5 text-fg-muted`,children:ft(e,i)})]})]})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,Q.jsx)(C,{asChild:!0,children:(0,Q.jsx)(U,{variant:`secondary`,children:i.modalClose})}),(0,Q.jsxs)(U,{variant:`secondary`,disabled:a,onClick:()=>void g(),children:[a?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):(0,Q.jsx)(y,{className:`size-4`}),i.connectorPreviewButton]}),t?(0,Q.jsxs)(U,{variant:`secondary`,disabled:!0,children:[(0,Q.jsx)(O,{className:`size-4`}),i.connectedBadge]}):(0,Q.jsxs)(U,{variant:`primary`,onClick:()=>{r(e),n()},children:[(0,Q.jsx)(P,{className:`size-4`}),i.connect]})]})]})]})})}var vt=o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,m);function yt(e){let t=(0,Z.c)(58),{open:n,sessionIdleTtlMinutes:r,saving:i,onChange:a,onSave:s,onClose:c,t:l,mcp:u}=e,d;t[0]===c?d=t[1]:(d=e=>{e||c()},t[0]=c,t[1]=d);let f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Q.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[2]=f):f=t[2];let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=o(`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-panel shadow-float dark:border-edge`),t[3]=p):p=t[3];let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,Q.jsx)(D,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})}),t[4]=m):m=t[4];let h;t[5]===l.runtimeSettingsTitle?h=t[6]:(h=(0,Q.jsx)(pe,{className:`text-base font-semibold text-fg`,children:l.runtimeSettingsTitle}),t[5]=l.runtimeSettingsTitle,t[6]=h);let g;t[7]===l.runtimeSettingsHint?g=t[8]:(g=(0,Q.jsx)(te,{className:`mt-1 text-sm text-fg-muted`,children:l.runtimeSettingsHint}),t[7]=l.runtimeSettingsHint,t[8]=g);let _;t[9]!==h||t[10]!==g?(_=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[m,(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[h,g]})]}),t[9]=h,t[10]=g,t[11]=_):_=t[11];let v;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(v=o(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,N.focusRingPanel),t[12]=v):v=t[12];let y;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(k,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=y):y=t[13];let b;t[14]===l.modalClose?b=t[15]:(b=(0,Q.jsx)(C,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:v,"aria-label":l.modalClose,children:y})}),t[14]=l.modalClose,t[15]=b);let S;t[16]!==b||t[17]!==_?(S=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[_,b]}),t[16]=b,t[17]=_,t[18]=S):S=t[18];let w;t[19]===u.idleTtlLabel?w=t[20]:(w=(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:u.idleTtlLabel}),t[19]=u.idleTtlLabel,t[20]=w);let T;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(T=o(vt,`w-40 flex-none`),t[21]=T):T=t[21];let O=r??``,A;t[22]===a?A=t[23]:(A=e=>{let t=e.currentTarget.value.trim();a(t===``?void 0:Number.parseInt(t,10))},t[22]=a,t[23]=A);let j;t[24]!==u.idleTtlPlaceholder||t[25]!==O||t[26]!==A?(j=(0,Q.jsx)(`input`,{type:`number`,min:0,className:T,value:O,placeholder:u.idleTtlPlaceholder,onChange:A}),t[24]=u.idleTtlPlaceholder,t[25]=O,t[26]=A,t[27]=j):j=t[27];let M;t[28]===u.idleTtlHint?M=t[29]:(M=(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:u.idleTtlHint}),t[28]=u.idleTtlHint,t[29]=M);let P;t[30]!==w||t[31]!==j||t[32]!==M?(P=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,Q.jsxs)(`label`,{className:`flex max-w-xl flex-col gap-1.5`,children:[w,j,M]})}),t[30]=w,t[31]=j,t[32]=M,t[33]=P):P=t[33];let F;t[34]!==c||t[35]!==i||t[36]!==l.modalCancel?(F=(0,Q.jsx)(U,{type:`button`,variant:`secondary`,disabled:i,onClick:c,children:l.modalCancel}),t[34]=c,t[35]=i,t[36]=l.modalCancel,t[37]=F):F=t[37];let L;t[38]===s?L=t[39]:(L=()=>void s(),t[38]=s,t[39]=L);let R;t[40]===i?R=t[41]:(R=i?(0,Q.jsx)(G,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[40]=i,t[41]=R);let z;t[42]!==u.save||t[43]!==i||t[44]!==L||t[45]!==R?(z=(0,Q.jsxs)(U,{type:`button`,variant:`primary`,disabled:i,onClick:L,children:[R,u.save]}),t[42]=u.save,t[43]=i,t[44]=L,t[45]=R,t[46]=z):z=t[46];let B;t[47]!==F||t[48]!==z?(B=(0,Q.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[F,z]}),t[47]=F,t[48]=z,t[49]=B):B=t[49];let V;t[50]!==S||t[51]!==P||t[52]!==B?(V=(0,Q.jsxs)(E,{children:[f,(0,Q.jsxs)(I,{className:p,children:[S,P,B]})]}),t[50]=S,t[51]=P,t[52]=B,t[53]=V):V=t[53];let H;return t[54]!==n||t[55]!==d||t[56]!==V?(H=(0,Q.jsx)(ee,{open:n,onOpenChange:d,children:V}),t[54]=n,t[55]=d,t[56]=V,t[57]=H):H=t[57],H}var bt=(0,X.memo)(function(e){let t=(0,Z.c)(12),{value:n,onChange:r,placeholder:i,className:a}=e,s;t[0]===a?s=t[1]:(s=o(`relative flex 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 shadow-surface`,a),t[0]=a,t[1]=s);let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(_e,{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]=c):c=t[2];let l;t[3]===r?l=t[4]:(l=e=>r(e.currentTarget.value),t[3]=r,t[4]=l);let u;t[5]!==i||t[6]!==l||t[7]!==n?(u=(0,Q.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:n,onChange:l,placeholder:i,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`}),t[5]=i,t[6]=l,t[7]=n,t[8]=u):u=t[8];let d;return t[9]!==s||t[10]!==u?(d=(0,Q.jsxs)(`label`,{className:s,children:[c,u]}),t[9]=s,t[10]=u,t[11]=d):d=t[11],d}),xt=(0,X.memo)(function(e){let t=(0,Z.c)(30),{onBrowseCatalog:n,onAddCustomServer:r,onOpenRuntimeSettings:i,addLabel:a,browseLabel:s,customLabel:c,settingsLabel:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(se,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=u):u=t[0];let d;t[1]===l?d=t[2]:(d=(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:l}),t[1]=l,t[2]=d);let f;t[3]!==i||t[4]!==l||t[5]!==d?(f=(0,Q.jsxs)(U,{type:`button`,variant:`secondary`,className:`shrink-0 gap-2`,"aria-label":l,title:l,onClick:i,children:[u,d]}),t[3]=i,t[4]=l,t[5]=d,t[6]=f):f=t[6];let p;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Q.jsx)(de,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[7]=p):p=t[7];let m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(J,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[8]=m):m=t[8];let h;t[9]===a?h=t[10]:(h=(0,Q.jsx)(v,{asChild:!0,children:(0,Q.jsxs)(U,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,children:[p,a,m]})}),t[9]=a,t[10]=h);let _;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(_=o(`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,N.transition),t[11]=_):_=t[11];let b;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Q.jsx)(he,{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]!==n?(x=(0,Q.jsxs)(j,{className:_,onSelect:n,children:[b,s]}),t[13]=s,t[14]=n,t[15]=x):x=t[15];let S;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(S=o(`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,N.transition),t[16]=S):S=t[16];let C;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Q.jsx)(y,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[17]=C):C=t[17];let w;t[18]!==c||t[19]!==r?(w=(0,Q.jsxs)(j,{className:S,onSelect:r,children:[C,c]}),t[18]=c,t[19]=r,t[20]=w):w=t[20];let T;t[21]!==w||t[22]!==x?(T=(0,Q.jsx)(g,{children:(0,Q.jsxs)(q,{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:[x,w]})}),t[21]=w,t[22]=x,t[23]=T):T=t[23];let E;t[24]!==T||t[25]!==h?(E=(0,Q.jsxs)(K,{children:[h,T]}),t[24]=T,t[25]=h,t[26]=E):E=t[26];let D;return t[27]!==E||t[28]!==f?(D=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[f,E]}),t[27]=E,t[28]=f,t[29]=D):D=t[29],D}),St=/^([^:=]+)[:=](.*)$/;function Ct(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=St.exec(t);r&&n.push({key:r[1].trim(),value:r[2].trim()})}return n.length>0?n:null}function wt(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 Tt(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 Et(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 Dt(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)||Et(t)&&(r[e]=t);return r}function Ot(e){let t=e.trim();if(t)return t.split(/\s+/).filter(Boolean)}function kt(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 At(e){if(e.transport===`stdio`){let t={command:e.command.trim()},n=Ot(e.argsText);return n?.length&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envJson.trim()&&(t.env=kt(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=wt(e.headers);return n&&(t.headers=n),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),e.requestTimeoutMs!=null&&Number.isFinite(e.requestTimeoutMs)&&(t.requestTimeoutMs=e.requestTimeoutMs),t}function jt(e,t){let n=typeof t.url==`string`&&t.url.trim().length>0,r=typeof t.transport==`string`?t.transport.trim().toLowerCase():``,i=n?r===`sse`?`sse`:`streamable-http`:`stdio`,a=t.headers&&typeof t.headers==`object`&&!Array.isArray(t.headers)?t.headers:void 0;return{clientKey:e,id:e,transport:i,command:typeof t.command==`string`?t.command:``,argsText:Array.isArray(t.args)?t.args.map(String).join(` `):``,envJson:t.env&&typeof t.env==`object`?JSON.stringify(t.env,null,2):``,cwd:typeof t.cwd==`string`?t.cwd:typeof t.workingDirectory==`string`?t.workingDirectory:``,url:typeof t.url==`string`?t.url:``,headers:Tt(a),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 Mt(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`stdio`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[{key:`Authorization`,value:``}],connectionTimeoutMs:void 0,requestTimeoutMs:void 0}}function Nt(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)||Et(t)?[]:[jt(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 Pt(e){return At(e)}async function Ft(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]=At(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 f(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({mcp:r})}),A()}function It(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n==`string`){let e=n.trim();e&&t.push({name:e});continue}if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.name!=`string`)continue;let r=e.name.trim();if(!r)continue;let i=typeof e.shortName==`string`&&e.shortName.trim()?e.shortName.trim():void 0,a=typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0;t.push({name:r,shortName:i,description:a})}return t}function Lt(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 Rt(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 zt(e,t){let n=await f(d(`/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=It(n.payload.tools),i=Lt(n.payload.resources),a=Rt(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 Bt(e){return e.connectionTimeoutMs==null||!Number.isFinite(e.connectionTimeoutMs)?``:String(Math.round(e.connectionTimeoutMs/1e3))}function Vt(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 Ht(e){return e.requestTimeoutMs==null||!Number.isFinite(e.requestTimeoutMs)?``:String(Math.round(e.requestTimeoutMs/1e3))}function Ut(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 Wt(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 $(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,n),e)}function Gt({row:e,t,cs:n,onEdit:r,onRemove:i}){let[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(null),[d,f]=(0,X.useState)(null),p=Wt(e),m=(0,X.useCallback)(async()=>{o(!0),f(null);try{let t=await zt(e.id.trim());u({toolCount:t.toolCount,resourceCount:t.resourceCount,promptCount:t.promptCount})}catch(e){f(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.id]),h=(0,X.useCallback)(async()=>{c(!0),f(null);try{await i()}catch(e){f(e instanceof Error?e.message:String(e)),c(!1)}},[i]);return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-[10.5rem] cursor-pointer flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`,onClick:r,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.id.trim()||t.cardUntitled}),(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:n.customBadge}),(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.transportLabels[e.transport]})]}),p?(0,Q.jsx)(`p`,{className:`mt-3 line-clamp-2 break-all font-mono text-xs leading-5 text-fg-subtle`,title:p,children:p}):null,d?(0,Q.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:d}):null,l?(0,Q.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:$(n.customCapabilitySummary,{tools:String(l.toolCount),resources:String(l.resourceCount),prompts:String(l.promptCount)})}):null]}),(0,Q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.connectorDetails}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(U,{variant:`secondary`,disabled:a,onClick:()=>void m(),children:[a?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):(0,Q.jsx)(O,{className:`size-4`}),t.testConnection]}),(0,Q.jsxs)(U,{variant:`ghost`,disabled:s,onClick:()=>void h(),children:[s?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):(0,Q.jsx)(T,{className:`size-4`}),t.removeServer]})]})]})]})}function Kt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function qt(e,t,n){let r=t.trim().toLowerCase();if(!r)return!0;let i=e.shortName||Kt(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
2
+ `).toLowerCase().includes(r)}function Jt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Yt(e){let t=(0,Z.c)(29),{tools:n,stripPrefix:r,searchPlaceholder:i,searchEmptyLabel:a}=e,[s,c]=(0,X.useState)(``),l;if(t[0]!==s||t[1]!==r||t[2]!==n){let e;t[4]!==s||t[5]!==r?(e=e=>qt(e,s,r),t[4]=s,t[5]=r,t[6]=e):e=t[6],l=n.filter(e),t[0]=s,t[1]=r,t[2]=n,t[3]=l}else l=t[3];let u=l,d;t[7]===s?d=t[8]:(d=s.trim(),t[7]=s,t[8]=d);let f=d.length>0,p;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Q.jsx)(_e,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=p):p=t[9];let h,g;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(h=o(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg`,`placeholder:text-fg-subtle`,m),g=e=>c(e.target.value),t[10]=h,t[11]=g):(h=t[10],g=t[11]);let _;t[12]!==s||t[13]!==i?(_=(0,Q.jsxs)(`div`,{className:`relative`,children:[p,(0,Q.jsx)(`input`,{type:`search`,value:s,placeholder:i,"aria-label":i,className:h,onChange:g})]}),t[12]=s,t[13]=i,t[14]=_):_=t[14];let v;t[15]!==u.length||t[16]!==f||t[17]!==n.length?(v=f?(0,Q.jsxs)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:[u.length,` / `,n.length]}):null,t[15]=u.length,t[16]=f,t[17]=n.length,t[18]=v):v=t[18];let y;t[19]!==_||t[20]!==v?(y=(0,Q.jsxs)(`div`,{className:`border-b border-edge px-5 py-3`,children:[_,v]}),t[19]=_,t[20]=v,t[21]=y):y=t[21];let b;t[22]!==u||t[23]!==a||t[24]!==r?(b=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:u.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a}):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>{let n=e.shortName||Jt(e.name,r)||e.name||`?`,i=e.name||`tool-${t}`;return(0,Q.jsxs)(`li`,{className:`min-w-0 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[(0,Q.jsx)(`div`,{className:`truncate font-mono text-sm font-medium text-fg`,title:e.name===n?n:e.name,children:n}),e.description?(0,Q.jsx)(`p`,{className:`mt-1 truncate text-xs leading-relaxed text-fg-muted`,title:e.description,children:e.description}):null]},i)})})}),t[22]=u,t[23]=a,t[24]=r,t[25]=b):b=t[25];let x;return t[26]!==y||t[27]!==b?(x=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[y,b]}),t[26]=y,t[27]=b,t[28]=x):x=t[28],x}function Xt(e){let t=(0,Z.c)(38),{open:n,onOpenChange:r,serverId:i,title:a,subtitle:s,searchPlaceholder:c,searchEmptyLabel:l,emptyLabel:u,closeLabel:d,tools:f,stripPrefix:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(x,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,re)}),t[0]=m):m=t[0];let h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=o(`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`,ge,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`),t[1]=h):h=t[1];let g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Q.jsx)(y,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[2]=g):g=t[2];let _;t[3]===a?_=t[4]:(_=(0,Q.jsxs)(pe,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[g,a]}),t[3]=a,t[4]=_);let v;t[5]!==i||t[6]!==s||t[7]!==f.length?(v=s.replace(`{{serverId}}`,i).replace(`{{count}}`,String(f.length)),t[5]=i,t[6]=s,t[7]=f.length,t[8]=v):v=t[8];let b;t[9]===v?b=t[10]:(b=(0,Q.jsx)(te,{className:`mt-1 text-sm text-fg-muted`,children:v}),t[9]=v,t[10]=b);let S;t[11]!==_||t[12]!==b?(S=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[_,b]}),t[11]=_,t[12]=b,t[13]=S):S=t[13];let w;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Q.jsx)(k,{className:`size-4`,"aria-hidden":!0}),t[14]=w):w=t[14];let T;t[15]===d?T=t[16]:(T=(0,Q.jsx)(C,{asChild:!0,children:(0,Q.jsx)(U,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":d,children:w})}),t[15]=d,t[16]=T);let D;t[17]!==S||t[18]!==T?(D=(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[S,T]}),t[17]=S,t[18]=T,t[19]=D):D=t[19];let O;t[20]!==u||t[21]!==n||t[22]!==l||t[23]!==c||t[24]!==i||t[25]!==p||t[26]!==f?(O=f.length>0?(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,Q.jsx)(Yt,{tools:f,stripPrefix:p,searchPlaceholder:c,searchEmptyLabel:l},`${i}-${n?`open`:`closed`}`)}):(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u})}),t[20]=u,t[21]=n,t[22]=l,t[23]=c,t[24]=i,t[25]=p,t[26]=f,t[27]=O):O=t[27];let A;t[28]===d?A=t[29]:(A=(0,Q.jsx)(`div`,{className:`flex justify-end border-t border-edge px-5 py-3`,children:(0,Q.jsx)(C,{asChild:!0,children:(0,Q.jsx)(U,{type:`button`,variant:`secondary`,children:d})})}),t[28]=d,t[29]=A);let j;t[30]!==D||t[31]!==O||t[32]!==A?(j=(0,Q.jsxs)(E,{children:[m,(0,Q.jsxs)(I,{className:h,children:[D,O,A]})]}),t[30]=D,t[31]=O,t[32]=A,t[33]=j):j=t[33];let M;return t[34]!==r||t[35]!==n||t[36]!==j?(M=(0,Q.jsx)(ee,{open:n,onOpenChange:r,children:j}),t[34]=r,t[35]=n,t[36]=j,t[37]=M):M=t[37],M}var Zt=o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,m);function Qt(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function $t(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function en(e,t){return e.errorCode===`missing_credential`?t.composioHealthMissingCredential:e.errorCode===`unauthorized`?t.composioHealthUnauthorized:e.errorCode===`forbidden`?t.composioHealthForbidden:e.errorCode===`network`?t.composioHealthNetwork:e.errorCode===`timeout`?t.composioHealthTimeout:t.composioHealthDegraded}function tn({instance:e,t,onChanged:n}){let r=Qt(e),[i,s]=(0,X.useState)([]),[c,l]=(0,X.useState)([]),[u,d]=(0,X.useState)([]),[f,p]=(0,X.useState)([]),[m,h]=(0,X.useState)(null),[g,_]=(0,X.useState)([]),[v,y]=(0,X.useState)(null),[b,x]=(0,X.useState)([]),[S,C]=(0,X.useState)({}),[E,D]=(0,X.useState)(`read`),[O,A]=(0,X.useState)(!1),[j,M]=(0,X.useState)(null),N=(0,X.useCallback)(async()=>{if(!(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)){A(!0),M(null);try{let[t,n,i,a,o,c,u,f]=await Promise.all([Re().catch(()=>[]),Me(r).catch(()=>[]),Qe(20).catch(()=>[]),Ie(r).catch(()=>`read`),tt().catch(()=>[]),Ze(r).catch(()=>null),Ue(r).catch(()=>null),Pe().catch(()=>[])]);s(t.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),l(n),d(i.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())),D(a),p(o.filter(t=>t.connectorId===e.connectorId)),h(c?.policy??null),_(c?.agents??[]),y(u),x(f);let m=t.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase()),g=await Promise.all(m.map(async e=>[e.id,await qe(e.id)]).map(e=>e.catch(()=>null)));C(Object.fromEntries(g.filter(e=>e!==null)))}catch(e){M(e instanceof Error?e.message:String(e))}finally{A(!1)}}},[e.connectorId,e.materialized,r]);(0,X.useEffect)(()=>{N()},[N]);let P=(0,X.useCallback)(async()=>{if(r){A(!0),M(null);try{let t=await He(e.connectorId);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if(w()){let e=await window.electronAPI?.shell?.openExternalUrl(t.authorizationUrl);if(!e?.ok)throw Error(e?.error??`Could not open the system browser.`)}else window.open(t.authorizationUrl,`_blank`,`noopener,noreferrer`);await Oe((await Te(r,t.connectionId)).id),await n?.(),await N()}catch(e){M(e instanceof Error?e.message:String(e))}finally{A(!1)}}},[e.connectorId,N,n,r]),F=(0,X.useCallback)(async e=>{if(r){D(e);try{await Ce(r,e),await N()}catch(e){M(e instanceof Error?e.message:String(e))}}},[N,r]),I=(0,X.useCallback)(async(e,t)=>{A(!0),M(null);try{await $e(e,t),await N()}catch(e){M(e instanceof Error?e.message:String(e))}finally{A(!1)}},[N]),L=(0,X.useCallback)(async e=>{if(r){M(null);try{h(await De(r,e))}catch(e){M(e instanceof Error?e.message:String(e))}}},[e.connectorId,r]),ee=(0,X.useCallback)(e=>{m&&L({allowedAgentIds:m.allowedAgentIds.includes(e)?m.allowedAgentIds.filter(t=>t!==e):[...m.allowedAgentIds,e]})},[L,m]),R=(0,X.useCallback)(async e=>{A(!0),M(null);try{await e(),await N()}catch(e){M(e instanceof Error?e.message:String(e))}finally{A(!1)}},[N]);return r?e.materialized.type===`composio`&&e.materialized.role===`credential`?(0,Q.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:t.composioApiKeyStored}):(0,Q.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`font-medium text-fg`,children:$(t.composioToolkitTitle,{toolkit:r})}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioScopeHint})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsxs)(U,{variant:`secondary`,disabled:O,onClick:()=>void P(),children:[O?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):(0,Q.jsx)(B,{className:`size-4`}),t.connectOAuth]}),(0,Q.jsx)(U,{variant:`ghost`,disabled:O,onClick:()=>void N(),children:t.refresh})]})]}),j?(0,Q.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:j}):null,v?(0,Q.jsxs)(`div`,{className:o(`mt-3 flex flex-wrap items-center justify-between gap-2 rounded-lg border px-3 py-2 text-xs`,v.status===`connected`?`border-emerald-500/30 bg-emerald-500/5 text-emerald-700`:`border-amber-500/30 bg-amber-500/5 text-amber-700`),children:[(0,Q.jsx)(`span`,{children:v.status===`connected`?$(t.composioHealthConnected,{count:String(v.activeConnections)}):v.status===`reauthorization_required`?t.composioHealthReconnect:v.status===`degraded`?en(v,t):t.composioHealthDisconnected}),v.recovery===`none`?null:(0,Q.jsx)(U,{variant:`ghost`,disabled:O,onClick:()=>void(v.recovery===`retry`?N():P()),children:v.recovery===`retry`?t.composioRetry:t.connectOAuth}),v.status===`degraded`&&v.message?(0,Q.jsx)(`p`,{className:`basis-full break-words text-[11px] opacity-80`,children:v.message}):null]}):null,m?(0,Q.jsxs)(`div`,{className:`mt-4 grid gap-3 rounded-lg border border-edge bg-surface-panel p-3 md:grid-cols-3`,children:[(0,Q.jsxs)(`label`,{className:`text-xs font-medium text-fg-subtle`,children:[t.composioAccessTitle,(0,Q.jsxs)(le,{className:o(Zt,`mt-1 h-9 py-1`),value:E,onChange:e=>void F(e.currentTarget.value),children:[(0,Q.jsx)(V,{value:`read`,children:t.composioAccessReadOnly}),(0,Q.jsx)(V,{value:`write`,children:t.composioAccessReadWrite}),E===`admin`?(0,Q.jsx)(V,{value:`admin`,children:t.composioAccessAdminCurrent}):null]}),(0,Q.jsx)(`span`,{className:`mt-1 block font-normal leading-4 text-fg-muted`,children:E===`read`?t.composioAccessReadHint:E===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,Q.jsxs)(`label`,{className:`text-xs font-medium text-fg-subtle`,children:[t.composioConfirmationPolicy,(0,Q.jsxs)(le,{className:o(Zt,`mt-1 h-9 py-1`),value:m.confirmationPolicy,onChange:e=>void L({confirmationPolicy:e.currentTarget.value}),children:[(0,Q.jsx)(V,{value:`writes`,children:t.composioConfirmWrites}),(0,Q.jsx)(V,{value:`always`,children:t.composioConfirmAlways}),m.confirmationPolicy===`never`?(0,Q.jsx)(V,{value:`never`,children:t.composioConfirmNever}):null]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:t.composioAllowedAgents}),(0,Q.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:m.allowedAgentIds.length?t.composioAllowedAgentsSelected:t.composioAllowedAgentsAll}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:g.map(e=>(0,Q.jsx)(`button`,{type:`button`,className:o(`rounded-full border px-2.5 py-1 text-xs transition-colors`,m.allowedAgentIds.includes(e.id)?`border-accent bg-accent/10 text-accent`:`border-edge text-fg-muted hover:text-fg`),onClick:()=>ee(e.id),children:e.name},e.id))})]})]}):null,f.length?(0,Q.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioPendingApprovals}),f.map(e=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-amber-500/30 bg-amber-500/5 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`truncate font-mono text-xs font-medium text-fg`,children:e.actionId}),(0,Q.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs text-fg-subtle`,children:JSON.stringify(e.argumentsPreview)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:$(t.composioApprovalExpires,{time:new Date(e.expiresAt).toLocaleTimeString()})})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Q.jsxs)(U,{variant:`secondary`,disabled:O,onClick:()=>void I(e.id,`denied`),children:[(0,Q.jsx)(k,{className:`size-4`}),t.composioDeny]}),(0,Q.jsxs)(U,{disabled:O,onClick:()=>void I(e.id,`approved`),children:[(0,Q.jsx)(a,{className:`size-4`}),t.approve]})]})]},e.id))]}):null,(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioConnections}),i.length?i.map(e=>(0,Q.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-edge bg-surface-panel p-2`,children:[(()=>{let n=b.find(t=>t.connectionId===e.id);return n?(0,Q.jsx)(`p`,{className:o(`text-xs`,n.status===`failed`?`text-red-600`:`text-fg-subtle`),children:$(t.connectorLearningStatus,{status:n.status,count:String(n.candidatesCreated)})}):null})(),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.accountEmail??e.username??e.workspace??e.providerConnectionId}),(0,Q.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[e.status,e.isDefault?` · ${t.composioDefaultAccount}`:``]})]}),S[e.id]?(0,Q.jsxs)(`div`,{className:`grid gap-2 rounded-lg border border-edge bg-surface-base p-2 sm:grid-cols-3`,children:[(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-subtle`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:S[e.id].scanEnabled,disabled:O,onChange:t=>void R(()=>we(e.id,{scanEnabled:t.currentTarget.checked}))}),t.connectorScheduledScan]}),(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-subtle`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:S[e.id].proactiveEnabled,disabled:O||!S[e.id].scanEnabled,onChange:t=>void R(()=>we(e.id,{proactiveEnabled:t.currentTarget.checked}))}),t.connectorProactiveUse]}),(0,Q.jsxs)(`label`,{className:`text-xs text-fg-subtle`,children:[t.connectorScanInterval,(0,Q.jsxs)(le,{className:o(Zt,`mt-1 h-8 py-1 text-xs`),value:String(S[e.id].intervalMinutes??30),disabled:O||!S[e.id].scanEnabled,onChange:t=>void R(()=>we(e.id,{intervalMinutes:Number(t.currentTarget.value)})),children:[(0,Q.jsxs)(V,{value:`5`,children:[`5 `,t.connectorMinutes]}),(0,Q.jsxs)(V,{value:`15`,children:[`15 `,t.connectorMinutes]}),(0,Q.jsxs)(V,{value:`30`,children:[`30 `,t.connectorMinutes]}),(0,Q.jsxs)(V,{value:`60`,children:[`60 `,t.connectorMinutes]})]})]})]}):null,(0,Q.jsx)(`input`,{className:o(Zt,`h-8 py-1 text-xs`),defaultValue:e.alias??``,placeholder:t.composioAccountAlias,onBlur:t=>{t.currentTarget.value!==(e.alias??``)&&R(()=>Ee(e.id,{alias:t.currentTarget.value}))}}),(0,Q.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Q.jsx)(U,{variant:`ghost`,className:`size-8 p-0`,title:t.composioMakeDefault,disabled:O||e.isDefault,onClick:()=>void R(async()=>{await Ee(e.id,{isDefault:!0}),r&&await De(r,{selectedConnectionIds:[e.id]})}),children:(0,Q.jsx)(ce,{className:o(`size-4`,e.isDefault&&`fill-current`)})}),(0,Q.jsx)(U,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:O,onClick:()=>void R(()=>Ae(e.id)),children:(0,Q.jsx)(ve,{className:`size-4`})}),(0,Q.jsx)(U,{variant:`ghost`,className:`size-8 p-0`,title:t.composioRevoke,disabled:O,onClick:()=>{window.confirm(t.composioRevokeConfirm)&&R(()=>je(e.id))},children:(0,Q.jsx)(T,{className:`size-4 text-red-500`})})]}),e.status===`active`?(0,Q.jsx)(`div`,{children:(0,Q.jsxs)(U,{variant:`secondary`,className:`w-full`,disabled:O,onClick:()=>void R(async()=>{await Oe(e.id),await n?.()}),children:[O?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):(0,Q.jsx)(ve,{className:`size-4`}),t.composioSyncNow]})}):null]},e.id)):(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioConnectionsEmpty})]})}),(0,Q.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge bg-surface-panel p-3`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted`,children:t.composioAdvancedSettings}),(0,Q.jsxs)(`div`,{className:`mt-4 grid gap-4 lg:grid-cols-2`,children:[(0,Q.jsx)(`div`,{className:`space-y-3`,children:(0,Q.jsxs)(`label`,{className:`block text-xs text-fg-subtle`,children:[t.composioAdvancedScope,(0,Q.jsxs)(le,{className:o(Zt,`mt-1 h-9 py-1`),value:E,onChange:e=>void F(e.currentTarget.value),children:[(0,Q.jsx)(V,{value:`read`,children:t.composioScopeRead}),(0,Q.jsx)(V,{value:`write`,children:t.composioScopeWrite}),(0,Q.jsx)(V,{value:`admin`,children:t.composioScopeAdmin})]})]})}),(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),c.length?c.slice(0,8).map(e=>(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-2`,children:[(0,Q.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,Q.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[$t(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),u.length?u.slice(0,5).map(e=>(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-2`,children:[(0,Q.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})]})]})]})]})]}):null}var nn=o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,m);function rn(e,t){return e?t.healthStatusLabels[e]??e:t.healthNotTested}function an(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 on(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 sn(e){let t=(0,Z.c)(12),{title:n,description:r,meta:i}=e,a;t[0]===r?a=t[1]:(a=r?(0,Q.jsx)(S,{delayDuration:300,skipDelayDuration:100,children:(0,Q.jsxs)(F,{children:[(0,Q.jsx)(R,{asChild:!0,children:(0,Q.jsx)(`p`,{tabIndex:0,title:r,className:o(`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,Q.jsx)(L,{children:(0,Q.jsx)(h,{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,Q.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:r})})})]})}):null,t[0]=r,t[1]=a);let s=a,c;t[2]===n?c=t[3]:(c=(0,Q.jsx)(`p`,{className:`min-w-0 break-all font-mono text-xs font-medium leading-5 text-fg`,children:n}),t[2]=n,t[3]=c);let l;t[4]===i?l=t[5]:(l=i?(0,Q.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]=l);let u;t[6]!==c||t[7]!==l?(u=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;return t[9]!==s||t[10]!==u?(d=(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[u,s]}),t[9]=s,t[10]=u,t[11]=d):d=t[11],d}function cn({instance:e,definition:t,onClose:n,onChanged:r,t:i,mcp:a}){let[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(null),[_,v]=(0,X.useState)(null),[b,S]=(0,X.useState)(e.materialized.type===`mcp`?`health`:`permissions`),[w,D]=(0,X.useState)(!1),[A,j]=(0,X.useState)(()=>an(t,e)),[M,P]=(0,X.useState)(null),F=t?.setup.config??[],L=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&F.length>0&&(t?.setup.secrets??[]).length===0,R=_?_.toolCount:e.usage.lastToolCount,V=(0,X.useMemo)(()=>{let t=e.materialized.type===`mcp`?[[`health`,ie,i.detailHealth],[`tools`,y,`${i.detailTools} ${_?_.toolCount:e.usage.lastToolCount??``}`],[`resources`,z,`${i.detailResources} ${_?_.resourceCount:e.usage.lastResourceCount??``}`],[`prompts`,ye,`${i.detailPrompts} ${_?_.promptCount:e.usage.lastPromptCount??``}`],[`permissions`,B,i.detailPermissions]]:[[`permissions`,B,i.detailPermissions]];return L?[...t,[`config`,z,i.connectorConfigLabel]]:t},[_,e.materialized.type,e.usage.lastPromptCount,e.usage.lastResourceCount,e.usage.lastToolCount,L,i]),H=(0,X.useCallback)(async()=>{c(!0),P(null);try{let t=await Ve(e.instanceId);v(t),t.toolCount>0&&S(`tools`),r()}catch(e){P(e instanceof Error?e.message:String(e))}finally{c(!1)}},[e.instanceId,r]),re=(0,X.useCallback)(async()=>{u(!0),P(null);try{await Se(e.instanceId),await r(),n()}catch(e){P(e instanceof Error?e.message:String(e)),u(!1)}},[e.instanceId,r,n]),ae=(0,X.useCallback)(async()=>{if(!(!t||!L)){f(!0),P(null);try{let n={};for(let e of t.setup.config??[]){let t=on(e.type,A[e.key]??``);t!==void 0&&(n[e.key]=t)}await ke(e.instanceId,{config:n}),await r(),S(`health`)}catch(e){P(e instanceof Error?e.message:String(e))}finally{f(!1)}}},[A,t,e.instanceId,r,L]),oe=(0,X.useCallback)(async()=>{m(!0),g(null),P(null);try{g((await Y(e.connectorId)).recordIds.length),await r()}catch(e){P(e instanceof Error?e.message:String(e))}finally{m(!1)}},[e.connectorId,r]);return(0,Q.jsxs)(ee,{open:!0,onOpenChange:e=>{e||n()},children:[(0,Q.jsxs)(E,{children:[(0,Q.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(I,{className:o(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,54rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float outline-none dark:border-edge`),children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Q.jsx)(Xe,{connector:t,size:`lg`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(pe,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,Q.jsx)(te,{className:`mt-1 text-sm text-fg-muted`,children:t?.description??(e.materialized.type===`mcp`?$(i.mcpServerRuntime,{serverId:e.materialized.serverId}):$(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,Q.jsx)(C,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:o(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,N.focusRingPanel),"aria-label":i.modalClose,children:[(0,Q.jsx)(k,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[M?(0,Q.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:M}):null,(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:V.map(([e,t,n])=>(0,Q.jsxs)(`button`,{type:`button`,className:o(`inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs`,b===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:text-fg`),onClick:()=>S(e),children:[(0,Q.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),n]},e))}),(0,Q.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[b===`health`?(0,Q.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,Q.jsxs)(`p`,{children:[i.statusLabel,` `,(0,Q.jsx)(`span`,{className:_?.ok?`font-medium text-emerald-700 dark:text-emerald-300`:`font-medium text-fg`,children:rn(_?.status??e.usage.lastHealthStatus,i)})]}),(0,Q.jsxs)(`p`,{children:[i.lastCheckLabel,` `,e.usage.lastHealthCheckAt?new Date(e.usage.lastHealthCheckAt).toLocaleString():i.never]}),_?.action?(0,Q.jsx)(`p`,{children:_.action}):null]}):null,b===`tools`?_?.tools.length?(0,Q.jsxs)(`div`,{className:`grid gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:$(i.toolsAvailable,{count:String(_.tools.length)})}),(0,Q.jsx)(U,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>D(!0),children:a.viewAllTools})]}),(0,Q.jsx)(`div`,{className:`grid gap-2`,children:_.tools.slice(0,8).map(e=>(0,Q.jsx)(sn,{title:e.shortName??e.name,description:e.description},e.name))})]}):(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-fg-muted`,children:R?$(i.toolsLastCheckSummary,{count:String(R)}):i.toolsRunTestHint}),(0,Q.jsxs)(U,{type:`button`,variant:`secondary`,disabled:s,onClick:()=>void H(),children:[s?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):(0,Q.jsx)(O,{className:`size-4`}),i.test]})]}):null,b===`resources`?_?.resources.length?(0,Q.jsx)(`div`,{className:`grid gap-2`,children:_.resources.slice(0,8).map(e=>(0,Q.jsx)(sn,{title:e.title??e.name,description:e.uri,meta:e.mimeType},e.uri))}):(0,Q.jsx)(`p`,{className:`text-fg-muted`,children:i.resourcesRunTestHint}):null,b===`prompts`?_?.prompts.length?(0,Q.jsx)(`div`,{className:`grid gap-2`,children:_.prompts.slice(0,8).map(e=>(0,Q.jsx)(sn,{title:e.title??e.name,description:e.description,meta:e.argumentCount?$(i.promptArgumentCount,{count:String(e.argumentCount)}):void 0},e.name))}):(0,Q.jsx)(`p`,{className:`text-fg-muted`,children:i.promptsRunTestHint}):null,b===`permissions`?(0,Q.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,Q.jsx)(`p`,{children:$(i.secretsConfigured,{count:String(Object.values(e.secretStatus).filter(Boolean).length)})}),(0,Q.jsx)(`p`,{children:e.materialized.type===`mcp`?$(i.runtimeServerLabel,{runtime:e.materialized.type.toUpperCase(),serverId:e.materialized.serverId}):$(i.runtimeLabel,{runtime:e.materialized.type.toUpperCase()})}),(0,Q.jsx)(`p`,{children:e.materialized.type===`mcp`?i.mcpPolicyHint:i.connectorPolicyHint})]}):null,b===`config`&&L?(0,Q.jsx)(`div`,{className:`grid gap-3`,children:F.map(e=>(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,Q.jsx)(`input`,{className:nn,value:A[e.key]??``,placeholder:e.placeholder,onChange:t=>j(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}),e.materialized.type===`composio`?(0,Q.jsx)(tn,{instance:e,t:i,onChanged:r}):null,e.materialized.type===`memorySource`?(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-between gap-3 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`font-medium text-fg`,children:i.connectedSourceSync}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t?.description}),h===null?null:(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:$(i.connectedSourceSynced,{count:String(h)})})]}),(0,Q.jsxs)(U,{disabled:p,onClick:()=>void oe(),children:[p?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):(0,Q.jsx)(z,{className:`size-4`}),i.composioSyncNow]})]}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,Q.jsx)(U,{variant:`secondary`,onClick:n,children:i.modalClose}),b===`config`&&L?(0,Q.jsxs)(U,{variant:`primary`,disabled:d,onClick:()=>void ae(),children:[d?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):(0,Q.jsx)(ne,{className:`size-4`}),i.modalSave]}):null,e.materialized.type===`mcp`?(0,Q.jsxs)(U,{variant:`secondary`,disabled:s,onClick:()=>void H(),children:[s?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):(0,Q.jsx)(O,{className:`size-4`}),i.test]}):null,(0,Q.jsxs)(U,{variant:`ghost`,disabled:l,onClick:()=>void re(),children:[l?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):(0,Q.jsx)(T,{className:`size-4`}),i.remove]})]})]})]}),e.materialized.type===`mcp`?(0,Q.jsx)(Xt,{open:w,onOpenChange:D,serverId:e.materialized.serverId,title:$(i.installedToolsDialogTitle,{name:e.displayName}),subtitle:i.installedToolsDialogSubtitle,searchPlaceholder:a.toolsDialogSearchPlaceholder,searchEmptyLabel:a.toolsDialogSearchEmpty,emptyLabel:i.toolsRunTestHint,closeLabel:a.toolsDialogClose,tools:_?.tools??[],stripPrefix:`${e.materialized.serverId}__`}):null]})}var ln=[`understand`,`act`,`reach`];function un(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 dn(e){return un(e)[0]??`act`}function fn(e,t){let n=t?dn(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 pn({instance:e,definition:t,highlighted:n=!1,onOpenDetails:r,onChanged:i,t:a}){let[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(null),p=(0,X.useCallback)(async()=>{c(!0),f(null);try{await Ve(e.instanceId),await i()}catch(e){f(e instanceof Error?e.message:String(e))}finally{c(!1)}},[e.instanceId,i]),m=(0,X.useCallback)(async()=>{u(!0),f(null);try{await Se(e.instanceId),await i()}catch(e){f(e instanceof Error?e.message:String(e)),u(!1)}},[e.instanceId,i]),h=e.usage.lastHealthStatus?a.healthStatusLabels[e.usage.lastHealthStatus]??e.usage.lastHealthStatus:a.healthNotTested,g=e.usage.lastToolCount??0,_=!!(t?.setup.config?.length&&!t.setup.secrets?.length&&e.materialized.type===`mcp`),v=fn(e,t).state,y=v===`ready`?{label:a.connectionReady,Icon:W,className:`border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`}:v===`needs_setup`?{label:a.connectionNeedsSetup,Icon:oe,className:`border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300`}:{label:a.connectionChecking,Icon:ue,className:`border-edge bg-surface-base text-fg-muted`};return(0,Q.jsxs)(`div`,{className:o(`flex h-full min-h-[10.5rem] cursor-pointer flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`,n&&`ring-2 ring-accent/45 ring-offset-2 ring-offset-surface-panel`),onClick:()=>r(e),children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3`,children:[(0,Q.jsx)(Xe,{connector:t}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.displayName}),(0,Q.jsxs)(`span`,{className:o(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium`,y.className),children:[(0,Q.jsx)(y.Icon,{className:`size-3`,"aria-hidden":!0}),y.label]}),_?(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:a.connectorConfigLabel}):null]}),t?.description?(0,Q.jsx)(`p`,{className:`mt-3 line-clamp-2 text-sm leading-5 text-fg-muted`,children:t.description}):null,(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs text-fg-muted`,children:[(0,Q.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:[a.statusLabel,` `,h]}),(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:$(a.toolsAvailable,{count:String(g)})})]}),d?(0,Q.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:d}):null]})]}),(0,Q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:a.connectorDetails}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[v===`needs_setup`?(0,Q.jsxs)(U,{variant:`primary`,onClick:()=>r(e),children:[(0,Q.jsx)(oe,{className:`size-4`}),a.connectionResolveAction]}):null,e.materialized.type===`mcp`?(0,Q.jsxs)(U,{variant:`secondary`,disabled:s,onClick:()=>void p(),children:[s?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):(0,Q.jsx)(O,{className:`size-4`}),a.test]}):null,(0,Q.jsxs)(U,{variant:`ghost`,disabled:l,onClick:()=>void m(),children:[l?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):(0,Q.jsx)(T,{className:`size-4`}),a.remove]})]})]})]})}var mn=o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,m),hn=o(mn,`min-h-28 font-mono`);function gn(e,t){return e?t.healthStatusLabels[e]??e:t.healthStatusPending}function _n(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 vn(e){let t=(0,Z.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,Q.jsx)(`div`,{className:`border-b border-edge px-3 py-2 text-xs font-semibold text-fg`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,12).map(yn),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>12?(0,Q.jsxs)(`div`,{className:`px-3 py-2 text-xs text-fg-subtle`,children:[`+`,r.length-12]}):null,t[4]=r.length,t[5]=o);let s;t[6]!==a||t[7]!==o?(s=(0,Q.jsxs)(`div`,{className:`max-h-40 overflow-y-auto`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==i||t[10]!==s?(c=(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel`,children:[i,s]}),t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function yn(e){return(0,Q.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,Q.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,Q.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function bn({draft:e,onChange:t,onClose:n,onInstalled:r,t:i}){let{connector:a}=e,s=a.runtime.type===`composio`&&a.runtime.role===`toolkit`,c=a.runtime.type===`composio`&&a.runtime.role===`toolkit`?a.runtime.toolkit:null,[l,u]=(0,X.useState)(!s),[d,f]=(0,X.useState)(s),[p,m]=(0,X.useState)(``),[h,g]=(0,X.useState)(null),[_,v]=(0,X.useState)(!0);(0,X.useEffect)(()=>{if(!s)return;let e=!1;return Le().then(({configured:t})=>{e||u(t)}).catch(t=>{e||g(t instanceof Error?t.message:String(t))}).finally(()=>{e||f(!1)}),()=>{e=!0}},[a.id,s]);let y=e.result?`complete`:e.installing?`health`:`configure`,S=[{id:`configure`,label:i.connectStepConfigure},{id:`health`,label:i.connectStepVerify},{id:`complete`,label:i.connectStepReady}],T=(0,X.useCallback)(async()=>{let n=w(),i=s&&!n?window.open(``,`_blank`):null;i&&(i.opener=null),g(null),t({...e,installing:!0,error:null,result:null,health:null});try{s&&!l&&(await Ge(p),u(!0));let o={};for(let t of a.setup.config??[]){let n=_n(t.type,e.config[t.key]??``);n!==void 0&&(o[t.key]=n)}let d=e.store?await ze(e.store.packageName,{secrets:e.secrets,config:o},e.store.version):await We(a.id,{secrets:e.secrets,config:o,definition:a.source===`registry`?a:void 0}),f=null;try{if(s)if((c?await Ue(c).catch(()=>null):null)?.status===`connected`){i?.close();let e=await Te(c);_&&await Oe(e.id)}else{let e=await He(a.id);if(!e.authorizationUrl)throw Error(`The connection service did not return an authorization URL.`);if(n){let t=await window.electronAPI?.shell?.openExternalUrl(e.authorizationUrl);if(!t?.ok)throw Error(t?.error??`Could not open the system browser.`)}else i?i.location.href=e.authorizationUrl:window.open(e.authorizationUrl,`_blank`,`noopener,noreferrer`);let t=await Te(c,e.connectionId);i?.close(),_&&await Oe(t.id)}}catch(n){i?.close(),t({...e,installing:!1,result:d,health:null,error:n instanceof Error?n.message:String(n)}),await r(d);return}if(!s)try{f=await Ve(d.instanceId)}catch{f=null}t({...e,installing:!1,result:d,health:f}),await r(d)}catch(n){i?.close(),t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}},[p,l,c,a,e,s,_,t,r]);return(0,Q.jsx)(ee,{open:!0,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(E,{children:[(0,Q.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(I,{className:o(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Q.jsx)(Xe,{connector:a,size:`lg`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(pe,{className:`text-base font-semibold text-fg`,children:$(i.connectDialogTitle,{name:a.displayName})}),(0,Q.jsx)(te,{className:`mt-1 line-clamp-3 text-sm text-fg-muted`,children:a.description})]})]}),(0,Q.jsx)(C,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:o(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,N.focusRingPanel),"aria-label":i.modalClose,children:[(0,Q.jsx)(k,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 overflow-y-auto px-6 py-5`,children:[(0,Q.jsx)(`div`,{className:`mb-5 grid grid-cols-3 gap-2`,"aria-label":i.connectProgressAria,children:S.map((e,t)=>{let n=S.findIndex(e=>e.id===y);return(0,Q.jsxs)(`div`,{className:o(`rounded-xl border px-3 py-2 text-xs font-medium`,t===n?`border-accent bg-accent-soft text-accent-fg`:t<n?`border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-900/40 dark:bg-emerald-950/40 dark:text-emerald-200`:`border-edge bg-surface-base text-fg-muted`),children:[(0,Q.jsxs)(`span`,{className:`mr-1 tabular-nums`,children:[t+1,`.`]}),e.label]},e.id)})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[s&&!l?(0,Q.jsxs)(`section`,{className:`rounded-2xl border border-accent/25 bg-accent-soft/50 p-4`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.composioSetupTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:i.composioSetupHint}),(0,Q.jsxs)(`ol`,{className:`mt-3 list-inside list-decimal space-y-1 text-xs text-fg-muted`,children:[(0,Q.jsx)(`li`,{children:i.composioSetupStepProject}),(0,Q.jsx)(`li`,{children:i.composioSetupStepKey}),(0,Q.jsx)(`li`,{children:i.composioSetupStepPaste})]}),(0,Q.jsxs)(`a`,{className:`mt-3 inline-flex items-center gap-1 text-xs font-medium text-accent-fg hover:underline`,href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,children:[i.composioSetupOpenDashboard,(0,Q.jsx)(b,{className:`size-3.5`,"aria-hidden":!0})]}),(0,Q.jsx)(M,{className:`mt-3`,value:p,onChange:m,labels:i.secretInputLabels,placeholder:i.composioSetupKeyPlaceholder}),(0,Q.jsx)(`p`,{className:`mt-2 text-[11px] text-fg-subtle`,children:i.composioSetupStorageHint})]}):null,s?(0,Q.jsxs)(`label`,{className:`flex items-start gap-3 rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 accent-accent`,checked:_,onChange:e=>v(e.currentTarget.checked)}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:i.learnAfterConnect}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:i.learnAfterConnectHint})]})]}):null,e.store?(0,Q.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.detailPermissions}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[(e.store.permissions.data??[]).map(e=>(0,Q.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:e},e)),(e.store.permissions.networkDomains??[]).map(e=>(0,Q.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:e},e)),(0,Q.jsx)(`span`,{className:`rounded-md border border-emerald-500/30 bg-emerald-500/10 px-2 py-1 text-xs text-emerald-700 dark:text-emerald-300`,children:i.storeLocalExecDenied})]})]}):null,(a.setup.secrets??[]).map(n=>(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.description?(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.description}):null,(0,Q.jsx)(M,{value:e.secrets[n.key]??``,onChange:r=>t({...e,secrets:{...e.secrets,[n.key]:r},error:null}),labels:i.secretInputLabels,placeholder:n.required?i.requiredPlaceholder:i.optionalPlaceholder})]},n.key)),(a.setup.config??[]).map(n=>(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.type===`json`?(0,Q.jsx)(`textarea`,{className:hn,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})}):(0,Q.jsx)(`input`,{className:mn,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})})]},n.key)),e.installing?(0,Q.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-fg`,children:[(0,Q.jsx)(G,{className:`size-4 animate-spin text-accent`,"aria-hidden":!0}),i.connectingTitle]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i.connectingHint})]}):null,e.error?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:e.error}):null,h?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:h}):null,e.result?(0,Q.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsx)(`div`,{children:(0,Q.jsx)(`p`,{className:`font-medium text-fg`,children:i.connectedBadge})}),(0,Q.jsx)(`span`,{className:o(`rounded-full px-2 py-0.5 text-xs font-medium`,e.health?.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e.health?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-hover text-fg-muted`),children:e.health?.ok?i.healthStatusHealthy:gn(e.health?.status,i)})]}),e.health?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.toolCount}),(0,Q.jsx)(`div`,{children:i.toolsMetric})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.resourceCount}),(0,Q.jsx)(`div`,{children:i.resourcesMetric})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.promptCount}),(0,Q.jsx)(`div`,{children:i.promptsMetric})]})]}),(0,Q.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,Q.jsx)(vn,{title:i.detailTools,items:e.health.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,Q.jsx)(vn,{title:i.detailResources,items:e.health.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,Q.jsx)(vn,{title:i.detailPrompts,items:e.health.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??$(i.promptArgumentCount,{count:String(e.argumentCount)})}))})]})]}):(0,Q.jsx)(`p`,{className:`mt-3`,children:i.installedWithoutHealth}),e.health?.action?(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:e.health.action}):null]}):null]})]}),(0,Q.jsx)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:(0,Q.jsxs)(U,{variant:`primary`,disabled:!!e.result||e.installing||d||s&&!l&&!p.trim(),onClick:()=>void T(),children:[e.installing?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):e.result?(0,Q.jsx)(W,{className:`size-4`}):(0,Q.jsx)(P,{className:`size-4`}),e.result?i.connectedBadge:i.connect]})})]})]})})}function xn(e,t){let n={};for(let t of e.setup.secrets??[])n[t.key]=``;let r={};for(let t of e.setup.config??[])r[t.key]=t.defaultValue===void 0?``:typeof t.defaultValue==`string`?t.defaultValue:JSON.stringify(t.defaultValue,null,2);return{connector:e,secrets:n,config:r,installing:!1,error:null,result:null,health:null,...t?{store:t}:{}}}function Sn(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 Mt(r)}function Cn(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 wn(){return o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,m)}function Tn({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:i,pasteFailed:a,keyPlaceholder:c,valuePlaceholder:l,headers:u,onChange:d}){let f=(e,t)=>{d(u.map((n,r)=>r===e?{...n,...t}:n))},p=()=>{d([...u,{key:``,value:``}])},m=e=>{let t=u.filter((t,n)=>n!==e);d(t.length>0?t:[{key:``,value:``}])},h=async()=>{try{let e=await s();if(!e){window.alert(a);return}let t=Ct(e);if(!t?.length){window.alert(a);return}d(t)}catch{window.alert(a)}};return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,Q.jsx)(`span`,{children:e}),t?(0,Q.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),(0,Q.jsxs)(U,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void h(),children:[(0,Q.jsx)(H,{className:`size-3.5`,"aria-hidden":!0}),i]})]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{className:o(wn(),`min-w-0 flex-1 font-mono text-xs`),value:e.key,placeholder:c,onChange:e=>f(t,{key:e.target.value})}),(0,Q.jsx)(`input`,{className:o(wn(),`min-w-0 flex-[1.4] font-mono text-xs`),value:e.value,placeholder:l,onChange:e=>f(t,{value:e.target.value})}),(0,Q.jsx)(U,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:u.length<=1&&!e.key&&!e.value,onClick:()=>m(t),"aria-label":r,children:(0,Q.jsx)(T,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})})]},Cn(e,t,u)))}),(0,Q.jsxs)(`button`,{type:`button`,className:o(`self-start text-sm text-accent hover:underline`,N.press),onClick:p,children:[`+ `,n]})]})}var En=[`stdio`,`sse`,`streamable-http`];function Dn(e){let t=(0,Z.c)(11),{label:n,description:r,required:i,children:a}=e,o;t[0]===i?o=t[1]:(o=i?(0,Q.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,Q.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,Q.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,Q.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 On(){return o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,m)}function kn(e){let t=(0,Z.c)(35),{row:n,t:r,onUpdate:i,idConflictMessage:a,variant:s}=e,c=s===void 0?`all`:s,l=c===`all`||c===`basic`,u=c===`all`||c===`advanced`,d;t[0]!==a||t[1]!==i||t[2]!==n.id||t[3]!==n.transport||t[4]!==l||t[5]!==r?(d=l?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Dn,{label:r.transportLabel,required:!0,children:(0,Q.jsx)(le,{className:On(),value:n.transport,onChange:e=>i({transport:e.target.value}),children:En.map(e=>(0,Q.jsx)(V,{value:e,children:r.transportLabels[e]},e))})}),(0,Q.jsxs)(Dn,{label:r.serverIdLabel,required:!0,children:[(0,Q.jsx)(`input`,{className:On(),value:n.id,placeholder:r.serverIdPlaceholder,onChange:e=>i({id:e.target.value})}),a?(0,Q.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]=l,t[5]=r,t[6]=d):d=t[6];let f;t[7]!==i||t[8]!==n.argsText||t[9]!==n.command||t[10]!==n.cwd||t[11]!==n.envJson||t[12]!==n.headers||t[13]!==n.transport||t[14]!==n.url||t[15]!==u||t[16]!==l||t[17]!==r||t[18]!==c?(f=n.transport===`stdio`?(0,Q.jsxs)(Q.Fragment,{children:[l?(0,Q.jsx)(`div`,{className:c===`basic`?`md:col-span-2`:void 0,children:(0,Q.jsx)(Dn,{label:r.commandLabel,required:!0,children:(0,Q.jsx)(`input`,{className:On(),value:n.command,onChange:e=>i({command:e.target.value})})})}):null,u?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Dn,{label:r.argsLabel,description:r.argsHint,children:(0,Q.jsx)(`input`,{className:On(),value:n.argsText,onChange:e=>i({argsText:e.target.value})})}),(0,Q.jsx)(Dn,{label:r.cwdLabel,children:(0,Q.jsx)(`input`,{className:On(),value:n.cwd,onChange:e=>i({cwd:e.target.value})})}),(0,Q.jsx)(Dn,{label:r.envLabel,description:r.envHint,children:(0,Q.jsx)(`textarea`,{className:o(On(),`min-h-[4rem] font-mono text-xs`),value:n.envJson,onChange:e=>i({envJson:e.target.value})})})]}):null]}):(0,Q.jsxs)(Q.Fragment,{children:[l?(0,Q.jsx)(`div`,{className:`md:col-span-2`,children:(0,Q.jsx)(Dn,{label:r.urlLabel,required:!0,children:(0,Q.jsx)(`input`,{className:o(On(),`font-mono text-xs`),value:n.url,placeholder:`https://example.com/mcp`,onChange:e=>i({url:e.target.value})})})}):null,u?(0,Q.jsx)(Tn,{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:e})}):null]}),t[7]=i,t[8]=n.argsText,t[9]=n.command,t[10]=n.cwd,t[11]=n.envJson,t[12]=n.headers,t[13]=n.transport,t[14]=n.url,t[15]=u,t[16]=l,t[17]=r,t[18]=c,t[19]=f):f=t[19];let p;t[20]!==i||t[21]!==n||t[22]!==u||t[23]!==r?(p=u?(0,Q.jsx)(Dn,{label:r.timeoutLabel,description:r.timeoutHint,children:(0,Q.jsx)(`input`,{type:`number`,min:1,max:600,className:On(),value:Bt(n),placeholder:r.timeoutPlaceholder,onChange:e=>i({connectionTimeoutMs:Vt(e.target.value)})})}):null,t[20]=i,t[21]=n,t[22]=u,t[23]=r,t[24]=p):p=t[24];let m;t[25]!==i||t[26]!==n||t[27]!==u||t[28]!==r?(m=u?(0,Q.jsx)(Dn,{label:r.requestTimeoutLabel,description:r.requestTimeoutHint,children:(0,Q.jsx)(`input`,{type:`number`,min:1,max:14400,className:On(),value:Ht(n),placeholder:r.requestTimeoutPlaceholder,onChange:e=>i({requestTimeoutMs:Ut(e.target.value)})})}):null,t[25]=i,t[26]=n,t[27]=u,t[28]=r,t[29]=m):m=t[29];let h;return t[30]!==d||t[31]!==f||t[32]!==p||t[33]!==m?(h=(0,Q.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[d,f,p,m]}),t[30]=d,t[31]=f,t[32]=p,t[33]=m,t[34]=h):h=t[34],h}function An(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 jn(e){let t=(0,Z.c)(13),{tool:n,serverId:r}=e,i;t[0]!==r||t[1]!==n?(i=An(n,r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,s=n.name===a?a:n.name,c;t[3]===n.description?c=t[4]:(c=n.description?.trim(),t[3]=n.description,t[4]=c);let l=c,u;t[5]!==a||t[6]!==s?(u=(0,Q.jsx)(`p`,{className:`break-all font-mono text-xs font-medium leading-5 text-fg`,title:s,children:a}),t[5]=a,t[6]=s,t[7]=u):u=t[7];let d;t[8]===l?d=t[9]:(d=l?(0,Q.jsx)(S,{delayDuration:300,skipDelayDuration:100,children:(0,Q.jsxs)(F,{children:[(0,Q.jsx)(R,{asChild:!0,children:(0,Q.jsx)(`p`,{tabIndex:0,title:l,className:o(`mt-1 line-clamp-3 cursor-help text-xs leading-5 text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:l})}),(0,Q.jsx)(L,{children:(0,Q.jsx)(h,{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,Q.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:l})})})]})}):null,t[8]=l,t[9]=d);let f;return t[10]!==u||t[11]!==d?(f=(0,Q.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[u,d]}),t[10]=u,t[11]=d,t[12]=f):f=t[12],f}function Mn({open:e,mode:t,initialRow:n,existingCustomServers:r,sessionIdleTtlMinutes:i,config:a,managedServerIds:s,t:c,cs:l,onClose:u,onSaved:d}){let[f,p]=(0,X.useState)(n),[m,h]=(0,X.useState)(!1),[g,_]=(0,X.useState)(!1),[v,b]=(0,X.useState)(null),[S,w]=(0,X.useState)(!1),[T,D]=(0,X.useState)({status:`idle`}),[A,j]=(0,X.useState)(null),M=n.id.trim(),P=f.id.trim()!==M&&s.has(f.id.trim())||s.has(f.id.trim())&&t===`add`?c.reservedServerId:void 0,F=f.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===f.id.trim())?l.duplicateServerId:void 0,L=f.id.trim().length>0&&!P&&!F&&(f.transport===`stdio`?f.command.trim().length>0:f.url.trim().length>0),R=Wt(f),z=(0,X.useCallback)(async()=>{if(f.id.trim()){_(!0),b(null),D({status:`loading`});try{D({status:`ok`,tools:(await zt(f.id.trim(),Pt(f))).tools})}catch(e){D({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{_(!1)}}},[f]),B=(0,X.useCallback)(async()=>{if(!(!L||m)){h(!0),b(null);try{let e=r.filter(e=>!(t===`edit`&&e.clientKey===n.clientKey));e.push(f),await Ft({sessionIdleTtlMinutes:i,servers:e.sort((e,t)=>e.id.localeCompare(t.id))},Dt(a)),await d(),u()}catch(e){b(e instanceof Error?e.message:String(e))}finally{h(!1)}}},[L,a,r,n.clientKey,t,u,d,M,f,m,i]);return e?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ee,{open:e,onOpenChange:e=>{e||u()},children:(0,Q.jsxs)(E,{children:[(0,Q.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(I,{className:o(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(pe,{className:`text-base font-semibold text-fg`,children:t===`add`?l.addCustomServerTitle:l.editCustomServerTitle}),(0,Q.jsx)(te,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?l.addCustomServerHint:l.editCustomServerHint})]}),(0,Q.jsx)(C,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:o(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,N.focusRingPanel),"aria-label":l.modalClose,children:[(0,Q.jsx)(k,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`sr-only`,children:l.modalClose})]})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(ae,{className:`size-4 text-accent`,"aria-hidden":!0}),f.id.trim()||c.cardUntitled]}),(0,Q.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs leading-5 text-fg-muted`,children:R||(f.transport===`stdio`?c.commandLabel:c.urlLabel)})]}),(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:c.transportLabels[f.transport]})]})}),(0,Q.jsxs)(`section`,{children:[(0,Q.jsxs)(`div`,{className:`mb-3`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.connectorBasicConfigTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.connectorBasicConfigHint})]}),(0,Q.jsx)(kn,{row:f,t:c,variant:`basic`,onUpdate:e=>{p(t=>({...t,...e})),b(null)},idConflictMessage:P??F})]}),T.status===`ok`?(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,Q.jsx)(y,{className:`size-4 text-accent`,"aria-hidden":!0}),T.tools.length===0?c.toolsEmpty:c.toolsTitle.replace(`{{count}}`,String(T.tools.length))]}),T.tools.length>0?(0,Q.jsx)(U,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>j(T.tools),children:c.viewAllTools}):null]}),T.tools.length>0?(0,Q.jsx)(`div`,{className:`mt-3 grid gap-2`,children:T.tools.slice(0,6).map((e,t)=>(0,Q.jsx)(jn,{tool:e,serverId:f.id},e.name||`tool-${t}`))}):null]}):null,T.status===`error`?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:T.message}):null,v?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:v}):null,(0,Q.jsxs)(`details`,{open:S,onToggle:e=>w(e.currentTarget.open),className:`group rounded-xl border border-edge bg-surface-base`,children:[(0,Q.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,Q.jsx)(J,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`group-open:hidden`,children:l.connectorShowAdvancedConfig}),(0,Q.jsx)(`span`,{className:`hidden group-open:inline`,children:l.connectorHideAdvancedConfig})]}),(0,Q.jsx)(`div`,{className:`border-t border-edge p-4`,children:(0,Q.jsx)(kn,{row:f,t:c,variant:`advanced`,onUpdate:e=>{p(t=>({...t,...e})),b(null)}})})]})]})}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,Q.jsxs)(U,{variant:`secondary`,disabled:!f.id.trim()||g,onClick:()=>void z(),children:[g?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):(0,Q.jsx)(O,{className:`size-4`}),c.testConnection]}),(0,Q.jsx)(C,{asChild:!0,children:(0,Q.jsx)(U,{variant:`secondary`,children:l.modalCancel})}),(0,Q.jsxs)(U,{variant:`primary`,disabled:!L||m,onClick:()=>void B(),children:[m?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):(0,Q.jsx)(W,{className:`size-4`}),m?c.saving:l.modalSave]})]})]})]})}),A?(0,Q.jsx)(Xt,{open:!0,onOpenChange:e=>{e||j(null)},serverId:f.id,title:c.toolsDialogTitle,subtitle:c.toolsDialogSubtitle,searchPlaceholder:c.toolsDialogSearchPlaceholder,searchEmptyLabel:c.toolsDialogSearchEmpty,emptyLabel:c.toolsEmpty,closeLabel:c.toolsDialogClose,tools:A,stripPrefix:`${f.id.trim()}__`}):null]}):null}function Nn(e){return!(e.runtime.type===`composio`&&e.runtime.role===`credential`)}function Pn(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 Fn(e,t,n){return e.filter(e=>Pn(e,t)).toSorted((e,t)=>n===`source`&&e.source!==t.source?e.source.localeCompare(t.source):e.displayName.localeCompare(t.displayName))}function In(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 Ln(e,t){let n=t.trim().toLowerCase();return n?[e.id,e.command??``,e.url??``,e.transport].some(e=>e.toLowerCase().includes(n)):!0}var Rn=`all`,zn=`builtin`,Bn=`composio`,Vn=`xopc-store`;function Hn(e){let t=[`code`,`docs`,`browser`,`data`,`automation`,`custom`].includes(e.category??``)?e.category:`custom`;return{id:e.name,version:e.latestVersion??`store`,displayName:e.name,description:e.description,category:t,kind:`mcp`,source:`store`,capabilities:[`tools`,`runtime.mcp.streamableHttp`],tags:[`store`],auth:{mode:`none`},setup:{},runtime:{type:`mcp`,serverId:`store-${e.name}`.slice(0,64)}}}function Un(e){return e.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t)}function Wn(){let e=c(u(e=>e.language)),t=e.connectorsSettings,n=e.mcpSettings,r=l(e=>e.token),a=!!r,[s,d]=i(),[f,m]=(0,X.useState)(s.get(`tab`)===`connected`?`connected`:`discover`),h=(0,X.useRef)(!1),[g,v]=(0,X.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null,peopleGraph:null}),[y,b]=(0,X.useState)(!1),[x,S]=(0,X.useState)(!1),[C,w]=(0,X.useState)(1),[T,E]=(0,X.useState)(void 0),[D,O]=(0,X.useState)(``),[k,A]=(0,X.useState)(``),[j,M]=(0,X.useState)(!1),[N,P]=(0,X.useState)(``),[F,I]=(0,X.useState)(zn),[L,ee]=(0,X.useState)(`name`),[R,te]=(0,X.useState)(`all`),[z,B]=(0,X.useState)(null),[V,H]=(0,X.useState)(null),[ne,re]=(0,X.useState)(null),[ie,ae]=(0,X.useState)(null),[oe,se]=(0,X.useState)(null),[ce,le]=(0,X.useState)(null),[ue,de]=(0,X.useState)(!1),[W,pe]=(0,X.useState)(void 0),[he,ge]=(0,X.useState)(!1),{data:_e,mutate:ve}=p(a),K=_e?.payload?.config,q=(0,X.useMemo)(()=>K===void 0?null:Nt(K),[K]),J=q?.servers??[],ye=g.instances.length+J.length;(0,X.useEffect)(()=>{q&&pe(q.sessionIdleTtlMinutes)},[q]);let Y=(0,X.useCallback)(async()=>{if(!r){v({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null,peopleGraph:null});return}v(e=>({...e,loading:!0,error:null}));try{let[e,t,n]=await Promise.all([Ne(),Ke(),Be(``,12).catch(()=>null)]);v(r=>({catalog:e,registryCatalog:r.registryCatalog,instances:t,loading:!1,error:null,peopleGraph:n}))}catch(e){v({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e),peopleGraph:null})}},[r]);(0,X.useEffect)(()=>{Y()},[Y]),(0,X.useEffect)(()=>{if(!a||f!==`connected`)return;let e=!1,t=window.setTimeout(()=>{M(!0),Be(k,50).then(t=>{e||v(e=>({...e,peopleGraph:t}))}).catch(()=>{}).finally(()=>{e||M(!1)})},250);return()=>{e=!0,window.clearTimeout(t)}},[a,k,f]),(0,X.useEffect)(()=>{h.current||g.loading||a&&!q||(m(ye>0?`connected`:`discover`),h.current=!0)},[a,ye,q,g.loading]);let Se=(0,X.useCallback)(e=>{h.current=!0,m(e)},[]),Ce=(0,X.useMemo)(()=>[{id:Bn,displayName:t.composioSourceName},{id:Vn,displayName:t.storeSourceName}],[t.composioSourceName,t.storeSourceName]),we=(0,X.useCallback)(async e=>{if(!a||F===zn){v(e=>({...e,registryCatalog:[]})),w(1),E(void 0);return}let t=N.trim(),n=Math.max(e?.page??1,1),r=e?.append??!1,i=F===Rn?Ce:Ce.filter(e=>e.id===F);if(i.length!==0){b(!0),r?v(e=>({...e,error:null})):(w(1),E(void 0),v(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(i.map(async e=>{if(e.id===Bn){let e=await Je({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let r=await Ye({q:t||void 0,page:n,pageSize:24,sort:L===`source`?`newest`:`downloads`});return{connectors:r.items.map(Hn),totalPages:r.meta.totalPages}})),a=Un(e.flatMap(e=>e.connectors)),o=Math.max(1,...e.map(e=>e.totalPages??1));w(n),E(o),v(e=>({...e,registryCatalog:r?Un([...e.registryCatalog,...a]):a}))}catch(e){v(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{b(!1)}}},[L,N,F,a,Ce]);(0,X.useEffect)(()=>{if(f!==`discover`||g.loading)return;if(F===zn){v(e=>({...e,registryCatalog:[]})),w(1),E(void 0);return}let e=window.setTimeout(()=>{we()},N.trim()?350:0);return()=>window.clearTimeout(e)},[N,F,we,g.loading,f]);let Te=(0,X.useMemo)(()=>new Set(g.instances.map(e=>e.connectorId)),[g.instances]),Ee=(0,X.useMemo)(()=>new Map([...g.catalog,...g.registryCatalog].map(e=>[e.id,e])),[g.catalog,g.registryCatalog]);(0,X.useEffect)(()=>{if(g.loading)return;let e=s.get(`connector`),t=s.get(`instance`);if(!e&&!t)return;let n=g.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)h.current=!0,O(``),re(n.instanceId),ae(n),m(`connected`);else if(e){let t=Ee.get(e);if(!t)return;h.current=!0,I(zn),P(``),H(t),m(`discover`)}let r=new URLSearchParams(s);r.delete(`connector`),r.delete(`instance`),r.delete(`personalContext`),r.set(`tab`,n?`connected`:`discover`),d(r,{replace:!0})},[Ee,s,d,g.instances,g.loading]);let De=(0,X.useCallback)(async e=>{S(!0),v(e=>({...e,error:null}));try{let t=await Fe(e);B(xn(t.definition,{packageName:t.packageName,version:t.version,permissions:t.permissions}))}catch(e){v(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{S(!1)}},[]),Oe=(0,X.useMemo)(()=>new Set(g.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[g.instances]),ke=(0,X.useCallback)(async e=>{if(!q||K===void 0)return;let t=J.filter(t=>t.clientKey!==e.clientKey);await Ft({sessionIdleTtlMinutes:q.sessionIdleTtlMinutes,servers:t},Dt(K)),await ve(),await Y()},[K,J,Y,q,ve]),Ae=(0,X.useCallback)(()=>{le({mode:`add`,row:Sn(J,Oe)})},[J,Oe]),je=(0,X.useCallback)(async()=>{if(!(!q||K===void 0||he)){ge(!0);try{await Ft({sessionIdleTtlMinutes:W,servers:J},Dt(K)),await ve(),de(!1)}finally{ge(!1)}}},[K,J,n.saved,q,ve,W,he]),Me=_(e=>e.setPageHeader),Pe=_(e=>e.clearPageHeader),Ie=(0,X.useMemo)(()=>(0,Q.jsx)(xt,{onBrowseCatalog:()=>Se(`discover`),onAddCustomServer:Ae,onOpenRuntimeSettings:()=>de(!0),addLabel:t.addConnection,browseLabel:t.addFromCatalog,customLabel:t.addCustomServerAdvanced,settingsLabel:t.runtimeSettings}),[t,Ae,Se]);(0,X.useLayoutEffect)(()=>(Me({startExtra:null,main:(0,Q.jsx)(`div`,{className:`min-w-0`,children:(0,Q.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title})}),end:Ie}),()=>Pe()),[Pe,t.title,Ie,Me]);let Le=(0,X.useMemo)(()=>g.instances.map(e=>({instance:e,value:fn(e,Ee.get(e.connectorId))})),[Ee,g.instances]),Re=(0,X.useMemo)(()=>new Map(Le.map(({instance:e,value:t})=>[e.instanceId,t])),[Le]),ze=(0,X.useMemo)(()=>g.instances.filter(e=>In(e,D)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=Re.get(e.instanceId)?.state??`checking`,i=Re.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[D,Re,g.instances]),Ve=(0,X.useMemo)(()=>J.filter(e=>Ln(e,D)),[D,J]),He=ze.length+Ve.length,Ue=(0,X.useMemo)(()=>g.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&Nn(e)),[g.catalog]),We=(0,X.useMemo)(()=>F===zn?Ue:F===Rn?Un([...Ue,...g.registryCatalog]):g.registryCatalog,[Ue,F,g.registryCatalog]),Ge=(0,X.useMemo)(()=>Fn(R===`all`?We:We.filter(e=>un(e).includes(R)),N,L),[L,N,We,R]),qe=(0,X.useMemo)(()=>ln.filter(e=>We.some(t=>un(t).includes(e))),[We]);(0,X.useEffect)(()=>{R!==`all`&&!qe.includes(R)&&te(`all`)},[qe,R]);let Xe=f===`discover`&&F!==zn&&!!(T&&C<T),Ze=(0,X.useMemo)(()=>g.instances.find(e=>e.instanceId===ne)??ie,[ne,ie,g.instances]),Qe=(0,X.useMemo)(()=>[{value:Rn,label:t.discoverSourceAll},{value:zn,label:t.discoverSourceBuiltin},...Ce.map(e=>({value:e.id,label:e.displayName}))],[t.discoverSourceAll,t.discoverSourceBuiltin,Ce]),$e=[{id:`connected`,label:t.tabConnected,count:ye},{id:`discover`,label:t.tabDiscover}];return(0,Q.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,Q.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[a?null:(0,Q.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:t.tokenHint}),(0,Q.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(`div`,{className:`border-b border-edge-subtle pb-3 dark:border-edge-subtle`,children:(0,Q.jsx)(xe,{items:$e,activeTab:f,onChange:Se,ariaLabel:t.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),g.error?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:g.error}):null,f===`connected`&&a?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,Q.jsx)(bt,{value:D,onChange:O,placeholder:t.connectedSearchPlaceholder,className:`max-w-xl`}),(0,Q.jsx)(fe,{className:`size-9 shrink-0 p-0`,loading:g.loading,label:t.refreshConnections,title:t.refreshConnections,onClick:Y})]}),g.peopleGraph&&(g.peopleGraph.people.length>0||k)?(0,Q.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`div`,{className:`rounded-lg bg-accent-soft p-2 text-accent-fg`,children:(0,Q.jsx)(be,{className:`size-4`,"aria-hidden":!0})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.peopleGraphTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.peopleGraphHint.replace(`{{people}}`,String(g.peopleGraph.people.length)).replace(`{{sources}}`,String(new Set(g.peopleGraph.sourceEdges.map(e=>e.sourceInstanceId)).size))})]})]}),(0,Q.jsxs)(`div`,{className:`relative w-full max-w-xs`,children:[(0,Q.jsx)(bt,{value:k,onChange:A,placeholder:t.peopleGraphSearchPlaceholder}),j?(0,Q.jsx)(G,{className:`absolute right-3 top-2.5 size-4 animate-spin text-fg-subtle`,"aria-hidden":!0}):null]})]}),g.peopleGraph.people.length?(0,Q.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:g.peopleGraph.people.slice(0,10).map(e=>{let t=[...new Set(g.peopleGraph.sourceEdges.filter(t=>t.personId===e.id).map(e=>e.toolkit??e.connectorId??e.sourceInstanceId))];return(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel px-3 py-2.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.label}),(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:e.mentionCount})]}),(0,Q.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:e.emails[0]??e.usernames[0]??e.roles.join(` · `)}),(0,Q.jsx)(`p`,{className:`mt-1 truncate text-[11px] text-fg-subtle`,children:t.join(` · `)})]},e.id)})}):(0,Q.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:t.peopleGraphSearchEmpty})]}):null,g.loading?(0,Q.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":t.loading,children:it.slice(0,3).map(e=>(0,Q.jsx)(lt,{},e))}):ye===0?(0,Q.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.connectionsEmpty}),(0,Q.jsx)(U,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>Se(`discover`),children:t.addFromCatalog})]}):He===0?(0,Q.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.connectionsSearchEmpty}):(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:[ze.map(e=>(0,Q.jsx)(pn,{instance:e,definition:Ee.get(e.connectorId),highlighted:e.instanceId===oe,onOpenDetails:e=>{se(null),re(e.instanceId),ae(e)},onChanged:Y,t},e.instanceId)),Ve.map(e=>(0,Q.jsx)(Gt,{row:e,t:n,cs:t,onEdit:()=>le({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>ke(e)},e.clientKey))]})]}):null,f===`discover`&&a?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":t.outcomeFilterAria,children:[`all`,...qe].map(e=>(0,Q.jsx)(`button`,{type:`button`,className:o(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,R===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":R===e,onClick:()=>te(e),children:e===`all`?t.outcomeAll:t.connectorBenefitHeadings[e]},e))}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 lg:flex-row lg:items-center`,children:[(0,Q.jsx)(bt,{value:N,onChange:P,placeholder:t.discoverSearchPlaceholder,className:`max-w-xl`}),(0,Q.jsxs)(`div`,{className:`grid min-w-0 grid-cols-1 gap-2 sm:grid-cols-2 lg:ml-auto lg:w-[26rem]`,children:[(0,Q.jsx)(me,{value:F,options:Qe,placeholder:t.discoverSourceAll,allowEmpty:!1,ariaLabel:t.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:I}),(0,Q.jsx)(me,{value:L,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=>ee(e)})]})]}),(g.loading||y)&&Ge.length===0?(0,Q.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:it.map(e=>(0,Q.jsx)(st,{},e))}):Ge.length===0?(0,Q.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.discoverEmpty}):(0,Q.jsxs)(`div`,{className:`relative`,children:[y?(0,Q.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,Q.jsx)(G,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,Q.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:Ge.map(e=>(0,Q.jsx)(nt,{connector:e,installed:Te.has(e.id)||at(e,g.instances),onInstall:e=>{if(e.source===`store`){De(e.id);return}B(xn(e))},onOpenDetails:e.source===`store`?void 0:H,t},e.id))}),Xe?(0,Q.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,Q.jsxs)(U,{type:`button`,variant:`secondary`,disabled:y||x,onClick:()=>void we({page:C+1,append:!0}),children:[y?(0,Q.jsx)(G,{className:`size-4 animate-spin`}):null,t.loadMore]})}):null]})]}):null]}),z?(0,Q.jsx)(bn,{draft:z,onChange:B,onClose:()=>B(null),t,onInstalled:async e=>{await Y(),await ve(),se(e.instanceId),Se(`connected`)}}):null,V?(0,Q.jsx)(_t,{connector:V,installed:Te.has(V.id)||at(V,g.instances),onClose:()=>H(null),onInstall:e=>B(xn(e)),t}):null,Ze?(0,Q.jsx)(cn,{instance:Ze,definition:Ee.get(Ze.connectorId),onClose:()=>{re(null),ae(null)},onChanged:Y,t,mcp:n}):null,ce?(0,Q.jsx)(Mn,{open:!0,mode:ce.mode,initialRow:ce.row,existingCustomServers:J,sessionIdleTtlMinutes:W,config:K,managedServerIds:Oe,t:n,cs:t,onClose:()=>le(null),onSaved:async()=>{await ve(),await Y(),Se(`connected`)}},`${ce.mode}-${ce.row.clientKey}`):null,(0,Q.jsx)(yt,{open:ue,sessionIdleTtlMinutes:W,saving:he,onChange:pe,onSave:je,onClose:()=>de(!1),t,mcp:n})]})})}export{Wn as ConnectorsPage};