const require_rolldown_runtime = require('../../../../../_virtual/rolldown_runtime.cjs');
let node_path = require("node:path");
let node_fs = require("node:fs");

//#region ../@intlayer/cli/dist/esm/utils/getParentPackageJSON.mjs
const getParentPackageJSON = (startDir) => {
	let currentDir = startDir;
	while (currentDir !== (0, node_path.dirname)(currentDir)) {
		const packageJsonPath = (0, node_path.resolve)(currentDir, "package.json");
		if ((0, node_fs.existsSync)(packageJsonPath)) return JSON.parse((0, node_fs.readFileSync)(packageJsonPath, "utf8"));
		currentDir = (0, node_path.dirname)(currentDir);
	}
	const rootPackageJsonPath = (0, node_path.resolve)(currentDir, "package.json");
	if ((0, node_fs.existsSync)(rootPackageJsonPath)) return JSON.parse((0, node_fs.readFileSync)(rootPackageJsonPath, "utf8"));
	throw new Error(`No package.json found in any parent directory of ${startDir}`);
};

//#endregion
exports.getParentPackageJSON = getParentPackageJSON;
//# sourceMappingURL=getParentPackageJSON.cjs.map