"use strict";
exports.id = "InteractiveUpgrader";
exports.ids = ["InteractiveUpgrader"];
exports.modules = {

/***/ 787280
/*!***********************************************************!*\
  !*** ./lib-intermediate-esm/logic/InteractiveUpgrader.js ***!
  \***********************************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   InteractiveUpgrader: () => (/* binding */ InteractiveUpgrader)
/* harmony export */ });
/* harmony import */ var inquirer_lib_ui_prompt__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! inquirer/lib/ui/prompt */ 81059);
/* harmony import */ var inquirer_lib_ui_prompt__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(inquirer_lib_ui_prompt__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _rushstack_npm_check_fork__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @rushstack/npm-check-fork */ 366560);
/* harmony import */ var _rushstack_npm_check_fork__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_rushstack_npm_check_fork__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _rushstack_terminal__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @rushstack/terminal */ 367587);
/* harmony import */ var _rushstack_terminal__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_rushstack_terminal__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _utilities_InteractiveUpgradeUI__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../utilities/InteractiveUpgradeUI */ 580636);
/* harmony import */ var _utilities_prompts_SearchListPrompt__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utilities/prompts/SearchListPrompt */ 92664);
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.





class InteractiveUpgrader {
    constructor(rushConfiguration) {
        this._rushConfiguration = rushConfiguration;
    }
    async upgradeAsync() {
        const rushProject = await this._getUserSelectedProjectForUpgradeAsync();
        const dependenciesState = await this._getPackageDependenciesStatusAsync(rushProject);
        const depsToUpgrade = await this._getUserSelectedDependenciesToUpgradeAsync(dependenciesState);
        return { projects: [rushProject], depsToUpgrade };
    }
    async _getUserSelectedDependenciesToUpgradeAsync(packages) {
        return (0,_utilities_InteractiveUpgradeUI__WEBPACK_IMPORTED_MODULE_3__.upgradeInteractive)(packages);
    }
    async _getUserSelectedProjectForUpgradeAsync() {
        const projects = this._rushConfiguration.projects;
        const ui = new (inquirer_lib_ui_prompt__WEBPACK_IMPORTED_MODULE_0___default())({
            list: _utilities_prompts_SearchListPrompt__WEBPACK_IMPORTED_MODULE_4__.SearchListPrompt
        });
        const { selectProject } = await ui.run([
            {
                name: 'selectProject',
                message: 'Select a project you would like to upgrade',
                type: 'list',
                choices: projects.map((project) => {
                    return {
                        name: _rushstack_terminal__WEBPACK_IMPORTED_MODULE_2__.Colorize.green(project.packageName),
                        value: project
                    };
                }),
                pageSize: 12
            }
        ]);
        return selectProject;
    }
    async _getPackageDependenciesStatusAsync(rushProject) {
        var _a;
        const { projectFolder } = rushProject;
        const currentState = await (0,_rushstack_npm_check_fork__WEBPACK_IMPORTED_MODULE_1__.NpmCheck)({
            cwd: projectFolder
        });
        return (_a = currentState.packages) !== null && _a !== void 0 ? _a : [];
    }
}
//# sourceMappingURL=InteractiveUpgrader.js.map

/***/ },

/***/ 580636
/*!****************************************************************!*\
  !*** ./lib-intermediate-esm/utilities/InteractiveUpgradeUI.js ***!
  \****************************************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   UI_GROUPS: () => (/* binding */ UI_GROUPS),
/* harmony export */   upgradeInteractive: () => (/* binding */ upgradeInteractive)
/* harmony export */ });
/* harmony import */ var inquirer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! inquirer */ 639937);
/* harmony import */ var inquirer__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(inquirer__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var cli_table__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! cli-table */ 865063);
/* harmony import */ var cli_table__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(cli_table__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _rushstack_terminal__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @rushstack/terminal */ 367587);
/* harmony import */ var _rushstack_terminal__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_rushstack_terminal__WEBPACK_IMPORTED_MODULE_2__);
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
// UI Code, Table creation, and choice layout leveraged from npm-check
// https://github.com/dylang/npm-check/blob/master/lib/out/interactive-update.js
// Extended to use one type of text table



