https://www.elitesupps.com.au/cdn/shop/t/815/assets/product-form.js?v=170172036656190162351790812122
1window.routes||(window.routes={cart_add_url:"/cart/add",cart_change_url:"/cart/change",cart_update_url:"/cart/update",cart_url:"/cart",predictive_search_url:"/search/suggest"}),customElements.get("product-form")||customElements.define("product-form",class extends HTMLElement{constructor(){super(),this.form=this.querySelector("form"),this.form.querySelector("[name=id]").disabled=!1,this.form.addEventListener("submit",this.onSubmitHandler.bind(this)),this.cart=document.querySelector("cart-notification")||document.querySelector("cart-drawer"),this.submitButton=this.querySelector('[type="submit"]'),document.querySelector("cart-drawer")&&this.submitButton.setAttribute("aria-haspopup","dialog"),this.hideErrors=this.dataset.hideErrors==="true"}onSubmitHandler(evt){if(evt.preventDefault(),this.submitButton.getAttribute("aria-disabled")==="true")return;this.handleErrorMessage(),this.submitButton.setAttribute("aria-disabled",!0),this.submitButton.classList.add("loading"),this.querySelector(".loading__spinner").classList.remove("hidden");const config=fetchConfig("javascript");config.headers["X-Requested-With"]="XMLHttpRequest",delete config.headers["Content-Type"];var cart_add_url=routes.cart_add_url,formData=new FormData(this.form),$this=this;this.cart&&(formData.append("sections",this.cart.getSectionsToRender().map(section=>section.id)),formData.append("sections_url",window.location.pathname),this.cart.setActiveElement(document.activeElement),config.body=formData),fetch(cart_add_url,config).then(response=>response.json()).then(response=>{if(response.status){publish(PUB_SUB_EVENTS.cartError,{source:"product-form",productVariantId:formData.get("id"),errors:response.errors||response.description,message:response.message}),this.handleErrorMessage(response.description);const soldOutMessage=this.submitButton.querySelector(".sold-out-message");if(!soldOutMessage)return;this.submitButton.setAttribute("aria-disabled",!0),this.submitButton.querySelector("span").classList.add("hidden"),soldOutMessage.classList.remove("hidden"),this.error=!0;return}else if(!this.cart){window.location=window.routes.cart_url;return}GA4.add_to_cart(response),this.error||publish(PUB_SUB_EVENTS.cartUpdate,{source:"product-form",productVariantId:formData.get("id"),cartData:response}),this.error=!1;const quickAddModal=this.closest("quick-add-modal");quickAddModal?(document.body.addEventListener("modalClosed",()=>{setTimeout(()=>{this.cart.renderContents(response)})},{once:!0}),quickAddModal.hide(!0)):this.cart.renderContents(response)}).catch(e=>{console.error(e)}).finally(()=>{this.submitButton.classList.remove("loading"),this.cart&&this.cart.classList.contains("is-empty")&&this.cart.classList.remove("is-empty"),this.error||this.submitButton.removeAttribute("aria-disabled"),this.querySelector(".loading__spinner").classList.add("hidden")})}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)))}});function formatDate(date){var d=new Date(date),month=""+(d.getMonth()+1),day=""+d.getDate(),year=d.getFullYear();return month.length<2&&(month="0"+month),day.length<2&&(day="0"+day),[day,month,year].join("/")}function calculateEstimatedDelivery(){var cutOffTime=12,aestTime=new Date().toLocaleString("en-US",{timeZone:"Australia/Sydney"}),currentDate=new Date(aestTime),currentHour=currentDate.getHours(),HolidayList=["26/12/2024","01/01/2025","21/04/2025","26/01/2026","02/03/2026"];currentHour>cutOffTime-1&¤tDate.setDate(currentDate.getDate()+1);var dispatchDate=new Date(currentDate),currentDay=currentDate.getDay();currentDay>0&¤tDay<6?dispatchDate=new Date(currentDate):currentDay==6?dispatchDate.setDate(dispatchDate.getDate()+2):currentDay==0&&dispatchDate.setDate(dispatchDate.getDate()+1);var dispatchDay=dispatchDate.getDay(),deliveryDate=new Date(dispat
1chDate);for(deliveryDate.setDate(dispatchDate.getDate()+2),dispatchDay==4?deliveryDate.setDate(deliveryDate.getDate()+1):dispatchDay==5&&deliveryDate.setDate(deliveryDate.getDate()+2),i=0;i<HolidayList.length;i++){var holiday=HolidayList[i],dateFrom=formatDate(dispatchDate),dateTo=formatDate(deliveryDate),d1=dateFrom.split("/"),d2=dateTo.split("/"),c=holiday.split("/"),from=new Date(d1[2],parseInt(d1[1])-1,d1[0]),to=new Date(d2[2],parseInt(d2[1])-1,d2[0]),check=new Date(c[2],parseInt(c[1])-1,c[0]);check>=from&&check<=to&&deliveryDate.setDate(deliveryDate.getDate()+1);var deliveryDay=deliveryDate.getDay();deliveryDay==6?deliveryDate.setDate(deliveryDate.getDate()+2):deliveryDay==0&&deliveryDate.setDate(deliveryDate.getDate()+1)}var month=deliveryDate.toLocaleString("default",{month:"short"}),nthNumber=number=>{if(number>3&&number<21)return"th";switch(number%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}},date=`${deliveryDate.getDate()}${nthNumber(deliveryDate.getDate())} ${month}`;return date}if(document.getElementById("delivery-date")&&(document.getElementById("delivery-date").innerHTML=calculateEstimatedDelivery(),document.querySelectorAll(".expected-delivery").forEach(function(el){el.style.display="flex"})),window.Shopify.uniq=function(t){for(var e=[],o=0;o<t.length;o++)Shopify.arrayIncludes(e,t[o])||e.push(t[o]);return e},Shopify.arrayIncludes=function(t,e){for(var o=0;o<t.length;o++)if(t[o]==e)return!0;return!1},window.Shopify.updateOptionsInSelector=function(selectorIndex,parent){var selects=document.querySelectorAll(parent+" .product-form__input .select__select");switch(selectorIndex){case 0:var key="root";break;case 1:var key=selects[0]?selects[0].value:"";break;case 2:var key=selects[0]?selects[0].value:"";key+=` / ${selects[1]?selects[1].value:""}`}var availableOptions=Shopify.optionsMap[key];key!="root"&&(availableOptions=window.Shopify.changeorder(availableOptions,key));var selector=selects[selectorIndex],initialValue=selector?selector.value:"";if(!document.querySelector(".variant-v2")){selector&&(selector.innerHTML="");for(var i2=0;i2<availableOptions.length;i2++){var option=availableOptions[i2],newOption=document.createElement("option");newOption.value=option,newOption.innerHTML=option,selector&&selector.appendChild(newOption)}availableOptions.includes(initialValue)&&(selector.value=initialValue),selector&&selector.dispatchEvent(new Event("change",{bubbles:!0}))}},window.Shopify.updateOptionsInSelectorRadio=function(selectorIndex,parent){var fieldsets=document.querySelectorAll(parent+" fieldset");switch(selectorIndex){case 0:var key="root";break;case 1:var checked0=fieldsets[0]?fieldsets[0].querySelector("input:checked"):null,key=checked0?checked0.value:"";break;case 2:var checked0=fieldsets[0]?fieldsets[0].querySelector("input:checked"):null,checked1=fieldsets[1]?f
1ieldsets[1].querySelector("input:checked"):null,key=checked0?checked0.value:"";key+=` / ${checked1?checked1.value:""}`}const availableOptions=Shopify.optionsMap[key];var selector=fieldsets[selectorIndex],$product=window.productJSONData;if(selector){selector.querySelectorAll("label").forEach(function(l){l.classList.remove("v-available")}),selector.querySelectorAll("label").forEach(function(l){l.classList.add("v-unavailable")});for(var i2=0;i2<availableOptions.length;i2++){var option=availableOptions[i2];if(selector.querySelectorAll(`input[value="${option}"]+label`).forEach(function(l){l.classList.add("v-available")}),selector.querySelectorAll(`input[value="${option}"]+label`).forEach(function(l){l.classList.remove("v-unavailable")}),selectorIndex==1){for(j=0;j<$product.variants.length;j++)if($variant=$product.variants[j],$variant.option1==key&&$variant.option2==option){var $imgBase=$variant.featured_image?$variant.featured_image.src:$product.featured_image,$img=$imgBase+"&width=200",$imgSrcset=$imgBase+"&width=100 100w, "+$imgBase+"&width=200 200w",$imgAlt=$product.title+" "+$variant.title;selector.querySelectorAll(`input[value="${option}"]+label .swatch-flavour-img`).forEach(function(el){var swatchImg=el.querySelector("img");swatchImg?(swatchImg.src=$img,swatchImg.srcset=$imgSrcset,swatchImg.alt=$imgAlt):el.innerHTML=`<img src="${$img}" srcset="${$imgSrcset}" sizes="100px" loading="lazy" alt="${$imgAlt}">`})}}}setTimeout(function(){var checkedInput=selector.querySelector("input:checked");if(checkedInput&&checkedInput.classList.contains("disabled")){var firstNotDisabled=selector.querySelector("input:not(.disabled)");firstNotDisabled&&firstNotDisabled.click()}},100),document.querySelectorAll(".variant-v2 variant-radios .product-form__input").forEach(function(el){var $length=el.querySelectorAll(".v2-swatch-wrapper .v-available").length,optSize=el.querySelector(".option-size");optSize&&(optSize.innerHTML=$length+" options")})}},window.Shopify.changeorder=function(options,key){var $movebottomlist="";if(window.pre_order_options)var $pre_order_or_soldout=window.pre_order_options.split(","),$movebottomlist=$pre_order_or_soldout.filter(entry=>entry.startsWith(key)).map(entry=>entry.split("/")[1]?.trim());if($movebottomlist.length){const moveToBottom=$movebottomlist,isTargetOption=option=>moveToBottom.some(target=>option.toLowerCase().includes(target.toLowerCase())),bottomOptions=options.filter(isTargetOption);return[...options.filter(option=>!isTargetOption(option)),...bottomOptions]}else return options},window.Shopify.linkOptionSelectors=function(product,parent){window.Shopify.optionsMap={};for(let i2=0;i2<product.variants.length;i2++){const variant=product.variants[i2];if(variant){if(window.Shopify.optionsMap.root=window.Shopify.optionsMap.root||[],window.Shopify.optionsMap.root.push(variant.option1),window.Shopify.optionsMap.root=window.Shopify.uniq(window.Shopify.optionsMap.root),product.options.length>1){const key=variant.option1;window.Shopify.optionsMap[key]=window.Shopify.optionsMap[key]||[],window.Shopify.optionsMap[key].push(variant.option2),window.Shopify.optionsMap[key]=window.Shopify.uniq(window.Shopify.optionsMap[key])}if(product.options.length===3){const key=`${variant.option1} / ${variant.option2}`;window.Shopify.optionsMap[key]=window.Shopify.optionsMap[key]||[],window.Shopify.optionsMap[key].push(variant.option3),window.Shopify.optionsMap[key]=window.Shopify.uniq(window.Shopify.optionsMap[key])}}}if(document.querySelector(".variant-v2")){window.Shopify.updateOptionsInSelectorRadio(0,parent),product.options.length>1&&window.Shopify.updateOptionsInSelectorRadio(1,parent);var fieldsets=document.querySelectorAll(parent+" fieldset");fieldsets[0]&&fieldsets[0].querySelectorAll("input[type=radio]").forEach(function(r){r.addEventListener("change",function(){product.options.length===2&&window.Shopify.updateOptionsInSelectorRadio(1,parent)})})}else{window.Shopify.updateOptionsInSelector(0,parent),product.options.length>1&&window.Shopify.updateOptionsInSelector(1,parent),product.options.length===3&&window.Shopify.updateOptionsInSelector(2,parent);var selects=document.querySelectorAll(parent+" .product-form__input .select__select");selects[0]&&selects[0].addEventListener("change",function(){product.options.length===2&&window.Shopify.updateOptionsInSelector(1,parent),product.options.length===3&&window.Shopify.updateOptionsInSelector(2,parent)}),selects[1]&&selects[1].addEventListener("change",function(){product.options.length===3&&window.Shopify.updateOptionsInSelector(2,parent)})}},document.querySelectorAll(".product__info-wrapper-last-column, .product__info-wrapper-apparel").forEach(function(el){var infoContainer=el.querySelector(".product__info-container");infoContainer&&infoContainer.dataset.handle&&setTimeout(function(){var Handle=infoContainer.dataset.handle,JSON
1Data=JSON.parse(document.getElementById("product-"+Handle).innerHTML);window.productJSONData=JSONData;var wrapperClass=el.classList.contains("product__info-wrapper-apparel")?".product__info-wrapper-apparel":".product__info-wrapper-last-column",variantSelects=document.querySelector(wrapperClass+' .product__info-container[data-handle="'+Handle+'"] variant-selects'),$id=variantSelects?variantSelects.id:null;el.querySelector(".variant-v2")?Shopify.linkOptionSelectors(JSONData,wrapperClass+' .product__info-container[data-handle="'+Handle+'"] variant-radios'):$id?Shopify.linkOptionSelectors(JSONData,"#"+$id):Shopify.linkOptionSelectors(JSONData,wrapperClass+' .product__info-container[data-handle="'+Handle+'"] variant-selects')},1e3)}),document.querySelectorAll(".quantity-pack input[type=radio]").forEach(function(radio){radio.addEventListener("change",function(){document.querySelectorAll(".quantity-pack").forEach(function(el){el.classList.remove("active")}),radio.parentElement.classList.add("active")})}),window.location.pathname!="/products/mystery-product-stack"&&window.location.pathname!="/products/per4m"){var wrapper_v3=document.querySelector(".flavour-type-variant-wrapper .v2-swatch-wrapper");if(wrapper_v3){const children=Array.from(wrapper_v3.children),pairs=[];for(let i2=0;i2<children.length;i2+=2){const input=children[i2],label=children[i2+1];if(input&&label&&label.tagName==="LABEL"){const text=label.textContent.trim().toLowerCase();pairs.push({input,label,text})}}pairs.sort((a,b)=>a.text.localeCompare(b.text)),wrapper_v3.innerHTML="",pairs.forEach(pair=>{wrapper_v3.appendChild(pair.input),wrapper_v3.appendChild(pair.label)})}}document.querySelectorAll(".mystery-product-selection .flavour-type-variant-wrapper input[type=radio]").forEach(function(radio){radio.addEventListener("change",function(){var $p_total=0,$c_total=0;document.querySelectorAll(".mystery-product-selection .flavour-type-variant-wrapper").forEach(function(wrapper){var checked=wrapper.querySelector("input[type=radio]:checked");checked&&($p_total+=parseInt(checked.dataset.price),$c_total+=parseInt(checked.dataset.cprice))});var customPrice=document.querySelector(".custom-price");customPrice&&(customPrice.innerHTML=Shopify.formatMoney($p_total,Shopify.money_format));var priceSale=document.querySelector(".price__container .price-item--sale");priceSale&&(priceSale.innerHTML=Shopify.formatMoney($p_total,Shopify.money_format));var priceRegular=document.querySelector(".price__container .price-item--regular");priceRegular&&(priceRegular.innerHTML=Shopify.formatMoney($c_total,Shopify.money_format));var discount=Math.round((1-$p_total/$c_total)*100),badgeSale=document.querySelector(".price__badge-sale");badgeSale&&(badgeSale.innerHTML=discount+"% OFF")})}); 2//# sourceMappingURL=/cdn/shop/t/815/assets/product-form.js.map?v=170172036656190162351790812122
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.