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

const filePath = path.join(__dirname, 'enhancedAIAssistant.js');
let content = fs.readFileSync(filePath, 'utf8');

// Replace all unescaped double quotes within double-quoted strings
const replacements = [
  ['"I couldn\'t pull products right now. Try a keyword like "pens" or a SKU."', '"I couldn\'t pull products right now. Try a keyword like \\"pens\\" or a SKU."'],
  ['"I don\'t have a previous list to add. Search first (e.g. "pens"), then say "add all to quote"."', '"I don\'t have a previous list to add. Search first (e.g. \\"pens\\"), then say \\"add all to quote\\"."'],
  ['"I don\'t have a previous list to add. Search first (e.g. "pens"), then say "add all to cart"."', '"I don\'t have a previous list to add. Search first (e.g. \\"pens\\"), then say \\"add all to cart\\"."'],
  ['"Tell me the SKU or say "add the first one"."', '"Tell me the SKU or say \\"add the first one\\"."'],
  ['"Tell me the SKU or say "remove the first one"."', '"Tell me the SKU or say \\"remove the first one\\"."'],
  ['"Tell me the SKU (or say "send enquiry for the first one")."', '"Tell me the SKU (or say \\"send enquiry for the first one\\")."'],
];

for (const [oldStr, newStr] of replacements) {
  content = content.replace(oldStr, newStr);
}

fs.writeFileSync(filePath, content);
console.log('Fixed all quote syntax errors');
