1class CartDrawerRemoveButton extends HTMLElement{constructor(){super(),this.addEventListener("click",event=>{event.preventDefault(),this.closest("cart-drawer").updateQuantity(this.dataset.index,0)})}}customElements.define("cart-drawer-remove-button",CartDrawerRemoveButton);class CartDrawer extends HTMLElement{constructor(){super(),this.drawer=document.getElementById("cart-drawer"),this.cartButton=document.querySelector(".js-open-cart"),this.cartButton.addEventListener("click",this.handleCartClick.bind(this)),this.closeIcon=document.getElementById("cart-drawer__close"),this.closeIcon.addEventListener("click",this.close.bind(this)),this.addEventListener("click",event=>{event.target.classList.contains("checkout")&&this.handleCheckout(event)}),this.onBodyClick=this.handleBodyClick.bind(this),this.drawer.addEventListener("keyup",evt=>evt.code==="Escape"&&this.close()),this.pageOverlayElement=document.querySelector(".page-overlay"),this.debouncedOnChange=debounce(event=>{this.onChange(event)},300),this.addEventListener("change",this.debouncedOnChange.bind(this))}open(){this.drawer.setAttribute("aria-hidden",!1),this.drawer.setAttribute("aria-expanded",!0),this.pageOverlayElement.classList.remove("invisible","opacity-0"),document.body.addEventListener("click",this.onBodyClick),document.body.classList.add("overflow-hidden")}close(){this.drawer.setAttribute("aria-hidden",!0),this.drawer.removeAttribute("aria-expanded",!0),this.pageOverlayElement.classList.add("invisible","opacity-0"),document.body.removeEventListener("click",this.onBodyClick),document.body.classList.remove("overflow-hidden")}onChange(event){event.target.id!="agree"&&this.updateQuantity(event.target.dataset.index,event.target.value,document.activeElement.getAttribute("name"))}updateQuantity(line,quantity,name){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);this.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)})),this.disableLoading()}).catch(()=>{this.disableLoading()})}rerender(open){this.enableLoading();const body=JSON.stringify({sections:this.getSectionsToRender().map(section=>section.section),sections_url:window.location.pathname});fetch(`${routes.cart_update_url}`,{...fetchConfig(),body}).then(response=>response.text()).then(state=>{const parsedState=JSON.parse(state);this.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)})),this.updateValues(parsedState),this.disableLoading()}).catch(()=>{this.disableLoading()}).finally(()=>{open&&this.open()})}getSectionsToRender(){return[{id:"cart-drawer__content",section:document.getElementById("cart-drawer__content").dataset.id,selector:"#cart-drawer__content"},{id:"cart-icon-bubble",section:"header",selector:"#cart-icon-bubble"},{id:"cart-count",section:document.getElementById("cart-drawer__content").dataset.id,selector:"#cart-count"}]}getSectionInnerHTML(html,selector){return new DOMParser().parseFromString(html,"text/html").querySelector(selector).innerHTML}enableLoading(){}disableLoading(){}handleBodyClick(event){event.target.classList.contains("page-overlay")&&(this.close(),this.pageOverlayElement.classList.remove("is-visible"))}handleCartClick(event){event.preventDefault(),this.open()}handleCheckout(event){this.querySelector("#agree").checked?window.location.href="/checkout":(event.preventDefault(),window.alert("Please agree to the terms and conditions before making a purchase!"))}}customElements.define("cart-drawer",CartDrawer); 2//# sourceMappingURL=/cdn/shop/t/101/assets/cart-drawer.js.map?v=43974742630223853361755458473
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.