'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

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

var _reducers = require('../../reducers');

var _OptionPickerInput = require('../../components/record/OptionPickerInput');

var _OptionPickerInput2 = _interopRequireDefault(_OptionPickerInput);

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

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

const mapStateToProps = (state, ownProps) => {
  const source = ownProps.source;


  return {
    options: (0, _reducers.getOptionList)(state, source)
  };
};

const mapDispatchToProps = {};

const mergeProps = (stateProps, dispatchProps, ownProps) => {
  const source = ownProps.source,
        remainingOwnProps = _objectWithoutProperties(ownProps, ['source']);

  return Object.assign({}, remainingOwnProps, stateProps, dispatchProps);
};

const ConnectedOptionPickerInput = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps, mergeProps)(_OptionPickerInput2.default);

ConnectedOptionPickerInput.propTypes = Object.assign({}, _OptionPickerInput2.default.propTypes, {
  source: _propTypes2.default.string
});

exports.default = ConnectedOptionPickerInput;