/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
const require_colors = require('../cli/dist/lib/colors.cjs');
const require_print = require('../cli/dist/lib/print.cjs');
const require_nodeUtils = require('../css/nodeUtils.cjs');
const require_runner = require('../css/runner.cjs');
const require_css_helpers = require('./css.helpers.cjs');

//#region src/commands/css.ts
const showHelp = () => {
	require_print.print("");
	require_print.print(`${require_colors.green("uds css")} - Generate CSS for app`);
	require_print.print("");
	require_print.print(`${require_colors.magenta("Usage:")}`);
	require_print.print(`  ${require_colors.cyan("uds css")} [options]`);
	require_print.print(`  ${require_colors.cyan("uds css init")} [options]`);
	require_print.print("");
	require_print.print(`${require_colors.magenta("Commands:")}`);
	require_print.print(`  ${require_colors.cyan("init")}              Create a new uds.theme.ts file`);
	require_print.print("");
	require_print.print(`${require_colors.magenta("Options:")}`);
	require_print.print(`  ${require_colors.cyan("--entry <path>")}    Entry directory to scan (default: /src/)`);
	require_print.print(`  ${require_colors.cyan("--outFile <path>")}  Output CSS file (default: dist/uds.css)`);
	require_print.print(`  ${require_colors.cyan("--config <path>")}   Path to uds.config.ts for tokens`);
	require_print.print(`  ${require_colors.cyan("--theme <path>")}    Path to uds.theme.ts (default: uds.theme.ts)`);
	require_print.print(`  ${require_colors.cyan("--watch, -w")}       Watch for file changes and regenerate`);
	require_print.print(`  ${require_colors.cyan("--silent, -s")}      Suppress output logging`);
	require_print.print(`  ${require_colors.cyan("--force")}           Overwrite existing uds.theme.ts (for init)`);
	require_print.print(`  ${require_colors.cyan("--help, -h")}        Show this help message`);
	require_print.print("");
	require_print.print(`${require_colors.magenta("Initialize theme config:")}`);
	require_print.print(`  ${require_colors.gray("uds css init")}`);
	require_print.print("");
	require_print.print(`${require_colors.magenta("Simple mode")} (no uds.theme.ts):`);
	require_print.print(`  ${require_colors.gray("uds css --entry ./src --outFile dist/uds.css")}`);
	require_print.print("");
	require_print.print(`${require_colors.magenta("Theme mode")} (with uds.theme.ts):`);
	require_print.print(`  ${require_colors.gray("uds css --theme uds.theme.ts --outFile dist/uds.css")}`);
	require_print.print("");
	require_print.print(`${require_colors.magenta("Example uds.theme.ts:")}`);
	require_print.print(require_colors.gray(`  import { defineTheme } from '@yahoo/uds';

  export default defineTheme({
    config: './uds.config.ts',
    entry: './src',
    colorModes: ['dark'],
    css: {
      preflight: true,
      fontFaceDeclarations: true,
      enableSystemColorMode: false,      // Auto dark mode via prefers-color-scheme
      disableOverrideTailwindTheme: true // Don't merge into Tailwind defaults
    }
  });`));
	require_print.print("");
};
const makeCSSCommand = (getContext) => ({
	name: "css",
	description: "Generate CSS for app",
	tag: "hidden",
	run: async (props) => {
		const { variants, autoVariants, componentData } = await getContext();
		if (require_css_helpers.shouldShowHelp(props.options)) {
			showHelp();
			return;
		}
		if (require_css_helpers.isInitCommand(props.first)) {
			await require_nodeUtils.scaffoldThemeConfig(require_css_helpers.getCssInitOptions(props.options));
			return;
		}
		await require_runner.runCssCommand(require_css_helpers.getCssRunOptions(process.cwd(), props.options), {
			variants,
			autoVariants,
			componentData
		});
	}
});

//#endregion
exports.makeCSSCommand = makeCSSCommand;