1function loadGwpImages(){document.querySelectorAll(".gwp-img").forEach(img=>{!img.src&&img.dataset.src&&(img.src=img.dataset.src)})}function mountCleanGwpCarousel(){const root=document.querySelector("cart-drawer.cart-drawer--clean .cart__gwp-cards");if(!root)return;const track=root.querySelector("[data-gwp-track]");if(!track||track.dataset.gwpBound==="true")return;track.dataset.gwpBound="true";const getStep=()=>{const slide=track.querySelector(".cart__gwp-slide");if(!slide)return track.clientWidth;const styles=window.getComputedStyle(track),gap=parseFloat(styles.columnGap||styles.gap)||0;return slide.getBoundingClientRect().width+gap},scrollByStep=direction=>{const step=getStep(),max=Math.max(0,track.scrollWidth-track.clientWidth),current=track.scrollLeft;if(direction>0){if(current>=max-2){track.scrollTo({left:0,behavior:"smooth"});return}track.scrollTo({left:Math.min(current+step,max),behavior:"smooth"});return}if(current<=2){track.scrollTo({left:max,behavior:"smooth"});return}track.scrollTo({left:Math.max(current-step,0),behavior:"smooth"})},prev=root.querySelector(".cart__gwp-nav--prev"),next=root.querySelector(".cart__gwp-nav--next");prev&&prev.addEventListener("click",()=>scrollByStep(-1)),next&&next.addEventListener("click",()=>scrollByStep(1))}function mountCartGwpCarousel(){if(loadGwpImages(),!!document.querySelector("cart-drawer.cart-drawer--clean")){mountCleanGwpCarousel();return}const el=document.getElementById("splide__gwp");!el||typeof Splide>"u"||(Number(el.dataset.count)||0)<=2||el.classList.contains("splide--static")||el.splide||window.matchMedia("(max-width: 576px)").matches&&new Splide(el,{type:"loop",lazyLoad:!1,arrows:!0,perPage:2.8,perMove:1,gap:16,pagination:!1,clones:6}).mount()}window.mountCartGwpCarousel=mountCartGwpCarousel;class CartRemoveButton extends HTMLElement{constructor(){super(),this.addEventListener("click",event=>{event.preventDefault(),(this.closest("cart-items")||this.closest("cart-drawer-items")).updateQuantity(this.dataset.index,0)})}}customElements.define("cart-remove-button",CartRemoveButton);class CartItems extends HTMLElement{constructor(){super(),this.lineItemStatusElement=document.getElementById("shopping-cart-line-item-status")||document.getElementById("CartDrawer-LineItemStatus");const debouncedOnChange=debounce(event=>{this.onChange(event)},ON_CHANGE_DEBOUNCE_TIMER);this.addEventListener("change",debouncedOnChange.bind(this)),document.addEventListener("cart:opened",()=>{this.addGiftToCart()})}
1cartUpdateUnsubscriber=void 0;connectedCallback(){this.cartUpdateUnsubscriber=subscribe(PUB_SUB_EVENTS.cartUpdate,event=>{event.source==="cart-items"||event.source==="product-form"||this.onCartUpdate()})}disconnectedCallback(){this.cartUpdateUnsubscriber&&this.cartUpdateUnsubscriber()}onChange(event){this.updateQuantity(event.target.dataset.index,event.target.value,document.activeElement.getAttribute("name"),event.target.dataset.quantityVariantId)}onCartUpdate(){this.tagName==="CART-DRAWER-ITEMS"?fetch(`${routes.cart_url}?section_id=cart-drawer`).then(response=>response.text()).then(responseText=>{const html=new DOMParser().parseFromString(responseText,"text/html"),selectors=["cart-drawer-items",".cart-drawer__footer",".drawer__header--icon"];for(const selector of selectors){const targetElement=document.querySelector(selector),sourceElement=html.querySelector(selector);targetElement&&sourceElement&&targetElement.replaceWith(sourceElement)}document.dispatchEvent(new CustomEvent("cart:drawer-updated"))}).catch(e=>{console.error(e)}).finally(()=>{mountCartGwpCarousel(),this.addGiftToCart(),document.dispatchEvent(new CustomEvent("countdown:restart")),document.dispatchEvent(new CustomEvent("mini-countdown:restart")),nostojs(api=>{api.loadRecommendations()})}):fetch(`${routes.cart_url}?section_id=main-cart-items`).then(response=>response.text()).then(responseText=>{const sourceQty=new DOMParser().parseFromString(responseText,"text/html").querySelector("cart-items");this.innerHTML=sourceQty.innerHTML}).catch(e=>{console.error(e)}).finally(()=>{mountCartGwpCarousel(),this.addGiftToCart(),document.dispatchEvent(new CustomEvent("countdown:restart")),document.dispatchEvent(new CustomEvent("mini-countdown:restart")),nostojs(api=>{api.loadRecommendations()})})}getSectionsToRender(){return[{id:"cart__form",section:document.getElementById("cart__form").dataset.id,selector:".cart__form"},{id:"cart-icon-bubble",section:"cart-icon-bubble",selector:".shopify-section"},{id:"cart-live-region-text",section:"cart-live-region-text",selector:".shopify-section"}]}updateQuantity(line,quantity,name,variantId){this.enableLoading(line);const body=JSON.stringify({line,quantity,sections:this.getSectionsToRender().map(section=>section.section),sections_url:window.location.pathname});fetch(`${routes.cart_change_url}`,{...fetchConfig(),body}).then(response=>response.text()).then(state=>{const parsedState=JSON.parse(state),quantityElement=document.getElementById(`Quantity-${line}`)||document.getElementById(`Drawer-quantity-${line}`),items=document.querySelectorAll(".cart-item");if(parsedState.errors){quantityElement.value=quantityElement.getAttribute("value"),this.updateLiveRegions(line,parsedState.errors);return}this.classList.toggle("is-empty",parsedState.item_count===0);const cartDrawerWrapper=document.querySelector("cart-drawer"),cartFooter=document.getElementById("main-cart-footer");cartFooter&&cartFooter.classList.toggle("is-empty",parsedState.item_count===0),cartDrawerWrapper&&cartDrawerWrapper.classList.toggle("is-empty",parsedState.item_count===0),this.get
1SectionsToRender().forEach(section=>{const elementToReplace=document.getElementById(section.id).querySelector(section.selector)||document.getElementById(section.id);elementToReplace.innerHTML=this.getSectionInnerHTML(parsedState.sections[section.section],section.selector)});const updatedValue=parsedState.items[line-1]?parsedState.items[line-1].quantity:void 0;let message="";items.length===parsedState.items.length&&updatedValue!==parseInt(quantityElement.value)&&(typeof updatedValue>"u"?message=window.cartStrings.error:message=window.cartStrings.quantityError.replace("[quantity]",updatedValue)),this.updateLiveRegions(line,message);const lineItem=document.getElementById(`CartItem-${line}`)||document.getElementById(`CartDrawer-Item-${line}`);lineItem&&lineItem.querySelector(`[name="${name}"]`)?cartDrawerWrapper?trapFocus(cartDrawerWrapper,lineItem.querySelector(`[name="${name}"]`)):lineItem.querySelector(`[name="${name}"]`).focus():parsedState.item_count===0&&cartDrawerWrapper?trapFocus(cartDrawerWrapper.querySelector(".drawer__inner-empty"),cartDrawerWrapper.querySelector("a")):document.querySelector(".cart-item")&&cartDrawerWrapper&&trapFocus(cartDrawerWrapper,document.querySelector(".cart-item__name")),publish(PUB_SUB_EVENTS.cartUpdate,{source:"cart-items",cartData:parsedState,variantId})}).catch(()=>{this.querySelectorAll(".loading__spinner").forEach(overlay=>overlay.classList.add("hidden"));const errors=document.getElementById("cart-errors")||document.getElementById("CartDrawer-CartErrors");errors.textContent=window.cartStrings.error}).finally(()=>{this.disableLoading(line),mountCartGwpCarousel(),this.addGiftToCart(),document.dispatchEvent(new CustomEvent("cart:drawer-updated")),document.dispatchEvent(new CustomEvent("countdown:restart")),document.dispatchEvent(new CustomEvent("mini-countdown:restart")),nostojs(api=>{api.loadRecommendations()})})}updateLiveRegions(line,message){const lineItemError=document.getElementById(`Line-item-error-${line}`)||document.getElementById(`CartDrawer-LineItemError-${line}`);lineItemError&&(lineItemError.querySelector(".cart-item__error-text").innerHTML=message),this.lineItemStatusElement.setAttribute("aria-hidden",!0);const cartStatus=document.getElementById("cart-live-region-text")||document.getElementById("CartDrawer-LiveRegionText");cartStatus.setAttribute("aria-hidden",!1),setTimeout(()=>{cartStatus.setAttribute("aria-hidden",!0)},1e3)}getSectionInnerHTML(html,selector){return new DOMParser().parseFromString(html,"text/html").querySelector(selector).innerHTML}enableLoading(line){(document.getElementById("main-cart-items")||document.getElementById("CartDrawer-CartItems")).classList.add("cart__items--disabled");const cartItemElements=this.querySelectorAll(`#CartItem-${line} .loading__spinner`),cartDrawerItemElements=this.querySelectorAll(`#CartDrawer-Item-${line} .loading__spinner`);
1[...cartItemElements,...cartDrawerItemElements].forEach(overlay=>overlay.classList.remove("hidden")),document.activeElement.blur(),this.lineItemStatusElement.setAttribute("aria-hidden",!1)}disableLoading(line){(document.getElementById("main-cart-items")||document.getElementById("CartDrawer-CartItems")).classList.remove("cart__items--disabled");const cartItemElements=this.querySelectorAll(`#CartItem-${line} .loading__spinner`),cartDrawerItemElements=this.querySelectorAll(`#CartDrawer-Item-${line} .loading__spinner`);cartItemElements.forEach(overlay=>overlay.classList.add("hidden")),cartDrawerItemElements.forEach(overlay=>overlay.classList.add("hidden"))}addGiftToCart(){const sections=[{section:"cart-icon-bubble",id:"cart-icon-bubble"}],addVariantToCart=variantId=>{const body=JSON.stringify({id:variantId,quantity:1,sections:sections.map(section=>section.section)});fetch(`${routes.cart_add_url}`,{...fetchConfig(),body}).then(response=>response.json()).then(response=>{publish(PUB_SUB_EVENTS.cartUpdate,{source:"gwp",productVariantId:JSON.stringify(body.id),cartData:response}),response&&response.sections&§ions.forEach(section=>{const sectionElement=section.selector?document.querySelector(section.selector):document.getElementById(section.id);sectionElement.innerHTML=section.selector?this.getSectionInnerHTML(response.sections[section.section],section.selector):response.sections[section.section]})}).catch(error=>{console.error("GWP Add Error:",error)})};document.querySelectorAll(".js-gwp-size-select").forEach(select=>{const next=select.cloneNode(!0);select.replaceWith(next),next.addEventListener("change",e=>{const value=e.target.value;if(value){try{const data=JSON.parse(value);data.id&&addVariantToCart(String(data.id))}catch(error){console.error("GWP Size Select Error:",error)}e.target.selectedIndex=0}})}),document.querySelectorAll(".cart__gwp-size").forEach(sizeBtn=>{const next=sizeBtn.cloneNode(!0);sizeBtn.replaceWith(next),next.addEventListener("click",e=>{if(e.preventDefault(),e.stopPropagation(),next.disabled)return;const card=next.closest(".cart__gwp-card");if(!card)return;card.querySelectorAll(".cart__gwp-size").forEach(btn=>btn.classList.remove("is-selected")),next.classList.add("is-selected");const addBtn=card.querySelector(".add-gift-to-cart");addBtn&&(addBtn.dataset.variantId=next.dataset.variantId,addBtn.disabled=!1,addBtn.classList.remove("disabled"));const label=card.querySelector(".cart__gwp-size-label");label&&next.dataset.size&&(label.textContent="Size: "+next.dataset.size)})}),document.querySelectorAll(".add-gift-to-cart").forEach(btn=>{const next=btn.cloneNode(!0);btn.replaceWith(next),next.addEventListener("click",e=>{if(e.preventDefault(),e.stopPropagation(),next.disabled)return;next.classList.add("loading");const variantId=next.getAttribute("data-variant-id");variantId&&addVariantToCart(variantId)?.finally(()=>{next.classList.remove("loading")})})})}}customElements.define("cart-items",CartItems),customElements.get("cart-note")||customElements.define("cart-note",class extends HTMLElement{constructor(){super(),this.addEventListener("input",debounce(event=>{const body=JSON.stringify({note:event.target.value});fetch(`${routes.cart_update_url}`,{...fetchConfig(),body})},ON_CHANGE_DEBOUNCE_TIMER))}}); 2//# sourceMappingURL=/cdn/shop/t/36/assets/cart.js.map?v=179702597137612493771788332608
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.