@kaitranntt/ccs 8.10.0-dev.17 → 8.10.0-dev.19

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 (146) hide show
  1. package/dist/cliproxy/accounts/claude-pool-policy-api.d.ts +12 -0
  2. package/dist/cliproxy/accounts/claude-pool-policy-api.d.ts.map +1 -0
  3. package/dist/cliproxy/accounts/claude-pool-policy-api.js +74 -0
  4. package/dist/cliproxy/accounts/claude-pool-policy-api.js.map +1 -0
  5. package/dist/cliproxy/accounts/claude-pool-policy-lease.d.ts +11 -0
  6. package/dist/cliproxy/accounts/claude-pool-policy-lease.d.ts.map +1 -0
  7. package/dist/cliproxy/accounts/claude-pool-policy-lease.js +55 -0
  8. package/dist/cliproxy/accounts/claude-pool-policy-lease.js.map +1 -0
  9. package/dist/cliproxy/accounts/claude-pool-policy-reconciliation.d.ts +13 -0
  10. package/dist/cliproxy/accounts/claude-pool-policy-reconciliation.d.ts.map +1 -0
  11. package/dist/cliproxy/accounts/claude-pool-policy-reconciliation.js +215 -0
  12. package/dist/cliproxy/accounts/claude-pool-policy-reconciliation.js.map +1 -0
  13. package/dist/cliproxy/accounts/claude-pool-policy-runtime.d.ts +19 -0
  14. package/dist/cliproxy/accounts/claude-pool-policy-runtime.d.ts.map +1 -0
  15. package/dist/cliproxy/accounts/claude-pool-policy-runtime.js +65 -0
  16. package/dist/cliproxy/accounts/claude-pool-policy-runtime.js.map +1 -0
  17. package/dist/cliproxy/accounts/claude-pool-policy-state.d.ts +37 -0
  18. package/dist/cliproxy/accounts/claude-pool-policy-state.d.ts.map +1 -0
  19. package/dist/cliproxy/accounts/claude-pool-policy-state.js +205 -0
  20. package/dist/cliproxy/accounts/claude-pool-policy-state.js.map +1 -0
  21. package/dist/cliproxy/accounts/claude-pool-policy.d.ts +48 -0
  22. package/dist/cliproxy/accounts/claude-pool-policy.d.ts.map +1 -0
  23. package/dist/cliproxy/accounts/claude-pool-policy.js +401 -0
  24. package/dist/cliproxy/accounts/claude-pool-policy.js.map +1 -0
  25. package/dist/cliproxy/accounts/drain-order.d.ts +1 -1
  26. package/dist/cliproxy/accounts/drain-order.d.ts.map +1 -1
  27. package/dist/cliproxy/accounts/drain-order.js +17 -0
  28. package/dist/cliproxy/accounts/drain-order.js.map +1 -1
  29. package/dist/cliproxy/accounts/pool-state.d.ts +1 -1
  30. package/dist/cliproxy/accounts/pool-state.d.ts.map +1 -1
  31. package/dist/cliproxy/accounts/registry-config.d.ts +4 -0
  32. package/dist/cliproxy/accounts/registry-config.d.ts.map +1 -0
  33. package/dist/cliproxy/accounts/registry-config.js +46 -0
  34. package/dist/cliproxy/accounts/registry-config.js.map +1 -0
  35. package/dist/cliproxy/accounts/token-file-ops.d.ts +1 -2
  36. package/dist/cliproxy/accounts/token-file-ops.d.ts.map +1 -1
  37. package/dist/cliproxy/accounts/token-file-ops.js +2 -7
  38. package/dist/cliproxy/accounts/token-file-ops.js.map +1 -1
  39. package/dist/cliproxy/accounts/types.d.ts +1 -1
  40. package/dist/cliproxy/accounts/types.d.ts.map +1 -1
  41. package/dist/cliproxy/config/generator.d.ts +2 -1
  42. package/dist/cliproxy/config/generator.d.ts.map +1 -1
  43. package/dist/cliproxy/config/generator.js +7 -2
  44. package/dist/cliproxy/config/generator.js.map +1 -1
  45. package/dist/cliproxy/quota/quota-fetcher-claude-normalizer.d.ts +17 -4
  46. package/dist/cliproxy/quota/quota-fetcher-claude-normalizer.d.ts.map +1 -1
  47. package/dist/cliproxy/quota/quota-fetcher-claude-normalizer.js +246 -153
  48. package/dist/cliproxy/quota/quota-fetcher-claude-normalizer.js.map +1 -1
  49. package/dist/cliproxy/quota/quota-fetcher-claude-probe-state.d.ts +3 -0
  50. package/dist/cliproxy/quota/quota-fetcher-claude-probe-state.d.ts.map +1 -1
  51. package/dist/cliproxy/quota/quota-fetcher-claude-probe-state.js +17 -10
  52. package/dist/cliproxy/quota/quota-fetcher-claude-probe-state.js.map +1 -1
  53. package/dist/cliproxy/quota/quota-fetcher-claude.d.ts +4 -4
  54. package/dist/cliproxy/quota/quota-fetcher-claude.d.ts.map +1 -1
  55. package/dist/cliproxy/quota/quota-fetcher-claude.js +118 -29
  56. package/dist/cliproxy/quota/quota-fetcher-claude.js.map +1 -1
  57. package/dist/cliproxy/quota/quota-label-sanitizer.d.ts +3 -2
  58. package/dist/cliproxy/quota/quota-label-sanitizer.d.ts.map +1 -1
  59. package/dist/cliproxy/quota/quota-label-sanitizer.js +6 -5
  60. package/dist/cliproxy/quota/quota-label-sanitizer.js.map +1 -1
  61. package/dist/cliproxy/quota/quota-manager.d.ts.map +1 -1
  62. package/dist/cliproxy/quota/quota-manager.js +3 -9
  63. package/dist/cliproxy/quota/quota-manager.js.map +1 -1
  64. package/dist/cliproxy/quota/quota-types.d.ts +12 -0
  65. package/dist/cliproxy/quota/quota-types.d.ts.map +1 -1
  66. package/dist/commands/cliproxy/help-subcommand.d.ts.map +1 -1
  67. package/dist/commands/cliproxy/help-subcommand.js +9 -0
  68. package/dist/commands/cliproxy/help-subcommand.js.map +1 -1
  69. package/dist/commands/cliproxy/order-subcommand.d.ts.map +1 -1
  70. package/dist/commands/cliproxy/order-subcommand.js +86 -44
  71. package/dist/commands/cliproxy/order-subcommand.js.map +1 -1
  72. package/dist/commands/cliproxy/pool-state-renderer.d.ts.map +1 -1
  73. package/dist/commands/cliproxy/pool-state-renderer.js +9 -2
  74. package/dist/commands/cliproxy/pool-state-renderer.js.map +1 -1
  75. package/dist/commands/cliproxy/quota-subcommand/claude-window-helpers.d.ts +1 -2
  76. package/dist/commands/cliproxy/quota-subcommand/claude-window-helpers.d.ts.map +1 -1
  77. package/dist/commands/cliproxy/quota-subcommand/claude-window-helpers.js +5 -16
  78. package/dist/commands/cliproxy/quota-subcommand/claude-window-helpers.js.map +1 -1
  79. package/dist/commands/cliproxy/quota-subcommand/sections/claude.d.ts.map +1 -1
  80. package/dist/commands/cliproxy/quota-subcommand/sections/claude.js +1 -1
  81. package/dist/commands/cliproxy/quota-subcommand/sections/claude.js.map +1 -1
  82. package/dist/docker/docker-bootstrap.d.ts.map +1 -1
  83. package/dist/docker/docker-bootstrap.js +29 -5
  84. package/dist/docker/docker-bootstrap.js.map +1 -1
  85. package/dist/shared/claude-pool-policy.d.ts +20 -0
  86. package/dist/shared/claude-pool-policy.d.ts.map +1 -0
  87. package/dist/shared/claude-pool-policy.js +3 -0
  88. package/dist/shared/claude-pool-policy.js.map +1 -0
  89. package/dist/ui/assets/{Trans-ButNUgI0.js → Trans-Dlb02vqu.js} +1 -1
  90. package/dist/ui/assets/{accounts-MLY7WLik.js → accounts-NMmfEBnl.js} +1 -1
  91. package/dist/ui/assets/{alert-dialog-B5gsPnVB.js → alert-dialog-CLeTz0Di.js} +1 -1
  92. package/dist/ui/assets/{api-Bz71asnK.js → api-DxGxeHbw.js} +1 -1
  93. package/dist/ui/assets/{auth-section-BqGQc4ub.js → auth-section-AI2YNrUB.js} +1 -1
  94. package/dist/ui/assets/{backups-section-BP8fVjA2.js → backups-section-CxyuzCda.js} +1 -1
  95. package/dist/ui/assets/{channels-CXItlOs8.js → channels-SBcIEMn0.js} +1 -1
  96. package/dist/ui/assets/{checkbox-D3_x-6PV.js → checkbox-C1D6YcRy.js} +1 -1
  97. package/dist/ui/assets/{claude-extension-DvAAS238.js → claude-extension-C3Ik79tl.js} +1 -1
  98. package/dist/ui/assets/{cliproxy-io8Z1slq.js → cliproxy-BySCuRxu.js} +1 -1
  99. package/dist/ui/assets/{cliproxy-ai-providers-DkgBWX_r.js → cliproxy-ai-providers-B8LPZhj3.js} +1 -1
  100. package/dist/ui/assets/{cliproxy-control-panel-C6IMwMpu.js → cliproxy-control-panel-Dsv31SI_.js} +1 -1
  101. package/dist/ui/assets/{codex-BKntGtWm.js → codex-CWZlSLEn.js} +1 -1
  102. package/dist/ui/assets/{confirm-dialog-CU4RRUuI.js → confirm-dialog-tpU9d5TR.js} +1 -1
  103. package/dist/ui/assets/{copilot-S045zi-v.js → copilot-C5uwBK-k.js} +1 -1
  104. package/dist/ui/assets/{cursor-q4VVsOHM.js → cursor-BwoYXKM4.js} +1 -1
  105. package/dist/ui/assets/{droid-C4hxPz1p.js → droid-Cv6mZctn.js} +1 -1
  106. package/dist/ui/assets/{globalenv-section-DeVJimxG.js → globalenv-section-CKc1Udhj.js} +1 -1
  107. package/dist/ui/assets/{health-D5k73-1v.js → health-Ctfcm6p0.js} +1 -1
  108. package/dist/ui/assets/{index-BJJcWQcN.js → index--TAxR0Iy.js} +1 -1
  109. package/dist/ui/assets/index-0hASk2BU.css +1 -0
  110. package/dist/ui/assets/{index-DpL-rgkN.js → index-C2ABCKof.js} +1 -1
  111. package/dist/ui/assets/{index-CSfupFf3.js → index-C5YaR--I.js} +1 -1
  112. package/dist/ui/assets/{index-9RHJNAlK.js → index-CBKaNavQ.js} +1 -1
  113. package/dist/ui/assets/{index-DQWeKrTw.js → index-DnnSa3K6.js} +1 -1
  114. package/dist/ui/assets/{index-Nd8v14jh.js → index-G9JzuSyw.js} +1 -1
  115. package/dist/ui/assets/{index-B7Y50Pmj.js → index-gX7Mi5Ws.js} +37 -37
  116. package/dist/ui/assets/{logs-DBRI0Vct.js → logs-D6LiKkzU.js} +1 -1
  117. package/dist/ui/assets/{masked-input-CO6eBTBI.js → masked-input-CmtENW5h.js} +1 -1
  118. package/dist/ui/assets/proxy-status-widget-DqVBhfEP.js +1 -0
  119. package/dist/ui/assets/{raw-json-settings-editor-panel-Czb-dWwA.js → raw-json-settings-editor-panel-C9-_RC57.js} +1 -1
  120. package/dist/ui/assets/{searchable-select-EyJfxEUO.js → searchable-select-BeEQJh2E.js} +1 -1
  121. package/dist/ui/assets/{separator-DbhOtMVl.js → separator-CB-e5SCL.js} +1 -1
  122. package/dist/ui/assets/{shared-Dx9MtTlc.js → shared-GU9wziRt.js} +1 -1
  123. package/dist/ui/assets/{table-NcM1_A4G.js → table-BFrniqUJ.js} +1 -1
  124. package/dist/ui/assets/{updates-BmhLCm82.js → updates-DYhBCREi.js} +1 -1
  125. package/dist/ui/assets/{use-accounts-sRp8XTDE.js → use-accounts-xaNW9KeG.js} +1 -1
  126. package/dist/ui/index.html +2 -2
  127. package/dist/web-server/index.d.ts +1 -1
  128. package/dist/web-server/index.d.ts.map +1 -1
  129. package/dist/web-server/index.js +4 -1
  130. package/dist/web-server/index.js.map +1 -1
  131. package/dist/web-server/routes/bar-pool-account-quota-adapter.d.ts.map +1 -1
  132. package/dist/web-server/routes/bar-pool-account-quota-adapter.js +1 -3
  133. package/dist/web-server/routes/bar-pool-account-quota-adapter.js.map +1 -1
  134. package/dist/web-server/routes/cliproxy-routing-routes.d.ts.map +1 -1
  135. package/dist/web-server/routes/cliproxy-routing-routes.js +16 -0
  136. package/dist/web-server/routes/cliproxy-routing-routes.js.map +1 -1
  137. package/dist/web-server/shutdown.d.ts +2 -3
  138. package/dist/web-server/shutdown.d.ts.map +1 -1
  139. package/dist/web-server/shutdown.js +16 -8
  140. package/dist/web-server/shutdown.js.map +1 -1
  141. package/dist/web-server/usage/native-quota-collector.d.ts.map +1 -1
  142. package/dist/web-server/usage/native-quota-collector.js +33 -65
  143. package/dist/web-server/usage/native-quota-collector.js.map +1 -1
  144. package/package.json +1 -1
  145. package/dist/ui/assets/index-h0wykXqj.css +0 -1
  146. package/dist/ui/assets/proxy-status-widget-Bfp37KO_.js +0 -1
