1(async()=>{const{updateURLParams,historyPush,parseHTML}=await import(window.theme.modules.utils),baseComponent=await import(window.theme.modules.baseComponent);customElements.define("product-form",class extends baseComponent.default{elements={form:"form",addButton:"[data-add-button]",buyButton:"[data-buy-button]",soldOutButton:"[data-sold-out-button]",content:"[data-content]",input:"[data-variant-id-input]",sellingPlanInput:'input[name="selling_plan"]'};async render(){if(this._enableInput(),this.cartSection=document.querySelector("main-cart"),this.isProductPage=this.getAttribute("page-type")==="product",this.listenTo("variantChange",(e,data)=>{this._rerender(data),data.variant&&this._rerenderVariantInput(data)}),this.on("cartChange",(e,data)=>{this._updateQtyStatus(data.variantId)},!1),this.hasAttribute("cart-popup")&&this.$form.addEventListener("submit",this._handleSubmit.bind(this)),this.$sellingPlanInput&&this.hasAttribute("selling-plan-enable")){this.currentSellingPlanId=this.querySelector('input[name="selling_plan"]').value;const{observeInputValueChange}=await import(window.theme.modules.sellingPlanUtil);observeInputValueChange(this.$sellingPlanInput,this._handleSellingPlanChange.bind(this))}}_handleSellingPlanChange(newSellingPlanId){if(newSellingPlanId===this.currentSellingPlanId)return;this.currentSellingPlanId=newSellingPlanId;const{queryURL,currentURL}=updateURLParams({selling_plan:this.currentSellingPlanId,variant:this.getAttribute("current-variant")},this.sectionId);this.isProductPage&&historyPush(currentURL),this._fetchPageWithVariant(queryURL,html=>{this.forwardEvent("sellingPlanChange",{html})})}_enableInput(){this.$input.disabled=!1}_fetchPageWithVariant(url,onResponse){return fetch(url).then(response=>response.text()).then(responseText=>{const html=parseHTML(responseText);onResponse(html)})}_rerender(data){const isHiddenAddBtn=data.html.querySelector("[data-add-button]").hasAttribute("hidden"),isHiddenSoldOutBtn=data.html.querySelector("[data-sold-out-button]").hasAttribute("hidden");this.$addButton.toggleAttribute("hidden",isHiddenAddBtn),this.$buyButton&&this.$buyButton.toggleAttribute("hidden",isHiddenAddBtn),this.$soldOutButton.toggleAttribute("hidden",isHiddenSoldOutBtn)}_rerenderVariantInput(data){this.setAttribute("current-variant",`${data.variant.id}`);const value=data.html.querySelector(this.elements.input).value;this.$input.value=value}_handleSubmit(e){e.preventDefault(),this.formData=new FormData(e.target),this._addToCartRequest()}_addToCartRequest(){this._setLoading(!0),fetch(`${window.routes.cart_add_url}.js`,{method:"POST",headers:{Accept:"application/javascript"},body:this.formData}).then(res=>res.json()).then(()=>{this.trigger("updateCart",{callback:()=>{this._setLoading(!1),this._updateQtyStatus(this.formData.get("id")),this.cartSection?this.cartSection.update():this.trigger("openPopup",{target:"CART"})}})}).catch(error=>{this._setLoading(!1),console.log(error)})}_updateQtyStatus(variantId){const url=`${this.getAttribute("product-url")}?variant=${variantId}§ion_id=${this.getAttribute("section-id")}`;this._fetchPageWithVariant(url,html=>{this.trigger("qtyStatusUpdate",{html,variantId}),this._rerender({html})})}_setLoading(status){status?this.$addButton.setAttribute("loading",""):this.$addButton.removeAttribute("loading")}})})(); 2//# sourceMappingURL=/cdn/shop/t/99/assets/product-form.js.map?v=29524374975839005961762321204
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.