import{_ as A,a as S,m as D,q as C,s as E,f as _,i as u,r as v,j as N,o as a,b as e,g as i,c as l,h as c,l as b,F as V,x as B,t as m,y as w}from"./index-CUYQqFVq.js";import{C as H}from"./ClientLayout-DanO4-aG.js";import{L}from"./LoadingSpinner-CUFKSlOx.js";import{E as $}from"./ErrorMessage-mpDE5Gnd.js";import{S as I}from"./StatusBadge-BRLbZ97e.js";import{b as T}from"./useWhatsAppClientLink-DfGmXkj9.js";import"./LogoutButton-Bp6dRVKV.js";const W={key:2,class:"wa-home-banner card"},F=["href"],M={key:3,class:"no-appointment"},R={key:4,class:"appointments-list"},U={class:"appointment-header"},j={class:"appointment-service"},q={class:"appointment-barber"},z={class:"appointment-details"},O={class:"detail-row"},P={class:"detail-value"},G={class:"detail-row"},J={class:"detail-value"},K={key:5,class:"reserve-link"},Q={__name:"InicioView",setup(X){const g=S(),r=v(!0),p=v(""),f=v([]),y=new Date;y.setHours(0,0,0,0);const h=w(()=>T(g.publicWhatsappPhone,`Hola, escribo desde la app de ${g.businessName}.`)),d=w(()=>f.value.filter(s=>{const t=s.status,n=new Date(s.appointment_date);return n.setHours(0,0,0,0),(t==="pending"||t==="confirmed")&&n>=y}).sort((s,t)=>{const n=new Date(`${s.appointment_date}T${s.start_time}`),o=new Date(`${t.appointment_date}T${t.start_time}`);return n-o}));D(k),C(k);async function k(){r.value=!0,p.value="";try{const s=await E.getAppointments();f.value=s.data||[]}catch{p.value="Error al cargar las citas"}finally{r.value=!1}}function x(s){return new Date(s).toLocaleDateString("es-ES",{weekday:"long",year:"numeric",month:"long",day:"numeric"})}return(s,t)=>{const n=N("router-link");return a(),_(H,null,{default:u(()=>[t[7]||(t[7]=e("h2",{style:{margin:"0 0 5px 0","font-size":"22px"}},"Inicio",-1)),t[8]||(t[8]=e("p",{class:"title-sm",style:{"margin-top":"0"}},"Tus citas próximas",-1)),r.value?(a(),_(L,{key:0})):i("",!0),p.value?(a(),_($,{key:1,message:p.value},null,8,["message"])):i("",!0),h.value?(a(),l("div",W,[t[0]||(t[0]=e("div",{class:"wa-home-banner__text"},[e("span",{class:"wa-home-banner__icon","aria-hidden":"true"},"💬"),e("span",null,"¿Necesitás ayuda? Escribinos por WhatsApp.")],-1)),e("a",{href:h.value,class:"btn btn-outline btn-sm wa-home-banner__btn",target:"_blank",rel:"noopener noreferrer"}," Abrir WhatsApp ",8,F)])):i("",!0),!r.value&&d.value.length===0?(a(),l("div",M,[t[2]||(t[2]=e("p",{class:"no-text"},"No tenés citas próximas",-1)),c(n,{to:"/client/book",class:"btn btn-gold"},{default:u(()=>[...t[1]||(t[1]=[b("Reservar Cita",-1)])]),_:1})])):i("",!0),!r.value&&d.value.length>0?(a(),l("div",R,[(a(!0),l(V,null,B(d.value,o=>(a(),l("div",{key:o.id,class:"card appointment-card"},[e("div",U,[e("div",null,[e("h3",j,m(o.service?.name),1),e("p",q,m(o.barber?.user?.name),1)]),c(I,{status:o.status},null,8,["status"])]),e("div",z,[e("div",O,[t[3]||(t[3]=e("span",{class:"title-sm"},"FECHA",-1)),e("span",P,m(x(o.appointment_date)),1)]),e("div",G,[t[4]||(t[4]=e("span",{class:"title-sm"},"HORA",-1)),e("span",J,m(o.start_time),1)])]),c(n,{to:"/client/my-appointment",class:"btn btn-outline",style:{"margin-top":"16px",display:"block","text-align":"center","text-decoration":"none"}},{default:u(()=>[...t[5]||(t[5]=[b(" Ver detalles ",-1)])]),_:1})]))),128))])):i("",!0),!r.value&&d.value.length>0?(a(),l("div",K,[c(n,{to:"/client/book",class:"btn btn-gold"},{default:u(()=>[...t[6]||(t[6]=[b("Reservar otra cita",-1)])]),_:1})])):i("",!0)]),_:1})}}},ot=A(Q,[["__scopeId","data-v-c755330b"]]);export{ot as default};
