
try{
jQuery(document).ready(function(){if(jQuery('.wp-2fa-settings-wrapper .notice').length){jQuery('.wp-2fa-settings-wrapper .notice').addClass('wp-2fa-budged');jQuery('.wp-2fa-settings-wrapper .notice').insertBefore('.wp-2fa-settings-wrapper');jQuery('.wp-2fa-budged').css('margin-left','0');}
if(jQuery('#excluded_sites_search').length){const usersUrl=`${wp2faData.ajaxURL}?action=wp_2fa_get_all_network_sites&wp_2fa_nonce=${wp2faData.nonce}`;jQuery('#excluded_sites_search').autocomplete({source:usersUrl,minLength:1,focus:function(){return false;},select:function(event,ui){const currentlyExcluded=jQuery('#excluded_sites').val();if(!currentlyExcluded.includes(ui.item.value)){jQuery('#excluded_sites').val(`${currentlyExcluded + ui.item.value},`);}
const excludedUsersArray=jQuery('#excluded_sites').val().split(',');jQuery('#excluded_sites_buttons').html('');jQuery.each(excludedUsersArray,function(i){if(excludedUsersArray[i]){jQuery('#excluded_sites_buttons').append(`<a class="user-btn button button-secondary" data-user-value="${excludedUsersArray[i]}">${excludedUsersArray[i].split( ':' )[0]}<span class="remove-item">x</span></a>`);}});jQuery('#excluded_sites_search').val('');return false;},open:function(event,ui){jQuery('.ui-menu-item').each(function(i,obj){var originalLabel=jQuery(this).text();jQuery(this).text(originalLabel.split(':')[0]);});}});var excludedUsersArray=jQuery('#excluded_sites').val().split(',');jQuery.each(excludedUsersArray,function(i){if(excludedUsersArray[i]){jQuery('#excluded_sites_buttons').append(`<a class="user-btn button button-secondary" data-user-value="${excludedUsersArray[i]}">${excludedUsersArray[i].split( ':' )[0]}<span class="remove-item">x</span></a>`);}});}
jQuery('body').on('click','.remove-item',function(e){e.preventDefault();var textToRemove=jQuery(this).closest('.user-btn').attr('data-user-value');var textToRemove=`${textToRemove},`;var currentlyExcluded=jQuery(this).closest('div').siblings('input[type="hidden"]').val();var currentlyExcluded=currentlyExcluded.replace(textToRemove,'');jQuery(this).closest('div').siblings('input[type="hidden"]').val(currentlyExcluded);jQuery(this).closest('.user-btn').remove();});jQuery('[name="wp_2fa_policy[enforcement-policy]"], [name="wp_2fa_policy[grace-policy]"]').on("input",function(){if(jQuery('input[name="wp_2fa_policy[grace-policy]"]:checked').val()=='no-grace-period'&&jQuery('input[name="wp_2fa_policy[enforcement-policy]"]:checked').val()=='all-users'){var userToAdd=jQuery('[data-user-login-name]').attr('data-user-login-name');var targetElement=jQuery('#excluded-users-multi-select');if(jQuery('#exclude-self-from-instant-2fa').length&&!jQuery(targetElement).find('option[value="'+userToAdd+'"]').length){var{__}=window.wp.i18n;jQuery('#wp-2fa-exclude-text').html(__('You are about to enforce 2FA instantly on all users, including yourself, however you have not yet configured your own 2FA method. What would you like to do?','wp-2fa'));MicroModal.show('exclude-self-from-instant-2fa');}}});jQuery('#zero-email').on("input",function(){if(jQuery(this).is(':checked')){var userToAdd=jQuery('[data-user-login-name]').attr('data-user-login-name');var targetElement=jQuery('#excluded-users-multi-select');if(jQuery('#exclude-self-from-instant-2fa').length&&!jQuery(targetElement).find('option[value="'+userToAdd+'"]').length){var{__}=window.wp.i18n;jQuery('#wp-2fa-exclude-text').html(__('You are enabling Zero-setup email 2FA. This will enforce 2FA for all users, including your own account, replacing any current 2FA method enabled. That means you will be asked for a one-time code sent by email the next time you log in.','wp-2fa')+'<br><br>'+__('If you don’t want this applied to your account, you can exclude yourself from the 2FA policies before continuing.','wp-2fa')+'<br><br><i>'+__('Note: After closing this prompt, don’t forget to save your settings for the changes to take effect.','wp-2fa')+'</i>');MicroModal.show('exclude-self-from-instant-2fa');}}});jQuery('body').on('click','[data-user-login-name]',function(e){e.preventDefault();var newValue=[];var userToAdd=jQuery('[data-user-login-name]').attr('data-user-login-name');newValue.push(userToAdd);var targetElement=jQuery('#excluded-users-multi-select');if(!jQuery(targetElement).find('option[value="'+newValue+'"]').length){var newState=new Option(newValue,newValue,true,true);jQuery(targetElement).append(newState).trigger('change');}});jQuery('body').on('input','input[type="number"]#grace-period',function(e){var targetElm=jQuery(this);var currentValue=targetElm.val();var newValue=!!currentValue&&0<=Math.abs(currentValue)?Math.abs(currentValue):null;var upperLimit=targetElm.attr('max');if(parseInt(upperLimit)<parseInt(newValue)){newValue=upperLimit;}
if(newValue!=currentValue){targetElm.val(newValue);}});jQuery('body').on('focusout','input[type="number"]#grace-period',function(e){var targetElm=jQuery(this);var currentValue=targetElm.val();var minVal=targetElm.attr('min');if(''===jQuery.trim(currentValue)){targetElm.val(minVal);}});jQuery('body').on('click','input[type="checkbox"]#grace-cron',function(e){if(jQuery(this).is(':checked')){jQuery('.destory-session-setting').removeClass('disabled');}else if(jQuery(this).is(':not(:checked)')){jQuery('.destory-session-setting').addClass('disabled');jQuery('input[type="checkbox"]#destory-session').prop('checked',false);}});if(jQuery('input[type="checkbox"]#grace-cron').is(':checked')){jQuery('.destory-session-setting').removeClass('disabled');}else if(jQuery('input[type="checkbox"]#grace-cron').is(':not(:checked)')){jQuery('.destory-session-setting').addClass('disabled');jQuery('input[type="checkbox"]#destory-session').prop('checked',false);}
jQuery('body').on('click','input[type="radio"][id*="use_custom_page"]',function(e){if(jQuery(this).attr('id').indexOf('dont')&&jQuery(this).is(':checked')){jQuery(this).closest('table').find('.custom-user-page-setting').removeClass('disabled');if(jQuery('#custom-user-page-url').val().trim().length===0){jQuery('#custom-user-page-url').val('/wp-2fa-config/');}}else{jQuery(this).closest('table').find('.custom-user-page-setting').addClass('disabled');if(jQuery('#custom-user-page-url').val().trim().length===0){jQuery('#custom-user-page-url').val('');}}});jQuery('body').on('click','input[type="checkbox"][name*="enable_email"]',function(e){if(jQuery(this).is(':checked')){jQuery(this).parent().parent().find('div.use-different-hotp-mail').removeClass('disabled');}else{jQuery(this).parent().parent().find('div.use-different-hotp-mail').addClass('disabled');}});jQuery('body').on('click','input[type="checkbox"][name*="enable_trusted_devices"]',function(e){if(jQuery(this).is(':checked')){jQuery(this).closest('table').find('.trusted-settings').removeClass('disabled');}else{jQuery(this).closest('table').find('.trusted-settings').addClass('disabled');}});jQuery('body').on('click','input[type="checkbox"][name*="enable_oob_email"]',function(e){if(jQuery(this).is(':checked')){jQuery(this).parent().parent().find('div.use-different-oob-mail').removeClass('disabled');}else{jQuery(this).parent().parent().find('div.use-different-oob-mail').addClass('disabled');}});jQuery('body').on('click','input[type="checkbox"][name*="enable_0_setup_email"]',function(e){if(jQuery(this).is(':checked')){jQuery(this).parent().parent().find('div.zero-setup-email-code-period-wrapper').removeClass('disabled');}else{jQuery(this).parent().parent().find('div.zero-setup-email-code-period-wrapper').addClass('disabled');}});jQuery('body').on('click','.js-button-test-email-trigger',function(e){e.preventDefault();const button=jQuery(this);const emailId=button.attr('data-email-id');const nonceValue=button.attr('data-nonce');button.append('<span class="spinner is-active"></span>');const spinner=button.find('.spinner');button.siblings('.notice').remove();button.attr('disabled','disabled');button.addClass('has-spinner');jQuery.post(wp2faData.ajaxURL,{action:'wp2fa_test_email',email_id:emailId,_wpnonce:nonceValue}).done(function(data){let classes='notice notice-after-button notice-';classes+=(data.success)?'success':'error';var message=(data.success)?wp2faData.email_sent_success:wp2faData.email_sent_failure;if('data'in data){message=data.data;}
button.after(`<span class="${classes}">${message}</span>`);spinner.remove();button.removeClass('has-spinner');button.removeAttr('disabled');});});jQuery('body').on('click','input[type="checkbox"].disabled[data-disabled-hint]',function(e){var text=jQuery(this).attr('data-disabled-hint');jQuery('<p id="setup-warning" style="color: red:>'+text+'</p>').insertAfter(this).delay(2000).remove();});jQuery('.white-labelling-tabs #wp2fa_links-inner-wrapper a').each(function(i){if(window.location.href==jQuery(this).attr('href')){jQuery(this).addClass('nav-tab-active');}else{jQuery(this).removeClass('nav-tab-active');}});jQuery('body').on('click','.notice-success.is-dismissible.wp-2fa-budged .notice-dismiss',function(e){jQuery('.notice-success.is-dismissible.wp-2fa-budged').slideUp();});jQuery('.wp-2fa-email-notice').click(function(){const thisNotice=jQuery(this).closest('.notice');jQuery.ajax({type:'POST',url:wp2faData.ajaxURL,async:true,data:{action:'wp2fa_dismiss_notice_mail_domain',nonce:jQuery('#wp2fa_dismiss_notice_mail_domain').val()},success:function(data){jQuery(thisNotice).slideUp();}});});jQuery('body').on('click','.settings-list li',function(e){const anchor=jQuery(this).find('a');if(anchor.length){window.location=anchor.attr('href');}});jQuery('body').on('keydown','.settings-list li',function(e){if(e.key==='Enter'||e.keyCode===13){const anchor=jQuery(this).find('a');if(anchor.length){window.location=anchor.attr('href');}}});});
}
catch(e){console.error("An error has occurred settings.js: "+e.stack);}

