/**
 * Convert SVG icons to PNG using sharp
 * Run: npm install -D sharp (nếu chưa có)
 */

const sharp = require('sharp');
const fs = require('fs');
const path = require('path');

const iconsDir = path.join(__dirname, '..', 'icons');
const sizes = [16, 48, 128];

async function convertIcons() {
  console.log('🔄 Converting SVG to PNG...');
  
  for (const size of sizes) {
    const svgPath = path.join(iconsDir, `icon${size}.svg`);
    const pngPath = path.join(iconsDir, `icon${size}.png`);
    
    if (!fs.existsSync(svgPath)) {
      console.log(`⚠️  SVG not found: icon${size}.svg`);
      continue;
    }
    
    try {
      await sharp(svgPath)
        .resize(size, size)
        .png()
        .toFile(pngPath);
      
      console.log(`✅ Converted: icon${size}.png`);
    } catch (error) {
      console.error(`❌ Error converting icon${size}:`, error.message);
    }
  }
  
  console.log('\n✅ Done! Icons ready in icons/ folder');
}

convertIcons().catch(console.error);

