/**
 * dashboard.html entry (v0.9) — host ●status list. No inline script (strict CSP).
 */
import { readConfig } from '../config'
import { createApiClient } from '../api-client'
import { mountDashboard } from '../dashboard'

function boot(): void {
  const cfg = readConfig(window.location)
  const root = document.getElementById('dashboard')
  if (!root) return
  const api = createApiClient(cfg)
  mountDashboard(root, api, {
    onOpen: (hostId) => {
      window.location.assign(`/term.html?host=${encodeURIComponent(hostId)}`)
    },
  })
}

if (document.readyState === 'loading') {
  document.addEventListener('DOMContentLoaded', boot)
} else {
  boot()
}
