/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
const require_colors = require('../cli/dist/lib/colors.cjs');
const require_print = require('../cli/dist/lib/print.cjs');
const require_generatePurgeCSSData = require('../utils/generatePurgeCSSData.cjs');
let node_path = require("node:path");
node_path = require_runtime.__toESM(node_path);

//#region src/commands/generatePurgeCSSData.ts
const makeGeneratePurgeCSSDataCommand = (getContext) => ({
	name: "generatePurgeCSSData",
	description: `Generates purge CSS data for UDS components. This is an internal command used to generate the data needed to purge unused CSS in UDS. It should not be used directly by users.`,
	tag: "hidden",
	run: async (_props) => {
		const { project, variants, UDS, UDS_EXPERIMENTAL } = await getContext();
		const exportedComponents = require_generatePurgeCSSData.getExportedComponents(UDS, UDS_EXPERIMENTAL);
		const exportsToFilePath = require_generatePurgeCSSData.getExportsToFilePath(project);
		const variantsList = require_generatePurgeCSSData.convertVariantsIntoTailwindClass(variants);
		const componentToVariants = require_generatePurgeCSSData.getComponentsProps(project, exportedComponents, variants, variantsList, exportsToFilePath);
		const componentsDependencies = require_generatePurgeCSSData.getComponentsDependencies(project, exportedComponents, exportsToFilePath);
		let componentToTwClasses = await require_generatePurgeCSSData.getTwClassesInComponent(exportedComponents, exportsToFilePath);
		componentToTwClasses = require_generatePurgeCSSData.addAutoVariantsToComponentClasses(componentToTwClasses);
		const outputFilePath = node_path.default.resolve(process.cwd(), "./generated/tailwindPurge.ts");
		const fileContent = `
//! This file is generated by \`uds purge\` from @yahoo/uds
//! Do not edit directly
//! If there is issue with this file please report to #ask-uds

export type PropToUsedOptions = [string, string[]];
export type ComponentToVariants = { [key: string]: PropToUsedOptions[] };
export type VariantsList = string[];
export type ComponentDependencies = { [key: string]: string[] };
export type ComponentToTwClasses = { [key: string]: string };

export const variantsList: VariantsList = ${JSON.stringify(variantsList)};
export const componentToVariants: ComponentToVariants = ${JSON.stringify(componentToVariants)};
export const componentToTwClasses: ComponentToTwClasses = ${JSON.stringify(componentToTwClasses)};
export const componentsDependencies: ComponentDependencies = ${JSON.stringify(componentsDependencies)};
`;
		await Bun.write(outputFilePath, fileContent);
		require_print.print(require_colors.green(`✅ Purge CSS Data saved ${outputFilePath}`));
	}
});

//#endregion
exports.makeGeneratePurgeCSSDataCommand = makeGeneratePurgeCSSDataCommand;