
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
import { Disposable } from '../../../../base/common/lifecycle.js';
import { localize } from '../../../../nls.js';
import { IQuickInputService } from '../../../../platform/quickinput/common/quickInput.service.js';

let TableColumnResizeQuickPick = class TableColumnResizeQuickPick extends Disposable {
    constructor(_table, _quickInputService) {
        super();
        this._table = _table;
        this._quickInputService = _quickInputService;
    }
    async show() {
        const items = [];
        this._table.getColumnLabels().forEach((label, index) => {
            if (label) {
                items.push({ label, index });
            }
        });
        const column = await this._quickInputService.pick(items, { placeHolder: ( localize(7201, "Select the column to resize, type to filter.")) });
        if (!column) {
            return;
        }
        const value = await this._quickInputService.input({
            placeHolder: ( localize(7202, "i.e. 20, 60, 100...")),
            prompt: ( localize(
                7203,
                "Please enter a width in percentage for the '{0}' column.",
                column.label
            )),
            validateInput: (input) => this._validateColumnResizeValue(input)
        });
        const percentageValue = value ? Number.parseInt(value) : undefined;
        if (!percentageValue) {
            return;
        }
        this._table.resizeColumn(column.index, percentageValue);
    }
    async _validateColumnResizeValue(input) {
        const percentage = Number.parseInt(input);
        if (input && !Number.isInteger(percentage)) {
            return localize(7204, "Please enter an integer.");
        }
        else if (percentage < 0 || percentage > 100) {
            return localize(
                7205,
                "Please enter a number greater than 0 and less than or equal to 100."
            );
        }
        return null;
    }
};
TableColumnResizeQuickPick = ( __decorate([
    ( __param(1, IQuickInputService))
], TableColumnResizeQuickPick));

export { TableColumnResizeQuickPick };