try{
jQuery(document).ready(function(){MicroModal.init();function updateStepTitles(){if(jQuery('[data-step-title]').length){jQuery('.step-title-wrapper').remove();jQuery('.wp2fa-setup-content').prepend('<div class="step-title-wrapper"></div>');var counter=1;jQuery('[data-step-title]:not(.hidden)').each(function(){var stepLabel=jQuery(this).attr('data-step-title');if(jQuery(this).hasClass('active')){jQuery('.step-title-wrapper').append(`<span class="step-title active-step-title"><span>${counter}</span> ${stepLabel}</span>`);}else{jQuery('.step-title-wrapper').append(`<span class="step-title"><span>${counter}</span> ${stepLabel}</span>`);}
counter++;});}
checkWizardOffset();setTimeout(function(){jQuery('.step-setting-wrapper.active input[type="tel"] ').focus();},200);}
updateStepTitles();jQuery('body').on('click','.step-title',function(e){var currentLabel=jQuery(this).text().substr(2);jQuery('[data-step-title]:not(.hidden)').each(function(){var currentStep=jQuery(this);jQuery('[data-step-title]').removeClass('active');jQuery('.step-title').removeClass('active-step-title');var stepLabel=jQuery(this).attr('data-step-title');jQuery(`[data-step-title="${currentLabel}"]`).addClass('active');});updateStepTitles();});jQuery('[data-unhide-when-checked]').each(function(){if(jQuery(this).is(':checked')){const thingToShow=jQuery(this).attr('data-unhide-when-checked');jQuery(thingToShow).show(0);}});jQuery('body').on('click','[for="all-users"], [for="certain-roles-only"]',function(e){jQuery('.step-setting-wrapper.hidden').removeClass('hidden').addClass('un-hidden');updateStepTitles();});jQuery('body').on('click','[for="do-not-enforce"]',function(e){jQuery('.step-setting-wrapper.un-hidden').removeClass('un-hidden').addClass('hidden');updateStepTitles();});jQuery('body').on('click','.modal__btn',function(e){e.preventDefault();});jQuery('body').on('keypress','.wp2fa-modal',function(event){var keycode=(event.keyCode?event.keyCode:event.which);if('13'==keycode){return false;}});jQuery(document).on('click','[data-open-configure-2fa-wizard]',function(event){jQuery(window).off("beforeunload")
event.preventDefault();wp2fa_fireWizard();});jQuery(document).on('click','.step-setting-wrapper.active .option-pill input[type="checkbox"]',function(e){if('backup-codes'!==this.id&&!jQuery(this).hasClass('disabled')){if(true!==jQuery('#geek').prop('checked')&&true!==jQuery('#basic').prop('checked')){jQuery('#backup-codes').addClass('disabled');jQuery('label[for=\'backup-codes\']').addClass('disabled');window.backupCodes=jQuery('#backup-codes').prop('checked');jQuery('#backup-codes').prop('checked',false);if(jQuery('[name="next_step_setting"]').length){jQuery('[name="next_step_setting"]').addClass('disabled').attr('name','next_step_setting_disabled');}}else{jQuery('#backup-codes').removeClass('disabled');jQuery('label[for=\'backup-codes\']').removeClass('disabled');if('undefined'!==window.backupCodes){jQuery('#backup-codes').prop('checked',window.backupCodes);}
if(jQuery('[name="next_step_setting_disabled"]').length){jQuery('[name="next_step_setting_disabled"]').removeClass('disabled').attr('name','next_step_setting');}}}else{if(!jQuery(this).hasClass('disabled')){window.backupCodes=jQuery('#backup-codes').prop('checked');}else{jQuery('#backup-codes').prop('checked',false);}}});jQuery(document).on('click touchend','.radio-cells label, .radio-cells input[type="radio"]',function(e){jQuery('.option-pill').removeClass('isSelected');jQuery('.radio-cells input[type="radio"]:checked').closest('.option-pill').addClass('isSelected');});jQuery('.wizard-tooltip').each(function(){var contentDiv=jQuery(this).attr('data-tooltip-content');var ourItem=jQuery(this);if(jQuery('['+contentDiv+']').length){var content=jQuery('['+contentDiv+']').clone();jQuery(ourItem).append(content);}});jQuery(document).on('click touchend','.wizard-tooltip',function(e){var contentDiv=jQuery(this).attr('data-tooltip-content');var ourItem=jQuery(this);if(jQuery(this).hasClass('isOpen')){jQuery('.inline-helper').slideDown();}else{jQuery('[data-tooltip-content]').removeClass('isOpen');setTimeout(function(){if(jQuery('.inline-helper').length>2){jQuery('.inline-helper').not('['+contentDiv+']').slideUp();}},100);setTimeout(function(){if(jQuery('.inline-helper').length>2){jQuery('.inline-helper').not('['+contentDiv+']').remove();}},600);if(jQuery('['+contentDiv+']').length){var content=jQuery('['+contentDiv+']').html();jQuery('<div class="inline-helper" '+contentDiv+'>'+content+'</div>').insertAfter('.radio-cells');jQuery('.inline-helper').slideDown();}
jQuery(ourItem).addClass('isOpen');}});jQuery(document).on('click','.wp-2fa-method-select input[type="checkbox"]',function(e){let role_suffix=('global'===jQuery(this).data('role'))?'':'-'+jQuery(this).data('role');if('zero-email'+role_suffix===this.id&&true===jQuery(this).prop('checked')){jQuery(this).closest('fieldset#wp-2fa-method-select'+role_suffix).find('div.method-wrapper').each(function(){if(jQuery(this).find('input[type="checkbox"]').length){if('zero-email'+role_suffix!==jQuery(this).find('input[type="checkbox"]').attr('id')){jQuery(this).find('input[type="checkbox"]').prop('checked',false);jQuery(this).find('label').addClass('disabled');}}});jQuery('label[for=backup-codes'+role_suffix+']').removeClass('disabled');if(jQuery('#enable-email-backup'+((''===role_suffix)?'-global':role_suffix)).length){jQuery('#enable-email-backup'+((''===role_suffix)?'-global':role_suffix)).prop('checked',false);jQuery('label[for=enable-email-backup'+((''===role_suffix)?'-global':role_suffix)).addClass('disabled');}}
if('zero-email'+role_suffix===this.id&&false===jQuery(this).prop('checked')){jQuery(this).closest('fieldset#wp-2fa-method-select'+role_suffix).find('div.method-wrapper').each(function(){if(jQuery(this).find('input[type="checkbox"]').length){if('zero-email'+role_suffix!==jQuery(this).find('input[type="checkbox"]').attr('id')){jQuery(this).find('label').removeClass('disabled');}}});if(jQuery('#enable-email-backup'+((''===role_suffix)?'-global':role_suffix)).length){jQuery('label[for=enable-email-backup'+((''===role_suffix)?'-global':role_suffix)).removeClass('disabled');}}
if('backup-codes'+role_suffix!==this.id&&!jQuery(this).hasClass('disabled')){let backDisabled=false;if(true!==jQuery('#totp'+role_suffix).prop('checked')&&true!==jQuery('#hotp'+role_suffix).prop('checked')){backDisabled=true;if(jQuery('#oob'+role_suffix).length){if(true===jQuery('#oob'+role_suffix).prop('checked')){backDisabled=false;}}
if(jQuery('#authy'+role_suffix).length){setTimeout(function(){},2000);if(true===jQuery('#authy'+role_suffix).prop('checked')){backDisabled=false;}}
if(jQuery('#twilio'+role_suffix).length){setTimeout(function(){},2000);if(true===jQuery('#twilio'+role_suffix).prop('checked')){backDisabled=false;}}
if(jQuery('#yubico'+role_suffix).length){setTimeout(function(){},2000);if(true===jQuery('#yubico'+role_suffix).prop('checked')){backDisabled=false;}}
if(jQuery('#zero-email'+role_suffix).length){setTimeout(function(){},2000);if(true===jQuery('#zero-email'+role_suffix).prop('checked')){backDisabled=false;}}
if(jQuery('#passkeys'+role_suffix).length&&true===jQuery('#passkeys'+role_suffix).prop('checked')&&backDisabled===true){jQuery('#enable-email-backup'+role_suffix).addClass('disabled');jQuery('label[for="enable-email-backup'+role_suffix+'"]').addClass('disabled');jQuery('.email-backup-options'+role_suffix).addClass('disabled');}}
if(backDisabled){jQuery('#backup-codes'+role_suffix).addClass('disabled');jQuery('label[for="backup-codes'+role_suffix+'"]').addClass('disabled');window.backupCodes=jQuery('#backup-codes'+role_suffix).prop('checked');jQuery('#backup-codes'+role_suffix).prop('checked',false);jQuery('[for="all-users"], [for="certain-roles-only"]').addClass('disabled');}else{jQuery('[for="all-users"], [for="certain-roles-only"]').removeClass('disabled');jQuery('#backup-codes'+role_suffix).removeClass('disabled');jQuery('label[for="backup-codes'+role_suffix+'"]').removeClass('disabled');if('undefined'!==window.backupCodes){jQuery('#backup-codes'+role_suffix).prop('checked',window.backupCodes);}
jQuery('#enable-email-backup'+role_suffix).removeClass('disabled');jQuery('label[for="enable-email-backup'+role_suffix+'"]').removeClass('disabled');jQuery('.email-backup-options'+role_suffix).removeClass('disabled');}}else{if(!jQuery(this).hasClass('disabled')){window.backupCodes=jQuery('#backup-codes'+role_suffix).prop('checked');}else{jQuery('#backup-codes'+role_suffix).prop('checked',false);}}});jQuery(document).on('click','.wp2fa-setup-form .wp-2fa-method-select input[type="checkbox"]',function(e){let twilio=false;let authy=false;let zero_mail=false;if(jQuery('#twilio').length){if(jQuery('#twilio[data-sid-setup-wizard]').length&&jQuery('#wizard-sid-key').is(':visible')){twilio=false;}else{twilio=jQuery('#twilio').prop('checked');}}
if(jQuery('#authy').length){if(jQuery('#authy[data-api-setup-wizard]').length&&jQuery('#wizard-api-key').is(':visible')){authy=false;}else{authy=jQuery('#authy').prop('checked');}}
if(jQuery('#zero-email').length){zero_mail=jQuery('#zero-email').prop('checked');}
if(true!==jQuery('#totp').prop('checked')&&true!==jQuery('#hotp').prop('checked')&&true!==jQuery('#oob').prop('checked')&&true!==authy&&true!==twilio&&true!==zero_mail){let showAlert=true;if(jQuery(this).is(jQuery('input#authy.disabled'))&&jQuery('#wizard-api-key').is(':visible')){showAlert=false;}
if(jQuery(this).is(jQuery('input#twilio.disabled'))&&jQuery('#wizard-sid-key').is(':visible')){showAlert=false;}
if(showAlert){alert('Please select at least one 2FA method');}
jQuery('button.button[name="next_step_setting"]').prop('disabled',true);jQuery('button.button[name="next_step_setting"]').addClass('disabled');}else{jQuery('button.button[name="next_step_setting"]').prop('disabled',false);jQuery('button.button[name="next_step_setting"]').removeClass('disabled');}});jQuery(document).on('click','[data-close-2fa-modal]',function(e){e.preventDefault();jQuery(window).off("beforeunload");var modalToClose=`#${  jQuery( this ).closest( '.wp2fa-modal' ).attr( 'id' )}`;jQuery(modalToClose).removeClass('is-open').attr('aria-hidden','true');if('reLogin'in wp2faWizardData&&wp2faWizardData.reLoginEnabled==jQuery.trim(wp2faWizardData.reLogin)){jQuery.ajax({type:'POST',url:wp2faData.ajaxURL,data:{action:'custom_ajax_logout',_wpnonce:wp2faWizardData.nonce,},success:function(r){if('loginUrl'in wp2faWizardData&&''!=jQuery.trim(wp2faWizardData.loginUrl)){window.location.replace(wp2faWizardData.loginUrl);}else{window.location.replace('/wp-login.php');}}});}else if('redirectToUrl'in wp2faWizardData&&''!=jQuery.trim(wp2faWizardData.redirectToUrl)){window.location.replace(wp2faWizardData.redirectToUrl);}else{removeShowParam();}});jQuery(document).on('click','[data-close-2fa-modal-and-refresh]',function(e){e.preventDefault();jQuery(window).off("beforeunload");var modalToClose=`#${  jQuery( this ).closest( '.wp2fa-modal' ).attr( 'id' )}`;jQuery(modalToClose).removeClass('is-open').attr('aria-hidden','true');if(jQuery('#wp-2fa-manual-backup-codes-trigger').length){removeShowParam();}else{if('reLogin'in wp2faWizardData&&wp2faWizardData.reLoginEnabled==jQuery.trim(wp2faWizardData.reLogin)){jQuery.ajax({type:'POST',url:wp2faData.ajaxURL,data:{action:'custom_ajax_logout',_wpnonce:wp2faWizardData.nonce,},success:function(r){if('loginUrl'in wp2faWizardData&&''!=jQuery.trim(wp2faWizardData.loginUrl)){window.location.replace(wp2faWizardData.loginUrl);}else{window.location.replace('/wp-login.php');}}});}else if('redirectToUrl'in wp2faWizardData&&''!=jQuery.trim(wp2faWizardData.redirectToUrl)){window.location.replace(wp2faWizardData.redirectToUrl);}else{removeShowParam();}}});jQuery(document).on('click','[data-validate-authcode-ajax]',function(e){e.preventDefault();const thisButton=jQuery(this);let actionToRun='validate_authcode_via_ajax';let authcode=false;if(jQuery('#wp-2fa-totp-authcode').length&&jQuery('#wp-2fa-totp-authcode').val().length){authcode=true;}
if(typeof jQuery(this).data('oob-test')!=='undefined'){actionToRun='validate_oob_authcode_via_ajax';}
const nonceValue=jQuery(this).attr('data-nonce');var values={};jQuery.each(jQuery('.wp-2fa-user-profile-form :input, .wp2fa-modal :input').serializeArray(),function(i,field){values[field.name]=field.value;});const currentPageURL=window.location.href;const form=values;jQuery.ajax({type:'POST',dataType:'json',url:wp2faData.ajaxURL,data:{action:actionToRun,form:values,_wpnonce:nonceValue,},complete:function(data){if(false===data.responseJSON.success){jQuery(thisButton).parent().find('.verification-response').html('<span style="color:red"></span>').find('span').text(data.responseJSON.data['error']);}
if(true===data.responseJSON.success){let nextSubStep=jQuery('#wp-2fa-wizard-config-backup-codes');if(authcode){if(jQuery('#wp-2fa-wizard-backup-methods').length){nextSubStep=jQuery('#wp-2fa-wizard-backup-methods');}else if(jQuery('#wp-2fa-wizard-email-backup-selected').length){nextSubStep=jQuery('#wp-2fa-wizard-email-backup-selected');}}
jQuery(this).parent().parent().find('.active').not('.step-setting-wrapper').removeClass('active');jQuery('.wizard-step.active').removeClass('active');jQuery(nextSubStep).addClass('active');jQuery(document).on('click','#select-backup-method',function(e){e.preventDefault();var backupRadio=jQuery("input[name=backup_method_select]:checked");jQuery('.wizard-step.active').removeClass('active');jQuery('#'+backupRadio.data('step')).addClass('active');});jQuery(document).on('click','[name="save_step"], [data-close-2fa-modal]',function(){if('reLogin'in wp2faWizardData&&wp2faWizardData.reLoginEnabled==jQuery.trim(wp2faWizardData.reLogin)){jQuery.ajax({type:'POST',url:wp2faData.ajaxURL,data:{action:'custom_ajax_logout',_wpnonce:nonceValue,},success:function(r){if('loginUrl'in wp2faWizardData&&''!=jQuery.trim(wp2faWizardData.loginUrl)){window.location.replace(wp2faWizardData.loginUrl);}else{window.location.replace('/wp-login.php');}}});}else{if('redirectToUrl'in wp2faWizardData&&''!=jQuery.trim(wp2faWizardData.redirectToUrl)){window.location.replace(wp2faWizardData.redirectToUrl);}else{removeShowParam();}}});}}},);});jQuery('body').on('click','.contains-hidden-inputs input[type="radio"]',function(e){if(jQuery(this).hasClass('js-nested')){return;}
jQuery(this).closest('.contains-hidden-inputs').find('.hidden').hide(200);if(jQuery(this).is('[data-unhide-when-checked]')){const thingToShow=jQuery(this).attr('data-unhide-when-checked');if(jQuery(this).is(':checked')){jQuery(thingToShow).slideDown(200);}}});jQuery(document).on('click','.dismiss-user-reconfigure-nag',function(){const thisNotice=jQuery(this).closest('.notice');jQuery.ajax({url:wp2faData.ajaxURL,data:{action:'wp2fa_dismiss_reconfigure_nag',nonce:wp2faData.dismissNonce},complete:function(data){jQuery(thisNotice).slideUp();},});});jQuery(document).on('click','[data-trigger-account-unlock]',function(){const nonce=jQuery(this).attr('data-nonce');const account=jQuery(this).attr('data-account-to-unlock');jQuery.ajax({url:wp2faData.ajaxURL,data:{action:'unlock_account',user_id:account,wp_2fa_nonce:nonce}});});jQuery(document).on('click','.remove-2fa',function(e){e.preventDefault();});jQuery('body').on('click','#wp-2fa-wizard-totp .button[name="next_step_setting"]',function(e){e.preventDefault;const currentSubStep=jQuery(this).closest('.step-setting-wrapper.active');const nextSubStep=jQuery(currentSubStep).nextAll('div:not(.hidden)').filter(':first');jQuery(currentSubStep).removeClass('active');jQuery(nextSubStep).addClass('active');updateStepTitles();});jQuery('body').on('click','.wp2fa-first-time-wizard .button[name="next_step_setting"]',function(e){e.preventDefault;const currentSubStep=jQuery(this).closest('.step-setting-wrapper.active');const nextSubStep=jQuery(currentSubStep).nextAll('div:not(.hidden)').filter(':first');jQuery(currentSubStep).removeClass('active');jQuery(nextSubStep).addClass('active');updateStepTitles();});jQuery(document).on('click','.modal_logout',function(e){e.preventDefault();if(jQuery('#confirm-logout').length){MicroModal.show('confirm-logout');jQuery('.button-confirm-logout').blur();}});jQuery(document).on('click touchend','.button-confirm-logout',function(e){e.preventDefault();jQuery.ajax({type:'POST',url:wp2faData.ajaxURL,data:{action:'wp2fa_logout_account',_wpnonce:jQuery('.modal_logout').data('nonce'),},complete:function(data){location.reload();},});});jQuery(document).on('click','.modal_cancel',function(e){e.preventDefault();if(jQuery('#notify-users').length){MicroModal.show('notify-users');jQuery('.button-confirm').blur();}});jQuery(document).on('click touchend','.button-confirm',function(e){e.preventDefault();MicroModal.close('configure-2fa');MicroModal.close('notify-users');jQuery('.inline-helper').remove();if('reLogin'in wp2faWizardData&&wp2faWizardData.reLoginEnabled==jQuery.trim(wp2faWizardData.reLogin)){jQuery.ajax({type:'POST',url:wp2faData.ajaxURL,data:{action:'custom_ajax_logout',_wpnonce:wp2faWizardData.nonce,},success:function(r){if('redirectToUrl'in wp2faWizardData&&''!=jQuery.trim(wp2faWizardData.redirectToUrl)){window.location.replace(wp2faWizardData.redirectToUrl);}else{removeShowParam();}}});}else{removeShowParam();}});jQuery(document).on('click touchend','.button-decline',function(e){e.preventDefault();});jQuery(document).on('click','#close-settings',function(e){e.preventDefault();MicroModal.close('notify-admin-settings-page');window.location.replace(jQuery(this).data('redirect-url'));});jQuery(document).on('click','.first-time-wizard',function(e){e.preventDefault();MicroModal.show('notify-admin-settings-page');});jQuery(document).on('click','[data-trigger-remove-2fa]',function(){const nonce=jQuery(this).attr('data-nonce');const account=jQuery(this).attr('data-user-id');jQuery.ajax({url:wp2faData.ajaxURL,data:{action:'remove_user_2fa',user_id:account,wp_2fa_nonce:nonce},complete:function(data){location.reload();},});});jQuery(document).on('click','[data-trigger-remove-2fa-backup-email]',function(){const nonce=jQuery(this).attr('data-nonce');const account=jQuery(this).attr('data-user-id');jQuery.ajax({url:wp2faData.ajaxURL,data:{action:'remove_backup_email',user_id:account,wp_2fa_nonce:nonce},complete:function(data){location.reload();},});});jQuery(document).on('click','[data-submit-2fa-form]',function(e){jQuery('#submit').click();});function validateEmail(email){var re=/\S+@\S+\.\S+/;return re.test(email);}
jQuery(document).on('click','[data-trigger-setup-email]',function(e){let actionToRun='send_authentication_setup_email';var emailAddress=false;var inputUsed='';if(jQuery('#use_custom_email').prop('checked')){emailAddress=jQuery('#custom-email-address').val();inputUsed=jQuery('#custom-email-address');}else{emailAddress=null;inputUsed=jQuery('#use_wp_email');}
if(typeof jQuery(this).data('oob-test')!=='undefined'){actionToRun='send_authentication_oob_setup_email';emailAddress=jQuery('#use_wp_oob_email').val();if(jQuery('#use_custom_oob_email').prop('checked')){emailAddress=jQuery('#custom-oob-email-address').val();inputUsed=jQuery('#custom-oob-email-address');}}
if(null!==emailAddress)
if(!validateEmail(emailAddress)||false==emailAddress){e.preventDefault();let errMsg=jQuery('#wp-2fa-error-msg');if(errMsg.length){errMsg.remove();}
if(jQuery(this).hasClass('resend-email-code')){if(jQuery('#wp-2fa-email-authcode').is(":visible")){inputUsed=jQuery('#wp-2fa-email-authcode');}else if(jQuery('#wp-2fa-oob-authcode').is(":visible")){inputUsed=jQuery('#wp-2fa-oob-authcode');}}
jQuery('<span id="wp-2fa-error-msg" style="color:red;">'+wp2faData.invalidEmail+'</span>').insertAfter(inputUsed);return false;}
if(jQuery(this).hasClass('resend-email-code')){var updateBtnText=true;var originalBtnText=jQuery(this).text();if(jQuery('#wp-2fa-email-authcode').is(":visible")){inputUsed=jQuery('#wp-2fa-email-authcode');}else if(jQuery('#wp-2fa-oob-authcode').is(":visible")){inputUsed=jQuery('#wp-2fa-oob-authcode');}}else{const currentSubStep=jQuery(this).closest('.step-setting-wrapper.active');const nextSubStep=currentSubStep.nextAll('div:not(.hidden)').filter(':first');jQuery(currentSubStep).removeClass('active');nextSubStep.addClass('active');updateStepTitles();}
const userID=jQuery(this).attr('data-user-id');const nonce=jQuery(this).attr('data-nonce');const thisBtn=jQuery(this);jQuery.ajax({type:'POST',dataType:'json',url:wp2faData.ajaxURL,data:{action:actionToRun,email_address:emailAddress,user_id:userID,nonce:nonce},error:function(jqXHR,textStatus,errorThrown){if(false===jqXHR.responseJSON.success){let errMsg=jQuery('#wp-2fa-error-msg');if(errMsg.length){errMsg.remove();}
jQuery('<span id="wp-2fa-error-msg" style="color:red;">'+jqXHR.responseJSON.data[0].message+'</span>').insertAfter(inputUsed);}},complete:function(data){},success:function(data){let errMsg=jQuery('#wp-2fa-error-msg');if(errMsg.length){errMsg.remove();}
if(updateBtnText){jQuery(thisBtn).find('span').fadeTo(100,0,function(){jQuery(thisBtn).find('span').delay(100);jQuery(thisBtn).find('span').text(wp2faWizardData.codeReSentText);jQuery(thisBtn).find('span').fadeTo(100,1);});setTimeout(function(){jQuery(thisBtn).find('span').fadeTo(100,0,function(){jQuery(thisBtn).find('span').delay(100);jQuery(thisBtn).find('span').text(originalBtnText);jQuery(thisBtn).find('span').fadeTo(100,1);});},2500);}}});});jQuery(document).on('change','[name="wp_2fa_enabled_methods"]',function(event){var step=jQuery('[name="wp_2fa_enabled_methods"]:checked').val();if(undefined===step){jQuery('.wp-2fa-choose-method[data-name]').removeAttr('data-next-step');}else{jQuery('.wp-2fa-choose-method[data-name]').attr('data-next-step',`wp-2fa-wizard-${step}`);}});jQuery('body').on('click','.button[data-name="next_step_setting_modal_wizard"]',function(e){e.preventDefault;var nextStep=jQuery(this).attr('data-next-step');if(undefined===nextStep){var nextStep='wp-2fa-wizard-'+jQuery('[name="wp_2fa_enabled_methods"]:checked').val();jQuery('.wp-2fa-choose-method[data-name]').attr('data-next-step',`wp-2fa-wizard-${nextStep}`);}
if(nextStep){const currentSubStep=jQuery(this).parent().parent().find('.active').not('.step-setting-wrapper');const nextSubStep=jQuery(`#${nextStep}`);jQuery(this).parent().parent().find('.active').not('.step-setting-wrapper').removeClass('active');jQuery('.wizard-step.active').removeClass('active');jQuery(nextSubStep).addClass('active');var in_el=jQuery(nextSubStep).find("input[type=text]");if(!in_el.length){in_el=jQuery(nextSubStep).find("input[type=password]");}
if(in_el.length){in_el.focus();}}else{const currentSubStep=jQuery(this).parent().parent().find('.active').not('.step-setting-wrapper');const nextSubStep=jQuery(currentSubStep).next();jQuery('.wizard-step.active').removeClass('active');jQuery(nextSubStep).addClass('active');}
jQuery('.inline-helper').remove();});jQuery('body').on('click','.button[data-trigger-generate-backup-codes]',function(e){e.preventDefault();const actionToRun='wp2fa_run_ajax_generate_json';const nonceValue=jQuery(this).attr('data-nonce');const currentSubStep=jQuery(this).closest('.step-setting-wrapper.active');const nextSubStep=jQuery(currentSubStep).nextAll('div:not(.hidden)').filter(':first');jQuery(currentSubStep).removeClass('active');jQuery(nextSubStep).addClass('active');updateStepTitles();jQuery.ajax({type:'POST',dataType:'json',url:wp2faData.ajaxURL,data:{action:actionToRun,_wpnonce:nonceValue},complete:function(data){jQuery('#backup-codes-wrapper').slideUp(0);jQuery('.wp2fa-modal.is-open #backup-codes-wrapper, .wp2fa-setup-content #backup-codes-wrapper').val('');var codes=jQuery.parseJSON(data.responseText);var codes=codes.data['codes'];jQuery.each(codes,function(index,value){var oldValue=jQuery('.wp2fa-modal.is-open #backup-codes-wrapper, .wp2fa-setup-content #backup-codes-wrapper').val();var counter=index+1;jQuery('.wp2fa-modal.is-open #backup-codes-wrapper, .wp2fa-setup-content #backup-codes-wrapper').val(oldValue+counter+': '+`${value} \n`);});jQuery('#backup-codes-wrapper').slideDown(500);jQuery('.close-wizard-link').text(wp2faWizardData.readyText).fadeIn(50);}},);});jQuery('body').on('click','.button[data-trigger-reset-key]',function(e){e.preventDefault();if(jQuery('.qr-code-wrapper').length){jQuery('.qr-code-wrapper').addClass('regenerating');}
var doReload=jQuery(this).attr('data-trigger-reset-key');const thisButton=jQuery(this);const actionToRun='regenerate_authentication_key';const nonceValue=jQuery(this).attr('data-nonce');const userID=jQuery(this).attr('data-user-id');jQuery.ajax({type:'POST',dataType:'json',url:wp2faData.ajaxURL,data:{action:actionToRun,_wpnonce:nonceValue,user_id:userID},complete:function(data){if(jQuery('.change-2fa-confirm.hidden').length){jQuery('.change-2fa-confirm.hidden').trigger('click');}
if(jQuery('.app-key').length){jQuery('#wp-2fa-totp-qrcode').attr('src',data.responseJSON.data['qr']);jQuery('.app-key').val(data.responseJSON.data['key']);jQuery('[name="wp-2fa-totp-key"]').val(data.responseJSON.data['key']);setTimeout(function(){jQuery('.qr-code-wrapper').removeClass('regenerating');},500);}}},);});jQuery('body').on('click','.button[data-trigger-backup-code-email]',function(e){e.preventDefault();const thisButton=jQuery(this);const actionToRun='send_backup_codes_email';const nonceValue=jQuery(this).attr('data-nonce');const userID=jQuery(this).attr('data-user-id');const codesWrapper=JSON.stringify(jQuery('.active #backup-codes-wrapper').val());jQuery.ajax({type:'POST',dataType:'json',url:wp2faData.ajaxURL,data:{action:actionToRun,_wpnonce:nonceValue,user_id:userID,codes:codesWrapper},complete:function(data){jQuery('.button[data-trigger-backup-code-email]').text(wp2faWizardData.backupCodesSent).attr('value',wp2faWizardData.backupCodesSent);}},);});jQuery('body').on('click','.click-to-copy',function(e){var copyText=jQuery(this).prev();var{__}=window.wp.i18n;copyText.select();if(typeof copyText.setSelectionRange!=="undefined"){copyText.setSelectionRange(0,99999);}
navigator.clipboard.writeText(copyText[0].value);jQuery(this).addClass('done').html(window.wp.i18n.__('Copied','wp-2fa'));});jQuery('body').on('click','.button[data-trigger-backup-code-copy]',function(e){e.preventDefault();var{__}=window.wp.i18n;var copyText=jQuery('.active #backup-codes-wrapper');copyText.select();if(typeof copyText.setSelectionRange!=="undefined"){copyText.setSelectionRange(0,99999);}
navigator.clipboard.writeText(copyText[0].value);jQuery(this).addClass('done').html(window.wp.i18n.__('Copied','wp-2fa'));});jQuery('body').on('click','.button[data-trigger-backup-code-download]',function(e){e.preventDefault();const userName=jQuery(this).attr('data-user');const websiteURL=jQuery(this).attr('data-website-url');const preamble=`${wp2faWizardData.codesPreamble} ${userName} on the website ${websiteURL}:\n\n`;var codesWrapper=jQuery('.active #backup-codes-wrapper').val().split(' ').join('\n');download('backup_codes.txt',preamble+codesWrapper);});jQuery('body').on('click','.button[data-trigger-print]',function(e){e.preventDefault();const userName=jQuery(this).attr('data-user-id');const websiteURL=jQuery(this).attr('data-website-url');const preamble=`${wp2faWizardData.codesPreamble} ${userName} on the website ${websiteURL}:\n\n`;const divToPrint=jQuery('.active #backup-codes-wrapper').val();const newWin=window.open('','Print-Window');newWin.document.open();const doc=newWin.document;doc.write('<html><body onload="window.print()"></body></html>');const pre=doc.createElement('pre');pre.textContent=preamble+'\n\n'+divToPrint;doc.body.appendChild(pre);newWin.document.close();setTimeout(function(){newWin.close();},10);});function download(filename,text){const element=document.createElement('a');element.setAttribute('href',`data:text/plain;charset=utf-8,${encodeURIComponent( text )}`);element.setAttribute('download',filename);element.style.display='none';document.body.appendChild(element);element.click();document.body.removeChild(element);}
jQuery(document).on('click','#custom-email-address',function(){jQuery('#use_custom_email').prop('checked',true);});jQuery(document).on('click','#custom-oob-email-address',function(){jQuery('#use_custom_oob_email').prop('checked',true);});jQuery(document).on('click','[data-check-on-click]',function(){const thingToCheck=jQuery(this).attr('data-check-on-click');jQuery(thingToCheck).prop('checked',true);});jQuery(document).on('click','[data-trigger-submit-form]',function(e){e.preventDefault();const thingToSubmit=jQuery(this).attr('data-trigger-submit-form');jQuery('.change-2fa-confirm').trigger('click');});jQuery(document).on('click','[data-reload]',function(e){removeShowParam();});window.removeShowParam=function(){let url=new URL(location.href);let params=new URLSearchParams(url.search);params.delete('show');location.replace(`${location.pathname}?${params}`);}
jQuery('[name="wp_2fa_settings[enforcement-policy]"]').on("input",function(){if(jQuery('input[name="wp_2fa_settings[enforcement-policy]"]:checked').val()!=='do-not-enforce'){jQuery('[data-step-title="Exclude users"]').removeClass('hidden');updateStepTitles();}else{jQuery('[data-step-title="Exclude users"]').addClass('hidden');updateStepTitles();}});jQuery('body').on('click','.iti__flag-container',function(e){var isExpand=(jQuery('.iti__selected-flag').attr('aria-expanded'))?'expand-panel':'';jQuery(this).closest('.wizard-step.active').toggleClass(isExpand);});jQuery('body').on('click','.step-setting-wrapper #all-users, .step-setting-wrapper #certain-roles-only',function(e){jQuery('.step-setting-wrapper.active .continue-wizard').removeClass('hidden');jQuery('.step-setting-wrapper.active .save-wizard').addClass('hidden');});jQuery('body').on('click','.step-setting-wrapper #do-not-enforce',function(e){jQuery('.step-setting-wrapper.active .continue-wizard').addClass('hidden');jQuery('.step-setting-wrapper.active .save-wizard').removeClass('hidden');});});window.onresize=function(){checkWizardOffset();}
function checkWizardOffset(){var elem=document.querySelector('.setup-wizard-wrapper');if(elem){var bounding=elem.getBoundingClientRect();if(bounding.top<0){var clientHeight=bounding.height / 2;elem.style.cssText+='top: '+clientHeight+'px';}}}
window.wp2fa_fireWizard=function(){jQuery('.verification-response span').remove();jQuery('#configure-2fa .wizard-step.active, #configure-2fa .step-setting-wrapper.active').removeClass('active');jQuery('#configure-2fa .wizard-step:first-of-type, #configure-2fa .step-setting-wrapper:first-of-type').addClass('active');jQuery('.modal__content input:not([type="radio"]):not([type="hidden"])').not('.app-key').val('');MicroModal.show('configure-2fa');if(jQuery('input#basic').is(':visible')){jQuery('input#basic').trigger("click");}else{if(jQuery('input#geek').is(':visible')){jQuery('input#geek').trigger("click");}else{if(jQuery('input#oob').length){jQuery('input#oob').trigger("click");}else if(jQuery('input#authy').length){jQuery('input#authy').trigger("click");}else if(jQuery('input#twilio').length){jQuery('input#twilio').trigger("click");}}}
jQuery('[name="wp_2fa_enabled_methods"]').change();if(1===jQuery('.wizard-step.active .option-pill').length){jQuery('#configure-2fa .wizard-step:first-of-type, #configure-2fa input:radio[name=wp_2fa_enabled_methods]:first').attr("checked",true);setTimeout(()=>{jQuery('.wp-2fa-button-primary.wp-2fa-choose-method').trigger("click");},100)}else{jQuery('#configure-2fa .wizard-step:first-of-type, #configure-2fa input:radio[name=wp_2fa_enabled_methods]:first').prop("checked",true);jQuery('[name="wp_2fa_enabled_methods"]').change();jQuery('#configure-2fa .wizard-step:first-of-type, #configure-2fa input:radio[name=wp_2fa_enabled_methods]:first').trigger("click");}};
}
catch(e){console.error("An error has occurred common.js: "+e.stack);}

