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