1import{j as e}from"./vendor-react-CfkQo2Qg.js";import{t as n}from"./index-DgwJNwTT.js";import{B as h}from"./Breadcrumbs-C5_OWaxK.js";import{R as u}from"./RelatedTools-BdteHLPx.js";import{B as o}from"./badge-D_pSxyaO.js";import{$ as c,E as m,ad as j,aI as g,V as N}from"./vendor-lucide-CpuI9xs4.js";import{R as f,L as v,C as y,X as R,Y as A,T as w,a as S,b as i}from"./vendor-recharts-Cht0p0lU.js";import"./vendor-cytoscape-q9j-66rY.js";import"./vendor-trpc-CqKgE1xI.js";import"./vendor-vite-preload-BXl3LOEh.js";import"./vendor-radix-overlay-DthDVWT0.js";import"./vendor-radix-base-ZbR3PUjz.js";import"./vendor-framer-BGJAXFmM.js";import"./vendor-d3-CzMK0bJS.js";function P(){const{data:r,isLoading:x}=n.emailAnalytics.getOverallStats.useQuery(),{data:a,isLoading:b}=n.emailAnalytics.getTimeSeriesData.useQuery(),{data:d,isLoading:p}=n.emailAnalytics.getRecentActivity.useQuery(),t=s=>s?`$${(s/100).toLocaleString()}`:"$0.00",l=s=>s?new Date(s).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"N/A";return e.jsxs("div",{className:"min-h-screen bg-background py-12",children:[e.jsxs("div",{className:"container mx-auto px-4",children:[e.jsx(h,{items:[{label:"Admin",href:"/admin"},{label:"Email Analytics"}]}),e.jsxs("div",{className:"mb-8",children:[e.jsx("h1",{className:"text-4xl font-display font-bold uppercase mb-2",children:"Email Analytics"}),e.jsx("p",{className:"text-muted-foreground",children:"Track cart recovery email performance and revenue impact"})]}),x?e.jsx("div",{className:"text-center py-12",children:e.jsx("div",{className:"inline-block w-8 h-8 border-4 border-primary border-t-transparent rounded-full animate-spin"})}):r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-8",children:[e.jsxs("div",{className:"bg-card border border-border p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx(c,{className:"w-8 h-8 text-blue-500"}),e.jsx("span",{className:"text-3xl font-bold",children:r.emailsSent})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Recovery Emails Sent"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["of ",r.totalCarts," abandoned carts"]})]}),e.jsxs("div",{className:"bg-card border border-border p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx(m,{className:"w-8 h-8 text-purple-500"}),e.jsxs("span",{className:"text-3xl font-bold",children:[r.openRate,"%"]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Email Open Rate"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[r.emailsOpened," emails opened"]})]}),e.jsxs("div",{className:"bg-card border border-border p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx(j,{className:"w-8 h-8 text-green-500"}),e.jsxs("span",{className:"text-3xl font-bold",children:[r.conversionRate,"%"]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Conversion Rate"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[r.recovered," carts recovered"]})]}),e.jsxs("div",{className:"bg-card border border-border p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx(g,{className:"w-8 h-8 text-primary"}),e.jsx("span",{className:"text-3xl font-bold",children:t(r.recoveredValue)})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Revenue Recovered"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[r.revenueRecoveryRate,"% of total at-risk"]})]})]}),e.jsxs("div",{className:"bg-card border border-border p-6 mb-8",children:[e.jsx("h3",{className:"text-xl font-bold mb-4",children:"Revenue Impact"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"Total At-Risk Revenue"}),e.jsx("p",{className:"text-2xl font-bold text-yellow-500",children:t(r.totalValue)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"Revenue Recovered"}),e.jsx("p",{className:"text-2xl font-bold text-green-500",children:t(r.recoveredValue)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"Still At Risk"}),e.jsx("p",{className:"text-2xl font-bold text-red-500",children:t(r.totalValue-r.recoveredValue)})]})]})]})]}):null,b?e.jsx("div",{className:"text-center py-12",children:e.jsx("div",{className:"inline-block w-8 h-8 border-4 border-primary border-t-transparent roun
1ded-full animate-spin"})}):a&&a.length>0?e.jsxs("div",{className:"bg-card border border-border p-6 mb-8",children:[e.jsx("h3",{className:"text-xl font-bold mb-4",children:"30-Day Performance Trend"}),e.jsx(f,{width:"100%",height:300,children:e.jsxs(v,{data:a,children:[e.jsx(y,{strokeDasharray:"3 3",stroke:"#333"}),e.jsx(R,{dataKey:"date",stroke:"#999"}),e.jsx(A,{stroke:"#999"}),e.jsx(w,{contentStyle:{backgroundColor:"#1a1a1a",border:"1px solid #333"},labelStyle:{color:"#9add26"}}),e.jsx(S,{}),e.jsx(i,{type:"monotone",dataKey:"sent",stroke:"#3b82f6",name:"Emails Sent"}),e.jsx(i,{type:"monotone",dataKey:"opened",stroke:"#a855f7",name:"Emails Opened"}),e.jsx(i,{type:"monotone",dataKey:"recovered",stroke:"#22c55e",name:"Carts Recovered"})]})})]}):null,p?e.jsx("div",{className:"text-center py-12",children:e.jsx("div",{className:"inline-block w-8 h-8 border-4 border-primary border-t-transparent rounded-full animate-spin"})}):d&&d.length>0?e.jsxs("div",{className:"bg-card border border-border p-6",children:[e.jsx("h3",{className:"text-xl font-bold mb-4",children:"Recent Recovery Activity"}),e.jsx("div",{className:"space-y-3",children:d.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-4 bg-background border border-border rounded",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[e.jsx("p",{className:"font-semibold",children:s.name||"Guest"}),s.recovered?e.jsx(o,{className:"bg-green-500/10 text-green-500 border-green-500/30",children:"â Recovered"}):s.emailOpened?e.jsxs(o,{className:"bg-purple-500/10 text-purple-500 border-purple-500/30",children:[e.jsx(m,{className:"w-3 h-3 mr-1"}),"Opened"]}):e.jsxs(o,{className:"bg-blue-500/10 text-blue-500 border-blue-500/30",children:[e.jsx(c,{className:"w-3 h-3 mr-1"}),"Sent"]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.email}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Sent: ",l(s.emailSentAt),s.emailOpenedAt&&` ⢠Opened: ${l(s.emailOpenedAt)}`,s.recoveredAt&&` ⢠Recovered: ${l(s.recoveredAt)}`]})]}),e.jsx("div",{className:"text-right",children:e.jsx("p",{className:"text-lg font-bold text-primary",children:t(s.totalAmount)})})]},s.id))})]}):e.jsxs("div",{className:"text-center py-12 bg-card border border-border",children:[e.jsx(N,{className:"w-16 h-16 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-xl font-semibold mb-2",children:"No recovery activity yet"}),e.jsx("p",{className:"text-muted-foreground",children:"Recovery emails will appear here once sent"})]})]}),e.jsx(u,{currentPath:"/admin/email-analytics"})]})}export{P 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.