"use strict";

exports.__esModule = true;
exports.default = void 0;
exports.findCorrespondingLocale = findCorrespondingLocale;
exports.getLocalization = getLocalization;
exports.getNotLocalizedString = getNotLocalizedString;
var _propertyHelper = require("./propertyHelper");
(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;
};
function getLocalization(localizations, locale, defaultValue, useDefaultForEmptyValue) {
  var _localisation;
  if (useDefaultForEmptyValue === void 0) {
    useDefaultForEmptyValue = true;
  }
  var fallbackValue = getNotLocalizedString(defaultValue);
  if (!localizations || !locale) return fallbackValue;
  var localisation = (0, _propertyHelper.getPropertyOrDefault)(localizations, locale, fallbackValue, true);
  if (localisation === fallbackValue) {
    localisation = (0, _propertyHelper.getPropertyOrDefault)(localizations, locale.split("-")[0], fallbackValue, true, true);
  }
  if (useDefaultForEmptyValue && ((_localisation = localisation) == null ? void 0 : _localisation.trim()) === "") {
    return fallbackValue;
  }
  return localisation;
}
function getNotLocalizedString(value) {
  return value && "[".concat(value, "]");
}
function findCorrespondingLocale(locales, language) {
  var _ref, _ref2, _ref3, _ref4, _locales$language;
  return (_ref = (_ref2 = (_ref3 = (_ref4 = (_locales$language = locales[language]) != null ? _locales$language : locales[language.replace(/-/g, "")]) != null ? _ref4 : locales[language.toLowerCase()]) != null ? _ref3 : locales[language.toLowerCase().replace(/-/g, "")]) != null ? _ref2 : locales[language.substring(0, 2).toLowerCase()]) != null ? _ref : null;
}
var _default = {
  getLocalization: getLocalization,
  getNotLocalizedString: getNotLocalizedString,
  findCorrespondingLocale: findCorrespondingLocale
};
var _default2 = _default;
var _default3 = exports.default = _default2;
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(getLocalization, "getLocalization", "/home/vsts/work/1/s/src/utils/localizationHelper.js");
  reactHotLoader.register(getNotLocalizedString, "getNotLocalizedString", "/home/vsts/work/1/s/src/utils/localizationHelper.js");
  reactHotLoader.register(findCorrespondingLocale, "findCorrespondingLocale", "/home/vsts/work/1/s/src/utils/localizationHelper.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/utils/localizationHelper.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(getLocalization, "getLocalization", "/home/vsts/work/1/s/src/utils/localizationHelper.js");
  reactHotLoader.register(getNotLocalizedString, "getNotLocalizedString", "/home/vsts/work/1/s/src/utils/localizationHelper.js");
  reactHotLoader.register(findCorrespondingLocale, "findCorrespondingLocale", "/home/vsts/work/1/s/src/utils/localizationHelper.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/utils/localizationHelper.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();