function greenUnderlineBold(text) {
    return _rushstack_terminal__WEBPACK_IMPORTED_MODULE_2__.Colorize.underline(_rushstack_terminal__WEBPACK_IMPORTED_MODULE_2__.Colorize.bold(_rushstack_terminal__WEBPACK_IMPORTED_MODULE_2__.Colorize.green(text)));
}
function yellowUnderlineBold(text) {
    return _rushstack_terminal__WEBPACK_IMPORTED_MODULE_2__.Colorize.underline(_rushstack_terminal__WEBPACK_IMPORTED_MODULE_2__.Colorize.bold(_rushstack_terminal__WEBPACK_IMPORTED_MODULE_2__.Colorize.yellow(text)));
}
function redUnderlineBold(text) {
    return _rushstack_terminal__WEBPACK_IMPORTED_MODULE_2__.Colorize.underline(_rushstack_terminal__WEBPACK_IMPORTED_MODULE_2__.Colorize.bold(_rushstack_terminal__WEBPACK_IMPORTED_MODULE_2__.Colorize.red(text)));
}
function magentaUnderlineBold(text) {
    return _rushstack_terminal__WEBPACK_IMPORTED_MODULE_2__.Colorize.underline(_rushstack_terminal__WEBPACK_IMPORTED_MODULE_2__.Colorize.bold(_rushstack_terminal__WEBPACK_IMPORTED_MODULE_2__.Colorize.magenta(text)));
}
const UI_GROUPS = [
    {
        title: greenUnderlineBold('Update package.json to match version installed.'),
        filter: { mismatch: true, bump: undefined }
    },
    {
        title: `${greenUnderlineBold('Missing.')} ${_rushstack_terminal__WEBPACK_IMPORTED_MODULE_2__.Colorize.green('You probably want these.')}`,
        filter: { notInstalled: true, bump: undefined }
    },
    {
        title: `${greenUnderlineBold('Patch Update')} ${_rushstack_terminal__WEBPACK_IMPORTED_MODULE_2__.Colorize.green('Backwards-compatible bug fixes.')}`,
        filter: { bump: 'patch' }
    },
    {
        title: `${yellowUnderlineBold('Minor Update')} ${_rushstack_terminal__WEBPACK_IMPORTED_MODULE_2__.Colorize.yellow('New backwards-compatible features.')}`,
        bgColor: 'yellow',
        filter: { bump: 'minor' }
    },
    {
        title: `${redUnderlineBold('Major Update')} ${_rushstack_terminal__WEBPACK_IMPORTED_MODULE_2__.Colorize.red('Potentially breaking API changes. Use caution.')}`,
        filter: { bump: 'major' }
    },
    {
        title: `${magentaUnderlineBold('Non-Semver')} ${_rushstack_terminal__WEBPACK_IMPORTED_MODULE_2__.Colorize.magenta('Versions less than 1.0.0, caution.')}`,
        filter: { bump: 'nonSemver' }
    }
];
function label(dep) {
    const bumpInstalled = dep.bump ? dep.installed : '';
    const installed = dep.mismatch ? dep.packageJson : bumpInstalled;
    const name = _rushstack_terminal__WEBPACK_IMPORTED_MODULE_2__.Colorize.yellow(dep.moduleName);
    const type = dep.devDependency ? _rushstack_terminal__WEBPACK_IMPORTED_MODULE_2__.Colorize.green(' devDep') : '';
    const missing = dep.notInstalled ? _rushstack_terminal__WEBPACK_IMPORTED_MODULE_2__.Colorize.red(' missing') : '';
    const homepage = dep.homepage ? _rushstack_terminal__WEBPACK_IMPORTED_MODULE_2__.Colorize.blue(_rushstack_terminal__WEBPACK_IMPORTED_MODULE_2__.Colorize.underline(dep.homepage)) : '';
    return [
        name + type + missing,
        installed,
        installed && '>',
        _rushstack_terminal__WEBPACK_IMPORTED_MODULE_2__.Colorize.bold(dep.latest || ''),
        dep.latest ? homepage : getErrorDep(dep)
    ];
}
function getErrorDep(dep) {
    if (dep.regError !== undefined && dep.regError && dep.regError instanceof Error) {
        return dep.regError.message;
    }
    else if (dep.pkgError !== undefined && dep.pkgError && dep.pkgError instanceof Error) {
        return dep.pkgError.message;
    }
    return '';
}
function short(dep) {
    return `${dep.moduleName}@${dep.latest}`;
}
function getChoice(dep) {
    if (!dep.mismatch && !dep.bump && !dep.notInstalled) {
        return false;
    }
    return {
        value: dep,
        name: label(dep),
        short: short(dep)
    };
}
function unselectable(options) {
    return new (inquirer__WEBPACK_IMPORTED_MODULE_0___default().Separator)(_rushstack_terminal__WEBPACK_IMPORTED_MODULE_2__.AnsiEscape.removeCodes(options ? options.title : ''));
}
function createChoices(packages, options) {
    const { filter } = options;
    const filteredChoices = packages.filter((pkg) => {
        if ('mismatch' in filter && pkg.mismatch !== filter.mismatch) {
            return false;
        }
        else if ('bump' in filter && pkg.bump !== filter.bump) {
            return false;
        }
        else if ('notInstalled' in filter && pkg.notInstalled !== filter.notInstalled) {
            return false;
        }
        else {
            return true;
        }
    });
    const choices = filteredChoices
        .map(getChoice)
        .filter(Boolean);
    const cliTable = new (cli_table__WEBPACK_IMPORTED_MODULE_1___default())({
        chars: {
            top: '',
            'top-mid': '',
            'top-left': '',
            'top-right': '',
            bottom: '',
            'bottom-mid': '',
            'bottom-left': '',
            'bottom-right': '',
            left: '',
            'left-mid': '',
            mid: '',
            'mid-mid': '',
            right: '',
            'right-mid': '',
            middle: ' '
        },
        colWidths: [50, 10, 3, 10, 100]
    });
    for (const choice of choices) {
        if (typeof choice === 'object' && 'name' in choice) {
            cliTable.push(choice.name);
        }
    }
    const choicesAsATable = cliTable.toString().split('\n');
    for (let i = 0; i < choices.length; i++) {
        const choice = choices[i];
        if (typeof choice === 'object' && 'name' in choice) {
            choice.name = choicesAsATable[i];
        }
    }
    if (choices.length > 0) {
        choices.unshift(unselectable(options));
        choices.unshift(unselectable());
        return choices;
    }
}
const upgradeInteractive = async (pkgs) => {
    const choicesGrouped = UI_GROUPS.map((group) => createChoices(pkgs, group)).filter(Boolean);
    const choices = [];
    for (const choiceGroup of choicesGrouped) {
        if (choiceGroup) {
            choices.push(...choiceGroup);
        }
    }
    if (!choices.length) {
        // eslint-disable-next-line no-console
        console.log('All dependencies are up to date!');
        return { packages: [] };
    }
    choices.push(unselectable());
    choices.push(unselectable({ title: 'Space to select. Enter to start upgrading. Control-C to cancel.' }));
    const promptQuestions = [
        {
            name: 'packages',
            message: 'Choose which packages to upgrade',
            type: 'checkbox',
            choices: choices.concat(unselectable()),
            pageSize: process.stdout.rows - 2
        }
    ];
    const answers = (await inquirer__WEBPACK_IMPORTED_MODULE_0___default().prompt(promptQuestions));
    return answers;
};
//# sourceMappingURL=InteractiveUpgradeUI.js.map

