1import*as NextSkyTheme from"@NextSkyTheme/global";import{ProductForm}from"@NextSkyTheme/add-to-cart";import{LazyLoadEventHover,LazyLoader}from"@NextSkyTheme/lazy-load";import{notifier}from"@NextSkyTheme/notification";import{eventModal}from"@NextSkyTheme/modal";LazyLoadEventHover.run();class MainCartEdit extends HTMLElement{constructor(){super(),this.init(),this.key=this.getAttribute("data-key"),this.quantity=this.getAttribute("data-quantity"),this.index=this.getAttribute("data-index");const href=this.getAttribute("data-href"),urlLocal=window.shopUrl,variant=href.indexOf("?")>-1||href.indexOf("?variant=")>-1||href.indexOf("&variant=")>-1?"&":"/?";this.url=urlLocal+href+variant+"section_id=main-cart-edit"}init(){this.addEventListener("click",e=>this.onClick(e)),this.addEventListener("keyup",e=>{e.key==="Enter"&&this.onClick(e)})}onClick(e){this.addLoading(!0),e.preventDefault(),fetch(this.url).then(response=>{if(!response.ok){var error=new Error(response.status);throw error}return response.text()}).then(response=>{const modal=NextSkyTheme.parser.parseFromString(response,"text/html").getElementById("shopify-section-main-cart-edit")?.querySelector("main-cart-edit-popup");modal&&(document.querySelectorAll("main-cart-edit-popup").forEach(el=>{el.remove()}),NextSkyTheme.getBody().appendChild(modal),new LazyLoader(".image-lazy-load"),setTimeout(()=>eventModal(document.querySelector("main-cart-edit-popup"),"open",!0),100),NextSkyTheme.global.rootToFocus=this)}).catch(error=>{console.error(error)}).finally(()=>{this.addLoading(!1);const modal=document.querySelector("main-cart-edit-popup");if(!modal)return;const quantity=modal.querySelector('quantity-input [name="quantity"]'),elementTotalPrice=modal.querySelector(".total-price__detail");if(!quantity||!elementTotalPrice)return;quantity.value=this.quantity;const dataTotalPrice=elementTotalPrice.getAttribute("data-total-price"),totalPrice=NextSkyTheme.formatMoney(dataTotalPrice*this.quantity,cartStrings.money_format);elementTotalPrice.textContent=totalPrice,modal.setAttribute("data-key",this.key),modal.setAttribute("data-index",this.index)})}addLoading(action=!1){action?this.classList.add("loading"):this.classList.remove("loading")}}customElements.define("main-cart-edit",MainCartEdit),customElements.get("product-form-edit-cart")||customElements.define("product-form-edit-cart",class extends ProductForm{constructor(){super(),this.form=this.querySelector("form"),this.cart=document.querySelector("main-cart"),this.form&&(this.form.querySelector("[name=id]")&&(this.form.querySelector("[name=id]").disabled=!1),this.form.addEventListener("submit",this.onSubmitHandler.bind(this)),this.submitButton=this.querySelector('[type="submit"]'),this.cart&&this.submitButton&&this.submitButton.setAttribute("aria-haspopup","dialog"),this.hideErrors=this.dataset.hideErrors==="true"),this.modal=document.querySelector("main-cart-edit-popup")}get cartKey(){return this.modal?.getAttribute("data-key")}get cartIndex(){return this.modal?.getAttribute("data-index")}get sectionId(){return this.cart.getAttribute("data-section-id")}resetSubmitButton(){this.submitButton&&(this.submitButton.classList.remove("loading"),this.submitButton.removeAttribute("aria-disabled"))}onSubmitHandler(event){if(event.preventDefault(),!this.submitButton||this.submitButton.getAttribute("aria-disabled")==="true")return;this.submitButton.setAttribute("aria-disabled",!0),this.submitButton.classList.add("loading");const config=NextSkyTheme.fetchConfig(),id=this.cartKey;if(!id){this.resetSubmitButton();return}config.body=JSON.stringify({id,quantity:0}),fetch(`${routes?.cart_change_url}`,config).then(response=>response.text()).then(state=>{let parsed;try{parsed=JSON.parse(state)}catch{throw new Error(window.cartStrings?.error||"Cart update failed")}if(parsed.errors||parsed.status)throw new Error(parsed.errors||parsed.description||window.cartStrings?.error||"Cart update failed");return this.addNewCart()}).catch(e=>{console.error(e),notifier.show(typeof e?.message=="string"?e.message:window.cartStrings?.error||"Error","error",3e3),this.resetSubmitButton()})}addNewCart(){this.addLoading(this.cartIndex,!0);const config=NextSkyTheme.fetchConfig("javascript");config.headers["X-Requested-With"]="XMLHttpRequest",delete config.headers["Content-Type"];const formData=new FormData(this.form);
1return this.cart&&(formData.append("sections",this.getSectionsToRender().map(section=>section.id)),formData.append("sections_url",window.location.pathname),NextSkyTheme.global.rootToFocus=this.submitButton),config.body=formData,fetch(`${routes.cart_add_url}`,config).then(response=>response.json()).then(response=>{if(response.status){NextSkyTheme.publish(NextSkyTheme.PUB_SUB_EVENTS.cartError,{source:"product-form",productVariantId:formData.get("id"),errors:response.errors||response.description,message:response.message}),this.querySelector(".product-form__error-message-wrapper")?this.handleErrorMessage(response.description):notifier.show(response.description,"error",4e3);return}this.updateMainCart(response),this.modal&&eventModal(document.querySelector("main-cart-edit-popup"),"close",!0),notifier.showElement(window.cartStrings.updateCartSuccess,null,"success",2500)}).catch(e=>{console.error(e),notifier.show(window.cartStrings?.error||"Error","error",3e3)}).finally(()=>{this.addLoading(this.cartIndex,!1),new NextSkyTheme.FSProgressBar("free-ship-progress-bar"),this.resetSubmitButton()})}handleErrorMessage(errorMessage=!1){this.hideErrors||(this.errorMessageWrapper=this.errorMessageWrapper||this.querySelector(".product-form__error-message-wrapper"),this.errorMessageWrapper&&(this.errorMessage=this.errorMessage||this.errorMessageWrapper.querySelector(".product-form__error-message"),this.errorMessageWrapper.toggleAttribute("hidden",!errorMessage),errorMessage&&(this.errorMessage.textContent=errorMessage)))}getSectionsToRender(){return[{id:this.sectionId,section:this.sectionId,selector:".main-cart-items"},{id:"cart-icon-bubble",section:"cart-icon-bubble"},{id:this.sectionId,section:this.sectionId,selector:".free-shipping-bar"},{id:this.sectionId,section:this.sectionId,selector:".cart-info .totals"},{id:this.sectionId,section:this.sectionId,selector:".cart-recommendations"}]}}); 2//# sourceMappingURL=/cdn/shop/t/18/assets/cart-page.js.map?v=150805733045015721101785762045
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.