import _ScopedCssBaseline from "@mui/material/ScopedCssBaseline";
/*!
 * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.
 * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
 *
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *
 * See the License for the specific language governing permissions and limitations under the License.
 */
import { memo, useMemo } from "react";
import { ConditionalWrapper } from "./ConditionalWrapper.js";
import { CssBaseline } from "./CssBaseline.js";
import { FullScreenOverlayProvider } from "./FullScreenOverlayContext.js";
import { TranslationProvider as OdysseyTranslationProvider } from "./i18n.generated/i18n.js";
import { OdysseyCacheProvider } from "./OdysseyCacheProvider.js";
import { OdysseyThemeProvider } from "./OdysseyThemeProvider.js";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
const scopedCssBaselineStyles = {
  height: "inherit"
};
const OdysseyProvider = ({
  children,
  contrastMode,
  designTokensOverride,
  emotionRoot,
  emotionRootElement,
  hasCssBaseline: hasGlobalCss,
  hasScopedCssBaseline = true,
  hasTranslationProvider = true,
  hasWrapperElement,
  languageCode,
  nonce,
  overlayParentElement,
  overlayType,
  shadowDomElement,
  shadowRootElement,
  stylisPlugins,
  themeOverride,
  translationOverrides
}) => {
  const TranslationWrapper = useMemo(() => children => _jsx(OdysseyTranslationProvider, {
    languageCode: languageCode,
    translationOverrides: translationOverrides,
    children: children
  }), [languageCode, translationOverrides]);
  return _jsx(OdysseyCacheProvider, {
    emotionRootElement: emotionRootElement || emotionRoot,
    nonce: nonce,
    stylisPlugins: stylisPlugins,
    children: _jsx(OdysseyThemeProvider, {
      contrastMode: contrastMode,
      designTokensOverride: designTokensOverride,
      hasWrapperElement: hasWrapperElement,
      shadowRootElement: shadowRootElement ?? shadowDomElement,
      themeOverride: themeOverride,
      children: _jsx(ConditionalWrapper, {
        isWrapped: hasTranslationProvider,
        Wrapper: TranslationWrapper,
        children: _jsxs(FullScreenOverlayProvider, {
          hasShadowDom: Boolean(shadowRootElement || shadowDomElement),
          overlayParentElement: overlayParentElement,
          overlayType: overlayType,
          children: [hasGlobalCss && _jsx(CssBaseline, {}), hasScopedCssBaseline ? _jsx(_ScopedCssBaseline, {
            sx: scopedCssBaselineStyles,
            children: children
          }) : children]
        })
      })
    })
  });
};
const MemoizedOdysseyProvider = memo(OdysseyProvider);
MemoizedOdysseyProvider.displayName = "OdysseyProvider";
export { MemoizedOdysseyProvider as OdysseyProvider };
//# sourceMappingURL=OdysseyProvider.js.map