@xopcai/xopc 0.0.307 → 0.0.309

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 (261) hide show
  1. package/dist/browser-ext/_locales/en/messages.json +8 -0
  2. package/dist/browser-ext/_locales/zh_CN/messages.json +8 -0
  3. package/dist/browser-ext/dist/assets/{sidepanel-BbSQr-6P.css → sidepanel-DD6GEMvc.css} +16 -0
  4. package/dist/browser-ext/dist/sidepanel.html +1 -1
  5. package/dist/browser-ext/dist/sidepanel.js +537 -96
  6. package/dist/browser-ext/manifest.json +1 -1
  7. package/dist/extensions/telegram/xopc.extension.json +1 -1
  8. package/dist/gateway/static/root/assets/{activity-store-wgSB2HYK.js → activity-store-XKNYlFUI.js} +1 -1
  9. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CZeQo09T.js → agent-avatar-dicebear-1S2TFECE.js} +1 -1
  10. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-f0-YFMUz.js +1 -0
  11. package/dist/gateway/static/root/assets/{agents-BlrHMbRx.js → agents-CPqUMtCL.js} +1 -1
  12. package/dist/gateway/static/root/assets/{api-BKHmTb0w.js → api-BEUEE4f2.js} +1 -1
  13. package/dist/gateway/static/root/assets/api-CN4id43t.js +1 -0
  14. package/dist/gateway/static/root/assets/{app-management-settings-panel-Bzw4fQP8.js → app-management-settings-panel-CgVBSqzu.js} +1 -1
  15. package/dist/gateway/static/root/assets/{appearance-settings-8GZpUXva.js → appearance-settings-CoWdCokb.js} +1 -1
  16. package/dist/gateway/static/root/assets/{apps-page-BkQQtIxH.js → apps-page-CexHOcWg.js} +1 -1
  17. package/dist/gateway/static/root/assets/{archive-plugin-CQ2NaoHb.js → archive-plugin-C3ZA6LRS.js} +1 -1
  18. package/dist/gateway/static/root/assets/{attachment-load-BFi1H7yJ.js → attachment-load-CdgS6_zy.js} +1 -1
  19. package/dist/gateway/static/root/assets/{automations-page-CDBXcii_.js → automations-page-BtHL2hpg.js} +1 -1
  20. package/dist/gateway/static/root/assets/automations-workspace-onJPfmO6.js +6 -0
  21. package/dist/gateway/static/root/assets/{binary-plugins-D07eWmOx.js → binary-plugins-CiDhtq_H.js} +1 -1
  22. package/dist/gateway/static/root/assets/{block-editor-CtVnjyYU.js → block-editor-Br00T83w.js} +3 -3
  23. package/dist/gateway/static/root/assets/{browser-automation-inputs-BzkJog8e.js → browser-automation-inputs-D2tILykA.js} +1 -1
  24. package/dist/gateway/static/root/assets/{browser-automations-page-DyrSbDdG.js → browser-automations-page-BVuEmryB.js} +1 -1
  25. package/dist/gateway/static/root/assets/browser-settings-page-BgVTyPFY.js +3 -0
  26. package/dist/gateway/static/root/assets/capabilities-settings-panel-Dra8wj1S.js +8 -0
  27. package/dist/gateway/static/root/assets/{channels-settings-DAD9qE3J.js → channels-settings-CkxiMDJ4.js} +1 -1
  28. package/dist/gateway/static/root/assets/{channels-status-swr-B2JwuTjG.js → channels-status-swr-Dtder4G_.js} +1 -1
  29. package/dist/gateway/static/root/assets/{chat-terminal-dock-B62SZdAo.js → chat-terminal-dock-JsMtzDao.js} +1 -1
  30. package/dist/gateway/static/root/assets/{computer-settings-page-ClSresNq.js → computer-settings-page-DHerePwo.js} +1 -1
  31. package/dist/gateway/static/root/assets/connector-service-page-DZFNUTiN.js +1 -0
  32. package/dist/gateway/static/root/assets/connectors-page-cl9ZrV4D.js +2 -0
  33. package/dist/gateway/static/root/assets/{cron-expression-CTMi_tql.js → cron-expression-DAhdv_Xv.js} +1 -1
  34. package/dist/gateway/static/root/assets/{date-picker-B71AJK50.js → date-picker-PacO1m3a.js} +1 -1
  35. package/dist/gateway/static/root/assets/{dependency-picker-DlyGK-kA.js → dependency-picker-B-BcuG1y.js} +1 -1
  36. package/dist/gateway/static/root/assets/{desktop-pet-DGkbTE8_.js → desktop-pet-CdBBhhdY.js} +1 -1
  37. package/dist/gateway/static/root/assets/{desktop-pet-settings-BY8r9j66.js → desktop-pet-settings-Gy03NgMI.js} +1 -1
  38. package/dist/gateway/static/root/assets/{device-pairing-wizard-DzRrgd59.js → device-pairing-wizard-aV25nKag.js} +1 -1
  39. package/dist/gateway/static/root/assets/{extension-debug-page-L8Mm1n3A.js → extension-debug-page-BFp5eKtY.js} +1 -1
  40. package/dist/gateway/static/root/assets/{extension-page-CFc4vSNU.js → extension-page-DL3vyyH6.js} +1 -1
  41. package/dist/gateway/static/root/assets/{extension-settings-page-B5zWyHr3.js → extension-settings-page-BXtvdAsY.js} +1 -1
  42. package/dist/gateway/static/root/assets/{gateway-config-swr-B6wHa6ZI.js → gateway-config-swr-xAOGtenO.js} +1 -1
  43. package/dist/gateway/static/root/assets/{gateway-realtime-B53R0CA4.js → gateway-realtime-BuaTsMSi.js} +1 -1
  44. package/dist/gateway/static/root/assets/gateway-realtime-store-BG95uGVW.js +1 -0
  45. package/dist/gateway/static/root/assets/{gateway-settings-D7qmTH4R.js → gateway-settings-Dcr2Ikeh.js} +1 -1
  46. package/dist/gateway/static/root/assets/{gateway-startup-retry-DRzGnEV-.js → gateway-startup-retry-BwDxKHd4.js} +1 -1
  47. package/dist/gateway/static/root/assets/{heartbeat-settings-Glsl3X5b.js → heartbeat-settings-DOy3alvT.js} +1 -1
  48. package/dist/gateway/static/root/assets/home-page-CDm3dGVy.js +1 -0
  49. package/dist/gateway/static/root/assets/{image-generation-api-Ck_pyDom.js → image-generation-api-wGMeI_yW.js} +1 -1
  50. package/dist/gateway/static/root/assets/{imports-page-ByBX7ome.js → imports-page-zexFT5Rq.js} +1 -1
  51. package/dist/gateway/static/root/assets/index-D-vczw_0.css +1 -0
  52. package/dist/gateway/static/root/assets/index-DJo4DimT.js +79 -0
  53. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-C45RlO8a.js → keyboard-shortcuts-settings-CutG9zLh.js} +1 -1
  54. package/dist/gateway/static/root/assets/{local-app-workbench-page-DP0x2jpR.js → local-app-workbench-page-CwLvTwjn.js} +2 -2
  55. package/dist/gateway/static/root/assets/{local-apps-page-C_AQc2bI.js → local-apps-page-CJy6I7Dt.js} +1 -1
  56. package/dist/gateway/static/root/assets/{locale-store-msTfRK8P.js → locale-store-DPZ79W1-.js} +1 -1
  57. package/dist/gateway/static/root/assets/{logs-page-DvM8Pyok.js → logs-page-egGcPHNi.js} +1 -1
  58. package/dist/gateway/static/root/assets/{management-settings-D1uwSutV.js → management-settings-BQhIOELc.js} +1 -1
  59. package/dist/gateway/static/root/assets/{markdown-view-BInabSKf.js → markdown-view-p2P5hP1U.js} +1 -1
  60. package/dist/gateway/static/root/assets/{media-plugins-C4mhf13f.js → media-plugins-CsBylqlN.js} +1 -1
  61. package/dist/gateway/static/root/assets/messages-BiYTyLJr.js +3 -0
  62. package/dist/gateway/static/root/assets/note-detail-panel-c2k5Uz6X.js +5 -0
  63. package/dist/gateway/static/root/assets/notes-page-BLQWJMhf.js +8 -0
  64. package/dist/gateway/static/root/assets/{page-tabs-1go_BtX1.js → page-tabs-ChQ4jJFs.js} +1 -1
  65. package/dist/gateway/static/root/assets/{preview-open-alternatives-DmoSC0j1.js → preview-open-alternatives-9B5W7nVE.js} +1 -1
  66. package/dist/gateway/static/root/assets/{proactive-page-xAjKTIID.js → proactive-page-iOjI0d_e.js} +1 -1
  67. package/dist/gateway/static/root/assets/{product-open-page-gmi5LLwM.js → product-open-page-BADxWEdP.js} +1 -1
  68. package/dist/gateway/static/root/assets/project-detail-page-BcxbQn2M.js +1 -0
  69. package/dist/gateway/static/root/assets/projects-page-BuSvld0O.js +1 -0
  70. package/dist/gateway/static/root/assets/{registry-api-BSWtko7U.js → registry-api-B_e_nZSN.js} +1 -1
  71. package/dist/gateway/static/root/assets/remote-access-hub-CFS8LQKW.js +1 -0
  72. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-ClkOoxDl.js → runtime-tools-settings-panel-D-pwiIyp.js} +1 -1
  73. package/dist/gateway/static/root/assets/{schema-form-BuEmLiaU.js → schema-form-IWmb05DX.js} +1 -1
  74. package/dist/gateway/static/root/assets/sessions-page-DZjc__ok.js +1 -0
  75. package/dist/gateway/static/root/assets/settings-advanced-gate-C1SM5B93.js +1 -0
  76. package/dist/gateway/static/root/assets/{settings-form-section-Dor39QON.js → settings-form-section-B0veRBZs.js} +1 -1
  77. package/dist/gateway/static/root/assets/{settings-page-Xj-yvIc8.js → settings-page-CxRWyWYe.js} +1 -1
  78. package/dist/gateway/static/root/assets/setup-status-panel-D9Rl7Tec.js +1 -0
  79. package/dist/gateway/static/root/assets/{share-preview-page-BFWZoXdm.js → share-preview-page-CirpgkfD.js} +1 -1
  80. package/dist/gateway/static/root/assets/shares-settings-CwCThBs0.js +1 -0
  81. package/dist/gateway/static/root/assets/skill-reload-api-DG6VGbOX.js +1 -0
  82. package/dist/gateway/static/root/assets/skills-page-BdRJ2vnL.js +2 -0
  83. package/dist/gateway/static/root/assets/{skills-page.utils-Ii8qeXhs.js → skills-page.utils-B42mpWKV.js} +1 -1
  84. package/dist/gateway/static/root/assets/{system-settings-panel-Di6OSO-0.js → system-settings-panel-DXIZpAvU.js} +1 -1
  85. package/dist/gateway/static/root/assets/task-detail-page-QXo9LJly.js +1 -0
  86. package/dist/gateway/static/root/assets/{theme-store-1SZ-HFHX.js → theme-store-BFbj_2Tu.js} +1 -1
  87. package/dist/gateway/static/root/assets/{tunnel-api-DDOlOYlj.js → tunnel-api-Db2guRdW.js} +1 -1
  88. package/dist/gateway/static/root/assets/{use-autosave-CQ8uWNnB.js → use-autosave-DDY9qoXZ.js} +1 -1
  89. package/dist/gateway/static/root/assets/user-model-page-CzPmMkaO.js +2 -0
  90. package/dist/gateway/static/root/assets/{voice-api-key-field-COTzshjL.js → voice-api-key-field-BZbKQ8HT.js} +1 -1
  91. package/dist/gateway/static/root/assets/{voice-config-api-DgJML_uM.js → voice-config-api-SKCeQLrH.js} +1 -1
  92. package/dist/gateway/static/root/assets/{work-discovery-overlay-_URrXbi4.js → work-discovery-overlay-BRVTTXNG.js} +1 -1
  93. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-CALs-1nd.js → workflow-run-setup-panel-D2kuwv5e.js} +2 -2
  94. package/dist/gateway/static/root/assets/workflows-page-CQXtiYtq.js +6 -0
  95. package/dist/gateway/static/root/index.html +12 -12
  96. package/dist/package.js +1 -1
  97. package/dist/packages/gateway-contract/src/notifications.js +1 -1
  98. package/dist/packages/gateway-contract/src/sessions.js +6 -1
  99. package/dist/src/agent/agent-manager.js +29 -4
  100. package/dist/src/agent/background-review/prompts.js +3 -1
  101. package/dist/src/agent/child-agent-factory.d.ts +1 -0
  102. package/dist/src/agent/child-agent-factory.js +18 -4
  103. package/dist/src/agent/coding/repository-instructions.d.ts +4 -0
  104. package/dist/src/agent/coding/repository-instructions.js +46 -2
  105. package/dist/src/agent/context/execution-context.js +4 -4
  106. package/dist/src/agent/data-acquisition/git.d.ts +17 -0
  107. package/dist/src/agent/data-acquisition/git.js +100 -0
  108. package/dist/src/agent/data-acquisition/render.d.ts +7 -0
  109. package/dist/src/agent/data-acquisition/render.js +79 -0
  110. package/dist/src/agent/data-acquisition/scheduler.d.ts +12 -0
  111. package/dist/src/agent/data-acquisition/scheduler.js +53 -0
  112. package/dist/src/agent/data-acquisition/schema.d.ts +75 -0
  113. package/dist/src/agent/data-acquisition/schema.js +206 -0
  114. package/dist/src/agent/data-acquisition/service.d.ts +10 -0
  115. package/dist/src/agent/data-acquisition/service.js +292 -0
  116. package/dist/src/agent/data-acquisition/types.d.ts +37 -0
  117. package/dist/src/agent/data-acquisition/types.js +5 -0
  118. package/dist/src/agent/embedded/run-turn.js +16 -4
  119. package/dist/src/agent/embedded/session-runner.d.ts +1 -0
  120. package/dist/src/agent/embedded/session-runner.js +3 -0
  121. package/dist/src/agent/embedded/tool-result-truncation.js +11 -0
  122. package/dist/src/agent/embedded/xopc-tools-bridge.js +2 -1
  123. package/dist/src/agent/external-tools/composio-provider.js +12 -1
  124. package/dist/src/agent/external-tools/gateway-tools.js +2 -1
  125. package/dist/src/agent/external-tools/index.js +8 -1
  126. package/dist/src/agent/external-tools/read-policy.d.ts +6 -0
  127. package/dist/src/agent/external-tools/read-policy.js +21 -0
  128. package/dist/src/agent/external-tools/service.d.ts +1 -0
  129. package/dist/src/agent/external-tools/service.js +4 -1
  130. package/dist/src/agent/external-tools/types.d.ts +2 -0
  131. package/dist/src/agent/memory/compaction-promotion.d.ts +1 -1
  132. package/dist/src/agent/memory/compaction-promotion.js +4 -3
  133. package/dist/src/agent/orchestration/agent-turn-policy.js +25 -10
  134. package/dist/src/agent/orchestration/delegation-scope.d.ts +9 -0
  135. package/dist/src/agent/orchestration/delegation-scope.js +11 -0
  136. package/dist/src/agent/prompt/sections/tooling.js +3 -1
  137. package/dist/src/agent/prompt/subagent-context.js +4 -2
  138. package/dist/src/agent/sandbox/fileAccess.d.ts +2 -0
  139. package/dist/src/agent/sandbox/fileAccess.js +31 -2
  140. package/dist/src/agent/tools/dataBatch.d.ts +4 -0
  141. package/dist/src/agent/tools/dataBatch.js +50 -0
  142. package/dist/src/agent/tools/delegate-tool.d.ts +6 -3
  143. package/dist/src/agent/tools/delegate-tool.js +65 -48
  144. package/dist/src/agent/tools/delegation-parent-policy.d.ts +7 -0
  145. package/dist/src/agent/tools/delegation-parent-policy.js +41 -0
  146. package/dist/src/agent/tools/delegation-policy.d.ts +16 -0
  147. package/dist/src/agent/tools/delegation-policy.js +93 -0
  148. package/dist/src/agent/tools/factory.d.ts +2 -0
  149. package/dist/src/agent/tools/factory.js +42 -3
  150. package/dist/src/agent/tools/fetch-text.d.ts +7 -0
  151. package/dist/src/agent/tools/fetch-text.js +86 -0
  152. package/dist/src/agent/tools/find.js +1 -1
  153. package/dist/src/agent/tools/grep.js +11 -23
  154. package/dist/src/agent/tools/index.d.ts +1 -0
  155. package/dist/src/agent/tools/index.js +2 -1
  156. package/dist/src/agent/tools/knowledge-memory-tool.d.ts +1 -1
  157. package/dist/src/agent/tools/knowledge-memory-tool.js +13 -5
  158. package/dist/src/agent/tools/read.js +7 -5
  159. package/dist/src/agent/tools/repository-search.d.ts +12 -2
  160. package/dist/src/agent/tools/repository-search.js +127 -74
  161. package/dist/src/agent/tools/user-context-tool.js +17 -7
  162. package/dist/src/agent/tools/web.js +19 -28
  163. package/dist/src/agent/workflow/subagent-runner.js +25 -3
  164. package/dist/src/agent/workflow/workflow-child-tools.js +13 -8
  165. package/dist/src/agent-config/schema.d.ts +7 -0
  166. package/dist/src/agent-config/schema.js +2 -0
  167. package/dist/src/chat-commands/builtins/understanding.js +1 -1
  168. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  169. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  170. package/dist/src/config/schema.d.ts +6 -4
  171. package/dist/src/config/schema.js +2 -2
  172. package/dist/src/connectors/connected-source-understanding.d.ts +1 -0
  173. package/dist/src/connectors/connected-source-understanding.js +1 -0
  174. package/dist/src/connectors/learning-coordinator.js +31 -9
  175. package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
  176. package/dist/src/gateway/heartbeat/service.js +2 -2
  177. package/dist/src/gateway/hono/lib/config-payload.d.ts +4 -2
  178. package/dist/src/gateway/hono/routes/connectors.js +1 -1
  179. package/dist/src/gateway/hono/routes/context-sources.js +0 -23
  180. package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
  181. package/dist/src/gateway/hono/routes/projects.js +8 -0
  182. package/dist/src/gateway/hono/routes/sessions.js +141 -13
  183. package/dist/src/gateway/hono/routes/user-model-refresh.d.ts +5 -0
  184. package/dist/src/gateway/hono/routes/user-model-refresh.js +128 -0
  185. package/dist/src/gateway/hono/routes/user-model.js +12 -5
  186. package/dist/src/gateway/hono/routes/work-discovery.js +0 -30
  187. package/dist/src/gateway/service.js +6 -6
  188. package/dist/src/heartbeat/index.js +1 -1
  189. package/dist/src/infra/update-restart.js +1 -1
  190. package/dist/src/knowledge/connected-knowledge-pipeline.js +1 -1
  191. package/dist/src/knowledge-memory/index.js +2 -2
  192. package/dist/src/knowledge-memory/repository.d.ts +7 -0
  193. package/dist/src/knowledge-memory/repository.js +58 -8
  194. package/dist/src/memory-maintenance/service.js +61 -31
  195. package/dist/src/migrations/memory-config.d.ts +2 -0
  196. package/dist/src/migrations/memory-config.js +77 -0
  197. package/dist/src/migrations/runner.js +2 -2
  198. package/dist/src/notifications/planner.js +5 -5
  199. package/dist/src/notifications/service.d.ts +2 -2
  200. package/dist/src/notifications/service.js +1 -1
  201. package/dist/src/storage/sqlite/index.d.ts +1 -0
  202. package/dist/src/storage/sqlite/index.js +2 -1
  203. package/dist/src/storage/sqlite/migrations/184_memory_suppressions.sql +12 -0
  204. package/dist/src/storage/sqlite/migrations/185_understanding_refresh_batches.sql +6 -0
  205. package/dist/src/storage/sqlite/migrations/186_sidebar_layout.sql +16 -0
  206. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  207. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  208. package/dist/src/storage/sqlite/schema.js +1 -1
  209. package/dist/src/storage/sqlite/sidebar-layout-repository.d.ts +12 -0
  210. package/dist/src/storage/sqlite/sidebar-layout-repository.js +53 -0
  211. package/dist/src/user-context/config.d.ts +4 -9
  212. package/dist/src/user-context/config.js +7 -27
  213. package/dist/src/user-context/memory-suppression.d.ts +7 -0
  214. package/dist/src/user-context/memory-suppression.js +23 -0
  215. package/dist/src/user-context/relationship-continuity.js +1 -1
  216. package/dist/src/user-context/sources/refresh-service.d.ts +48 -0
  217. package/dist/src/user-context/sources/refresh-service.js +221 -0
  218. package/dist/src/user-context/sources/repository.js +1 -1
  219. package/dist/src/user-model/bootstrap.js +27 -24
  220. package/dist/src/user-model/capture/executor.d.ts +1 -1
  221. package/dist/src/user-model/capture/executor.js +17 -11
  222. package/dist/src/user-model/capture/semantic.js +1 -1
  223. package/dist/src/user-model/domain.d.ts +6 -2
  224. package/dist/src/user-model/index.js +3 -3
  225. package/dist/src/user-model/profile.js +1 -1
  226. package/dist/src/user-model/repository.d.ts +4 -1
  227. package/dist/src/user-model/repository.js +96 -6
  228. package/dist/src/user-model/usage-policy.d.ts +2 -0
  229. package/dist/src/user-model/usage-policy.js +6 -2
  230. package/dist/src/work-discovery/project-understanding.js +2 -1
  231. package/dist/src/work-discovery/service.d.ts +8 -24
  232. package/dist/src/work-discovery/service.js +138 -180
  233. package/package.json +1 -1
  234. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-BPsRb9Ck.js +0 -1
  235. package/dist/gateway/static/root/assets/api-DFOlahZv.js +0 -1
  236. package/dist/gateway/static/root/assets/automations-workspace-CUpiTTiY.js +0 -6
  237. package/dist/gateway/static/root/assets/browser-settings-page-CqTxLpil.js +0 -3
  238. package/dist/gateway/static/root/assets/capabilities-settings-panel-BZ_-pnS6.js +0 -8
  239. package/dist/gateway/static/root/assets/connector-service-page-CPqVmNvx.js +0 -1
  240. package/dist/gateway/static/root/assets/connectors-page-BUQyg3CW.js +0 -2
  241. package/dist/gateway/static/root/assets/gateway-realtime-store-BLDgrJ30.js +0 -1
  242. package/dist/gateway/static/root/assets/home-page-s9hDQ8Hc.js +0 -1
  243. package/dist/gateway/static/root/assets/index-RBCkv8a_.js +0 -79
  244. package/dist/gateway/static/root/assets/index-cFU4S35z.css +0 -1
  245. package/dist/gateway/static/root/assets/messages-F74LVAiU.js +0 -3
  246. package/dist/gateway/static/root/assets/note-detail-panel-D35sErp2.js +0 -5
  247. package/dist/gateway/static/root/assets/notes-page-8jCDklDn.js +0 -8
  248. package/dist/gateway/static/root/assets/project-detail-page-BUMQHy_N.js +0 -1
  249. package/dist/gateway/static/root/assets/projects-page-DT-Mt7XR.js +0 -1
  250. package/dist/gateway/static/root/assets/remote-access-hub-Clz3byir.js +0 -1
  251. package/dist/gateway/static/root/assets/sessions-page-tQRwktKm.js +0 -1
  252. package/dist/gateway/static/root/assets/settings-advanced-gate-DqWg9XS5.js +0 -1
  253. package/dist/gateway/static/root/assets/setup-status-panel-BB_sMB7P.js +0 -1
  254. package/dist/gateway/static/root/assets/shares-settings-oDALm4b6.js +0 -1
  255. package/dist/gateway/static/root/assets/skill-reload-api-DmwelnfK.js +0 -1
  256. package/dist/gateway/static/root/assets/skills-page-BE9JXz4U.js +0 -2
  257. package/dist/gateway/static/root/assets/task-detail-page-D1AWszc7.js +0 -1
  258. package/dist/gateway/static/root/assets/user-model-page-C00i4ea0.js +0 -2
  259. package/dist/gateway/static/root/assets/workflows-page-BUiBjz6m.js +0 -6
  260. package/dist/src/migrations/knowledge-memory-read-policy-config.d.ts +0 -2
  261. package/dist/src/migrations/knowledge-memory-read-policy-config.js +0 -48
