(function() {
    'use strict';

    function initLoginForms() {
        var forms = document.querySelectorAll('.guard-dog-login-form__form');

        forms.forEach(function(form) {
            form.addEventListener('submit', function() {
                var wrapper = form.closest('.guard-dog-login-form');
                var submitButton = form.querySelector('.guard-dog-login-form__submit');

                if (wrapper) {
                    wrapper.classList.add('is-submitting');
                }

                if (submitButton) {
                    submitButton.disabled = true;
                    submitButton.setAttribute('aria-busy', 'true');
                }
            });
        });
    }

    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', initLoginForms);
    } else {
        initLoginForms();
    }
})();
