const require_logger = require('../../../config/dist/esm/logger.cjs');
const require_formatter = require('./utils/formatter.cjs');
const require_buildIntlayerDictionary = require('./buildIntlayerDictionary/buildIntlayerDictionary.cjs');
const require_createDictionaryEntryPoint = require('./createDictionaryEntryPoint/createDictionaryEntryPoint.cjs');
const require_createModuleAugmentation = require('./createType/createModuleAugmentation.cjs');
const require_createType = require('./createType/createType.cjs');
const require_loadLocalDictionaries = require('./loadDictionaries/loadLocalDictionaries.cjs');
const require_listDictionariesPath = require('./listDictionariesPath.cjs');

//#region ../chokidar/dist/esm/handleUnlinkedContentDeclarationFile.mjs
const handleUnlinkedContentDeclarationFile = async (filePath, config) => {
	const appLogger = require_logger.getAppLogger(config);
	appLogger(`Unlinked detected: ${require_formatter.formatPath(filePath)}`, { isVerbose: true });
	const dictionariesOutput = await require_buildIntlayerDictionary.buildDictionary(await require_loadLocalDictionaries.loadLocalDictionaries(await require_listDictionariesPath.listDictionaries(config), config), config);
	await require_createType.createTypes(Object.values(dictionariesOutput?.mergedDictionaries ?? {}).map((dictionary) => dictionary.dictionaryPath), config);
	await require_createDictionaryEntryPoint.createDictionaryEntryPoint();
	appLogger("Dictionaries rebuilt", { isVerbose: true });
	await require_createModuleAugmentation.createModuleAugmentation(config);
	appLogger("Module augmentation built", { isVerbose: true });
	for await (const plugin of config.plugins ?? []) {
		const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;
		await plugin.afterBuild?.({
			dictionaries: {
				unmergedDictionaries,
				mergedDictionaries
			},
			configuration: config
		});
	}
};

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