import{n as S,u as w,e as M,j as e,B as L,L as p,S as j,f as u,g as f,h as N,i as b}from"./index-DXI13nSQ.js";import{E as R}from"./empty-state-WHzNYVaT.js";import{T as V,a as $,b as g,c as l,d as E,e as c}from"./table-oUi0mGOn.js";import{a as F}from"./use-observability-Bum0mmDO.js";import{L as I}from"./loader-circle-BS5FFFg-.js";import{R as P}from"./refresh-ccw-BPKXoMZa.js";import"./react-Cb2sDjhD.js";import"./useQuery-CEwGD94N.js";/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const B=S("ChartColumn",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]),z=["user","agent","platform","intent"],H=["cost","calls","errors","avg_latency"];function K(){const{t:a}=w(["observability","common"]),[n,y]=M(),v=Math.max(1,Number(n.get("days"))||7),i=n.get("dim")??"agent",r=n.get("by")??"cost";function m(s){const t=new URLSearchParams(n);for(const[x,h]of Object.entries(s))h==null?t.delete(x):t.set(x,h);y(t,{replace:!0})}const{data:C,isLoading:T,isFetching:o,refetch:k}=F({dim:i,by:r,days:v,limit:20}),d=C?.items??[];return e.jsxs("div",{className:"mx-auto flex max-w-7xl flex-col gap-4",children:[e.jsx("header",{className:"flex flex-col gap-1",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("h1",{className:"text-xl font-semibold",children:a("topn.title")}),e.jsxs(L,{variant:"ghost",size:"sm",className:"ml-auto",onClick:()=>k(),disabled:o,"aria-label":a("actions.refresh",{ns:"common"}),children:[o?e.jsx(I,{className:"h-4 w-4 animate-spin"}):e.jsx(P,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:a("actions.refresh",{ns:"common"})})]})]})}),e.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(p,{htmlFor:"dim",className:"text-xs text-text-dim",children:a("topn.filter.dim")}),e.jsxs(j,{value:i,onValueChange:s=>m({dim:s==="agent"?null:s}),children:[e.jsx(u,{id:"dim",className:"w-32",children:e.jsx(f,{})}),e.jsx(N,{children:z.map(s=>e.jsx(b,{value:s,children:a(`topn.dim.${s}`)},s))})]})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(p,{htmlFor:"by",className:"text-xs text-text-dim",children:a("topn.filter.metric")}),e.jsxs(j,{value:r,onValueChange:s=>m({by:s==="cost"?null:s}),children:[e.jsx(u,{id:"by",className:"w-36",children:e.jsx(f,{})}),e.jsx(N,{children:H.map(s=>e.jsx(b,{value:s,children:a(`topn.metric.${s}`)},s))})]})]})]}),T?e.jsx("div",{className:"h-48 w-full rounded-md bg-surface-2 animate-pulse"}):d.length===0?e.jsx(R,{icon:e.jsx(B,{}),title:a("topn.empty.title"),description:a("topn.empty.description")}):e.jsxs(V,{children:[e.jsx($,{children:e.jsxs(g,{children:[e.jsx(l,{className:"w-12",children:a("topn.col.rank")}),e.jsx(l,{children:a("topn.col.key")}),e.jsx(l,{className:"w-24",children:a("topn.col.calls")}),e.jsx(l,{className:"w-24",children:a("topn.col.cost")}),e.jsx(l,{className:"w-24",children:a("topn.col.errors")}),e.jsx(l,{className:"w-32",children:a("topn.col.avgLatencyMs")})]})}),e.jsx(E,{children:d.map((s,t)=>e.jsxs(g,{children:[e.jsx(c,{className:"tabular-nums text-text-dim",children:t+1}),e.jsx(c,{className:"font-medium",children:s.key}),e.jsx(c,{className:"tabular-nums",children:s.calls}),e.jsxs(c,{className:"tabular-nums",children:["$",s.cost.toFixed(4)]}),e.jsx(c,{className:"tabular-nums",children:e.jsx("span",{className:s.errors>0?"text-danger":"text-text-dim",children:s.errors})}),e.jsxs(c,{className:"tabular-nums",children:[Math.round(s.avgLatencyMs),"ms"]})]},`${s.key}-${t}`))})]})]})}export{K as default};
//# sourceMappingURL=topn-D1LQXoLo.js.map
