{"version":3,"file":"UiShell.cjs","names":["_react","require","_reactErrorBoundary","_index","_OdysseyProvider","_NarrowUiShellContent","_UiShellProvider","_useUiShellBreakpoints","_WideUiShellContent","_jsxRuntime","defaultComponentProps","exports","sideNavProps","undefined","topNavProps","defaultTranslationSettings","errorComponent","jsx","UiShell","appBackgroundColor","appBackgroundContrastMode","appElement","appElementScrollingMode","breakpointConfig","closeSideNavMenu","connectFullscreenState","hasStandardAppContentPadding","initialVisibleSections","onError","console","error","onSubscriptionCreated","optionalComponents","sideNavBackgroundColor","sideNavBackgroundContrastColor","subscribeToCloseRightSideMenu","subscribeToCloseSideNavMenu","subscribeToPropChanges","subscribeToTranslationSettings","topNavBackgroundColor","uiShellAppElement","uiShellStylesElement","componentProps","setComponentProps","useState","translationSettings","setTranslationSettings","activeBreakpoint","useUiShellBreakpoints","logoProps","Error","useEffect","fullscreenModeHost","createFullscreenModeHost","disconnectFullscreenState","destroy","unsubscribeFromPropChanges","unsubscribeFromTranslationSettings","nextSettings","ErrorBoundary","fallback","children","OdysseyProvider","emotionRootElement","fullScreenOverlayId","hasCssBaseline","languageCode","shadowRootElement","translationOverrides","jsxs","UiShellProvider","NarrowUiShellContent","hasSideNavProps","Boolean","WideUiShellContent","hasSessionStorageState","isCollapsed","isCollapsible","MemoizedUiShell","memo","displayName"],"sources":["../../../src/ui-shell/UiShell.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2024-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { memo, type SetStateAction, useEffect, useState } from \"react\";\nimport { ErrorBoundary } from \"react-error-boundary\";\n\nimport {\n  type TranslationOverrides,\n  type TranslationProviderProps,\n} from \"../i18n.generated/i18n.js\";\nimport { createFullscreenModeHost } from \"../message-bus/index.js\";\nimport { OdysseyProvider } from \"../OdysseyProvider.js\";\nimport { MessageBus } from \"../tools/createMessageBus.js\";\nimport { type ReactRootElements } from \"../web-component/createReactRootElements.js\";\nimport { NarrowUiShellContent } from \"./NarrowUiShellContent.js\";\nimport {\n  UiShellContentProps,\n  UiShellNavComponentProps,\n} from \"./uiShellContentTypes.js\";\nimport { UiShellProvider, UiShellProviderProps } from \"./UiShellProvider.js\";\nimport {\n  UiShellBreakpointConfig,\n  useUiShellBreakpoints,\n} from \"./useUiShellBreakpoints.js\";\nimport { WideUiShellContent } from \"./WideUiShellContent.js\";\n\nexport const defaultComponentProps: UiShellNavComponentProps = {\n  sideNavProps: undefined,\n  topNavProps: undefined,\n} as const;\n\n/**\n * Runtime-updatable translation settings forwarded to UI Shell's internal `OdysseyProvider`.\n *\n * Consumers pass these as initial props to `renderUiShell({...})` and can update them later by calling `setTranslationSettings(...)` on the returned object.\n */\nexport type UiShellTranslationSettings = Pick<\n  TranslationProviderProps,\n  \"languageCode\"\n> & {\n  translationOverrides?: TranslationOverrides;\n};\n\nconst defaultTranslationSettings: UiShellTranslationSettings = {};\n\nconst errorComponent = <div data-error />;\n\nexport type UiShellProps = {\n  /**\n   * Customized breakpoints for UI Shell.\n   *\n   * The defaults are set for you. Pass these only if your app doesn't work properly with the defaults (like Admin).\n   */\n  breakpointConfig?: UiShellBreakpointConfig;\n  /**\n   * Called once the shell's fullscreen mode host is running. The function it returns is called when the shell unmounts, before the host stops.\n   *\n   * `renderUiShell` passes this so the fullscreen state it returns only listens to the page while the shell is on it.\n   */\n  connectFullscreenState?: () => () => void;\n  /**\n   * Notifies when subscribed to prop changes.\n   *\n   * UI Shell listens to prop updates, and it won't subscribe synchronously. Because of that, this callback notifies when that subscription is ready.\n   */\n  onSubscriptionCreated: () => void;\n  /**\n   * This is a callback that provides a subscriber callback to listen for changes to state. It allows UI Shell to listen for state changes.\n   *\n   * The props coming in this callback go directly to a React state; therefore, it shares the same signature and provides a previous state.\n   */\n  subscribeToPropChanges: MessageBus<\n    SetStateAction<UiShellNavComponentProps>\n  >[\"subscribe\"];\n  /**\n   * Subscriber for runtime-updatable translation settings (`languageCode`, `translationOverrides`).\n   *\n   * These are forwarded to the shell's internal `OdysseyProvider` so consumers can drive shell localization from their own i18n source instead of the browser's `navigator.language`.\n   *\n   * Optional for backward compatibility — when omitted, the shell falls back to `window.navigator.language` (its prior behavior).\n   */\n  subscribeToTranslationSettings?: MessageBus<\n    SetStateAction<UiShellTranslationSettings>\n  >[\"subscribe\"];\n  /**\n   * Element inside UI Shell's React root component renders into. If using a web component, this is going to exist inside it.\n   */\n  uiShellAppElement: ReactRootElements[\"appRootElement\"];\n  /**\n   * Typically, this is your `<head>` element. If using a web component, you need to create one yourself as Shadow DOM's don't have a `<head>`.\n   */\n  uiShellStylesElement: ReactRootElements[\"stylesRootElement\"];\n} & UiShellProviderProps &\n  Pick<\n    UiShellContentProps,\n    | \"appElement\"\n    | \"appElementScrollingMode\"\n    | \"hasStandardAppContentPadding\"\n    | \"initialVisibleSections\"\n    | \"onError\"\n    | \"optionalComponents\"\n  >;\n\n/**\n * Our new Unified Platform UI Shell.\n *\n * This includes the top and side navigation as well as the footer and provides a spot for your app to render into.\n *\n * If an error occurs, this will revert to only showing the app.\n */\nconst UiShell = ({\n  appBackgroundColor,\n  appBackgroundContrastMode,\n  appElement,\n  appElementScrollingMode,\n  breakpointConfig,\n  closeSideNavMenu,\n  connectFullscreenState,\n  hasStandardAppContentPadding,\n  initialVisibleSections,\n  onError = console.error,\n  onSubscriptionCreated,\n  optionalComponents,\n  sideNavBackgroundColor,\n  sideNavBackgroundContrastColor,\n  subscribeToCloseRightSideMenu,\n  subscribeToCloseSideNavMenu,\n  subscribeToPropChanges,\n  subscribeToTranslationSettings,\n  topNavBackgroundColor,\n  uiShellAppElement,\n  uiShellStylesElement,\n}: UiShellProps) => {\n  const [componentProps, setComponentProps] = useState(defaultComponentProps);\n  const [translationSettings, setTranslationSettings] =\n    useState<UiShellTranslationSettings>(defaultTranslationSettings);\n\n  const activeBreakpoint = useUiShellBreakpoints(breakpointConfig);\n\n  if (componentProps.sideNavProps?.logoProps && componentProps.logoProps) {\n    throw new Error(\n      \"Unified UI Shell: You passed both `logoProps` and `sideNavProps.logoProps` as component props. Please only use the top-level `logoProps` instead.\",\n    );\n  }\n\n  // Only one UI Shell renders on a page, while any number of apps can, so the shell is where the page's fullscreen stack lives. Destroying it on unmount clears the stack, so the app never stays in fullscreen with no shell to bring the navigation back.\n  useEffect(() => {\n    const fullscreenModeHost = createFullscreenModeHost();\n    const disconnectFullscreenState = connectFullscreenState?.();\n\n    return () => {\n      disconnectFullscreenState?.();\n      fullscreenModeHost.destroy();\n    };\n  }, [connectFullscreenState]);\n\n  useEffect(() => {\n    const unsubscribeFromPropChanges = subscribeToPropChanges(\n      (componentProps) => {\n        // If for some reason nothing is passed as `componentProps`, we fallback on `defaultComponentProps` as a safety mechanism to ensure nothing breaks.\n        setComponentProps(componentProps || defaultComponentProps);\n      },\n    );\n\n    // Both subscribers must be wired BEFORE `onSubscriptionCreated()` fires. `renderUiShell` uses `bufferLatest` to queue the initial translation settings until the React app subscribes; if we called `onSubscriptionCreated()` first, the buffered emission would fire before this subscriber exists and be lost.\n    const unsubscribeFromTranslationSettings = subscribeToTranslationSettings?.(\n      (nextSettings) => {\n        setTranslationSettings(nextSettings || defaultTranslationSettings);\n      },\n    );\n\n    onSubscriptionCreated();\n\n    return () => {\n      unsubscribeFromPropChanges();\n      unsubscribeFromTranslationSettings?.();\n    };\n  }, [\n    onSubscriptionCreated,\n    subscribeToPropChanges,\n    subscribeToTranslationSettings,\n  ]);\n\n  return activeBreakpoint === \"none\" ? null : (\n    <ErrorBoundary fallback={errorComponent} onError={onError}>\n      <OdysseyProvider\n        emotionRootElement={uiShellStylesElement}\n        fullScreenOverlayId=\"odyssey-react-overlay-component-render-ui-shell\"\n        hasCssBaseline\n        languageCode={translationSettings.languageCode}\n        shadowRootElement={uiShellAppElement}\n        translationOverrides={translationSettings.translationOverrides}\n      >\n        <ErrorBoundary fallback={errorComponent} onError={onError}>\n          <UiShellProvider\n            appBackgroundColor={appBackgroundColor}\n            appBackgroundContrastMode={appBackgroundContrastMode}\n            closeSideNavMenu={closeSideNavMenu}\n            sideNavBackgroundColor={sideNavBackgroundColor}\n            sideNavBackgroundContrastColor={sideNavBackgroundContrastColor}\n            subscribeToCloseRightSideMenu={subscribeToCloseRightSideMenu}\n            subscribeToCloseSideNavMenu={subscribeToCloseSideNavMenu}\n            topNavBackgroundColor={topNavBackgroundColor}\n          >\n            {activeBreakpoint === \"narrow\" && (\n              <NarrowUiShellContent\n                {...componentProps}\n                appElement={appElement}\n                appElementScrollingMode={appElementScrollingMode}\n                hasSideNavProps={Boolean(componentProps.sideNavProps)}\n                hasStandardAppContentPadding={hasStandardAppContentPadding}\n                initialVisibleSections={initialVisibleSections}\n                onError={onError}\n                optionalComponents={optionalComponents}\n              />\n            )}\n\n            {(activeBreakpoint === \"medium\" || activeBreakpoint === \"wide\") && (\n              <WideUiShellContent\n                {...{\n                  ...componentProps,\n                  ...{\n                    sideNavProps: {\n                      ...componentProps.sideNavProps,\n                      hasSessionStorageState: activeBreakpoint === \"wide\",\n                      isCollapsed:\n                        activeBreakpoint === \"medium\" ||\n                        componentProps.sideNavProps?.isCollapsed,\n                      isCollapsible:\n                        activeBreakpoint === \"medium\" ||\n                        componentProps.sideNavProps?.isCollapsible,\n                      logoProps:\n                        componentProps.sideNavProps?.logoProps ||\n                        componentProps.logoProps,\n                    } as typeof componentProps.sideNavProps, // We have to use `as` because sideNavProps expects you to have `sideNavItems` defined even though it had to be passed in `...componentProps.sideNavProps`.\n                  },\n                }}\n                appElement={appElement}\n                appElementScrollingMode={appElementScrollingMode}\n                hasSideNavProps={Boolean(componentProps.sideNavProps)}\n                hasStandardAppContentPadding={hasStandardAppContentPadding}\n                initialVisibleSections={initialVisibleSections}\n                onError={onError}\n                optionalComponents={optionalComponents}\n              />\n            )}\n          </UiShellProvider>\n        </ErrorBoundary>\n      </OdysseyProvider>\n    </ErrorBoundary>\n  );\n};\n\nconst MemoizedUiShell = memo(UiShell);\nMemoizedUiShell.displayName = \"UiShell\";\n\nexport { MemoizedUiShell as UiShell };\n"],"mappings":";;;;;;AAYA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AAMA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AAGA,IAAAI,qBAAA,GAAAJ,OAAA;AAKA,IAAAK,gBAAA,GAAAL,OAAA;AACA,IAAAM,sBAAA,GAAAN,OAAA;AAIA,IAAAO,mBAAA,GAAAP,OAAA;AAA6D,IAAAQ,WAAA,GAAAR,OAAA;AAjC7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyBO,MAAMS,qBAA+C,GAAAC,OAAA,CAAAD,qBAAA,GAAG;EAC7DE,YAAY,EAAEC,SAAS;EACvBC,WAAW,EAAED;AACf,CAAU;AAcV,MAAME,0BAAsD,GAAG,CAAC,CAAC;AAEjE,MAAMC,cAAc,GAAG,IAAAP,WAAA,CAAAQ,GAAA;EAAK;AAAU,CAAE,CAAC;AAiEzC,MAAMC,OAAO,GAAGA,CAAC;EACfC,kBAAkB;EAClBC,yBAAyB;EACzBC,UAAU;EACVC,uBAAuB;EACvBC,gBAAgB;EAChBC,gBAAgB;EAChBC,sBAAsB;EACtBC,4BAA4B;EAC5BC,sBAAsB;EACtBC,OAAO,GAAGC,OAAO,CAACC,KAAK;EACvBC,qBAAqB;EACrBC,kBAAkB;EAClBC,sBAAsB;EACtBC,8BAA8B;EAC9BC,6BAA6B;EAC7BC,2BAA2B;EAC3BC,sBAAsB;EACtBC,8BAA8B;EAC9BC,qBAAqB;EACrBC,iBAAiB;EACjBC;AACY,CAAC,KAAK;E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