try {
    console.error('Downloading emoji-test.txt...');
    const response = await fetch('https://unicode.org/Public/emoji/latest/emoji-test.txt');
    const text = await response.text();
    const emojis = extractEmojis(text);
    console.error(`Extracted ${emojis.length} fully-qualified emojis.`);
    console.log(`
    namespace Femto.Modules.Blog.Emoji;
    
    internal static partial class AllEmoji
    {
        public static readonly string[] Emojis = [\n${emojis.map(e => `"${e}"`).join(',\n')}\n];
    }
    `)
} catch (err) {
    console.error('Error:', err);
}


function extractEmojis(text) {
    const lines = text.split('\n');
    const emojis = [];

    for (const line of lines) {
        if (line.startsWith('#') || line.trim() === '') continue;

        const [codePart, descPart] = line.split(';');
        if (!descPart || !descPart.includes('fully-qualified')) continue;

        const match = line.match(/#\s+(.+?)\s+E\d+\.\d+/);
        if (match) {
            emojis.push(match[1]);
        }
    }

    return emojis;
}

