@kaitranntt/ccs 7.10.0 → 7.11.0-dev.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 (49) hide show
  1. package/dist/cliproxy/cliproxy-executor.d.ts.map +1 -1
  2. package/dist/cliproxy/cliproxy-executor.js +2 -1
  3. package/dist/cliproxy/cliproxy-executor.js.map +1 -1
  4. package/dist/cliproxy/config-generator.d.ts.map +1 -1
  5. package/dist/cliproxy/config-generator.js +32 -0
  6. package/dist/cliproxy/config-generator.js.map +1 -1
  7. package/dist/cliproxy/proxy-config-resolver.d.ts +5 -1
  8. package/dist/cliproxy/proxy-config-resolver.d.ts.map +1 -1
  9. package/dist/cliproxy/proxy-config-resolver.js +20 -0
  10. package/dist/cliproxy/proxy-config-resolver.js.map +1 -1
  11. package/dist/cliproxy/types.d.ts +2 -0
  12. package/dist/cliproxy/types.d.ts.map +1 -1
  13. package/dist/commands/help-command.d.ts.map +1 -1
  14. package/dist/commands/help-command.js +2 -0
  15. package/dist/commands/help-command.js.map +1 -1
  16. package/dist/config/unified-config-types.d.ts +2 -0
  17. package/dist/config/unified-config-types.d.ts.map +1 -1
  18. package/dist/config/unified-config-types.js.map +1 -1
  19. package/dist/ui/assets/{accounts-CmzZXhfc.js → accounts-DqxAfY13.js} +1 -1
  20. package/dist/ui/assets/{alert-dialog-zpnBn2CA.js → alert-dialog-BHdqW7k5.js} +1 -1
  21. package/dist/ui/assets/api-4P5LsOJB.js +1 -0
  22. package/dist/ui/assets/{auth-section-YgJ7Cv--.js → auth-section-CZI_qq1y.js} +1 -1
  23. package/dist/ui/assets/{card-dTUi3LxW.js → card-Bulg0XJ5.js} +1 -1
  24. package/dist/ui/assets/{cliproxy-control-panel-BRCh_7b3.js → cliproxy-control-panel-D4Pu1d6D.js} +1 -1
  25. package/dist/ui/assets/cliproxy-ukpwQdNn.js +3 -0
  26. package/dist/ui/assets/{confirm-dialog-ByfOsjk9.js → confirm-dialog-DCQuLIGr.js} +1 -1
  27. package/dist/ui/assets/copilot-DDDnyI2K.js +4 -0
  28. package/dist/ui/assets/{globalenv-section-BEpPTvKo.js → globalenv-section-Ch0loP2P.js} +1 -1
  29. package/dist/ui/assets/{health-DTRd-dXk.js → health-TFV-WeFP.js} +1 -1
  30. package/dist/ui/assets/{index-CEZrgkam.js → index-BIVI81o6.js} +1 -1
  31. package/dist/ui/assets/{index-BLoAjpcw.js → index-BsQ0Wso6.js} +1 -1
  32. package/dist/ui/assets/{index-QeBLfRj8.js → index-Caz6CssQ.js} +11 -11
  33. package/dist/ui/assets/{index-Bfwze8tN.js → index-OeLTUMco.js} +1 -1
  34. package/dist/ui/assets/{shared-BgDSyHKz.js → shared-BR10NN3P.js} +1 -1
  35. package/dist/ui/assets/{switch-B0PXGFIv.js → switch-CYCod1F-.js} +1 -1
  36. package/dist/ui/index.html +1 -1
  37. package/dist/web-server/routes/profile-routes.d.ts.map +1 -1
  38. package/dist/web-server/routes/profile-routes.js +9 -0
  39. package/dist/web-server/routes/profile-routes.js.map +1 -1
  40. package/dist/web-server/routes/settings-routes.d.ts.map +1 -1
  41. package/dist/web-server/routes/settings-routes.js +19 -0
  42. package/dist/web-server/routes/settings-routes.js.map +1 -1
  43. package/dist/web-server/routes/variant-routes.d.ts.map +1 -1
  44. package/dist/web-server/routes/variant-routes.js +6 -1
  45. package/dist/web-server/routes/variant-routes.js.map +1 -1
  46. package/package.json +1 -1
  47. package/dist/ui/assets/api-DFbZVPK4.js +0 -1
  48. package/dist/ui/assets/cliproxy-CsqKCFzj.js +0 -3
  49. package/dist/ui/assets/copilot-BQscualu.js +0 -4
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-uXQB-q0u.js";import{r as f,c as fe}from"./react-vendor-B_CU-WTZ.js";import{u as M,S as h,c as d,P as y,B as I,a as H,b as ee,d as pe,e as se,C as ge,g as te,f as je,h as Ne,i as ye,j as be}from"./index-QeBLfRj8.js";import{C as p,a as g,b as N,c as S}from"./card-dTUi3LxW.js";import{x as we,a2 as ae,a3 as z,a4 as re,v as ne,Q as ve,G as ke,a5 as Ce,a0 as $e,t as Y,U as Se,Z as le,q as Le,_ as G,a6 as De,s as Te,b as Fe,a7 as Re,a8 as Me}from"./icons-CwFZAiDB.js";import{u as Pe,a as P}from"./tanstack-Coed0rqz.js";import{K as D,L as Q,f as k,H as Ae}from"./utils-CzKF5WmX.js";import{R as ie,A as Be,C as Ue,X as qe,Y as V,T as oe,a as Z,P as Ie,b as Oe,c as Ke}from"./charts-CJC4bH8P.js";import"./notifications-dJQY2-U6.js";import"./form-utils-kUVlZZAO.js";import"./code-highlight-DKN39ySy.js";function Ee({data:s,isLoading:t}){const{privacyMode:a}=M();if(t)return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-5 gap-4",children:[1,2,3,4,5].map(o=>e.jsx(p,{children:e.jsx(g,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{className:"h-4 w-[100px]"}),e.jsx(h,{className:"h-8 w-[80px]"})]}),e.jsx(h,{className:"h-8 w-8 rounded-lg"})]})})},o))});const l=(s?.tokenBreakdown?.cacheCreation?.cost??0)+(s?.tokenBreakdown?.cacheRead?.cost??0),r=s?.totalCost?Math.round(l/s.totalCost*100):0,i=[{title:"Total Tokens",value:s?.totalTokens??0,icon:we,format:o=>R(o),color:"text-blue-600",bgColor:"bg-blue-100 dark:bg-blue-900/20",subtitle:`${R(s?.totalInputTokens??0)} in / ${R(s?.totalOutputTokens??0)} out`},{title:"Total Cost",value:s?.totalCost??0,icon:ae,format:o=>`$${o.toFixed(2)}`,color:"text-green-600",bgColor:"bg-green-100 dark:bg-green-900/20",subtitle:`$${s?.averageCostPerDay?.toFixed(2)??"0.00"}/day avg`},{title:"Cache Tokens",value:s?.totalCacheTokens??0,icon:z,format:o=>R(o),color:"text-cyan-600",bgColor:"bg-cyan-100 dark:bg-cyan-900/20",subtitle:`$${l.toFixed(2)} (${r}% of cost)`},{title:"Input Cost",value:s?.tokenBreakdown?.input?.cost??0,icon:re,format:o=>`$${o.toFixed(2)}`,color:"text-purple-600",bgColor:"bg-purple-100 dark:bg-purple-900/20",subtitle:`${R(s?.tokenBreakdown?.input?.tokens??0)} tokens`},{title:"Output Cost",value:s?.tokenBreakdown?.output?.cost??0,icon:ne,format:o=>`$${o.toFixed(2)}`,color:"text-orange-600",bgColor:"bg-orange-100 dark:bg-orange-900/20",subtitle:`${R(s?.tokenBreakdown?.output?.tokens??0)} tokens`}];return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-5 gap-4",children:i.map((o,n)=>{const c=o.icon;return e.jsx(p,{className:"hover:shadow-md transition-shadow",children:e.jsx(g,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between space-x-2",children:[e.jsxs("div",{className:"space-y-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground truncate",children:o.title}),e.jsx("p",{className:d("text-xl font-bold truncate",a&&y),children:o.format(o.value)}),o.subtitle&&e.jsx("p",{className:d("text-[10px] text-muted-foreground truncate",a&&y),children:o.subtitle})]}),e.jsx("div",{className:d("p-2 rounded-lg shrink-0",o.bgColor),children:e.jsx(c,{className:d("h-4 w-4",o.color)})})]})})},n)})})}function R(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function Ge({model:s}){const{privacyMode:t}=M(),a=We(s.ioRatio);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"h-4 w-4 text-primary shrink-0"}),e.jsx("h4",{className:"font-semibold leading-none truncate",title:s.model,children:s.model})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(I,{variant:"secondary",className:"text-[10px] h-5 px-1.5",children:[s.percentage.toFixed(1),"% usage"]}),e.jsxs(I,{variant:a.variant,className:"text-[10px] h-5 px-1.5",children:[s.ioRatio.toFixed(0),":1 I/O"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("p",{className:d("text-lg font-bold",t&&y),children:["$",s.cost.toFixed(2)]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Total Cost"})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsx("p",{className:d("text-lg font-bold",t&&y),children:_e(s.tokens)}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Total Tokens"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h5",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wider",children:"Token Breakdown"}),e.jsxs("div",{className:d("space-y-1",t&&y),children:[e.jsx(W,{label:"Input",tokens:s.inputTokens,cost:s.costBreakdown.input.cost,color:"#335c67",icon:re}),e.jsx(W,{label:"Output",tokens:s.outputTokens,cost:s.costBreakdown.output.cost,color:"#fff3b0",icon:ne}),e.jsx(W,{label:"Cache Write",tokens:s.cacheCreationTokens,cost:s.costBreakdown.cacheCreation.cost,color:"#e09f3e",icon:z}),e.jsx(W,{label:"Cache Read",tokens:s.cacheReadTokens,cost:s.costBreakdown.cacheRead.cost,color:"#9e2a2b",icon:z})]})]}),e.jsxs("div",{className:"p-2.5 rounded-md border bg-muted/20 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:"Input/Output Ratio"})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-snug",children:a.description})]})]})}function W({label:s,tokens:t,cost:a,color:l,icon:r}){return t===0?null:e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("div",{className:"w-1 h-6 rounded-full shrink-0",style:{backgroundColor:l}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium truncate",children:s}),e.jsxs("span",{className:"font-mono text-muted-foreground",children:["$",a.toFixed(3)]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[e.jsx(r,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:He(t)})]})]})]})}function We(s){return s>=200?{variant:"destructive",description:"Extended thinking or large context loading. Expected for reasoning models."}:s>=50?{variant:"secondary",description:"More input than output. Typical for analysis tasks."}:s>=5?{variant:"outline",description:"Balanced input/output ratio for typical coding tasks."}:{variant:"default",description:"More output than input. Generation-heavy workload."}}function He(s){return s.toLocaleString()}function _e(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}const ze="/api";function w(s){const t=s.getFullYear(),a=String(s.getMonth()+1).padStart(2,"0"),l=String(s.getDate()).padStart(2,"0");return`${t}${a}${l}`}const T={summary:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/summary?${t}`)},trends:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/daily?${t}`)},hourly:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),L(`/usage/hourly?${t}`)},models:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/models?${t}`)},sessions:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),s?.limit&&t.append("limit",s.limit.toString()),s?.offset&&t.append("offset",s.offset.toString()),L(`/usage/sessions?${t}`)},monthly:(s,t)=>{const a=new URLSearchParams;return s&&a.append("months",s.toString()),t&&a.append("profile",t),L(`/usage/monthly?${a}`)},refresh:async()=>{if(!(await fetch(`${ze}/usage/refresh`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to refresh usage cache")},status:()=>L("/usage/status"),insights:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/insights?${t}`)}};async function L(s){const a=await fetch(`/api${s}`,{headers:{"Content-Type":"application/json"}});if(!a.ok){const r=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(r.error||a.statusText)}const l=await a.json();return l.data||l}function Qe(s){return P({queryKey:["usage","summary",s],queryFn:()=>T.summary(s),staleTime:60*1e3})}function Ye(s){return P({queryKey:["usage","trends",s],queryFn:()=>T.trends(s),staleTime:60*1e3})}function Ve(s){return P({queryKey:["usage","hourly",s],queryFn:()=>T.hourly(s),staleTime:60*1e3})}function Ze(s){return P({queryKey:["usage","models",s],queryFn:()=>T.models(s),staleTime:60*1e3})}function Xe(){const s=Pe();return f.useCallback(async()=>{await T.refresh(),await s.invalidateQueries({queryKey:["usage"]})},[s])}function Je(){return P({queryKey:["usage","status"],queryFn:()=>T.status(),staleTime:10*1e3,refetchInterval:30*1e3})}function es(s){return P({queryKey:["usage","sessions",s],queryFn:()=>T.sessions(s),staleTime:60*1e3})}function ss(){const[s,t]=f.useState({from:D(new Date,30),to:new Date}),[a,l]=f.useState(!1),[r,i]=f.useState(null),[o,n]=f.useState(null),[c,x]=f.useState("daily"),u=Xe(),m=f.useCallback(async()=>{l(!0);try{await u()}finally{l(!1)}},[u]),j=f.useMemo(()=>({startDate:s?.from,endDate:s?.to}),[s?.from,s?.to]),{data:b,isLoading:v}=Qe(j),{data:C,isLoading:$}=Ye(j),{data:A,isLoading:B}=Ve(j),{data:U,isLoading:q}=Ze(j),{data:_,isLoading:O}=es({...j,limit:3}),{data:K}=Je(),ce=f.useCallback(()=>{const F=new Date;t({from:D(F,1),to:F}),x("hourly")},[]),de=f.useCallback(F=>{t(F),x("daily")},[]),xe=f.useMemo(()=>K?.lastFetch?Q(new Date(K.lastFetch),{addSuffix:!0}):null,[K?.lastFetch]),ue=f.useCallback((F,he)=>{const E=he.currentTarget.getBoundingClientRect();n({x:E.left+E.width/2,y:E.top+E.height/2}),i(F)},[]),me=f.useCallback(()=>{i(null),n(null)},[]);return{dateRange:s,isRefreshing:a,viewMode:c,selectedModel:r,popoverPosition:o,summary:b,trends:C,hourlyData:A,models:U,sessions:_,status:K,isSummaryLoading:v,isTrendsLoading:$,isHourlyLoading:B,isModelsLoading:q,isSessionsLoading:O,isLoading:v||$||q||O,handleRefresh:m,handleTodayClick:ce,handleDateRangeChange:de,handleModelClick:ue,handlePopoverClose:me,lastUpdatedText:xe}}function ts({value:s,onChange:t,presets:a=[{label:"Last 7 days",range:{from:D(new Date,7),to:new Date}},{label:"Last 30 days",range:{from:D(new Date,30),to:new Date}},{label:"Last 90 days",range:{from:D(new Date,90),to:new Date}}],className:l}){const[r,i]=fe.useState(!1),o=n=>!s||!s.from||!s.to||!n.from||!n.to?!1:k(s.from,"yyyy-MM-dd")===k(n.from,"yyyy-MM-dd")&&k(s.to,"yyyy-MM-dd")===k(n.to,"yyyy-MM-dd");return e.jsxs("div",{className:d("flex items-center gap-2",l),children:[a.map(n=>e.jsx(H,{variant:o(n.range)?"default":"outline",size:"sm",onClick:()=>t(n.range),children:n.label},n.label)),e.jsxs(ee,{open:r,onOpenChange:i,children:[e.jsx(pe,{asChild:!0,children:e.jsxs(H,{id:"date",variant:"outline",className:d("w-auto min-w-[240px] justify-start text-left font-normal",!s&&"text-muted-foreground"),children:[e.jsx(Ce,{className:"mr-2 h-4 w-4"}),s?.from?s.to?e.jsxs(e.Fragment,{children:[k(s.from,"LLL dd, y")," - ",k(s.to,"LLL dd, y")]}):k(s.from,"LLL dd, y"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(se,{className:"w-auto p-0",align:"end",children:e.jsx(ge,{initialFocus:!0,mode:"range",defaultMonth:s?.from,selected:s,onSelect:t,numberOfMonths:2})})]})]})}function as({dateRange:s,onDateRangeChange:t,onTodayClick:a,onRefresh:l,isRefreshing:r,lastUpdatedText:i,viewMode:o}){return e.jsxs("div",{className:"flex items-center justify-between shrink-0",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Analytics"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Track usage & insights"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{variant:o==="hourly"?"default":"outline",size:"sm",className:"h-8",onClick:a,children:"24H"}),e.jsx(ts,{value:s,onChange:t,presets:[{label:"7D",range:{from:D(new Date,7),to:new Date}},{label:"30D",range:{from:D(new Date,30),to:new Date}},{label:"Month",range:{from:Ae(new Date),to:new Date}},{label:"All Time",range:{from:void 0,to:new Date}}]}),i&&e.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:["Updated ",i]}),e.jsx(H,{variant:"outline",size:"sm",className:"gap-2 h-8",onClick:l,disabled:r,children:e.jsx($e,{className:`w-3.5 h-3.5 ${r?"animate-spin":""}`})})]})]})}function rs({data:s,isLoading:t,granularity:a="daily",className:l}){const{privacyMode:r}=M(),i=f.useMemo(()=>!s||s.length===0?[]:(a==="hourly"?s:[...s].reverse()).map(c=>{const x="hour"in c?c.hour:c.date;return{...c,dateFormatted:ns(x,a),costRounded:Number(c.cost.toFixed(4))}}),[s,a]);if(t)return e.jsx(h,{className:d("h-full w-full",l)});if(!s||s.length===0)return e.jsx("div",{className:d("h-full flex items-center justify-center",l),children:e.jsx("p",{className:"text-muted-foreground",children:a==="hourly"?"No usage data for today":"No usage data available"})});const o=({x:n,y:c,payload:x,isRight:u})=>{const m=u?`$${x.value}`:X(Number(x.value));return e.jsx("text",{x:n,y:c,dy:4,textAnchor:u?"start":"end",fontSize:12,fill:"currentColor",className:d("fill-muted-foreground",r&&"blur-[4px]"),children:m})};return e.jsx("div",{className:d("w-full h-full",l),children:e.jsx(ie,{width:"100%",height:"100%",children:e.jsxs(Be,{data:i,margin:{top:5,right:30,left:20,bottom:5},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"tokenGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#0080FF",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#0080FF",stopOpacity:.1})]}),e.jsxs("linearGradient",{id:"costGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#00C49F",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#00C49F",stopOpacity:.1})]})]}),e.jsx(Ue,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(qe,{dataKey:"dateFormatted",tick:{fontSize:12},tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(V,{yAxisId:"left",orientation:"left",tick:n=>e.jsx(o,{...n,isRight:!1}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(V,{yAxisId:"right",orientation:"right",tick:n=>e.jsx(o,{...n,isRight:!0}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(oe,{content:({active:n,payload:c,label:x})=>{if(!n||!c||!c.length)return null;const u=c[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-3 shadow-lg",children:[e.jsx("p",{className:"font-medium mb-2",children:x}),c.map((m,j)=>e.jsxs("p",{className:d("text-sm",r&&y),style:{color:m.color},children:[m.name,":"," ",m.name==="Tokens"?X(Number(m.value)||0):`$${m.value}`]},j)),"requests"in u&&e.jsxs("p",{className:d("text-sm text-muted-foreground mt-1",r&&y),children:["Requests: ",u.requests]})]})}}),e.jsx(Z,{yAxisId:"left",type:"monotone",dataKey:"tokens",stroke:"#0080FF",strokeWidth:2,fillOpacity:1,fill:"url(#tokenGradient)",name:"Tokens"}),e.jsx(Z,{yAxisId:"right",type:"monotone",dataKey:"costRounded",stroke:"#00C49F",strokeWidth:2,fillOpacity:1,fill:"url(#costGradient)",name:"Cost"})]})})})}function ns(s,t){if(t==="hourly"){const[l,r]=s.split(" ");if(l&&r){const i=new Date(`${l}T${r}:00Z`);return k(i,"HH:mm")}return s}const a=new Date(s);return t==="monthly"?k(a,"MMM yyyy"):k(a,"MMM dd")}function X(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function ls({data:s,isLoading:t,className:a}){const{privacyMode:l}=M(),r=f.useMemo(()=>!s||s.length===0?[]:s.map(n=>({name:n.model,value:n.tokens,cost:n.cost,percentage:n.percentage,fill:te(n.model)})),[s]);if(t)return e.jsx(h,{className:d("h-[300px] w-full",a)});if(!s||s.length===0)return e.jsx("div",{className:d("h-[300px] flex items-center justify-center",a),children:e.jsx("p",{className:"text-muted-foreground",children:"No model data available"})});const i=({active:n,payload:c})=>{if(!n||!c)return null;const x=c;if(!x.length)return null;const u=x[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-2 shadow-lg text-xs",children:[e.jsx("p",{className:"font-medium mb-1",children:u.name}),e.jsxs("p",{className:d("text-muted-foreground",l&&y),children:[is(u.value)," (",u.percentage.toFixed(1),"%)"]}),e.jsxs("p",{className:d("text-muted-foreground",l&&y),children:["$",u.cost.toFixed(4)]})]})},o=n=>n.percentage>5?`${n.percentage.toFixed(1)}%`:"";return e.jsx("div",{className:d("w-full",a),children:e.jsx(ie,{width:"100%",height:250,children:e.jsxs(Ie,{children:[e.jsx(Oe,{data:r,cx:"50%",cy:"50%",labelLine:!1,label:o,innerRadius:50,outerRadius:70,paddingAngle:2,dataKey:"value",children:r.map((n,c)=>e.jsx(Ke,{fill:n.fill,strokeWidth:1},`cell-${c}`))}),e.jsx(oe,{content:i})]})})})}function is(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function os({data:s,isLoading:t,className:a}){const{privacyMode:l}=M(),r=f.useMemo(()=>{if(!s?.sessions||s.sessions.length===0)return null;const i=s.sessions,o=s.total,n=i.reduce((b,v)=>b+(v.inputTokens+v.outputTokens),0),c=Math.round(n/i.length),u=i.reduce((b,v)=>b+v.cost,0)/i.length,m=i[0],j=m?Q(new Date(m.lastActivity),{addSuffix:!0}):"N/A";return{totalSessions:o,avgTokens:c,avgCost:u,lastActive:j,recentSessions:i.slice(0,3)}},[s]);return t?e.jsxs(p,{className:d("flex flex-col h-full",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsx(h,{className:"h-5 w-32"})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx(h,{className:"h-full w-full"})})]}):r?e.jsxs(p,{className:d("flex flex-col h-full shadow-sm",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Y,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsxs(g,{className:"px-3 pb-3 pt-0 flex-1 flex flex-col gap-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-blue-600 dark:text-blue-400",children:[e.jsx(Se,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xl font-bold",children:r.totalSessions})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:"Total Sessions"})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-green-600 dark:text-green-400",children:[e.jsx(le,{className:"w-4 h-4"}),e.jsxs("span",{className:d("text-xl font-bold",l&&y),children:["$",r.avgCost.toFixed(2)]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:"Avg Cost/Session"})]})]}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground font-medium mb-1",children:[e.jsx(Le,{className:"w-3 h-3"}),"Recent Activity"]}),e.jsx("div",{className:"space-y-1.5",children:r.recentSessions.map(i=>e.jsxs("div",{className:"flex items-center justify-between text-xs p-1.5 rounded bg-muted/30 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[e.jsx("span",{className:"font-medium truncate",title:i.projectPath,children:i.projectPath.split("/").pop()}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:Q(new Date(i.lastActivity),{addSuffix:!0})})]}),e.jsxs("div",{className:d("text-right shrink-0 ml-2",l&&y),children:[e.jsxs("div",{className:"font-mono",children:["$",i.cost.toFixed(2)]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[cs(i.inputTokens+i.outputTokens)," toks"]})]})]},i.sessionId))})]})]})]}):e.jsxs(p,{className:d("flex flex-col h-full",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Y,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:"No session data available"})})]})}function cs(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}function ds({className:s,isLoading:t}){const{data:a,isLoading:l}=je(),{data:r,isLoading:i,error:o}=Ne(a?.running);if(t||l||a?.running&&i)return e.jsxs(p,{className:d("flex flex-col h-full",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(h,{className:"h-4 w-[100px]"}),e.jsx(h,{className:"h-16 w-full"})]})})]});if(!a?.running)return e.jsxs(p,{className:d("flex flex-col h-full border-dashed",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4 text-muted-foreground"}),"CLIProxy Stats"]}),e.jsx(I,{variant:"secondary",className:"text-[10px] h-5",children:"Offline"})]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Start a CLIProxy session (gemini, codex, agy) to collect stats."})})]});if(o)return e.jsxs(p,{className:d("flex flex-col h-full border-destructive/50",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsx(I,{variant:"destructive",className:"text-[10px] h-5",children:"Error"})]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx("p",{className:"text-xs text-destructive",children:o.message})})]});const c=r?.totalRequests??0,x=r?.quotaExceededCount??0,u=c-x,m=c>0?Math.round(u/c*100):100,j=r?.tokens?.total??0,b=Object.entries(r?.requestsByModel??{}).sort((C,$)=>$[1]-C[1]).slice(0,4),v=b.length>0?b[0][1]:1;return e.jsxs(p,{className:d("flex flex-col h-full overflow-hidden",s),children:[e.jsx(N,{className:"px-3 py-2 border-b bg-muted/5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsxs(I,{variant:"outline",className:"text-[10px] h-5 text-green-600 border-green-200 bg-green-50 dark:bg-green-900/10 dark:border-green-800",children:[e.jsx(le,{className:"h-3 w-3 mr-0.5"}),"Running"]})]})}),e.jsx(g,{className:"p-0 flex-1 min-h-0",children:e.jsx(ye,{className:"h-full",children:e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("svg",{className:"w-10 h-10 -rotate-90",viewBox:"0 0 36 36",children:[e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",className:"text-muted/30"}),e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeDasharray:`${m*.88} 88`,strokeLinecap:"round",className:m>=90?"text-green-500":"text-amber-500"})]}),e.jsxs("span",{className:"absolute inset-0 flex items-center justify-center text-[8px] font-bold",children:[m,"%"]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:J(c)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:x>0?`${x} failed`:"All success"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsx("div",{className:"p-1.5 rounded-md bg-purple-100 dark:bg-purple-900/20",children:e.jsx(De,{className:"h-4 w-4 text-purple-600"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:J(j)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:"Total tokens"})]})]})]}),b.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium text-muted-foreground",children:[e.jsx(Te,{className:"h-3 w-3"}),"Models Used"]}),e.jsx("div",{className:"space-y-1",children:b.map(([C,$])=>{const A=Math.round($/v*100),B=xs(C);return e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] mb-0.5",children:[e.jsx("span",{className:"truncate font-medium",title:C,children:B}),e.jsx("span",{className:"text-muted-foreground shrink-0 ml-2",children:$})]}),e.jsx("div",{className:"h-1 bg-muted/50 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-accent/70 rounded-full transition-all",style:{width:`${A}%`}})})]},C)})})]})]})})})]})}function J(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function xs(s){let t=s.replace(/^gemini-claude-/,"").replace(/^gemini-/,"").replace(/^claude-/,"").replace(/^anthropic\./,"").replace(/-thinking$/," Thinking");return t=t.split(/[-_]/).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" "),t.length>20&&(t=t.slice(0,18)+"..."),t}function us(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(0)}K`:s.toString()}function ms({models:s,isLoading:t,onModelClick:a,privacyMode:l}){return e.jsxs(p,{className:"flex flex-col h-full min-h-0 shadow-sm lg:col-span-4",children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(ae,{className:"w-4 h-4"}),"Cost by Model"]})}),e.jsx(g,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 overflow-y-auto",children:t?e.jsx(h,{className:"h-full w-full"}):e.jsxs("div",{className:"space-y-0.5",children:[[...s||[]].sort((r,i)=>i.cost-r.cost).map(r=>e.jsxs("button",{className:"group flex items-center text-xs w-full hover:bg-muted/50 rounded px-2 py-1.5 transition-colors cursor-pointer gap-3",onClick:i=>a(r,i),title:"Click for details",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 w-[180px] shrink-0",children:[e.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:te(r.model)}}),e.jsx("span",{className:"font-medium truncate group-hover:underline underline-offset-2",children:r.model})]}),e.jsx(hs,{model:r}),e.jsx("span",{className:d("text-[10px] text-muted-foreground w-14 text-right shrink-0",l&&y),children:us(r.tokens)}),e.jsxs("span",{className:d("font-mono font-medium w-16 text-right shrink-0",l&&y),children:["$",r.cost.toFixed(2)]}),e.jsx(Fe,{className:"w-3 h-3 opacity-0 group-hover:opacity-50 transition-opacity shrink-0"})]},r.model)),e.jsx(fs,{})]})})]})}function hs({model:s}){const t={input:"#335c67",output:"#fff3b0",cacheWrite:"#e09f3e",cacheRead:"#9e2a2b"},a=l=>s.cost>0?l/s.cost*100:0;return e.jsx("div",{className:"flex-1 flex items-center gap-1 min-w-0",children:e.jsxs("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden flex",children:[e.jsx("div",{className:"h-full",style:{backgroundColor:t.input,width:`${a(s.costBreakdown.input.cost)}%`},title:`Input: $${s.costBreakdown.input.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.output,width:`${a(s.costBreakdown.output.cost)}%`},title:`Output: $${s.costBreakdown.output.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheWrite,width:`${a(s.costBreakdown.cacheCreation.cost)}%`},title:`Cache Write: $${s.costBreakdown.cacheCreation.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheRead,width:`${a(s.costBreakdown.cacheRead.cost)}%`},title:`Cache Read: $${s.costBreakdown.cacheRead.cost.toFixed(2)}`})]})})}function fs(){const s=[{color:"#335c67",label:"Input"},{color:"#fff3b0",label:"Output",hasBorder:!0},{color:"#e09f3e",label:"Cache Write"},{color:"#9e2a2b",label:"Cache Read"}];return e.jsx("div",{className:"flex items-center gap-3 pt-2 px-2 text-[10px] text-muted-foreground border-t mt-2",children:s.map(({color:t,label:a,hasBorder:l})=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("div",{className:d("w-2 h-2 rounded-full",l&&"border border-muted-foreground/30"),style:{backgroundColor:t}}),a]},a))})}function ps({viewMode:s,trends:t,hourlyData:a,models:l,sessions:r,isTrendsLoading:i,isHourlyLoading:o,isModelsLoading:n,isSessionsLoading:c,isSummaryLoading:x,onModelClick:u}){const{privacyMode:m}=M();return e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 gap-4",children:[e.jsxs(p,{className:"flex flex-col flex-1 min-h-0 max-h-[500px] overflow-hidden shadow-sm",children:[e.jsx(N,{className:"px-3 py-2 shrink-0",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Re,{className:"w-4 h-4"}),s==="hourly"?"Last 24 Hours":"Usage Trends"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 min-h-0",children:e.jsx(rs,{data:s==="hourly"?a||[]:t||[],isLoading:s==="hourly"?o:i,granularity:s==="hourly"?"hourly":"daily"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-10 gap-4 h-auto lg:h-[180px] shrink-0",children:[e.jsx(ms,{models:l,isLoading:n,onModelClick:u,privacyMode:m}),e.jsxs(p,{className:"flex flex-col h-full min-h-0 shadow-sm lg:col-span-2",children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Me,{className:"w-4 h-4"}),"Model Usage"]})}),e.jsx(g,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 flex items-center justify-center",children:e.jsx(ls,{data:l||[],isLoading:n,className:"h-full w-full"})})]}),e.jsx(os,{data:r,isLoading:c,className:"lg:col-span-2"}),e.jsx(ds,{isLoading:x,className:"lg:col-span-2"})]})]})}function Ls(){return e.jsxs("div",{className:"space-y-4 h-full overflow-hidden",children:[e.jsxs(p,{className:"flex flex-col min-h-[300px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-32"})}),e.jsx(g,{className:"p-4 pt-0 flex-1",children:e.jsx(h,{className:"h-full w-full"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs(p,{className:"flex flex-col min-h-[250px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-28"})}),e.jsx(g,{className:"p-4 pt-2",children:e.jsx("div",{className:"space-y-3",children:[1,2,3,4,5].map(s=>e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{className:"w-2.5 h-2.5 rounded-full"}),e.jsx(h,{className:"h-3 w-24"})]}),e.jsx(h,{className:"h-3 w-16"})]},s))})})]}),e.jsxs(p,{className:"flex flex-col min-h-[250px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-28"})}),e.jsx(g,{className:"p-4 pt-0 flex-1",children:e.jsxs("div",{className:"flex w-full h-full items-center",children:[e.jsx("div",{className:"flex-1 flex justify-center",children:e.jsx(h,{className:"h-[180px] w-[180px] rounded-full"})}),e.jsx("div",{className:"w-[140px] shrink-0 pl-2 space-y-2",children:[1,2,3,4].map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{className:"w-2 h-2 rounded-full"}),e.jsx(h,{className:"h-3 w-20"})]},s))})]})})]})]})]})}function Ds(){const s=f.useRef(null),{dateRange:t,handleDateRangeChange:a,handleTodayClick:l,handleRefresh:r,isRefreshing:i,lastUpdatedText:o,viewMode:n,summary:c,isSummaryLoading:x,trends:u,hourlyData:m,models:j,sessions:b,isTrendsLoading:v,isHourlyLoading:C,isModelsLoading:$,isSessionsLoading:A,handleModelClick:B,selectedModel:U,popoverPosition:q,handlePopoverClose:_}=ss();return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden px-4 pt-4 pb-50 gap-4",children:[e.jsx(as,{dateRange:t,onDateRangeChange:a,onTodayClick:l,onRefresh:r,isRefreshing:i,lastUpdatedText:o,viewMode:n}),e.jsx(Ee,{data:c,isLoading:x}),e.jsx(ps,{viewMode:n,trends:u,hourlyData:m,models:j,sessions:b,isTrendsLoading:v,isHourlyLoading:C,isModelsLoading:$,isSessionsLoading:A,isSummaryLoading:x,onModelClick:B}),e.jsxs(ee,{open:!!U,onOpenChange:O=>!O&&_(),children:[e.jsx(be,{asChild:!0,children:e.jsx("div",{ref:s,className:"fixed pointer-events-none",style:{left:q?.x??0,top:q?.y??0,width:1,height:1}})}),e.jsx(se,{className:"w-80 p-3",side:"top",align:"center",children:U&&e.jsx(Ge,{model:U})})]})]})}export{Ds as AnalyticsPage,Ls as AnalyticsSkeleton};
1
+ import{j as e}from"./radix-ui-uXQB-q0u.js";import{r as f,c as fe}from"./react-vendor-B_CU-WTZ.js";import{u as M,S as h,c as d,P as y,B as I,a as H,b as ee,d as pe,e as se,C as ge,g as te,f as je,h as Ne,i as ye,j as be}from"./index-Caz6CssQ.js";import{C as p,a as g,b as N,c as S}from"./card-Bulg0XJ5.js";import{x as we,a2 as ae,a3 as z,a4 as re,v as ne,Q as ve,G as ke,a5 as Ce,a0 as $e,t as Y,U as Se,Z as le,q as Le,_ as G,a6 as De,s as Te,b as Fe,a7 as Re,a8 as Me}from"./icons-CwFZAiDB.js";import{u as Pe,a as P}from"./tanstack-Coed0rqz.js";import{K as D,L as Q,f as k,H as Ae}from"./utils-CzKF5WmX.js";import{R as ie,A as Be,C as Ue,X as qe,Y as V,T as oe,a as Z,P as Ie,b as Oe,c as Ke}from"./charts-CJC4bH8P.js";import"./notifications-dJQY2-U6.js";import"./form-utils-kUVlZZAO.js";import"./code-highlight-DKN39ySy.js";function Ee({data:s,isLoading:t}){const{privacyMode:a}=M();if(t)return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-5 gap-4",children:[1,2,3,4,5].map(o=>e.jsx(p,{children:e.jsx(g,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{className:"h-4 w-[100px]"}),e.jsx(h,{className:"h-8 w-[80px]"})]}),e.jsx(h,{className:"h-8 w-8 rounded-lg"})]})})},o))});const l=(s?.tokenBreakdown?.cacheCreation?.cost??0)+(s?.tokenBreakdown?.cacheRead?.cost??0),r=s?.totalCost?Math.round(l/s.totalCost*100):0,i=[{title:"Total Tokens",value:s?.totalTokens??0,icon:we,format:o=>R(o),color:"text-blue-600",bgColor:"bg-blue-100 dark:bg-blue-900/20",subtitle:`${R(s?.totalInputTokens??0)} in / ${R(s?.totalOutputTokens??0)} out`},{title:"Total Cost",value:s?.totalCost??0,icon:ae,format:o=>`$${o.toFixed(2)}`,color:"text-green-600",bgColor:"bg-green-100 dark:bg-green-900/20",subtitle:`$${s?.averageCostPerDay?.toFixed(2)??"0.00"}/day avg`},{title:"Cache Tokens",value:s?.totalCacheTokens??0,icon:z,format:o=>R(o),color:"text-cyan-600",bgColor:"bg-cyan-100 dark:bg-cyan-900/20",subtitle:`$${l.toFixed(2)} (${r}% of cost)`},{title:"Input Cost",value:s?.tokenBreakdown?.input?.cost??0,icon:re,format:o=>`$${o.toFixed(2)}`,color:"text-purple-600",bgColor:"bg-purple-100 dark:bg-purple-900/20",subtitle:`${R(s?.tokenBreakdown?.input?.tokens??0)} tokens`},{title:"Output Cost",value:s?.tokenBreakdown?.output?.cost??0,icon:ne,format:o=>`$${o.toFixed(2)}`,color:"text-orange-600",bgColor:"bg-orange-100 dark:bg-orange-900/20",subtitle:`${R(s?.tokenBreakdown?.output?.tokens??0)} tokens`}];return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-5 gap-4",children:i.map((o,n)=>{const c=o.icon;return e.jsx(p,{className:"hover:shadow-md transition-shadow",children:e.jsx(g,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between space-x-2",children:[e.jsxs("div",{className:"space-y-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground truncate",children:o.title}),e.jsx("p",{className:d("text-xl font-bold truncate",a&&y),children:o.format(o.value)}),o.subtitle&&e.jsx("p",{className:d("text-[10px] text-muted-foreground truncate",a&&y),children:o.subtitle})]}),e.jsx("div",{className:d("p-2 rounded-lg shrink-0",o.bgColor),children:e.jsx(c,{className:d("h-4 w-4",o.color)})})]})})},n)})})}function R(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function Ge({model:s}){const{privacyMode:t}=M(),a=We(s.ioRatio);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"h-4 w-4 text-primary shrink-0"}),e.jsx("h4",{className:"font-semibold leading-none truncate",title:s.model,children:s.model})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(I,{variant:"secondary",className:"text-[10px] h-5 px-1.5",children:[s.percentage.toFixed(1),"% usage"]}),e.jsxs(I,{variant:a.variant,className:"text-[10px] h-5 px-1.5",children:[s.ioRatio.toFixed(0),":1 I/O"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("p",{className:d("text-lg font-bold",t&&y),children:["$",s.cost.toFixed(2)]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Total Cost"})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsx("p",{className:d("text-lg font-bold",t&&y),children:_e(s.tokens)}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Total Tokens"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h5",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wider",children:"Token Breakdown"}),e.jsxs("div",{className:d("space-y-1",t&&y),children:[e.jsx(W,{label:"Input",tokens:s.inputTokens,cost:s.costBreakdown.input.cost,color:"#335c67",icon:re}),e.jsx(W,{label:"Output",tokens:s.outputTokens,cost:s.costBreakdown.output.cost,color:"#fff3b0",icon:ne}),e.jsx(W,{label:"Cache Write",tokens:s.cacheCreationTokens,cost:s.costBreakdown.cacheCreation.cost,color:"#e09f3e",icon:z}),e.jsx(W,{label:"Cache Read",tokens:s.cacheReadTokens,cost:s.costBreakdown.cacheRead.cost,color:"#9e2a2b",icon:z})]})]}),e.jsxs("div",{className:"p-2.5 rounded-md border bg-muted/20 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:"Input/Output Ratio"})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-snug",children:a.description})]})]})}function W({label:s,tokens:t,cost:a,color:l,icon:r}){return t===0?null:e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("div",{className:"w-1 h-6 rounded-full shrink-0",style:{backgroundColor:l}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium truncate",children:s}),e.jsxs("span",{className:"font-mono text-muted-foreground",children:["$",a.toFixed(3)]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[e.jsx(r,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:He(t)})]})]})]})}function We(s){return s>=200?{variant:"destructive",description:"Extended thinking or large context loading. Expected for reasoning models."}:s>=50?{variant:"secondary",description:"More input than output. Typical for analysis tasks."}:s>=5?{variant:"outline",description:"Balanced input/output ratio for typical coding tasks."}:{variant:"default",description:"More output than input. Generation-heavy workload."}}function He(s){return s.toLocaleString()}function _e(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}const ze="/api";function w(s){const t=s.getFullYear(),a=String(s.getMonth()+1).padStart(2,"0"),l=String(s.getDate()).padStart(2,"0");return`${t}${a}${l}`}const T={summary:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/summary?${t}`)},trends:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/daily?${t}`)},hourly:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),L(`/usage/hourly?${t}`)},models:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/models?${t}`)},sessions:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),s?.limit&&t.append("limit",s.limit.toString()),s?.offset&&t.append("offset",s.offset.toString()),L(`/usage/sessions?${t}`)},monthly:(s,t)=>{const a=new URLSearchParams;return s&&a.append("months",s.toString()),t&&a.append("profile",t),L(`/usage/monthly?${a}`)},refresh:async()=>{if(!(await fetch(`${ze}/usage/refresh`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to refresh usage cache")},status:()=>L("/usage/status"),insights:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",w(s.startDate)),s?.endDate&&t.append("until",w(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/insights?${t}`)}};async function L(s){const a=await fetch(`/api${s}`,{headers:{"Content-Type":"application/json"}});if(!a.ok){const r=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(r.error||a.statusText)}const l=await a.json();return l.data||l}function Qe(s){return P({queryKey:["usage","summary",s],queryFn:()=>T.summary(s),staleTime:60*1e3})}function Ye(s){return P({queryKey:["usage","trends",s],queryFn:()=>T.trends(s),staleTime:60*1e3})}function Ve(s){return P({queryKey:["usage","hourly",s],queryFn:()=>T.hourly(s),staleTime:60*1e3})}function Ze(s){return P({queryKey:["usage","models",s],queryFn:()=>T.models(s),staleTime:60*1e3})}function Xe(){const s=Pe();return f.useCallback(async()=>{await T.refresh(),await s.invalidateQueries({queryKey:["usage"]})},[s])}function Je(){return P({queryKey:["usage","status"],queryFn:()=>T.status(),staleTime:10*1e3,refetchInterval:30*1e3})}function es(s){return P({queryKey:["usage","sessions",s],queryFn:()=>T.sessions(s),staleTime:60*1e3})}function ss(){const[s,t]=f.useState({from:D(new Date,30),to:new Date}),[a,l]=f.useState(!1),[r,i]=f.useState(null),[o,n]=f.useState(null),[c,x]=f.useState("daily"),u=Xe(),m=f.useCallback(async()=>{l(!0);try{await u()}finally{l(!1)}},[u]),j=f.useMemo(()=>({startDate:s?.from,endDate:s?.to}),[s?.from,s?.to]),{data:b,isLoading:v}=Qe(j),{data:C,isLoading:$}=Ye(j),{data:A,isLoading:B}=Ve(j),{data:U,isLoading:q}=Ze(j),{data:_,isLoading:O}=es({...j,limit:3}),{data:K}=Je(),ce=f.useCallback(()=>{const F=new Date;t({from:D(F,1),to:F}),x("hourly")},[]),de=f.useCallback(F=>{t(F),x("daily")},[]),xe=f.useMemo(()=>K?.lastFetch?Q(new Date(K.lastFetch),{addSuffix:!0}):null,[K?.lastFetch]),ue=f.useCallback((F,he)=>{const E=he.currentTarget.getBoundingClientRect();n({x:E.left+E.width/2,y:E.top+E.height/2}),i(F)},[]),me=f.useCallback(()=>{i(null),n(null)},[]);return{dateRange:s,isRefreshing:a,viewMode:c,selectedModel:r,popoverPosition:o,summary:b,trends:C,hourlyData:A,models:U,sessions:_,status:K,isSummaryLoading:v,isTrendsLoading:$,isHourlyLoading:B,isModelsLoading:q,isSessionsLoading:O,isLoading:v||$||q||O,handleRefresh:m,handleTodayClick:ce,handleDateRangeChange:de,handleModelClick:ue,handlePopoverClose:me,lastUpdatedText:xe}}function ts({value:s,onChange:t,presets:a=[{label:"Last 7 days",range:{from:D(new Date,7),to:new Date}},{label:"Last 30 days",range:{from:D(new Date,30),to:new Date}},{label:"Last 90 days",range:{from:D(new Date,90),to:new Date}}],className:l}){const[r,i]=fe.useState(!1),o=n=>!s||!s.from||!s.to||!n.from||!n.to?!1:k(s.from,"yyyy-MM-dd")===k(n.from,"yyyy-MM-dd")&&k(s.to,"yyyy-MM-dd")===k(n.to,"yyyy-MM-dd");return e.jsxs("div",{className:d("flex items-center gap-2",l),children:[a.map(n=>e.jsx(H,{variant:o(n.range)?"default":"outline",size:"sm",onClick:()=>t(n.range),children:n.label},n.label)),e.jsxs(ee,{open:r,onOpenChange:i,children:[e.jsx(pe,{asChild:!0,children:e.jsxs(H,{id:"date",variant:"outline",className:d("w-auto min-w-[240px] justify-start text-left font-normal",!s&&"text-muted-foreground"),children:[e.jsx(Ce,{className:"mr-2 h-4 w-4"}),s?.from?s.to?e.jsxs(e.Fragment,{children:[k(s.from,"LLL dd, y")," - ",k(s.to,"LLL dd, y")]}):k(s.from,"LLL dd, y"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(se,{className:"w-auto p-0",align:"end",children:e.jsx(ge,{initialFocus:!0,mode:"range",defaultMonth:s?.from,selected:s,onSelect:t,numberOfMonths:2})})]})]})}function as({dateRange:s,onDateRangeChange:t,onTodayClick:a,onRefresh:l,isRefreshing:r,lastUpdatedText:i,viewMode:o}){return e.jsxs("div",{className:"flex items-center justify-between shrink-0",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Analytics"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Track usage & insights"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{variant:o==="hourly"?"default":"outline",size:"sm",className:"h-8",onClick:a,children:"24H"}),e.jsx(ts,{value:s,onChange:t,presets:[{label:"7D",range:{from:D(new Date,7),to:new Date}},{label:"30D",range:{from:D(new Date,30),to:new Date}},{label:"Month",range:{from:Ae(new Date),to:new Date}},{label:"All Time",range:{from:void 0,to:new Date}}]}),i&&e.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:["Updated ",i]}),e.jsx(H,{variant:"outline",size:"sm",className:"gap-2 h-8",onClick:l,disabled:r,children:e.jsx($e,{className:`w-3.5 h-3.5 ${r?"animate-spin":""}`})})]})]})}function rs({data:s,isLoading:t,granularity:a="daily",className:l}){const{privacyMode:r}=M(),i=f.useMemo(()=>!s||s.length===0?[]:(a==="hourly"?s:[...s].reverse()).map(c=>{const x="hour"in c?c.hour:c.date;return{...c,dateFormatted:ns(x,a),costRounded:Number(c.cost.toFixed(4))}}),[s,a]);if(t)return e.jsx(h,{className:d("h-full w-full",l)});if(!s||s.length===0)return e.jsx("div",{className:d("h-full flex items-center justify-center",l),children:e.jsx("p",{className:"text-muted-foreground",children:a==="hourly"?"No usage data for today":"No usage data available"})});const o=({x:n,y:c,payload:x,isRight:u})=>{const m=u?`$${x.value}`:X(Number(x.value));return e.jsx("text",{x:n,y:c,dy:4,textAnchor:u?"start":"end",fontSize:12,fill:"currentColor",className:d("fill-muted-foreground",r&&"blur-[4px]"),children:m})};return e.jsx("div",{className:d("w-full h-full",l),children:e.jsx(ie,{width:"100%",height:"100%",children:e.jsxs(Be,{data:i,margin:{top:5,right:30,left:20,bottom:5},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"tokenGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#0080FF",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#0080FF",stopOpacity:.1})]}),e.jsxs("linearGradient",{id:"costGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#00C49F",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#00C49F",stopOpacity:.1})]})]}),e.jsx(Ue,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(qe,{dataKey:"dateFormatted",tick:{fontSize:12},tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(V,{yAxisId:"left",orientation:"left",tick:n=>e.jsx(o,{...n,isRight:!1}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(V,{yAxisId:"right",orientation:"right",tick:n=>e.jsx(o,{...n,isRight:!0}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(oe,{content:({active:n,payload:c,label:x})=>{if(!n||!c||!c.length)return null;const u=c[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-3 shadow-lg",children:[e.jsx("p",{className:"font-medium mb-2",children:x}),c.map((m,j)=>e.jsxs("p",{className:d("text-sm",r&&y),style:{color:m.color},children:[m.name,":"," ",m.name==="Tokens"?X(Number(m.value)||0):`$${m.value}`]},j)),"requests"in u&&e.jsxs("p",{className:d("text-sm text-muted-foreground mt-1",r&&y),children:["Requests: ",u.requests]})]})}}),e.jsx(Z,{yAxisId:"left",type:"monotone",dataKey:"tokens",stroke:"#0080FF",strokeWidth:2,fillOpacity:1,fill:"url(#tokenGradient)",name:"Tokens"}),e.jsx(Z,{yAxisId:"right",type:"monotone",dataKey:"costRounded",stroke:"#00C49F",strokeWidth:2,fillOpacity:1,fill:"url(#costGradient)",name:"Cost"})]})})})}function ns(s,t){if(t==="hourly"){const[l,r]=s.split(" ");if(l&&r){const i=new Date(`${l}T${r}:00Z`);return k(i,"HH:mm")}return s}const a=new Date(s);return t==="monthly"?k(a,"MMM yyyy"):k(a,"MMM dd")}function X(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function ls({data:s,isLoading:t,className:a}){const{privacyMode:l}=M(),r=f.useMemo(()=>!s||s.length===0?[]:s.map(n=>({name:n.model,value:n.tokens,cost:n.cost,percentage:n.percentage,fill:te(n.model)})),[s]);if(t)return e.jsx(h,{className:d("h-[300px] w-full",a)});if(!s||s.length===0)return e.jsx("div",{className:d("h-[300px] flex items-center justify-center",a),children:e.jsx("p",{className:"text-muted-foreground",children:"No model data available"})});const i=({active:n,payload:c})=>{if(!n||!c)return null;const x=c;if(!x.length)return null;const u=x[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-2 shadow-lg text-xs",children:[e.jsx("p",{className:"font-medium mb-1",children:u.name}),e.jsxs("p",{className:d("text-muted-foreground",l&&y),children:[is(u.value)," (",u.percentage.toFixed(1),"%)"]}),e.jsxs("p",{className:d("text-muted-foreground",l&&y),children:["$",u.cost.toFixed(4)]})]})},o=n=>n.percentage>5?`${n.percentage.toFixed(1)}%`:"";return e.jsx("div",{className:d("w-full",a),children:e.jsx(ie,{width:"100%",height:250,children:e.jsxs(Ie,{children:[e.jsx(Oe,{data:r,cx:"50%",cy:"50%",labelLine:!1,label:o,innerRadius:50,outerRadius:70,paddingAngle:2,dataKey:"value",children:r.map((n,c)=>e.jsx(Ke,{fill:n.fill,strokeWidth:1},`cell-${c}`))}),e.jsx(oe,{content:i})]})})})}function is(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function os({data:s,isLoading:t,className:a}){const{privacyMode:l}=M(),r=f.useMemo(()=>{if(!s?.sessions||s.sessions.length===0)return null;const i=s.sessions,o=s.total,n=i.reduce((b,v)=>b+(v.inputTokens+v.outputTokens),0),c=Math.round(n/i.length),u=i.reduce((b,v)=>b+v.cost,0)/i.length,m=i[0],j=m?Q(new Date(m.lastActivity),{addSuffix:!0}):"N/A";return{totalSessions:o,avgTokens:c,avgCost:u,lastActive:j,recentSessions:i.slice(0,3)}},[s]);return t?e.jsxs(p,{className:d("flex flex-col h-full",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsx(h,{className:"h-5 w-32"})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx(h,{className:"h-full w-full"})})]}):r?e.jsxs(p,{className:d("flex flex-col h-full shadow-sm",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Y,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsxs(g,{className:"px-3 pb-3 pt-0 flex-1 flex flex-col gap-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-blue-600 dark:text-blue-400",children:[e.jsx(Se,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xl font-bold",children:r.totalSessions})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:"Total Sessions"})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-green-600 dark:text-green-400",children:[e.jsx(le,{className:"w-4 h-4"}),e.jsxs("span",{className:d("text-xl font-bold",l&&y),children:["$",r.avgCost.toFixed(2)]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:"Avg Cost/Session"})]})]}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground font-medium mb-1",children:[e.jsx(Le,{className:"w-3 h-3"}),"Recent Activity"]}),e.jsx("div",{className:"space-y-1.5",children:r.recentSessions.map(i=>e.jsxs("div",{className:"flex items-center justify-between text-xs p-1.5 rounded bg-muted/30 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[e.jsx("span",{className:"font-medium truncate",title:i.projectPath,children:i.projectPath.split("/").pop()}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:Q(new Date(i.lastActivity),{addSuffix:!0})})]}),e.jsxs("div",{className:d("text-right shrink-0 ml-2",l&&y),children:[e.jsxs("div",{className:"font-mono",children:["$",i.cost.toFixed(2)]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[cs(i.inputTokens+i.outputTokens)," toks"]})]})]},i.sessionId))})]})]})]}):e.jsxs(p,{className:d("flex flex-col h-full",a),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Y,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:"No session data available"})})]})}function cs(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}function ds({className:s,isLoading:t}){const{data:a,isLoading:l}=je(),{data:r,isLoading:i,error:o}=Ne(a?.running);if(t||l||a?.running&&i)return e.jsxs(p,{className:d("flex flex-col h-full",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(h,{className:"h-4 w-[100px]"}),e.jsx(h,{className:"h-16 w-full"})]})})]});if(!a?.running)return e.jsxs(p,{className:d("flex flex-col h-full border-dashed",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4 text-muted-foreground"}),"CLIProxy Stats"]}),e.jsx(I,{variant:"secondary",className:"text-[10px] h-5",children:"Offline"})]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Start a CLIProxy session (gemini, codex, agy) to collect stats."})})]});if(o)return e.jsxs(p,{className:d("flex flex-col h-full border-destructive/50",s),children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsx(I,{variant:"destructive",className:"text-[10px] h-5",children:"Error"})]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx("p",{className:"text-xs text-destructive",children:o.message})})]});const c=r?.totalRequests??0,x=r?.quotaExceededCount??0,u=c-x,m=c>0?Math.round(u/c*100):100,j=r?.tokens?.total??0,b=Object.entries(r?.requestsByModel??{}).sort((C,$)=>$[1]-C[1]).slice(0,4),v=b.length>0?b[0][1]:1;return e.jsxs(p,{className:d("flex flex-col h-full overflow-hidden",s),children:[e.jsx(N,{className:"px-3 py-2 border-b bg-muted/5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsxs(I,{variant:"outline",className:"text-[10px] h-5 text-green-600 border-green-200 bg-green-50 dark:bg-green-900/10 dark:border-green-800",children:[e.jsx(le,{className:"h-3 w-3 mr-0.5"}),"Running"]})]})}),e.jsx(g,{className:"p-0 flex-1 min-h-0",children:e.jsx(ye,{className:"h-full",children:e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("svg",{className:"w-10 h-10 -rotate-90",viewBox:"0 0 36 36",children:[e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",className:"text-muted/30"}),e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeDasharray:`${m*.88} 88`,strokeLinecap:"round",className:m>=90?"text-green-500":"text-amber-500"})]}),e.jsxs("span",{className:"absolute inset-0 flex items-center justify-center text-[8px] font-bold",children:[m,"%"]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:J(c)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:x>0?`${x} failed`:"All success"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsx("div",{className:"p-1.5 rounded-md bg-purple-100 dark:bg-purple-900/20",children:e.jsx(De,{className:"h-4 w-4 text-purple-600"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:J(j)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:"Total tokens"})]})]})]}),b.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium text-muted-foreground",children:[e.jsx(Te,{className:"h-3 w-3"}),"Models Used"]}),e.jsx("div",{className:"space-y-1",children:b.map(([C,$])=>{const A=Math.round($/v*100),B=xs(C);return e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] mb-0.5",children:[e.jsx("span",{className:"truncate font-medium",title:C,children:B}),e.jsx("span",{className:"text-muted-foreground shrink-0 ml-2",children:$})]}),e.jsx("div",{className:"h-1 bg-muted/50 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-accent/70 rounded-full transition-all",style:{width:`${A}%`}})})]},C)})})]})]})})})]})}function J(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function xs(s){let t=s.replace(/^gemini-claude-/,"").replace(/^gemini-/,"").replace(/^claude-/,"").replace(/^anthropic\./,"").replace(/-thinking$/," Thinking");return t=t.split(/[-_]/).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" "),t.length>20&&(t=t.slice(0,18)+"..."),t}function us(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(0)}K`:s.toString()}function ms({models:s,isLoading:t,onModelClick:a,privacyMode:l}){return e.jsxs(p,{className:"flex flex-col h-full min-h-0 shadow-sm lg:col-span-4",children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(ae,{className:"w-4 h-4"}),"Cost by Model"]})}),e.jsx(g,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 overflow-y-auto",children:t?e.jsx(h,{className:"h-full w-full"}):e.jsxs("div",{className:"space-y-0.5",children:[[...s||[]].sort((r,i)=>i.cost-r.cost).map(r=>e.jsxs("button",{className:"group flex items-center text-xs w-full hover:bg-muted/50 rounded px-2 py-1.5 transition-colors cursor-pointer gap-3",onClick:i=>a(r,i),title:"Click for details",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 w-[180px] shrink-0",children:[e.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:te(r.model)}}),e.jsx("span",{className:"font-medium truncate group-hover:underline underline-offset-2",children:r.model})]}),e.jsx(hs,{model:r}),e.jsx("span",{className:d("text-[10px] text-muted-foreground w-14 text-right shrink-0",l&&y),children:us(r.tokens)}),e.jsxs("span",{className:d("font-mono font-medium w-16 text-right shrink-0",l&&y),children:["$",r.cost.toFixed(2)]}),e.jsx(Fe,{className:"w-3 h-3 opacity-0 group-hover:opacity-50 transition-opacity shrink-0"})]},r.model)),e.jsx(fs,{})]})})]})}function hs({model:s}){const t={input:"#335c67",output:"#fff3b0",cacheWrite:"#e09f3e",cacheRead:"#9e2a2b"},a=l=>s.cost>0?l/s.cost*100:0;return e.jsx("div",{className:"flex-1 flex items-center gap-1 min-w-0",children:e.jsxs("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden flex",children:[e.jsx("div",{className:"h-full",style:{backgroundColor:t.input,width:`${a(s.costBreakdown.input.cost)}%`},title:`Input: $${s.costBreakdown.input.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.output,width:`${a(s.costBreakdown.output.cost)}%`},title:`Output: $${s.costBreakdown.output.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheWrite,width:`${a(s.costBreakdown.cacheCreation.cost)}%`},title:`Cache Write: $${s.costBreakdown.cacheCreation.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheRead,width:`${a(s.costBreakdown.cacheRead.cost)}%`},title:`Cache Read: $${s.costBreakdown.cacheRead.cost.toFixed(2)}`})]})})}function fs(){const s=[{color:"#335c67",label:"Input"},{color:"#fff3b0",label:"Output",hasBorder:!0},{color:"#e09f3e",label:"Cache Write"},{color:"#9e2a2b",label:"Cache Read"}];return e.jsx("div",{className:"flex items-center gap-3 pt-2 px-2 text-[10px] text-muted-foreground border-t mt-2",children:s.map(({color:t,label:a,hasBorder:l})=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("div",{className:d("w-2 h-2 rounded-full",l&&"border border-muted-foreground/30"),style:{backgroundColor:t}}),a]},a))})}function ps({viewMode:s,trends:t,hourlyData:a,models:l,sessions:r,isTrendsLoading:i,isHourlyLoading:o,isModelsLoading:n,isSessionsLoading:c,isSummaryLoading:x,onModelClick:u}){const{privacyMode:m}=M();return e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 gap-4",children:[e.jsxs(p,{className:"flex flex-col flex-1 min-h-0 max-h-[500px] overflow-hidden shadow-sm",children:[e.jsx(N,{className:"px-3 py-2 shrink-0",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Re,{className:"w-4 h-4"}),s==="hourly"?"Last 24 Hours":"Usage Trends"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 min-h-0",children:e.jsx(rs,{data:s==="hourly"?a||[]:t||[],isLoading:s==="hourly"?o:i,granularity:s==="hourly"?"hourly":"daily"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-10 gap-4 h-auto lg:h-[180px] shrink-0",children:[e.jsx(ms,{models:l,isLoading:n,onModelClick:u,privacyMode:m}),e.jsxs(p,{className:"flex flex-col h-full min-h-0 shadow-sm lg:col-span-2",children:[e.jsx(N,{className:"px-3 py-2",children:e.jsxs(S,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Me,{className:"w-4 h-4"}),"Model Usage"]})}),e.jsx(g,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 flex items-center justify-center",children:e.jsx(ls,{data:l||[],isLoading:n,className:"h-full w-full"})})]}),e.jsx(os,{data:r,isLoading:c,className:"lg:col-span-2"}),e.jsx(ds,{isLoading:x,className:"lg:col-span-2"})]})]})}function Ls(){return e.jsxs("div",{className:"space-y-4 h-full overflow-hidden",children:[e.jsxs(p,{className:"flex flex-col min-h-[300px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-32"})}),e.jsx(g,{className:"p-4 pt-0 flex-1",children:e.jsx(h,{className:"h-full w-full"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs(p,{className:"flex flex-col min-h-[250px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-28"})}),e.jsx(g,{className:"p-4 pt-2",children:e.jsx("div",{className:"space-y-3",children:[1,2,3,4,5].map(s=>e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{className:"w-2.5 h-2.5 rounded-full"}),e.jsx(h,{className:"h-3 w-24"})]}),e.jsx(h,{className:"h-3 w-16"})]},s))})})]}),e.jsxs(p,{className:"flex flex-col min-h-[250px]",children:[e.jsx(N,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-28"})}),e.jsx(g,{className:"p-4 pt-0 flex-1",children:e.jsxs("div",{className:"flex w-full h-full items-center",children:[e.jsx("div",{className:"flex-1 flex justify-center",children:e.jsx(h,{className:"h-[180px] w-[180px] rounded-full"})}),e.jsx("div",{className:"w-[140px] shrink-0 pl-2 space-y-2",children:[1,2,3,4].map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{className:"w-2 h-2 rounded-full"}),e.jsx(h,{className:"h-3 w-20"})]},s))})]})})]})]})]})}function Ds(){const s=f.useRef(null),{dateRange:t,handleDateRangeChange:a,handleTodayClick:l,handleRefresh:r,isRefreshing:i,lastUpdatedText:o,viewMode:n,summary:c,isSummaryLoading:x,trends:u,hourlyData:m,models:j,sessions:b,isTrendsLoading:v,isHourlyLoading:C,isModelsLoading:$,isSessionsLoading:A,handleModelClick:B,selectedModel:U,popoverPosition:q,handlePopoverClose:_}=ss();return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden px-4 pt-4 pb-50 gap-4",children:[e.jsx(as,{dateRange:t,onDateRangeChange:a,onTodayClick:l,onRefresh:r,isRefreshing:i,lastUpdatedText:o,viewMode:n}),e.jsx(Ee,{data:c,isLoading:x}),e.jsx(ps,{viewMode:n,trends:u,hourlyData:m,models:j,sessions:b,isTrendsLoading:v,isHourlyLoading:C,isModelsLoading:$,isSessionsLoading:A,isSummaryLoading:x,onModelClick:B}),e.jsxs(ee,{open:!!U,onOpenChange:O=>!O&&_(),children:[e.jsx(be,{asChild:!0,children:e.jsx("div",{ref:s,className:"fixed pointer-events-none",style:{left:q?.x??0,top:q?.y??0,width:1,height:1}})}),e.jsx(se,{className:"w-80 p-3",side:"top",align:"center",children:U&&e.jsx(Ge,{model:U})})]})]})}export{Ds as AnalyticsPage,Ls as AnalyticsSkeleton};
@@ -1 +1 @@
1
- import{j as s}from"./radix-ui-uXQB-q0u.js";import{r as d}from"./react-vendor-B_CU-WTZ.js";import{C as l,a as m}from"./card-dTUi3LxW.js";import{au as c,av as x,aw as u,ax as h,ay as p,a as g}from"./index-QeBLfRj8.js";import{x as j,Q as f,av as N,T as v}from"./icons-CwFZAiDB.js";import"./tanstack-Coed0rqz.js";import"./notifications-dJQY2-U6.js";import"./utils-CzKF5WmX.js";import"./form-utils-kUVlZZAO.js";import"./code-highlight-DKN39ySy.js";function D(){const[t,r]=d.useState("commands"),{data:e}=c(),{data:n,isLoading:i}=x(t),o=[{id:"commands",label:"Commands",icon:j,count:e?.commands??0},{id:"skills",label:"Skills",icon:f,count:e?.skills??0},{id:"agents",label:"Agents",icon:N,count:e?.agents??0}];return s.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-8",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold",children:"Shared Data"}),s.jsx("p",{className:"text-muted-foreground",children:"Commands, skills, and agents shared across Claude instances"})]}),e&&!e.symlinkStatus.valid&&s.jsxs(u,{variant:"warning",children:[s.jsx(v,{className:"h-4 w-4"}),s.jsx(h,{children:"Configuration Required"}),s.jsxs(p,{children:[e.symlinkStatus.message,". Run `ccs sync` to configure."]})]}),s.jsx("div",{className:"flex gap-2 border-b pb-2",children:o.map(a=>s.jsxs(g,{variant:t===a.id?"default":"ghost",size:"sm",onClick:()=>r(a.id),className:"flex items-center gap-2",children:[s.jsx(a.icon,{className:"w-4 h-4"}),a.label," (",a.count,")"]},a.id))}),s.jsx("div",{className:"mt-4",children:i?s.jsx("div",{className:"text-muted-foreground",children:"Loading..."}):n?.items.length===0?s.jsxs("div",{className:"text-muted-foreground",children:["No ",t," found"]}):s.jsx("div",{className:"grid gap-3",children:n?.items.map(a=>s.jsx(l,{children:s.jsxs(m,{children:[s.jsx("div",{className:"font-medium",children:a.name}),s.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:a.description}),s.jsx("p",{className:"text-xs text-muted-foreground mt-2 font-mono truncate",children:a.path})]})},a.name))})})]})}export{D as SharedPage};
1
+ import{j as s}from"./radix-ui-uXQB-q0u.js";import{r as d}from"./react-vendor-B_CU-WTZ.js";import{C as l,a as m}from"./card-Bulg0XJ5.js";import{au as c,av as x,aw as u,ax as h,ay as p,a as g}from"./index-Caz6CssQ.js";import{x as j,Q as f,av as N,T as v}from"./icons-CwFZAiDB.js";import"./tanstack-Coed0rqz.js";import"./notifications-dJQY2-U6.js";import"./utils-CzKF5WmX.js";import"./form-utils-kUVlZZAO.js";import"./code-highlight-DKN39ySy.js";function D(){const[t,r]=d.useState("commands"),{data:e}=c(),{data:n,isLoading:i}=x(t),o=[{id:"commands",label:"Commands",icon:j,count:e?.commands??0},{id:"skills",label:"Skills",icon:f,count:e?.skills??0},{id:"agents",label:"Agents",icon:N,count:e?.agents??0}];return s.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-8",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold",children:"Shared Data"}),s.jsx("p",{className:"text-muted-foreground",children:"Commands, skills, and agents shared across Claude instances"})]}),e&&!e.symlinkStatus.valid&&s.jsxs(u,{variant:"warning",children:[s.jsx(v,{className:"h-4 w-4"}),s.jsx(h,{children:"Configuration Required"}),s.jsxs(p,{children:[e.symlinkStatus.message,". Run `ccs sync` to configure."]})]}),s.jsx("div",{className:"flex gap-2 border-b pb-2",children:o.map(a=>s.jsxs(g,{variant:t===a.id?"default":"ghost",size:"sm",onClick:()=>r(a.id),className:"flex items-center gap-2",children:[s.jsx(a.icon,{className:"w-4 h-4"}),a.label," (",a.count,")"]},a.id))}),s.jsx("div",{className:"mt-4",children:i?s.jsx("div",{className:"text-muted-foreground",children:"Loading..."}):n?.items.length===0?s.jsxs("div",{className:"text-muted-foreground",children:["No ",t," found"]}):s.jsx("div",{className:"grid gap-3",children:n?.items.map(a=>s.jsx(l,{children:s.jsxs(m,{children:[s.jsx("div",{className:"font-medium",children:a.name}),s.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:a.description}),s.jsx("p",{className:"text-xs text-muted-foreground mt-2 font-mono truncate",children:a.path})]})},a.name))})})]})}export{D as SharedPage};
@@ -1 +1 @@
1
- import{j as a,a8 as s,a9 as n}from"./radix-ui-uXQB-q0u.js";import"./react-vendor-B_CU-WTZ.js";import{c as e}from"./index-QeBLfRj8.js";function c({className:t,...r}){return a.jsx(s,{"data-slot":"switch",className:e("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...r,children:a.jsx(n,{"data-slot":"switch-thumb",className:e("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}export{c as S};
1
+ import{j as a,a8 as s,a9 as n}from"./radix-ui-uXQB-q0u.js";import"./react-vendor-B_CU-WTZ.js";import{c as e}from"./index-Caz6CssQ.js";function c({className:t,...r}){return a.jsx(s,{"data-slot":"switch",className:e("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...r,children:a.jsx(n,{"data-slot":"switch-thumb",className:e("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}export{c as S};
@@ -24,7 +24,7 @@
24
24
  href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap"
25
25
  rel="stylesheet"
26
26
  />
27
- <script type="module" crossorigin src="/assets/index-QeBLfRj8.js"></script>
27
+ <script type="module" crossorigin src="/assets/index-Caz6CssQ.js"></script>
28
28
  <link rel="modulepreload" crossorigin href="/assets/react-vendor-B_CU-WTZ.js">
29
29
  <link rel="modulepreload" crossorigin href="/assets/radix-ui-uXQB-q0u.js">
30
30
  <link rel="modulepreload" crossorigin href="/assets/tanstack-Coed0rqz.js">
@@ -1 +1 @@
1
- {"version":3,"file":"profile-routes.d.ts","sourceRoot":"","sources":["../../../src/web-server/routes/profile-routes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,QAAA,MAAM,MAAM,4CAAW,CAAC;AA4GxB,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"profile-routes.d.ts","sourceRoot":"","sources":["../../../src/web-server/routes/profile-routes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,QAAA,MAAM,MAAM,4CAAW,CAAC;AAsHxB,eAAe,MAAM,CAAC"}
@@ -77,6 +77,15 @@ router.put('/:name', (req, res) => {
77
77
  res.status(404).json({ error: 'Profile not found' });
78
78
  return;
79
79
  }
80
+ // Validate required fields if provided (prevent setting to empty)
81
+ if (baseUrl !== undefined && !baseUrl.trim()) {
82
+ res.status(400).json({ error: 'baseUrl cannot be empty' });
83
+ return;
84
+ }
85
+ if (apiKey !== undefined && !apiKey.trim()) {
86
+ res.status(400).json({ error: 'apiKey cannot be empty' });
87
+ return;
88
+ }
80
89
  try {
81
90
  (0, route_helpers_1.updateSettingsFile)(name, { baseUrl, apiKey, model, opusModel, sonnetModel, haikuModel });
82
91
  res.json({ name, updated: true });
@@ -1 +1 @@
1
- {"version":3,"file":"profile-routes.js","sourceRoot":"","sources":["../../../src/web-server/routes/profile-routes.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,qCAAoD;AACpD,gEAAqF;AACrF,sEAAuF;AACvF,sEAAsF;AACtF,mDAAqD;AAErD,MAAM,MAAM,GAAG,IAAA,gBAAM,GAAE,CAAC;AAExB,yDAAyD;AAEzD;;GAEG;AACH,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAa,EAAE,GAAa,EAAQ,EAAE;IACrD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAA,gCAAe,GAAE,CAAC;QACjC,sD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AC,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,GAAY,EAAE,GAAa,EAAQ,EAAE;IAC5D,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC;IAE5B,+DAA+D;IAC/D,IAAI,CAAC,IAAA,iCAAgB,EAAC,IAAI,CAAC,EAAE,CAAC;QAC5B,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,mBAAmB,EAAE,CAAC,CAAC;QACrD,OAAO;IACT,CAAC;IAED,oDAAoD;IACpD,MAAM,MAAM,GAAG,IAAA,iCAAgB,EAAC,IAAI,CAAC,CAAC;IAEtC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,0BAA0B,EAAE,CAAC,CAAC;QAC5E,OAAO;IACT,CAAC;IAED,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;AACpC,CAAC,CAAC,CAAC;AAEH,kBAAe,MAAM,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"settings-routes.d.ts","sourceRoot":"","sources":["../../../src/web-server/routes/settings-routes.ts"],"names":[],"mappings":"AAAA;;GAEG;AAoBH,QAAA,MAAM,MAAM,4CAAW,CAAC;AA0YxB,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"settings-routes.d.ts","sourceRoot":"","sources":["../../../src/web-server/routes/settings-routes.ts"],"names":[],"mappings":"AAAA;;GAEG;AAoBH,QAAA,MAAM,MAAM,4CAAW,CAAC;AAkaxB,eAAe,MAAM,CAAC"}
@@ -115,6 +115,13 @@ router.get('/:profile/raw', (req, res) => {
115
115
  res.status(500).json({ error: error.message });
116
116
  }
117
117
  });
118
+ /** Required env vars for CLIProxy providers to function */
119
+ const REQUIRED_ENV_KEYS = ['ANTHROPIC_BASE_URL', 'ANTHROPIC_AUTH_TOKEN'];
120
+ /** Check if settings have required fields (returns missing list for warnings) */
121
+ function checkRequiredEnvVars(settings) {
122
+ const env = settings?.env || {};
123
+ return REQUIRED_ENV_KEYS.filter((key) => !env[key]?.trim());
124
+ }
118
125
  /**
119
126
  * PUT /api/settings/:profile - Update settings with conflict detection and backup
120
127
  */
@@ -122,7 +129,14 @@ router.put('/:profile', (req, res) => {
122
129
  try {
123
130
  const { profile } = req.params;
124
131
  const { settings, expectedMtime } = req.body;
132
+ // Validate settings object exists
133
+ if (!settings || typeof settings !== 'object') {
134
+ res.status(400).json({ error: 'settings object is required in request body' });
135
+ return;
136
+ }
125
137
  const ccsDir = (0, config_manager_1.getCcsDir)();
138
+ // Check for missing required fields (warning, not blocking - runtime fills defaults)
139
+ const missingFields = checkRequiredEnvVars(settings);
126
140
  const settingsPath = resolveSettingsPath(profile);
127
141
  const fileExists = fs.existsSync(settingsPath);
128
142
  // Only check conflict if file exists and expectedMtime was provided
@@ -161,6 +175,11 @@ router.put('/:profile', (req, res) => {
161
175
  mtime: newStat.mtime.getTime(),
162
176
  backupPath,
163
177
  created: !fileExists,
178
+ // Include warning if fields missing (runtime will use defaults)
179
+ ...(missingFields.length > 0 && {
180
+ warning: `Missing fields will use defaults: ${missingFields.join(', ')}`,
181
+ missingFields,
182
+ }),
164
183
  });
165
184
  }
166
185
  catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"settings-routes.js","sourceRoot":"","sources":["../../../src/web-server/routes/settings-routes.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,qCAAoD;AACpD,uCAAyB;AACzB,uCAAyB;AACzB,2CAA6B;AAC7B,+DAAqE;AACrE,+DAAgF;AAChF,6EAAuE;AACvE,6CAOwB;AACxB,sEAAmE;AAGnE,MAAM,MAAM,GAAG,IAAA,gBAAM,GAA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EAAE,CAAC;QACf,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAG,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC,IAAa,EAAE,GAAa,EAAQ,EAAE;IACvE,IAAI,CAAC;QACH,IAAA,8BAAmB,GAAE,CAAC;QAEtB,8CAA8C;QAC9C,IAAA,mCAAgB,GAAE,CAAC;QAEnB,MAAM,OAAO,GAAG,IAAA,yBAAc,GAAE,CAAC;QACjC,GAAG,CAAC,IAAI,CAAC;YACP,OAAO,EAAE,IAAI;YACb,MAAM,EAAE;gBACN,KAAK,EAAE,IAAA,oBAAS,EAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;gBACtC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ;aAClC;YACD,gBAAgB,EAAE;gBAChB,KAAK,EAAE,IAAA,oBAAS,EAAC,OAAO,CAAC,gBAAgB,CAAC,KAAK,CAAC;gBAChD,QAAQ,EAAE,OAAO,CAAC,gBAAgB,CAAC,QAAQ;aAC5C;YACD,OAAO,EAAE,sDAAsD;SAChE,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAG,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,kBAAe,MAAM,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"variant-routes.d.ts","sourceRoot":"","sources":["../../../src/web-server/routes/variant-routes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAaH,QAAA,MAAM,MAAM,4CAAW,CAAC;AAsHxB,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"variant-routes.d.ts","sourceRoot":"","sources":["../../../src/web-server/routes/variant-routes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAaH,QAAA,MAAM,MAAM,4CAAW,CAAC;AA4HxB,eAAe,MAAM,CAAC"}
@@ -49,8 +49,13 @@ router.post('/', (req, res) => {
49
49
  });
50
50
  return;
51
51
  }
52
+ // Require model for variant creation (prevents empty model causing issues)
53
+ if (!model || !model.trim()) {
54
+ res.status(400).json({ error: 'Missing required field: model' });
55
+ return;
56
+ }
52
57
  // Use variant-service for proper port allocation
53
- const result = (0, variant_service_1.createVariant)(name, provider, model || '', account);
58
+ const result = (0, variant_service_1.createVariant)(name, provider, model, account);
54
59
  if (!result.success) {
55
60
  res.status(409).json({ error: result.error });
56
61
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"variant-routes.js","sourceRoot":"","sources":["../../../src/web-server/routes/variant-routes.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAEH,qCAAoD;AACpD,gEAAqF;AAErF,6EAMiD;AAEjD,MAAM,MAAM,GAAG,IAAA,gBAAM,GAAE,CAAC;AAExB;;;GAGG;AACH,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAa,EAAE,GAAa,EAAE,EAAE;IAC/C,MAAM,QAAQ,GAAG,IAAA,8BAAY,GAAE,CAAC;IAChC,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;QACrE,IAAI;QACJ,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,SAAS;QACrC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,kCAAkC;QACtD,KAAK,EAAE,OAAO,CAAC,KAAK;KACrB,CAAC,CAAC,CAAC;IAEJ,GAAG,CAAC,IAAI,CAAC,EA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AAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAChE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAG,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,kBAAe,MAAM,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaitranntt/ccs",
3
- "version": "7.10.0",
3
+ "version": "7.11.0-dev.1",
4
4
  "description": "Claude Code Switch - Instant profile switching between Claude Sonnet 4.5 and GLM 4.6",
5
5
  "keywords": [
6
6
  "cli",
@@ -1 +0,0 @@
1
- import{j as e}from"./radix-ui-uXQB-q0u.js";import{r as c}from"./react-vendor-B_CU-WTZ.js";import{B as S,c as E,T as je,k as Ne,l as ve,a as g,I as C,i as I,L as T,m as M,n as ne,o as be,s as we,p as Ce,q as ye,S as W,r as L,t as $,v as re,w as Oe,x as Ae,y as le,z as ie,A as ce,D as Ee,E as Te,F as X,G as Z,R as ke,H as q,J as _e,K as Se,M as Pe,N as Re}from"./index-QeBLfRj8.js";import{u as Le,a as Me,b as De}from"./tanstack-Coed0rqz.js";import{C as B,S as ee}from"./confirm-dialog-ByfOsjk9.js";import{t as Q}from"./notifications-dJQY2-U6.js";import{a0 as U,a9 as oe,L as G,aa as Ie,E as Ue,d as He,O as D,I as Fe,ab as de,Q as V,b as xe,ac as ze,N as Ke,ad as Je,m as me,X as $e,Z as ue,ae as Be,_ as Qe,V as he,af as qe,n as fe}from"./icons-CwFZAiDB.js";import{C as Ge,b as Ve,c as Ye,d as We,a as Xe}from"./card-dTUi3LxW.js";import"./utils-CzKF5WmX.js";import"./form-utils-kUVlZZAO.js";import"./code-highlight-DKN39ySy.js";import"./alert-dialog-zpnBn2CA.js";function Ze({className:s,showTooltip:t=!0}){const l=e.jsxs(S,{variant:"outline",className:E("bg-accent/10 border-accent/30 text-accent","dark:bg-accent/20 dark:border-accent/40 dark:text-accent-foreground",s),children:[e.jsx("img",{src:"/icons/openrouter.svg",alt:"OpenRouter",className:"mr-1 h-3 w-3"}),"OpenRouter"]});return t?e.jsxs(je,{children:[e.jsx(Ne,{asChild:!0,children:l}),e.jsx(ve,{children:e.jsx("p",{children:"Access 349+ models via OpenRouter"})})]}):l}function se(s){return[/^ANTHROPIC_AUTH_TOKEN$/,/_API_KEY$/,/_AUTH_TOKEN$/,/^API_KEY$/,/^AUTH_TOKEN$/,/_SECRET$/,/^SECRET$/].some(l=>l.test(s))}function pe(s){return s?.env?(s.env.ANTHROPIC_BASE_URL||"").toLowerCase().includes("openrouter.ai"):!1}function es(s){return{opus:s.ANTHROPIC_DEFAULT_OPUS_MODEL||void 0,sonnet:s.ANTHROPIC_DEFAULT_SONNET_MODEL||void 0,haiku:s.ANTHROPIC_DEFAULT_HAIKU_MODEL||void 0}}function ss(s,t){const l={...s};return t.opus?l.ANTHROPIC_DEFAULT_OPUS_MODEL=t.opus:delete l.ANTHROPIC_DEFAULT_OPUS_MODEL,t.sonnet?l.ANTHROPIC_DEFAULT_SONNET_MODEL=t.sonnet:delete l.ANTHROPIC_DEFAULT_SONNET_MODEL,t.haiku?l.ANTHROPIC_DEFAULT_HAIKU_MODEL=t.haiku:delete l.ANTHROPIC_DEFAULT_HAIKU_MODEL,l}function ts({profileName:s,data:t,settings:l,isLoading:i,isSaving:d,hasChanges:h,isRawJsonValid:x,onRefresh:n,onDelete:o,onSave:m}){return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s}),t?.path&&e.jsx(S,{variant:"outline",className:"text-xs",children:t.path.replace(/^.*\//,"")}),pe(l)&&e.jsx(Ze,{className:"ml-1"})]}),t&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",new Date(t.mtime).toLocaleString()]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(g,{variant:"ghost",size:"sm",onClick:n,disabled:i,children:e.jsx(U,{className:`w-4 h-4 ${i?"animate-spin":""}`})}),o&&e.jsx(g,{variant:"ghost",size:"sm",onClick:o,children:e.jsx(oe,{className:"w-4 h-4 text-destructive"})}),e.jsx(g,{size:"sm",onClick:m,disabled:d||!h||!x,children:d?e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ie,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function ge({label:s,...t}){const[l,i]=c.useState(!1);return e.jsxs("div",{className:"space-y-1",children:[s&&e.jsx("label",{className:"text-sm font-medium",children:s}),e.jsxs("div",{className:"relative",children:[e.jsx(C,{type:l?"text":"password",className:"pr-10 font-mono",...t}),e.jsx(g,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3",onClick:()=>i(!l),tabIndex:-1,children:l?e.jsx(Ue,{className:"w-4 h-4"}):e.jsx(He,{className:"w-4 h-4"})})]})]})}function as({currentSettings:s,newEnvKey:t,newEnvValue:l,onNewEnvKeyChange:i,onNewEnvValueChange:d,onEnvValueChange:h,onAddEnvVar:x}){return e.jsxs(e.Fragment,{children:[e.jsx(I,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-4",children:s?.env&&Object.keys(s.env).length>0?e.jsx(e.Fragment,{children:Object.entries(s.env).map(([n,o])=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(T,{className:"text-xs font-medium flex items-center gap-2 text-muted-foreground",children:[n,se(n)&&e.jsx(S,{variant:"secondary",className:"text-[10px] px-1 py-0 h-4",children:"sensitive"})]}),se(n)?e.jsx(ge,{value:o,onChange:m=>h(n,m.target.value),className:"font-mono text-sm h-8"}):e.jsx(C,{value:o,onChange:m=>h(n,m.target.value),className:"font-mono text-sm h-8"})]},n))}):e.jsxs("div",{className:"py-8 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed text-sm",children:[e.jsx("p",{children:"No environment variables configured."}),e.jsx("p",{className:"text-xs mt-1 opacity-70",children:"Add variables using the input below or edit the JSON directly."})]})})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(T,{className:"text-xs font-medium text-muted-foreground",children:"Add Environment Variable"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(C,{placeholder:"VARIABLE_NAME",value:t,onChange:n=>i(n.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:n=>n.key==="Enter"&&t.trim()&&x()}),e.jsx(C,{placeholder:"value",value:l,onChange:n=>d(n.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:n=>n.key==="Enter"&&t.trim()&&x()}),e.jsx(g,{variant:"outline",size:"sm",className:"h-8",onClick:x,disabled:!t.trim(),children:e.jsx(D,{className:"w-4 h-4"})})]})]})]})}function ns({profileName:s,data:t}){return e.jsx(I,{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(Fe,{className:"w-4 h-4"}),"Profile Information"]}),e.jsx("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Profile Name"}),e.jsx("span",{className:"font-mono",children:t.profile})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"File Path"}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:t.path}),e.jsx(M,{value:t.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Last Modified"}),e.jsx("span",{className:"text-xs",children:new Date(t.mtime).toLocaleString()})]})]})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Quick Usage"}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:"Run with profile"}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs ",s,' "prompt"']}),e.jsx(M,{value:`ccs ${s} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:"Set as default"}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs default ",s]}),e.jsx(M,{value:`ccs default ${s}`,size:"icon",className:"h-6 w-6"})]})]})]})]})]})})}function rs({value:s,onChange:t,placeholder:l="Search models...",className:i}){const[d,h]=c.useState(""),[x,n]=c.useState(null),{models:o,isLoading:m,isError:j,isFetching:y}=ne(),O=be(),N=c.useMemo(()=>we(o,d,{category:x??void 0}),[o,d,x]),b=c.useMemo(()=>Ce(o,2),[o]),_=!d.trim()&&!x,k=c.useMemo(()=>{const r={anthropic:[],openai:[],google:[],meta:[],mistral:[],opensource:[],other:[]};N.forEach(a=>{r[a.category].push(a)});for(const a of Object.keys(r))r[a]=ye(r[a]);return r},[N]),w=c.useCallback(()=>{O()},[O]),p=o.find(r=>r.id===s);return m&&o.length===0?e.jsxs("div",{className:E("space-y-2",i),children:[e.jsx(W,{className:"h-10 w-full"}),e.jsx(W,{className:"h-32 w-full"})]}):e.jsxs("div",{className:E("space-y-2 w-full min-w-0 overflow-hidden",i),children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(de,{className:"text-muted-foreground absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2"}),e.jsx(C,{value:d,onChange:r=>h(r.target.value),placeholder:l,className:"pl-9"})]}),e.jsx(g,{variant:"outline",size:"icon",onClick:w,disabled:y,title:"Refresh models",children:y?e.jsx(G,{className:"h-4 w-4 animate-spin"}):e.jsx(U,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsxs(S,{variant:x===null?"default":"outline",className:"cursor-pointer",onClick:()=>n(null),children:["All (",o.length,")"]}),Object.keys(L).map(r=>{const a=k[r].length;return a===0?null:e.jsxs(S,{variant:x===r?"default":"outline",className:"cursor-pointer",onClick:()=>n(r),children:[L[r]," (",a,")"]},r)})]}),p&&e.jsxs("div",{className:"bg-muted rounded-md p-2 text-sm",children:[e.jsx("span",{className:"font-medium",children:p.name}),e.jsxs("span",{className:"text-muted-foreground ml-2",children:[$(p.pricing)," |"," ",re(p.context_length)]})]}),e.jsx(I,{className:"h-72 w-full rounded-md border",children:j?e.jsxs("div",{className:"text-destructive p-4 text-center",children:["Failed to load models."," ",e.jsx(g,{variant:"link",onClick:w,children:"Retry"})]}):N.length===0?e.jsxs("div",{className:"text-muted-foreground p-4 text-center",children:['No models found matching "',d,'"']}):e.jsxs("div",{className:"space-y-6 p-3",children:[_&&b.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"text-muted-foreground bg-background sticky top-0 mb-2 flex items-center gap-1.5 py-1.5 text-xs font-semibold border-b pb-2",children:[e.jsx(V,{className:"h-3 w-3 text-accent"}),e.jsx("span",{children:"Newest Models"})]}),e.jsx("div",{className:"space-y-1",children:b.map(r=>e.jsx(te,{model:r,isSelected:r.id===s,onClick:()=>t(r.id),showAge:!0},r.id))})]}),Object.keys(L).map(r=>{const a=k[r];return a.length===0?null:e.jsxs("div",{children:[e.jsx("div",{className:"text-muted-foreground bg-background sticky top-0 mb-2 py-1.5 text-xs font-semibold border-b pb-2",children:L[r]}),e.jsx("div",{className:"space-y-1",children:a.map(v=>e.jsx(te,{model:v,isSelected:v.id===s,onClick:()=>t(v.id)},v.id))})]},r)})]})})]})}function te({model:s,isSelected:t,onClick:l,showAge:i=!1}){return e.jsxs("button",{type:"button",onClick:l,className:E("group flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm transition-colors","hover:bg-accent hover:text-accent-foreground",t&&"bg-accent text-accent-foreground"),children:[e.jsx("span",{className:"flex-1 min-w-0 truncate font-medium",children:s.name}),e.jsxs("span",{className:E("flex shrink-0 items-center gap-1 text-xs whitespace-nowrap",t?"text-accent-foreground/80":"text-muted-foreground group-hover:text-accent-foreground/80"),children:[i&&s.created&&e.jsx(S,{variant:"outline",className:E("text-[10px] px-1",t?"border-accent-foreground/30 text-accent-foreground/80":"text-accent border-accent/30 group-hover:text-accent-foreground/80 group-hover:border-accent-foreground/30"),children:Oe(s.created)}),s.isFree?e.jsx(S,{variant:"secondary",className:E("text-[10px] px-1",t?"bg-accent-foreground/20 text-accent-foreground":"group-hover:bg-accent-foreground/20 group-hover:text-accent-foreground"),children:"Free"}):s.isExacto?e.jsxs(e.Fragment,{children:[e.jsx(S,{variant:"outline",className:E("text-[10px] px-1 border-emerald-500/50 text-emerald-600",t?"border-accent-foreground/30 text-accent-foreground/80":"group-hover:border-accent-foreground/30 group-hover:text-accent-foreground/80"),children:"Exacto"}),e.jsx("span",{className:"tabular-nums",children:$(s.pricing)})]}):e.jsx("span",{className:"tabular-nums",children:$(s.pricing)}),e.jsx("span",{className:"tabular-nums",children:re(s.context_length)})]})]})}function ls({selectedModel:s,value:t,onChange:l,className:i}){const{models:d}=ne(),h=c.useMemo(()=>s?Ae(s,d):{},[s,d]),x=()=>{l(h)},n=(m,j)=>{l({...t,[m]:j||void 0})},o=s&&Object.keys(h).length>0;return e.jsxs(le,{className:E("group",i),children:[e.jsxs(ie,{className:"flex items-center gap-2 text-sm font-medium hover:underline",children:[e.jsx(xe,{className:"h-4 w-4 transition-transform group-data-[state=open]:rotate-90"}),"Model Tier Mapping",e.jsx("span",{className:"text-muted-foreground font-normal",children:"(Advanced)"})]}),e.jsxs(ce,{className:"space-y-3 pt-3",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Configure different models for Claude Code's opus/sonnet/haiku tiers."}),o&&e.jsxs(g,{type:"button",variant:"outline",size:"sm",onClick:x,children:[e.jsx(ze,{className:"mr-1 h-4 w-4"}),"Auto-suggest based on ",s?.split("/")[0]]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(T,{htmlFor:"tier-opus",className:"text-right",children:"Opus"}),e.jsx(C,{id:"tier-opus",value:t.opus??"",onChange:m=>n("opus",m.target.value),placeholder:"e.g., anthropic/claude-opus-4"})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(T,{htmlFor:"tier-sonnet",className:"text-right",children:"Sonnet"}),e.jsx(C,{id:"tier-sonnet",value:t.sonnet??"",onChange:m=>n("sonnet",m.target.value),placeholder:"e.g., anthropic/claude-sonnet-4"})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(T,{htmlFor:"tier-haiku",className:"text-right",children:"Haiku"}),e.jsx(C,{id:"tier-haiku",value:t.haiku??"",onChange:m=>n("haiku",m.target.value),placeholder:"e.g., anthropic/claude-3.5-haiku"})]})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"These set ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, ANTHROPIC_DEFAULT_HAIKU_MODEL."})]})]})}function is({profileName:s,data:t,currentSettings:l,newEnvKey:i,newEnvValue:d,onNewEnvKeyChange:h,onNewEnvValueChange:x,onEnvValueChange:n,onAddEnvVar:o,onEnvBulkChange:m}){const j=pe(l),y=l?.env,O=c.useMemo(()=>es(y??{}),[y]),N=y??{},b=a=>{if(m){const v={...N,ANTHROPIC_MODEL:a,ANTHROPIC_DEFAULT_OPUS_MODEL:a,ANTHROPIC_DEFAULT_SONNET_MODEL:a,ANTHROPIC_DEFAULT_HAIKU_MODEL:a};m(v)}else n("ANTHROPIC_MODEL",a),n("ANTHROPIC_DEFAULT_OPUS_MODEL",a),n("ANTHROPIC_DEFAULT_SONNET_MODEL",a),n("ANTHROPIC_DEFAULT_HAIKU_MODEL",a);Q.success("Applied model to all tiers",{duration:2e3})},_=a=>{if(m){const v=ss(N,a);m(v)}else a.opus!==void 0&&n("ANTHROPIC_DEFAULT_OPUS_MODEL",a.opus||""),a.sonnet!==void 0&&n("ANTHROPIC_DEFAULT_SONNET_MODEL",a.sonnet||""),a.haiku!==void 0&&n("ANTHROPIC_DEFAULT_HAIKU_MODEL",a.haiku||"")},[k,w]=c.useState(!1),p=new Set(["ANTHROPIC_AUTH_TOKEN"]),r=Object.entries(N).filter(([a])=>!p.has(a));return e.jsx("div",{className:"h-full w-full min-w-0 flex flex-col",children:e.jsxs(Ee,{defaultValue:"env",className:"h-full w-full min-w-0 flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Te,{className:"w-full",children:[e.jsx(X,{value:"env",className:"flex-1",children:j?"Configuration":"Environment Variables"}),e.jsx(X,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col min-w-0",children:[e.jsx(Z,{value:"env",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden min-w-0",children:j?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsxs("div",{className:"h-full overflow-y-auto overflow-x-hidden p-4 space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(T,{className:"text-sm font-medium",children:"Model Selection"}),e.jsx(rs,{value:N.ANTHROPIC_MODEL,onChange:b,placeholder:"Search OpenRouter models..."})]}),e.jsx(ls,{selectedModel:N.ANTHROPIC_MODEL,value:O,onChange:_}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{className:"text-sm font-medium",children:"API Key"}),e.jsx(ge,{value:N.ANTHROPIC_AUTH_TOKEN||"",onChange:a=>n("ANTHROPIC_AUTH_TOKEN",a.target.value),placeholder:"sk-or-v1-...",className:"font-mono text-sm"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your API key from"," ",e.jsx("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"openrouter.ai/keys"})]})]}),r.length>0&&e.jsxs(le,{open:k,onOpenChange:w,children:[e.jsxs(ie,{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors group",children:[e.jsx(xe,{className:E("h-4 w-4 transition-transform",k&&"rotate-90")}),e.jsx(Ke,{className:"h-4 w-4"}),e.jsx("span",{children:"Additional Variables"}),e.jsxs("span",{className:"text-xs font-normal opacity-70",children:["(",r.length,")"]})]}),e.jsx(ce,{className:"pt-4",children:e.jsx("div",{className:"space-y-3 border rounded-lg p-3 bg-muted/30",children:r.map(([a,v])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:a}),e.jsx(C,{value:v,onChange:P=>n(a,P.target.value),className:"font-mono text-xs h-8"})]},a))})})]})]})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(T,{className:"text-xs font-medium text-muted-foreground",children:"Add Environment Variable"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(C,{placeholder:"VARIABLE_NAME",value:i,onChange:a=>h(a.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:a=>a.key==="Enter"&&i.trim()&&o()}),e.jsx(C,{placeholder:"value",value:d,onChange:a=>x(a.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:a=>a.key==="Enter"&&i.trim()&&o()}),e.jsx(g,{variant:"outline",size:"sm",className:"h-8",onClick:o,disabled:!i.trim(),children:e.jsx(D,{className:"w-4 h-4"})})]})]})]}):e.jsx(as,{currentSettings:l,newEnvKey:i,newEnvValue:d,onNewEnvKeyChange:h,onNewEnvValueChange:x,onEnvValueChange:n,onAddEnvVar:o})}),e.jsx(Z,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(ns,{profileName:s,data:t})})]})]})})}function cs({profileName:s,onDelete:t,onHasChangesUpdate:l}){const[i,d]=c.useState({}),[h,x]=c.useState(!1),[n,o]=c.useState(null),[m,j]=c.useState(""),[y,O]=c.useState(""),N=Le(),{data:b,isLoading:_,isError:k,refetch:w}=Me({queryKey:["settings",s],queryFn:async()=>{const f=await fetch(`/api/settings/${s}/raw`);if(!f.ok)throw new Error(`Failed to load settings: ${f.status}`);return f.json()}}),p=b?.settings,r=c.useMemo(()=>{if(n!==null)try{return JSON.parse(n)}catch{}if(p)return{...p,env:{...p.env,...i}}},[p,i,n]),a=c.useMemo(()=>n!==null?n:p?JSON.stringify(p,null,2):"",[n,p]),v=c.useCallback(f=>{o(f)},[]),P=(f,A)=>{const R={...r?.env||{},[f]:A};d(J=>({...J,[f]:A})),o(JSON.stringify({...r,env:R},null,2))},H=f=>{const A={...r?.env||{},...f};d(R=>({...R,...f})),o(JSON.stringify({...r,env:A},null,2))},F=()=>{if(!m.trim())return;const f=m.trim(),A=y,R={...r?.env||{},[f]:A};d(J=>({...J,[f]:A})),o(JSON.stringify({...r,env:R},null,2)),j(""),O("")},u=c.useMemo(()=>{try{return JSON.parse(a),!0}catch{return!1}},[a]),z=c.useMemo(()=>n!==null?n!==JSON.stringify(p,null,2):Object.keys(i).length>0,[n,i,p]);c.useEffect(()=>{l?.(z)},[z,l]);const K=De({mutationFn:async()=>{let f;try{f=JSON.parse(a)}catch{f={...b?.settings,env:{...b?.settings?.env,...i}}}const A=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:f,expectedMtime:b?.mtime})});if(A.status===409)throw new Error("CONFLICT");if(!A.ok)throw new Error("Failed to save");return A.json()},onSuccess:()=>{N.invalidateQueries({queryKey:["settings",s]}),N.invalidateQueries({queryKey:["profiles"]}),d({}),o(null),Q.success("Settings saved")},onError:f=>{f.message==="CONFLICT"?x(!0):Q.error(f.message)}}),Y=async f=>{x(!1),f?(await w(),K.mutate()):(d({}),o(null))};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(ts,{profileName:s,data:b,settings:r,isLoading:_,isSaving:K.isPending,hasChanges:z,isRawJsonValid:u,onRefresh:()=>w(),onDelete:t,onSave:()=>K.mutate()}),_?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(G,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):k?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed to load settings."}),e.jsxs(g,{variant:"outline",size:"sm",onClick:()=>w(),children:[e.jsx(U,{className:"w-4 h-4 mr-1"}),"Retry"]})]})}):e.jsxs("div",{className:"flex-1 grid grid-cols-[40%_60%] divide-x overflow-hidden",children:[e.jsx("div",{className:"flex flex-col overflow-hidden bg-muted/5 min-w-0",children:e.jsx(is,{profileName:s,data:b,currentSettings:r,newEnvKey:m,newEnvValue:y,onNewEnvKeyChange:j,onNewEnvValueChange:O,onEnvValueChange:P,onEnvBulkChange:H,onAddEnvVar:F})}),e.jsxs("div",{className:"flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(Je,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(ke,{rawJsonContent:a,isRawJsonValid:u,rawJsonEdits:n,settings:p,onChange:v})]})]}),e.jsx(B,{open:h,title:"File Modified Externally",description:"Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>Y(!0),onCancel:()=>Y(!1)})]},s)}const ae="ccs:openrouter-banner-dismissed";function os({onCreateClick:s}){const[t,l]=c.useState(!0),{modelCount:i,isLoading:d}=q();c.useEffect(()=>{const x=localStorage.getItem(ae)==="true";l(x)},[]);const h=()=>{localStorage.setItem(ae,"true"),l(!0)};return t?null:e.jsx("div",{className:"bg-gradient-to-r from-accent to-accent/90 text-white px-4 py-3 relative shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between gap-4 max-w-screen-xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"p-1.5 bg-white/20 rounded-md shrink-0",children:e.jsx(V,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:"NEW: OpenRouter Integration"}),e.jsxs("p",{className:"text-xs text-white/80 truncate",children:["Browse ",d?"300+":`${i}+`," models from OpenAI, Anthropic, Google, Meta and more."]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s&&e.jsx(g,{size:"sm",variant:"secondary",onClick:s,className:"bg-white text-accent hover:bg-white/90 h-8",children:"Try it now"}),e.jsxs("a",{href:"https://openrouter.ai",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-white/80 hover:text-white hidden sm:flex items-center gap-1",children:["Learn more",e.jsx(me,{className:"w-3 h-3"})]}),e.jsxs(g,{size:"icon",variant:"ghost",onClick:h,className:"h-7 w-7 text-white/70 hover:text-white hover:bg-white/20",children:[e.jsx($e,{className:"w-4 h-4"}),e.jsx("span",{className:"sr-only",children:"Dismiss"})]})]})]})})}function ds({onOpenRouterClick:s,onCustomClick:t}){const{modelCount:l,isLoading:i}=q();return e.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/20 p-8",children:e.jsxs("div",{className:"max-w-lg w-full space-y-6",children:[e.jsxs(Ge,{className:"border-accent/30 dark:border-accent/40 bg-gradient-to-br from-accent/5 to-background dark:from-accent/10",children:[e.jsxs(Ve,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"p-2 rounded-lg bg-accent/10 dark:bg-accent/20",children:e.jsx("img",{src:"/icons/openrouter.svg",alt:"OpenRouter",className:"w-6 h-6"})}),e.jsx(S,{variant:"secondary",className:"bg-accent/10 text-accent dark:bg-accent/20 dark:text-accent-foreground",children:"Recommended"})]}),e.jsx(Ye,{className:"text-xl",children:"Start with OpenRouter"}),e.jsxs(We,{className:"text-base",children:["Access ",i?"300+":`${l}+`," models from OpenAI, Anthropic, Google, Meta and more - all through one API."]})]}),e.jsxs(Xe,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(ue,{className:"w-4 h-4 text-accent"}),e.jsx("span",{children:"One API, all providers"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(V,{className:"w-4 h-4 text-accent"}),e.jsx("span",{children:"Model tier mapping"})]})]}),e.jsxs(g,{onClick:s,className:"w-full bg-accent hover:bg-accent/90 text-white",size:"lg",children:["Create OpenRouter Profile",e.jsx(Be,{className:"w-4 h-4 ml-2"})]}),e.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:["Get your API key at"," ",e.jsxs("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline inline-flex items-center gap-1",children:["openrouter.ai/keys",e.jsx(me,{className:"w-3 h-3"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(ee,{className:"flex-1"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"or"}),e.jsx(ee,{className:"flex-1"})]}),e.jsx(g,{variant:"outline",onClick:t,className:"w-full",children:"Create Custom API Profile"})]})})}function xs({onCreateClick:s}){const{modelCount:t,isLoading:l}=q();return e.jsx("div",{className:"p-3 border-t bg-gradient-to-r from-accent/5 to-accent/10 dark:from-accent/10 dark:to-accent/15",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 bg-accent/10 dark:bg-accent/20 rounded shrink-0",children:e.jsx("img",{src:"/icons/openrouter.svg",alt:"",className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-accent dark:text-accent-foreground",children:"OpenRouter"}),e.jsxs("p",{className:"text-[10px] text-muted-foreground truncate",children:[l?"300+":`${t}+`," models available"]})]}),e.jsxs(g,{size:"sm",variant:"ghost",onClick:s,className:"h-7 px-2 text-accent hover:text-accent hover:bg-accent/10 dark:hover:bg-accent/20",children:[e.jsx(ue,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:"Add"})]})]})})}function Os(){const{data:s,isLoading:t,isError:l,refetch:i}=_e(),d=Se(),[h,x]=c.useState(null),[n,o]=c.useState(""),[m,j]=c.useState(!1),[y,O]=c.useState("normal"),[N,b]=c.useState(null),[_,k]=c.useState(!1),[w,p]=c.useState(null);Pe();const r=c.useMemo(()=>s?.profiles||[],[s?.profiles]),a=c.useMemo(()=>r.filter(u=>u.name.toLowerCase().includes(n.toLowerCase())),[r,n]),v=h?r.find(u=>u.name===h):null,P=u=>{d.mutate(u,{onSuccess:()=>{h===u&&x(null),b(null)}})},H=u=>{j(!1),_&&h!==null?p(u):x(u)},F=u=>{_&&h!==u?p(u):x(u)};return e.jsxs("div",{className:"h-[calc(100vh-100px)] flex flex-col",children:[e.jsx(os,{onCreateClick:()=>j(!0)}),e.jsxs("div",{className:"flex-1 flex min-h-0",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-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Qe,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:"API Profiles"})]}),e.jsxs(g,{size:"sm",onClick:()=>{j(!0)},children:[e.jsx(D,{className:"w-4 h-4 mr-1"}),"New"]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(de,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(C,{placeholder:"Search profiles...",className:"pl-8 h-9",value:n,onChange:u=>o(u.target.value)})]})]}),e.jsx(I,{className:"flex-1",children:t?e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading profiles..."}):l?e.jsx("div",{className:"p-4 text-center",children:e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(he,{className:"w-12 h-12 mx-auto text-destructive/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Failed to load profiles"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Unable to fetch API profiles. Please try again."})]}),e.jsxs(g,{size:"sm",variant:"outline",onClick:()=>i(),children:[e.jsx(U,{className:"w-4 h-4 mr-1"}),"Retry"]})]})}):a.length===0?e.jsx("div",{className:"p-4 text-center",children:r.length===0?e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(qe,{className:"w-12 h-12 mx-auto text-muted-foreground/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"No API profiles yet"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Create your first profile to connect to custom API endpoints"})]}),e.jsxs(g,{size:"sm",variant:"outline",onClick:()=>{j(!0)},children:[e.jsx(D,{className:"w-4 h-4 mr-1"}),"Create Profile"]})]}):e.jsxs("p",{className:"text-sm text-muted-foreground py-4",children:['No profiles match "',n,'"']})}):e.jsx("div",{className:"p-2 space-y-1",children:a.map(u=>e.jsx(ms,{profile:u,isSelected:h===u.name,onSelect:()=>F(u.name),onDelete:()=>b(u.name)},u.name))})}),r.length>0&&e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{children:[r.length," profile",r.length!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(fe,{className:"w-3 h-3 text-green-600"}),r.filter(u=>u.configured).length," configured"]})]})}),e.jsx(xs,{onCreateClick:()=>{O("openrouter"),j(!0)}})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:v?e.jsx(cs,{profileName:v.name,onDelete:()=>b(v.name),onHasChangesUpdate:k},v.name):e.jsx(ds,{onOpenRouterClick:()=>{O("openrouter"),j(!0)},onCustomClick:()=>{O("normal"),j(!0)}})})]}),e.jsx(Re,{open:m,onOpenChange:j,onSuccess:H,initialMode:y}),e.jsx(B,{open:!!N,title:"Delete Profile",description:`Are you sure you want to delete "${N}"? This will remove the settings file and cannot be undone.`,confirmText:"Delete",variant:"destructive",onConfirm:()=>N&&P(N),onCancel:()=>b(null)}),e.jsx(B,{open:!!w,title:"Unsaved Changes",description:`You have unsaved changes in "${h}". Discard and switch to "${w}"?`,confirmText:"Discard & Switch",variant:"destructive",onConfirm:()=>{k(!1),x(w),p(null)},onCancel:()=>p(null)})]})}function ms({profile:s,isSelected:t,onSelect:l,onDelete:i}){return e.jsxs("div",{className:E("group flex items-center gap-2 px-3 py-2.5 rounded-md cursor-pointer transition-colors",t?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:l,children:[s.configured?e.jsx(fe,{className:"w-4 h-4 text-green-600 shrink-0"}):e.jsx(he,{className:"w-4 h-4 text-yellow-600 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm truncate",children:s.name}),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("div",{className:"text-xs text-muted-foreground truncate flex-1",children:s.settingsPath}),e.jsx(M,{value:s.settingsPath,size:"icon",className:"h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity"})]})]}),e.jsx(g,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:d=>{d.stopPropagation(),i()},children:e.jsx(oe,{className:"w-3.5 h-3.5 text-destructive"})})]})}export{Os as ApiPage};