!function(e,s){"use strict";ElementsKit_Helper.registerWidget("elementskit-login-form.default",(function(s){let t=s.find(".ekit-login-form-wrapper"),o=t.find(".ekit-login-form"),r=(o.find(".ekit-login-form-button"),t.find(".ekit-login-lost-password")),i=t.find(".ekit-login-form-links"),n=t.find(".ekit-login-lost-password-form"),a=t.find(".ekit-lost-password-form-back"),d=t.find(".ekit-lost-password-message"),l=t.find(".ekit-login-error-message");const c=window.ekit_config?.ajaxurl||null;t.find(".ekit-login-form-password-toggle").each((function(){let s=e(this),o=s.data("target"),r=t.find("#"+o);s.off("click").on("click",(function(){if(!r.length)return;let e="password"===r.attr("type");r.attr("type",e?"text":"password"),s.toggleClass("is-active",e),s.attr("aria-label",e?"Hide password":"Show password"),s.find(".ekit-eye").toggle(!e),s.find(".ekit-eye-off").toggle(e)}))})),o.on("submit",(function(t){t.preventDefault();const r=e(this);let i=r.find(".ekit-login-error-message"),a=r.find(".ekit-login-form-button"),d=r.find('input[name="log"]').val(),l=r.find('input[name="pwd"]').val(),f=r.find('input[name="rememberme"]').is(":checked"),m=r.find('input[name="redirect_to"]').val();d&&l?(i.length&&i.html("").removeClass("error success").addClass("hidden"),a.prop("disabled",!0).css("cursor","not-allowed"),a.prop("disabled",!0),e.ajax({url:c,type:"POST",data:{action:"ekit_login_form",log:d,pwd:l,rememberme:f?1:0,redirect_to:m,security:window.ekit_config?.nonce||""},success:function(e){e.success?(i.length&&i.html(e.data.message).removeClass("hidden error").addClass("success"),e.data.redirect_url&&setTimeout((function(){window.location.href=e.data.redirect_url}),1e3)):i.length&&(i.html(e.data?.message||"Login failed. Please try again.").removeClass("hidden success").addClass("error"),s.find(".ekit-login-lost-password").on("click",(function(e){e.preventDefault(),o.hide(),n.show()})))},error:function(){i.length&&i.html(window.ekit_config?.errorMessage||"An error occurred. Please try again.").removeClass("hidden success").addClass("error")},complete:function(){a.prop("disabled",!1)}})):i.length&&i.html("Please enter both username and password.","elementskit").removeClass("hidden success").addClass("error")})),r.on("click",(function(e){e.preventDefault(),o.hide(),n.show(),i.hide()})),a.on("click",(function(e){e.preventDefault(),n.hide(),o.show(),i.show(),l.html("").removeClass("error").addClass("hidden"),d.html("").removeClass("error success").addClass("hidden")})),s.find("#ekit-lost-password-form").on("submit",(function(t){t.preventDefault();const o=e(this),r=o.find(".ekit-lost-password-message"),i=o.find(".ekit-lost-password-button"),n=o.find("#user_login_recover").val();n?(r.html("").removeClass("error success").addClass("hidden"),i.prop("disabled",!0),e.ajax({url:c,type:"POST",data:{action:"ekit_lost_password",user_login:n,security:window.ekit_config?.nonce||""},success:function(e){e.success?(r.html(e.data.message).removeClass("hidden error").addClass("success"),o[0].reset(),setTimeout((function(){s.find(".ekit-login-lost-password-form").hide(),s.find(".ekit-login-form").show(),r.html("").addClass("hidden")}),3e3)):r.html(e.data?.message||"Failed to process request. Please try again.").removeClass("hidden success").addClass("error")},error:function(){r.html(window.ekit_config?.errorMessage||"An error occurred. Please try again.").removeClass("hidden success").addClass("error")},complete:function(){i.prop("disabled",!1)}})):r.html(__("Please enter a username or email address.","elementskit")).removeClass("hidden success").addClass("error")}))}))}(jQuery,window.elementorFrontend);