1window.Eurus.loadedScript.has("product-cart.js")||(window.Eurus.loadedScript.add("product-cart.js"),requestAnimationFrame(()=>{document.addEventListener("alpine:init",()=>{Alpine.data("xProductCart",(wrappringVariantId,engravingVariantId)=>({loading:!1,errorMessage:!1,mainHasError:!1,buttonSubmit:"",error_message_wrapper:{},stopAction:!1,insuranceVariantId:"",loadInsurance(id){this.insuranceVariantId==""&&(this.insuranceVariantId=id)},scrollToAtcBtn(btnId){document.querySelector(`#${btnId}`).scrollIntoView({behavior:"smooth",block:"center",inline:"center"})},async addToCart(e,required,quickView,sticky){this.loading=!0,e.preventDefault(),setTimeout(async()=>{if(required){var productInfo=this.$el.closest(".product-info");if(sticky&&(productInfo=document.querySelector(".product-info")),productInfo){var propertiesInput=productInfo.querySelectorAll(".customization-picker");this.stopAction=!1;let scrollStatus=!1;propertiesInput.length&&propertiesInput.forEach(input=>{input.required&&input.value.trim()==""||input.classList.contains("validate-checkbox")?(input.classList.add("required-picker"),this.stopAction=!0,scrollStatus||(input.parentElement.querySelector(".text-required").scrollIntoView({behavior:"smooth",block:"center"}),scrollStatus=!0)):input.classList.remove("required-picker")}),this.stopAction||productInfo.querySelectorAll(".recipient_input").forEach(giftCardInput=>{!this.stopAction&&giftCardInput.required&&(this.stopAction=Alpine.$data(giftCardInput.closest("[x-data]")).onChangeInput(giftCardInput),this.stopAction&&giftCardInput.scrollIntoView({behavior:"smooth",block:"center"}))})}if(this.stopAction)return setTimeout(()=>{this.loading=!1},500),!0}await Alpine.store("xCartHelper").waitForCartUpdate(),window.updatingCart=!0,this.$refs.engraving_text&&engravingVariantId&&(this.$refs.engraving_text.value.trim()?this.$refs.engraving_text.hasAttribute("name")||this.$refs.engraving_text.setAttribute("name",this.$refs.text_area_name.value):this.$refs.engraving_text.hasAttribute("name")&&this.$refs.engraving_text.removeAttribute("name"));var productForm=this.$el.closest(".product-info")||this.$el.closest("form");let formData=new FormData(this.$refs.product_form);const productId=formData.get("product-id");var edt_element=productForm?productForm.querySelector(`.hidden.cart-edt-properties-${productId}`):null;edt_element&&(edt_element.value=edt_element.value.replace("time_to_cut_off",Alpine.store("xEstimateDelivery").noti)),formData=new FormData(this.$refs.product_form),formData.append("sections",Alpine.store("xCartHelper").getSectionsToRender().map(section=>section.id)),formData.append("sections_url",window.location.pathname);const newFormData=new FormData;for(let[key,value]of formData.entries())value!==""&&newFormData.append(key,value);const match=document.cookie.match("(^|;)\\s*eurus_insurance\\s*=\\s*([^;]+)"),linkedProductList=newFormData.getAll("properties[_linked_product_id][]"),linkedProductListQty=newFormData.getAll("properties[_linked_product_id_qty][]");if(this.$refs.gift_wrapping_checkbox&&this.$refs.gift_wrapping_checkbox.checked&&wrappringVariantId||this.$refs.engraving_text&&engravingVariantId&&this.$refs.engraving_text.value.trim()||this.insuranceVariantId&&!localStorage.getItem("insuranceRemoved")&&(!match||match[1].trim()==="")||linkedProductList.length>0||linkedProductListQty.length>0){const variantId=formData.get("id"),productTitle=productForm?productForm.querySelector(`.product-variant-title-${formData.get("product-id")}-${variantId}`)?.textContent:null;let additionalOptionData=[];if(this.$refs.gift_wrapping_checkbox&&this.$refs.gift_wrapping_checkbox.checked&&wrappringVariantId&&additionalOptionData.push({id:wrappringVariantId,quantity:1,parent_id:variantId,properties:{For:productTitle}}),linkedProductListQty.length>0){let qty=newFormData.get("quantity");linkedProductListQty.forEach(val=>{additionalOptionData.push({id:val,quantity:qty,parent_id:variantId,properties:{For:productTitle}})})}linkedProductList.length>0&&linkedProductList.forEach(val=>{additionalOptionData.push({id:val,quantity:1,parent_id:variantId,properties:{For:productTitle}})}),this.$refs.engraving_text&&engravingVariantId&&this.$refs.engraving_text.value.trim()&&additionalOptionData.push({id:engravingVariantId,quantity:1,parent_id:variantId,properties:{For:productTitle}}),this.insuranceVariantId&&!localStorage.getItem("insuranceRemoved")&&(!match||match[1].trim()==="")&&additionalOptionData.push({id:this.insuranceVariantId,quantity:1}),additionalOptionData.length!==0&&additionalOptionData.forEach((item,index)=>{const base=`items[${index}]`;newFormData.append(`${base}[id]`,item.id),newFormData.append(`${base}[quantity]`,item.quantity),item.parent_id&&newFormData.append(`${base}[parent_id]`,item.parent_id),item.properties&&Object.entries(item.properties).forEac
1h(([key,value])=>{newFormData.append(`${base}[properties][${key}]`,value)})})}let resProductId;await fetch(`${Eurus.cart_add_url}`,{method:"POST",headers:{Accept:"application/javascript","X-Requested-With":"XMLHttpRequest"},body:newFormData}).then(reponse=>reponse.json()).then(async response=>{response.status=="422"?(document.dispatchEvent(new CustomEvent("eurus:product:add-failed",{detail:{errorMessage:response.description}})),typeof response.errors=="object"?(this.error_message_wrapper=response.errors,document.querySelector(".recipient-error-message").classList.remove("hidden")):(this.errorMessage=!0,setTimeout(()=>{this.errorMessage=!1},3e3),this.$refs.error_message&&(this.$refs.error_message.textContent=response.description),this.$refs.error_message_mobile&&(this.$refs.error_message_mobile.textContent=response.description)),Alpine.store("xMiniCart")&&(Alpine.store("xMiniCart").reLoad(),document.dispatchEvent(new CustomEvent("eurus:cart:items-changed")))):(resProductId=response.product_id,Alpine.store("xCartNoti")&&Alpine.store("xCartNoti").enable&&Alpine.store("xCartNoti").setItem(response),document.querySelector(".recipient-error-message")&&document.querySelector(".recipient-error-message").classList.add("hidden"),this.error_message_wrapper={},Alpine.store("xQuickView")&&Alpine.store("xQuickView").show&&(Alpine.store("xQuickView").show=!1),Alpine.store("xPopup").close(),document.dispatchEvent(new CustomEvent("eurus:video-popup:close-popup")),quickView&&Alpine.store("xQuickView").buttonQuickView&&Alpine.store("xQuickView").buttonQuickView.dataset.addAsBundle||!quickView&&this.$refs.product_form&&this.$refs.product_form.querySelector('[data-add-as-bundle="true"]')?document.dispatchEvent(new CustomEvent("eurus:cart:add-as-bundle")):(Alpine.store("xCartHelper").reRenderSections(response.sections),(!Alpine.store("xCartNoti")||!Alpine.store("xCartNoti").enable)&&Alpine.store("xMiniCart").openCart(),Alpine.store("xCartHelper").currentItemCount=parseInt(document.getElementById("cart-icon-bubble").innerHTML),Alpine.store("xQuickView")&&(Alpine.store("xQuickView").openPopupMobile=!1),this.$el.closest(".choose-options")?.getElementsByClassName("js-close-button")[0].click(),this.$el.closest(".js-product-container")?.getElementsByClassName("js-close-button")[0].click(),document.dispatchEvent(new CustomEvent("eurus:cart:items-changed")),document.dispatchEvent(new CustomEvent("eurus:cart:redirect")),document.dispatchEvent(new CustomEvent("eurus:product:added",{detail:{product:response}}))))}).catch(error=>{document.dispatchEvent(new CustomEvent("eurus:product:add-failed",{detail:{errorMessage:error}})),console.error("Error:",error)}).finally(()=>{window.updatingCart=!1,document.dispatchEvent(new CustomEvent(`eurus:product-card:clear:${resProductId}`)),this.loading=!1,(quickView&&Alpine.store("xQuickView").buttonQuickView&&!Alpine.store("xQuickView").buttonQuickView.dataset.addAsBundle||!quickView&&this.$refs.product_form&&!this.$refs.product_form.querySelector('[data-add-as-bundle="true"]'))&&this.$refs.gift_wrapping_checkbox&&(this.$refs.gift_wrapping_checkbox.checked=!1),document.cookie=`eurus_insurance=${this.insuranceVariantId}; path=/`})},0)}}))})})); 2//# sourceMappingURL=/cdn/shop/t/137/assets/product-cart.js.map?v=60769023760558595491785395020
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.