(i=>{function e(){let o=(()=>{let o,c;var e={hidden:"visibilitychange",webkitHidden:"webkitvisibilitychange",mozHidden:"mozvisibilitychange",msHidden:"msvisibilitychange"};for(o in e)if(o in document){c=e[o];break}return function(e){return e&&document.addEventListener(c,e),!document[o]}})();o(function(){var e=(o=>{var c=document.cookie.split(";");for(let e=0;e'+t.replace(/\*/g,"").trim()+" "+cartflows.field_validation.error_msg+"")):e.find(".wcf-field-required-error").remove()}var e=(o=i("form.woocommerce-checkout")).find("input, textarea"),o=o.find("select");e.on("blur",function(){var e,o=i(this),c=o.attr("type"),t=o.closest("p.form-row"),a=o.val();r(a,t,o,c),"number"===c&&(c=o.attr("min"),e=o.attr("max"),a=Number(a),t=t,o=o,c=Number(c),e=Number(e),""===a||a'+cartflows.field_validation_msgs.number_field+c+" & "+e+"")):(o.removeClass("field-required"),t.find(".wcf-field-required-error").remove()))}),o.on("blur",function(){var e=i(this).closest("p.form-row"),o=e.find(".select2-container--default"),c=e.find("select").val();r(c,e,o,"select")})}function c(){if("yes"===cartflows.allow_persistence&&!1!==(()=>{var e="test";try{return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch(e){return!1}})()){var o="form.woocommerce-checkout #customer_details";let e={set(){let e=[];var o=i("form.woocommerce-checkout #customer_details");localStorage.removeItem("cartflows_checkout_form"),o.find("input[type=text], select, input[type=email], input[type=tel]").each(function(){e.push({name:this.name,value:this.value})}),cartflows_checkout_form=JSON.stringify(e),localStorage.setItem("cartflows_checkout_form",cartflows_checkout_form)},get(){if(null!==localStorage.getItem("cartflows_checkout_form")){checkout_data=JSON.parse(localStorage.getItem("cartflows_checkout_form"));for(let e=0;e()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(r))return o.after(''+cartflows.email_validation_msgs.error_msg+""),t.removeClass("wcf-show");clearTimeout(n);let a=++l;n=setTimeout(function(){i.ajax({url:cartflows.ajax_url,type:"POST",data:{action:"wcf_check_email_exists",email_address:e,security:cartflows.check_email_exist_nonce},success(e){a===l&&(c.remove(),e.data&&e.data.success&&t.hasClass("wcf-show")?o.after(''+cartflows.email_validation_msgs.success_msg+""):e.data&&e.data.success?(e.data.is_login_allowed&&(o.after(''+cartflows.email_validation_msgs.success_msg+""),t.slideDown(400).addClass("wcf-show")),i(".wcf-create-account-section").hide(),i(".woocommerce-billing-fields__customer-login-label").show()):(t.slideUp(400).removeClass("wcf-show"),i(".wcf-create-account-section .create-account label.checkbox").show(),i(".wcf-create-account-section").show(),i(".woocommerce-billing-fields__customer-login-label").hide()))}})},300)}else i(".wcf-create-account-section").hide(),i(".wcf-customer-login-section").hide(),i(".wcf-email-validation-block").hide(),i(".woocommerce-billing-fields__customer-login-label").show();var r}}function r(){i("body").hasClass("cartflows-instant-checkout")&&i(".woocommerce-NoticeGroup").prependTo(".woocommerce-notices-wrapper")}let s={init(){i(document.body).on("click",".wcf-submit-coupon",this.submit_coupon),i(document.body).on("click",".wcf-remove-coupon",this.remove_coupon)},submit_coupon(e){e.preventDefault();let c=i(".wcf-custom-coupon-field"),o=i(this).closest(c),t=o.find(".wcf-coupon-code-input"),a=t.val();if(""===a)return t.addClass("field-required"),!1;t.removeClass("field-required");e=i(".wcf-embed-checkout-form #billing_email").val(),e={coupon_code:a,action:"wcf_woo_apply_coupon",security:cartflows.wcf_validate_coupon_nonce,billing_email:e};i.ajax({type:"POST",url:cartflows.ajax_url,data:e,success(e){var o=i(".wcf-custom-coupon-field");o.find(".woocommerce-error, .woocommerce-message").remove(),e&&!0===e.status?(i(document.body).trigger("update_checkout",{update_shipping_method:!1}),o.prepend(e.msg),c.addClass("wcf-coupon-applied")):e&&e.msg&&(o.prepend(e.msg),c.removeClass("wcf-coupon-applied"))}})},remove_coupon(e){e.preventDefault();e={coupon_code:i(this).attr("data-coupon"),action:"wcf_woo_remove_coupon",security:cartflows.wcf_validate_remove_coupon_nonce};i.ajax({type:"POST",url:cartflows.ajax_url,data:e,success(e){var o=i(".wcf-custom-coupon-field");o.find(".woocommerce-error, .woocommerce-message").hide(),i(".wcf-custom-coupon-field").removeClass("wcf-coupon-applied"),e&&(i(document.body).trigger("update_checkout",{update_shipping_method:!1}),o.prepend(e))}})}},l=0,n;i(function(){c(),e(),o(),i(document.body).on("click","#wcf-embed-checkout-form .wcf-remove-product",function(e){e.preventDefault();let o=i(this).attr("data-id");e={p_key:i(this).attr("data-item-key"),p_id:o,action:"wcf_woo_remove_cart_product",security:cartflows.wcf_validate_remove_cart_product_nonce};i.ajax({type:"POST",url:cartflows.ajax_url,data:e,success(e){e=JSON.parse(e);!1===e.need_shipping&&i("#wcf-embed-checkout-form").find("#ship-to-different-address-checkbox").attr("checked",!1),i("#wcf-embed-checkout-form").find(".woocommerce-notices-wrapper").first().html(e.msg),i(document).trigger("cartflows_remove_product",[o]),i("#wcf-embed-checkout-form").trigger("update_checkout")}})}),s.init(),jQuery.each(cartflows_checkout_optimized_fields,function(o,e){e.is_optimized&&(jQuery("#"+o).prepend(''+e.field_label+""),jQuery("#wcf_optimized_"+o).on("click",function(e){e.preventDefault(),jQuery("#"+o).removeClass("wcf-hide-field");e=o.replace(/_field/g,"");i("#"+e).trigger("focus"),jQuery(this).remove()}))}),i(document.body).on("click",".coupon-field .wcf-custom-coupon-field .wcf-optimized-coupon-field",function(e){e.preventDefault(),i(".wcf-custom-coupon-field").removeClass("wcf-hide-field"),i(this).remove()}),i(document.body).on("checkout_error updated_checkout",r),t(),i(".wcf-customer-info #billing_email").on("input",function(){a()}),0