@xopcai/xopc 0.0.111 → 0.0.113

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 (443) hide show
  1. package/dist/browser-ext/icons/icon-128.png +0 -0
  2. package/dist/browser-ext/icons/icon-16.png +0 -0
  3. package/dist/browser-ext/icons/icon-32.png +0 -0
  4. package/dist/browser-ext/icons/icon-48.png +0 -0
  5. package/dist/browser-ext/manifest.json +1 -1
  6. package/dist/extensions/feishu/src/outbound/media-load.js +1 -1
  7. package/dist/extensions/feishu/src/workflow-progress.js +1 -1
  8. package/dist/extensions/telegram/src/adapters/streaming-adapter.js +1 -1
  9. package/dist/extensions/telegram/src/inbound-processor.js +1 -1
  10. package/dist/extensions/telegram/src/plugin.js +1 -1
  11. package/dist/extensions/telegram/src/routing-integration.js +2 -2
  12. package/dist/extensions/telegram/src/update-offset-store.js +1 -1
  13. package/dist/extensions/telegram/src/workflow-progress.js +1 -1
  14. package/dist/extensions/telegram/xopc.extension.json +1 -1
  15. package/dist/extensions/weixin/src/api/api.js +2 -2
  16. package/dist/extensions/weixin/src/auth/accounts.js +1 -1
  17. package/dist/extensions/weixin/src/cdn/upload.js +1 -1
  18. package/dist/extensions/weixin/src/delivery-to.d.ts +3 -3
  19. package/dist/extensions/weixin/src/delivery-to.js.map +1 -1
  20. package/dist/extensions/weixin/src/media/data-url.js +1 -1
  21. package/dist/extensions/weixin/src/messaging/debug-mode.js +1 -1
  22. package/dist/extensions/weixin/src/messaging/inbound.js +1 -1
  23. package/dist/extensions/weixin/src/messaging/process-message.js +1 -1
  24. package/dist/extensions/weixin/src/plugin.js +1 -1
  25. package/dist/extensions/weixin/src/storage/sync-buf.js +1 -1
  26. package/dist/extensions/weixin/src/workflow-progress.js +1 -1
  27. package/dist/gateway/static/root/apple-touch-icon.png +0 -0
  28. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-zlx9l5Yp.js → agent-avatar-dicebear-CBlklyNr.js} +1 -1
  29. package/dist/gateway/static/root/assets/agent-browser-settings-page-rGbKc2Hh.js +6 -0
  30. package/dist/gateway/static/root/assets/{agent-defaults-tabbed-page-Bz7JWjRM.js → agent-defaults-tabbed-page-CtwVbjOA.js} +1 -1
  31. package/dist/gateway/static/root/assets/agents-CCBmGcwc.js +71 -0
  32. package/dist/gateway/static/root/assets/{app-management-settings-panel-DaQwdeCq.js → app-management-settings-panel-28E_WfMe.js} +1 -1
  33. package/dist/gateway/static/root/assets/{appearance-settings-D2zv6r3P.js → appearance-settings-Do1z0XgJ.js} +1 -1
  34. package/dist/gateway/static/root/assets/{apps-page-BIppe_jj.js → apps-page-xwCsJS15.js} +1 -1
  35. package/dist/gateway/static/root/assets/{archive-plugin-DEmu8eH7.js → archive-plugin-BAFlsov_.js} +1 -1
  36. package/dist/gateway/static/root/assets/{attachment-load-B98lJoN5.js → attachment-load-V3qGPC3x.js} +1 -1
  37. package/dist/gateway/static/root/assets/{binary-plugins-CL9QKmyo.js → binary-plugins-DT8NvA6W.js} +1 -1
  38. package/dist/gateway/static/root/assets/{block-editor-BOAhMAhT.js → block-editor-CdLMEcHd.js} +1 -1
  39. package/dist/gateway/static/root/assets/{channels-settings-Br8iRnXp.js → channels-settings-C044DcYk.js} +1 -1
  40. package/dist/gateway/static/root/assets/{config-api-0o1WYdz2.js → config-api-Bf5mjpu7.js} +1 -1
  41. package/dist/gateway/static/root/assets/config-reload-event-Bjh2zoKp.js +1 -0
  42. package/dist/gateway/static/root/assets/connectors-settings-8VEWUOTj.js +2 -0
  43. package/dist/gateway/static/root/assets/cron-api--pAB_rps.js +1 -0
  44. package/dist/gateway/static/root/assets/cron-page-DqmNGNOy.js +3 -0
  45. package/dist/gateway/static/root/assets/dreaming-settings-6UZE1FSK.js +1 -0
  46. package/dist/gateway/static/root/assets/{extension-debug-page-Cjx6pZVz.js → extension-debug-page-BGhE7msg.js} +1 -1
  47. package/dist/gateway/static/root/assets/{extension-page-BSPNL90V.js → extension-page-CvpI45WG.js} +1 -1
  48. package/dist/gateway/static/root/assets/extension-settings-page-DAmR5FUe.js +1 -0
  49. package/dist/gateway/static/root/assets/{fetch-Bs7in_4F.js → fetch-NZmjSXLl.js} +1 -1
  50. package/dist/gateway/static/root/assets/format-cron-label-BsotZDO5.js +2 -0
  51. package/dist/gateway/static/root/assets/{format-interval-label-CftJ5uXu.js → format-interval-label-qhth3BMV.js} +1 -1
  52. package/dist/gateway/static/root/assets/{gateway-config-api-Clfck-hW.js → gateway-config-api-CaXBt-9R.js} +1 -1
  53. package/dist/gateway/static/root/assets/gateway-settings-DphpbLBc.js +1 -0
  54. package/dist/gateway/static/root/assets/{gateway-startup-retry-BkjVJc38.js → gateway-startup-retry-Be1omjh3.js} +1 -1
  55. package/dist/gateway/static/root/assets/{goal-detail-page-kqJue0sE.js → goal-detail-page-bv0VRDaf.js} +1 -1
  56. package/dist/gateway/static/root/assets/goals-page-1Ywnt4Cb.js +2 -0
  57. package/dist/gateway/static/root/assets/{goals-settings-CJnzNSDo.js → goals-settings-ceEBjnfc.js} +1 -1
  58. package/dist/gateway/static/root/assets/{heartbeat-config-api-Cp7CPuIn.js → heartbeat-config-api-BzO6G4fD.js} +1 -1
  59. package/dist/gateway/static/root/assets/{heartbeat-settings-ifSI1Wbh.js → heartbeat-settings-DCST9-du.js} +1 -1
  60. package/dist/gateway/static/root/assets/index-Cxm6xsps.js +122 -0
  61. package/dist/gateway/static/root/assets/index-b_R4tKqt.css +1 -0
  62. package/dist/gateway/static/root/assets/interval-presets-DJmshV8n.js +1 -0
  63. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings--MI1rYl7.js → keyboard-shortcuts-settings-9AUUlQ5Q.js} +1 -1
  64. package/dist/gateway/static/root/assets/{logs-page-BwrVNlyW.js → logs-page-B_wrxhee.js} +1 -1
  65. package/dist/gateway/static/root/assets/{markdown-split-B_oc9lJe.js → markdown-split-CYYELqAr.js} +1 -1
  66. package/dist/gateway/static/root/assets/{media-plugins-DLPvB5H3.js → media-plugins-BEcMR2M8.js} +1 -1
  67. package/dist/gateway/static/root/assets/messages-CkT-lcgP.js +3 -0
  68. package/dist/gateway/static/root/assets/models-hub-panel-D0JDSbNu.js +2 -0
  69. package/dist/gateway/static/root/assets/note-detail-page-DpFV-EO6.js +2 -0
  70. package/dist/gateway/static/root/assets/{note-image-lightbox-rSqAgOi9.js → note-image-lightbox-DNAoPcmm.js} +1 -1
  71. package/dist/gateway/static/root/assets/{notes-page-C9ACGEty.js → notes-page-CdkjTch8.js} +1 -1
  72. package/dist/gateway/static/root/assets/{preview-open-alternatives-Bw_N2oZi.js → preview-open-alternatives-BPLz0AIv.js} +1 -1
  73. package/dist/gateway/static/root/assets/{remote-access-hub-BhcWIKuM.js → remote-access-hub-DSYVAi96.js} +1 -1
  74. package/dist/gateway/static/root/assets/{save-bar-controls-CNP2jmw0.js → save-bar-controls-CrWwWRVK.js} +1 -1
  75. package/dist/gateway/static/root/assets/schedule-field-CF2sadvN.js +1 -0
  76. package/dist/gateway/static/root/assets/{schema-form-CDPzua9q.js → schema-form-Di5cKjYE.js} +1 -1
  77. package/dist/gateway/static/root/assets/{sessions-page-DzkpSDZr.js → sessions-page-CenkcVjF.js} +1 -1
  78. package/dist/gateway/static/root/assets/settings-advanced-gate-D9sva86V.js +1 -0
  79. package/dist/gateway/static/root/assets/{settings-collapsible-section-C9bff85B.js → settings-collapsible-section-Chh282jW.js} +1 -1
  80. package/dist/gateway/static/root/assets/settings-form-section-Dq-83cQd.js +1 -0
  81. package/dist/gateway/static/root/assets/{settings-page-DWK4Zo7s.js → settings-page-DL35U0x0.js} +1 -1
  82. package/dist/gateway/static/root/assets/setup-status-panel-Ctwbp9Er.js +1 -0
  83. package/dist/gateway/static/root/assets/{share-preview-page-DnutoY_S.js → share-preview-page-0FXYnSUA.js} +1 -1
  84. package/dist/gateway/static/root/assets/{shares-settings-6oRgJMpn.js → shares-settings-DIM3JNsr.js} +1 -1
  85. package/dist/gateway/static/root/assets/skill-reload-api-DAlNaNzL.js +1 -0
  86. package/dist/gateway/static/root/assets/skills-page-CLrHVzAt.js +2 -0
  87. package/dist/gateway/static/root/assets/{system-settings-panel-qP1JDtDd.js → system-settings-panel-W1pTcojB.js} +1 -1
  88. package/dist/gateway/static/root/assets/use-agent-defaults-form-BVRvkK7m.js +1 -0
  89. package/dist/gateway/static/root/assets/{use-channel-catalog-C4mg1hjD.js → use-channel-catalog-CgJibfMM.js} +1 -1
  90. package/dist/gateway/static/root/assets/{use-settings-tab-guard-F6C0mpJt.js → use-settings-tab-guard-Bw_qkRQE.js} +1 -1
  91. package/dist/gateway/static/root/assets/{voice-api-key-field-BnDDb6qO.js → voice-api-key-field-vYAO71Gn.js} +1 -1
  92. package/dist/gateway/static/root/assets/{voice-player-store-B2EwIhtY.js → voice-player-store-C7lziaAx.js} +1 -1
  93. package/dist/gateway/static/root/assets/{workflow-page.utils-CRB7WX9l.js → workflow-page.utils-sgHjOXOm.js} +1 -1
  94. package/dist/gateway/static/root/assets/{workflows-page-2Fptr0je.js → workflows-page-DYyOTmFx.js} +1 -1
  95. package/dist/gateway/static/root/favicon-16x16.png +0 -0
  96. package/dist/gateway/static/root/favicon-32x32.png +0 -0
  97. package/dist/gateway/static/root/favicon-icon.svg +1 -0
  98. package/dist/gateway/static/root/favicon.ico +0 -0
  99. package/dist/gateway/static/root/favicon.png +0 -0
  100. package/dist/gateway/static/root/favicon.svg +24 -15
  101. package/dist/gateway/static/root/index.html +11 -10
  102. package/dist/gateway/static/root/logo-dark.svg +23 -15
  103. package/dist/gateway/static/root/logo.svg +23 -16
  104. package/dist/package.js +1 -1
  105. package/dist/src/agent/agent-manager.d.ts +28 -2
  106. package/dist/src/agent/agent-manager.js +82 -11
  107. package/dist/src/agent/agent-manager.js.map +1 -1
  108. package/dist/src/agent/agent-scope.js +1 -1
  109. package/dist/src/agent/bootstrap/load-bootstrap-files.js +1 -1
  110. package/dist/src/agent/context/workspace-seed.js +2 -2
  111. package/dist/src/agent/context/workspace-state.js +1 -1
  112. package/dist/src/agent/context/workspace.js +1 -1
  113. package/dist/src/agent/goals/goal-locale.js +2 -2
  114. package/dist/src/agent/goals/persistent-goal-service.js +1 -1
  115. package/dist/src/agent/goals/post-turn.js +3 -3
  116. package/dist/src/agent/image/load-image-media.js +2 -2
  117. package/dist/src/agent/ipc/inbox.js +3 -3
  118. package/dist/src/agent/ipc/socket.js +1 -1
  119. package/dist/src/agent/mcp/bundle-mcp-materialize.js +1 -1
  120. package/dist/src/agent/mcp/bundle-mcp-runtime.js +1 -1
  121. package/dist/src/agent/mcp/mcp-transport-config.js +1 -1
  122. package/dist/src/agent/mcp/mcp-transport.js +1 -1
  123. package/dist/src/agent/memory/builtin-memory-store.js +1 -1
  124. package/dist/src/agent/memory/dreaming/deep-promotion.js +1 -1
  125. package/dist/src/agent/memory/dreaming/events.js +1 -1
  126. package/dist/src/agent/memory/dreaming/last-run.js +1 -1
  127. package/dist/src/agent/memory/dreaming/light-sweep.js +1 -1
  128. package/dist/src/agent/memory/dreaming/preview.js +1 -1
  129. package/dist/src/agent/memory/dreaming/rem-patterns.js +1 -1
  130. package/dist/src/agent/memory/dreaming/short-term-store.js +1 -1
  131. package/dist/src/agent/memory/dreaming/utils.js +1 -1
  132. package/dist/src/agent/memory/memory-flush.js +1 -1
  133. package/dist/src/agent/memory/plugin-discovery.js +1 -1
  134. package/dist/src/agent/messaging/command-handler.d.ts +3 -0
  135. package/dist/src/agent/messaging/command-handler.js +5 -0
  136. package/dist/src/agent/messaging/command-handler.js.map +1 -1
  137. package/dist/src/agent/models/manager.js +1 -1
  138. package/dist/src/agent/prompt/memory/index.js +1 -1
  139. package/dist/src/agent/prompt/service-prompt-builder.js +2 -2
  140. package/dist/src/agent/reply/post-compaction-context.js +1 -1
  141. package/dist/src/agent/reply/workspace-boundary-read.js +1 -1
  142. package/dist/src/agent/sandbox/path-policy.js +2 -2
  143. package/dist/src/agent/service/process-direct-streaming.js +9 -4
  144. package/dist/src/agent/service/process-direct-streaming.js.map +1 -1
  145. package/dist/src/agent/service/reconcile-dreaming-cron.js +8 -5
  146. package/dist/src/agent/service/reconcile-dreaming-cron.js.map +1 -1
  147. package/dist/src/agent/service.d.ts +2 -1
  148. package/dist/src/agent/service.js +10 -5
  149. package/dist/src/agent/service.js.map +1 -1
  150. package/dist/src/agent/service.types.d.ts +4 -0
  151. package/dist/src/agent/session/session-config-service.d.ts +8 -0
  152. package/dist/src/agent/session/session-config-service.js +20 -0
  153. package/dist/src/agent/session/session-config-service.js.map +1 -1
  154. package/dist/src/agent/session/session-inspector.js +1 -1
  155. package/dist/src/agent/skills/config.js +2 -2
  156. package/dist/src/agent/skills/filesystem-watcher.d.ts +19 -0
  157. package/dist/src/agent/skills/filesystem-watcher.js +182 -0
  158. package/dist/src/agent/skills/filesystem-watcher.js.map +1 -0
  159. package/dist/src/agent/skills/hub-hash.js +2 -2
  160. package/dist/src/agent/skills/hub-lock.js +1 -1
  161. package/dist/src/agent/skills/hub-pull.js +30 -36
  162. package/dist/src/agent/skills/hub-pull.js.map +1 -1
  163. package/dist/src/agent/skills/index.js +82 -38
  164. package/dist/src/agent/skills/index.js.map +1 -1
  165. package/dist/src/agent/skills/installer.js +2 -2
  166. package/dist/src/agent/skills/managed-store.d.ts +19 -0
  167. package/dist/src/agent/skills/managed-store.js +97 -38
  168. package/dist/src/agent/skills/managed-store.js.map +1 -1
  169. package/dist/src/agent/skills/skill-manage-ops.js +1 -1
  170. package/dist/src/agent/skills/skill-manager.d.ts +16 -6
  171. package/dist/src/agent/skills/skill-manager.js +79 -24
  172. package/dist/src/agent/skills/skill-manager.js.map +1 -1
  173. package/dist/src/agent/skills/skill-view-path.js +1 -1
  174. package/dist/src/agent/skills/test-framework.js +1 -1
  175. package/dist/src/agent/skills/types.d.ts +11 -0
  176. package/dist/src/agent/skills/watcher.js +1 -1
  177. package/dist/src/agent/starter-agents.js +1 -1
  178. package/dist/src/agent/tools/cronjob-tool.d.ts +6 -3
  179. package/dist/src/agent/tools/cronjob-tool.js +58 -23
  180. package/dist/src/agent/tools/cronjob-tool.js.map +1 -1
  181. package/dist/src/agent/tools/dreaming-tool.js +1 -1
  182. package/dist/src/agent/tools/factory.js +1 -1
  183. package/dist/src/agent/tools/find.js +1 -1
  184. package/dist/src/agent/tools/grep.js +1 -1
  185. package/dist/src/agent/tools/image-generate-tool.js +1 -1
  186. package/dist/src/agent/tools/skill-manage-tool.js +1 -1
  187. package/dist/src/agent/tools/workflow-tool.js +1 -1
  188. package/dist/src/agent/workflow/catalog.js +1 -1
  189. package/dist/src/agent/workspace-runtime/registry.d.ts +5 -0
  190. package/dist/src/agent/workspace-runtime/registry.js +7 -0
  191. package/dist/src/agent/workspace-runtime/registry.js.map +1 -1
  192. package/dist/src/ai-assist/text-assist.d.ts +42 -0
  193. package/dist/src/ai-assist/text-assist.js +252 -0
  194. package/dist/src/ai-assist/text-assist.js.map +1 -0
  195. package/dist/src/auth/credentials.js +2 -2
  196. package/dist/src/auth/profiles/store.js +2 -2
  197. package/dist/src/auth/sync-provider-auth.js +1 -1
  198. package/dist/src/browser/cache-dir-policy.js +1 -1
  199. package/dist/src/browser/cdp-local-launcher.js +2 -2
  200. package/dist/src/browser/providers/browser-ext-install.js +4 -4
  201. package/dist/src/browser/providers/cloakbrowser.js +5 -5
  202. package/dist/src/browser/providers/playwright-doctor.js +1 -1
  203. package/dist/src/browser/stealth.js +1 -1
  204. package/dist/src/channels/outbound/persist-store.js +1 -1
  205. package/dist/src/channels/pairing/allow-from-file.js +1 -1
  206. package/dist/src/channels/pairing/pairing-store.js +2 -2
  207. package/dist/src/channels/plugins/types.adapters.d.ts +2 -2
  208. package/dist/src/chat-commands/agent-edit.js +2 -2
  209. package/dist/src/chat-commands/builtins/config.js +3 -3
  210. package/dist/src/chat-commands/builtins/system.js +11 -4
  211. package/dist/src/chat-commands/builtins/system.js.map +1 -1
  212. package/dist/src/chat-commands/context.d.ts +3 -0
  213. package/dist/src/chat-commands/context.js +7 -0
  214. package/dist/src/chat-commands/context.js.map +1 -1
  215. package/dist/src/chat-commands/types.d.ts +2 -0
  216. package/dist/src/cli/commands/config.js +1 -1
  217. package/dist/src/cli/commands/cron.js +55 -16
  218. package/dist/src/cli/commands/cron.js.map +1 -1
  219. package/dist/src/cli/commands/doctor/checks/config-health.js +1 -1
  220. package/dist/src/cli/commands/doctor/checks/cron-health.js +2 -83
  221. package/dist/src/cli/commands/doctor/checks/cron-health.js.map +1 -1
  222. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  223. package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
  224. package/dist/src/cli/commands/doctor/checks/state-integrity.js +1 -1
  225. package/dist/src/cli/commands/doctor/checks/workspace-status.js +1 -1
  226. package/dist/src/cli/commands/extension-create.js +1 -1
  227. package/dist/src/cli/commands/extension-dev.js +2 -2
  228. package/dist/src/cli/commands/extension-marketplace.js +2 -2
  229. package/dist/src/cli/commands/extension-pack.js +2 -2
  230. package/dist/src/cli/commands/extension.js +3 -3
  231. package/dist/src/cli/commands/gateway/logs.js +1 -1
  232. package/dist/src/cli/commands/image.js +1 -1
  233. package/dist/src/cli/commands/init.js +2 -2
  234. package/dist/src/cli/commands/models.js +1 -1
  235. package/dist/src/cli/commands/skills-test.js +1 -1
  236. package/dist/src/cli/templates.js +1 -1
  237. package/dist/src/cli/utils/gateway-client.js +1 -1
  238. package/dist/src/cli/utils/init-workspace-core.js +2 -2
  239. package/dist/src/config/agent-profile.js +1 -1
  240. package/dist/src/config/agent-typed-models.js +1 -1
  241. package/dist/src/config/gateway-bind.js +1 -1
  242. package/dist/src/config/index.js +7 -7
  243. package/dist/src/config/loader.js +4 -4
  244. package/dist/src/config/models-json.js +2 -2
  245. package/dist/src/config/paths-state.js +1 -1
  246. package/dist/src/config/paths.js +1 -1
  247. package/dist/src/config/profile.js +1 -1
  248. package/dist/src/config/reload.js +1 -1
  249. package/dist/src/config/schema.d.ts +0 -2
  250. package/dist/src/config/schema.js +0 -3
  251. package/dist/src/config/schema.js.map +1 -1
  252. package/dist/src/config/web-patch.d.ts +0 -1
  253. package/dist/src/config/web-patch.js +0 -2
  254. package/dist/src/config/web-patch.js.map +1 -1
  255. package/dist/src/config/workspace-path.js +1 -1
  256. package/dist/src/cron/executor.js +102 -71
  257. package/dist/src/cron/executor.js.map +1 -1
  258. package/dist/src/cron/index.d.ts +1 -1
  259. package/dist/src/cron/index.js +3 -3
  260. package/dist/src/cron/run-log-store.d.ts +1 -0
  261. package/dist/src/cron/run-log-store.js +4 -2
  262. package/dist/src/cron/run-log-store.js.map +1 -1
  263. package/dist/src/cron/schedule.d.ts +10 -0
  264. package/dist/src/cron/schedule.js +85 -0
  265. package/dist/src/cron/schedule.js.map +1 -0
  266. package/dist/src/cron/service.d.ts +34 -77
  267. package/dist/src/cron/service.js +327 -264
  268. package/dist/src/cron/service.js.map +1 -1
  269. package/dist/src/cron/types.d.ts +80 -50
  270. package/dist/src/cron/validation.d.ts +358 -90
  271. package/dist/src/cron/validation.js +152 -132
  272. package/dist/src/cron/validation.js.map +1 -1
  273. package/dist/src/cron/workflow-run-completion.js +1 -1
  274. package/dist/src/daemon/constants.js +1 -1
  275. package/dist/src/daemon/install-plan.js +2 -2
  276. package/dist/src/daemon/launchd.js +2 -2
  277. package/dist/src/daemon/schtasks.js +2 -2
  278. package/dist/src/daemon/systemd.js +2 -2
  279. package/dist/src/extensions/bundle-mcp.js +1 -1
  280. package/dist/src/extensions/discover-extensions.js +2 -2
  281. package/dist/src/extensions/health.js +1 -1
  282. package/dist/src/extensions/install.js +2 -2
  283. package/dist/src/extensions/loader.js +2 -2
  284. package/dist/src/extensions/lockfile.js +3 -3
  285. package/dist/src/extensions/security.js +1 -1
  286. package/dist/src/extensions/update.js +2 -2
  287. package/dist/src/gateway/agents-admin.js +2 -2
  288. package/dist/src/gateway/chat-stream/mapper.d.ts +1 -0
  289. package/dist/src/gateway/chat-stream/mapper.js +6 -2
  290. package/dist/src/gateway/chat-stream/mapper.js.map +1 -1
  291. package/dist/src/gateway/chat-stream/protocol.d.ts +2 -0
  292. package/dist/src/gateway/file-path-classifier.js +2 -2
  293. package/dist/src/gateway/hono/lib/config-payload.d.ts +0 -1
  294. package/dist/src/gateway/hono/lib/config-payload.js +1 -1
  295. package/dist/src/gateway/hono/lib/extension-store.js +2 -2
  296. package/dist/src/gateway/hono/lib/static-ui.js +2 -2
  297. package/dist/src/gateway/hono/oauth-async.js +1 -1
  298. package/dist/src/gateway/hono/routes/agents.js +1 -1
  299. package/dist/src/gateway/hono/routes/ai-assist.d.ts +3 -0
  300. package/dist/src/gateway/hono/routes/ai-assist.js +66 -0
  301. package/dist/src/gateway/hono/routes/ai-assist.js.map +1 -0
  302. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
  303. package/dist/src/gateway/hono/routes/commands-skills.js +7 -0
  304. package/dist/src/gateway/hono/routes/commands-skills.js.map +1 -1
  305. package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
  306. package/dist/src/gateway/hono/routes/cron.js +24 -5
  307. package/dist/src/gateway/hono/routes/cron.js.map +1 -1
  308. package/dist/src/gateway/hono/routes/dreaming.js +1 -1
  309. package/dist/src/gateway/hono/routes/home.js +5 -3
  310. package/dist/src/gateway/hono/routes/home.js.map +1 -1
  311. package/dist/src/gateway/hono/routes/host-fs.js +2 -2
  312. package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
  313. package/dist/src/gateway/hono/routes/lazy-bundles.js.map +1 -1
  314. package/dist/src/gateway/hono/routes/models.js +1 -1
  315. package/dist/src/gateway/hono/routes/shares.js +1 -1
  316. package/dist/src/gateway/hono/routes/workflows.js +2 -2
  317. package/dist/src/gateway/hono/routes/workspace.js +2 -2
  318. package/dist/src/gateway/lock.js +3 -3
  319. package/dist/src/gateway/ports.js +1 -1
  320. package/dist/src/gateway/service/agent-runner.js +2 -2
  321. package/dist/src/gateway/service/config-coordinator.js +1 -1
  322. package/dist/src/gateway/service/marketplace-service.d.ts +22 -10
  323. package/dist/src/gateway/service/marketplace-service.js +46 -5
  324. package/dist/src/gateway/service/marketplace-service.js.map +1 -1
  325. package/dist/src/gateway/service.js +11 -5
  326. package/dist/src/gateway/service.js.map +1 -1
  327. package/dist/src/gateway/workspace-fs-file-list.js +1 -1
  328. package/dist/src/goals/goal-notifications.js +1 -1
  329. package/dist/src/goals/goal-workflow-judge.js +3 -3
  330. package/dist/src/i18n/goals-bundle.js +1 -1
  331. package/dist/src/i18n/index.js +1 -1
  332. package/dist/src/i18n/share-tool-bundle.js +2 -2
  333. package/dist/src/infra/brew.js +1 -1
  334. package/dist/src/infra/package-json.js +1 -1
  335. package/dist/src/infra/package-update-steps.js +1 -1
  336. package/dist/src/infra/path-env.js +2 -2
  337. package/dist/src/infra/restart.js +1 -1
  338. package/dist/src/infra/stable-node-path.js +1 -1
  339. package/dist/src/infra/update-check.js +1 -1
  340. package/dist/src/infra/update-global.js +1 -1
  341. package/dist/src/infra/update-lock.js +2 -2
  342. package/dist/src/infra/update-restart.js +1 -1
  343. package/dist/src/infra/update-runner.js +1 -1
  344. package/dist/src/infra/update-startup.js +1 -1
  345. package/dist/src/infra/write-file-atomic.js +2 -2
  346. package/dist/src/media/store.js +1 -1
  347. package/dist/src/notes/agent-context.js +1 -1
  348. package/dist/src/notes/service.js +1 -1
  349. package/dist/src/notes/store.js +2 -2
  350. package/dist/src/project-trust/trust-store.js +2 -2
  351. package/dist/src/providers/auth-runtime/auth-profile-store.js +1 -1
  352. package/dist/src/providers/index.js +1 -1
  353. package/dist/src/providers/model-registry.js +4 -4
  354. package/dist/src/session/init-session-turn.js +2 -2
  355. package/dist/src/session/resolve-session.js +3 -3
  356. package/dist/src/session/session-title.js +2 -2
  357. package/dist/src/session/store-reader.d.ts +5 -0
  358. package/dist/src/session/store-reader.js +1 -0
  359. package/dist/src/session/store.js +1 -1
  360. package/dist/src/share/share-auto.js +2 -2
  361. package/dist/src/share/share-store.js +3 -3
  362. package/dist/src/share/share-thumbnail.js +2 -2
  363. package/dist/src/share/share-zip.js +1 -1
  364. package/dist/src/share/site-share-store.js +3 -3
  365. package/dist/src/share/site-static-serve.js +1 -1
  366. package/dist/src/storage/sqlite/connection.js +1 -1
  367. package/dist/src/storage/sqlite/cron-job-repository.d.ts +6 -0
  368. package/dist/src/storage/sqlite/cron-job-repository.js +70 -0
  369. package/dist/src/storage/sqlite/cron-job-repository.js.map +1 -0
  370. package/dist/src/storage/sqlite/cron-run-repository.js +0 -1
  371. package/dist/src/storage/sqlite/cron-run-repository.js.map +1 -1
  372. package/dist/src/storage/sqlite/index.d.ts +1 -0
  373. package/dist/src/storage/sqlite/index.js +2 -1
  374. package/dist/src/storage/sqlite/memory-index-repository.js +2 -2
  375. package/dist/src/storage/sqlite/migrations/009_cron_jobs.sql +24 -0
  376. package/dist/src/storage/sqlite/migrations/discover.js +1 -1
  377. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  378. package/dist/src/storage/sqlite/migrations/runner.js +4 -4
  379. package/dist/src/storage/sqlite/migrations/runner.js.map +1 -1
  380. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  381. package/dist/src/storage/sqlite/schema.js +2 -2
  382. package/dist/src/storage/sqlite/schema.sql +25 -0
  383. package/dist/src/tui/clipboard-image.js +3 -3
  384. package/dist/src/tui/extension-host/load-extensions.js +1 -1
  385. package/dist/src/tui/theme-manager.js +1 -1
  386. package/dist/src/tui/tui-command-formatters.js +4 -4
  387. package/dist/src/tui/tui-commands.js +2 -2
  388. package/dist/src/tui/tui-keybindings-file.js +1 -1
  389. package/dist/src/tui/tui-scoped-models.js +2 -2
  390. package/dist/src/tui/tui-settings.js +1 -1
  391. package/dist/src/tui/tui-startup-resources.js +1 -1
  392. package/dist/src/tui/tui.js +6 -6
  393. package/dist/src/tunnel/frpc-binary.js +4 -4
  394. package/dist/src/tunnel/frpc-config.js +1 -1
  395. package/dist/src/tunnel/frpc-extract.js +1 -1
  396. package/dist/src/tunnel/tunnel-state.js +1 -1
  397. package/dist/src/utils/logger/audit.js +1 -1
  398. package/dist/src/utils/logger/log-store.js +1 -1
  399. package/dist/src/utils/logger/rotation.js +1 -1
  400. package/dist/src/utils/logger/streams.js +1 -1
  401. package/dist/src/voice/tts/audio.js +1 -1
  402. package/dist/src/voice/tts/providers/edge-speech.js +2 -2
  403. package/dist/src/workflows/draft/workflow-draft-service.js +1 -1
  404. package/dist/src/workflows/engine/projector.js +23 -14
  405. package/dist/src/workflows/engine/projector.js.map +1 -1
  406. package/dist/src/workflows/engine/workflow-engine.d.ts +1 -0
  407. package/dist/src/workflows/engine/workflow-engine.js +36 -0
  408. package/dist/src/workflows/engine/workflow-engine.js.map +1 -1
  409. package/dist/src/workflows/index.js +1 -1
  410. package/dist/src/workflows/service/workflow-run-service.js +2 -2
  411. package/dist/src/workflows/service/workflow-session-bridge.js +2 -2
  412. package/dist/src/workflows/store/event-store.js +1 -1
  413. package/dist/src/workflows/store/run-store.js +1 -1
  414. package/package.json +2 -3
  415. package/dist/gateway/static/root/assets/agent-browser-settings-page-B-0zGjt8.js +0 -6
  416. package/dist/gateway/static/root/assets/agents-DwDnJlXT.js +0 -71
  417. package/dist/gateway/static/root/assets/connectors-settings-DDvHo9in.js +0 -2
  418. package/dist/gateway/static/root/assets/cron-api-Dj_UZKST.js +0 -1
  419. package/dist/gateway/static/root/assets/cron-page-Dv7GII9G.js +0 -1
  420. package/dist/gateway/static/root/assets/cron-schedule-picker-DH10KgD6.js +0 -1
  421. package/dist/gateway/static/root/assets/dreaming-settings-L2rgZDQl.js +0 -1
  422. package/dist/gateway/static/root/assets/extension-settings-page-m_UQYkVc.js +0 -1
  423. package/dist/gateway/static/root/assets/gateway-settings-CS177xni.js +0 -1
  424. package/dist/gateway/static/root/assets/goals-page-C0FujUB5.js +0 -2
  425. package/dist/gateway/static/root/assets/index-COkF54xv.js +0 -121
  426. package/dist/gateway/static/root/assets/index-DIaSNGEO.css +0 -1
  427. package/dist/gateway/static/root/assets/interval-presets-B29Ss_2y.js +0 -2
  428. package/dist/gateway/static/root/assets/messages-Csef1aW7.js +0 -3
  429. package/dist/gateway/static/root/assets/models-hub-panel-DHGiTIvf.js +0 -2
  430. package/dist/gateway/static/root/assets/note-detail-page-BM7zlDiT.js +0 -2
  431. package/dist/gateway/static/root/assets/schedule-field-BPAWui3P.js +0 -1
  432. package/dist/gateway/static/root/assets/schedule-summary-B-hdSRdR.js +0 -1
  433. package/dist/gateway/static/root/assets/settings-advanced-gate-BYS-rpzn.js +0 -1
  434. package/dist/gateway/static/root/assets/settings-form-section-BsrK7TBF.js +0 -1
  435. package/dist/gateway/static/root/assets/setup-status-panel-DJiksNu4.js +0 -1
  436. package/dist/gateway/static/root/assets/skill-reload-api-CU9i0nJV.js +0 -1
  437. package/dist/gateway/static/root/assets/skills-page-ERbdWENm.js +0 -2
  438. package/dist/gateway/static/root/assets/use-agent-defaults-form-D3FGVLZb.js +0 -1
  439. package/dist/gateway/static/root/favicon-16.png +0 -0
  440. package/dist/gateway/static/root/favicon-32.png +0 -0
  441. package/dist/src/cron/persistence.d.ts +0 -62
  442. package/dist/src/cron/persistence.js +0 -188
  443. package/dist/src/cron/persistence.js.map +0 -1
