@kaitranntt/ccs 7.44.0-dev.1 → 7.44.0-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/dist/ui/assets/{accounts-Cr5UiSqw.js → accounts-B8J62kJ6.js} +1 -1
  2. package/dist/ui/assets/{alert-dialog-RKd6P34V.js → alert-dialog-B5t_5_UL.js} +1 -1
  3. package/dist/ui/assets/{api-BjsYBaDO.js → api-DuZyDFf7.js} +1 -1
  4. package/dist/ui/assets/{auth-section-DJjkM3Pc.js → auth-section-Dnaxf97q.js} +1 -1
  5. package/dist/ui/assets/{backups-section-C3OoH74L.js → backups-section-DUIq9Rxi.js} +1 -1
  6. package/dist/ui/assets/{cliproxy-bUQ9JQSI.js → cliproxy-aK19VC4f.js} +1 -1
  7. package/dist/ui/assets/{cliproxy-control-panel-bWG4j7j-.js → cliproxy-control-panel-9OS_kdTh.js} +1 -1
  8. package/dist/ui/assets/{confirm-dialog-39RkxEsp.js → confirm-dialog-D7hNt3ez.js} +1 -1
  9. package/dist/ui/assets/{copilot-CT5QKd7M.js → copilot-B5dVoOMQ.js} +1 -1
  10. package/dist/ui/assets/cursor-4zDGbBRA.js +1 -0
  11. package/dist/ui/assets/{globalenv-section-JUD29aAr.js → globalenv-section-DuUcheRN.js} +1 -1
  12. package/dist/ui/assets/{health-P6WZCBRj.js → health-Ddkl8zIJ.js} +1 -1
  13. package/dist/ui/assets/{index-BZe6NG3v.js → index-BRCdKMse.js} +1 -1
  14. package/dist/ui/assets/{index-Bikvb5yX.js → index-BRxqvMyp.js} +1 -1
  15. package/dist/ui/assets/index-C6u1zYVL.css +1 -0
  16. package/dist/ui/assets/{index-CIB-ESXC.js → index-D0I8OsQ3.js} +1 -1
  17. package/dist/ui/assets/{index-B-T25xBs.js → index-DOxNxHpI.js} +1 -1
  18. package/dist/ui/assets/{index-BteqkOAf.js → index-Dv5jtphl.js} +2 -2
  19. package/dist/ui/assets/{proxy-status-widget-BgJE3cHN.js → proxy-status-widget-DKYj4dWI.js} +1 -1
  20. package/dist/ui/assets/{separator-yty7hz16.js → separator-DrDw3JjB.js} +1 -1
  21. package/dist/ui/assets/{shared-BxLyXLjd.js → shared-psG1uSqB.js} +1 -1
  22. package/dist/ui/assets/{switch-Dq8eo1UY.js → switch-C0ri2ChT.js} +1 -1
  23. package/dist/ui/index.html +2 -2
  24. package/package.json +1 -1
  25. package/dist/ui/assets/cursor-CgHXk53L.js +0 -1
  26. package/dist/ui/assets/index-ByiEOnlQ.css +0 -1
