"use strict";(globalThis.webpackChunksurftrust=globalThis.webpackChunksurftrust||[]).push([[894],{5012:(e,t,a)=>{a.d(t,{A:()=>c});var s=a(1609),l=a.n(s),r=a(4731),n=a(6118);n.t1.register(...n.$L);const c=({chartData:e,title:t="Last 7 Days Activity"})=>{const a={labels:e.labels,datasets:[{label:"Views",data:e.views,borderColor:"#6c5ce7",backgroundColor:"rgba(108, 92, 231, 0.2)",fill:!0,tension:.4},{label:"Clicks",data:e.clicks,borderColor:"#00a3ff",backgroundColor:"rgba(0, 163, 255, 0.2)",fill:!0,tension:.4}]};return l().createElement("div",{className:"surftrust-panel"},l().createElement("h3",null,t),l().createElement(r.N1,{options:{responsive:!0,plugins:{legend:{display:!0,position:"top",align:"end"}},scales:{y:{beginAtZero:!0,ticks:{precision:0}}}},data:a}))}},7837:(e,t,a)=>{a.d(t,{A:()=>r});var s=a(1609),l=a.n(s);const r=({icon:e,value:t,label:a})=>l().createElement("div",{className:"surftrust-stat-card"},l().createElement("span",{className:`dashicons ${e}`}),l().createElement("div",null,l().createElement("div",{className:"surftrust-stat-card-value"},t),l().createElement("div",{className:"surftrust-stat-card-label"},a)))},7894:(e,t,a)=>{a.r(t),a.d(t,{default:()=>d});var s=a(1609),l=a.n(s),r=a(1455),n=a.n(r),c=a(6427),i=a(7837),o=a(5012);const u=()=>{const[e,t]=(0,s.useState)(null),[a,r]=(0,s.useState)(!0);return(0,s.useEffect)(()=>{r(!0),n()({path:"/surftrust/v1/analytics"}).then(e=>t(e)).catch(e=>console.error("Error fetching analytics:",e)).finally(()=>r(!1))},[]),a?l().createElement("div",{className:"surftrust-loading-container"},l().createElement(c.Spinner,null)):e?l().createElement("div",{className:"surftrust-analytics-wrapper"},l().createElement("div",{className:"surftrust-stats-grid"},l().createElement(i.A,{icon:"dashicons-visibility",value:e.totals.views,label:"Total Views"}),l().createElement(i.A,{icon:"dashicons-pointer",value:e.totals.clicks,label:"Total Clicks"}),l().createElement(i.A,{icon:"dashicons-chart-pie",value:`${e.totals.ctr}%`,label:"Click-Through Rate"})),l().createElement(o.A,{chartData:e.chart})):l().createElement("div",{className:"surftrust-panel"},"Could not load analytics data.")},d=()=>l().createElement(u,null)}}]);