(function () {
    'use strict';
    document.addEventListener('change', function (event) {
        var target = event.target;
        if (!target || target.name !== 'new_status') {
            return;
        }
        var form = target.closest('form');
        if (!form) {
            return;
        }
        var escalation = form.querySelector('[name="escalation_level"]');
        var outcome = form.querySelector('[name="investigation_outcome"]');
        if (escalation) {
            escalation.required = target.value === 'ESCALATED';
        }
        if (outcome) {
            outcome.required = ['EXPLAINED_ACTIVITY','CONFIRMED_ANOMALY','FALSE_POSITIVE','CLOSED'].indexOf(target.value) !== -1;
        }
    });
}());