/***/ },

/***/ 92664
/*!********************************************************************!*\
  !*** ./lib-intermediate-esm/utilities/prompts/SearchListPrompt.js ***!
  \********************************************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   SearchListPrompt: () => (/* binding */ SearchListPrompt)
/* harmony export */ });
/* harmony import */ var inquirer_lib_prompts_base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! inquirer/lib/prompts/base */ 816867);
/* harmony import */ var inquirer_lib_prompts_base__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(inquirer_lib_prompts_base__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var inquirer_lib_utils_events__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! inquirer/lib/utils/events */ 996525);
/* harmony import */ var inquirer_lib_utils_events__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(inquirer_lib_utils_events__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var inquirer_lib_utils_paginator__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! inquirer/lib/utils/paginator */ 138003);
/* harmony import */ var inquirer_lib_utils_paginator__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(inquirer_lib_utils_paginator__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var figures__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! figures */ 198149);
/* harmony import */ var figures__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(figures__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var rxjs_operators__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! rxjs/operators */ 180603);
/* harmony import */ var rxjs_operators__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(rxjs_operators__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var _rushstack_terminal__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @rushstack/terminal */ 367587);
/* harmony import */ var _rushstack_terminal__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_rushstack_terminal__WEBPACK_IMPORTED_MODULE_5__);
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.






