const require_rolldown_runtime = require('../../../../../../../../_virtual/rolldown_runtime.cjs');
const require_ESMxCJSHelpers = require('../../../../../../../config/dist/esm/utils/ESMxCJSHelpers.cjs');
const require_clearModuleCache = require('../../../../../../../config/dist/esm/utils/clearModuleCache.cjs');
const require_parallelize = require('../utils/parallelize.cjs');
let node_path = require("node:path");
let node_fs_promises = require("node:fs/promises");

//#region ../@intlayer/cli/dist/esm/chokidar/dist/esm/createType/createType.mjs
const generateTypeScriptType = (dictionary) => {
	return `/* eslint-disable */\nexport default ${JSON.stringify(dictionary, null, 2)} as const;\n`;
};
/**
* This function generates a TypeScript type definition from a JSON object
*/
const createTypes = async (dictionariesPaths, configuration) => {
	const { build, content } = configuration;
	const { typesDir } = content;
	await (0, node_fs_promises.mkdir)(typesDir, { recursive: true });
	return (await require_parallelize.parallelize(dictionariesPaths, async (dictionaryPath) => {
		const requireFunction = build.require ?? require_ESMxCJSHelpers.getProjectRequire();
		require_clearModuleCache.clearModuleCache(dictionaryPath);
		const dictionary = requireFunction(dictionaryPath);
		if (!dictionary.key) return;
		const typeDefinition = generateTypeScriptType(dictionary);
		const outputPath = (0, node_path.resolve)(typesDir, `${dictionary.key}.ts`);
		await (0, node_fs_promises.writeFile)(outputPath, typeDefinition);
		return outputPath;
	})).filter(Boolean);
};

//#endregion
exports.createTypes = createTypes;
//# sourceMappingURL=createType.cjs.map