"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ErrorBoundary = void 0;
var _propTypes = _interopRequireDefault(require("prop-types"));
var _react = _interopRequireDefault(require("react"));
var _helpers = require("./helpers");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
class InternalErrorBoundary extends _react.default.Component {
  constructor(props) {
    super(props);
    this.state = {
      error: undefined
    };
  }
  componentDidCatch(error, info) {
    (0, _helpers.reportError)(error, {
      componentStack: info === null || info === void 0 ? void 0 : info.componentStack
    });
    this.setState({
      error
    });
  }
  render() {
    const children = this.props.children;
    const error = this.state.error;
    if (error) throw error;
    return children || null;
  }
}
InternalErrorBoundary.displayName = 'core:components:ErrorBoundary';
InternalErrorBoundary.propTypes = {
  children: _propTypes.default.node
};
const ErrorBoundary = props => /*#__PURE__*/_react.default.createElement(InternalErrorBoundary, props);
exports.ErrorBoundary = ErrorBoundary;
ErrorBoundary.displayName = InternalErrorBoundary.displayName;
ErrorBoundary.propTypes = InternalErrorBoundary.propTypes;
//# sourceMappingURL=Core.ErrorBoundary.js.map