@@ -1,2 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-JdwAhgNB.js";import{t as a}from"./messages-Csef1aW7.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{c as s,i as c,n as l,t as u}from"./fetch-Bs7in_4F.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{$ as f,$r as p,B as m,Ci as h,Da as g,Di as _,Dr as v,Ds as y,Ea as b,Ei as x,Ga as S,Hi as C,J as w,Jr as T,Ma as E,Oi as D,Pi as O,Qr as k,R as A,Ss as j,Ti as M,U as N,Va as P,X as F,Xr as I,Y as L,Z as R,Zo as z,Zr as B,_a as V,_n as H,at as U,bi as ee,br as W,da as G,do as te,ei as ne,es as re,et as ie,gi as K,gn as q,is as ae,it as oe,ji as se,ki as J,ko as ce,li as le,mi as Y,ms as ue,ni as de,nt as fe,ot as pe,p as me,pa as he,pi as ge,qa as _e,qr as ve,ri as ye,rt as be,st as xe,ti as Se,ts as Ce,tt as we,ua as Te,vn as Ee,wi as De,xi as X,yo as Oe,yr as ke,z as Ae}from"./index-COkF54xv.js";import{a as je,c as Me,d as Ne,l as Pe,n as Fe,o as Ie,r as Le,s as Re,t as ze,u as Be}from"./voice-api-key-field-BnDDb6qO.js";import{t as Ve}from"./settings-advanced-gate-BYS-rpzn.js";import{t as He}from"./settings-collapsible-section-C9bff85B.js";import{n as Ue,t as We}from"./settings-form-section-BsrK7TBF.js";import{i as Ge,l as Ke,r as qe,t as Je}from"./config-api-0o1WYdz2.js";import{n as Ye,t as Xe}from"./save-bar-controls-CNP2jmw0.js";var Z=n(),Q=e(t(),1),$=r();async function Ze(){let e=await u(c(`/api/image/providers`));if(!e.ok)throw Error(`Image providers: HTTP ${e.status}`);return(await e.json()).payload?.providers??[]}function Qe(e){let t=new Set,n=[];for(let r of e){let e=r.models.length>0?r.models:r.defaultModel?[r.defaultModel]:[];for(let i of e){let e=`${r.id}/${i}`;t.has(e)||(t.add(e),n.push(e))}}return n}function $e(e,t){let n=Qe(e.filter(e=>e.configured===!0));return!t||n.includes(t)?n:[t,...n]}function et(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=n.split(/[/\s]+/).filter(Boolean);return e.filter(e=>{let t=e.toLowerCase();return r.every(e=>t.includes(e))})}var tt=`image-generation-providers`;function nt(e){let t=(0,Z.c)(80),{value:n,disabled:r,placeholder:a,searchPlaceholder:o,noMatches:s,registryEmptyHint:c,outOfFilterNote:l,className:u,onChange:f}=e,[p,m]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(``),v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v={revalidateOnFocus:!1},t[0]=v):v=t[0];let{data:y,isLoading:b,error:S}=d(tt,Ze,v),C;t[1]===n?C=t[2]:(C=n.trim(),t[1]=n,t[2]=C);let w=C,T;t[3]===y?T=t[4]:(T=Qe((y??[]).filter(at)),t[3]=y,t[4]=T);let E=T,D;t[5]===y?D=t[6]:(D=y??[],t[5]=y,t[6]=D);let O;t[7]!==D||t[8]!==w?(O=$e(D,w),t[7]=D,t[8]=w,t[9]=O):O=t[9];let k=O,A;t[10]!==k||t[11]!==g?(A=et(k,g),t[10]=k,t[11]=g,t[12]=A):A=t[12];let j=A,M;t[13]!==E||t[14]!==l||t[15]!==w?(M=!!l&&!!w&&!E.includes(w),t[13]=E,t[14]=l,t[15]=w,t[16]=M):M=t[16];let N=M,P;t[17]!==a||t[18]!==n?(P=n.trim()?n:a,t[17]=a,t[18]=n,t[19]=P):P=t[19];let F=P,I;t[20]!==a||t[21]!==n?(I=n.trim()||a,t[20]=a,t[21]=n,t[22]=I):I=t[22];let L=I,R;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(R=e=>{m(e),e||_(``)},t[23]=R):R=t[23];let z=R,B=r||b,V=b?`…`:L,H;t[24]===u?H=t[25]:(H=i(h,`items-center gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2 text-left text-sm font-normal text-fg`,X.transition,X.press,`hover:border-edge hover:bg-surface-hover/45`,x,`disabled:cursor-not-allowed disabled:opacity-50`,`dark:border-edge-subtle dark:hover:bg-surface-hover/55`,u),t[24]=u,t[25]=H);let U=b?`…`:F,ee;t[26]===U?ee=t[27]:(ee=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:U}),t[26]=U,t[27]=ee);let W;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(re,{className:`size-4 shrink-0 text-fg-subtle opacity-70`,"aria-hidden":!0}),t[28]=W):W=t[28];let G;t[29]!==p||t[30]!==B||t[31]!==V||t[32]!==H||t[33]!==ee?(G=(0,$.jsx)(ye,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,disabled:B,title:V,className:H,"aria-haspopup":`listbox`,"aria-expanded":p,children:[ee,W]})}),t[29]=p,t[30]=B,t[31]=V,t[32]=H,t[33]=ee,t[34]=G):G=t[34];let te;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(te=i(`w-[min(22rem,calc(100vw-2rem))] rounded-xl border border-edge-subtle bg-surface-panel p-1 shadow-elevated dark:border-edge-subtle`,Ee),t[35]=te):te=t[35];let ie;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(ie=i(`mb-1 w-full rounded-lg border border-edge-subtle bg-surface-base px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-disabled dark:bg-surface-hover/40`,De),t[36]=ie):ie=t[36];let K;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(K=e=>_(e.target.value),t[37]=K):K=t[37];let q;t[38]!==g||t[39]!==o?(q=(0,$.jsx)(`input`,{type:`search`,className:ie,placeholder:o,value:g,onChange:K,onKeyDown:rt}),t[38]=g,t[39]=o,t[40]=q):q=t[40];let oe;t[41]===S?oe=t[42]:(oe=S?(0,$.jsx)(`div`,{className:`p-2 text-xs text-red-600 dark:text-red-400`,children:S instanceof Error?S.message:`Failed to load image providers`}):null,t[41]=S,t[42]=oe);let se;t[43]!==k||t[44]!==S||t[45]!==b||t[46]!==s||t[47]!==c?(se=!S&&k.length===0&&!b?(0,$.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:c??s}):null,t[43]=k,t[44]=S,t[45]=b,t[46]=s,t[47]=c,t[48]=se):se=t[48];let J;t[49]!==k||t[50]!==S||t[51]!==j.length||t[52]!==s?(J=!S&&k.length>0&&j.length===0?(0,$.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:s}):null,t[49]=k,t[50]=S,t[51]=j.length,t[52]=s,t[53]=J):J=t[53];let ce;if(t[54]!==j||t[55]!==f||t[56]!==n){let e;t[58]!==f||t[59]!==n?(e=e=>(0,$.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":e===n,className:i(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-fg hover:bg-surface-hover`,X.press,e===n&&`bg-surface-hover/90 font-medium dark:bg-surface-hover/70`),onClick:()=>{f(e),m(!1),_(``)},children:[(0,$.jsx)(ae,{className:i(`size-4 shrink-0`,e!==n&&`invisible`),"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:e})]},e),t[58]=f,t[59]=n,t[60]=e):e=t[60],ce=j.map(e),t[54]=j,t[55]=f,t[56]=n,t[57]=ce}else ce=t[57];let le;t[61]!==o||t[62]!==oe||t[63]!==se||t[64]!==J||t[65]!==ce?(le=(0,$.jsxs)(`div`,{className:`max-h-60 overflow-auto`,role:`listbox`,"aria-label":o,children:[oe,se,J,ce]}),t[61]=o,t[62]=oe,t[63]=se,t[64]=J,t[65]=ce,t[66]=le):le=t[66];let Y;t[67]!==q||t[68]!==le?(Y=(0,$.jsx)(Se,{children:(0,$.jsxs)(ne,{className:te,side:`bottom`,sideOffset:4,align:`end`,onOpenAutoFocus:it,children:[q,le]})}),t[67]=q,t[68]=le,t[69]=Y):Y=t[69];let ue;t[70]!==p||t[71]!==G||t[72]!==Y?(ue=(0,$.jsxs)(de,{open:p,onOpenChange:z,modal:!1,children:[G,Y]}),t[70]=p,t[71]=G,t[72]=Y,t[73]=ue):ue=t[73];let fe;t[74]!==l||t[75]!==N?(fe=N?(0,$.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-400/90`,children:l}):null,t[74]=l,t[75]=N,t[76]=fe):fe=t[76];let pe;return t[77]!==ue||t[78]!==fe?(pe=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[ue,fe]}),t[77]=ue,t[78]=fe,t[79]=pe):pe=t[79],pe}function rt(e){return e.stopPropagation()}function it(e){return e.preventDefault()}function at(e){return e.configured===!0}function ot(e,t,n){let r=e.trim();return r?`model:${r}`:`empty:${n.slice(0,t).filter(e=>!e.trim()).length}`}function st(e){let t=(0,Z.c)(37),{a:n,chat:r,form:i,update:a}=e,o;t[0]!==n.cardModelsSubtitle||t[1]!==n.cardModelsTitle?(o=(0,$.jsx)(Ue,{icon:te,title:n.cardModelsTitle,subtitle:n.cardModelsSubtitle}),t[0]=n.cardModelsSubtitle,t[1]=n.cardModelsTitle,t[2]=o):o=t[2];let s;t[3]===a?s=t[4]:(s=e=>a({imageModel:e}),t[3]=a,t[4]=s);let c;t[5]!==n.visionOutOfFilterNote||t[6]!==n.visionRegistryEmpty||t[7]!==r.modelNoMatches||t[8]!==r.modelPlaceholder||t[9]!==r.modelSearchPlaceholder||t[10]!==i.imageModel||t[11]!==s?(c=(0,$.jsx)(N,{value:i.imageModel,placeholder:r.modelPlaceholder,searchPlaceholder:r.modelSearchPlaceholder,noMatches:r.modelNoMatches,capabilitiesFilter:`vision`,registryEmptyHint:n.visionRegistryEmpty,outOfFilterNote:n.visionOutOfFilterNote,onChange:s}),t[5]=n.visionOutOfFilterNote,t[6]=n.visionRegistryEmpty,t[7]=r.modelNoMatches,t[8]=r.modelPlaceholder,t[9]=r.modelSearchPlaceholder,t[10]=i.imageModel,t[11]=s,t[12]=c):c=t[12];let l;t[13]!==n.desc.imageModel||t[14]!==n.label.imageModel||t[15]!==c?(l=(0,$.jsx)(Ke,{label:n.label.imageModel,description:n.desc.imageModel,children:c}),t[13]=n.desc.imageModel,t[14]=n.label.imageModel,t[15]=c,t[16]=l):l=t[16];let u;t[17]===a?u=t[18]:(u=e=>a({imageGenerationModel:e}),t[17]=a,t[18]=u);let d;t[19]!==n.imageGenOutOfFilterNote||t[20]!==n.imageGenRegistryEmpty||t[21]!==r.modelNoMatches||t[22]!==r.modelPlaceholder||t[23]!==r.modelSearchPlaceholder||t[24]!==i.imageGenerationModel||t[25]!==u?(d=(0,$.jsx)(nt,{value:i.imageGenerationModel,placeholder:r.modelPlaceholder,searchPlaceholder:r.modelSearchPlaceholder,noMatches:r.modelNoMatches,registryEmptyHint:n.imageGenRegistryEmpty,outOfFilterNote:n.imageGenOutOfFilterNote,onChange:u}),t[19]=n.imageGenOutOfFilterNote,t[20]=n.imageGenRegistryEmpty,t[21]=r.modelNoMatches,t[22]=r.modelPlaceholder,t[23]=r.modelSearchPlaceholder,t[24]=i.imageGenerationModel,t[25]=u,t[26]=d):d=t[26];let f;t[27]!==n.desc.imageGenerationModel||t[28]!==n.label.imageGenerationModel||t[29]!==d?(f=(0,$.jsx)(Ke,{label:n.label.imageGenerationModel,description:n.desc.imageGenerationModel,children:d}),t[27]=n.desc.imageGenerationModel,t[28]=n.label.imageGenerationModel,t[29]=d,t[30]=f):f=t[30];let p;t[31]!==l||t[32]!==f?(p=(0,$.jsxs)(`div`,{className:`mt-4 flex flex-col gap-5`,children:[l,f]}),t[31]=l,t[32]=f,t[33]=p):p=t[33];let m;return t[34]!==o||t[35]!==p?(m=(0,$.jsxs)(We,{children:[o,p]}),t[34]=o,t[35]=p,t[36]=m):m=t[36],m}function ct(e){let t=(0,Z.c)(45),{a:n,chat:r,form:i,update:a}=e,o=n.label.imageModelFallbacks,s=n.desc.imageModelFallbacks,c;t[0]!==n.removeModelFallback||t[1]!==n.visionOutOfFilterNote||t[2]!==n.visionRegistryEmpty||t[3]!==r||t[4]!==i.imageModelFallbacks||t[5]!==a?(c=i.imageModelFallbacks.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(N,{value:e,placeholder:r.modelPlaceholder,searchPlaceholder:r.modelSearchPlaceholder,noMatches:r.modelNoMatches,capabilitiesFilter:`vision`,registryEmptyHint:n.visionRegistryEmpty,outOfFilterNote:n.visionOutOfFilterNote,onChange:e=>{let n=[...i.imageModelFallbacks];n[t]=e,a({imageModelFallbacks:n})}})}),(0,$.jsx)(J,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":n.removeModelFallback,onClick:()=>a({imageModelFallbacks:i.imageModelFallbacks.filter((e,n)=>n!==t)}),children:(0,$.jsx)(C,{className:`size-4`,strokeWidth:1.75})})]},ot(e,t,i.imageModelFallbacks))),t[0]=n.removeModelFallback,t[1]=n.visionOutOfFilterNote,t[2]=n.visionRegistryEmpty,t[3]=r,t[4]=i.imageModelFallbacks,t[5]=a,t[6]=c):c=t[6];let l;t[7]!==i.imageModelFallbacks||t[8]!==a?(l=()=>a({imageModelFallbacks:[...i.imageModelFallbacks,``]}),t[7]=i.imageModelFallbacks,t[8]=a,t[9]=l):l=t[9];let u;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(b,{className:`size-4 shrink-0`,strokeWidth:1.75}),t[10]=u):u=t[10];let d;t[11]!==n.addModelFallback||t[12]!==l?(d=(0,$.jsxs)(J,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5`,onClick:l,children:[u,n.addModelFallback]}),t[11]=n.addModelFallback,t[12]=l,t[13]=d):d=t[13];let f;t[14]!==c||t[15]!==d?(f=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[c,d]}),t[14]=c,t[15]=d,t[16]=f):f=t[16];let p;t[17]!==n.desc.imageModelFallbacks||t[18]!==n.label.imageModelFallbacks||t[19]!==f?(p=(0,$.jsx)(Ke,{label:o,description:s,children:f}),t[17]=n.desc.imageModelFallbacks,t[18]=n.label.imageModelFallbacks,t[19]=f,t[20]=p):p=t[20];let m=n.label.imageGenerationModelFallbacks,h=n.desc.imageGenerationModelFallbacks,g;t[21]!==n.imageGenOutOfFilterNote||t[22]!==n.imageGenRegistryEmpty||t[23]!==n.removeModelFallback||t[24]!==r||t[25]!==i.imageGenerationModelFallbacks||t[26]!==a?(g=i.imageGenerationModelFallbacks.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(nt,{value:e,placeholder:r.modelPlaceholder,searchPlaceholder:r.modelSearchPlaceholder,noMatches:r.modelNoMatches,registryEmptyHint:n.imageGenRegistryEmpty,outOfFilterNote:n.imageGenOutOfFilterNote,onChange:e=>{let n=[...i.imageGenerationModelFallbacks];n[t]=e,a({imageGenerationModelFallbacks:n})}})}),(0,$.jsx)(J,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":n.removeModelFallback,onClick:()=>a({imageGenerationModelFallbacks:i.imageGenerationModelFallbacks.filter((e,n)=>n!==t)}),children:(0,$.jsx)(C,{className:`size-4`,strokeWidth:1.75})})]},ot(e,t,i.imageGenerationModelFallbacks))),t[21]=n.imageGenOutOfFilterNote,t[22]=n.imageGenRegistryEmpty,t[23]=n.removeModelFallback,t[24]=r,t[25]=i.imageGenerationModelFallbacks,t[26]=a,t[27]=g):g=t[27];let _;t[28]!==i.imageGenerationModelFallbacks||t[29]!==a?(_=()=>a({imageGenerationModelFallbacks:[...i.imageGenerationModelFallbacks,``]}),t[28]=i.imageGenerationModelFallbacks,t[29]=a,t[30]=_):_=t[30];let v;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(b,{className:`size-4 shrink-0`,strokeWidth:1.75}),t[31]=v):v=t[31];let y;t[32]!==n.addModelFallback||t[33]!==_?(y=(0,$.jsxs)(J,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5`,onClick:_,children:[v,n.addModelFallback]}),t[32]=n.addModelFallback,t[33]=_,t[34]=y):y=t[34];let x;t[35]!==g||t[36]!==y?(x=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[g,y]}),t[35]=g,t[36]=y,t[37]=x):x=t[37];let S;t[38]!==n.desc.imageGenerationModelFallbacks||t[39]!==n.label.imageGenerationModelFallbacks||t[40]!==x?(S=(0,$.jsx)(Ke,{label:m,description:h,children:x}),t[38]=n.desc.imageGenerationModelFallbacks,t[39]=n.label.imageGenerationModelFallbacks,t[40]=x,t[41]=S):S=t[41];let w;return t[42]!==S||t[43]!==p?(w=(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[p,S]}),t[42]=S,t[43]=p,t[44]=w):w=t[44],w}function lt(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,D)}var ut=()=>c(Ne);function dt(e){return{imageModel:e.imageModel,imageModelFallbacks:e.imageModelFallbacks,imageGenerationModel:e.imageGenerationModel,imageGenerationModelFallbacks:e.imageGenerationModelFallbacks,imageGenerationModelTimeoutMs:e.imageGenerationModelTimeoutMs,imageGenerationModelAutoProviderFallback:e.imageGenerationModelAutoProviderFallback}}function ft(e){return{credentialsIntro:e.credentialsIntro,regionHint:e.regionHint,endpointPresetsHint:e.endpointPresetsHint,apiKeyLabel:e.apiKeyLabel,optionalPlaceholder:e.optionalPlaceholder,regionLabel:e.regionLabel,baseUrlLabel:e.baseUrlLabel,imageBaseUrlLabel:e.imageBaseUrlLabel,saveCredentials:e.saveCredentials,savingCredentials:e.savingCredentials,credentialsSaved:e.credentialsSaved,discardCredentials:e.discardCredentials,credentialsNothingToSave:e.credentialsNothingToSave,credentialsSaveError:e.credentialsSaveError,regionPresetDefault:e.regionPresetDefault,regionPresetCustom:e.regionPresetCustom,baseUrlPresetDefault:e.baseUrlPresetDefault,baseUrlPresetCustom:e.baseUrlPresetCustom,openExtensionSettings:e.openExtensionSettings,openImageModelsPage:e.openImageModelsPage,extensionSettingsLinkTitle:e.extensionSettingsLinkTitle,imageModelsLinkTitle:e.imageModelsLinkTitle,configured:e.configured,missingKey:e.missingKey,unsavedChanges:e.unsavedChanges,expandProvider:e.expandProvider,collapseProvider:e.collapseProvider,defaultModel:e.defaultModel,modelsLabel:e.modelsLabel,modelCountOne:e.modelCountOne,modelCountMany:e.modelCountMany,imageBaseUrlPresetHint:e.imageBaseUrlPresetHint,dashscopeRegion_beijing:e.dashscopeRegion_beijing,dashscopeRegion_singapore:e.dashscopeRegion_singapore,dashscopeRegion_us:e.dashscopeRegion_us,apiKeyMaskedHelp:e.apiKeyMaskedHelp,apiKeyCopy:e.apiKeyCopy,apiKeyCopied:e.apiKeyCopied,apiKeyShow:e.apiKeyShow,apiKeyHide:e.apiKeyHide,apiKeyNotInConfigFile:e.apiKeyNotInConfigFile,apiKeyRevealFailed:e.apiKeyRevealFailed,minimaxClusterLabel:e.minimaxClusterLabel,minimaxClusterHint:e.minimaxClusterHint,falQueueBaseLabel:e.falQueueBaseLabel,falQueueBaseHint:e.falQueueBaseHint}}var pt=A(),mt={loading:!0,saving:!1,savedFlash:!1,error:void 0};function ht({embedded:e=!1}={}){let t=o(e=>e.language),n=a(t),r=n.imageModelsSettings,c=!!s(e=>e.token),[l,u]=(0,Q.useReducer)(pt,{form:null,baseline:null}),f=l.form,p=l.baseline,[h,g]=(0,Q.useReducer)(m,mt),{loading:_,saving:y,savedFlash:b,error:x}=h,S=v(),C=(0,Q.useMemo)(()=>new Set(S.map(e=>e.id)),[S]),w=(0,Q.useCallback)(async()=>{if(c){g({type:`patch`,patch:{loading:!0,error:void 0}});try{let e=await Je();u({type:`sync`,value:structuredClone(e)})}catch(e){g({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{g({type:`patch`,patch:{loading:!1}})}}},[c]);(0,Q.useEffect)(()=>{w()},[w]);let T=(0,Q.useCallback)(e=>{u({type:`patch`,patch:e})},[]),{data:E=[]}=d(c?ut():null,Be,{revalidateOnFocus:!1}),D=E.some(e=>e.configured),O=W(c),k=Me(E),A=(0,Q.useMemo)(()=>!f||!p?!1:JSON.stringify(dt(f))!==JSON.stringify(dt(p)),[f,p]),j=A||k.credDirty;(0,Q.useEffect)(()=>{if(!j)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[j]);let M=(0,Q.useCallback)(async()=>{if(f){g({type:`patch`,patch:{saving:!0,error:void 0}});try{try{qe(f.paramsJson)}catch(e){g({type:`patch`,patch:{error:e instanceof SyntaxError?n.agentSettings.advanced.paramsInvalidJson:e instanceof Error?e.message:n.agentSettings.advanced.paramsInvalidJson}});return}let e=[];A&&e.push(Ge(f).then(()=>{u({type:`saved`,value:structuredClone(f)}),O.mutate?.()})),k.credDirty&&e.push(k.saveCredentials(r.credentialsSaveError)),await Promise.all(e),g({type:`patch`,patch:{savedFlash:!0}}),window.setTimeout(()=>g({type:`patch`,patch:{savedFlash:!1}}),1500)}catch(e){g({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{g({type:`patch`,patch:{saving:!1}})}}},[f,A,O,n.agentSettings,k,r.credentialsSaveError]),N=(0,Q.useCallback)(()=>{p&&(u({type:`discard`}),k.credDirty&&k.onDiscardCredentials(),g({type:`patch`,patch:{error:void 0,savedFlash:!1}}))},[p,k]);Ye({id:`image-models`,dirty:j,saving:y,save:M,discard:N});let P=(0,Q.useMemo)(()=>ft(r),[r]),F=(0,Q.useMemo)(()=>({getApiKey:n.providersSettings.getApiKey,getApiKeyIntl:n.providersSettings.getApiKeyIntl,getApiKeyCn:n.providersSettings.getApiKeyCn}),[n.providersSettings]),I=e?`flex flex-col gap-4`:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-8`,L=e?`w-full text-sm text-fg-muted`:`mx-auto w-full max-w-app-main px-4 py-8 text-sm text-fg-muted`,R=e?`flex w-full items-center gap-2 text-sm text-fg-muted`:`mx-auto flex w-full max-w-app-main items-center gap-2 px-4 py-8 text-sm text-fg-muted`;return c?_||!f?(0,$.jsxs)(`div`,{className:R,children:[(0,$.jsx)(_e,{className:`size-4 animate-spin`}),` Loading…`]}):(0,$.jsxs)(`div`,{className:I,children:[e?null:(0,$.jsxs)(`header`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:r.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[b?(0,$.jsx)(`span`,{className:`text-sm text-fg-muted`,children:r.saved}):null,(0,$.jsx)(J,{type:`button`,variant:`secondary`,onClick:N,disabled:!j||y,children:r.discard}),(0,$.jsxs)(J,{type:`button`,variant:`primary`,onClick:()=>void M(),disabled:!j||y,children:[y?(0,$.jsx)(_e,{className:`size-3.5 animate-spin`}):(0,$.jsx)(V,{className:`size-3.5`}),(0,$.jsx)(`span`,{className:`ml-1.5`,children:y?r.saving:r.save})]})]})]}),x?(0,$.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:x}):null,(0,$.jsx)(st,{form:f,update:T,a:n.agentSettings,chat:n.chat}),(0,$.jsx)(He,{advancedOnly:!0,showLabel:r.fallbackChainsTitle,hideLabel:r.fallbackChainsTitle,children:(0,$.jsx)(ct,{form:f,update:T,a:n.agentSettings,chat:n.chat})}),(0,$.jsx)(He,{advancedOnly:!0,showLabel:r.runtimeTuningTitle,hideLabel:r.runtimeTuningTitle,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium text-fg`,children:r.timeoutLabel}),(0,$.jsx)(`input`,{type:`number`,min:0,step:1e3,className:i(lt(),`max-w-48`),value:f.imageGenerationModelTimeoutMs??``,placeholder:`120000`,onChange:e=>{let t=e.target.value.trim(),n=t===``?null:Math.max(0,Math.floor(Number(t)));T({imageGenerationModelTimeoutMs:n&&n>0?n:null})}}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.timeoutHint})]}),(0,$.jsxs)(`label`,{className:`flex items-start gap-3 text-sm`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5`,checked:f.imageGenerationModelAutoProviderFallback,onChange:e=>T({imageGenerationModelAutoProviderFallback:e.target.checked}),"aria-label":r.autoFallbackLabel}),(0,$.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:r.autoFallbackLabel}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:r.autoFallbackHint})]})]})]})}),(0,$.jsx)(He,{advancedOnly:!0,icon:G,showLabel:r.providersTitle,hideLabel:r.providersTitle,defaultOpen:D,children:E.length===0?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.providersEmpty}):(0,$.jsx)(Pe,{summaries:E,credDraft:k.credDraft,credBaseline:k.credBaseline,credDirty:k.credDirty,credSaving:k.credSaving,credError:k.credError,credSavedFlash:k.credSavedFlash,credNoopFlash:k.credNoopFlash,updateCredRow:k.updateCredRow,onDiscardCredentials:k.onDiscardCredentials,onSaveCredentials:()=>void k.saveCredentials(r.credentialsSaveError),extensionIds:C,showExtensionLinks:!0,showImageModelsLink:!1,hideActions:!0,language:t,apiKeyLinkLabels:F,messages:P})})]}):(0,$.jsx)(`div`,{className:L,children:t===`zh`?`请先登录网关。`:`Connect to a gateway to continue.`})}var gt=M;function _t(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`groq`:return`(GROQ_API_KEY)`;default:return``}}function vt(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`minimax`:return`(MINIMAX_API_KEY)`;default:return``}}function yt(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,D,`dark:border-edge`)}function bt(){return i(_,M)}var xt=[{id:`paraformer-v2`,name:`Paraformer v2`},{id:`paraformer-v1`,name:`Paraformer v1`}],St=[{id:`whisper-1`,name:`Whisper-1`}],Ct=[{id:`whisper-large-v3-turbo`,name:`Whisper Large v3 Turbo`},{id:`whisper-large-v3`,name:`Whisper Large v3`}],wt=[{id:`tts-1`,name:`TTS-1`},{id:`tts-1-hd`,name:`TTS-1 HD`}],Tt=[{id:`alloy`,name:`Alloy`},{id:`echo`,name:`Echo`}],Et=[{id:`qwen-tts`,name:`Qwen TTS`},{id:`qwen3-tts-flash`,name:`Qwen3 TTS Flash`}],Dt=[{id:`Cherry`,name:`Cherry`},{id:`longxiaochun`,name:`Long Xiao Chun`}],Ot=[{id:`en-US-MichelleNeural`,name:`Michelle (US English)`},{id:`zh-CN-XiaoxiaoNeural`,name:`Xiaoxiao (Chinese)`}],kt=[{id:`speech-2.8-hd`,name:`Speech 2.8 HD (Recommended)`},{id:`speech-2.8-turbo`,name:`Speech 2.8 Turbo (Fast)`}],At=[{id:`male-qn-qingse`,name:`Male Qingse (青涩男声)`},{id:`female-shaonv`,name:`Female Shaonv (少女音)`}],jt=[{id:`openai`,capability:`tts`,displayName:`OpenAI`,aliases:[],configured:!1,fields:[],diagnostics:{requiresApiKey:!0,configPath:`messages.tts.providers.openai`}},{id:`alibaba`,capability:`tts`,displayName:`Alibaba DashScope`,aliases:[],configured:!1,fields:[],diagnostics:{requiresApiKey:!0,configPath:`messages.tts.providers.alibaba`}},{id:`minimax`,capability:`tts`,displayName:`MiniMax`,aliases:[],configured:!1,fields:[],diagnostics:{requiresApiKey:!0,configPath:`messages.tts.providers.minimax`}},{id:`edge`,capability:`tts`,displayName:`Microsoft Edge`,aliases:[],configured:!1,fields:[],diagnostics:{requiresApiKey:!1,configPath:`messages.tts.providers.edge`}},{id:`tts-local-cli`,capability:`tts`,displayName:`Local CLI`,aliases:[`cli`,`local-cli`],configured:!1,fields:[],diagnostics:{requiresApiKey:!1,configPath:`messages.tts.providers.tts-local-cli`}}],Mt=[{id:`alibaba`,capability:`stt`,displayName:`Alibaba DashScope`,aliases:[`dashscope`,`paraformer`],configured:!1,fields:[],diagnostics:{requiresApiKey:!0,configPath:`tools.media.audio.providers.alibaba`}},{id:`openai`,capability:`stt`,displayName:`OpenAI Whisper`,aliases:[],configured:!1,fields:[],diagnostics:{requiresApiKey:!0,configPath:`tools.media.audio.providers.openai`}}];function Nt(e,t){switch(e){case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function Pt(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 Ft(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function It(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 Lt(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 Rt(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`discard`:return e.baseline?{form:structuredClone(e.baseline),baseline:e.baseline}:e;case`saved`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}}}function zt({embedded:e=!1}={}){let t=o(e=>e.language),n=a(t),r=n.voiceSettings,i=!!s(e=>e.token),[l,u]=(0,Q.useReducer)(Rt,{form:null,baseline:null}),f=l.form,p=l.baseline,[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(!1),S=(0,Q.useRef)(!1),C=(0,Q.useRef)({parsed:null,models:void 0}),{data:w,error:T,isLoading:E,mutate:D}=W(i),{data:O,error:k,isLoading:A,mutate:j}=d(i?c(`/api/voice/models`):null,Fe,{revalidateOnFocus:!1}),{data:M,error:N,isLoading:P}=d(i?c(`/api/voice/providers`):null,Le,{revalidateOnFocus:!1}),{data:F,error:I,isLoading:L}=d(i?c(`/api/voice/stt-providers`):null,je,{revalidateOnFocus:!1}),R=(0,Q.useMemo)(()=>M?.providers??jt,[M]),z=(0,Q.useMemo)(()=>F?.providers??Mt,[F]),B=(0,Q.useMemo)(()=>w?.payload?.config===void 0?null:Ie(w.payload.config),[w]),V=(0,Q.useMemo)(()=>!f||!p?!1:JSON.stringify(f)!==JSON.stringify(p),[f,p]);i?B!==null&&O!==void 0&&!S.current&&(C.current.parsed!==B||C.current.models!==O)&&(C.current={parsed:B,models:O},u({type:`sync`,value:B}),h(O),x(!1)):(C.current.parsed!==null||C.current.models!==void 0)&&(C.current={parsed:null,models:void 0},u({type:`reset`}),h(null),S.current=!1);let H=!!(i&&(B===null||O===void 0||M===void 0||F===void 0)&&(E||A||P||L)),U=T instanceof Error?T.message:T?String(T):k instanceof Error?k.message:k?String(k):N instanceof Error?N.message:N?String(N):I instanceof Error?I.message:I?String(I):null,ee=(0,Q.useCallback)(e=>{S.current=!0,u({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e}}:null})},[]),G=(0,Q.useCallback)(e=>{S.current=!0,u({type:`update`,updater:t=>t?{...t,stt:{...t.stt,alibaba:{...t.stt.alibaba,...e}}}:null})},[]),te=(0,Q.useCallback)(e=>{S.current=!0,u({type:`update`,updater:t=>t?{...t,stt:{...t.stt,openai:{...t.stt.openai,...e}}}:null})},[]),ne=(0,Q.useCallback)(e=>{S.current=!0,u({type:`update`,updater:t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!0,order:[`alibaba`,`openai`]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}}})},[]),re=(0,Q.useCallback)(e=>{S.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),ie=(0,Q.useCallback)(e=>{S.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,alibaba:{...t.tts.alibaba,...e}}}:null})},[]),K=(0,Q.useCallback)(e=>{S.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,openai:{...t.tts.openai,...e}}}:null})},[]),q=(0,Q.useCallback)(e=>{S.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,edge:{...t.tts.edge,...e}}}:null})},[]),ae=(0,Q.useCallback)(e=>{S.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,minimax:{...t.tts.minimax,...e}}}:null})},[]),oe=(0,Q.useCallback)(e=>{S.current=!0,u({type:`update`,updater:t=>t?{...t,tts:{...t.tts,"tts-local-cli":{...t.tts[`tts-local-cli`],...e}}}:null})},[]),se=(0,Q.useCallback)(async()=>{if(!(!f||g)){_(!0),y(null),x(!1);try{await Re(f),u({type:`saved`,value:f}),S.current=!1,x(!0),window.setTimeout(()=>x(!1),2500)}catch(e){y(e instanceof Error?e.message:r.saveError)}finally{_(!1)}}},[f,g,r.saveError]),Y=(0,Q.useCallback)(()=>{p&&(S.current=!1,u({type:`discard`}),y(null),x(!1))},[p]);Ye({id:`voice`,dirty:V,saving:g,save:se,discard:Y});let ue=e?`flex flex-col gap-4`:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,de=e?`flex flex-col gap-3`:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`;if(!i)return(0,$.jsxs)(`div`,{className:de,children:[e?null:(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.settingsSections.voice}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.needToken})]});if(H)return(0,$.jsx)(`div`,{className:de,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(_e,{className:`size-4 animate-spin`}),r.loading]})});if(!f||m===null)return(0,$.jsxs)(`div`,{className:de,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:v??U??r.loadError}),(0,$.jsx)(J,{type:`button`,variant:`secondary`,onClick:()=>{D(),j()},children:r.retry})]});let fe=f.stt,pe=f.tts,me=Ft(r);return(0,$.jsxs)(`div`,{className:ue,children:[(0,$.jsxs)(`header`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[e?(0,$.jsx)(`div`,{className:`min-w-0`,"aria-hidden":!0}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.settingsSections.voice}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle}),(0,$.jsxs)(`a`,{href:le(t,`voice`),target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[r.docsLink,(0,$.jsx)(ce,{className:`size-3.5`})]})]}),e?null:(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[b?(0,$.jsx)(`span`,{className:`text-sm text-fg-muted`,children:r.saved}):null,(0,$.jsx)(J,{type:`button`,variant:`secondary`,disabled:!V||g,onClick:Y,children:r.discard}),(0,$.jsx)(J,{type:`button`,variant:`primary`,disabled:!V||g,onClick:()=>void se(),children:g?r.saving:r.save})]})]}),V&&!e?(0,$.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:r.unsavedHint}):null,v?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:v}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(Bt,{v:r,apiKeyLabels:me,stt:fe,models:m,sttProviders:z,updateStt:ee,updateSttAlibaba:G,updateSttOpenai:te,updateSttFallback:ne}),(0,$.jsx)(Gt,{v:r,apiKeyLabels:me,tts:pe,models:m,ttsProviders:R,updateTts:re,updateTtsAlibaba:ie,updateTtsOpenai:K,updateTtsEdge:q,updateTtsMinimax:ae,updateTtsLocalCli:oe})]}),(0,$.jsxs)(`div`,{className:`rounded-xl border border-accent/25 bg-accent/5 px-4 py-3 dark:border-accent/30 dark:bg-accent/10`,children:[(0,$.jsxs)(`p`,{className:`text-sm text-fg`,children:[(0,$.jsx)(`strong`,{className:`text-accent`,children:r.notes.title}),` `,r.notes.duration]}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:r.notes.envVars})]})]})}function Bt(e){let t=(0,Z.c)(60),{v:n,apiKeyLabels:r,stt:a,models:o,sttProviders:s,updateStt:c,updateSttAlibaba:l,updateSttOpenai:u,updateSttFallback:d}=e,f=o?.stt?.alibaba?.length?o.stt.alibaba:xt,p=o?.stt?.openai?.length?o.stt.openai:St,m;if(t[0]!==a.provider||t[1]!==s){let e=new Set;m=[];for(let t of s)e.has(t.id)||(e.add(t.id),m.push(t));if(a.provider&&!e.has(a.provider)){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[3]=e):e=t[3];let n;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(n=[{key:`apiKey`,label:`API Key`,type:`password`,secret:!0},{key:`model`,label:`Model`,type:`string`}],t[4]=n):n=t[4];let r=`tools.media.audio.providers.${a.provider}`,i;t[5]===r?i=t[6]:(i={requiresApiKey:!0,configPath:r},t[5]=r,t[6]=i);let o;t[7]!==a.provider||t[8]!==i?(o={id:a.provider,capability:`stt`,displayName:a.provider,aliases:e,configured:!1,fields:n,diagnostics:i},t[7]=a.provider,t[8]=i,t[9]=o):o=t[9],m.push(o)}t[0]=a.provider,t[1]=s,t[2]=m}else m=t[2];let h=m,g,_,v,y,b;if(t[10]!==f||t[11]!==r||t[12]!==p||t[13]!==h||t[14]!==a||t[15]!==c||t[16]!==l||t[17]!==d||t[18]!==u||t[19]!==n){let e=h.find(e=>e.id===a.provider),o=a.providers?.[a.provider],s=typeof o?.apiKey==`string`?o.apiKey:``,m=typeof o?.model==`string`?o.model:``,x={...a.provider===`alibaba`?a.alibaba??{}:{},...a.provider===`openai`?a.openai??{}:{},...o??{}},S=(e?.fields??[]).filter(Wt),C;t[25]!==a.provider||t[26]!==a.providers||t[27]!==c?(C=e=>{c({providers:{...a.providers??{},[a.provider]:{...a.providers?.[a.provider]??{},...e}}})},t[25]=a.provider,t[26]=a.providers,t[27]=c,t[28]=C):C=t[28];let w=C;y=`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`;let T;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(P,{className:`size-4 text-accent`,strokeWidth:1.75}),t[29]=T):T=t[29];let E;t[30]===n.stt.title?E=t[31]:(E=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[T,n.stt.title]}),t[30]=n.stt.title,t[31]=E);let D;t[32]===n.stt.description?D=t[33]:(D=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[32]=n.stt.description,t[33]=D),t[34]!==E||t[35]!==D?(b=(0,$.jsxs)(`div`,{className:`mb-4`,children:[E,D]}),t[34]=E,t[35]=D,t[36]=b):b=t[36],g=`space-y-4`;let O;t[37]===n.stt.enable?O=t[38]:(O=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.enable}),t[37]=n.stt.enable,t[38]=O);let k;t[39]===n.stt.enableDesc?k=t[40]:(k=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.enableDesc}),t[39]=n.stt.enableDesc,t[40]=k);let A;t[41]!==O||t[42]!==k?(A=(0,$.jsxs)(`div`,{children:[O,k]}),t[41]=O,t[42]=k,t[43]=A):A=t[43];let j;t[44]===c?j=t[45]:(j=e=>c({enabled:e.target.checked}),t[44]=c,t[45]=j);let M;t[46]!==a.enabled||t[47]!==j?(M=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:a.enabled,onChange:j}),t[46]=a.enabled,t[47]=j,t[48]=M):M=t[48],t[49]!==A||t[50]!==M?(_=(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:[A,M]}),t[49]=A,t[50]=M,t[51]=_):_=t[51],v=a.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,gt),children:[(0,$.jsx)(Qt,{children:n.stt.provider}),(0,$.jsx)(`select`,{className:bt(),value:a.provider,onChange:e=>c({provider:e.target.value}),children:h.map(e=>(0,$.jsxs)(`option`,{value:e.id,children:[Nt(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,$.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,gt),children:[(0,$.jsx)(Qt,{children:n.stt.model}),a.provider===`alibaba`?(0,$.jsx)(`select`,{className:bt(),value:a.alibaba?.model??``,onChange:e=>l({model:e.target.value}),children:f.map(Ut)}):a.provider===`openai`?(0,$.jsx)(`select`,{className:bt(),value:a.openai?.model??``,onChange:e=>u({model:e.target.value}),children:p.map(Ht)}):a.provider===`groq`?(0,$.jsx)(`select`,{className:bt(),value:m||Ct[0].id,onChange:e=>w({model:e.target.value}),children:Ct.map(Vt)}):(0,$.jsx)(`input`,{className:yt(),value:m,onChange:e=>w({model:e.target.value}),placeholder:a.provider})]}),(0,$.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,gt),children:[(0,$.jsx)(Qt,{children:n.stt.apiKey}),(0,$.jsx)(ze,{kind:`stt`,providerId:a.provider,fieldId:`voice-stt-${a.provider}-api-key`,value:a.provider===`alibaba`?a.alibaba?.apiKey??``:a.provider===`openai`?a.openai?.apiKey??``:s,onChange:e=>{a.provider===`alibaba`?l({apiKey:e}):a.provider===`openai`?u({apiKey:e}):w({apiKey:e})},labels:r,placeholder:a.provider===`groq`?`gsk_...`:`sk-...`}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.stt.apiKeyDesc,_t(a.provider)?` ${_t(a.provider)}`:``]})]})]}),S.length>0?(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:S.map(e=>(0,$.jsx)(Xt,{field:e,value:It(x,e),onChange:t=>w({[e.key]:t}),className:e.type===`textarea`?`sm:col-span-2`:gt},e.key))}):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:a.fallback?.enabled??!0,onChange:e=>d({enabled:e.target.checked})})]})]}):null,t[10]=f,t[11]=r,t[12]=p,t[13]=h,t[14]=a,t[15]=c,t[16]=l,t[17]=d,t[18]=u,t[19]=n,t[20]=g,t[21]=_,t[22]=v,t[23]=y,t[24]=b}else g=t[20],_=t[21],v=t[22],y=t[23],b=t[24];let x;t[52]!==g||t[53]!==_||t[54]!==v?(x=(0,$.jsxs)(`div`,{className:g,children:[_,v]}),t[52]=g,t[53]=_,t[54]=v,t[55]=x):x=t[55];let S;return t[56]!==y||t[57]!==b||t[58]!==x?(S=(0,$.jsxs)(`section`,{className:y,children:[b,x]}),t[56]=y,t[57]=b,t[58]=x,t[59]=S):S=t[59],S}function Vt(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id)}function Ht(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id)}function Ut(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id)}function Wt(e){return e.key!==`apiKey`&&e.key!==`model`}function Gt(e){let t=(0,Z.c)(76),{v:n,apiKeyLabels:r,tts:a,models:o,ttsProviders:s,updateTts:c,updateTtsAlibaba:l,updateTtsOpenai:u,updateTtsEdge:d,updateTtsMinimax:f,updateTtsLocalCli:p}=e,m;t[0]===n?m=t[1]:(m=e=>e===`off`?n.tts.triggerDescOff:e===`always`?n.tts.triggerDescAlways:e===`inbound`?n.tts.triggerDescInbound:e===`tagged`?n.tts.triggerDescTagged:``,t[0]=n,t[1]=m);let h=m,g=o?.tts?.openai?.length?o.tts.openai:wt,_=o?.ttsVoices?.openai?.length?o.ttsVoices.openai:Tt,v=o?.tts?.alibaba?.length?o.tts.alibaba:Et,y=o?.ttsVoices?.alibaba?.length?o.ttsVoices.alibaba:Dt,b=o?.ttsVoices?.edge?.length?o.ttsVoices.edge:Ot,x=o?.tts?.minimax?.length?o.tts.minimax:kt,S=o?.ttsVoices?.minimax?.length?o.ttsVoices.minimax:At,C;if(t[2]!==a.provider||t[3]!==s){let e=new Set;C=[];for(let t of s)e.has(t.id)||(e.add(t.id),C.push(t));if(a.provider&&!e.has(a.provider)){let e;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[5]=e):e=t[5];let n;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(n=[{key:`apiKey`,label:`API Key`,type:`password`,secret:!0},{key:`model`,label:`Model`,type:`string`},{key:`voice`,label:`Voice`,type:`string`}],t[6]=n):n=t[6];let r=`messages.tts.providers.${a.provider}`,i;t[7]===r?i=t[8]:(i={requiresApiKey:!0,configPath:r},t[7]=r,t[8]=i);let o;t[9]!==i||t[10]!==a.provider?(o={id:a.provider,capability:`tts`,displayName:a.provider,aliases:e,configured:!1,fields:n,diagnostics:i},t[9]=i,t[10]=a.provider,t[11]=o):o=t[11],C.push(o)}t[2]=a.provider,t[3]=s,t[4]=C}else C=t[4];let w=C,T,E,D,k,A;if(t[12]!==r||t[13]!==w||t[14]!==h||t[15]!==a||t[16]!==v||t[17]!==x||t[18]!==g||t[19]!==y||t[20]!==b||t[21]!==S||t[22]!==_||t[23]!==c||t[24]!==l||t[25]!==d||t[26]!==p||t[27]!==f||t[28]!==u||t[29]!==n){let e=w.find(e=>e.id===a.provider),o=a.providers?.[a.provider],s={...a.provider===`openai`?a.openai??{}:{},...a.provider===`alibaba`?a.alibaba??{}:{},...a.provider===`edge`?a.edge??{}:{},...a.provider===`minimax`?a.minimax??{}:{},...a.provider===`tts-local-cli`?a[`tts-local-cli`]??{}:{},...o??{}},m=(e?.fields??[]).filter(Yt),C;t[35]!==a.provider||t[36]!==a.providers||t[37]!==c?(C=e=>{c({providers:{...a.providers??{},[a.provider]:{...a.providers?.[a.provider]??{},...e}}})},t[35]=a.provider,t[36]=a.providers,t[37]=c,t[38]=C):C=t[38];let j=C,M;t[39]!==a.provider||t[40]!==j||t[41]!==d||t[42]!==f||t[43]!==u?(M=(e,t)=>{let n={[e.key]:t};j(n),a.provider===`openai`&&e.key===`baseUrl`?u(n):a.provider===`minimax`&&(e.key===`baseUrl`||e.key===`groupId`)?f(n):a.provider===`edge`&&e.key===`lang`&&d(n)},t[39]=a.provider,t[40]=j,t[41]=d,t[42]=f,t[43]=u,t[44]=M):M=t[44];let N=M;k=`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`;let P;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(O,{className:`size-4 text-accent`,strokeWidth:1.75}),t[45]=P):P=t[45];let F;t[46]===n.tts.title?F=t[47]:(F=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[P,n.tts.title]}),t[46]=n.tts.title,t[47]=F);let I;t[48]===n.tts.description?I=t[49]:(I=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.tts.description}),t[48]=n.tts.description,t[49]=I),t[50]!==F||t[51]!==I?(A=(0,$.jsxs)(`div`,{className:`mb-4`,children:[F,I]}),t[50]=F,t[51]=I,t[52]=A):A=t[52],T=`space-y-4`;let L;t[53]===n.tts.enable?L=t[54]:(L=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.tts.enable}),t[53]=n.tts.enable,t[54]=L);let R;t[55]===n.tts.enableDesc?R=t[56]:(R=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.tts.enableDesc}),t[55]=n.tts.enableDesc,t[56]=R);let z;t[57]!==L||t[58]!==R?(z=(0,$.jsxs)(`div`,{children:[L,R]}),t[57]=L,t[58]=R,t[59]=z):z=t[59];let B;t[60]===c?B=t[61]:(B=e=>c({enabled:e.target.checked}),t[60]=c,t[61]=B);let V;t[62]!==B||t[63]!==a.enabled?(V=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:a.enabled,onChange:B}),t[62]=B,t[63]=a.enabled,t[64]=V):V=t[64],t[65]!==z||t[66]!==V?(E=(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:[z,V]}),t[65]=z,t[66]=V,t[67]=E):E=t[67],D=a.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,gt),children:[(0,$.jsx)(Qt,{children:n.tts.trigger}),(0,$.jsxs)(`select`,{className:bt(),value:a.trigger,onChange:e=>c({trigger:e.target.value}),children:[(0,$.jsx)(`option`,{value:`off`,children:n.tts.triggerOff}),(0,$.jsx)(`option`,{value:`always`,children:n.tts.triggerAlways}),(0,$.jsx)(`option`,{value:`inbound`,children:n.tts.triggerInbound}),(0,$.jsx)(`option`,{value:`tagged`,children:n.tts.triggerTagged})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:h(a.trigger)})]}),(0,$.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,gt),children:[(0,$.jsx)(Qt,{children:n.tts.provider}),(0,$.jsx)(`select`,{className:bt(),value:a.provider,onChange:e=>c({provider:e.target.value}),children:w.map(e=>(0,$.jsx)(`option`,{value:e.id,children:Pt(e.id,n)},e.id))})]})]}),a.provider===`openai`||a.provider===`alibaba`||a.provider===`minimax`?(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,gt),children:[(0,$.jsx)(Qt,{children:n.stt.apiKey}),(0,$.jsx)(ze,{kind:`tts`,providerId:a.provider,fieldId:`voice-tts-${a.provider}-api-key`,value:a.provider===`openai`?a.openai?.apiKey??``:a.provider===`alibaba`?a.alibaba?.apiKey??``:a.minimax?.apiKey??``,onChange:e=>{a.provider===`openai`?u({apiKey:e}):a.provider===`alibaba`?l({apiKey:e}):f({apiKey:e})},labels:r,placeholder:a.provider===`minimax`?`eyJ...`:`sk-...`}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.stt.apiKeyDesc,vt(a.provider)?` ${vt(a.provider)}`:``]})]}),(0,$.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,gt),children:[(0,$.jsx)(Qt,{children:n.stt.model}),(0,$.jsx)(`select`,{className:bt(),value:a.provider===`openai`?a.openai?.model??``:a.provider===`alibaba`?a.alibaba?.model??``:a.minimax?.model??``,onChange:e=>{a.provider===`openai`?u({model:e.target.value}):a.provider===`alibaba`?l({model:e.target.value}):f({model:e.target.value})},children:(a.provider===`openai`?g:a.provider===`alibaba`?v:x).map(Jt)})]}),(0,$.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,gt),children:[(0,$.jsx)(Qt,{children:n.tts.voice}),(0,$.jsx)(`select`,{className:bt(),value:a.provider===`openai`?a.openai?.voice??``:a.provider===`alibaba`?a.alibaba?.voice??``:a.minimax?.voice??``,onChange:e=>{a.provider===`openai`?u({voice:e.target.value}):a.provider===`alibaba`?l({voice:e.target.value}):f({voice:e.target.value})},children:(a.provider===`openai`?_:a.provider===`alibaba`?y:S).map(qt)})]})]}):null,a.provider===`edge`?(0,$.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,gt),children:[(0,$.jsx)(Qt,{children:n.tts.voice}),(0,$.jsx)(`select`,{className:bt(),value:a.edge?.voice??``,onChange:e=>d({voice:e.target.value}),children:b.map(Kt)}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.tts.edgeHint})]}):null,a.provider===`tts-local-cli`?(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,$.jsx)(Qt,{children:n.tts.localCli.command}),(0,$.jsx)(`input`,{className:i(yt(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:a[`tts-local-cli`]?.command??``,onChange:e=>p({command:e.target.value}),placeholder:n.tts.localCli.commandPlaceholder}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.tts.localCli.commandDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Qt,{children:n.tts.localCli.cwd}),(0,$.jsx)(`input`,{className:i(yt(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:a[`tts-local-cli`]?.cwd??``,onChange:e=>p({cwd:e.target.value}),placeholder:`/path/to/cwd`}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.tts.localCli.cwdDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Qt,{children:n.tts.localCli.outputFormat}),(0,$.jsxs)(`select`,{className:bt(),value:a[`tts-local-cli`]?.outputFormat??`wav`,onChange:e=>p({outputFormat:e.target.value}),children:[(0,$.jsx)(`option`,{value:`wav`,children:`wav`}),(0,$.jsx)(`option`,{value:`mp3`,children:`mp3`}),(0,$.jsx)(`option`,{value:`opus`,children:`opus`})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.tts.localCli.outputFormatDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,$.jsx)(Qt,{children:n.tts.localCli.timeoutMs}),(0,$.jsx)(`input`,{className:yt(),type:`number`,min:0,step:1e3,value:typeof a[`tts-local-cli`]?.timeoutMs==`number`?String(a[`tts-local-cli`].timeoutMs):``,onChange:e=>{let t=e.target.value.trim();if(t===``){p({timeoutMs:void 0});return}let n=Number(t);Number.isFinite(n)&&n>=0&&p({timeoutMs:n})},placeholder:`30000`}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.tts.localCli.timeoutMsDesc})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:n.tts.localCli.hint})]}):null,m.length>0?(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:m.map(e=>(0,$.jsx)(Xt,{field:e,value:It(s,e),onChange:t=>N(e,t),className:e.type===`textarea`?`sm:col-span-2`:gt},e.key))}):null]}):null,t[12]=r,t[13]=w,t[14]=h,t[15]=a,t[16]=v,t[17]=x,t[18]=g,t[19]=y,t[20]=b,t[21]=S,t[22]=_,t[23]=c,t[24]=l,t[25]=d,t[26]=p,t[27]=f,t[28]=u,t[29]=n,t[30]=T,t[31]=E,t[32]=D,t[33]=k,t[34]=A}else T=t[30],E=t[31],D=t[32],k=t[33],A=t[34];let j;t[68]!==T||t[69]!==E||t[70]!==D?(j=(0,$.jsxs)(`div`,{className:T,children:[E,D]}),t[68]=T,t[69]=E,t[70]=D,t[71]=j):j=t[71];let M;return t[72]!==k||t[73]!==A||t[74]!==j?(M=(0,$.jsxs)(`section`,{className:k,children:[A,j]}),t[72]=k,t[73]=A,t[74]=j,t[75]=M):M=t[75],M}function Kt(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id)}function qt(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id)}function Jt(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id)}function Yt(e){return![`apiKey`,`model`,`voice`].includes(e.key)}function Xt(e){let t=(0,Z.c)(36),{field:n,value:r,onChange:a,className:o}=e,s=`voice-schema-field-${n.key}`,c=n.description;if(n.type===`boolean`){let e;t[0]===o?e=t[1]:(e=i(`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,o),t[0]=o,t[1]=e);let s;t[2]===n.label?s=t[3]:(s=(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n.label}),t[2]=n.label,t[3]=s);let l;t[4]===c?l=t[5]:(l=c?(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:c}):null,t[4]=c,t[5]=l);let u;t[6]!==s||t[7]!==l?(u=(0,$.jsxs)(`span`,{children:[s,l]}),t[6]=s,t[7]=l,t[8]=u):u=t[8];let d=!!r,f;t[9]!==n||t[10]!==a?(f=e=>a(Lt(n,e.target.checked)),t[9]=n,t[10]=a,t[11]=f):f=t[11];let p;t[12]!==d||t[13]!==f?(p=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:d,onChange:f}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;return t[15]!==e||t[16]!==u||t[17]!==p?(m=(0,$.jsxs)(`label`,{className:e,children:[u,p]}),t[15]=e,t[16]=u,t[17]=p,t[18]=m):m=t[18],m}let l=typeof r==`boolean`?``:String(r),u;t[19]===o?u=t[20]:(u=i(`flex flex-col gap-1.5`,o),t[19]=o,t[20]=u);let d;t[21]===n.label?d=t[22]:(d=(0,$.jsx)(Qt,{children:n.label}),t[21]=n.label,t[22]=d);let f;t[23]!==o||t[24]!==n||t[25]!==l||t[26]!==s||t[27]!==a?(f=n.type===`select`?(0,$.jsx)(`select`,{id:s,className:bt(),value:l,required:n.required,onChange:e=>a(Lt(n,e.target.value)),children:(n.options??[]).map(Zt)}):n.type===`textarea`?(0,$.jsx)(`textarea`,{id:s,className:i(yt(),`min-h-24 resize-y`),value:l,required:n.required,placeholder:n.placeholder,onChange:e=>a(Lt(n,e.target.value))}):n.type===`password`?(0,$.jsx)(K,{id:s,className:o,value:l,onChange:e=>a(Lt(n,e)),placeholder:n.placeholder,labels:ge}):(0,$.jsx)(`input`,{id:s,className:yt(),type:n.type===`number`?`number`:`text`,autoComplete:n.secret?`new-password`:`off`,spellCheck:!1,value:l,required:n.required,placeholder:n.placeholder,onChange:e=>a(Lt(n,e.target.value))}),t[23]=o,t[24]=n,t[25]=l,t[26]=s,t[27]=a,t[28]=f):f=t[28];let p;t[29]===c?p=t[30]:(p=c?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:c}):null,t[29]=c,t[30]=p);let m;return t[31]!==u||t[32]!==d||t[33]!==f||t[34]!==p?(m=(0,$.jsxs)(`div`,{className:u,children:[d,f,p]}),t[31]=u,t[32]=d,t[33]=f,t[34]=p,t[35]=m):m=t[35],m}function Zt(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id)}function Qt(e){let t=(0,Z.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 $t(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 en(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 l(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),ke()}async function tn(e){let t=await l(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 nn(e){let t=(0,Z.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 rn(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,D,`dark:border-edge`)}function an(){return i(_,M)}var on=[`brave`,`tavily`,`bing`,`searxng`];function sn(){return{type:`brave`,apiKey:``,url:``,disabled:!1}}var cn=A();function ln({embedded:e=!1}={}){let t=o(e=>e.language),n=a(t),r=n.webSearchSettings,c=n.logs,l=!!s(e=>e.token),[u,d]=(0,Q.useReducer)(cn,{form:null,baseline:null}),f=u.form,p=u.baseline,[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(!1),x=(0,Q.useRef)(!1),S=(0,Q.useRef)(null),{data:C,error:w,isLoading:T,mutate:E}=W(l);Ae({enabled:l,parsed:(0,Q.useMemo)(()=>C?.payload?.config===void 0?null:$t(C.payload.config),[C]),dirty:x.current,trackedParsedRef:S,dispatch:d,onResetDirty:()=>{x.current=!1}});let D=!!(l&&T&&C===void 0&&!w),O=w instanceof Error?w.message:w?String(w):null,k=(0,Q.useMemo)(()=>!f||!p?!1:JSON.stringify(f)!==JSON.stringify(p),[f,p]),A=(0,Q.useCallback)(e=>{x.current=!0,d({type:`patch`,patch:e})},[]),j=(0,Q.useCallback)(async()=>{if(!(!f||m)){h(!0),_(null),y(!1);try{await en(f),x.current=!1,d({type:`saved`,value:f}),y(!0),window.setTimeout(()=>y(!1),2500)}catch(e){_(e instanceof Error?e.message:r.saveError)}finally{h(!1)}}},[f,m,r.saveError]),M=(0,Q.useCallback)(()=>{p&&(x.current=!1,d({type:`discard`}),_(null),y(!1))},[p]);Ye({id:`search`,dirty:k,saving:m,save:j,discard:M});let N=e?`flex flex-col gap-4`:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,P=e?`flex flex-col gap-3`:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`;return l?D?(0,$.jsxs)(`div`,{className:i(P,`items-center`),children:[(0,$.jsx)(_e,{className:`size-8 animate-spin text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.loading})]}):f?(0,$.jsxs)(`div`,{className:N,children:[(0,$.jsxs)(`header`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[e?(0,$.jsx)(`div`,{className:`min-w-0`,"aria-hidden":!0}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:r.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle}),(0,$.jsxs)(`a`,{href:le(t,`gateway`),target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[r.docsLink,(0,$.jsx)(ce,{className:`size-3.5`})]})]}),e?null:(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[v?(0,$.jsx)(`span`,{className:`text-sm text-fg-muted`,children:r.saved}):null,(0,$.jsx)(J,{type:`button`,variant:`secondary`,disabled:!k||m,onClick:M,children:r.discard}),(0,$.jsx)(J,{type:`button`,variant:`primary`,disabled:!k||m,onClick:()=>void j(),children:m?r.saving:r.save})]})]}),k&&!e?(0,$.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:r.unsavedHint}):null,g?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:g}):null,(0,$.jsxs)(We,{children:[(0,$.jsx)(Ue,{icon:he,title:r.sectionRegion,subtitle:r.sectionRegionHint}),(0,$.jsx)(`div`,{className:`flex max-w-md flex-col gap-4`,children:(0,$.jsx)(nn,{label:r.regionLabel,description:r.regionDesc,children:(0,$.jsxs)(`select`,{className:an(),value:f.regionMode,onChange:e=>A({regionMode:e.target.value}),children:[(0,$.jsx)(`option`,{value:`auto`,children:r.regionAuto}),(0,$.jsx)(`option`,{value:`cn`,children:r.regionCn}),(0,$.jsx)(`option`,{value:`global`,children:r.regionGlobal})]})})})]}),(0,$.jsx)(Ve,{children:(0,$.jsxs)(We,{children:[(0,$.jsx)(Ue,{icon:ue,title:r.sectionBlocklist,subtitle:r.sectionBlocklistHint}),(0,$.jsxs)(`div`,{className:`flex max-w-xl 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:f.blocklistEnabled,onChange:e=>A({blocklistEnabled:e.target.checked})}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium`,children:r.blocklistEnabled}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r.blocklistEnabledDesc})]})]}),(0,$.jsx)(nn,{label:r.blocklistDomains,description:r.blocklistDomainsDesc,children:(0,$.jsx)(`textarea`,{className:i(rn(),`min-h-[6rem] font-mono text-xs`),value:f.blocklistDomains.join(`
2
- `),placeholder:r.blocklistDomainsPlaceholder,disabled:!f.blocklistEnabled,onChange:e=>{A({blocklistDomains:e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]})})}})})]})]})}),(0,$.jsxs)(We,{children:[(0,$.jsx)(Ue,{icon:he,title:r.sectionSearch,subtitle:r.sectionSearchHint}),(0,$.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-6`,children:[(0,$.jsx)(nn,{label:r.maxResultsLabel,description:r.maxResultsDesc,children:(0,$.jsx)(`input`,{type:`number`,min:1,max:50,className:rn(),value:f.maxResults,onChange:e=>A({maxResults:Math.max(1,Math.min(50,Number(e.target.value)||5))})})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r.providersTitle}),f.providers.map((e,t)=>(0,$.jsx)(un,{row:e,providerIndex:t,labels:r,secretLabels:Y(n.providersSettings),onChange:e=>{let n=[...f.providers];n[t]=e,A({providers:n})},onRemove:()=>{A({providers:f.providers.filter((e,n)=>n!==t)})}},`${e.type}:${e.url}:${e.apiKey}:${e.disabled}`)),(0,$.jsxs)(J,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>A({providers:[...f.providers,sn()]}),children:[(0,$.jsx)(b,{className:`size-4`}),r.addProvider]})]})]})]}),(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r.footerHint})]}):(0,$.jsxs)(`div`,{className:P,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:g??O??r.loadError}),(0,$.jsx)(J,{type:`button`,variant:`secondary`,onClick:()=>void E(),children:c.refresh})]}):(0,$.jsxs)(`div`,{className:P,children:[e?null:(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:r.title}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.needToken})]})}function un(e){let t=(0,Z.c)(54),{row:n,providerIndex:r,labels:a,secretLabels:o,onChange:s,onRemove:c}=e,l;t[0]===r?l=t[1]:(l=()=>tn(r).then(dn),t[0]=r,t[1]=l);let u=l,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=i(an(),`min-w-[8rem]`),t[2]=d):d=t[2];let f=n.type,p;t[3]!==s||t[4]!==n?(p=e=>s({...n,type:e.target.value,url:e.target.value===`searxng`?n.url:``}),t[3]=s,t[4]=n,t[5]=p):p=t[5];let m;t[6]===a.providerTypes?m=t[7]:(m=on.map(e=>(0,$.jsx)(`option`,{value:e,children:a.providerTypes[e]},e)),t[6]=a.providerTypes,t[7]=m);let h;t[8]!==n.type||t[9]!==p||t[10]!==m?(h=(0,$.jsx)(`select`,{className:d,value:f,onChange:p,children:m}),t[8]=n.type,t[9]=p,t[10]=m,t[11]=h):h=t[11];let g;t[12]!==s||t[13]!==n?(g=e=>s({...n,disabled:e.target.checked}),t[12]=s,t[13]=n,t[14]=g):g=t[14];let _;t[15]!==n.disabled||t[16]!==g?(_=(0,$.jsx)(`input`,{type:`checkbox`,className:`size-3.5 rounded border-edge`,checked:n.disabled,onChange:g}),t[15]=n.disabled,t[16]=g,t[17]=_):_=t[17];let v;t[18]!==a.disabled||t[19]!==_?(v=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-fg-muted`,children:[_,a.disabled]}),t[18]=a.disabled,t[19]=_,t[20]=v):v=t[20];let y;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(C,{className:`size-4`}),t[21]=y):y=t[21];let b;t[22]===c?b=t[23]:(b=(0,$.jsx)(J,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-fg-muted`,onClick:c,children:y}),t[22]=c,t[23]=b);let x;t[24]!==b||t[25]!==v?(x=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[v,b]}),t[24]=b,t[25]=v,t[26]=x):x=t[26];let S;t[27]!==x||t[28]!==h?(S=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[h,x]}),t[27]=x,t[28]=h,t[29]=S):S=t[29];let w;t[30]!==a.urlDesc||t[31]!==a.urlLabel||t[32]!==s||t[33]!==n?(w=n.type===`searxng`?(0,$.jsx)(nn,{label:a.urlLabel,description:a.urlDesc,children:(0,$.jsx)(`input`,{type:`url`,className:rn(),value:n.url,placeholder:`http://localhost:8080`,onChange:e=>s({...n,url:e.target.value})})}):null,t[30]=a.urlDesc,t[31]=a.urlLabel,t[32]=s,t[33]=n,t[34]=w):w=t[34];let T;t[35]!==s||t[36]!==n?(T=e=>s({...n,apiKey:e}),t[35]=s,t[36]=n,t[37]=T):T=t[37];let E;t[38]!==a.keyPlaceholder||t[39]!==a.keyPlaceholderMasked||t[40]!==a.saveError||t[41]!==u||t[42]!==n.apiKey||t[43]!==o||t[44]!==T?(E=(0,$.jsx)(K,{value:n.apiKey,onChange:T,placeholder:a.keyPlaceholder,labels:o,reveal:u,loadFailedLabel:a.saveError,notInConfigFile:a.keyPlaceholderMasked}),t[38]=a.keyPlaceholder,t[39]=a.keyPlaceholderMasked,t[40]=a.saveError,t[41]=u,t[42]=n.apiKey,t[43]=o,t[44]=T,t[45]=E):E=t[45];let D;t[46]!==a.apiKeyDesc||t[47]!==a.apiKeyLabel||t[48]!==E?(D=(0,$.jsx)(nn,{label:a.apiKeyLabel,description:a.apiKeyDesc,children:E}),t[46]=a.apiKeyDesc,t[47]=a.apiKeyLabel,t[48]=E,t[49]=D):D=t[49];let O;return t[50]!==S||t[51]!==w||t[52]!==D?(O=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-panel/60 p-4 dark:border-edge-subtle`,children:[S,w,D]}),t[50]=S,t[51]=w,t[52]=D,t[53]=O):O=t[53],O}function dn(e){return e.apiKey??null}var fn=[{value:`openai-completions`,label:`OpenAI Completions`},{value:`openai-responses`,label:`OpenAI Responses`},{value:`anthropic-messages`,label:`Anthropic Messages`},{value:`google-generative-ai`,label:`Google Generative AI`},{value:`azure-openai-responses`,label:`Azure OpenAI`},{value:`bedrock-converse-stream`,label:`AWS Bedrock`},{value:`openai-codex-responses`,label:`OpenAI Codex`},{value:`google-gemini-cli`,label:`Google Gemini CLI`},{value:`google-vertex`,label:`Google Vertex AI`}];function pn(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&`message`in t.error){let e=t.error.message;return typeof e==`string`?e:void 0}}function mn(e){if(!e||typeof e!=`object`)return{providers:{}};let t=e,n=t.providers;return n&&typeof n==`object`&&!Array.isArray(n)?e:{...t,providers:{}}}async function hn(){let e=await u(c(`/api/models-json`)),t=await e.json().catch(()=>({}));if(!e.ok||!t.ok||!t.payload)throw Error(pn(t)||`HTTP ${e.status}`);return{...t.payload,config:mn(t.payload.config)}}async function gn(e){let t=await u(c(`/api/models-json`),{method:`PATCH`,body:JSON.stringify({config:e})}),n=await t.json().catch(()=>({}));if(!t.ok||!n.ok||!n.payload)throw Error(pn(n)||`HTTP ${t.status}`);return await U(),n.payload}function _n(e,t,n){return{id:e,name:t||e,input:[`text`],contextWindow:128e3,maxTokens:16384,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},...n}}function vn(){let e=(0,Z.c)(31),t=s(Cn),n=!!t,{data:r,isLoading:i}=W(n),a;e[0]===n?a=e[1]:(a=n?c(`/api/providers/meta`):null,e[0]=n,e[1]=a);let o;e[2]===t?o=e[3]:(o=async e=>{let{payload:n}=await(await fetch(e,{headers:{Authorization:`Bearer ${t}`}})).json();return n?.providers??[]},e[2]=t,e[3]=o);let l;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(l={revalidateOnFocus:!1},e[4]=l):l=e[4];let{data:u,isLoading:f}=d(a,o,l),p;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(p={revalidateOnFocus:!1},e[5]=p):p=e[5];let{data:m,isLoading:h}=d(n?pe:null,Sn,p),g;e[6]===m?g=e[7]:(g=m===void 0?[]:m,e[6]=m,e[7]=g);let _=g,v;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(v={revalidateOnFocus:!1},e[8]=v):v=e[8];let{data:y}=d(n?oe:null,xn,v),b;bb0:{if(!u||r===void 0){let t;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[9]=t):t=e[9],b=t;break bb0}let t;e[10]!==r?.payload?.config||e[11]!==u||e[12]!==_?(t=ie(u,fe(r?.payload?.config),_),e[10]=r?.payload?.config,e[11]=u,e[12]=_,e[13]=t):t=e[13],b=t}let x=b,S;bb1:{if(!y){S=null;break bb1}let t;e[14]===y.config?t=e[15]:(t=mn(y.config),e[14]=y.config,e[15]=t),S=t}let C=S,w;if(e[16]!==x||e[17]!==C||e[18]!==u||e[19]!==_){w=[];let t=new Set((u??[]).filter(bn).map(yn)),n;e[21]===C?n=e[22]:(n=new Set(C?Object.keys(C.providers):[]),e[21]=C,e[22]=n);let r=n;for(let e of x){if(!t.has(e.id))continue;let n=r.has(e.id),i=n?C.providers[e.id]?.models?.length??0:_.filter(t=>t.provider===e.id).length;w.push({id:e.id,name:e.name,configured:!0,isCustom:n,modelCount:i})}if(C){let t;e[23]===C.providers?t=e[24]:(t=Object.entries(C.providers),e[23]=C.providers,e[24]=t);for(let[e,n]of t)w.some(t=>t.id===e)||w.push({id:e,name:e,configured:!0,isCustom:!0,modelCount:n.models?.length??0})}e[16]=x,e[17]=C,e[18]=u,e[19]=_,e[20]=w}else w=e[20];let T=w,E=i||f||h,D;return e[25]!==x||e[26]!==T||e[27]!==C||e[28]!==E||e[29]!==_?(D={cards:T,loading:E,builtinRows:x,customConfig:C,allModels:_},e[25]=x,e[26]=T,e[27]=C,e[28]=E,e[29]=_,e[30]=D):D=e[30],D}function yn(e){return e.id}function bn(e){return e.configured}function xn(){return hn()}function Sn(){return xe()}function Cn(e){return e.token}function wn(e){let t=(0,Z.c)(16),{labels:n,onAdd:r,onManage:i}=e,{cards:a,loading:o}=vn();if(o){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`h-6 w-48 animate-pulse rounded bg-surface-hover`}),t[0]=e):e=t[0];let n;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[e,(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[1,2,3].map(En)})]}),t[1]=n):n=t[1],n}let s;if(t[2]!==a||t[3]!==n||t[4]!==r||t[5]!==i){let e=a.filter(Tn),o=e.length>0?n.titleCount.replace(`{{count}}`,String(e.length)):n.title,c;t[7]===o?c=t[8]:(c=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:o}),t[7]=o,t[8]=c);let l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(b,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t[9]=l):l=t[9];let u;t[10]!==n.addProvider||t[11]!==r?(u=(0,$.jsxs)(J,{type:`button`,variant:`primary`,className:`gap-1.5`,onClick:r,children:[l,n.addProvider]}),t[10]=n.addProvider,t[11]=r,t[12]=u):u=t[12];let d;t[13]!==c||t[14]!==u?(d=(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[c,u]}),t[13]=c,t[14]=u,t[15]=d):d=t[15],s=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,e.length===0?(0,$.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-edge-subtle bg-surface-panel/40 px-6 py-10 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.empty}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.emptyHint}),(0,$.jsxs)(J,{type:`button`,variant:`primary`,className:`mt-4 gap-1.5`,onClick:r,children:[(0,$.jsx)(b,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),n.addProvider]})]}):(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>(0,$.jsx)(Dn,{card:e,labels:n,onManage:()=>i(e.id,e.isCustom)},e.id))})]}),t[2]=a,t[3]=n,t[4]=r,t[5]=i,t[6]=s}else s=t[6];return s}function Tn(e){return e.configured}function En(e){return(0,$.jsx)(`div`,{className:`h-32 animate-pulse rounded-2xl bg-surface-hover`},e)}function Dn(e){let t=(0,Z.c)(28),{card:n,labels:r,onManage:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=i(`group relative flex flex-col justify-between rounded-2xl border border-edge-subtle bg-surface-base p-4 text-left transition-colors`,`hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,X.pressCard),t[0]=o):o=t[0];let s;t[1]===n.name?s=t[2]:(s=(0,$.jsx)(`span`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[1]=n.name,t[2]=s);let c;t[3]!==n.isCustom||t[4]!==r.custom?(c=n.isCustom?(0,$.jsx)(`span`,{className:`shrink-0 rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:r.custom}):null,t[3]=n.isCustom,t[4]=r.custom,t[5]=c):c=t[5];let l;t[6]!==s||t[7]!==c?(l=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(z,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),t[9]=u):u=t[9];let d;t[10]===l?d=t[11]:(d=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[l,u]}),t[10]=l,t[11]=d);let f;t[12]!==n.modelCount||t[13]!==r.modelsCount||t[14]!==r.noModels?(f=n.modelCount>0?r.modelsCount.replace(`{{count}}`,String(n.modelCount)):r.noModels,t[12]=n.modelCount,t[13]=r.modelsCount,t[14]=r.noModels,t[15]=f):f=t[15];let p;t[16]===f?p=t[17]:(p=(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:f}),t[16]=f,t[17]=p);let m;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(Te,{className:`size-3`,"aria-hidden":!0}),t[18]=m):m=t[18];let h;t[19]===r.manage?h=t[20]:(h=(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-xs font-medium text-accent-fg opacity-0 transition-opacity group-hover:opacity-100`,children:[m,r.manage]}),t[19]=r.manage,t[20]=h);let g;t[21]!==h||t[22]!==p?(g=(0,$.jsxs)(`div`,{className:`mt-2.5 flex items-center justify-between`,children:[p,h]}),t[21]=h,t[22]=p,t[23]=g):g=t[23];let _;return t[24]!==a||t[25]!==g||t[26]!==d?(_=(0,$.jsxs)(`button`,{type:`button`,onClick:a,className:o,children:[d,g]}),t[24]=a,t[25]=g,t[26]=d,t[27]=_):_=t[27],_}async function On(e){let t=await u(c(`/api/auth/oauth-async/start`),{method:`POST`,body:JSON.stringify({provider:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`OAuth start failed: ${t.status}`)}return(await t.json()).payload}async function kn(e){let t=await u(c(`/api/auth/oauth-async/${encodeURIComponent(e)}/status`));if(!t.ok)throw Error(`OAuth status: ${t.status}`);return(await t.json()).payload}async function An(e,t){let n=await u(c(`/api/auth/oauth-async/${encodeURIComponent(e)}/code`),{method:`POST`,body:JSON.stringify({code:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`Submit code failed: ${n.status}`)}}async function jn(e){let t=await u(c(`/api/auth/oauth-async/${encodeURIComponent(e)}/cancel`),{method:`POST`});if(!t.ok)throw Error(`Cancel OAuth failed: ${t.status}`)}async function Mn(e){let t=await u(c(`/api/auth/oauth-async/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(`Cleanup session failed: ${t.status}`)}async function Nn(e){let t=await u(c(`/api/auth/oauth/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(`Revoke OAuth failed: ${t.status}`)}var Pn=[`common`,`specialty`,`enterprise`,`oauth`,`extension`];function Fn(e){let t=new Map;for(let e of Pn)t.set(e,[]);for(let n of e){let e=n.category||`specialty`,r=t.get(e)??[];r.push(n),t.set(e,r)}return t}var In={ollama:{baseUrl:`http://localhost:11434/v1`,api:`openai-completions`,apiKey:`ollama`},lmstudio:{baseUrl:`http://localhost:1234/v1`,api:`openai-completions`,apiKey:`lmstudio`},openrouter:{baseUrl:`https://openrouter.ai/api/v1`,api:`openai-completions`,apiKey:``},zhipuCn:{baseUrl:`https://open.bigmodel.cn/api/coding/paas/v4`,api:`openai-completions`,apiKey:`ZHIPU_API_KEY`},zaiGeneral:{baseUrl:`https://api.z.ai/api/paas/v4`,api:`openai-completions`,apiKey:`ZAI_API_KEY`}};function Ln(e){return e===`openrouter`?`openrouter`:e===`zhipuCn`?`zhipu-cn`:e===`zaiGeneral`?`zai`:e}var Rn=[{value:`text`,labelKey:`inputTextOnly`},{value:`text,image`,labelKey:`inputTextVision`}];function zn(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,D,`dark:border-edge`)}function Bn(){return i(_,M)}function Vn(e){return(e.input||[`text`]).includes(`image`)?`text,image`:`text`}function Hn(e){return e===`text,image`?[`text`,`image`]:[`text`]}function Un(e){let t=(0,Z.c)(21),{open:n,onOpenChange:r,builtinRows:a,customConfig:o,labels:s,language:c,onSaved:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u={type:`pick`},t[0]=u):u=t[0];let[d,f]=(0,Q.useState)(u),[p,m]=(0,Q.useState)(``),h;t[1]===r?h=t[2]:(h=e=>{e||window.setTimeout(()=>{f({type:`pick`}),m(``)},200),r(e)},t[1]=r,t[2]=h);let g=h,_;t[3]!==g||t[4]!==l?(_=()=>{l(),g(!1)},t[3]=g,t[4]=l,t[5]=_):_=t[5];let v=_,y;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(I,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,H)}),t[6]=y):y=t[6];let b;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(b=i(`fixed left-1/2 top-1/2 flex max-h-[85vh] w-full max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base shadow-xl`,q),t[7]=b):b=t[7];let x;t[8]!==a||t[9]!==o||t[10]!==v||t[11]!==s||t[12]!==c||t[13]!==p||t[14]!==d.providerId||t[15]!==d.type?(x=(0,$.jsxs)(B,{children:[y,(0,$.jsx)(T,{className:b,children:d.type===`pick`?(0,$.jsx)(Gn,{builtinRows:a,searchQuery:p,onSearchChange:m,labels:s,onPickBuiltin:e=>f({type:`builtin`,providerId:e}),onPickCustom:()=>f({type:`custom`})}):d.type===`builtin`?(0,$.jsx)(Kn,{providerId:d.providerId,builtinRows:a,labels:s,language:c,onBack:()=>f({type:`pick`}),onSaved:v}):(0,$.jsx)(Yn,{customConfig:o,labels:s,language:c,onBack:()=>f({type:`pick`}),onSaved:v})})]}),t[8]=a,t[9]=o,t[10]=v,t[11]=s,t[12]=c,t[13]=p,t[14]=d.providerId,t[15]=d.type,t[16]=x):x=t[16];let S;return t[17]!==g||t[18]!==n||t[19]!==x?(S=(0,$.jsx)(k,{open:n,onOpenChange:g,children:x}),t[17]=g,t[18]=n,t[19]=x,t[20]=S):S=t[20],S}function Wn(e){let t=(0,Z.c)(4),{label:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,X.press),t[0]=r):r=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(se,{className:`size-4`,"aria-hidden":!0}),t[1]=a):a=t[1];let o;return t[2]===n?o=t[3]:(o=(0,$.jsx)(ve,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:r,"aria-label":n,children:a})}),t[2]=n,t[3]=o),o}function Gn(e){let t=(0,Z.c)(42),{builtinRows:n,searchQuery:r,onSearchChange:a,labels:o,onPickBuiltin:s,onPickCustom:c}=e,l;t[0]===r?l=t[1]:(l=r.trim().toLowerCase(),t[0]=r,t[1]=l);let u=l,d;bb0:{if(!u){d=n;break bb0}let e;if(t[2]!==n||t[3]!==u){let r;t[5]===u?r=t[6]:(r=e=>{let t=w[e.id]?.aliases??[];return e.id.toLowerCase().includes(u)||e.name.toLowerCase().includes(u)||t.some(e=>e.toLowerCase().includes(u))},t[5]=u,t[6]=r),e=n.filter(r),t[2]=n,t[3]=u,t[4]=e}else e=t[4];d=e}let f=d,m;t[7]===f?m=t[8]:(m=Fn(f),t[7]=f,t[8]=m);let h=m,g;t[9]===o.step1Title?g=t[10]:(g=(0,$.jsx)(p,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:o.step1Title}),t[9]=o.step1Title,t[10]=g);let _;t[11]===o.close?_=t[12]:(_=(0,$.jsx)(Wn,{label:o.close}),t[11]=o.close,t[12]=_);let v;t[13]!==g||t[14]!==_?(v=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-edge-subtle px-5 py-4`,children:[g,_]}),t[13]=g,t[14]=_,t[15]=v):v=t[15];let y;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(he,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[16]=y):y=t[16];let b;t[17]===a?b=t[18]:(b=e=>a(e.target.value),t[17]=a,t[18]=b);let x=o.searchPlaceholder,S;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(S=i(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-10 pr-3 text-sm text-fg placeholder:text-fg-subtle`,D),t[19]=S):S=t[19];let C;t[20]!==o.searchPlaceholder||t[21]!==r||t[22]!==b?(C=(0,$.jsx)(`div`,{className:`px-5 pt-3`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[y,(0,$.jsx)(`input`,{type:`search`,value:r,onChange:b,placeholder:x,autoComplete:`off`,autoFocus:!0,className:S})]})}),t[20]=o.searchPlaceholder,t[21]=r,t[22]=b,t[23]=C):C=t[23];let T;t[24]!==o.addCustom||t[25]!==o.customDescription||t[26]!==c||t[27]!==u?(T=u?null:(0,$.jsxs)(`button`,{type:`button`,onClick:c,className:i(`mb-3 flex w-full items-center gap-3 rounded-xl border border-dashed border-edge-subtle bg-surface-panel/40 px-4 py-3 text-left transition-colors`,`hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,X.press),children:[(0,$.jsx)(Oe,{className:`size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:o.addCustom}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:o.customDescription})]}),(0,$.jsx)(Ce,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0})]}),t[24]=o.addCustom,t[25]=o.customDescription,t[26]=c,t[27]=u,t[28]=T):T=t[28];let E;t[29]!==f.length||t[30]!==h||t[31]!==o.categories||t[32]!==o.noResults||t[33]!==s?(E=f.length===0?(0,$.jsx)(`p`,{className:`py-6 text-center text-sm text-fg-muted`,children:o.noResults}):(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:Pn.map(e=>{let t=h.get(e)??[];return t.length===0?null:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`mb-1 px-1 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:o.categories[e]??e}),(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:t.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>s(e.id),className:i(`flex w-full items-center justify-between gap-2 rounded-lg px-3 py-2.5 text-left transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,X.press),children:[(0,$.jsx)(`span`,{className:`truncate text-sm text-fg`,children:e.name}),e.configured?(0,$.jsx)(z,{className:`size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):null]},e.id))})]},e)})}),t[29]=f.length,t[30]=h,t[31]=o.categories,t[32]=o.noResults,t[33]=s,t[34]=E):E=t[34];let O;t[35]!==T||t[36]!==E?(O=(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-3`,children:[T,E]}),t[35]=T,t[36]=E,t[37]=O):O=t[37];let k;return t[38]!==C||t[39]!==O||t[40]!==v?(k=(0,$.jsxs)($.Fragment,{children:[v,C,O]}),t[38]=C,t[39]=O,t[40]=v,t[41]=k):k=t[41],k}function Kn({providerId:e,builtinRows:t,labels:n,language:r,onBack:o,onSaved:s}){let c=t.find(t=>t.id===e),l=w[e],[u,d]=(0,Q.useState)(``),[f,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(!1),y=(0,Q.useRef)(null),b=a(r).providersSettings,x=Y(b),S=(0,Q.useMemo)(()=>L(e,r),[e,r]),C=c?.supportsApiKey!==!1,T=c?.supportsOAuth===!0,[E,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(null),[j,M]=(0,Q.useState)(`idle`),[N,P]=(0,Q.useState)(null),[I,R]=(0,Q.useState)(null),[B,V]=(0,Q.useState)(``),H=j===`waiting`||j===`waiting_code`;(0,Q.useEffect)(()=>{if(!E||!H)return;let e=window.setInterval(()=>{(async()=>{try{let t=await kn(E);t.status===`waiting_auth`||t.status===`waiting_code`?(M(t.status===`waiting_code`?`waiting_code`:`waiting`),A(t.message??null),P(t.authUrl??null),R(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),M(`success`),A(t.message??b.saved),window.setTimeout(s,600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),M(`error`),A(t.error??t.message??b.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[E,H,s,b.revokeFailed,b.saved]),(0,Q.useEffect)(()=>()=>{E&&Mn(E).catch(()=>{})},[E]);let U=async()=>{M(`waiting`),A(b.oauthStarting),g(null);try{O((await On(e)).sessionId)}catch(e){M(`error`),A(e instanceof Error?e.message:b.revokeFailed)}},ee=async()=>{if(E){try{await jn(E)}catch{}M(`idle`),A(null),O(null),P(null),R(null)}},W=async()=>{if(!(!E||!B.trim()))try{await An(E,B.trim()),V(``),A(b.oauthProcessingCode)}catch(e){M(`error`),A(e instanceof Error?e.message:b.revokeFailed)}},G=async()=>{let t=u.trim();if(!(!t||!C)){m(!0),g(null);try{await we({[e]:t}),v(!0),window.setTimeout(s,600)}catch(e){g(e instanceof Error?e.message:n.saveError)}finally{m(!1)}}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:o,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,X.press),"aria-label":n.back,children:(0,$.jsx)(Ce,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,$.jsx)(p,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:c?.name??e}),(0,$.jsx)(Wn,{label:n.close})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 px-5 py-4`,children:[l?.description?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.description}):null,C?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`builtin-api-key`,className:`text-sm font-medium text-fg`,children:n.apiKeyLabel}),(0,$.jsx)(K,{id:`builtin-api-key`,value:u,onChange:d,placeholder:n.apiKeyPlaceholder,labels:x,inputRef:y,onKeyDown:e=>{e.key===`Enter`&&G()}})]}):null,T?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-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:b.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:b.oauthHint})]}),(0,$.jsxs)(J,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:H,onClick:()=>void U(),children:[H?(0,$.jsx)(_e,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,b.oauth]})]}),k?(0,$.jsx)(`p`,{className:i(`text-xs`,j===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:k}):null,j===`waiting`||j===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[N?(0,$.jsxs)(`a`,{href:N,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-white hover:bg-accent-hover`,children:[b.openAuthPage,(0,$.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]}):null,(0,$.jsx)(J,{type:`button`,variant:`secondary`,onClick:()=>void ee(),children:b.cancelOAuth})]}):null,I?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:I}):null,j===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:B,onChange:e=>V(e.target.value),onKeyDown:e=>e.key===`Enter`&&void W(),placeholder:b.pasteRedirectUrl,className:i(`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`,D)}),(0,$.jsx)(J,{type:`button`,variant:`primary`,onClick:()=>void W(),children:b.submitCode})]}):null]}):null,S.length>0&&C?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:S.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:[F(e,n),(0,$.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]},e))}):null,h?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:h}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsx)(J,{type:`button`,variant:`secondary`,onClick:o,children:n.cancel}),C?(0,$.jsx)(J,{type:`button`,variant:`primary`,disabled:!u.trim()||f||_,onClick:()=>void G(),children:_?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(z,{className:`size-3.5`,"aria-hidden":!0}),n.saved]}):f?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(_e,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save}):null]})]})]})}function qn(e=`custom`){if(e!==`custom`&&In[e]){let t=In[e];return{preset:e,providerId:Ln(e),baseUrl:t.baseUrl??``,api:t.api??`openai-completions`,apiKey:t.apiKey??``,modelIds:[``],error:null}}return{preset:`custom`,providerId:``,baseUrl:``,api:`openai-completions`,apiKey:``,modelIds:[``],error:null}}function Jn(e,t){switch(t.type){case`applyPreset`:return t.key===`custom`?{...e,preset:`custom`,error:null}:In[t.key]?{...qn(t.key),modelIds:e.modelIds}:e;case`setProviderId`:return{...e,providerId:t.value};case`setBaseUrl`:return{...e,baseUrl:t.value};case`setApi`:return{...e,api:t.value};case`setApiKey`:return{...e,apiKey:t.value};case`addModelSlot`:return{...e,modelIds:[...e.modelIds,``]};case`updateModelId`:return{...e,modelIds:e.modelIds.map((e,n)=>n===t.index?t.value:e)};case`removeModelSlot`:return{...e,modelIds:e.modelIds.filter((e,n)=>n!==t.index)};case`setError`:return{...e,error:t.value}}}function Yn({customConfig:e,labels:t,language:n,onBack:r,onSaved:o}){let[s,c]=(0,Q.useReducer)(Jn,void 0,()=>qn()),[l,u]=(0,Q.useState)(!1),d=Y(a(n).providersSettings),{preset:f,providerId:m,baseUrl:h,api:g,apiKey:_,modelIds:v,error:y}=s,x=async()=>{let n=m.trim(),r=h.trim();if(!n){c({type:`setError`,value:t.providerIdRequired});return}if(!r){c({type:`setError`,value:t.baseUrlRequired});return}let i=v.map(e=>e.trim()).filter(Boolean);u(!0),c({type:`setError`,value:null});try{let t=e?.providers??{},a={baseUrl:r,api:g,apiKey:_.trim()||void 0,models:i.map(e=>({id:e}))};await gn({providers:{...t,[n]:a}}),o()}catch(e){c({type:`setError`,value:e instanceof Error?e.message:t.saveError})}finally{u(!1)}},S=m.trim()&&h.trim();return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:r,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,X.press),"aria-label":t.back,children:(0,$.jsx)(Ce,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,$.jsx)(p,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:t.step2CustomTitle}),(0,$.jsx)(Wn,{label:t.close})]}),(0,$.jsxs)(`div`,{className:`flex max-h-[60vh] flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.customDescription}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-preset`,className:`text-sm font-medium text-fg`,children:t.presetLabel}),(0,$.jsxs)(`select`,{id:`custom-preset`,value:f,onChange:e=>c({type:`applyPreset`,key:e.target.value}),className:Bn(),children:[(0,$.jsx)(`option`,{value:`custom`,children:t.presetCustom}),(0,$.jsx)(`option`,{value:`ollama`,children:t.presetOllama}),(0,$.jsx)(`option`,{value:`lmstudio`,children:t.presetLmStudio}),(0,$.jsx)(`option`,{value:`openrouter`,children:t.presetOpenRouter}),(0,$.jsx)(`option`,{value:`zhipuCn`,children:t.presetZhipuCn}),(0,$.jsx)(`option`,{value:`zaiGeneral`,children:t.presetZaiGeneral})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-provider-id`,className:`text-sm font-medium text-fg`,children:t.providerIdLabel}),(0,$.jsx)(`input`,{id:`custom-provider-id`,type:`text`,autoComplete:`off`,autoFocus:!0,value:m,onChange:e=>c({type:`setProviderId`,value:e.target.value}),placeholder:t.providerIdPlaceholder,className:i(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,D)})]}),(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-base-url`,className:`text-sm font-medium text-fg`,children:t.baseUrlLabel}),(0,$.jsx)(`input`,{id:`custom-base-url`,type:`url`,autoComplete:`off`,value:h,onChange:e=>c({type:`setBaseUrl`,value:e.target.value}),placeholder:t.baseUrlPlaceholder,className:i(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,D)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-api-type`,className:`text-sm font-medium text-fg`,children:t.apiTypeLabel}),(0,$.jsx)(`select`,{id:`custom-api-type`,value:g,onChange:e=>c({type:`setApi`,value:e.target.value}),className:Bn(),children:fn.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-api-key`,className:`text-sm font-medium text-fg`,children:t.apiKeyLabel}),(0,$.jsx)(K,{id:`custom-api-key`,value:_,onChange:e=>c({type:`setApiKey`,value:e}),placeholder:t.apiKeyPlaceholder,labels:d})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.modelIdLabel}),v.map((e,n)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`text`,autoComplete:`off`,value:e,onChange:e=>c({type:`updateModelId`,index:n,value:e.target.value}),placeholder:t.modelIdPlaceholder,className:i(`flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,D)}),v.length>1?(0,$.jsx)(`button`,{type:`button`,onClick:()=>c({type:`removeModelSlot`,index:n}),className:i(`rounded-lg p-1.5 text-fg-subtle hover:bg-surface-hover hover:text-fg`,X.press),children:(0,$.jsx)(se,{className:`size-3.5`,"aria-hidden":!0})}):null]},e||`model-slot-${n}`)),(0,$.jsxs)(J,{type:`button`,variant:`ghost`,className:`w-fit gap-1.5 text-fg-muted`,onClick:()=>c({type:`addModelSlot`}),children:[(0,$.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),t.addModel]})]}),y?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:y}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsx)(J,{type:`button`,variant:`secondary`,onClick:r,children:t.cancel}),(0,$.jsx)(J,{type:`button`,variant:`primary`,disabled:!S||l,onClick:()=>void x(),children:l?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(_e,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),t.saving]}):t.save})]})]})}function Xn(e){let t=(0,Z.c)(156),{model:n,isNew:r,providerId:a,onSave:o,onClose:s,m:c}=e,l;t[0]===n?l=t[1]:(l=()=>n?{...n}:_n(``),t[0]=n,t[1]=l);let[u,d]=(0,Q.useState)(l),[f,m]=(0,Q.useState)(Zn),h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=(e,t)=>{d(n=>({...n,[e]:t})),m(t=>{let n=new Map(t);return n.delete(e),n})},t[2]=h):h=t[2];let g=h,_;t[3]!==u.contextWindow||t[4]!==u.id||t[5]!==u.maxTokens||t[6]!==c.modelIdRequired||t[7]!==c.mustBePositive?(_=()=>{let e=new Map;return(u.id||``).trim()||e.set(`id`,c.modelIdRequired),u.contextWindow!==void 0&&u.contextWindow<=0&&e.set(`contextWindow`,c.mustBePositive),u.maxTokens!==void 0&&u.maxTokens<=0&&e.set(`maxTokens`,c.mustBePositive),m(e),e.size===0},t[3]=u.contextWindow,t[4]=u.id,t[5]=u.maxTokens,t[6]=c.modelIdRequired,t[7]=c.mustBePositive,t[8]=_):_=t[8];let v=_,y;t[9]!==u||t[10]!==s||t[11]!==o||t[12]!==v?(y=()=>{if(!v())return;let e=(u.id||``).trim();o({...u,id:e,name:u.name?.trim()||e,reasoning:u.reasoning||!1,input:u.input||[`text`],contextWindow:u.contextWindow??128e3,maxTokens:u.maxTokens??16384,cost:{input:u.cost?.input??0,output:u.cost?.output??0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}}),s()},t[9]=u,t[10]=s,t[11]=o,t[12]=v,t[13]=y):y=t[13];let b=y,x=u,S;t[14]===x?S=t[15]:(S=Vn(x),t[14]=x,t[15]=S);let C=S,w=r?c.addModelTitle:c.editModelTitle,T;t[16]===w?T=t[17]:(T=(0,$.jsx)(p,{className:`text-base font-semibold text-fg`,children:w}),t[16]=w,t[17]=T);let E;t[18]!==c.modelProviderLabel||t[19]!==a?(E=a?(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[c.modelProviderLabel,`: `,a]}):null,t[18]=c.modelProviderLabel,t[19]=a,t[20]=E):E=t[20];let D;t[21]!==T||t[22]!==E?(D=(0,$.jsxs)(`div`,{children:[T,E]}),t[21]=T,t[22]=E,t[23]=D):D=t[23];let O;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(O=i(ee,`p-1.5 hover:bg-surface-base`),t[24]=O):O=t[24];let k;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(se,{className:`size-4`}),t[25]=k):k=t[25];let A;t[26]===c.close?A=t[27]:(A=(0,$.jsx)(ve,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:O,"aria-label":c.close,children:k})}),t[26]=c.close,t[27]=A);let j;t[28]!==D||t[29]!==A?(j=(0,$.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[D,A]}),t[28]=D,t[29]=A,t[30]=j):j=t[30];let M;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[31]=M):M=t[31];let N;t[32]===c.modelId?N=t[33]:(N=(0,$.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[c.modelId,M]}),t[32]=c.modelId,t[33]=N);let P;t[34]===f?P=t[35]:(P=i(zn(),f.has(`id`)&&`border-red-500`),t[34]=f,t[35]=P);let F=u.id||``,I;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(I=e=>g(`id`,e.target.value),t[36]=I):I=t[36];let L=!r,R;t[37]!==P||t[38]!==F||t[39]!==L?(R=(0,$.jsx)(`input`,{className:P,value:F,onChange:I,placeholder:`e.g. llama3.1:8b`,disabled:L}),t[37]=P,t[38]=F,t[39]=L,t[40]=R):R=t[40];let z;t[41]===f?z=t[42]:(z=f.has(`id`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`id`)}):null,t[41]=f,t[42]=z);let B;t[43]!==N||t[44]!==R||t[45]!==z?(B=(0,$.jsxs)(`div`,{children:[N,R,z]}),t[43]=N,t[44]=R,t[45]=z,t[46]=B):B=t[46];let V;t[47]===c.displayName?V=t[48]:(V=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.displayName}),t[47]=c.displayName,t[48]=V);let H;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(H=zn(),t[49]=H):H=t[49];let U=u.name||``,W;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(W=e=>g(`name`,e.target.value),t[50]=W):W=t[50];let G;t[51]===U?G=t[52]:(G=(0,$.jsx)(`input`,{className:H,value:U,onChange:W}),t[51]=U,t[52]=G);let te;t[53]!==V||t[54]!==G?(te=(0,$.jsxs)(`div`,{children:[V,G]}),t[53]=V,t[54]=G,t[55]=te):te=t[55];let ne;t[56]===c.inputTypes?ne=t[57]:(ne=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.inputTypes}),t[56]=c.inputTypes,t[57]=ne);let re;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(re=Bn(),t[58]=re):re=t[58];let ie;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(ie=e=>g(`input`,Hn(e.target.value)),t[59]=ie):ie=t[59];let K;t[60]===c?K=t[61]:(K=Rn.map(e=>(0,$.jsx)(`option`,{value:e.value,children:c[e.labelKey]},e.value)),t[60]=c,t[61]=K);let q;t[62]!==C||t[63]!==K?(q=(0,$.jsx)(`select`,{className:re,value:C,onChange:ie,children:K}),t[62]=C,t[63]=K,t[64]=q):q=t[64];let ae;t[65]!==ne||t[66]!==q?(ae=(0,$.jsxs)(`div`,{children:[ne,q]}),t[65]=ne,t[66]=q,t[67]=ae):ae=t[67];let oe=u.reasoning||!1,ce;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(ce=e=>g(`reasoning`,e.target.checked),t[68]=ce):ce=t[68];let le;t[69]===oe?le=t[70]:(le=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:oe,onChange:ce}),t[69]=oe,t[70]=le);let Y;t[71]!==c.reasoning||t[72]!==le?(Y=(0,$.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[le,c.reasoning]}),t[71]=c.reasoning,t[72]=le,t[73]=Y):Y=t[73];let ue;t[74]!==ae||t[75]!==Y?(ue=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ae,Y]}),t[74]=ae,t[75]=Y,t[76]=ue):ue=t[76];let de;t[77]===c.contextWindow?de=t[78]:(de=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.contextWindow}),t[77]=c.contextWindow,t[78]=de);let fe;t[79]===f?fe=t[80]:(fe=i(zn(),f.has(`contextWindow`)&&`border-red-500`),t[79]=f,t[80]=fe);let pe=u.contextWindow??128e3,me;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(me=e=>g(`contextWindow`,parseInt(e.target.value,10)||0),t[81]=me):me=t[81];let he;t[82]!==fe||t[83]!==pe?(he=(0,$.jsx)(`input`,{type:`number`,min:1,className:fe,value:pe,onChange:me}),t[82]=fe,t[83]=pe,t[84]=he):he=t[84];let ge;t[85]===f?ge=t[86]:(ge=f.has(`contextWindow`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`contextWindow`)}):null,t[85]=f,t[86]=ge);let _e;t[87]!==de||t[88]!==he||t[89]!==ge?(_e=(0,$.jsxs)(`div`,{children:[de,he,ge]}),t[87]=de,t[88]=he,t[89]=ge,t[90]=_e):_e=t[90];let ye;t[91]===c.maxOutputTokens?ye=t[92]:(ye=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.maxOutputTokens}),t[91]=c.maxOutputTokens,t[92]=ye);let be;t[93]===f?be=t[94]:(be=i(zn(),f.has(`maxTokens`)&&`border-red-500`),t[93]=f,t[94]=be);let xe=u.maxTokens??16384,Se;t[95]===Symbol.for(`react.memo_cache_sentinel`)?(Se=e=>g(`maxTokens`,parseInt(e.target.value,10)||0),t[95]=Se):Se=t[95];let Ce;t[96]!==be||t[97]!==xe?(Ce=(0,$.jsx)(`input`,{type:`number`,min:1,className:be,value:xe,onChange:Se}),t[96]=be,t[97]=xe,t[98]=Ce):Ce=t[98];let we;t[99]===f?we=t[100]:(we=f.has(`maxTokens`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`maxTokens`)}):null,t[99]=f,t[100]=we);let Te;t[101]!==ye||t[102]!==Ce||t[103]!==we?(Te=(0,$.jsxs)(`div`,{children:[ye,Ce,we]}),t[101]=ye,t[102]=Ce,t[103]=we,t[104]=Te):Te=t[104];let Ee;t[105]!==_e||t[106]!==Te?(Ee=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[_e,Te]}),t[105]=_e,t[106]=Te,t[107]=Ee):Ee=t[107];let De;t[108]===c.costSection?De=t[109]:(De=(0,$.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:c.costSection}),t[108]=c.costSection,t[109]=De);let X;t[110]===c.costInput?X=t[111]:(X=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:c.costInput}),t[110]=c.costInput,t[111]=X);let Oe;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=zn(),t[112]=Oe):Oe=t[112];let ke=u.cost?.input??0,Ae;t[113]===u.cost?Ae=t[114]:(Ae=e=>g(`cost`,{...u.cost,input:parseFloat(e.target.value)||0,output:u.cost?.output??0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}),t[113]=u.cost,t[114]=Ae);let je;t[115]!==ke||t[116]!==Ae?(je=(0,$.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Oe,value:ke,onChange:Ae}),t[115]=ke,t[116]=Ae,t[117]=je):je=t[117];let Me;t[118]!==X||t[119]!==je?(Me=(0,$.jsxs)(`div`,{children:[X,je]}),t[118]=X,t[119]=je,t[120]=Me):Me=t[120];let Ne;t[121]===c.costOutput?Ne=t[122]:(Ne=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:c.costOutput}),t[121]=c.costOutput,t[122]=Ne);let Pe;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=zn(),t[123]=Pe):Pe=t[123];let Fe=u.cost?.output??0,Ie;t[124]===u.cost?Ie=t[125]:(Ie=e=>g(`cost`,{...u.cost,input:u.cost?.input??0,output:parseFloat(e.target.value)||0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}),t[124]=u.cost,t[125]=Ie);let Le;t[126]!==Fe||t[127]!==Ie?(Le=(0,$.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Pe,value:Fe,onChange:Ie}),t[126]=Fe,t[127]=Ie,t[128]=Le):Le=t[128];let Re;t[129]!==Ne||t[130]!==Le?(Re=(0,$.jsxs)(`div`,{children:[Ne,Le]}),t[129]=Ne,t[130]=Le,t[131]=Re):Re=t[131];let ze;t[132]!==Me||t[133]!==Re?(ze=(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[Me,Re]}),t[132]=Me,t[133]=Re,t[134]=ze):ze=t[134];let Be;t[135]!==De||t[136]!==ze?(Be=(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[De,ze]}),t[135]=De,t[136]=ze,t[137]=Be):Be=t[137];let Ve;t[138]!==B||t[139]!==te||t[140]!==ue||t[141]!==Ee||t[142]!==Be?(Ve=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[B,te,ue,Ee,Be]}),t[138]=B,t[139]=te,t[140]=ue,t[141]=Ee,t[142]=Be,t[143]=Ve):Ve=t[143];let He;t[144]===c.cancel?He=t[145]:(He=(0,$.jsx)(ve,{asChild:!0,children:(0,$.jsx)(J,{type:`button`,variant:`secondary`,children:c.cancel})}),t[144]=c.cancel,t[145]=He);let Ue=r?c.addModelConfirm:c.saveModelConfirm,We;t[146]!==b||t[147]!==Ue?(We=(0,$.jsx)(J,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,onClick:b,children:Ue}),t[146]=b,t[147]=Ue,t[148]=We):We=t[148];let Ge;t[149]!==He||t[150]!==We?(Ge=(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[He,We]}),t[149]=He,t[150]=We,t[151]=Ge):Ge=t[151];let Ke;return t[152]!==j||t[153]!==Ve||t[154]!==Ge?(Ke=(0,$.jsxs)($.Fragment,{children:[j,Ve,Ge]}),t[152]=j,t[153]=Ve,t[154]=Ge,t[155]=Ke):Ke=t[155],Ke}function Zn(){return new Map}function Qn(e){let t=(0,Z.c)(16),{open:n,onOpenChange:r,providerId:a,model:o,isNew:s,onSave:c,m:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(I,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,H)}),t[0]=u):u=t[0];let d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=i(`xopc-dialog-content fixed left-1/2 top-1/2 max-h-[min(90vh,720px)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,q,`overflow-y-auto rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`),t[1]=d):d=t[1];let f;t[2]!==s||t[3]!==l||t[4]!==o||t[5]!==r||t[6]!==c||t[7]!==n||t[8]!==a?(f=n?(0,$.jsx)(Xn,{model:o,isNew:s,providerId:a,onSave:c,onClose:()=>r(!1),m:l},`${a??`none`}-${o?.id??`new`}`):null,t[2]=s,t[3]=l,t[4]=o,t[5]=r,t[6]=c,t[7]=n,t[8]=a,t[9]=f):f=t[9];let p;t[10]===f?p=t[11]:(p=(0,$.jsxs)(B,{children:[u,(0,$.jsx)(T,{className:d,onOpenAutoFocus:$n,children:f})]}),t[10]=f,t[11]=p);let m;return t[12]!==r||t[13]!==n||t[14]!==p?(m=(0,$.jsx)(k,{open:n,onOpenChange:r,children:p}),t[12]=r,t[13]=n,t[14]=p,t[15]=m):m=t[15],m}function $n(e){return e.preventDefault()}function er(e){let t=(0,Z.c)(14),{providerId:n,inputId:r,value:i,onChange:a,labels:o}=e,s;t[0]===n?s=t[1]:(s=()=>be(n).then(tr),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)(K,{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 tr(e){return e.apiKey??null}function nr(e){let t=(0,Z.c)(16),{open:n,onOpenChange:r,providerId:a,isCustom:o,builtinRows:s,customConfig:c,allModels:l,labels:u,language:d,onSaved:f}=e,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(I,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,H)}),t[0]=p):p=t[0];let m;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(m=i(`fixed left-1/2 top-1/2 flex max-h-[85vh] w-full max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base shadow-xl`,q),t[1]=m):m=t[1];let h;t[2]!==l||t[3]!==s||t[4]!==c||t[5]!==o||t[6]!==u||t[7]!==d||t[8]!==r||t[9]!==f||t[10]!==a?(h=(0,$.jsxs)(B,{children:[p,(0,$.jsx)(T,{className:m,children:o?(0,$.jsx)(ir,{providerId:a,customConfig:c,labels:u,language:d,onClose:()=>r(!1),onSaved:f}):(0,$.jsx)(rr,{providerId:a,builtinRows:s,allModels:l,labels:u,language:d,onClose:()=>r(!1),onSaved:f})})]}),t[2]=l,t[3]=s,t[4]=c,t[5]=o,t[6]=u,t[7]=d,t[8]=r,t[9]=f,t[10]=a,t[11]=h):h=t[11];let g;return t[12]!==r||t[13]!==n||t[14]!==h?(g=(0,$.jsx)(k,{open:n,onOpenChange:r,children:h}),t[12]=r,t[13]=n,t[14]=h,t[15]=g):g=t[15],g}function rr({providerId:e,builtinRows:t,allModels:n,labels:r,language:o,onClose:s,onSaved:c}){let l=t.find(t=>t.id===e),u=w[e],d=n.filter(t=>t.provider===e),[m,h]=(0,Q.useState)(l?.apiKey??``),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(!1),O=a(o).providersSettings,k=l?.supportsApiKey!==!1,A=l?.supportsOAuth===!0,M=l?.authMode===`oauth`&&l.authStatus===`connected`,N=l?.configured===!0&&l.activeKeySource!==`env`&&l.activeKeySource!==`extension`&&l.activeKeySource!==`models_json`,[P,I]=(0,Q.useState)(null),[B,V]=(0,Q.useState)(null),[H,U]=(0,Q.useState)(`idle`),[ee,W]=(0,Q.useState)(null),[G,te]=(0,Q.useState)(null),[ne,re]=(0,Q.useState)(``),ie=H===`waiting`||H===`waiting_code`,K=(0,Q.useMemo)(()=>L(e,o),[e,o]),q=m!==(l?.apiKey??``),ae=async()=>{let t=m.trim();if(!(!t||!k||f(t))){_(!0),x(null);try{await we({[e]:t}),y(!0),window.setTimeout(()=>{c(),s()},600)}catch(e){x(e instanceof Error?e.message:r.saveError)}finally{_(!1)}}};(0,Q.useEffect)(()=>{if(!P||!ie)return;let e=window.setInterval(()=>{(async()=>{try{let t=await kn(P);t.status===`waiting_auth`||t.status===`waiting_code`?(U(t.status===`waiting_code`?`waiting_code`:`waiting`),V(t.message??null),W(t.authUrl??null),te(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),U(`success`),V(t.message??O.saved),window.setTimeout(()=>{c(),s()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),U(`error`),V(t.error??t.message??O.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[P,ie,s,c,O.revokeFailed,O.saved]),(0,Q.useEffect)(()=>()=>{P&&Mn(P).catch(()=>{})},[P]);let oe=async()=>{try{await R(e),c(),s()}catch{}},le=async()=>{U(`waiting`),V(O.oauthStarting),x(null);try{I((await On(e)).sessionId)}catch(e){U(`error`),V(e instanceof Error?e.message:O.revokeFailed)}},Y=async()=>{if(P){try{await jn(P)}catch{}U(`idle`),V(null),I(null),W(null),te(null)}},ue=async()=>{if(!(!P||!ne.trim()))try{await An(P,ne.trim()),re(``),V(O.oauthProcessingCode)}catch(e){U(`error`),V(e instanceof Error?e.message:O.revokeFailed)}},de=async()=>{try{await Nn(e),c(),s()}catch(e){x(e instanceof Error?e.message:O.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)(p,{className:`text-base font-semibold text-fg`,children:l?.name??e}),(0,$.jsx)(ve,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,X.press),children:(0,$.jsx)(se,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[u?.description?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.description}):null,l?.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:l.baseUrl})]}):l?.category===`extension`?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.apiUrlExtensionHint}):null,k?(0,$.jsx)(er,{providerId:e,inputId:`manage-api-key`,value:m,onChange:e=>{h(e),y(!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}}):l?.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}),l?.extensionId?(0,$.jsxs)(j,{to:`/settings/ext/${encodeURIComponent(l.extensionId)}`,className:`inline-flex w-fit items-center gap-1 font-medium text-accent hover:underline`,title:r.extensionSettingsLinkTitle,onClick:s,children:[r.openExtensionSettings,(0,$.jsx)(ce,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,A?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-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:O.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:M?O.sourceOauth:O.oauthHint})]}),M?(0,$.jsx)(J,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void de(),children:O.revoke}):(0,$.jsxs)(J,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:ie,onClick:()=>void le(),children:[ie?(0,$.jsx)(_e,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),O.oauth]})]}),B?(0,$.jsx)(`p`,{className:i(`text-xs`,H===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:B}):null,H===`waiting`||H===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[ee?(0,$.jsxs)(`a`,{href:ee,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-white hover:bg-accent-hover`,children:[(0,$.jsx)(ce,{className:`size-4`,"aria-hidden":!0}),O.openAuthPage]}):null,(0,$.jsx)(J,{type:`button`,variant:`secondary`,onClick:()=>void Y(),children:O.cancelOAuth})]}):null,G?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:G}):null,H===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:ne,onChange:e=>re(e.target.value),onKeyDown:e=>e.key===`Enter`&&void ue(),placeholder:O.pasteRedirectUrl,className:i(`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`,D)}),(0,$.jsx)(J,{type:`button`,variant:`primary`,onClick:()=>void ue(),children:O.submitCode})]}):null]}):null,K.length>0&&k?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:K.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:[F(e,r),(0,$.jsx)(ce,{className:`size-3`,"aria-hidden":!0})]},e))}):null,d.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,` (`,d.length,`)`]}),(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:d.map(e=>(0,$.jsx)(`span`,{className:`inline-block rounded-md bg-surface-hover px-2 py-1 text-xs text-fg-muted`,children:e.id.includes(`/`)?e.id.split(`/`).pop():e.id},e.id))})})]}):(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.noModels}),b?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:b}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[N?(0,$.jsxs)(J,{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:()=>E(!0),children:[(0,$.jsx)(C,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:k&&q&&!f(m.trim())?(0,$.jsx)(J,{type:`button`,variant:`primary`,disabled:!m.trim()||g||v,onClick:()=>void ae(),children:v?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(z,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):g?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(_e,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,$.jsx)(me,{open:T,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,l?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void oe(),onCancel:()=>E(!1)})]})}function ir({providerId:e,customConfig:t,labels:n,language:r,onClose:o,onSaved:s}){let c=a(r).modelsSettings,l=t?.providers[e],[u,d]=(0,Q.useState)(l?.baseUrl??``),[m,h]=(0,Q.useState)(l?.apiKey??``),[g,_]=(0,Q.useState)(l?.models??[]),[v,y]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(null),P=n=>{if(!t)return null;let r=m.trim(),i={...l,baseUrl:u.trim()||void 0,apiKey:f(r)?l?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},F=async()=>{let e=P({models:g});if(e){y(!0),S(null);try{await gn(e),s(),o()}catch(e){S(e instanceof Error?e.message:n.saveError)}finally{y(!1)}}},I=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await gn({providers:r}),s(),o()}catch{}},L=(e,t)=>{N({model:e,isNew:t}),j(!0)},R=async e=>{if(!M)return;let t=M.isNew?[...g,e]:g.map(t=>t.id===e.id?e:t);_(t);let r=P({models:t});if(r)try{await gn(r),s()}catch(e){S(e instanceof Error?e.message:n.saveError)}},z=async e=>{let t=g.filter(t=>t.id!==e);_(t),k(null);let r=P({models:t});if(r)try{await gn(r),s()}catch(e){S(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)(p,{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)(ve,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,X.press),children:(0,$.jsx)(se,{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:u,onChange:e=>d(e.target.value),className:i(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,D)})]}),(0,$.jsx)(er,{providerId:e,inputId:`manage-custom-api-key`,value:m,onChange:h,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)(`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:[c.modelsSection,g.length>0?` (${g.length})`:``]}),(0,$.jsxs)(J,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>L(null,!0),children:[(0,$.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),c.addModel]})]}),g.length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:c.modelsEmpty}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:g.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.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:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,X.press),onClick:()=>L(e,!1),"aria-label":c.editModel,children:(0,$.jsx)(E,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-red-600 dark:hover:text-red-400`,X.press),onClick:()=>k(e.id),"aria-label":c.removeModel,children:(0,$.jsx)(C,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),x?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:x}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsxs)(J,{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:()=>T(!0),children:[(0,$.jsx)(C,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(J,{type:`button`,variant:`primary`,disabled:v,onClick:()=>void F(),children:v?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(_e,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,$.jsx)(me,{open:w,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void I(),onCancel:()=>T(!1)}),(0,$.jsx)(me,{open:O!==null,title:c.removeModel,description:c.removeModelConfirm.replace(`{{id}}`,O??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{O&&z(O)},onCancel:()=>k(null)}),(0,$.jsx)(Qn,{open:A,onOpenChange:e=>{j(e),e||N(null)},providerId:e,model:M?.model??null,isNew:M?.isNew??!1,onSave:e=>void R(e),m:c})]})}var ar=[`services`,`image-models`,`voice`,`search`];function or(e){let t=(e??``).trim();return ar.includes(t)?t:`services`}function sr(){let e=(0,Z.c)(72),t=o(lr),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n,s=r.modelsHub,[c,l]=y(),u;e[2]===c?u=e[3]:(u=or(c.get(`tab`)),e[2]=c,e[3]=u);let d=u,[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(null),_=vn(),v;e[4]!==s.servicesHint||e[5]!==s.tabs.services?(v={id:`services`,icon:g,label:s.tabs.services,hint:s.servicesHint},e[4]=s.servicesHint,e[5]=s.tabs.services,e[6]=v):v=e[6];let b;e[7]!==s.imageModelsHint||e[8]!==s.tabs.imageModels?(b={id:`image-models`,icon:te,label:s.tabs.imageModels,hint:s.imageModelsHint},e[7]=s.imageModelsHint,e[8]=s.tabs.imageModels,e[9]=b):b=e[9];let x;e[10]!==s.tabs.voice||e[11]!==s.voiceHint?(x={id:`voice`,icon:P,label:s.tabs.voice,hint:s.voiceHint},e[10]=s.tabs.voice,e[11]=s.voiceHint,e[12]=x):x=e[12];let S;e[13]!==s.searchHint||e[14]!==s.tabs.search?(S={id:`search`,icon:he,label:s.tabs.search,hint:s.searchHint},e[13]=s.searchHint,e[14]=s.tabs.search,e[15]=S):S=e[15];let C;e[16]!==v||e[17]!==b||e[18]!==x||e[19]!==S?(C=[v,b,x,S],e[16]=v,e[17]=b,e[18]=x,e[19]=S,e[20]=C):C=e[20];let w=C,T;e[21]===l?T=e[22]:(T=e=>{l(t=>{let n=new URLSearchParams(t);return e===`services`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[21]=l,e[22]=T);let E=T,D=cr,O;e[23]===r.settingsSections.credentials?O=e[24]:(O=(0,$.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:r.settingsSections.credentials}),e[23]=r.settingsSections.credentials,e[24]=O);let k;e[25]===s.subtitle?k=e[26]:(k=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s.subtitle}),e[25]=s.subtitle,e[26]=k);let A;e[27]===t?A=e[28]:(A=le(t,`configuration`),e[27]=t,e[28]=A);let j;e[29]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(ce,{className:`size-3.5`,"aria-hidden":!0}),e[29]=j):j=e[29];let M;e[30]!==s.docsLink||e[31]!==A?(M=(0,$.jsxs)(`a`,{href:A,target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[s.docsLink,j]}),e[30]=s.docsLink,e[31]=A,e[32]=M):M=e[32];let N;e[33]!==M||e[34]!==O||e[35]!==k?(N=(0,$.jsx)(`header`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[O,k,M]})}),e[33]=M,e[34]=O,e[35]=k,e[36]=N):N=e[36];let F;e[37]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(Xe,{}),e[37]=F):F=e[37];let I=s.tabsAria,L;e[38]!==d||e[39]!==E?(L=e=>{e.key!==`ArrowLeft`&&e.key!==`ArrowRight`||(e.preventDefault(),E(ar[(ar.indexOf(d)+(e.key===`ArrowRight`?1:-1)+ar.length)%ar.length]))},e[38]=d,e[39]=E,e[40]=L):L=e[40];let R;e[41]!==d||e[42]!==E||e[43]!==w?(R=w.map(e=>{let{id:t,icon:n,label:r}=e,a=t===d;return(0,$.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":a,id:`hub-tab-${t}`,"aria-controls":`hub-panel-${t}`,className:i(`inline-flex shrink-0 items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,X.press,a?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>E(t),children:[(0,$.jsx)(n,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:r})]},t)}),e[41]=d,e[42]=E,e[43]=w,e[44]=R):R=e[44];let z;e[45]!==s.tabsAria||e[46]!==L||e[47]!==R?(z=(0,$.jsx)(`div`,{className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,role:`tablist`,"aria-label":I,onKeyDown:L,children:R}),e[45]=s.tabsAria,e[46]=L,e[47]=R,e[48]=z):z=e[48];let B;e[49]!==d||e[50]!==s.connectedProviders||e[51]!==w?(B=w.map(e=>(0,$.jsx)(dr,{id:e.id,activeTab:d,hint:e.hint,children:e.id===`services`?(0,$.jsx)(wn,{labels:s.connectedProviders,onAdd:()=>p(!0),onManage:(e,t)=>h({providerId:e,isCustom:t})}):(0,$.jsx)(ur,{tab:e.id})},e.id)),e[49]=d,e[50]=s.connectedProviders,e[51]=w,e[52]=B):B=e[52];let V;e[53]!==f||e[54]!==s.addProviderDialog||e[55]!==t||e[56]!==_.builtinRows||e[57]!==_.customConfig?(V=(0,$.jsx)(Un,{open:f,onOpenChange:p,builtinRows:_.builtinRows,customConfig:_.customConfig,labels:s.addProviderDialog,language:t,onSaved:D}),e[53]=f,e[54]=s.addProviderDialog,e[55]=t,e[56]=_.builtinRows,e[57]=_.customConfig,e[58]=V):V=e[58];let H;e[59]!==s.manageProviderDialog||e[60]!==t||e[61]!==m||e[62]!==_.allModels||e[63]!==_.builtinRows||e[64]!==_.customConfig?(H=m?(0,$.jsx)(nr,{open:!0,onOpenChange:e=>{e||h(null)},providerId:m.providerId,isCustom:m.isCustom,builtinRows:_.builtinRows,customConfig:_.customConfig,allModels:_.allModels,labels:s.manageProviderDialog,language:t,onSaved:D}):null,e[59]=s.manageProviderDialog,e[60]=t,e[61]=m,e[62]=_.allModels,e[63]=_.builtinRows,e[64]=_.customConfig,e[65]=H):H=e[65];let U;return e[66]!==N||e[67]!==z||e[68]!==B||e[69]!==V||e[70]!==H?(U=(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-4 px-4 py-6`,children:[N,F,z,B,V,H]}),e[66]=N,e[67]=z,e[68]=B,e[69]=V,e[70]=H,e[71]=U):U=e[71],U}function cr(){U()}function lr(e){return e.language}function ur(e){let t=(0,Z.c)(3),{tab:n}=e;switch(n){case`services`:return null;case`image-models`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ht,{embedded:!0}),t[0]=e):e=t[0],e}case`voice`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(zt,{embedded:!0}),t[1]=e):e=t[1],e}case`search`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ln,{embedded:!0}),t[2]=e):e=t[2],e}}}function dr({id:e,activeTab:t,hint:n,children:r}){let a=e===t,o=(0,Q.useRef)(a);return a&&(o.current=!0),o.current?(0,$.jsxs)(`div`,{role:`tabpanel`,id:`hub-panel-${e}`,"aria-labelledby":`hub-tab-${e}`,hidden:!a,className:i(a?`flex min-w-0 flex-col gap-3`:void 0),children:[a?(0,$.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:n}):null,r]}):null}export{sr as ModelsHubPanel};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/block-editor-BOAhMAhT.js","assets/rolldown-runtime-aKtaBQYM.js","assets/index-COkF54xv.js","assets/preload-helper-zJ_50EbN.js","assets/dist-CkobR7mk.js","assets/Combination-BzaXOLd9.js","assets/dist-DokQNVMQ.js","assets/vendor-react-BOUWij0V.js","assets/cn-JdwAhgNB.js","assets/vendor-swr-BIWyz7Rc.js","assets/createLucideIcon-DPHK1VkS.js","assets/middleware-Pd0e8Igk.js","assets/locale-store-DjbfSsfA.js","assets/messages-Csef1aW7.js","assets/fetch-Bs7in_4F.js","assets/gateway-startup-retry-BkjVJc38.js","assets/toast-z0toXu32.js","assets/theme-store-CD2wtgZV.js","assets/index-DIaSNGEO.css","assets/vendor-codemirror-CNP1wPe7.js","assets/note-image-lightbox-rSqAgOi9.js","assets/voice-player-store-B2EwIhtY.js","assets/block-editor-D4ZIVQbk.css","assets/markdown-editor-AssmZFx4.js","assets/code-editor-dZTY2dRW.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{t as a}from"./cn-JdwAhgNB.js";import{t as o}from"./messages-Csef1aW7.js";import{t as s}from"./locale-store-DjbfSsfA.js";import{i as c}from"./theme-store-CD2wtgZV.js";import{r as l}from"./toast-z0toXu32.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{Ct as d,Es as f,Et as p,Gi as m,Ma as h,Oo as g,Ro as _,St as v,To as y,Ts as b,Wa as ee,Wi as x,_s as S,_t as C,ba as w,dt as T,ft as E,gs as te,ht as D,ii as O,ji as k,lt as A,mo as j,mt as M,pt as N,ra as ne,si as P,wt as re,xt as F}from"./index-COkF54xv.js";import{n as ie,t as I}from"./note-image-lightbox-rSqAgOi9.js";import{r as L}from"./note-time-hm6JO_Wi.js";var R=n(),z=e(t(),1),B=r(),V={edit:h,ai_edit:ne,sync:w,restore:S};function H(e,t){return{edit:t.triggerEdit,ai_edit:t.triggerAiEdit,sync:t.triggerSync,restore:t.triggerRestore}[e]??e}function ae({noteId:e,activeTimestamp:t,onSelect:n,onClose:r,onRestored:i}){let c=o(s(e=>e.language)).notes,f=c,{data:p}=u(e?[`note-history`,e]:null,()=>M(e)),[m,g]=(0,z.useState)(!1),[_,v]=(0,z.useState)(null),y=(0,z.useCallback)(async t=>{g(!0);try{await d(e,t),l({type:`success`,title:c.restoreSuccess}),v(null),i()}catch{l({type:`error`,title:c.restoreFailed})}finally{g(!1)}},[e,c.restoreSuccess,c.restoreFailed,i]),b=Date.now();return(0,B.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-4 py-3`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,B.jsx)(j,{className:`h-4 w-4`,"aria-hidden":!0}),c.history]}),(0,B.jsx)(`button`,{type:`button`,onClick:r,className:`rounded-lg p-1 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:(0,B.jsx)(k,{className:`h-4 w-4`,"aria-hidden":!0})})]}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:p?.length?(0,B.jsx)(`ul`,{className:`divide-y divide-edge`,children:p.map(e=>{let r=V[e.trigger]??h,i=t===e.timestamp,o=_===e.timestamp;return(0,B.jsxs)(`li`,{children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:a(`w-full px-4 py-3 text-left transition-colors`,i?`bg-accent/10`:`hover:bg-surface-hover`),children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,B.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:H(e.trigger,c)}),(0,B.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:L(e.timestamp,b,f)})]}),e.snippet&&(0,B.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted/60`,children:e.snippet})]}),i&&(0,B.jsx)(`div`,{className:`border-t border-edge/50 px-4 py-2`,children:o?(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`min-w-0 truncate text-xs text-fg-muted`,children:c.restoreConfirm}),(0,B.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),y(e.timestamp)},disabled:m,className:`shrink-0 rounded-lg bg-accent px-3 py-1 text-xs font-medium text-on-accent transition-colors hover:bg-accent/90 disabled:opacity-50`,children:m?`...`:c.restore}),(0,B.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),v(null)},className:`shrink-0 rounded-lg px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover`,children:`Cancel`})]}):(0,B.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),v(e.timestamp)},className:`rounded-lg bg-surface-hover px-3 py-1 text-xs font-medium text-fg transition-colors hover:bg-accent hover:text-on-accent`,children:c.restore})})]},e.timestamp)})}):(0,B.jsxs)(`div`,{className:`px-4 py-8 text-center`,children:[(0,B.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,children:c.historyEmpty}),(0,B.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted/60`,children:c.historyEmptyDescription})]})})]})}function oe(e){let t=(0,R.c)(10),{noteId:n,note:r,catalyzing:i,onCatalyze:c,onClose:l,noteThreads:d,openingChat:f,onOpenChat:p,onOpenNewChat:h}=e,g=o(s(se)).notes,_=b(),y=r?.aiDeep?.catalysis,S=y?.report??null,C;t[0]===n?C=t[1]:(C=n?[`note-agent-context-status`,n]:null,t[0]=n,t[1]=C);let w;t[2]===n?w=t[3]:(w=()=>E(n),t[2]=n,t[3]=w);let T;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(T={revalidateOnFocus:!1},t[4]=T):T=t[4];let{data:D,mutate:O,isLoading:k}=u(C,w,T),A;t[5]===n?A=t[6]:(A=async e=>{try{await v(n,e)}catch{}},t[5]=n,t[6]=A);let j=A,M;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,B.jsx)(ne,{className:`h-4 w-4 text-accent`,"aria-hidden":!0}),t[7]=M):M=t[7];let N;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,B.jsx)(te,{className:`h-4 w-4 rotate-180`,"aria-hidden":!0}),t[8]=N):N=t[8];let P;return t[9]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,B.jsx)(ee,{className:`h-4 w-4 text-accent`,"aria-hidden":!0}),t[9]=P):P=t[9],(0,B.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-4 py-3`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[M,(0,B.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:g.catalysisSectionTitle})]}),(0,B.jsx)(`button`,{type:`button`,onClick:l,"aria-label":g.lightboxClose,className:`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:N})]}),(0,B.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:[(0,B.jsx)(`p`,{className:`mb-4 text-xs leading-relaxed text-fg-muted`,children:g.catalysisSectionDescription}),D?(0,B.jsxs)(`section`,{className:`mb-4 rounded-xl border border-edge-subtle bg-surface-base p-3`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.contextStatusTitle}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>void O(()=>F(n),{revalidate:!1}),disabled:k,className:`rounded-md px-1.5 py-0.5 text-[11px] font-medium text-accent transition-colors hover:bg-accent/10 disabled:cursor-not-allowed disabled:opacity-50`,children:g.contextRebuild}),(0,B.jsx)(`span`,{className:a(`rounded-full px-2 py-0.5 text-[11px] font-medium`,D.status===`ready`?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-300`:D.status===`partial`?`bg-amber-500/10 text-amber-600 dark:text-amber-300`:`bg-red-500/10 text-red-600 dark:text-red-300`),children:D.status})]}),(0,B.jsx)(`div`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:g.contextStatusDetail.replace(`{{attachments}}`,String(D.attachments.length)).replace(`{{tokens}}`,String(D.tokenEstimate??0))}),D.attachments.length>0?(0,B.jsx)(`div`,{className:`mt-3 space-y-1.5`,children:D.attachments.slice(0,5).map(J)}):null]}):null,(0,B.jsx)(`button`,{type:`button`,onClick:c,disabled:i,className:`w-full rounded-lg bg-accent px-2.5 py-1.5 text-xs font-medium text-white transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50`,children:i?g.processing:S?g.recatalyze:g.catalyzeAction}),S?(0,B.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.valueHypothesis}),(0,B.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg`,children:S.valueHypothesis})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.targetUsers}),(0,B.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:S.targetUsers.slice(0,5).map(q)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.keyQuestions}),(0,B.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:S.keyQuestions.slice(0,3).map(K)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.mvpPathLabel}),(0,B.jsx)(`ol`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:S.mvpPath.slice(0,3).map(G)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.risks}),(0,B.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:S.risks.slice(0,3).map(W)})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.nextActions}),(0,B.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:S.nextActions.slice(0,4).map(U)})]}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle pt-3`,children:[(0,B.jsx)(`span`,{className:`text-xs text-fg-muted`,children:g.confidenceLabel.replace(`{{percent}}`,String(Math.round(S.confidence*100)))}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>void j(`helpful`),className:a(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,y?.feedback===`helpful`&&`bg-accent/10 text-accent`),"aria-label":g.feedbackHelpfulAria,children:(0,B.jsx)(x,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>void j(`not_helpful`),className:a(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,y?.feedback===`not_helpful`&&`bg-accent/10 text-accent`),"aria-label":g.feedbackNotHelpfulAria,children:(0,B.jsx)(m,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})]})]})]}):(0,B.jsx)(`div`,{className:`mt-4 rounded-lg border border-dashed border-edge-subtle px-3 py-6 text-center text-sm text-fg-muted`,children:g.noCatalysisReportHint}),(0,B.jsxs)(`section`,{className:`mt-6 rounded-xl border border-edge-subtle bg-surface-base p-4`,children:[(0,B.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[P,g.relatedThreadsTitle]}),(0,B.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:g.relatedThreadsDescription})]}),(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:p,disabled:f,className:`rounded-lg border border-edge px-2.5 py-1.5 text-xs font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`,children:f?g.openingChat:g.openThread}),(0,B.jsx)(`button`,{type:`button`,onClick:h,disabled:f,className:`rounded-lg bg-accent px-2.5 py-1.5 text-xs font-medium text-white transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50`,children:g.newThread})]})]}),d.length>0?(0,B.jsx)(`div`,{className:`space-y-2`,children:d.slice(0,5).map(e=>(0,B.jsxs)(`button`,{type:`button`,onClick:()=>_(`/chat/${encodeURIComponent(e.key)}`),className:`w-full rounded-lg border border-edge-subtle px-3 py-2 text-left transition-colors hover:bg-surface-hover`,children:[(0,B.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.name||g.noteDiscussionFallback}),(0,B.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:g.messageCount.replace(`{{count}}`,String(e.messageCount??0))})]},e.key))}):(0,B.jsx)(`div`,{className:`rounded-lg border border-dashed border-edge-subtle px-3 py-5 text-center text-sm text-fg-muted`,children:g.noThreads})]})]})]})}function U(e){return(0,B.jsxs)(`li`,{className:`flex gap-2`,children:[(0,B.jsx)(`span`,{className:`rounded bg-accent/10 px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-accent`,children:e.kind}),(0,B.jsx)(`span`,{children:e.text})]},`${e.kind}:${e.text}`)}function W(e){return(0,B.jsxs)(`li`,{className:`flex gap-2`,children:[(0,B.jsx)(`span`,{className:`mt-2 h-1 w-1 shrink-0 rounded-full bg-fg-muted`}),(0,B.jsx)(`span`,{children:e})]},e)}function G(e,t){return(0,B.jsxs)(`li`,{className:`flex gap-2`,children:[(0,B.jsxs)(`span`,{className:`text-fg-muted`,children:[t+1,`.`]}),(0,B.jsx)(`span`,{children:e})]},e)}function K(e){return(0,B.jsxs)(`li`,{className:`flex gap-2`,children:[(0,B.jsx)(`span`,{className:`mt-2 h-1 w-1 shrink-0 rounded-full bg-accent`}),(0,B.jsx)(`span`,{children:e})]},e)}function q(e){return(0,B.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg`,children:e},e)}function J(e){return(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-lg bg-surface-hover px-2 py-1.5 text-xs`,children:[(0,B.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.fileName}),(0,B.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:e.status})]},e.attachmentId)}function se(e){return e.language}var Y=()=>i(()=>import(`./block-editor-BOAhMAhT.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22])),X=()=>i(()=>import(`./markdown-editor-AssmZFx4.js`).then(e=>e.n),__vite__mapDeps([23,1,3,19,7,24])),ce=(0,z.lazy)(()=>Y().then(e=>({default:e.BlockEditor}))),le=(0,z.lazy)(()=>X().then(e=>({default:e.MarkdownEditor})));function ue(){let e=(0,R.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,B.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col px-6 py-4`,"aria-busy":!0,children:[(0,B.jsx)(`div`,{className:`h-8 w-56 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,B.jsx)(`div`,{className:`mt-6 h-4 w-11/12 animate-pulse rounded bg-surface-hover`}),(0,B.jsx)(`div`,{className:`mt-3 h-4 w-9/12 animate-pulse rounded bg-surface-hover`}),(0,B.jsx)(`div`,{className:`mt-3 h-4 w-10/12 animate-pulse rounded bg-surface-hover`})]}),e[0]=t):t=e[0],t}function de(e){let t=(0,R.c)(14),{mode:n,onModeChange:r,labels:i}=e,o;t[0]===i.edit?o=t[1]:(o={id:`wysiwyg`,label:i.edit,Icon:y},t[0]=i.edit,t[1]=o);let s;t[2]===i.source?s=t[3]:(s={id:`source`,label:i.source,Icon:_},t[2]=i.source,t[3]=s);let c;t[4]===i.preview?c=t[5]:(c={id:`preview`,label:i.preview,Icon:g},t[4]=i.preview,t[5]=c);let l;t[6]!==o||t[7]!==s||t[8]!==c?(l=[o,s,c],t[6]=o,t[7]=s,t[8]=c,t[9]=l):l=t[9];let u=l,d;return t[10]!==n||t[11]!==u||t[12]!==r?(d=(0,B.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg border border-edge p-0.5`,children:u.map(e=>{let{id:t,label:i,Icon:o}=e;return(0,B.jsxs)(`button`,{type:`button`,onClick:()=>r(t),onMouseEnter:()=>{t===`wysiwyg`&&Y(),t===`source`&&X()},onFocus:()=>{t===`wysiwyg`&&Y(),t===`source`&&X()},className:a(`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-xs font-medium transition-colors`,n===t?`bg-surface-hover text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:[(0,B.jsx)(o,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),i]},t)})}),t[10]=n,t[11]=u,t[12]=r,t[13]=d):d=t[13],d}function Z(e){let t=(0,R.c)(9),{noteId:n,onBack:r,onSaved:i}=e,a=s(Q),c;t[0]===a?c=t[1]:(c=o(a),t[0]=a,t[1]=c);let l=c.notes.lightboxClose,u;t[2]!==n||t[3]!==r||t[4]!==i?(u=(0,B.jsx)(fe,{noteId:n,onBack:r,onSaved:i}),t[2]=n,t[3]=r,t[4]=i,t[5]=u):u=t[5];let d;return t[6]!==l||t[7]!==u?(d=(0,B.jsx)(I,{closeLabel:l,children:u}),t[6]=l,t[7]=u,t[8]=d):d=t[8],d}function Q(e){return e.language}function fe({noteId:e,onBack:t,onSaved:n}){let r=o(s(e=>e.language)).notes,i=b(),d=c(e=>e.resolved)===`dark`,{openImage:f}=ie(),[m,h]=(0,z.useState)(`wysiwyg`),[g,_]=(0,z.useState)(null),[v,y]=(0,z.useState)(null),[x,S]=(0,z.useState)(!1),[w,E]=(0,z.useState)(``),[k,M]=(0,z.useState)(360),[F,I]=(0,z.useState)(!1),[L,R]=(0,z.useState)(!1),[V,H]=(0,z.useState)(!1),U=(0,z.useRef)(!1),W=(0,z.useRef)(!1),G=(0,z.useRef)(null),K=(0,z.useRef)(null),q=(0,z.useRef)(null),J=(0,z.useRef)(null),se=(0,z.useRef)(null),Y=O(e=>e.setPageHeader),X=O(e=>e.clearPageHeader),{data:Z,mutate:Q}=u(e?[`note-detail`,e]:null,()=>T(e)),{data:fe=[],mutate:pe}=u(e?[`note-threads`,e]:null,()=>D(e),{revalidateOnFocus:!1});(0,z.useEffect)(()=>{U.current=!1,E(``),y(null),_(null),W.current=!1},[e]),(0,z.useEffect)(()=>{!Z||U.current||(E(Z.title??``),U.current=!0)},[Z]);let me=Z?new Date(Z.createdAt).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):``,he=(0,z.useMemo)(()=>(0,B.jsx)(`button`,{type:`button`,onClick:t,"aria-label":r.back,className:a(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,P),children:(0,B.jsx)(te,{className:`h-4 w-4`,"aria-hidden":!0})}),[r.back,t]),ge=(0,z.useCallback)(t=>{E(t),e&&(J.current=t,K.current&&clearTimeout(K.current),K.current=setTimeout(async()=>{let t=J.current;if(J.current=null,t!==null){S(!0);try{await re(e,{title:t}),await Q(),n?.()}catch{}finally{S(!1)}}},600))},[e,Q,n]),_e=(0,z.useMemo)(()=>(0,B.jsxs)(`div`,{className:a(`flex min-w-0 items-center gap-2 px-3 sm:px-5 xl:px-6`,P),children:[(0,B.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,title:w||me||void 0,children:w||me}),x?(0,B.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted opacity-60`,children:r.saving}):null]}),[r.saving,x,me,w]),$=(0,z.useCallback)(async(t=!1)=>{H(!0);try{let n=await C(e,{forceNew:t});await Q(),await pe(),i(`/chat/${encodeURIComponent(n.sessionKey)}`)}catch(e){l({type:`error`,title:r.chatOpenFailedTitle,message:e instanceof Error?e.message:r.chatOpenFailedMessage})}finally{H(!1)}},[Q,pe,i,e,r.chatOpenFailedMessage,r.chatOpenFailedTitle]),ve=(0,z.useCallback)(async()=>{R(!0);try{await A(e),await Q(),l({type:`success`,title:r.catalysisDone})}catch(e){l({type:`error`,title:r.catalysisFailed,message:e instanceof Error?e.message:r.chatOpenFailedMessage})}finally{R(!1)}},[Q,e]),ye=(0,z.useCallback)(()=>{_(g===`breakdown`?null:`breakdown`),!Z?.aiDeep?.catalysis?.report&&!L&&ve()},[g,L,ve,Z?.aiDeep?.catalysis?.report]),be=(0,z.useMemo)(()=>(0,B.jsxs)(`div`,{className:a(`flex items-center gap-2`,P),children:[(0,B.jsxs)(`button`,{type:`button`,onClick:ye,disabled:L,"aria-label":r.catalysisSectionTitle,className:a(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50`,g===`breakdown`?`bg-accent/10 text-accent`:`bg-accent/10 text-fg hover:bg-accent/15`),children:[(0,B.jsx)(ne,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),L?r.catalyzing:r.catalyzeButton]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>$(!1),disabled:V,className:a(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors`,`border border-edge text-fg-muted hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`),children:[(0,B.jsx)(ee,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),V?r.openingChat:r.openChatButton]}),(0,B.jsx)(de,{mode:m,onModeChange:h,labels:{edit:r.modeEdit,source:r.modeSource,preview:r.modePreview}}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>_(g===`history`?null:`history`),"aria-label":r.history,className:a(`rounded-lg p-1.5 transition-colors`,g===`history`?`bg-accent/10 text-accent`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:(0,B.jsx)(j,{className:`h-4 w-4`,"aria-hidden":!0})})]}),[L,ye,$,m,r.history,r.modeEdit,r.modePreview,r.modeSource,V,g]);(0,z.useLayoutEffect)(()=>(Y({startExtra:he,main:Z?_e:null,end:Z?be:null}),()=>X()),[X,be,_e,he,Z,Y]);let xe=(0,z.useCallback)(t=>{e&&(q.current=t,G.current&&clearTimeout(G.current),G.current=setTimeout(async()=>{let t=q.current;if(q.current=null,t!==null){S(!0);try{await re(e,{markdown:t}),await Q(),n?.()}catch(e){l({type:`error`,title:r.saveFailed,message:e instanceof Error?e.message:r.saveFailedHint})}finally{S(!1)}}},600))},[e,Q,r.saveFailed,r.saveFailedHint,n]),Se=(0,z.useCallback)(t=>{N(e,t.timestamp).then(e=>{e&&y(e)})},[e]),Ce=(0,z.useCallback)(()=>{_(null),y(null)},[]),we=(0,z.useCallback)(()=>{_(null),y(null),Q(),n?.()},[Q,n]);if((0,z.useEffect)(()=>()=>{G.current&&clearTimeout(G.current),K.current&&clearTimeout(K.current);let t=q.current,n=J.current;q.current=null,J.current=null;let r={};t!==null&&(r.markdown=t),n!==null&&(r.title=n),Object.keys(r).length>0&&re(e,r)},[e]),Z===void 0)return(0,B.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,B.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-accent border-t-transparent`})});if(Z===null)return(0,B.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 text-center`,children:[(0,B.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r.notFoundTitle}),(0,B.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.notFoundDescription}),(0,B.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-lg border border-edge px-3 py-1.5 text-sm font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:r.back})]});let Te=v!==null,Ee=Te?v.title??``:w,De=Te?v.markdown??``:Z.markdown??``;return(0,B.jsxs)(`div`,{className:`flex h-full min-h-0 gap-3 p-4 sm:px-5`,children:[(0,B.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,B.jsx)(`div`,{ref:se,className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-base`,children:Te?(0,B.jsxs)(`div`,{className:`h-full overflow-y-auto px-6 py-4`,children:[Ee&&(0,B.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg/70`,children:Ee}),De?(0,B.jsx)(p,{noteId:e,content:De,className:`opacity-80`}):(0,B.jsx)(`p`,{className:`italic text-fg-muted`,children:r.emptyPreview})]}):(0,B.jsxs)(B.Fragment,{children:[m===`wysiwyg`&&(0,B.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,B.jsx)(`div`,{className:`shrink-0 px-6 pt-4`,children:(0,B.jsx)(`input`,{type:`text`,value:w,onChange:e=>ge(e.target.value),onCompositionStart:()=>{W.current=!0},onCompositionEnd:()=>{W.current=!1},onKeyDown:e=>{let t=e.nativeEvent;e.key===`Enter`&&!W.current&&!t.isComposing&&(e.preventDefault(),(se.current?.querySelector(`.ProseMirror`))?.focus())},placeholder:r.titlePlaceholder,className:`w-full border-none bg-transparent text-2xl font-bold text-fg placeholder:text-fg-muted/40 focus:outline-none`})}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(ue,{}),children:(0,B.jsx)(ce,{initialContent:Z.markdown??``,onChange:xe,noteId:e},`wysiwyg-${e}`)})})]}),m===`source`&&(0,B.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,B.jsx)(`div`,{className:`shrink-0 px-6 pt-4`,children:(0,B.jsx)(`input`,{type:`text`,value:w,onChange:e=>ge(e.target.value),placeholder:r.titlePlaceholder,className:`w-full border-none bg-transparent text-2xl font-bold text-fg placeholder:text-fg-muted/40 focus:outline-none`})}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(ue,{}),children:(0,B.jsx)(le,{initialContent:Z.markdown??``,onChange:xe,isDark:d},`source-${e}`)})})]}),m===`preview`&&(0,B.jsxs)(`div`,{className:`h-full overflow-y-auto px-6 py-4`,onClick:e=>{let t=e.target;t instanceof HTMLImageElement&&f(t.currentSrc||t.src,t.alt)},children:[w&&(0,B.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg`,children:w}),Z.markdown?(0,B.jsx)(p,{noteId:e,content:Z.markdown,className:`[&_img]:cursor-zoom-in`}):(0,B.jsx)(`p`,{className:`italic text-fg-muted`,children:r.emptyPreview})]})]})})}),(0,B.jsx)(`div`,{className:a(`relative flex min-h-0 shrink-0 flex-col overflow-hidden`,!F&&`transition-[width] duration-300 ease-in-out`),style:{width:g?k:0},children:(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,style:{width:k},children:[(0,B.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,onPointerDown:e=>{e.preventDefault();let t=e.currentTarget;t.setPointerCapture(e.pointerId),I(!0);let n=e.clientX,r=k,i=e.pointerId,a=e=>{let t=r-(e.clientX-n);M(Math.max(280,Math.min(600,t)))},o=()=>{try{t.releasePointerCapture(i)}catch{}I(!1),window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,o)},className:a(`absolute left-0 top-0 z-10 h-full w-2 -translate-x-1/2 cursor-col-resize`,`before:content-[''] before:pointer-events-none before:absolute before:left-1/2 before:top-0 before:h-full before:w-px before:-translate-x-1/2`,`before:bg-transparent before:transition-[background-color] before:duration-150`,`hover:before:bg-edge/65 dark:hover:before:bg-edge/75`,F&&`before:!bg-edge/80 dark:before:!bg-edge/85`,`touch-none select-none`)}),(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-base`,children:g===`history`?(0,B.jsx)(ae,{noteId:e,activeTimestamp:v?.timestamp??null,onSelect:Se,onClose:Ce,onRestored:we}):g===`breakdown`?(0,B.jsx)(oe,{noteId:e,note:Z??null,catalyzing:L,onCatalyze:ve,onClose:()=>_(null),noteThreads:fe,openingChat:V,onOpenChat:()=>$(!1),onOpenNewChat:()=>$(!0)}):null})]})})]})}function pe(){let e=(0,R.c)(5),{noteId:t}=f(),n=b(),r;e[0]===n?r=e[1]:(r=()=>{n(`/notes`)},e[0]=n,e[1]=r);let i=r;if(!t)return null;let a;return e[2]!==i||e[3]!==t?(a=(0,B.jsx)(`div`,{className:`mx-auto flex h-full min-h-0 w-full max-w-6xl flex-1 flex-col`,children:(0,B.jsx)(Z,{noteId:t,onBack:i})}),e[2]=i,e[3]=t,e[4]=a):a=e[4],a}export{pe as NoteDetailPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-JdwAhgNB.js";import{Di as a,ki as o,wi as s}from"./index-COkF54xv.js";import{n as c}from"./interval-presets-B29Ss_2y.js";import{t as l}from"./cron-schedule-picker-DH10KgD6.js";var u=n(),d=e(t(),1),f=r(),p=i(`h-9 min-w-0 flex-1 rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm tabular-nums text-fg`,s),m=i(a,`h-9 max-w-[11rem] shrink-0 text-xs sm:max-w-[12rem]`);function h(e,t){switch(e){case 3e4:return t.every30s;case 6e4:return t.every1min;case 3e5:return t.every5min;case 6e5:return t.every10min;case 9e5:return t.every15min;case 18e5:return t.every30min;case 36e5:return t.every1h;case 72e5:return t.every2h;default:return String(e)}}function g({valueMs:e,onChangeMs:t,labels:n,disabled:r,presets:i=c,minSeconds:a=1}){let o=(0,d.useMemo)(()=>new Set(i),[i]),s=(0,d.useMemo)(()=>o.has(e)?String(e):``,[o,e]),[l,u]=(0,d.useState)(null),g=(0,d.useRef)(e);g.current!==e&&(g.current=e,u(null));let _=Math.max(a,Math.round(e/1e3)),v=l===null?String(_):l;return(0,f.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,f.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.secondsLabel}),(0,f.jsxs)(`div`,{className:`flex gap-2`,children:[(0,f.jsx)(`input`,{type:`number`,min:a,step:1,disabled:r,className:p,value:v,onChange:e=>{let n=e.target.value;u(n);let r=parseInt(n,10);Number.isFinite(r)&&r>=a&&t(r*1e3)},onBlur:()=>{if(l===null)return;let e=parseInt(l,10);t(!Number.isFinite(e)||e<a?a*1e3:e*1e3),u(null)}}),(0,f.jsxs)(`select`,{className:m,disabled:r,value:s,onChange:e=>{let n=e.target.value;n&&(t(parseInt(n,10)),u(null))},children:[(0,f.jsx)(`option`,{value:``,children:n.presets.custom}),i.map(e=>(0,f.jsx)(`option`,{value:String(e),children:h(e,n.presets)},e))]})]})]})}var _=i(`mt-1 w-full rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm text-fg`,s),v=()=>({start:`09:00`,end:`22:00`,timezone:``});function y(e){let t=(0,u.c)(55),{value:n,onChange:r,labels:i,disabled:a}=e;if(!n){let e;t[0]===r?e=t[1]:(e=()=>r(v()),t[0]=r,t[1]=e);let n;return t[2]!==a||t[3]!==i.add||t[4]!==e?(n=(0,f.jsx)(o,{type:`button`,variant:`secondary`,className:`text-sm`,disabled:a,onClick:e,children:i.add}),t[2]=a,t[3]=i.add,t[4]=e,t[5]=n):n=t[5],n}let s;t[6]===i.start?s=t[7]:(s=(0,f.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.start}),t[6]=i.start,t[7]=s);let c;t[8]!==r||t[9]!==n?(c=e=>r({...n,start:e.target.value}),t[8]=r,t[9]=n,t[10]=c):c=t[10];let l;t[11]!==a||t[12]!==c||t[13]!==n.start?(l=(0,f.jsx)(`input`,{type:`time`,step:60,disabled:a,className:_,value:n.start,onChange:c}),t[11]=a,t[12]=c,t[13]=n.start,t[14]=l):l=t[14];let d;t[15]!==s||t[16]!==l?(d=(0,f.jsxs)(`label`,{className:`block min-w-0`,children:[s,l]}),t[15]=s,t[16]=l,t[17]=d):d=t[17];let p;t[18]===i.end?p=t[19]:(p=(0,f.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.end}),t[18]=i.end,t[19]=p);let m;t[20]!==r||t[21]!==n?(m=e=>r({...n,end:e.target.value}),t[20]=r,t[21]=n,t[22]=m):m=t[22];let h;t[23]!==a||t[24]!==m||t[25]!==n.end?(h=(0,f.jsx)(`input`,{type:`time`,step:60,disabled:a,className:_,value:n.end,onChange:m}),t[23]=a,t[24]=m,t[25]=n.end,t[26]=h):h=t[26];let g;t[27]!==p||t[28]!==h?(g=(0,f.jsxs)(`label`,{className:`block min-w-0`,children:[p,h]}),t[27]=p,t[28]=h,t[29]=g):g=t[29];let y;t[30]===i.timezone?y=t[31]:(y=(0,f.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.timezone}),t[30]=i.timezone,t[31]=y);let b;t[32]!==r||t[33]!==n?(b=e=>r({...n,timezone:e.target.value}),t[32]=r,t[33]=n,t[34]=b):b=t[34];let x;t[35]!==a||t[36]!==b||t[37]!==n.timezone?(x=(0,f.jsx)(`input`,{type:`text`,disabled:a,className:_,value:n.timezone,onChange:b,placeholder:`Asia/Shanghai`,autoComplete:`off`}),t[35]=a,t[36]=b,t[37]=n.timezone,t[38]=x):x=t[38];let S;t[39]!==x||t[40]!==y?(S=(0,f.jsxs)(`label`,{className:`block min-w-0`,children:[y,x]}),t[39]=x,t[40]=y,t[41]=S):S=t[41];let C;t[42]!==S||t[43]!==d||t[44]!==g?(C=(0,f.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[d,g,S]}),t[42]=S,t[43]=d,t[44]=g,t[45]=C):C=t[45];let w;t[46]===r?w=t[47]:(w=()=>r(null),t[46]=r,t[47]=w);let T;t[48]!==a||t[49]!==i.clear||t[50]!==w?(T=(0,f.jsx)(o,{type:`button`,variant:`secondary`,className:`text-xs`,disabled:a,onClick:w,children:i.clear}),t[48]=a,t[49]=i.clear,t[50]=w,t[51]=T):T=t[51];let E;return t[52]!==C||t[53]!==T?(E=(0,f.jsxs)(`div`,{className:`space-y-2`,children:[C,T]}),t[52]=C,t[53]=T,t[54]=E):E=t[54],E}function b(e){let t=(0,u.c)(34),{disabled:n,label:r,hint:a,className:o}=e,s;t[0]===o?s=t[1]:(s=i(`flex flex-col gap-2`,o),t[0]=o,t[1]=s);let d;t[2]===r?d=t[3]:(d=r?(0,f.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r}):null,t[2]=r,t[3]=d);let p;t[4]!==n||t[5]!==r||t[6]!==e.kind||t[7]!==e.labels||t[8]!==e.onChange||t[9]!==e.value?(p=e.kind===`cron`?(0,f.jsx)(l,{value:e.value,onChange:e.onChange,labels:e.labels,disabled:n,showHeading:!r}):null,t[4]=n,t[5]=r,t[6]=e.kind,t[7]=e.labels,t[8]=e.onChange,t[9]=e.value,t[10]=p):p=t[10];let m;t[11]!==n||t[12]!==e.kind||t[13]!==e.labels||t[14]!==e.minSeconds||t[15]!==e.onChangeMs||t[16]!==e.presets||t[17]!==e.valueMs?(m=e.kind===`interval`?(0,f.jsx)(g,{valueMs:e.valueMs,onChangeMs:e.onChangeMs,labels:e.labels,disabled:n,presets:e.presets??c,minSeconds:e.minSeconds}):null,t[11]=n,t[12]=e.kind,t[13]=e.labels,t[14]=e.minSeconds,t[15]=e.onChangeMs,t[16]=e.presets,t[17]=e.valueMs,t[18]=m):m=t[18];let h;t[19]!==n||t[20]!==e.kind||t[21]!==e.labels||t[22]!==e.onChange||t[23]!==e.value?(h=e.kind===`active-hours`?(0,f.jsx)(y,{value:e.value,onChange:e.onChange,labels:e.labels,disabled:n}):null,t[19]=n,t[20]=e.kind,t[21]=e.labels,t[22]=e.onChange,t[23]=e.value,t[24]=h):h=t[24];let _;t[25]===a?_=t[26]:(_=a?(0,f.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:a}):null,t[25]=a,t[26]=_);let v;return t[27]!==s||t[28]!==d||t[29]!==p||t[30]!==m||t[31]!==h||t[32]!==_?(v=(0,f.jsxs)(`div`,{className:s,children:[d,p,m,h,_]}),t[27]=s,t[28]=d,t[29]=p,t[30]=m,t[31]=h,t[32]=_,t[33]=v):v=t[33],v}export{b as t};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{r as n}from"./interval-presets-B29Ss_2y.js";import{t as r}from"./format-interval-label-CftJ5uXu.js";var i=e(),a=t();function o(e){let t=(0,i.c)(12),o;t[0]!==e.expression||t[1]!==e.kind||t[2]!==e.labels||t[3]!==e.locale||t[4]!==e.nextRun||t[5]!==e.presetLabels||t[6]!==e.timezone||t[7]!==e.valueMs?(o=e.kind===`cron`?n(e.expression,e.locale,e.labels,{timezone:e.timezone,nextRun:e.nextRun}):r(e.valueMs,e.locale,e.presetLabels),t[0]=e.expression,t[1]=e.kind,t[2]=e.labels,t[3]=e.locale,t[4]=e.nextRun,t[5]=e.presetLabels,t[6]=e.timezone,t[7]=e.valueMs,t[8]=o):o=t[8];let s=o,c;return t[9]!==e.className||t[10]!==s?(c=(0,a.jsx)(`span`,{className:e.className,children:s}),t[9]=e.className,t[10]=s,t[11]=c):c=t[11],c}export{o as t};
@@ -1 +0,0 @@
1
- import{Zt as e}from"./index-COkF54xv.js";function t(t){let{children:n,fallback:r}=t,i=r===void 0?null:r;return e()?n:i}export{t};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-JdwAhgNB.js";import{Ma as r,xi as i}from"./index-COkF54xv.js";var a=e();function o(){return`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`}var s=t();function c(e){let t=(0,a.c)(5),{children:r,className:i}=e,c;t[0]===i?c=t[1]:(c=n(o(),i),t[0]=i,t[1]=c);let l;return t[2]!==r||t[3]!==c?(l=(0,s.jsx)(`section`,{className:c,children:r}),t[2]=r,t[3]=c,t[4]=l):l=t[4],l}var l=`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted transition-colors dark:bg-surface-hover/70`;function u(e){let t=(0,a.c)(26),{icon:o,title:c,subtitle:u,trailing:d,className:f,iconInteractive:p,iconLeading:m}=e,h;t[0]===o?h=t[1]:(h=(0,s.jsx)(o,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=o,t[1]=h);let g=m??h,_;t[2]===m?_=t[3]:(_=m?n(`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel p-0 ring-1 ring-inset ring-edge-subtle transition-[box-shadow] hover:ring-accent/40 dark:ring-edge-subtle`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,i.press):n(l,`hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,i.press),t[2]=m,t[3]=_);let v=_,y=!!(p&&m),b;t[4]===f?b=t[5]:(b=n(`mb-5 flex items-start gap-3`,f),t[4]=f,t[5]=b);let x;t[6]!==p||t[7]!==m||t[8]!==g||t[9]!==v||t[10]!==y?(x=p?y?(0,s.jsxs)(`span`,{className:`relative shrink-0`,children:[(0,s.jsx)(`button`,{type:`button`,id:p.id,onClick:p.onClick,"aria-label":p.ariaLabel,className:v,children:g}),(0,s.jsx)(`span`,{className:`pointer-events-none absolute -bottom-0.5 -right-0.5 flex size-4 items-center justify-center rounded-md border border-edge bg-surface-panel text-fg-muted shadow-sm dark:border-edge dark:bg-surface-base`,"aria-hidden":!0,children:(0,s.jsx)(r,{className:`size-2.5`,strokeWidth:2.25})})]}):(0,s.jsx)(`button`,{type:`button`,id:p.id,onClick:p.onClick,"aria-label":p.ariaLabel,className:v,children:g}):(0,s.jsx)(`div`,{className:n(m?`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel ring-1 ring-inset ring-edge-subtle dark:ring-edge-subtle`:l),"aria-hidden":!m,children:g}),t[6]=p,t[7]=m,t[8]=g,t[9]=v,t[10]=y,t[11]=x):x=t[11];let S;t[12]===c?S=t[13]:(S=(0,s.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:c}),t[12]=c,t[13]=S);let C;t[14]===u?C=t[15]:(C=u?(0,s.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:u}):null,t[14]=u,t[15]=C);let w;t[16]!==S||t[17]!==C?(w=(0,s.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[S,C]}),t[16]=S,t[17]=C,t[18]=w):w=t[18];let T;t[19]===d?T=t[20]:(T=d?(0,s.jsx)(`div`,{className:`shrink-0`,children:d}):null,t[19]=d,t[20]=T);let E;return t[21]!==b||t[22]!==x||t[23]!==w||t[24]!==T?(E=(0,s.jsxs)(`div`,{className:b,children:[x,w,T]}),t[21]=b,t[22]=x,t[23]=w,t[24]=T,t[25]=E):E=t[25],E}export{u as n,o as r,c as t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-JdwAhgNB.js";import{t as a}from"./messages-Csef1aW7.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{c as s}from"./fetch-Bs7in_4F.js";import{i as c}from"./vendor-swr-BIWyz7Rc.js";import{Jt as l,Q as u,Ss as d,Vt as f,Wo as p,ba as m,br as h,ct as g,is as _,ji as v,ot as y,qa as b,ra as x,st as S,ts as C,xi as w,yi as T}from"./index-COkF54xv.js";import{n as E,t as D}from"./settings-form-section-BsrK7TBF.js";var O=e(t(),1),k=n(),A=[{id:`lightChat`,steps:[{path:`/settings/credentials?tab=providers`,labelKey:`stepProviders`},{path:`/settings/agent-defaults`,labelKey:`stepDefaultModel`}]},{id:`multiChannel`,steps:[{path:`/settings/credentials?tab=providers`,labelKey:`stepProviders`},{path:`/settings/agent-defaults`,labelKey:`stepDefaultModel`},{path:`/channels`,labelKey:`stepChannel`},{path:`/agents`,labelKey:`stepPresets`}]},{id:`automation`,steps:[{path:`/settings/credentials?tab=providers`,labelKey:`stepProviders`},{path:`/skills`,labelKey:`stepSkills`},{path:`/cron`,labelKey:`stepCron`}]}],j=`xopc-scenario-presets-dismissed`;function M(){try{return localStorage.getItem(j)===`true`}catch{return!1}}function N(){try{localStorage.setItem(j,`true`)}catch{}}var P=r();function F(e,t){return t[e.labelKey]??e.labelKey}function I(){let e=(0,k.c)(5),t=a(o(L)).setupStatus.scenarios,[n,r]=(0,O.useState)(M);if(n)return null;let s,c,l;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=i(`inline-flex shrink-0 items-center gap-1 rounded-lg px-2 py-1.5 text-xs font-medium text-fg-muted`,`hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,w.press),c=()=>{N(),r(!0)},l=(0,P.jsx)(v,{className:`size-3.5`,"aria-hidden":!0}),e[0]=s,e[1]=c,e[2]=l):(s=e[0],c=e[1],l=e[2]);let u=A.map(e=>{let n=t.presets[e.id];return(0,P.jsxs)(`article`,{className:`flex flex-col rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.title}),(0,P.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:n.description}),(0,P.jsx)(`ol`,{className:`mt-3 flex flex-col gap-1`,children:e.steps.map((n,r)=>(0,P.jsx)(`li`,{children:(0,P.jsxs)(d,{to:n.path,className:i(`text-xs font-medium text-accent-fg hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent rounded`),children:[r+1,`. `,F(n,t.steps)]})},`${e.id}-${n.labelKey}`))})]},e.id)}),f;return e[3]===u?f=e[4]:(f=(0,P.jsx)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-3`,children:u}),e[3]=u,e[4]=f),(0,P.jsxs)(D,{children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,P.jsx)(E,{icon:x,title:t.title,subtitle:t.subtitle}),(0,P.jsxs)(`button`,{type:`button`,className:s,onClick:c,children:[l,t.dismiss]})]}),f]})}function L(e){return e.language}function R(e){if(!e||typeof e!=`object`)return 0;let t=e.providers;return!t||typeof t!=`object`||Array.isArray(t)?0:Object.values(t).filter(e=>typeof e==`string`&&T(e)).length}function z(e){if(!e||typeof e!=`object`)return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t.defaults;if(!n||typeof n!=`object`||Array.isArray(n))return``;let r=n.model;return typeof r==`string`?r.trim():``}function B(e){if(!e||typeof e!=`object`)return!1;let t=e.channels;return!t||typeof t!=`object`||Array.isArray(t)?!1:Object.values(t).some(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;if(`configured`in t||`config`in t||`schema`in t||`uiHints`in t){if(t.configured===!0)return!0;let e=t.config;if(!e||typeof e!=`object`||Array.isArray(e))return!1;let n=e;return n.enabled===!0||Object.keys(n).length>0}return t.enabled===!0||Object.keys(t).length>0})}function V(e){let t=R(e.config),n=e.providerMeta?.configured??t,r=e.providerMeta?.total??0,i=n>0||t>0,a=z(e.config),o=a.length>0,s=e.hasToken&&e.sseConnected,c=B(e.config),l=e.skillCount>0,u=[{id:`gateway`,done:s,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline},{id:`provider`,done:i,detail:i?e.providerMeta&&e.providerMeta.total>0?e.labels.providersMetaReady(n,r):e.labels.providersConfigured(t):e.labels.providersMissing},{id:`defaultModel`,done:o,detail:o?e.labels.modelConfigured(a):e.labels.modelMissing},{id:`channel`,done:c,optional:!0,detail:c?e.labels.channelConfigured:e.labels.channelMissing},{id:`skill`,done:l,optional:!0,detail:l?e.labels.skillsConfigured(e.skillCount):e.labels.skillsMissing},{id:`presets`,done:e.presetsDone,optional:!0,detail:e.presetsDone?e.labels.presetsConfigured:e.labels.presetsMissing}],d=u.filter(e=>!e.optional).every(e=>e.done),f=u.every(e=>e.done);return{gatewayConnected:s,providerConfigured:i,providerCount:t,providerMetaConfigured:n,providerMetaTotal:r,defaultModel:a,defaultModelConfigured:o,channelConfigured:c,skillInstalled:l,skillCount:e.skillCount,presetsDone:e.presetsDone,agentCount:e.agentCount,checklist:u,requiredComplete:d,allComplete:f}}function H(e){return!!(e&&e.length>1)}function U(){let e=(0,k.c)(44),t=s(J),n=o(q),r;e[0]===n?r=e[1]:(r=a(n),e[0]=n,e[1]=r);let i=r.setupStatus.labels,l=g(K),{data:d,error:p,isLoading:m,mutate:_}=h(!!t),v;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(v={revalidateOnFocus:!1},e[2]=v):v=e[2];let{data:b,error:x,isLoading:C,mutate:w}=c(t?`setup-checklist-skills`:null,G,v),T;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(T={revalidateOnFocus:!1},e[3]=T):T=e[3];let{data:E,error:D,isLoading:O,mutate:A}=c(t?`setup-checklist-provider-meta`:null,u,T),j;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(j={revalidateOnFocus:!1},e[4]=j):j=e[4];let{data:M,error:N,isLoading:P,mutate:F}=c(t?`setup-checklist-agents`:null,f,j),I;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(I={revalidateOnFocus:!1},e[5]=I):I=e[5],c(t?y:null,S,I);let L=!t||!m&&!C&&!O&&!P,R=!!(p||x||D||N),z;bb0:{if(!t||!L){z=null;break bb0}let n=b?.catalog?.length??0,r;if(e[6]!==M?.agents||e[7]!==d?.payload?.config||e[8]!==i.channelConfigured||e[9]!==i.channelMissing||e[10]!==i.gatewayOffline||e[11]!==i.gatewayOnline||e[12]!==i.modelConfigured||e[13]!==i.modelMissing||e[14]!==i.presetsConfigured||e[15]!==i.presetsMissing||e[16]!==i.providersConfigured||e[17]!==i.providersMetaReady||e[18]!==i.providersMissing||e[19]!==i.skillsConfigured||e[20]!==i.skillsMissing||e[21]!==E||e[22]!==n||e[23]!==l||e[24]!==t){let a=E?.filter(W).length??0,o=E?.length??0,s=M?.agents.length??0,c=H(M?.agents),u;e[26]===i.providersConfigured?u=e[27]:(u=e=>i.providersConfigured.replace(`{{count}}`,String(e)),e[26]=i.providersConfigured,e[27]=u);let f;e[28]===i.providersMetaReady?f=e[29]:(f=(e,t)=>i.providersMetaReady.replace(`{{configured}}`,String(e)).replace(`{{total}}`,String(t)),e[28]=i.providersMetaReady,e[29]=f);let p;e[30]===i.modelConfigured?p=e[31]:(p=e=>i.modelConfigured.replace(`{{model}}`,e),e[30]=i.modelConfigured,e[31]=p);let m;e[32]===i.skillsConfigured?m=e[33]:(m=e=>i.skillsConfigured.replace(`{{count}}`,String(e)),e[32]=i.skillsConfigured,e[33]=m),r=V({hasToken:!!t,sseConnected:l,config:d?.payload?.config,skillCount:n,providerMeta:o>0?{configured:a,total:o}:null,presetsDone:c,agentCount:s,labels:{gatewayOnline:i.gatewayOnline,gatewayOffline:i.gatewayOffline,providersConfigured:u,providersMetaReady:f,providersMissing:i.providersMissing,modelConfigured:p,modelMissing:i.modelMissing,channelConfigured:i.channelConfigured,channelMissing:i.channelMissing,skillsConfigured:m,skillsMissing:i.skillsMissing,presetsConfigured:i.presetsConfigured.replace(`{{count}}`,String(s)),presetsMissing:i.presetsMissing}}),e[6]=M?.agents,e[7]=d?.payload?.config,e[8]=i.channelConfigured,e[9]=i.channelMissing,e[10]=i.gatewayOffline,e[11]=i.gatewayOnline,e[12]=i.modelConfigured,e[13]=i.modelMissing,e[14]=i.presetsConfigured,e[15]=i.presetsMissing,e[16]=i.providersConfigured,e[17]=i.providersMetaReady,e[18]=i.providersMissing,e[19]=i.skillsConfigured,e[20]=i.skillsMissing,e[21]=E,e[22]=n,e[23]=l,e[24]=t,e[25]=r}else r=e[25];z=r}let B=z,U;e[34]!==F||e[35]!==_||e[36]!==A||e[37]!==w?(U=async()=>{await Promise.all([_(),w(),A(),F()])},e[34]=F,e[35]=_,e[36]=A,e[37]=w,e[38]=U):U=e[38];let Y=U,X;return e[39]!==R||e[40]!==L||e[41]!==Y||e[42]!==B?(X={ready:L,error:R,snapshot:B,refresh:Y},e[39]=R,e[40]=L,e[41]=Y,e[42]=B,e[43]=X):X=e[43],X}function W(e){return e.configured}function G(){return l()}function K(e){return e.connectionState===`connected`}function q(e){return e.language}function J(e){return e.token}var Y={gateway:`/settings/gateway`,provider:`/settings/credentials`,defaultModel:`/settings/agent-defaults`,channel:`/channels`,skill:`/skills`,presets:`/agents`};function X(e){let t=(0,k.c)(5),{ok:n,label:r}=e,a=n?`bg-success-soft text-success`:`bg-surface-hover text-fg-muted`,o;t[0]===a?o=t[1]:(o=i(`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium`,a),t[0]=a,t[1]=o);let s;return t[2]!==r||t[3]!==o?(s=(0,P.jsx)(`span`,{className:o,children:r}),t[2]=r,t[3]=o,t[4]=s):s=t[4],s}function Z(){let e=(0,k.c)(7),t=a(o(Q)).setupStatus,{ready:n,error:r,snapshot:s,refresh:c}=U(),l;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=i(`inline-flex shrink-0 items-center gap-2 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,w.press),e[0]=l):l=e[0];let u;e[1]===c?u=e[2]:(u=()=>void c(),e[1]=c,e[2]=u);let f=!n&&`animate-spin`,h;e[3]===f?h=e[4]:(h=i(`size-4`,f),e[3]=f,e[4]=h);let g;return e[5]===h?g=e[6]:(g=(0,P.jsx)(m,{className:h,"aria-hidden":!0}),e[5]=h,e[6]=g),(0,P.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,P.jsxs)(`header`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,P.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.title}),(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.subtitle})]}),(0,P.jsxs)(`button`,{type:`button`,className:l,onClick:u,disabled:!n,children:[g,t.refresh]})]}),r?(0,P.jsx)(`p`,{className:`rounded-xl border border-red-300/40 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-300`,children:t.loadError}):null,!n||!s?(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,"aria-busy":!0,children:[(0,P.jsx)(b,{className:`size-4 animate-spin`,"aria-hidden":!0}),t.loading]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(D,{children:[(0,P.jsx)(E,{icon:_,title:t.summaryTitle,subtitle:t.summarySubtitle}),(0,P.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-3`,children:[(0,P.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel px-4 py-3`,children:[(0,P.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.summaryGateway}),(0,P.jsx)(`div`,{className:`mt-2`,children:(0,P.jsx)(X,{ok:s.gatewayConnected,label:s.gatewayConnected?t.statusOnline:t.statusOffline})})]}),(0,P.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel px-4 py-3`,children:[(0,P.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.summaryProviders}),(0,P.jsx)(`p`,{className:`mt-2 truncate text-sm font-medium text-fg`,children:s.providerConfigured?s.providerMetaTotal>0?t.labels.providersMetaReady.replace(`{{configured}}`,String(s.providerMetaConfigured)).replace(`{{total}}`,String(s.providerMetaTotal)):t.labels.providersConfigured.replace(`{{count}}`,String(s.providerCount)):t.labels.providersMissing})]}),(0,P.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel px-4 py-3`,children:[(0,P.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.summaryModel}),(0,P.jsx)(`p`,{className:`mt-2 truncate text-sm font-medium text-fg`,children:s.defaultModelConfigured?s.defaultModel:t.labels.modelMissing})]})]}),s.requiredComplete?(0,P.jsx)(`p`,{className:`mt-4 text-sm text-success`,children:t.requiredCompleteMessage}):(0,P.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:t.requiredIncompleteMessage})]}),(0,P.jsx)(I,{}),(0,P.jsxs)(D,{children:[(0,P.jsx)(E,{icon:p,title:t.checklistTitle,subtitle:t.checklistSubtitle}),(0,P.jsx)(`ul`,{className:`mt-4 flex flex-col gap-1`,children:s.checklist.map(e=>{let n=t.items[e.id];return(0,P.jsx)(`li`,{children:(0,P.jsxs)(d,{to:Y[e.id],className:i(`flex items-center gap-3 rounded-xl px-3 py-3 transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,P.jsx)(`span`,{className:i(`flex size-6 shrink-0 items-center justify-center rounded-full border`,e.done?`border-success/40 bg-success-soft text-success`:`border-edge bg-surface-panel text-fg-subtle`),"aria-hidden":!0,children:e.done?(0,P.jsx)(_,{className:`size-3.5`,strokeWidth:2.5}):null}),(0,P.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,P.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.title}),e.optional?(0,P.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:t.optionalBadge}):null]}),(0,P.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-muted`,children:n.description}),e.detail?(0,P.jsx)(`span`,{className:`mt-1 block truncate text-xs text-fg-subtle`,children:e.detail}):null]}),(0,P.jsx)(C,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0})]})},e.id)})})]})]})]})}function Q(e){return e.language}export{Z as SetupStatusPanel};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{i as t,t as n}from"./fetch-Bs7in_4F.js";import{Yt as r}from"./index-COkF54xv.js";var i=e({reloadSkills:()=>a});async function a(){let e=await n(t(`/api/skills/reload`),{method:`POST`});if(!e.ok)throw Error(await r(e))}export{i as n,a as t};