@kaitranntt/ccs 7.55.0 → 7.56.0-dev.2
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/README.md +15 -3
- package/dist/api/services/cliproxy-profile-bridge.d.ts +13 -0
- package/dist/api/services/cliproxy-profile-bridge.d.ts.map +1 -0
- package/dist/api/services/cliproxy-profile-bridge.js +147 -0
- package/dist/api/services/cliproxy-profile-bridge.js.map +1 -0
- package/dist/api/services/index.d.ts +3 -1
- package/dist/api/services/index.d.ts.map +1 -1
- package/dist/api/services/index.js +9 -1
- package/dist/api/services/index.js.map +1 -1
- package/dist/api/services/profile-lifecycle-service.d.ts.map +1 -1
- package/dist/api/services/profile-lifecycle-service.js +10 -10
- package/dist/api/services/profile-lifecycle-service.js.map +1 -1
- package/dist/api/services/profile-reader.d.ts.map +1 -1
- package/dist/api/services/profile-reader.js +37 -14
- package/dist/api/services/profile-reader.js.map +1 -1
- package/dist/api/services/profile-types.d.ts +35 -0
- package/dist/api/services/profile-types.d.ts.map +1 -1
- package/dist/api/services/profile-writer.d.ts +7 -1
- package/dist/api/services/profile-writer.d.ts.map +1 -1
- package/dist/api/services/profile-writer.js +77 -37
- package/dist/api/services/profile-writer.js.map +1 -1
- package/dist/auth/commands/create-command.js +1 -1
- package/dist/auth/commands/create-command.js.map +1 -1
- package/dist/auth/commands/remove-command.js +1 -1
- package/dist/auth/commands/remove-command.js.map +1 -1
- package/dist/auth/profile-registry.d.ts.map +1 -1
- package/dist/auth/profile-registry.js +46 -48
- package/dist/auth/profile-registry.js.map +1 -1
- package/dist/cliproxy/account-manager.d.ts +1 -1
- package/dist/cliproxy/account-manager.d.ts.map +1 -1
- package/dist/cliproxy/account-manager.js +4 -1
- package/dist/cliproxy/account-manager.js.map +1 -1
- package/dist/cliproxy/accounts/index.d.ts +1 -1
- package/dist/cliproxy/accounts/index.d.ts.map +1 -1
- package/dist/cliproxy/accounts/index.js +4 -1
- package/dist/cliproxy/accounts/index.js.map +1 -1
- package/dist/cliproxy/accounts/query.d.ts.map +1 -1
- package/dist/cliproxy/accounts/query.js +4 -6
- package/dist/cliproxy/accounts/query.js.map +1 -1
- package/dist/cliproxy/accounts/registry.d.ts +2 -2
- package/dist/cliproxy/accounts/registry.d.ts.map +1 -1
- package/dist/cliproxy/accounts/registry.js +292 -320
- package/dist/cliproxy/accounts/registry.js.map +1 -1
- package/dist/cliproxy/accounts/token-file-ops.d.ts +16 -1
- package/dist/cliproxy/accounts/token-file-ops.d.ts.map +1 -1
- package/dist/cliproxy/accounts/token-file-ops.js +55 -3
- package/dist/cliproxy/accounts/token-file-ops.js.map +1 -1
- package/dist/cliproxy/ai-providers/config-store.d.ts +19 -0
- package/dist/cliproxy/ai-providers/config-store.d.ts.map +1 -0
- package/dist/cliproxy/ai-providers/config-store.js +150 -0
- package/dist/cliproxy/ai-providers/config-store.js.map +1 -0
- package/dist/cliproxy/ai-providers/config-yaml-sections.d.ts +2 -0
- package/dist/cliproxy/ai-providers/config-yaml-sections.d.ts.map +1 -0
- package/dist/cliproxy/ai-providers/config-yaml-sections.js +43 -0
- package/dist/cliproxy/ai-providers/config-yaml-sections.js.map +1 -0
- package/dist/cliproxy/ai-providers/index.d.ts +4 -0
- package/dist/cliproxy/ai-providers/index.d.ts.map +1 -0
- package/dist/cliproxy/ai-providers/index.js +12 -0
- package/dist/cliproxy/ai-providers/index.js.map +1 -0
- package/dist/cliproxy/ai-providers/service.d.ts +6 -0
- package/dist/cliproxy/ai-providers/service.d.ts.map +1 -0
- package/dist/cliproxy/ai-providers/service.js +220 -0
- package/dist/cliproxy/ai-providers/service.js.map +1 -0
- package/dist/cliproxy/ai-providers/types.d.ts +99 -0
- package/dist/cliproxy/ai-providers/types.d.ts.map +1 -0
- package/dist/cliproxy/ai-providers/types.js +53 -0
- package/dist/cliproxy/ai-providers/types.js.map +1 -0
- package/dist/cliproxy/auth/oauth-handler.d.ts +1 -0
- package/dist/cliproxy/auth/oauth-handler.d.ts.map +1 -1
- package/dist/cliproxy/auth/oauth-handler.js +31 -69
- package/dist/cliproxy/auth/oauth-handler.js.map +1 -1
- package/dist/cliproxy/auth/oauth-process.d.ts +1 -0
- package/dist/cliproxy/auth/oauth-process.d.ts.map +1 -1
- package/dist/cliproxy/auth/oauth-process.js +5 -5
- package/dist/cliproxy/auth/oauth-process.js.map +1 -1
- package/dist/cliproxy/auth/token-manager.d.ts +1 -1
- package/dist/cliproxy/auth/token-manager.d.ts.map +1 -1
- package/dist/cliproxy/auth/token-manager.js +53 -20
- package/dist/cliproxy/auth/token-manager.js.map +1 -1
- package/dist/cliproxy/auth-token-manager.d.ts.map +1 -1
- package/dist/cliproxy/auth-token-manager.js +47 -50
- package/dist/cliproxy/auth-token-manager.js.map +1 -1
- package/dist/cliproxy/base-config-loader.d.ts +1 -1
- package/dist/cliproxy/base-config-loader.d.ts.map +1 -1
- package/dist/cliproxy/codex-plan-compatibility.d.ts +19 -0
- package/dist/cliproxy/codex-plan-compatibility.d.ts.map +1 -1
- package/dist/cliproxy/codex-plan-compatibility.js +62 -1
- package/dist/cliproxy/codex-plan-compatibility.js.map +1 -1
- package/dist/cliproxy/codex-reasoning-proxy.d.ts +5 -0
- package/dist/cliproxy/codex-reasoning-proxy.d.ts.map +1 -1
- package/dist/cliproxy/codex-reasoning-proxy.js +103 -20
- package/dist/cliproxy/codex-reasoning-proxy.js.map +1 -1
- package/dist/cliproxy/composite-validator.d.ts.map +1 -1
- package/dist/cliproxy/composite-validator.js.map +1 -1
- package/dist/cliproxy/config/env-builder.d.ts +2 -2
- package/dist/cliproxy/config/env-builder.d.ts.map +1 -1
- package/dist/cliproxy/config/extended-context-config.d.ts +1 -1
- package/dist/cliproxy/config/extended-context-config.d.ts.map +1 -1
- package/dist/cliproxy/config/generator.d.ts +1 -1
- package/dist/cliproxy/config/generator.d.ts.map +1 -1
- package/dist/cliproxy/config/path-resolver.d.ts +1 -1
- package/dist/cliproxy/config/path-resolver.d.ts.map +1 -1
- package/dist/cliproxy/config/thinking-config.d.ts +2 -2
- package/dist/cliproxy/config/thinking-config.d.ts.map +1 -1
- package/dist/cliproxy/config/thinking-config.js.map +1 -1
- package/dist/cliproxy/executor/index.js +1 -1
- package/dist/cliproxy/executor/index.js.map +1 -1
- package/dist/cliproxy/index.d.ts +2 -0
- package/dist/cliproxy/index.d.ts.map +1 -1
- package/dist/cliproxy/index.js +9 -2
- package/dist/cliproxy/index.js.map +1 -1
- package/dist/cliproxy/management-api-client.d.ts +9 -0
- package/dist/cliproxy/management-api-client.d.ts.map +1 -1
- package/dist/cliproxy/management-api-client.js +16 -3
- package/dist/cliproxy/management-api-client.js.map +1 -1
- package/dist/cliproxy/model-catalog.d.ts +1 -1
- package/dist/cliproxy/model-catalog.d.ts.map +1 -1
- package/dist/cliproxy/model-id-normalizer.d.ts +1 -1
- package/dist/cliproxy/model-id-normalizer.d.ts.map +1 -1
- package/dist/cliproxy/services/variant-config-adapter.d.ts.map +1 -1
- package/dist/cliproxy/services/variant-config-adapter.js +43 -39
- package/dist/cliproxy/services/variant-config-adapter.js.map +1 -1
- package/dist/cliproxy/thinking-validator.d.ts +1 -1
- package/dist/cliproxy/thinking-validator.d.ts.map +1 -1
- package/dist/cliproxy/thinking-validator.js.map +1 -1
- package/dist/cliproxy/types.d.ts +22 -0
- package/dist/cliproxy/types.d.ts.map +1 -1
- package/dist/commands/api-command/create-command.d.ts.map +1 -1
- package/dist/commands/api-command/create-command.js +89 -0
- package/dist/commands/api-command/create-command.js.map +1 -1
- package/dist/commands/api-command/help.d.ts.map +1 -1
- package/dist/commands/api-command/help.js +6 -0
- package/dist/commands/api-command/help.js.map +1 -1
- package/dist/commands/api-command/shared.d.ts +2 -1
- package/dist/commands/api-command/shared.d.ts.map +1 -1
- package/dist/commands/api-command/shared.js +6 -0
- package/dist/commands/api-command/shared.js.map +1 -1
- package/dist/commands/cliproxy/proxy-lifecycle-subcommand.d.ts +0 -5
- package/dist/commands/cliproxy/proxy-lifecycle-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/proxy-lifecycle-subcommand.js +6 -16
- package/dist/commands/cliproxy/proxy-lifecycle-subcommand.js.map +1 -1
- package/dist/commands/cliproxy/resolve-lifecycle-port.d.ts +6 -0
- package/dist/commands/cliproxy/resolve-lifecycle-port.d.ts.map +1 -0
- package/dist/commands/cliproxy/resolve-lifecycle-port.js +15 -0
- package/dist/commands/cliproxy/resolve-lifecycle-port.js.map +1 -0
- package/dist/commands/config-auth/disable-command.d.ts.map +1 -1
- package/dist/commands/config-auth/disable-command.js +8 -8
- package/dist/commands/config-auth/disable-command.js.map +1 -1
- package/dist/commands/config-auth/setup-command.d.ts.map +1 -1
- package/dist/commands/config-auth/setup-command.js +9 -11
- package/dist/commands/config-auth/setup-command.js.map +1 -1
- package/dist/commands/config-dashboard-host.js +2 -2
- package/dist/commands/config-dashboard-host.js.map +1 -1
- package/dist/commands/copilot-command.js +11 -11
- package/dist/commands/copilot-command.js.map +1 -1
- package/dist/commands/cursor-command.d.ts.map +1 -1
- package/dist/commands/cursor-command.js +11 -11
- package/dist/commands/cursor-command.js.map +1 -1
- package/dist/commands/help-command.d.ts.map +1 -1
- package/dist/commands/help-command.js +5 -1
- package/dist/commands/help-command.js.map +1 -1
- package/dist/commands/setup-command.d.ts.map +1 -1
- package/dist/commands/setup-command.js +4 -3
- package/dist/commands/setup-command.js.map +1 -1
- package/dist/config/unified-config-loader.d.ts +2 -2
- package/dist/config/unified-config-loader.d.ts.map +1 -1
- package/dist/config/unified-config-loader.js +39 -32
- package/dist/config/unified-config-loader.js.map +1 -1
- package/dist/management/instance-manager.d.ts +2 -1
- package/dist/management/instance-manager.d.ts.map +1 -1
- package/dist/management/instance-manager.js +23 -9
- package/dist/management/instance-manager.js.map +1 -1
- package/dist/management/profile-context-sync-lock.d.ts +3 -0
- package/dist/management/profile-context-sync-lock.d.ts.map +1 -1
- package/dist/management/profile-context-sync-lock.js +75 -3
- package/dist/management/profile-context-sync-lock.js.map +1 -1
- package/dist/management/shared-manager.d.ts +21 -8
- package/dist/management/shared-manager.d.ts.map +1 -1
- package/dist/management/shared-manager.js +353 -24
- package/dist/management/shared-manager.js.map +1 -1
- package/dist/shared/claude-extension-setup.js +2 -2
- package/dist/shared/claude-extension-setup.js.map +1 -1
- package/dist/types/cli.d.ts +10 -9
- package/dist/types/cli.d.ts.map +1 -1
- package/dist/types/cli.js +8 -9
- package/dist/types/cli.js.map +1 -1
- package/dist/types/utils.d.ts +7 -6
- package/dist/types/utils.d.ts.map +1 -1
- package/dist/types/utils.js +6 -7
- package/dist/types/utils.js.map +1 -1
- package/dist/ui/assets/{accounts-CjGyCl_8.js → accounts-BikRyqcT.js} +1 -1
- package/dist/ui/assets/{alert-dialog-cy99V8EM.js → alert-dialog-CwEJfEUX.js} +1 -1
- package/dist/ui/assets/antigravity-responsibility-constants-Bvh4Ybz0.js +1 -0
- package/dist/ui/assets/api-BYSEdQYh.js +4 -0
- package/dist/ui/assets/{auth-section-DsDyGmzl.js → auth-section-CrFrby6w.js} +1 -1
- package/dist/ui/assets/{backups-section-B63xrUmB.js → backups-section-CdMvSnSm.js} +1 -1
- package/dist/ui/assets/{checkbox-AxZFvatO.js → checkbox-CC0rU-9-.js} +1 -1
- package/dist/ui/assets/{claude-extension-N0lxo7BY.js → claude-extension-CzGeZYz8.js} +1 -1
- package/dist/ui/assets/cliproxy-BSNSGNOv.js +3 -0
- package/dist/ui/assets/cliproxy-ai-providers-D-U6NKfV.js +21 -0
- package/dist/ui/assets/cliproxy-control-panel-BCexyz40.js +1 -0
- package/dist/ui/assets/{confirm-dialog-D2bDFGvT.js → confirm-dialog-Bee0kh6i.js} +1 -1
- package/dist/ui/assets/{copilot-INm6uOZF.js → copilot-BZRAvPLD.js} +1 -1
- package/dist/ui/assets/{cursor-C8rDHKEp.js → cursor-CO2rCNKC.js} +1 -1
- package/dist/ui/assets/{droid-OZDvbiwC.js → droid-CcKqoQtO.js} +2 -2
- package/dist/ui/assets/{globalenv-section-ClTBgKg5.js → globalenv-section-CBRvmZbS.js} +1 -1
- package/dist/ui/assets/{health-CGaRANip.js → health-DgrTQESI.js} +1 -1
- package/dist/ui/assets/icons-DR-ORtNe.js +1 -0
- package/dist/ui/assets/{index-DS1QEaxk.js → index-BOhcsuQK.js} +1 -1
- package/dist/ui/assets/{index-CGOZU3jq.js → index-CursmDny.js} +1 -1
- package/dist/ui/assets/{index-CCSdUs7x.js → index-D90gSn57.js} +1 -1
- package/dist/ui/assets/{index-DQ4jn6yA.js → index-DJCPwAoe.js} +1 -1
- package/dist/ui/assets/index-kGiBvBM-.css +1 -0
- package/dist/ui/assets/index-sCtK1kDn.js +47 -0
- package/dist/ui/assets/providers/codex-color.svg +24 -0
- package/dist/ui/assets/providers/vertex.svg +25 -0
- package/dist/ui/assets/proxy-status-widget-C8cOlsqE.js +1 -0
- package/dist/ui/assets/{searchable-select-D6dcPTiL.js → searchable-select-CF22qEzz.js} +1 -1
- package/dist/ui/assets/{separator-Czy9IRpl.js → separator-CAoIlNuN.js} +1 -1
- package/dist/ui/assets/{shared-BUJNJgAr.js → shared-zeFjETE6.js} +1 -1
- package/dist/ui/assets/{switch-Bog43RUy.js → switch-BeqpDfK5.js} +1 -1
- package/dist/ui/assets/{updates-jcWPnn9L.js → updates-By9S46EJ.js} +1 -1
- package/dist/ui/index.html +3 -3
- package/dist/utils/claude-config-path.d.ts.map +1 -1
- package/dist/utils/claude-config-path.js +2 -5
- package/dist/utils/claude-config-path.js.map +1 -1
- package/dist/utils/config-manager.d.ts +7 -1
- package/dist/utils/config-manager.d.ts.map +1 -1
- package/dist/utils/config-manager.js +30 -1
- package/dist/utils/config-manager.js.map +1 -1
- package/dist/utils/shell-executor.js +1 -1
- package/dist/utils/shell-executor.js.map +1 -1
- package/dist/web-server/health-service.d.ts.map +1 -1
- package/dist/web-server/health-service.js +2 -3
- package/dist/web-server/health-service.js.map +1 -1
- package/dist/web-server/middleware/auth-middleware.d.ts +2 -0
- package/dist/web-server/middleware/auth-middleware.d.ts.map +1 -1
- package/dist/web-server/middleware/auth-middleware.js +23 -1
- package/dist/web-server/middleware/auth-middleware.js.map +1 -1
- package/dist/web-server/routes/account-routes.d.ts.map +1 -1
- package/dist/web-server/routes/account-routes.js +26 -6
- package/dist/web-server/routes/account-routes.js.map +1 -1
- package/dist/web-server/routes/ai-provider-routes.d.ts +3 -0
- package/dist/web-server/routes/ai-provider-routes.d.ts.map +1 -0
- package/dist/web-server/routes/ai-provider-routes.js +118 -0
- package/dist/web-server/routes/ai-provider-routes.js.map +1 -0
- package/dist/web-server/routes/cliproxy-auth-routes.d.ts +7 -0
- package/dist/web-server/routes/cliproxy-auth-routes.d.ts.map +1 -1
- package/dist/web-server/routes/cliproxy-auth-routes.js +119 -32
- package/dist/web-server/routes/cliproxy-auth-routes.js.map +1 -1
- package/dist/web-server/routes/cliproxy-stats-routes.d.ts.map +1 -1
- package/dist/web-server/routes/cliproxy-stats-routes.js +6 -0
- package/dist/web-server/routes/cliproxy-stats-routes.js.map +1 -1
- package/dist/web-server/routes/cliproxy-sync-routes.d.ts.map +1 -1
- package/dist/web-server/routes/cliproxy-sync-routes.js +6 -11
- package/dist/web-server/routes/cliproxy-sync-routes.js.map +1 -1
- package/dist/web-server/routes/cursor-settings-routes.d.ts.map +1 -1
- package/dist/web-server/routes/cursor-settings-routes.js +36 -33
- package/dist/web-server/routes/cursor-settings-routes.js.map +1 -1
- package/dist/web-server/routes/index.d.ts.map +1 -1
- package/dist/web-server/routes/index.js +2 -0
- package/dist/web-server/routes/index.js.map +1 -1
- package/dist/web-server/routes/misc-routes.d.ts.map +1 -1
- package/dist/web-server/routes/misc-routes.js +26 -19
- package/dist/web-server/routes/misc-routes.js.map +1 -1
- package/dist/web-server/routes/profile-routes.d.ts.map +1 -1
- package/dist/web-server/routes/profile-routes.js +45 -0
- package/dist/web-server/routes/profile-routes.js.map +1 -1
- package/dist/web-server/routes/proxy-routes.d.ts.map +1 -1
- package/dist/web-server/routes/proxy-routes.js +6 -0
- package/dist/web-server/routes/proxy-routes.js.map +1 -1
- package/dist/web-server/routes/settings-routes.d.ts.map +1 -1
- package/dist/web-server/routes/settings-routes.js +146 -109
- package/dist/web-server/routes/settings-routes.js.map +1 -1
- package/dist/web-server/routes/websearch-routes.d.ts.map +1 -1
- package/dist/web-server/routes/websearch-routes.js +31 -43
- package/dist/web-server/routes/websearch-routes.js.map +1 -1
- package/dist/web-server/shared-routes.d.ts.map +1 -1
- package/dist/web-server/shared-routes.js +6 -0
- package/dist/web-server/shared-routes.js.map +1 -1
- package/package.json +2 -2
- package/scripts/dev-release.sh +103 -51
- package/dist/ui/assets/api-DKrhDjiy.js +0 -4
- package/dist/ui/assets/cliproxy-D2ozaUJ3.js +0 -3
- package/dist/ui/assets/cliproxy-control-panel-5fYLcZKs.js +0 -1
- package/dist/ui/assets/icons-DtwH984l.js +0 -1
- package/dist/ui/assets/index-ClEn7Y7g.css +0 -1
- package/dist/ui/assets/index-tMnuUCFi.js +0 -47
- package/dist/ui/assets/proxy-status-widget-PESjh9-t.js +0 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as o}from"./react-vendor-CNOkPC89.js";import{a as Be,u as gs,b as $s}from"./tanstack-B8i0evp-.js";import{d as L,C as fs,b as js,c as V,P as Ae,a as Z,a8 as se,L as Y,I as le,r as vs,s as Ns,t as ys,v as bs,w as Ie,a9 as ws,aa as Qs,ab as zs,ac as Js,u as ks,ad as Ve,ae as Ge,af as $e,ag as Qe,ah as Cs,ai as as,aj as Ws,ak as Xs,W as As,al as Fe,am as Ss,Y as we,B,an as Ue,ao as ns,ap as Ys,aq as Zs,ar as et,as as st,x as Ps,n as ze,at as Je,m as tt,au as at,av as nt,aw as it,ax as rt,ay as ot,az as lt,aA as ct,aB as pe,T as he,p as ge,q as fe,aC as dt,aD as ut,aE as mt,aF as is,aG as xt,aH as pt,aI as ht,aJ as gt,aK as ft,aL as jt,aM as vt,Q as Nt,R as yt,U as rs,V as os,aN as bt,aO as wt,aP as kt,aQ as Ct,aR as At,aS as St,aT as Pt,aU as Mt,aV as Tt,aW as Dt,aX as Ot,aY as Et,S as _t}from"./index-sCtK1kDn.js";import{C as He}from"./default-ports-1QQSffYX.js";import{t as K}from"./notifications-B2HqRBj7.js";import{C as Ms,L as J,o as me,Q as Rt,l as ce,n as Ts,at as We,R as Xe,p as xe,a4 as ve,T as Se,a2 as Lt,au as Ds,as as It,av as Pe,Z as Ne,O as Os,h as Ft,t as Es,aw as Ut,aj as Ht,X as Ye,a3 as _s,m as Kt,x as qt,y as Rs,z as Ke,ax as Bt,u as ls,ay as Vt,ai as Ls,v as Gt,az as cs,am as $t,aA as Is}from"./icons-DR-ORtNe.js";import{R as ke,A as ds,D as _e,i as Qt,a as zt}from"./antigravity-responsibility-constants-Bvh4Ybz0.js";import{C as Ce}from"./checkbox-CC0rU-9-.js";import{C as Jt}from"./confirm-dialog-Bee0kh6i.js";import{S as Ze}from"./separator-CAoIlNuN.js";import{S as Wt}from"./searchable-select-CF22qEzz.js";import{S as Fs}from"./switch-BeqpDfK5.js";import{P as Xt}from"./proxy-status-widget-C8cOlsqE.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-CwEJfEUX.js";const je={agy:{provider:"agy",displayName:"Antigravity",defaultModel:"claude-opus-4-6-thinking",models:[{id:"claude-opus-4-6-thinking",name:"Claude Opus 4.6 Thinking",description:"Latest flagship, extended thinking",extendedContext:!1,presetMapping:{default:"claude-opus-4-6-thinking",opus:"claude-opus-4-6-thinking",sonnet:"claude-sonnet-4-6",haiku:"claude-sonnet-4-6"}},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",description:"Latest Sonnet with thinking budget support",presetMapping:{default:"claude-sonnet-4-6",opus:"claude-opus-4-6-thinking",sonnet:"claude-sonnet-4-6",haiku:"claude-sonnet-4-6"}},{id:"gemini-3-pro-preview",name:"Gemini 3 Pro",description:"Google latest model via Antigravity",extendedContext:!0,presetMapping:{default:"gemini-3-pro-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini 3 Flash",description:"Fast Gemini model via Antigravity",extendedContext:!0,presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}}]},gemini:{provider:"gemini",displayName:"Gemini",defaultModel:"gemini-2.5-pro",models:[{id:"gemini-3-pro-preview",name:"Gemini 3 Pro",tier:"paid",description:"Latest model, requires paid Google account",extendedContext:!0,presetMapping:{default:"gemini-3-pro-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini 3 Flash",tier:"paid",description:"Fast Gemini 3 model, requires paid Google account",extendedContext:!0,presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",description:"Stable, works with free Google account",extendedContext:!0,presetMapping:{default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-2.5-flash"}}]},codex:{provider:"codex",displayName:"Codex",defaultModel:"gpt-5-codex",models:[{id:"gpt-5-codex",name:"GPT-5 Codex",description:"Cross-plan safe Codex default",presetMapping:{default:"gpt-5-codex",opus:"gpt-5-codex",sonnet:"gpt-5-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5-codex-mini",name:"GPT-5 Codex Mini",description:"Faster and cheaper Codex option",presetMapping:{default:"gpt-5-codex-mini",opus:"gpt-5-codex",sonnet:"gpt-5-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"Legacy mini model ID kept for backwards compatibility",presetMapping:{default:"gpt-5-mini",opus:"gpt-5-codex",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"}},{id:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex Mini",description:"Legacy fast Codex mini model",presetMapping:{default:"gpt-5.1-codex-mini",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini"}},{id:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",description:"Higher-effort Codex model with xhigh support",presetMapping:{default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini"}},{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",description:"Cross-plan Codex model with xhigh support",presetMapping:{default:"gpt-5.2-codex",opus:"gpt-5.2-codex",sonnet:"gpt-5.2-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",tier:"paid",description:"Paid Codex plans only",presetMapping:{default:"gpt-5.3-codex",opus:"gpt-5.3-codex",sonnet:"gpt-5.3-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",tier:"paid",description:"Paid Codex plans only, ultra-fast coding model",presetMapping:{default:"gpt-5.3-codex-spark",opus:"gpt-5.3-codex",sonnet:"gpt-5.3-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.4",name:"GPT-5.4",tier:"paid",description:"Paid Codex plans only, latest GPT-5 family model",presetMapping:{default:"gpt-5.4",opus:"gpt-5.4",sonnet:"gpt-5.4",haiku:"gpt-5-codex-mini"}}]},qwen:{provider:"qwen",displayName:"Qwen",defaultModel:"qwen3-coder-plus",models:[{id:"qwen3-coder-plus",name:"Qwen3 Coder Plus",description:"Code-focused model (1M context)",presetMapping:{default:"qwen3-coder-plus",opus:"qwen3-max",sonnet:"qwen3-coder-plus",haiku:"qwen3-coder-flash"}},{id:"qwen3-max",name:"Qwen3 Max",description:"Flagship model (256K context)",presetMapping:{default:"qwen3-max",opus:"qwen3-max",sonnet:"qwen3-coder-plus",haiku:"qwen3-coder-flash"}},{id:"qwen3-max-preview",name:"Qwen3 Max Preview",description:"Preview with thinking support (256K)",presetMapping:{default:"qwen3-max-preview",opus:"qwen3-max-preview",sonnet:"qwen3-max",haiku:"qwen3-coder-flash"}},{id:"qwen3-235b",name:"Qwen3 235B",description:"Large 235B A22B model",presetMapping:{default:"qwen3-235b",opus:"qwen3-max",sonnet:"qwen3-235b",haiku:"qwen3-coder-flash"}},{id:"qwen3-vl-plus",name:"Qwen3 VL Plus",description:"Vision-language multimodal"},{id:"qwen3-coder-flash",name:"Qwen3 Coder Flash",description:"Fast code generation"},{id:"qwen3-32b",name:"Qwen3 32B",description:"Qwen3 32B model"}]},iflow:{provider:"iflow",displayName:"iFlow",defaultModel:"qwen3-coder-plus",models:[{id:"qwen3-coder-plus",name:"Qwen3 Coder Plus",description:"Recommended default for iFlow accounts",presetMapping:{default:"qwen3-coder-plus",opus:"qwen3-coder-plus",sonnet:"qwen3-coder-plus",haiku:"qwen3-coder-plus"}},{id:"qwen3-max",name:"Qwen3 Max",description:"Flagship Qwen model via iFlow"},{id:"kimi-k2",name:"Kimi K2",description:"Kimi model currently available via iFlow"},{id:"deepseek-v3.2",name:"DeepSeek V3.2",description:"Current DeepSeek V3.2 model via iFlow"},{id:"deepseek-r1",name:"DeepSeek R1",description:"Reasoning-focused DeepSeek model"},{id:"glm-4.6",name:"GLM 4.6",description:"Zhipu GLM 4.6 via iFlow"},{id:"qwen3-vl-plus",name:"Qwen3 VL Plus",description:"Vision-language model"}]},kimi:{provider:"kimi",displayName:"Kimi (Moonshot)",defaultModel:"kimi-k2.5",models:[{id:"kimi-k2.5",name:"Kimi K2.5",description:"Latest multimodal model (262K context)",presetMapping:{default:"kimi-k2.5",opus:"kimi-k2.5",sonnet:"kimi-k2-thinking",haiku:"kimi-k2"}},{id:"kimi-k2-thinking",name:"Kimi K2 Thinking",description:"Extended reasoning model",presetMapping:{default:"kimi-k2-thinking",opus:"kimi-k2.5",sonnet:"kimi-k2-thinking",haiku:"kimi-k2"}},{id:"kimi-k2",name:"Kimi K2",description:"Flagship coding model"}]},kiro:{provider:"kiro",displayName:"Kiro (AWS)",defaultModel:"kiro-claude-sonnet-4-5",models:[{id:"kiro-claude-opus-4-5",name:"Kiro Claude Opus 4.5",description:"Claude Opus 4.5 via Kiro (2.2x credit)",presetMapping:{default:"kiro-claude-opus-4-5",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4-5",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4-5",name:"Kiro Claude Sonnet 4.5",description:"Claude Sonnet 4.5 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4-5",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4-5",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4",name:"Kiro Claude Sonnet 4",description:"Claude Sonnet 4 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-haiku-4-5",name:"Kiro Claude Haiku 4.5",description:"Claude Haiku 4.5 via Kiro (0.4x credit)"}]},ghcp:{provider:"ghcp",displayName:"GitHub Copilot (OAuth)",defaultModel:"claude-sonnet-4.5",models:[{id:"claude-opus-4.5",name:"Claude Opus 4.5",description:"Anthropic Claude Opus 4.5 via GitHub Copilot",presetMapping:{default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"}},{id:"claude-sonnet-4.5",name:"Claude Sonnet 4.5",description:"Anthropic Claude Sonnet 4.5 via GitHub Copilot",presetMapping:{default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"}},{id:"claude-sonnet-4",name:"Claude Sonnet 4",description:"Anthropic Claude Sonnet 4 via GitHub Copilot"},{id:"claude-haiku-4.5",name:"Claude Haiku 4.5",description:"Anthropic Claude Haiku 4.5 via GitHub Copilot"},{id:"gpt-5.2",name:"GPT-5.2",description:"OpenAI GPT-5.2 via GitHub Copilot",presetMapping:{default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"}},{id:"gpt-5.1",name:"GPT-5.1",description:"OpenAI GPT-5.1 via GitHub Copilot"},{id:"gpt-5",name:"GPT-5",description:"OpenAI GPT-5 via GitHub Copilot"},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"OpenAI GPT-5 Mini via GitHub Copilot"},{id:"gemini-3-pro",name:"Gemini 3 Pro",description:"Google Gemini 3 Pro via GitHub Copilot"}]},claude:{provider:"claude",displayName:"Claude (Anthropic)",defaultModel:"claude-sonnet-4-6",models:[{id:"claude-opus-4-6",name:"Claude Opus 4.6",description:"Latest flagship model",extendedContext:!0,presetMapping:{default:"claude-opus-4-6",opus:"claude-opus-4-6",sonnet:"claude-sonnet-4-6",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",description:"Balanced performance and speed",extendedContext:!0,presetMapping:{default:"claude-sonnet-4-6",opus:"claude-opus-4-6",sonnet:"claude-sonnet-4-6",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-opus-4-5-20251101",name:"Claude Opus 4.5",description:"Most capable Claude model",extendedContext:!0,presetMapping:{default:"claude-opus-4-5-20251101",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-5-20250929",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-sonnet-4-5-20250929",name:"Claude Sonnet 4.5",description:"Balanced performance and speed",extendedContext:!0,presetMapping:{default:"claude-sonnet-4-5-20250929",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-5-20250929",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-sonnet-4-20250514",name:"Claude Sonnet 4",description:"Previous generation Sonnet",extendedContext:!0,presetMapping:{default:"claude-sonnet-4-20250514",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-20250514",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-haiku-4-5-20251001",name:"Claude Haiku 4.5",description:"Fast and efficient"}]}},Re="ccs-internal-managed";async function Yt(){try{const s=await fetch("/api/settings/auth/tokens/raw");return s.ok?(await s.json())?.apiKey?.value??Re:Re}catch{return Re}}async function qe(s,t){const a=je[s];if(!a)return{success:!1};const i=a.models.find(l=>l.id===a.defaultModel)||a.models[0],r=i?.presetMapping||{default:a.defaultModel,opus:a.defaultModel,sonnet:a.defaultModel,haiku:a.defaultModel},p=await Yt(),c={env:{ANTHROPIC_BASE_URL:`http://127.0.0.1:${He}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:p,ANTHROPIC_MODEL:r.default,ANTHROPIC_DEFAULT_OPUS_MODEL:r.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:r.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:r.haiku}};try{return{success:(await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:c})})).ok,presetName:i?.name||a.defaultModel}}catch{return{success:!1}}}function Zt({currentProgress:s,allSteps:t}){return e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:t.map((a,i)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${s>=i?"bg-primary":"bg-muted"}`},a))})}function ea({providers:s,onSelect:t}){return e.jsx("div",{className:"grid gap-2",children:s.map(a=>e.jsxs("button",{onClick:()=>t(a.id),className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:a.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:a.description})]}),e.jsx(Ms,{className:"w-4 h-4 text-muted-foreground"})]},a.id))})}function sa({selectedProvider:s,providers:t,authCommand:a,isRefreshing:i,isPending:r,onBack:p,onStartAuth:x,onRefresh:c}){const[l,u]=o.useState(!1),g=async f=>{await navigator.clipboard.writeText(f),u(!0),setTimeout(()=>u(!1),2e3)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Authenticate with ",t.find(f=>f.id===s)?.name," to add an account"]}),e.jsx(L,{onClick:x,disabled:r,className:"w-full gap-2",size:"lg",children:r?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"w-4 h-4 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(me,{className:"w-4 h-4"}),"Authenticate in Browser"]})}),r&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Complete the OAuth flow in your browser..."})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Or use terminal"})})]}),e.jsx(fs,{children:e.jsxs(js,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Rt,{className:"w-4 h-4"}),"Run this command in your terminal:"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 px-3 py-2 bg-muted rounded-md font-mono text-sm",children:a}),e.jsx(L,{variant:"outline",size:"icon",onClick:()=>g(a),children:l?e.jsx(ce,{className:"w-4 h-4 text-green-500"}):e.jsx(Ts,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(L,{variant:"ghost",onClick:p,disabled:r,children:[e.jsx(We,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs(L,{variant:"outline",onClick:c,disabled:i||r,children:[e.jsx(Xe,{className:`w-4 h-4 mr-2 ${i?"animate-spin":""}`}),i?"Checking...":"Refresh Status"]})]})]})}function ta({accounts:s,privacyMode:t,onSelect:a,onAddNew:i,onBack:r}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:["Select an account (",s.length,")"]}),e.jsx("div",{className:"grid gap-2 max-h-[320px] overflow-y-auto pr-1",children:s.map(p=>e.jsxs("button",{type:"button",onClick:()=>a(p),className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center",children:e.jsx(xe,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:V("font-medium",t&&Ae),children:p.email||p.id}),p.isDefault&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Default account"})]})]}),e.jsx(Ms,{className:"w-4 h-4 text-muted-foreground"})]},p.id))}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Or"})})]}),e.jsxs("button",{type:"button",className:"w-full flex items-center gap-3 p-3 border-2 border-dashed border-primary/50 rounded-lg hover:border-primary hover:bg-primary/5 transition-colors text-left",onClick:i,children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(me,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-primary",children:"Add new account"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Authenticate with a different account"})]})]}),e.jsx("div",{className:"flex items-center justify-between pt-2",children:e.jsxs(L,{variant:"ghost",onClick:r,children:[e.jsx(We,{className:"w-4 h-4 mr-2"}),"Back"]})})]})}const us="__custom__";function aa({selectedProvider:s,selectedAccount:t,variantName:a,modelName:i,isPending:r,privacyMode:p,onVariantNameChange:x,onModelChange:c,onBack:l,onSkip:u,onCreate:g}){const{t:f}=Z(),h=je[s]?.models||[],y=i&&!h.some(n=>n.id===i),[P,w]=o.useState(y),C=s==="agy"&&i.trim().length>0?se(i):!1,D=n=>{n===us?(w(!0),c("")):(w(!1),c(n))};return e.jsxs("div",{className:"space-y-4",children:[t&&e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx(xe,{className:"w-4 h-4"}),e.jsxs("span",{children:[f("setupVariant.using")," ",e.jsx("span",{className:V(p&&Ae),children:t.email||t.id})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"variant-name",children:f("setupVariant.variantNameRequired")}),e.jsx(le,{id:"variant-name",value:a,onChange:n=>x(n.target.value),placeholder:f("setupVariant.variantNamePlaceholder")}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[f("setupVariant.invokeHintPrefix")," ccs ",a||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{children:f("setupVariant.model")}),P?e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{value:i,onChange:n=>c(n.target.value),placeholder:f("setupVariant.modelPlaceholder")}),C&&e.jsx("p",{className:"text-xs text-destructive",children:"Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated."}),e.jsx("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:()=>{w(!1),s==="agy"&&se(i)&&c("")},children:f("setupVariant.choosePresetInstead")})]}):e.jsxs(vs,{value:h.some(n=>n.id===i)?i:"",onValueChange:D,children:[e.jsx(Ns,{children:e.jsx(ys,{placeholder:f("setupVariant.selectModel")})}),e.jsxs(bs,{children:[h.map(n=>e.jsx(Ie,{value:n.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:n.name}),n.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",n.description]})]})},n.id)),e.jsx(Ie,{value:us,children:e.jsx("span",{className:"text-primary",children:f("setupVariant.customModelName")})})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:P?f("setupVariant.enterAnyModel"):f("setupVariant.defaultModel",{model:je[s]?.defaultModel||f("setupVariant.providerDefault")})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(L,{variant:"ghost",onClick:l,children:[e.jsx(We,{className:"w-4 h-4 mr-2"}),f("setupVariant.back")]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(L,{variant:"ghost",onClick:u,children:f("setupVariant.skip")}),e.jsx(L,{onClick:g,disabled:!a||r||C,children:f(r?"setupVariant.creating":"setupVariant.createVariant")})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:f("setupVariant.skipHint")})]})}function na({variantName:s,onClose:t}){return e.jsxs("div",{className:"space-y-4 text-center",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"w-16 h-16 bg-green-100 dark:bg-green-900/30 rounded-full flex items-center justify-center",children:e.jsx(ce,{className:"w-8 h-8 text-green-600 dark:text-green-400"})})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-lg",children:"Variant Created!"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Your custom variant is ready to use"})]}),e.jsx(fs,{children:e.jsxs(js,{className:"p-4 space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Usage:"}),e.jsxs("code",{className:"block px-3 py-2 bg-muted rounded-md font-mono text-sm",children:["ccs ",s,' "your prompt here"']})]})}),e.jsx(L,{onClick:t,className:"w-full",children:"Done"})]})}function ia({open:s,onClose:t}){const[a,i]=o.useState("provider"),[r,p]=o.useState(""),[x,c]=o.useState(null),[l,u]=o.useState(""),[g,f]=o.useState(""),[h,y]=o.useState(!1),[P,w]=o.useState(!1),{data:C,refetch:D}=ws(),n=Qs(),b=zs(),v=Js(),{privacyMode:F}=ks(),O=C?.authStatus.find(E=>E.provider===r),m=o.useMemo(()=>O?.accounts||[],[O?.accounts]);o.useEffect(()=>{if(!s){const E=setTimeout(()=>{i("provider"),p(""),c(null),u(""),f(""),w(!1)},0);return()=>clearTimeout(E)}},[s]),o.useEffect(()=>{if(a==="auth"&&m.length>0&&!P){const E=setTimeout(()=>{i("account")},0);return()=>clearTimeout(E)}},[a,m,P]);const S=async()=>{y(!0),await D(),y(!1)},N=()=>{const E=(O?.accounts?.length||0)===0;b.mutate({provider:r},{onSuccess:async R=>{if(E){const H=await qe(r);H.success&&H.presetName?K.success(`Applied "${H.presetName}" preset`):H.success||K.warning(As.t("commonToast.accountAddedPresetFailed"))}R.account&&(c(R.account),i("variant")),D()}})},k=E=>{p(E),(C?.authStatus.find(G=>G.provider===E)?.accounts||[]).length===0?i("auth"):i("account")},M=E=>{c(E),i("variant")},j=async()=>{if(!(!l||!r))try{await n.mutateAsync({name:l,provider:r,model:g||void 0,account:x?.id}),i("success")}catch(E){console.error("Failed to create variant:",E)}},A=`ccs ${r} --auth --add`,q=Xs(a),U=E=>{if(!E&&(b.isPending&&r&&v.mutate(r),a==="success"||a==="provider")){t();return}};return e.jsx(Ve,{open:s,onOpenChange:U,children:e.jsxs(Ge,{className:"sm:max-w-lg",onPointerDownOutside:E=>{a!=="success"&&a!=="provider"&&E.preventDefault()},onEscapeKeyDown:E=>{(b.isPending||n.isPending)&&E.preventDefault()},children:[e.jsxs($e,{children:[e.jsxs(Qe,{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"w-5 h-5 text-primary"}),"Quick Setup Wizard"]}),e.jsxs(Cs,{children:[a==="provider"&&"Select a provider to get started",a==="auth"&&"Authenticate with your provider",a==="account"&&"Select which account to use",a==="variant"&&"Create your custom variant",a==="success"&&"Setup complete!"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[a==="provider"&&e.jsx(ea,{providers:as,onSelect:k}),a==="auth"&&e.jsx(sa,{selectedProvider:r,providers:as,authCommand:A,isRefreshing:h,isPending:b.isPending,onBack:()=>i("provider"),onStartAuth:N,onRefresh:S}),a==="account"&&e.jsx(ta,{accounts:m,privacyMode:F,onSelect:M,onAddNew:()=>{w(!0),i("auth")},onBack:()=>i("provider")}),a==="variant"&&e.jsx(aa,{selectedProvider:r,selectedAccount:x,variantName:l,modelName:g,isPending:n.isPending,privacyMode:F,onVariantNameChange:u,onModelChange:f,onBack:()=>m.length>0?i("account"):i("provider"),onSkip:t,onCreate:j}),a==="success"&&e.jsx(na,{variantName:l,onClose:t})]}),e.jsx(Zt,{currentProgress:q,allSteps:Ws})]})})}const ra=3e3,oa=300*1e3,la=3;async function Le(s){const t=await s.text();if(!t)return{};try{return JSON.parse(t)}catch{const a=s.status>=400?`Request failed with status ${s.status}`:void 0;return a?{error:a}:{}}}const oe={provider:null,isAuthenticating:!1,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:!1};function ca(){const[s,t]=o.useState(oe),a=o.useRef(0),i=o.useRef(null),r=o.useRef(null),p=o.useRef(0),x=o.useRef(0),c=o.useRef(!1),l=Be(),u=o.useCallback(w=>w===a.current,[]),g=o.useCallback(()=>{r.current&&(clearInterval(r.current),r.current=null),x.current=0},[]);o.useEffect(()=>()=>{i.current?.abort(),g(),c.current=!1},[g]);const f=o.useCallback(async(w,C,D)=>{if(u(D)){if(Date.now()-p.current>oa){g(),u(D)&&t(n=>({...n,isAuthenticating:!1,error:"Authentication timed out. Please try again."}));return}try{const n=await fetch(`/api/cliproxy/auth/${w}/status?state=${encodeURIComponent(C)}`);if(!u(D))return;const b=await n.json();if(x.current=0,b.status==="ok")g(),l.invalidateQueries({queryKey:["cliproxy-auth"]}),l.invalidateQueries({queryKey:["account-quota"]}),K.success(`${w} authentication successful`),c.current=!1,t(oe);else if(b.status==="auth_url"){const v=b.url||b.auth_url;v&&(t(F=>({...F,authUrl:v})),c.current||(c.current=!0,window.open(v,"_blank")))}else if(b.status==="device_code"){g();const v=b.user_code&&b.verification_url?`Open ${b.verification_url} and enter code: ${b.user_code}`:"Switch to Device Code method and try again.";K.error("Provider returned Device Code flow in callback mode"),t(F=>({...F,isAuthenticating:!1,error:v}))}else if(b.status==="error"){g();const v=b.error||"Authentication failed";K.error(v),t(F=>({...F,isAuthenticating:!1,error:v}))}}catch(n){if(!u(D)||(x.current+=1,x.current<la))return;g();const b=n instanceof Error&&n.message.trim().length>0?n.message:"Lost contact with the auth status endpoint";K.error(b),t(v=>({...v,isAuthenticating:!1,error:b}))}}},[u,l,g]),h=o.useCallback(async(w,C)=>{if(!Fe(w)){t({...oe,error:`Unknown provider: ${w}`});return}i.current?.abort(),g(),c.current=!1,x.current=0;const D=new AbortController,n=a.current+1;a.current=n,i.current=D;const v=(C?.flowType||(Ss(w)?"device_code":"authorization_code"))==="device_code",F=C?.startEndpoint||(v?"start":"start-url"),O={nickname:C?.nickname,kiroMethod:C?.kiroMethod,riskAcknowledgement:C?.riskAcknowledgement};t({provider:w,isAuthenticating:!0,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:v});try{if(F==="start")fetch(`/api/cliproxy/auth/${w}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(O),signal:D.signal}).then(async m=>{if(!u(n))return;const S=await Le(m);if(!u(n))return;const N=S.success===!0;if(m.ok&&N)l.invalidateQueries({queryKey:["cliproxy-auth"]}),l.invalidateQueries({queryKey:["account-quota"]}),c.current=!1,t(oe);else{const k=typeof S.error=="string"?S.error:"Authentication failed";K.error(k),t(M=>({...M,isAuthenticating:!1,error:k}))}}).catch(m=>{if(!u(n)||m instanceof Error&&m.name==="AbortError")return;const S=m instanceof Error?m.message:"Authentication failed";K.error(S),t(N=>({...N,isAuthenticating:!1,error:S}))});else{const m=await fetch(`/api/cliproxy/auth/${w}/start-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(O),signal:D.signal});if(!u(n))return;const S=await Le(m);if(!u(n))return;const N=S.success===!0;if(!m.ok||!N){const j=typeof S.error=="string"?S.error:"Failed to start OAuth";throw new Error(j)}const k=typeof S.authUrl=="string"?S.authUrl:null,M=typeof S.state=="string"?S.state:null;t(j=>({...j,authUrl:k,oauthState:M})),k&&(c.current=!0,window.open(k,"_blank")),M&&(p.current=Date.now(),r.current=setInterval(()=>{f(w,M,n)},ra))}}catch(m){if(!u(n))return;if(m instanceof Error&&m.name==="AbortError"){c.current=!1,t(oe);return}const S=m instanceof Error?m.message:"Authentication failed";K.error(S),t(N=>({...N,isAuthenticating:!1,error:S}))}},[u,f,g,l]),y=o.useCallback(()=>{const w=s.provider;a.current+=1,i.current?.abort(),g(),c.current=!1,t(oe),w&&we.cliproxy.auth.cancel(w).catch(()=>{})},[s.provider,g]),P=o.useCallback(async w=>{if(!s.provider)return;const C=a.current,D=s.provider;t(n=>({...n,isSubmittingCallback:!0,error:null}));try{const n=await fetch(`/api/cliproxy/auth/${D}/submit-callback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({redirectUrl:w})});if(!u(C))return;const b=await Le(n);if(!u(C))return;const v=b.success===!0,F=typeof b.account=="object"&&b.account!==null;if(n.ok&&v&&F)g(),l.invalidateQueries({queryKey:["cliproxy-auth"]}),l.invalidateQueries({queryKey:["account-quota"]}),K.success(`${D} authentication successful`),t(oe);else{const O=typeof b.error=="string"?b.error:v?"Authenticated account could not be registered":"Callback submission failed";throw new Error(O)}}catch(n){if(!u(C))return;const b=n instanceof Error?n.message:"Failed to submit callback";K.error(b),t(v=>({...v,isSubmittingCallback:!1,error:b}))}},[u,s.provider,l,g]);return o.useMemo(()=>({...s,startAuth:h,cancelAuth:y,submitCallback:P}),[s,h,y,P])}function Us({className:s,showAcknowledgement:t=!1,acknowledgementPhrase:a=ke,acknowledgementText:i="",onAcknowledgementTextChange:r,disabled:p=!1,showProxySettingsLink:x=!1}){const{t:c}=Z(),l=c("accountSafetyWarning.title"),u=c("accountSafetyWarning.subtitle"),g=c("accountSafetyWarning.firstLine"),f=c("accountSafetyWarning.secondLine"),h="https://github.com/kaitranntt/ccs/issues/509",y=c("accountSafetyWarning.issueLabel"),P=c("accountSafetyWarning.proxySettingsLabel");return e.jsxs("section",{role:"alert",className:V("relative overflow-hidden rounded-xl border border-amber-500/30 bg-gradient-to-br from-amber-50 via-background to-rose-50/70 shadow-sm dark:from-amber-950/20 dark:to-rose-950/20",s),children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-0.5 bg-gradient-to-r from-amber-500 via-orange-500 to-rose-500"}),e.jsxs("div",{className:"space-y-3 p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx("div",{className:"mt-0.5 inline-flex h-7 w-7 items-center justify-center rounded-md bg-amber-500/15 text-amber-700 dark:text-amber-400",children:e.jsx(Se,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:l}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u})]})]}),e.jsx(B,{variant:"outline",className:"border-amber-500/40 text-amber-700 dark:text-amber-300",children:"High Risk"})]}),e.jsxs("div",{className:"space-y-2 text-sm leading-relaxed",children:[e.jsx("p",{children:g}),e.jsx("p",{className:"font-medium text-amber-900 dark:text-amber-200",children:f}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"CCS is provided as-is and does not take responsibility for suspension, bans, or access loss from upstream providers."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("a",{href:h,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 rounded-md border border-amber-500/30 bg-amber-500/10 px-2.5 py-1 text-xs font-medium text-amber-800 transition-colors hover:bg-amber-500/15 dark:text-amber-200",children:[y,e.jsx(me,{className:"h-3.5 w-3.5"})]}),x&&e.jsxs("a",{href:"/settings?tab=proxy",className:"inline-flex items-center gap-1.5 rounded-md border border-amber-500/30 bg-amber-500/10 px-2.5 py-1 text-xs font-medium text-amber-800 transition-colors hover:bg-amber-500/15 dark:text-amber-200",children:[e.jsx(Lt,{className:"h-3.5 w-3.5"}),P]}),e.jsx("span",{className:"rounded-md border border-border/70 bg-muted/60 px-2.5 py-1 text-xs text-muted-foreground",children:"Applies to CLI and dashboard auth"})]}),t&&r&&e.jsxs("div",{className:"rounded-lg border border-amber-500/25 bg-amber-500/5 p-2.5",children:[e.jsxs(Y,{htmlFor:"account-risk-ack-text",className:"text-xs leading-5",children:["Type exact phrase to continue:"," ",e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono",children:a})]}),e.jsx(le,{id:"account-risk-ack-text",value:i,onChange:w=>r(w.target.value),placeholder:a,disabled:p,className:"mt-2 font-mono text-xs"})]})]})]})}function da({className:s,value:t,onChange:a,disabled:i=!1}){const{t:r}=Z(),p=[t.reviewedIssue509,t.understandsBanRisk,t.acceptsFullResponsibility,t.typedPhrase.trim().replace(/\s+/g," ").toUpperCase()===ds].filter(Boolean).length,x=p/4*100,c=l=>{a({...t,...l})};return e.jsxs("section",{role:"alert",className:V("relative overflow-hidden rounded-xl border border-rose-500/35 bg-gradient-to-br from-rose-50 via-background to-amber-50/70 p-4 shadow-sm dark:from-rose-950/20 dark:to-amber-950/20",s),children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-0.5 bg-gradient-to-r from-rose-500 via-orange-500 to-amber-500"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx("div",{className:"mt-0.5 inline-flex h-7 w-7 items-center justify-center rounded-md bg-rose-500/15 text-rose-700 dark:text-rose-300",children:e.jsx(Se,{className:"h-4 w-4"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:r("antigravityChecklist.title")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r("antigravityChecklist.subtitle")})]})]}),e.jsx(B,{variant:"outline",className:"border-rose-500/40 text-rose-700 dark:text-rose-300",children:r("antigravityChecklist.mandatory")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:r("antigravityChecklist.completion")}),e.jsx("span",{children:r("antigravityChecklist.stepsCount",{current:p})})]}),e.jsx(Ue,{value:x,className:"h-2"})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border border-rose-500/20 bg-rose-500/5 p-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ce,{id:"agy-step-reviewed-issue",checked:t.reviewedIssue509,onCheckedChange:l=>c({reviewedIssue509:!!l}),disabled:i}),e.jsx(Y,{htmlFor:"agy-step-reviewed-issue",className:"text-xs leading-5",children:"Step 1: I reviewed issue #509 and understand AGY OAuth can trigger account bans/suspensions."})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ce,{id:"agy-step-understands-risk",checked:t.understandsBanRisk,onCheckedChange:l=>c({understandsBanRisk:!!l}),disabled:i}),e.jsx(Y,{htmlFor:"agy-step-understands-risk",className:"text-xs leading-5",children:"Step 2: I understand this OAuth action is my own decision and I accept the upstream risk."})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ce,{id:"agy-step-accept-responsibility",checked:t.acceptsFullResponsibility,onCheckedChange:l=>c({acceptsFullResponsibility:!!l}),disabled:i}),e.jsx(Y,{htmlFor:"agy-step-accept-responsibility",className:"text-xs leading-5",children:"Step 3: I accept full responsibility. CCS is not liable for suspension, bans, or access loss."})]})]}),e.jsxs("div",{className:"space-y-2 rounded-lg border border-amber-500/25 bg-amber-500/5 p-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-amber-800 dark:text-amber-200",children:[e.jsx(Ds,{className:"h-3.5 w-3.5"}),"Step 4: Type exact phrase to continue"]}),e.jsx(le,{value:t.typedPhrase,onChange:l=>c({typedPhrase:l.target.value}),placeholder:ds,disabled:i,className:"font-mono text-xs"})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:e.jsxs("a",{href:"https://github.com/kaitranntt/ccs/issues/509",target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 rounded-md border border-rose-500/30 bg-rose-500/10 px-2.5 py-1 font-medium text-rose-800 transition-colors hover:bg-rose-500/15 dark:text-rose-200",children:["Read issue #509",e.jsx(me,{className:"h-3.5 w-3.5"})]})})]})]})}function ua(s){return s.trim().replace(/\s+/g," ").toUpperCase()}function ma({open:s,onClose:t,provider:a,displayName:i,isFirstAccount:r=!1}){const[p,x]=o.useState(""),[c,l]=o.useState(""),[u,g]=o.useState(!1),[f,h]=o.useState(null),[y,P]=o.useState(""),[w,C]=o.useState(_e),[D,n]=o.useState(!1),[b,v]=o.useState(!1),[F,O]=o.useState(ns),{t:m}=Z(),S=o.useRef(!1),N=ca(),k=Ys(),M=a==="kiro",j=a==="gemini",A=a==="agy"&&!D,q=a==="agy"&&b,U=Qt(w),E=ua(y)===ke,R=Ss(a),H=Zs(F),G=M?H.flowType==="device_code":R,$=N.isAuthenticating||k.isPending,ae=p.trim(),ee=f||N.error,W=o.useCallback(async()=>{const T=await fetch("/api/settings/auth/antigravity-risk");if(!T.ok)throw new Error("Failed to load Antigravity power user setting");return(await T.json()).antigravityAckBypass===!0},[]),d=()=>{x(""),l(""),g(!1),h(null),P(""),C(_e),n(!1),v(!1),O(ns),S.current=!1,t()};o.useEffect(()=>{s&&(P(""),C(_e),h(null))},[a,s]),o.useEffect(()=>{let T=!1;if(!s||a!=="agy"){n(!1),v(!1);return}return(async()=>{try{v(!0);const ne=await W();T||n(ne)}catch{T||n(!1)}finally{T||v(!1)}})(),()=>{T=!0}},[W,s,a]),o.useEffect(()=>{if(!s||a!=="agy"||!N.error||!D)return;const T=N.error.toLowerCase();if(!(T.includes("agy_risk_ack_required")||T.includes("responsibility acknowledgement")||T.includes("responsibility checklist")))return;let ne=!1;return(async()=>{try{v(!0);const ye=await W();if(ne)return;n(ye),ye||h("Power user mode is off. Complete the AGY checklist and retry.")}catch{if(ne)return;n(!1),h("Power user mode is off. Complete the AGY checklist and retry.")}finally{ne||v(!1)}})(),()=>{ne=!0}},[D,N.error,W,s,a]),o.useEffect(()=>{!N.isAuthenticating&&!N.error&&N.provider===null&&s&&S.current&&(S.current=!1,(async()=>{try{const te=await qe(a);te.success&&te.presetName&&r&&K.success(`Applied "${te.presetName}" preset`)}catch{}d()})())},[N.isAuthenticating,N.error,N.provider]);const _=()=>{N.cancelAuth(),d()},z=async()=>{N.authUrl&&(await navigator.clipboard.writeText(N.authUrl),g(!0),setTimeout(()=>g(!1),2e3))},de=()=>{c.trim()&&N.submitCallback(c.trim())},Me=()=>{if(q){h("Loading Antigravity safety settings. Please wait a moment and retry.");return}if(A&&!U){h("Complete all Antigravity responsibility steps before authenticating this provider.");return}if(j&&!E){h(`Type "${ke}" to acknowledge the account safety warning before authenticating this provider.`);return}h(null),S.current=!0,N.startAuth(a,{nickname:ae||void 0,kiroMethod:M?F:void 0,flowType:M?H.flowType:void 0,startEndpoint:M?H.startEndpoint:void 0,riskAcknowledgement:A?{version:zt,reviewedIssue509:w.reviewedIssue509,understandsBanRisk:w.understandsBanRisk,acceptsFullResponsibility:w.acceptsFullResponsibility,typedPhrase:w.typedPhrase}:void 0})},Te=()=>{S.current=!0,k.mutate(void 0,{onSuccess:async()=>{const T=await qe("kiro");T.success&&T.presetName&&r&&K.success(`Applied "${T.presetName}" preset`),d()}})},De=T=>{T||_()},X=N.isAuthenticating;return e.jsx(Ve,{open:s,onOpenChange:De,children:e.jsxs(Ge,{className:"sm:max-w-md",onInteractOutside:T=>{X&&T.preventDefault()},children:[e.jsxs($e,{children:[e.jsx(Qe,{children:m("addAccountDialog.title",{displayName:i})}),e.jsx(Cs,{children:m(M?"addAccountDialog.descKiro":G?"addAccountDialog.descDeviceCode":"addAccountDialog.descOauth")})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[A&&!X&&e.jsx(da,{value:w,onChange:T=>{C(T),h(null)},disabled:$}),a==="agy"&&D&&!X&&e.jsxs("div",{className:"rounded-lg border border-amber-400/35 bg-amber-50/70 p-3 text-xs text-amber-900 dark:border-amber-800/60 dark:bg-amber-950/25 dark:text-amber-100",children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 font-semibold",children:[e.jsx(Ds,{className:"h-3.5 w-3.5"}),m("addAccountDialog.powerUserEnabled")]}),m("addAccountDialog.powerUserSkipped")]}),j&&!X&&e.jsx(Us,{showAcknowledgement:!0,acknowledgementPhrase:ke,acknowledgementText:y,onAcknowledgementTextChange:T=>{P(T),h(null)},disabled:$}),M&&!X&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"kiro-auth-method",children:m("addAccountDialog.authMethod")}),e.jsxs(vs,{value:F,onValueChange:T=>{O(T),h(null)},children:[e.jsx(Ns,{id:"kiro-auth-method",children:e.jsx(ys,{placeholder:m("addAccountDialog.selectKiroAuthMethod")})}),e.jsx(bs,{children:et.map(T=>e.jsx(Ie,{value:T.id,children:T.label},T.id))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:H.description})]}),!X&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"nickname",children:m("addAccountDialog.nicknameOptional")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(le,{id:"nickname",value:p,onChange:T=>{x(T.target.value),h(null)},placeholder:m("addAccountDialog.nicknamePlaceholder"),disabled:$,className:"flex-1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:m("addAccountDialog.nicknameOptionalHint")})]}),X&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx(J,{className:"w-4 h-4 inline mr-2 animate-spin"}),m("addAccountDialog.waitingForAuth")]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:N.isDeviceCodeFlow?m("addAccountDialog.deviceCodeHint"):m("addAccountDialog.browserHint")})]}),N.authUrl&&!N.isDeviceCodeFlow&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{className:"text-xs",children:m("addAccountDialog.openUrlLabel")}),e.jsxs("div",{className:"p-3 bg-muted rounded-md",children:[e.jsx("p",{className:"text-xs text-muted-foreground break-all font-mono line-clamp-3",children:N.authUrl}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(L,{variant:"outline",size:"sm",onClick:z,children:u?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-3 h-3 mr-1"}),m("addAccountDialog.copied")]}):e.jsxs(e.Fragment,{children:[e.jsx(Ts,{className:"w-3 h-3 mr-1"}),m("addAccountDialog.copy")]})}),e.jsxs(L,{variant:"outline",size:"sm",onClick:()=>{if(!N.authUrl)return;const T=window.open(N.authUrl,"_blank");(!T||T.closed||typeof T.closed>"u")&&K.warning(m("addAccountDialog.popupBlocked"),{duration:5e3})},children:[e.jsx(me,{className:"w-3 h-3 mr-1"}),m("addAccountDialog.open")]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"callback-url",className:"text-xs",children:m("addAccountDialog.redirectPasteLabel")}),e.jsx(le,{id:"callback-url",value:c,onChange:T=>l(T.target.value),placeholder:m("addAccountDialog.callbackPlaceholder"),className:"font-mono text-xs"}),e.jsx(L,{variant:"secondary",size:"sm",onClick:de,disabled:!c.trim()||N.isSubmittingCallback,children:N.isSubmittingCallback?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"w-3 h-3 mr-1 animate-spin"}),m("addAccountDialog.submitting")]}):m("addAccountDialog.submitCallback")})]})]}),!N.authUrl&&!N.isDeviceCodeFlow&&e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:m("addAccountDialog.preparingUrl")})]}),ee&&e.jsx("p",{className:"text-xs text-center text-destructive",children:ee}),k.isPending&&e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:[e.jsx(J,{className:"w-4 h-4 inline mr-2 animate-spin"}),m("addAccountDialog.importingToken")]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(L,{variant:"ghost",onClick:_,children:m("addAccountDialog.cancel")}),M&&!X&&e.jsx(L,{variant:"outline",onClick:Te,disabled:$,children:k.isPending?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"w-4 h-4 mr-2 animate-spin"}),m("addAccountDialog.importing")]}):e.jsxs(e.Fragment,{children:[e.jsx(It,{className:"w-4 h-4 mr-2"}),m("addAccountDialog.importFromIde")]})}),!X&&e.jsxs(L,{onClick:Me,disabled:$||q||A&&!U||j&&!E,children:[e.jsx(me,{className:"w-4 h-4 mr-2"}),m("addAccountDialog.authenticate")]})]})]})]})})}const es="[1m]";function xa(s){return s.toLowerCase().startsWith("gemini-")}function ss(s){return s.toLowerCase().endsWith(es.toLowerCase())}function pa(s){return!s||ss(s)?s:`${s}${es}`}function Hs(s){return s&&(ss(s)?s.slice(0,-es.length):s)}const ms=["ANTHROPIC_MODEL"],ha=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function ga(s){const t=s?.env||{};return ha.filter(a=>!t[a]?.trim())}function fa(s){const[t,a]=o.useState(null),[i,r]=o.useState(!1),p=Be(),{data:x,isLoading:c,refetch:l}=gs({queryKey:["settings",s],queryFn:async()=>{const k=await fetch(`/api/settings/${s}/raw`);return k.ok?k.json():{profile:s,settings:{env:{}},mtime:Date.now(),path:`~/.ccs/profiles/${s}/settings.json`}}}),u=x?.settings,g=o.useMemo(()=>t!==null?t:u?JSON.stringify(u,null,2):`{
|
|
2
|
+
"env": {}
|
|
3
|
+
}`,[t,u]),f=o.useCallback(k=>{a(k)},[]),h=o.useMemo(()=>{try{return JSON.parse(g)}catch{return u||{env:{}}}},[g,u]),y=h?.env?.ANTHROPIC_MODEL,P=h?.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,w=h?.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,C=h?.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,D=o.useMemo(()=>{const k=h?.env||{};return ms.some(M=>{const j=k[M];return j&&ss(j)})},[h]),n=o.useCallback((k,M)=>{const j={...h?.env||{},[k]:M},A={...h,env:j};a(JSON.stringify(A,null,2))},[h]),b=o.useCallback(k=>{const M=h?.env||{},j={};for(const U of ms){const E=M[U];E&&(j[U]=k?pa(E):Hs(E))}const A={...M,...j};delete A.CCS_EXTENDED_CONTEXT;const q={...h,env:A};a(JSON.stringify(q,null,2))},[h]),v=o.useCallback(k=>{const M={...h?.env||{},...k},j={...h,env:M};a(JSON.stringify(j,null,2))},[h]),F=o.useMemo(()=>{try{return JSON.parse(g),!0}catch{return!1}},[g]),O=o.useMemo(()=>t===null?!1:t!==JSON.stringify(u,null,2),[t,u]),m=o.useMemo(()=>ga(h),[h]),S=$s({mutationFn:async()=>{const k=JSON.parse(g),M=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:k,expectedMtime:x?.mtime})});if(M.status===409)throw new Error("CONFLICT");if(!M.ok)throw new Error("Failed to save");return M.json()},onSuccess:k=>{p.invalidateQueries({queryKey:["settings",s]}),a(null),k?.warning?K.success("Settings saved",{description:k.warning}):K.success("Settings saved")},onError:k=>{k.message==="CONFLICT"?r(!0):K.error(k.message)}}),N=async k=>{r(!1),k?(await l(),S.mutate()):a(null)};return{data:x,isLoading:c,refetch:l,rawJsonContent:g,rawJsonEdits:t,isRawJsonValid:F,hasChanges:O,currentSettings:h,currentModel:y,opusModel:P,sonnetModel:w,haikuModel:C,extendedContextEnabled:D,toggleExtendedContext:b,handleRawJsonChange:f,updateEnvValue:n,updateEnvValues:v,saveMutation:{mutate:()=>S.mutate(),isPending:S.isPending},conflictDialog:i,setConflictDialog:r,handleConflictResolve:N,missingRequiredFields:m}}const ja=/-(medium|high|xhigh)$/i;function va(s){if(!s)return;const t=s.trim().match(ja);if(t?.[1])return t[1].toLowerCase()}function Na(s){if(!s)return null;const t=va(s);return t?{label:`Pinned ${t}`,explicit:!0}:{label:"Auto effort",explicit:!1}}function ya({label:s}){return e.jsx(B,{variant:"outline",className:"text-[9px] h-4 px-1",children:s})}function be({modelId:s}){const t=Na(s);return t?e.jsx(B,{variant:t.explicit?"secondary":"outline",className:"text-[9px] h-4 px-1 uppercase",children:t.label}):null}function re({label:s,description:t,value:a,onChange:i,catalog:r,allModels:p,disabled:x}){const{t:c}=Z(),l=new Set(r?.models.map(y=>y.id)||[]),u=r?.provider==="codex",g=(r?.models??[]).map(y=>({value:y.id,groupKey:"recommended",searchText:`${y.id} ${y.name}`,keywords:[y.tier??"",r?.provider??""],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:y.id}),u&&e.jsx(be,{modelId:y.id})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:y.id}),y.tier==="paid"&&e.jsx(ya,{label:c("providerModelSelector.paid")}),u&&e.jsx(be,{modelId:y.id})]})})),f=p.filter(y=>!l.has(y.id)).map(y=>({value:y.id,groupKey:"all",searchText:y.id,keywords:[y.owned_by],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:y.id}),u&&e.jsx(be,{modelId:y.id})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:y.id}),u&&e.jsx(be,{modelId:y.id})]})})),h=g.length+f.length>0;return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:s}),t&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:t})]}),e.jsx(Wt,{value:a||void 0,onChange:i,disabled:x,placeholder:c("providerModelSelector.selectModel"),searchPlaceholder:c("searchableSelect.searchModels"),emptyText:c(h?"searchableSelect.noResults":"providerModelSelector.noModelsAvailable"),triggerClassName:"h-9",groups:[{key:"recommended",label:e.jsx("span",{className:"text-xs text-primary",children:c("providerModelSelector.recommended")})},{key:"all",label:e.jsx("span",{className:"text-xs text-muted-foreground",children:c("providerModelSelector.allModelsCount",{count:p.length})})}],options:[...g,...f]})]})}function ba({open:s,onClose:t,currentValues:a,onApply:i,onSave:r,isSaving:p,catalog:x,allModels:c}){const{t:l}=Z(),[u,g]=o.useState(a),[f,h]=o.useState(""),y=P=>{P?(g(a),h("")):t()};return e.jsx(Ve,{open:s,onOpenChange:y,children:e.jsxs(Ge,{className:"sm:max-w-md",children:[e.jsx($e,{children:e.jsxs(Qe,{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"w-4 h-4"}),l("customPresetDialog.title")]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"preset-name",children:l("customPresetDialog.presetNameOptional")}),e.jsx(le,{id:"preset-name",value:f,onChange:P=>h(P.target.value),placeholder:l("customPresetDialog.presetNamePlaceholder"),className:"text-sm"})]}),e.jsx(Ze,{}),x?.provider==="codex"&&e.jsxs("p",{className:"text-[11px] text-muted-foreground rounded-md border bg-muted/30 px-2.5 py-2",children:[l("customPresetDialog.codexTipPrefix")," ",e.jsx("code",{children:"-medium"}),", ",e.jsx("code",{children:"-high"}),", and"," ",e.jsx("code",{children:"-xhigh"})," ",l("customPresetDialog.codexTipSuffix")]}),e.jsx(re,{label:l("customPresetDialog.defaultModel"),description:l("customPresetDialog.defaultModelDesc"),value:u.default,onChange:P=>g({...u,default:P}),catalog:x,allModels:c}),e.jsx(re,{label:l("customPresetDialog.opusModel"),description:l("customPresetDialog.opusModelDesc"),value:u.opus,onChange:P=>g({...u,opus:P}),catalog:x,allModels:c}),e.jsx(re,{label:l("customPresetDialog.sonnetModel"),description:l("customPresetDialog.sonnetModelDesc"),value:u.sonnet,onChange:P=>g({...u,sonnet:P}),catalog:x,allModels:c}),e.jsx(re,{label:l("customPresetDialog.haikuModel"),description:l("customPresetDialog.haikuModelDesc"),value:u.haiku,onChange:P=>g({...u,haiku:P}),catalog:x,allModels:c})]}),e.jsxs(st,{className:"gap-2 sm:gap-0",children:[e.jsx(L,{variant:"outline",onClick:t,children:l("customPresetDialog.cancel")}),r&&e.jsxs(L,{variant:"secondary",onClick:()=>r(u,f||void 0),disabled:p||!f.trim(),children:[p?e.jsx(J,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(Pe,{className:"w-4 h-4 mr-1"}),l("customPresetDialog.savePreset")]}),e.jsxs(L,{onClick:()=>i(u,f||void 0),children:[e.jsx(Ne,{className:"w-4 h-4 mr-1"}),l("customPresetDialog.applyPreset")]})]})]})})}function ue({label:s,command:t}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:s}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:t}),e.jsx(Ps,{value:t,size:"icon",className:"h-6 w-6"})]})]})}function wa({provider:s,displayName:t,defaultTarget:a,data:i,authStatus:r}){const p=a||"claude",x=p==="droid";return e.jsx(ze,{className:"h-full",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[e.jsx(Os,{className:"w-4 h-4"}),"Provider Information"]}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Provider"}),e.jsx("span",{className:"font-mono",children:t})]}),i&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"File Path"}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:i.path}),e.jsx(Ps,{value:i.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Last Modified"}),e.jsx("span",{className:"text-xs",children:new Date(i.mtime).toLocaleString()})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Status"}),r.authenticated?e.jsxs(B,{variant:"outline",className:"w-fit text-green-600 border-green-200 bg-green-50",children:[e.jsx(Ft,{className:"w-3 h-3 mr-1"}),"Authenticated"]}):e.jsx(B,{variant:"outline",className:"w-fit text-muted-foreground",children:"Not connected"})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Default Target"}),e.jsx("span",{className:"font-mono",children:p})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Quick Usage"}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsx(ue,{label:"Run with prompt",command:`ccs ${s} "your prompt"`}),e.jsx(ue,{label:x?"Droid alias (explicit)":"Run on Droid",command:x?`ccsd ${s} "your prompt"`:`ccs ${s} --target droid "your prompt"`}),e.jsx(ue,{label:x?"Override to Claude":"Override target",command:`ccs ${s} --target claude "your prompt"`}),e.jsx(ue,{label:"Change model",command:`ccs ${s} --config`}),e.jsx(ue,{label:"Add account",command:`ccs ${s} --add`}),e.jsx(ue,{label:"List accounts",command:`ccs ${s} --accounts`})]})]})]})})}function ka({displayName:s,logoProvider:t,provider:a,data:i,isLoading:r,hasChanges:p,isRawJsonValid:x,isSaving:c,isRemoteMode:l,port:u,onRefetch:g,onSave:f}){return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Je,{provider:t||a,size:"lg"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s}),l&&e.jsxs(B,{variant:"secondary",className:"text-xs gap-1 bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",children:[e.jsx(Es,{className:"w-3 h-3"}),"Remote"]}),u&&e.jsxs(B,{variant:"outline",className:"text-xs gap-1 font-mono",children:[e.jsx(Ut,{className:"w-3 h-3"}),":",u]}),!l&&i?.path&&e.jsx(B,{variant:"outline",className:"text-xs",children:i.path.replace(/^.*[\\/]/,"")})]}),l?e.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400 mt-0.5",children:"Traffic auto-routed to remote server"}):i&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",new Date(i.mtime).toLocaleString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(L,{variant:"ghost",size:"sm",onClick:g,disabled:r,children:e.jsx(Xe,{className:`w-4 h-4 ${r?"animate-spin":""}`})}),e.jsx(L,{size:"sm",onClick:f,disabled:c||!p||!x,children:c?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ht,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function Ca({model:s,provider:t,enabled:a,onToggle:i,disabled:r,className:p}){if(!s?.extendedContext)return null;const x=xa(s.id);return e.jsxs("div",{className:V("rounded-lg border p-3 space-y-2",a?"border-primary/50 bg-primary/5":"border-border bg-muted/30",p),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ne,{className:V("w-4 h-4",a?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:"text-sm font-medium",children:"Extended Context"}),e.jsx(B,{variant:a?"default":"secondary",className:"text-[10px] h-5 px-1.5",children:"1M tokens"})]}),e.jsx(Fs,{checked:a,onCheckedChange:i,disabled:r})]}),e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground",children:[e.jsx(Os,{className:"w-3.5 h-3.5 mt-0.5 shrink-0"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{children:"Enables 1M token context window instead of default 200K."}),e.jsx("p",{className:"text-[10px]",children:x?e.jsxs("span",{className:"text-primary",children:["Auto-enabled for ",t," Gemini models"]}):e.jsxs("span",{children:["Opt-in for ",t," Claude models via --1m flag"]})}),a&&e.jsx("p",{className:"text-amber-600 dark:text-amber-500",children:"Note: 2x input pricing applies for tokens beyond 200K"})]})]})]})}function Aa(s){const t=s.presetMapping||{default:s.id,opus:s.id,sonnet:s.id,haiku:s.id};return{ANTHROPIC_MODEL:t.default,ANTHROPIC_DEFAULT_OPUS_MODEL:t.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:t.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:t.haiku}}function Sa({catalog:s,savedPresets:t,currentModel:a,opusModel:i,sonnetModel:r,haikuModel:p,providerModels:x,provider:c,extendedContextEnabled:l,onExtendedContextToggle:u,onApplyPreset:g,onUpdateEnvValue:f,onOpenCustomPreset:h,onDeletePreset:y,isDeletePending:P}){const w=o.useMemo(()=>{if(!s||!a)return;const n=Hs(a);return s.models.find(b=>b.id===n)},[s,a]),C=o.useMemo(()=>{const n=(s?.models??[]).filter(v=>v.presetMapping);return n.length===0?[]:n.some(v=>v.tier==="paid")?[{key:"free",label:"Free Tier",description:"Available on free or paid plans",badgeClassName:"text-[10px] bg-green-100 text-green-700 border-green-200",iconClassName:"text-green-600",models:n.filter(v=>v.tier!=="paid")},{key:"paid",label:"Paid Tier",description:"Requires paid access",badgeClassName:"text-[10px] bg-amber-100 text-amber-700 border-amber-200",iconClassName:"text-amber-700",models:n.filter(v=>v.tier==="paid")}].filter(v=>v.models.length>0):[{key:"default",models:n.slice(0,4)}]},[s]),D=C.length>0||t.length>0;return e.jsxs(e.Fragment,{children:[D&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(ve,{className:"w-4 h-4"}),"Presets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Apply pre-configured model mappings"}),e.jsxs("div",{className:"space-y-4",children:[C.map(n=>e.jsxs("div",{children:["label"in n&&n.label&&e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(B,{variant:"outline",className:n.badgeClassName,children:n.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:n.description})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:n.models.map(b=>e.jsxs(L,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>g(Aa(b)),children:[e.jsx(Ne,{className:`w-3 h-3 ${"iconClassName"in n?n.iconClassName:""}`}),b.name]},b.id))})]},n.key)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.map(n=>e.jsxs("div",{className:"group relative",children:[e.jsxs(L,{variant:"secondary",size:"sm",className:"text-xs h-7 gap-1 pr-6",onClick:()=>{g({ANTHROPIC_MODEL:n.default,ANTHROPIC_DEFAULT_OPUS_MODEL:n.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:n.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:n.haiku})},children:[e.jsx(Pe,{className:"w-3 h-3 fill-current"}),n.name]}),e.jsx(L,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-7 w-5 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:b=>{b.stopPropagation(),y(n.name)},disabled:P,children:e.jsx(Ye,{className:"w-3 h-3"})})]},n.name)),e.jsxs(L,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1 border-primary/50 text-primary hover:bg-primary/10 hover:border-primary",onClick:h,children:[e.jsx(_s,{className:"w-3 h-3"}),"Custom"]})]})]})]}),e.jsx(Ze,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:"Model Mapping"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),c==="codex"&&e.jsxs("p",{className:"text-[11px] text-muted-foreground mb-3 rounded-md border bg-muted/30 px-2.5 py-2",children:["Codex tip: suffixes ",e.jsx("code",{children:"-medium"}),", ",e.jsx("code",{children:"-high"}),", and ",e.jsx("code",{children:"-xhigh"})," ","pin reasoning effort. Unsuffixed models use Thinking settings."]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(re,{label:"Default Model",description:"Used when no specific tier is requested",value:a,onChange:n=>f("ANTHROPIC_MODEL",n),catalog:s,allModels:x}),w?.extendedContext&&u&&e.jsx(Ca,{model:w,provider:c,enabled:l??!1,onToggle:u}),e.jsx(re,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:i,onChange:n=>f("ANTHROPIC_DEFAULT_OPUS_MODEL",n),catalog:s,allModels:x}),e.jsx(re,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:r,onChange:n=>f("ANTHROPIC_DEFAULT_SONNET_MODEL",n),catalog:s,allModels:x}),e.jsx(re,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:p,onChange:n=>f("ANTHROPIC_DEFAULT_HAIKU_MODEL",n),catalog:s,allModels:x})]})]})]})}function xs(s){const t=Math.max(0,Math.min(100,s));return t<=20?"bg-destructive":t<=50?"bg-yellow-500":"bg-green-500"}function ps(s){if(!s)return"";try{const t=new Date(s),i=new Date().getTime()-t.getTime();if(i<0)return"just now";const r=Math.floor(i/(1e3*60)),p=Math.floor(i/(1e3*60*60)),x=Math.floor(i/(1e3*60*60*24));return x>0?`${x}d ago`:p>0?`${p}h ago`:r>0?`${r}m ago`:"just now"}catch{return""}}function Pa(s){if(!s)return!1;try{const t=new Date(s);return new Date().getTime()-t.getTime()<3600*1e3}catch{return!1}}function Ma({account:s,onSetDefault:t,onRemove:a,onPauseToggle:i,isRemoving:r,isPausingAccount:p,privacyMode:x,showQuota:c,selectable:l,selected:u,onSelectChange:g}){const{t:f}=Z(),h=s.provider.toLowerCase(),y=h==="codex",P=h==="claude"||h==="anthropic",{data:w}=tt(c),{data:C,isLoading:D}=at(h,s.id,c),n=w?.accountStats?.[s.email||s.id]?.lastUsedAt,b=Pa(n),v=nt(s.provider,C),F=it(s.provider,C),O=y&&C&&rt(C)?ot(C.windows):null,m=[{label:"5h",value:O?.fiveHourWindow?.remainingPercent??null},{label:"Weekly",value:O?.weeklyWindow?.remainingPercent??null}].filter(U=>U.value!==null),S=P&&C&<(C)?[{label:"5h",value:C.coreUsage?.fiveHour?.remainingPercent??C.windows.find(U=>U.rateLimitType==="five_hour")?.remainingPercent??null},{label:"Weekly",value:C.coreUsage?.weekly?.remainingPercent??C.windows.find(U=>["seven_day","seven_day_opus","seven_day_sonnet","seven_day_oauth_apps","seven_day_cowork"].includes(U.rateLimitType))?.remainingPercent??null}].filter(U=>U.value!==null):[],N=y?m:P?S:[],k=v!==null?xt(v):null,M=k!==null?Number(k):null,j=ct(C),A=j?.label==="Reauth"?Kt:j?.tone==="warning"?Se:qt,q=j?.tone==="warning"?"border-amber-500/50 text-amber-600 dark:text-amber-400":j?.tone==="destructive"?"border-destructive/50 text-destructive":"border-muted-foreground/50 text-muted-foreground";return e.jsxs("div",{className:V("flex flex-col gap-2 p-3 rounded-lg border transition-colors overflow-hidden",s.isDefault?"border-primary/30 bg-primary/5":"border-border hover:bg-muted/30",s.paused&&"opacity-75",u&&"ring-2 ring-primary/50 bg-primary/5"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[l&&e.jsx("button",{type:"button",onClick:()=>g?.(!u),className:V("flex items-center justify-center w-5 h-5 rounded border-2 transition-colors shrink-0",u?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30 hover:border-primary/50"),"aria-label":u?"Deselect account":"Select account",children:u&&e.jsx(ce,{className:"w-3 h-3"})}),i&&e.jsx(pe,{children:e.jsxs(he,{children:[e.jsx(ge,{asChild:!0,children:e.jsx(L,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>i(!s.paused),disabled:p,children:p?e.jsx(J,{className:"w-4 h-4 animate-spin"}):s.paused?e.jsx(Rs,{className:"w-4 h-4 text-emerald-500"}):e.jsx(Ke,{className:"w-4 h-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(fe,{side:"top",children:s.paused?"Resume account":"Pause account"})]})}),e.jsxs("div",{className:"relative shrink-0",children:[e.jsx("div",{className:V("flex items-center justify-center w-8 h-8 rounded-full",s.isDefault?"bg-primary/10":"bg-muted"),children:e.jsx(xe,{className:"w-4 h-4"})}),s.tier&&s.tier!=="unknown"&&s.tier!=="free"&&e.jsx("span",{className:V("absolute -bottom-0.5 -right-0.5 text-[7px] font-bold uppercase px-1 py-px rounded","ring-1 ring-background",s.tier==="ultra"?"bg-violet-500/20 text-violet-600 dark:bg-violet-500/30 dark:text-violet-300":"bg-yellow-500/20 text-yellow-700 dark:bg-yellow-500/25 dark:text-yellow-400"),children:s.tier==="ultra"?"U":"P"})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:V("font-medium text-sm truncate",x&&Ae),children:s.email||s.id}),s.isDefault&&e.jsxs(B,{variant:"secondary",className:"text-[10px] h-4 px-1.5 gap-0.5",children:[e.jsx(Pe,{className:"w-2.5 h-2.5 fill-current"}),"Default"]}),s.paused&&e.jsxs(B,{variant:"outline",className:"text-[10px] h-4 px-1.5 border-yellow-500 text-yellow-600",children:[e.jsx(Ke,{className:"w-2 h-2 mr-0.5"}),"Paused"]})]}),s.provider==="agy"&&e.jsx("div",{className:"flex items-center gap-1.5 mt-1",children:s.projectId?e.jsx(pe,{children:e.jsxs(he,{children:[e.jsx(ge,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Bt,{className:"w-3 h-3","aria-hidden":"true"}),e.jsx("span",{className:V("font-mono max-w-[180px] truncate",x&&Ae),title:s.projectId,children:s.projectId})]})}),e.jsx(fe,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:"GCP Project ID (read-only)"})})]})}):e.jsx(pe,{children:e.jsxs(he,{children:[e.jsx(ge,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-500",children:[e.jsx(Se,{className:"w-3 h-3","aria-label":"Warning"}),e.jsx("span",{children:"Project ID: N/A"})]})}),e.jsx(fe,{side:"bottom",className:"max-w-[250px]",children:e.jsxs("div",{className:"text-xs space-y-1",children:[e.jsx("p",{className:"font-medium text-amber-600",children:"Missing Project ID"}),e.jsx("p",{children:"This may cause errors. Remove the account and re-add it to fetch the project ID."})]})})]})})}),s.lastUsedAt&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground mt-0.5",children:[e.jsx(ls,{className:"w-3 h-3"}),"Last used: ",new Date(s.lastUsedAt).toLocaleDateString()]})]})]}),e.jsxs(dt,{children:[e.jsx(ut,{asChild:!0,children:e.jsx(L,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(Vt,{className:"w-4 h-4"})})}),e.jsxs(mt,{align:"end",children:[!s.isDefault&&e.jsxs(is,{onClick:t,children:[e.jsx(Pe,{className:"w-4 h-4 mr-2"}),"Set as default"]}),e.jsxs(is,{className:"text-destructive focus:text-destructive",onClick:a,disabled:r,children:[e.jsx(Ls,{className:"w-4 h-4 mr-2"}),r?"Removing...":"Remove account"]})]})]})]}),c&&e.jsx("div",{className:"pl-11",children:D?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(J,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{children:"Loading quota..."})]}):M!==null?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex items-center gap-1.5 text-xs",children:b?e.jsxs(e.Fragment,{children:[e.jsx(Gt,{className:"w-3 h-3 text-emerald-500"}),e.jsxs("span",{className:"text-emerald-600 dark:text-emerald-400",children:["Active · ",ps(n)]})]}):n?e.jsxs(e.Fragment,{children:[e.jsx(ls,{className:"w-3 h-3 text-muted-foreground"}),e.jsxs("span",{className:"text-muted-foreground",children:["Last used ",ps(n)]})]}):e.jsxs(e.Fragment,{children:[e.jsx(cs,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Not used yet"})]})}),e.jsx(pe,{children:e.jsxs(he,{children:[e.jsx(ge,{asChild:!0,children:N.length>0?e.jsx("div",{className:"space-y-1.5",children:N.map(U=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-10 text-[10px] text-muted-foreground",children:U.label}),e.jsx(Ue,{value:Math.max(0,Math.min(100,U.value)),className:"h-2 flex-1",indicatorClassName:xs(U.value)}),e.jsxs("span",{className:"text-xs font-medium w-10 text-right",children:[U.value,"%"]})]},U.label))}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ue,{value:Math.max(0,Math.min(100,M)),className:"h-2 flex-1",indicatorClassName:xs(M)}),e.jsxs("span",{className:"text-xs font-medium w-10 text-right",children:[k,"%"]})]})}),e.jsx(fe,{side:"bottom",className:"max-w-xs",children:e.jsx(pt,{quota:C,resetTime:F})})]})})]}):C?.success?e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(B,{variant:"outline",className:"text-[10px] h-5 px-2 gap-1 border-muted-foreground/50 text-muted-foreground",children:[e.jsx(cs,{className:"w-3 h-3"}),f("accountCard.quotaUnavailable")]})}):j?e.jsx(pe,{children:e.jsxs(he,{children:[e.jsx(ge,{asChild:!0,children:e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(B,{variant:"outline",className:V("text-[10px] h-5 px-2 gap-1",q),children:[e.jsx(A,{className:"w-3 h-3"}),j.label]})})}),e.jsx(fe,{side:"bottom",className:"max-w-[260px]",children:e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("p",{children:j.summary}),j.actionHint&&e.jsx("p",{className:"text-muted-foreground",children:j.actionHint}),j.technicalDetail&&e.jsx("p",{className:"font-mono text-[11px] text-muted-foreground",children:j.technicalDetail}),j.rawDetail&&e.jsx("pre",{className:"whitespace-pre-wrap break-all rounded bg-muted/40 px-2 py-1 font-mono text-[10px] text-muted-foreground",children:j.rawDetail})]})})]})}):null})]})}function Ta({selectedCount:s,onPauseSelected:t,onResumeSelected:a,onClearSelection:i,isPausing:r,isResuming:p}){if(s<1)return null;const x=r||p;return e.jsxs("div",{className:"flex items-center gap-3 p-2 bg-muted/50 rounded-lg border mt-2",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[s," selected"]}),e.jsx(L,{variant:"ghost",size:"sm",className:"text-xs h-6 px-2",onClick:i,disabled:x,children:"Clear"}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsxs(L,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:t,disabled:x,children:[r?e.jsx(J,{className:"w-3 h-3 animate-spin"}):e.jsx(Ke,{className:"w-3 h-3"}),"Pause Selected"]}),e.jsxs(L,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:a,disabled:x,children:[p?e.jsx(J,{className:"w-3 h-3 animate-spin"}):e.jsx(Rs,{className:"w-3 h-3"}),"Resume Selected"]})]})]})}function Da({accounts:s,onAddAccount:t,onSetDefault:a,onRemoveAccount:i,onPauseToggle:r,onSoloMode:p,onBulkPause:x,onBulkResume:c,isRemovingAccount:l,isPausingAccount:u,isSoloingAccount:g,isBulkPausing:f,isBulkResuming:h,privacyMode:y,showQuota:P,isKiro:w,kiroNoIncognito:C,onKiroNoIncognitoChange:D,kiroSettingsLoading:n}){const[b,v]=o.useState(new Set),F=o.useMemo(()=>new Set(s.map(R=>R.id)),[s]),O=o.useMemo(()=>new Set([...b].filter(R=>F.has(R))),[b,F]),m=!!(x&&c),S=O.size,N=s.length>0&&O.size===s.length,k=O.size>0&&O.size<s.length,M=o.useCallback(R=>{v(H=>{const G=new Set(H);return G.has(R)?G.delete(R):G.add(R),G})},[]),j=o.useCallback(()=>{v(new Set(s.map(R=>R.id)))},[s]),A=o.useCallback(()=>{v(new Set)},[]),q=o.useCallback(()=>{N?A():j()},[N,j,A]),U=o.useCallback(()=>{x&&O.size>0&&(x(Array.from(O)),v(new Set))},[x,O]),E=o.useCallback(()=>{c&&O.size>0&&(c(Array.from(O)),v(new Set))},[c,O]);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2",children:[m&&s.length>0&&e.jsx(Ce,{checked:N,onCheckedChange:q,"aria-label":"Select all accounts",className:k?"data-[state=checked]:bg-primary/50":"",...k?{"data-state":"indeterminate"}:{}}),e.jsx(xe,{className:"w-4 h-4"}),"Accounts",s.length>0&&e.jsx(B,{variant:"secondary",className:"text-xs",children:s.length})]}),e.jsxs(L,{variant:"default",size:"sm",className:"h-7 text-xs gap-1",onClick:t,children:[e.jsx(_s,{className:"w-3 h-3"}),"Add"]})]}),m&&S>0&&e.jsx(Ta,{selectedCount:S,onPauseSelected:U,onResumeSelected:E,onClearSelection:A,isPausing:!!f,isResuming:!!h}),s.length>0?e.jsx("div",{className:"space-y-2",children:s.map(R=>e.jsx(Ma,{account:R,onSetDefault:()=>a(R.id),onRemove:()=>i(R.id),onPauseToggle:r?H=>r(R.id,H):void 0,onSoloMode:p?()=>p(R.id):void 0,isRemoving:l,isPausingAccount:u,isSoloingAccount:g,privacyMode:y,showQuota:P,selectable:m,selected:O.has(R.id),onSelectChange:()=>M(R.id)},R.id))}):e.jsxs("div",{className:"py-6 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed",children:[e.jsx(xe,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No accounts connected"}),e.jsx("p",{className:"text-xs opacity-70",children:"Add an account to get started"})]}),w&&D&&e.jsx("div",{className:"mt-3 pt-3 border-t border-dashed",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Es,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Use incognito"})]}),e.jsx(Fs,{checked:!C,onCheckedChange:R=>D(!R),disabled:n,className:"scale-90"})]})})]})}function Oa({provider:s,catalog:t,savedPresets:a,currentModel:i,opusModel:r,sonnetModel:p,haikuModel:x,providerModels:c,extendedContextEnabled:l,onExtendedContextToggle:u,onApplyPreset:g,onUpdateEnvValue:f,onOpenCustomPreset:h,onDeletePreset:y,isDeletePending:P,accounts:w,onAddAccount:C,onSetDefault:D,onRemoveAccount:n,onPauseToggle:b,onSoloMode:v,onBulkPause:F,onBulkResume:O,isRemovingAccount:m,isPausingAccount:S,isSoloingAccount:N,isBulkPausing:k,isBulkResuming:M,privacyMode:j,isRemoteMode:A}){const q=s.toLowerCase(),U=(ht.includes(q)||["anthropic","antigravity","gemini-cli","copilot","github-copilot"].includes(q))&&!A,E=s==="kiro",[R,H]=o.useState(!0),[G,$]=o.useState(!0),[ae,ee]=o.useState(!1),W=o.useCallback(async()=>{if(E)try{$(!0);const z=(await we.config.get()).cliproxy;H(z?.kiro_no_incognito??!0)}catch{H(!0)}finally{$(!1)}},[E]),d=o.useCallback(async _=>{H(_),ee(!0);try{const z=await we.config.get(),de=z.cliproxy??{};await we.config.update({...z,cliproxy:{...de,kiro_no_incognito:_}})}catch{H(!_)}finally{ee(!1)}},[]);return o.useEffect(()=>{W()},[W]),e.jsx(ze,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsx(Sa,{catalog:t,savedPresets:a,currentModel:i,opusModel:r,sonnetModel:p,haikuModel:x,providerModels:c,provider:s,extendedContextEnabled:l,onExtendedContextToggle:u,onApplyPreset:g,onUpdateEnvValue:f,onOpenCustomPreset:h,onDeletePreset:y,isDeletePending:P}),e.jsx(Ze,{}),e.jsx(Da,{accounts:w,onAddAccount:C,onSetDefault:D,onRemoveAccount:n,onPauseToggle:b,onSoloMode:v,onBulkPause:F,onBulkResume:O,isRemovingAccount:m,isPausingAccount:S,isSoloingAccount:N,isBulkPausing:k,isBulkResuming:M,privacyMode:j,showQuota:U,isKiro:E,kiroNoIncognito:R,onKiroNoIncognitoChange:d,kiroSettingsLoading:G||ae})]})})}function hs({provider:s,displayName:t,authStatus:a,catalog:i,logoProvider:r,baseProvider:p,isRemoteMode:x,port:c,defaultTarget:l,onAddAccount:u,onSetDefault:g,onRemoveAccount:f,onPauseToggle:h,onSoloMode:y,onBulkPause:P,onBulkResume:w,isRemovingAccount:C,isPausingAccount:D,isSoloingAccount:n,isBulkPausing:b,isBulkResuming:v}){const[F,O]=o.useState(!1),{privacyMode:m}=ks(),{data:S}=gt(),{data:N}=ft(s),k=jt(),M=vt(),j=p||s,A=j.toLowerCase()==="agy",q=o.useMemo(()=>{const I=N?.presets||[];return A?I.filter(Q=>!se(Q.default)&&!se(Q.opus)&&!se(Q.sonnet)&&!se(Q.haiku)):I},[A,N?.presets]),U=o.useMemo(()=>{if(!S?.models)return[];const Q={gemini:["google"],agy:["antigravity"],codex:["openai"],qwen:["alibaba","qwen"],iflow:["iflow"],kiro:["kiro","aws"],ghcp:["github","copilot"],kimi:["kimi","moonshot"]}[j.toLowerCase()]||[j.toLowerCase()];return S.models.filter(ie=>Q.some(Ee=>ie.owned_by.toLowerCase().includes(Ee))?A?!se(ie.id):!0:!1)},[A,S,j]),E=(p||s).toLowerCase(),{data:R,isLoading:H,refetch:G,rawJsonContent:$,rawJsonEdits:ae,isRawJsonValid:ee,hasChanges:W,currentModel:d,opusModel:_,sonnetModel:z,haikuModel:de,extendedContextEnabled:Me,toggleExtendedContext:Te,handleRawJsonChange:De,updateEnvValue:X,updateEnvValues:T,saveMutation:te,conflictDialog:ne,handleConflictResolve:Oe,missingRequiredFields:ye}=fa(s),Ks=o.useMemo(()=>(a.accounts||[]).map(I=>({...I,provider:I.provider||p||s})),[a.accounts,p,s]),{data:qs}=gs({queryKey:["auth-tokens-raw"],queryFn:async()=>{const I=await fetch("/api/settings/auth/tokens/raw");return I.ok?I.json():{apiKey:{value:"ccs-internal-managed"}}},staleTime:6e4}),ts=qs?.apiKey?.value??"ccs-internal-managed",Bs=I=>{if(A&&[I.ANTHROPIC_MODEL,I.ANTHROPIC_DEFAULT_OPUS_MODEL,I.ANTHROPIC_DEFAULT_SONNET_MODEL,I.ANTHROPIC_DEFAULT_HAIKU_MODEL].some(ie=>typeof ie=="string"&&se(ie))){K.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}T({ANTHROPIC_BASE_URL:`http://127.0.0.1:${c??He}/api/provider/${E}`,ANTHROPIC_AUTH_TOKEN:ts,...I}),K.success(`Applied "${I.ANTHROPIC_MODEL?.split("/").pop()||"preset"}" preset`)},Vs=(I,Q)=>{if(A&&[I.default,I.opus,I.sonnet,I.haiku].some(Ee=>se(Ee))){K.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}T({ANTHROPIC_BASE_URL:`http://127.0.0.1:${c??He}/api/provider/${E}`,ANTHROPIC_AUTH_TOKEN:ts,ANTHROPIC_MODEL:I.default,ANTHROPIC_DEFAULT_OPUS_MODEL:I.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:I.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:I.haiku}),K.success(`Applied ${Q?`"${Q}"`:"custom"} preset`),O(!1)},Gs=(I,Q)=>{if(!Q){K.error(As.t("commonToast.enterPresetName"));return}if(A&&[I.default,I.opus,I.sonnet,I.haiku].some(ie=>se(ie))){K.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}k.mutate({profile:s,data:{name:Q,...I}}),O(!1)};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(ka,{provider:s,displayName:t,logoProvider:r,data:R,isLoading:H,hasChanges:W,isRawJsonValid:ee,isSaving:te.isPending,isRemoteMode:x,port:c,onRefetch:G,onSave:()=>te.mutate()}),H?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(J,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):e.jsxs("div",{className:"flex-1 grid grid-cols-[40%_60%] divide-x overflow-hidden",children:[e.jsx("div",{className:"flex flex-col overflow-hidden bg-muted/5",children:e.jsxs(Nt,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(yt,{className:"w-full",children:[e.jsx(rs,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(rs,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(os,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(Oa,{provider:s,catalog:i,savedPresets:q,currentModel:d,opusModel:_,sonnetModel:z,haikuModel:de,providerModels:U,extendedContextEnabled:Me,onExtendedContextToggle:Te,onApplyPreset:Bs,onUpdateEnvValue:X,onOpenCustomPreset:()=>O(!0),onDeletePreset:I=>M.mutate({profile:s,name:I}),isDeletePending:M.isPending,accounts:Ks,onAddAccount:u,onSetDefault:g,onRemoveAccount:f,onPauseToggle:h,onSoloMode:y,onBulkPause:P,onBulkResume:w,isRemovingAccount:C,isPausingAccount:D,isSoloingAccount:n,isBulkPausing:b,isBulkResuming:v,privacyMode:m,isRemoteMode:x})}),e.jsx(os,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(wa,{provider:s,displayName:t,defaultTarget:l,data:R,authStatus:a})})]})]})}),e.jsxs("div",{className:"flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx($t,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(bt,{rawJsonContent:$,isRawJsonValid:ee,rawJsonEdits:ae,onRawJsonChange:De,profileEnv:R?.settings?.env,missingRequiredFields:ye})]})]}),e.jsx(Jt,{open:ne,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>Oe(!0),onCancel:()=>Oe(!1)}),e.jsx(ba,{open:F,onClose:()=>O(!1),currentValues:{default:d||"",opus:_||"",sonnet:z||"",haiku:de||""},onApply:Vs,onSave:Gs,isSaving:k.isPending,catalog:i,allModels:U})]})}function Ea({status:s,isSelected:t,onSelect:a}){const{t:i}=Z(),r=s.accounts?.length||0;return e.jsxs("button",{className:V("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors cursor-pointer text-left",t?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:a,children:[e.jsx(Je,{provider:s.provider,size:"md"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:s.displayName}),r>0&&e.jsx(B,{variant:"secondary",className:"text-[10px] h-4 px-1",children:r})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:s.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-green-600",children:i("cliproxyPage.connected")})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ye,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:i("cliproxyPage.notConnected")})]})})]})]})}function _a({variant:s,parentAuth:t,isSelected:a,onSelect:i,onDelete:r,isDeleting:p}){const{t:x}=Z(),c=()=>{i()};return e.jsxs("div",{role:"button",tabIndex:0,className:V("group w-full flex items-center gap-3 px-3 py-2 rounded-lg transition-colors cursor-pointer text-left pl-6",a?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:c,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),c())},children:[e.jsxs("div",{className:"relative",children:[e.jsx(Je,{provider:s.provider,size:"sm"}),e.jsx(Is,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5 text-muted-foreground"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:s.name}),e.jsx(B,{variant:"outline",className:"text-[9px] h-4 px-1",children:x("cliproxyPage.variant")}),e.jsx(B,{variant:"outline",className:"text-[9px] h-4 px-1 uppercase",children:s.target||"claude"})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:t?.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-muted-foreground truncate",children:x("cliproxyPage.viaProvider",{provider:s.provider})})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ye,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:x("cliproxyPage.parentNotConnected")})]})})]}),e.jsx(L,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:l=>{l.stopPropagation(),r()},disabled:p,children:e.jsx(Ls,{className:"w-3 h-3"})})]})}function Ra({onSetup:s}){const{t}=Z();return e.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/20",children:e.jsxs("div",{className:"text-center max-w-md px-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-muted flex items-center justify-center mx-auto mb-6",children:e.jsx(Ne,{className:"w-8 h-8 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:t("cliproxyPage.emptyTitle")}),e.jsx("p",{className:"text-muted-foreground mb-4",children:t("cliproxyPage.emptyDesc")}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-6",children:[t("cliproxyPage.emptyControlPanelPrefix")," ",e.jsx("a",{href:"/cliproxy/control-panel",className:"text-primary hover:underline",children:t("cliproxyPage.controlPanel")}),"."]}),e.jsxs(L,{onClick:s,className:"gap-2",children:[e.jsx(ve,{className:"w-4 h-4"}),t("cliproxyPage.quickSetup")]})]})})}function en(){const{t:s}=Z(),t=Be(),{data:a,isLoading:i}=ws(),{data:r,isFetching:p}=wt(),{data:x}=kt(),c=Ct(),l=At(),u=St(),g=Pt(),f=Mt(),h=Tt(),y=Dt(),P=Ot(),[w,C]=o.useState(()=>{if(typeof window<"u"){const _=new URLSearchParams(window.location.search).get("provider")?.trim().toLowerCase();return _&&Fe(_)?_:localStorage.getItem("cliproxy-selected-provider")}return null}),[D,n]=o.useState(null),[b,v]=o.useState(!1),[F,O]=o.useState(()=>{if(typeof window>"u")return null;const d=new URLSearchParams(window.location.search),_=d.get("provider")?.trim().toLowerCase();return d.get("action")!=="auth"||!_||!Fe(_)?null:{provider:_,displayName:Et(_),isFirstAccount:!1}}),m=o.useMemo(()=>a?.authStatus||[],[a?.authStatus]),S=a?.source==="remote",N=o.useMemo(()=>r?.variants||[],[r?.variants]),k=d=>{C(d),d&&localStorage.setItem("cliproxy-selected-provider",d)},M=o.useMemo(()=>D?null:w&&m.some(d=>d.provider===w)?w:m.length>0&&(m.find(_=>(_.accounts?.length||0)>0)?.provider||m[0]?.provider)||null,[w,D,m]),j=m.find(d=>d.provider===M),A=N.find(d=>d.name===D),q=A?m.find(d=>d.provider===A.provider):void 0,U=(A?.provider||j?.provider||"").toLowerCase().trim(),E=U==="gemini"||U==="agy",R=()=>{t.invalidateQueries({queryKey:["cliproxy"]}),t.invalidateQueries({queryKey:["cliproxy-auth"]})},H=(d,_,z)=>{u.isPending||g.isPending||(z?u.mutate({provider:d,accountId:_}):g.mutate({provider:d,accountId:_}))},G=(d,_)=>{f.isPending||f.mutate({provider:d,accountId:_})},$=(d,_)=>{h.isPending||h.mutate({provider:d,accountIds:_})},ae=(d,_)=>{y.isPending||y.mutate({provider:d,accountIds:_})},ee=d=>{k(d),n(null)},W=d=>{n(d),k(null)};return e.jsxs("div",{className:"h-[calc(100vh-100px)] flex",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ne,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:x?.backendLabel??"CLIProxy"})]}),e.jsx(L,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:R,disabled:p,children:e.jsx(Xe,{className:V("w-4 h-4",p&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:s("cliproxyPage.accountManagement")}),e.jsxs(L,{variant:"default",size:"sm",className:"w-full gap-2",onClick:()=>v(!0),children:[e.jsx(ve,{className:"w-4 h-4"}),s("cliproxyPage.quickSetup")]})]}),e.jsx(ze,{className:"flex-1",children:e.jsxs("div",{className:"p-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3 py-2",children:s("cliproxyPage.providers")}),i?e.jsx("div",{className:"space-y-2 px-2",children:[1,2,3,4].map(d=>e.jsx(_t,{className:"h-14 w-full rounded-lg"},d))}):e.jsx("div",{className:"space-y-1",children:m.map(d=>e.jsx(Ea,{status:d,isSelected:M===d.provider,onSelect:()=>ee(d.provider)},d.provider))}),N.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3 py-2 mt-4 flex items-center gap-1.5",children:[e.jsx(Is,{className:"w-3 h-3"}),s("cliproxyPage.variants")]}),e.jsx("div",{className:"space-y-1",children:N.map(d=>e.jsx(_a,{variant:d,parentAuth:m.find(_=>_.provider===d.provider),isSelected:D===d.name,onSelect:()=>W(d.name),onDelete:()=>P.mutate(d.name),isDeleting:P.isPending},d.name))})]})]})}),e.jsx("div",{className:"p-3 border-t",children:e.jsx(Xt,{})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:s("cliproxyPage.providerCount",{count:m.length})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ce,{className:"w-3 h-3 text-green-600"}),s("cliproxyPage.connectedCount",{count:m.filter(d=>d.authenticated).length})]})]})})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0 bg-background",children:[E&&e.jsx(Us,{showProxySettingsLink:!0,className:"mx-4 mt-4"}),A&&q?e.jsx(e.Fragment,{children:e.jsx(hs,{provider:A.name,displayName:s("cliproxyPage.variantDisplay",{name:A.name,provider:A.provider}),authStatus:q,catalog:je[A.provider],logoProvider:A.provider,baseProvider:A.provider,defaultTarget:A.target,isRemoteMode:S,port:A.port,onAddAccount:()=>O({provider:A.provider,displayName:q.displayName,isFirstAccount:(q.accounts?.length||0)===0}),onSetDefault:d=>c.mutate({provider:A.provider,accountId:d}),onRemoveAccount:d=>l.mutate({provider:A.provider,accountId:d}),onPauseToggle:(d,_)=>H(A.provider,d,_),onSoloMode:d=>G(A.provider,d),onBulkPause:d=>$(A.provider,d),onBulkResume:d=>ae(A.provider,d),isRemovingAccount:l.isPending,isPausingAccount:u.isPending||g.isPending,isSoloingAccount:f.isPending,isBulkPausing:h.isPending,isBulkResuming:y.isPending})}):j?e.jsx(e.Fragment,{children:e.jsx(hs,{provider:j.provider,displayName:j.displayName,authStatus:j,catalog:je[j.provider],isRemoteMode:S,onAddAccount:()=>O({provider:j.provider,displayName:j.displayName,isFirstAccount:(j.accounts?.length||0)===0}),onSetDefault:d=>c.mutate({provider:j.provider,accountId:d}),onRemoveAccount:d=>l.mutate({provider:j.provider,accountId:d}),onPauseToggle:(d,_)=>H(j.provider,d,_),onSoloMode:d=>G(j.provider,d),onBulkPause:d=>$(j.provider,d),onBulkResume:d=>ae(j.provider,d),isRemovingAccount:l.isPending,isPausingAccount:u.isPending||g.isPending,isSoloingAccount:f.isPending,isBulkPausing:h.isPending,isBulkResuming:y.isPending})}):e.jsx(Ra,{onSetup:()=>v(!0)})]}),e.jsx(ia,{open:b,onClose:()=>v(!1)}),e.jsx(ma,{open:F!==null,onClose:()=>O(null),provider:F?.provider||"",displayName:F?.displayName||"",isFirstAccount:F?.isFirstAccount||!1})]})}export{en as CliproxyPage};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as m,u as qe,h as $e}from"./react-vendor-CNOkPC89.js";import{c as K,at as me,aZ as ue,B as h,ad as Ke,ae as He,af as Be,ag as De,ah as Fe,L as A,I as k,M as Ge,N as Ve,O as ze,as as Je,d as f,Y as re,S as fe,n as ee,Q as ve,R as ye,U as W,V as X,a_ as be,a$ as _e}from"./index-sCtK1kDn.js";import{P as Qe}from"./proxy-status-widget-C8cOlsqE.js";import{C as We}from"./confirm-dialog-Bee0kh6i.js";import{k as Xe,x as Pe,l as Ae,m as pe,an as se,r as Ye,R as le,Z as Ze,a3 as Se,o as Ie,aB as es,I as ss,ai as ts,aj as as,O as je,aC as Ue,aD as Le,aE as Me,am as rs,aF as ns}from"./icons-DR-ORtNe.js";import{u as is,a as xe,b as he}from"./tanstack-B8i0evp-.js";import{t as G}from"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-CwEJfEUX.js";function ls(t){switch(t){case"ready":return{icon:Ae,text:"Ready",className:"text-green-600"};case"partial":return{icon:Pe,text:"Needs attention",className:"text-amber-600"};default:return{icon:Xe,text:"Not configured",className:"text-muted-foreground"}}}function os({families:t,selectedFamily:s,onSelect:a}){return e.jsx("div",{className:"space-y-1",children:t.map(r=>{const i=r.id===s,o=ls(r.status),d=o.icon;return e.jsx("button",{type:"button",onClick:()=>a(r.id),className:K("w-full cursor-pointer rounded-lg border px-3 py-2.5 text-left transition-colors",i?"border-primary/20 bg-primary/10":"border-transparent hover:bg-muted/70"),children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(me,{provider:ue(r.id),size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:r.displayName}),r.entries.length>0&&e.jsx(h,{variant:"secondary",className:"h-4 px-1 text-[10px]",children:r.entries.length})]}),e.jsxs("div",{className:K("mt-0.5 flex items-center gap-1.5 text-xs",o.className),children:[e.jsx(d,{className:"h-3 w-3"}),e.jsx("span",{children:o.text})]})]}),e.jsx(h,{variant:"outline",className:"h-5 px-1.5 text-[9px] uppercase tracking-wide",children:r.authMode})]})},r.id)})})}function ds(t){switch(t){case"gemini-api-key":return{familyName:"Gemini",description:"Store the Gemini key here so CLIProxy can route Gemini requests without creating a separate CCS API Profile.",requiredNow:["Paste the Gemini API key.","Leave Base URL empty unless you use a custom Gemini host."],optionalLater:["Model mappings only when requested names and Gemini names differ.","Headers only when your provider setup requires them."],keyLabel:"Gemini API Key",keyPlaceholder:"AIza...",keyHelper:"This is the only field most Gemini setups need.",baseUrlPlaceholder:"https://generativelanguage.googleapis.com",baseUrlHelper:"Optional. Leave blank to keep the default Gemini endpoint.",aliasesPlaceholder:"claude-sonnet-4-5=gemini-2.5-pro",aliasesHelper:"Format: requested=upstream. Leave this blank unless the upstream Gemini model name differs.",headersPlaceholder:"X-Goog-User-Project: your-project"};case"codex-api-key":return{familyName:"Codex",description:"Store the Codex or OpenAI key here so CLIProxy can route Codex requests without duplicating the setup in API Profiles.",requiredNow:["Paste the Codex or OpenAI API key.","Leave Base URL empty unless this route should target another OpenAI-style endpoint."],optionalLater:["Model mappings only when the upstream model ID differs.","Headers only when org or project routing needs them."],keyLabel:"Codex API Key",keyPlaceholder:"sk-...",keyHelper:"This is the only field most Codex setups need.",baseUrlPlaceholder:"https://api.openai.com/v1",baseUrlHelper:"Optional. Leave blank to keep the default Codex endpoint.",aliasesPlaceholder:"claude-sonnet-4-5=gpt-5",aliasesHelper:"Format: requested=upstream. Add a mapping only when the upstream model name differs.",headersPlaceholder:"OpenAI-Organization: org_..."};case"claude-api-key":return{familyName:"Claude",description:"Store the Anthropic or compatible key here for CLIProxy-managed Claude routing. Save the key first, then add rewrites only if this route needs them.",requiredNow:["Paste the Claude or Anthropic-compatible API key.","Leave Base URL empty unless this route should target another compatible endpoint."],optionalLater:["Model mappings only when the requested and upstream Claude model IDs differ.","Proxy, prefix, exclusions, and headers only for advanced routing cases."],keyLabel:"Claude API Key",keyPlaceholder:"sk-ant-...",keyHelper:"Most Claude routes can start with the key only.",baseUrlPlaceholder:"https://api.anthropic.com",baseUrlHelper:"Optional. Leave blank to keep the default Claude-compatible endpoint.",aliasesPlaceholder:"claude-sonnet-4-5=claude-3-7-sonnet-latest",aliasesHelper:"Format: requested=upstream. Add a mapping only when the upstream model ID should differ.",headersPlaceholder:"X-Project: internal-routing"};case"vertex-api-key":return{familyName:"Vertex",description:"Store the Vertex key here so CLIProxy can route Vertex traffic without creating a separate CCS API Profile.",requiredNow:["Paste the Vertex API key.","Leave Base URL empty unless a regional or gateway endpoint is required."],optionalLater:["Model mappings only when the upstream name differs.","Headers only when the provider expects extra routing context."],keyLabel:"Vertex API Key",keyPlaceholder:"AIza...",keyHelper:"Most Vertex routes only need the key.",baseUrlPlaceholder:"https://vertex.googleapis.com",baseUrlHelper:"Optional. Leave blank to keep the default Vertex endpoint.",aliasesPlaceholder:"claude-sonnet-4-5=gemini-2.5-pro",aliasesHelper:"Format: requested=upstream. Leave blank unless the upstream model name differs.",headersPlaceholder:"X-Goog-User-Project: your-project"};case"openai-compatibility":return{familyName:"OpenAI-Compatible Connector",description:"Create a named connector for OpenRouter, Together, or any OpenAI-style endpoint. This page owns the connector setup directly inside CLIProxy.",requiredNow:["Pick a connector name such as openrouter or together.","Set the connector Base URL.","Add at least one API key before saving."],optionalLater:["Model mappings only when requested and upstream model names differ.","Headers only when the connector requires provider-specific auth or routing."],keyLabel:"API Keys",keyPlaceholder:"sk-...",keyHelper:"Add one key per line. Most connectors start with a single key.",connectorPlaceholder:"openrouter",connectorHelper:"This becomes the connector label in the saved entries list.",baseUrlPlaceholder:"https://openrouter.ai/api/v1",baseUrlHelper:"Required for connectors. This is the upstream OpenAI-style endpoint.",aliasesPlaceholder:"claude-sonnet-4-5=gpt-4.1",aliasesHelper:"Format: requested=upstream. Leave blank unless the connector expects a different model ID.",headersPlaceholder:"HTTP-Referer: https://your-app.example"}}}function Ne(t){return t.split(`
|
|
2
|
+
`).map(s=>s.trim()).filter(s=>s.length>0)}function cs(t){return t.split(`
|
|
3
|
+
`).map(s=>s.trim()).filter(s=>s.length>0).map(s=>{const a=s.includes(":")?":":"=",[r,...i]=s.split(a);return{key:r.trim(),value:i.join(a).trim()}}).filter(s=>s.key.length>0)}function ms(t){return t.split(`
|
|
4
|
+
`).map(s=>s.trim()).filter(s=>s.length>0).map(s=>{const a=s.indexOf("=");return a===-1?{name:s.trim(),alias:""}:{name:s.slice(0,a).trim(),alias:s.slice(a+1).trim()}}).filter(s=>s.name.length>0||s.alias.length>0)}function Y({value:t,onChange:s,placeholder:a,rows:r=4}){return e.jsx("textarea",{rows:r,value:t,onChange:i=>s(i.target.value),placeholder:a,className:"flex min-h-24 w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-xs outline-none transition-[color,box-shadow] placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50"})}function us(t){return(t?.headers||[]).map(s=>`${s.key}: ${s.value}`).join(`
|
|
5
|
+
`)}function ps(t){return(t?.excludedModels||[]).join(`
|
|
6
|
+
`)}function xs(t){return(t?.models||[]).map(s=>s.alias.trim()?`${s.name}=${s.alias}`:s.name).join(`
|
|
7
|
+
`)}function we({title:t,items:s,icon:a}){return e.jsxs("div",{className:"rounded-xl border bg-background/80 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[a,t]}),e.jsx("div",{className:"mt-3 space-y-3",children:s.map((r,i)=>e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border bg-muted/40 text-[11px] font-semibold text-muted-foreground",children:i+1}),e.jsx("div",{className:"text-sm leading-6 text-muted-foreground",children:r})]},`${t}:${r}`))})]})}function hs({family:t,entry:s,open:a,onOpenChange:r,onSubmit:i,isSaving:o}){const d=m.useMemo(()=>ds(t),[t]),l=!!s,c=t==="openai-compatibility",v=t==="claude-api-key",[S,E]=m.useState(()=>s?.name||""),[b,T]=m.useState(()=>s?.baseUrl||""),[j,O]=m.useState(()=>s?.proxyUrl||""),[I,J]=m.useState(()=>s?.prefix||""),[N,U]=m.useState(""),[y,p]=m.useState(""),[L,w]=m.useState(()=>us(s)),[q,H]=m.useState(()=>ps(s)),[B,g]=m.useState(()=>xs(s)),[R,P]=m.useState(()=>!!(s?.headers.length||s?.excludedModels.length||s?.proxyUrl||s?.prefix)),D=m.useMemo(()=>!l||!s?.secretConfigured?null:c?"Leave API keys blank to keep the stored connector secrets.":"Leave the API key blank to keep the stored secret.",[s?.secretConfigured,l,c]),F=async()=>{const n=N.trim(),$=Ne(y),C=l&&s?.secretConfigured&&!n.length&&$.length===0,ie={name:c?S:void 0,baseUrl:b,proxyUrl:v?j:void 0,prefix:v?I:void 0,headers:cs(L),excludedModels:v?Ne(q):void 0,models:ms(B),preserveSecrets:C,...c?$.length>0?{apiKeys:$}:{}:n.length>0?{apiKey:n}:{}};await i(ie)};return e.jsx(Ke,{open:a,onOpenChange:r,children:e.jsx(He,{className:"overflow-hidden p-0 sm:max-w-3xl",children:e.jsxs("div",{className:"max-h-[85vh] overflow-y-auto",children:[e.jsx("div",{className:"border-b bg-muted/20 px-6 py-5",children:e.jsxs(Be,{className:"gap-4 text-left",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-xl border bg-background",children:e.jsx(me,{provider:ue(t),size:"md"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(De,{children:l?`Edit ${d.familyName}`:`Set up ${d.familyName}`}),e.jsx(h,{variant:"outline",className:"uppercase text-[11px]",children:c?"connector":"api-key"})]}),e.jsx(Fe,{className:"mt-1 max-w-2xl leading-6",children:d.description})]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(we,{title:"Required now",items:d.requiredNow,icon:e.jsx(pe,{className:"h-4 w-4 text-primary"})}),e.jsx(we,{title:"Optional later",items:d.optionalLater,icon:e.jsx(se,{className:"h-4 w-4 text-primary"})})]}),D?e.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-5 text-amber-800",children:D}):null]})}),e.jsxs("div",{className:"space-y-6 px-6 py-6",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold",children:"Required setup"}),e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:"Save the smallest working configuration first."})]}),c?e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(A,{htmlFor:"connector-name",children:"Connector Name"}),e.jsx(k,{id:"connector-name",value:S,onChange:n=>E(n.target.value),placeholder:d.connectorPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d.connectorHelper})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(A,{htmlFor:"base-url",children:"Base URL"}),e.jsx(k,{id:"base-url",value:b,onChange:n=>T(n.target.value),placeholder:d.baseUrlPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d.baseUrlHelper})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(A,{children:"API Keys"}),e.jsx(Y,{value:y,onChange:p,rows:4,placeholder:`${d.keyPlaceholder}
|
|
8
|
+
${d.keyPlaceholder}`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d.keyHelper})]})]}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(A,{htmlFor:"api-key",children:d.keyLabel}),e.jsx(k,{id:"api-key",type:"password",value:N,onChange:n=>U(n.target.value),placeholder:d.keyPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d.keyHelper})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold",children:"Optional routing"}),e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:"Only fill these when the route needs more than the default behavior."})]}),c?null:e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(A,{htmlFor:"base-url",children:"Base URL"}),e.jsx(k,{id:"base-url",value:b,onChange:n=>T(n.target.value),placeholder:d.baseUrlPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d.baseUrlHelper})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(A,{children:"Model Mappings"}),e.jsx(Y,{value:B,onChange:g,rows:4,placeholder:d.aliasesPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d.aliasesHelper})]})]}),e.jsx(Ge,{open:R,onOpenChange:P,children:e.jsxs("div",{className:"rounded-xl border",children:[e.jsx(Ve,{asChild:!0,children:e.jsxs("button",{type:"button",className:"flex w-full items-center justify-between gap-4 px-4 py-4 text-left",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(se,{className:"h-4 w-4 text-primary"}),"Advanced routing"]}),e.jsxs("div",{className:"mt-1 text-sm text-muted-foreground",children:["Headers",v?", proxy, prefix, and exclusions.":" and provider-specific overrides."]})]}),e.jsx(Ye,{className:K("h-4 w-4 text-muted-foreground transition-transform",R&&"rotate-180")})]})}),e.jsx(ze,{className:"border-t px-4 py-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(A,{children:"Headers"}),e.jsx(Y,{value:L,onChange:w,rows:3,placeholder:d.headersPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Use headers only when the provider requires extra routing or auth context."})]}),v?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(A,{htmlFor:"prefix",children:"Prefix"}),e.jsx(k,{id:"prefix",value:I,onChange:n=>J(n.target.value),placeholder:"glm-"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Prepends model names before routing."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(A,{htmlFor:"proxy-url",children:"Proxy URL"}),e.jsx(k,{id:"proxy-url",value:j,onChange:n=>O(n.target.value),placeholder:"http://127.0.0.1:8080"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Sends requests through an intermediate proxy."})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(A,{children:"Excluded Models"}),e.jsx(Y,{value:q,onChange:H,rows:3,placeholder:"claude-opus-4-1\\nclaude-sonnet-4-5"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. One model ID per line when this route should reject specific upstream models."})]})]}):null]})})]})})]}),e.jsxs(Je,{className:"border-t bg-muted/10 px-6 py-4",children:[e.jsx(f,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(f,{type:"button",onClick:()=>void F(),disabled:o,children:o?"Saving...":c?l?"Save Connector":"Create Connector":"Save Entry"})]})]})})})}const ne=["cliproxy-ai-providers"];function gs(){return is({queryKey:ne,queryFn:()=>re.cliproxy.aiProviders.list()})}function fs(){const t=xe();return he({mutationFn:({family:s,data:a})=>re.cliproxy.aiProviders.create(s,a),onSuccess:()=>{t.invalidateQueries({queryKey:ne}),G.success("Provider entry created")},onError:s=>{G.error(s.message)}})}function vs(){const t=xe();return he({mutationFn:({family:s,entryId:a,data:r})=>re.cliproxy.aiProviders.update(s,a,r),onSuccess:()=>{t.invalidateQueries({queryKey:ne}),G.success("Provider entry updated")},onError:s=>{G.error(s.message)}})}function ys(){const t=xe();return he({mutationFn:({family:s,entryId:a})=>re.cliproxy.aiProviders.delete(s,a),onSuccess:()=>{t.invalidateQueries({queryKey:ne}),G.success("Provider entry removed")},onError:s=>{G.error(s.message)}})}function _({label:t,value:s,hint:a}){return e.jsxs("div",{className:"rounded-lg border bg-background p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t}),e.jsx("div",{className:"mt-1 break-all text-sm font-medium leading-5",children:s}),a?e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:a}):null]})}function bs(t){switch(t){case"ready":return{label:"Ready",className:"bg-emerald-50 text-emerald-700 hover:bg-emerald-50"};case"partial":return{label:"Needs attention",className:"bg-amber-50 text-amber-700 hover:bg-amber-50"};default:return{label:"Empty",className:"bg-muted text-muted-foreground hover:bg-muted"}}}function de(t){return t.proxyUrl?"Proxy override":t.prefix?"Prefixed route":t.baseUrl?"Direct upstream":"Default runtime"}function Te(t){return t.filter(s=>s.alias.trim().length>0).length}function Re(t){return t.filter(s=>s.name.trim().length>0&&s.alias.trim().length===0).length}function te(t){const s=Te(t),a=Re(t),r=[];return s>0&&r.push(`${s} mapped`),a>0&&r.push(`${a} direct`),r.length>0?r.join(" + "):"No model rules"}function ce({configured:t}){return e.jsx(h,{variant:"secondary",className:K("border-transparent text-[10px]",t?"bg-emerald-50 text-emerald-700 hover:bg-emerald-50":"bg-muted text-muted-foreground hover:bg-muted"),children:t?"Configured":"Missing secret"})}const V="<stored in CLIProxy>";function Ee(t){switch(t.id){case"gemini-api-key":return{requiredNow:["Save the Gemini API key.","Leave Base URL blank unless you use a custom Gemini gateway.","Add model mappings only when Gemini model names differ from the requested ones."],optionalLater:["Headers for provider-specific project routing.","Base URL override for a proxy or regional endpoint.","Mappings such as claude-sonnet-4-5 -> gemini-2.5-pro."],emptyStateSummary:[`Requests to ${t.routePath} use CLIProxy-managed Gemini credentials.`,"The default upstream is enough for most Gemini setups.","Model mappings and headers are optional, not step one."],profileBoundary:"Use API Profiles when you want a CCS-native Anthropic-compatible profile instead of this CLIProxy-managed Gemini route.",editPrompts:[{label:"Base URL",hint:"Change it only for a custom Gemini gateway or regional endpoint."},{label:"Model mappings",hint:"Add them only when requested names and Gemini names differ."},{label:"Headers",hint:"Keep them empty unless the provider requires project or org routing."}]};case"codex-api-key":return{requiredNow:["Save the Codex or OpenAI API key.","Leave Base URL blank unless this route should hit a different OpenAI-style host.","Add mappings only when the upstream model name differs from what CCS requests."],optionalLater:["Base URL override for a gateway, proxy, or self-hosted endpoint.","Headers for org or project routing.","Mappings such as claude-sonnet-4-5 -> gpt-5."],emptyStateSummary:[`Requests to ${t.routePath} use CLIProxy-managed Codex credentials.`,"Most setups can keep the default upstream and skip extra routing.","Mappings are only needed when the upstream model naming does not match the requested one."],profileBoundary:"Use API Profiles when you want a CCS-native Anthropic-compatible profile rather than this CLIProxy-managed Codex route.",editPrompts:[{label:"Base URL",hint:"Change it only when Codex should resolve through another OpenAI-style endpoint."},{label:"Model mappings",hint:"Map requested model names to the exact upstream model ID only when needed."},{label:"Headers",hint:"Use headers sparingly for project routing or extra auth."}]};case"claude-api-key":return{requiredNow:["Save the Anthropic or compatible API key.","Leave Base URL blank unless this route should point at a custom Claude-compatible endpoint.","Add mappings only when the upstream model ID differs from the requested Claude model name."],optionalLater:["Prefix or proxy overrides for advanced route rewriting.","Excluded models when a route should block specific model IDs.","Headers for project-scoped routing."],emptyStateSummary:[`Requests to ${t.routePath} use a CLIProxy-managed Claude-compatible key.`,"Base URL, proxy, and prefix rewrites are advanced options, not the minimum setup.","Most users can start with a key only, then add mappings or filters if routing needs it."],profileBoundary:"Use API Profiles when you want a CCS-native Anthropic-compatible profile or preset instead of this CLIProxy-managed Claude route.",editPrompts:[{label:"Base URL",hint:"Change it only when Claude traffic should target another compatible endpoint."},{label:"Mappings",hint:"Add them only when the requested Claude model name should route to a different upstream ID."},{label:"Advanced routing",hint:"Proxy, prefix, headers, and exclusions are for edge cases. Leave them blank when unsure."}]};case"vertex-api-key":return{requiredNow:["Save the Vertex API key.","Leave Base URL blank unless a regional or gateway endpoint is required.","Add mappings only when the upstream model name differs from the requested name."],optionalLater:["Base URL override for a regional gateway.","Headers for provider-specific routing.","Mappings for translating requested names to Vertex model IDs."],emptyStateSummary:[`Requests to ${t.routePath} use CLIProxy-managed Vertex credentials.`,"Most setups start with the key only and keep the default endpoint.","Mappings and headers are optional follow-up steps."],profileBoundary:"Use API Profiles when you need a CCS-native Anthropic-compatible profile rather than this CLIProxy-managed Vertex route.",editPrompts:[{label:"Base URL",hint:"Use it only for a regional gateway or managed Vertex endpoint."},{label:"Model mappings",hint:"Add them only when the requested names need translating upstream."},{label:"Headers",hint:"Keep them empty unless the provider requires extra routing context."}]};case"openai-compatibility":return{requiredNow:["Name the connector, for example openrouter or together.","Set the connector Base URL.","Add at least one API key before saving."],optionalLater:["Headers for provider-specific auth or project routing.","Model mappings such as claude-sonnet-4-5 -> gpt-4.1.","Additional API keys for the same connector."],emptyStateSummary:[`Requests to ${t.routePath} resolve through a named OpenAI-compatible connector.`,"This flow needs a connector name, a Base URL, and one or more API keys.","Headers and mappings come after the connector is already working."],profileBoundary:"Use API Profiles when you want a CCS-native Anthropic-compatible profile, preset, or provider outside the CLIProxy connector flow.",editPrompts:[{label:"Connector identity",hint:"Keep the connector name and Base URL stable once clients depend on it."},{label:"Model mappings",hint:"Only add them when the connector expects a different upstream model ID."},{label:"Headers",hint:"Use them for provider-specific auth or project routing, not as a default."}]}}}function z(t){return t.split(`
|
|
9
|
+
`).map(s=>s.trim()).filter(s=>s.length>0)}function ae(t){return t.split(`
|
|
10
|
+
`).map(s=>s.trim()).filter(s=>s.length>0).map(s=>{const a=s.includes(":")?":":"=",[r,...i]=s.split(a);return{key:r.trim(),value:i.join(a).trim()}}).filter(s=>s.key.length>0)}function Q(t){return t.split(`
|
|
11
|
+
`).map(s=>s.trim()).filter(s=>s.length>0).map(s=>{const a=s.indexOf("=");return a===-1?{name:s.trim(),alias:""}:{name:s.slice(0,a).trim(),alias:s.slice(a+1).trim()}}).filter(s=>s.name.length>0||s.alias.length>0)}function js(t){return(t?.headers||[]).map(s=>`${s.key}: ${s.value}`).join(`
|
|
12
|
+
`)}function Ns(t){return(t?.excludedModels||[]).join(`
|
|
13
|
+
`)}function ws(t){return(t?.models||[]).map(s=>s.alias.trim()?`${s.name}=${s.alias}`:s.name).join(`
|
|
14
|
+
`)}function oe(t){return{name:t.name||"",baseUrl:t.baseUrl||"",proxyUrl:t.proxyUrl||"",prefix:t.prefix||"",headersText:js(t),excludedModelsText:Ns(t),modelAliasesText:ws(t),apiKey:"",apiKeysText:""}}function Cs(t){const s=ae(t);if(s.length!==0)return Object.fromEntries(s.map(a=>[a.key,a.value]))}function ks(t){const s=Q(t).map(a=>a.alias.trim()?{name:a.name,alias:a.alias}:{name:a.name});return s.length>0?s:void 0}function Ps(t){const s=z(t);return s.length>0?s:void 0}function Ce(t,s,a){const r=Cs(a.headersText),i=ks(a.modelAliasesText),o=Ps(a.excludedModelsText),d=a.apiKey.trim()||(s.secretConfigured?V:"");if(t.id==="openai-compatibility"){const l=z(a.apiKeysText),c=s.apiKeysMasked?.length||1;return{name:a.name.trim()||s.name||"connector","base-url":a.baseUrl.trim(),...r?{headers:r}:{},"api-key-entries":l.length>0?l.map(v=>({"api-key":v})):s.secretConfigured?Array.from({length:c},()=>({"api-key":V})):[],...i?{models:i}:{}}}return{"api-key":d,...a.baseUrl.trim()?{"base-url":a.baseUrl.trim()}:{},...a.proxyUrl.trim()?{"proxy-url":a.proxyUrl.trim()}:{},...a.prefix.trim()?{prefix:a.prefix.trim()}:{},...r?{headers:r}:{},...o?{"excluded-models":o}:{},...i?{models:i}:{}}}function As(t,s,a){const r=JSON.parse(a);if(!r||typeof r!="object"||Array.isArray(r))throw new Error("Raw config must be a JSON object.");if(t.id==="openai-compatibility"){const o=r,l=(Array.isArray(o["api-key-entries"])?o["api-key-entries"]:[]).map(c=>typeof c=="string"?c:c&&typeof c=="object"&&typeof c["api-key"]=="string"?c["api-key"]:"").filter(c=>c&&c!==V);return{name:typeof o.name=="string"?o.name:s.name||"",baseUrl:typeof o["base-url"]=="string"?o["base-url"]:"",proxyUrl:"",prefix:"",headersText:o.headers&&typeof o.headers=="object"&&!Array.isArray(o.headers)?Object.entries(o.headers).map(([c,v])=>`${c}: ${v}`).join(`
|
|
15
|
+
`):"",excludedModelsText:"",modelAliasesText:Array.isArray(o.models)?o.models.map(c=>c.alias?.trim()?`${c.name?.trim()||""}=${c.alias.trim()}`:c.name?.trim()||"").filter(Boolean).join(`
|
|
16
|
+
`):"",apiKey:"",apiKeysText:l.join(`
|
|
17
|
+
`)}}const i=r;return{name:"",baseUrl:typeof i["base-url"]=="string"?i["base-url"]:"",proxyUrl:typeof i["proxy-url"]=="string"?i["proxy-url"]:"",prefix:typeof i.prefix=="string"?i.prefix:"",headersText:i.headers&&typeof i.headers=="object"&&!Array.isArray(i.headers)?Object.entries(i.headers).map(([o,d])=>`${o}: ${d}`).join(`
|
|
18
|
+
`):"",excludedModelsText:Array.isArray(i["excluded-models"])?i["excluded-models"].join(`
|
|
19
|
+
`):"",modelAliasesText:Array.isArray(i.models)?i.models.map(o=>o.alias?.trim()?`${o.name?.trim()||""}=${o.alias.trim()}`:o.name?.trim()||"").filter(Boolean).join(`
|
|
20
|
+
`):"",apiKey:typeof i["api-key"]=="string"&&i["api-key"]!==V?i["api-key"]:"",apiKeysText:""}}function Ss(t,s,a){if(t.id==="openai-compatibility"){const o=z(a.apiKeysText),d=s.secretConfigured&&o.length===0;return{name:a.name.trim(),baseUrl:a.baseUrl.trim(),headers:ae(a.headersText),models:Q(a.modelAliasesText),preserveSecrets:d,...o.length>0?{apiKeys:o}:{}}}const r=a.apiKey.trim(),i=s.secretConfigured&&r.length===0;return{baseUrl:a.baseUrl.trim(),proxyUrl:a.proxyUrl.trim(),prefix:a.prefix.trim(),headers:ae(a.headersText),excludedModels:z(a.excludedModelsText),models:Q(a.modelAliasesText),preserveSecrets:i,...r.length>0?{apiKey:r}:{}}}function Is(t,s,a){const r={ANTHROPIC_BASE_URL:`${a.target}${t.routePath}`,ANTHROPIC_AUTH_TOKEN:"ccs-internal-managed"},i=Q(s.modelAliasesText).find(o=>o.name.trim());return i?.name&&(r.ANTHROPIC_MODEL=i.name),{env:r}}function ke({badge:t,title:s,items:a}){return e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(h,{variant:"secondary",className:"text-[11px]",children:t}),e.jsx("div",{className:"text-sm font-medium",children:s})]}),e.jsx("div",{className:"mt-4 space-y-3",children:a.map((r,i)=>e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border bg-muted/10 px-3 py-3",children:[e.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border bg-background text-[11px] font-semibold text-muted-foreground",children:i+1}),e.jsx("div",{className:"text-sm leading-6 text-muted-foreground",children:r})]},`${s}:${r}`))})]})}function M({label:t,helper:s,children:a}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:t}),a,s?e.jsx("div",{className:"text-xs leading-5 text-muted-foreground",children:s}):null]})}function Z({value:t,onChange:s,placeholder:a,rows:r=4}){return e.jsx("textarea",{rows:r,value:t,onChange:i=>s(i.target.value),placeholder:a,className:"flex min-h-24 w-full rounded-md border border-input bg-background px-3 py-2 text-sm shadow-xs outline-none transition-[color,box-shadow] placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50"})}function Us({family:t,entry:s,source:a,isSaving:r,onSave:i,onDelete:o}){const d=Ee(t),[l,c]=m.useState(()=>oe(s)),[v,S]=m.useState(null),[E,b]=m.useState(!0),[T,j]=m.useState(null),[O,I]=m.useState("config"),[J,N]=m.useState("raw"),U=m.useMemo(()=>JSON.stringify(Ce(t,s,oe(s)),null,2),[s,t]),y=m.useMemo(()=>JSON.stringify(Ce(t,s,l),null,2),[l,s,t]),p=v??y,L=m.useMemo(()=>Is(t,l,a),[l,t,a]),w=m.useMemo(()=>Q(l.modelAliasesText),[l.modelAliasesText]),q=m.useMemo(()=>ae(l.headersText),[l.headersText]),H=m.useMemo(()=>z(l.excludedModelsText),[l.excludedModelsText]),B=m.useMemo(()=>JSON.stringify(L,null,2),[L]),g=Te(w),R=Re(w),P=q.length+H.length+(l.proxyUrl.trim()?1:0)+(l.prefix.trim()?1:0),D=t.id==="openai-compatibility"?l.headersText.trim().length>0:!!(l.proxyUrl.trim()||l.prefix.trim()||l.headersText.trim()||l.excludedModelsText.trim()),F=v!==null?v!==U:y!==U,n=m.useMemo(()=>{if(t.id==="openai-compatibility"){const u=[];return l.name.trim()||u.push("name"),l.baseUrl.trim()||u.push("base-url"),!s.secretConfigured&&z(l.apiKeysText).length===0&&u.push("api-key-entries"),u}return!s.secretConfigured&&!l.apiKey.trim()?["api-key"]:[]},[l.apiKey,l.apiKeysText,l.baseUrl,l.name,s.secretConfigured,t.id]),$=E&&n.length===0&&F,C=u=>{c(x=>u(x)),S(null),b(!0),j(null)},ie=u=>{S(u);try{const x=As(t,s,u);c(x),b(!0),j(null)}catch(x){b(!1),j(x instanceof Error?x.message:"Invalid JSON")}},Oe=()=>{c(oe(s)),S(null),b(!0),j(null)},ge=u=>{C(x=>u==="minimal"?t.id==="openai-compatibility"?{...x,headersText:"",modelAliasesText:""}:{...x,baseUrl:"",proxyUrl:"",prefix:"",headersText:"",excludedModelsText:"",modelAliasesText:""}:{...x,proxyUrl:"",prefix:"",headersText:"",excludedModelsText:t.id==="openai-compatibility"?x.excludedModelsText:""})};return e.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-[minmax(360px,0.44fr)_minmax(0,0.56fr)] divide-x overflow-hidden rounded-b-xl border-x border-b bg-card",children:[e.jsx("div",{className:"min-h-0 overflow-hidden bg-muted/5",children:e.jsxs(ve,{value:O,onValueChange:I,className:"flex h-full flex-col",children:[e.jsxs("div",{className:"border-b bg-background px-4 pt-4",children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"truncate text-lg font-semibold",children:s.label}),e.jsx(ce,{configured:s.secretConfigured}),e.jsx(h,{variant:"outline",className:"uppercase",children:t.authMode})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(h,{variant:"outline",className:"font-mono text-[11px]",children:t.routePath}),e.jsx(h,{variant:"outline",className:"text-[11px]",children:de(s)}),e.jsx(h,{variant:"outline",className:"text-[11px]",children:a.label})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(f,{type:"button",size:"sm",variant:"outline",onClick:Oe,disabled:!F,children:[e.jsx(ss,{className:"mr-1 h-3.5 w-3.5"}),"Reset"]}),e.jsxs(f,{type:"button",size:"sm",variant:"outline",onClick:o,children:[e.jsx(ts,{className:"mr-1 h-3.5 w-3.5"}),"Remove"]}),e.jsxs(f,{type:"button",size:"sm",onClick:()=>void i(Ss(t,s,l)),disabled:!$||r,children:[e.jsx(as,{className:"mr-1 h-3.5 w-3.5"}),r?"Saving...":"Save"]})]})]}),e.jsxs(ye,{className:"grid w-full grid-cols-2",children:[e.jsxs(W,{value:"config",className:"gap-2 text-xs",children:[e.jsx(se,{className:"h-3.5 w-3.5"}),"Config"]}),e.jsxs(W,{value:"usage",className:"gap-2 text-xs",children:[e.jsx(je,{className:"h-3.5 w-3.5"}),"Info & Usage"]})]})]}),e.jsx(X,{value:"config",className:"mt-0 min-h-0 flex-1 overflow-hidden data-[state=inactive]:hidden",children:e.jsx(ee,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 p-5",children:[e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm font-medium",children:"Workspace presets"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Keep the route lean by default, then layer routing only when this entry actually needs it."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(f,{type:"button",size:"sm",variant:"outline",onClick:()=>ge("minimal"),children:"Minimal setup"}),e.jsx(f,{type:"button",size:"sm",variant:"outline",onClick:()=>ge("clean-routing"),children:"Clear routing noise"})]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 2xl:grid-cols-3",children:[e.jsx(_,{label:"Secret",value:s.secretConfigured?"Stored in CLIProxy":"Missing",hint:s.secretConfigured?"Rotate only when needed":"Required to save"}),e.jsx(_,{label:"Model Rules",value:w.length>0?te(w):"No model rules",hint:"Requested model names stay direct unless remapped"}),e.jsx(_,{label:"Advanced",value:P>0?`${P} active`:"Optional",hint:"Proxy, prefix, headers, and exclusions"})]})]}),n.length>0?e.jsxs("div",{className:"rounded-xl border border-amber-200 bg-amber-50/80 p-4 text-sm text-amber-900",children:["Missing required fields:"," ",e.jsx("span",{className:"font-mono",children:n.join(", ")})]}):null,e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"mb-4 flex items-center gap-2 text-sm font-medium",children:[e.jsx(pe,{className:"h-4 w-4 text-primary"}),"Connection"]}),e.jsxs("div",{className:"grid gap-4 2xl:grid-cols-2",children:[t.id==="openai-compatibility"?e.jsx(M,{label:"Connector Name",helper:"This is the saved connector label shown in the entry switcher.",children:e.jsx(k,{value:l.name,onChange:u=>C(x=>({...x,name:u.target.value})),placeholder:"openrouter"})}):e.jsx(M,{label:`${t.displayName} API Key`,helper:s.secretConfigured?"Leave blank to keep the stored secret. Enter a new value only to rotate it.":"Required before this route can authenticate.",children:e.jsx(k,{type:"password",value:l.apiKey,onChange:u=>C(x=>({...x,apiKey:u.target.value})),placeholder:s.secretConfigured?s.apiKeyMasked||V:"Paste provider API key"})}),t.id==="openai-compatibility"?e.jsx(M,{label:"API Keys",helper:s.secretConfigured?"One key per line. Leave empty to preserve the stored connector keys.":"Add one key per line. A connector needs at least one key.",children:e.jsx(Z,{value:l.apiKeysText,onChange:u=>C(x=>({...x,apiKeysText:u})),placeholder:"sk-...",rows:4})}):null,e.jsx(M,{label:"Base URL",helper:t.id==="openai-compatibility"?"Required for connectors. This is the upstream OpenAI-style endpoint.":"Leave blank unless this route should target another upstream host.",children:e.jsx(k,{value:l.baseUrl,onChange:u=>C(x=>({...x,baseUrl:u.target.value})),placeholder:t.id==="codex-api-key"?"https://api.openai.com/v1":t.id==="claude-api-key"?"https://api.anthropic.com":t.id==="openai-compatibility"?"https://openrouter.ai/api/v1":"https://provider.example.com"})}),t.id!=="openai-compatibility"?e.jsx(M,{label:"Proxy URL",helper:"Optional intermediary endpoint. Leave blank for direct routing.",children:e.jsx(k,{value:l.proxyUrl,onChange:u=>C(x=>({...x,proxyUrl:u.target.value})),placeholder:"https://proxy.example.com/v1"})}):null,t.id!=="openai-compatibility"?e.jsx(M,{label:"Prefix",helper:"Optional model prefix rewrite for advanced routing only.",children:e.jsx(k,{value:l.prefix,onChange:u=>C(x=>({...x,prefix:u.target.value})),placeholder:"provider/"})}):null]})]}),e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Ue,{className:"h-4 w-4 text-primary"}),"Model rules"]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[g>0?e.jsxs(h,{variant:"outline",children:[g," mapped"]}):null,R>0?e.jsxs(h,{variant:"outline",children:[R," direct"]}):null,w.length===0?e.jsx(h,{variant:"outline",children:"Optional"}):null]})]}),e.jsx(M,{label:"Requested [= Upstream]",helper:"Use requested=upstream for remaps. Use a plain model name when you want the route to expose that model directly.",children:e.jsx(Z,{value:l.modelAliasesText,onChange:u=>C(x=>({...x,modelAliasesText:u})),placeholder:`claude-sonnet-4-5=gpt-5
|
|
21
|
+
glm-5`,rows:6})})]}),e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(se,{className:"h-4 w-4 text-primary"}),"Advanced routing"]}),e.jsx(h,{variant:"outline",children:D?`${P} active`:"Optional"})]}),e.jsxs("div",{className:"grid gap-4 2xl:grid-cols-2",children:[e.jsx(M,{label:"Headers",helper:"One header per line. Use only when the upstream expects org, project, or secondary auth headers.",children:e.jsx(Z,{value:l.headersText,onChange:u=>C(x=>({...x,headersText:u})),placeholder:"OpenAI-Organization: org_...",rows:5})}),t.id!=="openai-compatibility"?e.jsx(M,{label:"Excluded Models",helper:"One model ID per line. These models will be blocked for this entry.",children:e.jsx(Z,{value:l.excludedModelsText,onChange:u=>C(x=>({...x,excludedModelsText:u})),placeholder:"claude-opus-4-1",rows:5})}):e.jsx("div",{className:"rounded-xl border border-dashed bg-muted/10 p-4 text-sm text-muted-foreground",children:"OpenAI-compatible connectors keep advanced routing lean. Add headers or model mappings first before introducing extra route layers elsewhere."})]})]})]})})}),e.jsx(X,{value:"usage",className:"mt-0 min-h-0 flex-1 overflow-hidden data-[state=inactive]:hidden",children:e.jsx(ee,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 p-5",children:[e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Le,{className:"h-4 w-4 text-primary"}),"How this route behaves"]}),e.jsxs("div",{className:"mt-3 space-y-3 text-sm leading-6 text-muted-foreground",children:[e.jsxs("div",{className:"rounded-lg border bg-muted/10 p-4",children:["Calls to ",e.jsx("span",{className:"font-mono",children:t.routePath})," use this saved entry inside CLIProxy."]}),e.jsx("div",{className:"rounded-lg border bg-muted/10 p-4",children:l.baseUrl.trim()?`Traffic resolves to ${l.baseUrl.trim()} unless you layer another proxy in front.`:"Traffic keeps the family default upstream unless you add a custom base URL."}),e.jsx("div",{className:"rounded-lg border bg-muted/10 p-4",children:w.length>0?`${te(w)} rule${w.length===1?"":"s"} active for this entry.`:"Requested model names pass through unchanged until you add explicit model rules."})]})]}),e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(je,{className:"h-4 w-4 text-primary"}),"When API Profiles fits better"]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:d.profileBoundary})]}),e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Me,{className:"h-4 w-4 text-primary"}),"Editing rule of thumb"]}),e.jsx("div",{className:"mt-3 space-y-3",children:d.editPrompts.map(u=>e.jsxs("div",{className:"rounded-lg border bg-muted/10 p-4",children:[e.jsx("div",{className:"text-sm font-medium",children:u.label}),e.jsx("div",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:u.hint})]},u.label))})]})]})})})]})}),e.jsx("div",{className:"min-h-0 overflow-hidden",children:e.jsxs(ve,{value:J,onValueChange:N,className:"flex h-full flex-col",children:[e.jsxs("div",{className:"border-b bg-background px-4 pt-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-sm font-medium",children:"Raw configuration"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Target ",e.jsx("span",{className:"font-mono",children:a.target})]})]}),e.jsxs(ye,{className:"grid w-full grid-cols-2",children:[e.jsxs(W,{value:"raw",className:"gap-2 text-xs",children:[e.jsx(rs,{className:"h-3.5 w-3.5"}),"Raw Entry Config"]}),e.jsxs(W,{value:"preview",className:"gap-2 text-xs",children:[e.jsx(ns,{className:"h-3.5 w-3.5"}),"settings.json Preview"]})]})]}),e.jsx(X,{value:"raw",className:"mt-0 min-h-0 flex-1 overflow-hidden data-[state=inactive]:hidden",children:e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx("div",{className:"border-b bg-muted/10 px-6 py-3 text-sm text-muted-foreground",children:s.secretConfigured?`Stored secrets are shown as ${V}. Replace the placeholder only when you want to rotate the secret.`:"Add secrets directly in the JSON or use the form on the left."}),T?e.jsx("div",{className:"mx-6 mt-4 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:T}):null,e.jsx("div",{className:"min-h-0 flex-1 px-6 pb-4 pt-4",children:e.jsx("div",{className:"h-full overflow-hidden rounded-md border bg-background",children:e.jsx(be,{value:p,onChange:ie,language:"json",minHeight:"100%"})})})]})}),e.jsx(X,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden data-[state=inactive]:hidden",children:e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx("div",{className:"border-b bg-muted/10 px-6 py-3 text-sm text-muted-foreground",children:"Derived preview for a CCS profile that points to this CLIProxy route. The route stays local; the upstream key remains managed here."}),e.jsx("div",{className:"min-h-0 flex-1 px-6 pb-4 pt-4",children:e.jsx("div",{className:"h-full overflow-hidden rounded-md border bg-background",children:e.jsx(be,{value:B,onChange:()=>{},language:"json",readonly:!0,minHeight:"100%"})})}),e.jsx("div",{className:"mx-6 mb-4 overflow-hidden rounded-md border",children:e.jsx(_e,{profileEnv:L.env})})]})})]})})]})}function Ls({family:t,onAddEntry:s,onOpenControlPanel:a,onOpenProfiles:r}){const i=Ee(t),o=t.supportsNamedEntries?"Create connector":`Add ${t.displayName} entry`;return e.jsx("div",{className:"space-y-5",children:e.jsxs("div",{className:"grid gap-5 2xl:grid-cols-[minmax(0,1fr)_320px]",children:[e.jsxs("div",{className:"rounded-xl border bg-card",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 border-b px-5 py-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-muted",children:e.jsx(pe,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-lg font-semibold",children:["Set up ",t.displayName]}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Start with the smallest working setup. Add routing rules only after the route is already working."})]})]}),e.jsxs(f,{type:"button",onClick:s,children:[e.jsx(Se,{className:"mr-1 h-4 w-4"}),o]})]}),e.jsxs("div",{className:"space-y-4 p-5",children:[e.jsxs("div",{className:"rounded-xl border bg-muted/10 p-4",children:[e.jsx("div",{className:"text-sm font-medium",children:"Recommended setup flow"}),e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:"Finish the left section first. Treat the right section as optional follow-up."}),e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsx(ke,{badge:"Do this first",title:"Minimum working setup",items:i.requiredNow}),e.jsx(ke,{badge:"Only if needed",title:"Optional later",items:i.optionalLater})]})]}),e.jsxs("div",{className:"rounded-xl border bg-muted/15 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Me,{className:"h-4 w-4 text-emerald-600"}),"Need the other pages?"]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:"Use Overview or Control Panel for OAuth sign-ins. Use API Profiles only for CCS-native Anthropic-compatible profiles and presets."}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(f,{type:"button",size:"sm",variant:"outline",onClick:a,children:"Control Panel"}),e.jsxs(f,{type:"button",size:"sm",variant:"outline",onClick:r,children:["API Profiles",e.jsx(Ie,{className:"ml-1 h-3.5 w-3.5"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl border bg-card p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Le,{className:"h-4 w-4 text-primary"}),"What this route does"]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(h,{variant:"outline",className:"font-mono text-[11px]",children:t.routePath}),e.jsx(h,{variant:"outline",className:"uppercase text-[11px]",children:t.authMode})]}),e.jsx("div",{className:"mt-4 space-y-3",children:i.emptyStateSummary.map(d=>e.jsx("div",{className:"rounded-lg border bg-muted/10 p-4 text-sm leading-6 text-muted-foreground",children:d},d))})]}),e.jsxs("div",{className:"rounded-xl border bg-card p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Ue,{className:"h-4 w-4 text-primary"}),"When API Profiles is the better fit"]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:i.profileBoundary})]})]})]})})}function Gs(){const t=qe(),s=$e(),{data:a,error:r,isLoading:i,isFetching:o,refetch:d}=gs(),l=fs(),c=vs(),v=ys(),[S,E]=m.useState(!1),[b,T]=m.useState(null),[j,O]=m.useState(null),[I,J]=m.useState(null),N=m.useMemo(()=>a?.families??[],[a?.families]),U=m.useMemo(()=>new URLSearchParams(t.search).get("family")||null,[t.search]),y=m.useMemo(()=>U&&N.some(n=>n.id===U)?U:N[0]?.id??"gemini-api-key",[N,U]),p=m.useMemo(()=>N.find(n=>n.id===y)||null,[N,y]),L=m.useMemo(()=>{const n=p?.entries??[];return n.length===0?null:I&&n.some($=>$.id===I)?I:n[0]?.id??null},[I,p?.entries]),w=n=>{s({pathname:t.pathname,search:`?family=${n}`},{replace:!0})},q=()=>{T(null),E(!0)};if(i)return e.jsxs("div",{className:"flex h-[calc(100vh-100px)] min-h-0",children:[e.jsx(fe,{className:"h-full w-80 rounded-none"}),e.jsx(fe,{className:"h-full flex-1 rounded-none"})]});if(r||!a||!p){const n=r instanceof Error?r.message:"Failed to load CLIProxy AI providers. Check the local server and try again.";return e.jsx("div",{className:"flex h-[calc(100vh-100px)] min-h-0 items-center justify-center bg-muted/10 p-6",children:e.jsx("div",{className:"w-full max-w-2xl rounded-xl border bg-card p-6 shadow-sm",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-11 w-11 items-center justify-center rounded-lg bg-destructive/10",children:e.jsx(Pe,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-lg font-semibold",children:"Unable to load AI Providers"}),e.jsx("div",{className:"mt-2 text-sm text-muted-foreground",children:n}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsxs(f,{type:"button",onClick:()=>void d(),children:[e.jsx(le,{className:"mr-2 h-4 w-4"}),"Retry"]}),e.jsx(f,{type:"button",variant:"outline",onClick:()=>s("/cliproxy/control-panel"),children:"Control Panel"}),e.jsx(f,{type:"button",variant:"outline",onClick:()=>s("/providers"),children:"API Profiles"})]})]})]})})})}const H=p.entries.filter(n=>n.secretConfigured),B=N.filter(n=>n.status==="ready").length,g=p.entries.find(n=>n.id===L)??null,R=p.entries.length>1,P=bs(p.status),D=p.entries.length>0,F=e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:"Setup status"}),e.jsx("div",{className:"mt-1 text-sm font-medium",children:p.routePath})]}),e.jsx(h,{variant:"secondary",className:P.className,children:P.label})]}),e.jsxs("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:[e.jsx(_,{label:"Entries",value:`${p.entries.length}`,hint:"configured rows"}),e.jsx(_,{label:"Secrets",value:`${H.length}/${p.entries.length||0}`,hint:"stored in CLIProxy"})]}),e.jsx("div",{className:"mt-3 rounded-lg border bg-muted/15 p-3 text-xs leading-5 text-muted-foreground",children:"Overview handles OAuth sign-ins. This page stores CLIProxy-managed keys and connectors. API Profiles remains for CCS-native Anthropic-compatible profiles."})]});return e.jsxs("div",{className:"flex h-[calc(100vh-100px)] min-h-0",children:[e.jsxs("div",{className:"flex w-80 flex-col border-r bg-muted/30",children:[e.jsxs("div",{className:"border-b bg-background p-4",children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ze,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:"CLIProxy Plus"})]}),e.jsx(f,{variant:"ghost",size:"icon",className:"h-8 w-8",type:"button",onClick:()=>void d(),disabled:o,children:e.jsx(le,{className:K("h-4 w-4",o&&"animate-spin")})})]}),e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"AI Providers"}),e.jsxs(f,{variant:"default",size:"sm",className:"w-full gap-2",type:"button",onClick:q,children:[e.jsx(Se,{className:"h-4 w-4"}),p.supportsNamedEntries?"Create Connector":`Add ${p.displayName} Entry`]})]}),e.jsx(ee,{className:"flex-1",children:e.jsxs("div",{className:"p-2",children:[e.jsx("div",{className:"px-3 py-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Provider Families"}),e.jsx(os,{families:N,selectedFamily:y,onSelect:w})]})}),e.jsx("div",{className:"border-t p-3",children:e.jsx(Qe,{})}),e.jsx("div",{className:"border-t bg-background p-3 text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{children:[N.length," families"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ae,{className:"h-3 w-3 text-emerald-600"}),B," ready"]})]})})]}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col bg-background",children:[e.jsx("div",{className:"shrink-0 border-b bg-background px-6 py-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(me,{provider:ue(p.id),size:"lg"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:p.displayName}),e.jsx(h,{variant:"secondary",className:P.className,children:P.label}),e.jsx(h,{variant:"outline",className:"uppercase",children:p.authMode}),e.jsx(h,{variant:"outline",className:"font-mono text-[11px]",children:p.routePath})]}),e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:p.description})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(f,{type:"button",variant:"ghost",size:"sm",onClick:()=>void d(),disabled:o,children:e.jsx(le,{className:K("h-4 w-4",o&&"animate-spin")})}),e.jsx(f,{type:"button",variant:"outline",onClick:()=>s("/cliproxy/control-panel"),children:"Control Panel"}),e.jsxs(f,{type:"button",variant:"outline",onClick:()=>s("/providers"),children:["API Profiles",e.jsx(Ie,{className:"ml-1 h-3.5 w-3.5"})]})]})]})}),D?e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 border-b bg-muted/5 px-6 py-4",children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:[e.jsx(es,{className:"h-3 w-3"}),R?"Saved entries":"Saved entry"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(h,{variant:"outline",className:"text-[11px]",children:[p.entries.length," entries"]}),e.jsxs(h,{variant:"outline",className:"text-[11px]",children:[H.length,"/",p.entries.length," secrets stored"]})]})]}),R?e.jsx("div",{className:"flex flex-wrap gap-3",children:p.entries.map(n=>e.jsxs("button",{type:"button",onClick:()=>J(n.id),className:K("min-w-[220px] max-w-[280px] flex-1 rounded-xl border bg-background px-4 py-3 text-left transition-colors",n.id===L?"border-primary/30 bg-primary/5 shadow-sm":"border-border/60 hover:bg-muted/50"),children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:n.label}),e.jsx(ce,{configured:n.secretConfigured})]}),e.jsx("div",{className:"mt-2 truncate text-xs text-muted-foreground",children:n.baseUrl||p.routePath}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[e.jsx(h,{variant:"outline",className:"text-[10px]",children:de(n)}),n.models.length>0?e.jsx(h,{variant:"outline",className:"text-[10px]",children:te(n.models)}):null,e.jsxs(h,{variant:"outline",className:"text-[10px]",children:[n.headers.length," hdr"]})]})]},n.id))}):g?e.jsx("div",{className:"rounded-xl border bg-background px-4 py-3",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:g.label}),e.jsx(ce,{configured:g.secretConfigured})]}),e.jsx("div",{className:"mt-1 truncate text-xs text-muted-foreground",children:g.baseUrl||p.routePath})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(h,{variant:"outline",className:"text-[10px]",children:de(g)}),g.models.length>0?e.jsx(h,{variant:"outline",className:"text-[10px]",children:te(g.models)}):null,e.jsxs(h,{variant:"outline",className:"text-[10px]",children:[g.headers.length," hdr"]})]})]})}):null]}),g?e.jsx(Us,{family:p,entry:g,source:a.source,isSaving:c.isPending,onSave:async n=>{await c.mutateAsync({family:y,entryId:g.id,data:n}),d()},onDelete:()=>O(g)},g.id):null]}):e.jsx(ee,{className:"flex-1",children:e.jsxs("div",{className:"space-y-6 p-6",children:[F,e.jsx(Ls,{family:p,onAddEntry:q,onOpenControlPanel:()=>s("/cliproxy/control-panel"),onOpenProfiles:()=>s("/providers")})]})})]}),e.jsx(hs,{family:y,entry:b,open:S,onOpenChange:E,onSubmit:async n=>{b?await c.mutateAsync({family:y,entryId:b.id,data:n}):await l.mutateAsync({family:y,data:n}),E(!1),T(null),d()},isSaving:l.isPending||c.isPending},`${y}:${b?.id??"new"}:${S?"open":"closed"}`),e.jsx(We,{open:j!==null,title:"Remove provider entry?",description:j?`This removes ${j.label} from ${p.displayName}.`:"",confirmText:"Remove",variant:"destructive",onConfirm:async()=>{j&&(await v.mutateAsync({family:y,entryId:j.id}),O(null))},onCancel:()=>O(null)})]})}export{Gs as CliproxyAiProvidersPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as s}from"./react-vendor-CNOkPC89.js";import{u as w}from"./tanstack-B8i0evp-.js";import{Y as U,b0 as A}from"./index-sCtK1kDn.js";import{C as P}from"./default-ports-1QQSffYX.js";import{G as M,R as k,x as q}from"./icons-DR-ORtNe.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function F({port:a=P}){const l=s.useRef(null),[L,g]=s.useState(null),[$,R]=s.useState(0),[y,c]=s.useState(null),[E,i]=s.useState(!1),{data:b,error:x}=w({queryKey:["cliproxy-server-config"],queryFn:()=>U.cliproxyServer.get(),staleTime:3e4}),{data:j}=w({queryKey:["auth-tokens-raw"],queryFn:async()=>{const t=await fetch(A("/settings/auth/tokens/raw"));if(!t.ok)throw new Error("Failed to fetch auth tokens");return t.json()},staleTime:3e4});s.useEffect(()=>{x&&console.warn("[ControlPanelEmbed] Config fetch failed, using local mode:",x)},[x]);const{managementUrl:n,checkUrl:m,authToken:h,isRemote:d,displayHost:u}=s.useMemo(()=>{const t=b?.remote;if(t?.enabled&&t?.host){const o=t.protocol||"http",r=t.port||(o==="https"?443:P),N=o==="https"&&r===443||o==="http"&&r===80?"":`:${r}`,v=`${o}://${t.host}${N}`;return{managementUrl:`${v}/management.html`,checkUrl:`${v}/`,authToken:t.auth_token||void 0,isRemote:!0,displayHost:`${t.host}${N}`}}const f=j?.managementSecret?.value||"ccs";return{managementUrl:`http://localhost:${a}/management.html`,checkUrl:`http://localhost:${a}/`,authToken:f,isRemote:!1,displayHost:`localhost:${a}`}},[b,j,a]),p=L===n,I=!p;s.useEffect(()=>{const t=new AbortController,f=async()=>{try{(await fetch(m,{signal:t.signal})).ok?(i(!0),c(null)):(i(!1),c(d?`Remote CLIProxy at ${u} returned an error`:"CLIProxy returned an error"))}catch(r){if(r instanceof Error&&r.name==="AbortError")return;i(!1),c(d?`Remote CLIProxy at ${u} is not reachable`:"CLIProxy is not running")}},o=setTimeout(()=>t.abort(),2e3);return f().finally(()=>clearTimeout(o)),()=>t.abort()},[m,d,u]);const C=s.useCallback(()=>{if(!(!p||!l.current?.contentWindow||!h))try{const t=m.replace(/\/$/,"");if(!l.current.src.startsWith(t)){console.warn("[ControlPanelEmbed] Iframe origin mismatch, skipping postMessage");return}l.current.contentWindow.postMessage({type:"ccs-auto-login",apiBase:t,managementKey:h},t)}catch(t){console.debug("[ControlPanelEmbed] postMessage failed - cross-origin:",t)}},[h,m,p]);s.useEffect(()=>{C()},[C]);const S=s.useCallback(()=>{g(n)},[n]),T=()=>{g(null),R(t=>t+1),c(null),i(!1)};return!E&&y?e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(M,{className:"w-5 h-5 text-primary"}),e.jsx("h2",{className:"font-semibold",children:"CLIProxy Control Panel"})]}),e.jsxs("button",{className:"inline-flex items-center gap-2 px-3 py-1.5 text-sm border rounded-md hover:bg-muted",onClick:T,children:[e.jsx(k,{className:"w-4 h-4"}),"Retry"]})]}),e.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/20",children:e.jsxs("div",{className:"text-center max-w-md px-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-destructive/10 flex items-center justify-center mx-auto mb-6",children:e.jsx(q,{className:"w-8 h-8 text-destructive"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"CLIProxy Not Available"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:y}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Start a CLIProxy session with"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs gemini"})," or run"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs config"})," which auto-starts it."]})]})})]}):e.jsx("div",{className:"flex-1 flex flex-col",children:e.jsxs("div",{className:"flex-1 flex flex-col relative",children:[I&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/80 z-10",children:e.jsxs("div",{className:"text-center",children:[e.jsx(k,{className:"w-8 h-8 animate-spin text-primary mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d?`Loading Control Panel from ${u}...`:"Loading Control Panel..."})]})}),e.jsx("iframe",{ref:l,src:n,className:"flex-1 w-full border-0",title:"CLIProxy Management Panel",onLoad:S},`${n}:${$}`)]})})}function Q(){return e.jsx("div",{className:"h-[calc(100vh-100px)] flex flex-col",children:e.jsx(F,{})})}export{Q as CliproxyControlPanelPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Dt3edmE5.js";import{A as c,a as d,b as g,c as x,d as h,e as j,f as A,g as D}from"./alert-dialog-
|
|
1
|
+
import{j as e}from"./radix-ui-Dt3edmE5.js";import{A as c,a as d,b as g,c as x,d as h,e as j,f as A,g as D}from"./alert-dialog-CwEJfEUX.js";function f({open:i,onConfirm:l,onCancel:r,title:s,description:t,confirmText:a="Confirm",variant:o="default"}){return e.jsx(c,{open:i,onOpenChange:n=>!n&&r(),children:e.jsxs(d,{children:[e.jsxs(g,{children:[e.jsx(x,{children:s}),e.jsx(h,{children:t})]}),e.jsxs(j,{children:[e.jsx(A,{onClick:r,children:"Cancel"}),e.jsx(D,{onClick:l,className:o==="destructive"?"bg-red-600 hover:bg-red-700 text-white":"",children:a})]})]})})}export{f as C};
|