/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
import { cyan, gray, green, magenta } from "../cli/dist/lib/colors.js";
import { print } from "../cli/dist/lib/print.js";
import { scaffoldThemeConfig } from "../css/nodeUtils.js";
import { runCssCommand } from "../css/runner.js";
import { getCssInitOptions, getCssRunOptions, isInitCommand, shouldShowHelp } from "./css.helpers.js";

//#region src/commands/css.ts
const showHelp = () => {
	print("");
	print(`${green("uds css")} - Generate CSS for app`);
	print("");
	print(`${magenta("Usage:")}`);
	print(`  ${cyan("uds css")} [options]`);
	print(`  ${cyan("uds css init")} [options]`);
	print("");
	print(`${magenta("Commands:")}`);
	print(`  ${cyan("init")}              Create a new uds.theme.ts file`);
	print("");
	print(`${magenta("Options:")}`);
	print(`  ${cyan("--entry <path>")}    Entry directory to scan (default: /src/)`);
	print(`  ${cyan("--outFile <path>")}  Output CSS file (default: dist/uds.css)`);
	print(`  ${cyan("--config <path>")}   Path to uds.config.ts for tokens`);
	print(`  ${cyan("--theme <path>")}    Path to uds.theme.ts (default: uds.theme.ts)`);
	print(`  ${cyan("--watch, -w")}       Watch for file changes and regenerate`);
	print(`  ${cyan("--silent, -s")}      Suppress output logging`);
	print(`  ${cyan("--force")}           Overwrite existing uds.theme.ts (for init)`);
	print(`  ${cyan("--help, -h")}        Show this help message`);
	print("");
	print(`${magenta("Initialize theme config:")}`);
	print(`  ${gray("uds css init")}`);
	print("");
	print(`${magenta("Simple mode")} (no uds.theme.ts):`);
	print(`  ${gray("uds css --entry ./src --outFile dist/uds.css")}`);
	print("");
	print(`${magenta("Theme mode")} (with uds.theme.ts):`);
	print(`  ${gray("uds css --theme uds.theme.ts --outFile dist/uds.css")}`);
	print("");
	print(`${magenta("Example uds.theme.ts:")}`);
	print(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
    }
  });`));
	print("");
};
const makeCSSCommand = (getContext) => ({
	name: "css",
	description: "Generate CSS for app",
	tag: "hidden",
	run: async (props) => {
		const { variants, autoVariants, componentData } = await getContext();
		if (shouldShowHelp(props.options)) {
			showHelp();
			return;
		}
		if (isInitCommand(props.first)) {
			await scaffoldThemeConfig(getCssInitOptions(props.options));
			return;
		}
		await runCssCommand(getCssRunOptions(process.cwd(), props.options), {
			variants,
			autoVariants,
			componentData
		});
	}
});

//#endregion
export { makeCSSCommand };
//# sourceMappingURL=css.js.map