'+r.messages+""):n.prepend(r),n.find(".input-text, select, input:checkbox").trigger("validate").trigger("blur"),t.scroll_to_notices()}t.init_payment_methods(),r&&"success"===r.result&&o.current_target&&-1!==o.current_target.id.indexOf("shipping_method")&&document.getElementById(o.current_target.id).focus(),e(document.body).trigger("updated_checkout",[r])}}})}},handleUnloadEvent:function(e){return-1===navigator.userAgent.indexOf("MSIE")&&!document.documentMode||(e.preventDefault(),undefined)},attachUnloadEventsOnSubmit:function(){e(window).on("beforeunload",this.handleUnloadEvent)},detachUnloadEventsOnSubmit:function(){e(window).off("beforeunload",this.handleUnloadEvent)},blockOnSubmit:function(e){1!==e.data("blockUI.isBlocked")&&e.block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},submitOrder:function(){t.blockOnSubmit(e(this))},submit:function(){t.reset_update_checkout_timer();var o=e(this);return!o.is(".processing")&&(!1!==o.triggerHandler("checkout_place_order",[t])&&!1!==o.triggerHandler("checkout_place_order_"+t.get_payment_method(),[t])&&(o.addClass("processing"),t.blockOnSubmit(o),t.attachUnloadEventsOnSubmit(),e.ajaxSetup({dataFilter:function(e,o){if("json"!==o)return e;if(t.is_valid_json(e))return e;var r=e.match(/{"result.*}/);return null===r?console.log("Unable to fix malformed JSON #1"):t.is_valid_json(r[0])?(console.log("Fixed malformed JSON. Original:"),console.log(e),e=r[0]):console.log("Unable to fix malformed JSON #2"),e}}),e.ajax({type:"POST",url:wc_checkout_params.checkout_url,data:o.serialize(),dataType:"json",success:function(r){t.detachUnloadEventsOnSubmit(),e(".checkout-inline-error-message").remove();try{if("success"!==r.result||!1===o.triggerHandler("checkout_place_order_success",[r,t]))throw"failure"===r.result?"Result failure":"Invalid response";-1===r.redirect.indexOf("https://")||-1===r.redirect.indexOf("http://")?window.location=r.redirect:window.location=decodeURI(r.redirect)}catch(a){if(!0===r.reload)return void window.location.reload();if(!0===r.refresh&&e(document.body).trigger("update_checkout"),r.messages){var c=e(r.messages).removeAttr("role").attr("tabindex","-1"),i=t.wrapMessagesInsideLink(c),n=e('').append(i);t.submit_error(n.prop("outerHTML")),t.show_inline_errors(c)}else t.submit_error(''+wc_checkout_params.i18n_checkout_error+"
")}},error:function(e,o,r){t.detachUnloadEventsOnSubmit();var c=r;"object"==typeof wc_checkout_params&&null!==wc_checkout_params&&wc_checkout_params.hasOwnProperty("i18n_checkout_error")&&"string"==typeof wc_checkout_params.i18n_checkout_error&&""!==wc_checkout_params.i18n_checkout_error.trim()&&(c=wc_checkout_params.i18n_checkout_error),t.submit_error(''+c+"
")}})),!1)},submit_error:function(o){e(".woocommerce-NoticeGroup-checkout, .woocommerce-error, .woocommerce-message, .is-error, .is-success").remove(),t.$checkout_form.prepend(''+o+"
"),t.$checkout_form.removeClass("processing").unblock(),t.$checkout_form.find(".input-text, select, input:checkbox").trigger("validate").trigger("blur"),t.scroll_to_notices(),t.$checkout_form.find('.woocommerce-error[tabindex="-1"], .wc-block-components-notice-banner.is-error[tabindex="-1"]').focus(),e(document.body).trigger("checkout_error",[o])},wrapMessagesInsideLink:function(t){return t.find("li[data-id]").each(function(){const t=e(this),o=t.attr("data-id");if(o){const r=e("",{href:"#"+o,html:t.html()});t.empty().append(r)}}),t},show_inline_errors:function(t){t.find("li[data-id]").each(function(){const t=e(this),o=t.attr("data-id"),r=e("#"+o);if(1===r.length){const e=o+"_description",c=t.text().trim(),i=r.closest(".form-row"),n=document.createElement("p");n.id=e,n.className="checkout-inline-error-message",n.textContent=c,i&&n.textContent.length>0&&i.append(n),r.attr("aria-describedby",e),r.attr("aria-invalid","true")}})},scroll_to_notices:function(){var t=e(".woocommerce-NoticeGroup-updateOrderReview, .woocommerce-NoticeGroup-checkout");t.length||(t=e("form.checkout")),e.scroll_to_notices(t)}},o={init:function(){e(document.body).on("click","a.showcoupon",this.show_coupon_form),e(document.body).on("click",".woocommerce-remove-coupon",this.remove_coupon),e(document.body).on("blur change input","#coupon_code",this.remove_coupon_error),e("form.checkout_coupon").hide().on("submit",this.submit.bind(this))},show_coupon_form:function(){var t=e(this);return e(".checkout_coupon").slideToggle(400,function(){var o=e(this);o.is(":visible")?(t.attr("aria-expanded","true"),o.find(":input:eq(0)").trigger("focus")):t.attr("aria-expanded","false")}),!1},show_coupon_error:function(t,o){if(0!==o.length){var r=e(e.parseHTML(t)).text().trim();""!==r&&(o.find("#coupon_code").focus().addClass("has-error").attr("aria-invalid","true").attr("aria-describedby","coupon-error-notice"),e("",{"class":"coupon-error-notice",id:"coupon-error-notice",role:"alert",text:r}).appendTo(o))}},remove_coupon_error:function(t){e(t.currentTarget).removeClass("has-error").removeAttr("aria-invalid").removeAttr("aria-describedby").next(".coupon-error-notice").remove()},submit:function(o){var r=e(o.currentTarget),c=r.find("#coupon_code"),i=this;if(r.is(".processing"))return!1;r.addClass("processing").block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var n={security:wc_checkout_params.apply_coupon_nonce,coupon_code:r.find('input[name="coupon_code"]').val(),billing_email:t.$checkout_form.find('input[name="billing_email"]').val()};return e.ajax({type:"POST",url:wc_checkout_params.wc_ajax_url.toString().replace("%%endpoint%%","apply_coupon"),data:n,success:function(t){e(".woocommerce-error, .woocommerce-message, .is-error, .is-success, .checkout-inline-error-message").remove(),r.removeClass("processing").unblock(),t&&(-1===t.indexOf("woocommerce-error")&&-1===t.indexOf("is-error")?r.slideUp(400,function(){e("a.showcoupon").attr("aria-expanded","false"),r.before(t)}):i.show_coupon_error(t,c.parent()),e(document.body).trigger("applied_coupon_in_checkout",[n.coupon_code]),e(document.body).trigger("update_checkout",{update_shipping_method:!1}))},dataType:"html"}),!1},remove_coupon:function(t){t.preventDefault();var o=e(this).parents(".woocommerce-checkout-review-order"),r=e(this).data("coupon");o.addClass("processing").block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var c={security:wc_checkout_params.remove_coupon_nonce,coupon:r};e.ajax({type:"POST",url:wc_checkout_params.wc_ajax_url.toString().replace("%%endpoint%%","remove_coupon"),data:c,success:function(t){e(".woocommerce-error, .woocommerce-message, .is-error, .is-success").remove(),o.removeClass("processing").unblock(),t&&(e("form.woocommerce-checkout").before(t),e(document.body).trigger("removed_coupon_in_checkout",[c.coupon]),e(document.body).trigger("update_checkout",{update_shipping_method:!1}),e("form.checkout_coupon").find('input[name="coupon_code"]').val(""),e("form.checkout_coupon").slideUp(400,function(){e("a.showcoupon").attr("aria-expanded","false")}))},error:function(e){wc_checkout_params.debug_mode&&console.log(e.responseText)},dataType:"html"})}},r={init:function(){e(document.body).on("click","a.showlogin",this.show_login_form)},show_login_form:function(){return e("form.login, form.woocommerce-form--login").slideToggle(),!1}},c={init:function(){e(document.body).on("click","a.woocommerce-terms-and-conditions-link",this.toggle_terms)},toggle_terms:function(){if(e(".woocommerce-terms-and-conditions").length)return e(".woocommerce-terms-and-conditions").slideToggle(function(){var t=e(".woocommerce-terms-and-conditions-link");e(".woocommerce-terms-and-conditions").is(":visible")?(t.addClass("woocommerce-terms-and-conditions-link--open"),t.removeClass("woocommerce-terms-and-conditions-link--closed")):(t.removeClass("woocommerce-terms-and-conditions-link--open"),t.addClass("woocommerce-terms-and-conditions-link--closed"))}),!1}};t.init(),o.init(),r.init(),c.init()});;