"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = HotkeysHelper;
var _react = _interopRequireWildcard(require("react"));
var _reactI18next = require("react-i18next");
var _classifyHotkeys = _interopRequireDefault(require("./classify-hotkeys"));
var _hotKeys = require("../../constants/hot-keys");
var _eventTypes = require("../../constants/event-types");
var _eventBus = _interopRequireDefault(require("../../utils/event-bus"));
var _constants = require("../../constants");
require("./style.css");
function HotkeysHelper() {
  const {
    t
  } = (0, _reactI18next.useTranslation)(_constants.TRANSLATE_NAMESPACE);
  const useHelp = t('userHelp', {
    returnObjects: true
  });
  const {
    title,
    userHelpData
  } = useHelp;
  const onCloseClick = (0, _react.useCallback)(() => {
    const eventBus = _eventBus.default.getInstance();
    eventBus.dispatch(_eventTypes.EXTERNAL_EVENTS.ON_HELP_INFO_TOGGLE, false);
  }, []);
  return /*#__PURE__*/_react.default.createElement("div", {
    className: "sf-editor-helper"
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: "sf-editor-helper__header"
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: "title"
  }, title), /*#__PURE__*/_react.default.createElement("div", {
    className: "help-close",
    onClick: onCloseClick
  }, /*#__PURE__*/_react.default.createElement("i", {
    className: "iconfont icon-x"
  }))), /*#__PURE__*/_react.default.createElement("div", {
    className: "sf-editor-helper__content"
  }, userHelpData.map((item, index) => {
    const shortcutData = _hotKeys.HELPER_HOTKEYS[index];
    const {
      shortcutType: title,
      shortcutData: shortcutDataNames
    } = item;
    return /*#__PURE__*/_react.default.createElement(_classifyHotkeys.default, {
      key: `use-hotkey-${index}`,
      title: title,
      shortcutData: shortcutData,
      shortcutDataNames: shortcutDataNames
    });
  })));
}