import{u as w,i as y,s as v,c as a,a as e,t as o,f as u,e as D,F as g,k as x,l as M,q as V,r as _,p as C,o as l,g as j,n as B}from"./index-DWNalbut.js";import{u as z}from"./activities-DN88j27F.js";import{u as A}from"./deals-Bh3SQGc9.js";const N={class:"p-6"},R={class:"mb-8"},S={class:"text-2xl font-bold text-white"},E={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8"},F={class:"stat-card"},H={class:"flex items-center gap-4"},L={class:"stat-value"},P={class:"stat-card"},T={class:"flex items-center gap-4"},I={class:"stat-value"},K={class:"stat-card"},O={class:"flex items-center gap-4"},U={class:"stat-value"},q={class:"stat-card"},G={class:"flex items-center gap-4"},W={class:"stat-value"},J={class:"grid grid-cols-1 lg:grid-cols-2 gap-6"},Q={class:"card"},X={class:"px-6 py-4 border-b border-pulse-border flex items-center justify-between"},Y={key:0,class:"badge-red"},Z={class:"p-4"},$={key:0,class:"text-center py-8 text-pulse-muted"},ee={key:1,class:"space-y-3"},se={class:"flex-shrink-0"},te={class:"badge-red"},oe={class:"flex-1 min-w-0"},ae={class:"text-sm text-white truncate"},le={class:"text-xs text-pulse-muted"},ne={class:"text-xs text-red-400"},re={class:"card"},ie={class:"px-6 py-4 border-b border-pulse-border flex items-center justify-between"},de={class:"p-4"},ce={key:0,class:"text-center py-8 text-pulse-muted"},ue={key:1,class:"space-y-3"},pe={class:"flex-shrink-0"},me={class:"flex-1 min-w-0"},ve={class:"text-sm text-white truncate"},he={class:"text-xs text-pulse-muted"},ge={class:"text-xs text-pulse-muted"},ke={__name:"DashboardView",setup(xe){const f=w(),n=z();A();const r=_({contacts:0,companies:0,openDeals:0,pipelineValue:0}),b=_(!0);y(async()=>{var i,s,m,p;try{const[t,c,d]=await Promise.all([v.get("/api/v1/contacts",{params:{limit:1}}),v.get("/api/v1/companies",{params:{limit:1}}),v.get("/api/v1/deals/stats")]);r.value.contacts=((i=t.data.meta)==null?void 0:i.total)||0,r.value.companies=((s=c.data.meta)==null?void 0:s.total)||0,r.value.openDeals=((m=d.data.data)==null?void 0:m.openDeals)||0,r.value.pipelineValue=((p=d.data.data)==null?void 0:p.pipelineValue)||0,await Promise.all([n.fetchUpcoming(7),n.fetchOverdue(),n.fetchStats()])}catch(t){console.error("Dashboard load error:",t)}finally{b.value=!1}});function k(i){return new Intl.NumberFormat("de-DE",{style:"currency",currency:"EUR"}).format(i||0)}function h(i){return i?new Date(i).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"}):"-"}return(i,s)=>{var p;const m=C("RouterLink");return l(),a("div",N,[e("div",R,[e("h1",S," Guten Tag, "+o((p=u(f).user)==null?void 0:p.firstName)+"! 👋 ",1),s[0]||(s[0]=e("p",{class:"text-pulse-muted mt-1"},"Hier ist Ihr Überblick für heute.",-1))]),e("div",E,[e("div",F,[e("div",H,[s[2]||(s[2]=e("div",{class:"p-3 rounded-xl bg-blue-500/20"},[e("svg",{class:"w-6 h-6 text-blue-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z"})])],-1)),e("div",null,[e("p",L,o(r.value.contacts),1),s[1]||(s[1]=e("p",{class:"stat-label"},"Kontakte",-1))])])]),e("div",P,[e("div",T,[s[4]||(s[4]=e("div",{class:"p-3 rounded-xl bg-purple-500/20"},[e("svg",{class:"w-6 h-6 text-purple-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"})])],-1)),e("div",null,[e("p",I,o(r.value.companies),1),s[3]||(s[3]=e("p",{class:"stat-label"},"Firmen",-1))])])]),e("div",K,[e("div",O,[s[6]||(s[6]=e("div",{class:"p-3 rounded-xl bg-green-500/20"},[e("svg",{class:"w-6 h-6 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})])],-1)),e("div",null,[e("p",U,o(r.value.openDeals),1),s[5]||(s[5]=e("p",{class:"stat-label"},"Offene Deals",-1))])])]),e("div",q,[e("div",G,[s[8]||(s[8]=e("div",{class:"p-3 rounded-xl bg-yellow-500/20"},[e("svg",{class:"w-6 h-6 text-yellow-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})])],-1)),e("div",null,[e("p",W,o(k(r.value.pipelineValue)),1),s[7]||(s[7]=e("p",{class:"stat-label"},"Pipeline-Wert",-1))])])])]),e("div",J,[e("div",Q,[e("div",X,[s[9]||(s[9]=e("h2",{class:"font-semibold text-white"},"Überfällige Aufgaben",-1)),u(n).overdue.length?(l(),a("span",Y,o(u(n).overdue.length),1)):D("",!0)]),e("div",Z,[u(n).overdue.length===0?(l(),a("div",$,[...s[10]||(s[10]=[e("svg",{class:"w-12 h-12 mx-auto mb-3 opacity-50",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})],-1),e("p",null,"Alles erledigt! 🎉",-1)])])):(l(),a("div",ee,[(l(!0),a(g,null,x(u(n).overdue.slice(0,5),t=>{var c,d;return l(),a("div",{key:t.id,class:"flex items-center gap-3 p-3 rounded-lg bg-red-500/10 border border-red-500/20"},[e("div",se,[e("span",te,o(t.type),1)]),e("div",oe,[e("p",ae,o(t.subject),1),e("p",le,o(((c=t.contact)==null?void 0:c.name)||((d=t.company)==null?void 0:d.name)||"-"),1)]),e("span",ne,o(h(t.dueDate)),1)])}),128))]))])]),e("div",re,[e("div",ie,[s[12]||(s[12]=e("h2",{class:"font-semibold text-white"},"Anstehend (7 Tage)",-1)),M(m,{to:"/activities",class:"text-sm text-primary-400 hover:text-primary-300"},{default:V(()=>[...s[11]||(s[11]=[j(" Alle anzeigen → ",-1)])]),_:1})]),e("div",de,[u(n).upcoming.length===0?(l(),a("div",ce,[...s[13]||(s[13]=[e("p",null,"Keine anstehenden Aufgaben",-1)])])):(l(),a("div",ue,[(l(!0),a(g,null,x(u(n).upcoming.slice(0,5),t=>{var c,d;return l(),a("div",{key:t.id,class:"flex items-center gap-3 p-3 rounded-lg hover:bg-pulse-dark/30 transition-colors"},[e("div",pe,[e("span",{class:B(["badge",t.type==="call"?"badge-blue":t.type==="meeting"?"badge-green":t.type==="task"?"badge-yellow":"badge-gray"])},o(t.type),3)]),e("div",me,[e("p",ve,o(t.subject),1),e("p",he,o(((c=t.contact)==null?void 0:c.name)||((d=t.company)==null?void 0:d.name)||"-"),1)]),e("span",ge,o(h(t.dueDate)),1)])}),128))]))])])])])}}};export{ke as default};