@xopcai/xopc 0.0.162 → 0.0.164

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 (262) hide show
  1. package/README.md +4 -2
  2. package/README.zh-CN.md +4 -2
  3. package/dist/browser-ext/manifest.json +1 -1
  4. package/dist/extensions/telegram/xopc.extension.json +1 -1
  5. package/dist/gateway/static/root/assets/{activity-store-hpcNv9MZ.js → activity-store-DkALQFJT.js} +1 -1
  6. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Zf9UQEmQ.js → agent-avatar-dicebear-RpxkQtQ3.js} +1 -1
  7. package/dist/gateway/static/root/assets/agents-CxpwxMPE.js +2 -0
  8. package/dist/gateway/static/root/assets/{api-Dnatri09.js → api-DPIXEcIq.js} +1 -1
  9. package/dist/gateway/static/root/assets/{app-management-settings-panel-BBTR9wJP.js → app-management-settings-panel-DLdjfMXB.js} +1 -1
  10. package/dist/gateway/static/root/assets/{appearance-settings-C2zpLCHD.js → appearance-settings-C89-uxkq.js} +1 -1
  11. package/dist/gateway/static/root/assets/apps-page-k-tZbaRB.js +1 -0
  12. package/dist/gateway/static/root/assets/{archive-plugin-9eR_ODY1.js → archive-plugin-CqbH5geE.js} +1 -1
  13. package/dist/gateway/static/root/assets/{attachment-load-DPuWYUeX.js → attachment-load-CeU4Qiot.js} +1 -1
  14. package/dist/gateway/static/root/assets/{automation-suggestion-card-Dw49OJRl.js → automation-suggestion-card-WiOuqXq9.js} +1 -1
  15. package/dist/gateway/static/root/assets/automations-page-Bdn3dgC_.js +6 -0
  16. package/dist/gateway/static/root/assets/{binary-plugins-BdkJpDFm.js → binary-plugins-C5TdzrhJ.js} +1 -1
  17. package/dist/gateway/static/root/assets/{block-editor-CAi7SXYU.js → block-editor-BjvWhphG.js} +39 -39
  18. package/dist/gateway/static/root/assets/browser-settings-page-GsVTGfGs.js +8 -0
  19. package/dist/gateway/static/root/assets/{browser-workflow-inputs-Dx6wkGz1.js → browser-workflow-inputs-DXmzQ3nk.js} +1 -1
  20. package/dist/gateway/static/root/assets/{browser-workflows-page-Skertc-A.js → browser-workflows-page-C1-ptRe4.js} +2 -2
  21. package/dist/gateway/static/root/assets/capabilities-settings-panel-6d4kVjzl.js +2 -0
  22. package/dist/gateway/static/root/assets/{capability-presets-api-CNFl7dM3.js → capability-presets-api-C0pVlUyc.js} +1 -1
  23. package/dist/gateway/static/root/assets/capability-presets-settings-panel-DCxy5Ls_.js +2 -0
  24. package/dist/gateway/static/root/assets/{channel-recipient-api-DYQyGDw4.js → channel-recipient-api-B5rLegwk.js} +1 -1
  25. package/dist/gateway/static/root/assets/channels-settings-Bg3P8k0f.js +1 -0
  26. package/dist/gateway/static/root/assets/channels-status-swr-DZZq0upi.js +1 -0
  27. package/dist/gateway/static/root/assets/{connector-logo-Bng6kxYF.js → connector-logo-CuI5w4qM.js} +1 -1
  28. package/dist/gateway/static/root/assets/connectors-page-6UR7yhIZ.js +2 -0
  29. package/dist/gateway/static/root/assets/{desktop-pet-Bpf6oegd.js → desktop-pet-BvG8vDXZ.js} +1 -1
  30. package/dist/gateway/static/root/assets/{desktop-pet-settings-BVUyefSd.js → desktop-pet-settings-CR__kZ8C.js} +1 -1
  31. package/dist/gateway/static/root/assets/{directory-picker-path-field-DjSZAPz_.js → directory-picker-path-field-BblWMz3e.js} +1 -1
  32. package/dist/gateway/static/root/assets/{dreaming-settings-CAZk2AM4.js → dreaming-settings-DHMPugDE.js} +3 -3
  33. package/dist/gateway/static/root/assets/{extension-debug-page-C2F6vTTd.js → extension-debug-page-ByVY1gZg.js} +1 -1
  34. package/dist/gateway/static/root/assets/{extension-page-AnIt4bn4.js → extension-page-DLCKKtbK.js} +1 -1
  35. package/dist/gateway/static/root/assets/extension-settings-page-M-rhlFBC.js +1 -0
  36. package/dist/gateway/static/root/assets/{gateway-config-api-DLFyZv33.js → gateway-config-api-DZHqhbXH.js} +1 -1
  37. package/dist/gateway/static/root/assets/{gateway-settings-DnQAA-qq.js → gateway-settings-CZswIehx.js} +1 -1
  38. package/dist/gateway/static/root/assets/{gateway-startup-retry-DbzLyJ3R.js → gateway-startup-retry-ulwTJovP.js} +1 -1
  39. package/dist/gateway/static/root/assets/goal-create-dialog-TbyRfDas.js +1 -0
  40. package/dist/gateway/static/root/assets/goal-detail-page-B-QBVOf2.js +4 -0
  41. package/dist/gateway/static/root/assets/{goals-config-api-REmr3QCr.js → goals-config-api-DMxG6f0N.js} +1 -1
  42. package/dist/gateway/static/root/assets/goals-page-BGxki8BR.js +2 -0
  43. package/dist/gateway/static/root/assets/{goals-settings-Dz0F3uRO.js → goals-settings-G-w1gCYD.js} +1 -1
  44. package/dist/gateway/static/root/assets/{heartbeat-settings-CQFY5gYs.js → heartbeat-settings-Csb90R59.js} +1 -1
  45. package/dist/gateway/static/root/assets/index-BXtJvaQl.css +1 -0
  46. package/dist/gateway/static/root/assets/{index-C8JkTS6d.js → index-CGwuxvzr.js} +70 -70
  47. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BnOQXU5k.js → keyboard-shortcuts-settings-C_Bl3YOr.js} +1 -1
  48. package/dist/gateway/static/root/assets/local-app-workbench-page-BR2tBhO3.js +2 -0
  49. package/dist/gateway/static/root/assets/{local-apps-page-KsOtWOyM.js → local-apps-page-_8Rv-tSk.js} +1 -1
  50. package/dist/gateway/static/root/assets/{locale-store-0lpYdNDr.js → locale-store-C_ax27uc.js} +1 -1
  51. package/dist/gateway/static/root/assets/logs-page-CwF0C_Z2.js +7 -0
  52. package/dist/gateway/static/root/assets/{markdown-split-D5GRg10r.js → markdown-split-CZnZS6gq.js} +1 -1
  53. package/dist/gateway/static/root/assets/{media-plugins-C1ryULGs.js → media-plugins-C2XLYC6G.js} +1 -1
  54. package/dist/gateway/static/root/assets/messages-C96Zjb0V.js +5 -0
  55. package/dist/gateway/static/root/assets/{notes-page-CIeZ1_DT.js → notes-page-BkuZxTFo.js} +1 -1
  56. package/dist/gateway/static/root/assets/notes-workbench-CD4FADi7.js +4 -0
  57. package/dist/gateway/static/root/assets/{page-tabs-Caj1-E_X.js → page-tabs-DR2FGC4E.js} +1 -1
  58. package/dist/gateway/static/root/assets/{preview-open-alternatives-DKwEce-9.js → preview-open-alternatives-B65O8wBL.js} +1 -1
  59. package/dist/gateway/static/root/assets/{product-open-page-B90ZskkN.js → product-open-page-Cag-utLH.js} +1 -1
  60. package/dist/gateway/static/root/assets/project-detail-page-COKtUblD.js +1 -0
  61. package/dist/gateway/static/root/assets/projects-page-QYmqanBN.js +1 -0
  62. package/dist/gateway/static/root/assets/remote-access-hub-BU_gBU0f.js +1 -0
  63. package/dist/gateway/static/root/assets/{save-bar-controls-BDYt53uQ.js → save-bar-controls-DCWpFnPc.js} +1 -1
  64. package/dist/gateway/static/root/assets/schedule-field-ClacZdvE.js +1 -0
  65. package/dist/gateway/static/root/assets/{schema-form-D7oCARF7.js → schema-form-BVlbEipU.js} +1 -1
  66. package/dist/gateway/static/root/assets/sessions-page-u-Pjbzfm.js +1 -0
  67. package/dist/gateway/static/root/assets/settings-advanced-gate-1Yck1PKq.js +1 -0
  68. package/dist/gateway/static/root/assets/{settings-form-section-CARTHCxH.js → settings-form-section-GSNlQWSW.js} +1 -1
  69. package/dist/gateway/static/root/assets/{settings-loading-skeleton-DEwYqESe.js → settings-loading-skeleton-08Ae5sB_.js} +1 -1
  70. package/dist/gateway/static/root/assets/{settings-page-B6vVdHeQ.js → settings-page-BseJD4I-.js} +1 -1
  71. package/dist/gateway/static/root/assets/{settings-page-layout-D3srt5Bi.js → settings-page-layout-bSliH-Y3.js} +1 -1
  72. package/dist/gateway/static/root/assets/setup-status-panel-CGRhJVlt.js +1 -0
  73. package/dist/gateway/static/root/assets/{share-preview-page-Ck9SxiXw.js → share-preview-page-C114OpTx.js} +1 -1
  74. package/dist/gateway/static/root/assets/shares-settings-BRFpWFgI.js +1 -0
  75. package/dist/gateway/static/root/assets/skill-reload-api-cVjU2GnN.js +1 -0
  76. package/dist/gateway/static/root/assets/skills-page-CoMTjtRT.js +2 -0
  77. package/dist/gateway/static/root/assets/{system-settings-panel-DLBUQSk2.js → system-settings-panel-El8cDcTY.js} +1 -1
  78. package/dist/gateway/static/root/assets/{theme-store-C1oaqeD2.js → theme-store-D37XLD_C.js} +1 -1
  79. package/dist/gateway/static/root/assets/time-picker-CU7hhD8T.js +1 -0
  80. package/dist/gateway/static/root/assets/{typed-models-lib-Divbg_C4.js → typed-models-lib-kToxD7Rc.js} +1 -1
  81. package/dist/gateway/static/root/assets/{use-channel-catalog-CP9a_rAf.js → use-channel-catalog-DBh0dOC9.js} +1 -1
  82. package/dist/gateway/static/root/assets/user-context-page-C0xYCSXB.js +1 -0
  83. package/dist/gateway/static/root/assets/voice-api-key-field-DzEpwYaU.js +1 -0
  84. package/dist/gateway/static/root/assets/work-discovery-page-DakZqR85.js +1 -0
  85. package/dist/gateway/static/root/assets/work-item-detail-page-CswqPbTT.js +1 -0
  86. package/dist/gateway/static/root/assets/work-page-DYRXEk8m.js +1 -0
  87. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DbDPYQwB.js → workflow-run-setup-panel-BwSxyVMM.js} +2 -2
  88. package/dist/gateway/static/root/assets/workflows-page-CiLSYGuN.js +11 -0
  89. package/dist/gateway/static/root/index.html +7 -7
  90. package/dist/package.js +1 -1
  91. package/dist/src/agent/client-error-format.d.ts +1 -1
  92. package/dist/src/agent/client-error-format.js +6 -2
  93. package/dist/src/agent/embedded/model-runtime.d.ts +4 -0
  94. package/dist/src/agent/embedded/model-runtime.js +49 -0
  95. package/dist/src/agent/embedded/run-for-session.js +38 -31
  96. package/dist/src/agent/embedded/session-runner.d.ts +1 -0
  97. package/dist/src/agent/embedded/session-runner.js +13 -5
  98. package/dist/src/agent/failover-error.d.ts +1 -1
  99. package/dist/src/agent/image/generation/openai-compatible-image-provider.d.ts +2 -6
  100. package/dist/src/agent/image/generation/openai-compatible-image-provider.js +1 -3
  101. package/dist/src/agent/image/generation/provider-registry.d.ts +5 -46
  102. package/dist/src/agent/image/generation/provider-registry.js +24 -73
  103. package/dist/{extensions/dashscope/src/image-generation-provider.d.ts → src/agent/image/generation/providers/dashscope.d.ts} +3 -6
  104. package/dist/{extensions/dashscope/src/image-generation-provider.js → src/agent/image/generation/providers/dashscope.js} +36 -59
  105. package/dist/{extensions/fal/src/image-generation-provider.d.ts → src/agent/image/generation/providers/fal.d.ts} +1 -1
  106. package/dist/{extensions/fal/src/image-generation-provider.js → src/agent/image/generation/providers/fal.js} +19 -29
  107. package/dist/{extensions/google/src/image-generation-provider.d.ts → src/agent/image/generation/providers/google.d.ts} +2 -2
  108. package/dist/{extensions/google/src/image-generation-provider.js → src/agent/image/generation/providers/google.js} +23 -30
  109. package/dist/{extensions/minimax/src/image-generation-provider.d.ts → src/agent/image/generation/providers/minimax.d.ts} +2 -5
  110. package/dist/{extensions/minimax/src/image-generation-provider.js → src/agent/image/generation/providers/minimax.js} +35 -51
  111. package/dist/{extensions/openai/src/image-generation-provider.d.ts → src/agent/image/generation/providers/openai.d.ts} +2 -2
  112. package/dist/{extensions/openai/src/image-generation-provider.js → src/agent/image/generation/providers/openai.js} +13 -38
  113. package/dist/src/agent/image/generation/runtime-types.d.ts +1 -0
  114. package/dist/src/agent/image/generation/runtime.d.ts +1 -3
  115. package/dist/src/agent/image/generation/runtime.js +6 -6
  116. package/dist/src/agent/image/generation/types.d.ts +23 -3
  117. package/dist/src/agent/image/index.d.ts +1 -1
  118. package/dist/src/agent/image/index.js +2 -2
  119. package/dist/src/agent/media-generation/runtime-shared.d.ts +2 -0
  120. package/dist/src/agent/media-generation/runtime-shared.js +1 -0
  121. package/dist/src/agent/tools/factory.js +4 -1
  122. package/dist/src/agent/tools/image-generate-tool.d.ts +2 -0
  123. package/dist/src/agent/tools/image-generate-tool.js +14 -7
  124. package/dist/src/auth/credentials.js +45 -2
  125. package/dist/src/auth/index.js +2 -1
  126. package/dist/src/auth/oauth/anthropic.js +27 -24
  127. package/dist/src/auth/oauth/github-copilot.js +20 -15
  128. package/dist/src/auth/oauth/google-antigravity.js +9 -2
  129. package/dist/src/auth/oauth/google-gemini-cli.js +9 -2
  130. package/dist/src/auth/oauth/google-oauth/google-antigravity.js +47 -40
  131. package/dist/src/auth/oauth/google-oauth/google-gemini-cli.js +48 -41
  132. package/dist/src/auth/oauth/google-oauth/oauth-page.js +7 -2
  133. package/dist/src/auth/oauth/google-oauth/pkce.js +4 -1
  134. package/dist/src/auth/oauth/index.d.ts +2 -0
  135. package/dist/src/auth/oauth/index.js +24 -10
  136. package/dist/src/auth/oauth/kimi-coding.js +76 -71
  137. package/dist/src/auth/oauth/minimax-cn.js +78 -73
  138. package/dist/src/auth/oauth/minimax.js +78 -73
  139. package/dist/src/auth/oauth/openai-codex.js +31 -25
  140. package/dist/src/auth/oauth/pkce.js +4 -1
  141. package/dist/src/auth/oauth/registry.d.ts +13 -0
  142. package/dist/src/auth/oauth/registry.js +65 -0
  143. package/dist/src/auth/oauth/xopc-cloud.d.ts +2 -0
  144. package/dist/src/auth/oauth/xopc-cloud.js +101 -0
  145. package/dist/src/auth/sync-provider-auth.d.ts +3 -0
  146. package/dist/src/auth/sync-provider-auth.js +17 -1
  147. package/dist/src/cli/commands/models.js +2 -5
  148. package/dist/src/cli/commands/onboard/model.js +3 -2
  149. package/dist/src/cli/commands/setup-shared/types.d.ts +1 -1
  150. package/dist/src/cli/utils/oauth-providers.d.ts +3 -26
  151. package/dist/src/cli/utils/oauth-providers.js +6 -80
  152. package/dist/src/config/index.js +2 -2
  153. package/dist/src/config/models-json.d.ts +6 -0
  154. package/dist/src/config/models-json.js +10 -6
  155. package/dist/src/config/schema.d.ts +26 -15
  156. package/dist/src/config/schema.js +23 -12
  157. package/dist/src/gateway/heartbeat/service.js +1 -1
  158. package/dist/src/gateway/hono/app.js +12 -6
  159. package/dist/src/gateway/hono/lib/safe-providers-config.d.ts +0 -3
  160. package/dist/src/gateway/hono/lib/safe-providers-config.js +1 -3
  161. package/dist/src/gateway/hono/middleware/strict-rate-limit.d.ts +4 -0
  162. package/dist/src/gateway/hono/middleware/strict-rate-limit.js +8 -1
  163. package/dist/src/gateway/hono/oauth-async.js +3 -19
  164. package/dist/src/gateway/hono/oauth.js +3 -19
  165. package/dist/src/gateway/hono/routes/config-patch/misc.js +2 -11
  166. package/dist/src/gateway/hono/routes/deps.d.ts +1 -0
  167. package/dist/src/gateway/hono/routes/lazy-bundles.js +9 -2
  168. package/dist/src/gateway/hono/routes/models.js +96 -128
  169. package/dist/src/gateway/image-generation-setup.d.ts +40 -0
  170. package/dist/src/gateway/image-generation-setup.js +130 -0
  171. package/dist/src/gateway/rate-limit/buckets.d.ts +3 -0
  172. package/dist/src/gateway/rate-limit/buckets.js +12 -0
  173. package/dist/src/gateway/service.d.ts +3 -0
  174. package/dist/src/gateway/service.js +10 -0
  175. package/dist/src/heartbeat/index.js +1 -1
  176. package/dist/src/media-shared/http/private-network.d.ts +1 -1
  177. package/dist/src/media-shared/http/private-network.js +1 -1
  178. package/dist/src/providers/auth-runtime/resolve-api-key.d.ts +2 -4
  179. package/dist/src/providers/auth-runtime/resolve-api-key.js +2 -4
  180. package/dist/src/providers/auth-runtime/resolve-auth.d.ts +3 -4
  181. package/dist/src/providers/auth-runtime/resolve-auth.js +18 -18
  182. package/dist/src/providers/domestic-presets.d.ts +2 -0
  183. package/dist/src/providers/index.js +9 -0
  184. package/dist/src/providers/model-catalog-store.d.ts +33 -0
  185. package/dist/src/providers/model-catalog-store.js +63 -0
  186. package/dist/src/providers/model-catalog-sync-service.d.ts +40 -0
  187. package/dist/src/providers/model-catalog-sync-service.js +132 -0
  188. package/dist/src/providers/model-reference-auditor.d.ts +14 -0
  189. package/dist/src/providers/model-reference-auditor.js +71 -0
  190. package/dist/src/providers/model-registry.d.ts +4 -1
  191. package/dist/src/providers/model-registry.js +33 -2
  192. package/dist/src/providers/presentation.js +2 -0
  193. package/dist/src/providers/xopc-cloud-model-source.d.ts +30 -0
  194. package/dist/src/providers/xopc-cloud-model-source.js +68 -0
  195. package/dist/src/session/index.d.ts +1 -1
  196. package/dist/src/session/index.js +2 -2
  197. package/dist/src/session/session-title.d.ts +2 -0
  198. package/dist/src/session/session-title.js +24 -3
  199. package/dist/src/work-discovery/analyzer.js +27 -14
  200. package/package.json +5 -7
  201. package/dist/extensions/dashscope/src/index.d.ts +0 -4
  202. package/dist/extensions/dashscope/src/index.js +0 -2
  203. package/dist/extensions/dashscope/xopc.extension.json +0 -15
  204. package/dist/extensions/fal/src/index.d.ts +0 -4
  205. package/dist/extensions/fal/src/index.js +0 -2
  206. package/dist/extensions/fal/xopc.extension.json +0 -14
  207. package/dist/extensions/google/src/index.d.ts +0 -4
  208. package/dist/extensions/google/src/index.js +0 -2
  209. package/dist/extensions/google/xopc.extension.json +0 -14
  210. package/dist/extensions/minimax/src/index.d.ts +0 -4
  211. package/dist/extensions/minimax/src/index.js +0 -2
  212. package/dist/extensions/minimax/xopc.extension.json +0 -15
  213. package/dist/extensions/openai/src/index.d.ts +0 -4
  214. package/dist/extensions/openai/src/index.js +0 -2
  215. package/dist/extensions/openai/xopc.extension.json +0 -14
  216. package/dist/gateway/static/root/assets/agents-DfVkZlHc.js +0 -2
  217. package/dist/gateway/static/root/assets/apps-page-BMtAa4Ra.js +0 -1
  218. package/dist/gateway/static/root/assets/automations-page-BiSAMYTr.js +0 -6
  219. package/dist/gateway/static/root/assets/browser-settings-page-DHmaEJS2.js +0 -8
  220. package/dist/gateway/static/root/assets/capabilities-settings-panel-B5wSgf4f.js +0 -2
  221. package/dist/gateway/static/root/assets/capability-presets-settings-panel-DyvFZwBj.js +0 -2
  222. package/dist/gateway/static/root/assets/channels-settings-BBKEqDZn.js +0 -1
  223. package/dist/gateway/static/root/assets/channels-status-swr-Drk110ve.js +0 -1
  224. package/dist/gateway/static/root/assets/connectors-page-HpgaUDQ1.js +0 -2
  225. package/dist/gateway/static/root/assets/extension-settings-page-CLSc6682.js +0 -1
  226. package/dist/gateway/static/root/assets/goal-create-dialog-DrnKFC6M.js +0 -1
  227. package/dist/gateway/static/root/assets/goal-detail-page-Cw1hpJkZ.js +0 -4
  228. package/dist/gateway/static/root/assets/goals-page-BDGkTVma.js +0 -2
  229. package/dist/gateway/static/root/assets/index-hmrG55qg.css +0 -1
  230. package/dist/gateway/static/root/assets/local-app-workbench-page-Bdef1b7F.js +0 -2
  231. package/dist/gateway/static/root/assets/logs-page-CwLPgrWh.js +0 -7
  232. package/dist/gateway/static/root/assets/messages-BwQ3WssU.js +0 -5
  233. package/dist/gateway/static/root/assets/notes-workbench-Cf06q19x.js +0 -4
  234. package/dist/gateway/static/root/assets/project-detail-page-SHTurM4t.js +0 -1
  235. package/dist/gateway/static/root/assets/projects-page-BcC2qUAw.js +0 -1
  236. package/dist/gateway/static/root/assets/remote-access-hub-6vGefBHv.js +0 -1
  237. package/dist/gateway/static/root/assets/schedule-field-Bcdni4Pj.js +0 -1
  238. package/dist/gateway/static/root/assets/sessions-page-C5014a53.js +0 -1
  239. package/dist/gateway/static/root/assets/settings-advanced-gate-CDY3ZI1K.js +0 -1
  240. package/dist/gateway/static/root/assets/settings-collapsible-section-6eNF8Jey.js +0 -1
  241. package/dist/gateway/static/root/assets/setup-status-panel-z-rF0Hdg.js +0 -1
  242. package/dist/gateway/static/root/assets/shares-settings-CHZFXE_d.js +0 -1
  243. package/dist/gateway/static/root/assets/skill-reload-api-B7p2QNXt.js +0 -1
  244. package/dist/gateway/static/root/assets/skills-page-ncw3tX9P.js +0 -2
  245. package/dist/gateway/static/root/assets/user-context-page-iYfeSLKI.js +0 -1
  246. package/dist/gateway/static/root/assets/voice-api-key-field-CrwkicvT.js +0 -1
  247. package/dist/gateway/static/root/assets/work-discovery-page-BQWxyPg8.js +0 -1
  248. package/dist/gateway/static/root/assets/work-item-detail-page-50ZzGay5.js +0 -1
  249. package/dist/gateway/static/root/assets/work-page-DPqEahx7.js +0 -1
  250. package/dist/gateway/static/root/assets/workflows-page-C3eIC5HZ.js +0 -11
  251. package/dist/src/agent/embedded/xopc-auth-storage.d.ts +0 -19
  252. package/dist/src/agent/embedded/xopc-auth-storage.js +0 -40
  253. package/dist/src/agent/image/generation/bundled-registry.d.ts +0 -18
  254. package/dist/src/agent/image/generation/bundled-registry.js +0 -35
  255. package/dist/src/agent/image/generation/bundled.d.ts +0 -10
  256. package/dist/src/agent/image/generation/bundled.js +0 -15
  257. package/dist/src/agent/image/generation/image-provider-ui.d.ts +0 -20
  258. package/dist/src/agent/image/generation/image-provider-ui.js +0 -1
  259. package/dist/src/gateway/image-capabilities.d.ts +0 -28
  260. package/dist/src/gateway/image-capabilities.js +0 -78
  261. package/dist/src/generated/bundled-image-generation-providers.d.ts +0 -14
  262. package/dist/src/generated/bundled-image-generation-providers.js +0 -17