@@ -1,3 +1,3 @@
1
- import{j as e,$ as Es,a0 as Ds}from"./radix-ui-qEZD5MMp.js";import{r as d}from"./react-vendor-CNOkPC89.js";import{a as we,u as as,b as _s}from"./tanstack-De4wvi8X.js";import{b as O,C as ns,a as is,c as H,P as me,L as Y,I as ie,X as be,Y as Ce,Z as ye,_ as ke,$ as re,a0 as rs,a1 as Rs,a2 as Ls,a3 as Is,u as os,a4 as Se,a5 as Ae,a6 as Pe,a7 as Me,a8 as ls,a9 as $e,aa as Fs,ab as Us,ac as qs,ad as cs,ae as ue,af as Ge,ag as Hs,ah as Ks,ai as $s,aj as Gs,B as K,ak as Be,al as ze,am as Bs,q as ds,m as Te,l as zs,an as Qs,ao as Vs,ap as Js,aq as Ws,ar as Xs,as as ee,T as se,o as te,p as ae,at as Ys,au as Zs,av as et,aw as Qe,ax as Ve,ay as st,az as tt,aA as at,aB as nt,aC as it,aD as rt,H as ot,J as lt,K as Je,M as We,aE as ct,aF as dt,aG as ut,aH as mt,aI as xt,aJ as pt,aK as ht,aL as ft,aM as gt,aN as jt,aO as vt,S as Nt}from"./index-BteqkOAf.js";import{t as I}from"./notifications-B2HqRBj7.js";import{b as us,L as B,m as xe,y as wt,j as z,l as ms,an as Oe,R as Ee,n as ne,a0 as le,ao as bt,ap as pe,Z as ce,I as xs,f as Ct,a2 as ps,aq as yt,ah as kt,X as De,$ as hs,s as fs,t as je,ar as St,T as At,p as Xe,as as Pt,ag as gs,q as Mt,at as Tt,k as Ot,a1 as Et,ak as Dt,au as js}from"./icons-DGASzt3M.js";import{C as _t}from"./confirm-dialog-39RkxEsp.js";import{S as _e}from"./separator-yty7hz16.js";import{S as vs}from"./switch-Dq8eo1UY.js";import{P as Rt}from"./proxy-status-widget-BgJE3cHN.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-RKd6P34V.js";const oe={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-5-thinking",haiku:"claude-sonnet-4-5"}},{id:"claude-opus-4-5-thinking",name:"Claude Opus 4.5 Thinking",description:"Previous flagship, extended thinking",presetMapping:{default:"claude-opus-4-5-thinking",opus:"claude-opus-4-5-thinking",sonnet:"claude-sonnet-4-5-thinking",haiku:"claude-sonnet-4-5"}},{id:"claude-sonnet-4-5-thinking",name:"Claude Sonnet 4.5 Thinking",description:"Balanced with extended thinking",presetMapping:{default:"claude-sonnet-4-5-thinking",opus:"claude-opus-4-6-thinking",sonnet:"claude-sonnet-4-5-thinking",haiku:"claude-sonnet-4-5"}},{id:"claude-sonnet-4-5",name:"Claude Sonnet 4.5",description:"Fast and capable",presetMapping:{default:"claude-sonnet-4-5",opus:"claude-opus-4-6-thinking",sonnet:"claude-sonnet-4-5",haiku:"claude-sonnet-4-5"}},{id:"gemini-3-pro-preview",name:"Gemini 3 Pro",description:"Google latest model via Antigravity",extendedContext:!0,presetMapping:{default:"gemini-3-pro-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini 3 Flash",description:"Fast Gemini model via Antigravity",extendedContext:!0,presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}}]},gemini:{provider:"gemini",displayName:"Gemini",defaultModel:"gemini-2.5-pro",models:[{id:"gemini-3-pro-preview",name:"Gemini 3 Pro",tier:"paid",description:"Latest model, requires paid Google account",extendedContext:!0,presetMapping:{default:"gemini-3-pro-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini 3 Flash",tier:"paid",description:"Fast Gemini 3 model, requires paid Google account",extendedContext:!0,presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",description:"Stable, works with free Google account",extendedContext:!0,presetMapping:{default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-2.5-flash"}}]},codex:{provider:"codex",displayName:"Codex",defaultModel:"gpt-5.3-codex",models:[{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",description:"Supports up to xhigh effort",presetMapping:{default:"gpt-5.3-codex-xhigh",opus:"gpt-5.3-codex-xhigh",sonnet:"gpt-5.3-codex-high",haiku:"gpt-5-mini-medium"}},{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",description:"Previous stable Codex model",presetMapping:{default:"gpt-5.2-codex-xhigh",opus:"gpt-5.2-codex-xhigh",sonnet:"gpt-5.2-codex-high",haiku:"gpt-5-mini-medium"}},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"Fast, capped at high effort (no xhigh)",presetMapping:{default:"gpt-5-mini-medium",opus:"gpt-5.3-codex-xhigh",sonnet:"gpt-5-mini-high",haiku:"gpt-5-mini-medium"}},{id:"gpt-5.1-codex-max",name:"Codex Max (5.1)",description:"Legacy most capable Codex model",presetMapping:{default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max-high",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini-high"}},{id:"gpt-5.2",name:"GPT 5.2",description:"Latest GPT model",presetMapping:{default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.2",haiku:"gpt-5.2"}},{id:"gpt-5.1-codex-mini",name:"Codex Mini",description:"Fast and efficient Codex model"}]},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:"iflow-default",models:[{id:"iflow-default",name:"iFlow Default",description:"Default iFlow 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-5-20250929",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-5-20250929",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"}]}},ve=8317,fe="ccs-internal-managed";async function Lt(){try{const s=await fetch("/api/settings/auth/tokens/raw");return s.ok?(await s.json())?.apiKey?.value??fe:fe}catch{return fe}}async function Ne(s,a){const t=oe[s];if(!t)return{success:!1};const n=t.models[0],i=n?.presetMapping||{default:t.defaultModel,opus:t.defaultModel,sonnet:t.defaultModel,haiku:t.defaultModel},u=await Lt(),m={env:{ANTHROPIC_BASE_URL:`http://127.0.0.1:${ve}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:u,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:m})})).ok,presetName:n?.name||t.defaultModel}}catch{return{success:!1}}}function It({currentProgress:s,allSteps:a}){return e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:a.map((t,n)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${s>=n?"bg-primary":"bg-muted"}`},t))})}function Ft({providers:s,onSelect:a}){return e.jsx("div",{className:"grid gap-2",children:s.map(t=>e.jsxs("button",{onClick:()=>a(t.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:t.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:t.description})]}),e.jsx(us,{className:"w-4 h-4 text-muted-foreground"})]},t.id))})}function Ut({selectedProvider:s,providers:a,authCommand:t,isRefreshing:n,isPending:i,onBack:u,onStartAuth:c,onRefresh:m}){const[f,h]=d.useState(!1),x=async v=>{await navigator.clipboard.writeText(v),h(!0),setTimeout(()=>h(!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 ",a.find(v=>v.id===s)?.name," to add an account"]}),e.jsx(O,{onClick:c,disabled:i,className:"w-full gap-2",size:"lg",children:i?e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"w-4 h-4 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(xe,{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(ns,{children:e.jsxs(is,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(wt,{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:t}),e.jsx(O,{variant:"outline",size:"icon",onClick:()=>x(t),children:f?e.jsx(z,{className:"w-4 h-4 text-green-500"}):e.jsx(ms,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(O,{variant:"ghost",onClick:u,disabled:i,children:[e.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs(O,{variant:"outline",onClick:m,disabled:n||i,children:[e.jsx(Ee,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),n?"Checking...":"Refresh Status"]})]})]})}function qt({accounts:s,privacyMode:a,onSelect:t,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(u=>e.jsxs("button",{type:"button",onClick:()=>t(u),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(ne,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:H("font-medium",a&&me),children:u.email||u.id}),u.isDefault&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Default account"})]})]}),e.jsx(us,{className:"w-4 h-4 text-muted-foreground"})]},u.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(xe,{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(O,{variant:"ghost",onClick:i,children:[e.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Back"]})})]})}const Ye="__custom__";function Ht({selectedProvider:s,selectedAccount:a,variantName:t,modelName:n,isPending:i,privacyMode:u,onVariantNameChange:c,onModelChange:m,onBack:f,onSkip:h,onCreate:x}){const v=oe[s]?.models||[],r=n&&!v.some(o=>o.id===n),[g,N]=d.useState(r),C=o=>{o===Ye?(N(!0),m("")):(N(!1),m(o))};return e.jsxs("div",{className:"space-y-4",children:[a&&e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx(ne,{className:"w-4 h-4"}),e.jsxs("span",{children:["Using:"," ",e.jsx("span",{className:H(u&&me),children:a.email||a.id})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"variant-name",children:"Variant Name *"}),e.jsx(ie,{id:"variant-name",value:t,onChange:o=>c(o.target.value),placeholder:"e.g., my-gemini, g3, flash"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Use this name to invoke: ccs ",t||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{children:"Model"}),g?e.jsxs("div",{className:"space-y-2",children:[e.jsx(ie,{value:n,onChange:o=>m(o.target.value),placeholder:"e.g., gemini-2.5-pro, claude-opus-4-5"}),e.jsx("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:()=>N(!1),children:"Choose from presets instead"})]}):e.jsxs(be,{value:v.some(o=>o.id===n)?n:"",onValueChange:C,children:[e.jsx(Ce,{children:e.jsx(ye,{placeholder:"Select a model"})}),e.jsxs(ke,{children:[v.map(o=>e.jsx(re,{value:o.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:o.name}),o.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",o.description]})]})},o.id)),e.jsx(re,{value:Ye,children:e.jsx("span",{className:"text-primary",children:"Custom model name..."})})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:g?"Enter any model name supported by CLIProxy":`Default: ${oe[s]?.defaultModel||"provider default"}`})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(O,{variant:"ghost",onClick:f,children:[e.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{variant:"ghost",onClick:h,children:"Skip"}),e.jsx(O,{onClick:x,disabled:!t||i,children:i?"Creating...":"Create Variant"})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:"Skip if you just wanted to add an account without creating a variant"})]})}function Kt({variantName:s,onClose:a}){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(z,{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(ns,{children:e.jsxs(is,{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(O,{onClick:a,className:"w-full",children:"Done"})]})}function $t({open:s,onClose:a}){const[t,n]=d.useState("provider"),[i,u]=d.useState(""),[c,m]=d.useState(null),[f,h]=d.useState(""),[x,v]=d.useState(""),[r,g]=d.useState(!1),[N,C]=d.useState(!1),{data:o,refetch:p}=rs(),T=Rs(),k=Ls(),j=Is(),{privacyMode:E}=os(),S=o?.authStatus.find(P=>P.provider===i),D=d.useMemo(()=>S?.accounts||[],[S?.accounts]);d.useEffect(()=>{if(!s){const P=setTimeout(()=>{n("provider"),u(""),m(null),h(""),v(""),C(!1)},0);return()=>clearTimeout(P)}},[s]),d.useEffect(()=>{if(t==="auth"&&D.length>0&&!N){const P=setTimeout(()=>{n("account")},0);return()=>clearTimeout(P)}},[t,D,N]);const L=async()=>{g(!0),await p(),g(!1)},F=()=>{const P=(S?.accounts?.length||0)===0;k.mutate({provider:i},{onSuccess:async M=>{if(P){const b=await Ne(i);b.success&&b.presetName?I.success(`Applied "${b.presetName}" preset`):b.success||I.warning("Account added, but failed to apply default preset")}M.account&&(m(M.account),n("variant")),p()}})},y=P=>{u(P),(o?.authStatus.find(q=>q.provider===P)?.accounts||[]).length===0?n("auth"):n("account")},A=P=>{m(P),n("variant")},w=async()=>{if(!(!f||!i))try{await T.mutateAsync({name:f,provider:i,model:x||void 0,account:c?.id}),n("success")}catch(P){console.error("Failed to create variant:",P)}},_=`ccs ${i} --auth --add`,U=Us(t),$=P=>{if(!P&&(k.isPending&&i&&j.mutate(i),t==="success"||t==="provider")){a();return}};return e.jsx(Se,{open:s,onOpenChange:$,children:e.jsxs(Ae,{className:"sm:max-w-lg",onPointerDownOutside:P=>{t!=="success"&&t!=="provider"&&P.preventDefault()},onEscapeKeyDown:P=>{(k.isPending||T.isPending)&&P.preventDefault()},children:[e.jsxs(Pe,{children:[e.jsxs(Me,{className:"flex items-center gap-2",children:[e.jsx(le,{className:"w-5 h-5 text-primary"}),"Quick Setup Wizard"]}),e.jsxs(ls,{children:[t==="provider"&&"Select a provider to get started",t==="auth"&&"Authenticate with your provider",t==="account"&&"Select which account to use",t==="variant"&&"Create your custom variant",t==="success"&&"Setup complete!"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[t==="provider"&&e.jsx(Ft,{providers:$e,onSelect:y}),t==="auth"&&e.jsx(Ut,{selectedProvider:i,providers:$e,authCommand:_,isRefreshing:r,isPending:k.isPending,onBack:()=>n("provider"),onStartAuth:F,onRefresh:L}),t==="account"&&e.jsx(qt,{accounts:D,privacyMode:E,onSelect:A,onAddNew:()=>{C(!0),n("auth")},onBack:()=>n("provider")}),t==="variant"&&e.jsx(Ht,{selectedProvider:i,selectedAccount:c,variantName:f,modelName:x,isPending:T.isPending,privacyMode:E,onVariantNameChange:h,onModelChange:v,onBack:()=>D.length>0?n("account"):n("provider"),onSkip:a,onCreate:w}),t==="success"&&e.jsx(Kt,{variantName:f,onClose:a})]}),e.jsx(It,{currentProgress:U,allSteps:Fs})]})})}const Gt=3e3,Bt=300*1e3,X={provider:null,isAuthenticating:!1,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:!1};function zt(){const[s,a]=d.useState(X),t=d.useRef(null),n=d.useRef(null),i=d.useRef(0),u=d.useRef(!1),c=we(),m=d.useCallback(()=>{n.current&&(clearInterval(n.current),n.current=null)},[]);d.useEffect(()=>()=>{t.current?.abort(),m(),u.current=!1},[m]);const f=d.useCallback(async(r,g)=>{if(Date.now()-i.current>Bt){m(),a(N=>({...N,isAuthenticating:!1,error:"Authentication timed out. Please try again."}));return}try{const C=await(await fetch(`/api/cliproxy/auth/${r}/status?state=${encodeURIComponent(g)}`)).json();if(C.status==="ok")m(),c.invalidateQueries({queryKey:["cliproxy-auth"]}),c.invalidateQueries({queryKey:["account-quota"]}),I.success(`${r} authentication successful`),u.current=!1,a(X);else if(C.status==="auth_url"){const o=C.url||C.auth_url;o&&(a(p=>({...p,authUrl:o})),u.current||(u.current=!0,window.open(o,"_blank")))}else if(C.status==="device_code"){m();const o=C.user_code&&C.verification_url?`Open ${C.verification_url} and enter code: ${C.user_code}`:"Switch to Device Code method and try again.";I.error("Provider returned Device Code flow in callback mode"),a(p=>({...p,isAuthenticating:!1,error:o}))}else if(C.status==="error"){m();const o=C.error||"Authentication failed";I.error(o),a(p=>({...p,isAuthenticating:!1,error:o}))}}catch{}},[c,m]),h=d.useCallback(async(r,g)=>{if(!qs(r)){a({...X,error:`Unknown provider: ${r}`});return}t.current?.abort(),m(),u.current=!1;const N=new AbortController;t.current=N;const o=(g?.flowType||(cs(r)?"device_code":"authorization_code"))==="device_code",p=g?.startEndpoint||(o?"start":"start-url"),T={nickname:g?.nickname,kiroMethod:g?.kiroMethod};a({provider:r,isAuthenticating:!0,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:o});try{if(p==="start")fetch(`/api/cliproxy/auth/${r}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(T),signal:N.signal}).then(async k=>{const j=await k.json();if(k.ok&&j.success)c.invalidateQueries({queryKey:["cliproxy-auth"]}),c.invalidateQueries({queryKey:["account-quota"]}),u.current=!1,a(X);else{const E=j.error||"Authentication failed";I.error(E),a(S=>({...S,isAuthenticating:!1,error:E}))}}).catch(k=>{if(k instanceof Error&&k.name==="AbortError")return;const j=k instanceof Error?k.message:"Authentication failed";I.error(j),a(E=>({...E,isAuthenticating:!1,error:j}))});else{const k=await fetch(`/api/cliproxy/auth/${r}/start-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(T),signal:N.signal}),j=await k.json();if(!k.ok||!j.success)throw new Error(j.error||"Failed to start OAuth");a(E=>({...E,authUrl:j.authUrl||null,oauthState:j.state})),j.authUrl&&(u.current=!0,window.open(j.authUrl,"_blank")),j.state&&(i.current=Date.now(),n.current=setInterval(()=>{f(r,j.state)},Gt))}}catch(k){if(k instanceof Error&&k.name==="AbortError"){u.current=!1,a(X);return}const j=k instanceof Error?k.message:"Authentication failed";I.error(j),a(E=>({...E,isAuthenticating:!1,error:j}))}},[f,m,c]),x=d.useCallback(()=>{const r=s.provider;t.current?.abort(),m(),u.current=!1,a(X),r&&ue.cliproxy.auth.cancel(r).catch(()=>{})},[s.provider,m]),v=d.useCallback(async r=>{if(s.provider){a(g=>({...g,isSubmittingCallback:!0,error:null}));try{const g=await fetch(`/api/cliproxy/auth/${s.provider}/submit-callback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({redirectUrl:r})}),N=await g.json();if(g.ok&&N.success)m(),c.invalidateQueries({queryKey:["cliproxy-auth"]}),c.invalidateQueries({queryKey:["account-quota"]}),I.success(`${s.provider} authentication successful`),a(X);else throw new Error(N.error||"Callback submission failed")}catch(g){const N=g instanceof Error?g.message:"Failed to submit callback";I.error(N),a(C=>({...C,isSubmittingCallback:!1,error:N}))}}},[s.provider,c,m]);return d.useMemo(()=>({...s,startAuth:h,cancelAuth:x,submitCallback:v}),[s,h,x,v])}function Qt({open:s,onClose:a,provider:t,displayName:n,isFirstAccount:i=!1}){const[u,c]=d.useState(""),[m,f]=d.useState(""),[h,x]=d.useState(!1),[v,r]=d.useState(null),[g,N]=d.useState(Ge),C=d.useRef(!1),o=zt(),p=Hs(),T=t==="kiro",k=cs(t),j=Gs(t),E=Ks(g),S=T?E.flowType==="device_code":k,D=o.isAuthenticating||p.isPending,L=u.trim(),F=v||o.error,y=()=>{c(""),f(""),x(!1),r(null),N(Ge),C.current=!1,a()};d.useEffect(()=>{!o.isAuthenticating&&!o.error&&o.provider===null&&s&&C.current&&(C.current=!1,(async()=>{try{const q=await Ne(t);q.success&&q.presetName&&i&&I.success(`Applied "${q.presetName}" preset`)}catch{}y()})())},[o.isAuthenticating,o.error,o.provider]);const A=()=>{o.cancelAuth(),y()},w=async()=>{o.authUrl&&(await navigator.clipboard.writeText(o.authUrl),x(!0),setTimeout(()=>x(!1),2e3))},_=()=>{m.trim()&&o.submitCallback(m.trim())},U=()=>{if(j&&!L){r(`Nickname is required for ${n} accounts.`);return}r(null),C.current=!0,o.startAuth(t,{nickname:L||void 0,kiroMethod:T?g:void 0,flowType:T?E.flowType:void 0,startEndpoint:T?E.startEndpoint:void 0})},$=()=>{C.current=!0,p.mutate(void 0,{onSuccess:async()=>{const b=await Ne("kiro");b.success&&b.presetName&&i&&I.success(`Applied "${b.presetName}" preset`),y()}})},P=b=>{b||A()},M=o.isAuthenticating;return e.jsx(Se,{open:s,onOpenChange:P,children:e.jsxs(Ae,{className:"sm:max-w-md",onInteractOutside:b=>{M&&b.preventDefault()},children:[e.jsxs(Pe,{children:[e.jsxs(Me,{children:["Add ",n," Account"]}),e.jsx(ls,{children:T?"Choose a Kiro auth method, then authenticate via browser or import from Kiro IDE.":S?"Click Authenticate. A verification code will appear for you to enter on the provider website.":"Click Authenticate to get an OAuth URL. Open it in any browser to sign in."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[T&&!M&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"kiro-auth-method",children:"Auth Method"}),e.jsxs(be,{value:g,onValueChange:b=>{N(b),r(null)},children:[e.jsx(Ce,{id:"kiro-auth-method",children:e.jsx(ye,{placeholder:"Select Kiro auth method"})}),e.jsx(ke,{children:$s.map(b=>e.jsx(re,{value:b.id,children:b.label},b.id))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:E.description})]}),!M&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"nickname",children:j?"Nickname (required)":"Nickname (optional)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(ie,{id:"nickname",value:u,onChange:b=>{c(b.target.value),r(null)},placeholder:"e.g., work, personal",disabled:D,className:"flex-1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:j?"Required for this provider. Use a unique friendly name (e.g., work, personal).":"A friendly name to identify this account. Auto-generated from email if left empty."})]}),M&&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(B,{className:"w-4 h-4 inline mr-2 animate-spin"}),"Waiting for authentication..."]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:o.isDeviceCodeFlow?"A verification code dialog will appear shortly. Enter the code on the provider website.":"Complete the authentication in your browser. This dialog closes automatically."})]}),o.authUrl&&!o.isDeviceCodeFlow&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{className:"text-xs",children:"Open this URL in any browser to sign in:"}),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:o.authUrl}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(O,{variant:"outline",size:"sm",onClick:w,children:h?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"w-3 h-3 mr-1"}),"Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(ms,{className:"w-3 h-3 mr-1"}),"Copy"]})}),e.jsxs(O,{variant:"outline",size:"sm",onClick:()=>{if(!o.authUrl)return;const b=window.open(o.authUrl,"_blank");(!b||b.closed||typeof b.closed>"u")&&I.warning("Popup blocked. Copy the URL above and open it manually in your browser.",{duration:5e3})},children:[e.jsx(xe,{className:"w-3 h-3 mr-1"}),"Open"]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"callback-url",className:"text-xs",children:"Redirect didn't work? Paste the callback URL:"}),e.jsx(ie,{id:"callback-url",value:m,onChange:b=>f(b.target.value),placeholder:"Paste the redirect URL here...",className:"font-mono text-xs"}),e.jsx(O,{variant:"secondary",size:"sm",onClick:_,disabled:!m.trim()||o.isSubmittingCallback,children:o.isSubmittingCallback?e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"w-3 h-3 mr-1 animate-spin"}),"Submitting..."]}):"Submit Callback"})]})]}),!o.authUrl&&!o.isDeviceCodeFlow&&e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:"Preparing sign-in URL..."})]}),F&&e.jsx("p",{className:"text-xs text-center text-destructive",children:F}),p.isPending&&e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:[e.jsx(B,{className:"w-4 h-4 inline mr-2 animate-spin"}),"Importing token from Kiro IDE..."]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(O,{variant:"ghost",onClick:A,children:"Cancel"}),T&&!M&&e.jsx(O,{variant:"outline",onClick:$,disabled:D,children:p.isPending?e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"w-4 h-4 mr-2 animate-spin"}),"Importing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(bt,{className:"w-4 h-4 mr-2"}),"Import from IDE"]})}),!M&&e.jsxs(O,{onClick:U,disabled:D||j&&!L,children:[e.jsx(xe,{className:"w-4 h-4 mr-2"}),"Authenticate"]})]})]})]})})}const Re="[1m]";function Vt(s){return s.toLowerCase().startsWith("gemini-")}function Le(s){return s.toLowerCase().endsWith(Re.toLowerCase())}function Jt(s){return!s||Le(s)?s:`${s}${Re}`}function Ns(s){return s&&(Le(s)?s.slice(0,-Re.length):s)}const Ze=["ANTHROPIC_MODEL"],Wt=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function Xt(s){const a=s?.env||{};return Wt.filter(t=>!a[t]?.trim())}function Yt(s){const[a,t]=d.useState(null),[n,i]=d.useState(!1),u=we(),{data:c,isLoading:m,refetch:f}=as({queryKey:["settings",s],queryFn:async()=>{const y=await fetch(`/api/settings/${s}/raw`);return y.ok?y.json():{profile:s,settings:{env:{}},mtime:Date.now(),path:`~/.ccs/profiles/${s}/settings.json`}}}),h=c?.settings,x=d.useMemo(()=>a!==null?a:h?JSON.stringify(h,null,2):`{
1
+ import{j as e,$ as Es,a0 as Ds}from"./radix-ui-qEZD5MMp.js";import{r as d}from"./react-vendor-CNOkPC89.js";import{a as we,u as as,b as _s}from"./tanstack-De4wvi8X.js";import{b as O,C as ns,a as is,c as H,P as me,L as Y,I as ie,X as be,Y as Ce,Z as ye,_ as ke,$ as re,a0 as rs,a1 as Rs,a2 as Ls,a3 as Is,u as os,a4 as Se,a5 as Ae,a6 as Pe,a7 as Me,a8 as ls,a9 as $e,aa as Fs,ab as Us,ac as qs,ad as cs,ae as ue,af as Ge,ag as Hs,ah as Ks,ai as $s,aj as Gs,B as K,ak as Be,al as ze,am as Bs,q as ds,m as Te,l as zs,an as Qs,ao as Vs,ap as Js,aq as Ws,ar as Xs,as as ee,T as se,o as te,p as ae,at as Ys,au as Zs,av as et,aw as Qe,ax as Ve,ay as st,az as tt,aA as at,aB as nt,aC as it,aD as rt,H as ot,J as lt,K as Je,M as We,aE as ct,aF as dt,aG as ut,aH as mt,aI as xt,aJ as pt,aK as ht,aL as ft,aM as gt,aN as jt,aO as vt,S as Nt}from"./index-Dv5jtphl.js";import{t as I}from"./notifications-B2HqRBj7.js";import{b as us,L as B,m as xe,y as wt,j as z,l as ms,an as Oe,R as Ee,n as ne,a0 as le,ao as bt,ap as pe,Z as ce,I as xs,f as Ct,a2 as ps,aq as yt,ah as kt,X as De,$ as hs,s as fs,t as je,ar as St,T as At,p as Xe,as as Pt,ag as gs,q as Mt,at as Tt,k as Ot,a1 as Et,ak as Dt,au as js}from"./icons-DGASzt3M.js";import{C as _t}from"./confirm-dialog-D7hNt3ez.js";import{S as _e}from"./separator-DrDw3JjB.js";import{S as vs}from"./switch-C0ri2ChT.js";import{P as Rt}from"./proxy-status-widget-DKYj4dWI.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-B5t_5_UL.js";const oe={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-5-thinking",haiku:"claude-sonnet-4-5"}},{id:"claude-opus-4-5-thinking",name:"Claude Opus 4.5 Thinking",description:"Previous flagship, extended thinking",presetMapping:{default:"claude-opus-4-5-thinking",opus:"claude-opus-4-5-thinking",sonnet:"claude-sonnet-4-5-thinking",haiku:"claude-sonnet-4-5"}},{id:"claude-sonnet-4-5-thinking",name:"Claude Sonnet 4.5 Thinking",description:"Balanced with extended thinking",presetMapping:{default:"claude-sonnet-4-5-thinking",opus:"claude-opus-4-6-thinking",sonnet:"claude-sonnet-4-5-thinking",haiku:"claude-sonnet-4-5"}},{id:"claude-sonnet-4-5",name:"Claude Sonnet 4.5",description:"Fast and capable",presetMapping:{default:"claude-sonnet-4-5",opus:"claude-opus-4-6-thinking",sonnet:"claude-sonnet-4-5",haiku:"claude-sonnet-4-5"}},{id:"gemini-3-pro-preview",name:"Gemini 3 Pro",description:"Google latest model via Antigravity",extendedContext:!0,presetMapping:{default:"gemini-3-pro-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini 3 Flash",description:"Fast Gemini model via Antigravity",extendedContext:!0,presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}}]},gemini:{provider:"gemini",displayName:"Gemini",defaultModel:"gemini-2.5-pro",models:[{id:"gemini-3-pro-preview",name:"Gemini 3 Pro",tier:"paid",description:"Latest model, requires paid Google account",extendedContext:!0,presetMapping:{default:"gemini-3-pro-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini 3 Flash",tier:"paid",description:"Fast Gemini 3 model, requires paid Google account",extendedContext:!0,presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",description:"Stable, works with free Google account",extendedContext:!0,presetMapping:{default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-2.5-flash"}}]},codex:{provider:"codex",displayName:"Codex",defaultModel:"gpt-5.3-codex",models:[{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",description:"Supports up to xhigh effort",presetMapping:{default:"gpt-5.3-codex-xhigh",opus:"gpt-5.3-codex-xhigh",sonnet:"gpt-5.3-codex-high",haiku:"gpt-5-mini-medium"}},{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",description:"Previous stable Codex model",presetMapping:{default:"gpt-5.2-codex-xhigh",opus:"gpt-5.2-codex-xhigh",sonnet:"gpt-5.2-codex-high",haiku:"gpt-5-mini-medium"}},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"Fast, capped at high effort (no xhigh)",presetMapping:{default:"gpt-5-mini-medium",opus:"gpt-5.3-codex-xhigh",sonnet:"gpt-5-mini-high",haiku:"gpt-5-mini-medium"}},{id:"gpt-5.1-codex-max",name:"Codex Max (5.1)",description:"Legacy most capable Codex model",presetMapping:{default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max-high",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini-high"}},{id:"gpt-5.2",name:"GPT 5.2",description:"Latest GPT model",presetMapping:{default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.2",haiku:"gpt-5.2"}},{id:"gpt-5.1-codex-mini",name:"Codex Mini",description:"Fast and efficient Codex model"}]},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:"iflow-default",models:[{id:"iflow-default",name:"iFlow Default",description:"Default iFlow 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-5-20250929",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-5-20250929",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"}]}},ve=8317,fe="ccs-internal-managed";async function Lt(){try{const s=await fetch("/api/settings/auth/tokens/raw");return s.ok?(await s.json())?.apiKey?.value??fe:fe}catch{return fe}}async function Ne(s,a){const t=oe[s];if(!t)return{success:!1};const n=t.models[0],i=n?.presetMapping||{default:t.defaultModel,opus:t.defaultModel,sonnet:t.defaultModel,haiku:t.defaultModel},u=await Lt(),m={env:{ANTHROPIC_BASE_URL:`http://127.0.0.1:${ve}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:u,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:m})})).ok,presetName:n?.name||t.defaultModel}}catch{return{success:!1}}}function It({currentProgress:s,allSteps:a}){return e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:a.map((t,n)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${s>=n?"bg-primary":"bg-muted"}`},t))})}function Ft({providers:s,onSelect:a}){return e.jsx("div",{className:"grid gap-2",children:s.map(t=>e.jsxs("button",{onClick:()=>a(t.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:t.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:t.description})]}),e.jsx(us,{className:"w-4 h-4 text-muted-foreground"})]},t.id))})}function Ut({selectedProvider:s,providers:a,authCommand:t,isRefreshing:n,isPending:i,onBack:u,onStartAuth:c,onRefresh:m}){const[f,h]=d.useState(!1),x=async v=>{await navigator.clipboard.writeText(v),h(!0),setTimeout(()=>h(!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 ",a.find(v=>v.id===s)?.name," to add an account"]}),e.jsx(O,{onClick:c,disabled:i,className:"w-full gap-2",size:"lg",children:i?e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"w-4 h-4 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(xe,{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(ns,{children:e.jsxs(is,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(wt,{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:t}),e.jsx(O,{variant:"outline",size:"icon",onClick:()=>x(t),children:f?e.jsx(z,{className:"w-4 h-4 text-green-500"}):e.jsx(ms,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(O,{variant:"ghost",onClick:u,disabled:i,children:[e.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs(O,{variant:"outline",onClick:m,disabled:n||i,children:[e.jsx(Ee,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),n?"Checking...":"Refresh Status"]})]})]})}function qt({accounts:s,privacyMode:a,onSelect:t,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(u=>e.jsxs("button",{type:"button",onClick:()=>t(u),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(ne,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:H("font-medium",a&&me),children:u.email||u.id}),u.isDefault&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Default account"})]})]}),e.jsx(us,{className:"w-4 h-4 text-muted-foreground"})]},u.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(xe,{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(O,{variant:"ghost",onClick:i,children:[e.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Back"]})})]})}const Ye="__custom__";function Ht({selectedProvider:s,selectedAccount:a,variantName:t,modelName:n,isPending:i,privacyMode:u,onVariantNameChange:c,onModelChange:m,onBack:f,onSkip:h,onCreate:x}){const v=oe[s]?.models||[],r=n&&!v.some(o=>o.id===n),[g,N]=d.useState(r),C=o=>{o===Ye?(N(!0),m("")):(N(!1),m(o))};return e.jsxs("div",{className:"space-y-4",children:[a&&e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx(ne,{className:"w-4 h-4"}),e.jsxs("span",{children:["Using:"," ",e.jsx("span",{className:H(u&&me),children:a.email||a.id})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"variant-name",children:"Variant Name *"}),e.jsx(ie,{id:"variant-name",value:t,onChange:o=>c(o.target.value),placeholder:"e.g., my-gemini, g3, flash"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Use this name to invoke: ccs ",t||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{children:"Model"}),g?e.jsxs("div",{className:"space-y-2",children:[e.jsx(ie,{value:n,onChange:o=>m(o.target.value),placeholder:"e.g., gemini-2.5-pro, claude-opus-4-5"}),e.jsx("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:()=>N(!1),children:"Choose from presets instead"})]}):e.jsxs(be,{value:v.some(o=>o.id===n)?n:"",onValueChange:C,children:[e.jsx(Ce,{children:e.jsx(ye,{placeholder:"Select a model"})}),e.jsxs(ke,{children:[v.map(o=>e.jsx(re,{value:o.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:o.name}),o.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",o.description]})]})},o.id)),e.jsx(re,{value:Ye,children:e.jsx("span",{className:"text-primary",children:"Custom model name..."})})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:g?"Enter any model name supported by CLIProxy":`Default: ${oe[s]?.defaultModel||"provider default"}`})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(O,{variant:"ghost",onClick:f,children:[e.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{variant:"ghost",onClick:h,children:"Skip"}),e.jsx(O,{onClick:x,disabled:!t||i,children:i?"Creating...":"Create Variant"})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:"Skip if you just wanted to add an account without creating a variant"})]})}function Kt({variantName:s,onClose:a}){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(z,{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(ns,{children:e.jsxs(is,{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(O,{onClick:a,className:"w-full",children:"Done"})]})}function $t({open:s,onClose:a}){const[t,n]=d.useState("provider"),[i,u]=d.useState(""),[c,m]=d.useState(null),[f,h]=d.useState(""),[x,v]=d.useState(""),[r,g]=d.useState(!1),[N,C]=d.useState(!1),{data:o,refetch:p}=rs(),T=Rs(),k=Ls(),j=Is(),{privacyMode:E}=os(),S=o?.authStatus.find(P=>P.provider===i),D=d.useMemo(()=>S?.accounts||[],[S?.accounts]);d.useEffect(()=>{if(!s){const P=setTimeout(()=>{n("provider"),u(""),m(null),h(""),v(""),C(!1)},0);return()=>clearTimeout(P)}},[s]),d.useEffect(()=>{if(t==="auth"&&D.length>0&&!N){const P=setTimeout(()=>{n("account")},0);return()=>clearTimeout(P)}},[t,D,N]);const L=async()=>{g(!0),await p(),g(!1)},F=()=>{const P=(S?.accounts?.length||0)===0;k.mutate({provider:i},{onSuccess:async M=>{if(P){const b=await Ne(i);b.success&&b.presetName?I.success(`Applied "${b.presetName}" preset`):b.success||I.warning("Account added, but failed to apply default preset")}M.account&&(m(M.account),n("variant")),p()}})},y=P=>{u(P),(o?.authStatus.find(q=>q.provider===P)?.accounts||[]).length===0?n("auth"):n("account")},A=P=>{m(P),n("variant")},w=async()=>{if(!(!f||!i))try{await T.mutateAsync({name:f,provider:i,model:x||void 0,account:c?.id}),n("success")}catch(P){console.error("Failed to create variant:",P)}},_=`ccs ${i} --auth --add`,U=Us(t),$=P=>{if(!P&&(k.isPending&&i&&j.mutate(i),t==="success"||t==="provider")){a();return}};return e.jsx(Se,{open:s,onOpenChange:$,children:e.jsxs(Ae,{className:"sm:max-w-lg",onPointerDownOutside:P=>{t!=="success"&&t!=="provider"&&P.preventDefault()},onEscapeKeyDown:P=>{(k.isPending||T.isPending)&&P.preventDefault()},children:[e.jsxs(Pe,{children:[e.jsxs(Me,{className:"flex items-center gap-2",children:[e.jsx(le,{className:"w-5 h-5 text-primary"}),"Quick Setup Wizard"]}),e.jsxs(ls,{children:[t==="provider"&&"Select a provider to get started",t==="auth"&&"Authenticate with your provider",t==="account"&&"Select which account to use",t==="variant"&&"Create your custom variant",t==="success"&&"Setup complete!"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[t==="provider"&&e.jsx(Ft,{providers:$e,onSelect:y}),t==="auth"&&e.jsx(Ut,{selectedProvider:i,providers:$e,authCommand:_,isRefreshing:r,isPending:k.isPending,onBack:()=>n("provider"),onStartAuth:F,onRefresh:L}),t==="account"&&e.jsx(qt,{accounts:D,privacyMode:E,onSelect:A,onAddNew:()=>{C(!0),n("auth")},onBack:()=>n("provider")}),t==="variant"&&e.jsx(Ht,{selectedProvider:i,selectedAccount:c,variantName:f,modelName:x,isPending:T.isPending,privacyMode:E,onVariantNameChange:h,onModelChange:v,onBack:()=>D.length>0?n("account"):n("provider"),onSkip:a,onCreate:w}),t==="success"&&e.jsx(Kt,{variantName:f,onClose:a})]}),e.jsx(It,{currentProgress:U,allSteps:Fs})]})})}const Gt=3e3,Bt=300*1e3,X={provider:null,isAuthenticating:!1,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:!1};function zt(){const[s,a]=d.useState(X),t=d.useRef(null),n=d.useRef(null),i=d.useRef(0),u=d.useRef(!1),c=we(),m=d.useCallback(()=>{n.current&&(clearInterval(n.current),n.current=null)},[]);d.useEffect(()=>()=>{t.current?.abort(),m(),u.current=!1},[m]);const f=d.useCallback(async(r,g)=>{if(Date.now()-i.current>Bt){m(),a(N=>({...N,isAuthenticating:!1,error:"Authentication timed out. Please try again."}));return}try{const C=await(await fetch(`/api/cliproxy/auth/${r}/status?state=${encodeURIComponent(g)}`)).json();if(C.status==="ok")m(),c.invalidateQueries({queryKey:["cliproxy-auth"]}),c.invalidateQueries({queryKey:["account-quota"]}),I.success(`${r} authentication successful`),u.current=!1,a(X);else if(C.status==="auth_url"){const o=C.url||C.auth_url;o&&(a(p=>({...p,authUrl:o})),u.current||(u.current=!0,window.open(o,"_blank")))}else if(C.status==="device_code"){m();const o=C.user_code&&C.verification_url?`Open ${C.verification_url} and enter code: ${C.user_code}`:"Switch to Device Code method and try again.";I.error("Provider returned Device Code flow in callback mode"),a(p=>({...p,isAuthenticating:!1,error:o}))}else if(C.status==="error"){m();const o=C.error||"Authentication failed";I.error(o),a(p=>({...p,isAuthenticating:!1,error:o}))}}catch{}},[c,m]),h=d.useCallback(async(r,g)=>{if(!qs(r)){a({...X,error:`Unknown provider: ${r}`});return}t.current?.abort(),m(),u.current=!1;const N=new AbortController;t.current=N;const o=(g?.flowType||(cs(r)?"device_code":"authorization_code"))==="device_code",p=g?.startEndpoint||(o?"start":"start-url"),T={nickname:g?.nickname,kiroMethod:g?.kiroMethod};a({provider:r,isAuthenticating:!0,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:o});try{if(p==="start")fetch(`/api/cliproxy/auth/${r}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(T),signal:N.signal}).then(async k=>{const j=await k.json();if(k.ok&&j.success)c.invalidateQueries({queryKey:["cliproxy-auth"]}),c.invalidateQueries({queryKey:["account-quota"]}),u.current=!1,a(X);else{const E=j.error||"Authentication failed";I.error(E),a(S=>({...S,isAuthenticating:!1,error:E}))}}).catch(k=>{if(k instanceof Error&&k.name==="AbortError")return;const j=k instanceof Error?k.message:"Authentication failed";I.error(j),a(E=>({...E,isAuthenticating:!1,error:j}))});else{const k=await fetch(`/api/cliproxy/auth/${r}/start-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(T),signal:N.signal}),j=await k.json();if(!k.ok||!j.success)throw new Error(j.error||"Failed to start OAuth");a(E=>({...E,authUrl:j.authUrl||null,oauthState:j.state})),j.authUrl&&(u.current=!0,window.open(j.authUrl,"_blank")),j.state&&(i.current=Date.now(),n.current=setInterval(()=>{f(r,j.state)},Gt))}}catch(k){if(k instanceof Error&&k.name==="AbortError"){u.current=!1,a(X);return}const j=k instanceof Error?k.message:"Authentication failed";I.error(j),a(E=>({...E,isAuthenticating:!1,error:j}))}},[f,m,c]),x=d.useCallback(()=>{const r=s.provider;t.current?.abort(),m(),u.current=!1,a(X),r&&ue.cliproxy.auth.cancel(r).catch(()=>{})},[s.provider,m]),v=d.useCallback(async r=>{if(s.provider){a(g=>({...g,isSubmittingCallback:!0,error:null}));try{const g=await fetch(`/api/cliproxy/auth/${s.provider}/submit-callback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({redirectUrl:r})}),N=await g.json();if(g.ok&&N.success)m(),c.invalidateQueries({queryKey:["cliproxy-auth"]}),c.invalidateQueries({queryKey:["account-quota"]}),I.success(`${s.provider} authentication successful`),a(X);else throw new Error(N.error||"Callback submission failed")}catch(g){const N=g instanceof Error?g.message:"Failed to submit callback";I.error(N),a(C=>({...C,isSubmittingCallback:!1,error:N}))}}},[s.provider,c,m]);return d.useMemo(()=>({...s,startAuth:h,cancelAuth:x,submitCallback:v}),[s,h,x,v])}function Qt({open:s,onClose:a,provider:t,displayName:n,isFirstAccount:i=!1}){const[u,c]=d.useState(""),[m,f]=d.useState(""),[h,x]=d.useState(!1),[v,r]=d.useState(null),[g,N]=d.useState(Ge),C=d.useRef(!1),o=zt(),p=Hs(),T=t==="kiro",k=cs(t),j=Gs(t),E=Ks(g),S=T?E.flowType==="device_code":k,D=o.isAuthenticating||p.isPending,L=u.trim(),F=v||o.error,y=()=>{c(""),f(""),x(!1),r(null),N(Ge),C.current=!1,a()};d.useEffect(()=>{!o.isAuthenticating&&!o.error&&o.provider===null&&s&&C.current&&(C.current=!1,(async()=>{try{const q=await Ne(t);q.success&&q.presetName&&i&&I.success(`Applied "${q.presetName}" preset`)}catch{}y()})())},[o.isAuthenticating,o.error,o.provider]);const A=()=>{o.cancelAuth(),y()},w=async()=>{o.authUrl&&(await navigator.clipboard.writeText(o.authUrl),x(!0),setTimeout(()=>x(!1),2e3))},_=()=>{m.trim()&&o.submitCallback(m.trim())},U=()=>{if(j&&!L){r(`Nickname is required for ${n} accounts.`);return}r(null),C.current=!0,o.startAuth(t,{nickname:L||void 0,kiroMethod:T?g:void 0,flowType:T?E.flowType:void 0,startEndpoint:T?E.startEndpoint:void 0})},$=()=>{C.current=!0,p.mutate(void 0,{onSuccess:async()=>{const b=await Ne("kiro");b.success&&b.presetName&&i&&I.success(`Applied "${b.presetName}" preset`),y()}})},P=b=>{b||A()},M=o.isAuthenticating;return e.jsx(Se,{open:s,onOpenChange:P,children:e.jsxs(Ae,{className:"sm:max-w-md",onInteractOutside:b=>{M&&b.preventDefault()},children:[e.jsxs(Pe,{children:[e.jsxs(Me,{children:["Add ",n," Account"]}),e.jsx(ls,{children:T?"Choose a Kiro auth method, then authenticate via browser or import from Kiro IDE.":S?"Click Authenticate. A verification code will appear for you to enter on the provider website.":"Click Authenticate to get an OAuth URL. Open it in any browser to sign in."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[T&&!M&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"kiro-auth-method",children:"Auth Method"}),e.jsxs(be,{value:g,onValueChange:b=>{N(b),r(null)},children:[e.jsx(Ce,{id:"kiro-auth-method",children:e.jsx(ye,{placeholder:"Select Kiro auth method"})}),e.jsx(ke,{children:$s.map(b=>e.jsx(re,{value:b.id,children:b.label},b.id))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:E.description})]}),!M&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"nickname",children:j?"Nickname (required)":"Nickname (optional)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(ie,{id:"nickname",value:u,onChange:b=>{c(b.target.value),r(null)},placeholder:"e.g., work, personal",disabled:D,className:"flex-1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:j?"Required for this provider. Use a unique friendly name (e.g., work, personal).":"A friendly name to identify this account. Auto-generated from email if left empty."})]}),M&&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(B,{className:"w-4 h-4 inline mr-2 animate-spin"}),"Waiting for authentication..."]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:o.isDeviceCodeFlow?"A verification code dialog will appear shortly. Enter the code on the provider website.":"Complete the authentication in your browser. This dialog closes automatically."})]}),o.authUrl&&!o.isDeviceCodeFlow&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{className:"text-xs",children:"Open this URL in any browser to sign in:"}),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:o.authUrl}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(O,{variant:"outline",size:"sm",onClick:w,children:h?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"w-3 h-3 mr-1"}),"Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(ms,{className:"w-3 h-3 mr-1"}),"Copy"]})}),e.jsxs(O,{variant:"outline",size:"sm",onClick:()=>{if(!o.authUrl)return;const b=window.open(o.authUrl,"_blank");(!b||b.closed||typeof b.closed>"u")&&I.warning("Popup blocked. Copy the URL above and open it manually in your browser.",{duration:5e3})},children:[e.jsx(xe,{className:"w-3 h-3 mr-1"}),"Open"]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"callback-url",className:"text-xs",children:"Redirect didn't work? Paste the callback URL:"}),e.jsx(ie,{id:"callback-url",value:m,onChange:b=>f(b.target.value),placeholder:"Paste the redirect URL here...",className:"font-mono text-xs"}),e.jsx(O,{variant:"secondary",size:"sm",onClick:_,disabled:!m.trim()||o.isSubmittingCallback,children:o.isSubmittingCallback?e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"w-3 h-3 mr-1 animate-spin"}),"Submitting..."]}):"Submit Callback"})]})]}),!o.authUrl&&!o.isDeviceCodeFlow&&e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:"Preparing sign-in URL..."})]}),F&&e.jsx("p",{className:"text-xs text-center text-destructive",children:F}),p.isPending&&e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:[e.jsx(B,{className:"w-4 h-4 inline mr-2 animate-spin"}),"Importing token from Kiro IDE..."]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(O,{variant:"ghost",onClick:A,children:"Cancel"}),T&&!M&&e.jsx(O,{variant:"outline",onClick:$,disabled:D,children:p.isPending?e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"w-4 h-4 mr-2 animate-spin"}),"Importing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(bt,{className:"w-4 h-4 mr-2"}),"Import from IDE"]})}),!M&&e.jsxs(O,{onClick:U,disabled:D||j&&!L,children:[e.jsx(xe,{className:"w-4 h-4 mr-2"}),"Authenticate"]})]})]})]})})}const Re="[1m]";function Vt(s){return s.toLowerCase().startsWith("gemini-")}function Le(s){return s.toLowerCase().endsWith(Re.toLowerCase())}function Jt(s){return!s||Le(s)?s:`${s}${Re}`}function Ns(s){return s&&(Le(s)?s.slice(0,-Re.length):s)}const Ze=["ANTHROPIC_MODEL"],Wt=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function Xt(s){const a=s?.env||{};return Wt.filter(t=>!a[t]?.trim())}function Yt(s){const[a,t]=d.useState(null),[n,i]=d.useState(!1),u=we(),{data:c,isLoading:m,refetch:f}=as({queryKey:["settings",s],queryFn:async()=>{const y=await fetch(`/api/settings/${s}/raw`);return y.ok?y.json():{profile:s,settings:{env:{}},mtime:Date.now(),path:`~/.ccs/profiles/${s}/settings.json`}}}),h=c?.settings,x=d.useMemo(()=>a!==null?a:h?JSON.stringify(h,null,2):`{
2
2
  "env": {}
