import A from"./BKduTEy4.js";import P from"./CK-efZdt.js";import{d as C,ba as M,w as O,M as S,r as x,j as N,bs as W,b8 as V,f,h as v,x as $,g as u,A as F,i as K,F as T,y as j,c as z,bD as H,o as l,t as J,_ as L}from"./BxiWQxwE.js";import{u as Q}from"./DV8hZmlQ.js";import{u as R}from"./D0yXLBOh.js";import{u as U}from"./82sW_ACQ.js";import"./CJJKXTL2.js";import"./4HfP1VOY.js";import"./QMEN6lyk.js";import"./CxeYIrhH.js";import"./B3ykzW4l.js";import"./6_wmZUKe.js";import"./BXJ7yDe-.js";import"./DeW1CcJJ.js";import"./rygnbzXY.js";import"./mNyKjZh7.js";import"./DA8rZi_P.js";import"./DVEjoXxb.js";import"./ERvin0ES.js";const q={class:"container"},X={key:0,class:"pastries"},Y=C({__name:"overview",async setup(Z){let m,b;const{hide:y}=M(),{getPastryPrice:D}=Q(),{dekagebakDepartment:g}=R(),{listWebGroupProducts:I}=U(),{data:d,error:w}=([m,b]=O(async()=>z("deka-gebak",async()=>{var e,o;if(g.value){const t=new Map,n=((o=(e=g.value)==null?void 0:e.webGroups)==null?void 0:o.map(a=>a.webGroupId))??[],r=await Promise.all(n.map(async a=>{const{listWebGroupProducts:{productAssortment:s}}=await I(a,H);return{webgroupId:a,products:Array.isArray(s)?s==null?void 0:s.filter(Boolean):[]}}));return(r==null?void 0:r.length)===0?[]:(r.forEach(({webgroupId:a,products:s})=>{s.forEach(i=>{const{webgroup:_}=i.productInformation;let p=t.get(String(_));p||(p={id:a,items:[]},t.set(String(_),p)),p.items.some(G=>G.productId===i.productId)||p.items.push({...i,webgroupId:a,category:_,price:D(i)})})}),Array.from(t,([a,{id:s,items:i}])=>({webgroup:a,webgroupId:s,items:i}))??[])}})),m=await m,b(),m);w.value&&S({statusCode:404,statusMessage:`DekaGebak error, ${JSON.stringify(w.value)}`});const c=x(null),h=x("");N(async()=>{await W(),E()}),V(()=>{var e;return(e=c.value)==null?void 0:e.disconnect()});const E=()=>{var o;c.value&&c.value.disconnect();const e=window.innerWidth<=768?"-144px 0px -30% 0px":window.innerWidth<=1024?"-144px 0px -50% 0px":"0px 0px -50% 0px";c.value=new IntersectionObserver(B,{root:null,rootMargin:e,threshold:.1}),(o=d.value)==null||o.forEach(t=>{const n=document.getElementById(String(t.webgroupId));n&&c.value.observe(n)})},B=e=>{e.forEach(o=>{var t;o.isIntersecting&&(h.value=(t=o.target)==null?void 0:t.id)})};return(e,o)=>{const t=A,n=P;return l(),f("section",null,[v("div",q,[u(d)?(l(),f("div",X,[v("div",{class:F(["pastries__nav",{"header--hide":u(y)}])},[K(t,{departments:u(d),"active-department":u(h)},null,8,["departments","active-department"])],2),v("div",null,[(l(!0),f(T,null,j(u(d),(r,k)=>(l(),J(n,{id:r.webgroupId,key:`department-${r==null?void 0:r.webgroup}--${k}`,department:r},null,8,["id","department"]))),128))])])):$("",!0)])])}}}),he=L(Y,[["__scopeId","data-v-2220b5b5"]]);export{he as default};
