@xopcai/xopc 0.0.162 → 0.0.164

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (262) hide show
  1. package/README.md +4 -2
  2. package/README.zh-CN.md +4 -2
  3. package/dist/browser-ext/manifest.json +1 -1
  4. package/dist/extensions/telegram/xopc.extension.json +1 -1
  5. package/dist/gateway/static/root/assets/{activity-store-hpcNv9MZ.js → activity-store-DkALQFJT.js} +1 -1
  6. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Zf9UQEmQ.js → agent-avatar-dicebear-RpxkQtQ3.js} +1 -1
  7. package/dist/gateway/static/root/assets/agents-CxpwxMPE.js +2 -0
  8. package/dist/gateway/static/root/assets/{api-Dnatri09.js → api-DPIXEcIq.js} +1 -1
  9. package/dist/gateway/static/root/assets/{app-management-settings-panel-BBTR9wJP.js → app-management-settings-panel-DLdjfMXB.js} +1 -1
  10. package/dist/gateway/static/root/assets/{appearance-settings-C2zpLCHD.js → appearance-settings-C89-uxkq.js} +1 -1
  11. package/dist/gateway/static/root/assets/apps-page-k-tZbaRB.js +1 -0
  12. package/dist/gateway/static/root/assets/{archive-plugin-9eR_ODY1.js → archive-plugin-CqbH5geE.js} +1 -1
  13. package/dist/gateway/static/root/assets/{attachment-load-DPuWYUeX.js → attachment-load-CeU4Qiot.js} +1 -1
  14. package/dist/gateway/static/root/assets/{automation-suggestion-card-Dw49OJRl.js → automation-suggestion-card-WiOuqXq9.js} +1 -1
  15. package/dist/gateway/static/root/assets/automations-page-Bdn3dgC_.js +6 -0
  16. package/dist/gateway/static/root/assets/{binary-plugins-BdkJpDFm.js → binary-plugins-C5TdzrhJ.js} +1 -1
  17. package/dist/gateway/static/root/assets/{block-editor-CAi7SXYU.js → block-editor-BjvWhphG.js} +39 -39
  18. package/dist/gateway/static/root/assets/browser-settings-page-GsVTGfGs.js +8 -0
  19. package/dist/gateway/static/root/assets/{browser-workflow-inputs-Dx6wkGz1.js → browser-workflow-inputs-DXmzQ3nk.js} +1 -1
  20. package/dist/gateway/static/root/assets/{browser-workflows-page-Skertc-A.js → browser-workflows-page-C1-ptRe4.js} +2 -2
  21. package/dist/gateway/static/root/assets/capabilities-settings-panel-6d4kVjzl.js +2 -0
  22. package/dist/gateway/static/root/assets/{capability-presets-api-CNFl7dM3.js → capability-presets-api-C0pVlUyc.js} +1 -1
  23. package/dist/gateway/static/root/assets/capability-presets-settings-panel-DCxy5Ls_.js +2 -0
  24. package/dist/gateway/static/root/assets/{channel-recipient-api-DYQyGDw4.js → channel-recipient-api-B5rLegwk.js} +1 -1
  25. package/dist/gateway/static/root/assets/channels-settings-Bg3P8k0f.js +1 -0
  26. package/dist/gateway/static/root/assets/channels-status-swr-DZZq0upi.js +1 -0
  27. package/dist/gateway/static/root/assets/{connector-logo-Bng6kxYF.js → connector-logo-CuI5w4qM.js} +1 -1
  28. package/dist/gateway/static/root/assets/connectors-page-6UR7yhIZ.js +2 -0
  29. package/dist/gateway/static/root/assets/{desktop-pet-Bpf6oegd.js → desktop-pet-BvG8vDXZ.js} +1 -1
  30. package/dist/gateway/static/root/assets/{desktop-pet-settings-BVUyefSd.js → desktop-pet-settings-CR__kZ8C.js} +1 -1
  31. package/dist/gateway/static/root/assets/{directory-picker-path-field-DjSZAPz_.js → directory-picker-path-field-BblWMz3e.js} +1 -1
  32. package/dist/gateway/static/root/assets/{dreaming-settings-CAZk2AM4.js → dreaming-settings-DHMPugDE.js} +3 -3
  33. package/dist/gateway/static/root/assets/{extension-debug-page-C2F6vTTd.js → extension-debug-page-ByVY1gZg.js} +1 -1
  34. package/dist/gateway/static/root/assets/{extension-page-AnIt4bn4.js → extension-page-DLCKKtbK.js} +1 -1
  35. package/dist/gateway/static/root/assets/extension-settings-page-M-rhlFBC.js +1 -0
  36. package/dist/gateway/static/root/assets/{gateway-config-api-DLFyZv33.js → gateway-config-api-DZHqhbXH.js} +1 -1
  37. package/dist/gateway/static/root/assets/{gateway-settings-DnQAA-qq.js → gateway-settings-CZswIehx.js} +1 -1
  38. package/dist/gateway/static/root/assets/{gateway-startup-retry-DbzLyJ3R.js → gateway-startup-retry-ulwTJovP.js} +1 -1
  39. package/dist/gateway/static/root/assets/goal-create-dialog-TbyRfDas.js +1 -0
  40. package/dist/gateway/static/root/assets/goal-detail-page-B-QBVOf2.js +4 -0
  41. package/dist/gateway/static/root/assets/{goals-config-api-REmr3QCr.js → goals-config-api-DMxG6f0N.js} +1 -1
  42. package/dist/gateway/static/root/assets/goals-page-BGxki8BR.js +2 -0
  43. package/dist/gateway/static/root/assets/{goals-settings-Dz0F3uRO.js → goals-settings-G-w1gCYD.js} +1 -1
  44. package/dist/gateway/static/root/assets/{heartbeat-settings-CQFY5gYs.js → heartbeat-settings-Csb90R59.js} +1 -1
  45. package/dist/gateway/static/root/assets/index-BXtJvaQl.css +1 -0
  46. package/dist/gateway/static/root/assets/{index-C8JkTS6d.js → index-CGwuxvzr.js} +70 -70
  47. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BnOQXU5k.js → keyboard-shortcuts-settings-C_Bl3YOr.js} +1 -1
  48. package/dist/gateway/static/root/assets/local-app-workbench-page-BR2tBhO3.js +2 -0
  49. package/dist/gateway/static/root/assets/{local-apps-page-KsOtWOyM.js → local-apps-page-_8Rv-tSk.js} +1 -1
  50. package/dist/gateway/static/root/assets/{locale-store-0lpYdNDr.js → locale-store-C_ax27uc.js} +1 -1
  51. package/dist/gateway/static/root/assets/logs-page-CwF0C_Z2.js +7 -0
  52. package/dist/gateway/static/root/assets/{markdown-split-D5GRg10r.js → markdown-split-CZnZS6gq.js} +1 -1
  53. package/dist/gateway/static/root/assets/{media-plugins-C1ryULGs.js → media-plugins-C2XLYC6G.js} +1 -1
  54. package/dist/gateway/static/root/assets/messages-C96Zjb0V.js +5 -0
  55. package/dist/gateway/static/root/assets/{notes-page-CIeZ1_DT.js → notes-page-BkuZxTFo.js} +1 -1
  56. package/dist/gateway/static/root/assets/notes-workbench-CD4FADi7.js +4 -0
  57. package/dist/gateway/static/root/assets/{page-tabs-Caj1-E_X.js → page-tabs-DR2FGC4E.js} +1 -1
  58. package/dist/gateway/static/root/assets/{preview-open-alternatives-DKwEce-9.js → preview-open-alternatives-B65O8wBL.js} +1 -1
  59. package/dist/gateway/static/root/assets/{product-open-page-B90ZskkN.js → product-open-page-Cag-utLH.js} +1 -1
  60. package/dist/gateway/static/root/assets/project-detail-page-COKtUblD.js +1 -0
  61. package/dist/gateway/static/root/assets/projects-page-QYmqanBN.js +1 -0
  62. package/dist/gateway/static/root/assets/remote-access-hub-BU_gBU0f.js +1 -0
  63. package/dist/gateway/static/root/assets/{save-bar-controls-BDYt53uQ.js → save-bar-controls-DCWpFnPc.js} +1 -1
  64. package/dist/gateway/static/root/assets/schedule-field-ClacZdvE.js +1 -0
  65. package/dist/gateway/static/root/assets/{schema-form-D7oCARF7.js → schema-form-BVlbEipU.js} +1 -1
  66. package/dist/gateway/static/root/assets/sessions-page-u-Pjbzfm.js +1 -0
  67. package/dist/gateway/static/root/assets/settings-advanced-gate-1Yck1PKq.js +1 -0
  68. package/dist/gateway/static/root/assets/{settings-form-section-CARTHCxH.js → settings-form-section-GSNlQWSW.js} +1 -1
  69. package/dist/gateway/static/root/assets/{settings-loading-skeleton-DEwYqESe.js → settings-loading-skeleton-08Ae5sB_.js} +1 -1
  70. package/dist/gateway/static/root/assets/{settings-page-B6vVdHeQ.js → settings-page-BseJD4I-.js} +1 -1
  71. package/dist/gateway/static/root/assets/{settings-page-layout-D3srt5Bi.js → settings-page-layout-bSliH-Y3.js} +1 -1
  72. package/dist/gateway/static/root/assets/setup-status-panel-CGRhJVlt.js +1 -0
  73. package/dist/gateway/static/root/assets/{share-preview-page-Ck9SxiXw.js → share-preview-page-C114OpTx.js} +1 -1
  74. package/dist/gateway/static/root/assets/shares-settings-BRFpWFgI.js +1 -0
  75. package/dist/gateway/static/root/assets/skill-reload-api-cVjU2GnN.js +1 -0
  76. package/dist/gateway/static/root/assets/skills-page-CoMTjtRT.js +2 -0
  77. package/dist/gateway/static/root/assets/{system-settings-panel-DLBUQSk2.js → system-settings-panel-El8cDcTY.js} +1 -1
  78. package/dist/gateway/static/root/assets/{theme-store-C1oaqeD2.js → theme-store-D37XLD_C.js} +1 -1
  79. package/dist/gateway/static/root/assets/time-picker-CU7hhD8T.js +1 -0
  80. package/dist/gateway/static/root/assets/{typed-models-lib-Divbg_C4.js → typed-models-lib-kToxD7Rc.js} +1 -1
  81. package/dist/gateway/static/root/assets/{use-channel-catalog-CP9a_rAf.js → use-channel-catalog-DBh0dOC9.js} +1 -1
  82. package/dist/gateway/static/root/assets/user-context-page-C0xYCSXB.js +1 -0
  83. package/dist/gateway/static/root/assets/voice-api-key-field-DzEpwYaU.js +1 -0
  84. package/dist/gateway/static/root/assets/work-discovery-page-DakZqR85.js +1 -0
  85. package/dist/gateway/static/root/assets/work-item-detail-page-CswqPbTT.js +1 -0
  86. package/dist/gateway/static/root/assets/work-page-DYRXEk8m.js +1 -0
  87. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DbDPYQwB.js → workflow-run-setup-panel-BwSxyVMM.js} +2 -2
  88. package/dist/gateway/static/root/assets/workflows-page-CiLSYGuN.js +11 -0
  89. package/dist/gateway/static/root/index.html +7 -7
  90. package/dist/package.js +1 -1
  91. package/dist/src/agent/client-error-format.d.ts +1 -1
  92. package/dist/src/agent/client-error-format.js +6 -2
  93. package/dist/src/agent/embedded/model-runtime.d.ts +4 -0
  94. package/dist/src/agent/embedded/model-runtime.js +49 -0
  95. package/dist/src/agent/embedded/run-for-session.js +38 -31
  96. package/dist/src/agent/embedded/session-runner.d.ts +1 -0
  97. package/dist/src/agent/embedded/session-runner.js +13 -5
  98. package/dist/src/agent/failover-error.d.ts +1 -1
  99. package/dist/src/agent/image/generation/openai-compatible-image-provider.d.ts +2 -6
  100. package/dist/src/agent/image/generation/openai-compatible-image-provider.js +1 -3
  101. package/dist/src/agent/image/generation/provider-registry.d.ts +5 -46
  102. package/dist/src/agent/image/generation/provider-registry.js +24 -73
  103. package/dist/{extensions/dashscope/src/image-generation-provider.d.ts → src/agent/image/generation/providers/dashscope.d.ts} +3 -6
  104. package/dist/{extensions/dashscope/src/image-generation-provider.js → src/agent/image/generation/providers/dashscope.js} +36 -59
  105. package/dist/{extensions/fal/src/image-generation-provider.d.ts → src/agent/image/generation/providers/fal.d.ts} +1 -1
  106. package/dist/{extensions/fal/src/image-generation-provider.js → src/agent/image/generation/providers/fal.js} +19 -29
  107. package/dist/{extensions/google/src/image-generation-provider.d.ts → src/agent/image/generation/providers/google.d.ts} +2 -2
  108. package/dist/{extensions/google/src/image-generation-provider.js → src/agent/image/generation/providers/google.js} +23 -30
  109. package/dist/{extensions/minimax/src/image-generation-provider.d.ts → src/agent/image/generation/providers/minimax.d.ts} +2 -5
  110. package/dist/{extensions/minimax/src/image-generation-provider.js → src/agent/image/generation/providers/minimax.js} +35 -51
  111. package/dist/{extensions/openai/src/image-generation-provider.d.ts → src/agent/image/generation/providers/openai.d.ts} +2 -2
  112. package/dist/{extensions/openai/src/image-generation-provider.js → src/agent/image/generation/providers/openai.js} +13 -38
  113. package/dist/src/agent/image/generation/runtime-types.d.ts +1 -0
  114. package/dist/src/agent/image/generation/runtime.d.ts +1 -3
  115. package/dist/src/agent/image/generation/runtime.js +6 -6
  116. package/dist/src/agent/image/generation/types.d.ts +23 -3
  117. package/dist/src/agent/image/index.d.ts +1 -1
  118. package/dist/src/agent/image/index.js +2 -2
  119. package/dist/src/agent/media-generation/runtime-shared.d.ts +2 -0
  120. package/dist/src/agent/media-generation/runtime-shared.js +1 -0
  121. package/dist/src/agent/tools/factory.js +4 -1
  122. package/dist/src/agent/tools/image-generate-tool.d.ts +2 -0
  123. package/dist/src/agent/tools/image-generate-tool.js +14 -7
  124. package/dist/src/auth/credentials.js +45 -2
  125. package/dist/src/auth/index.js +2 -1
  126. package/dist/src/auth/oauth/anthropic.js +27 -24
  127. package/dist/src/auth/oauth/github-copilot.js +20 -15
  128. package/dist/src/auth/oauth/google-antigravity.js +9 -2
  129. package/dist/src/auth/oauth/google-gemini-cli.js +9 -2
  130. package/dist/src/auth/oauth/google-oauth/google-antigravity.js +47 -40
  131. package/dist/src/auth/oauth/google-oauth/google-gemini-cli.js +48 -41
  132. package/dist/src/auth/oauth/google-oauth/oauth-page.js +7 -2
  133. package/dist/src/auth/oauth/google-oauth/pkce.js +4 -1
  134. package/dist/src/auth/oauth/index.d.ts +2 -0
  135. package/dist/src/auth/oauth/index.js +24 -10
  136. package/dist/src/auth/oauth/kimi-coding.js +76 -71
  137. package/dist/src/auth/oauth/minimax-cn.js +78 -73
  138. package/dist/src/auth/oauth/minimax.js +78 -73
  139. package/dist/src/auth/oauth/openai-codex.js +31 -25
  140. package/dist/src/auth/oauth/pkce.js +4 -1
  141. package/dist/src/auth/oauth/registry.d.ts +13 -0
  142. package/dist/src/auth/oauth/registry.js +65 -0
  143. package/dist/src/auth/oauth/xopc-cloud.d.ts +2 -0
  144. package/dist/src/auth/oauth/xopc-cloud.js +101 -0
  145. package/dist/src/auth/sync-provider-auth.d.ts +3 -0
  146. package/dist/src/auth/sync-provider-auth.js +17 -1
  147. package/dist/src/cli/commands/models.js +2 -5
  148. package/dist/src/cli/commands/onboard/model.js +3 -2
  149. package/dist/src/cli/commands/setup-shared/types.d.ts +1 -1
  150. package/dist/src/cli/utils/oauth-providers.d.ts +3 -26
  151. package/dist/src/cli/utils/oauth-providers.js +6 -80
  152. package/dist/src/config/index.js +2 -2
  153. package/dist/src/config/models-json.d.ts +6 -0
  154. package/dist/src/config/models-json.js +10 -6
  155. package/dist/src/config/schema.d.ts +26 -15
  156. package/dist/src/config/schema.js +23 -12
  157. package/dist/src/gateway/heartbeat/service.js +1 -1
  158. package/dist/src/gateway/hono/app.js +12 -6
  159. package/dist/src/gateway/hono/lib/safe-providers-config.d.ts +0 -3
  160. package/dist/src/gateway/hono/lib/safe-providers-config.js +1 -3
  161. package/dist/src/gateway/hono/middleware/strict-rate-limit.d.ts +4 -0
  162. package/dist/src/gateway/hono/middleware/strict-rate-limit.js +8 -1
  163. package/dist/src/gateway/hono/oauth-async.js +3 -19
  164. package/dist/src/gateway/hono/oauth.js +3 -19
  165. package/dist/src/gateway/hono/routes/config-patch/misc.js +2 -11
  166. package/dist/src/gateway/hono/routes/deps.d.ts +1 -0
  167. package/dist/src/gateway/hono/routes/lazy-bundles.js +9 -2
  168. package/dist/src/gateway/hono/routes/models.js +96 -128
  169. package/dist/src/gateway/image-generation-setup.d.ts +40 -0
  170. package/dist/src/gateway/image-generation-setup.js +130 -0
  171. package/dist/src/gateway/rate-limit/buckets.d.ts +3 -0
  172. package/dist/src/gateway/rate-limit/buckets.js +12 -0
  173. package/dist/src/gateway/service.d.ts +3 -0
  174. package/dist/src/gateway/service.js +10 -0
  175. package/dist/src/heartbeat/index.js +1 -1
  176. package/dist/src/media-shared/http/private-network.d.ts +1 -1
  177. package/dist/src/media-shared/http/private-network.js +1 -1
  178. package/dist/src/providers/auth-runtime/resolve-api-key.d.ts +2 -4
  179. package/dist/src/providers/auth-runtime/resolve-api-key.js +2 -4
  180. package/dist/src/providers/auth-runtime/resolve-auth.d.ts +3 -4
  181. package/dist/src/providers/auth-runtime/resolve-auth.js +18 -18
  182. package/dist/src/providers/domestic-presets.d.ts +2 -0
  183. package/dist/src/providers/index.js +9 -0
  184. package/dist/src/providers/model-catalog-store.d.ts +33 -0
  185. package/dist/src/providers/model-catalog-store.js +63 -0
  186. package/dist/src/providers/model-catalog-sync-service.d.ts +40 -0
  187. package/dist/src/providers/model-catalog-sync-service.js +132 -0
  188. package/dist/src/providers/model-reference-auditor.d.ts +14 -0
  189. package/dist/src/providers/model-reference-auditor.js +71 -0
  190. package/dist/src/providers/model-registry.d.ts +4 -1
  191. package/dist/src/providers/model-registry.js +33 -2
  192. package/dist/src/providers/presentation.js +2 -0
  193. package/dist/src/providers/xopc-cloud-model-source.d.ts +30 -0
  194. package/dist/src/providers/xopc-cloud-model-source.js +68 -0
  195. package/dist/src/session/index.d.ts +1 -1
  196. package/dist/src/session/index.js +2 -2
  197. package/dist/src/session/session-title.d.ts +2 -0
  198. package/dist/src/session/session-title.js +24 -3
  199. package/dist/src/work-discovery/analyzer.js +27 -14
  200. package/package.json +5 -7
  201. package/dist/extensions/dashscope/src/index.d.ts +0 -4
  202. package/dist/extensions/dashscope/src/index.js +0 -2
  203. package/dist/extensions/dashscope/xopc.extension.json +0 -15
  204. package/dist/extensions/fal/src/index.d.ts +0 -4
  205. package/dist/extensions/fal/src/index.js +0 -2
  206. package/dist/extensions/fal/xopc.extension.json +0 -14
  207. package/dist/extensions/google/src/index.d.ts +0 -4
  208. package/dist/extensions/google/src/index.js +0 -2
  209. package/dist/extensions/google/xopc.extension.json +0 -14
  210. package/dist/extensions/minimax/src/index.d.ts +0 -4
  211. package/dist/extensions/minimax/src/index.js +0 -2
  212. package/dist/extensions/minimax/xopc.extension.json +0 -15
  213. package/dist/extensions/openai/src/index.d.ts +0 -4
  214. package/dist/extensions/openai/src/index.js +0 -2
  215. package/dist/extensions/openai/xopc.extension.json +0 -14
  216. package/dist/gateway/static/root/assets/agents-DfVkZlHc.js +0 -2
  217. package/dist/gateway/static/root/assets/apps-page-BMtAa4Ra.js +0 -1
  218. package/dist/gateway/static/root/assets/automations-page-BiSAMYTr.js +0 -6
  219. package/dist/gateway/static/root/assets/browser-settings-page-DHmaEJS2.js +0 -8
  220. package/dist/gateway/static/root/assets/capabilities-settings-panel-B5wSgf4f.js +0 -2
  221. package/dist/gateway/static/root/assets/capability-presets-settings-panel-DyvFZwBj.js +0 -2
  222. package/dist/gateway/static/root/assets/channels-settings-BBKEqDZn.js +0 -1
  223. package/dist/gateway/static/root/assets/channels-status-swr-Drk110ve.js +0 -1
  224. package/dist/gateway/static/root/assets/connectors-page-HpgaUDQ1.js +0 -2
  225. package/dist/gateway/static/root/assets/extension-settings-page-CLSc6682.js +0 -1
  226. package/dist/gateway/static/root/assets/goal-create-dialog-DrnKFC6M.js +0 -1
  227. package/dist/gateway/static/root/assets/goal-detail-page-Cw1hpJkZ.js +0 -4
  228. package/dist/gateway/static/root/assets/goals-page-BDGkTVma.js +0 -2
  229. package/dist/gateway/static/root/assets/index-hmrG55qg.css +0 -1
  230. package/dist/gateway/static/root/assets/local-app-workbench-page-Bdef1b7F.js +0 -2
  231. package/dist/gateway/static/root/assets/logs-page-CwLPgrWh.js +0 -7
  232. package/dist/gateway/static/root/assets/messages-BwQ3WssU.js +0 -5
  233. package/dist/gateway/static/root/assets/notes-workbench-Cf06q19x.js +0 -4
  234. package/dist/gateway/static/root/assets/project-detail-page-SHTurM4t.js +0 -1
  235. package/dist/gateway/static/root/assets/projects-page-BcC2qUAw.js +0 -1
  236. package/dist/gateway/static/root/assets/remote-access-hub-6vGefBHv.js +0 -1
  237. package/dist/gateway/static/root/assets/schedule-field-Bcdni4Pj.js +0 -1
  238. package/dist/gateway/static/root/assets/sessions-page-C5014a53.js +0 -1
  239. package/dist/gateway/static/root/assets/settings-advanced-gate-CDY3ZI1K.js +0 -1
  240. package/dist/gateway/static/root/assets/settings-collapsible-section-6eNF8Jey.js +0 -1
  241. package/dist/gateway/static/root/assets/setup-status-panel-z-rF0Hdg.js +0 -1
  242. package/dist/gateway/static/root/assets/shares-settings-CHZFXE_d.js +0 -1
  243. package/dist/gateway/static/root/assets/skill-reload-api-B7p2QNXt.js +0 -1
  244. package/dist/gateway/static/root/assets/skills-page-ncw3tX9P.js +0 -2
  245. package/dist/gateway/static/root/assets/user-context-page-iYfeSLKI.js +0 -1
  246. package/dist/gateway/static/root/assets/voice-api-key-field-CrwkicvT.js +0 -1
  247. package/dist/gateway/static/root/assets/work-discovery-page-BQWxyPg8.js +0 -1
  248. package/dist/gateway/static/root/assets/work-item-detail-page-50ZzGay5.js +0 -1
  249. package/dist/gateway/static/root/assets/work-page-DPqEahx7.js +0 -1
  250. package/dist/gateway/static/root/assets/workflows-page-C3eIC5HZ.js +0 -11
  251. package/dist/src/agent/embedded/xopc-auth-storage.d.ts +0 -19
  252. package/dist/src/agent/embedded/xopc-auth-storage.js +0 -40
  253. package/dist/src/agent/image/generation/bundled-registry.d.ts +0 -18
  254. package/dist/src/agent/image/generation/bundled-registry.js +0 -35
  255. package/dist/src/agent/image/generation/bundled.d.ts +0 -10
  256. package/dist/src/agent/image/generation/bundled.js +0 -15
  257. package/dist/src/agent/image/generation/image-provider-ui.d.ts +0 -20
  258. package/dist/src/agent/image/generation/image-provider-ui.js +0 -1
  259. package/dist/src/gateway/image-capabilities.d.ts +0 -28
  260. package/dist/src/gateway/image-capabilities.js +0 -78
  261. package/dist/src/generated/bundled-image-generation-providers.d.ts +0 -14
  262. package/dist/src/generated/bundled-image-generation-providers.js +0 -17
