import { useTenantStore } from "../../stores/tenantStore.mjs";
import { greyScale, useTypeScale, verticalPrimary, verticalSecondary } from "../style/verticalStyles.mjs";
import { useRouteRegistry } from "../../routes/routeRegistryStore.mjs";
import { c } from "react-compiler-runtime";
import React, { useState } from "react";
import { CssBaseline, lighten } from "@material-ui/core";
import { initializeTheme } from "udp-react-stencil-component-library";
import { createTheme } from "@material-ui/core/styles";
import MuiThemeProvider from "@material-ui/styles/esm/ThemeProvider";
//#region src/utilities/theme/theme.jsx
/**
* Custom MUI theme provider
*/
const ThemeProvider = (t0) => {
	const $ = c(77);
	const { children } = t0;
	const [h1, h2, h3, h4, h5, h6, body1, body2, subtitle1, subtitle2, subtitle3, button, caption, caption2, overline] = useTypeScale();
	const [mode, setMode] = useState("light");
	const activeTenant = useTenantStore()?.currentTenant ?? null;
	const tenantTheme = activeTenant?.theme ?? null;
	const routeConfig = useRouteRegistry(_temp);
	const isThemeInitialized = Boolean(activeTenant?.tenantId);
	const t1 = routeConfig?.isPublic === true && !tenantTheme ? "sap" : tenantTheme ?? "";
	let t2;
	if ($[0] !== t1) {
		t2 = t1.toLowerCase();
		$[0] = t1;
		$[1] = t2;
	} else t2 = $[1];
	const resolvedTheme = t2;
	let t3;
	if ($[2] !== mode || $[3] !== tenantTheme) {
		t3 = () => ({
			mode,
			currentTheme: tenantTheme ?? ""
		});
		$[2] = mode;
		$[3] = tenantTheme;
		$[4] = t3;
	} else t3 = $[4];
	const getThemeData = t3;
	let t4;
	if ($[5] !== body1.letterSpacing || $[6] !== body1.lineHeight || $[7] !== body1.size || $[8] !== body1.weight || $[9] !== body2.letterSpacing || $[10] !== body2.lineHeight || $[11] !== body2.size || $[12] !== body2.weight || $[13] !== button.letterSpacing || $[14] !== button.lineHeight || $[15] !== button.size || $[16] !== button.weight || $[17] !== caption.letterSpacing || $[18] !== caption.lineHeight || $[19] !== caption.size || $[20] !== caption.weight || $[21] !== caption2.letterSpacing || $[22] !== caption2.lineHeight || $[23] !== caption2.size || $[24] !== caption2.weight || $[25] !== h1.letterSpacing || $[26] !== h1.lineHeight || $[27] !== h1.size || $[28] !== h1.weight || $[29] !== h2.letterSpacing || $[30] !== h2.lineHeight || $[31] !== h2.size || $[32] !== h2.weight || $[33] !== h3.letterSpacing || $[34] !== h3.lineHeight || $[35] !== h3.size || $[36] !== h3.weight || $[37] !== h4.letterSpacing || $[38] !== h4.lineHeight || $[39] !== h4.size || $[40] !== h4.weight || $[41] !== h5.letterSpacing || $[42] !== h5.lineHeight || $[43] !== h5.size || $[44] !== h5.weight || $[45] !== h6.letterSpacing || $[46] !== h6.lineHeight || $[47] !== h6.size || $[48] !== h6.weight || $[49] !== mode || $[50] !== overline.letterSpacing || $[51] !== overline.lineHeight || $[52] !== overline.size || $[53] !== overline.weight || $[54] !== resolvedTheme || $[55] !== subtitle1.letterSpacing || $[56] !== subtitle1.lineHeight || $[57] !== subtitle1.size || $[58] !== subtitle1.weight || $[59] !== subtitle2.letterSpacing || $[60] !== subtitle2.lineHeight || $[61] !== subtitle2.size || $[62] !== subtitle2.weight || $[63] !== subtitle3.letterSpacing || $[64] !== subtitle3.lineHeight || $[65] !== subtitle3.size || $[66] !== subtitle3.weight) {
		const { augmentColor } = createTheme().palette;
		const primary = verticalPrimary(resolvedTheme);
		const secondary = verticalSecondary(resolvedTheme);
		initializeTheme({
			primaryColor: primary,
			mode
		});
		let t5;
		if ($[68] === Symbol.for("react.memo_cache_sentinel")) {
			t5 = [
				"Segoe UI",
				"Roboto",
				"Noto",
				"Helvetica Neue",
				"Helvetica",
				"Ubuntu",
				"Arial",
				"sans-serif",
				"Apple Color Emoji",
				"Segoe UI Emoji",
				"Segoe UI Symbol"
			].map(_temp2);
			$[68] = t5;
		} else t5 = $[68];
		t4 = createTheme({
			...createTheme({
				palette: {
					type: mode,
					primary: {
						main: primary,
						light: lighten(primary, .8)
					},
					secondary: { main: secondary },
					appBar: augmentColor({ main: "#021b38" }),
					background: {
						default: greyScale(mode),
						footer: "#021b38"
					}
				},
				dimensions: { drawerWidth: 200 },
				typography: { fontFamily: t5.join(", ") },
				mixins: {},
				props: { MuiTextField: {
					margin: "normal",
					variant: "filled",
					fullWidth: true
				} }
			}),
			overrides: {
				MuiCssBaseline: { "@global": {
					"*, *::before, *::after": { boxSizing: "border-box" },
					"*::-webkit-scrollbar": {
						height: 8,
						width: 8,
						backgroundColor: "#fff"
					},
					"*::-webkit-scrollbar-track": { backgroundColor: "#fff" },
					"*::-webkit-scrollbar-track:hover": { backgroundColor: "#f4f4f4" },
					"*::-webkit-scrollbar-thumb": {
						backgroundColor: "#babac0",
						borderRadius: 16,
						border: "2px solid #fff"
					},
					"*::-webkit-scrollbar-thumb:hover": {
						backgroundColor: "#a0a0a5",
						border: "2px solid #f4f4f4"
					}
				} },
				MuiTypography: {
					h1: {
						fontSize: h1.size,
						fontWeight: h1.weight,
						lineHeight: h1.lineHeight,
						letterSpacing: h1.letterSpacing
					},
					h2: {
						fontSize: h2.size,
						fontWeight: h2.weight,
						lineHeight: h2.lineHeight,
						letterSpacing: h2.letterSpacing
					},
					h3: {
						fontSize: h3.size,
						fontWeight: h3.weight,
						lineHeight: h3.lineHeight,
						letterSpacing: h3.letterSpacing
					},
					h4: {
						fontSize: h4.size,
						fontWeight: h4.weight,
						lineHeight: h4.lineHeight,
						letterSpacing: h4.letterSpacing
					},
					h5: {
						fontSize: h5.size,
						fontWeight: h5.weight,
						lineHeight: h5.lineHeight,
						letterSpacing: h5.letterSpacing
					},
					h6: {
						fontSize: h6.size,
						fontWeight: h6.weight,
						lineHeight: h6.lineHeight,
						letterSpacing: h6.letterSpacing
					},
					subtitle1: {
						fontSize: subtitle1.size,
						fontWeight: subtitle1.weight,
						lineHeight: subtitle1.lineHeight,
						letterSpacing: subtitle1.letterSpacing
					},
					subtitle2: {
						fontSize: subtitle2.size,
						fontWeight: subtitle2.weight,
						lineHeight: subtitle2.lineHeight,
						letterSpacing: subtitle2.letterSpacing
					},
					subtitle3: {
						fontSize: subtitle3.size,
						fontWeight: subtitle3.weight,
						lineHeight: subtitle3.lineHeight,
						letterSpacing: subtitle3.letterSpacing
					},
					body1: {
						fontSize: body1.size,
						fontWeight: body1.weight,
						lineHeight: body1.lineHeight,
						letterSpacing: body1.letterSpacing
					},
					body2: {
						fontSize: body2.size,
						fontWeight: body2.weight,
						lineHeight: body2.lineHeight,
						letterSpacing: body2.letterSpacing
					},
					button: {
						fontSize: button.size,
						fontWeight: button.weight,
						lineHeight: button.lineHeight,
						letterSpacing: button.letterSpacing
					},
					caption: {
						fontSize: caption.size,
						fontWeight: caption.weight,
						lineHeight: caption.lineHeight,
						letterSpacing: caption.letterSpacing
					},
					caption2: {
						fontSize: caption2.size,
						fontWeight: caption2.weight,
						lineHeight: caption2.lineHeight,
						letterSpacing: caption2.letterSpacing
					},
					overline: {
						fontSize: overline.size,
						fontWeight: overline.weight,
						lineHeight: overline.lineHeight,
						letterSpacing: overline.letterSpacing
					}
				}
			}
		});
		$[5] = body1.letterSpacing;
		$[6] = body1.lineHeight;
		$[7] = body1.size;
		$[8] = body1.weight;
		$[9] = body2.letterSpacing;
		$[10] = body2.lineHeight;
		$[11] = body2.size;
		$[12] = body2.weight;
		$[13] = button.letterSpacing;
		$[14] = button.lineHeight;
		$[15] = button.size;
		$[16] = button.weight;
		$[17] = caption.letterSpacing;
		$[18] = caption.lineHeight;
		$[19] = caption.size;
		$[20] = caption.weight;
		$[21] = caption2.letterSpacing;
		$[22] = caption2.lineHeight;
		$[23] = caption2.size;
		$[24] = caption2.weight;
		$[25] = h1.letterSpacing;
		$[26] = h1.lineHeight;
		$[27] = h1.size;
		$[28] = h1.weight;
		$[29] = h2.letterSpacing;
		$[30] = h2.lineHeight;
		$[31] = h2.size;
		$[32] = h2.weight;
		$[33] = h3.letterSpacing;
		$[34] = h3.lineHeight;
		$[35] = h3.size;
		$[36] = h3.weight;
		$[37] = h4.letterSpacing;
		$[38] = h4.lineHeight;
		$[39] = h4.size;
		$[40] = h4.weight;
		$[41] = h5.letterSpacing;
		$[42] = h5.lineHeight;
		$[43] = h5.size;
		$[44] = h5.weight;
		$[45] = h6.letterSpacing;
		$[46] = h6.lineHeight;
		$[47] = h6.size;
		$[48] = h6.weight;
		$[49] = mode;
		$[50] = overline.letterSpacing;
		$[51] = overline.lineHeight;
		$[52] = overline.size;
		$[53] = overline.weight;
		$[54] = resolvedTheme;
		$[55] = subtitle1.letterSpacing;
		$[56] = subtitle1.lineHeight;
		$[57] = subtitle1.size;
		$[58] = subtitle1.weight;
		$[59] = subtitle2.letterSpacing;
		$[60] = subtitle2.lineHeight;
		$[61] = subtitle2.size;
		$[62] = subtitle2.weight;
		$[63] = subtitle3.letterSpacing;
		$[64] = subtitle3.lineHeight;
		$[65] = subtitle3.size;
		$[66] = subtitle3.weight;
		$[67] = t4;
	} else t4 = $[67];
	const fullTheme = t4;
	let t5;
	if ($[69] !== fullTheme || $[70] !== getThemeData || $[71] !== isThemeInitialized) {
		t5 = {
			...fullTheme,
			isInitialized: isThemeInitialized,
			setMode,
			getThemeData
		};
		$[69] = fullTheme;
		$[70] = getThemeData;
		$[71] = isThemeInitialized;
		$[72] = t5;
	} else t5 = $[72];
	const theme = t5;
	let t6;
	if ($[73] === Symbol.for("react.memo_cache_sentinel")) {
		t6 = /* @__PURE__ */ React.createElement(CssBaseline, null);
		$[73] = t6;
	} else t6 = $[73];
	let t7;
	if ($[74] !== children || $[75] !== theme) {
		t7 = /* @__PURE__ */ React.createElement(MuiThemeProvider, { theme }, t6, children);
		$[74] = children;
		$[75] = theme;
		$[76] = t7;
	} else t7 = $[76];
	return t7;
};
function _temp(state) {
	return state.routeMap[state.currentPath];
}
function _temp2(item) {
	return item.includes(" ") ? `"${item}"` : item;
}
//#endregion
export { ThemeProvider };

//# sourceMappingURL=theme.mjs.map