"use strict"; 'use client'; Object.defineProperty(exports, "__esModule", { value: true }); exports.ErrorBoundary = ErrorBoundary; const bottom_tabs_1 = require("@react-navigation/bottom-tabs"); const react_1 = require("react"); const react_native_1 = require("react-native"); const react_native_safe_area_context_1 = require("react-native-safe-area-context"); const Pressable_1 = require("./Pressable"); const Link_1 = require("../link/Link"); const errors_1 = require("../rsc/router/errors"); function StandardErrorView({ error }) { return ( Something went wrong Error: {error.message} ); } function ErrorBoundary({ error, retry }) { const inTabBar = (0, react_1.use)(bottom_tabs_1.BottomTabBarHeightContext); const Wrapper = inTabBar ? react_native_1.View : react_native_safe_area_context_1.SafeAreaView; const isServerError = error instanceof errors_1.ReactServerError; return ( {isServerError ? () : ()} {process.env.NODE_ENV === 'development' && ( Sitemap )} {({ hovered, pressed }) => ( Retry )} ); } const COMMON_ERROR_STATUS = { 404: 'NOT_FOUND', 500: 'INTERNAL_SERVER_ERROR', 503: 'SERVICE_UNAVAILABLE', 504: 'GATEWAY_TIMEOUT', }; // TODO: This should probably be replaced by a DOM component that loads server errors in the future. function ReactServerErrorView({ error }) { let title = String(error.statusCode); title += ': ' + (COMMON_ERROR_STATUS[error.statusCode] ?? 'Server Error'); const errorId = error.headers.get('cf-ray'); const date = error.headers.get('Date'); return ( {title} {process.env.EXPO_OS === 'web' ? ( {error.message} ) : ()} {errorId && } {date && } {error.url && ( {error.url} )} ); } function InfoRow({ title, right }) { const style = { fontSize: 16, color: 'white', }; return ( {title} {right && ( {right} )} ); } const styles = react_native_1.StyleSheet.create({ container: { flex: 1, backgroundColor: 'black', padding: 24, alignItems: 'stretch', justifyContent: 'center', }, title: { color: 'white', fontSize: react_native_1.Platform.select({ web: 32, default: 24 }), fontWeight: 'bold', }, buttonText: { fontSize: 18, fontWeight: 'bold', color: 'black', ...react_native_1.Platform.select({ web: { transitionDuration: '100ms', }, }), }, buttonInner: { ...react_native_1.Platform.select({ web: { transitionDuration: '100ms', }, }), paddingVertical: 12, paddingHorizontal: 24, borderColor: 'white', borderWidth: 2, marginLeft: 8, justifyContent: 'center', alignItems: 'center', }, code: { fontFamily: react_native_1.Platform.select({ default: 'Courier', ios: 'Courier New', android: 'monospace', }), fontWeight: '500', }, errorMessage: { color: 'white', fontSize: 16, }, subtitle: { color: 'white', fontSize: 14, marginBottom: 12, }, link: { color: 'rgba(255,255,255,0.4)', textDecorationStyle: 'solid', textDecorationLine: 'underline', fontSize: 14, textAlign: 'center', }, }); //# sourceMappingURL=ErrorBoundary.js.map