"use client";
import { getPrimaryShade } from "../get-primary-shade/get-primary-shade.mjs";
import { isLightColor } from "../luminance/luminance.mjs";
//#region packages/@mantine/core/src/core/MantineProvider/color-functions/parse-theme-color/parse-theme-color.ts
function parseThemeColor({ color, theme, colorScheme }) {
	if (typeof color !== "string") throw new Error(`[@mantine/core] Failed to parse color. Expected color to be a string, instead got ${typeof color}`);
	if (color === "bright") return {
		color,
		value: colorScheme === "dark" ? theme.white : theme.black,
		shade: void 0,
		isThemeColor: false,
		isLight: isLightColor(colorScheme === "dark" ? theme.white : theme.black, theme.luminanceThreshold),
		variable: "--mantine-color-bright"
	};
	if (color === "dimmed") return {
		color,
		value: colorScheme === "dark" ? theme.colors.dark[2] : theme.colors.gray[7],
		shade: void 0,
		isThemeColor: false,
		isLight: isLightColor(colorScheme === "dark" ? theme.colors.dark[2] : theme.colors.gray[6], theme.luminanceThreshold),
		variable: "--mantine-color-dimmed"
	};
	if (color === "white" || color === "black") return {
		color,
		value: color === "white" ? theme.white : theme.black,
		shade: void 0,
		isThemeColor: false,
		isLight: isLightColor(color === "white" ? theme.white : theme.black, theme.luminanceThreshold),
		variable: `--mantine-color-${color}`
	};
	const [_color, shade] = color.split(".");
	const colorShade = shade ? Number(shade) : void 0;
	const isThemeColor = _color in theme.colors;
	if (isThemeColor) {
		const colorValue = colorShade !== void 0 ? theme.colors[_color][colorShade] : theme.colors[_color][getPrimaryShade(theme, colorScheme || "light")];
		return {
			color: _color,
			value: colorValue,
			shade: colorShade,
			isThemeColor,
			isLight: isLightColor(colorValue, theme.luminanceThreshold),
			variable: shade ? `--mantine-color-${_color}-${colorShade}` : `--mantine-color-${_color}-filled`
		};
	}
	return {
		color,
		value: color,
		isThemeColor,
		isLight: isLightColor(color, theme.luminanceThreshold),
		shade: colorShade,
		variable: void 0
	};
}
//#endregion
export { parseThemeColor };

//# sourceMappingURL=parse-theme-color.mjs.map