import puppeteer from 'puppeteer';
const CHROME='/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
const OUT=process.env.SHOTS;
const b=await puppeteer.launch({executablePath:CHROME, headless:'new', args:['--no-sandbox','--disable-dev-shm-usage']});
const p=await b.newPage();
p.on('console',m=>{ if(m.type()==='error') console.log('  [console.error]', m.text().slice(0,160)); });
p.on('pageerror',e=>console.log('  [pageerror]', String(e).slice(0,200)));
await p.setViewport({width:390,height:844,deviceScaleFactor:2,isMobile:true,hasTouch:true});
await p.goto('https://el3ab-player.caprover.al-arcade.com/',{waitUntil:'networkidle2',timeout:45000});
await new Promise(r=>setTimeout(r,2500));
await p.screenshot({path:OUT+'/00-boot.png'});
console.log('title:', await p.title());
console.log('body :', (await p.evaluate(()=>document.body.innerText)).slice(0,400).replace(/\n+/g,' | '));
await b.close();
