@kaitranntt/ccs 7.61.1 → 7.62.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/services/profile-lifecycle-service.d.ts.map +1 -1
- package/dist/api/services/profile-lifecycle-service.js +17 -3
- package/dist/api/services/profile-lifecycle-service.js.map +1 -1
- package/dist/api/services/profile-writer.d.ts.map +1 -1
- package/dist/api/services/profile-writer.js +29 -4
- package/dist/api/services/profile-writer.js.map +1 -1
- package/dist/ccs.js +3 -3
- package/dist/ccs.js.map +1 -1
- package/dist/cliproxy/binary/installer.d.ts.map +1 -1
- package/dist/cliproxy/binary/installer.js +32 -7
- package/dist/cliproxy/binary/installer.js.map +1 -1
- package/dist/cliproxy/config/generator.d.ts +2 -1
- package/dist/cliproxy/config/generator.d.ts.map +1 -1
- package/dist/cliproxy/config/generator.js +3 -1
- package/dist/cliproxy/config/generator.js.map +1 -1
- package/dist/cliproxy/config/thinking-config.d.ts +1 -1
- package/dist/cliproxy/config/thinking-config.js +1 -1
- package/dist/cliproxy/executor/index.d.ts.map +1 -1
- package/dist/cliproxy/executor/index.js +7 -1
- package/dist/cliproxy/executor/index.js.map +1 -1
- package/dist/cliproxy/model-catalog.d.ts +5 -0
- package/dist/cliproxy/model-catalog.d.ts.map +1 -1
- package/dist/cliproxy/model-catalog.js +32 -8
- package/dist/cliproxy/model-catalog.js.map +1 -1
- package/dist/cliproxy/quota-fetcher-gemini-cli.d.ts.map +1 -1
- package/dist/cliproxy/quota-fetcher-gemini-cli.js +7 -2
- package/dist/cliproxy/quota-fetcher-gemini-cli.js.map +1 -1
- package/dist/cliproxy/services/variant-settings.d.ts.map +1 -1
- package/dist/cliproxy/services/variant-settings.js +38 -5
- package/dist/cliproxy/services/variant-settings.js.map +1 -1
- package/dist/commands/docker/up-subcommand.d.ts.map +1 -1
- package/dist/commands/docker/up-subcommand.js +3 -0
- package/dist/commands/docker/up-subcommand.js.map +1 -1
- package/dist/docker/docker-bootstrap.js +18 -0
- package/dist/docker/docker-bootstrap.js.map +1 -1
- package/dist/docker/docker-executor.d.ts.map +1 -1
- package/dist/docker/docker-executor.js +16 -11
- package/dist/docker/docker-executor.js.map +1 -1
- package/dist/shared/gemini-minor-version-compatibility.d.ts +11 -0
- package/dist/shared/gemini-minor-version-compatibility.d.ts.map +1 -0
- package/dist/shared/gemini-minor-version-compatibility.js +14 -0
- package/dist/shared/gemini-minor-version-compatibility.js.map +1 -0
- package/dist/ui/assets/{accounts-DMUoqqhT.js → accounts-m0p6IBoA.js} +1 -1
- package/dist/ui/assets/{alert-dialog-B_dqaWsT.js → alert-dialog-BZ6JV1c0.js} +1 -1
- package/dist/ui/assets/{api-CIyeonZ1.js → api-Dtl8GVR9.js} +1 -1
- package/dist/ui/assets/{auth-section-D_TfW2-_.js → auth-section-FODNJaQ2.js} +1 -1
- package/dist/ui/assets/{backups-section-Dgydey89.js → backups-section-CneYf6OW.js} +1 -1
- package/dist/ui/assets/{channels-spHiV1Ue.js → channels-CSBFhO0j.js} +1 -1
- package/dist/ui/assets/{checkbox-jhdR_fIK.js → checkbox-CJ-YurJ7.js} +1 -1
- package/dist/ui/assets/{claude-extension-C8W6Yb3R.js → claude-extension-B92RrQBM.js} +1 -1
- package/dist/ui/assets/cliproxy-D5aRH37D.js +3 -0
- package/dist/ui/assets/{cliproxy-ai-providers-VAxFHC4K.js → cliproxy-ai-providers-B4-qQbF8.js} +1 -1
- package/dist/ui/assets/{cliproxy-control-panel-Bd80kVsY.js → cliproxy-control-panel-w2F2zCtp.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-BE-5hP8L.js → confirm-dialog-DIuIPwxn.js} +1 -1
- package/dist/ui/assets/{copilot-BTZxWOED.js → copilot-uJ6AImjB.js} +1 -1
- package/dist/ui/assets/{cursor-l2ZM09W9.js → cursor-NUW-BOKQ.js} +1 -1
- package/dist/ui/assets/{droid-BWdAXhtv.js → droid-DhPJNIUW.js} +1 -1
- package/dist/ui/assets/{globalenv-section-C84bxTwY.js → globalenv-section-C2b6kJ0Y.js} +1 -1
- package/dist/ui/assets/{health-ow5fF7nc.js → health-DDnBMaVh.js} +1 -1
- package/dist/ui/assets/{index-BSRCIA1G.js → index-BXZ7G8jm.js} +1 -1
- package/dist/ui/assets/{index-CWIXuEF6.js → index-D8BejENh.js} +1 -1
- package/dist/ui/assets/{index-iR1nbsvS.js → index-UpcLnXXT.js} +1 -1
- package/dist/ui/assets/{index-DqflCpiA.js → index-hU8FFwHq.js} +1 -1
- package/dist/ui/assets/{index-lttPkZpv.js → index-jRf9TX0x.js} +3 -3
- package/dist/ui/assets/{masked-input-VQBwZqNw.js → masked-input-Cxw4W898.js} +1 -1
- package/dist/ui/assets/{proxy-status-widget-CoE2yaWW.js → proxy-status-widget-CtV1jNBS.js} +1 -1
- package/dist/ui/assets/{searchable-select-z_lKd8bq.js → searchable-select-alvnHZb-.js} +1 -1
- package/dist/ui/assets/{separator-DL9wgY_Q.js → separator-D_QkAzrO.js} +1 -1
- package/dist/ui/assets/{shared-BtcUBeFK.js → shared-RtaBZIic.js} +1 -1
- package/dist/ui/assets/{switch-hUEOHCrU.js → switch-wk_QOO2s.js} +1 -1
- package/dist/ui/assets/{updates-D2jZT4GP.js → updates-JpNSqNks.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/dist/utils/websearch/hook-installer.d.ts +2 -0
- package/dist/utils/websearch/hook-installer.d.ts.map +1 -1
- package/dist/utils/websearch/hook-installer.js +68 -6
- package/dist/utils/websearch/hook-installer.js.map +1 -1
- package/dist/utils/websearch/index.d.ts +2 -2
- package/dist/utils/websearch/index.d.ts.map +1 -1
- package/dist/utils/websearch/index.js +3 -2
- package/dist/utils/websearch/index.js.map +1 -1
- package/dist/utils/websearch/profile-hook-injector.d.ts +1 -4
- package/dist/utils/websearch/profile-hook-injector.d.ts.map +1 -1
- package/dist/utils/websearch/profile-hook-injector.js +42 -30
- package/dist/utils/websearch/profile-hook-injector.js.map +1 -1
- package/dist/utils/websearch-manager.d.ts +2 -2
- package/dist/utils/websearch-manager.d.ts.map +1 -1
- package/dist/utils/websearch-manager.js +3 -2
- package/dist/utils/websearch-manager.js.map +1 -1
- package/dist/web-server/health/cliproxy-checks.d.ts +4 -0
- package/dist/web-server/health/cliproxy-checks.d.ts.map +1 -1
- package/dist/web-server/health/cliproxy-checks.js +29 -14
- package/dist/web-server/health/cliproxy-checks.js.map +1 -1
- package/dist/web-server/model-pricing.d.ts.map +1 -1
- package/dist/web-server/model-pricing.js +10 -0
- package/dist/web-server/model-pricing.js.map +1 -1
- package/dist/web-server/routes/auth-routes.d.ts.map +1 -1
- package/dist/web-server/routes/auth-routes.js +6 -1
- package/dist/web-server/routes/auth-routes.js.map +1 -1
- package/package.json +1 -1
- package/scripts/github/ccs-backlog-sync-lib.mjs +379 -0
- package/scripts/github/ccs-backlog-sync.mjs +6 -0
- package/dist/ui/assets/cliproxy-DS6LvM1n.js +0 -3
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as c}from"./react-vendor-CNOkPC89.js";import{a as Je,u as ws,b as Ys}from"./tanstack-B8i0evp-.js";import{a8 as Zs,d as I,C as bs,b as ys,c as B,P as Ee,a as ee,a9 as se,L as Z,I as ce,r as Cs,s as ks,t as As,v as Ps,w as Ge,aa as Ss,ab as et,ac as st,ad as tt,u as Ms,ae as We,af as Xe,ag as Ye,ah as Ze,ai as Ts,aj as rs,ak as at,al as nt,W as Ds,am as Ve,an as Es,Y as Me,B as G,ao as Be,ap as os,aq as it,ar as rt,as as ot,at as lt,au as ct,av as ls,aw as dt,x as Rs,n as es,ax as ss,ay as cs,az as ut,m as mt,aA as pt,aB as xt,aC as ht,aD as gt,aE as ft,aF as vt,aG as jt,aH as Nt,aI as fe,T as ve,p as je,q as Ne,aJ as wt,aK as bt,aL as yt,aM as ds,aN as Ct,aO as kt,aP as At,aQ as Pt,aR as St,aS as Mt,aT as Tt,Q as Dt,R as Et,U as us,V as ms,aU as Rt,aV as _t,aW as Ot,aX as It,aY as Lt,aZ as Ft,a_ as Ut,a$ as qt,b0 as Ht,b1 as Kt,b2 as Gt,b3 as Vt,S as Bt}from"./index-jRf9TX0x.js";import{C as ze}from"./default-ports-1QQSffYX.js";import{t as H}from"./notifications-B2HqRBj7.js";import{C as _s,L as W,o as me,Q as zt,l as de,n as Os,au as ts,R as as,p as pe,a4 as ye,T as Re,a2 as Qt,av as Is,at as $t,aw as _e,Z as Ce,O as Ls,h as Jt,t as Fs,ax as Wt,ak as Xt,X as ns,a3 as Us,m as Yt,x as Zt,y as qs,z as Qe,ay as ea,u as ps,az as sa,aj as Hs,v as ta,aA as xs,an as aa,aB as Ks}from"./icons-EbXCUruD.js";import{R as Te,A as hs,D as qe,i as na,a as ia}from"./antigravity-responsibility-constants-Bvh4Ybz0.js";import{C as De}from"./checkbox-CJ-YurJ7.js";import{C as ra}from"./confirm-dialog-DIuIPwxn.js";import{S as is}from"./separator-D_QkAzrO.js";import{S as oa}from"./searchable-select-alvnHZb-.js";import{S as Gs}from"./switch-wk_QOO2s.js";import{P as la}from"./proxy-status-widget-CtV1jNBS.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-BZ6JV1c0.js";const Vs=Object.freeze({"gemini-3-pro-preview":"gemini-3.1-pro-preview","gemini-3.1-pro-preview":"gemini-3-pro-preview","gemini-3-flash-preview":"gemini-3.1-flash-preview","gemini-3.1-flash-preview":"gemini-3-flash-preview"}),ca=/^gemini-(\d+(?:[.-]\d+)*)-(pro|flash)-preview(-customtools)?$/i;function be(s){return Zs(s).toLowerCase()}function Oe(s){const t=be(s),a=t.match(ca);if(!a)return null;const[,n,i,l]=a;return{normalizedId:t,version:n.split(/[.-]/).map(u=>Number(u)),family:i,customtools:!!l,dottedVersion:n.includes(".")}}function Bs(s,t){const a=Math.max(s.length,t.length);for(let n=0;n<a;n+=1){const i=s[n]??0,l=t[n]??0;if(i!==l)return i>l?1:-1}return 0}function da(s,t,a){if(s.customtools!==t.customtools)return s.customtools?1:-1;const n=Bs(s.version,t.version);if(n!==0)return n>0?-1:1;const i=+(s.dottedVersion===a.dottedVersion),l=+(t.dottedVersion===a.dottedVersion);return i!==l?l-i:s.normalizedId.localeCompare(t.normalizedId)}function gs(s,t){const a=be(t);return s.find(n=>be(n.id)===a)?.id}function ua(s,t){const a=Oe(s);return!a||t.length===0?void 0:t.map(i=>{const l=Oe(i.id);return!l||l.family!==a.family?null:{id:i.id,info:l}}).filter(i=>!!i).sort((i,l)=>da(i.info,l.info,a))[0]?.id}const xe={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.1-pro-preview",name:"Gemini Pro",description:"Resolves to the best advertised Gemini Pro preview via Antigravity",extendedContext:!0,presetMapping:{default:"gemini-3.1-pro-preview",opus:"gemini-3.1-pro-preview",sonnet:"gemini-3.1-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini Flash",description:"Resolves to the best advertised Gemini Flash preview via Antigravity",extendedContext:!0,presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3.1-pro-preview",sonnet:"gemini-3.1-pro-preview",haiku:"gemini-3-flash-preview"}}]},gemini:{provider:"gemini",displayName:"Gemini",defaultModel:"gemini-2.5-pro",models:[{id:"gemini-3.1-pro-preview",name:"Gemini Pro",tier:"paid",description:"Uses the best advertised Gemini Pro preview when Google exposes one",extendedContext:!0,presetMapping:{default:"gemini-3.1-pro-preview",opus:"gemini-3.1-pro-preview",sonnet:"gemini-3.1-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini Flash",tier:"paid",description:"Uses the best advertised Gemini Flash preview when Google exposes one",extendedContext:!0,presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3.1-pro-preview",sonnet:"gemini-3.1-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"}]}};function zs(s,t){const a=xe[s.toLowerCase()];if(!a)return;const n=be(t),i=Vs[n.toLowerCase()],l=a.models.find(o=>o.id===n||o.id===i);if(l)return l;const u=Oe(n);if(u)return a.models.map(o=>({model:o,info:Oe(o.id)})).filter(o=>!!(o.info&&o.info.family===u.family)).sort((o,r)=>Bs(r.info.version,o.info.version))[0]?.model}function we(s,t=[]){const a=be(s),n=ua(a,t);if(n)return n;const i=gs(t,a);if(i)return i;const l=Vs[a];return(l?gs(t,l):void 0)??a}function ma(s,t=[]){return{default:we(s.default,t),opus:we(s.opus,t),sonnet:we(s.sonnet,t),haiku:we(s.haiku,t)}}function Qs(s,t=[]){if(!s)return[];const a=new Set;return s.models.map(n=>{const i=we(n.id,t),l=n.presetMapping?ma(n.presetMapping,t):void 0;return{...n,id:i,presetMapping:l}}).filter(n=>a.has(n.id)?!1:(a.add(n.id),!0))}function pa(s,t){return zs(s,t)?.extendedContext===!0}const He="ccs-internal-managed";async function xa(){try{const s=await fetch("/api/settings/auth/tokens/raw");return s.ok?(await s.json())?.apiKey?.value??He:He}catch{return He}}async function $e(s,t){const a=xe[s];if(!a)return{success:!1};const n=a.models.find(r=>r.id===a.defaultModel)||a.models[0],i=n?.presetMapping||{default:a.defaultModel,opus:a.defaultModel,sonnet:a.defaultModel,haiku:a.defaultModel},l=await xa(),o={env:{ANTHROPIC_BASE_URL:`http://127.0.0.1:${ze}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:l,ANTHROPIC_MODEL:i.default,ANTHROPIC_DEFAULT_OPUS_MODEL:i.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:i.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:i.haiku}};try{return{success:(await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:o})})).ok,presetName:n?.name||a.defaultModel}}catch{return{success:!1}}}function ha({currentProgress:s,allSteps:t}){return e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:t.map((a,n)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${s>=n?"bg-primary":"bg-muted"}`},a))})}function ga({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(_s,{className:"w-4 h-4 text-muted-foreground"})]},a.id))})}function fa({selectedProvider:s,providers:t,authCommand:a,isRefreshing:n,isPending:i,onBack:l,onStartAuth:u,onRefresh:o}){const[r,p]=c.useState(!1),N=async w=>{await navigator.clipboard.writeText(w),p(!0),setTimeout(()=>p(!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(w=>w.id===s)?.name," to add an account"]}),e.jsx(I,{onClick:u,disabled:i,className:"w-full gap-2",size:"lg",children:i?e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"w-4 h-4 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(me,{className:"w-4 h-4"}),"Authenticate in Browser"]})}),i&&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(bs,{children:e.jsxs(ys,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(zt,{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(I,{variant:"outline",size:"icon",onClick:()=>N(a),children:r?e.jsx(de,{className:"w-4 h-4 text-green-500"}):e.jsx(Os,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(I,{variant:"ghost",onClick:l,disabled:i,children:[e.jsx(ts,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs(I,{variant:"outline",onClick:o,disabled:n||i,children:[e.jsx(as,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),n?"Checking...":"Refresh Status"]})]})]})}function va({accounts:s,privacyMode:t,onSelect:a,onAddNew:n,onBack:i}){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(l=>e.jsxs("button",{type:"button",onClick:()=>a(l),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(pe,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:B("font-medium",t&&Ee),children:l.email||l.id}),l.isDefault&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Default account"})]})]}),e.jsx(_s,{className:"w-4 h-4 text-muted-foreground"})]},l.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:n,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(I,{variant:"ghost",onClick:i,children:[e.jsx(ts,{className:"w-4 h-4 mr-2"}),"Back"]})})]})}const fs="__custom__";function ja({selectedProvider:s,selectedAccount:t,variantName:a,modelName:n,isPending:i,privacyMode:l,onVariantNameChange:u,onModelChange:o,onBack:r,onSkip:p,onCreate:N}){const{t:w}=ee(),f=xe[s]?.models||[],O=n&&!f.some(g=>g.id===n),[j,k]=c.useState(O),A=s==="agy"&&n.trim().length>0?se(n):!1,P=g=>{g===fs?(k(!0),o("")):(k(!1),o(g))};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(pe,{className:"w-4 h-4"}),e.jsxs("span",{children:[w("setupVariant.using")," ",e.jsx("span",{className:B(l&&Ee),children:t.email||t.id})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"variant-name",children:w("setupVariant.variantNameRequired")}),e.jsx(ce,{id:"variant-name",value:a,onChange:g=>u(g.target.value),placeholder:w("setupVariant.variantNamePlaceholder")}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[w("setupVariant.invokeHintPrefix")," ccs ",a||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:w("setupVariant.model")}),j?e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{value:n,onChange:g=>o(g.target.value),placeholder:w("setupVariant.modelPlaceholder")}),A&&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:()=>{k(!1),s==="agy"&&se(n)&&o("")},children:w("setupVariant.choosePresetInstead")})]}):e.jsxs(Cs,{value:f.some(g=>g.id===n)?n:"",onValueChange:P,children:[e.jsx(ks,{children:e.jsx(As,{placeholder:w("setupVariant.selectModel")})}),e.jsxs(Ps,{children:[f.map(g=>e.jsx(Ge,{value:g.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:g.name}),g.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",g.description]})]})},g.id)),e.jsx(Ge,{value:fs,children:e.jsx("span",{className:"text-primary",children:w("setupVariant.customModelName")})})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:j?w("setupVariant.enterAnyModel"):w("setupVariant.defaultModel",{model:xe[s]?.defaultModel||w("setupVariant.providerDefault")})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(I,{variant:"ghost",onClick:r,children:[e.jsx(ts,{className:"w-4 h-4 mr-2"}),w("setupVariant.back")]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{variant:"ghost",onClick:p,children:w("setupVariant.skip")}),e.jsx(I,{onClick:N,disabled:!a||i||A,children:w(i?"setupVariant.creating":"setupVariant.createVariant")})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:w("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(de,{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(bs,{children:e.jsxs(ys,{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(I,{onClick:t,className:"w-full",children:"Done"})]})}function wa({open:s,onClose:t}){const[a,n]=c.useState("provider"),[i,l]=c.useState(""),[u,o]=c.useState(null),[r,p]=c.useState(""),[N,w]=c.useState(""),[f,O]=c.useState(!1),[j,k]=c.useState(!1),{data:A,refetch:P}=Ss(),g=et(),m=st(),y=tt(),{privacyMode:C}=Ms(),M=A?.authStatus.find(E=>E.provider===i),d=c.useMemo(()=>M?.accounts||[],[M?.accounts]);c.useEffect(()=>{if(!s){const E=setTimeout(()=>{n("provider"),l(""),o(null),p(""),w(""),k(!1)},0);return()=>clearTimeout(E)}},[s]),c.useEffect(()=>{if(a==="auth"&&d.length>0&&!j){const E=setTimeout(()=>{n("account")},0);return()=>clearTimeout(E)}},[a,d,j]);const S=async()=>{O(!0),await P(),O(!1)},D=()=>{const E=(M?.accounts?.length||0)===0;m.mutate({provider:i},{onSuccess:async _=>{if(E){const K=await $e(i);K.success&&K.presetName?H.success(`Applied "${K.presetName}" preset`):K.success||H.warning(Ds.t("commonToast.accountAddedPresetFailed"))}_.account&&(o(_.account),n("variant")),P()}})},U=E=>{l(E),(A?.authStatus.find(V=>V.provider===E)?.accounts||[]).length===0?n("auth"):n("account")},h=E=>{o(E),n("variant")},v=async()=>{if(!(!r||!i))try{await g.mutateAsync({name:r,provider:i,model:N||void 0,account:u?.id}),n("success")}catch(E){console.error("Failed to create variant:",E)}},b=`ccs ${i} --auth --add`,q=nt(a),L=E=>{if(!E&&(m.isPending&&i&&y.mutate(i),a==="success"||a==="provider")){t();return}};return e.jsx(We,{open:s,onOpenChange:L,children:e.jsxs(Xe,{className:"sm:max-w-lg",onPointerDownOutside:E=>{a!=="success"&&a!=="provider"&&E.preventDefault()},onEscapeKeyDown:E=>{(m.isPending||g.isPending)&&E.preventDefault()},children:[e.jsxs(Ye,{children:[e.jsxs(Ze,{className:"flex items-center gap-2",children:[e.jsx(ye,{className:"w-5 h-5 text-primary"}),"Quick Setup Wizard"]}),e.jsxs(Ts,{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(ga,{providers:rs,onSelect:U}),a==="auth"&&e.jsx(fa,{selectedProvider:i,providers:rs,authCommand:b,isRefreshing:f,isPending:m.isPending,onBack:()=>n("provider"),onStartAuth:D,onRefresh:S}),a==="account"&&e.jsx(va,{accounts:d,privacyMode:C,onSelect:h,onAddNew:()=>{k(!0),n("auth")},onBack:()=>n("provider")}),a==="variant"&&e.jsx(ja,{selectedProvider:i,selectedAccount:u,variantName:r,modelName:N,isPending:g.isPending,privacyMode:C,onVariantNameChange:p,onModelChange:w,onBack:()=>d.length>0?n("account"):n("provider"),onSkip:t,onCreate:v}),a==="success"&&e.jsx(Na,{variantName:r,onClose:t})]}),e.jsx(ha,{currentProgress:q,allSteps:at})]})})}const ba=3e3,ya=300*1e3,Ca=3;async function Ke(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 le={provider:null,isAuthenticating:!1,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:!1};function ka(){const[s,t]=c.useState(le),a=c.useRef(0),n=c.useRef(null),i=c.useRef(null),l=c.useRef(0),u=c.useRef(0),o=c.useRef(!1),r=Je(),p=c.useCallback(k=>k===a.current,[]),N=c.useCallback(()=>{i.current&&(clearInterval(i.current),i.current=null),u.current=0},[]);c.useEffect(()=>()=>{n.current?.abort(),N(),o.current=!1},[N]);const w=c.useCallback(async(k,A,P)=>{if(p(P)){if(Date.now()-l.current>ya){N(),p(P)&&t(g=>({...g,isAuthenticating:!1,error:"Authentication timed out. Please try again."}));return}try{const g=await fetch(`/api/cliproxy/auth/${k}/status?state=${encodeURIComponent(A)}`);if(!p(P))return;const m=await g.json();if(u.current=0,m.status==="ok"){if(!(typeof m.account=="object"&&m.account!==null)){N();const C="Authenticated account could not be registered";H.error(C),t(M=>({...M,isAuthenticating:!1,error:C}));return}N(),r.invalidateQueries({queryKey:["cliproxy-auth"]}),r.invalidateQueries({queryKey:["cliproxy-accounts"]}),r.invalidateQueries({queryKey:["account-quota"]}),H.success(`${k} authentication successful`),o.current=!1,t(le)}else if(m.status==="auth_url"){const y=m.url||m.auth_url;y&&(t(C=>({...C,authUrl:y})),o.current||(o.current=!0,window.open(y,"_blank")))}else if(m.status==="device_code"){N();const y=m.user_code&&m.verification_url?`Open ${m.verification_url} and enter code: ${m.user_code}`:"Switch to Device Code method and try again.";H.error("Provider returned Device Code flow in callback mode"),t(C=>({...C,isAuthenticating:!1,error:y}))}else if(m.status==="error"){N();const y=m.error||"Authentication failed";H.error(y),t(C=>({...C,isAuthenticating:!1,error:y}))}}catch(g){if(!p(P)||(u.current+=1,u.current<Ca))return;N();const m=g instanceof Error&&g.message.trim().length>0?g.message:"Lost contact with the auth status endpoint";H.error(m),t(y=>({...y,isAuthenticating:!1,error:m}))}}},[p,r,N]),f=c.useCallback(async(k,A)=>{if(!Ve(k)){t({...le,error:`Unknown provider: ${k}`});return}n.current?.abort(),N(),o.current=!1,u.current=0;const P=new AbortController,g=a.current+1;a.current=g,n.current=P;const y=(A?.flowType||(Es(k)?"device_code":"authorization_code"))==="device_code",C=A?.startEndpoint||(y?"start":"start-url"),M={nickname:A?.nickname,kiroMethod:A?.kiroMethod,riskAcknowledgement:A?.riskAcknowledgement};t({provider:k,isAuthenticating:!0,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:y});try{if(C==="start")fetch(`/api/cliproxy/auth/${k}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M),signal:P.signal}).then(async d=>{if(!p(g))return;const S=await Ke(d);if(!p(g))return;const D=S.success===!0,U=typeof S.account=="object"&&S.account!==null;if(d.ok&&D&&U)r.invalidateQueries({queryKey:["cliproxy-auth"]}),r.invalidateQueries({queryKey:["cliproxy-accounts"]}),r.invalidateQueries({queryKey:["account-quota"]}),o.current=!1,t(le);else{const h=typeof S.error=="string"?S.error:D?"Authenticated account could not be registered":"Authentication failed";H.error(h),t(v=>({...v,isAuthenticating:!1,error:h}))}}).catch(d=>{if(!p(g)||d instanceof Error&&d.name==="AbortError")return;const S=d instanceof Error?d.message:"Authentication failed";H.error(S),t(D=>({...D,isAuthenticating:!1,error:S}))});else{const d=await fetch(`/api/cliproxy/auth/${k}/start-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M),signal:P.signal});if(!p(g))return;const S=await Ke(d);if(!p(g))return;const D=S.success===!0;if(!d.ok||!D){const v=typeof S.error=="string"?S.error:"Failed to start OAuth";throw new Error(v)}const U=typeof S.authUrl=="string"?S.authUrl:null,h=typeof S.state=="string"?S.state:null;t(v=>({...v,authUrl:U,oauthState:h})),U&&(o.current=!0,window.open(U,"_blank")),h&&(l.current=Date.now(),i.current=setInterval(()=>{w(k,h,g)},ba))}}catch(d){if(!p(g))return;if(d instanceof Error&&d.name==="AbortError"){o.current=!1,t(le);return}const S=d instanceof Error?d.message:"Authentication failed";H.error(S),t(D=>({...D,isAuthenticating:!1,error:S}))}},[p,w,N,r]),O=c.useCallback(()=>{const k=s.provider;a.current+=1,n.current?.abort(),N(),o.current=!1,t(le),k&&Me.cliproxy.auth.cancel(k).catch(()=>{})},[s.provider,N]),j=c.useCallback(async k=>{if(!s.provider)return;const A=a.current,P=s.provider;t(g=>({...g,isSubmittingCallback:!0,error:null}));try{const g=await fetch(`/api/cliproxy/auth/${P}/submit-callback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({redirectUrl:k})});if(!p(A))return;const m=await Ke(g);if(!p(A))return;const y=m.success===!0,C=typeof m.account=="object"&&m.account!==null;if(g.ok&&y&&C)N(),r.invalidateQueries({queryKey:["cliproxy-auth"]}),r.invalidateQueries({queryKey:["cliproxy-accounts"]}),r.invalidateQueries({queryKey:["account-quota"]}),H.success(`${P} authentication successful`),t(le);else{const M=typeof m.error=="string"?m.error:y?"Authenticated account could not be registered":"Callback submission failed";throw new Error(M)}}catch(g){if(!p(A))return;const m=g instanceof Error?g.message:"Failed to submit callback";H.error(m),t(y=>({...y,isSubmittingCallback:!1,error:m}))}},[p,s.provider,r,N]);return c.useMemo(()=>({...s,startAuth:f,cancelAuth:O,submitCallback:j}),[s,f,O,j])}function $s({className:s,showAcknowledgement:t=!1,acknowledgementPhrase:a=Te,acknowledgementText:n="",onAcknowledgementTextChange:i,disabled:l=!1,showProxySettingsLink:u=!1}){const{t:o}=ee(),r=o("accountSafetyWarning.title"),p=o("accountSafetyWarning.subtitle"),N=o("accountSafetyWarning.firstLine"),w=o("accountSafetyWarning.secondLine"),f="https://github.com/kaitranntt/ccs/issues/509",O=o("accountSafetyWarning.issueLabel"),j=o("accountSafetyWarning.proxySettingsLabel");return e.jsxs("section",{role:"alert",className:B("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(Re,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:r}),e.jsx("p",{className:"text-xs text-muted-foreground",children:p})]})]}),e.jsx(G,{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:N}),e.jsx("p",{className:"font-medium text-amber-900 dark:text-amber-200",children:w}),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:f,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:[O,e.jsx(me,{className:"h-3.5 w-3.5"})]}),u&&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(Qt,{className:"h-3.5 w-3.5"}),j]}),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&&i&&e.jsxs("div",{className:"rounded-lg border border-amber-500/25 bg-amber-500/5 p-2.5",children:[e.jsxs(Z,{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(ce,{id:"account-risk-ack-text",value:n,onChange:k=>i(k.target.value),placeholder:a,disabled:l,className:"mt-2 font-mono text-xs"})]})]})]})}function Aa({className:s,value:t,onChange:a,disabled:n=!1}){const{t:i}=ee(),l=[t.reviewedIssue509,t.understandsBanRisk,t.acceptsFullResponsibility,t.typedPhrase.trim().replace(/\s+/g," ").toUpperCase()===hs].filter(Boolean).length,u=l/4*100,o=r=>{a({...t,...r})};return e.jsxs("section",{role:"alert",className:B("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(Re,{className:"h-4 w-4"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:i("antigravityChecklist.title")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i("antigravityChecklist.subtitle")})]})]}),e.jsx(G,{variant:"outline",className:"border-rose-500/40 text-rose-700 dark:text-rose-300",children:i("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:i("antigravityChecklist.completion")}),e.jsx("span",{children:i("antigravityChecklist.stepsCount",{current:l})})]}),e.jsx(Be,{value:u,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(De,{id:"agy-step-reviewed-issue",checked:t.reviewedIssue509,onCheckedChange:r=>o({reviewedIssue509:!!r}),disabled:n}),e.jsx(Z,{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(De,{id:"agy-step-understands-risk",checked:t.understandsBanRisk,onCheckedChange:r=>o({understandsBanRisk:!!r}),disabled:n}),e.jsx(Z,{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(De,{id:"agy-step-accept-responsibility",checked:t.acceptsFullResponsibility,onCheckedChange:r=>o({acceptsFullResponsibility:!!r}),disabled:n}),e.jsx(Z,{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(Is,{className:"h-3.5 w-3.5"}),"Step 4: Type exact phrase to continue"]}),e.jsx(ce,{value:t.typedPhrase,onChange:r=>o({typedPhrase:r.target.value}),placeholder:hs,disabled:n,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 Pa(s){return s.trim().replace(/\s+/g," ").toUpperCase()}function Sa({open:s,onClose:t,provider:a,displayName:n,isFirstAccount:i=!1}){const[l,u]=c.useState(""),[o,r]=c.useState(""),[p,N]=c.useState(!1),[w,f]=c.useState(null),[O,j]=c.useState(""),[k,A]=c.useState(qe),[P,g]=c.useState(!1),[m,y]=c.useState(!1),[C,M]=c.useState(os),{t:d}=ee(),S=c.useRef(!1),D=c.useRef(0),U=c.useRef(!1),h=ka(),v=it(),b=a==="kiro",q=a==="agy"||a==="gemini",L=a==="gemini"&&!P,E=a==="agy"&&!P,_=q&&m,K=na(k),V=Pa(O)===Te,te=Es(a),X=rt(C),ae=b?X.flowType==="device_code":te,$=h.isAuthenticating||v.isPending,x=l.trim(),R=w||h.error,z=c.useCallback(async()=>{const T=await fetch("/api/settings/auth/antigravity-risk");if(!T.ok)throw new Error("Failed to load power user mode setting");return(await T.json()).antigravityAckBypass===!0},[]),ne=c.useCallback(async({pendingMessage:T=null,disabledMessage:Y=null}={})=>{const ge=++D.current;y(!0),T!==null&&f(T);try{const oe=await z();return D.current!==ge||(g(oe),Y?f(oe?null:Y):T!==null&&f(null)),oe}catch{return D.current!==ge||(g(!1),f(Y??d("addAccountDialog.powerUserLoadFailed")),U.current||(U.current=!0,H.error(d("addAccountDialog.powerUserLoadFailed")))),!1}finally{D.current===ge&&y(!1)}},[z,d]),he=()=>{u(""),r(""),N(!1),f(null),j(""),A(qe),g(!1),y(!1),M(os),D.current+=1,U.current=!1,S.current=!1,t()};c.useEffect(()=>{s&&(j(""),A(qe),f(null))},[a,s]),c.useEffect(()=>()=>{D.current+=1},[]),c.useEffect(()=>{if(!s||!q){D.current+=1,g(!1),y(!1);return}ne()},[s,a,q,ne]),c.useEffect(()=>{if(!s||a!=="agy"||!h.error||!P)return;const T=h.error.toLowerCase();(T.includes("agy_risk_ack_required")||T.includes("responsibility acknowledgement")||T.includes("responsibility checklist"))&&ne({pendingMessage:d("addAccountDialog.powerUserLoading"),disabledMessage:d("addAccountDialog.powerUserUnavailableRetry")})},[h.error,s,P,a,ne,d]),c.useEffect(()=>{!h.isAuthenticating&&!h.error&&h.provider===null&&s&&S.current&&(S.current=!1,(async()=>{try{const Y=await $e(a);Y.success&&Y.presetName&&i&&H.success(`Applied "${Y.presetName}" preset`)}catch{}he()})())},[h.isAuthenticating,h.error,h.provider]);const ke=()=>{h.cancelAuth(),he()},Ie=async()=>{h.authUrl&&(await navigator.clipboard.writeText(h.authUrl),N(!0),setTimeout(()=>N(!1),2e3))},Le=()=>{o.trim()&&h.submitCallback(o.trim())},Ae=()=>{if(_){f(d("addAccountDialog.powerUserLoading"));return}if(E&&!K){f("Complete all Antigravity responsibility steps before authenticating this provider.");return}if(L&&!V){f(`Type "${Te}" to acknowledge the account safety warning before authenticating this provider.`);return}f(null),S.current=!0,h.startAuth(a,{nickname:x||void 0,kiroMethod:b?C:void 0,flowType:b?X.flowType:void 0,startEndpoint:b?X.startEndpoint:void 0,riskAcknowledgement:E?{version:ia,reviewedIssue509:k.reviewedIssue509,understandsBanRisk:k.understandsBanRisk,acceptsFullResponsibility:k.acceptsFullResponsibility,typedPhrase:k.typedPhrase}:void 0})},Pe=()=>{S.current=!0,v.mutate(void 0,{onSuccess:async()=>{const T=await $e("kiro");T.success&&T.presetName&&i&&H.success(`Applied "${T.presetName}" preset`),he()}})},Fe=T=>{T||ke()},J=h.isAuthenticating;return e.jsx(We,{open:s,onOpenChange:Fe,children:e.jsxs(Xe,{className:"sm:max-w-md",onInteractOutside:T=>{J&&T.preventDefault()},children:[e.jsxs(Ye,{children:[e.jsx(Ze,{children:d("addAccountDialog.title",{displayName:n})}),e.jsx(Ts,{children:d(b?"addAccountDialog.descKiro":ae?"addAccountDialog.descDeviceCode":"addAccountDialog.descOauth")})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[E&&!J&&e.jsx(Aa,{value:k,onChange:T=>{A(T),f(null)},disabled:$}),q&&P&&!J&&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(Is,{className:"h-3.5 w-3.5"}),d("addAccountDialog.powerUserEnabled")]}),d("addAccountDialog.powerUserSkipped")]}),L&&!J&&e.jsx($s,{showAcknowledgement:!0,acknowledgementPhrase:Te,acknowledgementText:O,onAcknowledgementTextChange:T=>{j(T),f(null)},disabled:$}),b&&!J&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"kiro-auth-method",children:d("addAccountDialog.authMethod")}),e.jsxs(Cs,{value:C,onValueChange:T=>{M(T),f(null)},children:[e.jsx(ks,{id:"kiro-auth-method",children:e.jsx(As,{placeholder:d("addAccountDialog.selectKiroAuthMethod")})}),e.jsx(Ps,{children:ot.map(T=>e.jsx(Ge,{value:T.id,children:T.label},T.id))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:X.description})]}),!J&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"nickname",children:d("addAccountDialog.nicknameOptional")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pe,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(ce,{id:"nickname",value:l,onChange:T=>{u(T.target.value),f(null)},placeholder:d("addAccountDialog.nicknamePlaceholder"),disabled:$,className:"flex-1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d("addAccountDialog.nicknameOptionalHint")})]}),J&&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(W,{className:"w-4 h-4 inline mr-2 animate-spin"}),d("addAccountDialog.waitingForAuth")]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:h.isDeviceCodeFlow?d("addAccountDialog.deviceCodeHint"):d("addAccountDialog.browserHint")})]}),h.authUrl&&!h.isDeviceCodeFlow&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{className:"text-xs",children:d("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:h.authUrl}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(I,{variant:"outline",size:"sm",onClick:Ie,children:p?e.jsxs(e.Fragment,{children:[e.jsx(de,{className:"w-3 h-3 mr-1"}),d("addAccountDialog.copied")]}):e.jsxs(e.Fragment,{children:[e.jsx(Os,{className:"w-3 h-3 mr-1"}),d("addAccountDialog.copy")]})}),e.jsxs(I,{variant:"outline",size:"sm",onClick:()=>{if(!h.authUrl)return;const T=window.open(h.authUrl,"_blank");(!T||T.closed||typeof T.closed>"u")&&H.warning(d("addAccountDialog.popupBlocked"),{duration:5e3})},children:[e.jsx(me,{className:"w-3 h-3 mr-1"}),d("addAccountDialog.open")]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"callback-url",className:"text-xs",children:d("addAccountDialog.redirectPasteLabel")}),e.jsx(ce,{id:"callback-url",value:o,onChange:T=>r(T.target.value),placeholder:d("addAccountDialog.callbackPlaceholder"),className:"font-mono text-xs"}),e.jsx(I,{variant:"secondary",size:"sm",onClick:Le,disabled:!o.trim()||h.isSubmittingCallback,children:h.isSubmittingCallback?e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"w-3 h-3 mr-1 animate-spin"}),d("addAccountDialog.submitting")]}):d("addAccountDialog.submitCallback")})]})]}),!h.authUrl&&!h.isDeviceCodeFlow&&e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:d("addAccountDialog.preparingUrl")})]}),R&&e.jsx("p",{className:"text-xs text-center text-destructive",children:R}),v.isPending&&e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:[e.jsx(W,{className:"w-4 h-4 inline mr-2 animate-spin"}),d("addAccountDialog.importingToken")]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(I,{variant:"ghost",onClick:ke,children:d("addAccountDialog.cancel")}),b&&!J&&e.jsx(I,{variant:"outline",onClick:Pe,disabled:$,children:v.isPending?e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"w-4 h-4 mr-2 animate-spin"}),d("addAccountDialog.importing")]}):e.jsxs(e.Fragment,{children:[e.jsx($t,{className:"w-4 h-4 mr-2"}),d("addAccountDialog.importFromIde")]})}),!J&&e.jsxs(I,{onClick:Ae,disabled:$||_||E&&!K||L&&!V,children:[e.jsx(me,{className:"w-4 h-4 mr-2"}),d("addAccountDialog.authenticate")]})]})]})]})})}const Ma=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function Ta(s){const t=s?.env||{};return Ma.filter(a=>!t[a]?.trim())}function Da(s){const[t,a]=c.useState(null),[n,i]=c.useState(!1),l=Je(),{data:u,isLoading:o,refetch:r}=ws({queryKey:["settings",s],queryFn:async()=>{const h=await fetch(`/api/settings/${s}/raw`);return h.ok?h.json():{profile:s,settings:{env:{}},mtime:Date.now(),path:`~/.ccs/profiles/${s}/settings.json`}}}),p=u?.settings,N=c.useMemo(()=>t!==null?t:p?JSON.stringify(p,null,2):`{
|
|
2
|
+
"env": {}
|
|
3
|
+
}`,[t,p]),w=c.useCallback(h=>{a(h)},[]),f=c.useMemo(()=>{try{return JSON.parse(N)}catch{return p||{env:{}}}},[N,p]),O=f?.env?.ANTHROPIC_MODEL,j=f?.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,k=f?.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,A=f?.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,P=c.useMemo(()=>lt(f?.env||{}),[f]),g=c.useCallback((h,v)=>ct(h,v,{supportsExtendedContext:b=>pa(s,b)}),[s]),m=c.useCallback((h,v)=>{const b={...f?.env||{},[h]:v},q=ls(h)?g(b,P):b;delete q.CCS_EXTENDED_CONTEXT;const L={...f,env:q};a(JSON.stringify(L,null,2))},[g,f,P]),y=c.useCallback(h=>{const v=f?.env||{},b=g(v,h);delete b.CCS_EXTENDED_CONTEXT;const q={...f,env:b};a(JSON.stringify(q,null,2))},[g,f]),C=c.useCallback(h=>{const v={...f?.env||{},...h},q=Object.keys(h).some(ls)?g(v,P):v;delete q.CCS_EXTENDED_CONTEXT;const L={...f,env:q};a(JSON.stringify(L,null,2))},[g,f,P]),M=c.useMemo(()=>{try{return JSON.parse(N),!0}catch{return!1}},[N]),d=c.useMemo(()=>t===null?!1:t!==JSON.stringify(p,null,2),[t,p]),S=c.useMemo(()=>Ta(f),[f]),D=Ys({mutationFn:async()=>{const h=JSON.parse(N),v=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:h,expectedMtime:u?.mtime})});if(v.status===409)throw new Error("CONFLICT");if(!v.ok)throw new Error("Failed to save");return v.json()},onSuccess:h=>{l.invalidateQueries({queryKey:["settings",s]}),a(null),h?.warning?H.success("Settings saved",{description:h.warning}):H.success("Settings saved")},onError:h=>{h.message==="CONFLICT"?i(!0):H.error(h.message)}}),U=async h=>{i(!1),h?(await r(),D.mutate()):a(null)};return{data:u,isLoading:o,refetch:r,rawJsonContent:N,rawJsonEdits:t,isRawJsonValid:M,hasChanges:d,currentSettings:f,currentModel:O,opusModel:j,sonnetModel:k,haikuModel:A,extendedContextEnabled:P,toggleExtendedContext:y,handleRawJsonChange:w,updateEnvValue:m,updateEnvValues:C,saveMutation:{mutate:()=>D.mutate(),isPending:D.isPending},conflictDialog:n,setConflictDialog:i,handleConflictResolve:U,missingRequiredFields:S}}const Ea=/-(medium|high|xhigh)$/i;function Ra(s){if(!s)return;const t=s.trim().match(Ea);if(t?.[1])return t[1].toLowerCase()}function _a(s){if(!s)return null;const t=Ra(s);return t?{label:`Pinned ${t}`,explicit:!0}:{label:"Auto effort",explicit:!1}}function Oa({label:s}){return e.jsx(G,{variant:"outline",className:"text-[9px] h-4 px-1",children:s})}function Se({modelId:s}){const t=_a(s);return t?e.jsx(G,{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:n,catalog:i,allModels:l,disabled:u}){const{t:o}=ee(),r=i?.provider==="codex",p=c.useMemo(()=>Qs(i,l),[l,i]),N=new Set(p.map(j=>j.id)),w=p.map(j=>({value:j.id,groupKey:"recommended",searchText:`${j.id} ${j.name}`,keywords:[j.tier??"",i?.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:j.id}),r&&e.jsx(Se,{modelId:j.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:j.id}),j.tier==="paid"&&e.jsx(Oa,{label:o("providerModelSelector.paid")}),r&&e.jsx(Se,{modelId:j.id})]})})),f=l.filter(j=>!N.has(j.id)).map(j=>({value:j.id,groupKey:"all",searchText:j.id,keywords:[j.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:j.id}),r&&e.jsx(Se,{modelId:j.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:j.id}),r&&e.jsx(Se,{modelId:j.id})]})})),O=w.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(oa,{value:a||void 0,onChange:n,disabled:u,placeholder:o("providerModelSelector.selectModel"),searchPlaceholder:o("searchableSelect.searchModels"),emptyText:o(O?"searchableSelect.noResults":"providerModelSelector.noModelsAvailable"),triggerClassName:"h-9",groups:[{key:"recommended",label:e.jsx("span",{className:"text-xs text-primary",children:o("providerModelSelector.recommended")})},{key:"all",label:e.jsx("span",{className:"text-xs text-muted-foreground",children:o("providerModelSelector.allModelsCount",{count:l.length})})}],options:[...w,...f]})]})}function Ia({open:s,onClose:t,currentValues:a,onApply:n,onSave:i,isSaving:l,catalog:u,allModels:o}){const{t:r}=ee(),[p,N]=c.useState(a),[w,f]=c.useState(""),O=j=>{j?(N(a),f("")):t()};return e.jsx(We,{open:s,onOpenChange:O,children:e.jsxs(Xe,{className:"sm:max-w-md",children:[e.jsx(Ye,{children:e.jsxs(Ze,{className:"flex items-center gap-2",children:[e.jsx(ye,{className:"w-4 h-4"}),r("customPresetDialog.title")]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"preset-name",children:r("customPresetDialog.presetNameOptional")}),e.jsx(ce,{id:"preset-name",value:w,onChange:j=>f(j.target.value),placeholder:r("customPresetDialog.presetNamePlaceholder"),className:"text-sm"})]}),e.jsx(is,{}),u?.provider==="codex"&&e.jsxs("p",{className:"text-[11px] text-muted-foreground rounded-md border bg-muted/30 px-2.5 py-2",children:[r("customPresetDialog.codexTipPrefix")," ",e.jsx("code",{children:"-medium"}),", ",e.jsx("code",{children:"-high"}),", and"," ",e.jsx("code",{children:"-xhigh"})," ",r("customPresetDialog.codexTipSuffix")]}),e.jsx(re,{label:r("customPresetDialog.defaultModel"),description:r("customPresetDialog.defaultModelDesc"),value:p.default,onChange:j=>N({...p,default:j}),catalog:u,allModels:o}),e.jsx(re,{label:r("customPresetDialog.opusModel"),description:r("customPresetDialog.opusModelDesc"),value:p.opus,onChange:j=>N({...p,opus:j}),catalog:u,allModels:o}),e.jsx(re,{label:r("customPresetDialog.sonnetModel"),description:r("customPresetDialog.sonnetModelDesc"),value:p.sonnet,onChange:j=>N({...p,sonnet:j}),catalog:u,allModels:o}),e.jsx(re,{label:r("customPresetDialog.haikuModel"),description:r("customPresetDialog.haikuModelDesc"),value:p.haiku,onChange:j=>N({...p,haiku:j}),catalog:u,allModels:o})]}),e.jsxs(dt,{className:"gap-2 sm:gap-0",children:[e.jsx(I,{variant:"outline",onClick:t,children:r("customPresetDialog.cancel")}),i&&e.jsxs(I,{variant:"secondary",onClick:()=>i(p,w||void 0),disabled:l||!w.trim(),children:[l?e.jsx(W,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(_e,{className:"w-4 h-4 mr-1"}),r("customPresetDialog.savePreset")]}),e.jsxs(I,{onClick:()=>n(p,w||void 0),children:[e.jsx(Ce,{className:"w-4 h-4 mr-1"}),r("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(Rs,{value:t,size:"icon",className:"h-6 w-6"})]})]})}function La({provider:s,displayName:t,defaultTarget:a,data:n,authStatus:i}){const l=a||"claude",u=l==="droid";return e.jsx(es,{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(Ls,{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})]}),n&&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:n.path}),e.jsx(Rs,{value:n.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(n.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"}),i.authenticated?e.jsxs(G,{variant:"outline",className:"w-fit text-green-600 border-green-200 bg-green-50",children:[e.jsx(Jt,{className:"w-3 h-3 mr-1"}),"Authenticated"]}):e.jsx(G,{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:l})]})]})]}),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:u?"Droid alias (explicit)":"Run on Droid",command:`ccs-droid ${s} "your prompt"`}),e.jsx(ue,{label:u?"Override to Claude":"Run on Droid (--target)",command:`ccs ${s} --target ${u?"claude":"droid"} "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 Fa({displayName:s,logoProvider:t,provider:a,data:n,isLoading:i,hasChanges:l,isRawJsonValid:u,isSaving:o,isRemoteMode:r,port:p,onRefetch:N,onSave:w}){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(ss,{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}),r&&e.jsxs(G,{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(Fs,{className:"w-3 h-3"}),"Remote"]}),p&&e.jsxs(G,{variant:"outline",className:"text-xs gap-1 font-mono",children:[e.jsx(Wt,{className:"w-3 h-3"}),":",p]}),!r&&n?.path&&e.jsx(G,{variant:"outline",className:"text-xs",children:n.path.replace(/^.*[\\/]/,"")})]}),r?e.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400 mt-0.5",children:"Traffic auto-routed to remote server"}):n&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",new Date(n.mtime).toLocaleString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{variant:"ghost",size:"sm",onClick:N,disabled:i,children:e.jsx(as,{className:`w-4 h-4 ${i?"animate-spin":""}`})}),e.jsx(I,{size:"sm",onClick:w,disabled:o||!l||!u,children:o?e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Xt,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function Ua({models:s,provider:t,enabled:a,onToggle:n,disabled:i,className:l}){if(s.length===0)return null;const u=s.some(p=>cs(p.id)),o=s.some(p=>!cs(p.id));let r="Compatible mappings stay on standard context unless you turn this on.";return u&&o?r="Gemini-compatible mappings can use 1M automatically. Claude mappings stay plain unless you turn this on.":u&&(r="Gemini-compatible mappings can use 1M by default. Turn this off to keep standard context."),e.jsxs("div",{className:B("rounded-lg border p-3 space-y-2",a?"border-primary/50 bg-primary/5":"border-border bg-muted/30",l),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:B("w-4 h-4",a?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:"text-sm font-medium",children:"Extended Context"}),e.jsx(G,{variant:a?"default":"secondary",className:"text-[10px] h-5 px-1.5",children:"1M tokens"})]}),e.jsx(Gs,{checked:a,onCheckedChange:n,disabled:i})]}),e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground",children:[e.jsx(Ls,{className:"w-3.5 h-3.5 mt-0.5 shrink-0"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{children:["Applies the explicit ",e.jsx("code",{children:"[1m]"})," long-context suffix to compatible saved mappings."]}),e.jsx("p",{className:"text-[10px]",children:r}),e.jsxs("p",{className:"text-amber-600 dark:text-amber-500",children:["CCS only saves ",e.jsx("code",{children:"[1m]"}),". Provider pricing and entitlement are separate, and some accounts can still return 429 extra-usage errors for long-context requests."]})]})]})]})}function qa(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 Ha({catalog:s,savedPresets:t,currentModel:a,opusModel:n,sonnetModel:i,haikuModel:l,providerModels:u,provider:o,extendedContextEnabled:r,onExtendedContextToggle:p,onApplyPreset:N,onUpdateEnvValue:w,onOpenCustomPreset:f,onDeletePreset:O,isDeletePending:j}){const k=c.useMemo(()=>{if(!s)return[];const m=[a,n,i,l].filter(C=>!!C).map(C=>ut(C));return[...new Set(m)].map(C=>zs(s.provider,C)).filter(C=>!!C?.extendedContext)},[s,a,n,i,l]),A=c.useMemo(()=>Qs(s,u),[s,u]),P=c.useMemo(()=>{const m=A.filter(C=>C.presetMapping);return m.length===0?[]:m.some(C=>C.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:m.filter(C=>C.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:m.filter(C=>C.tier==="paid")}].filter(C=>C.models.length>0):[{key:"default",models:m.slice(0,4)}]},[A]),g=P.length>0||t.length>0;return e.jsxs(e.Fragment,{children:[g&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(ye,{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:[P.map(m=>e.jsxs("div",{children:["label"in m&&m.label&&e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(G,{variant:"outline",className:m.badgeClassName,children:m.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:m.description})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:m.models.map(y=>e.jsxs(I,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>N(qa(y)),children:[e.jsx(Ce,{className:`w-3 h-3 ${"iconClassName"in m?m.iconClassName:""}`}),y.name]},y.id))})]},m.key)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.map(m=>e.jsxs("div",{className:"group relative",children:[e.jsxs(I,{variant:"secondary",size:"sm",className:"text-xs h-7 gap-1 pr-6",onClick:()=>{N({ANTHROPIC_MODEL:m.default,ANTHROPIC_DEFAULT_OPUS_MODEL:m.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:m.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:m.haiku})},children:[e.jsx(_e,{className:"w-3 h-3 fill-current"}),m.name]}),e.jsx(I,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-7 w-5 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:y=>{y.stopPropagation(),O(m.name)},disabled:j,children:e.jsx(ns,{className:"w-3 h-3"})})]},m.name)),e.jsxs(I,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1 border-primary/50 text-primary hover:bg-primary/10 hover:border-primary",onClick:f,children:[e.jsx(Us,{className:"w-3 h-3"}),"Custom"]})]})]})]}),e.jsx(is,{}),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"}),o==="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:m=>w("ANTHROPIC_MODEL",m),catalog:s,allModels:u}),k.length>0&&p&&e.jsx(Ua,{models:k,provider:o,enabled:r??!1,onToggle:p}),e.jsx(re,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:n,onChange:m=>w("ANTHROPIC_DEFAULT_OPUS_MODEL",m),catalog:s,allModels:u}),e.jsx(re,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:i,onChange:m=>w("ANTHROPIC_DEFAULT_SONNET_MODEL",m),catalog:s,allModels:u}),e.jsx(re,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:l,onChange:m=>w("ANTHROPIC_DEFAULT_HAIKU_MODEL",m),catalog:s,allModels:u})]})]})]})}function vs(s){const t=Math.max(0,Math.min(100,s));return t<=20?"bg-destructive":t<=50?"bg-yellow-500":"bg-green-500"}function js(s){if(!s)return"";try{const t=new Date(s),n=new Date().getTime()-t.getTime();if(n<0)return"just now";const i=Math.floor(n/(1e3*60)),l=Math.floor(n/(1e3*60*60)),u=Math.floor(n/(1e3*60*60*24));return u>0?`${u}d ago`:l>0?`${l}h ago`:i>0?`${i}m ago`:"just now"}catch{return""}}function Ka(s){if(!s)return!1;try{const t=new Date(s);return new Date().getTime()-t.getTime()<3600*1e3}catch{return!1}}function Ga({account:s,onSetDefault:t,onRemove:a,onPauseToggle:n,isRemoving:i,isPausingAccount:l,privacyMode:u,showQuota:o,selectable:r,selected:p,onSelectChange:N}){const{t:w}=ee(),f=s.provider.toLowerCase(),O=f==="codex",j=f==="claude"||f==="anthropic",{data:k}=mt(o),{data:A,isLoading:P}=pt(f,s.id,o),g=xt(k,s)?.lastUsedAt,m=Ka(g),y=ht(s.provider,A),C=gt(s.provider,A),M=O&&A&&ft(A)?vt(A.windows):null,d=[{label:"5h",value:M?.fiveHourWindow?.remainingPercent??null},{label:"Weekly",value:M?.weeklyWindow?.remainingPercent??null}].filter(L=>L.value!==null),S=j&&A&&jt(A)?[{label:"5h",value:A.coreUsage?.fiveHour?.remainingPercent??A.windows.find(L=>L.rateLimitType==="five_hour")?.remainingPercent??null},{label:"Weekly",value:A.coreUsage?.weekly?.remainingPercent??A.windows.find(L=>["seven_day","seven_day_opus","seven_day_sonnet","seven_day_oauth_apps","seven_day_cowork"].includes(L.rateLimitType))?.remainingPercent??null}].filter(L=>L.value!==null):[],D=O?d:j?S:[],U=y!==null?Ct(y):null,h=U!==null?Number(U):null,v=Nt(A),b=v?.label==="Reauth"?Yt:v?.tone==="warning"?Re:Zt,q=v?.tone==="warning"?"border-amber-500/50 text-amber-600 dark:text-amber-400":v?.tone==="destructive"?"border-destructive/50 text-destructive":"border-muted-foreground/50 text-muted-foreground";return e.jsxs("div",{className:B("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",p&&"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:[r&&e.jsx("button",{type:"button",onClick:()=>N?.(!p),className:B("flex items-center justify-center w-5 h-5 rounded border-2 transition-colors shrink-0",p?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30 hover:border-primary/50"),"aria-label":p?"Deselect account":"Select account",children:p&&e.jsx(de,{className:"w-3 h-3"})}),n&&e.jsx(fe,{children:e.jsxs(ve,{children:[e.jsx(je,{asChild:!0,children:e.jsx(I,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>n(!s.paused),disabled:l,children:l?e.jsx(W,{className:"w-4 h-4 animate-spin"}):s.paused?e.jsx(qs,{className:"w-4 h-4 text-emerald-500"}):e.jsx(Qe,{className:"w-4 h-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(Ne,{side:"top",children:s.paused?"Resume account":"Pause account"})]})}),e.jsxs("div",{className:"relative shrink-0",children:[e.jsx("div",{className:B("flex items-center justify-center w-8 h-8 rounded-full",s.isDefault?"bg-primary/10":"bg-muted"),children:e.jsx(pe,{className:"w-4 h-4"})}),s.tier&&s.tier!=="unknown"&&s.tier!=="free"&&e.jsx("span",{className:B("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:B("font-medium text-sm truncate",u&&Ee),children:s.email||s.id}),s.isDefault&&e.jsxs(G,{variant:"secondary",className:"text-[10px] h-4 px-1.5 gap-0.5",children:[e.jsx(_e,{className:"w-2.5 h-2.5 fill-current"}),"Default"]}),s.paused&&e.jsxs(G,{variant:"outline",className:"text-[10px] h-4 px-1.5 border-yellow-500 text-yellow-600",children:[e.jsx(Qe,{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(fe,{children:e.jsxs(ve,{children:[e.jsx(je,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(ea,{className:"w-3 h-3","aria-hidden":"true"}),e.jsx("span",{className:B("font-mono max-w-[180px] truncate",u&&Ee),title:s.projectId,children:s.projectId})]})}),e.jsx(Ne,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:"GCP Project ID (read-only)"})})]})}):e.jsx(fe,{children:e.jsxs(ve,{children:[e.jsx(je,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-500",children:[e.jsx(Re,{className:"w-3 h-3","aria-label":"Warning"}),e.jsx("span",{children:"Project ID: N/A"})]})}),e.jsx(Ne,{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(ps,{className:"w-3 h-3"}),"Last used: ",new Date(s.lastUsedAt).toLocaleDateString()]})]})]}),e.jsxs(wt,{children:[e.jsx(bt,{asChild:!0,children:e.jsx(I,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(sa,{className:"w-4 h-4"})})}),e.jsxs(yt,{align:"end",children:[!s.isDefault&&e.jsxs(ds,{onClick:t,children:[e.jsx(_e,{className:"w-4 h-4 mr-2"}),"Set as default"]}),e.jsxs(ds,{className:"text-destructive focus:text-destructive",onClick:a,disabled:i,children:[e.jsx(Hs,{className:"w-4 h-4 mr-2"}),i?"Removing...":"Remove account"]})]})]})]}),o&&e.jsx("div",{className:"pl-11",children:P?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(W,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{children:"Loading quota..."})]}):h!==null?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex items-center gap-1.5 text-xs",children:m?e.jsxs(e.Fragment,{children:[e.jsx(ta,{className:"w-3 h-3 text-emerald-500"}),e.jsxs("span",{className:"text-emerald-600 dark:text-emerald-400",children:["Active · ",js(g)]})]}):g?e.jsxs(e.Fragment,{children:[e.jsx(ps,{className:"w-3 h-3 text-muted-foreground"}),e.jsxs("span",{className:"text-muted-foreground",children:["Last used ",js(g)]})]}):e.jsxs(e.Fragment,{children:[e.jsx(xs,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Not used yet"})]})}),e.jsx(fe,{children:e.jsxs(ve,{children:[e.jsx(je,{asChild:!0,children:D.length>0?e.jsx("div",{className:"space-y-1.5",children:D.map(L=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-10 text-[10px] text-muted-foreground",children:L.label}),e.jsx(Be,{value:Math.max(0,Math.min(100,L.value)),className:"h-2 flex-1",indicatorClassName:vs(L.value)}),e.jsxs("span",{className:"text-xs font-medium w-10 text-right",children:[L.value,"%"]})]},L.label))}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Be,{value:Math.max(0,Math.min(100,h)),className:"h-2 flex-1",indicatorClassName:vs(h)}),e.jsxs("span",{className:"text-xs font-medium w-10 text-right",children:[U,"%"]})]})}),e.jsx(Ne,{side:"bottom",className:"max-w-xs",children:e.jsx(kt,{quota:A,resetTime:C})})]})})]}):A?.success?e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(G,{variant:"outline",className:"text-[10px] h-5 px-2 gap-1 border-muted-foreground/50 text-muted-foreground",children:[e.jsx(xs,{className:"w-3 h-3"}),w("accountCard.quotaUnavailable")]})}):v?e.jsx(fe,{children:e.jsxs(ve,{children:[e.jsx(je,{asChild:!0,children:e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(G,{variant:"outline",className:B("text-[10px] h-5 px-2 gap-1",q),children:[e.jsx(b,{className:"w-3 h-3"}),v.label]})})}),e.jsx(Ne,{side:"bottom",className:"max-w-[260px]",children:e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("p",{children:v.summary}),v.actionHint&&e.jsx("p",{className:"text-muted-foreground",children:v.actionHint}),v.technicalDetail&&e.jsx("p",{className:"font-mono text-[11px] text-muted-foreground",children:v.technicalDetail}),v.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:v.rawDetail})]})})]})}):null})]})}function Va({selectedCount:s,onPauseSelected:t,onResumeSelected:a,onClearSelection:n,isPausing:i,isResuming:l}){if(s<1)return null;const u=i||l;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(I,{variant:"ghost",size:"sm",className:"text-xs h-6 px-2",onClick:n,disabled:u,children:"Clear"}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsxs(I,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:t,disabled:u,children:[i?e.jsx(W,{className:"w-3 h-3 animate-spin"}):e.jsx(Qe,{className:"w-3 h-3"}),"Pause Selected"]}),e.jsxs(I,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:a,disabled:u,children:[l?e.jsx(W,{className:"w-3 h-3 animate-spin"}):e.jsx(qs,{className:"w-3 h-3"}),"Resume Selected"]})]})]})}function Ba({accounts:s,onAddAccount:t,onSetDefault:a,onRemoveAccount:n,onPauseToggle:i,onSoloMode:l,onBulkPause:u,onBulkResume:o,isRemovingAccount:r,isPausingAccount:p,isSoloingAccount:N,isBulkPausing:w,isBulkResuming:f,privacyMode:O,showQuota:j,isKiro:k,kiroNoIncognito:A,onKiroNoIncognitoChange:P,kiroSettingsLoading:g}){const[m,y]=c.useState(new Set),C=c.useMemo(()=>new Set(s.map(_=>_.id)),[s]),M=c.useMemo(()=>new Set([...m].filter(_=>C.has(_))),[m,C]),d=!!(u&&o),S=M.size,D=s.length>0&&M.size===s.length,U=M.size>0&&M.size<s.length,h=c.useCallback(_=>{y(K=>{const V=new Set(K);return V.has(_)?V.delete(_):V.add(_),V})},[]),v=c.useCallback(()=>{y(new Set(s.map(_=>_.id)))},[s]),b=c.useCallback(()=>{y(new Set)},[]),q=c.useCallback(()=>{D?b():v()},[D,v,b]),L=c.useCallback(()=>{u&&M.size>0&&(u(Array.from(M)),y(new Set))},[u,M]),E=c.useCallback(()=>{o&&M.size>0&&(o(Array.from(M)),y(new Set))},[o,M]);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:[d&&s.length>0&&e.jsx(De,{checked:D,onCheckedChange:q,"aria-label":"Select all accounts",className:U?"data-[state=checked]:bg-primary/50":"",...U?{"data-state":"indeterminate"}:{}}),e.jsx(pe,{className:"w-4 h-4"}),"Accounts",s.length>0&&e.jsx(G,{variant:"secondary",className:"text-xs",children:s.length})]}),e.jsxs(I,{variant:"default",size:"sm",className:"h-7 text-xs gap-1",onClick:t,children:[e.jsx(Us,{className:"w-3 h-3"}),"Add"]})]}),d&&S>0&&e.jsx(Va,{selectedCount:S,onPauseSelected:L,onResumeSelected:E,onClearSelection:b,isPausing:!!w,isResuming:!!f}),s.length>0?e.jsx("div",{className:"space-y-2",children:s.map(_=>e.jsx(Ga,{account:_,onSetDefault:()=>a(_.id),onRemove:()=>n(_.id),onPauseToggle:i?K=>i(_.id,K):void 0,onSoloMode:l?()=>l(_.id):void 0,isRemoving:r,isPausingAccount:p,isSoloingAccount:N,privacyMode:O,showQuota:j,selectable:d,selected:M.has(_.id),onSelectChange:()=>h(_.id)},_.id))}):e.jsxs("div",{className:"py-6 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed",children:[e.jsx(pe,{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"})]}),k&&P&&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(Fs,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Use incognito"})]}),e.jsx(Gs,{checked:!A,onCheckedChange:_=>P(!_),disabled:g,className:"scale-90"})]})})]})}function za({provider:s,catalog:t,savedPresets:a,currentModel:n,opusModel:i,sonnetModel:l,haikuModel:u,providerModels:o,extendedContextEnabled:r,onExtendedContextToggle:p,onApplyPreset:N,onUpdateEnvValue:w,onOpenCustomPreset:f,onDeletePreset:O,isDeletePending:j,accounts:k,onAddAccount:A,onSetDefault:P,onRemoveAccount:g,onPauseToggle:m,onSoloMode:y,onBulkPause:C,onBulkResume:M,isRemovingAccount:d,isPausingAccount:S,isSoloingAccount:D,isBulkPausing:U,isBulkResuming:h,privacyMode:v,isRemoteMode:b}){const q=s.toLowerCase(),L=(At.includes(q)||["anthropic","antigravity","gemini-cli","copilot","github-copilot"].includes(q))&&!b,E=s==="kiro",[_,K]=c.useState(!0),[V,te]=c.useState(!0),[X,ae]=c.useState(!1),$=c.useCallback(async()=>{if(E)try{te(!0);const z=(await Me.config.get()).cliproxy;K(z?.kiro_no_incognito??!0)}catch{K(!0)}finally{te(!1)}},[E]),x=c.useCallback(async R=>{K(R),ae(!0);try{const z=await Me.config.get(),ne=z.cliproxy??{};await Me.config.update({...z,cliproxy:{...ne,kiro_no_incognito:R}})}catch{K(!R)}finally{ae(!1)}},[]);return c.useEffect(()=>{$()},[$]),e.jsx(es,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsx(Ha,{catalog:t,savedPresets:a,currentModel:n,opusModel:i,sonnetModel:l,haikuModel:u,providerModels:o,provider:s,extendedContextEnabled:r,onExtendedContextToggle:p,onApplyPreset:N,onUpdateEnvValue:w,onOpenCustomPreset:f,onDeletePreset:O,isDeletePending:j}),e.jsx(is,{}),e.jsx(Ba,{accounts:k,onAddAccount:A,onSetDefault:P,onRemoveAccount:g,onPauseToggle:m,onSoloMode:y,onBulkPause:C,onBulkResume:M,isRemovingAccount:d,isPausingAccount:S,isSoloingAccount:D,isBulkPausing:U,isBulkResuming:h,privacyMode:v,showQuota:L,isKiro:E,kiroNoIncognito:_,onKiroNoIncognitoChange:x,kiroSettingsLoading:V||X})]})})}function Ns({provider:s,displayName:t,authStatus:a,catalog:n,logoProvider:i,baseProvider:l,isRemoteMode:u,port:o,defaultTarget:r,onAddAccount:p,onSetDefault:N,onRemoveAccount:w,onPauseToggle:f,onSoloMode:O,onBulkPause:j,onBulkResume:k,isRemovingAccount:A,isPausingAccount:P,isSoloingAccount:g,isBulkPausing:m,isBulkResuming:y}){const[C,M]=c.useState(!1),{privacyMode:d}=Ms(),{data:S}=Pt(),{data:D}=St(s),U=Mt(),h=Tt(),v=l||s,b=v.toLowerCase()==="agy",q=c.useMemo(()=>{const F=D?.presets||[];return b?F.filter(Q=>!se(Q.default)&&!se(Q.opus)&&!se(Q.sonnet)&&!se(Q.haiku)):F},[b,D?.presets]),L=c.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"]}[v.toLowerCase()]||[v.toLowerCase()];return S.models.filter(ie=>Q.some(Ue=>ie.owned_by.toLowerCase().includes(Ue))?b?!se(ie.id):!0:!1)},[b,S,v]),E=(l||s).toLowerCase(),{data:_,isLoading:K,refetch:V,rawJsonContent:te,rawJsonEdits:X,isRawJsonValid:ae,hasChanges:$,currentModel:x,opusModel:R,sonnetModel:z,haikuModel:ne,extendedContextEnabled:he,toggleExtendedContext:ke,handleRawJsonChange:Ie,updateEnvValue:Le,updateEnvValues:Ae,saveMutation:Pe,conflictDialog:Fe,handleConflictResolve:J,missingRequiredFields:T}=Da(s),Y=c.useMemo(()=>(a.accounts||[]).map(F=>({...F,provider:F.provider||l||s})),[a.accounts,l,s]),{data:ge}=ws({queryKey:["auth-tokens-raw"],queryFn:async()=>{const F=await fetch("/api/settings/auth/tokens/raw");return F.ok?F.json():{apiKey:{value:"ccs-internal-managed"}}},staleTime:6e4}),oe=ge?.apiKey?.value??"ccs-internal-managed",Js=F=>{if(b&&[F.ANTHROPIC_MODEL,F.ANTHROPIC_DEFAULT_OPUS_MODEL,F.ANTHROPIC_DEFAULT_SONNET_MODEL,F.ANTHROPIC_DEFAULT_HAIKU_MODEL].some(ie=>typeof ie=="string"&&se(ie))){H.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}Ae({ANTHROPIC_BASE_URL:`http://127.0.0.1:${o??ze}/api/provider/${E}`,ANTHROPIC_AUTH_TOKEN:oe,...F}),H.success(`Applied "${F.ANTHROPIC_MODEL?.split("/").pop()||"preset"}" preset`)},Ws=(F,Q)=>{if(b&&[F.default,F.opus,F.sonnet,F.haiku].some(Ue=>se(Ue))){H.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}Ae({ANTHROPIC_BASE_URL:`http://127.0.0.1:${o??ze}/api/provider/${E}`,ANTHROPIC_AUTH_TOKEN:oe,ANTHROPIC_MODEL:F.default,ANTHROPIC_DEFAULT_OPUS_MODEL:F.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:F.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:F.haiku}),H.success(`Applied ${Q?`"${Q}"`:"custom"} preset`),M(!1)},Xs=(F,Q)=>{if(!Q){H.error(Ds.t("commonToast.enterPresetName"));return}if(b&&[F.default,F.opus,F.sonnet,F.haiku].some(ie=>se(ie))){H.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}U.mutate({profile:s,data:{name:Q,...F}}),M(!1)};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(Fa,{provider:s,displayName:t,logoProvider:i,data:_,isLoading:K,hasChanges:$,isRawJsonValid:ae,isSaving:Pe.isPending,isRemoteMode:u,port:o,onRefetch:V,onSave:()=>Pe.mutate()}),K?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(W,{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:"min-h-0 flex-1 grid grid-cols-[40%_60%] divide-x overflow-hidden",children:[e.jsx("div",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden bg-muted/5",children:e.jsxs(Dt,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Et,{className:"w-full",children:[e.jsx(us,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(us,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(ms,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(za,{provider:s,catalog:n,savedPresets:q,currentModel:x,opusModel:R,sonnetModel:z,haikuModel:ne,providerModels:L,extendedContextEnabled:he,onExtendedContextToggle:ke,onApplyPreset:Js,onUpdateEnvValue:Le,onOpenCustomPreset:()=>M(!0),onDeletePreset:F=>h.mutate({profile:s,name:F}),isDeletePending:h.isPending,accounts:Y,onAddAccount:p,onSetDefault:N,onRemoveAccount:w,onPauseToggle:f,onSoloMode:O,onBulkPause:j,onBulkResume:k,isRemovingAccount:A,isPausingAccount:P,isSoloingAccount:g,isBulkPausing:m,isBulkResuming:y,privacyMode:d,isRemoteMode:u})}),e.jsx(ms,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(La,{provider:s,displayName:t,defaultTarget:r,data:_,authStatus:a})})]})]})}),e.jsxs("div",{className:"flex min-h-0 min-w-0 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(aa,{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(Rt,{rawJsonContent:te,isRawJsonValid:ae,rawJsonEdits:X,onRawJsonChange:Ie,profileEnv:_?.settings?.env,missingRequiredFields:T})]})]}),e.jsx(ra,{open:Fe,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>J(!0),onCancel:()=>J(!1)}),e.jsx(Ia,{open:C,onClose:()=>M(!1),currentValues:{default:x||"",opus:R||"",sonnet:z||"",haiku:ne||""},onApply:Ws,onSave:Xs,isSaving:U.isPending,catalog:n,allModels:L})]})}function Qa({status:s,isSelected:t,onSelect:a}){const{t:n}=ee(),i=s.accounts?.length||0;return e.jsxs("button",{className:B("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(ss,{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}),i>0&&e.jsx(G,{variant:"secondary",className:"text-[10px] h-4 px-1",children:i})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:s.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(de,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-green-600",children:n("cliproxyPage.connected")})]}):e.jsxs(e.Fragment,{children:[e.jsx(ns,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:n("cliproxyPage.notConnected")})]})})]})]})}function $a({variant:s,parentAuth:t,isSelected:a,onSelect:n,onDelete:i,isDeleting:l}){const{t:u}=ee(),o=()=>{n()};return e.jsxs("div",{role:"button",tabIndex:0,className:B("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:o,onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),o())},children:[e.jsxs("div",{className:"relative",children:[e.jsx(ss,{provider:s.provider,size:"sm"}),e.jsx(Ks,{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(G,{variant:"outline",className:"text-[9px] h-4 px-1",children:u("cliproxyPage.variant")}),e.jsx(G,{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(de,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-muted-foreground truncate",children:u("cliproxyPage.viaProvider",{provider:s.provider})})]}):e.jsxs(e.Fragment,{children:[e.jsx(ns,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:u("cliproxyPage.parentNotConnected")})]})})]}),e.jsx(I,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:r=>{r.stopPropagation(),i()},disabled:l,children:e.jsx(Hs,{className:"w-3 h-3"})})]})}function Ja({onSetup:s}){const{t}=ee();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(Ce,{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(I,{onClick:s,className:"gap-2",children:[e.jsx(ye,{className:"w-4 h-4"}),t("cliproxyPage.quickSetup")]})]})})}function hn(){const{t:s}=ee(),t=Je(),{data:a,isLoading:n}=Ss(),{data:i,isFetching:l}=_t(),{data:u}=Ot(),o=It(),r=Lt(),p=Ft(),N=Ut(),w=qt(),f=Ht(),O=Kt(),j=Gt(),[k,A]=c.useState(()=>{if(typeof window<"u"){const R=new URLSearchParams(window.location.search).get("provider")?.trim().toLowerCase();return R&&Ve(R)?R:localStorage.getItem("cliproxy-selected-provider")}return null}),[P,g]=c.useState(null),[m,y]=c.useState(!1),[C,M]=c.useState(()=>{if(typeof window>"u")return null;const x=new URLSearchParams(window.location.search),R=x.get("provider")?.trim().toLowerCase();return x.get("action")!=="auth"||!R||!Ve(R)?null:{provider:R,displayName:Vt(R),isFirstAccount:!1}}),d=c.useMemo(()=>a?.authStatus||[],[a?.authStatus]),S=a?.source==="remote",D=c.useMemo(()=>i?.variants||[],[i?.variants]),U=x=>{A(x),x&&localStorage.setItem("cliproxy-selected-provider",x)},h=c.useMemo(()=>P?null:k&&d.some(x=>x.provider===k)?k:d.length>0&&(d.find(R=>(R.accounts?.length||0)>0)?.provider||d[0]?.provider)||null,[k,P,d]),v=d.find(x=>x.provider===h),b=D.find(x=>x.name===P),q=b?d.find(x=>x.provider===b.provider):void 0,L=(b?.provider||v?.provider||"").toLowerCase().trim(),E=L==="gemini"||L==="agy",_=()=>{t.invalidateQueries({queryKey:["cliproxy"]}),t.invalidateQueries({queryKey:["cliproxy-auth"]})},K=(x,R,z)=>{p.isPending||N.isPending||(z?p.mutate({provider:x,accountId:R}):N.mutate({provider:x,accountId:R}))},V=(x,R)=>{w.isPending||w.mutate({provider:x,accountId:R})},te=(x,R)=>{f.isPending||f.mutate({provider:x,accountIds:R})},X=(x,R)=>{O.isPending||O.mutate({provider:x,accountIds:R})},ae=x=>{U(x),g(null)},$=x=>{g(x),U(null)};return e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",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(Ce,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:u?.backendLabel??"CLIProxy"})]}),e.jsx(I,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:_,disabled:l,children:e.jsx(as,{className:B("w-4 h-4",l&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:s("cliproxyPage.accountManagement")}),e.jsxs(I,{variant:"default",size:"sm",className:"w-full gap-2",onClick:()=>y(!0),children:[e.jsx(ye,{className:"w-4 h-4"}),s("cliproxyPage.quickSetup")]})]}),e.jsx(es,{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")}),n?e.jsx("div",{className:"space-y-2 px-2",children:[1,2,3,4].map(x=>e.jsx(Bt,{className:"h-14 w-full rounded-lg"},x))}):e.jsx("div",{className:"space-y-1",children:d.map(x=>e.jsx(Qa,{status:x,isSelected:h===x.provider,onSelect:()=>ae(x.provider)},x.provider))}),D.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(Ks,{className:"w-3 h-3"}),s("cliproxyPage.variants")]}),e.jsx("div",{className:"space-y-1",children:D.map(x=>e.jsx($a,{variant:x,parentAuth:d.find(R=>R.provider===x.provider),isSelected:P===x.name,onSelect:()=>$(x.name),onDelete:()=>j.mutate(x.name),isDeleting:j.isPending},x.name))})]})]})}),e.jsx("div",{className:"p-3 border-t",children:e.jsx(la,{})}),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:d.length})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(de,{className:"w-3 h-3 text-green-600"}),s("cliproxyPage.connectedCount",{count:d.filter(x=>x.authenticated).length})]})]})})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0 bg-background",children:[E&&e.jsx($s,{showProxySettingsLink:!0,className:"mx-4 mt-4"}),b&&q?e.jsx(e.Fragment,{children:e.jsx(Ns,{provider:b.name,displayName:s("cliproxyPage.variantDisplay",{name:b.name,provider:b.provider}),authStatus:q,catalog:xe[b.provider],logoProvider:b.provider,baseProvider:b.provider,defaultTarget:b.target,isRemoteMode:S,port:b.port,onAddAccount:()=>M({provider:b.provider,displayName:q.displayName,isFirstAccount:(q.accounts?.length||0)===0}),onSetDefault:x=>o.mutate({provider:b.provider,accountId:x}),onRemoveAccount:x=>r.mutate({provider:b.provider,accountId:x}),onPauseToggle:(x,R)=>K(b.provider,x,R),onSoloMode:x=>V(b.provider,x),onBulkPause:x=>te(b.provider,x),onBulkResume:x=>X(b.provider,x),isRemovingAccount:r.isPending,isPausingAccount:p.isPending||N.isPending,isSoloingAccount:w.isPending,isBulkPausing:f.isPending,isBulkResuming:O.isPending})}):v?e.jsx(e.Fragment,{children:e.jsx(Ns,{provider:v.provider,displayName:v.displayName,authStatus:v,catalog:xe[v.provider],isRemoteMode:S,onAddAccount:()=>M({provider:v.provider,displayName:v.displayName,isFirstAccount:(v.accounts?.length||0)===0}),onSetDefault:x=>o.mutate({provider:v.provider,accountId:x}),onRemoveAccount:x=>r.mutate({provider:v.provider,accountId:x}),onPauseToggle:(x,R)=>K(v.provider,x,R),onSoloMode:x=>V(v.provider,x),onBulkPause:x=>te(v.provider,x),onBulkResume:x=>X(v.provider,x),isRemovingAccount:r.isPending,isPausingAccount:p.isPending||N.isPending,isSoloingAccount:w.isPending,isBulkPausing:f.isPending,isBulkResuming:O.isPending})}):e.jsx(Ja,{onSetup:()=>y(!0)})]}),e.jsx(wa,{open:m,onClose:()=>y(!1)}),e.jsx(Sa,{open:C!==null,onClose:()=>M(null),provider:C?.provider||"",displayName:C?.displayName||"",isFirstAccount:C?.isFirstAccount||!1})]})}export{hn as CliproxyPage};
|
package/dist/ui/assets/{cliproxy-ai-providers-VAxFHC4K.js → cliproxy-ai-providers-B4-qQbF8.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
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,ax as me,b4 as ue,B as h,ae as Ke,af as He,ag as Be,ah as De,ai as Fe,L as A,I as k,M as Ge,N as Ve,O as ze,aw as Je,d as f,Y as ae,S as fe,n as ee,Q as ve,R as ye,U as W,V as X,b5 as be,b6 as _e}from"./index-
|
|
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,ax as me,b4 as ue,B as h,ae as Ke,af as He,ag as Be,ah as De,ai as Fe,L as A,I as k,M as Ge,N as Ve,O as ze,aw as Je,d as f,Y as ae,S as fe,n as ee,Q as ve,R as ye,U as W,V as X,b5 as be,b6 as _e}from"./index-jRf9TX0x.js";import{P as Qe}from"./proxy-status-widget-CtV1jNBS.js";import{C as We}from"./confirm-dialog-DIuIPwxn.js";import{k as Xe,x as Pe,l as Ae,m as pe,ao as se,r as Ye,R as le,Z as Ze,a3 as Se,o as Ie,aC as es,I as ss,aj as ts,ak as rs,O as je,aD as Ue,aE as Le,aF as Me,an as as,aG as ns}from"./icons-EbXCUruD.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-BZ6JV1c0.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:r}){return e.jsx("div",{className:"space-y-1",children:t.map(a=>{const i=a.id===s,o=ls(a.status),d=o.icon;return e.jsx("button",{type:"button",onClick:()=>r(a.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(a.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:a.displayName}),a.entries.length>0&&e.jsx(h,{variant:"secondary",className:"h-4 px-1 text-[10px]",children:a.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:a.authMode})]})},a.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
2
|
`).map(s=>s.trim()).filter(s=>s.length>0)}function cs(t){return t.split(`
|
|
3
3
|
`).map(s=>s.trim()).filter(s=>s.length>0).map(s=>{const r=s.includes(":")?":":"=",[a,...i]=s.split(r);return{key:a.trim(),value:i.join(r).trim()}}).filter(s=>s.key.length>0)}function ms(t){return t.split(`
|
|
4
4
|
`).map(s=>s.trim()).filter(s=>s.length>0).map(s=>{const r=s.indexOf("=");return r===-1?{name:s.trim(),alias:""}:{name:s.slice(0,r).trim(),alias:s.slice(r+1).trim()}}).filter(s=>s.name.length>0||s.alias.length>0)}function Y({value:t,onChange:s,placeholder:r,rows:a=4}){return e.jsx("textarea",{rows:a,value:t,onChange:i=>s(i.target.value),placeholder:r,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(`
|
package/dist/ui/assets/{cliproxy-control-panel-Bd80kVsY.js → cliproxy-control-panel-w2F2zCtp.js}
RENAMED
|
@@ -1 +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,b7 as A}from"./index-
|
|
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,b7 as A}from"./index-jRf9TX0x.js";import{C as P}from"./default-ports-1QQSffYX.js";import{G as M,R as k,x as q}from"./icons-EbXCUruD.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:"flex h-full min-h-0 flex-col overflow-hidden",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-BZ6JV1c0.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};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Dt3edmE5.js";import{b7 as w,b8 as Pe,B as S,d as N,a as ie,V as ne,n as G,L as T,I as ce,r as ke,s as Fe,t as Te,v as Me,w as X,x as he,b9 as Le,S as b,ba as Re,bb as Ae,bc as Oe,Q as Ee,R as _e,U as Y,bd as qe,c as se}from"./index-lttPkZpv.js";import{r as v}from"./react-vendor-CNOkPC89.js";import{a as De,u as _,b as M}from"./tanstack-B8i0evp-.js";import{C as Ie}from"./confirm-dialog-BE-5hP8L.js";import{R as ge,L as fe,ak as Ke,a4 as Ue,Z as de,O as Qe,T as je,an as $e,b as Je,a7 as ze,at as Be,aH as me,K as He,N as Ge,aI as Ve,v as ve,w as we}from"./icons-EbXCUruD.js";import{S as ae}from"./separator-DL9wgY_Q.js";import{S as We}from"./searchable-select-z_lKd8bq.js";import{S as Z}from"./switch-hUEOHCrU.js";import{t as q}from"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-B_dqaWsT.js";async function Xe(){const t=await fetch(w("/copilot/status"));if(!t.ok)throw new Error("Failed to fetch copilot status");return t.json()}async function Ye(){const t=await fetch(w("/copilot/config"));if(!t.ok)throw new Error("Failed to fetch copilot config");return t.json()}async function Ze(){const t=await fetch(w("/copilot/models"));if(!t.ok)throw new Error("Failed to fetch copilot models");return t.json()}async function et(){const t=await fetch(w("/copilot/settings/raw"));if(!t.ok)throw new Error("Failed to fetch copilot raw settings");return t.json()}async function tt(t){const s=await fetch(w("/copilot/config"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!s.ok)throw new Error("Failed to update copilot config");return s.json()}async function st(t){const s=await fetch(w("/copilot/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(s.status===409)throw new Pe("Copilot raw settings changed externally");if(!s.ok)throw new Error("Failed to save copilot raw settings");return s.json()}async function at(){const t=await fetch(w("/copilot/auth/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start auth");return t.json()}async function it(){const t=await fetch(w("/copilot/daemon/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start daemon");return t.json()}async function nt(){const t=await fetch(w("/copilot/daemon/stop"),{method:"POST"});if(!t.ok)throw new Error("Failed to stop daemon");return t.json()}async function ot(){const t=await fetch(w("/copilot/info"));if(!t.ok)throw new Error("Failed to fetch copilot info");return t.json()}async function lt(t){const s=await fetch(w("/copilot/install"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{version:t}:{})});if(!s.ok)throw new Error("Failed to install copilot-api");return s.json()}function Ne(){const t=De(),s=_({queryKey:["copilot-status"],queryFn:Xe,refetchInterval:5e3}),l=_({queryKey:["copilot-config"],queryFn:Ye}),c=_({queryKey:["copilot-models"],queryFn:Ze}),i=_({queryKey:["copilot-raw-settings"],queryFn:et}),d=_({queryKey:["copilot-info"],queryFn:ot}),r=M({mutationFn:tt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),n=M({mutationFn:st,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),x=M({mutationFn:at,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),p=M({mutationFn:it,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),g=M({mutationFn:nt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),o=M({mutationFn:lt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-info"]})}});return v.useMemo(()=>({status:s.data,statusLoading:s.isLoading,statusError:s.error,refetchStatus:s.refetch,config:l.data,configLoading:l.isLoading,models:c.data?.models??[],currentModel:c.data?.current,modelsLoading:c.isLoading,rawSettings:i.data,rawSettingsLoading:i.isLoading,refetchRawSettings:i.refetch,updateConfig:r.mutate,updateConfigAsync:r.mutateAsync,isUpdating:r.isPending,saveRawSettings:n.mutate,saveRawSettingsAsync:n.mutateAsync,isSavingRawSettings:n.isPending,startAuth:x.mutate,startAuthAsync:x.mutateAsync,isAuthenticating:x.isPending,authResult:x.data,startDaemon:p.mutate,isStartingDaemon:p.isPending,stopDaemon:g.mutate,isStoppingDaemon:g.isPending,info:d.data,infoLoading:d.isLoading,refetchInfo:d.refetch,install:o.mutate,installAsync:o.mutateAsync,isInstalling:o.isPending}),[s.data,s.isLoading,s.error,s.refetch,l.data,l.isLoading,c.data,c.isLoading,i.data,i.isLoading,i.refetch,r.mutate,r.mutateAsync,r.isPending,n.mutate,n.mutateAsync,n.isPending,x.mutate,x.mutateAsync,x.isPending,x.data,p.mutate,p.isPending,g.mutate,g.isPending,d.data,d.isLoading,d.refetch,o.mutate,o.mutateAsync,o.isPending])}function rt({rawSettings:t,rawSettingsLoading:s,isUpdating:l,isSavingRawSettings:c,hasChanges:i,isRawJsonValid:d,onRefresh:r,onSave:n}){return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Copilot Configuration"}),t&&e.jsx(S,{variant:"outline",className:"text-xs",children:"copilot.settings.json"})]}),t&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified:"," ",t.exists?new Date(t.mtime).toLocaleString():"Never saved"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{variant:"ghost",size:"sm",onClick:r,disabled:s,children:e.jsx(ge,{className:`w-4 h-4 ${s?"animate-spin":""}`})}),e.jsx(N,{size:"sm",onClick:n,disabled:l||c||!i||!d,children:l||c?e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ke,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}const ct=[{name:"GPT-4.1 (Free)",description:"Free tier - no premium usage",default:"gpt-4.1",opus:"gpt-4.1",sonnet:"gpt-4.1",haiku:"gpt-4.1"},{name:"GPT-5 Mini (Free)",description:"Free tier - lightweight model",default:"gpt-5-mini",opus:"gpt-5-mini",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"}],dt=[{name:"Claude Opus 4.5",description:"Pro+ (3x) - Most capable reasoning",default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"Claude Sonnet 4.5",description:"Pro+ (1x) - Balanced performance",default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"GPT-5.2",description:"Pro+ (1x) - Latest OpenAI (Preview)",default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"},{name:"GPT-5.1 Codex Max",description:"Pro+ (1x) - Best for coding",default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex",haiku:"gpt-5.1-codex-mini"},{name:"Gemini 2.5 Pro",description:"Pro+ (1x) - Google latest",default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-3-flash"}];function ue(t){switch(t){case"free":return"bg-green-100 text-green-700 border-green-200";case"pro":return"bg-blue-100 text-blue-700 border-blue-200";case"pro+":return"bg-purple-100 text-purple-700 border-purple-200";case"business":return"bg-orange-100 text-orange-700 border-orange-200";case"enterprise":return"bg-red-100 text-red-700 border-red-200";default:return"bg-muted text-muted-foreground"}}function mt(t){return t==null?null:t===0?"Free":t<1?`${t}x`:t===1?"1x":`${t}x`}function z({label:t,description:s,value:l,onChange:c,models:i,disabled:d}){const{t:r}=ie();return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:t}),s&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s})]}),e.jsx(We,{value:l||void 0,onChange:c,disabled:d,placeholder:r("componentModelSelector.selectModel"),searchPlaceholder:r("searchableSelect.searchModels"),emptyText:r("searchableSelect.noResults"),triggerClassName:"h-9",groups:[{key:"models",label:r("componentModelSelector.availableModelsCount",{count:i.length})}],options:i.map(n=>({value:n.id,groupKey:"models",searchText:`${n.name||n.id} ${n.id}`,keywords:[n.minPlan??"",n.preview?"preview":""],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:n.id}),n.minPlan&&e.jsx(S,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ue(n.minPlan)}`,children:n.minPlan})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:n.name||n.id}),n.minPlan&&e.jsx(S,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ue(n.minPlan)}`,children:n.minPlan}),n.multiplier!==void 0&&e.jsx("span",{className:"text-[9px] text-muted-foreground",children:mt(n.multiplier)}),n.preview&&e.jsx(S,{variant:"secondary",className:"text-[9px] px-1 py-0 h-4",children:r("componentModelSelector.preview")})]})}))})]})}function ee(t){if(t>=1e6){const s=t/1e6;return s%1===0?`${s}M`:`${s.toFixed(1)}M`}if(t>=1e3){const s=t/1e3;return s%1===0?`${s}K`:`${s.toFixed(1)}K`}return`${t}`}function ut(t){if(!t?.limits)return null;const s=[];return t.limits.maxPromptTokens&&s.push(`prompt ${ee(t.limits.maxPromptTokens)}`),t.limits.maxContextWindowTokens&&s.push(`context ${ee(t.limits.maxContextWindowTokens)}`),t.limits.maxOutputTokens&&s.push(`output ${ee(t.limits.maxOutputTokens)}`),s.length>0?s.join(" | "):null}function xt({currentModel:t,opusModel:s,sonnetModel:l,haikuModel:c,models:i,modelsLoading:d,onApplyPreset:r,onUpdateModel:n,onUpdateOpusModel:x,onUpdateSonnetModel:p,onUpdateHaikuModel:g}){const o=[{label:"Default",id:t},{label:"Opus",id:s||t},{label:"Sonnet",id:l||t},{label:"Haiku",id:c||t}].map(({label:a,id:u})=>{const y=i.find(P=>P.id===u),C=ut(y);return C?{label:a,id:u,limits:C}:null}).filter(a=>a!==null);return e.jsx(ne,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(G,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(Ue,{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:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(S,{variant:"outline",className:"text-[10px] bg-green-100 text-green-700 border-green-200",children:"Free Tier"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"No premium usage count"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ct.map(a=>e.jsxs(N,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>r(a),title:a.description,children:[e.jsx(de,{className:"w-3 h-3 text-green-600"}),a.name]},a.name))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(S,{variant:"outline",className:"text-[10px] bg-blue-100 text-blue-700 border-blue-200",children:"Pro+ Required"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Uses premium request quota"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:dt.map(a=>e.jsxs(N,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>r(a),title:a.description,children:[e.jsx(de,{className:"w-3 h-3"}),a.name]},a.name))})]})]}),e.jsx(ae,{}),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"}),e.jsxs("div",{className:"mb-4 rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-xs text-amber-900 dark:text-amber-200",children:[e.jsx("p",{className:"font-medium",children:"GitHub Copilot controls prompt/context limits upstream."}),e.jsx("p",{className:"mt-1",children:"CCS can switch Copilot models, but it cannot increase the provider's max prompt or context window."}),o.length>0?e.jsx("div",{className:"mt-2 space-y-1 text-[11px] font-mono",children:o.map(a=>e.jsxs("p",{children:[a.label,": ",a.id," (",a.limits,")"]},`${a.label}-${a.id}`))}):e.jsx("p",{className:"mt-2 text-[11px] font-mono",children:"Start the daemon to inspect live model limits from GitHub Copilot metadata."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(z,{label:"Default Model",description:"Used when no specific tier is requested",value:t,onChange:n,models:i,disabled:d}),e.jsx(z,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:s||t,onChange:x,models:i,disabled:d}),e.jsx(z,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:l||t,onChange:p,models:i,disabled:d}),e.jsx(z,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:c||t,onChange:g,models:i,disabled:d})]})]})]})})})}function pt({enabled:t,autoStart:s,port:l,accountType:c,rateLimit:i,waitOnLimit:d,onUpdateEnabled:r,onUpdateAutoStart:n,onUpdatePort:x,onUpdateAccountType:p,onUpdateRateLimit:g,onUpdateWaitOnLimit:o}){const{t:a}=ie();return e.jsx(ne,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(G,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(T,{htmlFor:"enabled",className:"text-sm font-medium",children:a("copilotSettings.enableCopilot")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("copilotSettings.enableCopilotDesc")})]}),e.jsx(Z,{id:"enabled",checked:t,onCheckedChange:r})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:a("copilotSettings.basicSettings")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"port",className:"text-xs",children:a("copilotPage.port")}),e.jsx(ce,{id:"port",type:"number",value:l,onChange:u=>x(parseInt(u.target.value,10)),min:1024,max:65535,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"account-type",className:"text-xs",children:a("copilotSettings.accountType")}),e.jsxs(ke,{value:c,onValueChange:p,children:[e.jsx(Fe,{id:"account-type",className:"max-w-[150px] h-8",children:e.jsx(Te,{})}),e.jsxs(Me,{children:[e.jsx(X,{value:"individual",children:a("copilotSettings.accountTypeIndividual")}),e.jsx(X,{value:"business",children:a("copilotSettings.accountTypeBusiness")}),e.jsx(X,{value:"enterprise",children:a("copilotSettings.accountTypeEnterprise")})]})]})]})]}),e.jsx(ae,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:a("copilotSettings.rateLimiting")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"rate-limit",className:"text-xs",children:a("copilotSettings.rateLimitSeconds")}),e.jsx(ce,{id:"rate-limit",type:"number",value:i,onChange:u=>g(u.target.value),placeholder:a("copilotSettings.noLimit"),min:0,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(T,{htmlFor:"wait-on-limit",className:"text-xs",children:a("copilotSettings.waitOnRateLimit")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a("copilotSettings.waitOnRateLimitDesc")})]}),e.jsx(Z,{id:"wait-on-limit",checked:d,onCheckedChange:o})]})]}),e.jsx(ae,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:a("copilotSettings.daemonSettings")}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(T,{htmlFor:"auto-start",className:"text-xs",children:a("copilotSettings.autoStartDaemon")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a("copilotSettings.autoStartDaemonDesc")})]}),e.jsx(Z,{id:"auto-start",checked:s,onCheckedChange:n})]})]})]})})})}function B({label:t,command:s}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:t}),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:s}),e.jsx(he,{value:s,size:"icon",className:"h-6 w-6"})]})]})}function ht({rawSettings:t}){return e.jsx(ne,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(G,{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(Qe,{className:"w-4 h-4"}),"Configuration Info"]}),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:"GitHub Copilot"})]}),t&&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:t.path}),e.jsx(he,{value:t.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:"Status"}),e.jsx(S,{variant:"outline",className:t.exists?"w-fit text-green-600 border-green-200 bg-green-50":"w-fit text-muted-foreground",children:t.exists?"File exists":"Using defaults"})]})]})]})]}),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(B,{label:"Run with Copilot",command:"ccs copilot"}),e.jsx(B,{label:"Authenticate",command:"ccs copilot auth"}),e.jsx(B,{label:"Start daemon",command:"ccs copilot --start"}),e.jsx(B,{label:"Stop daemon",command:"ccs copilot --stop"})]})]})]})})})}const gt=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function xe(t){const s=t?.env||{};return gt.filter(l=>!s[l]?.trim())}function pe(t){if(!t||t.length===0)return[];const s=new Map;return t.forEach(l=>{s.set(l.message,l)}),[...s.values()]}function ft(){const{config:t,configLoading:s,models:l,modelsLoading:c,rawSettings:i,rawSettingsLoading:d,updateConfigAsync:r,isUpdating:n,saveRawSettingsAsync:x,isSavingRawSettings:p,refetchRawSettings:g}=Ne(),[o,a]=v.useState({}),[u,y]=v.useState(null),[C,P]=v.useState(!1),D=o.enabled??t?.enabled??!1,I=o.autoStart??t?.auto_start??!1,L=o.port??t?.port??4141,K=o.accountType??t?.account_type??"individual",R=o.model??t?.model??"claude-sonnet-4-6",A=o.rateLimit??t?.rate_limit?.toString()??"",f=o.waitOnLimit??t?.wait_on_limit??!0,U=o.opusModel??t?.opus_model??"",Q=o.sonnetModel??t?.sonnet_model??"",$=o.haikuModel??t?.haiku_model??"",J=(h,j)=>{a(O=>({...O,[h]:j}))},V=h=>{a(j=>({...j,model:h.default,opusModel:h.opus,sonnetModel:h.sonnet,haikuModel:h.haiku})),q.success(`Applied "${h.name}" preset`)},k=v.useMemo(()=>u!==null?u:i?.settings?JSON.stringify(i.settings,null,2):`{
|
|
1
|
+
import{j as e}from"./radix-ui-Dt3edmE5.js";import{b7 as w,b8 as Pe,B as S,d as N,a as ie,V as ne,n as G,L as T,I as ce,r as ke,s as Fe,t as Te,v as Me,w as X,x as he,b9 as Le,S as b,ba as Re,bb as Ae,bc as Oe,Q as Ee,R as _e,U as Y,bd as qe,c as se}from"./index-jRf9TX0x.js";import{r as v}from"./react-vendor-CNOkPC89.js";import{a as De,u as _,b as M}from"./tanstack-B8i0evp-.js";import{C as Ie}from"./confirm-dialog-DIuIPwxn.js";import{R as ge,L as fe,ak as Ke,a4 as Ue,Z as de,O as Qe,T as je,an as $e,b as Je,a7 as ze,at as Be,aH as me,K as He,N as Ge,aI as Ve,v as ve,w as we}from"./icons-EbXCUruD.js";import{S as ae}from"./separator-D_QkAzrO.js";import{S as We}from"./searchable-select-alvnHZb-.js";import{S as Z}from"./switch-wk_QOO2s.js";import{t as q}from"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-BZ6JV1c0.js";async function Xe(){const t=await fetch(w("/copilot/status"));if(!t.ok)throw new Error("Failed to fetch copilot status");return t.json()}async function Ye(){const t=await fetch(w("/copilot/config"));if(!t.ok)throw new Error("Failed to fetch copilot config");return t.json()}async function Ze(){const t=await fetch(w("/copilot/models"));if(!t.ok)throw new Error("Failed to fetch copilot models");return t.json()}async function et(){const t=await fetch(w("/copilot/settings/raw"));if(!t.ok)throw new Error("Failed to fetch copilot raw settings");return t.json()}async function tt(t){const s=await fetch(w("/copilot/config"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!s.ok)throw new Error("Failed to update copilot config");return s.json()}async function st(t){const s=await fetch(w("/copilot/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(s.status===409)throw new Pe("Copilot raw settings changed externally");if(!s.ok)throw new Error("Failed to save copilot raw settings");return s.json()}async function at(){const t=await fetch(w("/copilot/auth/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start auth");return t.json()}async function it(){const t=await fetch(w("/copilot/daemon/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start daemon");return t.json()}async function nt(){const t=await fetch(w("/copilot/daemon/stop"),{method:"POST"});if(!t.ok)throw new Error("Failed to stop daemon");return t.json()}async function ot(){const t=await fetch(w("/copilot/info"));if(!t.ok)throw new Error("Failed to fetch copilot info");return t.json()}async function lt(t){const s=await fetch(w("/copilot/install"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{version:t}:{})});if(!s.ok)throw new Error("Failed to install copilot-api");return s.json()}function Ne(){const t=De(),s=_({queryKey:["copilot-status"],queryFn:Xe,refetchInterval:5e3}),l=_({queryKey:["copilot-config"],queryFn:Ye}),c=_({queryKey:["copilot-models"],queryFn:Ze}),i=_({queryKey:["copilot-raw-settings"],queryFn:et}),d=_({queryKey:["copilot-info"],queryFn:ot}),r=M({mutationFn:tt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),n=M({mutationFn:st,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),x=M({mutationFn:at,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),p=M({mutationFn:it,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),g=M({mutationFn:nt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),o=M({mutationFn:lt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-info"]})}});return v.useMemo(()=>({status:s.data,statusLoading:s.isLoading,statusError:s.error,refetchStatus:s.refetch,config:l.data,configLoading:l.isLoading,models:c.data?.models??[],currentModel:c.data?.current,modelsLoading:c.isLoading,rawSettings:i.data,rawSettingsLoading:i.isLoading,refetchRawSettings:i.refetch,updateConfig:r.mutate,updateConfigAsync:r.mutateAsync,isUpdating:r.isPending,saveRawSettings:n.mutate,saveRawSettingsAsync:n.mutateAsync,isSavingRawSettings:n.isPending,startAuth:x.mutate,startAuthAsync:x.mutateAsync,isAuthenticating:x.isPending,authResult:x.data,startDaemon:p.mutate,isStartingDaemon:p.isPending,stopDaemon:g.mutate,isStoppingDaemon:g.isPending,info:d.data,infoLoading:d.isLoading,refetchInfo:d.refetch,install:o.mutate,installAsync:o.mutateAsync,isInstalling:o.isPending}),[s.data,s.isLoading,s.error,s.refetch,l.data,l.isLoading,c.data,c.isLoading,i.data,i.isLoading,i.refetch,r.mutate,r.mutateAsync,r.isPending,n.mutate,n.mutateAsync,n.isPending,x.mutate,x.mutateAsync,x.isPending,x.data,p.mutate,p.isPending,g.mutate,g.isPending,d.data,d.isLoading,d.refetch,o.mutate,o.mutateAsync,o.isPending])}function rt({rawSettings:t,rawSettingsLoading:s,isUpdating:l,isSavingRawSettings:c,hasChanges:i,isRawJsonValid:d,onRefresh:r,onSave:n}){return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Copilot Configuration"}),t&&e.jsx(S,{variant:"outline",className:"text-xs",children:"copilot.settings.json"})]}),t&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified:"," ",t.exists?new Date(t.mtime).toLocaleString():"Never saved"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{variant:"ghost",size:"sm",onClick:r,disabled:s,children:e.jsx(ge,{className:`w-4 h-4 ${s?"animate-spin":""}`})}),e.jsx(N,{size:"sm",onClick:n,disabled:l||c||!i||!d,children:l||c?e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ke,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}const ct=[{name:"GPT-4.1 (Free)",description:"Free tier - no premium usage",default:"gpt-4.1",opus:"gpt-4.1",sonnet:"gpt-4.1",haiku:"gpt-4.1"},{name:"GPT-5 Mini (Free)",description:"Free tier - lightweight model",default:"gpt-5-mini",opus:"gpt-5-mini",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"}],dt=[{name:"Claude Opus 4.5",description:"Pro+ (3x) - Most capable reasoning",default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"Claude Sonnet 4.5",description:"Pro+ (1x) - Balanced performance",default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"GPT-5.2",description:"Pro+ (1x) - Latest OpenAI (Preview)",default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"},{name:"GPT-5.1 Codex Max",description:"Pro+ (1x) - Best for coding",default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex",haiku:"gpt-5.1-codex-mini"},{name:"Gemini 2.5 Pro",description:"Pro+ (1x) - Google latest",default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-3-flash"}];function ue(t){switch(t){case"free":return"bg-green-100 text-green-700 border-green-200";case"pro":return"bg-blue-100 text-blue-700 border-blue-200";case"pro+":return"bg-purple-100 text-purple-700 border-purple-200";case"business":return"bg-orange-100 text-orange-700 border-orange-200";case"enterprise":return"bg-red-100 text-red-700 border-red-200";default:return"bg-muted text-muted-foreground"}}function mt(t){return t==null?null:t===0?"Free":t<1?`${t}x`:t===1?"1x":`${t}x`}function z({label:t,description:s,value:l,onChange:c,models:i,disabled:d}){const{t:r}=ie();return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:t}),s&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s})]}),e.jsx(We,{value:l||void 0,onChange:c,disabled:d,placeholder:r("componentModelSelector.selectModel"),searchPlaceholder:r("searchableSelect.searchModels"),emptyText:r("searchableSelect.noResults"),triggerClassName:"h-9",groups:[{key:"models",label:r("componentModelSelector.availableModelsCount",{count:i.length})}],options:i.map(n=>({value:n.id,groupKey:"models",searchText:`${n.name||n.id} ${n.id}`,keywords:[n.minPlan??"",n.preview?"preview":""],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:n.id}),n.minPlan&&e.jsx(S,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ue(n.minPlan)}`,children:n.minPlan})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:n.name||n.id}),n.minPlan&&e.jsx(S,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ue(n.minPlan)}`,children:n.minPlan}),n.multiplier!==void 0&&e.jsx("span",{className:"text-[9px] text-muted-foreground",children:mt(n.multiplier)}),n.preview&&e.jsx(S,{variant:"secondary",className:"text-[9px] px-1 py-0 h-4",children:r("componentModelSelector.preview")})]})}))})]})}function ee(t){if(t>=1e6){const s=t/1e6;return s%1===0?`${s}M`:`${s.toFixed(1)}M`}if(t>=1e3){const s=t/1e3;return s%1===0?`${s}K`:`${s.toFixed(1)}K`}return`${t}`}function ut(t){if(!t?.limits)return null;const s=[];return t.limits.maxPromptTokens&&s.push(`prompt ${ee(t.limits.maxPromptTokens)}`),t.limits.maxContextWindowTokens&&s.push(`context ${ee(t.limits.maxContextWindowTokens)}`),t.limits.maxOutputTokens&&s.push(`output ${ee(t.limits.maxOutputTokens)}`),s.length>0?s.join(" | "):null}function xt({currentModel:t,opusModel:s,sonnetModel:l,haikuModel:c,models:i,modelsLoading:d,onApplyPreset:r,onUpdateModel:n,onUpdateOpusModel:x,onUpdateSonnetModel:p,onUpdateHaikuModel:g}){const o=[{label:"Default",id:t},{label:"Opus",id:s||t},{label:"Sonnet",id:l||t},{label:"Haiku",id:c||t}].map(({label:a,id:u})=>{const y=i.find(P=>P.id===u),C=ut(y);return C?{label:a,id:u,limits:C}:null}).filter(a=>a!==null);return e.jsx(ne,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(G,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(Ue,{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:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(S,{variant:"outline",className:"text-[10px] bg-green-100 text-green-700 border-green-200",children:"Free Tier"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"No premium usage count"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ct.map(a=>e.jsxs(N,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>r(a),title:a.description,children:[e.jsx(de,{className:"w-3 h-3 text-green-600"}),a.name]},a.name))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(S,{variant:"outline",className:"text-[10px] bg-blue-100 text-blue-700 border-blue-200",children:"Pro+ Required"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Uses premium request quota"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:dt.map(a=>e.jsxs(N,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>r(a),title:a.description,children:[e.jsx(de,{className:"w-3 h-3"}),a.name]},a.name))})]})]}),e.jsx(ae,{}),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"}),e.jsxs("div",{className:"mb-4 rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-xs text-amber-900 dark:text-amber-200",children:[e.jsx("p",{className:"font-medium",children:"GitHub Copilot controls prompt/context limits upstream."}),e.jsx("p",{className:"mt-1",children:"CCS can switch Copilot models, but it cannot increase the provider's max prompt or context window."}),o.length>0?e.jsx("div",{className:"mt-2 space-y-1 text-[11px] font-mono",children:o.map(a=>e.jsxs("p",{children:[a.label,": ",a.id," (",a.limits,")"]},`${a.label}-${a.id}`))}):e.jsx("p",{className:"mt-2 text-[11px] font-mono",children:"Start the daemon to inspect live model limits from GitHub Copilot metadata."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(z,{label:"Default Model",description:"Used when no specific tier is requested",value:t,onChange:n,models:i,disabled:d}),e.jsx(z,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:s||t,onChange:x,models:i,disabled:d}),e.jsx(z,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:l||t,onChange:p,models:i,disabled:d}),e.jsx(z,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:c||t,onChange:g,models:i,disabled:d})]})]})]})})})}function pt({enabled:t,autoStart:s,port:l,accountType:c,rateLimit:i,waitOnLimit:d,onUpdateEnabled:r,onUpdateAutoStart:n,onUpdatePort:x,onUpdateAccountType:p,onUpdateRateLimit:g,onUpdateWaitOnLimit:o}){const{t:a}=ie();return e.jsx(ne,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(G,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(T,{htmlFor:"enabled",className:"text-sm font-medium",children:a("copilotSettings.enableCopilot")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("copilotSettings.enableCopilotDesc")})]}),e.jsx(Z,{id:"enabled",checked:t,onCheckedChange:r})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:a("copilotSettings.basicSettings")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"port",className:"text-xs",children:a("copilotPage.port")}),e.jsx(ce,{id:"port",type:"number",value:l,onChange:u=>x(parseInt(u.target.value,10)),min:1024,max:65535,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"account-type",className:"text-xs",children:a("copilotSettings.accountType")}),e.jsxs(ke,{value:c,onValueChange:p,children:[e.jsx(Fe,{id:"account-type",className:"max-w-[150px] h-8",children:e.jsx(Te,{})}),e.jsxs(Me,{children:[e.jsx(X,{value:"individual",children:a("copilotSettings.accountTypeIndividual")}),e.jsx(X,{value:"business",children:a("copilotSettings.accountTypeBusiness")}),e.jsx(X,{value:"enterprise",children:a("copilotSettings.accountTypeEnterprise")})]})]})]})]}),e.jsx(ae,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:a("copilotSettings.rateLimiting")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"rate-limit",className:"text-xs",children:a("copilotSettings.rateLimitSeconds")}),e.jsx(ce,{id:"rate-limit",type:"number",value:i,onChange:u=>g(u.target.value),placeholder:a("copilotSettings.noLimit"),min:0,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(T,{htmlFor:"wait-on-limit",className:"text-xs",children:a("copilotSettings.waitOnRateLimit")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a("copilotSettings.waitOnRateLimitDesc")})]}),e.jsx(Z,{id:"wait-on-limit",checked:d,onCheckedChange:o})]})]}),e.jsx(ae,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:a("copilotSettings.daemonSettings")}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(T,{htmlFor:"auto-start",className:"text-xs",children:a("copilotSettings.autoStartDaemon")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a("copilotSettings.autoStartDaemonDesc")})]}),e.jsx(Z,{id:"auto-start",checked:s,onCheckedChange:n})]})]})]})})})}function B({label:t,command:s}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:t}),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:s}),e.jsx(he,{value:s,size:"icon",className:"h-6 w-6"})]})]})}function ht({rawSettings:t}){return e.jsx(ne,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(G,{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(Qe,{className:"w-4 h-4"}),"Configuration Info"]}),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:"GitHub Copilot"})]}),t&&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:t.path}),e.jsx(he,{value:t.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:"Status"}),e.jsx(S,{variant:"outline",className:t.exists?"w-fit text-green-600 border-green-200 bg-green-50":"w-fit text-muted-foreground",children:t.exists?"File exists":"Using defaults"})]})]})]})]}),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(B,{label:"Run with Copilot",command:"ccs copilot"}),e.jsx(B,{label:"Authenticate",command:"ccs copilot auth"}),e.jsx(B,{label:"Start daemon",command:"ccs copilot --start"}),e.jsx(B,{label:"Stop daemon",command:"ccs copilot --stop"})]})]})]})})})}const gt=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function xe(t){const s=t?.env||{};return gt.filter(l=>!s[l]?.trim())}function pe(t){if(!t||t.length===0)return[];const s=new Map;return t.forEach(l=>{s.set(l.message,l)}),[...s.values()]}function ft(){const{config:t,configLoading:s,models:l,modelsLoading:c,rawSettings:i,rawSettingsLoading:d,updateConfigAsync:r,isUpdating:n,saveRawSettingsAsync:x,isSavingRawSettings:p,refetchRawSettings:g}=Ne(),[o,a]=v.useState({}),[u,y]=v.useState(null),[C,P]=v.useState(!1),D=o.enabled??t?.enabled??!1,I=o.autoStart??t?.auto_start??!1,L=o.port??t?.port??4141,K=o.accountType??t?.account_type??"individual",R=o.model??t?.model??"claude-sonnet-4-6",A=o.rateLimit??t?.rate_limit?.toString()??"",f=o.waitOnLimit??t?.wait_on_limit??!0,U=o.opusModel??t?.opus_model??"",Q=o.sonnetModel??t?.sonnet_model??"",$=o.haikuModel??t?.haiku_model??"",J=(h,j)=>{a(O=>({...O,[h]:j}))},V=h=>{a(j=>({...j,model:h.default,opusModel:h.opus,sonnetModel:h.sonnet,haikuModel:h.haiku})),q.success(`Applied "${h.name}" preset`)},k=v.useMemo(()=>u!==null?u:i?.settings?JSON.stringify(i.settings,null,2):`{
|
|
2
2
|
"env": {}
|
|
3
3
|
}`,[u,i]),m=v.useCallback(h=>{y(h)},[]),oe=v.useMemo(()=>{try{return JSON.parse(k),!0}catch{return!1}},[k]),be=v.useMemo(()=>{const h=Object.keys(o).length>0,j=u!==null&&u!==JSON.stringify(i?.settings,null,2);return h||j},[o,u,i]),le=v.useMemo(()=>{if(u!==null)try{return JSON.parse(u)}catch{return i?.settings}return i?.settings},[u,i?.settings]),ye=v.useMemo(()=>xe(le),[le]),Se=v.useMemo(()=>pe([...t?.warnings??[],...i?.warnings??[]]),[t?.warnings,i?.warnings]),re=async({overwriteRawSettings:h=!1}={})=>{try{const j=[];if(Object.keys(o).length>0){const F=await r({enabled:D,auto_start:I,port:L,account_type:K,model:R,rate_limit:A?parseInt(A,10):null,wait_on_limit:f,opus_model:U||void 0,sonnet_model:Q||void 0,haiku_model:$||void 0});j.push(...F.warnings??[])}let O=[];if(u!==null&&oe){const F=JSON.parse(k);O=xe(F);const Ce=await x({settings:F,expectedMtime:h?void 0:i?.mtime});j.push(...Ce.warnings??[])}const W=pe(j),E=[];W.length>0&&E.push(W.map(F=>F.message).join(" ")),O.length>0&&E.push(`Missing fields will use defaults: ${O.join(", ")}`),W.length>0?q.warning("Copilot configuration saved with model adjustments",{description:E.join(" ")}):E.length>0?q.success("Copilot configuration saved",{description:E.join(" ")}):q.success("Copilot configuration saved"),a({}),y(null)}catch(j){Le(j)?P(!0):q.error("Failed to save settings")}};return{configLoading:s,rawSettingsLoading:d,modelsLoading:c,isUpdating:n,isSavingRawSettings:p,models:l,rawSettings:i,rawJsonContent:k,rawJsonEdits:u,enabled:D,autoStart:I,port:L,accountType:K,currentModel:R,rateLimit:A,waitOnLimit:f,opusModel:U,sonnetModel:Q,haikuModel:$,isRawJsonValid:oe,hasChanges:be,normalizationWarnings:Se,conflictDialog:C,updateField:J,applyPreset:V,handleRawJsonChange:m,handleSave:re,handleConflictResolve:async h=>{P(!1),h?await re({overwriteRawSettings:!0}):y(null)},refetchRawSettings:g,missingRequiredFields:ye}}function jt(){const{configLoading:t,rawSettingsLoading:s,modelsLoading:l,isUpdating:c,isSavingRawSettings:i,models:d,rawSettings:r,rawJsonContent:n,rawJsonEdits:x,enabled:p,autoStart:g,port:o,accountType:a,currentModel:u,rateLimit:y,waitOnLimit:C,opusModel:P,sonnetModel:D,haikuModel:I,isRawJsonValid:L,hasChanges:K,normalizationWarnings:R,conflictDialog:A,updateField:f,applyPreset:U,handleRawJsonChange:Q,handleSave:$,handleConflictResolve:J,refetchRawSettings:V,missingRequiredFields:k}=ft();return t||s?e.jsxs("div",{className:"space-y-6",children:[e.jsx(b,{className:"h-10 w-full"}),e.jsx(b,{className:"h-10 w-full"}),e.jsx(b,{className:"h-10 w-full"}),e.jsx(b,{className:"h-10 w-full"})]}):e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(rt,{rawSettings:r,rawSettingsLoading:s,isUpdating:c,isSavingRawSettings:i,hasChanges:K,isRawJsonValid:L,onRefresh:()=>V(),onSave:$}),R.length>0&&e.jsx("div",{className:"px-6 pt-4 shrink-0",children:e.jsxs(Re,{variant:"warning",children:[e.jsx(je,{className:"h-4 w-4"}),e.jsx(Ae,{children:"Deprecated Copilot models detected"}),e.jsxs(Oe,{className:"space-y-2",children:[e.jsx("p",{children:"Loading this page did not rewrite your files. Save the Copilot configuration to persist these replacements."}),e.jsx("div",{className:"space-y-1",children:R.map(m=>e.jsx("p",{children:m.message},m.message))})]})]})}),e.jsxs("div",{className:"flex-1 flex divide-x overflow-hidden",children:[e.jsx("div",{className:"w-[540px] shrink-0 flex flex-col overflow-hidden bg-muted/5",children:e.jsx("div",{className:"h-full flex flex-col",children:e.jsxs(Ee,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(_e,{className:"w-full",children:[e.jsx(Y,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(Y,{value:"settings",className:"flex-1",children:"Settings"}),e.jsx(Y,{value:"info",className:"flex-1",children:"Info"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(xt,{currentModel:u,opusModel:P,sonnetModel:D,haikuModel:I,models:d,modelsLoading:l,onApplyPreset:U,onUpdateModel:m=>f("model",m),onUpdateOpusModel:m=>f("opusModel",m),onUpdateSonnetModel:m=>f("sonnetModel",m),onUpdateHaikuModel:m=>f("haikuModel",m)}),e.jsx(pt,{enabled:p,autoStart:g,port:o,accountType:a,rateLimit:y,waitOnLimit:C,onUpdateEnabled:m=>f("enabled",m),onUpdateAutoStart:m=>f("autoStart",m),onUpdatePort:m=>f("port",m),onUpdateAccountType:m=>f("accountType",m),onUpdateRateLimit:m=>f("rateLimit",m),onUpdateWaitOnLimit:m=>f("waitOnLimit",m)}),e.jsx(ht,{rawSettings:r})]})]})})}),e.jsxs("div",{className:"flex-1 min-w-0 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($e,{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(qe,{rawJsonContent:n,isRawJsonValid:L,rawJsonEdits:x,rawSettingsEnv:r?.settings?.env,onChange:Q,missingRequiredFields:k})]})]}),e.jsx(Ie,{open:A,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>J(!0),onCancel:()=>J(!1)})]})}function te({title:t,children:s}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3",children:t}),e.jsx("div",{className:"space-y-1",children:s})]})}function H({icon:t,label:s,status:l,statusText:c,variant:i="default"}){return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg bg-muted/50",children:[e.jsx(t,{className:"w-4 h-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("span",{className:"text-sm",children:s})}),e.jsx("div",{className:"flex items-center gap-1.5",children:l?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:se("w-4 h-4",i==="warning"?"text-yellow-500":"text-green-500")}),e.jsx("span",{className:se("text-xs",i==="warning"?"text-yellow-500":"text-green-500"),children:c||"Yes"})]}):e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:c||"No"})]})})]})}function vt(){return e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsx(b,{className:"h-8 w-full"}),e.jsx(b,{className:"h-12 w-full"}),e.jsx(b,{className:"h-12 w-full"}),e.jsx(b,{className:"h-12 w-full"})]})}function Et(){const{t}=ie(),{status:s,statusLoading:l,refetchStatus:c,startAuth:i,isAuthenticating:d,startDaemon:r,isStartingDaemon:n,stopDaemon:x,isStoppingDaemon:p,install:g,isInstalling:o}=Ne();return e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30 shrink-0",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(Je,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:t("copilotPage.title")})]}),e.jsx(N,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>c(),disabled:l,children:e.jsx(ge,{className:se("w-4 h-4",l&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("copilotPage.subtitle")})]}),e.jsx(G,{className:"flex-1",children:l?e.jsx(vt,{}):e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-500/15 p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(je,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-400 shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-yellow-800 dark:text-yellow-200",children:t("copilotPage.unofficialTitle")})]}),e.jsxs("ul",{className:"text-[11px] text-yellow-700 dark:text-yellow-300 space-y-0.5 pl-6 list-disc",children:[e.jsx("li",{children:t("copilotPage.unofficialItem1")}),e.jsx("li",{children:t("copilotPage.unofficialItem2")}),e.jsx("li",{children:t("copilotPage.unofficialItem3")})]})]}),e.jsxs(te,{title:t("copilotPage.setup"),children:[e.jsx(H,{icon:ze,label:"copilot-api",status:s?.installed??!1,statusText:s?.installed?s.version?`v${s.version}`:t("copilotPage.installed"):t("copilotPage.missing")}),!s?.installed&&e.jsx(N,{size:"sm",className:"w-full mt-2",onClick:()=>g(void 0),disabled:o,children:o?e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}),t("copilotPage.installing")]}):e.jsxs(e.Fragment,{children:[e.jsx(Be,{className:"w-3.5 h-3.5 mr-1.5"}),t("copilotPage.installCopilotApi")]})}),s?.installed&&e.jsx(H,{icon:me,label:t("copilotPage.integration"),status:s?.enabled??!1,statusText:s?.enabled?t("copilotPage.enabled"):t("copilotPage.disabled")})]}),s?.installed&&e.jsxs(te,{title:t("copilotPage.auth"),children:[e.jsx(H,{icon:He,label:t("copilotPage.github"),status:s?.authenticated??!1,statusText:s?.authenticated?t("copilotPage.connected"):t("copilotPage.notConnected")}),!s?.authenticated&&e.jsx(N,{size:"sm",className:"w-full mt-2",onClick:()=>i(),disabled:d,children:t(d?"copilotPage.authenticating":"copilotPage.authenticate")})]}),s?.authenticated&&e.jsxs(te,{title:t("copilotPage.daemon"),children:[e.jsx(H,{icon:Ge,label:t("copilotPage.status"),status:s?.daemon_running??!1,statusText:s?.daemon_running?t("copilotPage.running"):t("copilotPage.stopped")}),e.jsxs("div",{className:"px-3 py-1 text-xs text-muted-foreground",children:[t("copilotPage.port"),": ",s?.port??4141]}),e.jsx("div",{className:"px-1",children:s?.daemon_running?e.jsxs(N,{size:"sm",variant:"outline",className:"w-full",onClick:()=>x(),disabled:p,children:[e.jsx(Ve,{className:"w-3.5 h-3.5 mr-1.5"}),t(p?"copilotPage.stopping":"copilotPage.stop")]}):e.jsxs(N,{size:"sm",variant:"outline",className:"w-full",onClick:()=>r(),disabled:n,children:[e.jsx(me,{className:"w-3.5 h-3.5 mr-1.5"}),t(n?"copilotPage.starting":"copilotPage.start")]})})]})]})}),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:t("copilotPage.proxy")}),s?.daemon_running?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ve,{className:"w-3 h-3 text-green-500"}),t("copilotPage.active")]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(we,{className:"w-3 h-3 text-muted-foreground"}),t("copilotPage.inactive")]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:e.jsx(jt,{})})]})}export{Et as CopilotPage};
|