1import{j as e}from"./app-xtnexrKX.js";import{V as t,r as a,h as r,M as s}from"./vendor-jfmykXpB.js";import{A as o}from"./AdminLayoutNew-C0AoHtGQ.js";import{D as n,V as i}from"./ViewPeriodSelector-te5ZPB3W.js";import{R as d,L as c,C as l,X as u,Y as m,T as h,a as g,b as v}from"./LineChart-BiVBuw7m.js";import"./utils-Cp3twET-.js";import"./ApplicationLogo-DxAzR1IV.js";import"./transition-BDGULseq.js";import"./DarkLightModeSwitcher-Cf-XG8h9.js";import"./DataContext-D360ttN-.js";import"./debounce-DUp1Mma4.js";import"./toInteger-DYpbiMyy.js";import"./tiny-invariant-BM5KeS_Z.js";function p({auth:p}){const{chartData:x}=t().props,[j,R]=a.useState("daily"),[C,f]=a.useState("3months"),[y,D]=a.useState(x),[S,k]=a.useState(!1),b=a.useRef(!0);a.useEffect(()=>{b.current?b.current=!1:(k(!0),r.get(route("admin.reports.conversions"),{dateRange:C},{preserveState:!0,preserveScroll:!0,only:["chartData"],onSuccess:e=>{D(e.props.chartData),k(!1)},onError:()=>{k(!1)}}))},[C]);const w=a.useMemo(()=>{if(!y||0===y.length)return[];switch(j){case"weekly":return(e=>{const t={};return e.forEach(e=>{const a=new Date(e.date),r=new Date(a.setDate(a.getDate()-a.getDay())).toISOString().split("T")[0];t[r]||(t[r]={date:r,regConvRate:0,purConvRate:0,count:0}),t[r].regConvRate+=e.regConvRate,t[r].purConvRate+=e.purConvRate,t[r].count++}),Object.values(t).map(e=>({...e,regConvRate:e.regConvRate/e.count,purConvRate:e.purConvRate/e.count})).sort((e,t)=>e.date.localeCompare(t.date))})(y);case"monthly":return(e=>{const t={};return e.forEach(e=>{const a=new Date(e.date),r=`${a.getFullYear()}-${String(a.getMonth()+1).padStart(2,"0")}-01`;t[r]||(t[r]={date:r,regConvRate:0,purConvRate:0,count:0}),t[r].regConvRate+=e.regConvRate,t[r].purConvRate+=e.purConvRate,t[r].count++}),Object.values(t).map(e=>({...e,regConvRate:e.regConvRate/e.count,purConvRate:e.purConvRate/e.count})).sort((e,t)=>e.date.localeCompare(t.date))})(y);default:return y}},[y,j]),N=e=>{const t="weekly"===j?"Weekly":"monthly"===j?"Monthly":"Daily";return"reg"===e?`${t} Registration Conversion Rate (%)`:`${t} Purchase Conversion Rate (%)`};return e.jsxs(o,{user:!(!p||!p.user)&&p.user,header:e.jsx("h2",{className:"font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight",children:"Conversions"}),children:[e.jsx(s,{title:"Conversions"}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 p-6 rounded-lg shadow",children:[e.jsx(n,{selectedDateRange:C,setSelectedDateRange:f,name:"conversionsDateRange",maxRange:"24months"}),e.jsx(i,{selectedPeriod:j,setSelectedPeriod:R,name:"conversionPeriod"}),e.jsxs("div",{className:"h-80 w-full",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-gray-200 mb-2",children:N("reg")}),S?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("div",{className:"text-gray-500 dark:text-gray-400",children:"Loading data..."})}):e.jsx(d,{width:"100%",height:"100%",children:e.jsxs(c,{data:w,margin:{top:5,right:30,left:20,bottom:35},children:[e.jsx(l,{strokeDasharray:"3 3"}),e.jsx(u,{dataKey:"date",tick:{fontSize:12},interval:"preserveStartEnd"}),e.jsx(m,{}),e.jsx(h,{formatter:e=>[e,"Registration Conversion Rate"],labelFormatter:e=>`Date: ${e}`}),e.jsx(g,{}),e.jsx(v,{type:"monotone",dataKey:"regConvRate",name:"Registration Conversion Rate",stroke:"#ffc658",activeDot:{r:8},dot:{strokeWidth:2}})]})})]}),e.jsxs("div",{className:"h-80 w-full mt-8",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-gray-200 mb-2",children:N("pur")}),S?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("div",{className:"text-gray-500 dark:text-gray-400",children:"Loading data..."})}):e.jsx(d,{width:"100%",height:"100%",children:e.jsxs(c,{data:w,margin:{top:5,right:30,left:20,bottom:35},children:[e.jsx(l,{strokeDasharray:"3 3"}),e.jsx(u,{dataKey:"date",tick:{fontSize:12},interval:"preserveStartEnd"}),e.jsx(m,{}),e.jsx(h,{formatter:e=>[e,"Purchase Conversion Rate"],labelFormatter:e=>`Date: ${e}`}),e.jsx(g,{}),e.jsx(v,{type:"monotone",dataKey:"purConvRate",name:"Purchase Conversion Rate",stroke:"#0088fe",activeDot:{r:8},dot:{strokeWidth:2}})]})})]})]})]})}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.