"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
/**
 * penguins-eggs
 * lib: select_keyboard_layout.ts
 * author: Piero Proietti
 * email: piero.proietti@gmail.com
 * license: MIT
 */
const inquirer = require('inquirer');
const keyboards_1 = tslib_1.__importDefault(require("../classes/keyboards"));
/**
  *
  */
async function selectKeyboardLayout(selected = '') {
    const keyboards = new keyboards_1.default();
    const layouts = keyboards.getLayouts();
    const supported = [];
    for (const l of layouts) {
        supported.push(l.code);
    }
    // sord keyboard layouts
    supported.sort();
    const questions = [
        {
            type: 'list',
            name: 'layout',
            message: 'Select layout: ',
            choices: supported,
            default: selected,
        },
    ];
    return new Promise(function (resolve) {
        inquirer.prompt(questions).then(function (options) {
            resolve(options.layout);
        });
    });
}
exports.default = selectKeyboardLayout;
