1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./quick-view.DBoDF0Iv.min.js","./sections-api-service.CIHHOVpP.min.js","./parse-html.C-hh7jJd.min.js","./quick-view.BmxGInuv.min.css"])))=>i.map(i=>d[i]); 2import{_ as I}from"./main.CuVUc8lJ.min.js";import{S as L}from"./swiper-slider.Dp9oLI2c.min.js";import{g as R,f as v,a as C,b as P}from"./bloomreach-api.CXtF3QJ5.min.js";import{S as _}from"./globals.CillLayD.min.js";import{g as M}from"./get-locale.F9QPgOWP.min.js";import{t as q,a as B}from"./bloomreach-recommendation-analytics.CbtKTv7O.min.js";import{E}from"./events.CylfRtLc.min.js";/* empty css *//* empty css */import"./format-currency.B0iqgZdr.min.js";class k extends HTMLElement{constructor(){super(),this.renderRecommendationsHandler=this.renderRecommendations.bind(this)}connectedCallback(){this.container=this.querySelectorAll('[data-component="bloomreach-minicart"]'),document.addEventListener(E.MINICART_RECOMMENDATIONS,this.renderRecommendationsHandler)}disconnectedCallback(){document.removeEventListener(E.MINICART_RECOMMENDATIONS,this.renderRecommendationsHandler)}async renderRecommendations(){const r=await this.getRecommendationsData();if(!r||r.length===0){console.warn("Bloomreach API returned no data for any slots."),this.classList.add("is-hidden");return}try{await this.initializeAndRenderSlot(r[0]);const o=await I(()=>import("./quick-view.DBoDF0Iv.min.js"),__vite__mapDeps([0,1,2,3]),import.meta.url);typeof o.default=="function"&&o.default()}catch(o){console.error("Bloomreach: Failed to render a minicart recommendation component:",{element:this,error:o}),this.classList.add("is-hidden")}}async getRecommendationsData(){var S,h,l,f;const{url:r,token:o,identifiers:m,pagetype:i,customer:d,itemids:g,count:t=16}=this.dataset,a=JSON.parse(m),e=((h=(S=document.querySelector("[data-store-country]"))==null?void 0:S.dataset.storeCountry)==null?void 0:h.toLowerCase())||((f=(l=_)==null?void 0:l.country)==null?void 0:f.toLowerCase()),n=a==null?void 0:a.brandCode;if(!a[i]){console.error(`BLM: Identifier for page type "${i}" is missing in the <bloomreach-minicart> element data-identifiers json.`,this.dataset.identifiers),this.classList.add("is-hidden");return}if(!n){console.error("BLM: brandCode is missing in the minicart slot identifiers config.",this.dataset.identifiers),this.classList.add("is-hidden");return}const s=Object.create(null);g.split(",").forEach(b=>{b&&(s[b]=1)});const c=Object.create(null),u=R("__exponea_etc__");u?c.cookie=u:d&&(c.consumer_no=d);const w={customer_ids:c,params:{siteId:n+"-"+e,language:_.locale,size:t,itemIds:s,pagePath:window.location.pathname}},p=r.endsWith("/")?`${r}${a[i]}`:`${r}/${a[i]}`;return await v(p,btoa(o),w)}async initializeAndRenderSlot(r){var n;if(!r||r.length===0){this.classList.add("is-hidden");return}const o=await this.renderProductCardsSwiper(r);q(o,this.dataset.listName||"Bloomreach Recommendations");const{slidesPerView:m,slidesPerViewMobile:i,spaceBetween:d}=this.dataset,g=parseInt(m,10),t=parseInt(i,10),a=d/2,e=(n=new L(this,{slidesPerView:i,slidesPerGroup:t,spaceBetween:a,watchSlidesProgress:!0,freeMode:{enabled:!0,sticky:!1,momentumBounce:!1},normalizeSlideIndex:!0,observer:!0,observeParents:!0,edgeSwipeDetection:!0,navigation:{nextEl:"[data-recommendation-swiper-next]",prevEl:"[data-recommendation-swiper-prev]"},pagination:{el:this.querySelector("[data-recommendation-swiper-pagination]"),clickable:!0},breakpoints:{769:{spaceBetween:d,slidesPerGroup:g,slidesPerView:m,on:{slideChange(s){var c;(c=s.pagination)==null||c.update()}}}}}))==null?void 0:n.swiper;if(requestAnimationFrame(()=>{requestAnimationFrame(()=>{e==null||e.updateSize(),e==null||e.update()})}),!e){console.error("Failed to initialize Swiper for Bloomreach recommendations component.",{element:this});return}}async renderProductCardsSwiper(r){const o=this.querySelector("#minicart-product-card-template"),m=await M();if(!o){console.error('Product Card Template: "#minicart-product-card-template" not found.');return}const i=this.dataset.hideNoImageProducts=="true",d=[],g=r.map(t=>{const e=o.content.cloneNode(!0).querySelector(".swiper-slide"),n=e.querySelector("a"),s=e.querySelector(".product-card-simple__image-img"),c=e.querySelector(".product-card-simple__title"),u=e.querySelector("[data-price]"),w=e.querySelector("[data-compare-at-price]"),p=e.querySelector("[data-savings]"),y=e.querySelector("[data-quick-view-button]"),S=t.url.substring(t.url.indexOf("/products/"));
2if(y.dataset.productUrl=S,n){const f=t.url.split("/products/")[1];n.href=`${window.location.origin}${m}products/${f}`,n.addEventListener("click",()=>{B(t,this.dataset.listName||"Bloomreach Recommendations",this.dataset.placement||"Minicart")})}if(i)if(s&&t.image!="")C(s,t);else return console.warn(`Bloomreach: product recommendation image is missing for product: ${t.url}`),"";else s&&C(s,t);c&&(c.textContent=t.title);const h=parseFloat(t.lowCurrent),l=parseFloat(t.lowOriginal);if(u&&(u.textContent=P(h)),w&&l>h&&(w.textContent=P(l),w.dataset.active="true",u.parentElement.classList.add("product-price--has-sale"),p)){const f=(l-h)/l*100;p.textContent=`-${Math.round(f)}%`,p.dataset.active="true",p.classList.remove("product-price__price-savings-text--transparent")}return d.push(t),e}).filter(Boolean);return this.querySelector(".swiper-wrapper").innerHTML="",this.querySelector(".swiper-wrapper").append(...g),d}}const j=()=>{customElements.get("bloomreach-minicart")||customElements.define("bloomreach-minicart",k)};export{j as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.