"use strict";

exports.__esModule = true;
exports["default"] = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactRedux = require("react-redux");
var _reduxForm = require("redux-form");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var tgFormValues = function tgFormValues() {
  for (var _len = arguments.length, fieldNames = new Array(_len), _key = 0; _key < _len; _key++) {
    fieldNames[_key] = arguments[_key];
  }
  return function (Component) {
    return function (props) {
      return /*#__PURE__*/_react["default"].createElement(_reduxForm.FormName, null, function (formName) {
        var name = formName.form;
        var Wrapped = (0, _react.useMemo)(function () {
          var selector = (0, _reduxForm.formValueSelector)(name || "");
          var wrapper = (0, _reactRedux.connect)(function (state) {
            var vals = {};
            fieldNames.forEach(function (name) {
              vals[name] = selector(state, name);
            });
            return vals;
          });
          return wrapper(Component);
        }, [name]);
        return /*#__PURE__*/_react["default"].createElement(Wrapped, props);
      });
    };
  };
};
var _default = tgFormValues;
exports["default"] = _default;
module.exports = exports.default;