/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
//#region ../css/dist/commands/css.helpers.mjs
/*! © 2026 Yahoo, Inc. UDS CSS v0.0.0-development */
const parseWorkersOption = (value) => {
	if (typeof value !== "string" || value === "auto") return;
	const num = Number(value);
	if (!Number.isInteger(num) || num < 1) return;
	return num;
};
const isTruthyFlag = (value) => value === true || value === "true";
const stringOption = (value) => typeof value === "string" ? value : void 0;
const entryOption = (value) => {
	if (typeof value === "string") return value;
	if (Array.isArray(value) && value.every((item) => typeof item === "string")) return value;
};
const shouldShowHelp = (options) => isTruthyFlag(options.help) || isTruthyFlag(options.h);
const isInitCommand = (firstArg) => firstArg === "init";
const getCssInitOptions = (options) => ({
	force: isTruthyFlag(options.force),
	configPath: stringOption(options.config),
	entry: entryOption(options.entry),
	outputPath: stringOption(options.outFile)
});
const parseEmitOption = (value) => {
	if (value === void 0 || value === null) return;
	if (value === "exhaustive" || value === "selective") return value;
	throw new Error(`Invalid --emit "${String(value)}". Expected 'exhaustive' or 'selective'.`);
};
const getCssRunOptions = (workspaceDir, options) => {
	return {
		workspaceDir,
		outFile: stringOption(options.outFile) ?? "dist/uds.css",
		themeConfigPath: stringOption(options.theme) ?? "uds.theme.ts",
		scope: stringOption(options.scope),
		entryOption: entryOption(options.entry),
		configOption: stringOption(options.config),
		emit: parseEmitOption(options.emit),
		includeDevFiles: isTruthyFlag(options["include-dev-files"]) || isTruthyFlag(options.includeDevFiles) ? true : void 0,
		includeStories: isTruthyFlag(options["include-stories"]) || isTruthyFlag(options.includeStories) ? true : void 0,
		watch: isTruthyFlag(options.watch) || isTruthyFlag(options.w),
		silent: isTruthyFlag(options.silent) || isTruthyFlag(options.s),
		verbose: isTruthyFlag(options.verbose) || isTruthyFlag(options.v),
		workers: parseWorkersOption(options.workers)
	};
};
//#endregion
export { getCssInitOptions, getCssRunOptions, isInitCommand, shouldShowHelp };
