import { jsx } from "react/jsx-runtime";
//#region src/components/ThemeProvider/theme-script.tsx
/**
* Generates inline script for SSR flash prevention
*
* Usage in Next.js App Router:
* ```tsx
* <script dangerouslySetInnerHTML={{ __html: getThemeScript() }} />
* ```
*
* Precedence: localStorage > cookie > system preference > defaultTheme
*
* Note: Cookie is written client-side, so only available on subsequent
* SSR requests (not first visit).
*/
function getThemeScript(options = {}) {
	const { storageKey = "theme", defaultTheme = "light", attribute = "class" } = options;
	return `!function(){try{var e=localStorage.getItem('${storageKey}');if(e)var t=e;else{var o=window.matchMedia('(prefers-color-scheme: dark)').matches;t='${defaultTheme}'==='system'?o?'dark':'light':'${defaultTheme}'}if('${attribute}'==='class'){var a='dark'===t;a?document.documentElement.classList.add('dark'):document.documentElement.classList.remove('dark')}else document.documentElement.setAttribute('${attribute}',t)}catch(e){}}()`;
}
/**
* ThemeScript component for SSR flash prevention
*
* Renders an inline script that runs before React hydrates to prevent
* flash of wrong theme. Place in <head> of your document.
*
* @example
* ```tsx
* // In Next.js layout.tsx
* <head>
*   <ThemeScript />
* </head>
* ```
*/
function ThemeScript({ storageKey = "theme", defaultTheme = "light", nonce } = {}) {
	return /* @__PURE__ */ jsx("script", {
		nonce,
		dangerouslySetInnerHTML: { __html: getThemeScript({
			storageKey,
			defaultTheme
		}) }
	});
}
//#endregion
export { ThemeScript, getThemeScript };

//# sourceMappingURL=index36.js.map