1import{u as C,j as e}from"./vendor-query-BROoW_jZ.js";import{a as A}from"./vendor-router-DB8Iq42h.js";import{A as w}from"./admin-layout-B-pSt6PS.js";import{C as x,b as h,d as j,a as p,s as S}from"./index-DUEDRU2t.js";import{S as c}from"./skeleton-CrG8PWA7.js";import{B as f}from"./badge-BKnL-l_B.js";import{T as k,a as R,b as u,c as r,d as T,e as l}from"./table-DmWei0PS.js";import{R as I,S as o,a as F,A as E,b as B,X as D,Y as $,c as z,L as K,d}from"./analytics-shared-BnDOHsXu.js";import{B as L}from"./bot-coM-PApt.js";import{C as M}from"./circle-check-Bk6XpyXj.js";import{C as H}from"./circle-x-BF5QWEW5.js";import{C as O}from"./circle-alert-Co8iOCFJ.js";import{A as X}from"./activity-DbSWVfyY.js";import{C as q}from"./clock-CoezAxad.js";import"./page-head-Dc8X8fDS.js";import"./theme-toggle-CYJ0Zdz9.js";import"./settings-Dq_8YxJ9.js";import"./panel-left-close-Diq_zBJU.js";import"./users-BxKfg4K2.js";import"./package-Bla7rFRv.js";import"./sparkles-F1kFfV3K.js";import"./grid-3x3-BEVg6Gq-.js";import"./coins-DOgeKu_2.js";import"./triangle-alert-HkRzuhoo.js";import"./search-Dq0igYZw.js";import"./chart-column-lczEX_mN.js";import"./eye-919-urbY.js";import"./shield-check-BSPo-3b9.js";import"./credit-card-cX0KhpZr.js";import"./mail-D0Oydl7s.js";import"./vendor-react-CHemKkfq.js";import"./index-Dh4i1-J3.js";function ve(){const[n,g]=A.useState(30),{data:t,isLoading:m}=C({queryKey:["/api/admin/analytics/ai-events",n],queryFn:async()=>{const{data:{session:a}}=await S.auth.getSession(),i=await fetch(`/api/admin/analytics/ai-events?days=${n}`,{headers:{Authorization:`Bearer ${a==null?void 0:a.access_token}`}});if(!i.ok)throw new Error("Failed");return i.json()}}),s=t==null?void 0:t.totals,N=s!=null&&s.started?Math.round(s.failed/s.started*100):0,y=s!=null&&s.started?Math.round(s.abandoned/s.started*100):0,b=s!=null&&s.started?Math.round(s.completed/s.started*100):0;return e.jsx(w,{title:"AI Tool Reliability",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"AI Tool Reliability"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Failure and abandonment rates across all AI streaming tools."})]}),e.jsx(I,{value:n,onChange:g})]}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-5 gap-4",children:[e.jsx(o,{label:"Started",value:(s==null?void 0:s.started)??0,icon:e.jsx(L,{className:"h-4 w-4"})}),e.jsx(o,{label:"Completed",value:(s==null?void 0:s.completed)??0,icon:e.jsx(M,{className:"h-4 w-4"}),hint:`${b}% rate`}),e.jsx(o,{label:"Failed",value:(s==null?void 0:s.failed)??0,icon:e.jsx(H,{className:"h-4 w-4"}),hint:`${N}% rate`}),e.jsx(o,{label:"Abandoned",value:(s==null?void 0:s.abandoned)??0,icon:e.jsx(O,{className:"h-4 w-4"}),hint:`${y}% rate`}),e.jsx(o,{label:"Total Sessions",value:((s==null?void 0:s.started)??0)+((s==null?void 0:s.completed)??0),icon:e.jsx(X,{className:"h-4 w-4"})})]}),e.jsxs(x,{children:[e.jsx(h,{children:e.jsxs(j,{className:"text-base",children:["AI events trend â last ",n," days"]})}),e.jsx(p,{children:m?e.jsx(c,{className:"h-64 w-full"}):e.jsx("div",{style:{width:"100%",height:280},children:e.jsx(F,{children:e.jsxs(E,{data:(t==null?void 0:t.trend)||[],margin:{top:5,right:10,left:-20,bottom:0},children:[e.jsx(B,{strokeDasharray:"3 3",className:"opacity-30"}),e.jsx(D,{dataKey:"date",tickFormatter:a=>a.slice(5),fontSize:11}),e.jsx($,{fontSize:11,allowDecimals:!1}),e.jsx(z,{contentStyle:{background:"hsl(var(--card))",border:"1px solid hsl(var(--border))",fontSize:12}}),e.jsx(K,{wrapperStyle:{fontSize:12}}),e.jsx(d,{type:"monotone",dataKey:"completed",stackId:"1",stroke:"hsl(140 60% 45%)",fill:"hsl(140 60% 45%)",fillOpacity:.5}),e.jsx(d,{type:"monotone",dataKey:"failed",stackId:"1",stroke:"hsl(0 70% 55%)",fill:"hsl(0 70% 55%)",fillOpacity:.5}),e.jsx(d,{type:"monotone",dataKey:"abandoned",stackId:"1",stroke:"hsl(40 90% 55%)",fill:"hsl(40 90% 55%)",fillOpacity:.5})]})})})})]}),e.jsxs(x,{children:[e.jsx(h,{children:e.jsx(j,{className:"text-base",children:"Per-tool reliability"})}),e.jsx(p,{className:"p-0",children:m?e.jsxs("div",{className:"p-6 space-y-3",children:[e.jsx(c,{className:"h-10 w-full"}),e.jsx(c,{className:"h-10 w-full"})]}):((t==null?void 0:t.items)||[]).length===0?e.jsx("p",{className:"p-12 text-center text-muted-foreground text-sm",children:"No AI events logged yet."}):e.jsxs(k,{children:[e.jsx(R,{children:e.jsxs(u,{children:[e.jsx(r,{children:"Tool"}),e.jsx(r,{className:"text-right",children:"Started"}),e.jsx(r,{className:"text-right",children:"Completed"}),e.jsx(r,{className:"text-right",children:"Failed"}),e.jsx(r,{className:"text-right",children:"Abandoned"}),e.jsx(r,{className:"text-right",children:"Success"}),e.jsx(r,{className:"text-right",children:"Failure"}),e.jsx(r,{className:"text-right",children:"Avg Duration"}),e.jsx(r,{children:"Last Errors"})]})}),e.jsx(T,{children:((t==null?void 0:t.items)||[]).map(a=>e.jsxs(u,{children:[e.jsx(l,{className:"font-medium",children:a.toolSlug}),e.jsx(l,{className:"text-right font-mono text-sm",children:a.started}),e.jsx(l,{className:"text-right font-mono text-sm",children:a.completed}),e.jsx(l,{className:"text-right font-mono text-sm",children:a.failed}),e.jsx(l,{className:"text-right font-mono text-sm",children:a.abandoned}),e.jsx(l,{className:"text-right",children:e.jsxs(f,{variant:a.completionRate>=80?"default":"secondary",className:"text-xs font-mono",children:[a.completionRate,"%"]})}),e.jsx(l,{className:"text-right",children:a.failureRate>0?e.jsxs(f,{variant:"destructive",className:"text-xs font-mono",children:[a.failureRate,"%"]}):e.jsx("span",{className:"text-muted-foreground text-xs",children:"0%"})}),e.jsxs(l,{className:"text-right font-mono text-xs flex items-center justify-end gap-1",children:[e.jsx(q,{className:"h-3 w-3 text-muted-foreground"}),a.avgDurationMs?`${(a.avgDurationMs/1e3).toFixed(1)}s`:"â"]}),e.jsx(l,{className:"max-w-xs",children:a.recentErrors.length===0?e.jsx("span",{className:"text-xs text-muted-foreground",children:"â"}):e.jsx("div",{className:"space-y-1",children:a.recentErrors.map((i,v)=>e.jsx("div",{className:"text-xs text-muted-foreground truncate",title:i.message,children:i.message},v))})})]}
1,a.toolSlug))})]})})]})]})})}export{ve 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.