import{_ as X}from"./BfkAGhbF.js";import{_ as Y}from"./CqdDYCDv.js";import{_ as W,o as l,b as k,B,T as z,f as $,d as E,u as tt,a4 as et,g as ot,$ as M,h as i,aB as rt,F as st,w as nt,y as at,a8 as lt,n as s,t as D,E as N,U as O,V as K,c as S,A as it,e as ct}from"./ClGV3uHt.js";import{e as V,p as dt}from"./tjB9Gthk.js";import{P as q,b as ut}from"./CfoqkG34.js";import{u as pt}from"./CIhOfKEU.js";import"./942tcsnM.js";import"./BVoCFatM.js";import"./BvD1YOii.js";import"./C2PiA__J.js";import"./kr2EvJyn.js";import"./BObIgP9_.js";import"./uXBH3zCt.js";import"./DA94OCfT.js";import"./CI9c1TW0.js";import"./kEe-sqSF.js";import"./B6e9DmpT.js";import"./DHIedM6L.js";import"./CSGs8R6P.js";import"./C40XNU9p.js";const mt={props:{isFlipped:Boolean,isLink:Boolean},computed:{arrowStyle(){return this.isFlipped?{transform:"rotate(180deg)"}:{}},arrowClass(){return this.isLink?"dropdown-arrow--link":""}}},_t=$("g",{stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},[$("path",{d:"M18.1002686,24.5 L34.3270399,7.98697064 C35.22432,7.07619685 35.22432,5.59560562 34.3270399,4.68483183 C33.4320547,3.77172272 31.9794247,3.77172272 31.0821446,4.68483183 L13.9810415,22.0876171 C12.6729862,23.4210834 12.6729862,25.5789166 13.9810415,26.9123829 L31.0821446,44.3151682 C31.9794247,45.2282773 33.4320547,45.2282773 34.3270399,44.3151682 C35.22432,43.4043944 35.22432,41.9238031 34.3270399,41.0130294 L18.1002686,24.5 Z",transform:"translate(24.000000, 24.500000) rotate(-90.000000) translate(-24.000000, -24.500000) ",class:"dropdown-arrow__content"})],-1),vt=[_t];function ft(P,e,g,m,o,c){return l(),k("svg",{viewBox:"0 0 48 48",version:"1.1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",class:B(["dropdown-arrow",c.arrowClass]),style:z(c.arrowStyle)},vt,6)}const ht=W(mt,[["render",ft]]),kt={class:"products-block"},gt={class:"products-block__viewport"},yt={key:1,class:"products-block__dropdown-container"},bt=E({__name:"Products",props:{title:{},limit:{},algorithm:{},productFilter:{},blockSystemId:{},forcedGhosts:{type:Boolean}},async setup(P){let e,g;const m=dt,o=P,c=tt(),v=et(),n=ot(),f=M("page"),F=M(rt,i(()=>null)),C=i(()=>o.title),y=i(()=>{var t,a;return(a=(t=f==null?void 0:f.value)==null?void 0:t.litiumPage)==null?void 0:a.systemId}),w=i(()=>o.blockSystemId),I=st(!1),U=i(()=>I.value?c.websiteTexts.blocks__products__showlessproducts:c.websiteTexts.blocks__products__showmoreproducts),j=()=>{I.value=!I.value},Z=i(()=>{var r,u;const t=!v.isMobile,a=v.isTablet.value&&(((r=x.value)==null?void 0:r.length)??0)>4,d=!v.isTablet.value&&(((u=x.value)==null?void 0:u.length)??0)>6;return t&&(a||d)}),b=i(()=>{var _,h,A,p,L;const t=F.value,a=t==null?void 0:t.id;if(!a)return;const d=n.query.Color;if(d&&((_=t.variants)==null?void 0:_.some(T=>T.fields.Color.value===d)))return`${a}_${d}`;const u=(L=(p=(A=(h=t.variants)==null?void 0:h[0])==null?void 0:A.fields)==null?void 0:p.Color)==null?void 0:L.value;if(u)return`${a}_${u}`}),H=i(()=>(b==null?void 0:b.value)||(w==null?void 0:w.value)),G=t=>!!t&&ut.includes(t),{data:x,status:J}=([e,g]=nt(async()=>at(`Elevate Products ${H.value}`,async()=>{var u,_,h;const t=o.algorithm,a=o.limit,d=o.productFilter?`rule incl ${o.productFilter}`:void 0,r=lt();try{if(G(t)&&!b.value)return[];if(G(t)&&b.value){const T=await((u=r.query)==null?void 0:u.productPage({productKey:b.value,viewId:r.querySettings.value.viewId,notify:r.querySettings.value.notify,presentCustom:q,presentPrices:V},{productGroup:{include:!1},recommendationLists:[{id:"product-block",algorithm:t,limit:a,productRules:d}]}));return T==null?void 0:T.recommendationLists[0].productGroups.map(m)}if(!y.value)return[];const p=await((_=r.query)==null?void 0:_.landingPage({pageReference:y.value,viewId:r.querySettings.value.viewId,notify:r.querySettings.value.notify,presentCustom:q,presentPrices:V},{recommendationLists:[{id:"product-block",algorithm:t,limit:a,productRules:d}]}));return p==null?void 0:p.recommendationLists[0].productGroups.map(m)}catch{if(!y.value)return[];const p=await((h=r.query)==null?void 0:h.landingPage({pageReference:y.value,viewId:r.querySettings.value.viewId,notify:r.querySettings.value.notify,presentCustom:q,presentPrices:V},{recommendationLists:[{id:"product-block",algorithm:"TOP_PRODUCTS",limit:a}]}));return p==null?void 0:p.recommendationLists[0].productGroups.map(m)}},{server:!1,watch:[b,y,()=>o.algorithm,()=>o.limit,()=>o.productFilter]})),e=await e,g(),e),R=i(()=>J.value==="pending"||o.forcedGhosts);return(t,a)=>{const d=X,r=Y,u=ht;return l(),k("div",kt,[s(C)?(l(),k("h3",{key:0,class:B({"products-block__title--ghost":s(R)})},D(s(R)?void 0:s(C)),3)):N("",!0),$("div",gt,[s(R)?(l(),k("div",{key:1,class:B(["products-block__container",{"products-block__container--expanded":s(I)}])},[(l(!0),k(O,null,K(t.limit??6,(_,h)=>(l(),S(r,{key:`ghost${h}`,style:z({order:h})},null,8,["style"]))),128))],2)):(l(),k("div",{key:0,class:B(["products-block__container",{"products-block__container--expanded":s(I)}])},[(l(!0),k(O,null,K(s(x),_=>(l(),S(d,{key:_.articleNumber,product:_},null,8,["product"]))),128))],2))]),s(Z)?(l(),k("div",yt,[$("a",{class:"alternative products-block__dropdown",onClick:j},[it(D(s(U))+" ",1),ct(u,{"is-link":""})])])):N("",!0)])}}}),Q=W(bt,[["__scopeId","data-v-5adb69c4"]]),wt=E({__name:"ProductsWithTest",props:{block:{}},setup(P){const e=P,g=n=>{var f;return{id:n.variantId,title:n.title,name:n._name,algorithm:(f=n.elevateAlgorithm)==null?void 0:f.value,limit:n.elevateLimit,productFilter:n.elevateProductFilter}},{variant:m,errorState:o}=pt(e.block.fields.testId),c=i(()=>!m.value&&!o.value),v=i(()=>{var C;const n=g(e.block.fields);return o.value?(console.warn(`Products block A/B test (id: ${e.block.fields.testId}) couldn't be loaded, so original variant was loaded. Reason: `,o.value),n):(((C=e.block.fields.productsBlockTestVariants)==null?void 0:C.map(g))??[]).find(y=>{var w;return y.id===((w=m.value)==null?void 0:w.id)})??n});return(n,f)=>{const F=Q;return l(),S(F,{"block-system-id":n.block.systemId,algorithm:s(v).algorithm,limit:s(v).limit,title:s(v).title,"product-filter":s(v).productFilter,"forced-ghosts":s(c)},null,8,["block-system-id","algorithm","limit","title","product-filter","forced-ghosts"])}}}),Wt=E({__name:"Products",props:{block:{}},setup(P){return(e,g)=>{var c;const m=wt,o=Q;return e.block.fields.testId?(l(),S(m,{key:0,block:e.block},null,8,["block"])):(l(),S(o,{key:1,"block-system-id":e.block.systemId,algorithm:(c=e.block.fields.elevateAlgorithm)==null?void 0:c.value,limit:e.block.fields.elevateLimit,title:e.block.fields.title,"product-filter":e.block.fields.elevateProductFilter},null,8,["block-system-id","algorithm","limit","title","product-filter"]))}}});export{Wt as default};