1import{r as a,j as e}from"./vendor-DG5Dz7Ik.js";import{e as g}from"./edgeInferenceAdminService-DWZw_k89.js";import"./view-analytics-BkPD6vG9.js";import"./pdf-vendor-BQyayL6K.js";import"./socket-vendor-DENoLIvz.js";import"./auth-vendor-CeReGQmr.js";const u={count:0,routedToEdgeCount:0,totalSavedUsdMicros:"0",latencyMs:{p50:0,p99:0}};function j(d){const t=Number.parseInt(d,10);return Number.isFinite(t)?`$${(t/1e6).toFixed(6)}`:"$0.0000"}const E=({orgId:d})=>{const[t,x]=a.useState(u),[c,m]=a.useState([]),[l,n]=a.useState(null),[i,o]=a.useState(!1),r=a.useCallback(async()=>{o(!0),n(null);try{const s=await g.fetchCostEvents(d,100);x({count:s.count,routedToEdgeCount:s.routedToEdgeCount,totalSavedUsdMicros:s.totalSavedUsdMicros,latencyMs:s.latencyMs}),m(s.items)}catch(s){n(s.message)}finally{o(!1)}},[d]);a.useEffect(()=>{r()},[r]);const h=t.count>0?t.routedToEdgeCount/t.count*100:0;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("header",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-white",children:"Edge Inference Cost Events"}),e.jsx("p",{className:"text-xs text-gray-400",children:"10% Cloudflare Workers AI / 90% in-region Cloud Run fallback â cost-event tally and latency telemetry."})]}),e.jsx("button",{onClick:()=>void r(),className:"bg-emerald-600 hover:bg-emerald-700 text-white text-xs px-3 py-1 rounded",children:"Refresh"})]}),l&&e.jsx("div",{className:"bg-red-900/50 border border-red-700 text-red-200 text-xs p-2 rounded",children:l}),e.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[e.jsxs("div",{className:"bg-gray-900 p-3 rounded",children:[e.jsx("div",{className:"text-xs text-gray-400",children:"Routed to edge"}),e.jsxs("div",{className:"text-xl text-white",children:[h.toFixed(1),"%"]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[t.routedToEdgeCount," / ",t.count]})]}),e.jsxs("div",{className:"bg-gray-900 p-3 rounded",children:[e.jsx("div",{className:"text-xs text-gray-400",children:"Saved cost"}),e.jsx("div",{className:"text-xl text-amber-300",children:j(t.totalSavedUsdMicros)}),e.jsx("div",{className:"text-xs text-gray-500",children:"across window"})]}),e.jsxs("div",{className:"bg-gray-900 p-3 rounded",children:[e.jsx("div",{className:"text-xs text-gray-400",children:"p50 latency"}),e.jsxs("div",{className:"text-xl text-emerald-300",children:[t.latencyMs.p50," ms"]})]}),e.jsxs("div",{className:"bg-gray-900 p-3 rounded",children:[e.jsx("div",{className:"text-xs text-gray-400",children:"p99 latency"}),e.jsxs("div",{className:"text-xl text-emerald-300",children:[t.latencyMs.p99," ms"]})]})]}),e.jsx("div",{className:"bg-gray-900 rounded overflow-hidden",children:e.jsxs("table",{className:"w-full text-xs text-left",children:[e.jsx("thead",{className:"bg-gray-800 text-gray-300",children:e.jsxs("tr",{children:[e.jsx("th",{className:"p-2",children:"Checkpoint"}),e.jsx("th",{className:"p-2",children:"Routed"}),e.jsx("th",{className:"p-2",children:"Latency"}),e.jsx("th",{className:"p-2",children:"Saved μUSD"}),e.jsx("th",{className:"p-2",children:"When"})]})}),e.jsxs("tbody",{children:[i&&e.jsx("tr",{children:e.jsx("td",{className:"p-2 text-gray-500",colSpan:5,children:"Loadingâ¦"})}),!i&&c.length===0&&e.jsx("tr",{children:e.jsx("td",{className:"p-2 text-gray-500",colSpan:5,children:"No events yet."})}),c.map(s=>e.jsxs("tr",{className:"border-t border-gray-800",children:[e.jsx("td",{className:"p-2 text-white",children:s.checkpointId}),e.jsx("td",{className:"p-2",children:s.routedToEdge?e.jsx("span",{className:"text-emerald-400",children:"edge"}):e.jsx("span",{className:"text-gray-400",children:"fallback"})}),e.jsxs("td",{className:"p-2 text-gray-300",children:[s.latencyMs," ms"]}),e.jsx("td",{className:"p-2 text-amber-300",children:s.savedCostUsdMicros}),e.jsx("td",{className:"p-2 text-gray-500",children:new Date(s.createdAt).toLocaleString()})]},s.id))]})]})})]})};export{E 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.