1class CartRemoveButton extends HTMLElement{constructor(){super(),this.addEventListener("click",event=>{event.preventDefault();const cartItems=this.closest("cart-items");if(this.bundleId=this.dataset.bundleId,this.bundleId){const itemsToRemove=Array.from(cartItems.querySelectorAll(`.cart-item[data-bundle-id="${this.bundleId}"]`));itemsToRemove.length>0&&cartItems.removeBulkItems(itemsToRemove.map(item=>item.dataset.key),itemsToRemove[0].querySelector(".loading__spinner"))}else cartItems.updateQuantity(this.dataset.index,0)})}}customElements.define("cart-remove-button",CartRemoveButton);class CartItems extends HTMLElement{constructor(){super();const debouncedOnChange=debounce(event=>{this.onChange(event)},ON_CHANGE_DEBOUNCE_TIMER);this.addEventListener("change",debouncedOnChange.bind(this))}cartUpdateUnsubscriber=void 0;connectedCallback(){this.cartUpdateUnsubscriber=subscribe(PUB_SUB_EVENTS.cartUpdate,event=>{event.source!=="cart-items"&&this.onCartUpdate()});const itemsToRemove=this.querySelectorAll(".cart-item--remove");itemsToRemove.length>0&&setTimeout(()=>{this.removeBulkItems(Array.from(itemsToRemove).map(item=>item.dataset.key))},250)}disconnectedCallback(){this.cartUpdateUnsubscriber&&this.cartUpdateUnsubscriber()}resetQuantityInput(id){const input=this.querySelector(`#Quantity-${id}`);input.value=input.getAttribute("value"),this.isEnterPressed=!1}setValidity(event,index,message){event.target.setCustomValidity(message),event.target.reportValidity(),this.resetQuantityInput(index),event.target.select()}validateQuantity(event){const inputValue=parseInt(event.target.value),index=event.target.dataset.index;let message="";inputValue<event.target.dataset.min?message=window.quickOrderListStrings.min_error.replace("[min]",event.target.dataset.min):inputValue>parseInt(event.target.max)?message=window.quickOrderListStrings.max_error.replace("[max]",event.target.max):inputValue%parseInt(event.target.step)!==0&&(message=window.quickOrderListStrings.step_error.replace("[step]",event.target.step)),message?this.setValidity(event,index,message):(event.target.setCustomValidity(""),event.target.reportValidity(),this.updateQuantity(index,inputValue,document.activeElement.getAttribute("name"),event.target.dataset.quantityVariantId))}onChange(event){this.validateQuantity(event)}onCartUpdate(){fetch(`${routes.cart_url}?section_id=up-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)})}getSectionsToRender(){return[{id:"main-cart-items",section:document.getElementById("main-cart-items").dataset.id,selector:".js-contents"},{id:"cart-icon-bubble",section:"cart-icon-bubble",selector:".shopify-section"},{id:"up-main-cart-empty",section:document.getElementById("up-main-cart-empty").dataset.id,selector:".up-cart-empty"}]}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}`),items=document.querySelectorAll(".cart-item");if(parsedState.errors){quantityElement.value=quantityElement.getAttribute("value"),this.updateLiveRegions(line,parsedState.errors);return}this.getSectionsToRender().forEach((section,index)=>{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}`);lineItem&&lineItem.querySelector(`[name="${name}"]`)&&lineItem.querySelector(`[name="${name}"]`).focus(),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");errors.textContent=window.cartStrings.error}).finally(()=>{this.disableLoading(line)})}removeBulkItems(keys,loadingSpinner){const items={};keys.forEach(key=>{items[key]=0});const body=JSON.stringify({updates:items,sections:this.getSectionsToRender().map(section=>section.section),sections_url:window.location.pathname});loadingSpinner&&loadingSpinner.classList.remove("hidden"),fetch(`${routes.cart_update_url}`,{...fetchConfig(),body}).then(response=>response.text()).then(state=>{const parsedState=JSON.parse(state);if(parsedState.errors){console.log(parsedState.errors);return}
1this.getSectionsToRender().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)})}).catch(e=>{console.log(e)}).finally(()=>{loadingSpinner&&loadingSpinner.classList.add("hidden")})}updateLiveRegions(line,message){const lineItemError=document.getElementById(`Line-item-error-${line}`);lineItemError&&(lineItemError.querySelector(".cart-item__error-text").innerHTML=message)}getSectionInnerHTML(html,selector){return new DOMParser().parseFromString(html,"text/html").querySelector(selector).innerHTML}enableLoading(line){document.getElementById("main-cart-items").classList.add("cart__items--disabled"),this.querySelectorAll(`#CartItem-${line} .loading__spinner`).forEach(overlay=>overlay.classList.remove("hidden")),document.activeElement.blur()}disableLoading(line){document.getElementById("main-cart-items").classList.remove("cart__items--disabled"),this.querySelectorAll(`#CartItem-${line} .loading__spinner`).forEach(overlay=>overlay.classList.add("hidden"))}}customElements.define("cart-items",CartItems); 2//# sourceMappingURL=/cdn/shop/t/51/assets/up-cart.js.map?v=106183552753645692841765533601
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.