1import D from"./D1xCj3a0.js";import{u as $}from"./CSQgM3SS.js";import{a as j}from"#entry";import{aC as G,q as h,g as x,j as C,_ as S,ak as q,e as I}from"./B9SPuWlS.js";import{aN as U,ag as c,r as p,o as r,y as i,aQ as o,x as V,aE as l,a as N,an as w,ay as u,p as H,a1 as Q,q as k,a3 as J,al as g,m as _}from"./CT7wXifU.js";import{_ as K}from"./D6trejea.js";import"./Cp2c5yTg.js";const W={class:"mb-6"},X={class:"pb-3"},Y={class:""},Z={key:0,class:"metrics-skeleton-loader"},ee={key:1,class:"no-data-container",style:{height:"300px"}},se={class:"d-flex flex-column align-center justify-center h-100"},te={class:"no-data-icon-wrapper"},ae={class:"no-data-text mt-4"},re={class:"no-data-subtext text-medium-emphasis"},ne={key:2},ie={class:"metric-content"},oe={key:0,class:"currency-symbol"},le={class:"metric-current-value"},ce={class:"metric-previous-value"},ue={class:"metric-label text-medium-emphasis mt-2"},de={class:"d-flex align-center mt-3 justify-center"},pe={class:"metric-change-text"},me={key:0,class:"text-center mt-3"},ve={__name:"LeadsRevenueOverview",props:{dateRangeFilter:{type:String,default:"last_30_days"}},setup(E){const f=E,{getApiCalls:L,secureEndpoint:R}=$(),M=j(),{$toast:he}=G(),P=_(()=>M.getOrgCurrencySign),m=g([]),n=g({loading:!0,message:"Loading metrics...",subtitle:"Please wait while we fetch the metrics..."}),v=g(!1),A=_(()=>{const a=["Revenue","Leads","Appointments","Trials","Event Purchases","Gift Card Purchases"];if(v.value){const e=[],s=[];return a.forEach(d=>{const y=m.value.find(O=>O.label===d);y&&e.push(y)}),m.value.forEach(d=>{a.includes(d.label)||s.push(d)}),[...e,...s]}const t=[];return a.forEach(e=>{const s=m.value.find(d=>d.label===e);s&&t.push(s)}),t}),T=_(()=>{const a=["Revenue","Leads","Appointments","Trials","Event Purchases","Gift Card Purchases"];return m.value.length>a.length}),z=async()=>{n.value.loading=!0,n.value.message="",n.value.subtitle="";try{const a=await L(R.DASHBOARD_LEAD_REVENUE_STATS,{date_range:f.dateRangeFilter});B(a),m.value.length||(n.value.message="No data available",n.value.subtitle="No lead or revenue metrics found for the selected period")}catch(a){console.error("Error fetching lead revenue stats:",a),n.value.message="Error fetching lead revenue stats",n.value.subtitle="Please try again later"}finally{n.value.loading=!1}},B=a=>{try{const t=[];if(a?.customer_statistics){const e=a.customer_statistics;if(e?.leads!==void 0){const s=e?.leads;t.push({id:1,label:"Leads",value:s.current||0,previousValue:s.previous||0,change:s.percentage_change,tooltip:"Number of leads added in the selected period"})}if(e?.trials!==void 0){const s=e?.trials;t.push({id:2,label:"Trials",value:s.current||0,previousValue:s.previous||0,change:s.percentage_change,tooltip:"Number of trials purchased in the selected period"})}if(e?.members!==void 0){const s=e?.members;t.push({id:3,label:"Members",value:s.current||0,previousValue:s.previous||0,change:s.percentage_change,tooltip:"Number of members added in the selected period"})}}if(a?.appointment_statistics){const e=a.appointment_statistics;t.push({id:4,label:"Appointments",value:e.current||0,previousValue:e.previous||0,change:e.percentage_change,tooltip:"Number of appointments scheduled in the selected period"})}if(a?.reserved_class_statistics){const e=a.reserved_class_statistics;t.push({id:5,label:"Reserved Classes",value:e.current||0,previousValue:e.previous||0,change:e.percentage_change,tooltip:"Number of reserved classes in the selected period"})}if(a?.event_purchase_statistics){const e=a.event_purchase_statistics;t.push({id:6,label:"Event Purchases",value:e.current||0,previousValue:e.previous||0,change:e.percentage_change,tooltip:"Number of event purchases made in the selected period"})}if(a?.gift_card_statistics){const e=a.gift_card_statistics;t.push({id:7,label:"Gift Card Purchases",value:e.current||0,previousValue:e.previous||0,change:e.percentage_change,tooltip:"Number of gift cards purchased in the selected period"})}if(a?.revenue_statistics){const e=a.revenue_statistics;t.push({id:8,label:"Revenue",value:e.current||0,previousValue:e.previous||0,change:e.percentage_change,tooltip:"Total revenue generated in the selected period",isCurrency:!0})}m.value=t}catch(t){console.error("Error mapping lead revenue stats to metrics:",t)}},b=a=>
1a.toLocaleString("en-US"),F=a=>{const t=parseFloat(a);return isNaN(t)?"0.00%":`${t>=0?"+":""}${t.toFixed(2)}%`};return U(()=>f.dateRangeFilter,()=>{z()},{immediate:!0}),(a,t)=>{const e=D;return c(),p("div",W,[r("div",X,[i(h,{class:"section-title py-0"},{default:o(()=>[...t[1]||(t[1]=[V("Leads & Revenue Overview",-1)])]),_:1})]),r("div",Y,[l(n).loading?(c(),p("div",Z,[i(S,null,{default:o(()=>[(c(),p(N,null,w(6,s=>i(h,{key:s,cols:"12",sm:"6",md:"2"},{default:o(()=>[i(x,{class:"modern-metric-card",elevation:"0",style:{height:"150px"}},{default:o(()=>[i(C,{class:"pa-4"},{default:o(()=>[...t[2]||(t[2]=[r("div",{class:"custom-skeleton-text mb-2",style:{width:"60%"}},null,-1),r("div",{class:"custom-skeleton-text mb-2",style:{width:"80%"}},null,-1),r("div",{class:"custom-skeleton-text mb-2",style:{width:"50%"}},null,-1)])]),_:1})]),_:1})]),_:1})),64))]),_:1})])):l(n).message&&!l(n).loading?(c(),p("div",ee,[r("div",se,[r("div",te,[i(e,{name:"mdi:chart-box-outline",size:"64",color:"grey-lighten-1",mode:"svg"})]),r("p",ae,u(l(n).message),1),r("p",re,u(l(n).subtitle),1)])])):(c(),p("div",ne,[i(S,null,{default:o(()=>[(c(!0),p(N,null,w(l(A),s=>(c(),H(h,{key:s.id,cols:"12",sm:"6",md:"2"},{default:o(()=>[i(x,{class:"metric-card modern-metric-card",elevation:"0"},{default:o(()=>[i(C,{class:"pa-4"},{default:o(()=>[r("div",ie,[i(q,{location:"top"},{activator:o(({props:d})=>[r("div",Q({class:"metric-values-row"},{ref_for:!0},d),[s.label==="Revenue"?(c(),p("sup",oe,u(l(P)),1)):k("",!0),r("span",le,u(b(s.value)),1),t[3]||(t[3]=r("span",{class:"metric-separator"},"/",-1)),r("span",ce,u(b(s.previousValue||0)),1)],16)]),default:o(()=>[r("span",null,u(s.tooltip),1)]),_:2},1024),r("div",ue,u(s.label),1),t[4]||(t[4]=r("div",{class:"metric-period-label text-caption text-medium-emphasis mt-1"},"Current/Previous",-1)),r("div",de,[r("div",{class:J(["metric-change-badge",s.change>=0?"positive":"negative"])},[i(e,{name:s.change>=0?"mdi-trending-up":"mdi-trending-down",size:"16",color:s.change>=0?"success":"error",mode:"svg"},null,8,["name","color"]),r("span",pe,u(F(s.change)),1)],2)])])]),_:2},1024)]),_:2},1024)]),_:2},1024))),128))]),_:1}),l(T)?(c(),p("div",me,[i(I,{variant:"outlined",color:"primary",size:"small",onClick:t[0]||(t[0]=s=>v.value=!l(v)),class:"text-capitalize gap-2"},{default:o(()=>[V(u(l(v)?"See Less":"See More")+" ",1),i(e,{name:l(v)?"mdi-chevron-up":"mdi-chevron-down",size:"18",mode:"svg"},null,8,["name"])]),_:1})])):k("",!0)]))])])}}},Se=K(ve,[["__scopeId","data-v-2457b46d"]]);export{Se 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.