"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.ConnectedReportViewerPage = void 0;

var _reactRedux = require("react-redux");

var _immutable = _interopRequireDefault(require("immutable"));

var _qs = _interopRequireDefault(require("qs"));

var _ReportViewerPage = _interopRequireDefault(require("../../components/pages/ReportViewerPage"));

var _withConfig = _interopRequireDefault(require("../../enhancers/withConfig"));

var _report = require("../../actions/report");

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

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

const mapDispatchToProps = (dispatch, ownProps) => ({
  readContent: (location, match) => {
    const queryParams = _qs.default.parse(location.search, {
      ignoreQueryPrefix: true
    });

    const {
      params: paramsJson
    } = queryParams,
          invocationDescriptorObject = _objectWithoutProperties(queryParams, ["params"]);

    const params = paramsJson && JSON.parse(paramsJson);

    const invocationDescriptor = _immutable.default.fromJS(invocationDescriptorObject);

    return dispatch((0, _report.invoke)(ownProps.config, match.params.reportCsid, invocationDescriptor, params));
  }
});

const ConnectedReportViewerPage = (0, _reactRedux.connect)(undefined, mapDispatchToProps)(_ReportViewerPage.default);
exports.ConnectedReportViewerPage = ConnectedReportViewerPage;

var _default = (0, _withConfig.default)(ConnectedReportViewerPage);

exports.default = _default;