"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
const deep_selector_replacer_1 = require("@ewizardjs/deep-selector-replacer");
const chalk_1 = require("chalk");
const I18n_1 = require("../modules/I18n");
const Logger_1 = require("../modules/Logger");
function updateDeepSelectors(presentationPath) {
    return __awaiter(this, void 0, void 0, function* () {
        const { files, nodeModules } = yield (0, deep_selector_replacer_1.replaceDeepSelectorsInFiles)(presentationPath);
        const boldBacktickedSelector = chalk_1.default.bold(I18n_1.default.info('BACKTICKED_DEEP_SELECTOR'));
        const boldShadowPiercing = chalk_1.default.bold(I18n_1.default.info('SHADOW_PIERCING'));
        if (!files.length) {
            Logger_1.default.info(I18n_1.default.info('NO_DEEP_SELECTORS_REPLACED', boldBacktickedSelector, boldShadowPiercing));
            return;
        }
        const listFiles = files.map((file) => ` * ${file}`).join('\n');
        const nodeModulesList = nodeModules.join(', ');
        Logger_1.default.info(I18n_1.default.info('DEEP_SELECTORS_REPLACED', boldBacktickedSelector, boldShadowPiercing, chalk_1.default.bold(I18n_1.default.info('V_DEEP_PSEUDO_ELEMENT')), listFiles));
        if (nodeModules.length) {
            console.log(`${chalk_1.default.hex('#ffa500')('WARNING:')} ${I18n_1.default.info('CHANGES_MADE_FOR_MODULES', chalk_1.default.bold(I18n_1.default.info('NODE_MODULES')), chalk_1.default.bold(nodeModulesList))} ${I18n_1.default.info('COMBINATOR_REPLACEMENT_FAILED', chalk_1.default.bold(I18n_1.default.info('WIZ_UPDATE_DEEP_SELECTOR')))}`);
        }
    });
}
exports.default = updateDeepSelectors;
//# sourceMappingURL=updateDeepSelectors.js.map