1if(!customElements.get("theme-cart")){class ThemeCart extends HTMLElement{constructor(){super()}connectedCallback(){this.setupEventListeners()}onFormChange(event){this.updateQuantity(event.target.dataset.index,event.target.value)}onNotesChange(){this.saveNotes()}saveNotes(){fetch(`${theme.routes.cart_update_url}.js`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({note:this.notes.value})})}setupEventListeners(){this.form=this.querySelector("#cart-form"),this.notes=this.querySelector("#CartSpecialInstructions"),this.removeProductEvent(),this.debouncedOnFormChange=debounce(event=>{this.onFormChange(event)},300),document.addEventListener("cart:refresh",event=>{this.refresh()}),this.notes?.addEventListener("change",this.onNotesChange.bind(this)),this.form?.addEventListener("change",this.debouncedOnFormChange.bind(this))}getSectionsToRender(){return[{id:"Cart",section:"main-cart",selector:".thb-cart-form"},{id:"Cart",section:"main-cart",selector:".thb-cart-form--count"},{id:"cart-drawer-toggle",section:"cart-bubble",selector:".thb-secondary-area--item-count"}]}displayErrors(line2,message){const lineItemError=document.getElementById(`Line-item-error-${line2}`)||document.getElementById(`CartDrawer-LineItemError-${line2}`);lineItemError&&(lineItemError.removeAttribute("hidden"),lineItemError.querySelector(".cart-item__error-text").innerHTML=message,this.form.querySelector(`#CartItem-${line2}`).classList.remove("loading"),this.setupEventListeners())}getSectionInnerHTML(html,selector){return new DOMParser().parseFromString(html,"text/html").querySelector(selector).innerHTML}updateQuantity(line2,quantity){this.form.classList.add("cart-disabled"),line2&&this.form.querySelector(`#CartItem-${line2}`).classList.add("loading");const body=JSON.stringify({line:line2,quantity,sections:this.getSectionsToRender().map(section=>section.section),sections_url:window.location.pathname});dispatchCustomEvent("line-item:change:start",{quantity}),fetch(`${theme.routes.cart_change_url}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body}).then(response=>response.text()).then(state=>{const parsedState=JSON.parse(state);if(parsedState.errors){this.displayErrors(line2,parsedState.errors),this.form.classList.remove("cart-disabled");return}this.renderContents(parsedState,line2,!1),this.form.classList.remove("cart-disabled"),dispatchCustomEvent("line-item:change:end",{quantity,cart:parsedState})})}refresh(){this.form.classList.add("cart-disabled"),fetch(`${window.location.pathname}/?sections=main-cart`).then(response=>response.text()).then(state=>{const parsedState=JSON.parse(state);if(parsedState.errors){this.displayErrors(line,parsedState.errors),this.form?.classList.remove("cart-disabled");return}this.renderContents(parsedState,!1,!0),this.form?.classList.remove("cart-disabled")})}removeProductEvent(){this.querySelectorAll(".remove").forEach(remove=>{remove.addEventListener("click",event=>{this.updateQuantity(event.target.dataset.index,"0"),event.preventDefault()})})}renderContents(parsedState,line2,refresh){this.getSectionsToRender().forEach((section=>{const elementToReplace=document.getElementById(section.id).querySelector(section.selector)||document.getElementById(section.id);refresh?parsedState[section.section]&&(elementToReplace.innerHTML=this.getSectionInnerHTML(parsedState[section.section],section.selector)):elementToReplace.innerHTML=this.getSectionInnerHTML(parsedState.sections[section.section],section.selector),this.removeProductEvent(),this.setupEventListeners(),line2&&this.form?.querySelector(`#CartItem-${line2}`)&&this.form.querySelector(`#CartItem-${line2}`).classList.remove("loading")}))}}customElements.define("theme-cart",ThemeCart)} 2//# sourceMappingURL=/cdn/shop/t/12/assets/cart.js.map?v=92537870821263415171783411002
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.