1import{r as d,y as S,a as D,j as o,e as F}from"./app-CZw4zvFM.js";import{E as g}from"./index-DUZSKLIY.js";import{R as T,C as f}from"./row-M-1fLFv3.js";import{C as y}from"./index-BlW28zjE.js";import{L as h}from"./index-DgcyfeKB.js";/* empty css */import"./useBreakpoint-PA8SwT4Z.js";import"./EllipsisOutlined-B7OjL6qX.js";import"./Overflow-uTMTJwUS.js";import"./PlusOutlined-CcDZkb5g.js";import"./makeChartComp-BxGRd6nc.js";import"./callSuper-Cu6FRejo.js";import"./objectWithoutProperties-BntJMkdI.js";function k(m,a,x,j){const c={};for(const r of m){if(!a(r))continue;const p=x(r);c[p]=j(c[p],r)}return Object.values(c).sort((r,p)=>r.date.localeCompare(p.date))}function G({tenantId:m}){const[a,x]=d.useState([]),[j,c]=d.useState(!0),{resolvedAppearance:r}=S(),p=r==="dark"?"classicDark":"classic";d.useEffect(()=>{let e=!1;c(!0);const t={};return m&&(t.tenant_id=m),D.get(route("admin.ai-telemetry.aggregates"),{params:t}).then(s=>{e||x(s.data)}).catch(()=>{e||x([])}).finally(()=>{e||c(!1)}),()=>{e=!0}},[m]);const C=d.useMemo(()=>k(a,e=>e.kind==="overall",e=>e.date,(e,t)=>({date:t.date,spans:(e?.spans??0)+t.count,errors:(e?.errors??0)+t.error_count})).flatMap(({date:e,spans:t,errors:s})=>[{date:e,value:t,category:"Total spans"},{date:e,value:s,category:"Errors"}]),[a]),$=d.useMemo(()=>k(a,e=>e.kind==="agent"&&e.p95_ms!=null&&!!e.dimension,e=>`${e.date}|${e.dimension}`,(e,t)=>({date:t.date,agent:t.dimension??"",p95:Math.max(e?.p95??0,t.p95_ms??0)})).map(({date:e,agent:t,p95:s})=>({date:e,value:s,category:t})),[a]),v=d.useMemo(()=>{const e=[...new Set(a.map(n=>n.date))].sort((n,l)=>n.localeCompare(l)),t={},s={};for(const n of a){if(n.kind!=="model"||!n.dimension)continue;const l=n.input_tokens+n.output_tokens;t[`${n.dimension}|${n.date}`]=(t[`${n.dimension}|${n.date}`]??0)+l,s[n.dimension]=(s[n.dimension]??0)+l}const i=[];for(const n of Object.keys(s))if(!(s[n]<=0))for(const l of e)i.push({date:l,value:t[`${n}|${l}`]??0,category:n});return i},[a]),b=d.useMemo(()=>k(a,()=>!0,e=>e.date,(e,t)=>{let s=0;if(t.kind==="model"&&t.cost_usd!=null){const i=parseFloat(t.cost_usd);i>0&&(s=i)}return{date:t.date,cost:(e?.cost??0)+s}}).map(({date:e,cost:t})=>({date:e,value:t,category:"Cost (USD)"})),[a]);if(j)return o.jsx("div",{style:{padding:64,textAlign:"center"},children:o.jsx(F,{size:"large"})});if(a.length===0)return o.jsx(g,{description:"Trends begin populating after the nightly rollup runs.",style:{padding:64}});const u=(e,t)=>({data:e,xField:"date",yField:"value",colorField:"category",smooth:!0,height:280,theme:p,axis:{x:{labelFormatter:s=>{const i=new Date(s);return`${i.getUTCMonth()+1}/${i.getUTCDate()}`}},y:{title:t,labelFormatter:s=>s>=1e3?`${(s/1e3).toFixed(1)}K`:String(s)}},legend:{position:"top-right"},animate:{enter:{type:"pathIn",duration:600}}}),M=e=>({...u(e,"USD"),axis:{...u(e,"USD").axis,y:{title:"USD",labelFormatter:t=>`$${t.toFixed(2)}`}}});return o.jsxs(T,{gutter:[16,16],children:[o.jsx(f,{xs:24,lg:12,children:o.jsx(y,{title:"Daily Span Count",children:C.length>0?o.jsx(h,{...u(C,"Count")}):o.jsx(g,{description:"No data"})})}),o.jsx(f,{xs:24,lg:12,children:o.jsx(y,{title:"Daily Cost",children:b.length>0?o.jsx(h,{...M(b)}):o.jsx(g,{description:"No cost data"})})}),o.jsx(f,{xs:24,lg:12,children:o.jsx(y,{title:"P95 Latency by Agent",children:$.length>0?o.jsx(h,{...u($,"ms")}):o.jsx(g,{description:"No latency data"})})}),o.jsx(f,{xs:24,lg:12,children:o.jsx(y,{title:"Token Usage by Model",children:v.length>0?o.jsx(h,{...u(v,"Tokens")}):o.jsx(g,{description:"No token data"})})})]})}export{G as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.