(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,302747,e=>{"use strict";var t=e.i(843476),a=e.i(271645),s=e.i(115504);let l=a.forwardRef(({className:e,...a},l)=>(0,t.jsx)("div",{ref:l,"data-slot":"skeleton",className:(0,s.cn)("animate-pulse rounded-md bg-muted",e),...a}));l.displayName="Skeleton",e.s(["Skeleton",0,l])},35440,e=>{"use strict";var t=e.i(843476),a=e.i(405033),s=e.i(271645),l=e.i(217923),d=e.i(266027),r=e.i(602869),i=e.i(519455),o=e.i(302747);function u(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function n({data:e,maxVal:a}){let s=Math.max(2,Math.floor(200/Math.max(e.length,1)));return(0,t.jsx)("div",{className:"flex items-end gap-px",style:{height:48},children:e.map((e,l)=>{let d=a>0?Math.max(2,e/a*48):2;return(0,t.jsx)("div",{className:"bg-primary rounded-[1px]",style:{width:s,height:d,opacity:.7+e/Math.max(a,1)*.3}},l)})})}let c=[{value:"7d",label:"7d"},{value:"30d",label:"30d"},{value:"90d",label:"90d"}],x=({accessToken:e,userId:a})=>{let x,m,[h,v]=(0,s.useState)("30d"),{start:g,end:b}=(x=new Date,(m=new Date).setDate(x.getDate()-("7d"===h?7:"30d"===h?30:90)),{start:m,end:x}),{data:p,isLoading:f}=(0,d.useQuery)({queryKey:["chat-user-usage",e,a,h],queryFn:()=>(0,r.userDailyActivityAggregatedCall)(e,g,b,a),enabled:!!e}),j=p?.metadata,N=p?.results??[],_=N.map(e=>e.metrics.spend),y=N.map(e=>e.metrics.api_requests),q=Math.max(..._,0),S=Math.max(...y,0),k=j?[{label:"Total Spend",value:`$${j.total_spend.toFixed(2)}`},{label:"API Requests",value:u(j.total_api_requests)},{label:"Tokens Used",value:u(j.total_tokens),sub:`${u(j.total_prompt_tokens)} in / ${u(j.total_completion_tokens)} out`},{label:"Success Rate",value:j.total_api_requests>0?`${(j.total_successful_requests/j.total_api_requests*100).toFixed(1)}%`:"N/A",sub:j.total_failed_requests>0?`${j.total_failed_requests} failed`:void 0,subVariant:j.total_failed_requests>0?"error":void 0}]:[];return(0,t.jsxs)("div",{className:"w-full",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-base font-semibold text-foreground mb-0.5",children:"Your Usage"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground m-0",children:"Spend and request activity"})]}),(0,t.jsx)("div",{className:"flex gap-1",children:c.map(e=>(0,t.jsx)(i.Button,{variant:h===e.value?"default":"outline",size:"sm",onClick:()=>v(e.value),children:e.label},e.value))})]}),f?(0,t.jsx)("div",{className:"grid grid-cols-2 gap-3",children:[void 0,void 0,void 0,void 0].map((e,a)=>(0,t.jsxs)("div",{className:"border rounded-lg p-4 bg-card flex flex-col gap-2",children:[(0,t.jsx)(o.Skeleton,{className:"h-3 w-1/2"}),(0,t.jsx)(o.Skeleton,{className:"h-5 w-2/3"})]},a))}):j&&0!==j.total_api_requests?(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"grid grid-cols-2 gap-3 mb-5",children:k.map(e=>(0,t.jsxs)("div",{className:"border rounded-lg p-4 bg-card",children:[(0,t.jsx)("div",{className:"text-xs text-muted-foreground mb-1",children:e.label}),(0,t.jsx)("div",{className:"text-xl font-semibold text-foreground",children:e.value}),e.sub&&(0,t.jsx)("div",{className:`text-xs mt-0.5 ${"error"===e.subVariant?"text-destructive":"text-muted-foreground"}`,children:e.sub})]},e.label))}),N.length>1&&(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,t.jsxs)("div",{className:"border rounded-lg p-4 bg-card",children:[(0,t.jsx)("div",{className:"text-xs text-muted-foreground mb-2",children:"Daily Spend"}),(0,t.jsx)(n,{data:_,maxVal:q})]}),(0,t.jsxs)("div",{className:"border rounded-lg p-4 bg-card",children:[(0,t.jsx)("div",{className:"text-xs text-muted-foreground mb-2",children:"Daily Requests"}),(0,t.jsx)(n,{data:y,maxVal:S})]})]})]}):(0,t.jsxs)("div",{className:"text-center text-muted-foreground text-sm py-12 border border-dashed rounded-lg",children:[(0,t.jsx)(l.BarChart3,{className:"h-6 w-6 mb-3 mx-auto text-muted-foreground/50"}),"No usage data for this period"]})]})};e.s(["default",0,function(){let{accessToken:e,userId:s}=(0,a.useChatShell)();return(0,t.jsx)("div",{className:"flex-1 min-h-0 overflow-auto w-full py-8 px-8",children:(0,t.jsx)(x,{accessToken:e,userId:s})})}],35440)}]);