import{k as y,b as E,j as R,L as a,O as c,V as w,M as I,S as M,P as F,U as N,H as b,Y as T,W as D,t as J,I as P,u as S,a0 as K,a1 as X,a as Z,z as ee,C as te}from"./DGQDO-VU.js";import{au as z,C as ne,u as W,d as H,aq as oe,a8 as re,az as ae}from"./BDl4c6dV.js";const ie=t=>{const h=z("categories",()=>t.value),r=z("conditions",()=>({})),n=y(()=>({groupName:"categoryids",where:r.value})),{data:u,refresh:p,pending:C}=ne("getFilterValues","getFilterValues-sideNavigation",n,{immediate:!1}),d=async()=>{var l;await p();const $=new Map((l=u.value)==null?void 0:l.map(({id:i,productCount:g})=>[i,g]));return h.value=Q($,[...t.value]),u};return E(r,async()=>{await d()}),{refresh:d,pending:C,data:u,categories:h,conditions:r}},Q=(t,h)=>h.map(r=>{var n,u;return r.path=((n=r.shopLevelCustomData)==null?void 0:n.redirectUrl)||r.path,r.shopLevelCustomData.active=(t.get(r.id)||0)>0||((u=r.shopLevelCustomData)==null?void 0:u.redirectUrl),(r.children||[]).length>0&&(r.children=[...Q(t,r.children||[])]),r}),le=R({__name:"SideNavigationSkeleton",props:{index:{type:Number,default:0}},setup(t){return(h,r)=>(a(),c("div",{class:w({"ml-4 mt-2 block h-4 w-1/2 animate-pulse bg-gray-400":!0,"w-1/4":t.index%2===0,"w-3/4":t.index%3===0})},null,2))}}),se={key:1,class:"flex items-center gap-2 border border-black px-4 py-2 text-xs uppercase tracking-wide opacity-50 lg:border-none lg:px-0 lg:text-base lg:normal-case lg:tracking-normal"},Y=R({__name:"SideNavigationItem",props:{category:{type:Object,required:!0},rootCategory:{type:Object||null,required:!0},showNestedCategories:{type:Boolean,default:!1}},emits:["click:navigationItem"],setup(t,{emit:h}){const r=W(),n=t,u=h,p=(l,i)=>{var g;for(const k in i)if(i[k].id===l||(g=i[k].children)!=null&&g.length&&p(l,i[k].children))return!0;return!1},C=y(()=>{var l,i,g;if(((l=n.rootCategory)==null?void 0:l.id)===n.category.id||d.value===n.category.id)return!0;if((i=n.category.children)!=null&&i.length){if(p((g=n.rootCategory)==null?void 0:g.id,n.category.children))return!0;if(d.value&&p(d.value,n.category.children))return!0}return!1}),d=y(()=>{var l,i;return(l=r.query)!=null&&l.cat?parseInt(((i=r.query)==null?void 0:i.cat)||""):null}),$=y(()=>{var l,i;return n.category.depth<2||n.category.id===d.value||n.category.id===((l=n.rootCategory)==null?void 0:l.id)?!0:(i=n.category.children)!=null&&i.length?p(d.value||n.rootCategory.id,n.category.children):!1});return(l,i)=>{var L;const g=H,k=Y;return a(),c("li",{onClick:i[0]||(i[0]=x=>u("click:navigationItem"))},[t.category.shopLevelCustomData.active?(a(),I(g,{key:0,to:t.category.path,class:w(["flex items-center gap-2 border border-black px-4 py-2 text-xs uppercase tracking-wide lg:border-none lg:px-0 lg:text-base lg:normal-case lg:tracking-normal",{"bg-gray-100 lg:border-0 lg:bg-transparent":C.value}])},{default:M(()=>[F("span",{class:w({"font-bold":C.value,"lg:text-3xl":t.category.depth===1})},N(t.category.name),3)]),_:1},8,["to","class"])):(a(),c("span",se,N(t.category.name),1)),t.showNestedCategories&&((L=t.category.children)!=null&&L.length)&&$.value?(a(),c("ul",{key:2,class:w(["mb-4 ml-4 mt-1 border-l border-black pl-6",{"!ml-0 border-none !pl-0":!t.rootCategory}])},[(a(!0),c(b,null,T(t.category.children,x=>(a(),I(k,{key:`side_navigation_list_item_${x.id}`,category:x,"root-category":t.rootCategory,"show-nested-categories":t.showNestedCategories},null,8,["category","root-category","show-nested-categories"]))),128))],2)):D("",!0)])}}}),ce={key:0},ue={class:"mb-2 hidden text-3xl lg:block"},de={key:0,class:"m-0 flex w-full gap-x-2 overflow-hidden overflow-x-auto whitespace-nowrap px-6 scrollbar-hide lg:hidden lg:pb-2.5"},he={key:1,class:"hidden lg:block"},ge={class:"hidden lg:mt-16 lg:flex lg:flex-col"},me={class:"block py-1.5 text-3xl"},fe={key:1,class:"block py-1.5 text-3xl opacity-50"},Ce=R({__name:"SideNavigation",props:{categories:{type:[Array,Object],default:()=>[]},fetching:{type:Boolean,required:!0},rootCategory:{type:Object,default:null},showNestedCategories:{type:Boolean,default:!1},keySuffix:{type:String,default:""}},emits:["redirect"],setup(t,{emit:h}){const{activeSubCategoriesWithFilter:r}=oe(),n=t,u=J(n,"categories"),p=y(()=>Array.isArray(u.value)?u.value:[u.value]),C=y(()=>`${n.keySuffix}${p.value.map(e=>e.id).join("-")}`),d=W(),$=h,l=()=>{var m,f;const e=v.value.filter(s=>s.shopLevelCustomData.active);if((e==null?void 0:e.length)===1&&d.path.includes("merken")){const s=(f=(m=e[0])==null?void 0:m.children)==null?void 0:f.filter(_=>_.shopLevelCustomData.active);(s==null?void 0:s.length)===1&&!s[0].path.includes("undefined")&&$("redirect",s[0].path)}},i=y(()=>n.rootCategory?g(n.rootCategory):""),g=e=>e.depth===2?e.name:e.depth>2&&e.parent?g(e.parent):"",k=y(()=>{var e;return((e=n.rootCategory)==null?void 0:e.depth)<2?v.value:r.value}),L=y(()=>{var e;return((e=n.rootCategory)==null?void 0:e.depth)<=2||d.path.includes("merken")?v.value:j(v.value)||A(v.value)||[]}),x=e=>{var m;if((m=e.shopLevelCustomData)!=null&&m.active)return!0;if(!e.children.length)return!1;for(const f in e.children)if(x(e.children[f]))return!0;return!1},j=e=>{var m,f;for(const s in e){if(e[s].id===((m=n.rootCategory)==null?void 0:m.id))return(f=e[s].children)!=null&&f.length&&e[s].children||null;const _=j(e[s].children||[]);if(_)return _}return null},A=e=>{var m;for(const f in e){if(e[f].id===((m=n.rootCategory)==null?void 0:m.id))return e;const s=A(e[f].children||[]);if(s)return s}return null},{categories:v,refresh:G}=ie(p);return re(async()=>{await G(),l()},`SideNavigation-${C.value}`),E(v,()=>{l()},{deep:!0}),(e,m)=>{var B,q,V;const f=le,s=Y,_=H;return t.fetching?(a(),c("div",ce,[(a(),c(b,null,T(5,o=>P(f,{key:`category-loading-${o}`,index:o},null,8,["index"])),64))])):(a(),c("div",{key:1,class:w(["-mx-6 lg:mx-0 lg:-mt-16",{"animate-pulse":t.fetching}])},[F("span",ue,N(i.value),1),L.value.length?(a(),c("ul",de,[(a(!0),c(b,null,T(L.value,o=>(a(),c(b,{key:`side_navigation_list_mobile_item_${o.id}`},[x(o)||!S(d).path.includes("merken")?(a(),I(s,{key:0,category:o,"root-category":t.rootCategory,"show-nested-categories":!1},null,8,["category","root-category"])):D("",!0)],64))),128))])):D("",!0),"length"in S(v)&&S(v).length&&(((B=t.rootCategory)==null?void 0:B.depth)>1||S(d).path.includes("merken"))?(a(),c("ul",he,[(a(!0),c(b,null,T(S(v),o=>(a(),c(b,{key:`side_navigation_list_item_${o.id}`},[x(o)||!S(d).path.includes("merken")?(a(),I(s,{key:0,category:o,"root-category":t.rootCategory,"show-nested-categories":t.showNestedCategories},null,8,["category","root-category","show-nested-categories"])):D("",!0)],64))),128))])):D("",!0),K(F("ul",ge,[(a(!0),c(b,null,T(k.value,o=>{var O,U;return a(),c("li",{class:w(i.value===(o==null?void 0:o.name)?"hidden":"")},[(O=t.rootCategory)!=null&&O.parentId||(U=o==null?void 0:o.shopLevelCustomData)!=null&&U.active?(a(),I(_,{key:0,to:o.path},{default:M(()=>[F("span",me,N(o==null?void 0:o.name),1)]),_:2},1032,["to"])):(a(),c("span",fe,N(o==null?void 0:o.name),1))],2)}),256))],512),[[X,((q=k.value)==null?void 0:q.length)&&((V=t.rootCategory)==null?void 0:V.depth)<2]])],2))}}}),pe={class:"hidden"},ke=R({__name:"ScrollToTop",setup(t){const h=Z(!1);function r(){document.body.scrollTop>500||document.documentElement.scrollTop>500?h.value=!0:h.value=!1}function n(){window.scrollTo({top:0,behavior:"smooth"})}return ee(()=>{window.addEventListener("scroll",r)}),te(()=>{window.removeEventListener("scroll",r)}),(u,p)=>{const C=ae;return a(),c("button",{class:w(["fixed bottom-4 right-6 z-20 m-auto flex h-10 w-10 items-center justify-center rounded-full bg-black text-white transition-opacity",{"opacity-0":!h.value}]),type:"button",onClick:n},[F("span",pe,N(u.$t("global.scroll_to_top")),1),P(C,{class:"h-[13px] w-[15px]"})],2)}}});export{Ce as _,ke as a};