import _objectSpread from "@babel/runtime/helpers/objectSpread2";
import { forwardRef } from 'react';
import { ErrorBoundary } from 'react-error-boundary';
import ErrorFallback from './ErrorFallback';
import { jsx as _jsx } from "react/jsx-runtime";

function withFormulaErrorBoundary(Form) {
  return /*#__PURE__*/forwardRef(function (_ref, ref) {
    var props = Object.assign({}, _ref);
    return /*#__PURE__*/_jsx(ErrorBoundary, {
      fallbackRender: function fallbackRender(errorProps) {
        var _props$customMessages;

        return /*#__PURE__*/_jsx(ErrorFallback, _objectSpread(_objectSpread({}, errorProps), {}, {
          customMessage: props === null || props === void 0 ? void 0 : (_props$customMessages = props.customMessages) === null || _props$customMessages === void 0 ? void 0 : _props$customMessages.error
        }));
      },
      children: /*#__PURE__*/_jsx(Form, _objectSpread({
        ref: ref
      }, props))
    });
  });
}

export default withFormulaErrorBoundary;
//# sourceMappingURL=withFormulaErrorBoundary.js.map