import { chromium } from "playwright";
import { mkdirSync } from "node:fs";
const BASE = "http://127.0.0.1:5180", API = "http://127.0.0.1:8010";
const OUT = process.argv[2] || "shots-aitools";
mkdirSync(OUT, { recursive: true });
const tok = (await (await fetch(`${API}/api/auth/login/`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ username: "airshelf", password: "Restraint2026" }) })).json()).token;
const pages = [["model-photo", "/model-photo"], ["platform-cover", "/platform-cover"], ["demo-a", "/model-photo/demo-a"], ["demo-b", "/model-photo/demo-b"]];
const browser = await chromium.launch();
const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 }, deviceScaleFactor: 1 });
await ctx.addInitScript((t) => localStorage.setItem("airshelf_token", t), tok);
const page = await ctx.newPage();
for (const [name, route] of pages) {
  await page.goto(BASE + route, { waitUntil: "networkidle", timeout: 30000 });
  await page.waitForTimeout(1500);
  await page.screenshot({ path: `${OUT}/${name}.png`, fullPage: true });
  console.log("shot", name);
}
await browser.close();
console.log("DONE");
