@xopcai/xopc 0.0.127 → 0.0.129

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 (334) 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/{agent-avatar-dicebear-CgGgO4OV.js → agent-avatar-dicebear-DHzfg5D-.js} +1 -1
  4. package/dist/gateway/static/root/assets/agents-CMxKKFQD.js +2 -0
  5. package/dist/gateway/static/root/assets/app-management-settings-panel-ptk9c5BN.js +1 -0
  6. package/dist/gateway/static/root/assets/{appearance-settings-BnHQW7Hv.js → appearance-settings-bYeEj3IW.js} +1 -1
  7. package/dist/gateway/static/root/assets/apps-page-DdZvDf5B.js +1 -0
  8. package/dist/gateway/static/root/assets/{archive-plugin-5NXT7Zqv.js → archive-plugin-Dy6lsTHw.js} +1 -1
  9. package/dist/gateway/static/root/assets/{attachment-load-DghwhYe0.js → attachment-load-qOtBYR6Y.js} +1 -1
  10. package/dist/gateway/static/root/assets/{automation-suggestion-card-DYmESgwl.js → automation-suggestion-card-BFH-RfaV.js} +1 -1
  11. package/dist/gateway/static/root/assets/automations-page-B8JTjkCr.js +4 -0
  12. package/dist/gateway/static/root/assets/{binary-plugins-DSbPKdWX.js → binary-plugins-DJvi_thc.js} +1 -1
  13. package/dist/gateway/static/root/assets/{block-editor-CoZ-_np-.js → block-editor-DlMnizlt.js} +4 -4
  14. package/dist/gateway/static/root/assets/browser-settings-page-slHLiZgi.js +8 -0
  15. package/dist/gateway/static/root/assets/capability-presets-api-D4q7vHVJ.js +1 -0
  16. package/dist/gateway/static/root/assets/capability-presets-settings-panel-Dng8Grpv.js +1 -0
  17. package/dist/gateway/static/root/assets/channel-recipient-api-BrW5Kcgc.js +1 -0
  18. package/dist/gateway/static/root/assets/channels-settings-KIsISXw0.js +1 -0
  19. package/dist/gateway/static/root/assets/{code-editor-gbRgS14t.js → code-editor--tMO38Tr.js} +1 -1
  20. package/dist/gateway/static/root/assets/connectors-page-C5fx4Qs9.js +2 -0
  21. package/dist/gateway/static/root/assets/desktop-pet-Jmdn6q47.js +1 -0
  22. package/dist/gateway/static/root/assets/{desktop-pet-settings-npJ0Oh5p.js → desktop-pet-settings-B-u63N4e.js} +1 -1
  23. package/dist/gateway/static/root/assets/{directory-picker-path-field-BR2ItBuf.js → directory-picker-path-field-8p1ehIHn.js} +1 -1
  24. package/dist/gateway/static/root/assets/dreaming-settings-CCkKP-I4.js +3 -0
  25. package/dist/gateway/static/root/assets/{extension-debug-page-Tl0f1rNv.js → extension-debug-page-DJ1ABK95.js} +1 -1
  26. package/dist/gateway/static/root/assets/{extension-page-Ck7QuwE3.js → extension-page-CP9P2lGM.js} +1 -1
  27. package/dist/gateway/static/root/assets/extension-settings-page-DnhU-tx0.js +1 -0
  28. package/dist/gateway/static/root/assets/fetch-BMjlW0g1.js +1 -0
  29. package/dist/gateway/static/root/assets/gateway-config-api-CjxDn46s.js +1 -0
  30. package/dist/gateway/static/root/assets/gateway-settings-TING7224.js +1 -0
  31. package/dist/gateway/static/root/assets/{gateway-startup-retry-Yh8h3hkj.js → gateway-startup-retry-CY5W2Pp4.js} +1 -1
  32. package/dist/gateway/static/root/assets/goal-create-dialog-2lPbGfp3.js +1 -0
  33. package/dist/gateway/static/root/assets/goal-detail-page-DHWVRafk.js +4 -0
  34. package/dist/gateway/static/root/assets/goals-config-api-BqhuxG8P.js +1 -0
  35. package/dist/gateway/static/root/assets/goals-page-CMk-9ZYN.js +2 -0
  36. package/dist/gateway/static/root/assets/goals-settings-BHzOAU_l.js +1 -0
  37. package/dist/gateway/static/root/assets/heartbeat-settings-BQIm0P3V.js +1 -0
  38. package/dist/gateway/static/root/assets/{html-workspace-editor-DV90ddkE.js → html-workspace-editor-COqmtESs.js} +1 -1
  39. package/dist/gateway/static/root/assets/index-C4k6QSXw.js +257 -0
  40. package/dist/gateway/static/root/assets/index-EKmpPvZj.css +1 -0
  41. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CfQrt_Rb.js → keyboard-shortcuts-settings-BrENZzM7.js} +1 -1
  42. package/dist/gateway/static/root/assets/logs-page-BiL302Ve.js +2 -0
  43. package/dist/gateway/static/root/assets/{markdown-editor-BFOjBBla.js → markdown-editor-jD1LPiP-.js} +2 -2
  44. package/dist/gateway/static/root/assets/{markdown-split-BwiMdCf_.js → markdown-split-BYF4ReGM.js} +1 -1
  45. package/dist/gateway/static/root/assets/{media-plugins-DhoizyZv.js → media-plugins-CpQDz-QJ.js} +1 -1
  46. package/dist/gateway/static/root/assets/messages-YzjnURPJ.js +3 -0
  47. package/dist/gateway/static/root/assets/models-hub-panel-CFPpl3Cq.js +2 -0
  48. package/dist/gateway/static/root/assets/notes-page-BurgcdVZ.js +1 -0
  49. package/dist/gateway/static/root/assets/notes-workbench-BAELRM_O.js +2 -0
  50. package/dist/gateway/static/root/assets/{page-tabs-DDC2t4Z8.js → page-tabs-RnYYOIWO.js} +1 -1
  51. package/dist/gateway/static/root/assets/{preview-open-alternatives-BTmk-XDM.js → preview-open-alternatives-CTRt06Ri.js} +1 -1
  52. package/dist/gateway/static/root/assets/project-detail-page-iXX1Ceo2.js +1 -0
  53. package/dist/gateway/static/root/assets/projects-page-GDVTFAY7.js +1 -0
  54. package/dist/gateway/static/root/assets/remote-access-hub-BUrbUnwv.js +1 -0
  55. package/dist/gateway/static/root/assets/{save-bar-controls-DqU-yKIh.js → save-bar-controls-c4pZeikq.js} +1 -1
  56. package/dist/gateway/static/root/assets/{schedule-field-CUttkoSB.js → schedule-field-Cb6R7iuP.js} +1 -1
  57. package/dist/gateway/static/root/assets/{schema-form-CVSQA9nI.js → schema-form-BqET_hEP.js} +1 -1
  58. package/dist/gateway/static/root/assets/sessions-page-CiOreA2k.js +1 -0
  59. package/dist/gateway/static/root/assets/settings-advanced-gate-C-qvptlu.js +1 -0
  60. package/dist/gateway/static/root/assets/{settings-collapsible-section-CK7ogS-P.js → settings-collapsible-section-DuOvqNsI.js} +1 -1
  61. package/dist/gateway/static/root/assets/{settings-form-section-Bugp38Fa.js → settings-form-section-DptSsbWd.js} +1 -1
  62. package/dist/gateway/static/root/assets/settings-loading-skeleton-BlVfBCb9.js +1 -0
  63. package/dist/gateway/static/root/assets/{settings-page-layout-DBRWwdhh.js → settings-page-layout-DVt69dJJ.js} +1 -1
  64. package/dist/gateway/static/root/assets/settings-page-xQx2Pkg5.js +1 -0
  65. package/dist/gateway/static/root/assets/setup-status-panel-DWB8VdLK.js +1 -0
  66. package/dist/gateway/static/root/assets/share-preview-page-8m_ACH0z.js +2 -0
  67. package/dist/gateway/static/root/assets/shares-settings-CgxfhNxI.js +1 -0
  68. package/dist/gateway/static/root/assets/skill-reload-api-BBFUOxmf.js +1 -0
  69. package/dist/gateway/static/root/assets/skills-page-bo695odu.js +2 -0
  70. package/dist/gateway/static/root/assets/{system-settings-panel-DJ6YuLqR.js → system-settings-panel-CW22OkZ4.js} +1 -1
  71. package/dist/gateway/static/root/assets/{typed-models-lib-B0T7N8Km.js → typed-models-lib-BqpGAKxV.js} +1 -1
  72. package/dist/gateway/static/root/assets/url-DFGNSBNT.js +1 -0
  73. package/dist/gateway/static/root/assets/use-channel-catalog-CPdJ0o0i.js +1 -0
  74. package/dist/gateway/static/root/assets/user-profile-settings-panel-CERVLuaW.js +1 -0
  75. package/dist/gateway/static/root/assets/{utils-CehXcWAY.js → utils-BnmysurA.js} +1 -1
  76. package/dist/gateway/static/root/assets/vendor-codemirror-C1WKjCk5.js +45 -0
  77. package/dist/gateway/static/root/assets/voice-api-key-field-Jr3jvPcB.js +1 -0
  78. package/dist/gateway/static/root/assets/work-item-detail-page-B-8rex4u.js +1 -0
  79. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-c4jeaohQ.js → workflow-run-setup-panel-Ci9GSPnS.js} +2 -2
  80. package/dist/gateway/static/root/assets/{workflow-start-dialog-ENRHjoqa.js → workflow-start-dialog-BhDj8pqH.js} +1 -1
  81. package/dist/gateway/static/root/assets/workflows-page-Brb3UGvs.js +18 -0
  82. package/dist/gateway/static/root/index.html +7 -6
  83. package/dist/package.js +1 -1
  84. package/dist/src/agent/agent-manager.d.ts +3 -0
  85. package/dist/src/agent/agent-manager.js +14 -6
  86. package/dist/src/agent/agent-manager.js.map +1 -1
  87. package/dist/src/agent/capabilities/definitions.d.ts +14 -0
  88. package/dist/src/agent/capabilities/definitions.js +19 -0
  89. package/dist/src/agent/capabilities/definitions.js.map +1 -1
  90. package/dist/src/agent/goals/post-turn.js +23 -2
  91. package/dist/src/agent/goals/post-turn.js.map +1 -1
  92. package/dist/src/agent/messaging/command-handler.d.ts +4 -0
  93. package/dist/src/agent/messaging/command-handler.js +6 -0
  94. package/dist/src/agent/messaging/command-handler.js.map +1 -1
  95. package/dist/src/agent/service.d.ts +2 -0
  96. package/dist/src/agent/service.js +23 -0
  97. package/dist/src/agent/service.js.map +1 -1
  98. package/dist/src/agent/skills/hub-lock.d.ts +5 -5
  99. package/dist/src/agent/skills/hub-lock.js +12 -12
  100. package/dist/src/agent/skills/hub-lock.js.map +1 -1
  101. package/dist/src/agent/skills/hub-pull.d.ts +15 -0
  102. package/dist/src/agent/skills/hub-pull.js +299 -24
  103. package/dist/src/agent/skills/hub-pull.js.map +1 -1
  104. package/dist/src/agent/skills/index.js +4 -40
  105. package/dist/src/agent/skills/index.js.map +1 -1
  106. package/dist/src/agent/skills/install-target.d.ts +3 -0
  107. package/dist/src/agent/skills/install-target.js +11 -0
  108. package/dist/src/agent/skills/install-target.js.map +1 -0
  109. package/dist/src/agent/skills/managed-store.d.ts +5 -3
  110. package/dist/src/agent/skills/managed-store.js +10 -9
  111. package/dist/src/agent/skills/managed-store.js.map +1 -1
  112. package/dist/src/agent/skills/marketplace/adapters/store/adapter.js +5 -3
  113. package/dist/src/agent/skills/marketplace/adapters/store/adapter.js.map +1 -1
  114. package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.d.ts +21 -1
  115. package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.js +62 -6
  116. package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.js.map +1 -1
  117. package/dist/src/agent/skills/marketplace/resolve-adapter.js +1 -1
  118. package/dist/src/agent/skills/marketplace/resolve-adapter.js.map +1 -1
  119. package/dist/src/agent/skills/skill-manage-ops.js +2 -2
  120. package/dist/src/agent/skills/skill-manage-ops.js.map +1 -1
  121. package/dist/src/agent/skills/skill-manager.js +1 -6
  122. package/dist/src/agent/skills/skill-manager.js.map +1 -1
  123. package/dist/src/agent/skills/workspace-skills-dir.d.ts +1 -0
  124. package/dist/src/agent/skills/workspace-skills-dir.js +5 -1
  125. package/dist/src/agent/skills/workspace-skills-dir.js.map +1 -1
  126. package/dist/src/agent/tools/automation-tool.d.ts +6 -6
  127. package/dist/src/agent/tools/browser/tool/schemas.d.ts +20 -20
  128. package/dist/src/agent/tools/composio-tool.d.ts +3 -3
  129. package/dist/src/agent/tools/desktop-pet-tool.d.ts +7 -7
  130. package/dist/src/agent/tools/factory.d.ts +3 -0
  131. package/dist/src/agent/tools/factory.js +6 -1
  132. package/dist/src/agent/tools/factory.js.map +1 -1
  133. package/dist/src/agent/tools/goal-tool.d.ts +16 -16
  134. package/dist/src/agent/tools/index.d.ts +1 -0
  135. package/dist/src/agent/tools/index.js +2 -1
  136. package/dist/src/agent/tools/skill-install-tool.d.ts +28 -0
  137. package/dist/src/agent/tools/skill-install-tool.js +81 -0
  138. package/dist/src/agent/tools/skill-install-tool.js.map +1 -0
  139. package/dist/src/agent/tools/skill-manage-tool.js +3 -6
  140. package/dist/src/agent/tools/skill-manage-tool.js.map +1 -1
  141. package/dist/src/agent/tools/tool-manual-tool.d.ts +2 -2
  142. package/dist/src/agent/tools/xopc-use-tool.d.ts +5 -5
  143. package/dist/src/automations/domain/types.d.ts +1 -0
  144. package/dist/src/automations/draft/automation-draft-service.js +1 -1
  145. package/dist/src/automations/service/automation-service.js +9 -0
  146. package/dist/src/automations/service/automation-service.js.map +1 -1
  147. package/dist/src/browser/schemas.d.ts +52 -52
  148. package/dist/src/capabilities/store-connector.d.ts +17 -0
  149. package/dist/src/capabilities/store-connector.js +191 -0
  150. package/dist/src/capabilities/store-connector.js.map +1 -0
  151. package/dist/src/chat-commands/builtins/skill.d.ts +1 -0
  152. package/dist/src/chat-commands/builtins/skill.js +132 -0
  153. package/dist/src/chat-commands/builtins/skill.js.map +1 -0
  154. package/dist/src/chat-commands/context.d.ts +3 -0
  155. package/dist/src/chat-commands/context.js +2 -0
  156. package/dist/src/chat-commands/context.js.map +1 -1
  157. package/dist/src/chat-commands/index.d.ts +1 -0
  158. package/dist/src/chat-commands/index.js +3 -1
  159. package/dist/src/chat-commands/index.js.map +1 -1
  160. package/dist/src/chat-commands/types.d.ts +17 -0
  161. package/dist/src/cli/command-loaders.js +1 -0
  162. package/dist/src/cli/command-loaders.js.map +1 -1
  163. package/dist/src/cli/command-manifest.js +4 -0
  164. package/dist/src/cli/command-manifest.js.map +1 -1
  165. package/dist/src/cli/commands/agent.js +2 -2
  166. package/dist/src/cli/commands/connectors.d.ts +4 -0
  167. package/dist/src/cli/commands/connectors.js +96 -0
  168. package/dist/src/cli/commands/connectors.js.map +1 -0
  169. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  170. package/dist/src/cli/commands/extension-marketplace.js +1 -1
  171. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  172. package/dist/src/cli/commands/models.js +1 -1
  173. package/dist/src/cli/commands/onboard.js +1 -1
  174. package/dist/src/cli/commands/profile.js +1 -1
  175. package/dist/src/cli/commands/skills.js +1 -1
  176. package/dist/src/cli/commands/tunnel.js +1 -1
  177. package/dist/src/cli/commands/update.js +1 -1
  178. package/dist/src/cli/extension-cli-register.js +1 -1
  179. package/dist/src/config/agent-profile.js +1 -1
  180. package/dist/src/config/index.js +1 -1
  181. package/dist/src/config/schema.js +2 -2
  182. package/dist/src/config/schema.js.map +1 -1
  183. package/dist/src/connectors/health.js +1 -1
  184. package/dist/src/connectors/install.js +3 -1
  185. package/dist/src/connectors/install.js.map +1 -1
  186. package/dist/src/connectors/materialize.js +2 -0
  187. package/dist/src/connectors/materialize.js.map +1 -1
  188. package/dist/src/connectors/types.d.ts +19 -1
  189. package/dist/src/extensions/install.js +1 -1
  190. package/dist/src/extensions/types/manifest.d.ts +1 -1
  191. package/dist/src/extensions/update.js +5 -3
  192. package/dist/src/extensions/update.js.map +1 -1
  193. package/dist/src/gateway/agents-admin.js +1 -1
  194. package/dist/src/gateway/chat-stream/mapper.js +5 -1
  195. package/dist/src/gateway/chat-stream/mapper.js.map +1 -1
  196. package/dist/src/gateway/chat-stream/protocol.d.ts +2 -0
  197. package/dist/src/gateway/hono/lib/config-payload.js +1 -1
  198. package/dist/src/gateway/hono/lib/config-payload.js.map +1 -1
  199. package/dist/src/gateway/hono/middleware/auth.d.ts +2 -2
  200. package/dist/src/gateway/hono/middleware/logger.d.ts +1 -1
  201. package/dist/src/gateway/hono/middleware/route-errors.d.ts +1 -1
  202. package/dist/src/gateway/hono/middleware/strict-rate-limit.d.ts +2 -2
  203. package/dist/src/gateway/hono/routes/capabilities.d.ts +3 -0
  204. package/dist/src/gateway/hono/routes/capabilities.js +79 -0
  205. package/dist/src/gateway/hono/routes/capabilities.js.map +1 -0
  206. package/dist/src/gateway/hono/routes/commands-skills.js +81 -3
  207. package/dist/src/gateway/hono/routes/commands-skills.js.map +1 -1
  208. package/dist/src/gateway/hono/routes/connectors.js +2 -2
  209. package/dist/src/gateway/hono/routes/goals.js +212 -3
  210. package/dist/src/gateway/hono/routes/goals.js.map +1 -1
  211. package/dist/src/gateway/hono/routes/index.js +2 -0
  212. package/dist/src/gateway/hono/routes/index.js.map +1 -1
  213. package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
  214. package/dist/src/gateway/hono/routes/lazy-bundles.js.map +1 -1
  215. package/dist/src/gateway/hono/routes/mcp.js +1 -1
  216. package/dist/src/gateway/hono/routes/mobile.d.ts +3 -0
  217. package/dist/src/gateway/hono/routes/mobile.js +113 -0
  218. package/dist/src/gateway/hono/routes/mobile.js.map +1 -0
  219. package/dist/src/gateway/hono/routes/projects.js +17 -0
  220. package/dist/src/gateway/hono/routes/projects.js.map +1 -1
  221. package/dist/src/gateway/hono/routes/workspace.js +4 -1
  222. package/dist/src/gateway/hono/routes/workspace.js.map +1 -1
  223. package/dist/src/gateway/hono/sse.d.ts +3 -3
  224. package/dist/src/gateway/run-loop.js +1 -1
  225. package/dist/src/gateway/service/marketplace-service.d.ts +23 -1
  226. package/dist/src/gateway/service/marketplace-service.js +57 -6
  227. package/dist/src/gateway/service/marketplace-service.js.map +1 -1
  228. package/dist/src/gateway/service.d.ts +2 -0
  229. package/dist/src/gateway/service.js +12 -2
  230. package/dist/src/gateway/service.js.map +1 -1
  231. package/dist/src/goals/goal-contract-draft.d.ts +15 -0
  232. package/dist/src/goals/goal-contract-draft.js +114 -0
  233. package/dist/src/goals/goal-contract-draft.js.map +1 -0
  234. package/dist/src/goals/goal-evidence-review.d.ts +15 -0
  235. package/dist/src/goals/goal-evidence-review.js +91 -0
  236. package/dist/src/goals/goal-evidence-review.js.map +1 -0
  237. package/dist/src/goals/goal-runner.js +3 -1
  238. package/dist/src/goals/goal-runner.js.map +1 -1
  239. package/dist/src/goals/goal-service.d.ts +17 -1
  240. package/dist/src/goals/goal-service.js +44 -3
  241. package/dist/src/goals/goal-service.js.map +1 -1
  242. package/dist/src/goals/goal-store.d.ts +18 -1
  243. package/dist/src/goals/goal-store.js +190 -1
  244. package/dist/src/goals/goal-store.js.map +1 -1
  245. package/dist/src/goals/index.d.ts +4 -0
  246. package/dist/src/goals/index.js +3 -1
  247. package/dist/src/goals/types.d.ts +42 -0
  248. package/dist/src/mcp/channel-bridge.js +1 -1
  249. package/dist/src/mobile/notification-service.d.ts +8 -0
  250. package/dist/src/mobile/notification-service.js +139 -0
  251. package/dist/src/mobile/notification-service.js.map +1 -0
  252. package/dist/src/mobile/notification-store.d.ts +28 -0
  253. package/dist/src/mobile/notification-store.js +134 -0
  254. package/dist/src/mobile/notification-store.js.map +1 -0
  255. package/dist/src/mobile/notification-types.d.ts +37 -0
  256. package/dist/src/mobile/notification-types.js +11 -0
  257. package/dist/src/mobile/notification-types.js.map +1 -0
  258. package/dist/src/storage/sqlite/migrations/026_goal_contracts.sql +10 -0
  259. package/dist/src/storage/sqlite/migrations/027_mobile_notifications.sql +43 -0
  260. package/dist/src/storage/sqlite/migrations/028_goal_evidence_requirements.sql +47 -0
  261. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  262. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  263. package/dist/src/storage/sqlite/migrations/runner.js.map +1 -1
  264. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  265. package/dist/src/storage/sqlite/schema.js +1 -1
  266. package/dist/src/storage/sqlite/schema.sql +44 -0
  267. package/dist/src/tui/tui-startup-resources.js +1 -1
  268. package/package.json +1 -1
  269. package/skills/THIRD_PARTY_NOTICES.md +16 -0
  270. package/skills/creative/algorithmic-art/SKILL.md +37 -0
  271. package/skills/creative/algorithmic-art/templates/generator-template.js +27 -0
  272. package/skills/creative/algorithmic-art/templates/viewer.html +27 -0
  273. package/skills/documents/doc-coauthoring/SKILL.md +40 -0
  274. package/skills/documents/doc-coauthoring/references/reader-review.md +9 -0
  275. package/skills/documents/docx/SKILL.md +40 -0
  276. package/skills/documents/docx/references/editing-checklist.md +8 -0
  277. package/skills/documents/docx/scripts/inspect_ooxml.py +36 -0
  278. package/skills/documents/docx/scripts/render_docx.py +33 -0
  279. package/skills/documents/pdf/SKILL.md +47 -0
  280. package/skills/documents/pdf/references/operations.md +16 -0
  281. package/skills/documents/pdf/scripts/inspect_pdf.py +41 -0
  282. package/skills/documents/pdf/scripts/render_pdf.py +32 -0
  283. package/skills/documents/pptx/SKILL.md +41 -0
  284. package/skills/documents/pptx/references/qa-checklist.md +6 -0
  285. package/skills/documents/pptx/scripts/inspect_ooxml.py +34 -0
  286. package/skills/documents/pptx/scripts/render_pptx.py +33 -0
  287. package/skills/engineering/define-goal/SKILL.md +41 -0
  288. package/skills/engineering/define-goal/references/objective-rubric.md +12 -0
  289. package/dist/gateway/static/root/assets/agents-k59l7NMb.js +0 -2
  290. package/dist/gateway/static/root/assets/app-management-settings-panel-DeQsTsyy.js +0 -1
  291. package/dist/gateway/static/root/assets/apps-page-BG9b4abG.js +0 -1
  292. package/dist/gateway/static/root/assets/automations-page-De8mVutL.js +0 -4
  293. package/dist/gateway/static/root/assets/browser-settings-page-C_ZRa4LF.js +0 -8
  294. package/dist/gateway/static/root/assets/capability-presets-api-hny224j-.js +0 -1
  295. package/dist/gateway/static/root/assets/capability-presets-settings-panel-Drc0qLsw.js +0 -1
  296. package/dist/gateway/static/root/assets/channel-recipient-api-DAlOHxKJ.js +0 -1
  297. package/dist/gateway/static/root/assets/channels-settings-CA20zBV9.js +0 -1
  298. package/dist/gateway/static/root/assets/connectors-page-qMyMB5te.js +0 -2
  299. package/dist/gateway/static/root/assets/desktop-pet-XG6Vb_fZ.js +0 -1
  300. package/dist/gateway/static/root/assets/dreaming-settings-CkUZ997f.js +0 -3
  301. package/dist/gateway/static/root/assets/extension-settings-page-3RMhQtZ3.js +0 -1
  302. package/dist/gateway/static/root/assets/fetch-pg2ErdAk.js +0 -1
  303. package/dist/gateway/static/root/assets/gateway-config-api-DbG97ia2.js +0 -1
  304. package/dist/gateway/static/root/assets/gateway-settings-B8cyqKk-.js +0 -1
  305. package/dist/gateway/static/root/assets/goal-create-dialog-DmeW7Zz3.js +0 -1
  306. package/dist/gateway/static/root/assets/goal-detail-page-DrTyGbVD.js +0 -1
  307. package/dist/gateway/static/root/assets/goals-config-api-CxCWGIBB.js +0 -1
  308. package/dist/gateway/static/root/assets/goals-page-DV1bJhIh.js +0 -2
  309. package/dist/gateway/static/root/assets/goals-settings-9DrfOkP5.js +0 -1
  310. package/dist/gateway/static/root/assets/heartbeat-settings-KaDpZrv0.js +0 -1
  311. package/dist/gateway/static/root/assets/index-C2F0Clvm.js +0 -256
  312. package/dist/gateway/static/root/assets/index-COQSX5d_.css +0 -1
  313. package/dist/gateway/static/root/assets/logs-page-C9dpiNTF.js +0 -2
  314. package/dist/gateway/static/root/assets/messages-DmnbiNxU.js +0 -3
  315. package/dist/gateway/static/root/assets/models-hub-panel-zdCdmBmH.js +0 -2
  316. package/dist/gateway/static/root/assets/notes-page-MpGeFfPt.js +0 -1
  317. package/dist/gateway/static/root/assets/notes-workbench-DYCM3yd2.js +0 -2
  318. package/dist/gateway/static/root/assets/project-detail-page-Cu0ElRnS.js +0 -1
  319. package/dist/gateway/static/root/assets/projects-page-DakNaUjZ.js +0 -1
  320. package/dist/gateway/static/root/assets/remote-access-hub-DYKjt7L9.js +0 -1
  321. package/dist/gateway/static/root/assets/sessions-page-CcGHDsz1.js +0 -1
  322. package/dist/gateway/static/root/assets/settings-advanced-gate-CuFdeKNu.js +0 -1
  323. package/dist/gateway/static/root/assets/settings-page-0AJoUvxi.js +0 -1
  324. package/dist/gateway/static/root/assets/setup-status-panel-D6a_hEk7.js +0 -1
  325. package/dist/gateway/static/root/assets/share-preview-page-BtsuETKF.js +0 -2
  326. package/dist/gateway/static/root/assets/shares-settings-CcEFT7S9.js +0 -1
  327. package/dist/gateway/static/root/assets/skill-reload-api-BcN_RuTD.js +0 -1
  328. package/dist/gateway/static/root/assets/skills-page-BbRZZZA5.js +0 -2
  329. package/dist/gateway/static/root/assets/use-channel-catalog-C6vrxdzZ.js +0 -1
  330. package/dist/gateway/static/root/assets/user-profile-settings-panel-DZ0nKMgj.js +0 -1
  331. package/dist/gateway/static/root/assets/vendor-codemirror-BvNgyE1Q.js +0 -45
  332. package/dist/gateway/static/root/assets/voice-api-key-field-2QKflCx8.js +0 -1
  333. package/dist/gateway/static/root/assets/work-item-detail-page-DfJnuWq1.js +0 -1
  334. package/dist/gateway/static/root/assets/workflows-page-BJwwFTm_.js +0 -18
