import isFunction from '../isFunction';
import callAll from './callAll';
/*
 * Combines one or more conditions with one or more callbacks to create a single callback function that will invoke all callbacks if all conditions are true
 *
 * Usage:
 * onKeyDown={ifAll(isCtrl, isZ)(onUndo, preventDefault)}
 */
var ifAll = function () {
    var conditions = [];
    for (var _i = 0; _i < arguments.length; _i++) {
        conditions[_i] = arguments[_i];
    }
    return function () {
        var callbacks = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            callbacks[_i] = arguments[_i];
        }
        return function () {
            var args = [];
            for (var _i = 0; _i < arguments.length; _i++) {
                args[_i] = arguments[_i];
            }
            var conditionsToCheck = conditions.filter(isFunction);
            if (conditionsToCheck.length && conditionsToCheck.every(function (condition) { return condition.apply(void 0, args); })) {
                callAll.apply(void 0, callbacks).apply(void 0, args);
            }
        };
    };
};
export default ifAll;
//# sourceMappingURL=ifAll.js.map