const fs = require('fs');
let appFinalJs = fs.readFileSync('app_final.js', 'utf8');

// The `else` block at the end of setupUserUI:
appFinalJs = appFinalJs.replace(
    /document\.getElementById\('nav-settlements'\)\.style\.display = 'block';/g,
    `document.getElementById('nav-settlements').style.display = 'block';
    document.getElementById('nav-accounting').style.display = 'block';`
);

fs.writeFileSync('app_final.js', appFinalJs, 'utf8');

// Update version in index.html to bust cache
let html = fs.readFileSync('index.html', 'utf8');
html = html.replace(/v=\d+/g, 'v=' + Date.now());
fs.writeFileSync('index.html', html, 'utf8');

console.log('Accounting nav added successfully');