@@ -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{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-DmnbiNxU.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s,i as c,n as l}from"./fetch-pg2ErdAk.js";import{r as u}from"./toast-z0toXu32.js";import{$r as d,Ba as f,Cc as p,Cs as m,Do as h,El as g,Fr as _,Ga as v,Ha as y,Ir as b,Lr as x,Ms as S,Oo as C,Pr as w,Qr as T,Ra as E,To as D,Ua as O,Us as k,Va as A,Vc as j,Wa as ee,Xc as M,_c as N,ao as P,bs as F,cs as I,ds as te,ei as L,eo as R,go as z,ha as ne,io as re,jc as ie,ma as ae,mo as oe,nc as B,ni as se,no as V,ns as ce,os as le,ti as ue,tl as de,vi as fe,wo as H,xs as pe,yo as U,za as me,zo as W,zr as he}from"./index-C2F0Clvm.js";import{n as ge,t as _e}from"./settings-form-section-Bugp38Fa.js";import{t as ve}from"./page-tabs-DDC2t4Z8.js";var G=e(t(),1),K=n(),q=r(),J=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`,ye=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function be(e,t){return t.some(t=>t.connectorId===e.id)}function Y(e,t){return t[e]??e}function X(e,t){return t.connectorCategoryTemplate.replace(`{{category}}`,Y(e,t.connectorCategoryLabels))}function xe(){let e=(0,K.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(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.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:(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:i(`h-4 min-w-0 flex-1`,J)}),(0,q.jsx)(`div`,{className:i(`h-8 w-[4.5rem] shrink-0 rounded-lg`,J)})]}),(0,q.jsx)(`div`,{className:i(`h-3 w-full`,J)}),(0,q.jsx)(`div`,{className:i(`h-3 w-[88%]`,J)})]})})}),e[0]=t):t=e[0],t}function Se(){let e=(0,K.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,q.jsx)(`div`,{className:i(`h-4 w-48 max-w-full`,J)}),(0,q.jsx)(`div`,{className:i(`h-3 w-72 max-w-full`,J)})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[t,(0,q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,q.jsx)(`div`,{className:i(`h-9 w-20 rounded-lg`,J)}),(0,q.jsx)(`div`,{className:i(`h-9 w-20 rounded-lg`,J)})]})]}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,q.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:[n,(0,q.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,q.jsx)(`div`,{className:i(`h-8 w-20 rounded-md`,J)}),(0,q.jsx)(`div`,{className:i(`h-8 w-24 rounded-md`,J)}),(0,q.jsx)(`div`,{className:i(`h-8 w-28 rounded-md`,J)})]}),(0,q.jsx)(`div`,{className:i(`mt-3 h-20 rounded-xl`,J)})]}),e[2]=r):r=e[2],r}function Ce(e){let t=(0,K.c)(69),{connector:n,installed:r,onInstall:a,onOpenDetails:o,t:s}=e,c;t[0]!==n.category||t[1]!==s?(c=X(n.category,s),t[0]=n.category,t[1]=s,t[2]=c):c=t[2];let l=c,u,d,f,p,m,h,g,_,v,y;if(t[3]!==l||t[4]!==n||t[5]!==r||t[6]!==a||t[7]!==o||t[8]!==s.install||t[9]!==s.installedBadge){let e=n.capabilities.slice(0,4),c=Math.max(0,n.capabilities.length-e.length),b;t[20]!==n||t[21]!==a||t[22]!==s.install?(b=e=>(0,q.jsxs)(D,{type:`button`,variant:`primary`,className:i(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:e=>{e.stopPropagation(),a(n)},children:[(0,q.jsx)(S,{className:`size-4`}),s.install]}),t[20]=n,t[21]=a,t[22]=s.install,t[23]=b):b=t[23],u=b;let x;t[24]!==n||t[25]!==o?(x=e=>{!o||e.currentTarget!==e.target||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),o(n))},t[24]=n,t[25]=o,t[26]=x):x=t[26];let C=x,w=o?`cursor-pointer`:null;t[27]===w?g=t[28]:(g=i(`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`,w),t[27]=w,t[28]=g),_=o?`button`:void 0,v=o?0:void 0,t[29]!==n||t[30]!==o?(y=()=>o?.(n),t[29]=n,t[30]=o,t[31]=y):y=t[31],d=C,f=`flex min-w-0 flex-1 flex-col`;let T;t[32]===n.displayName?T=t[33]:(T=(0,q.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[32]=n.displayName,t[33]=T);let E;t[34]===l?E=t[35]:(E=(0,q.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:l}),t[34]=l,t[35]=E);let O;t[36]!==T||t[37]!==E?(O=(0,q.jsx)(`div`,{className:`flex min-w-0 items-start gap-3`,children:(0,q.jsxs)(`div`,{className:`min-w-0`,children:[T,E]})}),t[36]=T,t[37]=E,t[38]=O):O=t[38];let k;t[39]!==r||t[40]!==u?(k=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:u()}),t[39]=r,t[40]=u,t[41]=k):k=t[41];let A;t[42]!==r||t[43]!==s.installedBadge?(A=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)(M,{className:`size-3`,"aria-hidden":!0}),s.installedBadge]}):null,t[42]=r,t[43]=s.installedBadge,t[44]=A):A=t[44];let j;t[45]!==k||t[46]!==A?(j=(0,q.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[k,A]}),t[45]=k,t[46]=A,t[47]=j):j=t[47],t[48]!==O||t[49]!==j?(p=(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[O,j]}),t[48]=O,t[49]=j,t[50]=p):p=t[50],t[51]===n.description?m=t[52]:(m=(0,q.jsx)(`p`,{className:`mt-4 line-clamp-2 text-sm leading-6 text-fg-muted`,title:n.description,children:n.description}),t[51]=n.description,t[52]=m),h=e.length>0?(0,q.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-1.5`,children:[e.map(we),c>0?(0,q.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,c]}):null]}):null,t[3]=l,t[4]=n,t[5]=r,t[6]=a,t[7]=o,t[8]=s.install,t[9]=s.installedBadge,t[10]=u,t[11]=d,t[12]=f,t[13]=p,t[14]=m,t[15]=h,t[16]=g,t[17]=_,t[18]=v,t[19]=y}else u=t[10],d=t[11],f=t[12],p=t[13],m=t[14],h=t[15],g=t[16],_=t[17],v=t[18],y=t[19];let b;t[53]!==f||t[54]!==p||t[55]!==m||t[56]!==h?(b=(0,q.jsxs)(`div`,{className:f,children:[p,m,h]}),t[53]=f,t[54]=p,t[55]=m,t[56]=h,t[57]=b):b=t[57];let x;t[58]!==r||t[59]!==u?(x=r?null:(0,q.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:u(`w-full`)}),t[58]=r,t[59]=u,t[60]=x):x=t[60];let C;return t[61]!==d||t[62]!==b||t[63]!==x||t[64]!==g||t[65]!==_||t[66]!==v||t[67]!==y?(C=(0,q.jsxs)(`div`,{className:g,role:_,tabIndex:v,onClick:y,onKeyDown:d,children:[b,x]}),t[61]=d,t[62]=b,t[63]=x,t[64]=g,t[65]=_,t[66]=v,t[67]=y,t[68]=C):C=t[68],C}function we(e){return(0,q.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:e},e)}function Z(e,t){if(!e.payload)throw Error(e.error??t);return e.payload}async function Te(){return Z(await l(c(`/api/connectors/catalog`)),`Could not load connector catalog.`).connectors}async function Ee(){return Z(await l(c(`/api/connectors/catalog`)),`Could not load connector registries.`).registries??[]}async function De(){return Z(await l(c(`/api/connectors/installed`)),`Could not load installed connectors.`).instances}var Q=new Map,Oe=300*1e3;async function ke(e,t=`all`,n){let r=e.trim(),i=t.trim()||`all`,a=n?.browse??!1,o=Math.max(n?.page??1,1),s=Math.max(n?.pageSize??24,1),u=`${i}:${r}:${a?`browse`:`search`}:${o}:${s}`,d=Date.now(),f=Q.get(u);if(f&&f.expiresAt>d)return f.promise;let p=new URLSearchParams;r&&p.set(`q`,r),i!==`all`&&p.set(`source`,i),a&&p.set(`browse`,`1`),p.set(`page`,String(o)),p.set(`pageSize`,String(s));let m=l(c(`/api/connectors/registry/search?${p.toString()}`)).then(e=>{let t=Z(e,`Could not search connector registries.`),n=Math.max(0,...(t.results??[]).map(e=>e.totalPages??0))||void 0;return{connectors:t.connectors,totalPages:n}});Q.set(u,{expiresAt:d+Oe,promise:m});try{return await m}catch(e){throw Q.delete(u),e}}async function Ae(e){return Z(await l(c(`/api/connectors/${encodeURIComponent(e)}/oauth/start`),{method:`POST`}),`Could not start connector OAuth.`).oauth}async function je(e,t){return Z(await l(c(`/api/connectors/${encodeURIComponent(e)}/oauth/complete`),{method:`POST`,body:JSON.stringify({deviceCode:t})}),`Could not complete connector OAuth.`).oauth}async function Me(e,t){let n=await l(c(`/api/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify(t)});return ae(),Z(n,`Could not install connector.`).instance}async function Ne(e,t={}){return Z(await l(c(`/api/connectors/preview`),{method:`POST`,body:JSON.stringify({...t,definition:e})}),`Could not preview connector capabilities.`).preview}async function Pe(e,t){return Z(await l(c(`/api/connectors/${encodeURIComponent(e)}/config`),{method:`POST`,body:JSON.stringify(t)}),`Could not update connector config.`).instance}async function Fe(e){await l(c(`/api/connectors/${encodeURIComponent(e)}`),{method:`DELETE`}),ae()}async function Ie(e){return Z(await l(c(`/api/connectors/${encodeURIComponent(e)}/test`),{method:`POST`}),`Connector test failed.`)}async function Le(){return Z(await l(c(`/api/connectors/composio/connections`)),`Could not load Composio connections.`).connections}async function Re(e){return Z(await l(c(`/api/connectors/composio/${encodeURIComponent(e)}/authorize`),{method:`POST`}),`Could not start Composio authorization.`).oauth}async function ze(e){return Z(await l(c(`/api/connectors/composio/${encodeURIComponent(e)}/scope`)),`Could not load Composio scope.`).scope}async function Be(e,t){let n=await l(c(`/api/connectors/composio/${encodeURIComponent(e)}/scope`),{method:`POST`,body:JSON.stringify({scope:t})});return ae(),Z(n,`Could not update Composio scope.`).scope}async function Ve(e){return Z(await l(c(`/api/connectors/composio/${encodeURIComponent(e)}/tools`)),`Could not load Composio tools.`).tools}async function He(e=50){return Z(await l(c(`/api/connectors/composio/triggers?limit=${encodeURIComponent(String(e))}`)),`Could not load Composio trigger events.`).events}function Ue(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function We(e,t){return t.connectorCapabilityLabels[e]??e}function Ge(e,t){if(e.runtime.type===`mcp`)return Ue(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.id??e.runtime.channelId??e.runtime.toolkit??e.runtime.toolsetId??e.runtime.sourceKind??e.runtime.type;return Ue(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n})}function Ke(e,t){return e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function qe(e){return(e.setup.secrets??[]).filter(e=>e.required).length+(e.setup.config??[]).filter(e=>e.required).length}function Je(e){let t=(0,K.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(Ye),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 Ye(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 Xe({connector:e,installed:t,onClose:n,onInstall:r,t:a}){let[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(null),[u,d]=(0,G.useState)(null),p=qe(e),g=e.capabilities.slice(0,8),_=Math.max(0,e.capabilities.length-g.length),v=[...(e.setup.secrets??[]).map(e=>({key:`secret:${e.key}`,label:e.label,description:e.description,required:e.required,kind:a.connectorSetupSecret})),...(e.setup.config??[]).map(e=>({key:`config:${e.key}`,label:e.label,description:e.description,required:!!e.required,kind:a.connectorSetupConfig}))],b=async()=>{s(!0),d(null);try{l(await Ne(e))}catch(e){l(null),d(e instanceof Error?e.message:String(e))}finally{s(!1)}};return(0,q.jsx)(O,{open:!0,onOpenChange:e=>{e||n()},children:(0,q.jsxs)(y,{children:[(0,q.jsx)(A,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,q.jsxs)(me,{className:i(`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:`min-w-0`,children:[(0,q.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.source}),(0,q.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.kind}),t?(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)(M,{className:`size-3`,"aria-hidden":!0}),a.installedBadge]}):null]}),(0,q.jsx)(ee,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,q.jsx)(f,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:e.description})]}),(0,q.jsx)(E,{asChild:!0,children:(0,q.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,U.focusRingPanel),"aria-label":a.modalClose,children:[(0,q.jsx)(h,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`sr-only`,children:a.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)(C,{className:`size-3.5`,"aria-hidden":!0}),a.detailTools]}),(0,q.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:c?Ue(a.connectorPreviewToolsCount,{count:c.toolCount}):a.connectorPreviewUnknown})]}),(0,q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,q.jsx)(B,{className:`size-3.5`,"aria-hidden":!0}),a.detailPermissions]}),(0,q.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:Ke(e,a)})]}),(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)(ie,{className:`size-3.5`,"aria-hidden":!0}),a.connectorRequiredInputs]}),(0,q.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:Ue(a.connectorRequiredInputsCount,{count:p})})]})]}),(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:a.connectorCapabilitiesTitle}),(0,q.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[g.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:We(e,a)},e)),_>0?(0,q.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-subtle`,children:[`+`,_]}):null]}),(0,q.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:a.connectorCapabilitiesHint})]}),u?(0,q.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:u}):null,c?(0,q.jsxs)(`section`,{children:[(0,q.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.connectorPreviewTitle}),(0,q.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs font-medium`,c.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:c.ok?a.healthStatusHealthy:a.healthStatusLabels[c.status]??c.status})]}),(0,q.jsxs)(`div`,{className:`mb-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,q.jsx)(`div`,{className:`font-semibold text-fg`,children:c.toolCount}),(0,q.jsx)(`div`,{className:`text-fg-muted`,children:a.toolsMetric})]}),(0,q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,q.jsx)(`div`,{className:`font-semibold text-fg`,children:c.resourceCount}),(0,q.jsx)(`div`,{className:`text-fg-muted`,children:a.resourcesMetric})]}),(0,q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,q.jsx)(`div`,{className:`font-semibold text-fg`,children:c.promptCount}),(0,q.jsx)(`div`,{className:`text-fg-muted`,children:a.promptsMetric})]})]}),(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(Je,{title:a.detailTools,items:c.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,q.jsx)(Je,{title:a.detailResources,items:c.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,q.jsx)(Je,{title:a.detailPrompts,items:c.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??Ue(a.promptArgumentCount,{count:e.argumentCount})}))})]}),c.error?(0,q.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:c.error}):null,c.action?(0,q.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-subtle`,children:c.action}):null]}):null]}),(0,q.jsxs)(`aside`,{className:`space-y-3`,children:[(0,q.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,q.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,q.jsx)(B,{className:`size-4 text-accent`,"aria-hidden":!0}),a.detailPermissions]}),(0,q.jsx)(`p`,{className:`mt-2 text-sm font-medium text-fg`,children:Ke(e,a)})]}),(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)(ie,{className:`size-4 text-accent`,"aria-hidden":!0}),a.connectorSetupTitle]}),v.length>0?(0,q.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-lg border border-edge`,children:v.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:a.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:a.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)(le,{className:`size-4 text-accent`,"aria-hidden":!0}),a.connectorRuntimeTitle]}),(0,q.jsx)(`p`,{className:`mt-2 break-words text-xs leading-5 text-fg-muted`,children:Ge(e,a)})]})]})]})]}),(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)(E,{asChild:!0,children:(0,q.jsx)(D,{variant:`secondary`,children:a.modalClose})}),(0,q.jsxs)(D,{variant:`secondary`,disabled:o,onClick:()=>void b(),children:[o?(0,q.jsx)(k,{className:`size-4 animate-spin`}):(0,q.jsx)(C,{className:`size-4`}),a.connectorPreviewButton]}),t?(0,q.jsxs)(D,{variant:`secondary`,disabled:!0,children:[(0,q.jsx)(m,{className:`size-4`}),a.installedBadge]}):(0,q.jsxs)(D,{variant:`primary`,onClick:()=>{r(e),n()},children:[(0,q.jsx)(S,{className:`size-4`}),a.install]})]})]})]})})}var Ze=(0,G.memo)(function(e){let t=(0,K.c)(19),{loading:n,searchQuery:r,setSearchQuery:i,onReloadClick:a,onAddCustomServer:o,searchPlaceholder:s,addLabel:c,reloadLabel:l}=e,u;t[0]!==n||t[1]!==a||t[2]!==l?(u=(0,q.jsx)(fe,{className:`size-9 shrink-0 p-0`,loading:n,label:l,title:l,onClick:a}),t[0]=n,t[1]=a,t[2]=l,t[3]=u):u=t[3];let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,q.jsx)(I,{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[4]=d):d=t[4];let f;t[5]===i?f=t[6]:(f=e=>i(e.currentTarget.value),t[5]=i,t[6]=f);let p;t[7]!==s||t[8]!==r||t[9]!==f?(p=(0,q.jsxs)(`label`,{className:`relative flex min-h-9 min-w-0 max-w-sm cursor-text items-center rounded-pill border border-edge bg-surface-panel py-1.5 pl-9 pr-3 shadow-surface dark:bg-surface-hover/40 sm:max-w-md`,children:[d,(0,q.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:r,onChange:f,placeholder:s,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[7]=s,t[8]=r,t[9]=f,t[10]=p):p=t[10];let m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,q.jsx)(F,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[11]=m):m=t[11];let h;t[12]!==c||t[13]!==o?(h=(0,q.jsxs)(D,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,onClick:o,children:[m,c]}),t[12]=c,t[13]=o,t[14]=h):h=t[14];let g;return t[15]!==u||t[16]!==p||t[17]!==h?(g=(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[u,p,h]}),t[15]=u,t[16]=p,t[17]=h,t[18]=g):g=t[18],g}),Qe=/^([^:=]+)[:=](.*)$/;function $e(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=Qe.exec(t);r&&n.push({key:r[1].trim(),value:r[2].trim()})}return n.length>0?n:null}function et(e){let t={};for(let n of e){let e=n.key.trim();e&&(t[e]=n.value)}return Object.keys(t).length>0?t:void 0}function tt(e){if(!e||typeof e!=`object`)return[{key:``,value:``}];let t=Object.entries(e).map(([e,t])=>({key:e,value:t==null?``:String(t)}));return t.length>0?t:[{key:``,value:``}]}function nt(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 rt(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)||nt(t)&&(r[e]=t);return r}function it(e){let t=e.trim();if(t)return t.split(/\s+/).filter(Boolean)}function at(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=it(e.argsText);return n?.length&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envJson.trim()&&(t.env=at(e.envJson)),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}let t={url:e.url.trim(),transport:e.transport},n=et(e.headers);return n&&(t.headers=n),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}function st(e,t){let n=typeof t.url==`string`&&t.url.trim().length>0,r=typeof t.transport==`string`?t.transport.trim().toLowerCase():``,i=n?r===`sse`?`sse`:`streamable-http`:`stdio`,a=t.headers&&typeof t.headers==`object`&&!Array.isArray(t.headers)?t.headers:void 0;return{clientKey:e,id:e,transport:i,command:typeof t.command==`string`?t.command:``,argsText:Array.isArray(t.args)?t.args.map(String).join(` `):``,envJson:t.env&&typeof t.env==`object`?JSON.stringify(t.env,null,2):``,cwd:typeof t.cwd==`string`?t.cwd:typeof t.workingDirectory==`string`?t.workingDirectory:``,url:typeof t.url==`string`?t.url:``,headers:tt(a),connectionTimeoutMs:typeof t.connectionTimeoutMs==`number`&&Number.isFinite(t.connectionTimeoutMs)?t.connectionTimeoutMs:void 0}}function ct(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`stdio`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[{key:`Authorization`,value:``}],connectionTimeoutMs:void 0}}function lt(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)||nt(t)?[]:[st(e,t)]).sort((e,t)=>e.id.localeCompare(t.id)):[],a=typeof n.sessionIdleTtlMs==`number`?n.sessionIdleTtlMs:void 0;return{sessionIdleTtlMinutes:a==null?void 0:a===0?0:Math.round(a/6e4),servers:i}}function ut(e){return ot(e)}async function dt(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 l(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({mcp:r})}),ae()}function ft(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 pt(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 mt(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 ht(e,t){let n=await l(c(`/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=ft(n.payload.tools),i=pt(n.payload.resources),a=mt(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 gt(e){return e.connectionTimeoutMs==null||!Number.isFinite(e.connectionTimeoutMs)?``:String(Math.round(e.connectionTimeoutMs/1e3))}function _t(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 vt(e){if(e.transport===`stdio`){let t=e.command.trim();if(!t)return``;let n=e.argsText.trim();return n?`${t} ${n}`:t}return e.url.trim()}function $(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,n),e)}function yt({row:e,t,cs:n,onEdit:r,onRemove:i}){let[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)(null),p=vt(e),h=(0,G.useCallback)(async()=>{o(!0),f(null);try{let t=await ht(e.id.trim());u({toolCount:t.toolCount,resourceCount:t.resourceCount,promptCount:t.promptCount})}catch(e){f(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.id]),g=(0,G.useCallback)(async()=>{c(!0),f(null);try{await i()}catch(e){f(e instanceof Error?e.message:String(e)),c(!1)}},[i]);return(0,q.jsxs)(`div`,{className:`flex h-full min-h-[10.5rem] cursor-pointer flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`,onClick:r,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.id.trim()||t.cardUntitled}),(0,q.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:n.customBadge}),(0,q.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.transportLabels[e.transport]})]}),p?(0,q.jsx)(`p`,{className:`mt-3 line-clamp-2 break-all font-mono text-xs leading-5 text-fg-subtle`,title:p,children:p}):null,d?(0,q.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:d}):null,l?(0,q.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:$(n.customCapabilitySummary,{tools:String(l.toolCount),resources:String(l.resourceCount),prompts:String(l.promptCount)})}):null]}),(0,q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.connectorDetails}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsxs)(D,{variant:`secondary`,disabled:a,onClick:()=>void h(),children:[a?(0,q.jsx)(k,{className:`size-4 animate-spin`}):(0,q.jsx)(m,{className:`size-4`}),t.testConnection]}),(0,q.jsxs)(D,{variant:`ghost`,disabled:s,onClick:()=>void g(),children:[s?(0,q.jsx)(k,{className:`size-4 animate-spin`}):(0,q.jsx)(W,{className:`size-4`}),t.removeServer]})]})]})]})}function bt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function xt(e,t,n){let r=t.trim().toLowerCase();if(!r)return!0;let i=e.shortName||bt(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
2
- `).toLowerCase().includes(r)}function St(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Ct(e){let t=(0,K.c)(29),{tools:n,stripPrefix:r,searchPlaceholder:a,searchEmptyLabel:o}=e,[s,c]=(0,G.useState)(``),l;if(t[0]!==s||t[1]!==r||t[2]!==n){let e;t[4]!==s||t[5]!==r?(e=e=>xt(e,s,r),t[4]=s,t[5]=r,t[6]=e):e=t[6],l=n.filter(e),t[0]=s,t[1]=r,t[2]=n,t[3]=l}else l=t[3];let u=l,d;t[7]===s?d=t[8]:(d=s.trim(),t[7]=s,t[8]=d);let f=d.length>0,p;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,q.jsx)(I,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=p):p=t[9];let m,h;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=i(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg`,`placeholder:text-fg-subtle`,H),h=e=>c(e.target.value),t[10]=m,t[11]=h):(m=t[10],h=t[11]);let g;t[12]!==s||t[13]!==a?(g=(0,q.jsxs)(`div`,{className:`relative`,children:[p,(0,q.jsx)(`input`,{type:`search`,value:s,placeholder:a,"aria-label":a,className:m,onChange:h})]}),t[12]=s,t[13]=a,t[14]=g):g=t[14];let _;t[15]!==u.length||t[16]!==f||t[17]!==n.length?(_=f?(0,q.jsxs)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:[u.length,` / `,n.length]}):null,t[15]=u.length,t[16]=f,t[17]=n.length,t[18]=_):_=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]!==u||t[23]!==o||t[24]!==r?(y=(0,q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:u.length===0?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o}):(0,q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>{let n=e.shortName||St(e.name,r)||e.name||`?`,i=e.name||`tool-${t}`;return(0,q.jsxs)(`li`,{className:`min-w-0 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[(0,q.jsx)(`div`,{className:`truncate font-mono text-sm font-medium text-fg`,title:e.name===n?n:e.name,children:n}),e.description?(0,q.jsx)(`p`,{className:`mt-1 truncate text-xs leading-relaxed text-fg-muted`,title:e.description,children:e.description}):null]},i)})})}),t[22]=u,t[23]=o,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 wt(e){let t=(0,K.c)(38),{open:n,onOpenChange:r,serverId:a,title:o,subtitle:s,searchPlaceholder:c,searchEmptyLabel:l,emptyLabel:u,closeLabel:d,tools:p,stripPrefix:m}=e,g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,q.jsx)(A,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,P)}),t[0]=g):g=t[0];let _;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(_=i(`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`,re,`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)(C,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[2]=v):v=t[2];let b;t[3]===o?b=t[4]:(b=(0,q.jsxs)(ee,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[v,o]}),t[3]=o,t[4]=b);let x;t[5]!==a||t[6]!==s||t[7]!==p.length?(x=s.replace(`{{serverId}}`,a).replace(`{{count}}`,String(p.length)),t[5]=a,t[6]=s,t[7]=p.length,t[8]=x):x=t[8];let S;t[9]===x?S=t[10]:(S=(0,q.jsx)(f,{className:`mt-1 text-sm text-fg-muted`,children:x}),t[9]=x,t[10]=S);let w;t[11]!==b||t[12]!==S?(w=(0,q.jsxs)(`div`,{className:`min-w-0`,children:[b,S]}),t[11]=b,t[12]=S,t[13]=w):w=t[13];let T;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,q.jsx)(h,{className:`size-4`,"aria-hidden":!0}),t[14]=T):T=t[14];let k;t[15]===d?k=t[16]:(k=(0,q.jsx)(E,{asChild:!0,children:(0,q.jsx)(D,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":d,children:T})}),t[15]=d,t[16]=k);let j;t[17]!==w||t[18]!==k?(j=(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[w,k]}),t[17]=w,t[18]=k,t[19]=j):j=t[19];let M;t[20]!==u||t[21]!==n||t[22]!==l||t[23]!==c||t[24]!==a||t[25]!==m||t[26]!==p?(M=p.length>0?(0,q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,q.jsx)(Ct,{tools:p,stripPrefix:m,searchPlaceholder:c,searchEmptyLabel:l},`${a}-${n?`open`:`closed`}`)}):(0,q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u})}),t[20]=u,t[21]=n,t[22]=l,t[23]=c,t[24]=a,t[25]=m,t[26]=p,t[27]=M):M=t[27];let N;t[28]===d?N=t[29]:(N=(0,q.jsx)(`div`,{className:`flex justify-end border-t border-edge px-5 py-3`,children:(0,q.jsx)(E,{asChild:!0,children:(0,q.jsx)(D,{type:`button`,variant:`secondary`,children:d})})}),t[28]=d,t[29]=N);let F;t[30]!==j||t[31]!==M||t[32]!==N?(F=(0,q.jsxs)(y,{children:[g,(0,q.jsxs)(me,{className:_,children:[j,M,N]})]}),t[30]=j,t[31]=M,t[32]=N,t[33]=F):F=t[33];let I;return t[34]!==r||t[35]!==n||t[36]!==F?(I=(0,q.jsx)(O,{open:n,onOpenChange:r,children:F}),t[34]=r,t[35]=n,t[36]=F,t[37]=I):I=t[37],I}var Tt=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,H);function Et(e){return e.materialized.type===`composio`?e.connectorId.replace(/^composio-/,``):null}function Dt(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function Ot({instance:e,t}){let n=Et(e),[r,a]=(0,G.useState)([]),[o,s]=(0,G.useState)([]),[c,l]=(0,G.useState)([]),[u,d]=(0,G.useState)(`read`),[f,p]=(0,G.useState)(!1),[m,h]=(0,G.useState)(null),g=(0,G.useCallback)(async()=>{if(!(!n||n===`api-key`)){p(!0),h(null);try{let[e,t,r,i]=await Promise.all([Le().catch(()=>[]),Ve(n).catch(()=>[]),He(20).catch(()=>[]),ze(n).catch(()=>`read`)]);a(e.filter(e=>e.toolkit.toLowerCase()===n.toLowerCase())),s(t),l(r.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===n.toLowerCase())),d(i)}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}},[n]);(0,G.useEffect)(()=>{g()},[g]);let _=(0,G.useCallback)(async()=>{if(n){p(!0),h(null);try{let e=await Re(n);window.open(e.connectUrl,`_blank`,`noopener,noreferrer`)}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}},[n]),v=(0,G.useCallback)(async e=>{if(n){d(e);try{await Be(n,e),await g()}catch(e){h(e instanceof Error?e.message:String(e))}}},[g,n]);return n?n===`api-key`?(0,q.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:t.composioApiKeyStored}):(0,q.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`font-medium text-fg`,children:$(t.composioToolkitTitle,{toolkit:n})}),(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)(R,{className:i(Tt,`h-9 w-28 py-1`),value:u,onChange:e=>void v(e.currentTarget.value),children:[(0,q.jsx)(V,{value:`read`,children:t.composioScopeRead}),(0,q.jsx)(V,{value:`write`,children:t.composioScopeWrite}),(0,q.jsx)(V,{value:`admin`,children:t.composioScopeAdmin})]}),(0,q.jsxs)(D,{variant:`secondary`,disabled:f,onClick:()=>void _(),children:[f?(0,q.jsx)(k,{className:`size-4 animate-spin`}):(0,q.jsx)(B,{className:`size-4`}),t.connectOAuth]}),(0,q.jsx)(D,{variant:`ghost`,disabled:f,onClick:()=>void g(),children:t.refresh})]})]}),m?(0,q.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:m}):null,(0,q.jsxs)(`div`,{className:`mt-4 grid gap-3 lg:grid-cols-3`,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?r.map(e=>(0,q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,q.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.accountEmail??e.username??e.workspace??e.id}),(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.status})]},e.id)):(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioConnectionsEmpty})]}),(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}),o.length?o.slice(0,8).map(e=>(0,q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel 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:[Dt(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}),c.length?c.slice(0,5).map(e=>(0,q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel 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 kt=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,H);function At(e,t){return e?t.healthStatusLabels[e]??e:t.healthNotTested}function jt(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 Mt(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 Nt(e){let t=(0,K.c)(12),{title:n,description:r,meta:a}=e,o;t[0]===r?o=t[1]:(o=r?(0,q.jsx)(L,{delayDuration:300,skipDelayDuration:100,children:(0,q.jsxs)(ue,{children:[(0,q.jsx)(se,{asChild:!0,children:(0,q.jsx)(`p`,{tabIndex:0,title:r,className:i(`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)(d,{children:(0,q.jsx)(T,{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]=o);let s=o,c;t[2]===n?c=t[3]:(c=(0,q.jsx)(`p`,{className:`min-w-0 break-all font-mono text-xs font-medium leading-5 text-fg`,children:n}),t[2]=n,t[3]=c);let l;t[4]===a?l=t[5]:(l=a?(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:a}):null,t[4]=a,t[5]=l);let u;t[6]!==c||t[7]!==l?(u=(0,q.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8];let f;return t[9]!==s||t[10]!==u?(f=(0,q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[u,s]}),t[9]=s,t[10]=u,t[11]=f):f=t[11],f}function Pt({instance:e,definition:t,onClose:n,onChanged:r,t:a,mcp:o}){let[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(!1),[d,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(null),[b,x]=(0,G.useState)(`health`),[S,w]=(0,G.useState)(!1),[T,j]=(0,G.useState)(()=>jt(t,e)),[M,N]=(0,G.useState)(null),P=t?.setup.config??[],F=e.materialized.type===`mcp`&&P.length>0&&(t?.setup.secrets??[]).length===0,I=_?_.toolCount:e.usage.lastToolCount,L=(0,G.useMemo)(()=>{let t=[[`health`,ce,a.detailHealth],[`tools`,C,`${a.detailTools} ${_?_.toolCount:e.usage.lastToolCount??``}`],[`resources`,ie,`${a.detailResources} ${_?_.resourceCount:e.usage.lastResourceCount??``}`],[`prompts`,p,`${a.detailPrompts} ${_?_.promptCount:e.usage.lastPromptCount??``}`],[`permissions`,B,a.detailPermissions]];return F?[...t,[`config`,ie,a.tabConfig]]:t},[_,e.usage.lastPromptCount,e.usage.lastResourceCount,e.usage.lastToolCount,F,a]),R=(0,G.useCallback)(async()=>{c(!0),N(null);try{let t=await Ie(e.instanceId);v(t),t.toolCount>0&&x(`tools`),r()}catch(e){N(e instanceof Error?e.message:String(e))}finally{c(!1)}},[e.instanceId,r]),z=(0,G.useCallback)(async()=>{u(!0),N(null);try{await Fe(e.instanceId),await r(),n()}catch(e){N(e instanceof Error?e.message:String(e)),u(!1)}},[e.instanceId,r,n]),ne=(0,G.useCallback)(async()=>{if(!(!t||!F)){g(!0),N(null);try{let n={};for(let e of t.setup.config??[]){let t=Mt(e.type,T[e.key]??``);t!==void 0&&(n[e.key]=t)}await Pe(e.instanceId,{config:n}),await r(),x(`health`)}catch(e){N(e instanceof Error?e.message:String(e))}finally{g(!1)}}},[T,t,e.instanceId,r,F]);return(0,q.jsxs)(O,{open:!0,onOpenChange:e=>{e||n()},children:[(0,q.jsxs)(y,{children:[(0,q.jsx)(A,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,q.jsxs)(me,{className:i(`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:`min-w-0`,children:[(0,q.jsx)(ee,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,q.jsx)(f,{className:`mt-1 text-sm text-fg-muted`,children:e.materialized.type===`mcp`?$(a.mcpServerRuntime,{serverId:e.materialized.serverId}):$(a.runtimeLabel,{runtime:e.materialized.type})})]}),(0,q.jsx)(E,{asChild:!0,children:(0,q.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,U.focusRingPanel),"aria-label":a.modalClose,children:[(0,q.jsx)(h,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`sr-only`,children:a.modalClose})]})})]}),(0,q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[M?(0,q.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:M}):null,(0,q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:L.map(([e,t,n])=>(0,q.jsxs)(`button`,{type:`button`,className:i(`inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs`,b===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:text-fg`),onClick:()=>x(e),children:[(0,q.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),n]},e))}),(0,q.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[b===`health`?(0,q.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,q.jsxs)(`p`,{children:[a.statusLabel,` `,(0,q.jsx)(`span`,{className:_?.ok?`font-medium text-emerald-700 dark:text-emerald-300`:`font-medium text-fg`,children:At(_?.status??e.usage.lastHealthStatus,a)})]}),(0,q.jsxs)(`p`,{children:[a.lastCheckLabel,` `,e.usage.lastHealthCheckAt?new Date(e.usage.lastHealthCheckAt).toLocaleString():a.never]}),_?.action?(0,q.jsx)(`p`,{children:_.action}):null]}):null,b===`tools`?_?.tools.length?(0,q.jsxs)(`div`,{className:`grid gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:$(a.toolsAvailable,{count:String(_.tools.length)})}),(0,q.jsx)(D,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>w(!0),children:o.viewAllTools})]}),(0,q.jsx)(`div`,{className:`grid gap-2`,children:_.tools.slice(0,8).map(e=>(0,q.jsx)(Nt,{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:I?$(a.toolsLastCheckSummary,{count:String(I)}):a.toolsRunTestHint}),(0,q.jsxs)(D,{type:`button`,variant:`secondary`,disabled:s,onClick:()=>void R(),children:[s?(0,q.jsx)(k,{className:`size-4 animate-spin`}):(0,q.jsx)(m,{className:`size-4`}),a.test]})]}):null,b===`resources`?_?.resources.length?(0,q.jsx)(`div`,{className:`grid gap-2`,children:_.resources.slice(0,8).map(e=>(0,q.jsx)(Nt,{title:e.title??e.name,description:e.uri,meta:e.mimeType},e.uri))}):(0,q.jsx)(`p`,{className:`text-fg-muted`,children:a.resourcesRunTestHint}):null,b===`prompts`?_?.prompts.length?(0,q.jsx)(`div`,{className:`grid gap-2`,children:_.prompts.slice(0,8).map(e=>(0,q.jsx)(Nt,{title:e.title??e.name,description:e.description,meta:e.argumentCount?$(a.promptArgumentCount,{count:String(e.argumentCount)}):void 0},e.name))}):(0,q.jsx)(`p`,{className:`text-fg-muted`,children:a.promptsRunTestHint}):null,b===`permissions`?(0,q.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,q.jsx)(`p`,{children:$(a.secretsConfigured,{count:String(Object.values(e.secretStatus).filter(Boolean).length)})}),(0,q.jsx)(`p`,{children:e.materialized.type===`mcp`?$(a.runtimeServerLabel,{runtime:e.materialized.type.toUpperCase(),serverId:e.materialized.serverId}):$(a.runtimeLabel,{runtime:e.materialized.type.toUpperCase()})}),(0,q.jsx)(`p`,{children:e.materialized.type===`mcp`?a.mcpPolicyHint:a.connectorPolicyHint})]}):null,b===`config`&&F?(0,q.jsx)(`div`,{className:`grid gap-3`,children:P.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:kt,value:T[e.key]??``,placeholder:e.placeholder,onChange:t=>j(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}),e.materialized.type===`composio`?(0,q.jsx)(Ot,{instance:e,t:a}):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)(D,{variant:`secondary`,onClick:n,children:a.modalClose}),b===`config`&&F?(0,q.jsxs)(D,{variant:`primary`,disabled:d,onClick:()=>void ne(),children:[d?(0,q.jsx)(k,{className:`size-4 animate-spin`}):(0,q.jsx)(te,{className:`size-4`}),a.modalSave]}):null,e.materialized.type===`mcp`?(0,q.jsxs)(D,{variant:`secondary`,disabled:s,onClick:()=>void R(),children:[s?(0,q.jsx)(k,{className:`size-4 animate-spin`}):(0,q.jsx)(m,{className:`size-4`}),a.test]}):null,(0,q.jsxs)(D,{variant:`ghost`,disabled:l,onClick:()=>void z(),children:[l?(0,q.jsx)(k,{className:`size-4 animate-spin`}):(0,q.jsx)(W,{className:`size-4`}),a.remove]})]})]})]}),e.materialized.type===`mcp`?(0,q.jsx)(wt,{open:S,onOpenChange:w,serverId:e.materialized.serverId,title:$(a.installedToolsDialogTitle,{name:e.displayName}),subtitle:a.installedToolsDialogSubtitle,searchPlaceholder:o.toolsDialogSearchPlaceholder,searchEmptyLabel:o.toolsDialogSearchEmpty,emptyLabel:a.toolsRunTestHint,closeLabel:o.toolsDialogClose,tools:_?.tools??[],stripPrefix:`${e.materialized.serverId}__`}):null]})}function Ft({instance:e,definition:t,onOpenDetails:n,onChanged:r,t:i}){let[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(null),d=(0,G.useCallback)(async()=>{o(!0),u(null);try{await Ie(e.instanceId),await r()}catch(e){u(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.instanceId,r]),f=(0,G.useCallback)(async()=>{c(!0),u(null);try{await Fe(e.instanceId),await r()}catch(e){u(e instanceof Error?e.message:String(e)),c(!1)}},[e.instanceId,r]),p=e.usage.lastHealthStatus?i.healthStatusLabels[e.usage.lastHealthStatus]??e.usage.lastHealthStatus:i.healthNotTested,h=e.usage.lastToolCount??0,g=!!(t?.setup.config?.length&&!t.setup.secrets?.length&&e.materialized.type===`mcp`);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:()=>n(e),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.displayName}),(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)(M,{className:`size-3`,"aria-hidden":!0}),i.installedBadge]}),g?(0,q.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:i.tabConfig}):null]}),(0,q.jsx)(`p`,{className:`mt-3 line-clamp-2 break-all text-sm leading-5 text-fg-muted`,children:e.materialized.type===`mcp`?$(i.mcpServerRuntime,{serverId:e.materialized.serverId}):$(i.runtimeLabel,{runtime:e.materialized.type})}),(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:[i.statusLabel,` `,p]}),(0,q.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:$(i.toolsAvailable,{count:String(h)})})]}),l?(0,q.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:l}):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:i.connectorDetails}),(0,q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[e.materialized.type===`mcp`?(0,q.jsxs)(D,{variant:`secondary`,disabled:a,onClick:()=>void d(),children:[a?(0,q.jsx)(k,{className:`size-4 animate-spin`}):(0,q.jsx)(m,{className:`size-4`}),i.test]}):null,(0,q.jsxs)(D,{variant:`ghost`,disabled:s,onClick:()=>void f(),children:[s?(0,q.jsx)(k,{className:`size-4 animate-spin`}):(0,q.jsx)(W,{className:`size-4`}),i.remove]})]})]})]})}var It=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,H),Lt=i(It,`min-h-28 font-mono`);function Rt(e,t){return e?t.healthStatusLabels[e]??e:t.healthStatusPending}function zt(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 Bt(e){let t={};for(let n of e.setup.secrets??[])t[n.key]=``;let n={};for(let t of e.setup.config??[])n[t.key]=t.defaultValue===void 0?``:typeof t.defaultValue==`string`?t.defaultValue:JSON.stringify(t.defaultValue,null,2);return{connector:e,secrets:t,config:n,installing:!1,error:null,result:null,health:null,oauth:{flow:null,connected:e.auth.mode!==`oauth`}}}function Vt(e){let t=(0,K.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,q.jsx)(`div`,{className:`border-b border-edge px-3 py-2 text-xs font-semibold text-fg`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,12).map(Ht),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>12?(0,q.jsxs)(`div`,{className:`px-3 py-2 text-xs text-fg-subtle`,children:[`+`,r.length-12]}):null,t[4]=r.length,t[5]=o);let s;t[6]!==a||t[7]!==o?(s=(0,q.jsxs)(`div`,{className:`max-h-40 overflow-y-auto`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==i||t[10]!==s?(c=(0,q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel`,children:[i,s]}),t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function Ht(e){return(0,q.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,q.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,q.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function Ut({draft:e,onChange:t,onClose:n,onInstalled:r,t:a}){let{connector:o}=e,s=e.result?`complete`:e.installing?`health`:`configure`,c=[{id:`configure`,label:a.installStepConfigure},{id:`health`,label:a.installStepHealth},{id:`complete`,label:a.installStepComplete}],l=(0,G.useCallback)(async()=>{t({...e,installing:!0,error:null});try{let n=await Ae(o.id);window.open(n.verificationUri,`_blank`,`noopener,noreferrer`),t({...e,installing:!1,error:null,oauth:{flow:n,connected:!1}})}catch(n){t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}},[o.id,e,t]),u=(0,G.useCallback)(async()=>{if(e.oauth.flow){t({...e,installing:!0,error:null});try{await je(o.id,e.oauth.flow.deviceCode),t({...e,installing:!1,error:null,oauth:{...e.oauth,connected:!0}})}catch(n){t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}}},[o.id,e,t]),d=(0,G.useCallback)(async()=>{t({...e,installing:!0,error:null,result:null,health:null});try{if(o.auth.mode===`oauth`&&!e.oauth.connected)throw Error(a.oauthRequiredBeforeInstall);let n={};for(let t of o.setup.config??[]){let r=zt(t.type,e.config[t.key]??``);r!==void 0&&(n[t.key]=r)}let i=await Me(o.id,{secrets:e.secrets,config:n,definition:o.source===`registry`?o:void 0}),s=null;try{s=await Ie(i.instanceId)}catch{s=null}t({...e,installing:!1,result:i,health:s}),await r()}catch(n){t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}},[o,e,t,r,a.oauthRequiredBeforeInstall]);return(0,q.jsx)(O,{open:!0,onOpenChange:e=>{e||n()},children:(0,q.jsxs)(y,{children:[(0,q.jsx)(A,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,q.jsxs)(me,{className:i(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex max-h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),children:[(0,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)(ee,{className:`text-base font-semibold text-fg`,children:$(a.installDialogTitle,{name:o.displayName})}),(0,q.jsx)(f,{className:`mt-1 line-clamp-3 text-sm text-fg-muted`,children:o.description})]}),(0,q.jsx)(E,{asChild:!0,children:(0,q.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,U.focusRingPanel),"aria-label":a.modalClose,children:[(0,q.jsx)(h,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`sr-only`,children:a.modalClose})]})})]}),(0,q.jsxs)(`div`,{className:`min-h-0 overflow-y-auto px-6 py-5`,children:[(0,q.jsx)(`div`,{className:`mb-5 grid grid-cols-3 gap-2`,"aria-label":a.installProgressAria,children:c.map((e,t)=>{let n=c.findIndex(e=>e.id===s);return(0,q.jsxs)(`div`,{className:i(`rounded-xl border px-3 py-2 text-xs font-medium`,t===n?`border-accent bg-accent-soft text-accent-fg`:t<n?`border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-900/40 dark:bg-emerald-950/40 dark:text-emerald-200`:`border-edge bg-surface-base text-fg-muted`),children:[(0,q.jsxs)(`span`,{className:`mr-1 tabular-nums`,children:[t+1,`.`]}),e.label]},e.id)})}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[o.auth.mode===`oauth`?(0,q.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4`,children:[(0,q.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:a.oauthTitle}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.oauthHint}),e.oauth.flow?(0,q.jsxs)(`div`,{className:`mt-3 rounded-xl bg-surface-base p-3 text-sm text-fg-muted`,children:[(0,q.jsx)(`p`,{children:$(a.oauthOpenCodePrefix,{url:e.oauth.flow.verificationUri})}),(0,q.jsx)(`p`,{className:`mt-2 font-mono text-lg font-semibold tracking-widest text-fg`,children:e.oauth.flow.userCode})]}):null,e.oauth.connected?(0,q.jsx)(`p`,{className:`mt-3 rounded-xl bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700`,children:a.oauthConnected}):null,(0,q.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,q.jsxs)(D,{variant:`secondary`,disabled:e.installing,onClick:()=>void l(),children:[e.installing&&!e.oauth.flow?(0,q.jsx)(k,{className:`size-4 animate-spin`}):(0,q.jsx)(m,{className:`size-4`}),a.oauthConnectButton]}),(0,q.jsxs)(D,{variant:`primary`,disabled:e.installing||!e.oauth.flow,onClick:()=>void u(),children:[e.installing&&e.oauth.flow?(0,q.jsx)(k,{className:`size-4 animate-spin`}):(0,q.jsx)(M,{className:`size-4`}),a.oauthAuthorizedButton]})]})]}):null,(o.setup.secrets??[]).map(n=>(0,q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.description?(0,q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.description}):null,(0,q.jsx)(oe,{value:e.secrets[n.key]??``,onChange:r=>t({...e,secrets:{...e.secrets,[n.key]:r},error:null}),labels:a.secretInputLabels,placeholder:n.required?a.requiredPlaceholder:a.optionalPlaceholder})]},n.key)),(o.setup.config??[]).map(n=>(0,q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.type===`json`?(0,q.jsx)(`textarea`,{className:Lt,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})}):(0,q.jsx)(`input`,{className:It,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})})]},n.key)),e.installing?(0,q.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-fg`,children:[(0,q.jsx)(k,{className:`size-4 animate-spin text-accent`,"aria-hidden":!0}),a.installingTitle]}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:a.installingHint})]}):null,e.error?(0,q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:e.error}):null,e.result?(0,q.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`font-medium text-fg`,children:$(a.installedAs,{target:e.result.materialized.type===`mcp`?e.result.materialized.serverId:e.result.instanceId})}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:$(a.runtimeLabel,{runtime:e.result.materialized.type.toUpperCase()})})]}),(0,q.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs font-medium`,e.health?.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e.health?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-hover text-fg-muted`),children:e.health?.ok?a.healthStatusHealthy:Rt(e.health?.status,a)})]}),e.health?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,q.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.toolCount}),(0,q.jsx)(`div`,{children:a.toolsMetric})]}),(0,q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,q.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.resourceCount}),(0,q.jsx)(`div`,{children:a.resourcesMetric})]}),(0,q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,q.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.promptCount}),(0,q.jsx)(`div`,{children:a.promptsMetric})]})]}),(0,q.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,q.jsx)(Vt,{title:a.detailTools,items:e.health.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,q.jsx)(Vt,{title:a.detailResources,items:e.health.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,q.jsx)(Vt,{title:a.detailPrompts,items:e.health.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??$(a.promptArgumentCount,{count:String(e.argumentCount)})}))})]})]}):(0,q.jsx)(`p`,{className:`mt-3`,children:a.installedWithoutHealth}),e.health?.action?(0,q.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:e.health.action}):null]}):null]})]}),(0,q.jsx)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:(0,q.jsxs)(D,{variant:`primary`,disabled:!!e.result||e.installing||o.auth.mode===`oauth`&&!e.oauth.connected,onClick:()=>void d(),children:[e.installing?(0,q.jsx)(k,{className:`size-4 animate-spin`}):e.result?(0,q.jsx)(M,{className:`size-4`}):(0,q.jsx)(S,{className:`size-4`}),e.result?a.installedBadge:a.install]})})]})]})})}function Wt(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 ct(r)}function Gt(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 Kt(e,t,n){return e.filter(e=>Gt(e,t)).toSorted((e,t)=>n===`source`&&e.source!==t.source?e.source.localeCompare(t.source):e.displayName.localeCompare(t.displayName))}function qt(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 Jt(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 Yt(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 Xt(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,H)}function Zt({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:a,pasteFailed:o,keyPlaceholder:s,valuePlaceholder:c,headers:l,onChange:u}){let d=(e,t)=>{u(l.map((n,r)=>r===e?{...n,...t}:n))},f=()=>{u([...l,{key:``,value:``}])},p=e=>{let t=l.filter((t,n)=>n!==e);u(t.length>0?t:[{key:``,value:``}])},m=async()=>{try{let e=await z();if(!e){window.alert(o);return}let t=$e(e);if(!t?.length){window.alert(o);return}u(t)}catch{window.alert(o)}};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)(D,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void m(),children:[(0,q.jsx)(j,{className:`size-3.5`,"aria-hidden":!0}),a]})]}),(0,q.jsx)(`div`,{className:`flex flex-col gap-2`,children:l.map((e,t)=>(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`input`,{className:i(Xt(),`min-w-0 flex-1 font-mono text-xs`),value:e.key,placeholder:s,onChange:e=>d(t,{key:e.target.value})}),(0,q.jsx)(`input`,{className:i(Xt(),`min-w-0 flex-[1.4] font-mono text-xs`),value:e.value,placeholder:c,onChange:e=>d(t,{value:e.target.value})}),(0,q.jsx)(D,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:l.length<=1&&!e.key&&!e.value,onClick:()=>p(t),"aria-label":r,children:(0,q.jsx)(W,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})})]},Yt(e,t,l)))}),(0,q.jsxs)(`button`,{type:`button`,className:i(`self-start text-sm text-accent hover:underline`,U.press),onClick:f,children:[`+ `,n]})]})}var Qt=[`stdio`,`sse`,`streamable-http`];function $t(e){let t=(0,K.c)(11),{label:n,description:r,required:i,children:a}=e,o;t[0]===i?o=t[1]:(o=i?(0,q.jsx)(`span`,{className:`ml-0.5 text-danger`,children:`*`}):null,t[0]=i,t[1]=o);let s;t[2]!==n||t[3]!==o?(s=(0,q.jsxs)(`div`,{className:`text-sm font-medium text-fg`,children:[n,o]}),t[2]=n,t[3]=o,t[4]=s):s=t[4];let c;t[5]===r?c=t[6]:(c=r?(0,q.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}):null,t[5]=r,t[6]=c);let l;return t[7]!==a||t[8]!==s||t[9]!==c?(l=(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[s,a,c]}),t[7]=a,t[8]=s,t[9]=c,t[10]=l):l=t[10],l}function en(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,H)}function tn(e){let t=(0,K.c)(29),{row:n,t:r,onUpdate:a,idConflictMessage:o,variant:s}=e,c=s===void 0?`all`:s,l=c===`all`||c===`basic`,u=c===`all`||c===`advanced`,d;t[0]!==o||t[1]!==a||t[2]!==n.id||t[3]!==n.transport||t[4]!==l||t[5]!==r?(d=l?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)($t,{label:r.transportLabel,required:!0,children:(0,q.jsx)(R,{className:en(),value:n.transport,onChange:e=>a({transport:e.target.value}),children:Qt.map(e=>(0,q.jsx)(V,{value:e,children:r.transportLabels[e]},e))})}),(0,q.jsxs)($t,{label:r.serverIdLabel,required:!0,children:[(0,q.jsx)(`input`,{className:en(),value:n.id,placeholder:r.serverIdPlaceholder,onChange:e=>a({id:e.target.value})}),o?(0,q.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-300`,children:o}):null]})]}):null,t[0]=o,t[1]=a,t[2]=n.id,t[3]=n.transport,t[4]=l,t[5]=r,t[6]=d):d=t[6];let f;t[7]!==a||t[8]!==n.argsText||t[9]!==n.command||t[10]!==n.cwd||t[11]!==n.envJson||t[12]!==n.headers||t[13]!==n.transport||t[14]!==n.url||t[15]!==u||t[16]!==l||t[17]!==r||t[18]!==c?(f=n.transport===`stdio`?(0,q.jsxs)(q.Fragment,{children:[l?(0,q.jsx)(`div`,{className:c===`basic`?`md:col-span-2`:void 0,children:(0,q.jsx)($t,{label:r.commandLabel,required:!0,children:(0,q.jsx)(`input`,{className:en(),value:n.command,onChange:e=>a({command:e.target.value})})})}):null,u?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)($t,{label:r.argsLabel,description:r.argsHint,children:(0,q.jsx)(`input`,{className:en(),value:n.argsText,onChange:e=>a({argsText:e.target.value})})}),(0,q.jsx)($t,{label:r.cwdLabel,children:(0,q.jsx)(`input`,{className:en(),value:n.cwd,onChange:e=>a({cwd:e.target.value})})}),(0,q.jsx)($t,{label:r.envLabel,description:r.envHint,children:(0,q.jsx)(`textarea`,{className:i(en(),`min-h-[4rem] font-mono text-xs`),value:n.envJson,onChange:e=>a({envJson:e.target.value})})})]}):null]}):(0,q.jsxs)(q.Fragment,{children:[l?(0,q.jsx)(`div`,{className:`md:col-span-2`,children:(0,q.jsx)($t,{label:r.urlLabel,required:!0,children:(0,q.jsx)(`input`,{className:i(en(),`font-mono text-xs`),value:n.url,placeholder:`https://example.com/mcp`,onChange:e=>a({url:e.target.value})})})}):null,u?(0,q.jsx)(Zt,{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=>a({headers:e})}):null]}),t[7]=a,t[8]=n.argsText,t[9]=n.command,t[10]=n.cwd,t[11]=n.envJson,t[12]=n.headers,t[13]=n.transport,t[14]=n.url,t[15]=u,t[16]=l,t[17]=r,t[18]=c,t[19]=f):f=t[19];let p;t[20]!==a||t[21]!==n||t[22]!==u||t[23]!==r?(p=u?(0,q.jsx)($t,{label:r.timeoutLabel,description:r.timeoutHint,children:(0,q.jsx)(`input`,{type:`number`,min:1,max:600,className:en(),value:gt(n),placeholder:r.timeoutPlaceholder,onChange:e=>a({connectionTimeoutMs:_t(e.target.value)})})}):null,t[20]=a,t[21]=n,t[22]=u,t[23]=r,t[24]=p):p=t[24];let m;return t[25]!==d||t[26]!==f||t[27]!==p?(m=(0,q.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[d,f,p]}),t[25]=d,t[26]=f,t[27]=p,t[28]=m):m=t[28],m}function nn(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 rn(e){let t=(0,K.c)(13),{tool:n,serverId:r}=e,a;t[0]!==r||t[1]!==n?(a=nn(n,r),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o=a,s=n.name===o?o:n.name,c;t[3]===n.description?c=t[4]:(c=n.description?.trim(),t[3]=n.description,t[4]=c);let l=c,u;t[5]!==o||t[6]!==s?(u=(0,q.jsx)(`p`,{className:`break-all font-mono text-xs font-medium leading-5 text-fg`,title:s,children:o}),t[5]=o,t[6]=s,t[7]=u):u=t[7];let f;t[8]===l?f=t[9]:(f=l?(0,q.jsx)(L,{delayDuration:300,skipDelayDuration:100,children:(0,q.jsxs)(ue,{children:[(0,q.jsx)(se,{asChild:!0,children:(0,q.jsx)(`p`,{tabIndex:0,title:l,className:i(`mt-1 line-clamp-3 cursor-help text-xs leading-5 text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:l})}),(0,q.jsx)(d,{children:(0,q.jsx)(T,{side:`top`,align:`start`,sideOffset:6,collisionPadding:12,className:`!z-[10000] max-h-[min(16rem,45vh)] max-w-[min(32rem,calc(100vw-2rem))] overflow-y-auto rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-5 text-fg shadow-popover`,children:(0,q.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:l})})})]})}):null,t[8]=l,t[9]=f);let p;return t[10]!==u||t[11]!==f?(p=(0,q.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[u,f]}),t[10]=u,t[11]=f,t[12]=p):p=t[12],p}function an({open:e,mode:t,initialRow:n,existingCustomServers:r,sessionIdleTtlMinutes:a,config:o,managedServerIds:s,t:c,cs:l,onClose:u,onSaved:d}){let[p,g]=(0,G.useState)(n),[_,v]=(0,G.useState)(!1),[b,x]=(0,G.useState)(!1),[S,w]=(0,G.useState)(null),[T,j]=(0,G.useState)(!1),[N,P]=(0,G.useState)({status:`idle`}),[F,I]=(0,G.useState)(null),te=n.id.trim(),L=p.id.trim()!==te&&s.has(p.id.trim())||s.has(p.id.trim())&&t===`add`?c.reservedServerId:void 0,R=p.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===p.id.trim())?l.duplicateServerId:void 0,z=p.id.trim().length>0&&!L&&!R&&(p.transport===`stdio`?p.command.trim().length>0:p.url.trim().length>0),ne=vt(p),re=(0,G.useCallback)(async()=>{if(p.id.trim()){x(!0),w(null),P({status:`loading`});try{P({status:`ok`,tools:(await ht(p.id.trim(),ut(p))).tools})}catch(e){P({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{x(!1)}}},[p]),ie=(0,G.useCallback)(async()=>{if(!(!z||_)){v(!0),w(null);try{let e=r.filter(e=>!(t===`edit`&&e.clientKey===n.clientKey));e.push(p),await dt({sessionIdleTtlMinutes:a,servers:e.sort((e,t)=>e.id.localeCompare(t.id))},rt(o)),await d(),u()}catch(e){w(e instanceof Error?e.message:String(e))}finally{v(!1)}}},[z,o,r,n.clientKey,t,u,d,te,p,_,a]);return e?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(O,{open:e,onOpenChange:e=>{e||u()},children:(0,q.jsxs)(y,{children:[(0,q.jsx)(A,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,q.jsxs)(me,{className:i(`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)(ee,{className:`text-base font-semibold text-fg`,children:t===`add`?l.addCustomServerTitle:l.editCustomServerTitle}),(0,q.jsx)(f,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?l.addCustomServerHint:l.editCustomServerHint})]}),(0,q.jsx)(E,{asChild:!0,children:(0,q.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,U.focusRingPanel),"aria-label":l.modalClose,children:[(0,q.jsx)(h,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`sr-only`,children:l.modalClose})]})})]}),(0,q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,q.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,q.jsx)(le,{className:`size-4 text-accent`,"aria-hidden":!0}),p.id.trim()||c.cardUntitled]}),(0,q.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs leading-5 text-fg-muted`,children:ne||(p.transport===`stdio`?c.commandLabel:c.urlLabel)})]}),(0,q.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:c.transportLabels[p.transport]})]})}),(0,q.jsxs)(`section`,{children:[(0,q.jsxs)(`div`,{className:`mb-3`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.connectorBasicConfigTitle}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.connectorBasicConfigHint})]}),(0,q.jsx)(tn,{row:p,t:c,variant:`basic`,onUpdate:e=>{g(t=>({...t,...e})),w(null)},idConflictMessage:L??R})]}),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)(C,{className:`size-4 text-accent`,"aria-hidden":!0}),N.tools.length===0?c.toolsEmpty:c.toolsTitle.replace(`{{count}}`,String(N.tools.length))]}),N.tools.length>0?(0,q.jsx)(D,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>I(N.tools),children:c.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)(rn,{tool:e,serverId:p.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:T,onToggle:e=>j(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)(de,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`group-open:hidden`,children:l.connectorShowAdvancedConfig}),(0,q.jsx)(`span`,{className:`hidden group-open:inline`,children:l.connectorHideAdvancedConfig})]}),(0,q.jsx)(`div`,{className:`border-t border-edge px-4 py-4`,children:(0,q.jsx)(tn,{row:p,t:c,variant:`advanced`,onUpdate:e=>{g(t=>({...t,...e})),w(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)(D,{variant:`secondary`,disabled:!p.id.trim()||b,onClick:()=>void re(),children:[b?(0,q.jsx)(k,{className:`size-4 animate-spin`}):(0,q.jsx)(m,{className:`size-4`}),c.testConnection]}),(0,q.jsx)(E,{asChild:!0,children:(0,q.jsx)(D,{variant:`secondary`,children:l.modalCancel})}),(0,q.jsxs)(D,{variant:`primary`,disabled:!z||_,onClick:()=>void ie(),children:[_?(0,q.jsx)(k,{className:`size-4 animate-spin`}):(0,q.jsx)(M,{className:`size-4`}),_?c.saving:l.modalSave]})]})]})]})}),F?(0,q.jsx)(wt,{open:!0,onOpenChange:e=>{e||I(null)},serverId:p.id,title:c.toolsDialogTitle,subtitle:c.toolsDialogSubtitle,searchPlaceholder:c.toolsDialogSearchPlaceholder,searchEmptyLabel:c.toolsDialogSearchEmpty,emptyLabel:c.toolsEmpty,closeLabel:c.toolsDialogClose,tools:F,stripPrefix:`${p.id.trim()}__`}):null]}):null}var on=`mprov`,sn=`smithery`,cn=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,H);function ln(){let e=a(o(e=>e.language)),t=e.connectorsSettings,n=e.mcpSettings,r=s(e=>e.token),c=!!r,[l,d]=g(),f=l.get(on)?.trim()||sn,[p,m]=(0,G.useState)(`marketplace`),[h,y]=(0,G.useState)({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!0,error:null}),[S,C]=(0,G.useState)(!1),[T,E]=(0,G.useState)(1),[O,A]=(0,G.useState)(void 0),[j,ee]=(0,G.useState)(``),[M,P]=(0,G.useState)(f),[F,I]=(0,G.useState)(`name`),[te,L]=(0,G.useState)(null),[R,z]=(0,G.useState)(null),[re,ie]=(0,G.useState)(null),[ae,oe]=(0,G.useState)(null),[B,se]=(0,G.useState)(null),[V,ce]=(0,G.useState)(void 0),[le,ue]=(0,G.useState)(!1),[fe,H]=(0,G.useState)(!1),{data:me,mutate:W}=ne(c),K=me?.payload?.config,J=(0,G.useMemo)(()=>K===void 0?null:lt(K),[K]),Y=J?.servers??[];(0,G.useEffect)(()=>{J&&ce(J.sessionIdleTtlMinutes)},[J]);let X=(0,G.useCallback)(async()=>{if(!r){y({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!1,error:null});return}y(e=>({...e,loading:!0,error:null}));try{let[e,t,n]=await Promise.all([Te(),De(),Ee()]);y(r=>({catalog:e,registryCatalog:r.registryCatalog,instances:t,registries:n,loading:!1,error:null}))}catch(e){y({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[r]);(0,G.useEffect)(()=>{X()},[X]);let we=l.toString(),Z=(0,G.useRef)(we);(0,G.useEffect)(()=>{Z.current!==we&&(Z.current=we,P(l.get(on)?.trim()||sn))},[l,we]);let Q=(0,G.useMemo)(()=>h.registries.map(e=>e.id),[h.registries]);(0,G.useEffect)(()=>{if(Q.length===0||Q.includes(M))return;let e=Q.includes(sn)?sn:Q[0];e&&P(e)},[M,Q]),(0,G.useEffect)(()=>{if(!M||M===l.get(on))return;let e=new URLSearchParams(l);e.set(on,M),Z.current=e.toString(),d(e,{replace:!0})},[M,l,d]);let Oe=(0,G.useCallback)(async e=>{let t=j.trim(),n=e?.browse??!1,r=Math.max(e?.page??1,1),i=e?.append??!1;if(!(!c||!t&&!n)){C(!0),i?y(e=>({...e,error:null})):(E(1),A(void 0),y(e=>({...e,registryCatalog:[],error:null})));try{let e=await ke(t,M,{browse:n,page:r});E(r),A(e.totalPages),y(t=>({...t,registryCatalog:i?[...t.registryCatalog,...e.connectors].filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t):e.connectors}))}catch(e){y(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{C(!1)}}},[c,j,M]);(0,G.useEffect)(()=>{if(p!==`marketplace`)return;let e=window.setTimeout(()=>{j.trim()?Oe():M&&Oe({browse:!0})},j.trim()?350:0);return()=>window.clearTimeout(e)},[M,j,Oe,h.loading,p]);let Ae=(0,G.useMemo)(()=>new Set(h.instances.map(e=>e.connectorId)),[h.instances]),je=(0,G.useMemo)(()=>new Map([...h.catalog,...h.registryCatalog].map(e=>[e.id,e])),[h.catalog,h.registryCatalog]),Me=(0,G.useMemo)(()=>new Set(h.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[h.instances]),Ne=(0,G.useCallback)(async e=>{if(!J||K===void 0)return;let t=Y.filter(t=>t.clientKey!==e.clientKey);await dt({sessionIdleTtlMinutes:J.sessionIdleTtlMinutes,servers:t},rt(K)),await W(),await X()},[K,Y,X,J,W]),Pe=(0,G.useCallback)(()=>{se({mode:`add`,row:Wt(Y,Me)})},[Y,Me]),Fe=(0,G.useCallback)(async()=>{if(!(!J||K===void 0||le)){ue(!0),H(!1);try{await dt({sessionIdleTtlMinutes:V,servers:Y},rt(K)),await W(),H(!0),u({type:`success`,title:n.saved})}finally{ue(!1)}}},[K,Y,J,W,V,le]),Ie=v(e=>e.setPageHeader),Le=v(e=>e.clearPageHeader),Re=(0,G.useMemo)(()=>(0,q.jsx)(Ze,{loading:h.loading||S,searchQuery:j,setSearchQuery:ee,onReloadClick:X,onAddCustomServer:Pe,searchPlaceholder:p===`marketplace`?t.marketplaceSearchPlaceholder:p===`builtin`?t.builtinSearchPlaceholder:p===`user`?t.userSearchPlaceholder:t.configSearchPlaceholder,addLabel:t.addCustomServer,reloadLabel:t.reload}),[t,X,Pe,S,j,h.loading,p]);(0,G.useLayoutEffect)(()=>(Ie({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:Re}),()=>Le()),[Le,t.title,Re,Ie]);let ze=h.instances.length+Y.length,Be=(0,G.useMemo)(()=>Kt(h.catalog.filter(e=>e.source===`builtin`),j,F),[F,j,h.catalog]),Ve=(0,G.useMemo)(()=>Kt(h.registryCatalog,j,F),[F,j,h.registryCatalog]),He=p===`marketplace`&&!!(O&&T<O),Ue=(0,G.useMemo)(()=>h.instances.filter(e=>qt(e,j)),[j,h.instances]),We=(0,G.useMemo)(()=>Y.filter(e=>Jt(e,j)),[Y,j]),Ge=(0,G.useMemo)(()=>h.instances.find(e=>e.instanceId===re)??ae,[re,ae,h.instances]),Ke=Ue.length+We.length,qe=[{id:`marketplace`,label:t.tabMarketplace},{id:`builtin`,label:t.tabBuiltin,count:Be.length},{id:`user`,label:t.tabUser,count:ze},{id:`config`,label:t.tabConfig}];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:[c?null:(0,q.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:t.tokenHint}),(0,q.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-edge-subtle pb-3 sm:flex-row sm:items-center sm:justify-between dark:border-edge-subtle`,children:[(0,q.jsx)(ve,{items:qe,activeTab:p,onChange:m,ariaLabel:t.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`}),(0,q.jsxs)(`div`,{className:`flex min-h-9 min-w-0 flex-wrap items-center gap-2 sm:justify-end`,children:[p===`marketplace`?(0,q.jsx)(`div`,{className:`inline-flex h-9 max-w-full shrink-0 overflow-x-auto rounded-lg border border-edge bg-surface-panel p-0.5 shadow-surface`,role:`group`,"aria-label":t.registrySourceAria,children:h.registries.map(e=>(0,q.jsx)(`button`,{type:`button`,className:i(`shrink-0 rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors`,U.focusRingPanel,M===e.id?`bg-fg text-surface-panel dark:bg-fg dark:text-surface-base`:`text-fg-muted hover:text-fg`),"aria-pressed":M===e.id,onClick:()=>P(e.id),children:e.displayName},e.id))}):null,p!==`user`&&p!==`config`?(0,q.jsxs)(x,{children:[(0,q.jsx)(he,{asChild:!0,children:(0,q.jsxs)(`button`,{type:`button`,className:i(`inline-flex h-9 min-h-9 min-w-[9rem] shrink-0 items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 text-xs font-medium text-fg shadow-surface`,U.transition,U.focusRingPanel),children:[(0,q.jsx)(N,{className:`size-3.5 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,q.jsx)(`span`,{children:F===`name`?t.sortName:t.sortSource}),(0,q.jsx)(de,{className:`size-3.5 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0})]})}),(0,q.jsx)(b,{children:(0,q.jsxs)(w,{className:`z-50 min-w-[10rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[(0,q.jsx)(_,{className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover data-[highlighted]:bg-surface-hover`,onSelect:()=>I(`name`),children:t.sortName}),(0,q.jsx)(_,{className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover data-[highlighted]:bg-surface-hover`,onSelect:()=>I(`source`),children:t.sortSource})]})})]}):null]})]}),h.error?(0,q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:h.error}):null,p===`user`&&c?(0,q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.installedTitle}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.installedHint})]}),h.loading?(0,q.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":t.loading,children:ye.slice(0,3).map(e=>(0,q.jsx)(Se,{},e))}):ze===0||Ke===0?(0,q.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:ze===0?t.installedEmpty:t.userEmpty}):(0,q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:[Ue.map(e=>(0,q.jsx)(Ft,{instance:e,definition:je.get(e.connectorId),onOpenDetails:e=>{ie(e.instanceId),oe(e)},onChanged:X,t},e.instanceId)),We.map(e=>(0,q.jsx)(yt,{row:e,t:n,cs:t,onEdit:()=>se({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>Ne(e)},e.clientKey))]}),(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.disableHint})]}):null,p===`config`&&c?(0,q.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,q.jsxs)(_e,{children:[(0,q.jsx)(ge,{icon:pe,title:n.globalTitle,subtitle:n.globalHint}),(0,q.jsx)(`div`,{className:`max-w-xl`,children:(0,q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.idleTtlLabel}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`input`,{type:`number`,min:0,className:i(cn,`w-40 flex-none`),value:V??``,placeholder:n.idleTtlPlaceholder,onChange:e=>{let t=e.target.value.trim();ce(t===``?void 0:Number.parseInt(t,10)),H(!1)}}),(0,q.jsxs)(D,{variant:`secondary`,disabled:le,onClick:()=>void Fe(),children:[le?(0,q.jsx)(k,{className:`size-4 animate-spin`}):null,n.save]})]}),(0,q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.idleTtlHint})]})})]})}):null,p===`marketplace`&&c?(0,q.jsx)(`div`,{className:`flex flex-col gap-4`,children:S&&Ve.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:ye.map(e=>(0,q.jsx)(xe,{},e))}):j.trim()&&Ve.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.marketplaceEmpty}):!j.trim()&&Ve.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.marketplaceStartHint}):(0,q.jsxs)(`div`,{className:`relative`,children:[S?(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)(k,{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:Ve.map(e=>(0,q.jsx)(Ce,{connector:e,installed:Ae.has(e.id)||be(e,h.instances),onInstall:e=>L(Bt(e)),onOpenDetails:z,t},e.id))}),He?(0,q.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,q.jsxs)(D,{type:`button`,variant:`secondary`,disabled:S,onClick:()=>void Oe({browse:!j.trim(),page:T+1,append:!0}),children:[S?(0,q.jsx)(k,{className:`size-4 animate-spin`}):null,t.loadMore]})}):null]})}):null,p===`builtin`&&c?(0,q.jsx)(`div`,{className:`flex flex-col gap-4`,children:h.loading?(0,q.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:ye.map(e=>(0,q.jsx)(xe,{},e))}):Be.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.builtinEmpty}):(0,q.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:Be.map(e=>(0,q.jsx)(Ce,{connector:e,installed:Ae.has(e.id)||be(e,h.instances),onInstall:e=>L(Bt(e)),onOpenDetails:z,t},e.id))})}):null]}),te?(0,q.jsx)(Ut,{draft:te,onChange:L,onClose:()=>L(null),t,onInstalled:async()=>{await X(),await W(),m(`user`)}}):null,R?(0,q.jsx)(Xe,{connector:R,installed:Ae.has(R.id)||be(R,h.instances),onClose:()=>z(null),onInstall:e=>L(Bt(e)),t}):null,Ge?(0,q.jsx)(Pt,{instance:Ge,definition:je.get(Ge.connectorId),onClose:()=>{ie(null),oe(null)},onChanged:X,t,mcp:n}):null,B?(0,q.jsx)(an,{open:!0,mode:B.mode,initialRow:B.row,existingCustomServers:Y,sessionIdleTtlMinutes:V,config:K,managedServerIds:Me,t:n,cs:t,onClose:()=>se(null),onSaved:async()=>{await W(),await X(),m(`user`)}},`${B.mode}-${B.row.clientKey}`):null]})})}export{ln as ConnectorsPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as ee}from"./cn-BQ_8x0bT.js";import{t as te}from"./messages-DmnbiNxU.js";import{n as ne}from"./locale-store-Ba72bFmP.js";import{at as i,ot as a,tl as re,yo as ie}from"./index-C2F0Clvm.js";import{t as ae}from"./desktop-pet-sprite-DqZ6fbIj.js";var o=e(t(),1),oe=n();function se(e){return e.kind===`agent-error`||e.severity===`error`?`error`:e.kind===`agent-success`||e.severity===`success`?`success`:e.kind===`agent-start`||e.kind===`agent-progress`?`typing`:e.kind===`agent-tool`?l(e.toolName):`idle`}function s(e){return a(e).replace(/[.:/\\]+/g,`_`)}function c(e,t){let n=e?.trim();if(!n)return t.toolActionUnknown;let r=s(n);if(r===`update_plan`||r.includes(`plan`))return t.toolActionUpdatePlan;if(r.includes(`browser`)||r.includes(`playwright`)||r.includes(`chrome`))return t.toolActionBrowse;if(r===`image_query`||r.includes(`image`)||r.includes(`visual`))return t.toolActionImage;if(r===`finance`||r.includes(`stock`)||r.includes(`market`)||r.includes(`crypto`))return t.toolActionFinance;if(r===`weather`||r.includes(`forecast`))return t.toolActionWeather;if(r===`sports`||r.includes(`score`)||r.includes(`schedule`))return t.toolActionSports;if(r===`time`||r.includes(`timezone`))return t.toolActionTime;if(r.includes(`memory`)||r.includes(`remember`))return t.toolActionMemory;if(r.includes(`automation`)||r.includes(`reminder`)||r.includes(`cron`))return t.toolActionAutomation;if(r.includes(`mcp`)||r.includes(`connector`)||r.includes(`plugin`))return t.toolActionConnector;if(r.includes(`apply_patch`)||r.includes(`edit_file`)||r.includes(`patch`))return t.toolActionEditFile;if(r.includes(`write_file`)||r.includes(`save_file`))return t.toolActionWriteFile;if(r.includes(`read_file`)||r.includes(`file_read`))return t.toolActionReadFile;if(r.includes(`exec_command`)||r.includes(`run_command`)||r.includes(`shell`)||r.includes(`bash`)||r.includes(`powershell`))return t.toolActionRunCommand;if(r.includes(`list_dir`)||r.includes(`list_directory`))return t.toolActionListDirectory;if(r.includes(`web_fetch`)||r.includes(`fetch_url`))return t.toolActionFetchUrl;if(r.includes(`open_url`))return t.toolActionOpenUrl;if(r.includes(`search`))return t.toolActionSearch;switch(i(n)){case`search`:return t.toolActionSearch;case`readFile`:return t.toolActionReadFile;case`editFile`:return t.toolActionEditFile;case`writeFile`:return t.toolActionWriteFile;case`runCommand`:return t.toolActionRunCommand;case`listDir`:return t.toolActionListDirectory;case`openUrl`:return t.toolActionOpenUrl;case`fetchUrl`:return t.toolActionFetchUrl;case`other`:return t.toolActionUnknown}return t.toolActionUnknown}function l(e){let t=e?.trim();if(!t)return`toolbox`;let n=s(t);if(n.includes(`browser`)||n.includes(`playwright`)||n.includes(`chrome`))return`browser`;if(n===`image_query`||n.includes(`image`)||n.includes(`visual`)||n===`weather`||n.includes(`forecast`)||n===`finance`||n.includes(`stock`)||n.includes(`market`)||n.includes(`crypto`)||n===`sports`||n.includes(`score`)||n.includes(`schedule`))return`search`;if(n.includes(`apply_patch`)||n.includes(`edit_file`)||n.includes(`patch`)||n.includes(`write_file`)||n.includes(`save_file`)||n.includes(`read_file`)||n.includes(`file_read`)||n.includes(`list_dir`)||n.includes(`list_directory`))return`file`;if(n.includes(`exec_command`)||n.includes(`run_command`)||n.includes(`shell`)||n.includes(`bash`)||n.includes(`powershell`))return`terminal`;if(n.includes(`web_fetch`)||n.includes(`fetch_url`)||n.includes(`open_url`))return`browser`;if(n.includes(`search`))return`search`;switch(i(t)){case`search`:return`search`;case`readFile`:case`editFile`:case`writeFile`:case`listDir`:return`file`;case`runCommand`:return`terminal`;case`openUrl`:case`fetchUrl`:return`browser`;case`other`:return`toolbox`}return`toolbox`}function u(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>t[n]??``)}function ce(e,t,n){if(e.message?.trim())return e.message.trim();let r=t===`zh`;return e.kind===`agent-start`?r?`收到,我开始处理。`:`Got it. I am on it.`:e.kind===`agent-tool`?u(n.toolUsing,{action:c(e.toolName,n)}):e.kind===`agent-progress`?r?`还在处理中。`:`Still working.`:e.kind===`agent-success`?r?`处理好了,点我查看。`:`Done. Click me to view it.`:e.kind===`agent-error`?r?`这里卡住了,点我看详情。`:`Something needs attention. Click for details.`:e.kind===`goal`?r?`目标状态有更新。`:`A goal status changed.`:r?`我在这里,有事点我。`:`I am here when you need me.`}var d=r();function f(){return{prefs:{enabled:!0,showOnStartup:!1,selectedPetId:`ember`,alwaysOnTop:!0,bubbleEnabled:!0,clickThroughWhenIdle:!1,muted:!1,feedbackLevel:`normal`,sizePercent:100,collapsed:!1},pets:[],visible:!0,customPetsDir:``,petIssues:[]}}function p(){let e=(0,oe.c)(80),t=ne(pe),n;e[0]===t?n=e[1]:(n=te(t),e[0]=t,e[1]=n);let r=n.desktopPet,[i,a]=(0,o.useState)(fe),[s,c]=(0,o.useState)(`idle`),[l,u]=(0,o.useState)(null),[f,p]=(0,o.useState)(0),[m,me]=(0,o.useState)(`/chat`),h=(0,o.useRef)(null),g=(0,o.useRef)(!1),_;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(_=[],e[2]=_):_=e[2],(0,o.useEffect)(de,_);let v,y;e[3]!==t||e[4]!==i.prefs.collapsed||e[5]!==i.prefs.feedbackLevel||e[6]!==r?(v=()=>{let e=window.electronAPI?.pet;if(!e)return;e.getState().then(e=>{a(e),p(0)}).catch(ue);let n=e.onStateChanged(e=>{a(e),e.prefs.collapsed||p(0)}),ee=e.onEvent(e=>{i.prefs.feedbackLevel===`quiet`&&e.severity!==`error`&&e.kind!==`agent-success`||(c(se(e)),u(ce(e,t,r)),p(e=>i.prefs.collapsed?Math.min(99,Math.max(1,e)+1):1),e.route?.startsWith(`/`)&&me(e.route),window.clearTimeout(Number(window.desktopPetBubbleTimer)),window.desktopPetBubbleTimer=window.setTimeout(()=>{c(`idle`),u(null),i.prefs.collapsed||p(0)},e.severity===`error`?9e3:6200))});return()=>{n(),ee()}},y=[t,i.prefs.collapsed,i.prefs.feedbackLevel,r],e[3]=t,e[4]=i.prefs.collapsed,e[5]=i.prefs.feedbackLevel,e[6]=r,e[7]=v,e[8]=y):(v=e[7],y=e[8]),(0,o.useEffect)(v,y);let b;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(b=[],e[9]=b):b=e[9],(0,o.useEffect)(le,b);let x;e[10]!==i.pets||e[11]!==i.prefs.selectedPetId?(x=i.pets.find(e=>e.id===i.prefs.selectedPetId)??i.pets[0],e[10]=i.pets,e[11]=i.prefs.selectedPetId,e[12]=x):x=e[12];let S=x,C=Math.min(1.4,Math.max(.7,i.prefs.sizePercent/100)),w;e[13]===C?w=e[14]:(w=Math.round(112*C),e[13]=C,e[14]=w);let he=w,T;e[15]===C?T=e[16]:(T=Math.round(132*C),e[15]=C,e[16]=T);let ge=`${T}px`,E;e[17]===C?E=e[18]:(E=Math.round(24*C),e[17]=C,e[18]=E);let _e=`${E}px`,D;e[19]===C?D=e[20]:(D=Math.round(16*C),e[19]=C,e[20]=D);let O=`${D}px`,k;e[21]===C?k=e[22]:(k=Math.round(28*C),e[21]=C,e[22]=k);let A=`${k}px`,j;e[23]===C?j=e[24]:(j=Math.round(-6*C),e[23]=C,e[24]=j);let M=`${j}px`,N;e[25]===C?N=e[26]:(N=Math.round(12*C),e[25]=C,e[26]=N);let P=`${N}px`,F;e[27]!==_e||e[28]!==O||e[29]!==A||e[30]!==M||e[31]!==P||e[32]!==ge?(F={"--desktop-pet-stage-size":ge,"--desktop-pet-stage-right":_e,"--desktop-pet-stage-bottom":O,"--desktop-pet-menu-size":A,"--desktop-pet-menu-left":M,"--desktop-pet-menu-bottom":P},e[27]=_e,e[28]=O,e[29]=A,e[30]=M,e[31]=P,e[32]=ge,e[33]=F):F=e[33];let I=F,L;e[34]===m?L=e[35]:(L=()=>{window.electronAPI?.pet?.openMainWindow(m)},e[34]=m,e[35]=L);let R=L,z;e[36]!==l||e[37]!==i.prefs.collapsed?(z=async()=>{let e=!i.prefs.collapsed;p(t=>e&&l?Math.max(1,t):0),a(t=>({...t,prefs:{...t.prefs,collapsed:e}}));let t=await window.electronAPI?.pet?.setPrefs({collapsed:e});t&&a(t)},e[36]=l,e[37]=i.prefs.collapsed,e[38]=z):z=e[38];let ve=z,B;e[39]===Symbol.for(`react.memo_cache_sentinel`)?(B=e=>{e.button===0&&(h.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,moved:!1},e.currentTarget.setPointerCapture(e.pointerId),window.electronAPI?.pet?.startDrag({screenX:e.screenX,screenY:e.screenY}))},e[39]=B):B=e[39];let ye=B,V;e[40]===Symbol.for(`react.memo_cache_sentinel`)?(V=e=>{let t=h.current;!t||t.pointerId!==e.pointerId||Math.abs(e.clientX-t.startX)+Math.abs(e.clientY-t.startY)>4&&(t.moved=!0,e.preventDefault(),window.electronAPI?.pet?.drag({screenX:e.screenX,screenY:e.screenY}))},e[40]=V):V=e[40];let be=V,H;e[41]===Symbol.for(`react.memo_cache_sentinel`)?(H=e=>{let t=h.current;!t||t.pointerId!==e.pointerId||(h.current=null,window.electronAPI?.pet?.endDrag(),t.moved&&(g.current=!0,e.preventDefault(),e.stopPropagation(),window.setTimeout(()=>{g.current=!1},0)))},e[41]=H):H=e[41];let xe=H,U;e[42]===R?U=e[43]:(U=()=>{g.current||R()},e[42]=R,e[43]=U);let W=U;if(!S){let t;return e[44]===r.loading?t=e[45]:(t=(0,d.jsx)(`div`,{className:`flex h-screen items-center justify-center bg-transparent text-sm text-fg-muted`,children:r.loading}),e[44]=r.loading,e[45]=t),t}let G;e[46]!==l||e[47]!==R||e[48]!==i.prefs.bubbleEnabled||e[49]!==i.prefs.collapsed||e[50]!==r.openApp?(G=i.prefs.bubbleEnabled&&!i.prefs.collapsed&&l?(0,d.jsx)(`button`,{type:`button`,className:ee(`desktop-pet-bubble`,ie.press),onClick:R,title:r.openApp,children:(0,d.jsx)(`span`,{className:`line-clamp-2`,children:l})}):null,e[46]=l,e[47]=R,e[48]=i.prefs.bubbleEnabled,e[49]=i.prefs.collapsed,e[50]=r.openApp,e[51]=G):G=e[51];let Se=i.prefs.collapsed&&`desktop-pet-menu-button--collapsed`,K;e[52]===Se?K=e[53]:(K=ee(`desktop-pet-menu-button`,Se),e[52]=Se,e[53]=K);let q;e[54]===ve?q=e[55]:(q=()=>void ve(),e[54]=ve,e[55]=q);let J;e[56]!==i.prefs.collapsed||e[57]!==f?(J=i.prefs.collapsed&&f>0?(0,d.jsx)(`span`,{className:`desktop-pet-tip-count`,children:f}):(0,d.jsx)(re,{className:`desktop-pet-menu-chevron size-4`,strokeWidth:1.8}),e[56]=i.prefs.collapsed,e[57]=f,e[58]=J):J=e[58];let Y;e[59]!==i.prefs.collapsed||e[60]!==r.menu||e[61]!==K||e[62]!==q||e[63]!==J?(Y=(0,d.jsx)(`button`,{type:`button`,className:K,onClick:q,"aria-pressed":i.prefs.collapsed,"aria-label":r.menu,title:r.menu,children:J}),e[59]=i.prefs.collapsed,e[60]=r.menu,e[61]=K,e[62]=q,e[63]=J,e[64]=Y):Y=e[64];let X;e[65]!==s||e[66]!==he||e[67]!==S?(X=(0,d.jsx)(ae,{pet:S,action:s,displayHeight:he}),e[65]=s,e[66]=he,e[67]=S,e[68]=X):X=e[68];let Z;e[69]!==W||e[70]!==r.openApp||e[71]!==X?(Z=(0,d.jsx)(`button`,{type:`button`,className:`desktop-pet-hit-area`,onClick:W,onDoubleClick:W,onPointerDown:ye,onPointerMove:be,onPointerUp:xe,onPointerCancel:xe,title:r.openApp,children:X}),e[69]=W,e[70]=r.openApp,e[71]=X,e[72]=Z):Z=e[72];let Q;e[73]!==Y||e[74]!==Z?(Q=(0,d.jsxs)(`div`,{className:`desktop-pet-stage`,children:[Y,Z]}),e[73]=Y,e[74]=Z,e[75]=Q):Q=e[75];let $;return e[76]!==I||e[77]!==G||e[78]!==Q?($=(0,d.jsxs)(`div`,{className:`desktop-pet-window`,style:I,children:[G,Q]}),e[76]=I,e[77]=G,e[78]=Q,e[79]=$):$=e[79],$}function le(){window.electronAPI?.pet?.setClickThrough(!1)}function ue(){}function de(){return document.documentElement.dataset.desktopPet=`true`,m}function m(){delete document.documentElement.dataset.desktopPet}function fe(){return f()}function pe(e){return e.language}function me(){let e=(0,oe.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,d.jsx)(p,{}),e[0]=t):t=e[0],t}export{me as DesktopPetPage};
@@ -1,3 +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"./cn-BQ_8x0bT.js";import{t as a}from"./messages-DmnbiNxU.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s,i as c,n as l}from"./fetch-pg2ErdAk.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{Dt as d,El as f,Hs as p,Oo as m,Ps as h,Qo as g,Ss as _,To as v,Us as y,Wo as b,as as x,bl as S,eo as C,ic as w,ma as T,ms as E,no as D,nr as O,us as k,xo as A,zo as j}from"./index-C2F0Clvm.js";import{n as ee,r as M,t as te}from"./settings-page-layout-DBRWwdhh.js";import{n as ne,t as re}from"./settings-form-section-Bugp38Fa.js";import{t as N}from"./page-tabs-DDC2t4Z8.js";import{n as P,t as F}from"./schedule-field-CUttkoSB.js";import{t as I}from"./format-cron-label-arqgGlVV.js";var L=e(t(),1),R=n();function z(e,t){let n=new URLSearchParams;e&&n.set(`agentId`,e);for(let[e,r]of Object.entries(t??{}))r!==void 0&&n.set(e,String(r));let r=n.toString();return r?`?${r}`:``}function ie(e){return c(`/api/dreaming${z(e)}`)}async function B(e){let t=await l(e?.startsWith(`/api/`)||e?.includes(`/api/dreaming`)?e:ie(e));if(!t.payload)throw Error(`Missing payload`);return t.payload}async function ae(e,t){await l(c(`/api/dreaming/action`),{method:`POST`,body:JSON.stringify({action:e,agentId:t})})}async function oe(e=`deep`,t){let n=await l(c(`/api/dreaming/run`),{method:`POST`,body:JSON.stringify({phase:e,agentId:t})});if(n.ok===!1||!n.payload)throw Error(`Failed to run dreaming phase`);let r=n.payload.phase;return{agentId:typeof n.payload.agentId==`string`?n.payload.agentId:void 0,phase:r===`light`||r===`deep`||r===`rem`?r:e,result:n.payload.result}}async function se(e,t){let n=await l(c(`/api/dreaming/preview${z(t,typeof e==`number`&&Number.isFinite(e)?{limit:e}:void 0)}`));if(!n.payload)throw Error(`Missing payload`);return n.payload}async function ce(e=50,t){return(await l(c(`/api/dreaming/events${z(t,{limit:e})}`))).payload?.events??[]}function V(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var H={enabled:!0,cron:`0 */6 * * *`,lookbackDays:1,limit:50,dedupeSimilarity:.85},U={enabled:!0,cron:`0 3 * * *`,minScore:.8,minRecallCount:3,minUniqueQueries:3,limit:10,recencyHalfLifeDays:14,maxAgeDays:30},W={enabled:!0,cron:`0 5 * * 0`,lookbackDays:7,limit:20,minPatternStrength:.6},G={enabled:!1,frequency:`0 3 * * *`,timezone:``,deepEnabled:!0,minScore:.8,minRecallCount:3,limit:10,light:H,deep:U,rem:W};function K(e,t){return Number.isFinite(e)?Math.max(0,Math.min(1,e)):t}function q(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?Math.max(0,Math.floor(n)):t}function J(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?n:t}function le(e){let t=V(e)?e:{},n=V(t.memory)?t.memory:{},r=V(t.dreaming)?t.dreaming:{},i=typeof t.enabled==`boolean`||typeof t.frequency==`string`||V(t.phases)?t:{},a=V(n.dreaming)?n.dreaming:Object.keys(r).length>0?r:i,o=V(a.phases)?a.phases:{},s=V(o.light)?o.light:{},c=V(o.deep)?o.deep:{},l=V(o.rem)?o.rem:{};return{enabled:a.enabled===!0,frequency:typeof a.frequency==`string`&&a.frequency.trim()?a.frequency.trim():G.frequency,timezone:typeof a.timezone==`string`?a.timezone:``,deepEnabled:c.enabled!==!1,minScore:K(typeof c.minScore==`number`?c.minScore:Number(c.minScore),G.minScore),minRecallCount:Math.max(1,q(c.minRecallCount,G.minRecallCount)),limit:q(c.limit,G.limit),light:{enabled:s.enabled!==!1,cron:typeof s.cron==`string`&&s.cron.trim()?s.cron.trim():H.cron,lookbackDays:Math.max(1,q(s.lookbackDays,H.lookbackDays)),limit:q(s.limit,H.limit),dedupeSimilarity:K(J(s.dedupeSimilarity,H.dedupeSimilarity),H.dedupeSimilarity)},deep:{enabled:c.enabled!==!1,cron:typeof c.cron==`string`&&c.cron.trim()?c.cron.trim():U.cron,minScore:K(J(c.minScore,U.minScore),U.minScore),minRecallCount:Math.max(1,q(c.minRecallCount,U.minRecallCount)),minUniqueQueries:Math.max(1,q(c.minUniqueQueries,U.minUniqueQueries)),limit:q(c.limit,U.limit),recencyHalfLifeDays:Math.max(1,J(c.recencyHalfLifeDays,U.recencyHalfLifeDays)),maxAgeDays:Math.max(1,J(c.maxAgeDays,U.maxAgeDays))},rem:{enabled:l.enabled!==!1,cron:typeof l.cron==`string`&&l.cron.trim()?l.cron.trim():W.cron,lookbackDays:Math.max(1,q(l.lookbackDays,W.lookbackDays)),limit:q(l.limit,W.limit),minPatternStrength:K(J(l.minPatternStrength,W.minPatternStrength),W.minPatternStrength)}}}async function ue(e,t,n){let r=t.frequency.trim(),i=t.timezone.trim();await l(c(`/api/agents/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({memory:{...n??{},mode:t.enabled?`confirmWrite`:typeof n?.mode==`string`?n.mode:`off`,sources:Array.isArray(n?.sources)?n.sources:[`session`,`curated`,`workspace`],writePolicy:V(n?.writePolicy)?n.writePolicy:{curated:`confirm`,workspace:`confirm`},dreaming:{enabled:!!t.enabled,...r?{frequency:r}:{},...i?{timezone:i}:{},phases:{light:{enabled:!!t.light.enabled,...t.light.cron.trim()?{cron:t.light.cron.trim()}:{},lookbackDays:Math.max(1,Math.floor(t.light.lookbackDays)),limit:Math.max(0,Math.floor(t.light.limit)),dedupeSimilarity:K(t.light.dedupeSimilarity,H.dedupeSimilarity)},deep:{enabled:!!t.deep.enabled,...t.deep.cron.trim()?{cron:t.deep.cron.trim()}:{},minScore:K(t.deep.minScore,U.minScore),minRecallCount:Math.max(1,Math.floor(t.deep.minRecallCount)),minUniqueQueries:Math.max(1,Math.floor(t.deep.minUniqueQueries)),limit:Math.max(0,Math.floor(t.deep.limit)),recencyHalfLifeDays:Math.max(1,t.deep.recencyHalfLifeDays),maxAgeDays:Math.max(1,t.deep.maxAgeDays)},rem:{enabled:!!t.rem.enabled,...t.rem.cron.trim()?{cron:t.rem.cron.trim()}:{},lookbackDays:Math.max(1,Math.floor(t.rem.lookbackDays)),limit:Math.max(0,Math.floor(t.rem.limit)),minPatternStrength:K(t.rem.minPatternStrength,W.minPatternStrength)}}}}})}),T()}var de=`p-4 sm:px-5`,fe=`mb-3`,Y=`rounded-xl bg-surface-panel/60 p-3 shadow-surface sm:p-4`,X=i(`mt-1 w-full rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm text-fg`,A);function pe(e){return e?e.replace(`T`,` `).replace(`Z`,``):`—`}function me(e){return e===void 0||!Number.isFinite(e)||e<0?`—`:e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(2)} s`}function he(e,t){return e.locked?{text:t.lockValueLocked,className:`text-amber-600 dark:text-amber-400`}:{text:t.lockValueUnlocked,className:`text-emerald-600 dark:text-emerald-400`}}var Z=r(),ge=`text-xs font-medium text-fg-muted`,_e=`text-sm font-medium text-fg`;function Q(e){let t=(0,R.c)(6),{label:n,children:r,className:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`span`,{className:ge,children:n}),t[0]=n,t[1]=a);let o;return t[2]!==r||t[3]!==i||t[4]!==a?(o=(0,Z.jsxs)(`div`,{className:i,children:[a,r]}),t[2]=r,t[3]=i,t[4]=a,t[5]=o):o=t[5],o}function $(e){let t=(0,R.c)(11),{label:n,children:r,className:a}=e,o;t[0]===a?o=t[1]:(o=i(`min-w-0`,a),t[0]=a,t[1]=o);let s;t[2]===n?s=t[3]:(s=(0,Z.jsx)(`dt`,{className:ge,children:n}),t[2]=n,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=i(_e,`mt-0.5`),t[4]=c):c=t[4];let l;t[5]===r?l=t[6]:(l=(0,Z.jsx)(`dd`,{className:c,children:r}),t[5]=r,t[6]=l);let u;return t[7]!==o||t[8]!==s||t[9]!==l?(u=(0,Z.jsxs)(`div`,{className:o,children:[s,l]}),t[7]=o,t[8]=s,t[9]=l,t[10]=u):u=t[10],u}function ve(e){let t=(0,R.c)(5),{label:n,className:r}=e,a;t[0]===r?a=t[1]:(a=i(`text-[0.7rem] font-semibold uppercase tracking-wider text-fg-muted`,r),t[0]=r,t[1]=a);let o;return t[2]!==n||t[3]!==a?(o=(0,Z.jsx)(`h3`,{className:a,children:n}),t[2]=n,t[3]=a,t[4]=o):o=t[4],o}function ye(e){let t=(0,R.c)(39),{icon:n,title:r,hint:i,enabled:a,onEnabledChange:o,cron:s,onCronChange:c,scheduleLabels:l,disabled:u,showEnabledControl:d,actions:f,status:p,enabledLabel:m,onLabel:h,offLabel:g,cronLabel:_,children:v}=e,y=d===void 0?!0:d,b;t[0]===n?b=t[1]:(b=(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:n}),t[0]=n,t[1]=b);let x;t[2]===r?x=t[3]:(x=(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=x);let S;t[4]!==p||t[5]!==x?(S=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[x,p]}),t[4]=p,t[5]=x,t[6]=S):S=t[6];let C;t[7]===i?C=t[8]:(C=(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs leading-snug text-fg-muted`,children:i}),t[7]=i,t[8]=C);let w;t[9]!==S||t[10]!==C?(w=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[S,C]}),t[9]=S,t[10]=C,t[11]=w):w=t[11];let T;t[12]!==b||t[13]!==w?(T=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[b,w]}),t[12]=b,t[13]=w,t[14]=T):T=t[14];let E;t[15]!==f||t[16]!==u||t[17]!==a||t[18]!==m||t[19]!==g||t[20]!==o||t[21]!==h||t[22]!==y?(E=f||y?(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[f,y?(0,Z.jsxs)(`label`,{className:`inline-flex shrink-0 items-center gap-2 text-xs text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:a,disabled:u,onChange:e=>o(e.target.checked)}),(0,Z.jsx)(`span`,{children:m??(a?h:g)})]}):null]}):null,t[15]=f,t[16]=u,t[17]=a,t[18]=m,t[19]=g,t[20]=o,t[21]=h,t[22]=y,t[23]=E):E=t[23];let D;t[24]!==T||t[25]!==E?(D=(0,Z.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-start justify-between gap-2 rounded-lg bg-surface-base/45 px-3 py-2.5`,children:[T,E]}),t[24]=T,t[25]=E,t[26]=D):D=t[26];let O;t[27]!==s||t[28]!==_||t[29]!==u||t[30]!==c||t[31]!==l?(O=(0,Z.jsx)(F,{kind:`cron`,className:`mb-2.5`,label:_,value:s,onChange:c,labels:l,disabled:u}),t[27]=s,t[28]=_,t[29]=u,t[30]=c,t[31]=l,t[32]=O):O=t[32];let k;t[33]===v?k=t[34]:(k=(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4`,children:v}),t[33]=v,t[34]=k);let A;return t[35]!==O||t[36]!==k||t[37]!==D?(A=(0,Z.jsxs)(`div`,{className:Y,children:[D,O,k]}),t[35]=O,t[36]=k,t[37]=D,t[38]=A):A=t[38],A}function be(e){let t=(0,R.c)(23),{icon:n,label:r,enabled:a,cron:o,scheduleSummary:s,details:c,t:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(Y,`space-y-1`),t[0]=u):u=t[0];let d;t[1]===r?d=t[2]:(d=(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r}),t[1]=r,t[2]=d);let f=a?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`,p;t[3]===f?p=t[4]:(p=i(`ml-auto text-xs font-medium`,f),t[3]=f,t[4]=p);let m=a?l.on:l.off,h;t[5]!==p||t[6]!==m?(h=(0,Z.jsx)(`span`,{className:p,children:m}),t[5]=p,t[6]=m,t[7]=h):h=t[7];let g;t[8]!==n||t[9]!==d||t[10]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n,d,h]}),t[8]=n,t[9]=d,t[10]=h,t[11]=g):g=t[11];let _;t[12]===s?_=t[13]:(_=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:s}),t[12]=s,t[13]=_);let v;t[14]===o?v=t[15]:(v=(0,Z.jsx)(`p`,{className:`truncate font-mono text-[0.65rem] text-fg-subtle`,title:o,children:o}),t[14]=o,t[15]=v);let y;t[16]===c?y=t[17]:(y=(0,Z.jsx)(`p`,{className:`text-[0.65rem] leading-snug text-fg-muted`,children:c}),t[16]=c,t[17]=y);let b;return t[18]!==y||t[19]!==g||t[20]!==_||t[21]!==v?(b=(0,Z.jsxs)(`div`,{className:u,children:[g,_,v,y]}),t[18]=y,t[19]=g,t[20]=_,t[21]=v,t[22]=b):b=t[22],b}function xe(e){let t=(0,R.c)(9),{label:n,lastRun:r,t:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(ve,{label:n,className:`mb-2`}),t[0]=n,t[1]=a);let o;t[2]!==r||t[3]!==i.lastRunRaw||t[4]!==i.phaseLastRunEmpty?(o=r?.exists?(0,Z.jsxs)(`details`,{className:`group rounded-lg bg-surface-panel/70 shadow-surface`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer list-none px-2.5 py-1.5 text-xs font-medium text-fg-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:(0,Z.jsx)(`span`,{className:`underline decoration-edge underline-offset-2 group-open:text-fg`,children:i.lastRunRaw})}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto bg-surface-base/50 p-2.5 text-xs text-fg-muted`,children:JSON.stringify(r.raw,null,2)})]}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.phaseLastRunEmpty}),t[2]=r,t[3]=i.lastRunRaw,t[4]=i.phaseLastRunEmpty,t[5]=o):o=t[5];let s;return t[6]!==a||t[7]!==o?(s=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-base/45 p-3`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8],s}function Se(e){let t=(0,R.c)(39),{t:n,r}=e,i=r.deep?.skipped,a=r.ok?`text-emerald-600 dark:text-emerald-400`:`text-amber-600 dark:text-amber-400`,o=r.ok?n.lastRunSuccess:n.lastRunFailure,s;t[0]!==a||t[1]!==o?(s=(0,Z.jsx)(`span`,{className:a,children:o}),t[0]=a,t[1]=o,t[2]=s):s=t[2];let c;t[3]!==n.lastRunStatus||t[4]!==s?(c=(0,Z.jsx)($,{label:n.lastRunStatus,children:s}),t[3]=n.lastRunStatus,t[4]=s,t[5]=c):c=t[5];let l=n.lastRunDuration,u;t[6]===r.durationMs?u=t[7]:(u=me(r.durationMs),t[6]=r.durationMs,t[7]=u);let d;t[8]!==n.lastRunDuration||t[9]!==u?(d=(0,Z.jsx)($,{label:l,children:u}),t[8]=n.lastRunDuration,t[9]=u,t[10]=d):d=t[10];let f=n.lastRunRanked,p=String(r.deep?.candidatesRanked??`—`),m;t[11]!==n.lastRunRanked||t[12]!==p?(m=(0,Z.jsx)($,{label:f,children:p}),t[11]=n.lastRunRanked,t[12]=p,t[13]=m):m=t[13];let h=n.lastRunApplied,g=String(r.deep?.applied??`—`),_;t[14]!==n.lastRunApplied||t[15]!==g?(_=(0,Z.jsx)($,{label:h,children:g}),t[14]=n.lastRunApplied,t[15]=g,t[16]=_):_=t[16];let v;t[17]===r.reason?v=t[18]:(v=(0,Z.jsx)(`span`,{className:`block text-pretty`,children:r.reason}),t[17]=r.reason,t[18]=v);let y;t[19]!==r.errorMessage||t[20]!==n.lastRunError?(y=r.errorMessage?(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-amber-600 dark:text-amber-400`,children:`${n.lastRunError}: ${r.errorMessage}`}):null,t[19]=r.errorMessage,t[20]=n.lastRunError,t[21]=y):y=t[21];let b;t[22]!==n.lastRunReason||t[23]!==v||t[24]!==y?(b=(0,Z.jsxs)($,{label:n.lastRunReason,className:`col-span-2 sm:col-span-3 lg:col-span-4`,children:[v,y]}),t[22]=n.lastRunReason,t[23]=v,t[24]=y,t[25]=b):b=t[25];let x;t[26]!==i||t[27]!==n.lastRunSkipContaminated||t[28]!==n.lastRunSkipHash||t[29]!==n.lastRunSkipKey||t[30]!==n.lastRunSkipRehydrate?(x=i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:n.lastRunSkipKey,children:String(i.alreadyPromotedKey)}),(0,Z.jsx)($,{label:n.lastRunSkipRehydrate,children:String(i.rehydrateFailed)}),(0,Z.jsx)($,{label:n.lastRunSkipContaminated,children:String(i.contaminated)}),(0,Z.jsx)($,{label:n.lastRunSkipHash,children:String(i.hashDuplicate)})]}):null,t[26]=i,t[27]=n.lastRunSkipContaminated,t[28]=n.lastRunSkipHash,t[29]=n.lastRunSkipKey,t[30]=n.lastRunSkipRehydrate,t[31]=x):x=t[31];let S;return t[32]!==m||t[33]!==_||t[34]!==b||t[35]!==x||t[36]!==c||t[37]!==d?(S=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-3 lg:grid-cols-4`,children:[c,d,m,_,b,x]}),t[32]=m,t[33]=_,t[34]=b,t[35]=x,t[36]=c,t[37]=d,t[38]=S):S=t[38],S}function Ce(e){let t=(0,R.c)(56),{t:n,schedulePickerLabels:r,hasToken:a,cfgForm:o,cfgBaseline:s,cfgDirty:c,cfgSaving:l,runPhase:u,runBusy:d,setCfgForm:f,doRunNow:p}=e,m;t[0]!==c||t[1]!==o?.enabled||t[2]!==l||t[3]!==p||t[4]!==a||t[5]!==d||t[6]!==u||t[7]!==n?(m=(e,t)=>o?.enabled?(0,Z.jsx)(Ee,{t:n,busy:d&&u===e,disabled:!a||l||d||!t||c,title:c?n.runNowSaveFirstHint:n.runNowHint,onClick:()=>{p(e)}}):null,t[0]=c,t[1]=o?.enabled,t[2]=l,t[3]=p,t[4]=a,t[5]=d,t[6]=u,t[7]=n,t[8]=m):m=t[8];let _=m,v;t[9]!==s||t[10]!==o||t[11]!==n.phasePendingSave||t[12]!==n.phaseWillDisable||t[13]!==n.phaseWillEnable?(v=e=>{if(!o||!s)return null;let t=o[e],r=s[e];return JSON.stringify(t)===JSON.stringify(r)?null:t.enabled===r.enabled?n.phasePendingSave:t.enabled?n.phaseWillEnable:n.phaseWillDisable},t[9]=s,t[10]=o,t[11]=n.phasePendingSave,t[12]=n.phaseWillDisable,t[13]=n.phaseWillEnable,t[14]=v):v=t[14];let y=v,x;return t[15]!==c||t[16]!==o||t[17]!==l||t[18]!==a||t[19]!==y||t[20]!==_||t[21]!==r||t[22]!==f||t[23]!==n.configDeepHalfLife||t[24]!==n.configDeepLimit||t[25]!==n.configDeepMaxAge||t[26]!==n.configDeepMinRecallCount||t[27]!==n.configDeepMinScore||t[28]!==n.configDeepMinUniqueQueries||t[29]!==n.configFrequency||t[30]!==n.configLightDedupe||t[31]!==n.configLightLimit||t[32]!==n.configLightLookbackDays||t[33]!==n.configLoading||t[34]!==n.configPhaseCron||t[35]!==n.configPhaseDeep||t[36]!==n.configPhaseDeepHint||t[37]!==n.configPhaseLight||t[38]!==n.configPhaseLightHint||t[39]!==n.configPhaseRem||t[40]!==n.configPhaseRemHint||t[41]!==n.configRemLimit||t[42]!==n.configRemLookbackDays||t[43]!==n.configRemMinStrength||t[44]!==n.configTimezone||t[45]!==n.masterHint||t[46]!==n.masterOff||t[47]!==n.masterOn||t[48]!==n.masterTitle||t[49]!==n.off||t[50]!==n.on||t[51]!==n.phasesTitle||t[52]!==n.scheduleTitle||t[53]!==n.unsavedConfigHint||t[54]!==n.unsavedConfigTitle?(x=(0,Z.jsx)(re,{className:`min-w-0 !p-0`,children:o?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:i(Y,`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`),children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.masterTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.masterHint})]}),(0,Z.jsxs)(`label`,{className:i(`inline-flex w-fit cursor-pointer items-center gap-2 rounded-xl border px-3 py-1.5 text-sm transition-colors`,o.enabled?`border-emerald-500/30 bg-emerald-500/5 text-fg`:`border-edge-subtle bg-surface-panel/50 text-fg-muted`),children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:o.enabled,disabled:!a||l,onChange:e=>f(t=>t&&{...t,enabled:e.target.checked})}),(0,Z.jsx)(`span`,{className:i(`text-xs font-semibold`,o.enabled?`text-emerald-600 dark:text-emerald-400`:``),children:o.enabled?n.masterOn:n.masterOff})]})]}),c?(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-xs text-amber-900 dark:text-amber-100`,children:[(0,Z.jsx)(w,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":!0}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`font-semibold`,children:n.unsavedConfigTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 leading-snug text-amber-800/90 dark:text-amber-100/80`,children:n.unsavedConfigHint})]})]}):null,(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(we,{title:n.scheduleTitle}),(0,Z.jsx)(`div`,{className:Y,children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 lg:grid-cols-12`,children:[(0,Z.jsx)(`div`,{className:`lg:col-span-9`,children:(0,Z.jsx)(F,{kind:`cron`,label:n.configFrequency,value:o.frequency,onChange:e=>f(t=>t&&{...t,frequency:e}),labels:r,disabled:!a||l})}),(0,Z.jsx)(Q,{label:n.configTimezone,className:`lg:col-span-3`,children:(0,Z.jsx)(`input`,{className:X,value:o.timezone,disabled:!a||l,onChange:e=>f(t=>t&&{...t,timezone:e.target.value}),placeholder:`Asia/Shanghai`})})]})})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(we,{title:n.phasesTitle}),(0,Z.jsxs)(ye,{icon:(0,Z.jsx)(b,{className:`size-4 text-amber-500`}),title:n.configPhaseLight,hint:n.configPhaseLightHint,enabled:o.light.enabled,onEnabledChange:e=>f(t=>t&&{...t,light:{...t.light,enabled:e}}),cron:o.light.cron,onCronChange:e=>f(t=>t&&{...t,light:{...t.light,cron:e}}),scheduleLabels:r,disabled:!a||l,showEnabledControl:o.enabled,actions:_(`light`,o.light.enabled),status:y(`light`)?(0,Z.jsx)(Te,{label:y(`light`)??``}):null,enabledLabel:y(`light`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configLightLookbackDays,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.light.lookbackDays,disabled:!a||l,onChange:e=>f(t=>t&&{...t,light:{...t.light,lookbackDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configLightLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:X,value:o.light.limit,disabled:!a||l,onChange:e=>f(t=>t&&{...t,light:{...t.light,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configLightDedupe,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:X,value:o.light.dedupeSimilarity,disabled:!a||l,onChange:e=>f(t=>t&&{...t,light:{...t.light,dedupeSimilarity:Number(e.target.value)}})})})]}),(0,Z.jsxs)(ye,{icon:(0,Z.jsx)(h,{className:`size-4 text-indigo-500`}),title:n.configPhaseDeep,hint:n.configPhaseDeepHint,enabled:o.deep.enabled,onEnabledChange:e=>f(t=>t&&{...t,deep:{...t.deep,enabled:e}}),cron:o.deep.cron,onCronChange:e=>f(t=>t&&{...t,deep:{...t.deep,cron:e}}),scheduleLabels:r,disabled:!a||l,showEnabledControl:o.enabled,actions:_(`deep`,o.deep.enabled),status:y(`deep`)?(0,Z.jsx)(Te,{label:y(`deep`)??``}):null,enabledLabel:y(`deep`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configDeepMinScore,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:X,value:o.deep.minScore,disabled:!a||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,minScore:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMinRecallCount,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.minRecallCount,disabled:!a||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,minRecallCount:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMinUniqueQueries,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.minUniqueQueries,disabled:!a||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,minUniqueQueries:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:X,value:o.deep.limit,disabled:!a||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepHalfLife,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.recencyHalfLifeDays,disabled:!a||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,recencyHalfLifeDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMaxAge,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.maxAgeDays,disabled:!a||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,maxAgeDays:Number(e.target.value)}})})})]}),(0,Z.jsxs)(ye,{icon:(0,Z.jsx)(g,{className:`size-4 text-purple-500`}),title:n.configPhaseRem,hint:n.configPhaseRemHint,enabled:o.rem.enabled,onEnabledChange:e=>f(t=>t&&{...t,rem:{...t.rem,enabled:e}}),cron:o.rem.cron,onCronChange:e=>f(t=>t&&{...t,rem:{...t.rem,cron:e}}),scheduleLabels:r,disabled:!a||l,showEnabledControl:o.enabled,actions:_(`rem`,o.rem.enabled),status:y(`rem`)?(0,Z.jsx)(Te,{label:y(`rem`)??``}):null,enabledLabel:y(`rem`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configRemLookbackDays,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.rem.lookbackDays,disabled:!a||l,onChange:e=>f(t=>t&&{...t,rem:{...t.rem,lookbackDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configRemLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:X,value:o.rem.limit,disabled:!a||l,onChange:e=>f(t=>t&&{...t,rem:{...t.rem,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configRemMinStrength,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:X,value:o.rem.minPatternStrength,disabled:!a||l,onChange:e=>f(t=>t&&{...t,rem:{...t.rem,minPatternStrength:Number(e.target.value)}})})})]})]})]}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.configLoading})}),t[15]=c,t[16]=o,t[17]=l,t[18]=a,t[19]=y,t[20]=_,t[21]=r,t[22]=f,t[23]=n.configDeepHalfLife,t[24]=n.configDeepLimit,t[25]=n.configDeepMaxAge,t[26]=n.configDeepMinRecallCount,t[27]=n.configDeepMinScore,t[28]=n.configDeepMinUniqueQueries,t[29]=n.configFrequency,t[30]=n.configLightDedupe,t[31]=n.configLightLimit,t[32]=n.configLightLookbackDays,t[33]=n.configLoading,t[34]=n.configPhaseCron,t[35]=n.configPhaseDeep,t[36]=n.configPhaseDeepHint,t[37]=n.configPhaseLight,t[38]=n.configPhaseLightHint,t[39]=n.configPhaseRem,t[40]=n.configPhaseRemHint,t[41]=n.configRemLimit,t[42]=n.configRemLookbackDays,t[43]=n.configRemMinStrength,t[44]=n.configTimezone,t[45]=n.masterHint,t[46]=n.masterOff,t[47]=n.masterOn,t[48]=n.masterTitle,t[49]=n.off,t[50]=n.on,t[51]=n.phasesTitle,t[52]=n.scheduleTitle,t[53]=n.unsavedConfigHint,t[54]=n.unsavedConfigTitle,t[55]=x):x=t[55],x}function we(e){let t=(0,R.c)(2),{title:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`px-0.5 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:n}),t[0]=n,t[1]=r),r}function Te(e){let t=(0,R.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`span`,{className:`inline-flex shrink-0 rounded-md border border-amber-500/25 bg-amber-500/10 px-1.5 py-0.5 text-[0.65rem] font-semibold text-amber-800 dark:text-amber-200`,children:n}),t[0]=n,t[1]=r),r}function Ee(e){let t=(0,R.c)(8),{t:n,busy:r,disabled:i,title:a,onClick:o}=e,s;t[0]===r?s=t[1]:(s=r?(0,Z.jsx)(y,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(_,{className:`size-3.5`,"aria-hidden":!0}),t[0]=r,t[1]=s);let c;return t[2]!==i||t[3]!==o||t[4]!==n.runNow||t[5]!==s||t[6]!==a?(c=(0,Z.jsxs)(v,{type:`button`,variant:`secondary`,className:`h-7 gap-1.5 rounded-lg px-2 text-xs`,disabled:i,title:a,onClick:o,children:[s,n.runNow]}),t[2]=i,t[3]=o,t[4]=n.runNow,t[5]=s,t[6]=a,t[7]=c):c=t[7],c}function De(e){let t=(0,R.c)(20),{t:n,hasToken:r,eventsLoading:i,events:a,loadEvents:o}=e,s=!r||i,c;t[0]===o?c=t[1]:(c=()=>void o(),t[0]=o,t[1]=c);let l;t[2]===i?l=t[3]:(l=i?(0,Z.jsx)(y,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=i,t[3]=l);let u;t[4]!==n.eventsLoad||t[5]!==s||t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(v,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:s,onClick:c,children:[l,n.eventsLoad]}),t[4]=n.eventsLoad,t[5]=s,t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]!==n.eventsHint||t[10]!==n.eventsTitle||t[11]!==u?(d=(0,Z.jsx)(ne,{className:fe,icon:S,title:n.eventsTitle,subtitle:n.eventsHint,trailing:u}),t[9]=n.eventsHint,t[10]=n.eventsTitle,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==a||t[14]!==n.eventsEmpty||t[15]!==n.eventsNotLoaded?(f=a?a.length>0?(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:a.map(Oe)}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.eventsEmpty}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.eventsNotLoaded}),t[13]=a,t[14]=n.eventsEmpty,t[15]=n.eventsNotLoaded,t[16]=f):f=t[16];let p;return t[17]!==d||t[18]!==f?(p=(0,Z.jsxs)(re,{className:de,children:[d,f]}),t[17]=d,t[18]=f,t[19]=p):p=t[19],p}function Oe(e){let t=e.phase===`light`?`☀️`:e.phase===`rem`?`✨`:`🌙`,n=e.phase===`light`?`scanned=${e.scannedEntries??0} new=${e.newSignals??0} deduped=${e.deduped??0}`:e.phase===`rem`?`patterns=${e.patternsDiscovered??0} analyzed=${e.entriesAnalyzed??0}`:`candidates=${e.candidates??0} applied=${e.applied??0}`;return(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 rounded-lg bg-surface-panel/70 px-3 py-2 text-xs shadow-surface`,children:[(0,Z.jsx)(`span`,{children:t}),(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:e.phase}),(0,Z.jsx)(`span`,{className:i(`font-medium`,e.ok?`text-emerald-600 dark:text-emerald-400`:`text-amber-600 dark:text-amber-400`),children:e.ok?`OK`:`FAIL`}),(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:n}),(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:me(e.durationMs)}),(0,Z.jsx)(`span`,{className:`ml-auto text-fg-subtle`,children:pe(e.timestamp)})]},`${e.timestamp}:${e.phase}`)}function ke(e){let t=(0,R.c)(40),{t:n,hasToken:r,agents:i,selectedAgentId:a,onAgentChange:o,cfgForm:s,cfgSaving:c,enableAllBusy:l,cfgDirty:u,saveConfig:d,enableAllAgentsDreaming:f,doRefresh:p}=e,m;t[0]!==i||t[1]!==c||t[2]!==r||t[3]!==o||t[4]!==a?(m=i.length>0?(0,Z.jsx)(C,{className:`h-9 max-w-44 rounded-md border border-edge bg-surface-panel px-2 text-sm text-fg outline-none transition focus:border-accent`,value:a,disabled:!r||c,onChange:e=>o(e.currentTarget.value),"aria-label":`Agent`,children:i.map(Ae)}):null,t[0]=i,t[1]=c,t[2]=r,t[3]=o,t[4]=a,t[5]=m):m=t[5];let h=!r||c||l||i.length===0,g;t[6]===f?g=t[7]:(g=()=>void f(),t[6]=f,t[7]=g);let _;t[8]===l?_=t[9]:(_=l?(0,Z.jsx)(y,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[8]=l,t[9]=_);let b;t[10]!==n.enableAllAgentsDreaming||t[11]!==h||t[12]!==g||t[13]!==_?(b=(0,Z.jsxs)(v,{type:`button`,variant:`secondary`,disabled:h,onClick:g,children:[_,n.enableAllAgentsDreaming]}),t[10]=n.enableAllAgentsDreaming,t[11]=h,t[12]=g,t[13]=_,t[14]=b):b=t[14];let x=!r||!s||c||l||!u,S;t[15]===d?S=t[16]:(S=()=>void d(),t[15]=d,t[16]=S);let w;t[17]===c?w=t[18]:(w=c?(0,Z.jsx)(y,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[17]=c,t[18]=w);let T;t[19]!==n.saveConfig||t[20]!==x||t[21]!==S||t[22]!==w?(T=(0,Z.jsxs)(v,{type:`button`,variant:`primary`,disabled:x,onClick:S,children:[w,n.saveConfig]}),t[19]=n.saveConfig,t[20]=x,t[21]=S,t[22]=w,t[23]=T):T=t[23];let D=!r,O;t[24]===p?O=t[25]:(O=()=>void p(),t[24]=p,t[25]=O);let k;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Z.jsx)(E,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[26]=k):k=t[26];let A;t[27]!==n.refresh||t[28]!==D||t[29]!==O?(A=(0,Z.jsx)(v,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:D,title:n.refresh,"aria-label":n.refresh,onClick:O,children:k}),t[27]=n.refresh,t[28]=D,t[29]=O,t[30]=A):A=t[30];let j;t[31]!==m||t[32]!==A||t[33]!==b||t[34]!==T?(j=(0,Z.jsxs)(Z.Fragment,{children:[m,b,T,A]}),t[31]=m,t[32]=A,t[33]=b,t[34]=T,t[35]=j):j=t[35];let M;return t[36]!==n.subtitle||t[37]!==n.title||t[38]!==j?(M=(0,Z.jsx)(ee,{title:n.title,subtitle:n.subtitle,actions:j}),t[36]=n.subtitle,t[37]=n.title,t[38]=j,t[39]=M):M=t[39],M}function Ae(e){return(0,Z.jsx)(D,{value:e.id,children:e.name||e.id},e.id)}function je(e){let t=(0,R.c)(30),{t:n,disabled:r,actionBusy:a,doAction:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=i(`max-w-2xl`,de),t[0]=s):s=t[0];let c;t[1]!==n.maintenanceHint||t[2]!==n.maintenanceTitle?(c=(0,Z.jsx)(ne,{className:fe,icon:m,title:n.maintenanceTitle,subtitle:n.maintenanceHint}),t[1]=n.maintenanceHint,t[2]=n.maintenanceTitle,t[3]=c):c=t[3];let l;t[4]!==o||t[5]!==n.confirmResetStore?(l=()=>{confirm(n.confirmResetStore)&&o(`reset_store`)},t[4]=o,t[5]=n.confirmResetStore,t[6]=l):l=t[6];let u;t[7]===a?u=t[8]:(u=a===`reset_store`?(0,Z.jsx)(y,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(j,{className:`mr-2 size-4`,"aria-hidden":!0}),t[7]=a,t[8]=u);let d;t[9]!==r||t[10]!==n.resetStore||t[11]!==l||t[12]!==u?(d=(0,Z.jsxs)(v,{variant:`secondary`,disabled:r,onClick:l,children:[u,n.resetStore]}),t[9]=r,t[10]=n.resetStore,t[11]=l,t[12]=u,t[13]=d):d=t[13];let f;t[14]!==o||t[15]!==n.confirmClearLock?(f=()=>{confirm(n.confirmClearLock)&&o(`clear_lock`)},t[14]=o,t[15]=n.confirmClearLock,t[16]=f):f=t[16];let h;t[17]===a?h=t[18]:(h=a===`clear_lock`?(0,Z.jsx)(y,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(p,{className:`mr-2 size-4`,"aria-hidden":!0}),t[17]=a,t[18]=h);let g;t[19]!==r||t[20]!==n.clearLock||t[21]!==f||t[22]!==h?(g=(0,Z.jsxs)(v,{variant:`secondary`,disabled:r,onClick:f,children:[h,n.clearLock]}),t[19]=r,t[20]=n.clearLock,t[21]=f,t[22]=h,t[23]=g):g=t[23];let _;t[24]!==d||t[25]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[d,g]}),t[24]=d,t[25]=g,t[26]=_):_=t[26];let b;return t[27]!==c||t[28]!==_?(b=(0,Z.jsxs)(re,{className:s,children:[c,_]}),t[27]=c,t[28]=_,t[29]=b):b=t[29],b}function Me(e){let t=(0,R.c)(21),{t:n,hasToken:r,previewLoading:i,previewItems:a,loadPreview:o}=e,s=!r||i,c;t[0]===o?c=t[1]:(c=()=>void o(),t[0]=o,t[1]=c);let l;t[2]===i?l=t[3]:(l=i?(0,Z.jsx)(y,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=i,t[3]=l);let u;t[4]!==n.previewLoad||t[5]!==s||t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(v,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:s,onClick:c,children:[l,n.previewLoad]}),t[4]=n.previewLoad,t[5]=s,t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]!==n.previewHint||t[10]!==n.previewTitle||t[11]!==u?(d=(0,Z.jsx)(ne,{className:fe,icon:k,title:n.previewTitle,subtitle:n.previewHint,trailing:u}),t[9]=n.previewHint,t[10]=n.previewTitle,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==a||t[14]!==n.previewEligible||t[15]!==n.previewEmpty||t[16]!==n.previewNotLoaded?(f=a?a.length>0?(0,Z.jsx)(`div`,{className:`space-y-2`,children:a.map(e=>{let t=`${e.path}:${e.startLine}-${e.endLine}`,r=e.skippedReason;return(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-2.5 py-2 shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:t}),(0,Z.jsxs)(`span`,{children:[`score=`,e.score.toFixed(3)]}),(0,Z.jsxs)(`span`,{children:[`recalls=`,e.recallCount]}),(0,Z.jsxs)(`span`,{children:[`avg=`,e.avgScore.toFixed(3)]}),(0,Z.jsxs)(`span`,{children:[`decay=`,e.recencyDecay?.toFixed(3)??`—`]}),r?(0,Z.jsx)(`span`,{className:`text-amber-600 dark:text-amber-400`,children:r}):(0,Z.jsx)(`span`,{className:`text-emerald-600 dark:text-emerald-400`,children:n.previewEligible})]}),e.snippet?(0,Z.jsx)(`div`,{className:`mt-2 text-sm text-fg`,children:e.snippet}):null]},`${e.key}:${e.hash}:${t}`)})}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.previewEmpty}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.previewNotLoaded}),t[13]=a,t[14]=n.previewEligible,t[15]=n.previewEmpty,t[16]=n.previewNotLoaded,t[17]=f):f=t[17];let p;return t[18]!==d||t[19]!==f?(p=(0,Z.jsxs)(re,{className:de,children:[d,f]}),t[18]=d,t[19]=f,t[20]=p):p=t[20],p}function Ne(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 null}}var Pe={second:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`second`,unitDisplay:`long`}),minute:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`minute`,unitDisplay:`long`}),hour:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`hour`,unitDisplay:`long`})},Fe={second:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`second`,unitDisplay:`long`}),minute:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`minute`,unitDisplay:`long`}),hour:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`hour`,unitDisplay:`long`})};function Ie(e,t){return e.startsWith(`zh`)?Fe[t]:Pe[t]}function Le(e,t,n){let r=Math.max(1e3,Math.round(e));if(n&&P.has(r)){let e=Ne(r,n);if(e)return e}let i=Math.max(1,Math.round(r/1e3));if(i<120)return Ie(t,`second`).format(i);let a=Math.round(i/60);if(a<120)return Ie(t,`minute`).format(a);let o=Math.round(a/60);return Ie(t,`hour`).format(o)}function Re(e){let t=(0,R.c)(12),n;t[0]!==e.expression||t[1]!==e.kind||t[2]!==e.labels||t[3]!==e.locale||t[4]!==e.nextRun||t[5]!==e.presetLabels||t[6]!==e.timezone||t[7]!==e.valueMs?(n=e.kind===`cron`?I(e.expression,e.locale,e.labels,{timezone:e.timezone,nextRun:e.nextRun}):Le(e.valueMs,e.locale,e.presetLabels),t[0]=e.expression,t[1]=e.kind,t[2]=e.labels,t[3]=e.locale,t[4]=e.nextRun,t[5]=e.presetLabels,t[6]=e.timezone,t[7]=e.valueMs,t[8]=n):n=t[8];let r=n,i;return t[9]!==e.className||t[10]!==r?(i=(0,Z.jsx)(`span`,{className:e.className,children:r}),t[9]=e.className,t[10]=r,t[11]=i):i=t[11],i}function ze(e){let t=(0,R.c)(100),{t:n,data:r,isLoading:a,localeTag:o,scheduleBadgeLabels:s}=e,c;t[0]!==r||t[1]!==n?(c=r?he(r.lock,n):null,t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c,u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(`min-w-0`,de),t[3]=u):u=t[3];let d;t[4]===a?d=t[5]:(d=a?(0,Z.jsx)(y,{className:`size-4 shrink-0 animate-spin text-fg-muted`,"aria-hidden":!0}):null,t[4]=a,t[5]=d);let f;t[6]!==n.runtimeHint||t[7]!==n.runtimeTitle||t[8]!==d?(f=(0,Z.jsx)(ne,{className:fe,icon:S,title:n.runtimeTitle,subtitle:n.runtimeHint,trailing:d}),t[6]=n.runtimeHint,t[7]=n.runtimeTitle,t[8]=d,t[9]=f):f=t[9];let p;t[10]===n.subsectionSchedule?p=t[11]:(p=(0,Z.jsx)(ve,{label:n.subsectionSchedule,className:`mb-2`}),t[10]=n.subsectionSchedule,t[11]=p);let m=r?r.config.enabled?n.on:n.off:`—`,_;t[12]!==n.enabled||t[13]!==m?(_=(0,Z.jsx)($,{label:n.enabled,children:m}),t[12]=n.enabled,t[13]=m,t[14]=_):_=t[14];let v=l?.className,x=l?l.text:`—`,C;t[15]!==v||t[16]!==x?(C=(0,Z.jsx)(`span`,{className:v,children:x}),t[15]=v,t[16]=x,t[17]=C):C=t[17];let w;t[18]!==n.lock||t[19]!==C?(w=(0,Z.jsx)($,{label:n.lock,children:C}),t[18]=n.lock,t[19]=C,t[20]=w):w=t[20];let T=r&&r.config.timezone||`—`,E;t[21]!==n.timezone||t[22]!==T?(E=(0,Z.jsx)($,{label:n.timezone,children:T}),t[21]=n.timezone,t[22]=T,t[23]=E):E=t[23];let D;t[24]!==r||t[25]!==o||t[26]!==s?(D=r?(0,Z.jsx)(Re,{kind:`cron`,expression:r.config.frequency,locale:o,labels:s,timezone:r.config.timezone||void 0}):`—`,t[24]=r,t[25]=o,t[26]=s,t[27]=D):D=t[27];let O;t[28]===r?O=t[29]:(O=r?.config.frequency?(0,Z.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[0.65rem] text-fg-subtle`,title:r.config.frequency,children:r.config.frequency}):null,t[28]=r,t[29]=O);let k;t[30]!==n.schedule||t[31]!==D||t[32]!==O?(k=(0,Z.jsxs)($,{label:n.schedule,className:`col-span-2 sm:col-span-2`,children:[D,O]}),t[30]=n.schedule,t[31]=D,t[32]=O,t[33]=k):k=t[33];let A;t[34]!==w||t[35]!==E||t[36]!==k||t[37]!==_?(A=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[_,w,E,k]}),t[34]=w,t[35]=E,t[36]=k,t[37]=_,t[38]=A):A=t[38];let j;t[39]!==A||t[40]!==p?(j=(0,Z.jsxs)(`div`,{className:Y,children:[p,A]}),t[39]=A,t[40]=p,t[41]=j):j=t[41];let ee;t[42]===n.subsectionStore?ee=t[43]:(ee=(0,Z.jsx)(ve,{label:n.subsectionStore,className:`mb-2`}),t[42]=n.subsectionStore,t[43]=ee);let M=r?String(r.store.entryCount):`—`,te;t[44]!==n.storeEntries||t[45]!==M?(te=(0,Z.jsx)($,{label:n.storeEntries,children:M}),t[44]=n.storeEntries,t[45]=M,t[46]=te):te=t[46];let N=r?String(r.store.promotedCount):`—`,P;t[47]!==n.storePromoted||t[48]!==N?(P=(0,Z.jsx)($,{label:n.storePromoted,children:N}),t[47]=n.storePromoted,t[48]=N,t[49]=P):P=t[49];let F;t[50]===r?F=t[51]:(F=r?pe(r.store.updatedAt):`—`,t[50]=r,t[51]=F);let L;t[52]!==n.storeUpdatedAt||t[53]!==F?(L=(0,Z.jsx)($,{label:n.storeUpdatedAt,children:F}),t[52]=n.storeUpdatedAt,t[53]=F,t[54]=L):L=t[54];let z;t[55]===r?z=t[56]:(z=r?pe(r.store.lastPromotedAt):`—`,t[55]=r,t[56]=z);let ie;t[57]!==n.storeLastPromotedAt||t[58]!==z?(ie=(0,Z.jsx)($,{label:n.storeLastPromotedAt,children:z}),t[57]=n.storeLastPromotedAt,t[58]=z,t[59]=ie):ie=t[59];let B;t[60]!==te||t[61]!==P||t[62]!==L||t[63]!==ie?(B=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[te,P,L,ie]}),t[60]=te,t[61]=P,t[62]=L,t[63]=ie,t[64]=B):B=t[64];let ae;t[65]!==ee||t[66]!==B?(ae=(0,Z.jsxs)(`div`,{className:Y,children:[ee,B]}),t[65]=ee,t[66]=B,t[67]=ae):ae=t[67];let oe;t[68]!==r||t[69]!==o||t[70]!==s||t[71]!==n?(oe=r?.config?.phases?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(ve,{label:n.subsectionPhases,className:`mb-2`}),(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[(0,Z.jsx)(be,{icon:(0,Z.jsx)(b,{className:`size-4 text-amber-500`}),label:`Light`,enabled:r.config.phases.light.enabled,cron:r.config.phases.light.cron,scheduleSummary:I(r.config.phases.light.cron,o,s,{timezone:r.config.timezone||void 0}),details:`lookback=${r.config.phases.light.lookbackDays}d, limit=${r.config.phases.light.limit}, dedupe=${r.config.phases.light.dedupeSimilarity}`,t:n}),(0,Z.jsx)(be,{icon:(0,Z.jsx)(h,{className:`size-4 text-indigo-500`}),label:`Deep`,enabled:r.config.phases.deep.enabled,cron:r.config.phases.deep.cron,scheduleSummary:I(r.config.phases.deep.cron,o,s,{timezone:r.config.timezone||void 0}),details:`minScore=${r.config.phases.deep.minScore}, recalls>=${r.config.phases.deep.minRecallCount}, queries>=${r.config.phases.deep.minUniqueQueries}, limit=${r.config.phases.deep.limit}, halfLife=${r.config.phases.deep.recencyHalfLifeDays}d`,t:n}),(0,Z.jsx)(be,{icon:(0,Z.jsx)(g,{className:`size-4 text-purple-500`}),label:`REM`,enabled:r.config.phases.rem.enabled,cron:r.config.phases.rem.cron,scheduleSummary:I(r.config.phases.rem.cron,o,s,{timezone:r.config.timezone||void 0}),details:`lookback=${r.config.phases.rem.lookbackDays}d, limit=${r.config.phases.rem.limit}, strength≥${r.config.phases.rem.minPatternStrength}`,t:n})]})]}):null,t[68]=r,t[69]=o,t[70]=s,t[71]=n,t[72]=oe):oe=t[72];let se;t[73]===n.subsectionLastRun?se=t[74]:(se=(0,Z.jsx)(ve,{label:n.subsectionLastRun,className:`mb-2`}),t[73]=n.subsectionLastRun,t[74]=se);let ce;t[75]===n.lastRunBlockHint?ce=t[76]:(ce=(0,Z.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:n.lastRunBlockHint}),t[75]=n.lastRunBlockHint,t[76]=ce);let V;t[77]!==r||t[78]!==n?(V=r?.lastRun?.exists?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[r.lastRun.parseError?(0,Z.jsxs)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:[n.lastRunParseError,`: `,r.lastRun.parseError]}):null,r.lastRun.record?(0,Z.jsx)(`div`,{className:`rounded-lg bg-surface-panel/70 p-2.5 shadow-surface`,children:(0,Z.jsx)(Se,{t:n,r:r.lastRun.record})}):null,r.lastRun.raw!==void 0&&r.lastRun.raw!==null?(0,Z.jsxs)(`details`,{className:`group rounded-lg bg-surface-panel/70 shadow-surface`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer list-none px-2.5 py-1.5 text-xs font-medium text-fg-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:(0,Z.jsx)(`span`,{className:`underline decoration-edge underline-offset-2 group-open:text-fg`,children:n.lastRunRaw})}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto bg-surface-base/50 p-2.5 text-xs text-fg-muted`,children:JSON.stringify(r.lastRun.raw,null,2)})]}):null]}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.lastRunEmpty}),t[77]=r,t[78]=n,t[79]=V):V=t[79];let H;t[80]!==se||t[81]!==ce||t[82]!==V?(H=(0,Z.jsxs)(`div`,{className:Y,children:[se,ce,V]}),t[80]=se,t[81]=ce,t[82]=V,t[83]=H):H=t[83];let U=r?.lightLastRun,W;t[84]!==n||t[85]!==U?(W=(0,Z.jsx)(xe,{label:n.subsectionLightLastRun,lastRun:U,t:n}),t[84]=n,t[85]=U,t[86]=W):W=t[86];let G=r?.remLastRun,K;t[87]!==n||t[88]!==G?(K=(0,Z.jsx)(xe,{label:n.subsectionRemLastRun,lastRun:G,t:n}),t[87]=n,t[88]=G,t[89]=K):K=t[89];let q;t[90]!==j||t[91]!==ae||t[92]!==oe||t[93]!==H||t[94]!==W||t[95]!==K?(q=(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[j,ae,oe,H,W,K]}),t[90]=j,t[91]=ae,t[92]=oe,t[93]=H,t[94]=W,t[95]=K,t[96]=q):q=t[96];let J;return t[97]!==q||t[98]!==f?(J=(0,Z.jsxs)(re,{className:u,children:[f,q]}),t[97]=q,t[98]=f,t[99]=J):J=t[99],J}var Be=[`config`,`runtime`,`insights`,`maintenance`],Ve={config:x,runtime:S,insights:k,maintenance:m};function He(e){return e&&Be.includes(e)?e:`config`}function Ue(e,t){return t===`config`?e.tabConfig:t===`runtime`?e.tabRuntime:t===`insights`?e.tabInsights:e.tabMaintenance}function We(e,t){return t===`config`?e.configTabHint:t===`runtime`?e.runtimeTabHint:t===`insights`?e.insightsTabHint:e.maintenanceTabHint}function Ge(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:return{form:t.value,baseline:t.value};case`set`:return{...e,form:t.value};case`saved`:return{form:t.value,baseline:t.value}}}var Ke={actionBusy:null,actionError:null,actionOk:!1,runBusy:!1,runOk:!1,runError:null,runPhase:`deep`,cfgSaving:!1,cfgOk:!1,cfgError:null,enableAllBusy:!1,previewLoading:!1,previewError:null,previewItems:null,eventsLoading:!1,eventsError:null,events:null},qe=900;function Je(){return typeof window>`u`||typeof window.requestAnimationFrame!=`function`?new Promise(e=>setTimeout(e,0)):new Promise(e=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>e())})})}function Ye(e,t){typeof window>`u`||window.dispatchEvent(new CustomEvent(e,{detail:t}))}function Xe(){let e=o(e=>e.language),t=a(e),n=t.dreamingSettings,r=t.cron.schedulePicker,i=t.cron.scheduleBadge,c=e===`zh`?`zh-CN`:`en-US`,l=!!s(e=>e.token),[p,m]=f(),h=He(p.get(`tab`)),g=p.get(`agentId`)?.trim()||``,_=(0,L.useCallback)(e=>{m(t=>{let n=new URLSearchParams(t);return e===`config`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[m]),[v,y]=(0,L.useReducer)(d,Ke),{actionBusy:b,actionError:x,runBusy:S,runError:C,runPhase:w,cfgSaving:T,cfgError:E,enableAllBusy:D,previewLoading:k,previewError:A,previewItems:j,eventsLoading:ee,eventsError:M,events:ne}=v,[re,N]=(0,L.useReducer)(Ge,{form:null,baseline:null}),P=re.form,F=re.baseline,I=(0,L.useRef)(!1),R=u(l?`dreaming-settings-agents`:null,O,{revalidateOnFocus:!1}),z=R.data?.agents??[],V=g||R.data?.defaultId||``,H=(0,L.useMemo)(()=>z.find(e=>e.id===V),[z,V]),U=(0,L.useCallback)(e=>{I.current=!1,N({type:`reset`}),m(t=>{let n=new URLSearchParams(t);return e?n.set(`agentId`,e):n.delete(`agentId`),n},{replace:!0})},[m]),{data:W,error:G,isLoading:K,mutate:q}=u(l&&V?ie(V):null,B,{revalidateOnFocus:!1}),J=(0,L.useMemo)(()=>{let e=[];return G&&e.push(G instanceof Error?G.message:String(G)),x&&e.push(x),C&&e.push(C),A&&e.push(A),M&&e.push(M),E&&e.push(E),e},[G,x,C,A,M,E]),de=(0,L.useCallback)(async()=>{y({type:`patch`,patch:{actionOk:!1,actionError:null,runOk:!1,runError:null,cfgOk:!1,cfgError:null,previewError:null}}),await q()},[q]),fe=(0,L.useCallback)(async()=>{y({type:`patch`,patch:{previewLoading:!0,previewError:null}});try{y({type:`patch`,patch:{previewItems:(await se(20,V)).items??[]}})}catch(e){y({type:`patch`,patch:{previewError:e instanceof Error?e.message:String(e)}})}finally{y({type:`patch`,patch:{previewLoading:!1}})}},[V]),Y=(0,L.useCallback)(async()=>{y({type:`patch`,patch:{eventsLoading:!0,eventsError:null}});try{y({type:`patch`,patch:{events:await ce(50,V)}})}catch(e){y({type:`patch`,patch:{eventsError:e instanceof Error?e.message:String(e)}})}finally{y({type:`patch`,patch:{eventsLoading:!1}})}},[V]),X=(0,L.useCallback)(async(e=`deep`)=>{let t=Date.now(),n=z.length>0?z.map(e=>({id:e.id,name:e.name,avatar:e.avatar})):[{id:V,name:H?.name,avatar:H?.avatar}].filter(e=>e.id),r=n.length>0?n:[{id:V}],i=[];y({type:`patch`,patch:{runPhase:e,runBusy:!0,runOk:!1,runError:null}});try{let t=r.map(t=>{let n={phase:e,...t.id?{agentId:t.id}:{},...t.name?{agentName:t.name}:{},...t.avatar?{avatar:t.avatar}:{}};return Ye(`dreaming-phase-start`,n),{target:t,detail:n}}).map(async({target:t,detail:n})=>{await Je();try{await oe(e,t.id||V)}catch(e){let n=t.name||t.id||V||`default`,r=e instanceof Error?e.message:String(e);i.push(`${n}: ${r}`)}finally{Ye(`dreaming-phase-end`,n)}});await Promise.all(t),y({type:`patch`,patch:i.length>0?{runError:i.join(`
2
- `)}:{runOk:!0}}),await q()}catch(e){y({type:`patch`,patch:{runError:e instanceof Error?e.message:String(e)}})}finally{let e=qe-(Date.now()-t);e>0&&await new Promise(t=>setTimeout(t,e)),y({type:`patch`,patch:{runBusy:!1}})}},[z,q,H?.avatar,H?.name,V]),pe=(0,L.useCallback)(async e=>{y({type:`patch`,patch:{actionBusy:e,actionError:null,actionOk:!1}});try{await ae(e,V),y({type:`patch`,patch:{actionOk:!0}}),await q()}catch(e){y({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{y({type:`patch`,patch:{actionBusy:null}})}},[q,V]),me=!l||K||!!b,he=(0,L.useMemo)(()=>{let e=W?.config;return le(e??{})},[W]),ge=W?.agentId||V||`main`,_e=W?.memory;(0,L.useEffect)(()=>{if(!l){N({type:`reset`}),I.current=!1;return}I.current||N({type:`sync`,value:he})},[he,l]);let Q=(0,L.useMemo)(()=>!P||!F?!1:JSON.stringify(P)!==JSON.stringify(F),[P,F]);return(0,Z.jsxs)(te,{children:[(0,Z.jsx)(ke,{t:n,hasToken:l,agents:z,selectedAgentId:V,onAgentChange:U,cfgForm:P,cfgSaving:T,enableAllBusy:D,cfgDirty:Q,saveConfig:(0,L.useCallback)(async()=>{if(P){y({type:`patch`,patch:{cfgSaving:!0,cfgOk:!1,cfgError:null}});try{await ue(ge,P,_e),N({type:`saved`,value:P}),I.current=!1,y({type:`patch`,patch:{cfgOk:!0}}),await q()}catch(e){y({type:`patch`,patch:{cfgError:e instanceof Error?e.message:String(e)}})}finally{y({type:`patch`,patch:{cfgSaving:!1}})}}},[ge,_e,P,q]),enableAllAgentsDreaming:(0,L.useCallback)(async()=>{let e=z.length>0?z:V?[{id:V,name:H?.name,avatar:H?.avatar}]:[];if(e.length===0)return;y({type:`patch`,patch:{enableAllBusy:!0,cfgOk:!1,cfgError:null}});let t=[];try{for(let n of e)try{let e=await B(n.id),t=le(e.config);await ue(n.id,{...t,enabled:!0,light:{...t.light,enabled:!0},deep:{...t.deep,enabled:!0},rem:{...t.rem,enabled:!0}},e.memory)}catch(e){let r=n.name||n.id;t.push(`${r}: ${e instanceof Error?e.message:String(e)}`)}t.length>0?y({type:`patch`,patch:{cfgError:t.join(`
3
- `)}}):y({type:`patch`,patch:{cfgOk:!0}}),await q()}finally{y({type:`patch`,patch:{enableAllBusy:!1}})}},[z,q,H?.avatar,H?.name,V]),doRefresh:de}),J.length>0?(0,Z.jsx)(`div`,{className:`space-y-1.5 rounded-2xl border border-amber-500/20 bg-amber-500/5 px-4 py-3`,role:`alert`,children:J.map(e=>(0,Z.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200/90`,children:e},e))}):null,(0,Z.jsx)(Ze,{t:n,activeTab:h,onChange:_}),(0,Z.jsx)(Qe,{t:n,id:`config`,activeTab:h,children:(0,Z.jsx)(Ce,{t:n,schedulePickerLabels:r,hasToken:l,cfgForm:P,cfgBaseline:F,cfgDirty:Q,cfgSaving:T,runPhase:w,runBusy:S,setCfgForm:e=>{I.current=!0;let t=typeof e==`function`?e(P):e;t&&N({type:`set`,value:t})},doRunNow:X})}),(0,Z.jsx)(Qe,{t:n,id:`runtime`,activeTab:h,children:(0,Z.jsx)(ze,{t:n,data:W,isLoading:K,localeTag:c,scheduleBadgeLabels:i})}),(0,Z.jsx)(Qe,{t:n,id:`insights`,activeTab:h,children:(0,Z.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,Z.jsx)(Me,{t:n,hasToken:l,previewLoading:k,previewItems:j,loadPreview:fe}),(0,Z.jsx)(De,{t:n,hasToken:l,eventsLoading:ee,events:ne,loadEvents:Y})]})}),(0,Z.jsx)(Qe,{t:n,id:`maintenance`,activeTab:h,children:(0,Z.jsx)(je,{t:n,disabled:me,actionBusy:b,doAction:pe})})]})}function Ze(e){let t=(0,R.c)(7),{t:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=Be.map(e=>({id:e,label:Ue(n,e),icon:Ve[e]})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,Z.jsx)(N,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`dreaming-settings-tab`,panelIdPrefix:`dreaming-settings-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function Qe(e){let t=(0,R.c)(13),{t:n,id:r,activeTab:i,children:a}=e,o=r!==`config`,s;t[0]!==r||t[1]!==n?(s=Ue(n,r),t[0]=r,t[1]=n,t[2]=s):s=t[2];let c;t[3]!==r||t[4]!==n?(c=We(n,r),t[3]=r,t[4]=n,t[5]=c):c=t[5];let l;return t[6]!==i||t[7]!==a||t[8]!==r||t[9]!==o||t[10]!==s||t[11]!==c?(l=(0,Z.jsx)(M,{id:r,activeTab:i,tabIdPrefix:`dreaming-settings-tab`,panelIdPrefix:`dreaming-settings-panel`,title:s,hint:c,showHeading:o,children:a}),t[6]=i,t[7]=a,t[8]=r,t[9]=o,t[10]=s,t[11]=c,t[12]=l):l=t[12],l}export{Xe as DreamingSettingsPanel};
@@ -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"./cn-BQ_8x0bT.js";import{t as a}from"./messages-DmnbiNxU.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s,i as c,n as l,t as u}from"./fetch-pg2ErdAk.js";import{r as d}from"./toast-z0toXu32.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{Co as p,So as m,Tl as h,To as g,Us as _,eo as v,no as y,rt as b,va as x,wo as S,xl as C}from"./index-C2F0Clvm.js";import{a as w,d as T,f as E,i as D,l as O,s as k,t as A,u as j}from"./voice-api-key-field-2QKflCx8.js";import{t as M}from"./schema-form-CVSQA9nI.js";var N=n(),P=e(t(),1),F=r(),I=()=>c(E);function L(e){return{credentialsIntro:e.credentialsIntro,regionHint:e.regionHint,endpointPresetsHint:e.endpointPresetsHint,apiKeyLabel:e.apiKeyLabel,optionalPlaceholder:e.optionalPlaceholder,regionLabel:e.regionLabel,baseUrlLabel:e.baseUrlLabel,imageBaseUrlLabel:e.imageBaseUrlLabel,saveCredentials:e.saveCredentials,savingCredentials:e.savingCredentials,credentialsSaved:e.credentialsSaved,discardCredentials:e.discardCredentials,credentialsNothingToSave:e.credentialsNothingToSave,credentialsSaveError:e.credentialsSaveError,regionPresetDefault:e.regionPresetDefault,regionPresetCustom:e.regionPresetCustom,baseUrlPresetDefault:e.baseUrlPresetDefault,baseUrlPresetCustom:e.baseUrlPresetCustom,openExtensionSettings:e.openExtensionSettings,openImageModelsPage:e.openImageModelsPage,extensionSettingsLinkTitle:e.extensionSettingsLinkTitle,imageModelsLinkTitle:e.imageModelsLinkTitle,configured:e.configured,missingKey:e.missingKey,unsavedChanges:e.unsavedChanges,expandProvider:e.expandProvider,collapseProvider:e.collapseProvider,defaultModel:e.defaultModel,modelsLabel:e.modelsLabel,modelCountOne:e.modelCountOne,modelCountMany:e.modelCountMany,imageBaseUrlPresetHint:e.imageBaseUrlPresetHint,dashscopeRegion_beijing:e.dashscopeRegion_beijing,dashscopeRegion_singapore:e.dashscopeRegion_singapore,dashscopeRegion_us:e.dashscopeRegion_us,apiKeyMaskedHelp:e.apiKeyMaskedHelp,apiKeyCopy:e.apiKeyCopy,apiKeyCopied:e.apiKeyCopied,apiKeyShow:e.apiKeyShow,apiKeyHide:e.apiKeyHide,apiKeyNotInConfigFile:e.apiKeyNotInConfigFile,apiKeyRevealFailed:e.apiKeyRevealFailed,minimaxClusterLabel:e.minimaxClusterLabel,minimaxClusterHint:e.minimaxClusterHint,falQueueBaseLabel:e.falQueueBaseLabel,falQueueBaseHint:e.falQueueBaseHint}}function R(e){let t=(0,N.c)(40),{extensionId:n}=e,r=o(B),i;t[0]===r?i=t[1]:(i=a(r),t[0]=r,t[1]=i);let c=i,l=c.imageModelsSettings,u=s(z),d;t[2]===u?d=t[3]:(d=u?I():null,t[2]=u,t[3]=d);let p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p={revalidateOnFocus:!1},t[4]=p):p=t[4];let{data:m,isLoading:h}=f(d,T,p),g;t[5]===m?g=t[6]:(g=m===void 0?[]:m,t[5]=m,t[6]=g);let v=g,y;if(t[7]!==v||t[8]!==n){let e;t[10]===n?e=t[11]:(e=e=>e.id===n,t[10]=n,t[11]=e),y=v.filter(e),t[7]=v,t[8]=n,t[9]=y}else y=t[9];let b=y,x=O(b),S;t[12]===l?S=t[13]:(S=L(l),t[12]=l,t[13]=S);let C=S,w;t[14]!==c.providersSettings.getApiKey||t[15]!==c.providersSettings.getApiKeyCn||t[16]!==c.providersSettings.getApiKeyIntl?(w={getApiKey:c.providersSettings.getApiKey,getApiKeyIntl:c.providersSettings.getApiKeyIntl,getApiKeyCn:c.providersSettings.getApiKeyCn},t[14]=c.providersSettings.getApiKey,t[15]=c.providersSettings.getApiKeyCn,t[16]=c.providersSettings.getApiKeyIntl,t[17]=w):w=t[17];let E=w;if(!u)return null;if(h){let e;return t[18]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,F.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-sm text-fg-muted`,children:[(0,F.jsx)(_,{className:`size-4 animate-spin`}),`…`]}),t[18]=e):e=t[18],e}if(b.length===0){let e=r===`zh`?`网关未注册该图像 Provider,或扩展已被禁用。`:`This image provider is not registered on the gateway, or the extension is disabled.`,n;return t[19]===e?n=t[20]:(n=(0,F.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[19]=e,t[20]=n),n}let D;t[21]!==x||t[22]!==l.credentialsSaveError?(D=()=>void x.saveCredentials(l.credentialsSaveError),t[21]=x,t[22]=l.credentialsSaveError,t[23]=D):D=t[23];let k;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(k=new Set,t[24]=k):k=t[24];let A;return t[25]!==E||t[26]!==x.credBaseline||t[27]!==x.credDirty||t[28]!==x.credDraft||t[29]!==x.credError||t[30]!==x.credNoopFlash||t[31]!==x.credSavedFlash||t[32]!==x.credSaving||t[33]!==x.onDiscardCredentials||t[34]!==x.updateCredRow||t[35]!==r||t[36]!==C||t[37]!==b||t[38]!==D?(A=(0,F.jsx)(j,{summaries:b,credDraft:x.credDraft,credBaseline:x.credBaseline,credDirty:x.credDirty,credSaving:x.credSaving,credError:x.credError,credSavedFlash:x.credSavedFlash,credNoopFlash:x.credNoopFlash,updateCredRow:x.updateCredRow,onDiscardCredentials:x.onDiscardCredentials,onSaveCredentials:D,extensionIds:k,showExtensionLinks:!1,showImageModelsLink:!1,language:r,apiKeyLinkLabels:E,messages:C}),t[25]=E,t[26]=x.credBaseline,t[27]=x.credDirty,t[28]=x.credDraft,t[29]=x.credError,t[30]=x.credNoopFlash,t[31]=x.credSavedFlash,t[32]=x.credSaving,t[33]=x.onDiscardCredentials,t[34]=x.updateCredRow,t[35]=r,t[36]=C,t[37]=b,t[38]=D,t[39]=A):A=t[39],A}function z(e){return!!e.token}function B(e){return e.language}function V(e){let t=(0,N.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,F.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}var H=[{id:`whisper-large-v3-turbo`,name:`Whisper Large v3 Turbo`},{id:`whisper-large-v3`,name:`Whisper Large v3`}];function U(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 W(){return i(p,m)}function G(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,S,`dark:border-edge`)}function K(e,t){if(!e||!t)return{apiKey:``,model:H[0].id};if(t===`alibaba`)return{apiKey:e.stt.alibaba?.apiKey??``,model:e.stt.alibaba?.model??`paraformer-v2`};if(t===`openai`)return{apiKey:e.stt.openai?.apiKey??``,model:e.stt.openai?.model??`whisper-1`};let n=e.stt.providers?.[t];return{apiKey:typeof n?.apiKey==`string`?n.apiKey:``,model:typeof n?.model==`string`?n.model:H[0].id}}function q({providerId:e,voiceSettings:t,mutateVoice:n}){let r=a(o(e=>e.language)),s=r.voiceSettings,l=r.extensionSttMedia,u={maskedHelp:s.apiKeyMaskedHelp,copy:s.apiKeyCopy,copied:s.apiKeyCopied,show:s.apiKeyShow,hide:s.apiKeyHide,notInConfigFile:s.apiKeyNotInConfigFile,loadFailed:s.apiKeyRevealFailed},{data:p}=f(c(`/api/voice/stt-providers`),w,{revalidateOnFocus:!1}),h=(0,P.useMemo)(()=>p?.providers.some(t=>t.id===e&&t.configured)??!1,[e,p]),_=(0,P.useMemo)(()=>K(t,e),[e,t]),b=(0,P.useRef)(!1),[x,S]=(0,P.useState)(null),[C,T]=(0,P.useState)(!1),[E,D]=(0,P.useState)(null),[O,j]=(0,P.useState)(!1),M=x??_,N=_,I=M.apiKey!==N.apiKey||M.model!==N.model,L=(0,P.useCallback)(async()=>{T(!0),D(null);try{let r=structuredClone(t);r.stt.enabled=!0,e===`alibaba`?(r.stt.provider=`alibaba`,r.stt.alibaba={...r.stt.alibaba,apiKey:M.apiKey,model:M.model}):e===`openai`?(r.stt.provider=`openai`,r.stt.openai={...r.stt.openai,apiKey:M.apiKey,model:M.model}):(r.stt.providers={...r.stt.providers??{},[e]:{...r.stt.providers?.[e]??{},apiKey:M.apiKey,model:M.model}},(!r.stt.provider||r.stt.provider===`alibaba`||r.stt.provider===`openai`)&&(r.stt.provider=e)),await k(r),await n(r,!1),b.current=!1,S(null),j(!0),d({type:`success`,title:s.saved})}catch(e){D(e instanceof Error?e.message:String(e))}finally{T(!1)}},[M.apiKey,M.model,n,e,t]),R=e===`groq`?H:[{id:M.model,name:M.model}];return(0,F.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl bg-surface-base p-4`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:l.credentialsTitle}),(0,F.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:l.credentialsHint.replace(`{providerId}`,e)})]}),(0,F.jsx)(`span`,{className:i(`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?l.configured:l.notConfigured})]}),(0,F.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,F.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,m),children:[(0,F.jsx)(V,{children:s.stt.apiKey}),(0,F.jsx)(A,{kind:`stt`,providerId:e,fieldId:`ext-stt-${e}-api-key`,value:M.apiKey,onChange:e=>{b.current=!0,S(t=>({...t??_,apiKey:e})),D(null)},labels:u,placeholder:e===`groq`?`gsk_...`:`sk-...`}),(0,F.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[s.stt.apiKeyDesc,e===`groq`?` (GROQ_API_KEY)`:``]})]}),(0,F.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,m),children:[(0,F.jsx)(V,{children:s.stt.model}),e===`groq`?(0,F.jsx)(v,{className:W(),value:M.model,onChange:e=>{b.current=!0,S(t=>({...t??_,model:e.target.value})),D(null)},children:R.map(e=>(0,F.jsx)(y,{value:e.id,children:e.name},e.id))}):(0,F.jsx)(`input`,{className:G(),value:M.model,onChange:e=>{b.current=!0,S(t=>({...t??_,model:e.target.value})),D(null)}})]})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[E?(0,F.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,children:E}):null,(0,F.jsx)(g,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,disabled:!I||C,onClick:()=>{b.current=!1,S(null),D(null)},children:s.discard}),(0,F.jsx)(g,{type:`button`,variant:`primary`,className:`h-8 text-xs`,disabled:!I||C,onClick:()=>void L(),children:C?s.saving:s.save})]})]})}function J(e){let t=(0,N.c)(13),{extensionId:n}=e,r=o(X),i=s(Y),a;t[0]===n?a=t[1]:(a=()=>l(c(`/api/extensions/${encodeURIComponent(n)}`)),t[0]=n,t[1]=a);let{data:u,isLoading:d}=f(i&&n?`ext-stt-detail-${n}`:null,a),p;t[2]===u?p=t[3]:(p=U(u),t[2]=u,t[3]=p);let m=p,h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h={revalidateOnFocus:!1},t[4]=h):h=t[4];let{data:g,mutate:v,isLoading:y}=f(i?`voice-settings-ext-stt`:null,D,h);if(!i)return null;if(d||y){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,F.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-sm text-fg-muted`,children:[(0,F.jsx)(_,{className:`size-4 animate-spin`}),`…`]}),t[5]=e):e=t[5],e}if(!m){let e=r===`zh`?`该扩展未声明 mediaUnderstandingProviders。`:`This extension does not declare mediaUnderstandingProviders.`,n;return t[6]===e?n=t[7]:(n=(0,F.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[6]=e,t[7]=n),n}if(!g)return null;let b=`${n}:${m}`,x;return t[8]!==v||t[9]!==m||t[10]!==b||t[11]!==g?(x=(0,F.jsx)(q,{providerId:m,voiceSettings:g,mutateVoice:v},b),t[8]=v,t[9]=m,t[10]=b,t[11]=g,t[12]=x):x=t[12],x}function Y(e){return!!e.token}function X(e){return e.language}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Q(e){let t={};if(e.type!==`object`||!Z(e.properties))return t;for(let[n,r]of Object.entries(e.properties))Z(r)&&Object.prototype.hasOwnProperty.call(r,`default`)&&(t[n]=r.default);return t}function ee(e,t){switch(t.type){case`sync`:return{...e,localValues:t.value,isDirty:!1,saveError:null};case`change`:return{...e,localValues:t.value,isDirty:!0,saveError:null,saveSuccess:!1};case`discard`:return{...e,localValues:t.value,isDirty:!1,saveError:null};case`reset-defaults`:return{...e,localValues:t.value,isDirty:!0,saveError:null,saveSuccess:!1};case`save-start`:return{...e,saving:!0,saveError:null};case`save-success`:return{...e,localValues:t.value,isDirty:!1,saving:!1,saveSuccess:!0,saveError:null};case`save-error`:return{...e,saving:!1,saveError:t.message}}}function te({extensionId:e}){let t=a(o(e=>e.language)).agentSettings,n=s(e=>!!e.token),{data:r,error:i}=f(n&&e?`ext-detail-${e}`:null,()=>l(c(`/api/extensions/${encodeURIComponent(e)}`))),{data:p,mutate:m,error:h}=f(n&&e?`ext-cfg-${e}`:null,()=>l(c(`/api/extensions/${encodeURIComponent(e)}/config`))),_=r?.manifest?.configSchema,v=(0,P.useMemo)(()=>_&&_.type===`object`?Q(_):{},[_]),y=(0,P.useMemo)(()=>({...v,...p??{}}),[v,p]),[b,x]=(0,P.useReducer)(ee,{localValues:{},isDirty:!1,saving:!1,saveError:null,saveSuccess:!1}),[S,C]=(0,P.useState)(!1),w=(0,P.useRef)(!1),T=(0,P.useRef)(y);!w.current&&T.current!==y&&(T.current=y,x({type:`sync`,value:y}));let E=(0,P.useCallback)(e=>{w.current=!0,x({type:`change`,value:e})},[]),D=(0,P.useCallback)(()=>{w.current=!1,x({type:`discard`,value:y})},[y]),O=(0,P.useCallback)(()=>{!_||_.type!==`object`||(w.current=!0,x({type:`reset-defaults`,value:{...Q(_)}}))},[_]),k=(0,P.useCallback)(async()=>{if(e){x({type:`save-start`});try{let n=await u(c(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(b.localValues)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error?.message??n.statusText)}await m(b.localValues,!1),w.current=!1,x({type:`save-success`,value:b.localValues}),C(!0),d({type:`success`,title:t.saved})}catch(e){x({type:`save-error`,message:e instanceof Error?e.message:String(e)})}}},[b.localValues,e,m]);if(!n)return null;if(i||h){let e=i??h;return(0,F.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`Could not load extension settings: `,e instanceof Error?e.message:String(e)]})}return!_||_.type!==`object`?null:(0,F.jsxs)(`div`,{className:`mb-6 flex flex-col gap-3 rounded-xl bg-surface-base p-4`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Configuration`}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[b.saveError?(0,F.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,children:b.saveError}):null,(0,F.jsx)(g,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,disabled:!b.isDirty,onClick:D,children:t.discard}),(0,F.jsx)(g,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:O,children:`Reset to defaults`}),(0,F.jsx)(g,{type:`button`,variant:`primary`,className:`h-8 text-xs`,disabled:!b.isDirty||b.saving,onClick:()=>void k(),children:b.saving?t.saving:t.save})]})]}),(0,F.jsx)(M,{schema:_,values:b.localValues,onChange:E,disabled:b.saving})]})}function ne(){let e=(0,N.c)(47),t=o(re),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n,i=r.extensionImageGen,s=r.extensionSttMedia,{extensionId:c,panelId:l}=h(),u=x();if(!c){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)($,{message:`No extension ID provided.`}),e[2]=t):t=e[2],t}let d,f,p;if(e[3]!==c||e[4]!==u||e[5]!==l){p=Symbol.for(`react.early_return_sentinel`);bb0:{let t;if(e[9]===c?t=e[10]:(t=e=>e.id===c,e[9]=c,e[10]=t),d=u.find(t),!d){let t=`Extension "${c}" not found or is not available in this workspace.`,n;e[11]===t?n=e[12]:(n=(0,F.jsx)($,{message:t}),e[11]=t,e[12]=n),p=n;break bb0}let n=d.ui?.contributions?.settingsPanels;f=l?n?.find(e=>e.id===l||e.id===`${c}.${l}`):n?.[0]}e[3]=c,e[4]=u,e[5]=l,e[6]=d,e[7]=f,e[8]=p}else d=e[6],f=e[7],p=e[8];if(p!==Symbol.for(`react.early_return_sentinel`))return p;let m=f,g=!!(m&&d.ui),_=!!d.hasConfigSchema,v=d.kind===`image-generation`,y=d.kind===`media-provider`;if(!_&&!g&&!(v||y)){let t=`Extension "${c}" has no settings panels or config schema.`,n;return e[13]===t?n=e[14]:(n=(0,F.jsx)($,{message:t}),e[13]=t,e[14]=n),n}let S=m?.title??`${d.name} Settings`,w;e[15]===S?w=e[16]:(w=(0,F.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:S}),e[15]=S,e[16]=w);let T;e[17]!==v||e[18]!==r.imageModelsSettings||e[19]!==i?(T=v?(0,F.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base px-4 py-3 text-sm`,children:[(0,F.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:i.banner}),(0,F.jsx)(C,{to:`/settings/credentials?tab=image-models`,className:`w-fit font-medium text-accent hover:underline`,title:r.imageModelsSettings.imageModelsLinkTitle,children:i.openImageModels})]}):null,e[17]=v,e[18]=r.imageModelsSettings,e[19]=i,e[20]=T):T=e[20];let E;e[21]!==c||e[22]!==v?(E=v?(0,F.jsx)(R,{extensionId:c}):null,e[21]=c,e[22]=v,e[23]=E):E=e[23];let D;e[24]!==y||e[25]!==s?(D=y?(0,F.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base px-4 py-3 text-sm`,children:[(0,F.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:s.banner}),(0,F.jsx)(C,{to:`/settings/credentials?tab=voice`,className:`w-fit font-medium text-accent hover:underline`,children:s.openVoice})]}):null,e[24]=y,e[25]=s,e[26]=D):D=e[26];let O;e[27]!==c||e[28]!==y?(O=y?(0,F.jsx)(J,{extensionId:c}):null,e[27]=c,e[28]=y,e[29]=O):O=e[29];let k;e[30]!==c||e[31]!==_?(k=_?(0,F.jsx)(te,{extensionId:c}):null,e[30]=c,e[31]=_,e[32]=k):k=e[32];let A;e[33]!==d.name||e[34]!==d.ui||e[35]!==c||e[36]!==g||e[37]!==m?(A=g&&m&&d.ui?(0,F.jsx)(`div`,{className:`overflow-hidden rounded-xl bg-surface-base shadow-surface`,children:(0,F.jsx)(b,{extensionId:c,extensionName:d.name,entrypoint:m.entrypoint,permissions:d.ui?.permissions,title:m.title,className:`w-full`,minHeight:120,maxHeight:2e3})}):null,e[33]=d.name,e[34]=d.ui,e[35]=c,e[36]=g,e[37]=m,e[38]=A):A=e[38];let j;return e[39]!==w||e[40]!==T||e[41]!==E||e[42]!==D||e[43]!==O||e[44]!==k||e[45]!==A?(j=(0,F.jsxs)(`div`,{className:`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,children:[w,T,E,D,O,k,A]}),e[39]=w,e[40]=T,e[41]=E,e[42]=D,e[43]=O,e[44]=k,e[45]=A,e[46]=j):j=e[46],j}function re(e){return e.language}function $(e){let t=(0,N.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,F.jsx)(`div`,{className:`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,children:(0,F.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{ne as ExtensionSettingsPage};
@@ -1 +0,0 @@
1
- import{t as e}from"./messages-DmnbiNxU.js";import{a as t,c as n,n as r,o as i,r as a}from"./locale-store-Ba72bFmP.js";var o=n((e,t)=>({baseUrl:typeof window<`u`?window.location.origin:``,token:void 0,tokenDialogOpen:!1,tokenExpired:!1,setGatewayToken:t=>{i(t),e({token:t,tokenDialogOpen:!1,tokenExpired:!1}),window.dispatchEvent(new CustomEvent(`token-saved`,{detail:{token:t}}))},clearGatewayToken:()=>{a(),e({token:void 0})},openTokenDialog:()=>e({tokenDialogOpen:!0}),closeTokenDialog:()=>e({tokenDialogOpen:!1}),onUnauthorized:()=>{t().clearGatewayToken(),e({tokenDialogOpen:!1,tokenExpired:!0}),window.dispatchEvent(new CustomEvent(`token-expired`))}}));function s(){let e=new URLSearchParams(window.location.search).get(`token`);if(e){o.getState().setGatewayToken(e);let t=window.location.pathname+window.location.hash,n=window.history.state,r=n&&typeof n==`object`&&!Array.isArray(n)?{...n}:n;window.history.replaceState(r,``,t);return}let n=t();o.setState({token:n||void 0,tokenDialogOpen:!1})}function c(){return window.location.origin}function l(e){let t=e.startsWith(`/`)?e:`/${e}`;return`${c()}${t}`}function u(e){let t=e.baseUrl.trim().replace(/\/+$/,``),n=new URL(`xopc://gateway/mobile-connect`);return n.searchParams.set(`baseUrl`,t),e.lanUrl?.trim()&&n.searchParams.set(`lanUrl`,e.lanUrl.trim().replace(/\/+$/,``)),n.searchParams.set(`ps`,e.pairingSecret),n.toString()}function d(e){try{let t=new URL(e.trim());if(t.protocol!==`http:`&&t.protocol!==`https:`)return!1;let n=t.hostname.toLowerCase();return!!(n===`localhost`||n===`127.0.0.1`||n===`[::1]`||n===`::1`||/^127\.\d+\.\d+\.\d+$/.test(n))}catch{return!1}}function f(){return r.getState().language}function p(e,t,n){let r=e.trim().toLowerCase();return!!(!r||r===`http ${t}`||n&&r===n.trim().toLowerCase()||t===500&&r===`internal server error`)}function m(t,n,r){let i=r?.trim()??``;if(i&&!p(i,t,n))return i;let a=e(f()).api;return t>=500?t===502?a.errorBadGateway:t===503?a.errorServiceUnavailable:t===504?a.errorGatewayTimeout:t===500?a.errorInternal:a.errorServer.replace(`{{status}}`,String(t)):t===404?a.errorNotFound:t===403?a.errorForbidden:a.errorRequest.replace(`{{status}}`,String(t))}var h=null,g=null;function _(){h||=new Promise(e=>{g=e})}function v(){h&&(g?.(),h=null,g=null)}typeof window<`u`&&window.addEventListener(`token-saved`,v);async function y(e,t){h&&await h;let n=o.getState().token,r=new Headers(t?.headers),i=t?.body,a=typeof FormData<`u`&&i instanceof FormData;!r.has(`Content-Type`)&&!a&&r.set(`Content-Type`,`application/json`),n&&r.set(`Authorization`,`Bearer ${n}`);let s=await fetch(e,{...t,headers:r});return s.status===401&&(_(),o.getState().onUnauthorized()),s}async function b(e,t){let n=await y(e,t);if(!n.ok){let e=await n.json().catch(()=>({})),t=typeof e.error==`string`?e.error:e.error?.message,r=m(n.status,n.statusText,t);throw Object.assign(Error(r),{status:n.status,body:e})}return n.json()}export{u as a,o as c,l as i,b as n,d as o,m as r,s,y as t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n}from"./vendor-react-BOUWij0V.js";import{i as r,n as i}from"./fetch-pg2ErdAk.js";import{_o as a,ma as o,mr as s}from"./index-C2F0Clvm.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 a(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}},corsOrigins:k(e.corsOrigins),trustedProxies:k(e.trustedProxies),allowRealIpFallback:e.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:e.dangerouslyAllowHostHeaderOriginFallback})}function j(e,t){return A(e)!==A(t)}function M(e){return e===`none`||e===`token`||e===`password`||e===`trusted-proxy`?e:`token`}function N(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 P(e){let t=w(e)?e:{};return{userHeader:typeof t.userHeader==`string`?t.userHeader:``,requiredHeaders:I(t.requiredHeaders,32),allowUsers:I(t.allowUsers,128),allowLoopback:t.allowLoopback===!0}}function F(e){return e===`auto`||e===`off`||e===`explicit`?e:`auto`}function I(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 L(e){return e===`auto`||e===`loopback`||e===`lan`||e===`tailnet`||e===`custom`?e:`loopback`}function R(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 z(e){let t=R(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 B(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:L(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:M(r.mode),token:typeof r.token==`string`?r.token:``,password:typeof r.password==`string`?r.password:``,rateLimit:N(r.rateLimit),trustedProxy:P(r.trustedProxy)},corsOrigins:l,trustedProxies:I(n.trustedProxies,64),allowRealIpFallback:n.allowRealIpFallback===!0,dangerouslyAllowHostHeaderOriginFallback:n.dangerouslyAllowHostHeaderOriginFallback===!0,securityStrict:i.strict===!0,maxSseConnections:typeof n.maxSseConnections==`number`&&Number.isFinite(n.maxSseConnections)?Math.max(1,Math.floor(n.maxSseConnections)):100,channelConnectDeferMode:F(n.channelConnectDeferMode),channelConnectDeferIds:I(n.channelConnectDeferIds),channelConnectDeferSkipIds:I(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 V(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 H(e){let t=z(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:V(e),corsOrigins:e.corsOrigins,trustedProxies:e.trustedProxies,allowRealIpFallback:e.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:e.dangerouslyAllowHostHeaderOriginFallback,security:{strict:e.securityStrict},maxSseConnections:e.maxSseConnections,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}}})}),o()}export{E as a,v as c,p as d,D as i,m as l,B as n,z as o,H as r,b as s,j as t,h 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{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-DmnbiNxU.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s,i as c,n as l}from"./fetch-pg2ErdAk.js";import{r as u}from"./toast-z0toXu32.js";import{i as d,o as f}from"./vendor-swr-BIWyz7Rc.js";import{C as p,Dt as m,El as h,Ns as g,Qc as _,Ro as v,To as y,Us as b,Ya as x,eo as S,es as C,fs as w,ha as T,ic as E,mo as D,mr as O,ms as k,nc as A,no as j,ns as M,po as N,ts as P,wo as F,yo as I,yr as L}from"./index-C2F0Clvm.js";import{n as ee,r as te,t as ne}from"./settings-page-layout-DBRWwdhh.js";import{t as re}from"./settings-advanced-gate-CuFdeKNu.js";import{n as R,t as z}from"./settings-form-section-Bugp38Fa.js";import{t as ie}from"./page-tabs-DDC2t4Z8.js";import{a as ae,c as oe,d as se,n as ce,o as le,r as ue,t as de}from"./gateway-config-api-DbG97ia2.js";var B=e(t(),1),V=n(),H={critical:3,warn:2,info:1};function U(){return c(`/api/doctor?security=true`)}function W(e){return e.toSorted((e,t)=>H[t.severity]-H[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 l(U()))}var q=r();function fe(e){let t=(0,V.c)(40),{enabled:n,refreshToken:r}=e,i=r===void 0?0:r,s=o(Y),c;t[0]===s?c=t[1]:(c=a(s),t[0]=s,t[1]=c);let l=c.gatewaySettings,u;t[2]!==n||t[3]!==i?(u=n?[U(),i]:null,t[2]=n,t[3]=i,t[4]=u):u=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:h,isLoading:g,isValidating:_,mutate:v}=d(u,J,p),x=m??null,S=h instanceof Error?h.message:h?String(h):null,C=g||_,w;t[6]===v?w=t[7]:(w=()=>{v(),f(U())},t[6]=v,t[7]=w);let T=w,E=!n||C,D;t[8]===C?D=t[9]:(D=C?(0,q.jsx)(b,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,q.jsx)(k,{className:`size-3.5`,"aria-hidden":!0}),t[8]=C,t[9]=D);let O;t[10]===l.securityAuditRefresh?O=t[11]:(O=(0,q.jsx)(`span`,{className:`ml-1.5`,children:l.securityAuditRefresh}),t[10]=l.securityAuditRefresh,t[11]=O);let A;t[12]!==T||t[13]!==E||t[14]!==D||t[15]!==O?(A=(0,q.jsxs)(y,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:E,onClick:T,children:[D,O]}),t[12]=T,t[13]=E,t[14]=D,t[15]=O,t[16]=A):A=t[16];let j;t[17]!==l.securityAuditSubtitle||t[18]!==l.securityAuditTitle||t[19]!==A?(j=(0,q.jsx)(R,{icon:M,title:l.securityAuditTitle,subtitle:l.securityAuditSubtitle,trailing:A}),t[17]=l.securityAuditSubtitle,t[18]=l.securityAuditTitle,t[19]=A,t[20]=j):j=t[20];let N;t[21]===l.securityAuditSavedConfigHint?N=t[22]:(N=(0,q.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:l.securityAuditSavedConfigHint}),t[21]=l.securityAuditSavedConfigHint,t[22]=N);let P;t[23]!==S||t[24]!==l.securityAuditLoadError?(P=S?(0,q.jsxs)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,role:`alert`,children:[l.securityAuditLoadError,`: `,S]}):null,t[23]=S,t[24]=l.securityAuditLoadError,t[25]=P):P=t[25];let F;t[26]!==x||t[27]!==S||t[28]!==l.securityAuditLoading||t[29]!==C?(F=!S&&C&&!x?(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,q.jsx)(b,{className:`size-4 animate-spin`,"aria-hidden":!0}),l.securityAuditLoading]}):null,t[26]=x,t[27]=S,t[28]=l.securityAuditLoading,t[29]=C,t[30]=F):F=t[30];let I;t[31]!==x||t[32]!==l?(I=x?(0,q.jsx)(pe,{g:l,audit:x}):null,t[31]=x,t[32]=l,t[33]=I):I=t[33];let L;return t[34]!==j||t[35]!==N||t[36]!==P||t[37]!==F||t[38]!==I?(L=(0,q.jsxs)(z,{children:[j,N,P,F,I]}),t[34]=j,t[35]=N,t[36]=P,t[37]=F,t[38]=I,t[39]=L):L=t[39],L}function J(){return K()}function Y(e){return e.language}function pe(e){let t=(0,V.c)(40),{g:n,audit:r}=e,a,o,s,c,l,u,d;t[0]!==r.findings||t[1]!==r.status||t[2]!==n?(o=ge(n,r.status,r.findings),d=`space-y-4`,l=i(`rounded-lg border px-3 py-2.5 text-sm`,o.bannerClass),u=`status`,c=`flex items-start gap-2`,a=o.icon,s=i(`mt-0.5 size-4 shrink-0`,o.iconClass),t[0]=r.findings,t[1]=r.status,t[2]=n,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d):(a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9]);let f;t[10]!==a||t[11]!==s?(f=(0,q.jsx)(a,{className:s,"aria-hidden":!0}),t[10]=a,t[11]=s,t[12]=f):f=t[12];let p;t[13]===o.title?p=t[14]:(p=(0,q.jsx)(`p`,{className:`font-medium`,children:o.title}),t[13]=o.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]!==c||t[21]!==f||t[22]!==h?(g=(0,q.jsxs)(`div`,{className:c,children:[f,h]}),t[20]=c,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)(X,{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(me)})]}):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 me(e){return(0,q.jsx)(`li`,{className:`font-mono`,children:e},e)}function X(e){let t=(0,V.c)(31),{g:n,finding:r}=e,a,o,s,c;if(t[0]!==r.severity){let e=he(r.severity);c=`rounded-lg bg-surface-panel/70 px-3 py-2.5 shadow-surface`,s=`flex items-start gap-2`,a=e.icon,o=i(`mt-0.5 size-4 shrink-0`,e.iconClass),t[0]=r.severity,t[1]=a,t[2]=o,t[3]=s,t[4]=c}else a=t[1],o=t[2],s=t[3],c=t[4];let l;t[5]!==a||t[6]!==o?(l=(0,q.jsx)(a,{className:o,"aria-hidden":!0}),t[5]=a,t[6]=o,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]!==s||t[26]!==l?(g=(0,q.jsxs)(`div`,{className:s,children:[l,h]}),t[24]=h,t[25]=s,t[26]=l,t[27]=g):g=t[27];let _;return t[28]!==g||t[29]!==c?(_=(0,q.jsx)(`li`,{className:c,children:g}),t[28]=g,t[29]=c,t[30]=_):_=t[30],_}function he(e){switch(e){case`critical`:return{icon:_,iconClass:`text-red-600 dark:text-red-400`};case`warn`:return{icon:v,iconClass:`text-amber-600 dark:text-amber-400`};default:return{icon:E,iconClass:`text-fg-muted`}}}function ge(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:_,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:v,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:E,iconClass:`text-fg-muted`,title:e.securityAuditStatusSkip,bannerClass:`border-edge bg-surface-panel/60 text-fg`}:{icon:M,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 i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,F,`dark:border-edge`)}var _e=[`network`,`access`,`updates`,`security`,`advanced`],ve={network:g,access:A,updates:k,security:P,advanced:C};function ye(e){return e&&_e.includes(e)?e:`network`}function be(e,t){return t===`network`?e.tabNetwork:t===`access`?e.tabAccess:t===`updates`?e.tabUpdates:t===`security`?e.tabSecurity:e.tabAdvanced}function xe(e,t){return t===`network`?e.networkTabHint:t===`access`?e.accessTabHint:t===`updates`?e.updatesTabHint:t===`security`?e.securitySectionHint:e.advancedSectionHint}function Se(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 Ce={saving:!1,error:null,saveOk:!1,auditRefreshToken:0,restarting:!1,restartConfirmOpen:!1};function we(){let e=o(e=>e.language),t=a(e),n=t.gatewaySettings,[r,c]=h(),l=O(e=>e.mode),d=l===`advanced`,f=ye(r.get(`tab`)),g=(0,B.useMemo)(()=>se(_e,l),[l]),v=(0,B.useCallback)(e=>{c(t=>{let n=new URLSearchParams(t);return e===`network`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[c]);oe(f,v);let C=s(e=>e.token),E=s(e=>e.tokenExpired),D=s(e=>e.openTokenDialog),k=!!C,[A,M]=(0,B.useReducer)(Se,{form:null,baseline:null,appliedBaseline:null}),P=A.form,F=A.baseline,I=A.appliedBaseline,[te,R]=(0,B.useReducer)(m,Ce),{saving:z,error:ie,auditRefreshToken:V,restarting:H,restartConfirmOpen:U}=te,W=(0,B.useRef)(!1),G=(0,B.useRef)(null),K=(0,B.useRef)(!1),{data:J,error:Y,isLoading:pe,mutate:me}=T(k),X=(0,B.useMemo)(()=>J?.payload?.config===void 0?null:structuredClone(ce(J.payload.config)),[J]);k?X!==null&&(K.current||(K.current=!0,M({type:`init-applied`,value:X})),!W.current&&G.current!==X&&(G.current=X,M({type:`sync`,value:X}),R({type:`patch`,patch:{saveOk:!1}}))):(G.current!==null||K.current)&&(G.current=null,K.current=!1,M({type:`reset`}),W.current=!1);let he=!!(k&&pe&&J===void 0&&!Y),ge=Y instanceof Error?Y.message:Y?String(Y):null,ve=(0,B.useMemo)(()=>!P||!F?!1:JSON.stringify(P)!==JSON.stringify(F),[P,F]),be=(0,B.useMemo)(()=>!F||!I?!1:de(I,F),[I,F]),xe=(0,B.useCallback)(e=>{W.current=!0,M({type:`set-form`,updater:t=>({...t,auth:{...t.auth,...e}})})},[]),we=(0,B.useCallback)(e=>{W.current=!0,M({type:`set-form`,updater:t=>({...t,updateChannel:e})})},[]),$=(0,B.useCallback)(e=>{W.current=!0,M({type:`set-form`,updater:t=>({...t,corsOrigins:e})})},[]),Me=(0,B.useCallback)(e=>{W.current=!0,M({type:`set-form`,updater:t=>({...t,bind:e})})},[]),Ne=(0,B.useCallback)(e=>{W.current=!0,M({type:`set-form`,updater:t=>({...t,customBindHost:e,bind:`custom`})})},[]),Pe=(0,B.useCallback)(e=>{W.current=!0,M({type:`set-form`,updater:t=>({...t,port:e})})},[]),Fe=(0,B.useCallback)(e=>{W.current=!0,M({type:`set-form`,updater:t=>({...t,auth:{...t.auth,rateLimit:{...t.auth.rateLimit,...e}}})})},[]),Ie=(0,B.useCallback)(e=>{W.current=!0,M({type:`set-form`,updater:t=>({...t,maxSseConnections:e})})},[]),Le=(0,B.useCallback)(e=>{W.current=!0,M({type:`set-form`,updater:t=>({...t,channelConnectDeferMode:e})})},[]),Re=(0,B.useCallback)(e=>{W.current=!0,M({type:`set-form`,updater:t=>({...t,channelConnectDeferIds:e})})},[]),ze=(0,B.useCallback)(e=>{W.current=!0,M({type:`set-form`,updater:t=>({...t,channelConnectDeferSkipIds:e})})},[]),Be=(0,B.useCallback)(e=>{W.current=!0,M({type:`set-form`,updater:t=>({...t,trustedProxies:e})})},[]),Ve=(0,B.useCallback)(e=>{W.current=!0,M({type:`set-form`,updater:t=>({...t,auth:{...t.auth,trustedProxy:{...t.auth.trustedProxy,...e}}})})},[]),He=(0,B.useCallback)(e=>{W.current=!0,M({type:`set-form`,updater:t=>({...t,securityStrict:e})})},[]),Ue=(0,B.useCallback)(e=>{W.current=!0,M({type:`set-form`,updater:t=>({...t,allowRealIpFallback:e})})},[]),We=(0,B.useCallback)(e=>{W.current=!0,M({type:`set-form`,updater:t=>({...t,dangerouslyAllowHostHeaderOriginFallback:e})})},[]),Ge=(0,B.useCallback)(async()=>{if(!P||z)return;let e=le(P);if(e){R({type:`patch`,patch:{error:e}});return}R({type:`patch`,patch:{saving:!0,error:null,saveOk:!1}});try{await ue(P),W.current=!1,M({type:`saved`,value:P}),R({type:`patch`,patch:{saveOk:!0,auditRefreshToken:V+1}}),u({type:`success`,title:n.saved})}catch(e){R({type:`patch`,patch:{error:e instanceof Error?e.message:n.saveError}})}finally{R({type:`patch`,patch:{saving:!1}})}},[P,z,n.saveError]),Ke=(0,B.useCallback)(()=>{F&&(W.current=!1,M({type:`discard`}),R({type:`patch`,patch:{error:null,saveOk:!1}}))},[F]),qe=N(n),Je=(0,B.useCallback)(async()=>{if(!H){R({type:`patch`,patch:{restarting:!0,restartConfirmOpen:!1}});try{let e=await L();e.ok?window.dispatchEvent(new Event(`gateway-restart-initiated`)):u({type:`error`,title:n.restartGatewayFailed,message:e.message??``})}catch(e){u({type:`error`,title:n.restartGatewayFailed,message:e instanceof Error?e.message:String(e)})}finally{R({type:`patch`,patch:{restarting:!1}})}}},[H,n.restartGatewayFailed]);return k?he?(0,q.jsx)(ne,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,q.jsx)(b,{className:`size-4 animate-spin`}),n.loading]})}):P?(0,q.jsxs)(ne,{gap:`gap-6`,children:[(0,q.jsx)(ee,{title:t.settingsSections.gateway,subtitle:n.subtitle,docsLink:x(e,`gateway`),docsLabel:n.docsLink,actions:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(y,{type:`button`,variant:`secondary`,disabled:!ve||z,onClick:Ke,children:n.discard}),(0,q.jsx)(y,{type:`button`,variant:`primary`,disabled:!ve||z,onClick:()=>void Ge(),children:z?n.saving:n.save})]})}),E?(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)(_,{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)(y,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:()=>D(),children:n.updateToken})})]}):null,ve?(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,be?(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)(y,{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:H,onClick:()=>R({type:`patch`,patch:{restartConfirmOpen:!0}}),children:[H?(0,q.jsx)(b,{className:`size-3.5 animate-spin`}):(0,q.jsx)(w,{className:`size-3.5`}),n.restartGatewayButton]})]}):null,(0,q.jsx)(p,{open:U,title:n.restartGatewayButton,description:n.restartGatewayConfirm,confirmLabel:n.restartGatewayButton,cancelLabel:n.discard,destructive:!0,onConfirm:()=>void Je(),onCancel:()=>R({type:`patch`,patch:{restartConfirmOpen:!1}})}),(0,q.jsx)(Te,{g:n,activeTab:f,visibleTabs:g,onChange:v}),(0,q.jsxs)(Q,{g:n,id:`network`,activeTab:f,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)(S,{id:`gateway-bind-mode`,className:Z(),value:P.bind,onChange:e=>Me(e.target.value),children:[(0,q.jsx)(j,{value:`loopback`,children:n.bindLoopback}),d?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(j,{value:`lan`,children:n.bindLan}),(0,q.jsx)(j,{value:`auto`,children:n.bindAuto}),(0,q.jsx)(j,{value:`custom`,children:n.bindCustom}),(0,q.jsx)(j,{value:`tailnet`,children:n.bindTailnet})]}):null]})]}),P.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:i(Z(),`font-mono text-xs`),value:P.customBindHost,onChange:e=>Ne(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:i(Z(),`font-mono text-xs`),value:P.port,onChange:e=>{let t=Number(e.target.value);Pe(Number.isFinite(t)?Math.max(1,Math.min(65535,Math.floor(t))):P.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)(ke,{g:n,origins:P.corsOrigins,onChange:$})})]}),(0,q.jsxs)(Q,{g:n,id:`access`,activeTab:f,children:[P.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)(S,{id:`gateway-auth-mode`,value:P.auth.mode,onChange:e=>xe({mode:e.target.value}),className:Z(),children:[(0,q.jsx)(j,{value:`token`,children:n.authModeToken}),(0,q.jsx)(j,{value:`password`,children:n.authModePassword}),d?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(j,{value:`trusted-proxy`,children:n.authModeTrustedProxy}),(0,q.jsx)(j,{value:`none`,children:n.authModeNoneLabel})]}):null]})]}),(0,q.jsx)(re,{children:P.auth.mode===`trusted-proxy`?(0,q.jsx)(De,{g:n,form:P,onTrustedProxyChange:Ve,onTrustedProxiesChange:Be,onAllowRealIpFallbackChange:Ue}):null}),P.auth.mode===`token`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(je,{id:`gateway-access-token`,label:n.accessToken,help:n.tokenHelp,placeholder:n.tokenPlaceholder,value:P.auth.token,labels:qe,reveal:()=>ae(`token`).then(e=>e.secret),loadFailedLabel:n.saveError,onChange:e=>xe({token:e})}),(0,q.jsx)(y,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:()=>D(),children:n.changeToken})]}):null,P.auth.mode===`password`?(0,q.jsx)(je,{id:`gateway-auth-password`,label:n.authPassword,help:n.authPasswordHelp,placeholder:n.authPasswordPlaceholder,value:P.auth.password,labels:qe,reveal:()=>ae(`password`).then(e=>e.secret),loadFailedLabel:n.saveError,onChange:e=>xe({password:e})}):null,(0,q.jsx)(re,{children:P.auth.mode===`none`?null:(0,q.jsx)(Ae,{g:n,rateLimit:P.auth.rateLimit,onChange:Fe})})]}),(0,q.jsxs)(Q,{g:n,id:`updates`,activeTab:f,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)(S,{id:`gateway-update-channel`,value:P.updateChannel,onChange:e=>we(e.target.value),className:Z(),children:[(0,q.jsx)(j,{value:`stable`,children:n.channelStable}),(0,q.jsx)(j,{value:`beta`,children:n.channelBeta}),(0,q.jsx)(j,{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:P.updateCheckOnStart,onChange:e=>{W.current=!0,M({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:P.updateAutoEnabled,onChange:e=>{W.current=!0,M({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:!P.updateAutoEnabled,className:Z(),value:P.updateAutoStableDelayHours,onChange:e=>{W.current=!0,M({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:!P.updateAutoEnabled,className:Z(),value:P.updateAutoStableJitterHours,onChange:e=>{W.current=!0,M({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:!P.updateAutoEnabled,className:Z(),value:P.updateAutoBetaCheckIntervalHours,onChange:e=>{W.current=!0,M({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)(Q,{g:n,id:`security`,activeTab:f,children:[(0,q.jsx)(fe,{enabled:k,refreshToken:V}),(0,q.jsx)(Ee,{g:n,form:P,onSecurityStrictChange:He,onDangerouslyAllowHostHeaderOriginFallbackChange:We})]}),(0,q.jsx)(Q,{g:n,id:`advanced`,activeTab:f,children:(0,q.jsx)(Oe,{g:n,form:P,onMaxSseConnectionsChange:Ie,onDeferModeChange:Le,onDeferIdsChange:Re,onSkipIdsChange:ze})})]}):(0,q.jsxs)(ne,{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??ge??n.loadError}),(0,q.jsx)(y,{type:`button`,variant:`secondary`,onClick:()=>void me(),children:n.retry})]}):(0,q.jsxs)(ne,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,q.jsx)(ee,{title:t.settingsSections.gateway}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]})}function Te(e){let t=(0,V.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:be(n,e),icon:ve[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 Q(e){let t=(0,V.c)(14),{g:n,id:r,activeTab:i,children:a}=e,o;t[0]!==n||t[1]!==r?(o=be(n,r),t[0]=n,t[1]=r,t[2]=o):o=t[2];let s;t[3]!==n||t[4]!==r?(s=xe(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 Ee(e){let t=(0,V.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 De(e){let t=(0,V.c)(80),{g:n,form:r,onTrustedProxyChange:a,onTrustedProxiesChange:o,onAllowRealIpFallbackChange:s}=e,c=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=i(Z(),`font-mono text-xs`),t[4]=d):d=t[4];let f;t[5]===a?f=t[6]:(f=e=>a({userHeader:e.target.value}),t[5]=a,t[6]=f);let p;t[7]!==n.trustedProxyUserHeaderPlaceholder||t[8]!==f||t[9]!==c.userHeader?(p=(0,q.jsx)(`input`,{id:`gateway-trusted-proxy-user-header`,className:d,value:c.userHeader,onChange:f,placeholder:n.trustedProxyUserHeaderPlaceholder,autoComplete:`off`}),t[7]=n.trustedProxyUserHeaderPlaceholder,t[8]=f,t[9]=c.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]===a?g=t[18]:(g=e=>a({requiredHeaders:e}),t[17]=a,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]!==c.requiredHeaders?(_=(0,q.jsx)($,{title:n.trustedProxyRequiredHeaders,hint:n.trustedProxyRequiredHeadersHint,emptyText:n.channelIdListEmpty,placeholder:n.trustedProxyUserHeaderPlaceholder,values:c.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]=c.requiredHeaders,t[25]=_):_=t[25];let v;t[26]===a?v=t[27]:(v=e=>a({allowUsers:e}),t[26]=a,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]!==c.allowUsers?(y=(0,q.jsx)($,{title:n.trustedProxyAllowUsers,hint:n.trustedProxyAllowUsersHint,emptyText:n.channelIdListEmpty,placeholder:n.trustedProxyUserHeaderPlaceholder,values:c.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]=c.allowUsers,t[34]=y):y=t[34];let b;t[35]===a?b=t[36]:(b=e=>a({allowLoopback:e.target.checked}),t[35]=a,t[36]=b);let x;t[37]!==b||t[38]!==c.allowLoopback?(x=(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:c.allowLoopback,onChange:b}),t[37]=b,t[38]=c.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]!==o?(E=(0,q.jsx)($,{title:n.trustedProxies,hint:n.trustedProxiesHint,emptyText:n.trustedProxiesEmpty,placeholder:n.trustedProxiesPlaceholder,values:r.trustedProxies,maxItems:64,onChange:o}),t[50]=r.trustedProxies,t[51]=n.trustedProxies,t[52]=n.trustedProxiesEmpty,t[53]=n.trustedProxiesHint,t[54]=n.trustedProxiesPlaceholder,t[55]=o,t[56]=E):E=t[56];let D;t[57]===s?D=t[58]:(D=e=>s(e.target.checked),t[57]=s,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 Oe(e){let t=(0,V.c)(58),{g:n,form:r,onMaxSseConnectionsChange:a,onDeferModeChange:o,onDeferIdsChange:s,onSkipIdsChange:c}=e,l;t[0]===n.maxSseConnections?l=t[1]:(l=(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-max-sse`,children:n.maxSseConnections}),t[0]=n.maxSseConnections,t[1]=l);let u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(Z(),`max-w-xs font-mono text-xs`),t[2]=u):u=t[2];let d;t[3]===a?d=t[4]:(d=e=>{let t=Number(e.target.value);Number.isFinite(t)&&a(Math.max(1,Math.floor(t)))},t[3]=a,t[4]=d);let f;t[5]!==r.maxSseConnections||t[6]!==d?(f=(0,q.jsx)(`input`,{id:`gateway-max-sse`,type:`number`,min:1,className:u,value:r.maxSseConnections,onChange:d}),t[5]=r.maxSseConnections,t[6]=d,t[7]=f):f=t[7];let p;t[8]===n.maxSseConnectionsHint?p=t[9]:(p=(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.maxSseConnectionsHint}),t[8]=n.maxSseConnectionsHint,t[9]=p);let m;t[10]!==l||t[11]!==f||t[12]!==p?(m=(0,q.jsxs)(`div`,{children:[l,f,p]}),t[10]=l,t[11]=f,t[12]=p,t[13]=m):m=t[13];let h;t[14]===n.channelConnectDeferMode?h=t[15]:(h=(0,q.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-channel-defer-mode`,children:n.channelConnectDeferMode}),t[14]=n.channelConnectDeferMode,t[15]=h);let g=r.channelConnectDeferMode,_;t[16]===o?_=t[17]:(_=e=>o(e.target.value),t[16]=o,t[17]=_);let v;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(v=Z(),t[18]=v):v=t[18];let y;t[19]===n.channelConnectDeferModeAuto?y=t[20]:(y=(0,q.jsx)(j,{value:`auto`,children:n.channelConnectDeferModeAuto}),t[19]=n.channelConnectDeferModeAuto,t[20]=y);let b;t[21]===n.channelConnectDeferModeOff?b=t[22]:(b=(0,q.jsx)(j,{value:`off`,children:n.channelConnectDeferModeOff}),t[21]=n.channelConnectDeferModeOff,t[22]=b);let x;t[23]===n.channelConnectDeferModeExplicit?x=t[24]:(x=(0,q.jsx)(j,{value:`explicit`,children:n.channelConnectDeferModeExplicit}),t[23]=n.channelConnectDeferModeExplicit,t[24]=x);let C;t[25]!==r.channelConnectDeferMode||t[26]!==y||t[27]!==b||t[28]!==x||t[29]!==_?(C=(0,q.jsxs)(S,{id:`gateway-channel-defer-mode`,value:g,onChange:_,className:v,children:[y,b,x]}),t[25]=r.channelConnectDeferMode,t[26]=y,t[27]=b,t[28]=x,t[29]=_,t[30]=C):C=t[30];let w;t[31]===n.channelConnectDeferModeHint?w=t[32]:(w=(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.channelConnectDeferModeHint}),t[31]=n.channelConnectDeferModeHint,t[32]=w);let T;t[33]!==C||t[34]!==w||t[35]!==h?(T=(0,q.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-4`,children:[h,C,w]}),t[33]=C,t[34]=w,t[35]=h,t[36]=T):T=t[36];let E;t[37]!==r.channelConnectDeferIds||t[38]!==r.channelConnectDeferMode||t[39]!==n.channelConnectDeferIds||t[40]!==n.channelConnectDeferIdsHint||t[41]!==n.channelIdListEmpty||t[42]!==n.channelIdListPlaceholder||t[43]!==s?(E=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[37]=r.channelConnectDeferIds,t[38]=r.channelConnectDeferMode,t[39]=n.channelConnectDeferIds,t[40]=n.channelConnectDeferIdsHint,t[41]=n.channelIdListEmpty,t[42]=n.channelIdListPlaceholder,t[43]=s,t[44]=E):E=t[44];let D;t[45]!==r.channelConnectDeferMode||t[46]!==r.channelConnectDeferSkipIds||t[47]!==n.channelConnectDeferSkipIds||t[48]!==n.channelConnectDeferSkipIdsHint||t[49]!==n.channelIdListEmpty||t[50]!==n.channelIdListPlaceholder||t[51]!==c?(D=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[45]=r.channelConnectDeferMode,t[46]=r.channelConnectDeferSkipIds,t[47]=n.channelConnectDeferSkipIds,t[48]=n.channelConnectDeferSkipIdsHint,t[49]=n.channelIdListEmpty,t[50]=n.channelIdListPlaceholder,t[51]=c,t[52]=D):D=t[52];let O;return t[53]!==T||t[54]!==E||t[55]!==D||t[56]!==m?(O=(0,q.jsxs)(`div`,{className:`space-y-4`,children:[m,T,E,D]}),t[53]=T,t[54]=E,t[55]=D,t[56]=m,t[57]=O):O=t[57],O}function $(e){let t=(0,V.c)(25),{title:n,hint:r,emptyText:a,placeholder:o,values:s,maxItems:c,onChange:l,children:u}=e,d;t[0]!==c||t[1]!==l||t[2]!==s?(d=e=>{let t=e.trim();!t||s.includes(t)||s.length>=c||l([...s,t])},t[0]=c,t[1]=l,t[2]=s,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]!==a||t[9]!==l||t[10]!==s?(h=s.length===0?(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a}):(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:s.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:i(`text-fg-muted hover:text-fg`,I.press),"aria-label":`Remove ${e}`,onClick:()=>l(s.filter(t=>t!==e)),children:`×`})]},e))}),t[8]=a,t[9]=l,t[10]=s,t[11]=h):h=t[11];let g;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(g=i(Z(),`font-mono text-xs`),t[12]=g):g=t[12];let _=s.length>=c,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]!==o||t[16]!==_||t[17]!==v?(y=(0,q.jsx)(`input`,{className:g,placeholder:o,disabled:_,onKeyDown:v}),t[15]=o,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 ke(e){let t=(0,V.c)(13),{g:n,origins:r,onChange:i}=e,a;t[0]===r?a=t[1]:(a=r.includes(`*`),t[0]=r,t[1]=a);let o=a,s;t[2]!==n.corsOriginsWildcardWarning||t[3]!==o?(s=o?(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[2]=n.corsOriginsWildcardWarning,t[3]=o,t[4]=s):s=t[4];let c;return t[5]!==n.corsOrigins||t[6]!==n.corsOriginsEmpty||t[7]!==n.corsOriginsHint||t[8]!==n.corsOriginsPlaceholder||t[9]!==i||t[10]!==r||t[11]!==s?(c=(0,q.jsx)($,{title:n.corsOrigins,hint:n.corsOriginsHint,emptyText:n.corsOriginsEmpty,placeholder:n.corsOriginsPlaceholder,values:r,maxItems:128,onChange:i,children:s}),t[5]=n.corsOrigins,t[6]=n.corsOriginsEmpty,t[7]=n.corsOriginsHint,t[8]=n.corsOriginsPlaceholder,t[9]=i,t[10]=r,t[11]=s,t[12]=c):c=t[12],c}function Ae(e){let t=(0,V.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 je(e){let t=(0,V.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)(D,{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{we as GatewaySettingsPanel};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./cn-BQ_8x0bT.js";import{Ba as i,Do as a,Ha as o,Qo as s,To as c,Ua as l,Va as u,Wa as d,as as f,bs as p,ct as m,eo as h,jt as g,ks as _,no as v,tl as y,to as b,za as x,zo as S}from"./index-C2F0Clvm.js";var C=e(t(),1),w=n();function T(){return{title:``,description:``,attachments:[],checklist:[``],priority:`normal`,deadlineMode:`none`,deadline:``,maxTurns:`10`,agentId:``,judgeModelRef:``}}function E(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function D(e){let t=e=>String(e).padStart(2,`0`);return[e.getFullYear(),`-`,t(e.getMonth()+1),`-`,t(e.getDate()),`T`,t(e.getHours()),`:`,t(e.getMinutes())].join(``)}function O(e){let t=new Date;return t.setDate(t.getDate()+e),t.setHours(23,59,0,0),D(t)}function k(){let e=new Date,t=e.getDay(),n=t<=5?5-t:7-t+5;return e.setDate(e.getDate()+n),e.setHours(23,59,0,0),D(e)}function A(e){if(e===`today`)return O(0);if(e===`tomorrow`)return O(1);if(e===`friday`)return k();if(e===`custom`){let e=new Date;return e.setHours(e.getHours()+1,0,0,0),D(e)}return``}function j(e,t){let n=e.title.trim()||t.createDialog.goalFallback;return t.createDialog.aiChecklistTemplates.map(e=>E(e,{goal:n}))}function M(e){let t=new Set,n=[];for(let r of e){let e=r.trim();!e||t.has(e.toLowerCase())||(t.add(e.toLowerCase()),n.push(e))}return n}function N({open:e,t,chat:n,busy:D,options:O,onClose:k,onCreate:N}){let[P,F]=(0,C.useState)(()=>T()),[I,L]=(0,C.useState)(!1),[R,z]=(0,C.useState)(null),B=m({chat:n});(0,C.useEffect)(()=>{e||(F(T()),L(!1),z(null),B.clearAttachments())},[B.clearAttachments,e]),(0,C.useEffect)(()=>{!e||!O.defaultAgentId||F(e=>e.agentId?e:{...e,agentId:O.defaultAgentId})},[e,O.defaultAgentId]);let V=e=>F(t=>({...t,...e})),H=O.agents.length?O.agents:[{id:O.defaultAgentId||`main`,workspace:``,profileDir:``,typedModels:{defaultRole:`deep`,preset:[],effective:[]},extends:[],isDefault:!0,skills:{preset:[]},tools:{presetDenied:[],entryDisable:[],effectiveDisable:[]}}],U=H.find(e=>e.id===P.agentId)??H.find(e=>e.id===O.defaultAgentId)??H[0],W=P.agentId||U?.id||`main`,G=[...U?.typedModels.effective??[]].sort((e,t)=>e.id===`judge`?-1:t.id===`judge`?1:e.id.localeCompare(t.id)),K=O.models.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t),q=e=>{V({deadlineMode:e,deadline:A(e)})},J=(e,t)=>{F(n=>({...n,checklist:n.checklist.map((n,r)=>r===e?t:n)}))},Y=e=>{F(t=>({...t,checklist:t.checklist.filter((t,n)=>n!==e)}))},X=async()=>{if(z(null),!P.title.trim()){z(t.createDialog.titleRequired);return}try{await N({...P,attachments:B.wireAttachmentsPayload(),checklist:M(P.checklist)}),k()}catch(e){z(e instanceof Error?e.message:t.errors.create)}};return(0,w.jsx)(l,{open:e,onOpenChange:e=>!e&&k(),children:(0,w.jsxs)(o,{children:[(0,w.jsx)(u,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,w.jsxs)(x,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(92vh,46rem)] w-[min(100%-2rem,44rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[(0,w.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-5 py-4`,children:[(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(d,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.createDialog.title}),(0,w.jsx)(i,{className:`mt-1 truncate text-sm text-fg-muted`,children:t.createDialog.description})]}),(0,w.jsx)(c,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":t.closeDetails,onClick:k,children:(0,w.jsx)(a,{className:`size-5`,"aria-hidden":!0})})]}),(0,w.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,w.jsxs)(`div`,{className:`grid gap-4`,children:[(0,w.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,w.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.goalTitle}),(0,w.jsx)(`input`,{value:P.title,onChange:e=>V({title:e.target.value}),placeholder:t.newGoalPlaceholder,className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,autoFocus:!0})]}),(0,w.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,w.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,w.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.goalDescription}),(0,w.jsxs)(c,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg text-xs`,onClick:()=>B.fileInputRef.current?.click(),children:[(0,w.jsx)(_,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.addAttachment]})]}),(0,w.jsx)(`textarea`,{value:P.description,onChange:e=>V({description:e.target.value}),placeholder:t.createDialog.descriptionPlaceholder,rows:4,className:`resize-none rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`}),(0,w.jsx)(`input`,{ref:B.fileInputRef,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{let t=Array.from(e.currentTarget.files??[]);e.currentTarget.value=``,B.processFiles(t)}}),(0,w.jsx)(g,{attachments:B.attachments,topPadded:!1,onRemove:B.removeAttachment})]}),(0,w.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base/60 p-4`,children:[(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.createDialog.criteriaTitle}),(0,w.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.createDialog.criteriaHint}),(0,w.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:O.checklistDecomposePolicy===`supplement_existing`?t.createDialog.checklistPolicySupplementExisting:t.createDialog.checklistPolicyEmptyOnly})]}),(0,w.jsxs)(c,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg text-xs`,onClick:()=>V({checklist:j(P,t)}),disabled:!P.title.trim()&&!P.description.trim(),children:[(0,w.jsx)(s,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.aiDraft]})]}),(0,w.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[P.checklist.map((e,n)=>(0,w.jsxs)(`div`,{className:`flex gap-2`,children:[(0,w.jsx)(`input`,{value:e,onChange:e=>J(n,e.target.value),placeholder:E(t.createDialog.criteriaPlaceholder,{index:n+1}),className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`}),(0,w.jsx)(c,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 rounded-lg p-0`,"aria-label":t.createDialog.removeCriteria,onClick:()=>Y(n),children:(0,w.jsx)(S,{className:`size-4`,"aria-hidden":!0})})]},n)),(0,w.jsxs)(c,{type:`button`,variant:`ghost`,className:`h-8 justify-start rounded-lg text-xs`,onClick:()=>V({checklist:[...P.checklist,``]}),children:[(0,w.jsx)(p,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.addCriteria]})]})]}),(0,w.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base/60`,children:[(0,w.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-4 py-3 text-left`,onClick:()=>L(e=>!e),children:[(0,w.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,w.jsx)(f,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t.createDialog.advanced]}),(0,w.jsx)(y,{className:r(`size-4 text-fg-muted transition-transform`,I&&`rotate-180`),"aria-hidden":!0})]}),I?(0,w.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-4 sm:grid-cols-2`,children:[(0,w.jsxs)(`label`,{className:`grid gap-1.5 sm:col-span-2`,children:[(0,w.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.agentId}),(0,w.jsx)(h,{value:W,onChange:e=>V({agentId:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:H.map(e=>(0,w.jsx)(v,{value:e.id,children:(e.name?.trim()||e.id)+(e.isDefault?` · ${t.createDialog.defaultAgent}`:` · ${e.id}`)},e.id))}),U?.description?(0,w.jsx)(`span`,{className:`line-clamp-2 text-xs text-fg-muted`,children:U.description}):U?.model?.primary?(0,w.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:E(t.createDialog.agentPrimaryModel,{model:U.model.primary})}):null]}),(0,w.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,w.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.priority}),(0,w.jsxs)(h,{value:P.priority,onChange:e=>V({priority:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:[(0,w.jsx)(v,{value:`normal`,children:t.priorities.normal}),(0,w.jsx)(v,{value:`high`,children:t.priorities.high}),(0,w.jsx)(v,{value:`low`,children:t.priorities.low})]})]}),(0,w.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,w.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.deadline}),(0,w.jsxs)(h,{value:P.deadlineMode,onChange:e=>q(e.target.value),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:[(0,w.jsx)(v,{value:`none`,children:t.createDialog.deadlineNone}),(0,w.jsx)(v,{value:`today`,children:t.createDialog.deadlineToday}),(0,w.jsx)(v,{value:`tomorrow`,children:t.createDialog.deadlineTomorrow}),(0,w.jsx)(v,{value:`friday`,children:t.createDialog.deadlineFriday}),(0,w.jsx)(v,{value:`custom`,children:t.createDialog.deadlineCustom})]})]}),P.deadlineMode===`none`?null:(0,w.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,w.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.deadlineAt}),(0,w.jsx)(`input`,{type:`datetime-local`,value:P.deadline,onChange:e=>V({deadline:e.target.value,deadlineMode:`custom`}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,w.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,w.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.maxTurns}),(0,w.jsx)(`input`,{type:`number`,min:1,max:500,value:P.maxTurns,onChange:e=>V({maxTurns:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,w.jsxs)(`label`,{className:`grid gap-1.5 sm:col-span-2`,children:[(0,w.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.judgeModel}),(0,w.jsxs)(h,{value:P.judgeModelRef,onChange:e=>V({judgeModelRef:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:[(0,w.jsx)(v,{value:``,children:t.createDialog.judgeModelPlaceholder}),G.length?(0,w.jsx)(b,{label:t.createDialog.agentModelRoles,children:G.map(e=>(0,w.jsxs)(v,{value:e.model,children:[e.id===`judge`?t.createDialog.judgeRole:e.id,` · `,e.model]},`${e.id}:${e.model}`))}):null,(0,w.jsx)(b,{label:t.createDialog.configuredModels,children:K.map(e=>(0,w.jsxs)(v,{value:e.id,children:[e.name,` · `,e.id]},e.id))})]})]})]}):null]}),R?(0,w.jsx)(`p`,{className:`rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:R}):null]})}),(0,w.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,w.jsx)(c,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:k,children:t.createDialog.cancel}),(0,w.jsxs)(c,{type:`button`,variant:`primary`,className:`rounded-lg`,disabled:D||!P.title.trim(),onClick:()=>void X(),children:[(0,w.jsx)(p,{className:`size-4`,"aria-hidden":!0}),t.createDialog.create]})]})]})]})})}export{M as n,N as t};