import { Component } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { SvgXml } from 'react-native-svg';
import { errorPage } from '../../assets/icons';
export class ErrorBoundary extends Component {
  constructor(props) {
    super(props);
    this.state = {
      hasError: false,
      error: null
    };
  }
  static getDerivedStateFromError(error) {
    return {
      hasError: true,
      error
    };
  }
  componentDidCatch(error, errorInfo) {
    var _this$props$onError, _this$props;
    (_this$props$onError = (_this$props = this.props).onError) === null || _this$props$onError === void 0 || _this$props$onError.call(_this$props, error, errorInfo);
  }
  handleReset = () => {
    var _this$props$onReset, _this$props2;
    this.setState({
      hasError: false,
      error: null
    });
    (_this$props$onReset = (_this$props2 = this.props).onReset) === null || _this$props$onReset === void 0 || _this$props$onReset.call(_this$props2);
  };
  render() {
    if (this.state.hasError) {
      if (this.props.fallback) {
        return this.props.fallback;
      }
      return /*#__PURE__*/React.createElement(View, {
        style: styles.container
      }, /*#__PURE__*/React.createElement(SvgXml, {
        xml: errorPage('#EBECEF')
      }), /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(Text, {
        style: styles.title
      }, "Something went wrong"), /*#__PURE__*/React.createElement(Text, {
        style: styles.description
      }, "The content you're looking for is unavailable.")));
    }
    return this.props.children;
  }
}
const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
    gap: 16,
    flexDirection: 'column'
  },
  title: {
    color: '#A5A9B5',
    textAlign: 'center',
    fontSize: 20
  },
  description: {
    color: '#A5A9B5',
    textAlign: 'center',
    fontSize: 15
  }
});
export default ErrorBoundary;
//# sourceMappingURL=ErrorBoundary.js.map