1class CartRemoveButton extends HTMLElement{constructor(){super(),this.addEventListener("click",event=>{event.preventDefault();const cartItems=this.closest("cart-items");cartItems.updateQuantity(this.dataset.index,0);const productTitle=this.closest("[data-cart-item]")?.getAttribute("data-cart-product"),message=window.accessibilityStrings.itemRemoved.replace("[item]",productTitle);cartItems.updateLiveRegion(message)})}}customElements.define("cart-remove-button",CartRemoveButton);class CartNote extends HTMLElement{constructor(){super(),this.addEventListener("input",window.utils.debounce(event=>{const config={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"}},body=JSON.stringify({note:event.target.value});fetch(`${routes.cart_update_url}`,{...config,body})},300))}}customElements.define("cart-note",CartNote);class CartItems extends HTMLElement{constructor(){super();const debouncedOnChange=window.utils.debounce(event=>{this.onChange(event)},300);this.addEventListener("change",debouncedOnChange.bind(this))}onChange(event){event.target.name==="updates[]"&&this.validateQuantity(event)}validateQuantity(event){const inputValue=parseInt(event.target.value),index=event.target.dataset.index;this.updateQuantity(index,inputValue,document.activeElement.getAttribute("name"),event.target.dataset.quantityVariantId)}getSectionsToRender(){return[{id:"cart-page-items",section:document.getElementById("cart-page-items")?.dataset.id,selectors:["#Cart"]},{id:"cart-drawer-items",section:document.getElementById("cart-drawer-items")?.dataset.id,selectors:[".cart-drawer__main",".cart-drawer__footer","#cart-drawer-heading"]},{id:"header-menu",section:document.getElementById("header-menu")?.dataset.id,selectors:["[data-cart-count]"]}]}getSectionInnerHTML(html,selector){return new DOMParser().parseFromString(html,"text/html").querySelector(selector)?.innerHTML}getElementClasslist(html,selector){return new DOMParser().parseFromString(html,"text/html").querySelector(selector)?.classList}renderContents(parsedState){this.renderSections(parsedState),setTimeout(()=>{const event=new CustomEvent("dialog:trigger:cart-drawer");document.dispatchEvent(event)})}renderSections(parsedState){this.getSectionsToRender().forEach(section=>{const targetSection=document.getElementById(section.id);if(!targetSection)return;let sectionObj=parsedState;parsedState.sections&&(sectionObj=parsedState.sections);for(const selector of section.selectors){const sourceElements=targetSection.querySelectorAll(selector);for(const element of sourceElements){const html=this.getSectionInnerHTML(sectionObj[section.section],selector),classList=this.getElementClasslist(sectionObj[section.section],selector);html&&(element.innerHTML=html),classList&&(element.classList=classList)}}})}updateQuantity(line,quantity,name,variantId){this.enableLoading(line);const productTitle=this.querySelector(`[data-cart-item="${line}"]`)?.getAttribute("data-cart-product"),body=JSON.stringify({line,quantity,sections:this.getSectionsToRender().map(section=>section.section),sections_url:window.location.pathname}),config={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"}};fetch(`${routes.cart_change_url}`,{...config,body}).then(response=>response.json()).then(parsedState=>{const quantityElement=this.querySelector(`[data-cart-line-item-quantity="${line}"]`),quantityValue=quantityElement.getAttribute("value");if(parsedState.errors){quantityElement.value=quantityValue,this.handleErrors(parsedState,variantId),this.refreshCart();return}this.renderSections(parsedState);const lineItem2=this.querySelector(`[data-cart-item="${line}"]`),lineItemActiveButton=lineItem2?.querySelector(`[name="${name}"]`);if(lineItem2&&lineItemActiveButton)lineItemActiveButton.focus({preventScroll:!0});else{const firstLineItemName=this.querySelector(".cart-item__title");firstLineItemName&&firstLineItemName.focus({preventScroll:!0})}let message;quantity>0?message=window.accessibilityStrings.itemQuantityUpdated.replace("[item]",productTitle).replace("[quantity]",quantity):message=window.accessibilityStrings.itemRemoved.replace("[item]",productTitle),this.updateLiveRegion(message);const event=new CustomEvent("cart:update",{detail:{source:this.id,cartData:parsedState,variantId}});document.dispatchEvent(event)}).catch(error=>{this.querySelectorAll(".loading__spinner").forEach(overlay=>overlay.classList.add("hidden"));const event=new CustomEvent("cart:error",{detail:{source:"cart",productVariantId:variantId,message:window.cartStrings.error}});document.dispatchEvent(event)}).finally(()=>{this.disableLoading(line)})}refreshCart(){const sectionString=this.getSectionsToRender().map(section=>section.section).filter(el=>el).join(","),params=new URLSearchParams(window.location.search);return params.append("sections",sectionString),fetch(`${window.location.origin}${window.location.pathname}?${params.toString()}`).then(response=>response.json()).then(state=>this.renderSections(state)).catch(err=>{err&&console.log(err);const event=new CustomEvent("rendering:error");document.dispatchEvent(event)})}updateLiveRegion(message){const localLiveRegion=this.querySelector("[data-live-region]");localLiveRegion?localLiveRegion.innerHTML=message:window.utils.announce(message)}handleErrors(response,variantId){const event=new CustomEvent("cart:error",{detail:{source:"cart",productVariantId:variantId,errors:response.errors,message:response.description||response.message||response.errors}});document.dispatchEvent(event)}enableLoading(line){this.querySelector(".cart__items").classList.add("cart__items--disabled"),[...this.querySelectorAll(`[data-cart-item="${line}
1"] .loading__spinner`)].forEach(overlay=>overlay.classList.remove("hidden"))}disableLoading(line){this.querySelector(".cart__items").classList.remove("cart__items--disabled"),this.querySelectorAll(`[data-cart-item="${line}"] .loading__spinner`).forEach(overlay=>overlay.classList.add("hidden"))}}customElements.define("cart-items",CartItems);class CartStickyObserver extends HTMLElement{constructor(){super(),this.calculateHeight(),this.observer=new ResizeObserver(entries=>{this.calculateHeight()}),this.observer.observe(this)}calculateHeight(){window.matchMedia("(min-width:64em)").matches&&(this.footer=this.querySelector("[data-cart-footer]"),this.clientHeight>=this.footer.scrollHeight?this.footer.classList.add("cart-drawer__footer--sticky"):this.footer.classList.remove("cart-drawer__footer--sticky"))}}customElements.define("cart-sticky-observer",CartStickyObserver); 2//# sourceMappingURL=/cdn/shop/t/16/assets/cart.js.map?v=11602353433573915451755644400
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.