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

// Only mount in the WP Admin page where the container exists
const container = document.getElementById('invizo-subs-dashboard')

if (container) {
  createRoot(container).render(
    <StrictMode>
      <App />
    </StrictMode>,
  )
} else if (import.meta.env.DEV) {
  // If we are developing via `npm run dev` locally, mount to generic #root
  const devContainer = document.getElementById('root')
  if (devContainer) {
    createRoot(devContainer).render(
      <StrictMode>
        <App />
      </StrictMode>,
    )
  }
}
