function lazyLoadProducts(){const e=document.querySelectorAll(".product-wrapper"),t=new IntersectionObserver((e,t)=>{e.forEach(e=>{e.isIntersecting&&(getProduct(e.target),t.unobserve(e.target))})});e.forEach(e=>{t.observe(e)})}function debounce(e,t,a){var o;return function(){var n=this,i=arguments,r=a&&!o;clearTimeout(o),o=setTimeout(function(){o=null,a||e.apply(n,i)},t),r&&e.apply(n,i)}}function showNotification(e,t,a,o){a=a||!1,o=o||null,e||(e="Unknown error has occured. Check inputs."),$("#notify_message").removeClass(),$("#notify_message").addClass("alert-"+t),$("#notify_message").html(e),$("#notify_message").slideDown(300).delay(1500).slideUp(300,function(){o&&(window.location=o),!0===a&&location.reload()})}function handleFailNotification(e,t){if(e.responseJSON&&e.responseJSON.length>0){const o=$("#validationModal");var a=validationErrors(e.responseJSON);return $(".modal-title",o).html(t||o.data("hdr")),$("#validationModalBody").html(a),void $("#validationModal").modal("show")}const o=e.responseJSON||{};showNotification(o.message,"danger",o.reload,o.redirect)}function slugify(e){return $.trim(e).replace(/[^a-z0-9-æøå]/gi,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").replace(/æ/gi,"ae").replace(/ø/gi,"oe").replace(/å/gi,"a").toLowerCase()}$(document).ready(function(){if(lazyLoadProducts(),$("#stripe-form").length>0){var e=Stripe($("#stripePublicKey").val()),t=e.elements().create("card",{style:{hidePostalCode:!0,base:{color:"#32325d",fontFamily:'"Helvetica Neue", Helvetica, sans-serif',fontSmoothing:"antialiased",fontSize:"16px","::placeholder":{color:"#aab7c4"}},invalid:{color:"#fa755a",iconColor:"#fa755a"}}});t.mount("#card-element"),$(document).on("submit","#stripe-payment-form",function(a){a.preventDefault(),$("#overlay").fadeIn(),e.createToken(t).then(function(e){e.error?showNotification("Your payment has declined. Please try again","danger",!0):$.ajax({type:"POST",url:"/stripe/checkout_action",data:{token:e.token.id}}).done(e=>{window.location=e.redirect}).fail(e=>{showNotification(`${e.message}`,"danger",!0),$("#overlay").fadeOut()})})})}$("#adyen-dropin").length>0&&$.ajax({method:"POST",url:"/adyen/setup"}).done(function(e){const t={locale:"en-AU",environment:e.environment.toLowerCase(),originKey:e.publicKey,paymentMethodsResponse:e.paymentsResponse};new AdyenCheckout(t).create("dropin",{paymentMethodsConfiguration:{card:{hasHolderName:!1,holderNameRequired:!1,enableStoreDetails:!1,groupTypes:["mc","visa"],name:"Credit or debit card"}},onSubmit:(e,t)=>{0===$("#shipping-form").validator("validate").has(".has-error").length&&$.ajax({type:"POST",url:"/adyen/checkout_action",data:{shipEmail:$("#shipEmail").val(),shipCompany:$("#shipCompany").val(),shipFirstname:$("#shipFirstname").val(),shipLastname:$("#shipLastname").val(),shipAddr1:$("#shipAddr1").val(),shipAddr2:$("#shipAddr2").val(),shipCountry:$("#shipCountry").val(),shipState:$("#shipState").val(),shipPostcode:$("#shipPostcode").val(),shipPhoneNumber:$("#shipPhoneNumber").val(),payment:JSON.stringify(e.data.paymentMethod)}}).done(e=>{window.location="/payment/"+e.paymentId}).fail(e=>{showNotification("Failed to complete transaction","danger",!0)})}}).mount("#adyen-dropin")}).fail(function(e){showNotification(e.responseJSON.message,"danger")})});let maxSwiperHeight=-1;function getProduct(e){const t=e.getAttribute("data-product"),a=e.getAttribute("data-alias"),o=e.getAttribute("data-productId");return $.ajax({type:"POST",url:"/product/pricing",data:{productAlias:a}}).done(e=>{$(`.price-details[data-id="pricing-${t}"]`).html(e.data),$(`.add-to-cart[data-id="${o}"]`).attr("data-unit",e.unit),setTimeout(function(){const e=$(`.price-details[data-id="pricing-${t}"]`).closest(".thumbnail").outerHeight();maxSwiperHeight=e>maxSwiperHeight?e:maxSwiperHeight,$(`.price-details[data-id="pricing-${t}"]`).closest(".thumbnail").css("height",maxSwiperHeight)},300),e.purchase&&$(`.product-action-btn[data-id="${o}"]`).removeClass("d-none").addClass("d-inline-flex")}).fail(e=>{}),null}function checkPassword(e){const t={status:!0};return e.match(/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,20}$/)||(t.status=!1,t.message="Min. 8 characters, with 1 capital and 1 lowercase characters and 1 number"),t}function intlTel({phone:e,countryCode:t="AU"}){return e?"AU"===t?e.startsWith("+61")?e:(e=(e=e.replace(/\D/g,"")).replace(/^0/g,""),"+61".concat(e)):e:""}function validationErrors(e){var t="";return e.forEach(e=>{t+=`
${e.dataPath.replace("/","")} - ${e.message}
`}),t}function preventDefaults(e){e.preventDefault(),e.stopPropagation()}function promptConfirm(e,{fnCancel:t,context:a,prompt:o,header:n}={}){const i=$("#confirmModal"),r=i.find("#buttonConfirm");r.unbind("click").on("click",()=>{i.modal("hide"),e(a)}),r.attr("data-func","noop"),i.find(".modal-body").html(o||i.attr("data-prompt")),i.find(".modal-title").html(n||i.attr("data-header"));const d=i.find("#buttonConfirmCancel");d.unbind("click"),t&&d.on("click",()=>t(a)),i.modal("show")}function promptInfo(e){$("#infoModal").find(".modal-body h2").html(e).end().modal("show")}window.noop=(()=>{});