const fs = require('fs');

const file = 'dist/assets/index-D9sWWWv_.js';
const content = fs.readFileSync(file, 'utf8');

const t1 = `C.useEffect(()=>{const p=new Date().toISOString().substring(0,10);k.some(N=>N.status==="used"&&N.created_at.startsWith(p))||O(N=>N.map(D=>{if(D.status==="used"){const E=D.created_at.includes(" ")?D.created_at.split(" ")[1]:"08:00";return{...D,created_at:\`\${p} \${E}\`}}return D}))},[]);`;
const r1 = `C.useEffect(()=>{},[]);`;

if (content.includes(t1)) {
  const newContent = content.replace(t1, r1);
  fs.writeFileSync(file, newContent, 'utf8');
  console.log("Successfully replaced t1 (disabled date shifting effect)");
} else {
  console.log("Could NOT find t1. Searching with simplified pattern...");
  // Let's do a regex search for the useEffect block
  const regex = /C\.useEffect\(\(\)=>{const p=new Date\(\)\.toISOString\(\)\.substring\(0,10\);k\.some\(N=>N\.status==="used"&&N\.created_at\.startsWith\(p\)\)\|\|O\(N=>N\.map\(D=>{if\(D\.status==="used"\){const E=D\.created_at\.includes\(" "\)\?D\.created_at\.split\(" "\)\[1\]:"08:00";return{\.\.\.D,created_at:`\${p}\s+\${E}`}}return D\}\)\)\},\[\]\);/;
  const match = content.match(regex);
  if (match) {
    const newContent = content.replace(match[0], r1);
    fs.writeFileSync(file, newContent, 'utf8');
    console.log("Successfully replaced via regex!");
  } else {
    console.log("Regex also did not match!");
  }
}
