import React, { useMemo } from 'react';
import { ErrorBoundary } from 'react-error-boundary';
import Lozenge from '@atlaskit/lozenge';
var withErrorBoundary = function withErrorBoundary(Component) {
  return function (props) {
    var fallback = useMemo(function () {
      var _props$testId;
      return /*#__PURE__*/React.createElement(Lozenge, {
        appearance: props === null || props === void 0 ? void 0 : props.appearance,
        isBold: true,
        testId: "".concat((_props$testId = props === null || props === void 0 ? void 0 : props.testId) !== null && _props$testId !== void 0 ? _props$testId : 'smart-element-lozenge-action', "-fallback"),
        trailingMetric: props === null || props === void 0 ? void 0 : props.trailingMetric
      }, props === null || props === void 0 ? void 0 : props.text);
    }, [props === null || props === void 0 ? void 0 : props.appearance, props === null || props === void 0 ? void 0 : props.testId, props === null || props === void 0 ? void 0 : props.text, props === null || props === void 0 ? void 0 : props.trailingMetric]);
    return /*#__PURE__*/React.createElement(ErrorBoundary, {
      fallback: fallback
    }, /*#__PURE__*/React.createElement(Component, props));
  };
};
export default withErrorBoundary;