function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

export function noop() {}
export function get(source, path, defaultValue) {
  var paths = path.replace(/\[(\d+)]/g, '.$1').split('.');
  var result = source;

  var _iterator = _createForOfIteratorHelper(paths),
      _step;

  try {
    for (_iterator.s(); !(_step = _iterator.n()).done;) {
      var p = _step.value;
      result = Object(result)[p];

      if (result === undefined) {
        return defaultValue;
      }
    }
  } catch (err) {
    _iterator.e(err);
  } finally {
    _iterator.f();
  }

  return result;
}
export function isValidArray(obj) {
  return Array.isArray(obj) && obj.length > 0;
}
export function findInArray() {
  var arr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  var fn = arguments.length > 1 ? arguments[1] : undefined;
  var ret = null;

  if (isValidArray(arr)) {
    arr.forEach(function (item, index) {
      if (!ret && fn(item, index)) {
        ret = item;
      }
    });
  }

  return ret;
}
export function isString(str) {
  return typeof str === 'string';
}
export function isNumber(num) {
  if (num === '' || num === null) {
    return false;
  }

  return typeof num === 'number' && !isNaN(num) || !isNaN(Number(num));
}
export function isUndef(obj) {
  return typeof obj === 'undefined';
}
export function isFunction(fn) {
  return typeof fn === 'function';
}
export function isBoolean(val) {
  return typeof val === 'boolean';
}
export function isNil(val) {
  return typeof val === 'undefined' || val === null;
}
export function isInvalidValue(val) {
  return isNil(val) || val === '';
}
export var nextTick = function nextTick(handler) {
  if (typeof requestAnimationFrame !== 'undefined') {
    requestAnimationFrame(handler);
    return;
  }

  if (typeof setTimeout !== 'undefined') {
    setTimeout(handler, 0);
    return;
  }

  handler();
};
export function removeFromArray() {
  var arr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  var val = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  return arr.filter(function (v) {
    return v !== val;
  });
}
export function replaceMessage(template, kv) {
  return template.replace(/\${\w+}/g, function (str) {
    var key = str.slice(2, -1);
    return kv[key];
  });
}
export function getValueFromEvents(e) {
  if (!isUndef(e.value)) {
    return e.value;
  }

  if (get(e, 'target.value')) {
    return e.target.value;
  }

  if (get(e, 'detail.value')) {
    return e.target.value;
  }

  if (get(e, 'originalEvent.detail.value')) {
    return e.originalEvent.detail.value;
  }
}
export function getNotUndef() {
  for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {
    values[_key] = arguments[_key];
  }

  for (var _i = 0, _values = values; _i < _values.length; _i++) {
    var it = _values[_i];

    if (!isUndef(it)) {
      return it;
    }
  }
}