@kaitranntt/ccs 8.1.1-dev.2 → 8.1.1

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 (158) hide show
  1. package/dist/channels/official-channels-runtime.js +1 -1
  2. package/dist/channels/official-channels-runtime.js.map +1 -1
  3. package/dist/cliproxy/ai-providers/codex-reasoning-proxy.d.ts.map +1 -1
  4. package/dist/cliproxy/ai-providers/codex-reasoning-proxy.js +11 -88
  5. package/dist/cliproxy/ai-providers/codex-reasoning-proxy.js.map +1 -1
  6. package/dist/cliproxy/auth/auth-types.d.ts +0 -2
  7. package/dist/cliproxy/auth/auth-types.d.ts.map +1 -1
  8. package/dist/cliproxy/auth/oauth-handler.d.ts.map +1 -1
  9. package/dist/cliproxy/auth/oauth-handler.js +6 -12
  10. package/dist/cliproxy/auth/oauth-handler.js.map +1 -1
  11. package/dist/cliproxy/auth/oauth-trace/redactor.d.ts.map +1 -1
  12. package/dist/cliproxy/auth/oauth-trace/redactor.js +0 -1
  13. package/dist/cliproxy/auth/oauth-trace/redactor.js.map +1 -1
  14. package/dist/cliproxy/proxy/proxy-config-resolver.d.ts.map +1 -1
  15. package/dist/cliproxy/proxy/proxy-config-resolver.js +1 -11
  16. package/dist/cliproxy/proxy/proxy-config-resolver.js.map +1 -1
  17. package/dist/cliproxy/proxy/tool-sanitization-proxy.d.ts.map +1 -1
  18. package/dist/cliproxy/proxy/tool-sanitization-proxy.js +8 -160
  19. package/dist/cliproxy/proxy/tool-sanitization-proxy.js.map +1 -1
  20. package/dist/codex-auth/codex-config-symlink.js +4 -21
  21. package/dist/codex-auth/codex-config-symlink.js.map +1 -1
  22. package/dist/commands/config-channels-command.d.ts +4 -1
  23. package/dist/commands/config-channels-command.d.ts.map +1 -1
  24. package/dist/commands/config-channels-command.js +24 -20
  25. package/dist/commands/config-channels-command.js.map +1 -1
  26. package/dist/cursor/cursor-daemon-entry.d.ts.map +1 -1
  27. package/dist/cursor/cursor-daemon-entry.js +0 -44
  28. package/dist/cursor/cursor-daemon-entry.js.map +1 -1
  29. package/dist/cursor/cursor-daemon.d.ts +1 -2
  30. package/dist/cursor/cursor-daemon.d.ts.map +1 -1
  31. package/dist/cursor/cursor-daemon.js +5 -21
  32. package/dist/cursor/cursor-daemon.js.map +1 -1
  33. package/dist/cursor/cursor-models.d.ts.map +1 -1
  34. package/dist/cursor/cursor-models.js +1 -2
  35. package/dist/cursor/cursor-models.js.map +1 -1
  36. package/dist/cursor/cursor-profile-executor.d.ts +1 -1
  37. package/dist/cursor/cursor-profile-executor.d.ts.map +1 -1
  38. package/dist/cursor/cursor-profile-executor.js +4 -7
  39. package/dist/cursor/cursor-profile-executor.js.map +1 -1
  40. package/dist/cursor/cursor-runtime-probe.d.ts.map +1 -1
  41. package/dist/cursor/cursor-runtime-probe.js +2 -4
  42. package/dist/cursor/cursor-runtime-probe.js.map +1 -1
  43. package/dist/cursor/types.d.ts +0 -1
  44. package/dist/cursor/types.d.ts.map +1 -1
  45. package/dist/dispatcher/profile-resolver.d.ts +0 -16
  46. package/dist/dispatcher/profile-resolver.d.ts.map +1 -1
  47. package/dist/dispatcher/profile-resolver.js +3 -49
  48. package/dist/dispatcher/profile-resolver.js.map +1 -1
  49. package/dist/docker/docker-key-rotation.d.ts +0 -2
  50. package/dist/docker/docker-key-rotation.d.ts.map +1 -1
  51. package/dist/docker/docker-key-rotation.js +1 -9
  52. package/dist/docker/docker-key-rotation.js.map +1 -1
  53. package/dist/glmt/sse-parser.d.ts +0 -1
  54. package/dist/glmt/sse-parser.d.ts.map +1 -1
  55. package/dist/glmt/sse-parser.js +1 -13
  56. package/dist/glmt/sse-parser.js.map +1 -1
  57. package/dist/proxy/server/messages-route.d.ts.map +1 -1
  58. package/dist/proxy/server/messages-route.js +3 -69
  59. package/dist/proxy/server/messages-route.js.map +1 -1
  60. package/dist/proxy/transformers/request-transformer.d.ts.map +1 -1
  61. package/dist/proxy/transformers/request-transformer.js +2 -9
  62. package/dist/proxy/transformers/request-transformer.js.map +1 -1
  63. package/dist/shared/claude-extension-setup.d.ts.map +1 -1
  64. package/dist/shared/claude-extension-setup.js +1 -2
  65. package/dist/shared/claude-extension-setup.js.map +1 -1
  66. package/dist/targets/codex-adapter.js +1 -1
  67. package/dist/targets/codex-adapter.js.map +1 -1
  68. package/dist/ui/assets/{Trans-BIQ-yfAc.js → Trans-DyZQZ3e2.js} +1 -1
  69. package/dist/ui/assets/accounts-BPJltru3.js +1 -0
  70. package/dist/ui/assets/{alert-dialog-D0yey0YJ.js → alert-dialog-DWHL-dqd.js} +1 -1
  71. package/dist/ui/assets/api-BxPN-zy4.js +4 -0
  72. package/dist/ui/assets/{auth-section-BHZUn2Hv.js → auth-section-B4o90dwz.js} +1 -1
  73. package/dist/ui/assets/{backups-section-BNVlJSV3.js → backups-section-1AsdSIJO.js} +1 -1
  74. package/dist/ui/assets/{channels-BOB1P4Kt.js → channels-CU4Zdsc_.js} +1 -1
  75. package/dist/ui/assets/{checkbox-Bt-F3GmI.js → checkbox-CbCKGH8I.js} +1 -1
  76. package/dist/ui/assets/claude-extension-CWpjmIGt.js +1 -0
  77. package/dist/ui/assets/cliproxy-K6eBb5VO.js +4 -0
  78. package/dist/ui/assets/{cliproxy-ai-providers-CzyaYfYI.js → cliproxy-ai-providers-Dr4L5NRY.js} +6 -6
  79. package/dist/ui/assets/cliproxy-control-panel-Cz5r7kHP.js +1 -0
  80. package/dist/ui/assets/codex-0HdbW8NR.js +30 -0
  81. package/dist/ui/assets/{confirm-dialog-CYvBJC0z.js → confirm-dialog-b5Dahgnk.js} +1 -1
  82. package/dist/ui/assets/{copilot-Csab21fh.js → copilot-B1Ojakbt.js} +2 -2
  83. package/dist/ui/assets/{cursor-fOpftodW.js → cursor-PUtNVPx1.js} +1 -1
  84. package/dist/ui/assets/{droid-FIcjtOf-.js → droid-S2gclncb.js} +1 -1
  85. package/dist/ui/assets/{globalenv-section-CpIAk36Y.js → globalenv-section-7wKSmNSG.js} +1 -1
  86. package/dist/ui/assets/{health-D0HvHNud.js → health-hMLN_gyw.js} +1 -1
  87. package/dist/ui/assets/index-BMoGhs28.css +1 -0
  88. package/dist/ui/assets/{index-D0VoBTF3.js → index-BWboJia4.js} +1 -1
  89. package/dist/ui/assets/index-COt1pbk-.js +1 -0
  90. package/dist/ui/assets/{index-sIfjKy42.js → index-CcGVqYOy.js} +18 -18
  91. package/dist/ui/assets/{index-Cr4G276q.js → index-Coc3_ABK.js} +1 -1
  92. package/dist/ui/assets/{index-BTPa3KEN.js → index-Cx0dmbiQ.js} +1 -1
  93. package/dist/ui/assets/{index-D5G9mVmP.js → index-CxvNNHgE.js} +1 -1
  94. package/dist/ui/assets/{index-Dm_QojrJ.js → index-DkR2KVhF.js} +1 -1
  95. package/dist/ui/assets/{logs-B33n-VaM.js → logs-BRFVfyLc.js} +1 -1
  96. package/dist/ui/assets/{masked-input-BrUE6z_f.js → masked-input-4L9CIZGb.js} +1 -1
  97. package/dist/ui/assets/proxy-status-widget-s1UWOE23.js +1 -0
  98. package/dist/ui/assets/{raw-json-settings-editor-panel-DZRtQXbD.js → raw-json-settings-editor-panel-DXh8c8rA.js} +1 -1
  99. package/dist/ui/assets/{searchable-select-D2smFEI5.js → searchable-select-CtvEQrMo.js} +1 -1
  100. package/dist/ui/assets/{separator-BvoSJCHW.js → separator-E0ISp1SN.js} +1 -1
  101. package/dist/ui/assets/{shared-qKNFwLmT.js → shared-BeYwHeNS.js} +2 -2
  102. package/dist/ui/assets/{table-DYyc1gJc.js → table-BBslZvNP.js} +1 -1
  103. package/dist/ui/assets/updates-CDrm903n.js +1 -0
  104. package/dist/ui/assets/{use-accounts-BR64_yUk.js → use-accounts-BdalFsdY.js} +1 -1
  105. package/dist/ui/index.html +2 -2
  106. package/dist/utils/browser/browser-settings.d.ts.map +1 -1
  107. package/dist/utils/browser/browser-settings.js +3 -13
  108. package/dist/utils/browser/browser-settings.js.map +1 -1
  109. package/dist/utils/glmt-deprecation.d.ts.map +1 -1
  110. package/dist/utils/glmt-deprecation.js +3 -1
  111. package/dist/utils/glmt-deprecation.js.map +1 -1
  112. package/dist/web-server/index.d.ts.map +1 -1
  113. package/dist/web-server/index.js +9 -0
  114. package/dist/web-server/index.js.map +1 -1
  115. package/dist/web-server/middleware/auth-middleware.d.ts.map +1 -1
  116. package/dist/web-server/middleware/auth-middleware.js +4 -26
  117. package/dist/web-server/middleware/auth-middleware.js.map +1 -1
  118. package/dist/web-server/routes/cliproxy-auth-routes.d.ts +0 -10
  119. package/dist/web-server/routes/cliproxy-auth-routes.d.ts.map +1 -1
  120. package/dist/web-server/routes/cliproxy-auth-routes.js +13 -45
  121. package/dist/web-server/routes/cliproxy-auth-routes.js.map +1 -1
  122. package/dist/web-server/routes/cliproxy-local-proxy.d.ts.map +1 -1
  123. package/dist/web-server/routes/cliproxy-local-proxy.js +8 -25
  124. package/dist/web-server/routes/cliproxy-local-proxy.js.map +1 -1
  125. package/dist/web-server/routes/cursor-routes.d.ts.map +1 -1
  126. package/dist/web-server/routes/cursor-routes.js +1 -6
  127. package/dist/web-server/routes/cursor-routes.js.map +1 -1
  128. package/dist/web-server/routes/image-analysis-routes.d.ts.map +1 -1
  129. package/dist/web-server/routes/image-analysis-routes.js +0 -7
  130. package/dist/web-server/routes/image-analysis-routes.js.map +1 -1
  131. package/dist/web-server/routes/settings-routes.d.ts.map +1 -1
  132. package/dist/web-server/routes/settings-routes.js +1 -10
  133. package/dist/web-server/routes/settings-routes.js.map +1 -1
  134. package/dist/web-server/services/claude-extension-settings-service.d.ts.map +1 -1
  135. package/dist/web-server/services/claude-extension-settings-service.js +1 -5
  136. package/dist/web-server/services/claude-extension-settings-service.js.map +1 -1
  137. package/lib/mcp/ccs-browser-server.cjs +13 -24
  138. package/package.json +1 -1
  139. package/dist/cliproxy/proxy/upstream-response-timeout.d.ts +0 -14
  140. package/dist/cliproxy/proxy/upstream-response-timeout.d.ts.map +0 -1
  141. package/dist/cliproxy/proxy/upstream-response-timeout.js +0 -72
  142. package/dist/cliproxy/proxy/upstream-response-timeout.js.map +0 -1
  143. package/dist/cursor/cursor-daemon-auth.d.ts +0 -2
  144. package/dist/cursor/cursor-daemon-auth.d.ts.map +0 -1
  145. package/dist/cursor/cursor-daemon-auth.js +0 -49
  146. package/dist/cursor/cursor-daemon-auth.js.map +0 -1
  147. package/dist/ui/assets/accounts-bN7DnjXo.js +0 -1
  148. package/dist/ui/assets/api-CEtMc2bM.js +0 -4
  149. package/dist/ui/assets/claude-extension-AzKgsH0H.js +0 -1
  150. package/dist/ui/assets/cliproxy-C1liaQi8.js +0 -4
  151. package/dist/ui/assets/cliproxy-control-panel-DmkEW68l.js +0 -1
  152. package/dist/ui/assets/codex-B2FLnjZI.js +0 -30
  153. package/dist/ui/assets/index-G3mgTfgR.css +0 -1
  154. package/dist/ui/assets/index-N35Xkk8N.js +0 -1
  155. package/dist/ui/assets/proxy-status-widget-Dm2ziI5D.js +0 -1
  156. package/dist/ui/assets/updates-XXi3TQNZ.js +0 -1
  157. package/scripts/github/stable-release-issue-cleanup-lib.mjs +0 -113
  158. package/scripts/github/stable-release-issue-cleanup.mjs +0 -134
