/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
import path from "node:path";
import fs from "node:fs";
//#region ../tailwind-internal/dist/utils/entryPoints.js
/*! © 2026 Yahoo, Inc. UDS Tailwind Internal v0.0.0-development */
const ALLOWED_ENTRY_FILE_EXTENSIONS = [".tsx"];
const DEFAULT_ENTRY = "./src";
const getAllowedEntryFileGlobPatterns = (prefix = "**/*") => ALLOWED_ENTRY_FILE_EXTENSIONS.map((extension) => `${prefix}${extension}`);
const hasAllowedEntryFileExtension = (entryPath) => ALLOWED_ENTRY_FILE_EXTENSIONS.includes(path.extname(entryPath));
const stripAllowedEntryFileExtension = (entryPath) => {
	const extension = ALLOWED_ENTRY_FILE_EXTENSIONS.find((candidate) => entryPath.endsWith(candidate));
	return extension ? entryPath.slice(0, -extension.length) : entryPath;
};
const formatAllowedEntryFileExtensions = () => ALLOWED_ENTRY_FILE_EXTENSIONS.join(", ");
const createUnsupportedEntryExtensionError = (entryPath) => /* @__PURE__ */ new Error(`Unsupported entry file extension for ${entryPath}. File entries must use one of: ${formatAllowedEntryFileExtensions()}.`);
const createMissingEntryPathError = (entryPath) => /* @__PURE__ */ new Error(`Entry path not found: ${entryPath}.`);
const isExistingDirectory = (entryPath) => {
	if (!fs.existsSync(entryPath)) return false;
	return fs.statSync(entryPath).isDirectory();
};
const toAbsoluteEntryPath = (entryPath, workspaceDir) => path.isAbsolute(entryPath) ? entryPath : path.join(workspaceDir, entryPath);
const resolveEntryPath = (entryPath, workspaceDir) => {
	const absolutePath = toAbsoluteEntryPath(entryPath, workspaceDir);
	if (fs.existsSync(absolutePath)) {
		const stats = fs.statSync(absolutePath);
		if (stats.isDirectory()) return {
			originalPath: entryPath,
			absolutePath,
			kind: "directory",
			watchDirectory: absolutePath
		};
		if (stats.isFile()) {
			if (!hasAllowedEntryFileExtension(absolutePath)) throw createUnsupportedEntryExtensionError(entryPath);
			return {
				originalPath: entryPath,
				absolutePath,
				kind: "file",
				watchDirectory: path.dirname(absolutePath),
				fileName: path.basename(absolutePath)
			};
		}
	}
	if (path.extname(entryPath) && isExistingDirectory(path.dirname(absolutePath)) && !hasAllowedEntryFileExtension(entryPath)) throw createUnsupportedEntryExtensionError(entryPath);
	throw createMissingEntryPathError(entryPath);
};
const normalizeEntryPaths = (entry, defaultEntry = DEFAULT_ENTRY) => {
	const normalized = (Array.isArray(entry) ? entry : [entry]).filter((value) => typeof value === "string" && value.trim().length > 0);
	return normalized.length > 0 ? [...new Set(normalized)] : [defaultEntry];
};
const formatEntryValue = (entry) => Array.isArray(entry) ? `[${entry.map((value) => `'${value}'`).join(", ")}]` : `'${entry}'`;
const resolveEntryPaths = (entry, workspaceDir, defaultEntry = DEFAULT_ENTRY) => normalizeEntryPaths(entry, defaultEntry).map((entryPath) => resolveEntryPath(entryPath, workspaceDir));
//#endregion
export { ALLOWED_ENTRY_FILE_EXTENSIONS, DEFAULT_ENTRY, formatEntryValue, getAllowedEntryFileGlobPatterns, hasAllowedEntryFileExtension, normalizeEntryPaths, resolveEntryPaths, stripAllowedEntryFileExtension };
