import _typeof from "@babel/runtime/helpers/typeof";
import includes from 'lodash/includes';
import en from './en';
import ja from './ja';
var localizations = [en, ja];
export var defaultLanguage = 'en-us';
export default (function (languages) {
  var _iteratorNormalCompletion = true;
  var _didIteratorError = false;
  var _iteratorError = undefined;

  try {
    var _loop = function _loop() {
      var _lang = _step.value;

      var lang = _lang.toLowerCase();

      var hit = localizations.find(function (loc) {
        return includes(loc.accept, lang);
      });

      if (hit) {
        return {
          v: hit
        };
      }
    };

    for (var _iterator = languages[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
      var _ret = _loop();

      if (_typeof(_ret) === "object") return _ret.v;
    }
  } catch (err) {
    _didIteratorError = true;
    _iteratorError = err;
  } finally {
    try {
      if (!_iteratorNormalCompletion && _iterator.return != null) {
        _iterator.return();
      }
    } finally {
      if (_didIteratorError) {
        throw _iteratorError;
      }
    }
  }

  return en; // default
});
export var acceptedLanguages = localizations.map(function (_ref) {
  var accept = _ref.accept,
      native = _ref.native;
  return {
    accept: accept,
    native: native
  };
});