"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 });
exports.openDocs = void 0;
const open = require("open");
const urljoin = require("url-join");
const winston = require("winston");
const Config_1 = require("../../modules/Config");
const I18n_1 = require("../../modules/I18n");
const DOC_LINKS = {
    edetailer: '/docs/ewizardjs/documentation/guide/e-detailer/',
    email: '/docs/ewizardjs/documentation/guide/email/',
    site: '/docs/ewizardjs/documentation/guide/site/',
};
const DEFAULT_DOC_LINK = '/docs/ewizardjs/documentation/guide/cli';
function openDocs(params) {
    return __awaiter(this, void 0, void 0, function* () {
        const { url } = (yield Config_1.Config.get()).ewizard;
        const options = Object.keys(params);
        if (options.length) {
            const fullLinks = options.map((option) => urljoin(url, getDocUrl(option)));
            winston.info(`${I18n_1.default.info('DOCUMENTATION_AVAILABLE_AT')} \n\n${fullLinks.join('\n')}\n`);
            for (const link of fullLinks) {
                yield open(link, { wait: true });
            }
        }
        else {
            const fullLink = urljoin(url, DEFAULT_DOC_LINK);
            winston.info(`${I18n_1.default.info('DOCUMENTATION_AVAILABLE_AT')} \n\n${fullLink}\n`);
            open(fullLink);
        }
    });
}
exports.openDocs = openDocs;
function getDocUrl(optionName) {
    return DOC_LINKS[optionName] || DEFAULT_DOC_LINK;
}
//# sourceMappingURL=openDocs.js.map