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

// Ensure the IndexedDB schema is fully open before any component mounts.
// Without this, table accessors (db.tables, db.orders, etc.) can be undefined
// when components try to use them synchronously on first render.
db.open().catch(err => console.error('[IDB] open failed:', err)).finally(() => {
  createRoot(document.getElementById('root')).render(
    <StrictMode>
      <App />
    </StrictMode>,
  )
})