try{
jQuery(function(){const select2Autocomplete=function(source,functionName){jQuery(source).select2({width:'resolve',ajax:{url:`${wp2faData.ajaxURL}?wp_2fa_nonce=${wp2faData.nonce}`,dataType:'json',delay:250,data:function(params){return{term:params.term,action:functionName};},processResults:function(data){var exclData=[];if(source==='#excluded-users-multi-select'){exclData=jQuery('#enforced_users-multi-select').val();}else if(source==='#enforced_users-multi-select'){exclData=jQuery('#excluded-users-multi-select').val();}else if(source==='#excluded-roles-multi-select'){exclData=jQuery('#enforced-roles-multi-select').val();}else if(source==='#enforced-roles-multi-select'){exclData=jQuery('#excluded-roles-multi-select').val();}else if(source==='#excluded-sites-multi-select'){exclData=jQuery('#enforced-sites-multi-select').val();}else if(source==='#enforced-sites-multi-select'){exclData=jQuery('#excluded-sites-multi-select').val();}
const options=[];if(data.data){jQuery.each(data.data,function(index,text){if(exclData.indexOf(text['label'])===-1){options.push({id:text['label'],text:text['value']});}});}
return{results:options};},cache:true},minimumInputLength:2});};if(jQuery('#excluded-users-multi-select').length){select2Autocomplete('#excluded-users-multi-select','wp_2fa_get_all_users');}
if(jQuery('#enforced_users-multi-select').length){select2Autocomplete('#enforced_users-multi-select','wp_2fa_get_all_users');}
if(jQuery('#excluded-roles-multi-select').length){select2Autocomplete('#excluded-roles-multi-select','wp_2fa_get_all_roles');}
if(jQuery('#enforced-roles-multi-select').length){select2Autocomplete('#enforced-roles-multi-select','wp_2fa_get_all_roles');}
if(jQuery('#excluded-sites-multi-select').length){select2Autocomplete('#excluded-sites-multi-select','wp_2fa_get_all_network_sites');}
if(jQuery('#enforced-sites-multi-select').length){select2Autocomplete('#enforced-sites-multi-select','wp_2fa_get_all_network_sites');}});
}
catch(e){console.error("An error has occurred select2control.js: "+e.stack);}
