/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
const require_index = require('../../fixtures/dist/index.cjs');
const require_index$1 = require('../../css-tokens/dist/index.cjs');
const require_entries = require('../../utils/entries.cjs');
const require_getResponsiveTextStyles = require('../components/getResponsiveTextStyles.cjs');
const require_defaultTailwindThemeAsUdsConfig = require('../defaultTailwindThemeAsUdsConfig.cjs');
const require_fromEntries = require('../../utils/fromEntries.cjs');
const require_composeTailwindPlugins = require('../utils/composeTailwindPlugins.cjs');
const require_addFontFaceDeclarations = require('../base/addFontFaceDeclarations.cjs');
const require_addFontVars = require('../base/addFontVars.cjs');
const require_getGroupedTextStyles = require('../components/getGroupedTextStyles.cjs');
const require_getFontFamilyTheme = require('../theme/getFontFamilyTheme.cjs');
let tailwindcss_plugin_js = require("tailwindcss/plugin.js");
tailwindcss_plugin_js = require_runtime.__toESM(tailwindcss_plugin_js);

//#region src/tailwind/plugins/typography.ts
const UDS_FONT_FAMILY_THEME_KEY = "udsFontFamily";
const UDS_FONT_SIZE_THEME_KEY = "udsFontSize";
const UDS_FONT_WEIGHT_THEME_KEY = "udsFontWeight";
const UDS_FONT_SLANT_THEME_KEY = "udsFontSlant";
const UDS_LINE_HEIGHT_THEME_KEY = "udsLineHeight";
const UDS_LETTER_SPACING_THEME_KEY = "udsLetterSpacing";
const UDS_TEXT_TRANSFORM_THEME_KEY = "udsTextTransform";
const UDS_FONT_WIDTH_THEME_KEY = "udsFontWidth";
/** @deprecated Descriptive font weights vary based on font, so this is not correct for each font we support
* This is used as a baseline for using native font weights in the system IE. <Text fontWeight="bold" />
*/
const fontWeightMap = {
	thin: "100",
	extralight: "200",
	light: "300",
	regular: "400",
	medium: "500",
	semibold: "600",
	bold: "700",
	extrabold: "800",
	black: "900"
};
const typographyPlugin = tailwindcss_plugin_js.default.withOptions(({ config, disableOverrideTailwindTheme, disableFontFaceDeclarations = false }) => (api) => {
	const shouldMergeTypographyTokensIntoTailwindTheme = !require_composeTailwindPlugins.shouldNotMergeTokensIntoTailwindTheme(disableOverrideTailwindTheme, "typography");
	const { addBase, addUtilities, addComponents, matchUtilities, theme } = api;
	const fontIds = Object.values(config.font);
	if (disableFontFaceDeclarations === false) require_addFontFaceDeclarations.addFontFaceDeclarations(fontIds, api);
	require_addFontVars.addFontVars(config.font, api);
	addBase(require_getResponsiveTextStyles.getBaseTextVars(config));
	addBase(require_getGroupedTextStyles.getGroupedTextStyles());
	if ((config.globalDefaults.enableResponsiveType ?? false) && config.typography && config.breakpoints) addComponents(require_getResponsiveTextStyles.getResponsiveTextStyles(config));
	const namedFontWeightsFromPlugin = theme("udsFontWeight") || {};
	const fontWeightsWithDescriptives = {
		...fontWeightMap,
		...namedFontWeightsFromPlugin
	};
	Object.entries(fontWeightsWithDescriptives).forEach(([fontWeight, value]) => {
		const styles = {};
		if (require_index.textVariants.map(require_getResponsiveTextStyles.textVariantsSafe).includes(fontWeight)) {
			const textVariant = fontWeight;
			const slantValue = theme(`udsFontSlant.${textVariant}`);
			const widthValue = theme(`udsFontWidth.${textVariant}`);
			styles["font-weight"] = value;
			styles["font-variation-settings"] = `"wght" ${value}, "slnt" ${slantValue}, "ital" ${slantValue}, "wdth" ${widthValue}`;
			const bolderStyles = { "font-variation-settings": "normal" };
			styles["b"] = bolderStyles;
			styles["strong"] = bolderStyles;
		} else styles["font-weight"] = value;
		if (shouldMergeTypographyTokensIntoTailwindTheme) addUtilities({ [`.font-weight-${fontWeight}`]: styles });
		addUtilities({ [`.uds-font-weight-${fontWeight}`]: styles });
	});
	if (shouldMergeTypographyTokensIntoTailwindTheme) matchUtilities({ "font-size": (value) => ({ "font-size": value }) }, { values: theme(UDS_FONT_SIZE_THEME_KEY) });
	matchUtilities({ "uds-font-size": (value) => ({ "font-size": value }) }, { values: theme(UDS_FONT_SIZE_THEME_KEY) });
	matchUtilities({ "uds-font-family": (value) => ({ "font-family": value }) }, { values: theme(UDS_FONT_FAMILY_THEME_KEY) });
	matchUtilities({ "uds-line-height": (value) => ({ "line-height": value }) }, { values: theme(UDS_LINE_HEIGHT_THEME_KEY) });
	matchUtilities({ "uds-letter-spacing": (value) => ({ "letter-spacing": value }) }, { values: theme(UDS_LETTER_SPACING_THEME_KEY) });
	if (shouldMergeTypographyTokensIntoTailwindTheme) matchUtilities({ case: (value) => ({ "text-transform": value }) }, { values: theme(UDS_TEXT_TRANSFORM_THEME_KEY) });
	matchUtilities({ "uds-text-transform": (value) => {
		return { "text-transform": value };
	} }, { values: theme(UDS_TEXT_TRANSFORM_THEME_KEY) });
}, ({ disableOverrideTailwindTheme }) => {
	const shouldNotMergeTypographyTokensIntoTailwindTheme = require_composeTailwindPlugins.shouldNotMergeTokensIntoTailwindTheme(disableOverrideTailwindTheme, "typography");
	/**
	* Reassign Tailwind's font size aliases to UDS's font size aliases
	* This makes it so UDS configs can power both Tailwind and UDS components
	*/
	const tailwindFontSize = require_fromEntries.fromEntries(require_entries.entries(require_defaultTailwindThemeAsUdsConfig.udsToTailwindMap.fontSize).map(([udsAlias, twAlias]) => {
		return [twAlias, [`var(--${require_index$1.FONT_SIZE_PREFIX}-${require_getResponsiveTextStyles.textVariantsSafe(udsAlias)})`, { lineHeight: `var(--${require_index$1.LINE_HEIGHT_PREFIX}-${require_getResponsiveTextStyles.textVariantsSafe(udsAlias)})` }]];
	}));
	const textClasses = require_index.textVariants.map((variant) => `uds-text-${require_getResponsiveTextStyles.textVariantsSafe(variant)}`);
	const responsiveTextClasses = [require_index$1.TEXT_RESPONSIVE_CLASSNAME, ...Object.keys(require_index$1.TEXT_RESPONSIVE_BREAKPOINT_CLASSNAMES).map((variant) => require_index$1.TEXT_RESPONSIVE_BREAKPOINT_CLASSNAMES[variant])];
	const fontFamily = require_getFontFamilyTheme.getFontFamilyTheme();
	const { lineHeight, letterSpacing, fontSize, textTransform, fontWeight, fontSlant, fontWidth } = require_getResponsiveTextStyles.RESPONSIVE_TAILWIND_CONFIG_MAP;
	return {
		safelist: [...textClasses, ...responsiveTextClasses],
		theme: { extend: {
			...shouldNotMergeTypographyTokensIntoTailwindTheme ? {} : {
				fontFamily,
				fontSize: tailwindFontSize,
				lineHeight,
				letterSpacing
			},
			[UDS_FONT_FAMILY_THEME_KEY]: fontFamily,
			[UDS_FONT_SIZE_THEME_KEY]: fontSize,
			[UDS_FONT_WEIGHT_THEME_KEY]: fontWeight,
			[UDS_FONT_SLANT_THEME_KEY]: fontSlant,
			[UDS_LINE_HEIGHT_THEME_KEY]: lineHeight,
			[UDS_LETTER_SPACING_THEME_KEY]: letterSpacing,
			[UDS_TEXT_TRANSFORM_THEME_KEY]: textTransform,
			[UDS_FONT_WIDTH_THEME_KEY]: fontWidth
		} }
	};
});

//#endregion
exports.typographyPlugin = typographyPlugin;