3
3
  }`,[a,h]),v=d.useCallback(y=>{t(y)},[]),r=d.useMemo(()=>{try{return JSON.parse(x)}catch{return h||{env:{}}}},[x,h]),g=r?.env?.ANTHROPIC_MODEL,N=r?.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,C=r?.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,o=r?.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,p=d.useMemo(()=>{const y=r?.env||{};return Ze.some(A=>{const w=y[A];return w&&Le(w)})},[r]),T=d.useCallback((y,A)=>{const w={...r?.env||{},[y]:A},_={...r,env:w};t(JSON.stringify(_,null,2))},[r]),k=d.useCallback(y=>{const A=r?.env||{},w={};for(const $ of Ze){const P=A[$];P&&(w[$]=y?Jt(P):Ns(P))}const _={...A,...w};delete _.CCS_EXTENDED_CONTEXT;const U={...r,env:_};t(JSON.stringify(U,null,2))},[r]),j=d.useCallback(y=>{const A={...r?.env||{},...y},w={...r,env:A};t(JSON.stringify(w,null,2))},[r]),E=d.useMemo(()=>{try{return JSON.parse(x),!0}catch{return!1}},[x]),S=d.useMemo(()=>a===null?!1:a!==JSON.stringify(h,null,2),[a,h]),D=d.useMemo(()=>Xt(r),[r]),L=_s({mutationFn:async()=>{const y=JSON.parse(x),A=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:y,expectedMtime:c?.mtime})});if(A.status===409)throw new Error("CONFLICT");if(!A.ok)throw new Error("Failed to save");return A.json()},onSuccess:y=>{u.invalidateQueries({queryKey:["settings",s]}),t(null),y?.warning?I.success("Settings saved",{description:y.warning}):I.success("Settings saved")},onError:y=>{y.message==="CONFLICT"?i(!0):I.error(y.message)}}),F=async y=>{i(!1),y?(await f(),L.mutate()):t(null)};return{data:c,isLoading:m,refetch:f,rawJsonContent:x,rawJsonEdits:a,isRawJsonValid:E,hasChanges:S,currentSettings:r,currentModel:g,opusModel:N,sonnetModel:C,haikuModel:o,extendedContextEnabled:p,toggleExtendedContext:k,handleRawJsonChange:v,updateEnvValue:T,updateEnvValues:j,saveMutation:{mutate:()=>L.mutate(),isPending:L.isPending},conflictDialog:n,setConflictDialog:i,handleConflictResolve:F,missingRequiredFields:D}}const Zt=/-(medium|high|xhigh)$/i;function ea(s){if(!s)return;const a=s.trim().match(Zt);if(a?.[1])return a[1].toLowerCase()}function ge(s){if(!s)return null;const a=ea(s);return a?{label:`Pinned ${a}`,explicit:!0}:{label:"Auto effort",explicit:!1}}function J({label:s,description:a,value:t,onChange:n,catalog:i,allModels:u,disabled:c}){const m=new Set(i?.models.map(x=>x.id)||[]),f=i?.provider==="codex",h=f?ge(t):null;return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:s}),a&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a})]}),e.jsxs(be,{value:t||"",onValueChange:n,disabled:c,children:[e.jsx(Ce,{className:"h-9",children:e.jsx(ye,{placeholder:"Select model",children:t&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:t}),h&&e.jsx(K,{variant:h.explicit?"secondary":"outline",className:"text-[9px] h-4 px-1 uppercase",children:h.label})]})})}),e.jsxs(ke,{className:"max-h-[300px]",children:[i&&i.models.length>0&&e.jsxs(Be,{children:[e.jsx(ze,{className:"text-xs text-primary",children:"Recommended"}),i.models.map(x=>{const v=f?ge(x.id):null;return e.jsx(re,{value:x.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:x.id}),x.tier==="paid"&&e.jsx(K,{variant:"outline",className:"text-[9px] h-4 px-1",children:"PAID"}),v&&e.jsx(K,{variant:v.explicit?"secondary":"outline",className:"text-[9px] h-4 px-1 uppercase",children:v.label}),t===x.id&&e.jsx(z,{className:"w-3 h-3 text-primary ml-auto"})]})},x.id)})]}),u.length>0&&e.jsxs(Be,{children:[e.jsxs(ze,{className:"text-xs text-muted-foreground",children:["All Models (",u.length,")"]}),u.filter(x=>!m.has(x.id)).map(x=>{const v=f?ge(x.id):null;return e.jsx(re,{value:x.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:x.id}),v&&e.jsx(K,{variant:v.explicit?"secondary":"outline",className:"text-[9px] h-4 px-1 uppercase",children:v.label}),t===x.id&&e.jsx(z,{className:"w-3 h-3 text-primary ml-auto"})]})},x.id)})]}),(!i||i.models.length===0)&&u.length===0&&e.jsx("div",{className:"py-2 px-3 text-xs text-muted-foreground",children:"No models available"})]})]})]})}function sa({open:s,onClose:a,currentValues:t,onApply:n,onSave:i,isSaving:u,catalog:c,allModels:m}){const[f,h]=d.useState(t),[x,v]=d.useState(""),r=g=>{g?(h(t),v("")):a()};return e.jsx(Se,{open:s,onOpenChange:r,children:e.jsxs(Ae,{className:"sm:max-w-md",children:[e.jsx(Pe,{children:e.jsxs(Me,{className:"flex items-center gap-2",children:[e.jsx(le,{className:"w-4 h-4"}),"Custom Preset"]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"preset-name",children:"Preset Name (optional)"}),e.jsx(ie,{id:"preset-name",value:x,onChange:g=>v(g.target.value),placeholder:"e.g., My Custom Config",className:"text-sm"})]}),e.jsx(_e,{}),c?.provider==="codex"&&e.jsxs("p",{className:"text-[11px] text-muted-foreground 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 effort. Unsuffixed models use Thinking settings."]}),e.jsx(J,{label:"Default Model",description:"Used when no specific tier is requested",value:f.default,onChange:g=>h({...f,default:g}),catalog:c,allModels:m}),e.jsx(J,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:f.opus,onChange:g=>h({...f,opus:g}),catalog:c,allModels:m}),e.jsx(J,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:f.sonnet,onChange:g=>h({...f,sonnet:g}),catalog:c,allModels:m}),e.jsx(J,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:f.haiku,onChange:g=>h({...f,haiku:g}),catalog:c,allModels:m})]}),e.jsxs(Bs,{className:"gap-2 sm:gap-0",children:[e.jsx(O,{variant:"outline",onClick:a,children:"Cancel"}),i&&e.jsxs(O,{variant:"secondary",onClick:()=>i(f,x||void 0),disabled:u||!x.trim(),children:[u?e.jsx(B,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(pe,{className:"w-4 h-4 mr-1"}),"Save Preset"]}),e.jsxs(O,{onClick:()=>n(f,x||void 0),children:[e.jsx(ce,{className:"w-4 h-4 mr-1"}),"Apply Preset"]})]})]})})}function de({label:s,command:a}){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:a}),e.jsx(ds,{value:a,size:"icon",className:"h-6 w-6"})]})]})}function ta({provider:s,displayName:a,data:t,authStatus:n}){return e.jsx(Te,{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(xs,{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:a})]}),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(ds,{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:"Last Modified"}),e.jsx("span",{className:"text-xs",children:new Date(t.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"}),n.authenticated?e.jsxs(K,{variant:"outline",className:"w-fit text-green-600 border-green-200 bg-green-50",children:[e.jsx(Ct,{className:"w-3 h-3 mr-1"}),"Authenticated"]}):e.jsx(K,{variant:"outline",className:"w-fit text-muted-foreground",children:"Not connected"})]})]})]}),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(de,{label:"Run with prompt",command:`ccs ${s} "your prompt"`}),e.jsx(de,{label:"Change model",command:`ccs ${s} --config`}),e.jsx(de,{label:"Add account",command:`ccs ${s} --add`}),e.jsx(de,{label:"List accounts",command:`ccs ${s} --accounts`})]})]})]})})}const aa={gemini:"/assets/providers/gemini-color.svg",codex:"/assets/providers/openai.svg",agy:"/assets/providers/agy.png",qwen:"/assets/providers/qwen-color.svg",iflow:"/assets/providers/iflow.png",kiro:"/assets/providers/kiro.png",ghcp:"/assets/providers/copilot.svg",claude:"/assets/providers/claude.svg"},na={gemini:{text:"text-blue-600",letter:"G"},claude:{text:"text-orange-600",letter:"C"},codex:{text:"text-emerald-600",letter:"X"},agy:{text:"text-violet-600",letter:"A"},qwen:{text:"text-cyan-600",letter:"Q"},iflow:{text:"text-indigo-600",letter:"i"},kiro:{text:"text-teal-600",letter:"K"},ghcp:{text:"text-green-600",letter:"C"}},ia={sm:{container:"w-6 h-6",icon:"w-4 h-4",text:"text-xs"},md:{container:"w-8 h-8",icon:"w-5 h-5",text:"text-sm"},lg:{container:"w-12 h-12",icon:"w-8 h-8",text:"text-lg"}};function Ie({provider:s,className:a,size:t="md"}){const n=s.toLowerCase(),i=na[n]||{text:"text-gray-600",letter:s[0]?.toUpperCase()||"?"},u=ia[t],c=aa[n];return e.jsx("div",{className:H("flex items-center justify-center rounded-md",c&&"bg-white p-1",u.container,a),children:c?e.jsx("img",{src:c,alt:`${s} logo`,className:H(u.icon,"object-contain")}):e.jsx("span",{className:H("font-semibold",i.text,u.text),children:i.letter})})}function ra({displayName:s,logoProvider:a,provider:t,data:n,isLoading:i,hasChanges:u,isRawJsonValid:c,isSaving:m,isRemoteMode:f,port:h,onRefetch:x,onSave:v}){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(Ie,{provider:a||t,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}),f&&e.jsxs(K,{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(ps,{className:"w-3 h-3"}),"Remote"]}),h&&e.jsxs(K,{variant:"outline",className:"text-xs gap-1 font-mono",children:[e.jsx(yt,{className:"w-3 h-3"}),":",h]}),!f&&n?.path&&e.jsx(K,{variant:"outline",className:"text-xs",children:n.path.replace(/^.*[\\/]/,"")})]}),f?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(O,{variant:"ghost",size:"sm",onClick:x,disabled:i,children:e.jsx(Ee,{className:`w-4 h-4 ${i?"animate-spin":""}`})}),e.jsx(O,{size:"sm",onClick:v,disabled:m||!u||!c,children:m?e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(kt,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function oa({model:s,provider:a,enabled:t,onToggle:n,disabled:i,className:u}){if(!s?.extendedContext)return null;const c=Vt(s.id);return e.jsxs("div",{className:H("rounded-lg border p-3 space-y-2",t?"border-primary/50 bg-primary/5":"border-border bg-muted/30",u),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:H("w-4 h-4",t?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:"text-sm font-medium",children:"Extended Context"}),e.jsx(K,{variant:t?"default":"secondary",className:"text-[10px] h-5 px-1.5",children:"1M tokens"})]}),e.jsx(vs,{checked:t,onCheckedChange:n,disabled:i})]}),e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground",children:[e.jsx(xs,{className:"w-3.5 h-3.5 mt-0.5 shrink-0"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{children:"Enables 1M token context window instead of default 200K."}),e.jsx("p",{className:"text-[10px]",children:c?e.jsxs("span",{className:"text-primary",children:["Auto-enabled for ",a," Gemini models"]}):e.jsxs("span",{children:["Opt-in for ",a," Claude models via --1m flag"]})}),t&&e.jsx("p",{className:"text-amber-600 dark:text-amber-500",children:"Note: 2x input pricing applies for tokens beyond 200K"})]})]})]})}function la({catalog:s,savedPresets:a,currentModel:t,opusModel:n,sonnetModel:i,haikuModel:u,providerModels:c,provider:m,extendedContextEnabled:f,onExtendedContextToggle:h,onApplyPreset:x,onUpdateEnvValue:v,onOpenCustomPreset:r,onDeletePreset:g,isDeletePending:N}){const C=s&&s.models.length>0||a.length>0,o=d.useMemo(()=>{if(!s||!t)return;const p=Ns(t);return s.models.find(T=>T.id===p)},[s,t]);return e.jsxs(e.Fragment,{children:[C&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(le,{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:"flex flex-wrap gap-2",children:[s?.models.slice(0,4).map(p=>e.jsxs(O,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>{const T=p.presetMapping||{default:p.id,opus:p.id,sonnet:p.id,haiku:p.id};x({ANTHROPIC_MODEL:T.default,ANTHROPIC_DEFAULT_OPUS_MODEL:T.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:T.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:T.haiku})},children:[e.jsx(ce,{className:"w-3 h-3"}),p.name]},p.id)),a.map(p=>e.jsxs("div",{className:"group relative",children:[e.jsxs(O,{variant:"secondary",size:"sm",className:"text-xs h-7 gap-1 pr-6",onClick:()=>{x({ANTHROPIC_MODEL:p.default,ANTHROPIC_DEFAULT_OPUS_MODEL:p.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:p.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:p.haiku})},children:[e.jsx(pe,{className:"w-3 h-3 fill-current"}),p.name]}),e.jsx(O,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-7 w-5 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:T=>{T.stopPropagation(),g(p.name)},disabled:N,children:e.jsx(De,{className:"w-3 h-3"})})]},p.name)),e.jsxs(O,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1 border-primary/50 text-primary hover:bg-primary/10 hover:border-primary",onClick:r,children:[e.jsx(hs,{className:"w-3 h-3"}),"Custom"]})]})]}),e.jsx(_e,{}),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"}),m==="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(J,{label:"Default Model",description:"Used when no specific tier is requested",value:t,onChange:p=>v("ANTHROPIC_MODEL",p),catalog:s,allModels:c}),o?.extendedContext&&h&&e.jsx(oa,{model:o,provider:m,enabled:f??!1,onToggle:h}),e.jsx(J,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:n,onChange:p=>v("ANTHROPIC_DEFAULT_OPUS_MODEL",p),catalog:s,allModels:c}),e.jsx(J,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:i,onChange:p=>v("ANTHROPIC_DEFAULT_SONNET_MODEL",p),catalog:s,allModels:c}),e.jsx(J,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:u,onChange:p=>v("ANTHROPIC_DEFAULT_HAIKU_MODEL",p),catalog:s,allModels:c})]})]})]})}function ca({className:s,...a}){return e.jsx(Es,{"data-slot":"checkbox",className:H("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",s),...a,children:e.jsx(Ds,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none",children:e.jsx(z,{className:"size-3.5"})})})}function es(s){const a=Math.max(0,Math.min(100,s));return a<=20?"bg-destructive":a<=50?"bg-yellow-500":"bg-green-500"}function ss(s){if(!s)return"";try{const a=new Date(s),n=new Date().getTime()-a.getTime();if(n<0)return"just now";const i=Math.floor(n/(1e3*60)),u=Math.floor(n/(1e3*60*60)),c=Math.floor(n/(1e3*60*60*24));return c>0?`${c}d ago`:u>0?`${u}h ago`:i>0?`${i}m ago`:"just now"}catch{return""}}function da(s){if(!s)return!1;try{const a=new Date(s);return new Date().getTime()-a.getTime()<3600*1e3}catch{return!1}}function ua({account:s,onSetDefault:a,onRemove:t,onPauseToggle:n,isRemoving:i,isPausingAccount:u,privacyMode:c,showQuota:m,selectable:f,selected:h,onSelectChange:x}){const{data:v}=zs(m),{data:r,isLoading:g}=Qs(s.provider,s.id,m),N=v?.accountStats?.[s.email||s.id]?.lastUsedAt,C=da(N),o=Vs(s.provider,r),p=Js(s.provider,r),T=s.provider==="codex"&&r&&Ws(r)?Xs(r.windows):null,k=[{label:"5h",value:T?.fiveHourWindow?.remainingPercent??null},{label:"Weekly",value:T?.weeklyWindow?.remainingPercent??null}].filter(j=>j.value!==null);return e.jsxs("div",{className:H("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",h&&"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:[f&&e.jsx("button",{type:"button",onClick:()=>x?.(!h),className:H("flex items-center justify-center w-5 h-5 rounded border-2 transition-colors shrink-0",h?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30 hover:border-primary/50"),"aria-label":h?"Deselect account":"Select account",children:h&&e.jsx(z,{className:"w-3 h-3"})}),n&&e.jsx(ee,{children:e.jsxs(se,{children:[e.jsx(te,{asChild:!0,children:e.jsx(O,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>n(!s.paused),disabled:u,children:u?e.jsx(B,{className:"w-4 h-4 animate-spin"}):s.paused?e.jsx(fs,{className:"w-4 h-4 text-emerald-500"}):e.jsx(je,{className:"w-4 h-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(ae,{side:"top",children:s.paused?"Resume account":"Pause account"})]})}),e.jsxs("div",{className:"relative shrink-0",children:[e.jsx("div",{className:H("flex items-center justify-center w-8 h-8 rounded-full",s.isDefault?"bg-primary/10":"bg-muted"),children:e.jsx(ne,{className:"w-4 h-4"})}),s.tier&&s.tier!=="unknown"&&s.tier!=="free"&&e.jsx("span",{className:H("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:H("font-medium text-sm truncate",c&&me),children:s.email||s.id}),s.isDefault&&e.jsxs(K,{variant:"secondary",className:"text-[10px] h-4 px-1.5 gap-0.5",children:[e.jsx(pe,{className:"w-2.5 h-2.5 fill-current"}),"Default"]}),s.paused&&e.jsxs(K,{variant:"outline",className:"text-[10px] h-4 px-1.5 border-yellow-500 text-yellow-600",children:[e.jsx(je,{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(ee,{children:e.jsxs(se,{children:[e.jsx(te,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(St,{className:"w-3 h-3","aria-hidden":"true"}),e.jsx("span",{className:H("font-mono max-w-[180px] truncate",c&&me),title:s.projectId,children:s.projectId})]})}),e.jsx(ae,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:"GCP Project ID (read-only)"})})]})}):e.jsx(ee,{children:e.jsxs(se,{children:[e.jsx(te,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-500",children:[e.jsx(At,{className:"w-3 h-3","aria-label":"Warning"}),e.jsx("span",{children:"Project ID: N/A"})]})}),e.jsx(ae,{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(Xe,{className:"w-3 h-3"}),"Last used: ",new Date(s.lastUsedAt).toLocaleDateString()]})]})]}),e.jsxs(Ys,{children:[e.jsx(Zs,{asChild:!0,children:e.jsx(O,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(Pt,{className:"w-4 h-4"})})}),e.jsxs(et,{align:"end",children:[!s.isDefault&&e.jsxs(Qe,{onClick:a,children:[e.jsx(pe,{className:"w-4 h-4 mr-2"}),"Set as default"]}),e.jsxs(Qe,{className:"text-destructive focus:text-destructive",onClick:t,disabled:i,children:[e.jsx(gs,{className:"w-4 h-4 mr-2"}),i?"Removing...":"Remove account"]})]})]})]}),m&&e.jsx("div",{className:"pl-11",children:g?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(B,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{children:"Loading quota..."})]}):o!==null?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex items-center gap-1.5 text-xs",children:C?e.jsxs(e.Fragment,{children:[e.jsx(Mt,{className:"w-3 h-3 text-emerald-500"}),e.jsxs("span",{className:"text-emerald-600 dark:text-emerald-400",children:["Active · ",ss(N)]})]}):N?e.jsxs(e.Fragment,{children:[e.jsx(Xe,{className:"w-3 h-3 text-muted-foreground"}),e.jsxs("span",{className:"text-muted-foreground",children:["Last used ",ss(N)]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Tt,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Not used yet"})]})}),e.jsx(ee,{children:e.jsxs(se,{children:[e.jsx(te,{asChild:!0,children:s.provider==="codex"&&k.length>0?e.jsx("div",{className:"space-y-1.5",children:k.map(j=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-10 text-[10px] text-muted-foreground",children:j.label}),e.jsx(Ve,{value:Math.max(0,Math.min(100,j.value)),className:"h-2 flex-1",indicatorClassName:es(j.value)}),e.jsxs("span",{className:"text-xs font-medium w-10 text-right",children:[j.value,"%"]})]},j.label))}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ve,{value:Math.max(0,Math.min(100,o)),className:"h-2 flex-1",indicatorClassName:es(o)}),e.jsxs("span",{className:"text-xs font-medium w-10 text-right",children:[o,"%"]})]})}),e.jsx(ae,{side:"bottom",className:"max-w-xs",children:r&&e.jsx(st,{quota:r,resetTime:p})})]})})]}):r?.needsReauth?e.jsx(ee,{children:e.jsxs(se,{children:[e.jsx(te,{asChild:!0,children:e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(K,{variant:"outline",className:"text-[10px] h-5 px-2 gap-1 border-amber-500/50 text-amber-600 dark:text-amber-400",children:[e.jsx(Ot,{className:"w-3 h-3"}),"Reauth"]})})}),e.jsx(ae,{side:"bottom",className:"max-w-[220px]",children:e.jsx("p",{className:"text-xs",children:r.error?.includes("No refresh token")?"No refresh token available. Remove and re-add account to fix.":r.error?.includes("refresh")||r.error?.includes("Invalid")?`Auto-refresh failed: ${r.error}`:`Token issue: ${r.error||"Re-authenticate required"}`})})]})}):r?.error||r&&!r.success?e.jsx(ee,{children:e.jsxs(se,{children:[e.jsx(te,{asChild:!0,children:e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(K,{variant:"outline",className:"text-[10px] h-5 px-2 gap-1 border-muted-foreground/50 text-muted-foreground",children:[e.jsx(Et,{className:"w-3 h-3"}),"N/A"]})})}),e.jsx(ae,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:r?.error||"Quota information unavailable"})})]})}):null})]})}function ma({selectedCount:s,onPauseSelected:a,onResumeSelected:t,onClearSelection:n,isPausing:i,isResuming:u}){if(s<1)return null;const c=i||u;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(O,{variant:"ghost",size:"sm",className:"text-xs h-6 px-2",onClick:n,disabled:c,children:"Clear"}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsxs(O,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:a,disabled:c,children:[i?e.jsx(B,{className:"w-3 h-3 animate-spin"}):e.jsx(je,{className:"w-3 h-3"}),"Pause Selected"]}),e.jsxs(O,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:t,disabled:c,children:[u?e.jsx(B,{className:"w-3 h-3 animate-spin"}):e.jsx(fs,{className:"w-3 h-3"}),"Resume Selected"]})]})]})}function xa({accounts:s,onAddAccount:a,onSetDefault:t,onRemoveAccount:n,onPauseToggle:i,onSoloMode:u,onBulkPause:c,onBulkResume:m,isRemovingAccount:f,isPausingAccount:h,isSoloingAccount:x,isBulkPausing:v,isBulkResuming:r,privacyMode:g,showQuota:N,isKiro:C,kiroNoIncognito:o,onKiroNoIncognitoChange:p,kiroSettingsLoading:T}){const[k,j]=d.useState(new Set),E=d.useMemo(()=>new Set(s.map(M=>M.id)),[s]),S=d.useMemo(()=>new Set([...k].filter(M=>E.has(M))),[k,E]),D=!!(c&&m),L=S.size,F=s.length>0&&S.size===s.length,y=S.size>0&&S.size<s.length,A=d.useCallback(M=>{j(b=>{const q=new Set(b);return q.has(M)?q.delete(M):q.add(M),q})},[]),w=d.useCallback(()=>{j(new Set(s.map(M=>M.id)))},[s]),_=d.useCallback(()=>{j(new Set)},[]),U=d.useCallback(()=>{F?_():w()},[F,w,_]),$=d.useCallback(()=>{c&&S.size>0&&(c(Array.from(S)),j(new Set))},[c,S]),P=d.useCallback(()=>{m&&S.size>0&&(m(Array.from(S)),j(new Set))},[m,S]);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(ca,{checked:F,onCheckedChange:U,"aria-label":"Select all accounts",className:y?"data-[state=checked]:bg-primary/50":"",...y?{"data-state":"indeterminate"}:{}}),e.jsx(ne,{className:"w-4 h-4"}),"Accounts",s.length>0&&e.jsx(K,{variant:"secondary",className:"text-xs",children:s.length})]}),e.jsxs(O,{variant:"default",size:"sm",className:"h-7 text-xs gap-1",onClick:a,children:[e.jsx(hs,{className:"w-3 h-3"}),"Add"]})]}),D&&L>0&&e.jsx(ma,{selectedCount:L,onPauseSelected:$,onResumeSelected:P,onClearSelection:_,isPausing:!!v,isResuming:!!r}),s.length>0?e.jsx("div",{className:"space-y-2",children:s.map(M=>e.jsx(ua,{account:M,onSetDefault:()=>t(M.id),onRemove:()=>n(M.id),onPauseToggle:i?b=>i(M.id,b):void 0,onSoloMode:u?()=>u(M.id):void 0,isRemoving:f,isPausingAccount:h,isSoloingAccount:x,privacyMode:g,showQuota:N,selectable:D,selected:S.has(M.id),onSelectChange:()=>A(M.id)},M.id))}):e.jsxs("div",{className:"py-6 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed",children:[e.jsx(ne,{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"})]}),C&&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(ps,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Use incognito"})]}),e.jsx(vs,{checked:!o,onCheckedChange:M=>p(!M),disabled:T,className:"scale-90"})]})})]})}function pa({provider:s,catalog:a,savedPresets:t,currentModel:n,opusModel:i,sonnetModel:u,haikuModel:c,providerModels:m,extendedContextEnabled:f,onExtendedContextToggle:h,onApplyPreset:x,onUpdateEnvValue:v,onOpenCustomPreset:r,onDeletePreset:g,isDeletePending:N,accounts:C,onAddAccount:o,onSetDefault:p,onRemoveAccount:T,onPauseToggle:k,onSoloMode:j,onBulkPause:E,onBulkResume:S,isRemovingAccount:D,isPausingAccount:L,isSoloingAccount:F,isBulkPausing:y,isBulkResuming:A,privacyMode:w,isRemoteMode:_}){const U=s==="kiro",[$,P]=d.useState(!0),[M,b]=d.useState(!0),[q,Z]=d.useState(!1),l=d.useCallback(async()=>{if(U)try{b(!0);const W=(await ue.config.get()).cliproxy;P(W?.kiro_no_incognito??!0)}catch{P(!0)}finally{b(!1)}},[U]),R=d.useCallback(async Q=>{P(Q),Z(!0);try{const W=await ue.config.get(),he=W.cliproxy??{};await ue.config.update({...W,cliproxy:{...he,kiro_no_incognito:Q}})}catch{P(!Q)}finally{Z(!1)}},[]);return d.useEffect(()=>{l()},[l]),e.jsx(Te,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsx(la,{catalog:a,savedPresets:t,currentModel:n,opusModel:i,sonnetModel:u,haikuModel:c,providerModels:m,provider:s,extendedContextEnabled:f,onExtendedContextToggle:h,onApplyPreset:x,onUpdateEnvValue:v,onOpenCustomPreset:r,onDeletePreset:g,isDeletePending:N}),e.jsx(_e,{}),e.jsx(xa,{accounts:C,onAddAccount:o,onSetDefault:p,onRemoveAccount:T,onPauseToggle:k,onSoloMode:j,onBulkPause:E,onBulkResume:S,isRemovingAccount:D,isPausingAccount:L,isSoloingAccount:F,isBulkPausing:y,isBulkResuming:A,privacyMode:w,showQuota:tt.includes(s)&&!_,isKiro:U,kiroNoIncognito:$,onKiroNoIncognitoChange:R,kiroSettingsLoading:M||q})]})})}function ts({provider:s,displayName:a,authStatus:t,catalog:n,logoProvider:i,baseProvider:u,isRemoteMode:c,port:m,onAddAccount:f,onSetDefault:h,onRemoveAccount:x,onPauseToggle:v,onSoloMode:r,onBulkPause:g,onBulkResume:N,isRemovingAccount:C,isPausingAccount:o,isSoloingAccount:p,isBulkPausing:T,isBulkResuming:k}){const[j,E]=d.useState(!1),{privacyMode:S}=os(),{data:D}=at(),{data:L}=nt(s),F=it(),y=rt(),A=L?.presets||[],w=u||s,_=d.useMemo(()=>{if(!D?.models)return[];const V={gemini:["google"],agy:["antigravity"],codex:["openai"],qwen:["alibaba","qwen"],iflow:["iflow"],kiro:["kiro","aws"],ghcp:["github","copilot"]}[w.toLowerCase()]||[w.toLowerCase()];return D.models.filter(Ke=>V.some(Os=>Ke.owned_by.toLowerCase().includes(Os)))},[D,w]),{data:U,isLoading:$,refetch:P,rawJsonContent:M,rawJsonEdits:b,isRawJsonValid:q,hasChanges:Z,currentModel:l,opusModel:R,sonnetModel:Q,haikuModel:W,extendedContextEnabled:he,toggleExtendedContext:ws,handleRawJsonChange:bs,updateEnvValue:Cs,updateEnvValues:Fe,saveMutation:Ue,conflictDialog:ys,handleConflictResolve:qe,missingRequiredFields:ks}=Yt(s),Ss=t.accounts||[],{data:As}=as({queryKey:["auth-tokens-raw"],queryFn:async()=>{const G=await fetch("/api/settings/auth/tokens/raw");return G.ok?G.json():{apiKey:{value:"ccs-internal-managed"}}},staleTime:6e4}),He=As?.apiKey?.value??"ccs-internal-managed",Ps=G=>{Fe({ANTHROPIC_BASE_URL:`http://127.0.0.1:${m??ve}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:He,...G}),I.success(`Applied "${G.ANTHROPIC_MODEL?.split("/").pop()||"preset"}" preset`)},Ms=(G,V)=>{Fe({ANTHROPIC_BASE_URL:`http://127.0.0.1:${m??ve}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:He,ANTHROPIC_MODEL:G.default,ANTHROPIC_DEFAULT_OPUS_MODEL:G.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:G.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:G.haiku}),I.success(`Applied ${V?`"${V}"`:"custom"} preset`),E(!1)},Ts=(G,V)=>{if(!V){I.error("Please enter a preset name to save");return}F.mutate({profile:s,data:{name:V,...G}}),E(!1)};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(ra,{provider:s,displayName:a,logoProvider:i,data:U,isLoading:$,hasChanges:Z,isRawJsonValid:q,isSaving:Ue.isPending,isRemoteMode:c,port:m,onRefetch:P,onSave:()=>Ue.mutate()}),$?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(B,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):e.jsxs("div",{className:"flex-1 grid grid-cols-[40%_60%] divide-x overflow-hidden",children:[e.jsx("div",{className:"flex flex-col overflow-hidden bg-muted/5",children:e.jsxs(ot,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(lt,{className:"w-full",children:[e.jsx(Je,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(Je,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(We,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(pa,{provider:s,catalog:n,savedPresets:A,currentModel:l,opusModel:R,sonnetModel:Q,haikuModel:W,providerModels:_,extendedContextEnabled:he,onExtendedContextToggle:ws,onApplyPreset:Ps,onUpdateEnvValue:Cs,onOpenCustomPreset:()=>E(!0),onDeletePreset:G=>y.mutate({profile:s,name:G}),isDeletePending:y.isPending,accounts:Ss,onAddAccount:f,onSetDefault:h,onRemoveAccount:x,onPauseToggle:v,onSoloMode:r,onBulkPause:g,onBulkResume:N,isRemovingAccount:C,isPausingAccount:o,isSoloingAccount:p,isBulkPausing:T,isBulkResuming:k,privacyMode:S,isRemoteMode:c})}),e.jsx(We,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(ta,{provider:s,displayName:a,data:U,authStatus:t})})]})]})}),e.jsxs("div",{className:"flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(Dt,{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(ct,{rawJsonContent:M,isRawJsonValid:q,rawJsonEdits:b,onRawJsonChange:bs,profileEnv:U?.settings?.env,missingRequiredFields:ks})]})]}),e.jsx(_t,{open:ys,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>qe(!0),onCancel:()=>qe(!1)}),e.jsx(sa,{open:j,onClose:()=>E(!1),currentValues:{default:l||"",opus:R||"",sonnet:Q||"",haiku:W||""},onApply:Ms,onSave:Ts,isSaving:F.isPending,catalog:n,allModels:_})]})}function ha({status:s,isSelected:a,onSelect:t}){const n=s.accounts?.length||0;return e.jsxs("button",{className:H("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors cursor-pointer text-left",a?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:t,children:[e.jsx(Ie,{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}),n>0&&e.jsx(K,{variant:"secondary",className:"text-[10px] h-4 px-1",children:n})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:s.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-green-600",children:"Connected"})]}):e.jsxs(e.Fragment,{children:[e.jsx(De,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Not connected"})]})})]})]})}function fa({variant:s,parentAuth:a,isSelected:t,onSelect:n,onDelete:i,isDeleting:u}){return e.jsxs("button",{className:H("group w-full flex items-center gap-3 px-3 py-2 rounded-lg transition-colors cursor-pointer text-left pl-6",t?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:n,children:[e.jsxs("div",{className:"relative",children:[e.jsx(Ie,{provider:s.provider,size:"sm"}),e.jsx(js,{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(K,{variant:"outline",className:"text-[9px] h-4 px-1",children:"variant"})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:a?.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"w-3 h-3 text-green-600"}),e.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["via ",s.provider]})]}):e.jsxs(e.Fragment,{children:[e.jsx(De,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Parent not connected"})]})})]}),e.jsx(O,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:c=>{c.stopPropagation(),i()},disabled:u,children:e.jsx(gs,{className:"w-3 h-3"})})]})}function ga({onSetup:s}){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:"CCS Profile Manager"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Manage OAuth authentication, account preferences, and model selection for CLIProxy providers. Configure how CCS routes requests to different AI backends."}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-6",children:["For live usage stats and real-time monitoring, visit the"," ",e.jsx("a",{href:"/cliproxy/control-panel",className:"text-primary hover:underline",children:"Control Panel"}),"."]}),e.jsxs(O,{onClick:s,className:"gap-2",children:[e.jsx(le,{className:"w-4 h-4"}),"Quick Setup"]})]})})}function Ea(){const s=we(),{data:a,isLoading:t}=rs(),{data:n,isFetching:i}=dt(),{data:u}=ut(),c=mt(),m=xt(),f=pt(),h=ht(),x=ft(),v=gt(),r=jt(),g=vt(),[N,C]=d.useState(()=>typeof window<"u"?localStorage.getItem("cliproxy-selected-provider"):null),[o,p]=d.useState(null),[T,k]=d.useState(!1),[j,E]=d.useState(null),S=d.useMemo(()=>a?.authStatus||[],[a?.authStatus]),D=a?.source==="remote",L=d.useMemo(()=>n?.variants||[],[n?.variants]),F=l=>{C(l),l&&localStorage.setItem("cliproxy-selected-provider",l)},y=d.useMemo(()=>o?null:N&&S.some(l=>l.provider===N)?N:S.length>0&&(S.find(R=>(R.accounts?.length||0)>0)?.provider||S[0]?.provider)||null,[N,o,S]),A=S.find(l=>l.provider===y),w=L.find(l=>l.name===o),_=w?S.find(l=>l.provider===w.provider):void 0,U=()=>{s.invalidateQueries({queryKey:["cliproxy"]}),s.invalidateQueries({queryKey:["cliproxy-auth"]})},$=(l,R,Q)=>{f.isPending||h.isPending||(Q?f.mutate({provider:l,accountId:R}):h.mutate({provider:l,accountId:R}))},P=(l,R)=>{x.isPending||x.mutate({provider:l,accountId:R})},M=(l,R)=>{v.isPending||v.mutate({provider:l,accountIds:R})},b=(l,R)=>{r.isPending||r.mutate({provider:l,accountIds:R})},q=l=>{F(l),p(null)},Z=l=>{p(l),F(null)};return e.jsxs("div",{className:"h-[calc(100vh-100px)] flex",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:u?.backendLabel??"CLIProxy"})]}),e.jsx(O,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:U,disabled:i,children:e.jsx(Ee,{className:H("w-4 h-4",i&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"CCS-level account management"}),e.jsxs(O,{variant:"default",size:"sm",className:"w-full gap-2",onClick:()=>k(!0),children:[e.jsx(le,{className:"w-4 h-4"}),"Quick Setup"]})]}),e.jsx(Te,{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:"Providers"}),t?e.jsx("div",{className:"space-y-2 px-2",children:[1,2,3,4].map(l=>e.jsx(Nt,{className:"h-14 w-full rounded-lg"},l))}):e.jsx("div",{className:"space-y-1",children:S.map(l=>e.jsx(ha,{status:l,isSelected:y===l.provider,onSelect:()=>q(l.provider)},l.provider))}),L.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(js,{className:"w-3 h-3"}),"Variants"]}),e.jsx("div",{className:"space-y-1",children:L.map(l=>e.jsx(fa,{variant:l,parentAuth:S.find(R=>R.provider===l.provider),isSelected:o===l.name,onSelect:()=>Z(l.name),onDelete:()=>g.mutate(l.name),isDeleting:g.isPending},l.name))})]})]})}),e.jsx("div",{className:"p-3 border-t",children:e.jsx(Rt,{})}),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.jsxs("span",{children:[S.length," provider",S.length!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(z,{className:"w-3 h-3 text-green-600"}),S.filter(l=>l.authenticated).length," connected"]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background",children:w&&_?e.jsx(ts,{provider:w.name,displayName:`${w.name} (${w.provider} variant)`,authStatus:_,catalog:oe[w.provider],logoProvider:w.provider,baseProvider:w.provider,isRemoteMode:D,port:w.port,onAddAccount:()=>E({provider:w.provider,displayName:_.displayName,isFirstAccount:(_.accounts?.length||0)===0}),onSetDefault:l=>c.mutate({provider:w.provider,accountId:l}),onRemoveAccount:l=>m.mutate({provider:w.provider,accountId:l}),onPauseToggle:(l,R)=>$(w.provider,l,R),onSoloMode:l=>P(w.provider,l),onBulkPause:l=>M(w.provider,l),onBulkResume:l=>b(w.provider,l),isRemovingAccount:m.isPending,isPausingAccount:f.isPending||h.isPending,isSoloingAccount:x.isPending,isBulkPausing:v.isPending,isBulkResuming:r.isPending}):A?e.jsx(ts,{provider:A.provider,displayName:A.displayName,authStatus:A,catalog:oe[A.provider],isRemoteMode:D,onAddAccount:()=>E({provider:A.provider,displayName:A.displayName,isFirstAccount:(A.accounts?.length||0)===0}),onSetDefault:l=>c.mutate({provider:A.provider,accountId:l}),onRemoveAccount:l=>m.mutate({provider:A.provider,accountId:l}),onPauseToggle:(l,R)=>$(A.provider,l,R),onSoloMode:l=>P(A.provider,l),onBulkPause:l=>M(A.provider,l),onBulkResume:l=>b(A.provider,l),isRemovingAccount:m.isPending,isPausingAccount:f.isPending||h.isPending,isSoloingAccount:x.isPending,isBulkPausing:v.isPending,isBulkResuming:r.isPending}):e.jsx(ga,{onSetup:()=>k(!0)})}),e.jsx($t,{open:T,onClose:()=>k(!1)}),e.jsx(Qt,{open:j!==null,onClose:()=>E(null),provider:j?.provider||"",displayName:j?.displayName||"",isFirstAccount:j?.isFirstAccount||!1})]})}export{Ea as CliproxyPage};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as s}from"./react-vendor-CNOkPC89.js";import{u as w}from"./tanstack-De4wvi8X.js";import{ae as E}from"./index-BteqkOAf.js";import{G as I,R as v,a1 as S,a2 as T,K as U,S as K,X as M}from"./icons-DGASzt3M.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";const A=8317;function F({port:c=A}){const n=s.useRef(null),[f,p]=s.useState(!0),[b,i]=s.useState(null),[k,m]=s.useState(!1),[P,L]=s.useState(!0),{data:g,error:h}=w({queryKey:["cliproxy-server-config"],queryFn:()=>E.cliproxyServer.get(),staleTime:3e4}),{data:j}=w({queryKey:["auth-tokens-raw"],queryFn:async()=>{const t=await fetch("/api/settings/auth/tokens/raw");if(!t.ok)throw new Error("Failed to fetch auth tokens");return t.json()},staleTime:3e4});s.useEffect(()=>{h&&console.warn("[ControlPanelEmbed] Config fetch failed, using local mode:",h)},[h]);const{managementUrl:y,checkUrl:d,authToken:r,isRemote:l,displayHost:u}=s.useMemo(()=>{const t=g?.remote;if(t?.enabled&&t?.host){const o=t.protocol||"http",a=t.port||(o==="https"?443:80),N=o==="https"&&a===443||o==="http"&&a===80?"":`:${a}`,C=`${o}://${t.host}${N}`;return{managementUrl:`${C}/management.html`,checkUrl:`${C}/`,authToken:t.auth_token||void 0,isRemote:!0,displayHost:`${t.host}${N}`}}const x=j?.managementSecret?.value||"ccs";return{managementUrl:`http://localhost:${c}/management.html`,checkUrl:`http://localhost:${c}/`,authToken:x,isRemote:!1,displayHost:`localhost:${c}`}},[g,j,c]);s.useEffect(()=>{const t=new AbortController,x=async()=>{try{(await fetch(d,{signal:t.signal})).ok?(m(!0),i(null)):(m(!1),i(l?`Remote CLIProxy at ${u} returned an error`:"CLIProxy returned an error"))}catch(a){if(a instanceof Error&&a.name==="AbortError")return;m(!1),i(l?`Remote CLIProxy at ${u} is not reachable`:"CLIProxy is not running")}},o=setTimeout(()=>t.abort(),2e3);return x().finally(()=>clearTimeout(o)),()=>t.abort()},[d,l,u]);const $=s.useCallback(()=>{if(p(!1),n.current?.contentWindow&&r)try{const t=d.replace(/\/$/,"");if(!n.current.src.startsWith(t)){console.warn("[ControlPanelEmbed] Iframe origin mismatch, skipping postMessage");return}n.current.contentWindow.postMessage({type:"ccs-auto-login",apiBase:t,managementKey:r},t)}catch(t){console.debug("[ControlPanelEmbed] postMessage failed - cross-origin:",t)}},[d,r]),R=()=>{p(!0),i(null),m(!1),n.current&&(n.current.src=y)};return!k&&b?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(I,{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:R,children:[e.jsx(v,{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(S,{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:b}),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.jsxs("div",{className:"flex-1 flex flex-col relative",children:[P&&!f&&e.jsx("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-20",children:e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-blue-50 dark:bg-blue-950 border border-blue-200 dark:border-blue-800 rounded-md text-sm",children:[l&&e.jsxs(e.Fragment,{children:[e.jsx(T,{className:"h-3.5 w-3.5 text-green-600"}),e.jsx("span",{className:"text-green-600 font-medium",children:"Remote"}),e.jsx("span",{className:"text-blue-300 dark:text-blue-700",children:"|"})]}),e.jsx(U,{className:"h-3.5 w-3.5 text-blue-600"}),e.jsxs("span",{children:["Key:"," ",e.jsx("code",{className:"bg-blue-100 dark:bg-blue-900 px-1 rounded font-mono font-semibold",children:r&&r.length>4?`***${r.slice(-4)}`:r||"ccs"})]}),e.jsx("a",{href:"/settings?tab=auth",className:"text-blue-600 hover:text-blue-800 dark:hover:text-blue-400",title:"Manage auth tokens",children:e.jsx(K,{className:"h-3.5 w-3.5"})}),e.jsx("button",{className:"text-blue-600 hover:text-blue-800 dark:hover:text-blue-400",onClick:()=>L(!1),children:e.jsx(M,{className:"h-3.5 w-3.5"})})]})}),f&&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(v,{className:"w-8 h-8 animate-spin text-primary mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l?`Loading Control Panel from ${u}...`:"Loading Control Panel..."})]})}),e.jsx("iframe",{ref:n,src:y,className:"flex-1 w-full border-0",title:"CLIProxy Management Panel",onLoad:$})]})}function D(){return e.jsx("div",{className:"h-[calc(100vh-100px)] flex flex-col",children:e.jsx(F,{})})}export{D as CliproxyControlPanelPage};
