"use strict";

exports.__esModule = true;
exports.default = void 0;

var _react = _interopRequireDefault(require("react"));

var _reactRouterDom = require("react-router-dom");

var _navigation = require("../../selectors/navigation");

var _navigation2 = require("../../actions/navigation");

var _useLoader = _interopRequireDefault(require("../../hooks/useLoader"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();

(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};

var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};

var withWaypointing = function withWaypointing(Comp, componentProps) {
  if (componentProps === void 0) {
    componentProps = {};
  }

  return __signature__(__signature__(function (props) {
    var match = props.match,
        mapFrom = props.mapFrom,
        modulePrependPath = props.modulePrependPath;
    var location = (0, _reactRouterDom.useLocation)();
    var loadActions = [];

    if (modulePrependPath) {
      loadActions.push((0, _navigation2.setCurrentPrependPath)(modulePrependPath));
    }

    if (match.isExact) {
      if (mapFrom) {
        loadActions.push((0, _navigation2.mapHref)(mapFrom, location.pathname), (0, _navigation2.setRoute)(_objectSpread(_objectSpread({}, location), {}, {
          pathname: mapFrom
        }), match));
      } else {
        loadActions.push((0, _navigation2.setRoute)(location, match));
      }
    }

    var cutout = function cutout(state) {
      return (0, _navigation.selectRouteHref)(state) === location.pathname;
    };

    (0, _useLoader.default)(loadActions, cutout);
    return /*#__PURE__*/_react.default.createElement(Comp, _extends({}, props, componentProps));
  }, "useLocation{location}\nuseLoader{}", function () {
    return [_reactRouterDom.useLocation, _useLoader.default];
  }), "useLocation{location}\nuseLoader{}", function () {
    return [_reactRouterDom.useLocation, _useLoader.default];
  });
};

var _default = withWaypointing;
var _default2 = _default;
var _default3 = _default2;
exports.default = _default3;
;

(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;

  if (!reactHotLoader) {
    return;
  }

  reactHotLoader.register(withWaypointing, "withWaypointing", "/home/vsts/work/1/s/src/components/Routing/withWaypointing.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/Routing/withWaypointing.js");
})();

;

(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();

;

(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;

  if (!reactHotLoader) {
    return;
  }

  reactHotLoader.register(withWaypointing, "withWaypointing", "/home/vsts/work/1/s/src/components/Routing/withWaypointing.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/Routing/withWaypointing.js");
})();

;

(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();