{"version":3,"file":"OdysseyCacheProvider.cjs","names":["_cache","_interopRequireDefault","require","_react","_react2","_useUniqueAlphabeticalId","_jsxRuntime","e","__esModule","default","OdysseyCacheProvider","children","emotionRoot","emotionRootElement","nonce","stylisPlugins","uniqueAlphabeticalId","useUniqueAlphabeticalId","emotionCache","useMemo","createCache","container","key","globalThis","cspNonce","prepend","speedy","jsx","CacheProvider","value","MemoizedOdysseyCacheProvider","exports","memo","displayName"],"sources":["../../src/OdysseyCacheProvider.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-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\ndeclare global {\n  var cspNonce: string; // Adding types to `globalThis` requires we use `var`.\n}\n\nimport createCache, { StylisPlugin } from \"@emotion/cache\";\nimport { CacheProvider } from \"@emotion/react\";\nimport { memo, ReactNode, useMemo } from \"react\";\n\nimport { useUniqueAlphabeticalId } from \"./useUniqueAlphabeticalId.js\";\n\nexport type OdysseyCacheProviderProps = {\n  children: ReactNode;\n  /**\n   * @deprecated Use `EmotionRootElement` instead. This was incorrectly configured as an `HTMLStyleElement`, but then we're rendering `<style>` inside `<style>`. We need this to be a `<div>` instead.\n   *\n   * Emotion caches styles into the style element.\n   * When enabling this prop, Emotion caches the styles at this element, rather than in <head>.\n   */\n  emotionRoot?: HTMLStyleElement;\n  /**\n   * Emotion adds `<style>` elements into this DOM node. Normally, Emotion puts these in `document.head`. This is useful if you want to render into a Shadow DOM or iframe.\n   */\n  emotionRootElement?: HTMLElement;\n  /**\n   * @deprecated No longer necessary.\n   *\n   * Required to know if a Shadow DOM is in use. This tells Emotion to change its cache configuration.\n   */\n  hasShadowDom?: boolean;\n  /**\n   * A cryptographic nonce (\"number used once\") that allows `<style>` tags injected by Emotion to pass a Content Security Policy that restricts inline styles.\n   */\n  nonce?: string;\n  /**\n   * @deprecated No longer necessary.\n   *\n   * Emotion renders into this HTML element.\n   * When enabling this prop, Emotion renders at the top of this component rather than the bottom like it does in the HTML `<head>`.\n   */\n  shadowDomElement?: HTMLDivElement | HTMLElement;\n  /** Custom Stylis plugins applied to Emotion's CSS processing pipeline. */\n  stylisPlugins?: StylisPlugin[];\n};\n\n/**\n * Configures Emotion's style cache for Odyssey components. Wrap your application in this provider when you need to render into a Shadow DOM, iframe, or non-`<head>` target element, or when your CSP requires a nonce on injected `<style>` tags.\n */\nconst OdysseyCacheProvider = ({\n  children,\n  emotionRoot,\n  emotionRootElement,\n  nonce,\n  stylisPlugins,\n}: OdysseyCacheProviderProps) => {\n  const uniqueAlphabeticalId = useUniqueAlphabeticalId();\n\n  const emotionCache = useMemo(\n    () =>\n      createCache({\n        ...((emotionRootElement || emotionRoot) && {\n          container: emotionRootElement || emotionRoot,\n        }),\n        key: uniqueAlphabeticalId,\n        nonce: nonce ?? globalThis.cspNonce,\n        prepend: true,\n        speedy: true,\n        ...(stylisPlugins && { stylisPlugins }),\n      }),\n    [\n      emotionRoot,\n      emotionRootElement,\n      nonce,\n      stylisPlugins,\n      uniqueAlphabeticalId,\n    ],\n  );\n\n  return <CacheProvider value={emotionCache}>{children}</CacheProvider>;\n};\n\nconst MemoizedOdysseyCacheProvider = memo(OdysseyCacheProvider);\nMemoizedOdysseyCacheProvider.displayName = \"OdysseyCacheProvider\";\n\nexport { MemoizedOdysseyCacheProvider as OdysseyCacheProvider };\n"],"mappings":";;;;;;AAgBA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAEA,IAAAG,wBAAA,GAAAH,OAAA;AAAuE,IAAAI,W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