/*!
 * Built by Revolist OU ❤️
 */
import KeyCodesEnum, { codesLetter, keyValues } from "./key.codes";
import OsPlatform from "./platform";
export function isMetaKey(code) {
    const keys = [
        KeyCodesEnum.ARROW_DOWN,
        KeyCodesEnum.ARROW_UP,
        KeyCodesEnum.ARROW_LEFT,
        KeyCodesEnum.ARROW_RIGHT,
        KeyCodesEnum.HOME,
        KeyCodesEnum.END,
        KeyCodesEnum.DELETE,
        KeyCodesEnum.BACKSPACE,
        KeyCodesEnum.F1,
        KeyCodesEnum.F2,
        KeyCodesEnum.F3,
        KeyCodesEnum.F4,
        KeyCodesEnum.F5,
        KeyCodesEnum.F6,
        KeyCodesEnum.F7,
        KeyCodesEnum.F8,
        KeyCodesEnum.F9,
        KeyCodesEnum.F10,
        KeyCodesEnum.F11,
        KeyCodesEnum.F12,
        KeyCodesEnum.TAB,
        KeyCodesEnum.PAGE_DOWN,
        KeyCodesEnum.PAGE_UP,
        KeyCodesEnum.ENTER,
        KeyCodesEnum.ESCAPE,
        KeyCodesEnum.SHIFT,
        KeyCodesEnum.CAPS_LOCK,
        KeyCodesEnum.ALT,
    ];
    return keys.indexOf(code) !== -1;
}
// navigator.platform
export function isCtrlKey(code, platform) {
    if (platform.includes(OsPlatform.mac)) {
        return [
            KeyCodesEnum.COMMAND_LEFT,
            KeyCodesEnum.COMMAND_RIGHT,
            KeyCodesEnum.COMMAND_FIREFOX,
        ].includes(code);
    }
    return code === KeyCodesEnum.CONTROL;
}
export function isCtrlMetaKey(code) {
    return [
        KeyCodesEnum.CONTROL,
        KeyCodesEnum.COMMAND_LEFT,
        KeyCodesEnum.COMMAND_RIGHT,
        KeyCodesEnum.COMMAND_FIREFOX,
    ].includes(code);
}
export function isClear(code) {
    return codesLetter.BACKSPACE === code || codesLetter.DELETE === code;
}
export function isTab(code) {
    return codesLetter.TAB === code;
}
export function isTabKeyValue(key) {
    return keyValues.TAB === key;
}
export function isEnterKeyValue(key) {
    return keyValues.ENTER === key;
}
export function isCut(event) {
    return ((event.ctrlKey && event.code === 'KeyX') || // Ctrl + X on Windows
        (event.metaKey && event.code === 'KeyX')); // Cmd + X on Mac
}
export function isCopy(event) {
    return ((event.ctrlKey && event.code === 'KeyC') || // Ctrl + C on Windows
        (event.metaKey && event.code === 'KeyC')); // Cmd + C on Mac
}
export function isPaste(event) {
    return ((event.ctrlKey && event.code === 'KeyV') || // Ctrl + V on Windows
        (event.metaKey && event.code === 'KeyV')); // Cmd + V on Mac
}
export function isAll(event) {
    return ((event.ctrlKey && event.code === 'KeyA') || // Ctrl + A on Windows
        (event.metaKey && event.code === 'KeyA')); // Cmd + A on Mac
}
