jQuery(document).ready(function(e){function a(){e("#dina-resend-code-btn").attr("aria-disabled","true").addClass("disabled");const a=parseInt(e("#dina-resend-code-btn").data("time"));clearInterval(n);const s=Date.now()+a;n=setInterval(()=>{const a=Date.now(),t=s-a;if(t>0){const a=`${Math.floor(t/1e3/60)}:${Math.floor(t%6e4/1e3)}`;e("#dina-code-timer").html(a)}else clearInterval(n),e("#dina-code-timer").html("").addClass("fal fa-sync"),e("#dina-resend-code-btn").removeAttr("aria-disabled").removeClass("disabled")},500),e(".dina-auto-submit").on("input change",function(){let a=e(this).val(),n=parseInt(e(this).attr("maxlength"),10);a.length>=n&&e("#registerNumberToken").click()}),"OTPCredential"in window&&navigator.credentials.get({otp:{transport:["sms"]}}).then(function(a){e("input.dina-otp:visible").val(a.code).trigger("input")}).catch(function(e){console.warn("OTP Autofill error:",e)})}var n;e(document).on("submit","form#dina_force_number_form",function(n){var s=e(this);z=s.parents(".dina-ajax-form-wrapper"),s.find("#registerNumberMobile").attr("aria-disabled","true").addClass("disabled"),s.find("#registerNumberMobile .fal").removeClass("fa-mobile").addClass("fa-spinner-third fa-spin"),s.find("div.status").removeClass(function(e,a){return(a.match(/(^|\s)woocommerce-\S+/g)||[]).join(" ")}),s.find("div.status").show().text(ajax_force_number_object.loadingmessage).addClass("woocommerce-info"),e.ajax({type:"POST",dataType:"json",url:ajax_force_number_object.ajaxurl,data:{action:"force_number_popup_action",phonenumber:s.find("#mobile_number").val(),userid:s.find("input[name=user_id]").val(),security:s.find("#force_mobile_number").val()},success:function(n){s.find("div.status").removeClass(function(e,a){return(a.match(/(^|\s)woocommerce-\S+/g)||[]).join(" ")}),s.find("#registerNumberMobile").removeAttr("aria-disabled").removeClass("disabled"),s.find("#registerNumberMobile .fal").removeClass("fa-spinner-third fa-spin").addClass("fa-mobile"),s.find("div.status").text(n.message).addClass(n.class),1==n.success&&e(".dina-ajax-form-wrapper").html(n.token_form)&&z.find("input[name='otp-code']").focus()&&a()&&e(".dina-ajax-form-wrapper div.status").text(n.message).addClass(n.class)}}),n.preventDefault()}),e(document).on("submit","form#dina_force_token_form",function(a){var n=e(this),s=n.find("input[name='otp-code']").val();n.find("#registerNumberToken").attr("aria-disabled","true").addClass("disabled"),n.find("#registerNumberToken .fal").removeClass("fa-mobile").addClass("fa-spinner-third fa-spin"),n.find("div.status").removeClass(function(e,a){return(a.match(/(^|\s)woocommerce-\S+/g)||[]).join(" ")}),n.find("div.status").show().text(ajax_force_number_token_object.loadingmessage).addClass("woocommerce-info"),e.ajax({type:"POST",dataType:"json",url:ajax_force_number_token_object.ajaxurl,data:{action:"force_number_token_action",token:s,userid:n.find("input[name=user_id]").val(),phonenumber:n.find("input[name=phone_number]").val(),security:n.find("#force_mobile_number_token").val()},success:function(e){n.find("div.status").removeClass(function(e,a){return(a.match(/(^|\s)woocommerce-\S+/g)||[]).join(" ")}),n.find("#registerNumberToken").removeAttr("aria-disabled").removeClass("disabled"),n.find("#registerNumberToken .fal").removeClass("fa-spinner-third fa-spin").addClass("fa-mobile"),n.find(".dina-otp-input").removeClass("is-valid is-invalid").addClass(e.inputclass),n.find("div.status").text(e.message).addClass(e.class),1==e.success?document.location.href=ajax_force_number_token_object.current:n.find("input[name='otp-code']").val("")&&n.find("input[name='otp-code']").focus()}}),a.preventDefault()}),e(document).on("click","#dina-resend-code-btn:not(.disabled)",function(n){var s=e(this),t=s.parents("form");e(".dina-otp-input").val(""),s.find(".dina-otp-input").focus(),s.attr("aria-disabled","true").addClass("disabled"),s.find("span").removeClass("fal fa-sync").addClass("fal fa-spinner-third fa-spin"),t.find("div.status").removeClass(function(e,a){return(a.match(/(^|\s)woocommerce-\S+/g)||[]).join(" ")}),t.find("div.status").show().text(ajax_force_resend_token_object.loadingmessage).addClass("woocommerce-info"),e.ajax({type:"POST",dataType:"json",url:ajax_force_resend_token_object.ajaxurl,data:{action:"force_resend_token_action",userid:t.find("input[name=user_id]").val(),phonenumber:t.find("input[name=phone_number]").val(),security:t.find("#force_resend_token").val()},success:function(e){t.find("div.status").removeClass(function(e,a){return(a.match(/(^|\s)woocommerce-\S+/g)||[]).join(" ")}),s.find("span").removeClass("fal fa-spinner-third fa-spin"),t.find("div.status").text(e.message).addClass(e.class),a()}}),n.preventDefault()})});