import { writeFileSync, mkdirSync } from 'fs';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
// Icons we need to extract
const icons = [
'zap', // ⚡
'heart', // ❤️
'chevron-up', // ⬆️
'chevron-down', // ⬇️
'sun', // ☀️
'moon', // 🌙
'user', // 👤
'plus' // ➕
];
const staticDir = join(__dirname, '..', 'static', 'icons');
mkdirSync(staticDir, { recursive: true });
// Import lucide-svelte to get the icon paths
try {
const lucide = await import('lucide-svelte');
for (const iconName of icons) {
// Convert kebab-case to PascalCase
const componentName = iconName
.split('-')
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
.join('');
// Get the icon component
const IconComponent = lucide[componentName];
if (!IconComponent) {
console.warn(`Icon ${iconName} (${componentName}) not found`);
continue;
}
// Extract SVG path from the component
// Lucide icons are SVG components, we need to render them to get the path
// For now, let's use the known SVG paths from lucide
const svgPaths = {
'zap': '',
'heart': '',
'chevron-up': '',
'chevron-down': '',
'sun': '',
'moon': '',
'user': '',
'plus': ''
};
const path = svgPaths[iconName];
if (!path) {
console.warn(`No SVG path found for ${iconName}`);
continue;
}
const svg = ``;
const filePath = join(staticDir, `${iconName}.svg`);
writeFileSync(filePath, svg, 'utf-8');
console.log(`Extracted ${iconName}.svg`);
}
console.log('All icons extracted successfully!');
} catch (error) {
console.error('Error extracting icons:', error);
process.exit(1);
}