@xopcai/xopc 0.0.217 → 0.0.219

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 (329) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-D6trMTyZ.js → activity-store-slG02hSm.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CAQdFrcu.js → agent-avatar-dicebear-DZ6ETNIk.js} +1 -1
  5. package/dist/gateway/static/root/assets/agents-DxaIH0Ep.js +68 -0
  6. package/dist/gateway/static/root/assets/{api-B9pZAyMB.js → api-Tz57QxiN.js} +1 -1
  7. package/dist/gateway/static/root/assets/app-management-settings-panel-DdR1L4LR.js +1 -0
  8. package/dist/gateway/static/root/assets/appearance-settings-wYbwqmee.js +1 -0
  9. package/dist/gateway/static/root/assets/apps-page-CyWr6KyO.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-BF0q7N24.js → archive-plugin-DKXa160O.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-D1qmjGDo.js → attachment-load-CzwA9g2y.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automations-page-Ccu4yRFa.js → automations-page-DwAXyWAY.js} +1 -1
  13. package/dist/gateway/static/root/assets/automations-workspace-CL7ieYIt.js +6 -0
  14. package/dist/gateway/static/root/assets/{binary-plugins-DooqxEZz.js → binary-plugins-DoQ_DnT7.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-Dqg9kvb9.js → block-editor-Bj_Uxxng.js} +47 -47
  16. package/dist/gateway/static/root/assets/browser-settings-page-BYa_FNC1.js +8 -0
  17. package/dist/gateway/static/root/assets/{browser-workflow-inputs-CsIh8ySc.js → browser-workflow-inputs-D4roXE6r.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-workflows-page-BXQFxT0p.js → browser-workflows-page-CleKTAKD.js} +2 -2
  19. package/dist/gateway/static/root/assets/capabilities-settings-panel-DYG37N0k.js +7 -0
  20. package/dist/gateway/static/root/assets/{capability-presets-api-BX9U0FRh.js → capability-presets-api-wtEN6Ss6.js} +1 -1
  21. package/dist/gateway/static/root/assets/capability-presets-settings-panel-C0Q4dFq-.js +3 -0
  22. package/dist/gateway/static/root/assets/{channel-recipient-api-CUBTQ0Bz.js → channel-recipient-api-DhuS2RJ3.js} +1 -1
  23. package/dist/gateway/static/root/assets/channels-settings-CpO6Xg0n.js +1 -0
  24. package/dist/gateway/static/root/assets/channels-status-swr-CXhPeiNj.js +1 -0
  25. package/dist/gateway/static/root/assets/chat-terminal-dock-ClQMDe2n.js +36 -0
  26. package/dist/gateway/static/root/assets/connectors-page-BvyiPdKU.js +2 -0
  27. package/dist/gateway/static/root/assets/{cron-expression-XzPZhzVM.js → cron-expression-4DvCFs-v.js} +1 -1
  28. package/dist/gateway/static/root/assets/date-picker-B6FSjt4Z.js +1 -0
  29. package/dist/gateway/static/root/assets/dependency-picker-Za18eMp1.js +1 -0
  30. package/dist/gateway/static/root/assets/{desktop-pet-DZjW-7Tw.js → desktop-pet-DUUf3yyJ.js} +1 -1
  31. package/dist/gateway/static/root/assets/desktop-pet-settings-Dwx3GfB8.js +1 -0
  32. package/dist/gateway/static/root/assets/directory-picker-path-field-C6dfTCsl.js +1 -0
  33. package/dist/gateway/static/root/assets/ellipsis-0k4rZLoy.js +1 -0
  34. package/dist/gateway/static/root/assets/{extension-debug-page-D7APnE3n.js → extension-debug-page-Cordpg4X.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-page-BhV5hz70.js → extension-page-Dw0dGyMl.js} +1 -1
  36. package/dist/gateway/static/root/assets/extension-settings-page-B2pUMaXm.js +1 -0
  37. package/dist/gateway/static/root/assets/eye-CABVeTq0.js +1 -0
  38. package/dist/gateway/static/root/assets/eye-off-DEAzt3g1.js +1 -0
  39. package/dist/gateway/static/root/assets/file-code-corner-byQA1VfD.js +1 -0
  40. package/dist/gateway/static/root/assets/form-field-width-DJw_jULe.js +1 -0
  41. package/dist/gateway/static/root/assets/gateway-config-api-DAZUOEQh.js +1 -0
  42. package/dist/gateway/static/root/assets/{gateway-config-swr-BTH9HVUk.js → gateway-config-swr-BIqRg-zo.js} +1 -1
  43. package/dist/gateway/static/root/assets/gateway-settings-ik2f-pmV.js +1 -0
  44. package/dist/gateway/static/root/assets/{gateway-startup-retry-DAEk_tnd.js → gateway-startup-retry-BFjWYOCS.js} +1 -1
  45. package/dist/gateway/static/root/assets/heartbeat-settings-BE81XJ8F.js +1 -0
  46. package/dist/gateway/static/root/assets/home-page-BTWXJu_m.js +1 -0
  47. package/dist/gateway/static/root/assets/{image-generation-api-HqcQrSed.js → image-generation-api-HXAWlgm6.js} +1 -1
  48. package/dist/gateway/static/root/assets/index-B6gWYy08.js +108 -0
  49. package/dist/gateway/static/root/assets/index-CDkuz_YC.css +2 -0
  50. package/dist/gateway/static/root/assets/interaction-BmQogeqz.js +1 -0
  51. package/dist/gateway/static/root/assets/is-masked-secret-DOkL5b_X.js +1 -0
  52. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BG6lShzn.js → keyboard-shortcuts-settings-ROqQ_Xlo.js} +1 -1
  53. package/dist/gateway/static/root/assets/local-app-workbench-page-Dcaf190G.js +2 -0
  54. package/dist/gateway/static/root/assets/{local-apps-page-vaz8ewe2.js → local-apps-page-Be79cyMG.js} +1 -1
  55. package/dist/gateway/static/root/assets/{locale-store-De8wYkd7.js → locale-store-DfK-Hofd.js} +1 -1
  56. package/dist/gateway/static/root/assets/logs-page-C2pjbXno.js +2 -0
  57. package/dist/gateway/static/root/assets/{management-settings-tqTGCHt0.js → management-settings-CRspx0oY.js} +1 -1
  58. package/dist/gateway/static/root/assets/{markdown-split-BGx8Aao0.js → markdown-split-G3PTpGw3.js} +1 -1
  59. package/dist/gateway/static/root/assets/{markdown-view-ybRARsPs.js → markdown-view-D4FPJZ91.js} +1 -1
  60. package/dist/gateway/static/root/assets/{media-plugins-xbM-SSP5.js → media-plugins-DT0P7j7u.js} +1 -1
  61. package/dist/gateway/static/root/assets/messages-B701TEZ5.js +3 -0
  62. package/dist/gateway/static/root/assets/{notes-api-D9CCwyWK.js → notes-api-q7HjYO07.js} +1 -1
  63. package/dist/gateway/static/root/assets/{notes-page-CMNBbg6g.js → notes-page-Cgl2h7AR.js} +1 -1
  64. package/dist/gateway/static/root/assets/notes-workbench-DFMQYyGJ.js +4 -0
  65. package/dist/gateway/static/root/assets/page-tabs-BaEQMYm_.js +1 -0
  66. package/dist/gateway/static/root/assets/preview-open-alternatives-CsNVTKC0.js +1 -0
  67. package/dist/gateway/static/root/assets/{product-open-page-CZdzgPZW.js → product-open-page-ComKLO4D.js} +1 -1
  68. package/dist/gateway/static/root/assets/project-detail-page-DUFmQscH.js +1 -0
  69. package/dist/gateway/static/root/assets/projects-page-CTWxt3dv.js +1 -0
  70. package/dist/gateway/static/root/assets/{registry-api-DYmKEwiG.js → registry-api-BBoJ7khF.js} +1 -1
  71. package/dist/gateway/static/root/assets/remote-access-hub-qmG-3qjj.js +1 -0
  72. package/dist/gateway/static/root/assets/rotate-cw-LIg3Am9S.js +1 -0
  73. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DQ12tLCL.js → runtime-tools-settings-panel-CXHQc53b.js} +2 -2
  74. package/dist/gateway/static/root/assets/{schema-form-DNCDIkqC.js → schema-form-3jTDF2lJ.js} +1 -1
  75. package/dist/gateway/static/root/assets/search-DA7gz22f.js +1 -0
  76. package/dist/gateway/static/root/assets/sessions-page-D_We4_MV.js +1 -0
  77. package/dist/gateway/static/root/assets/settings-advanced-gate-B_QhPgU0.js +1 -0
  78. package/dist/gateway/static/root/assets/settings-form-section-CUDozALU.js +1 -0
  79. package/dist/gateway/static/root/assets/{settings-loading-skeleton-xgo41cfo.js → settings-loading-skeleton-H3ZH6a6l.js} +1 -1
  80. package/dist/gateway/static/root/assets/{settings-page-8astk_1U.js → settings-page-tx29z21o.js} +1 -1
  81. package/dist/gateway/static/root/assets/setup-status-panel-VunfXpTX.js +1 -0
  82. package/dist/gateway/static/root/assets/{share-preview-page-BBZV4AGy.js → share-preview-page-MyThymEx.js} +1 -1
  83. package/dist/gateway/static/root/assets/shares-settings-DkZvY1cr.js +1 -0
  84. package/dist/gateway/static/root/assets/skill-reload-api-DVDOh1iY.js +1 -0
  85. package/dist/gateway/static/root/assets/skills-page-BOOyMnno.js +2 -0
  86. package/dist/gateway/static/root/assets/{skills-page.utils-HmoDhJVh.js → skills-page.utils-Bl5Yv3Cx.js} +1 -1
  87. package/dist/gateway/static/root/assets/system-settings-panel-DwQ3O1ta.js +1 -0
  88. package/dist/gateway/static/root/assets/tab-completion-input-D64VNmiA.js +1 -0
  89. package/dist/gateway/static/root/assets/tab-completion-input.utils-BP3NH_du.js +1 -0
  90. package/dist/gateway/static/root/assets/task-detail-page-BwOyrADL.js +1 -0
  91. package/dist/gateway/static/root/assets/{theme-store-STx6jo38.js → theme-store-Br4BtK4x.js} +1 -1
  92. package/dist/gateway/static/root/assets/typed-models-lib-q5-Vfqd8.js +1 -0
  93. package/dist/gateway/static/root/assets/{use-autosave-CqFVx92z.js → use-autosave-DRS3RwS9.js} +1 -1
  94. package/dist/gateway/static/root/assets/user-context-page-ClV2r3Cr.js +1 -0
  95. package/dist/gateway/static/root/assets/{voice-api-key-field-pYDiKKMo.js → voice-api-key-field-CGTE5156.js} +1 -1
  96. package/dist/gateway/static/root/assets/{work-discovery-overlay-LJLw9zf0.js → work-discovery-overlay-CW-HKD7h.js} +1 -1
  97. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-D0WhQ3kI.js → workflow-run-setup-panel-Dtr9fDC8.js} +2 -2
  98. package/dist/gateway/static/root/assets/workflows-page-CDOyNgZf.js +5 -0
  99. package/dist/gateway/static/root/index.html +20 -11
  100. package/dist/package.js +1 -1
  101. package/dist/packages/gateway-contract/src/new-session.js +99 -0
  102. package/dist/packages/gateway-contract/src/tasks.js +5 -0
  103. package/dist/packages/gateway-contract/src/user-message-display.js +55 -0
  104. package/dist/src/agent/agent-manager.js +3 -2
  105. package/dist/src/agent/background-review/prompts.d.ts +1 -1
  106. package/dist/src/agent/background-review/prompts.js +6 -3
  107. package/dist/src/agent/background-review/run-background-review.js +144 -16
  108. package/dist/src/agent/inbound/turn-dispatcher.d.ts +3 -1
  109. package/dist/src/agent/inbound/turn-dispatcher.js +2 -1
  110. package/dist/src/agent/memory/context/types.d.ts +1 -1
  111. package/dist/src/agent/memory/create-memory-manager.js +1 -1
  112. package/dist/src/agent/memory/manager.d.ts +2 -1
  113. package/dist/src/agent/memory/manager.js +2 -6
  114. package/dist/src/agent/memory/understanding/service.d.ts +1 -0
  115. package/dist/src/agent/memory/understanding/service.js +179 -36
  116. package/dist/src/agent/memory/understanding/types.d.ts +6 -0
  117. package/dist/src/agent/messaging/command-handler.d.ts +2 -0
  118. package/dist/src/agent/messaging/command-handler.js +3 -1
  119. package/dist/src/agent/service/direct-turn-helpers.d.ts +3 -0
  120. package/dist/src/agent/service/direct-turn-helpers.js +13 -3
  121. package/dist/src/agent/service/process-direct-streaming.d.ts +2 -1
  122. package/dist/src/agent/service/process-direct-streaming.js +12 -11
  123. package/dist/src/agent/session/session-config-service.d.ts +1 -0
  124. package/dist/src/agent/session/session-config-service.js +11 -0
  125. package/dist/src/agent/session/session-inspector.d.ts +1 -0
  126. package/dist/src/agent/session/session-inspector.js +1 -0
  127. package/dist/src/agent/source-context/budget.d.ts +3 -0
  128. package/dist/src/agent/source-context/budget.js +21 -0
  129. package/dist/src/agent/source-context/index.js +3 -3
  130. package/dist/src/agent/source-context/injector.d.ts +2 -2
  131. package/dist/src/agent/source-context/injector.js +19 -9
  132. package/dist/src/agent/source-context/types.d.ts +16 -0
  133. package/dist/src/agent/source-context/types.js +25 -1
  134. package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
  135. package/dist/src/agent/tool-manuals/xopc-use.js +19 -2
  136. package/dist/src/agent/tools/xopc-use-tool.js +62 -2
  137. package/dist/src/agent-runtime/index.js +1 -1
  138. package/dist/src/agent-runtime/runtime-profile.js +1 -1
  139. package/dist/src/browser/backend-from-config.d.ts +8 -0
  140. package/dist/src/browser/backend-from-config.js +16 -1
  141. package/dist/src/browser/providers/browser-ext-install.d.ts +3 -2
  142. package/dist/src/browser/providers/browser-ext-install.js +4 -2
  143. package/dist/src/chat-commands/builtins/review.js +11 -2
  144. package/dist/src/chat-commands/builtins/understanding.js +11 -4
  145. package/dist/src/chat-commands/types.d.ts +4 -0
  146. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  147. package/dist/src/cli/commands/extension-marketplace.js +1 -1
  148. package/dist/src/cli/commands/extension.js +1 -1
  149. package/dist/src/config/agent-profile.js +1 -1
  150. package/dist/src/config/models-json.d.ts +20 -20
  151. package/dist/src/connectors/connected-source-ingestion.js +21 -4
  152. package/dist/src/connectors/connected-source-normalizers.js +51 -4
  153. package/dist/src/connectors/connected-source-understanding.d.ts +20 -0
  154. package/dist/src/connectors/connected-source-understanding.js +180 -0
  155. package/dist/src/connectors/content-enrichment.d.ts +1 -0
  156. package/dist/src/connectors/content-enrichment.js +11 -7
  157. package/dist/src/connectors/learning-coordinator.js +112 -15
  158. package/dist/src/connectors/learning-recipes.js +2 -2
  159. package/dist/src/document-understanding/extract.d.ts +1 -1
  160. package/dist/src/document-understanding/extract.js +54 -1
  161. package/dist/src/extensions/update.js +1 -1
  162. package/dist/src/gateway/agents-admin.js +1 -1
  163. package/dist/src/gateway/chat-stream/mapper.js +18 -0
  164. package/dist/src/gateway/heartbeat/service.js +1 -1
  165. package/dist/src/gateway/hono/routes/agent-stream.js +12 -2
  166. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
  167. package/dist/src/gateway/hono/routes/commands-skills.js +1 -0
  168. package/dist/src/gateway/hono/routes/session-input-handler.d.ts +46 -2
  169. package/dist/src/gateway/hono/routes/session-input-handler.js +23 -3
  170. package/dist/src/gateway/hono/routes/sessions.js +17 -20
  171. package/dist/src/gateway/hono/routes/tasks.js +25 -0
  172. package/dist/src/gateway/hono/routes/understanding-sources.d.ts +9 -0
  173. package/dist/src/gateway/hono/routes/understanding-sources.js +138 -24
  174. package/dist/src/gateway/hono/routes/you.js +71 -4
  175. package/dist/src/gateway/rate-limit/buckets.d.ts +1 -1
  176. package/dist/src/gateway/rate-limit/buckets.js +2 -2
  177. package/dist/src/gateway/service/agent-runner.d.ts +7 -2
  178. package/dist/src/gateway/service/agent-runner.js +21 -1
  179. package/dist/src/gateway/service/config-coordinator.js +1 -1
  180. package/dist/src/gateway/service/run-gateway-agent.d.ts +2 -0
  181. package/dist/src/gateway/service/run-gateway-agent.js +2 -1
  182. package/dist/src/gateway/service/session-input-coordinator.d.ts +8 -2
  183. package/dist/src/gateway/service/session-input-coordinator.js +62 -3
  184. package/dist/src/gateway/service/sessions-api.d.ts +1 -0
  185. package/dist/src/gateway/service.d.ts +3 -2
  186. package/dist/src/gateway/service.js +16 -6
  187. package/dist/src/gateway/user-turn-input.d.ts +2 -0
  188. package/dist/src/gateway/xopc-cloud-capability-setup.d.ts +3 -2
  189. package/dist/src/gateway/xopc-cloud-capability-setup.js +16 -3
  190. package/dist/src/heartbeat/index.js +1 -1
  191. package/dist/src/infra/update-runner.js +1 -1
  192. package/dist/src/knowledge/connected-understanding-pipeline.d.ts +1 -1
  193. package/dist/src/knowledge/connected-understanding-pipeline.js +4 -2
  194. package/dist/src/retrieval/queryProfile.d.ts +1 -0
  195. package/dist/src/retrieval/queryProfile.js +9 -1
  196. package/dist/src/session/client-history.d.ts +11 -0
  197. package/dist/src/session/client-history.js +24 -2
  198. package/dist/src/session/config-types.d.ts +1 -1
  199. package/dist/src/session/session-title.js +2 -3
  200. package/dist/src/session/store.js +1 -0
  201. package/dist/src/session/transcript-outline.js +5 -2
  202. package/dist/src/session/types.d.ts +1 -0
  203. package/dist/src/session/user-message-display.d.ts +4 -0
  204. package/dist/src/session/user-message-display.js +22 -0
  205. package/dist/src/storage/sqlite/context-extraction-repository.d.ts +57 -0
  206. package/dist/src/storage/sqlite/context-extraction-repository.js +119 -0
  207. package/dist/src/storage/sqlite/context-relation-repository.d.ts +50 -0
  208. package/dist/src/storage/sqlite/context-relation-repository.js +97 -0
  209. package/dist/src/storage/sqlite/index.d.ts +4 -2
  210. package/dist/src/storage/sqlite/index.js +5 -3
  211. package/dist/src/storage/sqlite/migrations/126_focus_context_governance.sql +72 -0
  212. package/dist/src/storage/sqlite/migrations/127_context_object_origin.sql +36 -0
  213. package/dist/src/storage/sqlite/migrations/128_context_extraction.sql +73 -0
  214. package/dist/src/storage/sqlite/migrations/129_focus_versions.sql +51 -0
  215. package/dist/src/storage/sqlite/migrations/130_context_evidence_provenance.sql +18 -0
  216. package/dist/src/storage/sqlite/migrations/131_session_input_contexts.sql +2 -0
  217. package/dist/src/storage/sqlite/migrations/132_transcript_source_context_metadata.sql +34 -0
  218. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  219. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  220. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  221. package/dist/src/storage/sqlite/schema.js +1 -1
  222. package/dist/src/storage/sqlite/session-input-repository.d.ts +8 -0
  223. package/dist/src/storage/sqlite/session-input-repository.js +19 -7
  224. package/dist/src/storage/sqlite/session-turn-replace-repository.d.ts +3 -0
  225. package/dist/src/storage/sqlite/session-turn-replace-repository.js +3 -2
  226. package/dist/src/storage/sqlite/transcript-repository.js +29 -3
  227. package/dist/src/storage/sqlite/user-context-repository.d.ts +4 -1
  228. package/dist/src/storage/sqlite/user-context-repository.js +65 -29
  229. package/dist/src/tasks/index.d.ts +1 -0
  230. package/dist/src/tasks/index.js +2 -1
  231. package/dist/src/tasks/task-deletion-service.d.ts +21 -0
  232. package/dist/src/tasks/task-deletion-service.js +35 -0
  233. package/dist/src/tasks/task-repository.js +22 -1
  234. package/dist/src/tui/backends/embedded-backend.js +5 -3
  235. package/dist/src/tui/backends/gateway-realtime-backend.js +5 -3
  236. package/dist/src/tui/chat-history.js +2 -1
  237. package/dist/src/tui/tui-agent-events.js +4 -2
  238. package/dist/src/tui/tui-commands.d.ts +1 -0
  239. package/dist/src/tui/tui-commands.js +8 -3
  240. package/dist/src/tui/tui-empty-session-cleanup.d.ts +0 -1
  241. package/dist/src/tui/tui-empty-session-cleanup.js +1 -11
  242. package/dist/src/tui/tui-new-session-preferences.d.ts +10 -0
  243. package/dist/src/tui/tui-new-session-preferences.js +32 -0
  244. package/dist/src/tui/tui-session-actions.d.ts +1 -0
  245. package/dist/src/tui/tui-session-actions.js +2 -1
  246. package/dist/src/tui/tui-settings.d.ts +2 -0
  247. package/dist/src/tui/tui-settings.js +4 -1
  248. package/dist/src/tui/tui-types.d.ts +1 -0
  249. package/dist/src/tui/tui.js +57 -4
  250. package/dist/src/tunnel/frpc-process.js +3 -0
  251. package/dist/src/tunnel/tunnel-service.d.ts +2 -0
  252. package/dist/src/tunnel/tunnel-service.js +40 -28
  253. package/dist/src/user-context/context-objects.d.ts +17 -0
  254. package/dist/src/user-context/context-objects.js +99 -0
  255. package/dist/src/user-context/domain.d.ts +13 -1
  256. package/dist/src/user-context/evaluation/harness.d.ts +13 -0
  257. package/dist/src/user-context/evaluation/harness.js +31 -0
  258. package/dist/src/user-context/extraction/registry.d.ts +26 -0
  259. package/dist/src/user-context/extraction/registry.js +113 -0
  260. package/dist/src/user-context/extraction/repair.d.ts +19 -0
  261. package/dist/src/user-context/extraction/repair.js +68 -0
  262. package/dist/src/user-context/planner.js +214 -57
  263. package/dist/src/user-context/retriever.js +69 -9
  264. package/dist/src/user-context/sources/catalog.js +9 -2
  265. package/dist/src/user-context/sources/index.js +2 -2
  266. package/dist/src/user-context/sources/local-source-contract.d.ts +1 -1
  267. package/dist/src/user-context/sources/local-source-contract.js +1 -0
  268. package/dist/src/user-context/sources/processing-policy.d.ts +2 -0
  269. package/dist/src/user-context/sources/processing-policy.js +7 -0
  270. package/dist/src/user-context/sources/repository.d.ts +23 -4
  271. package/dist/src/user-context/sources/repository.js +122 -12
  272. package/dist/src/user-context/sources/types.d.ts +10 -1
  273. package/dist/src/user-context/understanding-writing.d.ts +1 -0
  274. package/dist/src/user-context/understanding-writing.js +4 -0
  275. package/dist/src/user-context/understanding.js +1 -1
  276. package/dist/src/work-discovery/analyzer.d.ts +6 -0
  277. package/dist/src/work-discovery/analyzer.js +181 -57
  278. package/dist/src/work-discovery/index.js +1 -1
  279. package/dist/src/work-discovery/probe.js +20 -0
  280. package/dist/src/work-discovery/service.d.ts +9 -0
  281. package/dist/src/work-discovery/service.js +39 -11
  282. package/dist/src/work-discovery/source-repository.js +1 -1
  283. package/dist/src/work-discovery/types.d.ts +5 -0
  284. package/package.json +3 -3
  285. package/dist/gateway/static/root/assets/agents-C6q_vDzP.js +0 -68
  286. package/dist/gateway/static/root/assets/app-management-settings-panel-DRsTwFbF.js +0 -1
  287. package/dist/gateway/static/root/assets/appearance-settings-B99NaPTf.js +0 -1
  288. package/dist/gateway/static/root/assets/apps-page-Dx66anqa.js +0 -1
  289. package/dist/gateway/static/root/assets/automations-workspace-CHbA8d-P.js +0 -6
  290. package/dist/gateway/static/root/assets/browser-settings-page-CpRc-9Jy.js +0 -8
  291. package/dist/gateway/static/root/assets/capabilities-settings-panel-C89FGECN.js +0 -7
  292. package/dist/gateway/static/root/assets/capability-presets-settings-panel-XT6WEz9E.js +0 -3
  293. package/dist/gateway/static/root/assets/channels-settings-DhKk1oNT.js +0 -1
  294. package/dist/gateway/static/root/assets/channels-status-swr-CiwOOoVL.js +0 -1
  295. package/dist/gateway/static/root/assets/chat-terminal-dock-CTbkTsc2.js +0 -36
  296. package/dist/gateway/static/root/assets/connectors-page-BDn3HTzX.js +0 -2
  297. package/dist/gateway/static/root/assets/date-picker-BmZjs4Bq.js +0 -1
  298. package/dist/gateway/static/root/assets/dependency-picker-ndtb88_T.js +0 -1
  299. package/dist/gateway/static/root/assets/desktop-pet-settings-C7BLs783.js +0 -1
  300. package/dist/gateway/static/root/assets/directory-picker-path-field-BWiap88p.js +0 -1
  301. package/dist/gateway/static/root/assets/extension-settings-page-BhbcGuiJ.js +0 -1
  302. package/dist/gateway/static/root/assets/gateway-config-api-CUt9bIpL.js +0 -1
  303. package/dist/gateway/static/root/assets/gateway-settings-RafSECLG.js +0 -1
  304. package/dist/gateway/static/root/assets/heartbeat-settings-CwVPlPLB.js +0 -1
  305. package/dist/gateway/static/root/assets/home-page-CbdBcCwC.js +0 -1
  306. package/dist/gateway/static/root/assets/index-AbNnQyKk.css +0 -2
  307. package/dist/gateway/static/root/assets/index-CMLkr37Y.js +0 -108
  308. package/dist/gateway/static/root/assets/local-app-workbench-page-DdaPtQ5M.js +0 -2
  309. package/dist/gateway/static/root/assets/logs-page-CjxMHTQO.js +0 -2
  310. package/dist/gateway/static/root/assets/messages-VI9m1xJl.js +0 -3
  311. package/dist/gateway/static/root/assets/notes-workbench-V9C-8vSn.js +0 -4
  312. package/dist/gateway/static/root/assets/page-tabs-e99j9S9K.js +0 -1
  313. package/dist/gateway/static/root/assets/preview-open-alternatives-DW9MDOva.js +0 -1
  314. package/dist/gateway/static/root/assets/project-detail-page-DHmAUggu.js +0 -1
  315. package/dist/gateway/static/root/assets/projects-page-D0EiN69Y.js +0 -1
  316. package/dist/gateway/static/root/assets/remote-access-hub-BuAVFk2O.js +0 -1
  317. package/dist/gateway/static/root/assets/sessions-page-hzlTfgOl.js +0 -1
  318. package/dist/gateway/static/root/assets/settings-advanced-gate-BlCoA_9h.js +0 -1
  319. package/dist/gateway/static/root/assets/settings-form-section-z0JH53Fu.js +0 -1
  320. package/dist/gateway/static/root/assets/setup-status-panel-fZQfoJAk.js +0 -1
  321. package/dist/gateway/static/root/assets/shares-settings-B5dPMq3Y.js +0 -1
  322. package/dist/gateway/static/root/assets/skill-reload-api-i1PGf1V2.js +0 -1
  323. package/dist/gateway/static/root/assets/skills-page-BSN2VaqR.js +0 -2
  324. package/dist/gateway/static/root/assets/system-settings-panel-CSibO8vj.js +0 -1
  325. package/dist/gateway/static/root/assets/tab-completion-input-B-VsxKhC.js +0 -1
  326. package/dist/gateway/static/root/assets/task-detail-page-HCKZ11E8.js +0 -1
  327. package/dist/gateway/static/root/assets/typed-models-lib-zrYg51t3.js +0 -1
  328. package/dist/gateway/static/root/assets/user-context-page-CqG56cDS.js +0 -1
  329. package/dist/gateway/static/root/assets/workflows-page-DQAJzV5w.js +0 -5
