PageSourceSearch

https://fcareportsaustralia.com.au/static/js/5872.642772d6.chunk.js

js fcareportsaustralia.com.au collected 2026-10-07 22:04:06 UTC 27,640 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunkfrontend=self.webpackChunkfrontend||[]).push([[5872],{1089(e,t,s){s.d(t,{cn:()=>l});var a=s(8387),r=s(9359);function l(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return(0,r.QP)((0,a.$)(t))}},4158(e,t,s){s.d(t,{Fc:()=>u,TN:()=>h});var a=s(9379),r=s(3986),l=s(5043),n=s(917),i=s(1089),d=s(579);const o=["className","variant"],c=["className"],x=["className"],m=(0,n.F)("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),u=l.forwardRef((e,t)=>{let{className:s,variant:l}=e,n=(0,r.A)(e,o);return(0,d.jsx)("div",(0,a.A)({ref:t,role:"alert",className:(0,i.cn)(m({variant:l}),s)},n))});u.displayName="Alert";l.forwardRef((e,t)=>{let{className:s}=e,l=(0,r.A)(e,c);return(0,d.jsx)("h5",(0,a.A)({ref:t,className:(0,i.cn)("mb-1 font-medium leading-none tracking-tight",s)},l))}).displayName="AlertTitle";const h=l.forwardRef((e,t)=>{let{className:s}=e,l=(0,r.A)(e,x);return(0,d.jsx)("div",(0,a.A)({ref:t,className:(0,i.cn)("text-sm [&_p]:leading-relaxed",s)},l))});h.displayName="AlertDescription"},5872(e,t,s){s.r(t),s.d(t,{default:()=>ue});var a=s(5043),r=s(5685),l=s(9722),n=s(7737),i=s(7719),d=s(2029),o=s(2024),c=s(3062),x=s(8899),m=s(9493),u=s(7010),h=s(4919),p=s(6405),v=s(8646),g=s(1180),b=s(5231),f=s(7734),N=s(2185),j=s(6026),w=s(3670),y=s(435),_=s(9379),k=s(3986),A=s(1089),C=s(579);const S=["className"],R=["className"],T=["className"],F=["className"],I=["className"],D=["className"],U=a.forwardRef((e,t)=>{let{className:s}=e,a=(0,k.A)(e,S);return(0,C.jsx)("div",(0,_.A)({ref:t,className:(0,A.cn)("rounded-xl border bg-card text-card-foreground shadow",s)},a))});U.displayName="Card";a.forwardRef((e,t)=>{let{className:s}=e,a=(0,k.A)(e,R);return(0,C.jsx)("div",(0,_.A)({ref:t,className:(0,A.cn)("flex flex-col space-y-1.5 p-6",s)},a))}).displayName="CardHeader";a.forwardRef((e,t)=>{let{className:s}=e,a=(0,k.A)(e,T);return(0,C.jsx)("div",(0,_.A)({ref:t,className:(0,A.cn)("font-semibold leading-none tracking-tight",s)},a))}).displayName="CardTitle";a.forwardRef((e,t)=>{let{className:s}=e,a=(0,k.A)(e,F);return(0,C.jsx)("div",(0,_.A)({ref:t,className:(0,A.cn)("text-sm text-muted-foreground",s)},a))}).displayName="CardDescription";a.forwardRef((e,t)=>{let{className:s}=e,a=(0,k.A)(e,I);return(0,C.jsx)("div",(0,_.A)({ref:t,className:(0,A.cn)("p-6 pt-0",s)},a))}).displayName="CardContent";a.forwardRef((e,t)=>{let{className:s}=e,a=(0,k.A)(e,D);return(0,C.jsx)("div",(0,_.A)({ref:t,className:(0,A.cn)("flex items-center p-6 pt-0",s)},a))}).displayName="CardFooter";var E=s(1467),z=s(917);const K=["className","variant","size","asChild"],B=(0,z.F)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),P=a.forwardRef((e,t)=>{let{className:s,variant:a,size:r,asChild:l=!1}=e,n=(0,k.A)(e,K);const i=l?E.DX:"button";return(0,C.jsx)(i,(0,_.A)({className:(0,A.cn)(B({variant:a,size:r,className:s})),ref:t},n))});P.displayName="Button";const H=["className","variant"],L=(0,z.F)("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function $(e){let{className:t,variant:s}=e,a=(0,k.A)(e,H);return(0,C.jsx)("div",(0,_.A)({className:(0,A.cn)(L({variant:s}),t)},a))}var M=s(4158);const O=["className"],V=["className"],W=["className"],Q=["className"],X=["className"],q=["className"],G=["className"],J=["className"],Y=a.forwardRef((e,t)=>
1{let{className:s}=e,a=(0,k.A)(e,O);return(0,C.jsx)("div",{className:"relative w-full overflow-auto",children:(0,C.jsx)("table",(0,_.A)({ref:t,className:(0,A.cn)("w-full caption-bottom text-sm",s)},a))})});Y.displayName="Table";const Z=a.forwardRef((e,t)=>{let{className:s}=e,a=(0,k.A)(e,V);return(0,C.jsx)("thead",(0,_.A)({ref:t,className:(0,A.cn)("[&_tr]:border-b",s)},a))});Z.displayName="TableHeader";const ee=a.forwardRef((e,t)=>{let{className:s}=e,a=(0,k.A)(e,W);return(0,C.jsx)("tbody",(0,_.A)({ref:t,className:(0,A.cn)("[&_tr:last-child]:border-0",s)},a))});ee.displayName="TableBody";a.forwardRef((e,t)=>{let{className:s}=e,a=(0,k.A)(e,Q);return(0,C.jsx)("tfoot",(0,_.A)({ref:t,className:(0,A.cn)("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",s)},a))}).displayName="TableFooter";const te=a.forwardRef((e,t)=>{let{className:s}=e,a=(0,k.A)(e,X);return(0,C.jsx)("tr",(0,_.A)({ref:t,className:(0,A.cn)("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",s)},a))});te.displayName="TableRow";const se=a.forwardRef((e,t)=>{let{className:s}=e,a=(0,k.A)(e,q);return(0,C.jsx)("th",(0,_.A)({ref:t,className:(0,A.cn)("h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s)},a))});se.displayName="TableHead";const ae=a.forwardRef((e,t)=>{let{className:s}=e,a=(0,k.A)(e,G);return(0,C.jsx)("td",(0,_.A)({ref:t,className:(0,A.cn)("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s)},a))});ae.displayName="TableCell";a.forwardRef((e,t)=>{let{className:s}=e,a=(0,k.A)(e,J);return(0,C.jsx)("caption",(0,_.A)({ref:t,className:(0,A.cn)("mt-4 text-sm text-muted-foreground",s)},a))}).displayName="TableCaption";const re="fca_admin_token_v1",le="".concat("https://fcareportsaustralia.com.au","/api/admin/cost"),ne=e=>{if(null===e||void 0===e)return"\u2014";const t=Number(e);return Number.isFinite(t)?"US$".concat(t.toFixed(2)):"\u2014"},ie=e=>null===e||void 0===e?"\u2014":Number(e).toLocaleString(),de=e=>{if(!e)return"\u2014";try{return new Date(e).toLocaleString("en-AU",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch(t){return e}};function oe(e){let{authError:t,onSignIn:s}=e;const[r,l]=(0,a.useState)("");return(0,C.jsx)("main",{className:"min-h-screen grid place-items-center bg-stone-50 px-4",children:(0,C.jsxs)(U,{className:"w-full max-w-md p-8 bg-white border border-stone-200 shadow-sm",children:[(0,C.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,C.jsx)("div",{className:"w-10 h-10 rounded-lg bg-teal-50 grid place-items-center",children:(0,C.jsx)(n.A,{className:"w-5 h-5 text-teal-700"})}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-[15px] font-semibold text-stone-900",children:"Admin Cost Dashboard"}),(0,C.jsx)("div",{className:"text-[12px] text-stone-500",children:"Enter your admin token to continue"})]})]}),t&&(0,C.jsxs)(M.Fc,{variant:"destructive",className:"mb-3",children:[(0,C.jsx)(i.A,{className:"w-4 h-4"}),(0,C.jsx)(M.TN,{children:t})]}),(0,C.jsxs)("form",{onSubmit:e=>{e.preventDefault(),s(r)},className:"space-y-3",children:[(0,C.jsx)("input",{"data-testid":"admin-cost-token-input",type:"password",value:r,onChange:e=>l(e.target.value),placeholder:"Admin token",className:"w-full px-3 py-2 border border-stone-300 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-teal-500"}),(0,C.jsx)(P,{"data-testid":"admin-cost-signin-btn",type:"submit",className:"w-full bg-teal-700 hover:bg-teal-800 text-white",children:"Sign in"})]})]})})}function ce(e){let{token:t,onRecorded:s}=e;const[r,n]=(0,a.useState)(""),[c,x]=(0,a.useState)(""),[m,u]=(0,a.useState)(!1),[h,p]=(0,a.useState)("");return(0,C.jsxs)(U,{className:"p-5 border border-stone-200 bg-white",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,C.jsx)(d.A,{className:"w-4 h-4 text-teal-700"}),(0,C.jsx)("div",{className:"text-[13px] font-semibold text-stone-900",children:"Record Universal Key Balance"})]}),(0,C.jsx)("p",{className:"text-[12px] text-stone-500 mb-3",children:"Enter your current Universal Key balance after each top-up. The dashboard will subtract app-observed spend to estimate remaining balance."}),h&&(0,C.jsxs)(M.Fc,{variant:"destructive",className:"mb-3",children:[(0,C.jsx)(i.A,{className:"w-4 h-4"}),(0,C.jsx)(M.TN,{children:h})]}),(0,C.jsxs)("form",{onSubmit:async e=>{e.preventDefault(),p("");const a=parseFloat(r);if(!Number.isFinite(a)||a<0)p("Enter a positive USD amount.");else{u(!0);try{await l.A.post("".concat(le,"/balance?token=").concat(encodeURIComponent(t)),{balance_usd:a,note:c||null}),n(""),x(""),s&&s()}catch(o){var i,d;p((null===o||void 0===o||null===(i=o.response)||void 0===i||null===(d=i.data)||void 0===d?void 0:d.detail)||o.message)}finally{u(!1)}}},className:"flex flex-col sm:flex-row gap-2",children:[(0,C.jsx)("input",{"data-testid":"admin-cost-balance-input",type:"number",step:"0.01",min:"0",value:r,onChange:e=>n(e.target.value),placeholder:"Balance in USD (e.g. 50.00)",className:"flex-1 px-3 py-2 border border-stone-300 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-teal-500"}),(0,C.jsx)("input",{"data-testid":"admin-cost-balance-note",type:"text",value:c,onChange:e=>x(e.target.value),placeholder:"Note (optional)",className:"flex-1 px-3 py-2 border border-stone-300 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-teal-500"}),(0,C.jsx)(P,{"data-testid":"admin-cost-balance-save-btn",type:"submit",disabled:m,className:"bg-teal-700 hover:bg-teal-800 text-white",children:m?(0,C.jsx)(o.A,{className:"w-4 h-4 animate-spin"}):"Record"})]})]})}function xe(e){let{balance:t,preflight:s}=e;if(null===t||void 0===t||!t.configured)return(0,C.jsxs)(U,{"data-testid":"admin-cost-balance-tile",className:"p-5 border border-stone-200 bg-white",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,C.jsx)(d.A,{className:"w-4 h-4 text-stone-500"}),(0,C.jsx)("div",{className:"text-[12px] text-stone-500 uppercase tracking-wide",children:"Universal Key Balance"})]}),(0,C.jsx)("div",{className:"text-2xl font-semibold text-stone-400 mb-1",children:"Not recorded"}),(0,C.jsx)("div",{className:"text-[12px] text-stone-500",children:"Record your current balance below to enable warnings."})]});const a=(null===s||void 0===s?void 0:s.status)||"unknown",r="sufficient"===a?"bg-emerald-50 text-emerald-700 border-emerald-200":"low"===a?"bg-amber-50 text-amber-700 border-amber-200":"insufficient"===a?"bg-red-50 text-red-700 border-red-200":"bg-stone-50 text-stone-700 border-stone-200";return(0,C.jsxs)(U,{"data-testid":"admin-cost-balance-tile",className:"p-5 border border-stone-200 bg-white",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,C.jsx)(d.A,{className:"w-4 h-4 text-teal-700"}),(0,C.jsx)("div",{className:"text-[12px] text-stone-500 uppercase tracking-wide",children:"Universal Key Balance"})]}),(0,C.jsx)("div",{className:"text-2xl font-semibold text-stone-900 mb
1-1",children:ne(t.estimated_remaining_usd)}),(0,C.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,C.jsx)($,{className:"text-[11px] ".concat(r),variant:"outline",children:a}),null!==(null===s||void 0===s?void 0:s.estimated_reviews_remaining)&&void 0!==(null===s||void 0===s?void 0:s.estimated_reviews_remaining)&&(0,C.jsxs)("span",{className:"text-[12px] text-stone-500",children:["~",s.estimated_reviews_remaining," large FCAs remaining"]})]}),(0,C.jsxs)("div",{className:"text-[11px] text-stone-500",children:["Recorded ",ne(t.recorded_balance_usd)," on ",de(t.recorded_at),(0,C.jsx)("br",{}),"Spent since: ",ne(t.spend_since_recorded_usd)]})]})}function me(e){let{label:t,data:s,testId:a}=e;return(0,C.jsxs)(U,{"data-testid":a,className:"p-5 border border-stone-200 bg-white",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,C.jsx)(c.A,{className:"w-4 h-4 text-teal-700"}),(0,C.jsx)("div",{className:"text-[12px] text-stone-500 uppercase tracking-wide",children:t})]}),(0,C.jsx)("div",{className:"text-2xl font-semibold text-stone-900 mb-1",children:ne(null===s||void 0===s?void 0:s.estimated_cost_usd)}),(0,C.jsxs)("div",{className:"text-[11px] text-stone-500",children:[ie(null===s||void 0===s?void 0:s.call_count)," calls \xb7 ",ie(null===s||void 0===s?void 0:s.total_tokens)," tokens"]})]})}function ue(){var e,t,s,n,d,c,_,k,A,S,R;const{token:T,authError:F,setAuthError:I,signIn:D,signOut:E}=(()=>{const[e,t]=(0,a.useState)(()=>localStorage.getItem(re)||""),[s,r]=(0,a.useState)("");return{token:e,authError:s,setAuthError:r,signIn:e=>{const s=(e||"").trim();s&&(localStorage.setItem(re,s),t(s),r(""))},signOut:()=>{localStorage.removeItem(re),t("")}}})(),[z,K]=(0,a.useState)(!1),[B,H]=(0,a.useState)(""),[L,$]=(0,a.useState)(null),[O,V]=(0,a.useState)(null),[W,Q]=(0,a.useState)(""),[X,q]=(0,a.useState)(null),[G,J]=(0,a.useState)(!1),[de,ue]=(0,a.useState)(""),he=(0,a.useCallback)(async()=>{if(T){K(!0),H("");try{const[e,t]=await Promise.all([l.A.get("".concat(le,"/dashboard?token=").concat(encodeURIComponent(T))),l.A.get("".concat(le,"/preflight?token=").concat(encodeURIComponent(T)))]);$(e.data),V(t.data)}catch(a){var e,t,s;if(401===(null===a||void 0===a||null===(e=a.response)||void 0===e?void 0:e.status))I("Token rejected. Please sign in again."),localStorage.removeItem(re),E();else H((null===a||void 0===a||null===(t=a.response)||void 0===t||null===(s=t.data)||void 0===s?void 0:s.detail)||a.message)}finally{K(!1)}}},[T,I,E]);(0,a.useEffect)(()=>{he()},[he]);const pe=(0,a.useMemo)(()=>((null===L||void 0===L?void 0:L.by_stage)||[]).slice(0,12),[L]);return T?(0,C.jsx)("main",{"data-testid":"admin-cost-page",className:"min-h-screen bg-stone-50",children:(0,C.jsxs)("div",{className:"max-w-7xl mx-auto px-6 py-8",children:[(0,C.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-[12px] text-teal-700 uppercase tracking-wide mb-1",children:"AI Operations"}),(0,C.jsx)("h1",{className:"text-2xl font-semibold text-stone-900",children:"Cost & Universal Key Dashboard"}),(0,C.jsx)("p",{className:"text-[13px] text-stone-500 mt-1",children:"Estimated app-side telemetry. Reconcile against Universal Key transaction history for source-of-truth billing."})]}),(0,C.jsxs)("div",{className:"flex items-center gap-2",children:[(0,C.jsx)(r.N_,{to:"/admin/fca-review",className:"text-[13px] text-stone-500 hover:text-teal-700",children:"\u2190 Back to FCA Review"}),(0,C.jsxs)(P,{"data-testid":"admin-cost-refresh-btn",variant:"outline",size:"sm",onClick:he,disabled:z,children:[z?(0,C.jsx)(o.A,{className:"w-4 h-4 animate-spin mr-1"}):(0,C.jsx)(x.A,{className:"w-4 h-4 mr-1"}),"Refresh"]}),(0,C.jsxs)(P,{"data-testid":"admin-cost-signout-btn",variant:"ghost",size:"sm",onClick:E,children:[(0,C.jsx)(m.A,{className:"w-4 h-4 mr-1"})," Sign out"]})]})]}),B&&(0,C.jsxs)(M.Fc,{variant:"destructive",className:"mb-4",children:[(0,C.jsx)(i.A,{className:"w-4 h-4"}),(0,C.jsx)(M.TN,{"data-testid":"admin-cost-error",children:B})]}),O&&(0,C.jsxs)(M.Fc,{"data-testid":"admin-cost-preflight-banner",className:"mb-4 ".concat("insufficient"===O.status?"border-red-300 bg-red-50":"low"===O.
1status?"border-amber-300 bg-amber-50":"sufficient"===O.status?"border-emerald-300 bg-emerald-50":"border-stone-300 bg-stone-50"),children:[(0,C.jsx)(i.A,{className:"w-4 h-4 ".concat("insufficient"===O.status?"text-red-600":"low"===O.status?"text-amber-600":"sufficient"===O.status?"text-emerald-600":"text-stone-500")}),(0,C.jsxs)(M.TN,{children:[(0,C.jsx)("div",{className:"text-[13px] text-stone-800",children:O.banner_message}),("insufficient"===O.status||"low"===O.status)&&O.topup_url&&(0,C.jsxs)("a",{"data-testid":"admin-cost-topup-link",href:O.topup_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 mt-1 text-[12px] font-medium text-teal-700 hover:text-teal-900",children:["Top up Universal Key ",(0,C.jsx)(u.A,{className:"w-3 h-3"})]})]})]}),(0,C.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-4 mb-6",children:[(0,C.jsx)(xe,{balance:null===L||void 0===L?void 0:L.balance,preflight:O}),(0,C.jsx)(me,{label:"Today",data:null===L||void 0===L||null===(e=L.summary)||void 0===e?void 0:e.today,testId:"admin-cost-tile-today"}),(0,C.jsx)(me,{label:"This Week",data:null===L||void 0===L||null===(t=L.summary)||void 0===t?void 0:t.this_week,testId:"admin-cost-tile-week"}),(0,C.jsx)(me,{label:"This Month",data:null===L||void 0===L||null===(s=L.summary)||void 0===s?void 0:s.this_month,testId:"admin-cost-tile-month"}),(0,C.jsx)(me,{label:"All-time",data:null===L||void 0===L||null===(n=L.summary)||void 0===n?void 0:n.all_time,testId:"admin-cost-tile-alltime"})]}),(0,C.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 mb-6",children:[(0,C.jsxs)(U,{"data-testid":"admin-cost-avg-per-review",className:"p-5 border border-stone-200 bg-white",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,C.jsx)(h.A,{className:"w-4 h-4 text-teal-700"}),(0,C.jsx)("div",{className:"text-[13px] font-semibold text-stone-900",children:"Average Cost Per FCA (last 5)"})]}),(0,C.jsx)("div",{className:"text-3xl font-semibold text-stone-900 mb-2",children:ne(null===L||void 0===L||null===(d=L.avg_per_review)||void 0===d?void 0:d.avg_usd)}),(0,C.jsxs)("div",{className:"text-[12px] text-stone-500",children:["Based on ",ie(null===L||void 0===L||null===(c=L.avg_per_review)||void 0===c?void 0:c.sample_size)," recent reviews.",0===((null===L||void 0===L||null===(_=L.avg_per_review)||void 0===_?void 0:_.sample_size)||0)&&(0,C.jsx)(C.Fragment,{children:" (No history yet \u2014 falls back to ~$12 conservative estimate for the pre-flight banner.)"})]})]}),(0,C.jsxs)(U,{"data-testid":"admin-cost-total-tokens",className:"p-5 border border-stone-200 bg-white",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,C.jsx)(p.A,{className:"w-4 h-4 text-teal-700"}),(0,C.jsx)("div",{className:"text-[13px] font-semibold text-stone-900",children:"Total Tokens (all-time)"})]}),(0,C.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-[11px] text-stone-500 uppercase tracking-wide mb-1",children:"Prompt"}),(0,C.jsx)("div",{className:"text-xl font-semibold text-stone-900",children:ie(null===L||void 0===L||null===(k=L.summary)||void 0===k||null===(A=k.all_time)||void 0===A?void 0:A.total_prompt_tokens)})]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-[11px] text-stone-500 uppercase tracking-wide mb-1",children:"Completion"}),(0,C.jsx)("div",{className:"text-xl font-semibold text-stone-900",children:ie(null===L||void 0===L||null===(S=L.summary)||void 0===S||null===(R=S.all_time)||void 0===R?void 0:R.total_completion_tokens)})]})]})]})]}),(0,C.jsxs)(U,{"data-testid":"admin-cost-trend-chart",className:"p-5 border border-stone-200 bg-white mb-6",children:[(0,C.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,C.jsx)(v.A,{className:"w-4 h-4 text-teal-700"}),(0,C.jsx)("div",{className:"text-[13px] font-semibold text-stone-900",children:"Daily Spend \u2014 Last 30 Days"})]}),(0,C.jsx)("div",{className:"h-56 w-full",style:{minHeight:220},children:((null===L||void 0===L?void 0:L.daily_series_30d)||[]).length>0?(0,C.jsx)(g.u,{width:"100%",height:"100%",children:(0,C.jsxs)(b.b,{data:L.daily_series_30d,margin:{top:5,right:10,left:0,bottom:5},children:[(0,C.jsx)(f.d,{strokeDasharray:"3 3",stroke:"#e7e5e4"}),(0,C.jsx)(N.W,{dataKey:"date",tick:{fontSize:10}
1,tickFormatter:e=>e.slice(5)}),(0,C.jsx)(j.h,{tick:{fontSize:10},tickFormatter:e=>"$".concat(e.toFixed(0))}),(0,C.jsx)(w.m,{formatter:e=>[ne(e),"Cost"],labelFormatter:e=>"Date: ".concat(e),contentStyle:{fontSize:12}}),(0,C.jsx)(y.N1,{type:"monotone",dataKey:"estimated_cost_usd",stroke:"#0f766e",strokeWidth:2,dot:{r:3},activeDot:{r:5}})]})}):(0,C.jsx)("div",{className:"grid place-items-center h-full text-[12px] text-stone-400",children:"No spend data yet."})})]}),(0,C.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 mb-6",children:[(0,C.jsxs)(U,{"data-testid":"admin-cost-top-expensive",className:"p-5 border border-stone-200 bg-white",children:[(0,C.jsx)("div",{className:"text-[13px] font-semibold text-stone-900 mb-3",children:"Top 10 Most Expensive Reviews"}),(0,C.jsx)("div",{className:"overflow-x-auto",children:(0,C.jsxs)(Y,{children:[(0,C.jsx)(Z,{children:(0,C.jsxs)(te,{children:[(0,C.jsx)(se,{className:"text-[11px]",children:"Review ID"}),(0,C.jsx)(se,{className:"text-[11px] text-right",children:"Calls"}),(0,C.jsx)(se,{className:"text-[11px] text-right",children:"Tokens"}),(0,C.jsx)(se,{className:"text-[11px] text-right",children:"Cost"})]})}),(0,C.jsxs)(ee,{children:[((null===L||void 0===L?void 0:L.top_expensive_reviews)||[]).map(e=>{var t;return(0,C.jsxs)(te,{"data-testid":"admin-cost-top-row-".concat(e.review_id),className:"cursor-pointer hover:bg-stone-50",onClick:()=>{Q(e.review_id)},children:[(0,C.jsxs)(ae,{className:"text-[12px] font-mono",children:[null===(t=e.review_id)||void 0===t?void 0:t.slice(0,12),"\u2026"]}),(0,C.jsx)(ae,{className:"text-[12px] text-right",children:ie(e.call_count)}
1),(0,C.jsx)(ae,{className:"text-[12px] text-right",children:ie(e.total_tokens)}),(0,C.jsx)(ae,{className:"text-[12px] text-right font-semibold",children:ne(e.estimated_cost_usd)})]},e.review_id)}),(!(null!==L&&void 0!==L&&L.top_expensive_reviews)||0===L.top_expensive_reviews.length)&&(0,C.jsx)(te,{children:(0,C.jsx)(ae,{colSpan:4,className:"text-[12px] text-center text-stone-400 py-6",children:"No reviews yet."})})]})]})})]}),(0,C.jsxs)(U,{"data-testid":"admin-cost-by-stage",className:"p-5 border border-stone-200 bg-white",children:[(0,C.jsx)("div",{className:"text-[13px] font-semibold text-stone-900 mb-3",children:"Average Cost by Review Stage"}),(0,C.jsx)("div",{className:"overflow-x-auto",children:(0,C.jsxs)(Y,{children:[(0,C.jsx)(Z,{children:(0,C.jsxs)(te,{children:[(0,C.jsx)(se,{className:"text-[11px]",children:"Stage"}),(0,C.jsx)(se,{className:"text-[11px] text-right",children:"Calls"}),(0,C.jsx)(se,{className:"text-[11px] text-right",children:"Avg / call"}),(0,C.jsx)(se,{className:"text-[11px] text-right",children:"Total"})]})}),(0,C.jsxs)(ee,{children:[pe.map(e=>(0,C.jsxs)(te,{children:[(0,C.jsx)(ae,{className:"text-[12px]",children:e.stage_key}),(0,C.jsx)(ae,{className:"text-[12px] text-right",children:ie(e.call_count)}
1),(0,C.jsx)(ae,{className:"text-[12px] text-right",children:ne(e.avg_usd_per_call)}),(0,C.jsx)(ae,{className:"text-[12px] text-right font-semibold",children:ne(e.total_usd)})]},e.stage_key)),0===pe.length&&(0,C.jsx)(te,{children:(0,C.jsx)(ae,{colSpan:4,className:"text-[12px] text-center text-stone-400 py-6",children:"No stage data yet."})})]})]})})]})]}),(0,C.jsxs)(U,{"data-testid":"admin-cost-drill",className:"p-5 border border-stone-200 bg-white mb-6",children:[(0,C.jsx)("div",{className:"text-[13px] font-semibold text-stone-900 mb-3",children:"Individual Review Cost Breakdown"}),(0,C.jsxs)("form",{onSubmit:e=>{e.preventDefault(),(async()=>{const e=W.trim();if(e){J(!0),ue(""),q(null);try{const t=await l.A.get("".concat(le,"/review/").concat(encodeURIComponent(e),"?token=").concat(encodeURIComponent(T)));q(t.data)}catch(a){var t,s;ue((null===a||void 0===a||null===(t=a.response)||void 0===t||null===(s=t.data)||void 0===s?void 0:s.detail)||a.message)}finally{J(!1)}}})()},className:"flex flex-col sm:flex-row gap-2 mb-4",children:[(0,C.jsx)("input",{"data-testid":"admin-cost-drill-input",type:"text",value:W,onChange:e=>Q(e.target.value),placeholder:"Enter review_id (or click a row in the leaderboard)",className:"flex-1 px-3 py-2 border border-stone-300 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-teal-500"}),(0,C.jsx)(P,{"data-testid":"admin-cost-drill-btn",type:"submit",disabled:G,className:"bg-teal-700 hover:bg-teal-800 text-white",children:G?(0,C.jsx)(o.A,{className:"w-4 h-4 animate-spin"}):"Load"})]}),de&&(0,C.jsxs)(M.Fc,{variant:"destructive",className:"mb-3",children:[(0,C.jsx)(i.A,{className:"w-4 h-4"}),(0,C.jsx)(M.TN,{children:de})]}),X&&(0,C.jsxs)("div",{"data-testid":"admin-cost-drill-result",children:[(0,C.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 mb-3 text-[12px]",children:[(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-stone-500 uppercase tracking-wide text-[10px]",children:"Calls"}),(0,C.jsx)("div",{className:"text-lg font-semibold",children:ie(X.call_count)})]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-stone-500 uppercase tracking-wide text-[10px]",children:"Prompt tokens"}),(0,C.jsx)("div",{className:"text-lg font-semibold",children:ie(X.total_prompt_tokens)})]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-stone-500 uppercase tracking-wide text-[10px]",children:"Completion tokens"}),(0,C.jsx)("div",{className:"text-lg font-semibold",children:ie(X.total_completion_tokens)})]}),(0,C.jsxs)("div",{children:[(0,C.jsx)("div",{className:"text-stone-500 uppercase tracking-wide text-[10px]",children:"Estimated cost"}),(0,C.jsx)("div",{className:"text-lg font-semibold text-teal-700",children:ne(X.estimated_cost_usd)})]})]}),(0,C.jsxs)(Y,{children:[(0,C.jsx)(Z,{children:(0,C.jsxs)(te,{children:[(0,C.jsx)(se,{className:"text-[11px]",children:"Stage"}),(0,C.jsx)(se,{className:"text-[11px] text-right",children:"Calls"}),(0,C.jsx)(se,{className:"text-[11px] text-right",children:"Prompt tokens"}),(0,C.jsx)(se,{className:"text-[11px] text-right",children:"Completion tokens"}),(0,C.jsx)(se,{className:"text-[11px] text-right",children:"Cost"})]})}),(0,C.jsx)(ee,{children:X.per_stage.map(e=>(0,C.jsxs)(te,{children:[(0,C.jsx)(ae,{className:"text-[12px]",children:e.stage_key}),(0,C.jsx)(ae,{className:"text-[12px] text-right",children:ie(e.calls)}),(0,C.jsx)(ae,{className:"text-[12px] text-right",children:ie(e.prompt_tokens)}),(0,C.jsx)(ae,{className:"text-[12px] text-right",children:ie(e.completion_tokens)}),(0,C.jsx)(ae,{className:"text-[12px] text-right font-semibold",children:ne(e.estimated_cost_usd)})]},e.stage_key))})]}),(0,C.jsx)("div",{className:"text-[11px] text-stone-400 mt-2 italic",children:X.note})]})]}),(0,C.jsx)(ce,{token:T,onRecorded:he}),(0,C.jsx)("div",{className:"text-[11px] text-stone-400 mt-6 text-center",children:"Cost figures are app-side estimates using published per-model rates. Reconcile against Universal Key transaction history for source-of-truth billing."})]})}):(0,C.jsx)(oe,{authError:F,onSignIn:D})}}}]);
2//# sourceMappingURL=5872.642772d6.chunk.js.map

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.