@kaitranntt/ccs 7.58.0 → 7.59.0

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