@@ -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{l as i,p as a}from"./chunk-KS7C4IRE-BaASWQor.js";import{t as o}from"./check-DUBLcKHA.js";import{n as s,r as c,t as l}from"./popover-select-BzdnTy3h.js";import{t as u}from"./circle-check-C23XjkUj.js";import{t as d}from"./loader-circle-CifKLtgG.js";import{t as f}from"./plus-Q2yW6OE7.js";import{t as p}from"./x-B_N4OPjy.js";import{t as m}from"./cn-JdwAhgNB.js";import{t as h}from"./button-CSEbl4zT.js";import{n as g}from"./copy-to-clipboard-HOJ79TWv.js";import{t as _}from"./messages-VI9m1xJl.js";import{l as v,n as y,r as b,s as x}from"./locale-store-De8wYkd7.js";import{i as S,o as C}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as w}from"./electron-env-DH5wF8X8.js";import{a as T,i as E,n as D,o as O,r as k,s as A,t as j}from"./dist-BPoKqzeH.js";import{n as M,r as N}from"./gateway-config-swr-BTH9HVUk.js";import{a as P,i as F,n as I,o as L,r as R}from"./dist-DY4Af0fY.js";import{At as z,Br as B,Bs as V,Bt as H,Ct as ee,Ds as te,Dt as U,Et as ne,Fr as W,Ft as re,Gt as ie,Ht as ae,Ic as oe,Il as se,Ir as ce,It as le,Jt as ue,Kt as de,Lr as fe,Ls as pe,Lt as me,Mt as he,Nl as ge,Nt as _e,Ot as ve,Pt as ye,Rr as be,Rt as xe,Sl as Se,St as Ce,Tt as we,Us as G,Ut as K,Vs as q,Vt as Te,Ws as Ee,Wt as De,Xo as J,Yt as Oe,_t as Y,al as ke,bt as Ae,ca as je,cs as Me,dc as Ne,ec as Pe,gt as Fe,ht as Ie,is as Le,jt as Re,kt as ze,nc as Be,pl as Ve,qs as He,qt as Ue,ro as We,ts as Ge,vs as Ke,vt as qe,ws as Je,wt as Ye,xl as Xe,xt as Ze,yt as Qe,zt as $e}from"./index-CMLkr37Y.js";import{t as et}from"./page-tabs-e99j9S9K.js";var X=e(t(),1),Z=n(),Q=r();function tt(e){let t=(0,Z.c)(74),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:o}=e,s,c,l,d,f,p,g,_,v,y;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(nt),b=e.slice(0,3),x=Math.max(0,e.length-b.length),S=o.connect,C=n.verificationLevel===`verified`?o.connectorVerified:n.verificationLevel===`beta`?o.connectorBeta:n.verificationLevel===`experimental`?o.connectorExperimental:null,w;t[20]!==S||t[21]!==n||t[22]!==i?(w=e=>(0,Q.jsxs)(h,{type:`button`,variant:`primary`,className:m(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:e=>{e.stopPropagation(),i(n)},children:[(0,Q.jsx)(Ne,{className:`size-4`}),S]}),t[20]=S,t[21]=n,t[22]=i,t[23]=w):w=t[23],s=w;let T;t[24]!==n||t[25]!==a?(T=e=>{!a||e.currentTarget!==e.target||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),a(n))},t[24]=n,t[25]=a,t[26]=T):T=t[26];let E=T,D=a?`cursor-pointer`:null;t[27]===D?p=t[28]:(p=m(`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`,D),t[27]=D,t[28]=p),g=a?`button`:void 0,_=a?0:void 0,t[29]!==n||t[30]!==a?(v=()=>a?.(n),t[29]=n,t[30]=a,t[31]=v):v=t[31],y=E,c=`flex min-w-0 flex-1 flex-col`;let O;t[32]===n?O=t[33]:(O=(0,Q.jsx)(qe,{connector:n}),t[32]=n,t[33]=O);let k;t[34]===n.displayName?k=t[35]:(k=(0,Q.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[34]=n.displayName,t[35]=k);let A;t[36]===C?A=t[37]:(A=C?(0,Q.jsx)(`span`,{className:`mt-1 inline-flex rounded-full border border-edge px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:C}):null,t[36]=C,t[37]=A);let j;t[38]!==k||t[39]!==A?(j=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[k,A]}),t[38]=k,t[39]=A,t[40]=j):j=t[40];let M;t[41]!==O||t[42]!==j?(M=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[O,j]}),t[41]=O,t[42]=j,t[43]=M):M=t[43];let N;t[44]!==r||t[45]!==s?(N=r?null:(0,Q.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 transition-opacity sm:pointer-events-none sm:flex sm:opacity-0 sm:group-hover:pointer-events-auto sm:group-hover:opacity-100 sm:group-focus-within:pointer-events-auto sm:group-focus-within:opacity-100`,children:s()}),t[44]=r,t[45]=s,t[46]=N):N=t[46];let P;t[47]!==r||t[48]!==o.connectedBadge?(P=r?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,Q.jsx)(u,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[47]=r,t[48]=o.connectedBadge,t[49]=P):P=t[49];let F;t[50]!==N||t[51]!==P?(F=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[N,P]}),t[50]=N,t[51]=P,t[52]=F):F=t[52],t[53]!==M||t[54]!==F?(l=(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[M,F]}),t[53]=M,t[54]=F,t[55]=l):l=t[55],t[56]===n.description?d=t[57]:(d=(0,Q.jsx)(`p`,{className:`mt-4 line-clamp-2 text-sm leading-6 text-fg-muted`,title:n.description,children:n.description}),t[56]=n.description,t[57]=d),f=b.length>0?(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-1.5`,children:[b.map(e=>(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:o.connectorCapabilityLabels[e]??e},e)),x>0?(0,Q.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,x]}):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]=s,t[11]=c,t[12]=l,t[13]=d,t[14]=f,t[15]=p,t[16]=g,t[17]=_,t[18]=v,t[19]=y}else s=t[10],c=t[11],l=t[12],d=t[13],f=t[14],p=t[15],g=t[16],_=t[17],v=t[18],y=t[19];let b;t[58]!==c||t[59]!==l||t[60]!==d||t[61]!==f?(b=(0,Q.jsxs)(`div`,{className:c,children:[l,d,f]}),t[58]=c,t[59]=l,t[60]=d,t[61]=f,t[62]=b):b=t[62];let x;t[63]!==r||t[64]!==s?(x=r?null:(0,Q.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:s(`w-full`)}),t[63]=r,t[64]=s,t[65]=x):x=t[65];let S;return t[66]!==b||t[67]!==x||t[68]!==p||t[69]!==g||t[70]!==_||t[71]!==v||t[72]!==y?(S=(0,Q.jsxs)(`div`,{className:p,role:g,tabIndex:_,onClick:v,onKeyDown:y,children:[b,x]}),t[66]=b,t[67]=x,t[68]=p,t[69]=g,t[70]=_,t[71]=v,t[72]=y,t[73]=S):S=t[73],S}function nt(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var rt=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function it(e,t){return t.some(t=>t.connectorId===e.id)}var at=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function ot(){let e=(0,Z.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(`div`,{className:m(`size-10 shrink-0 rounded-xl`,at)}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(`div`,{className:`flex h-full min-h-[9.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:[t,(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Q.jsx)(`div`,{className:m(`h-4 min-w-0 flex-1`,at)}),(0,Q.jsx)(`div`,{className:m(`h-8 w-[4.5rem] shrink-0 rounded-lg`,at)})]}),(0,Q.jsx)(`div`,{className:m(`h-3 w-full`,at)}),(0,Q.jsx)(`div`,{className:m(`h-3 w-[88%]`,at)})]})]})}),e[1]=n):n=e[1],n}var $=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function st(){let e=(0,Z.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(`div`,{className:m(`size-10 shrink-0 rounded-xl`,$)}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,Q.jsx)(`div`,{className:m(`h-4 w-48 max-w-full`,$)}),(0,Q.jsx)(`div`,{className:m(`h-3 w-72 max-w-full`,$)})]}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-start justify-between gap-3`,children:[n,(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Q.jsx)(`div`,{className:m(`h-9 w-20 rounded-lg`,$)}),(0,Q.jsx)(`div`,{className:m(`h-9 w-20 rounded-lg`,$)})]})]})]}),e[2]=r):r=e[2];let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:[r,(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,Q.jsx)(`div`,{className:m(`h-8 w-20 rounded-md`,$)}),(0,Q.jsx)(`div`,{className:m(`h-8 w-24 rounded-md`,$)}),(0,Q.jsx)(`div`,{className:m(`h-8 w-28 rounded-md`,$)})]}),(0,Q.jsx)(`div`,{className:m(`mt-3 h-20 rounded-xl`,$)})]}),e[3]=i):i=e[3],i}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,Z.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,Q.jsx)(`div`,{className:`border-b border-edge px-3 py-2 text-xs font-semibold text-fg`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,16).map(mt),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>16?(0,Q.jsxs)(`div`,{className:`px-3 py-2 text-xs text-fg-subtle`,children:[`+`,r.length-16]}):null,t[4]=r.length,t[5]=o);let s;t[6]!==a||t[7]!==o?(s=(0,Q.jsxs)(`div`,{className:`max-h-48 overflow-y-auto`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==i||t[10]!==s?(c=(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base`,children:[i,s]}),t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function mt(e){return(0,Q.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,Q.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,Q.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function ht({connector:e,installed:t,onClose:n,onInstall:r,t:i}){let[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(null),[l,f]=(0,X.useState)(null),g=ft(e),_=e.capabilities.slice(0,8),v=Math.max(0,e.capabilities.length-_.length),y=[...(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}))],b=async()=>{o(!0),f(null);try{c(await re(e))}catch(e){c(null),f(e instanceof Error?e.message:String(e))}finally{o(!1)}};return(0,Q.jsx)(j,{open:!0,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(O,{children:[(0,Q.jsx)(T,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(k,{className:m(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,52rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float outline-none dark:border-edge`),children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Q.jsx)(qe,{connector:e,size:`lg`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[t?(0,Q.jsx)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,Q.jsx)(u,{className:`size-3`,"aria-hidden":!0}),i.connectedBadge]})}):null,(0,Q.jsx)(A,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,Q.jsx)(E,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:e.description})]})]}),(0,Q.jsx)(D,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:m(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,J.focusRingPanel),"aria-label":i.modalClose,children:[(0,Q.jsx)(p,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,Q.jsx)(Le,{className:`size-3.5`,"aria-hidden":!0}),i.detailTools]}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:s?ct(i.connectorPreviewToolsCount,{count:s.toolCount}):i.connectorPreviewUnknown})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,Q.jsx)(oe,{className:`size-3.5`,"aria-hidden":!0}),i.detailPermissions]}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:dt(e,i)})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,Q.jsx)(Ve,{className:`size-3.5`,"aria-hidden":!0}),i.connectorRequiredInputs]}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:ct(i.connectorRequiredInputsCount,{count:g})})]})]}),(0,Q.jsxs)(`div`,{className:`mt-5 grid gap-5 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.connectorCapabilitiesTitle}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[_.map(e=>(0,Q.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-muted`,children:lt(e,i)},e)),v>0?(0,Q.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-subtle`,children:[`+`,v]}):null]})]}),l?(0,Q.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:l}):null,s?(0,Q.jsxs)(`section`,{children:[(0,Q.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.connectorPreviewTitle}),(0,Q.jsx)(`span`,{className:m(`rounded-full px-2 py-0.5 text-xs font-medium`,s.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:s.ok?i.healthStatusHealthy:i.healthStatusLabels[s.status]??s.status})]}),(0,Q.jsxs)(`div`,{className:`mb-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:s.toolCount}),(0,Q.jsx)(`div`,{className:`text-fg-muted`,children:i.toolsMetric})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:s.resourceCount}),(0,Q.jsx)(`div`,{className:`text-fg-muted`,children:i.resourcesMetric})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:s.promptCount}),(0,Q.jsx)(`div`,{className:`text-fg-muted`,children:i.promptsMetric})]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(pt,{title:i.detailTools,items:s.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,Q.jsx)(pt,{title:i.detailResources,items:s.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,Q.jsx)(pt,{title:i.detailPrompts,items:s.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??ct(i.promptArgumentCount,{count:e.argumentCount})}))})]}),s.error?(0,Q.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:s.error}):null,s.action?(0,Q.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-subtle`,children:s.action}):null]}):null]}),(0,Q.jsxs)(`aside`,{className:`space-y-3`,children:[(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(oe,{className:`size-4 text-accent`,"aria-hidden":!0}),i.detailPermissions]}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-medium text-fg`,children:dt(e,i)})]}),(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(Ve,{className:`size-4 text-accent`,"aria-hidden":!0}),i.connectorSetupTitle]}),y.length>0?(0,Q.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-lg border border-edge`,children:y.map(e=>(0,Q.jsxs)(`div`,{className:`bg-surface-panel px-3 py-2.5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e.kind}),e.required?(0,Q.jsx)(`span`,{className:`rounded-md bg-amber-500/10 px-1.5 py-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-300`,children:i.connectorSetupRequired}):null]}),e.description?(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.key))}):(0,Q.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:i.connectorSetupNone})]}),(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(q,{className:`size-4 text-accent`,"aria-hidden":!0}),i.connectorRuntimeTitle]}),(0,Q.jsx)(`p`,{className:`mt-2 break-words text-xs leading-5 text-fg-muted`,children:ut(e,i)})]})]})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,Q.jsx)(D,{asChild:!0,children:(0,Q.jsx)(h,{variant:`secondary`,children:i.modalClose})}),(0,Q.jsxs)(h,{variant:`secondary`,disabled:a,onClick:()=>void b(),children:[a?(0,Q.jsx)(d,{className:`size-4 animate-spin`}):(0,Q.jsx)(Le,{className:`size-4`}),i.connectorPreviewButton]}),t?(0,Q.jsxs)(h,{variant:`secondary`,disabled:!0,children:[(0,Q.jsx)(Be,{className:`size-4`}),i.connectedBadge]}):(0,Q.jsxs)(h,{variant:`primary`,onClick:()=>{r(e),n()},children:[(0,Q.jsx)(Ne,{className:`size-4`}),i.connect]})]})]})]})})}var gt=m(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Ge);function _t(e){let t=(0,Z.c)(58),{open:n,sessionIdleTtlMinutes:r,saving:i,onChange:a,onSave:o,onClose:s,t:c,mcp:l}=e,u;t[0]===s?u=t[1]:(u=e=>{e||s()},t[0]=s,t[1]=u);let f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Q.jsx)(T,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[2]=f):f=t[2];let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=m(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(32rem,calc(100vh-2rem))] w-[min(100%-2rem,38rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),t[3]=g):g=t[3];let _;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,Q.jsx)(Pe,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})}),t[4]=_):_=t[4];let v;t[5]===c.runtimeSettingsTitle?v=t[6]:(v=(0,Q.jsx)(A,{className:`text-base font-semibold text-fg`,children:c.runtimeSettingsTitle}),t[5]=c.runtimeSettingsTitle,t[6]=v);let y;t[7]===c.runtimeSettingsHint?y=t[8]:(y=(0,Q.jsx)(E,{className:`mt-1 text-sm text-fg-muted`,children:c.runtimeSettingsHint}),t[7]=c.runtimeSettingsHint,t[8]=y);let b;t[9]!==v||t[10]!==y?(b=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[_,(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[v,y]})]}),t[9]=v,t[10]=y,t[11]=b):b=t[11];let x;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(x=m(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,J.focusRingPanel),t[12]=x):x=t[12];let S;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Q.jsx)(p,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=S):S=t[13];let C;t[14]===c.modalClose?C=t[15]:(C=(0,Q.jsx)(D,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:x,"aria-label":c.modalClose,children:S})}),t[14]=c.modalClose,t[15]=C);let w;t[16]!==C||t[17]!==b?(w=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[b,C]}),t[16]=C,t[17]=b,t[18]=w):w=t[18];let M;t[19]===l.idleTtlLabel?M=t[20]:(M=(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:l.idleTtlLabel}),t[19]=l.idleTtlLabel,t[20]=M);let N;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(N=m(gt,`w-40 flex-none`),t[21]=N):N=t[21];let P=r??``,F;t[22]===a?F=t[23]:(F=e=>{let t=e.currentTarget.value.trim();a(t===``?void 0:Number.parseInt(t,10))},t[22]=a,t[23]=F);let I;t[24]!==l.idleTtlPlaceholder||t[25]!==P||t[26]!==F?(I=(0,Q.jsx)(`input`,{type:`number`,min:0,className:N,value:P,placeholder:l.idleTtlPlaceholder,onChange:F}),t[24]=l.idleTtlPlaceholder,t[25]=P,t[26]=F,t[27]=I):I=t[27];let L;t[28]===l.idleTtlHint?L=t[29]:(L=(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:l.idleTtlHint}),t[28]=l.idleTtlHint,t[29]=L);let R;t[30]!==M||t[31]!==I||t[32]!==L?(R=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,Q.jsxs)(`label`,{className:`flex max-w-xl flex-col gap-1.5`,children:[M,I,L]})}),t[30]=M,t[31]=I,t[32]=L,t[33]=R):R=t[33];let z;t[34]!==s||t[35]!==i||t[36]!==c.modalCancel?(z=(0,Q.jsx)(h,{type:`button`,variant:`secondary`,disabled:i,onClick:s,children:c.modalCancel}),t[34]=s,t[35]=i,t[36]=c.modalCancel,t[37]=z):z=t[37];let B;t[38]===o?B=t[39]:(B=()=>void o(),t[38]=o,t[39]=B);let V;t[40]===i?V=t[41]:(V=i?(0,Q.jsx)(d,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[40]=i,t[41]=V);let H;t[42]!==l.save||t[43]!==i||t[44]!==B||t[45]!==V?(H=(0,Q.jsxs)(h,{type:`button`,variant:`primary`,disabled:i,onClick:B,children:[V,l.save]}),t[42]=l.save,t[43]=i,t[44]=B,t[45]=V,t[46]=H):H=t[46];let ee;t[47]!==z||t[48]!==H?(ee=(0,Q.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[z,H]}),t[47]=z,t[48]=H,t[49]=ee):ee=t[49];let te;t[50]!==w||t[51]!==R||t[52]!==ee?(te=(0,Q.jsxs)(O,{children:[f,(0,Q.jsxs)(k,{className:g,children:[w,R,ee]})]}),t[50]=w,t[51]=R,t[52]=ee,t[53]=te):te=t[53];let U;return t[54]!==n||t[55]!==u||t[56]!==te?(U=(0,Q.jsx)(j,{open:n,onOpenChange:u,children:te}),t[54]=n,t[55]=u,t[56]=te,t[57]=U):U=t[57],U}var vt=(0,X.memo)(function(e){let t=(0,Z.c)(12),{value:n,onChange:r,placeholder:i,className:a}=e,o;t[0]===a?o=t[1]:(o=m(`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 s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(G,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=s):s=t[2];let c;t[3]===r?c=t[4]:(c=e=>r(e.currentTarget.value),t[3]=r,t[4]=c);let l;t[5]!==i||t[6]!==c||t[7]!==n?(l=(0,Q.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:n,onChange:c,placeholder:i,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`}),t[5]=i,t[6]=c,t[7]=n,t[8]=l):l=t[8];let u;return t[9]!==o||t[10]!==l?(u=(0,Q.jsxs)(`label`,{className:o,children:[s,l]}),t[9]=o,t[10]=l,t[11]=u):u=t[11],u}),yt=(0,X.memo)(function(e){let t=(0,Z.c)(30),{onBrowseCatalog:n,onAddCustomServer:r,onOpenRuntimeSettings:i,addLabel:a,browseLabel:o,customLabel:s,settingsLabel:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(V,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=l):l=t[0];let u;t[1]===c?u=t[2]:(u=(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:c}),t[1]=c,t[2]=u);let d;t[3]!==i||t[4]!==c||t[5]!==u?(d=(0,Q.jsxs)(h,{type:`button`,variant:`secondary`,className:`shrink-0 gap-2`,"aria-label":c,title:c,onClick:i,children:[l,u]}),t[3]=i,t[4]=c,t[5]=u,t[6]=d):d=t[6];let p;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Q.jsx)(f,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[7]=p):p=t[7];let g;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Q.jsx)(se,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[8]=g):g=t[8];let _;t[9]===a?_=t[10]:(_=(0,Q.jsx)(B,{asChild:!0,children:(0,Q.jsxs)(h,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,children:[p,a,g]})}),t[9]=a,t[10]=_);let v;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(v=m(`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,J.transition),t[11]=v):v=t[11];let y;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(Je,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=y):y=t[12];let b;t[13]!==o||t[14]!==n?(b=(0,Q.jsxs)(ce,{className:v,onSelect:n,children:[y,o]}),t[13]=o,t[14]=n,t[15]=b):b=t[15];let x;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(x=m(`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,J.transition),t[16]=x):x=t[16];let S;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Q.jsx)(Le,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[17]=S):S=t[17];let C;t[18]!==s||t[19]!==r?(C=(0,Q.jsxs)(ce,{className:x,onSelect:r,children:[S,s]}),t[18]=s,t[19]=r,t[20]=C):C=t[20];let w;t[21]!==C||t[22]!==b?(w=(0,Q.jsx)(fe,{children:(0,Q.jsxs)(W,{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:[b,C]})}),t[21]=C,t[22]=b,t[23]=w):w=t[23];let T;t[24]!==w||t[25]!==_?(T=(0,Q.jsxs)(be,{children:[_,w]}),t[24]=w,t[25]=_,t[26]=T):T=t[26];let E;return t[27]!==T||t[28]!==d?(E=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[d,T]}),t[27]=T,t[28]=d,t[29]=E):E=t[29],E}),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),e.requestTimeoutMs!=null&&Number.isFinite(e.requestTimeoutMs)&&(t.requestTimeoutMs=e.requestTimeoutMs),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),e.requestTimeoutMs!=null&&Number.isFinite(e.requestTimeoutMs)&&(t.requestTimeoutMs=e.requestTimeoutMs),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,requestTimeoutMs:typeof t.requestTimeoutMs==`number`&&Number.isFinite(t.requestTimeoutMs)?t.requestTimeoutMs: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,requestTimeoutMs: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 x(b(`/api/config`),{method:`PATCH`,body:JSON.stringify({mcp:r})}),M()}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 x(b(`/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){return e.requestTimeoutMs==null||!Number.isFinite(e.requestTimeoutMs)?``:String(Math.round(e.requestTimeoutMs/1e3))}function Vt(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);if(!(!Number.isFinite(n)||n<1||n>14400))return n*1e3}function Ht(e){if(e.transport===`stdio`){let t=e.command.trim();if(!t)return``;let n=e.argsText.trim();return n?`${t} ${n}`:t}return e.url.trim()}function Ut({row:e,t,cs:n,onEdit:r,onRemove:i}){let[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(null),[f,p]=(0,X.useState)(null),m=Ht(e),g=(0,X.useCallback)(async()=>{o(!0),p(null);try{let t=await Lt(e.id.trim());u({toolCount:t.toolCount,resourceCount:t.resourceCount,promptCount:t.promptCount})}catch(e){p(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.id]),_=(0,X.useCallback)(async()=>{c(!0),p(null);try{await i()}catch(e){p(e instanceof Error?e.message:String(e)),c(!1)}},[i]);return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-[10.5rem] cursor-pointer flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`,onClick:r,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.id.trim()||t.cardUntitled}),(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:n.customBadge}),(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.transportLabels[e.transport]})]}),m?(0,Q.jsx)(`p`,{className:`mt-3 line-clamp-2 break-all font-mono text-xs leading-5 text-fg-subtle`,title:m,children:m}):null,f?(0,Q.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:f}):null,l?(0,Q.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:Y(n.customCapabilitySummary,{tools:String(l.toolCount),resources:String(l.resourceCount),prompts:String(l.promptCount)})}):null]}),(0,Q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.connectorDetails}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(h,{variant:`secondary`,disabled:a,onClick:()=>void g(),children:[a?(0,Q.jsx)(d,{className:`size-4 animate-spin`}):(0,Q.jsx)(Be,{className:`size-4`}),t.testConnection]}),(0,Q.jsxs)(h,{variant:`ghost`,disabled:s,onClick:()=>void _(),children:[s?(0,Q.jsx)(d,{className:`size-4 animate-spin`}):(0,Q.jsx)(Ke,{className:`size-4`}),t.removeServer]})]})]})]})}function Wt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Gt(e,t,n){let r=t.trim().toLowerCase();if(!r)return!0;let i=e.shortName||Wt(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
2
- `).toLowerCase().includes(r)}function Kt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function qt(e){let t=(0,Z.c)(29),{tools:n,stripPrefix:r,searchPlaceholder:i,searchEmptyLabel:a}=e,[o,s]=(0,X.useState)(``),c;if(t[0]!==o||t[1]!==r||t[2]!==n){let e;t[4]!==o||t[5]!==r?(e=e=>Gt(e,o,r),t[4]=o,t[5]=r,t[6]=e):e=t[6],c=n.filter(e),t[0]=o,t[1]=r,t[2]=n,t[3]=c}else c=t[3];let l=c,u;t[7]===o?u=t[8]:(u=o.trim(),t[7]=o,t[8]=u);let d=u.length>0,f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Q.jsx)(G,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=f):f=t[9];let p,h;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(p=m(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg`,`placeholder:text-fg-subtle`,Ge),h=e=>s(e.target.value),t[10]=p,t[11]=h):(p=t[10],h=t[11]);let g;t[12]!==o||t[13]!==i?(g=(0,Q.jsxs)(`div`,{className:`relative`,children:[f,(0,Q.jsx)(`input`,{type:`search`,value:o,placeholder:i,"aria-label":i,className:p,onChange:h})]}),t[12]=o,t[13]=i,t[14]=g):g=t[14];let _;t[15]!==l.length||t[16]!==d||t[17]!==n.length?(_=d?(0,Q.jsxs)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:[l.length,` / `,n.length]}):null,t[15]=l.length,t[16]=d,t[17]=n.length,t[18]=_):_=t[18];let v;t[19]!==g||t[20]!==_?(v=(0,Q.jsxs)(`div`,{className:`border-b border-edge px-5 py-3`,children:[g,_]}),t[19]=g,t[20]=_,t[21]=v):v=t[21];let y;t[22]!==l||t[23]!==a||t[24]!==r?(y=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:l.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a}):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:l.map((e,t)=>{let n=e.shortName||Kt(e.name,r)||e.name||`?`,i=e.name||`tool-${t}`;return(0,Q.jsxs)(`li`,{className:`min-w-0 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[(0,Q.jsx)(`div`,{className:`truncate font-mono text-sm font-medium text-fg`,title:e.name===n?n:e.name,children:n}),e.description?(0,Q.jsx)(`p`,{className:`mt-1 truncate text-xs leading-relaxed text-fg-muted`,title:e.description,children:e.description}):null]},i)})})}),t[22]=l,t[23]=a,t[24]=r,t[25]=y):y=t[25];let b;return t[26]!==v||t[27]!==y?(b=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=b):b=t[28],b}function Jt(e){let t=(0,Z.c)(38),{open:n,onOpenChange:r,serverId:i,title:a,subtitle:o,searchPlaceholder:s,searchEmptyLabel:c,emptyLabel:l,closeLabel:u,tools:d,stripPrefix:f}=e,g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Q.jsx)(T,{className:m(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,C)}),t[0]=g):g=t[0];let _;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(_=m(`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`,S,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`),t[1]=_):_=t[1];let v;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Q.jsx)(Le,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[2]=v):v=t[2];let y;t[3]===a?y=t[4]:(y=(0,Q.jsxs)(A,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[v,a]}),t[3]=a,t[4]=y);let b;t[5]!==i||t[6]!==o||t[7]!==d.length?(b=o.replace(`{{serverId}}`,i).replace(`{{count}}`,String(d.length)),t[5]=i,t[6]=o,t[7]=d.length,t[8]=b):b=t[8];let x;t[9]===b?x=t[10]:(x=(0,Q.jsx)(E,{className:`mt-1 text-sm text-fg-muted`,children:b}),t[9]=b,t[10]=x);let w;t[11]!==y||t[12]!==x?(w=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[y,x]}),t[11]=y,t[12]=x,t[13]=w):w=t[13];let M;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Q.jsx)(p,{className:`size-4`,"aria-hidden":!0}),t[14]=M):M=t[14];let N;t[15]===u?N=t[16]:(N=(0,Q.jsx)(D,{asChild:!0,children:(0,Q.jsx)(h,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":u,children:M})}),t[15]=u,t[16]=N);let P;t[17]!==w||t[18]!==N?(P=(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[w,N]}),t[17]=w,t[18]=N,t[19]=P):P=t[19];let F;t[20]!==l||t[21]!==n||t[22]!==c||t[23]!==s||t[24]!==i||t[25]!==f||t[26]!==d?(F=d.length>0?(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,Q.jsx)(qt,{tools:d,stripPrefix:f,searchPlaceholder:s,searchEmptyLabel:c},`${i}-${n?`open`:`closed`}`)}):(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l})}),t[20]=l,t[21]=n,t[22]=c,t[23]=s,t[24]=i,t[25]=f,t[26]=d,t[27]=F):F=t[27];let I;t[28]===u?I=t[29]:(I=(0,Q.jsx)(`div`,{className:`flex justify-end border-t border-edge px-5 py-3`,children:(0,Q.jsx)(D,{asChild:!0,children:(0,Q.jsx)(h,{type:`button`,variant:`secondary`,children:u})})}),t[28]=u,t[29]=I);let L;t[30]!==P||t[31]!==F||t[32]!==I?(L=(0,Q.jsxs)(O,{children:[g,(0,Q.jsxs)(k,{className:_,children:[P,F,I]})]}),t[30]=P,t[31]=F,t[32]=I,t[33]=L):L=t[33];let R;return t[34]!==r||t[35]!==n||t[36]!==L?(R=(0,Q.jsx)(j,{open:n,onOpenChange:r,children:L}),t[34]=r,t[35]=n,t[36]=L,t[37]=R):R=t[37],R}function Yt(e){let t=e.connectedAt?Date.parse(e.connectedAt):0;return Number.isFinite(t)?t:0}function Xt(e,t){return e.status===`active`&&t.status!==`active`?-1:e.status!==`active`&&t.status===`active`?1:e.isCurrentAuthorization===t.isCurrentAuthorization?e.isDefault===t.isDefault?Yt(t)-Yt(e):e.isDefault?-1:1:e.isCurrentAuthorization?-1:1}function Zt(e){let t=new Map;for(let n of e){let e=n.accountId??n.identityKey??`authorization:${n.id}`;t.set(e,[...t.get(e)??[],n])}return[...t.entries()].map(([e,t])=>{let n=[...t].sort(Xt);return{key:e,primary:n[0],authorizations:n}}).sort((e,t)=>Xt(e.primary,t.primary))}var Qt=m(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Ge);function $t(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function en(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function tn(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 nn(e,t){return e===`active`?t.composioConnectionHealthy:e===`pending`?t.composioConnectionPending:e===`expired`?t.composioConnectionExpired:e===`failed`?t.composioConnectionFailed:e===`revoked`||e===`disabled`?t.composioConnectionRevoked:t.composioConnectionUnknown}function rn(e,t,n){return e.status===`paused`?t?.scanEnabled===!1?n.connectorLearningPausedByPolicy:n.connectorLearningPausedByFailure:e.status===`queued`?n.connectorLearningQueued:e.status===`running`?n.connectorLearningRunning:e.status===`completed`?n.connectorLearningCompleted:n.connectorLearningFailed}function an({instance:e,t,onChanged:n}){let r=$t(e),[i,a]=(0,X.useState)([]),[l,u]=(0,X.useState)([]),[f,g]=(0,X.useState)([]),[_,v]=(0,X.useState)([]),[y,b]=(0,X.useState)(null),[x,S]=(0,X.useState)([]),[C,T]=(0,X.useState)(null),[E,D]=(0,X.useState)(null),[O,k]=(0,X.useState)([]),[A,j]=(0,X.useState)({}),[M,N]=(0,X.useState)(`read`),[P,F]=(0,X.useState)(!1),[I,L]=(0,X.useState)(null),R=(0,X.useMemo)(()=>Zt(i),[i]),B=(0,X.useCallback)(async()=>{if(!(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)){F(!0),L(null);try{let[t,n,i,o,s,c,l,d,f]=await Promise.all([z().catch(()=>[]),Re(r).catch(()=>[]),he(20).catch(()=>[]),U(r).catch(()=>`read`),_e().catch(()=>[]),ne(r).catch(()=>null),we(r).catch(()=>null),ye().catch(()=>[]),ve(r).catch(()=>null)]);a(t.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),u(n),g(i.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())),N(o),v(s.filter(t=>t.connectorId===e.connectorId)),b(c?.policy??null),S(c?.agents??[]),T(l),k(d),D(f);let p=Zt(t.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())).map(e=>e.primary).filter(e=>!!e.accountId),m=await Promise.all(p.map(async e=>[e.accountId,await ze(e.accountId)]).map(e=>e.catch(()=>null)));j(Object.fromEntries(m.filter(e=>e!==null)))}catch(e){L(e instanceof Error?e.message:String(e))}finally{F(!1)}}},[e.connectorId,e.materialized,r]);(0,X.useEffect)(()=>{B()},[B]);let V=(0,X.useCallback)(async()=>{if(r){F(!0),L(null);try{let t=await ae(e.connectorId);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if(w()){let e=await window.electronAPI?.shell?.openExternalUrl(t.authorizationUrl);if(!e?.ok)throw Error(e?.error??`Could not open the system browser.`)}else window.open(t.authorizationUrl,`_blank`,`noopener,noreferrer`);let i=await Oe(r,t.connectionId);if(!i.accountId)throw Error(`Connector account is unavailable.`);await Te(i.accountId),await n?.(),await B()}catch(e){L(e instanceof Error?e.message:String(e))}finally{F(!1)}}},[e.connectorId,B,n,r]),ee=(0,X.useCallback)(async t=>{F(!0),L(null);try{await Ue(e.instanceId,{config:{...e.config??{},...t?{authConfigId:t}:{authConfigId:void 0}}}),await n?.(),await B()}catch(e){L(e instanceof Error?e.message:String(e))}finally{F(!1)}},[e.config,e.instanceId,B,n]),W=(0,X.useCallback)(async e=>{if(r){N(e);try{await H(r,e),await B()}catch(e){L(e instanceof Error?e.message:String(e))}}},[B,r]),re=(0,X.useCallback)(async(e,t)=>{F(!0),L(null);try{await xe(e,t),await B()}catch(e){L(e instanceof Error?e.message:String(e))}finally{F(!1)}},[B]),se=(0,X.useCallback)(async e=>{if(r){L(null);try{b(await de(r,e))}catch(e){L(e instanceof Error?e.message:String(e))}}},[e.connectorId,r]),ce=(0,X.useCallback)(e=>{y&&se({allowedAgentIds:y.allowedAgentIds.includes(e)?y.allowedAgentIds.filter(t=>t!==e):[...y.allowedAgentIds,e]})},[se,y]),fe=(0,X.useCallback)(async e=>{F(!0),L(null);try{await e(),await B()}catch(e){L(e instanceof Error?e.message:String(e))}finally{F(!1)}},[B]);return r?e.materialized.type===`composio`&&e.materialized.role===`credential`?(0,Q.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:t.composioApiKeyStored}):(0,Q.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`font-medium text-fg`,children:Y(t.composioToolkitTitle,{toolkit:r})}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioScopeHint})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsxs)(h,{variant:`secondary`,disabled:P,onClick:()=>void V(),children:[P?(0,Q.jsx)(d,{className:`size-4 animate-spin`}):(0,Q.jsx)(oe,{className:`size-4`}),t.connectOAuth]}),(0,Q.jsx)(h,{variant:`ghost`,disabled:P,onClick:()=>void B(),children:t.refresh})]})]}),I?(0,Q.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:I}):null,E?(0,Q.jsxs)(`div`,{className:`mt-3 rounded-lg border border-edge bg-surface-panel p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:t.composioAuthConfigTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:E.requiresCustomAuthConfig?t.composioAuthConfigRequiredHint:t.composioAuthConfigOptionalHint})]}),(0,Q.jsx)(`a`,{className:`text-xs font-medium text-accent-fg hover:underline`,href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,children:t.composioAuthConfigManage})]}),(0,Q.jsxs)(s,{className:m(Qt,`mt-2 h-9 py-1`),value:typeof e.config?.authConfigId==`string`?e.config.authConfigId:``,disabled:P,onChange:e=>void ee(e.currentTarget.value),children:[E.requiresCustomAuthConfig?null:(0,Q.jsx)(c,{value:``,children:t.composioAuthConfigManaged}),E.requiresCustomAuthConfig&&typeof e.config?.authConfigId!=`string`?(0,Q.jsx)(c,{value:``,disabled:!0,children:t.composioAuthConfigSelect}):null,E.authConfigs.filter(e=>e.status===`ENABLED`&&e.isEnabledForToolRouter).map(e=>(0,Q.jsxs)(c,{value:e.id,children:[e.name,` · `,e.authScheme??`OAuth`,` · `,e.id]},e.id))]}),E.requiresCustomAuthConfig&&E.authConfigs.every(e=>e.status!==`ENABLED`||!e.isEnabledForToolRouter)?(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-amber-700 dark:text-amber-300`,children:t.composioAuthConfigEmpty}):null]}):null,C?(0,Q.jsxs)(`div`,{className:m(`mt-3 flex flex-wrap items-center justify-between gap-2 rounded-lg border px-3 py-2 text-xs`,C.status===`connected`?`border-emerald-500/30 bg-emerald-500/5 text-emerald-700`:`border-amber-500/30 bg-amber-500/5 text-amber-700`),children:[(0,Q.jsx)(`span`,{children:C.status===`connected`?Y(t.composioHealthConnected,{count:String(R.filter(e=>e.primary.status===`active`).length)}):C.status===`reauthorization_required`?t.composioHealthReconnect:C.status===`degraded`?tn(C,t):t.composioHealthDisconnected}),C.recovery===`none`?null:(0,Q.jsx)(h,{variant:`ghost`,disabled:P,onClick:()=>void(C.recovery===`retry`?B():V()),children:C.recovery===`retry`?t.composioRetry:t.connectOAuth}),C.status===`degraded`&&C.message?(0,Q.jsx)(`p`,{className:`basis-full break-words text-[11px] opacity-80`,children:C.message}):null]}):null,y?(0,Q.jsxs)(`div`,{className:`mt-4 grid gap-3 rounded-lg border border-edge bg-surface-panel p-3 md:grid-cols-3`,children:[(0,Q.jsxs)(`label`,{className:`text-xs font-medium text-fg-subtle`,children:[t.composioAccessTitle,(0,Q.jsxs)(s,{className:m(Qt,`mt-1 h-9 py-1`),value:M,onChange:e=>void W(e.currentTarget.value),children:[(0,Q.jsx)(c,{value:`read`,children:t.composioAccessReadOnly}),(0,Q.jsx)(c,{value:`write`,children:t.composioAccessReadWrite}),M===`admin`?(0,Q.jsx)(c,{value:`admin`,children:t.composioAccessAdminCurrent}):null]}),(0,Q.jsx)(`span`,{className:`mt-1 block font-normal leading-4 text-fg-muted`,children:M===`read`?t.composioAccessReadHint:M===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,Q.jsxs)(`label`,{className:`text-xs font-medium text-fg-subtle`,children:[t.composioConfirmationPolicy,(0,Q.jsxs)(s,{className:m(Qt,`mt-1 h-9 py-1`),value:y.confirmationPolicy,onChange:e=>void se({confirmationPolicy:e.currentTarget.value}),children:[(0,Q.jsx)(c,{value:`writes`,children:t.composioConfirmWrites}),(0,Q.jsx)(c,{value:`always`,children:t.composioConfirmAlways}),y.confirmationPolicy===`never`?(0,Q.jsx)(c,{value:`never`,children:t.composioConfirmNever}):null]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:t.composioAllowedAgents}),(0,Q.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:y.allowedAgentIds.length?t.composioAllowedAgentsSelected:t.composioAllowedAgentsAll}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:x.map(e=>(0,Q.jsx)(`button`,{type:`button`,className:m(`rounded-full border px-2.5 py-1 text-xs transition-colors`,y.allowedAgentIds.includes(e.id)?`border-accent bg-accent/10 text-accent`:`border-edge text-fg-muted hover:text-fg`),onClick:()=>ce(e.id),children:e.name},e.id))})]})]}):null,_.length?(0,Q.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioPendingApprovals}),_.map(e=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-amber-500/30 bg-amber-500/5 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`truncate font-mono text-xs font-medium text-fg`,children:e.actionId}),(0,Q.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs text-fg-subtle`,children:JSON.stringify(e.argumentsPreview)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:Y(t.composioApprovalExpires,{time:new Date(e.expiresAt).toLocaleTimeString()})})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Q.jsxs)(h,{variant:`secondary`,disabled:P,onClick:()=>void re(e.id,`denied`),children:[(0,Q.jsx)(p,{className:`size-4`}),t.composioDeny]}),(0,Q.jsxs)(h,{disabled:P,onClick:()=>void re(e.id,`approved`),children:[(0,Q.jsx)(o,{className:`size-4`}),t.approve]})]})]},e.id))]}):null,(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioConnections}),R.length?[{title:t.composioConnectedAccounts,items:R.filter(e=>e.primary.status===`active`)},{title:t.composioNeedsAttention,items:R.filter(e=>e.primary.status!==`active`)}].filter(e=>e.items.length>0).map(e=>(0,Q.jsxs)(`section`,{className:`mb-3 space-y-2`,children:[(0,Q.jsxs)(`h4`,{className:`text-xs font-medium text-fg-muted`,children:[e.title,` · `,e.items.length]}),e.items.map(e=>{let i=e.primary,a=O.find(e=>i.accountId?e.accountId===i.accountId:e.connectionId===i.id),o=i.accountId?A[i.accountId]:void 0;return(0,Q.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-edge bg-surface-panel p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:i.alias??i.workspace??i.accountEmail??i.username??t.composioUnnamedAuthorization}),i.connectedAt?(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:Y(t.composioAuthorizedAt,{time:new Date(i.connectedAt).toLocaleString()})}):null,(0,Q.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[Y(t.composioAuthorizationCount,{count:String(e.authorizations.length)}),e.authorizations.length>1?` · ${Y(t.composioDuplicateAuthorizations,{count:String(e.authorizations.length-1)})}`:``]})]}),(0,Q.jsxs)(`span`,{className:m(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,i.status===`active`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:[nn(i.status,t),i.isDefault?` · ${t.composioDefaultAccount}`:``]})]}),a||i.status===`active`?(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:t.connectorLearningTitle}),(0,Q.jsx)(`p`,{className:m(`mt-1 text-xs`,a?.status===`failed`?`text-red-600`:`text-fg-subtle`),children:a?Y(t.connectorLearningStatus,{status:rn(a,o,t),count:String(a.candidatesCreated)}):t.connectorLearningEmpty}),o?(0,Q.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-subtle`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:o.scanEnabled,disabled:P,onChange:e=>void fe(()=>ue(i.accountId,{scanEnabled:e.currentTarget.checked}))}),t.connectorScheduledScan]}),(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-subtle`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:o.proactiveEnabled,disabled:P||!o.scanEnabled,onChange:e=>void fe(()=>ue(i.accountId,{proactiveEnabled:e.currentTarget.checked}))}),t.connectorProactiveUse]}),o.scanEnabled?(0,Q.jsxs)(`label`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:[t.connectorScanInterval,(0,Q.jsxs)(s,{className:m(Qt,`mt-1 h-8 py-1 text-xs`),value:String(o.intervalMinutes??30),disabled:P,onChange:e=>void fe(()=>ue(i.accountId,{intervalMinutes:Number(e.currentTarget.value)})),children:[(0,Q.jsxs)(c,{value:`5`,children:[`5 `,t.connectorMinutes]}),(0,Q.jsxs)(c,{value:`15`,children:[`15 `,t.connectorMinutes]}),(0,Q.jsxs)(c,{value:`30`,children:[`30 `,t.connectorMinutes]}),(0,Q.jsxs)(c,{value:`60`,children:[`60 `,t.connectorMinutes]})]})]}):null]}):null]}):null,(0,Q.jsxs)(`details`,{className:`text-xs text-fg-subtle`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer`,children:t.composioAdvancedSettings}),(0,Q.jsxs)(`div`,{className:`mt-2 space-y-2 rounded-lg bg-surface-base p-2`,children:[e.authorizations.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`p`,{className:`min-w-0 break-all font-mono`,children:[t.composioAuthorizationId,`: `,e.providerConnectionId]}),(0,Q.jsx)(h,{variant:`ghost`,className:`size-7 shrink-0 p-0`,title:t.composioRevoke,disabled:P,onClick:()=>{window.confirm(t.composioRevokeConfirm)&&fe(()=>$e(e.id))},children:(0,Q.jsx)(Ke,{className:`size-3.5 text-red-500`})})]},e.id)),(0,Q.jsx)(`input`,{className:m(Qt,`h-8 py-1 text-xs`),defaultValue:i.alias??``,placeholder:t.composioAccountAlias,onBlur:e=>{e.currentTarget.value!==(i.alias??``)&&fe(()=>ie(i.id,{alias:e.currentTarget.value}))}})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-1`,children:[(0,Q.jsx)(h,{variant:`ghost`,className:`size-8 p-0`,title:t.composioMakeDefault,disabled:P||i.isDefault||i.status!==`active`,onClick:()=>void fe(async()=>{await ie(i.id,{isDefault:!0}),r&&await de(r,{selectedConnectionIds:[i.id]})}),children:(0,Q.jsx)(te,{className:m(`size-4`,i.isDefault&&`fill-current`)})}),(0,Q.jsx)(h,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:P,onClick:()=>void fe(()=>le(i.id)),children:(0,Q.jsx)(He,{className:`size-4`})}),i.status===`active`?(0,Q.jsxs)(h,{variant:`secondary`,disabled:P,onClick:()=>void fe(async()=>{if(!i.accountId)throw Error(`Connector account is unavailable.`);await Te(i.accountId),await n?.()}),children:[P?(0,Q.jsx)(d,{className:`size-4 animate-spin`}):(0,Q.jsx)(He,{className:`size-4`}),t.composioSyncNow]}):null]})]},e.key)})]},e.title)):(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioConnectionsEmpty})]})}),(0,Q.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge bg-surface-panel p-3`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted`,children:t.composioAdvancedSettings}),(0,Q.jsxs)(`div`,{className:`mt-4 grid gap-4 lg:grid-cols-2`,children:[(0,Q.jsx)(`div`,{className:`space-y-3`,children:(0,Q.jsxs)(`label`,{className:`block text-xs text-fg-subtle`,children:[t.composioAdvancedScope,(0,Q.jsxs)(s,{className:m(Qt,`mt-1 h-9 py-1`),value:M,onChange:e=>void W(e.currentTarget.value),children:[(0,Q.jsx)(c,{value:`read`,children:t.composioScopeRead}),(0,Q.jsx)(c,{value:`write`,children:t.composioScopeWrite}),(0,Q.jsx)(c,{value:`admin`,children:t.composioScopeAdmin})]})]})}),(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),l.length?l.slice(0,8).map(e=>(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-2`,children:[(0,Q.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,Q.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[en(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),f.length?f.slice(0,5).map(e=>(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-2`,children:[(0,Q.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})]})]})]})]})]}):null}var on=m(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Ge);function sn(e,t){return e?t.healthStatusLabels[e]??e:t.healthNotTested}function cn(e,t){let n={};for(let r of e?.setup.config??[]){let e=t.config?.[r.key]??r.defaultValue??``;n[r.key]=typeof e==`string`?e:JSON.stringify(e,null,2)}return n}function ln(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 un(e){let t=(0,Z.c)(12),{title:n,description:r,meta:i}=e,a;t[0]===r?a=t[1]:(a=r?(0,Q.jsx)(F,{delayDuration:300,skipDelayDuration:100,children:(0,Q.jsxs)(P,{children:[(0,Q.jsx)(L,{asChild:!0,children:(0,Q.jsx)(`p`,{tabIndex:0,title:r,className:m(`mt-1 line-clamp-3 cursor-help text-xs leading-5 text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:r})}),(0,Q.jsx)(R,{children:(0,Q.jsx)(I,{side:`top`,align:`start`,sideOffset:6,collisionPadding:12,className:`!z-[10000] max-h-[min(16rem,45vh)] max-w-[min(32rem,calc(100vw-2rem))] overflow-y-auto rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-5 text-fg shadow-popover`,children:(0,Q.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:r})})})]})}):null,t[0]=r,t[1]=a);let o=a,s;t[2]===n?s=t[3]:(s=(0,Q.jsx)(`p`,{className:`min-w-0 break-all font-mono text-xs font-medium leading-5 text-fg`,children:n}),t[2]=n,t[3]=s);let c;t[4]===i?c=t[5]:(c=i?(0,Q.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] leading-4 text-fg-subtle`,children:i}):null,t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;return t[9]!==o||t[10]!==l?(u=(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[l,o]}),t[9]=o,t[10]=l,t[11]=u):u=t[11],u}function dn({instance:e,definition:t,onClose:n,onChanged:r,t:i,mcp:a}){let[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(!1),[u,f]=(0,X.useState)(!1),[g,_]=(0,X.useState)(!1),[v,y]=(0,X.useState)(null),[b,x]=(0,X.useState)(null),[S,C]=(0,X.useState)(e.materialized.type===`mcp`?`health`:`permissions`),[w,M]=(0,X.useState)(!1),[N,P]=(0,X.useState)(()=>cn(t,e)),[F,I]=(0,X.useState)(null),L=t?.setup.config??[],R=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&L.length>0&&(t?.setup.secrets??[]).length===0,z=b?b.toolCount:e.usage.lastToolCount,B=(0,X.useMemo)(()=>{let t=e.materialized.type===`mcp`?[[`health`,pe,i.detailHealth],[`tools`,Le,`${i.detailTools} ${b?b.toolCount:e.usage.lastToolCount??``}`],[`resources`,Ve,`${i.detailResources} ${b?b.resourceCount:e.usage.lastResourceCount??``}`],[`prompts`,ke,`${i.detailPrompts} ${b?b.promptCount:e.usage.lastPromptCount??``}`],[`permissions`,oe,i.detailPermissions]]:[[`permissions`,oe,i.detailPermissions]];return R?[...t,[`config`,Ve,i.connectorConfigLabel]]:t},[b,e.materialized.type,e.usage.lastPromptCount,e.usage.lastResourceCount,e.usage.lastToolCount,R,i]),V=(0,X.useCallback)(async()=>{s(!0),I(null);try{let t=await De(e.instanceId);x(t),t.toolCount>0&&C(`tools`),r()}catch(e){I(e instanceof Error?e.message:String(e))}finally{s(!1)}},[e.instanceId,r]),H=(0,X.useCallback)(async()=>{l(!0),I(null);try{await me(e.instanceId),await r(),n()}catch(e){I(e instanceof Error?e.message:String(e)),l(!1)}},[e.instanceId,r,n]),ee=(0,X.useCallback)(async()=>{if(!(!t||!R)){f(!0),I(null);try{let n={};for(let e of t.setup.config??[]){let t=ln(e.type,N[e.key]??``);t!==void 0&&(n[e.key]=t)}await Ue(e.instanceId,{config:n}),await r(),C(`health`)}catch(e){I(e instanceof Error?e.message:String(e))}finally{f(!1)}}},[N,t,e.instanceId,r,R]),te=(0,X.useCallback)(async()=>{_(!0),y(null),I(null);try{y((await K(e.connectorId)).recordIds.length),await r()}catch(e){I(e instanceof Error?e.message:String(e))}finally{_(!1)}},[e.connectorId,r]);return(0,Q.jsxs)(j,{open:!0,onOpenChange:e=>{e||n()},children:[(0,Q.jsxs)(O,{children:[(0,Q.jsx)(T,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(k,{className:m(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,54rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float outline-none dark:border-edge`),children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Q.jsx)(qe,{connector:t,size:`lg`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(A,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,Q.jsx)(E,{className:`mt-1 text-sm text-fg-muted`,children:t?.description??(e.materialized.type===`mcp`?Y(i.mcpServerRuntime,{serverId:e.materialized.serverId}):Y(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,Q.jsx)(D,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:m(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,J.focusRingPanel),"aria-label":i.modalClose,children:[(0,Q.jsx)(p,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[F?(0,Q.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:F}):null,(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:B.map(([e,t,n])=>(0,Q.jsxs)(`button`,{type:`button`,className:m(`inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs`,S===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:text-fg`),onClick:()=>C(e),children:[(0,Q.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),n]},e))}),(0,Q.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[S===`health`?(0,Q.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,Q.jsxs)(`p`,{children:[i.statusLabel,` `,(0,Q.jsx)(`span`,{className:b?.ok?`font-medium text-emerald-700 dark:text-emerald-300`:`font-medium text-fg`,children:sn(b?.status??e.usage.lastHealthStatus,i)})]}),(0,Q.jsxs)(`p`,{children:[i.lastCheckLabel,` `,e.usage.lastHealthCheckAt?new Date(e.usage.lastHealthCheckAt).toLocaleString():i.never]}),b?.action?(0,Q.jsx)(`p`,{children:b.action}):null]}):null,S===`tools`?b?.tools.length?(0,Q.jsxs)(`div`,{className:`grid gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:Y(i.toolsAvailable,{count:String(b.tools.length)})}),(0,Q.jsx)(h,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>M(!0),children:a.viewAllTools})]}),(0,Q.jsx)(`div`,{className:`grid gap-2`,children:b.tools.slice(0,8).map(e=>(0,Q.jsx)(un,{title:e.shortName??e.name,description:e.description},e.name))})]}):(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-fg-muted`,children:z?Y(i.toolsLastCheckSummary,{count:String(z)}):i.toolsRunTestHint}),(0,Q.jsxs)(h,{type:`button`,variant:`secondary`,disabled:o,onClick:()=>void V(),children:[o?(0,Q.jsx)(d,{className:`size-4 animate-spin`}):(0,Q.jsx)(Be,{className:`size-4`}),i.test]})]}):null,S===`resources`?b?.resources.length?(0,Q.jsx)(`div`,{className:`grid gap-2`,children:b.resources.slice(0,8).map(e=>(0,Q.jsx)(un,{title:e.title??e.name,description:e.uri,meta:e.mimeType},e.uri))}):(0,Q.jsx)(`p`,{className:`text-fg-muted`,children:i.resourcesRunTestHint}):null,S===`prompts`?b?.prompts.length?(0,Q.jsx)(`div`,{className:`grid gap-2`,children:b.prompts.slice(0,8).map(e=>(0,Q.jsx)(un,{title:e.title??e.name,description:e.description,meta:e.argumentCount?Y(i.promptArgumentCount,{count:String(e.argumentCount)}):void 0},e.name))}):(0,Q.jsx)(`p`,{className:`text-fg-muted`,children:i.promptsRunTestHint}):null,S===`permissions`?(0,Q.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,Q.jsx)(`p`,{children:Y(i.secretsConfigured,{count:String(Object.values(e.secretStatus).filter(Boolean).length)})}),(0,Q.jsx)(`p`,{children:e.materialized.type===`mcp`?Y(i.runtimeServerLabel,{runtime:e.materialized.type.toUpperCase(),serverId:e.materialized.serverId}):Y(i.runtimeLabel,{runtime:e.materialized.type.toUpperCase()})}),(0,Q.jsx)(`p`,{children:e.materialized.type===`mcp`?i.mcpPolicyHint:i.connectorPolicyHint})]}):null,S===`config`&&R?(0,Q.jsx)(`div`,{className:`grid gap-3`,children:L.map(e=>(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,Q.jsx)(`input`,{className:on,value:N[e.key]??``,placeholder:e.placeholder,onChange:t=>P(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}),e.materialized.type===`composio`?(0,Q.jsx)(an,{instance:e,t:i,onChanged:r}):null,e.materialized.type===`memorySource`?(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-between gap-3 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`font-medium text-fg`,children:i.connectedSourceSync}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t?.description}),v===null?null:(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:Y(i.connectedSourceSynced,{count:String(v)})})]}),(0,Q.jsxs)(h,{disabled:g,onClick:()=>void te(),children:[g?(0,Q.jsx)(d,{className:`size-4 animate-spin`}):(0,Q.jsx)(Ve,{className:`size-4`}),i.composioSyncNow]})]}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,Q.jsx)(h,{variant:`secondary`,onClick:n,children:i.modalClose}),S===`config`&&R?(0,Q.jsxs)(h,{variant:`primary`,disabled:u,onClick:()=>void ee(),children:[u?(0,Q.jsx)(d,{className:`size-4 animate-spin`}):(0,Q.jsx)(Ee,{className:`size-4`}),i.modalSave]}):null,e.materialized.type===`mcp`?(0,Q.jsxs)(h,{variant:`secondary`,disabled:o,onClick:()=>void V(),children:[o?(0,Q.jsx)(d,{className:`size-4 animate-spin`}):(0,Q.jsx)(Be,{className:`size-4`}),i.test]}):null,(0,Q.jsxs)(h,{variant:`ghost`,disabled:c,onClick:()=>void H(),children:[c?(0,Q.jsx)(d,{className:`size-4 animate-spin`}):(0,Q.jsx)(Ke,{className:`size-4`}),i.remove]})]})]})]}),e.materialized.type===`mcp`?(0,Q.jsx)(Jt,{open:w,onOpenChange:M,serverId:e.materialized.serverId,title:Y(i.installedToolsDialogTitle,{name:e.displayName}),subtitle:i.installedToolsDialogSubtitle,searchPlaceholder:a.toolsDialogSearchPlaceholder,searchEmptyLabel:a.toolsDialogSearchEmpty,emptyLabel:i.toolsRunTestHint,closeLabel:a.toolsDialogClose,tools:b?.tools??[],stripPrefix:`${e.materialized.serverId}__`}):null]})}var fn=[`understand`,`act`,`reach`];function pn(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 mn(e){return pn(e)[0]??`act`}function hn(e,t){let n=t?mn(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 gn({instance:e,definition:t,highlighted:n=!1,onOpenDetails:r,onChanged:i,t:a}){let[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(!1),[f,p]=(0,X.useState)(null),g=(0,X.useCallback)(async()=>{s(!0),p(null);try{await De(e.instanceId),await i()}catch(e){p(e instanceof Error?e.message:String(e))}finally{s(!1)}},[e.instanceId,i]),_=(0,X.useCallback)(async()=>{l(!0),p(null);try{await me(e.instanceId),await i()}catch(e){p(e instanceof Error?e.message:String(e)),l(!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=hn(e,t).state,S=x===`ready`?{label:a.connectionReady,Icon:u,className:`border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`}:x===`needs_setup`?{label:a.connectionNeedsSetup,Icon:ge,className:`border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300`}:{label:a.connectionChecking,Icon:Xe,className:`border-edge bg-surface-base text-fg-muted`};return(0,Q.jsxs)(`div`,{className:m(`flex h-full min-h-[10.5rem] cursor-pointer flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`,n&&`ring-2 ring-accent/45 ring-offset-2 ring-offset-surface-panel`),onClick:()=>r(e),children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3`,children:[(0,Q.jsx)(qe,{connector:t}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.displayName}),(0,Q.jsxs)(`span`,{className:m(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium`,S.className),children:[(0,Q.jsx)(S.Icon,{className:`size-3`,"aria-hidden":!0}),S.label]}),b?(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:a.connectorConfigLabel}):null]}),t?.description?(0,Q.jsx)(`p`,{className:`mt-3 line-clamp-2 text-sm leading-5 text-fg-muted`,children:t.description}):null,(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs text-fg-muted`,children:[(0,Q.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:[a.statusLabel,` `,v]}),(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:Y(a.toolsAvailable,{count:String(y)})})]}),f?(0,Q.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:f}):null]})]}),(0,Q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:a.connectorDetails}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[x===`needs_setup`?(0,Q.jsxs)(h,{variant:`primary`,onClick:()=>r(e),children:[(0,Q.jsx)(ge,{className:`size-4`}),a.connectionResolveAction]}):null,e.materialized.type===`mcp`?(0,Q.jsxs)(h,{variant:`secondary`,disabled:o,onClick:()=>void g(),children:[o?(0,Q.jsx)(d,{className:`size-4 animate-spin`}):(0,Q.jsx)(Be,{className:`size-4`}),a.test]}):null,(0,Q.jsxs)(h,{variant:`ghost`,disabled:c,onClick:()=>void _(),children:[c?(0,Q.jsx)(d,{className:`size-4 animate-spin`}):(0,Q.jsx)(Ke,{className:`size-4`}),a.remove]})]})]})]})}function _n(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 vn(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 yn(){return m(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Ge)}function bn({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:i,pasteFailed:a,keyPlaceholder:o,valuePlaceholder:s,headers:c,onChange:l}){let u=(e,t)=>{l(c.map((n,r)=>r===e?{...n,...t}:n))},d=()=>{l([...c,{key:``,value:``}])},f=e=>{let t=c.filter((t,n)=>n!==e);l(t.length>0?t:[{key:``,value:``}])},p=async()=>{try{let e=await g();if(!e){window.alert(a);return}let t=xt(e);if(!t?.length){window.alert(a);return}l(t)}catch{window.alert(a)}};return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,Q.jsx)(`span`,{children:e}),t?(0,Q.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),(0,Q.jsxs)(h,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void p(),children:[(0,Q.jsx)(Se,{className:`size-3.5`,"aria-hidden":!0}),i]})]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:c.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{className:m(yn(),`min-w-0 flex-1 font-mono text-xs`),value:e.key,placeholder:o,onChange:e=>u(t,{key:e.target.value})}),(0,Q.jsx)(`input`,{className:m(yn(),`min-w-0 flex-[1.4] font-mono text-xs`),value:e.value,placeholder:s,onChange:e=>u(t,{value:e.target.value})}),(0,Q.jsx)(h,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:c.length<=1&&!e.key&&!e.value,onClick:()=>f(t),"aria-label":r,children:(0,Q.jsx)(Ke,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})})]},vn(e,t,c)))}),(0,Q.jsxs)(`button`,{type:`button`,className:m(`self-start text-sm text-accent hover:underline`,J.press),onClick:d,children:[`+ `,n]})]})}var xn=[`stdio`,`sse`,`streamable-http`];function Sn(e){let t=(0,Z.c)(11),{label:n,description:r,required:i,children:a}=e,o;t[0]===i?o=t[1]:(o=i?(0,Q.jsx)(`span`,{className:`ml-0.5 text-danger`,children:`*`}):null,t[0]=i,t[1]=o);let s;t[2]!==n||t[3]!==o?(s=(0,Q.jsxs)(`div`,{className:`text-sm font-medium text-fg`,children:[n,o]}),t[2]=n,t[3]=o,t[4]=s):s=t[4];let c;t[5]===r?c=t[6]:(c=r?(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}):null,t[5]=r,t[6]=c);let l;return t[7]!==a||t[8]!==s||t[9]!==c?(l=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[s,a,c]}),t[7]=a,t[8]=s,t[9]=c,t[10]=l):l=t[10],l}function Cn(){return m(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Ge)}function wn(e){let t=(0,Z.c)(35),{row:n,t:r,onUpdate:i,idConflictMessage:a,variant:o}=e,l=o===void 0?`all`:o,u=l===`all`||l===`basic`,d=l===`all`||l===`advanced`,f;t[0]!==a||t[1]!==i||t[2]!==n.id||t[3]!==n.transport||t[4]!==u||t[5]!==r?(f=u?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Sn,{label:r.transportLabel,required:!0,children:(0,Q.jsx)(s,{className:Cn(),value:n.transport,onChange:e=>i({transport:e.target.value}),children:xn.map(e=>(0,Q.jsx)(c,{value:e,children:r.transportLabels[e]},e))})}),(0,Q.jsxs)(Sn,{label:r.serverIdLabel,required:!0,children:[(0,Q.jsx)(`input`,{className:Cn(),value:n.id,placeholder:r.serverIdPlaceholder,onChange:e=>i({id:e.target.value})}),a?(0,Q.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-300`,children:a}):null]})]}):null,t[0]=a,t[1]=i,t[2]=n.id,t[3]=n.transport,t[4]=u,t[5]=r,t[6]=f):f=t[6];let p;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]!==d||t[16]!==u||t[17]!==r||t[18]!==l?(p=n.transport===`stdio`?(0,Q.jsxs)(Q.Fragment,{children:[u?(0,Q.jsx)(`div`,{className:l===`basic`?`md:col-span-2`:void 0,children:(0,Q.jsx)(Sn,{label:r.commandLabel,required:!0,children:(0,Q.jsx)(`input`,{className:Cn(),value:n.command,onChange:e=>i({command:e.target.value})})})}):null,d?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Sn,{label:r.argsLabel,description:r.argsHint,children:(0,Q.jsx)(`input`,{className:Cn(),value:n.argsText,onChange:e=>i({argsText:e.target.value})})}),(0,Q.jsx)(Sn,{label:r.cwdLabel,children:(0,Q.jsx)(`input`,{className:Cn(),value:n.cwd,onChange:e=>i({cwd:e.target.value})})}),(0,Q.jsx)(Sn,{label:r.envLabel,description:r.envHint,children:(0,Q.jsx)(`textarea`,{className:m(Cn(),`min-h-[4rem] font-mono text-xs`),value:n.envJson,onChange:e=>i({envJson:e.target.value})})})]}):null]}):(0,Q.jsxs)(Q.Fragment,{children:[u?(0,Q.jsx)(`div`,{className:`md:col-span-2`,children:(0,Q.jsx)(Sn,{label:r.urlLabel,required:!0,children:(0,Q.jsx)(`input`,{className:m(Cn(),`font-mono text-xs`),value:n.url,placeholder:`https://example.com/mcp`,onChange:e=>i({url:e.target.value})})})}):null,d?(0,Q.jsx)(bn,{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]=d,t[16]=u,t[17]=r,t[18]=l,t[19]=p):p=t[19];let h;t[20]!==i||t[21]!==n||t[22]!==d||t[23]!==r?(h=d?(0,Q.jsx)(Sn,{label:r.timeoutLabel,description:r.timeoutHint,children:(0,Q.jsx)(`input`,{type:`number`,min:1,max:600,className:Cn(),value:Rt(n),placeholder:r.timeoutPlaceholder,onChange:e=>i({connectionTimeoutMs:zt(e.target.value)})})}):null,t[20]=i,t[21]=n,t[22]=d,t[23]=r,t[24]=h):h=t[24];let g;t[25]!==i||t[26]!==n||t[27]!==d||t[28]!==r?(g=d?(0,Q.jsx)(Sn,{label:r.requestTimeoutLabel,description:r.requestTimeoutHint,children:(0,Q.jsx)(`input`,{type:`number`,min:1,max:14400,className:Cn(),value:Bt(n),placeholder:r.requestTimeoutPlaceholder,onChange:e=>i({requestTimeoutMs:Vt(e.target.value)})})}):null,t[25]=i,t[26]=n,t[27]=d,t[28]=r,t[29]=g):g=t[29];let _;return t[30]!==f||t[31]!==p||t[32]!==h||t[33]!==g?(_=(0,Q.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[f,p,h,g]}),t[30]=f,t[31]=p,t[32]=h,t[33]=g,t[34]=_):_=t[34],_}function Tn(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 En(e){let t=(0,Z.c)(13),{tool:n,serverId:r}=e,i;t[0]!==r||t[1]!==n?(i=Tn(n,r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o=n.name===a?a:n.name,s;t[3]===n.description?s=t[4]:(s=n.description?.trim(),t[3]=n.description,t[4]=s);let c=s,l;t[5]!==a||t[6]!==o?(l=(0,Q.jsx)(`p`,{className:`break-all font-mono text-xs font-medium leading-5 text-fg`,title:o,children:a}),t[5]=a,t[6]=o,t[7]=l):l=t[7];let u;t[8]===c?u=t[9]:(u=c?(0,Q.jsx)(F,{delayDuration:300,skipDelayDuration:100,children:(0,Q.jsxs)(P,{children:[(0,Q.jsx)(L,{asChild:!0,children:(0,Q.jsx)(`p`,{tabIndex:0,title:c,className:m(`mt-1 line-clamp-3 cursor-help text-xs leading-5 text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:c})}),(0,Q.jsx)(R,{children:(0,Q.jsx)(I,{side:`top`,align:`start`,sideOffset:6,collisionPadding:12,className:`!z-[10000] max-h-[min(16rem,45vh)] max-w-[min(32rem,calc(100vw-2rem))] overflow-y-auto rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-5 text-fg shadow-popover`,children:(0,Q.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:c})})})]})}):null,t[8]=c,t[9]=u);let d;return t[10]!==l||t[11]!==u?(d=(0,Q.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[l,u]}),t[10]=l,t[11]=u,t[12]=d):d=t[12],d}function Dn({open:e,mode:t,initialRow:n,existingCustomServers:r,sessionIdleTtlMinutes:i,config:a,managedServerIds:o,t:s,cs:c,onClose:l,onSaved:f}){let[g,_]=(0,X.useState)(n),[v,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(!1),[S,C]=(0,X.useState)(null),[w,M]=(0,X.useState)(!1),[N,P]=(0,X.useState)({status:`idle`}),[F,I]=(0,X.useState)(null),L=n.id.trim(),R=g.id.trim()!==L&&o.has(g.id.trim())||o.has(g.id.trim())&&t===`add`?s.reservedServerId:void 0,z=g.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===g.id.trim())?c.duplicateServerId:void 0,B=g.id.trim().length>0&&!R&&!z&&(g.transport===`stdio`?g.command.trim().length>0:g.url.trim().length>0),V=Ht(g),H=(0,X.useCallback)(async()=>{if(g.id.trim()){x(!0),C(null),P({status:`loading`});try{P({status:`ok`,tools:(await Lt(g.id.trim(),Mt(g))).tools})}catch(e){P({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{x(!1)}}},[g]),ee=(0,X.useCallback)(async()=>{if(!(!B||v)){y(!0),C(null);try{let e=r.filter(e=>!(t===`edit`&&e.clientKey===n.clientKey));e.push(g),await Nt({sessionIdleTtlMinutes:i,servers:e.sort((e,t)=>e.id.localeCompare(t.id))},Tt(a)),await f(),l()}catch(e){C(e instanceof Error?e.message:String(e))}finally{y(!1)}}},[B,a,r,n.clientKey,t,l,f,L,g,v,i]);return e?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(j,{open:e,onOpenChange:e=>{e||l()},children:(0,Q.jsxs)(O,{children:[(0,Q.jsx)(T,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(k,{className:m(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(A,{className:`text-base font-semibold text-fg`,children:t===`add`?c.addCustomServerTitle:c.editCustomServerTitle}),(0,Q.jsx)(E,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?c.addCustomServerHint:c.editCustomServerHint})]}),(0,Q.jsx)(D,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:m(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,J.focusRingPanel),"aria-label":c.modalClose,children:[(0,Q.jsx)(p,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`sr-only`,children:c.modalClose})]})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(q,{className:`size-4 text-accent`,"aria-hidden":!0}),g.id.trim()||s.cardUntitled]}),(0,Q.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs leading-5 text-fg-muted`,children:V||(g.transport===`stdio`?s.commandLabel:s.urlLabel)})]}),(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:s.transportLabels[g.transport]})]})}),(0,Q.jsxs)(`section`,{children:[(0,Q.jsxs)(`div`,{className:`mb-3`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.connectorBasicConfigTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:c.connectorBasicConfigHint})]}),(0,Q.jsx)(wn,{row:g,t:s,variant:`basic`,onUpdate:e=>{_(t=>({...t,...e})),C(null)},idConflictMessage:R??z})]}),N.status===`ok`?(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,Q.jsx)(Le,{className:`size-4 text-accent`,"aria-hidden":!0}),N.tools.length===0?s.toolsEmpty:s.toolsTitle.replace(`{{count}}`,String(N.tools.length))]}),N.tools.length>0?(0,Q.jsx)(h,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>I(N.tools),children:s.viewAllTools}):null]}),N.tools.length>0?(0,Q.jsx)(`div`,{className:`mt-3 grid gap-2`,children:N.tools.slice(0,6).map((e,t)=>(0,Q.jsx)(En,{tool:e,serverId:g.id},e.name||`tool-${t}`))}):null]}):null,N.status===`error`?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:N.message}):null,S?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:S}):null,(0,Q.jsxs)(`details`,{open:w,onToggle:e=>M(e.currentTarget.open),className:`group rounded-xl border border-edge bg-surface-base`,children:[(0,Q.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg hover:text-fg [&::-webkit-details-marker]:hidden`,children:[(0,Q.jsx)(se,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`group-open:hidden`,children:c.connectorShowAdvancedConfig}),(0,Q.jsx)(`span`,{className:`hidden group-open:inline`,children:c.connectorHideAdvancedConfig})]}),(0,Q.jsx)(`div`,{className:`border-t border-edge p-4`,children:(0,Q.jsx)(wn,{row:g,t:s,variant:`advanced`,onUpdate:e=>{_(t=>({...t,...e})),C(null)}})})]})]})}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,Q.jsxs)(h,{variant:`secondary`,disabled:!g.id.trim()||b,onClick:()=>void H(),children:[b?(0,Q.jsx)(d,{className:`size-4 animate-spin`}):(0,Q.jsx)(Be,{className:`size-4`}),s.testConnection]}),(0,Q.jsx)(D,{asChild:!0,children:(0,Q.jsx)(h,{variant:`secondary`,children:c.modalCancel})}),(0,Q.jsxs)(h,{variant:`primary`,disabled:!B||v,onClick:()=>void ee(),children:[v?(0,Q.jsx)(d,{className:`size-4 animate-spin`}):(0,Q.jsx)(u,{className:`size-4`}),v?s.saving:c.modalSave]})]})]})]})}),F?(0,Q.jsx)(Jt,{open:!0,onOpenChange:e=>{e||I(null)},serverId:g.id,title:s.toolsDialogTitle,subtitle:s.toolsDialogSubtitle,searchPlaceholder:s.toolsDialogSearchPlaceholder,searchEmptyLabel:s.toolsDialogSearchEmpty,emptyLabel:s.toolsEmpty,closeLabel:s.toolsDialogClose,tools:F,stripPrefix:`${g.id.trim()}__`}):null]}):null}var On=`builtin`,kn=`composio`,An=`xopc-store`;function jn(e){return On}function Mn(e){return!(e.runtime.type===`composio`&&e.runtime.role===`credential`)}function Nn(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 Pn(e,t,n){return e.filter(e=>Nn(e,t)).toSorted((e,t)=>n===`source`&&e.source!==t.source?e.source.localeCompare(t.source):e.displayName.localeCompare(t.displayName))}function Fn(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 In(e,t){let n=t.trim().toLowerCase();return n?[e.id,e.command??``,e.url??``,e.transport].some(e=>e.toLowerCase().includes(n)):!0}function Ln(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 Rn(e){return e.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t)}function zn(e){return e?.startsWith(`/`)&&!e.startsWith(`//`)?e:`/you?tab=sources`}function Bn(){let e=_(y(e=>e.language)),t=e.connectorsSettings,n=e.mcpSettings,r=v(e=>e.token),o=!!r,s=i(),[c,u]=a(),f=c.get(`understanding`)===`1`,p=zn(c.get(`returnTo`)),g=c.get(`tab`),[b,x]=(0,X.useState)(!f&&g===`connected`?`connected`:`discover`),S=(0,X.useRef)(!1),[C,w]=(0,X.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null,peopleGraph:null}),[T,E]=(0,X.useState)(!1),[D,O]=(0,X.useState)(!1),[k,A]=(0,X.useState)(1),[j,M]=(0,X.useState)(void 0),[P,F]=(0,X.useState)(``),[I,L]=(0,X.useState)(``),[R,z]=(0,X.useState)(!1),[B,V]=(0,X.useState)(f?c.get(`connector`)??``:``),[H,te]=(0,X.useState)(jn(f?`understanding`:`default`)),[U,ne]=(0,X.useState)(`name`),[W,re]=(0,X.useState)(f?`understand`:`all`),[ie,ae]=(0,X.useState)(null),[oe,se]=(0,X.useState)(null),[ce,le]=(0,X.useState)(null),[ue,de]=(0,X.useState)(null),[fe,pe]=(0,X.useState)(null),[me,he]=(0,X.useState)(null),[ge,_e]=(0,X.useState)(!1),[ve,ye]=(0,X.useState)(void 0),[be,xe]=(0,X.useState)(!1),{data:Se,mutate:we}=N(o),G=Se?.payload?.config,K=(0,X.useMemo)(()=>G===void 0?null:jt(G),[G]),q=K?.servers??[],Te=C.instances.length+q.length;(0,X.useEffect)(()=>{K&&ye(K.sessionIdleTtlMinutes)},[K]);let Ee=(0,X.useCallback)(async()=>{if(!r){w({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null,peopleGraph:null});return}w(e=>({...e,loading:!0,error:null}));try{let[e,t,n]=await Promise.all([Ze(),Ce(),Ae(``,12).catch(()=>null)]);w(r=>({catalog:e,registryCatalog:r.registryCatalog,instances:t,loading:!1,error:null,peopleGraph:n}))}catch(e){w({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e),peopleGraph:null})}},[r]);(0,X.useEffect)(()=>{Ee()},[Ee]),(0,X.useEffect)(()=>{if(!o||b!==`connected`)return;let e=!1,t=window.setTimeout(()=>{z(!0),Ae(I,50).then(t=>{e||w(e=>({...e,peopleGraph:t}))}).catch(()=>{}).finally(()=>{e||z(!1)})},250);return()=>{e=!0,window.clearTimeout(t)}},[o,I,b]),(0,X.useEffect)(()=>{S.current||C.loading||o&&!K||(x(f?`discover`:Te>0?`connected`:`discover`),S.current=!0)},[o,Te,K,f,C.loading]);let De=(0,X.useCallback)(e=>{S.current=!0,x(e)},[]),J=(0,X.useMemo)(()=>[{id:kn,displayName:t.composioSourceName},{id:An,displayName:t.storeSourceName}],[t.composioSourceName,t.storeSourceName]),Oe=(0,X.useCallback)(async e=>{if(!o||H===`builtin`){w(e=>({...e,registryCatalog:[]})),A(1),M(void 0);return}let t=B.trim(),n=Math.max(e?.page??1,1),r=e?.append??!1,i=H===`all`?J:J.filter(e=>e.id===H);if(i.length!==0){E(!0),r?w(e=>({...e,error:null})):(A(1),M(void 0),w(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(i.map(async e=>{if(e.id===`composio`){let e=await Qe({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let r=await ee({q:t||void 0,page:n,pageSize:24,sort:U===`source`?`newest`:`downloads`});return{connectors:r.items.map(Ln),totalPages:r.meta.totalPages}})),a=Rn(e.flatMap(e=>e.connectors)),o=Math.max(1,...e.map(e=>e.totalPages??1));A(n),M(o),w(e=>({...e,registryCatalog:r?Rn([...e.registryCatalog,...a]):a}))}catch(e){w(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{E(!1)}}},[U,B,H,o,J]);(0,X.useEffect)(()=>{if(b!==`discover`||C.loading)return;if(H===`builtin`){w(e=>({...e,registryCatalog:[]})),A(1),M(void 0);return}let e=window.setTimeout(()=>{Oe()},B.trim()?350:0);return()=>window.clearTimeout(e)},[B,H,Oe,C.loading,b]);let Y=(0,X.useMemo)(()=>new Set(C.instances.map(e=>e.connectorId)),[C.instances]),ke=(0,X.useMemo)(()=>new Map([...C.catalog,...C.registryCatalog].map(e=>[e.id,e])),[C.catalog,C.registryCatalog]);(0,X.useEffect)(()=>{if(C.loading)return;let e=c.get(`connector`),t=c.get(`instance`);if(!e&&!t)return;let n=C.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)S.current=!0,F(``),le(n.instanceId),de(n),x(`connected`);else if(e){let t=ke.get(e);if(!t)return;S.current=!0,te(jn(f?`understanding`:`default`)),V(``),se(t),x(`discover`)}let r=new URLSearchParams(c);r.delete(`connector`),r.delete(`instance`),r.set(`tab`,n?`connected`:`discover`),u(r,{replace:!0})},[ke,f,c,u,C.instances,C.loading]);let Ne=(0,X.useCallback)(async e=>{O(!0),w(e=>({...e,error:null}));try{let t=await Ye(e);ae(Ie(t.definition,{packageName:t.packageName,version:t.version,permissions:t.permissions}))}catch(e){w(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{O(!1)}},[]),Pe=(0,X.useMemo)(()=>new Set(C.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[C.instances]),Le=(0,X.useCallback)(async e=>{if(!K||G===void 0)return;let t=q.filter(t=>t.clientKey!==e.clientKey);await Nt({sessionIdleTtlMinutes:K.sessionIdleTtlMinutes,servers:t},Tt(G)),await we(),await Ee()},[G,q,Ee,K,we]),Re=(0,X.useCallback)(()=>{he({mode:`add`,row:_n(q,Pe)})},[q,Pe]),ze=(0,X.useCallback)(async()=>{if(!(!K||G===void 0||be)){xe(!0);try{await Nt({sessionIdleTtlMinutes:ve,servers:q},Tt(G)),await we(),_e(!1)}finally{xe(!1)}}},[G,q,n.saved,K,we,ve,be]),Be=We(e=>e.setPageHeader),Ve=We(e=>e.clearPageHeader),He=(0,X.useMemo)(()=>(0,Q.jsx)(yt,{onBrowseCatalog:()=>De(`discover`),onAddCustomServer:Re,onOpenRuntimeSettings:()=>_e(!0),addLabel:t.addConnection,browseLabel:t.addFromCatalog,customLabel:t.addCustomServerAdvanced,settingsLabel:t.runtimeSettings}),[t,Re,De]);(0,X.useLayoutEffect)(()=>(Be({startExtra:null,main:(0,Q.jsx)(`div`,{className:`min-w-0`,children:(0,Q.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title})}),end:He}),()=>Ve()),[Ve,t.title,He,Be]);let Ue=(0,X.useMemo)(()=>C.instances.map(e=>({instance:e,value:hn(e,ke.get(e.connectorId))})),[ke,C.instances]),Ge=(0,X.useMemo)(()=>new Map(Ue.map(({instance:e,value:t})=>[e.instanceId,t])),[Ue]),Ke=(0,X.useMemo)(()=>C.instances.filter(e=>Fn(e,P)).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)}),[P,Ge,C.instances]),qe=(0,X.useMemo)(()=>q.filter(e=>In(e,P)),[P,q]),Je=Ke.length+qe.length,Xe=(0,X.useMemo)(()=>C.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&Mn(e)),[C.catalog]),$e=(0,X.useMemo)(()=>H===`builtin`?Xe:H===`all`?Rn([...Xe,...C.registryCatalog]):C.registryCatalog,[Xe,H,C.registryCatalog]),Z=(0,X.useMemo)(()=>{let e=f?$e.filter(e=>e.understanding?.mode===`activity`):$e;return Pn(W===`all`?e:e.filter(e=>pn(e).includes(W)),B,U)},[U,B,$e,f,W]),nt=(0,X.useMemo)(()=>fn.filter(e=>$e.some(t=>pn(t).includes(e))),[$e]);(0,X.useEffect)(()=>{W!==`all`&&!nt.includes(W)&&re(`all`)},[nt,W]);let at=b===`discover`&&H!==`builtin`&&!!(j&&k<j),$=(0,X.useMemo)(()=>C.instances.find(e=>e.instanceId===ce)??ue,[ce,ue,C.instances]),ct=(0,X.useMemo)(()=>[{value:`all`,label:t.discoverSourceAll},{value:On,label:t.discoverSourceBuiltin},...J.map(e=>({value:e.id,label:e.displayName}))],[t.discoverSourceAll,t.discoverSourceBuiltin,J]),lt=[{id:`connected`,label:t.tabConnected,count:Te},{id:`discover`,label:t.tabDiscover}];return(0,Q.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,Q.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[o?null:(0,Q.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:t.tokenHint}),f?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:t.understandingSetupTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.understandingSetupHint})]}),(0,Q.jsx)(h,{type:`button`,variant:`secondary`,className:`shrink-0`,onClick:()=>s(p),children:t.understandingSetupDone})]}):null,(0,Q.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(`div`,{className:`border-b border-edge-subtle pb-3 dark:border-edge-subtle`,children:(0,Q.jsx)(et,{items:lt,activeTab:b,onChange:De,ariaLabel:t.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),C.error?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:C.error}):null,b===`connected`&&o?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,Q.jsx)(vt,{value:P,onChange:F,placeholder:t.connectedSearchPlaceholder,className:`max-w-xl`}),(0,Q.jsx)(je,{className:`size-9 shrink-0 p-0`,loading:C.loading,label:t.refreshConnections,title:t.refreshConnections,onClick:Ee})]}),C.peopleGraph&&(C.peopleGraph.people.length>0||I)?(0,Q.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`div`,{className:`rounded-lg bg-accent-soft p-2 text-accent-fg`,children:(0,Q.jsx)(Me,{className:`size-4`,"aria-hidden":!0})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.peopleGraphTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.peopleGraphHint.replace(`{{people}}`,String(C.peopleGraph.people.length)).replace(`{{sources}}`,String(new Set(C.peopleGraph.sourceEdges.map(e=>e.sourceInstanceId)).size))})]})]}),(0,Q.jsxs)(`div`,{className:`relative w-full max-w-xs`,children:[(0,Q.jsx)(vt,{value:I,onChange:L,placeholder:t.peopleGraphSearchPlaceholder}),R?(0,Q.jsx)(d,{className:`absolute right-3 top-2.5 size-4 animate-spin text-fg-subtle`,"aria-hidden":!0}):null]})]}),C.peopleGraph.people.length?(0,Q.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:C.peopleGraph.people.slice(0,10).map(e=>{let t=[...new Set(C.peopleGraph.sourceEdges.filter(t=>t.personId===e.id).map(e=>e.toolkit??e.connectorId??e.sourceInstanceId))];return(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel px-3 py-2.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.label}),(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:e.mentionCount})]}),(0,Q.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:e.emails[0]??e.usernames[0]??e.roles.join(` · `)}),(0,Q.jsx)(`p`,{className:`mt-1 truncate text-[11px] text-fg-subtle`,children:t.join(` · `)})]},e.id)})}):(0,Q.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:t.peopleGraphSearchEmpty})]}):null,C.loading?(0,Q.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":t.loading,children:rt.slice(0,3).map(e=>(0,Q.jsx)(st,{},e))}):Te===0?(0,Q.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.connectionsEmpty}),(0,Q.jsx)(h,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>De(`discover`),children:t.addFromCatalog})]}):Je===0?(0,Q.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.connectionsSearchEmpty}):(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:[Ke.map(e=>(0,Q.jsx)(gn,{instance:e,definition:ke.get(e.connectorId),highlighted:e.instanceId===fe,onOpenDetails:e=>{pe(null),le(e.instanceId),de(e)},onChanged:Ee,t},e.instanceId)),qe.map(e=>(0,Q.jsx)(Ut,{row:e,t:n,cs:t,onEdit:()=>he({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>Le(e)},e.clientKey))]})]}):null,b===`discover`&&o?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[f?null:(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":t.taskFilterAria,children:[`all`,...nt].map(e=>(0,Q.jsx)(`button`,{type:`button`,className:m(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,W===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":W===e,onClick:()=>re(e),children:e===`all`?t.taskAll:t.connectorBenefitHeadings[e]},e))}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 lg:flex-row lg:items-center`,children:[(0,Q.jsx)(vt,{value:B,onChange:V,placeholder:t.discoverSearchPlaceholder,className:`max-w-xl`}),(0,Q.jsxs)(`div`,{className:m(`grid min-w-0 grid-cols-1 gap-2 lg:ml-auto`,f?`lg:w-52`:`sm:grid-cols-2 lg:w-[26rem]`),children:[f?null:(0,Q.jsx)(l,{value:H,options:ct,placeholder:t.discoverSourceAll,allowEmpty:!1,ariaLabel:t.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:te}),(0,Q.jsx)(l,{value:U,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=>ne(e)})]})]}),(C.loading||T)&&Z.length===0?(0,Q.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:rt.map(e=>(0,Q.jsx)(ot,{},e))}):Z.length===0?(0,Q.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.discoverEmpty}):(0,Q.jsxs)(`div`,{className:`relative`,children:[T?(0,Q.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1] flex justify-center bg-surface-panel/40 pt-[min(28vh,7.5rem)] backdrop-blur-[1px] motion-reduce:backdrop-blur-none dark:bg-surface-base/35`,"aria-busy":`true`,"aria-label":t.loading,children:(0,Q.jsx)(d,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,Q.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:Z.map(e=>(0,Q.jsx)(tt,{connector:e,installed:Y.has(e.id)||it(e,C.instances),onInstall:e=>{if(e.source===`store`){Ne(e.id);return}ae(Ie(e))},onOpenDetails:e.source===`store`?void 0:se,t},e.id))}),at?(0,Q.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,Q.jsxs)(h,{type:`button`,variant:`secondary`,disabled:T||D,onClick:()=>void Oe({page:k+1,append:!0}),children:[T?(0,Q.jsx)(d,{className:`size-4 animate-spin`}):null,t.loadMore]})}):null]})]}):null]}),ie?(0,Q.jsx)(Fe,{draft:ie,onChange:ae,onClose:()=>ae(null),t,onInstalled:async e=>{await Ee(),await we(),pe(e.instanceId),De(`connected`)}}):null,oe?(0,Q.jsx)(ht,{connector:oe,installed:Y.has(oe.id)||it(oe,C.instances),onClose:()=>se(null),onInstall:e=>ae(Ie(e)),t}):null,$?(0,Q.jsx)(dn,{instance:$,definition:ke.get($.connectorId),onClose:()=>{le(null),de(null)},onChanged:Ee,t,mcp:n}):null,me?(0,Q.jsx)(Dn,{open:!0,mode:me.mode,initialRow:me.row,existingCustomServers:q,sessionIdleTtlMinutes:ve,config:G,managedServerIds:Pe,t:n,cs:t,onClose:()=>he(null),onSaved:async()=>{await we(),await Ee(),De(`connected`)}},`${me.mode}-${me.row.clientKey}`):null,(0,Q.jsx)(_t,{open:ge,sessionIdleTtlMinutes:ve,saving:be,onChange:ye,onSave:ze,onClose:()=>_e(!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{a as i,c as a,m as ee,o as te,p as ne,s as re}from"./popover-select-BzdnTy3h.js";import{t as o}from"./cn-JdwAhgNB.js";import{n as ie}from"./locale-store-De8wYkd7.js";import{Fl as ae,Ll as oe,Pl as se}from"./index-CMLkr37Y.js";var ce=n(),le=e(t(),1),s=r();function c(e){return String(e).padStart(2,`0`)}function ue(e){return`${e.getFullYear()}-${c(e.getMonth()+1)}-${c(e.getDate())}`}function de(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2])-1,i=Number(t[3]),a=new Date(n,r,i,12);return a.getFullYear()===n&&a.getMonth()===r&&a.getDate()===i?a:null}function fe(e,t){let n=new Date(e.getFullYear(),e.getMonth(),1,12),r=(n.getDay()-t+7)%7;return Array.from({length:42},(e,t)=>new Date(n.getFullYear(),n.getMonth(),1-r+t,12))}function pe(e,t){let n=de(e);return n?t===`zh`?`${n.getFullYear()}/${c(n.getMonth()+1)}/${c(n.getDate())}`:new Intl.DateTimeFormat(`en`,{year:`numeric`,month:`short`,day:`numeric`}).format(n):``}function l(e){let t=(0,ce.c)(103),{value:n,onChange:r,disabled:c,className:l,ariaLabel:ve,placeholder:ye}=e,u=ie(_e),d=u===`zh`?`zh-CN`:`en`,f;t[0]===n?f=t[1]:(f=de(n),t[0]=n,t[1]=f);let p=f,[m,be]=(0,le.useState)(!1),h;t[2]===p?h=t[3]:(h=()=>p??new Date,t[2]=p,t[3]=h);let[g,xe]=(0,le.useState)(h),Se=te(),Ce=re(i(),Se!==null),_=+(u===`zh`),v,y;t[4]!==m||t[5]!==n?(v=()=>{if(!m)return;let e=de(n);e&&xe(e)},y=[m,n],t[4]=m,t[5]=n,t[6]=v,t[7]=y):(v=t[6],y=t[7]),(0,le.useEffect)(v,y);let b;t[8]!==g||t[9]!==_?(b=fe(g,_),t[8]=g,t[9]=_,t[10]=b):b=t[10];let we=b,x;if(t[11]!==d||t[12]!==_){let e=new Date(2026,7,23,12);x=Array.from({length:7},(t,n)=>{let r=new Date(e);return r.setDate(e.getDate()+_+n),new Intl.DateTimeFormat(d,{weekday:`narrow`}).format(r)}),t[11]=d,t[12]=_,t[13]=x}else x=t[13];let Te=x,S;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(S=ue(new Date),t[14]=S):S=t[14];let C=S,w;t[15]===p?w=t[16]:(w=p?ue(p):``,t[15]=p,t[16]=w);let T=w,E;t[17]!==d||t[18]!==g?(E=new Intl.DateTimeFormat(d,{year:`numeric`,month:`long`}).format(g),t[17]=d,t[18]=g,t[19]=E):E=t[19];let Ee=E,D;t[20]===r?D=t[21]:(D=e=>{r(e),be(!1)},t[20]=r,t[21]=D);let O=D,De=ee,Oe=c&&`cursor-not-allowed opacity-50`,k;t[22]!==l||t[23]!==Oe?(k=o(`flex h-10 w-full min-w-0 items-center justify-between gap-3 rounded-lg bg-surface-hover px-3 text-left text-sm text-fg outline-none transition-colors`,`hover:bg-surface-active focus-visible:ring-2 focus-visible:ring-accent/40`,Oe,l),t[22]=l,t[23]=Oe,t[24]=k):k=t[24];let ke=!n&&`text-fg-subtle`,A;t[25]===ke?A=t[26]:(A=o(`min-w-0 truncate tabular-nums`,ke),t[25]=ke,t[26]=A);let j;t[27]!==u||t[28]!==ye||t[29]!==n?(j=pe(n,u)||ye||(u===`zh`?`选择日期`:`Select date`),t[27]=u,t[28]=ye,t[29]=n,t[30]=j):j=t[30];let M;t[31]!==A||t[32]!==j?(M=(0,s.jsx)(`span`,{className:A,children:j}),t[31]=A,t[32]=j,t[33]=M):M=t[33];let N;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,s.jsx)(oe,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[34]=N):N=t[34];let P;t[35]!==ve||t[36]!==c||t[37]!==k||t[38]!==M?(P=(0,s.jsx)(ne,{asChild:!0,children:(0,s.jsxs)(`button`,{type:`button`,disabled:c,"aria-label":ve,className:k,children:[M,N]})}),t[35]=ve,t[36]=c,t[37]=k,t[38]=M,t[39]=P):P=t[39];let Ae=ee,je=Se??void 0,Me=ee,Ne=o(Ce,`w-[19rem] rounded-2xl bg-surface-panel p-3 shadow-float outline-none`),Pe=u===`zh`?`上个月`:`Previous month`,F,I;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>xe(ge),I=(0,s.jsx)(ae,{className:`size-4`,"aria-hidden":!0}),t[40]=F,t[41]=I):(F=t[40],I=t[41]);let L;t[42]===Pe?L=t[43]:(L=(0,s.jsx)(`button`,{type:`button`,className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":Pe,onClick:F,children:I}),t[42]=Pe,t[43]=L);let R;t[44]===Ee?R=t[45]:(R=(0,s.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:Ee}),t[44]=Ee,t[45]=R);let Fe=u===`zh`?`下个月`:`Next month`,z,B;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(z=()=>xe(he),B=(0,s.jsx)(se,{className:`size-4`,"aria-hidden":!0}),t[46]=z,t[47]=B):(z=t[46],B=t[47]);let V;t[48]===Fe?V=t[49]:(V=(0,s.jsx)(`button`,{type:`button`,className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":Fe,onClick:z,children:B}),t[48]=Fe,t[49]=V);let H;t[50]!==L||t[51]!==R||t[52]!==V?(H=(0,s.jsxs)(`div`,{className:`flex h-10 items-center justify-between gap-2 px-1`,children:[L,R,V]}),t[50]=L,t[51]=R,t[52]=V,t[53]=H):H=t[53];let U;t[54]===Te?U=t[55]:(U=(0,s.jsx)(`div`,{className:`mt-2 grid grid-cols-7`,"aria-hidden":!0,children:Te.map(me)}),t[54]=Te,t[55]=U);let W;if(t[56]!==we||t[57]!==d||t[58]!==O||t[59]!==T||t[60]!==C||t[61]!==g){let e;t[63]!==d||t[64]!==O||t[65]!==T||t[66]!==C||t[67]!==g?(e=e=>{let t=ue(e),n=t===T,r=t===C,i=e.getMonth()!==g.getMonth();return(0,s.jsx)(`button`,{type:`button`,role:`gridcell`,"aria-selected":n,"aria-label":new Intl.DateTimeFormat(d,{dateStyle:`full`}).format(e),className:o(`mx-auto flex size-9 items-center justify-center rounded-xl text-sm tabular-nums text-fg transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,i&&`text-fg-disabled`,r&&!n&&`bg-accent-soft font-semibold text-accent-fg`,n&&`bg-accent font-semibold text-white hover:bg-accent-hover`),onClick:()=>O(t),children:e.getDate()},t)},t[63]=d,t[64]=O,t[65]=T,t[66]=C,t[67]=g,t[68]=e):e=t[68],W=we.map(e),t[56]=we,t[57]=d,t[58]=O,t[59]=T,t[60]=C,t[61]=g,t[62]=W}else W=t[62];let G;t[69]===W?G=t[70]:(G=(0,s.jsx)(`div`,{className:`grid grid-cols-7 gap-y-1`,role:`grid`,children:W}),t[69]=W,t[70]=G);let Ie=!n,K;t[71]===O?K=t[72]:(K=()=>O(``),t[71]=O,t[72]=K);let Le=u===`zh`?`清除`:`Clear`,q;t[73]!==Ie||t[74]!==K||t[75]!==Le?(q=(0,s.jsx)(`button`,{type:`button`,disabled:Ie,className:`rounded-lg px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg disabled:pointer-events-none disabled:opacity-35`,onClick:K,children:Le}),t[73]=Ie,t[74]=K,t[75]=Le,t[76]=q):q=t[76];let J;t[77]!==O||t[78]!==C?(J=()=>O(C),t[77]=O,t[78]=C,t[79]=J):J=t[79];let Re=u===`zh`?`今天`:`Today`,Y;t[80]!==J||t[81]!==Re?(Y=(0,s.jsx)(`button`,{type:`button`,className:`rounded-lg bg-accent-soft px-2.5 py-1.5 text-xs font-medium text-accent-fg hover:bg-accent-soft/80`,onClick:J,children:Re}),t[80]=J,t[81]=Re,t[82]=Y):Y=t[82];let X;t[83]!==q||t[84]!==Y?(X=(0,s.jsxs)(`div`,{className:`mt-2 flex items-center justify-between px-1 pt-1`,children:[q,Y]}),t[83]=q,t[84]=Y,t[85]=X):X=t[85];let ze;t[86]===Symbol.for(`react.memo_cache_sentinel`)?(ze=(0,s.jsx)(a,{className:`fill-surface-panel`}),t[86]=ze):ze=t[86];let Z;t[87]!==Me.Content||t[88]!==Ne||t[89]!==H||t[90]!==U||t[91]!==G||t[92]!==X?(Z=(0,s.jsxs)(Me.Content,{align:`start`,sideOffset:6,collisionPadding:12,className:Ne,children:[H,U,G,X,ze]}),t[87]=Me.Content,t[88]=Ne,t[89]=H,t[90]=U,t[91]=G,t[92]=X,t[93]=Z):Z=t[93];let Q;t[94]!==Ae.Portal||t[95]!==je||t[96]!==Z?(Q=(0,s.jsx)(Ae.Portal,{container:je,children:Z}),t[94]=Ae.Portal,t[95]=je,t[96]=Z,t[97]=Q):Q=t[97];let $;return t[98]!==m||t[99]!==De.Root||t[100]!==P||t[101]!==Q?($=(0,s.jsxs)(De.Root,{open:m,onOpenChange:be,children:[P,Q]}),t[98]=m,t[99]=De.Root,t[100]=P,t[101]=Q,t[102]=$):$=t[102],$}function me(e,t){return(0,s.jsx)(`div`,{className:`flex h-8 items-center justify-center text-[11px] font-medium text-fg-subtle`,children:e},`${e}-${t}`)}function he(e){return new Date(e.getFullYear(),e.getMonth()+1,1,12)}function ge(e){return new Date(e.getFullYear(),e.getMonth()-1,1,12)}function _e(e){return e.language}export{l as t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./check-DUBLcKHA.js";import{t as a}from"./x-B_N4OPjy.js";import{t as o}from"./cn-JdwAhgNB.js";import{t as s}from"./button-CSEbl4zT.js";import{a as c,i as l,n as u,o as d,r as f}from"./dist-DY4Af0fY.js";import{Il as p,Us as m,kc as h}from"./index-CMLkr37Y.js";var g=n(),_=e(t(),1),v=r(),y=`!z-[10000] max-w-[min(28rem,90vw)] rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-relaxed text-fg shadow-lg`;function b(e){let t=(0,g.c)(30),{candidates:n,selectedIds:r,labels:b,disabled:S,borderless:C,onChange:w}=e,T=C===void 0?!1:C,[E,D]=(0,_.useState)(!1),[O,k]=(0,_.useState)(``),A;t[0]===O?A=t[1]:(A=O.trim().toLocaleLowerCase(),t[0]=O,t[1]=A);let j=A,M;if(t[2]!==n||t[3]!==j){let e;t[5]===j?e=t[6]:(e=e=>!j||e.title.toLocaleLowerCase().includes(j),t[5]=j,t[6]=e),M=n.filter(e).slice(0,20),t[2]=n,t[3]=j,t[4]=M}else M=t[4];let N=M,P;t[7]!==n||t[8]!==S||t[9]!==b.remove||t[10]!==w||t[11]!==r?(P=r.length>0?(0,v.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-2`,children:r.map(e=>{let t=n.find(t=>t.id===e);return t?(0,v.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-lg bg-accent-soft px-2.5 py-1.5 text-xs text-accent-fg`,children:[(0,v.jsxs)(c,{children:[(0,v.jsx)(d,{asChild:!0,children:(0,v.jsx)(`span`,{className:`min-w-0 truncate`,children:t.title})}),(0,v.jsx)(f,{children:(0,v.jsx)(u,{side:`top`,sideOffset:6,collisionPadding:12,className:y,children:(0,v.jsx)(`span`,{className:`break-words`,children:t.title})})})]}),(0,v.jsx)(`button`,{type:`button`,className:`shrink-0 rounded text-accent-fg/70 hover:text-accent-fg`,"aria-label":b.remove.replace(`{{task}}`,t.title),disabled:S,onClick:()=>w(r.filter(e=>e!==t.id)),children:(0,v.jsx)(a,{className:`size-3.5`,"aria-hidden":!0})})]},t.id):null})}):null,t[7]=n,t[8]=S,t[9]=b.remove,t[10]=w,t[11]=r,t[12]=P):P=t[12];let F;t[13]!==T||t[14]!==n.length||t[15]!==S||t[16]!==b.link||t[17]!==b.linked||t[18]!==b.noCandidates||t[19]!==b.noMatches||t[20]!==b.searchPlaceholder||t[21]!==N||t[22]!==w||t[23]!==E||t[24]!==O||t[25]!==r?(F=n.length>0?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(s,{type:`button`,variant:`secondary`,className:o(`w-fit rounded-lg`,T&&`border-0 bg-surface-hover shadow-none`),disabled:S,"aria-expanded":E,onClick:()=>D(x),children:[(0,v.jsx)(h,{className:`size-4`,"aria-hidden":!0}),r.length>0?b.linked.replace(`{{count}}`,String(r.length)):b.link,(0,v.jsx)(p,{className:o(`size-3.5 transition-transform`,E&&`rotate-180`),"aria-hidden":!0})]}),E?(0,v.jsxs)(`div`,{className:o(`grid gap-2 rounded-lg p-2`,T?`bg-surface-hover`:`border border-edge bg-surface-base`),children:[(0,v.jsxs)(`label`,{className:`relative block`,children:[(0,v.jsx)(m,{className:`pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,v.jsx)(`input`,{value:O,onChange:e=>k(e.target.value),placeholder:b.searchPlaceholder,className:o(`h-9 w-full rounded-md bg-surface-panel pl-8 pr-3 text-sm text-fg outline-none placeholder:text-fg-subtle`,T?`focus:ring-2 focus:ring-accent/30`:`border border-edge focus:border-accent`),autoFocus:!0})]}),N.length>0?(0,v.jsx)(`div`,{className:`grid max-h-52 gap-1 overflow-y-auto`,children:N.map(e=>{let t=r.includes(e.id);return(0,v.jsxs)(`button`,{type:`button`,"aria-pressed":t,disabled:S,onClick:()=>w(t?r.filter(t=>t!==e.id):[...r,e.id]),className:o(`flex items-center gap-2 rounded-md px-2.5 py-2 text-left text-sm transition-colors`,t?`bg-accent-soft text-accent-fg`:`text-fg hover:bg-surface-hover`),children:[(0,v.jsx)(`span`,{className:o(`flex size-4 shrink-0 items-center justify-center rounded`,T?t?`bg-accent text-white`:`bg-surface-active`:t?`border border-accent bg-accent text-white`:`border border-edge`),children:t?(0,v.jsx)(i,{className:`size-3`,"aria-hidden":!0}):null}),(0,v.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title})]},e.id)})}):(0,v.jsx)(`p`,{className:`px-2 py-3 text-center text-sm text-fg-subtle`,children:b.noMatches})]}):null]}):(0,v.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:b.noCandidates}),t[13]=T,t[14]=n.length,t[15]=S,t[16]=b.link,t[17]=b.linked,t[18]=b.noCandidates,t[19]=b.noMatches,t[20]=b.searchPlaceholder,t[21]=N,t[22]=w,t[23]=E,t[24]=O,t[25]=r,t[26]=F):F=t[26];let I;return t[27]!==P||t[28]!==F?(I=(0,v.jsx)(l,{delayDuration:300,children:(0,v.jsxs)(`div`,{className:`min-w-0 grid gap-2`,children:[P,F]})}),t[27]=P,t[28]=F,t[29]=I):I=t[29],I}function x(e){return!e}export{b as t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{l as i}from"./chunk-KS7C4IRE-BaASWQor.js";import{n as a,r as o}from"./popover-select-BzdnTy3h.js";import{t as s}from"./external-link-DjqjBmc3.js";import{t as c}from"./cn-JdwAhgNB.js";import{t as l}from"./messages-VI9m1xJl.js";import{n as u}from"./locale-store-De8wYkd7.js";import{t as d}from"./electron-env-DH5wF8X8.js";import{Ks as f,Nl as p,Ua as m,Xo as h,oc as g,os as _,qs as v,vc as y}from"./index-CMLkr37Y.js";import{t as b}from"./desktop-pet-sprite-DTqXSpqf.js";import{n as x,r as S}from"./settings-page-layout-BRQNel6r.js";var C=n(),w=e(t(),1),T=r();function E(e){let t=(0,C.c)(16),{title:n,desc:r,checked:i,disabled:a,onChange:o}=e,s;t[0]===n?s=t[1]:(s=(0,T.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=s);let c;t[2]===r?c=t[3]:(c=(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r}),t[2]=r,t[3]=c);let l;t[4]!==s||t[5]!==c?(l=(0,T.jsxs)(`div`,{className:`min-w-0`,children:[s,c]}),t[4]=s,t[5]=c,t[6]=l):l=t[6];let u;t[7]===o?u=t[8]:(u=e=>o(e.target.checked),t[7]=o,t[8]=u);let d;t[9]!==i||t[10]!==a||t[11]!==u?(d=(0,T.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:a,checked:i,onChange:u}),t[9]=i,t[10]=a,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==l||t[14]!==d?(f=(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[l,d]}),t[13]=l,t[14]=d,t[15]=f):f=t[15],f}function D(){let e=l(u(e=>e.language)).desktopPetSettings,t=i(),[n,r]=(0,w.useState)(null),[C,D]=(0,w.useState)(!1),[O,k]=(0,w.useState)(null),A=typeof window<`u`?window.electronAPI?.pet:void 0,j=(0,w.useMemo)(()=>n?.pets.find(e=>e.id===n.prefs.selectedPetId)??n?.pets[0],[n]),M=(0,w.useCallback)(async()=>{if(A){D(!0);try{r(await A.getState())}finally{D(!1)}}},[A]);if((0,w.useEffect)(()=>{if(A)return M(),A.onStateChanged(r)},[A,M]),!d()||!A)return null;if(!n)return(0,T.jsxs)(S,{gap:`gap-4`,children:[(0,T.jsx)(x,{title:e.title,subtitle:e.subtitle}),(0,T.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,"aria-busy":!0,"aria-label":e.loading,children:(0,T.jsxs)(`div`,{className:`space-y-3`,children:[(0,T.jsx)(m,{className:`h-14 rounded-xl`}),(0,T.jsx)(m,{className:`h-14 rounded-xl`}),(0,T.jsx)(m,{className:`h-24 rounded-xl`}),(0,T.jsx)(`div`,{className:`space-y-2 pt-2`,children:Array.from({length:3}).map((e,t)=>(0,T.jsx)(m,{className:`h-16 rounded-xl`},t))})]})})]});let N=async e=>{D(!0);try{r(await A.setPrefs(e))}finally{D(!1)}},P=async e=>{e?(await A.show(),r(await A.getState())):r(await A.setPrefs({enabled:!1}))},F=e=>{N({selectedPetId:e})},I=t=>{if(t.builtin&&t.i18nKey){let n=e.builtinPets[t.i18nKey];if(n)return n}return{name:t.name,description:t.description}},L=e=>{t({pathname:`/chat/new`,search:`?draft=${encodeURIComponent(e)}`})},R=e=>{if(e.sourcePrompt?.trim())return e.sourcePrompt.trim();let{description:t}=I(e);return t.replace(/^Custom pet generated from:\s*/i,``).trim()||t},z=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.split(`{${t}}`).join(n),e),B=()=>{L(e.createChatDraft)},V=t=>{L(z(e.optimizeChatDraft,{id:t.id,name:I(t).name,description:I(t).description,sourcePrompt:R(t)}))},H=t=>{L(z(e.fixChatDraft,{dir:t.dir,reason:t.reason,details:t.details?.join(`; `)||e.noIssueDetails}))},U=O??n.prefs.sizePercent,W=Math.max(1,Math.floor((Date.now()-n.relationship.firstMetAt)/864e5)+1),G=async(e=U)=>{let t=Math.min(140,Math.max(70,Math.round(e/5)*5));k(null),t!==n.prefs.sizePercent&&await N({sizePercent:t})};return(0,T.jsxs)(S,{gap:`gap-4`,children:[(0,T.jsx)(x,{title:e.title,subtitle:e.subtitle,actions:(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[(0,T.jsxs)(`button`,{type:`button`,className:c(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,h.press),disabled:C,onClick:()=>void M(),children:[(0,T.jsx)(v,{className:c(`size-3.5`,C&&`animate-spin`),strokeWidth:1.75}),e.refresh]}),(0,T.jsxs)(`button`,{type:`button`,className:c(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,h.press),onClick:()=>void A.openCustomPetsDir(),children:[(0,T.jsx)(s,{className:`size-3.5`,strokeWidth:1.75}),e.openFolder]})]})}),(0,T.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4 shadow-surface`,children:[(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(E,{title:e.enable,desc:e.enableDesc,checked:n.prefs.enabled,disabled:C,onChange:e=>void P(e)}),(0,T.jsx)(E,{title:e.showOnStartup,desc:e.showOnStartupDesc,checked:n.prefs.showOnStartup,disabled:C,onChange:e=>void N({showOnStartup:e})})]}),(0,T.jsx)(`div`,{className:`mt-5 rounded-xl border border-edge-subtle bg-surface-panel p-3`,children:(0,T.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,T.jsx)(_,{className:`mt-0.5 size-4 text-accent-fg`,strokeWidth:1.8}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.createTitle}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.createDesc})]})]}),(0,T.jsxs)(`button`,{type:`button`,className:c(`inline-flex h-9 shrink-0 items-center justify-center gap-1.5 rounded-lg bg-accent px-3 text-xs font-semibold text-white hover:bg-accent/90`,h.press),onClick:B,children:[(0,T.jsx)(y,{className:`size-3.5`,strokeWidth:1.75}),e.createInChat]})]})}),(0,T.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3 rounded-xl border border-edge-subtle bg-surface-panel p-3`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.bondTitle}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.bondDesc})]}),(0,T.jsx)(`span`,{className:`shrink-0 rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:e.bondSummary.replace(`{days}`,String(W)).replace(`{tasks}`,String(n.relationship.completedTaskCount))})]}),(0,T.jsxs)(`div`,{className:`mt-5`,children:[(0,T.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.petList}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.petListDesc})]}),j?(0,T.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:I(j).name}):null]}),(0,T.jsxs)(`div`,{className:`divide-y divide-edge-subtle rounded-xl border border-edge bg-surface-base`,children:[n.pets.map(t=>{let r=t.id===n.prefs.selectedPetId,i=I(t);return(0,T.jsxs)(`div`,{className:`flex items-center gap-3 p-3`,children:[(0,T.jsx)(b,{pet:t,action:`idle`,size:`tiny`}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:i.name}),t.builtin?null:(0,T.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.customBadge})]}),(0,T.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:i.description})]}),(0,T.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[t.builtin?null:(0,T.jsxs)(`button`,{type:`button`,className:c(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,h.press),onClick:()=>V(t),children:[(0,T.jsx)(g,{className:`size-3.5`,strokeWidth:1.75}),e.optimizeInChat]}),(0,T.jsx)(`button`,{type:`button`,className:c(`rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors`,r?`bg-surface-hover text-fg-muted`:`bg-surface-panel text-fg hover:bg-surface-hover`,h.press),disabled:r||C,onClick:()=>F(t.id),children:r?e.selected:e.select})]})]},t.id)}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-1 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`p`,{className:`text-xs font-semibold text-fg`,children:e.customPets}),(0,T.jsx)(`p`,{className:`font-mono text-xs text-fg-muted`,children:n.customPetsDir})]}),(0,T.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,onClick:()=>void A.openCustomPetsDir(),children:[e.openFolder,(0,T.jsx)(s,{className:`size-3.5`,strokeWidth:1.75})]})]})]}),n.petIssues.length>0?(0,T.jsxs)(`div`,{className:`mt-2 rounded-xl border border-danger/30 bg-danger/5 p-3`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold text-danger`,children:[(0,T.jsx)(p,{className:`size-3.5`,strokeWidth:1.8}),e.invalidPets]}),(0,T.jsx)(`div`,{className:`mt-2 space-y-2`,children:n.petIssues.map(t=>(0,T.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base/70 p-2 text-xs text-fg-muted sm:flex-row sm:items-start sm:justify-between`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsx)(`p`,{className:`truncate font-mono text-[11px] text-fg`,children:t.dir}),(0,T.jsx)(`p`,{children:t.reason}),t.details?.length?(0,T.jsx)(`p`,{className:`line-clamp-2`,children:t.details.join(`; `)}):null]}),(0,T.jsxs)(`button`,{type:`button`,className:c(`inline-flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-lg border border-danger/30 bg-surface-base px-2.5 text-xs font-medium text-danger hover:bg-danger/10`,h.press),onClick:()=>H(t),children:[(0,T.jsx)(y,{className:`size-3.5`,strokeWidth:1.75}),e.fixInChat]})]},`${t.dir}-${t.reason}`))})]}):null]}),(0,T.jsxs)(`div`,{className:`mt-5 grid gap-2`,children:[(0,T.jsxs)(`div`,{className:`rounded-xl bg-surface-hover/50 p-3 dark:bg-surface-hover/35`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.size}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.sizeDesc})]}),(0,T.jsxs)(`span`,{className:`text-xs font-medium text-fg-muted`,children:[U,`%`]})]}),(0,T.jsx)(`input`,{type:`range`,min:70,max:140,step:5,className:`mt-3 w-full accent-accent`,value:U,onChange:e=>k(Number(e.target.value)),onBlur:()=>void G(),onKeyUp:e=>{(e.key===`Enter`||e.key===` `||e.key.startsWith(`Arrow`))&&G()},onPointerUp:()=>void G()})]}),(0,T.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,T.jsx)(E,{title:e.alwaysOnTop,desc:e.alwaysOnTopDesc,checked:n.prefs.alwaysOnTop,disabled:C,onChange:e=>void N({alwaysOnTop:e})}),(0,T.jsx)(E,{title:e.bubbles,desc:e.bubblesDesc,checked:n.prefs.bubbleEnabled,disabled:C,onChange:e=>void N({bubbleEnabled:e})}),(0,T.jsx)(E,{title:e.proactiveTips,desc:e.proactiveTipsDesc,checked:n.prefs.proactiveTipsEnabled,disabled:C,onChange:e=>void N({proactiveTipsEnabled:e})}),(0,T.jsx)(E,{title:e.interactions,desc:e.interactionsDesc,checked:n.prefs.interactionEnabled,disabled:C,onChange:e=>void N({interactionEnabled:e})}),(0,T.jsx)(E,{title:e.reducedMotion,desc:e.reducedMotionDesc,checked:n.prefs.reducedMotion,disabled:C,onChange:e=>void N({reducedMotion:e})}),(0,T.jsx)(E,{title:e.clickThrough,desc:e.clickThroughDesc,checked:n.prefs.clickThroughWhenIdle,disabled:C,onChange:e=>void N({clickThroughWhenIdle:e})})]}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl bg-surface-hover/50 p-3 dark:bg-surface-hover/35 sm:flex-row sm:items-center sm:justify-between`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.behaviorMode}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.behaviorModeDesc})]}),(0,T.jsxs)(a,{className:`w-full sm:w-40`,triggerClassName:`h-9 bg-surface-panel`,value:n.prefs.behaviorMode,onChange:e=>void N({behaviorMode:e.target.value}),children:[(0,T.jsx)(o,{value:`focus`,children:e.behaviorFocus}),(0,T.jsx)(o,{value:`companion`,children:e.behaviorCompanion}),(0,T.jsx)(o,{value:`playful`,children:e.behaviorPlayful})]})]}),(0,T.jsxs)(`button`,{type:`button`,className:c(`inline-flex w-fit items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-3 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,h.press),disabled:C,onClick:()=>void A.resetPosition().then(r),children:[(0,T.jsx)(f,{className:`size-3.5`,strokeWidth:1.75}),e.resetPosition]})]})]})]})}export{D as DesktopPetSettings};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-JdwAhgNB.js";import{Xo as r,Xt as i,Zt as a,oa as o,tl as s}from"./index-CMLkr37Y.js";var c=e(),l=t();function u(e){let t=(0,c.c)(27),{value:i,onPick:a,disabled:u,placeholder:d,title:f,className:p,maxWidthClass:m,compact:h,"aria-label":g}=e,_=m===void 0?`max-w-[min(12rem,40vw)]`:m,v=h===void 0?!1:h,y,b;t[0]!==d||t[1]!==i?(b=i.trim(),y=b?o(b):d??``,t[0]=d,t[1]=i,t[2]=y,t[3]=b):(y=t[2],b=t[3]);let x=y,S=f??(b||void 0),C=g??f??x,w=v?`inline-flex size-9 shrink-0 items-center justify-center rounded-lg p-0`:`inline-flex min-h-8 min-w-0 shrink-0 items-center gap-1 rounded-lg px-2 py-1 text-xs`,T=!v&&_,E=u&&`cursor-not-allowed opacity-60`,D;t[4]!==p||t[5]!==w||t[6]!==T||t[7]!==E?(D=n(w,`border border-edge-subtle/80 bg-surface-hover/40 dark:border-edge-subtle`,r.transition,r.focusRingPanel,`cursor-pointer hover:bg-surface-hover/70 dark:hover:bg-surface-hover/50`,T,E,p),t[4]=p,t[5]=w,t[6]=T,t[7]=E,t[8]=D):D=t[8];let O;t[9]!==u||t[10]!==a?(O=e=>{e.stopPropagation(),u||a()},t[9]=u,t[10]=a,t[11]=O):O=t[11];let k=v?`size-4`:`size-3.5`,A;t[12]===k?A=t[13]:(A=n(`shrink-0 text-fg-muted`,k),t[12]=k,t[13]=A);let j;t[14]===A?j=t[15]:(j=(0,l.jsx)(s,{className:A,"aria-hidden":!0}),t[14]=A,t[15]=j);let M;t[16]!==v||t[17]!==x?(M=v?null:(0,l.jsx)(`span`,{className:`min-w-0 truncate text-left font-medium text-fg`,children:x}),t[16]=v,t[17]=x,t[18]=M):M=t[18];let N;return t[19]!==u||t[20]!==O||t[21]!==j||t[22]!==M||t[23]!==S||t[24]!==C||t[25]!==D?(N=(0,l.jsxs)(`button`,{type:`button`,disabled:u,title:S,"aria-label":C,className:D,onClick:O,children:[j,M]}),t[19]=u,t[20]=O,t[21]=j,t[22]=M,t[23]=S,t[24]=C,t[25]=D,t[26]=N):N=t[26],N}function d(e){let t=(0,c.c)(38),{value:r,onChange:o,disabled:s,wd:d,placeholder:f,inputClassName:p,autoFocus:m,trailing:h}=e,g;t[0]!==o||t[1]!==r?(g={initialPath:r,onPicked:o},t[0]=o,t[1]=r,t[2]=g):g=t[2];let _=a(g),v;t[3]===r?v=t[4]:(v=r.trim(),t[3]=r,t[4]=v);let y=v,b=y?`${y}\n${d.chooseFolder}`:`${f??d.notSet}\n${d.selectWorkingDirectory}`,x;t[5]===p?x=t[6]:(x=n(`min-w-0 flex-1`,p),t[5]=p,t[6]=x);let S=s||_.picking,C;t[7]===o?C=t[8]:(C=e=>void o(e.target.value),t[7]=o,t[8]=C);let w=f??d.pathInputPlaceholder,T;t[9]!==m||t[10]!==x||t[11]!==S||t[12]!==C||t[13]!==w||t[14]!==r?(T=(0,l.jsx)(`input`,{type:`text`,className:x,value:r,disabled:S,onChange:C,placeholder:w,autoFocus:m,autoComplete:`off`,spellCheck:!1}),t[9]=m,t[10]=x,t[11]=S,t[12]=C,t[13]=w,t[14]=r,t[15]=T):T=t[15];let E=s||_.picking,D;t[16]!==b||t[17]!==_.pick||t[18]!==E||t[19]!==r||t[20]!==d.selectWorkingDirectory?(D=(0,l.jsx)(u,{compact:!0,value:r,onPick:_.pick,disabled:E,title:b,"aria-label":d.selectWorkingDirectory}),t[16]=b,t[17]=_.pick,t[18]=E,t[19]=r,t[20]=d.selectWorkingDirectory,t[21]=D):D=t[21];let O;t[22]!==D||t[23]!==h?(O=(0,l.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[D,h]}),t[22]=D,t[23]=h,t[24]=O):O=t[24];let k;t[25]!==O||t[26]!==T?(k=(0,l.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[T,O]}),t[25]=O,t[26]=T,t[27]=k):k=t[27];let A;t[28]!==_.confirmPick||t[29]!==_.hasNativePicker||t[30]!==_.modalOpen||t[31]!==_.setModalOpen||t[32]!==y||t[33]!==d?(A=_.hasNativePicker?null:(0,l.jsx)(i,{open:_.modalOpen,onOpenChange:_.setModalOpen,initialAbsolutePath:y||void 0,onConfirm:_.confirmPick,wd:d}),t[28]=_.confirmPick,t[29]=_.hasNativePicker,t[30]=_.modalOpen,t[31]=_.setModalOpen,t[32]=y,t[33]=d,t[34]=A):A=t[34];let j;return t[35]!==k||t[36]!==A?(j=(0,l.jsxs)(l.Fragment,{children:[k,A]}),t[35]=k,t[36]=A,t[37]=j):j=t[37],j}export{d as t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,t as a}from"./chunk-KS7C4IRE-BaASWQor.js";import{n as o,r as s}from"./popover-select-BzdnTy3h.js";import{t as c}from"./cn-JdwAhgNB.js";import{t as l}from"./button-CSEbl4zT.js";import{t as u}from"./messages-VI9m1xJl.js";import{l as d,n as f,o as p,r as m,s as h}from"./locale-store-De8wYkd7.js";import{i as g}from"./vendor-swr-BIWyz7Rc.js";import{$o as _,Di as v,es as y,qa as b,ts as x}from"./index-CMLkr37Y.js";import{t as S}from"./settings-loading-skeleton-xgo41cfo.js";import{n as C,t as w}from"./use-autosave-CqFVx92z.js";import{c as T,d as E,s as D,t as O}from"./voice-api-key-field-pYDiKKMo.js";import{t as k}from"./schema-form-DNCDIkqC.js";var A=e(t(),1),j=n(),M=r();function N(e){let t=(0,j.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,M.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function P(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 F(){return c(y,_)}function I(){return c(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,x,`dark:border-edge`)}function L(e,t,n){if(!e||!t)return{apiKey:``,model:n};let r=e.stt.providers?.[t];return{apiKey:typeof r?.apiKey==`string`?r.apiKey:``,model:typeof r?.model==`string`?r.model:n}}function R({providerId:e,voiceSettings:t,mutateVoice:n}){let r=u(f(e=>e.language)),i=r.voiceSettings,a=r.extensionSttMedia,l={maskedHelp:i.apiKeyMaskedHelp,copy:i.apiKeyCopy,copied:i.apiKeyCopied,show:i.apiKeyShow,hide:i.apiKeyHide,notInConfigFile:i.apiKeyNotInConfigFile,loadFailed:i.apiKeyRevealFailed},{data:d}=g(m(`/api/voice/stt-providers`),T,{revalidateOnFocus:!1}),p=(0,A.useMemo)(()=>d?.providers.find(t=>t.id===e),[e,d]),h=p?.configured??!1,v=p?.models??[],y=v[0]?.id??p?.fields.find(e=>e.key===`model`)?.defaultValue??``,b=(0,A.useMemo)(()=>L(t,e,y),[y,e,t]),x=(0,A.useRef)(!1),[S,D]=(0,A.useState)(null),k=S??b,j=(0,A.useRef)(k);j.current=k;let P=b,R=w({value:k,dirty:k.apiKey!==P.apiKey||k.model!==P.model,onSave:(0,A.useCallback)(async r=>{let i=structuredClone(t);i.stt.enabled=!0,i.stt.provider=e,i.stt.providers={...i.stt.providers??{},[e]:{...i.stt.providers?.[e]??{},apiKey:r.apiKey,model:r.model}},await E(i),await n(i,!1),x.current=JSON.stringify(j.current)!==JSON.stringify(r),D(e=>e&&JSON.stringify(e)===JSON.stringify(r)?null:e)},[n,e,t])}),z=v.length>0?v:k.model?[{id:k.model,name:k.model}]:[];return(0,M.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl bg-surface-base p-4`,onBlurCapture:R.onBlurCapture,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a.credentialsTitle}),(0,M.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.credentialsHint.replace(`{providerId}`,e)})]}),(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(C,{status:R.status,error:R.error}),(0,M.jsx)(`span`,{className:c(`rounded-full px-2 py-0.5 text-xs font-medium`,h?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:h?a.configured:a.notConfigured})]})]}),(0,M.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,M.jsxs)(`div`,{className:c(`flex flex-col gap-1.5`,_),children:[(0,M.jsx)(N,{children:i.stt.apiKey}),(0,M.jsx)(O,{kind:`stt`,providerId:e,fieldId:`ext-stt-${e}-api-key`,value:k.apiKey,onChange:e=>{x.current=!0,D(t=>({...t??b,apiKey:e}))},labels:l,placeholder:e===`groq`?`gsk_...`:`sk-...`}),(0,M.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[i.stt.apiKeyDesc,e===`groq`?` (GROQ_API_KEY)`:``]})]}),(0,M.jsxs)(`div`,{className:c(`flex flex-col gap-1.5`,_),children:[(0,M.jsx)(N,{children:i.stt.model}),z.length>0?(0,M.jsx)(o,{className:F(),value:k.model,onChange:e=>{x.current=!0,D(t=>({...t??b,model:e.target.value})),R.saveNow({...k,model:e.target.value})},children:z.map(e=>(0,M.jsx)(s,{value:e.id,children:e.name},e.id))}):(0,M.jsx)(`input`,{className:I(),value:k.model,onChange:e=>{x.current=!0,D(t=>({...t??b,model:e.target.value}))}})]})]})]})}function z(e){let t=(0,j.c)(13),{extensionId:n}=e,r=f(V),i=d(B),a;t[0]===n?a=t[1]:(a=()=>h(m(`/api/extensions/${encodeURIComponent(n)}`)),t[0]=n,t[1]=a);let{data:o,isLoading:s}=g(i&&n?`ext-stt-detail-${n}`:null,a),c;t[2]===o?c=t[3]:(c=P(o),t[2]=o,t[3]=c);let l=c,u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u={revalidateOnFocus:!1},t[4]=u):u=t[4];let{data:p,mutate:_,isLoading:v}=g(i?`voice-settings-ext-stt`:null,D,u);if(!i)return null;if(s||v){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,M.jsx)(S,{rows:2}),t[5]=e):e=t[5],e}if(!l){let e=r===`zh`?`该扩展未声明 mediaUnderstandingProviders。`:`This extension does not declare mediaUnderstandingProviders.`,n;return t[6]===e?n=t[7]:(n=(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[6]=e,t[7]=n),n}if(!p)return null;let y=`${n}:${l}`,b;return t[8]!==_||t[9]!==l||t[10]!==y||t[11]!==p?(b=(0,M.jsx)(R,{providerId:l,voiceSettings:p,mutateVoice:_},y),t[8]=_,t[9]=l,t[10]=y,t[11]=p,t[12]=b):b=t[12],b}function B(e){return!!e.token}function V(e){return e.language}function H(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function U(e){let t={};if(e.type!==`object`||!H(e.properties))return t;for(let[n,r]of Object.entries(e.properties))H(r)&&Object.prototype.hasOwnProperty.call(r,`default`)&&(t[n]=r.default);return t}function W(e,t){switch(t.type){case`sync`:return{localValues:t.value,isDirty:!1};case`change`:return{localValues:t.value,isDirty:!0};case`reset-defaults`:return{localValues:t.value,isDirty:!0};case`saved`:return JSON.stringify(e.localValues)===JSON.stringify(t.value)?{localValues:e.localValues,isDirty:!1}:e}}function G({extensionId:e}){let t=d(e=>!!e.token),{data:n,error:r}=g(t&&e?`ext-detail-${e}`:null,()=>h(m(`/api/extensions/${encodeURIComponent(e)}`))),{data:i,mutate:a,error:o}=g(t&&e?`ext-cfg-${e}`:null,()=>h(m(`/api/extensions/${encodeURIComponent(e)}/config`))),s=n?.manifest?.configSchema,c=(0,A.useMemo)(()=>s&&s.type===`object`?U(s):{},[s]),u=(0,A.useMemo)(()=>({...c,...i??{}}),[c,i]),[f,_]=(0,A.useReducer)(W,{localValues:{},isDirty:!1}),v=(0,A.useRef)(!1),y=(0,A.useRef)(f.localValues);y.current=f.localValues;let b=(0,A.useRef)(u);!v.current&&b.current!==u&&(b.current=u,_({type:`sync`,value:u}));let x=(0,A.useCallback)(e=>{v.current=!0,_({type:`change`,value:e})},[]),S=(0,A.useCallback)(()=>{!s||s.type!==`object`||(v.current=!0,_({type:`reset-defaults`,value:{...U(s)}}))},[s]),T=(0,A.useCallback)(async t=>{if(!e)return;let n=await p(m(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error?.message??n.statusText)}await a(t,!1),_({type:`saved`,value:t}),v.current=JSON.stringify(y.current)!==JSON.stringify(t)},[e,a]),E=w({value:f.localValues,dirty:f.isDirty,onSave:T});if(!t)return null;if(r||o){let e=r??o;return(0,M.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`Could not load extension settings: `,e instanceof Error?e.message:String(e)]})}return!s||s.type!==`object`?null:(0,M.jsxs)(`div`,{className:`mb-6 flex flex-col gap-3 rounded-xl bg-surface-base p-4`,onBlurCapture:E.onBlurCapture,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,M.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Configuration`}),(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(C,{status:E.status,error:E.error}),(0,M.jsx)(l,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:S,children:`Reset to defaults`})]})]}),(0,M.jsx)(k,{schema:s,values:f.localValues,onChange:x})]})}function K(){let e=(0,j.c)(38),t=f(q),n;e[0]===t?n=e[1]:(n=u(t),e[0]=t,e[1]=n);let r=n.extensionSttMedia,{extensionId:o,panelId:s}=i(),c=b();if(!o){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,M.jsx)(J,{message:`No extension ID provided.`}),e[2]=t):t=e[2],t}let l,d,p;if(e[3]!==o||e[4]!==c||e[5]!==s){p=Symbol.for(`react.early_return_sentinel`);bb0:{let t;if(e[9]===o?t=e[10]:(t=e=>e.id===o,e[9]=o,e[10]=t),l=c.find(t),!l){let t=`Extension "${o}" not found or is not available in this workspace.`,n;e[11]===t?n=e[12]:(n=(0,M.jsx)(J,{message:t}),e[11]=t,e[12]=n),p=n;break bb0}let n=l.ui?.contributions?.settingsPanels;d=s?n?.find(e=>e.id===s||e.id===`${o}.${s}`):n?.[0]}e[3]=o,e[4]=c,e[5]=s,e[6]=l,e[7]=d,e[8]=p}else l=e[6],d=e[7],p=e[8];if(p!==Symbol.for(`react.early_return_sentinel`))return p;let m=d,h=!!(m&&l.ui),g=!!l.hasConfigSchema,_=l.kind===`media-provider`;if(!g&&!h&&!_){let t=`Extension "${o}" has no settings panels or config schema.`,n;return e[13]===t?n=e[14]:(n=(0,M.jsx)(J,{message:t}),e[13]=t,e[14]=n),n}let y=m?.title??`${l.name} Settings`,x;e[15]===y?x=e[16]:(x=(0,M.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:y}),e[15]=y,e[16]=x);let S;e[17]!==_||e[18]!==r?(S=_?(0,M.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base px-4 py-3 text-sm`,children:[(0,M.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:r.banner}),(0,M.jsx)(a,{to:`/settings/capabilities/voice`,className:`w-fit font-medium text-accent hover:underline`,children:r.openVoice})]}):null,e[17]=_,e[18]=r,e[19]=S):S=e[19];let C;e[20]!==o||e[21]!==_?(C=_?(0,M.jsx)(z,{extensionId:o}):null,e[20]=o,e[21]=_,e[22]=C):C=e[22];let w;e[23]!==o||e[24]!==g?(w=g?(0,M.jsx)(G,{extensionId:o}):null,e[23]=o,e[24]=g,e[25]=w):w=e[25];let T;e[26]!==l.name||e[27]!==l.ui||e[28]!==o||e[29]!==h||e[30]!==m?(T=h&&m&&l.ui?(0,M.jsx)(`div`,{className:`overflow-hidden rounded-xl bg-surface-base shadow-surface`,children:(0,M.jsx)(v,{extensionId:o,extensionName:l.name,entrypoint:m.entrypoint,permissions:l.ui?.permissions,title:m.title,className:`w-full`,minHeight:120,maxHeight:2e3})}):null,e[26]=l.name,e[27]=l.ui,e[28]=o,e[29]=h,e[30]=m,e[31]=T):T=e[31];let E;return e[32]!==x||e[33]!==S||e[34]!==C||e[35]!==w||e[36]!==T?(E=(0,M.jsxs)(`div`,{className:`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,children:[x,S,C,w,T]}),e[32]=x,e[33]=S,e[34]=C,e[35]=w,e[36]=T,e[37]=E):E=e[37],E}function q(e){return e.language}function J(e){let t=(0,j.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,M.jsx)(`div`,{className:`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,children:(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{K as ExtensionSettingsPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n}from"./vendor-react-BOUWij0V.js";import{r,s as i}from"./locale-store-De8wYkd7.js";import{n as a}from"./gateway-config-swr-BTH9HVUk.js";import{Jo as o,_r as s}from"./index-CMLkr37Y.js";var c=e(t(),1),l=n(),u=new Set([`updates`,`security`,`advanced`]),d=new Set([`local`,`cdp`,`cloud`]);function f(e,t){return t===`advanced`?!0:!u.has(e)}function p(e,t){return e.filter(e=>f(e,t))}function m(e,t){return t===`advanced`?!0:!d.has(e)}function h(e,t){return e.filter(e=>m(e,t))}function g(){return`network`}function _(){return`overview`}function v(e,t){let n=(0,l.c)(5),r=s(y),i,a;n[0]!==e||n[1]!==r||n[2]!==t?(i=()=>{f(e,r)||t(g())},a=[e,r,t],n[0]=e,n[1]=r,n[2]=t,n[3]=i,n[4]=a):(i=n[3],a=n[4]),(0,c.useEffect)(i,a)}function y(e){return e.mode}function b(e,t){let n=(0,l.c)(5),r=s(x),i,a;n[0]!==e||n[1]!==r||n[2]!==t?(i=()=>{m(e,r)||t(_())},a=[e,r,t],n[0]=e,n[1]=r,n[2]=t,n[3]=i,n[4]=a):(i=n[3],a=n[4]),(0,c.useEffect)(i,a)}function x(e){return e.mode}var S=18790,C={enabled:!0,maxAttempts:5,windowMs:9e5,blockDurationMs:3e5,exemptLoopback:!0};function w(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function T(e){return o(e)}async function E(e){let t=await i(r(`/api/gateway/reveal-auth-secret/${encodeURIComponent(e)}`),{method:`POST`,body:`{}`});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}async function D(){let e=await i(r(`/api/agents/browser/reveal-cloud-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!e.ok||!e.payload)throw Error(e.error?.message??`Reveal failed`);return e.payload}function O(e){return T(e)?``:e.trim()}function k(e){return[...e].map(e=>e.trim()).sort()}function A(e){return JSON.stringify({bind:e.bind,customBindHost:e.customBindHost.trim(),port:e.port,auth:{mode:e.auth.mode,token:O(e.auth.token),password:O(e.auth.password),rateLimit:e.auth.rateLimit,trustedProxy:{userHeader:e.auth.trustedProxy.userHeader.trim(),requiredHeaders:k(e.auth.trustedProxy.requiredHeaders),allowUsers:k(e.auth.trustedProxy.allowUsers),allowLoopback:e.auth.trustedProxy.allowLoopback}},trustedProxies:k(e.trustedProxies),allowRealIpFallback:e.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:e.dangerouslyAllowHostHeaderOriginFallback})}function j(e,t){return A(e)!==A(t)}async function M(e){return(await i(r(`/api/gateway/cors-origin-candidates?port=${encodeURIComponent(String(e))}`))).payload?.candidates??[]}function N(e){return e===`none`||e===`token`||e===`password`||e===`trusted-proxy`?e:`token`}function P(e){let t=w(e)?e:{};return{enabled:t.enabled!==!1,maxAttempts:typeof t.maxAttempts==`number`&&Number.isFinite(t.maxAttempts)?Math.max(1,Math.floor(t.maxAttempts)):C.maxAttempts,windowMs:typeof t.windowMs==`number`&&Number.isFinite(t.windowMs)&&t.windowMs>0?Math.floor(t.windowMs):C.windowMs,blockDurationMs:typeof t.blockDurationMs==`number`&&Number.isFinite(t.blockDurationMs)&&t.blockDurationMs>0?Math.floor(t.blockDurationMs):typeof t.lockoutMs==`number`&&Number.isFinite(t.lockoutMs)&&t.lockoutMs>0?Math.floor(t.lockoutMs):C.blockDurationMs,exemptLoopback:t.exemptLoopback!==!1}}function F(e){let t=w(e)?e:{};return{userHeader:typeof t.userHeader==`string`?t.userHeader:``,requiredHeaders:L(t.requiredHeaders,32),allowUsers:L(t.allowUsers,128),allowLoopback:t.allowLoopback===!0}}function I(e){return e===`auto`||e===`off`||e===`explicit`?e:`auto`}function L(e,t=24){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).slice(0,t):[]}function R(e){return e===`auto`||e===`loopback`||e===`lan`||e===`tailnet`||e===`custom`?e:`loopback`}function z(e){if(e.bind===`loopback`)return!1;if(e.bind===`lan`)return!0;if(e.bind===`custom`){let t=e.customBindHost.trim().toLowerCase();return t?t!==`127.0.0.1`&&t!==`localhost`&&t!==`::1`:!0}return!0}function B(e){let t=z(e);return t&&e.auth.mode===`none`?`Network-accessible gateway requires authentication (token, password, or trusted-proxy).`:t&&e.auth.mode===`trusted-proxy`&&e.trustedProxies.length===0?`Trusted-proxy auth on a network bind requires at least one gateway.trustedProxies entry.`:e.auth.mode===`trusted-proxy`&&!e.auth.trustedProxy.userHeader.trim()?`Trusted-proxy auth requires gateway.auth.trustedProxy.userHeader.`:t&&e.corsOrigins.includes(`*`)?`CORS wildcard "*" is not allowed on network-accessible binds.`:e.bind===`custom`&&!e.customBindHost.trim()?`Custom bind mode requires a bind address.`:null}function V(e){let t=w(e)?e:{},n=w(t.gateway)?t.gateway:{},r=w(n.auth)?n.auth:{},i=w(n.security)?n.security:{},a=w(t.update)?t.update:{},o=w(a.auto)?a.auto:{},s=a.channel,c=s===`beta`||s===`dev`||s===`stable`?s:`stable`,l=Array.isArray(n.corsOrigins)?n.corsOrigins.filter(e=>typeof e==`string`&&e.trim().length>0):[];return{bind:R(n.bind),customBindHost:typeof n.customBindHost==`string`&&n.customBindHost.trim()?n.customBindHost.trim():``,port:typeof n.port==`number`&&Number.isFinite(n.port)?Math.floor(n.port):S,auth:{mode:N(r.mode),token:typeof r.token==`string`?r.token:``,password:typeof r.password==`string`?r.password:``,rateLimit:P(r.rateLimit),trustedProxy:F(r.trustedProxy)},corsOrigins:l,trustedProxies:L(n.trustedProxies,64),allowRealIpFallback:n.allowRealIpFallback===!0,dangerouslyAllowHostHeaderOriginFallback:n.dangerouslyAllowHostHeaderOriginFallback===!0,securityStrict:i.strict===!0,channelConnectDeferMode:I(n.channelConnectDeferMode),channelConnectDeferIds:L(n.channelConnectDeferIds),channelConnectDeferSkipIds:L(n.channelConnectDeferSkipIds),updateChannel:c,updateCheckOnStart:a.checkOnStart!==!1,updateAutoEnabled:o.enabled===!0,updateAutoStableDelayHours:typeof o.stableDelayHours==`number`&&Number.isFinite(o.stableDelayHours)?Math.max(0,Math.floor(o.stableDelayHours)):6,updateAutoStableJitterHours:typeof o.stableJitterHours==`number`&&Number.isFinite(o.stableJitterHours)?Math.max(0,Math.floor(o.stableJitterHours)):12,updateAutoBetaCheckIntervalHours:typeof o.betaCheckIntervalHours==`number`&&Number.isFinite(o.betaCheckIntervalHours)?Math.max(.25,o.betaCheckIntervalHours):1}}function H(e){let t={mode:e.auth.mode,rateLimit:e.auth.rateLimit};if(e.auth.mode===`token`){let n=e.auth.token.trim();n.length>0&&!T(n)&&(t.token=e.auth.token),t.password=null,t.trustedProxy=null}else if(e.auth.mode===`password`){let n=e.auth.password.trim();n.length>0&&!T(n)&&(t.password=e.auth.password),t.token=null,t.trustedProxy=null}else if(e.auth.mode===`trusted-proxy`){t.token=null,t.password=null;let n=e.auth.trustedProxy;t.trustedProxy={userHeader:n.userHeader.trim(),...n.requiredHeaders.length>0?{requiredHeaders:n.requiredHeaders}:{},...n.allowUsers.length>0?{allowUsers:n.allowUsers}:{},...n.allowLoopback?{allowLoopback:!0}:{}}}else t.token=null,t.password=null,t.trustedProxy=null;return t}async function U(e){let t=B(e);if(t)throw Error(t);await i(r(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{bind:e.bind,...e.bind===`custom`?{customBindHost:e.customBindHost.trim()}:{},port:e.port,auth:H(e),corsOrigins:e.corsOrigins,trustedProxies:e.trustedProxies,allowRealIpFallback:e.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:e.dangerouslyAllowHostHeaderOriginFallback,security:{strict:e.securityStrict},channelConnectDeferMode:e.channelConnectDeferMode,channelConnectDeferIds:e.channelConnectDeferIds,channelConnectDeferSkipIds:e.channelConnectDeferSkipIds},update:{channel:e.updateChannel,checkOnStart:e.updateCheckOnStart,auto:{enabled:e.updateAutoEnabled,stableDelayHours:e.updateAutoStableDelayHours,stableJitterHours:e.updateAutoStableJitterHours,betaCheckIntervalHours:e.updateAutoBetaCheckIntervalHours}}})}),a()}export{D as a,b as c,h as d,p as f,U as i,v as l,j as n,E as o,V as r,B as s,M as t,m as u};
@@ -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{p as i}from"./chunk-KS7C4IRE-BaASWQor.js";import{n as a,r as o}from"./popover-select-BzdnTy3h.js";import{t as s}from"./loader-circle-CifKLtgG.js";import{t as c}from"./cn-JdwAhgNB.js";import{t as l}from"./button-CSEbl4zT.js";import{t as u}from"./messages-VI9m1xJl.js";import{l as d,n as f,r as p,s as m}from"./locale-store-De8wYkd7.js";import{i as h,o as g}from"./vendor-swr-BIWyz7Rc.js";import{r as _}from"./gateway-config-swr-BTH9HVUk.js";import{Ai as v,Bo as y,Fs as b,Gs as x,Ic as S,Ko as C,Ls as w,Mi as T,Nl as E,Ps as D,Rc as O,Sr as k,Ua as A,Xo as j,_r as M,_s as N,fc as P,qo as F,qs as I,ts as L}from"./index-CMLkr37Y.js";import{n as R,r as ee,t as te}from"./settings-page-layout-BRQNel6r.js";import{n as ne}from"./settings-loading-skeleton-xgo41cfo.js";import{t as re}from"./settings-advanced-gate-BlCoA_9h.js";import{n as z,t as B}from"./settings-form-section-z0JH53Fu.js";import{t as ie}from"./page-tabs-e99j9S9K.js";import{f as ae,i as oe,l as se,n as ce,o as le,r as ue,s as de,t as fe}from"./gateway-config-api-CUt9bIpL.js";var V=e(t(),1),H=n(),U={critical:3,warn:2,info:1};function pe(){return p(`/api/doctor?security=true`)}function W(e){return e.toSorted((e,t)=>U[t.severity]-U[e.severity]||e.checkId.localeCompare(t.checkId))}function G(e){let t=e?.checks?.find(e=>e.id===`security-audit`);if(!t)return{status:`skip`,message:`Security audit unavailable.`,hints:[],findings:[]};let n=W((t.findings??[]).filter(e=>typeof e.checkId==`string`&&(e.severity===`critical`||e.severity===`warn`||e.severity===`info`)&&typeof e.title==`string`&&typeof e.detail==`string`));return{status:t.status,message:t.message,hints:Array.isArray(t.hints)?t.hints.filter(e=>typeof e==`string`):[],findings:n}}async function K(){return G(await m(pe()))}var q=r();function me(e){let t=(0,H.c)(39),{enabled:n,refreshToken:r}=e,i=r===void 0?0:r,a=f(Y),o;t[0]===a?o=t[1]:(o=u(a),t[0]=a,t[1]=o);let c=o.gatewaySettings,d;t[2]!==n||t[3]!==i?(d=n?[pe(),i]:null,t[2]=n,t[3]=i,t[4]=d):d=t[4];let p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p={revalidateOnFocus:!1},t[5]=p):p=t[5];let{data:m,error:_,isLoading:v,isValidating:y,mutate:b}=h(d,J,p),x=m??null,S=_ instanceof Error?_.message:_?String(_):null,C=v||y,T;t[6]===b?T=t[7]:(T=()=>{b(),g(pe())},t[6]=b,t[7]=T);let E=T,D=!n||C,O;t[8]===C?O=t[9]:(O=C?(0,q.jsx)(s,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,q.jsx)(I,{className:`size-3.5`,"aria-hidden":!0}),t[8]=C,t[9]=O);let k;t[10]===c.securityAuditRefresh?k=t[11]:(k=(0,q.jsx)(`span`,{className:`ml-1.5`,children:c.securityAuditRefresh}),t[10]=c.securityAuditRefresh,t[11]=k);let j;t[12]!==E||t[13]!==D||t[14]!==O||t[15]!==k?(j=(0,q.jsxs)(l,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:D,onClick:E,children:[O,k]}),t[12]=E,t[13]=D,t[14]=O,t[15]=k,t[16]=j):j=t[16];let M;t[17]!==c.securityAuditSubtitle||t[18]!==c.securityAuditTitle||t[19]!==j?(M=(0,q.jsx)(z,{icon:w,title:c.securityAuditTitle,subtitle:c.securityAuditSubtitle,trailing:j}),t[17]=c.securityAuditSubtitle,t[18]=c.securityAuditTitle,t[19]=j,t[20]=M):M=t[20];let N;t[21]===c.securityAuditSavedConfigHint?N=t[22]:(N=(0,q.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:c.securityAuditSavedConfigHint}),t[21]=c.securityAuditSavedConfigHint,t[22]=N);let P;t[23]!==S||t[24]!==c.securityAuditLoadError?(P=S?(0,q.jsxs)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,role:`alert`,children:[c.securityAuditLoadError,`: `,S]}):null,t[23]=S,t[24]=c.securityAuditLoadError,t[25]=P):P=t[25];let F;t[26]!==x||t[27]!==S||t[28]!==C?(F=!S&&C&&!x?(0,q.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,q.jsx)(A,{className:`h-11 w-full rounded-lg`}),(0,q.jsx)(A,{className:`h-10 w-full rounded-lg`})]}):null,t[26]=x,t[27]=S,t[28]=C,t[29]=F):F=t[29];let L;t[30]!==x||t[31]!==c?(L=x?(0,q.jsx)(he,{g:c,audit:x}):null,t[30]=x,t[31]=c,t[32]=L):L=t[32];let R;return t[33]!==M||t[34]!==N||t[35]!==P||t[36]!==F||t[37]!==L?(R=(0,q.jsxs)(B,{children:[M,N,P,F,L]}),t[33]=M,t[34]=N,t[35]=P,t[36]=F,t[37]=L,t[38]=R):R=t[38],R}function J(){return K()}function Y(e){return e.language}function he(e){let t=(0,H.c)(40),{g:n,audit:r}=e,i,a,o,s,l,u,d;t[0]!==r.findings||t[1]!==r.status||t[2]!==n?(a=ve(n,r.status,r.findings),d=`space-y-4`,l=c(`rounded-lg border px-3 py-2.5 text-sm`,a.bannerClass),u=`status`,s=`flex items-start gap-2`,i=a.icon,o=c(`mt-0.5 size-4 shrink-0`,a.iconClass),t[0]=r.findings,t[1]=r.status,t[2]=n,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=l,t[8]=u,t[9]=d):(i=t[3],a=t[4],o=t[5],s=t[6],l=t[7],u=t[8],d=t[9]);let f;t[10]!==i||t[11]!==o?(f=(0,q.jsx)(i,{className:o,"aria-hidden":!0}),t[10]=i,t[11]=o,t[12]=f):f=t[12];let p;t[13]===a.title?p=t[14]:(p=(0,q.jsx)(`p`,{className:`font-medium`,children:a.title}),t[13]=a.title,t[14]=p);let m;t[15]===r.message?m=t[16]:(m=(0,q.jsx)(`p`,{className:`mt-0.5 text-xs opacity-90`,children:r.message}),t[15]=r.message,t[16]=m);let h;t[17]!==p||t[18]!==m?(h=(0,q.jsxs)(`div`,{children:[p,m]}),t[17]=p,t[18]=m,t[19]=h):h=t[19];let g;t[20]!==s||t[21]!==f||t[22]!==h?(g=(0,q.jsxs)(`div`,{className:s,children:[f,h]}),t[20]=s,t[21]=f,t[22]=h,t[23]=g):g=t[23];let _;t[24]!==g||t[25]!==l||t[26]!==u?(_=(0,q.jsx)(`div`,{className:l,role:u,children:g}),t[24]=g,t[25]=l,t[26]=u,t[27]=_):_=t[27];let v;t[28]!==r.findings||t[29]!==r.status||t[30]!==n?(v=r.findings.length>0?(0,q.jsx)(`ul`,{className:`space-y-2`,children:r.findings.map(e=>(0,q.jsx)(_e,{g:n,finding:e},e.checkId))}):r.status===`pass`||r.status===`skip`?(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.securityAuditNoFindings}):null,t[28]=r.findings,t[29]=r.status,t[30]=n,t[31]=v):v=t[31];let y;t[32]!==r.hints||t[33]!==n?(y=r.hints.length>0?(0,q.jsxs)(`div`,{className:`space-y-1 rounded-lg bg-surface-panel/50 px-3 py-2.5`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:n.securityAuditHintsTitle}),(0,q.jsx)(`ul`,{className:`space-y-1 text-xs text-fg-subtle`,children:r.hints.map(ge)})]}):null,t[32]=r.hints,t[33]=n,t[34]=y):y=t[34];let b;return t[35]!==_||t[36]!==v||t[37]!==y||t[38]!==d?(b=(0,q.jsxs)(`div`,{className:d,children:[_,v,y]}),t[35]=_,t[36]=v,t[37]=y,t[38]=d,t[39]=b):b=t[39],b}function ge(e){return(0,q.jsx)(`li`,{className:`font-mono`,children:e},e)}function _e(e){let t=(0,H.c)(31),{g:n,finding:r}=e,i,a,o,s;if(t[0]!==r.severity){let e=X(r.severity);s=`rounded-lg bg-surface-panel/70 px-3 py-2.5 shadow-surface`,o=`flex items-start gap-2`,i=e.icon,a=c(`mt-0.5 size-4 shrink-0`,e.iconClass),t[0]=r.severity,t[1]=i,t[2]=a,t[3]=o,t[4]=s}else i=t[1],a=t[2],o=t[3],s=t[4];let l;t[5]!==i||t[6]!==a?(l=(0,q.jsx)(i,{className:a,"aria-hidden":!0}),t[5]=i,t[6]=a,t[7]=l):l=t[7];let u;t[8]===r.title?u=t[9]:(u=(0,q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.title}),t[8]=r.title,t[9]=u);let d;t[10]===r.checkId?d=t[11]:(d=(0,q.jsx)(`span`,{className:`font-mono text-[0.65rem] text-fg-subtle`,children:r.checkId}),t[10]=r.checkId,t[11]=d);let f;t[12]!==u||t[13]!==d?(f=(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[u,d]}),t[12]=u,t[13]=d,t[14]=f):f=t[14];let p;t[15]===r.detail?p=t[16]:(p=(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.detail}),t[15]=r.detail,t[16]=p);let m;t[17]!==r.remediation||t[18]!==n?(m=r.remediation?(0,q.jsxs)(`p`,{className:`mt-1.5 text-xs text-fg-subtle`,children:[(0,q.jsx)(`span`,{className:`text-fg-muted`,children:n.securityAuditRemediation}),` `,r.remediation]}):null,t[17]=r.remediation,t[18]=n,t[19]=m):m=t[19];let h;t[20]!==f||t[21]!==p||t[22]!==m?(h=(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[f,p,m]}),t[20]=f,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g;t[24]!==h||t[25]!==o||t[26]!==l?(g=(0,q.jsxs)(`div`,{className:o,children:[l,h]}),t[24]=h,t[25]=o,t[26]=l,t[27]=g):g=t[27];let _;return t[28]!==g||t[29]!==s?(_=(0,q.jsx)(`li`,{className:s,children:g}),t[28]=g,t[29]=s,t[30]=_):_=t[30],_}function X(e){switch(e){case`critical`:return{icon:E,iconClass:`text-red-600 dark:text-red-400`};case`warn`:return{icon:N,iconClass:`text-amber-600 dark:text-amber-400`};default:return{icon:O,iconClass:`text-fg-muted`}}}function ve(e,t,n){let r=n.filter(e=>e.severity===`critical`).length,i=n.filter(e=>e.severity===`warn`).length;return t===`fail`||r>0?{icon:E,iconClass:`text-red-600 dark:text-red-400`,title:e.securityAuditStatusFail,bannerClass:`border-red-200 bg-red-50 text-red-950 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-100`}:t===`warn`||i>0?{icon:N,iconClass:`text-amber-600 dark:text-amber-400`,title:e.securityAuditStatusWarn,bannerClass:`border-amber-200 bg-amber-50 text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`}:t===`skip`?{icon:O,iconClass:`text-fg-muted`,title:e.securityAuditStatusSkip,bannerClass:`border-edge bg-surface-panel/60 text-fg`}:{icon:w,iconClass:`text-emerald-600 dark:text-emerald-400`,title:e.securityAuditStatusPass,bannerClass:`border-emerald-200 bg-emerald-50 text-emerald-950 dark:border-emerald-900/50 dark:bg-emerald-950/40 dark:text-emerald-100`}}function Z(){return c(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,L,`dark:border-edge`)}var ye=[`network`,`access`,`updates`,`security`,`advanced`],be={network:P,access:S,updates:I,security:b,advanced:D};function xe(e){return e&&ye.includes(e)?e:`network`}function Q(e,t){return t===`network`?e.tabNetwork:t===`access`?e.tabAccess:t===`updates`?e.tabUpdates:t===`security`?e.tabSecurity:e.tabAdvanced}function Se(e,t){return t===`network`?e.networkTabHint:t===`access`?e.accessTabHint:t===`updates`?e.updatesTabHint:t===`security`?e.securitySectionHint:e.advancedSectionHint}function Ce(e,t){switch(t.type){case`reset`:return{form:null,baseline:null,appliedBaseline:null};case`init-applied`:return{...e,appliedBaseline:structuredClone(t.value)};case`sync`:{let n=structuredClone(t.value);return{form:n,baseline:structuredClone(n),appliedBaseline:e.appliedBaseline}}case`set-form`:return e.form?{...e,form:t.updater(e.form)}:e;case`discard`:return e.baseline?{...e,form:structuredClone(e.baseline)}:e;case`saved`:{let n=structuredClone(t.value);return{form:n,baseline:structuredClone(n),appliedBaseline:e.appliedBaseline}}}}var we={saving:!1,error:null,saveOk:!1,auditRefreshToken:0,restarting:!1,restartConfirmOpen:!1};function Te(){let e=f(e=>e.language),t=u(e),n=t.gatewaySettings,[r,p]=i(),m=M(e=>e.mode),g=m===`advanced`,b=xe(r.get(`tab`)),S=(0,V.useMemo)(()=>ae(ye,m),[m]),w=(0,V.useCallback)(e=>{p(t=>{let n=new URLSearchParams(t);return e===`network`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[p]);se(b,w);let D=d(e=>e.token),O=d(e=>e.tokenExpired),A=d(e=>e.openTokenDialog),j=!!D,[N,P]=(0,V.useReducer)(Ce,{form:null,baseline:null,appliedBaseline:null}),F=N.form,I=N.baseline,L=N.appliedBaseline,[te,z]=(0,V.useReducer)(v,we),{saving:B,error:ie,auditRefreshToken:H,restarting:U,restartConfirmOpen:pe}=te,W=(0,V.useRef)(!1),G=(0,V.useRef)(null),K=(0,V.useRef)(!1),{data:J,error:Y,isLoading:he,mutate:ge}=_(j),_e=h(j&&F?[`gateway-cors-origin-candidates`,F.port]:null,([,e])=>fe(e),{revalidateOnFocus:!1}),X=(0,V.useMemo)(()=>J?.payload?.config===void 0?null:structuredClone(ue(J.payload.config)),[J]);j?X!==null&&(K.current||(K.current=!0,P({type:`init-applied`,value:X})),!W.current&&G.current!==X&&(G.current=X,P({type:`sync`,value:X}),z({type:`patch`,patch:{saveOk:!1}}))):(G.current!==null||K.current)&&(G.current=null,K.current=!1,P({type:`reset`}),W.current=!1);let ve=!!(j&&he&&J===void 0&&!Y),be=Y instanceof Error?Y.message:Y?String(Y):null,Q=(0,V.useMemo)(()=>!F||!I?!1:JSON.stringify(F)!==JSON.stringify(I),[F,I]),Se=(0,V.useMemo)(()=>!I||!L?!1:ce(L,I),[L,I]),Te=(0,V.useCallback)(e=>{W.current=!0,P({type:`set-form`,updater:t=>({...t,auth:{...t.auth,...e}})})},[]),$=(0,V.useCallback)(e=>{W.current=!0,P({type:`set-form`,updater:t=>({...t,updateChannel:e})})},[]),Me=(0,V.useCallback)(e=>{W.current=!0,P({type:`set-form`,updater:t=>({...t,corsOrigins:e})})},[]),Ne=(0,V.useCallback)(e=>{W.current=!0,P({type:`set-form`,updater:t=>({...t,bind:e})})},[]),Ie=(0,V.useCallback)(e=>{W.current=!0,P({type:`set-form`,updater:t=>({...t,customBindHost:e,bind:`custom`})})},[]),Le=(0,V.useCallback)(e=>{W.current=!0,P({type:`set-form`,updater:t=>({...t,port:e})})},[]),Re=(0,V.useCallback)(e=>{W.current=!0,P({type:`set-form`,updater:t=>({...t,auth:{...t.auth,rateLimit:{...t.auth.rateLimit,...e}}})})},[]),ze=(0,V.useCallback)(e=>{W.current=!0,P({type:`set-form`,updater:t=>({...t,channelConnectDeferMode:e})})},[]),Be=(0,V.useCallback)(e=>{W.current=!0,P({type:`set-form`,updater:t=>({...t,channelConnectDeferIds:e})})},[]),Ve=(0,V.useCallback)(e=>{W.current=!0,P({type:`set-form`,updater:t=>({...t,channelConnectDeferSkipIds:e})})},[]),He=(0,V.useCallback)(e=>{W.current=!0,P({type:`set-form`,updater:t=>({...t,trustedProxies:e})})},[]),Ue=(0,V.useCallback)(e=>{W.current=!0,P({type:`set-form`,updater:t=>({...t,auth:{...t.auth,trustedProxy:{...t.auth.trustedProxy,...e}}})})},[]),We=(0,V.useCallback)(e=>{W.current=!0,P({type:`set-form`,updater:t=>({...t,securityStrict:e})})},[]),Ge=(0,V.useCallback)(e=>{W.current=!0,P({type:`set-form`,updater:t=>({...t,allowRealIpFallback:e})})},[]),Ke=(0,V.useCallback)(e=>{W.current=!0,P({type:`set-form`,updater:t=>({...t,dangerouslyAllowHostHeaderOriginFallback:e})})},[]),qe=(0,V.useCallback)(async()=>{if(!F||B)return;let e=de(F);if(e){z({type:`patch`,patch:{error:e}});return}z({type:`patch`,patch:{saving:!0,error:null,saveOk:!1}});try{await oe(F),W.current=!1,P({type:`saved`,value:F}),z({type:`patch`,patch:{saveOk:!0,auditRefreshToken:H+1}})}catch(e){z({type:`patch`,patch:{error:e instanceof Error?e.message:n.saveError}})}finally{z({type:`patch`,patch:{saving:!1}})}},[F,B,n.saveError]),Je=(0,V.useCallback)(()=>{I&&(W.current=!1,P({type:`discard`}),z({type:`patch`,patch:{error:null,saveOk:!1}}))},[I]),Ye=C(n),Xe=(0,V.useCallback)(async()=>{if(!U){z({type:`patch`,patch:{restarting:!0,restartConfirmOpen:!1}});try{let e=await k();e.ok?window.dispatchEvent(new Event(`gateway-restart-initiated`)):z({type:`patch`,patch:{error:e.message||n.restartGatewayFailed}})}catch(e){z({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{z({type:`patch`,patch:{restarting:!1}})}}},[U,n.restartGatewayFailed]);return j?ve?(0,q.jsx)(ee,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,q.jsx)(ne,{sections:3})}):F?(0,q.jsxs)(ee,{gap:`gap-6`,children:[(0,q.jsx)(R,{title:t.settingsSections.gateway,subtitle:n.subtitle,docsLink:y(e,`gateway`),docsLabel:n.docsLink,actions:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(l,{type:`button`,variant:`secondary`,disabled:!Q||B,onClick:Je,children:n.discard}),(0,q.jsx)(l,{type:`button`,variant:`primary`,disabled:!Q||B,onClick:()=>void qe(),children:B?n.saving:n.save})]})}),O?(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-red-200 bg-red-50 px-4 py-3 dark:border-red-900/50 dark:bg-red-950/40`,role:`alert`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(E,{className:`mt-0.5 size-4 shrink-0 text-red-600 dark:text-red-400`}),(0,q.jsx)(`p`,{className:`text-sm text-red-900 dark:text-red-100`,children:n.tokenExpired})]}),(0,q.jsx)(`div`,{children:(0,q.jsx)(l,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:()=>A(),children:n.updateToken})})]}):null,Q?(0,q.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,ie?(0,q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:ie}):null,Se?(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 dark:border-amber-800 dark:bg-amber-950/40`,children:[(0,q.jsx)(`p`,{className:`text-xs text-amber-950 dark:text-amber-100`,children:n.restartHint}),(0,q.jsxs)(l,{type:`button`,variant:`secondary`,className:`shrink-0 gap-1.5 border-red-300 bg-red-50 text-xs text-red-700 hover:bg-red-100 dark:border-red-800 dark:bg-red-950/50 dark:text-red-300 dark:hover:bg-red-900/60`,disabled:U,onClick:()=>z({type:`patch`,patch:{restartConfirmOpen:!0}}),children:[U?(0,q.jsx)(s,{className:`size-3.5 animate-spin`}):(0,q.jsx)(x,{className:`size-3.5`}),n.restartGatewayButton]})]}):null,(0,q.jsx)(T,{open:pe,title:n.restartGatewayButton,description:n.restartGatewayConfirm,confirmLabel:n.restartGatewayButton,cancelLabel:n.discard,destructive:!0,onConfirm:()=>void Xe(),onCancel:()=>z({type:`patch`,patch:{restartConfirmOpen:!1}})}),(0,q.jsx)(Ee,{g:n,activeTab:b,visibleTabs:S,onChange:w}),(0,q.jsxs)(De,{g:n,id:`network`,activeTab:b,children:[(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-bind-mode`,children:n.bindMode}),(0,q.jsxs)(a,{id:`gateway-bind-mode`,className:Z(),value:F.bind,onChange:e=>Ne(e.target.value),children:[(0,q.jsx)(o,{value:`loopback`,children:n.bindLoopback}),g?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(o,{value:`lan`,children:n.bindLan}),(0,q.jsx)(o,{value:`auto`,children:n.bindAuto}),(0,q.jsx)(o,{value:`custom`,children:n.bindCustom}),(0,q.jsx)(o,{value:`tailnet`,children:n.bindTailnet})]}):null]})]}),F.bind===`custom`?(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-custom-bind-host`,children:n.customBindHost}),(0,q.jsx)(`input`,{id:`gateway-custom-bind-host`,className:c(Z(),`font-mono text-xs`),value:F.customBindHost,onChange:e=>Ie(e.target.value),placeholder:n.customBindHostPlaceholder,autoComplete:`off`})]}):null,(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-listen-port`,children:n.listenPort}),(0,q.jsx)(`input`,{id:`gateway-listen-port`,type:`number`,min:1,max:65535,className:c(Z(),`font-mono text-xs`),value:F.port,onChange:e=>{let t=Number(e.target.value);Le(Number.isFinite(t)?Math.max(1,Math.min(65535,Math.floor(t))):F.port)}})]}),(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:n.listenHint})]}),(0,q.jsx)(re,{children:(0,q.jsx)(je,{g:n,origins:F.corsOrigins,candidates:_e.data??[],onChange:Me})})]}),(0,q.jsxs)(De,{g:n,id:`access`,activeTab:b,children:[F.auth.mode===`none`?(0,q.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:n.authModeNone}):null,(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-auth-mode`,children:n.authMode}),(0,q.jsxs)(a,{id:`gateway-auth-mode`,value:F.auth.mode,onChange:e=>Te({mode:e.target.value}),className:Z(),children:[(0,q.jsx)(o,{value:`token`,children:n.authModeToken}),(0,q.jsx)(o,{value:`password`,children:n.authModePassword}),g?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(o,{value:`trusted-proxy`,children:n.authModeTrustedProxy}),(0,q.jsx)(o,{value:`none`,children:n.authModeNoneLabel})]}):null]})]}),(0,q.jsx)(re,{children:F.auth.mode===`trusted-proxy`?(0,q.jsx)(ke,{g:n,form:F,onTrustedProxyChange:Ue,onTrustedProxiesChange:He,onAllowRealIpFallbackChange:Ge}):null}),F.auth.mode===`token`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Fe,{id:`gateway-access-token`,label:n.accessToken,help:n.tokenHelp,placeholder:n.tokenPlaceholder,value:F.auth.token,labels:Ye,reveal:()=>le(`token`).then(e=>e.secret),loadFailedLabel:n.saveError,onChange:e=>Te({token:e})}),(0,q.jsx)(l,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:()=>A(),children:n.changeToken})]}):null,F.auth.mode===`password`?(0,q.jsx)(Fe,{id:`gateway-auth-password`,label:n.authPassword,help:n.authPasswordHelp,placeholder:n.authPasswordPlaceholder,value:F.auth.password,labels:Ye,reveal:()=>le(`password`).then(e=>e.secret),loadFailedLabel:n.saveError,onChange:e=>Te({password:e})}):null,(0,q.jsx)(re,{children:F.auth.mode===`none`?null:(0,q.jsx)(Pe,{g:n,rateLimit:F.auth.rateLimit,onChange:Re})})]}),(0,q.jsxs)(De,{g:n,id:`updates`,activeTab:b,children:[(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-update-channel`,children:n.updateChannel}),(0,q.jsxs)(a,{id:`gateway-update-channel`,value:F.updateChannel,onChange:e=>$(e.target.value),className:Z(),children:[(0,q.jsx)(o,{value:`stable`,children:n.channelStable}),(0,q.jsx)(o,{value:`beta`,children:n.channelBeta}),(0,q.jsx)(o,{value:`dev`,children:n.channelDev})]}),(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.updateChannelHint})]}),(0,q.jsxs)(`div`,{className:`space-y-4 border-t border-edge pt-4`,children:[(0,q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.updateAutoSection}),(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.updateAutoSectionHint}),(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:F.updateCheckOnStart,onChange:e=>{W.current=!0,P({type:`set-form`,updater:t=>({...t,updateCheckOnStart:e.target.checked})})}}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`span`,{className:`font-medium`,children:n.updateCheckOnStart}),(0,q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.updateCheckOnStartHint})]})]}),(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:F.updateAutoEnabled,onChange:e=>{W.current=!0,P({type:`set-form`,updater:t=>({...t,updateAutoEnabled:e.target.checked})})}}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`span`,{className:`font-medium`,children:n.updateAutoEnabled}),(0,q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.updateAutoEnabledHint})]})]}),(0,q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-delay`,children:n.updateAutoStableDelayHours}),(0,q.jsx)(`input`,{id:`update-auto-stable-delay`,type:`number`,min:0,disabled:!F.updateAutoEnabled,className:Z(),value:F.updateAutoStableDelayHours,onChange:e=>{W.current=!0,P({type:`set-form`,updater:t=>({...t,updateAutoStableDelayHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoStableDelayHoursHint})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-jitter`,children:n.updateAutoStableJitterHours}),(0,q.jsx)(`input`,{id:`update-auto-stable-jitter`,type:`number`,min:0,disabled:!F.updateAutoEnabled,className:Z(),value:F.updateAutoStableJitterHours,onChange:e=>{W.current=!0,P({type:`set-form`,updater:t=>({...t,updateAutoStableJitterHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoStableJitterHoursHint})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-beta-interval`,children:n.updateAutoBetaCheckIntervalHours}),(0,q.jsx)(`input`,{id:`update-auto-beta-interval`,type:`number`,min:.25,step:.25,disabled:!F.updateAutoEnabled,className:Z(),value:F.updateAutoBetaCheckIntervalHours,onChange:e=>{W.current=!0,P({type:`set-form`,updater:t=>({...t,updateAutoBetaCheckIntervalHours:Math.max(.25,Number(e.target.value)||1)})})}}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoBetaCheckIntervalHoursHint})]})]})]})]}),(0,q.jsxs)(De,{g:n,id:`security`,activeTab:b,children:[(0,q.jsx)(me,{enabled:j,refreshToken:H}),(0,q.jsx)(Oe,{g:n,form:F,onSecurityStrictChange:We,onDangerouslyAllowHostHeaderOriginFallbackChange:Ke})]}),(0,q.jsx)(De,{g:n,id:`advanced`,activeTab:b,children:(0,q.jsx)(Ae,{g:n,form:F,onDeferModeChange:ze,onDeferIdsChange:Be,onSkipIdsChange:Ve})})]}):(0,q.jsxs)(ee,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:ie??be??n.loadError}),(0,q.jsx)(l,{type:`button`,variant:`secondary`,onClick:()=>void ge(),children:n.retry})]}):(0,q.jsxs)(ee,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,q.jsx)(R,{title:t.settingsSections.gateway}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]})}function Ee(e){let t=(0,H.c)(10),{g:n,activeTab:r,visibleTabs:i,onChange:a}=e,o;if(t[0]!==n||t[1]!==i){let e;t[3]===n?e=t[4]:(e=e=>({id:e,label:Q(n,e),icon:be[e]}),t[3]=n,t[4]=e),o=i.map(e),t[0]=n,t[1]=i,t[2]=o}else o=t[2];let s=o,c;return t[5]!==r||t[6]!==n.tabsAriaLabel||t[7]!==s||t[8]!==a?(c=(0,q.jsx)(ie,{items:s,activeTab:r,onChange:a,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`gateway-settings-tab`,panelIdPrefix:`gateway-settings-panel`}),t[5]=r,t[6]=n.tabsAriaLabel,t[7]=s,t[8]=a,t[9]=c):c=t[9],c}function De(e){let t=(0,H.c)(14),{g:n,id:r,activeTab:i,children:a}=e,o;t[0]!==n||t[1]!==r?(o=Q(n,r),t[0]=n,t[1]=r,t[2]=o):o=t[2];let s;t[3]!==n||t[4]!==r?(s=Se(n,r),t[3]=n,t[4]=r,t[5]=s):s=t[5];let c;t[6]===a?c=t[7]:(c=(0,q.jsx)(`div`,{className:`space-y-4`,children:a}),t[6]=a,t[7]=c);let l;return t[8]!==i||t[9]!==r||t[10]!==o||t[11]!==s||t[12]!==c?(l=(0,q.jsx)(te,{id:r,activeTab:i,tabIdPrefix:`gateway-settings-tab`,panelIdPrefix:`gateway-settings-panel`,title:o,hint:s,children:c}),t[8]=i,t[9]=r,t[10]=o,t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function Oe(e){let t=(0,H.c)(37),{g:n,form:r,onSecurityStrictChange:i,onDangerouslyAllowHostHeaderOriginFallbackChange:a}=e,o;t[0]===i?o=t[1]:(o=e=>i(e.target.checked),t[0]=i,t[1]=o);let s;t[2]!==r.securityStrict||t[3]!==o?(s=(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.securityStrict,onChange:o}),t[2]=r.securityStrict,t[3]=o,t[4]=s):s=t[4];let c;t[5]===n.securityStrict?c=t[6]:(c=(0,q.jsx)(`span`,{className:`font-medium`,children:n.securityStrict}),t[5]=n.securityStrict,t[6]=c);let l;t[7]===n.securityStrictHint?l=t[8]:(l=(0,q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.securityStrictHint}),t[7]=n.securityStrictHint,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,q.jsxs)(`span`,{children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;t[12]!==s||t[13]!==u?(d=(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[s,u]}),t[12]=s,t[13]=u,t[14]=d):d=t[14];let f;t[15]===a?f=t[16]:(f=e=>a(e.target.checked),t[15]=a,t[16]=f);let p;t[17]!==r.dangerouslyAllowHostHeaderOriginFallback||t[18]!==f?(p=(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.dangerouslyAllowHostHeaderOriginFallback,onChange:f}),t[17]=r.dangerouslyAllowHostHeaderOriginFallback,t[18]=f,t[19]=p):p=t[19];let m;t[20]===n.dangerouslyAllowHostHeaderOriginFallback?m=t[21]:(m=(0,q.jsx)(`span`,{className:`font-medium`,children:n.dangerouslyAllowHostHeaderOriginFallback}),t[20]=n.dangerouslyAllowHostHeaderOriginFallback,t[21]=m);let h;t[22]===n.dangerouslyAllowHostHeaderOriginFallbackHint?h=t[23]:(h=(0,q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.dangerouslyAllowHostHeaderOriginFallbackHint}),t[22]=n.dangerouslyAllowHostHeaderOriginFallbackHint,t[23]=h);let g;t[24]!==h||t[25]!==m?(g=(0,q.jsxs)(`span`,{children:[m,h]}),t[24]=h,t[25]=m,t[26]=g):g=t[26];let _;t[27]!==g||t[28]!==p?(_=(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[p,g]}),t[27]=g,t[28]=p,t[29]=_):_=t[29];let v;t[30]!==r.dangerouslyAllowHostHeaderOriginFallback||t[31]!==n.dangerouslyAllowHostHeaderOriginFallbackWarning?(v=r.dangerouslyAllowHostHeaderOriginFallback?(0,q.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:n.dangerouslyAllowHostHeaderOriginFallbackWarning}):null,t[30]=r.dangerouslyAllowHostHeaderOriginFallback,t[31]=n.dangerouslyAllowHostHeaderOriginFallbackWarning,t[32]=v):v=t[32];let y;return t[33]!==_||t[34]!==v||t[35]!==d?(y=(0,q.jsxs)(`div`,{className:`space-y-4`,children:[d,_,v]}),t[33]=_,t[34]=v,t[35]=d,t[36]=y):y=t[36],y}function ke(e){let t=(0,H.c)(80),{g:n,form:r,onTrustedProxyChange:i,onTrustedProxiesChange:a,onAllowRealIpFallbackChange:o}=e,s=r.auth.trustedProxy,l;t[0]===n.authModeTrustedProxyHint?l=t[1]:(l=(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.authModeTrustedProxyHint}),t[0]=n.authModeTrustedProxyHint,t[1]=l);let u;t[2]===n.trustedProxyUserHeader?u=t[3]:(u=(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-trusted-proxy-user-header`,children:n.trustedProxyUserHeader}),t[2]=n.trustedProxyUserHeader,t[3]=u);let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=c(Z(),`font-mono text-xs`),t[4]=d):d=t[4];let f;t[5]===i?f=t[6]:(f=e=>i({userHeader:e.target.value}),t[5]=i,t[6]=f);let p;t[7]!==n.trustedProxyUserHeaderPlaceholder||t[8]!==f||t[9]!==s.userHeader?(p=(0,q.jsx)(`input`,{id:`gateway-trusted-proxy-user-header`,className:d,value:s.userHeader,onChange:f,placeholder:n.trustedProxyUserHeaderPlaceholder,autoComplete:`off`}),t[7]=n.trustedProxyUserHeaderPlaceholder,t[8]=f,t[9]=s.userHeader,t[10]=p):p=t[10];let m;t[11]===n.trustedProxyUserHeaderHint?m=t[12]:(m=(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.trustedProxyUserHeaderHint}),t[11]=n.trustedProxyUserHeaderHint,t[12]=m);let h;t[13]!==u||t[14]!==p||t[15]!==m?(h=(0,q.jsxs)(`div`,{children:[u,p,m]}),t[13]=u,t[14]=p,t[15]=m,t[16]=h):h=t[16];let g;t[17]===i?g=t[18]:(g=e=>i({requiredHeaders:e}),t[17]=i,t[18]=g);let _;t[19]!==n.channelIdListEmpty||t[20]!==n.trustedProxyRequiredHeaders||t[21]!==n.trustedProxyRequiredHeadersHint||t[22]!==n.trustedProxyUserHeaderPlaceholder||t[23]!==g||t[24]!==s.requiredHeaders?(_=(0,q.jsx)($,{title:n.trustedProxyRequiredHeaders,hint:n.trustedProxyRequiredHeadersHint,emptyText:n.channelIdListEmpty,placeholder:n.trustedProxyUserHeaderPlaceholder,values:s.requiredHeaders,maxItems:32,onChange:g}),t[19]=n.channelIdListEmpty,t[20]=n.trustedProxyRequiredHeaders,t[21]=n.trustedProxyRequiredHeadersHint,t[22]=n.trustedProxyUserHeaderPlaceholder,t[23]=g,t[24]=s.requiredHeaders,t[25]=_):_=t[25];let v;t[26]===i?v=t[27]:(v=e=>i({allowUsers:e}),t[26]=i,t[27]=v);let y;t[28]!==n.channelIdListEmpty||t[29]!==n.trustedProxyAllowUsers||t[30]!==n.trustedProxyAllowUsersHint||t[31]!==n.trustedProxyUserHeaderPlaceholder||t[32]!==v||t[33]!==s.allowUsers?(y=(0,q.jsx)($,{title:n.trustedProxyAllowUsers,hint:n.trustedProxyAllowUsersHint,emptyText:n.channelIdListEmpty,placeholder:n.trustedProxyUserHeaderPlaceholder,values:s.allowUsers,maxItems:128,onChange:v}),t[28]=n.channelIdListEmpty,t[29]=n.trustedProxyAllowUsers,t[30]=n.trustedProxyAllowUsersHint,t[31]=n.trustedProxyUserHeaderPlaceholder,t[32]=v,t[33]=s.allowUsers,t[34]=y):y=t[34];let b;t[35]===i?b=t[36]:(b=e=>i({allowLoopback:e.target.checked}),t[35]=i,t[36]=b);let x;t[37]!==b||t[38]!==s.allowLoopback?(x=(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:s.allowLoopback,onChange:b}),t[37]=b,t[38]=s.allowLoopback,t[39]=x):x=t[39];let S;t[40]===n.trustedProxyAllowLoopback?S=t[41]:(S=(0,q.jsx)(`span`,{className:`font-medium`,children:n.trustedProxyAllowLoopback}),t[40]=n.trustedProxyAllowLoopback,t[41]=S);let C;t[42]===n.trustedProxyAllowLoopbackHint?C=t[43]:(C=(0,q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.trustedProxyAllowLoopbackHint}),t[42]=n.trustedProxyAllowLoopbackHint,t[43]=C);let w;t[44]!==S||t[45]!==C?(w=(0,q.jsxs)(`span`,{children:[S,C]}),t[44]=S,t[45]=C,t[46]=w):w=t[46];let T;t[47]!==x||t[48]!==w?(T=(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[x,w]}),t[47]=x,t[48]=w,t[49]=T):T=t[49];let E;t[50]!==r.trustedProxies||t[51]!==n.trustedProxies||t[52]!==n.trustedProxiesEmpty||t[53]!==n.trustedProxiesHint||t[54]!==n.trustedProxiesPlaceholder||t[55]!==a?(E=(0,q.jsx)($,{title:n.trustedProxies,hint:n.trustedProxiesHint,emptyText:n.trustedProxiesEmpty,placeholder:n.trustedProxiesPlaceholder,values:r.trustedProxies,maxItems:64,onChange:a}),t[50]=r.trustedProxies,t[51]=n.trustedProxies,t[52]=n.trustedProxiesEmpty,t[53]=n.trustedProxiesHint,t[54]=n.trustedProxiesPlaceholder,t[55]=a,t[56]=E):E=t[56];let D;t[57]===o?D=t[58]:(D=e=>o(e.target.checked),t[57]=o,t[58]=D);let O;t[59]!==r.allowRealIpFallback||t[60]!==D?(O=(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.allowRealIpFallback,onChange:D}),t[59]=r.allowRealIpFallback,t[60]=D,t[61]=O):O=t[61];let k;t[62]===n.allowRealIpFallback?k=t[63]:(k=(0,q.jsx)(`span`,{className:`font-medium`,children:n.allowRealIpFallback}),t[62]=n.allowRealIpFallback,t[63]=k);let A;t[64]===n.allowRealIpFallbackHint?A=t[65]:(A=(0,q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.allowRealIpFallbackHint}),t[64]=n.allowRealIpFallbackHint,t[65]=A);let j;t[66]!==k||t[67]!==A?(j=(0,q.jsxs)(`span`,{children:[k,A]}),t[66]=k,t[67]=A,t[68]=j):j=t[68];let M;t[69]!==O||t[70]!==j?(M=(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[O,j]}),t[69]=O,t[70]=j,t[71]=M):M=t[71];let N;return t[72]!==l||t[73]!==y||t[74]!==T||t[75]!==E||t[76]!==M||t[77]!==h||t[78]!==_?(N=(0,q.jsxs)(`div`,{className:`space-y-4 border-t border-edge pt-4`,children:[l,h,_,y,T,E,M]}),t[72]=l,t[73]=y,t[74]=T,t[75]=E,t[76]=M,t[77]=h,t[78]=_,t[79]=N):N=t[79],N}function Ae(e){let t=(0,H.c)(43),{g:n,form:r,onDeferModeChange:i,onDeferIdsChange:s,onSkipIdsChange:c}=e,l;t[0]===n.channelConnectDeferMode?l=t[1]:(l=(0,q.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-channel-defer-mode`,children:n.channelConnectDeferMode}),t[0]=n.channelConnectDeferMode,t[1]=l);let u=r.channelConnectDeferMode,d;t[2]===i?d=t[3]:(d=e=>i(e.target.value),t[2]=i,t[3]=d);let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=Z(),t[4]=f):f=t[4];let p;t[5]===n.channelConnectDeferModeAuto?p=t[6]:(p=(0,q.jsx)(o,{value:`auto`,children:n.channelConnectDeferModeAuto}),t[5]=n.channelConnectDeferModeAuto,t[6]=p);let m;t[7]===n.channelConnectDeferModeOff?m=t[8]:(m=(0,q.jsx)(o,{value:`off`,children:n.channelConnectDeferModeOff}),t[7]=n.channelConnectDeferModeOff,t[8]=m);let h;t[9]===n.channelConnectDeferModeExplicit?h=t[10]:(h=(0,q.jsx)(o,{value:`explicit`,children:n.channelConnectDeferModeExplicit}),t[9]=n.channelConnectDeferModeExplicit,t[10]=h);let g;t[11]!==r.channelConnectDeferMode||t[12]!==d||t[13]!==p||t[14]!==m||t[15]!==h?(g=(0,q.jsxs)(a,{id:`gateway-channel-defer-mode`,value:u,onChange:d,className:f,children:[p,m,h]}),t[11]=r.channelConnectDeferMode,t[12]=d,t[13]=p,t[14]=m,t[15]=h,t[16]=g):g=t[16];let _;t[17]===n.channelConnectDeferModeHint?_=t[18]:(_=(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.channelConnectDeferModeHint}),t[17]=n.channelConnectDeferModeHint,t[18]=_);let v;t[19]!==l||t[20]!==g||t[21]!==_?(v=(0,q.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-4`,children:[l,g,_]}),t[19]=l,t[20]=g,t[21]=_,t[22]=v):v=t[22];let y;t[23]!==r.channelConnectDeferIds||t[24]!==r.channelConnectDeferMode||t[25]!==n.channelConnectDeferIds||t[26]!==n.channelConnectDeferIdsHint||t[27]!==n.channelIdListEmpty||t[28]!==n.channelIdListPlaceholder||t[29]!==s?(y=r.channelConnectDeferMode===`explicit`?(0,q.jsx)($,{title:n.channelConnectDeferIds,hint:n.channelConnectDeferIdsHint,emptyText:n.channelIdListEmpty,placeholder:n.channelIdListPlaceholder,values:r.channelConnectDeferIds,maxItems:24,onChange:s}):null,t[23]=r.channelConnectDeferIds,t[24]=r.channelConnectDeferMode,t[25]=n.channelConnectDeferIds,t[26]=n.channelConnectDeferIdsHint,t[27]=n.channelIdListEmpty,t[28]=n.channelIdListPlaceholder,t[29]=s,t[30]=y):y=t[30];let b;t[31]!==r.channelConnectDeferMode||t[32]!==r.channelConnectDeferSkipIds||t[33]!==n.channelConnectDeferSkipIds||t[34]!==n.channelConnectDeferSkipIdsHint||t[35]!==n.channelIdListEmpty||t[36]!==n.channelIdListPlaceholder||t[37]!==c?(b=r.channelConnectDeferMode===`off`?null:(0,q.jsx)($,{title:n.channelConnectDeferSkipIds,hint:n.channelConnectDeferSkipIdsHint,emptyText:n.channelIdListEmpty,placeholder:n.channelIdListPlaceholder,values:r.channelConnectDeferSkipIds,maxItems:24,onChange:c}),t[31]=r.channelConnectDeferMode,t[32]=r.channelConnectDeferSkipIds,t[33]=n.channelConnectDeferSkipIds,t[34]=n.channelConnectDeferSkipIdsHint,t[35]=n.channelIdListEmpty,t[36]=n.channelIdListPlaceholder,t[37]=c,t[38]=b):b=t[38];let x;return t[39]!==v||t[40]!==y||t[41]!==b?(x=(0,q.jsxs)(`div`,{className:`space-y-4`,children:[v,y,b]}),t[39]=v,t[40]=y,t[41]=b,t[42]=x):x=t[42],x}function $(e){let t=(0,H.c)(25),{title:n,hint:r,emptyText:i,placeholder:a,values:o,maxItems:s,onChange:l,children:u}=e,d;t[0]!==s||t[1]!==l||t[2]!==o?(d=e=>{let t=e.trim();!t||o.includes(t)||o.length>=s||l([...o,t])},t[0]=s,t[1]=l,t[2]=o,t[3]=d):d=t[3];let f=d,p;t[4]===n?p=t[5]:(p=(0,q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[4]=n,t[5]=p);let m;t[6]===r?m=t[7]:(m=(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r}),t[6]=r,t[7]=m);let h;t[8]!==i||t[9]!==l||t[10]!==o?(h=o.length===0?(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i}):(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:o.map(e=>(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e,(0,q.jsx)(`button`,{type:`button`,className:c(`text-fg-muted hover:text-fg`,j.press),"aria-label":`Remove ${e}`,onClick:()=>l(o.filter(t=>t!==e)),children:`×`})]},e))}),t[8]=i,t[9]=l,t[10]=o,t[11]=h):h=t[11];let g;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(g=c(Z(),`font-mono text-xs`),t[12]=g):g=t[12];let _=o.length>=s,v;t[13]===f?v=t[14]:(v=e=>{e.key===`Enter`&&(e.preventDefault(),f(e.target.value),e.target.value=``)},t[13]=f,t[14]=v);let y;t[15]!==a||t[16]!==_||t[17]!==v?(y=(0,q.jsx)(`input`,{className:g,placeholder:a,disabled:_,onKeyDown:v}),t[15]=a,t[16]=_,t[17]=v,t[18]=y):y=t[18];let b;return t[19]!==u||t[20]!==p||t[21]!==m||t[22]!==h||t[23]!==y?(b=(0,q.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-4`,children:[p,m,h,y,u]}),t[19]=u,t[20]=p,t[21]=m,t[22]=h,t[23]=y,t[24]=b):b=t[24],b}function je(e){let t=(0,H.c)(36),{g:n,origins:r,candidates:i,onChange:a}=e,o;t[0]===r?o=t[1]:(o=r.includes(`*`),t[0]=r,t[1]=o);let s=o,c,u,d,f,p,m,h,g,_;if(t[2]!==i||t[3]!==n.corsAddDetectedOrigins||t[4]!==n.corsDetectedOrigins||t[5]!==n.corsOrigins||t[6]!==n.corsOriginsEmpty||t[7]!==n.corsOriginsHint||t[8]!==n.corsOriginsPlaceholder||t[9]!==a||t[10]!==r){let e;t[20]===r?e=t[21]:(e=e=>!r.includes(e.url),t[20]=r,t[21]=e);let o=i.filter(e);c=$,u=n.corsOrigins,d=n.corsOriginsHint,f=n.corsOriginsEmpty,p=n.corsOriginsPlaceholder,m=r,h=128,g=a,_=o.length>0?(0,q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-muted px-3 py-2`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:n.corsDetectedOrigins}),(0,q.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:o.map(Ne)}),(0,q.jsx)(l,{type:`button`,variant:`secondary`,className:`mt-2 text-xs`,onClick:()=>a([...r,...o.map(Me)]),children:n.corsAddDetectedOrigins})]}):null,t[2]=i,t[3]=n.corsAddDetectedOrigins,t[4]=n.corsDetectedOrigins,t[5]=n.corsOrigins,t[6]=n.corsOriginsEmpty,t[7]=n.corsOriginsHint,t[8]=n.corsOriginsPlaceholder,t[9]=a,t[10]=r,t[11]=c,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[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[22]!==n.corsOriginsWildcardWarning||t[23]!==s?(v=s?(0,q.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:n.corsOriginsWildcardWarning}):null,t[22]=n.corsOriginsWildcardWarning,t[23]=s,t[24]=v):v=t[24];let y;return t[25]!==c||t[26]!==v||t[27]!==u||t[28]!==d||t[29]!==f||t[30]!==p||t[31]!==m||t[32]!==h||t[33]!==g||t[34]!==_?(y=(0,q.jsxs)(c,{title:u,hint:d,emptyText:f,placeholder:p,values:m,maxItems:h,onChange:g,children:[_,v]}),t[25]=c,t[26]=v,t[27]=u,t[28]=d,t[29]=f,t[30]=p,t[31]=m,t[32]=h,t[33]=g,t[34]=_,t[35]=y):y=t[35],y}function Me(e){return e.url}function Ne(e){return(0,q.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e.url,` · `,e.interfaceName]},e.url)}function Pe(e){let t=(0,H.c)(73),{g:n,rateLimit:r,onChange:i}=e,a;t[0]===n.rateLimitTitle?a=t[1]:(a=(0,q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.rateLimitTitle}),t[0]=n.rateLimitTitle,t[1]=a);let o;t[2]===n.rateLimitHint?o=t[3]:(o=(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.rateLimitHint}),t[2]=n.rateLimitHint,t[3]=o);let s;t[4]!==a||t[5]!==o?(s=(0,q.jsxs)(`div`,{children:[a,o]}),t[4]=a,t[5]=o,t[6]=s):s=t[6];let c;t[7]===i?c=t[8]:(c=e=>i({enabled:e.target.checked}),t[7]=i,t[8]=c);let l;t[9]!==r.enabled||t[10]!==c?(l=(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:c}),t[9]=r.enabled,t[10]=c,t[11]=l):l=t[11];let u;t[12]!==n.rateLimitEnabled||t[13]!==l?(u=(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[l,n.rateLimitEnabled]}),t[12]=n.rateLimitEnabled,t[13]=l,t[14]=u):u=t[14];let d=!r.enabled,f;t[15]===i?f=t[16]:(f=e=>i({exemptLoopback:e.target.checked}),t[15]=i,t[16]=f);let p;t[17]!==r.exemptLoopback||t[18]!==d||t[19]!==f?(p=(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.exemptLoopback,disabled:d,onChange:f}),t[17]=r.exemptLoopback,t[18]=d,t[19]=f,t[20]=p):p=t[20];let m;t[21]!==n.rateLimitExemptLoopback||t[22]!==p?(m=(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[p,n.rateLimitExemptLoopback]}),t[21]=n.rateLimitExemptLoopback,t[22]=p,t[23]=m):m=t[23];let h;t[24]===n.rateLimitMaxAttempts?h=t[25]:(h=(0,q.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-max`,children:n.rateLimitMaxAttempts}),t[24]=n.rateLimitMaxAttempts,t[25]=h);let g;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(g=Z(),t[26]=g):g=t[26];let _=!r.enabled,v;t[27]===i?v=t[28]:(v=e=>{let t=Number(e.target.value);Number.isFinite(t)&&i({maxAttempts:Math.max(1,Math.floor(t))})},t[27]=i,t[28]=v);let y;t[29]!==r.maxAttempts||t[30]!==_||t[31]!==v?(y=(0,q.jsx)(`input`,{id:`gateway-rate-max`,type:`number`,min:1,className:g,value:r.maxAttempts,disabled:_,onChange:v}),t[29]=r.maxAttempts,t[30]=_,t[31]=v,t[32]=y):y=t[32];let b;t[33]!==h||t[34]!==y?(b=(0,q.jsxs)(`div`,{children:[h,y]}),t[33]=h,t[34]=y,t[35]=b):b=t[35];let x;t[36]===n.rateLimitWindowMinutes?x=t[37]:(x=(0,q.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-window`,children:n.rateLimitWindowMinutes}),t[36]=n.rateLimitWindowMinutes,t[37]=x);let S;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(S=Z(),t[38]=S):S=t[38];let C;t[39]===r.windowMs?C=t[40]:(C=Math.round(r.windowMs/6e4),t[39]=r.windowMs,t[40]=C);let w=!r.enabled,T;t[41]===i?T=t[42]:(T=e=>{let t=Number(e.target.value);Number.isFinite(t)&&t>0&&i({windowMs:Math.floor(t)*6e4})},t[41]=i,t[42]=T);let E;t[43]!==C||t[44]!==w||t[45]!==T?(E=(0,q.jsx)(`input`,{id:`gateway-rate-window`,type:`number`,min:1,className:S,value:C,disabled:w,onChange:T}),t[43]=C,t[44]=w,t[45]=T,t[46]=E):E=t[46];let D;t[47]!==x||t[48]!==E?(D=(0,q.jsxs)(`div`,{children:[x,E]}),t[47]=x,t[48]=E,t[49]=D):D=t[49];let O;t[50]===n.rateLimitBlockMinutes?O=t[51]:(O=(0,q.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-block`,children:n.rateLimitBlockMinutes}),t[50]=n.rateLimitBlockMinutes,t[51]=O);let k;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(k=Z(),t[52]=k):k=t[52];let A;t[53]===r.blockDurationMs?A=t[54]:(A=Math.round(r.blockDurationMs/6e4),t[53]=r.blockDurationMs,t[54]=A);let j=!r.enabled,M;t[55]===i?M=t[56]:(M=e=>{let t=Number(e.target.value);Number.isFinite(t)&&t>0&&i({blockDurationMs:Math.floor(t)*6e4})},t[55]=i,t[56]=M);let N;t[57]!==A||t[58]!==j||t[59]!==M?(N=(0,q.jsx)(`input`,{id:`gateway-rate-block`,type:`number`,min:1,className:k,value:A,disabled:j,onChange:M}),t[57]=A,t[58]=j,t[59]=M,t[60]=N):N=t[60];let P;t[61]!==O||t[62]!==N?(P=(0,q.jsxs)(`div`,{children:[O,N]}),t[61]=O,t[62]=N,t[63]=P):P=t[63];let F;t[64]!==b||t[65]!==D||t[66]!==P?(F=(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[b,D,P]}),t[64]=b,t[65]=D,t[66]=P,t[67]=F):F=t[67];let I;return t[68]!==m||t[69]!==s||t[70]!==F||t[71]!==u?(I=(0,q.jsxs)(`div`,{className:`space-y-3 border-t border-edge pt-4`,children:[s,u,m,F]}),t[68]=m,t[69]=s,t[70]=F,t[71]=u,t[72]=I):I=t[72],I}function Fe(e){let t=(0,H.c)(17),{id:n,label:r,help:i,placeholder:a,value:o,labels:s,reveal:c,loadFailedLabel:l,onChange:u}=e,d;t[0]!==n||t[1]!==r?(d=(0,q.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=d):d=t[2];let f;t[3]!==n||t[4]!==s||t[5]!==l||t[6]!==u||t[7]!==a||t[8]!==c||t[9]!==o?(f=(0,q.jsx)(F,{id:n,value:o,onChange:u,placeholder:a,labels:s,reveal:c,loadFailedLabel:l,inputClassName:`text-xs`}),t[3]=n,t[4]=s,t[5]=l,t[6]=u,t[7]=a,t[8]=c,t[9]=o,t[10]=f):f=t[10];let p;t[11]===i?p=t[12]:(p=(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:i}),t[11]=i,t[12]=p);let m;return t[13]!==d||t[14]!==f||t[15]!==p?(m=(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[d,f,p]}),t[13]=d,t[14]=f,t[15]=p,t[16]=m):m=t[16],m}export{Te as GatewaySettingsPanel};
@@ -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{p as i}from"./chunk-KS7C4IRE-BaASWQor.js";import{n as a,r as o}from"./popover-select-BzdnTy3h.js";import{t as s}from"./loader-circle-CifKLtgG.js";import{t as c}from"./cn-JdwAhgNB.js";import{t as l}from"./button-CSEbl4zT.js";import{t as u}from"./messages-VI9m1xJl.js";import{l as d,n as f,r as p,s as m}from"./locale-store-De8wYkd7.js";import{i as h,o as g}from"./vendor-swr-BIWyz7Rc.js";import{n as _,r as v}from"./gateway-config-swr-BTH9HVUk.js";import{$o as y,Ai as b,Bo as x,Qo as S,Wc as C,_c as w,al as T,bl as E,es as D,no as O,qs as k,tc as A,ts as j}from"./index-CMLkr37Y.js";import{n as ee,r as M,t as te}from"./settings-page-layout-BRQNel6r.js";import{n as ne}from"./settings-loading-skeleton-xgo41cfo.js";import{n as re,t as ie}from"./use-autosave-CqFVx92z.js";import{n as N,t as P}from"./tab-completion-input-B-VsxKhC.js";import{t as F}from"./page-tabs-e99j9S9K.js";import{r as ae,t as I}from"./channel-recipient-api-CUBTQ0Bz.js";import{n as oe,t as se}from"./channels-status-swr-CiwOOoVL.js";import{n as L,o as R,t as z}from"./cron-expression-XzPZhzVM.js";import{t as ce}from"./date-picker-BmZjs4Bq.js";var B=e(t(),1),V=n();function le(){return p(`/api/workspace/heartbeat-md`)}async function ue(){let e=await m(le());return typeof e.payload?.content==`string`?e.payload.content:``}function H(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function de(e){let t=H(e)?e:{},n=H(t.gateway)?t.gateway:{},r=H(n.heartbeat)?n.heartbeat:{},i=r.activeHours,a=H(i)?i:null,o=a&&typeof a.start==`string`&&typeof a.end==`string`&&a.start&&a.end?{start:a.start,end:a.end,timezone:typeof a.timezone==`string`?a.timezone:``}:null;return{enabled:!!(r.enabled??!0),intervalMs:typeof r.intervalMs==`number`&&Number.isFinite(r.intervalMs)?r.intervalMs:18e5,includeSystemPromptSection:r.includeSystemPromptSection===!0,target:typeof r.target==`string`?r.target:``,targetChatId:typeof r.targetChatId==`string`?r.targetChatId:``,prompt:typeof r.prompt==`string`?r.prompt:``,ackMaxChars:typeof r.ackMaxChars==`number`&&Number.isFinite(r.ackMaxChars)?r.ackMaxChars:``,isolatedSession:!!r.isolatedSession,activeHours:o}}function U(e){let t={enabled:e.enabled,intervalMs:e.intervalMs,includeSystemPromptSection:e.includeSystemPromptSection};return e.target.trim()?t.target=e.target.trim():t.target=null,e.targetChatId.trim()?t.targetChatId=e.targetChatId.trim():t.targetChatId=null,e.prompt.trim()?t.prompt=e.prompt.trim():t.prompt=null,e.ackMaxChars===``||e.ackMaxChars===void 0?t.ackMaxChars=null:t.ackMaxChars=e.ackMaxChars,e.isolatedSession?t.isolatedSession=!0:t.isolatedSession=null,e.activeHours?.start?.trim()&&e.activeHours?.end?.trim()?t.activeHours={start:e.activeHours.start.trim(),end:e.activeHours.end.trim(),...e.activeHours.timezone.trim()?{timezone:e.activeHours.timezone.trim()}:{}}:t.activeHours=null,t}async function fe(e){await m(p(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{heartbeat:U(e)}})}),_()}async function pe(e){await m(p(`/api/workspace/heartbeat-md`),{method:`PUT`,body:JSON.stringify({content:e})}),g(le())}async function me(e){await m(p(`/api/heartbeat/trigger`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e?{reason:e}:{})})}var W=r(),he=Array.from({length:60},(e,t)=>t),G=c(D,`min-w-0 shrink text-xs sm:min-w-[7rem] sm:max-w-[11rem]`),ge=c(`h-9 w-14 shrink-0 rounded-lg border border-edge-subtle bg-surface-panel px-2 py-1.5 text-center text-sm tabular-nums text-fg`,S),_e=c(`min-h-[2.5rem] w-full rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 font-mono text-xs text-fg`,S);function K(e){return{...e,intervalMinutesDraft:null,intervalHoursDraft:null}}function q(e){let{intervalMinutesDraft:t,intervalHoursDraft:n,...r}=e;return r}function J(e,t){switch(t.type){case`reset`:return K(t.state);case`replace`:return t.state}}function ve({value:e,onChange:t,labels:n,disabled:r,showHeading:i=!0}){let s=(0,B.useMemo)(()=>L(e),[e]),[l,u]=(0,B.useReducer)(J,s,K),d=(0,B.useRef)(e);d.current!==e&&(d.current=e,u({type:`reset`,state:s}));let f=(0,B.useCallback)(e=>{let n={...l,...e};u({type:`replace`,state:n});let r=q(n),i=q(l);Object.keys(r).some(e=>r[e]!==i[e])&&t(z(r))},[t,l]),{mode:p,intervalKind:m,onceDate:h,intervalMinutes:g,intervalHours:_,minute:v,hour:y,weekDays:b,dayOfMonth:x,rawCron:S,intervalMinutesDraft:C,intervalHoursDraft:w}=l,T=`${String(y).padStart(2,`0`)}:${String(v).padStart(2,`0`)}`,E=e=>{if(!e)return;let[t,n]=e.split(`:`).map(e=>parseInt(e,10));Number.isNaN(t)||Number.isNaN(n)||f({minute:n,hour:t})},D=(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-nowrap items-center gap-2 overflow-x-auto pb-0.5`,children:[(0,W.jsxs)(a,{className:G,disabled:r,value:p,onChange:e=>{let t=e.target.value;f({mode:t})},"aria-label":n.scheduleTimeLabel,children:[(0,W.jsx)(o,{value:`no_repeat`,children:n.modeNoRepeat}),(0,W.jsx)(o,{value:`interval`,children:n.modeInterval}),(0,W.jsx)(o,{value:`hourly`,children:n.modeHourly}),(0,W.jsx)(o,{value:`daily`,children:n.modeDaily}),(0,W.jsx)(o,{value:`weekly`,children:n.modeWeekly}),(0,W.jsx)(o,{value:`monthly`,children:n.modeMonthly}),(0,W.jsx)(o,{value:`custom`,children:n.modeCustom})]}),p===`no_repeat`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ce,{disabled:r,className:`h-9 min-w-[9.5rem] shrink-0 bg-surface-panel px-2`,value:h,onChange:e=>f({onceDate:e}),ariaLabel:n.modeNoRepeat}),(0,W.jsx)(R,{disabled:r,className:`min-w-[6.5rem] shrink-0`,triggerClassName:`h-9 border-edge-subtle px-2`,value:T,onChange:E,ariaLabel:n.scheduleTimeLabel})]}),p===`interval`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(a,{className:c(G,`w-auto min-w-[5rem]`),disabled:r,value:m,onChange:e=>{let t=e.target.value;f({intervalKind:t,intervalMinutesDraft:null,intervalHoursDraft:null})},"aria-label":n.modeInterval,children:[(0,W.jsx)(o,{value:`minutes`,children:n.intervalKindMinutes}),(0,W.jsx)(o,{value:`hours`,children:n.intervalKindHours})]}),m===`minutes`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`input`,{type:`number`,min:1,max:59,disabled:r,className:ge,value:C??String(g),onChange:e=>{let t=e.target.value,n=parseInt(t,10),r={intervalMinutesDraft:t};Number.isFinite(n)&&n>=1&&n<=59&&(r.intervalMinutes=n),f(r)},onBlur:()=>{if(C===null)return;let e=parseInt(C,10);f({intervalMinutes:!Number.isFinite(e)||e<1?5:Math.min(59,Math.max(1,Math.round(e))),intervalMinutesDraft:null})},"aria-label":n.intervalMinutes}),(0,W.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`input`,{type:`number`,min:1,max:23,disabled:r,className:ge,value:w??String(_),onChange:e=>{let t=e.target.value,n=parseInt(t,10),r={intervalHoursDraft:t};Number.isFinite(n)&&n>=1&&n<=23&&(r.intervalHours=n),f(r)},onBlur:()=>{if(w===null)return;let e=parseInt(w,10);f({intervalHours:!Number.isFinite(e)||e<1?2:Math.min(23,Math.max(1,Math.round(e))),intervalHoursDraft:null})},"aria-label":n.intervalHours}),(0,W.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.hourUnit}),(0,W.jsx)(a,{className:c(G,`w-auto min-w-[4rem]`),disabled:r,value:v,onChange:e=>{f({minute:parseInt(e.target.value,10)})},"aria-label":n.minuteAtHour,children:he.map(e=>(0,W.jsx)(o,{value:e,children:String(e).padStart(2,`0`)},e))}),(0,W.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]})]}),p===`daily`&&(0,W.jsx)(R,{disabled:r,className:`min-w-[6.5rem] shrink-0`,triggerClassName:`h-9 border-edge-subtle px-2`,value:T,onChange:E,ariaLabel:n.scheduleTimeLabel}),p===`weekly`&&(0,W.jsx)(R,{disabled:r,className:`min-w-[6.5rem] shrink-0`,triggerClassName:`h-9 border-edge-subtle px-2`,value:T,onChange:E,ariaLabel:n.scheduleTimeLabel}),p===`monthly`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(a,{className:c(G,`w-auto min-w-[4.5rem]`),disabled:r,value:x,onChange:e=>{f({dayOfMonth:parseInt(e.target.value,10)})},"aria-label":n.dayOfMonth,children:Array.from({length:31},(e,t)=>t+1).map(e=>(0,W.jsx)(o,{value:e,children:e},e))}),(0,W.jsx)(R,{disabled:r,className:`min-w-[6.5rem] shrink-0`,triggerClassName:`h-9 border-edge-subtle px-2`,value:T,onChange:E,ariaLabel:n.scheduleTimeLabel})]}),p===`hourly`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(a,{className:c(G,`w-auto min-w-[4rem]`),disabled:r,value:v,onChange:e=>{f({minute:parseInt(e.target.value,10)})},"aria-label":n.minuteAtHour,children:he.map(e=>(0,W.jsx)(o,{value:e,children:String(e).padStart(2,`0`)},e))}),(0,W.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]})]}),O=p===`weekly`?(0,W.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,role:`group`,"aria-label":n.modeWeekly,children:n.weekdays.map((e,t)=>{let n=b[t];return(0,W.jsx)(`button`,{type:`button`,disabled:r,className:c(`flex size-9 select-none items-center justify-center rounded-full border text-xs font-medium transition-colors`,n?`border-fg bg-fg text-surface-panel`:`border-edge-subtle bg-surface-panel text-fg hover:border-edge`),"aria-pressed":n,onClick:()=>{let e=[...b];e[t]=!e[t],f({weekDays:e})},children:e},e)})}):null,k=p===`custom`?(0,W.jsxs)(`div`,{className:`pt-1`,children:[(0,W.jsx)(N,{disabled:r,className:_e,rows:2,spellCheck:!1,value:S,suggestion:`*/5 * * * *`,onAcceptSuggestion:e=>f({rawCron:e}),placeholder:`*/5 * * * *`,onChange:e=>{f({rawCron:e.target.value})},"aria-label":n.modeCustom}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.customCronHint})]}):null;return(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[i?(0,W.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.scheduleTimeLabel}):null,D,O,k]})}var Y=[3e4,6e4,3e5,6e5,9e5,18e5,36e5,72e5];new Set(Y);var X=c(`h-9 min-w-0 flex-1 rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm tabular-nums text-fg`,S),ye=c(D,`h-9 max-w-[11rem] shrink-0 text-xs sm:max-w-[12rem]`);function be(e,t){switch(e){case 3e4:return t.every30s;case 6e4:return t.every1min;case 3e5:return t.every5min;case 6e5:return t.every10min;case 9e5:return t.every15min;case 18e5:return t.every30min;case 36e5:return t.every1h;case 72e5:return t.every2h;default:return String(e)}}function xe({valueMs:e,onChangeMs:t,labels:n,disabled:r,presets:i=Y,minSeconds:s=1}){let c=(0,B.useMemo)(()=>new Set(i),[i]),l=(0,B.useMemo)(()=>c.has(e)?String(e):``,[c,e]),[u,d]=(0,B.useState)(null),f=(0,B.useRef)(e);f.current!==e&&(f.current=e,d(null));let p=Math.max(s,Math.round(e/1e3)),m=u===null?String(p):u;return(0,W.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,W.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.secondsLabel}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`input`,{type:`number`,min:s,step:1,disabled:r,className:X,value:m,onChange:e=>{let n=e.target.value;d(n);let r=parseInt(n,10);Number.isFinite(r)&&r>=s&&t(r*1e3)},onBlur:()=>{if(u===null)return;let e=parseInt(u,10);t(!Number.isFinite(e)||e<s?s*1e3:e*1e3),d(null)}}),(0,W.jsxs)(a,{className:ye,disabled:r,value:l,onChange:e=>{let n=e.target.value;n&&(t(parseInt(n,10)),d(null))},children:[(0,W.jsx)(o,{value:``,children:n.presets.custom}),i.map(e=>(0,W.jsx)(o,{value:String(e),children:be(e,n.presets)},e))]})]})]})}var Se=c(`mt-1 w-full rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm text-fg`,S),Z=()=>({start:`09:00`,end:`22:00`,timezone:``});function Ce(e){let t=(0,V.c)(61),{value:n,onChange:r,labels:i,disabled:a}=e;if(!n){let e;t[0]===r?e=t[1]:(e=()=>r(Z()),t[0]=r,t[1]=e);let n;return t[2]!==a||t[3]!==i.add||t[4]!==e?(n=(0,W.jsx)(l,{type:`button`,variant:`secondary`,className:`text-sm`,disabled:a,onClick:e,children:i.add}),t[2]=a,t[3]=i.add,t[4]=e,t[5]=n):n=t[5],n}let o;t[6]===i.start?o=t[7]:(o=(0,W.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.start}),t[6]=i.start,t[7]=o);let s;t[8]!==r||t[9]!==n?(s=e=>r({...n,start:e}),t[8]=r,t[9]=n,t[10]=s):s=t[10];let c;t[11]!==a||t[12]!==i.start||t[13]!==s||t[14]!==n.start?(c=(0,W.jsx)(R,{disabled:a,className:`mt-1 w-full`,triggerClassName:`h-9 border-edge-subtle px-2.5`,value:n.start,onChange:s,ariaLabel:i.start}),t[11]=a,t[12]=i.start,t[13]=s,t[14]=n.start,t[15]=c):c=t[15];let u;t[16]!==o||t[17]!==c?(u=(0,W.jsxs)(`label`,{className:`block min-w-0`,children:[o,c]}),t[16]=o,t[17]=c,t[18]=u):u=t[18];let d;t[19]===i.end?d=t[20]:(d=(0,W.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.end}),t[19]=i.end,t[20]=d);let f;t[21]!==r||t[22]!==n?(f=e=>r({...n,end:e}),t[21]=r,t[22]=n,t[23]=f):f=t[23];let p;t[24]!==a||t[25]!==i.end||t[26]!==f||t[27]!==n.end?(p=(0,W.jsx)(R,{disabled:a,className:`mt-1 w-full`,triggerClassName:`h-9 border-edge-subtle px-2.5`,value:n.end,onChange:f,ariaLabel:i.end}),t[24]=a,t[25]=i.end,t[26]=f,t[27]=n.end,t[28]=p):p=t[28];let m;t[29]!==d||t[30]!==p?(m=(0,W.jsxs)(`label`,{className:`block min-w-0`,children:[d,p]}),t[29]=d,t[30]=p,t[31]=m):m=t[31];let h;t[32]===i.timezone?h=t[33]:(h=(0,W.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.timezone}),t[32]=i.timezone,t[33]=h);let g;t[34]!==r||t[35]!==n?(g=e=>r({...n,timezone:e.target.value}),t[34]=r,t[35]=n,t[36]=g):g=t[36];let _;t[37]!==r||t[38]!==n?(_=e=>r({...n,timezone:e}),t[37]=r,t[38]=n,t[39]=_):_=t[39];let v;t[40]!==a||t[41]!==g||t[42]!==_||t[43]!==n.timezone?(v=(0,W.jsx)(P,{type:`text`,disabled:a,className:Se,value:n.timezone,onChange:g,suggestion:`Asia/Shanghai`,onAcceptSuggestion:_,placeholder:`Asia/Shanghai`,autoComplete:`off`}),t[40]=a,t[41]=g,t[42]=_,t[43]=n.timezone,t[44]=v):v=t[44];let y;t[45]!==v||t[46]!==h?(y=(0,W.jsxs)(`label`,{className:`block min-w-0`,children:[h,v]}),t[45]=v,t[46]=h,t[47]=y):y=t[47];let b;t[48]!==y||t[49]!==u||t[50]!==m?(b=(0,W.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[u,m,y]}),t[48]=y,t[49]=u,t[50]=m,t[51]=b):b=t[51];let x;t[52]===r?x=t[53]:(x=()=>r(null),t[52]=r,t[53]=x);let S;t[54]!==a||t[55]!==i.clear||t[56]!==x?(S=(0,W.jsx)(l,{type:`button`,variant:`secondary`,className:`text-xs`,disabled:a,onClick:x,children:i.clear}),t[54]=a,t[55]=i.clear,t[56]=x,t[57]=S):S=t[57];let C;return t[58]!==b||t[59]!==S?(C=(0,W.jsxs)(`div`,{className:`space-y-2`,children:[b,S]}),t[58]=b,t[59]=S,t[60]=C):C=t[60],C}function Q(e){let t=(0,V.c)(34),{disabled:n,label:r,hint:i,className:a}=e,o;t[0]===a?o=t[1]:(o=c(`flex flex-col gap-2`,a),t[0]=a,t[1]=o);let s;t[2]===r?s=t[3]:(s=r?(0,W.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r}):null,t[2]=r,t[3]=s);let l;t[4]!==n||t[5]!==r||t[6]!==e.kind||t[7]!==e.labels||t[8]!==e.onChange||t[9]!==e.value?(l=e.kind===`cron`?(0,W.jsx)(ve,{value:e.value,onChange:e.onChange,labels:e.labels,disabled:n,showHeading:!r}):null,t[4]=n,t[5]=r,t[6]=e.kind,t[7]=e.labels,t[8]=e.onChange,t[9]=e.value,t[10]=l):l=t[10];let u;t[11]!==n||t[12]!==e.kind||t[13]!==e.labels||t[14]!==e.minSeconds||t[15]!==e.onChangeMs||t[16]!==e.presets||t[17]!==e.valueMs?(u=e.kind===`interval`?(0,W.jsx)(xe,{valueMs:e.valueMs,onChangeMs:e.onChangeMs,labels:e.labels,disabled:n,presets:e.presets??Y,minSeconds:e.minSeconds}):null,t[11]=n,t[12]=e.kind,t[13]=e.labels,t[14]=e.minSeconds,t[15]=e.onChangeMs,t[16]=e.presets,t[17]=e.valueMs,t[18]=u):u=t[18];let d;t[19]!==n||t[20]!==e.kind||t[21]!==e.labels||t[22]!==e.onChange||t[23]!==e.value?(d=e.kind===`active-hours`?(0,W.jsx)(Ce,{value:e.value,onChange:e.onChange,labels:e.labels,disabled:n}):null,t[19]=n,t[20]=e.kind,t[21]=e.labels,t[22]=e.onChange,t[23]=e.value,t[24]=d):d=t[24];let f;t[25]===i?f=t[26]:(f=i?(0,W.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:i}):null,t[25]=i,t[26]=f);let p;return t[27]!==o||t[28]!==s||t[29]!==l||t[30]!==u||t[31]!==d||t[32]!==f?(p=(0,W.jsxs)(`div`,{className:o,children:[s,l,u,d,f]}),t[27]=o,t[28]=s,t[29]=l,t[30]=u,t[31]=d,t[32]=f,t[33]=p):p=t[33],p}function we(){return c(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,j,`dark:border-edge`)}function Te(){return c(D,y)}var Ee=[`schedule`,`delivery`,`prompt`,`document`],De={schedule:E,delivery:w,prompt:C,document:T};function Oe(e){return e&&Ee.includes(e)?e:`schedule`}function ke(e,t){return t===`schedule`?e.tabSchedule:t===`delivery`?e.tabDelivery:t===`prompt`?e.tabPrompt:e.tabDocument}function Ae(e,t){return t===`schedule`?e.scheduleTabHint:t===`delivery`?e.deliveryTabHint:t===`prompt`?e.promptTabHint:e.documentTabHint}function je(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`patch`:return{...e,form:e.form?{...e.form,...t.patch}:null};case`saved`:{let n=structuredClone(t.value);return{form:e.form&&JSON.stringify(e.form)!==JSON.stringify(t.value)?e.form:n,baseline:structuredClone(n)}}}}function Me(e,t){switch(t.type){case`reset`:return{doc:``,baseline:``};case`sync`:return{doc:t.value,baseline:t.value};case`set`:return{...e,doc:t.value};case`saved`:return{doc:e.doc===t.value?t.value:e.doc,baseline:t.value}}}function Ne(e){if(!e||typeof e!=`object`||Array.isArray(e))return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t;if(!Array.isArray(n.list))return``;let r=typeof n.default==`string`?n.default:``,i=n.list.find(e=>!e||typeof e!=`object`||Array.isArray(e)?!1:r?e.id===r:!0)??n.list[0];if(!i||typeof i!=`object`||Array.isArray(i))return``;let a=i.workspace;if(!a||typeof a!=`object`||Array.isArray(a))return``;let o=a.root;return typeof o==`string`?o:``}var Pe={triggerLoading:!1,triggerOk:!1,triggerError:null};function Fe(){let e=f(e=>e.language),t=u(e),n=t.heartbeatSettings,r=!!d(e=>e.token),[a,o]=i(),p=Oe(a.get(`tab`)),m=(0,B.useCallback)(e=>{o(t=>{let n=new URLSearchParams(t);return e===`schedule`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[o]),[g,_]=(0,B.useReducer)(je,{form:null,baseline:null}),y=g.form,S=g.baseline,[C,w]=(0,B.useReducer)(Me,{doc:``,baseline:``}),T=C.doc,E=C.baseline,[D,k]=(0,B.useReducer)(b,Pe),{triggerLoading:j,triggerOk:te,triggerError:N}=D,P=(0,B.useRef)(!1),F=(0,B.useRef)(!1),I=(0,B.useRef)(y),L=(0,B.useRef)(T);I.current=y,L.current=T;let{data:R,error:z,isLoading:ce,mutate:V}=v(r),{data:H,error:U,isLoading:he,mutate:G}=h(r?le():null,ue,{revalidateOnFocus:!1}),{data:ge=[]}=h(r?se():null,oe,{revalidateOnFocus:!1}),_e=(0,B.useMemo)(()=>Ne(R?.payload?.config),[R]),K=(0,B.useMemo)(()=>de(R?.payload?.config??{}),[R]),q=(0,B.useMemo)(()=>!y||!S?!1:JSON.stringify(y)!==JSON.stringify(S),[y,S]),J=T!==E;(0,B.useEffect)(()=>{if(!r){_({type:`reset`}),P.current=!1;return}R!==void 0&&(P.current||_({type:`sync`,value:K}))},[r,R,K]),(0,B.useEffect)(()=>{if(!r){w({type:`reset`}),F.current=!1;return}H!==void 0&&(F.current||w({type:`sync`,value:H}))},[r,H]);let ve=z instanceof Error?z.message:z?String(z):U instanceof Error?U.message:U?String(U):null,Y=!!(r&&(R===void 0||H===void 0)&&!ve&&(ce||he)),X=y?.target.trim()??``,{data:ye,setData:be}=O(()=>ae(X),[r,X],{enabled:r&&X.length>0,initial:[],errorData:[]}),xe=(0,B.useCallback)(()=>{X&&ae(X).then(be)},[X,be]),Se=(0,B.useCallback)(async()=>{k({type:`patch`,patch:{triggerLoading:!0,triggerOk:!1,triggerError:null}});try{await me(),k({type:`patch`,patch:{triggerOk:!0}}),window.setTimeout(()=>k({type:`patch`,patch:{triggerOk:!1}}),3e3)}catch(e){k({type:`patch`,patch:{triggerError:e instanceof Error?e.message:n.triggerError}})}finally{k({type:`patch`,patch:{triggerLoading:!1}})}},[n.triggerError]),Z=(0,B.useCallback)(e=>{P.current=!0,_({type:`patch`,patch:e})},[]),Ce=q||J,Q=ie({value:(0,B.useMemo)(()=>y?{form:y,doc:T,saveConfig:q,saveDoc:J}:null,[q,J,T,y]),dirty:Ce,onSave:(0,B.useCallback)(async e=>{try{e.saveConfig&&(await fe(e.form),_({type:`saved`,value:e.form}),P.current=!!(I.current&&JSON.stringify(I.current)!==JSON.stringify(e.form))),e.saveDoc&&(await pe(e.doc),w({type:`saved`,value:e.doc}),F.current=L.current!==e.doc)}catch(t){throw Error(t instanceof Error?t.message:e.saveConfig?n.saveConfigError:n.saveDocError)}},[n.saveConfigError,n.saveDocError]),delayMs:J?900:500});return r?Y?(0,W.jsx)(M,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,W.jsx)(ne,{sections:3})}):y?(0,W.jsxs)(M,{"aria-busy":Q.status===`saving`,"data-has-baseline":S?`1`:`0`,onBlurCapture:Q.onBlurCapture,children:[(0,W.jsx)(ee,{title:t.settingsSections.heartbeat,subtitle:n.subtitle,docsLink:x(e,`heartbeat`),docsLabel:n.docsLink,actions:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(re,{status:Q.status,error:Q.error}),(0,W.jsxs)(l,{type:`button`,variant:`secondary`,className:`inline-flex items-center gap-2`,disabled:j,onClick:()=>void Se(),children:[j?(0,W.jsx)(s,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,W.jsx)(A,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),j?n.triggering:n.triggerNow]}),te?(0,W.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.triggered}):null]})}),_e?(0,W.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.workspaceLabel,`: `,(0,W.jsx)(`span`,{className:`font-mono text-fg-muted`,children:_e})]}):null,Q.error?(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:Q.error}):null,N?(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:N}):null,(0,W.jsx)(Ie,{h:n,activeTab:p,onChange:m}),(0,W.jsx)($,{h:n,id:`schedule`,activeTab:p,children:(0,W.jsx)(Le,{h:n,form:y,update:Z})}),(0,W.jsx)($,{h:n,id:`delivery`,activeTab:p,children:(0,W.jsx)(Re,{h:n,cron:t.cron,form:y,channels:ge,sessionChatIds:ye,onRefreshChatIds:xe,update:Z,inputClassName:we,selectClassName:Te})}),(0,W.jsx)($,{h:n,id:`prompt`,activeTab:p,children:(0,W.jsx)(Ve,{h:n,form:y,update:Z,inputClassName:we})}),(0,W.jsxs)($,{h:n,id:`document`,activeTab:p,children:[(0,W.jsx)(`p`,{className:`mb-3 text-xs text-fg-subtle`,children:n.docHint}),(0,W.jsx)(`textarea`,{className:c(we(),`min-h-72 resize-y font-mono text-xs leading-relaxed`),value:T,onChange:e=>{F.current=!0,w({type:`set`,value:e.target.value})},spellCheck:!1,"aria-label":n.docSection,"data-doc-in-sync":T===E?`true`:`false`})]})]}):(0,W.jsxs)(M,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:ve??n.loadError}),(0,W.jsx)(l,{type:`button`,variant:`secondary`,onClick:()=>{V(),G()},children:n.retry})]}):(0,W.jsxs)(M,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,W.jsx)(ee,{title:t.settingsSections.heartbeat}),(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]})}function Ie(e){let t=(0,V.c)(7),{h:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=Ee.map(e=>({id:e,label:ke(n,e),icon:De[e]})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==n.tabsAriaLabel||t[4]!==o||t[5]!==i?(s=(0,W.jsx)(F,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`heartbeat-settings-tab`,panelIdPrefix:`heartbeat-settings-panel`}),t[2]=r,t[3]=n.tabsAriaLabel,t[4]=o,t[5]=i,t[6]=s):s=t[6],s}function $(e){let t=(0,V.c)(14),{h:n,id:r,activeTab:i,children:a}=e,o;t[0]!==n||t[1]!==r?(o=ke(n,r),t[0]=n,t[1]=r,t[2]=o):o=t[2];let s;t[3]!==n||t[4]!==r?(s=Ae(n,r),t[3]=n,t[4]=r,t[5]=s):s=t[5];let c;t[6]===a?c=t[7]:(c=(0,W.jsx)(`div`,{className:`space-y-4`,children:a}),t[6]=a,t[7]=c);let l;return t[8]!==i||t[9]!==r||t[10]!==o||t[11]!==s||t[12]!==c?(l=(0,W.jsx)(te,{id:r,activeTab:i,tabIdPrefix:`heartbeat-settings-tab`,panelIdPrefix:`heartbeat-settings-panel`,title:o,hint:s,children:c}),t[8]=i,t[9]=r,t[10]=o,t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function Le(e){let t=(0,V.c)(37),{h:n,form:r,update:i}=e,a;t[0]===i?a=t[1]:(a=e=>i({enabled:e.target.checked}),t[0]=i,t[1]=a);let o;t[2]!==r.enabled||t[3]!==a?(o=(0,W.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:a}),t[2]=r.enabled,t[3]=a,t[4]=o):o=t[4];let s;t[5]!==n.enable||t[6]!==o?(s=(0,W.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[o,n.enable]}),t[5]=n.enable,t[6]=o,t[7]=s):s=t[7];let c;t[8]===i?c=t[9]:(c=e=>i({intervalMs:e}),t[8]=i,t[9]=c);let l;t[10]!==n.intervalPresets||t[11]!==n.intervalSecondsLabel?(l={secondsLabel:n.intervalSecondsLabel,presets:n.intervalPresets},t[10]=n.intervalPresets,t[11]=n.intervalSecondsLabel,t[12]=l):l=t[12];let u=`${n.intervalHintPreset} ${n.intervalHint}`,d;t[13]!==r.intervalMs||t[14]!==n.interval||t[15]!==c||t[16]!==l||t[17]!==u?(d=(0,W.jsx)(Q,{kind:`interval`,label:n.interval,valueMs:r.intervalMs,onChangeMs:c,labels:l,hint:u}),t[13]=r.intervalMs,t[14]=n.interval,t[15]=c,t[16]=l,t[17]=u,t[18]=d):d=t[18];let f;t[19]===i?f=t[20]:(f=e=>i({activeHours:e}),t[19]=i,t[20]=f);let p;t[21]!==n.activeEnd||t[22]!==n.activeStart||t[23]!==n.activeTimezone||t[24]!==n.addActiveHours||t[25]!==n.clearActiveHours?(p={start:n.activeStart,end:n.activeEnd,timezone:n.activeTimezone,add:n.addActiveHours,clear:n.clearActiveHours},t[21]=n.activeEnd,t[22]=n.activeStart,t[23]=n.activeTimezone,t[24]=n.addActiveHours,t[25]=n.clearActiveHours,t[26]=p):p=t[26];let m;t[27]!==r.activeHours||t[28]!==n.activeHoursHint||t[29]!==n.activeHoursTitle||t[30]!==f||t[31]!==p?(m=(0,W.jsx)(Q,{kind:`active-hours`,label:n.activeHoursTitle,value:r.activeHours,onChange:f,labels:p,hint:n.activeHoursHint}),t[27]=r.activeHours,t[28]=n.activeHoursHint,t[29]=n.activeHoursTitle,t[30]=f,t[31]=p,t[32]=m):m=t[32];let h;return t[33]!==m||t[34]!==s||t[35]!==d?(h=(0,W.jsxs)(W.Fragment,{children:[s,d,m]}),t[33]=m,t[34]=s,t[35]=d,t[36]=h):h=t[36],h}function Re(e){let t=(0,V.c)(51),{h:n,cron:r,form:i,channels:s,sessionChatIds:u,onRefreshChatIds:d,update:f,inputClassName:p,selectClassName:m}=e,h;t[0]===s?h=t[1]:(h=new Set(s.map(Be)),t[0]=s,t[1]=h);let g=h,_;t[2]===i.target?_=t[3]:(_=i.target.trim(),t[2]=i.target,t[3]=_);let v=_,y=!!(v&&!g.has(v)),b;t[4]===n.deliveryHint?b=t[5]:(b=(0,W.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.deliveryHint}),t[4]=n.deliveryHint,t[5]=b);let x;t[6]===r.channel?x=t[7]:(x=(0,W.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r.channel}),t[6]=r.channel,t[7]=x);let S;t[8]===m?S=t[9]:(S=m(),t[8]=m,t[9]=S);let C;t[10]===f?C=t[11]:(C=e=>{f({target:e.target.value.trim(),targetChatId:``})},t[10]=f,t[11]=C);let w;t[12]===n.channelNone?w=t[13]:(w=(0,W.jsx)(o,{value:``,children:n.channelNone}),t[12]=n.channelNone,t[13]=w);let T;t[14]!==n.customChannelSuffix||t[15]!==y||t[16]!==v?(T=y?(0,W.jsxs)(o,{value:v,children:[v,` (`,n.customChannelSuffix,`)`]}):null,t[14]=n.customChannelSuffix,t[15]=y,t[16]=v,t[17]=T):T=t[17];let E;t[18]===s?E=t[19]:(E=s.map(ze),t[18]=s,t[19]=E);let D;t[20]!==S||t[21]!==C||t[22]!==w||t[23]!==T||t[24]!==E||t[25]!==v?(D=(0,W.jsxs)(a,{className:S,value:v,onChange:C,children:[w,T,E]}),t[20]=S,t[21]=C,t[22]=w,t[23]=T,t[24]=E,t[25]=v,t[26]=D):D=t[26];let O;t[27]!==D||t[28]!==x?(O=(0,W.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[x,D]}),t[27]=D,t[28]=x,t[29]=O):O=t[29];let A;t[30]!==r.enterManuallyOrSelect||t[31]!==r.lastActiveLabels||t[32]!==r.noRecentChats||t[33]!==r.noRecentChatsOption||t[34]!==r.recipient||t[35]!==r.recipientPlaceholder||t[36]!==r.refreshList||t[37]!==r.refreshRecipientHint||t[38]!==r.selectRecipient||t[39]!==i.targetChatId||t[40]!==p||t[41]!==d||t[42]!==m||t[43]!==u||t[44]!==v||t[45]!==f?(A=v?(0,W.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r.recipient}),(0,W.jsxs)(l,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,title:r.refreshRecipientHint,onClick:d,children:[(0,W.jsx)(k,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),r.refreshList]})]}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`input`,{type:`text`,className:c(p(),`min-w-0 flex-1`),value:i.targetChatId,onChange:e=>f({targetChatId:e.target.value}),placeholder:r.recipientPlaceholder,autoComplete:`off`}),(0,W.jsxs)(a,{className:c(m(),`max-w-40 shrink-0 text-xs`),value:i.targetChatId,onChange:e=>{let t=e.target.value;t&&f({targetChatId:t})},children:[(0,W.jsx)(o,{value:``,children:r.selectRecipient}),u.length>0?u.map(e=>(0,W.jsx)(o,{value:e.chatId,children:I(e,r.lastActiveLabels)},`${e.channel}-${e.chatId}`)):(0,W.jsx)(o,{value:``,disabled:!0,children:r.noRecentChatsOption})]})]}),(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:u.length>0?r.enterManuallyOrSelect:r.noRecentChats})]}):null,t[30]=r.enterManuallyOrSelect,t[31]=r.lastActiveLabels,t[32]=r.noRecentChats,t[33]=r.noRecentChatsOption,t[34]=r.recipient,t[35]=r.recipientPlaceholder,t[36]=r.refreshList,t[37]=r.refreshRecipientHint,t[38]=r.selectRecipient,t[39]=i.targetChatId,t[40]=p,t[41]=d,t[42]=m,t[43]=u,t[44]=v,t[45]=f,t[46]=A):A=t[46];let j;return t[47]!==O||t[48]!==A||t[49]!==b?(j=(0,W.jsxs)(W.Fragment,{children:[b,O,A]}),t[47]=O,t[48]=A,t[49]=b,t[50]=j):j=t[50],j}function ze(e){return(0,W.jsxs)(o,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:`(disabled)`]},e.name)}function Be(e){return e.name}function Ve(e){let t=(0,V.c)(65),{h:n,form:r,update:i,inputClassName:a}=e,o;t[0]===i?o=t[1]:(o=e=>i({includeSystemPromptSection:e.target.checked}),t[0]=i,t[1]=o);let s;t[2]!==r.includeSystemPromptSection||t[3]!==o?(s=(0,W.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.includeSystemPromptSection,onChange:o}),t[2]=r.includeSystemPromptSection,t[3]=o,t[4]=s):s=t[4];let l;t[5]===n.includeSystemPromptSectionHint?l=t[6]:(l=(0,W.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:n.includeSystemPromptSectionHint}),t[5]=n.includeSystemPromptSectionHint,t[6]=l);let u;t[7]!==n.includeSystemPromptSection||t[8]!==l?(u=(0,W.jsxs)(`span`,{children:[n.includeSystemPromptSection,l]}),t[7]=n.includeSystemPromptSection,t[8]=l,t[9]=u):u=t[9];let d;t[10]!==s||t[11]!==u?(d=(0,W.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[s,u]}),t[10]=s,t[11]=u,t[12]=d):d=t[12];let f;t[13]===n.prompt?f=t[14]:(f=(0,W.jsx)(`div`,{className:`mb-1 text-sm font-medium text-fg`,children:n.prompt}),t[13]=n.prompt,t[14]=f);let p;t[15]===a?p=t[16]:(p=c(a(),`min-h-36 resize-y font-mono text-xs`),t[15]=a,t[16]=p);let m;t[17]===i?m=t[18]:(m=e=>i({prompt:e.target.value}),t[17]=i,t[18]=m);let h;t[19]!==r.prompt||t[20]!==n.promptPlaceholder||t[21]!==p||t[22]!==m?(h=(0,W.jsx)(`textarea`,{className:p,value:r.prompt,onChange:m,placeholder:n.promptPlaceholder}),t[19]=r.prompt,t[20]=n.promptPlaceholder,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g;t[24]===n.promptHint?g=t[25]:(g=(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.promptHint}),t[24]=n.promptHint,t[25]=g);let _;t[26]!==g||t[27]!==f||t[28]!==h?(_=(0,W.jsxs)(`div`,{children:[f,h,g]}),t[26]=g,t[27]=f,t[28]=h,t[29]=_):_=t[29];let v;t[30]===n.ackMaxChars?v=t[31]:(v=(0,W.jsx)(`div`,{className:`mb-1 text-sm font-medium text-fg`,children:n.ackMaxChars}),t[30]=n.ackMaxChars,t[31]=v);let y;t[32]===a?y=t[33]:(y=a(),t[32]=a,t[33]=y);let b=r.ackMaxChars===``?``:r.ackMaxChars,x;t[34]===i?x=t[35]:(x=e=>{let t=e.target.value;if(t===``){i({ackMaxChars:``});return}let n=parseInt(t,10);i({ackMaxChars:Number.isFinite(n)?n:``})},t[34]=i,t[35]=x);let S;t[36]!==n.ackDefaultPlaceholder||t[37]!==y||t[38]!==b||t[39]!==x?(S=(0,W.jsx)(`input`,{type:`number`,min:1,className:y,value:b,onChange:x,placeholder:n.ackDefaultPlaceholder}),t[36]=n.ackDefaultPlaceholder,t[37]=y,t[38]=b,t[39]=x,t[40]=S):S=t[40];let C;t[41]===n.ackMaxCharsHint?C=t[42]:(C=(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.ackMaxCharsHint}),t[41]=n.ackMaxCharsHint,t[42]=C);let w;t[43]!==v||t[44]!==S||t[45]!==C?(w=(0,W.jsxs)(`div`,{children:[v,S,C]}),t[43]=v,t[44]=S,t[45]=C,t[46]=w):w=t[46];let T;t[47]===i?T=t[48]:(T=e=>i({isolatedSession:e.target.checked}),t[47]=i,t[48]=T);let E;t[49]!==r.isolatedSession||t[50]!==T?(E=(0,W.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.isolatedSession,onChange:T}),t[49]=r.isolatedSession,t[50]=T,t[51]=E):E=t[51];let D;t[52]===n.isolatedSessionHint?D=t[53]:(D=(0,W.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:n.isolatedSessionHint}),t[52]=n.isolatedSessionHint,t[53]=D);let O;t[54]!==n.isolatedSession||t[55]!==D?(O=(0,W.jsxs)(`span`,{children:[n.isolatedSession,D]}),t[54]=n.isolatedSession,t[55]=D,t[56]=O):O=t[56];let k;t[57]!==E||t[58]!==O?(k=(0,W.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[E,O]}),t[57]=E,t[58]=O,t[59]=k):k=t[59];let A;return t[60]!==_||t[61]!==w||t[62]!==k||t[63]!==d?(A=(0,W.jsxs)(W.Fragment,{children:[d,_,w,k]}),t[60]=_,t[61]=w,t[62]=k,t[63]=d,t[64]=A):A=t[64],A}export{Fe as HeartbeatSettingsPanel};