@xopcai/xopc 0.0.161 → 0.0.162
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.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-o7GRljfD.js → activity-store-hpcNv9MZ.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-9R3szLMc.js → agent-avatar-dicebear-Zf9UQEmQ.js} +1 -1
- package/dist/gateway/static/root/assets/agents-DfVkZlHc.js +2 -0
- package/dist/gateway/static/root/assets/{api-jSTqFMq9.js → api-Dnatri09.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-D81cyE76.js → app-management-settings-panel-BBTR9wJP.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-Ct6bZQCV.js → appearance-settings-C2zpLCHD.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-BMtAa4Ra.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-CfD7AZKn.js → archive-plugin-9eR_ODY1.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CP_Gaxt3.js → attachment-load-DPuWYUeX.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-BGKM_NDZ.js → automation-suggestion-card-Dw49OJRl.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-BiSAMYTr.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-IPr2EVnS.js → binary-plugins-BdkJpDFm.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-B6aHEGA6.js → block-editor-CAi7SXYU.js} +47 -47
- package/dist/gateway/static/root/assets/browser-settings-page-DHmaEJS2.js +8 -0
- package/dist/gateway/static/root/assets/browser-workflow-inputs-Dx6wkGz1.js +1 -0
- package/dist/gateway/static/root/assets/browser-workflows-page-Skertc-A.js +3 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-B5wSgf4f.js +2 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-CCX9-LjU.js → capability-presets-api-CNFl7dM3.js} +1 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-DyvFZwBj.js +2 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-MmLMLDWf.js → channel-recipient-api-DYQyGDw4.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-BBKEqDZn.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-Drk110ve.js +1 -0
- package/dist/gateway/static/root/assets/{connector-logo-BbjzIs87.js → connector-logo-Bng6kxYF.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-HpgaUDQ1.js +2 -0
- package/dist/gateway/static/root/assets/desktop-pet-Bpf6oegd.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-settings-DQLqGLc0.js → desktop-pet-settings-BVUyefSd.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-ClsiXhmz.js → directory-picker-path-field-DjSZAPz_.js} +1 -1
- package/dist/gateway/static/root/assets/{dreaming-settings-CjMPPdzg.js → dreaming-settings-CAZk2AM4.js} +3 -3
- package/dist/gateway/static/root/assets/{extension-debug-page-57eizjhB.js → extension-debug-page-C2F6vTTd.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CsbSb3u1.js → extension-page-AnIt4bn4.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DKA9-lyP.js → extension-settings-page-CLSc6682.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-DIPJuzBZ.js → gateway-config-api-DLFyZv33.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-CDLqAQY7.js → gateway-settings-DnQAA-qq.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-DrfSJtvT.js → gateway-startup-retry-DbzLyJ3R.js} +1 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-DrnKFC6M.js +1 -0
- package/dist/gateway/static/root/assets/goal-detail-page-Cw1hpJkZ.js +4 -0
- package/dist/gateway/static/root/assets/{goals-config-api-lGC10UkU.js → goals-config-api-REmr3QCr.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-BDGkTVma.js +2 -0
- package/dist/gateway/static/root/assets/{goals-settings-BWq0pdrA.js → goals-settings-Dz0F3uRO.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-D4o8BJVv.js → heartbeat-settings-CQFY5gYs.js} +1 -1
- package/dist/gateway/static/root/assets/index-C8JkTS6d.js +199 -0
- package/dist/gateway/static/root/assets/index-hmrG55qg.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-6T2QYehS.js → keyboard-shortcuts-settings-BnOQXU5k.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-Bdef1b7F.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-DCjg2K9f.js → local-apps-page-KsOtWOyM.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-Dar-xqQr.js → locale-store-0lpYdNDr.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-CyYCBqym.js → logs-page-CwLPgrWh.js} +3 -3
- package/dist/gateway/static/root/assets/{markdown-split-rt1XO43g.js → markdown-split-D5GRg10r.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-Bwo8CJuh.js → media-plugins-C1ryULGs.js} +1 -1
- package/dist/gateway/static/root/assets/messages-BwQ3WssU.js +5 -0
- package/dist/gateway/static/root/assets/{notes-page-Dp-pkX7d.js → notes-page-CIeZ1_DT.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-Cf06q19x.js +4 -0
- package/dist/gateway/static/root/assets/{page-tabs-CzZ4iKOb.js → page-tabs-Caj1-E_X.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-3E_Qa-58.js → preview-open-alternatives-DKwEce-9.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-B2T48Sbt.js → product-open-page-B90ZskkN.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-SHTurM4t.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-BcC2qUAw.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-6vGefBHv.js +1 -0
- package/dist/gateway/static/root/assets/save-bar-controls-BDYt53uQ.js +1 -0
- package/dist/gateway/static/root/assets/{schedule-field-TkqUL3wm.js → schedule-field-Bcdni4Pj.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-DC-iU5IG.js → schema-form-D7oCARF7.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-C5014a53.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-CDY3ZI1K.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-Dpqth3oA.js → settings-collapsible-section-6eNF8Jey.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-CNqF6IwY.js → settings-form-section-CARTHCxH.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-DkvwitK_.js → settings-loading-skeleton-DEwYqESe.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-B6vVdHeQ.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-layout-DWvNgISx.js → settings-page-layout-D3srt5Bi.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-z-rF0Hdg.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-DGpSPW-n.js → share-preview-page-Ck9SxiXw.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-CHZFXE_d.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-B7p2QNXt.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-ncw3tX9P.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-8TxxSbUw.js → system-settings-panel-DLBUQSk2.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-B5FzMWOx.js → theme-store-C1oaqeD2.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-DEGtSA5h.js → typed-models-lib-Divbg_C4.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-BDU6FneG.js → use-channel-catalog-CP9a_rAf.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-iYfeSLKI.js +1 -0
- package/dist/gateway/static/root/assets/voice-api-key-field-CrwkicvT.js +1 -0
- package/dist/gateway/static/root/assets/work-discovery-page-BQWxyPg8.js +1 -0
- package/dist/gateway/static/root/assets/work-item-detail-page-50ZzGay5.js +1 -0
- package/dist/gateway/static/root/assets/work-page-DPqEahx7.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-Cwi8Pz7n.js → workflow-run-setup-panel-DbDPYQwB.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-C3eIC5HZ.js +11 -0
- package/dist/gateway/static/root/index.html +7 -7
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.d.ts +1 -0
- package/dist/src/agent/agent-manager.js +1 -0
- package/dist/src/agent/client-error-format.js +3 -3
- package/dist/src/agent/outcomes/task-evaluation.d.ts +20 -0
- package/dist/src/agent/outcomes/task-evaluation.js +48 -0
- package/dist/src/agent/outcomes/task-verifier.d.ts +29 -0
- package/dist/src/agent/outcomes/task-verifier.js +71 -0
- package/dist/src/agent/prompt/memory/index.js +1 -1
- package/dist/src/agent/prompt/service-prompt-builder.js +32 -1
- package/dist/src/agent/service.js +1 -0
- package/dist/src/agent/service.types.d.ts +1 -0
- package/dist/src/agent/tools/browser/tool/browser-use-tool.d.ts +1 -7
- package/dist/src/agent/tools/browser/tool/browser-use-tool.js +2 -73
- package/dist/src/agent/tools/browser/tool/schemas.d.ts +1 -13
- package/dist/src/agent/tools/browser/tool/schemas.js +1 -9
- package/dist/src/agent/tools/browser-recipe-tool.d.ts +12 -0
- package/dist/src/agent/tools/browser-recipe-tool.js +113 -0
- package/dist/src/agent/tools/factory.d.ts +2 -0
- package/dist/src/agent/tools/factory.js +2 -0
- package/dist/src/agent/tools/index.d.ts +1 -0
- package/dist/src/agent/tools/index.js +2 -1
- package/dist/src/automations/domain/types.d.ts +13 -0
- package/dist/src/automations/domain/validation.d.ts +44 -24
- package/dist/src/automations/domain/validation.js +27 -18
- package/dist/src/automations/draft/automation-draft-validator.d.ts +6 -1
- package/dist/src/automations/draft/automation-draft-validator.js +1 -0
- package/dist/src/automations/service/action-executor.d.ts +1 -0
- package/dist/src/automations/service/action-executor.js +22 -0
- package/dist/src/browser/index.d.ts +0 -1
- package/dist/src/browser/index.js +1 -2
- package/dist/src/browser/pipeline/runner.d.ts +9 -2
- package/dist/src/browser/pipeline/runner.js +151 -105
- package/dist/src/browser/pipeline/schema.d.ts +21 -15
- package/dist/src/browser/pipeline/schema.js +93 -99
- package/dist/src/browser/recipes/index.d.ts +3 -0
- package/dist/src/browser/recipes/index.js +3 -0
- package/dist/src/browser/recipes/repository.d.ts +13 -0
- package/dist/src/browser/recipes/repository.js +81 -0
- package/dist/src/browser/recipes/runtime-service.d.ts +6 -0
- package/dist/src/browser/recipes/runtime-service.js +30 -0
- package/dist/src/browser/recipes/service.d.ts +36 -0
- package/dist/src/browser/recipes/service.js +186 -0
- package/dist/src/browser/recipes/types.d.ts +36 -0
- package/dist/src/browser/recipes/types.js +1 -0
- package/dist/src/cli/commands/browser-cli-helpers.js +6 -12
- package/dist/src/cli/commands/browser.js +4 -3
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/config/schema.d.ts +3 -3
- package/dist/src/config/schema.js +21 -21
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.d.ts +1 -1
- package/dist/src/gateway/hono/routes/browser-workflows.d.ts +3 -0
- package/dist/src/gateway/hono/routes/browser-workflows.js +78 -0
- package/dist/src/gateway/hono/routes/home.js +1 -0
- package/dist/src/gateway/hono/routes/index.js +4 -0
- package/dist/src/gateway/hono/routes/interaction-state.d.ts +3 -0
- package/dist/src/gateway/hono/routes/interaction-state.js +45 -0
- package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
- package/dist/src/gateway/hono/routes/memory.js +33 -4
- package/dist/src/gateway/hono/routes/task-outcomes.d.ts +3 -0
- package/dist/src/gateway/hono/routes/task-outcomes.js +109 -0
- package/dist/src/gateway/hono/routes/you.d.ts +10 -2
- package/dist/src/gateway/hono/routes/you.js +184 -28
- package/dist/src/gateway/service/run-gateway-agent.js +84 -0
- package/dist/src/gateway/service.d.ts +3 -0
- package/dist/src/gateway/service.js +14 -0
- package/dist/src/proactive/insight-repository.d.ts +2 -0
- package/dist/src/proactive/insight-repository.js +5 -2
- package/dist/src/proactive/run-processor.js +22 -1
- package/dist/src/proactive/types.d.ts +2 -0
- package/dist/src/proactive/value-score.d.ts +13 -0
- package/dist/src/proactive/value-score.js +30 -0
- package/dist/src/share/share-types.js +5 -5
- package/dist/src/share/site-share-types.d.ts +1 -1
- package/dist/src/share/site-share-types.js +5 -5
- package/dist/src/storage/sqlite/index.d.ts +3 -0
- package/dist/src/storage/sqlite/index.js +4 -1
- package/dist/src/storage/sqlite/interaction-state-repository.d.ts +17 -0
- package/dist/src/storage/sqlite/interaction-state-repository.js +60 -0
- package/dist/src/storage/sqlite/memory-records-repository.js +1 -1
- package/dist/src/storage/sqlite/migrations/053_browser_recipes.sql +45 -0
- package/dist/src/storage/sqlite/migrations/054_task_outcomes.sql +24 -0
- package/dist/src/storage/sqlite/migrations/055_relationship_settings.sql +14 -0
- package/dist/src/storage/sqlite/migrations/056_task_verification.sql +6 -0
- package/dist/src/storage/sqlite/migrations/057_interaction_states.sql +11 -0
- package/dist/src/storage/sqlite/migrations/058_proactive_value.sql +3 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/relationship-settings-repository.d.ts +17 -0
- package/dist/src/storage/sqlite/relationship-settings-repository.js +64 -0
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/schema.sql +46 -0
- package/dist/src/storage/sqlite/task-outcome-repository.d.ts +90 -0
- package/dist/src/storage/sqlite/task-outcome-repository.js +138 -0
- package/dist/src/user-context/interaction-state.d.ts +13 -0
- package/dist/src/user-context/interaction-state.js +69 -0
- package/dist/src/user-context/memory-use-audit.d.ts +10 -0
- package/dist/src/user-context/memory-use-audit.js +25 -0
- package/dist/src/user-context/personal-playbook.d.ts +11 -0
- package/dist/src/user-context/personal-playbook.js +41 -0
- package/dist/src/user-context/projection.d.ts +4 -0
- package/dist/src/user-context/projection.js +5 -1
- package/dist/src/user-context/relationship-continuity.d.ts +14 -0
- package/dist/src/user-context/relationship-continuity.js +51 -0
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/action-boundary-settings-panel-BIVBUiNT.js +0 -1
- package/dist/gateway/static/root/assets/agents-_qbUaYbs.js +0 -2
- package/dist/gateway/static/root/assets/apps-page-0sPqD0FK.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-BxWBuBsE.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-C499b9AH.js +0 -8
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-Dva9SiPK.js +0 -2
- package/dist/gateway/static/root/assets/channels-settings-DNAU7u9o.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-CIOH7tgn.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-TwiBp8vY.js +0 -2
- package/dist/gateway/static/root/assets/desktop-pet-CYH5ZSXy.js +0 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-Q3B0E-0s.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-C5VAK04G.js +0 -4
- package/dist/gateway/static/root/assets/goals-page-BJb-5IYw.js +0 -2
- package/dist/gateway/static/root/assets/index-CkUHH170.css +0 -1
- package/dist/gateway/static/root/assets/index-vq_cJZJC.js +0 -199
- package/dist/gateway/static/root/assets/local-app-workbench-page-euH17Kvb.js +0 -2
- package/dist/gateway/static/root/assets/messages-CxySDn9d.js +0 -5
- package/dist/gateway/static/root/assets/models-hub-panel-DObxxjc9.js +0 -2
- package/dist/gateway/static/root/assets/notes-workbench-CCb4RXcZ.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-BvEcriRC.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-B_e79MRJ.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-DGcqnYfR.js +0 -1
- package/dist/gateway/static/root/assets/save-bar-controls-CkeKasGm.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-DQZhrDJ8.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BkdeN99Y.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-qPG7I2zd.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-lwRAh9aw.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-BGj9IVUr.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-B2UBAs5U.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-DdjzFZ8I.js +0 -2
- package/dist/gateway/static/root/assets/user-context-page-BTTZpAGV.js +0 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-DuDQd-WU.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-BUVkVCsW.js +0 -1
- package/dist/gateway/static/root/assets/work-item-detail-page-DeEPPu4n.js +0 -1
- package/dist/gateway/static/root/assets/work-page-DQNUyTUq.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-BIy4wrzO.js +0 -11
- package/dist/src/browser/pipeline/source.d.ts +0 -9
- package/dist/src/browser/pipeline/source.js +0 -77
|
@@ -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-BwQ3WssU.js";import{l as c,n as l,o as u,r as d,s as f}from"./locale-store-0lpYdNDr.js";import{$l as p,Dc as m,Ec as h,Jc as g,Jl as _,Jo as v,Ll as y,Ls as b,Mt as x,Nt as S,Sl as C,Tc as w,Ul as T,Vl as E,Xa as D,Xn as O,Yr as k,Za as A,Zs as j,_c as M,ac as N,cu as P,eu as F,hs as I,ic as L,jt as R,ks as ee,nc as te,ou as z,ps as B,rs as V,ru as H,ts as ne,ws as U,xc as W,zc as G,zs as K}from"./index-C8JkTS6d.js";import{n as re,r as ie,t as ae}from"./settings-page-layout-D3srt5Bi.js";import{n as oe}from"./settings-loading-skeleton-DEwYqESe.js";import{t as se}from"./settings-advanced-gate-CDY3ZI1K.js";import{n as ce,t as q}from"./settings-form-section-CARTHCxH.js";import{t as le}from"./page-tabs-Caj1-E_X.js";import{c as ue,r as de,s as J}from"./typed-models-lib-Divbg_C4.js";import{i as fe,l as pe,s as me,u as he}from"./gateway-config-api-DLFyZv33.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)(ne,{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)(P,{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)(V,{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:te,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)(V,{value:`must_respond`,children:n.browserDialogPolicyMustRespond}),t[20]=n.browserDialogPolicyMustRespond,t[21]=g);let _;t[22]===n.browserDialogPolicyAutoDismiss?_=t[23]:(_=(0,Z.jsx)(V,{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)(V,{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)(ne,{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 j;t[54]===n.browserSecurityShow?j=t[55]:(j=(0,Z.jsx)(ce,{icon:N,title:n.browserSecurityShow}),t[54]=n.browserSecurityShow,t[55]=j);let M;t[56]===i?M=t[57]:(M=e=>i({browserAllowPrivateUrls:e.target.checked}),t[56]=i,t[57]=M);let P;t[58]!==r.browserAllowPrivateUrls||t[59]!==M?(P=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserAllowPrivateUrls,onChange:M}),t[58]=r.browserAllowPrivateUrls,t[59]=M,t[60]=P):P=t[60];let F;t[61]===n.browserAllowPrivateOn?F=t[62]:(F=(0,Z.jsx)(`span`,{children:n.browserAllowPrivateOn}),t[61]=n.browserAllowPrivateOn,t[62]=F);let I;t[63]!==P||t[64]!==F?(I=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[P,F]}),t[63]=P,t[64]=F,t[65]=I):I=t[65];let L;t[66]!==n.desc.browserAllowPrivateUrls||t[67]!==n.label.browserAllowPrivateUrls||t[68]!==I?(L=(0,Z.jsx)(Q,{label:n.label.browserAllowPrivateUrls,description:n.desc.browserAllowPrivateUrls,children:I}),t[66]=n.desc.browserAllowPrivateUrls,t[67]=n.label.browserAllowPrivateUrls,t[68]=I,t[69]=L):L=t[69];let R=n.label.browserCommandTimeout,ee=n.desc.browserCommandTimeout,z;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(z=J(),t[70]=z):z=t[70];let B=r.browserCommandTimeout??``,H;t[71]===i?H=t[72]:(H=e=>{let t=e.target.value;i({browserCommandTimeout:t===``?void 0:Number.parseInt(t,10)})},t[71]=i,t[72]=H);let U;t[73]!==B||t[74]!==H?(U=(0,Z.jsx)(`input`,{type:`number`,className:z,min:5,value:B,placeholder:`30`,onChange:H}),t[73]=B,t[74]=H,t[75]=U):U=t[75];let W;t[76]!==n.desc.browserCommandTimeout||t[77]!==n.label.browserCommandTimeout||t[78]!==U?(W=(0,Z.jsx)(Q,{label:R,description:ee,children:U}),t[76]=n.desc.browserCommandTimeout,t[77]=n.label.browserCommandTimeout,t[78]=U,t[79]=W):W=t[79];let G;t[80]!==L||t[81]!==W?(G=(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[L,W]}),t[80]=L,t[81]=W,t[82]=G):G=t[82];let K;t[83]!==j||t[84]!==G?(K=(0,Z.jsx)(`div`,{id:A,className:`scroll-mt-24`,children:(0,Z.jsxs)(q,{className:`border border-amber-500/20`,children:[j,G]})}),t[83]=j,t[84]=G,t[85]=K):K=t[85];let re;return t[86]!==k||t[87]!==K?(re=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[k,K]}),t[86]=k,t[87]=K,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=v(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)(y,{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)(P,{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=k(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:W,title:n.browserSetupExtTitle,description:n.browserSetupExtDesc,recommended:!0},{id:`cloakbrowser`,icon:L,title:n.browserBackendCloakBrowser,description:n.browserModeCloakTagline},{id:`local`,icon:G,title:n.browserSetupLocalTitle,description:n.browserSetupLocalDesc},{id:`cloud`,icon:_,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:z,color:`text-green-600 dark:text-green-400`,label:i.browserStatusReady},not_installed:{icon:K,color:`text-amber-600 dark:text-amber-400`,label:i.browserStatusNotInstalled},checking:{icon:g,color:`text-fg-muted`,label:i.browserStatusChecking},unknown:{icon:H,color:`text-fg-muted`,label:i.browserStatusUnknown},error:{icon:F,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 _;return t[23]!==l||t[24]!==m||t[25]!==h?(_=(0,Z.jsxs)(`span`,{className:l,children:[m,h]}),t[23]=l,t[24]=m,t[25]=h,t[26]=_):_=t[26],_}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)(S,Re),{instances:u,launchStatus:d,launchMessage:f,testStatus:p,testMessage:m,executablePath:_}=c,v=(0,Y.useCallback)(async()=>{try{l({type:`patch`,patch:{instances:await a()}})}catch{}},[a]);(0,Y.useEffect)(()=>{v();let e=setInterval(()=>void v(),8e3);return()=>clearInterval(e)},[v]);let y=(0,Y.useCallback)(async()=>{if(d!==`pending`){l({type:`patch`,patch:{launchStatus:`pending`,launchMessage:null}});try{let t=await r(_.trim()||void 0);l({type:`patch`,patch:{launchStatus:`ok`,launchMessage:e.browserCdpLaunchedAtPort.replace(`{{port}}`,String(t.port))}}),n(t.wsEndpoint),await v()}catch(e){l({type:`patch`,patch:{launchStatus:`error`,launchMessage:e instanceof Error?e.message:String(e)}})}}},[_,r,d,e.browserCdpLaunchedAtPort,n,v]),b=(0,Y.useCallback)(async e=>{await i(e),await v()},[v,i]),x=(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:h,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 y(),children:[d===`pending`?(0,Z.jsx)(g,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(h,{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:_,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 b(t.port),children:[(0,Z.jsx)(j,{className:`size-3`}),e.browserCdpStopLocal]})]},t.port))}):null]}),(0,Z.jsxs)(Fe,{icon:ee,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 x(),children:[p===`pending`?(0,Z.jsx)(g,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(w,{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)(S,Ue),{confirmOpen:f,installStatus:p,installMessage:m,openStatus:_,openMessage:v,runtime:y}=u,{progress:b,running:x,cancelling:C,run:w,reset:T,cancel:D}=i,k=t.kind===`ok`?t.data:null,A=k?.installed===!0,j=p===`installing`||x,N=(0,Y.useCallback)(async()=>{if(A)try{d({type:`patch`,patch:{runtime:await a()}})}catch{}},[a,A]);(0,Y.useEffect)(()=>{if(!A){d({type:`patch`,patch:{runtime:null}});return}N();let e=setInterval(()=>void N(),8e3);return()=>clearInterval(e)},[A,N]);let P=(0,Y.useCallback)(async()=>{d({type:`patch`,patch:{confirmOpen:!1,installStatus:`installing`,installMessage:null}}),T();let t=await w({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 N()},[r,s.binaryPath,s.cacheDir,e.browserCloakInstallFailed,e.browserCloakInstalled,n,N,T,w]),F=(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,_]),I=t.kind===`loading`?`checking`:t.kind===`error`?`error`:A?`ready`:`not_installed`,R=A&&k?.version?`v${k.version} (${k.platform})`:void 0;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Fe,{icon:L,title:e.browserCloakGuideTitle,description:e.browserCloakGuideDesc,status:I,statusDetail:R,m:e,embedded:l,primaryAction:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[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:_===`pending`,onClick:()=>void F(),children:[_===`pending`?(0,Z.jsx)(g,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(h,{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:j,onClick:()=>d({type:`patch`,patch:{confirmOpen:!0}}),children:[j?(0,Z.jsx)(g,{className:`size-3.5 animate-spin`}):A?(0,Z.jsx)(M,{className:`size-3.5`}):p===`installed`?(0,Z.jsx)(z,{className:`size-3.5 text-green-500`}):(0,Z.jsx)(E,{className:`size-3.5`}),j?e.browserCloakInstalling:A?e.browserReinstall:e.browserCloakDownload]})]}),children:[x?(0,Z.jsx)(Ve,{m:e,progress:b,cancelling:C,onCancel:()=>void D()}):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,A&&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)(ne,{className:ue(),value:s.humanPreset,onChange:e=>c({humanPreset:e.target.value}),children:[(0,Z.jsx)(V,{value:`careful`,children:e.browserHumanPresetCareful}),(0,Z.jsx)(V,{value:`default`,children:e.browserHumanPresetDefault})]})})]})]}),(0,Z.jsxs)(q,{className:`mt-4`,children:[(0,Z.jsx)(ce,{icon:L,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)(O,{open:f,title:e.browserConfirmDownloadTitle,description:Ke(e,k),confirmLabel:e.browserConfirmDownloadConfirm,cancelLabel:e.browserConfirmDownloadCancel,onConfirm:()=>void P(),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=B({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:_,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)(w,{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)(ne,{className:ue(),value:d,onChange:e=>n({provider:e.target.value}),children:[(0,Z.jsx)(V,{value:`browserbase`,children:e.browserCloudProviderBrowserbase}),(0,Z.jsx)(V,{value:`browser-use`,children:e.browserCloudProviderBrowserUse})]})}),(0,Z.jsx)(Q,{label:e.label.browserCloudApiKey,description:e.desc.browserCloudApiKey,children:(0,Z.jsx)(I,{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,m;t[0]!==r||t[1]!==n.browserExtensionInstallStep1?(m={id:`install`,label:n.browserExtensionInstallStep1,done:r},t[0]=r,t[1]=n.browserExtensionInstallStep1,t[2]=m):m=t[2];let h=!!i&&o,g;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?(g=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]=g):g=t[15];let _;t[16]!==n.browserExtensionInstallStep2||t[17]!==h||t[18]!==g?(_={id:`load`,label:n.browserExtensionInstallStep2,done:h,detail:g},t[16]=n.browserExtensionInstallStep2,t[17]=h,t[18]=g,t[19]=_):_=t[19];let v;t[20]!==o||t[21]!==n.browserExtensionInstallStep3?(v={id:`connect`,label:n.browserExtensionInstallStep3,done:o},t[20]=o,t[21]=n.browserExtensionInstallStep3,t[22]=v):v=t[22];let y;t[23]!==m||t[24]!==_||t[25]!==v?(y=[m,_,v],t[23]=m,t[24]=_,t[25]=v,t[26]=y):y=t[26];let b=y,x;t[27]===b?x=t[28]:(x=b.filter(Ye),t[27]=b,t[28]=x);let S=x.length,C=n.browserExtensionInstallGuideTitle,w;t[29]===n.browserExtensionInstallGuideTitle?w=t[30]:(w=(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:n.browserExtensionInstallGuideTitle}),t[29]=n.browserExtensionInstallGuideTitle,t[30]=w);let T;t[31]!==S||t[32]!==n.browserExtensionChecklistProgress||t[33]!==b.length?(T=n.browserExtensionChecklistProgress.replace(`{{done}}`,String(S)).replace(`{{total}}`,String(b.length)),t[31]=S,t[32]=n.browserExtensionChecklistProgress,t[33]=b.length,t[34]=T):T=t[34];let E;t[35]===T?E=t[36]:(E=(0,Z.jsx)(`span`,{className:`ml-auto text-xs font-normal text-fg-muted`,children:T}),t[35]=T,t[36]=E);let D;t[37]!==E||t[38]!==w?(D=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[w,E]}),t[37]=E,t[38]=w,t[39]=D):D=t[39];let O;t[40]!==n.browserExtensionChecklistDone||t[41]!==n.browserExtensionChecklistPending||t[42]!==b?(O=(0,Z.jsx)(`ol`,{className:`flex flex-col gap-3`,children:b.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)(z,{className:`size-4 text-emerald-500`,strokeWidth:2}):(0,Z.jsx)(p,{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]=b,t[43]=O):O=t[43];let k;return t[44]!==n.browserExtensionInstallGuideTitle||t[45]!==D||t[46]!==O?(k=(0,Z.jsxs)(`div`,{"aria-label":C,className:`rounded-xl bg-surface-base p-3`,children:[D,O]}),t[44]=n.browserExtensionInstallGuideTitle,t[45]=D,t[46]=O,t[47]=k):k=t[47],k}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[_,v]=(0,Y.useState)(null),[y,x]=(0,Y.useState)(null),[S,C]=(0,Y.useState)(null),T=f.port??Xe,D=f.host||`127.0.0.1`,O=`ws://${D}:${T}/browser-ext`,k=t.kind===`ok`&&t.data.running,A=t.kind===`ok`&&t.data.connected,M=t.kind===`ok`&&t.data.bridgeHeld===!0,N=t.kind===`ok`&&t.data.portConflict===!0,P=k||M,F=n.kind===`ok`?n.data:t.kind===`ok`?t.data.artifacts:void 0,I=F?.installed===!0,L=F?.extensionDir,R=F?.needsChromeReload===!0,ee=t.kind===`ok`?A?{icon:m,color:`text-green-500`,label:e.browserExtensionConnected}:k?{icon:w,color:`text-amber-500`,label:e.browserExtensionWaiting}:{icon:b,color:`text-fg-muted`,label:e.browserExtensionServerOff}:{icon:b,color:`text-fg-muted`,label:`…`},te=ee.icon,z=(0,Y.useCallback)(async()=>{if(!_){v(`start`),x(null);try{await i({host:D,port:T})}catch(e){x(e instanceof Error?e.message:String(e))}finally{v(null)}}},[_,D,T,i]),B=(0,Y.useCallback)(async()=>{if(!_){v(`stop`),x(null);try{await a()}catch(e){x(e instanceof Error?e.message:String(e))}finally{v(null)}}},[_,a]),V=(0,Y.useCallback)(async()=>{if(!_){v(`disconnect`),x(null);try{await s()}catch(e){x(e instanceof Error?e.message:String(e))}finally{v(null)}}},[_,s]),H=(0,Y.useCallback)(async()=>{if(!_){v(`install`),x(null),C(null);try{let t=await c({force:I});t?.extensionDir?C(`${e.browserExtensionInstalled}: ${t.extensionDir}`):C(e.browserExtensionInstalled),await l()}catch(e){x(e instanceof Error?e.message:String(e))}finally{v(null)}}},[_,c,I,e.browserExtensionInstalled,l]),ne=(0,Y.useCallback)(async()=>{if(!_){v(`open`),x(null);try{await u()}catch(e){x(e instanceof Error?e.message:String(e))}finally{v(null)}}},[_,u]),U=(0,Y.useCallback)(async()=>{if(!(!L||_)){v(`path`),x(null),C(null);try{await o(L)?C(e.browserExtensionPathCopied):C(e.browserExtensionPathCopyFailed)}catch(e){x(e instanceof Error?e.message:String(e))}finally{v(null)}}},[_,L,e.browserExtensionPathCopied,e.browserExtensionPathCopyFailed]),G=(0,Y.useCallback)(async()=>{if(!(!L||_)){v(`folder`),x(null),C(null);try{await d(),C(e.browserExtensionFolderOpened)}catch(e){x(e instanceof Error?e.message:String(e))}finally{v(null)}}},[_,L,e.browserExtensionFolderOpened,d]),K=(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:_!==null,onClick:()=>void H(),children:[_===`install`?(0,Z.jsx)(g,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(E,{className:`size-3.5`}),_===`install`?e.browserExtensionInstalling:e.browserExtensionInstall]}),P?(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:_!==null,onClick:()=>void B(),children:[_===`stop`?(0,Z.jsx)(g,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(j,{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:_!==null,onClick:()=>void z(),children:[_===`start`?(0,Z.jsx)(g,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(h,{className:`size-3.5`}),_===`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:_!==null,onClick:()=>void V(),children:[_===`disconnect`?(0,Z.jsx)(g,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(b,{className:`size-3.5`}),e.browserExtensionDisconnect]}):null]});return(0,Z.jsx)(Fe,{icon:W,title:e.browserBackendExtension,description:e.browserExtensionDownloadHint,m:e,embedded:p,primaryAction:K,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:O}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs ${ee.color}`,children:[(0,Z.jsx)(te,{className:`size-3.5`}),(0,Z.jsx)(`span`,{children:ee.label})]})]}),(0,Z.jsx)(Je,{m:e,installed:I,extensionDir:L,connected:A,busy:_!==null,pathBusy:_===`path`,folderBusy:_===`folder`,onOpenChrome:()=>void ne(),onCopyPath:()=>void U(),onRevealFolder:()=>void G()}),R?(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,N?(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(T))}):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:h,run:_,reset:v,cancel:y}=o,b;t[0]!==a||t[1]!==n.browserPlaywrightInstallFailed||t[2]!==n.browserPlaywrightInstalled||t[3]!==i||t[4]!==v||t[5]!==_?(b=async()=>{u(`installing`),f(null),v();let e=await _({fallbackError:n.browserPlaywrightInstallFailed});if(!e.ok){if(e.error===`busy`){u(`installing`);return}if(e.error===`cancelled`){u(`idle`),f(null),v();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]=v,t[5]=_,t[6]=b):b=t[6];let x=b,S=r.kind===`loading`?`checking`:r.kind===`error`?`error`:r.kind===`ok`?r.data.installed?`ready`:`not_installed`:`unknown`,C=r.kind===`ok`&&r.data.installed&&r.data.executablePath?r.data.executablePath:void 0,w=r.kind===`ok`&&r.data.installed,T=l===`installing`||m,D;t[7]===x?D=t[8]:(D=()=>void x(),t[7]=x,t[8]=D);let O;t[9]!==w||t[10]!==T||t[11]!==l?(O=T?(0,Z.jsx)(g,{className:`size-3.5 animate-spin`}):w?(0,Z.jsx)(M,{className:`size-3.5`}):l===`installed`?(0,Z.jsx)(z,{className:`size-3.5 text-green-500`}):(0,Z.jsx)(E,{className:`size-3.5`}),t[9]=w,t[10]=T,t[11]=l,t[12]=O):O=t[12];let k=T?n.browserPlaywrightInstalling:w?n.browserReinstall:n.browserPlaywrightInstall,A;t[13]!==T||t[14]!==D||t[15]!==O||t[16]!==k?(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:T,onClick:D,children:[O,k]}),t[13]=T,t[14]=D,t[15]=O,t[16]=k,t[17]=A):A=t[17];let j;t[18]===n.browserPlaywrightManualInstall?j=t[19]:(j=(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:n.browserPlaywrightManualInstall}),t[18]=n.browserPlaywrightManualInstall,t[19]=j);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]===j?P=t[22]:(P=(0,Z.jsxs)(`div`,{className:`text-xs`,children:[j,N]}),t[21]=j,t[22]=P);let F;t[23]!==y||t[24]!==h||t[25]!==n||t[26]!==p||t[27]!==m?(F=m?(0,Z.jsx)(Ve,{m:n,progress:p,showLogs:!0,cancelling:h,onCancel:()=>void y()}):null,t[23]=y,t[24]=h,t[25]=n,t[26]=p,t[27]=m,t[28]=F):F=t[28];let I;t[29]!==d||t[30]!==l?(I=d?(0,Z.jsx)(Le,{kind:l===`failed`?`error`:`success`,message:d}):null,t[29]=d,t[30]=l,t[31]=I):I=t[31];let L;return t[32]!==c||t[33]!==n||t[34]!==C||t[35]!==S||t[36]!==F||t[37]!==I||t[38]!==A||t[39]!==P?(L=(0,Z.jsxs)(Fe,{icon:G,title:n.browserPlaywrightGuideTitle,description:n.browserPlaywrightGuideDesc,status:S,statusDetail:C,m:n,embedded:c,primaryAction:A,children:[P,F,I]}),t[32]=c,t[33]=n,t[34]=C,t[35]=S,t[36]=F,t[37]=I,t[38]=A,t[39]=P,t[40]=L):L=t[40],L}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=k(mt),d=ft(`playwright`),f=ft(`cloakbrowser`),p=r.browserEnabled&&(o===`overview`||o===`extension`),m=r.browserEnabled&&(o===`overview`||o===`local`),h=r.browserEnabled&&(o===`overview`||o===`cloakbrowser`),g;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]!==h||t[7]!==p||t[8]!==m?(g={cacheDir:r.browserCloakCacheDir,binaryPath:r.browserCloakBinaryPath,browserEnabled:r.browserEnabled,activeBackend:r.browserBackend,probeExtension:p,probeLocal:m,probeCloak:h,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]=h,t[7]=p,t[8]=m,t[9]=g):g=t[9];let v=rt(g),y;t[10]===v.playwright?y=t[11]:(y=Ee(v.playwright),t[10]=v.playwright,t[11]=y);let b=y,x;t[12]===v.cloak?x=t[13]:(x=Ee(v.cloak),t[12]=v.cloak,t[13]=x);let S=x,w;t[14]===v.extension?w=t[15]:(w=Oe(v.extension),t[14]=v.extension,t[15]=w);let T=w,E;t[16]!==n||t[17]!==v.extension?(E=ke(v.extension,n),t[16]=n,t[17]=v.extension,t[18]=E):E=t[18];let D=E,O;t[19]!==n||t[20]!==S||t[21]!==T||t[22]!==D||t[23]!==b||t[24]!==u?(O=[{value:`extension`,icon:W,name:n.browserBackendExtension,tagline:n.browserModeExtTagline,status:T,statusLabel:D},{value:`local`,icon:G,name:n.browserBackendLocal,tagline:n.browserModeLocalTagline,status:b,statusLabel:De(b,n)},{value:`cloakbrowser`,icon:L,name:n.browserBackendCloakBrowser,tagline:n.browserModeCloakTagline,status:S,statusLabel:De(S,n)},{value:`cdp`,icon:ee,name:n.browserBackendCdp,tagline:n.browserModeCdpTagline},{value:`cloud`,icon:_,name:n.browserBackendCloud,tagline:n.browserModeCloudTagline}].filter(e=>pe(e.value,u)),t[19]=n,t[20]=S,t[21]=T,t[22]=D,t[23]=b,t[24]=u,t[25]=O):O=t[25];let A=O,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`,P;t[29]===N?P=t[30]:(P=a(`flex flex-col gap-5 transition-opacity`,N),t[29]=N,t[30]=P);let F=!r.browserEnabled,I;t[31]!==n||t[32]!==o||t[33]!==v.disconnectExtension||t[34]!==v.extension||t[35]!==v.extensionArtifacts||t[36]!==v.installExtensionArtifacts||t[37]!==v.openExtensionChrome||t[38]!==v.refetchExtensionArtifacts||t[39]!==v.revealExtensionFolder||t[40]!==v.startExtensionBridge||t[41]!==v.stopExtensionBridge||t[42]!==r.browserExtensionConnectionTimeout||t[43]!==r.browserExtensionHost||t[44]!==r.browserExtensionPort||t[45]!==i?(I=o===`extension`?(0,Z.jsx)(q,{children:(0,Z.jsx)(Qe,{embedded:!0,m:n,probe:v.extension,artifacts:v.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:v.startExtensionBridge,stopBridge:v.stopExtensionBridge,disconnectExtension:v.disconnectExtension,installArtifacts:v.installExtensionArtifacts,refetchArtifacts:v.refetchExtensionArtifacts,openExtensionChrome:v.openExtensionChrome,revealExtensionFolder:v.revealExtensionFolder})}):null,t[31]=n,t[32]=o,t[33]=v.disconnectExtension,t[34]=v.extension,t[35]=v.extensionArtifacts,t[36]=v.installExtensionArtifacts,t[37]=v.openExtensionChrome,t[38]=v.refetchExtensionArtifacts,t[39]=v.revealExtensionFolder,t[40]=v.startExtensionBridge,t[41]=v.stopExtensionBridge,t[42]=r.browserExtensionConnectionTimeout,t[43]=r.browserExtensionHost,t[44]=r.browserExtensionPort,t[45]=i,t[46]=I):I=t[46];let R;t[47]!==n||t[48]!==o||t[49]!==v.applyPlaywrightDoctor||t[50]!==v.playwright||t[51]!==v.refetchPlaywright||t[52]!==d?(R=o===`local`?(0,Z.jsx)(q,{children:(0,Z.jsx)($e,{embedded:!0,m:n,doctor:v.playwright,refetch:v.refetchPlaywright,applyDoctor:v.applyPlaywrightDoctor,installStream:d})}):null,t[47]=n,t[48]=o,t[49]=v.applyPlaywrightDoctor,t[50]=v.playwright,t[51]=v.refetchPlaywright,t[52]=d,t[53]=R):R=t[53];let te;t[54]!==n||t[55]!==o||t[56]!==f||t[57]!==v.applyCloakDoctor||t[58]!==v.cloak||t[59]!==v.fetchCloakRuntimeStatus||t[60]!==v.launchCloak||t[61]!==v.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?(te=o===`cloakbrowser`?(0,Z.jsx)(q,{children:(0,Z.jsx)(We,{embedded:!0,m:n,doctor:v.cloak,refetch:v.refetchCloak,applyDoctor:v.applyCloakDoctor,installStream:f,fetchRuntimeStatus:v.fetchCloakRuntimeStatus,launchCloak:v.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]=v.applyCloakDoctor,t[58]=v.cloak,t[59]=v.fetchCloakRuntimeStatus,t[60]=v.launchCloak,t[61]=v.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]=te):te=t[74];let z;t[75]!==n||t[76]!==o||t[77]!==v.launchCdp||t[78]!==v.listCdpInstances||t[79]!==v.pingCdp||t[80]!==v.stopCdp||t[81]!==r.browserCdpUrl||t[82]!==i?(z=o===`cdp`?(0,Z.jsx)(q,{children:(0,Z.jsx)(ze,{embedded:!0,m:n,cdpUrl:r.browserCdpUrl,onCdpUrlChange:e=>i({browserCdpUrl:e}),launch:v.launchCdp,stop:v.stopCdp,listInstances:v.listCdpInstances,ping:v.pingCdp})}):null,t[75]=n,t[76]=o,t[77]=v.launchCdp,t[78]=v.listCdpInstances,t[79]=v.pingCdp,t[80]=v.stopCdp,t[81]=r.browserCdpUrl,t[82]=i,t[83]=z):z=t[83];let B;t[84]!==n||t[85]!==o||t[86]!==v.testCloud||t[87]!==r.browserCloudApiKey||t[88]!==r.browserCloudProjectId||t[89]!==r.browserCloudProvider||t[90]!==r.browserCloudRegion||t[91]!==i?(B=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:v.testCloud})}):null,t[84]=n,t[85]=o,t[86]=v.testCloud,t[87]=r.browserCloudApiKey,t[88]=r.browserCloudProjectId,t[89]=r.browserCloudProvider,t[90]=r.browserCloudRegion,t[91]=i,t[92]=B):B=t[92];let V;t[93]!==I||t[94]!==R||t[95]!==te||t[96]!==z||t[97]!==B||t[98]!==P||t[99]!==F?(V=(0,Z.jsxs)(`div`,{className:P,"aria-hidden":F,children:[I,R,te,z,B]}),t[93]=I,t[94]=R,t[95]=te,t[96]=z,t[97]=B,t[98]=P,t[99]=F,t[100]=V):V=t[100];let H=V;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)(C,{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 w;return t[146]!==e||t[147]!==_||t[148]!==S?(w=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[e,_,S]}),t[146]=e,t[147]=_,t[148]=S,t[149]=w):w=t[149],w}return Pe(o)?H: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)(T,{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)(U,{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)(U,{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,C;t[33]!==b||t[34]!==x||t[35]!==S?(C=(0,Z.jsx)(U,{type:`button`,variant:`primary`,disabled:b,onClick:x,children:S}),t[33]=b,t[34]=x,t[35]=S,t[36]=C):C=t[36];let w;t[37]!==C||t[38]!==_||t[39]!==y?(w=(0,Z.jsxs)(Z.Fragment,{children:[_,y,C]}),t[37]=C,t[38]=_,t[39]=y,t[40]=w):w=t[40];let E;t[41]!==m||t[42]!==w||t[43]!==h||t[44]!==g?(E=(0,Z.jsx)(re,{title:m,subtitle:h,meta:g,actions:w}),t[41]=m,t[42]=w,t[43]=h,t[44]=g,t[45]=E):E=t[45];let D;t[46]===i.error?D=t[47]:(D=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]=D);let O;t[48]===a?O=t[49]:(O=(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-col gap-5 pb-8`,children:a}),t[48]=a,t[49]=O);let k;return t[50]!==E||t[51]!==D||t[52]!==O?(k=(0,Z.jsxs)(ie,{gap:`gap-6`,children:[E,D,O]}),t[50]=E,t[51]=D,t[52]=O,t[53]=k):k=t[53],k}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)})}),D()}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}=A(n);x({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&&!_),S=_ 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:S,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=k(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 A;e[32]!==y||e[33]!==x||e[34]!==C?(A=x?(0,Z.jsx)(pt,{...x,activeTab:y,setActiveTab:C}):null,e[32]=y,e[33]=x,e[34]=C,e[35]=A):A=e[35];let j;e[36]!==y||e[37]!==A?(j=(0,Z.jsx)(ae,{id:y,activeTab:y,tabIdPrefix:`agent-browser-tab`,panelIdPrefix:`agent-browser-panel`,showHeading:!1,framed:!1,children:A}),e[36]=y,e[37]=A,e[38]=j):j=e[38];let M;return e[39]!==O||e[40]!==j||e[41]!==d?(M=(0,Z.jsxs)(gt,{sectionId:`agent-browser`,intro:``,vm:d,tabbed:!0,children:[O,j]}),e[39]=O,e[40]=j,e[41]=d,e[42]=M):M=e[42],M}function Wt(e){return e.mode}function Gt(e){return e.language}export{Ut as AgentBrowserSettingsPage};
|
|
@@ -0,0 +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};
|
|
@@ -0,0 +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(`
|
|
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};
|
|
@@ -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{l as i,r as a,t as o,u as s}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as c}from"./cn-JdwAhgNB.js";import{t as l}from"./messages-BwQ3WssU.js";import{l as u,n as d,o as f,r as p,s as m}from"./locale-store-0lpYdNDr.js";import{i as h}from"./vendor-swr-BIWyz7Rc.js";import{Ac as g,An as _,Bn as v,Bo as y,Bs as b,Bt as x,Cn as S,Cs as C,Dn as w,Ds as T,Ec as E,En as D,Fn as O,Gn as k,Hn as A,Ho as j,Ht as M,In as N,Jc as P,Kc as F,Kn as I,Ll as L,Mn as R,Mr as ee,Ms as z,Mt as B,Nn as V,Nt as H,On as U,Pn as W,Qa as G,Rn as te,Ro as K,Sl as ne,Sn as re,Ss as ie,Su as ae,Tc as oe,Tn as se,Un as ce,Uo as le,Ut as ue,Vc as de,Vn as fe,Vt as pe,Wn as me,Wo as he,Xa as ge,Xn as _e,Xo as ve,Yo as ye,Za as be,Zs as xe,_s as Se,as as Ce,cc as we,cu as Te,es as Ee,fs as De,hs as Oe,jn as ke,js as Ae,jt as je,kn as Me,os as Ne,ou as Pe,pl as Fe,ps as Ie,qo as Le,rs as q,sc as Re,to as ze,ts as J,uc as Be,vs as Y,wc as Ve,wn as He,ws as X,xn as Ue,xs as We,zn as Ge,zo as Ke,zr as qe,zt as Je}from"./index-C8JkTS6d.js";import{n as Ye,r as Xe}from"./settings-page-layout-D3srt5Bi.js";import{t as Ze}from"./settings-loading-skeleton-DEwYqESe.js";import{c as Qe,d as $e,f as et,h as tt,i as nt,l as rt,m as it,n as at,o as ot,p as st,r as ct,s as lt,t as ut,u as dt}from"./voice-api-key-field-CrwkicvT.js";import{t as ft}from"./settings-advanced-gate-CDY3ZI1K.js";import{t as pt}from"./settings-collapsible-section-6eNF8Jey.js";import{n as mt,t as ht}from"./settings-form-section-CARTHCxH.js";import{t as gt}from"./page-tabs-Caj1-E_X.js";import{n as _t,r as vt,t as yt}from"./save-bar-controls-BDYt53uQ.js";var Z=n(),Q=e(t(),1),$=r(),bt=()=>p(tt),xt=e=>{let t=e?.trim();return p(t?`/api/image/capabilities?agentId=${encodeURIComponent(t)}`:`/api/image/capabilities`)},St=()=>p(`/api/global-defaults`),Ct=()=>`image-models-agents`,wt={imageModel:``,imageModelFallbacks:[],imageGenerationModel:``,imageGenerationModelFallbacks:[],imageGenerationModelTimeoutMs:``,imageGenerationModelAutoProviderFallback:!1};async function Tt(e){let t=await m(e);if(!t.payload)throw Error(`Invalid image capabilities response`);return t.payload}function Et(e){return{imageModel:e?.imageModel?.primary??``,imageModelFallbacks:e?.imageModel?.fallbacks??[],imageGenerationModel:e?.imageGenerationModel?.primary??``,imageGenerationModelFallbacks:e?.imageGenerationModel?.fallbacks??[],imageGenerationModelTimeoutMs:e?.imageGenerationModel?.timeoutMs?String(e.imageGenerationModel.timeoutMs):``,imageGenerationModelAutoProviderFallback:e?.imageGenerationModel?.autoProviderFallback===!0}}function Dt(e){return e.map(e=>e.trim()).filter(Boolean)}function Ot(e,t){let n={...e,roles:{...e.roles}},r=t.imageModel.trim();if(r){let e=Dt(t.imageModelFallbacks);n.imageModel={primary:r,...e.length>0?{fallbacks:e}:{}}}else delete n.imageModel;let i=t.imageGenerationModel.trim();if(i){let e=Dt(t.imageGenerationModelFallbacks),r=t.imageGenerationModelTimeoutMs.trim(),a=r?Number(r):void 0;n.imageGenerationModel={primary:i,...e.length>0?{fallbacks:e}:{},...Number.isFinite(a)&&a&&a>0?{timeoutMs:Math.floor(a)}:{},...t.imageGenerationModelAutoProviderFallback?{autoProviderFallback:!0}:{}}}else delete n.imageGenerationModel;return n}function kt(e){return e.filter(e=>e.configured).flatMap(e=>e.models.map(t=>({value:t.ref,label:`${t.name||t.id} · ${t.ref}`,configured:e.configured}))).sort((e,t)=>Number(t.configured)-Number(e.configured)||e.value.localeCompare(t.value))}function At(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{${t}}`,n),e)}function jt(e){return{credentialsIntro:e.credentialsIntro,regionHint:e.regionHint,endpointPresetsHint:e.endpointPresetsHint,apiKeyLabel:e.apiKeyLabel,optionalPlaceholder:e.optionalPlaceholder,regionLabel:e.regionLabel,baseUrlLabel:e.baseUrlLabel,imageBaseUrlLabel:e.imageBaseUrlLabel,saveCredentials:e.saveCredentials,savingCredentials:e.savingCredentials,credentialsSaved:e.credentialsSaved,discardCredentials:e.discardCredentials,credentialsNothingToSave:e.credentialsNothingToSave,credentialsSaveError:e.credentialsSaveError,regionPresetDefault:e.regionPresetDefault,regionPresetCustom:e.regionPresetCustom,baseUrlPresetDefault:e.baseUrlPresetDefault,baseUrlPresetCustom:e.baseUrlPresetCustom,openExtensionSettings:e.openExtensionSettings,openImageModelsPage:e.openImageModelsPage,extensionSettingsLinkTitle:e.extensionSettingsLinkTitle,imageModelsLinkTitle:e.imageModelsLinkTitle,configured:e.configured,missingKey:e.missingKey,unsavedChanges:e.unsavedChanges,expandProvider:e.expandProvider,collapseProvider:e.collapseProvider,defaultModel:e.defaultModel,modelsLabel:e.modelsLabel,modelCountOne:e.modelCountOne,modelCountMany:e.modelCountMany,imageBaseUrlPresetHint:e.imageBaseUrlPresetHint,dashscopeRegion_beijing:e.dashscopeRegion_beijing,dashscopeRegion_singapore:e.dashscopeRegion_singapore,dashscopeRegion_us:e.dashscopeRegion_us,apiKeyMaskedHelp:e.apiKeyMaskedHelp,apiKeyCopy:e.apiKeyCopy,apiKeyCopied:e.apiKeyCopied,apiKeyShow:e.apiKeyShow,apiKeyHide:e.apiKeyHide,apiKeyNotInConfigFile:e.apiKeyNotInConfigFile,apiKeyRevealFailed:e.apiKeyRevealFailed,minimaxClusterLabel:e.minimaxClusterLabel,minimaxClusterHint:e.minimaxClusterHint,falQueueBaseLabel:e.falQueueBaseLabel,falQueueBaseHint:e.falQueueBaseHint}}var Mt={saving:!1,savedFlash:!1,error:void 0};function Nt(e){let t=(0,Z.c)(40),{current:n,agentId:r,agentOptions:i,t:a,onAgentIdChange:o}=e,s=n?.effectiveImageModel??null,c=n?.imageModelSource??`none`,l=n?.imageModelRoleId??n?.imageModelRoleDescription??``,u;t[0]!==l||t[1]!==c||t[2]!==a.runtimeUnderstandingAutoProvider||t[3]!==a.runtimeUnderstandingAutoRole||t[4]!==a.runtimeUnderstandingExplicit||t[5]!==a.runtimeUnderstandingNone?(u=c===`explicit`?a.runtimeUnderstandingExplicit:c===`auto-role`?At(a.runtimeUnderstandingAutoRole,{role:l||`unknown`}):c===`auto-provider`?a.runtimeUnderstandingAutoProvider:a.runtimeUnderstandingNone,t[0]=l,t[1]=c,t[2]=a.runtimeUnderstandingAutoProvider,t[3]=a.runtimeUnderstandingAutoRole,t[4]=a.runtimeUnderstandingExplicit,t[5]=a.runtimeUnderstandingNone,t[6]=u):u=t[6];let d=u,f;t[7]!==n||t[8]!==a.runtimeUnderstandingFallbacks||t[9]!==a.runtimeUnderstandingNoFallbacks?(f=n?.effectiveImageModelFallbacks?.length?At(a.runtimeUnderstandingFallbacks,{models:n.effectiveImageModelFallbacks.join(`, `)}):a.runtimeUnderstandingNoFallbacks,t[7]=n,t[8]=a.runtimeUnderstandingFallbacks,t[9]=a.runtimeUnderstandingNoFallbacks,t[10]=f):f=t[10];let p=f,m;t[11]===a.runtimeUnderstandingTitle?m=t[12]:(m=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.runtimeUnderstandingTitle}),t[11]=a.runtimeUnderstandingTitle,t[12]=m);let h;t[13]===d?h=t[14]:(h=(0,$.jsx)(`p`,{className:`mt-1 max-w-[72ch] text-xs leading-relaxed text-fg-muted`,children:d}),t[13]=d,t[14]=h);let g;t[15]!==m||t[16]!==h?(g=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[m,h]}),t[15]=m,t[16]=h,t[17]=g):g=t[17];let _;t[18]!==r||t[19]!==i||t[20]!==o||t[21]!==a.runtimeAgentLabel?(_=i.length>0?(0,$.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5 text-xs font-medium text-fg-muted sm:w-56`,children:[a.runtimeAgentLabel,(0,$.jsx)(Ee,{value:r,options:i,placeholder:a.runtimeAgentLabel,allowEmpty:!1,triggerClassName:`bg-surface-panel`,onChange:o})]}):null,t[18]=r,t[19]=i,t[20]=o,t[21]=a.runtimeAgentLabel,t[22]=_):_=t[22];let v;t[23]!==g||t[24]!==_?(v=(0,$.jsxs)(`div`,{className:`mb-3 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[g,_]}),t[23]=g,t[24]=_,t[25]=v):v=t[25];let y=s??a.noModelSelected,b;t[26]===y?b=t[27]:(b=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:y}),t[26]=y,t[27]=b);let x;t[28]===p?x=t[29]:(x=(0,$.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:p}),t[28]=p,t[29]=x);let S;t[30]!==x||t[31]!==b?(S=(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-subtle px-3 py-2 shadow-surface`,children:[b,x]}),t[30]=x,t[31]=b,t[32]=S):S=t[32];let C;t[33]!==i.length||t[34]!==a.runtimeAgentHint?(C=i.length>0?(0,$.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:a.runtimeAgentHint}):null,t[33]=i.length,t[34]=a.runtimeAgentHint,t[35]=C):C=t[35];let w;return t[36]!==S||t[37]!==C||t[38]!==v?(w=(0,$.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-4`,children:[v,S,C]}),t[36]=S,t[37]=C,t[38]=v,t[39]=w):w=t[39],w}function Pt(e){let t=(0,Z.c)(63),{title:n,description:r,primaryLabel:i,fallbackLabel:a,fallbackPlaceholder:o,value:s,fallbackValues:c,options:l,emptyLabel:u,onValueChange:d,onFallbackValuesChange:f}=e,p;t[0]!==c||t[1]!==s?(p=new Set([s,...c].filter(Boolean)),t[0]=c,t[1]=s,t[2]=p):p=t[2];let m=p,h;t[3]!==l||t[4]!==m||t[5]!==s?(h=s?l.find(e=>!m.has(e.value))?.value??``:``,t[3]=l,t[4]=m,t[5]=s,t[6]=h):h=t[6];let g=h,_;t[7]!==c||t[8]!==g||t[9]!==f?(_=()=>{g&&f([...c,g])},t[7]=c,t[8]=g,t[9]=f,t[10]=_):_=t[10];let v=_,y;t[11]!==c||t[12]!==f?(y=(e,t)=>{let n=[...c];n[e]=t,f(n)},t[11]=c,t[12]=f,t[13]=y):y=t[13];let x=y,S;t[14]!==c||t[15]!==f?(S=e=>{f(c.filter((t,n)=>n!==e))},t[14]=c,t[15]=f,t[16]=S):S=t[16];let C=S,w;t[17]===n?w=t[18]:(w=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[17]=n,t[18]=w);let T;t[19]===r?T=t[20]:(T=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:r}),t[19]=r,t[20]=T);let E;t[21]!==w||t[22]!==T?(E=(0,$.jsxs)(`div`,{className:`mb-3`,children:[w,T]}),t[21]=w,t[22]=T,t[23]=E):E=t[23];let D;t[24]===c?D=t[25]:(D=new Set(c),t[24]=c,t[25]=D);let O;t[26]!==u||t[27]!==d||t[28]!==l||t[29]!==D||t[30]!==s?(O=(0,$.jsx)(Ee,{value:s,options:l,placeholder:u,emptyLabel:u,disabledValues:D,onChange:d}),t[26]=u,t[27]=d,t[28]=l,t[29]=D,t[30]=s,t[31]=O):O=t[31];let k;t[32]!==i||t[33]!==O?(k=(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-xs font-medium text-fg-muted`,children:[i,O]}),t[32]=i,t[33]=O,t[34]=k):k=t[34];let A;t[35]===a?A=t[36]:(A=(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:a}),t[35]=a,t[36]=A);let j;t[37]!==u||t[38]!==a||t[39]!==o||t[40]!==c||t[41]!==l||t[42]!==C||t[43]!==m||t[44]!==x?(j=c.length===0?(0,$.jsx)(`div`,{className:`flex min-h-10 items-center rounded-lg bg-surface-subtle px-3 text-sm font-normal text-fg-subtle shadow-surface`,children:o}):c.map((e,t)=>(0,$.jsxs)(`div`,{className:`grid h-10 grid-cols-[minmax(0,1fr)_2.5rem] gap-2`,children:[(0,$.jsx)(Ee,{value:e,options:l,placeholder:u,emptyLabel:u,allowEmpty:!1,disabledValues:m,onChange:e=>x(t,e)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>C(t),className:`box-border inline-flex size-10 shrink-0 items-center justify-center rounded-lg border border-edge bg-surface-subtle text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:border-edge-strong`,"aria-label":a,children:(0,$.jsx)(b,{className:`size-4`,"aria-hidden":`true`})})]},`${t}:${e}`)),t[37]=u,t[38]=a,t[39]=o,t[40]=c,t[41]=l,t[42]=C,t[43]=m,t[44]=x,t[45]=j):j=t[45];let M=!g,N;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(Ve,{className:`size-4`,"aria-hidden":`true`}),t[46]=N):N=t[46];let P;t[47]!==v||t[48]!==a||t[49]!==M?(P=(0,$.jsxs)(`button`,{type:`button`,onClick:v,disabled:M,className:`box-border inline-flex h-9 w-fit min-w-[7.5rem] items-center justify-center gap-2 rounded-lg border border-edge bg-surface-base px-3 text-sm text-fg disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-none focus-visible:border-edge-strong`,children:[N,a]}),t[47]=v,t[48]=a,t[49]=M,t[50]=P):P=t[50];let F;t[51]!==j||t[52]!==P?(F=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[j,P]}),t[51]=j,t[52]=P,t[53]=F):F=t[53];let I;t[54]!==A||t[55]!==F?(I=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[A,F]}),t[54]=A,t[55]=F,t[56]=I):I=t[56];let L;t[57]!==k||t[58]!==I?(L=(0,$.jsxs)(`div`,{className:`grid gap-3`,children:[k,I]}),t[57]=k,t[58]=I,t[59]=L):L=t[59];let R;return t[60]!==L||t[61]!==E?(R=(0,$.jsxs)(`section`,{className:`rounded-lg bg-surface-base p-4`,children:[E,L]}),t[60]=L,t[61]=E,t[62]=R):R=t[62],R}function Ft(){let e=(0,Z.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=Array.from({length:2}).map(It),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(G,{className:`h-4 w-36`}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-hidden":`true`,children:[t,(0,$.jsxs)(`section`,{className:`rounded-lg bg-surface-base p-4`,children:[n,(0,$.jsxs)(`div`,{className:`mt-4 grid gap-3 md:grid-cols-2`,children:[(0,$.jsx)(G,{className:`h-10 rounded-lg`}),(0,$.jsx)(G,{className:`h-16 rounded-lg`})]})]})]}),e[2]=r):r=e[2],r}function It(e,t){return(0,$.jsxs)(`section`,{className:`rounded-lg bg-surface-base p-4`,children:[(0,$.jsx)(G,{className:`h-4 w-40`}),(0,$.jsx)(G,{className:`mt-2 h-3 w-72 max-w-full`}),(0,$.jsxs)(`div`,{className:`mt-4 grid gap-3`,children:[(0,$.jsx)(G,{className:`h-10 rounded-lg`}),(0,$.jsx)(G,{className:`h-10 rounded-lg`}),(0,$.jsx)(G,{className:`h-9 w-36 rounded-lg`})]})]},t)}function Lt(){let e=d(e=>e.language),t=l(e),n=t.imageModelsSettings,r=!!u(e=>e.token),[i,a]=(0,Q.useReducer)(H,Mt),{saving:o,error:s}=i,c=ze(),f=(0,Q.useMemo)(()=>new Set(c.map(e=>e.id)),[c]),{data:p=[],isLoading:m}=h(r?bt():null,it,{revalidateOnFocus:!1}),{data:g,isLoading:_}=h(r?Ct():null,qe,{revalidateOnFocus:!1}),[v,y]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{g&&y(e=>e&&g.agents.some(t=>t.id===e)?e:g.defaultId||g.agents[0]?.id||``)},[g]);let{data:b,isLoading:x,mutate:S}=h(r?xt(v):null,Tt,{revalidateOnFocus:!1}),{data:C,isLoading:w,mutate:T}=h(r?St():null,M,{revalidateOnFocus:!1}),E=p.some(e=>e.configured),D=et(p),[O,k]=(0,Q.useState)(wt),[A,j]=(0,Q.useState)(wt);(0,Q.useEffect)(()=>{if(!C?.models)return;let e=Et(C.models);k(e),j(e)},[C?.models]);let N=JSON.stringify(O)!==JSON.stringify(A),P=D.credDirty||N;(0,Q.useEffect)(()=>{if(!P)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[P]),_t({id:`image-models`,dirty:P,saving:o,save:(0,Q.useCallback)(async()=>{a({type:`patch`,patch:{saving:!0,error:void 0}});try{if(N){if(!C?.models)throw Error(n.loadError);let e=await ue(Ot(C.models,O));await T(e,!1),await S();let t=Et(e.models);k(t),j(t)}D.credDirty&&(await D.saveCredentials(n.credentialsSaveError),await S()),a({type:`patch`,patch:{savedFlash:!0}})}catch(e){a({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{saving:!1}})}},[D,C?.models,N,O,T,S,n.credentialsSaveError,n.loadError,n.saved]),discard:(0,Q.useCallback)(()=>{D.credDirty&&D.onDiscardCredentials(),N&&k(A),a({type:`patch`,patch:{error:void 0,savedFlash:!1}})},[D,A,N])});let F=(0,Q.useMemo)(()=>jt(n),[n]),I=(0,Q.useMemo)(()=>kt(b?.imageUnderstanding.providers??[]),[b?.imageUnderstanding.providers]),L=(0,Q.useMemo)(()=>kt(b?.imageGeneration.providers??[]),[b?.imageGeneration.providers]),R=(0,Q.useMemo)(()=>({getApiKey:t.providersSettings.getApiKey,getApiKeyIntl:t.providersSettings.getApiKeyIntl,getApiKeyCn:t.providersSettings.getApiKeyCn}),[t.providersSettings]),z=(0,Q.useMemo)(()=>(g?.agents??[]).map(e=>({value:e.id,label:ee(e,t.agentsSettings)})),[g?.agents,t.agentsSettings]);return r?m||x||w||_?(0,$.jsx)(Ft,{}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[s?(0,$.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:s}):null,(0,$.jsx)(Nt,{current:b?.current,agentId:v,agentOptions:z,t:n,onAgentIdChange:y}),(0,$.jsx)(Pt,{title:n.understandingTitle,description:n.understandingDescription,primaryLabel:n.primaryModelLabel,fallbackLabel:n.fallbackModelsLabel,fallbackPlaceholder:n.fallbackModelsPlaceholder,value:O.imageModel,fallbackValues:O.imageModelFallbacks,options:I,emptyLabel:n.noModelSelected,onValueChange:e=>k(t=>({...t,imageModel:e,imageModelFallbacks:e?t.imageModelFallbacks.filter(t=>t!==e):[]})),onFallbackValuesChange:e=>k(t=>({...t,imageModelFallbacks:e}))}),(0,$.jsx)(Pt,{title:n.generationTitle,description:n.generationDescription,primaryLabel:n.primaryModelLabel,fallbackLabel:n.fallbackModelsLabel,fallbackPlaceholder:n.fallbackModelsPlaceholder,value:O.imageGenerationModel,fallbackValues:O.imageGenerationModelFallbacks,options:L,emptyLabel:n.noModelSelected,onValueChange:e=>k(t=>({...t,imageGenerationModel:e,imageGenerationModelFallbacks:e?t.imageGenerationModelFallbacks.filter(t=>t!==e):[]})),onFallbackValuesChange:e=>k(t=>({...t,imageGenerationModelFallbacks:e}))}),(0,$.jsxs)(`section`,{className:`rounded-lg bg-surface-base p-4`,children:[(0,$.jsxs)(`div`,{className:`mb-3`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.runtimeTuningTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:n.runtimeTuningHint})]}),(0,$.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[minmax(0,220px)_minmax(0,1fr)]`,children:[(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-xs font-medium text-fg-muted`,children:[n.timeoutLabel,(0,$.jsx)(`input`,{type:`number`,min:1,value:O.imageGenerationModelTimeoutMs,onChange:e=>k(t=>({...t,imageGenerationModelTimeoutMs:e.target.value})),placeholder:`120000`,className:`h-10 rounded-lg border border-edge bg-surface-subtle px-3 text-sm font-normal text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`})]}),(0,$.jsxs)(`label`,{className:`flex items-start gap-3 rounded-lg border border-edge bg-surface-subtle px-3 py-2.5 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:O.imageGenerationModelAutoProviderFallback,onChange:e=>k(t=>({...t,imageGenerationModelAutoProviderFallback:e.target.checked})),className:`mt-0.5 size-4 rounded border-edge accent-accent`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`block font-medium`,children:n.autoFallbackLabel}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs leading-relaxed text-fg-muted`,children:n.autoFallbackHint})]})]})]})]}),(0,$.jsx)(pt,{icon:we,showLabel:n.providersTitle,hideLabel:n.providersTitle,defaultOpen:E,children:p.length===0?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.providersEmpty}):(0,$.jsx)(st,{summaries:p,credDraft:D.credDraft,credBaseline:D.credBaseline,credDirty:D.credDirty,credSaving:D.credSaving,credError:D.credError,credSavedFlash:D.credSavedFlash,credNoopFlash:D.credNoopFlash,updateCredRow:D.updateCredRow,onDiscardCredentials:D.onDiscardCredentials,onSaveCredentials:()=>void D.saveCredentials(n.credentialsSaveError),extensionIds:f,showExtensionLinks:!0,showImageModelsLink:!1,hideActions:!0,language:e,apiKeyLinkLabels:R,messages:F})})]}):(0,$.jsx)(`div`,{className:`w-full text-sm text-fg-muted`,children:e===`zh`?`请先登录网关。`:`Connect to a gateway to continue.`})}var Rt=We;function zt(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`groq`:return`(GROQ_API_KEY)`;default:return``}}function Bt(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`minimax`:return`(MINIMAX_API_KEY)`;default:return``}}function Vt(){return c(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,C,`dark:border-edge`)}function Ht(){return c(ie,We)}function Ut(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Wt(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 Gt=[{id:`paraformer-v2`,name:`Paraformer v2`},{id:`paraformer-v1`,name:`Paraformer v1`}],Kt=[{id:`whisper-1`,name:`Whisper-1`}],qt=[{id:`whisper-large-v3-turbo`,name:`Whisper Large v3 Turbo`},{id:`whisper-large-v3`,name:`Whisper Large v3`}],Jt=[{id:`tts-1`,name:`TTS-1`},{id:`tts-1-hd`,name:`TTS-1 HD`}],Yt=[{id:`alloy`,name:`Alloy`},{id:`echo`,name:`Echo`}],Xt=[{id:`qwen-tts`,name:`Qwen TTS`},{id:`qwen3-tts-flash`,name:`Qwen3 TTS Flash`}],Zt=[{id:`Cherry`,name:`Cherry`},{id:`longxiaochun`,name:`Long Xiao Chun`}],Qt=[{id:`en-US-MichelleNeural`,name:`Michelle (US English)`},{id:`zh-CN-XiaoxiaoNeural`,name:`Xiaoxiao (Chinese)`}],$t=[{id:`speech-2.8-hd`,name:`Speech 2.8 HD (Recommended)`},{id:`speech-2.8-turbo`,name:`Speech 2.8 Turbo (Fast)`}],en=[{id:`male-qn-qingse`,name:`Male Qingse (青涩男声)`},{id:`female-shaonv`,name:`Female Shaonv (少女音)`}],tn=[{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 nn(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 rn(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 an(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 on(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 sn(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function cn(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 ln(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 un(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 dn(){let e=d(e=>e.language),t=l(e).voiceSettings,n=!!u(e=>e.token),[r,i]=(0,Q.useReducer)(un,{form:null,baseline:null}),a=r.form,o=r.baseline,[s,c]=(0,Q.useState)(null),[f,m]=(0,Q.useState)(!1),[g,_]=(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}=be(n),{data:w,error:T,isLoading:E,mutate:D}=h(n?p(`/api/voice/models`):null,ct,{revalidateOnFocus:!1}),{data:O,error:k,isLoading:A}=h(n?p(`/api/voice/providers`):null,nt,{revalidateOnFocus:!1}),{data:j,error:M,isLoading:N}=h(n?p(`/api/voice/stt-providers`):null,ot,{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:Qe(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)),ee=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,z=(0,Q.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e}}:null})},[]),B=(0,Q.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,stt:{...t.stt,alibaba:{...t.stt.alibaba,...e}}}:null})},[]),V=(0,Q.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,stt:{...t.stt,openai:{...t.stt.openai,...e}}}:null})},[]),H=(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}}}}})},[]),U=(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})},[]),W=(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]),G=(0,Q.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),te=(0,Q.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,tts:{...t.tts,alibaba:{...t.tts.alibaba,...e}}}:null})},[]),K=(0,Q.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,tts:{...t.tts,openai:{...t.tts.openai,...e}}}:null})},[]),ne=(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})},[]),re=(0,Q.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,tts:{...t.tts,minimax:{...t.tts.minimax,...e}}}:null})},[]),ie=(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(_t({id:`voice`,dirty:L,saving:f,save:(0,Q.useCallback)(async()=>{if(!(!a||f)){m(!0),_(null);try{await rt(a),i({type:`saved`,value:a}),v.current=!1}catch(e){_(e instanceof Error?e.message:t.saveError)}finally{m(!1)}}},[a,f,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)(Ze,{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:g??ee??t.loadError}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>{C(),D()},children:t.retry})]});let ae=a.stt,oe=a.tts,se=a.voice.input.refinement,ce=sn(t);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[g?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:g}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(fn,{v:t,voice:a.voice,updateLanguageMode:W}),(0,$.jsx)(pn,{v:t,stt:ae,tts:oe}),(0,$.jsx)(hn,{v:t,apiKeyLabels:ce,stt:ae,models:s,sttProviders:F,refinement:se,updateStt:z,updateSttAlibaba:B,updateSttOpenai:V,updateSttFallback:H,updateRefinement:U}),(0,$.jsx)(Cn,{v:t,apiKeyLabels:ce,tts:oe,models:s,ttsProviders:P,updateTts:G,updateTtsAlibaba:te,updateTtsOpenai:K,updateTtsEdge:ne,updateTtsMinimax:re,updateTtsLocalCli:ie})]}),(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 fn(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=Ht(),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)(q,{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)(q,{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)(J,{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 pn(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} · ${nn(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)(mn,{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?an(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)(mn,{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?`${rn(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)(mn,{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 mn(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=c(`mt-1 text-sm font-medium`,o),t[2]=o,t[3]=s);let l;t[4]!==s||t[5]!==r?(l=(0,$.jsx)(`div`,{className:s,children:r}),t[4]=s,t[5]=r,t[6]=l):l=t[6];let u;return t[7]!==a||t[8]!==l?(u=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[a,l]}),t[7]=a,t[8]=l,t[9]=u):u=t[9],u}function hn(e){let t=(0,Z.c)(49),{v:n,apiKeyLabels:r,stt:i,models:a,sttProviders:o,refinement:s,updateStt:l,updateSttAlibaba:u,updateSttOpenai:d,updateSttFallback:f,updateRefinement:p}=e,m=a?.stt?.alibaba?.length?a.stt.alibaba:Gt,h=a?.stt?.openai?.length?a.stt.openai:Kt,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]!==l||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(bn),E;t[20]!==i.provider||t[21]!==i.providers||t[22]!==l?(E=e=>{l({providers:{...i.providers??{},[i.provider]:{...i.providers?.[i.provider]??{},...e}}})},t[20]=i.provider,t[21]=i.providers,t[22]=l,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)(de,{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]===l?j=t[33]:(j=e=>l({enabled:e}),t[32]=l,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)(wn,{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:c(`flex flex-col gap-1.5`,Rt),children:[(0,$.jsx)(Dn,{children:n.stt.provider}),(0,$.jsx)(J,{className:Ht(),value:i.provider,onChange:e=>l({provider:e.target.value}),children:_.map(e=>(0,$.jsxs)(q,{value:e.id,children:[nn(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,$.jsxs)(`div`,{className:c(`flex flex-col gap-1.5`,Rt),children:[(0,$.jsx)(Dn,{children:n.stt.model}),i.provider===`xopc-local`?(0,$.jsx)(J,{className:Ht(),value:C||`sensevoice-small`,onChange:e=>D({model:e.target.value}),children:(a?.stt?.[`xopc-local`]??[]).map(yn)}):i.provider===`alibaba`?(0,$.jsx)(J,{className:Ht(),value:i.alibaba?.model??``,onChange:e=>u({model:e.target.value}),children:m.map(vn)}):i.provider===`openai`?(0,$.jsx)(J,{className:Ht(),value:i.openai?.model??``,onChange:e=>d({model:e.target.value}),children:h.map(_n)}):i.provider===`groq`?(0,$.jsx)(J,{className:Ht(),value:C||qt[0].id,onChange:e=>D({model:e.target.value}),children:qt.map(gn)}):(0,$.jsx)(`input`,{className:Vt(),value:C,onChange:e=>D({model:e.target.value}),placeholder:i.provider})]}),e?.diagnostics.requiresApiKey===!1?null:(0,$.jsxs)(`div`,{className:c(`flex flex-col gap-1.5`,Rt),children:[(0,$.jsx)(Dn,{children:n.stt.apiKey}),(0,$.jsx)(ut,{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,zt(i.provider)?` ${zt(i.provider)}`:``]})]})]}),T.length>0?(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:T.map(e=>(0,$.jsx)(Tn,{field:e,value:cn(w,e),onChange:t=>D({[e.key]:t}),className:e.type===`textarea`?`sm:col-span-2`:Rt},e.key))}):null,i.provider===`xopc-local`?(0,$.jsx)(Sn,{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)(J,{className:Ht(),value:s.mode,onChange:e=>p({mode:e.target.value}),children:[(0,$.jsx)(q,{value:`off`,children:n.stt.refinementOff}),(0,$.jsx)(q,{value:`punctuation`,children:n.stt.refinementPunctuation}),(0,$.jsx)(q,{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]=l,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 gn(e){return(0,$.jsx)(q,{value:e.id,children:e.name},e.id)}function _n(e){return(0,$.jsx)(q,{value:e.id,children:e.name},e.id)}function vn(e){return(0,$.jsx)(q,{value:e.id,children:e.name},e.id)}function yn(e){return(0,$.jsx)(q,{value:e.id,children:e.name},e.id)}function bn(e){return e.key!==`apiKey`&&e.key!==`model`}function xn(e){return`${Math.round(e/1024/1024)} MB`}function Sn({v:e}){let{data:t,error:n,mutate:r}=h(p(`/api/voice/local/status`),at,{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),l=(0,Q.useCallback)(async(e,t)=>{a(e.id),s(null);try{t===`install`?await lt(e.id):await dt(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:c(`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:[xn(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)(X,{type:`button`,variant:`secondary`,disabled:n,onClick:()=>void l(t,t.state===`ready`?`remove`:`install`),children:n?(0,$.jsx)(P,{className:`size-4 animate-spin`}):t.state===`ready`?e.stt.localRemove:e.stt.localInstall})]},t.id)})})]})}function Cn({v:e,apiKeyLabels:t,tts:n,models:r,ttsProviders:i,updateTts:a,updateTtsAlibaba:o,updateTtsOpenai:s,updateTtsEdge:l,updateTtsMinimax:u,updateTtsLocalCli:d}){let f=r?.tts?.openai?.length?r.tts.openai:Jt,p=r?.ttsVoices?.openai?.length?r.ttsVoices.openai:Yt,m=r?.tts?.alibaba?.length?r.tts.alibaba:Xt,h=r?.ttsVoices?.alibaba?.length?r.ttsVoices.alibaba:Zt,g=r?.ttsVoices?.edge?.length?r.ttsVoices.edge:Qt,_=r?.tts?.minimax?.length?r.tts.minimax:$t,v=r?.ttsVoices?.minimax?.length?r.ttsVoices.minimax:en,[y,b]=(0,Q.useState)(e.tts.test.sampleText),[x,S]=(0,Q.useState)({status:`idle`}),C=(0,Q.useRef)(null),w=(0,Q.useRef)(null),T=(0,Q.useCallback)(()=>{C.current?.pause(),C.current=null,w.current&&=(URL.revokeObjectURL(w.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]),O=D.find(e=>e.id===n.provider),k=n.providers?.[n.provider],A={...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`]??{}:{},...k??{}},j=(O?.fields??[]).filter(e=>![`apiKey`,`model`,`voice`].includes(e.key)),M=!!O?.diagnostics.requiresApiKey,N=!!O?.configured||!M,F=n.enabled?N?`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)(()=>()=>T(),[T]);let R=(0,Q.useCallback)(e=>{a({provider:e}),S({status:`idle`})},[a]),ee=(0,Q.useCallback)(async()=>{let t=y.trim();if(!t){S({status:`error`,message:e.tts.test.emptyText});return}T(),S({status:`loading`});try{let r=await $e({text:t,provider:n.provider,providerConfig:A,...I?{model:I}:{},...L?{voice:L}:{}}),i=Wt(r.audio,r.mimeType);w.current=i;let a=new Audio(i);C.current=a;let o=[r.provider,r.format,r.latencyMs===void 0?void 0:`${r.latencyMs}ms`,Ut(r.audioSize)].filter(Boolean).join(` · `);a.addEventListener(`ended`,()=>S({status:`done`,summary:o}),{once:!0}),a.addEventListener(`error`,()=>S({status:`error`,message:e.tts.test.playFailed}),{once:!0}),await a.play(),S({status:`playing`,summary:o})}catch(e){T(),S({status:`error`,message:e instanceof Error?e.message:String(e)})}},[I,L,A,T,y,n.provider,e.tts.test.emptyText,e.tts.test.playFailed]),z=(0,Q.useCallback)(e=>{a({providers:{...n.providers??{},[n.provider]:{...n.providers?.[n.provider]??{},...e}}})},[n.provider,n.providers,a]),B=(0,Q.useCallback)((e,t)=>{let r={[e.key]:t};z(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`&&l(r)},[n.provider,z,l,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)(Ae,{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)(wn,{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:c(`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?N?`${e.tts.statusReady} ${rn(n.provider,e)}${L?` · ${L}`:``}`:`${e.tts.statusNeedsSetup} ${rn(n.provider,e)} · ${O?.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:c(`flex flex-col gap-1.5`,Rt),children:[(0,$.jsx)(Dn,{children:e.tts.trigger}),(0,$.jsxs)(J,{className:Ht(),value:n.trigger,onChange:e=>a({trigger:e.target.value}),children:[(0,$.jsx)(q,{value:`off`,children:e.tts.triggerOff}),(0,$.jsx)(q,{value:`inbound`,children:e.tts.triggerInbound}),(0,$.jsx)(q,{value:`tagged`,children:e.tts.triggerTagged}),(0,$.jsx)(q,{value:`always`,children:e.tts.triggerAlways})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.triggerHelp})]}),(0,$.jsxs)(`div`,{className:c(`flex flex-col gap-1.5`,Rt),children:[(0,$.jsx)(Dn,{children:e.tts.provider}),(0,$.jsx)(J,{className:Ht(),value:n.provider,onChange:e=>R(e.target.value),children:D.map(t=>(0,$.jsx)(q,{value:t.id,children:rn(t.id,e)},t.id))}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[O?.configured?e.tts.configured:O?.diagnostics.requiresApiKey?`${e.tts.needsKey} · ${O.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.noKeyNeeded,` · `,O?.description??on(n.provider,e)]})]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,open:!N||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:c(`flex flex-col gap-1.5`,Rt),children:[(0,$.jsx)(Dn,{children:e.stt.apiKey}),(0,$.jsx)(ut,{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,Bt(n.provider)?` ${Bt(n.provider)}`:``]})]}),(0,$.jsxs)(`div`,{className:c(`flex flex-col gap-1.5`,Rt),children:[(0,$.jsx)(Dn,{children:e.stt.model}),(0,$.jsx)(J,{className:Ht(),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)(q,{value:e.id,children:e.name},e.id))})]}),(0,$.jsxs)(`div`,{className:c(`flex flex-col gap-1.5`,Rt),children:[(0,$.jsx)(Dn,{children:e.tts.voice}),(0,$.jsx)(J,{className:Ht(),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)(q,{value:e.id,children:e.name},e.id))})]})]}):null,n.provider===`edge`?(0,$.jsxs)(`div`,{className:c(`flex flex-col gap-1.5`,Rt),children:[(0,$.jsx)(Dn,{children:e.tts.voice}),(0,$.jsx)(J,{className:Ht(),value:n.edge?.voice??``,onChange:e=>l({voice:e.target.value}),children:g.map(e=>(0,$.jsx)(q,{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)(Dn,{children:e.tts.localCli.preset}),(0,$.jsxs)(J,{className:Ht(),value:``,onChange:e=>{let t=tn.find(t=>t.id===e.target.value);t&&d({command:t.command,outputFormat:t.outputFormat})},children:[(0,$.jsx)(q,{value:``,children:e.tts.localCli.presetPlaceholder}),tn.map(e=>(0,$.jsx)(q,{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)(Dn,{children:e.tts.localCli.command}),(0,$.jsx)(`input`,{className:c(Vt(),`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)(Dn,{children:e.tts.localCli.cwd}),(0,$.jsx)(`input`,{className:c(Vt(),`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)(Dn,{children:e.tts.localCli.outputFormat}),(0,$.jsxs)(J,{className:Ht(),value:n[`tts-local-cli`]?.outputFormat??`wav`,onChange:e=>d({outputFormat:e.target.value}),children:[(0,$.jsx)(q,{value:`wav`,children:`wav`}),(0,$.jsx)(q,{value:`mp3`,children:`mp3`}),(0,$.jsx)(q,{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)(Dn,{children:e.tts.localCli.timeoutMs}),(0,$.jsx)(`input`,{className:Vt(),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,j.length>0?(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:j.map(e=>(0,$.jsx)(Tn,{field:e,value:cn(A,e),onChange:t=>B(e,t),className:e.type===`textarea`?`sm:col-span-2`:Rt},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)(X,{type:`button`,variant:`primary`,onClick:()=>void ee(),disabled:x.status===`loading`,className:`h-9`,children:[x.status===`loading`?(0,$.jsx)(P,{className:`size-4 animate-spin`}):(0,$.jsx)(E,{className:`size-4`}),x.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,$.jsxs)(X,{type:`button`,variant:`secondary`,onClick:()=>{T(),S(e=>e.status===`playing`?{status:`done`,summary:e.summary}:{status:`idle`})},disabled:x.status!==`playing`,className:`h-9`,children:[(0,$.jsx)(xe,{className:`size-4`}),e.tts.test.stop]})]})]}),(0,$.jsx)(`textarea`,{className:c(Vt(),`mt-3 min-h-20 resize-y`),value:y,onChange:e=>b(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`]}),x.status===`playing`||x.status===`done`?(0,$.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-200`,children:[x.status===`playing`?e.tts.test.playing:e.tts.test.ready,` · `,x.summary]}):null,x.status===`error`?(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:x.message}):null]})]})]}):null]})]})}function wn(e){let t=(0,Z.c)(33),{checked:n,title:r,description:i,onLabel:a,offLabel:o,onChange:s}=e,l;t[0]!==n||t[1]!==s?(l=()=>s(!n),t[0]=n,t[1]=s,t[2]=l):l=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=c(`group flex w-full items-center justify-between gap-4 rounded-2xl px-4 py-3 text-left shadow-surface transition-colors`,C,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=c(`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=c(`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=c(`size-5 rounded-full bg-white shadow-surface transition-transform`,x),t[20]=x,t[21]=S);let w;t[22]===S?w=t[23]:(w=(0,$.jsx)(`span`,{className:S}),t[22]=S,t[23]=w);let T;t[24]!==b||t[25]!==w?(T=(0,$.jsx)(`span`,{className:b,"aria-hidden":!0,children:w}),t[24]=b,t[25]=w,t[26]=T):T=t[26];let E;return t[27]!==n||t[28]!==l||t[29]!==v||t[30]!==T||t[31]!==d?(E=(0,$.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":n,onClick:l,className:d,children:[v,T]}),t[27]=n,t[28]=l,t[29]=v,t[30]=T,t[31]=d,t[32]=E):E=t[32],E}function Tn(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=c(`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 l;t[4]===s?l=t[5]:(l=s?(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:s}):null,t[4]=s,t[5]=l);let u;t[6]!==o||t[7]!==l?(u=(0,$.jsxs)(`span`,{children:[o,l]}),t[6]=o,t[7]=l,t[8]=u):u=t[8];let d=!!r,f;t[9]!==n||t[10]!==i?(f=e=>i(ln(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 l=typeof r==`boolean`?``:String(r),u;t[19]===a?u=t[20]:(u=c(`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)(Dn,{children:n.label}),t[21]=n.label,t[22]=d);let f;t[23]!==a||t[24]!==n||t[25]!==l||t[26]!==o||t[27]!==i?(f=n.type===`select`?(0,$.jsx)(J,{id:o,className:Ht(),value:l,required:n.required,onChange:e=>i(ln(n,e.target.value)),children:(n.options??[]).map(En)}):n.type===`textarea`?(0,$.jsx)(`textarea`,{id:o,className:c(Vt(),`min-h-24 resize-y`),value:l,required:n.required,placeholder:n.placeholder,onChange:e=>i(ln(n,e.target.value))}):n.type===`password`?(0,$.jsx)(Oe,{id:o,className:a,value:l,onChange:e=>i(ln(n,e)),placeholder:n.placeholder,labels:De}):(0,$.jsx)(`input`,{id:o,className:Vt(),type:n.type===`number`?`number`:`text`,autoComplete:n.secret?`new-password`:`off`,spellCheck:!1,value:l,required:n.required,placeholder:n.placeholder,onChange:e=>i(ln(n,e.target.value))}),t[23]=a,t[24]=n,t[25]=l,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 En(e){return(0,$.jsx)(q,{value:e.id,children:e.name},e.id)}function Dn(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 On(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 kn(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 m(p(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),ge()}async function An(e){let t=await m(p(`/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 jn(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 Mn(){return c(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,C,`dark:border-edge`)}function Nn(){return c(ie,We)}var Pn=[`brave`,`tavily`,`bing`,`searxng`];function Fn(){return{type:`brave`,apiKey:``,url:``,disabled:!1}}var In=je();function Ln(){let e=l(d(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!u(e=>e.token),[i,a]=(0,Q.useReducer)(In,{form:null,baseline:null}),o=i.form,s=i.baseline,[f,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}=be(r);B({enabled:r,parsed:(0,Q.useMemo)(()=>v?.payload?.config===void 0?null:On(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 _t({id:`search`,dirty:w,saving:f,save:(0,Q.useCallback)(async()=>{if(!(!o||f)){p(!0),h(null);try{await kn(o),g.current=!1,a({type:`saved`,value:o})}catch(e){h(e instanceof Error?e.message:t.saveError)}finally{p(!1)}}},[o,f,t.saveError]),discard:(0,Q.useCallback)(()=>{s&&(g.current=!1,a({type:`discard`}),h(null))},[s])}),r?S?(0,$.jsx)(Ze,{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)(ht,{children:[(0,$.jsx)(mt,{icon:Be,title:t.sectionRegion,subtitle:t.sectionRegionHint}),(0,$.jsx)(`div`,{className:`flex max-w-md flex-col gap-4`,children:(0,$.jsx)(jn,{label:t.regionLabel,description:t.regionDesc,children:(0,$.jsxs)(J,{className:Nn(),value:o.regionMode,onChange:e=>T({regionMode:e.target.value}),children:[(0,$.jsx)(q,{value:`auto`,children:t.regionAuto}),(0,$.jsx)(q,{value:`cn`,children:t.regionCn}),(0,$.jsx)(q,{value:`global`,children:t.regionGlobal})]})})})]}),(0,$.jsx)(ft,{children:(0,$.jsxs)(ht,{children:[(0,$.jsx)(mt,{icon:ae,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)(jn,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,$.jsx)(`textarea`,{className:c(Mn(),`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)(ht,{children:[(0,$.jsx)(mt,{icon:Be,title:t.sectionSearch,subtitle:t.sectionSearchHint}),(0,$.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-6`,children:[(0,$.jsx)(jn,{label:t.maxResultsLabel,description:t.maxResultsDesc,children:(0,$.jsx)(`input`,{type:`number`,min:1,max:50,className:Mn(),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)(Rn,{row:n,providerIndex:r,labels:t,secretLabels:Ie(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)(X,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>T({providers:[...o.providers,Fn()]}),children:[(0,$.jsx)(Ve,{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)(X,{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 Rn(e){let t=(0,Z.c)(54),{row:n,providerIndex:r,labels:i,secretLabels:a,onChange:o,onRemove:s}=e,l;t[0]===r?l=t[1]:(l=()=>An(r).then(zn),t[0]=r,t[1]=l);let u=l,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=c(Nn(),`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=Pn.map(e=>(0,$.jsx)(q,{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)(J,{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)(b,{className:`size-4`}),t[21]=y):y=t[21];let x;t[22]===s?x=t[23]:(x=(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-fg-muted`,onClick:s,children:y}),t[22]=s,t[23]=x);let S;t[24]!==x||t[25]!==v?(S=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[v,x]}),t[24]=x,t[25]=v,t[26]=S):S=t[26];let C;t[27]!==S||t[28]!==h?(C=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[h,S]}),t[27]=S,t[28]=h,t[29]=C):C=t[29];let w;t[30]!==i.urlDesc||t[31]!==i.urlLabel||t[32]!==o||t[33]!==n?(w=n.type===`searxng`?(0,$.jsx)(jn,{label:i.urlLabel,description:i.urlDesc,children:(0,$.jsx)(`input`,{type:`url`,className:Mn(),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]=w):w=t[34];let T;t[35]!==o||t[36]!==n?(T=e=>o({...n,apiKey:e}),t[35]=o,t[36]=n,t[37]=T):T=t[37];let E;t[38]!==i.keyPlaceholder||t[39]!==i.keyPlaceholderMasked||t[40]!==i.saveError||t[41]!==u||t[42]!==n.apiKey||t[43]!==a||t[44]!==T?(E=(0,$.jsx)(Oe,{value:n.apiKey,onChange:T,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]=T,t[45]=E):E=t[45];let D;t[46]!==i.apiKeyDesc||t[47]!==i.apiKeyLabel||t[48]!==E?(D=(0,$.jsx)(jn,{label:i.apiKeyLabel,description:i.apiKeyDesc,children:E}),t[46]=i.apiKeyDesc,t[47]=i.apiKeyLabel,t[48]=E,t[49]=D):D=t[49];let O;return t[50]!==C||t[51]!==w||t[52]!==D?(O=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-panel/70 p-4 shadow-surface`,children:[C,w,D]}),t[50]=C,t[51]=w,t[52]=D,t[53]=O):O=t[53],O}function zn(e){return e.apiKey??null}async function Bn(e){let t=await f(p(`/api/auth/oauth-async/start`),{method:`POST`,body:JSON.stringify({provider:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`OAuth start failed: ${t.status}`)}return(await t.json()).payload}async function Vn(e){let t=await f(p(`/api/auth/oauth-async/${encodeURIComponent(e)}/status`));if(!t.ok)throw Error(`OAuth status: ${t.status}`);return(await t.json()).payload}async function Hn(e,t){let n=await f(p(`/api/auth/oauth-async/${encodeURIComponent(e)}/code`),{method:`POST`,body:JSON.stringify({code:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`Submit code failed: ${n.status}`)}}async function Un(e){let t=await f(p(`/api/auth/oauth-async/${encodeURIComponent(e)}/cancel`),{method:`POST`});if(!t.ok)throw Error(`Cancel OAuth failed: ${t.status}`)}async function Wn(e){let t=await f(p(`/api/auth/oauth-async/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(`Cleanup session failed: ${t.status}`)}async function Gn(e){let t=await f(p(`/api/auth/oauth/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(`Revoke OAuth failed: ${t.status}`)}var Kn=[`common`,`domestic`,`specialty`,`enterprise`,`oauth`,`extension`];function qn(e){let t=new Map;for(let e of Kn)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 Jn(e){let t=(0,Z.c)(22),{open:n,onOpenChange:r,builtinRows:i,customConfig:a,labels:o,language:s,onSaved:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u={type:`pick`},t[0]=u):u=t[0];let[d,f]=(0,Q.useState)(u),[p,m]=(0,Q.useState)(``),h;t[1]===r?h=t[2]:(h=e=>{e||window.setTimeout(()=>{f({type:`pick`}),m(``)},200),r(e)},t[1]=r,t[2]=h);let g=h,_;t[3]!==g||t[4]!==l?(_=()=>{l(),g(!1)},t[3]=g,t[4]=l,t[5]=_):_=t[5];let v=_,b;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(j,{className:c(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,Ne)}),t[6]=b):b=t[6];let x;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(x=c(`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`,Ce),t[7]=x):x=t[7];let S;t[8]!==i||t[9]!==a||t[10]!==v||t[11]!==o||t[12]!==s||t[13]!==p||t[14]!==d.presetKey||t[15]!==d.providerId||t[16]!==d.type?(S=(0,$.jsxs)(le,{children:[b,(0,$.jsx)(y,{className:x,children:d.type===`pick`?(0,$.jsx)(Xn,{builtinRows:i,searchQuery:p,onSearchChange:m,labels:o,onPickBuiltin:e=>{let t=R(e);f(t?{type:`custom`,presetKey:t}:{type:`builtin`,providerId:e})},onPickCustom:()=>f({type:`custom`})}):d.type===`builtin`?(0,$.jsx)(Zn,{providerId:d.providerId,builtinRows:i,labels:o,language:s,onBack:()=>f({type:`pick`}),onSaved:v}):(0,$.jsx)(er,{initialPresetKey:d.presetKey,customConfig:a,labels:o,language:s,onBack:()=>f({type:`pick`}),onSaved:v})})]}),t[8]=i,t[9]=a,t[10]=v,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)(K,{open:n,onOpenChange:g,children:S}),t[18]=g,t[19]=n,t[20]=S,t[21]=C):C=t[21],C}function Yn(e){let t=(0,Z.c)(4),{label:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=c(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Y.press),t[0]=r):r=t[0];let i;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(T,{className:`size-4`,"aria-hidden":!0}),t[1]=i):i=t[1];let a;return t[2]===n?a=t[3]:(a=(0,$.jsx)(Ke,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:r,"aria-label":n,children:i})}),t[2]=n,t[3]=a),a}function Xn(e){let t=(0,Z.c)(42),{builtinRows:n,searchQuery:r,onSearchChange:i,labels:a,onPickBuiltin:o,onPickCustom:s}=e,l;t[0]===r?l=t[1]:(l=r.trim().toLowerCase(),t[0]=r,t[1]=l);let u=l,d;bb0:{if(!u){d=n;break bb0}let e;if(t[2]!==n||t[3]!==u){let r;t[5]===u?r=t[6]:(r=e=>{let t=Je[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=qn(f),t[7]=f,t[8]=p);let m=p,h;t[9]===a.step1Title?h=t[10]:(h=(0,$.jsx)(he,{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)(Yn,{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)(Be,{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=c(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-10 pr-3 text-sm text-fg placeholder:text-fg-subtle`,C),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 w;t[24]!==a.addCustom||t[25]!==a.customDescription||t[26]!==s||t[27]!==u?(w=u?null:(0,$.jsxs)(`button`,{type:`button`,onClick:s,className:c(`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`,Y.press),children:[(0,$.jsx)(ne,{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)(Te,{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]=w):w=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:Kn.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:c(`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`,Y.press),children:[(0,$.jsx)(`span`,{className:`truncate text-sm text-fg`,children:e.name}),e.configured?(0,$.jsx)(Pe,{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]!==w||t[36]!==T?(E=(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-3`,children:[w,T]}),t[35]=w,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 Zn({providerId:e,builtinRows:t,labels:n,language:r,onBack:i,onSaved:a}){let o=t.find(t=>t.id===e),s=Je[e],[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(!1),y=(0,Q.useRef)(null),b=l(r).providersSettings,S=Ie(b),w=(0,Q.useMemo)(()=>x(e,r),[e,r]),T=o?.supportsApiKey!==!1,E=o?.supportsOAuth===!0,[D,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(null),[j,M]=(0,Q.useState)(`idle`),[N,F]=(0,Q.useState)(null),[I,L]=(0,Q.useState)(null),[R,ee]=(0,Q.useState)(``),z=j===`waiting`||j===`waiting_code`;(0,Q.useEffect)(()=>{if(!D||!z)return;let e=window.setInterval(()=>{(async()=>{try{let t=await Vn(D);t.status===`waiting_auth`||t.status===`waiting_code`?(M(t.status===`waiting_code`?`waiting_code`:`waiting`),A(t.message??null),F(t.authUrl??null),L(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),M(`success`),A(t.message??b.saved),window.setTimeout(a,600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),M(`error`),A(t.error??t.message??b.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[D,z,a,b.revokeFailed,b.saved]),(0,Q.useEffect)(()=>()=>{D&&Wn(D).catch(()=>{})},[D]);let B=async()=>{M(`waiting`),A(b.oauthStarting),h(null);try{O((await Bn(e)).sessionId)}catch(e){M(`error`),A(e instanceof Error?e.message:b.revokeFailed)}},V=async()=>{if(D){try{await Un(D)}catch{}M(`idle`),A(null),O(null),F(null),L(null)}},H=async()=>{if(!(!D||!R.trim()))try{await Hn(D,R.trim()),ee(``),A(b.oauthProcessingCode)}catch(e){M(`error`),A(e instanceof Error?e.message:b.revokeFailed)}},U=async()=>{let t=u.trim();if(!(!t||!T)){p(!0),h(null);try{await v({[e]:t}),_(!0),window.setTimeout(a,600)}catch(e){h(e instanceof Error?e.message:n.saveError)}finally{p(!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:c(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Y.press),"aria-label":n.back,children:(0,$.jsx)(Te,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,$.jsx)(he,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:o?.name??e}),(0,$.jsx)(Yn,{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,T?(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)(Oe,{id:`builtin-api-key`,value:u,onChange:d,placeholder:n.apiKeyPlaceholder,labels:S,inputRef:y,onKeyDown:e=>{e.key===`Enter`&&U()}})]}):null,E?(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:b.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:b.oauthHint})]}),(0,$.jsxs)(X,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:z,onClick:()=>void B(),children:[z?(0,$.jsx)(P,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,b.oauth]})]}),k?(0,$.jsx)(`p`,{className:c(`text-xs`,j===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:k}):null,j===`waiting`||j===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[N?(0,$.jsxs)(`a`,{href:N,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-2 text-sm font-medium text-white hover:bg-accent-hover`,children:[b.openAuthPage,(0,$.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]}):null,(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>void V(),children:b.cancelOAuth})]}):null,I?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:I}):null,j===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:R,onChange:e=>ee(e.target.value),onKeyDown:e=>e.key===`Enter`&&void H(),placeholder:b.pasteRedirectUrl,className:c(`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`,C)}),(0,$.jsx)(X,{type:`button`,variant:`primary`,onClick:()=>void H(),children:b.submitCode})]}):null]}):null,w.length>0&&T?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:w.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:[pe(e,n),(0,$.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]},e))}):null,m?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:m}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:i,children:n.cancel}),T?(0,$.jsx)(X,{type:`button`,variant:`primary`,disabled:!u.trim()||f||g,onClick:()=>void U(),children:g?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(Pe,{className:`size-3.5`,"aria-hidden":!0}),n.saved]}):f?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(P,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save}):null]})]})]})}function Qn(e=`custom`){if(e!==`custom`&&U[e]){let t=U[e].config;return{preset:e,providerId:W(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 $n(e,t){switch(t.type){case`applyPreset`:return t.key===`custom`?{...e,preset:`custom`,error:null}:U[t.key]?Qn(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 er({initialPresetKey:e,customConfig:t,labels:n,language:r,onBack:i,onSaved:a}){let[o,s]=(0,Q.useReducer)($n,void 0,()=>Qn(e)),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),m=Ie(l(r).providersSettings),{preset:h,providerId:g,baseUrl:_,api:v,apiKey:y,modelIds:b,error:x}=o,w=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:U[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 D({providers:{...n,[e]:s}}),a()}catch(e){s({type:`setError`,value:e instanceof Error?e.message:n.saveError})}finally{d(!1)}},E=async()=>{let e=g.trim()||W(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:U[h]?.config,i=(await S({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)}},k=g.trim()&&_.trim(),A=(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:c(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Y.press),"aria-label":n.back,children:(0,$.jsx)(Te,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,$.jsx)(he,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:n.step2CustomTitle}),(0,$.jsx)(Yn,{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)(J,{id:`custom-preset`,value:h,onChange:e=>s({type:`applyPreset`,key:e.target.value}),className:O(),children:[(0,$.jsx)(q,{value:`custom`,children:n.presetCustom}),Me.map(e=>(0,$.jsx)(q,{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:c(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,C)})]}),(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:c(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,C)})]}),(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)(J,{id:`custom-api-type`,value:v,onChange:e=>s({type:`setApi`,value:e.target.value}),className:O(),children:Ue.map(e=>(0,$.jsx)(q,{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)(Oe,{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)(X,{type:`button`,variant:`secondary`,className:`gap-1.5`,disabled:!A||f,onClick:()=>void E(),children:[f?(0,$.jsx)(P,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Be,{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:c(`flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,C)}),b.length>1?(0,$.jsx)(`button`,{type:`button`,onClick:()=>s({type:`removeModelSlot`,index:t}),className:c(`rounded-lg p-1.5 text-fg-subtle hover:bg-surface-hover hover:text-fg`,Y.press),children:(0,$.jsx)(T,{className:`size-3.5`,"aria-hidden":!0})}):null]},e||`model-slot-${t}`)),(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`w-fit gap-1.5 text-fg-muted`,onClick:()=>s({type:`addModelSlot`}),children:[(0,$.jsx)(Ve,{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)(X,{type:`button`,variant:`secondary`,onClick:i,children:n.cancel}),(0,$.jsx)(X,{type:`button`,variant:`primary`,disabled:!k||u,onClick:()=>void w(),children:u?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(P,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})]})]})}function tr(){let e=(0,Z.c)(31),t=u(or),n=!!t,{data:r,isLoading:i}=be(n),a;e[0]===n?a=e[1]:(a=n?p(`/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}=h(a,o,s),d;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(d={revalidateOnFocus:!1},e[5]=d):d=e[5];let{data:f,isLoading:m}=h(n?k:null,ar,d),g;e[6]===f?g=e[7]:(g=f===void 0?[]:f,e[6]=f,e[7]=g);let _=g,v;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(v={revalidateOnFocus:!1},e[8]=v):v=e[8];let{data:y}=h(n?ce:null,ir,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=Ge(c,fe(r?.payload?.config),_),e[10]=r?.payload?.config,e[11]=c,e[12]=_,e[13]=t):t=e[13],b=t}let x=b,S;bb1:{if(!y){S=null;break bb1}let t;e[14]===y.config?t=e[15]:(t=se(y.config),e[14]=y.config,e[15]=t),S=t}let C=S,w;if(e[16]!==x||e[17]!==C||e[18]!==c||e[19]!==_){w=[];let t=new Set((c??[]).filter(rr).map(nr)),n;e[21]===C?n=e[22]:(n=new Set(C?Object.keys(C.providers):[]),e[21]=C,e[22]=n);let r=n;for(let e of x){if(!t.has(e.id))continue;let n=r.has(e.id),i=n?C.providers[e.id]?.models?.length??0:_.filter(t=>t.provider===e.id).length;w.push({id:e.id,name:e.name,configured:!0,isCustom:n,modelCount:i})}if(C){let t;e[23]===C.providers?t=e[24]:(t=Object.entries(C.providers),e[23]=C.providers,e[24]=t);for(let[e,n]of t)w.some(t=>t.id===e)||w.push({id:e,name:e,configured:!0,isCustom:!0,modelCount:n.models?.length??0})}e[16]=x,e[17]=C,e[18]=c,e[19]=_,e[20]=w}else w=e[20];let T=w,E=i||l||m,D;return e[25]!==x||e[26]!==T||e[27]!==C||e[28]!==E||e[29]!==_?(D={cards:T,loading:E,builtinRows:x,customConfig:C,allModels:_},e[25]=x,e[26]=T,e[27]=C,e[28]=E,e[29]=_,e[30]=D):D=e[30],D}function nr(e){return e.id}function rr(e){return e.configured}function ir(){return He()}function ar(){return I()}function or(e){return e.token}function sr(e){let t=(0,Z.c)(16),{labels:n,onAdd:r,onManage:i}=e,{cards:a,loading:o}=tr();if(o){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(G,{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(lr)})]}),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(cr),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)(Ve,{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)(X,{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)(X,{type:`button`,variant:`primary`,className:`mt-4 gap-1.5`,onClick:r,children:[(0,$.jsx)(Ve,{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)(ur,{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 cr(e){return e.configured}function lr(e){return(0,$.jsx)(G,{className:`h-32 rounded-2xl`},e)}function ur(e){let t=(0,Z.c)(28),{card:n,labels:r,onManage:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=c(`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`,Y.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 l;t[6]!==o||t[7]!==s?(l=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[o,s]}),t[6]=o,t[7]=s,t[8]=l):l=t[8];let u;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(Pe,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),t[9]=u):u=t[9];let d;t[10]===l?d=t[11]:(d=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[l,u]}),t[10]=l,t[11]=d);let f;t[12]!==n.modelCount||t[13]!==r.modelsCount||t[14]!==r.noModels?(f=n.modelCount>0?r.modelsCount.replace(`{{count}}`,String(n.modelCount)):r.noModels,t[12]=n.modelCount,t[13]=r.modelsCount,t[14]=r.noModels,t[15]=f):f=t[15];let p;t[16]===f?p=t[17]:(p=(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:f}),t[16]=f,t[17]=p);let m;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(Re,{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 dr(e){let t=(0,Z.c)(156),{model:n,isNew:r,providerId:i,onSave:a,onClose:o,m:s}=e,l;t[0]===n?l=t[1]:(l=()=>n?{...n}:re(``),t[0]=n,t[1]=l);let[u,d]=(0,Q.useState)(l),[f,p]=(0,Q.useState)(fr),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 v=g,y;t[9]!==u||t[10]!==o||t[11]!==a||t[12]!==v?(y=()=>{if(!v())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]=v,t[13]=y):y=t[13];let b=y,x=u,S;t[14]===x?S=t[15]:(S=V(x),t[14]=x,t[15]=S);let C=S,E=r?s.addModelTitle:s.editModelTitle,D;t[16]===E?D=t[17]:(D=(0,$.jsx)(he,{className:`text-base font-semibold text-fg`,children:E}),t[16]=E,t[17]=D);let k;t[18]!==s.modelProviderLabel||t[19]!==i?(k=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]=k):k=t[20];let A;t[21]!==D||t[22]!==k?(A=(0,$.jsxs)(`div`,{children:[D,k]}),t[21]=D,t[22]=k,t[23]=A):A=t[23];let j;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(j=c(Se,`p-1.5 hover:bg-surface-base`),t[24]=j):j=t[24];let M;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(T,{className:`size-4`}),t[25]=M):M=t[25];let N;t[26]===s.close?N=t[27]:(N=(0,$.jsx)(Ke,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:j,"aria-label":s.close,children:M})}),t[26]=s.close,t[27]=N);let P;t[28]!==A||t[29]!==N?(P=(0,$.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[A,N]}),t[28]=A,t[29]=N,t[30]=P):P=t[30];let F;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[31]=F):F=t[31];let I;t[32]===s.modelId?I=t[33]:(I=(0,$.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[s.modelId,F]}),t[32]=s.modelId,t[33]=I);let L;t[34]===f?L=t[35]:(L=c(_(),f.has(`id`)&&`border-red-500`),t[34]=f,t[35]=L);let R=u.id||``,ee;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(ee=e=>h(`id`,e.target.value),t[36]=ee):ee=t[36];let z=!r,B;t[37]!==L||t[38]!==R||t[39]!==z?(B=(0,$.jsx)(`input`,{className:L,value:R,onChange:ee,placeholder:`e.g. llama3.1:8b`,disabled:z}),t[37]=L,t[38]=R,t[39]=z,t[40]=B):B=t[40];let H;t[41]===f?H=t[42]:(H=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]=H);let U;t[43]!==I||t[44]!==B||t[45]!==H?(U=(0,$.jsxs)(`div`,{children:[I,B,H]}),t[43]=I,t[44]=B,t[45]=H,t[46]=U):U=t[46];let W;t[47]===s.displayName?W=t[48]:(W=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.displayName}),t[47]=s.displayName,t[48]=W);let G;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(G=_(),t[49]=G):G=t[49];let te=u.name||``,K;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(K=e=>h(`name`,e.target.value),t[50]=K):K=t[50];let ne;t[51]===te?ne=t[52]:(ne=(0,$.jsx)(`input`,{className:G,value:te,onChange:K}),t[51]=te,t[52]=ne);let ie;t[53]!==W||t[54]!==ne?(ie=(0,$.jsxs)(`div`,{children:[W,ne]}),t[53]=W,t[54]=ne,t[55]=ie):ie=t[55];let ae;t[56]===s.inputTypes?ae=t[57]:(ae=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.inputTypes}),t[56]=s.inputTypes,t[57]=ae);let oe;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(oe=O(),t[58]=oe):oe=t[58];let se;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(se=e=>h(`input`,ke(e.target.value)),t[59]=se):se=t[59];let ce;t[60]===s?ce=t[61]:(ce=w.map(e=>(0,$.jsx)(q,{value:e.value,children:s[e.labelKey]},e.value)),t[60]=s,t[61]=ce);let le;t[62]!==C||t[63]!==ce?(le=(0,$.jsx)(J,{className:oe,value:C,onChange:se,children:ce}),t[62]=C,t[63]=ce,t[64]=le):le=t[64];let ue;t[65]!==ae||t[66]!==le?(ue=(0,$.jsxs)(`div`,{children:[ae,le]}),t[65]=ae,t[66]=le,t[67]=ue):ue=t[67];let de=u.reasoning||!1,fe;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(fe=e=>h(`reasoning`,e.target.checked),t[68]=fe):fe=t[68];let pe;t[69]===de?pe=t[70]:(pe=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:de,onChange:fe}),t[69]=de,t[70]=pe);let me;t[71]!==s.reasoning||t[72]!==pe?(me=(0,$.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[pe,s.reasoning]}),t[71]=s.reasoning,t[72]=pe,t[73]=me):me=t[73];let ge;t[74]!==ue||t[75]!==me?(ge=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ue,me]}),t[74]=ue,t[75]=me,t[76]=ge):ge=t[76];let _e;t[77]===s.contextWindow?_e=t[78]:(_e=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.contextWindow}),t[77]=s.contextWindow,t[78]=_e);let ve;t[79]===f?ve=t[80]:(ve=c(_(),f.has(`contextWindow`)&&`border-red-500`),t[79]=f,t[80]=ve);let ye=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]!==ve||t[83]!==ye?(xe=(0,$.jsx)(`input`,{type:`number`,min:1,className:ve,value:ye,onChange:be}),t[82]=ve,t[83]=ye,t[84]=xe):xe=t[84];let Ce;t[85]===f?Ce=t[86]:(Ce=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]=Ce);let we;t[87]!==_e||t[88]!==xe||t[89]!==Ce?(we=(0,$.jsxs)(`div`,{children:[_e,xe,Ce]}),t[87]=_e,t[88]=xe,t[89]=Ce,t[90]=we):we=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=c(_(),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 Ae;t[96]!==Ee||t[97]!==De?(Ae=(0,$.jsx)(`input`,{type:`number`,min:1,className:Ee,value:De,onChange:Oe}),t[96]=Ee,t[97]=De,t[98]=Ae):Ae=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]!==Ae||t[103]!==je?(Me=(0,$.jsxs)(`div`,{children:[Te,Ae,je]}),t[101]=Te,t[102]=Ae,t[103]=je,t[104]=Me):Me=t[104];let Ne;t[105]!==we||t[106]!==Me?(Ne=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[we,Me]}),t[105]=we,t[106]=Me,t[107]=Ne):Ne=t[107];let Pe;t[108]===s.costSection?Pe=t[109]:(Pe=(0,$.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:s.costSection}),t[108]=s.costSection,t[109]=Pe);let Fe;t[110]===s.costInput?Fe=t[111]:(Fe=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costInput}),t[110]=s.costInput,t[111]=Fe);let Ie;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=_(),t[112]=Ie):Ie=t[112];let Le=u.cost?.input??0,Re;t[113]===u.cost?Re=t[114]:(Re=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]=Re);let ze;t[115]!==Le||t[116]!==Re?(ze=(0,$.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Ie,value:Le,onChange:Re}),t[115]=Le,t[116]=Re,t[117]=ze):ze=t[117];let Be;t[118]!==Fe||t[119]!==ze?(Be=(0,$.jsxs)(`div`,{children:[Fe,ze]}),t[118]=Fe,t[119]=ze,t[120]=Be):Be=t[120];let Y;t[121]===s.costOutput?Y=t[122]:(Y=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costOutput}),t[121]=s.costOutput,t[122]=Y);let Ve;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(Ve=_(),t[123]=Ve):Ve=t[123];let He=u.cost?.output??0,Ue;t[124]===u.cost?Ue=t[125]:(Ue=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]=Ue);let We;t[126]!==He||t[127]!==Ue?(We=(0,$.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Ve,value:He,onChange:Ue}),t[126]=He,t[127]=Ue,t[128]=We):We=t[128];let Ge;t[129]!==Y||t[130]!==We?(Ge=(0,$.jsxs)(`div`,{children:[Y,We]}),t[129]=Y,t[130]=We,t[131]=Ge):Ge=t[131];let qe;t[132]!==Be||t[133]!==Ge?(qe=(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[Be,Ge]}),t[132]=Be,t[133]=Ge,t[134]=qe):qe=t[134];let Je;t[135]!==Pe||t[136]!==qe?(Je=(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[Pe,qe]}),t[135]=Pe,t[136]=qe,t[137]=Je):Je=t[137];let Ye;t[138]!==U||t[139]!==ie||t[140]!==ge||t[141]!==Ne||t[142]!==Je?(Ye=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[U,ie,ge,Ne,Je]}),t[138]=U,t[139]=ie,t[140]=ge,t[141]=Ne,t[142]=Je,t[143]=Ye):Ye=t[143];let Xe;t[144]===s.cancel?Xe=t[145]:(Xe=(0,$.jsx)(Ke,{asChild:!0,children:(0,$.jsx)(X,{type:`button`,variant:`secondary`,children:s.cancel})}),t[144]=s.cancel,t[145]=Xe);let Ze=r?s.addModelConfirm:s.saveModelConfirm,Qe;t[146]!==b||t[147]!==Ze?(Qe=(0,$.jsx)(X,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,onClick:b,children:Ze}),t[146]=b,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]!==P||t[153]!==Ye||t[154]!==$e?(et=(0,$.jsxs)($.Fragment,{children:[P,Ye,$e]}),t[152]=P,t[153]=Ye,t[154]=$e,t[155]=et):et=t[155],et}function fr(){return new Map}function pr(e){let t=(0,Z.c)(16),{open:n,onOpenChange:r,providerId:i,model:a,isNew:o,onSave:s,m:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(j,{className:c(`xopc-dialog-overlay fixed inset-0 bg-scrim`,Ne)}),t[0]=u):u=t[0];let d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=c(`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`,Ce,`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]!==l||t[4]!==a||t[5]!==r||t[6]!==s||t[7]!==n||t[8]!==i?(f=n?(0,$.jsx)(dr,{model:a,isNew:o,providerId:i,onSave:s,onClose:()=>r(!1),m:l},`${i??`none`}-${a?.id??`new`}`):null,t[2]=o,t[3]=l,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)(le,{children:[u,(0,$.jsx)(y,{className:d,onOpenAutoFocus:mr,children:f})]}),t[10]=f,t[11]=p);let m;return t[12]!==r||t[13]!==n||t[14]!==p?(m=(0,$.jsx)(K,{open:n,onOpenChange:r,children:p}),t[12]=r,t[13]=n,t[14]=p,t[15]=m):m=t[15],m}function mr(e){return e.preventDefault()}function hr(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=()=>A(n).then(gr),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)(Oe,{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 gr(e){return e.apiKey??null}function _r(e){let t=(0,Z.c)(16),{open:n,onOpenChange:r,providerId:i,isCustom:a,builtinRows:o,customConfig:s,allModels:l,labels:u,language:d,onSaved:f}=e,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(j,{className:c(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,Ne)}),t[0]=p):p=t[0];let m;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(m=c(`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`,Ce),t[1]=m):m=t[1];let h;t[2]!==l||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)(le,{children:[p,(0,$.jsx)(y,{className:m,children:a?(0,$.jsx)(yr,{providerId:i,customConfig:s,labels:u,language:d,onClose:()=>r(!1),onSaved:f}):(0,$.jsx)(vr,{providerId:i,builtinRows:o,allModels:l,labels:u,language:d,onClose:()=>r(!1),onSaved:f})})]}),t[2]=l,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)(K,{open:n,onOpenChange:r,children:h}),t[12]=r,t[13]=n,t[14]=h,t[15]=g):g=t[15],g}function vr({providerId:e,builtinRows:t,allModels:n,labels:r,language:i,onClose:a,onSaved:s}){let u=t.find(t=>t.id===e),d=Je[e],f=n.filter(t=>t.provider===e),[p,m]=(0,Q.useState)(u?.apiKey??``),[h,g]=(0,Q.useState)(!1),[_,y]=(0,Q.useState)(!1),[S,w]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(!1),O=l(i).providersSettings,k=u?.supportsApiKey!==!1,A=u?.supportsOAuth===!0,j=u?.authMode===`oauth`&&u.authStatus===`connected`,M=u?.configured===!0&&u.activeKeySource!==`env`&&u.activeKeySource!==`extension`&&u.activeKeySource!==`models_json`,[I,R]=(0,Q.useState)(null),[ee,z]=(0,Q.useState)(null),[B,V]=(0,Q.useState)(`idle`),[H,U]=(0,Q.useState)(null),[W,G]=(0,Q.useState)(null),[K,ne]=(0,Q.useState)(``),re=B===`waiting`||B===`waiting_code`,ie=(0,Q.useMemo)(()=>x(e,i),[e,i]),ae=p!==(u?.apiKey??``),oe=async()=>{let t=p.trim();if(!(!t||!k||te(t))){g(!0),w(null);try{await v({[e]:t}),y(!0),window.setTimeout(()=>{s(),a()},600)}catch(e){w(e instanceof Error?e.message:r.saveError)}finally{g(!1)}}};(0,Q.useEffect)(()=>{if(!I||!re)return;let e=window.setInterval(()=>{(async()=>{try{let t=await Vn(I);t.status===`waiting_auth`||t.status===`waiting_code`?(V(t.status===`waiting_code`?`waiting_code`:`waiting`),z(t.message??null),U(t.authUrl??null),G(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),V(`success`),z(t.message??O.saved),window.setTimeout(()=>{s(),a()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),V(`error`),z(t.error??t.message??O.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[I,re,a,s,O.revokeFailed,O.saved]),(0,Q.useEffect)(()=>()=>{I&&Wn(I).catch(()=>{})},[I]);let se=async()=>{try{await N(e),s(),a()}catch{}},ce=async()=>{V(`waiting`),z(O.oauthStarting),w(null);try{R((await Bn(e)).sessionId)}catch(e){V(`error`),z(e instanceof Error?e.message:O.revokeFailed)}},le=async()=>{if(I){try{await Un(I)}catch{}V(`idle`),z(null),R(null),U(null),G(null)}},ue=async()=>{if(!(!I||!K.trim()))try{await Hn(I,K.trim()),ne(``),z(O.oauthProcessingCode)}catch(e){V(`error`),z(e instanceof Error?e.message:O.revokeFailed)}},de=async()=>{try{await Gn(e),s(),a()}catch(e){w(e instanceof Error?e.message:O.revokeFailed)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(he,{className:`text-base font-semibold text-fg`,children:u?.name??e}),(0,$.jsx)(Ke,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:c(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Y.press),children:(0,$.jsx)(T,{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,u?.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:u.baseUrl})]}):u?.category===`extension`?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.apiUrlExtensionHint}):null,k?(0,$.jsx)(hr,{providerId:e,inputId:`manage-api-key`,value:p,onChange:e=>{m(e),y(!1)},labels:{apiKeyLabel:r.apiKeyLabel,apiKeyPlaceholder:r.apiKeyPlaceholder,maskedHelp:r.maskedHelp,copy:r.copy,copied:r.copied,show:r.showKey,hide:r.hideKey,notInConfigFile:r.notInConfigFile,loadFailed:r.loadFailed}}):u?.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}),u?.extensionId?(0,$.jsxs)(o,{to:`/settings/ext/${encodeURIComponent(u.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)(L,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,A?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 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:O.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:j?O.sourceOauth:O.oauthHint})]}),j?(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void de(),children:O.revoke}):(0,$.jsxs)(X,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:re,onClick:()=>void ce(),children:[re?(0,$.jsx)(P,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(F,{className:`size-3.5`,"aria-hidden":!0}),O.oauth]})]}),ee?(0,$.jsx)(`p`,{className:c(`text-xs`,B===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:ee}):null,B===`waiting`||B===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[H?(0,$.jsxs)(`a`,{href:H,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-2 text-sm font-medium text-white hover:bg-accent-hover`,children:[(0,$.jsx)(L,{className:`size-4`,"aria-hidden":!0}),O.openAuthPage]}):null,(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>void le(),children:O.cancelOAuth})]}):null,W?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:W}):null,B===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:K,onChange:e=>ne(e.target.value),onKeyDown:e=>e.key===`Enter`&&void ue(),placeholder:O.pasteRedirectUrl,className:c(`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`,C)}),(0,$.jsx)(X,{type:`button`,variant:`primary`,onClick:()=>void ue(),children:O.submitCode})]}):null]}):null,ie.length>0&&k?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ie.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:[pe(e,r),(0,$.jsx)(L,{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}),S?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:S}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[M?(0,$.jsxs)(X,{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:()=>D(!0),children:[(0,$.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:k&&ae&&!te(p.trim())?(0,$.jsx)(X,{type:`button`,variant:`primary`,disabled:!p.trim()||h||_,onClick:()=>void oe(),children:_?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(Pe,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):h?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(P,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,$.jsx)(_e,{open:E,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,u?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void se(),onCancel:()=>D(!1)})]})}function yr({providerId:e,customConfig:t,labels:n,language:r,onClose:i,onSaved:a}){let o=l(r).modelsSettings,s=t?.providers[e],[u,d]=(0,Q.useState)(s?.baseUrl??``),[f,p]=(0,Q.useState)(s?.apiKey??``),[m,h]=(0,Q.useState)(s?.models??[]),[_,v]=(0,Q.useState)(!1),[y,x]=(0,Q.useState)(null),[S,w]=(0,Q.useState)(!1),[E,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(null),N=n=>{if(!t)return null;let r=f.trim(),i={...s,baseUrl:u.trim()||void 0,apiKey:te(r)?s?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},F=async()=>{let e=N({models:m});if(e){v(!0),x(null);try{await D(e),a(),i()}catch(e){x(e instanceof Error?e.message:n.saveError)}finally{v(!1)}}},I=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await D({providers:r}),a(),i()}catch{}},L=(e,t)=>{M({model:e,isNew:t}),A(!0)},R=async e=>{if(!j)return;let t=j.isNew?[...m,e]:m.map(t=>t.id===e.id?e:t);h(t);let r=N({models:t});if(r)try{await D(r),a()}catch(e){x(e instanceof Error?e.message:n.saveError)}},ee=async e=>{let t=m.filter(t=>t.id!==e);h(t),O(null);let r=N({models:t});if(r)try{await D(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)(he,{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)(Ke,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:c(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Y.press),children:(0,$.jsx)(T,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`manage-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,$.jsx)(`input`,{id:`manage-base-url`,type:`url`,autoComplete:`off`,value:u,onChange:e=>d(e.target.value),className:c(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,C)})]}),(0,$.jsx)(hr,{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)(`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)(X,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>L(null,!0),children:[(0,$.jsx)(Ve,{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:c(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Y.press),onClick:()=>L(e,!1),"aria-label":o.editModel,children:(0,$.jsx)(g,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,className:c(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-red-600 dark:hover:text-red-400`,Y.press),onClick:()=>O(e.id),"aria-label":o.removeModel,children:(0,$.jsx)(b,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),y?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:y}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsxs)(X,{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:()=>w(!0),children:[(0,$.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(X,{type:`button`,variant:`primary`,disabled:_,onClick:()=>void F(),children:_?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(P,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,$.jsx)(_e,{open:S,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void I(),onCancel:()=>w(!1)}),(0,$.jsx)(_e,{open:E!==null,title:o.removeModel,description:o.removeModelConfirm.replace(`{{id}}`,E??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{E&&ee(E)},onCancel:()=>O(null)}),(0,$.jsx)(pr,{open:k,onOpenChange:e=>{A(e),e||M(null)},providerId:e,model:j?.model??null,isNew:j?.isNew??!1,onSave:e=>void R(e),m:o})]})}function br(e){return Le.includes(e)}function xr(){let e=(0,Z.c)(74),t=d(wr),n;e[0]===t?n=e[1]:(n=l(t),e[0]=t,e[1]=n);let r=n,c=r.capabilitiesSettings,u=i(),{capability:f}=s(),p=vt(Cr),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(null),v=tr(),y;e[2]!==c.unsavedChanges||e[3]!==p?(y=e=>p.get(e)?.dirty?(0,$.jsx)(`span`,{className:`size-1.5 rounded-full bg-amber-500`,"aria-label":c.unsavedChanges,title:c.unsavedChanges}):void 0,e[2]=c.unsavedChanges,e[3]=p,e[4]=y):y=e[4];let b=y,x;e[5]!==c.modelsHint||e[6]!==c.tabs.models?(x={id:`models`,icon:oe,label:c.tabs.models,hint:c.modelsHint},e[5]=c.modelsHint,e[6]=c.tabs.models,e[7]=x):x=e[7];let S=c.tabs.image,C=c.imageHint,w;e[8]===b?w=e[9]:(w=b(`image-models`),e[8]=b,e[9]=w);let T;e[10]!==c.imageHint||e[11]!==c.tabs.image||e[12]!==w?(T={id:`image`,icon:Fe,label:S,hint:C,suffix:w},e[10]=c.imageHint,e[11]=c.tabs.image,e[12]=w,e[13]=T):T=e[13];let E=c.tabs.voice,D=c.voiceHint,O;e[14]===b?O=e[15]:(O=b(`voice`),e[14]=b,e[15]=O);let k;e[16]!==c.tabs.voice||e[17]!==c.voiceHint||e[18]!==O?(k={id:`voice`,icon:de,label:E,hint:D,suffix:O},e[16]=c.tabs.voice,e[17]=c.voiceHint,e[18]=O,e[19]=k):k=e[19];let A=c.tabs.search,j=c.searchHint,M;e[20]===b?M=e[21]:(M=b(`search`),e[20]=b,e[21]=M);let N;e[22]!==c.searchHint||e[23]!==c.tabs.search||e[24]!==M?(N={id:`search`,icon:Be,label:A,hint:j,suffix:M},e[22]=c.searchHint,e[23]=c.tabs.search,e[24]=M,e[25]=N):N=e[25];let P;e[26]!==k||e[27]!==N||e[28]!==x||e[29]!==T?(P=[x,T,k,N],e[26]=k,e[27]=N,e[28]=x,e[29]=T,e[30]=P):P=e[30];let F=P,I;e[31]===u?I=e[32]:(I=e=>u(ye(e)),e[31]=u,e[32]=I);let L=I,R=Sr;if(!br(f)){let t;return e[33]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(a,{to:ye(`models`),replace:!0}),e[33]=t):t=e[33],t}let ee=r.nav.settingsCapabilities,B=c.subtitle,V;e[34]===t?V=e[35]:(V=ve(t,`configuration`),e[34]=t,e[35]=V);let H;e[36]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(z,{className:`size-4`,"aria-hidden":!0}),e[36]=H):H=e[36];let U;e[37]===c.agentSettingsLink?U=e[38]:(U=(0,$.jsx)(X,{asChild:!0,variant:`secondary`,children:(0,$.jsxs)(o,{to:`/agents`,children:[H,c.agentSettingsLink]})}),e[37]=c.agentSettingsLink,e[38]=U);let W;e[39]!==c.docsLink||e[40]!==c.subtitle||e[41]!==r.nav.settingsCapabilities||e[42]!==V||e[43]!==U?(W=(0,$.jsx)(Ye,{title:ee,subtitle:B,docsLink:V,docsLabel:c.docsLink,actions:U}),e[39]=c.docsLink,e[40]=c.subtitle,e[41]=r.nav.settingsCapabilities,e[42]=V,e[43]=U,e[44]=W):W=e[44];let G;e[45]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(yt,{}),e[45]=G):G=e[45];let te;e[46]!==c.tabsAria||e[47]!==f||e[48]!==F||e[49]!==L?(te=(0,$.jsx)(gt,{items:F,activeTab:f,onChange:L,ariaLabel:c.tabsAria,tabIdPrefix:`capability-tab`,panelIdPrefix:`capability-panel`}),e[46]=c.tabsAria,e[47]=f,e[48]=F,e[49]=L,e[50]=te):te=e[50];let K;e[51]!==c.connectedProviders||e[52]!==f||e[53]!==F?(K=F.map(e=>(0,$.jsx)(Er,{id:e.id,activeSection:f,hint:e.hint,children:e.id===`models`?(0,$.jsx)(sr,{labels:c.connectedProviders,onAdd:()=>h(!0),onManage:(e,t)=>_({providerId:e,isCustom:t})}):(0,$.jsx)(Tr,{section:e.id})},e.id)),e[51]=c.connectedProviders,e[52]=f,e[53]=F,e[54]=K):K=e[54];let ne;e[55]!==m||e[56]!==c.addProviderDialog||e[57]!==t||e[58]!==v.builtinRows||e[59]!==v.customConfig?(ne=(0,$.jsx)(Jn,{open:m,onOpenChange:h,builtinRows:v.builtinRows,customConfig:v.customConfig,labels:c.addProviderDialog,language:t,onSaved:R}),e[55]=m,e[56]=c.addProviderDialog,e[57]=t,e[58]=v.builtinRows,e[59]=v.customConfig,e[60]=ne):ne=e[60];let re;e[61]!==c.manageProviderDialog||e[62]!==t||e[63]!==g||e[64]!==v.allModels||e[65]!==v.builtinRows||e[66]!==v.customConfig?(re=g?(0,$.jsx)(_r,{open:!0,onOpenChange:e=>{e||_(null)},providerId:g.providerId,isCustom:g.isCustom,builtinRows:v.builtinRows,customConfig:v.customConfig,allModels:v.allModels,labels:c.manageProviderDialog,language:t,onSaved:R}):null,e[61]=c.manageProviderDialog,e[62]=t,e[63]=g,e[64]=v.allModels,e[65]=v.builtinRows,e[66]=v.customConfig,e[67]=re):re=e[67];let ie;return e[68]!==W||e[69]!==te||e[70]!==K||e[71]!==ne||e[72]!==re?(ie=(0,$.jsxs)(Xe,{children:[W,G,te,K,ne,re]}),e[68]=W,e[69]=te,e[70]=K,e[71]=ne,e[72]=re,e[73]=ie):ie=e[73],ie}function Sr(){me()}function Cr(e){return e.sections}function wr(e){return e.language}function Tr(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)(Lt,{}),t[0]=e):e=t[0],e}case`voice`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(dn,{}),t[1]=e):e=t[1],e}case`search`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ln,{}),t[2]=e):e=t[2],e}}}function Er({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:c(`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{xr as CapabilitiesSettingsPanel};
|