@@ -1 +0,0 @@
1
- import{j as e}from"./radix-ui-nu4wz29m.js";import{r as x}from"./react-vendor-Bjx91N7w.js";import{a as Y,bH as Ie,bI as Ee,c as b,B as R,e as $,bD as Ve,a_ as De,bJ as Oe,bK as $e,bL as Le,bM as Ue,bN as Me,bO as Fe,bP as qe,bQ as Be,bR as ze,T as He,O as Ke,R as Qe,j as Ye,k as Je,l as Xe,m as Ze,n as et,o as tt,p as st,q as nt,_ as rt}from"./index-B7Y50Pmj.js";import{A as at,a as ot,b as it,c as lt,d as dt,e as ct,f as ut,g as xt}from"./alert-dialog-B5gsPnVB.js";import{u as Re,a as gt,b as mt,h as pt}from"./tanstack-bhJxV1h8.js";import{t as le}from"./notifications-B4_o8bcr.js";import{bg as je,R as z,u as ge,t as me,v as ft,A as ht,bh as bt,bi as yt,bj as jt,X as vt,e as Nt,bk as St,bl as wt,U as Ct,w as Rt,n as kt,x as At,aG as Gt,T as de,aQ as Tt}from"./icons-DSLG1YsC.js";import{T as ve}from"./Trans-ButNUgI0.js";async function Pt(){const t=await fetch("/api/cliproxy/sync/status");if(!t.ok){let s="Failed to fetch sync status";try{const n=await t.json();s=n.error||n.message||s}catch{}throw new Error(s)}return t.json()}async function Wt(){const t=new AbortController,s=setTimeout(()=>t.abort(),3e4);try{const n=await fetch("/api/cliproxy/sync",{method:"POST",headers:{"Content-Type":"application/json"},signal:t.signal});if(!n.ok){let a="Sync failed";try{const o=await n.json();a=o.error||o.message||a}catch{}throw new Error(a)}return n.json()}catch(n){throw n instanceof Error&&n.name==="AbortError"?new Error("Sync request timed out after 30 seconds"):n}finally{clearTimeout(s)}}function _t(){return Re({queryKey:["cliproxy-sync-status"],queryFn:Pt,refetchInterval:3e4,retry:1,staleTime:1e4})}function It(){const t=gt(),{t:s}=Y();return mt({mutationFn:Wt,onSuccess:n=>{t.invalidateQueries({queryKey:["cliproxy-sync-status"]}),t.invalidateQueries({queryKey:["cliproxy-sync-preview"]}),n.syncedCount===0?le.info(s("toasts.noProfilesToSync")):le.success(`Synced ${n.syncedCount} profile${n.syncedCount===1?"":"s"} to CLIProxy`)},onError:n=>{le.error(s("toasts.syncFailed",{error:n.message}))}})}function Ne(t){const s=t.trim().replace(/^v/,""),[n,a="0"]=s.split("-",2),[o=0,c=0,d=0]=n.split(".").map(y=>Number.parseInt(y,10)||0),p=/^\d+$/.test(a)&&Number.parseInt(a,10)||0;return{major:o,minor:c,patch:d,forkRelease:p}}function ee(t,s){return t>s?1:t<s?-1:0}function pe(t,s){const n=Ne(t),a=Ne(s);return ee(n.major,a.major)||ee(n.minor,a.minor)||ee(n.patch,a.patch)||ee(n.forkRelease,a.forkRelease)}function ce(t,s){return pe(t,s)>0}function ue(t,s,n){return pe(t,s)>=0&&pe(t,n)<=0}function Se(t){if(!/^\d+$/.test(t))return null;const s=Number(t);return Number.isSafeInteger(s)?s:null}function Et(){const{t}=Y(),s=Ie(),n=Ee(),a=s.data?.request_retry??0,o=s.data?.max_retry_interval??0,c=s.data?.manageable!==!1,d=s.isLoading||s.isError||n.isPending||!c,p=s.error?.message??s.data?.message;return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-lg border border-border/60 bg-muted/20 px-2 py-1.5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[10px] font-medium text-foreground",children:t("routingGuidance.retryTitle")}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[t("routingGuidance.retryHint"),s.data?` · ${s.data.source} · ${s.data.target}`:""]})]}),e.jsx(Vt,{requestRetry:a,maxRetryInterval:o,disabled:d,onUpdate:(y,r)=>n.mutate({request_retry:y,max_retry_interval:r})},`${a}:${o}`)]}),p?e.jsx("div",{className:"rounded-lg border border-border/60 bg-muted/20 px-2 py-1.5 text-[10px] text-muted-foreground",children:p}):null]})}function Vt({requestRetry:t,maxRetryInterval:s,disabled:n,onUpdate:a}){const{t:o}=Y(),[c,d]=x.useState(String(t)),[p,y]=x.useState(String(s)),[r,j]=x.useState(null),g=()=>{if(n)return;const m=Se(c.trim()),S=Se(p.trim());if(m===null||S===null){j(o("routingGuidance.retryRangeError")),d(String(t)),y(String(s));return}j(null),(m!==t||S!==s)&&a(m,S)};return e.jsxs("div",{className:"flex flex-col items-end gap-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{"aria-label":o("routingGuidance.requestRetryLabel"),inputMode:"numeric",className:"h-6 w-10 rounded border border-border/70 bg-background px-1.5 text-[10px] text-foreground",value:c,onChange:m=>d(m.target.value),onBlur:g,disabled:n}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"/"}),e.jsx("input",{"aria-label":o("routingGuidance.maxRetryIntervalLabel"),inputMode:"numeric",className:"h-6 w-10 rounded border border-border/70 bg-background px-1.5 text-[10px] text-foreground",value:p,onChange:m=>y(m.target.value),onBlur:g,disabled:n})]}),r?e.jsx("div",{className:"text-[10px] text-destructive",children:r}):null]})}const xe={"round-robin":{title:"Round Robin",description:"Spread requests across matching accounts for even usage."},"fill-first":{title:"Fill First",description:"Drain one healthy account first and keep backups untouched until needed."}};function we({className:t,compact:s=!1,state:n,sessionAffinityState:a,isLoading:o,isSaving:c,error:d,onApply:p,onApplyAffinity:y}){const{t:r}=Y(),j=n?.strategy??"round-robin",g=n?.poolRouting?.enabled??!1,m=n?.poolRouting?.maxRetryCredentials,S=n?.poolRouting?.manageable??!0,w=!S,L=n?.poolRouting?.message??r("routingGuidance.poolRoutingLocalOnly"),C=a?.enabled??!1,f=a?.ttl??"1h",h=a?.manageable??!0,[v,H]=x.useState(j),[P,E]=x.useState(C),[k,W]=x.useState(f),[N,te]=x.useState(!1),A=n?.source==="live"?"Live CLIProxy":"Saved startup default",J=o||c||!n||v===j,X=N?"Hide details":"Show details",U=o||c||!!d||!h,V=r(h?P?"routingGuidance.disableSessionAffinity":"routingGuidance.enableSessionAffinity":"routingGuidance.sessionAffinityUnavailable"),D=x.useRef(null),G=x.useRef(!1);x.useEffect(()=>{H(j)},[j]),x.useEffect(()=>{E(C),W(f)},[C,f]),x.useEffect(()=>{if(c||!D.current)return;const l=D.current;l.enabled===C&&l.ttl===f||(E(C),W(f)),D.current=null},[c,C,f]);const O=()=>{if(!h)return;const l=!P,u=k.trim()||"1h";D.current={enabled:l,ttl:u},E(l),y({enabled:l,ttl:u})},M=()=>{if(!h||d)return;if(G.current){G.current=!1;return}const l=k.trim()||"1h";l!==f&&(D.current={enabled:P,ttl:l},y({enabled:P,ttl:l}))};if(s){const l=u=>{H(u),u!==j&&p(u)};return e.jsxs("div",{className:b("group/routing mt-1 space-y-2 -mx-1 rounded-lg p-1",t),children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg transition-colors hover:bg-primary/5",children:[e.jsxs("div",{className:"flex items-center gap-2 px-1 text-xs font-medium text-foreground",children:[e.jsxs("div",{className:"relative flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-background border border-border/60 text-muted-foreground shadow-sm overflow-hidden transition-all duration-300 group-hover/routing:border-primary/40 group-hover/routing:text-primary group-hover/routing:shadow-[0_0_12px_rgba(59,130,246,0.15)] dark:group-hover/routing:shadow-[0_0_12px_rgba(59,130,246,0.1)]",children:[e.jsx("div",{className:"absolute inset-0 bg-primary/10 translate-y-full group-hover/routing:translate-y-0 transition-transform duration-300 ease-out"}),e.jsx(je,{className:"relative z-10 h-3.5 w-3.5 transition-transform duration-300 group-hover/routing:scale-110"})]}),e.jsx("span",{className:"tracking-tight transition-colors duration-300 group-hover/routing:text-primary group-hover/routing:font-semibold",children:"Routing"}),c&&e.jsx(z,{className:"ml-1 h-3 w-3 shrink-0 animate-spin text-primary"})]}),e.jsxs("div",{className:"relative grid grid-cols-2 p-0.5 gap-0.5 rounded-lg border border-border/60 bg-muted/30 shadow-[inset_0_1px_2px_rgba(0,0,0,0.05)] dark:shadow-[inset_0_1px_3px_rgba(0,0,0,0.2)] transition-colors duration-300 group-hover/routing:border-primary/20 group-hover/routing:bg-primary/5",children:[e.jsx("div",{className:b("absolute inset-y-0.5 left-0.5 w-[calc(50%-0.1875rem)] rounded bg-background shadow-[0_1px_3px_rgba(0,0,0,0.1),0_1px_2px_rgba(0,0,0,0.06)] ring-1 ring-black/5 dark:ring-white/10 transition-all duration-300",v==="fill-first"?"translate-x-[calc(100%+0.125rem)]":"translate-x-0","group-hover/routing:shadow-[0_0_8px_rgba(59,130,246,0.15)] dark:group-hover/routing:shadow-[0_0_8px_rgba(59,130,246,0.1)] group-hover/routing:ring-primary/30"),style:{transitionTimingFunction:"cubic-bezier(0.175, 0.885, 0.32, 1.275)"}}),Object.entries(xe).map(([u,_])=>{const se=v===u;return e.jsx("button",{type:"button",className:b("relative z-10 flex items-center justify-center rounded px-2.5 py-0.5 text-[10px] font-medium whitespace-nowrap transition-colors duration-200",se?"text-foreground group-hover/routing:text-primary":"text-muted-foreground/70 hover:text-foreground/90 group-hover/routing:text-muted-foreground/90"),onClick:()=>l(u),disabled:o||c||!!d,title:_.description,children:_.title},u)})]})]}),g&&S?e.jsx("div",{role:"status",className:"rounded-lg border border-amber-500/40 bg-amber-500/10 px-2 py-1.5 text-[10px] leading-4 text-amber-700 dark:text-amber-300",children:r("routingGuidance.poolRoutingApplyWarning")}):null,e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-lg border border-border/60 bg-muted/20 px-2 py-1.5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[10px] font-medium text-foreground",children:r("routingGuidance.poolRouting")}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:w?L:r(g?"routingGuidance.drainOrderHint":"routingGuidance.poolRoutingOffHint")})]}),e.jsx(R,{variant:w?"outline":g?"secondary":"outline",title:w?L:r(g?"routingGuidance.poolRoutingManaged":"routingGuidance.poolRoutingOffHint"),children:w?r("routingGuidance.localOnly"):g?`${r("routingGuidance.poolRoutingOn")} · ${r("routingGuidance.poolMaxRetry",{count:m??0})}`:r("routingGuidance.poolRoutingOff")})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-lg border border-border/60 bg-muted/20 px-2 py-1.5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[10px] font-medium text-foreground",children:r("routingGuidance.sessionAffinity")}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:h?r("routingGuidance.ttlBadge",{ttl:f}):r("routingGuidance.localOnlySetting")})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[h?e.jsx("input",{"aria-label":"Session affinity TTL",className:"h-6 w-14 rounded border border-border/70 bg-background px-2 text-[10px] text-foreground",value:k,onChange:u=>W(u.target.value),onBlur:M,disabled:U}):null,e.jsx("button",{type:"button","aria-label":V,className:b("rounded border px-2 py-1 text-[10px] font-medium transition-colors",h?"border-border/70 bg-background text-foreground hover:border-primary/40 hover:text-primary":"border-border/60 bg-muted/40 text-muted-foreground"),onMouseDown:()=>{G.current=!0},onClick:O,disabled:U,title:a?.message,children:r(h?P?"routingGuidance.sessionAffinityOn":"routingGuidance.sessionAffinityOff":"routingGuidance.sessionAffinityUnavailable")})]})]}),a?.message?e.jsx("div",{className:"rounded-lg border border-border/60 bg-muted/20 px-2 py-1.5 text-[10px] text-muted-foreground",children:a.message}):null,e.jsx(Et,{})]})}return e.jsx("section",{className:b("rounded-xl border border-border/70 bg-background",t),children:e.jsxs("div",{className:"grid gap-3 px-4 py-3 xl:grid-cols-[minmax(0,1fr)_auto] xl:items-start",children:[e.jsxs("div",{className:"min-w-0 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"inline-flex h-7 w-7 items-center justify-center rounded-lg bg-muted text-primary",children:e.jsx(je,{className:"h-4 w-4"})}),e.jsx("div",{className:"text-sm font-medium",children:r("routingGuidance.routingStrategy")}),e.jsx(R,{variant:"secondary",children:j}),n?e.jsx(R,{variant:"outline",children:A}):null,n?e.jsx(R,{variant:"outline",children:n.target}):null,n?e.jsxs(R,{variant:w?"outline":g?"secondary":"outline",title:w?L:r(g?"routingGuidance.poolRoutingManaged":"routingGuidance.poolRoutingOffHint"),children:[r("routingGuidance.poolRouting"),":"," ",r(w?"routingGuidance.localOnly":g?"routingGuidance.poolRoutingOn":"routingGuidance.poolRoutingOff"),!w&&g&&m!==void 0?` · ${r("routingGuidance.poolMaxRetry",{count:m})}`:""]}):null]}),e.jsx("p",{className:"max-w-3xl text-xs leading-5 text-muted-foreground",children:"Proxy-wide account rotation. CCS keeps round-robin as the default until you explicitly change it."}),e.jsx("p",{className:"max-w-3xl text-[11px] leading-5 text-muted-foreground",children:r("routingGuidance.drainOrderHint")})]}),e.jsxs("div",{className:"flex flex-col gap-2 xl:items-end",children:[e.jsx("div",{className:"inline-flex flex-wrap rounded-lg border border-border/70 bg-muted/35 p-1",children:Object.entries(xe).map(([l,u])=>{const _=v===l;return e.jsx("button",{type:"button",className:b("rounded-md px-3 py-1.5 text-sm font-medium transition-colors",_?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),onClick:()=>H(l),disabled:o||c||!!d,children:u.title},l)})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs($,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-xs text-muted-foreground",onClick:()=>te(l=>!l),children:[N?e.jsx(ge,{className:"mr-1 h-3.5 w-3.5"}):e.jsx(me,{className:"mr-1 h-3.5 w-3.5"}),X]}),e.jsx($,{size:"sm",onClick:()=>p(v),disabled:J||!!d,children:c?"Saving...":`Use ${v}`})]}),g&&S?e.jsx("p",{role:"status",className:"max-w-xs text-[11px] leading-4 text-amber-700 dark:text-amber-400 xl:text-right",children:r("routingGuidance.poolRoutingApplyWarning")}):null]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground xl:col-span-2",children:[e.jsx("span",{children:r("routingGuidance.roundRobin")}),e.jsx("span",{className:"hidden text-border sm:inline",children:"•"}),e.jsx("span",{children:r("routingGuidance.fillFirst")})]}),e.jsxs("div",{className:"grid gap-3 rounded-lg border border-border/70 bg-muted/20 px-3 py-3 xl:col-span-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"text-sm font-medium",children:r("routingGuidance.sessionAffinity")}),e.jsx(R,{variant:"secondary",children:r(P?"routingGuidance.sessionAffinityOn":"routingGuidance.sessionAffinityOff")}),a?.ttl?e.jsx(R,{variant:"outline",children:r("routingGuidance.ttlBadge",{ttl:f})}):null,h?null:e.jsx(R,{variant:"outline",children:r("routingGuidance.localOnly")})]}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:r("routingGuidance.sessionAffinityDescription")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("input",{"aria-label":"Session affinity TTL",className:"h-9 w-24 rounded-md border border-border/70 bg-background px-3 text-sm text-foreground",value:k,onChange:l=>W(l.target.value),onBlur:M,disabled:U}),e.jsx($,{type:"button",variant:"outline",onMouseDown:()=>{G.current=!0},onClick:O,disabled:U,"aria-label":V,children:V})]}),a?.message?e.jsx("div",{className:"rounded-lg border border-border/70 bg-background/70 px-3 py-2 text-xs text-muted-foreground",children:a.message}):null]}),d?e.jsx("div",{className:"rounded-lg border border-destructive/25 bg-destructive/5 px-3 py-2 text-sm xl:col-span-2",children:d.message}):null,!d&&n?.message?e.jsx("div",{className:"rounded-lg border border-border/70 bg-muted/35 px-3 py-2 text-xs text-muted-foreground xl:col-span-2",children:n.message}):null,N?e.jsxs("div",{className:"grid gap-4 border-t border-border/60 pt-3 md:grid-cols-2 xl:col-span-2",children:[Object.entries(xe).map(([l,u])=>{const _=j===l;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"text-sm font-medium",children:u.title}),_?e.jsx(R,{variant:"secondary",children:"Current"}):null]}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:u.description})]},l)}),e.jsxs("div",{className:"space-y-1 md:col-span-2",children:[e.jsx("div",{className:"text-sm font-medium",children:r("routingGuidance.sessionRecognitionTitle")}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:r("routingGuidance.sessionRecognitionDescription")})]})]}):null]})})}const ke="cliproxy-status-widget-collapsed";function Dt(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(ke)==="true"}catch{return!1}}function Ce(t){if(!(typeof window>"u"))try{window.localStorage.setItem(ke,String(t))}catch{}}function Ot(t){if(!t)return"";const s=new Date(t).getTime(),a=Date.now()-s,o=Math.floor(a/(1e3*60*60)),c=Math.floor(a%(1e3*60*60)/(1e3*60));return o>0?`${o}h ${c}m`:`${c}m`}function $t(t,s){if(!t)return"";const n=Date.now()-t,a=Math.floor(n/(1e3*60)),o=Math.floor(n/(1e3*60*60));return a<1?s("proxyStatusWidget.justNow"):a<60?s("proxyStatusWidget.minutesAgo",{count:a}):s("proxyStatusWidget.hoursAgo",{count:o})}function Q({icon:t,tooltip:s,onClick:n,disabled:a,isPending:o,className:c,variant:d="ghost"}){return e.jsxs(tt,{children:[e.jsx(st,{asChild:!0,children:e.jsx($,{variant:d==="destructive-ghost"?"ghost":d,size:"sm",className:b("h-7 w-7 p-0",d==="destructive-ghost"&&"hover:bg-destructive/10 hover:text-destructive hover:border-destructive/30",c),onClick:n,disabled:a,"aria-label":s,children:o?e.jsx(z,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(t,{className:"w-3.5 h-3.5"})})}),e.jsx(nt,{side:"bottom",className:"text-xs",children:s})]})}function Kt(){const{t}=Y(),{data:s,isLoading:n}=Ve(),{data:a}=De(),{data:o,isLoading:c}=Oe(),{data:d,isLoading:p,error:y}=$e(),r=Le(),{data:j,isLoading:g,error:m}=Ue(),S=Me(),w=r.isPending||S.isPending,L=y instanceof Error?y:null,C=Fe(),f=qe(),h=Be(),v=ze(),{data:H}=_t(),{mutate:P,isPending:E}=It(),[k,W]=x.useState(!1),[N,te]=x.useState(""),[A,J]=x.useState(Dt),X=()=>{const i=!A;J(i),i&&W(!1),Ce(i)},U=()=>{const i=!k;W(i),i&&A&&(J(!1),Ce(!1))},V=t(A?"proxyStatusWidget.tooltipExpandWidget":"proxyStatusWidget.tooltipCollapseWidget"),[D,G]=x.useState(!1),[O,M]=x.useState(null),[l,u]=x.useState(null),{data:_}=Re({queryKey:["cliproxy-server-config"],queryFn:()=>rt.cliproxyServer.get(),staleTime:3e4}),se=pt({mutationKey:["update-backend"]})>0,F=_?.remote,ne=F?.enabled&&F?.host,I=j??(m instanceof Error?{source:"unsupported",target:d?.target??(ne?"remote":"local"),reachable:!1,manageable:!1,message:m.message}:void 0),K=s?.running??!1,re=C.isPending||f.isPending||h.isPending||v.isPending||se||E,Ae=a?.hasUpdate??!1,q=a?.isStable===!1,fe=a?.currentVersion,Z=H?.configured??!1,Ge=t(Z?"proxyStatusWidget.syncReady":"proxyStatusWidget.noConfig"),ae=q?a?.maxStableVersion||o?.latestStable:a?.latestVersion,he=o?.maxStableVersion||a?.maxStableVersion||"6.6.80",B=o?.faultyRange,Te=B&&`${B.min.replace(/-\d+$/,"")}-${B.max.replace(/-\d+$/,"")}`,oe=(i,T)=>{M(i),u(T),G(!0)},be=async i=>{if(!i)return;const T=ce(i,he);if(B!==void 0&&ue(i,B.min,B.max)){oe(i,"faulty");return}if(T){oe(i,"experimental");return}try{const ye=await v.mutateAsync({version:i});ye.requiresConfirmation&&oe(i,ye.isFaulty?"faulty":"experimental")}catch{}},Pe=()=>{O&&v.mutate({version:O,force:!0}),G(!1),M(null),u(null)},We=()=>{G(!1),M(null),u(null)},_e=ne?(()=>{const i=F.protocol||"http",T=F.port||(i==="https"?443:80);return i==="https"&&T===443||i==="http"&&T===80?F.host:`${F.host}:${T}`})():null;return ne?e.jsxs("div",{className:b("rounded-lg border p-3 transition-colors","border-blue-500/30 bg-blue-500/5"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ft,{className:"w-4 h-4 text-blue-500"}),e.jsx("span",{className:"text-sm font-medium",children:t("proxyStatusWidget.remoteProxy")}),e.jsx(R,{variant:"secondary",className:"text-[10px] h-4 px-1.5 bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",children:t("proxyStatusWidget.active")})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ht,{className:"w-3 h-3 text-blue-600"}),e.jsx($,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:X,title:V,"aria-label":V,children:A?e.jsx(me,{className:"w-3.5 h-3.5"}):e.jsx(ge,{className:"w-3.5 h-3.5"})})]})]}),!A&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:[e.jsx("div",{className:"flex items-center gap-1 mb-1",children:e.jsx("span",{className:"font-mono",children:_e})}),e.jsx("p",{className:"text-[10px] text-muted-foreground/70 leading-tight",children:t("proxyStatusWidget.trafficAutoRouted")})]}),e.jsx(we,{compact:!0,className:"mt-3",state:d,sessionAffinityState:I,isLoading:p||g,isSaving:w,error:L,onApply:i=>r.mutate(i),onApplyAffinity:i=>S.mutate(i)},`remote:${d?.strategy??"round-robin"}:${I?.enabled??"na"}:${I?.ttl??"na"}:${I?.manageable??"na"}`)]})]}):e.jsx(He,{delayDuration:300,children:e.jsxs("div",{className:b("rounded-lg border p-3 transition-colors",K?"border-green-500/30 bg-green-500/5":"border-muted bg-muted/30"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:b("w-2 h-2 rounded-full",K?"bg-green-500 animate-pulse":"bg-muted-foreground/30")}),e.jsx("span",{className:"text-sm font-medium",children:a?.backendLabel??"CLIProxy"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[n?e.jsx(z,{className:"w-3 h-3 animate-spin text-muted-foreground"}):K?e.jsxs(e.Fragment,{children:[e.jsx(Q,{icon:E?z:bt,tooltip:t("proxyStatusWidget.tooltipSync"),onClick:()=>P(),disabled:!Z||re,isPending:E}),e.jsx(Q,{icon:yt,tooltip:t("proxyStatusWidget.tooltipRestart"),onClick:()=>h.mutate(),disabled:re,isPending:h.isPending}),e.jsx(Q,{icon:jt,tooltip:t("proxyStatusWidget.tooltipStop"),onClick:()=>f.mutate(),disabled:re,isPending:f.isPending,variant:"destructive-ghost"})]}):null,e.jsx(Q,{icon:k?vt:Nt,tooltip:t(k?"proxyStatusWidget.tooltipClose":"proxyStatusWidget.tooltipVersionSettings"),onClick:U,className:k?"bg-muted":void 0}),e.jsx(Q,{icon:A?me:ge,tooltip:V,onClick:X})]})]}),fe&&e.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[e.jsxs("span",{className:b("text-xs font-mono text-muted-foreground",q&&"text-amber-600 dark:text-amber-400"),children:["v",fe]}),(Ae||q)&&ae&&e.jsxs(R,{variant:"secondary",className:b("text-[10px] h-4 px-1.5 gap-0.5 cursor-pointer transition-colors",q?"bg-amber-100 text-amber-700 hover:bg-amber-200 dark:bg-amber-900/30 dark:text-amber-400 dark:hover:bg-amber-900/50":"bg-green-100 text-green-700 hover:bg-green-200 dark:bg-green-900/30 dark:text-green-400 dark:hover:bg-green-900/50"),onClick:()=>void be(ae),title:t(q?"proxyStatusWidget.clickToDowngrade":"proxyStatusWidget.clickToUpdate"),children:[q?e.jsx(St,{className:"w-2.5 h-2.5"}):e.jsx(wt,{className:"w-2.5 h-2.5"}),ae]})]}),!A&&K&&s&&e.jsxs("div",{className:"mt-2 flex items-center gap-4 text-xs text-muted-foreground",children:[e.jsx("span",{className:"flex items-center gap-1",children:t("proxyStatusWidget.port",{port:s.port})}),s.sessionCount!==void 0&&s.sessionCount>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ct,{className:"w-3 h-3"}),t("proxyStatusWidget.sessionCount",{count:s.sessionCount})]}),s.startedAt&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Rt,{className:"w-3 h-3"}),Ot(s.startedAt)]})]}),!A&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-xs",children:[Z?e.jsx(kt,{className:"w-3 h-3 text-green-600 dark:text-green-400"}):e.jsx(At,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:b("text-xs",Z?"text-green-600 dark:text-green-400":"text-muted-foreground"),children:Ge})]}),e.jsx(we,{compact:!0,className:"mt-3",state:d,sessionAffinityState:I,isLoading:p||g,isSaving:w,error:L,onApply:i=>r.mutate(i),onApplyAffinity:i=>S.mutate(i)},`local:${d?.strategy??"round-robin"}:${I?.enabled??"na"}:${I?.ttl??"na"}:${I?.manageable??"na"}`)]}),e.jsx(Ke,{open:k,onOpenChange:W,children:e.jsxs(Qe,{className:"mt-3 pt-3 border-t border-muted",children:[e.jsx("h4",{className:"text-xs font-medium text-muted-foreground mb-3",children:t("proxyStatusWidget.versionManagement")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Ye,{value:N,onValueChange:te,disabled:c,children:[e.jsx(Je,{className:"h-8 text-xs flex-1",children:e.jsx(Xe,{placeholder:t("proxyStatusWidget.selectVersionPlaceholder")})}),e.jsx(Ze,{children:o?.versions.slice(0,20).map(i=>{const T=o?.maxStableVersion&&ce(i,o.maxStableVersion),ie=o?.faultyRange&&ue(i,o.faultyRange.min,o.faultyRange.max);return e.jsx(et,{value:i,className:"text-xs",children:e.jsxs("span",{className:"flex items-center gap-2",children:["v",i,i===o.latestStable&&e.jsx("span",{className:"text-green-600 dark:text-green-400",children:t("proxyStatusWidget.stable")}),(ie||T)&&e.jsx("span",{className:"text-amber-600 dark:text-amber-400",children:"⚠"})]})},i)})})]}),e.jsxs($,{variant:"outline",size:"sm",className:"h-8 text-xs gap-1.5 px-3",onClick:()=>void be(N),disabled:v.isPending||!N,children:[v.isPending?e.jsx(z,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Gt,{className:"w-3.5 h-3.5"}),t("proxyStatusWidget.install")]})]}),N&&o?.maxStableVersion&&ce(N,o.maxStableVersion)&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-[11px] text-amber-600 dark:text-amber-400",children:[e.jsx(de,{className:"w-3.5 h-3.5 flex-shrink-0"}),e.jsx("span",{children:t("proxyStatusWidget.versionsAboveUnstable",{version:o.maxStableVersion})})]}),N&&o?.faultyRange&&ue(N,o.faultyRange.min,o.faultyRange.max)&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-[11px] text-amber-600 dark:text-amber-400",children:[e.jsx(de,{className:"w-3.5 h-3.5 flex-shrink-0"}),e.jsx("span",{children:t("proxyStatusWidget.versionsKnownIssues",{version:N})})]}),a?.checkedAt&&e.jsx("div",{className:"mt-2 text-[10px] text-muted-foreground/60",children:t("proxyStatusWidget.lastChecked",{time:$t(a.checkedAt,t)})})]})}),!K&&e.jsxs("div",{className:"mt-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:t("proxyStatusWidget.notRunning")}),e.jsxs($,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>C.mutate(),disabled:C.isPending,children:[C.isPending?e.jsx(z,{className:"w-3 h-3 animate-spin"}):e.jsx(Tt,{className:"w-3 h-3"}),t("proxyStatusWidget.start")]})]}),e.jsx(at,{open:D,onOpenChange:G,children:e.jsxs(ot,{children:[e.jsxs(it,{children:[e.jsxs(lt,{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-5 h-5 text-amber-500"}),t(l==="faulty"?"proxyStatusWidget.installFaultyTitle":"proxyStatusWidget.installUnstableTitle")]}),e.jsxs(dt,{className:"space-y-2",children:[l==="faulty"?e.jsx("p",{children:e.jsx(ve,{i18nKey:"proxyStatusWidget.installFaultyDesc",values:{version:O??"",range:Te||""},components:{strong:e.jsx("strong",{})}})}):e.jsx("p",{children:e.jsx(ve,{i18nKey:"proxyStatusWidget.installUnstableDesc",values:{version:O??"",maxStable:he},components:{strong:e.jsx("strong",{})}})}),e.jsx("p",{className:"text-amber-600 dark:text-amber-400",children:t(l==="faulty"?"proxyStatusWidget.installFaultyWarning":"proxyStatusWidget.installUnstableWarning")}),e.jsx("p",{children:t("proxyStatusWidget.installUnstableConfirm")})]})]}),e.jsxs(ct,{children:[e.jsx(ut,{onClick:We,children:t("proxyStatusWidget.cancel")}),e.jsx(xt,{onClick:Pe,className:"bg-amber-500 hover:bg-amber-600 text-white",children:t("proxyStatusWidget.installAnyway")})]})]})})]})})}export{Kt as P};