'use strict';

var __rest = (undefined && undefined.__rest) || function (s, e) {
  var t = {};
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
    t[p] = s[p];
  if (s != null && typeof Object.getOwnPropertySymbols === "function")
    for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
      if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
        t[p[i]] = s[p[i]];
    }
  return t;
};
/**
 * It returns a function that takes a KeyboardEvent and dispatches a click event on the currentTarget if the key is Enter.
 *
 * @param {ClickEventOptions} options - An optional object that can contain a "composed" property to specify whether the dispatched event should be composed.
 * @returns {(e: KeyboardEvent) => void } A function that takes a KeyboardEvent and dispatches a click event on the currentTarget.
 */
function createEnterKeyHandlerToTriggerClick(options) {
  const _a = options || {}, { preventDefault = false } = _a, mouseEventOptions = __rest(_a, ["preventDefault"]);
  return function (e) {
    var _a;
    if (e.key === 'Enter') {
      if (preventDefault) {
        e.preventDefault();
      }
      (_a = e.currentTarget) === null || _a === void 0 ? void 0 : _a.dispatchEvent(new MouseEvent('click', Object.assign({ bubbles: true, cancelable: true, view: window }, mouseEventOptions)));
    }
  };
}

exports.createEnterKeyHandlerToTriggerClick = createEnterKeyHandlerToTriggerClick;
