"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MarkingModeService = void 0;
const os_1 = require("os");
const constants_1 = require("../constants");
const yok_1 = require("../common/yok");
const semver = require("semver/preload");
const MARKING_MODE_PROP = "markingMode";
const MARKING_MODE_FULL_DEPRECATION_MSG = `In the current version of NativeScript "${MARKING_MODE_PROP}:${"full"}" is no longer supported.`;
class MarkingModeService {
    constructor($logger, $projectConfigService, $projectHelper, $projectDataService) {
        this.$logger = $logger;
        this.$projectConfigService = $projectConfigService;
        this.$projectHelper = $projectHelper;
        this.$projectDataService = $projectDataService;
    }
    async handleMarkingModeFullDeprecation(options) {
        const markingModeValue = this.$projectConfigService.getValue("android.markingMode");
        const { skipWarnings, forceSwitch } = options;
        if (forceSwitch) {
            await this.setMarkingMode("none");
            return;
        }
        if (!skipWarnings && (markingModeValue === null || markingModeValue === void 0 ? void 0 : markingModeValue.toLowerCase()) !== "none") {
            const { version } = this.$projectDataService.getRuntimePackage(this.$projectHelper.projectDir, "android");
            const isMarkingModeFullDefault = version && semver.lt(semver.coerce(version), "7.0.0-rc.5");
            if (isMarkingModeFullDefault) {
                this.showMarkingModeFullWarning();
            }
        }
    }
    async setMarkingMode(newMode) {
        await this.$projectConfigService.setValue("android.markingMode", newMode);
    }
    showMarkingModeFullWarning() {
        const markingModeFullWarning = `You are using the deprecated "${MARKING_MODE_PROP}:${"full"}".${os_1.EOL}${os_1.EOL}${MARKING_MODE_FULL_DEPRECATION_MSG}${os_1.EOL}${os_1.EOL}You should update your marking mode by executing 'ns update --markingMode'.`;
        this.$logger.warn(markingModeFullWarning, {
            [constants_1.LoggerConfigData.wrapMessageWithBorders]: true,
        });
    }
}
exports.MarkingModeService = MarkingModeService;
yok_1.injector.register("markingModeService", MarkingModeService);
