'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var defineProperty = require('../defineProperty-COGyJ6Og.js');
var asyncToGenerator = require('../asyncToGenerator-8vhqAwJl.js');
var i18next = require('i18next');
var utils_constants = require('./constants.js');
var utils_dayjsFormatOverrides_default = require('./dayjsFormatOverrides/default.js');
require('../toPropertyKey-DW-YC76_.js');
require('../typeof-D4ZZ_FlZ.js');

function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = false, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = true, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), true), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { defineProperty._defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var DEFAULT_LOCALE = "en";
var localeFormatOverridesCache = {};
var getLocaleFormatOverrides = function getLocaleFormatOverrides(locale) {
  return localeFormatOverridesCache[locale];
};
var setLocaleFormatOverrides = function setLocaleFormatOverrides(locale, overrides) {
  localeFormatOverridesCache[locale] = overrides;
};
var LOCALES = {
  af: function af() {
    return import('dayjs/locale/af');
  },
  am: function am() {
    return import('dayjs/locale/am');
  },
  "ar-dz": function arDz() {
    return import('dayjs/locale/ar-dz');
  },
  "ar-iq": function arIq() {
    return import('dayjs/locale/ar-iq');
  },
  "ar-kw": function arKw() {
    return import('dayjs/locale/ar-kw');
  },
  "ar-ly": function arLy() {
    return import('dayjs/locale/ar-ly');
  },
  "ar-ma": function arMa() {
    return import('dayjs/locale/ar-ma');
  },
  "ar-sa": function arSa() {
    return import('dayjs/locale/ar-sa');
  },
  "ar-tn": function arTn() {
    return import('dayjs/locale/ar-tn');
  },
  ar: function ar() {
    return import('dayjs/locale/ar');
  },
  az: function az() {
    return import('dayjs/locale/az');
  },
  be: function be() {
    return import('dayjs/locale/be');
  },
  bg: function bg() {
    return import('dayjs/locale/bg');
  },
  bi: function bi() {
    return import('dayjs/locale/bi');
  },
  bm: function bm() {
    return import('dayjs/locale/bm');
  },
  "bn-bd": function bnBd() {
    return import('dayjs/locale/bn-bd');
  },
  bn: function bn() {
    return import('dayjs/locale/bn');
  },
  bo: function bo() {
    return import('dayjs/locale/bo');
  },
  br: function br() {
    return import('dayjs/locale/br');
  },
  bs: function bs() {
    return import('dayjs/locale/bs');
  },
  ca: function ca() {
    return import('dayjs/locale/ca');
  },
  cs: function cs() {
    return import('dayjs/locale/cs');
  },
  cv: function cv() {
    return import('dayjs/locale/cv');
  },
  cy: function cy() {
    return import('dayjs/locale/cy');
  },
  da: function da() {
    return import('dayjs/locale/da');
  },
  "de-at": function deAt() {
    return import('dayjs/locale/de-at');
  },
  "de-ch": function deCh() {
    return import('dayjs/locale/de-ch');
  },
  de: function de() {
    return import('dayjs/locale/de');
  },
  dv: function dv() {
    return import('dayjs/locale/dv');
  },
  el: function el() {
    return import('dayjs/locale/el');
  },
  "en-au": function enAu() {
    return import('dayjs/locale/en-au');
  },
  "en-ca": function enCa() {
    return import('dayjs/locale/en-ca');
  },
  "en-gb": function enGb() {
    return import('dayjs/locale/en-gb');
  },
  "en-ie": function enIe() {
    return import('dayjs/locale/en-ie');
  },
  "en-il": function enIl() {
    return import('dayjs/locale/en-il');
  },
  "en-in": function enIn() {
    return import('dayjs/locale/en-in');
  },
  "en-nz": function enNz() {
    return import('dayjs/locale/en-nz');
  },
  "en-sg": function enSg() {
    return import('dayjs/locale/en-sg');
  },
  "en-tt": function enTt() {
    return import('dayjs/locale/en-tt');
  },
  en: function en() {
    return import('dayjs/locale/en');
  },
  eo: function eo() {
    return import('dayjs/locale/eo');
  },
  "es-do": function esDo() {
    return import('dayjs/locale/es-do');
  },
  "es-mx": function esMx() {
    return import('dayjs/locale/es-mx');
  },
  "es-pr": function esPr() {
    return import('dayjs/locale/es-pr');
  },
  "es-us": function esUs() {
    return import('dayjs/locale/es-us');
  },
  es: function es() {
    return import('dayjs/locale/es');
  },
  et: function et() {
    return import('dayjs/locale/et');
  },
  eu: function eu() {
    return import('dayjs/locale/eu');
  },
  fa: function fa() {
    return import('dayjs/locale/fa');
  },
  fi: function fi() {
    return import('dayjs/locale/fi');
  },
  fo: function fo() {
    return import('dayjs/locale/fo');
  },
  "fr-ca": function frCa() {
    return import('dayjs/locale/fr-ca');
  },
  "fr-ch": function frCh() {
    return import('dayjs/locale/fr-ch');
  },
  fr: function fr() {
    return import('dayjs/locale/fr');
  },
  fy: function fy() {
    return import('dayjs/locale/fy');
  },
  ga: function ga() {
    return import('dayjs/locale/ga');
  },
  gd: function gd() {
    return import('dayjs/locale/gd');
  },
  gl: function gl() {
    return import('dayjs/locale/gl');
  },
  "gom-latn": function gomLatn() {
    return import('dayjs/locale/gom-latn');
  },
  gu: function gu() {
    return import('dayjs/locale/gu');
  },
  he: function he() {
    return import('dayjs/locale/he');
  },
  hi: function hi() {
    return import('dayjs/locale/hi');
  },
  hr: function hr() {
    return import('dayjs/locale/hr');
  },
  ht: function ht() {
    return import('dayjs/locale/ht');
  },
  hu: function hu() {
    return import('dayjs/locale/hu');
  },
  "hy-am": function hyAm() {
    return import('dayjs/locale/hy-am');
  },
  id: function id() {
    return import('dayjs/locale/id');
  },
  is: function is() {
    return import('dayjs/locale/is');
  },
  "it-ch": function itCh() {
    return import('dayjs/locale/it-ch');
  },
  it: function it() {
    return import('dayjs/locale/it');
  },
  ja: function ja() {
    return import('dayjs/locale/ja');
  },
  jv: function jv() {
    return import('dayjs/locale/jv');
  },
  ka: function ka() {
    return import('dayjs/locale/ka');
  },
  kk: function kk() {
    return import('dayjs/locale/kk');
  },
  km: function km() {
    return import('dayjs/locale/km');
  },
  kn: function kn() {
    return import('dayjs/locale/kn');
  },
  ko: function ko() {
    return import('dayjs/locale/ko');
  },
  ku: function ku() {
    return import('dayjs/locale/ku');
  },
  ky: function ky() {
    return import('dayjs/locale/ky');
  },
  lb: function lb() {
    return import('dayjs/locale/lb');
  },
  lo: function lo() {
    return import('dayjs/locale/lo');
  },
  lt: function lt() {
    return import('dayjs/locale/lt');
  },
  lv: function lv() {
    return import('dayjs/locale/lv');
  },
  me: function me() {
    return import('dayjs/locale/me');
  },
  mi: function mi() {
    return import('dayjs/locale/mi');
  },
  mk: function mk() {
    return import('dayjs/locale/mk');
  },
  ml: function ml() {
    return import('dayjs/locale/ml');
  },
  mn: function mn() {
    return import('dayjs/locale/mn');
  },
  mr: function mr() {
    return import('dayjs/locale/mr');
  },
  "ms-my": function msMy() {
    return import('dayjs/locale/ms-my');
  },
  ms: function ms() {
    return import('dayjs/locale/ms');
  },
  mt: function mt() {
    return import('dayjs/locale/mt');
  },
  my: function my() {
    return import('dayjs/locale/my');
  },
  nb: function nb() {
    return import('dayjs/locale/nb');
  },
  ne: function ne() {
    return import('dayjs/locale/ne');
  },
  "nl-be": function nlBe() {
    return import('dayjs/locale/nl-be');
  },
  nl: function nl() {
    return import('dayjs/locale/nl');
  },
  nn: function nn() {
    return import('dayjs/locale/nn');
  },
  "oc-lnc": function ocLnc() {
    return import('dayjs/locale/oc-lnc');
  },
  "pa-in": function paIn() {
    return import('dayjs/locale/pa-in');
  },
  pl: function pl() {
    return import('dayjs/locale/pl');
  },
  "pt-br": function ptBr() {
    return import('dayjs/locale/pt-br');
  },
  pt: function pt() {
    return import('dayjs/locale/pt');
  },
  rn: function rn() {
    return import('dayjs/locale/rn');
  },
  ro: function ro() {
    return import('dayjs/locale/ro');
  },
  ru: function ru() {
    return import('dayjs/locale/ru');
  },
  rw: function rw() {
    return import('dayjs/locale/rw');
  },
  sd: function sd() {
    return import('dayjs/locale/sd');
  },
  se: function se() {
    return import('dayjs/locale/se');
  },
  si: function si() {
    return import('dayjs/locale/si');
  },
  sk: function sk() {
    return import('dayjs/locale/sk');
  },
  sl: function sl() {
    return import('dayjs/locale/sl');
  },
  sq: function sq() {
    return import('dayjs/locale/sq');
  },
  "sr-cyrl": function srCyrl() {
    return import('dayjs/locale/sr-cyrl');
  },
  sr: function sr() {
    return import('dayjs/locale/sr');
  },
  ss: function ss() {
    return import('dayjs/locale/ss');
  },
  "sv-fi": function svFi() {
    return import('dayjs/locale/sv-fi');
  },
  sv: function sv() {
    return import('dayjs/locale/sv');
  },
  sw: function sw() {
    return import('dayjs/locale/sw');
  },
  ta: function ta() {
    return import('dayjs/locale/ta');
  },
  te: function te() {
    return import('dayjs/locale/te');
  },
  tet: function tet() {
    return import('dayjs/locale/tet');
  },
  tg: function tg() {
    return import('dayjs/locale/tg');
  },
  th: function th() {
    return import('dayjs/locale/th');
  },
  tk: function tk() {
    return import('dayjs/locale/tk');
  },
  "tl-ph": function tlPh() {
    return import('dayjs/locale/tl-ph');
  },
  tlh: function tlh() {
    return import('dayjs/locale/tlh');
  },
  tr: function tr() {
    return import('dayjs/locale/tr');
  },
  tzl: function tzl() {
    return import('dayjs/locale/tzl');
  },
  "tzm-latn": function tzmLatn() {
    return import('dayjs/locale/tzm-latn');
  },
  tzm: function tzm() {
    return import('dayjs/locale/tzm');
  },
  "ug-cn": function ugCn() {
    return import('dayjs/locale/ug-cn');
  },
  uk: function uk() {
    return import('dayjs/locale/uk');
  },
  ur: function ur() {
    return import('dayjs/locale/ur');
  },
  "uz-latn": function uzLatn() {
    return import('dayjs/locale/uz-latn');
  },
  uz: function uz() {
    return import('dayjs/locale/uz');
  },
  vi: function vi() {
    return import('dayjs/locale/vi');
  },
  "x-pseudo": function xPseudo() {
    return import('dayjs/locale/x-pseudo');
  },
  yo: function yo() {
    return import('dayjs/locale/yo');
  },
  "zh-cn": function zhCn() {
    return import('dayjs/locale/zh-cn');
  },
  "zh-hk": function zhHk() {
    return import('dayjs/locale/zh-hk');
  },
  "zh-tw": function zhTw() {
    return import('dayjs/locale/zh-tw');
  },
  zh: function zh() {
    return import('dayjs/locale/zh');
  },
  // special cases
  no: function no() {
    return import('dayjs/locale/nb');
  },
  // Norwegian
  zn: function zn() {
    return import('dayjs/locale/zh-cn');
  } // Chinese
};
var getDayjsLocale = function getDayjsLocale() {
  var _i18next$resolvedLang;
  var lang = (_i18next$resolvedLang = i18next.resolvedLanguage) === null || _i18next$resolvedLang === void 0 ? void 0 : _i18next$resolvedLang.toLowerCase();
  if (!lang) return DEFAULT_LOCALE;
  if (lang in LOCALES) return lang;

  // handle locales like `fr-be` and `fr-lu`
  var langPrefix = lang.split("-")[0];
  if (langPrefix in LOCALES) return langPrefix;
  return DEFAULT_LOCALE;
};
var localePlugin = (/*#__PURE__*/function () {
  var _ref = asyncToGenerator._asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_o, _c, d) {
    var locale, loadOverride, overrides, _t;
    return _regenerator().w(function (_context) {
      while (1) switch (_context.p = _context.n) {
        case 0:
          _context.p = 0;
          locale = getDayjsLocale();
          _context.n = 1;
          return LOCALES[locale]();
        case 1:
          loadOverride = utils_constants.FORMAT_OVERRIDE_LOADERS[locale];
          if (!loadOverride) {
            _context.n = 3;
            break;
          }
          _context.n = 2;
          return loadOverride();
        case 2:
          _t = _context.v["default"];
          _context.n = 4;
          break;
        case 3:
          _t = {};
        case 4:
          overrides = _t;
          setLocaleFormatOverrides(locale, _objectSpread(_objectSpread({}, utils_dayjsFormatOverrides_default), overrides));
          d.locale(locale);
          _context.n = 6;
          break;
        case 5:
          _context.p = 5;
          _context.v;
          d.locale(DEFAULT_LOCALE);
        case 6:
          return _context.a(2);
      }
    }, _callee, null, [[0, 5]]);
  }));
  return function (_x, _x2, _x3) {
    return _ref.apply(this, arguments);
  };
}());

exports.default = localePlugin;
exports.getLocaleFormatOverrides = getLocaleFormatOverrides;
exports.setLocaleFormatOverrides = setLocaleFormatOverrides;
//# sourceMappingURL=localePlugin.js.map
