/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
import { __toESM } from "../_virtual/_rolldown/runtime.js";
import { require_plugin } from "../node_modules/.bun/tailwindcss@3.4.19_7500dce058369e0a/node_modules/tailwindcss/plugin.js";
import { ALWAYS_PREFIX, deprecatedAlwaysPalette, newAlwaysPalette } from "../packages/palette/dist/index.js";
import { BACKGROUND_COLOR_PREFIX, DARK_COLOR_MODE_CLASSNAME, INVERT_COLOR_MODE_CLASSNAME, LIGHT_COLOR_MODE_CLASSNAME, SYSTEM_COLOR_MODE_CLASSNAME } from "../packages/css-tokens/dist/index.js";
import { mapValues as mapValues$1 } from "../packages/utils/dist/mapValues.js";
import { parseTokens } from "../utils/parseTokens.js";
import { DEFAULT_COLOR_MODE } from "../packages/modes/dist/index.js";
import { addColorModeVars } from "../base/addColorModeVars.js";
import { addColorModeVarsV2 } from "../base/addColorModeVarsV2.js";
import { getTailwindAsUdsColors } from "./getTailwindAsUdsColors.js";
import { mapKeys } from "lodash-es";
//#region ../tailwind-internal/dist/plugins/colors.js
/*! © 2026 Yahoo, Inc. UDS Tailwind Internal v0.0.0-development */
var import_plugin = /* @__PURE__ */ __toESM(require_plugin(), 1);
const tailwindColorsAsUds = getTailwindAsUdsColors();
const colorsPlugin = import_plugin.default.withOptions(({ config, enableSystemColorMode = false }) => (api) => {
	const tokens = parseTokens(config);
	if (enableSystemColorMode) addColorModeVarsV2(tokens, api);
	else addColorModeVars(tokens, api);
}, ({ config }) => {
	const colorModeToken = parseTokens(config).colorMode[DEFAULT_COLOR_MODE].tailwindConfig;
	const spectrumWithTailwind = mapValues$1(colorModeToken.spectrum, (hueConfig, hue) => {
		return {
			...hueConfig,
			...tailwindColorsAsUds[hue]
		};
	});
	const nestedNewAlwaysPalette = mapKeys(newAlwaysPalette, (_, key) => key.replace(ALWAYS_PREFIX, ""));
	const colors = {
		...tailwindColorsAsUds,
		...spectrumWithTailwind,
		...deprecatedAlwaysPalette,
		always: nestedNewAlwaysPalette
	};
	const textColors = colorModeToken.palette.foreground;
	const backgroundColors = colorModeToken.palette.background;
	const borderColors = colorModeToken.palette.line;
	const elevationBackgroundColors = config.elevation ? Object.fromEntries(Object.keys(config.elevation).map((level) => [`elevation-${level}`, `var(--${BACKGROUND_COLOR_PREFIX}-elevation-${level})`])) : {};
	return {
		darkMode: ["class", DARK_COLOR_MODE_CLASSNAME],
		safelist: [
			LIGHT_COLOR_MODE_CLASSNAME,
			DARK_COLOR_MODE_CLASSNAME,
			INVERT_COLOR_MODE_CLASSNAME,
			SYSTEM_COLOR_MODE_CLASSNAME
		],
		theme: { 
		/**
		* Preserve the default values from Tailwind, but also add new values
		* https://tailwindcss.com/docs/theme#extending-the-default-theme
		*/
extend: {
			/**
			* Colors object is included by default, but that does not include UDS semantic border colors
			* https://github.com/tailwindlabs/tailwindcss/blob/main/stubs/config.full.js#L743
			*/
			outlineColor: {
				...borderColors,
				DEFAULT: colors.gray["15"]
			},
			/**
			* https://github.com/tailwindlabs/tailwindcss/blob/main/stubs/config.full.js#L133
			*/
			colors,
			/**
			* Colors object is included by default, but that does not include UDS semantic background colors
			* https://github.com/tailwindlabs/tailwindcss/blob/main/stubs/config.full.js#L42
			*/
			backgroundColor: backgroundColors,
			/**
			* Colors object is included by default, but that does not include UDS semantic text colors
			* https://github.com/tailwindlabs/tailwindcss/blob/main/stubs/config.full.js#L889
			*/
			textColor: textColors,
			/**
			* Colors object is included by default, but that does not include UDS semantic border colors
			* https://github.com/tailwindlabs/tailwindcss/blob/main/stubs/config.full.js#L82
			*/
			borderColor: borderColors,
			/**
			* Colors object is included by default, but that does not include UDS semantic background colors
			* https://github.com/tailwindlabs/tailwindcss/blob/main/stubs/config.full.js#L253
			*/
			fill: backgroundColors,
			/**
			* Colors object is included by default, but that does not include UDS semantic text colors
			* https://github.com/tailwindlabs/tailwindcss/blob/main/stubs/config.full.js#L132
			*/
			caretColor: textColors,
			/**
			* Colors object is included by default, but that does not include UDS semantic text colors
			* https://github.com/tailwindlabs/tailwindcss/blob/main/stubs/config.full.js#L759
			*/
			placeholderColor: textColors,
			/**
			* Colors object is included by default, but that does not include UDS semantic text colors
			* https://github.com/tailwindlabs/tailwindcss/blob/main/stubs/config.full.js#L890
			*/
			textDecorationColor: textColors,
			/**
			* Colors object is included by default, but that does not include UDS semantic border colors
			* https://github.com/tailwindlabs/tailwindcss/blob/main/stubs/config.full.js#L241
			*/
			divideColor: borderColors,
			/**
			* Colors object is included by default, but that does not include UDS semantic border colors
			* https://github.com/tailwindlabs/tailwindcss/blob/main/stubs/config.full.js#L761
			*/
			ringColor: borderColors,
			/**
			* Colors object is included by default, but that does not include UDS semantic border colors
			* https://github.com/tailwindlabs/tailwindcss/blob/main/stubs/config.full.js#L765
			*/
			ringOffsetColor: borderColors,
			/**
			* Colors object is included by default, but that does not include UDS semantic border colors
			* https://github.com/tailwindlabs/tailwindcss/blob/main/stubs/config.full.js#L878
			*/
			stroke: borderColors,
			/**
			* Gradient color stops object is included by default, but that does not include UDS palette background colors
			* https://github.com/tailwindlabs/tailwindcss/blob/main/stubs/config.full.js#L42
			*/
			gradientColorStops: {
				...backgroundColors,
				...elevationBackgroundColors,
				...colors
			}
		} }
	};
});
//#endregion
export { colorsPlugin };
