(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,35064,e=>{"use strict";var s=e.i(43476),t=e.i(71645);function l(){let[e,l]=(0,t.useState)(null),[i,r]=(0,t.useState)(!0);return((0,t.useEffect)(()=>{fetch("/api/admin/stats").then(e=>e.json()).then(l).catch(console.error).finally(()=>r(!1))},[]),i)?(0,s.jsx)("div",{className:"py-20 text-center text-white/50",children:"Loading admin dashboard..."}):e?(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"text-2xl font-bold",children:"Admin Overview"}),(0,s.jsx)("p",{className:"text-sm text-white/50",children:"Platform-wide metrics and activity"})]}),(0,s.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[(0,s.jsx)(a,{label:"Total Users",value:e.totalUsers,sub:`+${e.signups7d} this week`}),(0,s.jsx)(a,{label:"MRR",value:`$${e.mrr}`,sub:`${e.usersByPlan?.starter||0} starter \xb7 ${e.usersByPlan?.pro||0} pro`}),(0,s.jsx)(a,{label:"Active Bots",value:e.activeBots,sub:`${e.totalBots} total`}),(0,s.jsx)(a,{label:"Conversations (24h)",value:e.conversations24h,sub:`${e.conversations7d} this week`}),(0,s.jsx)(a,{label:"Leads (7d)",value:e.leads7d,sub:`${e.totalLeads} total`}),(0,s.jsx)(a,{label:"Knowledge Chunks",value:e.totalChunks,sub:"Total stored"})]}),(0,s.jsx)("div",{className:"grid gap-4 md:grid-cols-3",children:["free","starter","pro"].map(t=>(0,s.jsxs)("div",{className:"rounded-2xl border border-white/10 bg-white/5 p-5",children:[(0,s.jsx)("p",{className:"text-xs font-semibold uppercase text-white/40",children:t}),(0,s.jsx)("p",{className:"mt-1 text-3xl font-bold",children:e.usersByPlan?.[t]||0}),(0,s.jsx)("p",{className:"text-xs text-white/40",children:"users"})]},t))}),(0,s.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,s.jsxs)("div",{className:"rounded-2xl border border-white/10 bg-white/5 p-5",children:[(0,s.jsx)("p",{className:"mb-3 text-sm font-semibold text-white/70",children:"Recent Signups"}),0===e.recentSignups.length?(0,s.jsx)("p",{className:"text-sm text-white/30",children:"No recent signups"}):(0,s.jsx)("div",{className:"space-y-2",children:e.recentSignups.map((e,t)=>(0,s.jsxs)("div",{className:"flex items-center justify-between rounded-xl bg-white/5 px-3 py-2 text-sm",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-medium",children:e.name}),(0,s.jsx)("p",{className:"text-xs text-white/40",children:e.email})]}),(0,s.jsxs)("div",{className:"text-right",children:[(0,s.jsx)("span",{className:"rounded-full bg-[var(--color-bg-brand)]/20 px-2 py-0.5 text-xs text-[var(--color-accent-green-light)]",children:e.plan}),(0,s.jsx)("p",{className:"mt-1 text-xs text-white/30",children:new Date(e.createdAt).toLocaleDateString()})]})]},t))})]}),(0,s.jsxs)("div",{className:"rounded-2xl border border-white/10 bg-white/5 p-5",children:[(0,s.jsx)("p",{className:"mb-3 text-sm font-semibold text-white/70",children:"Recent Bots Created"}),0===e.recentActivity.length?(0,s.jsx)("p",{className:"text-sm text-white/30",children:"No recent bots"}):(0,s.jsx)("div",{className:"space-y-2",children:e.recentActivity.map((e,t)=>(0,s.jsxs)("div",{className:"flex items-center justify-between rounded-xl bg-white/5 px-3 py-2 text-sm",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-medium",children:e.name}),(0,s.jsx)("p",{className:"text-xs text-white/40",children:e.userId?.email})]}),(0,s.jsx)("span",{className:`rounded-full px-2 py-0.5 text-xs ${"active"===e.status?"bg-green-500/20 text-green-400":"bg-yellow-500/20 text-yellow-400"}`,children:e.status})]},t))})]})]})]}):(0,s.jsx)("div",{className:"py-20 text-center text-red-400",children:"Failed to load stats"})}function a({label:e,value:t,sub:l}){return(0,s.jsxs)("div",{className:"rounded-2xl border border-white/10 bg-white/5 p-5",children:[(0,s.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wider text-white/40",children:e}),(0,s.jsx)("p",{className:"mt-2 text-3xl font-bold",children:t}),(0,s.jsx)("p",{className:"mt-1 text-xs text-white/40",children:l})]})}e.s(["default",()=>l])}]);