"use strict";

exports.__esModule = true;
exports.cultureNameByIsoCode = exports.cultureOptionList = exports.orderedCultureList = exports.defaultCulture = exports.cultureList = exports.cultures = exports.currentLocale = exports.currentLocaleOrDefault = exports.defaultLocale = void 0;

var _immutable = _interopRequireDefault(require("immutable"));

var _reselect = require("reselect");

var _localeFactory = require("../reducers/localeFactory");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();

(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();

var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};

var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};

var localeData = function localeData(state) {
  return state.get("locale");
};

var defaultLocale = (0, _reselect.createSelector)(localeData, function (data) {
  return data.getIn(["supportedLocales", 0, "cultureIso"]) || _localeFactory.cultureByDefault;
});
exports.defaultLocale = defaultLocale;
var supportedLocales = (0, _reselect.createSelector)(localeData, function (data) {
  return data.getIn(["supportedLocales"]) || _immutable.default.fromJS([]);
});
var currentLocaleOrDefault = (0, _reselect.createSelector)(localeData, defaultLocale, function (data, defaultLocale) {
  return data.get("locale") || defaultLocale;
});
exports.currentLocaleOrDefault = currentLocaleOrDefault;
var currentLocale = (0, _reselect.createSelector)(localeData, function (data) {
  return data.get("locale");
});
exports.currentLocale = currentLocale;
var cultures = (0, _reselect.createSelector)(localeData, function (locale) {
  return locale.get("cultures");
});
exports.cultures = cultures;
var cultureList = (0, _reselect.createSelector)(cultures, function (cultures) {
  return cultures.keySeq();
});
exports.cultureList = cultureList;
var defaultCulture = (0, _reselect.createSelector)(localeData, function (locale) {
  return locale.get("defaultCulture");
});
exports.defaultCulture = defaultCulture;
var orderedCultureList = (0, _reselect.createSelector)(cultureList, defaultCulture, function (cultures, defaultCulture) {
  return cultures.sort(function (a, b) {
    /*istanbul ignore if */
    if (a === defaultCulture) return -1;
    if (b === defaultCulture) return 1;
    return 0;
  });
});
exports.orderedCultureList = orderedCultureList;
var cultureOptionList = (0, _reselect.createSelector)(supportedLocales, function (locales) {
  return locales.map(function (iso) {
    return {
      value: iso.get("cultureIso"),
      label: iso.get("language")
    };
  });
});
exports.cultureOptionList = cultureOptionList;

var cultureNameByIsoCode = function cultureNameByIsoCode(cultureIsoCode) {
  return (0, _reselect.createSelector)(cultures, function (cultures) {
    var culturesList = cultures == null ? void 0 : cultures.toJS();

    if (cultureIsoCode != null) {
      var culture = culturesList[cultureIsoCode];

      if (culture != null) {
        return culture.cultureName;
      }

      return "[".concat(cultureIsoCode, "]");
    }

    return null;
  });
};

exports.cultureNameByIsoCode = cultureNameByIsoCode;
;

(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;

  if (!reactHotLoader) {
    return;
  }

  reactHotLoader.register(localeData, "localeData", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(defaultLocale, "defaultLocale", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(supportedLocales, "supportedLocales", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(currentLocaleOrDefault, "currentLocaleOrDefault", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(currentLocale, "currentLocale", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(cultures, "cultures", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(cultureList, "cultureList", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(defaultCulture, "defaultCulture", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(orderedCultureList, "orderedCultureList", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(cultureOptionList, "cultureOptionList", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(cultureNameByIsoCode, "cultureNameByIsoCode", "/home/vsts/work/1/s/src/selectors/locale.js");
})();

;

(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();

;

(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;

  if (!reactHotLoader) {
    return;
  }

  reactHotLoader.register(localeData, "localeData", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(defaultLocale, "defaultLocale", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(supportedLocales, "supportedLocales", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(currentLocaleOrDefault, "currentLocaleOrDefault", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(currentLocale, "currentLocale", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(cultures, "cultures", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(cultureList, "cultureList", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(defaultCulture, "defaultCulture", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(orderedCultureList, "orderedCultureList", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(cultureOptionList, "cultureOptionList", "/home/vsts/work/1/s/src/selectors/locale.js");
  reactHotLoader.register(cultureNameByIsoCode, "cultureNameByIsoCode", "/home/vsts/work/1/s/src/selectors/locale.js");
})();

;

(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();