import _noop from "lodash/fp/noop";
import _has from "lodash/fp/has";
import _getOr from "lodash/fp/getOr";
/* eslint-disable node/no-deprecated-api */
import { parse } from 'url';
const isLeftClickEvent = e => e.button === 0;
const isModifiedEvent = e => !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
const navigation = options => {
  const _history = _getOr({}, 'history', options);
  if (!_has('push', _history)) {
    return () => _noop;
  }
  return ({
    href
  } = {}) => e => {
    if (!href || e.defaultPrevented || isModifiedEvent(e) || !isLeftClickEvent(e)) {
      return;
    }
    if (parse(href).host) return;
    e.preventDefault();
    _history.push(href);
  };
};
export default navigation;
//# sourceMappingURL=navigation.js.map