"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MODIFIER_KEY_IDENTIFIER_MAP = exports.MODIFIER_KEY_HUMANIZED_MAP = exports.ESCAPE_KEY = void 0;
exports.keyIsSupported = keyIsSupported;
exports.keyIsSpecial = keyIsSpecial;
exports.humanizeSingleKey = humanizeSingleKey;
exports.encodeSingleKey = encodeSingleKey;
exports.ESCAPE_KEY = 'Escape';
const SUPPORTED_SPECIAL_KEYS = Object.freeze(new Set([
    'Enter',
    exports.ESCAPE_KEY,
    'Tab',
    'Backspace',
    'Delete',
    'ArrowUp',
    'ArrowDown',
    'ArrowLeft',
    'ArrowRight',
    'Home',
    'End',
    'PageUp',
    'PageDown',
]));
const SPECIAL_KEYS_NORMALIZED = Object.freeze({
    enter: 'Enter',
    escape: exports.ESCAPE_KEY,
    tab: 'Tab',
    backspace: 'Backspace',
    delete: 'Delete',
    arrowup: 'ArrowUp',
    arrowdown: 'ArrowDown',
    arrowleft: 'ArrowLeft',
    arrowright: 'ArrowRight',
    home: 'Home',
    end: 'End',
    pageup: 'PageUp',
    pagedown: 'PageDown',
});
exports.MODIFIER_KEY_HUMANIZED_MAP = Object.freeze({
    altKey: 'Alt',
    ctrlKey: 'Ctrl',
    metaKey: 'Cmd',
    shiftKey: 'Shift',
});
exports.MODIFIER_KEY_IDENTIFIER_MAP = Object.freeze({
    altKey: 'Alt',
    ctrlKey: 'Control',
    metaKey: 'Meta',
    shiftKey: 'Shift',
});
const SUPPORTED_KEYS = new Set([
    ' ',
    'a',
    'b',
    'c',
    'd',
    'e',
    'f',
    'g',
    'h',
    'i',
    'j',
    'k',
    'l',
    'm',
    'n',
    'o',
    'p',
    'q',
    'r',
    's',
    't',
    'u',
    'v',
    'w',
    'x',
    'y',
    'z',
    '/',
    ',',
    '<',
    '.',
    '>',
    '"',
    "'",
    ';',
    ':',
    ']',
    '}',
    '[',
    '{',
    '1',
    '2',
    '3',
    '4',
    '5',
    '6',
    '7',
    '8',
    '9',
    '0',
    '-',
    '_',
    '=',
    '+',
    '\\',
    '|',
    '!',
    '?',
    '@',
    '#',
    '$',
    '%',
    '^',
    '&',
    '*',
    '(',
    ')',
    '`',
    '~',
]);
function keyIsSupported(key) {
    return SUPPORTED_KEYS.has(key.toLowerCase()) || keyIsSpecial(key);
}
function keyIsSpecial(key) {
    return SUPPORTED_SPECIAL_KEYS.has(key);
}
function humanizeSingleKey(key) {
    return keyIsSpecial(key) ? `[${key.toUpperCase()}]` : key;
}
function encodeSingleKey(key) {
    if (key.match(/^\[.*]$/)) {
        const substring = key.substring(1, key.length - 1);
        return SPECIAL_KEYS_NORMALIZED[substring.toLowerCase()] || substring;
    }
    return key;
}
