/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
import { cyan, gray, green, magenta } from "../packages/cli/dist/lib/colors.js";
import { print } from "../packages/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 ../css/dist/commands/css.mjs
/*! © 2026 Yahoo, Inc. UDS CSS v0.0.0-development */
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("--verbose, -v")}     List every scanned file used for purging`);
	print(`  ${cyan("--workers <n>")}     Number of parallel workers (default: auto = CPU count - 1)`);
	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',
    scoped: {
      '@your-org/shared-ui': './packages/shared-ui/uds.config.ts'
    },
    colorModes: ['dark'],
    css: {
      preflight: true,
      fontFaceDeclarations: true,
      optimization: {
        deduplicateScopedCss: true
      }
    }
  });

  // Expanded form when you need a custom output path:
  // scoped: {
  //   '@your-org/shared-ui': {
  //     config: './packages/shared-ui/uds.config.ts',
  //     entry: './stories',
  //     outFile: 'dist/shared-ui.css'
  //   }
  // }`));
	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 };