@@ -1,2 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./circle-alert-BEjgurr2.js";import{t as s}from"./cn-JdwAhgNB.js";import{n as c}from"./copy-to-clipboard-HOJ79TWv.js";import{t as l}from"./messages-BwQ3WssU.js";import{l as u,n as d,r as f,s as p}from"./locale-store-0lpYdNDr.js";import{Bo as m,Bs as h,Cs as g,Dc as _,Ds as v,Fi as y,Hl as b,Ho as x,Ic as S,Ii as C,Jc as w,Li as T,Ll as E,Ms as D,Os as O,Pi as k,Ri as A,Ro as j,Tc as M,Uo as N,Vo as P,Wo as F,Xa as I,Xl as L,Xs as R,Za as z,Zl as B,_c as ee,_i as V,as as H,bi as U,bo as te,cc as ne,ea as re,es as ie,gi as ae,hi as oe,hs as se,ic as ce,jl as le,ll as ue,os as de,ou as fe,pc as pe,qs as me,rs as W,sc as he,ts as ge,uc as _e,uu as ve,vi as ye,vs as G,wc as K,ws as q,zo as J}from"./index-C8JkTS6d.js";import{t as be}from"./page-tabs-Caj1-E_X.js";import{t as xe}from"./connector-logo-Bng6kxYF.js";var Y=e(t(),1),X=n(),Z=r();function Se(e){let t=(0,X.c)(74),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:o}=e,c,l,u,d,f,p,m,h,g,_;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==o.connect||t[5]!==o.connectedBadge||t[6]!==o.connectorBeta||t[7]!==o.connectorCapabilityLabels||t[8]!==o.connectorExperimental||t[9]!==o.connectorVerified){let e=n.capabilities.filter(Ce),v=e.slice(0,3),y=Math.max(0,e.length-v.length),b=o.connect,x=n.verificationLevel===`verified`?o.connectorVerified:n.verificationLevel===`beta`?o.connectorBeta:n.verificationLevel===`experimental`?o.connectorExperimental:null,C;t[20]!==b||t[21]!==n||t[22]!==i?(C=e=>(0,Z.jsxs)(q,{type:`button`,variant:`primary`,className:s(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:e=>{e.stopPropagation(),i(n)},children:[(0,Z.jsx)(S,{className:`size-4`}),b]}),t[20]=b,t[21]=n,t[22]=i,t[23]=C):C=t[23],c=C;let w;t[24]!==n||t[25]!==a?(w=e=>{!a||e.currentTarget!==e.target||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),a(n))},t[24]=n,t[25]=a,t[26]=w):w=t[26];let T=w,E=a?`cursor-pointer`:null;t[27]===E?p=t[28]:(p=s(`group flex min-h-[9.5rem] flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,E),t[27]=E,t[28]=p),m=a?`button`:void 0,h=a?0:void 0,t[29]!==n||t[30]!==a?(g=()=>a?.(n),t[29]=n,t[30]=a,t[31]=g):g=t[31],_=T,l=`flex min-w-0 flex-1 flex-col`;let D;t[32]===n?D=t[33]:(D=(0,Z.jsx)(xe,{connector:n}),t[32]=n,t[33]=D);let O;t[34]===n.displayName?O=t[35]:(O=(0,Z.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[34]=n.displayName,t[35]=O);let k;t[36]===x?k=t[37]:(k=x?(0,Z.jsx)(`span`,{className:`mt-1 inline-flex rounded-full border border-edge px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:x}):null,t[36]=x,t[37]=k);let A;t[38]!==O||t[39]!==k?(A=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[O,k]}),t[38]=O,t[39]=k,t[40]=A):A=t[40];let j;t[41]!==D||t[42]!==A?(j=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[D,A]}),t[41]=D,t[42]=A,t[43]=j):j=t[43];let M;t[44]!==r||t[45]!==c?(M=r?null:(0,Z.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 transition-opacity sm:pointer-events-none sm:flex sm:opacity-0 sm:group-hover:pointer-events-auto sm:group-hover:opacity-100 sm:group-focus-within:pointer-events-auto sm:group-focus-within:opacity-100`,children:c()}),t[44]=r,t[45]=c,t[46]=M):M=t[46];let N;t[47]!==r||t[48]!==o.connectedBadge?(N=r?(0,Z.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,Z.jsx)(fe,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[47]=r,t[48]=o.connectedBadge,t[49]=N):N=t[49];let P;t[50]!==M||t[51]!==N?(P=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[M,N]}),t[50]=M,t[51]=N,t[52]=P):P=t[52],t[53]!==j||t[54]!==P?(u=(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[j,P]}),t[53]=j,t[54]=P,t[55]=u):u=t[55],t[56]===n.description?d=t[57]:(d=(0,Z.jsx)(`p`,{className:`mt-4 line-clamp-2 text-sm leading-6 text-fg-muted`,title:n.description,children:n.description}),t[56]=n.description,t[57]=d),f=v.length>0?(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-1.5`,children:[v.map(e=>(0,Z.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:o.connectorCapabilityLabels[e]??e},e)),y>0?(0,Z.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,y]}):null]}):null,t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o.connect,t[5]=o.connectedBadge,t[6]=o.connectorBeta,t[7]=o.connectorCapabilityLabels,t[8]=o.connectorExperimental,t[9]=o.connectorVerified,t[10]=c,t[11]=l,t[12]=u,t[13]=d,t[14]=f,t[15]=p,t[16]=m,t[17]=h,t[18]=g,t[19]=_}else c=t[10],l=t[11],u=t[12],d=t[13],f=t[14],p=t[15],m=t[16],h=t[17],g=t[18],_=t[19];let v;t[58]!==l||t[59]!==u||t[60]!==d||t[61]!==f?(v=(0,Z.jsxs)(`div`,{className:l,children:[u,d,f]}),t[58]=l,t[59]=u,t[60]=d,t[61]=f,t[62]=v):v=t[62];let y;t[63]!==r||t[64]!==c?(y=r?null:(0,Z.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:c(`w-full`)}),t[63]=r,t[64]=c,t[65]=y):y=t[65];let b;return t[66]!==v||t[67]!==y||t[68]!==p||t[69]!==m||t[70]!==h||t[71]!==g||t[72]!==_?(b=(0,Z.jsxs)(`div`,{className:p,role:m,tabIndex:h,onClick:g,onKeyDown:_,children:[v,y]}),t[66]=v,t[67]=y,t[68]=p,t[69]=m,t[70]=h,t[71]=g,t[72]=_,t[73]=b):b=t[73],b}function Ce(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var we=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function Te(e,t){return t.some(t=>t.connectorId===e.id)}var Ee=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function De(){let e=(0,X.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`div`,{className:s(`size-10 shrink-0 rounded-xl`,Ee)}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.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,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:[t,(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Z.jsx)(`div`,{className:s(`h-4 min-w-0 flex-1`,Ee)}),(0,Z.jsx)(`div`,{className:s(`h-8 w-[4.5rem] shrink-0 rounded-lg`,Ee)})]}),(0,Z.jsx)(`div`,{className:s(`h-3 w-full`,Ee)}),(0,Z.jsx)(`div`,{className:s(`h-3 w-[88%]`,Ee)})]})]})}),e[1]=n):n=e[1],n}var Oe=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function ke(){let e=(0,X.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`div`,{className:s(`size-10 shrink-0 rounded-xl`,Oe)}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,Z.jsx)(`div`,{className:s(`h-4 w-48 max-w-full`,Oe)}),(0,Z.jsx)(`div`,{className:s(`h-3 w-72 max-w-full`,Oe)})]}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-start justify-between gap-3`,children:[n,(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Z.jsx)(`div`,{className:s(`h-9 w-20 rounded-lg`,Oe)}),(0,Z.jsx)(`div`,{className:s(`h-9 w-20 rounded-lg`,Oe)})]})]})]}),e[2]=r):r=e[2];let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:[r,(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,Z.jsx)(`div`,{className:s(`h-8 w-20 rounded-md`,Oe)}),(0,Z.jsx)(`div`,{className:s(`h-8 w-24 rounded-md`,Oe)}),(0,Z.jsx)(`div`,{className:s(`h-8 w-28 rounded-md`,Oe)})]}),(0,Z.jsx)(`div`,{className:s(`mt-3 h-20 rounded-xl`,Oe)})]}),e[3]=i):i=e[3],i}function Q(e,t){if(!e.payload)throw Error(e.error??t);return e.payload}async function Ae(){return Q(await p(f(`/api/connectors/catalog`)),`Could not load connector catalog.`).connectors}async function je(e){let t=new URLSearchParams;return e?.q?.trim()&&t.set(`q`,e.q.trim()),e?.page&&t.set(`page`,String(e.page)),e?.pageSize&&t.set(`pageSize`,String(e.pageSize)),e?.refresh&&t.set(`refresh`,`1`),e?.verification&&t.set(`verification`,e.verification),Q(await p(f(`/api/connectors/composio/catalog${t.size?`?${t.toString()}`:``}`)),`Could not load Composio catalog.`)}async function Me(e){let t=new URLSearchParams;return e?.q?.trim()&&t.set(`q`,e.q.trim()),e?.page&&t.set(`page`,String(e.page)),e?.pageSize&&t.set(`pageSize`,String(e.pageSize)),e?.category?.trim()&&t.set(`category`,e.category.trim()),e?.sort&&t.set(`sort`,e.sort),Q(await p(f(`/api/capabilities/connectors${t.size?`?${t.toString()}`:``}`)),`Could not load Store connector capabilities.`)}async function Ne(e,t){return Q(await p(f(`/api/capabilities/connectors/${encodeURIComponent(e)}/install-plan`),{method:`POST`,body:JSON.stringify({version:t})}),`Could not prepare connector installation.`).plan}async function Pe(e,t,n){let r=await p(f(`/api/capabilities/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify({...t,version:n})});return I(),Q(r,`Could not install Store connector.`).instance}async function Fe(){return Q(await p(f(`/api/connectors/installed`)),`Could not load installed connectors.`).instances}async function Ie(e){return Q(await p(f(`/api/connectors/${encodeURIComponent(e)}/auth/start`),{method:`POST`}),`Could not start connector authorization.`).authorization}async function Le(){return Q(await p(f(`/api/connectors/composio/setup-status`)),`Could not check the connection service.`)}async function Re(e){Q(await p(f(`/api/connectors/composio/setup`),{method:`POST`,body:JSON.stringify({apiKey:e})}),`Could not enable the connection service.`)}async function ze(e,t){let n=await p(f(`/api/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify(t)});return I(),Q(n,`Could not install connector.`).instance}async function Be(e,t={}){return Q(await p(f(`/api/connectors/preview`),{method:`POST`,body:JSON.stringify({...t,definition:e})}),`Could not preview connector capabilities.`).preview}async function Ve(e,t){return Q(await p(f(`/api/connectors/${encodeURIComponent(e)}/config`),{method:`POST`,body:JSON.stringify(t)}),`Could not update connector config.`).instance}async function He(e){await p(f(`/api/connectors/${encodeURIComponent(e)}`),{method:`DELETE`}),I()}async function Ue(e){return Q(await p(f(`/api/connectors/${encodeURIComponent(e)}/test`),{method:`POST`}),`Connector test failed.`)}async function We(){return Q(await p(f(`/api/connectors/composio/connections`)),`Could not load Composio connections.`).connections}async function Ge(e,t){return Q(await p(f(`/api/connectors/composio/connections/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(t)}),`Could not update Composio connection.`).connection}async function Ke(e){return Q(await p(f(`/api/connectors/composio/${encodeURIComponent(e)}/health`)),`Could not check Composio connector health.`).health}async function qe(e){await p(f(`/api/connectors/composio/connections/${encodeURIComponent(e)}/refresh`),{method:`POST`})}async function Je(e){await p(f(`/api/connectors/composio/connections/${encodeURIComponent(e)}`),{method:`DELETE`})}async function Ye(e){return Q(await p(f(`/api/connectors/composio/${encodeURIComponent(e)}/scope`)),`Could not load Composio scope.`).scope}async function Xe(e,t){let n=await p(f(`/api/connectors/composio/${encodeURIComponent(e)}/scope`),{method:`POST`,body:JSON.stringify({scope:t})});return I(),Q(n,`Could not update Composio scope.`).scope}async function Ze(e){return Q(await p(f(`/api/connectors/composio/${encodeURIComponent(e)}/policy`)),`Could not load Composio policy.`)}async function Qe(e,t){return Q(await p(f(`/api/connectors/composio/${encodeURIComponent(e)}/policy`),{method:`PATCH`,body:JSON.stringify(t)}),`Could not update Composio policy.`).policy}async function $e(e){return Q(await p(f(`/api/connectors/composio/${encodeURIComponent(e)}/tools`)),`Could not load Composio tools.`).tools}async function et(e=50){return Q(await p(f(`/api/connectors/composio/triggers?limit=${encodeURIComponent(String(e))}`)),`Could not load Composio trigger events.`).events}async function tt(e){return Q(await p(f(`/api/connectors/${encodeURIComponent(e.connectorId)}/memory-sync`),{method:`POST`,body:JSON.stringify(e)}),`Could not sync connector data to memory.`)}async function nt(e){return Q(await p(f(`/api/connectors/${encodeURIComponent(e)}/memory-sync-profile`)),`Could not load memory sync settings.`).profile}async function rt(e,t){return Q(await p(f(`/api/connectors/${encodeURIComponent(e)}/memory-sync-profile`),{method:`PATCH`,body:JSON.stringify(t)}),`Could not save memory sync settings.`).profile}async function it(e){return Q(await p(f(`/api/connectors/${encodeURIComponent(e)}/memory-sync`),{method:`POST`,body:JSON.stringify({})}),`Could not sync connector data to memory.`)}async function at(e=``,t=100){return Q(await p(f(`/api/connectors/people?${new URLSearchParams({q:e,limit:String(t)}).toString()}`)),`Could not load the connected people graph.`)}async function ot(e=`pending`){return Q(await p(f(`/api/connectors/approvals?status=${encodeURIComponent(e)}`)),`Could not load connector approvals.`).approvals}async function st(e,t){return Q(await p(f(`/api/connectors/approvals/respond`),{method:`POST`,body:JSON.stringify({id:e,decision:t})}),`Could not update connector approval.`).approval}function ct(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function lt(e,t){return t.connectorCapabilityLabels[e]??e}function ut(e,t){if(e.runtime.type===`mcp`)return ct(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.type===`composio`?e.runtime.toolkit:e.runtime.type===`channel`?e.runtime.channelId:e.runtime.type===`nativeTool`?e.runtime.toolsetId:e.runtime.sourceKind;return ct(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n??e.runtime.type})}function dt(e,t){return e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function ft(e){return(e.setup.secrets??[]).filter(e=>e.required).length+(e.setup.config??[]).filter(e=>e.required).length}function pt(e){let t=(0,X.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,Z.jsx)(`div`,{className:`border-b border-edge px-3 py-2 text-xs font-semibold text-fg`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,16).map(mt),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>16?(0,Z.jsxs)(`div`,{className:`px-3 py-2 text-xs text-fg-subtle`,children:[`+`,r.length-16]}):null,t[4]=r.length,t[5]=o);let s;t[6]!==a||t[7]!==o?(s=(0,Z.jsxs)(`div`,{className:`max-h-48 overflow-y-auto`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==i||t[10]!==s?(c=(0,Z.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base`,children:[i,s]}),t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function mt(e){return(0,Z.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,Z.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,Z.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function ht({connector:e,installed:t,onClose:n,onInstall:r,t:i}){let[a,o]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(null),f=ft(e),p=e.capabilities.slice(0,8),h=Math.max(0,e.capabilities.length-p.length),g=[...(e.setup.secrets??[]).map(e=>({key:`secret:${e.key}`,label:e.label,description:e.description,required:e.required,kind:i.connectorSetupSecret})),...(e.setup.config??[]).map(e=>({key:`config:${e.key}`,label:e.label,description:e.description,required:!!e.required,kind:i.connectorSetupConfig}))],y=async()=>{o(!0),d(null);try{l(await Be(e))}catch(e){l(null),d(e instanceof Error?e.message:String(e))}finally{o(!1)}};return(0,Z.jsx)(j,{open:!0,onOpenChange:e=>{e||n()},children:(0,Z.jsxs)(N,{children:[(0,Z.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Z.jsxs)(m,{className:s(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,52rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float outline-none dark:border-edge`),children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Z.jsx)(xe,{connector:e,size:`lg`}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[t?(0,Z.jsx)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,Z.jsx)(fe,{className:`size-3`,"aria-hidden":!0}),i.connectedBadge]})}):null,(0,Z.jsx)(F,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,Z.jsx)(P,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:e.description})]})]}),(0,Z.jsx)(J,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:s(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,G.focusRingPanel),"aria-label":i.modalClose,children:[(0,Z.jsx)(v,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,Z.jsx)(O,{className:`size-3.5`,"aria-hidden":!0}),i.detailTools]}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:c?ct(i.connectorPreviewToolsCount,{count:c.toolCount}):i.connectorPreviewUnknown})]}),(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,Z.jsx)(ue,{className:`size-3.5`,"aria-hidden":!0}),i.detailPermissions]}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:dt(e,i)})]}),(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,Z.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),i.connectorRequiredInputs]}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:ct(i.connectorRequiredInputsCount,{count:f})})]})]}),(0,Z.jsxs)(`div`,{className:`mt-5 grid gap-5 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.connectorCapabilitiesTitle}),(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[p.map(e=>(0,Z.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-muted`,children:lt(e,i)},e)),h>0?(0,Z.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-subtle`,children:[`+`,h]}):null]})]}),u?(0,Z.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:u}):null,c?(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.connectorPreviewTitle}),(0,Z.jsx)(`span`,{className:s(`rounded-full px-2 py-0.5 text-xs font-medium`,c.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:c.ok?i.healthStatusHealthy:i.healthStatusLabels[c.status]??c.status})]}),(0,Z.jsxs)(`div`,{className:`mb-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`font-semibold text-fg`,children:c.toolCount}),(0,Z.jsx)(`div`,{className:`text-fg-muted`,children:i.toolsMetric})]}),(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`font-semibold text-fg`,children:c.resourceCount}),(0,Z.jsx)(`div`,{className:`text-fg-muted`,children:i.resourcesMetric})]}),(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`font-semibold text-fg`,children:c.promptCount}),(0,Z.jsx)(`div`,{className:`text-fg-muted`,children:i.promptsMetric})]})]}),(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Z.jsx)(pt,{title:i.detailTools,items:c.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,Z.jsx)(pt,{title:i.detailResources,items:c.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,Z.jsx)(pt,{title:i.detailPrompts,items:c.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??ct(i.promptArgumentCount,{count:e.argumentCount})}))})]}),c.error?(0,Z.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:c.error}):null,c.action?(0,Z.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-subtle`,children:c.action}):null]}):null]}),(0,Z.jsxs)(`aside`,{className:`space-y-3`,children:[(0,Z.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Z.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Z.jsx)(ue,{className:`size-4 text-accent`,"aria-hidden":!0}),i.detailPermissions]}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm font-medium text-fg`,children:dt(e,i)})]}),(0,Z.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Z.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Z.jsx)(b,{className:`size-4 text-accent`,"aria-hidden":!0}),i.connectorSetupTitle]}),g.length>0?(0,Z.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-lg border border-edge`,children:g.map(e=>(0,Z.jsxs)(`div`,{className:`bg-surface-panel px-3 py-2.5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),(0,Z.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e.kind}),e.required?(0,Z.jsx)(`span`,{className:`rounded-md bg-amber-500/10 px-1.5 py-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-300`,children:i.connectorSetupRequired}):null]}),e.description?(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.key))}):(0,Z.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:i.connectorSetupNone})]}),(0,Z.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Z.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Z.jsx)(ne,{className:`size-4 text-accent`,"aria-hidden":!0}),i.connectorRuntimeTitle]}),(0,Z.jsx)(`p`,{className:`mt-2 break-words text-xs leading-5 text-fg-muted`,children:ut(e,i)})]})]})]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,Z.jsx)(J,{asChild:!0,children:(0,Z.jsx)(q,{variant:`secondary`,children:i.modalClose})}),(0,Z.jsxs)(q,{variant:`secondary`,disabled:a,onClick:()=>void y(),children:[a?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(O,{className:`size-4`}),i.connectorPreviewButton]}),t?(0,Z.jsxs)(q,{variant:`secondary`,disabled:!0,children:[(0,Z.jsx)(_,{className:`size-4`}),i.connectedBadge]}):(0,Z.jsxs)(q,{variant:`primary`,onClick:()=>{r(e),n()},children:[(0,Z.jsx)(S,{className:`size-4`}),i.connect]})]})]})]})})}var gt=s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,g);function _t(e){let t=(0,X.c)(58),{open:n,sessionIdleTtlMinutes:r,saving:i,onChange:a,onSave:o,onClose:c,t:l,mcp:u}=e,d;t[0]===c?d=t[1]:(d=e=>{e||c()},t[0]=c,t[1]=d);let f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[2]=f):f=t[2];let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=s(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(32rem,calc(100vh-2rem))] w-[min(100%-2rem,38rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),t[3]=p):p=t[3];let h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,Z.jsx)(M,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})}),t[4]=h):h=t[4];let g;t[5]===l.runtimeSettingsTitle?g=t[6]:(g=(0,Z.jsx)(F,{className:`text-base font-semibold text-fg`,children:l.runtimeSettingsTitle}),t[5]=l.runtimeSettingsTitle,t[6]=g);let _;t[7]===l.runtimeSettingsHint?_=t[8]:(_=(0,Z.jsx)(P,{className:`mt-1 text-sm text-fg-muted`,children:l.runtimeSettingsHint}),t[7]=l.runtimeSettingsHint,t[8]=_);let y;t[9]!==g||t[10]!==_?(y=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[h,(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[g,_]})]}),t[9]=g,t[10]=_,t[11]=y):y=t[11];let b;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(b=s(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,G.focusRingPanel),t[12]=b):b=t[12];let S;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(v,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=S):S=t[13];let C;t[14]===l.modalClose?C=t[15]:(C=(0,Z.jsx)(J,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:b,"aria-label":l.modalClose,children:S})}),t[14]=l.modalClose,t[15]=C);let T;t[16]!==C||t[17]!==y?(T=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[y,C]}),t[16]=C,t[17]=y,t[18]=T):T=t[18];let E;t[19]===u.idleTtlLabel?E=t[20]:(E=(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:u.idleTtlLabel}),t[19]=u.idleTtlLabel,t[20]=E);let D;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(D=s(gt,`w-40 flex-none`),t[21]=D):D=t[21];let O=r??``,k;t[22]===a?k=t[23]:(k=e=>{let t=e.currentTarget.value.trim();a(t===``?void 0:Number.parseInt(t,10))},t[22]=a,t[23]=k);let A;t[24]!==u.idleTtlPlaceholder||t[25]!==O||t[26]!==k?(A=(0,Z.jsx)(`input`,{type:`number`,min:0,className:D,value:O,placeholder:u.idleTtlPlaceholder,onChange:k}),t[24]=u.idleTtlPlaceholder,t[25]=O,t[26]=k,t[27]=A):A=t[27];let I;t[28]===u.idleTtlHint?I=t[29]:(I=(0,Z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:u.idleTtlHint}),t[28]=u.idleTtlHint,t[29]=I);let L;t[30]!==E||t[31]!==A||t[32]!==I?(L=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,Z.jsxs)(`label`,{className:`flex max-w-xl flex-col gap-1.5`,children:[E,A,I]})}),t[30]=E,t[31]=A,t[32]=I,t[33]=L):L=t[33];let R;t[34]!==c||t[35]!==i||t[36]!==l.modalCancel?(R=(0,Z.jsx)(q,{type:`button`,variant:`secondary`,disabled:i,onClick:c,children:l.modalCancel}),t[34]=c,t[35]=i,t[36]=l.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,Z.jsx)(w,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[40]=i,t[41]=B);let ee;t[42]!==u.save||t[43]!==i||t[44]!==z||t[45]!==B?(ee=(0,Z.jsxs)(q,{type:`button`,variant:`primary`,disabled:i,onClick:z,children:[B,u.save]}),t[42]=u.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,Z.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]!==T||t[51]!==L||t[52]!==V?(H=(0,Z.jsxs)(N,{children:[f,(0,Z.jsxs)(m,{className:p,children:[T,L,V]})]}),t[50]=T,t[51]=L,t[52]=V,t[53]=H):H=t[53];let U;return t[54]!==n||t[55]!==d||t[56]!==H?(U=(0,Z.jsx)(j,{open:n,onOpenChange:d,children:H}),t[54]=n,t[55]=d,t[56]=H,t[57]=U):U=t[57],U}var vt=(0,Y.memo)(function(e){let t=(0,X.c)(12),{value:n,onChange:r,placeholder:i,className:a}=e,o;t[0]===a?o=t[1]:(o=s(`relative flex min-h-9 min-w-0 flex-1 cursor-text items-center rounded-pill border border-edge bg-surface-panel py-1.5 pl-9 pr-3 shadow-surface`,a),t[0]=a,t[1]=o);let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(_e,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=c):c=t[2];let l;t[3]===r?l=t[4]:(l=e=>r(e.currentTarget.value),t[3]=r,t[4]=l);let u;t[5]!==i||t[6]!==l||t[7]!==n?(u=(0,Z.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:n,onChange:l,placeholder:i,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`}),t[5]=i,t[6]=l,t[7]=n,t[8]=u):u=t[8];let d;return t[9]!==o||t[10]!==u?(d=(0,Z.jsxs)(`label`,{className:o,children:[c,u]}),t[9]=o,t[10]=u,t[11]=d):d=t[11],d}),yt=(0,Y.memo)(function(e){let t=(0,X.c)(30),{onBrowseCatalog:n,onAddCustomServer:r,onOpenRuntimeSettings:i,addLabel:a,browseLabel:o,customLabel:c,settingsLabel:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(he,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=u):u=t[0];let d;t[1]===l?d=t[2]:(d=(0,Z.jsx)(`span`,{className:`hidden sm:inline`,children:l}),t[1]=l,t[2]=d);let f;t[3]!==i||t[4]!==l||t[5]!==d?(f=(0,Z.jsxs)(q,{type:`button`,variant:`secondary`,className:`shrink-0 gap-2`,"aria-label":l,title:l,onClick:i,children:[u,d]}),t[3]=i,t[4]=l,t[5]=d,t[6]=f):f=t[6];let p;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(K,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[7]=p):p=t[7];let m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(ve,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[8]=m):m=t[8];let h;t[9]===a?h=t[10]:(h=(0,Z.jsx)(U,{asChild:!0,children:(0,Z.jsxs)(q,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,children:[p,a,m]})}),t[9]=a,t[10]=h);let g;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(g=s(`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,G.transition),t[11]=g):g=t[11];let _;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Z.jsx)(me,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=_):_=t[12];let v;t[13]!==o||t[14]!==n?(v=(0,Z.jsxs)(ae,{className:g,onSelect:n,children:[_,o]}),t[13]=o,t[14]=n,t[15]=v):v=t[15];let y;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(y=s(`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,G.transition),t[16]=y):y=t[16];let b;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(O,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[17]=b):b=t[17];let x;t[18]!==c||t[19]!==r?(x=(0,Z.jsxs)(ae,{className:y,onSelect:r,children:[b,c]}),t[18]=c,t[19]=r,t[20]=x):x=t[20];let S;t[21]!==x||t[22]!==v?(S=(0,Z.jsx)(V,{children:(0,Z.jsxs)(oe,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[v,x]})}),t[21]=x,t[22]=v,t[23]=S):S=t[23];let C;t[24]!==S||t[25]!==h?(C=(0,Z.jsxs)(ye,{children:[h,S]}),t[24]=S,t[25]=h,t[26]=C):C=t[26];let w;return t[27]!==C||t[28]!==f?(w=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[f,C]}),t[27]=C,t[28]=f,t[29]=w):w=t[29],w}),bt=/^([^:=]+)[:=](.*)$/;function xt(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return Object.entries(e).map(([e,t])=>({key:e,value:t==null?``:String(t)}))}catch{}let n=[];for(let e of t.split(/\r?\n/)){let t=e.trim();if(!t)continue;let r=bt.exec(t);r&&n.push({key:r[1].trim(),value:r[2].trim()})}return n.length>0?n:null}function St(e){let t={};for(let n of e){let e=n.key.trim();e&&(t[e]=n.value)}return Object.keys(t).length>0?t:void 0}function Ct(e){if(!e||typeof e!=`object`)return[{key:``,value:``}];let t=Object.entries(e).map(([e,t])=>({key:e,value:t==null?``:String(t)}));return t.length>0?t:[{key:``,value:``}]}function wt(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e.xopcConnector;return!!(t&&typeof t==`object`&&!Array.isArray(t)&&t.managed===!0)}function Tt(e){let t=e&&typeof e==`object`&&`mcp`in e?e.mcp:void 0,n=(t&&typeof t==`object`?t:{}).servers,r={};if(!n||typeof n!=`object`||Array.isArray(n))return r;for(let[e,t]of Object.entries(n))!t||typeof t!=`object`||Array.isArray(t)||wt(t)&&(r[e]=t);return r}function Et(e){let t=e.trim();if(t)return t.split(/\s+/).filter(Boolean)}function Dt(e){let t=e.trim();if(!t)return;let n=JSON.parse(t);if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`Expected a JSON object`);return n}function Ot(e){if(e.transport===`stdio`){let t={command:e.command.trim()},n=Et(e.argsText);return n?.length&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envJson.trim()&&(t.env=Dt(e.envJson)),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}let t={url:e.url.trim(),transport:e.transport},n=St(e.headers);return n&&(t.headers=n),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}function kt(e,t){let n=typeof t.url==`string`&&t.url.trim().length>0,r=typeof t.transport==`string`?t.transport.trim().toLowerCase():``,i=n?r===`sse`?`sse`:`streamable-http`:`stdio`,a=t.headers&&typeof t.headers==`object`&&!Array.isArray(t.headers)?t.headers:void 0;return{clientKey:e,id:e,transport:i,command:typeof t.command==`string`?t.command:``,argsText:Array.isArray(t.args)?t.args.map(String).join(` `):``,envJson:t.env&&typeof t.env==`object`?JSON.stringify(t.env,null,2):``,cwd:typeof t.cwd==`string`?t.cwd:typeof t.workingDirectory==`string`?t.workingDirectory:``,url:typeof t.url==`string`?t.url:``,headers:Ct(a),connectionTimeoutMs:typeof t.connectionTimeoutMs==`number`&&Number.isFinite(t.connectionTimeoutMs)?t.connectionTimeoutMs:void 0}}function At(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`stdio`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[{key:`Authorization`,value:``}],connectionTimeoutMs:void 0}}function jt(e){let t=e&&typeof e==`object`&&`mcp`in e?e.mcp:void 0,n=t&&typeof t==`object`?t:{},r=n.servers,i=r&&typeof r==`object`&&!Array.isArray(r)?Object.entries(r).flatMap(([e,t])=>!t||typeof t!=`object`||Array.isArray(t)||wt(t)?[]:[kt(e,t)]).sort((e,t)=>e.id.localeCompare(t.id)):[],a=typeof n.sessionIdleTtlMs==`number`?n.sessionIdleTtlMs:void 0;return{sessionIdleTtlMinutes:a==null?void 0:a===0?0:Math.round(a/6e4),servers:i}}function Mt(e){return Ot(e)}async function Nt(e,t={}){let n={};for(let r of e.servers){let e=r.id.trim();if(e){if(t[e])throw Error(`Server id "${e}" is reserved by an installed connector.`);n[e]=Ot(r)}}let r={servers:{...t,...n}};e.sessionIdleTtlMinutes!=null&&Number.isFinite(e.sessionIdleTtlMinutes)&&(r.sessionIdleTtlMs=e.sessionIdleTtlMinutes===0?0:Math.round(e.sessionIdleTtlMinutes*6e4)),await p(f(`/api/config`),{method:`PATCH`,body:JSON.stringify({mcp:r})}),I()}function Pt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n==`string`){let e=n.trim();e&&t.push({name:e});continue}if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.name!=`string`)continue;let r=e.name.trim();if(!r)continue;let i=typeof e.shortName==`string`&&e.shortName.trim()?e.shortName.trim():void 0,a=typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0;t.push({name:r,shortName:i,description:a})}return t}function Ft(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.uri!=`string`||typeof e.name!=`string`)continue;let r=e.uri.trim(),i=e.name.trim();!r||!i||t.push({uri:r,name:i,title:typeof e.title==`string`&&e.title.trim()?e.title.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,mimeType:typeof e.mimeType==`string`&&e.mimeType.trim()?e.mimeType.trim():void 0})}return t}function It(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.name!=`string`)continue;let r=e.name.trim();r&&t.push({name:r,title:typeof e.title==`string`&&e.title.trim()?e.title.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,argumentCount:typeof e.argumentCount==`number`?e.argumentCount:0})}return t}async function Lt(e,t){let n=await p(f(`/api/mcp/servers/${encodeURIComponent(e)}/test`),{method:`POST`,body:t?JSON.stringify({server:t}):void 0});if(!n.payload)throw Error(n.error??`MCP test failed`);let r=Pt(n.payload.tools),i=Ft(n.payload.resources),a=It(n.payload.prompts);return{serverId:n.payload.serverId??e,toolCount:typeof n.payload.toolCount==`number`?n.payload.toolCount:r.length,resourceCount:typeof n.payload.resourceCount==`number`?n.payload.resourceCount:i.length,promptCount:typeof n.payload.promptCount==`number`?n.payload.promptCount:a.length,tools:r,resources:i,prompts:a}}function Rt(e){return e.connectionTimeoutMs==null||!Number.isFinite(e.connectionTimeoutMs)?``:String(Math.round(e.connectionTimeoutMs/1e3))}function zt(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);if(!(!Number.isFinite(n)||n<1||n>600))return n*1e3}function Bt(e){if(e.transport===`stdio`){let t=e.command.trim();if(!t)return``;let n=e.argsText.trim();return n?`${t} ${n}`:t}return e.url.trim()}function $(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,n),e)}function Vt({row:e,t,cs:n,onEdit:r,onRemove:i}){let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(null),p=Bt(e),m=(0,Y.useCallback)(async()=>{o(!0),f(null);try{let t=await Lt(e.id.trim());u({toolCount:t.toolCount,resourceCount:t.resourceCount,promptCount:t.promptCount})}catch(e){f(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.id]),g=(0,Y.useCallback)(async()=>{c(!0),f(null);try{await i()}catch(e){f(e instanceof Error?e.message:String(e)),c(!1)}},[i]);return(0,Z.jsxs)(`div`,{className:`flex h-full min-h-[10.5rem] cursor-pointer flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`,onClick:r,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.id.trim()||t.cardUntitled}),(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:n.customBadge}),(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.transportLabels[e.transport]})]}),p?(0,Z.jsx)(`p`,{className:`mt-3 line-clamp-2 break-all font-mono text-xs leading-5 text-fg-subtle`,title:p,children:p}):null,d?(0,Z.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:d}):null,l?(0,Z.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:$(n.customCapabilitySummary,{tools:String(l.toolCount),resources:String(l.resourceCount),prompts:String(l.promptCount)})}):null]}),(0,Z.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.connectorDetails}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsxs)(q,{variant:`secondary`,disabled:a,onClick:()=>void m(),children:[a?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(_,{className:`size-4`}),t.testConnection]}),(0,Z.jsxs)(q,{variant:`ghost`,disabled:s,onClick:()=>void g(),children:[s?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(h,{className:`size-4`}),t.removeServer]})]})]})]})}function Ht(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Ut(e,t,n){let r=t.trim().toLowerCase();if(!r)return!0;let i=e.shortName||Ht(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
2
- `).toLowerCase().includes(r)}function Wt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Gt(e){let t=(0,X.c)(29),{tools:n,stripPrefix:r,searchPlaceholder:i,searchEmptyLabel:a}=e,[o,c]=(0,Y.useState)(``),l;if(t[0]!==o||t[1]!==r||t[2]!==n){let e;t[4]!==o||t[5]!==r?(e=e=>Ut(e,o,r),t[4]=o,t[5]=r,t[6]=e):e=t[6],l=n.filter(e),t[0]=o,t[1]=r,t[2]=n,t[3]=l}else l=t[3];let u=l,d;t[7]===o?d=t[8]:(d=o.trim(),t[7]=o,t[8]=d);let f=d.length>0,p;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(_e,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=p):p=t[9];let m,h;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=s(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg`,`placeholder:text-fg-subtle`,g),h=e=>c(e.target.value),t[10]=m,t[11]=h):(m=t[10],h=t[11]);let _;t[12]!==o||t[13]!==i?(_=(0,Z.jsxs)(`div`,{className:`relative`,children:[p,(0,Z.jsx)(`input`,{type:`search`,value:o,placeholder:i,"aria-label":i,className:m,onChange:h})]}),t[12]=o,t[13]=i,t[14]=_):_=t[14];let v;t[15]!==u.length||t[16]!==f||t[17]!==n.length?(v=f?(0,Z.jsxs)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:[u.length,` / `,n.length]}):null,t[15]=u.length,t[16]=f,t[17]=n.length,t[18]=v):v=t[18];let y;t[19]!==_||t[20]!==v?(y=(0,Z.jsxs)(`div`,{className:`border-b border-edge px-5 py-3`,children:[_,v]}),t[19]=_,t[20]=v,t[21]=y):y=t[21];let b;t[22]!==u||t[23]!==a||t[24]!==r?(b=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:u.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a}):(0,Z.jsx)(`ul`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>{let n=e.shortName||Wt(e.name,r)||e.name||`?`,i=e.name||`tool-${t}`;return(0,Z.jsxs)(`li`,{className:`min-w-0 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[(0,Z.jsx)(`div`,{className:`truncate font-mono text-sm font-medium text-fg`,title:e.name===n?n:e.name,children:n}),e.description?(0,Z.jsx)(`p`,{className:`mt-1 truncate text-xs leading-relaxed text-fg-muted`,title:e.description,children:e.description}):null]},i)})})}),t[22]=u,t[23]=a,t[24]=r,t[25]=b):b=t[25];let x;return t[26]!==y||t[27]!==b?(x=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[y,b]}),t[26]=y,t[27]=b,t[28]=x):x=t[28],x}function Kt(e){let t=(0,X.c)(38),{open:n,onOpenChange:r,serverId:i,title:a,subtitle:o,searchPlaceholder:c,searchEmptyLabel:l,emptyLabel:u,closeLabel:d,tools:f,stripPrefix:p}=e,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(x,{className:s(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,de)}),t[0]=h):h=t[0];let g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=s(`fixed left-1/2 top-1/2 flex max-h-[min(88vh,40rem)] w-[min(100%-2rem,min(92vw,36rem))] -translate-x-1/2 -translate-y-1/2 flex-col`,H,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`),t[1]=g):g=t[1];let _;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Z.jsx)(O,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[2]=_):_=t[2];let y;t[3]===a?y=t[4]:(y=(0,Z.jsxs)(F,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[_,a]}),t[3]=a,t[4]=y);let b;t[5]!==i||t[6]!==o||t[7]!==f.length?(b=o.replace(`{{serverId}}`,i).replace(`{{count}}`,String(f.length)),t[5]=i,t[6]=o,t[7]=f.length,t[8]=b):b=t[8];let S;t[9]===b?S=t[10]:(S=(0,Z.jsx)(P,{className:`mt-1 text-sm text-fg-muted`,children:b}),t[9]=b,t[10]=S);let C;t[11]!==y||t[12]!==S?(C=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[y,S]}),t[11]=y,t[12]=S,t[13]=C):C=t[13];let w;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(v,{className:`size-4`,"aria-hidden":!0}),t[14]=w):w=t[14];let T;t[15]===d?T=t[16]:(T=(0,Z.jsx)(J,{asChild:!0,children:(0,Z.jsx)(q,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":d,children:w})}),t[15]=d,t[16]=T);let E;t[17]!==C||t[18]!==T?(E=(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[C,T]}),t[17]=C,t[18]=T,t[19]=E):E=t[19];let D;t[20]!==u||t[21]!==n||t[22]!==l||t[23]!==c||t[24]!==i||t[25]!==p||t[26]!==f?(D=f.length>0?(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,Z.jsx)(Gt,{tools:f,stripPrefix:p,searchPlaceholder:c,searchEmptyLabel:l},`${i}-${n?`open`:`closed`}`)}):(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u})}),t[20]=u,t[21]=n,t[22]=l,t[23]=c,t[24]=i,t[25]=p,t[26]=f,t[27]=D):D=t[27];let k;t[28]===d?k=t[29]:(k=(0,Z.jsx)(`div`,{className:`flex justify-end border-t border-edge px-5 py-3`,children:(0,Z.jsx)(J,{asChild:!0,children:(0,Z.jsx)(q,{type:`button`,variant:`secondary`,children:d})})}),t[28]=d,t[29]=k);let A;t[30]!==E||t[31]!==D||t[32]!==k?(A=(0,Z.jsxs)(N,{children:[h,(0,Z.jsxs)(m,{className:g,children:[E,D,k]})]}),t[30]=E,t[31]=D,t[32]=k,t[33]=A):A=t[33];let M;return t[34]!==r||t[35]!==n||t[36]!==A?(M=(0,Z.jsx)(j,{open:n,onOpenChange:r,children:A}),t[34]=r,t[35]=n,t[36]=A,t[37]=M):M=t[37],M}var qt=s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,g);function Jt(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function Yt(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function Xt(e,t){return e.errorCode===`missing_credential`?t.composioHealthMissingCredential:e.errorCode===`unauthorized`?t.composioHealthUnauthorized:e.errorCode===`forbidden`?t.composioHealthForbidden:e.errorCode===`network`?t.composioHealthNetwork:e.errorCode===`timeout`?t.composioHealthTimeout:t.composioHealthDegraded}function Zt({instance:e,t,onChanged:n}){let r=Jt(e),[i,o]=(0,Y.useState)([]),[c,l]=(0,Y.useState)([]),[u,d]=(0,Y.useState)([]),[f,p]=(0,Y.useState)([]),[m,g]=(0,Y.useState)(null),[_,y]=(0,Y.useState)([]),[x,S]=(0,Y.useState)(``),[C,T]=(0,Y.useState)(`{}`),[E,D]=(0,Y.useState)(null),[O,k]=(0,Y.useState)(!1),[A,j]=(0,Y.useState)(!0),[M,N]=(0,Y.useState)(`15`),[P,F]=(0,Y.useState)(null),[I,L]=(0,Y.useState)(`read`),[z,B]=(0,Y.useState)(!1),[V,H]=(0,Y.useState)(null),U=(0,Y.useCallback)(async()=>{if(!(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)){B(!0),H(null);try{let[t,n,i,a,s,c,u,f]=await Promise.all([We().catch(()=>[]),$e(r).catch(()=>[]),et(20).catch(()=>[]),Ye(r).catch(()=>`read`),ot().catch(()=>[]),Ze(r).catch(()=>null),Ke(r).catch(()=>null),nt(e.connectorId).catch(()=>null)]);o(t.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),l(n),d(i.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())),L(a),p(s.filter(t=>t.connectorId===e.connectorId)),g(c?.policy??null),y(c?.agents??[]),S(f?.actionId??n.find(e=>e.scope===`read`&&e.curated)?.slug??``),T(f?JSON.stringify(f.arguments):`{}`),k(f?.enabled??!1),j(f?.triggerSync??!0),N(String(f?.intervalMinutes??15)),F(u)}catch(e){H(e instanceof Error?e.message:String(e))}finally{B(!1)}}},[e.connectorId,e.materialized,r]);(0,Y.useEffect)(()=>{U()},[U]);let te=(0,Y.useCallback)(async()=>{if(r){B(!0),H(null);try{let t=await Ie(e.connectorId);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);window.open(t.authorizationUrl,`_blank`,`noopener,noreferrer`)}catch(e){H(e instanceof Error?e.message:String(e))}finally{B(!1)}}},[e.connectorId,r]),ne=(0,Y.useCallback)(async e=>{if(r){L(e);try{await Xe(r,e),await U()}catch(e){H(e instanceof Error?e.message:String(e))}}},[U,r]),re=(0,Y.useCallback)(async(e,t)=>{B(!0),H(null);try{await st(e,t),await U()}catch(e){H(e instanceof Error?e.message:String(e))}finally{B(!1)}},[U]),ie=(0,Y.useCallback)(async e=>{if(r){H(null);try{g(await Qe(r,e))}catch(e){H(e instanceof Error?e.message:String(e))}}},[e.connectorId,r]),ae=(0,Y.useCallback)(e=>{m&&ie({allowedAgentIds:m.allowedAgentIds.includes(e)?m.allowedAgentIds.filter(t=>t!==e):[...m.allowedAgentIds,e]})},[ie,m]),oe=(0,Y.useCallback)(async e=>{B(!0),H(null);try{await e(),await U()}catch(e){H(e instanceof Error?e.message:String(e))}finally{B(!1)}},[U]),se=(0,Y.useCallback)(async()=>{if(!(!r||!x)){B(!0),H(null),D(null);try{let r=JSON.parse(C);if(!r||typeof r!=`object`||Array.isArray(r))throw Error(t.composioMemoryArgumentsObject);let a=m?.allowedAgentIds[0]??_[0]?.id;if(!a)throw Error(t.composioMemoryAgentMissing);D((await tt({connectorId:e.connectorId,actionId:x,agentId:a,connectionId:i.find(e=>e.isDefault)?.id,arguments:r})).recordId),await n?.()}catch(e){H(e instanceof Error?e.message:String(e))}finally{B(!1)}}},[_,i,e.connectorId,x,C,n,m,t,r]),ce=(0,Y.useCallback)(async()=>{if(!(!r||!x)){B(!0),H(null);try{let r=JSON.parse(C);if(!r||typeof r!=`object`||Array.isArray(r))throw Error(t.composioMemoryArgumentsObject);let a=m?.allowedAgentIds[0]??_[0]?.id;if(!a)throw Error(t.composioMemoryAgentMissing);let o=await rt(e.connectorId,{enabled:O,actionId:x,arguments:r,agentId:a,connectionId:i.find(e=>e.isDefault)?.id,intervalMinutes:Number(M),triggerSync:A});N(String(o.intervalMinutes)),await n?.()}catch(e){H(e instanceof Error?e.message:String(e))}finally{B(!1)}}},[_,i,e.connectorId,x,C,O,M,A,n,m,t,r]);return r?e.materialized.type===`composio`&&e.materialized.role===`credential`?(0,Z.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:t.composioApiKeyStored}):(0,Z.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`font-medium text-fg`,children:$(t.composioToolkitTitle,{toolkit:r})}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioScopeHint})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsxs)(q,{variant:`secondary`,disabled:z,onClick:()=>void te(),children:[z?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(ue,{className:`size-4`}),t.connectOAuth]}),(0,Z.jsx)(q,{variant:`ghost`,disabled:z,onClick:()=>void U(),children:t.refresh})]})]}),V?(0,Z.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:V}):null,P?(0,Z.jsxs)(`div`,{className:s(`mt-3 flex flex-wrap items-center justify-between gap-2 rounded-lg border px-3 py-2 text-xs`,P.status===`connected`?`border-emerald-500/30 bg-emerald-500/5 text-emerald-700`:`border-amber-500/30 bg-amber-500/5 text-amber-700`),children:[(0,Z.jsx)(`span`,{children:P.status===`connected`?$(t.composioHealthConnected,{count:String(P.activeConnections)}):P.status===`reauthorization_required`?t.composioHealthReconnect:P.status===`degraded`?Xt(P,t):t.composioHealthDisconnected}),P.recovery===`none`?null:(0,Z.jsx)(q,{variant:`ghost`,disabled:z,onClick:()=>void(P.recovery===`retry`?U():te()),children:P.recovery===`retry`?t.composioRetry:t.connectOAuth}),P.status===`degraded`&&P.message?(0,Z.jsx)(`p`,{className:`basis-full break-words text-[11px] opacity-80`,children:P.message}):null]}):null,m?(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-3 rounded-lg border border-edge bg-surface-panel p-3 md:grid-cols-3`,children:[(0,Z.jsxs)(`label`,{className:`text-xs font-medium text-fg-subtle`,children:[t.composioAccessTitle,(0,Z.jsxs)(ge,{className:s(qt,`mt-1 h-9 py-1`),value:I,onChange:e=>void ne(e.currentTarget.value),children:[(0,Z.jsx)(W,{value:`read`,children:t.composioAccessReadOnly}),(0,Z.jsx)(W,{value:`write`,children:t.composioAccessReadWrite}),I===`admin`?(0,Z.jsx)(W,{value:`admin`,children:t.composioAccessAdminCurrent}):null]}),(0,Z.jsx)(`span`,{className:`mt-1 block font-normal leading-4 text-fg-muted`,children:I===`read`?t.composioAccessReadHint:I===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,Z.jsxs)(`label`,{className:`text-xs font-medium text-fg-subtle`,children:[t.composioConfirmationPolicy,(0,Z.jsxs)(ge,{className:s(qt,`mt-1 h-9 py-1`),value:m.confirmationPolicy,onChange:e=>void ie({confirmationPolicy:e.currentTarget.value}),children:[(0,Z.jsx)(W,{value:`writes`,children:t.composioConfirmWrites}),(0,Z.jsx)(W,{value:`always`,children:t.composioConfirmAlways}),m.confirmationPolicy===`never`?(0,Z.jsx)(W,{value:`never`,children:t.composioConfirmNever}):null]})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:t.composioAllowedAgents}),(0,Z.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:m.allowedAgentIds.length?t.composioAllowedAgentsSelected:t.composioAllowedAgentsAll}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:_.map(e=>(0,Z.jsx)(`button`,{type:`button`,className:s(`rounded-full border px-2.5 py-1 text-xs transition-colors`,m.allowedAgentIds.includes(e.id)?`border-accent bg-accent/10 text-accent`:`border-edge text-fg-muted hover:text-fg`),onClick:()=>ae(e.id),children:e.name},e.id))})]})]}):null,[`gmail`,`googlecalendar`,`googledrive`,`googledocs`,`googlesheets`,`notion`,`slack`,`github`,`linear`,`jira`,`outlook`,`microsoft_teams`,`one_drive`,`excel`].includes(r)&&c.some(e=>e.scope===`read`&&e.curated)?(0,Z.jsxs)(`div`,{className:`mt-4 rounded-lg border border-edge bg-surface-panel p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(b,{className:`mt-0.5 size-4 text-accent`}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioMemorySync}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioMemorySyncHint})]})]}),(0,Z.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3`,children:(0,Z.jsxs)(q,{disabled:z||!x,onClick:()=>void se(),children:[z?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(b,{className:`size-4`}),t.composioSyncNow]})}),E?(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-emerald-600`,children:t.composioMemorySyncedSimple}):null,(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-end gap-3 border-t border-edge-subtle pt-3`,children:[(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:O,onChange:e=>k(e.currentTarget.checked)}),t.composioMemoryAutoSync]}),(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:A,onChange:e=>j(e.currentTarget.checked)}),t.composioMemoryTriggerSync]}),(0,Z.jsxs)(q,{variant:`secondary`,disabled:z||!x,onClick:()=>void ce(),children:[z?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(b,{className:`size-4`}),t.composioMemorySaveSchedule]})]})]}):null,f.length?(0,Z.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioPendingApprovals}),f.map(e=>(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-amber-500/30 bg-amber-500/5 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`truncate font-mono text-xs font-medium text-fg`,children:e.actionId}),(0,Z.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs text-fg-subtle`,children:JSON.stringify(e.argumentsPreview)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:$(t.composioApprovalExpires,{time:new Date(e.expiresAt).toLocaleTimeString()})})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Z.jsxs)(q,{variant:`secondary`,disabled:z,onClick:()=>void re(e.id,`denied`),children:[(0,Z.jsx)(v,{className:`size-4`}),t.composioDeny]}),(0,Z.jsxs)(q,{disabled:z,onClick:()=>void re(e.id,`approved`),children:[(0,Z.jsx)(a,{className:`size-4`}),t.approve]})]})]},e.id))]}):null,(0,Z.jsx)(`div`,{className:`mt-4`,children:(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioConnections}),i.length?i.map(e=>(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.accountEmail??e.username??e.workspace??e.providerConnectionId}),(0,Z.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[e.status,e.isDefault?` · ${t.composioDefaultAccount}`:``]})]}),(0,Z.jsx)(`input`,{className:s(qt,`h-8 py-1 text-xs`),defaultValue:e.alias??``,placeholder:t.composioAccountAlias,onBlur:t=>{t.currentTarget.value!==(e.alias??``)&&oe(()=>Ge(e.id,{alias:t.currentTarget.value}))}}),(0,Z.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Z.jsx)(q,{variant:`ghost`,className:`size-8 p-0`,title:t.composioMakeDefault,disabled:z||e.isDefault,onClick:()=>void oe(async()=>{await Ge(e.id,{isDefault:!0}),r&&await Qe(r,{selectedConnectionIds:[e.id]})}),children:(0,Z.jsx)(R,{className:s(`size-4`,e.isDefault&&`fill-current`)})}),(0,Z.jsx)(q,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:z,onClick:()=>void oe(()=>qe(e.id)),children:(0,Z.jsx)(ee,{className:`size-4`})}),(0,Z.jsx)(q,{variant:`ghost`,className:`size-8 p-0`,title:t.composioRevoke,disabled:z,onClick:()=>{window.confirm(t.composioRevokeConfirm)&&oe(()=>Je(e.id))},children:(0,Z.jsx)(h,{className:`size-4 text-red-500`})})]})]},e.id)):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioConnectionsEmpty})]})}),(0,Z.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge bg-surface-panel p-3`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted`,children:t.composioAdvancedSettings}),(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-4 lg:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`label`,{className:`block text-xs text-fg-subtle`,children:[t.composioAdvancedScope,(0,Z.jsxs)(ge,{className:s(qt,`mt-1 h-9 py-1`),value:I,onChange:e=>void ne(e.currentTarget.value),children:[(0,Z.jsx)(W,{value:`read`,children:t.composioScopeRead}),(0,Z.jsx)(W,{value:`write`,children:t.composioScopeWrite}),(0,Z.jsx)(W,{value:`admin`,children:t.composioScopeAdmin})]})]}),(0,Z.jsxs)(`label`,{className:`block text-xs text-fg-subtle`,children:[t.composioMemoryReadAction,(0,Z.jsx)(ge,{className:s(qt,`mt-1 h-9 py-1`),value:x,onChange:e=>S(e.currentTarget.value),children:c.filter(e=>e.scope===`read`&&e.curated).map(e=>(0,Z.jsx)(W,{value:e.slug,children:e.name??e.slug},e.slug))})]}),(0,Z.jsxs)(`label`,{className:`block text-xs text-fg-subtle`,children:[t.composioMemoryArguments,(0,Z.jsx)(`input`,{className:s(qt,`mt-1 h-9 py-1 font-mono text-xs`),value:C,onChange:e=>T(e.currentTarget.value)})]}),(0,Z.jsxs)(`label`,{className:`block text-xs text-fg-subtle`,children:[t.composioMemoryInterval,(0,Z.jsx)(`input`,{type:`number`,min:5,max:1440,className:s(qt,`mt-1 h-9 w-28 py-1`),value:M,onChange:e=>N(e.currentTarget.value)})]})]}),(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),c.length?c.slice(0,8).map(e=>(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-2`,children:[(0,Z.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,Z.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[Yt(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),u.length?u.slice(0,5).map(e=>(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-2`,children:[(0,Z.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})]})]})]})]})]}):null}var Qt=s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,g);function $t(e,t){return e?t.healthStatusLabels[e]??e:t.healthNotTested}function en(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 tn(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 nn(e){let t=(0,X.c)(12),{title:n,description:r,meta:i}=e,a;t[0]===r?a=t[1]:(a=r?(0,Z.jsx)(C,{delayDuration:300,skipDelayDuration:100,children:(0,Z.jsxs)(T,{children:[(0,Z.jsx)(A,{asChild:!0,children:(0,Z.jsx)(`p`,{tabIndex:0,title:r,className:s(`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,Z.jsx)(y,{children:(0,Z.jsx)(k,{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,Z.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:r})})})]})}):null,t[0]=r,t[1]=a);let o=a,c;t[2]===n?c=t[3]:(c=(0,Z.jsx)(`p`,{className:`min-w-0 break-all font-mono text-xs font-medium leading-5 text-fg`,children:n}),t[2]=n,t[3]=c);let l;t[4]===i?l=t[5]:(l=i?(0,Z.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] leading-4 text-fg-subtle`,children:i}):null,t[4]=i,t[5]=l);let u;t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;return t[9]!==o||t[10]!==u?(d=(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[u,o]}),t[9]=o,t[10]=u,t[11]=d):d=t[11],d}function rn({instance:e,definition:t,onClose:n,onChanged:r,t:i,mcp:a}){let[o,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(!1),[p,g]=(0,Y.useState)(!1),[y,S]=(0,Y.useState)(null),[C,T]=(0,Y.useState)(null),[E,D]=(0,Y.useState)(e.materialized.type===`mcp`?`health`:`permissions`),[k,A]=(0,Y.useState)(!1),[M,I]=(0,Y.useState)(()=>en(t,e)),[L,R]=(0,Y.useState)(null),z=t?.setup.config??[],B=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&z.length>0&&(t?.setup.secrets??[]).length===0,ee=C?C.toolCount:e.usage.lastToolCount,V=(0,Y.useMemo)(()=>{let t=e.materialized.type===`mcp`?[[`health`,ce,i.detailHealth],[`tools`,O,`${i.detailTools} ${C?C.toolCount:e.usage.lastToolCount??``}`],[`resources`,b,`${i.detailResources} ${C?C.resourceCount:e.usage.lastResourceCount??``}`],[`prompts`,le,`${i.detailPrompts} ${C?C.promptCount:e.usage.lastPromptCount??``}`],[`permissions`,ue,i.detailPermissions]]:[[`permissions`,ue,i.detailPermissions]];return B?[...t,[`config`,b,i.connectorConfigLabel]]:t},[C,e.materialized.type,e.usage.lastPromptCount,e.usage.lastResourceCount,e.usage.lastToolCount,B,i]),H=(0,Y.useCallback)(async()=>{c(!0),R(null);try{let t=await Ue(e.instanceId);T(t),t.toolCount>0&&D(`tools`),r()}catch(e){R(e instanceof Error?e.message:String(e))}finally{c(!1)}},[e.instanceId,r]),U=(0,Y.useCallback)(async()=>{u(!0),R(null);try{await He(e.instanceId),await r(),n()}catch(e){R(e instanceof Error?e.message:String(e)),u(!1)}},[e.instanceId,r,n]),te=(0,Y.useCallback)(async()=>{if(!(!t||!B)){f(!0),R(null);try{let n={};for(let e of t.setup.config??[]){let t=tn(e.type,M[e.key]??``);t!==void 0&&(n[e.key]=t)}await Ve(e.instanceId,{config:n}),await r(),D(`health`)}catch(e){R(e instanceof Error?e.message:String(e))}finally{f(!1)}}},[M,t,e.instanceId,r,B]),ne=(0,Y.useCallback)(async()=>{g(!0),S(null),R(null);try{S((await it(e.connectorId)).recordIds.length),await r()}catch(e){R(e instanceof Error?e.message:String(e))}finally{g(!1)}},[e.connectorId,r]);return(0,Z.jsxs)(j,{open:!0,onOpenChange:e=>{e||n()},children:[(0,Z.jsxs)(N,{children:[(0,Z.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Z.jsxs)(m,{className:s(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,54rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float outline-none dark:border-edge`),children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Z.jsx)(xe,{connector:t,size:`lg`}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(F,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,Z.jsx)(P,{className:`mt-1 text-sm text-fg-muted`,children:t?.description??(e.materialized.type===`mcp`?$(i.mcpServerRuntime,{serverId:e.materialized.serverId}):$(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,Z.jsx)(J,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:s(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,G.focusRingPanel),"aria-label":i.modalClose,children:[(0,Z.jsx)(v,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[L?(0,Z.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:L}):null,(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:V.map(([e,t,n])=>(0,Z.jsxs)(`button`,{type:`button`,className:s(`inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs`,E===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:text-fg`),onClick:()=>D(e),children:[(0,Z.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),n]},e))}),(0,Z.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[E===`health`?(0,Z.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,Z.jsxs)(`p`,{children:[i.statusLabel,` `,(0,Z.jsx)(`span`,{className:C?.ok?`font-medium text-emerald-700 dark:text-emerald-300`:`font-medium text-fg`,children:$t(C?.status??e.usage.lastHealthStatus,i)})]}),(0,Z.jsxs)(`p`,{children:[i.lastCheckLabel,` `,e.usage.lastHealthCheckAt?new Date(e.usage.lastHealthCheckAt).toLocaleString():i.never]}),C?.action?(0,Z.jsx)(`p`,{children:C.action}):null]}):null,E===`tools`?C?.tools.length?(0,Z.jsxs)(`div`,{className:`grid gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:$(i.toolsAvailable,{count:String(C.tools.length)})}),(0,Z.jsx)(q,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>A(!0),children:a.viewAllTools})]}),(0,Z.jsx)(`div`,{className:`grid gap-2`,children:C.tools.slice(0,8).map(e=>(0,Z.jsx)(nn,{title:e.shortName??e.name,description:e.description},e.name))})]}):(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:ee?$(i.toolsLastCheckSummary,{count:String(ee)}):i.toolsRunTestHint}),(0,Z.jsxs)(q,{type:`button`,variant:`secondary`,disabled:o,onClick:()=>void H(),children:[o?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(_,{className:`size-4`}),i.test]})]}):null,E===`resources`?C?.resources.length?(0,Z.jsx)(`div`,{className:`grid gap-2`,children:C.resources.slice(0,8).map(e=>(0,Z.jsx)(nn,{title:e.title??e.name,description:e.uri,meta:e.mimeType},e.uri))}):(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:i.resourcesRunTestHint}):null,E===`prompts`?C?.prompts.length?(0,Z.jsx)(`div`,{className:`grid gap-2`,children:C.prompts.slice(0,8).map(e=>(0,Z.jsx)(nn,{title:e.title??e.name,description:e.description,meta:e.argumentCount?$(i.promptArgumentCount,{count:String(e.argumentCount)}):void 0},e.name))}):(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:i.promptsRunTestHint}):null,E===`permissions`?(0,Z.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,Z.jsx)(`p`,{children:$(i.secretsConfigured,{count:String(Object.values(e.secretStatus).filter(Boolean).length)})}),(0,Z.jsx)(`p`,{children:e.materialized.type===`mcp`?$(i.runtimeServerLabel,{runtime:e.materialized.type.toUpperCase(),serverId:e.materialized.serverId}):$(i.runtimeLabel,{runtime:e.materialized.type.toUpperCase()})}),(0,Z.jsx)(`p`,{children:e.materialized.type===`mcp`?i.mcpPolicyHint:i.connectorPolicyHint})]}):null,E===`config`&&B?(0,Z.jsx)(`div`,{className:`grid gap-3`,children:z.map(e=>(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,Z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,Z.jsx)(`input`,{className:Qt,value:M[e.key]??``,placeholder:e.placeholder,onChange:t=>I(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}),e.materialized.type===`composio`?(0,Z.jsx)(Zt,{instance:e,t:i,onChanged:r}):null,e.materialized.type===`memorySource`?(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-between gap-3 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`font-medium text-fg`,children:i.memorySourceSync}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t?.description}),y===null?null:(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:$(i.memorySourceSynced,{count:String(y)})})]}),(0,Z.jsxs)(q,{disabled:p,onClick:()=>void ne(),children:[p?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(b,{className:`size-4`}),i.composioSyncNow]})]}):null]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,Z.jsx)(q,{variant:`secondary`,onClick:n,children:i.modalClose}),E===`config`&&B?(0,Z.jsxs)(q,{variant:`primary`,disabled:d,onClick:()=>void te(),children:[d?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(pe,{className:`size-4`}),i.modalSave]}):null,e.materialized.type===`mcp`?(0,Z.jsxs)(q,{variant:`secondary`,disabled:o,onClick:()=>void H(),children:[o?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(_,{className:`size-4`}),i.test]}):null,(0,Z.jsxs)(q,{variant:`ghost`,disabled:l,onClick:()=>void U(),children:[l?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(h,{className:`size-4`}),i.remove]})]})]})]}),e.materialized.type===`mcp`?(0,Z.jsx)(Kt,{open:k,onOpenChange:A,serverId:e.materialized.serverId,title:$(i.installedToolsDialogTitle,{name:e.displayName}),subtitle:i.installedToolsDialogSubtitle,searchPlaceholder:a.toolsDialogSearchPlaceholder,searchEmptyLabel:a.toolsDialogSearchEmpty,emptyLabel:i.toolsRunTestHint,closeLabel:a.toolsDialogClose,tools:C?.tools??[],stripPrefix:`${e.materialized.serverId}__`}):null]})}var an=[`understand`,`act`,`reach`];function on(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 sn(e){return on(e)[0]??`act`}function cn(e,t){let n=t?sn(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 ln({instance:e,definition:t,highlighted:n=!1,onOpenDetails:r,onChanged:i,t:a}){let[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(null),m=(0,Y.useCallback)(async()=>{l(!0),p(null);try{await Ue(e.instanceId),await i()}catch(e){p(e instanceof Error?e.message:String(e))}finally{l(!1)}},[e.instanceId,i]),g=(0,Y.useCallback)(async()=>{d(!0),p(null);try{await He(e.instanceId),await i()}catch(e){p(e instanceof Error?e.message:String(e)),d(!1)}},[e.instanceId,i]),v=e.usage.lastHealthStatus?a.healthStatusLabels[e.usage.lastHealthStatus]??e.usage.lastHealthStatus:a.healthNotTested,y=e.usage.lastToolCount??0,b=!!(t?.setup.config?.length&&!t.setup.secrets?.length&&e.materialized.type===`mcp`),x=cn(e,t).state,S=x===`ready`?{label:a.connectionReady,Icon:fe,className:`border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`}:x===`needs_setup`?{label:a.connectionNeedsSetup,Icon:o,className:`border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300`}:{label:a.connectionChecking,Icon:L,className:`border-edge bg-surface-base text-fg-muted`};return(0,Z.jsxs)(`div`,{className:s(`flex h-full min-h-[10.5rem] cursor-pointer flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`,n&&`ring-2 ring-accent/45 ring-offset-2 ring-offset-surface-panel`),onClick:()=>r(e),children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3`,children:[(0,Z.jsx)(xe,{connector:t}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.displayName}),(0,Z.jsxs)(`span`,{className:s(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium`,S.className),children:[(0,Z.jsx)(S.Icon,{className:`size-3`,"aria-hidden":!0}),S.label]}),b?(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:a.connectorConfigLabel}):null]}),t?.description?(0,Z.jsx)(`p`,{className:`mt-3 line-clamp-2 text-sm leading-5 text-fg-muted`,children:t.description}):null,(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs text-fg-muted`,children:[(0,Z.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:[a.statusLabel,` `,v]}),(0,Z.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:$(a.toolsAvailable,{count:String(y)})})]}),f?(0,Z.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:f}):null]})]}),(0,Z.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:a.connectorDetails}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[x===`needs_setup`?(0,Z.jsxs)(q,{variant:`primary`,onClick:()=>r(e),children:[(0,Z.jsx)(o,{className:`size-4`}),a.connectionResolveAction]}):null,e.materialized.type===`mcp`?(0,Z.jsxs)(q,{variant:`secondary`,disabled:c,onClick:()=>void m(),children:[c?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(_,{className:`size-4`}),a.test]}):null,(0,Z.jsxs)(q,{variant:`ghost`,disabled:u,onClick:()=>void g(),children:[u?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(h,{className:`size-4`}),a.remove]})]})]})]})}var un=s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,g),dn=s(un,`min-h-28 font-mono`);function fn(e,t){return e?t.healthStatusLabels[e]??e:t.healthStatusPending}function pn(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 mn(e){let t=(0,X.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,Z.jsx)(`div`,{className:`border-b border-edge px-3 py-2 text-xs font-semibold text-fg`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,12).map(hn),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>12?(0,Z.jsxs)(`div`,{className:`px-3 py-2 text-xs text-fg-subtle`,children:[`+`,r.length-12]}):null,t[4]=r.length,t[5]=o);let s;t[6]!==a||t[7]!==o?(s=(0,Z.jsxs)(`div`,{className:`max-h-40 overflow-y-auto`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==i||t[10]!==s?(c=(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel`,children:[i,s]}),t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function hn(e){return(0,Z.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,Z.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,Z.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function gn({draft:e,onChange:t,onClose:n,onInstalled:r,t:i}){let{connector:a}=e,o=a.runtime.type===`composio`&&a.runtime.role===`toolkit`,c=a.runtime.type===`composio`&&a.runtime.role===`toolkit`?a.runtime.toolkit:null,[l,u]=(0,Y.useState)(!o),[d,f]=(0,Y.useState)(o),[p,h]=(0,Y.useState)(``),[g,_]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{if(!o)return;let e=!1;return Le().then(({configured:t})=>{e||u(t)}).catch(t=>{e||_(t instanceof Error?t.message:String(t))}).finally(()=>{e||f(!1)}),()=>{e=!0}},[a.id,o]);let y=e.result?`complete`:e.installing?`health`:`configure`,b=[{id:`configure`,label:i.connectStepConfigure},{id:`health`,label:i.connectStepVerify},{id:`complete`,label:i.connectStepReady}],C=(0,Y.useCallback)(async()=>{let n=o?window.open(``,`_blank`):null;n&&(n.opener=null),_(null),t({...e,installing:!0,error:null,result:null,health:null});try{o&&!l&&(await Re(p),u(!0));let i={};for(let t of a.setup.config??[]){let n=pn(t.type,e.config[t.key]??``);n!==void 0&&(i[t.key]=n)}let s=e.store?await Pe(e.store.packageName,{secrets:e.secrets,config:i},e.store.version):await ze(a.id,{secrets:e.secrets,config:i,definition:a.source===`registry`?a:void 0}),d=null;try{if(o)if((c?await Ke(c).catch(()=>null):null)?.status===`connected`)n?.close();else{let e=await Ie(a.id);if(!e.authorizationUrl)throw Error(`The connection service did not return an authorization URL.`);n?n.location.href=e.authorizationUrl:window.open(e.authorizationUrl,`_blank`,`noopener,noreferrer`)}}catch(i){n?.close(),t({...e,installing:!1,result:s,health:null,error:i instanceof Error?i.message:String(i)}),await r(s);return}if(!o)try{d=await Ue(s.instanceId)}catch{d=null}t({...e,installing:!1,result:s,health:d}),await r(s)}catch(r){n?.close(),t({...e,installing:!1,error:r instanceof Error?r.message:String(r)})}},[p,l,c,a,e,o,t,r]);return(0,Z.jsx)(j,{open:!0,onOpenChange:e=>{e||n()},children:(0,Z.jsxs)(N,{children:[(0,Z.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Z.jsxs)(m,{className:s(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex max-h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Z.jsx)(xe,{connector:a,size:`lg`}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(F,{className:`text-base font-semibold text-fg`,children:$(i.connectDialogTitle,{name:a.displayName})}),(0,Z.jsx)(P,{className:`mt-1 line-clamp-3 text-sm text-fg-muted`,children:a.description})]})]}),(0,Z.jsx)(J,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:s(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,G.focusRingPanel),"aria-label":i.modalClose,children:[(0,Z.jsx)(v,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 overflow-y-auto px-6 py-5`,children:[(0,Z.jsx)(`div`,{className:`mb-5 grid grid-cols-3 gap-2`,"aria-label":i.connectProgressAria,children:b.map((e,t)=>{let n=b.findIndex(e=>e.id===y);return(0,Z.jsxs)(`div`,{className:s(`rounded-xl border px-3 py-2 text-xs font-medium`,t===n?`border-accent bg-accent-soft text-accent-fg`:t<n?`border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-900/40 dark:bg-emerald-950/40 dark:text-emerald-200`:`border-edge bg-surface-base text-fg-muted`),children:[(0,Z.jsxs)(`span`,{className:`mr-1 tabular-nums`,children:[t+1,`.`]}),e.label]},e.id)})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[o&&!l?(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-accent/25 bg-accent-soft/50 p-4`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.composioSetupTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:i.composioSetupHint}),(0,Z.jsxs)(`ol`,{className:`mt-3 list-inside list-decimal space-y-1 text-xs text-fg-muted`,children:[(0,Z.jsx)(`li`,{children:i.composioSetupStepProject}),(0,Z.jsx)(`li`,{children:i.composioSetupStepKey}),(0,Z.jsx)(`li`,{children:i.composioSetupStepPaste})]}),(0,Z.jsxs)(`a`,{className:`mt-3 inline-flex items-center gap-1 text-xs font-medium text-accent-fg hover:underline`,href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,children:[i.composioSetupOpenDashboard,(0,Z.jsx)(E,{className:`size-3.5`,"aria-hidden":!0})]}),(0,Z.jsx)(se,{className:`mt-3`,value:p,onChange:h,labels:i.secretInputLabels,placeholder:i.composioSetupKeyPlaceholder}),(0,Z.jsx)(`p`,{className:`mt-2 text-[11px] text-fg-subtle`,children:i.composioSetupStorageHint})]}):null,e.store?(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.detailPermissions}),(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[(e.store.permissions.data??[]).map(e=>(0,Z.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:e},e)),(e.store.permissions.networkDomains??[]).map(e=>(0,Z.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:e},e)),(0,Z.jsx)(`span`,{className:`rounded-md border border-emerald-500/30 bg-emerald-500/10 px-2 py-1 text-xs text-emerald-700 dark:text-emerald-300`,children:i.storeLocalExecDenied})]})]}):null,(a.setup.secrets??[]).map(n=>(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.description?(0,Z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.description}):null,(0,Z.jsx)(se,{value:e.secrets[n.key]??``,onChange:r=>t({...e,secrets:{...e.secrets,[n.key]:r},error:null}),labels:i.secretInputLabels,placeholder:n.required?i.requiredPlaceholder:i.optionalPlaceholder})]},n.key)),(a.setup.config??[]).map(n=>(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.type===`json`?(0,Z.jsx)(`textarea`,{className:dn,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})}):(0,Z.jsx)(`input`,{className:un,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})})]},n.key)),e.installing?(0,Z.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-fg`,children:[(0,Z.jsx)(w,{className:`size-4 animate-spin text-accent`,"aria-hidden":!0}),i.connectingTitle]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i.connectingHint})]}):null,e.error?(0,Z.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:e.error}):null,g?(0,Z.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:g}):null,e.result?(0,Z.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsx)(`div`,{children:(0,Z.jsx)(`p`,{className:`font-medium text-fg`,children:i.connectedBadge})}),(0,Z.jsx)(`span`,{className:s(`rounded-full px-2 py-0.5 text-xs font-medium`,e.health?.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e.health?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-hover text-fg-muted`),children:e.health?.ok?i.healthStatusHealthy:fn(e.health?.status,i)})]}),e.health?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.toolCount}),(0,Z.jsx)(`div`,{children:i.toolsMetric})]}),(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.resourceCount}),(0,Z.jsx)(`div`,{children:i.resourcesMetric})]}),(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.promptCount}),(0,Z.jsx)(`div`,{children:i.promptsMetric})]})]}),(0,Z.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,Z.jsx)(mn,{title:i.detailTools,items:e.health.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,Z.jsx)(mn,{title:i.detailResources,items:e.health.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,Z.jsx)(mn,{title:i.detailPrompts,items:e.health.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??$(i.promptArgumentCount,{count:String(e.argumentCount)})}))})]})]}):(0,Z.jsx)(`p`,{className:`mt-3`,children:i.installedWithoutHealth}),e.health?.action?(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:e.health.action}):null]}):null]})]}),(0,Z.jsx)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:(0,Z.jsxs)(q,{variant:`primary`,disabled:!!e.result||e.installing||d||o&&!l&&!p.trim(),onClick:()=>void C(),children:[e.installing?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):e.result?(0,Z.jsx)(fe,{className:`size-4`}):(0,Z.jsx)(S,{className:`size-4`}),e.result?i.connectedBadge:i.connect]})})]})]})})}function _n(e,t){let n={};for(let t of e.setup.secrets??[])n[t.key]=``;let r={};for(let t of e.setup.config??[])r[t.key]=t.defaultValue===void 0?``:typeof t.defaultValue==`string`?t.defaultValue:JSON.stringify(t.defaultValue,null,2);return{connector:e,secrets:n,config:r,installing:!1,error:null,result:null,health:null,...t?{store:t}:{}}}function vn(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 At(r)}function yn(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 bn(){return s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,g)}function xn({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:i,pasteFailed:a,keyPlaceholder:o,valuePlaceholder:l,headers:u,onChange:d}){let f=(e,t)=>{d(u.map((n,r)=>r===e?{...n,...t}:n))},p=()=>{d([...u,{key:``,value:``}])},m=e=>{let t=u.filter((t,n)=>n!==e);d(t.length>0?t:[{key:``,value:``}])},g=async()=>{try{let e=await c();if(!e){window.alert(a);return}let t=xt(e);if(!t?.length){window.alert(a);return}d(t)}catch{window.alert(a)}};return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,Z.jsx)(`span`,{children:e}),t?(0,Z.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),(0,Z.jsxs)(q,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void g(),children:[(0,Z.jsx)(B,{className:`size-3.5`,"aria-hidden":!0}),i]})]}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{className:s(bn(),`min-w-0 flex-1 font-mono text-xs`),value:e.key,placeholder:o,onChange:e=>f(t,{key:e.target.value})}),(0,Z.jsx)(`input`,{className:s(bn(),`min-w-0 flex-[1.4] font-mono text-xs`),value:e.value,placeholder:l,onChange:e=>f(t,{value:e.target.value})}),(0,Z.jsx)(q,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:u.length<=1&&!e.key&&!e.value,onClick:()=>m(t),"aria-label":r,children:(0,Z.jsx)(h,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})})]},yn(e,t,u)))}),(0,Z.jsxs)(`button`,{type:`button`,className:s(`self-start text-sm text-accent hover:underline`,G.press),onClick:p,children:[`+ `,n]})]})}var Sn=[`stdio`,`sse`,`streamable-http`];function Cn(e){let t=(0,X.c)(11),{label:n,description:r,required:i,children:a}=e,o;t[0]===i?o=t[1]:(o=i?(0,Z.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,Z.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,Z.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,Z.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 wn(){return s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,g)}function Tn(e){let t=(0,X.c)(29),{row:n,t:r,onUpdate:i,idConflictMessage:a,variant:o}=e,c=o===void 0?`all`:o,l=c===`all`||c===`basic`,u=c===`all`||c===`advanced`,d;t[0]!==a||t[1]!==i||t[2]!==n.id||t[3]!==n.transport||t[4]!==l||t[5]!==r?(d=l?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Cn,{label:r.transportLabel,required:!0,children:(0,Z.jsx)(ge,{className:wn(),value:n.transport,onChange:e=>i({transport:e.target.value}),children:Sn.map(e=>(0,Z.jsx)(W,{value:e,children:r.transportLabels[e]},e))})}),(0,Z.jsxs)(Cn,{label:r.serverIdLabel,required:!0,children:[(0,Z.jsx)(`input`,{className:wn(),value:n.id,placeholder:r.serverIdPlaceholder,onChange:e=>i({id:e.target.value})}),a?(0,Z.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-300`,children:a}):null]})]}):null,t[0]=a,t[1]=i,t[2]=n.id,t[3]=n.transport,t[4]=l,t[5]=r,t[6]=d):d=t[6];let f;t[7]!==i||t[8]!==n.argsText||t[9]!==n.command||t[10]!==n.cwd||t[11]!==n.envJson||t[12]!==n.headers||t[13]!==n.transport||t[14]!==n.url||t[15]!==u||t[16]!==l||t[17]!==r||t[18]!==c?(f=n.transport===`stdio`?(0,Z.jsxs)(Z.Fragment,{children:[l?(0,Z.jsx)(`div`,{className:c===`basic`?`md:col-span-2`:void 0,children:(0,Z.jsx)(Cn,{label:r.commandLabel,required:!0,children:(0,Z.jsx)(`input`,{className:wn(),value:n.command,onChange:e=>i({command:e.target.value})})})}):null,u?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Cn,{label:r.argsLabel,description:r.argsHint,children:(0,Z.jsx)(`input`,{className:wn(),value:n.argsText,onChange:e=>i({argsText:e.target.value})})}),(0,Z.jsx)(Cn,{label:r.cwdLabel,children:(0,Z.jsx)(`input`,{className:wn(),value:n.cwd,onChange:e=>i({cwd:e.target.value})})}),(0,Z.jsx)(Cn,{label:r.envLabel,description:r.envHint,children:(0,Z.jsx)(`textarea`,{className:s(wn(),`min-h-[4rem] font-mono text-xs`),value:n.envJson,onChange:e=>i({envJson:e.target.value})})})]}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[l?(0,Z.jsx)(`div`,{className:`md:col-span-2`,children:(0,Z.jsx)(Cn,{label:r.urlLabel,required:!0,children:(0,Z.jsx)(`input`,{className:s(wn(),`font-mono text-xs`),value:n.url,placeholder:`https://example.com/mcp`,onChange:e=>i({url:e.target.value})})})}):null,u?(0,Z.jsx)(xn,{label:r.headersLabel,optionalLabel:r.optionalSuffix,addLabel:r.addHeader,removeHeaderAria:r.removeHeader,pasteLabel:r.pasteHeaders,pasteFailed:r.pasteHeadersFailed,keyPlaceholder:r.headerKeyPlaceholder,valuePlaceholder:r.headerValuePlaceholder,headers:n.headers,onChange:e=>i({headers:e})}):null]}),t[7]=i,t[8]=n.argsText,t[9]=n.command,t[10]=n.cwd,t[11]=n.envJson,t[12]=n.headers,t[13]=n.transport,t[14]=n.url,t[15]=u,t[16]=l,t[17]=r,t[18]=c,t[19]=f):f=t[19];let p;t[20]!==i||t[21]!==n||t[22]!==u||t[23]!==r?(p=u?(0,Z.jsx)(Cn,{label:r.timeoutLabel,description:r.timeoutHint,children:(0,Z.jsx)(`input`,{type:`number`,min:1,max:600,className:wn(),value:Rt(n),placeholder:r.timeoutPlaceholder,onChange:e=>i({connectionTimeoutMs:zt(e.target.value)})})}):null,t[20]=i,t[21]=n,t[22]=u,t[23]=r,t[24]=p):p=t[24];let m;return t[25]!==d||t[26]!==f||t[27]!==p?(m=(0,Z.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[d,f,p]}),t[25]=d,t[26]=f,t[27]=p,t[28]=m):m=t[28],m}function En(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 Dn(e){let t=(0,X.c)(13),{tool:n,serverId:r}=e,i;t[0]!==r||t[1]!==n?(i=En(n,r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o=n.name===a?a:n.name,c;t[3]===n.description?c=t[4]:(c=n.description?.trim(),t[3]=n.description,t[4]=c);let l=c,u;t[5]!==a||t[6]!==o?(u=(0,Z.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]=u):u=t[7];let d;t[8]===l?d=t[9]:(d=l?(0,Z.jsx)(C,{delayDuration:300,skipDelayDuration:100,children:(0,Z.jsxs)(T,{children:[(0,Z.jsx)(A,{asChild:!0,children:(0,Z.jsx)(`p`,{tabIndex:0,title:l,className:s(`mt-1 line-clamp-3 cursor-help text-xs leading-5 text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:l})}),(0,Z.jsx)(y,{children:(0,Z.jsx)(k,{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,Z.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:l})})})]})}):null,t[8]=l,t[9]=d);let f;return t[10]!==u||t[11]!==d?(f=(0,Z.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[u,d]}),t[10]=u,t[11]=d,t[12]=f):f=t[12],f}function On({open:e,mode:t,initialRow:n,existingCustomServers:r,sessionIdleTtlMinutes:i,config:a,managedServerIds:o,t:c,cs:l,onClose:u,onSaved:d}){let[f,p]=(0,Y.useState)(n),[h,g]=(0,Y.useState)(!1),[y,b]=(0,Y.useState)(!1),[S,C]=(0,Y.useState)(null),[T,E]=(0,Y.useState)(!1),[D,k]=(0,Y.useState)({status:`idle`}),[A,M]=(0,Y.useState)(null),I=n.id.trim(),L=f.id.trim()!==I&&o.has(f.id.trim())||o.has(f.id.trim())&&t===`add`?c.reservedServerId:void 0,R=f.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===f.id.trim())?l.duplicateServerId:void 0,z=f.id.trim().length>0&&!L&&!R&&(f.transport===`stdio`?f.command.trim().length>0:f.url.trim().length>0),B=Bt(f),ee=(0,Y.useCallback)(async()=>{if(f.id.trim()){b(!0),C(null),k({status:`loading`});try{k({status:`ok`,tools:(await Lt(f.id.trim(),Mt(f))).tools})}catch(e){k({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{b(!1)}}},[f]),V=(0,Y.useCallback)(async()=>{if(!(!z||h)){g(!0),C(null);try{let e=r.filter(e=>!(t===`edit`&&e.clientKey===n.clientKey));e.push(f),await Nt({sessionIdleTtlMinutes:i,servers:e.sort((e,t)=>e.id.localeCompare(t.id))},Tt(a)),await d(),u()}catch(e){C(e instanceof Error?e.message:String(e))}finally{g(!1)}}},[z,a,r,n.clientKey,t,u,d,I,f,h,i]);return e?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(j,{open:e,onOpenChange:e=>{e||u()},children:(0,Z.jsxs)(N,{children:[(0,Z.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Z.jsxs)(m,{className:s(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(F,{className:`text-base font-semibold text-fg`,children:t===`add`?l.addCustomServerTitle:l.editCustomServerTitle}),(0,Z.jsx)(P,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?l.addCustomServerHint:l.editCustomServerHint})]}),(0,Z.jsx)(J,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:s(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,G.focusRingPanel),"aria-label":l.modalClose,children:[(0,Z.jsx)(v,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`sr-only`,children:l.modalClose})]})})]}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Z.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Z.jsx)(ne,{className:`size-4 text-accent`,"aria-hidden":!0}),f.id.trim()||c.cardUntitled]}),(0,Z.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs leading-5 text-fg-muted`,children:B||(f.transport===`stdio`?c.commandLabel:c.urlLabel)})]}),(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:c.transportLabels[f.transport]})]})}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(`div`,{className:`mb-3`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.connectorBasicConfigTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.connectorBasicConfigHint})]}),(0,Z.jsx)(Tn,{row:f,t:c,variant:`basic`,onUpdate:e=>{p(t=>({...t,...e})),C(null)},idConflictMessage:L??R})]}),D.status===`ok`?(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,Z.jsx)(O,{className:`size-4 text-accent`,"aria-hidden":!0}),D.tools.length===0?c.toolsEmpty:c.toolsTitle.replace(`{{count}}`,String(D.tools.length))]}),D.tools.length>0?(0,Z.jsx)(q,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>M(D.tools),children:c.viewAllTools}):null]}),D.tools.length>0?(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2`,children:D.tools.slice(0,6).map((e,t)=>(0,Z.jsx)(Dn,{tool:e,serverId:f.id},e.name||`tool-${t}`))}):null]}):null,D.status===`error`?(0,Z.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:D.message}):null,S?(0,Z.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:S}):null,(0,Z.jsxs)(`details`,{open:T,onToggle:e=>E(e.currentTarget.open),className:`group rounded-xl border border-edge bg-surface-base`,children:[(0,Z.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,Z.jsx)(ve,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`group-open:hidden`,children:l.connectorShowAdvancedConfig}),(0,Z.jsx)(`span`,{className:`hidden group-open:inline`,children:l.connectorHideAdvancedConfig})]}),(0,Z.jsx)(`div`,{className:`border-t border-edge p-4`,children:(0,Z.jsx)(Tn,{row:f,t:c,variant:`advanced`,onUpdate:e=>{p(t=>({...t,...e})),C(null)}})})]})]})}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,Z.jsxs)(q,{variant:`secondary`,disabled:!f.id.trim()||y,onClick:()=>void ee(),children:[y?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(_,{className:`size-4`}),c.testConnection]}),(0,Z.jsx)(J,{asChild:!0,children:(0,Z.jsx)(q,{variant:`secondary`,children:l.modalCancel})}),(0,Z.jsxs)(q,{variant:`primary`,disabled:!z||h,onClick:()=>void V(),children:[h?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):(0,Z.jsx)(fe,{className:`size-4`}),h?c.saving:l.modalSave]})]})]})]})}),A?(0,Z.jsx)(Kt,{open:!0,onOpenChange:e=>{e||M(null)},serverId:f.id,title:c.toolsDialogTitle,subtitle:c.toolsDialogSubtitle,searchPlaceholder:c.toolsDialogSearchPlaceholder,searchEmptyLabel:c.toolsDialogSearchEmpty,emptyLabel:c.toolsEmpty,closeLabel:c.toolsDialogClose,tools:A,stripPrefix:`${f.id.trim()}__`}):null]}):null}function kn(e){return!(e.runtime.type===`composio`&&e.runtime.role===`credential`)}function An(e,t){let n=t.trim().toLowerCase();return n?[e.displayName,e.description,e.category,e.kind,e.source,...e.tags??[]].some(e=>e.toLowerCase().includes(n)):!0}function jn(e,t,n){return e.filter(e=>An(e,t)).toSorted((e,t)=>n===`source`&&e.source!==t.source?e.source.localeCompare(t.source):e.displayName.localeCompare(t.displayName))}function Mn(e,t){let n=t.trim().toLowerCase();return n?[e.displayName,e.connectorId,e.instanceId,e.status,e.connectionStatus??``,e.materialized.type,e.materialized.type===`mcp`?e.materialized.serverId:e.materialized.id].some(e=>e.toLowerCase().includes(n)):!0}function Nn(e,t){let n=t.trim().toLowerCase();return n?[e.id,e.command??``,e.url??``,e.transport].some(e=>e.toLowerCase().includes(n)):!0}var Pn=`all`,Fn=`builtin`,In=`composio`,Ln=`xopc-store`;function Rn(e){let t=[`code`,`docs`,`browser`,`data`,`automation`,`custom`].includes(e.category??``)?e.category:`custom`;return{id:e.name,version:e.latestVersion??`store`,displayName:e.name,description:e.description,category:t,kind:`mcp`,source:`store`,capabilities:[`tools`,`runtime.mcp.streamableHttp`],tags:[`store`],auth:{mode:`none`},setup:{},runtime:{type:`mcp`,serverId:`store-${e.name}`.slice(0,64)}}}function zn(e){return e.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t)}function Bn(){let e=l(d(e=>e.language)),t=e.connectorsSettings,n=e.mcpSettings,r=u(e=>e.token),a=!!r,[o,c]=i(),[f,p]=(0,Y.useState)(o.get(`tab`)===`connected`?`connected`:`discover`),m=(0,Y.useRef)(!1),[h,g]=(0,Y.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null,peopleGraph:null}),[_,v]=(0,Y.useState)(!1),[y,b]=(0,Y.useState)(!1),[x,S]=(0,Y.useState)(1),[C,T]=(0,Y.useState)(void 0),[E,O]=(0,Y.useState)(``),[k,A]=(0,Y.useState)(``),[j,M]=(0,Y.useState)(!1),[N,P]=(0,Y.useState)(``),[F,I]=(0,Y.useState)(Fn),[L,R]=(0,Y.useState)(`name`),[B,ee]=(0,Y.useState)(`all`),[V,H]=(0,Y.useState)(null),[U,ne]=(0,Y.useState)(null),[ae,oe]=(0,Y.useState)(null),[se,ce]=(0,Y.useState)(null),[le,ue]=(0,Y.useState)(null),[de,fe]=(0,Y.useState)(null),[pe,me]=(0,Y.useState)(!1),[W,he]=(0,Y.useState)(void 0),[ge,_e]=(0,Y.useState)(!1),{data:ve,mutate:ye}=z(a),G=ve?.payload?.config,K=(0,Y.useMemo)(()=>G===void 0?null:jt(G),[G]),J=K?.servers??[],xe=h.instances.length+J.length;(0,Y.useEffect)(()=>{K&&he(K.sessionIdleTtlMinutes)},[K]);let X=(0,Y.useCallback)(async()=>{if(!r){g({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null,peopleGraph:null});return}g(e=>({...e,loading:!0,error:null}));try{let[e,t,n]=await Promise.all([Ae(),Fe(),at(``,12).catch(()=>null)]);g(r=>({catalog:e,registryCatalog:r.registryCatalog,instances:t,loading:!1,error:null,peopleGraph:n}))}catch(e){g({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e),peopleGraph:null})}},[r]);(0,Y.useEffect)(()=>{X()},[X]),(0,Y.useEffect)(()=>{if(!a||f!==`connected`)return;let e=!1,t=window.setTimeout(()=>{M(!0),at(k,50).then(t=>{e||g(e=>({...e,peopleGraph:t}))}).catch(()=>{}).finally(()=>{e||M(!1)})},250);return()=>{e=!0,window.clearTimeout(t)}},[a,k,f]),(0,Y.useEffect)(()=>{m.current||h.loading||a&&!K||(p(xe>0?`connected`:`discover`),m.current=!0)},[a,xe,K,h.loading]);let Ce=(0,Y.useCallback)(e=>{m.current=!0,p(e)},[]),Ee=(0,Y.useMemo)(()=>[{id:In,displayName:t.composioSourceName},{id:Ln,displayName:t.storeSourceName}],[t.composioSourceName,t.storeSourceName]),Oe=(0,Y.useCallback)(async e=>{if(!a||F===Fn){g(e=>({...e,registryCatalog:[]})),S(1),T(void 0);return}let t=N.trim(),n=Math.max(e?.page??1,1),r=e?.append??!1,i=F===Pn?Ee:Ee.filter(e=>e.id===F);if(i.length!==0){v(!0),r?g(e=>({...e,error:null})):(S(1),T(void 0),g(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(i.map(async e=>{if(e.id===In){let e=await je({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let r=await Me({q:t||void 0,page:n,pageSize:24,sort:L===`source`?`newest`:`downloads`});return{connectors:r.items.map(Rn),totalPages:r.meta.totalPages}})),a=zn(e.flatMap(e=>e.connectors)),o=Math.max(1,...e.map(e=>e.totalPages??1));S(n),T(o),g(e=>({...e,registryCatalog:r?zn([...e.registryCatalog,...a]):a}))}catch(e){g(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{v(!1)}}},[L,N,F,a,Ee]);(0,Y.useEffect)(()=>{if(f!==`discover`||h.loading)return;if(F===Fn){g(e=>({...e,registryCatalog:[]})),S(1),T(void 0);return}let e=window.setTimeout(()=>{Oe()},N.trim()?350:0);return()=>window.clearTimeout(e)},[N,F,Oe,h.loading,f]);let Q=(0,Y.useMemo)(()=>new Set(h.instances.map(e=>e.connectorId)),[h.instances]),Pe=(0,Y.useMemo)(()=>new Map([...h.catalog,...h.registryCatalog].map(e=>[e.id,e])),[h.catalog,h.registryCatalog]);(0,Y.useEffect)(()=>{if(h.loading)return;let e=o.get(`connector`),t=o.get(`instance`);if(!e&&!t)return;let n=h.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)m.current=!0,O(``),oe(n.instanceId),ce(n),p(`connected`);else if(e){let t=Pe.get(e);if(!t)return;m.current=!0,I(Fn),P(``),ne(t),p(`discover`)}let r=new URLSearchParams(o);r.delete(`connector`),r.delete(`instance`),r.delete(`personalContext`),r.set(`tab`,n?`connected`:`discover`),c(r,{replace:!0})},[Pe,o,c,h.instances,h.loading]);let Ie=(0,Y.useCallback)(async e=>{b(!0),g(e=>({...e,error:null}));try{let t=await Ne(e);H(_n(t.definition,{packageName:t.packageName,version:t.version,permissions:t.permissions}))}catch(e){g(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{b(!1)}},[]),Le=(0,Y.useMemo)(()=>new Set(h.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[h.instances]),Re=(0,Y.useCallback)(async e=>{if(!K||G===void 0)return;let t=J.filter(t=>t.clientKey!==e.clientKey);await Nt({sessionIdleTtlMinutes:K.sessionIdleTtlMinutes,servers:t},Tt(G)),await ye(),await X()},[G,J,X,K,ye]),ze=(0,Y.useCallback)(()=>{fe({mode:`add`,row:vn(J,Le)})},[J,Le]),Be=(0,Y.useCallback)(async()=>{if(!(!K||G===void 0||ge)){_e(!0);try{await Nt({sessionIdleTtlMinutes:W,servers:J},Tt(G)),await ye(),me(!1)}finally{_e(!1)}}},[G,J,n.saved,K,ye,W,ge]),Ve=te(e=>e.setPageHeader),He=te(e=>e.clearPageHeader),Ue=(0,Y.useMemo)(()=>(0,Z.jsx)(yt,{onBrowseCatalog:()=>Ce(`discover`),onAddCustomServer:ze,onOpenRuntimeSettings:()=>me(!0),addLabel:t.addConnection,browseLabel:t.addFromCatalog,customLabel:t.addCustomServerAdvanced,settingsLabel:t.runtimeSettings}),[t,ze,Ce]);(0,Y.useLayoutEffect)(()=>(Ve({startExtra:null,main:(0,Z.jsx)(`div`,{className:`min-w-0`,children:(0,Z.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title})}),end:Ue}),()=>He()),[He,t.title,Ue,Ve]);let We=(0,Y.useMemo)(()=>h.instances.map(e=>({instance:e,value:cn(e,Pe.get(e.connectorId))})),[Pe,h.instances]),Ge=(0,Y.useMemo)(()=>new Map(We.map(({instance:e,value:t})=>[e.instanceId,t])),[We]),Ke=(0,Y.useMemo)(()=>h.instances.filter(e=>Mn(e,E)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=Ge.get(e.instanceId)?.state??`checking`,i=Ge.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[E,Ge,h.instances]),qe=(0,Y.useMemo)(()=>J.filter(e=>Nn(e,E)),[E,J]),Je=Ke.length+qe.length,Ye=(0,Y.useMemo)(()=>h.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&kn(e)),[h.catalog]),Xe=(0,Y.useMemo)(()=>F===Fn?Ye:F===Pn?zn([...Ye,...h.registryCatalog]):h.registryCatalog,[Ye,F,h.registryCatalog]),Ze=(0,Y.useMemo)(()=>jn(B===`all`?Xe:Xe.filter(e=>on(e).includes(B)),N,L),[L,N,Xe,B]),Qe=(0,Y.useMemo)(()=>an.filter(e=>Xe.some(t=>on(t).includes(e))),[Xe]);(0,Y.useEffect)(()=>{B!==`all`&&!Qe.includes(B)&&ee(`all`)},[Qe,B]);let $e=f===`discover`&&F!==Fn&&!!(C&&x<C),et=(0,Y.useMemo)(()=>h.instances.find(e=>e.instanceId===ae)??se,[ae,se,h.instances]),tt=(0,Y.useMemo)(()=>[{value:Pn,label:t.discoverSourceAll},{value:Fn,label:t.discoverSourceBuiltin},...Ee.map(e=>({value:e.id,label:e.displayName}))],[t.discoverSourceAll,t.discoverSourceBuiltin,Ee]),nt=[{id:`connected`,label:t.tabConnected,count:xe},{id:`discover`,label:t.tabDiscover}];return(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[a?null:(0,Z.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:t.tokenHint}),(0,Z.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,Z.jsx)(`div`,{className:`border-b border-edge-subtle pb-3 dark:border-edge-subtle`,children:(0,Z.jsx)(be,{items:nt,activeTab:f,onChange:Ce,ariaLabel:t.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),h.error?(0,Z.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:h.error}):null,f===`connected`&&a?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,Z.jsx)(vt,{value:E,onChange:O,placeholder:t.connectedSearchPlaceholder,className:`max-w-xl`}),(0,Z.jsx)(re,{className:`size-9 shrink-0 p-0`,loading:h.loading,label:t.refreshConnections,title:t.refreshConnections,onClick:X})]}),h.peopleGraph&&(h.peopleGraph.people.length>0||k)?(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Z.jsx)(`div`,{className:`rounded-lg bg-accent-soft p-2 text-accent-fg`,children:(0,Z.jsx)(D,{className:`size-4`,"aria-hidden":!0})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.peopleGraphTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.peopleGraphHint.replace(`{{people}}`,String(h.peopleGraph.people.length)).replace(`{{sources}}`,String(new Set(h.peopleGraph.sourceEdges.map(e=>e.sourceInstanceId)).size))})]})]}),(0,Z.jsxs)(`div`,{className:`relative w-full max-w-xs`,children:[(0,Z.jsx)(vt,{value:k,onChange:A,placeholder:t.peopleGraphSearchPlaceholder}),j?(0,Z.jsx)(w,{className:`absolute right-3 top-2.5 size-4 animate-spin text-fg-subtle`,"aria-hidden":!0}):null]})]}),h.peopleGraph.people.length?(0,Z.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:h.peopleGraph.people.slice(0,10).map(e=>{let t=[...new Set(h.peopleGraph.sourceEdges.filter(t=>t.personId===e.id).map(e=>e.toolkit??e.connectorId??e.sourceInstanceId))];return(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel px-3 py-2.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Z.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.label}),(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:e.mentionCount})]}),(0,Z.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:e.emails[0]??e.usernames[0]??e.roles.join(` · `)}),(0,Z.jsx)(`p`,{className:`mt-1 truncate text-[11px] text-fg-subtle`,children:t.join(` · `)})]},e.id)})}):(0,Z.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:t.peopleGraphSearchEmpty})]}):null,h.loading?(0,Z.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":t.loading,children:we.slice(0,3).map(e=>(0,Z.jsx)(ke,{},e))}):xe===0?(0,Z.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.connectionsEmpty}),(0,Z.jsx)(q,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>Ce(`discover`),children:t.addFromCatalog})]}):Je===0?(0,Z.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.connectionsSearchEmpty}):(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:[Ke.map(e=>(0,Z.jsx)(ln,{instance:e,definition:Pe.get(e.connectorId),highlighted:e.instanceId===le,onOpenDetails:e=>{ue(null),oe(e.instanceId),ce(e)},onChanged:X,t},e.instanceId)),qe.map(e=>(0,Z.jsx)(Vt,{row:e,t:n,cs:t,onEdit:()=>fe({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>Re(e)},e.clientKey))]})]}):null,f===`discover`&&a?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":t.outcomeFilterAria,children:[`all`,...Qe].map(e=>(0,Z.jsx)(`button`,{type:`button`,className:s(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,B===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":B===e,onClick:()=>ee(e),children:e===`all`?t.outcomeAll:t.connectorBenefitHeadings[e]},e))}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 lg:flex-row lg:items-center`,children:[(0,Z.jsx)(vt,{value:N,onChange:P,placeholder:t.discoverSearchPlaceholder,className:`max-w-xl`}),(0,Z.jsxs)(`div`,{className:`grid min-w-0 grid-cols-1 gap-2 sm:grid-cols-2 lg:ml-auto lg:w-[26rem]`,children:[(0,Z.jsx)(ie,{value:F,options:tt,placeholder:t.discoverSourceAll,allowEmpty:!1,ariaLabel:t.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:I}),(0,Z.jsx)(ie,{value:L,options:[{value:`name`,label:t.sortName},{value:`source`,label:t.sortSource}],placeholder:t.sortName,allowEmpty:!1,ariaLabel:t.sortAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:e=>R(e)})]})]}),(h.loading||_)&&Ze.length===0?(0,Z.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:we.map(e=>(0,Z.jsx)(De,{},e))}):Ze.length===0?(0,Z.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.discoverEmpty}):(0,Z.jsxs)(`div`,{className:`relative`,children:[_?(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1] flex justify-center bg-surface-panel/40 pt-[min(28vh,7.5rem)] backdrop-blur-[1px] motion-reduce:backdrop-blur-none dark:bg-surface-base/35`,"aria-busy":`true`,"aria-label":t.loading,children:(0,Z.jsx)(w,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,Z.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:Ze.map(e=>(0,Z.jsx)(Se,{connector:e,installed:Q.has(e.id)||Te(e,h.instances),onInstall:e=>{if(e.source===`store`){Ie(e.id);return}H(_n(e))},onOpenDetails:e.source===`store`?void 0:ne,t},e.id))}),$e?(0,Z.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,Z.jsxs)(q,{type:`button`,variant:`secondary`,disabled:_||y,onClick:()=>void Oe({page:x+1,append:!0}),children:[_?(0,Z.jsx)(w,{className:`size-4 animate-spin`}):null,t.loadMore]})}):null]})]}):null]}),V?(0,Z.jsx)(gn,{draft:V,onChange:H,onClose:()=>H(null),t,onInstalled:async e=>{await X(),await ye(),ue(e.instanceId),Ce(`connected`)}}):null,U?(0,Z.jsx)(ht,{connector:U,installed:Q.has(U.id)||Te(U,h.instances),onClose:()=>ne(null),onInstall:e=>H(_n(e)),t}):null,et?(0,Z.jsx)(rn,{instance:et,definition:Pe.get(et.connectorId),onClose:()=>{oe(null),ce(null)},onChanged:X,t,mcp:n}):null,de?(0,Z.jsx)(On,{open:!0,mode:de.mode,initialRow:de.row,existingCustomServers:J,sessionIdleTtlMinutes:W,config:G,managedServerIds:Le,t:n,cs:t,onClose:()=>fe(null),onSaved:async()=>{await ye(),await X(),Ce(`connected`)}},`${de.mode}-${de.row.clientKey}`):null,(0,Z.jsx)(_t,{open:pe,sessionIdleTtlMinutes:W,saving:ge,onChange:he,onSave:Be,onClose:()=>me(!1),t,mcp:n})]})})}export{Bn as ConnectorsPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i,u as a}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as o}from"./cn-JdwAhgNB.js";import{t as s}from"./messages-BwQ3WssU.js";import{l as c,n as l,o as u,r as d,s as f}from"./locale-store-0lpYdNDr.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{Cs as m,Ss as h,ct as g,rs as _,to as v,ts as y,ws as b,xs as x}from"./index-C8JkTS6d.js";import{t as S}from"./settings-loading-skeleton-DEwYqESe.js";import{a as C,f as w,h as T,l as E,m as D,o as O,p as k,t as A}from"./voice-api-key-field-CrwkicvT.js";import{t as j}from"./schema-form-D7oCARF7.js";var M=n(),N=e(t(),1),P=r(),F=()=>d(T);function I(e){return{credentialsIntro:e.credentialsIntro,regionHint:e.regionHint,endpointPresetsHint:e.endpointPresetsHint,apiKeyLabel:e.apiKeyLabel,optionalPlaceholder:e.optionalPlaceholder,regionLabel:e.regionLabel,baseUrlLabel:e.baseUrlLabel,imageBaseUrlLabel:e.imageBaseUrlLabel,saveCredentials:e.saveCredentials,savingCredentials:e.savingCredentials,credentialsSaved:e.credentialsSaved,discardCredentials:e.discardCredentials,credentialsNothingToSave:e.credentialsNothingToSave,credentialsSaveError:e.credentialsSaveError,regionPresetDefault:e.regionPresetDefault,regionPresetCustom:e.regionPresetCustom,baseUrlPresetDefault:e.baseUrlPresetDefault,baseUrlPresetCustom:e.baseUrlPresetCustom,openExtensionSettings:e.openExtensionSettings,openImageModelsPage:e.openImageModelsPage,extensionSettingsLinkTitle:e.extensionSettingsLinkTitle,imageModelsLinkTitle:e.imageModelsLinkTitle,configured:e.configured,missingKey:e.missingKey,unsavedChanges:e.unsavedChanges,expandProvider:e.expandProvider,collapseProvider:e.collapseProvider,defaultModel:e.defaultModel,modelsLabel:e.modelsLabel,modelCountOne:e.modelCountOne,modelCountMany:e.modelCountMany,imageBaseUrlPresetHint:e.imageBaseUrlPresetHint,dashscopeRegion_beijing:e.dashscopeRegion_beijing,dashscopeRegion_singapore:e.dashscopeRegion_singapore,dashscopeRegion_us:e.dashscopeRegion_us,apiKeyMaskedHelp:e.apiKeyMaskedHelp,apiKeyCopy:e.apiKeyCopy,apiKeyCopied:e.apiKeyCopied,apiKeyShow:e.apiKeyShow,apiKeyHide:e.apiKeyHide,apiKeyNotInConfigFile:e.apiKeyNotInConfigFile,apiKeyRevealFailed:e.apiKeyRevealFailed,minimaxClusterLabel:e.minimaxClusterLabel,minimaxClusterHint:e.minimaxClusterHint,falQueueBaseLabel:e.falQueueBaseLabel,falQueueBaseHint:e.falQueueBaseHint}}function L(e){let t=(0,M.c)(40),{extensionId:n}=e,r=l(R),i;t[0]===r?i=t[1]:(i=s(r),t[0]=r,t[1]=i);let a=i,o=a.imageModelsSettings,u=c(ee),d;t[2]===u?d=t[3]:(d=u?F():null,t[2]=u,t[3]=d);let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f={revalidateOnFocus:!1},t[4]=f):f=t[4];let{data:m,isLoading:h}=p(d,D,f),g;t[5]===m?g=t[6]:(g=m===void 0?[]:m,t[5]=m,t[6]=g);let _=g,v;if(t[7]!==_||t[8]!==n){let e;t[10]===n?e=t[11]:(e=e=>e.id===n,t[10]=n,t[11]=e),v=_.filter(e),t[7]=_,t[8]=n,t[9]=v}else v=t[9];let y=v,b=w(y),x;t[12]===o?x=t[13]:(x=I(o),t[12]=o,t[13]=x);let C=x,T;t[14]!==a.providersSettings.getApiKey||t[15]!==a.providersSettings.getApiKeyCn||t[16]!==a.providersSettings.getApiKeyIntl?(T={getApiKey:a.providersSettings.getApiKey,getApiKeyIntl:a.providersSettings.getApiKeyIntl,getApiKeyCn:a.providersSettings.getApiKeyCn},t[14]=a.providersSettings.getApiKey,t[15]=a.providersSettings.getApiKeyCn,t[16]=a.providersSettings.getApiKeyIntl,t[17]=T):T=t[17];let E=T;if(!u)return null;if(h){let e;return t[18]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,P.jsx)(S,{rows:2}),t[18]=e):e=t[18],e}if(y.length===0){let e=r===`zh`?`网关未注册该图像 Provider,或扩展已被禁用。`:`This image provider is not registered on the gateway, or the extension is disabled.`,n;return t[19]===e?n=t[20]:(n=(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[19]=e,t[20]=n),n}let O;t[21]!==b||t[22]!==o.credentialsSaveError?(O=()=>void b.saveCredentials(o.credentialsSaveError),t[21]=b,t[22]=o.credentialsSaveError,t[23]=O):O=t[23];let A;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(A=new Set,t[24]=A):A=t[24];let j;return t[25]!==E||t[26]!==b.credBaseline||t[27]!==b.credDirty||t[28]!==b.credDraft||t[29]!==b.credError||t[30]!==b.credNoopFlash||t[31]!==b.credSavedFlash||t[32]!==b.credSaving||t[33]!==b.onDiscardCredentials||t[34]!==b.updateCredRow||t[35]!==r||t[36]!==C||t[37]!==y||t[38]!==O?(j=(0,P.jsx)(k,{summaries:y,credDraft:b.credDraft,credBaseline:b.credBaseline,credDirty:b.credDirty,credSaving:b.credSaving,credError:b.credError,credSavedFlash:b.credSavedFlash,credNoopFlash:b.credNoopFlash,updateCredRow:b.updateCredRow,onDiscardCredentials:b.onDiscardCredentials,onSaveCredentials:O,extensionIds:A,showExtensionLinks:!1,showImageModelsLink:!1,language:r,apiKeyLinkLabels:E,messages:C}),t[25]=E,t[26]=b.credBaseline,t[27]=b.credDirty,t[28]=b.credDraft,t[29]=b.credError,t[30]=b.credNoopFlash,t[31]=b.credSavedFlash,t[32]=b.credSaving,t[33]=b.onDiscardCredentials,t[34]=b.updateCredRow,t[35]=r,t[36]=C,t[37]=y,t[38]=O,t[39]=j):j=t[39],j}function ee(e){return!!e.token}function R(e){return e.language}function z(e){let t=(0,M.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,P.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}var B=[{id:`whisper-large-v3-turbo`,name:`Whisper Large v3 Turbo`},{id:`whisper-large-v3`,name:`Whisper Large v3`}];function V(e){let t=e?.manifest?.mediaUnderstandingProviders?.[0];if(typeof t==`string`&&t.trim())return t.trim();let n=e?.manifest?.contracts?.mediaUnderstandingProviders?.[0];if(typeof n==`string`&&n.trim())return n.trim()}function H(){return o(h,x)}function U(){return o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,m,`dark:border-edge`)}function W(e,t){if(!e||!t)return{apiKey:``,model:B[0].id};if(t===`alibaba`)return{apiKey:e.stt.alibaba?.apiKey??``,model:e.stt.alibaba?.model??`paraformer-v2`};if(t===`openai`)return{apiKey:e.stt.openai?.apiKey??``,model:e.stt.openai?.model??`whisper-1`};let n=e.stt.providers?.[t];return{apiKey:typeof n?.apiKey==`string`?n.apiKey:``,model:typeof n?.model==`string`?n.model:B[0].id}}function G({providerId:e,voiceSettings:t,mutateVoice:n}){let r=s(l(e=>e.language)),i=r.voiceSettings,a=r.extensionSttMedia,c={maskedHelp:i.apiKeyMaskedHelp,copy:i.apiKeyCopy,copied:i.apiKeyCopied,show:i.apiKeyShow,hide:i.apiKeyHide,notInConfigFile:i.apiKeyNotInConfigFile,loadFailed:i.apiKeyRevealFailed},{data:u}=p(d(`/api/voice/stt-providers`),O,{revalidateOnFocus:!1}),f=(0,N.useMemo)(()=>u?.providers.some(t=>t.id===e&&t.configured)??!1,[e,u]),m=(0,N.useMemo)(()=>W(t,e),[e,t]),h=(0,N.useRef)(!1),[g,v]=(0,N.useState)(null),[S,C]=(0,N.useState)(!1),[w,T]=(0,N.useState)(null),[D,k]=(0,N.useState)(!1),j=g??m,M=m,F=j.apiKey!==M.apiKey||j.model!==M.model,I=(0,N.useCallback)(async()=>{C(!0),T(null);try{let r=structuredClone(t);r.stt.enabled=!0,e===`alibaba`?(r.stt.provider=`alibaba`,r.stt.alibaba={...r.stt.alibaba,apiKey:j.apiKey,model:j.model}):e===`openai`?(r.stt.provider=`openai`,r.stt.openai={...r.stt.openai,apiKey:j.apiKey,model:j.model}):(r.stt.providers={...r.stt.providers??{},[e]:{...r.stt.providers?.[e]??{},apiKey:j.apiKey,model:j.model}},(!r.stt.provider||r.stt.provider===`alibaba`||r.stt.provider===`openai`)&&(r.stt.provider=e)),await E(r),await n(r,!1),h.current=!1,v(null),k(!0)}catch(e){T(e instanceof Error?e.message:String(e))}finally{C(!1)}},[j.apiKey,j.model,n,e,t]),L=e===`groq`?B:[{id:j.model,name:j.model}];return(0,P.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl bg-surface-base p-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a.credentialsTitle}),(0,P.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.credentialsHint.replace(`{providerId}`,e)})]}),(0,P.jsx)(`span`,{className:o(`rounded-full px-2 py-0.5 text-xs font-medium`,f?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:f?a.configured:a.notConfigured})]}),(0,P.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,P.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,x),children:[(0,P.jsx)(z,{children:i.stt.apiKey}),(0,P.jsx)(A,{kind:`stt`,providerId:e,fieldId:`ext-stt-${e}-api-key`,value:j.apiKey,onChange:e=>{h.current=!0,v(t=>({...t??m,apiKey:e})),T(null)},labels:c,placeholder:e===`groq`?`gsk_...`:`sk-...`}),(0,P.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[i.stt.apiKeyDesc,e===`groq`?` (GROQ_API_KEY)`:``]})]}),(0,P.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,x),children:[(0,P.jsx)(z,{children:i.stt.model}),e===`groq`?(0,P.jsx)(y,{className:H(),value:j.model,onChange:e=>{h.current=!0,v(t=>({...t??m,model:e.target.value})),T(null)},children:L.map(e=>(0,P.jsx)(_,{value:e.id,children:e.name},e.id))}):(0,P.jsx)(`input`,{className:U(),value:j.model,onChange:e=>{h.current=!0,v(t=>({...t??m,model:e.target.value})),T(null)}})]})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[w?(0,P.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,children:w}):null,(0,P.jsx)(b,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,disabled:!F||S,onClick:()=>{h.current=!1,v(null),T(null)},children:i.discard}),(0,P.jsx)(b,{type:`button`,variant:`primary`,className:`h-8 text-xs`,disabled:!F||S,onClick:()=>void I(),children:S?i.saving:i.save})]})]})}function K(e){let t=(0,M.c)(13),{extensionId:n}=e,r=l(J),i=c(q),a;t[0]===n?a=t[1]:(a=()=>f(d(`/api/extensions/${encodeURIComponent(n)}`)),t[0]=n,t[1]=a);let{data:o,isLoading:s}=p(i&&n?`ext-stt-detail-${n}`:null,a),u;t[2]===o?u=t[3]:(u=V(o),t[2]=o,t[3]=u);let m=u,h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h={revalidateOnFocus:!1},t[4]=h):h=t[4];let{data:g,mutate:_,isLoading:v}=p(i?`voice-settings-ext-stt`:null,C,h);if(!i)return null;if(s||v){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,P.jsx)(S,{rows:2}),t[5]=e):e=t[5],e}if(!m){let e=r===`zh`?`该扩展未声明 mediaUnderstandingProviders。`:`This extension does not declare mediaUnderstandingProviders.`,n;return t[6]===e?n=t[7]:(n=(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[6]=e,t[7]=n),n}if(!g)return null;let y=`${n}:${m}`,b;return t[8]!==_||t[9]!==m||t[10]!==y||t[11]!==g?(b=(0,P.jsx)(G,{providerId:m,voiceSettings:g,mutateVoice:_},y),t[8]=_,t[9]=m,t[10]=y,t[11]=g,t[12]=b):b=t[12],b}function q(e){return!!e.token}function J(e){return e.language}function Y(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function X(e){let t={};if(e.type!==`object`||!Y(e.properties))return t;for(let[n,r]of Object.entries(e.properties))Y(r)&&Object.prototype.hasOwnProperty.call(r,`default`)&&(t[n]=r.default);return t}function Z(e,t){switch(t.type){case`sync`:return{...e,localValues:t.value,isDirty:!1,saveError:null};case`change`:return{...e,localValues:t.value,isDirty:!0,saveError:null,saveSuccess:!1};case`discard`:return{...e,localValues:t.value,isDirty:!1,saveError:null};case`reset-defaults`:return{...e,localValues:t.value,isDirty:!0,saveError:null,saveSuccess:!1};case`save-start`:return{...e,saving:!0,saveError:null};case`save-success`:return{...e,localValues:t.value,isDirty:!1,saving:!1,saveSuccess:!0,saveError:null};case`save-error`:return{...e,saving:!1,saveError:t.message}}}function Q({extensionId:e}){let t=s(l(e=>e.language)).agentSettings,n=c(e=>!!e.token),{data:r,error:i}=p(n&&e?`ext-detail-${e}`:null,()=>f(d(`/api/extensions/${encodeURIComponent(e)}`))),{data:a,mutate:o,error:m}=p(n&&e?`ext-cfg-${e}`:null,()=>f(d(`/api/extensions/${encodeURIComponent(e)}/config`))),h=r?.manifest?.configSchema,g=(0,N.useMemo)(()=>h&&h.type===`object`?X(h):{},[h]),_=(0,N.useMemo)(()=>({...g,...a??{}}),[g,a]),[v,y]=(0,N.useReducer)(Z,{localValues:{},isDirty:!1,saving:!1,saveError:null,saveSuccess:!1}),[x,S]=(0,N.useState)(!1),C=(0,N.useRef)(!1),w=(0,N.useRef)(_);!C.current&&w.current!==_&&(w.current=_,y({type:`sync`,value:_}));let T=(0,N.useCallback)(e=>{C.current=!0,y({type:`change`,value:e})},[]),E=(0,N.useCallback)(()=>{C.current=!1,y({type:`discard`,value:_})},[_]),D=(0,N.useCallback)(()=>{!h||h.type!==`object`||(C.current=!0,y({type:`reset-defaults`,value:{...X(h)}}))},[h]),O=(0,N.useCallback)(async()=>{if(e){y({type:`save-start`});try{let t=await u(d(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(v.localValues)});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await o(v.localValues,!1),C.current=!1,y({type:`save-success`,value:v.localValues}),S(!0)}catch(e){y({type:`save-error`,message:e instanceof Error?e.message:String(e)})}}},[v.localValues,e,o]);if(!n)return null;if(i||m){let e=i??m;return(0,P.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`Could not load extension settings: `,e instanceof Error?e.message:String(e)]})}return!h||h.type!==`object`?null:(0,P.jsxs)(`div`,{className:`mb-6 flex flex-col gap-3 rounded-xl bg-surface-base p-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,P.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Configuration`}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v.saveError?(0,P.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,children:v.saveError}):null,(0,P.jsx)(b,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,disabled:!v.isDirty,onClick:E,children:t.discard}),(0,P.jsx)(b,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:D,children:`Reset to defaults`}),(0,P.jsx)(b,{type:`button`,variant:`primary`,className:`h-8 text-xs`,disabled:!v.isDirty||v.saving,onClick:()=>void O(),children:v.saving?t.saving:t.save})]})]}),(0,P.jsx)(j,{schema:h,values:v.localValues,onChange:T,disabled:v.saving})]})}function te(){let e=(0,M.c)(47),t=l(ne),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n,o=r.extensionImageGen,c=r.extensionSttMedia,{extensionId:u,panelId:d}=a(),f=v();if(!u){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,P.jsx)($,{message:`No extension ID provided.`}),e[2]=t):t=e[2],t}let p,m,h;if(e[3]!==u||e[4]!==f||e[5]!==d){h=Symbol.for(`react.early_return_sentinel`);bb0:{let t;if(e[9]===u?t=e[10]:(t=e=>e.id===u,e[9]=u,e[10]=t),p=f.find(t),!p){let t=`Extension "${u}" not found or is not available in this workspace.`,n;e[11]===t?n=e[12]:(n=(0,P.jsx)($,{message:t}),e[11]=t,e[12]=n),h=n;break bb0}let n=p.ui?.contributions?.settingsPanels;m=d?n?.find(e=>e.id===d||e.id===`${u}.${d}`):n?.[0]}e[3]=u,e[4]=f,e[5]=d,e[6]=p,e[7]=m,e[8]=h}else p=e[6],m=e[7],h=e[8];if(h!==Symbol.for(`react.early_return_sentinel`))return h;let _=m,y=!!(_&&p.ui),b=!!p.hasConfigSchema,x=p.kind===`image-generation`,S=p.kind===`media-provider`;if(!b&&!y&&!(x||S)){let t=`Extension "${u}" has no settings panels or config schema.`,n;return e[13]===t?n=e[14]:(n=(0,P.jsx)($,{message:t}),e[13]=t,e[14]=n),n}let C=_?.title??`${p.name} Settings`,w;e[15]===C?w=e[16]:(w=(0,P.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:C}),e[15]=C,e[16]=w);let T;e[17]!==x||e[18]!==r.imageModelsSettings||e[19]!==o?(T=x?(0,P.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base px-4 py-3 text-sm`,children:[(0,P.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:o.banner}),(0,P.jsx)(i,{to:`/settings/capabilities/image`,className:`w-fit font-medium text-accent hover:underline`,title:r.imageModelsSettings.imageModelsLinkTitle,children:o.openImageModels})]}):null,e[17]=x,e[18]=r.imageModelsSettings,e[19]=o,e[20]=T):T=e[20];let E;e[21]!==u||e[22]!==x?(E=x?(0,P.jsx)(L,{extensionId:u}):null,e[21]=u,e[22]=x,e[23]=E):E=e[23];let D;e[24]!==S||e[25]!==c?(D=S?(0,P.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base px-4 py-3 text-sm`,children:[(0,P.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:c.banner}),(0,P.jsx)(i,{to:`/settings/capabilities/voice`,className:`w-fit font-medium text-accent hover:underline`,children:c.openVoice})]}):null,e[24]=S,e[25]=c,e[26]=D):D=e[26];let O;e[27]!==u||e[28]!==S?(O=S?(0,P.jsx)(K,{extensionId:u}):null,e[27]=u,e[28]=S,e[29]=O):O=e[29];let k;e[30]!==u||e[31]!==b?(k=b?(0,P.jsx)(Q,{extensionId:u}):null,e[30]=u,e[31]=b,e[32]=k):k=e[32];let A;e[33]!==p.name||e[34]!==p.ui||e[35]!==u||e[36]!==y||e[37]!==_?(A=y&&_&&p.ui?(0,P.jsx)(`div`,{className:`overflow-hidden rounded-xl bg-surface-base shadow-surface`,children:(0,P.jsx)(g,{extensionId:u,extensionName:p.name,entrypoint:_.entrypoint,permissions:p.ui?.permissions,title:_.title,className:`w-full`,minHeight:120,maxHeight:2e3})}):null,e[33]=p.name,e[34]=p.ui,e[35]=u,e[36]=y,e[37]=_,e[38]=A):A=e[38];let j;return e[39]!==w||e[40]!==T||e[41]!==E||e[42]!==D||e[43]!==O||e[44]!==k||e[45]!==A?(j=(0,P.jsxs)(`div`,{className:`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,children:[w,T,E,D,O,k,A]}),e[39]=w,e[40]=T,e[41]=E,e[42]=D,e[43]=O,e[44]=k,e[45]=A,e[46]=j):j=e[46],j}function ne(e){return e.language}function $(e){let t=(0,M.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,P.jsx)(`div`,{className:`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,children:(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{te as ExtensionSettingsPage};
@@ -1 +0,0 @@
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"./cn-JdwAhgNB.js";import{t as i}from"./messages-BwQ3WssU.js";import{n as a}from"./locale-store-0lpYdNDr.js";import{Bo as o,Bs as s,Ds as c,Ho as l,Lt as u,Mr as d,Nc as f,Ro as p,Uo as ee,Vo as m,Wo as h,dt as g,ec as _,jr as v,ns as y,rs as b,sc as x,ts as S,uu as C,wc as w,ws as T}from"./index-C8JkTS6d.js";var E=e(t(),1);function D(){return{title:``,objective:``,description:``,attachments:[],checklist:[``],scopeBoundary:``,evidencePlan:[``],priority:`normal`,deadlineMode:`none`,deadline:``,maxTurns:`10`,agentId:``,judgeModelRef:``}}function O(e){let t=new Set,n=[];for(let r of e){let e=r.trim(),i=e.toLowerCase();!e||t.has(i)||(t.add(i),n.push(e))}return n}var k=n();function A(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function j(e){let t=e=>String(e).padStart(2,`0`);return[e.getFullYear(),`-`,t(e.getMonth()+1),`-`,t(e.getDate()),`T`,t(e.getHours()),`:`,t(e.getMinutes())].join(``)}function M(e){let t=new Date;return t.setDate(t.getDate()+e),t.setHours(23,59,0,0),j(t)}function N(){let e=new Date,t=e.getDay(),n=t<=5?5-t:7-t+5;return e.setDate(e.getDate()+n),e.setHours(23,59,0,0),j(e)}function P(e){if(e===`today`)return M(0);if(e===`tomorrow`)return M(1);if(e===`friday`)return N();if(e===`custom`){let e=new Date;return e.setHours(e.getHours()+1,0,0,0),j(e)}return``}function F({open:e,t,chat:n,busy:j,options:M,onClose:N,onCreate:F,onDraftContract:I}){let L=i(a(e=>e.language)).agentsSettings,[R,z]=(0,E.useState)(()=>D()),[B,V]=(0,E.useState)(!1),[H,U]=(0,E.useState)(!1),[W,G]=(0,E.useState)(null),[K,q]=(0,E.useState)(!1),J=g({chat:n});(0,E.useEffect)(()=>{e||(z(D()),V(!1),U(!1),G(null),q(!1),J.clearAttachments())},[J.clearAttachments,e]),(0,E.useEffect)(()=>{!e||!M.defaultAgentId||z(e=>e.agentId?e:{...e,agentId:M.defaultAgentId})},[e,M.defaultAgentId]);let Y=e=>z(t=>({...t,...e})),X=M.agents.length?M.agents:[{id:M.defaultAgentId||`main`,workspace:``,profileDir:``,typedModels:{defaultRole:`deep`,preset:[],effective:[]},extends:[],isDefault:!0,skills:{preset:[]},tools:{presetDenied:[],entryDisable:[],effectiveDisable:[]}}],Z=X.find(e=>e.id===R.agentId)??X.find(e=>e.id===M.defaultAgentId)??X[0],Q=Z?v(Z,L):``,te=R.agentId||Z?.id||`main`,$=[...Z?.typedModels.effective??[]].sort((e,t)=>e.id===`judge`?-1:t.id===`judge`?1:e.id.localeCompare(t.id)),ne=M.models.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t),re=e=>{Y({deadlineMode:e,deadline:P(e)})},ie=(e,t)=>{z(n=>({...n,checklist:n.checklist.map((n,r)=>r===e?t:n)}))},ae=e=>{z(t=>({...t,checklist:t.checklist.filter((t,n)=>n!==e)}))},oe=(e,t)=>{z(n=>({...n,evidencePlan:n.evidencePlan.map((n,r)=>r===e?t:n)}))},se=e=>{z(t=>({...t,evidencePlan:t.evidencePlan.filter((t,n)=>n!==e)}))},ce=async()=>{G(null),q(!0);try{Y(I?await I({...R,attachments:J.wireAttachmentsPayload()}):{objective:R.objective||R.title,scopeBoundary:R.scopeBoundary,evidencePlan:O(R.evidencePlan).length?R.evidencePlan:[...t.createDialog.defaultEvidencePlan],checklist:R.checklist}),V(!0)}catch(e){G(e instanceof Error?e.message:t.createDialog.draftFailed)}finally{q(!1)}},le=async()=>{if(G(null),!R.title.trim()){G(t.createDialog.titleRequired);return}try{await F({...R,attachments:J.wireAttachmentsPayload(),checklist:O(R.checklist)}),N()}catch(e){G(e instanceof Error?e.message:t.errors.create)}};return(0,k.jsx)(p,{open:e,onOpenChange:e=>!e&&N(),children:(0,k.jsxs)(ee,{children:[(0,k.jsx)(l,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,k.jsxs)(o,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(92vh,46rem)] w-[min(100%-2rem,44rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[(0,k.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-5 py-4`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(h,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.createDialog.title}),(0,k.jsx)(m,{className:`mt-1 truncate text-sm text-fg-muted`,children:t.createDialog.description})]}),(0,k.jsx)(T,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":t.closeDetails,onClick:N,children:(0,k.jsx)(c,{className:`size-5`,"aria-hidden":!0})})]}),(0,k.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,k.jsxs)(`div`,{className:`grid gap-4`,children:[(0,k.jsx)(`section`,{className:`rounded-lg border border-accent/25 bg-accent-soft/50 p-3`,children:(0,k.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.createDialog.simpleStartTitle}),(0,k.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.createDialog.simpleStartHint})]}),(0,k.jsxs)(T,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 rounded-lg text-xs`,onClick:()=>void ce(),disabled:K||!R.title.trim()&&!R.description.trim(),children:[(0,k.jsx)(_,{className:`size-3.5`,"aria-hidden":!0}),K?t.createDialog.drafting:t.createDialog.aiDraft]})]})}),(0,k.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.goalTitle}),(0,k.jsx)(`input`,{value:R.title,onChange:e=>Y({title:e.target.value}),placeholder:t.newGoalPlaceholder,className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,k.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.goalDescription}),(0,k.jsxs)(T,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg text-xs`,onClick:()=>J.fileInputRef.current?.click(),children:[(0,k.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.addAttachment]})]}),(0,k.jsx)(`textarea`,{value:R.description,onChange:e=>Y({description:e.target.value}),placeholder:t.createDialog.descriptionPlaceholder,rows:4,className:`resize-none rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`}),(0,k.jsx)(`input`,{ref:J.fileInputRef,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{let t=Array.from(e.currentTarget.files??[]);e.currentTarget.value=``,J.processFiles(t)}}),(0,k.jsx)(u,{attachments:J.attachments,topPadded:!1,onRemove:J.removeAttachment})]}),(0,k.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base/60`,children:[(0,k.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-4 py-3 text-left`,onClick:()=>V(e=>!e),children:[(0,k.jsxs)(`span`,{className:`min-w-0`,children:[(0,k.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:t.createDialog.completionPlan}),(0,k.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.createDialog.completionPlanHint})]}),(0,k.jsx)(C,{className:r(`size-4 shrink-0 text-fg-muted transition-transform`,B&&`rotate-180`),"aria-hidden":!0})]}),B?(0,k.jsxs)(`div`,{className:`grid gap-4 border-t border-edge-subtle p-4`,children:[(0,k.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/70 p-3`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.createDialog.criteriaTitle}),(0,k.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.createDialog.criteriaHint}),(0,k.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:M.checklistDecomposePolicy===`supplement_existing`?t.createDialog.checklistPolicySupplementExisting:t.createDialog.checklistPolicyEmptyOnly})]}),(0,k.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[R.checklist.map((e,n)=>(0,k.jsxs)(`div`,{className:`flex gap-2`,children:[(0,k.jsx)(`input`,{value:e,onChange:e=>ie(n,e.target.value),placeholder:A(t.createDialog.criteriaPlaceholder,{index:n+1}),className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`}),(0,k.jsx)(T,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 rounded-lg p-0`,"aria-label":t.createDialog.removeCriteria,onClick:()=>ae(n),children:(0,k.jsx)(s,{className:`size-4`,"aria-hidden":!0})})]},n)),(0,k.jsxs)(T,{type:`button`,variant:`ghost`,className:`h-8 justify-start rounded-lg text-xs`,onClick:()=>Y({checklist:[...R.checklist,``]}),children:[(0,k.jsx)(w,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.addCriteria]})]})]}),(0,k.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/70 p-3`,children:[(0,k.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.createDialog.contractTitle}),(0,k.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.createDialog.contractHint}),(0,k.jsxs)(`label`,{className:`mt-3 grid gap-1.5`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.objective}),(0,k.jsx)(`textarea`,{value:R.objective,onChange:e=>Y({objective:e.target.value}),placeholder:t.createDialog.objectivePlaceholder,rows:2,className:`resize-none rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,k.jsxs)(`label`,{className:`mt-3 grid gap-1.5`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.scopeBoundary}),(0,k.jsx)(`textarea`,{value:R.scopeBoundary,onChange:e=>Y({scopeBoundary:e.target.value}),placeholder:t.createDialog.scopeBoundaryPlaceholder,rows:2,className:`resize-none rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,k.jsxs)(`div`,{className:`mt-3 grid gap-1.5`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.evidencePlan}),(0,k.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.createDialog.evidencePlanHint}),R.evidencePlan.map((e,n)=>(0,k.jsxs)(`div`,{className:`flex gap-2`,children:[(0,k.jsx)(`input`,{value:e,onChange:e=>oe(n,e.target.value),placeholder:A(t.createDialog.evidencePlanPlaceholder,{index:n+1}),className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`}),(0,k.jsx)(T,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 rounded-lg p-0`,"aria-label":t.createDialog.removeEvidence,onClick:()=>se(n),children:(0,k.jsx)(s,{className:`size-4`,"aria-hidden":!0})})]},n)),(0,k.jsxs)(T,{type:`button`,variant:`ghost`,className:`h-8 justify-start rounded-lg text-xs`,onClick:()=>Y({evidencePlan:[...R.evidencePlan,``]}),children:[(0,k.jsx)(w,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.addEvidence]})]})]})]}):null]}),(0,k.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base/60`,children:[(0,k.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-4 py-3 text-left`,onClick:()=>U(e=>!e),children:[(0,k.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,k.jsx)(x,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t.createDialog.advanced]}),(0,k.jsx)(C,{className:r(`size-4 text-fg-muted transition-transform`,H&&`rotate-180`),"aria-hidden":!0})]}),H?(0,k.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-4 sm:grid-cols-2`,children:[(0,k.jsxs)(`label`,{className:`grid gap-1.5 sm:col-span-2`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.agentId}),(0,k.jsx)(S,{value:te,onChange:e=>Y({agentId:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:X.map(e=>(0,k.jsx)(b,{value:e.id,children:d(e,L)+(e.isDefault?` · ${t.createDialog.defaultAgent}`:` · ${e.id}`)},e.id))}),Q?(0,k.jsx)(`span`,{className:`line-clamp-2 text-xs text-fg-muted`,children:Q}):Z?.model?.primary?(0,k.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:A(t.createDialog.agentPrimaryModel,{model:Z.model.primary})}):null]}),(0,k.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.priority}),(0,k.jsxs)(S,{value:R.priority,onChange:e=>Y({priority:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:[(0,k.jsx)(b,{value:`normal`,children:t.priorities.normal}),(0,k.jsx)(b,{value:`high`,children:t.priorities.high}),(0,k.jsx)(b,{value:`low`,children:t.priorities.low})]})]}),(0,k.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.deadline}),(0,k.jsxs)(S,{value:R.deadlineMode,onChange:e=>re(e.target.value),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:[(0,k.jsx)(b,{value:`none`,children:t.createDialog.deadlineNone}),(0,k.jsx)(b,{value:`today`,children:t.createDialog.deadlineToday}),(0,k.jsx)(b,{value:`tomorrow`,children:t.createDialog.deadlineTomorrow}),(0,k.jsx)(b,{value:`friday`,children:t.createDialog.deadlineFriday}),(0,k.jsx)(b,{value:`custom`,children:t.createDialog.deadlineCustom})]})]}),R.deadlineMode===`none`?null:(0,k.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.deadlineAt}),(0,k.jsx)(`input`,{type:`datetime-local`,value:R.deadline,onChange:e=>Y({deadline:e.target.value,deadlineMode:`custom`}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,k.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.maxTurns}),(0,k.jsx)(`input`,{type:`number`,min:1,max:500,value:R.maxTurns,onChange:e=>Y({maxTurns:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,k.jsxs)(`label`,{className:`grid gap-1.5 sm:col-span-2`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.judgeModel}),(0,k.jsxs)(S,{value:R.judgeModelRef,onChange:e=>Y({judgeModelRef:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:[(0,k.jsx)(b,{value:``,children:t.createDialog.judgeModelPlaceholder}),$.length?(0,k.jsx)(y,{label:t.createDialog.agentModelRoles,children:$.map(e=>(0,k.jsxs)(b,{value:e.model,children:[e.id===`judge`?t.createDialog.judgeRole:e.id,` · `,e.model]},`${e.id}:${e.model}`))}):null,(0,k.jsx)(y,{label:t.createDialog.configuredModels,children:ne.map(e=>(0,k.jsxs)(b,{value:e.id,children:[e.name,` · `,e.id]},e.id))})]})]})]}):null]}),W?(0,k.jsx)(`p`,{className:`rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:W}):null]})}),(0,k.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,k.jsx)(T,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:N,children:t.createDialog.cancel}),(0,k.jsxs)(T,{type:`button`,variant:`primary`,className:`rounded-lg`,disabled:j||!R.title.trim(),onClick:()=>void le(),children:[(0,k.jsx)(w,{className:`size-4`,"aria-hidden":!0}),t.createDialog.create]})]})]})]})})}export{O as n,F as t};
@@ -1,4 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,l as a,t as o,u as s}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as c}from"./cn-JdwAhgNB.js";import{t as l}from"./messages-BwQ3WssU.js";import{n as u,r as d,s as f}from"./locale-store-0lpYdNDr.js";import{$ as p,$l as m,Bs as h,Cl as g,Dt as _,Eu as v,Ll as y,Ml as b,Qa as x,Us as S,Ws as C,_ as w,_c as T,_u as E,au as D,bo as O,cu as ee,dc as k,et as A,eu as j,ft as M,iu as te,jl as N,ju as P,ku as F,ou as ne,ql as I,rs as L,tl as R,ts as z,vt as re,wc as ie,wl as ae,ws as B,wt as oe,y as se,yt as ce,zs as le}from"./index-C8JkTS6d.js";import{t as ue}from"./automation-suggestion-card-Dw49OJRl.js";var de=n(),V=e(t(),1),H=r();function fe(e){return e.split(`
2
- `).map(e=>e.trim()).filter(Boolean)}function pe(){let e=(0,de.c)(7),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(x,{className:`h-5 w-20 rounded-full`}),(0,H.jsx)(x,{className:`h-4 w-28`}),(0,H.jsx)(x,{className:`h-4 w-24`})]}),n=(0,H.jsx)(x,{className:`mt-4 h-4 w-full max-w-3xl`}),r=(0,H.jsx)(x,{className:`mt-2 h-4 w-2/3 max-w-2xl`}),e[0]=t,e[1]=n,e[2]=r):(t=e[0],n=e[1],r=e[2]);let i;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,H.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[t,n,r,(0,H.jsxs)(`div`,{className:`mt-4 grid gap-3 md:grid-cols-3`,children:[(0,H.jsx)(x,{className:`h-16 rounded-md`}),(0,H.jsx)(x,{className:`h-16 rounded-md`}),(0,H.jsx)(x,{className:`h-16 rounded-md`})]})]}),e[3]=i):i=e[3];let a;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,H.jsx)(x,{className:`h-4 w-32`}),e[4]=a):a=e[4];let o;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,H.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[a,(0,H.jsx)(`div`,{className:`mt-4 grid gap-3`,children:Array.from({length:5}).map(U)})]}),e[5]=o):o=e[5];let s;return e[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,H.jsxs)(`div`,{className:`grid gap-4`,"aria-hidden":`true`,children:[i,(0,H.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[o,(0,H.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,H.jsx)(x,{className:`h-4 w-28`}),(0,H.jsx)(x,{className:`mt-4 h-24 rounded-md`}),(0,H.jsx)(x,{className:`mt-3 h-24 rounded-md`})]})]})]}),e[6]=s):s=e[6],s}function U(e,t){return(0,H.jsx)(x,{className:`h-14 rounded-md`},t)}var W=`min-w-0 rounded-md border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,me=[`message`,`link`,`file`,`diff`,`command`,`test`,`artifact`];function he(e){return e===`command`||e===`test`?S:e===`diff`?I:e===`file`||e===`artifact`?N:e===`link`?y:k}function ge(e){return e.data&&typeof e.data==`object`&&!Array.isArray(e.data)?e.data:{}}function G(e,t){let n=e[t];return typeof n==`string`&&n.trim()?n:void 0}function K(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function _e(e){let t=(0,de.c)(57),{item:n,language:r,t:i}=e,a;t[0]===n.kind?a=t[1]:(a=he(n.kind),t[0]=n.kind,t[1]=a);let o=a,s,c,l,u,d,f,p,m,h;if(t[2]!==o||t[3]!==n||t[4]!==r||t[5]!==i){let e=ge(n),a=G(e,`command`),g=K(e,`exitCode`),_=G(e,`path`)||n.uri,v=K(e,`outputBytes`);s=e.fuzzyMatchUsed===!0,f=`rounded-md bg-surface-muted/40 px-2.5 py-2`;let y;t[15]===o?y=t[16]:(y=(0,H.jsx)(o,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),t[15]=o,t[16]=y);let b;t[17]===n.title?b=t[18]:(b=(0,H.jsx)(`p`,{className:`break-words font-medium text-fg`,children:n.title}),t[17]=n.title,t[18]=b);let x=_?(0,H.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:_}):null,S;t[19]!==b||t[20]!==x?(S=(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[b,x]}),t[19]=b,t[20]=x,t[21]=S):S=t[21];let C;t[22]!==y||t[23]!==S?(C=(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[y,S]}),t[22]=y,t[23]=S,t[24]=C):C=t[24];let w;t[25]!==n.kind||t[26]!==i?(w=Oe(n.kind,i),t[25]=n.kind,t[26]=i,t[27]=w):w=t[27];let T;t[28]===w?T=t[29]:(T=(0,H.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:w}),t[28]=w,t[29]=T),t[30]!==C||t[31]!==T?(p=(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[C,T]}),t[30]=C,t[31]=T,t[32]=p):p=t[32],m=a?(0,H.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded-md bg-surface-panel px-2 py-1.5 text-xs text-fg`,children:(0,H.jsx)(`code`,{children:a})}):null,t[33]!==n.kind||t[34]!==n.summary?(h=n.summary?n.kind===`diff`?(0,H.jsx)(`pre`,{className:`mt-2 max-h-56 overflow-auto whitespace-pre-wrap rounded-md bg-surface-panel px-2 py-1.5 text-xs text-fg-muted`,children:(0,H.jsx)(`code`,{children:n.summary})}):(0,H.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-xs text-fg-muted`,children:n.summary}):null,t[33]=n.kind,t[34]=n.summary,t[35]=h):h=t[35],c=`mt-2 flex flex-wrap items-center gap-2 text-xs text-fg-muted`;let E;t[36]!==n.createdAt||t[37]!==r||t[38]!==i?(E=xe(n.createdAt,r,i),t[36]=n.createdAt,t[37]=r,t[38]=i,t[39]=E):E=t[39],t[40]===E?l=t[41]:(l=(0,H.jsx)(`time`,{children:E}),t[40]=E,t[41]=l),u=g==null?null:(0,H.jsx)(`span`,{children:q(i.exitCode,{code:g})}),d=v==null?null:(0,H.jsx)(`span`,{children:q(i.outputBytes,{bytes:v})}),t[2]=o,t[3]=n,t[4]=r,t[5]=i,t[6]=s,t[7]=c,t[8]=l,t[9]=u,t[10]=d,t[11]=f,t[12]=p,t[13]=m,t[14]=h}else s=t[6],c=t[7],l=t[8],u=t[9],d=t[10],f=t[11],p=t[12],m=t[13],h=t[14];let g;t[42]!==s||t[43]!==i?(g=s?(0,H.jsx)(`span`,{children:i.fuzzyMatch}):null,t[42]=s,t[43]=i,t[44]=g):g=t[44];let _;t[45]!==g||t[46]!==c||t[47]!==l||t[48]!==u||t[49]!==d?(_=(0,H.jsxs)(`div`,{className:c,children:[l,u,d,g]}),t[45]=g,t[46]=c,t[47]=l,t[48]=u,t[49]=d,t[50]=_):_=t[50];let v;return t[51]!==_||t[52]!==f||t[53]!==p||t[54]!==m||t[55]!==h?(v=(0,H.jsxs)(`li`,{className:f,children:[p,m,h,_]}),t[51]=_,t[52]=f,t[53]=p,t[54]=m,t[55]=h,t[56]=v):v=t[56],v}function ve(e){return e===`active`?`border-accent/40 bg-accent-soft text-accent-fg`:e===`done`?`border-edge bg-surface-muted text-fg-muted`:e===`blocked`||e===`needs_input`?`border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300`:`border-edge bg-surface-panel text-fg-muted`}function ye(e){return e===`succeeded`?`border-emerald-500/40 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`failed`||e===`timeout`?`border-destructive/40 bg-destructive/10 text-destructive`:e===`cancelled`?`border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300`:`border-accent/40 bg-accent-soft text-accent-fg`}function be(e){return e===`workflow_run`?g:e===`goal_run`?E:e===`queue`?te:e===`evidence`?N:P}function q(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function J(e){return e===`zh`?`zh-CN`:`en-US`}function xe(e,t,n){return e?A(e,J(t)):n.notSet}function Se(e,t,n){return e?p(e,J(t)):n.noDeadline}function Ce(e,t){return e===`blocked`||e===`needs_input`?t.primaryActions.resolveBlocker:e===`paused`?t.primaryActions.resume:e===`done`?t.primaryActions.completed:e===`archived`?t.primaryActions.archived:t.primaryActions.continue}function we(e){return e===`completed`?`✓`:e===`impossible`?`!`:`○`}function Te(e){return e===`all`||e===`queue`||e===`goal_run`||e===`workflow_run`||e===`event`||e===`evidence`}function Ee(e,t){return e?t.statuses[e]??e:``}function De(e,t){return t.priorities[e]??e}function Oe(e,t){return t.evidenceKinds[e]??e}function ke(e){return!e||e.currentValue==null?!1:e.direction===`increase`?e.currentValue>=e.targetValue:e.currentValue<=e.targetValue}function Ae(e){if(!e.trim())return;let t=Number(e);return Number.isFinite(t)?t:void 0}function je(e,t,n){let r=e.evidenceRequirements.some(e=>e.status!==`approved`),i=!!(e.contract?.outcomeMetric&&!ke(e.contract.outcomeMetric));if(e.status===`done`&&(r||i||t?.verdict===`continue`))return{title:n.progressPanel.executionFinishedTitle,body:n.progressPanel.executionFinishedFallback,tone:`attention`,needsReview:!0};if(e.status===`blocked`)return{title:n.progressPanel.blockedTitle,body:e.blockedReason||n.progressPanel.blockedFallback,tone:`attention`,needsReview:!1};if(e.status===`needs_input`){let t=e.blockedReason?.startsWith(`Completion review required`);return{title:t?n.progressPanel.executionFinishedTitle:n.progressPanel.needsInputTitle,body:t?n.progressPanel.executionFinishedFallback:e.blockedReason||e.nextAction||n.progressPanel.needsInputFallback,tone:`attention`,needsReview:!!t}}return e.status===`paused`?{title:n.progressPanel.pausedTitle,body:e.blockedReason||n.progressPanel.pausedFallback,tone:`normal`,needsReview:!1}:e.status===`done`?{title:n.progressPanel.doneTitle,body:n.progressPanel.doneFallback,tone:`done`,needsReview:!1}:e.status===`archived`?{title:n.progressPanel.archivedTitle,body:n.progressPanel.archivedFallback,tone:`normal`,needsReview:!1}:{title:n.progressPanel.activeTitle,body:e.nextAction||n.noNextAction,tone:`normal`,needsReview:!1}}function Me(e,t){return t<=0?0:Math.min(100,Math.max(0,Math.round(e/t*100)))}function Ne(e){let t=(0,de.c)(210),{goal:n,latestRun:r,done:i,total:a,evidence:o,language:s,t:l,busy:u,primaryActionDisabled:d,onContinue:f,onOpenChat:p,onPause:m,onConfigureOutcome:h,onReviewEvidence:g}=e,_;t[0]!==n||t[1]!==r||t[2]!==l?(_=je(n,r,l),t[0]=n,t[1]=r,t[2]=l,t[3]=_):_=t[3];let v=_,b,x,S,w,T,E,O,k,A,j,M,N,P,F;if(t[4]!==i||t[5]!==o||t[6]!==n.contract?.outcomeMetric||t[7]!==n.deadlineAt||t[8]!==n.evidenceRequirements||t[9]!==n.priority||t[10]!==n.status||t[11]!==s||t[12]!==r||t[13]!==g||t[14]!==v.body||t[15]!==v.needsReview||t[16]!==v.title||t[17]!==v.tone||t[18]!==l||t[19]!==a){let e=n.evidenceRequirements.filter(Ie).length,u=n.evidenceRequirements.length,d,f,p,m,h;if(t[34]!==i||t[35]!==n.contract?.outcomeMetric||t[36]!==n.deadlineAt||t[37]!==n.evidenceRequirements||t[38]!==n.priority||t[39]!==n.status||t[40]!==s||t[41]!==r||t[42]!==v.body||t[43]!==v.needsReview||t[44]!==v.title||t[45]!==v.tone||t[46]!==l||t[47]!==a){x=n.evidenceRequirements.filter(Fe).slice(0,2);let e;t[58]!==i||t[59]!==a?(e=Me(i,a),t[58]=i,t[59]=a,t[60]=e):e=t[60],d=e,b=n.contract?.outcomeMetric,S=ke(b);let o=v.tone===`attention`?le:v.tone===`done`?ne:te;E=`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,w=`grid gap-5`,f=`min-w-0`;let u;t[61]!==n.status||t[62]!==v.needsReview?(u=c(`rounded-full border px-2 py-0.5 text-xs`,ve(v.needsReview?`needs_input`:n.status)),t[61]=n.status,t[62]=v.needsReview,t[63]=u):u=t[63];let g;t[64]!==n.status||t[65]!==v.needsReview||t[66]!==l?(g=v.needsReview?l.progressPanel.reviewPendingLabel:Ee(n.status,l),t[64]=n.status,t[65]=v.needsReview,t[66]=l,t[67]=g):g=t[67];let _;t[68]!==u||t[69]!==g?(_=(0,H.jsx)(`span`,{className:u,children:g}),t[68]=u,t[69]=g,t[70]=_):_=t[70];let y;t[71]!==n.priority||t[72]!==l?(y=q(l.prioritySummary,{priority:De(n.priority,l)}),t[71]=n.priority,t[72]=l,t[73]=y):y=t[73];let C;t[74]===y?C=t[75]:(C=(0,H.jsx)(`span`,{className:`text-xs text-fg-muted`,children:y}),t[74]=y,t[75]=C);let T;t[76]!==n.deadlineAt||t[77]!==s||t[78]!==l?(T=n.deadlineAt?Se(n.deadlineAt,s,l):l.noDeadline,t[76]=n.deadlineAt,t[77]=s,t[78]=l,t[79]=T):T=t[79];let D;t[80]===T?D=t[81]:(D=(0,H.jsx)(`span`,{className:`text-xs text-fg-muted`,children:T}),t[80]=T,t[81]=D),t[82]!==_||t[83]!==C||t[84]!==D?(p=(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[_,C,D]}),t[82]=_,t[83]=C,t[84]=D,t[85]=p):p=t[85];let O=v.tone===`attention`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:v.tone===`done`?`bg-success-soft text-success`:`bg-accent-soft text-accent-fg`,ee;t[86]===O?ee=t[87]:(ee=c(`mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-lg`,O),t[86]=O,t[87]=ee);let k;t[88]===o?k=t[89]:(k=(0,H.jsx)(o,{className:`size-5`,"aria-hidden":!0}),t[88]=o,t[89]=k);let A;t[90]!==ee||t[91]!==k?(A=(0,H.jsx)(`div`,{className:ee,children:k}),t[90]=ee,t[91]=k,t[92]=A):A=t[92];let j;t[93]===v.title?j=t[94]:(j=(0,H.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:v.title}),t[93]=v.title,t[94]=j);let M;t[95]===v.body?M=t[96]:(M=(0,H.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:v.body}),t[95]=v.body,t[96]=M);let N;t[97]!==s||t[98]!==r||t[99]!==l?(N=r?.reason?(0,H.jsx)(`p`,{className:`mt-2 line-clamp-2 break-words text-xs text-fg-subtle`,children:q(l.progressPanel.lastCheck,{time:xe(r.finishedAt??r.startedAt,s,l),reason:r.reason})}):null,t[97]=s,t[98]=r,t[99]=l,t[100]=N):N=t[100];let P;t[101]!==j||t[102]!==M||t[103]!==N?(P=(0,H.jsxs)(`div`,{className:`min-w-0`,children:[j,M,N]}),t[101]=j,t[102]=M,t[103]=N,t[104]=P):P=t[104],t[105]!==A||t[106]!==P?(m=(0,H.jsxs)(`div`,{className:`mt-3 flex items-start gap-3`,children:[A,P]}),t[105]=A,t[106]=P,t[107]=m):m=t[107],h=x.length?(0,H.jsxs)(`div`,{className:`mt-4 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium text-amber-800 dark:text-amber-200`,children:l.progressPanel.evidenceNeeded}),(0,H.jsx)(`ul`,{className:`mt-1 grid gap-1 text-xs text-amber-800 dark:text-amber-200`,children:x.map(Pe)})]}):null,t[34]=i,t[35]=n.contract?.outcomeMetric,t[36]=n.deadlineAt,t[37]=n.evidenceRequirements,t[38]=n.priority,t[39]=n.status,t[40]=s,t[41]=r,t[42]=v.body,t[43]=v.needsReview,t[44]=v.title,t[45]=v.tone,t[46]=l,t[47]=a,t[48]=d,t[49]=b,t[50]=x,t[51]=S,t[52]=w,t[53]=E,t[54]=f,t[55]=p,t[56]=m,t[57]=h}else d=t[48],b=t[49],x=t[50],S=t[51],w=t[52],E=t[53],f=t[54],p=t[55],m=t[56],h=t[57];t[108]!==f||t[109]!==p||t[110]!==m||t[111]!==h?(T=(0,H.jsxs)(`div`,{className:f,children:[p,m,h]}),t[108]=f,t[109]=p,t[110]=m,t[111]=h,t[112]=T):T=t[112],P=`grid gap-3 md:grid-cols-3`;let _;t[113]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,H.jsx)(ae,{className:`size-4`,"aria-hidden":!0}),t[113]=_):_=t[113];let y;t[114]===l.progressPanel.execution?y=t[115]:(y=(0,H.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[_,l.progressPanel.execution]}),t[114]=l.progressPanel.execution,t[115]=y);let C;t[116]!==i||t[117]!==l.checklistProgress||t[118]!==l.notSet||t[119]!==a?(C=a?q(l.checklistProgress,{done:i,total:a}):l.notSet,t[116]=i,t[117]=l.checklistProgress,t[118]=l.notSet,t[119]=a,t[120]=C):C=t[120];let D;t[121]===C?D=t[122]:(D=(0,H.jsx)(`p`,{className:`mt-2 text-lg font-semibold tabular-nums text-fg`,children:C}),t[121]=C,t[122]=D);let I=`${d}%`,L;t[123]===I?L=t[124]:(L=(0,H.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-surface-hover`,children:(0,H.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:I}})}),t[123]=I,t[124]=L),t[125]!==y||t[126]!==D||t[127]!==L?(F=(0,H.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/70 p-3`,children:[y,D,L]}),t[125]=y,t[126]=D,t[127]=L,t[128]=F):F=t[128],A=`button`,j=`rounded-lg border border-edge-subtle bg-surface-panel/70 p-3 text-left transition-colors hover:bg-surface-hover`,M=g;let R;t[129]===l.progressPanel.evidence?R=t[130]:(R=(0,H.jsx)(`span`,{children:l.progressPanel.evidence}),t[129]=l.progressPanel.evidence,t[130]=R);let z;t[131]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,H.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),t[131]=z):z=t[131],t[132]===R?N=t[133]:(N=(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs font-medium text-fg-muted`,children:[R,z]}),t[132]=R,t[133]=N),O=`mt-2 text-lg font-semibold tabular-nums text-fg`,k=u?q(l.evidenceRequirementProgress,{approved:e,total:u}):q(l.progressPanel.evidenceCount,{count:o.length}),t[4]=i,t[5]=o,t[6]=n.contract?.outcomeMetric,t[7]=n.deadlineAt,t[8]=n.evidenceRequirements,t[9]=n.priority,t[10]=n.status,t[11]=s,t[12]=r,t[13]=g,t[14]=v.body,t[15]=v.needsReview,t[16]=v.title,t[17]=v.tone,t[18]=l,t[19]=a,t[20]=b,t[21]=x,t[22]=S,t[23]=w,t[24]=T,t[25]=E,t[26]=O,t[27]=k,t[28]=A,t[29]=j,t[30]=M,t[31]=N,t[32]=P,t[33]=F}else b=t[20],x=t[21],S=t[22],w=t[23],T=t[24],E=t[25],O=t[26],k=t[27],A=t[28],j=t[29],M=t[30],N=t[31],P=t[32],F=t[33];let I;t[134]!==O||t[135]!==k?(I=(0,H.jsx)(`p`,{className:O,children:k}),t[134]=O,t[135]=k,t[136]=I):I=t[136];let L=x.length?l.progressPanel.reviewNeeded:l.progressPanel.reviewComplete,R;t[137]===L?R=t[138]:(R=(0,H.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:L}),t[137]=L,t[138]=R);let z;t[139]!==I||t[140]!==R||t[141]!==A||t[142]!==j||t[143]!==M||t[144]!==N?(z=(0,H.jsxs)(`button`,{type:A,className:j,onClick:M,children:[N,I,R]}),t[139]=I,t[140]=R,t[141]=A,t[142]=j,t[143]=M,t[144]=N,t[145]=z):z=t[145];let re=b&&S?`border-success/30 bg-success-soft/40`:`border-edge-subtle bg-surface-panel/70`,ie;t[146]===re?ie=t[147]:(ie=c(`rounded-lg border p-3 text-left transition-colors hover:bg-surface-hover`,re),t[146]=re,t[147]=ie);let oe;t[148]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,H.jsx)(C,{className:`size-4`,"aria-hidden":!0}),t[148]=oe):oe=t[148];let se;t[149]===l.progressPanel.outcome?se=t[150]:(se=(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[oe,l.progressPanel.outcome]}),t[149]=l.progressPanel.outcome,t[150]=se);let ce;t[151]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,H.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),t[151]=ce):ce=t[151];let ue;t[152]===se?ue=t[153]:(ue=(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs font-medium text-fg-muted`,children:[se,ce]}),t[152]=se,t[153]=ue);let V;t[154]!==b||t[155]!==l.progressPanel.currentMissing||t[156]!==l.progressPanel.outcomeNotSet||t[157]!==l.progressPanel.outcomeSummary?(V=b?q(l.progressPanel.outcomeSummary,{baseline:b.baselineValue,current:b.currentValue??l.progressPanel.currentMissing,target:b.targetValue,unit:b.unit?` ${b.unit}`:``}):l.progressPanel.outcomeNotSet,t[154]=b,t[155]=l.progressPanel.currentMissing,t[156]=l.progressPanel.outcomeNotSet,t[157]=l.progressPanel.outcomeSummary,t[158]=V):V=t[158];let fe;t[159]===V?fe=t[160]:(fe=(0,H.jsx)(`p`,{className:`mt-2 truncate text-lg font-semibold tabular-nums text-fg`,children:V}),t[159]=V,t[160]=fe);let pe=b?b.name:l.progressPanel.outcomeNotSetHint,U;t[161]===pe?U=t[162]:(U=(0,H.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:pe}),t[161]=pe,t[162]=U);let W;t[163]!==h||t[164]!==ie||t[165]!==ue||t[166]!==fe||t[167]!==U?(W=(0,H.jsxs)(`button`,{type:`button`,className:ie,onClick:h,children:[ue,fe,U]}),t[163]=h,t[164]=ie,t[165]=ue,t[166]=fe,t[167]=U,t[168]=W):W=t[168];let me;t[169]!==z||t[170]!==W||t[171]!==P||t[172]!==F?(me=(0,H.jsxs)(`div`,{className:P,children:[F,z,W]}),t[169]=z,t[170]=W,t[171]=P,t[172]=F,t[173]=me):me=t[173];let he;t[174]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,H.jsx)(te,{className:`size-4`,"aria-hidden":!0}),t[174]=he):he=t[174];let ge;t[175]!==n.nextAction||t[176]!==n.status||t[177]!==v.needsReview||t[178]!==l?(ge=v.needsReview&&n.nextAction?l.progressPanel.continueExecution:Ce(n.status,l),t[175]=n.nextAction,t[176]=n.status,t[177]=v.needsReview,t[178]=l,t[179]=ge):ge=t[179];let G;t[180]!==f||t[181]!==d||t[182]!==ge?(G=(0,H.jsxs)(B,{type:`button`,variant:`primary`,className:`h-9 flex-1 rounded-lg`,disabled:d,onClick:f,children:[he,ge]}),t[180]=f,t[181]=d,t[182]=ge,t[183]=G):G=t[183];let K;t[184]!==x.length||t[185]!==g||t[186]!==l.progressPanel.reviewEvidenceAction?(K=x.length?(0,H.jsx)(B,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg`,onClick:g,children:l.progressPanel.reviewEvidenceAction}):null,t[184]=x.length,t[185]=g,t[186]=l.progressPanel.reviewEvidenceAction,t[187]=K):K=t[187];let _e;t[188]!==n.activeSessionKey||t[189]!==p||t[190]!==l.chat?(_e=n.activeSessionKey?(0,H.jsx)(B,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg px-2.5`,"aria-label":l.chat,onClick:p,children:(0,H.jsx)(y,{className:`size-4`,"aria-hidden":!0})}):null,t[188]=n.activeSessionKey,t[189]=p,t[190]=l.chat,t[191]=_e):_e=t[191];let ye=u!=null||n.status!==`active`,be;t[192]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,H.jsx)(D,{className:`size-4`,"aria-hidden":!0}),t[192]=be):be=t[192];let J;t[193]!==m||t[194]!==l.pause||t[195]!==ye?(J=(0,H.jsx)(B,{type:`button`,variant:`ghost`,className:`h-9 rounded-lg px-2.5`,"aria-label":l.pause,disabled:ye,onClick:m,children:be}),t[193]=m,t[194]=l.pause,t[195]=ye,t[196]=J):J=t[196];let we;t[197]!==G||t[198]!==K||t[199]!==_e||t[200]!==J?(we=(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-edge-subtle pt-4`,children:[G,K,_e,J]}),t[197]=G,t[198]=K,t[199]=_e,t[200]=J,t[201]=we):we=t[201];let Te;t[202]!==w||t[203]!==T||t[204]!==me||t[205]!==we?(Te=(0,H.jsxs)(`div`,{className:w,children:[T,me,we]}),t[202]=w,t[203]=T,t[204]=me,t[205]=we,t[206]=Te):Te=t[206];let Oe;return t[207]!==E||t[208]!==Te?(Oe=(0,H.jsx)(`section`,{className:E,children:Te}),t[207]=E,t[208]=Te,t[209]=Oe):Oe=t[209],Oe}function Pe(e){return(0,H.jsxs)(`li`,{className:`break-words`,children:[`- `,e.text]},e.id)}function Fe(e){return e.status!==`approved`}function Ie(e){return e.status===`approved`}function Le(e){let t=e?.trim();return!t||!t.startsWith(`/projects/`)||t.startsWith(`//`)||t.includes(`://`)?`/goals`:t}async function Re(e){return(await f(d(`/api/goals/${encodeURIComponent(e)}`))).goal}async function ze(e){return(await f(d(`/api/goals/${encodeURIComponent(e)}/runs?limit=100`))).runs}async function Be(e){return(await f(d(`/api/goals/${encodeURIComponent(e)}/evidence?limit=100`))).evidence}async function Ve(e){return(await f(d(`/api/goals/${encodeURIComponent(e)}/activity?limit=120`))).activities}async function He(e){return(await f(d(`/api/goals/${encodeURIComponent(e)}/workflow-suggestions`))).suggestions}function Ue(){let{goalId:e=``}=s(),t=a(),n=u(e=>e.language),r=l(n).goalDetailPage,p=l(n).automations.suggestions,S=O(e=>e.setPageHeader),E=O(e=>e.clearPageHeader),[D,k]=i(),[A,N]=(0,V.useState)(null),[I,ae]=(0,V.useState)([]),[le,de]=(0,V.useState)([]),[U,he]=(0,V.useState)([]),[K,ve]=(0,V.useState)([]),[J,Ce]=(0,V.useState)([]),[De,Me]=(0,V.useState)([]),[Pe,Fe]=(0,V.useState)(``),[Ie,Ue]=(0,V.useState)(`message`),[We,Ge]=(0,V.useState)(``),[Ke,qe]=(0,V.useState)(``),[Je,Ye]=(0,V.useState)(``),[Xe,Ze]=(0,V.useState)(``),[Qe,$e]=(0,V.useState)(``),[et,tt]=(0,V.useState)(``),[nt,rt]=(0,V.useState)(`normal`),[it,at]=(0,V.useState)(``),[ot,st]=(0,V.useState)(`10`),[ct,lt]=(0,V.useState)(``),[ut,dt]=(0,V.useState)(``),[ft,pt]=(0,V.useState)(``),[mt,ht]=(0,V.useState)(``),[gt,_t]=(0,V.useState)(``),[vt,yt]=(0,V.useState)(``),[bt,xt]=(0,V.useState)(``),[St,Ct]=(0,V.useState)(``),[wt,Tt]=(0,V.useState)(``),[Et,Dt]=(0,V.useState)(``),[Ot,kt]=(0,V.useState)(``),[At,jt]=(0,V.useState)(``),[Mt,Nt]=(0,V.useState)(``),[Pt,Ft]=(0,V.useState)(``),[It,Lt]=(0,V.useState)(``),[Rt,zt]=(0,V.useState)(!0),[Y,X]=(0,V.useState)(null),[Bt,Z]=(0,V.useState)(null),Vt=(0,V.useMemo)(()=>Le(D.get(`returnTo`)),[D]),Ht=(0,V.useCallback)(async()=>{if(e){zt(!0),Z(null);try{let[t,n,r]=await Promise.all([Re(e),ze(e),Be(e)]);N(t),ae(n);let[i,a]=await Promise.all([re(e,50),Ve(e)]);he(i),Me(a),ve(await He(e)),Ce(r)}catch(e){Z(e instanceof Error?e.message:r.errors.load)}finally{zt(!1)}}},[e,r.errors.load]);(0,V.useEffect)(()=>{Ht()},[Ht]),(0,V.useEffect)(()=>{let e=!1;return ce().then(t=>{e||(de(t),Ft(e=>e||t[0]?.id||``))}).catch(t=>{e||Z(t instanceof Error?t.message:r.errors.loadWorkflows)}),()=>{e=!0}},[r.errors.loadWorkflows]),(0,V.useEffect)(()=>{if(!A)return;$e(A.title),tt(A.description??``),rt(A.priority),at(A.deadlineAt?new Date(A.deadlineAt).toISOString().slice(0,10):``),st(String(A.maxTurns)),lt(A.judgeModelRef??``),dt(A.nextAction??``),pt(A.blockedReason??``),ht(A.contract?.objective??A.title),_t(A.contract?.scopeBoundary??``),yt(A.checklist.map(e=>e.text).join(`
3
- `)),xt(A.contract?.evidencePlan.join(`
4
- `)??``);let e=A.contract?.outcomeMetric;Ct(e?.name??``),Tt(e?String(e.baselineValue):``),Dt(e?String(e.targetValue):``),kt(e?.currentValue==null?``:String(e.currentValue)),jt(e?.unit??``),Nt(e?.sourceUrl??``),Ze(e=>A.evidenceRequirements.some(t=>t.id===e)?e:A.evidenceRequirements[0]?.id??``),Lt(e=>e||A.nextAction||A.title)},[A?.id,A?.updatedAt]);let Ut=async()=>{if(A){X(`continue`);try{A.status===`done`&&await f(d(`/api/goals/${encodeURIComponent(A.id)}/reopen`),{method:`POST`,body:JSON.stringify({})});let e=await f(d(`/api/goals/${encodeURIComponent(A.id)}/continue`),{method:`POST`,body:JSON.stringify({})});if(e.sessionKey){t(`/chat/${encodeURIComponent(e.sessionKey)}`);return}await Ht()}catch(e){Z(e instanceof Error?e.message:r.errors.continue)}finally{X(null)}}},Wt=async e=>{if(e.preventDefault(),!A)return;let t=Qe.trim();if(t){X(`details:save`),Z(null);try{let e=Number.parseInt(ot,10);N((await f(d(`/api/goals/${encodeURIComponent(A.id)}`),{method:`PATCH`,body:JSON.stringify({title:t,description:et.trim()||void 0,priority:nt,deadlineAt:it?new Date(`${it}T23:59:59`).getTime():void 0,maxTurns:Number.isFinite(e)?e:A.maxTurns,judgeModelRef:ct.trim()||void 0,nextAction:ut.trim()||void 0,blockedReason:ft.trim()||void 0})})).goal),await Q(A.id)}catch(e){Z(e instanceof Error?e.message:r.errors.save)}finally{X(null)}}},Gt=async e=>{if(e.preventDefault(),!A)return;let t=mt.trim();if(t){X(`contract:save`),Z(null);try{N((await f(d(`/api/goals/${encodeURIComponent(A.id)}/contract`),{method:`PUT`,body:JSON.stringify({objective:t,scopeBoundary:gt.trim()||void 0,criteria:fe(vt),evidencePlan:fe(bt)})})).goal),await Q(A.id)}catch(e){Z(e instanceof Error?e.message:r.errors.save)}finally{X(null)}}},Kt=async e=>{if(e.preventDefault(),!A)return;let t=Ae(wt),n=Ae(Et),i=Ae(Ot);if(!(!St.trim()||t==null||n==null)){X(`outcome:save`),Z(null);try{N((await f(d(`/api/goals/${encodeURIComponent(A.id)}/contract`),{method:`PUT`,body:JSON.stringify({objective:A.contract?.objective??A.title,scopeBoundary:A.contract?.scopeBoundary,criteria:A.checklist.map(e=>e.text),evidencePlan:A.contract?.evidencePlan??[],outcomeMetric:{name:St.trim(),baselineValue:t,targetValue:n,currentValue:i,unit:At.trim()||void 0,sourceUrl:Mt.trim()||void 0,measuredAt:i==null?void 0:Date.now()}})})).goal),await Q(A.id)}catch(e){Z(e instanceof Error?e.message:r.errors.save)}finally{X(null)}}},qt=async()=>{if(A){X(`outcome:clear`),Z(null);try{N((await f(d(`/api/goals/${encodeURIComponent(A.id)}/contract`),{method:`PUT`,body:JSON.stringify({objective:A.contract?.objective??A.title,scopeBoundary:A.contract?.scopeBoundary,criteria:A.checklist.map(e=>e.text),evidencePlan:A.contract?.evidencePlan??[],outcomeMetric:null})})).goal),await Q(A.id)}catch(e){Z(e instanceof Error?e.message:r.errors.save)}finally{X(null)}}},Jt=async e=>{if(A){X(e);try{await f(d(`/api/goals/${encodeURIComponent(A.id)}/${e}`),{method:`POST`,body:JSON.stringify({})}),await Ht()}catch(e){Z(e instanceof Error?e.message:r.errors.action)}finally{X(null)}}},Yt=async()=>{if(!(!A||!Pt)){X(`workflow:run`),Z(null);try{let e=await _({goalId:A.id,definitionId:Pt,goal:It.trim()||A.nextAction||A.title});await Ht(),t(`/chat/${encodeURIComponent(e.sessionKey)}`)}catch(e){Z(e instanceof Error?e.message:r.errors.startWorkflow)}finally{X(null)}}},Q=async e=>{try{Me(await Ve(e))}catch{}},Xt=async e=>{try{let[t,n,r]=await Promise.all([re(e,50),Ve(e),He(e)]);he(t),Me(n),ve(r)}catch{}},Zt=async e=>{if(A){X(`workflow:${e.id}:cancel`),Z(null);try{await M(e.id,{ownerAgentId:A.agentId}),await Xt(A.id)}catch(e){Z(e instanceof Error?e.message:r.errors.cancelWorkflow)}finally{X(null)}}},Qt=async e=>{if(A){X(`workflow:${e.id}:retry`),Z(null);try{let n=await oe(e.id,{ownerAgentId:A.agentId});await Xt(A.id),t(`/chat/${encodeURIComponent(n.sessionKey)}`)}catch(e){Z(e instanceof Error?e.message:r.errors.retryWorkflow)}finally{X(null)}}},$t=async e=>{if(e.preventDefault(),!A)return;let t=Pe.trim();if(t){X(`checklist:add`),Z(null);try{N((await f(d(`/api/goals/${encodeURIComponent(A.id)}/checklist`),{method:`POST`,body:JSON.stringify({text:t})})).goal),Fe(``),await Q(A.id)}catch(e){Z(e instanceof Error?e.message:r.errors.addChecklist)}finally{X(null)}}},en=async(e,t)=>{if(A){X(`checklist:${e}:${t}`),Z(null);try{N((await f(d(`/api/goals/${encodeURIComponent(A.id)}/checklist/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({status:t})})).goal),await Q(A.id)}catch(e){Z(e instanceof Error?e.message:r.errors.updateChecklist)}finally{X(null)}}},tn=async e=>{if(A){X(`checklist:${e}:delete`),Z(null);try{N((await f(d(`/api/goals/${encodeURIComponent(A.id)}/checklist/${encodeURIComponent(e)}`),{method:`DELETE`})).goal),await Q(A.id)}catch(e){Z(e instanceof Error?e.message:r.errors.deleteChecklist)}finally{X(null)}}},nn=async e=>{if(e.preventDefault(),!A)return;let t=We.trim();if(t){X(`evidence:add`),Z(null);try{let e=await f(d(`/api/goals/${encodeURIComponent(A.id)}/evidence`),{method:`POST`,body:JSON.stringify({kind:Ie,title:t,summary:Ke.trim()||void 0,uri:Je.trim()||void 0,requirementId:Xe||void 0})});Ce(t=>[e.evidence,...t]),N(await Re(A.id)),Ge(``),qe(``),Ye(``),await Q(A.id)}catch(e){Z(e instanceof Error?e.message:r.errors.addEvidence)}finally{X(null)}}},rn=async e=>{if(A){X(`requirement:${e}:review`),Z(null);try{await f(d(`/api/goals/${encodeURIComponent(A.id)}/evidence-requirements/${encodeURIComponent(e)}/review`),{method:`POST`,body:JSON.stringify({modelRef:A.judgeModelRef})}),N(await Re(A.id)),await Q(A.id)}catch(e){Z(e instanceof Error?e.message:r.errors.addEvidence)}finally{X(null)}}},an=async e=>{if(A){X(`requirement:${e}:approve`),Z(null);try{await f(d(`/api/goals/${encodeURIComponent(A.id)}/evidence-requirements/${encodeURIComponent(e)}/approve`),{method:`POST`,body:JSON.stringify({})}),N(await Re(A.id)),await Q(A.id)}catch(e){Z(e instanceof Error?e.message:r.errors.addEvidence)}finally{X(null)}}},on=async e=>{if(!A||!e.summary)return;Z(null);let t=l(n).automations,r=await f(d(`/api/goals/${encodeURIComponent(A.id)}/evidence`),{method:`POST`,body:JSON.stringify({kind:`message`,title:se(t.feedback.insightEvidenceTitle,{name:e.automationName}),summary:e.summary,data:{source:`automation`,automationRunId:e.id,automationId:e.automationId,automationName:e.automationName,sessionKey:e.sessionKey,workflowRunId:e.workflowRunId}})});Ce(e=>[r.evidence,...e]),await Q(A.id)},sn=A?.checklist.filter(e=>e.status===`completed`||e.status===`impossible`).length??0,cn=A?.checklist.length??0,ln=(0,V.useMemo)(()=>{let e=new Set;for(let t of J){let n=G(ge(t),`automationRunId`);n&&e.add(n)}return e},[J]),un=(0,V.useMemo)(()=>{let e=new Set;return J.filter(t=>{if(t.title.trim().toLowerCase().startsWith(`missing evidence:`))return!1;let n=`${t.kind}\u0000${t.title.trim()}\u0000${t.summary?.trim()??``}`;return e.has(n)?!1:(e.add(n),!0)})},[J]),dn=U.filter(e=>e.status===`failed`||e.status===`timeout`||e.status===`cancelled`),$=I[0],fn=Te(D.get(`timeline`))?D.get(`timeline`):`all`,pn=fn===`all`?De:De.filter(e=>e.kind===fn),mn=U.filter(e=>e.status===`queued`||e.status===`running`),hn=A?je(A,$,r):null,gn=A?.status===`done`&&!hn?.needsReview,_n=Y!=null||A?.status===`archived`||gn,vn=(0,V.useMemo)(()=>A?(0,H.jsxs)(H.Fragment,{children:[A.activeSessionKey?(0,H.jsxs)(B,{type:`button`,variant:`secondary`,className:`h-9 gap-2 rounded-lg px-2.5 md:px-3`,"aria-label":r.chat,onClick:()=>t(`/chat/${encodeURIComponent(A.activeSessionKey)}`),children:[(0,H.jsx)(y,{className:`size-4`,"aria-hidden":!0}),(0,H.jsx)(`span`,{className:`hidden md:inline`,children:r.chat})]}):null,(0,H.jsxs)(B,{type:`button`,variant:`ghost`,className:`h-9 gap-2 rounded-lg px-2.5 md:px-3`,"aria-label":r.archive,disabled:Y!=null||A.status===`archived`,onClick:()=>{window.confirm(r.archiveConfirm)&&Jt(`archive`)},children:[(0,H.jsx)(F,{className:`size-4`,"aria-hidden":!0}),(0,H.jsx)(`span`,{className:`hidden md:inline`,children:r.archive})]})]}):null,[Y,A,t,r]);(0,V.useLayoutEffect)(()=>(S({startExtra:(0,H.jsx)(o,{to:Vt,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":r.back,children:(0,H.jsx)(v,{className:`size-4`,"aria-hidden":!0})}),main:(0,H.jsxs)(`div`,{className:`min-w-0`,children:[Rt?(0,H.jsx)(x,{className:`h-5 w-48 max-w-full`}):(0,H.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:A?.title??r.notFound}),A?(0,H.jsxs)(`p`,{className:`truncate text-xs text-fg-muted`,children:[hn?.title??Ee(A.status,r),` · `,q(r.agent,{agentId:A.agentId})]}):null]}),end:vn}),()=>E()),[Vt,E,A,vn,Rt,S,hn?.title,r]);let yn=e=>{let t=new URLSearchParams(D);e===`all`?t.delete(`timeline`):t.set(`timeline`,e),k(t,{replace:!0})};return(0,H.jsx)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto bg-surface-panel`,children:(0,H.jsxs)(`div`,{className:`flex w-full flex-1 flex-col gap-4 px-3 py-5 sm:px-5 xl:px-6`,children:[Bt?(0,H.jsx)(`p`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:Bt}):null,!Rt&&!A?(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.notFound}):null,Rt?(0,H.jsx)(pe,{}):A?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Ne,{goal:A,latestRun:$,done:sn,total:cn,evidence:J,language:n,t:r,busy:Y,primaryActionDisabled:_n,onContinue:()=>void Ut(),onOpenChat:()=>A.activeSessionKey&&t(`/chat/${encodeURIComponent(A.activeSessionKey)}`),onPause:()=>void Jt(`pause`),onConfigureOutcome:()=>document.getElementById(`goal-outcome-metric`)?.scrollIntoView({behavior:`smooth`,block:`center`}),onReviewEvidence:()=>document.getElementById(`goal-verification`)?.scrollIntoView({behavior:`smooth`,block:`start`})}),(0,H.jsxs)(`section`,{id:`goal-outcome-metric`,className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,H.jsx)(C,{className:`size-4 text-accent`,"aria-hidden":!0}),r.outcomeMetric.title]}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.outcomeMetric.hint})]}),A.contract?.outcomeMetric?(0,H.jsx)(`span`,{className:c(`rounded-full border px-2 py-0.5 text-xs font-medium`,ke(A.contract.outcomeMetric)?`border-success/30 bg-success-soft text-success`:`border-amber-500/30 bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:ke(A.contract.outcomeMetric)?r.outcomeMetric.achieved:r.outcomeMetric.notAchieved}):null]}),(0,H.jsxs)(`form`,{className:`mt-4 grid gap-3`,onSubmit:Kt,children:[(0,H.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[minmax(12rem,1.4fr)_repeat(3,minmax(7rem,0.7fr))]`,children:[(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.outcomeMetric.name,(0,H.jsx)(`input`,{value:St,onChange:e=>Ct(e.target.value),className:W,placeholder:r.outcomeMetric.namePlaceholder})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.outcomeMetric.baseline,(0,H.jsx)(`input`,{value:wt,onChange:e=>Tt(e.target.value),className:W,type:`number`,step:`any`,inputMode:`decimal`})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.outcomeMetric.current,(0,H.jsx)(`input`,{value:Ot,onChange:e=>kt(e.target.value),className:W,type:`number`,step:`any`,inputMode:`decimal`})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.outcomeMetric.target,(0,H.jsx)(`input`,{value:Et,onChange:e=>Dt(e.target.value),className:W,type:`number`,step:`any`,inputMode:`decimal`})]})]}),(0,H.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[10rem_minmax(0,1fr)_auto] md:items-end`,children:[(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.outcomeMetric.unit,(0,H.jsx)(`input`,{value:At,onChange:e=>jt(e.target.value),className:W,placeholder:r.outcomeMetric.unitPlaceholder})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.outcomeMetric.source,(0,H.jsx)(`input`,{value:Mt,onChange:e=>Nt(e.target.value),className:W,placeholder:r.outcomeMetric.sourcePlaceholder})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[A.contract?.outcomeMetric?(0,H.jsx)(B,{type:`button`,variant:`ghost`,className:`h-9`,disabled:Y!=null,onClick:()=>void qt(),children:r.outcomeMetric.clear}):null,(0,H.jsx)(B,{type:`submit`,variant:`secondary`,className:`h-9`,disabled:Y!=null||!St.trim()||Ae(wt)==null||Ae(Et)==null,children:r.outcomeMetric.save})]})]})]})]}),(0,H.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.goalBrief}),A.description?(0,H.jsx)(`p`,{className:`mt-3 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:A.description}):null,A.contract?(0,H.jsxs)(`div`,{className:`mt-3 rounded-md border border-edge-subtle bg-surface-muted/40 p-3`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:r.goalContract}),(0,H.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:A.contract.objective}),A.contract.scopeBoundary?(0,H.jsxs)(`div`,{className:`mt-3`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:r.scopeBoundary}),(0,H.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:A.contract.scopeBoundary})]}):null,A.contract.evidencePlan.length?(0,H.jsxs)(`div`,{className:`mt-3`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:r.completionEvidence}),(0,H.jsx)(`ul`,{className:`mt-1 grid gap-1 text-sm text-fg-muted`,children:A.contract.evidencePlan.map(e=>(0,H.jsxs)(`li`,{children:[`• `,e]},e))})]}):null,(0,H.jsxs)(`details`,{className:`mt-3 rounded-md bg-surface-base/70 px-3 py-2`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:r.editContract}),(0,H.jsxs)(`form`,{className:`mt-3 grid gap-3`,onSubmit:Gt,children:[(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.contractObjective,(0,H.jsx)(`textarea`,{value:mt,onChange:e=>ht(e.target.value),name:`contractObjective`,autoComplete:`off`,className:c(W,`resize-y`),rows:2,placeholder:r.contractObjectivePlaceholder})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.scopeBoundary,(0,H.jsx)(`textarea`,{value:gt,onChange:e=>_t(e.target.value),name:`contractScopeBoundary`,autoComplete:`off`,className:c(W,`resize-y`),rows:2,placeholder:r.scopeBoundaryPlaceholder})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.acceptanceCriteria,(0,H.jsx)(`textarea`,{value:vt,onChange:e=>yt(e.target.value),name:`contractCriteria`,autoComplete:`off`,className:c(W,`resize-y`),rows:3,placeholder:r.contractLinesHint})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.completionEvidence,(0,H.jsx)(`textarea`,{value:bt,onChange:e=>xt(e.target.value),name:`contractEvidencePlan`,autoComplete:`off`,className:c(W,`resize-y`),rows:3,placeholder:r.contractLinesHint})]}),(0,H.jsx)(B,{type:`submit`,variant:`secondary`,className:`h-9 w-fit`,disabled:Y!=null||!mt.trim(),children:r.saveContract})]})]})]}):null]}),(0,H.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,H.jsxs)(`div`,{className:`grid min-w-0 gap-4`,children:[(0,H.jsxs)(`section`,{id:`goal-verification`,className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,H.jsx)(R,{className:`size-4 text-accent`,"aria-hidden":!0}),r.acceptance]}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.acceptanceHint})]}),(0,H.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[sn,`/`,cn]})]}),$?(0,H.jsxs)(`div`,{className:`mt-3 rounded-md bg-surface-muted/40 px-3 py-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,H.jsx)(`span`,{children:q(r.latestJudgement,{status:Ee($.verdict??$.status,r)})}),(0,H.jsx)(`time`,{children:xe($.finishedAt??$.startedAt,n,r)})]}),$.reason?(0,H.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:$.reason}):null,$.nextAction?(0,H.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-muted`,children:q(r.latestNext,{next:$.nextAction})}):null]}):null,(0,H.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,H.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,H.jsx)(R,{className:`size-4 text-accent`,"aria-hidden":!0}),r.checklist]}),(0,H.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[sn,`/`,cn]})]}),(0,H.jsxs)(`form`,{className:`mb-3 flex flex-col gap-2 sm:flex-row`,onSubmit:$t,children:[(0,H.jsx)(`input`,{value:Pe,onChange:e=>Fe(e.target.value),name:`checklistText`,"aria-label":r.addAcceptancePlaceholder,autoComplete:`off`,placeholder:r.addAcceptancePlaceholder,className:c(W,`flex-1`)}),(0,H.jsxs)(B,{type:`submit`,variant:`secondary`,className:`h-9 gap-2`,disabled:Y!=null||!Pe.trim(),children:[(0,H.jsx)(ie,{className:`size-4`,"aria-hidden":!0}),r.add]})]}),A.checklist.length?(0,H.jsx)(`ul`,{className:`space-y-2 text-sm`,children:A.checklist.map(e=>(0,H.jsx)(`li`,{className:`rounded-md bg-surface-muted/40 px-2.5 py-2`,children:(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2`,children:[(0,H.jsx)(`span`,{className:`mt-1 w-5 shrink-0 text-center text-fg-muted`,children:we(e.status)}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`p`,{className:`break-words text-fg`,children:e.text}),e.evidenceSummary?(0,H.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.evidenceSummary}):null]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,H.jsx)(B,{type:`button`,variant:`ghost`,className:`size-8 p-0`,title:r.markPending,"aria-label":r.markPending,disabled:Y!=null||e.status===`pending`,onClick:()=>void en(e.id,`pending`),children:(0,H.jsx)(m,{className:`size-4`,"aria-hidden":!0})}),(0,H.jsx)(B,{type:`button`,variant:`ghost`,className:`size-8 p-0`,title:r.markCompleted,"aria-label":r.markCompleted,disabled:Y!=null||e.status===`completed`,onClick:()=>void en(e.id,`completed`),children:(0,H.jsx)(ne,{className:`size-4`,"aria-hidden":!0})}),(0,H.jsx)(B,{type:`button`,variant:`ghost`,className:`size-8 p-0`,title:r.markImpossible,"aria-label":r.markImpossible,disabled:Y!=null||e.status===`impossible`,onClick:()=>void en(e.id,`impossible`),children:(0,H.jsx)(j,{className:`size-4`,"aria-hidden":!0})}),(0,H.jsx)(B,{type:`button`,variant:`ghost`,className:`size-8 p-0 text-destructive hover:text-destructive`,title:r.deleteChecklistItem,"aria-label":r.deleteChecklistItem,disabled:Y!=null,onClick:()=>void tn(e.id),children:(0,H.jsx)(h,{className:`size-4`,"aria-hidden":!0})})]})]})},e.id))}):(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.noChecklist}),(0,H.jsxs)(`div`,{className:`mt-4 border-t border-edge pt-4`,children:[(0,H.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,H.jsx)(b,{className:`size-4 text-accent`,"aria-hidden":!0}),r.evidence]}),A.evidenceRequirements.length?(0,H.jsxs)(`div`,{className:`mb-4 grid gap-2 rounded-md border border-edge-subtle bg-surface-muted/40 p-3`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:r.evidenceRequirements}),(0,H.jsx)(`span`,{className:`text-xs text-fg-muted`,children:q(r.evidenceRequirementProgress,{approved:A.evidenceRequirements.filter(e=>e.status===`approved`).length,total:A.evidenceRequirements.length})})]}),A.evidenceRequirements.map(e=>(0,H.jsx)(`div`,{className:`rounded-md bg-surface-base px-2.5 py-2`,children:(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`p`,{className:`break-words text-sm text-fg`,children:e.text}),(0,H.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[q(r.linkedEvidenceCount,{count:e.evidenceIds.length}),` · `,r.evidenceRequirementStatuses[e.status]]}),e.reviewReason?(0,H.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-muted`,children:e.reviewReason}):null]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-1.5`,children:[(0,H.jsx)(B,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,disabled:Y!=null||e.evidenceIds.length===0,onClick:()=>void rn(e.id),children:r.reviewEvidence}),(0,H.jsx)(B,{type:`button`,variant:`secondary`,className:`h-7 text-xs`,disabled:Y!=null||e.evidenceIds.length===0||e.status===`approved`,onClick:()=>void an(e.id),children:r.approveEvidence})]})]})},e.id))]}):null,(0,H.jsxs)(`form`,{className:`mb-3 grid gap-2`,onSubmit:nn,children:[(0,H.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[9rem_minmax(0,1fr)]`,children:[(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.kind,(0,H.jsx)(z,{value:Ie,onChange:e=>Ue(e.target.value),className:W,name:`evidenceKind`,children:me.map(e=>(0,H.jsx)(L,{value:e,children:Oe(e,r)},e))})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.title,(0,H.jsx)(`input`,{value:We,onChange:e=>Ge(e.target.value),name:`evidenceTitle`,autoComplete:`off`,placeholder:r.evidenceTitlePlaceholder,className:W})]})]}),A.evidenceRequirements.length?(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.provesRequirement,(0,H.jsx)(z,{value:Xe,onChange:e=>Ze(e.target.value),name:`evidenceRequirement`,className:W,children:A.evidenceRequirements.map(e=>(0,H.jsx)(L,{value:e.id,children:e.text},e.id))})]}):null,(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.uriOrPath,(0,H.jsx)(`input`,{value:Je,onChange:e=>Ye(e.target.value),name:`evidenceUri`,autoComplete:`off`,placeholder:r.uriOrPathPlaceholder,className:W})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.summary,(0,H.jsx)(`textarea`,{value:Ke,onChange:e=>qe(e.target.value),name:`evidenceSummary`,autoComplete:`off`,placeholder:r.summaryPlaceholder,rows:3,className:c(W,`resize-y`)})]}),(0,H.jsxs)(B,{type:`submit`,variant:`secondary`,className:`h-9 w-fit gap-2`,disabled:Y!=null||!We.trim(),children:[(0,H.jsx)(ie,{className:`size-4`,"aria-hidden":!0}),r.addEvidence]})]}),un.length?(0,H.jsx)(`ul`,{className:`space-y-2 text-sm`,children:un.slice(0,6).map(e=>(0,H.jsx)(_e,{item:e,language:n,t:r},e.id))}):(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.noEvidence})]})]}),(0,H.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,H.jsx)(P,{className:`size-4 text-accent`,"aria-hidden":!0}),r.timeline]}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.timelineHint})]}),(0,H.jsxs)(B,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,onClick:()=>void Ht(),children:[(0,H.jsx)(T,{className:`size-3.5`,"aria-hidden":!0}),r.refresh]})]}),I.length?(0,H.jsx)(`ol`,{className:`mt-4 grid gap-2`,children:I.slice(0,6).map((e,t)=>(0,H.jsx)(`li`,{children:(0,H.jsxs)(`details`,{open:t===0&&e.verdict!==`done`,className:`group rounded-lg border border-edge-subtle bg-surface-muted/40 px-3 py-2`,children:[(0,H.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 marker:hidden`,children:[(0,H.jsxs)(`span`,{className:`min-w-0`,children:[(0,H.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:q(r.executionProgress.runTitle,{number:I.length-t})}),(0,H.jsx)(`time`,{className:`mt-0.5 block text-xs text-fg-muted`,children:xe(e.finishedAt??e.startedAt,n,r)})]}),(0,H.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 text-xs text-fg-muted`,children:[Ee(e.verdict??e.status,r),(0,H.jsx)(ee,{className:`size-4 transition-transform group-open:rotate-90`,"aria-hidden":!0})]})]}),(0,H.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[e.reason?(0,H.jsx)(`p`,{className:`text-sm text-fg`,children:e.reason}):null,e.assistantPreview?(0,H.jsx)(`p`,{className:`mt-2 line-clamp-5 whitespace-pre-wrap text-xs text-fg-muted`,children:e.assistantPreview}):null,e.nextAction?(0,H.jsxs)(`div`,{className:`mt-3 rounded-md bg-surface-base px-3 py-2`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:r.nextAction}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:e.nextAction})]}):null]})]})},e.id))}):(0,H.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:r.executionProgress.noRuns}),(0,H.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-3`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:q(r.executionProgress.systemActivity,{count:De.length})}),(0,H.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[`all`,`goal_run`,`workflow_run`,`evidence`,`queue`,`event`].map(e=>(0,H.jsx)(`button`,{type:`button`,className:c(`rounded-md border px-2.5 py-1 text-xs font-medium`,fn===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>yn(e),children:r.timelineFilters[e]},e))}),pn.length?(0,H.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm`,children:pn.map(e=>(0,H.jsx)(`li`,{className:`rounded-md bg-surface-muted/50 px-2.5 py-2`,children:(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[(0,H.jsx)(be(e.kind),{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[(0,H.jsx)(`span`,{children:r.timelineFilters[e.kind]}),e.status?(0,H.jsx)(`span`,{children:Ee(e.status,r)}):null]}),(0,H.jsx)(`p`,{className:`mt-1 break-words font-medium text-fg`,children:e.title}),e.summary?(0,H.jsx)(`p`,{className:`mt-1 line-clamp-3 break-words text-xs text-fg-muted`,children:e.summary}):null]})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1 text-xs text-fg-muted`,children:[(0,H.jsx)(`time`,{children:xe(e.createdAt,n,r)}),e.link?.type===`chat`?(0,H.jsxs)(B,{type:`button`,variant:`ghost`,className:`h-7 gap-1.5`,onClick:()=>t(`/chat/${encodeURIComponent(e.link.value)}`),children:[(0,H.jsx)(y,{className:`size-3.5`,"aria-hidden":!0}),r.chat]}):null,e.link?.type===`workflow_run`?(0,H.jsxs)(B,{type:`button`,variant:`ghost`,className:`h-7 gap-1.5`,onClick:()=>t(`/workflows?run=${encodeURIComponent(e.link.value)}`),children:[(0,H.jsx)(y,{className:`size-3.5`,"aria-hidden":!0}),r.run]}):null]})]})},e.id))}):(0,H.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:r.noTimeline})]})]})]}),(0,H.jsxs)(`aside`,{className:`grid h-fit gap-4`,children:[(0,H.jsxs)(`section`,{className:`rounded-lg border border-accent/25 bg-accent-soft/30 p-4`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium text-accent-fg`,children:r.actionRail.nextTitle}),(0,H.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-sm font-medium text-fg`,children:gn?r.progressPanel.doneFallback:A.nextAction||r.noNextAction}),(0,H.jsxs)(B,{type:`button`,variant:`primary`,className:`mt-3 h-9 w-full gap-2`,disabled:Y!=null||A.status===`archived`,onClick:()=>{if(gn){window.confirm(r.archiveConfirm)&&Jt(`archive`);return}Ut()},children:[gn?(0,H.jsx)(F,{className:`size-4`,"aria-hidden":!0}):(0,H.jsx)(te,{className:`size-4`,"aria-hidden":!0}),gn?r.archive:r.actionRail.continueAction]})]}),A.evidenceRequirements.some(e=>e.status!==`approved`)||A.contract?.outcomeMetric&&!ke(A.contract.outcomeMetric)||$?.verdict===`continue`?(0,H.jsxs)(`section`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 p-4`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-amber-900 dark:text-amber-100`,children:r.actionRail.needsYou}),(0,H.jsxs)(`ul`,{className:`mt-3 grid gap-2 text-sm text-amber-900 dark:text-amber-100`,children:[A.contract?.outcomeMetric&&!ke(A.contract.outcomeMetric)?(0,H.jsxs)(`li`,{children:[`• `,r.outcomeMetric.notAchieved]}):null,A.evidenceRequirements.some(e=>e.status!==`approved`)?(0,H.jsxs)(`li`,{children:[`• `,q(r.actionRail.reviewEvidenceCount,{count:A.evidenceRequirements.filter(e=>e.status!==`approved`).length})]}):null,$?.verdict===`continue`?(0,H.jsxs)(`li`,{children:[`• `,r.actionRail.latestCheckContinue]}):null]}),(0,H.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[A.contract?.outcomeMetric&&!ke(A.contract.outcomeMetric)?(0,H.jsx)(B,{type:`button`,variant:`secondary`,className:`h-8`,onClick:()=>document.getElementById(`goal-outcome-metric`)?.scrollIntoView({behavior:`smooth`,block:`center`}),children:r.actionRail.setOutcome}):null,A.evidenceRequirements.some(e=>e.status!==`approved`)?(0,H.jsx)(B,{type:`button`,variant:`secondary`,className:`h-8`,onClick:()=>document.getElementById(`goal-verification`)?.scrollIntoView({behavior:`smooth`,block:`start`}),children:r.actionRail.reviewEvidence}):null]})]}):null,(0,H.jsxs)(`details`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer text-sm font-semibold text-fg`,children:r.actionRail.automation}),(0,H.jsxs)(`div`,{className:`mt-3 grid gap-3`,children:[(0,H.jsx)(w,{eventType:`goal.status_changed`,source:`goals`,payloadKey:`goalId`,payloadValue:A.id,onSaveInsight:on,isInsightSaved:e=>ln.has(e.id)}),(0,H.jsx)(w,{eventType:`goal.created`,source:`goals`,payloadKey:`goalId`,payloadValue:A.id,onSaveInsight:on,isInsightSaved:e=>ln.has(e.id)}),A.status===`blocked`||A.blockedReason?(0,H.jsx)(ue,{title:p.goalBlockedTitle,description:p.goalBlockedDescription,prompt:q(p.goalBlockedPrompt,{title:A.title}),coverage:{eventType:`goal.status_changed`,source:`goals`,eventPayload:{goalId:A.id,status:`blocked`}}}):null]})]}),(0,H.jsxs)(`details`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer text-sm font-semibold text-fg`,children:r.goalSettings}),(0,H.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-sm`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsx)(`dt`,{className:`text-fg-muted`,children:r.deadline}),(0,H.jsx)(`dd`,{className:`text-right text-fg`,children:Se(A.deadlineAt,n,r)})]}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsx)(`dt`,{className:`text-fg-muted`,children:r.judgeModel}),(0,H.jsx)(`dd`,{className:`min-w-0 truncate text-right text-fg`,children:A.judgeModelRef||r.default})]}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsx)(`dt`,{className:`text-fg-muted`,children:r.created}),(0,H.jsx)(`dd`,{className:`text-right text-fg`,children:Se(A.createdAt,n,r)})]}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsx)(`dt`,{className:`text-fg-muted`,children:r.updated}),(0,H.jsx)(`dd`,{className:`text-right text-fg`,children:xe(A.updatedAt,n,r)})]})]}),(0,H.jsxs)(`details`,{className:`mt-4 rounded-md bg-surface-muted/40 px-3 py-2`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:r.editDetails}),(0,H.jsxs)(`form`,{className:`mt-3 grid gap-3`,onSubmit:Wt,children:[(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.title,(0,H.jsx)(`input`,{value:Qe,onChange:e=>$e(e.target.value),name:`goalTitle`,autoComplete:`off`,className:W,placeholder:`${r.title}…`})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.description,(0,H.jsx)(`textarea`,{value:et,onChange:e=>tt(e.target.value),name:`goalDescription`,autoComplete:`off`,className:c(W,`resize-y`),rows:3,placeholder:`${r.description}…`})]}),(0,H.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3 xl:grid-cols-1`,children:[(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.priority,(0,H.jsxs)(z,{value:nt,onChange:e=>rt(e.target.value),name:`goalPriority`,className:W,children:[(0,H.jsx)(L,{value:`low`,children:r.priorities.low}),(0,H.jsx)(L,{value:`normal`,children:r.priorities.normal}),(0,H.jsx)(L,{value:`high`,children:r.priorities.high})]})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.deadline,(0,H.jsx)(`input`,{value:it,onChange:e=>at(e.target.value),name:`goalDeadline`,className:W,type:`date`})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.maxTurns,(0,H.jsx)(`input`,{value:ot,onChange:e=>st(e.target.value),name:`goalMaxTurns`,className:W,type:`number`,min:1,max:500,inputMode:`numeric`,placeholder:`${r.maxTurns}…`})]})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.judgeModel,(0,H.jsx)(`input`,{value:ct,onChange:e=>lt(e.target.value),name:`goalJudgeModel`,autoComplete:`off`,className:W,placeholder:`${r.judgeModel}…`})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.nextAction,(0,H.jsx)(`textarea`,{value:ut,onChange:e=>dt(e.target.value),name:`goalNextAction`,autoComplete:`off`,className:c(W,`resize-y`),rows:2,placeholder:`${r.nextAction}…`})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.blockedReason,(0,H.jsx)(`textarea`,{value:ft,onChange:e=>pt(e.target.value),name:`goalBlockedReason`,autoComplete:`off`,className:c(W,`resize-y`),rows:2,placeholder:`${r.blockedReason}…`})]}),(0,H.jsx)(B,{type:`submit`,variant:`secondary`,className:`h-9 w-fit`,disabled:Y!=null||!Qe.trim(),children:r.saveDetails})]})]})]}),(0,H.jsxs)(`details`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,H.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 text-sm font-semibold text-fg marker:hidden`,children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(g,{className:`size-4 text-accent`,"aria-hidden":!0}),r.workflow]}),mn.length?(0,H.jsx)(`span`,{className:`rounded-full border border-accent/40 bg-accent-soft px-2 py-0.5 text-xs text-accent-fg`,children:q(r.activeCount,{count:mn.length})}):null]}),(0,H.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:r.workflowHint}),K.length?(0,H.jsx)(`div`,{className:`mt-3 grid gap-2`,children:K.slice(0,2).map(e=>(0,H.jsxs)(`button`,{type:`button`,className:c(`min-w-0 rounded-md bg-surface-muted/40 px-2.5 py-2 text-left hover:bg-accent-soft/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,Pt===e.definitionId&&`bg-accent-soft/60 ring-1 ring-accent/30`),onClick:()=>{Ft(e.definitionId),Lt(A.nextAction||A.title)},children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,H.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.title}),(0,H.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.score})]}),(0,H.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:e.description})]},e.definitionId))}):null,(0,H.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.definition,(0,H.jsxs)(z,{value:Pt,onChange:e=>Ft(e.target.value),className:W,name:`workflowDefinition`,disabled:le.length===0,children:[le.length===0?(0,H.jsx)(L,{value:``,children:r.noWorkflows}):null,le.map(e=>(0,H.jsx)(L,{value:e.id,children:e.title||e.name},e.id))]})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.workflowGoal,(0,H.jsx)(`input`,{value:It,onChange:e=>Lt(e.target.value),name:`workflowGoal`,autoComplete:`off`,className:W,placeholder:`${r.workflowGoal}…`})]}),(0,H.jsxs)(B,{type:`button`,variant:`secondary`,className:`h-9 w-fit gap-2`,disabled:Y!=null||!Pt||A.status===`done`||A.status===`archived`,onClick:()=>void Yt(),children:[(0,H.jsx)(te,{className:`size-4`,"aria-hidden":!0}),r.runWorkflow]})]}),U.length?(0,H.jsxs)(`div`,{className:`mt-4 border-t border-edge pt-3`,children:[(0,H.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.recentWorkflowRuns}),(0,H.jsx)(`button`,{type:`button`,className:`text-xs text-fg-muted hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>yn(`workflow_run`),children:r.viewTimeline})]}),(0,H.jsx)(`ul`,{className:`grid gap-2`,children:U.slice(0,3).map(e=>{let i=e.metadata?.sessionKey,a=e.status===`queued`||e.status===`running`,o=e.status===`failed`||e.status===`timeout`||e.status===`cancelled`;return(0,H.jsxs)(`li`,{className:`rounded-md bg-surface-muted/40 px-2.5 py-2 text-sm`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,H.jsx)(`span`,{className:`min-w-0 truncate`,children:e.definitionId}),(0,H.jsx)(`span`,{className:c(`shrink-0 rounded-full border px-2 py-0.5`,ye(e.status)),children:Ee(e.status,r)})]}),(0,H.jsx)(`p`,{className:`mt-1 truncate text-fg`,children:e.title}),(0,H.jsx)(`time`,{className:`mt-1 block text-xs text-fg-muted`,children:xe(e.completedAtMs??e.startedAtMs??e.createdAtMs,n,r)}),(0,H.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[i?(0,H.jsxs)(B,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,onClick:()=>t(`/chat/${encodeURIComponent(i)}`),children:[(0,H.jsx)(y,{className:`size-3.5`,"aria-hidden":!0}),r.chat]}):null,a?(0,H.jsxs)(B,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 text-destructive hover:text-destructive`,disabled:Y!=null,onClick:()=>void Zt(e),children:[(0,H.jsx)(j,{className:`size-3.5`,"aria-hidden":!0}),r.cancel]}):null,o?(0,H.jsxs)(B,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,disabled:Y!=null,onClick:()=>void Qt(e),children:[(0,H.jsx)(T,{className:`size-3.5`,"aria-hidden":!0}),r.retry]}):null]})]},e.id)})})]}):null,dn.length?(0,H.jsxs)(`div`,{className:`mt-4 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-amber-800 dark:text-amber-200`,children:r.recoveryNeeded}),(0,H.jsx)(`span`,{className:`text-xs text-amber-700 dark:text-amber-300`,children:q(r.failedCount,{count:dn.length})})]}),(0,H.jsx)(`ul`,{className:`mt-2 grid gap-2`,children:dn.slice(0,3).map(e=>(0,H.jsxs)(`li`,{className:`grid gap-2 text-sm`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`p`,{className:`truncate text-fg`,children:e.title}),(0,H.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[e.definitionId,` · `,Ee(e.status,r)]})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,H.jsxs)(B,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,onClick:()=>t(`/workflows?run=${encodeURIComponent(e.id)}`),children:[(0,H.jsx)(y,{className:`size-3.5`,"aria-hidden":!0}),r.run]}),(0,H.jsxs)(B,{type:`button`,variant:`secondary`,className:`h-8 gap-1.5`,disabled:Y!=null,onClick:()=>void Qt(e),children:[(0,H.jsx)(T,{className:`size-3.5`,"aria-hidden":!0}),r.retry]})]})]},e.id))})]}):null]})]})]})]}):null]})})}export{Ue as GoalDetailPage};