const fs = require('fs');
const path = require('path');

function searchDir(dir) {
  const files = fs.readdirSync(dir);
  for (const file of files) {
    const fullPath = path.join(dir, file);
    if (file === 'node_modules' || file === '.git' || file === 'dist' || file === '.aistudio') continue;
    const stat = fs.statSync(fullPath);
    if (stat.isDirectory()) {
      searchDir(fullPath);
    } else if (file.endsWith('.js') || file.endsWith('.json') || file.endsWith('.html') || file.endsWith('.cjs')) {
      const content = fs.readFileSync(fullPath, 'utf8');
      if (content.includes('sendSaaSSystemNotification') || content.includes('saas_wa') || content.includes('saas_tele')) {
        console.log(`Found in: ${fullPath}`);
        // print matching lines
        const lines = content.split('\n');
        lines.forEach((line, i) => {
          if (line.includes('sendSaaSSystemNotification') || line.includes('saas_wa') || line.includes('saas_tele')) {
            console.log(`Line ${i+1}: ${line}`);
          }
        });
      }
    }
  }
}

searchDir('.');
