1import{d as p,r as h,j as e,bQ as f,aQ as u,av as d,Y as j}from"./index-THpNDw-R.js";import{A as b}from"./AdminLayout-Bvd6kpVI.js";import{a as v}from"./adminAuth-CdO2ZTrV.js";import{u as g}from"./useQuery-YTu1LlCd.js";import{B as y}from"./badge-D3jmxmXK.js";import{S as N,a as w,b as S,c as L,d as r}from"./select-V7DHHc3Q.js";import{R as C}from"./refresh-cw-BaOns5k4.js";import{T}from"./trending-up-BfFHU6nv.js";import{R as B,T as k,B as R}from"./generateCategoricalChart-yK5vQb8U.js";import{B as A}from"./BarChart-CWHVkKGd.js";import{C as P}from"./CartesianGrid-D_epByQw.js";import{X as $,Y as z}from"./YAxis-CXbUbujj.js";import"./AdminAuthContext-DQckviGB.js";import"./adminConfig-ByiE1NnN.js";import"./format-DjiTlc93.js";import"./parseISO-4uiFBtmk.js";import"./chevron-right-DAgFs4HQ.js";import"./bell-TlsqimA3.js";import"./megaphone-DBO2Tyh0.js";import"./database-CYgO3Csn.js";import"./radio-DWIaCngy.js";import"./chart-column-ViNZY9aO.js";import"./newspaper-DnJS5hgz.js";import"./wand-sparkles-BSyc2Iar.js";import"./image-f7rOdEnC.js";import"./brain-9Gj7jV_6.js";import"./rocket-n4bdhFW1.js";import"./bot-BQ4hX2lP.js";import"./sparkles-Bh9gGTd0.js";import"./settings-DW6cDq-L.js";import"./shield-check-DafoaNAl.js";import"./key-round-gN1DGVJ3.js";import"./external-link-CFgXtxD0.js";import"./index-9t7gNxAu.js";import"./index-DH73SiL4.js";import"./index-Cv_6r8O7.js";import"./index-Dhojajn_.js";import"./index-BEr2a01S.js";import"./index-BRAJGmhz.js";import"./chevron-up-SlgMXEG4.js";import"./tiny-invariant-BaFNuDhB.js";import"./index-C-zKSVM4.js";/** 2 * @license lucide-react v0.475.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const Q=[["path",{d:"M12.586 12.586 19 19",key:"ea5xo7"}],["path",{d:"M3.688 3.037a.497.497 0 0 0-.651.651l6.5 15.999a.501.501 0 0 0 .947-.062l1.569-6.083a2 2 0 0 1 1.448-1.479l6.124-1.579a.5.5 0 0 0 .063-.947z",key:"277e5u"}]],F=p("MousePointer",Q),I={hot:"bg-red-100 text-red-800",warm:"bg-yellow-100 text-yellow-800",cold:"bg-stone-100 text-stone-700"};function Ce(){const[i,n]=h.useState("30"),{data:c,isLoading:o,refetch:m,isFetching:l}=g({queryKey:["admin-traffic-sources",i],queryFn:()=>j.functions.invoke("getTrafficSourceData",{days:parseInt(i),_adminToken:v()}).then(s=>s.data),staleTime:1e3*60*2}),t=c||{totalPageviews:0,totalLeads:0,conversionRate:"0.0",trafficBySource:[],leadsBySource:[]};return e.jsx(b,{title:"Traffic Sources",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-bold text-stone-900 tracking-tight",children:"Traffic Sources"}),e.jsx("p",{className:"text-xs text-stone-400 mt-0.5",children:"Attribution data from assessments, forms, and newsletter signups"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(N,{value:i,onValueChange:n,children:[e.jsx(w,{className:"w-36 h-8 text-xs bg-white border-stone-200",children:e.jsx(S,{})}),e.jsxs(L,{children:[e.jsx(r,{value:"7",children:"Last 7 days"}),e.jsx(r,{value:"30",children:"Last 30 days"}),e.jsx(r,{value:"90",children:"Last 90 days"})]})]}),e.jsx(f,{variant:"outline",size:"sm",onClick:()=>m(),disabled:l,className:"h-8 px-2.5 border-stone-200",children:e.jsx(C,{className:`h-3.5 w-3.5 ${l?"animate-spin":""}`})})]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[{label:"Total Pageviews",value:t.totalPageviews.toLocaleString(),icon:F,color:"text-blue-600 bg-blue-50"},{label:"Leads Generated",value:t.totalLeads,icon:u,color:"text-emerald-600 bg-emerald-50"},{label:"Conversion Rate",value:`${t.conversionRate}%`,icon:T,color:"text-amber-600 bg-amber-50"}].map(s=>e.jsx("div",{className:"bg-white rounded-xl border border-stone-200/70 p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`p-2 rounded-lg ${s.color}`,children:e.jsx(s.icon,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-stone-500",children:s.label}),e.jsx("div",{className:"text-2xl font-bold text-stone-900 mt-0.5",children:o?"â¦":s.value})]})]})},s.label))}),e.jsxs("div",{className:"bg-white rounded-xl border border-stone-200/70 p-6",children:[e.jsx("h3",{className:"text-sm font-semibold text-stone-900 mb
6-4",children:"Traffic by Source"}),o?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(d,{className:"h-6 w-6 animate-spin text-stone-300"})}):t.trafficBySource.length===0?e.jsx("p",{className:"text-center py-12 text-stone-400 text-sm",children:"No traffic data for this period"}):e.jsx(B,{width:"100%",height:300,children:e.jsxs(A,{data:t.trafficBySource,children:[e.jsx(P,{strokeDasharray:"3 3",stroke:"#e7e5e4"}),e.jsx($,{dataKey:"name",tick:{fill:"#78716c",fontSize:12}}),e.jsx(z,{tick:{fill:"#78716c",fontSize:12}}),e.jsx(k,{contentStyle:{borderRadius:"8px",border:"1px solid #e7e5e4",boxShadow:"0 4px 12px rgba(0,0,0,0.08)"}}),e.jsx(R,{dataKey:"value",fill:"#B18C19",radius:[4,4,0,0]})]})})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-stone-200/70 p-6",children:[e.jsx("h3",{className:"text-sm font-semibold text-stone-900 mb-4",children:"Lead Quality by Source"}),o?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(d,{className:"h-6 w-6 animate-spin text-stone-300"})}):t.leadsBySource.length===0?e.jsx("p",{className:"text-center py-8 text-stone-400 text-sm",children:"No leads for this period"}):e.jsx("div",{className:"space-y-3",children:t.leadsBySource.map(s=>{const x=s.leads>0?(s.hot/s.leads*100).toFixed(1):0;return e.jsxs("div",{className:"border border-stone-200 rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-stone-900 text-sm capitalize",children:s.source}),e.jsxs("div",{className:"text-xs text-stone-400 mt-0.5",children:[s.leads," leads · ",x,"% hot"]})]}),e.jsx("div",{className:"flex gap-1.5",children:["Hot","Warm","Cold"].map(a=>e.jsxs(y,{className:`text-[10px] ${I[a.toLowerCase()]}`,children:[s[a.toLowerCase()]," ",a]},a))})]}),e.jsx("div",{className:"h-2 bg-stone-100 rounded-full overflow-hidden flex",children:s.leads>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bg-red-500",style:{width:`${s.hot/s.leads*100}%`}}),e.jsx("div",{className:"bg-yellow-500",style:{width:`${s.warm/s.leads*100}%`}}),e.jsx("div",{className:"bg-stone-300",style:{width:`${s.cold/s.leads*100}%`}})]})})]},s.source)})})]})]})})}export{Ce 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.