/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
import { assertUnreachable } from "../../utils/assertUnreachable.js";
import { entries } from "../../utils/entries.js";
import { mapValues } from "../../utils/mapValues.js";
import { shouldNotMergeTokensIntoTailwindTheme } from "../utils/composeTailwindPlugins.js";
import plugin from "tailwindcss/plugin.js";

//#region src/tailwind/plugins/breakpoints.ts
const UDS_BREAKPOINTS_THEME_KEY = "udsBreakpoints";
const getScreensTheme = (config, mergeTokensIntoTailwindTheme) => {
	const breakpoints = mapValues(config, (breakpoint) => {
		switch (breakpoint.type) {
			case "px": return `${breakpoint.value}px`;
		}
		return assertUnreachable(breakpoint.type);
	});
	if (!mergeTokensIntoTailwindTheme) return { [UDS_BREAKPOINTS_THEME_KEY]: breakpoints };
	return {
		[UDS_BREAKPOINTS_THEME_KEY]: breakpoints,
		screens: breakpoints
	};
};
const breakpointsPlugin = plugin.withOptions(({ config }) => ({ addVariant }) => {
	const breakpoints = entries(config.breakpoints).sort(([, { value: minWidthA }], [, { value: minWidthB }]) => minWidthA - minWidthB);
	for (const [name, { value: minWidth }] of breakpoints) addVariant(`uds-${name}`, `@media (min-width: ${minWidth}px)`);
}, ({ config, disableOverrideTailwindTheme }) => {
	const shouldNotMergeScreensTokensIntoTailwindTheme = shouldNotMergeTokensIntoTailwindTheme(disableOverrideTailwindTheme, "screens");
	return { theme: { extend: { ...getScreensTheme(config.breakpoints, !shouldNotMergeScreensTokensIntoTailwindTheme) } } };
});

//#endregion
export { breakpointsPlugin };
//# sourceMappingURL=breakpoints.js.map