@@ -1,8 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-swr-BIWyz7Rc.js","assets/rolldown-runtime-aKtaBQYM.js","assets/vendor-react-BOUWij0V.js"])))=>i.map(i=>d[i]);
2
- 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"./preload-helper-zJ_50EbN.js";import{d as a,h as o,p as s,r as c,t as l}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{n as u,r as d,t as f}from"./popover-select-9i-ZtHXL.js";import{t as p}from"./circle-check-C23XjkUj.js";import{t as m}from"./external-link-DjqjBmc3.js";import{t as h}from"./loader-circle-CifKLtgG.js";import{t as g}from"./plus-Q2yW6OE7.js";import{t as _}from"./x-B_N4OPjy.js";import{t as v}from"./cn-JdwAhgNB.js";import{a as y,c as b,i as x,n as S,r as C}from"./locale-store-msTfRK8P.js";import{t as w}from"./messages-F74LVAiU.js";import{a as T,i as E,n as D,o as O,r as k,s as A,t as j}from"./dist-BGTk37IG.js";import{i as M}from"./vendor-swr-BIWyz7Rc.js";import{t as N}from"./button-CS04eWY9.js";import{n as P,r as ee}from"./gateway-config-swr-B6wHa6ZI.js";import{t as F}from"./skeleton-BwbyijEw.js";import{i as I,o as L}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as R}from"./electron-env-Dit0bHgy.js";import{$i as z,Al as B,At as V,Au as H,Bc as U,Ct as te,Dt as W,Du as G,Eo as K,Et as ne,Fo as re,Js as q,Ju as J,Lo as ie,Mc as Y,Mo as ae,No as X,Ot as oe,Pl as Z,Po as se,Qi as ce,Ro as le,St as ue,To as de,Tt as fe,Wc as pe,Xi as me,_o as he,_t as ge,at as _e,bo as ve,bs as ye,bt as be,ct as xe,dt as Se,et as Ce,fc as we,fl as Te,fo as Ee,ft as De,ht as Oe,hu as ke,il as Ae,it as je,iu as Me,jo as Ne,ko as Pe,kt as Fe,lt as Ie,mn as Le,mo as Re,mt as ze,nc as Be,nt as Ve,ot as He,po as Ue,pt as We,qu as Ge,rt as Ke,st as qe,tc as Je,tt as Ye,ui as Xe,ut as Ze,vc as Qe,vo as $e,vt as et,wc as tt,wo as nt,xc as rt,xo as it,xs as at,xt as ot,yt as st,zc as ct}from"./index-RBCkv8a_.js";import{n as lt,r as ut}from"./settings-page-layout-X1x-2Cp9.js";import{n as dt,t as ft}from"./settings-form-section-Dor39QON.js";import{t as pt}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as mt,t as ht}from"./use-autosave-CQ8uWNnB.js";import{a as gt,c as _t,d as vt,f as yt,h as bt,i as xt,l as St,n as Ct,o as wt,p as Tt,r as Et,t as Dt,u as Ot}from"./voice-config-api-DgJML_uM.js";import{t as kt}from"./voice-api-key-field-COTzshjL.js";import{t as At}from"./page-tabs-1go_BtX1.js";import{t as jt}from"./settings-advanced-gate-DqWg9XS5.js";import{a as Mt,i as Nt,n as Pt,o as Ft,r as It,t as Lt}from"./image-generation-api-Ck_pyDom.js";var Rt=n(),Q=e(t(),1),$=r(),zt={en:{addTitle:`Add image service`,editTitle:`Manage image service`,intro:`Connect an endpoint that implements the OpenAI Images protocol.`,connection:`Connection`,providerId:`Provider ID`,providerIdHint:`Lowercase letters, numbers, hyphens, or underscores.`,name:`Display name`,baseUrl:`Base URL`,auth:`Authentication`,bearer:`Bearer token`,header:`Custom API key header`,none:`No authentication`,headerName:`Header name`,apiKey:`API key`,apiKeyHint:`Stored in the local credential store, separate from models.json.`,apiKeyUrl:`API key page (optional)`,docsUrl:`Documentation page (optional)`,openKeyPage:`Create API key`,paths:`Protocol and network`,generationsPath:`Generations path`,editsPath:`Edits path`,allowedHosts:`Allowed private hosts (optional)`,allowedHostsHint:`One exact hostname or IP per line. Private endpoints stay blocked unless listed here.`,staticHeaders:`Static headers (optional)`,staticHeadersHint:`One per line: X-Tenant: value. Credential headers are rejected.`,models:`Image models`,addModel:`Add model`,modelId:`Model ID`,modelName:`Name (optional)`,defaultModel:`Default model`,maxCount:`Max images`,defaultCount:`Default count`,defaultSize:`Default size`,format:`Output format`,supportsSize:`Supports size`,edit:`Supports edits`,remove:`Remove`,cancel:`Cancel`,save:`Save service`,saving:`Saving…`,test:`Test generation`,testing:`Generating…`,delete:`Delete service`,confirmDelete:`Delete permanently`,saved:`Image service saved.`,deleted:`Image service deleted.`,testReady:`Test image generated.`,show:`Show key`,hide:`Hide key`,copy:`Copy key`,copied:`Copied`,revealFailed:`Unable to reveal the saved key.`,notRevealable:`No revealable key is stored locally.`,required:`Complete the required connection and model fields.`,duplicateModels:`Model IDs must be unique.`,invalidHeaders:`Static headers must use “Name: value”, one per line.`},zh:{addTitle:`添加图片服务`,editTitle:`管理图片服务`,intro:`连接一个严格实现 OpenAI Images 协议的服务端点。`,connection:`连接信息`,providerId:`Provider ID`,providerIdHint:`仅支持小写字母、数字、连字符和下划线。`,name:`显示名称`,baseUrl:`Base URL`,auth:`认证方式`,bearer:`Bearer Token`,header:`自定义 API Key Header`,none:`无需认证`,headerName:`Header 名称`,apiKey:`API Key`,apiKeyHint:`密钥单独保存在本机凭据存储,不写入 models.json。`,apiKeyUrl:`API Key 创建页面(可选)`,docsUrl:`协议文档页面(可选)`,openKeyPage:`去创建 API Key`,paths:`协议与网络`,generationsPath:`生成路径`,editsPath:`编辑路径`,allowedHosts:`允许访问的私有主机(可选)`,allowedHostsHint:`每行一个精确主机名或 IP;未列出的私网端点保持阻止。`,staticHeaders:`静态 Headers(可选)`,staticHeadersHint:`每行一个:X-Tenant: value。认证 Header 会被拒绝。`,models:`图片模型`,addModel:`添加模型`,modelId:`模型 ID`,modelName:`名称(可选)`,defaultModel:`默认模型`,maxCount:`单次最大张数`,defaultCount:`默认张数`,defaultSize:`默认尺寸`,format:`输出格式`,supportsSize:`支持尺寸参数`,edit:`支持图片编辑`,remove:`移除`,cancel:`取消`,save:`保存服务`,saving:`保存中…`,test:`测试生成`,testing:`生成中…`,delete:`删除服务`,confirmDelete:`确认永久删除`,saved:`图片服务已保存。`,deleted:`图片服务已删除。`,testReady:`测试图片生成成功。`,show:`显示密钥`,hide:`隐藏密钥`,copy:`复制密钥`,copied:`已复制`,revealFailed:`无法查看已保存的密钥。`,notRevealable:`本机没有可查看的密钥。`,required:`请补全必填的连接和模型信息。`,duplicateModels:`模型 ID 不能重复。`,invalidHeaders:`静态 Header 必须使用“名称: 值”格式,每行一个。`}},Bt=`mt-1.5 h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`;function Vt(e){let t=e??{id:``,capabilities:{generate:{maxCount:1,supportsSize:!0},edit:{enabled:!1}}};return{original:t,id:t.id,name:t.name??``,maxCount:String(t.capabilities.generate?.maxCount??1),defaultCount:t.defaults?.count?String(t.defaults.count):``,defaultSize:t.defaults?.size??``,outputFormat:t.defaults?.outputFormat??``,supportsSize:t.capabilities.generate?.supportsSize??!1,editEnabled:t.capabilities.edit?.enabled??!1}}function Ht(e){let t=e.split(`
3
- `).map(e=>e.trim()).filter(Boolean);if(t.length===0)return;let n=t.map(e=>{let t=e.indexOf(`:`);if(t<=0||!e.slice(t+1).trim())throw Error(`invalid_headers`);return[e.slice(0,t).trim(),e.slice(t+1).trim()]});return Object.fromEntries(n)}function Ut({open:e,onOpenChange:t,provider:n,configured:r,language:i,onSaved:a}){let o=zt[i],[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(``),[d,p]=(0,Q.useState)(``),[m,y]=(0,Q.useState)(`bearer`),[b,x]=(0,Q.useState)(`x-api-key`),[S,C]=(0,Q.useState)(``),[w,M]=(0,Q.useState)(``),[P,ee]=(0,Q.useState)(``),[F,R]=(0,Q.useState)(`/images/generations`),[z,B]=(0,Q.useState)(`/images/edits`),[V,H]=(0,Q.useState)(``),[U,te]=(0,Q.useState)(``),[G,K]=(0,Q.useState)([Vt()]),[ne,re]=(0,Q.useState)(``),[q,J]=(0,Q.useState)(),[ie,Y]=(0,Q.useState)(!1),[ae,X]=(0,Q.useState)(),[oe,Z]=(0,Q.useState)(),[se,ce]=(0,Q.useState)();(0,Q.useEffect)(()=>{if(!e)return;let t=n?.imageGeneration;c(n?.providerId??``),u(t?.name??``),p(n?.baseUrl??``),y(t?.auth.type??`bearer`),x(t?.auth.type===`header`?t.auth.headerName:`x-api-key`),C(r?`••••••••••••`:``),M(t?.apiKeyUrl??``),ee(t?.documentationUrl??``),R(t?.paths?.generations??`/images/generations`),B(t?.paths?.edits??`/images/edits`),H(t?.network?.allowedHosts.join(`
4
- `)??``),te(Object.entries(n?.headers??{}).map(([e,t])=>`${e}: ${t}`).join(`
5
- `)),K(t?.models.map(Vt)??[Vt()]),re(t?.defaultModel??``),Z(void 0),J(void 0),Y(!1),X(void 0),ce(void 0)},[r,e,n]);let le=(0,Q.useMemo)(()=>G.filter(e=>e.id.trim()).map(e=>({value:e.id.trim(),label:e.name.trim()||e.id.trim()})),[G]),ue=(e,t)=>{K(n=>n.map((n,r)=>r===e?{...n,...t}:n))},de=()=>{let e=s.trim(),t=G.map(e=>({...e,id:e.id.trim(),name:e.name.trim()}));if(!e||!l.trim()||!d.trim()||t.some(e=>!e.id))throw Error(o.required);if(new Set(t.map(e=>e.id)).size!==t.length)throw Error(o.duplicateModels);let n=ne||t[0]?.id;if(!n||!t.some(e=>e.id===n))throw Error(o.required);let r;try{r=Ht(U)}catch{throw Error(o.invalidHeaders)}return{providerId:e,input:{baseUrl:d.trim(),...r?{headers:r}:{},imageGeneration:{api:`openai-images`,name:l.trim(),...P.trim()?{documentationUrl:P.trim()}:{},...w.trim()?{apiKeyUrl:w.trim()}:{},defaultModel:n,auth:m===`header`?{type:`header`,headerName:b.trim()}:{type:m},paths:{...F.trim()?{generations:F.trim()}:{},...z.trim()?{edits:z.trim()}:{}},...V.trim()?{network:{allowedHosts:V.split(`
6
- `).map(e=>e.trim()).filter(Boolean)}}:{},models:t.map(e=>({...e.original,id:e.id,...e.name?{name:e.name}:{name:void 0},capabilities:{...e.original.capabilities,generate:{...e.original.capabilities.generate,maxCount:Math.max(1,Number.parseInt(e.maxCount,10)||1),supportsSize:e.supportsSize},edit:{...e.original.capabilities.edit,enabled:e.editEnabled}},defaults:{...e.original.defaults,...e.defaultCount?{count:Math.max(1,Number.parseInt(e.defaultCount,10)||1)}:{count:void 0},...e.defaultSize.trim()?{size:e.defaultSize.trim()}:{size:void 0},...e.outputFormat?{outputFormat:e.outputFormat}:{outputFormat:void 0}}}))}}}},fe=async()=>{let e=de();return await Nt(e.providerId,e.input),m!==`none`&&S.trim()&&!it(S)&&await Mt(e.providerId,S.trim()),await a(e.providerId),e},pe=async()=>{J(`save`),X(void 0),Z(void 0);try{await fe(),C(m===`none`?``:`••••••••••••`),Z(o.saved)}catch(e){X(e instanceof Error?e.message:String(e))}finally{J(void 0)}},me=async()=>{J(`test`),X(void 0),Z(void 0),ce(void 0);try{let e=await fe();ce((await Ft(e.providerId,e.input.imageGeneration.defaultModel)).images[0]?.dataUrl),Z(o.testReady)}catch(e){X(e instanceof Error?e.message:String(e))}finally{J(void 0)}},he=async()=>{if(n){if(!ie){Y(!0);return}J(`delete`),X(void 0);try{await Lt(n.providerId),await a(),t(!1)}catch(e){X(e instanceof Error?e.message:String(e))}finally{J(void 0)}}};return(0,$.jsx)(j,{open:e,onOpenChange:t,children:(0,$.jsxs)(O,{children:[(0,$.jsx)(T,{className:v(`xopc-dialog-overlay fixed inset-0 bg-scrim`,L)}),(0,$.jsxs)(k,{className:v(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(88vh,760px)] w-[min(calc(100%-2rem),52rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover`,I),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(A,{className:`font-semibold text-fg`,children:n?o.editTitle:o.addTitle}),(0,$.jsx)(E,{className:`mt-1 text-sm text-fg-muted`,children:o.intro})]}),(0,$.jsx)(D,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`rounded-md p-1 text-fg-muted hover:bg-surface-inset hover:text-fg`,"aria-label":o.cancel,children:(0,$.jsx)(_,{className:`size-5`})})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-6 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`section`,{className:`space-y-4`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:o.connection}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.providerId,(0,$.jsx)(`input`,{value:s,disabled:!!n,onChange:e=>c(e.target.value),placeholder:`my-image-service`,className:Bt}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:o.providerIdHint})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.name,(0,$.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),placeholder:`My Image Service`,className:Bt})]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[o.baseUrl,(0,$.jsx)(`input`,{value:d,onChange:e=>p(e.target.value),placeholder:`https://api.example.com/v1`,className:Bt})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.auth,(0,$.jsx)(f,{value:m,options:[{value:`bearer`,label:o.bearer},{value:`header`,label:o.header},{value:`none`,label:o.none}],placeholder:o.auth,allowEmpty:!1,onChange:e=>y(e),triggerClassName:`mt-1.5`})]}),m===`header`?(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.headerName,(0,$.jsx)(`input`,{value:b,onChange:e=>x(e.target.value),className:Bt})]}):null]}),m===`none`?null:(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-image-api-key`,className:`text-xs font-medium text-fg-muted`,children:o.apiKey}),w.trim()?(0,$.jsxs)(`a`,{href:w.trim(),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[o.openKeyPage,(0,$.jsx)(Ge,{className:`size-3.5`})]}):null]}),(0,$.jsx)(ve,{id:`custom-image-api-key`,value:S,onChange:e=>C(it(S)?e.replace(/^•+/,``):e),labels:{show:o.show,hide:o.hide,copy:o.copy,copied:o.copied},reveal:()=>W(s).then(e=>e.apiKey),loadFailedLabel:o.revealFailed,notInConfigFile:o.notRevealable}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:o.apiKeyHint})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.apiKeyUrl,(0,$.jsx)(`input`,{value:w,onChange:e=>M(e.target.value),placeholder:`https://…`,className:Bt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.docsUrl,(0,$.jsx)(`input`,{value:P,onChange:e=>ee(e.target.value),placeholder:`https://…`,className:Bt})]})]}),(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2.5`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:o.paths}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.generationsPath,(0,$.jsx)(`input`,{value:F,onChange:e=>R(e.target.value),className:Bt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.editsPath,(0,$.jsx)(`input`,{value:z,onChange:e=>B(e.target.value),className:Bt})]})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[o.allowedHosts,(0,$.jsx)(`textarea`,{value:V,onChange:e=>H(e.target.value),rows:2,placeholder:`127.0.0.1
7
- image-server.lan`,className:`mt-1.5 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-xs text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:o.allowedHostsHint})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[o.staticHeaders,(0,$.jsx)(`textarea`,{value:U,onChange:e=>te(e.target.value),rows:3,className:`mt-1.5 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-xs text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:o.staticHeadersHint})]})]})]}),(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:o.models}),(0,$.jsxs)(N,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:()=>K(e=>[...e,Vt()]),children:[(0,$.jsx)(g,{className:`size-4`}),o.addModel]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[o.defaultModel,(0,$.jsx)(f,{value:ne||le[0]?.value||``,options:le,placeholder:o.defaultModel,allowEmpty:!1,onChange:re,triggerClassName:`mt-1.5 max-w-sm`})]}),G.map((e,t)=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.modelId,(0,$.jsx)(`input`,{value:e.id,onChange:e=>ue(t,{id:e.target.value}),placeholder:`image-1`,className:Bt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.modelName,(0,$.jsx)(`input`,{value:e.name,onChange:e=>ue(t,{name:e.target.value}),className:Bt})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.maxCount,(0,$.jsx)(`input`,{type:`number`,min:1,value:e.maxCount,onChange:e=>ue(t,{maxCount:e.target.value}),className:Bt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.defaultCount,(0,$.jsx)(`input`,{type:`number`,min:1,value:e.defaultCount,onChange:e=>ue(t,{defaultCount:e.target.value}),className:Bt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.defaultSize,(0,$.jsx)(`input`,{value:e.defaultSize,onChange:e=>ue(t,{defaultSize:e.target.value}),placeholder:`1024x1024`,className:Bt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.format,(0,$.jsx)(f,{value:e.outputFormat,options:[{value:`png`,label:`PNG`},{value:`jpeg`,label:`JPEG`},{value:`webp`,label:`WebP`}],placeholder:o.format,allowEmpty:!0,onChange:e=>ue(t,{outputFormat:e}),triggerClassName:`mt-1.5`})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-4`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.supportsSize,onChange:e=>ue(t,{supportsSize:e.target.checked})}),o.supportsSize]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.editEnabled,onChange:e=>ue(t,{editEnabled:e.target.checked})}),o.edit]}),(0,$.jsxs)(`button`,{type:`button`,disabled:G.length===1,onClick:()=>K(e=>e.filter((e,n)=>n!==t)),className:`ml-auto inline-flex items-center gap-1 text-xs text-red-600 disabled:opacity-40 dark:text-red-400`,children:[(0,$.jsx)(Be,{className:`size-3.5`}),o.remove]})]})]},t))]}),se?(0,$.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(Me,{className:`size-4`}),o.testReady]}),(0,$.jsx)(`img`,{src:se,alt:`Generated provider test`,className:`max-h-72 rounded-lg object-contain`})]}):null,oe?(0,$.jsx)(`p`,{className:`rounded-lg bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300`,role:`status`,children:oe}):null,ae?(0,$.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:ae}):null]}),(0,$.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-edge px-5 py-3`,children:[n?(0,$.jsxs)(N,{variant:`secondary`,className:`border-red-500/30 text-red-600 hover:bg-red-500/10 dark:text-red-400`,disabled:!!q,onClick:()=>void he(),children:[q===`delete`?(0,$.jsx)(h,{className:`size-4 animate-spin`}):(0,$.jsx)(Be,{className:`size-4`}),ie?o.confirmDelete:o.delete]}):null,(0,$.jsxs)(`div`,{className:`ml-auto flex gap-2`,children:[(0,$.jsx)(D,{asChild:!0,children:(0,$.jsx)(N,{variant:`secondary`,children:o.cancel})}),(0,$.jsxs)(N,{variant:`secondary`,disabled:!!q,onClick:()=>void me(),children:[q===`test`?(0,$.jsx)(h,{className:`size-4 animate-spin`}):null,q===`test`?o.testing:o.test]}),(0,$.jsxs)(N,{variant:`primary`,disabled:!!q,onClick:()=>void pe(),children:[q===`save`?(0,$.jsx)(h,{className:`size-4 animate-spin`}):null,q===`save`?o.saving:o.save]})]})]})]})]})})}var Wt=`••••••••••••`,Gt={en:{title:`Image generation`,intro:`Configure the default image model and service. Agents inherit this setting unless overridden in Agent settings.`,provider:`Provider`,model:`Model`,apiKey:`API key`,getApiKey:`Get API key`,apiKeyHint:`Stored in the local credential store, never in xopc.json.`,existingKey:`A credential or environment variable is already available. Leave this blank to reuse it.`,savedKey:`A credential is saved. Use the eye button to view it, or type a new key to replace it.`,revealFailed:`Unable to load the saved API key.`,keyNotRevealable:`This credential comes from an environment variable or another non-revealable source.`,advanced:`Provider settings`,enable:`Enable image generation`,enabling:`Verifying and enabling…`,enabled:`Image generation is ready.`,addService:`Add image service`,manageService:`Manage service`,custom:`Custom`,current:`Current`,configured:`Credential ready`,needsKey:`API key required`,connect:`Connect to a gateway to continue.`,loadError:`Unable to load image generation settings.`,selectModel:`Select a model`,show:`Show key`,hide:`Hide key`,copy:`Copy key`,copied:`Copied`},zh:{title:`图片生成`,intro:`配置全局图片生成模型和服务。各智能体默认继承此设置,也可在智能体详情中单独覆盖。`,provider:`Provider`,model:`模型`,apiKey:`API Key`,getApiKey:`获取 API Key`,apiKeyHint:`密钥只保存在本机凭据存储中,不会写入 xopc.json。`,existingKey:`已有凭据或环境变量;留空即可继续使用。`,savedKey:`凭据已保存。点击眼睛可查看,直接输入新密钥可替换。`,revealFailed:`无法读取已保存的 API Key。`,keyNotRevealable:`当前凭据来自环境变量或其他不可查看的来源。`,advanced:`服务商设置`,enable:`启用图片生成`,enabling:`正在验证并启用…`,enabled:`图片生成已可用。`,addService:`添加图片服务`,manageService:`管理服务`,custom:`自定义`,current:`当前使用`,configured:`凭据已就绪`,needsKey:`需要 API Key`,connect:`请先连接网关。`,loadError:`无法加载图片生成设置。`,selectModel:`选择模型`,show:`显示密钥`,hide:`隐藏密钥`,copy:`复制密钥`,copied:`已复制`}};async function Kt(){let e=await y(C(`/api/image-generation/default`));if(!e.payload)throw Error(`Invalid default image generation response`);return e.payload}function qt(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(0,t):void 0}function Jt(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(t+1):void 0}function Yt(e){return Object.fromEntries(e.configFields.map(t=>[t.key,e.config[t.key]??(t.required?t.options?.[0]?.value??``:``)]))}function Xt(e){let t=(0,Rt.c)(11),{field:n,value:r,onChange:i}=e,a;t[0]!==n.label||t[1]!==n.options||t[2]!==n.placeholder||t[3]!==n.required||t[4]!==n.type||t[5]!==i||t[6]!==r?(a=n.type===`select`?(0,$.jsx)(f,{value:r,options:(n.options??[]).map(Zt),placeholder:n.placeholder??n.label,allowEmpty:!n.required,onChange:i,triggerClassName:`mt-1.5`}):(0,$.jsx)(`input`,{type:`url`,value:r,required:n.required,onChange:e=>i(e.target.value),placeholder:n.placeholder,className:`mt-1.5 h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),t[0]=n.label,t[1]=n.options,t[2]=n.placeholder,t[3]=n.required,t[4]=n.type,t[5]=i,t[6]=r,t[7]=a):a=t[7];let o;return t[8]!==n.label||t[9]!==a?(o=(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[n.label,a]}),t[8]=n.label,t[9]=a,t[10]=o):o=t[10],o}function Zt(e){return{value:e.value,label:e.label}}function Qt(){let e=(0,Rt.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(F,{className:`h-24 rounded-xl`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`grid gap-4`,"aria-hidden":`true`,children:[t,(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:Array.from({length:5}).map($t)}),(0,$.jsx)(F,{className:`h-64 rounded-xl`})]}),e[1]=n):n=e[1],n}function $t(e,t){return(0,$.jsx)(F,{className:`h-24 rounded-xl`},t)}function en(){let e=S(e=>e.language),t=Gt[e],n=!!b(e=>e.conversationId),[r,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)({}),[m,_]=(0,Q.useState)(!1),[v,x]=(0,Q.useState)(),[w,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(),{data:A,isLoading:j,error:ee,mutate:F}=M(n?C(`/api/image-generation/catalog`):null,It,{revalidateOnFocus:!1}),{data:I,isLoading:L,error:R,mutate:z}=M(n?C(`/api/image-generation/custom-providers`):null,Pt,{revalidateOnFocus:!1}),{data:V,isLoading:H,error:U,mutate:te}=M(n?`default-image-generation`:null,Kt,{revalidateOnFocus:!1});(0,Q.useEffect)(()=>{if(!A||!V)return;let e=qt(V.model?.primary),t=A.find(t=>t.id===e)??A.find(e=>e.configured)??A[0];t&&(a(t.id),s(t.id===e&&Jt(V.model?.primary)||t.defaultModel),l(t.configured?Wt:``),d(Yt(t)))},[V,A]);let G=A?.find(e=>e.id===r),K=G?G.apiKeyUrl??Se(G.id,e)[0]?.href:void 0,ne=(0,Q.useMemo)(()=>(G?.models??[]).map(e=>({value:e,label:e})),[G?.models]),re=V?.model?.primary,q=!!(G&&o&&(G.credentialMode!==`api-key`||G.configured||c.trim())&&G.configFields.every(e=>!e.required||u[e.key]?.trim()));if(!n)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.connect});if(j||L||H)return(0,$.jsx)(Qt,{});if(ee||R||U||!A||!I)return(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:t.loadError});let J=e=>{a(e.id),s(e.defaultModel),l(e.configured?Wt:``),d(Yt(e)),x(void 0)},ie=()=>{k(void 0),D(!0)},Y=()=>{let e=I.find(e=>e.providerId===G?.id);e&&(k(e),D(!0))},ae=async e=>{let[t,n]=await Promise.all([z(),F()]);if(e&&n?.some(t=>t.id===e)){let r=n.find(t=>t.id===e);a(r.id),s(r.defaultModel),l(r.configured?Wt:``),d(Yt(r)),k(t?.find(t=>t.providerId===e))}},X=async()=>{if(!(!G||!q)){_(!0),x(void 0),T(!1);try{let e=await y(C(`/api/image-generation/default/setup`),{method:`POST`,body:JSON.stringify({providerId:G.id,modelId:o,...c.trim()&&!it(c)?{apiKey:c.trim()}:{},providerConfig:Object.fromEntries(Object.entries(u).filter(([,e])=>e.trim()))})});if(!e.payload)throw Error(`Invalid setup response`);await Promise.all([te(e.payload.default,{revalidate:!1}),F(e.payload.providers,{revalidate:!1}),i(async()=>{let{mutate:e}=await import(`./vendor-swr-BIWyz7Rc.js`).then(e=>e.r);return{mutate:e}},__vite__mapDeps([0,1,2])).then(({mutate:e})=>Promise.all([e(`settings-agent-defaults`),e(`settings-gateway-agents`)])),P()]),l(Wt),T(!0)}catch(e){x(e instanceof Error?e.message:String(e))}finally{_(!1)}}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(`div`,{className:`rounded-lg bg-accent/10 p-2 text-accent`,children:(0,$.jsx)(Z,{className:`size-5`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:t.intro})]})]})}),(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:t.provider}),(0,$.jsxs)(N,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:ie,children:[(0,$.jsx)(g,{className:`size-4`}),t.addService]})]}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:A.map(e=>{let n=e.id===r,i=e.id===qt(re);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>J(e),className:`min-h-24 rounded-xl p-4 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${n?`bg-accent-soft shadow-surface`:`bg-surface-base/55 hover:bg-surface-hover`}`,children:[(0,$.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.label}),e.source===`custom`?(0,$.jsx)(`span`,{className:`rounded-full bg-surface-inset px-2 py-0.5 text-[10px] text-fg-subtle`,children:t.custom}):null]}),(0,$.jsx)(`span`,{"aria-hidden":!i,className:`shrink-0 rounded-full bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent ${i?``:`invisible`}`,children:t.current})]}),(0,$.jsxs)(`span`,{className:`mt-2 flex items-center gap-1.5 text-xs ${e.configured?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`}`,children:[e.configured||e.credentialMode!==`api-key`?(0,$.jsx)(p,{className:`size-3.5`}):(0,$.jsx)(B,{className:`size-3.5`}),e.configured||e.credentialMode!==`api-key`?t.configured:t.needsKey]})]},e.id)})})]}),G?(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[t.model,(0,$.jsx)(f,{value:o,options:ne,placeholder:t.selectModel,allowEmpty:!1,onChange:s,triggerClassName:`mt-1.5`})]}),G.configFields.filter(e=>e.required).map(e=>(0,$.jsx)(Xt,{field:e,value:u[e.key]??``,onChange:t=>d(n=>({...n,[e.key]:t}))},e.key))]}),G.source===`custom`?(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(N,{variant:`secondary`,onClick:Y,children:[(0,$.jsx)(tt,{className:`size-4`}),t.manageService]})}):null,G.credentialMode===`api-key`?(0,$.jsxs)(`div`,{className:`mt-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`label`,{htmlFor:`image-generation-api-key`,className:`text-xs font-medium text-fg-muted`,children:t.apiKey}),K?(0,$.jsxs)(`a`,{href:K,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,children:[t.getApiKey,(0,$.jsx)(Ge,{className:`size-3.5`,"aria-hidden":`true`})]}):null]}),(0,$.jsx)(ve,{id:`image-generation-api-key`,value:c,onChange:e=>l(it(c)?e.replace(/^•+/,``):e),placeholder:G.configured?t.existingKey:t.needsKey,labels:{show:t.show,hide:t.hide,copy:t.copy,copied:t.copied},reveal:()=>W(G.id).then(e=>e.apiKey),loadFailedLabel:t.revealFailed,notInConfigFile:t.keyNotRevealable,className:`mt-1.5`,autoComplete:`new-password`},G.id),(0,$.jsx)(`span`,{className:`mt-1.5 block font-normal leading-relaxed text-fg-subtle`,children:G.configured?t.savedKey:t.apiKeyHint})]}):null,G.configFields.some(e=>!e.required)?(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-base/55 px-3 py-2.5`,children:[(0,$.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 text-sm font-medium text-fg-muted`,children:[(0,$.jsx)(Qe,{className:`size-4`}),t.advanced]}),(0,$.jsx)(`div`,{className:`mt-3 grid gap-3 md:grid-cols-2`,children:G.configFields.filter(e=>!e.required).map(e=>(0,$.jsx)(Xt,{field:e,value:u[e.key]??``,onChange:t=>d(n=>({...n,[e.key]:t}))},e.key))})]}):null,w?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300`,role:`status`,children:t.enabled}):null,v?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:v}):null,(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(N,{variant:`primary`,disabled:!q||m,onClick:()=>void X(),children:[m?(0,$.jsx)(h,{className:`size-4 animate-spin`}):(0,$.jsx)(p,{className:`size-4`}),(0,$.jsxs)(`span`,{className:`grid`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1`,children:t.enable}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1`,children:t.enabling}),(0,$.jsx)(`span`,{className:`col-start-1 row-start-1`,children:m?t.enabling:t.enable})]})]})})]}):null,(0,$.jsx)(Ut,{open:E,onOpenChange:D,provider:O,configured:!!(O&&A.find(e=>e.id===O.providerId)?.configured),language:e,onSaved:ae})]})}function tn({disabled:e=!1}){let t=S(e=>e.language)===`zh`,[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(``),{data:o,mutate:s,error:c}=M(C(`/api/voice/catalog`),async e=>{let t=await y(e);return re.parse(t.payload)}),l=t?{transcription:`录音转文字`,"transcription.stream":`实时听写 / 语音助手输入`,speech:`消息朗读`,"speech.stream":`语音助手输出`,conversation:`自然语音对话`}:{transcription:`Recorded transcription`,"transcription.stream":`Live dictation / assistant input`,speech:`Message readout`,"speech.stream":`Assistant speech`,conversation:`Natural conversation`},f=async e=>{if(o){r(!0),a(``);try{let t=await y(C(e?`/api/voice/selection`:`/api/voice/catalog/refresh`),{method:e?`PUT`:`POST`,...e?{body:JSON.stringify({revision:o.revision,selection:e})}:{}});await s(re.parse(t.payload),!1),await P()}catch(e){a(e instanceof Error?e.message:String(e)),await s()}finally{r(!1)}}};return(0,$.jsxs)(`section`,{className:`space-y-4 rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h3`,{className:`font-medium`,children:t?`XOPC 托管语音模型`:`XOPC managed voice models`}),(0,$.jsx)(N,{variant:`secondary`,disabled:n||e||!o,onClick:()=>void f(),children:t?`刷新目录`:`Refresh catalog`})]}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`各设备共用此 Gateway 的模型设置,修改在下次调用生效。仅显示支持对应场景的已发布模型。`:`Devices share this gateway’s selections. Changes apply to the next call. Only published models supporting each mode are shown.`}),i||c?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:i||String(c)}):null,o?Object.keys(l).map(r=>{let i=o.selections.find(e=>e.mode===r),a=o.models.filter(e=>e.voice.modes.includes(r)),s=a.find(e=>e.id===i?.model);return(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:l[r]}),(0,$.jsxs)(u,{className:`w-full`,value:i?.model??``,disabled:n||e||!a.length,onChange:e=>void f({mode:r,model:e.target.value}),children:[(0,$.jsx)(d,{value:``,disabled:!0,children:t?`选择模型`:`Choose model`}),i&&!s?(0,$.jsxs)(d,{value:i.model,disabled:!0,children:[i.model,` · `,t?`不可用`:`Unavailable`]}):null,a.map(e=>(0,$.jsx)(d,{value:e.id,children:e.name},e.id))]}),a.length?null:(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t?`暂无可用模型`:`No available model`})]}),s&&s.voice.voices.length>0?(0,$.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:t?`音色`:`Voice`}),(0,$.jsx)(u,{className:`w-full`,value:i?.voice??``,disabled:n||e,onChange:e=>void f({mode:r,model:s.id,voice:e.target.value}),children:s.voice.voices.map(e=>(0,$.jsx)(d,{value:e.id,children:e.name},e.id))})]}):null]},r)}):(0,$.jsx)(F,{className:`h-48 w-full`})]})}function nn({v:e}){let t=ie(e=>e.microphoneId),n=ie(e=>e.setMicrophoneId),[r,i]=(0,Q.useState)([]),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(!1),l=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{l.current=!0;let e=()=>{navigator.mediaDevices?.enumerateDevices().then(e=>{l.current&&i(e.filter(e=>e.kind===`audioinput`))}).catch(()=>{})};return e(),navigator.mediaDevices?.addEventListener(`devicechange`,e),()=>{l.current=!1,navigator.mediaDevices?.removeEventListener(`devicechange`,e)}},[]);let f=async()=>{c(!0),o(``);try{(await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(e=>e.stop());let e=await navigator.mediaDevices.enumerateDevices();l.current&&i(e.filter(e=>e.kind===`audioinput`))}catch(e){l.current&&o(e instanceof Error?e.message:String(e))}finally{l.current&&c(!1)}};return(0,$.jsxs)(`section`,{className:`space-y-4 rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:e.experience.microphone}),(0,$.jsxs)(u,{value:t,onChange:e=>n(e.target.value),children:[(0,$.jsx)(d,{value:``,children:e.experience.systemDevice}),t&&!r.some(e=>e.deviceId===t)?(0,$.jsx)(d,{value:t,children:e.experience.unavailable}):null,r.filter(e=>e.deviceId&&e.deviceId!=="default").map((t,n)=>(0,$.jsx)(d,{value:t.deviceId,children:t.label||`${e.experience.microphone} ${n+1}`},t.deviceId))]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.experience.deviceHint}),(0,$.jsx)(N,{variant:`secondary`,disabled:s,onClick:()=>void f(),children:e.experience.refreshDevices}),a?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:a}):null]})}function rn({v:e,canListen:t,canSpeak:n,disabled:r,onVerified:i}){let a=e.setup,o=(0,Q.useContext)(Pe)?.active??!1,[s,c]=(0,Q.useState)(`idle`),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),p=(0,Q.useRef)(`idle`),m=(0,Q.useRef)(null),g=(0,Q.useRef)(!1),_=e=>{p.current=e,c(e)},v=()=>{m.current?.(),m.current=null};(0,Q.useEffect)(()=>()=>m.current?.(),[]);async function y(e){v(),i?.({input:!1,output:!1}),g.current=!1,u(``),f(``),_(e?`connecting`:`playing`);let t=new AbortController,r,o,s,c,l=()=>{o?.cancel(),r?.getTracks().forEach(e=>e.stop()),s?.stop(`surface_closed`)},d=window.setTimeout(()=>h(a.timeout),6e4);m.current=()=>{t.abort(),window.clearTimeout(d),l(),c?.close()};function h(e){t.signal.aborted||(_(`error`),f(e),v())}async function y(){_(`playing`),l();try{let e=await yt(t.signal);if(t.signal.aborted)return;c?.enqueue(e,()=>{t.signal.aborted||(window.clearTimeout(d),_(`confirm`))})}catch(e){h(e instanceof Error?e.message:a.testFailed)}}try{if(n&&(c=new X,await c.start(),t.signal.throwIfAborted()),!e){await y();return}let d=window.electronAPI?.system;if(d){let e=await d.requestMicrophone();if(t.signal.throwIfAborted(),e.status===`denied`)throw Error(a.microphoneDenied)}if(r=await navigator.mediaDevices.getUserMedia({audio:le()}),t.signal.aborted){l();return}if(s=await se.connect({purpose:`dictation`,signal:t.signal,onEvent:e=>{t.signal.aborted||(e.type===`session.error`&&h(a.testFailed),p.current===`listening`&&(e.type===`input.transcript.delta`&&u(e.payload.text),e.type===`input.transcript.final`&&e.payload.text.trim()&&(u(e.payload.text.trim()),g.current=!0,n?y():(_(`passed`),i?.({input:!0,output:!1}),v()))))},onClose:()=>{(p.current===`listening`||p.current===`connecting`)&&h(a.testFailed)}}),t.signal.aborted){l();return}let f;if(o=await Ne.start(r,{onSamples:e=>{f&&!t.signal.aborted&&s?.sendAudio(f.push(e))}}),t.signal.aborted){l();return}f=new ae(o.sampleRate,s.session.inputFormat.sampleRate),_(`listening`)}catch(e){if(t.signal.aborted){l();return}h(e instanceof Error?e.message:a.testFailed)}}let b=s===`connecting`||s===`listening`||s===`playing`;return(0,$.jsxs)(`div`,{className:`space-y-3 rounded-xl bg-surface-base/45 p-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(N,{type:`button`,variant:`primary`,disabled:o||r||!t||b,onClick:()=>void y(!0),children:[b?(0,$.jsx)(h,{className:`size-4 animate-spin`}):(0,$.jsx)(Ae,{className:`size-4`}),n?a.test:a.testInput]}),(0,$.jsxs)(N,{type:`button`,variant:`secondary`,disabled:o||r||!n||b,onClick:()=>void y(!1),children:[(0,$.jsx)(U,{className:`size-4`}),e.tts.test.play]}),b?(0,$.jsxs)(N,{type:`button`,variant:`ghost`,onClick:()=>{v(),_(`idle`)},children:[(0,$.jsx)(we,{className:`size-4`}),e.tts.test.stop]}):null]}),(0,$.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`space-y-2 text-xs text-fg-muted`,children:[s===`idle`?(0,$.jsx)(`p`,{children:o?e.experience.endCallBeforeTest:r?a.saveBeforeTest:a.microphoneHint}):null,s===`connecting`?(0,$.jsx)(`p`,{children:a.connecting}):null,s===`listening`?(0,$.jsx)(`p`,{children:a.speakNow}):null,l?(0,$.jsx)(`p`,{className:`rounded-lg bg-surface-base p-3 text-sm text-fg`,children:l}):null,s===`playing`?(0,$.jsx)(`p`,{children:a.playing}):null,s===`confirm`?(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{children:a.heardQuestion}),(0,$.jsx)(N,{type:`button`,variant:`secondary`,onClick:()=>{v(),i?.({input:g.current,output:!0}),_(`passed`)},children:a.heard}),(0,$.jsx)(N,{type:`button`,variant:`ghost`,onClick:()=>{v(),_(`error`),f(a.notHeard)},children:a.notHeardButton})]}):null,s===`passed`?(0,$.jsx)(`p`,{children:g.current?n?a.passed:a.inputPassed:a.outputPassed}):null,s===`error`?(0,$.jsx)(`p`,{role:`alert`,className:`text-red-600 dark:text-red-400`,children:d}):null]})]})}function an(e,t){return{...e,stt:{...e.stt,enabled:!0,provider:t},voice:{...e.voice,realtime:{...e.voice.realtime,enabled:!0,tts:e.voice.realtime.tts?.provider===t?e.voice.realtime.tts:{provider:t,...t===`alibaba`?{voice:`Cherry`}:{}},omni:e.voice.realtime.omni?.provider===t?e.voice.realtime.omni:t===`xopc-cloud`?void 0:{provider:t,model:`qwen3-omni-flash-realtime`,voice:e.voice.realtime.omni?.voice??`Cherry`,instructions:e.voice.realtime.omni?.instructions??`Keep replies conversational and concise.`}}}}}function on(e){let t=(0,Rt.c)(117),{section:n,v:r,form:i,pending:a,apiKeyLabels:o,sttProviders:s,onChange:c}=e,f=r.setup,[p,m]=(0,Q.useState)(!1),h;t[0]===i?h=t[1]:(h=JSON.stringify(i),t[0]=i,t[1]=h);let g=h,_;t[2]===g?_=t[3]:(_={signature:g,input:!1,output:!1},t[2]=g,t[3]=_);let[v,y]=(0,Q.useState)(_);v.signature!==g&&y({signature:g,input:!1,output:!1});let b;t[4]!==a||t[5]!==g?(b=a?null:[`voice-realtime-status`,g],t[4]=a,t[5]=g,t[6]=b):b=t[6];let x;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(x={revalidateOnFocus:!0},t[7]=x):x=t[7];let{data:S,error:w,isLoading:T}=M(b,Et,x),E;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(E=C(`/api/voice/catalog`),t[8]=E):E=t[8];let{data:D}=M(E,dn),O=i.voice.realtime,k=i.stt.provider,A=O.tts,j=A?.provider??S?.tts?.provider,P=S?.tts?.model,ee;t[9]!==P||t[10]!==j?(ee=j&&P?[`realtime-voices`,j,P]:null,t[9]=P,t[10]=j,t[11]=ee):ee=t[11];let I;t[12]!==P||t[13]!==j?(I=()=>xt(j,P,`realtime`),t[12]=P,t[13]=j,t[14]=I):I=t[14];let L;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(L={revalidateOnFocus:!1},t[15]=L):L=t[15];let{data:R}=M(ee,I,L),z;t[16]===R?z=t[17]:(z=R===void 0?[]:R,t[16]=R,t[17]=z);let B=z,V;t[18]!==j||t[19]!==B?(V=j===`alibaba`?B.filter(un):B,t[18]=j,t[19]=B,t[20]=V):V=t[20];let H=V,U=typeof i.stt.providers?.alibaba?.apiKey==`string`?i.stt.providers.alibaba.apiKey:``,te;t[21]!==U||t[22]!==s?(te=!!U||s.some(ln),t[21]=U,t[22]=s,t[23]=te):te=t[23];let W=te,G=O.defaultEngine===`omni`,K=G?O.omni?.voice??``:A?.voice??S?.tts?.voice??``,ne;t[24]!==D?.models||t[25]!==G||t[26]!==O.omni?.model||t[27]!==O.omni?.provider||t[28]!==H?(ne=G?O.omni?.provider===`xopc-cloud`?D?.models.find(e=>e.id===O.omni?.model)?.voice.voices??[]:[`Cherry`,`Ethan`,`Serena`,`Chelsie`].map(cn):H,t[24]=D?.models,t[25]=G,t[26]=O.omni?.model,t[27]=O.omni?.provider,t[28]=H,t[29]=ne):ne=t[29];let re=ne,q=!!(S?.enabled&&S.stt),J=!!(S?.enabled&&S.tts),ie;t[30]!==i||t[31]!==c||t[32]!==O?(ie=e=>c({...i,voice:{...i.voice,realtime:{...O,...e}}}),t[30]=i,t[31]=c,t[32]=O,t[33]=ie):ie=t[33];let Y=ie,ae;t[34]!==i||t[35]!==c?(ae=e=>c(an(i,e)),t[34]=i,t[35]=c,t[36]=ae):ae=t[36];let X=ae,oe;t[37]!==a||t[38]!==O.enabled||t[39]!==f.disabled||t[40]!==f.needsSetup||t[41]!==f.pending||t[42]!==f.unverified||t[43]!==f.verified||t[44]!==g||t[45]!==v.signature?(oe=(e,t)=>O.enabled?a?f.pending:e?t&&v.signature===g?f.verified:f.unverified:f.needsSetup:f.disabled,t[37]=a,t[38]=O.enabled,t[39]=f.disabled,t[40]=f.needsSetup,t[41]=f.pending,t[42]=f.unverified,t[43]=f.verified,t[44]=g,t[45]=v.signature,t[46]=oe):oe=t[46];let Z=oe,se;t[47]!==o||t[48]!==X||t[49]!==p||t[50]!==w||t[51]!==i||t[52]!==U||t[53]!==W||t[54]!==c||t[55]!==a||t[56]!==k||t[57]!==O.defaultEngine||t[58]!==O.enabled||t[59]!==f.changeKey||t[60]!==f.configureConversation||t[61]!==f.customProvider||t[62]!==f.edgeHint||t[63]!==f.enable||t[64]!==f.finishSetup||t[65]!==f.hosted||t[66]!==f.hostedAccountHint||t[67]!==f.hostedHint||t[68]!==f.keyConfigured||t[69]!==f.keyHint||t[70]!==f.manageAccount||t[71]!==f.outputHint||t[72]!==f.ownKey||t[73]!==f.ownKeyHint||t[74]!==f.service||t[75]!==f.statusError||t[76]!==n||t[77]!==A||t[78]!==S?.tts||t[79]!==Y||t[80]!==r.experience||t[81]!==r.stt?(se=n===`service`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl bg-surface-base/45 p-3`,children:(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":O.enabled,className:`size-4 accent-accent`,checked:O.enabled,onChange:e=>{e.target.checked?X(k===`alibaba`?`alibaba`:`xopc-cloud`):Y({enabled:!1})}}),f.enable]})}),w?(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600 dark:text-red-400`,children:f.statusError}):null,(0,$.jsxs)(`fieldset`,{className:`space-y-3`,children:[(0,$.jsx)(`legend`,{className:`text-sm font-medium text-fg`,children:f.service}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[`xopc-cloud`,`alibaba`].map(e=>(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-lg bg-surface-base/55 px-3 py-3 text-sm text-fg has-checked:bg-accent-soft`,children:[(0,$.jsx)(`input`,{type:`radio`,name:`realtime-service`,value:e,checked:k===e,onChange:()=>X(e),className:`mt-1 accent-accent`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`block font-medium`,children:e===`xopc-cloud`?f.hosted:f.ownKey}),(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e===`xopc-cloud`?f.hostedHint:f.ownKeyHint})]})]},e))})]}),k!==`alibaba`&&k!==`xopc-cloud`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:f.customProvider.replace(`{provider}`,k)}):null,k===`alibaba`?(0,$.jsx)(`div`,{className:`space-y-2 text-xs`,children:W&&!p?(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:f.keyConfigured}),(0,$.jsx)(N,{type:`button`,variant:`ghost`,onClick:()=>m(!0),children:f.changeKey})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{htmlFor:`realtime-api-key`,className:`font-medium text-fg`,children:r.stt.apiKey}),(0,$.jsx)(kt,{kind:`stt`,providerId:`alibaba`,fieldId:`realtime-api-key`,value:U,labels:{...o,maskedHelp:``},onChange:e=>c({...i,stt:{...i.stt,providers:{...i.stt.providers,alibaba:{...i.stt.providers?.alibaba,apiKey:e}}}})}),(0,$.jsx)(`p`,{className:`text-fg-muted`,children:f.keyHint})]})}):null,k===`xopc-cloud`?(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[f.hostedAccountHint,` `,(0,$.jsx)(l,{className:`text-accent hover:underline`,to:`/settings/capabilities/models`,children:f.manageAccount})]}):null,!A&&!a&&!S?.tts&&(k===`alibaba`||k===`xopc-cloud`)?(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3 text-xs`,children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:f.finishSetup}),(0,$.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:i.tts.provider===`edge`?f.edgeHint:f.outputHint}),(0,$.jsx)(N,{className:`mt-2`,type:`button`,variant:`secondary`,onClick:()=>X(k),children:f.configureConversation})]}):null,(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:r.experience.defaultMode}),(0,$.jsxs)(u,{value:O.defaultEngine,className:de,onChange:e=>Y({defaultEngine:e.target.value}),children:[(0,$.jsx)(d,{value:`agent`,children:r.experience.assistant}),(0,$.jsx)(d,{value:`omni`,children:r.experience.natural})]})]}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[O.defaultEngine===`agent`?r.experience.assistantHint:r.experience.naturalHint,` `,r.experience.nextCall]})]}):null,t[47]=o,t[48]=X,t[49]=p,t[50]=w,t[51]=i,t[52]=U,t[53]=W,t[54]=c,t[55]=a,t[56]=k,t[57]=O.defaultEngine,t[58]=O.enabled,t[59]=f.changeKey,t[60]=f.configureConversation,t[61]=f.customProvider,t[62]=f.edgeHint,t[63]=f.enable,t[64]=f.finishSetup,t[65]=f.hosted,t[66]=f.hostedAccountHint,t[67]=f.hostedHint,t[68]=f.keyConfigured,t[69]=f.keyHint,t[70]=f.manageAccount,t[71]=f.outputHint,t[72]=f.ownKey,t[73]=f.ownKeyHint,t[74]=f.service,t[75]=f.statusError,t[76]=n,t[77]=A,t[78]=S?.tts,t[79]=Y,t[80]=r.experience,t[81]=r.stt,t[82]=se):se=t[82];let ce;t[83]!==K||t[84]!==G||t[85]!==j||t[86]!==O.bargeIn||t[87]!==O.omni||t[88]!==O.tts||t[89]!==f.bargeIn||t[90]!==f.defaultVoice||t[91]!==f.voice||t[92]!==n||t[93]!==A||t[94]!==S?.tts||t[95]!==Y||t[96]!==r.realtime||t[97]!==re?(ce=n===`listening`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,$.jsx)(`label`,{htmlFor:`realtime-voice`,className:`text-sm font-medium text-fg`,children:f.voice}),(0,$.jsxs)(u,{id:`realtime-voice`,className:`${de} w-full sm:w-56`,value:K,disabled:G?!O.omni:!A&&!S?.tts,onChange:e=>{if(G&&O.omni){Y({omni:{...O.omni,voice:e.target.value}});return}(j===`alibaba`||j===`xopc-cloud`)&&Y({tts:{...O.tts,provider:j,...e.target.value?{voice:e.target.value}:{}},...O.omni&&[`Cherry`,`Ethan`,`Serena`,`Chelsie`].includes(e.target.value)?{omni:{...O.omni,voice:e.target.value}}:{}})},children:[G?null:(0,$.jsx)(d,{value:``,children:f.defaultVoice}),K&&!re.some(e=>e.id===K)?(0,$.jsx)(d,{value:K,children:K}):null,re.map(sn)]})]}),(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-4 text-sm text-fg`,children:[(0,$.jsxs)(`span`,{children:[f.bargeIn,(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:r.realtime.bargeInDescription})]}),(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":O.bargeIn,checked:O.bargeIn,className:`size-4 accent-accent`,onChange:e=>Y({bargeIn:e.target.checked})})]})]}):null,t[83]=K,t[84]=G,t[85]=j,t[86]=O.bargeIn,t[87]=O.omni,t[88]=O.tts,t[89]=f.bargeIn,t[90]=f.defaultVoice,t[91]=f.voice,t[92]=n,t[93]=A,t[94]=S?.tts,t[95]=Y,t[96]=r.realtime,t[97]=re,t[98]=ce):ce=t[98];let le;t[99]!==q||t[100]!==J||t[101]!==w||t[102]!==T||t[103]!==a||t[104]!==n||t[105]!==g||t[106]!==S||t[107]!==Z||t[108]!==r||t[109]!==v.input||t[110]!==v.output?(le=n===`diagnostics`?(0,$.jsxs)($.Fragment,{children:[T?(0,$.jsx)(F,{className:`h-16 w-full`}):(0,$.jsxs)(`div`,{className:`space-y-2 text-sm`,role:`status`,children:[(0,$.jsxs)(`p`,{children:[r.experience.dictationReady,` · `,Z(q,v.input)]}),(0,$.jsxs)(`p`,{children:[r.experience.agentReady,` · `,Z(q&&J,v.input&&v.output)]}),(0,$.jsxs)(`p`,{children:[r.experience.omniReady,` · `,Z(!!(S?.enabled&&S.omni),!1)]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.experience.configurationOnly}),(0,$.jsx)(rn,{v:r,canListen:q,canSpeak:J,disabled:a||T||!!w,onVerified:e=>y({signature:g,...e})},`${g}:${JSON.stringify(S)}`)]}):null,t[99]=q,t[100]=J,t[101]=w,t[102]=T,t[103]=a,t[104]=n,t[105]=g,t[106]=S,t[107]=Z,t[108]=r,t[109]=v.input,t[110]=v.output,t[111]=le):le=t[111];let ue;return t[112]!==f.service||t[113]!==se||t[114]!==ce||t[115]!==le?(ue=(0,$.jsxs)(`section`,{className:`space-y-5 rounded-xl bg-surface-hover/20 p-4 sm:p-5`,"aria-label":f.service,children:[se,ce,le]}),t[112]=f.service,t[113]=se,t[114]=ce,t[115]=le,t[116]=ue):ue=t[116],ue}function sn(e){return(0,$.jsx)(d,{value:e.id,children:e.name},e.id)}function cn(e){return{id:e,name:e}}function ln(e){return e.id===`alibaba`&&e.configured}function un(e){return[`Cherry`,`Ethan`,`Serena`,`Chelsie`].includes(e.id)}async function dn(e){return re.parse((await y(e)).payload)}function fn(e){let t=(0,Rt.c)(22),{value:n,onChange:r}=e,i=S(mn)===`zh`,a;t[0]===i?a=t[1]:(a=(e,t)=>i?t:e,t[0]=i,t[1]=a);let o=a,s;t[2]!==r||t[3]!==n?(s=e=>{n&&r({...n,...e})},t[2]=r,t[3]=n,t[4]=s):s=t[4];let c=s,l;t[5]===o?l=t[6]:(l=o(`Natural conversation · advanced`,`自然对话 · 高级设置`),t[5]=o,t[6]=l);let f;t[7]===l?f=t[8]:(f=(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:l}),t[7]=l,t[8]=f);let p;t[9]===o?p=t[10]:(p=o(`Calls continue the same session using recent history. Service and credentials are shared with voice setup; override them here only when needed.`,`通话会接续同一会话的近期历史。默认共用语音服务与凭据,仅在需要独立配置时修改。`),t[9]=o,t[10]=p);let m;t[11]===p?m=t[12]:(m=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:p}),t[11]=p,t[12]=m);let h;t[13]!==o||t[14]!==r||t[15]!==c||t[16]!==n?(h=n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:o(`Connection`,`连接方式`)}),(0,$.jsx)(u,{value:n.provider,onChange:e=>r({model:n.model,voice:n.voice,instructions:n.instructions,provider:e.target.value}),children:(0,$.jsxs)(d,{value:`alibaba`,children:[`DashScope · `,o(`Your API key`,`自有 API Key`)]})})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.provider===`xopc-cloud`?o(`Uses your XOPC sign-in and the platform’s published Omni route and credits.`,`使用 XOPC 登录授权、平台发布的 Omni 路由和额度。`):o(`Leave empty to use the shared voice service credential.`,`留空使用语音服务中已配置的凭据。`)}),(0,$.jsx)(`p`,{className:`font-mono text-xs text-fg-muted`,children:n.model}),n.provider===`alibaba`?(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:`API Key`}),(0,$.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,type:`password`,autoComplete:`new-password`,value:n.apiKey??``,onChange:e=>c({apiKey:e.target.value})})]}):null,(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:o(`Endpoint override (optional)`,`自定义服务地址(可选)`)}),(0,$.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,value:n.baseUrl??``,placeholder:n.provider===`alibaba`?`wss://dashscope.aliyuncs.com/api-ws/v1/realtime`:`https://router.xopc.ai/v1`,onChange:e=>c({baseUrl:e.target.value.trim()||void 0})})]}),(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:o(`Voice`,`音色`)}),(0,$.jsx)(u,{value:n.voice,onChange:e=>c({voice:e.target.value}),children:[`Cherry`,`Ethan`,`Serena`,`Chelsie`].map(pn)})]}),(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:o(`Conversation instructions`,`聊天指令`)}),(0,$.jsx)(`textarea`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,rows:3,maxLength:8e3,value:n.instructions,onChange:e=>c({instructions:e.target.value})})]})]}):(0,$.jsx)(N,{variant:`secondary`,onClick:()=>r({provider:`alibaba`,model:`qwen3-omni-flash-realtime`,voice:`Cherry`,instructions:`You are a friendly voice companion. You cannot execute tools.`}),children:o(`Configure natural conversation`,`配置自然聊天`)}),t[13]=o,t[14]=r,t[15]=c,t[16]=n,t[17]=h):h=t[17];let g;return t[18]!==f||t[19]!==m||t[20]!==h?(g=(0,$.jsxs)(`details`,{className:`space-y-3 rounded-xl bg-surface-hover/20 p-4`,children:[f,m,h]}),t[18]=f,t[19]=m,t[20]=h,t[21]=g):g=t[21],g}function pn(e){return(0,$.jsx)(d,{value:e,children:e},e)}function mn(e){return e.language}var hn=nt;function gn(){return v(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,K,`dark:border-edge`)}function _n(){return v(de,nt)}function vn(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function yn(e,t){let n=window.atob(e),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return URL.createObjectURL(new Blob([r],{type:t}))}function bn(e,t){switch(e){case`xopc-local`:return t.stt.localProvider;case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function xn(e,t){switch(e){case`openai`:return t.tts.providerOpenai;case`alibaba`:return t.stt.alibaba;case`edge`:return t.tts.providerEdge;case`tts-local-cli`:return t.tts.providerLocalCli;case`minimax`:return`MiniMax`;default:return e}}function Sn(e,t){switch(e){case`off`:return t.tts.triggerOff;case`always`:return t.tts.triggerAlways;case`inbound`:return t.tts.triggerInbound;case`tagged`:return t.tts.triggerTagged}}function Cn(e,t){switch(e){case`edge`:return t.tts.providerHints.edge;case`openai`:return t.tts.providerHints.openai;case`alibaba`:return t.tts.providerHints.alibaba;case`minimax`:return t.tts.providerHints.minimax;case`tts-local-cli`:return t.tts.providerHints.localCli;default:return t.tts.providerHints.generic}}function wn(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function Tn(e,t){let n=e[t.key];return typeof n==`string`||typeof n==`number`||typeof n==`boolean`?n:t.defaultValue===void 0?t.type===`boolean`?!1:``:t.defaultValue}function En(e,t){if(e.type===`boolean`)return!!t;if(e.type!==`number`)return t;let n=String(t).trim();if(!n)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function Dn(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`update`:return{...e,form:t.updater(e.form)};case`saved`:{let n=structuredClone(t.value);return{form:e.form!==null&&JSON.stringify(e.form)!==JSON.stringify(t.value)?e.form:n,baseline:structuredClone(n)}}}}function On(){let e=S(e=>e.language),t=w(e).voiceSettings,[n,r]=(0,Q.useState)(`listening`),i=Le(),a=ie(e=>e.captions),o=ie(e=>e.setCaptions),s=!!b(e=>e.conversationId);(0,Q.useEffect)(()=>{!i&&n===`diagnostics`&&r(`listening`)},[n,i]);let[c,l]=(0,Q.useReducer)(Dn,{form:null,baseline:null}),f=c.form,p=c.baseline,[m,h]=(0,Q.useState)(null),g=(0,Q.useRef)(!1),_=(0,Q.useRef)(f);_.current=f;let v=(0,Q.useRef)({parsed:null,models:void 0}),{data:y,error:x,isLoading:T,mutate:E}=ee(s),{data:D,error:O,isLoading:k,mutate:A}=M(s?C(`/api/voice/models`):null,gt,{revalidateOnFocus:!1}),{data:j,error:P,isLoading:F}=M(s?C(`/api/voice/providers`):null,wt,{revalidateOnFocus:!1}),{data:I,error:L,isLoading:R}=M(s?C(`/api/voice/stt-providers`):null,_t,{revalidateOnFocus:!1}),z=(0,Q.useMemo)(()=>j?.providers??[],[j]),B=(0,Q.useMemo)(()=>I?.providers??[],[I]),V=(0,Q.useMemo)(()=>y?.payload?.config===void 0?null:Ot(y.payload.config),[y]),H=(0,Q.useMemo)(()=>!f||!p?!1:JSON.stringify(f)!==JSON.stringify(p),[f,p]);s?V!==null&&D!==void 0&&!g.current&&(v.current.parsed!==V||v.current.models!==D)&&(v.current={parsed:V,models:D},l({type:`sync`,value:V}),h(D)):(v.current.parsed!==null||v.current.models!==void 0)&&(v.current={parsed:null,models:void 0},l({type:`reset`}),h(null),g.current=!1);let U=!!(s&&(V===null||D===void 0||j===void 0||I===void 0)&&(T||k||F||R)),te=x instanceof Error?x.message:x?String(x):O instanceof Error?O.message:O?String(O):P instanceof Error?P.message:P?String(P):L instanceof Error?L.message:L?String(L):null,W=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e}}:null})},[]),G=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!1,order:[`xopc-local`]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}}})},[]),K=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,voice:{...t.voice,input:{...t.voice.input,refinement:{...t.voice.input.refinement,...e}}}}:null})},[]),ne=(0,Q.useCallback)(t=>{g.current=!0,l({type:`update`,updater:n=>n?{...n,voice:{...n.voice,languageMode:t,...t===`auto`?{language:e}:{}}}:null})},[e]),re=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,voice:{...t.voice,realtime:{...t.voice.realtime,...e}}}:null})},[]),q=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),J=ht({value:f,dirty:H,onSave:(0,Q.useCallback)(async e=>{let n=p?.stt.provider!==`xopc-local`&&e.stt.provider===`xopc-local`;try{await vt(e),n&&window.dispatchEvent(new Event(Dt)),l({type:`saved`,value:e}),g.current=!!(_.current&&JSON.stringify(_.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[p?.stt.provider,t.saveError])}),Y=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:()=>e})},[]);if(!s)return(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})});if(U)return(0,$.jsx)(pt,{rows:4});if(!f||m===null)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:te??t.loadError}),(0,$.jsx)(N,{type:`button`,variant:`secondary`,onClick:()=>{E(),A()},children:t.retry})]});let ae=f.stt,X=f.tts,oe=f.voice.input.refinement,Z=wn(t);return(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,onBlurCapture:J.onBlurCapture,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:(0,$.jsx)(mt,{status:J.status,error:J.error})}),J.error?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:J.error}):null,(0,$.jsx)(`nav`,{"aria-label":t.setup.advanced,className:`flex flex-wrap gap-2`,children:[`listening`,`input`,`devices`,`service`,...i?[`diagnostics`]:[]].map(e=>(0,$.jsx)(N,{variant:n===e?`secondary`:`ghost`,"aria-pressed":n===e,onClick:()=>r(e),children:t.experience[e]},e))}),n===`listening`||n===`service`||n===`diagnostics`?(0,$.jsx)(on,{section:n,v:t,form:f,pending:H||J.status===`saving`||!!J.error,apiKeyLabels:Z,sttProviders:B,onChange:Y}):null,n===`listening`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(kn,{v:t,voice:f.voice,updateLanguageMode:ne}),(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(12rem,18rem)] sm:items-center`,children:[(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:t.experience.pace}),(0,$.jsxs)(u,{className:_n(),value:String(f.voice.realtime.silenceDurationMs),onChange:e=>re({silenceDurationMs:Number(e.target.value)}),children:[(0,$.jsx)(d,{value:`800`,children:t.experience.fast}),(0,$.jsx)(d,{value:`1200`,children:t.experience.standard}),(0,$.jsx)(d,{value:`2000`,children:t.experience.relaxed}),[800,1200,2e3].includes(f.voice.realtime.silenceDurationMs)?null:(0,$.jsxs)(d,{value:String(f.voice.realtime.silenceDurationMs),children:[f.voice.realtime.silenceDurationMs,` ms`]})]})]})})]}):null,n===`input`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`flex items-center justify-between text-sm`,children:[t.experience.captions,(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":a,className:`ui-checkbox`,checked:a,onChange:e=>o(e.target.checked)})]}),(0,$.jsxs)(`label`,{className:`space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:t.stt.refinement}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.stt.refinementDesc}),(0,$.jsxs)(u,{className:_n(),value:oe.mode,onChange:e=>K({mode:e.target.value}),children:[(0,$.jsx)(d,{value:`off`,children:t.stt.refinementOff}),(0,$.jsx)(d,{value:`punctuation`,children:t.stt.refinementPunctuation}),(0,$.jsx)(d,{value:`light`,children:t.stt.refinementLight}),oe.mode===`custom`?(0,$.jsx)(d,{value:`custom`,children:t.setup.advanced}):null]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-base/55 px-4 py-3`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:[t.setup.readout,` · `,X.enabled?Sn(X.trigger,t):t.overview.off]}),(0,$.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.setup.readoutHint}),(0,$.jsx)(Pn,{v:t,apiKeyLabels:Z,tts:X,models:m,ttsProviders:z,updateTts:q})]})]}):null,n===`devices`?(0,$.jsx)(nn,{v:t}):null,n===`service`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(tn,{disabled:H||J.status===`saving`}),f.voice.realtime.enabled&&f.voice.realtime.omni?.provider===`alibaba`?(0,$.jsx)(fn,{value:f.voice.realtime.omni,onChange:e=>re({omni:e})}):null,(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-base/55 px-4 py-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:t.experience.technical}),(0,$.jsx)(An,{v:t,apiKeyLabels:Z,stt:ae,models:m,sttProviders:B,updateStt:W,updateSttFallback:G}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.notes.envVars})]})]}):null]})}function kn(e){let t=(0,Rt.c)(22),{v:n,voice:r,updateLanguageMode:i}=e,a;t[0]===n.language.title?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.language.title}),t[0]=n.language.title,t[1]=a);let o=r.languageMode===`auto`?n.language.autoDescription:n.language.manualDescription,s;t[2]===o?s=t[3]:(s=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o}),t[2]=o,t[3]=s);let c;t[4]!==a||t[5]!==s?(c=(0,$.jsxs)(`div`,{children:[a,s]}),t[4]=a,t[5]=s,t[6]=c):c=t[6];let l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=_n(),t[7]=l):l=t[7];let f;t[8]===i?f=t[9]:(f=e=>i(e.target.value),t[8]=i,t[9]=f);let p;t[10]===n.language.auto?p=t[11]:(p=(0,$.jsx)(d,{value:`auto`,children:n.language.auto}),t[10]=n.language.auto,t[11]=p);let m;t[12]===n.language.manual?m=t[13]:(m=(0,$.jsx)(d,{value:`manual`,children:n.language.manual}),t[12]=n.language.manual,t[13]=m);let h;t[14]!==f||t[15]!==p||t[16]!==m||t[17]!==r.languageMode?(h=(0,$.jsxs)(u,{className:l,value:r.languageMode,onChange:f,children:[p,m]}),t[14]=f,t[15]=p,t[16]=m,t[17]=r.languageMode,t[18]=h):h=t[18];let g;return t[19]!==c||t[20]!==h?(g=(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(12rem,18rem)] sm:items-center`,children:[c,h]})}),t[19]=c,t[20]=h,t[21]=g):g=t[21],g}function An(e){let t=(0,Rt.c)(58),{v:n,apiKeyLabels:r,stt:i,models:a,sttProviders:o,updateStt:s,updateSttFallback:c}=e,l;if(t[0]!==o){let e=new Set;l=[];for(let t of o)e.has(t.id)||(e.add(t.id),l.push(t));t[0]=o,t[1]=l}else l=t[1];let f=l,p,m,h,g;if(t[2]!==a||t[3]!==f||t[4]!==i.provider||t[5]!==i.providers){p=f.find(e=>e.id===i.provider);let e;t[10]!==i.provider||t[11]!==i.providers?(e=i.providers?.[i.provider]??{},t[10]=i.provider,t[11]=i.providers,t[12]=e):e=t[12],h=e,m=a?.stt?.[i.provider]?.length?a.stt[i.provider]:p?.models??[],g=p?.fields.find(jn),t[2]=a,t[3]=f,t[4]=i.provider,t[5]=i.providers,t[6]=p,t[7]=m,t[8]=h,t[9]=g}else p=t[6],m=t[7],h=t[8],g=t[9];let _=g,y=typeof h.model==`string`?h.model:void 0,b=y??(typeof _?.defaultValue==`string`?_.defaultValue:m[0]?.id),x;t[13]!==i.provider||t[14]!==i.providers||t[15]!==s?(x=e=>{s({providers:{...i.providers??{},[i.provider]:{...i.providers?.[i.provider]??{},...e}}})},t[13]=i.provider,t[14]=i.providers,t[15]=s,t[16]=x):x=t[16];let S=x,C,w;t[17]!==y||t[18]!==b||t[19]!==_||t[20]!==S?(C=()=>{_&&b&&y!==b&&S({model:b})},w=[y,b,_,S],t[17]=y,t[18]=b,t[19]=_,t[20]=S,t[21]=C,t[22]=w):(C=t[21],w=t[22]),(0,Q.useEffect)(C,w);let T;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(Ae,{className:`size-4 text-accent`,strokeWidth:1.75}),t[23]=T):T=t[23];let E;t[24]===n.stt.title?E=t[25]:(E=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[T,n.stt.title]}),t[24]=n.stt.title,t[25]=E);let D;t[26]===n.stt.description?D=t[27]:(D=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[26]=n.stt.description,t[27]=D);let O;t[28]!==E||t[29]!==D?(O=(0,$.jsxs)(`div`,{className:`mb-4`,children:[E,D]}),t[28]=E,t[29]=D,t[30]=O):O=t[30];let k;t[31]===s?k=t[32]:(k=e=>s({enabled:e}),t[31]=s,t[32]=k);let A;t[33]!==i.enabled||t[34]!==k||t[35]!==n.stt.enable||t[36]!==n.stt.enableDesc?(A=(0,$.jsx)(In,{checked:i.enabled,title:n.stt.enable,description:n.stt.enableDesc,onChange:k}),t[33]=i.enabled,t[34]=k,t[35]=n.stt.enable,t[36]=n.stt.enableDesc,t[37]=A):A=t[37];let j;t[38]!==p?.fields||t[39]!==r||t[40]!==b||t[41]!==m||t[42]!==f||t[43]!==h||t[44]!==i.enabled||t[45]!==i.fallback?.enabled||t[46]!==i.provider||t[47]!==S||t[48]!==s||t[49]!==c||t[50]!==n?(j=i.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:v(`flex flex-col gap-1.5`,hn),children:[(0,$.jsx)(zn,{children:n.stt.provider}),(0,$.jsx)(u,{className:_n(),value:i.provider,onChange:e=>s({provider:e.target.value}),children:f.map(e=>(0,$.jsxs)(d,{value:e.id,children:[bn(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,$.jsx)(Fn,{kind:`stt`,providerId:i.provider,fields:p?.fields??[],providerSlice:h,models:m,currentModel:b,apiKeyLabels:r,onPatch:S})]}),i.provider===`xopc-local`?(0,$.jsx)(Nn,{v:n}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.fallback}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.fallbackDesc})]}),(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:i.fallback?.enabled??!1,onChange:e=>c({enabled:e.target.checked})})]})]}):null,t[38]=p?.fields,t[39]=r,t[40]=b,t[41]=m,t[42]=f,t[43]=h,t[44]=i.enabled,t[45]=i.fallback?.enabled,t[46]=i.provider,t[47]=S,t[48]=s,t[49]=c,t[50]=n,t[51]=j):j=t[51];let M;t[52]!==A||t[53]!==j?(M=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[A,j]}),t[52]=A,t[53]=j,t[54]=M):M=t[54];let N;return t[55]!==M||t[56]!==O?(N=(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:[O,M]}),t[55]=M,t[56]=O,t[57]=N):N=t[57],N}function jn(e){return e.key===`model`}function Mn(e){return`${Math.round(e/1024/1024)} MB`}function Nn({v:e}){let{data:t,error:n,mutate:r}=M(C(`/api/voice/local/status`),Ct,{revalidateOnFocus:!1,refreshInterval:e=>e?.models.some(e=>e.state===`downloading`)?1e3:0}),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let e=()=>void r();return window.addEventListener(Dt,e),()=>window.removeEventListener(Dt,e)},[r]);let c=(0,Q.useCallback)(async(e,t)=>{a(e.id),s(null);try{t===`install`?await St(e.id):await Tt(e.id),await r()}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(null)}},[r]);return(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base/55 p-3`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.stt.localModels}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.stt.localModelsDesc}),n?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-red-600 dark:text-red-400`,children:String(n)}):null,t?.runtime.ready===!1?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-red-600 dark:text-red-400`,children:t.runtime.error??`Local voice runtime is unavailable`}):null,t?.decoder?.available===!1?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-amber-700 dark:text-amber-300`,children:t.decoder.error??`Compressed audio decoding is unavailable`}):null,o?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-red-600 dark:text-red-400`,children:o}):null,(0,$.jsx)(`div`,{className:`mt-3 grid gap-2`,children:(t?.models??[]).map(t=>{let n=i===t.id||t.state===`downloading`;return(0,$.jsxs)(`div`,{className:v(`flex items-center justify-between gap-3 rounded-lg bg-surface-base px-3 py-2.5`,t.recommended?`ring-1 ring-accent/40`:``),children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm font-medium text-fg`,children:[t.name,t.recommended?(0,$.jsx)(`span`,{className:`rounded-full bg-accent/10 px-2 py-0.5 text-[10px] font-medium text-accent`,children:e.stt.localRecommended}):null]}),(0,$.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[Mn(t.approximateBytes),` · `,t.description]}),(0,$.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-fg-subtle`,children:[t.engine,` · `,t.languages.join(` / `)]}),t.state===`downloading`?(0,$.jsxs)(`div`,{className:`mt-1 text-xs text-accent`,children:[e.stt.localDownloading,` `,Math.round((t.progress??0)*100),`%`]}):t.state===`error`?(0,$.jsx)(`div`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:t.error}):null]}),(0,$.jsx)(N,{type:`button`,variant:`secondary`,disabled:n,onClick:()=>void c(t,t.state===`ready`?`remove`:`install`),children:n?(0,$.jsx)(h,{className:`size-4 animate-spin`}):t.state===`ready`?e.stt.localRemove:e.stt.localInstall})]},t.id)})})]})}function Pn({v:e,apiKeyLabels:t,tts:n,models:r,ttsProviders:i,updateTts:a}){let[o,s]=(0,Q.useState)(e.tts.test.sampleText),[c,l]=(0,Q.useState)({status:`idle`}),f=(0,Q.useRef)(null),p=(0,Q.useRef)(null),m=(0,Q.useRef)(null),g=(0,Q.useCallback)(()=>{m.current?.abort(),m.current=null,f.current?.pause(),f.current=null,p.current&&=(URL.revokeObjectURL(p.current),null)},[]),_=(0,Q.useMemo)(()=>{let e=new Set,t=[];for(let n of i)e.has(n.id)||(e.add(n.id),t.push(n));return t},[i]),y=_.find(e=>e.id===n.provider),b=n.providers?.[n.provider]??{},x=r?.tts?.[n.provider]?.length?r.tts[n.provider]:y?.models??[],S=y?.fields.find(e=>e.key===`model`),C=y?.fields.find(e=>e.key===`voice`),w=typeof b.model==`string`?b.model:void 0,T=w??(typeof S?.defaultValue==`string`?S.defaultValue:x[0]?.id),E=x.find(e=>e.id===T),D=r?.ttsVoices?.[n.provider]?.length?r.ttsVoices[n.provider]:y?.voices??[],{data:O=[]}=M(T?`voice:tts:${n.provider}:${T}`:null,()=>xt(n.provider,T??``),{revalidateOnFocus:!1}),k=O.length>0?O:D,A=typeof b.voice==`string`?b.voice:void 0,j=A??k.find(e=>e.id===E?.tts?.defaultVoice)?.id??(typeof C?.defaultValue==`string`?C.defaultValue:k[0]?.id),P=(y?.fields??[]).filter(e=>(e.key!==`speed`||E?.tts?.speed!==!1)&&(e.key!==`instructions`||E?.tts?.instructions!==!1)),ee=!!y?.diagnostics.requiresApiKey,F=!!y?.configured||!ee,I=(0,Q.useCallback)(e=>{a({providers:{...n.providers??{},[n.provider]:{...n.providers?.[n.provider]??{},...e}}})},[n.provider,n.providers,a]);(0,Q.useEffect)(()=>{let e={};S&&T&&w!==T&&(e.model=T),C&&j&&A!==j&&(e.voice=j),Object.keys(e).length>0&&I(e)},[w,A,T,j,S,I,C]),(0,Q.useEffect)(()=>()=>g(),[g]);let L=(0,Q.useCallback)(e=>{a({provider:e}),l({status:`idle`})},[a]),R=(0,Q.useCallback)(async()=>{let t=o.trim();if(!t){l({status:`error`,message:e.tts.test.emptyText});return}g();let r=new AbortController;m.current=r,l({status:`loading`});try{let i=await bt({text:t,provider:n.provider,providerConfig:b,...T?{model:T}:{},...j?{voice:j}:{}},r.signal);if(r.signal.aborted)return;let a=yn(i.audio,i.mimeType);p.current=a;let o=new Audio(a);f.current=o;let s=[i.provider,i.format,i.latencyMs===void 0?void 0:`${i.latencyMs}ms`,vn(i.audioSize)].filter(Boolean).join(` · `);o.addEventListener(`ended`,()=>l({status:`done`,summary:s}),{once:!0}),o.addEventListener(`error`,()=>l({status:`error`,message:e.tts.test.playFailed}),{once:!0}),await o.play(),l({status:`playing`,summary:s})}catch(e){if(r.signal.aborted)return;g(),l({status:`error`,message:e instanceof Error?e.message:String(e)})}},[T,j,b,g,o,n.provider,e.tts.test.emptyText,e.tts.test.playFailed]);return(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:[(0,$.jsxs)(`div`,{className:`mb-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(q,{className:`size-4 text-accent`,strokeWidth:1.75}),e.tts.title]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.description})]}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(In,{checked:n.enabled,title:e.tts.enable,description:e.tts.enableDesc,onChange:e=>a({enabled:e})}),n.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:v(`flex flex-col gap-1.5`,hn),children:[(0,$.jsx)(zn,{children:e.tts.trigger}),(0,$.jsxs)(u,{className:_n(),value:n.trigger,onChange:e=>a({trigger:e.target.value}),children:[(0,$.jsx)(d,{value:`off`,children:e.tts.triggerOff}),(0,$.jsx)(d,{value:`inbound`,children:e.tts.triggerInbound}),(0,$.jsx)(d,{value:`tagged`,children:e.tts.triggerTagged}),(0,$.jsx)(d,{value:`always`,children:e.tts.triggerAlways})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.triggerHelp})]}),(0,$.jsxs)(`div`,{className:v(`flex flex-col gap-1.5`,hn),children:[(0,$.jsx)(zn,{children:e.tts.provider}),(0,$.jsx)(u,{className:_n(),value:n.provider,onChange:e=>L(e.target.value),children:_.map(t=>(0,$.jsx)(d,{value:t.id,children:xn(t.id,e)},t.id))}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[y?.configured?e.tts.configured:y?.diagnostics.requiresApiKey?`${e.tts.needsKey} · ${y.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.noKeyNeeded,` · `,y?.description??Cn(n.provider,e)]})]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,open:!F||n.provider===`tts-local-cli`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg marker:text-fg-muted`,children:[e.tts.advanced.title,(0,$.jsx)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:e.tts.advanced.description})]}),(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:(0,$.jsx)(Fn,{kind:`tts`,providerId:n.provider,fields:P,providerSlice:b,models:x,voices:k,currentModel:T,currentVoice:j,apiKeyLabels:t,onPatch:I,resetVoiceOnModelChange:!0})})})]}),(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.tts.test.title}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.test.description})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,$.jsxs)(N,{type:`button`,variant:`primary`,onClick:()=>void R(),disabled:c.status===`loading`,className:`h-9`,children:[c.status===`loading`?(0,$.jsx)(h,{className:`size-4 animate-spin`}):(0,$.jsx)(U,{className:`size-4`}),c.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,$.jsxs)(N,{type:`button`,variant:`secondary`,onClick:()=>{g(),l(e=>e.status===`playing`?{status:`done`,summary:e.summary}:{status:`idle`})},disabled:c.status!==`playing`,className:`h-9`,children:[(0,$.jsx)(we,{className:`size-4`}),e.tts.test.stop]})]})]}),(0,$.jsxs)(`details`,{className:`mt-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-xs text-fg-muted`,children:e.setup.sampleText}),(0,$.jsx)(`textarea`,{className:v(gn(),`mt-3 min-h-20 resize-y`),value:o,onChange:e=>s(e.target.value),maxLength:1e3})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,$.jsxs)(`span`,{className:`text-fg-subtle`,children:[o.length,`/1000`]}),c.status===`playing`||c.status===`done`?(0,$.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-200`,children:[c.status===`playing`?e.tts.test.playing:e.tts.test.ready,` · `,c.summary]}):null,c.status===`error`?(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:c.message}):null]})]})]}):null]})]})}function Fn({kind:e,providerId:t,fields:n,providerSlice:r,models:i,voices:a=[],currentModel:o,currentVoice:s,apiKeyLabels:c,onPatch:l,resetVoiceOnModelChange:f=!1}){return n.map(n=>n.key===`apiKey`?(0,$.jsxs)(`div`,{className:v(`flex flex-col gap-1.5`,hn),children:[(0,$.jsx)(zn,{children:n.label}),(0,$.jsx)(kt,{kind:e,providerId:t,fieldId:`voice-${e}-${t}-api-key`,value:typeof r.apiKey==`string`?r.apiKey:``,onChange:e=>l({apiKey:e}),labels:c,placeholder:n.placeholder}),n.description?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.description}):null]},n.key):n.key===`model`&&i.length>0?(0,$.jsxs)(`div`,{className:v(`flex flex-col gap-1.5`,hn),children:[(0,$.jsx)(zn,{children:n.label}),(0,$.jsx)(u,{className:_n(),value:o??``,onChange:e=>l({model:e.target.value,...f?{voice:void 0}:{}}),children:i.map(e=>(0,$.jsx)(d,{value:e.id,children:e.name},e.id))})]},n.key):n.key===`voice`&&a.length>0?(0,$.jsxs)(`div`,{className:v(`flex flex-col gap-1.5`,hn),children:[(0,$.jsx)(zn,{children:n.label}),(0,$.jsx)(u,{className:_n(),value:s??``,onChange:e=>l({voice:e.target.value}),children:a.map(e=>(0,$.jsx)(d,{value:e.id,children:e.name},e.id))})]},n.key):(0,$.jsx)(Ln,{field:n,value:Tn(r,n),onChange:e=>l({[n.key]:e}),className:n.type===`textarea`?`sm:col-span-2`:hn},n.key))}function In(e){let t=(0,Rt.c)(27),{checked:n,title:r,description:i,onChange:a}=e,o;t[0]!==n||t[1]!==a?(o=()=>a(!n),t[0]=n,t[1]=a,t[2]=o):o=t[2];let s=n?`bg-surface-panel text-fg`:`bg-surface-panel/80 text-fg hover:bg-surface-hover`,c;t[3]===s?c=t[4]:(c=v(`group flex w-full items-center justify-between gap-4 rounded-lg bg-surface-base/55 px-3 py-3 text-left transition-colors`,K,s),t[3]=s,t[4]=c);let l;t[5]===r?l=t[6]:(l=(0,$.jsx)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm font-semibold text-fg`,children:r}),t[5]=r,t[6]=l);let u;t[7]===i?u=t[8]:(u=(0,$.jsx)(`span`,{className:`mt-1 block text-xs leading-relaxed text-fg-muted`,children:i}),t[7]=i,t[8]=u);let d;t[9]!==l||t[10]!==u?(d=(0,$.jsxs)(`span`,{className:`min-w-0`,children:[l,u]}),t[9]=l,t[10]=u,t[11]=d):d=t[11];let f=n?`border-accent bg-accent`:`border-edge bg-surface-hover group-hover:border-accent/40`,p;t[12]===f?p=t[13]:(p=v(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,f),t[12]=f,t[13]=p);let m=n?`translate-x-5`:`translate-x-0.5`,h;t[14]===m?h=t[15]:(h=v(`size-5 rounded-full bg-white shadow-surface transition-transform`,m),t[14]=m,t[15]=h);let g;t[16]===h?g=t[17]:(g=(0,$.jsx)(`span`,{className:h}),t[16]=h,t[17]=g);let _;t[18]!==g||t[19]!==p?(_=(0,$.jsx)(`span`,{className:p,"aria-hidden":!0,children:g}),t[18]=g,t[19]=p,t[20]=_):_=t[20];let y;return t[21]!==n||t[22]!==o||t[23]!==_||t[24]!==c||t[25]!==d?(y=(0,$.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":n,onClick:o,className:c,children:[d,_]}),t[21]=n,t[22]=o,t[23]=_,t[24]=c,t[25]=d,t[26]=y):y=t[26],y}function Ln(e){let t=(0,Rt.c)(36),{field:n,value:r,onChange:i,className:a}=e,o=`voice-schema-field-${n.key}`,s=n.description;if(n.type===`boolean`){let e;t[0]===a?e=t[1]:(e=v(`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,a),t[0]=a,t[1]=e);let o;t[2]===n.label?o=t[3]:(o=(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n.label}),t[2]=n.label,t[3]=o);let c;t[4]===s?c=t[5]:(c=s?(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:s}):null,t[4]=s,t[5]=c);let l;t[6]!==o||t[7]!==c?(l=(0,$.jsxs)(`span`,{children:[o,c]}),t[6]=o,t[7]=c,t[8]=l):l=t[8];let u=!!r,d;t[9]!==n||t[10]!==i?(d=e=>i(En(n,e.target.checked)),t[9]=n,t[10]=i,t[11]=d):d=t[11];let f;t[12]!==u||t[13]!==d?(f=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:u,onChange:d}),t[12]=u,t[13]=d,t[14]=f):f=t[14];let p;return t[15]!==e||t[16]!==l||t[17]!==f?(p=(0,$.jsxs)(`label`,{className:e,children:[l,f]}),t[15]=e,t[16]=l,t[17]=f,t[18]=p):p=t[18],p}let c=typeof r==`boolean`?``:String(r),l;t[19]===a?l=t[20]:(l=v(`flex flex-col gap-1.5`,a),t[19]=a,t[20]=l);let d;t[21]===n.label?d=t[22]:(d=(0,$.jsx)(zn,{children:n.label}),t[21]=n.label,t[22]=d);let f;t[23]!==a||t[24]!==n||t[25]!==c||t[26]!==o||t[27]!==i?(f=n.type===`select`?(0,$.jsx)(u,{id:o,className:_n(),value:c,required:n.required,onChange:e=>i(En(n,e.target.value)),children:(n.options??[]).map(Rn)}):n.type===`textarea`?(0,$.jsx)(`textarea`,{id:o,className:v(gn(),`min-h-24 resize-y`),value:c,required:n.required,placeholder:n.placeholder,onChange:e=>i(En(n,e.target.value))}):n.type===`password`?(0,$.jsx)(ve,{id:o,className:a,value:c,onChange:e=>i(En(n,e)),placeholder:n.placeholder,labels:he}):(0,$.jsx)(`input`,{id:o,className:gn(),type:n.type===`number`?`number`:`text`,autoComplete:n.secret?`new-password`:`off`,spellCheck:!1,value:c,required:n.required,placeholder:n.placeholder,min:n.min,max:n.max,step:n.step,onChange:e=>i(En(n,e.target.value))}),t[23]=a,t[24]=n,t[25]=c,t[26]=o,t[27]=i,t[28]=f):f=t[28];let p;t[29]===s?p=t[30]:(p=s?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:s}):null,t[29]=s,t[30]=p);let m;return t[31]!==l||t[32]!==d||t[33]!==f||t[34]!==p?(m=(0,$.jsxs)(`div`,{className:l,children:[d,f,p]}),t[31]=l,t[32]=d,t[33]=f,t[34]=p,t[35]=m):m=t[35],m}function Rn(e){return(0,$.jsx)(d,{value:e.id,children:e.name},e.id)}function zn(e){let t=(0,Rt.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function Bn(e){let t=e&&typeof e==`object`&&`tools`in e?e.tools:void 0,n=t&&typeof t==`object`&&`web`in t?t.web:void 0,r=n&&typeof n==`object`&&`region`in n?n.region:void 0,i=r===`cn`||r===`global`?r:`auto`,a=n&&typeof n==`object`&&`search`in n?n.search:void 0,o=a&&typeof a==`object`?a:{},s=typeof o.maxResults==`number`&&Number.isFinite(o.maxResults)?Math.floor(o.maxResults):5,c=n&&typeof n==`object`&&`blocklist`in n?n.blocklist:void 0,l=c&&typeof c==`object`?c:{},u=Array.isArray(l.domains)?l.domains.filter(e=>typeof e==`string`&&e.trim().length>0):[],d=o.providers;return{regionMode:i,maxResults:s,providers:Array.isArray(d)?d.map(e=>{let t=e&&typeof e==`object`?e:{},n=t.type;return{type:n===`brave`||n===`tavily`||n===`bing`||n===`searxng`?n:`brave`,apiKey:typeof t.apiKey==`string`?t.apiKey:``,url:typeof t.url==`string`?t.url:``,disabled:t.disabled===!0}}):[],blocklistEnabled:l.enabled===!0,blocklistDomains:u}}async function Vn(e){let t=e.regionMode===`auto`?`auto`:e.regionMode===`cn`?`cn`:`global`,n={maxResults:e.maxResults,providers:e.providers.map(e=>{let t={type:e.type,apiKey:e.apiKey};return e.type===`searxng`&&e.url.trim()&&(t.url=e.url.trim().replace(/\/+$/,``)),e.disabled&&(t.disabled=!0),t})};await y(C(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),P()}async function Hn(e){let t=await y(C(`/api/tools/web/reveal-search-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({index:e})});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}function Un(e){let t=(0,Rt.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}),t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Wn(){return v(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,K,`dark:border-edge`)}function Gn(){return v(de,nt)}var Kn=[`brave`,`tavily`,`bing`,`searxng`];function qn(){return{type:`brave`,apiKey:``,url:``,disabled:!1}}var Jn=ce();function Yn(){let e=w(S(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!b(e=>e.conversationId),[i,a]=(0,Q.useReducer)(Jn,{form:null,baseline:null}),o=i.form,s=i.baseline,c=(0,Q.useRef)(!1),l=(0,Q.useRef)(o);l.current=o;let f=(0,Q.useRef)(null),{data:p,error:m,isLoading:h,mutate:_}=ee(r);z({enabled:r,parsed:(0,Q.useMemo)(()=>p?.payload?.config===void 0?null:Bn(p.payload.config),[p]),dirty:c.current,trackedParsedRef:f,dispatch:a,onResetDirty:()=>{c.current=!1}});let y=!!(r&&h&&p===void 0&&!m),x=m instanceof Error?m.message:m?String(m):null,C=(0,Q.useMemo)(()=>!o||!s?!1:JSON.stringify(o)!==JSON.stringify(s),[o,s]),T=(0,Q.useCallback)(e=>{c.current=!0,a({type:`patch`,patch:e})},[]),E=ht({value:o,dirty:C,onSave:(0,Q.useCallback)(async e=>{try{await Vn(e),a({type:`saved`,value:e}),c.current=!!(l.current&&JSON.stringify(l.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});return r?y?(0,$.jsx)(pt,{rows:3}):o?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,onBlurCapture:E.onBlurCapture,children:[E.error?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:E.error}):null,(0,$.jsxs)(ft,{children:[(0,$.jsx)(dt,{icon:ct,title:t.sectionSearch,subtitle:t.sectionSearchHint,trailing:(0,$.jsx)(mt,{status:E.status,error:E.error})}),(0,$.jsxs)(`div`,{className:`flex max-w-2xl flex-col gap-3`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:t.providersTitle}),o.providers.map((n,r)=>(0,$.jsx)(Xn,{row:n,providerIndex:r,labels:t,secretLabels:$e(e.providersSettings),onChange:e=>{let t=[...o.providers];t[r]=e,T({providers:t})},onRemove:()=>{T({providers:o.providers.filter((e,t)=>t!==r)})}},`${n.type}:${n.url}:${n.apiKey}:${n.disabled}`)),(0,$.jsxs)(N,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>T({providers:[...o.providers,qn()]}),children:[(0,$.jsx)(g,{className:`size-4`}),t.addProvider]})]})]}),(0,$.jsxs)(ft,{children:[(0,$.jsx)(dt,{icon:Qe,title:t.sectionPreferences}),(0,$.jsxs)(`div`,{className:`grid max-w-2xl gap-4 sm:grid-cols-2`,children:[(0,$.jsx)(Un,{label:t.regionLabel,description:t.regionDesc,children:(0,$.jsxs)(u,{className:Gn(),value:o.regionMode,onChange:e=>T({regionMode:e.target.value}),children:[(0,$.jsx)(d,{value:`auto`,children:t.regionAuto}),(0,$.jsx)(d,{value:`cn`,children:t.regionCn}),(0,$.jsx)(d,{value:`global`,children:t.regionGlobal})]})}),(0,$.jsx)(Un,{label:t.maxResultsLabel,description:t.maxResultsDesc,children:(0,$.jsx)(`input`,{type:`number`,min:1,max:50,className:Wn(),value:o.maxResults,onChange:e=>T({maxResults:Math.max(1,Math.min(50,Number(e.target.value)||5))})})})]})]}),(0,$.jsx)(jt,{children:(0,$.jsxs)(ft,{children:[(0,$.jsx)(dt,{icon:rt,title:t.sectionBlocklist,subtitle:t.sectionBlocklistHint}),(0,$.jsxs)(`div`,{className:`flex max-w-2xl flex-col gap-4`,children:[(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:o.blocklistEnabled,onChange:e=>T({blocklistEnabled:e.target.checked})}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium`,children:t.blocklistEnabled}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:t.blocklistEnabledDesc})]})]}),o.blocklistEnabled?(0,$.jsx)(Un,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,$.jsx)(`textarea`,{className:v(Wn(),`min-h-[6rem] font-mono text-xs`),value:o.blocklistDomains.join(`
8
- `),placeholder:t.blocklistDomainsPlaceholder,onChange:e=>{T({blocklistDomains:e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]})})}})}):null]})]})})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:x??t.loadError}),(0,$.jsx)(N,{type:`button`,variant:`secondary`,onClick:()=>void _(),children:n.refresh})]}):(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})})}function Xn(e){let t=(0,Rt.c)(54),{row:n,providerIndex:r,labels:i,secretLabels:a,onChange:o,onRemove:s}=e,c;t[0]===r?c=t[1]:(c=()=>Hn(r).then(Zn),t[0]=r,t[1]=c);let l=c,f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=v(Gn(),`min-w-[8rem]`),t[2]=f):f=t[2];let p=n.type,m;t[3]!==o||t[4]!==n?(m=e=>o({...n,type:e.target.value,url:e.target.value===`searxng`?n.url:``}),t[3]=o,t[4]=n,t[5]=m):m=t[5];let h;t[6]===i.providerTypes?h=t[7]:(h=Kn.map(e=>(0,$.jsx)(d,{value:e,children:i.providerTypes[e]},e)),t[6]=i.providerTypes,t[7]=h);let g;t[8]!==n.type||t[9]!==m||t[10]!==h?(g=(0,$.jsx)(u,{className:f,value:p,onChange:m,children:h}),t[8]=n.type,t[9]=m,t[10]=h,t[11]=g):g=t[11];let _;t[12]!==o||t[13]!==n?(_=e=>o({...n,disabled:e.target.checked}),t[12]=o,t[13]=n,t[14]=_):_=t[14];let y;t[15]!==n.disabled||t[16]!==_?(y=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:n.disabled,onChange:_}),t[15]=n.disabled,t[16]=_,t[17]=y):y=t[17];let b;t[18]!==i.disabled||t[19]!==y?(b=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-fg-muted`,children:[y,i.disabled]}),t[18]=i.disabled,t[19]=y,t[20]=b):b=t[20];let x;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(Be,{className:`size-4`}),t[21]=x):x=t[21];let S;t[22]===s?S=t[23]:(S=(0,$.jsx)(N,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-fg-muted`,onClick:s,children:x}),t[22]=s,t[23]=S);let C;t[24]!==S||t[25]!==b?(C=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[b,S]}),t[24]=S,t[25]=b,t[26]=C):C=t[26];let w;t[27]!==C||t[28]!==g?(w=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[g,C]}),t[27]=C,t[28]=g,t[29]=w):w=t[29];let T;t[30]!==i.urlDesc||t[31]!==i.urlLabel||t[32]!==o||t[33]!==n?(T=n.type===`searxng`?(0,$.jsx)(Un,{label:i.urlLabel,description:i.urlDesc,children:(0,$.jsx)(`input`,{type:`url`,className:Wn(),value:n.url,placeholder:`http://localhost:8080`,onChange:e=>o({...n,url:e.target.value})})}):null,t[30]=i.urlDesc,t[31]=i.urlLabel,t[32]=o,t[33]=n,t[34]=T):T=t[34];let E;t[35]!==o||t[36]!==n?(E=e=>o({...n,apiKey:e}),t[35]=o,t[36]=n,t[37]=E):E=t[37];let D;t[38]!==i.keyPlaceholder||t[39]!==i.keyPlaceholderMasked||t[40]!==i.saveError||t[41]!==l||t[42]!==n.apiKey||t[43]!==a||t[44]!==E?(D=(0,$.jsx)(ve,{value:n.apiKey,onChange:E,placeholder:i.keyPlaceholder,labels:a,reveal:l,loadFailedLabel:i.saveError,notInConfigFile:i.keyPlaceholderMasked}),t[38]=i.keyPlaceholder,t[39]=i.keyPlaceholderMasked,t[40]=i.saveError,t[41]=l,t[42]=n.apiKey,t[43]=a,t[44]=E,t[45]=D):D=t[45];let O;t[46]!==i.apiKeyDesc||t[47]!==i.apiKeyLabel||t[48]!==D?(O=(0,$.jsx)(Un,{label:i.apiKeyLabel,description:i.apiKeyDesc,children:D}),t[46]=i.apiKeyDesc,t[47]=i.apiKeyLabel,t[48]=D,t[49]=O):O=t[49];let k;return t[50]!==w||t[51]!==T||t[52]!==O?(k=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-panel/60 p-4`,children:[w,T,O]}),t[50]=w,t[51]=T,t[52]=O,t[53]=k):k=t[53],k}function Zn(e){return e.apiKey??null}function Qn(e){let t=(0,Rt.c)(184),{model:n,isNew:r,providerId:i,onSave:a,onClose:o,m:s}=e,c=S(er)===`zh`,l;t[0]===n?l=t[1]:(l=()=>n?{...n}:xe(``),t[0]=n,t[1]=l);let[f,p]=(0,Q.useState)(l),[m,h]=(0,Q.useState)($n),g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g=(e,t)=>{p(n=>({...n,[e]:t})),h(t=>{let n=new Map(t);return n.delete(e),n})},t[2]=g):g=t[2];let y=g,b;t[3]!==f.computerUse||t[4]!==f.contextWindow||t[5]!==f.id||t[6]!==f.input||t[7]!==f.maxTokens||t[8]!==s.modelIdRequired||t[9]!==s.mustBePositive||t[10]!==c?(b=()=>{let e=new Map;return(f.id||``).trim()||e.set(`id`,s.modelIdRequired),f.contextWindow!==void 0&&f.contextWindow<=0&&e.set(`contextWindow`,s.mustBePositive),f.maxTokens!==void 0&&f.maxTokens<=0&&e.set(`maxTokens`,s.mustBePositive),f.computerUse&&!f.input?.includes(`image`)&&e.set(`computerUse`,c?`电脑控制模型必须支持图片输入`:`Computer Use requires image input`),h(e),e.size===0},t[3]=f.computerUse,t[4]=f.contextWindow,t[5]=f.id,t[6]=f.input,t[7]=f.maxTokens,t[8]=s.modelIdRequired,t[9]=s.mustBePositive,t[10]=c,t[11]=b):b=t[11];let x=b,C;t[12]!==f||t[13]!==o||t[14]!==a||t[15]!==x?(C=()=>{if(!x())return;let e=(f.id||``).trim();a({...f,id:e,name:f.name?.trim()||e,reasoning:f.reasoning||!1,input:f.input||[`text`],contextWindow:f.contextWindow??128e3,maxTokens:f.maxTokens??16384,cost:{input:f.cost?.input??0,output:f.cost?.output??0,cacheRead:f.cost?.cacheRead??0,cacheWrite:f.cost?.cacheWrite??0}}),o()},t[12]=f,t[13]=o,t[14]=a,t[15]=x,t[16]=C):C=t[16];let w=C,T=f,E;t[17]===T?E=t[18]:(E=He(T),t[17]=T,t[18]=E);let O=E,k=r?s.addModelTitle:s.editModelTitle,j;t[19]===k?j=t[20]:(j=(0,$.jsx)(A,{className:`text-base font-semibold text-fg`,children:k}),t[19]=k,t[20]=j);let M;t[21]!==s.modelProviderLabel||t[22]!==i?(M=i?(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[s.modelProviderLabel,`: `,i]}):null,t[21]=s.modelProviderLabel,t[22]=i,t[23]=M):M=t[23];let P;t[24]!==j||t[25]!==M?(P=(0,$.jsxs)(`div`,{children:[j,M]}),t[24]=j,t[25]=M,t[26]=P):P=t[26];let ee;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(ee=v(ye,`p-1.5 hover:bg-surface-base`),t[27]=ee):ee=t[27];let F;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(_,{className:`size-4`}),t[28]=F):F=t[28];let I;t[29]===s.close?I=t[30]:(I=(0,$.jsx)(D,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:ee,"aria-label":s.close,children:F})}),t[29]=s.close,t[30]=I);let L;t[31]!==P||t[32]!==I?(L=(0,$.jsxs)(`div`,{className:`mb-3 flex shrink-0 items-start justify-between gap-2`,children:[P,I]}),t[31]=P,t[32]=I,t[33]=L):L=t[33];let R;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[34]=R):R=t[34];let z;t[35]===s.modelId?z=t[36]:(z=(0,$.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[s.modelId,R]}),t[35]=s.modelId,t[36]=z);let B;t[37]===m?B=t[38]:(B=v(je(),m.has(`id`)&&`border-red-500`),t[37]=m,t[38]=B);let V=f.id||``,H;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(H=e=>y(`id`,e.target.value),t[39]=H):H=t[39];let U=!r,te;t[40]!==B||t[41]!==V||t[42]!==U?(te=(0,$.jsx)(`input`,{className:B,value:V,onChange:H,placeholder:`e.g. llama3.1:8b`,disabled:U}),t[40]=B,t[41]=V,t[42]=U,t[43]=te):te=t[43];let W;t[44]===m?W=t[45]:(W=m.has(`id`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:m.get(`id`)}):null,t[44]=m,t[45]=W);let G;t[46]!==z||t[47]!==te||t[48]!==W?(G=(0,$.jsxs)(`div`,{children:[z,te,W]}),t[46]=z,t[47]=te,t[48]=W,t[49]=G):G=t[49];let K;t[50]===s.displayName?K=t[51]:(K=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.displayName}),t[50]=s.displayName,t[51]=K);let ne;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(ne=je(),t[52]=ne):ne=t[52];let re=f.name||``,q;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(q=e=>y(`name`,e.target.value),t[53]=q):q=t[53];let J;t[54]===re?J=t[55]:(J=(0,$.jsx)(`input`,{className:ne,value:re,onChange:q}),t[54]=re,t[55]=J);let ie;t[56]!==K||t[57]!==J?(ie=(0,$.jsxs)(`div`,{children:[K,J]}),t[56]=K,t[57]=J,t[58]=ie):ie=t[58];let Y;t[59]===s.inputTypes?Y=t[60]:(Y=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.inputTypes}),t[59]=s.inputTypes,t[60]=Y);let ae;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(ae=qe(),t[61]=ae):ae=t[61];let X;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(X=e=>y(`input`,_e(e.target.value)),t[62]=X):X=t[62];let oe;t[63]===s?oe=t[64]:(oe=Ke.map(e=>(0,$.jsx)(d,{value:e.value,children:s[e.labelKey]},e.value)),t[63]=s,t[64]=oe);let Z;t[65]!==O||t[66]!==oe?(Z=(0,$.jsx)(u,{className:ae,value:O,onChange:X,children:oe}),t[65]=O,t[66]=oe,t[67]=Z):Z=t[67];let se;t[68]!==Y||t[69]!==Z?(se=(0,$.jsxs)(`div`,{children:[Y,Z]}),t[68]=Y,t[69]=Z,t[70]=se):se=t[70];let ce=f.reasoning||!1,le;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(le=e=>y(`reasoning`,e.target.checked),t[71]=le):le=t[71];let ue;t[72]===ce?ue=t[73]:(ue=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:ce,onChange:le}),t[72]=ce,t[73]=ue);let de;t[74]!==s.reasoning||t[75]!==ue?(de=(0,$.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[ue,s.reasoning]}),t[74]=s.reasoning,t[75]=ue,t[76]=de):de=t[76];let fe;t[77]!==se||t[78]!==de?(fe=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[se,de]}),t[77]=se,t[78]=de,t[79]=fe):fe=t[79];let pe;t[80]===s.contextWindow?pe=t[81]:(pe=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.contextWindow}),t[80]=s.contextWindow,t[81]=pe);let me;t[82]===m?me=t[83]:(me=v(je(),m.has(`contextWindow`)&&`border-red-500`),t[82]=m,t[83]=me);let he=f.contextWindow??128e3,ge;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(ge=e=>y(`contextWindow`,parseInt(e.target.value,10)||0),t[84]=ge):ge=t[84];let ve;t[85]!==me||t[86]!==he?(ve=(0,$.jsx)(`input`,{type:`number`,min:1,className:me,value:he,onChange:ge}),t[85]=me,t[86]=he,t[87]=ve):ve=t[87];let be;t[88]===m?be=t[89]:(be=m.has(`contextWindow`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:m.get(`contextWindow`)}):null,t[88]=m,t[89]=be);let Se;t[90]!==pe||t[91]!==ve||t[92]!==be?(Se=(0,$.jsxs)(`div`,{children:[pe,ve,be]}),t[90]=pe,t[91]=ve,t[92]=be,t[93]=Se):Se=t[93];let Ce;t[94]===s.maxOutputTokens?Ce=t[95]:(Ce=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.maxOutputTokens}),t[94]=s.maxOutputTokens,t[95]=Ce);let we;t[96]===m?we=t[97]:(we=v(je(),m.has(`maxTokens`)&&`border-red-500`),t[96]=m,t[97]=we);let Te=f.maxTokens??16384,Ee;t[98]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=e=>y(`maxTokens`,parseInt(e.target.value,10)||0),t[98]=Ee):Ee=t[98];let De;t[99]!==we||t[100]!==Te?(De=(0,$.jsx)(`input`,{type:`number`,min:1,className:we,value:Te,onChange:Ee}),t[99]=we,t[100]=Te,t[101]=De):De=t[101];let Oe;t[102]===m?Oe=t[103]:(Oe=m.has(`maxTokens`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:m.get(`maxTokens`)}):null,t[102]=m,t[103]=Oe);let ke;t[104]!==Ce||t[105]!==De||t[106]!==Oe?(ke=(0,$.jsxs)(`div`,{children:[Ce,De,Oe]}),t[104]=Ce,t[105]=De,t[106]=Oe,t[107]=ke):ke=t[107];let Ae;t[108]!==Se||t[109]!==ke?(Ae=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Se,ke]}),t[108]=Se,t[109]=ke,t[110]=Ae):Ae=t[110];let Me;t[111]===s.costSection?Me=t[112]:(Me=(0,$.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:s.costSection}),t[111]=s.costSection,t[112]=Me);let Ne;t[113]===s.costInput?Ne=t[114]:(Ne=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costInput}),t[113]=s.costInput,t[114]=Ne);let Pe;t[115]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=je(),t[115]=Pe):Pe=t[115];let Fe=f.cost?.input??0,Ie;t[116]===f.cost?Ie=t[117]:(Ie=e=>y(`cost`,{...f.cost,input:parseFloat(e.target.value)||0,output:f.cost?.output??0,cacheRead:f.cost?.cacheRead??0,cacheWrite:f.cost?.cacheWrite??0}),t[116]=f.cost,t[117]=Ie);let Le;t[118]!==Fe||t[119]!==Ie?(Le=(0,$.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Pe,value:Fe,onChange:Ie}),t[118]=Fe,t[119]=Ie,t[120]=Le):Le=t[120];let Re;t[121]!==Ne||t[122]!==Le?(Re=(0,$.jsxs)(`div`,{children:[Ne,Le]}),t[121]=Ne,t[122]=Le,t[123]=Re):Re=t[123];let ze;t[124]===s.costOutput?ze=t[125]:(ze=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costOutput}),t[124]=s.costOutput,t[125]=ze);let Be;t[126]===Symbol.for(`react.memo_cache_sentinel`)?(Be=je(),t[126]=Be):Be=t[126];let Ve=f.cost?.output??0,Ue;t[127]===f.cost?Ue=t[128]:(Ue=e=>y(`cost`,{...f.cost,input:f.cost?.input??0,output:parseFloat(e.target.value)||0,cacheRead:f.cost?.cacheRead??0,cacheWrite:f.cost?.cacheWrite??0}),t[127]=f.cost,t[128]=Ue);let We;t[129]!==Ve||t[130]!==Ue?(We=(0,$.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Be,value:Ve,onChange:Ue}),t[129]=Ve,t[130]=Ue,t[131]=We):We=t[131];let Ge;t[132]!==ze||t[133]!==We?(Ge=(0,$.jsxs)(`div`,{children:[ze,We]}),t[132]=ze,t[133]=We,t[134]=Ge):Ge=t[134];let Je;t[135]!==Re||t[136]!==Ge?(Je=(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[Re,Ge]}),t[135]=Re,t[136]=Ge,t[137]=Je):Je=t[137];let Ye;t[138]!==Me||t[139]!==Je?(Ye=(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[Me,Je]}),t[138]=Me,t[139]=Je,t[140]=Ye):Ye=t[140];let Xe;t[141]!==G||t[142]!==ie||t[143]!==fe||t[144]!==Ae||t[145]!==Ye?(Xe=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[G,ie,fe,Ae,Ye]}),t[141]=G,t[142]=ie,t[143]=fe,t[144]=Ae,t[145]=Ye,t[146]=Xe):Xe=t[146];let Ze=c?`高级:电脑控制协议`:`Advanced: Computer Use protocol`,Qe;t[147]===Ze?Qe=t[148]:(Qe=(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:Ze}),t[147]=Ze,t[148]=Qe);let $e=c?`电脑控制协议`:`Computer Use protocol`,et=f.computerUse?.profile??``,tt;t[149]===Symbol.for(`react.memo_cache_sentinel`)?(tt=e=>y(`computerUse`,e.target.value?{profile:e.target.value}:void 0),t[149]=tt):tt=t[149];let nt=c?`未声明`:`Not declared`,rt;t[150]===nt?rt=t[151]:(rt=(0,$.jsx)(d,{value:``,children:nt}),t[150]=nt,t[151]=rt);let it,at;t[152]===Symbol.for(`react.memo_cache_sentinel`)?(it=(0,$.jsx)(d,{value:`gui-plus-2026-02-26`,children:`GUI-Plus (2026-02-26)`}),at=(0,$.jsx)(d,{value:`structured-tools-v1`,children:`structured-tools-v1`}),t[152]=it,t[153]=at):(it=t[152],at=t[153]);let ot;t[154]!==$e||t[155]!==et||t[156]!==rt?(ot=(0,$.jsxs)(u,{"aria-label":$e,value:et,onChange:tt,children:[rt,it,at]}),t[154]=$e,t[155]=et,t[156]=rt,t[157]=ot):ot=t[157];let st=c?`仅适用于已适配的 OpenAI Chat Completions 视觉模型。声明协议不代表模型已通过效果验证。`:`For adapted OpenAI Chat Completions vision models only. Declaring a protocol does not certify model quality.`,ct;t[158]===st?ct=t[159]:(ct=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:st}),t[158]=st,t[159]=ct);let lt;t[160]===m?lt=t[161]:(lt=m.has(`computerUse`)&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:m.get(`computerUse`)}),t[160]=m,t[161]=lt);let ut;t[162]!==ot||t[163]!==ct||t[164]!==lt?(ut=(0,$.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[ot,ct,lt]}),t[162]=ot,t[163]=ct,t[164]=lt,t[165]=ut):ut=t[165];let dt;t[166]!==Qe||t[167]!==ut?(dt=(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge p-3 text-sm text-fg`,children:[Qe,ut]}),t[166]=Qe,t[167]=ut,t[168]=dt):dt=t[168];let ft;t[169]!==Xe||t[170]!==dt?(ft=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-1`,children:[Xe,dt]}),t[169]=Xe,t[170]=dt,t[171]=ft):ft=t[171];let pt;t[172]===s.cancel?pt=t[173]:(pt=(0,$.jsx)(D,{asChild:!0,children:(0,$.jsx)(N,{type:`button`,variant:`secondary`,children:s.cancel})}),t[172]=s.cancel,t[173]=pt);let mt=r?s.addModelConfirm:s.saveModelConfirm,ht;t[174]!==w||t[175]!==mt?(ht=(0,$.jsx)(N,{type:`button`,variant:`primary`,className:`hover:bg-accent/90`,onClick:w,children:mt}),t[174]=w,t[175]=mt,t[176]=ht):ht=t[176];let gt;t[177]!==pt||t[178]!==ht?(gt=(0,$.jsxs)(`div`,{className:`mt-4 flex shrink-0 justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[pt,ht]}),t[177]=pt,t[178]=ht,t[179]=gt):gt=t[179];let _t;return t[180]!==L||t[181]!==ft||t[182]!==gt?(_t=(0,$.jsxs)($.Fragment,{children:[L,ft,gt]}),t[180]=L,t[181]=ft,t[182]=gt,t[183]=_t):_t=t[183],_t}function $n(){return new Map}function er(e){return e.language}function tr(e){let t=(0,Rt.c)(16),{open:n,onOpenChange:r,providerId:i,model:a,isNew:o,onSave:s,m:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(T,{className:v(`xopc-dialog-overlay fixed inset-0 bg-scrim`,L)}),t[0]=l):l=t[0];let u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=v(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(90vh,720px)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 flex-col`,I,`overflow-hidden rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`),t[1]=u):u=t[1];let d;t[2]!==o||t[3]!==c||t[4]!==a||t[5]!==r||t[6]!==s||t[7]!==n||t[8]!==i?(d=n?(0,$.jsx)(Qn,{model:a,isNew:o,providerId:i,onSave:s,onClose:()=>r(!1),m:c},`${i??`none`}-${a?.id??`new`}`):null,t[2]=o,t[3]=c,t[4]=a,t[5]=r,t[6]=s,t[7]=n,t[8]=i,t[9]=d):d=t[9];let f;t[10]===d?f=t[11]:(f=(0,$.jsxs)(O,{children:[l,(0,$.jsx)(k,{className:u,onOpenAutoFocus:nr,children:d})]}),t[10]=d,t[11]=f);let p;return t[12]!==r||t[13]!==n||t[14]!==f?(p=(0,$.jsx)(j,{open:n,onOpenChange:r,children:f}),t[12]=r,t[13]=n,t[14]=f,t[15]=p):p=t[15],p}function nr(e){return e.preventDefault()}function rr(e){let t=(0,Rt.c)(14),{providerId:n,inputId:r,value:i,onChange:a,labels:o}=e,s;t[0]===n?s=t[1]:(s=()=>W(n).then(ir),t[0]=n,t[1]=s);let c=s,l;t[2]!==r||t[3]!==o.apiKeyLabel?(l=(0,$.jsx)(`label`,{htmlFor:r,className:`text-sm font-medium text-fg`,children:o.apiKeyLabel}),t[2]=r,t[3]=o.apiKeyLabel,t[4]=l):l=t[4];let u;t[5]!==r||t[6]!==o||t[7]!==a||t[8]!==c||t[9]!==i?(u=(0,$.jsx)(ve,{id:r,value:i,onChange:a,placeholder:o.apiKeyPlaceholder,labels:o,reveal:c,loadFailedLabel:o.loadFailed,maskedHelp:o.maskedHelp,notInConfigFile:o.notInConfigFile}),t[5]=r,t[6]=o,t[7]=a,t[8]=c,t[9]=i,t[10]=u):u=t[10];let d;return t[11]!==l||t[12]!==u?(d=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[l,u]}),t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function ir(e){return e.apiKey??null}function ar(e){let t=(0,Rt.c)(16),{open:n,onOpenChange:r,providerId:i,isCustom:a,builtinRows:o,customConfig:s,allModels:c,labels:l,language:u,onSaved:d}=e,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(T,{className:v(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,L)}),t[0]=f):f=t[0];let p;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(p=v(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(85vh,720px)] w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`,I),t[1]=p):p=t[1];let m;t[2]!==c||t[3]!==o||t[4]!==s||t[5]!==a||t[6]!==l||t[7]!==u||t[8]!==r||t[9]!==d||t[10]!==i?(m=(0,$.jsxs)(O,{children:[f,(0,$.jsx)(k,{className:p,children:a?(0,$.jsx)(sr,{providerId:i,customConfig:s,labels:l,language:u,onClose:()=>r(!1),onSaved:d}):(0,$.jsx)(or,{providerId:i,builtinRows:o,allModels:c,labels:l,language:u,onClose:()=>r(!1),onSaved:d})})]}),t[2]=c,t[3]=o,t[4]=s,t[5]=a,t[6]=l,t[7]=u,t[8]=r,t[9]=d,t[10]=i,t[11]=m):m=t[11];let h;return t[12]!==r||t[13]!==n||t[14]!==m?(h=(0,$.jsx)(j,{open:n,onOpenChange:r,children:m}),t[12]=r,t[13]=n,t[14]=m,t[15]=h):h=t[15],h}function or({providerId:e,builtinRows:t,allModels:n,labels:r,language:i,onClose:a,onSaved:o}){let s=t.find(t=>t.id===e),c=Ze[e],u=n.filter(t=>t.provider===e),[d,f]=(0,Q.useState)(!1),[g,y]=(0,Q.useState)(s?.apiKey??``),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(!1),j=w(i).providersSettings,M=s?.supportsApiKey!==!1,P=s?.supportsOAuth===!0,ee=s?.authMode===`oauth`&&s.authStatus===`connected`,F=s?.configured===!0&&s.activeKeySource!==`env`&&s.activeKeySource!==`extension`&&s.activeKeySource!==`models_json`,[I,L]=(0,Q.useState)(null),[R,z]=(0,Q.useState)(null),[B,V]=(0,Q.useState)(`idle`),[H,U]=(0,Q.useState)(null),[W,G]=(0,Q.useState)(null),[re,q]=(0,Q.useState)(null),[J,ie]=(0,Q.useState)(``),Y=(0,Q.useRef)(null),ae=(0,Q.useRef)(null),X=B===`waiting`||B===`waiting_code`,oe=(0,Q.useMemo)(()=>Se(e,i),[e,i]),Z=g!==(s?.apiKey??``),se=async()=>{let t=g.trim();if(!(!t||!M||fe(t))){x(!0),E(null);try{await ne({[e]:t}),C(!0),window.setTimeout(()=>{o(),a()},600)}catch(e){E(e instanceof Error?e.message:r.saveError)}finally{x(!1)}}};(0,Q.useEffect)(()=>{if(!I||!X)return;let e=window.setInterval(()=>{(async()=>{try{let t=await st(I);t.status===`waiting_auth`||t.status===`waiting_code`?(V(t.status===`waiting_code`?`waiting_code`:`waiting`),z(t.message??null),U(t.authUrl??null),G(t.instructions??null),q(t.deviceCode??null),t.authUrl&&t.authUrl!==ae.current&&(ae.current=t.authUrl,ze(t.authUrl,Y.current).catch(()=>{}))):t.status===`completed`?(window.clearInterval(e),We(Y.current),Y.current=null,V(`success`),z(t.message??j.saved),window.setTimeout(()=>{o(),a()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),We(Y.current),Y.current=null,V(`error`),z(t.error??t.message??j.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[I,X,a,o,j.revokeFailed,j.saved]),(0,Q.useEffect)(()=>()=>{I&&et(I).catch(()=>{})},[I]),(0,Q.useEffect)(()=>()=>{We(Y.current),Y.current=null},[]);let ce=async()=>{try{await te(e),o(),a()}catch{}},le=async()=>{We(Y.current),Y.current=Oe(),ae.current=null,V(`waiting`),z(j.oauthStarting),U(null),G(null),q(null),E(null);try{L((await ot(e)).sessionId)}catch(e){We(Y.current),Y.current=null,V(`error`),z(e instanceof Error?e.message:j.revokeFailed)}},de=async()=>{if(I){try{await ge(I)}catch{}We(Y.current),Y.current=null,ae.current=null,V(`idle`),z(null),L(null),U(null),G(null),q(null)}},pe=async()=>{if(!(!I||!J.trim()))try{await ue(I,J.trim()),ie(``),z(j.oauthProcessingCode)}catch(e){V(`error`),z(e instanceof Error?e.message:j.revokeFailed)}},he=async()=>{try{await be(e),o(),a()}catch(e){E(e instanceof Error?e.message:j.revokeFailed)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(A,{className:`text-base font-semibold text-fg`,children:s?.name??e}),(0,$.jsx)(D,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:v(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,at.press),children:(0,$.jsx)(_,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[c?.description?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:c.description}):null,s?.baseUrl?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.apiUrlLabel}),(0,$.jsx)(`code`,{className:`break-all rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 font-mono text-xs text-fg-muted`,children:s.baseUrl})]}):s?.category===`extension`?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.apiUrlExtensionHint}):null,M?(0,$.jsx)(rr,{providerId:e,inputId:`manage-api-key`,value:g,onChange:e=>{y(e),C(!1)},labels:{apiKeyLabel:r.apiKeyLabel,apiKeyPlaceholder:r.apiKeyPlaceholder,maskedHelp:r.maskedHelp,copy:r.copy,copied:r.copied,show:r.showKey,hide:r.hideKey,notInConfigFile:r.notInConfigFile,loadFailed:r.loadFailed}}):s?.category===`extension`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{children:r.extensionKeyHint}),s?.extensionId?(0,$.jsxs)(l,{to:`/settings/ext/${encodeURIComponent(s.extensionId)}`,className:`inline-flex w-fit items-center gap-1 font-medium text-accent hover:underline`,title:r.extensionSettingsLinkTitle,onClick:a,children:[r.openExtensionSettings,(0,$.jsx)(m,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,P?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:j.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:ee?j.sourceOauth:j.oauthHint})]}),ee?(0,$.jsx)(N,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void he(),children:j.revoke}):(0,$.jsxs)(N,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:X,onClick:()=>void le(),children:[X?(0,$.jsx)(h,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Te,{className:`size-3.5`,"aria-hidden":!0}),j.oauth]})]}),R?(0,$.jsx)(`p`,{className:v(`text-xs`,B===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:R}):null,B===`waiting`||B===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[H?(0,$.jsxs)(`a`,{href:H,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-2 text-sm font-medium text-on-accent hover:bg-accent-hover`,children:[(0,$.jsx)(m,{className:`size-4`,"aria-hidden":!0}),j.openAuthPage]}):null,(0,$.jsx)(N,{type:`button`,variant:`secondary`,onClick:()=>void de(),children:j.cancelOAuth})]}):null,W?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:W}):null,re?(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:j.deviceCodeLabel}),(0,$.jsx)(`code`,{className:`mt-1 block select-all font-mono text-lg font-semibold tracking-widest text-fg`,children:re}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:j.deviceCodeHint})]}):null,B===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:J,onChange:e=>ie(e.target.value),onKeyDown:e=>e.key===`Enter`&&void pe(),placeholder:j.pasteRedirectUrl,className:v(`min-w-0 flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,K)}),(0,$.jsx)(N,{type:`button`,variant:`primary`,onClick:()=>void pe(),children:j.submitCode})]}):null]}):null,oe.length>0&&M?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:oe.map(({kind:e,href:t})=>(0,$.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[De(e,r),(0,$.jsx)(m,{className:`size-3`,"aria-hidden":!0})]},e))}):null,u.length>0?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-medium text-fg`,children:[r.modelsLabel,` (`,u.length,`)`]}),(0,$.jsxs)(`label`,{className:`mb-2 flex items-center gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:d,onChange:e=>f(e.target.checked)}),i===`zh`?`仅电脑控制模型`:`Computer Use only`]}),(0,$.jsx)(`div`,{className:`max-h-40 overflow-y-auto rounded-lg border border-edge-subtle bg-surface-panel/40 p-2`,children:(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:u.filter(e=>!d||e.computerUse).map(e=>(0,$.jsxs)(`span`,{className:`inline-block rounded-md bg-surface-hover px-2 py-1 text-xs text-fg-muted`,children:[Xe(e,i),e.computerUse?` · Computer Use`:``]},e.id))})})]}):(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.noModels}),T?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:T}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[F?(0,$.jsxs)(N,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>k(!0),children:[(0,$.jsx)(Be,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:M&&Z&&!fe(g.trim())?(0,$.jsx)(N,{type:`button`,variant:`primary`,disabled:!g.trim()||b||S,onClick:()=>void se(),children:S?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(p,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):b?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(h,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,$.jsx)(me,{open:O,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,s?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void ce(),onCancel:()=>k(!1)})]})}function sr({providerId:e,customConfig:t,labels:n,language:r,onClose:i,onSaved:a}){let o=w(r).modelsSettings,s=t?.providers[e],[c,l]=(0,Q.useState)(s?.baseUrl??``),[u,d]=(0,Q.useState)(s?.apiKey??``),[f,p]=(0,Q.useState)(s?.models??[]),[m,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(s?.modelDiscovery?.enabled===!0),[S,C]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(null),[P,ee]=(0,Q.useState)(!1),[F,I]=(0,Q.useState)(null),L=n=>{if(!t)return null;let r=u.trim(),i={...s,baseUrl:c.trim()||void 0,apiKey:fe(r)?s?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},R=async()=>{let e=L({models:f,modelDiscovery:{enabled:b}});if(e){C(!0),E(null);try{await Ie(e),a(),i()}catch(e){E(e instanceof Error?e.message:n.saveError)}finally{C(!1)}}},z=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await Ie({providers:r}),a(),i()}catch{}},B=(e,t)=>{I({model:e,isNew:t}),ee(!0)},V=async e=>{if(!F)return;let t=F.isNew?[...f,e]:f.map(t=>t.id===e.id?e:t);p(t);let r=L({models:t});if(r)try{await Ie(r),a()}catch(e){E(e instanceof Error?e.message:n.saveError)}},H=async e=>{let t=f.filter(t=>t.id!==e);p(t),M(null);let r=L({models:t});if(r)try{await Ie(r),a()}catch(e){E(e instanceof Error?e.message:n.saveError)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(A,{className:`text-base font-semibold text-fg`,children:e}),(0,$.jsx)(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:n.custom})]}),(0,$.jsx)(D,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:v(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,at.press),children:(0,$.jsx)(_,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`manage-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,$.jsx)(`input`,{id:`manage-base-url`,type:`url`,autoComplete:`off`,value:c,onChange:e=>l(e.target.value),className:v(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,K)})]}),(0,$.jsx)(rr,{providerId:e,inputId:`manage-custom-api-key`,value:u,onChange:d,labels:{apiKeyLabel:n.apiKeyLabel,apiKeyPlaceholder:n.apiKeyPlaceholder,maskedHelp:n.maskedHelp,copy:n.copy,copied:n.copied,show:n.showKey,hide:n.hideKey,notInConfigFile:n.notInConfigFile,loadFailed:n.loadFailed}}),(0,$.jsxs)(`label`,{className:`flex items-start gap-3 rounded-xl border border-edge-subtle bg-surface-panel/40 p-3`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:b,onChange:e=>x(e.target.checked),className:`mt-0.5 size-4 rounded border-edge accent-accent`}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:r===`zh`?`自动同步模型目录`:`Automatically sync model catalog`}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-muted`,children:r===`zh`?`启动时及定时从此服务的 /models 接口更新模型。`:`Update models from this service’s /models endpoint at startup and on schedule.`})]})]}),(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-semibold text-fg`,children:[o.modelsSection,f.length>0?` (${f.length})`:``]}),(0,$.jsxs)(N,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>B(null,!0),children:[(0,$.jsx)(g,{className:`size-3.5`,"aria-hidden":!0}),o.addModel]})]}),(0,$.jsxs)(`label`,{className:`mb-2 flex items-center gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:m,onChange:e=>y(e.target.checked)}),r===`zh`?`仅电脑控制模型`:`Computer Use only`]}),f.filter(e=>!m||e.computerUse).length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:o.modelsEmpty}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:f.filter(e=>!m||e.computerUse).map(e=>(0,$.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-lg border border-edge-subtle bg-surface-panel/40 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.id}),e.computerUse&&(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Computer Use`}),e.name&&e.name!==e.id?(0,$.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:e.name}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,className:v(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,at.press),onClick:()=>B(e,!1),"aria-label":o.editModel,children:(0,$.jsx)(pe,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,className:v(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-red-600 dark:hover:text-red-400`,at.press),onClick:()=>M(e.id),"aria-label":o.removeModel,children:(0,$.jsx)(Be,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),T?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:T}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsxs)(N,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>k(!0),children:[(0,$.jsx)(Be,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(N,{type:`button`,variant:`primary`,disabled:S,onClick:()=>void R(),children:S?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(h,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,$.jsx)(me,{open:O,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void z(),onCancel:()=>k(!1)}),(0,$.jsx)(me,{open:j!==null,title:o.removeModel,description:o.removeModelConfirm.replace(`{{id}}`,j??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{j&&H(j)},onCancel:()=>M(null)}),(0,$.jsx)(tr,{open:P,onOpenChange:e=>{ee(e),e||I(null)},providerId:e,model:F?.model??null,isNew:F?.isNew??!1,onSave:e=>void V(e),m:o})]})}function cr(e){return e.status===`ready`?`ready`:e.status===`disabled`?`off`:e.status===`degraded`?`degraded`:e.rejected?.length?`misconfigured`:`not-configured`}function lr(e,t){switch(e){case`computer-use`:return{href:`/settings/computer-use`,guidance:t?`选择兼容的电脑控制模型;本机权限需单独授权`:`Select a compatible computer model; local access requires separate approval`,action:t?`配置电脑控制`:`Configure computer use`};case`vision`:return{href:`${Ue(`models`)}?add=1`,guidance:t?`接入支持图片理解的模型服务`:`Connect a model service that supports vision`,action:t?`去接入模型`:`Connect model`};case`image-generation`:return{href:Ue(`image`),guidance:t?`选择图片模型并配置所需凭据`:`Choose an image model and configure its credentials`,action:t?`去配置图片生成`:`Configure image generation`};case`stt`:return{href:Ue(`voice`),guidance:t?`选择语音识别服务,或安装本地语音模型`:`Choose a speech-to-text service or install a local voice model`,action:t?`去配置语音识别`:`Configure speech-to-text`};case`tts`:return{href:Ue(`voice`),guidance:t?`选择语音合成服务并完成凭据配置`:`Choose a text-to-speech service and configure its credentials`,action:t?`去配置语音合成`:`Configure text-to-speech`}}}function ur(e){switch(e){case`computer-use`:return`/settings/computer-use`;case`vision`:return Ue(`models`);case`image-generation`:return Ue(`image`);case`stt`:case`tts`:return Ue(`voice`)}}async function dr(){let e=await x(C(`/api/models/catalog`)),t=await e.json().catch(()=>null);if(!e.ok||!t?.ok||!t.payload)throw Error(t?.error?.message??`HTTP ${e.status}`);return t.payload}async function fr(){let e=await x(C(`/api/capabilities/readiness`)),t=await e.json().catch(()=>null);if(!e.ok||!t?.ok||!t.payload)throw Error(t?.error?.message??`HTTP ${e.status}`);return t.payload}function pr(){let e=S(e=>e.language)===`zh`,{data:t,error:n,isLoading:r}=M(Fe,dr,{revalidateOnFocus:!1}),{data:i}=M(oe,fr,{revalidateOnFocus:!1}),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null);if(r)return(0,$.jsx)(F,{className:`h-24 w-full rounded-2xl`});let u=Object.values(t?.sources??{}),d=u.reduce((e,t)=>e+t.models.filter(e=>e.availability===`available`).length,0),f=(t?.references??[]).filter(e=>e.availability===`unavailable`),m=t?.sync.lastSuccessAt??Math.max(0,...u.map(e=>e.lastSuccessAt)),g=s??(n instanceof Error?n.message:t?.sync.lastError??Object.values(t?.sync.sourceErrors??{})[0]),_=Object.entries(i?.capabilities??{}).filter(([e])=>e!==`computer-use`||R()),y=_.some(([,e])=>{let t=cr(e);return t===`degraded`||t===`misconfigured`}),b=_.filter(([,e])=>cr(e)===`ready`).length,w=async()=>{o(!0),c(null);try{let e=await x(C(`/api/models/catalog/refresh`),{method:`POST`});if(!e.ok)throw Error(`HTTP ${e.status}`);await V()}catch(t){c(t instanceof Error?t.message:e?`模型目录刷新失败`:`Model catalog refresh failed`)}finally{o(!1)}};return(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/25 p-4 sm:p-5`,children:[(0,$.jsxs)(`details`,{className:`group`,open:y||void 0,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer list-none rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsxs)(`div`,{className:`flex min-h-10 items-center gap-2`,children:[y?(0,$.jsx)(Je,{className:`size-4 text-amber-500`,"aria-hidden":!0}):b===_.length&&_.length>0?(0,$.jsx)(p,{className:`size-4 text-emerald-500`,"aria-hidden":!0}):(0,$.jsx)(G,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:e?`可选能力`:`Optional capabilities`}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs font-normal text-fg-muted`,children:e?`${b}/${_.length} 项已配置,不影响基础聊天功能`:`${b} of ${_.length} configured · Not required for chat`})]}),(0,$.jsx)(H,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-open:rotate-90 motion-reduce:transition-none`,"aria-hidden":!0})]})}),i?(0,$.jsx)(`div`,{className:`mt-3 grid gap-1 sm:grid-cols-2`,children:Object.entries(i.capabilities).map(([t,n])=>{if(t===`computer-use`&&!R())return null;let r=t===`vision`?e?`图片理解`:`Vision`:t===`image-generation`?e?`图片生成`:`Image generation`:t===`computer-use`?e?`电脑控制模型`:`Computer use model`:t.toUpperCase(),i=n.selectionSource!==`explicit-config`,a=cr(n),o=a===`degraded`||a===`misconfigured`,s=lr(t,e),c=(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 text-xs font-medium text-fg`,children:r}),(0,$.jsx)(`span`,{className:a===`ready`?`shrink-0 text-xs text-emerald-600 dark:text-emerald-400`:a===`off`||a===`not-configured`?`shrink-0 text-xs text-fg-muted`:`shrink-0 text-xs text-amber-600 dark:text-amber-400`,children:a===`ready`?t===`computer-use`?e?`已配置`:`Configured`:e?`可用`:`Ready`:a===`off`?e?`已关闭`:`Off`:a===`not-configured`?e?`未配置`:`Not configured`:a===`degraded`?e?`正在使用备用方案`:`Using fallback`:e?`需处理`:`Needs attention`})]}),(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,title:n.primary?`${n.primary.provider}/${n.primary.model}`:void 0,children:n.primary?`${i?e?`自动`:`Auto`:e?`显式`:`Explicit`} · ${n.primary.provider}/${n.primary.model}`:a===`not-configured`?e?`可稍后按需配置`:`Set up later if needed`:e?`已配置的模型不可用`:`The configured model is unavailable`}),o?(0,$.jsxs)(`div`,{className:`mt-2 rounded-lg bg-amber-500/10 p-2`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-5 text-amber-700 dark:text-amber-300`,children:n.status===`degraded`?e?`当前配置不可用,正在使用备用方案。${s.guidance}`:`The current configuration is unavailable, so a fallback is in use. ${s.guidance}.`:s.guidance}),(0,$.jsxs)(`span`,{className:`mt-1 inline-flex items-center gap-1 text-xs font-medium text-accent`,children:[s.action,(0,$.jsx)(J,{className:`size-3.5`,"aria-hidden":!0})]})]}):null]});return(0,$.jsx)(l,{to:o?s.href:ur(t),"aria-label":o?`${r}:${s.action}`:`${e?`配置`:`Configure`} ${r}`,className:v(`rounded-lg bg-surface-base/45 px-3 py-3 transition-colors`,o?`bg-amber-500/5 hover:bg-amber-500/10`:`hover:bg-surface-hover/30`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:c},t)})}):null]}),f.length>0?(0,$.jsx)(`div`,{className:`mt-2 space-y-1 text-sm text-amber-700 dark:text-amber-300`,children:f.slice(0,3).map(t=>(0,$.jsxs)(`p`,{children:[t.ref,` `,e?`不可用`:`is unavailable`,t.suggestedRef?` · ${e?`建议`:`Suggested`} ${t.suggestedRef}`:``,` · ${t.locations.length} ${e?`处引用`:`references`}`]},t.ref))}):null,g?(0,$.jsx)(`p`,{className:`mt-3 text-sm text-danger`,role:`alert`,children:g}):null,(0,$.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-3`,children:[(0,$.jsx)(`summary`,{className:`min-h-8 cursor-pointer rounded-md py-1.5 text-xs font-medium text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:e?`高级诊断`:`Advanced diagnostics`}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e?`${u.length} 个来源,${d} 个可用模型${m?` · 最近同步 ${new Date(m).toLocaleString()}`:``}`:`${u.length} sources, ${d} available models${m?` · Last synced ${new Date(m).toLocaleString()}`:``}`}),(0,$.jsxs)(N,{className:`shrink-0`,type:`button`,variant:`secondary`,disabled:a,onClick:()=>void w(),children:[a?(0,$.jsx)(h,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Y,{className:`size-4`,"aria-hidden":!0}),a?e?`刷新中…`:`Refreshing…`:e?`刷新目录`:`Refresh catalog`]})]})]})]})}async function mr(){return(await y(C(`/api/models/xopc-cloud/account-summary`))).payload}function hr(e){let t=(0,Rt.c)(99),{labels:n}=e,r=S(gr)===`zh`?`zh-CN`:`en-US`,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={refreshInterval:6e4,revalidateOnFocus:!0},t[0]=i):i=t[0];let{data:a,error:o,isLoading:s,isValidating:c,mutate:l}=M(`/api/models/xopc-cloud/account-summary`,mr,i);if(s){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(F,{className:`h-40 w-full rounded-xl`}),t[1]=e):e=t[1],e}if(o||!a){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Je,{className:`mt-0.5 size-4 shrink-0 text-amber-500`,"aria-hidden":!0}),t[2]=e):e=t[2];let r;t[3]===n.title?r=t[4]:(r=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.title}),t[3]=n.title,t[4]=r);let i;t[5]===n.unavailable?i=t[6]:(i=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.unavailable}),t[5]=n.unavailable,t[6]=i);let a;t[7]!==r||t[8]!==i?(a=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[e,(0,$.jsxs)(`div`,{children:[r,i]})]}),t[7]=r,t[8]=i,t[9]=a):a=t[9];let o;t[10]===l?o=t[11]:(o=()=>void l(),t[10]=l,t[11]=o);let s=c?`size-4 animate-spin`:`size-4`,u;t[12]===s?u=t[13]:(u=(0,$.jsx)(Y,{className:s,"aria-hidden":!0}),t[12]=s,t[13]=u);let d;t[14]!==c||t[15]!==n.retry||t[16]!==o||t[17]!==u?(d=(0,$.jsxs)(N,{type:`button`,variant:`secondary`,disabled:c,onClick:o,children:[u,n.retry]}),t[14]=c,t[15]=n.retry,t[16]=o,t[17]=u,t[18]=d):d=t[18];let f;return t[19]!==a||t[20]!==d?(f=(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/25 p-4`,children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[a,d]})}),t[19]=a,t[20]=d,t[21]=f):f=t[21],f}let u,d,f,p,h,g,_;if(t[22]!==a.balance.credits||t[23]!==a.links.details||t[24]!==a.links.purchase||t[25]!==a.usage.chargedCredits||t[26]!==a.usage.requests||t[27]!==a.usage.totalTokens||t[28]!==n.availableCredits||t[29]!==n.connected||t[30]!==n.details||t[31]!==n.purchase||t[32]!==n.title||t[33]!==n.usageSummary||t[34]!==r){let e=new Intl.NumberFormat(r);_=n.usageSummary.replace(`{{tokens}}`,e.format(a.usage.totalTokens)).replace(`{{credits}}`,e.format(a.usage.chargedCredits)).replace(`{{requests}}`,e.format(a.usage.requests)),h=`rounded-xl bg-surface-hover/40 p-4 sm:p-5`;let i;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(ke,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),t[42]=i):i=t[42];let o;t[43]===n.title?o=t[44]:(o=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.title}),t[43]=n.title,t[44]=o);let s;t[45]===n.connected?s=t[46]:(s=(0,$.jsx)(`span`,{className:`rounded-full bg-emerald-500/10 px-2 py-0.5 text-xs font-medium text-emerald-700 dark:text-emerald-300`,children:n.connected}),t[45]=n.connected,t[46]=s);let c;t[47]!==s||t[48]!==o?(c=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[i,o,s]}),t[47]=s,t[48]=o,t[49]=c):c=t[49];let l;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),t[50]=l):l=t[50];let v;t[51]!==a.links.purchase||t[52]!==n.purchase?(v=(0,$.jsx)(N,{asChild:!0,variant:`primary`,children:(0,$.jsxs)(`a`,{href:a.links.purchase,target:`_blank`,rel:`noreferrer`,children:[n.purchase,l]})}),t[51]=a.links.purchase,t[52]=n.purchase,t[53]=v):v=t[53];let y;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),t[54]=y):y=t[54];let b;t[55]!==a.links.details||t[56]!==n.details?(b=(0,$.jsx)(N,{asChild:!0,variant:`secondary`,children:(0,$.jsxs)(`a`,{href:a.links.details,target:`_blank`,rel:`noreferrer`,children:[n.details,y]})}),t[55]=a.links.details,t[56]=n.details,t[57]=b):b=t[57];let x;t[58]!==v||t[59]!==b?(x=(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[v,b]}),t[58]=v,t[59]=b,t[60]=x):x=t[60],t[61]!==c||t[62]!==x?(g=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[c,x]}),t[61]=c,t[62]=x,t[63]=g):g=t[63],p=`mt-4 grid gap-4 rounded-lg bg-surface-base/45 p-3 sm:grid-cols-[minmax(12rem,0.7fr)_minmax(0,1.3fr)] sm:gap-6`,t[64]===n.availableCredits?f=t[65]:(f=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:n.availableCredits}),t[64]=n.availableCredits,t[65]=f),u=`mt-1 text-2xl font-semibold tracking-tight text-fg`,d=e.format(a.balance.credits),t[22]=a.balance.credits,t[23]=a.links.details,t[24]=a.links.purchase,t[25]=a.usage.chargedCredits,t[26]=a.usage.requests,t[27]=a.usage.totalTokens,t[28]=n.availableCredits,t[29]=n.connected,t[30]=n.details,t[31]=n.purchase,t[32]=n.title,t[33]=n.usageSummary,t[34]=r,t[35]=u,t[36]=d,t[37]=f,t[38]=p,t[39]=h,t[40]=g,t[41]=_}else u=t[35],d=t[36],f=t[37],p=t[38],h=t[39],g=t[40],_=t[41];let v;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(`span`,{className:`ml-2 text-sm font-medium text-fg-muted`,children:`credits`}),t[66]=v):v=t[66];let y;t[67]!==u||t[68]!==d?(y=(0,$.jsxs)(`p`,{className:u,children:[d,v]}),t[67]=u,t[68]=d,t[69]=y):y=t[69];let b;t[70]!==a.balance.credits||t[71]!==n.zeroBalance?(b=a.balance.credits===0?(0,$.jsx)(`p`,{className:`mt-1 text-sm font-medium text-danger`,children:n.zeroBalance}):null,t[70]=a.balance.credits,t[71]=n.zeroBalance,t[72]=b):b=t[72];let x;t[73]!==b||t[74]!==f||t[75]!==y?(x=(0,$.jsxs)(`div`,{children:[f,y,b]}),t[73]=b,t[74]=f,t[75]=y,t[76]=x):x=t[76];let C;t[77]===n.recentUsage?C=t[78]:(C=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:n.recentUsage}),t[77]=n.recentUsage,t[78]=C);let w;t[79]===_?w=t[80]:(w=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:_}),t[79]=_,t[80]=w);let T;t[81]!==a.balance.updatedAt||t[82]!==n.updatedAt||t[83]!==r?(T=n.updatedAt.replace(`{{time}}`,new Date(a.balance.updatedAt).toLocaleString(r)),t[81]=a.balance.updatedAt,t[82]=n.updatedAt,t[83]=r,t[84]=T):T=t[84];let E;t[85]===T?E=t[86]:(E=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:T}),t[85]=T,t[86]=E);let D;t[87]!==C||t[88]!==w||t[89]!==E?(D=(0,$.jsxs)(`div`,{children:[C,w,E]}),t[87]=C,t[88]=w,t[89]=E,t[90]=D):D=t[90];let O;t[91]!==x||t[92]!==D||t[93]!==p?(O=(0,$.jsxs)(`div`,{className:p,children:[x,D]}),t[91]=x,t[92]=D,t[93]=p,t[94]=O):O=t[94];let k;return t[95]!==O||t[96]!==h||t[97]!==g?(k=(0,$.jsxs)(`section`,{className:h,children:[g,O]}),t[95]=O,t[96]=h,t[97]=g,t[98]=k):k=t[98],k}function gr(e){return e.language}function _r(e){return Ee.includes(e)}function vr(){let e=(0,Rt.c)(69),t=S(xr),n;e[0]===t?n=e[1]:(n=w(t),e[0]=t,e[1]=n);let r=n,i=r.capabilitiesSettings,u=a(),[d,f]=o(),p;if(e[2]!==d){let t=d.get(`returnTo`);p=t?.startsWith(`/chat/`)?t:null,e[2]=d,e[3]=p}else p=e[3];let m=p,{capability:h}=s(),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null),b=Ye(),x;e[4]===b.cards?x=e[5]:(x=b.cards.some(br),e[4]=b.cards,e[5]=x);let C=x,T,E;e[6]!==h||e[7]!==d||e[8]!==f?(T=()=>{if(h!==`models`||d.get(`add`)!==`1`)return;_(!0);let e=new URLSearchParams(d);e.delete(`add`),f(e,{replace:!0})},E=[h,d,f],e[6]=h,e[7]=d,e[8]=f,e[9]=T,e[10]=E):(T=e[9],E=e[10]),(0,Q.useEffect)(T,E);let D;e[11]===i.tabs.models?D=e[12]:(D={id:`models`,icon:ct,label:i.tabs.models},e[11]=i.tabs.models,e[12]=D);let O;e[13]===i.tabs.image?O=e[14]:(O={id:`image`,icon:Z,label:i.tabs.image},e[13]=i.tabs.image,e[14]=O);let k;e[15]!==D||e[16]!==O?(k=[D,O],e[15]=D,e[16]=O,e[17]=k):k=e[17];let A=k,j;e[18]===u?j=e[19]:(j=e=>u(Ue(e)),e[18]=u,e[19]=j);let M=j,N=yr;if(!_r(h)){let t;return e[20]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(c,{to:Ue(`models`),replace:!0}),e[20]=t):t=e[20],t}let P=h===`models`||h===`image`,ee=h===`voice`?r.nav.settingsVoice:h===`search`?r.nav.settingsSearch:r.nav.settingsModels,F;e[21]===t?F=e[22]:(F=Re(t,`configuration`),e[21]=t,e[22]=F);let I;e[23]!==i.docsLink||e[24]!==ee||e[25]!==F?(I=(0,$.jsx)(lt,{title:ee,docsLink:F,docsLabel:i.docsLink}),e[23]=i.docsLink,e[24]=ee,e[25]=F,e[26]=I):I=e[26];let L;e[27]!==h||e[28]!==m||e[29]!==t?(L=h===`voice`&&m?(0,$.jsx)(l,{to:m,className:`text-sm text-accent-fg hover:underline`,children:t===`zh`?`返回对话`:`Return to conversation`}):null,e[27]=h,e[28]=m,e[29]=t,e[30]=L):L=e[30];let R;e[31]!==i.tabsAria||e[32]!==h||e[33]!==P||e[34]!==A||e[35]!==M?(R=P?(0,$.jsx)(At,{items:A,activeTab:h,onChange:M,ariaLabel:i.tabsAria,tabIdPrefix:`capability-tab`,panelIdPrefix:`capability-panel`}):null,e[31]=i.tabsAria,e[32]=h,e[33]=P,e[34]=A,e[35]=M,e[36]=R):R=e[36];let z=P?`tabpanel`:void 0,B=`capability-panel-${h}`,V=P?`capability-tab-${h}`:void 0,H;e[37]!==i.connectedProviders||e[38]!==i.xopcCloudAccount||e[39]!==h||e[40]!==b||e[41]!==C?(H=h===`models`?(0,$.jsxs)($.Fragment,{children:[C?(0,$.jsx)(hr,{labels:i.xopcCloudAccount}):null,(0,$.jsx)(Ce,{labels:i.connectedProviders,data:b,onAdd:()=>_(!0),onManage:(e,t)=>y({providerId:e,isCustom:t})}),b.cards.length>0?(0,$.jsx)(pr,{}):null]}):(0,$.jsx)(Sr,{section:h}),e[37]=i.connectedProviders,e[38]=i.xopcCloudAccount,e[39]=h,e[40]=b,e[41]=C,e[42]=H):H=e[42];let U;e[43]!==z||e[44]!==B||e[45]!==V||e[46]!==H?(U=(0,$.jsx)(`div`,{role:z,id:B,"aria-labelledby":V,className:`flex min-w-0 flex-col gap-4`,children:H}),e[43]=z,e[44]=B,e[45]=V,e[46]=H,e[47]=U):U=e[47];let te;e[48]===Symbol.for(`react.memo_cache_sentinel`)?(te=()=>N(),e[48]=te):te=e[48];let W;e[49]!==g||e[50]!==i.addProviderDialog||e[51]!==t||e[52]!==b.builtinRows||e[53]!==b.customConfig?(W=(0,$.jsx)(Ve,{open:g,onOpenChange:_,builtinRows:b.builtinRows,customConfig:b.customConfig,labels:i.addProviderDialog,language:t,onSaved:te}),e[49]=g,e[50]=i.addProviderDialog,e[51]=t,e[52]=b.builtinRows,e[53]=b.customConfig,e[54]=W):W=e[54];let G;e[55]!==i.manageProviderDialog||e[56]!==t||e[57]!==v||e[58]!==b.allModels||e[59]!==b.builtinRows||e[60]!==b.customConfig?(G=v?(0,$.jsx)(ar,{open:!0,onOpenChange:e=>{e||y(null)},providerId:v.providerId,isCustom:v.isCustom,builtinRows:b.builtinRows,customConfig:b.customConfig,allModels:b.allModels,labels:i.manageProviderDialog,language:t,onSaved:N}):null,e[55]=i.manageProviderDialog,e[56]=t,e[57]=v,e[58]=b.allModels,e[59]=b.builtinRows,e[60]=b.customConfig,e[61]=G):G=e[61];let K;return e[62]!==I||e[63]!==L||e[64]!==R||e[65]!==U||e[66]!==W||e[67]!==G?(K=(0,$.jsxs)(ut,{children:[I,L,R,U,W,G]}),e[62]=I,e[63]=L,e[64]=R,e[65]=U,e[66]=W,e[67]=G,e[68]=K):K=e[68],K}function yr(){V()}function br(e){return e.id===`xopc-cloud`&&!e.isCustom}function xr(e){return e.language}function Sr(e){let t=(0,Rt.c)(3),{section:n}=e;switch(n){case`models`:return null;case`image`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(en,{}),t[0]=e):e=t[0],e}case`voice`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(On,{}),t[1]=e):e=t[1],e}case`search`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Yn,{}),t[2]=e):e=t[2],e}}}export{vr as CapabilitiesSettingsPanel};
@@ -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"./chunk-KS7C4IRE-Cq1tE_3b.js";import{n as i}from"./locale-store-msTfRK8P.js";import{t as a}from"./messages-F74LVAiU.js";import{i as o}from"./vendor-swr-BIWyz7Rc.js";import{t as s}from"./button-CS04eWY9.js";import{t as c}from"./skeleton-BwbyijEw.js";import{Xi as l,Xo as u,as as d,bo as f,cs as p,gt as m,zo as h}from"./index-RBCkv8a_.js";var g=e(t(),1),_=n();function v(){let e=i(e=>e.language),t=a(e).connectorsSettings,n=e===`zh`,{data:v,error:y,mutate:b}=o(`connector-service`,u),[x,S]=(0,g.useState)(``),[C,w]=(0,g.useState)(!1),[T,E]=(0,g.useState)(),[D,O]=(0,g.useState)();async function k(e){w(!0),E(void 0);try{await e(),S(``),await b()}catch(e){E(e instanceof Error?e.message:String(e))}finally{w(!1)}}return(0,_.jsxs)(`main`,{className:`mx-auto w-full max-w-2xl space-y-6 p-6`,children:[(0,_.jsx)(r,{to:`/connectors`,className:`text-sm text-accent-fg`,children:t.title}),(0,_.jsx)(`h1`,{className:`text-xl font-semibold`,children:n?`应用连接服务`:`App connection service`}),(0,_.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`此设置决定新账号通过哪个服务连接。已有账号继续使用其原来的连接服务。`:`Choose the service for new accounts. Existing accounts keep their original service.`}),!v&&!y?(0,_.jsx)(c,{className:`h-40 w-full`}):null,v?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-edge p-4`,children:[(0,_.jsx)(`h2`,{className:`font-medium`,children:`XOPC Cloud`}),(0,_.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioSetupHint}),(0,_.jsx)(m,{providerId:`xopc-cloud`,displayName:`XOPC Cloud`,connected:v.mode===`managed`&&v.configured,onConnected:()=>{b()}}),(0,_.jsx)(s,{variant:`secondary`,disabled:C||v.mode===`managed`&&v.configured,onClick:()=>void k(()=>p({mode:`managed`})),children:v.mode===`managed`?n?`当前服务`:`Current service`:n?`使用 XOPC Cloud`:`Use XOPC Cloud`})]}),(0,_.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,_.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:t.composioSetupByok}),(0,_.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,_.jsxs)(`ol`,{className:`list-inside list-decimal text-sm text-fg-muted`,children:[(0,_.jsx)(`li`,{children:t.composioSetupStepProject}),(0,_.jsx)(`li`,{children:t.composioSetupStepKey}),(0,_.jsx)(`li`,{children:t.composioSetupStepPaste})]}),(0,_.jsx)(`a`,{href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,className:`text-sm text-accent-fg`,children:t.composioSetupOpenDashboard}),(0,_.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,_.jsx)(`span`,{children:`Composio API key`}),(0,_.jsx)(f,{value:x,onChange:S,labels:t.secretInputLabels,placeholder:t.composioSetupKeyPlaceholder})]}),(0,_.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioSetupStorageHint}),(0,_.jsx)(s,{disabled:C||!x.trim(),onClick:()=>void k(()=>h(x)),children:n?`验证并使用新项目`:`Verify and use new project`}),(0,_.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n?`验证只检查连接服务和现有账号访问,不执行写入。工具权限在实际使用时检查。环境变量密钥需在运行环境中修改。`:`Verification checks service and existing account access without writes. Tool permissions are checked on use. Environment keys must be updated in the gateway environment.`}),v.backends?.filter(e=>e.mode===`byok`).map(e=>(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 text-sm`,children:[(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsx)(`p`,{children:e.label}),(0,_.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[e.credentialSource===`environment`?n?`环境变量`:`Environment`:n?`本地保存`:`Stored locally`,e.verifiedAt&&` · ${new Date(e.verifiedAt).toLocaleString()}`]})]}),(0,_.jsx)(s,{variant:`ghost`,disabled:C||!x.trim()||e.credentialSource===`environment`,onClick:()=>void k(()=>h(x,e.id)),children:n?`用上方密钥更新`:`Update with key above`}),(0,_.jsx)(s,{variant:`ghost`,disabled:C||e.id===v.backendId,onClick:()=>void k(()=>p({backendId:e.id})),children:e.id===v.backendId?n?`当前服务`:`Current service`:n?`使用`:`Use`}),(0,_.jsx)(s,{variant:`ghost`,disabled:C||e.id===v.backendId,onClick:()=>O(e.id),children:n?`移除`:`Remove`})]},e.id))]})]})]}):null,T||y?(0,_.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:T??String(y)}):null,(0,_.jsx)(l,{open:!!D,title:n?`移除连接服务`:`Remove connection service`,description:n?`移除此服务及其本地保存的密钥,不修改环境变量。需要先切换服务并断开该项目的账号,已有数据不会删除。`:`Remove this service and its saved key, without changing environment variables. Switch services and disconnect this project’s accounts first. Existing data is retained.`,confirmLabel:n?`移除`:`Remove`,cancelLabel:t.modalCancel,destructive:!0,onCancel:()=>O(void 0),onConfirm:()=>{let e=D;O(void 0),e&&k(()=>d(e))}})]})}export{v as ConnectorServicePage};