const require_getConfiguration = require('../../../../config/dist/esm/configFile/getConfiguration.cjs');
const require_index = require('../unmerged-dictionaries-entry/dist/esm/index.cjs');
const require_getMissingLocalesContent = require('../core/dist/esm/deepTransformPlugins/getMissingLocalesContent.cjs');
const require_index$1 = require('../dictionaries-entry/dist/esm/index.cjs');

//#region ../@intlayer/cli/dist/esm/test/listMissingTranslations.mjs
const listMissingTranslations = (configurationOptions) => {
	const configuration = require_getConfiguration.getConfiguration(configurationOptions);
	const unmergedDictionariesRecord = require_index.getUnmergedDictionaries(configuration);
	const mergedDictionaries = require_index$1.getDictionaries(configuration);
	const missingTranslations = [];
	const { locales, requiredLocales } = configuration.internationalization;
	const dictionariesKeys = Object.keys(unmergedDictionariesRecord);
	for (const dictionaryKey of dictionariesKeys) {
		const dictionaries = unmergedDictionariesRecord[dictionaryKey];
		const multilingualDictionary = dictionaries.filter((dictionary) => !dictionary.locale);
		for (const dictionary of multilingualDictionary) {
			const missingLocales$2 = require_getMissingLocalesContent.getMissingLocalesContentFromDictionary(dictionary, locales);
			if (missingLocales$2.length > 0) missingTranslations.push({
				key: dictionaryKey,
				id: dictionary.id,
				filePath: dictionary.filePath,
				locales: missingLocales$2
			});
		}
		if (dictionaries.filter((dictionary) => dictionary.locale).length === 0) continue;
		const mergedDictionary = mergedDictionaries[dictionaryKey];
		const missingLocales$1 = require_getMissingLocalesContent.getMissingLocalesContentFromDictionary(mergedDictionary, locales);
		if (missingLocales$1.length > 0) missingTranslations.push({
			key: dictionaryKey,
			locales: missingLocales$1
		});
	}
	const missingLocalesSet = new Set(missingTranslations.flatMap((t) => t.locales));
	const missingLocales = Array.from(missingLocalesSet);
	return {
		missingTranslations,
		missingLocales,
		missingRequiredLocales: missingLocales.filter((locale) => (requiredLocales ?? locales).includes(locale))
	};
};

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