1
+ import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as s}from"./react-vendor-CNOkPC89.js";import{u as w}from"./tanstack-De4wvi8X.js";import{ae as E}from"./index-Dv5jtphl.js";import{G as I,R as v,a1 as S,a2 as T,K as U,S as K,X as M}from"./icons-DGASzt3M.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";const A=8317;function F({port:c=A}){const n=s.useRef(null),[f,p]=s.useState(!0),[b,i]=s.useState(null),[k,m]=s.useState(!1),[P,L]=s.useState(!0),{data:g,error:h}=w({queryKey:["cliproxy-server-config"],queryFn:()=>E.cliproxyServer.get(),staleTime:3e4}),{data:j}=w({queryKey:["auth-tokens-raw"],queryFn:async()=>{const t=await fetch("/api/settings/auth/tokens/raw");if(!t.ok)throw new Error("Failed to fetch auth tokens");return t.json()},staleTime:3e4});s.useEffect(()=>{h&&console.warn("[ControlPanelEmbed] Config fetch failed, using local mode:",h)},[h]);const{managementUrl:y,checkUrl:d,authToken:r,isRemote:l,displayHost:u}=s.useMemo(()=>{const t=g?.remote;if(t?.enabled&&t?.host){const o=t.protocol||"http",a=t.port||(o==="https"?443:80),N=o==="https"&&a===443||o==="http"&&a===80?"":`:${a}`,C=`${o}://${t.host}${N}`;return{managementUrl:`${C}/management.html`,checkUrl:`${C}/`,authToken:t.auth_token||void 0,isRemote:!0,displayHost:`${t.host}${N}`}}const x=j?.managementSecret?.value||"ccs";return{managementUrl:`http://localhost:${c}/management.html`,checkUrl:`http://localhost:${c}/`,authToken:x,isRemote:!1,displayHost:`localhost:${c}`}},[g,j,c]);s.useEffect(()=>{const t=new AbortController,x=async()=>{try{(await fetch(d,{signal:t.signal})).ok?(m(!0),i(null)):(m(!1),i(l?`Remote CLIProxy at ${u} returned an error`:"CLIProxy returned an error"))}catch(a){if(a instanceof Error&&a.name==="AbortError")return;m(!1),i(l?`Remote CLIProxy at ${u} is not reachable`:"CLIProxy is not running")}},o=setTimeout(()=>t.abort(),2e3);return x().finally(()=>clearTimeout(o)),()=>t.abort()},[d,l,u]);const $=s.useCallback(()=>{if(p(!1),n.current?.contentWindow&&r)try{const t=d.replace(/\/$/,"");if(!n.current.src.startsWith(t)){console.warn("[ControlPanelEmbed] Iframe origin mismatch, skipping postMessage");return}n.current.contentWindow.postMessage({type:"ccs-auto-login",apiBase:t,managementKey:r},t)}catch(t){console.debug("[ControlPanelEmbed] postMessage failed - cross-origin:",t)}},[d,r]),R=()=>{p(!0),i(null),m(!1),n.current&&(n.current.src=y)};return!k&&b?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(I,{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:R,children:[e.jsx(v,{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(S,{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:b}),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.jsxs("div",{className:"flex-1 flex flex-col relative",children:[P&&!f&&e.jsx("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-20",children:e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-blue-50 dark:bg-blue-950 border border-blue-200 dark:border-blue-800 rounded-md text-sm",children:[l&&e.jsxs(e.Fragment,{children:[e.jsx(T,{className:"h-3.5 w-3.5 text-green-600"}),e.jsx("span",{className:"text-green-600 font-medium",children:"Remote"}),e.jsx("span",{className:"text-blue-300 dark:text-blue-700",children:"|"})]}),e.jsx(U,{className:"h-3.5 w-3.5 text-blue-600"}),e.jsxs("span",{children:["Key:"," ",e.jsx("code",{className:"bg-blue-100 dark:bg-blue-900 px-1 rounded font-mono font-semibold",children:r&&r.length>4?`***${r.slice(-4)}`:r||"ccs"})]}),e.jsx("a",{href:"/settings?tab=auth",className:"text-blue-600 hover:text-blue-800 dark:hover:text-blue-400",title:"Manage auth tokens",children:e.jsx(K,{className:"h-3.5 w-3.5"})}),e.jsx("button",{className:"text-blue-600 hover:text-blue-800 dark:hover:text-blue-400",onClick:()=>L(!1),children:e.jsx(M,{className:"h-3.5 w-3.5"})})]})}),f&&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(v,{className:"w-8 h-8 animate-spin text-primary mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l?`Loading Control Panel from ${u}...`:"Loading Control Panel..."})]})}),e.jsx("iframe",{ref:n,src:y,className:"flex-1 w-full border-0",title:"CLIProxy Management Panel",onLoad:$})]})}function D(){return e.jsx("div",{className:"h-[calc(100vh-100px)] flex flex-col",children:e.jsx(F,{})})}export{D as CliproxyControlPanelPage};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-qEZD5MMp.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-RKd6P34V.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
+ import{j as e}from"./radix-ui-qEZD5MMp.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-B5t_5_UL.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-qEZD5MMp.js";import{B as b,b as v,X as le,Y as re,Z as ce,_ as de,ak as we,al as ye,$ as Q,M as X,m as J,L as C,I as te,q as ue,S as y,H as be,J as Ce,K as z,aP as Se,c as Y}from"./index-BteqkOAf.js";import{r as j}from"./react-vendor-CNOkPC89.js";import{a as ke,u as M,b as S}from"./tanstack-De4wvi8X.js";import{C as Fe}from"./confirm-dialog-39RkxEsp.js";import{R as me,L as xe,ah as Pe,j as Me,a0 as Ae,Z as ae,I as Le,ak as Re,a as Te,T as Ee,a4 as Oe,ao as _e,av as ne,K as Ie,x as qe,aw as De,q as he,r as pe}from"./icons-DGASzt3M.js";import{S as W}from"./separator-yty7hz16.js";import{S as H}from"./switch-Dq8eo1UY.js";import{t as A}from"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-RKd6P34V.js";const g="/api";async function Ue(){const s=await fetch(`${g}/copilot/status`);if(!s.ok)throw new Error("Failed to fetch copilot status");return s.json()}async function Ke(){const s=await fetch(`${g}/copilot/config`);if(!s.ok)throw new Error("Failed to fetch copilot config");return s.json()}async function Qe(){const s=await fetch(`${g}/copilot/models`);if(!s.ok)throw new Error("Failed to fetch copilot models");return s.json()}async function Je(){const s=await fetch(`${g}/copilot/settings/raw`);if(!s.ok)throw new Error("Failed to fetch copilot raw settings");return s.json()}async function $e(s){const t=await fetch(`${g}/copilot/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok)throw new Error("Failed to update copilot config");return t.json()}async function Be(s){const t=await fetch(`${g}/copilot/settings/raw`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(t.status===409)throw new Error("CONFLICT");if(!t.ok)throw new Error("Failed to save copilot raw settings");return t.json()}async function Ge(){const s=await fetch(`${g}/copilot/auth/start`,{method:"POST"});if(!s.ok)throw new Error("Failed to start auth");return s.json()}async function ze(){const s=await fetch(`${g}/copilot/daemon/start`,{method:"POST"});if(!s.ok)throw new Error("Failed to start daemon");return s.json()}async function He(){const s=await fetch(`${g}/copilot/daemon/stop`,{method:"POST"});if(!s.ok)throw new Error("Failed to stop daemon");return s.json()}async function Ve(){const s=await fetch(`${g}/copilot/info`);if(!s.ok)throw new Error("Failed to fetch copilot info");return s.json()}async function Ye(s){const t=await fetch(`${g}/copilot/install`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s?{version:s}:{})});if(!t.ok)throw new Error("Failed to install copilot-api");return t.json()}function fe(){const s=ke(),t=M({queryKey:["copilot-status"],queryFn:Ue,refetchInterval:5e3}),o=M({queryKey:["copilot-config"],queryFn:Ke}),c=M({queryKey:["copilot-models"],queryFn:Qe}),a=M({queryKey:["copilot-raw-settings"],queryFn:Je}),d=M({queryKey:["copilot-info"],queryFn:Ve}),l=S({mutationFn:$e,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]}),s.invalidateQueries({queryKey:["copilot-config"]}),s.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),i=S({mutationFn:Be,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]}),s.invalidateQueries({queryKey:["copilot-config"]}),s.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),u=S({mutationFn:Ge,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]})}}),h=S({mutationFn:ze,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]})}}),x=S({mutationFn:He,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]})}}),n=S({mutationFn:Ye,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]}),s.invalidateQueries({queryKey:["copilot-info"]})}});return j.useMemo(()=>({status:t.data,statusLoading:t.isLoading,statusError:t.error,refetchStatus:t.refetch,config:o.data,configLoading:o.isLoading,models:c.data?.models??[],currentModel:c.data?.current,modelsLoading:c.isLoading,rawSettings:a.data,rawSettingsLoading:a.isLoading,refetchRawSettings:a.refetch,updateConfig:l.mutate,updateConfigAsync:l.mutateAsync,isUpdating:l.isPending,saveRawSettings:i.mutate,saveRawSettingsAsync:i.mutateAsync,isSavingRawSettings:i.isPending,startAuth:u.mutate,startAuthAsync:u.mutateAsync,isAuthenticating:u.isPending,authResult:u.data,startDaemon:h.mutate,isStartingDaemon:h.isPending,stopDaemon:x.mutate,isStoppingDaemon:x.isPending,info:d.data,infoLoading:d.isLoading,refetchInfo:d.refetch,install:n.mutate,installAsync:n.mutateAsync,isInstalling:n.isPending}),[t.data,t.isLoading,t.error,t.refetch,o.data,o.isLoading,c.data,c.isLoading,a.data,a.isLoading,a.refetch,l.mutate,l.mutateAsync,l.isPending,i.mutate,i.mutateAsync,i.isPending,u.mutate,u.mutateAsync,u.isPending,u.data,h.mutate,h.isPending,x.mutate,x.isPending,d.data,d.isLoading,d.refetch,n.mutate,n.mutateAsync,n.isPending])}function We({rawSettings:s,rawSettingsLoading:t,isUpdating:o,isSavingRawSettings:c,hasChanges:a,isRawJsonValid:d,onRefresh:l,onSave:i}){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"}),s&&e.jsx(b,{variant:"outline",className:"text-xs",children:"copilot.settings.json"})]}),s&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified:"," ",s.exists?new Date(s.mtime).toLocaleString():"Never saved"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{variant:"ghost",size:"sm",onClick:l,disabled:t,children:e.jsx(me,{className:`w-4 h-4 ${t?"animate-spin":""}`})}),e.jsx(v,{size:"sm",onClick:i,disabled:o||c||!a||!d,children:o||c?e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Pe,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}const Xe=[{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"},{name:"Raptor Mini (Free)",description:"Free tier - fine-tuned for coding",default:"raptor-mini",opus:"raptor-mini",sonnet:"raptor-mini",haiku:"raptor-mini"}],Ze=[{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 ie(s){switch(s){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 es(s){return s==null?null:s===0?"Free":s<1?`${s}x`:s===1?"1x":`${s}x`}function D({label:s,description:t,value:o,onChange:c,models:a,disabled:d}){const l=a.find(i=>i.id===o);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.jsxs(le,{value:o||"",onValueChange:c,disabled:d,children:[e.jsx(re,{className:"h-9",children:e.jsx(ce,{placeholder:"Select model",children:o&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:o}),l?.minPlan&&e.jsx(b,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ie(l.minPlan)}`,children:l.minPlan})]})})}),e.jsx(de,{className:"max-h-[300px]",children:e.jsxs(we,{children:[e.jsxs(ye,{className:"text-xs text-muted-foreground",children:["Available Models (",a.length,")"]}),a.map(i=>e.jsx(Q,{value:i.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:i.name||i.id}),i.minPlan&&e.jsx(b,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ie(i.minPlan)}`,children:i.minPlan}),i.multiplier!==void 0&&e.jsx("span",{className:"text-[9px] text-muted-foreground",children:es(i.multiplier)}),i.preview&&e.jsx(b,{variant:"secondary",className:"text-[9px] px-1 py-0 h-4",children:"Preview"}),o===i.id&&e.jsx(Me,{className:"w-3 h-3 text-primary ml-auto"})]})},i.id))]})})]})]})}function ss({currentModel:s,opusModel:t,sonnetModel:o,haikuModel:c,models:a,modelsLoading:d,onApplyPreset:l,onUpdateModel:i,onUpdateOpusModel:u,onUpdateSonnetModel:h,onUpdateHaikuModel:x}){return e.jsx(X,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(J,{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(Ae,{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(b,{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:Xe.map(n=>e.jsxs(v,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>l(n),title:n.description,children:[e.jsx(ae,{className:"w-3 h-3 text-green-600"}),n.name]},n.name))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(b,{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:Ze.map(n=>e.jsxs(v,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>l(n),title:n.description,children:[e.jsx(ae,{className:"w-3 h-3"}),n.name]},n.name))})]})]}),e.jsx(W,{}),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:"space-y-4",children:[e.jsx(D,{label:"Default Model",description:"Used when no specific tier is requested",value:s,onChange:i,models:a,disabled:d}),e.jsx(D,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:t||s,onChange:u,models:a,disabled:d}),e.jsx(D,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:o||s,onChange:h,models:a,disabled:d}),e.jsx(D,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:c||s,onChange:x,models:a,disabled:d})]})]})]})})})}function ts({enabled:s,autoStart:t,port:o,accountType:c,rateLimit:a,waitOnLimit:d,onUpdateEnabled:l,onUpdateAutoStart:i,onUpdatePort:u,onUpdateAccountType:h,onUpdateRateLimit:x,onUpdateWaitOnLimit:n}){return e.jsx(X,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(J,{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(C,{htmlFor:"enabled",className:"text-sm font-medium",children:"Enable Copilot"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Allow using GitHub Copilot subscription"})]}),e.jsx(H,{id:"enabled",checked:s,onCheckedChange:l})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Basic Settings"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"port",className:"text-xs",children:"Port"}),e.jsx(te,{id:"port",type:"number",value:o,onChange:N=>u(parseInt(N.target.value,10)),min:1024,max:65535,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"account-type",className:"text-xs",children:"Account Type"}),e.jsxs(le,{value:c,onValueChange:h,children:[e.jsx(re,{id:"account-type",className:"max-w-[150px] h-8",children:e.jsx(ce,{})}),e.jsxs(de,{children:[e.jsx(Q,{value:"individual",children:"Individual"}),e.jsx(Q,{value:"business",children:"Business"}),e.jsx(Q,{value:"enterprise",children:"Enterprise"})]})]})]})]}),e.jsx(W,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Rate Limiting"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"rate-limit",className:"text-xs",children:"Rate Limit (seconds)"}),e.jsx(te,{id:"rate-limit",type:"number",value:a,onChange:N=>x(N.target.value),placeholder:"No limit",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(C,{htmlFor:"wait-on-limit",className:"text-xs",children:"Wait on Rate Limit"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Wait instead of error when limit hit"})]}),e.jsx(H,{id:"wait-on-limit",checked:d,onCheckedChange:n})]})]}),e.jsx(W,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Daemon Settings"}),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(C,{htmlFor:"auto-start",className:"text-xs",children:"Auto-start Daemon"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Start copilot-api when using profile"})]}),e.jsx(H,{id:"auto-start",checked:t,onCheckedChange:i})]})]})]})})})}function U({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(ue,{value:t,size:"icon",className:"h-6 w-6"})]})]})}function as({rawSettings:s}){return e.jsx(X,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(J,{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(Le,{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"})]}),s&&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:s.path}),e.jsx(ue,{value:s.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(b,{variant:"outline",className:s.exists?"w-fit text-green-600 border-green-200 bg-green-50":"w-fit text-muted-foreground",children:s.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(U,{label:"Run with Copilot",command:"ccs copilot"}),e.jsx(U,{label:"Authenticate",command:"ccs copilot auth"}),e.jsx(U,{label:"Start daemon",command:"ccs copilot --start"}),e.jsx(U,{label:"Stop daemon",command:"ccs copilot --stop"})]})]})]})})})}const ns=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function oe(s){const t=s?.env||{};return ns.filter(o=>!t[o]?.trim())}function is(){const{config:s,configLoading:t,models:o,modelsLoading:c,rawSettings:a,rawSettingsLoading:d,updateConfigAsync:l,isUpdating:i,saveRawSettingsAsync:u,isSavingRawSettings:h,refetchRawSettings:x}=fe(),[n,N]=j.useState({}),[f,k]=j.useState(null),[$,L]=j.useState(!1),R=n.enabled??s?.enabled??!1,T=n.autoStart??s?.auto_start??!1,F=n.port??s?.port??4141,E=n.accountType??s?.account_type??"individual",O=n.model??s?.model??"claude-sonnet-4-5-20250929",p=n.rateLimit??s?.rate_limit?.toString()??"",_=n.waitOnLimit??s?.wait_on_limit??!0,I=n.opusModel??s?.opus_model??"",q=n.sonnetModel??s?.sonnet_model??"",P=n.haikuModel??s?.haiku_model??"",B=(m,w)=>{N(ve=>({...ve,[m]:w}))},G=m=>{N(w=>({...w,model:m.default,opusModel:m.opus,sonnetModel:m.sonnet,haikuModel:m.haiku})),A.success(`Applied "${m.name}" preset`)},r=j.useMemo(()=>f!==null?f:a?.settings?JSON.stringify(a.settings,null,2):`{
1
+ import{j as e}from"./radix-ui-qEZD5MMp.js";import{B as b,b as v,X as le,Y as re,Z as ce,_ as de,ak as we,al as ye,$ as Q,M as X,m as J,L as C,I as te,q as ue,S as y,H as be,J as Ce,K as z,aP as Se,c as Y}from"./index-Dv5jtphl.js";import{r as j}from"./react-vendor-CNOkPC89.js";import{a as ke,u as M,b as S}from"./tanstack-De4wvi8X.js";import{C as Fe}from"./confirm-dialog-D7hNt3ez.js";import{R as me,L as xe,ah as Pe,j as Me,a0 as Ae,Z as ae,I as Le,ak as Re,a as Te,T as Ee,a4 as Oe,ao as _e,av as ne,K as Ie,x as qe,aw as De,q as he,r as pe}from"./icons-DGASzt3M.js";import{S as W}from"./separator-DrDw3JjB.js";import{S as H}from"./switch-C0ri2ChT.js";import{t as A}from"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-B5t_5_UL.js";const g="/api";async function Ue(){const s=await fetch(`${g}/copilot/status`);if(!s.ok)throw new Error("Failed to fetch copilot status");return s.json()}async function Ke(){const s=await fetch(`${g}/copilot/config`);if(!s.ok)throw new Error("Failed to fetch copilot config");return s.json()}async function Qe(){const s=await fetch(`${g}/copilot/models`);if(!s.ok)throw new Error("Failed to fetch copilot models");return s.json()}async function Je(){const s=await fetch(`${g}/copilot/settings/raw`);if(!s.ok)throw new Error("Failed to fetch copilot raw settings");return s.json()}async function $e(s){const t=await fetch(`${g}/copilot/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok)throw new Error("Failed to update copilot config");return t.json()}async function Be(s){const t=await fetch(`${g}/copilot/settings/raw`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(t.status===409)throw new Error("CONFLICT");if(!t.ok)throw new Error("Failed to save copilot raw settings");return t.json()}async function Ge(){const s=await fetch(`${g}/copilot/auth/start`,{method:"POST"});if(!s.ok)throw new Error("Failed to start auth");return s.json()}async function ze(){const s=await fetch(`${g}/copilot/daemon/start`,{method:"POST"});if(!s.ok)throw new Error("Failed to start daemon");return s.json()}async function He(){const s=await fetch(`${g}/copilot/daemon/stop`,{method:"POST"});if(!s.ok)throw new Error("Failed to stop daemon");return s.json()}async function Ve(){const s=await fetch(`${g}/copilot/info`);if(!s.ok)throw new Error("Failed to fetch copilot info");return s.json()}async function Ye(s){const t=await fetch(`${g}/copilot/install`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s?{version:s}:{})});if(!t.ok)throw new Error("Failed to install copilot-api");return t.json()}function fe(){const s=ke(),t=M({queryKey:["copilot-status"],queryFn:Ue,refetchInterval:5e3}),o=M({queryKey:["copilot-config"],queryFn:Ke}),c=M({queryKey:["copilot-models"],queryFn:Qe}),a=M({queryKey:["copilot-raw-settings"],queryFn:Je}),d=M({queryKey:["copilot-info"],queryFn:Ve}),l=S({mutationFn:$e,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]}),s.invalidateQueries({queryKey:["copilot-config"]}),s.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),i=S({mutationFn:Be,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]}),s.invalidateQueries({queryKey:["copilot-config"]}),s.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),u=S({mutationFn:Ge,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]})}}),h=S({mutationFn:ze,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]})}}),x=S({mutationFn:He,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]})}}),n=S({mutationFn:Ye,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]}),s.invalidateQueries({queryKey:["copilot-info"]})}});return j.useMemo(()=>({status:t.data,statusLoading:t.isLoading,statusError:t.error,refetchStatus:t.refetch,config:o.data,configLoading:o.isLoading,models:c.data?.models??[],currentModel:c.data?.current,modelsLoading:c.isLoading,rawSettings:a.data,rawSettingsLoading:a.isLoading,refetchRawSettings:a.refetch,updateConfig:l.mutate,updateConfigAsync:l.mutateAsync,isUpdating:l.isPending,saveRawSettings:i.mutate,saveRawSettingsAsync:i.mutateAsync,isSavingRawSettings:i.isPending,startAuth:u.mutate,startAuthAsync:u.mutateAsync,isAuthenticating:u.isPending,authResult:u.data,startDaemon:h.mutate,isStartingDaemon:h.isPending,stopDaemon:x.mutate,isStoppingDaemon:x.isPending,info:d.data,infoLoading:d.isLoading,refetchInfo:d.refetch,install:n.mutate,installAsync:n.mutateAsync,isInstalling:n.isPending}),[t.data,t.isLoading,t.error,t.refetch,o.data,o.isLoading,c.data,c.isLoading,a.data,a.isLoading,a.refetch,l.mutate,l.mutateAsync,l.isPending,i.mutate,i.mutateAsync,i.isPending,u.mutate,u.mutateAsync,u.isPending,u.data,h.mutate,h.isPending,x.mutate,x.isPending,d.data,d.isLoading,d.refetch,n.mutate,n.mutateAsync,n.isPending])}function We({rawSettings:s,rawSettingsLoading:t,isUpdating:o,isSavingRawSettings:c,hasChanges:a,isRawJsonValid:d,onRefresh:l,onSave:i}){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"}),s&&e.jsx(b,{variant:"outline",className:"text-xs",children:"copilot.settings.json"})]}),s&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified:"," ",s.exists?new Date(s.mtime).toLocaleString():"Never saved"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{variant:"ghost",size:"sm",onClick:l,disabled:t,children:e.jsx(me,{className:`w-4 h-4 ${t?"animate-spin":""}`})}),e.jsx(v,{size:"sm",onClick:i,disabled:o||c||!a||!d,children:o||c?e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Pe,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}const Xe=[{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"},{name:"Raptor Mini (Free)",description:"Free tier - fine-tuned for coding",default:"raptor-mini",opus:"raptor-mini",sonnet:"raptor-mini",haiku:"raptor-mini"}],Ze=[{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 ie(s){switch(s){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 es(s){return s==null?null:s===0?"Free":s<1?`${s}x`:s===1?"1x":`${s}x`}function D({label:s,description:t,value:o,onChange:c,models:a,disabled:d}){const l=a.find(i=>i.id===o);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.jsxs(le,{value:o||"",onValueChange:c,disabled:d,children:[e.jsx(re,{className:"h-9",children:e.jsx(ce,{placeholder:"Select model",children:o&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:o}),l?.minPlan&&e.jsx(b,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ie(l.minPlan)}`,children:l.minPlan})]})})}),e.jsx(de,{className:"max-h-[300px]",children:e.jsxs(we,{children:[e.jsxs(ye,{className:"text-xs text-muted-foreground",children:["Available Models (",a.length,")"]}),a.map(i=>e.jsx(Q,{value:i.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:i.name||i.id}),i.minPlan&&e.jsx(b,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ie(i.minPlan)}`,children:i.minPlan}),i.multiplier!==void 0&&e.jsx("span",{className:"text-[9px] text-muted-foreground",children:es(i.multiplier)}),i.preview&&e.jsx(b,{variant:"secondary",className:"text-[9px] px-1 py-0 h-4",children:"Preview"}),o===i.id&&e.jsx(Me,{className:"w-3 h-3 text-primary ml-auto"})]})},i.id))]})})]})]})}function ss({currentModel:s,opusModel:t,sonnetModel:o,haikuModel:c,models:a,modelsLoading:d,onApplyPreset:l,onUpdateModel:i,onUpdateOpusModel:u,onUpdateSonnetModel:h,onUpdateHaikuModel:x}){return e.jsx(X,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(J,{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(Ae,{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(b,{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:Xe.map(n=>e.jsxs(v,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>l(n),title:n.description,children:[e.jsx(ae,{className:"w-3 h-3 text-green-600"}),n.name]},n.name))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(b,{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:Ze.map(n=>e.jsxs(v,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>l(n),title:n.description,children:[e.jsx(ae,{className:"w-3 h-3"}),n.name]},n.name))})]})]}),e.jsx(W,{}),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:"space-y-4",children:[e.jsx(D,{label:"Default Model",description:"Used when no specific tier is requested",value:s,onChange:i,models:a,disabled:d}),e.jsx(D,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:t||s,onChange:u,models:a,disabled:d}),e.jsx(D,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:o||s,onChange:h,models:a,disabled:d}),e.jsx(D,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:c||s,onChange:x,models:a,disabled:d})]})]})]})})})}function ts({enabled:s,autoStart:t,port:o,accountType:c,rateLimit:a,waitOnLimit:d,onUpdateEnabled:l,onUpdateAutoStart:i,onUpdatePort:u,onUpdateAccountType:h,onUpdateRateLimit:x,onUpdateWaitOnLimit:n}){return e.jsx(X,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(J,{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(C,{htmlFor:"enabled",className:"text-sm font-medium",children:"Enable Copilot"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Allow using GitHub Copilot subscription"})]}),e.jsx(H,{id:"enabled",checked:s,onCheckedChange:l})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Basic Settings"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"port",className:"text-xs",children:"Port"}),e.jsx(te,{id:"port",type:"number",value:o,onChange:N=>u(parseInt(N.target.value,10)),min:1024,max:65535,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"account-type",className:"text-xs",children:"Account Type"}),e.jsxs(le,{value:c,onValueChange:h,children:[e.jsx(re,{id:"account-type",className:"max-w-[150px] h-8",children:e.jsx(ce,{})}),e.jsxs(de,{children:[e.jsx(Q,{value:"individual",children:"Individual"}),e.jsx(Q,{value:"business",children:"Business"}),e.jsx(Q,{value:"enterprise",children:"Enterprise"})]})]})]})]}),e.jsx(W,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Rate Limiting"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"rate-limit",className:"text-xs",children:"Rate Limit (seconds)"}),e.jsx(te,{id:"rate-limit",type:"number",value:a,onChange:N=>x(N.target.value),placeholder:"No limit",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(C,{htmlFor:"wait-on-limit",className:"text-xs",children:"Wait on Rate Limit"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Wait instead of error when limit hit"})]}),e.jsx(H,{id:"wait-on-limit",checked:d,onCheckedChange:n})]})]}),e.jsx(W,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Daemon Settings"}),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(C,{htmlFor:"auto-start",className:"text-xs",children:"Auto-start Daemon"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Start copilot-api when using profile"})]}),e.jsx(H,{id:"auto-start",checked:t,onCheckedChange:i})]})]})]})})})}function U({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(ue,{value:t,size:"icon",className:"h-6 w-6"})]})]})}function as({rawSettings:s}){return e.jsx(X,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(J,{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(Le,{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"})]}),s&&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:s.path}),e.jsx(ue,{value:s.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(b,{variant:"outline",className:s.exists?"w-fit text-green-600 border-green-200 bg-green-50":"w-fit text-muted-foreground",children:s.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(U,{label:"Run with Copilot",command:"ccs copilot"}),e.jsx(U,{label:"Authenticate",command:"ccs copilot auth"}),e.jsx(U,{label:"Start daemon",command:"ccs copilot --start"}),e.jsx(U,{label:"Stop daemon",command:"ccs copilot --stop"})]})]})]})})})}const ns=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function oe(s){const t=s?.env||{};return ns.filter(o=>!t[o]?.trim())}function is(){const{config:s,configLoading:t,models:o,modelsLoading:c,rawSettings:a,rawSettingsLoading:d,updateConfigAsync:l,isUpdating:i,saveRawSettingsAsync:u,isSavingRawSettings:h,refetchRawSettings:x}=fe(),[n,N]=j.useState({}),[f,k]=j.useState(null),[$,L]=j.useState(!1),R=n.enabled??s?.enabled??!1,T=n.autoStart??s?.auto_start??!1,F=n.port??s?.port??4141,E=n.accountType??s?.account_type??"individual",O=n.model??s?.model??"claude-sonnet-4-5-20250929",p=n.rateLimit??s?.rate_limit?.toString()??"",_=n.waitOnLimit??s?.wait_on_limit??!0,I=n.opusModel??s?.opus_model??"",q=n.sonnetModel??s?.sonnet_model??"",P=n.haikuModel??s?.haiku_model??"",B=(m,w)=>{N(ve=>({...ve,[m]:w}))},G=m=>{N(w=>({...w,model:m.default,opusModel:m.opus,sonnetModel:m.sonnet,haikuModel:m.haiku})),A.success(`Applied "${m.name}" preset`)},r=j.useMemo(()=>f!==null?f:a?.settings?JSON.stringify(a.settings,null,2):`{
2
2
  "env": {}
3
3
  }`,[f,a]),ge=j.useCallback(m=>{k(m)},[]),Z=j.useMemo(()=>{try{return JSON.parse(r),!0}catch{return!1}},[r]),je=j.useMemo(()=>{const m=Object.keys(n).length>0,w=f!==null&&f!==JSON.stringify(a?.settings,null,2);return m||w},[n,f,a]),ee=j.useMemo(()=>{if(f!==null)try{return JSON.parse(f)}catch{return a?.settings}return a?.settings},[f,a?.settings]),Ne=j.useMemo(()=>oe(ee),[ee]),se=async()=>{try{if(Object.keys(n).length>0&&await l({enabled:R,auto_start:T,port:F,account_type:E,model:O,rate_limit:p?parseInt(p,10):null,wait_on_limit:_,opus_model:I||void 0,sonnet_model:q||void 0,haiku_model:P||void 0}),f!==null&&Z){const m=JSON.parse(r),w=oe(m);await u({settings:m,expectedMtime:a?.mtime}),w.length>0?A.success("Copilot configuration saved",{description:`Missing fields will use defaults: ${w.join(", ")}`}):A.success("Copilot configuration saved")}else A.success("Copilot configuration saved");N({}),k(null)}catch(m){m.message==="CONFLICT"?L(!0):A.error("Failed to save settings")}};return{configLoading:t,rawSettingsLoading:d,modelsLoading:c,isUpdating:i,isSavingRawSettings:h,models:o,rawSettings:a,rawJsonContent:r,rawJsonEdits:f,enabled:R,autoStart:T,port:F,accountType:E,currentModel:O,rateLimit:p,waitOnLimit:_,opusModel:I,sonnetModel:q,haikuModel:P,isRawJsonValid:Z,hasChanges:je,conflictDialog:$,updateField:B,applyPreset:G,handleRawJsonChange:ge,handleSave:se,handleConflictResolve:async m=>{L(!1),m?(await x(),se()):k(null)},refetchRawSettings:x,missingRequiredFields:Ne}}function os(){const{configLoading:s,rawSettingsLoading:t,modelsLoading:o,isUpdating:c,isSavingRawSettings:a,models:d,rawSettings:l,rawJsonContent:i,rawJsonEdits:u,enabled:h,autoStart:x,port:n,accountType:N,currentModel:f,rateLimit:k,waitOnLimit:$,opusModel:L,sonnetModel:R,haikuModel:T,isRawJsonValid:F,hasChanges:E,conflictDialog:O,updateField:p,applyPreset:_,handleRawJsonChange:I,handleSave:q,handleConflictResolve:P,refetchRawSettings:B,missingRequiredFields:G}=is();return s||t?e.jsxs("div",{className:"space-y-6",children:[e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"})]}):e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(We,{rawSettings:l,rawSettingsLoading:t,isUpdating:c,isSavingRawSettings:a,hasChanges:E,isRawJsonValid:F,onRefresh:()=>B(),onSave:q}),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(be,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Ce,{className:"w-full",children:[e.jsx(z,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(z,{value:"settings",className:"flex-1",children:"Settings"}),e.jsx(z,{value:"info",className:"flex-1",children:"Info"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(ss,{currentModel:f,opusModel:L,sonnetModel:R,haikuModel:T,models:d,modelsLoading:o,onApplyPreset:_,onUpdateModel:r=>p("model",r),onUpdateOpusModel:r=>p("opusModel",r),onUpdateSonnetModel:r=>p("sonnetModel",r),onUpdateHaikuModel:r=>p("haikuModel",r)}),e.jsx(ts,{enabled:h,autoStart:x,port:n,accountType:N,rateLimit:k,waitOnLimit:$,onUpdateEnabled:r=>p("enabled",r),onUpdateAutoStart:r=>p("autoStart",r),onUpdatePort:r=>p("port",r),onUpdateAccountType:r=>p("accountType",r),onUpdateRateLimit:r=>p("rateLimit",r),onUpdateWaitOnLimit:r=>p("waitOnLimit",r)}),e.jsx(as,{rawSettings:l})]})]})})}),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(Re,{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(Se,{rawJsonContent:i,isRawJsonValid:F,rawJsonEdits:u,rawSettingsEnv:l?.settings?.env,onChange:I,missingRequiredFields:G})]})]}),e.jsx(Fe,{open:O,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>P(!0),onCancel:()=>P(!1)})]})}function V({title:s,children:t}){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:s}),e.jsx("div",{className:"space-y-1",children:t})]})}function K({icon:s,label:t,status:o,statusText:c,variant:a="default"}){return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg bg-muted/50",children:[e.jsx(s,{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:t})}),e.jsx("div",{className:"flex items-center gap-1.5",children:o?e.jsxs(e.Fragment,{children:[e.jsx(he,{className:Y("w-4 h-4",a==="warning"?"text-yellow-500":"text-green-500")}),e.jsx("span",{className:Y("text-xs",a==="warning"?"text-yellow-500":"text-green-500"),children:c||"Yes"})]}):e.jsxs(e.Fragment,{children:[e.jsx(pe,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:c||"No"})]})})]})}function ls(){return e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsx(y,{className:"h-8 w-full"}),e.jsx(y,{className:"h-12 w-full"}),e.jsx(y,{className:"h-12 w-full"}),e.jsx(y,{className:"h-12 w-full"})]})}function ys(){const{status:s,statusLoading:t,refetchStatus:o,startAuth:c,isAuthenticating:a,startDaemon:d,isStartingDaemon:l,stopDaemon:i,isStoppingDaemon:u,install:h,isInstalling:x}=fe();return e.jsxs("div",{className:"h-[calc(100vh-100px)] flex",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30 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(Te,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:"Copilot"})]}),e.jsx(v,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>o(),disabled:t,children:e.jsx(me,{className:Y("w-4 h-4",t&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"GitHub Copilot proxy"})]}),e.jsx(J,{className:"flex-1",children:t?e.jsx(ls,{}):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(Ee,{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:"Unofficial API - Use at Your Own Risk"})]}),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:"Reverse-engineered API - may break anytime"}),e.jsx("li",{children:"Excessive use may trigger account restrictions"}),e.jsx("li",{children:"No warranty, no responsibility from CCS"})]})]}),e.jsxs(V,{title:"Setup",children:[e.jsx(K,{icon:Oe,label:"copilot-api",status:s?.installed??!1,statusText:s?.installed?s.version?`v${s.version}`:"Installed":"Missing"}),!s?.installed&&e.jsx(v,{size:"sm",className:"w-full mt-2",onClick:()=>h(void 0),disabled:x,children:x?e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}),"Installing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(_e,{className:"w-3.5 h-3.5 mr-1.5"}),"Install copilot-api"]})}),s?.installed&&e.jsx(K,{icon:ne,label:"Integration",status:s?.enabled??!1,statusText:s?.enabled?"Enabled":"Disabled"})]}),s?.installed&&e.jsxs(V,{title:"Auth",children:[e.jsx(K,{icon:Ie,label:"GitHub",status:s?.authenticated??!1,statusText:s?.authenticated?"Connected":"Not Connected"}),!s?.authenticated&&e.jsx(v,{size:"sm",className:"w-full mt-2",onClick:()=>c(),disabled:a,children:a?"Authenticating...":"Authenticate"})]}),s?.authenticated&&e.jsxs(V,{title:"Daemon",children:[e.jsx(K,{icon:qe,label:"Status",status:s?.daemon_running??!1,statusText:s?.daemon_running?"Running":"Stopped"}),e.jsxs("div",{className:"px-3 py-1 text-xs text-muted-foreground",children:["Port: ",s?.port??4141]}),e.jsx("div",{className:"px-1",children:s?.daemon_running?e.jsxs(v,{size:"sm",variant:"outline",className:"w-full",onClick:()=>i(),disabled:u,children:[e.jsx(De,{className:"w-3.5 h-3.5 mr-1.5"}),u?"Stopping...":"Stop"]}):e.jsxs(v,{size:"sm",variant:"outline",className:"w-full",onClick:()=>d(),disabled:l,children:[e.jsx(ne,{className:"w-3.5 h-3.5 mr-1.5"}),l?"Starting...":"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:"Proxy"}),s?.daemon_running?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(he,{className:"w-3 h-3 text-green-500"}),"Active"]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(pe,{className:"w-3 h-3 text-muted-foreground"}),"Inactive"]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:e.jsx(os,{})})]})}export{ys as CopilotPage};
@@ -0,0 +1 @@
1
+ import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as p}from"./react-vendor-CNOkPC89.js";import{t as o}from"./notifications-B2HqRBj7.js";import{B as _,b as f,c as ie,m as E,H as Ve,J as Xe,K as W,M as ee,L as P,I as se,aP as Ze,a4 as Ye,a5 as We,a6 as es,a7 as ss,a8 as ts,am as as,X as ns,Y as rs,Z as is,_ as os,ak as ls,al as cs,$ as be}from"./index-Dv5jtphl.js";import{a as ds,u as q,b as D}from"./tanstack-De4wvi8X.js";import{S as Ce}from"./switch-C0ri2ChT.js";import{S as us}from"./separator-DrDw3JjB.js";import{R as Se,T as ms,ax as hs,K as G,a4 as xs,aw as ke,av as fs,L as M,s as ps,ah as gs,a0 as js,Z as te,ak as ws,q as vs,r as Ns}from"./icons-DGASzt3M.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";const v="/api";async function ys(){const s=await fetch(`${v}/cursor/status`);if(!s.ok)throw new Error("Failed to fetch cursor status");return s.json()}async function bs(){const s=await fetch(`${v}/cursor/settings`);if(!s.ok)throw new Error("Failed to fetch cursor config");return s.json()}async function Cs(){const s=await fetch(`${v}/cursor/models`);if(!s.ok)throw new Error("Failed to fetch cursor models");return s.json()}async function Ss(){const s=await fetch(`${v}/cursor/settings/raw`);if(!s.ok)throw new Error("Failed to fetch cursor raw settings");return s.json()}async function ks(s){const a=await fetch(`${v}/cursor/settings`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok)throw new Error("Failed to update cursor config");return a.json()}async function As(s){const a=await fetch(`${v}/cursor/settings/raw`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(a.status===409)throw new Error("CONFLICT");if(!a.ok)throw new Error("Failed to save cursor raw settings");return a.json()}async function _s(){const s=await fetch(`${v}/cursor/auth/auto-detect`,{method:"POST"});if(!s.ok){const a=await s.json().catch(()=>({error:"Auto-detect failed"}));throw new Error(a.error||"Auto-detect failed")}return s.json()}async function Ds(s){const a=await fetch(`${v}/cursor/auth/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok){const c=await a.json().catch(()=>({error:"Manual import failed"}));throw new Error(c.error||"Manual import failed")}return a.json()}async function Ms(){const s=await fetch(`${v}/cursor/daemon/start`,{method:"POST"});if(!s.ok)throw new Error("Failed to start cursor daemon");return s.json()}async function Ps(){const s=await fetch(`${v}/cursor/daemon/stop`,{method:"POST"});if(!s.ok)throw new Error("Failed to stop cursor daemon");return s.json()}function Ts(){const s=ds(),a=q({queryKey:["cursor-status"],queryFn:ys,refetchInterval:5e3}),c=q({queryKey:["cursor-config"],queryFn:bs}),d=q({queryKey:["cursor-models"],queryFn:Cs}),h=q({queryKey:["cursor-raw-settings"],queryFn:Ss}),l=()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-config"]}),s.invalidateQueries({queryKey:["cursor-models"]}),s.invalidateQueries({queryKey:["cursor-raw-settings"]})},n=D({mutationFn:ks,onSuccess:l}),m=D({mutationFn:As,onSuccess:l}),x=D({mutationFn:_s,onSuccess:l}),i=D({mutationFn:Ds,onSuccess:l}),N=D({mutationFn:Ms,onSuccess:l}),C=D({mutationFn:Ps,onSuccess:l});return p.useMemo(()=>({status:a.data,statusLoading:a.isLoading,statusError:a.error,refetchStatus:a.refetch,config:c.data,configLoading:c.isLoading,models:d.data?.models??[],currentModel:d.data?.current??null,modelsLoading:d.isLoading,rawSettings:h.data,rawSettingsLoading:h.isLoading,refetchRawSettings:h.refetch,updateConfig:n.mutate,updateConfigAsync:n.mutateAsync,isUpdatingConfig:n.isPending,saveRawSettings:m.mutate,saveRawSettingsAsync:m.mutateAsync,isSavingRawSettings:m.isPending,autoDetectAuth:x.mutate,autoDetectAuthAsync:x.mutateAsync,isAutoDetectingAuth:x.isPending,autoDetectAuthResult:x.data,importManualAuth:i.mutate,importManualAuthAsync:i.mutateAsync,isImportingManualAuth:i.isPending,manualAuthResult:i.data,startDaemon:N.mutate,startDaemonAsync:N.mutateAsync,isStartingDaemon:N.isPending,stopDaemon:C.mutate,stopDaemonAsync:C.mutateAsync,isStoppingDaemon:C.isPending}),[a.data,a.isLoading,a.error,a.refetch,c.data,c.isLoading,d.data,d.isLoading,h.data,h.isLoading,h.refetch,n.mutate,n.mutateAsync,n.isPending,m.mutate,m.mutateAsync,m.isPending,x.mutate,x.mutateAsync,x.isPending,x.data,i.mutate,i.mutateAsync,i.isPending,i.data,N.mutate,N.mutateAsync,N.isPending,C.mutate,C.mutateAsync,C.isPending])}function ae(s){return{port:String(s?.port??20129),auto_start:s?.auto_start??!1,ghost_mode:s?.ghost_mode??!0,model:s?.model?.trim()||"gpt-5.3-codex",opus_model:s?.opus_model?.trim()||"",sonnet_model:s?.sonnet_model?.trim()||"",haiku_model:s?.haiku_model?.trim()||""}}function y(s,a,c){return s.find(h=>a.some(l=>l.test(h.id)))?.id??c}function ne(s){return s.toLowerCase().replace(/[^a-z0-9]/g,"")}function b(s,a,c){const d=new Set(a.map(ne)),h=s.find(n=>d.has(ne(n.id)));if(h)return h.id;const l=s.find(n=>d.has(ne(n.name)));return l?l.id:c}function Fs(s){try{const a=JSON.parse(s||"{}");return!a||typeof a!="object"||Array.isArray(a)?{isValid:!1,error:"Raw settings must be a JSON object"}:{isValid:!0,settings:a}}catch(a){return{isValid:!1,error:a.message||"Invalid JSON"}}}function z({label:s,description:a,value:c,models:d,disabled:h,allowDefaultFallback:l=!1,onChange:n}){const m=c||(l?"__default":""),x=d.find(i=>i.id===c);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx(P,{className:"text-xs font-medium",children:s}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a})]}),e.jsxs(ns,{value:m,onValueChange:i=>{if(l&&i==="__default"){n("");return}n(i)},disabled:h,children:[e.jsx(rs,{className:"h-9",children:e.jsx(is,{placeholder:"Select model",children:m&&e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:l&&m==="__default"?"Use Default Model":x?.name||m}),x?.provider&&e.jsx(_,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:x.provider})]})})}),e.jsx(os,{className:"max-h-[300px]",children:e.jsxs(ls,{children:[e.jsxs(cs,{className:"text-xs text-muted-foreground",children:["Available Models (",d.length,")"]}),l&&e.jsx(be,{value:"__default",children:"Use Default Model"}),d.map(i=>e.jsx(be,{value:i.id,children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"truncate text-xs font-mono",children:i.name||i.id}),e.jsx(_,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:i.provider})]})},i.id))]})})]})]})}function re({icon:s,label:a,ok:c,detail:d}){return e.jsxs("div",{className:"flex items-center gap-3 rounded-lg bg-muted/50 px-3 py-2",children:[e.jsx(s,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"text-sm",children:a})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[c?e.jsx(vs,{className:"h-4 w-4 text-green-500"}):e.jsx(Ns,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:ie("text-xs",c?"text-green-500":"text-muted-foreground"),title:d,children:d})]})]})}function Ks(){const{status:s,statusLoading:a,refetchStatus:c,config:d,updateConfigAsync:h,isUpdatingConfig:l,models:n,modelsLoading:m,currentModel:x,rawSettings:i,rawSettingsLoading:N,refetchRawSettings:C,saveRawSettingsAsync:Ae,isSavingRawSettings:oe,autoDetectAuthAsync:_e,isAutoDetectingAuth:le,importManualAuthAsync:De,isImportingManualAuth:ce,startDaemonAsync:Me,isStartingDaemon:Pe,stopDaemonAsync:Te,isStoppingDaemon:de}=Ts(),[A,ue]=p.useState(()=>ae()),[g,me]=p.useState(!1),[he,Fe]=p.useState("{}"),[T,U]=p.useState(!1),[Re,I]=p.useState(!1),[B,xe]=p.useState(""),[J,fe]=p.useState(""),S=ae(d),pe=g?A.port:S.port,K=g?A.auto_start:S.auto_start,$=g?A.ghost_mode:S.ghost_mode,j=g?A.model:S.model,H=g?A.opus_model:S.opus_model,Q=g?A.sonnet_model:S.sonnet_model,V=g?A.haiku_model:S.haiku_model,X=T?he:JSON.stringify(i?.settings??{},null,2),ge=!!i,F=p.useMemo(()=>Fs(X),[X]),je=F.isValid,we=g||T,Ie=!T||ge&&je,L=p.useMemo(()=>{const t=new Set,r=[...n].sort((k,Y)=>k.name.localeCompare(Y.name)),u=r.filter(k=>t.has(k.id)?!1:(t.add(k.id),!0));return j&&!r.some(k=>k.id===j)?[{id:j,name:j,provider:"custom"},...u]:u},[n,j]),w=t=>{ue(r=>t(g?r:S)),me(!0)},Le=!!(s?.enabled&&s?.authenticated&&!s?.token_expired),Oe=p.useMemo(()=>s?.enabled?e.jsx(_,{children:"Enabled"}):e.jsx(_,{variant:"secondary",children:"Disabled"}),[s?.enabled]),Ee=async({suppressSuccessToast:t=!1}={})=>{const r=Number(pe);if(!Number.isInteger(r)||r<1||r>65535)return o.error("Port must be an integer between 1 and 65535"),!1;if(!j.trim())return o.error("Default model is required"),!1;try{return await h({port:r,auto_start:K,ghost_mode:$,model:j,opus_model:H||void 0,sonnet_model:Q||void 0,haiku_model:V||void 0}),me(!1),ue(ae({port:r,auto_start:K,ghost_mode:$,model:j,opus_model:H||void 0,sonnet_model:Q||void 0,haiku_model:V||void 0})),t||o.success("Cursor config and model mapping saved"),!0}catch(u){return o.error(u.message||"Failed to save config"),!1}},Z=t=>{const r=j||x||n[0]?.id||"gpt-5.3-codex",u=b(n,["gpt-5.3-codex","gpt53codex","GPT-5.3 Codex"],y(n,[/gpt[-.]?5.*codex/i],r)),k=b(n,["gpt-5.1-codex-max","gpt51codexmax","GPT-5.1 Codex Max"],y(n,[/gpt[-.]?5.*codex.*max/i],u)),Y=b(n,["gpt-5-fast","gpt5fast","GPT-5 Fast"],y(n,[/gpt[-.]?5.*fast/i],u)),$e=b(n,["gpt-5-mini","gpt5mini","GPT-5 Mini"],y(n,[/gpt[-.]?5.*mini/i],Y)),Ne=b(n,["claude-4.6-opus","claude46opus","Claude 4.6 Opus"],y(n,[/claude[-.]?4\.?6.*opus/i,/claude.*opus/i],u)),ye=b(n,["claude-4.5-sonnet","claude45sonnet","Claude 4.5 Sonnet"],y(n,[/claude[-.]?4\.?5.*sonnet/i,/claude.*sonnet/i],u)),He=b(n,["claude-4.5-haiku","claude45haiku","Claude 4.5 Haiku"],y(n,[/claude[-.]?4\.?5.*haiku/i,/haiku/i],ye)),O=b(n,["gemini-3-pro","gemini3pro","Gemini 3 Pro"],y(n,[/gemini[-.]?3.*pro/i],u)),Qe=b(n,["gemini-3-flash","gemini3flash","Gemini 3 Flash"],y(n,[/gemini[-.]?3.*flash/i,/gemini[-.]?2\.?5.*flash/i],O));if(t==="codex53"){w(R=>({...R,model:u,opus_model:k,sonnet_model:u,haiku_model:$e})),o.success("Applied GPT-5.3 Codex preset");return}if(t==="claude46"){w(R=>({...R,model:Ne,opus_model:Ne,sonnet_model:ye,haiku_model:He})),o.success("Applied Claude 4.6 preset");return}w(R=>({...R,model:O,opus_model:O,sonnet_model:O,haiku_model:Qe})),o.success("Applied Gemini 3 preset")},ve=async t=>{try{await h({enabled:t}),o.success(t?"Cursor integration enabled":"Cursor integration disabled")}catch(r){o.error(r.message||"Failed to update integration state")}},qe=async()=>{try{await _e(),o.success("Cursor credentials imported")}catch(t){o.error(t.message||"Auto-detect failed")}},Ge=async()=>{if(!B.trim()||!J.trim()){o.error("Token and machine ID are required");return}try{await De({accessToken:B.trim(),machineId:J.trim()}),o.success("Cursor credentials imported"),I(!1),xe(""),fe("")}catch(t){o.error(t.message||"Manual import failed")}},ze=async()=>{try{const t=await Me();if(!t.success){o.error(t.error||"Failed to start daemon");return}o.success(`Daemon started${t.pid?` (PID: ${t.pid})`:""}`)}catch(t){o.error(t.message||"Failed to start daemon")}},Ue=async()=>{try{const t=await Te();if(!t.success){o.error(t.error||"Failed to stop daemon");return}o.success("Daemon stopped")}catch(t){o.error(t.message||"Failed to stop daemon")}},Be=async({suppressSuccessToast:t=!1}={})=>{if(!ge)return o.error("Raw settings are still loading. Please wait and try again."),!1;if(!F.isValid||!F.settings)return o.error(F.error||"Invalid JSON"),!1;try{return await Ae({settings:F.settings,expectedMtime:i?.mtime}),U(!1),t||o.success("Raw settings saved"),!0}catch(r){const u=r.message||"Failed to save raw settings";return u==="CONFLICT"?o.error("Raw settings changed externally. Refresh and retry."):o.error(u),!1}},Je=async()=>{if(!we)return;const t=g,r=T;t&&!await Ee({suppressSuccessToast:r})||r&&!await Be({suppressSuccessToast:t})||t&&r&&o.success("Cursor configuration saved")},Ke=()=>{U(!1),c(),C()};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"h-[calc(100vh-100px)] flex",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("img",{src:"/assets/sidebar/cursor.svg",alt:"",className:"w-5 h-5 object-contain shrink-0"}),e.jsx("h1",{className:"font-semibold",children:"Cursor"}),e.jsx(_,{variant:"outline",className:"h-5 border-amber-500/60 bg-amber-500/10 px-1.5 text-[10px] font-semibold uppercase tracking-wide text-amber-800 dark:text-amber-300",children:"Beta"}),Oe]}),e.jsx(f,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>c(),disabled:a,children:e.jsx(Se,{className:ie("w-4 h-4",a&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Dedicated Cursor integration controls"})]}),e.jsx(E,{className:"flex-1",children: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(ms,{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:"Unofficial API - Use at Your Own Risk"})]}),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:"Reverse-engineered integration may break anytime"}),e.jsx("li",{children:"Abuse or excessive usage may risk account restrictions"}),e.jsx("li",{children:"No warranty, no responsibility from CCS"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(re,{icon:hs,label:"Integration",ok:!!s?.enabled,detail:s?.enabled?"Enabled":"Disabled"}),e.jsx(re,{icon:G,label:"Authentication",ok:!!(s?.authenticated&&!s?.token_expired),detail:s?.authenticated?s?.token_expired?"Expired":s.auth_method??"Connected":"Not connected"}),e.jsx(re,{icon:xs,label:"Daemon",ok:!!s?.daemon_running,detail:s?.daemon_running?"Running":"Stopped"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Actions"}),s?.enabled?e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:()=>ve(!1),disabled:l,children:[e.jsx(ke,{className:"w-3.5 h-3.5 mr-1.5"}),"Disable Integration"]}):e.jsxs(f,{size:"sm",className:"w-full",onClick:()=>ve(!0),disabled:l,children:[e.jsx(fs,{className:"w-3.5 h-3.5 mr-1.5"}),"Enable Integration"]}),e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:qe,disabled:le,children:[le?e.jsx(M,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(G,{className:"w-3.5 h-3.5 mr-1.5"}),"Auto-detect Auth"]}),e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:()=>I(!0),children:[e.jsx(G,{className:"w-3.5 h-3.5 mr-1.5"}),"Manual Auth Import"]}),s?.daemon_running?e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:Ue,disabled:de,children:[de?e.jsx(M,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(ke,{className:"w-3.5 h-3.5 mr-1.5"}),"Stop Daemon"]}):e.jsxs(f,{size:"sm",className:"w-full",onClick:ze,disabled:!Le,children:[Pe?e.jsx(M,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(ps,{className:"w-3.5 h-3.5 mr-1.5"}),"Start Daemon"]})]})]})}),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:"Port"}),e.jsx("span",{children:s?.port??d?.port??20129})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[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:"Cursor Configuration"}),i&&e.jsx(_,{variant:"outline",className:"text-xs",children:"cursor.settings.json"})]}),i&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified:"," ",i.exists?new Date(i.mtime).toLocaleString():"Never saved"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(f,{variant:"ghost",size:"sm",onClick:Ke,disabled:a||N,children:e.jsx(Se,{className:ie("w-4 h-4",(a||N)&&"animate-spin")})}),e.jsx(f,{size:"sm",onClick:Je,disabled:l||oe||!we||!Ie,children:l||oe?e.jsxs(e.Fragment,{children:[e.jsx(M,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(gs,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex divide-x overflow-hidden",children:[e.jsx("div",{className:"w-[540px] shrink-0 flex flex-col min-h-0 overflow-hidden bg-muted/5",children:e.jsxs(Ve,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Xe,{className:"w-full",children:[e.jsx(W,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(W,{value:"settings",className:"flex-1",children:"Settings"}),e.jsx(W,{value:"info",className:"flex-1",children:"Info"})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:[e.jsx(ee,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(E,{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(js,{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:"flex flex-wrap gap-2",children:[e.jsxs(f,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>Z("codex53"),title:"OpenAI-only mapping: GPT-5.3 Codex / Codex Max / GPT-5 Mini",children:[e.jsx(te,{className:"w-3 h-3"}),"GPT-5.3 Codex"]}),e.jsxs(f,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>Z("claude46"),title:"Claude-first mapping: Opus 4.6 / Sonnet 4.5 / Haiku 4.5",children:[e.jsx(te,{className:"w-3 h-3"}),"Claude 4.6"]}),e.jsxs(f,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>Z("gemini3"),title:"Gemini-first mapping: Gemini 3 Pro + Gemini 3 Flash",children:[e.jsx(te,{className:"w-3 h-3"}),"Gemini 3 Pro"]})]})]}),e.jsx(us,{}),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:"space-y-4",children:[e.jsx(z,{label:"Default Model",description:"Used when no specific tier is requested.",value:j,models:L,disabled:m,onChange:t=>{w(r=>({...r,model:t}))}}),e.jsx(z,{label:"Opus (Most capable)",description:"Complex reasoning and highest quality responses.",value:H,models:L,disabled:m,allowDefaultFallback:!0,onChange:t=>{w(r=>({...r,opus_model:t}))}}),e.jsx(z,{label:"Sonnet (Balanced)",description:"General coding and day-to-day chat workloads.",value:Q,models:L,disabled:m,allowDefaultFallback:!0,onChange:t=>{w(r=>({...r,sonnet_model:t}))}}),e.jsx(z,{label:"Haiku (Fast)",description:"Low-latency and lightweight request paths.",value:V,models:L,disabled:m,allowDefaultFallback:!0,onChange:t=>{w(r=>({...r,haiku_model:t}))}})]})]})]})})}),e.jsx(ee,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(E,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Runtime Settings"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"cursor-port",className:"text-xs",children:"Port"}),e.jsx(se,{id:"cursor-port",type:"number",min:1,max:65535,className:"max-w-[150px] h-8",value:pe,onChange:t=>{w(r=>({...r,port:t.target.value}))}})]}),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(P,{htmlFor:"cursor-auto-start",className:"text-xs",children:"Auto-start Daemon"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Start Cursor daemon automatically when integration is used."})]}),e.jsx(Ce,{id:"cursor-auto-start",checked:K,onCheckedChange:t=>{w(r=>({...r,auto_start:t}))}})]}),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(P,{htmlFor:"cursor-ghost-mode",className:"text-xs",children:"Ghost Mode"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Request `x-ghost-mode` to reduce telemetry."})]}),e.jsx(Ce,{id:"cursor-ghost-mode",checked:$,onCheckedChange:t=>{w(r=>({...r,ghost_mode:t}))}})]})]})})})}),e.jsx(ee,{value:"info",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(E,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[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:"Cursor IDE"})]}),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.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:i?.path??"~/.ccs/cursor.settings.json"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Model mapping writes `ANTHROPIC_MODEL`, `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, and `ANTHROPIC_DEFAULT_HAIKU_MODEL` in `cursor.settings.json`."})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Available Models"}),m?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(M,{className:"w-4 h-4 animate-spin"}),"Loading models..."]}):n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No model metadata available yet. Start daemon and refresh."}):e.jsx("div",{className:"space-y-2",children:n.map(t=>e.jsxs("div",{className:"rounded-lg border px-3 py-2 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:t.id}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.name," • ",t.provider]})]}),t.id===x&&e.jsx(_,{children:"Default"})]},t.id))})]})]})})})]})]})}),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(ws,{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(Ze,{rawJsonContent:X,isRawJsonValid:je,rawJsonEdits:T?he:null,rawSettingsEnv:i?.settings?.env,onChange:t=>{U(!0),Fe(t)}})]})]})]})})]}),e.jsx(Ye,{open:Re,onOpenChange:I,children:e.jsxs(We,{children:[e.jsxs(es,{children:[e.jsx(ss,{children:"Manual Cursor Auth Import"}),e.jsx(ts,{children:"Provide Cursor access token and machine ID if auto-detect is unavailable."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(P,{htmlFor:"cursor-manual-token",children:"Access Token"}),e.jsx(se,{id:"cursor-manual-token",value:B,onChange:t=>xe(t.target.value),placeholder:"Paste Cursor access token"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(P,{htmlFor:"cursor-manual-machine-id",children:"Machine ID"}),e.jsx(se,{id:"cursor-manual-machine-id",value:J,onChange:t=>fe(t.target.value),placeholder:"32-char hex (UUID without hyphens)"})]})]}),e.jsxs(as,{children:[e.jsx(f,{variant:"outline",onClick:()=>I(!1),children:"Cancel"}),e.jsxs(f,{onClick:Ge,disabled:ce,children:[ce?e.jsx(M,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(G,{className:"w-4 h-4 mr-2"}),"Import"]})]})]})})]})}export{Ks as CursorPage};