import _objectSpread from "@babel/runtime/helpers/objectSpread2";
import { mapValues, omitBy, pickBy } from 'lodash';
import { useCallback } from 'react';
import { useLocalize } from './useLocalize';
export var translateProperties = ['title', 'name', 'label', 'default', 'description', 'help', 'patternDescription', 'placeholder', 'yes', 'no', 'content', 'successText', 'enumNames', 'textDefault', 'consentTitle', 'consentMessage', 'labelError'];
export var translateArrayProperties = ['choices', 'elements', 'scaleMarks'];
export var translateArray = ['tableColumns'];
export var isLecacyTranslationObject = function isLecacyTranslationObject(value, key) {
  return typeof value === 'object' && translateProperties.includes(key);
};
export function useLocalizeConfig() {
  var localize = useLocalize();
  return useCallback(function localizeConfig(config) {
    var translatedConfig = omitBy(config, isLecacyTranslationObject);
    var translate = pickBy(config, isLecacyTranslationObject); // Proposal for translated config values
    // if (Object.keys(translate).length) {
    //   translatedConfig.intl = translate;
    // }

    return _objectSpread(_objectSpread({}, mapValues(translatedConfig, function (value, key) {
      return translateArrayProperties.includes(key) ? value === null || value === void 0 ? void 0 : value.map(function (value) {
        return typeof value === 'object' ? localizeConfig(value) : value;
      }) : translateArray.includes(key) ? value === null || value === void 0 ? void 0 : value.map(function (value) {
        return typeof value === 'object' ? localize(value) : value;
      }) : value;
    })), mapValues(translate, localize));
  }, [localize]);
}
//# sourceMappingURL=useLocalizeConfig.js.map