var _excluded = ["scope"];
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
import { useEventListener } from './EventListener';
function bindHotkeys(_ref) {
  var _ref$dependencies = _ref.dependencies,
    dependencies = _ref$dependencies === void 0 ? [] : _ref$dependencies,
    _ref$event = _ref.event,
    event = _ref$event === void 0 ? 'keydown' : _ref$event,
    _ref$handler = _ref.handler,
    _handler = _ref$handler === void 0 ? function () {} : _ref$handler,
    key = _ref.key,
    preventDefault = _ref.preventDefault,
    stopPropagation = _ref.stopPropagation;
  return function (scope) {
    var keys = Array.isArray(key) ? key : [key];
    useEventListener({
      dependencies: dependencies,
      event: event,
      handler: function handler(e) {
        if (keys.includes(e.key)) {
          _handler(e);
          preventDefault && e.preventDefault();
          stopPropagation && e.stopPropagation();
        }
      },
      scope: scope
    });
  };
}

/**
 * @deprecatedSince 9.7.0
 * @deprecated Pass functions directly to JSX elements. For window events, add a new listener and remove it in an effect
 */
export function useHotkey(_ref2) {
  var _ref2$scope = _ref2.scope,
    scope = _ref2$scope === void 0 ? window : _ref2$scope,
    config = _objectWithoutProperties(_ref2, _excluded);
  var scopes = Array.isArray(scope) ? scope : [scope];
  scopes.forEach(bindHotkeys(config));
}
//# sourceMappingURL=Hotkey.js.map