import{d as Se,c as Ce,r as o,a as $e,b as Ee,w as T,g as Ge,e as we,o as Ie,a2 as ce,a3 as Re,h as M,l as i,m as F,C as L,i as t,T as ue,k as S,j as pe,p as _e,q as Te,a4 as de,_ as Fe,t as Le,v as D,P as me,x as u,A as De,y as Ne}from"./D1QozqMg.js";import{_ as Oe}from"./C5LCsqGt.js";import{C as Be,P as He,a as ke,_ as Ve,b as Ue}from"./NYj3_b7p.js";import"./DSjuBfzT.js";import"./DhFW1opL.js";import"./DslTMqll.js";import"./BHP1V-5W.js";import"./CXnv8yYB.js";const We=_e(Oe),qe=_e(ke),je={class:"max-w-screen-xl mx-auto mt-5"},Ke={key:0,class:"text-center heading h1"},Qe={key:1,class:"text-center heading h1"},Ye={key:2,class:"px-5 text-center"},ze={key:0,class:"w-full text-center min-h-screen"},it=Se({__name:"index",async setup(Je){var q,j,K,Q,Y,z,J,X;let l,p;const{locale:s,t:fe}=Ce(),r=Te(),N=de,x=o(0),d=o(!0),y=o(!0),m=o([]),C=o([]),O=o([]),ge=$e(),B=Ee(),H=o({mainFacets:{},drawerFacets:{}}),c=o({productGroup:[],mountingOptions:[],mainMaterial:[],enStandard:[],constructionAssessment:[],ageGroup:[],isInclusive:!1,isExpress:!1,fallHeightMin:0,fallHeightMax:0,impactAreaMin:0,impactAreaMax:0,priceRangeMin:0,priceRangeMax:0}),b=o({sort:"variants.attributes.product-priority%20asc",label:null}),$=o({});let k="";r.public.PREVIEW=="true"&&(k="&preview=true");const{data:V}=([l,p]=T(()=>D("catalog-index",()=>$fetch(`content-type/${me.pageCatalog[s.value]}?locale=${s.value}&contentType=pageCatalog${k}`,{method:"GET",baseURL:`${r.public.AWS_API_ENDPOINT}/${r.public.AWS_API_ENV}/`}))),l=await l,p(),l),{data:n}=([l,p]=T(()=>D("catalog-index",()=>$fetch(`content-type/${me.pageCatalog[s.value]}?locale=${s.value}&contentType=pageCatalog`,{method:"GET",baseURL:`${r.public.AWS_API_ENDPOINT}/${r.public.AWS_API_ENV}/`}))),l=await l,p(),l),U=o((j=(q=n==null?void 0:n.value)==null?void 0:q.fields)==null?void 0:j.metaTitle),ve=o((Q=(K=n==null?void 0:n.value)==null?void 0:K.fields)==null?void 0:Q.metaDescription),xe=o((z=(Y=n==null?void 0:n.value)==null?void 0:Y.fields)==null?void 0:z.title),E={"nn-NO":"en-GB","da-DK":"en-GB","es-ES":"en-GB"}[s.value]||s.value,{data:P}=([l,p]=T(()=>D("main-categories",()=>$fetch(`product-maincategories?locale=${E}`,{method:"GET",baseURL:`${r.public.AWS_API_ENDPOINT}/${r.public.AWS_API_ENV}/`}))),l=await l,p(),l);(((J=P.value)==null?void 0:J.results)||[]).sort((a,e)=>a.name[E].localeCompare(e.name[E])),O.value=(X=P==null?void 0:P.value)==null?void 0:X.results,Ge({title:`${U.value?U.value:xe.value} ${fe("| Lappset Group | The world of playgrounds and sports")}`,meta:[{name:"description",content:ve.value}]});const W=we(()=>{const e={"nn-NO":"en-GB","da-DK":"en-GB","es-ES":"en-GB"}[s.value]||s.value,f=[`variants.attributes.product-groups.label.${e} as productGroup`,`variants.attributes.product-mounting-options.label.${e} as mountingOptions`,`variants.attributes.product-main-material.label.${e} as mainMaterial`,`variants.attributes.product-en-standard.label.${e} as enStandard`,`variants.attributes.product-age-group.label.${e} as ageGroup`,"variants.attributes.product-is-inclusive as isInclusive","variants.attributes.product-is-express as isExpress","variants.attributes.product-max-free-fall-height:range (0 to 5000) as fallHeight","variants.attributes.product-impact-area:range (0 to 500) as impactArea"];return s.value==="sv-SE"&&f.push("variants.attributes.product-construction-assessment as constructionAssessment"),f});let _,G;Ie(async()=>{c.value={productGroup:[],mountingOptions:[],mainMaterial:[],enStandard:[],constructionAssessment:[],ageGroup:[],isInclusive:!1,isExpress:!1,fallHeightMin:0,fallHeightMax:0,impactAreaMin:0,impactAreaMax:0,priceRangeMin:0,priceRangeMax:0},_=new Be(c.value,b.value,ge,B),G=new He(s.value,r),_.turnQueryParamsIntoFilters(),await ye(_.defaultFilters)}),ce(c,a=>{w(a,!1,b.value.sort)},{deep:!0}),ce(b,a=>{w(c.value,!1,a.sort)},{deep:!0});async function ye(a){try{const{facets:e}=await G.fetchProductsNonReactive(a,y.value,W.value,N,x.value);y.value&&(he(e),y.value=!1)}catch(e){console.error(e)}}async function w(a,e=!1,f="variants.attributes.product-priority%20asc"){d.value=!0,e||(x.value=0,m.value=[]);try{const{results:g,rest:I,error:v}=await G.fetchProductsData(a,y.value,W.value,N,x.value,null,f);v&&(console.error(v),d.value=!1),e?m.value=m.value.concat(g):m.value=g,$.value=I,d.value=!1,m.value.forEach((h,R)=>{C.value.push({item_id:h.key,item_name:h.name[s.value],affiliation:`Lappset.com/${s.value}`,index:R,item_list_id:"All Products",item_list_name:"All Products",quantity:"1"})})}catch(g){console.error(g),d.value=!1}}function he(a){_.setupFacets(a,H)}function Ae(){x.value=x.value+de,w(c.value,!0)}function Me(){Object.assign(c.value,{productGroup:[],mountingOptions:[],mainMaterial:[],enStandard:[],constructionAssessment:[],ageGroup:[],isInclusive:!1,isExpress:!1,fallHeightMin:0,fallHeightMax:0,impactAreaMin:0,impactAreaMax:0,priceRangeMin:0,priceRangeMax:0}),B.push({query:{}})}return Re(()=>{c.value={productGroup:[],mountingOptions:[],mainMaterial:[],enStandard:[],constructionAssessment:[],ageGroup:[],isInclusive:!1,isExpress:!1,fallHeightMin:0,fallHeightMax:0,impactAreaMin:0,impactAreaMax:0,priceRangeMin:0,priceRangeMax:0}}),(a,e)=>{var Z,ee,te,ae,se,ne,oe,le,ie,re;const f=De,g=We,I=qe,v=Fe,h=Le,R=Ve,be=Ue,Pe=Ne;return u(),M("div",null,[i(v,null,{default:F(()=>[i(f,{"breadcrumbs-list":[{slug:"pageCatalog",name:"pageCatalog"}]}),t(C).length?(u(),pe(g,{key:0,data:{event:"view_item_list",ecommerce:{items:t(C)}}},null,8,["data"])):S("",!0),i(I,{data:[],"category-type":"all"})]),_:1}),L("div",null,[L("div",je,[(ee=(Z=t(n))==null?void 0:Z.fields)!=null&&ee.heading?(u(),M("h1",Ke,ue((ae=(te=t(n))==null?void 0:te.fields)==null?void 0:ae.heading),1)):(u(),M("h1",Qe,ue(a.$t("All products")),1)),(ne=(se=t(n))==null?void 0:se.fields)!=null&&ne.description?(u(),M("div",Ye,[i(h,{content:(le=(oe=t(n))==null?void 0:oe.fields)==null?void 0:le.description},null,8,["content"])])):S("",!0),i(v,null,{default:F(()=>[i(R,{categories:t(O),facets:t(H),"selected-filters":t(c),"selected-sorting":t(b),metadata:t($),"category-type":"all-products",locale:t(s),"loading-facets":t(y),onSetSelectedFilter:e[0]||(e[0]=A=>t(_).setSelectedFilter(A)),onClearFilters:e[1]||(e[1]=A=>Me()),onSortProductsDisplayed:e[2]||(e[2]=A=>t(_).setSelectedSorting(A))},null,8,["categories","facets","selected-filters","selected-sorting","metadata","locale","loading-facets"])]),_:1})]),L("div",null,[i(v,null,{default:F(()=>[i(be,{loading:t(d),products:t(m),metadata:t($),"current-category":"All products",onLoadmore:e[3]||(e[3]=A=>Ae())},null,8,["loading","products","metadata"])]),_:1})]),t(d)?(u(),M("div",ze,[i(Pe,{class:"my-10"})])):S("",!0),(ie=t(V))!=null&&ie.fields.descriptionBottom?(u(),pe(h,{key:1,content:(re=t(V))==null?void 0:re.fields.descriptionBottom,class:"px-5 my-3 text-center"},null,8,["content"])):S("",!0)])])}}});export{it as default};