import { OperatingSystem } from './platform.js';
import { localizeWithPath } from '../../nls.js';
const _moduleId = "vs/base/common/keybindingLabels";
class ModifierLabelProvider {
    constructor(mac, windows, linux = windows) {
        this.modifierLabels = [null];
        this.modifierLabels[OperatingSystem.Macintosh] = mac;
        this.modifierLabels[OperatingSystem.Windows] = windows;
        this.modifierLabels[OperatingSystem.Linux] = linux;
    }
    toLabel(OS, chords, keyLabelProvider) {
        if (chords.length === 0) {
            return null;
        }
        const result = [];
        for (let i = 0, len = chords.length; i < len; i++) {
            const chord = chords[i];
            const keyLabel = keyLabelProvider(chord);
            if (keyLabel === null) {
                return null;
            }
            result[i] = _simpleAsString(chord, keyLabel, this.modifierLabels[OS]);
        }
        return result.join(' ');
    }
}
const UILabelProvider = ( (new ModifierLabelProvider({
    ctrlKey: '\u2303',
    shiftKey: '⇧',
    altKey: '⌥',
    metaKey: '⌘',
    separator: '',
}, {
    ctrlKey: ( localizeWithPath(_moduleId, 0, "Ctrl")),
    shiftKey: ( localizeWithPath(_moduleId, 1, "Shift")),
    altKey: ( localizeWithPath(_moduleId, 2, "Alt")),
    metaKey: ( localizeWithPath(_moduleId, 3, "Windows")),
    separator: '+',
}, {
    ctrlKey: ( localizeWithPath(_moduleId, 0, "Ctrl")),
    shiftKey: ( localizeWithPath(_moduleId, 1, "Shift")),
    altKey: ( localizeWithPath(_moduleId, 2, "Alt")),
    metaKey: ( localizeWithPath(_moduleId, 4, "Super")),
    separator: '+',
})));
const AriaLabelProvider = ( (new ModifierLabelProvider({
    ctrlKey: ( localizeWithPath(_moduleId, 5, "Control")),
    shiftKey: ( localizeWithPath(_moduleId, 6, "Shift")),
    altKey: ( localizeWithPath(_moduleId, 7, "Option")),
    metaKey: ( localizeWithPath(_moduleId, 8, "Command")),
    separator: '+',
}, {
    ctrlKey: ( localizeWithPath(_moduleId, 5, "Control")),
    shiftKey: ( localizeWithPath(_moduleId, 6, "Shift")),
    altKey: ( localizeWithPath(_moduleId, 9, "Alt")),
    metaKey: ( localizeWithPath(_moduleId, 10, "Windows")),
    separator: '+',
}, {
    ctrlKey: ( localizeWithPath(_moduleId, 5, "Control")),
    shiftKey: ( localizeWithPath(_moduleId, 6, "Shift")),
    altKey: ( localizeWithPath(_moduleId, 9, "Alt")),
    metaKey: ( localizeWithPath(_moduleId, 11, "Super")),
    separator: '+',
})));
const ElectronAcceleratorLabelProvider = ( (new ModifierLabelProvider({
    ctrlKey: 'Ctrl',
    shiftKey: 'Shift',
    altKey: 'Alt',
    metaKey: 'Cmd',
    separator: '+',
}, {
    ctrlKey: 'Ctrl',
    shiftKey: 'Shift',
    altKey: 'Alt',
    metaKey: 'Super',
    separator: '+',
})));
const UserSettingsLabelProvider = ( (new ModifierLabelProvider({
    ctrlKey: 'ctrl',
    shiftKey: 'shift',
    altKey: 'alt',
    metaKey: 'cmd',
    separator: '+',
}, {
    ctrlKey: 'ctrl',
    shiftKey: 'shift',
    altKey: 'alt',
    metaKey: 'win',
    separator: '+',
}, {
    ctrlKey: 'ctrl',
    shiftKey: 'shift',
    altKey: 'alt',
    metaKey: 'meta',
    separator: '+',
})));
function _simpleAsString(modifiers, key, labels) {
    if (key === null) {
        return '';
    }
    const result = [];
    if (modifiers.ctrlKey) {
        result.push(labels.ctrlKey);
    }
    if (modifiers.shiftKey) {
        result.push(labels.shiftKey);
    }
    if (modifiers.altKey) {
        result.push(labels.altKey);
    }
    if (modifiers.metaKey) {
        result.push(labels.metaKey);
    }
    if (key !== '') {
        result.push(key);
    }
    return result.join(labels.separator);
}
export { AriaLabelProvider, ElectronAcceleratorLabelProvider, ModifierLabelProvider, UILabelProvider, UserSettingsLabelProvider };
