1(()=>{function t(t){try{const e=JSON.parse(t.textContent);return e?(e.behavior=String(e.behavior||"").trim().toLowerCase()||"mandatory",e):null}catch(t){return null}}function e(t){return String(t.includedVariantIds).split(",").map((t=>t.trim()))}function i(t){if(!t)return 1;const e=Number(t.selectionMaxLimit);return isNaN(e)?1:e}function s(t){if(!t)return 1;const e=Number(t.selectionMinLimit);return isNaN(e)?1:e}function r(t){return 1===i(t)}class a{static instances=[];static wrapInstalled=!1;constructor(e){this.root=e,this.swiper=null,this.waitingForSwiper=!1,this.skipQuantityEvents=!1,this.cacheDom(),this.counterTemplate=e.getAttribute("data-cta-counter-template"),this.errorMessage=e.getAttribute("data-cta-popup-error-message")||"",this.biTypeAddToCart=e.getAttribute("data-cta-bi-type-add-to-cart")||"",this.biTypeBuyNow=e.getAttribute("data-cta-bi-type-buy-now")||"",this.rules=[...e.querySelectorAll("[data-cta-rule]")].map(t).filter(Boolean),this.resetState(),this.bindAll(),this.isReady=!(!this.overlay||!this.row),this.isReady&&this.listen()}cacheDom(){const t=t=>this.root.querySelector(t);this.overlay=t("[data-cta-popup-overlay]"),this.dialog=t("[data-cta-popup-dialog]"),this.closeBtn=t("[data-cta-popup-close]"),this.counterEl=t("[data-cta-popup-counter]"),this.swiperEl=t("[data-cta-popup-swiper]"),this.row=t("[data-cta-popup-row]"),this.errorEl=t("[data-cta-popup-footer-error]"),this.addToCartBtn=t("[data-cta-popup-add-to-cart]"),this.arrowPrev=this.swiperEl?.querySelector(".swiper-button-prev")??null,this.arrowNext=this.swiperEl?.querySelector(".swiper-button-next")??null,this.productCtaPopupTitle=t(".product-cta-popup-title")}bindAll(){this.onRowClick=this.onRowClick.bind(this),this.onCheckboxChange=this.onCheckboxChange.bind(this),this.onCloseClick=this.onCloseClick.bind(this),this.onOverlayClick=this.onOverlayClick.bind(this),this.onKeydown=this.onKeydown.bind(this),this.onAddToCartClick=this.onAddToCartClick.bind(this),this.onVariantChanged=this.onVariantChanged.bind(this),this.onQuantityChanged=this.onQuantityChanged.bind(this),this.onSwiperScriptLoad=this.onSwiperScriptLoad.bind(this)}listen(){this.row.addEventListener("click",this.onRowClick),this.row.addEventListener("change",this.onCheckboxChange),this.closeBtn?.addEventListener("click",this.onCloseClick),this.addToCartBtn?.addEventListener("click",this.onAddToCartClick),this.overlay.addEventListener("click",this.onOverlayClick),document.addEventListener("variant:changed",this.onVariantChanged),document.addEventListener("quantity:changed",this.onQuantityChanged)}resetState(){this.selected={},this.activeRule=null,this.continuePurchase=null,this.isMandatory=!0,this.purchaseOptions={}}matchRule(t){const r=String(t);for(const t of this.rules)if(t?.includedVariantIds&&e(t).includes(r)&&!(i(t)<s(t)))return t;return null}static findControllerForVariant(t){if(!t)return null;for(const e of a.instances){const i=e.matchRule(t);if(i)return{controller:e,rule:i}}return null}initSwiper(){requestAnimationFrame((()=>this.mountSwiper()))}onSwiperScriptLoad(){this.stopWaitingForSwiper(),requestAnimationFrame((()=>this.mountSwiper()))}stopWaitingForSwiper(){this.waitingForSwiper&&(document.removeEventListener("productCtaPopupSwiper:load",this.onSwiperScriptLoad),this.waitingForSwiper=!1)}mountSwiper(){this.swiperEl&&this.row&&(this.stopWaitingForSwiper(),this.mountSwiperIfReady()||(document.addEventListener("productCtaPopupSwiper:load",this.onSwiperScriptLoad),this.waitingForSwiper=!0,requestAnimationFrame((()=>{this.waitingForSwiper&&this.mountSwiperIfReady()&&this.stopWaitingForSwiper()}))))}mountSwiperIfReady(){if("undefined"==typeof Swiper)return!1;if(this.overlay.classList.contains("d-none")||!this.row.querySelector(".swiper-slide"))return!0;const t=this.swiperEl.querySelectorAll(".swiper-slide")?.length,e=Math.min(5,Math.max(1,t)),i=Math.max(1,Math.min(2.5,t));return this.swiper=new Swiper(this.swiperEl,{slidesPerView:i,spaceBetween:15,breakpoints:{768:{slidesPerView:e}},navigation:{prevEl:this.arrowPrev,nextEl:this.arrowNext}}),!0}destroySwiper(){if(this.stopWaitingForSwiper(),this.swiper){try{this.swiper.destroy(!0,!0)}catch(t){}this.swiper=null}}open(t,e,i={}){this.activeRule=t,this.continuePurchase=e,this.purchaseOptions=i,this.isMandatory="optional"!==t.behavior,this.selected={},this.errorEl.textContent="",this.overlay.classList.toggle("product-cta-popup-overlay--single-flavor",r(this.activeRule)),this.closeBtn?.classList.toggle("d-none",this.isMandatory),this.productCtaPopupTitle.textContent=this.activeRule.variantPopupTitle,this.setAddToCartBiType(i),this.clearCardSelection(),this.resetAllInputs(),this.refreshUI(),this.overlay.classList.remove("d-none"),this.overlay.classList.add("d-flex"),this.overlay.setAttribute("aria-hidden","false"),document.addEventListener("keydown",this.onKeydown),this.initSwiper(),this.activeRule.selectionMaxLimit>1&&this.row.querySelectorAll("[data-cta-popup-item-card] .quantity-selector-input").forEach((t=>{t.max=this.activeRule.selectionMaxLimit}))}setAddToCartBiType(t={}){this.addToCartBtn&&this.addToCartBtn.setAttribute("bi-type","checkout"===t.destination?this.biTypeBuyNow:this.biTypeAddToCart)}close(){this.destroySwiper(),this.addToCartBtn&&(this.addToCartBtn.disabled=!1),this.overlay.classList.remove("product-cta-popup-overlay--single-flavor","d-flex"),this.overlay.classList.add("d-none"),this.overlay.setAttribute("aria-hidden","true"),document.removeEventListener("keydown",this.onKeydown),this.resetState()}totalSelected(){return Object.values(this.selected).reduce(((t,e)=>{const i=parseInt(e,10);return t+(i>
10?i:0)}),0)}withinLimits(){const t=this.totalSelected();return t>=s(this.activeRule)&&t<=i(this.activeRule)&&t>0}handleRemainingProductsToPick(t){const e=i(this.activeRule)-this.totalSelected();return e>0?e:(t&&(t.checked=!1),this.refreshUI(),0)}setCardInput(t,e){const i=this.row.querySelector(`[data-cta-popup-item-card][data-variant-id="${CSS.escape(String(t))}"]`)?.querySelector(".quantity-selector-input");i&&(i.value=String(e),i.dispatchEvent(new Event("change",{bubbles:!0})))}guardedSetInput(t,e){this.skipQuantityEvents=!0;try{this.setCardInput(t,e)}finally{this.skipQuantityEvents=!1}}resetInput(t){this.guardedSetInput(t,0)}resetAllInputs(){this.skipQuantityEvents=!0;try{this.row.querySelectorAll("[data-cta-popup-item-card]").forEach((t=>{if("true"===t.getAttribute("data-cta-unavailable"))return;const e=t.getAttribute("data-variant-id");e&&this.setCardInput(e,0)}))}finally{this.skipQuantityEvents=!1}}syncSingleFlavorInputs(t){this.skipQuantityEvents=!0;try{this.row.querySelectorAll("[data-cta-popup-item-card]").forEach((e=>{if("true"===e.getAttribute("data-cta-unavailable"))return;const i=e.getAttribute("data-variant-id");if(i){const e=t&&i===String(t)?1:0;this.setCardInput(i,e)}}))}finally{this.skipQuantityEvents=!1}}clearCardSelection(){this.row.querySelectorAll("[data-cta-popup-item-card]").forEach((t=>{const e=t.querySelector("[data-cta-popup-item-checkbox]");e&&(e.checked=!1),t.classList.remove("product-cta-popup-card-selected")}))}cardFromClick(t){const e=t?.target;if(!e?.closest)return null;if(e.closest("[data-cta-popup-item-checkbox]"))return null;const i=e.closest("[data-cta-popup-item-card]");if(!i)return null;if("true"===i.getAttribute("data-cta-unavailable"))return null;if(i.classList.contains("product-cta-popup-card-disabled"))return null;const s=i.getAttribute("data-variant-id");return s?{card:i,variantId:s}:null}onRowClick(t){const e=this.cardFromClick(t);if(!e)return;const{card:i,variantId:s}=e,a=Object.prototype.hasOwnProperty.call(this.selected,s);if(r(this.activeRule))return a?(delete this.selected[s],this.syncSingleFlavorInputs(null)):(this.selected={[s]:1},this.syncSingleFlavorInputs(s)),void this.refreshUI();if(a)return delete this.selected[s],this.resetInput(s),void this.refreshUI();const n=this.handleRemainingProductsToPick();if(!n)return;const o=i.querySelector(".quantity-selector-input"),c=parseInt(o?.value,10),l=Math.min(Number.isFinite(c)&&c>0?c:1,n);this.selected[s]=l,this.guardedSetInput(s,l),this.refreshUI()}onCheckboxChange(t){const e=t.target;if(!e?.matches?.("[data-cta-popup-item-checkbox]"))return;t.stopPropagation();const i=e.closest("[data-cta-popup-item-card]");if(!i||"true"===i.getAttribute("data-cta-unavailable"))return;const s=i.getAttribute("data-variant-id");return s?e.checked?r(this.activeRule)?(this.selected={[s]:1},this.syncSingleFlavorInputs(s),void this.refreshUI()):void(this.handleRemainingProductsToPick(e)&&(this.selected[s]=1,this.guardedSetInput(s,1),this.refreshUI())):(delete this.selected[s],r(this.activeRule)?this.syncSingleFlavorInputs(null):this.resetInput(s),void this.refreshUI()):void 0}onOverlayClick(t){t.target===this.overlay&&(this.isMandatory?this.flashError(this.errorMessage):this.finish(!0))}onCloseClick(t){t.preventDefault(),t.stopPropagation(),this.isMandatory||this.finish(!0)}onKeydown(t){"Escape"!==t.key||this.isMandatory||this.finish(!0)}onAddToCartClick(t){t.preventDefault(),this.withinLimits()?this.finish():this.isMandatory&&this.flashError(this.errorMessage)}onVariantChanged(){this.overlay.classList.contains("d-none")||this.isMandatory||this.close()}onQuantityChanged(t){const e=t?.detail,s=null!=e?.variantId?String(e.variantId):null;if(!s)return;if(this.overlay.classList.contains("d-none"))return;if(!Object.prototype.hasOwnProperty.call(this.selected,s))return;if(this.skipQuantityEvents)return;if(r(this.activeRule))return;const a=i(this.activeRule);if(a<=0)return void this.refreshUI();const n=parseInt(e.value,10),o=isNaN(n)?0:n;if(o<=0)return delete this.selected[s],void this.refreshUI();const c=parseInt(this.selected[s],10)||0,l=a-Math.max(0,this.totalSelected()-c);l<=0?(delete this.selected[s],this.resetInput(s)):o>l?(this.guardedSetInput(s,l),this.selected[s]=l):this.selected[s]=Math.max(1,o),this.refreshUI()}refreshUI(){const t=this.totalSelected(),e=i(this.activeRule),a=e>0&&t>=e,n=Object.keys(this.selected).length>0,o=!r(this.activeRule)&&n&&t<=s(this.activeRule);this.row.querySelectorAll("[data-cta-popup-item-card]").forEach((t=>{this.refreshCard(t,{atCapacity:a,blockingMinimum:o})})),this.refreshCounter(t,e),this.addToCartBtn&&(this.addToCartBtn.disabled=!this.withinLimits()),this.withinLimits()&&this.clearError(),this.activeRule.selectionMaxLimit<=this.totalSelected()?this.row.querySelectorAll(".product-cta-popup-card-selected .quantity-selector-plus").forEach((t=>{t.disabled=!0})):this.row.querySelectorAll(".product-cta-popup-card-selected .quantity-selector-plus").forEach((t=>{t.disabled=!1}))}refreshCard(t,{atCapacity:e,blockingMinimum:i}){const s=t.getAttribute("data-variant-id"),a="true"===t.getAttribute("data-cta-unavailable"),n=t.querySelector("[data-cta-popup-item-checkbox]"),o=t.querySelector(".product-cta-quantity-selector-wrapper"),c=Object.prototype.hasOwnProperty.call(this.selected,s);if(r(this.activeRule)?o?.classList.add("d-none"):o?.classList.toggle("opacity-0",!c),a)return n&&(n.checked=!1,n.disabled=!0),void t.classList.add("product-cta-popup-card-disabled");n&&(n.checked=c),t.classList.toggle("product-cta-popup-card-selected",c);const l=!r(this.activeRule)&&!c&&e;t.classList.toggle("product-cta-popup-card-disabled",l),n&&(n.disabled=l)}refreshCounter(t,e){this.counterEl&&(this.counterEl.textContent=this.counterTemplate.replace(/%current%/g,String(Math.min(t,e))).replace(/%total%/g,String(e)))}clearError(){this.errorEl&&(this.errorEl.textContent="",this.errorEl.classList.add("d-none"))}flashError(t){this.errorEl&&(this.withinLimits()?this.clearError():(this.dialog.offsetWidth,this.errorEl.textContent=t,this.errorEl.classList.remove("d-none")))}buildExtraItems(){return Object.entries(this.selected).map((([t,e])=>{const i=parseInt(e,10);return isNaN(i)||i<1?null:{id:parseInt(t,10),quantity:i,options:{properties:{}}}}
1)).filter(Boolean)}finish(t=!1){if(this.isMandatory&&!this.withinLimits())return void this.flashError(this.errorMessage);const e=this.continuePurchase,i=t?[]:this.buildExtraItems(),s=this.activeRule,r=this.purchaseOptions?.destination;this.close(),"function"==typeof e&&e({extraItems:i,source:"product-cta-popup",selectionMinLimit:s?.selectionMinLimit,selectionMaxLimit:s?.selectionMaxLimit,destination:r})}hasProducts(){return this.row.querySelectorAll("[data-cta-popup-item-card]").length>0}static init(){if(a.collectInstances(),a.wrapInstalled)return;if(!a.instances.length)return;const t=()=>{const t=window.machinePDPInstance;if(!t||t.productCtaPopupWrapped)return;const e=t.addProductToCart.bind(t);t.productCtaPopupWrapped=!0,t.addProductToCart=function(i={}){const s=a.findControllerForVariant(t.currentVariant?.id);s&&s.controller.hasProducts()?s.controller.open(s.rule,e,i):e(i)},a.wrapInstalled=!0};window.machinePDPInstance?t():document.addEventListener("machinePDP:ready",t,{once:!0})}static collectInstances(){document.querySelectorAll("[data-cta-popup-root]").forEach((t=>{if("1"===t.dataset.ctaPopupInit)return;const e=new a(t);e.isReady&&(t.dataset.ctaPopupInit="1",a.instances.push(e))}))}}const n=()=>a.init();document.addEventListener("DOMContentLoaded",n),document.addEventListener("machinePDP:ready",n)})();
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.