import _extends from 'babel-runtime/helpers/extends';
import * as React from 'react';
import defaultLocaleData from '../../locale/en_US';
var LocaleContext = React.createContext(undefined);
export function useLocaleReceiver(componentName, defaultLocale) {
    var antLocale = React.useContext(LocaleContext);
    var componentLocale = React.useMemo(function () {
        var locale = defaultLocale || defaultLocaleData[componentName || 'global'];
        var localeFromContext = componentName && antLocale ? antLocale[componentName] : {};
        return _extends(_extends({}, typeof locale === 'function' ? locale() : locale), localeFromContext || {});
    }, [componentName, defaultLocale, antLocale]);
    return [componentLocale];
}