/* ErrorBoundary — ловит ошибки в модулях и показывает fallback вместо белого экрана */ window.RD = window.RD || { core: {}, modules: {} }; window.RD.core.ErrorBoundary = class ErrorBoundary extends React.Component { constructor(props) { super(props); this.state = { hasError: false, error: null, errorInfo: null }; } static getDerivedStateFromError(error) { return { hasError: true }; } componentDidCatch(error, errorInfo) { console.error('[ErrorBoundary] Module crashed:', error, errorInfo); this.state = { hasError: true, error: error, errorInfo: errorInfo }; } render() { if (this.state.hasError) { var h = React.createElement; return h('div', { style: { flex: 1, display: 'flex', alignItems: 'center', justifyContent: 'center', flexDirection: 'column', gap: 16, padding: 40, textAlign: 'center' } }, h('div', { style: { fontSize: 48 } }, '💥'), h('h2', { style: { fontSize: 20, fontWeight: 700, color: 'var(--rd-text)', marginBottom: 8 } }, 'Модуль сломался'), h('p', { style: { fontSize: 14, color: 'var(--rd-text-muted)', maxWidth: 500, marginBottom: 16 } }, 'Ошибка в модуле "' + (this.props.moduleName || 'Unknown') + '". Попробуйте другую вкладку или обновите страницу.'), h('details', { style: { background: 'var(--rd-surface-2)', border: '1px solid var(--rd-border)', borderRadius: 8, padding: 12, maxWidth: 600, textAlign: 'left', fontSize: 12, fontFamily: 'monospace' } }, h('summary', { style: { cursor: 'pointer', fontWeight: 600, color: 'var(--rd-bad)', marginBottom: 8 } }, '🔍 Детали ошибки (для разработчиков)'), h('pre', { style: { margin: 0, whiteSpace: 'pre-wrap', wordBreak: 'break-word', color: 'var(--rd-text-muted)' } }, 'Error: ' + (this.state.error && this.state.error.toString()) + '\n\n' + 'Stack:\n' + (this.state.errorInfo && this.state.errorInfo.componentStack) ) ), h('button', { onClick: function() { window.location.reload(); }, style: { padding: '10px 20px', border: '1px solid var(--rd-border)', borderRadius: 8, background: 'var(--rd-surface)', color: 'var(--rd-text)', cursor: 'pointer', fontSize: 14, fontWeight: 600 } }, '🔄 Обновить страницу') ); } return this.props.children; } };