=0){ file = target.slice(0,hi); hash = target.slice(hi+1); }
file = (file.split('/').pop()) || 'ledger-home.html';
if (file.indexOf('?')>=0){ file = file.slice(0, file.indexOf('?')); }
var html = PAGES[file];
if (!html){
// Resilient lookup: match ignoring case so a mis-cased link still resolves.
var want = file.toLowerCase();
for (var k in PAGES){ if (k.toLowerCase()===want){ html = PAGES[k]; file = k; break; } }
}
if (!html){
// Never fail silently. If the page is not in this build, fall back to home
// so a tap always lands somewhere rather than appearing dead.
try { if (window.console) console.warn('Ledger: page not found ->', file); } catch(e){}
if (file !== 'ledger-home.html' && PAGES['ledger-home.html']){ html = PAGES['ledger-home.html']; file = 'ledger-home.html'; hash = ''; }
else { return; }
}
var isDash = DASHBOARDS.indexOf(file)>=0;
if (homebtn){ homebtn.style.display = isDash ? 'inline-flex' : 'none'; }
stage.onload = function(){
stage.onload = null;
if (boot) { boot.style.display='none'; }
if(file==='ledger-home.html'){try{var _d=stage.contentDocument;var _bf=_d&&_d.getElementById('sjfilmbanner');if(_bf&&PAGES['St-Jean-and-Company-Film.html']){_bf.srcdoc=PAGES['St-Jean-and-Company-Film.html']+"";}}catch(e){}}
try { stage.contentWindow.scrollTo(0,0); } catch(e){}
if (hash){
try { var w = stage.contentWindow; if (typeof w.go === 'function'){ w.go(hash); } } catch(e){}
}
};
stage.srcdoc = html;
}
function pillGo(k){
try{ var w = stage.contentWindow; if (w && typeof w.go === 'function' && w.document && w.document.getElementById('view')){ w.go(k); return; } }catch(e){}
load('ledger-home.html#'+k);
}
window.addEventListener('message', function(e){
var d = e.data;
if (d && d.__ledgerNav){ load(d.__ledgerNav); }
});
load('ledger-home.html');