import { getConfiguration } from "@intlayer/config";
import { getUnmergedDictionaries } from "@intlayer/unmerged-dictionaries-entry";
import { getMissingLocalesContentFromDictionary } from "@intlayer/core";
import { getDictionaries } from "@intlayer/dictionaries-entry";

//#region src/test/listMissingTranslations.ts
const listMissingTranslations = (configurationOptions) => {
	const configuration = getConfiguration(configurationOptions);
	const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);
	const mergedDictionaries = 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 = 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 = 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
export { listMissingTranslations };
//# sourceMappingURL=listMissingTranslations.mjs.map