/* Minification failed. Returning unminified contents.
(34,32-33): run-time error JS1195: Expected expression: >
(44,1-2): run-time error JS1002: Syntax error: }
(46,29-30): run-time error JS1195: Expected expression: >
(59,1-2): run-time error JS1002: Syntax error: }
(61,40-41): run-time error JS1004: Expected ';': {
(62,37-38): run-time error JS1195: Expected expression: >
(65,6-7): run-time error JS1195: Expected expression: )
(67,1-5): run-time error JS1034: Unmatched 'else'; no 'if' defined: else
(67,29-30): run-time error JS1004: Expected ';': {
(68,37-38): run-time error JS1195: Expected expression: >
(71,6-7): run-time error JS1195: Expected expression: )
 */
$required = $("input[data-val-required], textarea[data-val-required], select[data-val-required], checkbox[data-val-required],radio[data-val-required]");
$.each($required, function (b) {
    var a = $(this).attr("id");
    a = $("label[for\x3d" + a + "]");
    a.addClass("nch-required-label");
    "checkbox" == $(this).attr("type") && (a = $(this).parent(),
        $nchthischeck = $(this).attr("data-val-ischecked"),
        $nchparentlabel = a.prevAll("label").first(),
        $nchthischeck && ($nchparentlabel.parent().is("div.list")
            ? a.prevAll("label").first().addClass("nch-required-label")
            : $(this).closest("label").addClass("nch-required-label")));
    "radio" == $(this).attr("type") && (a = $(this).parent(),
        a.prevAll("label").first().addClass("nch-required-label"));
    1 === b && $(this).closest("form").append("\x3cp\x3eAll fields marked with \x3cspan style\x3d'color:red;'\x3e*\x3c/span\x3e are required\x3c/p\x3e")
});;
$(document).ajaxStart(function () {
    var activeElement = $(document.activeElement);

    if ($(activeElement).hasClass("SitecoreFormsSubmit")) {        
        $(activeElement).prop("disabled", true)
            .prop("value", "Submitting - please wait")
            .addClass("form-button-disable");
    }
});

$(document).ajaxStop(function () {
    $(".SitecoreFormsSubmit").prop("disabled", false)
        .removeClass("form-button-disable");
}); ;
// Handles floating input labels

var $formInputs = $('.form input, .form textarea');

const checkInputFill = $input => {
    var $label = $input.parent('label');

    if ($label.length > 0) {
        if ($input[0].value) {
            $label.addClass('is-filled-label');
        } else {
            $label.removeClass('is-filled-label');
        }
    }
};

const newFormInput = input => {
    let $input = $(input);
    $input.on('input', function () {
        let $field = $(this).closest('div');
        if ($field.length > 0) {
            if (this.value) {
                $field.addClass('field--not-empty');
            } else {
                $field.removeClass('field--not-empty');
            }
        }
        checkInputFill($input);
    });
};

if (window.getAllAngularTestabilities) {
    $.each($formInputs, (i, input) => {
        newFormInput(input);
        checkInputFill($(input));
    });
}
else if (window['angular']) {
    $.each($formInputs, (i, input) => {
        newFormInput(input);
        checkInputFill($(input));
    });
};
