@georgedong32/ccs 7.67.0 → 7.67.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/.claude/commands/opsx/apply.md +152 -0
  2. package/.claude/commands/opsx/archive.md +157 -0
  3. package/.claude/commands/opsx/continue.md +114 -0
  4. package/.claude/commands/opsx/explore.md +173 -0
  5. package/.claude/commands/opsx/ff.md +97 -0
  6. package/.claude/commands/opsx/new.md +69 -0
  7. package/.claude/commands/opsx/propose.md +106 -0
  8. package/.claude/commands/opsx/sync.md +134 -0
  9. package/.claude/commands/opsx/verify.md +164 -0
  10. package/.claude/settings.local.json +51 -1
  11. package/dist/auth/commands/create-command-env.d.ts +1 -0
  12. package/dist/auth/commands/create-command-env.d.ts.map +1 -1
  13. package/dist/channels/official-channels-runtime.d.ts +1 -0
  14. package/dist/channels/official-channels-runtime.d.ts.map +1 -1
  15. package/dist/channels/official-channels-store.d.ts +1 -0
  16. package/dist/channels/official-channels-store.d.ts.map +1 -1
  17. package/dist/cliproxy/base-config-loader.d.ts +1 -0
  18. package/dist/cliproxy/base-config-loader.d.ts.map +1 -1
  19. package/dist/cliproxy/config/env-builder.d.ts +1 -0
  20. package/dist/cliproxy/config/env-builder.d.ts.map +1 -1
  21. package/dist/cliproxy/config/extended-context-config.d.ts +1 -0
  22. package/dist/cliproxy/config/extended-context-config.d.ts.map +1 -1
  23. package/dist/cliproxy/config/thinking-config.d.ts +1 -0
  24. package/dist/cliproxy/config/thinking-config.d.ts.map +1 -1
  25. package/dist/cliproxy/model-id-normalizer.d.ts +1 -0
  26. package/dist/cliproxy/model-id-normalizer.d.ts.map +1 -1
  27. package/dist/commands/command-catalog.d.ts +1 -1
  28. package/dist/commands/command-catalog.d.ts.map +1 -1
  29. package/dist/commands/cursor-command-display.d.ts.map +1 -1
  30. package/dist/commands/cursor-command-display.js +1 -0
  31. package/dist/commands/cursor-command-display.js.map +1 -1
  32. package/dist/commands/cursor-command.d.ts.map +1 -1
  33. package/dist/commands/cursor-command.js +41 -0
  34. package/dist/commands/cursor-command.js.map +1 -1
  35. package/dist/commands/cursor-usage-display.d.ts +29 -0
  36. package/dist/commands/cursor-usage-display.d.ts.map +1 -0
  37. package/dist/commands/cursor-usage-display.js +107 -0
  38. package/dist/commands/cursor-usage-display.js.map +1 -0
  39. package/dist/cursor/constants.d.ts +1 -1
  40. package/dist/cursor/constants.d.ts.map +1 -1
  41. package/dist/cursor/constants.js +1 -0
  42. package/dist/cursor/constants.js.map +1 -1
  43. package/dist/cursor/cursor-anthropic-response.d.ts +1 -0
  44. package/dist/cursor/cursor-anthropic-response.d.ts.map +1 -1
  45. package/dist/cursor/cursor-executor.d.ts +1 -0
  46. package/dist/cursor/cursor-executor.d.ts.map +1 -1
  47. package/dist/docker/docker-executor.d.ts +1 -0
  48. package/dist/docker/docker-executor.d.ts.map +1 -1
  49. package/dist/targets/claude-adapter.d.ts +1 -0
  50. package/dist/targets/claude-adapter.d.ts.map +1 -1
  51. package/dist/targets/codex-adapter.d.ts +1 -0
  52. package/dist/targets/codex-adapter.d.ts.map +1 -1
  53. package/dist/targets/droid-adapter.d.ts +1 -0
  54. package/dist/targets/droid-adapter.d.ts.map +1 -1
  55. package/dist/targets/target-adapter.d.ts +1 -0
  56. package/dist/targets/target-adapter.d.ts.map +1 -1
  57. package/dist/types/cli.d.ts +1 -0
  58. package/dist/types/cli.d.ts.map +1 -1
  59. package/dist/ui/assets/accounts-DhtktAIG.js +1 -0
  60. package/dist/ui/assets/{alert-dialog-DudTubF8.js → alert-dialog-DQK2Jxfk.js} +1 -1
  61. package/dist/ui/assets/api-Den1YY2d.js +4 -0
  62. package/dist/ui/assets/{auth-section-CHSm0Pb6.js → auth-section-BQitOLMK.js} +1 -1
  63. package/dist/ui/assets/{backups-section-wajt9dzX.js → backups-section-BLGK5re-.js} +1 -1
  64. package/dist/ui/assets/{channels-CHran6QE.js → channels-Dop1axTi.js} +1 -1
  65. package/dist/ui/assets/{checkbox-DvR--eRI.js → checkbox-DDrDuGxi.js} +1 -1
  66. package/dist/ui/assets/claude-extension-6WjTc0o8.js +1 -0
  67. package/dist/ui/assets/cliproxy-Ch7RdSMG.js +3 -0
  68. package/dist/ui/assets/{cliproxy-ai-providers-CjKicdzR.js → cliproxy-ai-providers-DjybBlb5.js} +7 -7
  69. package/dist/ui/assets/{cliproxy-control-panel-Dw9Q1OoX.js → cliproxy-control-panel-DDif_QAT.js} +1 -1
  70. package/dist/ui/assets/{codex-D3mdE9ZJ.js → codex-DFAV50Ee.js} +4 -4
  71. package/dist/ui/assets/{confirm-dialog-C5COcZYh.js → confirm-dialog-CP26_Zko.js} +1 -1
  72. package/dist/ui/assets/copilot-uZuyhqwv.js +3 -0
  73. package/dist/ui/assets/cursor-CuaM2FmN.js +1 -0
  74. package/dist/ui/assets/{droid-BRV6w--c.js → droid-DdjXJ2lF.js} +1 -1
  75. package/dist/ui/assets/{globalenv-section-D3NP1kLr.js → globalenv-section-D5_-EIlf.js} +1 -1
  76. package/dist/ui/assets/{health-D9LnJ4lp.js → health-BHhVKLNR.js} +1 -1
  77. package/dist/ui/assets/{icons-DhBsHU-U.js → icons-CQ3MLSan.js} +1 -1
  78. package/dist/ui/assets/{index-BCpf7__M.js → index-B8bAYHAs.js} +1 -1
  79. package/dist/ui/assets/{index-BYrPCHr6.js → index-Ba-43jCS.js} +1 -1
  80. package/dist/ui/assets/{index-A9ZK234F.js → index-Bm09kGOw.js} +1 -1
  81. package/dist/ui/assets/{index-DtD1WuHr.js → index-DHY37v8a.js} +1 -1
  82. package/dist/ui/assets/index-DLCFe4s3.js +1 -0
  83. package/dist/ui/assets/{index-CKNvmYLR.js → index-TSYtCr3K.js} +20 -20
  84. package/dist/ui/assets/{masked-input-CcbDAxug.js → masked-input-CTkIqCMg.js} +1 -1
  85. package/dist/ui/assets/{proxy-status-widget-DhIJtL48.js → proxy-status-widget-DPhKjJFl.js} +1 -1
  86. package/dist/ui/assets/{radix-ui-Zb8sVEtn.js → radix-ui-BlliRfHq.js} +1 -1
  87. package/dist/ui/assets/{raw-json-settings-editor-panel-BJetiLxV.js → raw-json-settings-editor-panel-DQr_y0E4.js} +1 -1
  88. package/dist/ui/assets/{searchable-select-DNmazsgI.js → searchable-select-C2sP7JW5.js} +1 -1
  89. package/dist/ui/assets/{separator-vdIGU0ab.js → separator-2lt47Sla.js} +1 -1
  90. package/dist/ui/assets/{shared-IFLNQqyt.js → shared-DPKtsiFQ.js} +1 -1
  91. package/dist/ui/assets/{table-C8wlucHc.js → table-DbsFACgT.js} +1 -1
  92. package/dist/ui/assets/{tanstack-DWm6aJ-G.js → tanstack-BjiH4QZq.js} +1 -1
  93. package/dist/ui/assets/updates-C5iL4KNn.js +1 -0
  94. package/dist/ui/index.html +4 -4
  95. package/dist/utils/claude-detector.d.ts +1 -0
  96. package/dist/utils/claude-detector.d.ts.map +1 -1
  97. package/dist/utils/claude-spawner.d.ts +1 -0
  98. package/dist/utils/claude-spawner.d.ts.map +1 -1
  99. package/dist/utils/shell-executor.d.ts +1 -0
  100. package/dist/utils/shell-executor.d.ts.map +1 -1
  101. package/dist/utils/websearch/trace.d.ts +1 -0
  102. package/dist/utils/websearch/trace.d.ts.map +1 -1
  103. package/dist/web-server/model-pricing.d.ts.map +1 -1
  104. package/dist/web-server/model-pricing.js +18 -0
  105. package/dist/web-server/model-pricing.js.map +1 -1
  106. package/dist/web-server/services/codex-dashboard-service.d.ts +1 -0
  107. package/dist/web-server/services/codex-dashboard-service.d.ts.map +1 -1
  108. package/dist/web-server/services/droid-dashboard-service.d.ts +1 -0
  109. package/dist/web-server/services/droid-dashboard-service.d.ts.map +1 -1
  110. package/dist/web-server/usage/aggregator.d.ts.map +1 -1
  111. package/dist/web-server/usage/aggregator.js +98 -0
  112. package/dist/web-server/usage/aggregator.js.map +1 -1
  113. package/dist/web-server/usage/cursor-csv-parser.d.ts +68 -0
  114. package/dist/web-server/usage/cursor-csv-parser.d.ts.map +1 -0
  115. package/dist/web-server/usage/cursor-csv-parser.js +238 -0
  116. package/dist/web-server/usage/cursor-csv-parser.js.map +1 -0
  117. package/dist/web-server/usage/cursor-data-store.d.ts +55 -0
  118. package/dist/web-server/usage/cursor-data-store.d.ts.map +1 -0
  119. package/dist/web-server/usage/cursor-data-store.js +240 -0
  120. package/dist/web-server/usage/cursor-data-store.js.map +1 -0
  121. package/dist/web-server/usage/handlers.d.ts +18 -0
  122. package/dist/web-server/usage/handlers.d.ts.map +1 -1
  123. package/dist/web-server/usage/handlers.js +127 -15
  124. package/dist/web-server/usage/handlers.js.map +1 -1
  125. package/dist/web-server/usage/routes.d.ts.map +1 -1
  126. package/dist/web-server/usage/routes.js +13 -0
  127. package/dist/web-server/usage/routes.js.map +1 -1
  128. package/package.json +7 -6
  129. package/dist/ui/assets/accounts-Cvu7FuLd.js +0 -1
  130. package/dist/ui/assets/api-B_SQnrmH.js +0 -4
  131. package/dist/ui/assets/claude-extension-EUfubgK-.js +0 -1
  132. package/dist/ui/assets/cliproxy-CMcQRlMQ.js +0 -3
  133. package/dist/ui/assets/copilot-C_bkjtNE.js +0 -3
  134. package/dist/ui/assets/cursor-CwFdpjUZ.js +0 -1
  135. package/dist/ui/assets/index-B8R9vAE9.js +0 -1
  136. package/dist/ui/assets/updates-BtnxoQcx.js +0 -1
