1class MCartRemoveButton extends HTMLElement{constructor(){super(),this.addEventListener("click",event=>{event.preventDefault(),(this.closest("m-cart")||this.closest("m-cart-drawer-items")).updateQuantity(this.dataset.index,0)})}}customElements.define("m-cart-remove-button",MCartRemoveButton);class MCartTemplate extends HTMLElement{constructor(){super(),this.cartUpdateUnsubscriber=void 0,this.isCartPage=MinimogSettings.templateName==="cart",this.cartDrawerWrapper=document.querySelector("m-cart-drawer"),this.cartDrawerInner=document.querySelector(".m-cart-drawer__inner"),this.mainCartItems=this.querySelector("[data-minimog-cart-items]"),this.cartSubTotal=this.querySelector("[data-cart-subtotal]"),this.cartDiscount=this.querySelector("[data-minimog-cart-discounts]"),this.giftWrapping=this.querySelector("[data-minimog-gift-wrapping]");let loadingTarget=this.cartDrawerInner;this.isCartPage&&(loadingTarget=document.body),this.loading=new MinimogLibs.AnimateLoading(loadingTarget,{overlay:loadingTarget}),this.rootUrl=window.Shopify.routes.root;const debouncedOnChange=debounce(event=>{event.target.name!=="id"&&this.onChange(event)},300);this.isCartPage?this.mainCartItems.addEventListener("change",debouncedOnChange.bind(this)):this.addEventListener("change",debouncedOnChange.bind(this)),MinimogEvents.subscribe(MinimogTheme.pubSubEvents.cartUpdate,response=>{this.getCart().then(cart=>{this.updateCartCount(cart.item_count)})})}updateCartCount(itemCount){document.querySelectorAll(".m-cart-count-bubble").forEach(cartCount=>{itemCount>0?(cartCount.textContent=itemCount,cartCount.classList.remove("m:hidden")):cartCount.classList.add("m:hidden")})}getCart(){return fetchJSON(this.rootUrl+"cart.json")}connectedCallback(){this.cartUpdateUnsubscriber=MinimogEvents.subscribe(MinimogTheme.pubSubEvents.cartUpdate,event=>{event.source!=="main-cart-items"&&this.onCartUpdate()})}disconnectedCallback(){this.cartUpdateUnsubscriber&&this.cartUpdateUnsubscriber()}onCartUpdate(renderFooter=!0){const{routes}=window.MinimogSettings;fetch(`${routes.cart}?section_id=cart-template`).then(response=>response.text()).then(responseText=>{const html=new DOMParser().parseFromString(responseText,"text/html"),cartItems=html.querySelector("[data-minimog-cart-items]"),cartSubTotal=html.querySelector("[data-cart-subtotal]"),cartDiscount=html.querySelector("[data-minimog-cart-discounts]"),giftWrapping=html.querySelector("[data-minimog-gift-wrapping]");this.isCartPage&&(this.mainCartItems.innerHTML=cartItems.innerHTML,renderFooter&&(this.cartSubTotal.innerHTML=cartSubTotal.innerHTML,this.cartDiscount.innerHTML=cartDiscount.innerHTML,this.giftWrapping.innerHTML=giftWrapping.innerHTML))}).catch(e=>{console.error(e)})}onChange(event){this.updateQuantity(event.target.dataset.index,event.target.value,document.activeElement.getAttribute("name"))}updateQuantity(line,quantity,name){this.loading.start();const{routes}=window.MinimogSettings,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);let quantityElement=document.getElementById(`MinimogDrawer-quantity-${line}`);this.isCartPage&&(MinimogTheme.config.mqlMobile?quantityElement=document.querySelector(`.MinimogQuantity-${line}.MinimogQuantity-mobile`):quantityElement=document.querySelector(`.MinimogQuantity-${line}.MinimogQuantity-desktop`));const items=document.querySelectorAll(".m-cart-item");if(parsedState.errors){this.loading.finish(),quantityElement.value=quantityElement.getAttribute("value"),this.updateLiveRegions(line,parsedState.errors);return}this.classList.toggle("m-cart--empty",parsedState.item_count===0),this.cartDrawerWrapper&&this.cartDrawerWrapper.classList.toggle("m-cart--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.MinimogStrings.cartError:message=window.MinimogStrings.quantityError.replace("{{ quantity }}",updatedValue)),this.updateLiveRegions(line,message),MinimogEvents.emit(MinimogTheme.pubSubEvents.cartUpdate,{...parsedState,source:"main-cart-items"})}).catch(()=>{}).finally(()=>{this.loading.finish()})}updateLiveRegions(line,message){let lineItemNode=document.getElementById(`MinimogCartDrawer-Item-${line}`);this.isCartPage&&(lineItemNode=document.getElementById(`MinimogCart-Item-${line}`)),message!==""&&lineItemNode&&MinimogTheme.Notification.show({target:lineItemNode,type:"warning",message})}getSectionInnerHTML(html,selector){return new DOMParser().parseFromString(html,"text/html").querySelector(selector).innerHTML}getSectionsToRender(){return[{id:"MinimogCart",section:"cart-template",selector:"[data-minimog-cart-items]"},{id:"MinimogCart",section:"cart-template",selector:"[data-cart-subtotal]"},{id:"MinimogCart",section:"cart-template",selector:"[data-minimog-cart-discounts]"},{id:"MinimogCart",section:"cart-template",selector:"[data-minimog-gift-wrapping]"}]}}customElements.define("m-cart",MCartTemplate); 2//# sourceMappingURL=/cdn/shop/t/49/assets/cart.js.map?v=161350708433824915711721400542
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.