"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = withFillActions;

var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));

var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

var _react = require("react");

var _styles = require("@material-ui/core/styles");

var _reactIntl = require("react-intl");

var _Button = _interopRequireDefault(require("@material-ui/core/Button"));

var _jsxRuntime = require("react/jsx-runtime");

var _excluded = ["fillProps", "customMessages"];
var useStyles = (0, _styles.makeStyles)(function (theme) {
  return {
    buttonContainer: {
      '& > *': {
        marginRight: theme.spacing(1),
        marginTop: theme.spacing(1),
        '@media print': {
          display: 'none'
        }
      }
    }
  };
});

function withFillActions(Form) {
  return /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
    var fillProps = _ref.fillProps,
        customMessages = _ref.customMessages,
        otherProps = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
    var classes = useStyles();

    if (fillProps === null || fillProps === void 0 ? void 0 : fillProps.actions) {
      var _customMessages$submi;

      return /*#__PURE__*/(0, _jsxRuntime.jsx)(Form, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
        ref: ref,
        fillProps: fillProps,
        customMessages: customMessages
      }, otherProps), {}, {
        children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
          className: classes.buttonContainer,
          children: [fillProps.actions, otherProps.draftButton, /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button["default"], {
            type: "submit",
            variant: "contained",
            color: "primary",
            children: (_customMessages$submi = customMessages === null || customMessages === void 0 ? void 0 : customMessages.submit) !== null && _customMessages$submi !== void 0 ? _customMessages$submi : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
              id: "6jFMKd",
              defaultMessage: [{
                "type": 0,
                "value": "Lähetä"
              }]
            })
          })]
        })
      }));
    } else {
      return /*#__PURE__*/(0, _jsxRuntime.jsx)(Form, (0, _objectSpread2["default"])({
        ref: ref,
        fillProps: fillProps,
        customMessages: customMessages
      }, otherProps));
    }
  });
}
//# sourceMappingURL=withFillActions.cjs.map