
/* pwa_app.js - entry */
import './pwa_sw_register.js';

window.app = {
  init: function(){
    const root = document.getElementById('pwa-root') || document.body;
    const role = root && root.dataset && root.dataset.role ? root.dataset.role : (window.ATULYA_PWA_ROLE || 'guest');
    root.innerHTML = '<div id="app"><header><h1>AtulyaSolar PWA — ' + role + '</h1></header><main id="main"></main></div>';
    // simple nav + load dashboard module
    import('/pwa/modules/dashboard.js').then(m=>m.render(role));
  }
};

if (document.readyState === 'complete' || document.readyState === 'interactive') {
  if (window.app && window.app.init) window.app.init();
} else {
  document.addEventListener('DOMContentLoaded', ()=> window.app.init());
}
