1const fetchConfig={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"}};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.cart=null,this.lineItemStatusElement=document.getElementById("shopping-cart-line-item-status")||document.getElementById("CartDrawer-LineItemStatus");const debouncedOnChange=debounce(event=>{this.onChange(event)},300);this.initLoading(),this.addEventListener("change",debouncedOnChange.bind(this))}cartUpdateUnsubscriber=void 0;connectedCallback(){this.cartUpdateUnsubscriber=window.FoxThemeEvents.subscribe("ON_ITEM_ADDED",async parsedState=>{window.FoxThemeSettings.template==="cart"&&this.renderContents(parsedState);const cart=await FoxThemeCartHelpers.getState();cart&&(this.cart=cart,FoxThemeCartHelpers.updateCartCount(cart.item_count))}),window.FoxThemeEvents.subscribe("ON_CART_UPDATED",cart=>{this.cart=cart,FoxThemeCartHelpers.updateCartCount(cart.item_count),this.classList.toggle("is-empty",cart.item_count===0)})}disconnectedCallback(){this.cartUpdateUnsubscriber&&this.cartUpdateUnsubscriber()}initLoading(){this.loading=new window.FoxTheme.AnimateLoading(document.body,{overlay:this.querySelector(".f-cart__items")})}onChange(event){event.target.getAttribute("name")==="updates[]"&&this.updateQuantity(event.target.dataset.index,event.target.value,document.activeElement.getAttribute("name"))}getSectionsToRender(){return[{id:"main-cart-items",section:document.getElementById("main-cart-items").dataset.id,selector:".js-contents"},{id:"cart-live-region-text",section:"cart-live-region-text",selector:".shopify-section"},{id:"main-cart-footer",section:document.getElementById("main-cart-footer").dataset.id,selector:".js-contents"}]}updateQuantity(line,quantity,name){this.enableLoading();const body=JSON.stringify({line,quantity,sections:this.getSectionsToRender().map(section=>section.section),sections_url:window.location.pathname});fetch(`${FoxThemeSettings.routes.cart_change_url}`,{...fetchConfig,body}).then(response=>response.text()).then(state=>{const parsedState=JSON.parse(state),quantityElement=this.querySelector(`#CartItem-${line}, #CartDrawer-Item-${line}`).querySelector('[name="updates[]"]'),items=document.querySelectorAll(".f-cart-item");if(parsedState.errors){quantityElement.value=quantityElement.getAttribute("value"),this.updateLiveRegions(line,parsedState.errors);return}const cartDrawer=document.querySelector("cart-drawer");this.classList.toggle("is-empty",parsedState.item_count===0);const cartFooter=document.getElementById("main-cart-footer");cartFooter&&cartFooter.classList.toggle("is-empty",parsedState.item_count===0),cartDrawer&&cartDrawer.classList.toggle("is-empty",parsedState.item_count===0),this.renderContents(parsedState);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.FoxThemeStrings.cartError:message=window.FoxThemeStrings.quantityError.replace("[quantity]",updatedValue)),this.updateLiveRegions(line,message);const lineItem=document.getElementById(`CartItem-${line}`)||document.getElementById(`CartDrawer-Item-${line}`);lineItem&&lineItem.querySelector(`[name="${name}"]`)?cartDrawer?trapFocus(cartDrawer,lineItem.querySelector(`[name="${name}"]`)):lineItem.querySelector(`[name="${name}"]`).focus():parsedState.item_count===0&&cartDrawer||document.querySelector(".f-cart-item")&&cartDrawer&&trapFocus(cartDrawer,document.querySelector(".f-cart-item__name")),window.FoxThemeEvents.emit("ON_CART_UPDATED",parsedState)}).catch(()=>{const errors=document.querySelector("#cart-errors, #CartDrawer-CartErrors");errors&&(errors.textContent=window.FoxThemeStrings.cartError)}).finally(()=>{this.loading.finish()})}
1renderContents(parsedState){this.getSectionsToRender().forEach(section=>{const elementToReplace=document.getElementById(section.id).querySelector(section.selector)||document.getElementById(section.id);elementToReplace&&(elementToReplace.innerHTML=this.getSectionInnerHTML(parsedState.sections[section.section],section.selector))})}updateLiveRegions(line,message){if(!message)return;const lineItemError=this.querySelector(`#CartItem-${line}, #CartDrawer-Item-${line}`);window.FoxTheme.Notification.show({target:lineItemError.querySelector(".f-cart-item__quantity, .f-cart-drawer__error"),method:"appendChild",type:"warning",message,last:5e3}),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){const domParser=new DOMParser().parseFromString(html,"text/html");return console.log(domParser,selector,"domParser"),domParser.querySelector(selector)?domParser.querySelector(selector).innerHTML:""}enableLoading(){this.loading.start(),document.activeElement.blur(),this.lineItemStatusElement.setAttribute("aria-hidden",!1)}}customElements.define("cart-items",CartItems); 2//# sourceMappingURL=/cdn/shop/t/13/assets/cart.js.map?v=121781415031164501691715769707
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.