@xopcai/xopc 0.0.323 → 0.0.325

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 (572) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/extensions/weixin/src/plugin.js +1 -9
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DFzmThVi.js → agent-avatar-dicebear-CxfXpPWs.js} +1 -1
  5. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CDHe8gJf.js +1 -0
  6. package/dist/gateway/static/root/assets/{agent-plugin-dialog-DYFYiuig.js → agent-plugin-dialog-DMv-udoZ.js} +1 -1
  7. package/dist/gateway/static/root/assets/{agents-BqIlB5Co.js → agents-D_xOAXgj.js} +1 -1
  8. package/dist/gateway/static/root/assets/{app-management-settings-panel-BgvMRGWe.js → app-management-settings-panel-p7fZB4dT.js} +1 -1
  9. package/dist/gateway/static/root/assets/{appearance-settings-CliHU03A.js → appearance-settings-C-clVcfp.js} +1 -1
  10. package/dist/gateway/static/root/assets/apps-page-Dz2g7eAN.js +1 -0
  11. package/dist/gateway/static/root/assets/{archive-plugin-DnuPpm0u.js → archive-plugin-Xm6xChUX.js} +1 -1
  12. package/dist/gateway/static/root/assets/{attachment-load-BiwaK0ie.js → attachment-load-Di8kuG4L.js} +1 -1
  13. package/dist/gateway/static/root/assets/{automations-page-CJSISGQH.js → automations-page-GUZgDhKj.js} +1 -1
  14. package/dist/gateway/static/root/assets/automations-workspace-BUZhG9aJ.js +7 -0
  15. package/dist/gateway/static/root/assets/{binary-plugins-KDjduQZO.js → binary-plugins-OCrDjC9O.js} +1 -1
  16. package/dist/gateway/static/root/assets/{block-editor-bclvgove.js → block-editor-m9tqvu7x.js} +3 -3
  17. package/dist/gateway/static/root/assets/{browser-automation-inputs-CfQ2T9t6.js → browser-automation-inputs-DSWXq9lI.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-automations-page-Cxq38Nnp.js → browser-automations-page-DuOaridE.js} +2 -2
  19. package/dist/gateway/static/root/assets/browser-settings-page-D2_PgHep.js +3 -0
  20. package/dist/gateway/static/root/assets/capabilities-sAZT4brT.js +1 -0
  21. package/dist/gateway/static/root/assets/capabilities-settings-panel-7Y_pJqyt.js +8 -0
  22. package/dist/gateway/static/root/assets/channels-settings-B-Igy1ro.js +1 -0
  23. package/dist/gateway/static/root/assets/{chat-terminal-dock-DKQC62nQ.js → chat-terminal-dock-BfnVh8oo.js} +1 -1
  24. package/dist/gateway/static/root/assets/{computer-settings-page-D1whpIqL.js → computer-settings-page-aRG2lU4w.js} +1 -1
  25. package/dist/gateway/static/root/assets/{connector-service-page-BAuYTgf5.js → connector-service-page-B5EhnfJH.js} +1 -1
  26. package/dist/gateway/static/root/assets/connectors-page-7HfRt1LW.js +2 -0
  27. package/dist/gateway/static/root/assets/date-picker-CtDyij_x.js +1 -0
  28. package/dist/gateway/static/root/assets/{dependency-picker-DOuVO2M1.js → dependency-picker-z6ouWxmz.js} +1 -1
  29. package/dist/gateway/static/root/assets/{desktop-pet-D9tu6Bhu.js → desktop-pet-BsIYCAkG.js} +1 -1
  30. package/dist/gateway/static/root/assets/{desktop-pet-settings-CQPXub2f.js → desktop-pet-settings-z-0aQ5ct.js} +1 -1
  31. package/dist/gateway/static/root/assets/{device-pairing-wizard-DxkOYSut.js → device-pairing-wizard-DlmhQvY5.js} +1 -1
  32. package/dist/gateway/static/root/assets/dist-3h6cXXhT.js +1 -0
  33. package/dist/gateway/static/root/assets/{extension-debug-page-CtWClPz-.js → extension-debug-page-Ct9pABNW.js} +1 -1
  34. package/dist/gateway/static/root/assets/{extension-page-BHh9HLCz.js → extension-page-BktsR4hj.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-settings-page-BdT3v5Uh.js → extension-settings-page-BQJc-vXH.js} +1 -1
  36. package/dist/gateway/static/root/assets/{gateway-config-swr-1eqyz9vZ.js → gateway-config-swr-CoQVulMd.js} +1 -1
  37. package/dist/gateway/static/root/assets/{gateway-settings-CZas_Ekx.js → gateway-settings-BfDVlvy6.js} +1 -1
  38. package/dist/gateway/static/root/assets/{gateway-startup-retry-C4rsW6vJ.js → gateway-startup-retry-B5GJ-CQV.js} +1 -1
  39. package/dist/gateway/static/root/assets/home-page-CI_eQTPL.js +1 -0
  40. package/dist/gateway/static/root/assets/{image-generation-api-B5DXMylk.js → image-generation-api-DvWDkbk1.js} +1 -1
  41. package/dist/gateway/static/root/assets/{imports-page-B1JH0G5j.js → imports-page-DFpQfHVU.js} +1 -1
  42. package/dist/gateway/static/root/assets/index-19rMUT3d.js +121 -0
  43. package/dist/gateway/static/root/assets/{index-CNc4N4TX.css → index-BKL5tg2f.css} +1 -1
  44. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DGrLJ8Yh.js → keyboard-shortcuts-settings-ctJLm8TP.js} +1 -1
  45. package/dist/gateway/static/root/assets/local-app-workbench-page-C9kaP3Dy.js +1 -0
  46. package/dist/gateway/static/root/assets/{local-apps-page-DqjStqbL.js → local-apps-page-BxC_LTqq.js} +1 -1
  47. package/dist/gateway/static/root/assets/{locale-store-BIkcRr3t.js → locale-store-BPZR8x9b.js} +1 -1
  48. package/dist/gateway/static/root/assets/logs-page-Ok5SpG-G.js +2 -0
  49. package/dist/gateway/static/root/assets/{management-settings-gCfH4cwH.js → management-settings-aOzRaQHM.js} +1 -1
  50. package/dist/gateway/static/root/assets/{markdown-view-Ck_5MADq.js → markdown-view-Dft8ASFD.js} +1 -1
  51. package/dist/gateway/static/root/assets/{media-plugins-DTsZqgo6.js → media-plugins-ni5zJ4Ok.js} +1 -1
  52. package/dist/gateway/static/root/assets/messages-kFWhF6_t.js +3 -0
  53. package/dist/gateway/static/root/assets/note-detail-panel-C9OEltN9.js +5 -0
  54. package/dist/gateway/static/root/assets/notes-page-Dj9rMgdi.js +8 -0
  55. package/dist/gateway/static/root/assets/{page-context-capture-button-DTI_g4tz.js → page-context-capture-button-BJA3d8vU.js} +1 -1
  56. package/dist/gateway/static/root/assets/{page-tabs-CfW_Q-K5.js → page-tabs-Dyc3wKkl.js} +1 -1
  57. package/dist/gateway/static/root/assets/popover-select-DcsFzD_i.js +1 -0
  58. package/dist/gateway/static/root/assets/{preview-open-alternatives-CuPN-vAn.js → preview-open-alternatives-tIOIQbNX.js} +1 -1
  59. package/dist/gateway/static/root/assets/{product-open-page-BHjxRz1E.js → product-open-page-DQctU8z3.js} +1 -1
  60. package/dist/gateway/static/root/assets/project-detail-page-Dy-EwZcc.js +1 -0
  61. package/dist/gateway/static/root/assets/{projects-page-Bk-es4i9.js → projects-page-JaGKa6rM.js} +1 -1
  62. package/dist/gateway/static/root/assets/{registry-api-BAAZUGnU.js → registry-api-DWWO6ajd.js} +1 -1
  63. package/dist/gateway/static/root/assets/remote-access-hub-Cb8-nd60.js +1 -0
  64. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-CHJBJKL1.js → runtime-tools-settings-panel-xhOSYfiX.js} +1 -1
  65. package/dist/gateway/static/root/assets/scenes-page-ClBkFdRY.js +2 -0
  66. package/dist/gateway/static/root/assets/{schema-form-FQAit5HL.js → schema-form-z8IeSdBp.js} +1 -1
  67. package/dist/gateway/static/root/assets/sessions-page-BYW5l_nY.js +1 -0
  68. package/dist/gateway/static/root/assets/settings-advanced-gate-CDNwmXuH.js +1 -0
  69. package/dist/gateway/static/root/assets/{settings-form-section-BDc6bw1q.js → settings-form-section-BXTJAser.js} +1 -1
  70. package/dist/gateway/static/root/assets/{settings-page-DnhxBJjV.js → settings-page-Br9no5e4.js} +1 -1
  71. package/dist/gateway/static/root/assets/{settings-page-layout-D3KNSQ5g.js → settings-page-layout-D6745w0p.js} +1 -1
  72. package/dist/gateway/static/root/assets/setup-status-panel-D2N9764S.js +1 -0
  73. package/dist/gateway/static/root/assets/{share-preview-page-DVQCRxwK.js → share-preview-page-CE0SER59.js} +1 -1
  74. package/dist/gateway/static/root/assets/shares-settings-Dk3_QOKQ.js +1 -0
  75. package/dist/gateway/static/root/assets/skill-reload-api-CPt61fEv.js +1 -0
  76. package/dist/gateway/static/root/assets/skills-page-Db6PB2C6.js +2 -0
  77. package/dist/gateway/static/root/assets/{skills-page.utils-mDwC9UJ-.js → skills-page.utils-DrtW5FBy.js} +1 -1
  78. package/dist/gateway/static/root/assets/{system-settings-panel-Bk7GrMij.js → system-settings-panel-CuY1Zh5s.js} +1 -1
  79. package/dist/gateway/static/root/assets/task-detail-page-o7RiDUMi.js +1 -0
  80. package/dist/gateway/static/root/assets/{tunnel-api-D3Aquraj.js → tunnel-api-PGHDgvWb.js} +1 -1
  81. package/dist/gateway/static/root/assets/{use-autosave-C1xQ-sHn.js → use-autosave-B55oBQUt.js} +1 -1
  82. package/dist/gateway/static/root/assets/user-model-page-DspelwAa.js +2 -0
  83. package/dist/gateway/static/root/assets/{voice-api-key-field-DCNECvcp.js → voice-api-key-field-By6Lgbse.js} +1 -1
  84. package/dist/gateway/static/root/assets/{voice-config-api-B-_niUTU.js → voice-config-api-BaxITrwZ.js} +1 -1
  85. package/dist/gateway/static/root/assets/{work-discovery-overlay-BrGx_JS_.js → work-discovery-overlay-DdhgIlyf.js} +1 -1
  86. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-CmmC2Pdr.js → workflow-run-setup-panel-BOJYQaxX.js} +2 -2
  87. package/dist/gateway/static/root/assets/workflows-page-6ObD0IQZ.js +6 -0
  88. package/dist/gateway/static/root/index.html +11 -10
  89. package/dist/package.js +1 -1
  90. package/dist/packages/gateway-contract/src/home.js +284 -55
  91. package/dist/packages/gateway-contract/src/index.js +0 -2
  92. package/dist/packages/gateway-contract/src/notifications.js +3 -10
  93. package/dist/src/activity/emitter.js +2 -1
  94. package/dist/src/activity/service.js +2 -1
  95. package/dist/src/agent/agent-manager.d.ts +3 -2
  96. package/dist/src/agent/agent-manager.js +36 -44
  97. package/dist/src/agent/agent-scope.d.ts +19 -48
  98. package/dist/src/agent/agent-scope.js +47 -169
  99. package/dist/src/agent/background-review/run-background-review.js +5 -4
  100. package/dist/src/agent/bootstrap/filter-bootstrap-files.js +1 -1
  101. package/dist/src/agent/commands/command-registry.js +7 -3
  102. package/dist/src/agent/context/coordinator.js +1 -1
  103. package/dist/src/agent/context/execution-context.js +2 -1
  104. package/dist/src/agent/context/execution-scope.js +2 -1
  105. package/dist/src/agent/context/workspace-seed.d.ts +1 -2
  106. package/dist/src/agent/context/workspace-seed.js +3 -3
  107. package/dist/src/agent/context/workspace-state.js +1 -1
  108. package/dist/src/agent/embedded/run-for-session.js +2 -2
  109. package/dist/src/agent/embedded/run-turn.js +2 -1
  110. package/dist/src/agent/embedded/sqlite-hydrating-session-manager.js +2 -1
  111. package/dist/src/agent/external-tools/cliProvider.js +2 -1
  112. package/dist/src/agent/external-tools/composio-provider.js +2 -1
  113. package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
  114. package/dist/src/agent/external-tools/index.js +2 -3
  115. package/dist/src/agent/external-tools/mcp-provider.js +2 -2
  116. package/dist/src/agent/image/tool-model-config.js +4 -5
  117. package/dist/src/agent/inbound/attachment-pipeline.js +1 -1
  118. package/dist/src/agent/ipc/bus.js +1 -1
  119. package/dist/src/agent/ipc/socket.js +3 -3
  120. package/dist/src/agent/media-generation/runtime-shared.d.ts +1 -1
  121. package/dist/src/agent/media-generation/runtime-shared.js +1 -1
  122. package/dist/src/agent/memory/plugin-discovery.js +1 -2
  123. package/dist/src/agent/models/manager.d.ts +1 -1
  124. package/dist/src/agent/models/manager.js +2 -2
  125. package/dist/src/agent/orchestration/run-agent-turn-with-timeout.js +1 -1
  126. package/dist/src/agent/prompt/response-language.js +2 -1
  127. package/dist/src/agent/prompt/service-prompt-builder.js +6 -3
  128. package/dist/src/agent/prompt/system-prompt.js +2 -1
  129. package/dist/src/agent/reply/post-compaction-context.js +2 -2
  130. package/dist/src/agent/service/build-direct-message-content.js +1 -1
  131. package/dist/src/agent/service/direct-turn-helpers.js +2 -1
  132. package/dist/src/agent/service/parse-outbound-session-key.js +2 -1
  133. package/dist/src/agent/service/process-direct-streaming.js +3 -2
  134. package/dist/src/agent/service/webchat-tts.js +2 -1
  135. package/dist/src/agent/service.d.ts +1 -1
  136. package/dist/src/agent/service.js +12 -11
  137. package/dist/src/agent/service.types.d.ts +2 -0
  138. package/dist/src/agent/session/session-inspector.js +4 -5
  139. package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.d.ts +5 -0
  140. package/dist/src/agent/starter-agents.d.ts +4 -5
  141. package/dist/src/agent/starter-agents.js +21 -20
  142. package/dist/src/agent/tasks/task-judge-service.js +2 -2
  143. package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
  144. package/dist/src/agent/tool-manuals/xopc-use.js +31 -1
  145. package/dist/src/agent/tools/delegation-parent-policy.js +2 -3
  146. package/dist/src/agent/tools/factory.d.ts +2 -0
  147. package/dist/src/agent/tools/factory.js +10 -9
  148. package/dist/src/agent/tools/image-generate-tool.js +1 -1
  149. package/dist/src/agent/tools/workflow-tool.js +2 -3
  150. package/dist/src/agent/tools/xopc-use-tool.d.ts +3 -2
  151. package/dist/src/agent/tools/xopc-use-tool.js +54 -6
  152. package/dist/src/agent/workflow/workflow-child-tools.js +1 -2
  153. package/dist/src/agent/workspace-runtime/registry.d.ts +1 -1
  154. package/dist/src/agent/workspace-runtime/registry.js +2 -2
  155. package/dist/src/agent-catalog/capabilities.d.ts +3 -0
  156. package/dist/src/agent-catalog/capabilities.js +238 -0
  157. package/dist/src/agent-catalog/id.d.ts +15 -0
  158. package/dist/src/agent-catalog/id.js +101 -0
  159. package/dist/src/agent-catalog/index.d.ts +6 -0
  160. package/dist/src/agent-catalog/index.js +10 -0
  161. package/dist/src/agent-catalog/migrations/legacy-config-cutover.d.ts +11 -0
  162. package/dist/src/agent-catalog/migrations/legacy-config-cutover.js +195 -0
  163. package/dist/src/agent-catalog/repository.d.ts +39 -0
  164. package/dist/src/agent-catalog/repository.js +319 -0
  165. package/dist/src/agent-catalog/service.d.ts +33 -0
  166. package/dist/src/agent-catalog/service.js +202 -0
  167. package/dist/src/agent-catalog/test-support.d.ts +14 -0
  168. package/dist/src/agent-catalog/test-support.js +34 -0
  169. package/dist/src/agent-catalog/types.d.ts +26 -0
  170. package/dist/src/agent-catalog/types.js +1 -0
  171. package/dist/src/agent-config/index.js +2 -2
  172. package/dist/src/agent-config/schema.d.ts +1 -172
  173. package/dist/src/agent-config/schema.js +2 -41
  174. package/dist/src/auth/credentials.js +3 -3
  175. package/dist/src/auth/oauth/xopc-cloud.js +1 -1
  176. package/dist/src/auth/sync-provider-auth.d.ts +1 -1
  177. package/dist/src/auth/sync-provider-auth.js +5 -9
  178. package/dist/src/automations/capabilities/drafts.js +8 -7
  179. package/dist/src/automations/service/action-executor.js +2 -1
  180. package/dist/src/bootstrap/application-state.d.ts +10 -0
  181. package/dist/src/bootstrap/application-state.js +26 -0
  182. package/dist/src/browser/automations/repository.js +2 -1
  183. package/dist/src/browser/automations/schema.d.ts +1 -1
  184. package/dist/src/browser/automations/service.d.ts +1 -1
  185. package/dist/src/browser/native-messaging-host.js +5 -4
  186. package/dist/src/browser/providers/extension.js +4 -2
  187. package/dist/src/browser/providers/realtime-extension.js +2 -1
  188. package/dist/src/capabilities/readiness/from-config.js +7 -4
  189. package/dist/src/capabilities/runtime/dispatcher.d.ts +1 -0
  190. package/dist/src/capabilities/runtime/dispatcher.js +10 -4
  191. package/dist/src/capabilities/runtime/product.js +2 -0
  192. package/dist/src/channels/catalog/channel-catalog-service.js +7 -13
  193. package/dist/src/chat-commands/agent-edit.js +4 -3
  194. package/dist/src/chat-commands/builtins/config.js +6 -8
  195. package/dist/src/chat-commands/builtins/review.js +1 -1
  196. package/dist/src/chat-commands/builtins/workflow.js +1 -1
  197. package/dist/src/chat-commands/config-paths.js +1 -1
  198. package/dist/src/chat-commands/context.js +2 -3
  199. package/dist/src/chat-previews/store.js +2 -1
  200. package/dist/src/cli/command-manifest.js +1 -1
  201. package/dist/src/cli/commands/agent.js +4 -4
  202. package/dist/src/cli/commands/agents.d.ts +1 -1
  203. package/dist/src/cli/commands/agents.js +36 -48
  204. package/dist/src/cli/commands/auth.js +2 -1
  205. package/dist/src/cli/commands/browser-cli-helpers.js +1 -2
  206. package/dist/src/cli/commands/channels.js +2 -4
  207. package/dist/src/cli/commands/config.js +4 -5
  208. package/dist/src/cli/commands/connectors.js +1 -2
  209. package/dist/src/cli/commands/doctor/checks/channel-config.js +2 -4
  210. package/dist/src/cli/commands/doctor/checks/channel-pairing-pending.js +1 -2
  211. package/dist/src/cli/commands/doctor/checks/channel-plugins.js +1 -2
  212. package/dist/src/cli/commands/doctor/checks/config-health.js +1 -2
  213. package/dist/src/cli/commands/doctor/checks/database-schema.js +4 -4
  214. package/dist/src/cli/commands/doctor/checks/gateway-health.js +1 -2
  215. package/dist/src/cli/commands/doctor/checks/gateway-service.js +1 -2
  216. package/dist/src/cli/commands/doctor/checks/provider-auth.js +13 -11
  217. package/dist/src/cli/commands/doctor/checks/security-audit.js +1 -2
  218. package/dist/src/cli/commands/doctor/checks/session-integrity.js +3 -3
  219. package/dist/src/cli/commands/doctor/checks/tool-runtimes.js +1 -2
  220. package/dist/src/cli/commands/doctor/checks/workspace-status.js +5 -7
  221. package/dist/src/cli/commands/extension-agent-plugin.js +1 -2
  222. package/dist/src/cli/commands/extension-dev.js +2 -4
  223. package/dist/src/cli/commands/extension-marketplace.js +1 -2
  224. package/dist/src/cli/commands/extension-pack.js +1 -2
  225. package/dist/src/cli/commands/extension.js +1 -2
  226. package/dist/src/cli/commands/gateway/run-foreground.js +3 -3
  227. package/dist/src/cli/commands/gateway/shared.js +1 -1
  228. package/dist/src/cli/commands/history.js +2 -1
  229. package/dist/src/cli/commands/image.js +2 -2
  230. package/dist/src/cli/commands/init.js +11 -30
  231. package/dist/src/cli/commands/mcp.js +1 -2
  232. package/dist/src/cli/commands/models.js +13 -11
  233. package/dist/src/cli/commands/onboard/channels/registry.js +1 -2
  234. package/dist/src/cli/commands/onboard/gateway.js +1 -2
  235. package/dist/src/cli/commands/onboard/model.d.ts +1 -1
  236. package/dist/src/cli/commands/onboard/model.js +18 -26
  237. package/dist/src/cli/commands/onboard.js +4 -2
  238. package/dist/src/cli/commands/platform.js +1 -0
  239. package/dist/src/cli/commands/project.js +3 -3
  240. package/dist/src/cli/commands/providers.js +2 -1
  241. package/dist/src/cli/commands/runtime.js +1 -2
  242. package/dist/src/cli/commands/search.js +1 -2
  243. package/dist/src/cli/commands/skills.js +1 -2
  244. package/dist/src/cli/commands/tui-runner.js +3 -2
  245. package/dist/src/cli/commands/tui.js +6 -8
  246. package/dist/src/cli/commands/tunnel.js +1 -1
  247. package/dist/src/cli/commands/voice.js +1 -2
  248. package/dist/src/cli/extension-cli-register.js +1 -1
  249. package/dist/src/cli/index.js +4 -2
  250. package/dist/src/cli/utils/gateway-client.js +1 -1
  251. package/dist/src/cli/utils/init-workspace-core.js +15 -16
  252. package/dist/src/cli/utils/session.js +1 -2
  253. package/dist/src/computer/model-config.d.ts +3 -3
  254. package/dist/src/computer/model-config.js +10 -20
  255. package/dist/src/computer/runtime.js +1 -1
  256. package/dist/src/config/agent-model-intents.js +2 -2
  257. package/dist/src/config/agent-profile.d.ts +5 -6
  258. package/dist/src/config/agent-profile.js +19 -19
  259. package/dist/src/config/config-surface.d.ts +0 -3
  260. package/dist/src/config/default-model.js +2 -6
  261. package/dist/src/config/index.js +7 -8
  262. package/dist/src/config/loader.js +12 -18
  263. package/dist/src/config/models-json.d.ts +6 -6
  264. package/dist/src/config/paths.d.ts +18 -19
  265. package/dist/src/config/paths.js +35 -35
  266. package/dist/src/config/reload.d.ts +0 -1
  267. package/dist/src/config/reload.js +1 -6
  268. package/dist/src/config/rules.js +0 -15
  269. package/dist/src/config/schema.d.ts +3 -406
  270. package/dist/src/config/schema.js +24 -86
  271. package/dist/src/config/validate-channel-configs.js +8 -14
  272. package/dist/src/config/workspace-dirs.d.ts +3 -4
  273. package/dist/src/config/workspace-dirs.js +9 -8
  274. package/dist/src/config/workspace-path-helpers.d.ts +1 -1
  275. package/dist/src/config/workspace-path-helpers.js +2 -2
  276. package/dist/src/connectors/cli/lifecycle.js +2 -1
  277. package/dist/src/connectors/composio-managed-events.js +2 -1
  278. package/dist/src/connectors/connected-source-ingestion.js +2 -1
  279. package/dist/src/connectors/connected-source-understanding.js +4 -2
  280. package/dist/src/connectors/content-enrichment.js +2 -1
  281. package/dist/src/connectors/learning-coordinator.js +2 -1
  282. package/dist/src/connectors/runtime-adapter-registry.js +2 -1
  283. package/dist/src/connectors/workflow-preflight.d.ts +8 -1
  284. package/dist/src/connectors/workflow-preflight.js +11 -3
  285. package/dist/src/discussions/analyzer.js +2 -2
  286. package/dist/src/endpoint-tools/runtime.js +2 -1
  287. package/dist/src/execution-environments/subject.js +2 -1
  288. package/dist/src/extensions/activation-context.js +3 -16
  289. package/dist/src/extensions/agent-plugins/validation.js +1 -1
  290. package/dist/src/extensions/discover-extensions.js +9 -15
  291. package/dist/src/extensions/extension-metadata-snapshot.d.ts +1 -1
  292. package/dist/src/extensions/extension-metadata-snapshot.js +9 -16
  293. package/dist/src/extensions/index.js +4 -10
  294. package/dist/src/extensions/install.js +1 -1
  295. package/dist/src/extensions/loader.js +7 -14
  296. package/dist/src/extensions/manifest-registry.js +93 -98
  297. package/dist/src/extensions/marketplace.js +5 -2
  298. package/dist/src/extensions/normalize-manifest.js +12 -17
  299. package/dist/src/extensions/update.js +1 -2
  300. package/dist/src/files/file-service.js +7 -8
  301. package/dist/src/gateway/agents-admin.d.ts +23 -27
  302. package/dist/src/gateway/agents-admin.js +109 -130
  303. package/dist/src/gateway/file-path-classifier.js +3 -3
  304. package/dist/src/gateway/file-space-service.js +2 -1
  305. package/dist/src/gateway/global-defaults-admin.d.ts +6 -4
  306. package/dist/src/gateway/global-defaults-admin.js +21 -20
  307. package/dist/src/gateway/hono/app.js +2 -1
  308. package/dist/src/gateway/hono/lib/config-payload.js +12 -9
  309. package/dist/src/gateway/hono/middleware/auth.js +2 -1
  310. package/dist/src/gateway/hono/middleware/scopes.js +2 -1
  311. package/dist/src/gateway/hono/routes/agents.js +22 -49
  312. package/dist/src/gateway/hono/routes/browser.js +4 -2
  313. package/dist/src/gateway/hono/routes/channels.js +1 -2
  314. package/dist/src/gateway/hono/routes/cli-connectors.js +2 -1
  315. package/dist/src/gateway/hono/routes/commands-skills.js +3 -1
  316. package/dist/src/gateway/hono/routes/composer-history.js +2 -1
  317. package/dist/src/gateway/hono/routes/config-patch/index.d.ts +1 -3
  318. package/dist/src/gateway/hono/routes/config-patch/index.js +1 -2
  319. package/dist/src/gateway/hono/routes/config-patch/misc.js +18 -11
  320. package/dist/src/gateway/hono/routes/config.js +0 -2
  321. package/dist/src/gateway/hono/routes/connectors.js +8 -4
  322. package/dist/src/gateway/hono/routes/context-sources.js +4 -3
  323. package/dist/src/gateway/hono/routes/device-pairing-approval.js +2 -1
  324. package/dist/src/gateway/hono/routes/device-push.js +3 -2
  325. package/dist/src/gateway/hono/routes/devices.js +6 -3
  326. package/dist/src/gateway/hono/routes/discussions.js +2 -1
  327. package/dist/src/gateway/hono/routes/endpoint-tools.js +2 -1
  328. package/dist/src/gateway/hono/routes/global-defaults.js +8 -16
  329. package/dist/src/gateway/hono/routes/home.js +93 -4
  330. package/dist/src/gateway/hono/routes/interaction-state.js +2 -1
  331. package/dist/src/gateway/hono/routes/models.js +8 -7
  332. package/dist/src/gateway/hono/routes/notes.js +4 -5
  333. package/dist/src/gateway/hono/routes/projects.js +6 -6
  334. package/dist/src/gateway/hono/routes/public-gateway.js +2 -1
  335. package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
  336. package/dist/src/gateway/hono/routes/sessions.js +4 -2
  337. package/dist/src/gateway/hono/routes/shares.js +4 -3
  338. package/dist/src/gateway/hono/routes/site-shares.js +2 -2
  339. package/dist/src/gateway/hono/routes/status.js +2 -3
  340. package/dist/src/gateway/hono/routes/tasks.js +1 -2
  341. package/dist/src/gateway/hono/routes/user-model-refresh.js +2 -1
  342. package/dist/src/gateway/hono/routes/user-model.js +3 -2
  343. package/dist/src/gateway/hono/routes/work-discovery.js +1 -1
  344. package/dist/src/gateway/hono/routes/workflows.js +2 -2
  345. package/dist/src/gateway/image-generation-setup.d.ts +19 -10
  346. package/dist/src/gateway/image-generation-setup.js +59 -23
  347. package/dist/src/gateway/index.js +1 -4
  348. package/dist/src/gateway/lock.js +13 -18
  349. package/dist/src/gateway/memory-maintenance-automation-reconciler.js +4 -3
  350. package/dist/src/gateway/run-loop.js +2 -3
  351. package/dist/src/gateway/security/gateway-scopes.js +6 -2
  352. package/dist/src/gateway/security/index.js +4 -1
  353. package/dist/src/gateway/service/agent-runner.js +4 -2
  354. package/dist/src/gateway/service/app-context-access.js +2 -1
  355. package/dist/src/gateway/service/config-coordinator.d.ts +0 -1
  356. package/dist/src/gateway/service/config-coordinator.js +4 -22
  357. package/dist/src/gateway/service/marketplace-service.js +3 -1
  358. package/dist/src/gateway/service/run-gateway-agent.js +4 -2
  359. package/dist/src/gateway/service/session-input-coordinator.js +4 -2
  360. package/dist/src/gateway/service.d.ts +5 -0
  361. package/dist/src/gateway/service.js +109 -33
  362. package/dist/src/gateway/session-context-summary.js +4 -2
  363. package/dist/src/gateway/xopc-cloud-capability-setup.d.ts +2 -0
  364. package/dist/src/gateway/xopc-cloud-capability-setup.js +15 -10
  365. package/dist/src/home-intelligence/application-service.d.ts +31 -0
  366. package/dist/src/home-intelligence/application-service.js +134 -0
  367. package/dist/src/home-intelligence/capability-preflight.d.ts +32 -0
  368. package/dist/src/home-intelligence/capability-preflight.js +118 -0
  369. package/dist/src/home-intelligence/evaluation.d.ts +34 -0
  370. package/dist/src/home-intelligence/evaluation.js +49 -0
  371. package/dist/src/home-intelligence/generator.d.ts +125 -0
  372. package/dist/src/home-intelligence/generator.js +227 -0
  373. package/dist/src/home-intelligence/host.d.ts +53 -0
  374. package/dist/src/home-intelligence/host.js +257 -0
  375. package/dist/src/home-intelligence/notification.d.ts +8 -0
  376. package/dist/src/home-intelligence/notification.js +20 -0
  377. package/dist/src/home-intelligence/policy.d.ts +16 -0
  378. package/dist/src/home-intelligence/policy.js +152 -0
  379. package/dist/src/home-intelligence/repository.d.ts +81 -0
  380. package/dist/src/home-intelligence/repository.js +495 -0
  381. package/dist/src/home-intelligence/snapshot.d.ts +43 -0
  382. package/dist/src/home-intelligence/snapshot.js +133 -0
  383. package/dist/src/home-intelligence/strategy.d.ts +14 -0
  384. package/dist/src/home-intelligence/strategy.js +10 -0
  385. package/dist/src/home-intelligence/types.d.ts +13 -0
  386. package/dist/src/home-intelligence/types.js +1 -0
  387. package/dist/src/infra/update-restart.js +4 -2
  388. package/dist/src/knowledge/connected-knowledge-pipeline.js +2 -1
  389. package/dist/src/knowledge/ingestion-service.js +2 -1
  390. package/dist/src/knowledge-memory/repository.js +2 -1
  391. package/dist/src/local-apps/service.js +1 -1
  392. package/dist/src/local-apps/store.js +2 -1
  393. package/dist/src/mcp/channel-bridge.js +1 -2
  394. package/dist/src/mcp/channel-server.js +1 -2
  395. package/dist/src/mcp/gateway-http-client.js +1 -2
  396. package/dist/src/media/session-references.js +2 -1
  397. package/dist/src/memory-maintenance/service.js +2 -1
  398. package/dist/src/migrations/memory-config.js +1 -2
  399. package/dist/src/notes/agent-context.js +2 -1
  400. package/dist/src/notes/attachment-ref.js +8 -4
  401. package/dist/src/notes/note-attachment-sync.js +2 -1
  402. package/dist/src/notes/note-index-meta.js +14 -7
  403. package/dist/src/notes/note-markdown.js +13 -7
  404. package/dist/src/notes/service.js +6 -3
  405. package/dist/src/notes/store.js +4 -2
  406. package/dist/src/notifications/device-store.js +1 -1
  407. package/dist/src/notifications/planner.js +24 -0
  408. package/dist/src/notifications/service.d.ts +7 -14
  409. package/dist/src/notifications/service.js +13 -3
  410. package/dist/src/notifications/store.js +1 -1
  411. package/dist/src/notifications/types.d.ts +1 -1
  412. package/dist/src/notifications/types.js +1 -1
  413. package/dist/src/projects/capabilities/write.js +2 -1
  414. package/dist/src/projects/project-agent-suggestion.js +1 -1
  415. package/dist/src/projects/project-agent.js +4 -4
  416. package/dist/src/projects/project-service.js +2 -1
  417. package/dist/src/projects/workspace.js +3 -2
  418. package/dist/src/providers/index.js +3 -3
  419. package/dist/src/providers/model-reference-auditor.d.ts +1 -2
  420. package/dist/src/providers/model-reference-auditor.js +8 -5
  421. package/dist/src/realtime/runtime.js +2 -1
  422. package/dist/src/routing/binding-schema.d.ts +41 -0
  423. package/dist/src/routing/binding-schema.js +26 -0
  424. package/dist/src/routing/bindings.d.ts +4 -2
  425. package/dist/src/routing/bindings.js +4 -4
  426. package/dist/src/routing/index.d.ts +1 -1
  427. package/dist/src/routing/resolve-route.d.ts +7 -24
  428. package/dist/src/routing/resolve-route.js +17 -18
  429. package/dist/src/routing/resolve-tui-session-key.d.ts +1 -4
  430. package/dist/src/routing/resolve-tui-session-key.js +10 -9
  431. package/dist/src/scenes/execution.d.ts +1 -1
  432. package/dist/src/scenes/model.js +1 -1
  433. package/dist/src/scenes/taskFollowUp/contracts.d.ts +1 -1
  434. package/dist/src/scenes/taskFollowUp/service.js +6 -4
  435. package/dist/src/scenes/templates.d.ts +2 -2
  436. package/dist/src/session/config-store.js +2 -1
  437. package/dist/src/session/init-session-turn.js +2 -1
  438. package/dist/src/session/resolve-session.js +2 -1
  439. package/dist/src/session/session-workspace.js +1 -1
  440. package/dist/src/session/store.js +3 -2
  441. package/dist/src/storage/sqlite/activity-repository.js +6 -2
  442. package/dist/src/storage/sqlite/browser-tab-binding-repository.js +6 -2
  443. package/dist/src/storage/sqlite/clarification-wait-repository.js +13 -8
  444. package/dist/src/storage/sqlite/collaboration-rule-repository.d.ts +1 -1
  445. package/dist/src/storage/sqlite/collaboration-rule-repository.js +8 -3
  446. package/dist/src/storage/sqlite/composer-input-history-repository.js +8 -3
  447. package/dist/src/storage/sqlite/config-repository.js +9 -5
  448. package/dist/src/storage/sqlite/connector-learning-repository.js +6 -2
  449. package/dist/src/storage/sqlite/connector-sync-policy-repository.js +6 -2
  450. package/dist/src/storage/sqlite/context-evidence-repository.js +8 -3
  451. package/dist/src/storage/sqlite/context-extraction-repository.js +8 -3
  452. package/dist/src/storage/sqlite/device-access-repository.js +15 -9
  453. package/dist/src/storage/sqlite/device-pairing-approval.js +6 -2
  454. package/dist/src/storage/sqlite/device-pairing-repository.js +10 -5
  455. package/dist/src/storage/sqlite/endpoint-principal-repository.js +6 -2
  456. package/dist/src/storage/sqlite/endpoint-session-binding-repository.js +6 -2
  457. package/dist/src/storage/sqlite/endpoint-tool-invocation-repository.js +6 -2
  458. package/dist/src/storage/sqlite/gateway-identity-repository.js +6 -2
  459. package/dist/src/storage/sqlite/home-attention-repository.js +6 -2
  460. package/dist/src/storage/sqlite/index.d.ts +0 -1
  461. package/dist/src/storage/sqlite/index.js +72 -42
  462. package/dist/src/storage/sqlite/interaction-state-repository.js +10 -4
  463. package/dist/src/storage/sqlite/knowledge-repository.js +6 -2
  464. package/dist/src/storage/sqlite/migrations/203_remove_retired_proactive_contracts.sql +70 -0
  465. package/dist/src/storage/sqlite/migrations/204_home_intelligence.sql +78 -0
  466. package/dist/src/storage/sqlite/migrations/205_agent_catalog.sql +66 -0
  467. package/dist/src/storage/sqlite/migrations/206_home_advice_strategy_version.sql +3 -0
  468. package/dist/src/storage/sqlite/migrations/conversation-backup.d.ts +2 -0
  469. package/dist/src/storage/sqlite/migrations/conversation-backup.js +8 -4
  470. package/dist/src/storage/sqlite/migrations/conversation-windows-owners.d.ts +7 -1
  471. package/dist/src/storage/sqlite/migrations/conversation-windows-owners.js +2 -2
  472. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  473. package/dist/src/storage/sqlite/migrations/runner.js +4 -4
  474. package/dist/src/storage/sqlite/note-agent-context-repository.js +6 -2
  475. package/dist/src/storage/sqlite/notes-repository.js +9 -4
  476. package/dist/src/storage/sqlite/schema.js +1 -1
  477. package/dist/src/storage/sqlite/session-task-plan-repository.js +14 -9
  478. package/dist/src/storage/sqlite/session-turn-replace-repository.js +9 -5
  479. package/dist/src/storage/sqlite/sidebar-layout-repository.js +14 -9
  480. package/dist/src/storage/sqlite/transcript-repository.js +10 -6
  481. package/dist/src/storage/sqlite/user-people-repository.js +8 -3
  482. package/dist/src/storage/sqlite/user-trust-repository.js +8 -3
  483. package/dist/src/tasks/attention-governor.d.ts +0 -1
  484. package/dist/src/tasks/attention-governor.js +1 -7
  485. package/dist/src/tasks/capabilities/read.js +2 -2
  486. package/dist/src/tasks/capabilities/write.d.ts +1 -1
  487. package/dist/src/tasks/execution-context.d.ts +2 -2
  488. package/dist/src/tasks/execution-context.js +6 -5
  489. package/dist/src/tasks/home-query-service.d.ts +3 -2
  490. package/dist/src/tasks/home-query-service.js +23 -44
  491. package/dist/src/tasks/task-context-assembler.js +2 -1
  492. package/dist/src/tasks/task-context-repository.d.ts +1 -1
  493. package/dist/src/tasks/task-contract-planner.d.ts +0 -3
  494. package/dist/src/tasks/task-contract-planner.js +1 -4
  495. package/dist/src/tasks/task-handoff-service.d.ts +0 -2
  496. package/dist/src/tasks/task-handoff-service.js +3 -3
  497. package/dist/src/tasks/task-value-metrics-service.js +2 -1
  498. package/dist/src/tui/backends/embedded-backend.js +12 -14
  499. package/dist/src/tui/extension-host/load-extensions.js +1 -1
  500. package/dist/src/tui/tui-commands.js +5 -3
  501. package/dist/src/tui/tui-skills-autocomplete.js +1 -1
  502. package/dist/src/tui/tui-startup-resources.js +3 -3
  503. package/dist/src/tui/tui.js +5 -5
  504. package/dist/src/tunnel/registration-proof.js +2 -1
  505. package/dist/src/user-context/access-policy.js +2 -1
  506. package/dist/src/user-context/domain.d.ts +1 -1
  507. package/dist/src/user-context/domain.js +18 -13
  508. package/dist/src/user-context/extraction/registry.js +2 -1
  509. package/dist/src/user-context/interaction-state.js +4 -1
  510. package/dist/src/user-context/relationship-continuity.js +2 -1
  511. package/dist/src/user-context/trust-policy.js +13 -8
  512. package/dist/src/user-model/bootstrap.js +2 -1
  513. package/dist/src/user-model/capture/executor.js +4 -2
  514. package/dist/src/user-model/capture/semantic.d.ts +1 -1
  515. package/dist/src/user-model/capture/semantic.js +1 -1
  516. package/dist/src/user-model/domain.js +7 -2
  517. package/dist/src/user-model/goals.js +2 -1
  518. package/dist/src/user-model/index.js +4 -1
  519. package/dist/src/user-model/repository.js +2 -1
  520. package/dist/src/utils/helpers.js +1 -4
  521. package/dist/src/utils/index.js +2 -2
  522. package/dist/src/utils/logger/index.d.ts +1 -1
  523. package/dist/src/utils/logger/index.js +2 -2
  524. package/dist/src/utils/logger/redact.d.ts +2 -0
  525. package/dist/src/utils/logger/redact.js +11 -3
  526. package/dist/src/utils/logger.js +2 -2
  527. package/dist/src/voice/realtime/memory-context.js +2 -1
  528. package/dist/src/voice/realtime/persona-context.js +6 -6
  529. package/dist/src/voice/tts/audio.js +1 -1
  530. package/dist/src/work-discovery/analyzer.js +3 -3
  531. package/dist/src/work-discovery/investigator.js +1 -1
  532. package/dist/src/work-discovery/service.js +12 -11
  533. package/dist/src/workflows/draft/workflow-draft-service.js +1 -1
  534. package/dist/src/workflows/service/workflow-run-service.js +4 -5
  535. package/dist/src/workflows/store/paths.js +1 -1
  536. package/package.json +5 -5
  537. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CAFHadiy.js +0 -1
  538. package/dist/gateway/static/root/assets/apps-page-Drt3Foi9.js +0 -1
  539. package/dist/gateway/static/root/assets/automations-workspace-B-Eduqwz.js +0 -7
  540. package/dist/gateway/static/root/assets/browser-settings-page-Dwgir6mu.js +0 -3
  541. package/dist/gateway/static/root/assets/capabilities-settings-panel-H5L5vynP.js +0 -8
  542. package/dist/gateway/static/root/assets/capabilities-uFKh3Hd0.js +0 -1
  543. package/dist/gateway/static/root/assets/channels-settings-RFBRYe5S.js +0 -1
  544. package/dist/gateway/static/root/assets/connectors-page-Px-v3Q6Q.js +0 -2
  545. package/dist/gateway/static/root/assets/date-picker-CfCo3lqh.js +0 -1
  546. package/dist/gateway/static/root/assets/home-page-w3_aWeNt.js +0 -1
  547. package/dist/gateway/static/root/assets/index--3c0awkr.js +0 -121
  548. package/dist/gateway/static/root/assets/local-app-workbench-page-BYKrJpFF.js +0 -1
  549. package/dist/gateway/static/root/assets/logs-page-Dl4kM4Na.js +0 -2
  550. package/dist/gateway/static/root/assets/messages-7VAhscYe.js +0 -3
  551. package/dist/gateway/static/root/assets/note-detail-panel-j6sioeL1.js +0 -5
  552. package/dist/gateway/static/root/assets/notes-page-CMvvHv0f.js +0 -8
  553. package/dist/gateway/static/root/assets/popover-select-B-GDnZO9.js +0 -1
  554. package/dist/gateway/static/root/assets/project-detail-page-C9K_e-EV.js +0 -1
  555. package/dist/gateway/static/root/assets/remote-access-hub-CLGJNA42.js +0 -1
  556. package/dist/gateway/static/root/assets/scenes-page-ClLAD1pz.js +0 -2
  557. package/dist/gateway/static/root/assets/sessions-page-Xj8MkXN1.js +0 -1
  558. package/dist/gateway/static/root/assets/settings-advanced-gate-DwALV8mi.js +0 -1
  559. package/dist/gateway/static/root/assets/setup-status-panel-F0rCQ-2a.js +0 -1
  560. package/dist/gateway/static/root/assets/shares-settings-C7hf6Cov.js +0 -1
  561. package/dist/gateway/static/root/assets/skill-reload-api-xPrFejRE.js +0 -1
  562. package/dist/gateway/static/root/assets/skills-page-RdDYu7Yj.js +0 -2
  563. package/dist/gateway/static/root/assets/task-detail-page-2A966jFY.js +0 -1
  564. package/dist/gateway/static/root/assets/user-model-page-CnBxPBVe.js +0 -2
  565. package/dist/gateway/static/root/assets/workflows-page-BZVpqw4T.js +0 -6
  566. package/dist/packages/gateway-contract/src/proactive.js +0 -136
  567. package/dist/src/commands/agents.config.d.ts +0 -31
  568. package/dist/src/commands/agents.config.js +0 -129
  569. package/dist/src/gateway/hono/routes/config-patch/agents.d.ts +0 -2
  570. package/dist/src/gateway/hono/routes/config-patch/agents.js +0 -6
  571. package/dist/src/storage/sqlite/relationship-settings-repository.d.ts +0 -17
  572. package/dist/src/storage/sqlite/relationship-settings-repository.js +0 -65
