// scripts/generate-pwa-screenshots.js
const fs = require("fs");
const path = require("path");
const sharp = require("sharp");

const OUT_DIR = path.join(__dirname, "..", "public", "screenshots");
fs.mkdirSync(OUT_DIR, { recursive: true });

async function main() {
  // Desktop dashboard placeholder
  await sharp({
    create: { width: 1280, height: 720, channels: 3, background: { r: 250, g: 248, b: 245 } }
  })
  .composite([{
    input: Buffer.from(`<svg width="1280" height="720" xmlns="http://www.w3.org/2000/svg">
      <text x="640" y="360" font-family="serif" font-size="48" fill="#1a4d2e" text-anchor="middle">Route Commerce</text>
    </svg>`),
    top: 0, left: 0,
  }])
  .png()
  .toFile(path.join(OUT_DIR, "dashboard.png"));
  console.log("✓ dashboard.png");

  // Mobile storefront placeholder
  await sharp({
    create: { width: 390, height: 844, channels: 3, background: { r: 250, g: 248, b: 245 } }
  })
  .composite([{
    input: Buffer.from(`<svg width="390" height="844" xmlns="http://www.w3.org/2000/svg">
      <text x="195" y="422" font-family="serif" font-size="32" fill="#1a4d2e" text-anchor="middle">Route Commerce</text>
    </svg>`),
    top: 0, left: 0,
  }])
  .png()
  .toFile(path.join(OUT_DIR, "mobile-storefront.png"));
  console.log("✓ mobile-storefront.png");
}

main().catch(console.error);
