{"version":3,"file":"ThemeProvider.mjs","sources":["../../../../../../../../../node_modules/@mui/system/esm/ThemeProvider/ThemeProvider.js"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\nimport { ThemeProvider as MuiThemeProvider, useTheme as usePrivateTheme } from '@mui/private-theming';\nimport exactProp from '@mui/utils/exactProp';\nimport { ThemeContext as StyledEngineThemeContext } from '@mui/styled-engine';\nimport useThemeWithoutDefault from \"../useThemeWithoutDefault/index.js\";\nimport RtlProvider from \"../RtlProvider/index.js\";\nimport DefaultPropsProvider from \"../DefaultPropsProvider/index.js\";\nimport useLayerOrder from \"./useLayerOrder.js\";\nimport { jsxs as _jsxs, jsx as _jsx } from \"react/jsx-runtime\";\nconst EMPTY_THEME = {};\nfunction useThemeScoping(themeId, upperTheme, localTheme, isPrivate = false) {\n  return React.useMemo(() => {\n    const resolvedTheme = themeId ? upperTheme[themeId] || upperTheme : upperTheme;\n    if (typeof localTheme === 'function') {\n      const mergedTheme = localTheme(resolvedTheme);\n      const result = themeId ? {\n        ...upperTheme,\n        [themeId]: mergedTheme\n      } : mergedTheme;\n      // must return a function for the private theme to NOT merge with the upper theme.\n      // see the test case \"use provided theme from a callback\" in ThemeProvider.test.js\n      if (isPrivate) {\n        return () => result;\n      }\n      return result;\n    }\n    return themeId ? {\n      ...upperTheme,\n      [themeId]: localTheme\n    } : {\n      ...upperTheme,\n      ...localTheme\n    };\n  }, [themeId, upperTheme, localTheme, isPrivate]);\n}\n\n/**\n * This component makes the `theme` available down the React tree.\n * It should preferably be used at **the root of your component tree**.\n *\n * <ThemeProvider theme={theme}> // existing use case\n * <ThemeProvider theme={{ id: theme }}> // theme scoping\n */\nfunction ThemeProvider(props) {\n  const {\n    children,\n    theme: localTheme,\n    themeId\n  } = props;\n  const upperTheme = useThemeWithoutDefault(EMPTY_THEME);\n  const upperPrivateTheme = usePrivateTheme() || EMPTY_THEME;\n  if (process.env.NODE_ENV !== 'production') {\n    if (upperTheme === null && typeof localTheme === 'function' || themeId && upperTheme && !upperTheme[themeId] && typeof localTheme === 'function') {\n      console.error(['MUI: You are providing a theme function prop to the ThemeProvider component:', '<ThemeProvider theme={outerTheme => outerTheme} />', '', 'However, no outer theme is present.', 'Make sure a theme is already injected higher in the React tree ' + 'or provide a theme object.'].join('\\n'));\n    }\n  }\n  const engineTheme = useThemeScoping(themeId, upperTheme, localTheme);\n  const privateTheme = useThemeScoping(themeId, upperPrivateTheme, localTheme, true);\n  const rtlValue = (themeId ? engineTheme[themeId] : engineTheme).direction === 'rtl';\n  const layerOrder = useLayerOrder(engineTheme);\n  return /*#__PURE__*/_jsx(MuiThemeProvider, {\n    theme: privateTheme,\n    children: /*#__PURE__*/_jsx(StyledEngineThemeContext.Provider, {\n      value: engineTheme,\n      children: /*#__PURE__*/_jsx(RtlProvider, {\n        value: rtlValue,\n        children: /*#__PURE__*/_jsxs(DefaultPropsProvider, {\n          value: themeId ? engineTheme[themeId].components : engineTheme.components,\n          children: [layerOrder, children]\n        })\n      })\n    })\n  });\n}\nprocess.env.NODE_ENV !== \"production\" ? ThemeProvider.propTypes /* remove-proptypes */ = {\n  // ┌────────────────────────────── Warning ──────────────────────────────┐\n  // │ These PropTypes are generated from the TypeScript type definitions. │\n  // │    To update them, edit the d.ts file and run `pnpm proptypes`.     │\n  // └─────────────────────────────────────────────────────────────────────┘\n  /**\n   * Your component tree.\n   */\n  children: PropTypes.node,\n  /**\n   * A theme object. You can provide a function to extend the outer theme.\n   */\n  theme: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).isRequired,\n  /**\n   * The design system's unique id for getting the corresponded theme when there are multiple design systems.\n   */\n  themeId: PropTypes.string\n} : void 0;\nif (process.env.NODE_ENV !== 'production') {\n  process.env.NODE_ENV !== \"production\" ? ThemeProvider.propTypes = exactProp(ThemeProvider.propTypes) : void 0;\n}\nexport default ThemeProvider;"],"names":["ThemeProvider","useThemeWithoutDefault","usePrivateTheme","_jsx","MuiThemeProvider","StyledEngineThemeContext","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