/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
const require_properties = require('../automated-config/dist/properties.cjs');

//#region src/css/utils.ts
/**
* Extract variant defaults from a UniversalTokensConfig.
* Converts from config structure to a simpler lookup format.
* e.g., { button: { defaults: { size: 'md' } } } -> { Button: { size: 'md' } }
*/
const extractVariantDefaults = (config) => {
	const componentNameMap = {
		avatar: "Avatar",
		badge: "Badge",
		button: "Button",
		checkbox: "Checkbox",
		chip: "Chip",
		divider: "Divider",
		iconButton: "IconButton",
		input: "Input",
		link: "Link",
		menu: "Menu",
		radio: "Radio",
		switch: "Switch"
	};
	return Object.entries(config).reduce((acc, [configKey, componentConfig]) => {
		const pascalName = componentNameMap[configKey];
		if (!pascalName || !componentConfig || typeof componentConfig !== "object") return acc;
		const configWithDefaults = componentConfig;
		return configWithDefaults.defaults ? {
			...acc,
			[pascalName]: configWithDefaults.defaults
		} : acc;
	}, {});
};
/**
* Format bytes to human readable string
*/
const formatBytes = (bytes) => {
	if (bytes < 1024) return `${bytes} B`;
	const kb = bytes / 1024;
	if (kb < 1024) return `${kb.toFixed(1)} KB`;
	return `${(kb / 1024).toFixed(2)} MB`;
};
/**
* Get motion CSS variable prefixes needed by a set of components.
* Looks up motionVarPrefixes from componentData.json for each component.
*/
const getMotionVarPrefixes = (componentData, components) => {
	const prefixes = components.flatMap((componentName) => {
		return componentData[componentName]?.motionVarPrefixes ?? [];
	});
	return [...new Set(prefixes)];
};
/**
* Collect css variable names exposed by configurable properties.
*/
const getConfigurableCssVariables = () => {
	const udsVarPrefix = "--uds";
	const cssVars = Object.values(require_properties.configurableProperties).flatMap(({ cssProperties }) => {
		if (typeof cssProperties === "string") return cssProperties.startsWith(udsVarPrefix) ? [cssProperties] : [];
		if (Array.isArray(cssProperties)) return cssProperties.filter((cssProperty) => typeof cssProperty === "string" && cssProperty.startsWith(udsVarPrefix));
		return [];
	});
	return [...new Set(["--uds-button-gap", ...cssVars])];
};

//#endregion
exports.extractVariantDefaults = extractVariantDefaults;
exports.formatBytes = formatBytes;
exports.getConfigurableCssVariables = getConfigurableCssVariables;
exports.getMotionVarPrefixes = getMotionVarPrefixes;