@@ -0,0 +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{f as i,m as a}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as o}from"./popover-select-DcsFzD_i.js";import{t as s}from"./circle-check-C23XjkUj.js";import{t as c}from"./x-B_N4OPjy.js";import{t as l}from"./cn-JdwAhgNB.js";import{a as u,c as d,i as f,n as p,r as m}from"./locale-store-BPZR8x9b.js";import{t as h}from"./messages-kFWhF6_t.js";import{a as g,i as _,n as v,o as y,r as b,s as x,t as S}from"./dist-BGTk37IG.js";import{i as C}from"./vendor-swr-BIWyz7Rc.js";import{t as w}from"./button-CS04eWY9.js";import{t as T}from"./skeleton-BwbyijEw.js";import{i as E,o as D}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as O}from"./settings-shell-layer-context-BTQUDoJ2.js";import{$c as k,Ac as A,Cn as j,Dn as M,En as N,Fa as P,Fu as ee,Io as F,Ks as I,Ma as L,On as R,Ul as z,gi as B,od as V,ol as te,ul as ne,ya as re,zc as ie}from"./index-19rMUT3d.js";import{n as ae,r as oe}from"./settings-page-layout-D6745w0p.js";import{t as se}from"./browser-BLJWD7WI.js";import{n as ce}from"./settings-loading-skeleton-CAmWMaOT.js";import{t as le}from"./schema-form-z8IeSdBp.js";var H=e(t(),1),U=n();async function ue(){return(await u(m(`/api/channels/status`))).payload?.channels||[]}function de(){return m(`/api/channels/status`)}var fe=ue;function pe(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}var me=e(se(),1),W=r();async function G(e){let t=await f(m(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function K(e){return e?.type===`poll`&&e.phase===`done`}function q(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function J(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function he(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function ge({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,H.useMemo)(()=>pe(e),[e]),o=(0,H.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[c,u]=(0,H.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,H.useEffect)(()=>{u({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let d=(0,H.useCallback)(async(n,i)=>{u(e=>({...e,busy:!0,error:null}));try{let a=await G({channelId:e.id,actionId:n,locale:t,input:i});u(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.conversationId?{actionId:a.statusAction,conversationId:a.conversationId,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){u(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,H.useEffect)(()=>{let t=J(c.payload,e.id);if(!t){u(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return u(e=>e.generatedQr?{...e,generatedQr:null}:e),me.toDataURL(t,{width:220,margin:1}).then(e=>{n||u(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,c.payload]),(0,H.useEffect)(()=>{let n=c.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||G({channelId:e.id,actionId:n.actionId,locale:t,input:{conversationId:n.conversationId}}).then(async e=>{i||(u(t=>({...t,payload:e,poll:K(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),K(e)&&window.clearInterval(a))}).catch(e=>{i||u(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,c.poll]);let f=a?.[1].label??(e.configured?n.reconnect:n.connect),p=e.actions?.[`doctor.run`]?.label??n.diagnose,m=q(c.payload),h=J(c.payload,e.id),g=h?c.generatedQr:he(c.payload),_=a?.[1].result===`qr`&&(c.busy||c.payload?.type===`qr`||c.payload?.type===`poll`),v=c.payload?.type===`form`?c.payload:null,y=c.payload?.type===`diagnostics`?c.payload.checks:null;return(0,W.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:l(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,W.jsxs)(w,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void d(a[0]),children:[c.busy?(0,W.jsx)(z,{className:`size-4 animate-spin`}):(0,W.jsx)(ne,{className:`size-4`}),f]}):null,e.actions?.[`doctor.run`]?(0,W.jsxs)(w,{type:`button`,variant:`secondary`,disabled:c.busy,onClick:()=>void d(`doctor.run`),children:[(0,W.jsx)(ie,{className:`size-4`}),p]}):null]})]}),m?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:m}):null,c.error?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:c.error}):null,_?(0,W.jsxs)(`div`,{className:l(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg bg-surface-base p-3 shadow-surface`,i?`mt-1 flex-col text-center sm:h-64 sm:flex-row sm:text-left`:`mt-4 flex-col sm:h-64 sm:flex-row`),children:[(0,W.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:g?(0,W.jsx)(`img`,{src:g,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,W.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,W.jsx)(T,{className:`size-48 rounded-md`})})}),(0,W.jsxs)(`div`,{className:l(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[g?(0,W.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,W.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,W.jsx)(T,{className:`h-4 w-48 max-w-full`}),(0,W.jsx)(T,{className:`h-4 w-36 max-w-full`})]}),h?(0,W.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:h,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,W.jsx)(ee,{className:`size-3.5`})]}):null]})]}):null,c.payload?.type===`poll`&&c.payload.phase===`done`?(0,W.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg bg-surface-base px-3 py-2 text-sm shadow-surface`,children:[(0,W.jsx)(s,{className:c.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,W.jsx)(`span`,{className:c.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:c.payload.message??(c.payload.ok?n.complete:n.failed)})]}):null,v?(0,W.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,W.jsx)(le,{schema:v.schema,values:c.formDraft,onChange:e=>u(t=>({...t,formDraft:e})),disabled:c.busy,labels:o}),(0,W.jsx)(w,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void d(v.submitAction,c.formDraft),children:n.saveSetup})]}):null,y?(0,W.jsx)(`div`,{className:`mt-4 space-y-2`,children:y.map((e,t)=>(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var Y=40;function _e(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function ve(e,t){return e.find(e=>e.id===_e(t))?.agentId?.trim().toLowerCase()??``}function ye(e,t,n){let r=_e(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:Y,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function be(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function xe(e,t,n){let r=be(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function Se(e,t=!1){return e===`drawer`?l(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-overlay shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,E):l(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`h-[min(calc(100dvh-2rem),48rem)] w-[min(calc(100%-2rem),36rem)]`,E,`rounded-2xl border border-edge bg-surface-overlay outline-none dark:border-edge`)}function Ce(e){let t=(0,U.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:s,srDescription:u,closeAriaLabel:d,children:f,footer:p,wide:m,headerExtra:h}=e,C=m===void 0?!1:m,T=n===`drawer`,[E,k]=(0,H.useState)(null),A;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,W.jsx)(g,{className:l(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,D)}),t[0]=A):A=t[0];let j;t[1]!==n||t[2]!==C?(j=Se(n,C),t[1]=n,t[2]=C,t[3]=j):j=t[3];let M;t[4]===s?M=t[5]:(M=s?(0,W.jsx)(x,{className:`sr-only`,children:s}):null,t[4]=s,t[5]=M);let N;t[6]===u?N=t[7]:(N=u?(0,W.jsx)(_,{className:`sr-only`,children:u}):null,t[6]=u,t[7]=N);let P;t[8]!==d||t[9]!==o||t[10]!==h||t[11]!==T||t[12]!==a?(P=T?(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,W.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,W.jsx)(v,{asChild:!0,children:(0,W.jsx)(w,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":d,children:(0,W.jsx)(c,{className:`size-5`,strokeWidth:1.75})})})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(v,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,className:l(I,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":d,children:(0,W.jsx)(c,{className:`size-4`})})}),h]}),t[8]=d,t[9]=o,t[10]=h,t[11]=T,t[12]=a,t[13]=P):P=t[13];let ee=T?`p-4`:`p-6`,F;t[14]===ee?F=t[15]:(F=l(`min-h-0 flex-1 overflow-y-auto`,ee),t[14]=ee,t[15]=F);let L;t[16]!==f||t[17]!==F?(L=(0,W.jsx)(`div`,{className:F,children:f}),t[16]=f,t[17]=F,t[18]=L):L=t[18];let R;t[19]!==p||t[20]!==E||t[21]!==M||t[22]!==N||t[23]!==P||t[24]!==L?(R=(0,W.jsxs)(O,{layer:`modal`,portalContainer:E,children:[M,N,P,L,p]}),t[19]=p,t[20]=E,t[21]=M,t[22]=N,t[23]=P,t[24]=L,t[25]=R):R=t[25];let z;t[26]!==R||t[27]!==j?(z=(0,W.jsxs)(y,{children:[A,(0,W.jsx)(b,{ref:k,className:j,onOpenAutoFocus:we,children:R})]}),t[26]=R,t[27]=j,t[28]=z):z=t[28];let B;return t[29]!==i||t[30]!==r||t[31]!==z?(B=(0,W.jsx)(S,{open:r,onOpenChange:i,children:z}),t[29]=i,t[30]=r,t[31]=z,t[32]=B):B=t[32],B}function we(e){return e.preventDefault()}var Te=(0,H.memo)(function(e){let t=(0,U.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,W.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,W.jsx)(re,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,W.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function Ee(e){let t=(0,U.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,W.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,W.jsx)(w,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,W.jsx)(w,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,W.jsx)(w,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,W.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,W.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}function De(e){return m(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function Oe(e){return(await u(De(e))).payload?.channels??[]}function ke(e,t){let n=(0,U.c)(14),r;n[0]!==e||n[1]!==t?(r=e?De(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>Oe(t),n[3]=t,n[4]=i);let a;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},n[5]=a):a=n[5];let{data:o,error:s,isLoading:c,isValidating:l,mutate:u}=C(r,i,a),d;n[6]===o?d=n[7]:(d=o??[],n[6]=o,n[7]=d);let f;return n[8]!==s||n[9]!==c||n[10]!==l||n[11]!==u||n[12]!==d?(f={entries:d,isLoading:c,isValidating:l,error:s,mutate:u},n[8]=s,n[9]=c,n[10]=l,n[11]=u,n[12]=d,n[13]=f):f=n[13],f}var Ae=`channels-status`;function je(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Me(e){let t=t=>e(t.detail);return window.addEventListener(Ae,t),()=>window.removeEventListener(Ae,t)}function Ne(e,t){let n=(0,U.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return Me(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,H.useEffect)(i,a)}function Pe(e){return e?m(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Fe(e){return(await u(m(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Ie=[`enabled`];async function Le(){let e=await u(m(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function Re(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function ze(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function X(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Be(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function Ve(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function He(e){return e===`running`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`stopped`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`checking`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`disabled`?`bg-surface-hover text-fg-muted`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`}function Ue(e){if(!e)return[];let t=e.uiHints??{},n=Z(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=X(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=Object.entries(t).filter(([,e])=>!Z(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Ie.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!Ie.includes(e))}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function We(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function Ge(e,t){let n={...We(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!Z(r)||!Z(r[n]))break;let o=Z(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...We(r[n]),properties:{}}),e===t.length-1){o[n]=We(r[n]);break}i=r[n],a=o[n]}}return n}function Ke(e){let t=e.properties;if(!Z(t))return!1;for(let[e,n]of Object.entries(t))Z(n)&&n.type===`object`&&Ke(n)&&delete t[e];return Object.keys(t).length===0}function qe(e,t){let n=We(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!Z(i))break;if(e===t.length-1){delete i[n];break}if(!Z(i[n]))break;r=i[n]}}return Ke(n),n}function Je(e){return e.type===`object`&&Z(e.properties)&&Object.keys(e.properties).length>0}function Ye(e,t){let n=e;for(let e of t.split(`.`)){if(!Z(n))return;n=n[e]}return n}function Q(e){let t=e.accounts;return Z(t)?Object.values(t).filter(e=>Z(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Xe(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Ze(e,t,n){let r=[],i=X(e);if(i.issues.length>0&&r.push(tt(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Xe(e,Ye(t,e),n);i&&r.push(i)}let a=Q(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Qe(e,t){let n=X(e),r=pe(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function $e(e,t){let n=pe(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function et(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function tt(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function nt({entry:e}){let[t,n]=(0,H.useState)(!1),r=(0,H.useMemo)(()=>!e.ui?.icon||t?null:new URL(m(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Re(e.ui.icon)}`)).toString(),[t,e.extensionId,e.ui?.icon]);return(0,W.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:r?(0,W.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>n(!0)}):(0,W.jsx)(P,{sourceChannel:e.id,className:`size-7`})})}function rt(e){let t=(0,U.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);let s=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,c=r&&`cursor-not-allowed opacity-60`,u;t[2]!==s||t[3]!==c?(u=l(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,s,c),t[2]=s,t[3]=c,t[4]=u):u=t[4];let d=n?`translate-x-5`:`translate-x-0.5`,f;t[5]===d?f=t[6]:(f=l(`size-5 rounded-full bg-white shadow-surface transition-transform`,d),t[5]=d,t[6]=f);let p;t[7]===f?p=t[8]:(p=(0,W.jsx)(`span`,{className:f}),t[7]=f,t[8]=p);let m;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==u||t[14]!==p?(m=(0,W.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:u,children:p}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=u,t[14]=p,t[15]=m):m=t[15],m}function it(e){let t=(0,U.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:o,ch:s,onOpen:c,onToggle:u,onRestart:d}=e,f;t[0]===n?f=t[1]:(f=X(n),t[0]=n,t[1]=f);let p=f,m,h,g,_,v,y,b;if(t[2]!==a||t[3]!==s||t[4]!==r||t[5]!==n||t[6]!==c||t[7]!==d||t[8]!==u||t[9]!==i||t[10]!==p.enabled||t[11]!==p.ready){let e=Ze(n,r,s),o=et(n,s);m=!p.enabled&&p.ready?u:i===`stopped`?d:c,y=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let f;t[19]===n?f=t[20]:(f=(0,W.jsx)(nt,{entry:n}),t[19]=n,t[20]=f);let x;t[21]===n.label?x=t[22]:(x=(0,W.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=x);let S;t[23]===i?S=t[24]:(S=l(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,He(i)),t[23]=i,t[24]=S);let C;t[25]!==s||t[26]!==i?(C=Be(i,s),t[25]=s,t[26]=i,t[27]=C):C=t[27];let w;t[28]!==S||t[29]!==C?(w=(0,W.jsx)(`span`,{className:S,children:C}),t[28]=S,t[29]=C,t[30]=w):w=t[30];let T;t[31]!==w||t[32]!==x?(T=(0,W.jsxs)(`div`,{className:`min-w-0`,children:[x,w]}),t[31]=w,t[32]=x,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==f?(E=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[f,T]}),t[34]=T,t[35]=f,t[36]=E):E=t[36];let D=p.enabled,O;t[37]!==s.toggleChannel||t[38]!==n.label?(O=s.toggleChannel.replace(`{{channel}}`,n.label),t[37]=s.toggleChannel,t[38]=n.label,t[39]=O):O=t[39];let k;t[40]!==a||t[41]!==u||t[42]!==p.enabled||t[43]!==O?(k=(0,W.jsx)(rt,{checked:D,disabled:a,label:O,onToggle:u}),t[40]=a,t[41]=u,t[42]=p.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==E||t[46]!==k?(b=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=b):b=t[47],h=`button`,g=c,_=`mt-5 min-h-[6.25rem] text-left`,v=p.ready?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,W.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(at)}):null]}):(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.cardSetupTitle}),(0,W.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??$e(n,s)}),o.length>0?(0,W.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:o.map($)}):null]}),t[2]=a,t[3]=s,t[4]=r,t[5]=n,t[6]=c,t[7]=d,t[8]=u,t[9]=i,t[10]=p.enabled,t[11]=p.ready,t[12]=m,t[13]=h,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b}else m=t[12],h=t[13],g=t[14],_=t[15],v=t[16],y=t[17],b=t[18];let x;t[48]!==h||t[49]!==g||t[50]!==_||t[51]!==v?(x=(0,W.jsx)(`button`,{type:h,onClick:g,className:_,children:v}),t[48]=h,t[49]=g,t[50]=_,t[51]=v,t[52]=x):x=t[52];let S=a||o,C;t[53]!==a||t[54]!==o?(C=a||o?(0,W.jsx)(z,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=C):C=t[55];let T;t[56]!==s||t[57]!==n||t[58]!==o||t[59]!==i?(T=o?s.restartingChannel:i===`stopped`?s.restartChannel:Qe(n,s),t[56]=s,t[57]=n,t[58]=o,t[59]=i,t[60]=T):T=t[60];let E;t[61]!==m||t[62]!==C||t[63]!==T||t[64]!==S?(E=(0,W.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,W.jsxs)(w,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:m,disabled:S,children:[C,T]})}),t[61]=m,t[62]=C,t[63]=T,t[64]=S,t[65]=E):E=t[65];let D;return t[66]!==E||t[67]!==y||t[68]!==b||t[69]!==x?(D=(0,W.jsxs)(`article`,{className:y,children:[b,x,E]}),t[66]=E,t[67]=y,t[68]=b,t[69]=x,t[70]=D):D=t[70],D}function $(e){return(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function at(e){return(0,W.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function ot(e){let t=(0,U.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:o,ch:c,onRestart:u,onCheck:d,onManageConnection:f}=e,p=n===`running`?s:n===`stopped`||n===`needs_setup`?V:z,m=n===`running`&&`text-emerald-600 dark:text-emerald-400`,h=n===`stopped`&&`text-red-600 dark:text-red-400`,g=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,_=n===`disabled`&&`text-fg-muted`,v=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,y;t[0]!==m||t[1]!==h||t[2]!==g||t[3]!==_||t[4]!==v?(y=l(`mt-0.5 size-5 shrink-0`,m,h,g,_,v),t[0]=m,t[1]=h,t[2]=g,t[3]=_,t[4]=v,t[5]=y):y=t[5];let b;t[6]!==p||t[7]!==y?(b=(0,W.jsx)(p,{className:y}),t[6]=p,t[7]=y,t[8]=b):b=t[8];let x;t[9]===c.connectionStatus?x=t[10]:(x=(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.connectionStatus}),t[9]=c.connectionStatus,t[10]=x);let S;t[11]!==c||t[12]!==n?(S=Ve(n,c),t[11]=c,t[12]=n,t[13]=S):S=t[13];let C;t[14]===S?C=t[15]:(C=(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S}),t[14]=S,t[15]=C);let T;t[16]!==C||t[17]!==x?(T=(0,W.jsxs)(`div`,{children:[x,C]}),t[16]=C,t[17]=x,t[18]=T):T=t[18];let E;t[19]!==T||t[20]!==b?(E=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[b,T]}),t[19]=T,t[20]=b,t[21]=E):E=t[21];let D=i||r,O;t[22]===i?O=t[23]:(O=i?(0,W.jsx)(z,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=O);let k=i?c.checkingConnection:c.checkConnection,A;t[24]!==d||t[25]!==D||t[26]!==O||t[27]!==k?(A=(0,W.jsxs)(w,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:D,onClick:d,children:[O,k]}),t[24]=d,t[25]=D,t[26]=O,t[27]=k,t[28]=A):A=t[28];let j;t[29]!==c.restartChannel||t[30]!==c.restartingChannel||t[31]!==i||t[32]!==u||t[33]!==r||t[34]!==n?(j=n===`stopped`?(0,W.jsxs)(w,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:u,children:[r?(0,W.jsx)(z,{className:`size-4 animate-spin`}):(0,W.jsx)(te,{className:`size-4`}),r?c.restartingChannel:c.restartChannel]}):null,t[29]=c.restartChannel,t[30]=c.restartingChannel,t[31]=i,t[32]=u,t[33]=r,t[34]=n,t[35]=j):j=t[35];let M;t[36]!==o||t[37]!==c.connectionOptions||t[38]!==c.hideConnectionOptions||t[39]!==i||t[40]!==f||t[41]!==r||t[42]!==a?(M=o?(0,W.jsx)(w,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:f,children:a?c.hideConnectionOptions:c.connectionOptions}):null,t[36]=o,t[37]=c.connectionOptions,t[38]=c.hideConnectionOptions,t[39]=i,t[40]=f,t[41]=r,t[42]=a,t[43]=M):M=t[43];let N;t[44]!==A||t[45]!==j||t[46]!==M?(N=(0,W.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[A,j,M]}),t[44]=A,t[45]=j,t[46]=M,t[47]=N):N=t[47];let P;return t[48]!==E||t[49]!==N?(P=(0,W.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[E,N]})}),t[48]=E,t[49]=N,t[50]=P):P=t[50],P}function st(e){let t=(0,U.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=X(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl bg-amber-50 px-4 py-3 text-amber-950 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,W.jsx)(A,{className:`mt-0.5 size-4 shrink-0`}),t[11]=u):u=t[11],o=`min-w-0`,t[12]===r.setupReadinessTitle?s=t[13]:(s=(0,W.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.setupReadinessTitle}),t[12]=r.setupReadinessTitle,t[13]=s);let p=e.enabled?r.setupReadinessEnabledBody:r.setupReadinessDisabledBody;t[14]===p?c=t[15]:(c=(0,W.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-amber-900 dark:text-amber-200`,children:p}),t[14]=p,t[15]=c),i=`mt-2 list-disc space-y-1 pl-5 text-sm text-amber-900 dark:text-amber-200`;let m;t[16]===r?m=t[17]:(m=e=>(0,W.jsx)(`li`,{children:tt(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=m),a=e.issues.map(m)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==i||t[19]!==a?(p=(0,W.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=p):p=t[20];let m;t[21]!==p||t[22]!==o||t[23]!==s||t[24]!==c?(m=(0,W.jsxs)(`div`,{className:o,children:[s,c,p]}),t[21]=p,t[22]=o,t[23]=s,t[24]=c,t[25]=m):m=t[25];let h;t[26]!==m||t[27]!==l||t[28]!==u?(h=(0,W.jsxs)(`div`,{className:l,children:[u,m]}),t[26]=m,t[27]=l,t[28]=u,t[29]=h):h=t[29];let g;return t[30]!==h||t[31]!==d?(g=(0,W.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function ct(){let e=p(e=>e.language),t=h(e),n=d(e=>!!e.conversationId),r=i(),{channelId:s}=a(),c=R(s),u=ke(n,e),g=u.entries,{data:_,mutate:v,isValidating:y}=C(n?de():null,fe,{revalidateOnFocus:!0}),{data:b,mutate:x}=C(n?`channels-config-map`:null,Le,{revalidateOnFocus:!1}),S=b?.channels??{},w=b?.bindings??[],{data:T}=C(n?`channel-routing-agents`:null,L,{revalidateOnFocus:!1}),E=F(e=>e.setPageHeader),D=F(e=>e.clearPageHeader),O=(0,H.useMemo)(()=>g.find(e=>e.id===c),[c,g]),A=O?ze(O):null,{data:P,mutate:I}=C(n&&A?Pe(A):null,()=>Fe(A)),[z,V]=(0,H.useState)(null),[te,ne]=(0,H.useState)(!1),[re,ie]=(0,H.useState)(null),[se,U]=(0,H.useState)(null),[ue,me]=(0,H.useState)(!1),[G,K]=(0,H.useState)(null),[q,J]=(0,H.useState)(null),he=z??P??{},Y=t.channelsSettings,_e=(0,H.useMemo)(()=>O?.configSchema??{type:`object`,properties:{}},[O?.configSchema]),be=(0,H.useMemo)(()=>qe(_e,Ie),[_e]),Se=(0,H.useMemo)(()=>Ue(O),[O]),we=(0,H.useMemo)(()=>Ge(be,Se),[Se,be]),De=(0,H.useMemo)(()=>qe(be,Se),[Se,be]),Oe=(0,H.useMemo)(()=>Je(we),[we]),Ae=O?q??ve(w,O.id):``,Me=(0,H.useMemo)(()=>(T?.items??[]).map(e=>{let n=j(e,t.agentsSettings);return{value:e.id,label:n===e.id?n:`${n} · ${e.id}`}}),[T?.items,t.agentsSettings]),Re=T?.items.find(e=>e.id===T.defaultId),Ve=Re?j(Re,t.agentsSettings):T?.defaultId??``,Z=(0,H.useMemo)(()=>({defaultBooleanLabel:Y.schemaBooleanDefault,unsupportedArrayType:Y.schemaUnsupportedArrayType,arrayAddPlaceholder:Y.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>Y.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[Y]),We=(0,H.useMemo)(()=>new Map((_??[]).map(e=>[e.name,e])),[_]),Ke=_!==void 0,Ye=(0,H.useCallback)(e=>xe(e,We.get(e.id),Ke),[We,Ke]),Q=(0,H.useCallback)(async()=>{await Promise.all([u.mutate(),v()])},[u,v]);Ne((0,H.useCallback)(e=>{let t=je(e);t&&v(t,!1)},[v]),n);let Xe=(0,H.useMemo)(()=>n?(0,W.jsx)(Te,{ch:Y,refreshing:u.isValidating||y,saveOk:!1,onRefresh:()=>void Q()}):null,[u.isValidating,Y,n,y,Q]);(0,H.useLayoutEffect)(()=>(E({startExtra:null,main:(0,W.jsx)(`div`,{className:`min-w-0`,children:(0,W.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:Xe}),()=>D()),[D,Xe,t.settingsSections.channels,E]);let Ze=(0,H.useCallback)(e=>{r(M(e)),V(null),J(null),K(null)},[r]),Qe=(0,H.useCallback)(()=>{r(N),V(null),J(null),K(null)},[r]),$e=(0,H.useCallback)(async e=>{U(e.id),K(null);try{let t=await f(m(`/api/channels/${encodeURIComponent(e.id)}/restart`),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await Q()}catch(e){K(e instanceof Error?e.message:String(e))}finally{U(null)}},[Q]);(0,H.useEffect)(()=>{J(null),me(!1)},[O?.id]);let et=(0,H.useCallback)(async()=>{if(!O||!z&&q===null)return!1;let e=ze(O);ne(!0),K(null);try{let t=await f(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({...z?{channels:{[e]:z}}:{},...q===null?{}:{bindings:ye(w,O.id,q)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return z&&await I(z,!1),await x(),await u.mutate(),V(null),J(null),!0}catch(e){return K(e instanceof Error?e.message:String(e)),!1}finally{ne(!1)}},[O,q,w,u,z,x,I]),tt=(0,H.useCallback)(async e=>{let t=X(e),n=ze(e),r=O?.id===e.id?z:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}ie(e.id),K(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await f(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[n]:i}})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error?.message??a.statusText)}await u.mutate(),await x(),await v(),O?.id===e.id&&(await I(),V(null))}catch(e){K(e instanceof Error?e.message:String(e))}finally{ie(null)}},[O?.id,u,z,x,I,v,Ze]),$=O?.ui?.modal,at=$?.placement!==`replace-config`,ct=O?Ye(O):`checking`,lt=O?!X(O).ready||ue:!1;return n?(0,W.jsxs)(oe,{gap:`gap-4`,className:`max-w-6xl`,padding:`px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:[u.isLoading?(0,W.jsx)(ce,{sections:2}):u.error?(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(u.error)}):(0,W.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:g.map(e=>(0,W.jsx)(it,{entry:e,config:S[ze(e)]?.config,runtime:Ye(e),busy:re===e.id,restarting:se===e.id,ch:Y,onOpen:()=>Ze(e.id),onToggle:()=>void tt(e),onRestart:()=>void $e(e)},e.id))}),G?(0,W.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:G}):null,(0,W.jsx)(Ce,{presentation:`modal`,open:!!O,onOpenChange:e=>{e||Qe()},closeAriaLabel:Y.close,srTitle:O?.label??Y.selectChannel,srDescription:O?.description,wide:!0,footer:O?(0,W.jsx)(Ee,{ch:Y,dirty:!!z||q!==null,saving:te,onCancel:Qe,onDiscard:()=>{V(null),J(null)},onSave:et}):null,children:O?(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,W.jsx)(nt,{entry:O}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:O.label}),(0,W.jsx)(`span`,{className:l(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,He(ct)),children:Be(ct,Y)})]}),(0,W.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,W.jsx)(`span`,{className:`min-w-0 truncate`,children:!X(O).ready&&pe(O)?.[1].result===`qr`?Y.scanLoginHint.replace(`{{channel}}`,O.label):O.description}),O.docsPath?(0,W.jsxs)(`a`,{href:O.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[Y.docs,(0,W.jsx)(ee,{className:`size-3.5`})]}):null]})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,W.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:X(O).enabled?Y.enabledLabel:Y.disabledLabel}),(0,W.jsx)(rt,{checked:X(O).enabled,disabled:re===O.id,label:Y.toggleChannel.replace(`{{channel}}`,O.label),onToggle:()=>void tt(O)})]})]})}),(0,W.jsx)(ot,{runtime:ct,restarting:se===O.id,checking:y,showConnectionOptions:ue,canManageConnection:X(O).ready&&$?.placement!==`replace-config`,ch:Y,onRestart:()=>void $e(O),onCheck:()=>void Q(),onManageConnection:()=>me(e=>!e)}),(0,W.jsx)(st,{entry:O,ch:Y}),lt&&$?.placement!==`replace-config`?(0,W.jsx)(ge,{entry:O,locale:e,messages:Y,compact:!0,onChanged:async()=>{await I(),await Q(),await x()}},O.id):null,$?.entrypoint&&$.placement===`before-config`?(0,W.jsx)(B,{extensionId:O.extensionId,extensionName:O.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:O.id,entry:O,config:he}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,W.jsx)(B,{extensionId:O.extensionId,extensionName:O.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:O.id,entry:O,config:he}}):null,at&&Oe?(0,W.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:`mb-4`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:Y.basicConfiguration}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:Y.basicConfigurationHint})]}),(0,W.jsx)(le,{schema:we,values:he,onChange:e=>V(e),disabled:te,labels:Z})]}):null,(0,W.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,W.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,W.jsx)(k,{className:`size-4 text-fg-muted`}),Y.messageHandling]}),(0,W.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,W.jsxs)(`div`,{className:`mb-3`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:Y.agentRouting}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:Y.messageHandlingHint})]}),(0,W.jsx)(o,{value:Ae,options:Me,placeholder:Y.agentRoutingSelect,emptyLabel:Y.agentRoutingDefault.replace(`{{agent}}`,Ve||Y.agentRoutingSelect),ariaLabel:Y.agentRouting,disabled:te||!T,onChange:e=>J(e)})]})]}),at&&Je(De)?(0,W.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,W.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,W.jsx)(k,{className:`size-4 text-fg-muted`}),Y.advancedConfiguration]}),(0,W.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,W.jsx)(le,{schema:De,values:he,onChange:e=>V(e),disabled:te,labels:Z})})]}):null,G?(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:G}):null]}):null})]}):(0,W.jsxs)(oe,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,W.jsx)(ae,{title:t.settingsSections.channels}),(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:Y.tokenRequired})]})}export{ct as ChannelsSettingsPanel};
@@ -1,4 +1,4 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./plus-Q2yW6OE7.js";import{t as i}from"./x-B_N4OPjy.js";import{n as a}from"./locale-store-BIkcRr3t.js";import{t as o}from"./messages-7VAhscYe.js";import{t as s}from"./button-CS04eWY9.js";import{t as c}from"./skeleton-BwbyijEw.js";import{Lc as l,M as u,N as d,P as f,Wa as p}from"./index--3c0awkr.js";var m=2,h=1,ee=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(m,Math.floor(u/e.css.cell.width)),rows:Math.max(h,Math.floor(l/e.css.cell.height))}}},g=Object.defineProperty,_=Object.getOwnPropertyDescriptor,te=(e,t)=>{for(var n in t)g(e,n,{get:t[n],enumerable:!0})},v=(e,t,n,r)=>{for(var i=r>1?void 0:r?_(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&g(t,n,i),i},y=(e,t)=>(n,r)=>t(n,r,e),ne=`Terminal input`,re={get:()=>ne,set:e=>ne=e},ie=`Too much output to announce, navigate to rows manually to read`,b={get:()=>ie,set:e=>ie=e};function ae(e){return e.replace(/\r?\n/g,`\r`)}function x(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function oe(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function S(e,t,n,r){e.stopPropagation(),e.clipboardData&&se(e.clipboardData.getData(`text/plain`),t,n,r)}function se(e,t,n,r){e=ae(e),e=x(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function ce(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function le(e,t,n,r,i){ce(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function C(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function w(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var ue=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},de=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},fe=``,pe=` `,me=class e{constructor(){this.fg=0,this.bg=0,this.extended=new he}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},he=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},T=class e extends me{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new he,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?C(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ge=`di$target`,_e=`di$dependencies`,ve=new Map;function ye(e){return e[_e]||[]}function E(e){if(ve.has(e))return ve.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);be(t,e,r)};return t._id=e,ve.set(e,t),t}function be(e,t,n){t[ge]===t?t[_e].push({id:e,index:n}):(t[_e]=[{id:e,index:n}],t[ge]=t)}var D=E(`BufferService`),xe=E(`CoreMouseService`),Se=E(`CoreService`),Ce=E(`CharsetService`),we=E(`InstantiationService`),Te=E(`LogService`),O=E(`OptionsService`),Ee=E(`OscLinkService`),De=E(`UnicodeService`),Oe=E(`DecorationService`),ke=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new T,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Ae(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};ke=v([y(0,D),y(1,O),y(2,Ee)],ke);function Ae(e,t){if(confirm(`Do you want to navigate to ${t}?
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./plus-Q2yW6OE7.js";import{t as i}from"./x-B_N4OPjy.js";import{n as a}from"./locale-store-BPZR8x9b.js";import{t as o}from"./messages-kFWhF6_t.js";import{t as s}from"./button-CS04eWY9.js";import{t as c}from"./skeleton-BwbyijEw.js";import{Hc as l,M as u,N as d,P as f,Wa as p}from"./index-19rMUT3d.js";var m=2,h=1,ee=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(m,Math.floor(u/e.css.cell.width)),rows:Math.max(h,Math.floor(l/e.css.cell.height))}}},g=Object.defineProperty,_=Object.getOwnPropertyDescriptor,te=(e,t)=>{for(var n in t)g(e,n,{get:t[n],enumerable:!0})},v=(e,t,n,r)=>{for(var i=r>1?void 0:r?_(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&g(t,n,i),i},y=(e,t)=>(n,r)=>t(n,r,e),ne=`Terminal input`,re={get:()=>ne,set:e=>ne=e},ie=`Too much output to announce, navigate to rows manually to read`,b={get:()=>ie,set:e=>ie=e};function ae(e){return e.replace(/\r?\n/g,`\r`)}function x(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function oe(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function S(e,t,n,r){e.stopPropagation(),e.clipboardData&&se(e.clipboardData.getData(`text/plain`),t,n,r)}function se(e,t,n,r){e=ae(e),e=x(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function ce(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function le(e,t,n,r,i){ce(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function C(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function w(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var ue=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},de=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},fe=``,pe=` `,me=class e{constructor(){this.fg=0,this.bg=0,this.extended=new he}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},he=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},T=class e extends me{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new he,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?C(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ge=`di$target`,_e=`di$dependencies`,ve=new Map;function ye(e){return e[_e]||[]}function E(e){if(ve.has(e))return ve.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);be(t,e,r)};return t._id=e,ve.set(e,t),t}function be(e,t,n){t[ge]===t?t[_e].push({id:e,index:n}):(t[_e]=[{id:e,index:n}],t[ge]=t)}var D=E(`BufferService`),xe=E(`CoreMouseService`),Se=E(`CoreService`),Ce=E(`CharsetService`),we=E(`InstantiationService`),Te=E(`LogService`),O=E(`OptionsService`),Ee=E(`OscLinkService`),De=E(`UnicodeService`),Oe=E(`DecorationService`),ke=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new T,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Ae(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};ke=v([y(0,D),y(1,O),y(2,Ee)],ke);function Ae(e,t){if(confirm(`Do you want to navigate to ${t}?
2
2
 
