"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var editor_keyboard_shortcut_exports = {};
__export(editor_keyboard_shortcut_exports, {
  EditorKeyboardShortcut: () => EditorKeyboardShortcut
});
module.exports = __toCommonJS(editor_keyboard_shortcut_exports);
var import_keys = require("./keys.js");
class EditorKeyboardShortcut {
  static of(shortcut) {
    return new EditorKeyboardShortcut(shortcut);
  }
  constructor(shortcut) {
    this.shortcut = shortcut;
    this.keys = {
      macOs: import_keys.Keys.parse(shortcut.keys.macOs),
      windows: import_keys.Keys.parse(shortcut.keys.windows)
    };
  }
  getKeyCombinationText(platform) {
    return this.keys[platform].toPlatformString(platform);
  }
  getTooltipHint(platform) {
    return this.keys[platform].toTooltipHint(platform);
  }
  /**
   * KeyboardShortcut config
   */
  getKeyboardShortcut() {
    return this.shortcut;
  }
  /**
   * Parsed Keys
   */
  getKeys(platform) {
    return this.keys[platform];
  }
  /**
   * Command to run
   */
  getCommand() {
    return this.shortcut.command;
  }
  /**
   * Enabled status
   */
  isEnabled() {
    return this.shortcut.enabled;
  }
  /**
   * Focus contexts where this shortcut is enabled
   */
  getEnabledIn() {
    return this.shortcut.enabledIn || ["editor", "toolbar"];
  }
  /**
   * Pre-localized name
   */
  getName() {
    return this.shortcut.name;
  }
  /**
   * Pre-localized group
   */
  getGroup() {
    return this.shortcut.group;
  }
  /**
   * Whether this shortcut should be displayed in the shortcut sheet
   */
  shouldShowInShortcutSheet() {
    return this.shortcut.showInShortcutSheet;
  }
  /**
   * Localized shortcut data for tooltips, help dialogs, etc
   */
  getDisplayData(t, platform) {
    return {
      name: t(this.shortcut.name),
      description: t(this.shortcut.description || ""),
      group: t(this.shortcut.group),
      keyCombinationText: this.getKeyCombinationText(platform),
      tooltipHint: this.getTooltipHint(platform)
    };
  }
  /**
   * Reconfigure Shortcut
   */
  configure(config) {
    return new EditorKeyboardShortcut({ ...this.shortcut, ...config });
  }
  /**
   * Determines whether shortcut equals to another shortcut, based on keys and group
   */
  equals(shortcut) {
    return this.keys.macOs.equals(shortcut.getKeys("macOs")) && this.keys.windows.equals(shortcut.getKeys("windows")) && !this.keys.macOs.equals(import_keys.Keys.parse("Arrow")) && !this.keys.windows.equals(import_keys.Keys.parse("Arrow")) && this.getGroup() === shortcut.getGroup();
  }
}
//# sourceMappingURL=editor-keyboard-shortcut.js.map
