import React, { useEffect } from 'react';
import { SnackbarProvider } from 'notistack';
import { ThemeProvider } from '../utilities/theme';
import { AuthProvider } from '../utilities/auth/AuthProvider';
import { initializeUnityI18n } from '../utilities/i18n/initializeI18n';
import { storeInitialPath } from '../utilities/redirect';
import { storeInitialTenant } from '../utilities/storage';
import { BrowserRouter } from 'react-router-dom';
import { QueryProvider } from './QueryProvider';
/**
 * Bundles the core UDP providers (theme, snackbar, auth) and ensures the shared
 * i18n instance is initialised exactly once. Intended to be rendered beneath a
 * react-router <Router /> so the auth provider has access to history.
 */
export const UdpAppProvider = ({ children, snackbarProps, authProps, i18nOptions, devTools, }) => {
    useEffect(() => {
        initializeUnityI18n(i18nOptions);
    }, [i18nOptions]);
    storeInitialPath();
    storeInitialTenant();
    return (React.createElement(ThemeProvider, null, React.createElement(QueryProvider, { showDevTools: devTools === null || devTools === void 0 ? void 0 : devTools.query }, React.createElement(AuthProvider, Object.assign({}, authProps), React.createElement(BrowserRouter, null, React.createElement(SnackbarProvider, Object.assign({ maxSnack: 3 }, snackbarProps), children))))));
};
//# sourceMappingURL=UdpAppProvider.js.map