@@ -1,3 +0,0 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as c}from"./react-vendor-CNOkPC89.js";import{a as Ve,u as hs,b as Qs}from"./tanstack-DWm6aJ-G.js";import{a6 as Js,d as I,C as gs,b as fs,a7 as vs,c as B,P as Be,B as G,a as se,a8 as ee,L as Y,I as de,p as js,q as Ns,r as bs,s as ys,t as Le,a9 as ws,aa as Ws,ab as Xs,ac as Ys,u as Cs,ad as ze,ae as $e,af as Qe,ag as Je,ah as ks,ai as ns,aj as Zs,ak as et,V as As,al as _e,am as Ss,l as ke,an as st,ao as is,ap as tt,aq as at,ar as nt,as as it,at as rt,au as rs,av as ot,w as Ps,v as We,aw as Xe,ax as os,ay as Ms,az as lt,aA as ct,aB as dt,aC as ut,aD as Fe,T as Ue,n as qe,o as Ke,aE as mt,aF as pt,aG as xt,aH as ls,aI as ht,aJ as gt,aK as ft,aL as vt,aM as jt,aN as Nt,O as bt,Q as yt,R as cs,U as ds,aO as wt,aP as Ct,aQ as kt,aR as At,aS as St,aT as Pt,aU as Mt,aV as Dt,aW as Tt,aX as Et,aY as Ot,aZ as Rt,S as It}from"./index-CKNvmYLR.js";import{C as He}from"./default-ports-1QQSffYX.js";import{t as U}from"./notifications-B2HqRBj7.js";import{C as Ds,L as Z,n as me,V as Lt,k as ue,m as Ts,ax as Ye,R as Ze,o as fe,a6 as je,T as es,a3 as _t,ay as Es,aw as Ft,x as ss,Z as Ne,Q as Os,h as Ut,s as Rs,az as qt,an as Kt,X as ts,a5 as Is,D as Ls,y as _s,aA as Ht,am as Fs,aB as Gt,aq as Vt,aC as Us}from"./icons-DhBsHU-U.js";import{R as Ae,A as us,D as Oe,i as Bt,a as zt}from"./antigravity-responsibility-constants-Bvh4Ybz0.js";import{C as Se}from"./checkbox-DvR--eRI.js";import{C as $t}from"./confirm-dialog-C5COcZYh.js";import{S as as}from"./separator-vdIGU0ab.js";import{S as Qt}from"./searchable-select-DNmazsgI.js";import{P as Jt}from"./proxy-status-widget-DhIJtL48.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-DudTubF8.js";const qs=Object.freeze({"gemini-3-pro-preview":"gemini-3.1-pro-preview","gemini-3.1-pro-preview":"gemini-3-pro-preview","gemini-3-flash-preview":"gemini-3.1-flash-preview","gemini-3.1-flash-preview":"gemini-3-flash-preview"}),Wt=/^gemini-(\d+(?:[.-]\d+)*)-(pro|flash)-preview(-customtools)?$/i;function ve(s){return Js(s).toLowerCase()}function Pe(s){const t=ve(s),a=t.match(Wt);if(!a)return null;const[,n,i,d]=a;return{normalizedId:t,version:n.split(/[.-]/).map(u=>Number(u)),family:i,customtools:!!d,dottedVersion:n.includes(".")}}function Ks(s,t){const a=Math.max(s.length,t.length);for(let n=0;n<a;n+=1){const i=s[n]??0,d=t[n]??0;if(i!==d)return i>d?1:-1}return 0}function Xt(s,t,a){if(s.customtools!==t.customtools)return s.customtools?1:-1;const n=Ks(s.version,t.version);if(n!==0)return n>0?-1:1;const i=+(s.dottedVersion===a.dottedVersion),d=+(t.dottedVersion===a.dottedVersion);return i!==d?d-i:s.normalizedId.localeCompare(t.normalizedId)}function ms(s,t){const a=ve(t);return s.find(n=>ve(n.id)===a)?.id}function Yt(s,t){const a=Pe(s);return!a||t.length===0?void 0:t.map(i=>{const d=Pe(i.id);return!d||d.family!==a.family?null:{id:i.id,info:d}}).filter(i=>!!i).sort((i,d)=>Xt(i.info,d.info,a))[0]?.id}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.1-pro-preview",name:"Gemini Pro",description:"Resolves to the best advertised Gemini Pro preview via Antigravity",extendedContext:!0,presetMapping:{default:"gemini-3.1-pro-preview",opus:"gemini-3.1-pro-preview",sonnet:"gemini-3.1-pro-preview",haiku:"gemini-3-1-flash-preview"}},{id:"gemini-3-1-flash-preview",name:"Gemini Flash",description:"Resolves to the best advertised Gemini Flash preview via Antigravity",extendedContext:!0,presetMapping:{default:"gemini-3-1-flash-preview",opus:"gemini-3.1-pro-preview",sonnet:"gemini-3.1-pro-preview",haiku:"gemini-3-1-flash-preview"}}]},gemini:{provider:"gemini",displayName:"Gemini",defaultModel:"gemini-2.5-pro",models:[{id:"gemini-3.1-pro-preview",name:"Gemini Pro",tier:"paid",description:"Uses the best advertised Gemini Pro preview when Google exposes one",extendedContext:!0,presetMapping:{default:"gemini-3.1-pro-preview",opus:"gemini-3.1-pro-preview",sonnet:"gemini-3.1-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini Flash",tier:"paid",description:"Uses the best advertised Gemini Flash preview when Google exposes one",extendedContext:!0,presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3.1-pro-preview",sonnet:"gemini-3.1-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",description:"Stable, works with free Google account",extendedContext:!0,presetMapping:{default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-2.5-flash"}}]},codex:{provider:"codex",displayName:"Codex",defaultModel:"gpt-5-codex",models:[{id:"gpt-5-codex",name:"GPT-5 Codex",description:"Cross-plan safe Codex default",presetMapping:{default:"gpt-5-codex",opus:"gpt-5-codex",sonnet:"gpt-5-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5-codex-mini",name:"GPT-5 Codex Mini",description:"Faster and cheaper Codex option",presetMapping:{default:"gpt-5-codex-mini",opus:"gpt-5-codex",sonnet:"gpt-5-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"Legacy mini model ID kept for backwards compatibility",presetMapping:{default:"gpt-5-mini",opus:"gpt-5-codex",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"}},{id:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex Mini",description:"Legacy fast Codex mini model",presetMapping:{default:"gpt-5.1-codex-mini",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini"}},{id:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",description:"Higher-effort Codex model with xhigh support",presetMapping:{default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini"}},{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",description:"Cross-plan Codex model with xhigh support",presetMapping:{default:"gpt-5.2-codex",opus:"gpt-5.2-codex",sonnet:"gpt-5.2-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",tier:"paid",description:"Paid Codex plans only",presetMapping:{default:"gpt-5.3-codex",opus:"gpt-5.3-codex",sonnet:"gpt-5.3-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",tier:"paid",description:"Paid Codex plans only, ultra-fast coding model",presetMapping:{default:"gpt-5.3-codex-spark",opus:"gpt-5.3-codex",sonnet:"gpt-5.3-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.4",name:"GPT-5.4",tier:"paid",description:"Paid Codex plans only, latest GPT-5 family model",presetMapping:{default:"gpt-5.4",opus:"gpt-5.4",sonnet:"gpt-5.4",haiku:"gpt-5-codex-mini"}}]},qwen:{provider:"qwen",displayName:"Qwen",defaultModel:"qwen3-coder-plus",models:[{id:"qwen3-coder-plus",name:"Qwen3 Coder Plus",description:"Code-focused model (1M context)",presetMapping:{default:"qwen3-coder-plus",opus:"qwen3-max",sonnet:"qwen3-coder-plus",haiku:"qwen3-coder-flash"}},{id:"qwen3-max",name:"Qwen3 Max",description:"Flagship model (256K context)",presetMapping:{default:"qwen3-max",opus:"qwen3-max",sonnet:"qwen3-coder-plus",haiku:"qwen3-coder-flash"}},{id:"qwen3-max-preview",name:"Qwen3 Max Preview",description:"Preview with thinking support (256K)",presetMapping:{default:"qwen3-max-preview",opus:"qwen3-max-preview",sonnet:"qwen3-max",haiku:"qwen3-coder-flash"}},{id:"qwen3-235b",name:"Qwen3 235B",description:"Large 235B A22B model",presetMapping:{default:"qwen3-235b",opus:"qwen3-max",sonnet:"qwen3-235b",haiku:"qwen3-coder-flash"}},{id:"qwen3-vl-plus",name:"Qwen3 VL Plus",description:"Vision-language multimodal"},{id:"qwen3-coder-flash",name:"Qwen3 Coder Flash",description:"Fast code generation"},{id:"qwen3-32b",name:"Qwen3 32B",description:"Qwen3 32B model"}]},iflow:{provider:"iflow",displayName:"iFlow",defaultModel:"qwen3-coder-plus",models:[{id:"qwen3-coder-plus",name:"Qwen3 Coder Plus",description:"Recommended default for iFlow accounts",presetMapping:{default:"qwen3-coder-plus",opus:"qwen3-coder-plus",sonnet:"qwen3-coder-plus",haiku:"qwen3-coder-plus"}},{id:"qwen3-max",name:"Qwen3 Max",description:"Flagship Qwen model via iFlow"},{id:"kimi-k2",name:"Kimi K2",description:"Kimi model currently available via iFlow"},{id:"deepseek-v3.2",name:"DeepSeek V3.2",description:"Current DeepSeek V3.2 model via iFlow"},{id:"deepseek-r1",name:"DeepSeek R1",description:"Reasoning-focused DeepSeek model"},{id:"glm-4.6",name:"GLM 4.6",description:"Zhipu GLM 4.6 via iFlow"},{id:"qwen3-vl-plus",name:"Qwen3 VL Plus",description:"Vision-language model"}]},kimi:{provider:"kimi",displayName:"Kimi (Moonshot)",defaultModel:"kimi-k2.5",models:[{id:"kimi-k2.5",name:"Kimi K2.5",description:"Latest multimodal model (262K context)",presetMapping:{default:"kimi-k2.5",opus:"kimi-k2.5",sonnet:"kimi-k2-thinking",haiku:"kimi-k2"}},{id:"kimi-k2-thinking",name:"Kimi K2 Thinking",description:"Extended reasoning model",presetMapping:{default:"kimi-k2-thinking",opus:"kimi-k2.5",sonnet:"kimi-k2-thinking",haiku:"kimi-k2"}},{id:"kimi-k2",name:"Kimi K2",description:"Flagship coding model"}]},kiro:{provider:"kiro",displayName:"Kiro (AWS)",defaultModel:"kiro-claude-sonnet-4-6",models:[{id:"kiro-claude-opus-4-6",name:"Kiro Claude Opus 4.6",description:"Claude Opus 4.6 via Kiro (2.2x credit)",presetMapping:{default:"kiro-claude-opus-4-6",opus:"kiro-claude-opus-4-6",sonnet:"kiro-claude-sonnet-4-6",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4-6",name:"Kiro Claude Sonnet 4.6",description:"Claude Sonnet 4.6 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4-6",opus:"kiro-claude-opus-4-6",sonnet:"kiro-claude-sonnet-4-6",haiku:"kiro-claude-haiku-4-5"}},{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 Hs(s,t){const a=pe[s.toLowerCase()];if(!a)return;const n=ve(t),i=qs[n.toLowerCase()],d=a.models.find(r=>r.id===n||r.id===i);if(d)return d;const u=Pe(n);if(u)return a.models.map(r=>({model:r,info:Pe(r.id)})).filter(r=>!!(r.info&&r.info.family===u.family)).sort((r,o)=>Ks(o.info.version,r.info.version))[0]?.model}function ge(s,t=[]){const a=ve(s),n=Yt(a,t);if(n)return n;const i=ms(t,a);if(i)return i;const d=qs[a];return(d?ms(t,d):void 0)??a}function Zt(s,t=[]){return{default:ge(s.default,t),opus:ge(s.opus,t),sonnet:ge(s.sonnet,t),haiku:ge(s.haiku,t)}}function Gs(s,t=[]){if(!s)return[];const a=new Set;return s.models.map(n=>{const i=ge(n.id,t),d=n.presetMapping?Zt(n.presetMapping,t):void 0;return{...n,id:i,presetMapping:d}}).filter(n=>a.has(n.id)?!1:(a.add(n.id),!0))}function ea(s,t){return Hs(s,t)?.extendedContext===!0}const Re="ccs-internal-managed";async function sa(){try{const s=await fetch("/api/settings/auth/tokens/raw");return s.ok?(await s.json())?.apiKey?.value??Re:Re}catch{return Re}}async function Ge(s,t){const a=pe[s];if(!a)return{success:!1};const n=a.models.find(o=>o.id===a.defaultModel)||a.models[0],i=n?.presetMapping||{default:a.defaultModel,opus:a.defaultModel,sonnet:a.defaultModel,haiku:a.defaultModel},d=await sa(),r={env:{ANTHROPIC_BASE_URL:`http://127.0.0.1:${He}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:d,ANTHROPIC_MODEL:i.default,ANTHROPIC_DEFAULT_OPUS_MODEL:i.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:i.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:i.haiku}};try{return{success:(await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:r})})).ok,presetName:n?.name||a.defaultModel}}catch{return{success:!1}}}function ta({currentProgress:s,allSteps:t}){return e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:t.map((a,n)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${s>=n?"bg-primary":"bg-muted"}`},a))})}function aa({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 na({selectedProvider:s,providers:t,authCommand:a,isRefreshing:n,isPending:i,onBack:d,onStartAuth:u,onRefresh:r}){const[o,p]=c.useState(!1),f=async v=>{await navigator.clipboard.writeText(v),p(!0),setTimeout(()=>p(!1),2e3)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Authenticate with ",t.find(v=>v.id===s)?.name," to add an account"]}),e.jsx(I,{onClick:u,disabled:i,className:"w-full gap-2",size:"lg",children:i?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"w-4 h-4 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(me,{className:"w-4 h-4"}),"Authenticate in Browser"]})}),i&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Complete the OAuth flow in your browser..."})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Or use terminal"})})]}),e.jsx(gs,{children:e.jsxs(fs,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Lt,{className:"w-4 h-4"}),"Run this command in your terminal:"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 px-3 py-2 bg-muted rounded-md font-mono text-sm",children:a}),e.jsx(I,{variant:"outline",size:"icon",onClick:()=>f(a),children:o?e.jsx(ue,{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(I,{variant:"ghost",onClick:d,disabled:i,children:[e.jsx(Ye,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs(I,{variant:"outline",onClick:r,disabled:n||i,children:[e.jsx(Ze,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),n?"Checking...":"Refresh Status"]})]})]})}function ia({accounts:s,privacyMode:t,onSelect:a,onAddNew:n,onBack:i}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:["Select an account (",s.length,")"]}),e.jsx("div",{className:"grid gap-2 max-h-[320px] overflow-y-auto pr-1",children:s.map(d=>{const u=vs(d.id,d.email,d.tokenFile);return e.jsxs("button",{type:"button",onClick:()=>a(d),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(fe,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:B("font-medium",t&&Be),children:u.email}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[u.audienceLabel&&e.jsx(G,{variant:"outline",className:B("text-[10px] h-4 px-1.5 border-transparent",u.audience==="business"?"bg-sky-500/12 text-sky-700 dark:text-sky-300":"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300"),children:u.audienceLabel}),u.detailLabel&&e.jsx(G,{variant:"outline",className:"text-[10px] h-4 px-1.5",children:u.detailLabel}),d.isDefault&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Default account"})]})]})]}),e.jsx(Ds,{className:"w-4 h-4 text-muted-foreground"})]},d.id)})}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Or"})})]}),e.jsxs("button",{type:"button",className:"w-full flex items-center gap-3 p-3 border-2 border-dashed border-primary/50 rounded-lg hover:border-primary hover:bg-primary/5 transition-colors text-left",onClick:n,children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(me,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-primary",children:"Add new account"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Authenticate with a different account"})]})]}),e.jsx("div",{className:"flex items-center justify-between pt-2",children:e.jsxs(I,{variant:"ghost",onClick:i,children:[e.jsx(Ye,{className:"w-4 h-4 mr-2"}),"Back"]})})]})}const ps="__custom__";function ra({selectedProvider:s,selectedAccount:t,variantName:a,modelName:n,isPending:i,privacyMode:d,onVariantNameChange:u,onModelChange:r,onBack:o,onSkip:p,onCreate:f}){const{t:v}=se(),g=pe[s]?.models||[],L=n&&!g.some(l=>l.id===n),[j,w]=c.useState(L),D=s==="agy"&&n.trim().length>0?ee(n):!1,b=t?vs(t.id,t.email,t.tokenFile):null,N=l=>{l===ps?(w(!0),r("")):(w(!1),r(l))};return e.jsxs("div",{className:"space-y-4",children:[t&&e.jsxs("div",{className:"flex items-start gap-2 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx(fe,{className:"w-4 h-4"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("span",{children:[v("setupVariant.using")," ",e.jsx("span",{className:B(d&&Be),children:b?.email})]}),(b?.audienceLabel||b?.detailLabel)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[b?.audienceLabel&&e.jsx(G,{variant:"outline",className:B("text-[10px] h-4 px-1.5 border-transparent",b.audience==="business"?"bg-sky-500/12 text-sky-700 dark:text-sky-300":"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300"),children:b.audienceLabel}),b?.detailLabel&&e.jsx(G,{variant:"outline",className:"text-[10px] h-4 px-1.5",children:b.detailLabel})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"variant-name",children:v("setupVariant.variantNameRequired")}),e.jsx(de,{id:"variant-name",value:a,onChange:l=>u(l.target.value),placeholder:v("setupVariant.variantNamePlaceholder")}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[v("setupVariant.invokeHintPrefix")," ccs ",a||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{children:v("setupVariant.model")}),j?e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{value:n,onChange:l=>r(l.target.value),placeholder:v("setupVariant.modelPlaceholder")}),D&&e.jsx("p",{className:"text-xs text-destructive",children:"Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated."}),e.jsx("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:()=>{w(!1),s==="agy"&&ee(n)&&r("")},children:v("setupVariant.choosePresetInstead")})]}):e.jsxs(js,{value:g.some(l=>l.id===n)?n:"",onValueChange:N,children:[e.jsx(Ns,{children:e.jsx(bs,{placeholder:v("setupVariant.selectModel")})}),e.jsxs(ys,{children:[g.map(l=>e.jsx(Le,{value:l.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:l.name}),l.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",l.description]})]})},l.id)),e.jsx(Le,{value:ps,children:e.jsx("span",{className:"text-primary",children:v("setupVariant.customModelName")})})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:j?v("setupVariant.enterAnyModel"):v("setupVariant.defaultModel",{model:pe[s]?.defaultModel||v("setupVariant.providerDefault")})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(I,{variant:"ghost",onClick:o,children:[e.jsx(Ye,{className:"w-4 h-4 mr-2"}),v("setupVariant.back")]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{variant:"ghost",onClick:p,children:v("setupVariant.skip")}),e.jsx(I,{onClick:f,disabled:!a||i||D,children:v(i?"setupVariant.creating":"setupVariant.createVariant")})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:v("setupVariant.skipHint")})]})}function oa({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(ue,{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(gs,{children:e.jsxs(fs,{className:"p-4 space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Usage:"}),e.jsxs("code",{className:"block px-3 py-2 bg-muted rounded-md font-mono text-sm",children:["ccs ",s,' "your prompt here"']})]})}),e.jsx(I,{onClick:t,className:"w-full",children:"Done"})]})}function la({open:s,onClose:t}){const[a,n]=c.useState("provider"),[i,d]=c.useState(""),[u,r]=c.useState(null),[o,p]=c.useState(""),[f,v]=c.useState(""),[g,L]=c.useState(!1),[j,w]=c.useState(!1),{data:D,refetch:b}=ws(),N=Ws(),l=Xs(),A=Ys(),{privacyMode:C}=Cs(),M=D?.authStatus.find(T=>T.provider===i),m=c.useMemo(()=>M?.accounts||[],[M?.accounts]);c.useEffect(()=>{if(!s){const T=setTimeout(()=>{n("provider"),d(""),r(null),p(""),v(""),w(!1)},0);return()=>clearTimeout(T)}},[s]),c.useEffect(()=>{if(a==="auth"&&m.length>0&&!j){const T=setTimeout(()=>{n("account")},0);return()=>clearTimeout(T)}},[a,m,j]);const S=async()=>{L(!0),await b(),L(!1)},O=()=>{const T=(M?.accounts?.length||0)===0;l.mutate({provider:i},{onSuccess:async R=>{if(T){const K=await Ge(i);K.success&&K.presetName?U.success(`Applied "${K.presetName}" preset`):K.success||U.warning(As.t("commonToast.accountAddedPresetFailed"))}R.account&&(r(R.account),n("variant")),b()}})},q=T=>{d(T),(D?.authStatus.find(V=>V.provider===T)?.accounts||[]).length===0?n("auth"):n("account")},h=T=>{r(T),n("variant")},k=async()=>{if(!(!o||!i))try{await N.mutateAsync({name:o,provider:i,model:f||void 0,account:u?.id}),n("success")}catch(T){console.error("Failed to create variant:",T)}},y=`ccs ${i} --auth --add`,F=et(a),H=T=>{if(!T&&(l.isPending&&i&&A.mutate(i),a==="success"||a==="provider")){t();return}};return e.jsx(ze,{open:s,onOpenChange:H,children:e.jsxs($e,{className:"sm:max-w-lg",onPointerDownOutside:T=>{a!=="success"&&a!=="provider"&&T.preventDefault()},onEscapeKeyDown:T=>{(l.isPending||N.isPending)&&T.preventDefault()},children:[e.jsxs(Qe,{children:[e.jsxs(Je,{className:"flex items-center gap-2",children:[e.jsx(je,{className:"w-5 h-5 text-primary"}),"Quick Setup Wizard"]}),e.jsxs(ks,{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(aa,{providers:ns,onSelect:q}),a==="auth"&&e.jsx(na,{selectedProvider:i,providers:ns,authCommand:y,isRefreshing:g,isPending:l.isPending,onBack:()=>n("provider"),onStartAuth:O,onRefresh:S}),a==="account"&&e.jsx(ia,{accounts:m,privacyMode:C,onSelect:h,onAddNew:()=>{w(!0),n("auth")},onBack:()=>n("provider")}),a==="variant"&&e.jsx(ra,{selectedProvider:i,selectedAccount:u,variantName:o,modelName:f,isPending:N.isPending,privacyMode:C,onVariantNameChange:p,onModelChange:v,onBack:()=>m.length>0?n("account"):n("provider"),onSkip:t,onCreate:k}),a==="success"&&e.jsx(oa,{variantName:o,onClose:t})]}),e.jsx(ta,{currentProgress:F,allSteps:Zs})]})})}const ca=3e3,da=300*1e3,ua=3;async function Ie(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 ce={provider:null,isAuthenticating:!1,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:!1};function ma(){const[s,t]=c.useState(ce),a=c.useRef(0),n=c.useRef(null),i=c.useRef(null),d=c.useRef(0),u=c.useRef(0),r=c.useRef(!1),o=Ve(),p=c.useCallback(w=>w===a.current,[]),f=c.useCallback(()=>{i.current&&(clearInterval(i.current),i.current=null),u.current=0},[]);c.useEffect(()=>()=>{n.current?.abort(),f(),r.current=!1},[f]);const v=c.useCallback(async(w,D,b)=>{if(p(b)){if(Date.now()-d.current>da){f(),p(b)&&t(N=>({...N,isAuthenticating:!1,error:"Authentication timed out. Please try again."}));return}try{const N=await fetch(`/api/cliproxy/auth/${w}/status?state=${encodeURIComponent(D)}`);if(!p(b))return;const l=await N.json();if(u.current=0,l.status==="ok"){if(!(typeof l.account=="object"&&l.account!==null)){f();const C="Authenticated account could not be registered";U.error(C),t(M=>({...M,isAuthenticating:!1,error:C}));return}f(),o.invalidateQueries({queryKey:["cliproxy-auth"]}),o.invalidateQueries({queryKey:["cliproxy-accounts"]}),o.invalidateQueries({queryKey:["account-quota"]}),U.success(`${w} authentication successful`),r.current=!1,t(ce)}else if(l.status==="auth_url"){const A=l.url||l.auth_url;A&&(t(C=>({...C,authUrl:A})),r.current||(r.current=!0,window.open(A,"_blank")))}else if(l.status==="device_code"){f();const A=l.user_code&&l.verification_url?`Open ${l.verification_url} and enter code: ${l.user_code}`:"Switch to Device Code method and try again.";U.error("Provider returned Device Code flow in callback mode"),t(C=>({...C,isAuthenticating:!1,error:A}))}else if(l.status==="error"){f();const A=l.error||"Authentication failed";U.error(A),t(C=>({...C,isAuthenticating:!1,error:A}))}}catch(N){if(!p(b)||(u.current+=1,u.current<ua))return;f();const l=N instanceof Error&&N.message.trim().length>0?N.message:"Lost contact with the auth status endpoint";U.error(l),t(A=>({...A,isAuthenticating:!1,error:l}))}}},[p,o,f]),g=c.useCallback(async(w,D)=>{if(!_e(w)){t({...ce,error:`Unknown provider: ${w}`});return}n.current?.abort(),f(),r.current=!1,u.current=0;const b=new AbortController,N=a.current+1;a.current=N,n.current=b;const A=(D?.flowType||(Ss(w)?"device_code":"authorization_code"))==="device_code",C=D?.startEndpoint||(A?"start":"start-url"),M={nickname:D?.nickname,kiroMethod:D?.kiroMethod,riskAcknowledgement:D?.riskAcknowledgement};t({provider:w,isAuthenticating:!0,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:A});try{if(C==="start")fetch(`/api/cliproxy/auth/${w}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M),signal:b.signal}).then(async m=>{if(!p(N))return;const S=await Ie(m);if(!p(N))return;const O=S.success===!0,q=typeof S.account=="object"&&S.account!==null;if(m.ok&&O&&q)o.invalidateQueries({queryKey:["cliproxy-auth"]}),o.invalidateQueries({queryKey:["cliproxy-accounts"]}),o.invalidateQueries({queryKey:["account-quota"]}),r.current=!1,t(ce);else{const h=typeof S.error=="string"?S.error:O?"Authenticated account could not be registered":"Authentication failed";U.error(h),t(k=>({...k,isAuthenticating:!1,error:h}))}}).catch(m=>{if(!p(N)||m instanceof Error&&m.name==="AbortError")return;const S=m instanceof Error?m.message:"Authentication failed";U.error(S),t(O=>({...O,isAuthenticating:!1,error:S}))});else{const m=await fetch(`/api/cliproxy/auth/${w}/start-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M),signal:b.signal});if(!p(N))return;const S=await Ie(m);if(!p(N))return;const O=S.success===!0;if(!m.ok||!O){const k=typeof S.error=="string"?S.error:"Failed to start OAuth";throw new Error(k)}const q=typeof S.authUrl=="string"?S.authUrl:null,h=typeof S.state=="string"?S.state:null;t(k=>({...k,authUrl:q,oauthState:h})),q&&(r.current=!0,window.open(q,"_blank")),h&&(d.current=Date.now(),i.current=setInterval(()=>{v(w,h,N)},ca))}}catch(m){if(!p(N))return;if(m instanceof Error&&m.name==="AbortError"){r.current=!1,t(ce);return}const S=m instanceof Error?m.message:"Authentication failed";U.error(S),t(O=>({...O,isAuthenticating:!1,error:S}))}},[p,v,f,o]),L=c.useCallback(()=>{const w=s.provider;a.current+=1,n.current?.abort(),f(),r.current=!1,t(ce),w&&ke.cliproxy.auth.cancel(w).catch(()=>{})},[s.provider,f]),j=c.useCallback(async w=>{if(!s.provider)return;const D=a.current,b=s.provider;t(N=>({...N,isSubmittingCallback:!0,error:null}));try{const N=await fetch(`/api/cliproxy/auth/${b}/submit-callback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({redirectUrl:w})});if(!p(D))return;const l=await Ie(N);if(!p(D))return;const A=l.success===!0,C=l.status==="wait",M=typeof l.account=="object"&&l.account!==null;if(N.ok&&C)t(m=>({...m,isSubmittingCallback:!1,error:null}));else if(N.ok&&A&&M)f(),o.invalidateQueries({queryKey:["cliproxy-auth"]}),o.invalidateQueries({queryKey:["cliproxy-accounts"]}),o.invalidateQueries({queryKey:["account-quota"]}),U.success(`${b} authentication successful`),t(ce);else{const m=typeof l.error=="string"?l.error:A?"Authenticated account could not be registered":"Callback submission failed";throw new Error(m)}}catch(N){if(!p(D))return;const l=N instanceof Error?N.message:"Failed to submit callback";U.error(l),t(A=>({...A,isSubmittingCallback:!1,error:l}))}},[p,s.provider,o,f]);return c.useMemo(()=>({...s,startAuth:g,cancelAuth:L,submitCallback:j}),[s,g,L,j])}function Vs({className:s,showAcknowledgement:t=!1,acknowledgementPhrase:a=Ae,acknowledgementText:n="",onAcknowledgementTextChange:i,disabled:d=!1,showProxySettingsLink:u=!1}){const{t:r}=se(),o=r("accountSafetyWarning.title"),p=r("accountSafetyWarning.subtitle"),f=r("accountSafetyWarning.firstLine"),v=r("accountSafetyWarning.secondLine"),g="https://github.com/kaitranntt/ccs/issues/509",L=r("accountSafetyWarning.issueLabel"),j=r("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(es,{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:p})]})]}),e.jsx(G,{variant:"outline",className:"border-amber-500/40 text-amber-700 dark:text-amber-300",children:"High Risk"})]}),e.jsxs("div",{className:"space-y-2 text-sm leading-relaxed",children:[e.jsx("p",{children:f}),e.jsx("p",{className:"font-medium text-amber-900 dark:text-amber-200",children:v}),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:[L,e.jsx(me,{className:"h-3.5 w-3.5"})]}),u&&e.jsxs("a",{href:"/settings?tab=proxy",className:"inline-flex items-center gap-1.5 rounded-md border border-amber-500/30 bg-amber-500/10 px-2.5 py-1 text-xs font-medium text-amber-800 transition-colors hover:bg-amber-500/15 dark:text-amber-200",children:[e.jsx(_t,{className:"h-3.5 w-3.5"}),j]}),e.jsx("span",{className:"rounded-md border border-border/70 bg-muted/60 px-2.5 py-1 text-xs text-muted-foreground",children:"Applies to CLI and dashboard auth"})]}),t&&i&&e.jsxs("div",{className:"rounded-lg border border-amber-500/25 bg-amber-500/5 p-2.5",children:[e.jsxs(Y,{htmlFor:"account-risk-ack-text",className:"text-xs leading-5",children:["Type exact phrase to continue:"," ",e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono",children:a})]}),e.jsx(de,{id:"account-risk-ack-text",value:n,onChange:w=>i(w.target.value),placeholder:a,disabled:d,className:"mt-2 font-mono text-xs"})]})]})]})}function pa({className:s,value:t,onChange:a,disabled:n=!1}){const{t:i}=se(),d=[t.reviewedIssue509,t.understandsBanRisk,t.acceptsFullResponsibility,t.typedPhrase.trim().replace(/\s+/g," ").toUpperCase()===us].filter(Boolean).length,u=d/4*100,r=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(es,{className:"h-4 w-4"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:i("antigravityChecklist.title")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i("antigravityChecklist.subtitle")})]})]}),e.jsx(G,{variant:"outline",className:"border-rose-500/40 text-rose-700 dark:text-rose-300",children:i("antigravityChecklist.mandatory")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:i("antigravityChecklist.completion")}),e.jsx("span",{children:i("antigravityChecklist.stepsCount",{current:d})})]}),e.jsx(st,{value:u,className:"h-2"})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border border-rose-500/20 bg-rose-500/5 p-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Se,{id:"agy-step-reviewed-issue",checked:t.reviewedIssue509,onCheckedChange:o=>r({reviewedIssue509:!!o}),disabled:n}),e.jsx(Y,{htmlFor:"agy-step-reviewed-issue",className:"text-xs leading-5",children:"Step 1: I reviewed issue #509 and understand AGY OAuth can trigger account bans/suspensions."})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Se,{id:"agy-step-understands-risk",checked:t.understandsBanRisk,onCheckedChange:o=>r({understandsBanRisk:!!o}),disabled:n}),e.jsx(Y,{htmlFor:"agy-step-understands-risk",className:"text-xs leading-5",children:"Step 2: I understand this OAuth action is my own decision and I accept the upstream risk."})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Se,{id:"agy-step-accept-responsibility",checked:t.acceptsFullResponsibility,onCheckedChange:o=>r({acceptsFullResponsibility:!!o}),disabled:n}),e.jsx(Y,{htmlFor:"agy-step-accept-responsibility",className:"text-xs leading-5",children:"Step 3: I accept full responsibility. CCS is not liable for suspension, bans, or access loss."})]})]}),e.jsxs("div",{className:"space-y-2 rounded-lg border border-amber-500/25 bg-amber-500/5 p-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-amber-800 dark:text-amber-200",children:[e.jsx(Es,{className:"h-3.5 w-3.5"}),"Step 4: Type exact phrase to continue"]}),e.jsx(de,{value:t.typedPhrase,onChange:o=>r({typedPhrase:o.target.value}),placeholder:us,disabled:n,className:"font-mono text-xs"})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:e.jsxs("a",{href:"https://github.com/kaitranntt/ccs/issues/509",target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 rounded-md border border-rose-500/30 bg-rose-500/10 px-2.5 py-1 font-medium text-rose-800 transition-colors hover:bg-rose-500/15 dark:text-rose-200",children:["Read issue #509",e.jsx(me,{className:"h-3.5 w-3.5"})]})})]})]})}function xa(s){return s.trim().replace(/\s+/g," ").toUpperCase()}function ha({open:s,onClose:t,provider:a,displayName:n,isFirstAccount:i=!1}){const[d,u]=c.useState(""),[r,o]=c.useState(""),[p,f]=c.useState(!1),[v,g]=c.useState(null),[L,j]=c.useState(""),[w,D]=c.useState(Oe),[b,N]=c.useState(!1),[l,A]=c.useState(!1),[C,M]=c.useState(is),{t:m}=se(),S=c.useRef(!1),O=c.useRef(0),q=c.useRef(!1),h=ma(),k=tt(),y=a==="kiro",F=a==="agy"||a==="gemini",H=a==="gemini"&&!b,T=a==="agy"&&!b,R=F&&l,K=Bt(w),V=xa(L)===Ae,te=Ss(a),W=at(C),ae=y?W.flowType==="device_code":te,Q=h.isAuthenticating||k.isPending,x=d.trim(),E=v||h.error,z=c.useCallback(async()=>{const P=await fetch("/api/settings/auth/antigravity-risk");if(!P.ok)throw new Error("Failed to load power user mode setting");return(await P.json()).antigravityAckBypass===!0},[]),ne=c.useCallback(async({pendingMessage:P=null,disabledMessage:X=null}={})=>{const he=++O.current;A(!0),P!==null&&g(P);try{const le=await z();return O.current!==he||(N(le),X?g(le?null:X):P!==null&&g(null)),le}catch{return O.current!==he||(N(!1),g(X??m("addAccountDialog.powerUserLoadFailed")),q.current||(q.current=!0,U.error(m("addAccountDialog.powerUserLoadFailed")))),!1}finally{O.current===he&&A(!1)}},[z,m]),xe=()=>{u(""),o(""),f(!1),g(null),j(""),D(Oe),N(!1),A(!1),M(is),O.current+=1,q.current=!1,S.current=!1,t()};c.useEffect(()=>{s&&(j(""),D(Oe),g(null))},[a,s]),c.useEffect(()=>()=>{O.current+=1},[]),c.useEffect(()=>{if(!s||!F){O.current+=1,N(!1),A(!1);return}ne()},[s,a,F,ne]),c.useEffect(()=>{if(!s||a!=="agy"||!h.error||!b)return;const P=h.error.toLowerCase();(P.includes("agy_risk_ack_required")||P.includes("responsibility acknowledgement")||P.includes("responsibility checklist"))&&ne({pendingMessage:m("addAccountDialog.powerUserLoading"),disabledMessage:m("addAccountDialog.powerUserUnavailableRetry")})},[h.error,s,b,a,ne,m]),c.useEffect(()=>{!h.isAuthenticating&&!h.error&&h.provider===null&&s&&S.current&&(S.current=!1,(async()=>{try{const X=await Ge(a);X.success&&X.presetName&&i&&U.success(`Applied "${X.presetName}" preset`)}catch{}xe()})())},[h.isAuthenticating,h.error,h.provider]);const be=()=>{h.cancelAuth(),xe()},Me=async()=>{h.authUrl&&(await navigator.clipboard.writeText(h.authUrl),f(!0),setTimeout(()=>f(!1),2e3))},De=()=>{r.trim()&&h.submitCallback(r.trim())},ye=()=>{if(R){g(m("addAccountDialog.powerUserLoading"));return}if(T&&!K){g("Complete all Antigravity responsibility steps before authenticating this provider.");return}if(H&&!V){g(`Type "${Ae}" to acknowledge the account safety warning before authenticating this provider.`);return}g(null),S.current=!0,h.startAuth(a,{nickname:x||void 0,kiroMethod:y?C:void 0,flowType:y?W.flowType:void 0,startEndpoint:y?W.startEndpoint:void 0,riskAcknowledgement:T?{version:zt,reviewedIssue509:w.reviewedIssue509,understandsBanRisk:w.understandsBanRisk,acceptsFullResponsibility:w.acceptsFullResponsibility,typedPhrase:w.typedPhrase}:void 0})},we=()=>{S.current=!0,k.mutate(void 0,{onSuccess:async()=>{const P=await Ge("kiro");P.success&&P.presetName&&i&&U.success(`Applied "${P.presetName}" preset`),xe()}})},Te=P=>{P||be()},J=h.isAuthenticating;return e.jsx(ze,{open:s,onOpenChange:Te,children:e.jsxs($e,{className:"sm:max-w-md",onInteractOutside:P=>{J&&P.preventDefault()},children:[e.jsxs(Qe,{children:[e.jsx(Je,{children:m("addAccountDialog.title",{displayName:n})}),e.jsx(ks,{children:m(y?"addAccountDialog.descKiro":ae?"addAccountDialog.descDeviceCode":"addAccountDialog.descOauth")})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[T&&!J&&e.jsx(pa,{value:w,onChange:P=>{D(P),g(null)},disabled:Q}),F&&b&&!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"}),m("addAccountDialog.powerUserEnabled")]}),m("addAccountDialog.powerUserSkipped")]}),H&&!J&&e.jsx(Vs,{showAcknowledgement:!0,acknowledgementPhrase:Ae,acknowledgementText:L,onAcknowledgementTextChange:P=>{j(P),g(null)},disabled:Q}),y&&!J&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"kiro-auth-method",children:m("addAccountDialog.authMethod")}),e.jsxs(js,{value:C,onValueChange:P=>{M(P),g(null)},children:[e.jsx(Ns,{id:"kiro-auth-method",children:e.jsx(bs,{placeholder:m("addAccountDialog.selectKiroAuthMethod")})}),e.jsx(ys,{children:nt.map(P=>e.jsx(Le,{value:P.id,children:P.label},P.id))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:W.description})]}),!J&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"nickname",children:m("addAccountDialog.nicknameOptional")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fe,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(de,{id:"nickname",value:d,onChange:P=>{u(P.target.value),g(null)},placeholder:m("addAccountDialog.nicknamePlaceholder"),disabled:Q,className:"flex-1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:m("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(Z,{className:"w-4 h-4 inline mr-2 animate-spin"}),m("addAccountDialog.waitingForAuth")]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:h.isDeviceCodeFlow?m("addAccountDialog.deviceCodeHint"):m("addAccountDialog.browserHint")})]}),h.authUrl&&!h.isDeviceCodeFlow&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{className:"text-xs",children:m("addAccountDialog.openUrlLabel")}),e.jsxs("div",{className:"p-3 bg-muted rounded-md",children:[e.jsx("p",{className:"text-xs text-muted-foreground break-all font-mono line-clamp-3",children:h.authUrl}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(I,{variant:"outline",size:"sm",onClick:Me,children:p?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-3 h-3 mr-1"}),m("addAccountDialog.copied")]}):e.jsxs(e.Fragment,{children:[e.jsx(Ts,{className:"w-3 h-3 mr-1"}),m("addAccountDialog.copy")]})}),e.jsxs(I,{variant:"outline",size:"sm",onClick:()=>{if(!h.authUrl)return;const P=window.open(h.authUrl,"_blank");(!P||P.closed||typeof P.closed>"u")&&U.warning(m("addAccountDialog.popupBlocked"),{duration:5e3})},children:[e.jsx(me,{className:"w-3 h-3 mr-1"}),m("addAccountDialog.open")]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"callback-url",className:"text-xs",children:m("addAccountDialog.redirectPasteLabel")}),e.jsx(de,{id:"callback-url",value:r,onChange:P=>o(P.target.value),placeholder:m("addAccountDialog.callbackPlaceholder"),className:"font-mono text-xs"}),e.jsx(I,{variant:"secondary",size:"sm",onClick:De,disabled:!r.trim()||h.isSubmittingCallback,children:h.isSubmittingCallback?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"w-3 h-3 mr-1 animate-spin"}),m("addAccountDialog.submitting")]}):m("addAccountDialog.submitCallback")})]})]}),!h.authUrl&&!h.isDeviceCodeFlow&&e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:m("addAccountDialog.preparingUrl")})]}),E&&e.jsx("p",{className:"text-xs text-center text-destructive",children:E}),k.isPending&&e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:[e.jsx(Z,{className:"w-4 h-4 inline mr-2 animate-spin"}),m("addAccountDialog.importingToken")]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(I,{variant:"ghost",onClick:be,children:m("addAccountDialog.cancel")}),y&&!J&&e.jsx(I,{variant:"outline",onClick:we,disabled:Q,children:k.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"w-4 h-4 mr-2 animate-spin"}),m("addAccountDialog.importing")]}):e.jsxs(e.Fragment,{children:[e.jsx(Ft,{className:"w-4 h-4 mr-2"}),m("addAccountDialog.importFromIde")]})}),!J&&e.jsxs(I,{onClick:ye,disabled:Q||R||T&&!K||H&&!V,children:[e.jsx(me,{className:"w-4 h-4 mr-2"}),m("addAccountDialog.authenticate")]})]})]})]})})}const ga=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function fa(s){const t=s?.env||{};return ga.filter(a=>!t[a]?.trim())}function va(s){const[t,a]=c.useState(null),[n,i]=c.useState(!1),d=Ve(),{data:u,isLoading:r,refetch:o}=hs({queryKey:["settings",s],queryFn:async()=>{const h=await fetch(`/api/settings/${s}/raw`);return h.ok?h.json():{profile:s,settings:{env:{}},mtime:Date.now(),path:`~/.ccs/profiles/${s}/settings.json`}}}),p=u?.settings,f=c.useMemo(()=>t!==null?t:p?JSON.stringify(p,null,2):`{
2
- "env": {}
3
- }`,[t,p]),v=c.useCallback(h=>{a(h)},[]),g=c.useMemo(()=>{try{return JSON.parse(f)}catch{return p||{env:{}}}},[f,p]),L=g?.env?.ANTHROPIC_MODEL,j=g?.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,w=g?.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,D=g?.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,b=c.useMemo(()=>it(g?.env||{}),[g]),N=c.useCallback((h,k)=>rt(h,k,{supportsExtendedContext:y=>ea(s,y)}),[s]),l=c.useCallback((h,k)=>{const y={...g?.env||{},[h]:k},F=rs(h)?N(y,b):y;delete F.CCS_EXTENDED_CONTEXT;const H={...g,env:F};a(JSON.stringify(H,null,2))},[N,g,b]),A=c.useCallback(h=>{const k=g?.env||{},y=N(k,h);delete y.CCS_EXTENDED_CONTEXT;const F={...g,env:y};a(JSON.stringify(F,null,2))},[N,g]),C=c.useCallback(h=>{const k={...g?.env||{},...h},F=Object.keys(h).some(rs)?N(k,b):k;delete F.CCS_EXTENDED_CONTEXT;const H={...g,env:F};a(JSON.stringify(H,null,2))},[N,g,b]),M=c.useMemo(()=>{try{return JSON.parse(f),!0}catch{return!1}},[f]),m=c.useMemo(()=>t===null?!1:t!==JSON.stringify(p,null,2),[t,p]),S=c.useMemo(()=>fa(g),[g]),O=Qs({mutationFn:async()=>{const h=JSON.parse(f),k=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:h,expectedMtime:u?.mtime})});if(k.status===409)throw new Error("CONFLICT");if(!k.ok)throw new Error("Failed to save");return k.json()},onSuccess:h=>{d.invalidateQueries({queryKey:["settings",s]}),a(null),h?.warning?U.success("Settings saved",{description:h.warning}):U.success("Settings saved")},onError:h=>{h.message==="CONFLICT"?i(!0):U.error(h.message)}}),q=async h=>{i(!1),h?(await o(),O.mutate()):a(null)};return{data:u,isLoading:r,refetch:o,rawJsonContent:f,rawJsonEdits:t,isRawJsonValid:M,hasChanges:m,currentSettings:g,currentModel:L,opusModel:j,sonnetModel:w,haikuModel:D,extendedContextEnabled:b,toggleExtendedContext:A,handleRawJsonChange:v,updateEnvValue:l,updateEnvValues:C,saveMutation:{mutate:()=>O.mutate(),isPending:O.isPending},conflictDialog:n,setConflictDialog:i,handleConflictResolve:q,missingRequiredFields:S}}const ja=/-(medium|high|xhigh)$/i;function Na(s){if(!s)return;const t=s.trim().match(ja);if(t?.[1])return t[1].toLowerCase()}function ba(s){if(!s)return null;const t=Na(s);return t?{label:`Pinned ${t}`,explicit:!0}:{label:"Auto effort",explicit:!1}}function ya({label:s}){return e.jsx(G,{variant:"outline",className:"text-[9px] h-4 px-1",children:s})}function Ce({modelId:s}){const t=ba(s);return t?e.jsx(G,{variant:t.explicit?"secondary":"outline",className:"text-[9px] h-4 px-1 uppercase",children:t.label}):null}function oe({label:s,description:t,value:a,onChange:n,catalog:i,allModels:d,disabled:u}){const{t:r}=se(),o=i?.provider==="codex",p=c.useMemo(()=>Gs(i,d),[d,i]),f=new Set(p.map(j=>j.id)),v=p.map(j=>({value:j.id,groupKey:"recommended",searchText:`${j.id} ${j.name}`,keywords:[j.tier??"",i?.provider??""],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:j.id}),o&&e.jsx(Ce,{modelId:j.id})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:j.id}),j.tier==="paid"&&e.jsx(ya,{label:r("providerModelSelector.paid")}),o&&e.jsx(Ce,{modelId:j.id})]})})),g=d.filter(j=>!f.has(j.id)).map(j=>({value:j.id,groupKey:"all",searchText:j.id,keywords:[j.owned_by],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:j.id}),o&&e.jsx(Ce,{modelId:j.id})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:j.id}),o&&e.jsx(Ce,{modelId:j.id})]})})),L=v.length+g.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(Qt,{value:a||void 0,onChange:n,disabled:u,placeholder:r("providerModelSelector.selectModel"),searchPlaceholder:r("searchableSelect.searchModels"),emptyText:r(L?"searchableSelect.noResults":"providerModelSelector.noModelsAvailable"),triggerClassName:"h-9",groups:[{key:"recommended",label:e.jsx("span",{className:"text-xs text-primary",children:r("providerModelSelector.recommended")})},{key:"all",label:e.jsx("span",{className:"text-xs text-muted-foreground",children:r("providerModelSelector.allModelsCount",{count:d.length})})}],options:[...v,...g]})]})}function wa({open:s,onClose:t,currentValues:a,onApply:n,onSave:i,isSaving:d,catalog:u,allModels:r}){const{t:o}=se(),[p,f]=c.useState(a),[v,g]=c.useState(""),L=j=>{j?(f(a),g("")):t()};return e.jsx(ze,{open:s,onOpenChange:L,children:e.jsxs($e,{className:"sm:max-w-md",children:[e.jsx(Qe,{children:e.jsxs(Je,{className:"flex items-center gap-2",children:[e.jsx(je,{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(Y,{htmlFor:"preset-name",children:o("customPresetDialog.presetNameOptional")}),e.jsx(de,{id:"preset-name",value:v,onChange:j=>g(j.target.value),placeholder:o("customPresetDialog.presetNamePlaceholder"),className:"text-sm"})]}),e.jsx(as,{}),u?.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(oe,{label:o("customPresetDialog.defaultModel"),description:o("customPresetDialog.defaultModelDesc"),value:p.default,onChange:j=>f({...p,default:j}),catalog:u,allModels:r}),e.jsx(oe,{label:o("customPresetDialog.opusModel"),description:o("customPresetDialog.opusModelDesc"),value:p.opus,onChange:j=>f({...p,opus:j}),catalog:u,allModels:r}),e.jsx(oe,{label:o("customPresetDialog.sonnetModel"),description:o("customPresetDialog.sonnetModelDesc"),value:p.sonnet,onChange:j=>f({...p,sonnet:j}),catalog:u,allModels:r}),e.jsx(oe,{label:o("customPresetDialog.haikuModel"),description:o("customPresetDialog.haikuModelDesc"),value:p.haiku,onChange:j=>f({...p,haiku:j}),catalog:u,allModels:r})]}),e.jsxs(ot,{className:"gap-2 sm:gap-0",children:[e.jsx(I,{variant:"outline",onClick:t,children:o("customPresetDialog.cancel")}),i&&e.jsxs(I,{variant:"secondary",onClick:()=>i(p,v||void 0),disabled:d||!v.trim(),children:[d?e.jsx(Z,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(ss,{className:"w-4 h-4 mr-1"}),o("customPresetDialog.savePreset")]}),e.jsxs(I,{onClick:()=>n(p,v||void 0),children:[e.jsx(Ne,{className:"w-4 h-4 mr-1"}),o("customPresetDialog.applyPreset")]})]})]})})}function re({label:s,command:t}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:s}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:t}),e.jsx(Ps,{value:t,size:"icon",className:"h-6 w-6"})]})]})}function Ca({provider:s,displayName:t,defaultTarget:a,data:n,authStatus:i,supportsModelConfig:d=!1}){const u=a||"claude",r=u==="droid",o=s==="codex",p=u==="claude"?`ccs ${s}`:`ccs ${s} --target claude`,f=`${p} --config`,v=`${p} --auth --add`,g=`${p} --accounts`;return e.jsx(We,{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})]}),n&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"File Path"}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:n.path}),e.jsx(Ps,{value:n.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Last Modified"}),e.jsx("span",{className:"text-xs",children:new Date(n.mtime).toLocaleString()})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Status"}),i.authenticated?e.jsxs(G,{variant:"outline",className:"w-fit text-green-600 border-green-200 bg-green-50",children:[e.jsx(Ut,{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:u})]})]})]}),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(re,{label:"Run with prompt",command:`ccs ${s} "your prompt"`}),o&&e.jsxs(e.Fragment,{children:[e.jsx(re,{label:"Run on native Codex (shortcut)",command:'ccsxp "your prompt"'}),e.jsx(re,{label:"Run on native Codex (--target)",command:`ccs ${s} --target codex "your prompt"`})]}),e.jsx(re,{label:r?"Droid alias (explicit)":"Run on Droid",command:`ccs-droid ${s} "your prompt"`}),e.jsx(re,{label:r?"Override to Claude":"Run on Droid (--target)",command:`ccs ${s} --target ${r?"claude":"droid"} "your prompt"`}),d&&e.jsx(re,{label:u==="claude"?"Change model":"Change model (Claude target)",command:f}),e.jsx(re,{label:u==="claude"?"Add account":"Add account (Claude target)",command:v}),e.jsx(re,{label:u==="claude"?"List accounts":"List accounts (Claude target)",command:g}),u!=="claude"&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Account and model-management flags stay on Claude target. Codex and Droid runtime launches reject those CLIProxy management commands."})]})]})]})})}function ka({displayName:s,logoProvider:t,provider:a,data:n,isLoading:i,hasChanges:d,isRawJsonValid:u,isSaving:r,isRemoteMode:o,port:p,onRefetch:f,onSave:v}){return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Xe,{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"]}),p&&e.jsxs(G,{variant:"outline",className:"text-xs gap-1 font-mono",children:[e.jsx(qt,{className:"w-3 h-3"}),":",p]}),!o&&n?.path&&e.jsx(G,{variant:"outline",className:"text-xs",children:n.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"}):n&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",new Date(n.mtime).toLocaleString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{variant:"ghost",size:"sm",onClick:f,disabled:i,children:e.jsx(Ze,{className:`w-4 h-4 ${i?"animate-spin":""}`})}),e.jsx(I,{size:"sm",onClick:v,disabled:r||!d||!u,children:r?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Kt,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function Aa({models:s,provider:t,enabled:a,onToggle:n,disabled:i,className:d}){if(s.length===0)return null;const u=s.some(p=>os(p.id)),r=s.some(p=>!os(p.id));let o="Compatible mappings stay on standard context unless you turn this on.";return u&&r?o="Gemini-compatible mappings can use 1M automatically. Claude mappings stay plain unless you turn this on.":u&&(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",d),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ne,{className: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(Ms,{checked:a,onCheckedChange:n,disabled:i})]}),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 Sa(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 Pa({catalog:s,savedPresets:t,currentModel:a,opusModel:n,sonnetModel:i,haikuModel:d,providerModels:u,provider:r,extendedContextEnabled:o,onExtendedContextToggle:p,onApplyPreset:f,onUpdateEnvValue:v,onOpenCustomPreset:g,onDeletePreset:L,isDeletePending:j}){const w=c.useMemo(()=>{if(!s)return[];const l=[a,n,i,d].filter(C=>!!C).map(C=>lt(C));return[...new Set(l)].map(C=>Hs(s.provider,C)).filter(C=>!!C?.extendedContext)},[s,a,n,i,d]),D=c.useMemo(()=>Gs(s,u),[s,u]),b=c.useMemo(()=>{const l=D.filter(C=>C.presetMapping);return l.length===0?[]:l.some(C=>C.tier==="paid")?[{key:"free",label:"Free Tier",description:"Available on free or paid plans",badgeClassName:"text-[10px] bg-green-100 text-green-700 border-green-200",iconClassName:"text-green-600",models:l.filter(C=>C.tier!=="paid")},{key:"paid",label:"Paid Tier",description:"Requires paid access",badgeClassName:"text-[10px] bg-amber-100 text-amber-700 border-amber-200",iconClassName:"text-amber-700",models:l.filter(C=>C.tier==="paid")}].filter(C=>C.models.length>0):[{key:"default",models:l.slice(0,4)}]},[D]),N=b.length>0||t.length>0;return e.jsxs(e.Fragment,{children:[N&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(je,{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:[b.map(l=>e.jsxs("div",{children:["label"in l&&l.label&&e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(G,{variant:"outline",className:l.badgeClassName,children:l.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:l.description})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l.models.map(A=>e.jsxs(I,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>f(Sa(A)),children:[e.jsx(Ne,{className:`w-3 h-3 ${"iconClassName"in l?l.iconClassName:""}`}),A.name]},A.id))})]},l.key)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.map(l=>e.jsxs("div",{className:"group relative",children:[e.jsxs(I,{variant:"secondary",size:"sm",className:"text-xs h-7 gap-1 pr-6",onClick:()=>{f({ANTHROPIC_MODEL:l.default,ANTHROPIC_DEFAULT_OPUS_MODEL:l.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:l.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:l.haiku})},children:[e.jsx(ss,{className:"w-3 h-3 fill-current"}),l.name]}),e.jsx(I,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-7 w-5 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:A=>{A.stopPropagation(),L(l.name)},disabled:j,children:e.jsx(ts,{className:"w-3 h-3"})})]},l.name)),e.jsxs(I,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1 border-primary/50 text-primary hover:bg-primary/10 hover:border-primary",onClick:g,children:[e.jsx(Is,{className:"w-3 h-3"}),"Custom"]})]})]})]}),e.jsx(as,{}),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"}),r==="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(oe,{label:"Default Model",description:"Used when no specific tier is requested",value:a,onChange:l=>v("ANTHROPIC_MODEL",l),catalog:s,allModels:u}),w.length>0&&p&&e.jsx(Aa,{models:w,provider:r,enabled:o??!1,onToggle:p}),e.jsx(oe,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:n,onChange:l=>v("ANTHROPIC_DEFAULT_OPUS_MODEL",l),catalog:s,allModels:u}),e.jsx(oe,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:i,onChange:l=>v("ANTHROPIC_DEFAULT_SONNET_MODEL",l),catalog:s,allModels:u}),e.jsx(oe,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:d,onChange:l=>v("ANTHROPIC_DEFAULT_HAIKU_MODEL",l),catalog:s,allModels:u})]})]})]})}function Ma(s,t){return s?e.jsx(Fe,{children:e.jsxs(Ue,{children:[e.jsx(qe,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(Gt,{className:"w-3 h-3","aria-hidden":"true"}),e.jsx("span",{className:B("font-mono max-w-[180px] truncate",t&&Be),title:s,children:s})]})}),e.jsx(Ke,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:"GCP Project ID (read-only)"})})]})}):e.jsx(Fe,{children:e.jsxs(Ue,{children:[e.jsx(qe,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-500",children:[e.jsx(es,{className:"w-3 h-3","aria-label":"Warning"}),e.jsx("span",{children:"Project ID: N/A"})]})}),e.jsx(Ke,{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."})]})})]})})}function Da({account:s,onSetDefault:t,onRemove:a,onPauseToggle:n,isRemoving:i,isPausingAccount:d,privacyMode:u,showQuota:r,selectable:o,selected:p,onSelectChange:f}){const v=s.provider.toLowerCase(),{data:g}=ct(r),{data:L,isLoading:j}=dt(v,s.id,r),w=ut(g,s)?.lastUsedAt,D=o||n?e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[o&&e.jsx("button",{type:"button",onClick:()=>f?.(!p),className:B("flex items-center justify-center w-5 h-5 rounded border-2 transition-colors shrink-0",p?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30 hover:border-primary/50"),"aria-label":p?"Deselect account":"Select account",children:p&&e.jsx(ue,{className:"w-3 h-3"})}),n&&e.jsx(Fe,{children:e.jsxs(Ue,{children:[e.jsx(qe,{asChild:!0,children:e.jsx(I,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>n(!s.paused),disabled:d,children:d?e.jsx(Z,{className:"w-4 h-4 animate-spin"}):s.paused?e.jsx(Ls,{className:"w-4 h-4 text-emerald-500"}):e.jsx(_s,{className:"w-4 h-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(Ke,{side:"top",children:s.paused?"Resume account":"Pause account"})]})})]}):void 0,b=e.jsxs(mt,{children:[e.jsx(pt,{asChild:!0,children:e.jsx(I,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(Ht,{className:"w-4 h-4"})})}),e.jsxs(xt,{align:"end",children:[!s.isDefault&&e.jsxs(ls,{onClick:t,children:[e.jsx(ss,{className:"w-4 h-4 mr-2"}),"Set as default"]}),e.jsxs(ls,{className:"text-destructive focus:text-destructive",onClick:a,disabled:i,children:[e.jsx(Fs,{className:"w-4 h-4 mr-2"}),i?"Removing...":"Remove account"]})]})]});return e.jsx("div",{className:B("rounded-lg border p-3 transition-colors overflow-hidden",s.isDefault?"border-primary/30 bg-primary/5":"border-border hover:bg-muted/30",s.paused&&"opacity-75",p&&"ring-2 ring-primary/50 bg-primary/5"),children:e.jsx(ht,{mode:"detailed",provider:s.provider,accountId:s.id,email:s.email,displayEmail:s.email||s.id,tokenFile:s.tokenFile,tier:s.tier,isDefault:s.isDefault,paused:s.paused,privacyMode:u,showQuota:r,quota:L,quotaLoading:j,runtimeLastUsed:w,beforeIdentity:D,headerEnd:b,bodySlot:s.provider==="agy"?Ma(s.projectId,u):null,quotaInsetClassName:"pl-11"})})}function Ta({selectedCount:s,onPauseSelected:t,onResumeSelected:a,onClearSelection:n,isPausing:i,isResuming:d}){if(s<1)return null;const u=i||d;return e.jsxs("div",{className:"flex items-center gap-3 p-2 bg-muted/50 rounded-lg border mt-2",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[s," selected"]}),e.jsx(I,{variant:"ghost",size:"sm",className:"text-xs h-6 px-2",onClick:n,disabled:u,children:"Clear"}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsxs(I,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:t,disabled:u,children:[i?e.jsx(Z,{className:"w-3 h-3 animate-spin"}):e.jsx(_s,{className:"w-3 h-3"}),"Pause Selected"]}),e.jsxs(I,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:a,disabled:u,children:[d?e.jsx(Z,{className:"w-3 h-3 animate-spin"}):e.jsx(Ls,{className:"w-3 h-3"}),"Resume Selected"]})]})]})}function Ea({accounts:s,onAddAccount:t,onSetDefault:a,onRemoveAccount:n,onPauseToggle:i,onSoloMode:d,onBulkPause:u,onBulkResume:r,isRemovingAccount:o,isPausingAccount:p,isSoloingAccount:f,isBulkPausing:v,isBulkResuming:g,privacyMode:L,showQuota:j,isKiro:w,kiroNoIncognito:D,onKiroNoIncognitoChange:b,kiroSettingsLoading:N}){const[l,A]=c.useState(new Set),C=c.useMemo(()=>new Set(s.map(R=>R.id)),[s]),M=c.useMemo(()=>new Set([...l].filter(R=>C.has(R))),[l,C]),m=!!(u&&r),S=M.size,O=s.length>0&&M.size===s.length,q=M.size>0&&M.size<s.length,h=c.useCallback(R=>{A(K=>{const V=new Set(K);return V.has(R)?V.delete(R):V.add(R),V})},[]),k=c.useCallback(()=>{A(new Set(s.map(R=>R.id)))},[s]),y=c.useCallback(()=>{A(new Set)},[]),F=c.useCallback(()=>{O?y():k()},[O,k,y]),H=c.useCallback(()=>{u&&M.size>0&&(u(Array.from(M)),A(new Set))},[u,M]),T=c.useCallback(()=>{r&&M.size>0&&(r(Array.from(M)),A(new Set))},[r,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:[m&&s.length>0&&e.jsx(Se,{checked:O,onCheckedChange:F,"aria-label":"Select all accounts",className:q?"data-[state=checked]:bg-primary/50":"",...q?{"data-state":"indeterminate"}:{}}),e.jsx(fe,{className:"w-4 h-4"}),"Accounts",s.length>0&&e.jsx(G,{variant:"secondary",className:"text-xs",children:s.length})]}),e.jsxs(I,{variant:"default",size:"sm",className:"h-7 text-xs gap-1",onClick:t,children:[e.jsx(Is,{className:"w-3 h-3"}),"Add"]})]}),m&&S>0&&e.jsx(Ta,{selectedCount:S,onPauseSelected:H,onResumeSelected:T,onClearSelection:y,isPausing:!!v,isResuming:!!g}),s.length>0?e.jsx("div",{className:"space-y-2",children:s.map(R=>e.jsx(Da,{account:R,onSetDefault:()=>a(R.id),onRemove:()=>n(R.id),onPauseToggle:i?K=>i(R.id,K):void 0,onSoloMode:d?()=>d(R.id):void 0,isRemoving:o,isPausingAccount:p,isSoloingAccount:f,privacyMode:L,showQuota:j,selectable:m,selected:M.has(R.id),onSelectChange:()=>h(R.id)},R.id))}):e.jsxs("div",{className:"py-6 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed",children:[e.jsx(fe,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No accounts connected"}),e.jsx("p",{className:"text-xs opacity-70",children:"Add an account to get started"})]}),w&&b&&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(Ms,{checked:!D,onCheckedChange:R=>b(!R),disabled:N,className:"scale-90"})]})})]})}function Oa({provider:s,catalog:t,savedPresets:a,currentModel:n,opusModel:i,sonnetModel:d,haikuModel:u,providerModels:r,extendedContextEnabled:o,onExtendedContextToggle:p,onApplyPreset:f,onUpdateEnvValue:v,onOpenCustomPreset:g,onDeletePreset:L,isDeletePending:j,accounts:w,onAddAccount:D,onSetDefault:b,onRemoveAccount:N,onPauseToggle:l,onSoloMode:A,onBulkPause:C,onBulkResume:M,isRemovingAccount:m,isPausingAccount:S,isSoloingAccount:O,isBulkPausing:q,isBulkResuming:h,privacyMode:k,isRemoteMode:y}){const F=s.toLowerCase(),H=(gt.includes(F)||["anthropic","antigravity","gemini-cli","copilot","github-copilot"].includes(F))&&!y,T=s==="kiro",[R,K]=c.useState(!0),[V,te]=c.useState(!0),[W,ae]=c.useState(!1),Q=c.useCallback(async()=>{if(T)try{te(!0);const z=(await ke.config.get()).cliproxy;K(z?.kiro_no_incognito??!0)}catch{K(!0)}finally{te(!1)}},[T]),x=c.useCallback(async E=>{K(E),ae(!0);try{const z=await ke.config.get(),ne=z.cliproxy??{};await ke.config.update({...z,cliproxy:{...ne,kiro_no_incognito:E}})}catch{K(!E)}finally{ae(!1)}},[]);return c.useEffect(()=>{Q()},[Q]),e.jsx(We,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsx(Pa,{catalog:t,savedPresets:a,currentModel:n,opusModel:i,sonnetModel:d,haikuModel:u,providerModels:r,provider:s,extendedContextEnabled:o,onExtendedContextToggle:p,onApplyPreset:f,onUpdateEnvValue:v,onOpenCustomPreset:g,onDeletePreset:L,isDeletePending:j}),e.jsx(as,{}),e.jsx(Ea,{accounts:w,onAddAccount:D,onSetDefault:b,onRemoveAccount:N,onPauseToggle:l,onSoloMode:A,onBulkPause:C,onBulkResume:M,isRemovingAccount:m,isPausingAccount:S,isSoloingAccount:O,isBulkPausing:q,isBulkResuming:h,privacyMode:k,showQuota:H,isKiro:T,kiroNoIncognito:R,onKiroNoIncognitoChange:x,kiroSettingsLoading:V||W})]})})}function xs({provider:s,displayName:t,authStatus:a,catalog:n,logoProvider:i,baseProvider:d,isRemoteMode:u,port:r,defaultTarget:o,onAddAccount:p,onSetDefault:f,onRemoveAccount:v,onPauseToggle:g,onSoloMode:L,onBulkPause:j,onBulkResume:w,isRemovingAccount:D,isPausingAccount:b,isSoloingAccount:N,isBulkPausing:l,isBulkResuming:A}){const[C,M]=c.useState(!1),{privacyMode:m}=Cs(),{data:S}=ft(),{data:O}=vt(s),q=jt(),h=Nt(),k=d||s,y=k.toLowerCase()==="agy",F=c.useMemo(()=>{const _=O?.presets||[];return y?_.filter($=>!ee($.default)&&!ee($.opus)&&!ee($.sonnet)&&!ee($.haiku)):_},[y,O?.presets]),H=c.useMemo(()=>{if(!S?.models)return[];const $={gemini:["google"],agy:["antigravity"],codex:["openai"],qwen:["alibaba","qwen"],iflow:["iflow"],kiro:["kiro","aws"],ghcp:["github","copilot"],kimi:["kimi","moonshot"]}[k.toLowerCase()]||[k.toLowerCase()];return S.models.filter(ie=>$.some(Ee=>ie.owned_by.toLowerCase().includes(Ee))?y?!ee(ie.id):!0:!1)},[y,S,k]),T=(d||s).toLowerCase(),{data:R,isLoading:K,refetch:V,rawJsonContent:te,rawJsonEdits:W,isRawJsonValid:ae,hasChanges:Q,currentModel:x,opusModel:E,sonnetModel:z,haikuModel:ne,extendedContextEnabled:xe,toggleExtendedContext:be,handleRawJsonChange:Me,updateEnvValue:De,updateEnvValues:ye,saveMutation:we,conflictDialog:Te,handleConflictResolve:J,missingRequiredFields:P}=va(s),X=c.useMemo(()=>(a.accounts||[]).map(_=>({..._,provider:_.provider||d||s})),[a.accounts,d,s]),{data:he}=hs({queryKey:["auth-tokens-raw"],queryFn:async()=>{const _=await fetch("/api/settings/auth/tokens/raw");return _.ok?_.json():{apiKey:{value:"ccs-internal-managed"}}},staleTime:6e4}),le=he?.apiKey?.value??"ccs-internal-managed",Bs=_=>{if(y&&[_.ANTHROPIC_MODEL,_.ANTHROPIC_DEFAULT_OPUS_MODEL,_.ANTHROPIC_DEFAULT_SONNET_MODEL,_.ANTHROPIC_DEFAULT_HAIKU_MODEL].some(ie=>typeof ie=="string"&&ee(ie))){U.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}ye({ANTHROPIC_BASE_URL:`http://127.0.0.1:${r??He}/api/provider/${T}`,ANTHROPIC_AUTH_TOKEN:le,..._}),U.success(`Applied "${_.ANTHROPIC_MODEL?.split("/").pop()||"preset"}" preset`)},zs=(_,$)=>{if(y&&[_.default,_.opus,_.sonnet,_.haiku].some(Ee=>ee(Ee))){U.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}ye({ANTHROPIC_BASE_URL:`http://127.0.0.1:${r??He}/api/provider/${T}`,ANTHROPIC_AUTH_TOKEN:le,ANTHROPIC_MODEL:_.default,ANTHROPIC_DEFAULT_OPUS_MODEL:_.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:_.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:_.haiku}),U.success(`Applied ${$?`"${$}"`:"custom"} preset`),M(!1)},$s=(_,$)=>{if(!$){U.error(As.t("commonToast.enterPresetName"));return}if(y&&[_.default,_.opus,_.sonnet,_.haiku].some(ie=>ee(ie))){U.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}q.mutate({profile:s,data:{name:$,..._}}),M(!1)};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(ka,{provider:s,displayName:t,logoProvider:i,data:R,isLoading:K,hasChanges:Q,isRawJsonValid:ae,isSaving:we.isPending,isRemoteMode:u,port:r,onRefetch:V,onSave:()=>we.mutate()}),K?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(Z,{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(bt,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(yt,{className:"w-full",children:[e.jsx(cs,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(cs,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(ds,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(Oa,{provider:s,catalog:n,savedPresets:F,currentModel:x,opusModel:E,sonnetModel:z,haikuModel:ne,providerModels:H,extendedContextEnabled:xe,onExtendedContextToggle:be,onApplyPreset:Bs,onUpdateEnvValue:De,onOpenCustomPreset:()=>M(!0),onDeletePreset:_=>h.mutate({profile:s,name:_}),isDeletePending:h.isPending,accounts:X,onAddAccount:p,onSetDefault:f,onRemoveAccount:v,onPauseToggle:g,onSoloMode:L,onBulkPause:j,onBulkResume:w,isRemovingAccount:D,isPausingAccount:b,isSoloingAccount:N,isBulkPausing:l,isBulkResuming:A,privacyMode:m,isRemoteMode:u})}),e.jsx(ds,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(Ca,{provider:s,displayName:t,defaultTarget:o,data:R,authStatus:a,supportsModelConfig:!!n})})]})]})}),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(Vt,{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(wt,{rawJsonContent:te,isRawJsonValid:ae,rawJsonEdits:W,onRawJsonChange:Me,profileEnv:R?.settings?.env,missingRequiredFields:P})]})]}),e.jsx($t,{open:Te,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(wa,{open:C,onClose:()=>M(!1),currentValues:{default:x||"",opus:E||"",sonnet:z||"",haiku:ne||""},onApply:zs,onSave:$s,isSaving:q.isPending,catalog:n,allModels:H})]})}function Ra({status:s,isSelected:t,onSelect:a}){const{t:n}=se(),i=s.accounts?.length||0;return e.jsxs("button",{className:B("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors cursor-pointer text-left",t?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:a,children:[e.jsx(Xe,{provider:s.provider,size:"md"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:s.displayName}),i>0&&e.jsx(G,{variant:"secondary",className:"text-[10px] h-4 px-1",children:i})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:s.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-green-600",children:n("cliproxyPage.connected")})]}):e.jsxs(e.Fragment,{children:[e.jsx(ts,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:n("cliproxyPage.notConnected")})]})})]})]})}function Ia({variant:s,parentAuth:t,isSelected:a,onSelect:n,onDelete:i,isDeleting:d}){const{t:u}=se(),r=()=>{n()};return e.jsxs("div",{role:"button",tabIndex:0,className:B("group w-full flex items-center gap-3 px-3 py-2 rounded-lg transition-colors cursor-pointer text-left pl-6",a?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:r,onKeyDown:o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),r())},children:[e.jsxs("div",{className:"relative",children:[e.jsx(Xe,{provider:s.provider,size:"sm"}),e.jsx(Us,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5 text-muted-foreground"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:s.name}),e.jsx(G,{variant:"outline",className:"text-[9px] h-4 px-1",children:u("cliproxyPage.variant")}),e.jsx(G,{variant:"outline",className:"text-[9px] h-4 px-1 uppercase",children:s.target||"claude"})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:t?.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-muted-foreground truncate",children:u("cliproxyPage.viaProvider",{provider:s.provider})})]}):e.jsxs(e.Fragment,{children:[e.jsx(ts,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:u("cliproxyPage.parentNotConnected")})]})})]}),e.jsx(I,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:o=>{o.stopPropagation(),i()},disabled:d,children:e.jsx(Fs,{className:"w-3 h-3"})})]})}function La({onSetup:s}){const{t}=se();return e.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/20",children:e.jsxs("div",{className:"text-center max-w-md px-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-muted flex items-center justify-center mx-auto mb-6",children:e.jsx(Ne,{className:"w-8 h-8 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:t("cliproxyPage.emptyTitle")}),e.jsx("p",{className:"text-muted-foreground mb-4",children:t("cliproxyPage.emptyDesc")}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-6",children:[t("cliproxyPage.emptyControlPanelPrefix")," ",e.jsx("a",{href:"/cliproxy/control-panel",className:"text-primary hover:underline",children:t("cliproxyPage.controlPanel")}),"."]}),e.jsxs(I,{onClick:s,className:"gap-2",children:[e.jsx(je,{className:"w-4 h-4"}),t("cliproxyPage.quickSetup")]})]})})}function en(){const{t:s}=se(),t=Ve(),{data:a,isLoading:n}=ws(),{data:i,isFetching:d}=Ct(),{data:u}=kt(),r=At(),o=St(),p=Pt(),f=Mt(),v=Dt(),g=Tt(),L=Et(),j=Ot(),[w,D]=c.useState(()=>{if(typeof window<"u"){const E=new URLSearchParams(window.location.search).get("provider")?.trim().toLowerCase();return E&&_e(E)?E:localStorage.getItem("cliproxy-selected-provider")}return null}),[b,N]=c.useState(null),[l,A]=c.useState(!1),[C,M]=c.useState(()=>{if(typeof window>"u")return null;const x=new URLSearchParams(window.location.search),E=x.get("provider")?.trim().toLowerCase();return x.get("action")!=="auth"||!E||!_e(E)?null:{provider:E,displayName:Rt(E),isFirstAccount:!1}}),m=c.useMemo(()=>a?.authStatus||[],[a?.authStatus]),S=a?.source==="remote",O=c.useMemo(()=>i?.variants||[],[i?.variants]),q=x=>{D(x),x&&localStorage.setItem("cliproxy-selected-provider",x)},h=c.useMemo(()=>b?null:w&&m.some(x=>x.provider===w)?w:m.length>0&&(m.find(E=>(E.accounts?.length||0)>0)?.provider||m[0]?.provider)||null,[w,b,m]),k=m.find(x=>x.provider===h),y=O.find(x=>x.name===b),F=y?m.find(x=>x.provider===y.provider):void 0,H=(y?.provider||k?.provider||"").toLowerCase().trim(),T=H==="gemini"||H==="agy",R=()=>{t.invalidateQueries({queryKey:["cliproxy"]}),t.invalidateQueries({queryKey:["cliproxy-auth"]})},K=(x,E,z)=>{p.isPending||f.isPending||(z?p.mutate({provider:x,accountId:E}):f.mutate({provider:x,accountId:E}))},V=(x,E)=>{v.isPending||v.mutate({provider:x,accountId:E})},te=(x,E)=>{g.isPending||g.mutate({provider:x,accountIds:E})},W=(x,E)=>{L.isPending||L.mutate({provider:x,accountIds:E})},ae=x=>{q(x),N(null)},Q=x=>{N(x),q(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(Ne,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:u?.backendLabel??"CLIProxy"})]}),e.jsx(I,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:R,disabled:d,children:e.jsx(Ze,{className:B("w-4 h-4",d&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:s("cliproxyPage.accountManagement")}),e.jsxs(I,{variant:"default",size:"sm",className:"w-full gap-2",onClick:()=>A(!0),children:[e.jsx(je,{className:"w-4 h-4"}),s("cliproxyPage.quickSetup")]})]}),e.jsx(We,{className:"flex-1",children:e.jsxs("div",{className:"p-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3 py-2",children:s("cliproxyPage.providers")}),n?e.jsx("div",{className:"space-y-2 px-2",children:[1,2,3,4].map(x=>e.jsx(It,{className:"h-14 w-full rounded-lg"},x))}):e.jsx("div",{className:"space-y-1",children:m.map(x=>e.jsx(Ra,{status:x,isSelected:h===x.provider,onSelect:()=>ae(x.provider)},x.provider))}),O.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(Us,{className:"w-3 h-3"}),s("cliproxyPage.variants")]}),e.jsx("div",{className:"space-y-1",children:O.map(x=>e.jsx(Ia,{variant:x,parentAuth:m.find(E=>E.provider===x.provider),isSelected:b===x.name,onSelect:()=>Q(x.name),onDelete:()=>j.mutate(x.name),isDeleting:j.isPending},x.name))})]})]})}),e.jsx("div",{className:"p-3 border-t",children:e.jsx(Jt,{})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:s("cliproxyPage.providerCount",{count:m.length})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ue,{className:"w-3 h-3 text-green-600"}),s("cliproxyPage.connectedCount",{count:m.filter(x=>x.authenticated).length})]})]})})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0 bg-background",children:[T&&e.jsx(Vs,{showProxySettingsLink:!0,className:"mx-4 mt-4"}),y&&F?e.jsx(e.Fragment,{children:e.jsx(xs,{provider:y.name,displayName:s("cliproxyPage.variantDisplay",{name:y.name,provider:y.provider}),authStatus:F,catalog:pe[y.provider],logoProvider:y.provider,baseProvider:y.provider,defaultTarget:y.target,isRemoteMode:S,port:y.port,onAddAccount:()=>M({provider:y.provider,displayName:F.displayName,isFirstAccount:(F.accounts?.length||0)===0}),onSetDefault:x=>r.mutate({provider:y.provider,accountId:x}),onRemoveAccount:x=>o.mutate({provider:y.provider,accountId:x}),onPauseToggle:(x,E)=>K(y.provider,x,E),onSoloMode:x=>V(y.provider,x),onBulkPause:x=>te(y.provider,x),onBulkResume:x=>W(y.provider,x),isRemovingAccount:o.isPending,isPausingAccount:p.isPending||f.isPending,isSoloingAccount:v.isPending,isBulkPausing:g.isPending,isBulkResuming:L.isPending})}):k?e.jsx(e.Fragment,{children:e.jsx(xs,{provider:k.provider,displayName:k.displayName,authStatus:k,catalog:pe[k.provider],isRemoteMode:S,onAddAccount:()=>M({provider:k.provider,displayName:k.displayName,isFirstAccount:(k.accounts?.length||0)===0}),onSetDefault:x=>r.mutate({provider:k.provider,accountId:x}),onRemoveAccount:x=>o.mutate({provider:k.provider,accountId:x}),onPauseToggle:(x,E)=>K(k.provider,x,E),onSoloMode:x=>V(k.provider,x),onBulkPause:x=>te(k.provider,x),onBulkResume:x=>W(k.provider,x),isRemovingAccount:o.isPending,isPausingAccount:p.isPending||f.isPending,isSoloingAccount:v.isPending,isBulkPausing:g.isPending,isBulkResuming:L.isPending})}):e.jsx(La,{onSetup:()=>A(!0)})]}),e.jsx(la,{open:l,onClose:()=>A(!1)}),e.jsx(ha,{open:C!==null,onClose:()=>M(null),provider:C?.provider||"",displayName:C?.displayName||"",isFirstAccount:C?.isFirstAccount||!1})]})}export{en as CliproxyPage};
@@ -1,3 +0,0 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{b1 as w,b2 as Pe,B as S,d as N,a as ie,U as ne,v as H,L as T,ay as X,I as ce,p as ke,q as Fe,r as Te,s as Me,t as Y,w as he,b3 as Le,S as b,b4 as Re,b5 as Ae,b6 as Oe,O as Ee,Q as qe,R as Z,b7 as _e,c as se}from"./index-CKNvmYLR.js";import{r as v}from"./react-vendor-CNOkPC89.js";import{a as De,u as q,b as M}from"./tanstack-DWm6aJ-G.js";import{C as Ie}from"./confirm-dialog-C5COcZYh.js";import{R as ge,L as fe,an as Ke,a6 as Qe,Z as de,Q as Ue,T as je,aq as Je,b as $e,a9 as ze,aw as Be,aI as me,K as Ge,O as He,aJ as We,v as ve,z as we}from"./icons-DhBsHU-U.js";import{S as ae}from"./separator-vdIGU0ab.js";import{S as Ve}from"./searchable-select-DNmazsgI.js";import{t as _}from"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-DudTubF8.js";async function Xe(){const t=await fetch(w("/copilot/status"));if(!t.ok)throw new Error("Failed to fetch copilot status");return t.json()}async function Ye(){const t=await fetch(w("/copilot/config"));if(!t.ok)throw new Error("Failed to fetch copilot config");return t.json()}async function Ze(){const t=await fetch(w("/copilot/models"));if(!t.ok)throw new Error("Failed to fetch copilot models");return t.json()}async function et(){const t=await fetch(w("/copilot/settings/raw"));if(!t.ok)throw new Error("Failed to fetch copilot raw settings");return t.json()}async function tt(t){const s=await fetch(w("/copilot/config"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!s.ok)throw new Error("Failed to update copilot config");return s.json()}async function st(t){const s=await fetch(w("/copilot/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(s.status===409)throw new Pe("Copilot raw settings changed externally");if(!s.ok)throw new Error("Failed to save copilot raw settings");return s.json()}async function at(){const t=await fetch(w("/copilot/auth/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start auth");return t.json()}async function it(){const t=await fetch(w("/copilot/daemon/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start daemon");return t.json()}async function nt(){const t=await fetch(w("/copilot/daemon/stop"),{method:"POST"});if(!t.ok)throw new Error("Failed to stop daemon");return t.json()}async function ot(){const t=await fetch(w("/copilot/info"));if(!t.ok)throw new Error("Failed to fetch copilot info");return t.json()}async function lt(t){const s=await fetch(w("/copilot/install"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{version:t}:{})});if(!s.ok)throw new Error("Failed to install copilot-api");return s.json()}function Ne(){const t=De(),s=q({queryKey:["copilot-status"],queryFn:Xe,refetchInterval:5e3}),l=q({queryKey:["copilot-config"],queryFn:Ye}),c=q({queryKey:["copilot-models"],queryFn:Ze}),i=q({queryKey:["copilot-raw-settings"],queryFn:et}),d=q({queryKey:["copilot-info"],queryFn:ot}),r=M({mutationFn:tt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),n=M({mutationFn:st,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),x=M({mutationFn:at,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),p=M({mutationFn:it,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),g=M({mutationFn:nt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),o=M({mutationFn:lt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-info"]})}});return v.useMemo(()=>({status:s.data,statusLoading:s.isLoading,statusError:s.error,refetchStatus:s.refetch,config:l.data,configLoading:l.isLoading,models:c.data?.models??[],currentModel:c.data?.current,modelsLoading:c.isLoading,rawSettings:i.data,rawSettingsLoading:i.isLoading,refetchRawSettings:i.refetch,updateConfig:r.mutate,updateConfigAsync:r.mutateAsync,isUpdating:r.isPending,saveRawSettings:n.mutate,saveRawSettingsAsync:n.mutateAsync,isSavingRawSettings:n.isPending,startAuth:x.mutate,startAuthAsync:x.mutateAsync,isAuthenticating:x.isPending,authResult:x.data,startDaemon:p.mutate,isStartingDaemon:p.isPending,stopDaemon:g.mutate,isStoppingDaemon:g.isPending,info:d.data,infoLoading:d.isLoading,refetchInfo:d.refetch,install:o.mutate,installAsync:o.mutateAsync,isInstalling:o.isPending}),[s.data,s.isLoading,s.error,s.refetch,l.data,l.isLoading,c.data,c.isLoading,i.data,i.isLoading,i.refetch,r.mutate,r.mutateAsync,r.isPending,n.mutate,n.mutateAsync,n.isPending,x.mutate,x.mutateAsync,x.isPending,x.data,p.mutate,p.isPending,g.mutate,g.isPending,d.data,d.isLoading,d.refetch,o.mutate,o.mutateAsync,o.isPending])}function rt({rawSettings:t,rawSettingsLoading:s,isUpdating:l,isSavingRawSettings:c,hasChanges:i,isRawJsonValid:d,onRefresh:r,onSave:n}){return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Copilot Configuration"}),t&&e.jsx(S,{variant:"outline",className:"text-xs",children:"copilot.settings.json"})]}),t&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified:"," ",t.exists?new Date(t.mtime).toLocaleString():"Never saved"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{variant:"ghost",size:"sm",onClick:r,disabled:s,children:e.jsx(ge,{className:`w-4 h-4 ${s?"animate-spin":""}`})}),e.jsx(N,{size:"sm",onClick:n,disabled:l||c||!i||!d,children:l||c?e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ke,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}const ct=[{name:"GPT-4.1 (Free)",description:"Free tier - no premium usage",default:"gpt-4.1",opus:"gpt-4.1",sonnet:"gpt-4.1",haiku:"gpt-4.1"},{name:"GPT-5 Mini (Free)",description:"Free tier - lightweight model",default:"gpt-5-mini",opus:"gpt-5-mini",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"}],dt=[{name:"Claude Opus 4.5",description:"Pro+ (3x) - Most capable reasoning",default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"Claude Sonnet 4.5",description:"Pro+ (1x) - Balanced performance",default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"GPT-5.2",description:"Pro+ (1x) - Latest OpenAI (Preview)",default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"},{name:"GPT-5.1 Codex Max",description:"Pro+ (1x) - Best for coding",default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex",haiku:"gpt-5.1-codex-mini"},{name:"Gemini 2.5 Pro",description:"Pro+ (1x) - Google latest",default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-3-flash"}];function ue(t){switch(t){case"free":return"bg-green-100 text-green-700 border-green-200";case"pro":return"bg-blue-100 text-blue-700 border-blue-200";case"pro+":return"bg-purple-100 text-purple-700 border-purple-200";case"business":return"bg-orange-100 text-orange-700 border-orange-200";case"enterprise":return"bg-red-100 text-red-700 border-red-200";default:return"bg-muted text-muted-foreground"}}function mt(t){return t==null?null:t===0?"Free":t<1?`${t}x`:t===1?"1x":`${t}x`}function z({label:t,description:s,value:l,onChange:c,models:i,disabled:d}){const{t:r}=ie();return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:t}),s&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s})]}),e.jsx(Ve,{value:l||void 0,onChange:c,disabled:d,placeholder:r("componentModelSelector.selectModel"),searchPlaceholder:r("searchableSelect.searchModels"),emptyText:r("searchableSelect.noResults"),triggerClassName:"h-9",groups:[{key:"models",label:r("componentModelSelector.availableModelsCount",{count:i.length})}],options:i.map(n=>({value:n.id,groupKey:"models",searchText:`${n.name||n.id} ${n.id}`,keywords:[n.minPlan??"",n.preview?"preview":""],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:n.id}),n.minPlan&&e.jsx(S,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ue(n.minPlan)}`,children:n.minPlan})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:n.name||n.id}),n.minPlan&&e.jsx(S,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ue(n.minPlan)}`,children:n.minPlan}),n.multiplier!==void 0&&e.jsx("span",{className:"text-[9px] text-muted-foreground",children:mt(n.multiplier)}),n.preview&&e.jsx(S,{variant:"secondary",className:"text-[9px] px-1 py-0 h-4",children:r("componentModelSelector.preview")})]})}))})]})}function ee(t){if(t>=1e6){const s=t/1e6;return s%1===0?`${s}M`:`${s.toFixed(1)}M`}if(t>=1e3){const s=t/1e3;return s%1===0?`${s}K`:`${s.toFixed(1)}K`}return`${t}`}function ut(t){if(!t?.limits)return null;const s=[];return t.limits.maxPromptTokens&&s.push(`prompt ${ee(t.limits.maxPromptTokens)}`),t.limits.maxContextWindowTokens&&s.push(`context ${ee(t.limits.maxContextWindowTokens)}`),t.limits.maxOutputTokens&&s.push(`output ${ee(t.limits.maxOutputTokens)}`),s.length>0?s.join(" | "):null}function xt({currentModel:t,opusModel:s,sonnetModel:l,haikuModel:c,models:i,modelsLoading:d,onApplyPreset:r,onUpdateModel:n,onUpdateOpusModel:x,onUpdateSonnetModel:p,onUpdateHaikuModel:g}){const o=[{label:"Default",id:t},{label:"Opus",id:s||t},{label:"Sonnet",id:l||t},{label:"Haiku",id:c||t}].map(({label:a,id:u})=>{const y=i.find(P=>P.id===u),C=ut(y);return C?{label:a,id:u,limits:C}:null}).filter(a=>a!==null);return e.jsx(ne,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(H,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(Qe,{className:"w-4 h-4"}),"Presets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Apply pre-configured model mappings"}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(S,{variant:"outline",className:"text-[10px] bg-green-100 text-green-700 border-green-200",children:"Free Tier"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"No premium usage count"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ct.map(a=>e.jsxs(N,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>r(a),title:a.description,children:[e.jsx(de,{className:"w-3 h-3 text-green-600"}),a.name]},a.name))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(S,{variant:"outline",className:"text-[10px] bg-blue-100 text-blue-700 border-blue-200",children:"Pro+ Required"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Uses premium request quota"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:dt.map(a=>e.jsxs(N,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>r(a),title:a.description,children:[e.jsx(de,{className:"w-3 h-3"}),a.name]},a.name))})]})]}),e.jsx(ae,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:"Model Mapping"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),e.jsxs("div",{className:"mb-4 rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-xs text-amber-900 dark:text-amber-200",children:[e.jsx("p",{className:"font-medium",children:"GitHub Copilot controls prompt/context limits upstream."}),e.jsx("p",{className:"mt-1",children:"CCS can switch Copilot models, but it cannot increase the provider's max prompt or context window."}),o.length>0?e.jsx("div",{className:"mt-2 space-y-1 text-[11px] font-mono",children:o.map(a=>e.jsxs("p",{children:[a.label,": ",a.id," (",a.limits,")"]},`${a.label}-${a.id}`))}):e.jsx("p",{className:"mt-2 text-[11px] font-mono",children:"Start the daemon to inspect live model limits from GitHub Copilot metadata."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(z,{label:"Default Model",description:"Used when no specific tier is requested",value:t,onChange:n,models:i,disabled:d}),e.jsx(z,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:s||t,onChange:x,models:i,disabled:d}),e.jsx(z,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:l||t,onChange:p,models:i,disabled:d}),e.jsx(z,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:c||t,onChange:g,models:i,disabled:d})]})]})]})})})}function pt({enabled:t,autoStart:s,port:l,accountType:c,rateLimit:i,waitOnLimit:d,onUpdateEnabled:r,onUpdateAutoStart:n,onUpdatePort:x,onUpdateAccountType:p,onUpdateRateLimit:g,onUpdateWaitOnLimit:o}){const{t:a}=ie();return e.jsx(ne,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(H,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(T,{htmlFor:"enabled",className:"text-sm font-medium",children:a("copilotSettings.enableCopilot")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("copilotSettings.enableCopilotDesc")})]}),e.jsx(X,{id:"enabled",checked:t,onCheckedChange:r})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:a("copilotSettings.basicSettings")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"port",className:"text-xs",children:a("copilotPage.port")}),e.jsx(ce,{id:"port",type:"number",value:l,onChange:u=>x(parseInt(u.target.value,10)),min:1024,max:65535,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"account-type",className:"text-xs",children:a("copilotSettings.accountType")}),e.jsxs(ke,{value:c,onValueChange:p,children:[e.jsx(Fe,{id:"account-type",className:"max-w-[150px] h-8",children:e.jsx(Te,{})}),e.jsxs(Me,{children:[e.jsx(Y,{value:"individual",children:a("copilotSettings.accountTypeIndividual")}),e.jsx(Y,{value:"business",children:a("copilotSettings.accountTypeBusiness")}),e.jsx(Y,{value:"enterprise",children:a("copilotSettings.accountTypeEnterprise")})]})]})]})]}),e.jsx(ae,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:a("copilotSettings.rateLimiting")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"rate-limit",className:"text-xs",children:a("copilotSettings.rateLimitSeconds")}),e.jsx(ce,{id:"rate-limit",type:"number",value:i,onChange:u=>g(u.target.value),placeholder:a("copilotSettings.noLimit"),min:0,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(T,{htmlFor:"wait-on-limit",className:"text-xs",children:a("copilotSettings.waitOnRateLimit")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a("copilotSettings.waitOnRateLimitDesc")})]}),e.jsx(X,{id:"wait-on-limit",checked:d,onCheckedChange:o})]})]}),e.jsx(ae,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:a("copilotSettings.daemonSettings")}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(T,{htmlFor:"auto-start",className:"text-xs",children:a("copilotSettings.autoStartDaemon")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a("copilotSettings.autoStartDaemonDesc")})]}),e.jsx(X,{id:"auto-start",checked:s,onCheckedChange:n})]})]})]})})})}function B({label:t,command:s}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:t}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:s}),e.jsx(he,{value:s,size:"icon",className:"h-6 w-6"})]})]})}function ht({rawSettings:t}){return e.jsx(ne,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(H,{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(Ue,{className:"w-4 h-4"}),"Configuration Info"]}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Provider"}),e.jsx("span",{className:"font-mono",children:"GitHub Copilot"})]}),t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"File Path"}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:t.path}),e.jsx(he,{value:t.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Status"}),e.jsx(S,{variant:"outline",className:t.exists?"w-fit text-green-600 border-green-200 bg-green-50":"w-fit text-muted-foreground",children:t.exists?"File exists":"Using defaults"})]})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Quick Usage"}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsx(B,{label:"Run with Copilot",command:"ccs copilot"}),e.jsx(B,{label:"Authenticate",command:"ccs copilot auth"}),e.jsx(B,{label:"Start daemon",command:"ccs copilot --start"}),e.jsx(B,{label:"Stop daemon",command:"ccs copilot --stop"})]})]})]})})})}const gt=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function xe(t){const s=t?.env||{};return gt.filter(l=>!s[l]?.trim())}function pe(t){if(!t||t.length===0)return[];const s=new Map;return t.forEach(l=>{s.set(l.message,l)}),[...s.values()]}function ft(){const{config:t,configLoading:s,models:l,modelsLoading:c,rawSettings:i,rawSettingsLoading:d,updateConfigAsync:r,isUpdating:n,saveRawSettingsAsync:x,isSavingRawSettings:p,refetchRawSettings:g}=Ne(),[o,a]=v.useState({}),[u,y]=v.useState(null),[C,P]=v.useState(!1),D=o.enabled??t?.enabled??!1,I=o.autoStart??t?.auto_start??!1,L=o.port??t?.port??4141,K=o.accountType??t?.account_type??"individual",R=o.model??t?.model??"claude-sonnet-4-6",A=o.rateLimit??t?.rate_limit?.toString()??"",f=o.waitOnLimit??t?.wait_on_limit??!0,Q=o.opusModel??t?.opus_model??"",U=o.sonnetModel??t?.sonnet_model??"",J=o.haikuModel??t?.haiku_model??"",$=(h,j)=>{a(O=>({...O,[h]:j}))},W=h=>{a(j=>({...j,model:h.default,opusModel:h.opus,sonnetModel:h.sonnet,haikuModel:h.haiku})),_.success(`Applied "${h.name}" preset`)},k=v.useMemo(()=>u!==null?u:i?.settings?JSON.stringify(i.settings,null,2):`{
2
- "env": {}
3
- }`,[u,i]),m=v.useCallback(h=>{y(h)},[]),oe=v.useMemo(()=>{try{return JSON.parse(k),!0}catch{return!1}},[k]),be=v.useMemo(()=>{const h=Object.keys(o).length>0,j=u!==null&&u!==JSON.stringify(i?.settings,null,2);return h||j},[o,u,i]),le=v.useMemo(()=>{if(u!==null)try{return JSON.parse(u)}catch{return i?.settings}return i?.settings},[u,i?.settings]),ye=v.useMemo(()=>xe(le),[le]),Se=v.useMemo(()=>pe([...t?.warnings??[],...i?.warnings??[]]),[t?.warnings,i?.warnings]),re=async({overwriteRawSettings:h=!1}={})=>{try{const j=[];if(Object.keys(o).length>0){const F=await r({enabled:D,auto_start:I,port:L,account_type:K,model:R,rate_limit:A?parseInt(A,10):null,wait_on_limit:f,opus_model:Q||void 0,sonnet_model:U||void 0,haiku_model:J||void 0});j.push(...F.warnings??[])}let O=[];if(u!==null&&oe){const F=JSON.parse(k);O=xe(F);const Ce=await x({settings:F,expectedMtime:h?void 0:i?.mtime});j.push(...Ce.warnings??[])}const V=pe(j),E=[];V.length>0&&E.push(V.map(F=>F.message).join(" ")),O.length>0&&E.push(`Missing fields will use defaults: ${O.join(", ")}`),V.length>0?_.warning("Copilot configuration saved with model adjustments",{description:E.join(" ")}):E.length>0?_.success("Copilot configuration saved",{description:E.join(" ")}):_.success("Copilot configuration saved"),a({}),y(null)}catch(j){Le(j)?P(!0):_.error("Failed to save settings")}};return{configLoading:s,rawSettingsLoading:d,modelsLoading:c,isUpdating:n,isSavingRawSettings:p,models:l,rawSettings:i,rawJsonContent:k,rawJsonEdits:u,enabled:D,autoStart:I,port:L,accountType:K,currentModel:R,rateLimit:A,waitOnLimit:f,opusModel:Q,sonnetModel:U,haikuModel:J,isRawJsonValid:oe,hasChanges:be,normalizationWarnings:Se,conflictDialog:C,updateField:$,applyPreset:W,handleRawJsonChange:m,handleSave:re,handleConflictResolve:async h=>{P(!1),h?await re({overwriteRawSettings:!0}):y(null)},refetchRawSettings:g,missingRequiredFields:ye}}function jt(){const{configLoading:t,rawSettingsLoading:s,modelsLoading:l,isUpdating:c,isSavingRawSettings:i,models:d,rawSettings:r,rawJsonContent:n,rawJsonEdits:x,enabled:p,autoStart:g,port:o,accountType:a,currentModel:u,rateLimit:y,waitOnLimit:C,opusModel:P,sonnetModel:D,haikuModel:I,isRawJsonValid:L,hasChanges:K,normalizationWarnings:R,conflictDialog:A,updateField:f,applyPreset:Q,handleRawJsonChange:U,handleSave:J,handleConflictResolve:$,refetchRawSettings:W,missingRequiredFields:k}=ft();return t||s?e.jsxs("div",{className:"space-y-6",children:[e.jsx(b,{className:"h-10 w-full"}),e.jsx(b,{className:"h-10 w-full"}),e.jsx(b,{className:"h-10 w-full"}),e.jsx(b,{className:"h-10 w-full"})]}):e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(rt,{rawSettings:r,rawSettingsLoading:s,isUpdating:c,isSavingRawSettings:i,hasChanges:K,isRawJsonValid:L,onRefresh:()=>W(),onSave:J}),R.length>0&&e.jsx("div",{className:"px-6 pt-4 shrink-0",children:e.jsxs(Re,{variant:"warning",children:[e.jsx(je,{className:"h-4 w-4"}),e.jsx(Ae,{children:"Deprecated Copilot models detected"}),e.jsxs(Oe,{className:"space-y-2",children:[e.jsx("p",{children:"Loading this page did not rewrite your files. Save the Copilot configuration to persist these replacements."}),e.jsx("div",{className:"space-y-1",children:R.map(m=>e.jsx("p",{children:m.message},m.message))})]})]})}),e.jsxs("div",{className:"flex-1 flex divide-x overflow-hidden",children:[e.jsx("div",{className:"w-[540px] shrink-0 flex flex-col overflow-hidden bg-muted/5",children:e.jsx("div",{className:"h-full flex flex-col",children:e.jsxs(Ee,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(qe,{className:"w-full",children:[e.jsx(Z,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(Z,{value:"settings",className:"flex-1",children:"Settings"}),e.jsx(Z,{value:"info",className:"flex-1",children:"Info"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(xt,{currentModel:u,opusModel:P,sonnetModel:D,haikuModel:I,models:d,modelsLoading:l,onApplyPreset:Q,onUpdateModel:m=>f("model",m),onUpdateOpusModel:m=>f("opusModel",m),onUpdateSonnetModel:m=>f("sonnetModel",m),onUpdateHaikuModel:m=>f("haikuModel",m)}),e.jsx(pt,{enabled:p,autoStart:g,port:o,accountType:a,rateLimit:y,waitOnLimit:C,onUpdateEnabled:m=>f("enabled",m),onUpdateAutoStart:m=>f("autoStart",m),onUpdatePort:m=>f("port",m),onUpdateAccountType:m=>f("accountType",m),onUpdateRateLimit:m=>f("rateLimit",m),onUpdateWaitOnLimit:m=>f("waitOnLimit",m)}),e.jsx(ht,{rawSettings:r})]})]})})}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(Je,{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(_e,{rawJsonContent:n,isRawJsonValid:L,rawJsonEdits:x,rawSettingsEnv:r?.settings?.env,onChange:U,missingRequiredFields:k})]})]}),e.jsx(Ie,{open:A,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>$(!0),onCancel:()=>$(!1)})]})}function te({title:t,children:s}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3",children:t}),e.jsx("div",{className:"space-y-1",children:s})]})}function G({icon:t,label:s,status:l,statusText:c,variant:i="default"}){return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg bg-muted/50",children:[e.jsx(t,{className:"w-4 h-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("span",{className:"text-sm",children:s})}),e.jsx("div",{className:"flex items-center gap-1.5",children:l?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:se("w-4 h-4",i==="warning"?"text-yellow-500":"text-green-500")}),e.jsx("span",{className:se("text-xs",i==="warning"?"text-yellow-500":"text-green-500"),children:c||"Yes"})]}):e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:c||"No"})]})})]})}function vt(){return e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsx(b,{className:"h-8 w-full"}),e.jsx(b,{className:"h-12 w-full"}),e.jsx(b,{className:"h-12 w-full"}),e.jsx(b,{className:"h-12 w-full"})]})}function Ot(){const{t}=ie(),{status:s,statusLoading:l,refetchStatus:c,startAuth:i,isAuthenticating:d,startDaemon:r,isStartingDaemon:n,stopDaemon:x,isStoppingDaemon:p,install:g,isInstalling:o}=Ne();return e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30 shrink-0",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($e,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:t("copilotPage.title")})]}),e.jsx(N,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>c(),disabled:l,children:e.jsx(ge,{className:se("w-4 h-4",l&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("copilotPage.subtitle")})]}),e.jsx(H,{className:"flex-1",children:l?e.jsx(vt,{}):e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-500/15 p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(je,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-400 shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-yellow-800 dark:text-yellow-200",children:t("copilotPage.unofficialTitle")})]}),e.jsxs("ul",{className:"text-[11px] text-yellow-700 dark:text-yellow-300 space-y-0.5 pl-6 list-disc",children:[e.jsx("li",{children:t("copilotPage.unofficialItem1")}),e.jsx("li",{children:t("copilotPage.unofficialItem2")}),e.jsx("li",{children:t("copilotPage.unofficialItem3")})]})]}),e.jsxs(te,{title:t("copilotPage.setup"),children:[e.jsx(G,{icon:ze,label:"copilot-api",status:s?.installed??!1,statusText:s?.installed?s.version?`v${s.version}`:t("copilotPage.installed"):t("copilotPage.missing")}),!s?.installed&&e.jsx(N,{size:"sm",className:"w-full mt-2",onClick:()=>g(void 0),disabled:o,children:o?e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}),t("copilotPage.installing")]}):e.jsxs(e.Fragment,{children:[e.jsx(Be,{className:"w-3.5 h-3.5 mr-1.5"}),t("copilotPage.installCopilotApi")]})}),s?.installed&&e.jsx(G,{icon:me,label:t("copilotPage.integration"),status:s?.enabled??!1,statusText:s?.enabled?t("copilotPage.enabled"):t("copilotPage.disabled")})]}),s?.installed&&e.jsxs(te,{title:t("copilotPage.auth"),children:[e.jsx(G,{icon:Ge,label:t("copilotPage.github"),status:s?.authenticated??!1,statusText:s?.authenticated?t("copilotPage.connected"):t("copilotPage.notConnected")}),!s?.authenticated&&e.jsx(N,{size:"sm",className:"w-full mt-2",onClick:()=>i(),disabled:d,children:t(d?"copilotPage.authenticating":"copilotPage.authenticate")})]}),s?.authenticated&&e.jsxs(te,{title:t("copilotPage.daemon"),children:[e.jsx(G,{icon:He,label:t("copilotPage.status"),status:s?.daemon_running??!1,statusText:s?.daemon_running?t("copilotPage.running"):t("copilotPage.stopped")}),e.jsxs("div",{className:"px-3 py-1 text-xs text-muted-foreground",children:[t("copilotPage.port"),": ",s?.port??4141]}),e.jsx("div",{className:"px-1",children:s?.daemon_running?e.jsxs(N,{size:"sm",variant:"outline",className:"w-full",onClick:()=>x(),disabled:p,children:[e.jsx(We,{className:"w-3.5 h-3.5 mr-1.5"}),t(p?"copilotPage.stopping":"copilotPage.stop")]}):e.jsxs(N,{size:"sm",variant:"outline",className:"w-full",onClick:()=>r(),disabled:n,children:[e.jsx(me,{className:"w-3.5 h-3.5 mr-1.5"}),t(n?"copilotPage.starting":"copilotPage.start")]})})]})]})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:t("copilotPage.proxy")}),s?.daemon_running?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ve,{className:"w-3 h-3 text-green-500"}),t("copilotPage.active")]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(we,{className:"w-3 h-3 text-muted-foreground"}),t("copilotPage.inactive")]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:e.jsx(jt,{})})]})}export{Ot as CopilotPage};
@@ -1 +0,0 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as j}from"./react-vendor-CNOkPC89.js";import{t as o}from"./notifications-B2HqRBj7.js";import{b1 as N,b2 as Ze,a as Se,B as D,d as f,c as oe,v as E,O as $e,Q as Ye,R as Y,U as ee,L as _,I as se,ay as ye,b7 as es,ad as ss,ae as as,af as ts,ag as rs,ah as ns,av as os,b3 as is}from"./index-CKNvmYLR.js";import{a as cs,u as z,b as M}from"./tanstack-DWm6aJ-G.js";import{D as ke}from"./default-ports-1QQSffYX.js";import{S as ls}from"./separator-vdIGU0ab.js";import{S as ds}from"./searchable-select-DNmazsgI.js";import{R as be,T as us,aG as ms,K as q,a9 as hs,aJ as Ce,aI as gs,L as A,D as xs,an as fs,a6 as ps,Z as ae,aq as js,v as vs,z as ws}from"./icons-DhBsHU-U.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";async function Ps(){const s=await fetch(N("/cursor/status"));if(!s.ok)throw new Error("Failed to fetch cursor status");return s.json()}async function Ns(){const s=await fetch(N("/cursor/settings"));if(!s.ok)throw new Error("Failed to fetch cursor config");return s.json()}async function ys(){const s=await fetch(N("/cursor/models"));if(!s.ok)throw new Error("Failed to fetch cursor models");return s.json()}async function bs(){const s=await fetch(N("/cursor/settings/raw"));if(!s.ok)throw new Error("Failed to fetch cursor raw settings");return s.json()}async function Cs(s){const t=await fetch(N("/cursor/settings"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok)throw new Error("Failed to update cursor config");return t.json()}async function Ss(s){const t=await fetch(N("/cursor/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(t.status===409)throw new Ze("Cursor raw settings changed externally");if(!t.ok)throw new Error("Failed to save cursor raw settings");return t.json()}async function ks(){const s=await fetch(N("/cursor/auth/auto-detect"),{method:"POST"});if(!s.ok){const t=await s.json().catch(()=>({error:"Auto-detect failed"}));throw new Error(t.error||"Auto-detect failed")}return s.json()}async function Ds(s){const t=await fetch(N("/cursor/auth/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok){const l=await t.json().catch(()=>({error:"Manual import failed"}));throw new Error(l.error||"Manual import failed")}return t.json()}async function Ms(){const s=await fetch(N("/cursor/daemon/start"),{method:"POST"});if(!s.ok)throw new Error("Failed to start cursor daemon");return s.json()}async function As(){const s=await fetch(N("/cursor/daemon/stop"),{method:"POST"});if(!s.ok)throw new Error("Failed to stop cursor daemon");return s.json()}function _s(){const s=cs(),t=z({queryKey:["cursor-status"],queryFn:Ps,refetchInterval:5e3}),l=z({queryKey:["cursor-config"],queryFn:Ns}),u=z({queryKey:["cursor-models"],queryFn:ys}),g=z({queryKey:["cursor-raw-settings"],queryFn:bs}),m=()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-config"]}),s.invalidateQueries({queryKey:["cursor-models"]}),s.invalidateQueries({queryKey:["cursor-raw-settings"]})},h=M({mutationFn:Cs,onSuccess:m}),r=M({mutationFn:Ss,onSuccess:m}),d=M({mutationFn:ks,onSuccess:m}),p=M({mutationFn:Ds,onSuccess:m}),i=M({mutationFn:Ms,onSuccess:m}),c=M({mutationFn:As,onSuccess:m});return j.useMemo(()=>({status:t.data,statusLoading:t.isLoading,statusError:t.error,refetchStatus:t.refetch,config:l.data,configLoading:l.isLoading,models:u.data?.models??[],currentModel:u.data?.current??null,modelsLoading:u.isLoading,rawSettings:g.data,rawSettingsLoading:g.isLoading,refetchRawSettings:g.refetch,updateConfig:h.mutate,updateConfigAsync:h.mutateAsync,isUpdatingConfig:h.isPending,saveRawSettings:r.mutate,saveRawSettingsAsync:r.mutateAsync,isSavingRawSettings:r.isPending,autoDetectAuth:d.mutate,autoDetectAuthAsync:d.mutateAsync,isAutoDetectingAuth:d.isPending,autoDetectAuthResult:d.data,importManualAuth:p.mutate,importManualAuthAsync:p.mutateAsync,isImportingManualAuth:p.isPending,manualAuthResult:p.data,startDaemon:i.mutate,startDaemonAsync:i.mutateAsync,isStartingDaemon:i.isPending,stopDaemon:c.mutate,stopDaemonAsync:c.mutateAsync,isStoppingDaemon:c.isPending}),[t.data,t.isLoading,t.error,t.refetch,l.data,l.isLoading,u.data,u.isLoading,g.data,g.isLoading,g.refetch,h.mutate,h.mutateAsync,h.isPending,r.mutate,r.mutateAsync,r.isPending,d.mutate,d.mutateAsync,d.isPending,d.data,p.mutate,p.mutateAsync,p.isPending,p.data,i.mutate,i.mutateAsync,i.isPending,c.mutate,c.mutateAsync,c.isPending])}function te(s){return{port:String(s?.port??ke),auto_start:s?.auto_start??!1,ghost_mode:s?.ghost_mode??!0,model:s?.model?.trim()||"gpt-5.3-codex",opus_model:s?.opus_model?.trim()||"",sonnet_model:s?.sonnet_model?.trim()||"",haiku_model:s?.haiku_model?.trim()||""}}function y(s,t,l){return s.find(g=>t.some(m=>m.test(g.id)))?.id??l}function re(s){return s.toLowerCase().replace(/[^a-z0-9]/g,"")}function b(s,t,l){const u=new Set(t.map(re)),g=s.find(h=>u.has(re(h.id)));if(g)return g.id;const m=s.find(h=>u.has(re(h.name)));return m?m.id:l}function Ts(s){try{const t=JSON.parse(s||"{}");return!t||typeof t!="object"||Array.isArray(t)?{isValid:!1,error:"Raw settings must be a JSON object"}:{isValid:!0,settings:t}}catch(t){return{isValid:!1,error:t.message||"Invalid JSON"}}}function G({label:s,description:t,value:l,models:u,disabled:g,allowDefaultFallback:m=!1,onChange:h}){const{t:r}=Se(),d=l||(m?"__default":""),p=j.useMemo(()=>{const i=u.map(c=>({value:c.id,groupKey:"models",searchText:`${c.name||c.id} ${c.id}`,keywords:[c.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:c.name||c.id}),c.provider&&e.jsx(D,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:c.provider})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate text-xs font-mono",children:c.name||c.id}),e.jsx(D,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:c.provider})]})}));return m?[{value:"__default",groupKey:"models",searchText:r("cursorPage.useDefaultModel"),triggerContent:e.jsx("span",{className:"truncate font-mono text-xs",children:r("cursorPage.useDefaultModel")}),itemContent:e.jsx("span",{children:r("cursorPage.useDefaultModel")})},...i]:i},[m,u,r]);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx(_,{className:"text-xs font-medium",children:s}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:t})]}),e.jsx(ds,{value:d||void 0,onChange:i=>{if(m&&i==="__default"){h("");return}h(i)},disabled:g,placeholder:r("cursorPage.selectModel"),searchPlaceholder:r("searchableSelect.searchModels"),emptyText:r("searchableSelect.noResults"),triggerClassName:"h-9",groups:[{key:"models",label:r("cursorPage.availableModelCount",{count:u.length})}],options:p})]})}function ne({icon:s,label:t,ok:l,detail:u}){return e.jsxs("div",{className:"flex items-center gap-3 rounded-lg bg-muted/50 px-3 py-2",children:[e.jsx(s,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"text-sm",children:t})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[l?e.jsx(vs,{className:"h-4 w-4 text-green-500"}):e.jsx(ws,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:oe("text-xs",l?"text-green-500":"text-muted-foreground"),title:u,children:u})]})]})}function Js(){const{t:s}=Se(),{status:t,statusLoading:l,refetchStatus:u,config:g,updateConfigAsync:m,isUpdatingConfig:h,models:r,modelsLoading:d,currentModel:p,rawSettings:i,rawSettingsLoading:c,refetchRawSettings:De,saveRawSettingsAsync:Me,isSavingRawSettings:ie,autoDetectAuthAsync:Ae,isAutoDetectingAuth:ce,importManualAuthAsync:_e,isImportingManualAuth:le,startDaemonAsync:Te,isStartingDaemon:Re,stopDaemonAsync:Fe,isStoppingDaemon:de}=_s(),[k,ue]=j.useState(()=>te()),[v,me]=j.useState(!1),[he,Ie]=j.useState("{}"),[T,K]=j.useState(!1),[Le,I]=j.useState(!1),[U,ge]=j.useState(""),[B,xe]=j.useState(""),C=te(g),fe=v?k.port:C.port,J=v?k.auto_start:C.auto_start,Q=v?k.ghost_mode:C.ghost_mode,w=v?k.model:C.model,H=v?k.opus_model:C.opus_model,V=v?k.sonnet_model:C.sonnet_model,W=v?k.haiku_model:C.haiku_model,X=T?he:JSON.stringify(i?.settings??{},null,2),pe=!!i,R=j.useMemo(()=>Ts(X),[X]),je=R.isValid,ve=v||T,Oe=!T||pe&&je,L=j.useMemo(()=>{const a=new Set,n=[...r].sort((S,$)=>S.name.localeCompare($.name)),x=n.filter(S=>a.has(S.id)?!1:(a.add(S.id),!0));return w&&!n.some(S=>S.id===w)?[{id:w,name:w,provider:"custom"},...x]:x},[r,w]),P=a=>{ue(n=>a(v?n:C)),me(!0)},Ee=!!(t?.enabled&&t?.authenticated&&!t?.token_expired),ze=j.useMemo(()=>t?.enabled?e.jsx(D,{children:s("cursorPage.enabled")}):e.jsx(D,{variant:"secondary",children:s("cursorPage.disabled")}),[t?.enabled,s]),qe=async({suppressSuccessToast:a=!1}={})=>{const n=Number(fe);if(!Number.isInteger(n)||n<1||n>65535)return o.error(s("cursorPage.invalidPort")),!1;if(!w.trim())return o.error(s("cursorPage.defaultModelRequired")),!1;try{return await m({port:n,auto_start:J,ghost_mode:Q,model:w,opus_model:H||void 0,sonnet_model:V||void 0,haiku_model:W||void 0}),me(!1),ue(te({port:n,auto_start:J,ghost_mode:Q,model:w,opus_model:H||void 0,sonnet_model:V||void 0,haiku_model:W||void 0})),a||o.success(s("cursorPage.savedConfig")),!0}catch(x){return o.error(x.message||s("cursorPage.failedSaveConfig")),!1}},Z=a=>{if(d){o.error(s("cursorPage.modelsLoadingWait"));return}if(r.length===0){o.error(s("cursorPage.noModelsAvailable"));return}const n=w||p||r[0]?.id||"gpt-5.3-codex",x=b(r,["gpt-5.3-codex","gpt53codex","GPT-5.3 Codex"],y(r,[/gpt[-.]?5.*codex/i],n)),S=b(r,["gpt-5.1-codex-max","gpt51codexmax","GPT-5.1 Codex Max"],y(r,[/gpt[-.]?5.*codex.*max/i],x)),$=b(r,["gpt-5-fast","gpt5fast","GPT-5 Fast"],y(r,[/gpt[-.]?5.*fast/i],x)),Ve=b(r,["gpt-5-mini","gpt5mini","GPT-5 Mini"],y(r,[/gpt[-.]?5.*mini/i],$)),Pe=b(r,["claude-4.6-opus","claude46opus","Claude 4.6 Opus"],y(r,[/claude[-.]?4\.?6.*opus/i,/claude.*opus/i],x)),Ne=b(r,["claude-4.5-sonnet","claude45sonnet","Claude 4.5 Sonnet"],y(r,[/claude[-.]?4\.?5.*sonnet/i,/claude.*sonnet/i],x)),We=b(r,["claude-4.5-haiku","claude45haiku","Claude 4.5 Haiku"],y(r,[/claude[-.]?4\.?5.*haiku/i,/haiku/i],Ne)),O=b(r,["gemini-3-pro","gemini3pro","Gemini 3 Pro"],y(r,[/gemini[-.]?3.*pro/i],x)),Xe=b(r,["gemini-3-flash","gemini3flash","Gemini 3 Flash"],y(r,[/gemini[-.]?3.*flash/i,/gemini[-.]?2\.?5.*flash/i],O));if(a==="codex53"){P(F=>({...F,model:x,opus_model:S,sonnet_model:x,haiku_model:Ve})),o.success(s("cursorPage.appliedCodexPreset"));return}if(a==="claude46"){P(F=>({...F,model:Pe,opus_model:Pe,sonnet_model:Ne,haiku_model:We})),o.success(s("cursorPage.appliedClaudePreset"));return}P(F=>({...F,model:O,opus_model:O,sonnet_model:O,haiku_model:Xe})),o.success(s("cursorPage.appliedGeminiPreset"))},we=async a=>{try{await m({enabled:a}),o.success(s(a?"cursorPage.integrationEnabled":"cursorPage.integrationDisabled"))}catch(n){o.error(n.message||s("cursorPage.failedUpdateIntegration"))}},Ge=async()=>{try{await Ae(),o.success(s("cursorPage.credentialsImported"))}catch(a){o.error(a.message||s("cursorPage.autoDetectFailed"))}},Ke=async()=>{if(!U.trim()||!B.trim()){o.error(s("cursorPage.manualRequired"));return}try{await _e({accessToken:U.trim(),machineId:B.trim()}),o.success(s("cursorPage.credentialsImported")),I(!1),ge(""),xe("")}catch(a){o.error(a.message||s("cursorPage.manualImportFailed"))}},Ue=async()=>{try{const a=await Te();if(!a.success){o.error(a.error||s("cursorPage.failedStartDaemon"));return}o.success(a.pid?s("cursorPage.daemonStartedWithPid",{pid:a.pid}):s("cursorPage.daemonStarted"))}catch(a){o.error(a.message||s("cursorPage.failedStartDaemon"))}},Be=async()=>{try{const a=await Fe();if(!a.success){o.error(a.error||s("cursorPage.failedStopDaemon"));return}o.success(s("cursorPage.daemonStopped"))}catch(a){o.error(a.message||s("cursorPage.failedStopDaemon"))}},Je=async({suppressSuccessToast:a=!1}={})=>{if(!pe)return o.error(s("cursorPage.rawLoading")),!1;if(!R.isValid||!R.settings)return o.error(R.error||s("cursorPage.invalidJson")),!1;try{return await Me({settings:R.settings,expectedMtime:i?.mtime}),K(!1),a||o.success(s("cursorPage.rawSaved")),!0}catch(n){return is(n)?o.error(s("cursorPage.rawChanged")):o.error(n.message||s("cursorPage.failedSaveRaw")),!1}},Qe=async()=>{if(!ve)return;const a=v,n=T;a&&!await qe({suppressSuccessToast:n})||n&&!await Je({suppressSuccessToast:a})||a&&n&&o.success(s("cursorPage.savedAll"))},He=()=>{K(!1),u(),De()};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30 shrink-0",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("img",{src:"/assets/sidebar/cursor.svg",alt:"",className:"w-5 h-5 object-contain shrink-0"}),e.jsx("h1",{className:"font-semibold",children:s("cursorPage.title")}),e.jsx(D,{variant:"outline",className:"h-5 border-amber-500/60 bg-amber-500/10 px-1.5 text-[10px] font-semibold uppercase tracking-wide text-amber-800 dark:text-amber-300",children:s("cursorPage.beta")}),ze]}),e.jsx(f,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>u(),disabled:l,children:e.jsx(be,{className:oe("w-4 h-4",l&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("cursorPage.subtitle")})]}),e.jsx(E,{className:"flex-1",children:e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-500/15 p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(us,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-400 shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-yellow-800 dark:text-yellow-200",children:s("cursorPage.unofficialTitle")})]}),e.jsxs("ul",{className:"text-[11px] text-yellow-700 dark:text-yellow-300 space-y-0.5 pl-6 list-disc",children:[e.jsx("li",{children:s("cursorPage.unofficialItem1")}),e.jsx("li",{children:s("cursorPage.unofficialItem2")}),e.jsx("li",{children:s("cursorPage.unofficialItem3")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ne,{icon:ms,label:s("cursorPage.integration"),ok:!!t?.enabled,detail:t?.enabled?s("cursorPage.enabled"):s("cursorPage.disabled")}),e.jsx(ne,{icon:q,label:s("cursorPage.authentication"),ok:!!(t?.authenticated&&!t?.token_expired),detail:t?.authenticated?t?.token_expired?s("cursorPage.expired"):t.auth_method??s("cursorPage.connected"):s("cursorPage.notConnected")}),e.jsx(ne,{icon:hs,label:s("cursorPage.daemon"),ok:!!t?.daemon_running,detail:t?.daemon_running?s("cursorPage.running"):s("cursorPage.stopped")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:s("cursorPage.actions")}),t?.enabled?e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:()=>we(!1),disabled:h,children:[e.jsx(Ce,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.disableIntegration")]}):e.jsxs(f,{size:"sm",className:"w-full",onClick:()=>we(!0),disabled:h,children:[e.jsx(gs,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.enableIntegration")]}),e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:Ge,disabled:ce,children:[ce?e.jsx(A,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(q,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.autoDetectAuth")]}),e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:()=>I(!0),children:[e.jsx(q,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.manualAuthImport")]}),t?.daemon_running?e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",onClick:Be,disabled:de,children:[de?e.jsx(A,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(Ce,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.stopDaemon")]}):e.jsxs(f,{size:"sm",className:"w-full",onClick:Ue,disabled:!Ee,children:[Re?e.jsx(A,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(xs,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.startDaemon")]})]})]})}),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("cursorPage.port")}),e.jsx("span",{children:t?.port??g?.port??ke})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s("cursorPage.configuration")}),i&&e.jsx(D,{variant:"outline",className:"text-xs",children:"cursor.settings.json"})]}),i&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[s("cursorPage.lastModified")," ",i.exists?new Date(i.mtime).toLocaleString():s("cursorPage.neverSaved")]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(f,{variant:"ghost",size:"sm",onClick:He,disabled:l||c,children:e.jsx(be,{className:oe("w-4 h-4",(l||c)&&"animate-spin")})}),e.jsx(f,{size:"sm",onClick:Qe,disabled:h||ie||!ve||!Oe,children:h||ie?e.jsxs(e.Fragment,{children:[e.jsx(A,{className:"w-4 h-4 mr-1 animate-spin"}),s("cursorPage.saving")]}):e.jsxs(e.Fragment,{children:[e.jsx(fs,{className:"w-4 h-4 mr-1"}),s("cursorPage.save")]})})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex divide-x overflow-hidden",children:[e.jsx("div",{className:"w-[540px] shrink-0 flex flex-col min-h-0 overflow-hidden bg-muted/5",children:e.jsxs($e,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Ye,{className:"w-full",children:[e.jsx(Y,{value:"config",className:"flex-1",children:s("cursorPage.modelConfig")}),e.jsx(Y,{value:"settings",className:"flex-1",children:s("cursorPage.settings")}),e.jsx(Y,{value:"info",className:"flex-1",children:s("cursorPage.info")})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:[e.jsx(ee,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(E,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(ps,{className:"w-4 h-4"}),s("cursorPage.presets")]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:s("cursorPage.presetsDesc")}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(f,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>Z("codex53"),disabled:d||r.length===0,title:"OpenAI-only mapping: GPT-5.3 Codex / Codex Max / GPT-5 Mini",children:[e.jsx(ae,{className:"w-3 h-3"}),"GPT-5.3 Codex"]}),e.jsxs(f,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>Z("claude46"),disabled:d||r.length===0,title:"Claude-first mapping: Opus 4.6 / Sonnet 4.5 / Haiku 4.5",children:[e.jsx(ae,{className:"w-3 h-3"}),"Claude 4.6"]}),e.jsxs(f,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>Z("gemini3"),disabled:d||r.length===0,title:"Gemini-first mapping: Gemini 3 Pro + Gemini 3 Flash",children:[e.jsx(ae,{className:"w-3 h-3"}),"Gemini 3 Pro"]})]})]}),e.jsx(ls,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:s("cursorPage.modelMapping")}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:s("cursorPage.modelMappingDesc")}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(G,{label:s("cursorPage.defaultModel"),description:s("cursorPage.defaultModelDesc"),value:w,models:L,disabled:d,onChange:a=>{P(n=>({...n,model:a}))}}),e.jsx(G,{label:s("cursorPage.opusModel"),description:s("cursorPage.opusModelDesc"),value:H,models:L,disabled:d,allowDefaultFallback:!0,onChange:a=>{P(n=>({...n,opus_model:a}))}}),e.jsx(G,{label:s("cursorPage.sonnetModel"),description:s("cursorPage.sonnetModelDesc"),value:V,models:L,disabled:d,allowDefaultFallback:!0,onChange:a=>{P(n=>({...n,sonnet_model:a}))}}),e.jsx(G,{label:s("cursorPage.haikuModel"),description:s("cursorPage.haikuModelDesc"),value:W,models:L,disabled:d,allowDefaultFallback:!0,onChange:a=>{P(n=>({...n,haiku_model:a}))}})]})]})]})})}),e.jsx(ee,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(E,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:s("cursorPage.runtimeSettings")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_,{htmlFor:"cursor-port",className:"text-xs",children:"Port"}),e.jsx(se,{id:"cursor-port",type:"number",min:1,max:65535,className:"max-w-[150px] h-8",value:fe,onChange:a=>{P(n=>({...n,port:a.target.value}))}})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(_,{htmlFor:"cursor-auto-start",className:"text-xs",children:s("cursorPage.autoStartDaemon")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s("cursorPage.autoStartDesc")})]}),e.jsx(ye,{id:"cursor-auto-start",checked:J,onCheckedChange:a=>{P(n=>({...n,auto_start:a}))}})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(_,{htmlFor:"cursor-ghost-mode",className:"text-xs",children:s("cursorPage.ghostMode")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s("cursorPage.ghostModeDesc")})]}),e.jsx(ye,{id:"cursor-ghost-mode",checked:Q,onCheckedChange:a=>{P(n=>({...n,ghost_mode:a}))}})]})]})})})}),e.jsx(ee,{value:"info",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(E,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:s("cursorPage.provider")}),e.jsx("span",{className:"font-mono",children:"Cursor IDE"})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:s("cursorPage.filePath")}),e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:i?.path??"~/.ccs/cursor.settings.json"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Model mapping writes `ANTHROPIC_MODEL`, `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, and `ANTHROPIC_DEFAULT_HAIKU_MODEL` in `cursor.settings.json`."})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:s("cursorPage.availableModels")}),d?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(A,{className:"w-4 h-4 animate-spin"}),s("cursorPage.loadingModels")]}):r.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:s("cursorPage.noModels")}):e.jsx("div",{className:"space-y-2",children:r.map(a=>e.jsxs("div",{className:"rounded-lg border px-3 py-2 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:a.id}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[a.name," • ",a.provider]})]}),a.id===p&&e.jsx(D,{children:s("cursorPage.default")})]},a.id))})]})]})})})]})]})}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(js,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:s("cursorPage.rawConfiguration")})]}),e.jsx(es,{rawJsonContent:X,isRawJsonValid:je,rawJsonEdits:T?he:null,rawSettingsEnv:i?.settings?.env,onChange:a=>{K(!0),Ie(a)}})]})]})]})})]}),e.jsx(ss,{open:Le,onOpenChange:I,children:e.jsxs(as,{children:[e.jsxs(ts,{children:[e.jsx(rs,{children:s("cursorPage.manualImportTitle")}),e.jsx(ns,{children:s("cursorPage.manualImportDesc")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_,{htmlFor:"cursor-manual-token",children:s("cursorPage.accessToken")}),e.jsx(se,{id:"cursor-manual-token",value:U,onChange:a=>ge(a.target.value),placeholder:s("cursorPage.accessTokenPlaceholder")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_,{htmlFor:"cursor-manual-machine-id",children:s("cursorPage.machineId")}),e.jsx(se,{id:"cursor-manual-machine-id",value:B,onChange:a=>xe(a.target.value),placeholder:s("cursorPage.machineIdPlaceholder")})]})]}),e.jsxs(os,{children:[e.jsx(f,{variant:"outline",onClick:()=>I(!1),children:s("cursorPage.cancel")}),e.jsxs(f,{onClick:Ke,disabled:le,children:[le?e.jsx(A,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(q,{className:"w-4 h-4 mr-2"}),s("cursorPage.import")]})]})]})})]})}export{Js as CursorPage};
@@ -1 +0,0 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as f,c as ye}from"./react-vendor-CNOkPC89.js";import{u as P,a as T,C as k,b as C,S as j,c as d,P as w,B as X,d as E,e as ae,f as je,g as ne,h as Ne,i as re,j as M,k as q,l as Q,I as we,m as be}from"./index-CKNvmYLR.js";import{a0 as ve,ae as W,af as V,ag as le,_ as oe,a6 as ke,G as Ce,ah as z,R as De,V as J,U as Se,Z as Me,t as Le,ai as $e,aj as Te,ak as ie,C as Fe,al as Re}from"./icons-DhBsHU-U.js";import{a as ce,u as $,b as Pe}from"./tanstack-DWm6aJ-G.js";import{K as R,L as Z,f as L,H as Be}from"./utils-CzKF5WmX.js";import{R as de,A as Ae,C as Ue,X as qe,Y as ee,T as ue,a as se,P as Ke,b as Ie,c as Oe}from"./charts-BBPXh0Ar.js";import"./notifications-B2HqRBj7.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function _e({data:s,isLoading:t}){const{privacyMode:n}=P(),{t:a}=T();if(t)return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:[1,2,3,4,5].map(r=>e.jsx(k,{children:e.jsx(C,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{className:"h-4 w-[100px]"}),e.jsx(j,{className:"h-8 w-[80px]"})]}),e.jsx(j,{className:"h-8 w-8 rounded-lg"})]})})},r))});const l=(s?.tokenBreakdown?.cacheCreation?.cost??0)+(s?.tokenBreakdown?.cacheRead?.cost??0),o=s?.totalCost?Math.round(l/s.totalCost*100):0,i=[{title:a("analyticsSummary.totalTokens"),value:s?.totalTokens??0,icon:ve,format:r=>U(r),color:"text-blue-600",bgColor:"bg-blue-100 dark:bg-blue-900/20",subtitle:a("analyticsSummary.totalTokensSubtitle",{input:U(s?.totalInputTokens??0),output:U(s?.totalOutputTokens??0)})},{title:a("analyticsSummary.totalCost"),value:s?.totalCost??0,icon:W,format:r=>`$${r.toFixed(2)}`,color:"text-green-600",bgColor:"bg-green-100 dark:bg-green-900/20",subtitle:a("analyticsSummary.totalCostSubtitle",{value:s?.averageCostPerDay?.toFixed(2)??"0.00"})},{title:a("analyticsSummary.cacheTokens"),value:s?.totalCacheTokens??0,icon:V,format:r=>U(r),color:"text-cyan-600",bgColor:"bg-cyan-100 dark:bg-cyan-900/20",subtitle:a("analyticsSummary.cacheTokensSubtitle",{cost:l.toFixed(2),percent:o})},{title:a("analyticsSummary.inputCost"),value:s?.tokenBreakdown?.input?.cost??0,icon:le,format:r=>`$${r.toFixed(2)}`,color:"text-purple-600",bgColor:"bg-purple-100 dark:bg-purple-900/20",subtitle:a("analyticsSummary.tokensSubtitle",{value:U(s?.tokenBreakdown?.input?.tokens??0)})},{title:a("analyticsSummary.outputCost"),value:s?.tokenBreakdown?.output?.cost??0,icon:oe,format:r=>`$${r.toFixed(2)}`,color:"text-orange-600",bgColor:"bg-orange-100 dark:bg-orange-900/20",subtitle:a("analyticsSummary.tokensSubtitle",{value:U(s?.tokenBreakdown?.output?.tokens??0)})}];return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:i.map((r,c)=>{const u=r.icon;return e.jsx(k,{className:"hover:shadow-md transition-shadow",children:e.jsx(C,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between space-x-2",children:[e.jsxs("div",{className:"space-y-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground truncate",children:r.title}),e.jsx("p",{className:d("text-xl font-bold truncate",n&&w),children:r.format(r.value)}),r.subtitle&&e.jsx("p",{className:d("text-[10px] text-muted-foreground truncate",n&&w),children:r.subtitle})]}),e.jsx("div",{className:d("p-2 rounded-lg shrink-0",r.bgColor),children:e.jsx(u,{className:d("h-4 w-4",r.color)})})]})})},c)})})}function U(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function He({model:s}){const{privacyMode:t}=P(),{t:n}=T(),a=Ee(s.ioRatio,n);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"h-4 w-4 text-primary shrink-0"}),e.jsx("h4",{className:"font-semibold leading-none truncate",title:s.model,children:s.model})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(X,{variant:"secondary",className:"text-[10px] h-5 px-1.5",children:n("analyticsModelDetail.percentUsage",{percent:s.percentage.toFixed(1)})}),e.jsx(X,{variant:a.variant,className:"text-[10px] h-5 px-1.5",children:n("analyticsModelDetail.ioRatio",{ratio:s.ioRatio.toFixed(0)})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("p",{className:d("text-lg font-bold",t&&w),children:["$",s.cost.toFixed(2)]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:n("analyticsModelDetail.totalCost")})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsx("p",{className:d("text-lg font-bold",t&&w),children:Ge(s.tokens)}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:n("analyticsModelDetail.totalTokens")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h5",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wider",children:n("analyticsModelDetail.tokenBreakdown")}),e.jsxs("div",{className:d("space-y-1",t&&w),children:[e.jsx(H,{label:n("analyticsToken.input"),tokens:s.inputTokens,cost:s.costBreakdown.input.cost,color:"#335c67",icon:le}),e.jsx(H,{label:n("analyticsToken.output"),tokens:s.outputTokens,cost:s.costBreakdown.output.cost,color:"#fff3b0",icon:oe}),e.jsx(H,{label:n("analyticsToken.cacheWrite"),tokens:s.cacheCreationTokens,cost:s.costBreakdown.cacheCreation.cost,color:"#e09f3e",icon:V}),e.jsx(H,{label:n("analyticsToken.cacheRead"),tokens:s.cacheReadTokens,cost:s.costBreakdown.cacheRead.cost,color:"#9e2a2b",icon:V})]})]}),e.jsxs("div",{className:"p-2.5 rounded-md border bg-muted/20 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:n("analyticsModelDetail.ioRatioTitle")})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-snug",children:a.description})]})]})}function H({label:s,tokens:t,cost:n,color:a,icon:l}){return t===0?null:e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("div",{className:"w-1 h-6 rounded-full shrink-0",style:{backgroundColor:a}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium truncate",children:s}),e.jsxs("span",{className:"font-mono text-muted-foreground",children:["$",n.toFixed(3)]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[e.jsx(l,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:We(t)})]})]})]})}function Ee(s,t){return s>=200?{variant:"destructive",description:t("analyticsModelDetail.ioDescHigh")}:s>=50?{variant:"secondary",description:t("analyticsModelDetail.ioDescMedHigh")}:s>=5?{variant:"outline",description:t("analyticsModelDetail.ioDescBalanced")}:{variant:"default",description:t("analyticsModelDetail.ioDescHighOutput")}}function We(s){return s.toLocaleString()}function Ge(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}const Qe="/api";function D(s){const t=s.getFullYear(),n=String(s.getMonth()+1).padStart(2,"0"),a=String(s.getDate()).padStart(2,"0");return`${t}${n}${a}`}const B={summary:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",D(s.startDate)),s?.endDate&&t.append("until",D(s.endDate)),s?.profile&&t.append("profile",s.profile),F(`/usage/summary?${t}`)},trends:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",D(s.startDate)),s?.endDate&&t.append("until",D(s.endDate)),s?.profile&&t.append("profile",s.profile),F(`/usage/daily?${t}`)},hourly:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",D(s.startDate)),s?.endDate&&t.append("until",D(s.endDate)),F(`/usage/hourly?${t}`)},models:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",D(s.startDate)),s?.endDate&&t.append("until",D(s.endDate)),s?.profile&&t.append("profile",s.profile),F(`/usage/models?${t}`)},sessions:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",D(s.startDate)),s?.endDate&&t.append("until",D(s.endDate)),s?.profile&&t.append("profile",s.profile),s?.limit&&t.append("limit",s.limit.toString()),s?.offset&&t.append("offset",s.offset.toString()),F(`/usage/sessions?${t}`)},monthly:(s,t)=>{const n=new URLSearchParams;return s&&n.append("months",s.toString()),t&&n.append("profile",t),F(`/usage/monthly?${n}`)},refresh:async()=>{if(!(await fetch(`${Qe}/usage/refresh`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to refresh usage cache")},status:()=>F("/usage/status"),insights:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",D(s.startDate)),s?.endDate&&t.append("until",D(s.endDate)),s?.profile&&t.append("profile",s.profile),F(`/usage/insights?${t}`)}};async function F(s){const n=await fetch(`/api${s}`,{headers:{"Content-Type":"application/json"}});if(!n.ok){const l=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(l.error||n.statusText)}const a=await n.json();return a.data||a}function Ye(s){return $({queryKey:["usage","summary",s],queryFn:()=>B.summary(s),staleTime:60*1e3})}function Ve(s){return $({queryKey:["usage","trends",s],queryFn:()=>B.trends(s),staleTime:60*1e3})}function ze(s){return $({queryKey:["usage","hourly",s],queryFn:()=>B.hourly(s),staleTime:60*1e3})}function Ze(s){return $({queryKey:["usage","models",s],queryFn:()=>B.models(s),staleTime:60*1e3})}function Xe(){const s=ce();return f.useCallback(async()=>{await B.refresh(),await s.invalidateQueries({queryKey:["usage"]})},[s])}function Je(){return $({queryKey:["usage","status"],queryFn:()=>B.status(),staleTime:10*1e3,refetchInterval:30*1e3})}function es(s){return $({queryKey:["usage","sessions",s],queryFn:()=>B.sessions(s),staleTime:60*1e3})}function ss(){const[s,t]=f.useState({from:R(new Date,30),to:new Date}),[n,a]=f.useState(!1),[l,o]=f.useState(null),[i,r]=f.useState(null),[c,u]=f.useState("daily"),x=Xe(),p=f.useCallback(async()=>{a(!0);try{await x()}finally{a(!1)}},[x]),g=f.useMemo(()=>({startDate:s?.from,endDate:s?.to}),[s?.from,s?.to]),{data:S,isLoading:v}=Ye(g),{data:h,isLoading:m}=Ve(g),{data:b,isLoading:N}=ze(g),{data:y,isLoading:K}=Ze(g),{data:G,isLoading:I}=es({...g,limit:3}),{data:O}=Je(),xe=f.useCallback(()=>{const A=new Date;t({from:R(A,1),to:A}),u("hourly")},[]),me=f.useCallback(A=>{t(A),u("daily")},[]),fe=f.useMemo(()=>O?.lastFetch?Z(new Date(O.lastFetch),{addSuffix:!0}):null,[O?.lastFetch]),he=f.useCallback((A,ge)=>{const _=ge.currentTarget.getBoundingClientRect();r({x:_.left+_.width/2,y:_.top+_.height/2}),o(A)},[]),pe=f.useCallback(()=>{o(null),r(null)},[]);return{dateRange:s,isRefreshing:n,viewMode:c,selectedModel:l,popoverPosition:i,summary:S,trends:h,hourlyData:b,models:y,sessions:G,status:O,isSummaryLoading:v,isTrendsLoading:m,isHourlyLoading:N,isModelsLoading:K,isSessionsLoading:I,isLoading:v||m||K||I,handleRefresh:p,handleTodayClick:xe,handleDateRangeChange:me,handleModelClick:he,handlePopoverClose:pe,lastUpdatedText:fe}}function ts({value:s,onChange:t,presets:n=[{label:"Last 7 days",range:{from:R(new Date,7),to:new Date}},{label:"Last 30 days",range:{from:R(new Date,30),to:new Date}},{label:"Last 90 days",range:{from:R(new Date,90),to:new Date}}],className:a}){const[l,o]=ye.useState(!1),i=r=>!s||!s.from||!s.to||!r.from||!r.to?!1:L(s.from,"yyyy-MM-dd")===L(r.from,"yyyy-MM-dd")&&L(s.to,"yyyy-MM-dd")===L(r.to,"yyyy-MM-dd");return e.jsxs("div",{className:d("flex flex-wrap items-center gap-2",a),children:[n.map(r=>e.jsx(E,{variant:i(r.range)?"default":"outline",size:"sm",onClick:()=>t(r.range),children:r.label},r.label)),e.jsxs(ae,{open:l,onOpenChange:o,children:[e.jsx(je,{asChild:!0,children:e.jsxs(E,{id:"date",variant:"outline",className:d("w-auto min-w-[200px] sm:min-w-[240px] justify-start text-left font-normal",!s&&"text-muted-foreground"),children:[e.jsx(z,{className:"mr-2 h-4 w-4"}),s?.from?s.to?e.jsxs(e.Fragment,{children:[L(s.from,"LLL dd, y")," - ",L(s.to,"LLL dd, y")]}):L(s.from,"LLL dd, y"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(ne,{className:"w-auto p-0",align:"end",children:e.jsx(Ne,{initialFocus:!0,mode:"range",defaultMonth:s?.from,selected:s,onSelect:t,numberOfMonths:2})})]})]})}function as({dateRange:s,onDateRangeChange:t,onTodayClick:n,onRefresh:a,isRefreshing:l,lastUpdatedText:o,viewMode:i}){const{t:r}=T();return e.jsxs("div",{className:"flex flex-col gap-3 shrink-0 xl:flex-row xl:items-center xl:justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold",children:r("analytics.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r("analytics.subtitle")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 xl:justify-end",children:[e.jsx(E,{variant:i==="hourly"?"default":"outline",size:"sm",className:"h-8",onClick:n,children:"24H"}),e.jsx(ts,{className:"flex-wrap",value:s,onChange:t,presets:[{label:"7D",range:{from:R(new Date,7),to:new Date}},{label:"30D",range:{from:R(new Date,30),to:new Date}},{label:r("analytics.month"),range:{from:Be(new Date),to:new Date}},{label:r("analytics.allTime"),range:{from:void 0,to:new Date}}]}),o&&e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:r("analytics.updated",{value:o})}),e.jsx(E,{variant:"outline",size:"sm",className:"gap-2 h-8",onClick:a,disabled:l,children:e.jsx(De,{className:`w-3.5 h-3.5 ${l?"animate-spin":""}`})})]})]})}function ns({data:s,isLoading:t,granularity:n="daily",className:a}){const{privacyMode:l}=P(),o=f.useMemo(()=>!s||s.length===0?[]:s.map(c=>{const u="hour"in c?c.hour:c.date;return{...c,dateFormatted:rs(u,n),costRounded:Number(c.cost.toFixed(4))}}),[s,n]);if(t)return e.jsx(j,{className:d("h-full w-full",a)});if(!s||s.length===0)return e.jsx("div",{className:d("h-full flex items-center justify-center",a),children:e.jsx("p",{className:"text-muted-foreground",children:n==="hourly"?"No usage data for today":"No usage data available"})});const i=({x:r,y:c,payload:u,isRight:x})=>{const p=x?`$${u.value}`:te(Number(u.value));return e.jsx("text",{x:r,y:c,dy:4,textAnchor:x?"start":"end",fontSize:12,fill:"currentColor",className:d("fill-muted-foreground",l&&"blur-[4px]"),children:p})};return e.jsx("div",{className:d("w-full h-full",a),children:e.jsx(de,{width:"100%",height:"100%",children:e.jsxs(Ae,{data:o,margin:{top:5,right:30,left:20,bottom:5},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"tokenGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#0080FF",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#0080FF",stopOpacity:.1})]}),e.jsxs("linearGradient",{id:"costGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#00C49F",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#00C49F",stopOpacity:.1})]})]}),e.jsx(Ue,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(qe,{dataKey:"dateFormatted",tick:{fontSize:12},tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(ee,{yAxisId:"left",orientation:"left",tick:r=>e.jsx(i,{...r,isRight:!1}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(ee,{yAxisId:"right",orientation:"right",tick:r=>e.jsx(i,{...r,isRight:!0}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(ue,{content:({active:r,payload:c,label:u})=>{if(!r||!c||!c.length)return null;const x=c[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-3 shadow-lg",children:[e.jsx("p",{className:"font-medium mb-2",children:u}),c.map((p,g)=>e.jsxs("p",{className:d("text-sm",l&&w),style:{color:p.color},children:[p.name,":"," ",p.name==="Tokens"?te(Number(p.value)||0):`$${p.value}`]},g)),"requests"in x&&e.jsxs("p",{className:d("text-sm text-muted-foreground mt-1",l&&w),children:["Requests: ",x.requests]})]})}}),e.jsx(se,{yAxisId:"left",type:"monotone",dataKey:"tokens",stroke:"#0080FF",strokeWidth:2,fillOpacity:1,fill:"url(#tokenGradient)",name:"Tokens"}),e.jsx(se,{yAxisId:"right",type:"monotone",dataKey:"costRounded",stroke:"#00C49F",strokeWidth:2,fillOpacity:1,fill:"url(#costGradient)",name:"Cost"})]})})})}function rs(s,t){if(t==="hourly"){const[a,l]=s.split(" ");if(a&&l){const o=new Date(`${a}T${l}:00Z`);return L(o,"HH:mm")}return s}const n=new Date(s);return t==="monthly"?L(n,"MMM yyyy"):L(n,"MMM dd")}function te(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function ls({data:s,isLoading:t,className:n}){const{privacyMode:a}=P(),{t:l}=T(),o=f.useMemo(()=>!s||s.length===0?[]:s.map(c=>({name:c.model,value:c.tokens,cost:c.cost,percentage:c.percentage,fill:re(c.model)})),[s]);if(t)return e.jsx(j,{className:d("h-full min-h-[100px] w-full",n)});if(!s||s.length===0)return e.jsx("div",{className:d("h-full min-h-[100px] flex items-center justify-center",n),children:e.jsx("p",{className:"text-muted-foreground",children:l("analyticsModel.emptyState")})});const i=({active:c,payload:u})=>{if(!c||!u)return null;const x=u;if(!x.length)return null;const p=x[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-2 shadow-lg text-xs",children:[e.jsx("p",{className:"font-medium mb-1",children:p.name}),e.jsxs("p",{className:d("text-muted-foreground",a&&w),children:[os(p.value)," (",p.percentage.toFixed(1),"%)"]}),e.jsxs("p",{className:d("text-muted-foreground",a&&w),children:["$",p.cost.toFixed(4)]})]})},r=c=>c.percentage>5?`${c.percentage.toFixed(1)}%`:"";return e.jsx("div",{className:d("w-full h-full min-h-[100px]",n),children:e.jsx(de,{width:"100%",height:"100%",children:e.jsxs(Ke,{children:[e.jsx(Ie,{data:o,cx:"50%",cy:"50%",labelLine:!1,label:r,innerRadius:50,outerRadius:70,paddingAngle:2,dataKey:"value",children:o.map((c,u)=>e.jsx(Oe,{fill:c.fill,strokeWidth:1},`cell-${u}`))}),e.jsx(ue,{content:i})]})})})}function os(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function is(s){if(!s)return"";const n=s.replace(/^\/|\/$/g,"").split("/").filter(a=>a.length>0);return n[n.length-1]||""}function cs({data:s,isLoading:t,className:n}){const{privacyMode:a}=P(),{t:l}=T(),o=f.useMemo(()=>{if(!s?.sessions||s.sessions.length===0)return null;const i=s.sessions,r=s.total,c=i.reduce((v,h)=>v+(h.inputTokens+h.outputTokens),0),u=Math.round(c/i.length),p=i.reduce((v,h)=>v+h.cost,0)/i.length,g=i[0],S=g?Z(new Date(g.lastActivity),{addSuffix:!0}):"N/A";return{totalSessions:r,avgTokens:u,avgCost:p,lastActive:S,recentSessions:i.slice(0,3)}},[s]);return t?e.jsxs(k,{className:d("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",n),children:[e.jsx(M,{className:"px-3 py-2",children:e.jsx(j,{className:"h-5 w-32"})}),e.jsx(C,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx(j,{className:"h-full w-full"})})]}):o?e.jsxs(k,{className:d("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm",n),children:[e.jsx(M,{className:"px-3 py-2",children:e.jsxs(q,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(J,{className:"w-4 h-4"}),l("analyticsSession.title")]})}),e.jsxs(C,{className:"px-3 pb-3 pt-0 flex-1 min-h-0 flex flex-col gap-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-blue-600 dark:text-blue-400",children:[e.jsx(Se,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xl font-bold",children:o.totalSessions})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:l("analyticsSession.totalSessions")})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-green-600 dark:text-green-400",children:[e.jsx(Me,{className:"w-4 h-4"}),e.jsxs("span",{className:d("text-xl font-bold",a&&w),children:["$",o.avgCost.toFixed(2)]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:l("analyticsSession.avgCostPerSession")})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground font-medium mb-1",children:[e.jsx(Le,{className:"w-3 h-3"}),l("analyticsSession.recentActivity")]}),e.jsx("div",{className:"space-y-1.5 max-h-full overflow-y-auto pr-1",children:o.recentSessions.map(i=>e.jsxs("div",{className:"flex items-center justify-between text-xs p-1.5 rounded bg-muted/30 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"font-medium truncate",title:i.projectPath,children:is(i.projectPath)}),(i.target??"claude")!=="claude"&&e.jsx("span",{className:"shrink-0 px-1 py-0 text-[9px] font-medium rounded bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-300 uppercase",children:i.target})]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:Z(new Date(i.lastActivity),{addSuffix:!0})})]}),e.jsxs("div",{className:d("text-right shrink-0 ml-2",a&&w),children:[e.jsxs("div",{className:"font-mono",children:["$",i.cost.toFixed(2)]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[ds(i.inputTokens+i.outputTokens)," toks"]})]})]},i.sessionId))})]})]})]}):e.jsxs(k,{className:d("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",n),children:[e.jsx(M,{className:"px-3 py-2",children:e.jsxs(q,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(J,{className:"w-4 h-4"}),l("analyticsSession.title")]})}),e.jsx(C,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:l("analyticsSession.emptyState")})})]})}function ds(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}async function Y(s,t){try{const n=new URLSearchParams,a=r=>{const c=r.getFullYear(),u=String(r.getMonth()+1).padStart(2,"0"),x=String(r.getDate()).padStart(2,"0");return`${c}${u}${x}`};n.append("since",a(s)),n.append("until",a(t));const l=await fetch(`/api/usage/summary?${n}`,{headers:{"Content-Type":"application/json"}});if(!l.ok)return 0;const o=await l.json();return(o.data||o).totalCost||0}catch{return 0}}function us(){const s=new Date;return new Date(s.getFullYear(),s.getMonth()+1,0).getDate()}function xs(){return new Date().getDate()}function ms(s,t){return t<=0?"N/A":`${(s/t).toFixed(2)}x`}function fs(s,t){return t<=0?null:s/t}function hs(){const s=ce(),t=$({queryKey:["cost-leverage-config"],queryFn:async()=>{const b=(await Q.config.get()).preferences?.baseline_cost_30d;return typeof b=="number"?b:void 0},staleTime:30*1e3}),n=t.data,a=f.useMemo(()=>new Date,[]),l=f.useMemo(()=>{const h=new Date(a),m=new Date(a);return m.setDate(m.getDate()-6),{start:m,end:h}},[a]),o=f.useMemo(()=>{const h=new Date(a),m=new Date(a);return m.setDate(m.getDate()-29),{start:m,end:h}},[a]),i=f.useMemo(()=>{const h=new Date(a.getFullYear(),a.getMonth(),1),m=new Date(a);return{start:h,end:m}},[a]),r=$({queryKey:["cost-leverage","7d"],queryFn:()=>Y(l.start,l.end),staleTime:60*1e3}),c=$({queryKey:["cost-leverage","30d"],queryFn:()=>Y(o.start,o.end),staleTime:60*1e3}),u=$({queryKey:["cost-leverage","month"],queryFn:()=>Y(i.start,i.end),staleTime:60*1e3}),x=Pe({mutationFn:async h=>{const m=await Q.config.get(),N={...m.preferences||{}};h==null?delete N.baseline_cost_30d:N.baseline_cost_30d=h;const y=typeof m.version=="number"?m.version:12;return Q.config.update({version:y,preferences:N})},onSuccess:()=>{s.invalidateQueries({queryKey:["cost-leverage-config"]})}}),p=f.useMemo(()=>{const h=xs(),m=us();return[{label:"7d",cost:r.data??0,windowDays:7,scaleDays:7},{label:"30d",cost:c.data??0,windowDays:30,scaleDays:30},{label:"Month",cost:u.data??0,windowDays:h,scaleDays:m}].map(N=>{const y=n?n*N.scaleDays/30:0;return{label:N.label,estimatedCost:N.cost,scaledBaseline:y,ratio:fs(N.cost,y),ratioDisplay:ms(N.cost,y),windowDays:N.windowDays}})},[n,r.data,c.data,u.data]),g=f.useCallback(h=>{const m=h.trim();if(m==="")return x.mutate(void 0),{valid:!0};const b=Number(m);return isNaN(b)||b<=0?{valid:!1,error:"invalid"}:(x.mutate(b),{valid:!0})},[x]),S=t.isLoading||r.isLoading&&c.isLoading&&u.isLoading,v=t.error?.message||x.error?.message||null;return{baselineCost:n,windows:p,isLoading:S,isSaving:x.isPending,error:v,saveBaseline:g,cost7d:r.data,cost30d:c.data,costMonth:u.data}}function ps({className:s,isLoading:t}){const{privacyMode:n}=P(),{t:a}=T(),{baselineCost:l,windows:o,isLoading:i,isSaving:r,error:c,saveBaseline:u}=hs(),[x,p]=f.useState(l!==void 0?String(l):""),[g,S]=f.useState(null),[v,h]=f.useState(!1);l!==void 0&&!v&&(p(String(l)),h(!0)),l===void 0&&v&&h(!1);const m=f.useCallback(()=>{u(x).valid?(S(null),x.trim()===""&&(p(""),h(!1))):S(a("analyticsCostLeverage.invalidInput"))},[x,u,a]),b=f.useCallback(y=>{y.key==="Enter"&&(y.preventDefault(),m())},[m]),N=l!==void 0&&l>0;return i||t?e.jsxs(k,{className:d("flex flex-col h-full",s),children:[e.jsx(M,{className:"px-3 py-2",children:e.jsx(j,{className:"h-5 w-36"})}),e.jsx(C,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx(j,{className:"h-full w-full"})})]}):e.jsxs(k,{className:d("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm",s),children:[e.jsx(M,{className:"px-3 py-2 shrink-0",children:e.jsxs(q,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx($e,{className:"w-4 h-4"}),a("analyticsCostLeverage.title")]})}),e.jsxs(C,{className:"px-3 pb-3 pt-0 flex-1 min-h-0 flex flex-col gap-2",children:[N?e.jsx("div",{className:"flex-1 flex flex-col gap-2 justify-center min-h-0",children:o.map(y=>e.jsx(gs,{window:y,privacyMode:n,t:a},y.label))}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-muted/50 flex items-center justify-center",children:e.jsx(W,{className:"w-5 h-5 text-muted-foreground"})}),e.jsx("p",{className:"text-xs text-muted-foreground text-center leading-relaxed max-w-[180px]",children:a("analyticsCostLeverage.noBaseline")})]}),e.jsxs("div",{className:"shrink-0 pt-2 mt-auto border-t",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{className:"w-3.5 h-3.5 text-muted-foreground shrink-0"}),e.jsx(we,{type:"text",inputMode:"decimal",value:x,onChange:y=>{p(y.target.value),S(null)},onBlur:m,onKeyDown:b,placeholder:a("analyticsCostLeverage.baselinePlaceholder"),disabled:r,className:d("h-7 text-xs",g&&"border-destructive focus-visible:ring-destructive")}),r&&e.jsx("span",{className:"text-[10px] text-muted-foreground animate-pulse",children:a("analyticsCostLeverage.saving")})]}),g&&e.jsx("p",{className:"text-[10px] text-destructive mt-1",children:g}),c&&e.jsxs("p",{className:"text-[10px] text-destructive mt-1",children:[a("analyticsCostLeverage.saveError"),": ",c]})]})]})]})}function gs({window:s,privacyMode:t,t:n}){const a=s.label==="7d"?"analyticsCostLeverage.window7d":s.label==="30d"?"analyticsCostLeverage.window30d":"analyticsCostLeverage.windowMonth",l=s.label==="7d"?z:s.label==="30d"?Te:z,o=s.ratio===null?"text-muted-foreground":s.ratio<2.5?"text-red-600 dark:text-red-400":s.ratio<10?"text-amber-600 dark:text-amber-400":"text-emerald-600 dark:text-emerald-400",i=s.ratio===null?"bg-muted/30":s.ratio<2.5?"bg-red-100/30 dark:bg-red-950/30":s.ratio<10?"bg-amber-100/30 dark:bg-amber-950/30":"bg-emerald-100/30 dark:bg-emerald-950/30";return e.jsxs("div",{className:d("flex items-center gap-2 px-2.5 py-2 rounded-lg border transition-colors",i),children:[e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx(l,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:n(a)})]}),e.jsxs("span",{className:d("text-xs text-muted-foreground font-mono",t&&w),children:["$",s.estimatedCost.toFixed(2)]}),e.jsx("div",{className:"flex-1 border-t border-dashed border-muted-foreground/30"}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[s.ratio!==null&&s.ratio>=10&&e.jsx(ie,{className:"w-3.5 h-3.5 text-emerald-500"}),e.jsx("span",{className:d("text-lg font-bold tabular-nums min-w-[56px] text-right",o,t&&w),children:s.ratioDisplay})]})]})}function ys(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(0)}K`:s.toString()}function js({models:s,isLoading:t,onModelClick:n,privacyMode:a}){const{t:l}=T();return e.jsxs(k,{className:"flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm lg:col-span-4",children:[e.jsx(M,{className:"px-3 py-2",children:e.jsxs(q,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(W,{className:"w-4 h-4"}),l("analyticsCostModel.title")]})}),e.jsx(C,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 overflow-y-auto",children:t?e.jsx(j,{className:"h-full w-full"}):e.jsxs("div",{className:"space-y-0.5",children:[[...s||[]].sort((o,i)=>i.cost-o.cost).map(o=>e.jsxs("button",{className:"group flex items-center text-xs w-full hover:bg-muted/50 rounded px-2 py-1.5 transition-colors cursor-pointer gap-3",onClick:i=>n(o,i),title:l("analyticsCostModel.clickForDetails"),children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 w-[180px] shrink-0",children:[e.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:re(o.model)}}),e.jsx("span",{className:"font-medium truncate group-hover:underline underline-offset-2",children:o.model})]}),e.jsx(Ns,{model:o}),e.jsx("span",{className:d("text-[10px] text-muted-foreground w-14 text-right shrink-0",a&&w),children:ys(o.tokens)}),e.jsxs("span",{className:d("font-mono font-medium w-16 text-right shrink-0",a&&w),children:["$",o.cost.toFixed(2)]}),e.jsx(Fe,{className:"w-3 h-3 opacity-0 group-hover:opacity-50 transition-opacity shrink-0"})]},o.model)),e.jsx(ws,{})]})})]})}function Ns({model:s}){const{t}=T(),n={input:"#335c67",output:"#fff3b0",cacheWrite:"#e09f3e",cacheRead:"#9e2a2b"},a=l=>s.cost>0?l/s.cost*100:0;return e.jsx("div",{className:"flex-1 flex items-center gap-1 min-w-0",children:e.jsxs("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden flex",children:[e.jsx("div",{className:"h-full",style:{backgroundColor:n.input,width:`${a(s.costBreakdown.input.cost)}%`},title:`${t("analyticsToken.input")}: $${s.costBreakdown.input.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:n.output,width:`${a(s.costBreakdown.output.cost)}%`},title:`${t("analyticsToken.output")}: $${s.costBreakdown.output.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:n.cacheWrite,width:`${a(s.costBreakdown.cacheCreation.cost)}%`},title:`${t("analyticsToken.cacheWrite")}: $${s.costBreakdown.cacheCreation.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:n.cacheRead,width:`${a(s.costBreakdown.cacheRead.cost)}%`},title:`${t("analyticsToken.cacheRead")}: $${s.costBreakdown.cacheRead.cost.toFixed(2)}`})]})})}function ws(){const{t:s}=T(),t=[{color:"#335c67",label:s("analyticsToken.input")},{color:"#fff3b0",label:s("analyticsToken.output"),hasBorder:!0},{color:"#e09f3e",label:s("analyticsToken.cacheWrite")},{color:"#9e2a2b",label:s("analyticsToken.cacheRead")}];return e.jsx("div",{className:"flex items-center gap-3 pt-2 px-2 text-[10px] text-muted-foreground border-t mt-2",children:t.map(({color:n,label:a,hasBorder:l})=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("div",{className:d("w-2 h-2 rounded-full",l&&"border border-muted-foreground/30"),style:{backgroundColor:n}}),a]},a))})}function bs({viewMode:s,trends:t,hourlyData:n,models:a,sessions:l,isTrendsLoading:o,isHourlyLoading:i,isModelsLoading:r,isSessionsLoading:c,isSummaryLoading:u,onModelClick:x}){const{privacyMode:p}=P(),{t:g}=T();return e.jsxs("div",{className:"min-h-0 grid gap-4 lg:grid-rows-[minmax(260px,1.2fr)_minmax(220px,0.9fr)]",children:[e.jsxs(k,{className:"flex flex-col h-full min-h-[220px] lg:min-h-[240px] overflow-hidden gap-0 py-0 shadow-sm",children:[e.jsx(M,{className:"px-3 py-2 shrink-0",children:e.jsxs(q,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(ie,{className:"w-4 h-4"}),g(s==="hourly"?"analytics.last24Hours":"analytics.usageTrends")]})}),e.jsx(C,{className:"px-3 pb-3 pt-0 flex-1 min-h-0",children:e.jsx(ns,{data:s==="hourly"?n||[]:t||[],isLoading:s==="hourly"?i:o,granularity:s==="hourly"?"hourly":"daily"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-10 gap-4 h-auto min-h-[220px] lg:h-full lg:min-h-[220px] lg:grid-rows-[minmax(0,1fr)] lg:[&>*]:min-h-0",children:[e.jsx(js,{models:a,isLoading:r,onModelClick:x,privacyMode:p}),e.jsxs(k,{className:"flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm lg:col-span-2",children:[e.jsx(M,{className:"px-3 py-2",children:e.jsxs(q,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Re,{className:"w-4 h-4"}),g("analytics.modelUsage")]})}),e.jsx(C,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 flex items-center justify-center",children:e.jsx(ls,{data:a||[],isLoading:r,className:"h-full w-full"})})]}),e.jsx(cs,{data:l,isLoading:c,className:"lg:col-span-2"}),e.jsx(ps,{className:"lg:col-span-2"})]})]})}function Rs(){return e.jsxs("div",{className:"space-y-4 h-full overflow-hidden",children:[e.jsxs(k,{className:"flex flex-col min-h-[300px]",children:[e.jsx(M,{className:"p-4 pb-2",children:e.jsx(j,{className:"h-4 w-32"})}),e.jsx(C,{className:"p-4 pt-0 flex-1",children:e.jsx(j,{className:"h-full w-full"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs(k,{className:"flex flex-col min-h-[250px]",children:[e.jsx(M,{className:"p-4 pb-2",children:e.jsx(j,{className:"h-4 w-28"})}),e.jsx(C,{className:"p-4 pt-2",children:e.jsx("div",{className:"space-y-3",children:[1,2,3,4,5].map(s=>e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(j,{className:"w-2.5 h-2.5 rounded-full"}),e.jsx(j,{className:"h-3 w-24"})]}),e.jsx(j,{className:"h-3 w-16"})]},s))})})]}),e.jsxs(k,{className:"flex flex-col min-h-[250px]",children:[e.jsx(M,{className:"p-4 pb-2",children:e.jsx(j,{className:"h-4 w-28"})}),e.jsx(C,{className:"p-4 pt-0 flex-1",children:e.jsxs("div",{className:"flex w-full h-full items-center",children:[e.jsx("div",{className:"flex-1 flex justify-center",children:e.jsx(j,{className:"h-[180px] w-[180px] rounded-full"})}),e.jsx("div",{className:"w-[140px] shrink-0 pl-2 space-y-2",children:[1,2,3,4].map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(j,{className:"w-2 h-2 rounded-full"}),e.jsx(j,{className:"h-3 w-20"})]},s))})]})})]})]})]})}function Ps(){const s=f.useRef(null),{dateRange:t,handleDateRangeChange:n,handleTodayClick:a,handleRefresh:l,isRefreshing:o,lastUpdatedText:i,viewMode:r,summary:c,isSummaryLoading:u,trends:x,hourlyData:p,models:g,sessions:S,isTrendsLoading:v,isHourlyLoading:h,isModelsLoading:m,isSessionsLoading:b,handleModelClick:N,selectedModel:y,popoverPosition:K,handlePopoverClose:G}=ss();return e.jsxs("div",{className:"grid h-full min-h-0 grid-rows-[auto_auto_minmax(0,1fr)] gap-4 overflow-y-auto px-4 py-4",children:[e.jsx(as,{dateRange:t,onDateRangeChange:n,onTodayClick:a,onRefresh:l,isRefreshing:o,lastUpdatedText:i,viewMode:r}),e.jsx(_e,{data:c,isLoading:u}),e.jsx(bs,{viewMode:r,trends:x,hourlyData:p,models:g,sessions:S,isTrendsLoading:v,isHourlyLoading:h,isModelsLoading:m,isSessionsLoading:b,isSummaryLoading:u,onModelClick:N}),e.jsxs(ae,{open:!!y,onOpenChange:I=>!I&&G(),children:[e.jsx(be,{asChild:!0,children:e.jsx("div",{ref:s,className:"fixed pointer-events-none",style:{left:K?.x??0,top:K?.y??0,width:1,height:1}})}),e.jsx(ne,{className:"w-80 p-3",side:"top",align:"center",children:y&&e.jsx(He,{model:y})})]})]})}export{Ps as AnalyticsPage,Rs as AnalyticsSkeleton};
@@ -1 +0,0 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{L as P,r as o}from"./react-vendor-CNOkPC89.js";import{a as p,B as y,c as k,d as x,w as E,be as M,C as g,j,k as N,Y as w,b as v,v as b,bf as U,bg as $,I as z,bh as B}from"./index-CKNvmYLR.js";import{_ as L,V as Q,a$ as J,v as V,E as Y,J as q,a6 as G,C as F,b0 as H,ao as K}from"./icons-DhBsHU-U.js";import"./tanstack-DWm6aJ-G.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const W={new:"border-blue-200 bg-blue-50 text-blue-700 dark:border-blue-900/50 dark:bg-blue-900/20 dark:text-blue-300",stable:"border-green-200 bg-green-50 text-green-700 dark:border-green-900/50 dark:bg-green-900/20 dark:text-green-300",planned:"border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-900/50 dark:bg-amber-900/20 dark:text-amber-300"};function X({status:s,className:a}){const{t}=p(),d={new:t("updates.statusNew"),stable:t("updates.statusStable"),planned:t("updates.statusPlanned")};return e.jsx(y,{variant:"outline",className:k("font-medium",W[s],a),children:d[s]})}const I="ccs:updates:notice-progress:v1";function Z(s){return s==="new"?"new":"seen"}function u(s,a){return a[s.id]??Z(s.status)}function A(s){return s!=="done"&&s!=="dismissed"}function ee(){if(typeof window>"u")return{};try{const s=window.localStorage.getItem(I);if(!s)return{};const a=JSON.parse(s);if(!a||typeof a!="object"||Array.isArray(a))return{};const t={};for(const[d,l]of Object.entries(a))typeof d=="string"&&(l==="new"||l==="seen"||l==="done"||l==="dismissed")&&(t[d]=l);return t}catch{return{}}}function se(s){typeof window>"u"||window.localStorage.setItem(I,JSON.stringify(s))}function R({state:s,className:a}){const{t}=p(),d={new:{label:t("updates.progressNeedsAction"),className:"border-amber-300/70 bg-amber-100/70 text-amber-800 dark:border-amber-500/40 dark:bg-amber-500/15 dark:text-amber-300",showDot:!0},seen:{label:t("updates.progressInReview"),className:"border-blue-300/70 bg-blue-100/70 text-blue-800 dark:border-blue-500/40 dark:bg-blue-500/15 dark:text-blue-300"},done:{label:t("updates.progressDone"),className:"border-emerald-300/70 bg-emerald-100/70 text-emerald-800 dark:border-emerald-500/40 dark:bg-emerald-500/15 dark:text-emerald-300"},dismissed:{label:t("updates.progressDismissed"),className:"border-muted-foreground/20 bg-muted text-muted-foreground dark:border-muted-foreground/30"}}[s];return e.jsxs(y,{variant:"outline",className:k("gap-1.5 border text-[10px] font-medium",d.className,a),children:[d.showDot&&e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),d.label]})}function ae({action:s}){const{t:a}=p();return e.jsxs("div",{className:"rounded-md border bg-muted/20 p-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 space-y-0.5",children:[e.jsx("p",{className:"text-sm font-medium",children:s.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.description})]}),s.type==="route"&&s.path&&e.jsx(x,{size:"sm",asChild:!0,children:e.jsxs(P,{to:s.path,children:[a("updates.open"),e.jsx(L,{className:"h-3.5 w-3.5"})]})})]}),s.type==="command"&&s.command&&e.jsxs("div",{className:"mt-2 flex items-center gap-2 rounded-md border bg-background px-2 py-1.5",children:[e.jsx(Q,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("code",{className:"min-w-0 flex-1 truncate text-[11px]",children:s.command}),e.jsx(E,{value:s.command})]})]})}function re({notice:s,progress:a,relatedEntries:t,onUpdateProgress:d}){const{t:l}=p();return s?e.jsxs("div",{className:"flex-1 min-w-0 bg-background grid grid-rows-[auto_minmax(0,1fr)] overflow-hidden",children:[e.jsxs("div",{className:"border-b bg-background px-4 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("h2",{className:"text-base font-semibold leading-tight",children:s.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.summary})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[a&&e.jsx(R,{state:a}),e.jsx(X,{status:s.status})]})]}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(J,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:l("updates.published",{date:M(s.publishedAt)})})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(x,{size:"sm",onClick:()=>d("done"),children:[e.jsx(V,{className:"h-4 w-4"}),l("updates.markDone")]}),e.jsxs(x,{size:"sm",variant:"outline",onClick:()=>d("dismissed"),children:[e.jsx(Y,{className:"h-4 w-4"}),l("updates.dismiss")]}),e.jsxs(x,{size:"sm",variant:"ghost",onClick:()=>d("new"),children:[e.jsx(q,{className:"h-4 w-4"}),l("updates.reopen")]})]})]}),e.jsx("div",{className:"min-h-0 p-4",children:e.jsxs("div",{className:"grid h-full gap-4 xl:grid-cols-[minmax(0,1.5fr)_minmax(320px,1fr)] overflow-hidden",children:[e.jsxs(g,{className:"h-full overflow-hidden",children:[e.jsxs(j,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4 text-primary"}),e.jsx(N,{className:"text-base",children:l("updates.doNext")})]}),e.jsx(w,{children:s.primaryAction})]}),e.jsx(v,{className:"min-h-0",children:e.jsx(b,{className:"h-full pr-2",children:e.jsx("div",{className:"space-y-3",children:s.actions.map(n=>e.jsx(ae,{action:n},`${s.id}-${n.id}`))})})})]}),e.jsxs("div",{className:"grid h-full grid-rows-[minmax(0,1fr)_minmax(0,1fr)] gap-4 overflow-hidden",children:[e.jsxs(g,{className:"overflow-hidden",children:[e.jsxs(j,{className:"pb-3",children:[e.jsx(N,{className:"text-base",children:l("updates.impactedIntegrations")}),e.jsx(w,{children:l("updates.impactedDesc")})]}),e.jsx(v,{className:"min-h-0",children:e.jsx(b,{className:"h-full pr-2",children:e.jsx("div",{className:"space-y-2",children:t.map(n=>e.jsxs("div",{className:"rounded-md border bg-muted/20 p-2.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("p",{className:"min-w-0 truncate text-sm font-medium",children:n.name}),e.jsx(y,{variant:"outline",className:"h-5 px-1.5 text-[10px]",children:U[n.scope]})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[n.routes[0]&&e.jsx(x,{size:"sm",variant:"outline",asChild:!0,children:e.jsx(P,{to:n.routes[0].path,children:n.routes[0].label})}),n.commands[0]&&e.jsxs("div",{className:"ml-auto flex min-w-0 items-center gap-1.5",children:[e.jsx("code",{className:"truncate rounded bg-background px-1.5 py-0.5 text-[11px]",children:n.commands[0]}),e.jsx(E,{value:n.commands[0]})]})]})]},n.id))})})})]}),e.jsxs(g,{className:"overflow-hidden",children:[e.jsxs(j,{className:"pb-3",children:[e.jsx(N,{className:"text-base",children:l("updates.whyMatters")}),e.jsx(w,{children:l("updates.whyMattersDesc")})]}),e.jsx(v,{className:"min-h-0",children:e.jsx(b,{className:"h-full pr-2",children:e.jsx("ul",{className:"space-y-2 text-sm text-muted-foreground",children:s.highlights.map(n=>e.jsxs("li",{children:["- ",n]},`${s.id}-${n}`))})})})]})]})]})})]}):e.jsx("div",{className:"flex h-full items-center justify-center rounded-lg border border-dashed bg-muted/20 p-6",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:l("updates.noUpdates")})})}function te({notice:s,progress:a,selected:t,onSelect:d}){return e.jsxs("button",{type:"button",onClick:d,className:k("w-full rounded-lg border px-3 py-3 text-left transition-colors",t?"border-primary/30 bg-primary/10":"border-transparent bg-background/40 hover:border-border hover:bg-muted/70"),children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:s.title}),e.jsx("p",{className:"line-clamp-2 text-xs text-muted-foreground",children:s.primaryAction})]}),e.jsx(F,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"})]}),e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-[11px] text-muted-foreground",children:M(s.publishedAt)}),e.jsx(R,{state:a})]})]})}function de(s,a){return a?[s.title,s.summary,s.primaryAction,...s.highlights,...s.commands,...s.actions.map(d=>`${d.label} ${d.description} ${d.command||""}`),...s.routes.map(d=>d.label)].join(" ").toLowerCase().includes(a):!0}function be(){const{t:s}=p(),a=o.useMemo(()=>[...$].sort((r,i)=>i.publishedAt.localeCompare(r.publishedAt)),[]),[t,d]=o.useState("inbox"),[l,n]=o.useState(""),[c,C]=o.useState(()=>ee()),[S,T]=o.useState(null);o.useEffect(()=>{se(c)},[c]);const h=o.useMemo(()=>{const r=l.trim().toLowerCase();return a.filter(i=>{const f=u(i,c);return de(i,r)?t==="done"?f==="done":t==="inbox"?A(f):!0:!1})},[a,c,l,t]),m=o.useMemo(()=>{const r=t==="all"?a:h;return r.find(i=>i.id===S)??r[0]??null},[a,S,t,h]),D=r=>{T(r.id),C(i=>u(r,i)!=="new"?i:{...i,[r.id]:"seen"})},O=o.useMemo(()=>a.filter(r=>A(u(r,c))).length,[a,c]),_=o.useMemo(()=>a.filter(r=>u(r,c)==="done").length,[a,c]);return e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"w-80 border-r bg-muted/30 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"p-4 border-b bg-background space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:s("updates.inboxTitle")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("updates.inboxSubtitle")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsxs("div",{className:"rounded-md border bg-background px-2 py-1.5",children:[e.jsx("p",{className:"text-muted-foreground",children:s("updates.needsAction")}),e.jsx("p",{className:"text-base font-semibold",children:O})]}),e.jsxs("div",{className:"rounded-md border bg-background px-2 py-1.5",children:[e.jsx("p",{className:"text-muted-foreground",children:s("updates.doneCount")}),e.jsx("p",{className:"text-base font-semibold",children:_})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(K,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(z,{value:l,onChange:r=>n(r.target.value),placeholder:s("updates.searchPlaceholder"),className:"h-9 pl-8"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:[{id:"inbox",label:s("updates.actionRequired")},{id:"done",label:s("updates.done")},{id:"all",label:s("updates.all")}].map(r=>e.jsx(x,{size:"sm",variant:t===r.id?"default":"outline",onClick:()=>d(r.id),children:r.label},r.id))})]}),e.jsx(b,{className:"flex-1",children:e.jsx("div",{className:"space-y-2 p-2",children:h.length===0?e.jsx("div",{className:"rounded-md border border-dashed p-3 text-xs text-muted-foreground",children:s("updates.noNotices")}):h.map(r=>e.jsx(te,{notice:r,progress:u(r,c),selected:m?.id===r.id,onSelect:()=>D(r)},r.id))})})]}),e.jsx(re,{notice:m,progress:m?u(m,c):null,relatedEntries:m?B(m):[],onUpdateProgress:r=>{m&&C(i=>({...i,[m.id]:r}))}})]})}export{be as UpdatesPage};