@@ -0,0 +1,8 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as a}from"./cn-JdwAhgNB.js";import{t as o}from"./copy-to-clipboard-HOJ79TWv.js";import{t as s}from"./messages-C96Zjb0V.js";import{l as c,n as l,o as u,r as d,s as f}from"./locale-store-C_ax27uc.js";import{$o as p,Ac as m,Ec as h,Fc as g,Ic as _,Jc as v,Js as y,Kl as b,Ks as x,Mt as S,Ns as C,Nt as w,Pc as T,Ql as E,Rs as D,Ss as O,Xl as k,_u as A,cs as j,cu as M,dc as N,ei as P,fu as F,hu as I,jl as L,jt as R,lu as z,mc as B,no as V,oc as H,os as U,pc as W,rl as G,ru as K,to as ee,tr as te,ws as ne}from"./index-CGwuxvzr.js";import{n as re,r as ie,t as ae}from"./settings-page-layout-bSliH-Y3.js";import{n as oe}from"./settings-loading-skeleton-08Ae5sB_.js";import{t as se}from"./settings-advanced-gate-1Yck1PKq.js";import{n as ce,t as q}from"./settings-form-section-GSNlQWSW.js";import{t as le}from"./page-tabs-DR2FGC4E.js";import{c as ue,r as de,s as J}from"./typed-models-lib-kToxD7Rc.js";import{i as fe,l as pe,s as me,u as he}from"./gateway-config-api-DZHqhbXH.js";var Y=e(t(),1),X=n(),Z=r();function Q(e){let t=(0,X.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.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,Z.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,Z.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 ge(e){switch(e){case`ready`:return`bg-emerald-500`;case`not_installed`:case`checking`:return`bg-amber-500`;case`error`:return`bg-red-500`;default:return`bg-fg-subtle/60`}}function _e(e){let t=(0,X.c)(28),{value:n,onChange:r,onOpenConfig:i,options:o,m:s}=e,c;if(t[0]!==s.browserGoToConfigure||t[1]!==s.browserPickerSubtitle||t[2]!==s.browserPickerTitle||t[3]!==r||t[4]!==i||t[5]!==o||t[6]!==n){let e=o.find(e=>e.value===n)??o[0],l;t[8]===s.browserPickerTitle?l=t[9]:(l=(0,Z.jsx)(`label`,{htmlFor:`browser-backend-select`,className:`text-sm font-medium text-fg`,children:s.browserPickerTitle}),t[8]=s.browserPickerTitle,t[9]=l);let u;t[10]===s.browserPickerSubtitle?u=t[11]:(u=(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:s.browserPickerSubtitle}),t[10]=s.browserPickerSubtitle,t[11]=u);let d;t[12]!==l||t[13]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[l,u]}),t[12]=l,t[13]=u,t[14]=d):d=t[14];let f;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(f=a(ue(),`min-w-0 flex-1 sm:max-w-md`),t[15]=f):f=t[15];let p;t[16]===r?p=t[17]:(p=e=>r(e.target.value),t[16]=r,t[17]=p);let m=s.browserPickerTitle,h;t[18]===o?h=t[19]:(h=o.map(ve),t[18]=o,t[19]=h);let g;t[20]!==s.browserPickerTitle||t[21]!==p||t[22]!==h||t[23]!==n?(g=(0,Z.jsx)(U,{id:`browser-backend-select`,className:f,value:n,onChange:p,"aria-label":m,children:h}),t[20]=s.browserPickerTitle,t[21]=p,t[22]=h,t[23]=n,t[24]=g):g=t[24];let _=i?(0,Z.jsxs)(`button`,{type:`button`,className:a(`inline-flex shrink-0 items-center justify-center gap-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-xs font-medium text-accent`,`transition-colors hover:border-edge-strong hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),onClick:()=>i(n),"aria-label":`${e?.name??n} — ${s.browserGoToConfigure}`,children:[(0,Z.jsx)(`span`,{children:s.browserGoToConfigure}),(0,Z.jsx)(A,{className:`size-4 shrink-0`,"aria-hidden":!0})]}):null,v;t[25]!==_||t[26]!==g?(v=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-2`,children:[g,_]}),t[25]=_,t[26]=g,t[27]=v):v=t[27],c=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[d,v,e?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e.statusLabel?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] font-medium text-fg-muted`,"aria-label":e.statusLabel,children:[(0,Z.jsx)(`span`,{className:a(`inline-block size-1.5 rounded-full`,ge(e.status)),"aria-hidden":!0}),e.statusLabel]}):null}),(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:e.tagline})]}):null]}),t[0]=s.browserGoToConfigure,t[1]=s.browserPickerSubtitle,t[2]=s.browserPickerTitle,t[3]=r,t[4]=i,t[5]=o,t[6]=n,t[7]=c}else c=t[7];return c}function ve(e){return(0,Z.jsx)(j,{value:e.value,children:e.name},e.value)}function ye(e){return`browser-focus-${e}`}function be(e){switch(e){case`connection`:case`extension`:case`local`:case`cloak`:case`cdp`:case`cloud`:case`runtime`:case`security`:return e;default:return null}}function xe(e){let t=(0,X.c)(89),{a:n,form:r,update:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=ye(`runtime`),t[0]=a):a=t[0];let o;t[1]===n.browserBehaviorShow?o=t[2]:(o=(0,Z.jsx)(ce,{icon:N,title:n.browserBehaviorShow}),t[1]=n.browserBehaviorShow,t[2]=o);let s;t[3]===i?s=t[4]:(s=e=>i({browserHeadless:e.target.checked}),t[3]=i,t[4]=s);let c;t[5]!==r.browserHeadless||t[6]!==s?(c=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserHeadless,onChange:s}),t[5]=r.browserHeadless,t[6]=s,t[7]=c):c=t[7];let l;t[8]===n.browserHeadlessOn?l=t[9]:(l=(0,Z.jsx)(`span`,{children:n.browserHeadlessOn}),t[8]=n.browserHeadlessOn,t[9]=l);let u;t[10]!==c||t[11]!==l?(u=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[c,l]}),t[10]=c,t[11]=l,t[12]=u):u=t[12];let d;t[13]!==n.desc.browserHeadless||t[14]!==n.label.browserHeadless||t[15]!==u?(d=(0,Z.jsx)(Q,{label:n.label.browserHeadless,description:n.desc.browserHeadless,children:u}),t[13]=n.desc.browserHeadless,t[14]=n.label.browserHeadless,t[15]=u,t[16]=d):d=t[16];let f=n.label.browserDialogPolicy,p=n.desc.browserDialogPolicy,m;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(m=ue(),t[17]=m):m=t[17];let h;t[18]===i?h=t[19]:(h=e=>i({browserDialogPolicy:e.target.value}),t[18]=i,t[19]=h);let g;t[20]===n.browserDialogPolicyMustRespond?g=t[21]:(g=(0,Z.jsx)(j,{value:`must_respond`,children:n.browserDialogPolicyMustRespond}),t[20]=n.browserDialogPolicyMustRespond,t[21]=g);let _;t[22]===n.browserDialogPolicyAutoDismiss?_=t[23]:(_=(0,Z.jsx)(j,{value:`auto_dismiss`,children:n.browserDialogPolicyAutoDismiss}),t[22]=n.browserDialogPolicyAutoDismiss,t[23]=_);let v;t[24]===n.browserDialogPolicyAutoAccept?v=t[25]:(v=(0,Z.jsx)(j,{value:`auto_accept`,children:n.browserDialogPolicyAutoAccept}),t[24]=n.browserDialogPolicyAutoAccept,t[25]=v);let y;t[26]!==r.browserDialogPolicy||t[27]!==h||t[28]!==g||t[29]!==_||t[30]!==v?(y=(0,Z.jsxs)(U,{className:m,value:r.browserDialogPolicy,onChange:h,children:[g,_,v]}),t[26]=r.browserDialogPolicy,t[27]=h,t[28]=g,t[29]=_,t[30]=v,t[31]=y):y=t[31];let b;t[32]!==n.desc.browserDialogPolicy||t[33]!==n.label.browserDialogPolicy||t[34]!==y?(b=(0,Z.jsx)(Q,{label:f,description:p,children:y}),t[32]=n.desc.browserDialogPolicy,t[33]=n.label.browserDialogPolicy,t[34]=y,t[35]=b):b=t[35];let x=n.label.browserDialogTimeout,S=n.desc.browserDialogTimeout,C;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(C=J(),t[36]=C):C=t[36];let w=r.browserDialogTimeout??``,T;t[37]===i?T=t[38]:(T=e=>{let t=e.target.value;i({browserDialogTimeout:t===``?void 0:Number.parseInt(t,10)})},t[37]=i,t[38]=T);let E;t[39]!==w||t[40]!==T?(E=(0,Z.jsx)(`input`,{type:`number`,className:C,min:1,value:w,placeholder:`300`,onChange:T}),t[39]=w,t[40]=T,t[41]=E):E=t[41];let D;t[42]!==n.desc.browserDialogTimeout||t[43]!==n.label.browserDialogTimeout||t[44]!==E?(D=(0,Z.jsx)(Q,{label:x,description:S,children:E}),t[42]=n.desc.browserDialogTimeout,t[43]=n.label.browserDialogTimeout,t[44]=E,t[45]=D):D=t[45];let O;t[46]!==b||t[47]!==D||t[48]!==d?(O=(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[d,b,D]}),t[46]=b,t[47]=D,t[48]=d,t[49]=O):O=t[49];let k;t[50]!==o||t[51]!==O?(k=(0,Z.jsx)(`div`,{id:a,className:`scroll-mt-24`,children:(0,Z.jsxs)(q,{children:[o,O]})}),t[50]=o,t[51]=O,t[52]=k):k=t[52];let A;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(A=ye(`security`),t[53]=A):A=t[53];let M;t[54]===n.browserSecurityShow?M=t[55]:(M=(0,Z.jsx)(ce,{icon:B,title:n.browserSecurityShow}),t[54]=n.browserSecurityShow,t[55]=M);let P;t[56]===i?P=t[57]:(P=e=>i({browserAllowPrivateUrls:e.target.checked}),t[56]=i,t[57]=P);let F;t[58]!==r.browserAllowPrivateUrls||t[59]!==P?(F=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserAllowPrivateUrls,onChange:P}),t[58]=r.browserAllowPrivateUrls,t[59]=P,t[60]=F):F=t[60];let I;t[61]===n.browserAllowPrivateOn?I=t[62]:(I=(0,Z.jsx)(`span`,{children:n.browserAllowPrivateOn}),t[61]=n.browserAllowPrivateOn,t[62]=I);let L;t[63]!==F||t[64]!==I?(L=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[F,I]}),t[63]=F,t[64]=I,t[65]=L):L=t[65];let R;t[66]!==n.desc.browserAllowPrivateUrls||t[67]!==n.label.browserAllowPrivateUrls||t[68]!==L?(R=(0,Z.jsx)(Q,{label:n.label.browserAllowPrivateUrls,description:n.desc.browserAllowPrivateUrls,children:L}),t[66]=n.desc.browserAllowPrivateUrls,t[67]=n.label.browserAllowPrivateUrls,t[68]=L,t[69]=R):R=t[69];let z=n.label.browserCommandTimeout,V=n.desc.browserCommandTimeout,H;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(H=J(),t[70]=H):H=t[70];let W=r.browserCommandTimeout??``,G;t[71]===i?G=t[72]:(G=e=>{let t=e.target.value;i({browserCommandTimeout:t===``?void 0:Number.parseInt(t,10)})},t[71]=i,t[72]=G);let K;t[73]!==W||t[74]!==G?(K=(0,Z.jsx)(`input`,{type:`number`,className:H,min:5,value:W,placeholder:`30`,onChange:G}),t[73]=W,t[74]=G,t[75]=K):K=t[75];let ee;t[76]!==n.desc.browserCommandTimeout||t[77]!==n.label.browserCommandTimeout||t[78]!==K?(ee=(0,Z.jsx)(Q,{label:z,description:V,children:K}),t[76]=n.desc.browserCommandTimeout,t[77]=n.label.browserCommandTimeout,t[78]=K,t[79]=ee):ee=t[79];let te;t[80]!==R||t[81]!==ee?(te=(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[R,ee]}),t[80]=R,t[81]=ee,t[82]=te):te=t[82];let ne;t[83]!==M||t[84]!==te?(ne=(0,Z.jsx)(`div`,{id:A,className:`scroll-mt-24`,children:(0,Z.jsxs)(q,{className:`border border-amber-500/20`,children:[M,te]})}),t[83]=M,t[84]=te,t[85]=ne):ne=t[85];let re;return t[86]!==k||t[87]!==ne?(re=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[k,ne]}),t[86]=k,t[87]=ne,t[88]=re):re=t[88],re}function Se(e){let t=(0,X.c)(9),{language:n,label:r,className:i}=e,o;t[0]===n?o=t[1]:(o=p(n),t[0]=n,t[1]=o);let s;t[2]===i?s=t[3]:(s=a(`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,i),t[2]=i,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(b,{className:`size-3 shrink-0`,"aria-hidden":!0}),t[4]=c):c=t[4];let l;return t[5]!==r||t[6]!==o||t[7]!==s?(l=(0,Z.jsxs)(`a`,{href:o,target:`_blank`,rel:`noreferrer`,className:s,children:[r,c]}),t[5]=r,t[6]=o,t[7]=s,t[8]=l):l=t[8],l}function Ce(e){let t=(0,X.c)(27),{title:n,description:r,recommended:i,recommendedLabel:o,icon:s,onSelect:c,selectLabel:l}=e,u=`${n} — ${l}`,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=a(`group flex w-full flex-col rounded-xl bg-surface-panel/80 p-3 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/40`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=d):d=t[0];let f;t[1]===s?f=t[2]:(f=(0,Z.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,Z.jsx)(s,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=s,t[2]=f);let p;t[3]===n?p=t[4]:(p=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=p);let m;t[5]!==i||t[6]!==o?(m=i&&o?(0,Z.jsx)(`span`,{className:`rounded-full bg-accent/15 px-2 py-0.5 text-[10px] font-medium text-accent`,children:o}):null,t[5]=i,t[6]=o,t[7]=m):m=t[7];let h;t[8]!==p||t[9]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[p,m]}),t[8]=p,t[9]=m,t[10]=h):h=t[10];let g;t[11]===r?g=t[12]:(g=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=g);let _;t[13]!==h||t[14]!==g?(_=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[h,g]}),t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(A,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[16]=v):v=t[16];let y;t[17]!==f||t[18]!==_?(y=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[f,_,v]}),t[17]=f,t[18]=_,t[19]=y):y=t[19];let b;t[20]===l?b=t[21]:(b=(0,Z.jsx)(`span`,{className:`mt-2 text-[11px] font-medium text-accent`,children:l}),t[20]=l,t[21]=b);let x;return t[22]!==c||t[23]!==u||t[24]!==y||t[25]!==b?(x=(0,Z.jsxs)(`button`,{type:`button`,onClick:c,"aria-label":u,className:d,children:[y,b]}),t[22]=c,t[23]=u,t[24]=y,t[25]=b,t[26]=x):x=t[26],x}function we(e){let t=(0,X.c)(25),{m:n,onStart:r}=e,i=P(Te),a;t[0]!==n.browserBackendCloakBrowser||t[1]!==n.browserModeCloakTagline||t[2]!==n.browserSetupCloudDesc||t[3]!==n.browserSetupCloudTitle||t[4]!==n.browserSetupExtDesc||t[5]!==n.browserSetupExtTitle||t[6]!==n.browserSetupLocalDesc||t[7]!==n.browserSetupLocalTitle||t[8]!==i?(a=[{id:`extension`,icon:m,title:n.browserSetupExtTitle,description:n.browserSetupExtDesc,recommended:!0},{id:`cloakbrowser`,icon:W,title:n.browserBackendCloakBrowser,description:n.browserModeCloakTagline},{id:`local`,icon:v,title:n.browserSetupLocalTitle,description:n.browserSetupLocalDesc},{id:`cloud`,icon:K,title:n.browserSetupCloudTitle,description:n.browserSetupCloudDesc}].filter(e=>pe(e.id,i)),t[0]=n.browserBackendCloakBrowser,t[1]=n.browserModeCloakTagline,t[2]=n.browserSetupCloudDesc,t[3]=n.browserSetupCloudTitle,t[4]=n.browserSetupExtDesc,t[5]=n.browserSetupExtTitle,t[6]=n.browserSetupLocalDesc,t[7]=n.browserSetupLocalTitle,t[8]=i,t[9]=a):a=t[9];let o=a,s;t[10]===n.browserSetupTitle?s=t[11]:(s=(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.browserSetupTitle}),t[10]=n.browserSetupTitle,t[11]=s);let c;t[12]===n.browserSetupSubtitle?c=t[13]:(c=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:n.browserSetupSubtitle}),t[12]=n.browserSetupSubtitle,t[13]=c);let l;t[14]!==s||t[15]!==c?(l=(0,Z.jsxs)(`div`,{children:[s,c]}),t[14]=s,t[15]=c,t[16]=l):l=t[16];let u;t[17]!==n.browserSetupRecommended||t[18]!==n.browserSetupSelect||t[19]!==o||t[20]!==r?(u=(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:o.map(e=>(0,Z.jsx)(Ce,{icon:e.icon,title:e.title,description:e.description,recommended:e.recommended,recommendedLabel:n.browserSetupRecommended,selectLabel:n.browserSetupSelect,onSelect:()=>r(e.id)},e.id))}),t[17]=n.browserSetupRecommended,t[18]=n.browserSetupSelect,t[19]=o,t[20]=r,t[21]=u):u=t[21];let d;return t[22]!==l||t[23]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-base p-4`,children:[l,u]}),t[22]=l,t[23]=u,t[24]=d):d=t[24],d}function Te(e){return e.mode}function Ee(e){if(e.kind===`loading`)return`checking`;if(e.kind===`error`)return`error`;if(e.kind===`ok`)return e.data.installed?`ready`:`not_installed`}function De(e,t){if(e)return{ready:t.browserStatusReady,not_installed:t.browserStatusNotInstalled,checking:t.browserStatusChecking,unknown:t.browserStatusUnknown,error:t.browserStatusError}[e]}function Oe(e){if(e.kind!==`idle`)return e.kind===`loading`?`checking`:e.kind===`error`?`error`:e.data.connected?`ready`:(e.data.running,`not_installed`)}function ke(e,t){if(e.kind!==`idle`)return e.kind===`loading`?t.browserStatusChecking:e.kind===`error`?t.browserStatusError:e.data.connected?t.browserExtensionConnected:e.data.running?t.browserExtensionWaiting:t.browserExtensionServerOff}var Ae=[`overview`,`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],je=[`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],Me={connection:`overview`,extension:`extension`,local:`local`,cloak:`cloakbrowser`,cdp:`cdp`,cloud:`cloud`,runtime:`overview`,security:`overview`};function Ne(e){let t=(e??``).trim();return t===`behavior`?`overview`:Ae.includes(t)?t:`overview`}function Pe(e){return je.includes(e)}function Fe(e){let t=(0,X.c)(46),{icon:n,title:r,description:i,status:a,statusDetail:o,primaryAction:s,children:c,advanced:l,m:u,embedded:d,sectionTitle:f,advancedTitle:p}=e,m=d===void 0?!1:d,h;t[0]!==l||t[1]!==p?(h=l?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[p?(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:p}):null,l]}):null,t[0]=l,t[1]=p,t[2]=h):h=t[2];let g=h;if(m){let e;t[3]!==i||t[4]!==f?(e=f?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:f}),i?(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i}):null]}):null,t[3]=i,t[4]=f,t[5]=e):e=t[5];let n;t[6]!==u||t[7]!==s||t[8]!==a||t[9]!==o?(n=a||s?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[a?(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(Ie,{kind:a,detail:o,m:u})}):(0,Z.jsx)(`span`,{}),s?(0,Z.jsx)(`div`,{className:`shrink-0`,children:s}):null]}):null,t[6]=u,t[7]=s,t[8]=a,t[9]=o,t[10]=n):n=t[10];let r;t[11]===c?r=t[12]:(r=c?(0,Z.jsx)(`div`,{className:`flex flex-col gap-4`,children:c}):null,t[11]=c,t[12]=r);let l;return t[13]!==g||t[14]!==e||t[15]!==n||t[16]!==r?(l=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e,n,r,g]}),t[13]=g,t[14]=e,t[15]=n,t[16]=r,t[17]=l):l=t[17],l}let _;t[18]===n?_=t[19]:(_=(0,Z.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,Z.jsx)(n,{className:`size-4`,strokeWidth:1.75})}),t[18]=n,t[19]=_);let v;t[20]===r?v=t[21]:(v=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r}),t[20]=r,t[21]=v);let y;t[22]!==u||t[23]!==a||t[24]!==o?(y=a?(0,Z.jsx)(Ie,{kind:a,detail:o,m:u}):null,t[22]=u,t[23]=a,t[24]=o,t[25]=y):y=t[25];let b;t[26]!==v||t[27]!==y?(b=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=b):b=t[28];let x;t[29]===i?x=t[30]:(x=(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i}),t[29]=i,t[30]=x);let S;t[31]!==b||t[32]!==x?(S=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[b,x]}),t[31]=b,t[32]=x,t[33]=S):S=t[33];let C;t[34]===s?C=t[35]:(C=s?(0,Z.jsx)(`div`,{className:`shrink-0`,children:s}):null,t[34]=s,t[35]=C);let w;t[36]!==_||t[37]!==S||t[38]!==C?(w=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[_,S,C]}),t[36]=_,t[37]=S,t[38]=C,t[39]=w):w=t[39];let T;t[40]===c?T=t[41]:(T=c?(0,Z.jsx)(`div`,{className:`flex flex-col gap-4`,children:c}):null,t[40]=c,t[41]=T);let E;return t[42]!==g||t[43]!==w||t[44]!==T?(E=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[w,T,g]}),t[42]=g,t[43]=w,t[44]=T,t[45]=E):E=t[45],E}function Ie(e){let t=(0,X.c)(27),{kind:n,detail:r,m:i}=e,o,s,c,l;if(t[0]!==n||t[1]!==i.browserStatusChecking||t[2]!==i.browserStatusError||t[3]!==i.browserStatusNotInstalled||t[4]!==i.browserStatusReady||t[5]!==i.browserStatusUnknown){let{icon:e,color:r,label:u}={ready:{icon:I,color:`text-green-600 dark:text-green-400`,label:i.browserStatusReady},not_installed:{icon:y,color:`text-amber-600 dark:text-amber-400`,label:i.browserStatusNotInstalled},checking:{icon:G,color:`text-fg-muted`,label:i.browserStatusChecking},unknown:{icon:F,color:`text-fg-muted`,label:i.browserStatusUnknown},error:{icon:z,color:`text-red-600 dark:text-red-400`,label:i.browserStatusError}}[n];o=e,s=u,l=`inline-flex min-w-0 flex-col items-start gap-1`,c=a(`inline-flex shrink-0 items-center gap-1 whitespace-nowrap text-xs font-medium`,r),t[0]=n,t[1]=i.browserStatusChecking,t[2]=i.browserStatusError,t[3]=i.browserStatusNotInstalled,t[4]=i.browserStatusReady,t[5]=i.browserStatusUnknown,t[6]=o,t[7]=s,t[8]=c,t[9]=l}else o=t[6],s=t[7],c=t[8],l=t[9];let u=n===`checking`&&`animate-spin`,d;t[10]===u?d=t[11]:(d=a(`size-3.5 shrink-0`,u),t[10]=u,t[11]=d);let f;t[12]!==o||t[13]!==d?(f=(0,Z.jsx)(o,{className:d}),t[12]=o,t[13]=d,t[14]=f):f=t[14];let p;t[15]===s?p=t[16]:(p=(0,Z.jsx)(`span`,{children:s}),t[15]=s,t[16]=p);let m;t[17]!==c||t[18]!==f||t[19]!==p?(m=(0,Z.jsxs)(`span`,{className:c,children:[f,p]}),t[17]=c,t[18]=f,t[19]=p,t[20]=m):m=t[20];let h;t[21]===r?h=t[22]:(h=r?(0,Z.jsx)(`span`,{className:`break-all font-mono text-[11px] leading-snug text-fg-subtle`,children:r}):null,t[21]=r,t[22]=h);let g;return t[23]!==l||t[24]!==m||t[25]!==h?(g=(0,Z.jsxs)(`span`,{className:l,children:[m,h]}),t[23]=l,t[24]=m,t[25]=h,t[26]=g):g=t[26],g}function Le(e){let t=(0,X.c)(5),{kind:n,message:r}=e,i=n===`success`?`border-green-500/30 bg-green-500/10 text-green-700 dark:text-green-300`:`border-red-500/30 bg-red-500/10 text-red-600 dark:text-red-300`,o;t[0]===i?o=t[1]:(o=a(`rounded-lg border px-3 py-2 text-xs leading-relaxed`,i),t[0]=i,t[1]=o);let s;return t[2]!==r||t[3]!==o?(s=(0,Z.jsx)(`div`,{className:o,children:r}),t[2]=r,t[3]=o,t[4]=s):s=t[4],s}var Re={instances:[],launchStatus:`idle`,launchMessage:null,testStatus:`idle`,testMessage:null,executablePath:``};function ze({m:e,cdpUrl:t,onCdpUrlChange:n,launch:r,stop:i,listInstances:a,ping:o,embedded:s=!1}){let[c,l]=(0,Y.useReducer)(w,Re),{instances:u,launchStatus:d,launchMessage:f,testStatus:p,testMessage:m,executablePath:h}=c,_=(0,Y.useCallback)(async()=>{try{l({type:`patch`,patch:{instances:await a()}})}catch{}},[a]);(0,Y.useEffect)(()=>{_();let e=setInterval(()=>void _(),8e3);return()=>clearInterval(e)},[_]);let v=(0,Y.useCallback)(async()=>{if(d!==`pending`){l({type:`patch`,patch:{launchStatus:`pending`,launchMessage:null}});try{let t=await r(h.trim()||void 0);l({type:`patch`,patch:{launchStatus:`ok`,launchMessage:e.browserCdpLaunchedAtPort.replace(`{{port}}`,String(t.port))}}),n(t.wsEndpoint),await _()}catch(e){l({type:`patch`,patch:{launchStatus:`error`,launchMessage:e instanceof Error?e.message:String(e)}})}}},[h,r,d,e.browserCdpLaunchedAtPort,n,_]),y=(0,Y.useCallback)(async e=>{await i(e),await _()},[_,i]),b=(0,Y.useCallback)(async()=>{if(t.trim()){l({type:`patch`,patch:{testStatus:`pending`,testMessage:null}});try{let n=await o(t.trim());n.reachable?l({type:`patch`,patch:{testStatus:`ok`,testMessage:e.browserCdpReachable.replace(`{{browser}}`,n.browser??`—`)}}):l({type:`patch`,patch:{testStatus:`error`,testMessage:e.browserCdpUnreachable.replace(`{{error}}`,n.error??`—`)}})}catch(t){l({type:`patch`,patch:{testStatus:`error`,testMessage:e.browserCdpUnreachable.replace(`{{error}}`,t instanceof Error?t.message:String(t))}})}}},[t,e.browserCdpReachable,e.browserCdpUnreachable,o]);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(Fe,{icon:g,title:e.browserCdpLaunchLocal,description:e.browserCdpLaunchLocalDesc,m:e,embedded:s,sectionTitle:s?e.browserCdpLaunchLocal:void 0,primaryAction:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:d===`pending`,onClick:()=>void v(),children:[d===`pending`?(0,Z.jsx)(G,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(g,{className:`size-3.5`}),d===`pending`?e.browserCdpLaunching:e.browserCdpLaunchLocal]}),children:[f?(0,Z.jsx)(Le,{kind:d===`error`?`error`:`success`,message:f}):null,(0,Z.jsx)(Q,{label:e.browserCdpChromePath,description:e.browserCdpChromePathDesc,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:h,placeholder:`/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`,onChange:e=>l({type:`patch`,patch:{executablePath:e.target.value}}),autoComplete:`off`})}),u.length>0?(0,Z.jsx)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base p-3 shadow-surface`,children:u.map(t=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Z.jsxs)(`span`,{className:`font-mono text-fg`,children:[`port `,t.port,` · pid `,t.pid]}),(0,Z.jsx)(`span`,{className:`truncate text-fg-subtle`,children:t.wsEndpoint})]}),(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs font-medium text-fg hover:bg-surface-raised`,onClick:()=>void y(t.port),children:[(0,Z.jsx)(H,{className:`size-3`}),e.browserCdpStopLocal]})]},t.port))}):null]}),(0,Z.jsxs)(Fe,{icon:D,title:e.label.browserCdpUrl,description:e.desc.browserCdpUrl,m:e,embedded:s,sectionTitle:s?e.label.browserCdpUrl:void 0,primaryAction:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:!t.trim()||p===`pending`,onClick:()=>void b(),children:[p===`pending`?(0,Z.jsx)(G,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(T,{className:`size-3.5`}),p===`pending`?e.browserCdpTesting:e.browserCdpTestConnection]}),children:[(0,Z.jsx)(`input`,{type:`text`,className:J(),value:t,placeholder:`ws://127.0.0.1:9222`,onChange:e=>n(e.target.value),autoComplete:`off`}),(0,Z.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:e.browserCdpLoopbackOnly}),m?(0,Z.jsx)(Le,{kind:p===`error`?`error`:`success`,message:m}):null]})]})}function Be(e,t){let n=t.phase;if(!n)return e.browserInstallPhaseStarting;if(n===`downloading`)return t.percent==null?e.browserInstallPhaseDownloading:e.browserInstallPhaseDownloadingPercent.replace(`{{percent}}`,String(t.percent));switch(n){case`starting`:return e.browserInstallPhaseStarting;case`verifying`:return e.browserInstallPhaseVerifying;case`extracting`:return e.browserInstallPhaseExtracting;case`running`:return t.message??e.browserInstallPhaseRunning;case`ready`:return e.browserInstallPhaseReady;default:return t.message??e.browserInstallPhaseRunning}}function Ve(e){let t=(0,X.c)(32),{m:n,progress:r,showLogs:i,onCancel:a,cancelling:o}=e,s=i===void 0?!1:i,c=o===void 0?!1:o;if(!r.phase)return null;let l;t[0]!==n||t[1]!==r?(l=Be(n,r),t[0]=n,t[1]=r,t[2]=l):l=t[2];let u=l,d=r.percent==null?(r.phase===`extracting`||r.phase===`verifying`||r.phase===`running`||r.phase,null):Math.min(100,Math.max(0,r.percent)),f;t[3]===u?f=t[4]:(f=(0,Z.jsx)(`span`,{className:`text-fg`,children:u}),t[3]=u,t[4]=f);let p;t[5]===d?p=t[6]:(p=d==null?null:(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[d,`%`]}),t[5]=d,t[6]=p);let m;t[7]!==c||t[8]!==n||t[9]!==a?(m=a?(0,Z.jsx)(`button`,{type:`button`,className:`rounded-md border border-edge px-2 py-0.5 text-[11px] font-medium text-fg-muted hover:bg-surface-raised hover:text-fg disabled:cursor-not-allowed disabled:opacity-60`,disabled:c,onClick:()=>void a(),children:c?n.browserInstallCancelling:n.browserInstallCancel}):null,t[7]=c,t[8]=n,t[9]=a,t[10]=m):m=t[10];let h;t[11]!==p||t[12]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[p,m]}),t[11]=p,t[12]=m,t[13]=h):h=t[13];let g;t[14]!==f||t[15]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs text-fg-muted`,children:[f,h]}),t[14]=f,t[15]=h,t[16]=g):g=t[16];let _;t[17]===d?_=t[18]:(_=(0,Z.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-raised`,children:d==null?(0,Z.jsx)(`div`,{className:`h-full w-1/3 animate-pulse rounded-full bg-accent/70`}):(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width] duration-300 ease-out`,style:{width:`${d}%`}})}),t[17]=d,t[18]=_);let v;t[19]!==r.lines||t[20]!==s?(v=s&&r.lines.length>0?(0,Z.jsx)(`div`,{className:`max-h-28 overflow-y-auto rounded-md bg-surface-panel px-2 py-1.5 font-mono text-[10px] leading-relaxed text-fg-muted shadow-surface`,children:r.lines.map(He)}):null,t[19]=r.lines,t[20]=s,t[21]=v):v=t[21];let y;t[22]!==r.message||t[23]!==r.percent||t[24]!==r.phase||t[25]!==s?(y=!s&&r.phase===`downloading`&&r.message&&r.percent==null?(0,Z.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:r.message}):null,t[22]=r.message,t[23]=r.percent,t[24]=r.phase,t[25]=s,t[26]=y):y=t[26];let b;return t[27]!==v||t[28]!==y||t[29]!==g||t[30]!==_?(b=(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-lg bg-surface-base px-3 py-2.5 shadow-surface`,children:[g,_,v,y]}),t[27]=v,t[28]=y,t[29]=g,t[30]=_,t[31]=b):b=t[31],b}function He(e){return(0,Z.jsx)(`div`,{className:`truncate`,children:e},e)}var Ue={confirmOpen:!1,installStatus:`idle`,installMessage:null,openStatus:`idle`,openMessage:null,runtime:null};function We({m:e,doctor:t,refetch:n,applyDoctor:r,installStream:i,fetchRuntimeStatus:a,launchCloak:o,form:s,onChange:c,embedded:l=!1}){let[u,d]=(0,Y.useReducer)(w,Ue),{confirmOpen:f,installStatus:p,installMessage:m,openStatus:_,openMessage:v,runtime:y}=u,{progress:b,running:x,cancelling:S,run:C,reset:T,cancel:E}=i,D=t.kind===`ok`?t.data:null,O=D?.installed===!0,A=p===`installing`||x,M=(0,Y.useCallback)(async()=>{if(O)try{d({type:`patch`,patch:{runtime:await a()}})}catch{}},[a,O]);(0,Y.useEffect)(()=>{if(!O){d({type:`patch`,patch:{runtime:null}});return}M();let e=setInterval(()=>void M(),8e3);return()=>clearInterval(e)},[O,M]);let N=(0,Y.useCallback)(async()=>{d({type:`patch`,patch:{confirmOpen:!1,installStatus:`installing`,installMessage:null}}),T();let t=await C({body:{cacheDir:s.cacheDir.trim()||void 0,binaryPath:s.binaryPath.trim()||void 0},fallbackError:e.browserCloakInstallFailed});if(!t.ok){if(t.error===`busy`){d({type:`patch`,patch:{installStatus:`installing`}});return}if(t.error===`cancelled`){d({type:`patch`,patch:{installStatus:`idle`,installMessage:null}}),T();return}d({type:`patch`,patch:{installStatus:`failed`,installMessage:t.errorMessage??e.browserCloakInstallFailed}});return}t.payload&&r?.(t.payload),d({type:`patch`,patch:{installStatus:`installed`,installMessage:t.payload?.binaryPath?`${e.browserCloakInstalled}: ${t.payload.binaryPath}`:e.browserCloakInstalled}}),await n({cacheDir:s.cacheDir,binaryPath:s.binaryPath}),await M()},[r,s.binaryPath,s.cacheDir,e.browserCloakInstallFailed,e.browserCloakInstalled,n,M,T,C]),P=(0,Y.useCallback)(async()=>{if(_!==`pending`){d({type:`patch`,patch:{openStatus:`pending`,openMessage:null}});try{let t=await o();d({type:`patch`,patch:{openStatus:`ok`,openMessage:t.reused?e.browserCloakOpenReused.replace(`{{port}}`,String(t.port)):e.browserCloakOpenLaunched.replace(`{{port}}`,String(t.port)),runtime:t}})}catch(e){d({type:`patch`,patch:{openStatus:`error`,openMessage:e instanceof Error?e.message:String(e)}})}}},[o,e.browserCloakOpenLaunched,e.browserCloakOpenReused,_]),F=t.kind===`loading`?`checking`:t.kind===`error`?`error`:O?`ready`:`not_installed`,L=O&&D?.version?`v${D.version} (${D.platform})`:void 0;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Fe,{icon:W,title:e.browserCloakGuideTitle,description:e.browserCloakGuideDesc,status:F,statusDetail:L,m:e,embedded:l,primaryAction:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[O?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:_===`pending`,onClick:()=>void P(),children:[_===`pending`?(0,Z.jsx)(G,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(g,{className:`size-3.5`}),_===`pending`?e.browserCloakOpening:e.browserCloakOpen]}):null,(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:A,onClick:()=>d({type:`patch`,patch:{confirmOpen:!0}}),children:[A?(0,Z.jsx)(G,{className:`size-3.5 animate-spin`}):O?(0,Z.jsx)(h,{className:`size-3.5`}):p===`installed`?(0,Z.jsx)(I,{className:`size-3.5 text-green-500`}):(0,Z.jsx)(k,{className:`size-3.5`}),A?e.browserCloakInstalling:O?e.browserReinstall:e.browserCloakDownload]})]}),children:[x?(0,Z.jsx)(Ve,{m:e,progress:b,cancelling:S,onCancel:()=>void E()}):null,m?(0,Z.jsx)(Le,{kind:p===`failed`?`error`:`success`,message:m}):null,v?(0,Z.jsx)(Le,{kind:_===`error`?`error`:`success`,message:v}):null,O&&y?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base p-3 shadow-surface`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:y.running?e.browserCloakRuntimeRunning.replace(`{{port}}`,String(y.port)):e.browserCloakRuntimeOff})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Z.jsx)(`span`,{className:`text-fg-subtle`,children:e.browserCloakProfileLabel}),(0,Z.jsx)(`span`,{className:`break-all font-mono text-[11px] text-fg-muted`,children:y.userDataDir})]}),(0,Z.jsx)(`p`,{className:`text-[11px] leading-relaxed text-fg-subtle`,children:e.browserCloakProfileAgentHint}),y.temporaryProfile?(0,Z.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:e.browserCloakTemporaryProfileHint}):null]}):null,(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)(Q,{label:e.label.browserCloakKeepOpen,description:e.desc.browserCloakKeepOpen,children:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:s.keepOpen,onChange:e=>c({keepOpen:e.target.checked})}),(0,Z.jsx)(`span`,{children:e.browserCloakKeepOpenOn})]})}),(0,Z.jsx)(Q,{label:e.label.browserCloakTemporaryProfile,description:e.desc.browserCloakTemporaryProfile,children:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:s.temporaryProfile,onChange:e=>c({temporaryProfile:e.target.checked})}),(0,Z.jsx)(`span`,{children:e.browserCloakTemporaryProfileOn})]})}),(0,Z.jsx)(Q,{label:e.label.browserHumanize,description:e.desc.browserHumanize,children:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:s.humanize,onChange:e=>c({humanize:e.target.checked})}),(0,Z.jsx)(`span`,{children:e.browserHumanizeOn})]})}),(0,Z.jsx)(Q,{label:e.label.browserHumanPreset,description:e.desc.browserHumanPreset,children:(0,Z.jsxs)(U,{className:ue(),value:s.humanPreset,onChange:e=>c({humanPreset:e.target.value}),children:[(0,Z.jsx)(j,{value:`careful`,children:e.browserHumanPresetCareful}),(0,Z.jsx)(j,{value:`default`,children:e.browserHumanPresetDefault})]})})]})]}),(0,Z.jsxs)(q,{className:`mt-4`,children:[(0,Z.jsx)(ce,{icon:W,title:e.browserCloakAdvancedShow}),(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsxs)(Q,{label:e.label.browserCloakCacheDir,description:e.desc.browserCloakCacheDir,children:[(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.cacheDir,placeholder:`~/.xopc/bin/cloakbrowser`,onChange:e=>c({cacheDir:e.target.value}),autoComplete:`off`}),(0,Z.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:e.browserCacheDirHomeOnly})]}),(0,Z.jsxs)(Q,{label:e.label.browserCloakBinaryPath,description:e.desc.browserCloakBinaryPath,children:[(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.binaryPath,placeholder:`~/.xopc/bin/cloakbrowser/chromium-v.../Chromium.app/Contents/MacOS/Chromium`,onChange:e=>c({binaryPath:e.target.value}),autoComplete:`off`}),s.binaryPath.trim()?(0,Z.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:e.browserBinaryPathWarning}):null]}),(0,Z.jsx)(Q,{label:e.label.browserCloakTimezone,description:e.desc.browserCloakTimezone,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.timezone,placeholder:`America/New_York`,onChange:e=>c({timezone:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(Q,{label:e.label.browserCloakLocale,description:e.desc.browserCloakLocale,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.locale,placeholder:`en-US`,onChange:e=>c({locale:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(Q,{label:e.label.browserCloakWebrtcIp,description:e.desc.browserCloakWebrtcIp,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.webrtcIp,placeholder:`203.0.113.10`,onChange:e=>c({webrtcIp:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(Q,{label:e.label.browserCloakFingerprintPlatform,description:e.desc.browserCloakFingerprintPlatform,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.fingerprintPlatform,placeholder:`macos`,onChange:e=>c({fingerprintPlatform:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(`div`,{className:`sm:col-span-2`,children:(0,Z.jsx)(Q,{label:e.label.browserCloakExtraArgs,description:e.desc.browserCloakExtraArgs,children:(0,Z.jsx)(`textarea`,{className:Ge(),value:s.extraArgs,placeholder:`--disable-dev-shm-usage`,rows:3,onChange:e=>c({extraArgs:e.target.value})})})})]})]}),(0,Z.jsx)(te,{open:f,title:e.browserConfirmDownloadTitle,description:Ke(e,D),confirmLabel:e.browserConfirmDownloadConfirm,cancelLabel:e.browserConfirmDownloadCancel,onConfirm:()=>void N(),onCancel:()=>d({type:`patch`,patch:{confirmOpen:!1}})})]})}function Ge(){return`${J()} min-h-[4.5rem] resize-y font-mono text-xs`}function Ke(e,t){if(!t)return e.browserConfirmDownloadBody;let n=[e.browserConfirmDownloadBody.replace(`{{version}}`,t.version??`—`).replace(`{{platform}}`,t.platform).replace(`{{url}}`,t.downloadUrl||`—`)];return t.expectedSha256?n.push(`SHA-256: ${t.expectedSha256.slice(0,16)}…`):n.push(e.browserCloakSha256Skipped),n.join(`
2
+ `)}function qe({m:e,form:t,onChange:n,testCloud:r,embedded:i=!1}){let[a,o]=(0,Y.useState)(`idle`),[c,u]=(0,Y.useState)(null),d=t.provider===`local`?`browserbase`:t.provider,f=s(l(e=>e.language)).providersSettings,p=O({show:f.show,hide:f.hide,copy:f.copy,copied:f.copied}),m=(0,Y.useCallback)(()=>fe().then(e=>e.apiKey??null),[]),h=(0,Y.useCallback)(async()=>{o(`pending`),u(null);try{let n=await r(d,t.apiKey);n.reachable?(o(`ok`),u(e.browserCloudTestOk)):(o(`error`),u(e.browserCloudTestFailed.replace(`{{error}}`,n.error??`—`)))}catch(t){o(`error`),u(e.browserCloudTestFailed.replace(`{{error}}`,t instanceof Error?t.message:String(t)))}},[t.apiKey,e.browserCloudTestFailed,e.browserCloudTestOk,d,r]);return(0,Z.jsxs)(Fe,{icon:K,title:e.label.browserCloudProvider,description:e.desc.browserCloudProvider,m:e,embedded:i,primaryAction:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:a===`pending`,onClick:()=>void h(),children:[a===`pending`?(0,Z.jsx)(G,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(T,{className:`size-3.5`}),e.browserCloudTestConnection]}),children:[(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)(Q,{label:e.label.browserCloudProvider,description:e.desc.browserCloudProvider,children:(0,Z.jsxs)(U,{className:ue(),value:d,onChange:e=>n({provider:e.target.value}),children:[(0,Z.jsx)(j,{value:`browserbase`,children:e.browserCloudProviderBrowserbase}),(0,Z.jsx)(j,{value:`browser-use`,children:e.browserCloudProviderBrowserUse})]})}),(0,Z.jsx)(Q,{label:e.label.browserCloudApiKey,description:e.desc.browserCloudApiKey,children:(0,Z.jsx)(ne,{value:t.apiKey,onChange:e=>n({apiKey:e}),placeholder:d===`browserbase`?`BROWSERBASE_API_KEY`:`BROWSER_USE_API_KEY`,labels:p,reveal:m,loadFailedLabel:`Failed to load key`})}),d===`browserbase`?(0,Z.jsx)(Q,{label:e.label.browserCloudProjectId,description:e.desc.browserCloudProjectId,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:t.projectId,placeholder:`BROWSERBASE_PROJECT_ID`,onChange:e=>n({projectId:e.target.value}),autoComplete:`off`})}):null,(0,Z.jsx)(Q,{label:e.label.browserCloudRegion,description:e.desc.browserCloudRegion,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:t.region,placeholder:`us-west-2`,onChange:e=>n({region:e.target.value}),autoComplete:`off`})})]}),c?(0,Z.jsx)(Le,{kind:a===`error`?`error`:`success`,message:c}):null]})}function Je(e){let t=(0,X.c)(48),{m:n,installed:r,extensionDir:i,connected:o,busy:s,onOpenChrome:c,onCopyPath:l,onRevealFolder:u,pathBusy:d,folderBusy:f}=e,p;t[0]!==r||t[1]!==n.browserExtensionInstallStep1?(p={id:`install`,label:n.browserExtensionInstallStep1,done:r},t[0]=r,t[1]=n.browserExtensionInstallStep1,t[2]=p):p=t[2];let m=!!i&&o,h;t[3]!==s||t[4]!==i||t[5]!==f||t[6]!==n.browserExtensionCopyPath||t[7]!==n.browserExtensionInstallStep2FolderLabel||t[8]!==n.browserExtensionInstalling||t[9]!==n.browserExtensionOpenChrome||t[10]!==n.browserExtensionRevealFolder||t[11]!==l||t[12]!==c||t[13]!==u||t[14]!==d?(h=i?(0,Z.jsxs)(`div`,{className:`mt-2 rounded-md bg-surface-raised px-2.5 py-2 shadow-surface`,children:[(0,Z.jsx)(`p`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:n.browserExtensionInstallStep2FolderLabel}),(0,Z.jsx)(`p`,{className:`mt-1 break-all font-mono text-[11px] text-fg`,children:i}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-3`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:s,onClick:c,children:n.browserExtensionOpenChrome}),(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:s,onClick:l,title:i,children:d?n.browserExtensionInstalling:n.browserExtensionCopyPath}),(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:s,onClick:u,title:i,children:f?n.browserExtensionInstalling:n.browserExtensionRevealFolder})]})]}):null,t[3]=s,t[4]=i,t[5]=f,t[6]=n.browserExtensionCopyPath,t[7]=n.browserExtensionInstallStep2FolderLabel,t[8]=n.browserExtensionInstalling,t[9]=n.browserExtensionOpenChrome,t[10]=n.browserExtensionRevealFolder,t[11]=l,t[12]=c,t[13]=u,t[14]=d,t[15]=h):h=t[15];let g;t[16]!==n.browserExtensionInstallStep2||t[17]!==m||t[18]!==h?(g={id:`load`,label:n.browserExtensionInstallStep2,done:m,detail:h},t[16]=n.browserExtensionInstallStep2,t[17]=m,t[18]=h,t[19]=g):g=t[19];let _;t[20]!==o||t[21]!==n.browserExtensionInstallStep3?(_={id:`connect`,label:n.browserExtensionInstallStep3,done:o},t[20]=o,t[21]=n.browserExtensionInstallStep3,t[22]=_):_=t[22];let v;t[23]!==p||t[24]!==g||t[25]!==_?(v=[p,g,_],t[23]=p,t[24]=g,t[25]=_,t[26]=v):v=t[26];let y=v,b;t[27]===y?b=t[28]:(b=y.filter(Ye),t[27]=y,t[28]=b);let x=b.length,S=n.browserExtensionInstallGuideTitle,C;t[29]===n.browserExtensionInstallGuideTitle?C=t[30]:(C=(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:n.browserExtensionInstallGuideTitle}),t[29]=n.browserExtensionInstallGuideTitle,t[30]=C);let w;t[31]!==x||t[32]!==n.browserExtensionChecklistProgress||t[33]!==y.length?(w=n.browserExtensionChecklistProgress.replace(`{{done}}`,String(x)).replace(`{{total}}`,String(y.length)),t[31]=x,t[32]=n.browserExtensionChecklistProgress,t[33]=y.length,t[34]=w):w=t[34];let T;t[35]===w?T=t[36]:(T=(0,Z.jsx)(`span`,{className:`ml-auto text-xs font-normal text-fg-muted`,children:w}),t[35]=w,t[36]=T);let E;t[37]!==T||t[38]!==C?(E=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[C,T]}),t[37]=T,t[38]=C,t[39]=E):E=t[39];let D;t[40]!==n.browserExtensionChecklistDone||t[41]!==n.browserExtensionChecklistPending||t[42]!==y?(D=(0,Z.jsx)(`ol`,{className:`flex flex-col gap-3`,children:y.map((e,t)=>(0,Z.jsxs)(`li`,{className:`flex gap-2.5`,children:[(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0`,"aria-hidden":!0,children:e.done?(0,Z.jsx)(I,{className:`size-4 text-emerald-500`,strokeWidth:2}):(0,Z.jsx)(M,{className:`size-4 text-fg-subtle`,strokeWidth:1.75})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`p`,{className:a(`text-[11px] leading-relaxed`,e.done?`text-fg-muted line-through decoration-fg-subtle/60`:`text-fg`),children:[(0,Z.jsxs)(`span`,{className:`sr-only`,children:[e.done?n.browserExtensionChecklistDone:n.browserExtensionChecklistPending,` `]}),t+1,`. `,e.label]}),e.detail]})]},e.id))}),t[40]=n.browserExtensionChecklistDone,t[41]=n.browserExtensionChecklistPending,t[42]=y,t[43]=D):D=t[43];let O;return t[44]!==n.browserExtensionInstallGuideTitle||t[45]!==E||t[46]!==D?(O=(0,Z.jsxs)(`div`,{"aria-label":S,className:`rounded-xl bg-surface-base p-3`,children:[E,D]}),t[44]=n.browserExtensionInstallGuideTitle,t[45]=E,t[46]=D,t[47]=O):O=t[47],O}function Ye(e){return e.done}var Xe=19820,Ze=3e4;function Qe({m:e,probe:t,artifacts:n,onChange:r,startBridge:i,stopBridge:a,disconnectExtension:s,installArtifacts:c,refetchArtifacts:l,openExtensionChrome:u,revealExtensionFolder:d,form:f,embedded:p=!1}){let[h,v]=(0,Y.useState)(null),[y,b]=(0,Y.useState)(null),[S,C]=(0,Y.useState)(null),w=f.port??Xe,E=f.host||`127.0.0.1`,D=`ws://${E}:${w}/browser-ext`,O=t.kind===`ok`&&t.data.running,A=t.kind===`ok`&&t.data.connected,j=t.kind===`ok`&&t.data.bridgeHeld===!0,M=t.kind===`ok`&&t.data.portConflict===!0,N=O||j,P=n.kind===`ok`?n.data:t.kind===`ok`?t.data.artifacts:void 0,F=P?.installed===!0,I=P?.extensionDir,L=P?.needsChromeReload===!0,R=t.kind===`ok`?A?{icon:_,color:`text-green-500`,label:e.browserExtensionConnected}:O?{icon:T,color:`text-amber-500`,label:e.browserExtensionWaiting}:{icon:x,color:`text-fg-muted`,label:e.browserExtensionServerOff}:{icon:x,color:`text-fg-muted`,label:`…`},z=R.icon,B=(0,Y.useCallback)(async()=>{if(!h){v(`start`),b(null);try{await i({host:E,port:w})}catch(e){b(e instanceof Error?e.message:String(e))}finally{v(null)}}},[h,E,w,i]),V=(0,Y.useCallback)(async()=>{if(!h){v(`stop`),b(null);try{await a()}catch(e){b(e instanceof Error?e.message:String(e))}finally{v(null)}}},[h,a]),U=(0,Y.useCallback)(async()=>{if(!h){v(`disconnect`),b(null);try{await s()}catch(e){b(e instanceof Error?e.message:String(e))}finally{v(null)}}},[h,s]),W=(0,Y.useCallback)(async()=>{if(!h){v(`install`),b(null),C(null);try{let t=await c({force:F});t?.extensionDir?C(`${e.browserExtensionInstalled}: ${t.extensionDir}`):C(e.browserExtensionInstalled),await l()}catch(e){b(e instanceof Error?e.message:String(e))}finally{v(null)}}},[h,c,F,e.browserExtensionInstalled,l]),K=(0,Y.useCallback)(async()=>{if(!h){v(`open`),b(null);try{await u()}catch(e){b(e instanceof Error?e.message:String(e))}finally{v(null)}}},[h,u]),ee=(0,Y.useCallback)(async()=>{if(!(!I||h)){v(`path`),b(null),C(null);try{await o(I)?C(e.browserExtensionPathCopied):C(e.browserExtensionPathCopyFailed)}catch(e){b(e instanceof Error?e.message:String(e))}finally{v(null)}}},[h,I,e.browserExtensionPathCopied,e.browserExtensionPathCopyFailed]),te=(0,Y.useCallback)(async()=>{if(!(!I||h)){v(`folder`),b(null),C(null);try{await d(),C(e.browserExtensionFolderOpened)}catch(e){b(e instanceof Error?e.message:String(e))}finally{v(null)}}},[h,I,e.browserExtensionFolderOpened,d]),ne=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:h!==null,onClick:()=>void W(),children:[h===`install`?(0,Z.jsx)(G,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(k,{className:`size-3.5`}),h===`install`?e.browserExtensionInstalling:e.browserExtensionInstall]}),N?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:h!==null,onClick:()=>void V(),children:[h===`stop`?(0,Z.jsx)(G,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(H,{className:`size-3.5`}),e.browserExtensionStopBridge]}):(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:h!==null,onClick:()=>void B(),children:[h===`start`?(0,Z.jsx)(G,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(g,{className:`size-3.5`}),h===`start`?e.browserExtensionStarting:e.browserExtensionStartBridge]}),A?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:h!==null,onClick:()=>void U(),children:[h===`disconnect`?(0,Z.jsx)(G,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(x,{className:`size-3.5`}),e.browserExtensionDisconnect]}):null]});return(0,Z.jsx)(Fe,{icon:m,title:e.browserBackendExtension,description:e.browserExtensionDownloadHint,m:e,embedded:p,primaryAction:ne,advancedTitle:e.browserAdvancedShow,advanced:(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)(Q,{label:e.label.browserExtensionPort,description:e.desc.browserExtensionPort,children:(0,Z.jsx)(`input`,{type:`number`,className:J(),min:1024,max:65535,value:f.port??``,placeholder:String(Xe),onChange:e=>{let t=e.target.value;r({port:t===``?void 0:Number.parseInt(t,10)})}})}),(0,Z.jsx)(Q,{label:e.label.browserExtensionHost,description:e.desc.browserExtensionHost,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:f.host,placeholder:`127.0.0.1`,onChange:e=>r({host:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(Q,{label:e.label.browserExtensionConnectionTimeout,description:e.desc.browserExtensionConnectionTimeout,children:(0,Z.jsx)(`input`,{type:`number`,className:J(),min:1,step:1,value:f.connectionTimeoutMs==null?``:Math.round(f.connectionTimeoutMs/1e3),placeholder:String(Ze/1e3),onChange:e=>{let t=e.target.value;r({connectionTimeoutMs:t===``?void 0:Math.max(1,Number.parseInt(t,10))*1e3})}})})]}),children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:D}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs ${R.color}`,children:[(0,Z.jsx)(z,{className:`size-3.5`}),(0,Z.jsx)(`span`,{children:R.label})]})]}),(0,Z.jsx)(Je,{m:e,installed:F,extensionDir:I,connected:A,busy:h!==null,pathBusy:h===`path`,folderBusy:h===`folder`,onOpenChrome:()=>void K(),onCopyPath:()=>void ee(),onRevealFolder:()=>void te()}),L?(0,Z.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-relaxed text-amber-800 dark:text-amber-200`,children:e.browserExtensionNeedsChromeReload}):null,M?(0,Z.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-relaxed text-amber-800 dark:text-amber-200`,children:e.browserExtensionPortConflict.replace(`{{port}}`,String(w))}):null,S?(0,Z.jsx)(Le,{kind:`success`,message:S}):null,y?(0,Z.jsx)(Le,{kind:`error`,message:y}):null]})})}function $e(e){let t=(0,X.c)(41),{m:n,doctor:r,refetch:i,applyDoctor:a,installStream:o,embedded:s}=e,c=s===void 0?!1:s,[l,u]=(0,Y.useState)(`idle`),[d,f]=(0,Y.useState)(null),{progress:p,running:m,cancelling:g,run:_,reset:y,cancel:b}=o,x;t[0]!==a||t[1]!==n.browserPlaywrightInstallFailed||t[2]!==n.browserPlaywrightInstalled||t[3]!==i||t[4]!==y||t[5]!==_?(x=async()=>{u(`installing`),f(null),y();let e=await _({fallbackError:n.browserPlaywrightInstallFailed});if(!e.ok){if(e.error===`busy`){u(`installing`);return}if(e.error===`cancelled`){u(`idle`),f(null),y();return}u(`failed`),f(e.errorMessage??n.browserPlaywrightInstallFailed);return}e.payload&&a?.(e.payload),u(`installed`),f(e.payload?.executablePath?`${n.browserPlaywrightInstalled}: ${e.payload.executablePath}`:n.browserPlaywrightInstalled),await i()},t[0]=a,t[1]=n.browserPlaywrightInstallFailed,t[2]=n.browserPlaywrightInstalled,t[3]=i,t[4]=y,t[5]=_,t[6]=x):x=t[6];let S=x,C=r.kind===`loading`?`checking`:r.kind===`error`?`error`:r.kind===`ok`?r.data.installed?`ready`:`not_installed`:`unknown`,w=r.kind===`ok`&&r.data.installed&&r.data.executablePath?r.data.executablePath:void 0,T=r.kind===`ok`&&r.data.installed,E=l===`installing`||m,D;t[7]===S?D=t[8]:(D=()=>void S(),t[7]=S,t[8]=D);let O;t[9]!==T||t[10]!==E||t[11]!==l?(O=E?(0,Z.jsx)(G,{className:`size-3.5 animate-spin`}):T?(0,Z.jsx)(h,{className:`size-3.5`}):l===`installed`?(0,Z.jsx)(I,{className:`size-3.5 text-green-500`}):(0,Z.jsx)(k,{className:`size-3.5`}),t[9]=T,t[10]=E,t[11]=l,t[12]=O):O=t[12];let A=E?n.browserPlaywrightInstalling:T?n.browserReinstall:n.browserPlaywrightInstall,j;t[13]!==E||t[14]!==D||t[15]!==O||t[16]!==A?(j=(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:E,onClick:D,children:[O,A]}),t[13]=E,t[14]=D,t[15]=O,t[16]=A,t[17]=j):j=t[17];let M;t[18]===n.browserPlaywrightManualInstall?M=t[19]:(M=(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:n.browserPlaywrightManualInstall}),t[18]=n.browserPlaywrightManualInstall,t[19]=M);let N;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(`code`,{className:`mt-2 block w-fit rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg`,children:`node node_modules/playwright-core/cli.js install chromium`}),t[20]=N):N=t[20];let P;t[21]===M?P=t[22]:(P=(0,Z.jsxs)(`div`,{className:`text-xs`,children:[M,N]}),t[21]=M,t[22]=P);let F;t[23]!==b||t[24]!==g||t[25]!==n||t[26]!==p||t[27]!==m?(F=m?(0,Z.jsx)(Ve,{m:n,progress:p,showLogs:!0,cancelling:g,onCancel:()=>void b()}):null,t[23]=b,t[24]=g,t[25]=n,t[26]=p,t[27]=m,t[28]=F):F=t[28];let L;t[29]!==d||t[30]!==l?(L=d?(0,Z.jsx)(Le,{kind:l===`failed`?`error`:`success`,message:d}):null,t[29]=d,t[30]=l,t[31]=L):L=t[31];let R;return t[32]!==c||t[33]!==n||t[34]!==w||t[35]!==C||t[36]!==F||t[37]!==L||t[38]!==j||t[39]!==P?(R=(0,Z.jsxs)(Fe,{icon:v,title:n.browserPlaywrightGuideTitle,description:n.browserPlaywrightGuideDesc,status:C,statusDetail:w,m:n,embedded:c,primaryAction:j,children:[P,F,L]}),t[32]=c,t[33]=n,t[34]=w,t[35]=C,t[36]=F,t[37]=L,t[38]=j,t[39]=P,t[40]=R):R=t[40],R}async function et(e){let t=await u(e),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1){let e=typeof n.error==`string`?n.error:n.error?.message;throw Error(e||`Request failed: ${t.status}`)}if(n.payload===void 0)throw Error(`Empty payload`);return n.payload}async function $(e,t){let n=await u(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})}),r=await n.json().catch(()=>({}));if(!n.ok||r.ok===!1){let e=typeof r.error==`string`?r.error:r.error?.message;throw Error(e||`Request failed: ${n.status}`)}if(r.payload===void 0)throw Error(`Empty payload`);return r.payload}var tt={playwright:{kind:`idle`},cloak:{kind:`idle`},extension:{kind:`idle`},extensionArtifacts:{kind:`idle`}};function nt(e,t){switch(t.type){case`playwright`:return{...e,playwright:t.state};case`cloak`:return{...e,cloak:t.state};case`extension`:return{...e,extension:t.state};case`extension-artifacts`:return{...e,extensionArtifacts:t.state};case`playwright-idle`:return{...e,playwright:{kind:`idle`}};case`cloak-idle`:return{...e,cloak:{kind:`idle`}};case`extension-idle`:return{...e,extension:{kind:`idle`},extensionArtifacts:{kind:`idle`}};case`extension-start-probe`:return{...e,extension:e.extension.kind===`ok`?e.extension:{kind:`loading`}};case`extension-artifacts-start-probe`:return{...e,extensionArtifacts:e.extensionArtifacts.kind===`ok`?e.extensionArtifacts:{kind:`loading`}}}}function rt(e){let[t,n]=(0,Y.useReducer)(nt,tt),{playwright:r,cloak:i,extension:a,extensionArtifacts:o}=t,s=(0,Y.useCallback)(async()=>{n({type:`playwright`,state:{kind:`loading`}});try{n({type:`playwright`,state:{kind:`ok`,data:await et(d(`/api/browser/playwright/doctor`))}})}catch(e){n({type:`playwright`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}})}},[]),c=(0,Y.useCallback)(async t=>{n({type:`cloak`,state:{kind:`loading`}});let r=(t?.cacheDir??e.cacheDir??``).trim(),i=(t?.binaryPath??e.binaryPath??``).trim(),a=new URLSearchParams;r&&a.set(`cacheDir`,r),i&&a.set(`binaryPath`,i);try{let e=await et(d(`/api/browser/cloakbrowser/doctor${a.size?`?${a}`:``}`));return n({type:`cloak`,state:{kind:`ok`,data:e}}),e}catch(e){return n({type:`cloak`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}}),null}},[e.binaryPath,e.cacheDir]),l=(0,Y.useCallback)(e=>{n({type:`playwright`,state:{kind:`ok`,data:e}})},[]),f=(0,Y.useCallback)(e=>{n({type:`cloak`,state:{kind:`ok`,data:e}})},[]),p=(0,Y.useCallback)(async()=>et(d(`/api/browser/cloakbrowser/status`)),[]),m=(0,Y.useCallback)(async()=>$(d(`/api/browser/cloakbrowser/launch`),{}),[]),h=e.browserEnabled===!0&&e.probeExtension===!0,g=e.browserEnabled===!0&&e.probeLocal===!0,_=e.browserEnabled===!0&&e.probeCloak===!0,{extensionHost:v,extensionPort:y}=e,b=(0,Y.useCallback)(async()=>{let e=new URLSearchParams({probe:`1`});v&&e.set(`host`,v),y!==void 0&&e.set(`port`,String(y)),n({type:`extension-start-probe`});try{let t=await u(d(`/api/browser/extension-status?${e}`),{signal:AbortSignal.timeout(3e3)}),r=await t.json().catch(()=>({}));if(!t.ok){n({type:`extension`,state:{kind:`error`,message:`HTTP ${t.status}`}});return}n({type:`extension`,state:{kind:`ok`,data:{running:r.running===!0,connected:r.connected===!0,backend:r.backend,artifacts:r.artifacts,bridgeHeld:r.bridgeHeld===!0,refCount:typeof r.refCount==`number`?r.refCount:void 0,manualBridge:r.manualBridge===!0,portConflict:r.portConflict===!0}}})}catch(e){n({type:`extension`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}})}},[v,y]),x=(0,Y.useCallback)(async()=>{n({type:`extension-artifacts-start-probe`});try{let e=await et(d(`/api/browser/extension/doctor`));return n({type:`extension-artifacts`,state:{kind:`ok`,data:e}}),e}catch(e){return n({type:`extension-artifacts`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}}),null}},[]),S=(0,Y.useCallback)(async e=>{let t=(await $(d(`/api/browser/extension/install`),{force:e?.force??!1})).doctor;return n({type:`extension-artifacts`,state:{kind:`ok`,data:t}}),await b(),t},[b]),C=(0,Y.useCallback)(async()=>{await $(d(`/api/browser/extension/open`),{action:`chrome`})},[]),w=(0,Y.useCallback)(async()=>{await $(d(`/api/browser/extension/open`),{action:`folder`})},[]);(0,Y.useEffect)(()=>{if(!g){n({type:`playwright-idle`});return}s()},[g,s]),(0,Y.useEffect)(()=>{if(!_){n({type:`cloak-idle`});return}c()},[_,c]);let T=(0,Y.useRef)(h);T.current!==h&&(T.current=h,h||n({type:`extension-idle`})),(0,Y.useEffect)(()=>{if(!h)return;b(),x();let e=setInterval(()=>void b(),5e3);return()=>clearInterval(e)},[h,b,x]);let E=(0,Y.useCallback)(async e=>{await $(d(`/api/browser/extension/start`),{host:e?.host??v,port:e?.port??y}),await b()},[v,y,b]),D=(0,Y.useCallback)(async()=>{await $(d(`/api/browser/extension/stop`),{}),await b()},[b]),O=(0,Y.useCallback)(async()=>{await $(d(`/api/browser/extension/disconnect`),{}),await b()},[b]),k=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{if(!h||e.activeBackend!==`extension`){k.current=null;return}if(a.kind!==`ok`||a.data.running||a.data.bridgeHeld)return;let t=`${v}:${y??19820}`;k.current!==t&&(k.current=t,E({host:v,port:y}).catch(()=>{k.current=null}))},[h,a,v,y,e.activeBackend,E]),{playwright:r,cloak:i,extension:a,extensionArtifacts:o,refetchPlaywright:s,applyPlaywrightDoctor:l,refetchCloak:c,applyCloakDoctor:f,fetchCloakRuntimeStatus:p,launchCloak:m,refetchExtension:b,refetchExtensionArtifacts:x,installExtensionArtifacts:S,openExtensionChrome:C,revealExtensionFolder:w,pingCdp:(0,Y.useCallback)(async e=>$(d(`/api/browser/cdp/ping`),{cdpUrl:e}),[]),testCloud:(0,Y.useCallback)(async(e,t)=>$(d(`/api/browser/cloud/test-connection`),{provider:e,apiKey:t}),[]),launchCdp:(0,Y.useCallback)(async e=>$(d(`/api/browser/cdp/launch`),{executablePath:e}),[]),stopCdp:(0,Y.useCallback)(async e=>{await $(d(`/api/browser/cdp/stop`),{port:e})},[]),listCdpInstances:(0,Y.useCallback)(async()=>(await et(d(`/api/browser/cdp/instances`))).instances,[]),startExtensionBridge:E,stopExtensionBridge:D,disconnectExtension:O}}var it=`
3
+
4
+ `,at=/\r\n/g,ot={playwright:`/api/browser/playwright/install/stream`,cloakbrowser:`/api/browser/cloakbrowser/install/stream`},st={playwright:`/api/browser/playwright/install/cancel`,cloakbrowser:`/api/browser/cloakbrowser/install/cancel`},ct=8;function lt(){return{phase:null,message:null,percent:null,lines:[]}}function ut(e,t){let n={phase:t.phase,message:t.message??t.line??e.message,percent:t.percent??e.percent,lines:e.lines};if(t.line){let r=[...e.lines,t.line];n.lines=r.length>ct?r.slice(-8):r}return n}async function dt(e,t,n){let r=e.getReader(),i=new TextDecoder,a=``,o=null,s=e=>{let n=``,r=``;for(let t of e.split(`
5
+ `)){let e=t.replace(/\r$/,``);e.startsWith(`event:`)?n=e.slice(6).trim():e.startsWith(`data:`)&&(r+=e.slice(5).trimStart())}if(r){if(n===`progress`){try{let e=JSON.parse(r);e&&typeof e==`object`&&typeof e.phase==`string`&&t(e)}catch{}return}if(n===`result`)try{let e=JSON.parse(r);o=e.ok?{ok:!0,payload:e.payload}:{ok:!1,error:String(e.error??`unknown`),message:typeof e.message==`string`?e.message:void 0,status:e.error===`busy`?409:e.error===`cancelled`?499:500}}catch{o={ok:!1,error:`parse`,status:0}}}};try{let e=async()=>{if(o!==null)return o;if(n?.aborted)return await r.cancel().catch(()=>{}),{ok:!1,error:`cancelled`,status:499};let{done:t,value:c}=await r.read();if(t)return o??{ok:!1,error:`no-result`,status:0};a+=i.decode(c,{stream:!0}),a=a.replace(at,`
6
+ `);let l=a.split(it);a=l.pop()??``;for(let e of l)e.length&&s(e);return e()},t=await e();if(t)return t}catch(e){if(n?.aborted||e instanceof DOMException&&e.name===`AbortError`)return{ok:!1,error:`cancelled`,status:499};throw e}finally{r.releaseLock()}return o||(n?.aborted?{ok:!1,error:`cancelled`,status:499}:{ok:!1,error:`no-result`,status:0})}function ft(e){let[t,n]=(0,Y.useState)(lt),[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(!1),s=(0,Y.useRef)(!1),c=(0,Y.useRef)(null),l=(0,Y.useCallback)(()=>{s.current||n(lt())},[]),f=(0,Y.useCallback)(async()=>{if(s.current){o(!0);try{await u(d(st[e]),{method:`POST`}).catch(()=>{}),c.current?.abort()}finally{o(!1)}}},[e]);return{progress:t,running:r,cancelling:a,run:(0,Y.useCallback)(async t=>{if(s.current)return{ok:!1,error:`busy`,status:409,errorMessage:`An install for this browser type is already in progress.`};let r=new AbortController;c.current=r,s.current=!0,i(!0),n(lt());try{let i=await u(d(ot[e]),{method:`POST`,headers:{Accept:`text/event-stream`,...t.body===void 0?{}:{"Content-Type":`application/json`}},body:t.body===void 0?void 0:JSON.stringify(t.body),signal:r.signal});if(!i.ok||!i.body){let e=await i.text().catch(()=>``),t=`HTTP ${i.status}`;try{let n=JSON.parse(e);typeof n.message==`string`?t=n.message:typeof n.error==`string`&&(t=n.error)}catch{e&&(t=e.slice(0,500))}return{ok:!1,error:i.status===409?`busy`:`http`,status:i.status,errorMessage:t}}let a=await dt(i.body,e=>{n(t=>ut(t,e))},r.signal);return a.ok?a:a.error===`cancelled`?{...a,errorMessage:void 0}:{...a,errorMessage:a.message??(a.error===`busy`?`An install for this browser type is already in progress.`:t.fallbackError)}}catch(e){return r.signal.aborted||e instanceof DOMException&&e.name===`AbortError`?{ok:!1,error:`cancelled`,status:499}:{ok:!1,error:`network`,errorMessage:e instanceof Error?e.message:t.fallbackError}}finally{c.current===r&&(c.current=null),s.current=!1,i(!1),o(!1)}},[e]),reset:l,cancel:f}}function pt(e){let t=(0,X.c)(150),{a:n,form:r,update:i,activeTab:o,setActiveTab:s}=e,c=l(ht),u=P(mt),d=ft(`playwright`),f=ft(`cloakbrowser`),p=r.browserEnabled&&(o===`overview`||o===`extension`),h=r.browserEnabled&&(o===`overview`||o===`local`),g=r.browserEnabled&&(o===`overview`||o===`cloakbrowser`),_;t[0]!==r.browserBackend||t[1]!==r.browserCloakBinaryPath||t[2]!==r.browserCloakCacheDir||t[3]!==r.browserEnabled||t[4]!==r.browserExtensionHost||t[5]!==r.browserExtensionPort||t[6]!==g||t[7]!==p||t[8]!==h?(_={cacheDir:r.browserCloakCacheDir,binaryPath:r.browserCloakBinaryPath,browserEnabled:r.browserEnabled,activeBackend:r.browserBackend,probeExtension:p,probeLocal:h,probeCloak:g,extensionHost:r.browserExtensionHost,extensionPort:r.browserExtensionPort},t[0]=r.browserBackend,t[1]=r.browserCloakBinaryPath,t[2]=r.browserCloakCacheDir,t[3]=r.browserEnabled,t[4]=r.browserExtensionHost,t[5]=r.browserExtensionPort,t[6]=g,t[7]=p,t[8]=h,t[9]=_):_=t[9];let y=rt(_),b;t[10]===y.playwright?b=t[11]:(b=Ee(y.playwright),t[10]=y.playwright,t[11]=b);let x=b,S;t[12]===y.cloak?S=t[13]:(S=Ee(y.cloak),t[12]=y.cloak,t[13]=S);let C=S,w;t[14]===y.extension?w=t[15]:(w=Oe(y.extension),t[14]=y.extension,t[15]=w);let T=w,E;t[16]!==n||t[17]!==y.extension?(E=ke(y.extension,n),t[16]=n,t[17]=y.extension,t[18]=E):E=t[18];let O=E,k;t[19]!==n||t[20]!==C||t[21]!==T||t[22]!==O||t[23]!==x||t[24]!==u?(k=[{value:`extension`,icon:m,name:n.browserBackendExtension,tagline:n.browserModeExtTagline,status:T,statusLabel:O},{value:`local`,icon:v,name:n.browserBackendLocal,tagline:n.browserModeLocalTagline,status:x,statusLabel:De(x,n)},{value:`cloakbrowser`,icon:W,name:n.browserBackendCloakBrowser,tagline:n.browserModeCloakTagline,status:C,statusLabel:De(C,n)},{value:`cdp`,icon:D,name:n.browserBackendCdp,tagline:n.browserModeCdpTagline},{value:`cloud`,icon:K,name:n.browserBackendCloud,tagline:n.browserModeCloudTagline}].filter(e=>pe(e.value,u)),t[19]=n,t[20]=C,t[21]=T,t[22]=O,t[23]=x,t[24]=u,t[25]=k):k=t[25];let A=k,j;t[26]!==s||t[27]!==i?(j=e=>{i({browserEnabled:!0,browserBackend:e}),s(e)},t[26]=s,t[27]=i,t[28]=j):j=t[28];let M=j,N=!r.browserEnabled&&`pointer-events-none opacity-40`,F;t[29]===N?F=t[30]:(F=a(`flex flex-col gap-5 transition-opacity`,N),t[29]=N,t[30]=F);let I=!r.browserEnabled,R;t[31]!==n||t[32]!==o||t[33]!==y.disconnectExtension||t[34]!==y.extension||t[35]!==y.extensionArtifacts||t[36]!==y.installExtensionArtifacts||t[37]!==y.openExtensionChrome||t[38]!==y.refetchExtensionArtifacts||t[39]!==y.revealExtensionFolder||t[40]!==y.startExtensionBridge||t[41]!==y.stopExtensionBridge||t[42]!==r.browserExtensionConnectionTimeout||t[43]!==r.browserExtensionHost||t[44]!==r.browserExtensionPort||t[45]!==i?(R=o===`extension`?(0,Z.jsx)(q,{children:(0,Z.jsx)(Qe,{embedded:!0,m:n,probe:y.extension,artifacts:y.extensionArtifacts,form:{port:r.browserExtensionPort,host:r.browserExtensionHost,connectionTimeoutMs:r.browserExtensionConnectionTimeout},onChange:e=>i({...e.port===void 0?{}:{browserExtensionPort:e.port},...e.host===void 0?{}:{browserExtensionHost:e.host},...e.connectionTimeoutMs===void 0?{}:{browserExtensionConnectionTimeout:e.connectionTimeoutMs}}),startBridge:y.startExtensionBridge,stopBridge:y.stopExtensionBridge,disconnectExtension:y.disconnectExtension,installArtifacts:y.installExtensionArtifacts,refetchArtifacts:y.refetchExtensionArtifacts,openExtensionChrome:y.openExtensionChrome,revealExtensionFolder:y.revealExtensionFolder})}):null,t[31]=n,t[32]=o,t[33]=y.disconnectExtension,t[34]=y.extension,t[35]=y.extensionArtifacts,t[36]=y.installExtensionArtifacts,t[37]=y.openExtensionChrome,t[38]=y.refetchExtensionArtifacts,t[39]=y.revealExtensionFolder,t[40]=y.startExtensionBridge,t[41]=y.stopExtensionBridge,t[42]=r.browserExtensionConnectionTimeout,t[43]=r.browserExtensionHost,t[44]=r.browserExtensionPort,t[45]=i,t[46]=R):R=t[46];let z;t[47]!==n||t[48]!==o||t[49]!==y.applyPlaywrightDoctor||t[50]!==y.playwright||t[51]!==y.refetchPlaywright||t[52]!==d?(z=o===`local`?(0,Z.jsx)(q,{children:(0,Z.jsx)($e,{embedded:!0,m:n,doctor:y.playwright,refetch:y.refetchPlaywright,applyDoctor:y.applyPlaywrightDoctor,installStream:d})}):null,t[47]=n,t[48]=o,t[49]=y.applyPlaywrightDoctor,t[50]=y.playwright,t[51]=y.refetchPlaywright,t[52]=d,t[53]=z):z=t[53];let B;t[54]!==n||t[55]!==o||t[56]!==f||t[57]!==y.applyCloakDoctor||t[58]!==y.cloak||t[59]!==y.fetchCloakRuntimeStatus||t[60]!==y.launchCloak||t[61]!==y.refetchCloak||t[62]!==r.browserCloakBinaryPath||t[63]!==r.browserCloakCacheDir||t[64]!==r.browserCloakExtraArgs||t[65]!==r.browserCloakFingerprintPlatform||t[66]!==r.browserCloakKeepOpen||t[67]!==r.browserCloakLocale||t[68]!==r.browserCloakTemporaryProfile||t[69]!==r.browserCloakTimezone||t[70]!==r.browserCloakWebrtcIp||t[71]!==r.browserHumanPreset||t[72]!==r.browserHumanize||t[73]!==i?(B=o===`cloakbrowser`?(0,Z.jsx)(q,{children:(0,Z.jsx)(We,{embedded:!0,m:n,doctor:y.cloak,refetch:y.refetchCloak,applyDoctor:y.applyCloakDoctor,installStream:f,fetchRuntimeStatus:y.fetchCloakRuntimeStatus,launchCloak:y.launchCloak,form:{cacheDir:r.browserCloakCacheDir,binaryPath:r.browserCloakBinaryPath,keepOpen:r.browserCloakKeepOpen,temporaryProfile:r.browserCloakTemporaryProfile,humanize:r.browserHumanize,humanPreset:r.browserHumanPreset,timezone:r.browserCloakTimezone,locale:r.browserCloakLocale,webrtcIp:r.browserCloakWebrtcIp,fingerprintPlatform:r.browserCloakFingerprintPlatform,extraArgs:r.browserCloakExtraArgs},onChange:e=>i({...e.cacheDir===void 0?{}:{browserCloakCacheDir:e.cacheDir},...e.binaryPath===void 0?{}:{browserCloakBinaryPath:e.binaryPath},...e.keepOpen===void 0?{}:{browserCloakKeepOpen:e.keepOpen},...e.temporaryProfile===void 0?{}:{browserCloakTemporaryProfile:e.temporaryProfile},...e.humanize===void 0?{}:{browserHumanize:e.humanize},...e.humanPreset===void 0?{}:{browserHumanPreset:e.humanPreset},...e.timezone===void 0?{}:{browserCloakTimezone:e.timezone},...e.locale===void 0?{}:{browserCloakLocale:e.locale},...e.webrtcIp===void 0?{}:{browserCloakWebrtcIp:e.webrtcIp},...e.fingerprintPlatform===void 0?{}:{browserCloakFingerprintPlatform:e.fingerprintPlatform},...e.extraArgs===void 0?{}:{browserCloakExtraArgs:e.extraArgs}})})}):null,t[54]=n,t[55]=o,t[56]=f,t[57]=y.applyCloakDoctor,t[58]=y.cloak,t[59]=y.fetchCloakRuntimeStatus,t[60]=y.launchCloak,t[61]=y.refetchCloak,t[62]=r.browserCloakBinaryPath,t[63]=r.browserCloakCacheDir,t[64]=r.browserCloakExtraArgs,t[65]=r.browserCloakFingerprintPlatform,t[66]=r.browserCloakKeepOpen,t[67]=r.browserCloakLocale,t[68]=r.browserCloakTemporaryProfile,t[69]=r.browserCloakTimezone,t[70]=r.browserCloakWebrtcIp,t[71]=r.browserHumanPreset,t[72]=r.browserHumanize,t[73]=i,t[74]=B):B=t[74];let V;t[75]!==n||t[76]!==o||t[77]!==y.launchCdp||t[78]!==y.listCdpInstances||t[79]!==y.pingCdp||t[80]!==y.stopCdp||t[81]!==r.browserCdpUrl||t[82]!==i?(V=o===`cdp`?(0,Z.jsx)(q,{children:(0,Z.jsx)(ze,{embedded:!0,m:n,cdpUrl:r.browserCdpUrl,onCdpUrlChange:e=>i({browserCdpUrl:e}),launch:y.launchCdp,stop:y.stopCdp,listInstances:y.listCdpInstances,ping:y.pingCdp})}):null,t[75]=n,t[76]=o,t[77]=y.launchCdp,t[78]=y.listCdpInstances,t[79]=y.pingCdp,t[80]=y.stopCdp,t[81]=r.browserCdpUrl,t[82]=i,t[83]=V):V=t[83];let H;t[84]!==n||t[85]!==o||t[86]!==y.testCloud||t[87]!==r.browserCloudApiKey||t[88]!==r.browserCloudProjectId||t[89]!==r.browserCloudProvider||t[90]!==r.browserCloudRegion||t[91]!==i?(H=o===`cloud`?(0,Z.jsx)(q,{children:(0,Z.jsx)(qe,{embedded:!0,m:n,form:{provider:r.browserCloudProvider,apiKey:r.browserCloudApiKey,projectId:r.browserCloudProjectId,region:r.browserCloudRegion},onChange:e=>i({...e.provider===void 0?{}:{browserCloudProvider:e.provider},...e.apiKey===void 0?{}:{browserCloudApiKey:e.apiKey},...e.projectId===void 0?{}:{browserCloudProjectId:e.projectId},...e.region===void 0?{}:{browserCloudRegion:e.region}}),testCloud:y.testCloud})}):null,t[84]=n,t[85]=o,t[86]=y.testCloud,t[87]=r.browserCloudApiKey,t[88]=r.browserCloudProjectId,t[89]=r.browserCloudProvider,t[90]=r.browserCloudRegion,t[91]=i,t[92]=H):H=t[92];let U;t[93]!==R||t[94]!==z||t[95]!==B||t[96]!==V||t[97]!==H||t[98]!==F||t[99]!==I?(U=(0,Z.jsxs)(`div`,{className:F,"aria-hidden":I,children:[R,z,B,V,H]}),t[93]=R,t[94]=z,t[95]=B,t[96]=V,t[97]=H,t[98]=F,t[99]=I,t[100]=U):U=t[100];let G=U;if(o===`overview`){let e;t[101]!==n||t[102]!==r.browserEnabled||t[103]!==M?(e=r.browserEnabled?null:(0,Z.jsx)(we,{m:n,onStart:M}),t[101]=n,t[102]=r.browserEnabled,t[103]=M,t[104]=e):e=t[104];let o;t[105]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,"aria-hidden":!0,children:(0,Z.jsx)(L,{className:`size-4`,strokeWidth:1.75})}),t[105]=o):o=t[105];let l;t[106]===i?l=t[107]:(l=e=>i({browserEnabled:e.target.checked}),t[106]=i,t[107]=l);let u;t[108]!==r.browserEnabled||t[109]!==l?(u=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserEnabled,onChange:l}),t[108]=r.browserEnabled,t[109]=l,t[110]=u):u=t[110];let d;t[111]===n.browserEnabledOn?d=t[112]:(d=(0,Z.jsx)(`span`,{children:n.browserEnabledOn}),t[111]=n.browserEnabledOn,t[112]=d);let f;t[113]!==u||t[114]!==d?(f=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[u,d]}),t[113]=u,t[114]=d,t[115]=f):f=t[115];let p;t[116]!==n.desc.browserEnabled||t[117]!==n.label.browserEnabled||t[118]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3`,children:[o,(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(Q,{label:n.label.browserEnabled,description:n.desc.browserEnabled,children:f})})]}),t[116]=n.desc.browserEnabled,t[117]=n.label.browserEnabled,t[118]=f,t[119]=p):p=t[119];let m;t[120]!==n.browserDocsLink||t[121]!==c?(m=(0,Z.jsx)(Se,{language:c,label:n.browserDocsLink,className:`shrink-0 pt-1`}),t[120]=n.browserDocsLink,t[121]=c,t[122]=m):m=t[122];let h;t[123]!==p||t[124]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[p,m]}),t[123]=p,t[124]=m,t[125]=h):h=t[125];let g;t[126]!==n||t[127]!==r.browserBackend||t[128]!==r.browserEnabled||t[129]!==A||t[130]!==s||t[131]!==i?(g=r.browserEnabled?(0,Z.jsx)(`div`,{id:ye(`connection`),className:a(`scroll-mt-24 transition-opacity`,!r.browserEnabled&&`pointer-events-none opacity-40`),children:(0,Z.jsx)(_e,{m:n,value:r.browserBackend,onChange:e=>i({browserBackend:e}),onOpenConfig:s,options:A})}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.browserDisabledHint}),t[126]=n,t[127]=r.browserBackend,t[128]=r.browserEnabled,t[129]=A,t[130]=s,t[131]=i,t[132]=g):g=t[132];let _;t[133]!==h||t[134]!==g?(_=(0,Z.jsx)(q,{children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[h,g]})}),t[133]=h,t[134]=g,t[135]=_):_=t[135];let v=!r.browserEnabled&&`pointer-events-none opacity-40`,y;t[136]===v?y=t[137]:(y=a(`transition-opacity`,v),t[136]=v,t[137]=y);let b=!r.browserEnabled,x;t[138]!==n||t[139]!==r||t[140]!==i?(x=(0,Z.jsx)(xe,{a:n,form:r,update:i}),t[138]=n,t[139]=r,t[140]=i,t[141]=x):x=t[141];let S;t[142]!==y||t[143]!==b||t[144]!==x?(S=(0,Z.jsx)(se,{children:(0,Z.jsx)(`div`,{className:y,"aria-hidden":b,children:x})}),t[142]=y,t[143]=b,t[144]=x,t[145]=S):S=t[145];let C;return t[146]!==e||t[147]!==_||t[148]!==S?(C=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[e,_,S]}),t[146]=e,t[147]=_,t[148]=S,t[149]=C):C=t[149],C}return Pe(o)?G:null}function mt(e){return e.mode}function ht(e){return e.language}function gt(e){let t=(0,X.c)(54),{sectionId:n,intro:r,vm:i,children:a,tabbed:o}=e,c=o===void 0?!1:o,u=l(_t),d;t[0]===u?d=t[1]:(d=s(u),t[0]=u,t[1]=d);let f=d,p=f.agentSettings,m=f.settingsSections[n]??n;if(!i.hasToken){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(E,{className:`mt-0.5 size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75}),t[2]=e):e=t[2];let n;t[3]===m?n=t[4]:(n=(0,Z.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:m}),t[3]=m,t[4]=n);let r;t[5]===p.needToken?r=t[6]:(r=(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:p.needToken}),t[5]=p.needToken,t[6]=r);let i;return t[7]!==n||t[8]!==r?(i=(0,Z.jsx)(ie,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl bg-surface-base p-6`,children:[e,(0,Z.jsxs)(`div`,{children:[n,r]})]})}),t[7]=n,t[8]=r,t[9]=i):i=t[9],i}if(i.loading){let e;return t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(ie,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,Z.jsx)(oe,{sections:1})}),t[10]=e):e=t[10],e}if(!i.form){let e=i.error??i.fetchError??p.loadError,n;t[11]===e?n=t[12]:(n=(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[11]=e,t[12]=n);let r;t[13]===i?r=t[14]:(r=()=>void i.mutate(),t[13]=i,t[14]=r);let a;t[15]!==f.logs.refresh||t[16]!==r?(a=(0,Z.jsx)(C,{type:`button`,variant:`secondary`,onClick:r,children:f.logs.refresh}),t[15]=f.logs.refresh,t[16]=r,t[17]=a):a=t[17];let o;return t[18]!==n||t[19]!==a?(o=(0,Z.jsxs)(ie,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:[n,a]}),t[18]=n,t[19]=a,t[20]=o):o=t[20],o}let h=c?void 0:r,g;t[21]===p.sectionDesc?g=t[22]:(g=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:p.sectionDesc}),t[21]=p.sectionDesc,t[22]=g);let _;t[23]!==p.saved||t[24]!==i.dirty||t[25]!==i.saveOk?(_=i.saveOk&&!i.dirty?(0,Z.jsx)(`span`,{className:`text-sm text-fg-muted`,role:`status`,children:p.saved}):null,t[23]=p.saved,t[24]=i.dirty,t[25]=i.saveOk,t[26]=_):_=t[26];let v=!i.dirty||i.saving,y;t[27]!==p.discard||t[28]!==v||t[29]!==i.discard?(y=(0,Z.jsx)(C,{type:`button`,variant:`secondary`,disabled:v,onClick:i.discard,children:p.discard}),t[27]=p.discard,t[28]=v,t[29]=i.discard,t[30]=y):y=t[30];let b=!i.dirty||i.saving,x;t[31]===i?x=t[32]:(x=()=>void i.save(),t[31]=i,t[32]=x);let S=i.saving?p.saving:p.save,w;t[33]!==b||t[34]!==x||t[35]!==S?(w=(0,Z.jsx)(C,{type:`button`,variant:`primary`,disabled:b,onClick:x,children:S}),t[33]=b,t[34]=x,t[35]=S,t[36]=w):w=t[36];let T;t[37]!==w||t[38]!==_||t[39]!==y?(T=(0,Z.jsxs)(Z.Fragment,{children:[_,y,w]}),t[37]=w,t[38]=_,t[39]=y,t[40]=T):T=t[40];let D;t[41]!==m||t[42]!==T||t[43]!==h||t[44]!==g?(D=(0,Z.jsx)(re,{title:m,subtitle:h,meta:g,actions:T}),t[41]=m,t[42]=T,t[43]=h,t[44]=g,t[45]=D):D=t[45];let O;t[46]===i.error?O=t[47]:(O=i.error?(0,Z.jsx)(`div`,{className:`rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/50 dark:bg-red-950/50 dark:text-red-400`,role:`alert`,children:i.error}):null,t[46]=i.error,t[47]=O);let k;t[48]===a?k=t[49]:(k=(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-col gap-5 pb-8`,children:a}),t[48]=a,t[49]=k);let A;return t[50]!==D||t[51]!==O||t[52]!==k?(A=(0,Z.jsxs)(ie,{gap:`gap-6`,children:[D,O,k]}),t[50]=D,t[51]=O,t[52]=k,t[53]=A):A=t[53],A}function _t(e){return e.language}var vt={enabled:!0,mode:`default`,reserveTokens:8e3,triggerThreshold:.8,minMessagesBeforeCompact:10,keepRecentMessages:5,evictionWindow:.2,retentionWindow:6},yt={enabled:!0,maxToolResultChars:1e4,headKeepRatio:.3,tailKeepRatio:.3},bt={enabled:!0,useEnhancedSystem:!0,userProfileEnabled:!0,provider:``,injectionFrequency:``,memoryCharLimit:void 0,userCharLimit:void 0,contextCadence:void 0,dialecticCadence:void 0},xt={summaryModel:``},St={model:``,maxLength:void 0};function Ct(e){if(!e)return``;if(typeof e==`string`)return e;if(typeof e==`object`&&!Array.isArray(e)){let t=e.primary;return typeof t==`string`?t:``}return``}function wt(e){if(typeof e!=`object`||!e||!(`fallbacks`in e))return[];let t=e.fallbacks;return Array.isArray(t)?t.filter(e=>typeof e==`string`&&e.trim().length>0):[]}function Tt(e){return e===!0||e===`true`||e===1}function Et(e){let t=e;if(!t||typeof t!=`object`||Array.isArray(t))return{browserEnabled:!0,browserHeadless:!1,browserAllowPrivateUrls:!1,browserCommandTimeout:void 0,browserBackend:`extension`,browserCloudProvider:`local`,browserCloudApiKey:``,browserCloudProjectId:``,browserCloudRegion:``,browserCdpUrl:``,browserExtensionPort:void 0,browserExtensionHost:`127.0.0.1`,browserExtensionConnectionTimeout:void 0,browserCloakKeepOpen:!0,browserCloakTemporaryProfile:!1,browserCloakCacheDir:``,browserCloakBinaryPath:``,browserCloakTimezone:``,browserCloakLocale:``,browserCloakWebrtcIp:``,browserCloakFingerprintPlatform:``,browserCloakExtraArgs:``,browserHumanize:!0,browserHumanPreset:`careful`,browserDialogPolicy:`auto_dismiss`,browserDialogTimeout:void 0};let n=t,r=Tt(n.enabled),i=n.headless,a=i===!0||i===`true`||i===1,o=Tt(n.allowPrivateUrls),s=typeof n.commandTimeout==`number`&&Number.isFinite(n.commandTimeout)&&n.commandTimeout>=5?Math.floor(n.commandTimeout):void 0,c=n.backend,l=c===`local`||c===`cdp`||c===`cloud`||c===`extension`||c===`cloakbrowser`?c:`extension`,u=n.cloudProvider,d=u===`browserbase`||u===`browser-use`?u:`local`,f=typeof n.cloud==`object`&&n.cloud&&!Array.isArray(n.cloud)?n.cloud:{},p=typeof f.apiKey==`string`?f.apiKey:``,m=typeof f.projectId==`string`?f.projectId:``,h=typeof f.region==`string`?f.region:``,g=typeof n.cdpUrl==`string`?n.cdpUrl:``,_=typeof n.extension==`object`&&n.extension&&!Array.isArray(n.extension)?n.extension:{},v=typeof _.port==`number`&&Number.isFinite(_.port)&&_.port>=1024&&_.port<=65535?Math.floor(_.port):void 0,y=typeof _.host==`string`&&_.host?_.host:`127.0.0.1`,b=typeof _.connectionTimeout==`number`&&Number.isFinite(_.connectionTimeout)&&_.connectionTimeout>=1e3?Math.floor(_.connectionTimeout):void 0,x=typeof n.cloakbrowser==`object`&&n.cloakbrowser&&!Array.isArray(n.cloakbrowser)?n.cloakbrowser:{},S=n.humanPreset==="default"?`default`:`careful`,C=n.dialogPolicy,w=C===`must_respond`||C===`auto_accept`?C:`auto_dismiss`,T=typeof n.dialogTimeoutSeconds==`number`&&Number.isFinite(n.dialogTimeoutSeconds)&&n.dialogTimeoutSeconds>=1?Math.floor(n.dialogTimeoutSeconds):void 0;return{browserEnabled:r,browserHeadless:a,browserAllowPrivateUrls:o,browserCommandTimeout:s,browserBackend:l,browserCloudProvider:d,browserCloudApiKey:p,browserCloudProjectId:m,browserCloudRegion:h,browserCdpUrl:g,browserExtensionPort:v,browserExtensionHost:y,browserExtensionConnectionTimeout:b,browserCloakKeepOpen:x.keepOpen!==!1,browserCloakTemporaryProfile:x.temporaryProfile===!0,browserCloakCacheDir:typeof x.cacheDir==`string`?x.cacheDir:``,browserCloakBinaryPath:typeof x.binaryPath==`string`?x.binaryPath:``,browserCloakTimezone:typeof x.timezone==`string`?x.timezone:``,browserCloakLocale:typeof x.locale==`string`?x.locale:``,browserCloakWebrtcIp:typeof x.webrtcIp==`string`?x.webrtcIp:``,browserCloakFingerprintPlatform:typeof x.fingerprintPlatform==`string`?x.fingerprintPlatform:``,browserCloakExtraArgs:Array.isArray(x.extraArgs)?x.extraArgs.filter(e=>typeof e==`string`&&e.trim().length>0).join(`
7
+ `):``,browserHumanize:n.humanize!==!1,browserHumanPreset:S,browserDialogPolicy:w,browserDialogTimeout:T}}function Dt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...vt};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:vt.enabled,mode:t.mode===`safeguard`?`safeguard`:`default`,reserveTokens:typeof t.reserveTokens==`number`&&Number.isFinite(t.reserveTokens)?Math.floor(t.reserveTokens):vt.reserveTokens,triggerThreshold:typeof t.triggerThreshold==`number`&&Number.isFinite(t.triggerThreshold)?t.triggerThreshold:vt.triggerThreshold,minMessagesBeforeCompact:typeof t.minMessagesBeforeCompact==`number`&&Number.isFinite(t.minMessagesBeforeCompact)?Math.floor(t.minMessagesBeforeCompact):vt.minMessagesBeforeCompact,keepRecentMessages:typeof t.keepRecentMessages==`number`&&Number.isFinite(t.keepRecentMessages)?Math.floor(t.keepRecentMessages):vt.keepRecentMessages,evictionWindow:typeof t.evictionWindow==`number`&&Number.isFinite(t.evictionWindow)?t.evictionWindow:vt.evictionWindow,retentionWindow:typeof t.retentionWindow==`number`&&Number.isFinite(t.retentionWindow)?Math.floor(t.retentionWindow):vt.retentionWindow}}function Ot(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...yt};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:yt.enabled,maxToolResultChars:typeof t.maxToolResultChars==`number`&&Number.isFinite(t.maxToolResultChars)?Math.floor(t.maxToolResultChars):yt.maxToolResultChars,headKeepRatio:typeof t.headKeepRatio==`number`&&Number.isFinite(t.headKeepRatio)?t.headKeepRatio:yt.headKeepRatio,tailKeepRatio:typeof t.tailKeepRatio==`number`&&Number.isFinite(t.tailKeepRatio)?t.tailKeepRatio:yt.tailKeepRatio}}function kt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...bt};let t=e,n=t.provider,r=n===`none`||n===`stub`?n:``,i=t.injectionFrequency,a=i===`every-turn`||i===`first-turn`?i:``;return{enabled:typeof t.enabled==`boolean`?t.enabled:bt.enabled,useEnhancedSystem:typeof t.useEnhancedSystem==`boolean`?t.useEnhancedSystem:bt.useEnhancedSystem,userProfileEnabled:typeof t.userProfileEnabled==`boolean`?t.userProfileEnabled:bt.userProfileEnabled,provider:r,injectionFrequency:a,memoryCharLimit:typeof t.memoryCharLimit==`number`&&t.memoryCharLimit>0?Math.floor(t.memoryCharLimit):void 0,userCharLimit:typeof t.userCharLimit==`number`&&t.userCharLimit>0?Math.floor(t.userCharLimit):void 0,contextCadence:typeof t.contextCadence==`number`&&t.contextCadence>=1?Math.floor(t.contextCadence):void 0,dialecticCadence:typeof t.dialecticCadence==`number`&&t.dialecticCadence>=1?Math.floor(t.dialecticCadence):void 0}}function At(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...xt};let t=e;return{summaryModel:typeof t.summaryModel==`string`?t.summaryModel:``}}function jt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...St};let t=e;return{model:typeof t.model==`string`?t.model:``,maxLength:typeof t.maxLength==`number`&&t.maxLength>0?t.maxLength:void 0}}function Mt(e,t){if(!e||typeof e!=`object`||Array.isArray(e))return{enabled:t};let n=e;return{enabled:typeof n.enabled==`boolean`?n.enabled:t}}function Nt(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Pt(e){if(e==null)return``;if(typeof e==`string`){let t=e.trim();if(!t)return``;try{let e=JSON.parse(t);if(typeof e==`object`&&e&&!Array.isArray(e))return JSON.stringify(e,null,2)}catch{return t}return``}if(typeof e==`object`&&!Array.isArray(e))try{return JSON.stringify(e,null,2)}catch{return``}return``}function Ft(e){let t=e.imageGenerationModelTimeoutMs;if(typeof t==`number`&&Number.isFinite(t)&&t>0)return Math.floor(t);let n=e.imageGenerationModel;if(n&&typeof n==`object`&&!Array.isArray(n)){let e=n.timeoutMs;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return Math.floor(e)}return null}function It(e){if(e.imageGenerationModelAutoProviderFallback===!0)return!0;let t=e.imageGenerationModel;return t&&typeof t==`object`&&!Array.isArray(t)?t.autoProviderFallback===!0:!1}function Lt(e){let t={},n=t.models&&typeof t.models==`object`&&!Array.isArray(t.models)?t.models:{},r=n.chat,i=t.modelFallbacks,a=Array.isArray(i)&&i.every(e=>typeof e==`string`)?i:wt(r),o=t.imageModelFallbacks,s=Array.isArray(o)&&o.every(e=>typeof e==`string`)?o:wt(t.imageModel),c=t.imageGenerationModelFallbacks,l=Array.isArray(c)&&c.every(e=>typeof e==`string`)?c:wt(t.imageGenerationModel),u=Et((e&&typeof e==`object`&&!Array.isArray(e)?e:{}).browser),d=typeof t.maxTaskDurationMs==`number`&&Number.isFinite(t.maxTaskDurationMs)?t.maxTaskDurationMs:void 0,f=d===void 0?void 0:Math.round(d/6e4);return{model:Ct(r),modelFallbacks:a,imageModel:Ct(t.imageModel),imageModelFallbacks:s,imageGenerationModel:Ct(t.imageGenerationModel),imageGenerationModelFallbacks:l,imageGenerationModelTimeoutMs:Ft(t),imageGenerationModelAutoProviderFallback:It(t),mediaMaxMb:typeof t.mediaMaxMb==`number`&&!Number.isNaN(t.mediaMaxMb)?t.mediaMaxMb:void 0,maxTokens:typeof t.maxTokens==`number`?t.maxTokens:8192,temperature:typeof t.temperature==`number`?t.temperature:.7,maxToolIterations:typeof t.maxToolIterations==`number`?t.maxToolIterations:20,maxTaskDurationMinutes:f,maxRequestsPerTurn:typeof t.maxRequestsPerTurn==`number`?t.maxRequestsPerTurn:50,maxToolFailuresPerTurn:typeof t.maxToolFailuresPerTurn==`number`?t.maxToolFailuresPerTurn:3,workspace:typeof t.workspace==`string`?t.workspace:`~/.xopc/workspace`,...u,thinkingDefault:typeof t.thinkingDefault==`string`?t.thinkingDefault:`medium`,reasoningDefault:typeof t.reasoningDefault==`string`?t.reasoningDefault:`stream`,verboseDefault:typeof t.verboseDefault==`string`?t.verboseDefault:`full`,compaction:Dt(t.compaction),pruning:Ot(t.pruning),memory:kt(t.memory),sessionSearch:At(t.sessionSearch),webExtract:jt(t.webExtract),delegate:Mt(t.delegate,!1),executeCode:Mt(t.executeCode,!1),systemPromptOverride:typeof t.systemPromptOverride==`string`?t.systemPromptOverride:``,skillsAllowlist:Nt(t.skills),toolsDisable:(()=>{let e=t.tools;if(!e||typeof e!=`object`||Array.isArray(e))return[];let n=e.disable;return Nt(n)})(),typedModels:de(n),paramsJson:Pt(t.params)}}function Rt(e){return{enabled:e.browserEnabled,headless:e.browserHeadless,allowPrivateUrls:e.browserAllowPrivateUrls,...e.browserCommandTimeout===void 0?{}:{commandTimeout:e.browserCommandTimeout},backend:e.browserBackend,...e.browserCloudProvider===`local`?{}:{cloudProvider:e.browserCloudProvider},...e.browserBackend===`cloud`?{cloud:{...e.browserCloudApiKey.trim()?{apiKey:e.browserCloudApiKey.trim()}:{},...e.browserCloudProjectId.trim()?{projectId:e.browserCloudProjectId.trim()}:{},...e.browserCloudRegion.trim()?{region:e.browserCloudRegion.trim()}:{}}}:{},...e.browserCdpUrl.trim()?{cdpUrl:e.browserCdpUrl.trim()}:{},...e.browserBackend===`extension`?{extension:{...e.browserExtensionPort===void 0?{}:{port:e.browserExtensionPort},...e.browserExtensionHost.trim()?{host:e.browserExtensionHost.trim()}:{},...e.browserExtensionConnectionTimeout===void 0?{}:{connectionTimeout:e.browserExtensionConnectionTimeout}}}:{},...e.browserBackend===`cloakbrowser`?{cloakbrowser:{keepOpen:e.browserCloakKeepOpen,temporaryProfile:e.browserCloakTemporaryProfile,...e.browserCloakCacheDir.trim()?{cacheDir:e.browserCloakCacheDir.trim()}:{},...e.browserCloakBinaryPath.trim()?{binaryPath:e.browserCloakBinaryPath.trim()}:{},...e.browserCloakTimezone.trim()?{timezone:e.browserCloakTimezone.trim()}:{},...e.browserCloakLocale.trim()?{locale:e.browserCloakLocale.trim()}:{},...e.browserCloakWebrtcIp.trim()?{webrtcIp:e.browserCloakWebrtcIp.trim()}:{},...e.browserCloakFingerprintPlatform.trim()?{fingerprintPlatform:e.browserCloakFingerprintPlatform.trim()}:{},...(()=>{let t=e.browserCloakExtraArgs.split(`
8
+ `).map(e=>e.trim()).filter(Boolean);return t.length>0?{extraArgs:t}:{}})()},humanize:e.browserHumanize,humanPreset:e.browserHumanPreset}:{},...e.browserDialogPolicy===`auto_dismiss`?{}:{dialogPolicy:e.browserDialogPolicy},...e.browserDialogTimeout===void 0?{}:{dialogTimeoutSeconds:e.browserDialogTimeout}}}async function zt(e){await f(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({browser:Rt(e)})}),ee()}var Bt=R();function Vt(e,t={}){let n=!!c(e=>e.token),[r,i]=(0,Y.useReducer)(Bt,{form:null,baseline:null}),a=r.form,o=r.baseline,[s,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(!1),m=(0,Y.useRef)(!1),h=(0,Y.useRef)(null),{data:g,error:_,isLoading:v,mutate:y}=V(n);S({enabled:n,parsed:(0,Y.useMemo)(()=>g?.payload?.config===void 0?null:Lt(g.payload.config),[g]),dirty:m.current,trackedParsedRef:h,dispatch:i,onResetDirty:()=>{m.current=!1}});let b=!!(n&&v&&g===void 0&&!_),x=_ instanceof Error?_.message:_?String(_):null,C=(0,Y.useMemo)(()=>!a||!o?!1:JSON.stringify(a)!==JSON.stringify(o),[a,o]);return{hasToken:n,loading:b,fetchError:x,form:a,update:(0,Y.useCallback)(e=>{m.current=!0,p(!1),i({type:`patch`,patch:e})},[]),dirty:C,saving:s,saveOk:f,error:u,setError:d,save:(0,Y.useCallback)(async()=>{if(!a||s)return!1;l(!0),d(null),p(!1);try{return await zt(a),m.current=!1,i({type:`saved`,value:a}),p(!0),y(),!0}catch(t){return d(t instanceof Error?t.message:e.saveError),!1}finally{l(!1)}},[e.saveError,a,y,s]),discard:(0,Y.useCallback)(()=>{m.current=!1,i({type:`discard`}),p(!1),d(null)},[]),mutate:y}}function Ht(e,t){return e.browserTabs[t]}function Ut(){let e=(0,X.c)(43),t=l(Gt),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n,a=r.agentSettings,o=r.chat,c=P(Wt),u;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(u={saveScope:`browser`},e[2]=u):u=e[2];let d=Vt(a,u),[f,p]=i(),m;e[3]===c?m=e[4]:(m=he(Ae,c),e[3]=c,e[4]=m);let h=m,g;e[5]===f?g=e[6]:(g=be(f.get(`focus`)),e[5]=f,e[6]=g);let _=g,v;e[7]!==_||e[8]!==f?(v=_?Me[_]??Ne(f.get(`tab`)):Ne(f.get(`tab`)),e[7]=_,e[8]=f,e[9]=v):v=e[9];let y=v,b;bb0:{if(!d.form){b=null;break bb0}let t;e[10]!==a||e[11]!==o||e[12]!==d.form||e[13]!==d.update?(t={form:d.form,update:d.update,a,chat:o},e[10]=a,e[11]=o,e[12]=d.form,e[13]=d.update,e[14]=t):t=e[14],b=t}let x=b,S;e[15]===p?S=e[16]:(S=e=>{p(t=>{let n=new URLSearchParams(t);return n.delete(`focus`),e===`overview`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[15]=p,e[16]=S);let C=S;me(y,C);let w,T;e[17]!==_||e[18]!==f||e[19]!==p?(w=()=>{if(!_)return;let e=Me[_]??Ne(f.get(`tab`));p(t=>{let n=new URLSearchParams(t);return n.delete(`focus`),e===`overview`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0});let t=_===`runtime`||_===`security`?ye(_):null;if(!t)return;let n=window.setTimeout(()=>{document.getElementById(t)?.scrollIntoView({behavior:`smooth`,block:`start`})},80);return()=>window.clearTimeout(n)},T=[_,f,p],e[17]=_,e[18]=f,e[19]=p,e[20]=w,e[21]=T):(w=e[20],T=e[21]),(0,Y.useEffect)(w,T);let E;if(e[22]!==a||e[23]!==h){let t;e[25]===a?t=e[26]:(t=e=>({id:e,label:Ht(a,e)}),e[25]=a,e[26]=t),E=h.map(t),e[22]=a,e[23]=h,e[24]=E}else E=e[24];let D=E,O;e[27]!==y||e[28]!==a.browserTabsAria||e[29]!==C||e[30]!==D?(O=(0,Z.jsx)(le,{items:D,activeTab:y,onChange:C,ariaLabel:a.browserTabsAria,tabIdPrefix:`agent-browser-tab`,panelIdPrefix:`agent-browser-panel`}),e[27]=y,e[28]=a.browserTabsAria,e[29]=C,e[30]=D,e[31]=O):O=e[31];let k;e[32]!==y||e[33]!==x||e[34]!==C?(k=x?(0,Z.jsx)(pt,{...x,activeTab:y,setActiveTab:C}):null,e[32]=y,e[33]=x,e[34]=C,e[35]=k):k=e[35];let A;e[36]!==y||e[37]!==k?(A=(0,Z.jsx)(ae,{id:y,activeTab:y,tabIdPrefix:`agent-browser-tab`,panelIdPrefix:`agent-browser-panel`,showHeading:!1,framed:!1,children:k}),e[36]=y,e[37]=k,e[38]=A):A=e[38];let j;return e[39]!==O||e[40]!==A||e[41]!==d?(j=(0,Z.jsxs)(gt,{sectionId:`agent-browser`,intro:``,vm:d,tabbed:!0,children:[O,A]}),e[39]=O,e[40]=A,e[41]=d,e[42]=j):j=e[42],j}function Wt(e){return e.mode}function Gt(e){return e.language}export{Ut as AgentBrowserSettingsPage};
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{r as n,s as r}from"./locale-store-0lpYdNDr.js";import{es as i}from"./index-C8JkTS6d.js";var a={list:()=>r(n(`/api/browser/workflows`)),setEnabled:(e,t)=>r(n(`/api/browser/workflows/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({enabled:t})}),remove:e=>r(n(`/api/browser/workflows/${encodeURIComponent(e)}`),{method:`DELETE`}),run:(e,t)=>r(n(`/api/browser/workflows/${encodeURIComponent(e)}/run`),{method:`POST`,body:JSON.stringify({inputs:t})}),getRun:e=>r(n(`/api/browser/workflow-runs/${encodeURIComponent(e)}`)),listRuns:e=>r(n(`/api/browser/workflow-runs?workflowId=${encodeURIComponent(e)}`)),cancel:e=>r(n(`/api/browser/workflow-runs/${encodeURIComponent(e)}/cancel`),{method:`POST`})},o=e(),s=t();function c(e){return Object.fromEntries(Object.entries(e.inputs).flatMap(([e,t])=>t.default===void 0?[]:[[e,t.default]]))}function l(e,t){return!Object.entries(e.inputs).some(([e,n])=>n.required&&(t[e]===void 0||t[e]===``))}function u(e){let t=(0,o.c)(54),{name:n,input:r,value:a,yes:c,no:l,onChange:u}=e,f;t[0]!==r.description||t[1]!==n?(f=r.description?.trim()||n,t[0]=r.description,t[1]=n,t[2]=f):f=t[2];let p=f;if(r.choices?.length){let e;t[3]===r.choices?e=t[4]:(e=r.choices.map(d),t[3]=r.choices,t[4]=e);let n=e,o=r.required?` *`:``,c;t[5]!==p||t[6]!==o?(c=(0,s.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,o]}),t[5]=p,t[6]=o,t[7]=c):c=t[7];let l;t[8]===a?l=t[9]:(l=a===void 0?``:JSON.stringify(a),t[8]=a,t[9]=l);let f;t[10]===u?f=t[11]:(f=e=>u(JSON.parse(e)),t[10]=u,t[11]=f);let m;t[12]!==p||t[13]!==n||t[14]!==l||t[15]!==f?(m=(0,s.jsx)(i,{value:l,options:n,placeholder:p,onChange:f}),t[12]=p,t[13]=n,t[14]=l,t[15]=f,t[16]=m):m=t[16];let h;return t[17]!==c||t[18]!==m?(h=(0,s.jsxs)(`label`,{className:`block text-sm text-fg`,children:[c,m]}),t[17]=c,t[18]=m,t[19]=h):h=t[19],h}if(r.type===`boolean`){let e=r.required?` *`:``,n;t[20]!==p||t[21]!==e?(n=(0,s.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,e]}),t[20]=p,t[21]=e,t[22]=n):n=t[22];let o=typeof a==`boolean`?String(a):``,d;t[23]===c?d=t[24]:(d={value:`true`,label:c},t[23]=c,t[24]=d);let f;t[25]===l?f=t[26]:(f={value:`false`,label:l},t[25]=l,t[26]=f);let m;t[27]!==d||t[28]!==f?(m=[d,f],t[27]=d,t[28]=f,t[29]=m):m=t[29];let h;t[30]===u?h=t[31]:(h=e=>u(e===`true`),t[30]=u,t[31]=h);let g;t[32]!==p||t[33]!==o||t[34]!==m||t[35]!==h?(g=(0,s.jsx)(i,{value:o,options:m,placeholder:p,onChange:h}),t[32]=p,t[33]=o,t[34]=m,t[35]=h,t[36]=g):g=t[36];let _;return t[37]!==n||t[38]!==g?(_=(0,s.jsxs)(`label`,{className:`block text-sm text-fg`,children:[n,g]}),t[37]=n,t[38]=g,t[39]=_):_=t[39],_}let m=r.type===`number`||r.type===`integer`,h=r.required?` *`:``,g;t[40]!==p||t[41]!==h?(g=(0,s.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,h]}),t[40]=p,t[41]=h,t[42]=g):g=t[42];let _=m?`number`:`text`,v=r.type===`integer`?1:void 0,y=a===void 0?``:String(a),b;t[43]!==m||t[44]!==u?(b=e=>u(m?e.target.value===``?void 0:Number(e.target.value):e.target.value),t[43]=m,t[44]=u,t[45]=b):b=t[45];let x;t[46]!==_||t[47]!==v||t[48]!==y||t[49]!==b?(x=(0,s.jsx)(`input`,{type:_,step:v,value:y,onChange:b,className:`h-10 w-full rounded-lg border border-edge bg-surface-subtle px-3 text-sm text-fg outline-none focus:border-accent`}),t[46]=_,t[47]=v,t[48]=y,t[49]=b,t[50]=x):x=t[50];let S;return t[51]!==g||t[52]!==x?(S=(0,s.jsxs)(`label`,{className:`block text-sm text-fg`,children:[g,x]}),t[51]=g,t[52]=x,t[53]=S):S=t[53],S}function d(e){return{value:JSON.stringify(e),label:String(e)}}function f(e){let t=(0,o.c)(7),{workflow:n,values:r,language:i,onChange:a}=e,c;t[0]===n.inputs?c=t[1]:(c=Object.entries(n.inputs),t[0]=n.inputs,t[1]=c);let l;return t[2]!==i||t[3]!==a||t[4]!==c||t[5]!==r?(l=(0,s.jsx)(`div`,{className:`grid gap-4`,children:c.map(e=>{let[t,n]=e;return(0,s.jsx)(u,{name:t,input:n,value:r[t],yes:i===`zh`?`是`:`Yes`,no:i===`zh`?`否`:`No`,onChange:e=>a({...r,[t]:e})},t)})}),t[2]=i,t[3]=a,t[4]=c,t[5]=r,t[6]=l):l=t[6],l}export{a as i,l as n,c as r,f as t};
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{r as n,s as r}from"./locale-store-C_ax27uc.js";import{as as i}from"./index-CGwuxvzr.js";var a={list:()=>r(n(`/api/browser/workflows`)),setEnabled:(e,t)=>r(n(`/api/browser/workflows/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({enabled:t})}),remove:e=>r(n(`/api/browser/workflows/${encodeURIComponent(e)}`),{method:`DELETE`}),run:(e,t)=>r(n(`/api/browser/workflows/${encodeURIComponent(e)}/run`),{method:`POST`,body:JSON.stringify({inputs:t})}),getRun:e=>r(n(`/api/browser/workflow-runs/${encodeURIComponent(e)}`)),listRuns:e=>r(n(`/api/browser/workflow-runs?workflowId=${encodeURIComponent(e)}`)),cancel:e=>r(n(`/api/browser/workflow-runs/${encodeURIComponent(e)}/cancel`),{method:`POST`})},o=e(),s=t();function c(e){return Object.fromEntries(Object.entries(e.inputs).flatMap(([e,t])=>t.default===void 0?[]:[[e,t.default]]))}function l(e,t){return!Object.entries(e.inputs).some(([e,n])=>n.required&&(t[e]===void 0||t[e]===``))}function u(e){let t=(0,o.c)(54),{name:n,input:r,value:a,yes:c,no:l,onChange:u}=e,f;t[0]!==r.description||t[1]!==n?(f=r.description?.trim()||n,t[0]=r.description,t[1]=n,t[2]=f):f=t[2];let p=f;if(r.choices?.length){let e;t[3]===r.choices?e=t[4]:(e=r.choices.map(d),t[3]=r.choices,t[4]=e);let n=e,o=r.required?` *`:``,c;t[5]!==p||t[6]!==o?(c=(0,s.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,o]}),t[5]=p,t[6]=o,t[7]=c):c=t[7];let l;t[8]===a?l=t[9]:(l=a===void 0?``:JSON.stringify(a),t[8]=a,t[9]=l);let f;t[10]===u?f=t[11]:(f=e=>u(JSON.parse(e)),t[10]=u,t[11]=f);let m;t[12]!==p||t[13]!==n||t[14]!==l||t[15]!==f?(m=(0,s.jsx)(i,{value:l,options:n,placeholder:p,onChange:f}),t[12]=p,t[13]=n,t[14]=l,t[15]=f,t[16]=m):m=t[16];let h;return t[17]!==c||t[18]!==m?(h=(0,s.jsxs)(`label`,{className:`block text-sm text-fg`,children:[c,m]}),t[17]=c,t[18]=m,t[19]=h):h=t[19],h}if(r.type===`boolean`){let e=r.required?` *`:``,n;t[20]!==p||t[21]!==e?(n=(0,s.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,e]}),t[20]=p,t[21]=e,t[22]=n):n=t[22];let o=typeof a==`boolean`?String(a):``,d;t[23]===c?d=t[24]:(d={value:`true`,label:c},t[23]=c,t[24]=d);let f;t[25]===l?f=t[26]:(f={value:`false`,label:l},t[25]=l,t[26]=f);let m;t[27]!==d||t[28]!==f?(m=[d,f],t[27]=d,t[28]=f,t[29]=m):m=t[29];let h;t[30]===u?h=t[31]:(h=e=>u(e===`true`),t[30]=u,t[31]=h);let g;t[32]!==p||t[33]!==o||t[34]!==m||t[35]!==h?(g=(0,s.jsx)(i,{value:o,options:m,placeholder:p,onChange:h}),t[32]=p,t[33]=o,t[34]=m,t[35]=h,t[36]=g):g=t[36];let _;return t[37]!==n||t[38]!==g?(_=(0,s.jsxs)(`label`,{className:`block text-sm text-fg`,children:[n,g]}),t[37]=n,t[38]=g,t[39]=_):_=t[39],_}let m=r.type===`number`||r.type===`integer`,h=r.required?` *`:``,g;t[40]!==p||t[41]!==h?(g=(0,s.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,h]}),t[40]=p,t[41]=h,t[42]=g):g=t[42];let _=m?`number`:`text`,v=r.type===`integer`?1:void 0,y=a===void 0?``:String(a),b;t[43]!==m||t[44]!==u?(b=e=>u(m?e.target.value===``?void 0:Number(e.target.value):e.target.value),t[43]=m,t[44]=u,t[45]=b):b=t[45];let x;t[46]!==_||t[47]!==v||t[48]!==y||t[49]!==b?(x=(0,s.jsx)(`input`,{type:_,step:v,value:y,onChange:b,className:`h-10 w-full rounded-lg border border-edge bg-surface-subtle px-3 text-sm text-fg outline-none focus:border-accent`}),t[46]=_,t[47]=v,t[48]=y,t[49]=b,t[50]=x):x=t[50];let S;return t[51]!==g||t[52]!==x?(S=(0,s.jsxs)(`label`,{className:`block text-sm text-fg`,children:[g,x]}),t[51]=g,t[52]=x,t[53]=S):S=t[53],S}function d(e){return{value:JSON.stringify(e),label:String(e)}}function f(e){let t=(0,o.c)(7),{workflow:n,values:r,language:i,onChange:a}=e,c;t[0]===n.inputs?c=t[1]:(c=Object.entries(n.inputs),t[0]=n.inputs,t[1]=c);let l;return t[2]!==i||t[3]!==a||t[4]!==c||t[5]!==r?(l=(0,s.jsx)(`div`,{className:`grid gap-4`,children:c.map(e=>{let[t,n]=e;return(0,s.jsx)(u,{name:t,input:n,value:r[t],yes:i===`zh`?`是`:`Yes`,no:i===`zh`?`否`:`No`,onChange:e=>a({...r,[t]:e})},t)})}),t[2]=i,t[3]=a,t[4]=c,t[5]=r,t[6]=l):l=t[6],l}export{a as i,l as n,c as r,f as t};
@@ -1,3 +1,3 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{l as r}from"./chunk-KS7C4IRE-uQ0fehio.js";import{n as i}from"./locale-store-0lpYdNDr.js";import{Ac as a,Bl as o,Bs as s,Ec as c,Qa as l,Xl as u,Zs as d,_u as f,au as p,bo as m,iu as h,ws as g}from"./index-C8JkTS6d.js";import{i as _,n as v,r as y,t as b}from"./browser-workflow-inputs-Dx6wkGz1.js";var x=e(t(),1),S=n(),C={en:{title:`Browser automations`,subtitle:`Let your assistant repeat routine actions on the web.`,emptyTitle:`No browser automations yet`,emptyBody:`Tell your assistant what to do on the web. Once it works, save it and run it again whenever you need.`,create:`Create with assistant`,edit:`Edit with assistant`,run:`Run now`,stop:`Stop`,enable:`Enable`,pause:`Pause`,enabled:`Enabled`,paused:`Paused`,inputs:`Before running`,noInputs:`This automation is ready to run.`,history:`Recent activity`,delete:`Delete automation`,confirmDelete:`Delete this browser automation?`,required:`Please complete all required fields.`,queued:`Waiting to start`,running:`Running`,succeeded:`Completed`,failed:`Needs attention`,cancelled:`Stopped`,result:`Result`,read_only:`Reads information`,account_write:`Changes account data`,sensitive:`Sensitive action`,createPrompt:`Help me create a reusable browser automation. Ask what I want the browser to do, perform it once with me, then save the successful steps. Keep all technical details hidden.`,editPrompt:`Help me update the browser automation "{name}" (id: {id}). Ask what should change, test the new browser steps, then save it.`},zh:{title:`浏览器自动化`,subtitle:`让助手自动重复完成网页上的固定操作。`,emptyTitle:`还没有浏览器自动化`,emptyBody:`告诉助手你希望在网页上自动完成什么。成功执行一次后,即可保存并重复运行。`,create:`让助手帮我创建`,edit:`让助手帮我修改`,run:`立即运行`,stop:`停止`,enable:`启用`,pause:`暂停`,enabled:`已启用`,paused:`已暂停`,inputs:`运行前需要填写`,noInputs:`这个自动化可以直接运行。`,history:`最近运行`,delete:`删除自动化`,confirmDelete:`确定删除这个浏览器自动化吗?`,required:`请填写所有必填内容。`,queued:`等待开始`,running:`正在运行`,succeeded:`已完成`,failed:`需要处理`,cancelled:`已停止`,result:`运行结果`,read_only:`仅读取信息`,account_write:`会修改账户数据`,sensitive:`包含敏感操作`,createPrompt:`请帮我创建一个可重复运行的浏览器自动化。先询问我希望浏览器完成什么,陪我实际执行成功一次,然后保存成功步骤。不要让我处理技术细节。`,editPrompt:`请帮我修改浏览器自动化“{name}”(id:{id})。先询问我要修改什么,实际测试新的浏览器步骤,然后保存。`}};function w(e){return e!==`queued`&&e!==`running`}function T(e){return e==null?`-`:typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):Array.isArray(e)?e.map(e=>`• ${T(e)}`).join(`
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{l as r}from"./chunk-KS7C4IRE-uQ0fehio.js";import{n as i}from"./locale-store-C_ax27uc.js";import{Eu as a,Fc as o,Ns as s,To as c,Yl as l,Ys as u,au as d,mu as f,oc as p,pu as m,ro as h,zc as g}from"./index-CGwuxvzr.js";import{i as _,n as v,r as y,t as b}from"./browser-workflow-inputs-DXmzQ3nk.js";var x=e(t(),1),S=n(),C={en:{title:`Browser automations`,subtitle:`Let your assistant repeat routine actions on the web.`,emptyTitle:`No browser automations yet`,emptyBody:`Tell your assistant what to do on the web. Once it works, save it and run it again whenever you need.`,create:`Create with assistant`,edit:`Edit with assistant`,run:`Run now`,stop:`Stop`,enable:`Enable`,pause:`Pause`,enabled:`Enabled`,paused:`Paused`,inputs:`Before running`,noInputs:`This automation is ready to run.`,history:`Recent activity`,delete:`Delete automation`,confirmDelete:`Delete this browser automation?`,required:`Please complete all required fields.`,queued:`Waiting to start`,running:`Running`,succeeded:`Completed`,failed:`Needs attention`,cancelled:`Stopped`,result:`Result`,read_only:`Reads information`,account_write:`Changes account data`,sensitive:`Sensitive action`,createPrompt:`Help me create a reusable browser automation. Ask what I want the browser to do, perform it once with me, then save the successful steps. Keep all technical details hidden.`,editPrompt:`Help me update the browser automation "{name}" (id: {id}). Ask what should change, test the new browser steps, then save it.`},zh:{title:`浏览器自动化`,subtitle:`让助手自动重复完成网页上的固定操作。`,emptyTitle:`还没有浏览器自动化`,emptyBody:`告诉助手你希望在网页上自动完成什么。成功执行一次后,即可保存并重复运行。`,create:`让助手帮我创建`,edit:`让助手帮我修改`,run:`立即运行`,stop:`停止`,enable:`启用`,pause:`暂停`,enabled:`已启用`,paused:`已暂停`,inputs:`运行前需要填写`,noInputs:`这个自动化可以直接运行。`,history:`最近运行`,delete:`删除自动化`,confirmDelete:`确定删除这个浏览器自动化吗?`,required:`请填写所有必填内容。`,queued:`等待开始`,running:`正在运行`,succeeded:`已完成`,failed:`需要处理`,cancelled:`已停止`,result:`运行结果`,read_only:`仅读取信息`,account_write:`会修改账户数据`,sensitive:`包含敏感操作`,createPrompt:`请帮我创建一个可重复运行的浏览器自动化。先询问我希望浏览器完成什么,陪我实际执行成功一次,然后保存成功步骤。不要让我处理技术细节。`,editPrompt:`请帮我修改浏览器自动化“{name}”(id:{id})。先询问我要修改什么,实际测试新的浏览器步骤,然后保存。`}};function w(e){return e!==`queued`&&e!==`running`}function T(e){return e==null?`-`:typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):Array.isArray(e)?e.map(e=>`• ${T(e)}`).join(`
2
2
  `):typeof e==`object`?Object.entries(e).map(([e,t])=>`${e}: ${T(t)}`).join(`
3
- `):String(e)}function E(){let e=i(e=>e.language),t=C[e],n=r(),E=m(e=>e.setPageHeader),D=m(e=>e.clearPageHeader),[O,k]=(0,x.useState)(null),[A,j]=(0,x.useState)(),[M,N]=(0,x.useState)({}),[P,F]=(0,x.useState)([]),[I,L]=(0,x.useState)(),[R,z]=(0,x.useState)(``),[B,V]=(0,x.useState)(!1),H=(0,x.useMemo)(()=>O?.find(e=>e.id===A),[A,O]),U=(0,x.useCallback)(async()=>{let e=await _.list();k(e.workflows),j(t=>t&&e.workflows.some(e=>e.id===t)?t:e.workflows[0]?.id)},[]);(0,x.useEffect)(()=>{U().catch(e=>z(String(e)))},[U]),(0,x.useEffect)(()=>{H&&(N(y(H)),L(void 0),z(``),_.listRuns(H.id).then(e=>F(e.runs)).catch(e=>z(String(e))))},[H]),(0,x.useEffect)(()=>{if(!I||w(I.status))return;let e=window.setInterval(()=>{_.getRun(I.id).then(({run:e})=>{L(e),w(e.status)&&H&&_.listRuns(H.id).then(e=>F(e.runs))}).catch(e=>z(String(e)))},700);return()=>window.clearInterval(e)},[I,H]);let W=(0,x.useCallback)(e=>{n(`/chat/new?draft=${encodeURIComponent(e)}`)},[n]),G=(0,x.useMemo)(()=>(0,S.jsxs)(g,{onClick:()=>W(t.createPrompt),children:[(0,S.jsx)(f,{className:`size-4`}),t.create]}),[W,t.create,t.createPrompt]);(0,x.useLayoutEffect)(()=>(E({startExtra:null,main:(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title}),(0,S.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:t.subtitle})]}),end:G}),()=>D()),[D,G,E,t.subtitle,t.title]);let K=async()=>{if(H){V(!0);try{await _.setEnabled(H.id,!H.enabled),await U()}catch(e){z(String(e))}finally{V(!1)}}},q=async()=>{if(H){if(!v(H,M)){z(t.required);return}V(!0);try{let{run:e}=await _.run(H.id,M);L(e),z(``)}catch(e){z(String(e))}finally{V(!1)}}},J=async()=>{if(!(!H||!window.confirm(t.confirmDelete))){V(!0);try{await _.remove(H.id),j(void 0),F([]),await U()}catch(e){z(String(e))}finally{V(!1)}}};return O===null?(0,S.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel p-4 sm:p-6`,children:(0,S.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[280px_minmax(0,1fr)]`,children:[(0,S.jsx)(l,{className:`h-[420px] rounded-xl`}),(0,S.jsx)(l,{className:`h-[420px] rounded-xl`})]})}):O.length===0?(0,S.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel p-4 sm:p-6`,children:(0,S.jsxs)(`div`,{className:`m-auto max-w-md rounded-2xl border border-edge bg-surface-base p-8 text-center`,children:[(0,S.jsx)(f,{className:`mx-auto size-10 text-accent`}),(0,S.jsx)(`h2`,{className:`mt-4 text-lg font-semibold text-fg`,children:t.emptyTitle}),(0,S.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:t.emptyBody}),(0,S.jsxs)(g,{className:`mt-5`,onClick:()=>W(t.createPrompt),children:[(0,S.jsx)(f,{className:`size-4`}),t.create]})]})}):(0,S.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel p-4 sm:p-6`,children:(0,S.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-4 lg:grid-cols-[280px_minmax(0,1fr)]`,children:[(0,S.jsx)(`aside`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge bg-surface-base p-2`,children:O.map(e=>(0,S.jsxs)(`button`,{onClick:()=>j(e.id),className:`mb-1 w-full rounded-lg p-3 text-left ${A===e.id?`bg-accent-soft text-accent-fg`:`hover:bg-surface-hover`}`,children:[(0,S.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.name}),(0,S.jsxs)(`span`,{className:`mt-1 flex items-center gap-1.5 text-xs text-fg-muted`,children:[e.enabled?(0,S.jsx)(h,{className:`size-3.5 text-emerald-600`}):(0,S.jsx)(p,{className:`size-3.5`}),e.enabled?t.enabled:t.paused]})]},e.id))}),H&&(0,S.jsxs)(`main`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge bg-surface-base p-5 sm:p-6`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:H.name}),H.description&&(0,S.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:H.description}),(0,S.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs`,children:[(0,S.jsx)(`span`,{className:`rounded-full bg-surface-subtle px-2.5 py-1 text-fg-muted`,children:t[H.risk]}),H.domains.map(e=>(0,S.jsxs)(`span`,{className:`flex items-center gap-1 rounded-full bg-surface-subtle px-2.5 py-1 text-fg-muted`,children:[(0,S.jsx)(o,{className:`size-3`}),e]},e))]})]}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsxs)(g,{variant:`secondary`,disabled:B,onClick:()=>void K(),children:[H.enabled?(0,S.jsx)(p,{className:`size-4`}):(0,S.jsx)(h,{className:`size-4`}),H.enabled?t.pause:t.enable]}),(0,S.jsxs)(g,{variant:`secondary`,onClick:()=>W(t.editPrompt.replace(`{name}`,H.name).replace(`{id}`,H.id)),children:[(0,S.jsx)(a,{className:`size-4`}),t.edit]})]})]}),(0,S.jsxs)(`section`,{className:`mt-7 max-w-xl`,children:[(0,S.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.inputs}),Object.keys(H.inputs).length===0?(0,S.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:t.noInputs}):(0,S.jsx)(`div`,{className:`mt-3`,children:(0,S.jsx)(b,{workflow:H,values:M,language:e,onChange:N})}),(0,S.jsxs)(`div`,{className:`mt-5 flex gap-2`,children:[(0,S.jsxs)(g,{variant:`primary`,disabled:!H.enabled||B||!!(I&&!w(I.status)),onClick:()=>void q(),children:[(0,S.jsx)(c,{className:`size-4`}),t.run]}),I&&!w(I.status)&&(0,S.jsxs)(g,{variant:`secondary`,onClick:()=>void _.cancel(I.id),children:[(0,S.jsx)(d,{className:`size-4`}),t.stop]})]}),R&&(0,S.jsx)(`p`,{className:`mt-3 text-sm text-red-700 dark:text-red-300`,children:R})]}),I&&(0,S.jsxs)(`section`,{className:`mt-7 rounded-xl border border-edge bg-surface-subtle p-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,S.jsx)(u,{className:`size-4`}),t[I.status]]}),I.error&&(0,S.jsx)(`p`,{className:`mt-2 text-sm text-red-700 dark:text-red-300`,children:I.error}),I.status===`succeeded`&&I.result!==void 0&&(0,S.jsxs)(`div`,{className:`mt-3`,children:[(0,S.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:t.result}),(0,S.jsx)(`pre`,{className:`mt-2 max-h-64 overflow-auto whitespace-pre-wrap text-sm text-fg`,children:T(I.result)})]})]}),(0,S.jsxs)(`section`,{className:`mt-8`,children:[(0,S.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.history}),(0,S.jsx)(`div`,{className:`mt-2 divide-y divide-edge`,children:P.slice(0,10).map(e=>(0,S.jsxs)(`button`,{className:`flex w-full items-center justify-between gap-3 py-3 text-left text-sm hover:text-accent`,onClick:()=>L(e),children:[(0,S.jsx)(`span`,{children:t[e.status]}),(0,S.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[new Date(e.createdAtMs).toLocaleString(),e.durationMs?` · ${Math.max(1,Math.round(e.durationMs/1e3))}s`:``]})]},e.id))})]}),(0,S.jsx)(`div`,{className:`mt-8 border-t border-edge pt-4`,children:(0,S.jsxs)(g,{variant:`ghost`,className:`text-red-700 dark:text-red-300`,disabled:B,onClick:()=>void J(),children:[(0,S.jsx)(s,{className:`size-4`}),t.delete]})})]})]})})}export{E as BrowserWorkflowsPage};
3
+ `):String(e)}function E(){let e=i(e=>e.language),t=C[e],n=r(),E=c(e=>e.setPageHeader),D=c(e=>e.clearPageHeader),[O,k]=(0,x.useState)(null),[A,j]=(0,x.useState)(),[M,N]=(0,x.useState)({}),[P,F]=(0,x.useState)([]),[I,L]=(0,x.useState)(),[R,z]=(0,x.useState)(``),[B,V]=(0,x.useState)(!1),H=(0,x.useMemo)(()=>O?.find(e=>e.id===A),[A,O]),U=(0,x.useCallback)(async()=>{let e=await _.list();k(e.workflows),j(t=>t&&e.workflows.some(e=>e.id===t)?t:e.workflows[0]?.id)},[]);(0,x.useEffect)(()=>{U().catch(e=>z(String(e)))},[U]),(0,x.useEffect)(()=>{H&&(N(y(H)),L(void 0),z(``),_.listRuns(H.id).then(e=>F(e.runs)).catch(e=>z(String(e))))},[H]),(0,x.useEffect)(()=>{if(!I||w(I.status))return;let e=window.setInterval(()=>{_.getRun(I.id).then(({run:e})=>{L(e),w(e.status)&&H&&_.listRuns(H.id).then(e=>F(e.runs))}).catch(e=>z(String(e)))},700);return()=>window.clearInterval(e)},[I,H]);let W=(0,x.useCallback)(e=>{n(`/chat/new?draft=${encodeURIComponent(e)}`)},[n]),G=(0,x.useMemo)(()=>(0,S.jsxs)(s,{onClick:()=>W(t.createPrompt),children:[(0,S.jsx)(a,{className:`size-4`}),t.create]}),[W,t.create,t.createPrompt]);(0,x.useLayoutEffect)(()=>(E({startExtra:null,main:(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title}),(0,S.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:t.subtitle})]}),end:G}),()=>D()),[D,G,E,t.subtitle,t.title]);let K=async()=>{if(H){V(!0);try{await _.setEnabled(H.id,!H.enabled),await U()}catch(e){z(String(e))}finally{V(!1)}}},q=async()=>{if(H){if(!v(H,M)){z(t.required);return}V(!0);try{let{run:e}=await _.run(H.id,M);L(e),z(``)}catch(e){z(String(e))}finally{V(!1)}}},J=async()=>{if(!(!H||!window.confirm(t.confirmDelete))){V(!0);try{await _.remove(H.id),j(void 0),F([]),await U()}catch(e){z(String(e))}finally{V(!1)}}};return O===null?(0,S.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel p-4 sm:p-6`,children:(0,S.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[280px_minmax(0,1fr)]`,children:[(0,S.jsx)(h,{className:`h-[420px] rounded-xl`}),(0,S.jsx)(h,{className:`h-[420px] rounded-xl`})]})}):O.length===0?(0,S.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel p-4 sm:p-6`,children:(0,S.jsxs)(`div`,{className:`m-auto max-w-md rounded-2xl border border-edge bg-surface-base p-8 text-center`,children:[(0,S.jsx)(a,{className:`mx-auto size-10 text-accent`}),(0,S.jsx)(`h2`,{className:`mt-4 text-lg font-semibold text-fg`,children:t.emptyTitle}),(0,S.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:t.emptyBody}),(0,S.jsxs)(s,{className:`mt-5`,onClick:()=>W(t.createPrompt),children:[(0,S.jsx)(a,{className:`size-4`}),t.create]})]})}):(0,S.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel p-4 sm:p-6`,children:(0,S.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-4 lg:grid-cols-[280px_minmax(0,1fr)]`,children:[(0,S.jsx)(`aside`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge bg-surface-base p-2`,children:O.map(e=>(0,S.jsxs)(`button`,{onClick:()=>j(e.id),className:`mb-1 w-full rounded-lg p-3 text-left ${A===e.id?`bg-accent-soft text-accent-fg`:`hover:bg-surface-hover`}`,children:[(0,S.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.name}),(0,S.jsxs)(`span`,{className:`mt-1 flex items-center gap-1.5 text-xs text-fg-muted`,children:[e.enabled?(0,S.jsx)(m,{className:`size-3.5 text-emerald-600`}):(0,S.jsx)(f,{className:`size-3.5`}),e.enabled?t.enabled:t.paused]})]},e.id))}),H&&(0,S.jsxs)(`main`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge bg-surface-base p-5 sm:p-6`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:H.name}),H.description&&(0,S.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:H.description}),(0,S.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs`,children:[(0,S.jsx)(`span`,{className:`rounded-full bg-surface-subtle px-2.5 py-1 text-fg-muted`,children:t[H.risk]}),H.domains.map(e=>(0,S.jsxs)(`span`,{className:`flex items-center gap-1 rounded-full bg-surface-subtle px-2.5 py-1 text-fg-muted`,children:[(0,S.jsx)(l,{className:`size-3`}),e]},e))]})]}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsxs)(s,{variant:`secondary`,disabled:B,onClick:()=>void K(),children:[H.enabled?(0,S.jsx)(f,{className:`size-4`}):(0,S.jsx)(m,{className:`size-4`}),H.enabled?t.pause:t.enable]}),(0,S.jsxs)(s,{variant:`secondary`,onClick:()=>W(t.editPrompt.replace(`{name}`,H.name).replace(`{id}`,H.id)),children:[(0,S.jsx)(g,{className:`size-4`}),t.edit]})]})]}),(0,S.jsxs)(`section`,{className:`mt-7 max-w-xl`,children:[(0,S.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.inputs}),Object.keys(H.inputs).length===0?(0,S.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:t.noInputs}):(0,S.jsx)(`div`,{className:`mt-3`,children:(0,S.jsx)(b,{workflow:H,values:M,language:e,onChange:N})}),(0,S.jsxs)(`div`,{className:`mt-5 flex gap-2`,children:[(0,S.jsxs)(s,{variant:`primary`,disabled:!H.enabled||B||!!(I&&!w(I.status)),onClick:()=>void q(),children:[(0,S.jsx)(o,{className:`size-4`}),t.run]}),I&&!w(I.status)&&(0,S.jsxs)(s,{variant:`secondary`,onClick:()=>void _.cancel(I.id),children:[(0,S.jsx)(p,{className:`size-4`}),t.stop]})]}),R&&(0,S.jsx)(`p`,{className:`mt-3 text-sm text-red-700 dark:text-red-300`,children:R})]}),I&&(0,S.jsxs)(`section`,{className:`mt-7 rounded-xl border border-edge bg-surface-subtle p-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,S.jsx)(d,{className:`size-4`}),t[I.status]]}),I.error&&(0,S.jsx)(`p`,{className:`mt-2 text-sm text-red-700 dark:text-red-300`,children:I.error}),I.status===`succeeded`&&I.result!==void 0&&(0,S.jsxs)(`div`,{className:`mt-3`,children:[(0,S.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:t.result}),(0,S.jsx)(`pre`,{className:`mt-2 max-h-64 overflow-auto whitespace-pre-wrap text-sm text-fg`,children:T(I.result)})]})]}),(0,S.jsxs)(`section`,{className:`mt-8`,children:[(0,S.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.history}),(0,S.jsx)(`div`,{className:`mt-2 divide-y divide-edge`,children:P.slice(0,10).map(e=>(0,S.jsxs)(`button`,{className:`flex w-full items-center justify-between gap-3 py-3 text-left text-sm hover:text-accent`,onClick:()=>L(e),children:[(0,S.jsx)(`span`,{children:t[e.status]}),(0,S.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[new Date(e.createdAtMs).toLocaleString(),e.durationMs?` · ${Math.max(1,Math.round(e.durationMs/1e3))}s`:``]})]},e.id))})]}),(0,S.jsx)(`div`,{className:`mt-8 border-t border-edge pt-4`,children:(0,S.jsxs)(s,{variant:`ghost`,className:`text-red-700 dark:text-red-300`,disabled:B,onClick:()=>void J(),children:[(0,S.jsx)(u,{className:`size-4`}),t.delete]})})]})]})})}export{E as BrowserWorkflowsPage};
@@ -0,0 +1,2 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,l as a,r as o,t as s,u as c}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as l}from"./cn-JdwAhgNB.js";import{t as u}from"./messages-C96Zjb0V.js";import{l as d,n as f,o as p,r as m,s as h}from"./locale-store-C_ax27uc.js";import{i as g}from"./vendor-swr-BIWyz7Rc.js";import{An as _,As as v,Bn as y,Bs as b,Bt as x,Cn as S,Dn as C,Ds as w,Ec as T,En as E,Es as D,Fc as O,Fn as k,Gn as A,Go as j,Hn as M,In as N,Is as P,Jn as F,Jo as I,Js as L,Kl as R,Kn as z,Ln as B,Lr as V,Mn as H,Ms as U,Mt as ee,Nc as te,Nn as ne,Ns as W,On as re,Pc as ie,Pn as ae,Qo as G,Rn as oe,Sl as se,Sn as K,Ss as q,Tn as ce,Un as le,Uo as ue,Vs as de,Vt as fe,Wn as pe,Wo as me,Wr as he,Xc as ge,Xn as _e,Yn as ve,Yo as ye,Ys as be,Zn as xe,_u as Se,as as Ce,bn as we,cs as J,dc as Te,es as Ee,gc as De,hu as Oe,jl as ke,jn as Ae,js as je,jt as Me,ju as Ne,kn as Pe,ms as Fe,no as Ie,oc as Le,os as Y,ps as Re,qn as ze,qo as Be,rl as X,ro as Ve,tl as He,to as Ue,tr as We,ts as Ge,vl as Ke,wn as qe,ws as Je,xn as Ye,xs as Xe,yc as Ze,yn as Qe,zc as $e,zn as et,zt as tt}from"./index-CGwuxvzr.js";import{n as nt,r as rt}from"./settings-page-layout-bSliH-Y3.js";import{t as it}from"./settings-loading-skeleton-08Ae5sB_.js";import{c as at,d as ot,i as st,l as ct,n as lt,o as ut,r as dt,s as ft,t as pt,u as mt}from"./voice-api-key-field-DzEpwYaU.js";import{t as ht}from"./settings-advanced-gate-1Yck1PKq.js";import{n as gt,t as _t}from"./settings-form-section-GSNlQWSW.js";import{t as vt}from"./page-tabs-DR2FGC4E.js";import{n as yt,r as bt,t as xt}from"./save-bar-controls-DCWpFnPc.js";var Z=n(),Q=e(t(),1),$=r(),St={en:{title:`Image generation`,intro:`Choose an agent and a built-in provider. One action stores the credential and enables the model.`,agent:`Agent`,provider:`Provider`,model:`Model`,apiKey:`API key`,apiKeyHint:`Stored in the local credential store, never in xopc.json.`,existingKey:`A credential or environment variable is already available. Leave this blank to reuse it.`,region:`Service region`,cn:`China`,intl:`International`,advanced:`Custom endpoint`,baseUrl:`Base URL (optional)`,enable:`Enable image generation`,enabling:`Verifying and enabling…`,enabled:`Image generation is ready.`,enabledWithoutVerify:`Image generation is enabled. This provider does not expose a lightweight credential check.`,current:`Current`,configured:`Credential ready`,needsKey:`API key required`,connect:`Connect to a gateway to continue.`,loadError:`Unable to load image generation settings.`,selectAgent:`Select an agent`,selectModel:`Select a model`,show:`Show key`,hide:`Hide key`,copy:`Copy key`,copied:`Copied`},zh:{title:`图片生成`,intro:`选择 Agent 和内置 Provider,一次操作完成凭据保存与模型启用。`,agent:`Agent`,provider:`Provider`,model:`模型`,apiKey:`API Key`,apiKeyHint:`密钥只保存在本机凭据存储中,不会写入 xopc.json。`,existingKey:`已有凭据或环境变量;留空即可继续使用。`,region:`服务地域`,cn:`中国站`,intl:`国际站`,advanced:`自定义服务地址`,baseUrl:`Base URL(可选)`,enable:`启用图片生成`,enabling:`正在验证并启用…`,enabled:`图片生成已可用。`,enabledWithoutVerify:`图片生成已启用;该 Provider 暂无轻量凭据验证接口。`,current:`当前使用`,configured:`凭据已就绪`,needsKey:`需要 API Key`,connect:`请先连接网关。`,loadError:`无法加载图片生成设置。`,selectAgent:`选择 Agent`,selectModel:`选择模型`,show:`显示密钥`,hide:`隐藏密钥`,copy:`复制密钥`,copied:`已复制`}};async function Ct(){let e=await h(m(`/api/image-generation/catalog`));if(!Array.isArray(e.payload?.providers))throw Error(`Invalid image provider catalog`);return e.payload.providers}async function wt(e){let t=await h(m(`/api/agents/${encodeURIComponent(e)}/image-generation`));if(!t.payload)throw Error(`Invalid agent image generation response`);return t.payload}function Tt(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(0,t):void 0}function Et(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(t+1):void 0}function Dt(){let e=(0,Z.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Ve,{className:`h-24 rounded-xl`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`grid gap-4`,"aria-hidden":`true`,children:[t,(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:Array.from({length:5}).map(Ot)}),(0,$.jsx)(Ve,{className:`h-64 rounded-xl`})]}),e[1]=n):n=e[1],n}function Ot(e,t){return(0,$.jsx)(Ve,{className:`h-24 rounded-xl`},t)}function kt(){let e=f(e=>e.language),t=St[e],n=u(e),r=!!d(e=>e.token),[i,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``),[p,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(e===`zh`?`cn`:`intl`),[b,x]=(0,Q.useState)(``),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(),[E,D]=(0,Q.useState)(),{data:O,isLoading:k,error:A}=g(r?`image-generation-agents`:null,he,{revalidateOnFocus:!1}),{data:j,isLoading:M,error:N,mutate:P}=g(r?m(`/api/image-generation/catalog`):null,Ct,{revalidateOnFocus:!1});(0,Q.useEffect)(()=>{!O||i||a(O.defaultId||O.agents[0]?.id||``)},[i,O]);let{data:F,isLoading:I,error:L,mutate:R}=g(r&&i?[`agent-image-generation`,i]:null,()=>wt(i),{revalidateOnFocus:!1});(0,Q.useEffect)(()=>{if(!j||!F)return;let e=Tt(F.model?.primary),t=j.find(t=>t.id===e)??j.find(e=>e.configured)??j[0];t&&(s(t.id),l(t.id===e&&Et(F.model?.primary)||t.defaultModel),_(``))},[F,j]),(0,Q.useEffect)(()=>{T(void 0),D(void 0)},[i]);let z=j?.find(e=>e.id===o),B=(0,Q.useMemo)(()=>(O?.agents??[]).map(e=>({value:e.id,label:V(e,n.agentsSettings)})),[O?.agents,n.agentsSettings]),H=(0,Q.useMemo)(()=>(z?.models??[]).map(e=>({value:e,label:e})),[z?.models]),U=F?.model?.primary,ee=!!(i&&z&&c&&(z.configured||p.trim()));if(!r)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.connect});if(k||M||I)return(0,$.jsx)(Dt,{});if(A||N||L||!j||!O)return(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:t.loadError});let te=e=>{s(e.id),l(e.defaultModel),_(``),x(``),T(void 0),D(void 0)},ne=async()=>{if(!(!z||!ee)){C(!0),T(void 0),D(void 0);try{let e=await h(m(`/api/agents/${encodeURIComponent(i)}/image-generation/setup`),{method:`POST`,body:JSON.stringify({providerId:z.id,modelId:c,...p.trim()?{apiKey:p.trim()}:{},...z.requiresRegion?{region:v}:{},...b.trim()?{baseUrl:b.trim()}:{}})});if(!e.payload)throw Error(`Invalid setup response`);await Promise.all([R(e.payload.agent,{revalidate:!1}),P(e.payload.providers,{revalidate:!1})]),_(``),D(e.payload.verification.supported?t.enabled:t.enabledWithoutVerify)}catch(e){T(e instanceof Error?e.message:String(e))}finally{C(!1)}}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(`div`,{className:`rounded-lg bg-accent/10 p-2 text-accent`,children:(0,$.jsx)(se,{className:`size-5`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:t.intro})]})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[t.agent,(0,$.jsx)(Ce,{value:i,options:B,placeholder:t.selectAgent,allowEmpty:!1,onChange:a,triggerClassName:`mt-1.5 max-w-md`})]})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:t.provider}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:j.map(e=>{let n=e.id===o,r=e.id===Tt(U);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>te(e),className:`rounded-xl border p-4 text-left transition-colors ${n?`border-accent bg-accent/5 ring-1 ring-accent/20`:`border-edge bg-surface-base hover:border-edge-strong`}`,children:[(0,$.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:e.label}),r?(0,$.jsx)(`span`,{className:`rounded-full bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent`,children:t.current}):null]}),(0,$.jsxs)(`span`,{className:`mt-2 flex items-center gap-1.5 text-xs ${e.configured?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`}`,children:[e.configured?(0,$.jsx)(Oe,{className:`size-3.5`}):(0,$.jsx)(Ke,{className:`size-3.5`}),e.configured?t.configured:t.needsKey]})]},e.id)})})]}),z?(0,$.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:[(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[t.model,(0,$.jsx)(Ce,{value:c,options:H,placeholder:t.selectModel,allowEmpty:!1,onChange:l,triggerClassName:`mt-1.5`})]}),z.requiresRegion?(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[t.region,(0,$.jsx)(Ce,{value:v,options:[{value:`cn`,label:t.cn},{value:`intl`,label:t.intl}],placeholder:t.region,allowEmpty:!1,onChange:e=>y(e),triggerClassName:`mt-1.5`})]}):null]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[t.apiKey,(0,$.jsx)(Je,{value:p,onChange:_,placeholder:z.configured?t.existingKey:t.needsKey,labels:{show:t.show,hide:t.hide,copy:t.copy,copied:t.copied},className:`mt-1.5`,autoComplete:`new-password`}),(0,$.jsx)(`span`,{className:`mt-1.5 block font-normal leading-relaxed text-fg-subtle`,children:z.configured?t.existingKey:t.apiKeyHint})]}),(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge bg-surface-subtle px-3 py-2.5`,children:[(0,$.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 text-sm font-medium text-fg-muted`,children:[(0,$.jsx)(Te,{className:`size-4`}),t.advanced]}),(0,$.jsxs)(`label`,{className:`mt-3 block text-xs font-medium text-fg-muted`,children:[t.baseUrl,(0,$.jsx)(`input`,{value:b,onChange:e=>x(e.target.value),placeholder:`https://…`,className:`mt-1.5 h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`})]})]}),w?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:w}):null,E?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-400`,children:E}):null,(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(W,{variant:`primary`,disabled:!ee||S,onClick:()=>void ne(),children:[S?(0,$.jsx)(X,{className:`size-4 animate-spin`}):(0,$.jsx)(Oe,{className:`size-4`}),S?t.enabling:t.enable]})})]}):null]})}var At=v;function jt(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`groq`:return`(GROQ_API_KEY)`;default:return``}}function Mt(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`minimax`:return`(MINIMAX_API_KEY)`;default:return``}}function Nt(){return l(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,U,`dark:border-edge`)}function Pt(){return l(je,v)}function Ft(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function It(e,t){let n=window.atob(e),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return URL.createObjectURL(new Blob([r],{type:t}))}var Lt=[{id:`paraformer-v2`,name:`Paraformer v2`},{id:`paraformer-v1`,name:`Paraformer v1`}],Rt=[{id:`whisper-1`,name:`Whisper-1`}],zt=[{id:`whisper-large-v3-turbo`,name:`Whisper Large v3 Turbo`},{id:`whisper-large-v3`,name:`Whisper Large v3`}],Bt=[{id:`tts-1`,name:`TTS-1`},{id:`tts-1-hd`,name:`TTS-1 HD`}],Vt=[{id:`alloy`,name:`Alloy`},{id:`echo`,name:`Echo`}],Ht=[{id:`qwen-tts`,name:`Qwen TTS`},{id:`qwen3-tts-flash`,name:`Qwen3 TTS Flash`}],Ut=[{id:`Cherry`,name:`Cherry`},{id:`longxiaochun`,name:`Long Xiao Chun`}],Wt=[{id:`en-US-MichelleNeural`,name:`Michelle (US English)`},{id:`zh-CN-XiaoxiaoNeural`,name:`Xiaoxiao (Chinese)`}],Gt=[{id:`speech-2.8-hd`,name:`Speech 2.8 HD (Recommended)`},{id:`speech-2.8-turbo`,name:`Speech 2.8 Turbo (Fast)`}],Kt=[{id:`male-qn-qingse`,name:`Male Qingse (青涩男声)`},{id:`female-shaonv`,name:`Female Shaonv (少女音)`}],qt=[{id:`piper`,command:`piper --model /path/to/voice.onnx --output_file "{{OutputPath}}"`,outputFormat:`wav`},{id:`sherpa-onnx`,command:`sherpa-onnx-offline-tts --text "{{Text}}" --output-filename "{{OutputPath}}"`,outputFormat:`wav`},{id:`mlx-audio`,command:`python -m mlx_audio.tts.generate --text "{{Text}}" --file_prefix "{{OutputBase}}"`,outputFormat:`wav`}];function Jt(e,t){switch(e){case`xopc-local`:return t.stt.localProvider;case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function Yt(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 Xt(e,t){switch(e){case`off`:return t.tts.triggerOff;case`always`:return t.tts.triggerAlways;case`inbound`:return t.tts.triggerInbound;case`tagged`:return t.tts.triggerTagged}}function Zt(e,t){switch(e){case`edge`:return t.tts.providerHints.edge;case`openai`:return t.tts.providerHints.openai;case`alibaba`:return t.tts.providerHints.alibaba;case`minimax`:return t.tts.providerHints.minimax;case`tts-local-cli`:return t.tts.providerHints.localCli;default:return t.tts.providerHints.generic}}function Qt(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function $t(e,t){let n=e[t.key];return typeof n==`string`||typeof n==`number`||typeof n==`boolean`?n:t.defaultValue===void 0?t.type===`boolean`?!1:``:t.defaultValue}function en(e,t){if(e.type===`boolean`)return!!t;if(e.type!==`number`)return t;let n=String(t).trim();if(!n)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function tn(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 nn(){let e=f(e=>e.language),t=u(e).voiceSettings,n=!!d(e=>e.token),[r,i]=(0,Q.useReducer)(tn,{form:null,baseline:null}),a=r.form,o=r.baseline,[s,c]=(0,Q.useState)(null),[l,p]=(0,Q.useState)(!1),[h,_]=(0,Q.useState)(null),v=(0,Q.useRef)(!1),y=(0,Q.useRef)({parsed:null,models:void 0}),{data:b,error:x,isLoading:S,mutate:C}=Ie(n),{data:w,error:T,isLoading:E,mutate:D}=g(n?m(`/api/voice/models`):null,dt,{revalidateOnFocus:!1}),{data:O,error:k,isLoading:A}=g(n?m(`/api/voice/providers`):null,st,{revalidateOnFocus:!1}),{data:j,error:M,isLoading:N}=g(n?m(`/api/voice/stt-providers`):null,ut,{revalidateOnFocus:!1}),P=(0,Q.useMemo)(()=>O?.providers??[],[O]),F=(0,Q.useMemo)(()=>j?.providers??[],[j]),I=(0,Q.useMemo)(()=>b?.payload?.config===void 0?null:at(b.payload.config),[b]),L=(0,Q.useMemo)(()=>!a||!o?!1:JSON.stringify(a)!==JSON.stringify(o),[a,o]);n?I!==null&&w!==void 0&&!v.current&&(y.current.parsed!==I||y.current.models!==w)&&(y.current={parsed:I,models:w},i({type:`sync`,value:I}),c(w)):(y.current.parsed!==null||y.current.models!==void 0)&&(y.current={parsed:null,models:void 0},i({type:`reset`}),c(null),v.current=!1);let R=!!(n&&(I===null||w===void 0||O===void 0||j===void 0)&&(S||E||A||N)),z=x instanceof Error?x.message:x?String(x):T instanceof Error?T.message:T?String(T):k instanceof Error?k.message:k?String(k):M instanceof Error?M.message:M?String(M):null,B=(0,Q.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e}}:null})},[]),V=(0,Q.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,stt:{...t.stt,alibaba:{...t.stt.alibaba,...e}}}:null})},[]),H=(0,Q.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,stt:{...t.stt,openai:{...t.stt.openai,...e}}}:null})},[]),U=(0,Q.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!1,order:[`xopc-local`]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}}})},[]),ee=(0,Q.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,voice:{...t.voice,input:{...t.voice.input,refinement:{...t.voice.input.refinement,...e}}}}:null})},[]),te=(0,Q.useCallback)(t=>{v.current=!0,i({type:`update`,updater:n=>n?{...n,voice:{...n.voice,languageMode:t,...t===`auto`?{language:e}:{}}}:null})},[e]),ne=(0,Q.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),re=(0,Q.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,tts:{...t.tts,alibaba:{...t.tts.alibaba,...e}}}:null})},[]),ie=(0,Q.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,tts:{...t.tts,openai:{...t.tts.openai,...e}}}:null})},[]),ae=(0,Q.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,voice:e.voice!==void 0||e.lang!==void 0?{...t.voice,languageMode:`manual`}:t.voice,tts:{...t.tts,edge:{...t.tts.edge,...e}}}:null})},[]),G=(0,Q.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,tts:{...t.tts,minimax:{...t.tts.minimax,...e}}}:null})},[]),oe=(0,Q.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,tts:{...t.tts,"tts-local-cli":{...t.tts[`tts-local-cli`],...e}}}:null})},[]);if(yt({id:`voice`,dirty:L,saving:l,save:(0,Q.useCallback)(async()=>{if(!(!a||l)){p(!0),_(null);try{await ct(a),i({type:`saved`,value:a}),v.current=!1}catch(e){_(e instanceof Error?e.message:t.saveError)}finally{p(!1)}}},[a,l,t.saveError]),discard:(0,Q.useCallback)(()=>{o&&(v.current=!1,i({type:`discard`}),_(null))},[o])}),!n)return(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})});if(R)return(0,$.jsx)(it,{rows:4});if(!a||s===null)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:h??z??t.loadError}),(0,$.jsx)(W,{type:`button`,variant:`secondary`,onClick:()=>{C(),D()},children:t.retry})]});let se=a.stt,K=a.tts,q=a.voice.input.refinement,ce=Qt(t);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[h?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:h}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(rn,{v:t,voice:a.voice,updateLanguageMode:te}),(0,$.jsx)(an,{v:t,stt:se,tts:K}),(0,$.jsx)(sn,{v:t,apiKeyLabels:ce,stt:se,models:s,sttProviders:F,refinement:q,updateStt:B,updateSttAlibaba:V,updateSttOpenai:H,updateSttFallback:U,updateRefinement:ee}),(0,$.jsx)(hn,{v:t,apiKeyLabels:ce,tts:K,models:s,ttsProviders:P,updateTts:ne,updateTtsAlibaba:re,updateTtsOpenai:ie,updateTtsEdge:ae,updateTtsMinimax:G,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:t.notes.title}),` `,t.notes.duration]}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.notes.envVars})]})]})}function rn(e){let t=(0,Z.c)(22),{v:n,voice:r,updateLanguageMode:i}=e,a;t[0]===n.language.title?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.language.title}),t[0]=n.language.title,t[1]=a);let o=r.languageMode===`auto`?n.language.autoDescription:n.language.manualDescription,s;t[2]===o?s=t[3]:(s=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o}),t[2]=o,t[3]=s);let c;t[4]!==a||t[5]!==s?(c=(0,$.jsxs)(`div`,{children:[a,s]}),t[4]=a,t[5]=s,t[6]=c):c=t[6];let l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=Pt(),t[7]=l):l=t[7];let u;t[8]===i?u=t[9]:(u=e=>i(e.target.value),t[8]=i,t[9]=u);let d;t[10]===n.language.auto?d=t[11]:(d=(0,$.jsx)(J,{value:`auto`,children:n.language.auto}),t[10]=n.language.auto,t[11]=d);let f;t[12]===n.language.manual?f=t[13]:(f=(0,$.jsx)(J,{value:`manual`,children:n.language.manual}),t[12]=n.language.manual,t[13]=f);let p;t[14]!==u||t[15]!==d||t[16]!==f||t[17]!==r.languageMode?(p=(0,$.jsxs)(Y,{className:l,value:r.languageMode,onChange:u,children:[d,f]}),t[14]=u,t[15]=d,t[16]=f,t[17]=r.languageMode,t[18]=p):p=t[18];let m;return t[19]!==c||t[20]!==p?(m=(0,$.jsx)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(12rem,18rem)] sm:items-center`,children:[c,p]})}),t[19]=c,t[20]=p,t[21]=m):m=t[21],m}function an(e){let t=(0,Z.c)(39),{v:n,stt:r,tts:i}=e,a=i.provider===`openai`?i.openai?.voice:i.provider===`alibaba`?i.alibaba?.voice:i.provider===`minimax`?i.minimax?.voice:i.provider===`edge`?i.edge?.voice:void 0,o;t[0]===n.overview.title?o=t[1]:(o=(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.overview.title}),t[0]=n.overview.title,t[1]=o);let s;t[2]===n.overview.description?s=t[3]:(s=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.overview.description}),t[2]=n.overview.description,t[3]=s);let c;t[4]!==o||t[5]!==s?(c=(0,$.jsxs)(`div`,{className:`mb-4`,children:[o,s]}),t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;t[7]!==r.enabled||t[8]!==r.provider||t[9]!==n?(l=r.enabled?`${n.overview.ready} · ${Jt(r.provider,n)}`:n.overview.off,t[7]=r.enabled,t[8]=r.provider,t[9]=n,t[10]=l):l=t[10];let u;t[11]!==r.enabled||t[12]!==l||t[13]!==n.overview.input?(u=(0,$.jsx)(on,{label:n.overview.input,value:l,ready:r.enabled}),t[11]=r.enabled,t[12]=l,t[13]=n.overview.input,t[14]=u):u=t[14];let d;t[15]!==i.enabled||t[16]!==i.trigger||t[17]!==n?(d=i.enabled?Xt(i.trigger,n):n.overview.off,t[15]=i.enabled,t[16]=i.trigger,t[17]=n,t[18]=d):d=t[18];let f=i.enabled&&i.trigger!==`off`,p;t[19]!==d||t[20]!==f||t[21]!==n.overview.replies?(p=(0,$.jsx)(on,{label:n.overview.replies,value:d,ready:f}),t[19]=d,t[20]=f,t[21]=n.overview.replies,t[22]=p):p=t[22];let m;t[23]!==a||t[24]!==i.enabled||t[25]!==i.provider||t[26]!==n?(m=i.enabled?`${Yt(i.provider,n)}${a?` · ${a}`:``}`:n.overview.off,t[23]=a,t[24]=i.enabled,t[25]=i.provider,t[26]=n,t[27]=m):m=t[27];let h;t[28]!==m||t[29]!==i.enabled||t[30]!==n.overview.voice?(h=(0,$.jsx)(on,{label:n.overview.voice,value:m,ready:i.enabled}),t[28]=m,t[29]=i.enabled,t[30]=n.overview.voice,t[31]=h):h=t[31];let g;t[32]!==h||t[33]!==u||t[34]!==p?(g=(0,$.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[u,p,h]}),t[32]=h,t[33]=u,t[34]=p,t[35]=g):g=t[35];let _;return t[36]!==g||t[37]!==c?(_=(0,$.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[c,g]}),t[36]=g,t[37]=c,t[38]=_):_=t[38],_}function on(e){let t=(0,Z.c)(10),{label:n,value:r,ready:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-xs text-fg-muted`,children:n}),t[0]=n,t[1]=a);let o=i?`text-fg`:`text-fg-muted`,s;t[2]===o?s=t[3]:(s=l(`mt-1 text-sm font-medium`,o),t[2]=o,t[3]=s);let c;t[4]!==s||t[5]!==r?(c=(0,$.jsx)(`div`,{className:s,children:r}),t[4]=s,t[5]=r,t[6]=c):c=t[6];let u;return t[7]!==a||t[8]!==c?(u=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[a,c]}),t[7]=a,t[8]=c,t[9]=u):u=t[9],u}function sn(e){let t=(0,Z.c)(49),{v:n,apiKeyLabels:r,stt:i,models:a,sttProviders:o,refinement:s,updateStt:c,updateSttAlibaba:u,updateSttOpenai:d,updateSttFallback:f,updateRefinement:p}=e,m=a?.stt?.alibaba?.length?a.stt.alibaba:Lt,h=a?.stt?.openai?.length?a.stt.openai:Rt,g;if(t[0]!==o){let e=new Set;g=[];for(let t of o)e.has(t.id)||(e.add(t.id),g.push(t));t[0]=o,t[1]=g}else g=t[1];let _=g,v,y,b,x,S;if(t[2]!==m||t[3]!==r||t[4]!==a?.stt||t[5]!==h||t[6]!==_||t[7]!==s||t[8]!==i||t[9]!==p||t[10]!==c||t[11]!==u||t[12]!==f||t[13]!==d||t[14]!==n){let e=_.find(e=>e.id===i.provider),o=i.providers?.[i.provider],g=typeof o?.apiKey==`string`?o.apiKey:``,C=typeof o?.model==`string`?o.model:``,w={...i.provider===`alibaba`?i.alibaba??{}:{},...i.provider===`openai`?i.openai??{}:{},...o??{}},T=(e?.fields??[]).filter(fn),E;t[20]!==i.provider||t[21]!==i.providers||t[22]!==c?(E=e=>{c({providers:{...i.providers??{},[i.provider]:{...i.providers?.[i.provider]??{},...e}}})},t[20]=i.provider,t[21]=i.providers,t[22]=c,t[23]=E):E=t[23];let D=E;x=`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`;let O;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(ge,{className:`size-4 text-accent`,strokeWidth:1.75}),t[24]=O):O=t[24];let k;t[25]===n.stt.title?k=t[26]:(k=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[O,n.stt.title]}),t[25]=n.stt.title,t[26]=k);let A;t[27]===n.stt.description?A=t[28]:(A=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[27]=n.stt.description,t[28]=A),t[29]!==k||t[30]!==A?(S=(0,$.jsxs)(`div`,{className:`mb-4`,children:[k,A]}),t[29]=k,t[30]=A,t[31]=S):S=t[31],v=`space-y-4`;let j;t[32]===c?j=t[33]:(j=e=>c({enabled:e}),t[32]=c,t[33]=j),t[34]!==i.enabled||t[35]!==j||t[36]!==n.overview.off||t[37]!==n.overview.ready||t[38]!==n.stt.enable||t[39]!==n.stt.enableDesc?(y=(0,$.jsx)(gn,{checked:i.enabled,title:n.stt.enable,description:n.stt.enableDesc,onLabel:n.overview.ready,offLabel:n.overview.off,onChange:j}),t[34]=i.enabled,t[35]=j,t[36]=n.overview.off,t[37]=n.overview.ready,t[38]=n.stt.enable,t[39]=n.stt.enableDesc,t[40]=y):y=t[40],b=i.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,At),children:[(0,$.jsx)(yn,{children:n.stt.provider}),(0,$.jsx)(Y,{className:Pt(),value:i.provider,onChange:e=>c({provider:e.target.value}),children:_.map(e=>(0,$.jsxs)(J,{value:e.id,children:[Jt(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,$.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,At),children:[(0,$.jsx)(yn,{children:n.stt.model}),i.provider===`xopc-local`?(0,$.jsx)(Y,{className:Pt(),value:C||`sensevoice-small`,onChange:e=>D({model:e.target.value}),children:(a?.stt?.[`xopc-local`]??[]).map(dn)}):i.provider===`alibaba`?(0,$.jsx)(Y,{className:Pt(),value:i.alibaba?.model??``,onChange:e=>u({model:e.target.value}),children:m.map(un)}):i.provider===`openai`?(0,$.jsx)(Y,{className:Pt(),value:i.openai?.model??``,onChange:e=>d({model:e.target.value}),children:h.map(ln)}):i.provider===`groq`?(0,$.jsx)(Y,{className:Pt(),value:C||zt[0].id,onChange:e=>D({model:e.target.value}),children:zt.map(cn)}):(0,$.jsx)(`input`,{className:Nt(),value:C,onChange:e=>D({model:e.target.value}),placeholder:i.provider})]}),e?.diagnostics.requiresApiKey===!1?null:(0,$.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,At),children:[(0,$.jsx)(yn,{children:n.stt.apiKey}),(0,$.jsx)(pt,{kind:`stt`,providerId:i.provider,fieldId:`voice-stt-${i.provider}-api-key`,value:i.provider===`alibaba`?i.alibaba?.apiKey??``:i.provider===`openai`?i.openai?.apiKey??``:g,onChange:e=>{i.provider===`alibaba`?u({apiKey:e}):i.provider===`openai`?d({apiKey:e}):D({apiKey:e})},labels:r,placeholder:i.provider===`groq`?`gsk_...`:`sk-...`}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.stt.apiKeyDesc,jt(i.provider)?` ${jt(i.provider)}`:``]})]})]}),T.length>0?(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:T.map(e=>(0,$.jsx)(_n,{field:e,value:$t(w,e),onChange:t=>D({[e.key]:t}),className:e.type===`textarea`?`sm:col-span-2`:At},e.key))}):null,i.provider===`xopc-local`?(0,$.jsx)(mn,{v:n}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.fallback}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.fallbackDesc})]}),(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:i.fallback?.enabled??!1,onChange:e=>f({enabled:e.target.checked})})]}),(0,$.jsxs)(`div`,{className:`grid gap-3 rounded-xl bg-surface-hover/50 p-3 dark:bg-surface-hover/35 sm:grid-cols-[minmax(0,1fr)_minmax(12rem,18rem)] sm:items-center`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.refinement}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.refinementDesc})]}),(0,$.jsxs)(Y,{className:Pt(),value:s.mode,onChange:e=>p({mode:e.target.value}),children:[(0,$.jsx)(J,{value:`off`,children:n.stt.refinementOff}),(0,$.jsx)(J,{value:`punctuation`,children:n.stt.refinementPunctuation}),(0,$.jsx)(J,{value:`light`,children:n.stt.refinementLight})]})]})]}):null,t[2]=m,t[3]=r,t[4]=a?.stt,t[5]=h,t[6]=_,t[7]=s,t[8]=i,t[9]=p,t[10]=c,t[11]=u,t[12]=f,t[13]=d,t[14]=n,t[15]=v,t[16]=y,t[17]=b,t[18]=x,t[19]=S}else v=t[15],y=t[16],b=t[17],x=t[18],S=t[19];let C;t[41]!==v||t[42]!==y||t[43]!==b?(C=(0,$.jsxs)(`div`,{className:v,children:[y,b]}),t[41]=v,t[42]=y,t[43]=b,t[44]=C):C=t[44];let w;return t[45]!==x||t[46]!==S||t[47]!==C?(w=(0,$.jsxs)(`section`,{className:x,children:[S,C]}),t[45]=x,t[46]=S,t[47]=C,t[48]=w):w=t[48],w}function cn(e){return(0,$.jsx)(J,{value:e.id,children:e.name},e.id)}function ln(e){return(0,$.jsx)(J,{value:e.id,children:e.name},e.id)}function un(e){return(0,$.jsx)(J,{value:e.id,children:e.name},e.id)}function dn(e){return(0,$.jsx)(J,{value:e.id,children:e.name},e.id)}function fn(e){return e.key!==`apiKey`&&e.key!==`model`}function pn(e){return`${Math.round(e/1024/1024)} MB`}function mn({v:e}){let{data:t,error:n,mutate:r}=g(m(`/api/voice/local/status`),lt,{revalidateOnFocus:!1,refreshInterval:e=>e?.models.some(e=>e.state===`downloading`)?1e3:0}),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(null),c=(0,Q.useCallback)(async(e,t)=>{a(e.id),s(null);try{t===`install`?await ft(e.id):await mt(e.id),await r()}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(null)}},[r]);return(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel/60 p-3`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.stt.localModels}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.stt.localModelsDesc}),n?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-red-600 dark:text-red-400`,children:String(n)}):null,o?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-red-600 dark:text-red-400`,children:o}):null,(0,$.jsx)(`div`,{className:`mt-3 grid gap-2`,children:(t?.models??[]).map(t=>{let n=i===t.id||t.state===`downloading`;return(0,$.jsxs)(`div`,{className:l(`flex items-center justify-between gap-3 rounded-lg bg-surface-base px-3 py-2.5`,t.recommended?`ring-1 ring-accent/40`:``),children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm font-medium text-fg`,children:[t.name,t.recommended?(0,$.jsx)(`span`,{className:`rounded-full bg-accent/10 px-2 py-0.5 text-[10px] font-medium text-accent`,children:e.stt.localRecommended}):null]}),(0,$.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[pn(t.approximateBytes),` · `,t.description]}),(0,$.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-fg-subtle`,children:[t.engine,` · `,t.languages.join(` / `)]}),t.state===`downloading`?(0,$.jsxs)(`div`,{className:`mt-1 text-xs text-accent`,children:[e.stt.localDownloading,` `,Math.round((t.progress??0)*100),`%`]}):t.state===`error`?(0,$.jsx)(`div`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:t.error}):null]}),(0,$.jsx)(W,{type:`button`,variant:`secondary`,disabled:n,onClick:()=>void c(t,t.state===`ready`?`remove`:`install`),children:n?(0,$.jsx)(X,{className:`size-4 animate-spin`}):t.state===`ready`?e.stt.localRemove:e.stt.localInstall})]},t.id)})})]})}function hn({v:e,apiKeyLabels:t,tts:n,models:r,ttsProviders:i,updateTts:a,updateTtsAlibaba:o,updateTtsOpenai:s,updateTtsEdge:c,updateTtsMinimax:u,updateTtsLocalCli:d}){let f=r?.tts?.openai?.length?r.tts.openai:Bt,p=r?.ttsVoices?.openai?.length?r.ttsVoices.openai:Vt,m=r?.tts?.alibaba?.length?r.tts.alibaba:Ht,h=r?.ttsVoices?.alibaba?.length?r.ttsVoices.alibaba:Ut,g=r?.ttsVoices?.edge?.length?r.ttsVoices.edge:Wt,_=r?.tts?.minimax?.length?r.tts.minimax:Gt,v=r?.ttsVoices?.minimax?.length?r.ttsVoices.minimax:Kt,[y,x]=(0,Q.useState)(e.tts.test.sampleText),[S,C]=(0,Q.useState)({status:`idle`}),w=(0,Q.useRef)(null),T=(0,Q.useRef)(null),E=(0,Q.useCallback)(()=>{w.current?.pause(),w.current=null,T.current&&=(URL.revokeObjectURL(T.current),null)},[]),D=(0,Q.useMemo)(()=>{let e=new Set,t=[];for(let n of i)e.has(n.id)||(e.add(n.id),t.push(n));return t},[i]),k=D.find(e=>e.id===n.provider),A=n.providers?.[n.provider],j={...n.provider===`openai`?n.openai??{}:{},...n.provider===`alibaba`?n.alibaba??{}:{},...n.provider===`edge`?n.edge??{}:{},...n.provider===`minimax`?n.minimax??{}:{},...n.provider===`tts-local-cli`?n[`tts-local-cli`]??{}:{},...A??{}},M=(k?.fields??[]).filter(e=>![`apiKey`,`model`,`voice`].includes(e.key)),N=!!k?.diagnostics.requiresApiKey,P=!!k?.configured||!N,F=n.enabled?P?`ready`:`action`:`muted`,I=n.provider===`openai`?n.openai?.model:n.provider===`alibaba`?n.alibaba?.model:n.provider===`minimax`?n.minimax?.model:void 0,L=n.provider===`openai`?n.openai?.voice:n.provider===`alibaba`?n.alibaba?.voice:n.provider===`minimax`?n.minimax?.voice:n.provider===`edge`?n.edge?.voice:void 0;(0,Q.useEffect)(()=>()=>E(),[E]);let R=(0,Q.useCallback)(e=>{a({provider:e}),C({status:`idle`})},[a]),z=(0,Q.useCallback)(async()=>{let t=y.trim();if(!t){C({status:`error`,message:e.tts.test.emptyText});return}E(),C({status:`loading`});try{let r=await ot({text:t,provider:n.provider,providerConfig:j,...I?{model:I}:{},...L?{voice:L}:{}}),i=It(r.audio,r.mimeType);T.current=i;let a=new Audio(i);w.current=a;let o=[r.provider,r.format,r.latencyMs===void 0?void 0:`${r.latencyMs}ms`,Ft(r.audioSize)].filter(Boolean).join(` · `);a.addEventListener(`ended`,()=>C({status:`done`,summary:o}),{once:!0}),a.addEventListener(`error`,()=>C({status:`error`,message:e.tts.test.playFailed}),{once:!0}),await a.play(),C({status:`playing`,summary:o})}catch(e){E(),C({status:`error`,message:e instanceof Error?e.message:String(e)})}},[I,L,j,E,y,n.provider,e.tts.test.emptyText,e.tts.test.playFailed]),B=(0,Q.useCallback)(e=>{a({providers:{...n.providers??{},[n.provider]:{...n.providers?.[n.provider]??{},...e}}})},[n.provider,n.providers,a]),V=(0,Q.useCallback)((e,t)=>{let r={[e.key]:t};B(r),n.provider===`openai`&&e.key===`baseUrl`?s(r):n.provider===`minimax`&&(e.key===`baseUrl`||e.key===`groupId`)?u(r):n.provider===`edge`&&e.key===`lang`&&c(r)},[n.provider,B,c,u,s]);return(0,$.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[(0,$.jsxs)(`div`,{className:`mb-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(b,{className:`size-4 text-accent`,strokeWidth:1.75}),e.tts.title]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.description})]}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(gn,{checked:n.enabled,title:e.tts.enable,description:e.tts.enableDesc,onLabel:e.overview.ready,offLabel:e.overview.off,onChange:e=>a({enabled:e})}),(0,$.jsxs)(`div`,{className:l(`rounded-xl border px-3 py-2.5 text-sm`,F===`ready`?`border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-100`:F===`action`?`border-amber-300/50 bg-amber-50 text-amber-900 dark:border-amber-300/30 dark:bg-amber-400/10 dark:text-amber-100`:`border-edge bg-surface-panel text-fg-muted`),children:[(0,$.jsx)(`div`,{className:`font-medium text-fg`,children:e.tts.statusTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs`,children:n.enabled?P?`${e.tts.statusReady} ${Yt(n.provider,e)}${L?` · ${L}`:``}`:`${e.tts.statusNeedsSetup} ${Yt(n.provider,e)} · ${k?.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.statusOff})]}),n.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,At),children:[(0,$.jsx)(yn,{children:e.tts.trigger}),(0,$.jsxs)(Y,{className:Pt(),value:n.trigger,onChange:e=>a({trigger:e.target.value}),children:[(0,$.jsx)(J,{value:`off`,children:e.tts.triggerOff}),(0,$.jsx)(J,{value:`inbound`,children:e.tts.triggerInbound}),(0,$.jsx)(J,{value:`tagged`,children:e.tts.triggerTagged}),(0,$.jsx)(J,{value:`always`,children:e.tts.triggerAlways})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.triggerHelp})]}),(0,$.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,At),children:[(0,$.jsx)(yn,{children:e.tts.provider}),(0,$.jsx)(Y,{className:Pt(),value:n.provider,onChange:e=>R(e.target.value),children:D.map(t=>(0,$.jsx)(J,{value:t.id,children:Yt(t.id,e)},t.id))}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[k?.configured?e.tts.configured:k?.diagnostics.requiresApiKey?`${e.tts.needsKey} · ${k.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.noKeyNeeded,` · `,k?.description??Zt(n.provider,e)]})]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,open:!P||n.provider===`tts-local-cli`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg marker:text-fg-muted`,children:[e.tts.advanced.title,(0,$.jsx)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:e.tts.advanced.description})]}),(0,$.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[n.provider===`openai`||n.provider===`alibaba`||n.provider===`minimax`?(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,At),children:[(0,$.jsx)(yn,{children:e.stt.apiKey}),(0,$.jsx)(pt,{kind:`tts`,providerId:n.provider,fieldId:`voice-tts-${n.provider}-api-key`,value:n.provider===`openai`?n.openai?.apiKey??``:n.provider===`alibaba`?n.alibaba?.apiKey??``:n.minimax?.apiKey??``,onChange:e=>{n.provider===`openai`?s({apiKey:e}):n.provider===`alibaba`?o({apiKey:e}):u({apiKey:e})},labels:t,placeholder:n.provider===`minimax`?`eyJ...`:`sk-...`}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[e.stt.apiKeyDesc,Mt(n.provider)?` ${Mt(n.provider)}`:``]})]}),(0,$.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,At),children:[(0,$.jsx)(yn,{children:e.stt.model}),(0,$.jsx)(Y,{className:Pt(),value:n.provider===`openai`?n.openai?.model??``:n.provider===`alibaba`?n.alibaba?.model??``:n.minimax?.model??``,onChange:e=>{n.provider===`openai`?s({model:e.target.value}):n.provider===`alibaba`?o({model:e.target.value}):u({model:e.target.value})},children:(n.provider===`openai`?f:n.provider===`alibaba`?m:_).map(e=>(0,$.jsx)(J,{value:e.id,children:e.name},e.id))})]}),(0,$.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,At),children:[(0,$.jsx)(yn,{children:e.tts.voice}),(0,$.jsx)(Y,{className:Pt(),value:n.provider===`openai`?n.openai?.voice??``:n.provider===`alibaba`?n.alibaba?.voice??``:n.minimax?.voice??``,onChange:e=>{n.provider===`openai`?s({voice:e.target.value}):n.provider===`alibaba`?o({voice:e.target.value}):u({voice:e.target.value})},children:(n.provider===`openai`?p:n.provider===`alibaba`?h:v).map(e=>(0,$.jsx)(J,{value:e.id,children:e.name},e.id))})]})]}):null,n.provider===`edge`?(0,$.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,At),children:[(0,$.jsx)(yn,{children:e.tts.voice}),(0,$.jsx)(Y,{className:Pt(),value:n.edge?.voice??``,onChange:e=>c({voice:e.target.value}),children:g.map(e=>(0,$.jsx)(J,{value:e.id,children:e.name},e.id))}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.edgeHint})]}):null,n.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)(yn,{children:e.tts.localCli.preset}),(0,$.jsxs)(Y,{className:Pt(),value:``,onChange:e=>{let t=qt.find(t=>t.id===e.target.value);t&&d({command:t.command,outputFormat:t.outputFormat})},children:[(0,$.jsx)(J,{value:``,children:e.tts.localCli.presetPlaceholder}),qt.map(e=>(0,$.jsx)(J,{value:e.id,children:e.id},e.id))]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.presetDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,$.jsx)(yn,{children:e.tts.localCli.command}),(0,$.jsx)(`input`,{className:l(Nt(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:n[`tts-local-cli`]?.command??``,onChange:e=>d({command:e.target.value}),placeholder:e.tts.localCli.commandPlaceholder}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.commandDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(yn,{children:e.tts.localCli.cwd}),(0,$.jsx)(`input`,{className:l(Nt(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:n[`tts-local-cli`]?.cwd??``,onChange:e=>d({cwd:e.target.value}),placeholder:`/path/to/cwd`}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.cwdDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(yn,{children:e.tts.localCli.outputFormat}),(0,$.jsxs)(Y,{className:Pt(),value:n[`tts-local-cli`]?.outputFormat??`wav`,onChange:e=>d({outputFormat:e.target.value}),children:[(0,$.jsx)(J,{value:`wav`,children:`wav`}),(0,$.jsx)(J,{value:`mp3`,children:`mp3`}),(0,$.jsx)(J,{value:`opus`,children:`opus`})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.outputFormatDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,$.jsx)(yn,{children:e.tts.localCli.timeoutMs}),(0,$.jsx)(`input`,{className:Nt(),type:`number`,min:0,step:1e3,value:typeof n[`tts-local-cli`]?.timeoutMs==`number`?String(n[`tts-local-cli`].timeoutMs):``,onChange:e=>{let t=e.target.value.trim();if(t===``){d({timeoutMs:void 0});return}let n=Number(t);Number.isFinite(n)&&n>=0&&d({timeoutMs:n})},placeholder:`30000`}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.timeoutMsDesc})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:e.tts.localCli.hint})]}):null,M.length>0?(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:M.map(e=>(0,$.jsx)(_n,{field:e,value:$t(j,e),onChange:t=>V(e,t),className:e.type===`textarea`?`sm:col-span-2`:At},e.key))}):null]})]}),(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.tts.test.title}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.test.description})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,$.jsxs)(W,{type:`button`,variant:`primary`,onClick:()=>void z(),disabled:S.status===`loading`,className:`h-9`,children:[S.status===`loading`?(0,$.jsx)(X,{className:`size-4 animate-spin`}):(0,$.jsx)(O,{className:`size-4`}),S.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,$.jsxs)(W,{type:`button`,variant:`secondary`,onClick:()=>{E(),C(e=>e.status===`playing`?{status:`done`,summary:e.summary}:{status:`idle`})},disabled:S.status!==`playing`,className:`h-9`,children:[(0,$.jsx)(Le,{className:`size-4`}),e.tts.test.stop]})]})]}),(0,$.jsx)(`textarea`,{className:l(Nt(),`mt-3 min-h-20 resize-y`),value:y,onChange:e=>x(e.target.value),maxLength:1e3}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,$.jsxs)(`span`,{className:`text-fg-subtle`,children:[y.length,`/1000`]}),S.status===`playing`||S.status===`done`?(0,$.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-200`,children:[S.status===`playing`?e.tts.test.playing:e.tts.test.ready,` · `,S.summary]}):null,S.status===`error`?(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:S.message}):null]})]})]}):null]})]})}function gn(e){let t=(0,Z.c)(33),{checked:n,title:r,description:i,onLabel:a,offLabel:o,onChange:s}=e,c;t[0]!==n||t[1]!==s?(c=()=>s(!n),t[0]=n,t[1]=s,t[2]=c):c=t[2];let u=n?`bg-accent/10 text-fg ring-1 ring-accent/45 dark:bg-accent/15`:`bg-surface-panel/80 text-fg hover:bg-surface-hover`,d;t[3]===u?d=t[4]:(d=l(`group flex w-full items-center justify-between gap-4 rounded-2xl px-4 py-3 text-left shadow-surface transition-colors`,U,u),t[3]=u,t[4]=d);let f=n?`bg-accent text-white`:`bg-surface-hover text-fg-muted`,p;t[5]===f?p=t[6]:(p=l(`rounded-full px-2 py-0.5 text-[11px] font-medium`,f),t[5]=f,t[6]=p);let m=n?a:o,h;t[7]!==p||t[8]!==m?(h=(0,$.jsx)(`span`,{className:p,children:m}),t[7]=p,t[8]=m,t[9]=h):h=t[9];let g;t[10]!==h||t[11]!==r?(g=(0,$.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm font-semibold text-fg`,children:[r,h]}),t[10]=h,t[11]=r,t[12]=g):g=t[12];let _;t[13]===i?_=t[14]:(_=(0,$.jsx)(`span`,{className:`mt-1 block text-xs leading-relaxed text-fg-muted`,children:i}),t[13]=i,t[14]=_);let v;t[15]!==g||t[16]!==_?(v=(0,$.jsxs)(`span`,{className:`min-w-0`,children:[g,_]}),t[15]=g,t[16]=_,t[17]=v):v=t[17];let y=n?`border-accent bg-accent`:`border-edge bg-surface-hover group-hover:border-accent/40`,b;t[18]===y?b=t[19]:(b=l(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,y),t[18]=y,t[19]=b);let x=n?`translate-x-5`:`translate-x-0.5`,S;t[20]===x?S=t[21]:(S=l(`size-5 rounded-full bg-white shadow-surface transition-transform`,x),t[20]=x,t[21]=S);let C;t[22]===S?C=t[23]:(C=(0,$.jsx)(`span`,{className:S}),t[22]=S,t[23]=C);let w;t[24]!==b||t[25]!==C?(w=(0,$.jsx)(`span`,{className:b,"aria-hidden":!0,children:C}),t[24]=b,t[25]=C,t[26]=w):w=t[26];let T;return t[27]!==n||t[28]!==c||t[29]!==v||t[30]!==w||t[31]!==d?(T=(0,$.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":n,onClick:c,className:d,children:[v,w]}),t[27]=n,t[28]=c,t[29]=v,t[30]=w,t[31]=d,t[32]=T):T=t[32],T}function _n(e){let t=(0,Z.c)(36),{field:n,value:r,onChange:i,className:a}=e,o=`voice-schema-field-${n.key}`,s=n.description;if(n.type===`boolean`){let e;t[0]===a?e=t[1]:(e=l(`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,a),t[0]=a,t[1]=e);let o;t[2]===n.label?o=t[3]:(o=(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n.label}),t[2]=n.label,t[3]=o);let c;t[4]===s?c=t[5]:(c=s?(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:s}):null,t[4]=s,t[5]=c);let u;t[6]!==o||t[7]!==c?(u=(0,$.jsxs)(`span`,{children:[o,c]}),t[6]=o,t[7]=c,t[8]=u):u=t[8];let d=!!r,f;t[9]!==n||t[10]!==i?(f=e=>i(en(n,e.target.checked)),t[9]=n,t[10]=i,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 c=typeof r==`boolean`?``:String(r),u;t[19]===a?u=t[20]:(u=l(`flex flex-col gap-1.5`,a),t[19]=a,t[20]=u);let d;t[21]===n.label?d=t[22]:(d=(0,$.jsx)(yn,{children:n.label}),t[21]=n.label,t[22]=d);let f;t[23]!==a||t[24]!==n||t[25]!==c||t[26]!==o||t[27]!==i?(f=n.type===`select`?(0,$.jsx)(Y,{id:o,className:Pt(),value:c,required:n.required,onChange:e=>i(en(n,e.target.value)),children:(n.options??[]).map(vn)}):n.type===`textarea`?(0,$.jsx)(`textarea`,{id:o,className:l(Nt(),`min-h-24 resize-y`),value:c,required:n.required,placeholder:n.placeholder,onChange:e=>i(en(n,e.target.value))}):n.type===`password`?(0,$.jsx)(Je,{id:o,className:a,value:c,onChange:e=>i(en(n,e)),placeholder:n.placeholder,labels:Xe}):(0,$.jsx)(`input`,{id:o,className:Nt(),type:n.type===`number`?`number`:`text`,autoComplete:n.secret?`new-password`:`off`,spellCheck:!1,value:c,required:n.required,placeholder:n.placeholder,onChange:e=>i(en(n,e.target.value))}),t[23]=a,t[24]=n,t[25]=c,t[26]=o,t[27]=i,t[28]=f):f=t[28];let p;t[29]===s?p=t[30]:(p=s?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:s}):null,t[29]=s,t[30]=p);let m;return t[31]!==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 vn(e){return(0,$.jsx)(J,{value:e.id,children:e.name},e.id)}function yn(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 bn(e){let t=e&&typeof e==`object`&&`tools`in e?e.tools:void 0,n=t&&typeof t==`object`&&`web`in t?t.web:void 0,r=n&&typeof n==`object`&&`region`in n?n.region:void 0,i=r===`cn`||r===`global`?r:`auto`,a=n&&typeof n==`object`&&`search`in n?n.search:void 0,o=a&&typeof a==`object`?a:{},s=typeof o.maxResults==`number`&&Number.isFinite(o.maxResults)?Math.floor(o.maxResults):5,c=n&&typeof n==`object`&&`blocklist`in n?n.blocklist:void 0,l=c&&typeof c==`object`?c:{},u=Array.isArray(l.domains)?l.domains.filter(e=>typeof e==`string`&&e.trim().length>0):[],d=o.providers;return{regionMode:i,maxResults:s,providers:Array.isArray(d)?d.map(e=>{let t=e&&typeof e==`object`?e:{},n=t.type;return{type:n===`brave`||n===`tavily`||n===`bing`||n===`searxng`?n:`brave`,apiKey:typeof t.apiKey==`string`?t.apiKey:``,url:typeof t.url==`string`?t.url:``,disabled:t.disabled===!0}}):[],blocklistEnabled:l.enabled===!0,blocklistDomains:u}}async function xn(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 h(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),Ue()}async function Sn(e){let t=await h(m(`/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 Cn(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 wn(){return l(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,U,`dark:border-edge`)}function Tn(){return l(je,v)}var En=[`brave`,`tavily`,`bing`,`searxng`];function Dn(){return{type:`brave`,apiKey:``,url:``,disabled:!1}}var On=Me();function kn(){let e=u(f(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!d(e=>e.token),[i,a]=(0,Q.useReducer)(On,{form:null,baseline:null}),o=i.form,s=i.baseline,[c,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(null),g=(0,Q.useRef)(!1),_=(0,Q.useRef)(null),{data:v,error:y,isLoading:b,mutate:x}=Ie(r);ee({enabled:r,parsed:(0,Q.useMemo)(()=>v?.payload?.config===void 0?null:bn(v.payload.config),[v]),dirty:g.current,trackedParsedRef:_,dispatch:a,onResetDirty:()=>{g.current=!1}});let S=!!(r&&b&&v===void 0&&!y),C=y instanceof Error?y.message:y?String(y):null,w=(0,Q.useMemo)(()=>!o||!s?!1:JSON.stringify(o)!==JSON.stringify(s),[o,s]),T=(0,Q.useCallback)(e=>{g.current=!0,a({type:`patch`,patch:e})},[]);return yt({id:`search`,dirty:w,saving:c,save:(0,Q.useCallback)(async()=>{if(!(!o||c)){p(!0),h(null);try{await xn(o),g.current=!1,a({type:`saved`,value:o})}catch(e){h(e instanceof Error?e.message:t.saveError)}finally{p(!1)}}},[o,c,t.saveError]),discard:(0,Q.useCallback)(()=>{s&&(g.current=!1,a({type:`discard`}),h(null))},[s])}),r?S?(0,$.jsx)(it,{rows:3}):o?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[m?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:m}):null,(0,$.jsxs)(_t,{children:[(0,$.jsx)(gt,{icon:Ze,title:t.sectionRegion,subtitle:t.sectionRegionHint}),(0,$.jsx)(`div`,{className:`flex max-w-md flex-col gap-4`,children:(0,$.jsx)(Cn,{label:t.regionLabel,description:t.regionDesc,children:(0,$.jsxs)(Y,{className:Tn(),value:o.regionMode,onChange:e=>T({regionMode:e.target.value}),children:[(0,$.jsx)(J,{value:`auto`,children:t.regionAuto}),(0,$.jsx)(J,{value:`cn`,children:t.regionCn}),(0,$.jsx)(J,{value:`global`,children:t.regionGlobal})]})})})]}),(0,$.jsx)(ht,{children:(0,$.jsxs)(_t,{children:[(0,$.jsx)(gt,{icon:Ne,title:t.sectionBlocklist,subtitle:t.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:o.blocklistEnabled,onChange:e=>T({blocklistEnabled:e.target.checked})}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium`,children:t.blocklistEnabled}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:t.blocklistEnabledDesc})]})]}),(0,$.jsx)(Cn,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,$.jsx)(`textarea`,{className:l(wn(),`min-h-[6rem] font-mono text-xs`),value:o.blocklistDomains.join(`
2
+ `),placeholder:t.blocklistDomainsPlaceholder,disabled:!o.blocklistEnabled,onChange:e=>{T({blocklistDomains:e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]})})}})})]})]})}),(0,$.jsxs)(_t,{children:[(0,$.jsx)(gt,{icon:Ze,title:t.sectionSearch,subtitle:t.sectionSearchHint}),(0,$.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-6`,children:[(0,$.jsx)(Cn,{label:t.maxResultsLabel,description:t.maxResultsDesc,children:(0,$.jsx)(`input`,{type:`number`,min:1,max:50,className:wn(),value:o.maxResults,onChange:e=>T({maxResults:Math.max(1,Math.min(50,Number(e.target.value)||5))})})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.providersTitle}),o.providers.map((n,r)=>(0,$.jsx)(An,{row:n,providerIndex:r,labels:t,secretLabels:q(e.providersSettings),onChange:e=>{let t=[...o.providers];t[r]=e,T({providers:t})},onRemove:()=>{T({providers:o.providers.filter((e,t)=>t!==r)})}},`${n.type}:${n.url}:${n.apiKey}:${n.disabled}`)),(0,$.jsxs)(W,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>T({providers:[...o.providers,Dn()]}),children:[(0,$.jsx)(te,{className:`size-4`}),t.addProvider]})]})]})]}),(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:t.footerHint})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:m??C??t.loadError}),(0,$.jsx)(W,{type:`button`,variant:`secondary`,onClick:()=>void x(),children:n.refresh})]}):(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})})}function An(e){let t=(0,Z.c)(54),{row:n,providerIndex:r,labels:i,secretLabels:a,onChange:o,onRemove:s}=e,c;t[0]===r?c=t[1]:(c=()=>Sn(r).then(jn),t[0]=r,t[1]=c);let u=c,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=l(Tn(),`min-w-[8rem]`),t[2]=d):d=t[2];let f=n.type,p;t[3]!==o||t[4]!==n?(p=e=>o({...n,type:e.target.value,url:e.target.value===`searxng`?n.url:``}),t[3]=o,t[4]=n,t[5]=p):p=t[5];let m;t[6]===i.providerTypes?m=t[7]:(m=En.map(e=>(0,$.jsx)(J,{value:e,children:i.providerTypes[e]},e)),t[6]=i.providerTypes,t[7]=m);let h;t[8]!==n.type||t[9]!==p||t[10]!==m?(h=(0,$.jsx)(Y,{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]!==o||t[13]!==n?(g=e=>o({...n,disabled:e.target.checked}),t[12]=o,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]!==i.disabled||t[19]!==_?(v=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-fg-muted`,children:[_,i.disabled]}),t[18]=i.disabled,t[19]=_,t[20]=v):v=t[20];let y;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(be,{className:`size-4`}),t[21]=y):y=t[21];let b;t[22]===s?b=t[23]:(b=(0,$.jsx)(W,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-fg-muted`,onClick:s,children:y}),t[22]=s,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 C;t[30]!==i.urlDesc||t[31]!==i.urlLabel||t[32]!==o||t[33]!==n?(C=n.type===`searxng`?(0,$.jsx)(Cn,{label:i.urlLabel,description:i.urlDesc,children:(0,$.jsx)(`input`,{type:`url`,className:wn(),value:n.url,placeholder:`http://localhost:8080`,onChange:e=>o({...n,url:e.target.value})})}):null,t[30]=i.urlDesc,t[31]=i.urlLabel,t[32]=o,t[33]=n,t[34]=C):C=t[34];let w;t[35]!==o||t[36]!==n?(w=e=>o({...n,apiKey:e}),t[35]=o,t[36]=n,t[37]=w):w=t[37];let T;t[38]!==i.keyPlaceholder||t[39]!==i.keyPlaceholderMasked||t[40]!==i.saveError||t[41]!==u||t[42]!==n.apiKey||t[43]!==a||t[44]!==w?(T=(0,$.jsx)(Je,{value:n.apiKey,onChange:w,placeholder:i.keyPlaceholder,labels:a,reveal:u,loadFailedLabel:i.saveError,notInConfigFile:i.keyPlaceholderMasked}),t[38]=i.keyPlaceholder,t[39]=i.keyPlaceholderMasked,t[40]=i.saveError,t[41]=u,t[42]=n.apiKey,t[43]=a,t[44]=w,t[45]=T):T=t[45];let E;t[46]!==i.apiKeyDesc||t[47]!==i.apiKeyLabel||t[48]!==T?(E=(0,$.jsx)(Cn,{label:i.apiKeyLabel,description:i.apiKeyDesc,children:T}),t[46]=i.apiKeyDesc,t[47]=i.apiKeyLabel,t[48]=T,t[49]=E):E=t[49];let D;return t[50]!==S||t[51]!==C||t[52]!==E?(D=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-panel/70 p-4 shadow-surface`,children:[S,C,E]}),t[50]=S,t[51]=C,t[52]=E,t[53]=D):D=t[53],D}function jn(e){return e.apiKey??null}var Mn=[`common`,`domestic`,`specialty`,`enterprise`,`oauth`,`extension`];function Nn(e){let t=new Map;for(let e of Mn)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}function Pn(e){let t=(0,Z.c)(22),{open:n,onOpenChange:r,builtinRows:i,customConfig:a,labels:o,language:s,onSaved:c}=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,v;t[3]!==g||t[4]!==c?(v=()=>{c(),g(!1)},t[3]=g,t[4]=c,t[5]=v):v=t[5];let y=v,b;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(Be,{className:l(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,Fe)}),t[6]=b):b=t[6];let x;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(x=l(`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`,Re),t[7]=x):x=t[7];let S;t[8]!==i||t[9]!==a||t[10]!==y||t[11]!==o||t[12]!==s||t[13]!==p||t[14]!==d.presetKey||t[15]!==d.providerId||t[16]!==d.type?(S=(0,$.jsxs)(I,{children:[b,(0,$.jsx)(j,{className:x,children:d.type===`pick`?(0,$.jsx)(In,{builtinRows:i,searchQuery:p,onSearchChange:m,labels:o,onPickBuiltin:e=>{let t=_(e);f(t?{type:`custom`,presetKey:t}:{type:`builtin`,providerId:e})},onPickCustom:()=>f({type:`custom`})}):d.type===`builtin`?(0,$.jsx)(Ln,{providerId:d.providerId,builtinRows:i,labels:o,language:s,onBack:()=>f({type:`pick`}),onSaved:y}):(0,$.jsx)(Bn,{initialPresetKey:d.presetKey,customConfig:a,labels:o,language:s,onBack:()=>f({type:`pick`}),onSaved:y})})]}),t[8]=i,t[9]=a,t[10]=y,t[11]=o,t[12]=s,t[13]=p,t[14]=d.presetKey,t[15]=d.providerId,t[16]=d.type,t[17]=S):S=t[17];let C;return t[18]!==g||t[19]!==n||t[20]!==S?(C=(0,$.jsx)(ue,{open:n,onOpenChange:g,children:S}),t[18]=g,t[19]=n,t[20]=S,t[21]=C):C=t[21],C}function Fn(e){let t=(0,Z.c)(4),{label:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=l(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,w.press),t[0]=r):r=t[0];let i;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(P,{className:`size-4`,"aria-hidden":!0}),t[1]=i):i=t[1];let a;return t[2]===n?a=t[3]:(a=(0,$.jsx)(me,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:r,"aria-label":n,children:i})}),t[2]=n,t[3]=a),a}function In(e){let t=(0,Z.c)(42),{builtinRows:n,searchQuery:r,onSearchChange:i,labels:a,onPickBuiltin:o,onPickCustom:s}=e,c;t[0]===r?c=t[1]:(c=r.trim().toLowerCase(),t[0]=r,t[1]=c);let u=c,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=tt[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,p;t[7]===f?p=t[8]:(p=Nn(f),t[7]=f,t[8]=p);let m=p,h;t[9]===a.step1Title?h=t[10]:(h=(0,$.jsx)(ye,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:a.step1Title}),t[9]=a.step1Title,t[10]=h);let g;t[11]===a.close?g=t[12]:(g=(0,$.jsx)(Fn,{label:a.close}),t[11]=a.close,t[12]=g);let _;t[13]!==h||t[14]!==g?(_=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-edge-subtle px-5 py-4`,children:[h,g]}),t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(Ze,{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]=v):v=t[16];let y;t[17]===i?y=t[18]:(y=e=>i(e.target.value),t[17]=i,t[18]=y);let b=a.searchPlaceholder,x;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(x=l(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-10 pr-3 text-sm text-fg placeholder:text-fg-subtle`,U),t[19]=x):x=t[19];let S;t[20]!==a.searchPlaceholder||t[21]!==r||t[22]!==y?(S=(0,$.jsx)(`div`,{className:`px-5 pt-3`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[v,(0,$.jsx)(`input`,{type:`search`,value:r,onChange:y,placeholder:b,autoComplete:`off`,className:x})]})}),t[20]=a.searchPlaceholder,t[21]=r,t[22]=y,t[23]=S):S=t[23];let C;t[24]!==a.addCustom||t[25]!==a.customDescription||t[26]!==s||t[27]!==u?(C=u?null:(0,$.jsxs)(`button`,{type:`button`,onClick:s,className:l(`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`,w.press),children:[(0,$.jsx)(ke,{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:a.addCustom}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:a.customDescription})]}),(0,$.jsx)(Se,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0})]}),t[24]=a.addCustom,t[25]=a.customDescription,t[26]=s,t[27]=u,t[28]=C):C=t[28];let T;t[29]!==f.length||t[30]!==m||t[31]!==a.categories||t[32]!==a.noResults||t[33]!==o?(T=f.length===0?(0,$.jsx)(`p`,{className:`py-6 text-center text-sm text-fg-muted`,children:a.noResults}):(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:Mn.map(e=>{let t=m.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:a.categories[e]??e}),(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:t.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>o(e.id),className:l(`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`,w.press),children:[(0,$.jsx)(`span`,{className:`truncate text-sm text-fg`,children:e.name}),e.configured?(0,$.jsx)(Oe,{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]=m,t[31]=a.categories,t[32]=a.noResults,t[33]=o,t[34]=T):T=t[34];let E;t[35]!==C||t[36]!==T?(E=(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-3`,children:[C,T]}),t[35]=C,t[36]=T,t[37]=E):E=t[37];let D;return t[38]!==S||t[39]!==E||t[40]!==_?(D=(0,$.jsxs)($.Fragment,{children:[_,S,E]}),t[38]=S,t[39]=E,t[40]=_,t[41]=D):D=t[41],D}function Ln({providerId:e,builtinRows:t,labels:n,language:r,onBack:i,onSaved:a}){let o=t.find(t=>t.id===e),s=tt[e],[c,d]=(0,Q.useState)(``),[f,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(!1),b=(0,Q.useRef)(null),S=u(r).providersSettings,C=q(S),T=(0,Q.useMemo)(()=>x(e,r),[e,r]),E=o?.supportsApiKey!==!1,D=o?.supportsOAuth===!0,[O,A]=(0,Q.useState)(null),[j,M]=(0,Q.useState)(null),[P,F]=(0,Q.useState)(`idle`),[I,L]=(0,Q.useState)(null),[R,z]=(0,Q.useState)(null),[B,V]=(0,Q.useState)(``),H=P===`waiting`||P===`waiting_code`;(0,Q.useEffect)(()=>{if(!O||!H)return;let t=window.setInterval(()=>{(async()=>{try{let n=await N(O);if(n.status===`waiting_auth`||n.status===`waiting_code`)F(n.status===`waiting_code`?`waiting_code`:`waiting`),M(n.message??null),L(n.authUrl??null),z(n.instructions??null);else if(n.status===`completed`){window.clearInterval(t);try{if(e===`xopc-cloud`){let e=await p(m(`/api/models/catalog/refresh`),{method:`POST`});if(!e.ok)throw Error(`Model catalog refresh failed: ${e.status}`);await ve()}}catch(e){F(`error`),M(e instanceof Error?e.message:S.revokeFailed);return}F(`success`),M(n.message??S.saved),window.setTimeout(a,600)}else (n.status===`failed`||n.status===`cancelled`)&&(window.clearInterval(t),F(`error`),M(n.error??n.message??S.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(t)},[O,H,a,e,S.revokeFailed,S.saved]),(0,Q.useEffect)(()=>()=>{O&&k(O).catch(()=>{})},[O]);let ee=async()=>{F(`waiting`),M(S.oauthStarting),_(null);try{A((await oe(e)).sessionId)}catch(e){F(`error`),M(e instanceof Error?e.message:S.revokeFailed)}},te=async()=>{if(O){try{await ae(O)}catch{}F(`idle`),M(null),A(null),L(null),z(null)}},ne=async()=>{if(!(!O||!B.trim()))try{await et(O,B.trim()),V(``),M(S.oauthProcessingCode)}catch(e){F(`error`),M(e instanceof Error?e.message:S.revokeFailed)}},re=async()=>{let t=c.trim();if(!(!t||!E)){h(!0),_(null);try{await pe({[e]:t}),y(!0),window.setTimeout(a,600)}catch(e){_(e instanceof Error?e.message:n.saveError)}finally{h(!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:i,className:l(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,w.press),"aria-label":n.back,children:(0,$.jsx)(Se,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,$.jsx)(ye,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:o?.name??e}),(0,$.jsx)(Fn,{label:n.close})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 px-5 py-4`,children:[s?.description?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.description}):null,E?(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)(Je,{id:`builtin-api-key`,value:c,onChange:d,placeholder:n.apiKeyPlaceholder,labels:C,inputRef:b,onKeyDown:e=>{e.key===`Enter`&&re()}})]}):null,D?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:S.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:S.oauthHint})]}),(0,$.jsxs)(W,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:H,onClick:()=>void ee(),children:[H?(0,$.jsx)(X,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,S.oauth]})]}),j?(0,$.jsx)(`p`,{className:l(`text-xs`,P===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:j}):null,P===`waiting`||P===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[I?(0,$.jsxs)(`a`,{href:I,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:[S.openAuthPage,(0,$.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]}):null,(0,$.jsx)(W,{type:`button`,variant:`secondary`,onClick:()=>void te(),children:S.cancelOAuth})]}):null,R?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:R}):null,P===`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 ne(),placeholder:S.pasteRedirectUrl,className:l(`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`,U)}),(0,$.jsx)(W,{type:`button`,variant:`primary`,onClick:()=>void ne(),children:S.submitCode})]}):null]}):null,T.length>0&&E?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:T.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:[fe(e,n),(0,$.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]},e))}):null,g?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:g}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsx)(W,{type:`button`,variant:`secondary`,onClick:i,children:n.cancel}),E?(0,$.jsx)(W,{type:`button`,variant:`primary`,disabled:!c.trim()||f||v,onClick:()=>void re(),children:v?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(Oe,{className:`size-3.5`,"aria-hidden":!0}),n.saved]}):f?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(X,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save}):null]})]})]})}function Rn(e=`custom`){if(e!==`custom`&&E[e]){let t=E[e].config;return{preset:e,providerId:H(e),baseUrl:t.baseUrl??``,api:t.api??`openai-completions`,apiKey:t.apiKey??``,modelIds:t.models?.map(e=>e.id)??[``],error:null}}return{preset:`custom`,providerId:``,baseUrl:``,api:`openai-completions`,apiKey:``,modelIds:[``],error:null}}function zn(e,t){switch(t.type){case`applyPreset`:return t.key===`custom`?{...e,preset:`custom`,error:null}:E[t.key]?Rn(t.key):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`setModelIds`:return{...e,modelIds:t.values.length>0?t.values:[``]};case`removeModelSlot`:return{...e,modelIds:e.modelIds.filter((e,n)=>n!==t.index)};case`setError`:return{...e,error:t.value}}}function Bn({initialPresetKey:e,customConfig:t,labels:n,language:r,onBack:i,onSaved:a}){let[o,s]=(0,Q.useReducer)(zn,void 0,()=>Rn(e)),[c,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),m=q(u(r).providersSettings),{preset:h,providerId:g,baseUrl:_,api:v,apiKey:y,modelIds:b,error:x}=o,S=async()=>{let e=g.trim(),r=_.trim();if(!e){s({type:`setError`,value:n.providerIdRequired});return}if(!r){s({type:`setError`,value:n.baseUrlRequired});return}let i=b.map(e=>e.trim()).filter(Boolean);d(!0),s({type:`setError`,value:null});try{let n=t?.providers??{},o=h===`custom`?void 0:E[h]?.config,s={...o??{},baseUrl:r,api:v,apiKey:y.trim()||void 0,models:i.map(e=>o?.models?.find(t=>t.id===e)??{id:e})};await qe({providers:{...n,[e]:s}}),a()}catch(e){s({type:`setError`,value:e instanceof Error?e.message:n.saveError})}finally{d(!1)}},T=async()=>{let e=g.trim()||H(h)||`custom`,t=_.trim();if(!t){s({type:`setError`,value:n.baseUrlRequired});return}p(!0),s({type:`setError`,value:null});try{let r=h===`custom`?void 0:E[h]?.config,i=(await Ye({providerId:e,baseUrl:t,apiKey:y.trim()||void 0,api:v,headers:r?.headers})).map(e=>e.id).filter(e=>e&&!e.includes(`/`));s({type:`setModelIds`,values:i}),i.length===0&&s({type:`setError`,value:n.discoverModelsHint})}catch(e){s({type:`setError`,value:e instanceof Error?e.message:n.discoverModelsHint})}finally{p(!1)}},D=g.trim()&&_.trim(),O=(v===`openai-completions`||v===`openai-responses`)&&_.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:i,className:l(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,w.press),"aria-label":n.back,children:(0,$.jsx)(Se,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,$.jsx)(ye,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:n.step2CustomTitle}),(0,$.jsx)(Fn,{label:n.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:n.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:n.presetLabel}),(0,$.jsxs)(Y,{id:`custom-preset`,value:h,onChange:e=>s({type:`applyPreset`,key:e.target.value}),className:ne(),children:[(0,$.jsx)(J,{value:`custom`,children:n.presetCustom}),C.map(e=>(0,$.jsx)(J,{value:e.key,children:e.label},e.key))]})]}),(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:n.providerIdLabel}),(0,$.jsx)(`input`,{id:`custom-provider-id`,type:`text`,autoComplete:`off`,value:g,onChange:e=>s({type:`setProviderId`,value:e.target.value}),placeholder:n.providerIdPlaceholder,className:l(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,U)})]}),(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:n.baseUrlLabel}),(0,$.jsx)(`input`,{id:`custom-base-url`,type:`url`,autoComplete:`off`,value:_,onChange:e=>s({type:`setBaseUrl`,value:e.target.value}),placeholder:n.baseUrlPlaceholder,className:l(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,U)})]}),(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:n.apiTypeLabel}),(0,$.jsx)(Y,{id:`custom-api-type`,value:v,onChange:e=>s({type:`setApi`,value:e.target.value}),className:ne(),children:Qe.map(e=>(0,$.jsx)(J,{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:n.apiKeyLabel}),(0,$.jsx)(Je,{id:`custom-api-key`,value:y,onChange:e=>s({type:`setApiKey`,value:e}),placeholder:n.apiKeyPlaceholder,labels:m})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.modelIdLabel}),(0,$.jsxs)(W,{type:`button`,variant:`secondary`,className:`gap-1.5`,disabled:!O||f,onClick:()=>void T(),children:[f?(0,$.jsx)(X,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Ze,{className:`size-3.5`,"aria-hidden":!0}),f?n.discoveringModels:n.discoverModels]})]}),b.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`text`,autoComplete:`off`,value:e,onChange:e=>s({type:`updateModelId`,index:t,value:e.target.value}),placeholder:n.modelIdPlaceholder,className:l(`flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,U)}),b.length>1?(0,$.jsx)(`button`,{type:`button`,onClick:()=>s({type:`removeModelSlot`,index:t}),className:l(`rounded-lg p-1.5 text-fg-subtle hover:bg-surface-hover hover:text-fg`,w.press),children:(0,$.jsx)(P,{className:`size-3.5`,"aria-hidden":!0})}):null]},e||`model-slot-${t}`)),(0,$.jsxs)(W,{type:`button`,variant:`ghost`,className:`w-fit gap-1.5 text-fg-muted`,onClick:()=>s({type:`addModelSlot`}),children:[(0,$.jsx)(te,{className:`size-3.5`,"aria-hidden":!0}),n.addModel]})]}),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-end gap-2 border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsx)(W,{type:`button`,variant:`secondary`,onClick:i,children:n.cancel}),(0,$.jsx)(W,{type:`button`,variant:`primary`,disabled:!D||c,onClick:()=>void S(),children:c?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(X,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})]})]})}function Vn(){let e=(0,Z.c)(31),t=d(Kn),n=!!t,{data:r,isLoading:i}=Ie(n),a;e[0]===n?a=e[1]:(a=n?m(`/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 s;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(s={revalidateOnFocus:!1},e[4]=s):s=e[4];let{data:c,isLoading:l}=g(a,o,s),u;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(u={revalidateOnFocus:!1},e[5]=u):u=e[5];let{data:f,isLoading:p}=g(n?_e:null,Gn,u),h;e[6]===f?h=e[7]:(h=f===void 0?[]:f,e[6]=f,e[7]=h);let _=h,v;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(v={revalidateOnFocus:!1},e[8]=v):v=e[8];let{data:y}=g(n?ze:null,Wn,v),b;bb0:{if(!c||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]!==c||e[12]!==_?(t=le(c,A(r?.payload?.config),_),e[10]=r?.payload?.config,e[11]=c,e[12]=_,e[13]=t):t=e[13],b=t}let x=b,C;bb1:{if(!y){C=null;break bb1}let t;e[14]===y.config?t=e[15]:(t=S(y.config),e[14]=y.config,e[15]=t),C=t}let w=C,T;if(e[16]!==x||e[17]!==w||e[18]!==c||e[19]!==_){T=[];let t=new Set((c??[]).filter(Un).map(Hn)),n;e[21]===w?n=e[22]:(n=new Set(w?Object.keys(w.providers):[]),e[21]=w,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?w.providers[e.id]?.models?.length??0:_.filter(t=>t.provider===e.id).length;T.push({id:e.id,name:e.name,configured:!0,isCustom:n,modelCount:i})}if(w){let t;e[23]===w.providers?t=e[24]:(t=Object.entries(w.providers),e[23]=w.providers,e[24]=t);for(let[e,n]of t)T.some(t=>t.id===e)||T.push({id:e,name:e,configured:!0,isCustom:!0,modelCount:n.models?.length??0})}e[16]=x,e[17]=w,e[18]=c,e[19]=_,e[20]=T}else T=e[20];let E=T,D=i||l||p,O;return e[25]!==x||e[26]!==E||e[27]!==w||e[28]!==D||e[29]!==_?(O={cards:E,loading:D,builtinRows:x,customConfig:w,allModels:_},e[25]=x,e[26]=E,e[27]=w,e[28]=D,e[29]=_,e[30]=O):O=e[30],O}function Hn(e){return e.id}function Un(e){return e.configured}function Wn(){return K()}function Gn(){return xe()}function Kn(e){return e.token}function qn(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)(Ve,{className:`h-6 w-48 max-w-full`}),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`,"aria-busy":`true`,children:[e,(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[1,2,3].map(Yn)})]}),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(Jn),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)(te,{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)(W,{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 bg-surface-panel/60 px-6 py-10 text-center shadow-surface`,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)(W,{type:`button`,variant:`primary`,className:`mt-4 gap-1.5`,onClick:r,children:[(0,$.jsx)(te,{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)(Xn,{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 Jn(e){return e.configured}function Yn(e){return(0,$.jsx)(Ve,{className:`h-32 rounded-2xl`},e)}function Xn(e){let t=(0,Z.c)(28),{card:n,labels:r,onManage:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=l(`group relative flex flex-col justify-between rounded-2xl bg-surface-base p-4 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,w.pressCard),t[0]=a):a=t[0];let o;t[1]===n.name?o=t[2]:(o=(0,$.jsx)(`span`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[1]=n.name,t[2]=o);let s;t[3]!==n.isCustom||t[4]!==r.custom?(s=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]=s):s=t[5];let c;t[6]!==o||t[7]!==s?(c=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[o,s]}),t[6]=o,t[7]=s,t[8]=c):c=t[8];let u;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(Oe,{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]===c?d=t[11]:(d=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[c,u]}),t[10]=c,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)(De,{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]!==i||t[25]!==g||t[26]!==d?(_=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:a,children:[d,g]}),t[24]=i,t[25]=g,t[26]=d,t[27]=_):_=t[27],_}function Zn(e){let t=(0,Z.c)(156),{model:n,isNew:r,providerId:i,onSave:a,onClose:o,m:s}=e,c;t[0]===n?c=t[1]:(c=()=>n?{...n}:we(``),t[0]=n,t[1]=c);let[u,d]=(0,Q.useState)(c),[f,p]=(0,Q.useState)(Qn),m;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(m=(e,t)=>{d(n=>({...n,[e]:t})),p(t=>{let n=new Map(t);return n.delete(e),n})},t[2]=m):m=t[2];let h=m,g;t[3]!==u.contextWindow||t[4]!==u.id||t[5]!==u.maxTokens||t[6]!==s.modelIdRequired||t[7]!==s.mustBePositive?(g=()=>{let e=new Map;return(u.id||``).trim()||e.set(`id`,s.modelIdRequired),u.contextWindow!==void 0&&u.contextWindow<=0&&e.set(`contextWindow`,s.mustBePositive),u.maxTokens!==void 0&&u.maxTokens<=0&&e.set(`maxTokens`,s.mustBePositive),p(e),e.size===0},t[3]=u.contextWindow,t[4]=u.id,t[5]=u.maxTokens,t[6]=s.modelIdRequired,t[7]=s.mustBePositive,t[8]=g):g=t[8];let _=g,v;t[9]!==u||t[10]!==o||t[11]!==a||t[12]!==_?(v=()=>{if(!_())return;let e=(u.id||``).trim();a({...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}}),o()},t[9]=u,t[10]=o,t[11]=a,t[12]=_,t[13]=v):v=t[13];let y=v,b=u,x;t[14]===b?x=t[15]:(x=Ae(b),t[14]=b,t[15]=x);let S=x,C=r?s.addModelTitle:s.editModelTitle,w;t[16]===C?w=t[17]:(w=(0,$.jsx)(ye,{className:`text-base font-semibold text-fg`,children:C}),t[16]=C,t[17]=w);let T;t[18]!==s.modelProviderLabel||t[19]!==i?(T=i?(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[s.modelProviderLabel,`: `,i]}):null,t[18]=s.modelProviderLabel,t[19]=i,t[20]=T):T=t[20];let E;t[21]!==w||t[22]!==T?(E=(0,$.jsxs)(`div`,{children:[w,T]}),t[21]=w,t[22]=T,t[23]=E):E=t[23];let O;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(O=l(D,`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)(P,{className:`size-4`}),t[25]=k):k=t[25];let A;t[26]===s.close?A=t[27]:(A=(0,$.jsx)(me,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:O,"aria-label":s.close,children:k})}),t[26]=s.close,t[27]=A);let j;t[28]!==E||t[29]!==A?(j=(0,$.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[E,A]}),t[28]=E,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]===s.modelId?N=t[33]:(N=(0,$.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[s.modelId,M]}),t[32]=s.modelId,t[33]=N);let F;t[34]===f?F=t[35]:(F=l(re(),f.has(`id`)&&`border-red-500`),t[34]=f,t[35]=F);let I=u.id||``,L;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(L=e=>h(`id`,e.target.value),t[36]=L):L=t[36];let R=!r,z;t[37]!==F||t[38]!==I||t[39]!==R?(z=(0,$.jsx)(`input`,{className:F,value:I,onChange:L,placeholder:`e.g. llama3.1:8b`,disabled:R}),t[37]=F,t[38]=I,t[39]=R,t[40]=z):z=t[40];let B;t[41]===f?B=t[42]:(B=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]=B);let V;t[43]!==N||t[44]!==z||t[45]!==B?(V=(0,$.jsxs)(`div`,{children:[N,z,B]}),t[43]=N,t[44]=z,t[45]=B,t[46]=V):V=t[46];let H;t[47]===s.displayName?H=t[48]:(H=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.displayName}),t[47]=s.displayName,t[48]=H);let U;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(U=re(),t[49]=U):U=t[49];let ee=u.name||``,te;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(te=e=>h(`name`,e.target.value),t[50]=te):te=t[50];let ie;t[51]===ee?ie=t[52]:(ie=(0,$.jsx)(`input`,{className:U,value:ee,onChange:te}),t[51]=ee,t[52]=ie);let ae;t[53]!==H||t[54]!==ie?(ae=(0,$.jsxs)(`div`,{children:[H,ie]}),t[53]=H,t[54]=ie,t[55]=ae):ae=t[55];let G;t[56]===s.inputTypes?G=t[57]:(G=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.inputTypes}),t[56]=s.inputTypes,t[57]=G);let oe;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(oe=ne(),t[58]=oe):oe=t[58];let se;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(se=e=>h(`input`,Pe(e.target.value)),t[59]=se):se=t[59];let K;t[60]===s?K=t[61]:(K=ce.map(e=>(0,$.jsx)(J,{value:e.value,children:s[e.labelKey]},e.value)),t[60]=s,t[61]=K);let q;t[62]!==S||t[63]!==K?(q=(0,$.jsx)(Y,{className:oe,value:S,onChange:se,children:K}),t[62]=S,t[63]=K,t[64]=q):q=t[64];let le;t[65]!==G||t[66]!==q?(le=(0,$.jsxs)(`div`,{children:[G,q]}),t[65]=G,t[66]=q,t[67]=le):le=t[67];let ue=u.reasoning||!1,de;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(de=e=>h(`reasoning`,e.target.checked),t[68]=de):de=t[68];let fe;t[69]===ue?fe=t[70]:(fe=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:ue,onChange:de}),t[69]=ue,t[70]=fe);let pe;t[71]!==s.reasoning||t[72]!==fe?(pe=(0,$.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[fe,s.reasoning]}),t[71]=s.reasoning,t[72]=fe,t[73]=pe):pe=t[73];let he;t[74]!==le||t[75]!==pe?(he=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[le,pe]}),t[74]=le,t[75]=pe,t[76]=he):he=t[76];let ge;t[77]===s.contextWindow?ge=t[78]:(ge=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.contextWindow}),t[77]=s.contextWindow,t[78]=ge);let _e;t[79]===f?_e=t[80]:(_e=l(re(),f.has(`contextWindow`)&&`border-red-500`),t[79]=f,t[80]=_e);let ve=u.contextWindow??128e3,be;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(be=e=>h(`contextWindow`,parseInt(e.target.value,10)||0),t[81]=be):be=t[81];let xe;t[82]!==_e||t[83]!==ve?(xe=(0,$.jsx)(`input`,{type:`number`,min:1,className:_e,value:ve,onChange:be}),t[82]=_e,t[83]=ve,t[84]=xe):xe=t[84];let Se;t[85]===f?Se=t[86]:(Se=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]=Se);let Ce;t[87]!==ge||t[88]!==xe||t[89]!==Se?(Ce=(0,$.jsxs)(`div`,{children:[ge,xe,Se]}),t[87]=ge,t[88]=xe,t[89]=Se,t[90]=Ce):Ce=t[90];let Te;t[91]===s.maxOutputTokens?Te=t[92]:(Te=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.maxOutputTokens}),t[91]=s.maxOutputTokens,t[92]=Te);let Ee;t[93]===f?Ee=t[94]:(Ee=l(re(),f.has(`maxTokens`)&&`border-red-500`),t[93]=f,t[94]=Ee);let De=u.maxTokens??16384,Oe;t[95]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=e=>h(`maxTokens`,parseInt(e.target.value,10)||0),t[95]=Oe):Oe=t[95];let ke;t[96]!==Ee||t[97]!==De?(ke=(0,$.jsx)(`input`,{type:`number`,min:1,className:Ee,value:De,onChange:Oe}),t[96]=Ee,t[97]=De,t[98]=ke):ke=t[98];let je;t[99]===f?je=t[100]:(je=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]=je);let Me;t[101]!==Te||t[102]!==ke||t[103]!==je?(Me=(0,$.jsxs)(`div`,{children:[Te,ke,je]}),t[101]=Te,t[102]=ke,t[103]=je,t[104]=Me):Me=t[104];let Ne;t[105]!==Ce||t[106]!==Me?(Ne=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Ce,Me]}),t[105]=Ce,t[106]=Me,t[107]=Ne):Ne=t[107];let Fe;t[108]===s.costSection?Fe=t[109]:(Fe=(0,$.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:s.costSection}),t[108]=s.costSection,t[109]=Fe);let Ie;t[110]===s.costInput?Ie=t[111]:(Ie=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costInput}),t[110]=s.costInput,t[111]=Ie);let Le;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(Le=re(),t[112]=Le):Le=t[112];let Re=u.cost?.input??0,ze;t[113]===u.cost?ze=t[114]:(ze=e=>h(`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]=ze);let Be;t[115]!==Re||t[116]!==ze?(Be=(0,$.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Le,value:Re,onChange:ze}),t[115]=Re,t[116]=ze,t[117]=Be):Be=t[117];let X;t[118]!==Ie||t[119]!==Be?(X=(0,$.jsxs)(`div`,{children:[Ie,Be]}),t[118]=Ie,t[119]=Be,t[120]=X):X=t[120];let Ve;t[121]===s.costOutput?Ve=t[122]:(Ve=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costOutput}),t[121]=s.costOutput,t[122]=Ve);let He;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(He=re(),t[123]=He):He=t[123];let Ue=u.cost?.output??0,We;t[124]===u.cost?We=t[125]:(We=e=>h(`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]=We);let Ge;t[126]!==Ue||t[127]!==We?(Ge=(0,$.jsx)(`input`,{type:`number`,step:`any`,min:0,className:He,value:Ue,onChange:We}),t[126]=Ue,t[127]=We,t[128]=Ge):Ge=t[128];let Ke;t[129]!==Ve||t[130]!==Ge?(Ke=(0,$.jsxs)(`div`,{children:[Ve,Ge]}),t[129]=Ve,t[130]=Ge,t[131]=Ke):Ke=t[131];let qe;t[132]!==X||t[133]!==Ke?(qe=(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[X,Ke]}),t[132]=X,t[133]=Ke,t[134]=qe):qe=t[134];let Je;t[135]!==Fe||t[136]!==qe?(Je=(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[Fe,qe]}),t[135]=Fe,t[136]=qe,t[137]=Je):Je=t[137];let Ye;t[138]!==V||t[139]!==ae||t[140]!==he||t[141]!==Ne||t[142]!==Je?(Ye=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[V,ae,he,Ne,Je]}),t[138]=V,t[139]=ae,t[140]=he,t[141]=Ne,t[142]=Je,t[143]=Ye):Ye=t[143];let Xe;t[144]===s.cancel?Xe=t[145]:(Xe=(0,$.jsx)(me,{asChild:!0,children:(0,$.jsx)(W,{type:`button`,variant:`secondary`,children:s.cancel})}),t[144]=s.cancel,t[145]=Xe);let Ze=r?s.addModelConfirm:s.saveModelConfirm,Qe;t[146]!==y||t[147]!==Ze?(Qe=(0,$.jsx)(W,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,onClick:y,children:Ze}),t[146]=y,t[147]=Ze,t[148]=Qe):Qe=t[148];let $e;t[149]!==Xe||t[150]!==Qe?($e=(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[Xe,Qe]}),t[149]=Xe,t[150]=Qe,t[151]=$e):$e=t[151];let et;return t[152]!==j||t[153]!==Ye||t[154]!==$e?(et=(0,$.jsxs)($.Fragment,{children:[j,Ye,$e]}),t[152]=j,t[153]=Ye,t[154]=$e,t[155]=et):et=t[155],et}function Qn(){return new Map}function $n(e){let t=(0,Z.c)(16),{open:n,onOpenChange:r,providerId:i,model:a,isNew:o,onSave:s,m:c}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(Be,{className:l(`xopc-dialog-overlay fixed inset-0 bg-scrim`,Fe)}),t[0]=u):u=t[0];let d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=l(`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`,Re,`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]!==o||t[3]!==c||t[4]!==a||t[5]!==r||t[6]!==s||t[7]!==n||t[8]!==i?(f=n?(0,$.jsx)(Zn,{model:a,isNew:o,providerId:i,onSave:s,onClose:()=>r(!1),m:c},`${i??`none`}-${a?.id??`new`}`):null,t[2]=o,t[3]=c,t[4]=a,t[5]=r,t[6]=s,t[7]=n,t[8]=i,t[9]=f):f=t[9];let p;t[10]===f?p=t[11]:(p=(0,$.jsxs)(I,{children:[u,(0,$.jsx)(j,{className:d,onOpenAutoFocus:er,children:f})]}),t[10]=f,t[11]=p);let m;return t[12]!==r||t[13]!==n||t[14]!==p?(m=(0,$.jsx)(ue,{open:n,onOpenChange:r,children:p}),t[12]=r,t[13]=n,t[14]=p,t[15]=m):m=t[15],m}function er(e){return e.preventDefault()}function tr(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=()=>z(n).then(nr),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)(Je,{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 nr(e){return e.apiKey??null}function rr(e){let t=(0,Z.c)(16),{open:n,onOpenChange:r,providerId:i,isCustom:a,builtinRows:o,customConfig:s,allModels:c,labels:u,language:d,onSaved:f}=e,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(Be,{className:l(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,Fe)}),t[0]=p):p=t[0];let m;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(m=l(`fixed left-1/2 top-1/2 flex max-h-[85vh] w-[calc(100%-2rem)] 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`,Re),t[1]=m):m=t[1];let h;t[2]!==c||t[3]!==o||t[4]!==s||t[5]!==a||t[6]!==u||t[7]!==d||t[8]!==r||t[9]!==f||t[10]!==i?(h=(0,$.jsxs)(I,{children:[p,(0,$.jsx)(j,{className:m,children:a?(0,$.jsx)(ar,{providerId:i,customConfig:s,labels:u,language:d,onClose:()=>r(!1),onSaved:f}):(0,$.jsx)(ir,{providerId:i,builtinRows:o,allModels:c,labels:u,language:d,onClose:()=>r(!1),onSaved:f})})]}),t[2]=c,t[3]=o,t[4]=s,t[5]=a,t[6]=u,t[7]=d,t[8]=r,t[9]=f,t[10]=i,t[11]=h):h=t[11];let g;return t[12]!==r||t[13]!==n||t[14]!==h?(g=(0,$.jsx)(ue,{open:n,onOpenChange:r,children:h}),t[12]=r,t[13]=n,t[14]=h,t[15]=g):g=t[15],g}function ir({providerId:e,builtinRows:t,allModels:n,labels:r,language:i,onClose:a,onSaved:o}){let c=t.find(t=>t.id===e),d=tt[e],f=n.filter(t=>t.provider===e),[p,m]=(0,Q.useState)(c?.apiKey??``),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(!1),[b,S]=(0,Q.useState)(null),[C,T]=(0,Q.useState)(!1),E=u(i).providersSettings,D=c?.supportsApiKey!==!1,O=c?.supportsOAuth===!0,A=c?.authMode===`oauth`&&c.authStatus===`connected`,j=c?.configured===!0&&c.activeKeySource!==`env`&&c.activeKeySource!==`extension`&&c.activeKeySource!==`models_json`,[F,I]=(0,Q.useState)(null),[L,z]=(0,Q.useState)(null),[V,H]=(0,Q.useState)(`idle`),[ee,te]=(0,Q.useState)(null),[ne,re]=(0,Q.useState)(null),[ie,G]=(0,Q.useState)(``),se=V===`waiting`||V===`waiting_code`,K=(0,Q.useMemo)(()=>x(e,i),[e,i]),q=p!==(c?.apiKey??``),ce=async()=>{let t=p.trim();if(!(!t||!D||M(t))){g(!0),S(null);try{await pe({[e]:t}),v(!0),window.setTimeout(()=>{o(),a()},600)}catch(e){S(e instanceof Error?e.message:r.saveError)}finally{g(!1)}}};(0,Q.useEffect)(()=>{if(!F||!se)return;let e=window.setInterval(()=>{(async()=>{try{let t=await N(F);t.status===`waiting_auth`||t.status===`waiting_code`?(H(t.status===`waiting_code`?`waiting_code`:`waiting`),z(t.message??null),te(t.authUrl??null),re(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),H(`success`),z(t.message??E.saved),window.setTimeout(()=>{o(),a()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),H(`error`),z(t.error??t.message??E.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[F,se,a,o,E.revokeFailed,E.saved]),(0,Q.useEffect)(()=>()=>{F&&k(F).catch(()=>{})},[F]);let le=async()=>{try{await y(e),o(),a()}catch{}},ue=async()=>{H(`waiting`),z(E.oauthStarting),S(null);try{I((await oe(e)).sessionId)}catch(e){H(`error`),z(e instanceof Error?e.message:E.revokeFailed)}},de=async()=>{if(F){try{await ae(F)}catch{}H(`idle`),z(null),I(null),te(null),re(null)}},he=async()=>{if(!(!F||!ie.trim()))try{await et(F,ie.trim()),G(``),z(E.oauthProcessingCode)}catch(e){H(`error`),z(e instanceof Error?e.message:E.revokeFailed)}},ge=async()=>{try{await B(e),o(),a()}catch(e){S(e instanceof Error?e.message:E.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)(ye,{className:`text-base font-semibold text-fg`,children:c?.name??e}),(0,$.jsx)(me,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:l(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,w.press),children:(0,$.jsx)(P,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[d?.description?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d.description}):null,c?.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:c.baseUrl})]}):c?.category===`extension`?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.apiUrlExtensionHint}):null,D?(0,$.jsx)(tr,{providerId:e,inputId:`manage-api-key`,value:p,onChange:e=>{m(e),v(!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}}):c?.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}),c?.extensionId?(0,$.jsxs)(s,{to:`/settings/ext/${encodeURIComponent(c.extensionId)}`,className:`inline-flex w-fit items-center gap-1 font-medium text-accent hover:underline`,title:r.extensionSettingsLinkTitle,onClick:a,children:[r.openExtensionSettings,(0,$.jsx)(R,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,O?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:E.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:A?E.sourceOauth:E.oauthHint})]}),A?(0,$.jsx)(W,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void ge(),children:E.revoke}):(0,$.jsxs)(W,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:se,onClick:()=>void ue(),children:[se?(0,$.jsx)(X,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(He,{className:`size-3.5`,"aria-hidden":!0}),E.oauth]})]}),L?(0,$.jsx)(`p`,{className:l(`text-xs`,V===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:L}):null,V===`waiting`||V===`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)(R,{className:`size-4`,"aria-hidden":!0}),E.openAuthPage]}):null,(0,$.jsx)(W,{type:`button`,variant:`secondary`,onClick:()=>void de(),children:E.cancelOAuth})]}):null,ne?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:ne}):null,V===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:ie,onChange:e=>G(e.target.value),onKeyDown:e=>e.key===`Enter`&&void he(),placeholder:E.pasteRedirectUrl,className:l(`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`,U)}),(0,$.jsx)(W,{type:`button`,variant:`primary`,onClick:()=>void he(),children:E.submitCode})]}):null]}):null,K.length>0&&D?(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:[fe(e,r),(0,$.jsx)(R,{className:`size-3`,"aria-hidden":!0})]},e))}):null,f.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,` (`,f.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:f.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:[j?(0,$.jsxs)(W,{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)(be,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:D&&q&&!M(p.trim())?(0,$.jsx)(W,{type:`button`,variant:`primary`,disabled:!p.trim()||h||_,onClick:()=>void ce(),children:_?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(Oe,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):h?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(X,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,$.jsx)(We,{open:C,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,c?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void le(),onCancel:()=>T(!1)})]})}function ar({providerId:e,customConfig:t,labels:n,language:r,onClose:i,onSaved:a}){let o=u(r).modelsSettings,s=t?.providers[e],[c,d]=(0,Q.useState)(s?.baseUrl??``),[f,p]=(0,Q.useState)(s?.apiKey??``),[m,h]=(0,Q.useState)(s?.models??[]),[g,_]=(0,Q.useState)(s?.modelDiscovery?.enabled===!0),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(null),[D,O]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(null),j=n=>{if(!t)return null;let r=f.trim(),i={...s,baseUrl:c.trim()||void 0,apiKey:M(r)?s?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},N=async()=>{let e=j({models:m,modelDiscovery:{enabled:g}});if(e){y(!0),x(null);try{await qe(e),a(),i()}catch(e){x(e instanceof Error?e.message:n.saveError)}finally{y(!1)}}},F=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await qe({providers:r}),a(),i()}catch{}},I=(e,t)=>{A({model:e,isNew:t}),O(!0)},L=async e=>{if(!k)return;let t=k.isNew?[...m,e]:m.map(t=>t.id===e.id?e:t);h(t);let r=j({models:t});if(r)try{await qe(r),a()}catch(e){x(e instanceof Error?e.message:n.saveError)}},R=async e=>{let t=m.filter(t=>t.id!==e);h(t),E(null);let r=j({models:t});if(r)try{await qe(r),a()}catch(e){x(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)(ye,{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)(me,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:l(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,w.press),children:(0,$.jsx)(P,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`manage-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,$.jsx)(`input`,{id:`manage-base-url`,type:`url`,autoComplete:`off`,value:c,onChange:e=>d(e.target.value),className:l(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,U)})]}),(0,$.jsx)(tr,{providerId:e,inputId:`manage-custom-api-key`,value:f,onChange:p,labels:{apiKeyLabel:n.apiKeyLabel,apiKeyPlaceholder:n.apiKeyPlaceholder,maskedHelp:n.maskedHelp,copy:n.copy,copied:n.copied,show:n.showKey,hide:n.hideKey,notInConfigFile:n.notInConfigFile,loadFailed:n.loadFailed}}),(0,$.jsxs)(`label`,{className:`flex items-start gap-3 rounded-xl border border-edge-subtle bg-surface-panel/40 p-3`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:g,onChange:e=>_(e.target.checked),className:`mt-0.5 size-4 rounded border-edge accent-accent`}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:r===`zh`?`自动同步模型目录`:`Automatically sync model catalog`}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-muted`,children:r===`zh`?`启动时及定时从此服务的 /models 接口更新模型。`:`Update models from this service’s /models endpoint at startup and on schedule.`})]})]}),(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-semibold text-fg`,children:[o.modelsSection,m.length>0?` (${m.length})`:``]}),(0,$.jsxs)(W,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>I(null,!0),children:[(0,$.jsx)(te,{className:`size-3.5`,"aria-hidden":!0}),o.addModel]})]}),m.length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:o.modelsEmpty}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:m.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:l(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,w.press),onClick:()=>I(e,!1),"aria-label":o.editModel,children:(0,$.jsx)($e,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,className:l(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-red-600 dark:hover:text-red-400`,w.press),onClick:()=>E(e.id),"aria-label":o.removeModel,children:(0,$.jsx)(be,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),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:[(0,$.jsxs)(W,{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:()=>C(!0),children:[(0,$.jsx)(be,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(W,{type:`button`,variant:`primary`,disabled:v,onClick:()=>void N(),children:v?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(X,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,$.jsx)(We,{open:S,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void F(),onCancel:()=>C(!1)}),(0,$.jsx)(We,{open:T!==null,title:o.removeModel,description:o.removeModelConfirm.replace(`{{id}}`,T??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{T&&R(T)},onCancel:()=>E(null)}),(0,$.jsx)($n,{open:D,onOpenChange:e=>{O(e),e||A(null)},providerId:e,model:k?.model??null,isNew:k?.isNew??!1,onSave:e=>void L(e),m:o})]})}async function or(){let e=await p(m(`/api/models/catalog`)),t=await e.json().catch(()=>null);if(!e.ok||!t?.ok||!t.payload)throw Error(t?.error?.message??`HTTP ${e.status}`);return t.payload}function sr(){let e=f(e=>e.language)===`zh`,{data:t,error:n,isLoading:r}=g(F,or,{revalidateOnFocus:!1}),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(null);if(r)return(0,$.jsx)(Ve,{className:`h-24 w-full rounded-2xl`});let c=Object.values(t?.sources??{}),l=c.reduce((e,t)=>e+t.models.filter(e=>e.availability===`available`).length,0),u=(t?.references??[]).filter(e=>e.availability===`unavailable`),d=t?.sync.lastSuccessAt??Math.max(0,...c.map(e=>e.lastSuccessAt)),h=o??(n instanceof Error?n.message:t?.sync.lastError??Object.values(t?.sync.sourceErrors??{})[0]),_=async()=>{a(!0),s(null);try{let e=await p(m(`/api/models/catalog/refresh`),{method:`POST`});if(!e.ok)throw Error(`HTTP ${e.status}`);await ve()}catch(t){s(t instanceof Error?t.message:e?`模型目录刷新失败`:`Model catalog refresh failed`)}finally{a(!1)}};return(0,$.jsx)(`div`,{className:`rounded-2xl border border-edge-subtle bg-surface-panel/40 p-4`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[h||u.length>0?(0,$.jsx)(L,{className:`size-4 text-amber-500`,"aria-hidden":!0}):(0,$.jsx)(Oe,{className:`size-4 text-emerald-500`,"aria-hidden":!0}),(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:e?`模型目录同步`:`Model catalog sync`})]}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e?`${c.length} 个来源,${l} 个可用模型${d?` · 最近同步 ${new Date(d).toLocaleString()}`:``}`:`${c.length} sources, ${l} available models${d?` · Last synced ${new Date(d).toLocaleString()}`:``}`}),u.length>0?(0,$.jsx)(`div`,{className:`mt-2 space-y-1 text-sm text-amber-700 dark:text-amber-300`,children:u.slice(0,3).map(t=>(0,$.jsxs)(`p`,{children:[t.ref,` `,e?`不可用`:`is unavailable`,t.suggestedRef?` · ${e?`建议`:`Suggested`} ${t.suggestedRef}`:``,` · ${t.locations.length} ${e?`处引用`:`references`}`]},t.ref))}):null,h?(0,$.jsx)(`p`,{className:`mt-2 text-sm text-danger`,children:h}):null]}),(0,$.jsxs)(W,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>void _(),children:[i?(0,$.jsx)(X,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(T,{className:`size-4`,"aria-hidden":!0}),i?e?`刷新中…`:`Refreshing…`:e?`立即刷新`:`Refresh now`]})]})})}function cr(e){return G.includes(e)}function lr(){let e=(0,Z.c)(79),t=f(fr),n;e[0]===t?n=e[1]:(n=u(t),e[0]=t,e[1]=n);let r=n,l=r.capabilitiesSettings,d=a(),[p,m]=i(),{capability:h}=c(),g=bt(dr),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(null),x=Vn(),S,C;e[2]!==h||e[3]!==p||e[4]!==m?(S=()=>{if(h!==`models`||p.get(`add`)!==`1`)return;v(!0);let e=new URLSearchParams(p);e.delete(`add`),m(e,{replace:!0})},C=[h,p,m],e[2]=h,e[3]=p,e[4]=m,e[5]=S,e[6]=C):(S=e[5],C=e[6]),(0,Q.useEffect)(S,C);let w;e[7]!==l.unsavedChanges||e[8]!==g?(w=e=>g.get(e)?.dirty?(0,$.jsx)(`span`,{className:`size-1.5 rounded-full bg-amber-500`,"aria-label":l.unsavedChanges,title:l.unsavedChanges}):void 0,e[7]=l.unsavedChanges,e[8]=g,e[9]=w):w=e[9];let T=w,E;e[10]!==l.modelsHint||e[11]!==l.tabs.models?(E={id:`models`,icon:ie,label:l.tabs.models,hint:l.modelsHint},e[10]=l.modelsHint,e[11]=l.tabs.models,e[12]=E):E=e[12];let D=l.tabs.image,O=l.imageHint,k;e[13]===T?k=e[14]:(k=T(`image-models`),e[13]=T,e[14]=k);let A;e[15]!==l.imageHint||e[16]!==l.tabs.image||e[17]!==k?(A={id:`image`,icon:se,label:D,hint:O,suffix:k},e[15]=l.imageHint,e[16]=l.tabs.image,e[17]=k,e[18]=A):A=e[18];let j=l.tabs.voice,M=l.voiceHint,N;e[19]===T?N=e[20]:(N=T(`voice`),e[19]=T,e[20]=N);let P;e[21]!==l.tabs.voice||e[22]!==l.voiceHint||e[23]!==N?(P={id:`voice`,icon:ge,label:j,hint:M,suffix:N},e[21]=l.tabs.voice,e[22]=l.voiceHint,e[23]=N,e[24]=P):P=e[24];let F=l.tabs.search,I=l.searchHint,L;e[25]===T?L=e[26]:(L=T(`search`),e[25]=T,e[26]=L);let R;e[27]!==l.searchHint||e[28]!==l.tabs.search||e[29]!==L?(R={id:`search`,icon:Ze,label:F,hint:I,suffix:L},e[27]=l.searchHint,e[28]=l.tabs.search,e[29]=L,e[30]=R):R=e[30];let z;e[31]!==P||e[32]!==R||e[33]!==E||e[34]!==A?(z=[E,A,P,R],e[31]=P,e[32]=R,e[33]=E,e[34]=A,e[35]=z):z=e[35];let B=z,V;e[36]===d?V=e[37]:(V=e=>d(Ee(e)),e[36]=d,e[37]=V);let H=V,U=ur;if(!cr(h)){let t;return e[38]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(o,{to:Ee(`models`),replace:!0}),e[38]=t):t=e[38],t}let ee=r.nav.settingsCapabilities,te=l.subtitle,ne;e[39]===t?ne=e[40]:(ne=Ge(t,`configuration`),e[39]=t,e[40]=ne);let re;e[41]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsx)(de,{className:`size-4`,"aria-hidden":!0}),e[41]=re):re=e[41];let ae;e[42]===l.agentSettingsLink?ae=e[43]:(ae=(0,$.jsx)(W,{asChild:!0,variant:`secondary`,children:(0,$.jsxs)(s,{to:`/agents`,children:[re,l.agentSettingsLink]})}),e[42]=l.agentSettingsLink,e[43]=ae);let G;e[44]!==l.docsLink||e[45]!==l.subtitle||e[46]!==r.nav.settingsCapabilities||e[47]!==ne||e[48]!==ae?(G=(0,$.jsx)(nt,{title:ee,subtitle:te,docsLink:ne,docsLabel:l.docsLink,actions:ae}),e[44]=l.docsLink,e[45]=l.subtitle,e[46]=r.nav.settingsCapabilities,e[47]=ne,e[48]=ae,e[49]=G):G=e[49];let oe;e[50]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,$.jsx)(xt,{}),e[50]=oe):oe=e[50];let K;e[51]!==l.tabsAria||e[52]!==h||e[53]!==B||e[54]!==H?(K=(0,$.jsx)(vt,{items:B,activeTab:h,onChange:H,ariaLabel:l.tabsAria,tabIdPrefix:`capability-tab`,panelIdPrefix:`capability-panel`}),e[51]=l.tabsAria,e[52]=h,e[53]=B,e[54]=H,e[55]=K):K=e[55];let q;e[56]!==l.connectedProviders||e[57]!==h||e[58]!==B?(q=B.map(e=>(0,$.jsx)(mr,{id:e.id,activeSection:h,hint:e.hint,children:e.id===`models`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(sr,{}),(0,$.jsx)(qn,{labels:l.connectedProviders,onAdd:()=>v(!0),onManage:(e,t)=>b({providerId:e,isCustom:t})})]}):(0,$.jsx)(pr,{section:e.id})},e.id)),e[56]=l.connectedProviders,e[57]=h,e[58]=B,e[59]=q):q=e[59];let ce;e[60]!==_||e[61]!==l.addProviderDialog||e[62]!==t||e[63]!==x.builtinRows||e[64]!==x.customConfig?(ce=(0,$.jsx)(Pn,{open:_,onOpenChange:v,builtinRows:x.builtinRows,customConfig:x.customConfig,labels:l.addProviderDialog,language:t,onSaved:U}),e[60]=_,e[61]=l.addProviderDialog,e[62]=t,e[63]=x.builtinRows,e[64]=x.customConfig,e[65]=ce):ce=e[65];let le;e[66]!==l.manageProviderDialog||e[67]!==t||e[68]!==y||e[69]!==x.allModels||e[70]!==x.builtinRows||e[71]!==x.customConfig?(le=y?(0,$.jsx)(rr,{open:!0,onOpenChange:e=>{e||b(null)},providerId:y.providerId,isCustom:y.isCustom,builtinRows:x.builtinRows,customConfig:x.customConfig,allModels:x.allModels,labels:l.manageProviderDialog,language:t,onSaved:U}):null,e[66]=l.manageProviderDialog,e[67]=t,e[68]=y,e[69]=x.allModels,e[70]=x.builtinRows,e[71]=x.customConfig,e[72]=le):le=e[72];let ue;return e[73]!==G||e[74]!==K||e[75]!==q||e[76]!==ce||e[77]!==le?(ue=(0,$.jsxs)(rt,{children:[G,oe,K,q,ce,le]}),e[73]=G,e[74]=K,e[75]=q,e[76]=ce,e[77]=le,e[78]=ue):ue=e[78],ue}function ur(){ve()}function dr(e){return e.sections}function fr(e){return e.language}function pr(e){let t=(0,Z.c)(3),{section:n}=e;switch(n){case`models`:return null;case`image`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(kt,{}),t[0]=e):e=t[0],e}case`voice`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(nn,{}),t[1]=e):e=t[1],e}case`search`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(kn,{}),t[2]=e):e=t[2],e}}}function mr({id:e,activeSection:t,hint:n,children:r}){let i=e===t,a=(0,Q.useRef)(i);return i&&(a.current=!0),a.current?(0,$.jsxs)(`div`,{role:`tabpanel`,id:`capability-panel-${e}`,"aria-labelledby":`capability-tab-${e}`,hidden:!i,className:l(`min-w-0 rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,i?`flex flex-col gap-3`:void 0),children:[i?(0,$.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:n}):null,r]}):null}export{lr as CapabilitiesSettingsPanel};