import { IntlProvider } from 'react-intl';
import '../common/theme.mjs';
import '../common/direction.mjs';
import '@transferwise/neptune-tokens';
import '../common/propsValues/control.mjs';
import '../common/propsValues/size.mjs';
import '../common/propsValues/typography.mjs';
import '../common/propsValues/width.mjs';
import '../common/propsValues/type.mjs';
import '../common/propsValues/dateMode.mjs';
import '../common/propsValues/monthFormat.mjs';
import '../common/propsValues/position.mjs';
import '../common/propsValues/layouts.mjs';
import '../common/propsValues/status.mjs';
import '../common/propsValues/sentiment.mjs';
import '../common/propsValues/profileType.mjs';
import '../common/propsValues/variant.mjs';
import '../common/propsValues/scroll.mjs';
import '../common/propsValues/markdownNodeType.mjs';
import '../common/fileType.mjs';
import { adjustLocale, DEFAULT_LOCALE, getDirectionFromLocale } from '../common/locale/index.mjs';
import '@transferwise/icons';
import 'clsx';
import 'react';
import '../common/closeButton/CloseButton.messages.mjs';
import { jsx } from 'react/jsx-runtime';
import en from '../i18n/en.json.mjs';
import { DirectionProvider } from './direction/DirectionProvider.mjs';
import { LanguageProvider } from './language/LanguageProvider.mjs';

function Provider({
  i18n,
  children
}) {
  const {
    locale,
    messages,
    defaultRichTextElements
  } = i18n;
  const adjustedLocale = adjustLocale(locale);
  let intlConfig;
  if (adjustedLocale === null) {
    // eslint-disable-next-line no-console
    console.warn(`Unsupported locale value was provided: '${locale}', defaulting to '${DEFAULT_LOCALE}'`);
    intlConfig = {
      locale: DEFAULT_LOCALE,
      messages: {
        ...en,
        ...messages
      }
    };
  } else {
    intlConfig = {
      locale: adjustedLocale,
      messages
    };
  }
  return /*#__PURE__*/jsx(DirectionProvider, {
    direction: getDirectionFromLocale(locale),
    children: /*#__PURE__*/jsx(LanguageProvider, {
      locale: locale,
      children: /*#__PURE__*/jsx(IntlProvider, {
        defaultLocale: DEFAULT_LOCALE,
        locale: intlConfig.locale,
        messages: intlConfig.messages,
        defaultRichTextElements: defaultRichTextElements,
        children: children
      })
    })
  });
}

export { Provider as default };
//# sourceMappingURL=Provider.mjs.map