@@ -1,4 +0,0 @@
1
- import{j as e}from"./radix-ui-nu4wz29m.js";import{r as c}from"./react-vendor-Bjx91N7w.js";import{a as wt,u as ss,b as Is}from"./tanstack-bhJxV1h8.js";import{a9 as Ts,a as W,e as U,C as as,b as ns,aa as rs,ab as is,c as X,P as kt,B as z,ac as xe,L as ee,I as ce,j as $e,k as We,l as Qe,m as Je,n as Se,ad as os,ae as ls,af as Es,ag as Rs,ah as Os,u as ds,ai as Ct,aj as At,ak as St,al as Mt,Y as he,am as cs,an as Ht,ao as _s,ap as Ls,aq as Re,ar as us,_ as Xe,as as Fs,at as qt,au as zt,av as Us,aw as Ks,ax as Hs,ay as qs,az as zs,aA as Gs,aB as Bs,aC as Vs,aD as Gt,aE as $s,z as ms,aF as Ws,x as Pt,aG as Qs,aH as Dt,aI as Bt,aJ as ps,aK as Js,w as Xs,aL as Ys,aM as Zs,T as ft,o as gt,p as vt,q as jt,aN as ea,aO as ta,aP as sa,aQ as ct,aR as aa,aS as na,aT as ra,aU as ia,aV as oa,aW as la,U as da,V as ca,W as Vt,X as $t,aX as ua,aY as ma,aZ as pa,a_ as xa,a$ as ha,b0 as fa,b1 as ga,b2 as va,b3 as ja,b4 as ba,b5 as Na,b6 as ze,b7 as ya,S as wa}from"./index-sIfjKy42.js";import{C as bt}from"./default-ports-1QQSffYX.js";import{t as B}from"./notifications-B4_o8bcr.js";import{C as xs,L as ue,p as Me,$ as ka,m as Pe,o as hs,aG as It,R as at,q as Oe,aa as Tt,T as et,a7 as Wt,aH as fs,aF as Ca,z as Et,Z as _e,_ as gs,i as Aa,u as vs,aI as Sa,au as Ma,X as Rt,a9 as nt,J as js,D as bs,aJ as Pa,at as Ns,aK as Da,ax as Ia,aL as tt}from"./icons-DzKUh8vG.js";import{R as Ye,A as Qt,D as ut,i as Ta,a as Ea}from"./antigravity-responsibility-constants-Bvh4Ybz0.js";import{C as Ze}from"./checkbox-Bt-F3GmI.js";import{C as Ra}from"./confirm-dialog-CYvBJC0z.js";import{S as Ot}from"./separator-BvoSJCHW.js";import{S as Oa}from"./searchable-select-D2smFEI5.js";import{P as _a}from"./proxy-status-widget-Dm2ziI5D.js";import"./utils-CzKF5WmX.js";import"./form-utils-CuHzLhJZ.js";import"./charts-eIPy2oG6.js";import"./alert-dialog-D0yey0YJ.js";import"./Trans-BIQ-yfAc.js";const ne="gemini-3.1-pro-high",Ie="gemini-3.1-pro-low",La=Object.freeze({"gemini-3-pro-high":ne,"gemini-3.1-pro-high":ne,"gemini-3-pro-low":Ie,"gemini-3.1-pro-low":Ie,"gemini-3-pro-preview":ne,"gemini-3-pro-preview-customtools":ne,"gemini-3.1-pro-preview":ne,"gemini-3.1-pro-preview-customtools":ne,"gemini-3-1-pro-preview":ne,"gemini-3-1-pro-preview-customtools":ne}),ys=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"}),Fa=/^gemini-(\d+(?:[.-]\d+)*)-(pro|flash)-preview(-customtools)?$/i,Ua=["agy/","gcli/"];function J(t){return Ts(t).toLowerCase()}function Ka(t){const a=t.trim(),s=a.toLowerCase();for(const n of Ua)if(s.startsWith(n))return a.slice(n.length);return a}function Ha(t){return t.replace(/-customtools$/i,"")}function qa(t){return La[J(t)]}function st(t){const a=J(t),s=a.match(Fa);if(!s)return null;const[,n,r,o]=s;return{normalizedId:a,version:n.split(/[.-]/).map(l=>Number(l)),family:r,customtools:!!o,dottedVersion:n.includes(".")}}function ws(t,a){const s=Math.max(t.length,a.length);for(let n=0;n<s;n+=1){const r=t[n]??0,o=a[n]??0;if(r!==o)return r>o?1:-1}return 0}function za(t,a,s){if(t.customtools!==a.customtools)return t.customtools?1:-1;const n=ws(t.version,a.version);if(n!==0)return n>0?-1:1;const r=+(t.dottedVersion===s.dottedVersion),o=+(a.dottedVersion===s.dottedVersion);return r!==o?o-r:t.normalizedId.localeCompare(a.normalizedId)}function Jt(t,a){const s=J(a);return t.find(n=>J(n.id)===s)?.id}function Ga(t,a){const s=st(t);return!s||a.length===0?void 0:a.map(r=>{const o=st(r.id);return!o||o.family!==s.family?null:{id:r.id,info:o}}).filter(r=>!!r).sort((r,o)=>za(r.info,o.info,s))[0]?.id}const je={agy:{provider:"agy",displayName:"Antigravity",defaultModel:"claude-opus-4-6-thinking",models:[{id:"claude-opus-4-6-thinking",name:"Claude Opus 4.6 Thinking",description:"Latest flagship, extended thinking",extendedContext:!1,presetMapping:{default:"claude-opus-4-6-thinking",opus:"claude-opus-4-6-thinking",sonnet:"claude-sonnet-4-6",haiku:"claude-sonnet-4-6"}},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",description:"Latest Sonnet with thinking budget support",presetMapping:{default:"claude-sonnet-4-6",opus:"claude-opus-4-6-thinking",sonnet:"claude-sonnet-4-6",haiku:"claude-sonnet-4-6"}},{id:ne,name:"Gemini Pro High",description:"Current Antigravity Gemini Pro route with higher reasoning budget",extendedContext:!0,presetMapping:{default:ne,opus:ne,sonnet:ne,haiku:"gemini-3-1-flash-preview"}},{id:Ie,name:"Gemini Pro Low",description:"Current Antigravity Gemini Pro route with the lighter quota tier",extendedContext:!0,presetMapping:{default:Ie,opus:Ie,sonnet:Ie,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:ne,sonnet:ne,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.4",models:[{id:"gpt-5.5",name:"GPT-5.5",tier:"paid",description:"Newest Codex-released GPT-5 family model; falls back to GPT-5.4 on free plans",codexMaxEffort:"xhigh",codexServiceTiers:["fast"],presetMapping:{default:"gpt-5.5",opus:"gpt-5.5",sonnet:"gpt-5.5",haiku:"gpt-5.4-mini"}},{id:"gpt-5.4",name:"GPT-5.4",description:"Recommended Codex default for most coding and agentic tasks",codexMaxEffort:"xhigh",codexServiceTiers:["fast"],presetMapping:{default:"gpt-5.4",opus:"gpt-5.4",sonnet:"gpt-5.4",haiku:"gpt-5.4-mini"}},{id:"gpt-5.4-mini",name:"GPT-5.4 Mini",description:"Fast, lower-cost Codex option for lighter tasks and haiku-tier routing",codexMaxEffort:"high",presetMapping:{default:"gpt-5.4-mini",opus:"gpt-5.4",sonnet:"gpt-5.4",haiku:"gpt-5.4-mini"}},{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",tier:"paid",description:"Previous flagship coding model whose capabilities now power GPT-5.4",codexMaxEffort:"xhigh",presetMapping:{default:"gpt-5.3-codex",opus:"gpt-5.3-codex",sonnet:"gpt-5.3-codex",haiku:"gpt-5.4-mini"}},{id:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",tier:"paid",description:"Research preview model for ChatGPT Pro subscribers, optimized for near-instant coding iteration",codexMaxEffort:"xhigh",presetMapping:{default:"gpt-5.3-codex-spark",opus:"gpt-5.3-codex",sonnet:"gpt-5.3-codex",haiku:"gpt-5.4-mini"}},{id:"gpt-5.2",name:"GPT-5.2",description:"Previous general-purpose Codex model",codexMaxEffort:"xhigh",presetMapping:{default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.2",haiku:"gpt-5.4-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-7",name:"Claude Opus 4.7",description:"Latest flagship model",extendedContext:!0,presetMapping:{default:"claude-opus-4-7",opus:"claude-opus-4-7",sonnet:"claude-sonnet-4-6",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-opus-4-6",name:"Claude Opus 4.6",description:"Previous 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 Ee(t,a){if(!t)return;const s=J(a);if(t.provider==="agy"){const l=qa(s);if(l){const d=t.models.find(i=>i.id===l);if(d)return d}}const n=ys[s.toLowerCase()],r=t.models.find(l=>l.id===s||l.id===n);if(r)return r;const o=st(s);if(o)return t.models.map(l=>({model:l,info:st(l.id)})).filter(l=>!!(l.info&&l.info.family===o.family)).sort((l,d)=>ws(d.info.version,l.info.version))[0]?.model}function Ba(t){if(t==="free")return"free";if(typeof t=="string"&&t.trim().length>0)return"paid"}function Va(t,a){const s=je[t.toLowerCase()];if(!a||a.models.length===0)return s;const n=a.models.map(d=>({id:d.id,owned_by:a.provider})),r=a.models.map(d=>{const i=Ee(s,d.id);return{...d,name:d.name||i?.name||d.id,tier:i?.tier??Ba(d.tier),description:d.description??i?.description,broken:i?.broken,issueUrl:i?.issueUrl,deprecated:i?.deprecated,deprecationReason:i?.deprecationReason,extendedContext:d.extendedContext??i?.extendedContext,presetMapping:i?.presetMapping}}),o=s?.defaultModel?Te(s.defaultModel,n):void 0,l=typeof o=="string"&&n.some(d=>J(d.id)===J(o));return{provider:a.provider,displayName:a.displayName||s?.displayName||t,defaultModel:l?o:a.defaultModel,models:r}}function _t(t){const a={},s=new Set([...Object.keys(je),...Object.keys(t??{})]);for(const n of s){const r=Va(n,t?.[n]);r&&(a[n]=r)}return a}function ks(t,a,s){const n=Ee(s,a);return n||Ee(je[t.toLowerCase()],a)}function Te(t,a=[]){const s=J(t),n=Ga(s,a);if(n)return n;const r=Jt(a,s);if(r)return r;const o=ys[s];return(o?Jt(a,o):void 0)??s}function $a(t,a=[]){return{default:Te(t.default,a),opus:Te(t.opus,a),sonnet:Te(t.sonnet,a),haiku:Te(t.haiku,a)}}function Lt(t,a=[]){if(!t)return[];const s=je[t.provider.toLowerCase()]??t,n=new Set;return s.models.map(r=>{const o=Te(r.id,a),l=r.presetMapping?$a(r.presetMapping,a):void 0,d=t.models.find(i=>J(i.id)===J(o));return{...r,id:o,name:d?.name||r.name,description:d?.description??r.description,presetMapping:l}}).filter(r=>n.has(r.id)?!1:(n.add(r.id),!0))}function Wa(t,a,s=[]){const n=t.trim().toLowerCase();if(!a||!n)return[];const r=je[n]??a,o=Lt(a,s),l=new Set(o.map(m=>J(m.id))),d=new Set(o.map(m=>Ee(r,m.id)?.id).filter(m=>!!m).map(m=>J(m))),i=new Set,p=new Set(s.map(m=>J(m.id)));return s.filter(m=>{const v=J(m.id),x=Ka(m.id),b=Ha(x),N=Ee(r,x)??Ee(r,b);if(l.has(J(x))||v!==J(x)&&p.has(J(x)))return!1;const C=J(b);if(C!==J(x)&&p.has(C))return!1;const T=N?J(N.id):C;return N&&d.has(T)||i.has(T)||!N&&n==="agy"?!1:(i.add(T),!0)})}function Qa(t,a,s){return ks(t,a,s)?.extendedContext===!0}const mt="ccs-internal-managed";async function Ja(){try{const t=await fetch("/api/settings/auth/tokens/raw");return t.ok?(await t.json())?.apiKey?.value??mt:mt}catch{return mt}}async function Xa(t,a){if(a)return a;try{const s=await fetch("/api/cliproxy/catalog");if(!s.ok)return je[t];const n=await s.json();return _t(n.catalogs)[t]??je[t]}catch{return je[t]}}async function Nt(t,a,s){const n=await Xa(t,s);if(!n)return{success:!1};const r=n.models.find(p=>p.id===n.defaultModel)||n.models[0],o=r?.presetMapping||{default:n.defaultModel,opus:n.defaultModel,sonnet:n.defaultModel,haiku:n.defaultModel},l=await Ja(),i={env:{ANTHROPIC_BASE_URL:`http://127.0.0.1:${bt}/api/provider/${t}`,ANTHROPIC_AUTH_TOKEN:l,ANTHROPIC_MODEL:o.default,ANTHROPIC_DEFAULT_OPUS_MODEL:o.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:o.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:o.haiku}};try{return{success:(await fetch(`/api/settings/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:i})})).ok,presetName:r?.name||n.defaultModel}}catch{return{success:!1}}}function Ya({currentProgress:t,allSteps:a}){return e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:a.map((s,n)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${t>=n?"bg-primary":"bg-muted"}`},s))})}function Za({providers:t,onSelect:a}){return e.jsx("div",{className:"grid gap-2",children:t.map(s=>e.jsxs("button",{onClick:()=>a(s.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:s.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s.description})]}),e.jsx(xs,{className:"w-4 h-4 text-muted-foreground"})]},s.id))})}function en({selectedProvider:t,providers:a,authCommand:s,isRefreshing:n,isPending:r,onBack:o,onStartAuth:l,onRefresh:d}){const{t:i}=W(),[p,m]=c.useState(!1),v=async x=>{await navigator.clipboard.writeText(x),m(!0),setTimeout(()=>m(!1),2e3)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:i("setupWizard.authStep.authenticateWith",{provider:a.find(x=>x.id===t)?.name})}),e.jsx(U,{onClick:l,disabled:r,className:"w-full gap-2",size:"lg",children:r?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-4 h-4 animate-spin"}),i("setupWizard.authStep.authenticating")]}):e.jsxs(e.Fragment,{children:[e.jsx(Me,{className:"w-4 h-4"}),i("setupWizard.authStep.authenticateInBrowser")]})}),r&&e.jsx("p",{className:"text-xs text-muted-foreground",children:i("setupWizard.authStep.completeOAuth")})]}),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:i("setupWizard.authStep.orUseTerminal")})})]}),e.jsx(as,{children:e.jsxs(ns,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ka,{className:"w-4 h-4"}),i("setupWizard.authStep.runCommandHint")]}),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:s}),e.jsx(U,{variant:"outline",size:"icon",onClick:()=>v(s),children:p?e.jsx(Pe,{className:"w-4 h-4 text-green-500"}):e.jsx(hs,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(U,{variant:"ghost",onClick:o,disabled:r,children:[e.jsx(It,{className:"w-4 h-4 mr-2"}),i("setupWizard.authStep.back")]}),e.jsxs(U,{variant:"outline",onClick:d,disabled:n||r,children:[e.jsx(at,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),i(n?"setupWizard.authStep.checking":"setupWizard.authStep.refreshStatus")]})]})]})}function tn({accounts:t,privacyMode:a,onSelect:s,onAddNew:n,onBack:r}){const{t:o}=W();return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:o("setupWizard.accountStep.selectAccount",{count:t.length})}),e.jsx("div",{className:"grid gap-2 max-h-[320px] overflow-y-auto pr-1",children:t.map(l=>{const d=rs(l.id,l.email,l.tokenFile),i=l.provider?.toLowerCase()==="codex"?is(d):null;return e.jsxs("button",{type:"button",onClick:()=>s(l),className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center",children:e.jsx(Oe,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:X("font-medium",a&&kt),children:d.email}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[i?.label?e.jsx(z,{variant:"outline",className:X("text-[10px] h-4 px-1.5 border-transparent",i.audience==="business"?"bg-sky-500/12 text-sky-700 dark:text-sky-300":i.audience==="free"?"bg-slate-200/70 text-slate-700 dark:bg-slate-700/40 dark:text-slate-200":"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300"),children:i.label}):d.audienceLabel?e.jsx(z,{variant:"outline",className:X("text-[10px] h-4 px-1.5 border-transparent",d.audience==="business"?"bg-sky-500/12 text-sky-700 dark:text-sky-300":d.audience==="free"?"bg-slate-200/70 text-slate-700 dark:bg-slate-700/40 dark:text-slate-200":"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300"),children:d.audienceLabel}):null,!i?.label&&d.detailLabel&&e.jsx(z,{variant:"outline",className:"text-[10px] h-4 px-1.5",children:d.detailLabel}),l.isDefault&&e.jsx("span",{className:"text-xs text-muted-foreground",children:o("setupWizard.accountStep.defaultAccount")})]})]})]}),e.jsx(xs,{className:"w-4 h-4 text-muted-foreground"})]},l.id)})}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:o("setupWizard.accountStep.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:o("setupWizard.accountStep.addNewAccount")}),e.jsx("div",{className:"text-xs text-muted-foreground",children:o("setupWizard.accountStep.addNewAccountDesc")})]})]}),e.jsx("div",{className:"flex items-center justify-between pt-2",children:e.jsxs(U,{variant:"ghost",onClick:r,children:[e.jsx(It,{className:"w-4 h-4 mr-2"}),o("setupWizard.accountStep.back")]})})]})}const Xt="__custom__";function sn({selectedProvider:t,catalog:a,selectedAccount:s,variantName:n,modelName:r,isPending:o,privacyMode:l,onVariantNameChange:d,onModelChange:i,onBack:p,onSkip:m,onCreate:v}){const{t:x}=W(),b=a||je[t],N=b?.models||[],C=r&&!N.some(g=>g.id===r),[T,M]=c.useState(C),S=t==="agy"&&r.trim().length>0?xe(r):!1,w=s?rs(s.id,s.email,s.tokenFile):null,y=t==="codex"&&w?is(w):null,h=g=>{g===Xt?(M(!0),i("")):(M(!1),i(g))};return e.jsxs("div",{className:"space-y-4",children:[s&&e.jsxs("div",{className:"flex min-w-0 items-start gap-2 rounded-md bg-muted/50 p-2 text-sm",children:[e.jsx(Oe,{className:"w-4 h-4 shrink-0"}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("span",{children:[x("setupVariant.using")," ",e.jsx("span",{className:X("break-all",l&&kt),children:w?.email})]}),(w?.audienceLabel||w?.detailLabel)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[y?.label?e.jsx(z,{variant:"outline",className:X("text-[10px] h-4 px-1.5 border-transparent",y.audience==="business"?"bg-sky-500/12 text-sky-700 dark:text-sky-300":y.audience==="free"?"bg-slate-200/70 text-slate-700 dark:bg-slate-700/40 dark:text-slate-200":"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300"),children:y.label}):w?.audienceLabel?e.jsx(z,{variant:"outline",className:X("text-[10px] h-4 px-1.5 border-transparent",w.audience==="business"?"bg-sky-500/12 text-sky-700 dark:text-sky-300":w.audience==="free"?"bg-slate-200/70 text-slate-700 dark:bg-slate-700/40 dark:text-slate-200":"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300"),children:w.audienceLabel}):null,!y?.label&&w?.detailLabel&&e.jsx(z,{variant:"outline",className:"text-[10px] h-4 px-1.5",children:w.detailLabel})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ee,{htmlFor:"variant-name",children:x("setupVariant.variantNameRequired")}),e.jsx(ce,{id:"variant-name",value:n,onChange:g=>d(g.target.value),placeholder:x("setupVariant.variantNamePlaceholder")}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[x("setupVariant.invokeHintPrefix")," ccs ",n||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ee,{children:x("setupVariant.model")}),T?e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{value:r,onChange:g=>i(g.target.value),placeholder:x("setupVariant.modelPlaceholder")}),S&&e.jsx("p",{className:"text-xs text-destructive",children:x("providerEditor.agyDenylist")}),e.jsx("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:()=>{M(!1),t==="agy"&&xe(r)&&i("")},children:x("setupVariant.choosePresetInstead")})]}):e.jsxs($e,{value:N.some(g=>g.id===r)?r:"",onValueChange:h,children:[e.jsx(We,{className:"min-w-0",children:e.jsx(Qe,{placeholder:x("setupVariant.selectModel")})}),e.jsxs(Je,{className:"max-w-[calc(100vw-2rem)]",children:[N.map(g=>e.jsx(Se,{value:g.id,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate",children:g.name}),g.description&&e.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:["- ",g.description]})]})},g.id)),e.jsx(Se,{value:Xt,children:e.jsx("span",{className:"text-primary",children:x("setupVariant.customModelName")})})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:T?x("setupVariant.enterAnyModel"):x("setupVariant.defaultModel",{model:b?.defaultModel||x("setupVariant.providerDefault")})})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs(U,{variant:"ghost",onClick:p,className:"justify-start",children:[e.jsx(It,{className:"w-4 h-4 mr-2"}),x("setupVariant.back")]}),e.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:items-center",children:[e.jsx(U,{variant:"ghost",onClick:m,children:x("setupVariant.skip")}),e.jsx(U,{onClick:v,disabled:!n||o||S,children:x(o?"setupVariant.creating":"setupVariant.createVariant")})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:x("setupVariant.skipHint")})]})}function an({variantName:t,onClose:a}){const{t:s}=W();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(Pe,{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:s("setupWizard.successStep.title")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("setupWizard.successStep.subtitle")})]}),e.jsx(as,{children:e.jsxs(ns,{className:"p-4 space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:s("setupWizard.successStep.usage")}),e.jsxs("code",{className:"block px-3 py-2 bg-muted rounded-md font-mono text-sm",children:["ccs ",t,' "your prompt here"']})]})}),e.jsx(U,{onClick:a,className:"w-full",children:s("setupWizard.successStep.done")})]})}function nn({open:t,onClose:a}){const[s,n]=c.useState("provider"),[r,o]=c.useState(""),[l,d]=c.useState(null),[i,p]=c.useState(""),[m,v]=c.useState(""),[x,b]=c.useState(!1),[N,C]=c.useState(!1),{data:T,refetch:M}=os(),{data:S}=ls(),w=Es(),y=Rs(),h=Os(),{privacyMode:g}=ds(),E=T?.authStatus.find(k=>k.provider===r),u=c.useMemo(()=>E?.accounts||[],[E?.accounts]),I=c.useMemo(()=>_t(S?.catalogs),[S?.catalogs]),A=!!S;c.useEffect(()=>{if(!t){const k=setTimeout(()=>{n("provider"),o(""),d(null),p(""),v(""),C(!1)},0);return()=>clearTimeout(k)}},[t]),c.useEffect(()=>{if(s==="auth"&&u.length>0&&!N){const k=setTimeout(()=>{n("account")},0);return()=>clearTimeout(k)}},[s,u,N]);const q=async()=>{b(!0),await M(),b(!1)},P=()=>{const k=(E?.accounts?.length||0)===0;y.mutate({provider:r},{onSuccess:async Q=>{if(k){const j=await Nt(r,void 0,A?I[r]:void 0);j.success&&j.presetName?B.success(`Applied "${j.presetName}" preset`):j.success||B.warning(he.t("commonToast.accountAddedPresetFailed"))}Q.account&&(d(Q.account),n("variant")),M()}})},_=k=>{o(k),(T?.authStatus.find(Y=>Y.provider===k)?.accounts||[]).length===0?n("auth"):n("account")},H=k=>{d(k),n("variant")},G=async()=>{if(!(!i||!r))try{await w.mutateAsync({name:i,provider:r,model:m||void 0,account:l?.id}),n("success")}catch(k){console.error("Failed to create variant:",k)}},V=`ccs ${r} --auth --add`,R=Ls(s),O=k=>{if(!k&&(y.isPending&&r&&h.mutate(r),s==="success"||s==="provider")){a();return}};return e.jsx(Ct,{open:t,onOpenChange:O,children:e.jsxs(At,{className:"grid max-h-[calc(100dvh-2rem)] w-[calc(100vw-2rem)] max-w-lg grid-rows-[auto_minmax(0,1fr)_auto] overflow-hidden p-0 sm:max-w-lg",onPointerDownOutside:k=>{s!=="success"&&s!=="provider"&&k.preventDefault()},onEscapeKeyDown:k=>{(y.isPending||w.isPending)&&k.preventDefault()},children:[e.jsxs(St,{className:"min-w-0 px-6 pt-6 pr-12",children:[e.jsxs(Mt,{className:"flex min-w-0 items-center gap-2",children:[e.jsx(Tt,{className:"w-5 h-5 text-primary"}),he.t("setupWizard.title")]}),e.jsxs(cs,{children:[s==="provider"&&he.t("setupWizard.stepProviderDesc"),s==="auth"&&he.t("setupWizard.stepAuthDesc"),s==="account"&&he.t("setupWizard.stepAccountDesc"),s==="variant"&&he.t("setupWizard.stepVariantDesc"),s==="success"&&he.t("setupWizard.stepSuccessDesc")]})]}),e.jsxs("div",{className:"min-h-0 space-y-4 overflow-y-auto px-6 py-4",children:[s==="provider"&&e.jsx(Za,{providers:Ht,onSelect:_}),s==="auth"&&e.jsx(en,{selectedProvider:r,providers:Ht,authCommand:V,isRefreshing:x,isPending:y.isPending,onBack:()=>n("provider"),onStartAuth:P,onRefresh:q}),s==="account"&&e.jsx(tn,{accounts:u,privacyMode:g,onSelect:H,onAddNew:()=>{C(!0),n("auth")},onBack:()=>n("provider")}),s==="variant"&&e.jsx(sn,{selectedProvider:r,catalog:I[r],selectedAccount:l,variantName:i,modelName:m,isPending:w.isPending,privacyMode:g,onVariantNameChange:p,onModelChange:v,onBack:()=>u.length>0?n("account"):n("provider"),onSkip:a,onCreate:G}),s==="success"&&e.jsx(an,{variantName:i,onClose:a})]}),e.jsx("div",{className:"px-6 pb-6",children:e.jsx(Ya,{currentProgress:R,allSteps:_s})})]})})}const rn=3e3,on=300*1e3,ln=3;function pt(t){t.invalidateQueries({queryKey:["cliproxy-catalog"]}),t.invalidateQueries({queryKey:["cliproxy-models"]})}async function xt(t){const a=await t.text();if(!a)return{};try{return JSON.parse(a)}catch{const s=t.status>=400?`Request failed with status ${t.status}`:void 0;return s?{error:s}:{}}}function dn(t,a){const s=typeof t.message=="string"?t.message:typeof t.error=="string"?t.error:a,n=Array.isArray(t.hints)?t.hints.filter(r=>typeof r=="string"&&r.trim().length>0):[];return n.length>0?[s,...n].join(`
2
- `):s}const Ne={provider:null,isAuthenticating:!1,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:!1};function cn(){const{t}=W(),[a,s]=c.useState(Ne),n=c.useRef(Ne),r=c.useRef(0),o=c.useRef(null),l=c.useRef(null),d=c.useRef(0),i=c.useRef(0),p=c.useRef(!1),m=wt(),v=c.useCallback(M=>M===r.current,[]),x=c.useCallback(()=>{l.current&&(clearInterval(l.current),l.current=null),i.current=0},[]);c.useEffect(()=>()=>{o.current?.abort(),x(),p.current=!1},[x]),c.useEffect(()=>{n.current=a},[a]);const b=c.useCallback(async(M,S,w)=>{if(v(w)){if(Date.now()-d.current>on){x(),v(w)&&s(y=>({...y,isAuthenticating:!1,error:t("toasts.providerAuthTimeout")}));return}try{const y=await fetch(`/api/cliproxy/auth/${M}/status?state=${encodeURIComponent(S)}`);if(!v(w))return;const h=await y.json();if(i.current=0,h.status==="ok"){if(!(typeof h.account=="object"&&h.account!==null)){x();const E=t("toasts.providerAccountRegistrationFailed");B.error(E),s(u=>({...u,isAuthenticating:!1,error:E}));return}x(),m.invalidateQueries({queryKey:["cliproxy-auth"]}),m.invalidateQueries({queryKey:["cliproxy-accounts"]}),m.invalidateQueries({queryKey:["account-quota"]}),pt(m),B.success(t("toasts.providerAuthSuccess",{provider:M})),p.current=!1,s(Ne)}else if(h.status==="auth_url"){const g=h.url||h.auth_url;g&&(s(E=>({...E,authUrl:g})),p.current||(p.current=!0,window.open(g,"_blank")))}else if(h.status==="device_code"){x();const g=h.user_code&&h.verification_url?`Open ${h.verification_url} and enter code: ${h.user_code}`:"Switch to Device Code method and try again.";B.error(t("toasts.providerDeviceCodeInCallback")),s(E=>({...E,isAuthenticating:!1,error:g}))}else if(h.status==="error"){x();const g=h.error||"Authentication failed";B.error(g),s(E=>({...E,isAuthenticating:!1,error:g}))}}catch(y){if(!v(w)||(i.current+=1,i.current<ln))return;x();const h=y instanceof Error&&y.message.trim().length>0?y.message:t("toasts.providerLostStatusEndpoint");B.error(h),s(g=>({...g,isAuthenticating:!1,error:h}))}}},[v,m,x,t]),N=c.useCallback(async(M,S)=>{if(!Re(M)){s({...Ne,error:t("toasts.providerUnknown",{provider:M})});return}o.current?.abort(),x(),p.current=!1,i.current=0;const w=new AbortController,y=r.current+1;r.current=y,o.current=w;const g=(S?.flowType||(us(M)?"device_code":"authorization_code"))==="device_code",E=S?.startEndpoint||(g?"start":"start-url"),u={accountId:S?.accountId,nickname:S?.nickname,kiroMethod:S?.kiroMethod,kiroIDCStartUrl:S?.kiroIDCStartUrl,kiroIDCRegion:S?.kiroIDCRegion,kiroIDCFlow:S?.kiroIDCFlow,gitlabAuthMode:S?.gitlabAuthMode,gitlabBaseUrl:S?.gitlabBaseUrl,gitlabPersonalAccessToken:S?.gitlabPersonalAccessToken,riskAcknowledgement:S?.riskAcknowledgement};s({provider:M,isAuthenticating:!0,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:g});try{if(E==="start")fetch(`/api/cliproxy/auth/${M}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u),signal:w.signal}).then(async I=>{if(!v(y))return;const A=await xt(I);if(!v(y))return;const q=A.success===!0,P=typeof A.account=="object"&&A.account!==null;if(I.ok&&q&&P)m.invalidateQueries({queryKey:["cliproxy-auth"]}),m.invalidateQueries({queryKey:["cliproxy-accounts"]}),m.invalidateQueries({queryKey:["account-quota"]}),pt(m),p.current=!1,s(Ne);else{const _=typeof A.error=="string"?A.error:t(q?"toasts.providerAccountRegistrationFailed":"auth.loginFailed");B.error(_),s(H=>({...H,isAuthenticating:!1,error:_}))}}).catch(I=>{if(!v(y)||I instanceof Error&&I.name==="AbortError")return;const A=I instanceof Error?I.message:"Authentication failed";B.error(A),s(q=>({...q,isAuthenticating:!1,error:A}))});else{const I=await fetch(`/api/cliproxy/auth/${M}/start-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u),signal:w.signal});if(!v(y))return;const A=await xt(I);if(!v(y))return;const q=A.success===!0;if(!I.ok||!q){const H=dn(A,t("toasts.providerStartOAuthFailed"));throw new Error(H)}const P=typeof A.authUrl=="string"?A.authUrl:null,_=typeof A.state=="string"?A.state:null;if(s(H=>({...H,authUrl:P,oauthState:_})),P&&(p.current=!0,window.open(P,"_blank")),_){if(d.current=Date.now(),!P){if(await b(M,_,y),!v(y))return;const H=n.current;if(!H.isAuthenticating||H.provider!==M)return}l.current=setInterval(()=>{b(M,_,y)},rn)}}}catch(I){if(!v(y))return;if(I instanceof Error&&I.name==="AbortError"){p.current=!1,s(Ne);return}const A=I instanceof Error?I.message:t("auth.loginFailed");B.error(A),s(q=>({...q,isAuthenticating:!1,error:A}))}},[v,b,x,m,t]),C=c.useCallback(()=>{const M=a.provider;r.current+=1,o.current?.abort(),x(),p.current=!1,s(Ne),M&&Xe.cliproxy.auth.cancel(M).catch(()=>{})},[a.provider,x]),T=c.useCallback(async M=>{if(!a.provider)return;const S=r.current,w=a.provider;s(y=>({...y,isSubmittingCallback:!0,error:null}));try{const y=await fetch(`/api/cliproxy/auth/${w}/submit-callback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({redirectUrl:M})});if(!v(S))return;const h=await xt(y);if(!v(S))return;const g=h.success===!0,E=h.status==="wait",u=typeof h.account=="object"&&h.account!==null;if(y.ok&&E)s(I=>({...I,isSubmittingCallback:!1,error:null}));else if(y.ok&&g&&u)x(),m.invalidateQueries({queryKey:["cliproxy-auth"]}),m.invalidateQueries({queryKey:["cliproxy-accounts"]}),m.invalidateQueries({queryKey:["account-quota"]}),pt(m),B.success(t("toasts.providerAuthSuccess",{provider:w})),s(Ne);else{const I=typeof h.error=="string"?h.error:t(g?"toasts.providerAccountRegistrationFailed":"toasts.providerCallbackFailed");throw new Error(I)}}catch(y){if(!v(S))return;const h=y instanceof Error?y.message:t("toasts.providerSubmitCallbackFailed");B.error(h),s(g=>({...g,isSubmittingCallback:!1,error:h}))}},[v,a.provider,m,x,t]);return c.useMemo(()=>({...a,startAuth:N,cancelAuth:C,submitCallback:T}),[a,N,C,T])}function yt({className:t,compact:a=!1,showAcknowledgement:s=!1,acknowledgementPhrase:n=Ye,acknowledgementText:r="",onAcknowledgementTextChange:o,disabled:l=!1,showProxySettingsLink:d=!1}){const{t:i}=W(),p=i("accountSafetyWarning.title"),m=i("accountSafetyWarning.subtitle"),v=i("accountSafetyWarning.firstLine"),x=i("accountSafetyWarning.secondLine"),b="https://github.com/kaitranntt/ccs/issues/509",N=i("accountSafetyWarning.issueLabel"),C=i("accountSafetyWarning.proxySettingsLabel");return a?e.jsx("section",{role:"alert",className:X("border-b border-amber-200/70 bg-amber-50/45 dark:bg-amber-950/5",t),children:e.jsxs("div",{className:"flex flex-col gap-3 px-6 py-3 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"min-w-0 flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 inline-flex h-6 w-6 items-center justify-center rounded-md bg-amber-500/12 text-amber-700 dark:text-amber-300",children:e.jsx(et,{className:"h-3.5 w-3.5"})}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"text-xs font-semibold leading-5",children:p}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:m})]}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:v}),e.jsx("p",{className:"text-xs font-medium leading-5 text-amber-900 dark:text-amber-200",children:x})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 lg:justify-end",children:[e.jsxs("a",{href:b,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 rounded-md border border-amber-500/25 bg-background/90 px-2 py-1 text-[11px] font-medium text-amber-800 transition-colors hover:bg-amber-500/10 dark:text-amber-200",children:[N,e.jsx(Me,{className:"h-3 w-3"})]}),d?e.jsxs("a",{href:"/settings?tab=proxy",className:"inline-flex items-center gap-1 rounded-md border border-amber-500/25 bg-background/90 px-2 py-1 text-[11px] font-medium text-amber-800 transition-colors hover:bg-amber-500/10 dark:text-amber-200",children:[e.jsx(Wt,{className:"h-3 w-3"}),C]}):null,e.jsx(z,{variant:"outline",className:"border-amber-500/40 text-[10px] text-amber-700 dark:text-amber-300",children:"High Risk"})]})]})}):e.jsxs("section",{role:"alert",className:X("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",t),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(et,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:p}),e.jsx("p",{className:"text-xs text-muted-foreground",children:m})]})]}),e.jsx(z,{variant:"outline",className:"border-amber-500/40 text-amber-700 dark:text-amber-300",children:"High Risk"})]}),e.jsxs("div",{className:"space-y-2 text-sm leading-relaxed",children:[e.jsx("p",{children:v}),e.jsx("p",{className:"font-medium text-amber-900 dark:text-amber-200",children:x}),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:b,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:[N,e.jsx(Me,{className:"h-3.5 w-3.5"})]}),d&&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(Wt,{className:"h-3.5 w-3.5"}),C]}),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"})]}),s&&o&&e.jsxs("div",{className:"rounded-lg border border-amber-500/25 bg-amber-500/5 p-2.5",children:[e.jsxs(ee,{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:n})]}),e.jsx(ce,{id:"account-risk-ack-text",value:r,onChange:T=>o(T.target.value),placeholder:n,disabled:l,className:"mt-2 font-mono text-xs"})]})]})]})}function un({className:t,value:a,onChange:s,disabled:n=!1}){const{t:r}=W(),o=[a.reviewedIssue509,a.understandsBanRisk,a.acceptsFullResponsibility,a.typedPhrase.trim().replace(/\s+/g," ").toUpperCase()===Qt].filter(Boolean).length,l=o/4*100,d=i=>{s({...a,...i})};return e.jsxs("section",{role:"alert",className:X("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",t),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(et,{className:"h-4 w-4"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:r("antigravityChecklist.title")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r("antigravityChecklist.subtitle")})]})]}),e.jsx(z,{variant:"outline",className:"border-rose-500/40 text-rose-700 dark:text-rose-300",children:r("antigravityChecklist.mandatory")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:r("antigravityChecklist.completion")}),e.jsx("span",{children:r("antigravityChecklist.stepsCount",{current:o})})]}),e.jsx(Fs,{value:l,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(Ze,{id:"agy-step-reviewed-issue",checked:a.reviewedIssue509,onCheckedChange:i=>d({reviewedIssue509:!!i}),disabled:n}),e.jsx(ee,{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(Ze,{id:"agy-step-understands-risk",checked:a.understandsBanRisk,onCheckedChange:i=>d({understandsBanRisk:!!i}),disabled:n}),e.jsx(ee,{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(Ze,{id:"agy-step-accept-responsibility",checked:a.acceptsFullResponsibility,onCheckedChange:i=>d({acceptsFullResponsibility:!!i}),disabled:n}),e.jsx(ee,{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(fs,{className:"h-3.5 w-3.5"}),"Step 4: Type exact phrase to continue"]}),e.jsx(ce,{value:a.typedPhrase,onChange:i=>d({typedPhrase:i.target.value}),placeholder:Qt,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 mn(t){return t.trim().replace(/\s+/g," ").toUpperCase()}function pn({open:t,onClose:a,provider:s,displayName:n,catalog:r,account:o,isFirstAccount:l=!1}){const[d,i]=c.useState(""),[p,m]=c.useState(""),[v,x]=c.useState(!1),[b,N]=c.useState(null),[C,T]=c.useState(""),[M,S]=c.useState(ut),[w,y]=c.useState(!1),[h,g]=c.useState(!1),[E,u]=c.useState(qt),[I,A]=c.useState(""),[q,P]=c.useState(""),[_,H]=c.useState(zt),[G,V]=c.useState("oauth"),[R,O]=c.useState(""),[k,Q]=c.useState(""),{t:j}=W(),Y=c.useRef(!1),se=c.useRef(0),le=c.useRef(!1),K=cn(),re=Us(),$=s==="kiro",Z=s==="gitlab",ie=s==="agy"||s==="gemini",be=s==="gemini"&&!w,fe=s==="agy"&&!w,ke=ie&&h,Ce=Ta(M),f=mn(C)===Ye,F=us(s),ge=Ks(E),me=$&&E==="idc",pe=$&&qs(E),Ae=$?Hs(E,_):void 0,it=$?Gs(E):void 0,ot=$?Ae==="device_code":F,de=K.isAuthenticating||re.isPending,Le=d.trim(),Fe=I.trim(),Ue=q.trim(),Ke=R.trim(),L=k.trim(),te=b||K.error,ae=!!o,De=o?.email||o?.nickname||o?.id||n,Ut=c.useCallback(async()=>{const D=await fetch("/api/settings/auth/antigravity-risk");if(!D.ok)throw new Error("Failed to load power user mode setting");return(await D.json()).antigravityAckBypass===!0},[]),He=c.useCallback(async({pendingMessage:D=null,disabledMessage:ve=null}={})=>{const dt=++se.current;g(!0),D!==null&&N(D);try{const qe=await Ut();return se.current!==dt||(y(qe),ve?N(qe?null:ve):D!==null&&N(null)),qe}catch{return se.current!==dt||(y(!1),N(ve??j("addAccountDialog.powerUserLoadFailed")),le.current||(le.current=!0,B.error(j("addAccountDialog.powerUserLoadFailed")))),!1}finally{se.current===dt&&g(!1)}},[Ut,j]),lt=()=>{i(""),m(""),x(!1),N(null),T(""),S(ut),y(!1),g(!1),u(qt),A(""),P(""),H(zt),V("oauth"),O(""),Q(""),se.current+=1,le.current=!1,Y.current=!1,a()};c.useEffect(()=>{t&&(T(""),S(ut),N(null))},[s,t]),c.useEffect(()=>()=>{se.current+=1},[]),c.useEffect(()=>{if(!t||!ie){se.current+=1,y(!1),g(!1);return}He()},[t,s,ie,He]),c.useEffect(()=>{if(!t||s!=="agy"||!K.error||!w)return;const D=K.error.toLowerCase();(D.includes("agy_risk_ack_required")||D.includes("responsibility acknowledgement")||D.includes("responsibility checklist"))&&He({pendingMessage:j("addAccountDialog.powerUserLoading"),disabledMessage:j("addAccountDialog.powerUserUnavailableRetry")})},[K.error,t,w,s,He,j]),c.useEffect(()=>{!K.isAuthenticating&&!K.error&&K.provider===null&&t&&Y.current&&(Y.current=!1,(async()=>{try{const ve=await Nt(s,void 0,r);ve.success&&ve.presetName&&l&&B.success(`Applied "${ve.presetName}" preset`)}catch{}lt()})())},[K.isAuthenticating,K.error,K.provider]);const Kt=()=>{K.cancelAuth(),lt()},As=async()=>{K.authUrl&&(await navigator.clipboard.writeText(K.authUrl),x(!0),setTimeout(()=>x(!1),2e3))},Ss=()=>{p.trim()&&K.submitCallback(p.trim())},Ms=()=>{if(ke){N(j("addAccountDialog.powerUserLoading"));return}if(fe&&!Ce){N("Complete all Antigravity responsibility steps before authenticating this provider.");return}if(be&&!f){N(`Type "${Ye}" to acknowledge the account safety warning before authenticating this provider.`);return}if(N(null),me&&!Fe){N("IDC Start URL is required for Kiro IAM Identity Center login.");return}if(Z&&G==="pat"&&!L){N(j("addAccountDialog.gitlabPatRequired"));return}Y.current=!0,K.startAuth(s,{accountId:o?.id,nickname:o?o.nickname:Le||void 0,kiroMethod:$?E:void 0,kiroIDCStartUrl:me?Fe:void 0,kiroIDCRegion:me&&Ue?Ue:void 0,kiroIDCFlow:me?_:void 0,gitlabAuthMode:Z?G:void 0,gitlabBaseUrl:Z&&Ke?Ke:void 0,gitlabPersonalAccessToken:Z&&G==="pat"&&L?L:void 0,flowType:$?Ae:void 0,startEndpoint:$?it:Z&&G==="pat"?"start":void 0,riskAcknowledgement:fe?{version:Ea,reviewedIssue509:M.reviewedIssue509,understandsBanRisk:M.understandsBanRisk,acceptsFullResponsibility:M.acceptsFullResponsibility,typedPhrase:M.typedPhrase}:void 0})},Ps=()=>{Y.current=!0,re.mutate(void 0,{onSuccess:async()=>{const D=await Nt("kiro",void 0,r);D.success&&D.presetName&&l&&B.success(`Applied "${D.presetName}" preset`),lt()}})},Ds=D=>{D||Kt()},oe=K.isAuthenticating;return e.jsx(Ct,{open:t,onOpenChange:Ds,children:e.jsxs(At,{className:"grid max-h-[calc(100dvh-2rem)] w-[calc(100vw-2rem)] max-w-md grid-rows-[auto_minmax(0,1fr)] overflow-hidden p-0 sm:max-w-md",onInteractOutside:D=>{oe&&D.preventDefault()},children:[e.jsxs(St,{className:"min-w-0 px-6 pt-6 pr-12",children:[e.jsx(Mt,{children:ae?`Reauthenticate ${n}`:j("addAccountDialog.title",{displayName:n})}),e.jsx(cs,{children:ae?`Refresh credentials for ${De}.`:j($?"addAccountDialog.descKiro":ot?"addAccountDialog.descDeviceCode":"addAccountDialog.descOauth")})]}),e.jsxs("div",{className:"min-h-0 space-y-4 overflow-y-auto px-6 py-4",children:[fe&&!oe&&e.jsx(un,{value:M,onChange:D=>{S(D),N(null)},disabled:de}),ie&&w&&!oe&&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(fs,{className:"h-3.5 w-3.5"}),j("addAccountDialog.powerUserEnabled")]}),j("addAccountDialog.powerUserSkipped")]}),be&&!oe&&e.jsx(yt,{showAcknowledgement:!0,acknowledgementPhrase:Ye,acknowledgementText:C,onAcknowledgementTextChange:D=>{T(D),N(null)},disabled:de}),$&&!oe&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ee,{htmlFor:"kiro-auth-method",children:j("addAccountDialog.authMethod")}),e.jsxs($e,{value:E,onValueChange:D=>{u(D),N(null)},children:[e.jsx(We,{id:"kiro-auth-method",children:e.jsx(Qe,{placeholder:j("addAccountDialog.selectKiroAuthMethod")})}),e.jsx(Je,{children:zs.map(D=>e.jsx(Se,{value:D.id,children:D.label},D.id))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:ge.description}),pe&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["If your browser does not return automatically after login, CCS can accept the final",e.jsx("span",{className:"mx-1 rounded bg-muted px-1.5 py-0.5 font-mono text-[11px]",children:"kiro://..."}),"callback URL in the next step."]})]}),me&&!oe&&e.jsxs("div",{className:"space-y-4 rounded-lg border border-border/60 bg-muted/20 p-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ee,{htmlFor:"kiro-idc-start-url",children:"IDC Start URL"}),e.jsx(ce,{id:"kiro-idc-start-url",value:I,onChange:D=>{A(D.target.value),N(null)},placeholder:"https://d-xxx.awsapps.com/start",disabled:de}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Required for organization IAM Identity Center login."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ee,{htmlFor:"kiro-idc-region",children:"IDC Region"}),e.jsx(ce,{id:"kiro-idc-region",value:q,onChange:D=>{P(D.target.value),N(null)},placeholder:"us-east-1",disabled:de}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Leave blank to use the upstream default region."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ee,{htmlFor:"kiro-idc-flow",children:"IDC Flow"}),e.jsxs($e,{value:_,onValueChange:D=>{H(D),N(null)},children:[e.jsx(We,{id:"kiro-idc-flow",children:e.jsx(Qe,{placeholder:"{/* TODO i18n: missing key */}Select IDC flow"})}),e.jsxs(Je,{children:[e.jsx(Se,{value:"authcode",children:"Authorization Code"}),e.jsx(Se,{value:"device",children:"Device Code"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Auth Code opens a browser and may need the final callback URL pasted back. Device Code shows a verification code instead."})]})]}),Z&&!oe&&e.jsxs("div",{className:"space-y-4 rounded-lg border border-border/60 bg-muted/20 p-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ee,{htmlFor:"gitlab-auth-mode",children:j("addAccountDialog.gitlabAuthMethod")}),e.jsxs($e,{value:G,onValueChange:D=>{V(D),N(null)},children:[e.jsx(We,{id:"gitlab-auth-mode",children:e.jsx(Qe,{placeholder:j("addAccountDialog.selectGitlabAuthMethod")})}),e.jsxs(Je,{children:[e.jsx(Se,{value:"oauth",children:j("addAccountDialog.gitlabAuthOAuth")}),e.jsx(Se,{value:"pat",children:j("addAccountDialog.gitlabAuthPat")})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:j("addAccountDialog.gitlabAuthHint")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ee,{htmlFor:"gitlab-base-url",children:j("addAccountDialog.gitlabUrl")}),e.jsx(ce,{id:"gitlab-base-url",value:R,onChange:D=>{O(D.target.value),N(null)},placeholder:j("addAccountDialog.gitlabUrlPlaceholder"),disabled:de}),e.jsx("p",{className:"text-xs text-muted-foreground",children:j("addAccountDialog.gitlabUrlHint")})]}),G==="pat"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ee,{htmlFor:"gitlab-pat",children:j("addAccountDialog.gitlabPat")}),e.jsx(ce,{id:"gitlab-pat",type:"password",value:k,onChange:D=>{Q(D.target.value),N(null)},placeholder:j("addAccountDialog.gitlabPatPlaceholder"),disabled:de}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[j("addAccountDialog.gitlabPatHint")," ",e.jsx("span",{className:"font-mono",children:"api"})," and"," ",e.jsx("span",{className:"font-mono",children:"read_user"})," scopes."]})]})]}),!oe&&ae&&e.jsxs("div",{className:"rounded-md border bg-muted/30 px-3 py-2 text-sm",children:[e.jsx("div",{className:"font-medium",children:De}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"This sign-in updates the selected account instead of creating another account."})]}),!oe&&!ae&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ee,{htmlFor:"nickname",children:j("addAccountDialog.nicknameOptional")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Oe,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(ce,{id:"nickname",value:d,onChange:D=>{i(D.target.value),N(null)},placeholder:j("addAccountDialog.nicknamePlaceholder"),disabled:de,className:"flex-1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:j("addAccountDialog.nicknameOptionalHint")})]}),oe&&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(ue,{className:"w-4 h-4 inline mr-2 animate-spin"}),j("addAccountDialog.waitingForAuth")]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:K.isDeviceCodeFlow?j("addAccountDialog.deviceCodeHint"):pe?"Complete sign-in in your browser. If it does not return automatically, paste the final kiro:// callback URL below.":j("addAccountDialog.browserHint")})]}),K.authUrl&&!K.isDeviceCodeFlow&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ee,{className:"text-xs",children:j("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:K.authUrl}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(U,{variant:"outline",size:"sm",onClick:As,children:v?e.jsxs(e.Fragment,{children:[e.jsx(Pe,{className:"w-3 h-3 mr-1"}),j("addAccountDialog.copied")]}):e.jsxs(e.Fragment,{children:[e.jsx(hs,{className:"w-3 h-3 mr-1"}),j("addAccountDialog.copy")]})}),e.jsxs(U,{variant:"outline",size:"sm",onClick:()=>{if(!K.authUrl)return;const D=window.open(K.authUrl,"_blank");(!D||D.closed||typeof D.closed>"u")&&B.warning(j("addAccountDialog.popupBlocked"),{duration:5e3})},children:[e.jsx(Me,{className:"w-3 h-3 mr-1"}),j("addAccountDialog.open")]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ee,{htmlFor:"callback-url",className:"text-xs",children:pe?"Browser did not return? Paste the final kiro:// callback URL:":j("addAccountDialog.redirectPasteLabel")}),e.jsx(ce,{id:"callback-url",value:p,onChange:D=>m(D.target.value),placeholder:pe?"kiro://kiro.kiroAgent/authenticate-success?code=...&state=...":j("addAccountDialog.callbackPlaceholder"),className:"font-mono text-xs"}),e.jsx(U,{variant:"secondary",size:"sm",onClick:Ss,disabled:!p.trim()||K.isSubmittingCallback,children:K.isSubmittingCallback?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-3 h-3 mr-1 animate-spin"}),j("addAccountDialog.submitting")]}):j("addAccountDialog.submitCallback")})]})]}),!K.authUrl&&!K.isDeviceCodeFlow&&e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:pe?"Preparing the Kiro sign-in URL. If it does not open automatically, it will appear here shortly.":j("addAccountDialog.preparingUrl")})]}),te&&e.jsx("p",{className:"text-xs text-center text-destructive whitespace-pre-line",children:te}),re.isPending&&e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:[e.jsx(ue,{className:"w-4 h-4 inline mr-2 animate-spin"}),j("addAccountDialog.importingToken")]}),e.jsxs("div",{className:"flex flex-col-reverse gap-2 pt-2 sm:flex-row sm:items-center sm:justify-end",children:[e.jsx(U,{variant:"ghost",onClick:Kt,className:"w-full sm:w-auto",children:j("addAccountDialog.cancel")}),$&&!oe&&e.jsx(U,{variant:"outline",onClick:Ps,disabled:de,className:"w-full sm:w-auto",children:re.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-4 h-4 mr-2 animate-spin"}),j("addAccountDialog.importing")]}):e.jsxs(e.Fragment,{children:[e.jsx(Ca,{className:"w-4 h-4 mr-2"}),j("addAccountDialog.importFromIde")]})}),!oe&&e.jsxs(U,{onClick:Ms,className:"w-full sm:w-auto",disabled:de||ke||fe&&!Ce||be&&!f,children:[e.jsx(Me,{className:"w-4 h-4 mr-2"}),ae?"Reauthenticate":j("addAccountDialog.authenticate")]})]})]})]})})}const xn=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function hn(t){const a=t?.env||{};return xn.filter(s=>!a[s]?.trim())}function fn(t,a){const[s,n]=c.useState(null),[r,o]=c.useState(!1),l=wt(),{data:d,isLoading:i,refetch:p}=ss({queryKey:["settings",t],queryFn:async()=>{const P=await fetch(`/api/settings/${t}/raw`);if(!P.ok){const _=t==="cursor"?`~/.ccs/cliproxy/providers/${t}.settings.json`:Re(t)?`~/.ccs/${t}.settings.json`:`~/.ccs/profiles/${t}/settings.json`;return{profile:t,settings:{env:{}},mtime:Date.now(),path:_}}return P.json()}}),m=d?.settings,v=c.useMemo(()=>s!==null?s:m?JSON.stringify(m,null,2):`{
3
- "env": {}
4
- }`,[s,m]),x=c.useCallback(P=>{n(P)},[]),b=c.useMemo(()=>{try{return JSON.parse(v)}catch{return m||{env:{}}}},[v,m]),N=b?.env?.ANTHROPIC_MODEL,C=b?.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,T=b?.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,M=b?.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,S=c.useMemo(()=>Bs(b?.env||{}),[b]),w=c.useCallback((P,_)=>Vs(P,_,{supportsExtendedContext:H=>Qa(t,H,a)}),[a,t]),y=c.useCallback((P,_)=>{const H={...b?.env||{},[P]:_},G=Gt(P)?w(H,S):H;delete G.CCS_EXTENDED_CONTEXT;const V={...b,env:G};n(JSON.stringify(V,null,2))},[w,b,S]),h=c.useCallback(P=>{const _=b?.env||{},H=w(_,P);delete H.CCS_EXTENDED_CONTEXT;const G={...b,env:H};n(JSON.stringify(G,null,2))},[w,b]),g=c.useCallback(P=>{const _={...b?.env||{},...P},G=Object.keys(P).some(Gt)?w(_,S):_;delete G.CCS_EXTENDED_CONTEXT;const V={...b,env:G};n(JSON.stringify(V,null,2))},[w,b,S]),E=c.useMemo(()=>{try{return JSON.parse(v),!0}catch{return!1}},[v]),u=c.useMemo(()=>s===null?!1:s!==JSON.stringify(m,null,2),[s,m]),I=c.useMemo(()=>hn(b),[b]),A=Is({mutationFn:async()=>{const P=JSON.parse(v),_=await fetch(`/api/settings/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:P,expectedMtime:d?.mtime})});if(_.status===409)throw new Error("CONFLICT");if(!_.ok)throw new Error("Failed to save");return _.json()},onSuccess:P=>{l.invalidateQueries({queryKey:["settings",t]}),n(null),P?.warning?B.success(he.t("settings.saved"),{description:P.warning}):B.success(he.t("settings.saved"))},onError:P=>{P.message==="CONFLICT"?o(!0):B.error(P.message)}}),q=async P=>{o(!1),P?(await p(),A.mutate()):n(null)};return{data:d,isLoading:i,refetch:p,rawJsonContent:v,rawJsonEdits:s,isRawJsonValid:E,hasChanges:u,currentSettings:b,currentModel:N,opusModel:C,sonnetModel:T,haikuModel:M,extendedContextEnabled:S,toggleExtendedContext:h,handleRawJsonChange:x,updateEnvValue:y,updateEnvValues:g,saveMutation:{mutate:()=>A.mutate(),isPending:A.isPending},conflictDialog:r,setConflictDialog:o,handleConflictResolve:q,missingRequiredFields:I}}const gn=/-(minimal|low|medium|high|xhigh|fast)$/i,vn=["minimal","low","medium","high","xhigh"];function jn(t){return t?.trim()??""}function rt(t){let a=jn(t),s,n;for(let r=0;r<2;r+=1){const o=a.match(gn);if(!o?.[1])break;const l=o[1].toLowerCase();if(l==="fast"){if(n)break;n="fast"}else{if(s)break;s=l}a=a.slice(0,-o[0].length)}return{baseModel:a,effort:s,serviceTier:n}}function Ft(t){return rt(t).effort}function Cs(t){return rt(t).serviceTier}function bn(t){return rt(t).baseModel}function Yt(t,a){const s=rt(t),n=s.baseModel;return!n||!a?s.serviceTier?`${n}-${s.serviceTier}`:n:[n,a,s.serviceTier].filter(Boolean).join("-")}function Nn(t,a,s=[]){if(!a){const l=Ft(t);return[Yt(t,l)]}const n=bn(t),r=[],o=l=>{const d=l?Yt(n,l):n;r.push(d);for(const i of s)r.push(`${d}-${i}`)};o(void 0);for(const l of vn)if(o(l),l===a)break;return r}function yn(t,a){if(!t)return null;const s=Ft(t);return s?{label:`Pinned ${s}`,explicit:!0}:{label:"Auto effort",explicit:!1}}function wn({label:t}){return e.jsx(z,{variant:"outline",className:"text-[9px] h-4 px-1",children:t})}function Ge({modelId:t}){const a=yn(t);return a?e.jsx(z,{variant:a.explicit?"secondary":"outline",className:"text-[9px] h-4 px-1 uppercase",children:a.label}):null}function Be({modelId:t}){const a=Cs(t);return a?e.jsx(z,{variant:"secondary",className:"text-[9px] h-4 px-1 uppercase",children:a}):null}function Zt(t,a){if(!t)return"";if(!a?.prefix)return t;const s=`${a.prefix}/`;return t.startsWith(s)?t.slice(s.length):t}function Ve(t,a){return a?.recommendedModelId??t}function ht(t,a,s,n){return n?Nn(s,t,a):[s]}function kn(t,a){return a?Cs(t)?"codex-fast":Ft(t)?"codex-reasoning":"recommended":"recommended"}function we({label:t,description:a,value:s,onChange:n,catalog:r,allModels:o,routing:l,disabled:d}){const{t:i}=W(),p=r?.provider==="codex",m=c.useMemo(()=>Lt(r,o),[o,r]),v=c.useMemo(()=>Wa(r?.provider??"",r,o),[o,r]),x=new Set(m.map(h=>h.id)),b=c.useMemo(()=>new Map((l?.models??[]).map(h=>[h.modelId.toLowerCase(),h])),[l]),N=c.useMemo(()=>new Set(m.flatMap(h=>ht(h.codexMaxEffort,h.codexServiceTiers,Ve(h.id,b.get(h.id.toLowerCase())),p))),[p,m,b]),C=c.useMemo(()=>b.get(Zt(s,l).toLowerCase()),[l,b,s]),T=m.flatMap(h=>{const g=b.get(h.id.toLowerCase());return ht(h.codexMaxEffort,h.codexServiceTiers,Ve(h.id,g),p).map(u=>({value:u,groupKey:kn(u,p),searchText:`${u} ${h.id} ${h.name} ${g?.recommendedModelId??""}`,keywords:[h.tier??"",r?.provider??""],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:u}),g?.pinnedAvailable?e.jsx(z,{variant:"secondary",className:"text-[9px] h-4 px-1 uppercase",children:g.prefix}):null,p&&e.jsx(Ge,{modelId:u}),p&&e.jsx(Be,{modelId:u})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:u}),h.tier==="paid"&&e.jsx(wn,{label:i("providerModelSelector.paid")}),g?.unprefixedStatus==="shadowed"?e.jsx(z,{variant:"outline",className:"text-[9px] h-4 px-1",children:i("providerModelSelector.shadowed")}):null,g?.unprefixedStatus==="prefix-only"?e.jsx(z,{variant:"outline",className:"text-[9px] h-4 px-1",children:i("providerModelSelector.prefixOnly")}):null,p&&e.jsx(Ge,{modelId:u}),p&&e.jsx(Be,{modelId:u})]})}))}),M=v.filter(h=>!x.has(h.id)).filter(h=>!N.has(Ve(h.id,b.get(h.id.toLowerCase())))).flatMap(h=>{const g=b.get(h.id.toLowerCase());return ht(void 0,void 0,Ve(h.id,g),p).map(u=>({value:u,groupKey:"all",searchText:`${u} ${h.id} ${g?.recommendedModelId??""}`,keywords:[h.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:u}),g?.pinnedAvailable?e.jsx(z,{variant:"secondary",className:"text-[9px] h-4 px-1 uppercase",children:g.prefix}):null,p&&e.jsx(Ge,{modelId:u}),p&&e.jsx(Be,{modelId:u})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:u}),g?.unprefixedStatus==="shadowed"?e.jsx(z,{variant:"outline",className:"text-[9px] h-4 px-1",children:i("providerModelSelector.shadowed")}):null,g?.unprefixedStatus==="prefix-only"?e.jsx(z,{variant:"outline",className:"text-[9px] h-4 px-1",children:i("providerModelSelector.prefixOnly")}):null,p&&e.jsx(Ge,{modelId:u}),p&&e.jsx(Be,{modelId:u})]})}))}),S=!!s&&!T.some(h=>h.value===s)&&!M.some(h=>h.value===s),w=s?{value:s,groupKey:"current",searchText:s,triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:s}),e.jsx(z,{variant:"outline",className:"text-[9px] h-4 px-1",children:i("providerModelSelector.current")})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:s}),e.jsx(z,{variant:"outline",className:"text-[9px] h-4 px-1",children:i("providerModelSelector.current")})]})}:null,y=T.length+M.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:t}),a&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a})]}),e.jsx(Oa,{value:s||void 0,onChange:n,disabled:d,placeholder:i("providerModelSelector.selectModel"),searchPlaceholder:i("searchableSelect.searchModels"),emptyText:i(y?"searchableSelect.noResults":"providerModelSelector.noModelsAvailable"),triggerClassName:"h-9",groups:[...S&&w?[{key:"current",label:e.jsx("span",{className:"text-xs text-muted-foreground",children:i("providerModelSelector.currentValue")})}]:[],{key:"recommended",label:e.jsx("span",{className:"text-xs text-primary",children:i("providerModelSelector.recommended")})},...p?[{key:"codex-reasoning",label:e.jsx("span",{className:"text-xs text-muted-foreground",children:i("providerModelSelector.codexReasoningVariants")})},{key:"codex-fast",label:e.jsx("span",{className:"text-xs text-amber-600",children:i("providerModelSelector.codexFastVariants")})}]:[],...M.length>0?[{key:"all",label:e.jsx("span",{className:"text-xs text-muted-foreground",children:i("providerModelSelector.allModelsCount",{count:M.length})})}]:[]],options:[...S&&w?[w]:[],...T,...M]}),C?e.jsxs("div",{className:X("rounded-md border px-2.5 py-2 text-[11px]",C.unprefixedStatus==="safe"?"border-border/70 bg-muted/25 text-muted-foreground":"border-amber-300/60 bg-amber-50 text-amber-900 dark:border-amber-500/30 dark:bg-amber-950/25 dark:text-amber-100"),children:[e.jsxs("div",{className:"font-medium",children:[C.pinnedAvailable?i("providerModelSelector.preferredPinnedModel"):i("providerModelSelector.pinnedRouteStatus")," ",e.jsx("code",{children:C.pinnedAvailable?C.recommendedModelId:C.pinnedModelId})]}),e.jsx("p",{className:"mt-1 leading-5",children:C.summary})]}):null,s&&!C&&Zt(s,l)!==s?e.jsx("div",{className:"rounded-md border border-amber-300/60 bg-amber-50 px-2.5 py-2 text-[11px] text-amber-900 dark:border-amber-500/30 dark:bg-amber-950/25 dark:text-amber-100",children:i("providerModelSelector.pinnedModelNotAdvertised",{model:s})}):null]})}function es(t,a){const s=n=>a?.models.find(o=>o.modelId.toLowerCase()===n.toLowerCase())?.recommendedModelId??n;return{default:s(t.default),opus:s(t.opus),sonnet:s(t.sonnet),haiku:s(t.haiku)}}function Cn({open:t,onClose:a,currentValues:s,onApply:n,onSave:r,isSaving:o,catalog:l,allModels:d,routing:i}){const{t:p}=W(),[m,v]=c.useState(es(s,i)),[x,b]=c.useState(""),N=C=>{C?(v(es(s,i)),b("")):a()};return e.jsx(Ct,{open:t,onOpenChange:N,children:e.jsxs(At,{className:"sm:max-w-md",children:[e.jsx(St,{children:e.jsxs(Mt,{className:"flex items-center gap-2",children:[e.jsx(Tt,{className:"w-4 h-4"}),p("customPresetDialog.title")]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ee,{htmlFor:"preset-name",children:p("customPresetDialog.presetNameOptional")}),e.jsx(ce,{id:"preset-name",value:x,onChange:C=>b(C.target.value),placeholder:p("customPresetDialog.presetNamePlaceholder"),className:"text-sm"})]}),e.jsx(Ot,{}),l?.provider==="codex"&&e.jsxs("p",{className:"text-[11px] text-muted-foreground rounded-md border bg-muted/30 px-2.5 py-2",children:[p("customPresetDialog.codexTipPrefix")," ",e.jsx("code",{children:"-medium"}),", ",e.jsx("code",{children:"-high"}),", and"," ",e.jsx("code",{children:"-xhigh"})," ",p("customPresetDialog.codexTipSuffix")]}),e.jsx(we,{label:p("customPresetDialog.defaultModel"),description:p("customPresetDialog.defaultModelDesc"),value:m.default,onChange:C=>v({...m,default:C}),catalog:l,allModels:d,routing:i}),e.jsx(we,{label:p("customPresetDialog.opusModel"),description:p("customPresetDialog.opusModelDesc"),value:m.opus,onChange:C=>v({...m,opus:C}),catalog:l,allModels:d,routing:i}),e.jsx(we,{label:p("customPresetDialog.sonnetModel"),description:p("customPresetDialog.sonnetModelDesc"),value:m.sonnet,onChange:C=>v({...m,sonnet:C}),catalog:l,allModels:d,routing:i}),e.jsx(we,{label:p("customPresetDialog.haikuModel"),description:p("customPresetDialog.haikuModelDesc"),value:m.haiku,onChange:C=>v({...m,haiku:C}),catalog:l,allModels:d,routing:i})]}),e.jsxs($s,{className:"gap-2 sm:gap-0",children:[e.jsx(U,{variant:"outline",onClick:a,children:p("customPresetDialog.cancel")}),r&&e.jsxs(U,{variant:"secondary",onClick:()=>r(m,x||void 0),disabled:o||!x.trim(),children:[o?e.jsx(ue,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(Et,{className:"w-4 h-4 mr-1"}),p("customPresetDialog.savePreset")]}),e.jsxs(U,{onClick:()=>n(m,x||void 0),children:[e.jsx(_e,{className:"w-4 h-4 mr-1"}),p("customPresetDialog.applyPreset")]})]})]})})}function ye({label:t,command:a}){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:a}),e.jsx(ms,{value:a,size:"icon",className:"h-6 w-6"})]})]})}function An({provider:t,displayName:a,baseProvider:s,defaultTarget:n,data:r,authStatus:o,supportsModelConfig:l=!1}){const{t:d}=W(),i=n||"claude",p=i==="droid",m=t==="codex",v=s||o.provider||t,x=Ws(v),b=i==="claude"?`ccs ${t}`:`ccs ${t} --target claude`,N=`${b} --config`,C=`${b} --auth --add`,T=`${b} --accounts`;return e.jsx(Pt,{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(gs,{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:d("providerEditor.provider")}),e.jsx("span",{className:"font-mono",children:a})]}),r&&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:d("providerEditor.filePath")}),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:r.path}),e.jsx(ms,{value:r.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:d("providerEditor.lastModified")}),e.jsx("span",{className:"text-xs",children:new Date(r.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:d("providerEditor.status")}),o.authenticated?e.jsxs(z,{variant:"outline",className:"w-fit text-green-600 border-green-200 bg-green-50",children:[e.jsx(Aa,{className:"w-3 h-3 mr-1"}),"Authenticated"]}):e.jsx(z,{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:d("providerEditor.defaultTarget")}),e.jsx("span",{className:"font-mono",children:i})]}),x&&e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-start",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:d("providerConfig.trackLabel")}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"font-mono",children:d(x.labelKey)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[d(x.hintKey),Qs(v)?` ${d("providerConfig.plusTrackNote")}`:""]})]})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:d("providerEditor.quickUsage")}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsx(ye,{label:"Run with prompt",command:`ccs ${t} "your prompt"`}),m&&e.jsxs(e.Fragment,{children:[e.jsx(ye,{label:"Run on native Codex (shortcut)",command:'ccsxp "your prompt"'}),e.jsx(ye,{label:"Run on native Codex (--target)",command:`ccs ${t} --target codex "your prompt"`})]}),e.jsx(ye,{label:p?"Droid alias (explicit)":"Run on Droid",command:`ccs-droid ${t} "your prompt"`}),e.jsx(ye,{label:p?"Override to Claude":"Run on Droid (--target)",command:`ccs ${t} --target ${p?"claude":"droid"} "your prompt"`}),l&&e.jsx(ye,{label:i==="claude"?"Change model":"Change model (Claude target)",command:N}),e.jsx(ye,{label:i==="claude"?"Add account":"Add account (Claude target)",command:C}),e.jsx(ye,{label:i==="claude"?"List accounts":"List accounts (Claude target)",command:T}),i!=="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 Sn(t){const a=t.replace(/\\/g,"/"),n=a.lastIndexOf("/cliproxy/providers/");return n!==-1?a.slice(n+1):a.replace(/^.*\//,"")}function Mn({displayName:t,logoProvider:a,provider:s,data:n,isLoading:r,hasChanges:o,isRawJsonValid:l,isSaving:d,isRemoteMode:i,port:p,onRefetch:m,onSave:v}){const{t:x}=W();return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Dt,{provider:a||s,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:t}),i&&e.jsxs(z,{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(vs,{className:"w-3 h-3"}),"Remote"]}),p&&e.jsxs(z,{variant:"outline",className:"text-xs gap-1 font-mono",children:[e.jsx(Sa,{className:"w-3 h-3"}),":",p]}),!i&&n?.path&&e.jsx(z,{variant:"outline",className:"text-xs",children:Sn(n.path)})]}),i?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:[x("providerEditor.lastModified"),": ",new Date(n.mtime).toLocaleString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(U,{variant:"ghost",size:"sm",onClick:m,disabled:r,children:e.jsx(at,{className:`w-4 h-4 ${r?"animate-spin":""}`})}),e.jsx(U,{size:"sm",onClick:v,disabled:d||!o||!l,children:d?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ma,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function Pn({models:t,provider:a,enabled:s,onToggle:n,disabled:r,className:o}){const{t:l}=W();if(t.length===0)return null;const d=t.some(m=>Bt(m.id)),i=t.some(m=>!Bt(m.id));let p="Compatible mappings stay on standard context unless you turn this on.";return d&&i?p="Gemini-compatible mappings can use 1M automatically. Claude mappings stay plain unless you turn this on.":d&&(p="Gemini-compatible mappings can use 1M by default. Turn this off to keep standard context."),e.jsxs("div",{className:X("rounded-lg border p-3 space-y-2",s?"border-primary/50 bg-primary/5":"border-border bg-muted/30",o),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_e,{className:X("w-4 h-4",s?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:"text-sm font-medium",children:l("extendedContext.extendedContext")}),e.jsx(z,{variant:s?"default":"secondary",className:"text-[10px] h-5 px-1.5",children:"1M tokens"})]}),e.jsx(ps,{checked:s,onCheckedChange:n,disabled:r})]}),e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground",children:[e.jsx(gs,{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:p}),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 Dn(t,a){const s=t.presetMapping||{default:t.id,opus:t.id,sonnet:t.id,haiku:t.id};return{ANTHROPIC_MODEL:a(s.default),ANTHROPIC_DEFAULT_OPUS_MODEL:a(s.opus),ANTHROPIC_DEFAULT_SONNET_MODEL:a(s.sonnet),ANTHROPIC_DEFAULT_HAIKU_MODEL:a(s.haiku)}}function In({catalog:t,savedPresets:a,currentModel:s,opusModel:n,sonnetModel:r,haikuModel:o,providerModels:l,routing:d,provider:i,extendedContextEnabled:p,onExtendedContextToggle:m,onApplyPreset:v,onUpdateEnvValue:x,onOpenCustomPreset:b,onDeletePreset:N,isDeletePending:C}){const{t:T}=W(),M=(d?.models??[]).some(u=>u.pinnedAvailable),S=c.useMemo(()=>new Map((d?.models??[]).map(u=>[u.modelId.toLowerCase(),u])),[d]),w=u=>S.get(u.toLowerCase())?.recommendedModelId??u,y=c.useMemo(()=>{if(!t)return[];const u=[s,n,r,o].filter(A=>!!A).map(A=>Js(A));return[...new Set(u)].map(A=>ks(t.provider,A,t)).filter(A=>!!A?.extendedContext)},[t,s,n,r,o]),h=c.useMemo(()=>Lt(t,l),[t,l]),g=c.useMemo(()=>{const u=h.filter(A=>A.presetMapping);return u.length===0?[]:u.some(A=>A.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:u.filter(A=>A.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:u.filter(A=>A.tier==="paid")}].filter(A=>A.models.length>0):[{key:"default",models:u.slice(0,4)}]},[h]),E=g.length>0||a.length>0;return e.jsxs(e.Fragment,{children:[E&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(Tt,{className:"w-4 h-4"}),"Presets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:T("providerEditor.presets")}),e.jsxs("div",{className:"space-y-4",children:[g.map(u=>e.jsxs("div",{children:["label"in u&&u.label&&e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(z,{variant:"outline",className:u.badgeClassName,children:u.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:u.description})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:u.models.map(I=>e.jsxs(U,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>v(Dn(I,w)),children:[e.jsx(_e,{className:`w-3 h-3 ${"iconClassName"in u?u.iconClassName:""}`}),I.name]},I.id))})]},u.key)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.map(u=>e.jsxs("div",{className:"group relative",children:[e.jsxs(U,{variant:"secondary",size:"sm",className:"text-xs h-7 gap-1 pr-6",onClick:()=>{v({ANTHROPIC_MODEL:w(u.default),ANTHROPIC_DEFAULT_OPUS_MODEL:w(u.opus),ANTHROPIC_DEFAULT_SONNET_MODEL:w(u.sonnet),ANTHROPIC_DEFAULT_HAIKU_MODEL:w(u.haiku)})},children:[e.jsx(Et,{className:"w-3 h-3 fill-current"}),u.name]}),e.jsx(U,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-7 w-5 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:I=>{I.stopPropagation(),N(u.name)},disabled:C,children:e.jsx(Rt,{className:"w-3 h-3"})})]},u.name)),e.jsxs(U,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1 border-primary/50 text-primary hover:bg-primary/10 hover:border-primary",onClick:b,children:[e.jsx(nt,{className:"w-3 h-3"}),"Custom"]})]})]})]}),e.jsx(Ot,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:T("providerEditor.modelMapping")}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),d?e.jsx("p",{className:"text-[11px] text-muted-foreground mb-3 rounded-md border bg-muted/30 px-2.5 py-2",children:M?e.jsxs(e.Fragment,{children:["Preferred pinned model names use the ",e.jsxs("code",{children:[d.prefix,"/"]})," prefix. Unprefixed names can still resolve to a different backend when providers overlap."]}):e.jsxs(e.Fragment,{children:["Managed pinning for ",e.jsxs("code",{children:[d.prefix,"/"]})," is not currently advertised by the proxy. Unprefixed names may still be ambiguous until prefix repair completes."]})}):null,i==="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:"-minimal"}),", ",e.jsx("code",{children:"-low"}),", ",e.jsx("code",{children:"-medium"}),","," ",e.jsx("code",{children:"-high"}),", and ",e.jsx("code",{children:"-xhigh"})," pin reasoning effort. ",e.jsx("code",{children:"-fast"})," ","enables the Codex fast service tier on models that support it, including combined forms such as ",e.jsx("code",{children:"gpt-5.4-high-fast"}),"."]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(we,{label:"Default Model",description:"Used when no specific tier is requested",value:s,onChange:u=>x("ANTHROPIC_MODEL",u),catalog:t,allModels:l,routing:d}),y.length>0&&m&&e.jsx(Pn,{models:y,provider:i,enabled:p??!1,onToggle:m}),e.jsx(we,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:n,onChange:u=>x("ANTHROPIC_DEFAULT_OPUS_MODEL",u),catalog:t,allModels:l,routing:d}),e.jsx(we,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:r,onChange:u=>x("ANTHROPIC_DEFAULT_SONNET_MODEL",u),catalog:t,allModels:l,routing:d}),e.jsx(we,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:o,onChange:u=>x("ANTHROPIC_DEFAULT_HAIKU_MODEL",u),catalog:t,allModels:l,routing:d})]})]})]})}function Tn(t,a,s){return t?e.jsx(ft,{children:e.jsxs(gt,{children:[e.jsx(vt,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(Da,{className:"w-3 h-3","aria-hidden":"true"}),e.jsx("span",{className:X("font-mono max-w-[180px] truncate",a&&kt),title:t,children:t})]})}),e.jsx(jt,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:s("providerEditor.gcpProjectIdReadonly")})})]})}):e.jsx(ft,{children:e.jsxs(gt,{children:[e.jsx(vt,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-500",children:[e.jsx(et,{className:"w-3 h-3","aria-label":"Warning"}),e.jsx("span",{children:s("providerEditor.projectIdNA")})]})}),e.jsx(jt,{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:s("providerEditor.missingProjectId")}),e.jsx("p",{children:s("providerEditor.missingProjectIdHint")})]})})]})})}function En({account:t,onSetDefault:a,onRemove:s,onReauth:n,onPauseToggle:r,isRemoving:o,isPausingAccount:l,privacyMode:d,showQuota:i,selectable:p,selected:m,onSelectChange:v}){const{t:x}=W(),b=t.provider.toLowerCase(),{data:N}=Xs(i),{data:C,isLoading:T}=Ys(b,t.id,i),M=Zs(N,t)?.lastUsedAt,S=p||r?e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[p&&e.jsx("button",{type:"button",onClick:()=>v?.(!m),className:X("flex items-center justify-center w-5 h-5 rounded border-2 transition-colors shrink-0",m?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30 hover:border-primary/50"),"aria-label":m?"Deselect account":"Select account",children:m&&e.jsx(Pe,{className:"w-3 h-3"})}),r&&e.jsx(ft,{children:e.jsxs(gt,{children:[e.jsx(vt,{asChild:!0,children:e.jsx(U,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>r(!t.paused),disabled:l,children:l?e.jsx(ue,{className:"w-4 h-4 animate-spin"}):t.paused?e.jsx(js,{className:"w-4 h-4 text-emerald-500"}):e.jsx(bs,{className:"w-4 h-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(jt,{side:"top",children:t.paused?"Resume account":"Pause account"})]})})]}):void 0,w=e.jsxs(ea,{children:[e.jsx(ta,{asChild:!0,children:e.jsx(U,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(Pa,{className:"w-4 h-4"})})}),e.jsxs(sa,{align:"end",children:[!t.isDefault&&e.jsxs(ct,{onClick:a,children:[e.jsx(Et,{className:"w-4 h-4 mr-2"}),"Set as default"]}),n&&e.jsxs(ct,{onClick:n,children:[e.jsx(at,{className:"w-4 h-4 mr-2"}),"Reauthenticate"]}),e.jsxs(ct,{className:"text-destructive focus:text-destructive",onClick:s,disabled:o,children:[e.jsx(Ns,{className:"w-4 h-4 mr-2"}),o?"Removing...":"Remove account"]})]})]});return e.jsx("div",{className:X("rounded-lg border p-3 transition-colors overflow-hidden",t.isDefault?"border-primary/30 bg-primary/5":"border-border hover:bg-muted/30",t.paused&&"opacity-75",m&&"ring-2 ring-primary/50 bg-primary/5"),children:e.jsx(aa,{mode:"detailed",provider:t.provider,accountId:t.id,email:t.email,displayEmail:t.email||t.id,tokenFile:t.tokenFile,tier:t.tier,isDefault:t.isDefault,paused:t.paused,privacyMode:d,showQuota:i,quota:C,quotaLoading:T,runtimeLastUsed:M,beforeIdentity:S,headerEnd:w,bodySlot:t.provider==="agy"?Tn(t.projectId,d,x):null,quotaInsetClassName:"pl-11"})})}function Rn({selectedCount:t,onPauseSelected:a,onResumeSelected:s,onClearSelection:n,isPausing:r,isResuming:o}){if(t<1)return null;const l=r||o;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:[t," selected"]}),e.jsx(U,{variant:"ghost",size:"sm",className:"text-xs h-6 px-2",onClick:n,disabled:l,children:"Clear"}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsxs(U,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:a,disabled:l,children:[r?e.jsx(ue,{className:"w-3 h-3 animate-spin"}):e.jsx(bs,{className:"w-3 h-3"}),"Pause Selected"]}),e.jsxs(U,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:s,disabled:l,children:[o?e.jsx(ue,{className:"w-3 h-3 animate-spin"}):e.jsx(js,{className:"w-3 h-3"}),"Resume Selected"]})]})]})}function On({accounts:t,onAddAccount:a,onReauthAccount:s,onSetDefault:n,onRemoveAccount:r,onPauseToggle:o,onSoloMode:l,onBulkPause:d,onBulkResume:i,isRemovingAccount:p,isPausingAccount:m,isSoloingAccount:v,isBulkPausing:x,isBulkResuming:b,privacyMode:N,showQuota:C,isKiro:T,kiroNoIncognito:M,onKiroNoIncognitoChange:S,kiroSettingsLoading:w}){const{t:y}=W(),[h,g]=c.useState(new Set),E=c.useMemo(()=>new Set(t.map(k=>k.id)),[t]),u=c.useMemo(()=>new Set([...h].filter(k=>E.has(k))),[h,E]),I=!!(d&&i),A=u.size,q=t.length>0&&u.size===t.length,P=u.size>0&&u.size<t.length,_=c.useCallback(k=>{g(Q=>{const j=new Set(Q);return j.has(k)?j.delete(k):j.add(k),j})},[]),H=c.useCallback(()=>{g(new Set(t.map(k=>k.id)))},[t]),G=c.useCallback(()=>{g(new Set)},[]),V=c.useCallback(()=>{q?G():H()},[q,H,G]),R=c.useCallback(()=>{d&&u.size>0&&(d(Array.from(u)),g(new Set))},[d,u]),O=c.useCallback(()=>{i&&u.size>0&&(i(Array.from(u)),g(new Set))},[i,u]);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:[I&&t.length>0&&e.jsx(Ze,{checked:q,onCheckedChange:V,"aria-label":"Select all accounts",className:P?"data-[state=checked]:bg-primary/50":"",...P?{"data-state":"indeterminate"}:{}}),e.jsx(Oe,{className:"w-4 h-4"}),y("providerEditor.accounts"),t.length>0&&e.jsx(z,{variant:"secondary",className:"text-xs",children:t.length})]}),e.jsxs(U,{variant:"default",size:"sm",className:"h-7 text-xs gap-1",onClick:a,children:[e.jsx(nt,{className:"w-3 h-3"}),y("providerEditor.addAccount")]})]}),I&&A>0&&e.jsx(Rn,{selectedCount:A,onPauseSelected:R,onResumeSelected:O,onClearSelection:G,isPausing:!!x,isResuming:!!b}),t.length>0?e.jsx("div",{className:"space-y-2",children:t.map(k=>e.jsx(En,{account:k,onSetDefault:()=>n(k.id),onRemove:()=>r(k.id),onReauth:s?()=>s(k):void 0,onPauseToggle:o?Q=>o(k.id,Q):void 0,onSoloMode:l?()=>l(k.id):void 0,isRemoving:p,isPausingAccount:m,isSoloingAccount:v,privacyMode:N,showQuota:C,selectable:I,selected:u.has(k.id),onSelectChange:()=>_(k.id)},k.id))}):e.jsxs("div",{className:"py-6 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed",children:[e.jsx(Oe,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:y("providerEditor.noAccountsConnected")}),e.jsx("p",{className:"text-xs opacity-70",children:y("providerEditor.addAccountToStart")})]}),T&&S&&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(vs,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:y("providerEditor.useIncognito")})]}),e.jsx(ps,{checked:!M,onCheckedChange:k=>S(!k),disabled:w,className:"scale-90"})]})})]})}function _n({provider:t,catalog:a,savedPresets:s,currentModel:n,opusModel:r,sonnetModel:o,haikuModel:l,providerModels:d,routing:i,extendedContextEnabled:p,onExtendedContextToggle:m,onApplyPreset:v,onUpdateEnvValue:x,onOpenCustomPreset:b,onDeletePreset:N,isDeletePending:C,accounts:T,onAddAccount:M,onReauthAccount:S,onSetDefault:w,onRemoveAccount:y,onPauseToggle:h,onSoloMode:g,onBulkPause:E,onBulkResume:u,isRemovingAccount:I,isPausingAccount:A,isSoloingAccount:q,isBulkPausing:P,isBulkResuming:_,privacyMode:H,isRemoteMode:G}){const V=t.toLowerCase(),R=(na.includes(V)||["anthropic","antigravity","gemini-cli","copilot","github-copilot"].includes(V))&&!G,O=t==="kiro",[k,Q]=c.useState(!0),[j,Y]=c.useState(!0),[se,le]=c.useState(!1),K=c.useCallback(async()=>{if(O)try{Y(!0);const Z=(await Xe.config.get()).cliproxy;Q(Z?.kiro_no_incognito??!0)}catch{Q(!0)}finally{Y(!1)}},[O]),re=c.useCallback(async $=>{Q($),le(!0);try{const Z=await Xe.config.get(),ie=Z.cliproxy??{};await Xe.config.update({...Z,cliproxy:{...ie,kiro_no_incognito:$}})}catch{Q(!$)}finally{le(!1)}},[]);return c.useEffect(()=>{K()},[K]),e.jsx(Pt,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsx(In,{catalog:a,savedPresets:s,currentModel:n,opusModel:r,sonnetModel:o,haikuModel:l,providerModels:d,routing:i,provider:t,extendedContextEnabled:p,onExtendedContextToggle:m,onApplyPreset:v,onUpdateEnvValue:x,onOpenCustomPreset:b,onDeletePreset:N,isDeletePending:C}),e.jsx(Ot,{}),e.jsx(On,{accounts:T,onAddAccount:M,onReauthAccount:S,onSetDefault:w,onRemoveAccount:y,onPauseToggle:h,onSoloMode:g,onBulkPause:E,onBulkResume:u,isRemovingAccount:I,isPausingAccount:A,isSoloingAccount:q,isBulkPausing:P,isBulkResuming:_,privacyMode:H,showQuota:R,isKiro:O,kiroNoIncognito:k,onKiroNoIncognitoChange:re,kiroSettingsLoading:j||se})]})})}function ts({provider:t,displayName:a,authStatus:s,catalog:n,routing:r,logoProvider:o,baseProvider:l,isRemoteMode:d,port:i,defaultTarget:p,topNotice:m,onAddAccount:v,onReauthAccount:x,onSetDefault:b,onRemoveAccount:N,onPauseToggle:C,onSoloMode:T,onBulkPause:M,onBulkResume:S,isRemovingAccount:w,isPausingAccount:y,isSoloingAccount:h,isBulkPausing:g,isBulkResuming:E}){const[u,I]=c.useState(!1),{privacyMode:A}=ds(),{t:q}=W(),{data:P}=ra(),{data:_}=ia(t),H=oa(),G=la(),V=l||t,R=V.toLowerCase()==="agy",O=c.useMemo(()=>{const L=_?.presets||[];return R?L.filter(te=>!xe(te.default)&&!xe(te.opus)&&!xe(te.sonnet)&&!xe(te.haiku)):L},[R,_?.presets]),k=c.useMemo(()=>{if(!P?.models)return[];const te={gemini:["google"],agy:["antigravity"],codex:["openai"],cursor:["cursor"],gitlab:["gitlab","duo"],codebuddy:["codebuddy"],qwen:["alibaba","qwen"],iflow:["iflow"],kilo:["kilo"],kiro:["kiro","aws"],ghcp:["github","copilot"],kimi:["kimi","moonshot"]}[V.toLowerCase()]||[V.toLowerCase()];return P.models.filter(ae=>te.some(De=>ae.owned_by.toLowerCase().includes(De))?R?!xe(ae.id):!0:!1)},[R,P,V]),Q=(l||t).toLowerCase(),{data:j,isLoading:Y,refetch:se,rawJsonContent:le,rawJsonEdits:K,isRawJsonValid:re,hasChanges:$,currentModel:Z,opusModel:ie,sonnetModel:be,haikuModel:fe,extendedContextEnabled:ke,toggleExtendedContext:Ce,handleRawJsonChange:f,updateEnvValue:F,updateEnvValues:ge,saveMutation:me,conflictDialog:pe,handleConflictResolve:Ae,missingRequiredFields:it}=fn(t,n),ot=c.useMemo(()=>(s.accounts||[]).map(L=>({...L,provider:L.provider||l||t})),[s.accounts,l,t]),{data:de}=ss({queryKey:["auth-tokens-raw"],queryFn:async()=>{const L=await fetch("/api/settings/auth/tokens/raw");return L.ok?L.json():{apiKey:{value:"ccs-internal-managed"}}},staleTime:6e4}),Le=de?.apiKey?.value??"ccs-internal-managed",Fe=L=>{if(R&&[L.ANTHROPIC_MODEL,L.ANTHROPIC_DEFAULT_OPUS_MODEL,L.ANTHROPIC_DEFAULT_SONNET_MODEL,L.ANTHROPIC_DEFAULT_HAIKU_MODEL].some(ae=>typeof ae=="string"&&xe(ae))){B.error(q("providerEditor.agyDenylist"));return}ge({ANTHROPIC_BASE_URL:`http://127.0.0.1:${i??bt}/api/provider/${Q}`,ANTHROPIC_AUTH_TOKEN:Le,...L}),B.success(`Applied "${L.ANTHROPIC_MODEL?.split("/").pop()||"preset"}" preset`)},Ue=(L,te)=>{if(R&&[L.default,L.opus,L.sonnet,L.haiku].some(De=>xe(De))){B.error(q("providerEditor.agyDenylist"));return}ge({ANTHROPIC_BASE_URL:`http://127.0.0.1:${i??bt}/api/provider/${Q}`,ANTHROPIC_AUTH_TOKEN:Le,ANTHROPIC_MODEL:L.default,ANTHROPIC_DEFAULT_OPUS_MODEL:L.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:L.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:L.haiku}),B.success(`Applied ${te?`"${te}"`:"custom"} preset`),I(!1)},Ke=(L,te)=>{if(!te){B.error(he.t("commonToast.enterPresetName"));return}if(R&&[L.default,L.opus,L.sonnet,L.haiku].some(ae=>xe(ae))){B.error(q("providerEditor.agyDenylist"));return}H.mutate({profile:t,data:{name:te,...L}}),I(!1)};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(Mn,{provider:t,displayName:a,logoProvider:o,data:j,isLoading:Y,hasChanges:$,isRawJsonValid:re,isSaving:me.isPending,isRemoteMode:d,port:i,onRefetch:se,onSave:()=>me.mutate()}),m?e.jsx("div",{className:"border-b bg-muted/10 px-4 py-3",children:m}):null,Y?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(ue,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:q("providerEditor.loadingSettings")})]}):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(da,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(ca,{className:"w-full",children:[e.jsx(Vt,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(Vt,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx($t,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(_n,{provider:t,catalog:n,savedPresets:O,currentModel:Z,opusModel:ie,sonnetModel:be,haikuModel:fe,providerModels:k,routing:r,extendedContextEnabled:ke,onExtendedContextToggle:Ce,onApplyPreset:Fe,onUpdateEnvValue:F,onOpenCustomPreset:()=>I(!0),onDeletePreset:L=>G.mutate({profile:t,name:L}),isDeletePending:G.isPending,accounts:ot,onAddAccount:v,onReauthAccount:x,onSetDefault:b,onRemoveAccount:N,onPauseToggle:C,onSoloMode:T,onBulkPause:M,onBulkResume:S,isRemovingAccount:w,isPausingAccount:y,isSoloingAccount:h,isBulkPausing:g,isBulkResuming:E,privacyMode:A,isRemoteMode:d})}),e.jsx($t,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(An,{provider:t,displayName:a,baseProvider:l,defaultTarget:p,data:j,authStatus:s,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(Ia,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("span",{className:"text-sm font-medium text-muted-foreground",children:[q("rawEditorSection.rawConfig")," (JSON)"]})]}),e.jsx(ua,{rawJsonContent:le,isRawJsonValid:re,rawJsonEdits:K,onRawJsonChange:f,profileEnv:j?.settings?.env,missingRequiredFields:it})]})]}),e.jsx(Ra,{open:pe,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>Ae(!0),onCancel:()=>Ae(!1)}),e.jsx(Cn,{open:u,onClose:()=>I(!1),currentValues:{default:Z||"",opus:ie||"",sonnet:be||"",haiku:fe||""},onApply:Ue,onSave:Ke,isSaving:H.isPending,catalog:n,allModels:k,routing:r})]})}function Ln({status:t,isSelected:a,onSelect:s}){const{t:n}=W(),r=t.accounts?.length||0;return e.jsxs("button",{className:X("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors cursor-pointer text-left",a?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:s,children:[e.jsx(Dt,{provider:t.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:t.displayName}),r>0&&e.jsx(z,{variant:"secondary",className:"text-[10px] h-4 px-1",children:r})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:t.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(Pe,{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(Rt,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:n("cliproxyPage.notConnected")})]})})]})]})}function Fn({variant:t,parentAuth:a,isSelected:s,onSelect:n,onDelete:r,isDeleting:o}){const{t:l}=W(),d=()=>{n()};return e.jsxs("div",{role:"button",tabIndex:0,className:X("group w-full flex items-center gap-3 px-3 py-2 rounded-lg transition-colors cursor-pointer text-left pl-6",s?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:d,onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),d())},children:[e.jsxs("div",{className:"relative",children:[e.jsx(Dt,{provider:t.provider,size:"sm"}),e.jsx(tt,{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:t.name}),e.jsx(z,{variant:"outline",className:"text-[9px] h-4 px-1",children:l("cliproxyPage.variant")}),e.jsx(z,{variant:"outline",className:"text-[9px] h-4 px-1 uppercase",children:t.target||"claude"})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:a?.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(Pe,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-muted-foreground truncate",children:l("cliproxyPage.viaProvider",{provider:t.provider})})]}):e.jsxs(e.Fragment,{children:[e.jsx(Rt,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:l("cliproxyPage.parentNotConnected")})]})})]}),e.jsx(U,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:i=>{i.stopPropagation(),r()},disabled:o,children:e.jsx(Ns,{className:"w-3 h-3"})})]})}function Un({onAddAccount:t,onCreateVariant:a}){const{t:s}=W();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(_e,{className:"w-8 h-8 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:s("cliproxyPage.emptyTitle")}),e.jsx("p",{className:"text-muted-foreground mb-4",children:s("cliproxyPage.emptyDesc")}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-6",children:[s("cliproxyPage.emptyControlPanelPrefix")," ",e.jsx("a",{href:"/cliproxy/control-panel",className:"text-primary hover:underline",children:s("cliproxyPage.controlPanel")}),"."]}),e.jsxs("div",{className:"flex flex-col justify-center gap-2 sm:flex-row",children:[e.jsxs(U,{onClick:t,className:"gap-2",children:[e.jsx(nt,{className:"w-4 h-4"}),s("cliproxyPage.addAccount")]}),e.jsxs(U,{onClick:a,variant:"outline",className:"gap-2",children:[e.jsx(tt,{className:"w-4 h-4"}),s("cliproxyPage.advancedVariant")]})]})]})})}function nr(){const{t}=W(),a=wt(),{data:s,isLoading:n}=os(),{data:r,isFetching:o}=ma(),{data:l}=ls(),{data:d}=pa(),i=xa(),p=ha(),m=fa(),v=ga(),x=va(),b=ja(),N=ba(),C=Na(),[T,M]=c.useState(()=>{if(typeof window<"u"){const F=new URLSearchParams(window.location.search).get("provider")?.trim().toLowerCase();return F&&Re(F)?F:localStorage.getItem("cliproxy-selected-provider")}return null}),[S,w]=c.useState(null),[y,h]=c.useState(!1),[g,E]=c.useState(()=>{if(typeof window>"u")return null;const f=new URLSearchParams(window.location.search),F=f.get("provider")?.trim().toLowerCase();return f.get("action")!=="auth"||!F||!Re(F)?null:{provider:F,displayName:ze(F),isFirstAccount:!1}}),u=c.useMemo(()=>s?.authStatus||[],[s?.authStatus]),I=c.useMemo(()=>ya(u,f=>f.provider),[u]),A=s?.source==="remote",q=c.useMemo(()=>r?.variants||[],[r?.variants]),P=c.useMemo(()=>_t(l?.catalogs),[l?.catalogs]),_=l?.routing??{},H=!!l,G=f=>{M(f),f&&localStorage.setItem("cliproxy-selected-provider",f)},V=c.useMemo(()=>S?null:T&&u.some(f=>f.provider===T)?T:u.length>0&&(u.find(F=>(F.accounts?.length||0)>0)?.provider||u[0]?.provider)||null,[T,S,u]),R=u.find(f=>f.provider===V),O=q.find(f=>f.name===S),k=O?u.find(f=>f.provider===O.provider):void 0,Q=O&&k?{provider:O.provider,displayName:k.displayName,accountCount:k.accounts?.length||0}:R?{provider:R.provider,displayName:R.displayName,accountCount:R.accounts?.length||0}:null,j=O?{provider:O.provider,displayName:ze(O.provider),accountCount:0}:T&&Re(T)?{provider:T,displayName:ze(T),accountCount:0}:{provider:"gemini",displayName:ze("gemini"),accountCount:0},Y=Q??j,se=(O?.provider||R?.provider||"").toLowerCase().trim(),le=se==="gemini"||se==="agy",K=()=>{a.invalidateQueries({queryKey:["cliproxy"]}),a.invalidateQueries({queryKey:["cliproxy-auth"]}),a.invalidateQueries({queryKey:["cliproxy-catalog"]}),a.invalidateQueries({queryKey:["cliproxy-models"]})},re=(f,F,ge)=>{m.isPending||v.isPending||(ge?m.mutate({provider:f,accountId:F}):v.mutate({provider:f,accountId:F}))},$=(f,F)=>{x.isPending||x.mutate({provider:f,accountId:F})},Z=(f,F)=>{b.isPending||b.mutate({provider:f,accountIds:F})},ie=(f,F)=>{N.isPending||N.mutate({provider:f,accountIds:F})},be=f=>{G(f),w(null)},fe=f=>{w(f),G(null)},ke=()=>{E({provider:Y.provider,displayName:Y.displayName,isFirstAccount:Y.accountCount===0})},Ce=(f,F,ge,me)=>{const pe=ge?.find(Ae=>Ae.id===me);pe&&E({provider:f,displayName:F,isFirstAccount:!1,account:pe})};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(_e,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:d?.backendLabel??"CLIProxy"})]}),e.jsx(U,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:K,disabled:o,children:e.jsx(at,{className:X("w-4 h-4",o&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:t("cliproxyPage.accountManagement")}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(U,{variant:"default",size:"sm",className:"w-full gap-2",onClick:ke,children:[e.jsx(nt,{className:"w-4 h-4"}),t("cliproxyPage.addAccount")]}),e.jsxs(U,{variant:"outline",size:"sm",className:"w-full gap-2",onClick:()=>h(!0),children:[e.jsx(tt,{className:"w-4 h-4"}),t("cliproxyPage.advancedVariant")]}),e.jsx("p",{className:"text-[11px] leading-relaxed text-muted-foreground",children:t("cliproxyPage.setupActionsHint")})]})]}),e.jsx(Pt,{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:t("cliproxyPage.providers")}),n?e.jsx("div",{className:"space-y-2 px-2",children:[1,2,3,4].map(f=>e.jsx(wa,{className:"h-14 w-full rounded-lg"},f))}):e.jsx("div",{className:"space-y-4",children:I.map(f=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"px-3",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:t(f.labelKey)}),e.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:t(f.hintKey)})]}),e.jsx("div",{className:"space-y-1",children:f.items.map(F=>e.jsx(Ln,{status:F,isSelected:V===F.provider,onSelect:()=>be(F.provider)},F.provider))})]},f.id))}),q.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(tt,{className:"w-3 h-3"}),t("cliproxyPage.variants")]}),e.jsx("div",{className:"space-y-1",children:q.map(f=>e.jsx(Fn,{variant:f,parentAuth:u.find(F=>F.provider===f.provider),isSelected:S===f.name,onSelect:()=>fe(f.name),onDelete:()=>C.mutate(f.name),isDeleting:C.isPending},f.name))})]})]})}),e.jsx("div",{className:"p-3 border-t",children:e.jsx(_a,{})}),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("cliproxyPage.providerCount",{count:u.length})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Pe,{className:"w-3 h-3 text-green-600"}),t("cliproxyPage.connectedCount",{count:u.filter(f=>f.authenticated).length})]})]})})]}),e.jsx("div",{className:"flex-1 flex min-w-0 flex-col overflow-hidden bg-background",children:O&&k?e.jsx(e.Fragment,{children:e.jsx(ts,{provider:O.name,displayName:t("cliproxyPage.variantDisplay",{name:O.name,provider:O.provider}),authStatus:k,catalog:P[O.provider],routing:_[O.provider],logoProvider:O.provider,baseProvider:O.provider,defaultTarget:O.target,isRemoteMode:A,port:O.port,topNotice:le?e.jsx(yt,{compact:!0,showProxySettingsLink:!0}):void 0,onAddAccount:()=>E({provider:O.provider,displayName:k.displayName,isFirstAccount:(k.accounts?.length||0)===0}),onReauthAccount:f=>Ce(O.provider,k.displayName,k.accounts,f.id),onSetDefault:f=>i.mutate({provider:O.provider,accountId:f}),onRemoveAccount:f=>p.mutate({provider:O.provider,accountId:f}),onPauseToggle:(f,F)=>re(O.provider,f,F),onSoloMode:f=>$(O.provider,f),onBulkPause:f=>Z(O.provider,f),onBulkResume:f=>ie(O.provider,f),isRemovingAccount:p.isPending,isPausingAccount:m.isPending||v.isPending,isSoloingAccount:x.isPending,isBulkPausing:b.isPending,isBulkResuming:N.isPending})}):R?e.jsx(e.Fragment,{children:e.jsx(ts,{provider:R.provider,displayName:R.displayName,authStatus:R,catalog:P[R.provider],routing:_[R.provider],isRemoteMode:A,topNotice:le?e.jsx(yt,{compact:!0,showProxySettingsLink:!0}):void 0,onAddAccount:()=>E({provider:R.provider,displayName:R.displayName,isFirstAccount:(R.accounts?.length||0)===0}),onReauthAccount:f=>Ce(R.provider,R.displayName,R.accounts,f.id),onSetDefault:f=>i.mutate({provider:R.provider,accountId:f}),onRemoveAccount:f=>p.mutate({provider:R.provider,accountId:f}),onPauseToggle:(f,F)=>re(R.provider,f,F),onSoloMode:f=>$(R.provider,f),onBulkPause:f=>Z(R.provider,f),onBulkResume:f=>ie(R.provider,f),isRemovingAccount:p.isPending,isPausingAccount:m.isPending||v.isPending,isSoloingAccount:x.isPending,isBulkPausing:b.isPending,isBulkResuming:N.isPending})}):e.jsx(Un,{onAddAccount:ke,onCreateVariant:()=>h(!0)})}),e.jsx(nn,{open:y,onClose:()=>h(!1)}),e.jsx(pn,{open:g!==null,onClose:()=>E(null),provider:g?.provider||"",displayName:g?.displayName||"",catalog:H&&g?.provider?P[g.provider]:void 0,isFirstAccount:g?.isFirstAccount||!1,account:g?.account})]})}export{nr as CliproxyPage};
@@ -1 +0,0 @@
1
- import{j as t}from"./radix-ui-nu4wz29m.js";import{r as a}from"./react-vendor-Bjx91N7w.js";import{u as _}from"./tanstack-bhJxV1h8.js";import{a as D,bf as g,_ as $}from"./index-sIfjKy42.js";import{C as A}from"./default-ports-1QQSffYX.js";import{G as Q,R as T,w as X}from"./icons-DzKUh8vG.js";import"./notifications-B4_o8bcr.js";import"./utils-CzKF5WmX.js";import"./form-utils-CuHzLhJZ.js";import"./charts-eIPy2oG6.js";const O="cli-proxy-auth",U="isLoggedIn",K="apiBase",B="apiUrl",C="managementKey";function k(l){return l.startsWith("/")?new URL(l.replace(/\/$/,""),window.location.origin).href:l.replace(/\/$/,"")}function J(l,u){window.localStorage.removeItem(O),window.localStorage.setItem(K,l),window.localStorage.setItem(B,l),window.localStorage.setItem(C,u),window.localStorage.setItem(U,"true")}function w(){window.localStorage.removeItem(O),window.localStorage.removeItem(K),window.localStorage.removeItem(B),window.localStorage.removeItem(C),window.localStorage.removeItem(U)}function V(){window.localStorage.removeItem(C)}function Z({port:l=A}){const{t:u}=D(),f=a.useRef(null),[F,N]=a.useState(null),[M,G]=a.useState(0),[E,P]=a.useState(null),[H,j]=a.useState(!1),{data:i,error:y}=_({queryKey:["cliproxy-server-config"],queryFn:()=>$.cliproxyServer.get(),staleTime:3e4});a.useEffect(()=>{y&&console.warn("[ControlPanelEmbed] Config fetch failed, using local mode:",y)},[y]);const R=!!(i?.remote?.enabled&&i?.remote?.host),{data:b,error:x}=_({queryKey:["auth-tokens-raw",R?"remote":"local"],enabled:i!==void 0&&!R,queryFn:async()=>{try{const e=await fetch(g("/settings/auth/tokens/raw"));if(!e.ok)throw new Error("Failed to fetch auth tokens");const s=await e.json(),o=s.managementSecret.value.trim();if(!o)throw new Error("Management secret missing");return J(k(g("/cliproxy-local/")),o),s}catch(e){throw w(),e}},staleTime:3e4}),{managementUrl:S,checkUrl:h,authToken:L,isRemote:n,displayHost:c}=a.useMemo(()=>{const e=i?.remote,s=i?.local?.port??l;if(e?.enabled&&e?.host){const o=e.protocol||"http",m=e.port||(o==="https"?443:A),p=o==="https"&&m===443||o==="http"&&m===80?"":`:${m}`,r=`${o}://${e.host}${p}`;return{managementUrl:`${r}/management.html`,checkUrl:`${r}/`,authToken:e.auth_token||void 0,isRemote:!0,displayHost:`${e.host}${p}`}}return{managementUrl:g("/cliproxy-local/management.html"),checkUrl:g("/cliproxy-local/"),authToken:b?.managementSecret?.value||void 0,isRemote:!1,displayHost:`localhost:${s}`}},[i,b,l]),v=`${S}:${n?"remote":"local"}:${h}:${L??"missing"}:${M}`,I=i!==void 0&&(n||!!b||!!x);a.useEffect(()=>{x&&console.warn("[ControlPanelEmbed] Failed to preload local control panel session, falling back to manual login:",x)},[x]),a.useEffect(()=>{if(n)return;const e=()=>{w()};return window.addEventListener("beforeunload",e),()=>{window.removeEventListener("beforeunload",e),w()}},[n]);const Y=!I||!(F===v),q=()=>{if(!(!n||!f.current?.contentWindow||!L))try{const e=k(h),s=new URL(`${e}/`).origin;if(new URL(f.current.src,window.location.origin).origin!==s){console.warn("[ControlPanelEmbed] Remote iframe origin mismatch, skipping postMessage");return}f.current.contentWindow.postMessage({type:"ccs-auto-login",apiBase:e,managementKey:L},s)}catch(e){console.debug("[ControlPanelEmbed] Remote postMessage bootstrap failed:",e)}};a.useEffect(()=>{const e=new AbortController;let s=!1;const o=(r,d)=>{s||(j(r),P(d))},m=async()=>{try{if(n){const r=i?.remote,d=await $.cliproxyServer.test({host:r?.host??"",port:r?.port,protocol:r?.protocol??"http",authToken:r?.auth_token});d?.reachable?o(!0,null):o(!1,d?.error?`Remote CLIProxy at ${c}: ${d.error}`:`Remote CLIProxy at ${c} returned an error`)}else(await fetch(h,{signal:e.signal})).ok?o(!0,null):o(!1,"CLIProxy returned an error")}catch(r){if(r instanceof Error&&r.name==="AbortError")return;o(!1,n?`Remote CLIProxy at ${c} is not reachable`:"CLIProxy is not running")}},p=setTimeout(()=>e.abort(),2e3);return m().finally(()=>clearTimeout(p)),()=>{s=!0,e.abort()}},[h,n,c,i]);const W=()=>{N(v),q(),n||V()},z=()=>{n||w(),N(null),G(e=>e+1),P(null),j(!1)};return!H&&E?t.jsxs("div",{className:"flex-1 flex flex-col",children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Q,{className:"w-5 h-5 text-primary"}),t.jsx("h2",{className:"font-semibold",children:u("cliproxyHeader.cliproxyControlPanel")})]}),t.jsxs("button",{className:"inline-flex items-center gap-2 px-3 py-1.5 text-sm border rounded-md hover:bg-muted",onClick:z,children:[t.jsx(T,{className:"w-4 h-4"}),"Retry"]})]}),t.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/20",children:t.jsxs("div",{className:"text-center max-w-md px-8",children:[t.jsx("div",{className:"w-16 h-16 rounded-full bg-destructive/10 flex items-center justify-center mx-auto mb-6",children:t.jsx(X,{className:"w-8 h-8 text-destructive"})}),t.jsx("h3",{className:"text-lg font-semibold mb-2",children:u("cliproxyHeader.cliproxyNotAvailable")}),t.jsx("p",{className:"text-muted-foreground mb-4",children:E}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Start a CLIProxy session with"," ",t.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs gemini"})," or run"," ",t.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs config"})," which auto-starts it."]})]})})]}):t.jsx("div",{className:"flex-1 flex flex-col",children:t.jsxs("div",{className:"flex-1 flex flex-col relative",children:[Y&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/80 z-10",children:t.jsxs("div",{className:"text-center",children:[t.jsx(T,{className:"w-8 h-8 animate-spin text-primary mx-auto mb-2"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:n?`Loading Control Panel from ${c}...`:"Loading Control Panel..."})]})}),I?t.jsx("iframe",{ref:f,src:S,className:"flex-1 w-full border-0",title:"CLIProxy Management Panel",onLoad:W},v):null]})})}function de(){return t.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:t.jsx(Z,{})})}export{de as CliproxyControlPanelPage};
@@ -1,30 +0,0 @@
1
- import{j as e}from"./radix-ui-nu4wz29m.js";import{r as N}from"./react-vendor-Bjx91N7w.js";import{t as U}from"./notifications-B4_o8bcr.js";import{bf as ne,a as T,B as y,T as ns,o as as,p as os,e as C,q as ls,C as I,s as F,t as K,b as W,aJ as ee,j as E,k as D,l as O,m as L,n as b,I as _,x as we,Y as S,bg as Ae,c as Me,bm as is,bn as Ce,bo as cs,U as ds,V as xs,W as oe,X as le,bh as Se}from"./index-sIfjKy42.js";import{T as Re,a as Ie,b as ce,c as B,d as Fe,e as V}from"./table-DYyc1gJc.js";import{u as je,a as us,b as _e}from"./tanstack-bhJxV1h8.js";import{L as G,aa as ms,aS as hs,at as de,n as ps,aT as fs,aU as js,aC as gs,w as vs,a7 as bs,aV as ws,aW as Ns,aX as ys,ai as ge,p as Te,$ as Cs,m as Ss,o as _s,_ as Ts,S as ks,aN as ke,aY as Ps,x as Es,I as Ds,T as Os,N as Ls}from"./icons-DzKUh8vG.js";import{T as te}from"./Trans-BIQ-yfAc.js";import{S as ie}from"./separator-BvoSJCHW.js";import{R as As}from"./raw-json-settings-editor-panel-DZRtQXbD.js";import"./utils-CzKF5WmX.js";import"./form-utils-CuHzLhJZ.js";import"./charts-eIPy2oG6.js";async function Ms(){const s=await fetch(ne("/codex/profiles"));if(!s.ok)throw new Error("Failed to fetch Codex auth profiles");return s.json()}function Rs(){return je({queryKey:["codex-auth-profiles"],queryFn:Ms,refetchInterval:15e3})}function re({children:s}){return e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[0.85em] text-foreground",children:s})}function Is(s){if(!s)return"never";try{const t=new Date(s),r=Date.now()-t.getTime(),a=Math.floor(r/6e4);if(a<2)return"just now";if(a<60)return`${a} min ago`;const o=Math.floor(a/60);if(o<24)return`${o}h ago`;const n=Math.floor(o/24);return n===1?"yesterday":`${n}d ago`}catch{return s}}function Ke(s,t){switch(s){case"default":return t("codex.auth.sourceDefault");case"env":return t("codex.auth.sourceEnv");case"explicit-codex-home":return t("codex.auth.sourceExplicitCodexHome")}}function Pe({label:s}){return e.jsx(ns,{children:e.jsxs(as,{children:[e.jsx(os,{asChild:!0,children:e.jsx("span",{tabIndex:0,className:"inline-block",children:e.jsx(C,{variant:"outline",size:"sm",disabled:!0,className:"pointer-events-none",children:s})})}),e.jsx(ls,{children:e.jsx(te,{i18nKey:"codex.auth.terminalOnlyTooltipRich",components:{code:e.jsx(re,{})}})})]})})}function Fs({entry:s,isActive:t,activeSource:r}){const{t:a}=T();return e.jsxs(ce,{className:t?"bg-muted/40":void 0,children:[e.jsx(V,{className:"font-medium",children:e.jsxs("span",{className:"flex items-center gap-2",children:[s.name,t&&r&&e.jsx(y,{variant:"secondary",className:"text-xs",children:a("codex.auth.activeSourceBadge",{source:Ke(r,a)})})]})}),e.jsx(V,{children:s.email??"—"}),e.jsx(V,{children:s.plan??"—"}),e.jsx(V,{children:Is(s.lastUsed)}),e.jsx(V,{children:s.authValid?e.jsx(y,{variant:"secondary",className:"text-xs text-green-700 dark:text-green-400",children:a("codex.auth.statusOk")}):e.jsx(y,{variant:"destructive",className:"text-xs",children:a("codex.auth.statusInvalid")})}),e.jsx(V,{children:e.jsxs("span",{className:"flex gap-1",children:[e.jsx(Pe,{label:a("codex.auth.switchAction")}),e.jsx(Pe,{label:a("codex.auth.removeAction")})]})})]})}function Ks(){const{t:s}=T(),{data:t,isLoading:r,error:a}=Rs();return r?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground p-4",children:[e.jsx(G,{className:"h-4 w-4 animate-spin"}),s("codex.auth.loading")]}):a||!t?e.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:s("codex.auth.loadError")}):t.profiles.length===0?e.jsxs("div",{className:"rounded-md border bg-muted/30 px-4 py-3 text-sm text-muted-foreground space-y-1",children:[e.jsx("p",{children:e.jsx(te,{i18nKey:"codex.auth.emptyRegistryRich",components:{code:e.jsx(re,{})}})}),e.jsx("p",{children:e.jsx(te,{i18nKey:"codex.auth.legacyCodexHomeRich",components:{code:e.jsx(re,{})}})})]}):t.active?t.active.source==="explicit-codex-home"&&t.active.name===null?e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"rounded-md border bg-muted/30 px-4 py-3 text-sm text-muted-foreground",children:e.jsx(te,{i18nKey:"codex.auth.externalCodexHomeRich",values:{path:t.active.codexHome},components:{code:e.jsx(re,{})}})}),e.jsx(ue,{data:t})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(Ws,{name:t.active.name,source:t.active.source,profiles:t.profiles}),e.jsx(ue,{data:t})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"rounded-md border bg-muted/30 px-4 py-3 text-sm text-muted-foreground",children:e.jsx(te,{i18nKey:"codex.auth.legacyModeRich",components:{code:e.jsx(re,{})}})}),e.jsx(ue,{data:t})]})}function Ws({name:s,source:t,profiles:r}){const{t:a}=T(),o=r.find(n=>n.name===s);return e.jsxs("div",{className:"rounded-md border bg-muted/20 px-4 py-3 text-sm space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[a("codex.auth.activeProfile"),e.jsx("span",{children:s??a("codex.auth.unknownProfile")}),e.jsx(y,{variant:"secondary",className:"text-xs",children:Ke(t,a)})]}),o&&e.jsxs("div",{className:"text-muted-foreground text-xs space-x-3",children:[o.email&&e.jsx("span",{children:o.email}),o.plan&&e.jsxs("span",{children:[a("codex.auth.planLabel")," ",e.jsx("strong",{children:o.plan})]}),!o.authValid&&e.jsx("span",{className:"text-destructive",children:a("codex.auth.statusInvalid")})]})]})}function ue({data:s}){const{t}=T();return e.jsx("div",{className:"rounded-md border overflow-auto",children:e.jsxs(Re,{children:[e.jsx(Ie,{children:e.jsxs(ce,{children:[e.jsx(B,{children:t("codex.auth.col.name")}),e.jsx(B,{children:t("codex.auth.col.email")}),e.jsx(B,{children:t("codex.auth.col.plan")}),e.jsx(B,{children:t("codex.auth.col.lastUsed")}),e.jsx(B,{children:t("codex.auth.col.status")}),e.jsx(B,{children:t("codex.auth.col.actions")})]})}),e.jsx(Fe,{children:s.profiles.map(r=>e.jsx(Fs,{entry:r,isActive:s.active?.name===r.name,activeSource:s.active?.name===r.name?s.active.source:void 0},r.name))})]})})}function se({title:s,icon:t,badge:r,description:a,disabledReason:o,children:n}){return e.jsxs(I,{children:[e.jsxs(F,{className:"pb-2",children:[e.jsxs(K,{className:"flex items-center gap-2 text-base",children:[t,s,r?e.jsx(y,{variant:"outline",className:"text-[10px] font-normal",children:r}):null]}),a?e.jsx("p",{className:"text-xs text-muted-foreground",children:a}):null]}),e.jsxs(W,{className:"space-y-3",children:[o?e.jsx("p",{className:"text-xs text-amber-600",children:o}):null,n]})]})}function qs({catalog:s,state:t,disabled:r=!1,disabledReason:a,onToggle:o}){const{t:n}=T(),l=new Set(s.map(i=>i.name)),c=Object.entries(t).filter(([i])=>!l.has(i)).sort(([i],[d])=>i.localeCompare(d));return e.jsxs(se,{title:n("codex.features"),badge:"features",icon:e.jsx(ms,{className:"h-4 w-4"}),description:n("codex.featuresDesc"),disabledReason:a,children:[e.jsx("div",{className:"space-y-2",children:s.map(i=>{const d=t[i.name]??null;return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium",children:i.label}),e.jsx(y,{variant:"outline",className:"font-mono text-[10px]",children:i.name})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[d!==null?e.jsx(C,{variant:"outline",size:"sm",onClick:()=>o(i.name,null),disabled:r,children:n("codex.useDefault")}):null,e.jsx(ee,{checked:d===!0,onCheckedChange:m=>o(i.name,m),disabled:r})]})]},i.name)})}),c.length>0?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:n("codex.configOnlyFlags")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n("codex.configOnlyFlagsDesc")})]}),c.map(([i,d])=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-dashed px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium",children:i}),e.jsx(y,{variant:"secondary",className:"text-[10px]",children:n("codex.existing")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n(d===null?"codex.nonBooleanForm":"codex.discoveredFromFile")})]}),d===null?e.jsx(y,{variant:"outline",children:n("codex.rawOnly")}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{variant:"outline",size:"sm",onClick:()=>o(i,null),disabled:r,children:n("codex.useDefault")}),e.jsx(ee,{checked:d===!0,onCheckedChange:m=>o(i,m),disabled:r})]})]},i))]}):null]})}const Us={name:"",transport:"stdio",command:null,args:[],url:null,enabled:!0,required:!1,startupTimeoutSec:null,toolTimeoutSec:null,enabledTools:[],disabledTools:[],isCcsManaged:!1,managementSurface:null};function me(s){return s.join(", ")}function he(s){return s.split(",").map(t=>t.trim()).filter(Boolean)}function Bs({initialDraft:s,isNew:t,disabled:r,saving:a,canDelete:o,onSave:n,onDelete:l}){const{t:c}=T(),[i,d]=N.useState(s),m=t&&i.name.trim()==="ccs_browser";return e.jsxs(e.Fragment,{children:[m?e.jsxs("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm text-amber-900 dark:text-amber-200",children:[e.jsx("strong",{children:"ccs_browser"})," is reserved for the CCS-managed browser tooling path. Configure it from ",e.jsx("code",{children:"Settings > Browser"})," instead of creating it here."]}):null,e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(_,{value:i.name,onChange:h=>d(x=>({...x,name:h.target.value})),placeholder:"playwright",disabled:r||!t}),e.jsxs(E,{value:i.transport,onValueChange:h=>d(x=>({...x,transport:h})),disabled:r,children:[e.jsx(D,{children:e.jsx(O,{})}),e.jsxs(L,{children:[e.jsx(b,{value:"stdio",children:c("codex.stdio")}),e.jsx(b,{value:"streamable-http",children:c("codex.streamableHttp")})]})]}),i.transport==="stdio"?e.jsxs(e.Fragment,{children:[e.jsx(_,{value:i.command??"",onChange:h=>d(x=>({...x,command:h.target.value||null})),placeholder:"npx",disabled:r}),e.jsx(_,{value:me(i.args),onChange:h=>d(x=>({...x,args:he(h.target.value)})),placeholder:"@playwright/mcp@latest, --flag",disabled:r})]}):e.jsx(_,{className:"sm:col-span-2",value:i.url??"",onChange:h=>d(x=>({...x,url:h.target.value||null})),placeholder:"https://example.test/mcp",disabled:r}),e.jsx(_,{type:"number",min:1,value:i.startupTimeoutSec??"",onChange:h=>d(x=>({...x,startupTimeoutSec:h.target.value?Number(h.target.value):null})),placeholder:"Startup timeout (sec)",disabled:r}),e.jsx(_,{type:"number",min:1,value:i.toolTimeoutSec??"",onChange:h=>d(x=>({...x,toolTimeoutSec:h.target.value?Number(h.target.value):null})),placeholder:"Tool timeout (sec)",disabled:r}),e.jsx(_,{value:me(i.enabledTools),onChange:h=>d(x=>({...x,enabledTools:he(h.target.value)})),placeholder:"enabled_tools",disabled:r}),e.jsx(_,{value:me(i.disabledTools),onChange:h=>d(x=>({...x,disabledTools:he(h.target.value)})),placeholder:"disabled_tools",disabled:r})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Enabled",e.jsx(ee,{checked:i.enabled,onCheckedChange:h=>d(x=>({...x,enabled:h})),disabled:r})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Required",e.jsx(ee,{checked:i.required,onCheckedChange:h=>d(x=>({...x,required:h})),disabled:r})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs(C,{variant:"outline",onClick:l,disabled:r||a||!o,children:[e.jsx(de,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsxs(C,{onClick:()=>n(i.name,{transport:i.transport,command:i.command,args:i.args,url:i.url,enabled:i.enabled,required:i.required,startupTimeoutSec:i.startupTimeoutSec,toolTimeoutSec:i.toolTimeoutSec,enabledTools:i.enabledTools,disabledTools:i.disabledTools}),disabled:r||a||i.name.trim().length===0||m,children:[a?e.jsx(G,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save MCP server"]})]})]})}function Vs({entries:s,disabled:t=!1,disabledReason:r,saving:a=!1,onSave:o,onDelete:n}){const{t:l}=T(),[c,i]=N.useState("new"),d=N.useMemo(()=>s.find(g=>g.name===c)??null,[s,c]),m=d??Us,h=JSON.stringify(m),x=d?.isCcsManaged&&d.managementSurface==="browser-settings";return e.jsxs(se,{title:"MCP servers",badge:"mcp_servers",icon:e.jsx(hs,{className:"h-4 w-4"}),description:"Manage the safe MCP transport fields. Keep auth headers and bearer tokens in raw TOML.",disabledReason:r,children:[x?e.jsxs("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm text-amber-900 dark:text-amber-200",children:[e.jsx("strong",{children:d?.name})," is CCS-managed. Configure browser tooling from"," ",e.jsx("code",{children:"Settings > Browser"}),"; the generic MCP editor is read-only for this entry."]}):null,e.jsxs(E,{value:c,onValueChange:i,disabled:t,children:[e.jsx(D,{children:e.jsx(O,{placeholder:"Select MCP server"})}),e.jsxs(L,{children:[e.jsx(b,{value:"new",children:l("codex.createNewMcpServer")}),s.map(g=>e.jsx(b,{value:g.name,children:g.isCcsManaged?`${g.name} (CCS managed)`:g.name},g.name))]})]}),e.jsx(Bs,{initialDraft:m,isNew:c==="new",disabled:t||!!x,saving:a,canDelete:d!==null&&!x,onDelete:async()=>{d&&(await n(d.name),i("new"))},onSave:async(g,p)=>{await o(g,p),i(g)}},h)]})}const $s={name:"",displayName:null,baseUrl:null,envKey:null,wireApi:"responses",requiresOpenaiAuth:!1,supportsWebsockets:!1},zs={name:"cliproxy",displayName:"CLIProxy Codex",baseUrl:"http://127.0.0.1:8317/api/provider/codex",envKey:"CLIPROXY_API_KEY",wireApi:"responses",requiresOpenaiAuth:!1,supportsWebsockets:!1};function Gs({initialDraft:s,isNew:t,disabled:r,saving:a,canDelete:o,onSave:n,onDelete:l}){const{t:c}=T(),[i,d]=N.useState(s);return e.jsxs(e.Fragment,{children:[t&&e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-dashed px-3 py-2 text-xs text-muted-foreground",children:[e.jsxs("p",{children:["Quick start: apply the CLIProxy Codex preset here, then set"," ",e.jsx("strong",{children:c("codex.defaultProvider")})," to ",e.jsx("code",{children:"cliproxy"})," in Top-level settings."]}),e.jsx(C,{variant:"outline",size:"sm",onClick:()=>d(zs),disabled:r,children:"Use CLIProxy Codex preset"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(_,{value:i.name,onChange:m=>d(h=>({...h,name:m.target.value})),placeholder:"Provider id",disabled:r||!t}),e.jsx(_,{value:i.displayName??"",onChange:m=>d(h=>({...h,displayName:m.target.value||null})),placeholder:"Display name",disabled:r}),e.jsx(_,{value:i.baseUrl??"",onChange:m=>d(h=>({...h,baseUrl:m.target.value||null})),placeholder:"http://127.0.0.1:8317/api/provider/codex",disabled:r}),e.jsx(_,{value:i.envKey??"",onChange:m=>d(h=>({...h,envKey:m.target.value||null})),placeholder:"CLIPROXY_API_KEY",disabled:r})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs(E,{value:i.wireApi??"responses",onValueChange:m=>d(h=>({...h,wireApi:m})),disabled:r,children:[e.jsx(D,{children:e.jsx(O,{})}),e.jsx(L,{children:e.jsx(b,{value:"responses",children:c("codex.responses")})})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Requires OpenAI auth",e.jsx(ee,{checked:i.requiresOpenaiAuth,onCheckedChange:m=>d(h=>({...h,requiresOpenaiAuth:m})),disabled:r})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Supports websockets",e.jsx(ee,{checked:i.supportsWebsockets,onCheckedChange:m=>d(h=>({...h,supportsWebsockets:m})),disabled:r})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs(C,{variant:"outline",onClick:l,disabled:r||a||!o,children:[e.jsx(de,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsxs(C,{onClick:()=>n(i.name,{displayName:i.displayName,baseUrl:i.baseUrl,envKey:i.envKey,wireApi:i.wireApi,requiresOpenaiAuth:i.requiresOpenaiAuth,supportsWebsockets:i.supportsWebsockets}),disabled:r||a||i.name.trim().length===0,children:[a?e.jsx(G,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save provider"]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["If you want plain native ",e.jsx("code",{children:"codex"})," to default to CLIProxy, save a provider named"," ",e.jsx("code",{children:"cliproxy"})," with ",e.jsx("code",{children:"CLIPROXY_API_KEY"})," here, then pick"," ",e.jsx("code",{children:"cliproxy"})," in the ",e.jsx("strong",{children:c("codex.defaultProvider")})," control above."]})]})}function Xs({entries:s,disabled:t=!1,disabledReason:r,saving:a=!1,onSave:o,onDelete:n}){const{t:l}=T(),[c,i]=N.useState("new"),d=N.useMemo(()=>s.find(x=>x.name===c)??null,[s,c]),m=d??$s,h=JSON.stringify(m);return e.jsxs(se,{title:"Model providers",badge:"model_providers",icon:e.jsx(ps,{className:"h-4 w-4"}),description:"Edit the common provider fields CCS can support safely. Keep secret migration and inline bearer tokens in raw TOML.",disabledReason:r,children:[e.jsxs(E,{value:c,onValueChange:i,disabled:t,children:[e.jsx(D,{children:e.jsx(O,{placeholder:"Select provider"})}),e.jsxs(L,{children:[e.jsx(b,{value:"new",children:l("codex.createNewProvider")}),s.map(x=>e.jsx(b,{value:x.name,children:x.name},x.name))]})]}),e.jsx(Gs,{initialDraft:m,isNew:c==="new",disabled:t,saving:a,canDelete:d!==null,onDelete:async()=>{d&&(await n(d.name),i("new"))},onSave:async(x,g)=>{await o(x,g),i(x)}},h)]})}function Hs({initialName:s,initialModel:t,initialProvider:r,initialEffort:a,providerNames:o,activeProfile:n,selectedEntryName:l,disabled:c,saving:i,onSave:d,onDelete:m,onSetActive:h}){const{t:x}=T(),[g,p]=N.useState(s),[w,M]=N.useState(t),[q,u]=N.useState(r),[v,X]=N.useState(a);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(_,{value:g,onChange:j=>p(j.target.value),placeholder:"deep-review",disabled:c||l!==null}),e.jsx(_,{value:w??"",onChange:j=>M(j.target.value||null),placeholder:"gpt-5.4",disabled:c}),e.jsxs(E,{value:q??"__unset__",onValueChange:j=>u(j==="__unset__"?null:j),disabled:c,children:[e.jsx(D,{children:e.jsx(O,{placeholder:x("codex.useGlobalProvider")})}),e.jsxs(L,{children:[e.jsx(b,{value:"__unset__",children:x("codex.useGlobalProvider")}),o.map(j=>e.jsx(b,{value:j,children:j},j))]})]}),e.jsxs(E,{value:v??"__unset__",onValueChange:j=>X(j==="__unset__"?null:j),disabled:c,children:[e.jsx(D,{children:e.jsx(O,{placeholder:x("codex.useGlobalEffort")})}),e.jsxs(L,{children:[e.jsx(b,{value:"__unset__",children:x("codex.useGlobalEffort")}),["minimal","low","medium","high","xhigh"].map(j=>e.jsx(b,{value:j,children:j},j))]})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(C,{variant:"outline",onClick:m,disabled:c||i||!l,children:[e.jsx(de,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsx(C,{variant:"outline",onClick:h,disabled:c||i||!l||l===n,children:"Set active"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(C,{variant:"outline",onClick:()=>d(g,{model:w,modelProvider:q,modelReasoningEffort:v},!1),disabled:c||i||g.trim().length===0,children:[i?e.jsx(G,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save profile"]}),e.jsxs(C,{onClick:()=>d(g,{model:w,modelProvider:q,modelReasoningEffort:v},!0),disabled:c||i||g.trim().length===0,children:[i?e.jsx(G,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save + activate"]})]})]})]})}function Ys({activeProfile:s,entries:t,providerNames:r,disabled:a=!1,disabledReason:o,saving:n=!1,onSave:l,onDelete:c,onSetActive:i}){const{t:d}=T(),[m,h]=N.useState("new"),x=N.useMemo(()=>t.find(p=>p.name===m)??null,[t,m]),g=JSON.stringify(x??{name:"",values:{}});return e.jsxs(se,{title:d("codex.profiles"),badge:"profiles",icon:e.jsx(fs,{className:"h-4 w-4"}),description:"Create reusable Codex overlays and set the active default profile.",disabledReason:o,children:[e.jsxs(E,{value:m,onValueChange:h,disabled:a,children:[e.jsx(D,{children:e.jsx(O,{placeholder:"Select profile"})}),e.jsxs(L,{children:[e.jsx(b,{value:"new",children:d("codex.createNewProfile")}),t.map(p=>e.jsxs(b,{value:p.name,children:[p.name,p.name===s?" (active)":""]},p.name))]})]}),e.jsx(Hs,{initialName:x?.name??"",initialModel:x?.values.model??null,initialProvider:x?.values.modelProvider??null,initialEffort:x?.values.modelReasoningEffort??null,providerNames:r,activeProfile:s,selectedEntryName:x?.name??null,disabled:a,saving:n,onDelete:async()=>{x&&(await c(x.name),h("new"))},onSetActive:async()=>{x&&await i(x.name)},onSave:async(p,w,M)=>{await l(p,w,M),h(p)}},g)]})}function Qs({workspacePath:s,disabled:t,saving:r,onSave:a}){const{t:o}=T(),[n,l]=N.useState(s),[c,i]=N.useState("trusted");return e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_160px_auto]",children:[e.jsx(_,{value:n,onChange:d=>l(d.target.value),placeholder:"~/repo or /absolute/path",disabled:t}),e.jsxs(E,{value:c,onValueChange:i,disabled:t,children:[e.jsx(D,{children:e.jsx(O,{})}),e.jsxs(L,{children:[e.jsx(b,{value:"trusted",children:o("codex.trusted")}),e.jsx(b,{value:"untrusted",children:o("codex.untrusted")})]})]}),e.jsxs(C,{onClick:()=>a(n,c),disabled:t||r,children:[r?e.jsx(G,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save trust"]})]})}function Js({workspacePath:s,entries:t,disabled:r=!1,disabledReason:a,saving:o=!1,onSave:n}){const{t:l}=T();return e.jsxs(se,{title:"Project trust",badge:"projects",icon:e.jsx(js,{className:"h-4 w-4"}),description:"Trust current workspaces or remove stale trust entries without opening raw TOML.",disabledReason:a,children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Paths must be absolute or start with ",e.jsx("code",{children:"~/"}),". Relative paths are rejected so CCS does not trust the wrong folder."]}),e.jsx(Qs,{workspacePath:s,disabled:r,saving:o,onSave:n},s),e.jsx(C,{variant:"outline",className:"w-full justify-start",onClick:()=>n(s,"trusted"),disabled:r||o,children:"Trust current workspace"}),e.jsx("div",{className:"space-y-2",children:t.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:l("codex.noProjectTrustEntries")}):t.map(c=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:c.path}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["trust_level = ",c.trustLevel]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>n(c.path,c.trustLevel==="trusted"?"untrusted":"trusted"),disabled:r||o,children:"Toggle"}),e.jsx(C,{variant:"ghost",size:"icon",onClick:()=>n(c.path,null),disabled:r||o,children:e.jsx(de,{className:"h-4 w-4"})})]})]},c.path))})]})}const A="__unset__",Zs=105e4,et=272e3,Ee=8e5,De=7e5,st=new Intl.NumberFormat("en-US");function Y(s){return s??A}function Q(s,t){return t&&!s.includes(t)?[t,...s]:s}function pe(s){return st.format(s)}function tt(s){return s?.trim().toLowerCase().startsWith("gpt-5.4")??!1}function rt(s,t){const r={};return t.model!==s.model&&(r.model=t.model),t.modelReasoningEffort!==s.modelReasoningEffort&&(r.modelReasoningEffort=t.modelReasoningEffort),t.modelContextWindow!==s.modelContextWindow&&(r.modelContextWindow=t.modelContextWindow),t.modelAutoCompactTokenLimit!==s.modelAutoCompactTokenLimit&&(r.modelAutoCompactTokenLimit=t.modelAutoCompactTokenLimit),t.modelProvider!==s.modelProvider&&(r.modelProvider=t.modelProvider),t.approvalPolicy!==s.approvalPolicy&&(r.approvalPolicy=t.approvalPolicy),t.sandboxMode!==s.sandboxMode&&(r.sandboxMode=t.sandboxMode),t.webSearch!==s.webSearch&&(r.webSearch=t.webSearch),t.toolOutputTokenLimit!==s.toolOutputTokenLimit&&(r.toolOutputTokenLimit=t.toolOutputTokenLimit),t.personality!==s.personality&&(r.personality=t.personality),r}function nt({initialValues:s,providerNames:t,disabled:r,saving:a,onSave:o}){const{t:n}=T(),[l,c]=N.useState(s),i=Q(["minimal","low","medium","high","xhigh"],l.modelReasoningEffort),d=Q(t,l.modelProvider),m=Q(["on-request","never","untrusted"],l.approvalPolicy),h=Q(["read-only","workspace-write","danger-full-access"],l.sandboxMode),x=Q(["cached","live","disabled"],l.webSearch),g=Q(["none","friendly","pragmatic"],l.personality),p=rt(s,l),w=Object.keys(p).length>0,M=tt(l.model),q=u=>{const v=u.trim();return v.length>0?Number(v):null};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.model")}),e.jsx(_,{value:l.model??"",onChange:u=>c(v=>({...v,model:u.target.value||null})),placeholder:"gpt-5.5",disabled:r})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.reasoningEffort")}),e.jsxs(E,{value:Y(l.modelReasoningEffort),onValueChange:u=>c(v=>({...v,modelReasoningEffort:u===A?null:u})),disabled:r,children:[e.jsx(D,{children:e.jsx(O,{placeholder:n("codex.useDefault")})}),e.jsxs(L,{children:[e.jsx(b,{value:A,children:n("codex.useDefault")}),i.map(u=>e.jsx(b,{value:u,children:u},u))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.defaultProvider")}),e.jsxs(E,{value:Y(l.modelProvider),onValueChange:u=>c(v=>({...v,modelProvider:u===A?null:u})),disabled:r,children:[e.jsx(D,{children:e.jsx(O,{placeholder:n("codex.useCodexDefault")})}),e.jsxs(L,{children:[e.jsx(b,{value:A,children:n("codex.useCodexDefault")}),d.map(u=>e.jsx(b,{value:u,children:u},u))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.approvalPolicy")}),e.jsxs(E,{value:Y(l.approvalPolicy),onValueChange:u=>c(v=>({...v,approvalPolicy:u===A?null:u})),disabled:r,children:[e.jsx(D,{children:e.jsx(O,{placeholder:n("codex.useDefault")})}),e.jsxs(L,{children:[e.jsx(b,{value:A,children:n("codex.useDefault")}),m.map(u=>e.jsx(b,{value:u,children:u},u))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.sandboxMode")}),e.jsxs(E,{value:Y(l.sandboxMode),onValueChange:u=>c(v=>({...v,sandboxMode:u===A?null:u})),disabled:r,children:[e.jsx(D,{children:e.jsx(O,{placeholder:n("codex.useDefault")})}),e.jsxs(L,{children:[e.jsx(b,{value:A,children:n("codex.useDefault")}),h.map(u=>e.jsx(b,{value:u,children:u},u))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.webSearch")}),e.jsxs(E,{value:Y(l.webSearch),onValueChange:u=>c(v=>({...v,webSearch:u===A?null:u})),disabled:r,children:[e.jsx(D,{children:e.jsx(O,{placeholder:n("codex.useDefault")})}),e.jsxs(L,{children:[e.jsx(b,{value:A,children:n("codex.useDefault")}),x.map(u=>e.jsx(b,{value:u,children:u},u))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.toolOutputTokenLimit")}),e.jsx(_,{type:"number",min:1,value:l.toolOutputTokenLimit??"",onChange:u=>c(v=>({...v,toolOutputTokenLimit:u.target.value?Number(u.target.value):null})),placeholder:"25000",disabled:r})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.personality")}),e.jsxs(E,{value:Y(l.personality),onValueChange:u=>c(v=>({...v,personality:u===A?null:u})),disabled:r,children:[e.jsx(D,{children:e.jsx(O,{placeholder:n("codex.useDefault")})}),e.jsxs(L,{children:[e.jsx(b,{value:A,children:n("codex.useDefault")}),g.map(u=>e.jsx(b,{value:u,children:u},u))]})]})]})]}),e.jsxs("div",{className:"space-y-4 rounded-xl border border-amber-500/30 bg-amber-500/5 p-4 shadow-sm dark:bg-amber-400/5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(vs,{className:"h-4 w-4 text-amber-600 dark:text-amber-300"}),e.jsx("p",{className:"text-sm font-semibold",children:n("codex.longContextOverride")}),e.jsx(y,{variant:"outline",className:"border-amber-500/40 bg-background/80 text-[10px] uppercase tracking-[0.16em] text-amber-700 dark:text-amber-300",children:"Manual opt-in only"}),e.jsx(y,{variant:"secondary",className:"text-[10px] uppercase tracking-[0.16em] text-muted-foreground",children:M?"GPT-5.4 long-context selected":"GPT-5.4 long-context reference"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Draft values only. Nothing applies until Save."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(C,{type:"button",variant:"outline",size:"sm",disabled:r,onClick:()=>c(u=>({...u,modelContextWindow:Ee,modelAutoCompactTokenLimit:De})),children:"Fill cautious pair"}),e.jsx(C,{type:"button",variant:"outline",size:"sm",disabled:r,onClick:()=>c(u=>({...u,modelContextWindow:Zs})),children:"Set official max window"}),e.jsx(C,{type:"button",variant:"ghost",size:"sm",disabled:r,onClick:()=>c(u=>({...u,modelContextWindow:null,modelAutoCompactTokenLimit:null})),children:"Clear"})]})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Official max"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:"1.05M / 1M"}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:n("codex.gptContextCap")})]}),e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Standard window"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:pe(et)}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:n("codex.normalUsageWindow")})]}),e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Above 272K"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:n("codex.counts2x")}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:n("codex.usageLimitCost")})]})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border bg-background/75 px-3 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"One cautious pair"}),e.jsxs("div",{className:"rounded-full border bg-background px-2.5 py-1 font-mono text-[11px] font-medium",children:["Context ",pe(Ee)]}),e.jsxs("div",{className:"rounded-full border bg-background px-2.5 py-1 font-mono text-[11px] font-medium",children:["Auto-compact ",pe(De)]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(y,{variant:"outline",className:"border-border/70 bg-background/80 text-[10px] uppercase tracking-[0.14em] text-muted-foreground",children:"Not official"}),e.jsx(y,{variant:"outline",className:"border-border/70 bg-background/80 text-[10px] uppercase tracking-[0.14em] text-muted-foreground",children:"Draft only"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{children:n("codex.quickFillWarning")}),!M&&l.model?e.jsxs("span",{children:[e.jsx("code",{children:l.model})," should be checked separately."]}):null]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.modelContextWindow")}),e.jsx(_,{"aria-label":n("codex.modelContextWindow"),type:"number",min:1,value:l.modelContextWindow??"",onChange:u=>c(v=>({...v,modelContextWindow:q(u.target.value)})),placeholder:"Unset",disabled:r}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Writes ",e.jsx("code",{children:"model_context_window"}),". Leave unset to keep Codex defaults."]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.autoCompactTokenLimit")}),e.jsx(_,{"aria-label":n("codex.autoCompactTokenLimit"),type:"number",min:1,value:l.modelAutoCompactTokenLimit??"",onChange:u=>c(v=>({...v,modelAutoCompactTokenLimit:q(u.target.value)})),placeholder:"Unset",disabled:r}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Writes ",e.jsx("code",{children:"model_auto_compact_token_limit"}),". Leave unset to keep model defaults."]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-[0.14em]",children:"Docs"}),e.jsx("a",{href:"https://platform.openai.com/docs/models",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"GPT-5 model guide"}),e.jsx("a",{href:"https://openai.com/index/introducing-gpt-5-5/",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"Release notes"}),e.jsx("a",{href:"https://developers.openai.com/codex/config-reference",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"Config reference"})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(C,{onClick:()=>o(p),disabled:r||a||!w,children:[a?e.jsx(G,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save top-level settings"]})})]})}function at({values:s,providerNames:t,disabled:r=!1,disabledReason:a,saving:o=!1,onSave:n}){return e.jsx(se,{title:"Top-level controls",badge:"config.toml",icon:e.jsx(gs,{className:"h-4 w-4"}),description:"Structured controls for the stable top-level Codex settings users touch most often. Unsupported upstream shapes stay untouched and should be edited in raw TOML.",disabledReason:a,children:e.jsx(nt,{initialValues:s,providerNames:t,disabled:r,saving:o,onSave:n},JSON.stringify(s))})}function ot({workspacePath:s,activeProfile:t,topLevelSettings:r,projectTrustEntries:a,profileEntries:o,modelProviderEntries:n,mcpServerEntries:l,featureCatalog:c,featureState:i,disabled:d,disabledReason:m,saving:h,onPatch:x}){const{t:g}=T();return e.jsx(we,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 pr-1 pb-6",children:[e.jsxs("div",{className:"group relative overflow-hidden rounded-xl border border-border/80 bg-background/50 p-5 shadow-sm transition-all hover:bg-background hover:shadow-md dark:border-border/60",children:[e.jsx("div",{className:"absolute inset-x-0 -top-px h-px bg-gradient-to-r from-transparent via-foreground/15 to-transparent transition-opacity group-hover:via-foreground/30"}),e.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary transition-colors group-hover:border-primary/30",children:e.jsx(bs,{className:"h-4 w-4"})}),e.jsx("div",{children:e.jsx("h2",{className:"text-base font-semibold tracking-tight text-foreground",children:g("codex.controlCenter")})})]}),e.jsxs("ul",{className:"grid gap-3 sm:grid-cols-2 text-sm text-muted-foreground",children:[e.jsxs("li",{className:"flex items-start gap-2.5",children:[e.jsx(ws,{className:"h-4 w-4 shrink-0 text-muted-foreground/60 mt-0.5"}),e.jsxs("span",{className:"leading-relaxed",children:["Writes exclusively to user-layer"," ",e.jsx("code",{className:"text-[11px] bg-muted/70 px-1.5 py-0.5 rounded border border-border/50",children:"config.toml"})]})]}),e.jsxs("li",{className:"flex items-start gap-2.5",children:[e.jsx(Ns,{className:"h-4 w-4 shrink-0 text-muted-foreground/60 mt-0.5"}),e.jsx("span",{className:"leading-relaxed",children:"Does not reflect repo trust layers or CLI overrides"})]})]})]}),e.jsx("div",{className:"shrink-0 lg:w-[280px]",children:e.jsx("div",{className:"relative overflow-hidden rounded-lg border border-amber-500/20 bg-amber-500/5 p-4 transition-colors group-hover:border-amber-500/30 group-hover:bg-amber-500/10 dark:border-amber-400/10 dark:bg-amber-400/5",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ys,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-bold text-amber-700 dark:text-amber-300 uppercase tracking-wider",children:"Formatting Note"}),e.jsx("p",{className:"text-[13px] leading-relaxed text-amber-800/80 dark:text-amber-200/70",children:"Saves normalize TOML formatting and strip comments. Switch to the raw editor if exact layout matters."})]})]})})})]})]}),e.jsx(at,{values:r,providerNames:n.map(p=>p.name),disabled:d,disabledReason:m,saving:h,onSave:p=>x({kind:"top-level",values:p},g("toasts.codexSaved"))}),e.jsx(Js,{workspacePath:s,entries:a,disabled:d,disabledReason:m,saving:h,onSave:(p,w)=>x({kind:"project-trust",path:p,trustLevel:w},w?"Saved project trust entry.":"Removed project trust entry.")}),e.jsx(Ys,{activeProfile:t,entries:o,providerNames:n.map(p=>p.name),disabled:d,disabledReason:m,saving:h,onSave:(p,w,M)=>x({kind:"profile",action:"upsert",name:p,values:w,setAsActive:M},"Saved profile."),onDelete:p=>x({kind:"profile",action:"delete",name:p},"Deleted profile."),onSetActive:p=>x({kind:"profile",action:"set-active",name:p},"Set active profile.")}),e.jsx(Xs,{entries:n,disabled:d,disabledReason:m,saving:h,onSave:(p,w)=>x({kind:"model-provider",action:"upsert",name:p,values:w},"Saved model provider."),onDelete:p=>x({kind:"model-provider",action:"delete",name:p},"Deleted model provider.")}),e.jsx(Vs,{entries:l,disabled:d,disabledReason:m,saving:h,onSave:(p,w)=>x({kind:"mcp-server",action:"upsert",name:p,values:w},"Saved MCP server."),onDelete:p=>x({kind:"mcp-server",action:"delete",name:p},"Deleted MCP server.")}),e.jsx(qs,{catalog:c,state:i,disabled:d,disabledReason:m,onToggle:(p,w)=>x({kind:"feature",feature:p,enabled:w},"Saved feature toggle.")})]})})}const We=`model_provider = "cliproxy"
2
-
3
- [model_providers.cliproxy]
4
- name = "CLIProxy Codex"
5
- base_url = "http://127.0.0.1:8317/api/provider/codex"
6
- env_key = "CLIPROXY_API_KEY"
7
- wire_api = "responses"
8
- requires_openai_auth = false
9
- supports_websockets = false`,lt=["multi_agent","unified_exec","shell_snapshot","apply_patch_freeform","js_repl","runtime_metrics","prevent_idle_sleep","fast_mode","apps","smart_approvals"];function it(){return[{name:"multi_agent",label:S.t("codex.featureMultiAgentLabel"),description:S.t("codex.featureMultiAgentDesc")},{name:"unified_exec",label:S.t("codex.featureUnifiedExecLabel"),description:S.t("codex.featureUnifiedExecDesc")},{name:"shell_snapshot",label:S.t("codex.featureShellSnapshotLabel"),description:S.t("codex.featureShellSnapshotDesc")},{name:"apply_patch_freeform",label:S.t("codex.featureApplyPatchLabel"),description:S.t("codex.featureApplyPatchDesc")},{name:"js_repl",label:S.t("codex.featureJsReplLabel"),description:S.t("codex.featureJsReplDesc")},{name:"runtime_metrics",label:S.t("codex.featureRuntimeMetricsLabel"),description:S.t("codex.featureRuntimeMetricsDesc")},{name:"prevent_idle_sleep",label:S.t("codex.featurePreventIdleSleepLabel"),description:S.t("codex.featurePreventIdleSleepDesc")},{name:"fast_mode",label:S.t("codex.featureFastModeLabel"),description:S.t("codex.featureFastModeDesc")},{name:"apps",label:S.t("codex.featureAppsLabel"),description:S.t("codex.featureAppsDesc")},{name:"smart_approvals",label:S.t("codex.featureSmartApprovalsLabel"),description:S.t("codex.featureSmartApprovalsDesc")}]}function z(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)?s:null}function P(s){return typeof s=="string"&&s.trim().length>0?s.trim():null}function Z(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function fe(s){return Array.isArray(s)?s.filter(t=>typeof t=="string").map(t=>t.trim()):[]}function qe(s){return{model:P(s?.model),modelReasoningEffort:P(s?.model_reasoning_effort),modelContextWindow:Z(s?.model_context_window),modelAutoCompactTokenLimit:Z(s?.model_auto_compact_token_limit),modelProvider:P(s?.model_provider),approvalPolicy:P(s?.approval_policy),sandboxMode:P(s?.sandbox_mode),webSearch:P(s?.web_search),toolOutputTokenLimit:Z(s?.tool_output_token_limit),personality:P(s?.personality)}}function ct(s){const t=z(s?.projects);return t?Object.entries(t).map(([r,a])=>{const o=P(z(a)?.trust_level);return o?{path:r,trustLevel:o}:null}).filter(r=>r!==null).sort((r,a)=>r.path.localeCompare(a.path)):[]}function dt(s){const t=z(s?.profiles);return t?Object.entries(t).map(([r,a])=>({name:r,values:qe(z(a))})).sort((r,a)=>r.name.localeCompare(a.name)):[]}function xt(s){const t=z(s?.model_providers);return t?Object.entries(t).map(([r,a])=>{const o=z(a);return o?{name:r,displayName:P(o.name),baseUrl:P(o.base_url),envKey:P(o.env_key),wireApi:P(o.wire_api),requiresOpenaiAuth:o.requires_openai_auth===!0,supportsWebsockets:o.supports_websockets===!0}:null}).filter(r=>r!==null).sort((r,a)=>r.name.localeCompare(a.name)):[]}function ut(s){const t=z(s?.mcp_servers);return t?Object.entries(t).map(([r,a])=>{const o=z(a);if(!o)return null;const n=P(o.command)?"stdio":"streamable-http",l=Z(o.startup_timeout_ms);return{name:r,transport:n,command:P(o.command),args:fe(o.args),url:P(o.url),enabled:o.enabled!==!1,required:o.required===!0,startupTimeoutSec:Z(o.startup_timeout_sec)??(l!==null?l/1e3:null),toolTimeoutSec:Z(o.tool_timeout_sec),enabledTools:fe(o.enabled_tools),disabledTools:fe(o.disabled_tools),isCcsManaged:r==="ccs_browser",managementSurface:r==="ccs_browser"?"browser-settings":null}}).filter(r=>r!==null).sort((r,a)=>r.name.localeCompare(a.name)):[]}function mt(s){const t=z(s?.features),r={};for(const a of lt){const o=t?.[a];r[a]=typeof o=="boolean"?o:null}if(t)for(const[a,o]of Object.entries(t))a in r||(r[a]=typeof o=="boolean"?o:null);return r}const ht=[{id:"codex-config-basic",label:"Codex Config Basics",url:"https://developers.openai.com/codex/config-basic",description:"Official user-layer setup, config location, and baseline configuration behavior."},{id:"codex-config-advanced",label:"Codex Config Advanced",url:"https://developers.openai.com/codex/config-advanced",description:"Layering, trust, profiles, and advanced config behavior."},{id:"codex-config-reference",label:"Codex Config Reference",url:"https://developers.openai.com/codex/config-reference",description:"Canonical upstream config surface for providers, MCP, features, and trust."},{id:"codex-releases",label:"Codex GitHub Releases",url:"https://github.com/openai/codex/releases",description:"Track upstream release notes and fast-moving CLI changes."}],pt=[{provider:"openai",label:"OpenAI Responses API",apiFormat:"Responses API",url:"https://platform.openai.com/docs/api-reference/responses"}];function ft(s){const t=/https?:\/\/[^\s)]+/g,r=[];let a=0,o;for(;(o=t.exec(s))!==null;){const[n]=o,l=o.index;l>a&&r.push(s.slice(a,l)),r.push(e.jsx("a",{href:n,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:n},`${n}-${l}`)),a=l+n.length}return a<s.length&&r.push(s.slice(a)),r.length>0?r:[s]}function jt({diagnostics:s}){const{t}=T(),r=s.docsReference??{notes:[],links:[],providerDocs:[],providerValues:[],settingsHierarchy:[]},a=r.links.length>0?r.links:ht,o=r.providerDocs.length>0?r.providerDocs:pt;return e.jsx(we,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(K,{className:"flex items-center gap-2 text-base",children:[e.jsx(ge,{className:"h-4 w-4"}),"CCS bridge recipe"]})}),e.jsxs(W,{className:"space-y-3 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{children:[e.jsx("strong",{children:t("codex.builtInLabel")})," ",t("codex.builtInCcsxpDesc")]}),e.jsxs("p",{children:[e.jsx("strong",{children:t("codex.nativeRecipeLabel")})," ",t("codex.nativeRecipeDesc")]}),e.jsxs("p",{children:[e.jsx("strong",{children:t("codex.managedBridgeLabel")})," ",t("codex.managedBridgeDesc")]})]}),e.jsx("pre",{className:"overflow-x-auto rounded-md border bg-muted/20 p-3 text-xs text-foreground",children:We}),e.jsxs("ol",{className:"ml-4 list-decimal space-y-1.5 [&>li]:pl-1",children:[e.jsxs("li",{children:["Save the ",e.jsx("code",{children:"cliproxy"})," provider in your user config."]}),e.jsxs("li",{children:["Set top-level ",e.jsx("code",{children:"model_provider"})," to ",e.jsx("code",{children:"cliproxy"}),"."]}),e.jsxs("li",{children:["Export ",e.jsx("code",{children:"CLIPROXY_API_KEY"})," before launching native Codex."]})]}),e.jsxs("p",{children:["CCS-managed browser tooling belongs to ",e.jsx("code",{children:"Settings > Browser"}),". Do not edit the ",e.jsx("code",{children:"ccs_browser"})," entry from the generic MCP card unless you are intentionally overriding the managed path in raw TOML."]})]})]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(K,{className:"flex items-center gap-2 text-base",children:[e.jsx(ge,{className:"h-4 w-4"}),"Upstream notes"]})}),e.jsxs(W,{className:"space-y-2 text-sm",children:[r.notes.length>0&&e.jsx("ul",{className:"ml-4 list-disc space-y-1.5 text-muted-foreground [&>li]:pl-1",children:r.notes.map((n,l)=>e.jsx("li",{children:ft(n)},`${l}-${n}`))}),e.jsx(ie,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:t("codex.codexDocs")}),e.jsx("div",{className:"space-y-1.5",children:a.map(n=>e.jsxs("a",{href:n.url,target:"_blank",rel:"noreferrer",className:"block rounded-md border px-2.5 py-2 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-medium",children:n.label}),e.jsx(Te,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:n.description}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground/90 underline underline-offset-2",children:n.url})]},n.id))})]}),e.jsx(ie,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Provider / bridge reference"}),e.jsx("div",{className:"space-y-1.5",children:o.map(n=>e.jsxs("a",{href:n.url,target:"_blank",rel:"noreferrer",className:"block rounded-md border px-2.5 py-2 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-medium",children:n.label}),e.jsx(Te,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.jsxs("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:["provider: ",n.provider," | format: ",n.apiFormat]}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground/90 underline underline-offset-2",children:n.url})]},`${n.provider}-${n.url}`))})]}),r.providerValues.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(ie,{}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Provider values: ",r.providerValues.join(", ")]})]}),r.settingsHierarchy.length>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Settings hierarchy: ",r.settingsHierarchy.join(" -> ")]})]})]})]})})}function gt(s,t){let r=s.slice(0,t).split(/\r\n|\n|\r/g);return[r.length,r.pop().length+1]}function vt(s,t,r){let a=s.split(/\r\n|\n|\r/g),o="",n=(Math.log10(t+1)|0)+1;for(let l=t-1;l<=t+1;l++){let c=a[l-1];c&&(o+=l.toString().padEnd(n," "),o+=": ",o+=c,o+=`
10
- `,l===t&&(o+=" ".repeat(n+r+2),o+=`^
11
- `))}return o}class f extends Error{line;column;codeblock;constructor(t,r){const[a,o]=gt(r.toml,r.ptr),n=vt(r.toml,a,o);super(`Invalid TOML document: ${t}
12
-
13
- ${n}`,r),this.line=a,this.column=o,this.codeblock=n}}function bt(s,t){let r=0;for(;s[t-++r]==="\\";);return--r&&r%2}function ve(s,t=0,r=s.length){let a=s.indexOf(`
14
- `,t);return s[a-1]==="\r"&&a--,a<=r?a:-1}function xe(s,t){for(let r=t;r<s.length;r++){let a=s[r];if(a===`
15
- `)return r;if(a==="\r"&&s[r+1]===`
16
- `)return r+1;if(a<" "&&a!==" "||a==="")throw new f("control characters are not allowed in comments",{toml:s,ptr:t})}return s.length}function $(s,t,r,a){let o;for(;;){for(;(o=s[t])===" "||o===" "||!r&&(o===`
17
- `||o==="\r"&&s[t+1]===`
18
- `);)t++;if(a||o!=="#")break;t=xe(s,t)}return t}function wt(s,t,r,a,o=!1){if(!a)return t=ve(s,t),t<0?s.length:t;for(let n=t;n<s.length;n++){let l=s[n];if(l==="#")n=ve(s,n);else{if(l===r)return n+1;if(l===a||o&&(l===`
19
- `||l==="\r"&&s[n+1]===`
20
- `))return n}}throw new f("cannot find end of structure",{toml:s,ptr:t})}function Ue(s,t){let r=s[t],a=r===s[t+1]&&s[t+1]===s[t+2]?s.slice(t,t+3):r;t+=a.length-1;do t=s.indexOf(a,++t);while(t>-1&&r!=="'"&&bt(s,t));return t>-1&&(t+=a.length,a.length>1&&(s[t]===r&&t++,s[t]===r&&t++)),t}let Nt=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;class J extends Date{#s=!1;#t=!1;#e=null;constructor(t){let r=!0,a=!0,o="Z";if(typeof t=="string"){let n=t.match(Nt);n?(n[1]||(r=!1,t=`0000-01-01T${t}`),a=!!n[2],a&&t[10]===" "&&(t=t.replace(" ","T")),n[2]&&+n[2]>23?t="":(o=n[3]||null,t=t.toUpperCase(),!o&&a&&(t+="Z"))):t=""}super(t),isNaN(this.getTime())||(this.#s=r,this.#t=a,this.#e=o)}isDateTime(){return this.#s&&this.#t}isLocal(){return!this.#s||!this.#t||!this.#e}isDate(){return this.#s&&!this.#t}isTime(){return this.#t&&!this.#s}isValid(){return this.#s||this.#t}toISOString(){let t=super.toISOString();if(this.isDate())return t.slice(0,10);if(this.isTime())return t.slice(11,23);if(this.#e===null)return t.slice(0,-1);if(this.#e==="Z")return t;let r=+this.#e.slice(1,3)*60+ +this.#e.slice(4,6);return r=this.#e[0]==="-"?r:-r,new Date(this.getTime()-r*6e4).toISOString().slice(0,-1)+this.#e}static wrapAsOffsetDateTime(t,r="Z"){let a=new J(t);return a.#e=r,a}static wrapAsLocalDateTime(t){let r=new J(t);return r.#e=null,r}static wrapAsLocalDate(t){let r=new J(t);return r.#t=!1,r.#e=null,r}static wrapAsLocalTime(t){let r=new J(t);return r.#s=!1,r.#e=null,r}}let yt=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,Ct=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,St=/^[+-]?0[0-9_]/,_t=/^[0-9a-f]{2,8}$/i,Oe={b:"\b",t:" ",n:`
21
- `,f:"\f",r:"\r",e:"\x1B",'"':'"',"\\":"\\"};function Be(s,t=0,r=s.length){let a=s[t]==="'",o=s[t++]===s[t]&&s[t]===s[t+1];o&&(r-=2,s[t+=2]==="\r"&&t++,s[t]===`
22
- `&&t++);let n=0,l,c="",i=t;for(;t<r-1;){let d=s[t++];if(d===`
23
- `||d==="\r"&&s[t]===`
24
- `){if(!o)throw new f("newlines are not allowed in strings",{toml:s,ptr:t-1})}else if(d<" "&&d!==" "||d==="")throw new f("control characters are not allowed in strings",{toml:s,ptr:t-1});if(l){if(l=!1,d==="x"||d==="u"||d==="U"){let m=s.slice(t,t+=d==="x"?2:d==="u"?4:8);if(!_t.test(m))throw new f("invalid unicode escape",{toml:s,ptr:n});try{c+=String.fromCodePoint(parseInt(m,16))}catch{throw new f("invalid unicode escape",{toml:s,ptr:n})}}else if(o&&(d===`
25
- `||d===" "||d===" "||d==="\r")){if(t=$(s,t-1,!0),s[t]!==`
26
- `&&s[t]!=="\r")throw new f("invalid escape: only line-ending whitespace may be escaped",{toml:s,ptr:n});t=$(s,t)}else if(d in Oe)c+=Oe[d];else throw new f("unrecognized escape sequence",{toml:s,ptr:n});i=t}else!a&&d==="\\"&&(n=t-1,l=!0,c+=s.slice(i,n))}return c+s.slice(i,r-1)}function Tt(s,t,r,a){if(s==="true")return!0;if(s==="false")return!1;if(s==="-inf")return-1/0;if(s==="inf"||s==="+inf")return 1/0;if(s==="nan"||s==="+nan"||s==="-nan")return NaN;if(s==="-0")return a?0n:0;let o=yt.test(s);if(o||Ct.test(s)){if(St.test(s))throw new f("leading zeroes are not allowed",{toml:t,ptr:r});s=s.replace(/_/g,"");let l=+s;if(isNaN(l))throw new f("invalid number",{toml:t,ptr:r});if(o){if((o=!Number.isSafeInteger(l))&&!a)throw new f("integer value cannot be represented losslessly",{toml:t,ptr:r});(o||a===!0)&&(l=BigInt(s))}return l}const n=new J(s);if(!n.isValid())throw new f("invalid value",{toml:t,ptr:r});return n}function kt(s,t,r){let a=s.slice(t,r),o=a.indexOf("#");return o>-1&&(xe(s,o),a=a.slice(0,o)),[a.trimEnd(),o]}function Ne(s,t,r,a,o){if(a===0)throw new f("document contains excessively nested structures. aborting.",{toml:s,ptr:t});let n=s[t];if(n==="["||n==="{"){let[i,d]=n==="["?Dt(s,t,a,o):Et(s,t,a,o);if(r){if(d=$(s,d),s[d]===",")d++;else if(s[d]!==r)throw new f("expected comma or end of structure",{toml:s,ptr:d})}return[i,d]}let l;if(n==='"'||n==="'"){l=Ue(s,t);let i=Be(s,t,l);if(r){if(l=$(s,l),s[l]&&s[l]!==","&&s[l]!==r&&s[l]!==`
27
- `&&s[l]!=="\r")throw new f("unexpected character encountered",{toml:s,ptr:l});l+=+(s[l]===",")}return[i,l]}l=wt(s,t,",",r);let c=kt(s,t,l-+(s[l-1]===","));if(!c[0])throw new f("incomplete key-value declaration: no value specified",{toml:s,ptr:t});return r&&c[1]>-1&&(l=$(s,t+c[1]),l+=+(s[l]===",")),[Tt(c[0],s,t,o),l]}let Pt=/^[a-zA-Z0-9-_]+[ \t]*$/;function be(s,t,r="="){let a=t-1,o=[],n=s.indexOf(r,t);if(n<0)throw new f("incomplete key-value: cannot find end of key",{toml:s,ptr:t});do{let l=s[t=++a];if(l!==" "&&l!==" ")if(l==='"'||l==="'"){if(l===s[t+1]&&l===s[t+2])throw new f("multiline strings are not allowed in keys",{toml:s,ptr:t});let c=Ue(s,t);if(c<0)throw new f("unfinished string encountered",{toml:s,ptr:t});a=s.indexOf(".",c);let i=s.slice(c,a<0||a>n?n:a),d=ve(i);if(d>-1)throw new f("newlines are not allowed in keys",{toml:s,ptr:t+a+d});if(i.trimStart())throw new f("found extra tokens after the string part",{toml:s,ptr:c});if(n<c&&(n=s.indexOf(r,c),n<0))throw new f("incomplete key-value: cannot find end of key",{toml:s,ptr:t});o.push(Be(s,t,c))}else{a=s.indexOf(".",t);let c=s.slice(t,a<0||a>n?n:a);if(!Pt.test(c))throw new f("only letter, numbers, dashes and underscores are allowed in keys",{toml:s,ptr:t});o.push(c.trimEnd())}}while(a+1&&a<n);return[o,$(s,n+1,!0,!0)]}function Et(s,t,r,a){let o={},n=new Set,l;for(t++;(l=s[t++])!=="}"&&l;){if(l===",")throw new f("expected value, found comma",{toml:s,ptr:t-1});if(l==="#")t=xe(s,t);else if(l!==" "&&l!==" "&&l!==`
28
- `&&l!=="\r"){let c,i=o,d=!1,[m,h]=be(s,t-1);for(let p=0;p<m.length;p++){if(p&&(i=d?i[c]:i[c]={}),c=m[p],(d=Object.hasOwn(i,c))&&(typeof i[c]!="object"||n.has(i[c])))throw new f("trying to redefine an already defined value",{toml:s,ptr:t});!d&&c==="__proto__"&&Object.defineProperty(i,c,{enumerable:!0,configurable:!0,writable:!0})}if(d)throw new f("trying to redefine an already defined value",{toml:s,ptr:t});let[x,g]=Ne(s,h,"}",r-1,a);n.add(x),i[c]=x,t=g}}if(!l)throw new f("unfinished table encountered",{toml:s,ptr:t});return[o,t]}function Dt(s,t,r,a){let o=[],n;for(t++;(n=s[t++])!=="]"&&n;){if(n===",")throw new f("expected value, found comma",{toml:s,ptr:t-1});if(n==="#")t=xe(s,t);else if(n!==" "&&n!==" "&&n!==`
29
- `&&n!=="\r"){let l=Ne(s,t-1,"]",r-1,a);o.push(l[0]),t=l[1]}}if(!n)throw new f("unfinished array encountered",{toml:s,ptr:t});return[o,t]}function Le(s,t,r,a){let o=t,n=r,l,c=!1,i;for(let d=0;d<s.length;d++){if(d){if(o=c?o[l]:o[l]={},n=(i=n[l]).c,a===0&&(i.t===1||i.t===2))return null;if(i.t===2){let m=o.length-1;o=o[m],n=n[m].c}}if(l=s[d],(c=Object.hasOwn(o,l))&&n[l]?.t===0&&n[l]?.d)return null;c||(l==="__proto__"&&(Object.defineProperty(o,l,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(n,l,{enumerable:!0,configurable:!0,writable:!0})),n[l]={t:d<s.length-1&&a===2?3:a,d:!1,i:0,c:{}})}if(i=n[l],i.t!==a&&!(a===1&&i.t===3)||(a===2&&(i.d||(i.d=!0,o[l]=[]),o[l].push(o={}),i.c[i.i++]=i={t:1,d:!1,i:0,c:{}}),i.d))return null;if(i.d=!0,a===1)o=c?o[l]:o[l]={};else if(a===0&&c)return null;return[l,o,i.c]}function Ot(s,{maxDepth:t=1e3,integersAsBigInt:r}={}){let a={},o={},n=a,l=o;for(let c=$(s,0);c<s.length;){if(s[c]==="["){let i=s[++c]==="[",d=be(s,c+=+i,"]");if(i){if(s[d[1]-1]!=="]")throw new f("expected end of table declaration",{toml:s,ptr:d[1]-1});d[1]++}let m=Le(d[0],a,o,i?2:1);if(!m)throw new f("trying to redefine an already defined table or value",{toml:s,ptr:c});l=m[2],n=m[1],c=d[1]}else{let i=be(s,c),d=Le(i[0],n,l,0);if(!d)throw new f("trying to redefine an already defined table or value",{toml:s,ptr:c});let m=Ne(s,i[1],void 0,t,r);d[1][d[0]]=m[0],c=m[1]}if(c=$(s,c,!0),s[c]&&s[c]!==`
30
- `&&s[c]!=="\r")throw new f("each key-value declaration must be followed by an end-of-line",{toml:s,ptr:c});c=$(s,c)}return a}function Lt(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function At(s){return s.charCodeAt(0)===65279?s.slice(1):s}function Mt(s){const t=At(s);if(!t.trim())return{};const a=Ot(t);if(!Lt(a))throw new Error("TOML root must be a table.");return a}function Ve(s){try{return{config:Mt(s),parseError:null}}catch(t){return{config:null,parseError:t.message}}}async function Rt(){const s=await fetch(ne("/codex/diagnostics"));if(!s.ok)throw new Error("Failed to fetch Codex diagnostics");return s.json()}async function It(){const s=await fetch(ne("/codex/config/raw"));if(!s.ok)throw new Error("Failed to fetch Codex raw config");return s.json()}async function Ft(s){const t=await fetch(ne("/codex/config/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(t.status===409)throw new Ae("Codex raw config changed externally");if(!t.ok){const r=await t.json().catch(()=>null);throw new Error(r?.error||"Failed to save Codex raw config")}return t.json()}async function Kt(s){const t=await fetch(ne("/codex/config/patch"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(t.status===409)throw new Ae("Codex config changed externally");if(!t.ok){const r=await t.json().catch(()=>null);throw new Error(r?.error||"Failed to patch Codex config")}return t.json()}function Wt(){const s=us(),t=je({queryKey:["codex-diagnostics"],queryFn:Rt,refetchInterval:1e4}),r=je({queryKey:["codex-raw-config"],queryFn:It}),a=_e({mutationFn:Ft,onSuccess:(n,l)=>{s.setQueryData(["codex-raw-config"],c=>{const i=c?.path??"$CODEX_HOME/config.toml",d=c?.resolvedPath??i,m=Ve(l.rawText);return{path:i,resolvedPath:d,exists:!0,mtime:n.mtime,rawText:l.rawText,config:m.config,parseError:m.parseError,readError:null}}),s.invalidateQueries({queryKey:["codex-diagnostics"]})}}),o=_e({mutationFn:Kt,onSuccess:n=>{s.setQueryData(["codex-raw-config"],n),s.invalidateQueries({queryKey:["codex-diagnostics"]})}});return N.useMemo(()=>({diagnostics:t.data,diagnosticsLoading:t.isLoading,diagnosticsError:t.error,refetchDiagnostics:t.refetch,rawConfig:r.data,rawConfigLoading:r.isLoading,rawConfigError:r.error,refetchRawConfig:r.refetch,saveRawConfig:a.mutate,saveRawConfigAsync:a.mutateAsync,isSavingRawConfig:a.isPending,patchConfig:o.mutate,patchConfigAsync:o.mutateAsync,isPatchingConfig:o.isPending}),[t.data,t.isLoading,t.error,t.refetch,r.data,r.isLoading,r.error,r.refetch,a.mutate,a.mutateAsync,a.isPending,o.mutate,o.mutateAsync,o.isPending])}const qt=[{label:"Start Default",command:"ccs",description:"Launch Claude with default profile"},{label:"GLM Profile",command:"ccs glm",description:"Switch to GLM model"},{label:"Health Check",command:"ccs doctor",description:"Run system diagnostics"},{label:"Delegate Task",command:'ccs glm -p "your task"',description:"Delegate to GLM profile"}];function Ut({snippets:s=qt}){const[t,r]=N.useState(null),{t:a}=T(),o=async(n,l)=>{await navigator.clipboard.writeText(n),r(l),setTimeout(()=>r(null),2e3)};return e.jsxs(I,{children:[e.jsx(F,{className:"pb-3",children:e.jsxs(K,{className:"text-lg flex items-center gap-2",children:[e.jsx(Cs,{className:"w-5 h-5 text-muted-foreground"}),a("quickCommands.title")]})}),e.jsx(W,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:s.map((n,l)=>e.jsxs("div",{className:Me("group flex items-center justify-between gap-2 px-3 py-2","rounded-lg border bg-muted/30 hover:bg-muted/50 transition-colors"),children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:n.label}),e.jsx("code",{className:"text-sm font-mono font-medium truncate block",children:n.command})]}),e.jsx(C,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>o(n.command,l),title:n.description,children:t===l?e.jsx(Ss,{className:"h-4 w-4 text-green-600"}):e.jsx(_s,{className:"h-4 w-4"})})]},l))})})]})}function Bt(s){return!s||!Number.isFinite(s)?"N/A":new Date(s).toLocaleString()}function Vt(s){return!s||s<=0?"0 B":s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(2)} MB`}function k({label:s,value:t,mono:r=!1}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 text-sm",children:[e.jsx("span",{className:"text-muted-foreground shrink-0",children:s}),e.jsx("span",{className:Me("text-right break-all",r&&"font-mono text-xs"),children:t})]})}function $t({diagnostics:s}){const{t}=T(),r=s.config.activeProfile?`codex --profile ${s.config.activeProfile}`:"codex",a=s.binary.supportsConfigOverrides;return e.jsx(we,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(K,{className:"flex items-center gap-2 text-base",children:[e.jsx(Ts,{className:"h-4 w-4"}),t("codex.howCodexWorks")]})}),e.jsx(W,{className:"text-sm text-muted-foreground",children:e.jsxs("ul",{className:"ml-4 list-disc space-y-1.5 [&>li]:pl-1",children:[e.jsx("li",{children:t("codex.nativeDesc")}),e.jsxs("li",{children:[e.jsx("strong",{children:t("codex.nativeConfigLabel")})," ",t("codex.nativeConfigDesc")]}),e.jsxs("li",{children:[e.jsx("strong",{children:t("codex.transientOverridesLabel")})," ",t("codex.transientOverridesDesc")]}),e.jsxs("li",{children:[e.jsx("strong",{children:t("codex.cliproxyDefaultLabel")})," ",t("codex.cliproxyDefaultDesc")]}),e.jsx("li",{children:t("codex.apiProfilesDefault")})]})})]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(K,{className:"flex items-center gap-2 text-base",children:[e.jsx(ks,{className:"h-4 w-4"}),t("codex.runtimeInstall")]})}),e.jsxs(W,{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:t("codex.status")}),e.jsx(y,{variant:s.binary.installed?"default":"secondary",children:s.binary.installed?t("codex.detected"):t("codex.notFound")})]}),e.jsx(k,{label:t("codex.detectionSource"),value:s.binary.source,mono:!0}),e.jsx(k,{label:t("codex.binaryPath"),value:s.binary.path||t("codex.notFound"),mono:!0}),e.jsx(k,{label:t("codex.installDirectory"),value:s.binary.installDir||"N/A",mono:!0}),e.jsx(k,{label:t("codex.versionLabel"),value:s.binary.version||"Unknown",mono:!0}),e.jsx(k,{label:t("codex.nativeAliases"),value:"ccs-codex, ccsx",mono:!0}),e.jsx(k,{label:t("codex.ccsProviderShortcut"),value:"ccsxp",mono:!0}),e.jsxs("div",{className:"flex items-center justify-between rounded-md border px-3 py-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:t("codex.configOverrideSupport")}),e.jsx(y,{variant:s.binary.supportsConfigOverrides?"default":"secondary",children:s.binary.supportsConfigOverrides?t("codex.available"):t("codex.missing")})]})]})]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(K,{className:"flex items-center gap-2 text-base",children:[e.jsx(ke,{className:"h-4 w-4"}),t("codex.cliproxyNativeCodex")]})}),e.jsx(W,{className:"space-y-3 text-sm text-muted-foreground",children:a?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{children:e.jsx("strong",{children:t("codex.twoSupportedPaths")})}),e.jsxs("ul",{className:"ml-4 list-disc space-y-1 [&>li]:pl-1",children:[e.jsxs("li",{children:[e.jsx("strong",{children:t("codex.builtInLabel")})," ",t("codex.builtInCcsxpDesc")]}),e.jsxs("li",{children:[e.jsx("strong",{children:t("codex.nativeRecipeLabel")})," ",t("codex.nativeRecipeDesc")]})]})]}),e.jsxs("div",{className:"rounded-md border bg-muted/20 p-3",children:[e.jsx("p",{className:"font-medium text-foreground",children:t("codex.codexNativeRecipe")}),e.jsx("pre",{className:"mt-2 overflow-x-auto rounded-md bg-background p-3 text-xs text-foreground",children:We})]}),e.jsxs("ol",{className:"ml-4 list-decimal space-y-1.5 [&>li]:pl-1",children:[e.jsx("li",{children:t("codex.saveProviderNamedCliproxy")}),e.jsx("li",{children:t("codex.inTopLevelSetDefault")}),e.jsx("li",{children:t("codex.exportCliproxyApiKey")})]})]}):e.jsx("p",{children:t("codex.noConfigOverrides")})})]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(K,{className:"flex items-center gap-2 text-base",children:[e.jsx(Ps,{className:"h-4 w-4"}),t("codex.configFile")]})}),e.jsx(W,{className:"space-y-3",children:e.jsxs("div",{className:"rounded-md border p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:t("codex.userConfig")}),s.file.exists?e.jsx(Es,{className:"h-4 w-4 text-green-600"}):e.jsx(Ds,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(k,{label:t("codex.path"),value:s.file.path,mono:!0}),e.jsx(k,{label:t("codex.resolved"),value:s.file.resolvedPath,mono:!0}),e.jsx(k,{label:t("codex.size"),value:Vt(s.file.sizeBytes)}),e.jsx(k,{label:t("codex.lastModified"),value:Bt(s.file.mtimeMs)}),s.file.parseError&&e.jsxs("p",{className:"text-xs text-amber-600",children:[t("codex.tomlWarning"),": ",s.file.parseError]}),s.file.readError&&e.jsxs("p",{className:"text-xs text-destructive",children:[t("codex.readWarning"),": ",s.file.readError]})]})})]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(K,{className:"flex items-center gap-2 text-base",children:[e.jsx(ge,{className:"h-4 w-4"}),t("codex.currentUserLayerSummary")]})}),e.jsxs(W,{className:"space-y-3",children:[e.jsx(k,{label:t("codex.model"),value:s.config.model||t("codex.notSet"),mono:!0}),e.jsx(k,{label:t("codex.defaultProvider"),value:s.config.modelProvider||t("codex.notSet"),mono:!0}),e.jsx(k,{label:t("codex.activeProfile"),value:s.config.activeProfile||t("codex.notSet"),mono:!0}),e.jsx(k,{label:t("codex.approvalPolicy"),value:s.config.approvalPolicy||t("codex.notSet"),mono:!0}),e.jsx(k,{label:t("codex.sandboxMode"),value:s.config.sandboxMode||t("codex.notSet"),mono:!0}),e.jsx(k,{label:t("codex.webSearch"),value:s.config.webSearch||t("codex.notSet"),mono:!0}),e.jsx(ie,{}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsx(y,{variant:"outline",className:"justify-center",children:t("codex.providersCount",{count:s.config.modelProviderCount})}),e.jsx(y,{variant:"outline",className:"justify-center",children:t("codex.profilesCount",{count:s.config.profileCount})}),e.jsx(y,{variant:"outline",className:"justify-center",children:t("codex.enabledFeaturesCount",{count:s.config.enabledFeatures.length})}),e.jsx(y,{variant:"outline",className:"justify-center",children:t("codex.mcpServersCount",{count:s.config.mcpServerCount})})]}),s.config.topLevelKeys.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:t("codex.userLayerKeysPresent")}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.config.topLevelKeys.map(o=>e.jsx(y,{variant:"secondary",className:"font-mono text-[10px]",children:o},o))})]})]})]}),e.jsx(Ut,{snippets:[{label:t("codex.nativeShortAlias"),command:"ccsx",description:"Launch the short native Codex runtime alias."},{label:t("codex.ccsCodexShortcut"),command:'ccsxp "your prompt"',description:a?t("codex.runBuiltInCodex"):"Requires a Codex build that exposes --config overrides."},{label:t("codex.explicitProviderRoute"),command:'ccs codex --target codex "your prompt"',description:a?t("codex.runBuiltInCodexExplicit"):"Requires a Codex build that exposes --config overrides."},{label:s.config.activeProfile?"Inspect active profile":t("codex.openNativeCodex"),command:r,description:s.config.activeProfile?"Inspect the active named profile directly in native Codex.":"Open native Codex without forcing a named profile overlay."}]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(K,{className:"flex items-center gap-2 text-base",children:[e.jsx(ke,{className:"h-4 w-4"}),t("codex.runtimeVsProvider")]})}),e.jsxs(W,{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"flex flex-col rounded-md border p-3 text-sm",children:[e.jsx("p",{className:"font-medium text-foreground",children:t("codex.nativeCodexRuntime")}),e.jsxs("ul",{className:"mt-2 flex-grow list-disc space-y-1.5 pl-4 text-muted-foreground [&>li]:pl-1",children:[e.jsx("li",{children:e.jsx("code",{children:"ccs-codex"})}),e.jsx("li",{children:e.jsx("code",{children:"ccsx"})}),e.jsx("li",{children:e.jsx("code",{children:"--target codex"})})]}),e.jsx(y,{variant:"secondary",className:"mt-4 w-fit justify-center font-normal",children:t("codex.honorsSavedNativeConfig")})]}),e.jsxs("div",{className:"flex flex-col rounded-md border p-3 text-sm",children:[e.jsx("p",{className:"font-medium text-foreground",children:t("codex.ccsCodexProvider")}),a?e.jsxs(e.Fragment,{children:[e.jsxs("ul",{className:"mt-2 flex-grow list-disc space-y-1.5 pl-4 text-muted-foreground [&>li]:pl-1",children:[e.jsx("li",{children:e.jsx("code",{children:"ccsxp"})}),e.jsx("li",{children:e.jsx("code",{children:"ccs codex --target codex"})})]}),e.jsx("p",{className:"mt-4 text-muted-foreground",children:t("codex.transientOverridesDesc")})]}):e.jsx("p",{className:"mt-2 text-muted-foreground",children:t("codex.unavailableNoConfig")})]})]})]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsx(K,{className:"text-base",children:t("codex.supportedFlows")})}),e.jsx(W,{children:e.jsxs(Re,{children:[e.jsx(Ie,{children:e.jsxs(ce,{children:[e.jsx(B,{children:t("codex.flow")}),e.jsx(B,{children:t("codex.status")}),e.jsx(B,{children:t("codex.notes")})]})}),e.jsx(Fe,{children:s.supportMatrix.map(o=>e.jsxs(ce,{children:[e.jsx(V,{className:"font-mono text-xs",children:o.label}),e.jsx(V,{children:e.jsx(y,{variant:o.supported?"default":"secondary",children:o.supported?t("codex.yes"):t("codex.no")})}),e.jsx(V,{className:"text-xs text-muted-foreground",children:o.notes})]},o.id))})]})})]}),s.warnings.length>0&&e.jsxs(I,{className:"border-amber-200 bg-amber-50/50 dark:bg-amber-950/20",children:[e.jsx(F,{className:"pb-2",children:e.jsxs(K,{className:"flex items-center gap-2 text-base",children:[e.jsx(Os,{className:"h-4 w-4 text-amber-600"}),t("codex.warningsTitle")]})}),e.jsx(W,{className:"space-y-1.5",children:s.warnings.map(o=>e.jsxs("p",{className:"text-sm text-amber-800 dark:text-amber-300",children:["- ",o]},o))})]})]})})}function ar(){const{t:s}=T(),t=it(),{diagnostics:r,diagnosticsLoading:a,diagnosticsError:o,refetchDiagnostics:n,rawConfig:l,rawConfigLoading:c,rawConfigError:i,refetchRawConfig:d,saveRawConfigAsync:m,isSavingRawConfig:h,patchConfigAsync:x,isPatchingConfig:g}=Wt(),[p,w]=N.useState(null),M=l?.rawText??"",q=p??M,u=p!==null&&p!==M,v=Ve(q),X=v.parseError?{valid:!1,error:v.parseError}:{valid:!0},j=l?.config??null,$e=c||!l||u||l?.parseError!==null||l?.readError!==null,ze=i?"Structured controls unavailable: failed to load the current config.toml.":l?.readError?`Structured controls unavailable: ${l.readError}`:u?X.valid?"Save or discard raw TOML edits before using structured controls.":"Fix or discard raw TOML edits before using structured controls.":l?.parseError?`Structured controls disabled: ${l.parseError}`:null,Ge=N.useMemo(()=>qe(j),[j]),Xe=N.useMemo(()=>ct(j),[j]),He=N.useMemo(()=>dt(j),[j]),Ye=N.useMemo(()=>xt(j),[j]),Qe=N.useMemo(()=>ut(j),[j]),Je=N.useMemo(()=>mt(j),[j]),Ze=R=>{if(R===M){w(null);return}w(R)},es=async()=>{try{if((await Promise.all([n(),d()])).some(H=>!H||H.status==="error"||H.isError||H.error)){U.error(s("toasts.codexRefreshFailed"));return}w(null)}catch(R){U.error(R.message||s("toasts.codexRefreshError"))}},ss=async()=>{if(!X.valid){U.error(s("toasts.codexFixToml"));return}try{await m({rawText:q,expectedMtime:l?.exists?l.mtime:void 0}),w(null),U.success(s("toasts.codexSaved")),await n()}catch(R){Se(R)?U.error(s("toasts.codexChangedExternally")):U.error(R.message||s("toasts.codexSaveFailed"))}},ts=async(R,ye)=>{try{await x({...R,expectedMtime:l?.exists?l.mtime:void 0}),w(null),U.success(ye)}catch(H){Se(H)?U.error(s("toasts.codexChangedExternally")):U.error(H.message||s("toasts.codexUpdateFailed"))}},ae="mt-0 h-full border-0 p-0 data-[state=inactive]:hidden",rs=()=>a?e.jsxs("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:[e.jsx(G,{className:"mr-2 h-5 w-5 animate-spin"}),"Loading Codex diagnostics..."]}):o||!r?e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center text-destructive",children:"Failed to load Codex diagnostics."}):e.jsxs(ds,{defaultValue:"overview",className:"flex h-full flex-col",children:[e.jsx("div",{className:"shrink-0 px-4 pt-4",children:e.jsxs(xs,{className:"grid w-full grid-cols-4",children:[e.jsx(oe,{value:"overview",children:s("codexPage.overview")}),e.jsx(oe,{value:"controls",children:s("codexPage.controlCenter")}),e.jsx(oe,{value:"docs",children:s("codexPage.docs")}),e.jsx(oe,{value:"auth-profiles",children:s("codexPage.authProfiles")})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden px-4 pb-4 pt-3",children:[e.jsx(le,{value:"overview",className:ae,children:e.jsx($t,{diagnostics:r})}),e.jsx(le,{value:"controls",className:ae,children:e.jsx(ot,{workspacePath:r.workspacePath,activeProfile:r.config.activeProfile,topLevelSettings:Ge,projectTrustEntries:Xe,profileEntries:He,modelProviderEntries:Ye,mcpServerEntries:Qe,featureCatalog:t,featureState:Je,disabled:$e,disabledReason:ze,saving:g,onPatch:ts})}),e.jsx(le,{value:"docs",className:ae,children:e.jsx(jt,{diagnostics:r})}),e.jsx(le,{value:"auth-profiles",className:ae,children:e.jsx("div",{className:"h-full overflow-auto p-1",children:e.jsx(Ks,{})})})]})]});return e.jsx("div",{className:"h-full min-h-0 overflow-hidden",children:e.jsxs(is,{direction:"horizontal",className:"h-full",children:[e.jsx(Ce,{defaultSize:45,minSize:35,children:e.jsx("div",{className:"h-full border-r bg-muted/20",children:rs()})}),e.jsx(cs,{className:"group flex w-2 cursor-col-resize items-center justify-center bg-border transition-colors hover:bg-primary/20",children:e.jsx(Ls,{className:"h-3 w-3 text-muted-foreground group-hover:text-primary"})}),e.jsx(Ce,{defaultSize:55,minSize:35,children:e.jsx(As,{title:"Codex config.toml",pathLabel:l?.path||r?.file.path||"$CODEX_HOME/config.toml",loading:c,parseWarning:X.valid?l?.parseError:X.error,readWarning:l?.readError,value:q,dirty:u,readOnly:!!l?.readError,saving:h,saveDisabled:!u||h||c||!X.valid||!!l?.readError,onChange:R=>{Ze(R)},onSave:ss,onRefresh:es,onDiscard:()=>w(null),language:"toml",exactText:!0,loadingLabel:"Loading config.toml...",parseWarningLabel:"TOML warning",ownershipNotice:e.jsxs("div",{className:"rounded-md border border-amber-200 bg-amber-50/60 px-3 py-2 text-sm text-amber-900 dark:bg-amber-950/20 dark:text-amber-300",children:[e.jsx("p",{className:"font-medium",children:"This file is upstream-owned by Codex CLI."}),e.jsxs("p",{children:["CCS does not keep ",e.jsx("code",{children:"~/.codex/config.toml"})," in sync for you."]}),e.jsxs("p",{children:["CCS-backed Codex launches may apply transient ",e.jsx("code",{children:"-c"})," overrides and",e.jsx("code",{children:" CCS_CODEX_API_KEY"}),"; those effective values may not appear here."]})]})})})]})})}export{ar as CodexPage};