3
3
  WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var je=E(`CharSizeService`),Me=E(`CoreBrowserService`),Ne=E(`MouseService`),Pe=E(`RenderService`),Fe=E(`SelectionService`),Ie=E(`CharacterJoinerService`),Le=E(`ThemeService`),Re=E(`LinkProviderService`),ze=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Ge.isErrorNoTelemetry(e)?new Ge(e.message+`
4
4
 
@@ -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"./chunk-KS7C4IRE-BMYIfy9x.js";import{a,n as o,r as s}from"./locale-store-BIkcRr3t.js";import{t as c}from"./messages-7VAhscYe.js";import{i as l}from"./vendor-swr-BIWyz7Rc.js";import{t as u}from"./button-CS04eWY9.js";import{r as d}from"./gateway-config-swr-1eqyz9vZ.js";import{t as f}from"./skeleton-BwbyijEw.js";import{n as p,t as m}from"./registry-api-BAAZUGnU.js";import{El as h,Gc as g,Ic as _,Tl as v,_n as y,gn as b,ki as x,mu as S}from"./index--3c0awkr.js";import{n as C,r as w}from"./settings-page-layout-D3KNSQ5g.js";var T=n(),E=e(t(),1),D=r();function O({zh:e}){let t=c(e?`zh`:`en`).computerSettings,n=l(`settings-agent-defaults`,b),r=l(m,p),a=n.data?.defaults.models.computerUse?.primary??``,[o,s]=(0,E.useState)(a),[d,h]=(0,E.useState)(!1),[g,_]=(0,E.useState)(``),[v,S]=(0,E.useState)(!1);(0,E.useEffect)(()=>{s(a)},[a]);let C=!o||r.data?.some(e=>e.id===o&&e.computerUse),w=async()=>{h(!0),_(``),S(!1);try{if(!C)throw Error(t.modelUnavailable);let e=await b(),r={...e.defaults.models};o?r.computerUse={primary:o,fallbacks:[]}:delete r.computerUse;let i=await y({...e.defaults,models:r});await n.mutate(i,!1),S(!0)}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(!1)}};return(0,D.jsxs)(`section`,{"aria-label":t.model,className:`space-y-3`,children:[(0,D.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.model}),!n.data&&!n.error?(0,D.jsx)(f,{className:`h-52 w-full rounded-xl`}):n.error?(0,D.jsxs)(`div`,{role:`alert`,className:`text-sm text-danger`,children:[String(n.error),(0,D.jsx)(u,{onClick:()=>{n.mutate().catch(()=>{})},children:t.retry})]}):(0,D.jsxs)(`div`,{className:`space-y-4 rounded-xl bg-surface-hover/25 p-4 sm:p-5`,children:[(0,D.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.modelDescription}),(0,D.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:t.modelScope}),r.isLoading?(0,D.jsx)(f,{className:`h-10 w-full rounded-lg`}):(0,D.jsx)(x,{value:o,onChange:e=>{s(e),S(!1)},disabled:d,capabilitiesFilter:`computer-use`,models:r.data??[],modelsError:r.error,placeholder:t.selectModel,searchPlaceholder:t.searchModel,noMatches:t.noModels,registryEmptyHint:t.noModels,allowEmpty:!0,emptyLabel:t.noModel,ariaLabel:t.modelLabel,className:`w-full`,contentAlign:`start`}),!C&&!r.isLoading&&!r.error&&(0,D.jsx)(`p`,{role:`status`,className:`text-sm text-warning`,children:t.modelUnavailable}),r.error&&(0,D.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[String(r.error),(0,D.jsx)(u,{onClick:()=>{r.mutate().catch(()=>{})},children:t.retry})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,D.jsx)(u,{variant:`primary`,disabled:d||o===a||!C||!!r.error||r.isLoading,onClick:()=>{w()},children:t.saveModel}),(0,D.jsx)(u,{asChild:!0,variant:`ghost`,children:(0,D.jsx)(i,{to:`/settings/capabilities/models?add=1`,children:t.manageModels})}),v&&(0,D.jsx)(`span`,{role:`status`,className:`text-xs text-fg-muted`,children:t.modelSaved})]}),g&&(0,D.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:g})]}),(0,D.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:t.modelPrivacy})]})}function k(e){let t=(0,T.c)(15),{icon:n,title:r,description:i,children:a}=e,o;t[0]===n?o=t[1]:(o=n&&(0,D.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-base/70 text-fg-muted`,"aria-hidden":!0,children:n}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,D.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r}),t[2]=r,t[3]=s);let c;t[4]===i?c=t[5]:(c=i&&(0,D.jsx)(`div`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===a?u=t[10]:(u=a&&(0,D.jsx)(`div`,{className:`flex shrink-0 items-center gap-3`,children:a}),t[9]=a,t[10]=u);let d;return t[11]!==o||t[12]!==l||t[13]!==u?(d=(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 p-4 sm:flex-nowrap sm:p-5`,children:[o,l,u]}),t[11]=o,t[12]=l,t[13]=u,t[14]=d):d=t[14],d}function A(){let e=(0,T.c)(2),t=o(j)===`zh`,n;return e[0]===t?n=e[1]:(n=(0,D.jsx)(M,{zh:t}),e[0]=t,e[1]=n),n}function j(e){return e.language}function M({zh:e}){let t=c(e?`zh`:`en`).computerSettings,{data:n,mutate:r,error:o}=d(!0),l=n?.payload?.config,[p,m]=(0,E.useState)(!1),[y,b]=(0,E.useState)(``),[x,T]=(0,E.useState)(!1),[A,j]=(0,E.useState)(null),[M,N]=(0,E.useState)(!1),P=window.electronAPI?.platform===`darwin`?window.electronAPI.computer:void 0,F=window.electronAPI?.platform===`darwin`?window.electronAPI.system:void 0;(0,E.useEffect)(()=>{if(!P)return;let e=!1,t=!1,n=async()=>{if(!t){t=!0;try{let t=await P.status();e||(j(t),N(!1))}catch{e||(j(null),N(!0))}finally{t=!1}}};n();let r=window.setInterval(()=>{n()},2e3);return()=>{e=!0,window.clearInterval(r)}},[P]);let I=async e=>{m(!0),b(``);try{await e()}catch(e){b(e instanceof Error?e.message:String(e))}finally{m(!1)}},L=e=>I(async()=>{await a(s(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({computer:{enabled:e}})}),await r()}),R=async()=>{b(``),T(!1);try{await P?.stop(),T(!0),P&&j(await P.status())}catch(e){b(e instanceof Error?e.message:String(e))}},z=A?.session?.status??`idle`,B=t.states[z]??z;return(0,D.jsxs)(w,{gap:`gap-7`,children:[(0,D.jsx)(C,{title:t.title,subtitle:t.subtitle,meta:(0,D.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,D.jsx)(`span`,{className:`inline-flex rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:t.experimental}),(0,D.jsx)(`span`,{className:`inline-flex rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:t.preview})]}),(0,D.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:t.experimentalDescription})]}),actions:P&&(0,D.jsxs)(u,{onClick:()=>{R()},children:[(0,D.jsx)(_,{className:`size-3.5`}),t.stop]})}),y&&(0,D.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:y}),x&&(0,D.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.stoppedNotice}),A?.controlPaused&&(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl bg-warning-soft p-4`,children:[(0,D.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.pausedNotice}),(0,D.jsx)(u,{disabled:p,onClick:()=>{I(async()=>{P&&j(await P.resume()),T(!1)})},children:t.resume})]}),(0,D.jsx)(O,{zh:e}),(0,D.jsxs)(`section`,{"aria-labelledby":`computer-control-title`,className:`space-y-3`,children:[(0,D.jsx)(`h2`,{id:`computer-control-title`,className:`text-sm font-semibold text-fg`,children:t.control}),!l&&!o?(0,D.jsx)(f,{className:`h-40 w-full rounded-xl`}):o?(0,D.jsxs)(`div`,{role:`alert`,className:`text-sm text-fg-muted`,children:[String(o),` `,(0,D.jsx)(u,{onClick:()=>{I(()=>r())},children:t.retry})]}):(0,D.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-xl bg-surface-hover/20 p-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45`,children:[(0,D.jsx)(k,{icon:(0,D.jsx)(v,{className:`size-5`}),title:t.desktop,description:t.desktopDescription,children:(0,D.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.desktop,"aria-checked":l?.computer?.enabled===!0,disabled:p,onClick:()=>{L(l?.computer?.enabled!==!0)},className:`touch-target flex items-center rounded-lg px-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,D.jsx)(`span`,{className:`flex h-6 w-11 items-center rounded-full p-0.5 transition-colors ${l?.computer?.enabled?`bg-accent`:`bg-fg-muted/30`}`,children:(0,D.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${l?.computer?.enabled?`translate-x-5`:`translate-x-0`}`})})})}),(0,D.jsx)(k,{icon:(0,D.jsx)(g,{className:`size-5`}),title:t.approvals,description:t.approvalsDescription,children:(0,D.jsx)(`span`,{className:`rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:t.approvalsRequired})}),(0,D.jsx)(k,{icon:(0,D.jsx)(S,{className:`size-5`}),title:t.browser,description:(0,D.jsxs)(D.Fragment,{children:[t.browserDescription,(0,D.jsx)(`span`,{className:`mt-1 block text-xs`,children:l?.browser?.enabled?t.browserEnabled:t.browserDisabled})]}),children:(0,D.jsx)(u,{asChild:!0,children:(0,D.jsx)(i,{to:`/settings/agent-browser`,children:t.manage})})})]}),(0,D.jsxs)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:[t.safety,` `,t.lockedDescription]})]}),(0,D.jsxs)(`section`,{"aria-labelledby":`computer-permissions-title`,className:`space-y-3`,children:[(0,D.jsx)(`h2`,{id:`computer-permissions-title`,className:`text-sm font-semibold text-fg`,children:t.permissions}),P?M?(0,D.jsx)(`p`,{role:`alert`,className:`rounded-xl bg-danger-soft p-5 text-sm text-danger`,children:t.nativeError}):A?(0,D.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-xl bg-surface-hover/20 p-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45`,children:[(0,D.jsx)(k,{icon:(0,D.jsx)(h,{className:`size-5`}),title:t.device,description:(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`span`,{"aria-live":`polite`,children:[A.connected?t.connected:t.disconnected,` · `,B]}),A.reenrollmentRequired&&(0,D.jsx)(`p`,{className:`mt-1`,children:t.revoked})]}),children:A.reenrollmentRequired&&(0,D.jsx)(u,{disabled:p,onClick:()=>{I(async()=>{j(await P.reenroll())})},children:t.reenroll})}),F&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(k,{icon:(0,D.jsx)(g,{className:`size-5`}),title:t.accessibility,description:t.accessibilityDescription,children:[(0,D.jsx)(`span`,{className:`text-xs text-fg-muted`,children:A.permissions.accessibility?t.granted:t.notGranted}),!A.permissions.accessibility&&(0,D.jsx)(u,{disabled:p,"aria-label":`${t.openSettings}: ${t.accessibility}`,onClick:()=>{I(()=>F.requestAccessibility())},children:t.openSettings})]}),(0,D.jsxs)(k,{icon:(0,D.jsx)(h,{className:`size-5`}),title:t.screen,description:t.screenDescription,children:[(0,D.jsx)(`span`,{className:`text-xs text-fg-muted`,children:A.permissions.screenRecording===`granted`?t.granted:t.notGranted}),A.permissions.screenRecording!==`granted`&&(0,D.jsx)(u,{disabled:p,"aria-label":`${t.openSettings}: ${t.screen}`,onClick:()=>{I(()=>F.requestScreen())},children:t.openSettings})]})]})]}):(0,D.jsx)(`div`,{"aria-label":t.checking,children:(0,D.jsx)(f,{className:`h-52 w-full rounded-xl`})}):(0,D.jsx)(`p`,{className:`rounded-xl bg-surface-hover/20 p-5 text-sm leading-relaxed text-fg-muted`,children:window.electronAPI&&window.electronAPI.platform!==`darwin`?t.unsupportedPlatform:t.desktopRequired}),(A?.error||A?.session?.errorCode)&&(0,D.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-red-600`,children:A.error||A.session?.errorCode})]})]})}export{A as ComputerSettingsPage,M as ComputerSettingsPanel};
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"./chunk-KS7C4IRE-BMYIfy9x.js";import{a,n as o,r as s}from"./locale-store-BPZR8x9b.js";import{t as c}from"./messages-kFWhF6_t.js";import{i as l}from"./vendor-swr-BIWyz7Rc.js";import{t as u}from"./button-CS04eWY9.js";import{r as d}from"./gateway-config-swr-CoQVulMd.js";import{t as f}from"./skeleton-BwbyijEw.js";import{n as p,t as m}from"./registry-api-DWWO6ajd.js";import{Al as h,Vc as g,Xc as _,_n as v,gn as y,jl as b,ki as x,yu as S}from"./index-19rMUT3d.js";import{n as C,r as w}from"./settings-page-layout-D6745w0p.js";var T=n(),E=e(t(),1),D=r();function O({zh:e}){let t=c(e?`zh`:`en`).computerSettings,n=l(`settings-agent-defaults`,y),r=l(m,p),a=n.data?.defaults.models.computerUse?.primary??``,[o,s]=(0,E.useState)(a),[d,h]=(0,E.useState)(!1),[g,_]=(0,E.useState)(``),[b,S]=(0,E.useState)(!1);(0,E.useEffect)(()=>{s(a)},[a]);let C=!o||r.data?.some(e=>e.id===o&&e.computerUse),w=async()=>{h(!0),_(``),S(!1);try{if(!C)throw Error(t.modelUnavailable);let e=await y(),r={...e.defaults.models};o?r.computerUse={primary:o,fallbacks:[]}:delete r.computerUse;let i=await v({...e.defaults,models:r});await n.mutate(i,!1),S(!0)}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(!1)}};return(0,D.jsxs)(`section`,{"aria-label":t.model,className:`space-y-3`,children:[(0,D.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.model}),!n.data&&!n.error?(0,D.jsx)(f,{className:`h-52 w-full rounded-xl`}):n.error?(0,D.jsxs)(`div`,{role:`alert`,className:`text-sm text-danger`,children:[String(n.error),(0,D.jsx)(u,{onClick:()=>{n.mutate().catch(()=>{})},children:t.retry})]}):(0,D.jsxs)(`div`,{className:`space-y-4 rounded-xl bg-surface-hover/25 p-4 sm:p-5`,children:[(0,D.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.modelDescription}),(0,D.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:t.modelScope}),r.isLoading?(0,D.jsx)(f,{className:`h-10 w-full rounded-lg`}):(0,D.jsx)(x,{value:o,onChange:e=>{s(e),S(!1)},disabled:d,capabilitiesFilter:`computer-use`,models:r.data??[],modelsError:r.error,placeholder:t.selectModel,searchPlaceholder:t.searchModel,noMatches:t.noModels,registryEmptyHint:t.noModels,allowEmpty:!0,emptyLabel:t.noModel,ariaLabel:t.modelLabel,className:`w-full`,contentAlign:`start`}),!C&&!r.isLoading&&!r.error&&(0,D.jsx)(`p`,{role:`status`,className:`text-sm text-warning`,children:t.modelUnavailable}),r.error&&(0,D.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[String(r.error),(0,D.jsx)(u,{onClick:()=>{r.mutate().catch(()=>{})},children:t.retry})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,D.jsx)(u,{variant:`primary`,disabled:d||o===a||!C||!!r.error||r.isLoading,onClick:()=>{w()},children:t.saveModel}),(0,D.jsx)(u,{asChild:!0,variant:`ghost`,children:(0,D.jsx)(i,{to:`/settings/capabilities/models?add=1`,children:t.manageModels})}),b&&(0,D.jsx)(`span`,{role:`status`,className:`text-xs text-fg-muted`,children:t.modelSaved})]}),g&&(0,D.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:g})]}),(0,D.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:t.modelPrivacy})]})}function k(e){let t=(0,T.c)(15),{icon:n,title:r,description:i,children:a}=e,o;t[0]===n?o=t[1]:(o=n&&(0,D.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-base/70 text-fg-muted`,"aria-hidden":!0,children:n}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,D.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r}),t[2]=r,t[3]=s);let c;t[4]===i?c=t[5]:(c=i&&(0,D.jsx)(`div`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===a?u=t[10]:(u=a&&(0,D.jsx)(`div`,{className:`flex shrink-0 items-center gap-3`,children:a}),t[9]=a,t[10]=u);let d;return t[11]!==o||t[12]!==l||t[13]!==u?(d=(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 p-4 sm:flex-nowrap sm:p-5`,children:[o,l,u]}),t[11]=o,t[12]=l,t[13]=u,t[14]=d):d=t[14],d}function A(){let e=(0,T.c)(2),t=o(j)===`zh`,n;return e[0]===t?n=e[1]:(n=(0,D.jsx)(M,{zh:t}),e[0]=t,e[1]=n),n}function j(e){return e.language}function M({zh:e}){let t=c(e?`zh`:`en`).computerSettings,{data:n,mutate:r,error:o}=d(!0),l=n?.payload?.config,[p,m]=(0,E.useState)(!1),[v,y]=(0,E.useState)(``),[x,T]=(0,E.useState)(!1),[A,j]=(0,E.useState)(null),[M,N]=(0,E.useState)(!1),P=window.electronAPI?.platform===`darwin`?window.electronAPI.computer:void 0,F=window.electronAPI?.platform===`darwin`?window.electronAPI.system:void 0;(0,E.useEffect)(()=>{if(!P)return;let e=!1,t=!1,n=async()=>{if(!t){t=!0;try{let t=await P.status();e||(j(t),N(!1))}catch{e||(j(null),N(!0))}finally{t=!1}}};n();let r=window.setInterval(()=>{n()},2e3);return()=>{e=!0,window.clearInterval(r)}},[P]);let I=async e=>{m(!0),y(``);try{await e()}catch(e){y(e instanceof Error?e.message:String(e))}finally{m(!1)}},L=e=>I(async()=>{await a(s(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({computer:{enabled:e}})}),await r()}),R=async()=>{y(``),T(!1);try{await P?.stop(),T(!0),P&&j(await P.status())}catch(e){y(e instanceof Error?e.message:String(e))}},z=A?.session?.status??`idle`,B=t.states[z]??z;return(0,D.jsxs)(w,{gap:`gap-7`,children:[(0,D.jsx)(C,{title:t.title,subtitle:t.subtitle,meta:(0,D.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,D.jsx)(`span`,{className:`inline-flex rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:t.experimental}),(0,D.jsx)(`span`,{className:`inline-flex rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:t.preview})]}),(0,D.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:t.experimentalDescription})]}),actions:P&&(0,D.jsxs)(u,{onClick:()=>{R()},children:[(0,D.jsx)(g,{className:`size-3.5`}),t.stop]})}),v&&(0,D.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:v}),x&&(0,D.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.stoppedNotice}),A?.controlPaused&&(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl bg-warning-soft p-4`,children:[(0,D.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.pausedNotice}),(0,D.jsx)(u,{disabled:p,onClick:()=>{I(async()=>{P&&j(await P.resume()),T(!1)})},children:t.resume})]}),(0,D.jsx)(O,{zh:e}),(0,D.jsxs)(`section`,{"aria-labelledby":`computer-control-title`,className:`space-y-3`,children:[(0,D.jsx)(`h2`,{id:`computer-control-title`,className:`text-sm font-semibold text-fg`,children:t.control}),!l&&!o?(0,D.jsx)(f,{className:`h-40 w-full rounded-xl`}):o?(0,D.jsxs)(`div`,{role:`alert`,className:`text-sm text-fg-muted`,children:[String(o),` `,(0,D.jsx)(u,{onClick:()=>{I(()=>r())},children:t.retry})]}):(0,D.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-xl bg-surface-hover/20 p-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45`,children:[(0,D.jsx)(k,{icon:(0,D.jsx)(h,{className:`size-5`}),title:t.desktop,description:t.desktopDescription,children:(0,D.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.desktop,"aria-checked":l?.computer?.enabled===!0,disabled:p,onClick:()=>{L(l?.computer?.enabled!==!0)},className:`touch-target flex items-center rounded-lg px-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,D.jsx)(`span`,{className:`flex h-6 w-11 items-center rounded-full p-0.5 transition-colors ${l?.computer?.enabled?`bg-accent`:`bg-fg-muted/30`}`,children:(0,D.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${l?.computer?.enabled?`translate-x-5`:`translate-x-0`}`})})})}),(0,D.jsx)(k,{icon:(0,D.jsx)(_,{className:`size-5`}),title:t.approvals,description:t.approvalsDescription,children:(0,D.jsx)(`span`,{className:`rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:t.approvalsRequired})}),(0,D.jsx)(k,{icon:(0,D.jsx)(S,{className:`size-5`}),title:t.browser,description:(0,D.jsxs)(D.Fragment,{children:[t.browserDescription,(0,D.jsx)(`span`,{className:`mt-1 block text-xs`,children:l?.browser?.enabled?t.browserEnabled:t.browserDisabled})]}),children:(0,D.jsx)(u,{asChild:!0,children:(0,D.jsx)(i,{to:`/settings/agent-browser`,children:t.manage})})})]}),(0,D.jsxs)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:[t.safety,` `,t.lockedDescription]})]}),(0,D.jsxs)(`section`,{"aria-labelledby":`computer-permissions-title`,className:`space-y-3`,children:[(0,D.jsx)(`h2`,{id:`computer-permissions-title`,className:`text-sm font-semibold text-fg`,children:t.permissions}),P?M?(0,D.jsx)(`p`,{role:`alert`,className:`rounded-xl bg-danger-soft p-5 text-sm text-danger`,children:t.nativeError}):A?(0,D.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-xl bg-surface-hover/20 p-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45`,children:[(0,D.jsx)(k,{icon:(0,D.jsx)(b,{className:`size-5`}),title:t.device,description:(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`span`,{"aria-live":`polite`,children:[A.connected?t.connected:t.disconnected,` · `,B]}),A.reenrollmentRequired&&(0,D.jsx)(`p`,{className:`mt-1`,children:t.revoked})]}),children:A.reenrollmentRequired&&(0,D.jsx)(u,{disabled:p,onClick:()=>{I(async()=>{j(await P.reenroll())})},children:t.reenroll})}),F&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(k,{icon:(0,D.jsx)(_,{className:`size-5`}),title:t.accessibility,description:t.accessibilityDescription,children:[(0,D.jsx)(`span`,{className:`text-xs text-fg-muted`,children:A.permissions.accessibility?t.granted:t.notGranted}),!A.permissions.accessibility&&(0,D.jsx)(u,{disabled:p,"aria-label":`${t.openSettings}: ${t.accessibility}`,onClick:()=>{I(()=>F.requestAccessibility())},children:t.openSettings})]}),(0,D.jsxs)(k,{icon:(0,D.jsx)(b,{className:`size-5`}),title:t.screen,description:t.screenDescription,children:[(0,D.jsx)(`span`,{className:`text-xs text-fg-muted`,children:A.permissions.screenRecording===`granted`?t.granted:t.notGranted}),A.permissions.screenRecording!==`granted`&&(0,D.jsx)(u,{disabled:p,"aria-label":`${t.openSettings}: ${t.screen}`,onClick:()=>{I(()=>F.requestScreen())},children:t.openSettings})]})]})]}):(0,D.jsx)(`div`,{"aria-label":t.checking,children:(0,D.jsx)(f,{className:`h-52 w-full rounded-xl`})}):(0,D.jsx)(`p`,{className:`rounded-xl bg-surface-hover/20 p-5 text-sm leading-relaxed text-fg-muted`,children:window.electronAPI&&window.electronAPI.platform!==`darwin`?t.unsupportedPlatform:t.desktopRequired}),(A?.error||A?.session?.errorCode)&&(0,D.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-red-600`,children:A.error||A.session?.errorCode})]})]})}export{A as ComputerSettingsPage,M as ComputerSettingsPanel};
@@ -1 +1 @@
1
- import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{t as a}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as o}from"./x-B_N4OPjy.js";import{n as s}from"./locale-store-BIkcRr3t.js";import{t as c}from"./messages-7VAhscYe.js";import{a as l,c as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./dist-BGTk37IG.js";import{i as _}from"./vendor-swr-BIWyz7Rc.js";import{t as v}from"./button-CS04eWY9.js";import{t as y}from"./skeleton-BwbyijEw.js";import{At as b,Ko as x,Ps as S,Ss as C,ba as w,ds as T,js as E}from"./index--3c0awkr.js";var D=t({ConnectorServiceDialog:()=>F,ConnectorServicePage:()=>j}),O=r(),k=e(n(),1),A=i();function j(){let e=(0,O.c)(11),t=s(M),n;e[0]===t?n=e[1]:(n=c(t),e[0]=t,e[1]=n);let r=n.connectorsSettings,i=t===`zh`,o;e[2]===r.title?o=e[3]:(o=(0,A.jsx)(a,{to:`/connectors`,className:`text-sm text-accent-fg`,children:r.title}),e[2]=r.title,e[3]=o);let l=i?`应用连接服务`:`App connection service`,u;e[4]===l?u=e[5]:(u=(0,A.jsx)(`h1`,{className:`text-xl font-semibold`,children:l}),e[4]=l,e[5]=u);let d,f;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,A.jsx)(`p`,{className:`text-sm text-fg-muted`,children:(0,A.jsx)(N,{})}),f=(0,A.jsx)(L,{}),e[6]=d,e[7]=f):(d=e[6],f=e[7]);let p;return e[8]!==o||e[9]!==u?(p=(0,A.jsxs)(`main`,{className:`mx-auto w-full max-w-2xl space-y-6 p-6`,children:[o,u,d,f]}),e[8]=o,e[9]=u,e[10]=p):p=e[10],p}function M(e){return e.language}function N(){let e=(0,O.c)(2),t=s(P)===`zh`?`此设置决定新账号通过哪个服务连接。已有账号继续使用其原来的连接服务。`:`Choose the service for new accounts. Existing accounts keep their original service.`,n;return e[0]===t?n=e[1]:(n=(0,A.jsx)(A.Fragment,{children:t}),e[0]=t,e[1]=n),n}function P(e){return e.language}function F(){let e=(0,O.c)(22),t=s(I),n;e[0]===t?n=e[1]:(n=c(t),e[0]=t,e[1]=n);let r=n.connectorsSettings,i=t===`zh`,a=i?`应用连接服务`:`Connection service`,_;e[2]===a?_=e[3]:(_=(0,A.jsx)(u,{asChild:!0,children:(0,A.jsx)(v,{type:`button`,variant:`secondary`,className:`shrink-0`,children:a})}),e[2]=a,e[3]=_);let y;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,A.jsx)(l,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),e[4]=y):y=e[4];let b=i?`应用连接服务`:`App connection service`,x;e[5]===b?x=e[6]:(x=(0,A.jsx)(h,{className:`text-base font-semibold text-fg`,children:b}),e[5]=b,e[6]=x);let S;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,A.jsx)(d,{className:`mt-1 text-sm text-fg-muted`,children:(0,A.jsx)(N,{})}),e[7]=S):S=e[7];let C;e[8]===x?C=e[9]:(C=(0,A.jsxs)(`div`,{className:`min-w-0`,children:[x,S]}),e[8]=x,e[9]=C);let w;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,A.jsx)(o,{className:`size-5`,"aria-hidden":!0}),e[10]=w):w=e[10];let T;e[11]===r.modalClose?T=e[12]:(T=(0,A.jsx)(f,{asChild:!0,children:(0,A.jsx)(v,{variant:`ghost`,className:`shrink-0 p-1.5`,"aria-label":r.modalClose,children:w})}),e[11]=r.modalClose,e[12]=T);let E;e[13]!==C||e[14]!==T?(E=(0,A.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[C,T]}),e[13]=C,e[14]=T,e[15]=E):E=e[15];let D;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,A.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,A.jsx)(L,{})}),e[16]=D):D=e[16];let k;e[17]===E?k=e[18]:(k=(0,A.jsxs)(p,{children:[y,(0,A.jsxs)(m,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100dvh-2rem,42rem)] w-[min(100%-2rem,42rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-float`,children:[E,D]})]}),e[17]=E,e[18]=k);let j;return e[19]!==k||e[20]!==_?(j=(0,A.jsxs)(g,{children:[_,k]}),e[19]=k,e[20]=_,e[21]=j):j=e[21],j}function I(e){return e.language}function L(){let e=s(e=>e.language),t=c(e).connectorsSettings,n=e===`zh`,{data:r,error:i,mutate:a}=_(`connector-service`,C),[o,l]=(0,k.useState)(``),[u,d]=(0,k.useState)(!1),[f,p]=(0,k.useState)(),[m,h]=(0,k.useState)();async function g(e){d(!0),p(void 0);try{await e(),l(``),await a()}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!1)}}return(0,A.jsxs)(`div`,{className:`space-y-6`,children:[!r&&!i?(0,A.jsx)(y,{className:`h-40 w-full`}):null,r?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-edge p-4`,children:[(0,A.jsx)(`h2`,{className:`font-medium`,children:`XOPC Cloud`}),(0,A.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioSetupHint}),(0,A.jsx)(b,{providerId:`xopc-cloud`,displayName:`XOPC Cloud`,connected:r.mode===`managed`&&r.configured,onConnected:()=>{a()}}),(0,A.jsx)(v,{variant:`secondary`,disabled:u||r.mode===`managed`&&r.configured,onClick:()=>void g(()=>S({mode:`managed`})),children:r.mode===`managed`?n?`当前服务`:`Current service`:n?`使用 XOPC Cloud`:`Use XOPC Cloud`})]}),(0,A.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,A.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:t.composioSetupByok}),(0,A.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,A.jsxs)(`ol`,{className:`list-inside list-decimal text-sm text-fg-muted`,children:[(0,A.jsx)(`li`,{children:t.composioSetupStepProject}),(0,A.jsx)(`li`,{children:t.composioSetupStepKey}),(0,A.jsx)(`li`,{children:t.composioSetupStepPaste})]}),(0,A.jsx)(`a`,{href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,className:`text-sm text-accent-fg`,children:t.composioSetupOpenDashboard}),(0,A.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,A.jsx)(`span`,{children:`Composio API key`}),(0,A.jsx)(x,{value:o,onChange:l,labels:t.secretInputLabels,placeholder:t.composioSetupKeyPlaceholder})]}),(0,A.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioSetupStorageHint}),(0,A.jsx)(v,{disabled:u||!o.trim(),onClick:()=>void g(()=>T(o)),children:n?`验证并使用新项目`:`Verify and use new project`}),(0,A.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n?`验证只检查连接服务和现有账号访问,不执行写入。工具权限在实际使用时检查。环境变量密钥需在运行环境中修改。`:`Verification checks service and existing account access without writes. Tool permissions are checked on use. Environment keys must be updated in the gateway environment.`}),(0,A.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioSessionWritePermissionHint}),r.backends?.filter(e=>e.mode===`byok`).map(e=>(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 text-sm`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`p`,{children:e.label}),(0,A.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[e.credentialSource===`environment`?n?`环境变量`:`Environment`:n?`本地保存`:`Stored locally`,e.verifiedAt&&` · ${new Date(e.verifiedAt).toLocaleString()}`]})]}),(0,A.jsx)(v,{variant:`ghost`,disabled:u||!o.trim()||e.credentialSource===`environment`,onClick:()=>void g(()=>T(o,e.id)),children:n?`用上方密钥更新`:`Update with key above`}),(0,A.jsx)(v,{variant:`ghost`,disabled:u||e.id===r.backendId,onClick:()=>void g(()=>S({backendId:e.id})),children:e.id===r.backendId?n?`当前服务`:`Current service`:n?`使用`:`Use`}),(0,A.jsx)(v,{variant:`ghost`,disabled:u||e.id===r.backendId,onClick:()=>h(e.id),children:n?`移除`:`Remove`})]},e.id))]})]})]}):null,f||i?(0,A.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:f??String(i)}):null,(0,A.jsx)(w,{open:!!m,title:n?`移除连接服务`:`Remove connection service`,description:n?`移除此服务及其本地保存的密钥,不修改环境变量。需要先切换服务并断开该项目的账号,已有数据不会删除。`:`Remove this service and its saved key, without changing environment variables. Switch services and disconnect this project’s accounts first. Existing data is retained.`,confirmLabel:n?`移除`:`Remove`,cancelLabel:t.modalCancel,destructive:!0,onCancel:()=>h(void 0),onConfirm:()=>{let e=m;h(void 0),e&&g(()=>E(e))}})]})}export{D as n,F as t};
1
+ import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{t as a}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as o}from"./x-B_N4OPjy.js";import{n as s}from"./locale-store-BPZR8x9b.js";import{t as c}from"./messages-kFWhF6_t.js";import{a as l,c as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./dist-BGTk37IG.js";import{i as _}from"./vendor-swr-BIWyz7Rc.js";import{t as v}from"./button-CS04eWY9.js";import{t as y}from"./skeleton-BwbyijEw.js";import{At as b,Ko as x,Ps as S,Ss as C,ba as w,ds as T,js as E}from"./index-19rMUT3d.js";var D=t({ConnectorServiceDialog:()=>F,ConnectorServicePage:()=>j}),O=r(),k=e(n(),1),A=i();function j(){let e=(0,O.c)(11),t=s(M),n;e[0]===t?n=e[1]:(n=c(t),e[0]=t,e[1]=n);let r=n.connectorsSettings,i=t===`zh`,o;e[2]===r.title?o=e[3]:(o=(0,A.jsx)(a,{to:`/connectors`,className:`text-sm text-accent-fg`,children:r.title}),e[2]=r.title,e[3]=o);let l=i?`应用连接服务`:`App connection service`,u;e[4]===l?u=e[5]:(u=(0,A.jsx)(`h1`,{className:`text-xl font-semibold`,children:l}),e[4]=l,e[5]=u);let d,f;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,A.jsx)(`p`,{className:`text-sm text-fg-muted`,children:(0,A.jsx)(N,{})}),f=(0,A.jsx)(L,{}),e[6]=d,e[7]=f):(d=e[6],f=e[7]);let p;return e[8]!==o||e[9]!==u?(p=(0,A.jsxs)(`main`,{className:`mx-auto w-full max-w-2xl space-y-6 p-6`,children:[o,u,d,f]}),e[8]=o,e[9]=u,e[10]=p):p=e[10],p}function M(e){return e.language}function N(){let e=(0,O.c)(2),t=s(P)===`zh`?`此设置决定新账号通过哪个服务连接。已有账号继续使用其原来的连接服务。`:`Choose the service for new accounts. Existing accounts keep their original service.`,n;return e[0]===t?n=e[1]:(n=(0,A.jsx)(A.Fragment,{children:t}),e[0]=t,e[1]=n),n}function P(e){return e.language}function F(){let e=(0,O.c)(22),t=s(I),n;e[0]===t?n=e[1]:(n=c(t),e[0]=t,e[1]=n);let r=n.connectorsSettings,i=t===`zh`,a=i?`应用连接服务`:`Connection service`,_;e[2]===a?_=e[3]:(_=(0,A.jsx)(u,{asChild:!0,children:(0,A.jsx)(v,{type:`button`,variant:`secondary`,className:`shrink-0`,children:a})}),e[2]=a,e[3]=_);let y;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,A.jsx)(l,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),e[4]=y):y=e[4];let b=i?`应用连接服务`:`App connection service`,x;e[5]===b?x=e[6]:(x=(0,A.jsx)(h,{className:`text-base font-semibold text-fg`,children:b}),e[5]=b,e[6]=x);let S;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,A.jsx)(d,{className:`mt-1 text-sm text-fg-muted`,children:(0,A.jsx)(N,{})}),e[7]=S):S=e[7];let C;e[8]===x?C=e[9]:(C=(0,A.jsxs)(`div`,{className:`min-w-0`,children:[x,S]}),e[8]=x,e[9]=C);let w;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,A.jsx)(o,{className:`size-5`,"aria-hidden":!0}),e[10]=w):w=e[10];let T;e[11]===r.modalClose?T=e[12]:(T=(0,A.jsx)(f,{asChild:!0,children:(0,A.jsx)(v,{variant:`ghost`,className:`shrink-0 p-1.5`,"aria-label":r.modalClose,children:w})}),e[11]=r.modalClose,e[12]=T);let E;e[13]!==C||e[14]!==T?(E=(0,A.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[C,T]}),e[13]=C,e[14]=T,e[15]=E):E=e[15];let D;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,A.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,A.jsx)(L,{})}),e[16]=D):D=e[16];let k;e[17]===E?k=e[18]:(k=(0,A.jsxs)(p,{children:[y,(0,A.jsxs)(m,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100dvh-2rem,42rem)] w-[min(100%-2rem,42rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-float`,children:[E,D]})]}),e[17]=E,e[18]=k);let j;return e[19]!==k||e[20]!==_?(j=(0,A.jsxs)(g,{children:[_,k]}),e[19]=k,e[20]=_,e[21]=j):j=e[21],j}function I(e){return e.language}function L(){let e=s(e=>e.language),t=c(e).connectorsSettings,n=e===`zh`,{data:r,error:i,mutate:a}=_(`connector-service`,C),[o,l]=(0,k.useState)(``),[u,d]=(0,k.useState)(!1),[f,p]=(0,k.useState)(),[m,h]=(0,k.useState)();async function g(e){d(!0),p(void 0);try{await e(),l(``),await a()}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!1)}}return(0,A.jsxs)(`div`,{className:`space-y-6`,children:[!r&&!i?(0,A.jsx)(y,{className:`h-40 w-full`}):null,r?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-edge p-4`,children:[(0,A.jsx)(`h2`,{className:`font-medium`,children:`XOPC Cloud`}),(0,A.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioSetupHint}),(0,A.jsx)(b,{providerId:`xopc-cloud`,displayName:`XOPC Cloud`,connected:r.mode===`managed`&&r.configured,onConnected:()=>{a()}}),(0,A.jsx)(v,{variant:`secondary`,disabled:u||r.mode===`managed`&&r.configured,onClick:()=>void g(()=>S({mode:`managed`})),children:r.mode===`managed`?n?`当前服务`:`Current service`:n?`使用 XOPC Cloud`:`Use XOPC Cloud`})]}),(0,A.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,A.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:t.composioSetupByok}),(0,A.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,A.jsxs)(`ol`,{className:`list-inside list-decimal text-sm text-fg-muted`,children:[(0,A.jsx)(`li`,{children:t.composioSetupStepProject}),(0,A.jsx)(`li`,{children:t.composioSetupStepKey}),(0,A.jsx)(`li`,{children:t.composioSetupStepPaste})]}),(0,A.jsx)(`a`,{href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,className:`text-sm text-accent-fg`,children:t.composioSetupOpenDashboard}),(0,A.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,A.jsx)(`span`,{children:`Composio API key`}),(0,A.jsx)(x,{value:o,onChange:l,labels:t.secretInputLabels,placeholder:t.composioSetupKeyPlaceholder})]}),(0,A.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioSetupStorageHint}),(0,A.jsx)(v,{disabled:u||!o.trim(),onClick:()=>void g(()=>T(o)),children:n?`验证并使用新项目`:`Verify and use new project`}),(0,A.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n?`验证只检查连接服务和现有账号访问,不执行写入。工具权限在实际使用时检查。环境变量密钥需在运行环境中修改。`:`Verification checks service and existing account access without writes. Tool permissions are checked on use. Environment keys must be updated in the gateway environment.`}),(0,A.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioSessionWritePermissionHint}),r.backends?.filter(e=>e.mode===`byok`).map(e=>(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 text-sm`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`p`,{children:e.label}),(0,A.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[e.credentialSource===`environment`?n?`环境变量`:`Environment`:n?`本地保存`:`Stored locally`,e.verifiedAt&&` · ${new Date(e.verifiedAt).toLocaleString()}`]})]}),(0,A.jsx)(v,{variant:`ghost`,disabled:u||!o.trim()||e.credentialSource===`environment`,onClick:()=>void g(()=>T(o,e.id)),children:n?`用上方密钥更新`:`Update with key above`}),(0,A.jsx)(v,{variant:`ghost`,disabled:u||e.id===r.backendId,onClick:()=>void g(()=>S({backendId:e.id})),children:e.id===r.backendId?n?`当前服务`:`Current service`:n?`使用`:`Use`}),(0,A.jsx)(v,{variant:`ghost`,disabled:u||e.id===r.backendId,onClick:()=>h(e.id),children:n?`移除`:`Remove`})]},e.id))]})]})]}):null,f||i?(0,A.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:f??String(i)}):null,(0,A.jsx)(w,{open:!!m,title:n?`移除连接服务`:`Remove connection service`,description:n?`移除此服务及其本地保存的密钥,不修改环境变量。需要先切换服务并断开该项目的账号,已有数据不会删除。`:`Remove this service and its saved key, without changing environment variables. Switch services and disconnect this project’s accounts first. Existing data is retained.`,confirmLabel:n?`移除`:`Remove`,cancelLabel:t.modalCancel,destructive:!0,onCancel:()=>h(void 0),onConfirm:()=>{let e=m;h(void 0),e&&g(()=>E(e))}})]})}export{D as n,F as t};
@@ -0,0 +1,2 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,g as a}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{n as o,r as s,t as c}from"./popover-select-DcsFzD_i.js";import{t as l}from"./circle-check-C23XjkUj.js";import{t as u}from"./plus-Q2yW6OE7.js";import{t as d}from"./x-B_N4OPjy.js";import{t as f}from"./cn-JdwAhgNB.js";import{c as p,n as m}from"./locale-store-BPZR8x9b.js";import{t as h}from"./messages-kFWhF6_t.js";import{a as g,i as _,n as v,o as y,r as b,s as x,t as S}from"./dist-BGTk37IG.js";import{n as C}from"./copy-to-clipboard-HOJ79TWv.js";import{t as w}from"./button-CS04eWY9.js";import{r as T}from"./gateway-config-swr-CoQVulMd.js";import{t as E}from"./skeleton-BwbyijEw.js";import{i as D,o as O}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as k}from"./electron-env-Dit0bHgy.js";import{a as A,i as j,n as M,r as N,t as P}from"./dist-Che_jiQF.js";import{$ as F,$c as I,An as L,As as R,Bs as z,Cs as B,Do as ee,Ds as V,Dt as H,El as U,Es as te,Fn as ne,Fs as re,Gs as ie,Hs as ae,In as oe,Io as se,Is as ce,Ju as le,Lc as ue,Ln as de,Ls as fe,Mn as pe,Ms as me,Ns as he,Oc as ge,Os as _e,Ot as ve,Pn as ye,Q as be,Rs as W,Ts as xe,Ul as G,Us as Se,Vs as Ce,Ws as we,X as K,Xc as q,Xu as J,Z as Te,Zl as Ee,Zo as De,_s as Oe,ba as ke,bs as Ae,el as je,et as Y,fs as Me,gl as X,gs as Ne,hs as Pe,il as Fe,jc as Ie,jn as Le,kn as Re,ks as ze,kt as Be,ku as Ve,ld as He,ml as Ue,ms as We,nl as Ge,nt as Ke,od as qe,ou as Je,ps as Ye,qc as Xe,qs as Ze,sd as Qe,sl as $e,tt as et,vs as tt,ws as nt,xc as rt,xs as it,ya as at,ys as ot,zn as st,zs as ct,zu as lt}from"./index-19rMUT3d.js";import{t as ut}from"./connector-service-page-B5EhnfJH.js";import{t as dt}from"./page-tabs-Dyc3wKkl.js";import{a as ft,c as pt,d as mt,f as ht,g as gt,h as _t,i as vt,l as yt,m as bt,n as xt,o as St,p as Ct,r as wt,s as Tt,u as Et}from"./agent-plugin-dialog-DMv-udoZ.js";var Z=e(t(),1),Q=n(),$=r();function Dt(e){let t=(0,Q.c)(57),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:o}=e,s,c,u,d,p,m;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==o){let e=n.capabilities.filter(Ot),h=e.slice(0,2),g=Math.max(0,e.length-h.length),_=o.connect,v;t[11]!==n||t[12]!==o?(v=F(n,o),t[11]=n,t[12]=o,t[13]=v):v=t[13];let y=v,b=n.verificationLevel===`verified`?o.connectorVerified:n.verificationLevel===`beta`?o.connectorBeta:n.verificationLevel===`experimental`?o.connectorExperimental:null,x;t[14]!==_||t[15]!==n||t[16]!==i?(x=e=>(0,$.jsxs)(w,{type:`button`,variant:`primary`,className:f(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:()=>i(n),children:[(0,$.jsx)(U,{className:`size-4`}),_]}),t[14]=_,t[15]=n,t[16]=i,t[17]=x):x=t[17],s=x,m=`group flex min-h-[8.75rem] flex-col rounded-xl border border-edge bg-surface-panel p-4 transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,c=`flex min-w-0 flex-1 flex-col`;let S;t[18]===n?S=t[19]:(S=(0,$.jsx)(Ke,{connector:n}),t[18]=n,t[19]=S);let C;t[20]!==n||t[21]!==a?(C=a?(0,$.jsx)(`button`,{type:`button`,className:`block max-w-full truncate text-left text-sm font-semibold text-fg hover:underline`,onClick:()=>a(n),children:n.displayName}):(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[20]=n,t[21]=a,t[22]=C):C=t[22];let T;t[23]===b?T=t[24]:(T=b?(0,$.jsx)(`span`,{className:`mt-1 inline-flex rounded-full border border-edge px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:b}):null,t[23]=b,t[24]=T);let E;t[25]!==T||t[26]!==C?(E=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[C,T]}),t[25]=T,t[26]=C,t[27]=E):E=t[27];let D;t[28]!==E||t[29]!==S?(D=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[S,E]}),t[28]=E,t[29]=S,t[30]=D):D=t[30];let O;t[31]!==r||t[32]!==s?(O=r?null:(0,$.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 sm:flex`,children:s()}),t[31]=r,t[32]=s,t[33]=O):O=t[33];let k;t[34]!==r||t[35]!==o.connectedBadge?(k=r?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(l,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[34]=r,t[35]=o.connectedBadge,t[36]=k):k=t[36];let A;t[37]!==O||t[38]!==k?(A=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[O,k]}),t[37]=O,t[38]=k,t[39]=A):A=t[39],t[40]!==D||t[41]!==A?(u=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[D,A]}),t[40]=D,t[41]=A,t[42]=u):u=t[42],t[43]===y?d=t[44]:(d=(0,$.jsx)(`p`,{className:`mt-3 line-clamp-2 text-sm leading-6 text-fg-muted`,title:y,children:y}),t[43]=y,t[44]=d),p=h.length>0?(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[h.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:o.connectorCapabilityLabels[e]??e},e)),g>0?(0,$.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,g]}):null]}):null,t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=u,t[8]=d,t[9]=p,t[10]=m}else s=t[5],c=t[6],u=t[7],d=t[8],p=t[9],m=t[10];let h;t[45]!==c||t[46]!==u||t[47]!==d||t[48]!==p?(h=(0,$.jsxs)(`div`,{className:c,children:[u,d,p]}),t[45]=c,t[46]=u,t[47]=d,t[48]=p,t[49]=h):h=t[49];let g;t[50]!==r||t[51]!==s?(g=r?null:(0,$.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:s(`w-full`)}),t[50]=r,t[51]=s,t[52]=g):g=t[52];let _;return t[53]!==m||t[54]!==h||t[55]!==g?(_=(0,$.jsxs)(`div`,{className:m,children:[h,g]}),t[53]=m,t[54]=h,t[55]=g,t[56]=_):_=t[56],_}function Ot(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var kt=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function At(e,t){return t.some(t=>t.connectorId===e.id)}var jt=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function Mt(){let e=(0,Q.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:f(`size-10 shrink-0 rounded-xl`,jt)}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{className:`flex h-full min-h-[9.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:f(`h-4 min-w-0 flex-1`,jt)}),(0,$.jsx)(`div`,{className:f(`h-8 w-[4.5rem] shrink-0 rounded-lg`,jt)})]}),(0,$.jsx)(`div`,{className:f(`h-3 w-full`,jt)}),(0,$.jsx)(`div`,{className:f(`h-3 w-[88%]`,jt)})]})]})}),e[1]=n):n=e[1],n}var Nt=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function Pt(){let e=(0,Q.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:f(`size-10 shrink-0 rounded-xl`,Nt)}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,$.jsx)(`div`,{className:f(`h-4 w-48 max-w-full`,Nt)}),(0,$.jsx)(`div`,{className:f(`h-3 w-72 max-w-full`,Nt)})]}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-start justify-between gap-3`,children:[n,(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,$.jsx)(`div`,{className:f(`h-9 w-20 rounded-lg`,Nt)}),(0,$.jsx)(`div`,{className:f(`h-9 w-20 rounded-lg`,Nt)})]})]})]}),e[2]=r):r=e[2];let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:[r,(0,$.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,$.jsx)(`div`,{className:f(`h-8 w-20 rounded-md`,Nt)}),(0,$.jsx)(`div`,{className:f(`h-8 w-24 rounded-md`,Nt)}),(0,$.jsx)(`div`,{className:f(`h-8 w-28 rounded-md`,Nt)})]}),(0,$.jsx)(`div`,{className:f(`mt-3 h-20 rounded-xl`,Nt)})]}),e[3]=i):i=e[3],i}var Ft=[`understand`,`act`,`reach`];function It(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 Lt(e){return It(e)[0]??`act`}function Rt(e,t){let n=t?Lt(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 zt(e,t){return t.connectorCapabilityLabels[e]??e}function Bt(e,t){if(e.runtime.type===`mcp`)return Y(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.type===`composio`?e.runtime.toolkit:e.runtime.type===`cli`?e.runtime.adapterId:e.runtime.sourceKind;return Y(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n??e.runtime.type})}function Vt(e,t){return e.auth.mode===`cli`?t.connectorAuthCli:e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function Ht(e){let t=(0,Q.c)(9),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,$.jsx)(`h4`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,12).map(Ut),t[2]=r,t[3]=a);let o;t[4]===a?o=t[5]:(o=(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-lg border border-edge bg-surface-panel`,children:a}),t[4]=a,t[5]=o);let s;return t[6]!==i||t[7]!==o?(s=(0,$.jsxs)(`section`,{children:[i,o]}),t[6]=i,t[7]=o,t[8]=s):s=t[8],s}function Ut(e){return(0,$.jsxs)(`div`,{className:`px-3 py-2.5`,children:[(0,$.jsx)(`p`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function Wt({connector:e,installed:t,onClose:n,onInstall:r,t:i}){let[a,o]=(0,Z.useState)(!1),s=F(e,i),[c,u]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(null),h=It(e),C=[...(e.setup.secrets??[]).filter(e=>e.required),...(e.setup.config??[]).filter(e=>e.required)],T=e.capabilities.filter(e=>!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)),E=async()=>{o(!0),m(null);try{u(await ze(e))}catch(e){u(null),m(e instanceof Error?e.message:String(e))}finally{o(!1)}};return(0,$.jsx)(S,{open:!0,onOpenChange:e=>{e||n()},children:(0,$.jsxs)(y,{children:[(0,$.jsx)(g,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(b,{className:f(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,42rem)] w-[min(100%-2rem,min(92vw,44rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-float outline-none dark:border-edge`),children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-5 py-5 sm:px-6`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(Ke,{connector:e,size:`lg`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(x,{className:`text-base font-semibold text-fg`,children:e.displayName}),t?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(l,{className:`size-3`,"aria-hidden":!0}),i.connectedBadge]}):null]}),(0,$.jsx)(_,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:s})]})]}),(0,$.jsx)(v,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:f(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Ze.focusRingPanel),"aria-label":i.modalClose,children:(0,$.jsx)(d,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-5 sm:px-6`,children:[h.length?(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.connectorWhyConnect}),(0,$.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:h.map(e=>(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:i.connectorBenefitHeadings[e]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:i.connectorBenefitHints[e]})]},e))})]}):null,(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,$.jsx)(Je,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:i.detailPermissions}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:Vt(e,i)})]})]}),(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:i.connectorSetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:C.length?Y(i.connectorRequiredInputsCount,{count:String(C.length)}):i.connectorSetupNone})]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:i.connectorTechnicalDetails}),(0,$.jsxs)(`div`,{className:`space-y-5 border-t border-edge-subtle px-4 py-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,$.jsx)(je,{className:`size-3.5`,"aria-hidden":!0}),i.connectorRuntimeTitle]}),(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-subtle`,children:Bt(e,i)})]}),T.length?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:T.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:zt(e,i)},e))}):null,(0,$.jsxs)(w,{variant:`secondary`,disabled:a,onClick:()=>void E(),children:[a?(0,$.jsx)(G,{className:`size-4 animate-spin`}):(0,$.jsx)(rt,{className:`size-4`}),i.connectorPreviewButton]}),p?(0,$.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:p}):null,c?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(Ht,{title:i.detailTools,items:c.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,$.jsx)(Ht,{title:i.detailResources,items:c.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description}))}),(0,$.jsx)(Ht,{title:i.detailPrompts,items:c.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description}))})]}):null]})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4 sm:px-6`,children:[(0,$.jsx)(v,{asChild:!0,children:(0,$.jsx)(w,{variant:`secondary`,children:i.modalClose})}),t?null:(0,$.jsxs)(w,{variant:`primary`,onClick:()=>{r(e),n()},children:[(0,$.jsx)(U,{className:`size-4`}),i.connect]})]})]})]})})}var Gt=f(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,De);function Kt(e){let t=(0,Q.c)(58),{open:n,sessionIdleTtlMinutes:r,saving:i,onChange:a,onSave:o,onClose:s,t:c,mcp:l}=e,u;t[0]===s?u=t[1]:(u=e=>{e||s()},t[0]=s,t[1]=u);let p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(g,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[2]=p):p=t[2];let m;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(m=f(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(32rem,calc(100vh-2rem))] w-[min(100%-2rem,38rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-float dark:border-edge`),t[3]=m):m=t[3];let h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,$.jsx)(Ue,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})}),t[4]=h):h=t[4];let C;t[5]===c.runtimeSettingsTitle?C=t[6]:(C=(0,$.jsx)(x,{className:`text-base font-semibold text-fg`,children:c.runtimeSettingsTitle}),t[5]=c.runtimeSettingsTitle,t[6]=C);let T;t[7]===c.runtimeSettingsHint?T=t[8]:(T=(0,$.jsx)(_,{className:`mt-1 text-sm text-fg-muted`,children:c.runtimeSettingsHint}),t[7]=c.runtimeSettingsHint,t[8]=T);let E;t[9]!==C||t[10]!==T?(E=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[h,(0,$.jsxs)(`div`,{className:`min-w-0`,children:[C,T]})]}),t[9]=C,t[10]=T,t[11]=E):E=t[11];let D;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(D=f(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Ze.focusRingPanel),t[12]=D):D=t[12];let O;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(d,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=O):O=t[13];let k;t[14]===c.modalClose?k=t[15]:(k=(0,$.jsx)(v,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:D,"aria-label":c.modalClose,children:O})}),t[14]=c.modalClose,t[15]=k);let A;t[16]!==k||t[17]!==E?(A=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[E,k]}),t[16]=k,t[17]=E,t[18]=A):A=t[18];let j;t[19]===l.idleTtlLabel?j=t[20]:(j=(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:l.idleTtlLabel}),t[19]=l.idleTtlLabel,t[20]=j);let M;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(M=f(Gt,`w-40 flex-none`),t[21]=M):M=t[21];let N=r??``,P;t[22]===a?P=t[23]:(P=e=>{let t=e.currentTarget.value.trim();a(t===``?void 0:Number.parseInt(t,10))},t[22]=a,t[23]=P);let F;t[24]!==l.idleTtlPlaceholder||t[25]!==N||t[26]!==P?(F=(0,$.jsx)(`input`,{type:`number`,min:0,className:M,value:N,placeholder:l.idleTtlPlaceholder,onChange:P}),t[24]=l.idleTtlPlaceholder,t[25]=N,t[26]=P,t[27]=F):F=t[27];let I;t[28]===l.idleTtlHint?I=t[29]:(I=(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:l.idleTtlHint}),t[28]=l.idleTtlHint,t[29]=I);let L;t[30]!==j||t[31]!==F||t[32]!==I?(L=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,$.jsxs)(`label`,{className:`flex max-w-xl flex-col gap-1.5`,children:[j,F,I]})}),t[30]=j,t[31]=F,t[32]=I,t[33]=L):L=t[33];let R;t[34]!==s||t[35]!==i||t[36]!==c.modalCancel?(R=(0,$.jsx)(w,{type:`button`,variant:`secondary`,disabled:i,onClick:s,children:c.modalCancel}),t[34]=s,t[35]=i,t[36]=c.modalCancel,t[37]=R):R=t[37];let z;t[38]===o?z=t[39]:(z=()=>void o(),t[38]=o,t[39]=z);let B;t[40]===i?B=t[41]:(B=i?(0,$.jsx)(G,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[40]=i,t[41]=B);let ee;t[42]!==l.save||t[43]!==i||t[44]!==z||t[45]!==B?(ee=(0,$.jsxs)(w,{type:`button`,variant:`primary`,disabled:i,onClick:z,children:[B,l.save]}),t[42]=l.save,t[43]=i,t[44]=z,t[45]=B,t[46]=ee):ee=t[46];let V;t[47]!==R||t[48]!==ee?(V=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[R,ee]}),t[47]=R,t[48]=ee,t[49]=V):V=t[49];let H;t[50]!==A||t[51]!==L||t[52]!==V?(H=(0,$.jsxs)(y,{children:[p,(0,$.jsxs)(b,{className:m,children:[A,L,V]})]}),t[50]=A,t[51]=L,t[52]=V,t[53]=H):H=t[53];let U;return t[54]!==n||t[55]!==u||t[56]!==H?(U=(0,$.jsx)(S,{open:n,onOpenChange:u,children:H}),t[54]=n,t[55]=u,t[56]=H,t[57]=U):U=t[57],U}var qt=(0,Z.memo)(function(e){let t=(0,Q.c)(12),{value:n,onChange:r,placeholder:i,className:a}=e,o;t[0]===a?o=t[1]:(o=f(`relative flex min-h-11 sm:min-h-9 min-w-0 flex-1 cursor-text items-center rounded-pill border border-edge bg-surface-panel py-1.5 pl-9 pr-3 focus-within:ring-2 focus-within:ring-accent`,a),t[0]=a,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(Ge,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=s):s=t[2];let c;t[3]===r?c=t[4]:(c=e=>r(e.currentTarget.value),t[3]=r,t[4]=c);let l;t[5]!==i||t[6]!==c||t[7]!==n?(l=(0,$.jsx)(`input`,{type:`search`,"aria-label":i,enterKeyHint:`search`,value:n,onChange:c,placeholder:i,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-base sm:text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`}),t[5]=i,t[6]=c,t[7]=n,t[8]=l):l=t[8];let u;return t[9]!==o||t[10]!==l?(u=(0,$.jsxs)(`label`,{className:o,children:[s,l]}),t[9]=o,t[10]=l,t[11]=u):u=t[11],u}),Jt=(0,Z.memo)(function(e){let t=(0,Q.c)(28),{onRefresh:n,refreshing:r,refreshLabel:i,onBrowseCatalog:a,onAddCustomServer:o,addLabel:s,browseLabel:c,customLabel:l}=e,d;t[0]!==n||t[1]!==i||t[2]!==r?(d=n?(0,$.jsx)(at,{className:`size-9 shrink-0 p-0`,loading:r,label:i,title:i,onClick:n}):null,t[0]=n,t[1]=i,t[2]=r,t[3]=d):d=t[3];let p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(ut,{}),t[4]=p):p=t[4];let m;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(u,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[5]=m):m=t[5];let h;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(He,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[6]=h):h=t[6];let g;t[7]===s?g=t[8]:(g=(0,$.jsx)(st,{asChild:!0,children:(0,$.jsxs)(w,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,children:[m,s,h]})}),t[7]=s,t[8]=g);let _;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(_=f(`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,Ze.transition),t[9]=_):_=t[9];let v;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(ue,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[10]=v):v=t[10];let y;t[11]!==c||t[12]!==a?(y=(0,$.jsxs)(ne,{className:_,onSelect:a,children:[v,c]}),t[11]=c,t[12]=a,t[13]=y):y=t[13];let b;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(b=f(`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,Ze.transition),t[14]=b):b=t[14];let x;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(rt,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[15]=x):x=t[15];let S;t[16]!==l||t[17]!==o?(S=(0,$.jsxs)(ne,{className:b,onSelect:o,children:[x,l]}),t[16]=l,t[17]=o,t[18]=S):S=t[18];let C;t[19]!==S||t[20]!==y?(C=(0,$.jsx)(oe,{children:(0,$.jsxs)(ye,{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:[y,S]})}),t[19]=S,t[20]=y,t[21]=C):C=t[21];let T;t[22]!==C||t[23]!==g?(T=(0,$.jsxs)(de,{children:[g,C]}),t[22]=C,t[23]=g,t[24]=T):T=t[24];let E;return t[25]!==d||t[26]!==T?(E=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[d,p,T]}),t[25]=d,t[26]=T,t[27]=E):E=t[27],E});function Yt(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 Xt({row:e,t,cs:n,onEdit:r,onRemove:i}){let[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),y=Yt(e),b=e.transport===`streamable-http`&&e.auth===`oauth`;(0,Z.useEffect)(()=>{if(!b){g(null);return}let t=!1,n=async()=>{try{let n=await pt(e.id.trim());t||(g(n),n.status===`error`&&n.session?.error&&m(n.session.error),n.status===`connected`&&m(null))}catch(e){t||m(e instanceof Error?e.message:String(e))}};n();let r=window.setInterval(()=>{h?.status===`authorizing`&&n()},1e3);return()=>{t=!0,window.clearInterval(r)}},[h?.status,e.id,b]);let x=(0,Z.useCallback)(async()=>{v(!0),m(null);let n=Be();try{let r=await bt(e.id.trim());g(r),r.status===`error`&&r.session?.error&&m(r.session.error),r.status===`connected`&&m(null);let i=r.session?.authorizationUrl;i?await ve(i,n)||m(t.oauthOpenFailed):H(n)}catch(e){H(n),m(e instanceof Error?e.message:String(e))}finally{v(!1)}},[e.id,t.oauthOpenFailed]),S=(0,Z.useCallback)(async()=>{v(!0),m(null);try{g(await ft(e.id.trim()))}catch(e){m(e instanceof Error?e.message:String(e))}finally{v(!1)}},[e.id]),C=(0,Z.useCallback)(async()=>{o(!0),m(null);try{let t=await _t(e.id.trim());f({toolCount:t.toolCount,resourceCount:t.resourceCount,promptCount:t.promptCount})}catch(e){m(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.id]),T=(0,Z.useCallback)(async()=>{c(!0),m(null);try{await i()}catch(e){m(e instanceof Error?e.message:String(e)),c(!1)}},[i]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`px-4 py-3.5 hover:bg-surface-hover/50`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`block w-full min-w-0 text-left`,onClick:r,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.id.trim()||t.cardUntitled}),(0,$.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:n.customBadge}),(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.transportLabels[e.transport]}),b&&h?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:t.oauthStatus[h.status===`not_configured`?`disconnected`:h.status]}):null]}),y?(0,$.jsx)(`p`,{className:`mt-3 line-clamp-2 break-all font-mono text-xs leading-5 text-fg-subtle`,title:y,children:y}):null,p?(0,$.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:p}):null,d?(0,$.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:Y(n.customCapabilitySummary,{tools:String(d.toolCount),resources:String(d.resourceCount),prompts:String(d.promptCount)})}):null]}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[b&&h?.status!==`connected`?(0,$.jsxs)(w,{variant:`secondary`,disabled:_,onClick:()=>void x(),children:[_?(0,$.jsx)(G,{className:`size-4 animate-spin`}):(0,$.jsx)(Ee,{className:`size-4`}),h?.status===`authorizing`?t.oauthOpenAuthorization:t.oauthConnect]}):(0,$.jsxs)(w,{variant:`secondary`,disabled:a,onClick:()=>void C(),children:[a?(0,$.jsx)(G,{className:`size-4 animate-spin`}):(0,$.jsx)(X,{className:`size-4`}),t.testConnection]}),b&&h?.status===`connected`?(0,$.jsxs)(w,{variant:`ghost`,disabled:_,onClick:()=>void S(),children:[_?(0,$.jsx)(G,{className:`size-4 animate-spin`}):(0,$.jsx)(ge,{className:`size-4`}),t.oauthDisconnect]}):null,(0,$.jsxs)(w,{variant:`ghost`,disabled:s,onClick:()=>u(!0),children:[s?(0,$.jsx)(G,{className:`size-4 animate-spin`}):(0,$.jsx)(Ie,{className:`size-4`}),t.removeServer]})]})]}),(0,$.jsx)(ke,{open:l,title:n.removeConfirmTitle.replace(`{{name}}`,e.id.trim()||t.cardUntitled),description:n.removeConfirmDescription,confirmLabel:t.removeServer,cancelLabel:n.modalCancel,destructive:!0,onConfirm:()=>{u(!1),T()},onCancel:()=>{s||u(!1)}})]})}function Zt(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||Zt(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
2
+ `).toLowerCase().includes(r)}function $t(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function en(e){let t=(0,Q.c)(29),{tools:n,stripPrefix:r,searchPlaceholder:i,searchEmptyLabel:a}=e,[o,s]=(0,Z.useState)(``),c;if(t[0]!==o||t[1]!==r||t[2]!==n){let e;t[4]!==o||t[5]!==r?(e=e=>Qt(e,o,r),t[4]=o,t[5]=r,t[6]=e):e=t[6],c=n.filter(e),t[0]=o,t[1]=r,t[2]=n,t[3]=c}else c=t[3];let l=c,u;t[7]===o?u=t[8]:(u=o.trim(),t[7]=o,t[8]=u);let d=u.length>0,p;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(Ge,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=p):p=t[9];let m,h;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=f(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg`,`placeholder:text-fg-subtle`,De),h=e=>s(e.target.value),t[10]=m,t[11]=h):(m=t[10],h=t[11]);let g;t[12]!==o||t[13]!==i?(g=(0,$.jsxs)(`div`,{className:`relative`,children:[p,(0,$.jsx)(`input`,{type:`search`,value:o,placeholder:i,"aria-label":i,className:m,onChange:h})]}),t[12]=o,t[13]=i,t[14]=g):g=t[14];let _;t[15]!==l.length||t[16]!==d||t[17]!==n.length?(_=d?(0,$.jsxs)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:[l.length,` / `,n.length]}):null,t[15]=l.length,t[16]=d,t[17]=n.length,t[18]=_):_=t[18];let v;t[19]!==g||t[20]!==_?(v=(0,$.jsxs)(`div`,{className:`border-b border-edge px-5 py-3`,children:[g,_]}),t[19]=g,t[20]=_,t[21]=v):v=t[21];let y;t[22]!==l||t[23]!==a||t[24]!==r?(y=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:l.length===0?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-2`,children:l.map((e,t)=>{let n=e.shortName||$t(e.name,r)||e.name||`?`,i=e.name||`tool-${t}`;return(0,$.jsxs)(`li`,{className:`min-w-0 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[(0,$.jsx)(`div`,{className:`truncate font-mono text-sm font-medium text-fg`,title:e.name===n?n:e.name,children:n}),e.description?(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs leading-relaxed text-fg-muted`,title:e.description,children:e.description}):null]},i)})})}),t[22]=l,t[23]=a,t[24]=r,t[25]=y):y=t[25];let b;return t[26]!==v||t[27]!==y?(b=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=b):b=t[28],b}function tn(e){let t=(0,Q.c)(38),{open:n,onOpenChange:r,serverId:i,title:a,subtitle:o,searchPlaceholder:s,searchEmptyLabel:c,emptyLabel:l,closeLabel:u,tools:p,stripPrefix:m}=e,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(g,{className:f(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,O)}),t[0]=h):h=t[0];let C;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(C=f(`xopc-dialog-content fixed left-1/2 top-1/2 flex max-h-[min(88vh,40rem)] w-[min(100%-2rem,min(92vw,36rem))] -translate-x-1/2 -translate-y-1/2 flex-col`,D,`rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none dark:border-edge`),t[1]=C):C=t[1];let T;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(rt,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[2]=T):T=t[2];let E;t[3]===a?E=t[4]:(E=(0,$.jsxs)(x,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[T,a]}),t[3]=a,t[4]=E);let k;t[5]!==i||t[6]!==o||t[7]!==p.length?(k=o.replace(`{{serverId}}`,i).replace(`{{count}}`,String(p.length)),t[5]=i,t[6]=o,t[7]=p.length,t[8]=k):k=t[8];let A;t[9]===k?A=t[10]:(A=(0,$.jsx)(_,{className:`mt-1 text-sm text-fg-muted`,children:k}),t[9]=k,t[10]=A);let j;t[11]!==E||t[12]!==A?(j=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[E,A]}),t[11]=E,t[12]=A,t[13]=j):j=t[13];let M;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(d,{className:`size-4`,"aria-hidden":!0}),t[14]=M):M=t[14];let N;t[15]===u?N=t[16]:(N=(0,$.jsx)(v,{asChild:!0,children:(0,$.jsx)(w,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":u,children:M})}),t[15]=u,t[16]=N);let P;t[17]!==j||t[18]!==N?(P=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[j,N]}),t[17]=j,t[18]=N,t[19]=P):P=t[19];let F;t[20]!==l||t[21]!==n||t[22]!==c||t[23]!==s||t[24]!==i||t[25]!==m||t[26]!==p?(F=p.length>0?(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,$.jsx)(en,{tools:p,stripPrefix:m,searchPlaceholder:s,searchEmptyLabel:c},`${i}-${n?`open`:`closed`}`)}):(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l})}),t[20]=l,t[21]=n,t[22]=c,t[23]=s,t[24]=i,t[25]=m,t[26]=p,t[27]=F):F=t[27];let I;t[28]===u?I=t[29]:(I=(0,$.jsx)(`div`,{className:`flex justify-end border-t border-edge px-5 py-3`,children:(0,$.jsx)(v,{asChild:!0,children:(0,$.jsx)(w,{type:`button`,variant:`secondary`,children:u})})}),t[28]=u,t[29]=I);let L;t[30]!==P||t[31]!==F||t[32]!==I?(L=(0,$.jsxs)(y,{children:[h,(0,$.jsxs)(b,{className:C,children:[P,F,I]})]}),t[30]=P,t[31]=F,t[32]=I,t[33]=L):L=t[33];let R;return t[34]!==r||t[35]!==n||t[36]!==L?(R=(0,$.jsx)(S,{open:n,onOpenChange:r,children:L}),t[34]=r,t[35]=n,t[36]=L,t[37]=R):R=t[37],R}function nn(e){let t=e.connectedAt?Date.parse(e.connectedAt):0;return Number.isFinite(t)?t:0}function rn(e,t){return e.status===`active`&&t.status!==`active`?-1:e.status!==`active`&&t.status===`active`?1:e.isCurrentAuthorization===t.isCurrentAuthorization?nn(t)-nn(e):e.isCurrentAuthorization?-1:1}function an(e){let t=new Map;for(let n of e){let e=n.accountId??n.identityKey??`authorization:${n.id}`;t.set(e,[...t.get(e)??[],n])}return[...t.entries()].map(([e,t])=>{let n=[...t].sort(rn);return{key:e,primary:n[0],authorizations:n}}).sort((e,t)=>rn(e.primary,t.primary))}var on=f(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,De);function sn(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function cn(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function ln(e,t,n){return e.status===`connected`?Y(n.composioHealthConnected,{count:String(t)}):e.status===`reauthorization_required`?n.composioHealthReconnect:e.status===`disconnected`?n.composioHealthDisconnected:e.errorCode===`missing_credential`?n.composioHealthMissingCredential:e.errorCode===`unauthorized`?n.composioHealthUnauthorized:e.errorCode===`forbidden`?n.composioHealthForbidden:e.errorCode===`network`?n.composioHealthNetwork:e.errorCode===`timeout`?n.composioHealthTimeout:n.composioHealthDegraded}function un(e,t){return e===`active`?t.composioConnectionHealthy:e===`pending`?t.composioConnectionPending:e===`expired`?t.composioConnectionExpired:e===`failed`?t.composioConnectionFailed:e===`revoked`||e===`disabled`?t.composioConnectionRevoked:t.composioConnectionUnknown}function dn(e,t,n){return e.status===`paused`?t?.scanEnabled===!1?n.connectorLearningPausedByPolicy:n.connectorLearningPausedByFailure:e.status===`queued`?n.connectorLearningQueued:e.status===`running`?n.connectorLearningRunning:e.status===`completed`?n.connectorLearningCompleted:n.connectorLearningFailed}function fn({instance:e,t,onChanged:n}){let r=sn(e),i=m(e=>e.language)===`zh`,[a,c]=(0,Z.useState)([]),[u,d]=(0,Z.useState)([]),[p,h]=(0,Z.useState)([]),[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)([]),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(null),[T,D]=(0,Z.useState)([]),[O,A]=(0,Z.useState)({}),[j,M]=(0,Z.useState)(`read`),[N,P]=(0,Z.useState)(!1),[F,I]=(0,Z.useState)(null),[L,ee]=(0,Z.useState)(!1),[H,U]=(0,Z.useState)(null),[ne,oe]=(0,Z.useState)(null),[se,le]=(0,Z.useState)(!1),[ue,de]=(0,Z.useState)(!1),[pe,me]=(0,Z.useState)(!1),ge=(0,Z.useRef)(0),ve=(0,Z.useRef)(0),ye=(0,Z.useMemo)(()=>an(a),[a]),W=(0,Z.useCallback)(e=>new Promise((t,n)=>{let r=window.setTimeout(()=>n(Error(i?`连接服务响应超时,请重试。`:`The connection service timed out. Please retry.`)),15e3);e.then(t,n).finally(()=>window.clearTimeout(r))}),[i]),K=(0,Z.useCallback)(async()=>{if(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)return;P(!0),I(null);let t=++ge.current;try{let e=(await Promise.allSettled([W(xe()).then(e=>{t===ge.current&&(c(e.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),le(!0))}),W(it(r)).then(e=>{t===ge.current&&M(e)}),W(Ae(r)).then(e=>{t===ge.current&&(_(e.policy),y(e.agents))})])).find(e=>e.status===`rejected`);t===ge.current&&e?.status===`rejected`&&I(String(e.reason instanceof Error?e.reason.message:e.reason))}finally{t===ge.current&&P(!1)}},[e.materialized,r,W]);(0,Z.useEffect)(()=>(K(),()=>{ge.current++}),[K]);let q=(0,Z.useCallback)(async()=>{if(!r)return;let e=++ve.current;me(!0),ee(!1);let t=t=>n=>{e===ve.current&&t(n)},n=await Promise.allSettled([W(te(r)).then(t(d)),W(V(20)).then(t(e=>h(e.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())))),W(B(r)).then(t(C)),W(ot(r)).then(t(x))]);e===ve.current&&(ee(n.some(e=>e.status===`rejected`)),me(!1))},[r,W]);(0,Z.useEffect)(()=>(ue&&q(),()=>{ve.current++}),[ue,q]),(0,Z.useEffect)(()=>{let e=!1,t=an(a).map(e=>e.primary).filter(e=>e.supportsLearning&&e.accountId);if(t.length)return W(_e()).then(t=>{e||D(t)}).catch(()=>{}),Promise.allSettled(t.map(async e=>[e.accountId,await W(nt(e.accountId))])).then(t=>{e||A(Object.fromEntries(t.flatMap(e=>e.status===`fulfilled`?[e.value]:[])))}),()=>{e=!0}},[a,W]);let J=(0,Z.useCallback)(async i=>{if(!r)return;let a=k()?null:window.open(`about:blank`,`_blank`);a&&(a.opener=null),P(!0),I(null);try{if(!k()&&!a)throw Error(`Allow popups to open the authorization page.`);let t=await fe(e.connectorId,i);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if(k()){let e=await window.electronAPI?.shell?.openExternalUrl(t.authorizationUrl);if(!e?.ok)throw Error(e?.error??`Could not open the system browser.`)}else a.location.href=t.authorizationUrl;let o=await ie(r,t.connectionId,12e4,t.attemptId);if(i&&o.accountId!==i)throw Error(`A different account was authorized. The original account and its task bindings were not changed.`);await Promise.all([n?.(),K()])}catch(e){I(be(e,t))}finally{a?.close(),P(!1)}},[e.connectorId,K,n,t,r]),Te=(0,Z.useCallback)(async t=>{P(!0),I(null);try{await Se(e.instanceId,{config:{...e.config??{},authConfigId:t||void 0}}),await Promise.all([n?.(),K()])}catch(e){I(e instanceof Error?e.message:String(e))}finally{P(!1)}},[e.config,e.instanceId,K,n]),Ee=async e=>{let t=k()?null:window.open(`about:blank`,`_blank`);t&&(t.opener=null),I(null);try{let n=await tt(e.id);if(n.authorizationUrl)if(k())await window.electronAPI?.shell?.openExternalUrl(n.authorizationUrl);else if(t)t.location.href=n.authorizationUrl;else throw Error(`Allow popups to reopen authorization.`);else t?.close(),await K()}catch(e){t?.close(),I(e instanceof Error?e.message:String(e))}},De=(0,Z.useCallback)(async e=>{if(r){M(e),I(null);try{await re(r,e)}catch(e){I(e instanceof Error?e.message:String(e)),await K()}}},[K,r]),Oe=(0,Z.useCallback)(async e=>{if(r){I(null);try{_(await ae(r,e))}catch(e){I(e instanceof Error?e.message:String(e))}}},[r]),je=(0,Z.useCallback)(e=>{if(!g)return;let t=g.allowedAgentIds.includes(e);t&&g.allowedAgentIds.length===1||Oe({allowedAgentIds:t?g.allowedAgentIds.filter(t=>t!==e):[...g.allowedAgentIds,e]})},[Oe,g]),X=(0,Z.useCallback)(async e=>{P(!0),I(null);try{await e(),await K()}catch(e){I(e instanceof Error?e.message:String(e))}finally{P(!1)}},[K]);if(!r)return null;if(e.materialized.type===`composio`&&e.materialized.role===`credential`)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioApiKeyStored});let Ne=ye.filter(e=>e.primary.status===`active`).length,Pe=Ne>0?t.composioAddAccount:t.composioConnectAccount,Fe=se&&Ne>0,Le=S?.requiresCustomAuthConfig===!0,Re=S?.authConfigs.filter(e=>e.status===`ENABLED`&&e.isEnabledForToolRouter)??[];return(0,$.jsxs)(`div`,{className:`space-y-5`,children:[(0,$.jsxs)(`section`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`span`,{className:f(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,Fe?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:[Fe?(0,$.jsx)(l,{className:`size-3.5`}):(0,$.jsx)(qe,{className:`size-3.5`}),Fe?t.connectionReady:se||F?t.connectionNeedsSetup:t.connectionChecking]}),se&&(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:Y(t.composioAccountCount,{count:String(ye.length)})})]}),(0,$.jsxs)(w,{variant:`primary`,className:`shrink-0`,disabled:N,onClick:()=>void J(),children:[N?(0,$.jsx)(G,{className:`size-4 animate-spin`}):(0,$.jsx)(Je,{className:`size-4`}),Pe]})]}),F?(0,$.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center justify-between gap-2 rounded-xl border border-danger/20 bg-danger/5 px-3 py-2 text-sm text-danger`,children:[(0,$.jsx)(`p`,{children:F}),(0,$.jsx)(w,{variant:`secondary`,disabled:N,onClick:()=>void K(),children:t.composioRetry})]}):null,b&&!Fe?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-amber-500/25 bg-amber-500/5 p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:ln(b,Ne,t)}),b.recovery===`none`?null:(0,$.jsx)(w,{variant:`secondary`,disabled:N,onClick:()=>void(b.recovery===`retry`?K():J()),children:b.recovery===`retry`?t.composioRetry:t.composioReconnectAccount})]}):null,Le&&Re.length===0?(0,$.jsx)(`p`,{className:`rounded-xl border border-amber-500/25 bg-amber-500/5 px-4 py-3 text-sm text-amber-800 dark:text-amber-200`,children:t.composioAuthConfigEmpty}):null,g?(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle px-4 py-4 sm:grid-cols-[minmax(0,1fr)_15rem] sm:items-start`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAccessTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:j===`read`?t.composioAccessReadHint:j===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,$.jsxs)(o,{value:j,onChange:e=>void De(e.currentTarget.value),children:[(0,$.jsx)(s,{value:`read`,children:t.composioAccessReadOnly}),(0,$.jsx)(s,{value:`write`,children:t.composioAccessReadWrite}),j===`admin`?(0,$.jsx)(s,{value:`admin`,children:t.composioAccessAdminCurrent}):null]})]}),(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm text-fg-muted`,children:t.composioAdvancedSettings}),(0,$.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle px-4 py-4 sm:grid-cols-[minmax(0,1fr)_15rem] sm:items-center`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioConfirmationPolicy}),(0,$.jsxs)(o,{value:g.confirmationPolicy,onChange:e=>void Oe({confirmationPolicy:e.currentTarget.value}),children:[(0,$.jsx)(s,{value:`writes`,children:t.composioConfirmWrites}),(0,$.jsx)(s,{value:`always`,children:t.composioConfirmAlways}),g.confirmationPolicy===`never`?(0,$.jsx)(s,{value:`never`,children:t.composioConfirmNever}):null]})]}),(0,$.jsxs)(`div`,{className:`px-4 py-4`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAllowedAgents}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:g.allowedAgentIds.length?t.composioAllowedAgentsSelected:t.composioAllowedAgentsAll}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,className:f(`rounded-full border px-2.5 py-1 text-xs transition-colors`,g.allowedAgentIds.length===0?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>void Oe({allowedAgentIds:[]}),children:t.composioAllowedAgentsAllOption}),v.map(e=>(0,$.jsx)(`button`,{type:`button`,className:f(`rounded-full border px-2.5 py-1 text-xs transition-colors`,g.allowedAgentIds.includes(e.id)?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>je(e.id),children:e.name},e.id))]})]}),(0,$.jsxs)(`fieldset`,{className:`space-y-2 border-t border-edge-subtle p-4 text-xs text-fg-muted`,children:[(0,$.jsx)(`legend`,{children:i?`可用账号范围`:`Available accounts`}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:g.selectedAccountIds===null,disabled:N,onChange:e=>void Oe({selectedAccountIds:e.currentTarget.checked?null:[]})}),i?`所有账号(包括以后新增)`:`All accounts, including new ones`]}),g.selectedAccountIds!==null&&ye.map(({primary:e})=>e.accountId&&(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:N,checked:g.selectedAccountIds.includes(e.accountId),onChange:t=>void Oe({selectedAccountIds:t.currentTarget.checked?[...g.selectedAccountIds,e.accountId]:g.selectedAccountIds.filter(t=>t!==e.accountId)})}),e.alias??e.accountEmail??e.accountId]},e.accountId)),g.selectedAccountIds?.length===0&&(0,$.jsx)(`p`,{children:i?`未选择账号,Agent 无法使用此应用。`:`No accounts selected. Agents cannot use this app.`})]})]})]}):null,(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.composioConnectedAccounts}),se&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:Y(t.composioAccountCount,{count:String(ye.length)})})]}),(0,$.jsxs)(w,{variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:N,onClick:()=>void K(),children:[(0,$.jsx)($e,{className:f(`size-3.5`,N&&`animate-spin`)}),t.refresh]})]}),ye.length?(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:ye.map(e=>{let r=e.primary,a=T.find(e=>r.accountId?e.accountId===r.accountId:e.connectionId===r.id),c=r.accountId?O[r.accountId]:void 0;return(0,$.jsxs)(`article`,{className:`px-4 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-start justify-between gap-3 sm:flex-row`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,$.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:r.alias??r.workspace??r.accountEmail??r.username??t.composioUnnamedAuthorization})}),(0,$.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:r.accountEmail??r.username??r.workspace??r.accountId}),r.backendLabel&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.backendLabel}),(0,$.jsx)(`p`,{className:f(`mt-1 text-xs`,r.status===`active`?`text-emerald-700 dark:text-emerald-300`:`text-amber-700 dark:text-amber-300`),children:r.accountEnabled===!1?i?`已暂停`:`Paused`:un(r.status,t)}),a?(0,$.jsx)(`p`,{className:f(`mt-1 text-xs`,a.status===`failed`?`text-red-600`:`text-fg-subtle`),children:Y(t.connectorLearningStatus,{status:dn(a,c,t),count:String(a.candidatesCreated)})}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[r.status===`pending`&&(0,$.jsx)(w,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,onClick:()=>void Ee(r),children:i?`继续授权`:`Continue authorization`}),r.accountId&&(0,$.jsx)(w,{variant:`ghost`,className:`h-8 px-2.5 text-xs text-danger`,disabled:N,onClick:()=>oe(r.accountId),children:i?`断开`:`Disconnect`}),r.accountId&&r.status!==`active`&&(0,$.jsx)(w,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:N,onClick:()=>void J(r.accountId),children:t.composioReconnectAccount}),r.accountId&&(0,$.jsx)(w,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:N,onClick:()=>void X(()=>z(r.accountId,{enabled:r.accountEnabled===!1})),children:r.accountEnabled===!1?i?`启用`:`Enable`:i?`暂停`:`Pause`}),r.supportsLearning&&r.status===`active`&&r.accountEnabled!==!1?(0,$.jsxs)(w,{variant:`secondary`,className:`h-8 shrink-0 px-2.5 text-xs`,disabled:N,onClick:()=>void X(async()=>{if(!r.accountId)throw Error(`Connector account is unavailable.`);await ce(r.accountId),await n?.()}),children:[(0,$.jsx)($e,{className:`size-3.5`}),t.composioSyncNow]}):null]})]}),(0,$.jsxs)(`details`,{className:`mt-3 text-xs text-fg-muted`,children:[(0,$.jsx)(`summary`,{className:`w-fit cursor-pointer font-medium hover:text-fg`,children:t.composioAccountSettings}),(0,$.jsxs)(`div`,{className:`mt-3 space-y-4 rounded-lg bg-surface-panel p-3`,children:[r.accountId&&(0,$.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,$.jsx)(`legend`,{className:`mb-2 font-medium`,children:t.composioAllowedAgents}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:N,checked:r.allowedAgentIds==null,onChange:e=>void X(()=>z(r.accountId,{allowedAgentIds:e.currentTarget.checked?null:[]}))}),t.composioAllowedAgentsAllOption]}),r.allowedAgentIds!=null&&v.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:N,checked:r.allowedAgentIds.includes(e.id),onChange:t=>{let n=t.currentTarget.checked;X(()=>z(r.accountId,{allowedAgentIds:n?[...r.allowedAgentIds,e.id]:r.allowedAgentIds.filter(t=>t!==e.id)}))}}),e.name]},e.id)),r.allowedAgentIds?.length===0&&(0,$.jsx)(`p`,{children:i?`未选择 Agent:任何 Agent 都不能使用此账号。`:`No agents selected: this account is unavailable to all agents.`})]}),r.supportsLearning&&c?(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:c.scanEnabled,disabled:N,onChange:e=>void X(()=>we(r.accountId,{scanEnabled:e.currentTarget.checked}))}),t.connectorScheduledScan]}),c.scanEnabled?(0,$.jsxs)(`label`,{className:`sm:col-span-2`,children:[t.connectorScanInterval,(0,$.jsxs)(o,{className:`mt-1`,value:String(c.intervalMinutes??30),disabled:N,onChange:e=>void X(()=>we(r.accountId,{intervalMinutes:Number(e.currentTarget.value)})),children:[(0,$.jsxs)(s,{value:`5`,children:[`5 `,t.connectorMinutes]}),(0,$.jsxs)(s,{value:`15`,children:[`15 `,t.connectorMinutes]}),(0,$.jsxs)(s,{value:`30`,children:[`30 `,t.connectorMinutes]}),(0,$.jsxs)(s,{value:`60`,children:[`60 `,t.connectorMinutes]})]})]}):null]}):null,(0,$.jsxs)(`label`,{className:`block`,children:[t.composioAccountAlias,(0,$.jsx)(`input`,{className:f(on,`mt-1 h-8 py-1 text-xs`),defaultValue:r.alias??``,onBlur:e=>{e.currentTarget.value!==(r.alias??``)&&X(()=>Ce(r.id,{alias:e.currentTarget.value}))}})]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:e.authorizations.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`p`,{className:`min-w-0 break-all font-mono text-fg-subtle`,children:[t.composioAuthorizationId,`: `,e.providerConnectionId]}),(0,$.jsx)(w,{variant:`ghost`,className:`size-7 shrink-0 p-0 text-danger`,title:t.composioRevoke,disabled:N,onClick:()=>U(e.id),children:(0,$.jsx)(Ie,{className:`size-3.5`})})]},e.id))}),(0,$.jsx)(`div`,{className:`flex justify-end gap-1`,children:(0,$.jsx)(w,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:N,onClick:()=>void X(()=>R(r.id)),children:(0,$.jsx)($e,{className:`size-4`})})})]})]})]},e.key)})}):N&&!se?(0,$.jsxs)(`div`,{"aria-busy":`true`,"aria-label":t.connectionChecking,className:`space-y-3`,children:[(0,$.jsx)(E,{className:`h-16 w-full`}),(0,$.jsx)(E,{className:`h-16 w-full`})]}):se?(0,$.jsx)(`div`,{className:`rounded-xl border border-dashed border-edge px-4 py-8 text-center`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioConnectionsEmpty})}):null]}),(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-base`,onToggle:e=>de(e.currentTarget.open),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:t.composioAdvancedSettings}),(0,$.jsxs)(`div`,{className:`space-y-5 border-t border-edge-subtle px-4 py-4`,children:[pe?(0,$.jsx)(E,{"aria-label":t.connectionChecking,className:`h-16 w-full`}):null,L?(0,$.jsxs)(`p`,{className:`rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-200`,children:[t.composioDiagnosticsUnavailable,(0,$.jsx)(w,{variant:`ghost`,disabled:pe,onClick:()=>void q(),children:t.composioRetry})]}):null,S?.mode===`byok`?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAuthConfigTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:Le?t.composioAuthConfigRequiredHint:t.composioAuthConfigOptionalHint})]}),(0,$.jsx)(`a`,{className:`text-xs font-medium text-accent-fg hover:underline`,href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,children:t.composioAuthConfigManage})]}),(0,$.jsxs)(o,{className:`mt-3`,value:typeof e.config?.authConfigId==`string`?e.config.authConfigId:``,disabled:N,onChange:e=>void Te(e.currentTarget.value),children:[Le?null:(0,$.jsx)(s,{value:``,children:t.composioAuthConfigManaged}),Le&&typeof e.config?.authConfigId!=`string`?(0,$.jsx)(s,{value:``,disabled:!0,children:t.composioAuthConfigSelect}):null,Re.map(e=>(0,$.jsxs)(s,{value:e.id,children:[e.name,` · `,e.authScheme??`OAuth`]},e.id))]})]}):null,(0,$.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),(0,$.jsx)(`div`,{className:`space-y-2`,children:u.length?u.slice(0,8).map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:[cn(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),(0,$.jsx)(`div`,{className:`space-y-2`,children:p.length?p.slice(0,5).map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})})]})]})]})]}),(0,$.jsx)(ke,{open:ne!==null,title:i?`断开账号`:`Disconnect account`,description:i?`停止此账号的工具使用和学习,并撤销其全部授权。已保存的数据不会删除。`:`Stop tool access and learning for this account and revoke all its authorizations. Saved data will not be deleted.`,confirmLabel:i?`断开`:`Disconnect`,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=ne;oe(null),e&&X(()=>Me(e))},onCancel:()=>oe(null)}),(0,$.jsx)(ke,{open:H!==null,title:t.composioRevoke,description:t.composioRevokeConfirm,confirmLabel:t.composioRevoke,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=H;U(null),e&&X(()=>he(e))},onCancel:()=>U(null)})]})}var pn=f(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,De);function mn(e,t){return e?t.healthStatusLabels[e]??e:t.healthNotTested}function hn(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 gn(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 _n(e){let t=(0,Q.c)(12),{title:n,description:r,meta:i}=e,a;t[0]===r?a=t[1]:(a=r?(0,$.jsx)(N,{delayDuration:300,skipDelayDuration:100,children:(0,$.jsxs)(j,{children:[(0,$.jsx)(A,{asChild:!0,children:(0,$.jsx)(`p`,{tabIndex:0,title:r,className:f(`mt-1 line-clamp-3 cursor-help text-xs leading-5 text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:r})}),(0,$.jsx)(M,{children:(0,$.jsx)(P,{side:`top`,align:`start`,sideOffset:6,collisionPadding:12,className:`!z-[10000] max-h-[min(16rem,45vh)] max-w-[min(32rem,calc(100vw-2rem))] overflow-y-auto rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-5 text-fg shadow-popover`,children:(0,$.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:r})})})]})}):null,t[0]=r,t[1]=a);let o=a,s;t[2]===n?s=t[3]:(s=(0,$.jsx)(`p`,{className:`min-w-0 break-all font-mono text-xs font-medium leading-5 text-fg`,children:n}),t[2]=n,t[3]=s);let c;t[4]===i?c=t[5]:(c=i?(0,$.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] leading-4 text-fg-subtle`,children:i}):null,t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;return t[9]!==o||t[10]!==l?(u=(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[l,o]}),t[9]=o,t[10]=l,t[11]=u):u=t[11],u}function vn({instance:e,definition:t,onClose:n,onChanged:r,t:i,mcp:a}){let[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),[u,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(!1),[C,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(null),[O,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(`health`),[M,N]=(0,Z.useState)(!1),[P,I]=(0,Z.useState)(()=>hn(t,e)),[L,R]=(0,Z.useState)(null),z=t?.setup.config??[],B=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&z.length>0&&(t?.setup.secrets??[]).length===0,ee=O?O.toolCount:e.usage.lastToolCount,V=e.materialized.type===`mcp`,H=e.materialized.type===`composio`,U=e.materialized.type===`memorySource`,te=t?F(t,i):null,ne=(0,Z.useMemo)(()=>{let t=[[`health`,q,i.detailHealth],[`tools`,rt,`${i.detailTools} ${O?O.toolCount:e.usage.lastToolCount??``}`],[`resources`,lt,`${i.detailResources} ${O?O.resourceCount:e.usage.lastResourceCount??``}`],[`prompts`,Ve,`${i.detailPrompts} ${O?O.promptCount:e.usage.lastPromptCount??``}`],[`permissions`,Je,i.detailPermissions]];return B?[...t,[`config`,lt,i.connectorConfigLabel]]:t},[O,e.usage.lastPromptCount,e.usage.lastResourceCount,e.usage.lastToolCount,B,i]),re=(0,Z.useCallback)(async()=>{s(!0),R(null);try{let t=await ct(e.instanceId);k(t),t.toolCount>0&&j(`tools`),r()}catch(e){R(e instanceof Error?e.message:String(e))}finally{s(!1)}},[e.instanceId,r]),ie=(0,Z.useCallback)(async()=>{l(!0),R(null);try{await me(e.instanceId),await r(),n()}catch(e){R(e instanceof Error?e.message:String(e)),l(!1)}},[e.instanceId,r,n]),ae=(0,Z.useCallback)(async()=>{if(!(!t||!B)){h(!0),R(null);try{let n={};for(let e of t.setup.config??[]){let t=gn(e.type,P[e.key]??``);t!==void 0&&(n[e.key]=t)}await Se(e.instanceId,{config:n}),await r(),j(`health`)}catch(e){R(e instanceof Error?e.message:String(e))}finally{h(!1)}}},[P,t,e.instanceId,r,B]),oe=(0,Z.useCallback)(async()=>{T(!0),D(null),R(null);try{D((await W(e.connectorId)).recordIds.length),await r()}catch(e){R(e instanceof Error?e.message:String(e))}finally{T(!1)}},[e.connectorId,r]);return(0,$.jsxs)(S,{open:!0,onOpenChange:e=>{e||n()},children:[(0,$.jsxs)(y,{children:[(0,$.jsx)(g,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(b,{className:f(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,H?`h-[min(100dvh-2rem,36rem)] w-[min(100%-2rem,40rem)]`:`h-[min(100dvh-2rem,44rem)] w-[min(100%-2rem,min(92vw,54rem))]`,`rounded-2xl border border-edge bg-surface-overlay shadow-float outline-none dark:border-edge`),children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(Ke,{connector:t,size:`lg`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(x,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,$.jsx)(_,{className:`mt-1 text-sm text-fg-muted`,children:te??(e.materialized.type===`mcp`?Y(i.mcpServerRuntime,{serverId:e.materialized.serverId}):Y(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,$.jsx)(v,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:f(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Ze.focusRingPanel),"aria-label":i.modalClose,children:[(0,$.jsx)(d,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[L?(0,$.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:L}):null,V?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ne.map(([e,t,n])=>(0,$.jsxs)(`button`,{type:`button`,className:f(`inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs`,A===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:text-fg`),onClick:()=>j(e),children:[(0,$.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),n]},e))}),(0,$.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[A===`health`?(0,$.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,$.jsxs)(`p`,{children:[i.statusLabel,` `,(0,$.jsx)(`span`,{className:O?.ok?`font-medium text-emerald-700 dark:text-emerald-300`:`font-medium text-fg`,children:mn(O?.status??e.usage.lastHealthStatus,i)})]}),(0,$.jsxs)(`p`,{children:[i.lastCheckLabel,` `,e.usage.lastHealthCheckAt?new Date(e.usage.lastHealthCheckAt).toLocaleString():i.never]}),O?.action?(0,$.jsx)(`p`,{children:O.action}):null]}):null,A===`tools`?O?.tools.length?(0,$.jsxs)(`div`,{className:`grid gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:Y(i.toolsAvailable,{count:String(O.tools.length)})}),(0,$.jsx)(w,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>N(!0),children:a.viewAllTools})]}),(0,$.jsx)(`div`,{className:`grid gap-2`,children:O.tools.slice(0,8).map(e=>(0,$.jsx)(_n,{title:e.shortName??e.name,description:e.description},e.name))})]}):(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-fg-muted`,children:ee?Y(i.toolsLastCheckSummary,{count:String(ee)}):i.toolsRunTestHint}),(0,$.jsxs)(w,{type:`button`,variant:`secondary`,disabled:o,onClick:()=>void re(),children:[o?(0,$.jsx)(G,{className:`size-4 animate-spin`}):(0,$.jsx)(X,{className:`size-4`}),i.test]})]}):null,A===`resources`?O?.resources.length?(0,$.jsx)(`div`,{className:`grid gap-2`,children:O.resources.slice(0,8).map(e=>(0,$.jsx)(_n,{title:e.title??e.name,description:e.uri,meta:e.mimeType},e.uri))}):(0,$.jsx)(`p`,{className:`text-fg-muted`,children:i.resourcesRunTestHint}):null,A===`prompts`?O?.prompts.length?(0,$.jsx)(`div`,{className:`grid gap-2`,children:O.prompts.slice(0,8).map(e=>(0,$.jsx)(_n,{title:e.title??e.name,description:e.description,meta:e.argumentCount?Y(i.promptArgumentCount,{count:String(e.argumentCount)}):void 0},e.name))}):(0,$.jsx)(`p`,{className:`text-fg-muted`,children:i.promptsRunTestHint}):null,A===`permissions`?(0,$.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,$.jsx)(`p`,{children:Y(i.secretsConfigured,{count:String(Object.values(e.secretStatus).filter(Boolean).length)})}),(0,$.jsx)(`p`,{children:e.materialized.type===`mcp`?Y(i.runtimeServerLabel,{runtime:e.materialized.type.toUpperCase(),serverId:e.materialized.serverId}):Y(i.runtimeLabel,{runtime:e.materialized.type.toUpperCase()})}),(0,$.jsx)(`p`,{children:e.materialized.type===`mcp`?i.mcpPolicyHint:i.connectorPolicyHint})]}):null,A===`config`&&B?(0,$.jsx)(`div`,{className:`grid gap-3`,children:z.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,$.jsx)(`input`,{className:pn,value:P[e.key]??``,placeholder:e.placeholder,onChange:t=>I(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]})]}):null,H?(0,$.jsx)(fn,{instance:e,t:i,onChanged:r}):null,U?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl border border-edge bg-surface-base p-4 text-sm`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:i.connectedSourceSync}),te?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:te}):null,E===null?null:(0,$.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:Y(i.connectedSourceSynced,{count:String(E)})})]}),(0,$.jsxs)(w,{disabled:C,onClick:()=>void oe(),children:[C?(0,$.jsx)(G,{className:`size-4 animate-spin`}):(0,$.jsx)(lt,{className:`size-4`}),i.composioSyncNow]})]}),B?(0,$.jsx)(`div`,{className:`grid gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:z.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,$.jsx)(`input`,{className:pn,value:P[e.key]??``,placeholder:e.placeholder,onChange:t=>I(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}):null,!V&&!H&&!U?(0,$.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:(0,$.jsx)(`p`,{children:i.connectorPolicyHint})}):null,(0,$.jsxs)(`details`,{className:`mt-5 rounded-xl border border-edge`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-danger`,children:i.dangerZone}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 border-t border-danger/15 px-4 py-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:i.removeConnectorHint}),(0,$.jsxs)(w,{variant:`secondary`,className:`shrink-0 border-danger/30 text-danger hover:bg-danger/10`,disabled:c,onClick:()=>p(!0),children:[c?(0,$.jsx)(G,{className:`size-4 animate-spin`}):(0,$.jsx)(Ie,{className:`size-4`}),i.remove]})]})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,$.jsx)(w,{variant:`secondary`,onClick:n,children:i.modalClose}),(V&&A===`config`||U)&&B?(0,$.jsxs)(w,{variant:`primary`,disabled:m,onClick:()=>void ae(),children:[m?(0,$.jsx)(G,{className:`size-4 animate-spin`}):(0,$.jsx)(Fe,{className:`size-4`}),i.modalSave]}):null,V?(0,$.jsxs)(w,{variant:`secondary`,disabled:o,onClick:()=>void re(),children:[o?(0,$.jsx)(G,{className:`size-4 animate-spin`}):(0,$.jsx)(X,{className:`size-4`}),i.test]}):null]})]})]}),e.materialized.type===`mcp`?(0,$.jsx)(tn,{open:M,onOpenChange:N,serverId:e.materialized.serverId,title:Y(i.installedToolsDialogTitle,{name:e.displayName}),subtitle:i.installedToolsDialogSubtitle,searchPlaceholder:a.toolsDialogSearchPlaceholder,searchEmptyLabel:a.toolsDialogSearchEmpty,emptyLabel:i.toolsRunTestHint,closeLabel:a.toolsDialogClose,tools:O?.tools??[],stripPrefix:`${e.materialized.serverId}__`}):null,(0,$.jsx)(ke,{open:u,title:Y(i.removeConfirmTitle,{name:e.displayName}),description:i.removeConfirmDescription,confirmLabel:i.removeConfirmAction,cancelLabel:i.modalCancel,destructive:!0,onConfirm:()=>{p(!1),ie()},onCancel:()=>{c||p(!1)}})]})}function yn(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=e.instance.materialized.type===`cli`&&e.definition?(0,$.jsx)(et,{definition:e.definition,instance:e.instance,onClose:e.onClose,onChanged:e.onChanged}):(0,$.jsx)(vn,{...e}),t[0]=e,t[1]=n),n}function bn(e){let t=(0,Q.c)(55),{instance:n,definition:r,highlighted:i,onOpenDetails:a,t:o}=e,s=i===void 0?!1:i,c;t[0]!==r||t[1]!==n?(c=Rt(n,r),t[0]=r,t[1]=n,t[2]=c):c=t[2];let u=c.state,d;t[3]!==r||t[4]!==o?(d=r?F(r,o):null,t[3]=r,t[4]=o,t[5]=d):d=t[5];let p=d,m,h,g,_,v,y,b,x,S;if(t[6]!==u||t[7]!==r||t[8]!==s||t[9]!==n||t[10]!==a||t[11]!==o.connectionChecking||t[12]!==o.connectionNeedsSetup||t[13]!==o.connectionReady){m=u===`ready`?{label:o.connectionReady,Icon:l,className:`text-emerald-700 dark:text-emerald-300`}:u===`needs_setup`?{label:o.connectionNeedsSetup,Icon:qe,className:`text-amber-700 dark:text-amber-300`}:{label:o.connectionChecking,Icon:le,className:`text-fg-muted`},x=`button`;let e=s&&`bg-accent-soft`;t[23]===e?S=t[24]:(S=f(`flex w-full items-center gap-3 px-4 py-3.5 text-left hover:bg-surface-hover/60`,`rounded-none first:rounded-t-[calc(var(--radius-xl)-1px)] last:rounded-b-[calc(var(--radius-xl)-1px)]`,Ze.transition,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,e),t[23]=e,t[24]=S),t[25]!==n||t[26]!==a?(h=()=>a(n),t[25]=n,t[26]=a,t[27]=h):h=t[27],t[28]===r?g=t[29]:(g=(0,$.jsx)(Ke,{connector:r}),t[28]=r,t[29]=g),b=`min-w-0 flex-1`,v=`flex min-w-0 items-center gap-2`,t[30]===n.displayName?y=t[31]:(y=(0,$.jsx)(`h3`,{className:`truncate text-sm font-medium text-fg`,children:n.displayName}),t[30]=n.displayName,t[31]=y),_=f(`inline-flex shrink-0 items-center gap-1 text-xs font-medium`,m.className),t[6]=u,t[7]=r,t[8]=s,t[9]=n,t[10]=a,t[11]=o.connectionChecking,t[12]=o.connectionNeedsSetup,t[13]=o.connectionReady,t[14]=m,t[15]=h,t[16]=g,t[17]=_,t[18]=v,t[19]=y,t[20]=b,t[21]=x,t[22]=S}else m=t[14],h=t[15],g=t[16],_=t[17],v=t[18],y=t[19],b=t[20],x=t[21],S=t[22];let C;t[32]===m.Icon?C=t[33]:(C=(0,$.jsx)(m.Icon,{className:`size-3.5`,"aria-hidden":!0}),t[32]=m.Icon,t[33]=C);let w;t[34]!==m.label||t[35]!==C||t[36]!==_?(w=(0,$.jsxs)(`span`,{className:_,children:[C,m.label]}),t[34]=m.label,t[35]=C,t[36]=_,t[37]=w):w=t[37];let T;t[38]!==w||t[39]!==v||t[40]!==y?(T=(0,$.jsxs)(`div`,{className:v,children:[y,w]}),t[38]=w,t[39]=v,t[40]=y,t[41]=T):T=t[41];let E;t[42]===p?E=t[43]:(E=p?(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:p}):null,t[42]=p,t[43]=E);let D;t[44]!==T||t[45]!==E||t[46]!==b?(D=(0,$.jsxs)(`div`,{className:b,children:[T,E]}),t[44]=T,t[45]=E,t[46]=b,t[47]=D):D=t[47];let O;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(Qe,{className:`size-4 shrink-0 text-fg-disabled`,"aria-hidden":!0}),t[48]=O):O=t[48];let k;return t[49]!==h||t[50]!==g||t[51]!==D||t[52]!==x||t[53]!==S?(k=(0,$.jsxs)(`button`,{type:x,className:S,onClick:h,children:[g,D,O]}),t[49]=h,t[50]=g,t[51]=D,t[52]=x,t[53]=S,t[54]=k):k=t[54],k}function xn(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 St(r)}function Sn(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 Cn(){return f(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,De)}function wn({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:i,pasteFailed:a,keyPlaceholder:o,valuePlaceholder:s,headers:c,onChange:l}){let u=(e,t)=>{l(c.map((n,r)=>r===e?{...n,...t}:n))},d=()=>{l([...c,{key:``,value:``}])},p=e=>{let t=c.filter((t,n)=>n!==e);l(t.length>0?t:[{key:``,value:``}])},m=async()=>{try{let e=await C();if(!e){window.alert(a);return}let t=gt(e);if(!t?.length){window.alert(a);return}l(t)}catch{window.alert(a)}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:e}),t?(0,$.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),(0,$.jsxs)(w,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void m(),children:[(0,$.jsx)(J,{className:`size-3.5`,"aria-hidden":!0}),i]})]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:c.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{className:f(Cn(),`min-w-0 flex-1 font-mono text-xs`),value:e.key,placeholder:o,onChange:e=>u(t,{key:e.target.value})}),(0,$.jsx)(`input`,{className:f(Cn(),`min-w-0 flex-[1.4] font-mono text-xs`),value:e.value,placeholder:s,onChange:e=>u(t,{value:e.target.value})}),(0,$.jsx)(w,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:c.length<=1&&!e.key&&!e.value,onClick:()=>p(t),"aria-label":r,children:(0,$.jsx)(Ie,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})})]},Sn(e,t,c)))}),(0,$.jsxs)(`button`,{type:`button`,className:f(`self-start text-sm text-accent hover:underline`,Ze.press),onClick:d,children:[`+ `,n]})]})}var Tn=[`stdio`,`sse`,`streamable-http`],En=[`none`,`oauth`];function Dn(e){let t=(0,Q.c)(11),{label:n,description:r,required:i,children:a}=e,o;t[0]===i?o=t[1]:(o=i?(0,$.jsx)(`span`,{className:`ml-0.5 text-danger`,children:`*`}):null,t[0]=i,t[1]=o);let s;t[2]!==n||t[3]!==o?(s=(0,$.jsxs)(`div`,{className:`text-sm font-medium text-fg`,children:[n,o]}),t[2]=n,t[3]=o,t[4]=s):s=t[4];let c;t[5]===r?c=t[6]:(c=r?(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}):null,t[5]=r,t[6]=c);let l;return t[7]!==a||t[8]!==s||t[9]!==c?(l=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[s,a,c]}),t[7]=a,t[8]=s,t[9]=c,t[10]=l):l=t[10],l}function On(){return f(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,De)}function kn(e){let t=(0,Q.c)(37),{row:n,t:r,onUpdate:i,idConflictMessage:a,variant:c}=e,l=c===void 0?`all`:c,u=l===`all`||l===`basic`,d=l===`all`||l===`advanced`,p;t[0]!==a||t[1]!==i||t[2]!==n.id||t[3]!==n.transport||t[4]!==u||t[5]!==r?(p=u?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Dn,{label:r.transportLabel,required:!0,children:(0,$.jsx)(o,{className:On(),value:n.transport,onChange:e=>i({transport:e.target.value}),children:Tn.map(e=>(0,$.jsx)(s,{value:e,children:r.transportLabels[e]},e))})}),(0,$.jsxs)(Dn,{label:r.serverIdLabel,required:!0,children:[(0,$.jsx)(`input`,{className:On(),value:n.id,placeholder:r.serverIdPlaceholder,onChange:e=>i({id:e.target.value})}),a?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-300`,children:a}):null]})]}):null,t[0]=a,t[1]=i,t[2]=n.id,t[3]=n.transport,t[4]=u,t[5]=r,t[6]=p):p=t[6];let m;t[7]!==i||t[8]!==n.argsText||t[9]!==n.auth||t[10]!==n.command||t[11]!==n.cwd||t[12]!==n.envJson||t[13]!==n.headers||t[14]!==n.oauthClientId||t[15]!==n.transport||t[16]!==n.url||t[17]!==d||t[18]!==u||t[19]!==r||t[20]!==l?(m=n.transport===`stdio`?(0,$.jsxs)($.Fragment,{children:[u?(0,$.jsx)(`div`,{className:l===`basic`?`md:col-span-2`:void 0,children:(0,$.jsx)(Dn,{label:r.commandLabel,required:!0,children:(0,$.jsx)(`input`,{className:On(),value:n.command,onChange:e=>i({command:e.target.value})})})}):null,d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Dn,{label:r.argsLabel,description:r.argsHint,children:(0,$.jsx)(`input`,{className:On(),value:n.argsText,onChange:e=>i({argsText:e.target.value})})}),(0,$.jsx)(Dn,{label:r.cwdLabel,children:(0,$.jsx)(`input`,{className:On(),value:n.cwd,onChange:e=>i({cwd:e.target.value})})}),(0,$.jsx)(Dn,{label:r.envLabel,description:r.envHint,children:(0,$.jsx)(`textarea`,{className:f(On(),`min-h-[4rem] font-mono text-xs`),value:n.envJson,onChange:e=>i({envJson:e.target.value})})})]}):null]}):(0,$.jsxs)($.Fragment,{children:[u?(0,$.jsx)(`div`,{className:`md:col-span-2`,children:(0,$.jsx)(Dn,{label:r.urlLabel,required:!0,children:(0,$.jsx)(`input`,{className:f(On(),`font-mono text-xs`),value:n.url,placeholder:`https://example.com/mcp`,onChange:e=>i({url:e.target.value})})})}):null,u&&n.transport===`streamable-http`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Dn,{label:r.authLabel,description:r.authHint,children:(0,$.jsx)(o,{className:On(),value:n.auth,onChange:e=>{let t=e.target.value;i({auth:t,headers:t===`oauth`?n.headers.filter(jn):n.headers})},children:En.map(e=>(0,$.jsx)(s,{value:e,children:r.authLabels[e]},e))})}),n.auth===`oauth`?(0,$.jsx)(Dn,{label:r.oauthClientIdLabel,description:r.oauthClientIdHint,children:(0,$.jsx)(`input`,{className:f(On(),`font-mono text-xs`),value:n.oauthClientId,placeholder:r.oauthClientIdPlaceholder,onChange:e=>i({oauthClientId:e.target.value})})}):null]}):null,d?(0,$.jsx)(wn,{label:r.headersLabel,optionalLabel:r.optionalSuffix,addLabel:r.addHeader,removeHeaderAria:r.removeHeader,pasteLabel:r.pasteHeaders,pasteFailed:r.pasteHeadersFailed,keyPlaceholder:r.headerKeyPlaceholder,valuePlaceholder:r.headerValuePlaceholder,headers:n.headers,onChange:e=>i({headers:n.auth===`oauth`?e.filter(An):e})}):null]}),t[7]=i,t[8]=n.argsText,t[9]=n.auth,t[10]=n.command,t[11]=n.cwd,t[12]=n.envJson,t[13]=n.headers,t[14]=n.oauthClientId,t[15]=n.transport,t[16]=n.url,t[17]=d,t[18]=u,t[19]=r,t[20]=l,t[21]=m):m=t[21];let h;t[22]!==i||t[23]!==n||t[24]!==d||t[25]!==r?(h=d?(0,$.jsx)(Dn,{label:r.timeoutLabel,description:r.timeoutHint,children:(0,$.jsx)(`input`,{type:`number`,min:1,max:600,className:On(),value:vt(n),placeholder:r.timeoutPlaceholder,onChange:e=>i({connectionTimeoutMs:Et(e.target.value)})})}):null,t[22]=i,t[23]=n,t[24]=d,t[25]=r,t[26]=h):h=t[26];let g;t[27]!==i||t[28]!==n||t[29]!==d||t[30]!==r?(g=d?(0,$.jsx)(Dn,{label:r.requestTimeoutLabel,description:r.requestTimeoutHint,children:(0,$.jsx)(`input`,{type:`number`,min:1,max:14400,className:On(),value:Ct(n),placeholder:r.requestTimeoutPlaceholder,onChange:e=>i({requestTimeoutMs:mt(e.target.value)})})}):null,t[27]=i,t[28]=n,t[29]=d,t[30]=r,t[31]=g):g=t[31];let _;return t[32]!==p||t[33]!==m||t[34]!==h||t[35]!==g?(_=(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[p,m,h,g]}),t[32]=p,t[33]=m,t[34]=h,t[35]=g,t[36]=_):_=t[36],_}function An(e){return e.key.trim().toLowerCase()!==`authorization`}function jn(e){return e.key.trim().toLowerCase()!==`authorization`}function Mn(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 Nn(e){let t=(0,Q.c)(13),{tool:n,serverId:r}=e,i;t[0]!==r||t[1]!==n?(i=Mn(n,r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o=n.name===a?a:n.name,s;t[3]===n.description?s=t[4]:(s=n.description?.trim(),t[3]=n.description,t[4]=s);let c=s,l;t[5]!==a||t[6]!==o?(l=(0,$.jsx)(`p`,{className:`break-all font-mono text-xs font-medium leading-5 text-fg`,title:o,children:a}),t[5]=a,t[6]=o,t[7]=l):l=t[7];let u;t[8]===c?u=t[9]:(u=c?(0,$.jsx)(N,{delayDuration:300,skipDelayDuration:100,children:(0,$.jsxs)(j,{children:[(0,$.jsx)(A,{asChild:!0,children:(0,$.jsx)(`p`,{tabIndex:0,title:c,className:f(`mt-1 line-clamp-3 cursor-help text-xs leading-5 text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:c})}),(0,$.jsx)(M,{children:(0,$.jsx)(P,{side:`top`,align:`start`,sideOffset:6,collisionPadding:12,className:`!z-[10000] max-h-[min(16rem,45vh)] max-w-[min(32rem,calc(100vw-2rem))] overflow-y-auto rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-5 text-fg shadow-popover`,children:(0,$.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:c})})})]})}):null,t[8]=c,t[9]=u);let d;return t[10]!==l||t[11]!==u?(d=(0,$.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[l,u]}),t[10]=l,t[11]=u,t[12]=d):d=t[12],d}function Pn({open:e,mode:t,initialRow:n,existingCustomServers:r,sessionIdleTtlMinutes:i,config:a,managedServerIds:o,t:s,cs:c,onClose:u,onSaved:p}){let[m,h]=(0,Z.useState)(n),[C,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)({status:`idle`}),[P,F]=(0,Z.useState)(null),I=n.id.trim(),L=m.id.trim()!==I&&o.has(m.id.trim())||o.has(m.id.trim())&&t===`add`?s.reservedServerId:void 0,R=m.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===m.id.trim())?c.duplicateServerId:void 0,z=m.id.trim().length>0&&!L&&!R&&(m.transport===`stdio`?m.command.trim().length>0:m.url.trim().length>0),B=!(m.transport===`streamable-http`&&m.auth===`oauth`),ee=Yt(m),V=(0,Z.useCallback)(async()=>{if(m.id.trim()){D(!0),k(null),N({status:`loading`});try{N({status:`ok`,tools:(await _t(m.id.trim(),wt(m))).tools})}catch(e){N({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{D(!1)}}},[m]),H=(0,Z.useCallback)(async()=>{if(!(!z||C)){T(!0),k(null);try{let e=r.filter(e=>!(t===`edit`&&e.clientKey===n.clientKey));e.push(m),await ht({sessionIdleTtlMinutes:i,servers:e.sort((e,t)=>e.id.localeCompare(t.id))},Tt(a)),await p(),u()}catch(e){k(e instanceof Error?e.message:String(e))}finally{T(!1)}}},[z,a,r,n.clientKey,t,u,p,I,m,C,i]);return e?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(S,{open:e,onOpenChange:e=>{e||u()},children:(0,$.jsxs)(y,{children:[(0,$.jsx)(g,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(b,{className:f(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-float dark:border-edge`),children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(x,{className:`text-base font-semibold text-fg`,children:t===`add`?c.addCustomServerTitle:c.editCustomServerTitle}),(0,$.jsx)(_,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?c.addCustomServerHint:c.editCustomServerHint})]}),(0,$.jsx)(v,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:f(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Ze.focusRingPanel),"aria-label":c.modalClose,children:[(0,$.jsx)(d,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`sr-only`,children:c.modalClose})]})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(je,{className:`size-4 text-accent`,"aria-hidden":!0}),m.id.trim()||s.cardUntitled]}),(0,$.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs leading-5 text-fg-muted`,children:ee||(m.transport===`stdio`?s.commandLabel:s.urlLabel)})]}),(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:s.transportLabels[m.transport]})]})}),(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-3`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.connectorBasicConfigTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:c.connectorBasicConfigHint})]}),(0,$.jsx)(kn,{row:m,t:s,variant:`basic`,onUpdate:e=>{h(t=>({...t,...e})),k(null)},idConflictMessage:L??R})]}),M.status===`ok`?(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(rt,{className:`size-4 text-accent`,"aria-hidden":!0}),M.tools.length===0?s.toolsEmpty:s.toolsTitle.replace(`{{count}}`,String(M.tools.length))]}),M.tools.length>0?(0,$.jsx)(w,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>F(M.tools),children:s.viewAllTools}):null]}),M.tools.length>0?(0,$.jsx)(`div`,{className:`mt-3 grid gap-2`,children:M.tools.slice(0,6).map((e,t)=>(0,$.jsx)(Nn,{tool:e,serverId:m.id},e.name||`tool-${t}`))}):null]}):null,M.status===`error`?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:M.message}):null,O?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:O}):null,(0,$.jsxs)(`details`,{open:A,onToggle:e=>j(e.currentTarget.open),className:`group rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg hover:text-fg [&::-webkit-details-marker]:hidden`,children:[(0,$.jsx)(He,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`group-open:hidden`,children:c.connectorShowAdvancedConfig}),(0,$.jsx)(`span`,{className:`hidden group-open:inline`,children:c.connectorHideAdvancedConfig})]}),(0,$.jsx)(`div`,{className:`border-t border-edge p-4`,children:(0,$.jsx)(kn,{row:m,t:s,variant:`advanced`,onUpdate:e=>{h(t=>({...t,...e})),k(null)}})})]})]})}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,$.jsxs)(w,{variant:`secondary`,disabled:!m.id.trim()||E||!B,title:B?void 0:s.oauthSaveBeforeTest,onClick:()=>void V(),children:[E?(0,$.jsx)(G,{className:`size-4 animate-spin`}):(0,$.jsx)(X,{className:`size-4`}),s.testConnection]}),(0,$.jsx)(v,{asChild:!0,children:(0,$.jsx)(w,{variant:`secondary`,children:c.modalCancel})}),(0,$.jsxs)(w,{variant:`primary`,disabled:!z||C,onClick:()=>void H(),children:[C?(0,$.jsx)(G,{className:`size-4 animate-spin`}):(0,$.jsx)(l,{className:`size-4`}),C?s.saving:c.modalSave]})]})]})]})}),P?(0,$.jsx)(tn,{open:!0,onOpenChange:e=>{e||F(null)},serverId:m.id,title:s.toolsDialogTitle,subtitle:s.toolsDialogSubtitle,searchPlaceholder:s.toolsDialogSearchPlaceholder,searchEmptyLabel:s.toolsDialogSearchEmpty,emptyLabel:s.toolsEmpty,closeLabel:s.toolsDialogClose,tools:P,stripPrefix:`${m.id.trim()}__`}):null]}):null}var Fn=`builtin`,In=`composio`,Ln=`xopc-store`;function Rn(e){return Fn}function zn(e){let t=e.connectorManifest;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t;if(n.contractVersion!==1||n.id!==e.name)return null;let r=n.runtime,i=n.auth;if(!r||typeof r!=`object`||Array.isArray(r)||!i||typeof i!=`object`||Array.isArray(i))return null;let a=r,o=i;if(a.type!==`mcp`||typeof a.serverId!=`string`)return null;let s=[`code`,`docs`,`browser`,`data`,`automation`,`custom`].includes(String(n.category??``))?n.category:`custom`,c=o.mode===`oauth`?{mode:`oauth`,...typeof o.clientId==`string`?{clientId:o.clientId}:{}}:o.mode===`apiKey`?{mode:`apiKey`}:{mode:`none`};return{id:e.name,version:e.latestVersion??`store`,displayName:typeof n.displayName==`string`?n.displayName:e.name,description:typeof n.description==`string`?n.description:e.description,category:s,kind:`mcp`,source:`store`,capabilities:Array.isArray(n.capabilities)?n.capabilities.filter(e=>typeof e==`string`):[],tags:Array.isArray(n.tags)?n.tags.filter(e=>typeof e==`string`):[`store`],auth:c,setup:n.setup&&typeof n.setup==`object`&&!Array.isArray(n.setup)?n.setup:{},runtime:{type:`mcp`,serverId:a.serverId}}}function Bn(e){return e.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t)}function Vn(e){return e?.startsWith(`/`)&&!e.startsWith(`//`)?e:`/user-model`}function Hn(){let e=ee().filter(e=>e.format===`agent-plugin`),t=h(m(e=>e.language)),n=t.connectorsSettings,r=t.mcpSettings,o=p(e=>e.conversationId),s=!!o,l=i(),[u,d]=a(),g=u.get(`understanding`)===`1`,_=Vn(u.get(`returnTo`)),v=!!u.get(`returnTo`)&&!g,y=u.get(`tab`),[b,x]=(0,Z.useState)(!g&&y===`connected`?`connected`:`discover`),S=(0,Z.useRef)(!1),[C,E]=(0,Z.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null}),[D,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(1),[N,P]=(0,Z.useState)(void 0),[F,R]=(0,Z.useState)(``),[z,B]=(0,Z.useState)(g||v?u.get(`connector`)??``:``),[V,H]=(0,Z.useState)(Rn(g?`understanding`:`default`)),[U,te]=(0,Z.useState)(`name`),[ne,re]=(0,Z.useState)(g?`understand`:`all`),[ie,ae]=(0,Z.useState)(null),[oe,ce]=(0,Z.useState)(null),[le,ue]=(0,Z.useState)(null),[de,fe]=(0,Z.useState)(null),[me,he]=(0,Z.useState)(null),[ge,_e]=(0,Z.useState)(null),[ve,ye]=(0,Z.useState)(!1),[be,W]=(0,Z.useState)(void 0),[xe,Se]=(0,Z.useState)(!1),{data:Ce,mutate:we}=T(s),q=Ce?.payload?.config,J=(0,Z.useMemo)(()=>q===void 0?null:yt(q),[q]),Ee=J?.servers??[],De=C.instances.length+Ee.length+e.reduce((e,t)=>e+(t.components?.mcp.length??0),0);(0,Z.useEffect)(()=>{J&&W(J.sessionIdleTtlMinutes)},[J]);let ke=(0,Z.useCallback)(async()=>{if(!o){E({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null});return}E(e=>({...e,loading:!0,error:null}));try{let[e,t]=await Promise.all([We(),Pe()]);E(n=>({catalog:e,registryCatalog:n.registryCatalog,instances:t,loading:!1,error:null}))}catch(e){E({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[o]);(0,Z.useEffect)(()=>{ke()},[ke]),(0,Z.useEffect)(()=>{S.current||C.loading||s&&!J||(x(g?`discover`:De>0?`connected`:`discover`),S.current=!0)},[s,De,J,g,C.loading]);let Ae=(0,Z.useCallback)(e=>{S.current=!0,x(e)},[]),je=(0,Z.useMemo)(()=>[{id:In,displayName:n.composioSourceName},{id:Ln,displayName:n.storeSourceName}],[n.composioSourceName,n.storeSourceName]),Y=(0,Z.useCallback)(async e=>{if(!s||V===`builtin`){E(e=>({...e,registryCatalog:[]})),M(1),P(void 0);return}let t=z.trim(),n=Math.max(e?.page??1,1),r=e?.append??!1,i=V===`all`?je:je.filter(e=>e.id===V);if(i.length!==0){O(!0),r?E(e=>({...e,error:null})):(M(1),P(void 0),E(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(i.map(async e=>{if(e.id===`composio`){let e=await Ye({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let r=await Ne({q:t||void 0,page:n,pageSize:24,sort:U===`source`?`newest`:`downloads`});return{connectors:r.items.flatMap(e=>{let t=zn(e);return t?[t]:[]}),totalPages:r.meta.totalPages}})),a=Bn(e.flatMap(e=>e.connectors)),o=Math.max(1,...e.map(e=>e.totalPages??1));M(n),P(o),E(e=>({...e,registryCatalog:r?Bn([...e.registryCatalog,...a]):a}))}catch(e){E(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{O(!1)}}},[U,z,V,s,je]);(0,Z.useEffect)(()=>{if(b!==`discover`||C.loading)return;if(V===`builtin`){E(e=>({...e,registryCatalog:[]})),M(1),P(void 0);return}let e=window.setTimeout(()=>{Y()},z.trim()?350:0);return()=>window.clearTimeout(e)},[z,V,Y,C.loading,b]);let Me=(0,Z.useMemo)(()=>new Set(C.instances.map(e=>e.connectorId)),[C.instances]),X=(0,Z.useMemo)(()=>new Map([...C.catalog,...C.registryCatalog].map(e=>[e.id,e])),[C.catalog,C.registryCatalog]);(0,Z.useEffect)(()=>{if(C.loading)return;let e=u.get(`connector`),t=u.get(`instance`);if(!e&&!t)return;let n=C.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)S.current=!0,R(``),ue(n.instanceId),fe(n),x(`connected`);else if(e){let t=X.get(e);if(!t)return;S.current=!0,H(Rn(g?`understanding`:`default`)),B(``),ce(t),x(`discover`)}let r=new URLSearchParams(u);r.delete(`connector`),r.delete(`instance`),r.set(`tab`,n?`connected`:`discover`),d(r,{replace:!0})},[X,g,u,d,C.instances,C.loading]);let Fe=(0,Z.useCallback)(async e=>{A(!0),E(e=>({...e,error:null}));try{let t=await Oe(e);ae(K(t.definition,{packageName:t.packageName,version:t.version,permissions:t.permissions}))}catch(e){E(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{A(!1)}},[]),Ie=(0,Z.useMemo)(()=>new Set(C.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[C.instances]),ze=(0,Z.useCallback)(async e=>{if(!J||q===void 0)return;let t=Ee.filter(t=>t.clientKey!==e.clientKey);await ht({sessionIdleTtlMinutes:J.sessionIdleTtlMinutes,servers:t},Tt(q)),await we(),await ke()},[q,Ee,ke,J,we]),Be=(0,Z.useCallback)(()=>{_e({mode:`add`,row:xn(Ee,Ie)})},[Ee,Ie]),Ve=(0,Z.useCallback)(async()=>{if(!(!J||q===void 0||xe)){Se(!0);try{await ht({sessionIdleTtlMinutes:be,servers:Ee},Tt(q)),await we(),ye(!1)}finally{Se(!1)}}},[q,Ee,r.saved,J,we,be,xe]),He=se(e=>e.setPageHeader),Ue=se(e=>e.clearPageHeader),Ge=(0,Z.useMemo)(()=>(0,$.jsx)(Jt,{onRefresh:b===`connected`&&s?ke:void 0,refreshing:C.loading,refreshLabel:n.refreshConnections,onBrowseCatalog:()=>Ae(`discover`),onAddCustomServer:Be,addLabel:n.addConnection,browseLabel:n.addFromCatalog,customLabel:n.addCustomServerAdvanced}),[n,s,ke,Be,Ae,C.loading,b]);(0,Z.useLayoutEffect)(()=>(He({startExtra:null,main:(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title})}),end:Ge}),()=>Ue()),[Ue,n.title,Ge,He]);let Ke=(0,Z.useMemo)(()=>C.instances.map(e=>({instance:e,value:Rt(e,X.get(e.connectorId))})),[X,C.instances]),qe=(0,Z.useMemo)(()=>new Map(Ke.map(({instance:e,value:t})=>[e.instanceId,t])),[Ke]),Je=(0,Z.useMemo)(()=>C.instances.filter(e=>Le(e,F)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=qe.get(e.instanceId)?.state??`checking`,i=qe.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[F,qe,C.instances]),Ze=(0,Z.useMemo)(()=>Je.filter(e=>qe.get(e.instanceId)?.state===`needs_setup`),[qe,Je]),Qe=(0,Z.useMemo)(()=>Je.filter(e=>qe.get(e.instanceId)?.state!==`needs_setup`),[qe,Je]),$e=(0,Z.useMemo)(()=>Ee.filter(e=>Re(e,F)),[F,Ee]),et=(0,Z.useMemo)(()=>{let t=F.trim().toLowerCase();return e.flatMap(e=>(e.components?.mcp??[]).filter(n=>`${e.name} ${n.name}`.toLowerCase().includes(t)).map(t=>({extension:e,server:t})))},[F,e]),tt=Je.length+$e.length+et.length,nt=(0,Z.useMemo)(()=>C.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&pe(e)),[C.catalog]),rt=(0,Z.useMemo)(()=>V===`builtin`?nt:V===`all`?Bn([...nt,...C.registryCatalog]):C.registryCatalog,[nt,V,C.registryCatalog]),it=(0,Z.useMemo)(()=>{let e=g?rt.filter(e=>e.understanding?.mode===`activity`):rt;return L(ne===`all`?e:e.filter(e=>It(e).includes(ne)),z,U)},[U,z,rt,g,ne]),at=(0,Z.useMemo)(()=>Ft.filter(e=>rt.some(t=>It(t).includes(e))),[rt]);(0,Z.useEffect)(()=>{ne!==`all`&&!at.includes(ne)&&re(`all`)},[at,ne]);let ot=b===`discover`&&V!==`builtin`&&!!(N&&j<N),st=(0,Z.useMemo)(()=>C.instances.find(e=>e.instanceId===le)??de,[le,de,C.instances]),ct=(0,Z.useMemo)(()=>[{value:`all`,label:n.discoverSourceAll},{value:Fn,label:n.discoverSourceBuiltin},...je.map(e=>({value:e.id,label:e.displayName}))],[n.discoverSourceAll,n.discoverSourceBuiltin,je]),lt=[{id:`connected`,label:n.tabConnected,count:De},{id:`discover`,label:n.tabDiscover}];return(0,$.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-6 px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:[s?null:(0,$.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:n.tokenHint}),g?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:n.understandingSetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n.understandingSetupHint})]}),(0,$.jsx)(w,{type:`button`,variant:`secondary`,className:`shrink-0`,onClick:()=>l(_),children:n.understandingSetupDone})]}):null,v?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:n.recoverySetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n.recoverySetupHint})]}),(0,$.jsx)(w,{type:`button`,variant:`secondary`,className:`min-h-11 shrink-0`,onClick:()=>l(_),children:n.recoverySetupDone})]}):null,(0,$.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(`div`,{className:`border-b border-edge-subtle pb-3 dark:border-edge-subtle`,children:(0,$.jsx)(dt,{items:lt,activeTab:b,onChange:Ae,ariaLabel:n.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),C.error?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:C.error}):null,b===`connected`&&s?(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[De>5||F?(0,$.jsx)(qt,{value:F,onChange:R,placeholder:n.connectedSearchPlaceholder,className:`max-w-xl`}):null,C.loading?(0,$.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":n.loading,children:kt.slice(0,3).map(e=>(0,$.jsx)(Pt,{},e))}):De===0?(0,$.jsxs)(`div`,{className:`py-14 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.connectionsEmpty}),(0,$.jsx)(w,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>Ae(`discover`),children:n.addFromCatalog})]}):tt===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:n.connectionsSearchEmpty}):(0,$.jsxs)(`div`,{className:`space-y-6`,children:[Ze.length?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.needsAttentionTitle}),(0,$.jsx)(`span`,{className:`text-xs tabular-nums text-amber-700 dark:text-amber-300`,children:Ze.length})]}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-amber-500/25 bg-amber-500/5`,children:Ze.map(e=>(0,$.jsx)(bn,{instance:e,definition:X.get(e.connectorId),highlighted:e.instanceId===me,onOpenDetails:e=>{he(null),ue(e.instanceId),fe(e)},t:n},e.instanceId))})]}):null,Qe.length?(0,$.jsx)(`section`,{children:(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:Qe.map(e=>(0,$.jsx)(bn,{instance:e,definition:X.get(e.connectorId),highlighted:e.instanceId===me,onOpenDetails:e=>{he(null),ue(e.instanceId),fe(e)},t:n},e.instanceId))})}):null,et.map(({extension:e,server:t})=>(0,$.jsx)(xt,{pluginId:e.pluginId,server:t,enabled:e.active},t.id)),$e.length||!F.trim()?(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer px-4 py-3`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.customIntegrationsTitle}),(0,$.jsx)(`span`,{className:`ml-2 text-xs tabular-nums text-fg-subtle`,children:$e.length}),(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:n.customIntegrationsHint})]}),(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2 px-4 py-3`,children:[(0,$.jsx)(w,{type:`button`,variant:`secondary`,className:`h-8 text-xs`,onClick:Be,children:n.addCustomServerAdvanced}),(0,$.jsxs)(w,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>ye(!0),children:[(0,$.jsx)(I,{className:`size-3.5`}),n.runtimeSettings]})]}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:$e.map(e=>(0,$.jsx)(Xt,{row:e,t:r,cs:n,onEdit:()=>_e({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>ze(e)},e.clientKey))})]})]}):null]})]}):null,b===`discover`&&s?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[g?null:(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":n.taskFilterAria,children:[`all`,...at].map(e=>(0,$.jsx)(`button`,{type:`button`,className:f(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,ne===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":ne===e,onClick:()=>re(e),children:e===`all`?n.taskAll:n.connectorBenefitHeadings[e]},e))}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 lg:flex-row lg:items-center`,children:[(0,$.jsx)(qt,{value:z,onChange:B,placeholder:n.discoverSearchPlaceholder,className:`max-w-xl`}),(0,$.jsxs)(`details`,{className:`relative shrink-0 lg:ml-auto`,children:[(0,$.jsxs)(`summary`,{className:`flex h-9 cursor-pointer list-none items-center gap-2 rounded-lg border border-edge bg-surface-panel px-3 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,children:[(0,$.jsx)(Xe,{className:`size-3.5`,"aria-hidden":!0}),n.filters]}),(0,$.jsxs)(`div`,{className:f(`mt-2 grid min-w-[15rem] grid-cols-1 gap-2 rounded-xl border border-edge bg-surface-panel p-3 shadow-popover sm:absolute sm:right-0 sm:z-10`,!g&&`sm:min-w-[24rem] sm:grid-cols-2`),children:[g?null:(0,$.jsx)(c,{value:V,options:ct,placeholder:n.discoverSourceAll,allowEmpty:!1,ariaLabel:n.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:H}),(0,$.jsx)(c,{value:U,options:[{value:`name`,label:n.sortName},{value:`source`,label:n.sortSource}],placeholder:n.sortName,allowEmpty:!1,ariaLabel:n.sortAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:e=>te(e)})]})]})]}),(C.loading||D)&&it.length===0?(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":n.loading,children:kt.map(e=>(0,$.jsx)(Mt,{},e))}):it.length===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:n.discoverEmpty}):(0,$.jsxs)(`div`,{className:`relative`,children:[D?(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1] flex justify-center bg-surface-panel/40 pt-[min(28vh,7.5rem)] backdrop-blur-[1px] motion-reduce:backdrop-blur-none dark:bg-surface-base/35`,"aria-busy":`true`,"aria-label":n.loading,children:(0,$.jsx)(G,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:it.map(e=>(0,$.jsx)(Dt,{connector:e,installed:Me.has(e.id)||At(e,C.instances),onInstall:e=>{if(e.source===`store`){Fe(e.id);return}ae(K(e))},onOpenDetails:e.source===`store`?void 0:ce,t:n},e.id))}),ot?(0,$.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,$.jsxs)(w,{type:`button`,variant:`secondary`,disabled:D||k,onClick:()=>void Y({page:j+1,append:!0}),children:[D?(0,$.jsx)(G,{className:`size-4 animate-spin`}):null,n.loadMore]})}):null]})]}):null]}),ie?(0,$.jsx)(Te,{draft:ie,onChange:ae,onClose:()=>ae(null),t:n,onInstalled:async e=>{await ke(),await we(),he(e.instanceId),Ae(`connected`)}}):null,oe?(0,$.jsx)(Wt,{connector:oe,installed:Me.has(oe.id)||At(oe,C.instances),onClose:()=>ce(null),onInstall:e=>ae(K(e)),t:n}):null,st?(0,$.jsx)(yn,{instance:st,definition:X.get(st.connectorId),onClose:()=>{ue(null),fe(null)},onChanged:ke,t:n,mcp:r}):null,ge?(0,$.jsx)(Pn,{open:!0,mode:ge.mode,initialRow:ge.row,existingCustomServers:Ee,sessionIdleTtlMinutes:be,config:q,managedServerIds:Ie,t:r,cs:n,onClose:()=>_e(null),onSaved:async()=>{await we(),await ke(),Ae(`connected`)}},`${ge.mode}-${ge.row.clientKey}`):null,(0,$.jsx)(Kt,{open:ve,sessionIdleTtlMinutes:be,saving:xe,onChange:W,onSave:Ve,onClose:()=>ye(!1),t:n,mcp:r})]})})}export{Hn as ConnectorsPage};
@@ -0,0 +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{s as i}from"./popover-select-DcsFzD_i.js";import{t as a}from"./cn-JdwAhgNB.js";import{n as o}from"./locale-store-BPZR8x9b.js";import{o as ee,s as te,t as ne}from"./dist-3h6cXXhT.js";import{n as re,r as ie}from"./settings-shell-layer-context-BTQUDoJ2.js";import{cd as ae,sd as oe,ud as se}from"./index-19rMUT3d.js";var s=e(t(),1),ce=n();function c(e){return String(e).padStart(2,`0`)}function le(e){return`${e.getFullYear()}-${c(e.getMonth()+1)}-${c(e.getDate())}`}function ue(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2])-1,i=Number(t[3]),a=new Date(n,r,i,12);return a.getFullYear()===n&&a.getMonth()===r&&a.getDate()===i?a:null}function de(e,t){let n=ue(e);return n?t===`zh`?`${n.getFullYear()}/${c(n.getMonth()+1)}/${c(n.getDate())}`:new Intl.DateTimeFormat(`en`,{year:`numeric`,month:`short`,day:`numeric`}).format(n):``}var l=r();function fe(e,t){let n=new Date(e.getFullYear(),e.getMonth(),1,12),r=(n.getDay()-t+7)%7;return Array.from({length:42},(e,t)=>new Date(n.getFullYear(),n.getMonth(),1-r+t,12))}function u(e){let t=(0,ce.c)(105),{value:n,onChange:r,disabled:c,className:u,ariaLabel:_e,placeholder:ve,min:d,max:f}=e,p=o(ge),m=p===`zh`?`zh-CN`:`en`,ye;t[0]===n?ye=t[1]:(ye=ue(n),t[0]=n,t[1]=ye);let h=ye,[g,be]=(0,s.useState)(!1),[xe,Se]=(0,s.useState)(null),_;t[2]===h?_=t[3]:(_=()=>h??new Date,t[2]=h,t[3]=_);let[v,Ce]=(0,s.useState)(_),we=re(xe),Te=i(ie(),we!==null),y=+(p===`zh`),b,x;t[4]!==g||t[5]!==n?(b=()=>{if(!g)return;let e=ue(n);e&&Ce(e)},x=[g,n],t[4]=g,t[5]=n,t[6]=b,t[7]=x):(b=t[6],x=t[7]),(0,s.useEffect)(b,x);let S;t[8]!==v||t[9]!==y?(S=fe(v,y),t[8]=v,t[9]=y,t[10]=S):S=t[10];let Ee=S,C;if(t[11]!==m||t[12]!==y){let e=new Date(2026,7,23,12);C=Array.from({length:7},(t,n)=>{let r=new Date(e);return r.setDate(e.getDate()+y+n),new Intl.DateTimeFormat(m,{weekday:`narrow`}).format(r)}),t[11]=m,t[12]=y,t[13]=C}else C=t[13];let De=C,w;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(w=le(new Date),t[14]=w):w=t[14];let T=w,E;t[15]===h?E=t[16]:(E=h?le(h):``,t[15]=h,t[16]=E);let D=E,O;t[17]!==m||t[18]!==v?(O=new Intl.DateTimeFormat(m,{year:`numeric`,month:`long`}).format(v),t[17]=m,t[18]=v,t[19]=O):O=t[19];let Oe=O,k;t[20]===r?k=t[21]:(k=e=>{r(e),be(!1)},t[20]=r,t[21]=k);let A=k,ke=te,Ae=c&&`cursor-not-allowed opacity-50`,j;t[22]!==u||t[23]!==Ae?(j=a(`flex h-10 w-full min-w-0 items-center justify-between gap-3 rounded-lg bg-surface-hover px-3 text-left text-sm text-fg outline-none transition-colors`,`hover:bg-surface-active focus-visible:ring-2 focus-visible:ring-accent/40`,Ae,u),t[22]=u,t[23]=Ae,t[24]=j):j=t[24];let je=!n&&`text-fg-subtle`,M;t[25]===je?M=t[26]:(M=a(`min-w-0 truncate tabular-nums`,je),t[25]=je,t[26]=M);let N;t[27]!==p||t[28]!==ve||t[29]!==n?(N=de(n,p)||ve||(p===`zh`?`选择日期`:`Select date`),t[27]=p,t[28]=ve,t[29]=n,t[30]=N):N=t[30];let P;t[31]!==M||t[32]!==N?(P=(0,l.jsx)(`span`,{className:M,children:N}),t[31]=M,t[32]=N,t[33]=P):P=t[33];let F;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,l.jsx)(se,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[34]=F):F=t[34];let I;t[35]!==_e||t[36]!==c||t[37]!==j||t[38]!==P?(I=(0,l.jsx)(ee,{asChild:!0,children:(0,l.jsxs)(`button`,{ref:Se,type:`button`,disabled:c,"aria-label":_e,className:j,children:[P,F]})}),t[35]=_e,t[36]=c,t[37]=j,t[38]=P,t[39]=I):I=t[39];let Me=te,Ne=we??void 0,Pe=te,Fe=a(Te,`w-[19rem] rounded-2xl border border-edge bg-surface-overlay p-3 shadow-float outline-none`),Ie=p===`zh`?`上个月`:`Previous month`,L,R;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>Ce(he),R=(0,l.jsx)(ae,{className:`size-4`,"aria-hidden":!0}),t[40]=L,t[41]=R):(L=t[40],R=t[41]);let z;t[42]===Ie?z=t[43]:(z=(0,l.jsx)(`button`,{type:`button`,className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":Ie,onClick:L,children:R}),t[42]=Ie,t[43]=z);let B;t[44]===Oe?B=t[45]:(B=(0,l.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:Oe}),t[44]=Oe,t[45]=B);let Le=p===`zh`?`下个月`:`Next month`,V,Re;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(V=()=>Ce(me),Re=(0,l.jsx)(oe,{className:`size-4`,"aria-hidden":!0}),t[46]=V,t[47]=Re):(V=t[46],Re=t[47]);let H;t[48]===Le?H=t[49]:(H=(0,l.jsx)(`button`,{type:`button`,className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":Le,onClick:V,children:Re}),t[48]=Le,t[49]=H);let U;t[50]!==z||t[51]!==B||t[52]!==H?(U=(0,l.jsxs)(`div`,{className:`flex h-10 items-center justify-between gap-2 px-1`,children:[z,B,H]}),t[50]=z,t[51]=B,t[52]=H,t[53]=U):U=t[53];let W;t[54]===De?W=t[55]:(W=(0,l.jsx)(`div`,{className:`mt-2 grid grid-cols-7`,"aria-hidden":!0,children:De.map(pe)}),t[54]=De,t[55]=W);let G;if(t[56]!==Ee||t[57]!==m||t[58]!==f||t[59]!==d||t[60]!==A||t[61]!==D||t[62]!==v){let e;t[64]!==m||t[65]!==f||t[66]!==d||t[67]!==A||t[68]!==D||t[69]!==v?(e=e=>{let t=le(e),n=t===D,r=t===T,i=e.getMonth()!==v.getMonth(),o=!!(d&&t<d||f&&t>f);return(0,l.jsx)(`button`,{type:`button`,role:`gridcell`,"aria-selected":n,"aria-disabled":o,disabled:o,"aria-label":new Intl.DateTimeFormat(m,{dateStyle:`full`}).format(e),className:a(`mx-auto flex size-9 items-center justify-center rounded-xl text-sm tabular-nums text-fg transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,i&&`text-fg-disabled`,o&&`cursor-not-allowed opacity-35 hover:bg-transparent`,r&&!n&&`bg-accent-soft font-semibold text-accent-fg`,n&&`bg-accent font-semibold text-on-accent hover:bg-accent-hover`),onClick:()=>A(t),children:e.getDate()},t)},t[64]=m,t[65]=f,t[66]=d,t[67]=A,t[68]=D,t[69]=v,t[70]=e):e=t[70],G=Ee.map(e),t[56]=Ee,t[57]=m,t[58]=f,t[59]=d,t[60]=A,t[61]=D,t[62]=v,t[63]=G}else G=t[63];let K;t[71]===G?K=t[72]:(K=(0,l.jsx)(`div`,{className:`grid grid-cols-7 gap-y-1`,role:`grid`,children:G}),t[71]=G,t[72]=K);let ze=!n,q;t[73]===A?q=t[74]:(q=()=>A(``),t[73]=A,t[74]=q);let Be=p===`zh`?`清除`:`Clear`,J;t[75]!==ze||t[76]!==q||t[77]!==Be?(J=(0,l.jsx)(`button`,{type:`button`,disabled:ze,className:`rounded-lg px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg disabled:pointer-events-none disabled:opacity-35`,onClick:q,children:Be}),t[75]=ze,t[76]=q,t[77]=Be,t[78]=J):J=t[78];let Ve=!!(d&&T<d||f&&T>f),Y;t[79]===A?Y=t[80]:(Y=()=>A(T),t[79]=A,t[80]=Y);let He=p===`zh`?`今天`:`Today`,X;t[81]!==Ve||t[82]!==Y||t[83]!==He?(X=(0,l.jsx)(`button`,{type:`button`,disabled:Ve,className:`rounded-lg bg-accent-soft px-2.5 py-1.5 text-xs font-medium text-accent-fg hover:bg-accent-soft/80 disabled:pointer-events-none disabled:opacity-35`,onClick:Y,children:He}),t[81]=Ve,t[82]=Y,t[83]=He,t[84]=X):X=t[84];let Z;t[85]!==J||t[86]!==X?(Z=(0,l.jsxs)(`div`,{className:`mt-2 flex items-center justify-between px-1 pt-1`,children:[J,X]}),t[85]=J,t[86]=X,t[87]=Z):Z=t[87];let Ue;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=(0,l.jsx)(ne,{className:`fill-surface-overlay`}),t[88]=Ue):Ue=t[88];let Q;t[89]!==Pe.Content||t[90]!==Fe||t[91]!==U||t[92]!==W||t[93]!==K||t[94]!==Z?(Q=(0,l.jsxs)(Pe.Content,{align:`start`,sideOffset:6,collisionPadding:12,className:Fe,children:[U,W,K,Z,Ue]}),t[89]=Pe.Content,t[90]=Fe,t[91]=U,t[92]=W,t[93]=K,t[94]=Z,t[95]=Q):Q=t[95];let $;t[96]!==Me.Portal||t[97]!==Ne||t[98]!==Q?($=(0,l.jsx)(Me.Portal,{container:Ne,children:Q}),t[96]=Me.Portal,t[97]=Ne,t[98]=Q,t[99]=$):$=t[99];let We;return t[100]!==g||t[101]!==ke.Root||t[102]!==I||t[103]!==$?(We=(0,l.jsxs)(ke.Root,{open:g,onOpenChange:be,children:[I,$]}),t[100]=g,t[101]=ke.Root,t[102]=I,t[103]=$,t[104]=We):We=t[104],We}function pe(e,t){return(0,l.jsx)(`div`,{className:`flex h-8 items-center justify-center text-[11px] font-medium text-fg-subtle`,children:e},`${e}-${t}`)}function me(e){return new Date(e.getFullYear(),e.getMonth()+1,1,12)}function he(e){return new Date(e.getFullYear(),e.getMonth()-1,1,12)}function ge(e){return e.language}export{u as t};
@@ -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"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./x-B_N4OPjy.js";import{t as s}from"./cn-JdwAhgNB.js";import{t as c}from"./button-CS04eWY9.js";import{a as l,i as u,n as d,r as f,t as p}from"./dist-Che_jiQF.js";import{Kl as m,Zc as h,id as g}from"./index--3c0awkr.js";var _=n(),v=e(t(),1),y=r(),b=`!z-[10000] max-w-[min(28rem,90vw)] rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-relaxed text-fg shadow-lg`;function x(e){let t=(0,_.c)(31),{candidates:n,selectedIds:r,labels:x,disabled:C,borderless:w,getTaskHref:T,onChange:E}=e,D=w===void 0?!1:w,[O,k]=(0,v.useState)(!1),[A,j]=(0,v.useState)(``),M;t[0]===A?M=t[1]:(M=A.trim().toLocaleLowerCase(),t[0]=A,t[1]=M);let N=M,P;if(t[2]!==n||t[3]!==N){let e;t[5]===N?e=t[6]:(e=e=>!N||e.title.toLocaleLowerCase().includes(N),t[5]=N,t[6]=e),P=n.filter(e).slice(0,20),t[2]=n,t[3]=N,t[4]=P}else P=t[4];let F=P,I;t[7]!==n||t[8]!==C||t[9]!==T||t[10]!==x.remove||t[11]!==E||t[12]!==r?(I=r.length>0?(0,y.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-2`,children:r.map(e=>{let t=n.find(t=>t.id===e);return t?(0,y.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-lg bg-surface-hover px-2.5 py-1.5 text-xs text-fg-muted`,children:[(0,y.jsxs)(u,{children:[(0,y.jsx)(l,{asChild:!0,children:T?(0,y.jsx)(i,{to:T(t.id),className:`min-w-0 truncate rounded-sm outline-none transition-colors hover:text-fg hover:underline focus-visible:ring-2 focus-visible:ring-accent/50`,children:t.title}):(0,y.jsx)(`span`,{className:`min-w-0 truncate`,children:t.title})}),(0,y.jsx)(d,{children:(0,y.jsx)(p,{side:`top`,sideOffset:6,collisionPadding:12,className:b,children:(0,y.jsx)(`span`,{className:`break-words`,children:t.title})})})]}),(0,y.jsx)(`button`,{type:`button`,className:`shrink-0 rounded text-fg-subtle transition-colors hover:text-fg`,"aria-label":x.remove.replace(`{{task}}`,t.title),disabled:C,onClick:()=>E(r.filter(e=>e!==t.id)),children:(0,y.jsx)(o,{className:`size-3.5`,"aria-hidden":!0})})]},t.id):null})}):null,t[7]=n,t[8]=C,t[9]=T,t[10]=x.remove,t[11]=E,t[12]=r,t[13]=I):I=t[13];let L;t[14]!==D||t[15]!==n.length||t[16]!==C||t[17]!==x.link||t[18]!==x.linked||t[19]!==x.noCandidates||t[20]!==x.noMatches||t[21]!==x.searchPlaceholder||t[22]!==F||t[23]!==E||t[24]!==O||t[25]!==A||t[26]!==r?(L=n.length>0?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(c,{type:`button`,variant:`secondary`,className:s(`w-fit rounded-lg`,D&&`border-0 bg-surface-hover shadow-none`),disabled:C,"aria-expanded":O,onClick:()=>k(S),children:[(0,y.jsx)(m,{className:`size-4`,"aria-hidden":!0}),r.length>0?x.linked.replace(`{{count}}`,String(r.length)):x.link,(0,y.jsx)(g,{className:s(`size-3.5 transition-transform`,O&&`rotate-180`),"aria-hidden":!0})]}),O?(0,y.jsxs)(`div`,{className:s(`grid gap-2 rounded-lg p-2`,D?`bg-surface-hover`:`border border-edge bg-surface-base`),children:[(0,y.jsxs)(`label`,{className:`relative block`,children:[(0,y.jsx)(h,{className:`pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,y.jsx)(`input`,{value:A,onChange:e=>j(e.target.value),placeholder:x.searchPlaceholder,className:s(`h-9 w-full rounded-md bg-surface-panel pl-8 pr-3 text-sm text-fg outline-none placeholder:text-fg-subtle`,D?`focus:ring-2 focus:ring-accent/30`:`border border-edge focus:border-accent`),autoFocus:!0})]}),F.length>0?(0,y.jsx)(`div`,{className:`grid max-h-52 gap-1 overflow-y-auto`,children:F.map(e=>{let t=r.includes(e.id);return(0,y.jsxs)(`button`,{type:`button`,"aria-pressed":t,disabled:C,onClick:()=>E(t?r.filter(t=>t!==e.id):[...r,e.id]),className:s(`flex items-center gap-2 rounded-md px-2.5 py-2 text-left text-sm transition-colors`,t?`bg-accent-soft text-accent-fg`:`text-fg hover:bg-surface-hover`),children:[(0,y.jsx)(`span`,{className:s(`flex size-4 shrink-0 items-center justify-center rounded`,D?t?`bg-accent text-on-accent`:`bg-surface-active`:t?`border border-accent bg-accent text-on-accent`:`border border-edge`),children:t?(0,y.jsx)(a,{className:`size-3`,"aria-hidden":!0}):null}),(0,y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title})]},e.id)})}):(0,y.jsx)(`p`,{className:`px-2 py-3 text-center text-sm text-fg-subtle`,children:x.noMatches})]}):null]}):(0,y.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:x.noCandidates}),t[14]=D,t[15]=n.length,t[16]=C,t[17]=x.link,t[18]=x.linked,t[19]=x.noCandidates,t[20]=x.noMatches,t[21]=x.searchPlaceholder,t[22]=F,t[23]=E,t[24]=O,t[25]=A,t[26]=r,t[27]=L):L=t[27];let R;return t[28]!==I||t[29]!==L?(R=(0,y.jsx)(f,{delayDuration:300,children:(0,y.jsxs)(`div`,{className:`min-w-0 grid gap-2`,children:[I,L]})}),t[28]=I,t[29]=L,t[30]=R):R=t[30],R}function S(e){return!e}export{x as t};
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"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./x-B_N4OPjy.js";import{t as s}from"./cn-JdwAhgNB.js";import{t as c}from"./button-CS04eWY9.js";import{a as l,i as u,n as d,r as f,t as p}from"./dist-Che_jiQF.js";import{Zl as m,ld as h,nl as g}from"./index-19rMUT3d.js";var _=n(),v=e(t(),1),y=r(),b=`!z-[10000] max-w-[min(28rem,90vw)] rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-relaxed text-fg shadow-lg`;function x(e){let t=(0,_.c)(31),{candidates:n,selectedIds:r,labels:x,disabled:C,borderless:w,getTaskHref:T,onChange:E}=e,D=w===void 0?!1:w,[O,k]=(0,v.useState)(!1),[A,j]=(0,v.useState)(``),M;t[0]===A?M=t[1]:(M=A.trim().toLocaleLowerCase(),t[0]=A,t[1]=M);let N=M,P;if(t[2]!==n||t[3]!==N){let e;t[5]===N?e=t[6]:(e=e=>!N||e.title.toLocaleLowerCase().includes(N),t[5]=N,t[6]=e),P=n.filter(e).slice(0,20),t[2]=n,t[3]=N,t[4]=P}else P=t[4];let F=P,I;t[7]!==n||t[8]!==C||t[9]!==T||t[10]!==x.remove||t[11]!==E||t[12]!==r?(I=r.length>0?(0,y.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-2`,children:r.map(e=>{let t=n.find(t=>t.id===e);return t?(0,y.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-lg bg-surface-hover px-2.5 py-1.5 text-xs text-fg-muted`,children:[(0,y.jsxs)(u,{children:[(0,y.jsx)(l,{asChild:!0,children:T?(0,y.jsx)(i,{to:T(t.id),className:`min-w-0 truncate rounded-sm outline-none transition-colors hover:text-fg hover:underline focus-visible:ring-2 focus-visible:ring-accent/50`,children:t.title}):(0,y.jsx)(`span`,{className:`min-w-0 truncate`,children:t.title})}),(0,y.jsx)(d,{children:(0,y.jsx)(p,{side:`top`,sideOffset:6,collisionPadding:12,className:b,children:(0,y.jsx)(`span`,{className:`break-words`,children:t.title})})})]}),(0,y.jsx)(`button`,{type:`button`,className:`shrink-0 rounded text-fg-subtle transition-colors hover:text-fg`,"aria-label":x.remove.replace(`{{task}}`,t.title),disabled:C,onClick:()=>E(r.filter(e=>e!==t.id)),children:(0,y.jsx)(o,{className:`size-3.5`,"aria-hidden":!0})})]},t.id):null})}):null,t[7]=n,t[8]=C,t[9]=T,t[10]=x.remove,t[11]=E,t[12]=r,t[13]=I):I=t[13];let L;t[14]!==D||t[15]!==n.length||t[16]!==C||t[17]!==x.link||t[18]!==x.linked||t[19]!==x.noCandidates||t[20]!==x.noMatches||t[21]!==x.searchPlaceholder||t[22]!==F||t[23]!==E||t[24]!==O||t[25]!==A||t[26]!==r?(L=n.length>0?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(c,{type:`button`,variant:`secondary`,className:s(`w-fit rounded-lg`,D&&`border-0 bg-surface-hover shadow-none`),disabled:C,"aria-expanded":O,onClick:()=>k(S),children:[(0,y.jsx)(m,{className:`size-4`,"aria-hidden":!0}),r.length>0?x.linked.replace(`{{count}}`,String(r.length)):x.link,(0,y.jsx)(h,{className:s(`size-3.5 transition-transform`,O&&`rotate-180`),"aria-hidden":!0})]}),O?(0,y.jsxs)(`div`,{className:s(`grid gap-2 rounded-lg p-2`,D?`bg-surface-hover`:`border border-edge bg-surface-base`),children:[(0,y.jsxs)(`label`,{className:`relative block`,children:[(0,y.jsx)(g,{className:`pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,y.jsx)(`input`,{value:A,onChange:e=>j(e.target.value),placeholder:x.searchPlaceholder,className:s(`h-9 w-full rounded-md bg-surface-panel pl-8 pr-3 text-sm text-fg outline-none placeholder:text-fg-subtle`,D?`focus:ring-2 focus:ring-accent/30`:`border border-edge focus:border-accent`),autoFocus:!0})]}),F.length>0?(0,y.jsx)(`div`,{className:`grid max-h-52 gap-1 overflow-y-auto`,children:F.map(e=>{let t=r.includes(e.id);return(0,y.jsxs)(`button`,{type:`button`,"aria-pressed":t,disabled:C,onClick:()=>E(t?r.filter(t=>t!==e.id):[...r,e.id]),className:s(`flex items-center gap-2 rounded-md px-2.5 py-2 text-left text-sm transition-colors`,t?`bg-accent-soft text-accent-fg`:`text-fg hover:bg-surface-hover`),children:[(0,y.jsx)(`span`,{className:s(`flex size-4 shrink-0 items-center justify-center rounded`,D?t?`bg-accent text-on-accent`:`bg-surface-active`:t?`border border-accent bg-accent text-on-accent`:`border border-edge`),children:t?(0,y.jsx)(a,{className:`size-3`,"aria-hidden":!0}):null}),(0,y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title})]},e.id)})}):(0,y.jsx)(`p`,{className:`px-2 py-3 text-center text-sm text-fg-subtle`,children:x.noMatches})]}):null]}):(0,y.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:x.noCandidates}),t[14]=D,t[15]=n.length,t[16]=C,t[17]=x.link,t[18]=x.linked,t[19]=x.noCandidates,t[20]=x.noMatches,t[21]=x.searchPlaceholder,t[22]=F,t[23]=E,t[24]=O,t[25]=A,t[26]=r,t[27]=L):L=t[27];let R;return t[28]!==I||t[29]!==L?(R=(0,y.jsx)(f,{delayDuration:300,children:(0,y.jsxs)(`div`,{className:`min-w-0 grid gap-2`,children:[I,L]})}),t[28]=I,t[29]=L,t[30]=R):R=t[30],R}function S(e){return!e}export{x as t};