class SearchListPrompt extends (inquirer_lib_prompts_base__WEBPACK_IMPORTED_MODULE_0___default()) {
    constructor(question, readline, answers) {
        super(question, readline, answers);
        this._selected = 0;
        this._query = '';
        this._firstRender = true;
        if (!this.opt.choices) {
            this.throwParamError('choices');
        }
        const isDefaultANumber = typeof this.opt.default === 'number';
        if (isDefaultANumber && this.opt.default >= 0 && this.opt.default < this.opt.choices.realLength) {
            this._selected = this.opt.default;
        }
        else if (!isDefaultANumber && this.opt.default !== null) {
            const index = this.opt.choices.realChoices.findIndex(({ value }) => value === this.opt.default);
            this._selected = Math.max(index, 0);
        }
        // Make sure no default is set (so it won't be printed)
        this.opt.default = null;
        this._paginator = new (inquirer_lib_utils_paginator__WEBPACK_IMPORTED_MODULE_2___default())(this.screen);
    }
    _run(callback) {
        this.done = callback;
        // eslint-disable-next-line @typescript-eslint/typedef
        const events = inquirer_lib_utils_events__WEBPACK_IMPORTED_MODULE_1___default()(this.rl);
        // eslint-disable-next-line @typescript-eslint/typedef
        const validation = this.handleSubmitEvents(events.line.pipe((0,rxjs_operators__WEBPACK_IMPORTED_MODULE_4__.map)(this._getCurrentValue.bind(this))));
        void validation.success.forEach(this._onSubmit.bind(this));
        void validation.error.forEach(this._onError.bind(this));
        void events.numberKey
            .pipe((0,rxjs_operators__WEBPACK_IMPORTED_MODULE_4__.takeUntil)(events.line))
            .forEach(this._onNumberKey.bind(this));
        void events.keypress
            .pipe((0,rxjs_operators__WEBPACK_IMPORTED_MODULE_4__.takeUntil)(validation.success))
            .forEach(this._onKeyPress.bind(this));
        this.render();
        return this;
    }
    _onUpKey() {
        return this._adjustSelected(-1);
    }
    _onDownKey() {
        return this._adjustSelected(1);
    }
    _onNumberKey(input) {
        if (input <= this.opt.choices.realLength) {
            this._selected = input - 1;
        }
        this.render();
    }
    /**
     * When user press `enter` key
     */
    _onSubmit(state) {
        this.status = 'answered';
        // Rerender prompt (and clean subline error)
        this.render();
        this.screen.done();
        this.done(state.value);
    }
    _onError(state) {
        this.render(state.isValid || undefined);
    }
    _onKeyPress(event) {
        var _a, _b;
        if (event.key.ctrl) {
            switch (event.key.name) {
                case 'backspace':
                    return this._setQuery('');
            }
        }
        else {
            switch (event.key.name) {
                // Go to beginning of list
                case 'home':
                    return this._adjustSelected(-Infinity);
                // Got to end of list
                case 'end':
                    return this._adjustSelected(Infinity);
                // Paginate up
                case 'pageup':
                    return this._adjustSelected(-((_a = this.opt.pageSize) !== null && _a !== void 0 ? _a : 1));
                // Paginate down
                case 'pagedown':
                    return this._adjustSelected((_b = this.opt.pageSize) !== null && _b !== void 0 ? _b : 1);
                case 'backspace':
                    return this._setQuery(this._query.slice(0, -1));
                case 'up':
                    return this._onUpKey();
                case 'down':
                    return this._onDownKey();
                default:
                    if (event.key.sequence && event.key.sequence.length === 1) {
                        this._setQuery(this._query + event.key.sequence);
                    }
            }
        }
    }
    _setQuery(query) {
        this._query = query;
        const filter = query.toUpperCase();
        const { choices } = this.opt.choices;
        for (const choice of choices) {
            if (choice.type !== 'separator') {
                choice.disabled = !choice.short.toUpperCase().includes(filter);
            }
        }
        // Select the first valid option
        this._adjustSelected(0);
    }
    // Provide the delta in deplayed choices and change the selected
    // index accordingly by the delta in real choices
    _adjustSelected(delta) {
        const { choices } = this.opt.choices;
        const pointer = this._selected;
        let lastValidIndex = pointer;
        // if delta is less than 0, we are moving up in list w/ selected index
        if (delta < 0) {
            for (let i = pointer - 1; i >= 0; i--) {
                const choice = choices[i];
                if (isValidChoice(choice)) {
                    ++delta;
                    lastValidIndex = i;
                    // if delta is 0, we have found the next valid choice that has an index less than the selected index
                    if (delta === 0) {
                        break;
                    }
                }
            }
        }
        else {
            // if delta is greater than 0, we are moving down in list w/ selected index
            // Also, if delta is exactly 0, the request is to adjust to the first
            // displayed choice that has an index >= the current selected choice.
            ++delta;
            for (let i = pointer, len = choices.length; i < len; i++) {
                const choice = choices[i];
                if (isValidChoice(choice)) {
                    --delta;
                    lastValidIndex = i;
                    // if delta is 0, we have found the next valid choice that has an index greater than the selected index
                    if (delta === 0) {
                        break;
                    }
                }
            }
        }
        this._selected = lastValidIndex;
        this.render();
    }
    _getCurrentValue() {
        return this.opt.choices.getChoice(this._selected).value;
    }
    render(error) {
        // Render the question
        let message = this.getQuestion();
        let bottomContent = '';
        if (this._firstRender) {
            message += _rushstack_terminal__WEBPACK_IMPORTED_MODULE_5__.Colorize.dim(' (Use arrow keys)');
        }
        // Render choices or answer depending on the state
        if (this.status === 'answered') {
            message += _rushstack_terminal__WEBPACK_IMPORTED_MODULE_5__.Colorize.cyan(this.opt.choices.getChoice(this._selected).short);
        }
        else {
            const choicesStr = listRender(this.opt.choices, this._selected);
            const indexPosition = this.opt.choices.indexOf(this.opt.choices.getChoice(this._selected));
            let realIndexPosition = 0;
            const { choices } = this.opt.choices;
            for (let i = 0; i < indexPosition; i++) {
                const value = choices[i];
                // Add line if it's a separator
                if (value.type === 'separator') {
                    realIndexPosition++;
                    continue;
                }
                // Do not render choices which disabled property
                // these represent choices that are filtered out
                if (value.disabled) {
                    continue;
                }
                const line = value.name;
                // Non-strings take up one line
                if (typeof line !== 'string') {
                    realIndexPosition++;
                    continue;
                }
                // Calculate lines taken up by string
                // eslint-disable-next-line no-bitwise
                realIndexPosition += ((line.length / process.stdout.columns) | 0) + 1;
            }
            message += `\n${_rushstack_terminal__WEBPACK_IMPORTED_MODULE_5__.Colorize.white(_rushstack_terminal__WEBPACK_IMPORTED_MODULE_5__.Colorize.bold('Start typing to filter:'))} ${_rushstack_terminal__WEBPACK_IMPORTED_MODULE_5__.Colorize.cyan(this._query)}`;
            // @ts-expect-error Types are wrong
            message += '\n' + this._paginator.paginate(choicesStr, realIndexPosition, this.opt.pageSize);
        }
        if (error) {
            bottomContent = _rushstack_terminal__WEBPACK_IMPORTED_MODULE_5__.Colorize.red('>> ') + error;
        }
        this.screen.render(message, bottomContent);
    }
}
function listRender(choices, pointer) {
    let output = '';
    choices.forEach((choice, i) => {
        if (choice.type === 'separator') {
            output += ' ' + choice + '\n';
            return;
        }
        if (!choice.disabled) {
            const line = choice.name;
            if (i === pointer) {
                output += _rushstack_terminal__WEBPACK_IMPORTED_MODULE_5__.Colorize.cyan((figures__WEBPACK_IMPORTED_MODULE_3___default().pointer) + line);
            }
            else {
                output += ' ' + line;
            }
        }
        if (i < choices.length - 1) {
            output += '\n';
        }
    });
    return output.replace(/\n$/, '');
}
function isValidChoice(choice) {
    return !choice.disabled;
}
//# sourceMappingURL=SearchListPrompt.js.map

/***/ }

};
;
//# sourceMappingURL=InteractiveUpgrader.js.map