import React, { Component, ErrorInfo, ReactNode } from 'react'; import ReactDOM from 'react-dom/client'; import App from './App'; // Polyfills for browser resilience if (typeof window !== 'undefined') { if (!(window as any).IntersectionObserver) { (window as any).IntersectionObserver = class { private callback: any; constructor(callback: any) { this.callback = callback; } observe(element: any) { if (this.callback) { try { this.callback([{ isIntersecting: true, target: element }]); } catch (_) {} } } unobserve() {} disconnect() {} }; } if (!(window as any).ResizeObserver) { (window as any).ResizeObserver = class { private callback: any; constructor(callback: any) { this.callback = callback; } observe(element: any) { if (this.callback) { try { this.callback([{ target: element, contentRect: element.getBoundingClientRect() }]); } catch (_) {} } } unobserve() {} disconnect() {} }; } } interface ErrorBoundaryProps { children: ReactNode; } interface ErrorBoundaryState { hasError: boolean; } class RootErrorBoundary extends Component { constructor(props: ErrorBoundaryProps) { super(props); this.state = { hasError: false }; } public static getDerivedStateFromError(): ErrorBoundaryState { return { hasError: true }; } public componentDidCatch(error: Error, errorInfo: ErrorInfo) { console.error("Lys d'Orient Spa - Uncaught error:", error, errorInfo); } public render() { if (this.state.hasError) { return (
Lys d'Orient Spa

Lys d'Orient Spa

Une légère interruption est survenue lors de l'affichage. Veuillez actualiser la page pour retrouver votre expérience.

); } return this.props.children; } } // Resilient mounting with immediate attempt + event listeners + polling function startApp(): boolean { if (typeof window === 'undefined') return false; if ((window as any).__lys_spa_mounted) return true; const rootElement = document.getElementById('root'); if (!rootElement) { return false; } try { (window as any).__lys_spa_mounted = true; const root = ReactDOM.createRoot(rootElement); root.render( ); return true; } catch (err) { console.error("Mount error in Lys d'Orient:", err); return false; } } // 1. Immediate mount attempt if (!startApp()) { // 2. If DOM not ready yet, wait for events if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', () => startApp()); } window.addEventListener('load', () => startApp()); // 3. Fallback interval in case of delayed execution or iframe delay let attempts = 0; const timer = setInterval(() => { attempts++; if (startApp() || attempts > 50) { clearInterval(timer); } }, 40); }