const fs = require('fs');
let h = fs.readFileSync('index.html', 'utf8');

// Remove treasury field from sales returns modal
const salesTreasuryBlock = `        <div class="flex-col">
          <label>الدفع / الخزينة (اختياري)</label>
          <select id="sales-returns-treasury"><option value="">-- آجل / لم يتم الدفع --</option></select>
        </div>`;
if (h.includes(salesTreasuryBlock)) {
  h = h.replace(salesTreasuryBlock, '');
  console.log('Removed sales treasury field');
} else {
  console.log('Sales treasury field not found with exact match, trying partial...');
  const idx = h.indexOf('sales-returns-treasury');
  console.log('sales-returns-treasury found at:', idx);
}

// Remove treasury field from purchases returns modal
const purchasesTreasuryBlock = `        <div class="flex-col">
          <label>الدفع / الخزينة (اختياري)</label>
          <select id="purchases-returns-treasury"><option value="">-- آجل / لم يتم الدفع --</option></select>
        </div>`;
if (h.includes(purchasesTreasuryBlock)) {
  h = h.replace(purchasesTreasuryBlock, '');
  console.log('Removed purchases treasury field');
} else {
  console.log('Purchases treasury field not found with exact match');
  const idx = h.indexOf('purchases-returns-treasury');
  console.log('purchases-returns-treasury found at:', idx);
}

fs.writeFileSync('index.html', h);
console.log('Done. File size:', h.length);
