/**
 * JavaScript for Iron Security 2FA login functionality
 */
(function($) {
    'use strict';

    $(document).ready(function() {
        // Check if we need to show 2FA field on login form
        $('#user_login, #user_pass').on('change', function() {
            const username = $('#user_login').val();
            
            if (!username) {
                return;
            }
            
            $.ajax({
                url: ajaxurl,
                type: 'POST',
                data: {
                    action: 'iron_security_check_2fa_required',
                    username: username,
                    nonce: ironSecurity2FA.nonce
                },
                success: function(response) {
                    if (response.success && response.data.required) {
                        $('#iron-security-2fa-field').show();
                    } else {
                        $('#iron-security-2fa-field').hide();
                    }
                }
            });
        });
    });

})(jQuery); 