// Final pass: catch remaining "Shield" mentions in user-facing copy.
const fs = require('fs');
const path = require('path');
const dir = 'public/views';
const files = fs.readdirSync(dir).filter(f => f.endsWith('.html'));
let changedFiles = 0;
const replacements = [
  // About page specific
  [/Vesamuni Cybersecurity &amp; the Shield Mission/g, 'Vesamuni Cybersecurity &amp; the takedowns mission'],
  [/Vesamuni Cybersecurity & the Shield Mission/g, 'Vesamuni Cybersecurity & the takedowns mission'],
  // Meta keywords
  [/Shield about/g, 'takedowns about'],
  // Blog/image alt text
  [/>Shield blog</g, '>takedowns blog'],
  [/content="Shield blog/g, 'content="takedowns blog'],
  // Generic: any "Shield" preceded by space, capital, or punctuation → takedowns
  // Catch sentences where "Shield" is the subject: "Shield is", "Shield will", etc.
  [/\bShield is\b/g, 'takedowns is'],
  [/\bShield will\b/g, 'takedowns will'],
  [/\bShield can\b/g, 'takedowns can'],
  [/\bShield does\b/g, 'takedowns does'],
  [/\bShield doesn\b/g, "takedowns doesn"],
  [/\bShield never\b/g, 'takedowns never'],
  [/\bShield provides\b/g, 'takedowns provides'],
  [/\bShield prioritizes\b/g, 'takedowns prioritizes'],
  [/\bShield operates\b/g, 'takedowns operates'],
  [/\bShield coordinates\b/g, 'takedowns coordinates'],
  [/\bShield compiles\b/g, 'takedowns compiles'],
  [/\bShield derives\b/g, 'takedowns derives'],
  [/\bShield handles\b/g, 'takedowns handles'],
  [/\bShield reduces\b/g, 'takedowns reduces'],
  [/\bShield structures\b/g, 'takedowns structures'],
  [/\bShield helps\b/g, 'takedowns helps'],
  [/\bShield serves\b/g, 'takedowns serves'],
  [/\bShield requires\b/g, 'takedowns requires'],
  [/\bShield tracks\b/g, 'takedowns tracks'],
  [/\bShield runs\b/g, 'takedowns runs'],
  [/\bShield offers\b/g, 'takedowns offers'],
  [/\bShield dispatches\b/g, 'takedowns dispatches'],
  [/\bShield drafts\b/g, 'takedowns drafts'],
  [/\bShield removes\b/g, 'takedowns removes'],
  [/\bShield stores\b/g, 'takedowns stores'],
  [/\bShield uses\b/g, 'takedowns uses'],
  [/\bShield generates\b/g, 'takedowns generates'],
  [/\bShield exports\b/g, 'takedowns exports'],
  [/\bShield lets\b/g, 'takedowns lets'],
  [/\bShield enables\b/g, 'takedowns enables'],
  [/\bShield ensures\b/g, 'takedowns ensures'],
  [/\bShield is operated\b/g, 'takedowns is operated'],
  [/\bShield is built\b/g, 'takedowns is built'],
  [/\bShield is a\b/g, 'takedowns is a'],
  [/\bShield is an\b/g, 'takedowns is an'],
  [/\bShield is not\b/g, 'takedowns is not'],
  [/\bShield structures these\b/g, 'takedowns structures these'],
  [/\bShield reduces manual\b/g, 'takedowns reduces manual'],
  [/\bShield handles the volume\b/g, 'takedowns handles the volume'],
  [/\buse of Shield\b/g, 'use of takedowns'],
  [/\bwith Shield\b/g, 'with takedowns'],
  [/\bby Shield\b/g, 'by takedowns'],
  [/\bShield — Article\b/g, 'takedowns — Article'],
];
for (const f of files) {
  const fp = path.join(dir, f);
  let html = fs.readFileSync(fp, 'utf8');
  const before = html;
  for (const [pattern, repl] of replacements) {
    html = html.replace(pattern, repl);
  }
  if (html !== before) {
    fs.writeFileSync(fp, html);
    changedFiles++;
  }
}
console.log('Final pass changed', changedFiles, 'files');
