!function(i){window.llms=window.llms||{},window.llms.checkout=new function(){var m=[],o=[];return this.$checkout_form=i("#llms-product-purchase-form"),this.$confirm_form=i("#llms-product-purchase-confirm-form"),this.$form_sections=!1,this.form_action=!1,this.init=function(){var t=this;i(".llms-checkout-wrapper").length&&this.bind_login(),this.$checkout_form.length?(this.form_action="checkout",this.$form_sections=this.$checkout_form.find(".llms-checkout-section"),this.$checkout_form.on("submit",this,this.submit),document.querySelector("html").style.scrollBehavior="auto",i(".llms-password-strength-meter").length&&this.add_before_submit_event({data:LLMS.PasswordStrength,handler:LLMS.PasswordStrength.checkout}),this.bind_coupon(),this.bind_gateways()):this.$confirm_form.length&&(this.form_action="confirm",this.$form_sections=this.$confirm_form.find(".llms-checkout-section"),this.$confirm_form.on("submit",function(){t.processing("start")}))},this.add_before_submit_event=function(t){t.handler&&"function"==typeof t.handler&&(t.data||(t.data=null),m.push(t))},this.add_error=function(t,e){var o="llms-checkout-errors";($err=i("#"+o)).length||($err=i('
'),i(".llms-checkout-wrapper").prepend($err)),$err.append(""+t+""),e&&console.error(e)},this.add_gateway=function(t){o.push(t)},this.bind_coupon=function(){var e=this;i('a[href="#llms-coupon-toggle"]').on("click",function(t){t.preventDefault(),i(".llms-coupon-entry").slideToggle(400)}),i("#llms-apply-coupon").on("click",function(t){t.preventDefault(),e.coupon_apply(i(this))}),i("#llms-remove-coupon").on("click",function(t){t.preventDefault(),e.coupon_remove(i(this))})},this.bind_gateways=function(){this.load_gateways(),i('input[name="llms_payment_gateway"]').length||i("#llms_create_pending_order").removeAttr("disabled"),i('input[name="llms_payment_gateway"]').on("change",function(){i('input[name="llms_payment_gateway"]').each(function(){var t=i(this),e=t.closest(".llms-payment-gateway"),o=e.find(".llms-gateway-fields").find("input, textarea, select"),s=t.is(":checked");e[s?"addClass":"removeClass"]("is-selected"),s?(o.removeAttr("disabled"),i(".llms-payment-gateways").trigger("llms-gateway-selected",{id:t.val(),$selector:e})):o.attr("disabled","disabled")})}),i(".llms-payment-gateways").on("llms-gateway-selected",function(t,e){var o=i("#llms_create_pending_order");e.$selector&&e.$selector.find(".llms-gateway-fields .invalid").length?o.attr("disabled","disabled"):o.removeAttr("disabled")})},this.bind_login=function(){i('a[href="#llms-show-login"]').on("click",function(t){t.preventDefault(),i(this).closest(".llms-info,.llms-notice").slideUp(400),i("form.llms-login").slideDown(400)})},this.clear_errors=function(){i("#llms-checkout-errors").remove()},this.coupon_apply=function(t){var o=this,e=i("#llms_coupon_code").val(),s=i(".llms-coupon-messages"),n=s.find(".llms-error"),l=i("form.llms-checkout");LLMS.Spinner.start(l),window.LLMS.Ajax.call({data:{action:"validate_coupon_code",code:e,plan_id:i("#llms-plan-id").val()},beforeSend:function(){n.hide()},success:function(t){var e;LLMS.Spinner.stop(l),"error"===t.code?(e=i(""+t.message+""),n.length?n.empty():(n=i(''),s.append(n)),e.appendTo(n),n.show()):t.success&&(i(".llms-coupon-wrapper").replaceWith(t.data.coupon_html),o.bind_coupon(),i(".llms-payment-gateways").replaceWith(t.data.gateways_html),o.bind_gateways(),i(".llms-order-summary").replaceWith(t.data.summary_html))}})},this.coupon_remove=function(t){var e=this,o=i("form.llms-checkout");LLMS.Spinner.start(o),window.LLMS.Ajax.call({data:{action:"remove_coupon_code",plan_id:i("#llms-plan-id").val()},success:function(t){LLMS.Spinner.stop(o),t.success&&(i(".llms-coupon-wrapper").replaceWith(t.data.coupon_html),e.bind_coupon(),i(".llms-order-summary").replaceWith(t.data.summary_html),i(".llms-payment-gateways").replaceWith(t.data.gateways_html),e.bind_gateways())}})},this.focus_errors=function(){i("html, body").animate({scrollTop:i("#llms-checkout-errors").offset().top-50},200)},this.load_gateways=function(){for(var t=0;t<=o.length;t++){var e=o[t];"object"==typeof e&&null!==e&&void 0!==e.bind&&"function"==typeof e.bind&&e.bind()}},this.processing=function(t){var e,o="stop"===t?"removeClass":"addClass";"checkout"===this.form_action?e=this.$checkout_form:"confirm"===this.form_action&&(e=this.$confirm_form),e[o]("llms-is-processing"),LLMS.Spinner[t](this.$form_sections)},this.submit=function(t){var s,n=t.data,l=m.length,i=0,r=[],a=0,c=0;t.preventDefault(),n.processing("start"),n.clear_errors();for(var e=0;e