const require_rolldown_runtime = require('../../../../../../../../_virtual/rolldown_runtime.cjs');
const require_getConfiguration = require('../../../../../../../config/dist/esm/configFile/getConfiguration.cjs');
const require_parallelize = require('../utils/parallelize.cjs');
const require_writeFileIfChanged = require('../writeFileIfChanged.cjs');
const require_generateDictionaryListContent = require('./generateDictionaryListContent.cjs');
const require_getBuiltDictionariesPath = require('./getBuiltDictionariesPath.cjs');
const require_getBuiltDynamicDictionariesPath = require('./getBuiltDynamicDictionariesPath.cjs');
const require_getBuiltFetchDictionariesPath = require('./getBuiltFetchDictionariesPath.cjs');
const require_getBuiltRemoteDictionariesPath = require('./getBuiltRemoteDictionariesPath.cjs');
const require_getBuiltUnmergedDictionariesPath = require('./getBuiltUnmergedDictionariesPath.cjs');
let node_path = require("node:path");
let node_fs_promises = require("node:fs/promises");

//#region ../@intlayer/cli/dist/esm/chokidar/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs
const writeDictionaryFiles = async (paths, fileName, functionName, format, configuration = require_getConfiguration.getConfiguration()) => {
	const content = require_generateDictionaryListContent.generateDictionaryListContent(await paths, functionName, format, configuration);
	const extension = format === "cjs" ? "cjs" : "mjs";
	const { mainDir } = configuration.content;
	await require_writeFileIfChanged.writeFileIfChanged((0, node_path.resolve)(mainDir, `${fileName}.${extension}`), content);
};
/**
* This function generates a list of dictionaries in the main directory
*/
const createDictionaryEntryPoint = async (configuration = require_getConfiguration.getConfiguration(), formats) => {
	const outputFormats = formats ?? configuration.build.outputFormat;
	const { mainDir } = configuration.content;
	await (0, node_fs_promises.mkdir)(mainDir, { recursive: true });
	await require_parallelize.parallelize([
		...outputFormats.map((format) => ({
			paths: require_getBuiltRemoteDictionariesPath.getBuiltRemoteDictionariesPath(configuration),
			functionName: "getRemoteDictionaries",
			fileName: "remote_dictionaries",
			format
		})),
		...outputFormats.map((format) => ({
			paths: require_getBuiltDictionariesPath.getBuiltDictionariesPath(configuration),
			functionName: "getDictionaries",
			fileName: "dictionaries",
			format
		})),
		...outputFormats.map((format) => ({
			paths: require_getBuiltUnmergedDictionariesPath.getBuiltUnmergedDictionariesPath(configuration),
			functionName: "getUnmergedDictionaries",
			fileName: "unmerged_dictionaries",
			format
		})),
		...outputFormats.map((format) => ({
			paths: require_getBuiltDynamicDictionariesPath.getBuiltDynamicDictionariesPath(configuration, format),
			functionName: "getDynamicDictionaries",
			fileName: "dynamic_dictionaries",
			format
		})),
		...outputFormats.map((format) => ({
			paths: require_getBuiltFetchDictionariesPath.getBuiltFetchDictionariesPath(configuration, format),
			functionName: "getFetchDictionaries",
			fileName: "fetch_dictionaries",
			format
		}))
	], async ({ paths, fileName, format, functionName }) => writeDictionaryFiles(paths, fileName, functionName, format, configuration));
};

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