'use strict';

var isNil = require('../node_modules/lodash-es/isNil.js');
require('core-js/modules/es.array.concat.js');
require('core-js/modules/es.array.filter.js');
require('core-js/modules/es.object.to-string.js');

var useMatchingThreshold = function useMatchingThreshold(_ref) {
  var thresholds = _ref.thresholds,
    value = _ref.value;
  if (!(thresholds !== null && thresholds !== void 0 && thresholds.length)) {
    return null;
  }
  return thresholds.filter(function (t) {
    if (typeof t.comparison === 'function') {
      return t.comparison(value);
    }
    switch (t.comparison) {
      case '<':
        return !isNil(value) && value < t.value;
      case '>':
        return value > t.value;
      case '=':
        return value === t.value;
      case '<=':
        return !isNil(value) && value <= t.value;
      case '>=':
        return value >= t.value;
      default:
        return false;
    }
  }).concat([null])[0];
};
var useMatchingThreshold$1 = useMatchingThreshold;

module.exports = useMatchingThreshold$1;
