1import{j as e}from"./trpc-vendor-Bta84Nsh.js";import{t as g}from"./index-_3-B0itT.js";import{l as k,n as b,F as j,aC as L,y as F,aa as v,a3 as w,m as V,b4 as S,bf as B,bb as q,bc as C,b8 as A,bg as f}from"./ui-vendor-NEZNvIbV.js";import"./react-vendor-DpXpH6G7.js";const m={ads:"Werbeanzeigen",flyer:"Flyer / Aktion",referral:"Empfehlung",walk_in:"Walk-in (Laufkunde)",online:"Online-Formular",call_center:"Call Center",other:"Website / Webseite",website:"Website / Webseite"},N=["#f97316","#fb923c","#fdba74","#fed7aa","#fef3c7","#d1fae5","#a7f3d0"];function U(r,a){return a?Math.round(r/a*100):null}function h({from:r,to:a}){const l=U(a,r);if(l===null)return null;const c=l>=50?"text-green-400":l>=25?"text-yellow-400":"text-red-400";return e.jsxs("span",{className:`text-xs font-semibold ${c}`,children:[l,"%"]})}function Q(){const{data:r,isLoading:a}=g.funnel.stats.useQuery(),{data:l=[]}=g.analytics.getPageFunnel.useQuery({});if(a)return e.jsx("div",{className:"p-6 text-center text-gray-400",children:"Lädt Funnel-Daten..."});const c=r,n=c?.bySource??[],d=c?.byForm??[],i=n.reduce((s,t)=>s+t.totalLeads,0);return e.jsxs("div",{className:"p-6 max-w-5xl mx-auto space-y-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Funnel-Analyse"}),e.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"Besucherflow von der Webseite bis zum Vertragsabschluss."})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[{label:"Leads gesamt",value:i,icon:e.jsx(k,{className:"w-5 h-5 text-orange-500"})},{label:"Termine gesamt",value:n.reduce((s,t)=>s+t.appointments,0),icon:e.jsx(b,{className:"w-5 h-5 text-blue-400"})},{label:"Verträge gesamt",value:n.reduce((s,t)=>s+t.closed,0),icon:e.jsx(j,{className:"w-5 h-5 text-green-400"})},{label:"à Abschlussquote",value:i>0?`${(n.reduce((s,t)=>s+t.closed,0)/i*100).toFixed(1)}%`:"â",icon:e.jsx(L,{className:"w-5 h-5 text-purple-400"})}].map(s=>e.jsxs("div",{className:"bg-card rounded-xl border p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.icon,e.jsx("span",{className:"text-xs text-gray-400",children:s.label})]}),e.jsx("div",{className:"text-2xl font-bold",children:s.value})]},s.label))}),e.jsxs("a",{href:"/admin/checkout-vergleich",className:"flex items-center gap-3 bg-card rounded-xl border p-4 hover:border-primary/50 transition",children:[e.jsx(F,{className:"w-5 h-5 text-violet-400 flex-shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-semibold text-sm",children:"Checkout-Vergleich öffnen"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Standard vs. Premium â Abschlussquote & wo Besucher abbrechen (mit Reinzoomen je Checkout)."})]}),e.jsx(v,{className:"w-4 h-4 text-muted-foreground"})]}),l.length>0&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h2",{className:"font-semibold flex items-center gap-2",children:[e.jsx(w,{className:"w-5 h-5 text-cyan-400"}),"Funnel pro Studio"]}),l.map(s=>e.jsxs("div",{className:"bg-card rounded-xl border p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold text-base",children:s.brandName}),s.slug&&e.jsxs("span",{className:"ml-2 text-xs text-muted-foreground",children:["/",s.slug]})]}),e.jsxs("div",{className:"flex gap-4 text-xs text-muted-foreground",children:[e.jsxs("span",{children:[e.jsx("span",{className:"font-semibold text-orange-400",children:s.leadCount})," Leads"]}),e.jsxs("span",{children:[e.jsx("span",{className:"font-semibold text-green-400",children:s.contractsBooked})," Verträge"]})]})]}),e.jsxs("div",{className:"space-y-1",children:[s.landingViews>0&&e.jsx(u,{label:"Hauptseite",views:s.landingViews,unique:s.landingUnique,color:"bg-blue-500",maxViews:s.landingViews}),s.appointmentViews>0&&e.jsxs(e.Fragment,{children:[e.jsx(y,{}),e.jsx(u,{label:"Terminbuchungsseite",views:s.appointmentViews,unique:s.appointmentUnique,color:"bg-cyan-500",maxViews:s.landingViews||s.appointmentViews,rightBadge:s.appointmentsBooked>0?e.jsxs("span",{className:"flex items-center gap-1.5 text-xs bg-cyan-500/10 text-cyan-400 border border-cyan-500/20 px-2 py-0.5 rounded-full",children:[e.jsx(b,{className:"w-3 h-3"}),s.appointmentsBooked," Termine gebucht",s.appointmentUnique>0&&e.jsx(h,{from:s.appointmentUnique,to:s.appointmentsBooked})]}):void 0})]}),s.contractViews>0&&e.jsxs(e.Fragment,{children:[e.jsx(y,{}),e.jsx(u,{label:"Vertragsseite",views:s.contractViews,unique:s.contractUnique,color:"bg-orange-500",maxViews:s.landingViews||s.c
1ontractViews,rightBadge:s.contractsBooked>0?e.jsxs("span",{className:"flex items-center gap-1.5 text-xs bg-green-500/10 text-green-400 border border-green-500/20 px-2 py-0.5 rounded-full",children:[e.jsx(j,{className:"w-3 h-3"}),s.contractsBooked," Verträge",s.contractUnique>0&&e.jsx(h,{from:s.contractUnique,to:s.contractsBooked})]}):void 0}),s.checkoutSteps?.length>0&&e.jsx("div",{className:"ml-4 mt-1 space-y-0.5 border-l border-border/50 pl-4",children:s.checkoutSteps.map((t,o)=>{const x=o>0?s.checkoutSteps[o-1]:null,p=o===s.checkoutSteps.length-1;return e.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[e.jsx("div",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${p?"bg-green-400":"bg-muted-foreground/40"}`}),e.jsxs("span",{className:"text-xs text-muted-foreground w-36 flex-shrink-0",children:["Schritt ",t.step,": ",t.label]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`text-xs font-semibold ${p?"text-green-400":"text-foreground"}`,children:t.views}),x&&x.views>0&&t.views>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",e.jsx(h,{from:x.views,to:t.views}),")"]})]})]},t.step)})})]})]})]},s.brandId))]}),e.jsxs("div",{className:"bg-card rounded-xl border p-6",children:[e.jsxs("h2",{className:"font-semibold mb-4 flex items-center gap-2",children:[e.jsx(V,{className:"w-5 h-5 text-orange-500"}),"Performance nach Leadquelle"]}),n.length===0?e.jsx("p",{className:"text-gray-400 text-sm text-center py-8",children:"Noch keine Daten vorhanden."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-48 mb-6",children:e.jsx(S,{width:"100%",height:"100%",children:e.jsxs(B,{data:n.map(s=>({name:m[s.source]??s.source,leads:s.totalLeads,abschlüsse:s.closed})),children:[e.jsx(q,{dataKey:"name",tick:{fontSize:11,fill:"#9ca3af"}}),e.jsx(C,{tick:{fontSize:11,fill:"#9ca3af"}}),e.jsx(A,{contentStyle:{background:"#1f2937",border:"none",borderRadius:8,color:"#f9fafb"}}),e.jsx(f,{dataKey:"leads",name:"Leads",fill:"#f97316",radius:[4,4,0,0]}),e.jsx(f,{dataKey:"abschlüsse",name:"Abschlüsse",fill:"#22c55e",radius:[4,4,0,0]})]})})}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-gray-400 border-b border-border",children:[e.jsx("th",{className:"text-left py-2 font-medium",children:"Quelle"}),e.jsx("th",{className:"text-right py-2 font-medium",children:"Leads"}),e.jsx("th",{className:"text-right py-2 font-medium",children:"Kontaktiert"}),e.jsx("th",{className:"text-right py-2 font-medium",children:"Termin"}),e.jsx("th",{className:"text-right py-2 font-medium",children:"Abschluss"}),e.jsx("th",{className:"text-right py-2 font-medium",children:"Quote"})]})}),e.jsx("tbody",{children:n.map((s,t)=>e.jsxs("tr",{className:"border-b border-border/50 hover:bg-muted/30",children:[e.jsxs("td",{className:"py-2.5 flex items-center gap-2",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-full",style:{background:N[t%N.length]}}),m[s.source]??s.source]}),e.jsx("td",{className:"text-right py-2.5",children:s.totalLeads}),e.jsx("td",{className:"text-right py-2.5",children:s.contacted}),e.jsx("td",{className:"text-right py-2.5",children:s.appointments}),e.jsx("td",{className:"text-right py-2.5 text-green-400 font-semibold",children:s.closed}),e.jsx("td",{className:"text-right py-2.5",children:s.totalLeads>0?`${(s.closed/s.totalLeads*100).toFixed(1)}%`:"â"})]},s.source))})]})})]})]}),d.length>0&&e.jsxs("div",{className:"bg-card rounded-xl border p-6",children:[e.jsx("h2",{className:"font-semibold mb-4",children:"Performance nach Formular"}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-gray-400 border-b border-border",children:[e.jsx("th",{className:"text-left py-2 font-medium",children:"Formular"}),e.jsx("th",{className:"text-left py-2 font-medium",children:"Quelle"}),e.jsx("th",{className:"text-right py-2 font-medium",children:"Leads"}),e.jsx("th",{className:"text-right py-2 font-medium",children:"Absc
1hlüsse"}),e.jsx("th",{className:"text-right py-2 font-medium",children:"Quote"})]})}),e.jsx("tbody",{children:d.map(s=>e.jsxs("tr",{className:"border-b border-border/50 hover:bg-muted/30",children:[e.jsx("td",{className:"py-2.5",children:s.formName??"Direkt / Manuell"}),e.jsx("td",{className:"py-2.5 text-gray-400",children:m[s.source]??s.source}),e.jsx("td",{className:"text-right py-2.5",children:s.totalLeads}),e.jsx("td",{className:"text-right py-2.5 text-green-400 font-semibold",children:s.closed}),e.jsx("td",{className:"text-right py-2.5",children:s.totalLeads>0?`${(s.closed/s.totalLeads*100).toFixed(1)}%`:"â"})]},s.formId??"direct"))})]})})]})]})}function y(){return e.jsx("div",{className:"flex items-center pl-2 py-0.5",children:e.jsx(v,{className:"w-3 h-3 text-muted-foreground/50"})})}function u({label:r,views:a,unique:l,color:c,maxViews:n,rightBadge:d}){const i=n>0?Math.max(4,Math.round(a/n*100)):4;return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs text-muted-foreground w-36 flex-shrink-0",children:r}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"relative h-5 rounded overflow-hidden bg-muted/30",children:[e.jsx("div",{className:`absolute left-0 top-0 h-full ${c} opacity-70 rounded transition-all`,style:{width:`${i}%`}}),e.jsxs("span",{className:"absolute left-2 top-0 h-full flex items-center text-xs font-semibold text-white drop-shadow",children:[a.toLocaleString("de")," Besucher ",l<a&&e.jsxs("span",{className:"ml-1 opacity-70",children:["(",l," unique)"]})]})]})}),d&&e.jsx("div",{className:"flex-shrink-0",children:d})]})}export{Q 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.