const fs = require('fs');

const frontendContent = fs.readFileSync('./dist/assets/index-D9sWWWv_.js', 'utf8');
const backendContent = fs.readFileSync('./dist/server.cjs', 'utf8');

function findMatches(content, filename, term) {
  let idx = 0;
  console.log(`=== Matches for "${term}" in ${filename} ===`);
  while (true) {
    idx = content.indexOf(term, idx);
    if (idx === -1) break;
    console.log(content.substring(Math.max(0, idx - 150), Math.min(content.length, idx + 450)));
    console.log('------------------');
    idx += term.length;
  }
}

findMatches(frontendContent, 'frontend bundle', 'expiredMode');
findMatches(backendContent, 'dist/server.cjs', 'expiredMode');
findMatches(backendContent, 'dist/server.cjs', 'sapu_rekam');
findMatches(backendContent, 'dist/server.cjs', 'sapu');
