const fs = require('fs');
const s = fs.readFileSync('chat/public/builder.js','utf8');
let paren=0,brack=0,brace=0,backtick=0;
for(let i=0;i<s.length;i++){
  const c=s[i];
  if(c==='`') backtick ^= 1;
  if(!backtick){
    if(c==='(') paren++;
    if(c===')') paren--;
    if(c==='[') brack++;
    if(c===']') brack--;
    if(c==='{') brace++;
    if(c==='}') brace--;
  }
  if(paren<0||brack<0||brace<0){
    const lines=s.slice(0,i+1).split('\n');
    console.log('Mismatch at char', i, 'line', lines.length);
    console.log('char:',c);
    console.log('paren,brack,brace',paren,brack,brace);
    console.log(lines.slice(-6).join('\n'));
    process.exit(1);
  }
}
console.log('final counts paren,brack,brace,backtick',paren,brack,brace,backtick);