import{al as v,d as U,a as F,e as g,q as S,f as h,h as E,x as M,v as m,g as n,z as O,A as b,bb as N,o as w,bm as j,bn as f,_ as q}from"./BxiWQxwE.js";import{u as A}from"./Dl6s6BfE.js";import{a as C}from"./Bo9XA6rV.js";function B(a,e){return v(a,e==null?void 0:e.in).getDay()}function z(a,e){return v(a,e==null?void 0:e.in).getDay()===1}function I(a,e,c){let s=e-B(a,c);return s<=0&&(s+=7),C(a,s,c)}function L(a,e){return I(a,1,e)}const V={class:"offers__products--dates"},Y=["aria-label"],K=["aria-label"],R=U({__name:"header",props:{offerType:{type:String,required:!0},formatter:{type:Object,required:!1,default:()=>({weekday:"short",day:"numeric",month:"short"})}},emits:["handleOfferDate"],setup(a,{emit:e}){const c=a,s=(t,r=c.formatter)=>t==null?void 0:t.toLocaleDateString("nl-NL",r),{$messages:u}=F(),x=g(()=>!0),{now:k}=A(),p=S(N),i=g(()=>{const t=j(p.value?new Date(p.value.dateTime):k.value),r=t.getFullYear(),d=f(`${r}-12-17`),T=f(`${r}-12-26`),D=f(`${r}-12-27`),$=f(`${r+1}-01-01`),_=f(`${r+1}-01-02`);let o,l;return t>d&&t<=D?(o=T,l=D):t>D&&t<=_?(o=$,l=_):(o=z(t)?t:L(t),l=C(o,1)),{endDateCurrent:o,startDateUpcoming:l}}),y=e;return(t,r)=>(w(),h("div",V,[E("button",{class:b({active:a.offerType==="currentOffers"}),type:"button","aria-label":n(u)("aria.showOffersTillDate",{date:s(new Date(n(i).endDateCurrent),{weekday:"long",day:"numeric",month:"short"})}),onClick:r[0]||(r[0]=O(d=>y("handleOfferDate","currentOffers"),["prevent"]))},m(n(u)("offers.prefixDate"))+" "+m(s(new Date(n(i).endDateCurrent))),11,Y),n(x)?(w(),h("button",{key:0,class:b({active:a.offerType==="upcomingOffers"}),type:"button","aria-label":n(u)("aria.showOffersTillDate",{date:s(new Date(n(i).startDateUpcoming),{weekday:"long",day:"numeric",month:"short"})}),onClick:r[1]||(r[1]=O(d=>y("handleOfferDate","upcomingOffers"),["prevent"]))},m(n(u)("offers.prefixDateFrom"))+" "+m(s(new Date(n(i).startDateUpcoming))),11,K)):M("",!0)]))}}),P=q(R,[["__scopeId","data-v-77f41215"]]);export{P as default};
