import { StrictMode } from 'react'
import './i18n'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.tsx'

// If opened directly via file:// protocol (user opened index.html in browser),
// do NOT mount React — the static HTML content is already visible.
// Only mount React when served over HTTP/HTTPS (Readdy preview/server).
if (window.location.protocol === 'file:') {
  // Static HTML mode — do nothing, let the static content show
  console.log('Static HTML mode — React not mounted.');
} else {
  const rootEl = document.getElementById('root')
  if (rootEl) {
    // Clear static fallback content before mounting React
    rootEl.innerHTML = ''
    createRoot(rootEl).render(
      <StrictMode>
        <App />
      </StrictMode>,
    )
  }
}