import React, { useMemo } from "react";
import { connect } from "react-redux";
import { FormName, formValueSelector } from "redux-form";
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.createElement(FormName, null, function (formName) {
        var name = formName.form;
        var Wrapped = useMemo(function () {
          var selector = formValueSelector(name || "");
          var wrapper = connect(function (state) {
            var vals = {};
            fieldNames.forEach(function (name) {
              vals[name] = selector(state, name);
            });
            return vals;
          });
          return wrapper(Component);
        }, [name]);
        return /*#__PURE__*/React.createElement(Wrapped, props);
      });
    };
  };
};
export default tgFormValues;