// Emoji shortcode to Unicode mapping
// Based on common emoji shortcodes used in chat platforms
const emojiMap: Record<string, string> = {
  // Smileys & Emotion
  'joy': '😂',
  'heart_eyes': '😍',
  'sob': '😭',
  'blush': '😊',
  'kissing_heart': '😘',
  'smiling': '☺️',
  'weary': '😩',
  'pensive': '😔',
  'smirk': '😏',
  'grin': '😁',
  'wink': '😉',
  'relieved': '😌',
  'flushed': '😳',
  'cry': '😢',
  'sunglasses': '😎',
  'sweat_smile': '😅',
  'sleeping': '😴',
  'smile': '😄',
  'purple_heart': '💜',
  'broken_heart': '💔',
  'expressionless': '😑',
  'sparkling_heart': '💖',
  'blue_heart': '💙',
  'confused': '😕',
  'stuck_out_tongue_winking_eye': '😜',
  'disappointed': '😞',
  'yum': '😋',
  'neutral_face': '😐',
  'sleepy': '😪',
  'cupid': '💘',
  'heartpulse': '💗',
  'revolving_hearts': '💞',
  'speak_no_evil': '🙊',
  'see_no_evil': '🙈',
  'rage': '😡',
  'smiley': '😃',
  'tired_face': '😫',
  'stuck_out_tongue_closed_eyes': '😝',
  'muscle': '💪',
  'skull': '💀',
  'sunny': '☀️',
  'yellow_heart': '💛',
  'triumph': '😤',
  'new_moon_with_face': '🌚',
  'laughing': '😆',
  'sweat': '😓',
  'heavy_check_mark': '✔️',
  'heart_eyes_cat': '😻',
  'grinning': '😀',
  'mask': '😷',
  'green_heart': '💚',
  'persevere': '😣',
  'heartbeat': '💓',
  'angry': '😠',
  'grimacing': '😬',
  'gun': '🔫',
  'thumbsdown': '👎',
  'dancer': '💃',
  'musical_note': '🎵',
  'no_mouth': '😶',
  'dizzy': '💫',
  'fist': '✊',
  'unamused': '😒',
  'cold_sweat': '😰',
  'gem': '💎',
  'pizza': '🍕',
  'joy_cat': '😹',
  'sun_with_face': '🌞',
  
  // Hearts
  'heart': '❤️',
  'two_hearts': '💕',
  'kiss': '💋',
  
  // Hand gestures
  'thumbsup': '👍',
  'thumbs_up': '👍',
  'thumbs_down': '👎',
  'ok_hand': '👌',
  'pray': '🙏',
  'raised_hands': '🙌',
  'clap': '👏',
  'point_right': '👉',
  'point_left': '👈',
  'point_up': '☝️',
  'point_down': '👇',
  'raised_hand': '✋',
  'wave': '👋',
  'v': '✌️',
  'oncoming_fist': '👊',
  'facepunch': '👊',
  'punch': '👊',
  
  // Objects & symbols
  'fire': '🔥',
  'tada': '🎉',
  'camera': '📷',
  'notes': '🎶',
  'sparkles': '✨',
  'star2': '🌟',
  'crown': '👑',
  'headphones': '🎧',
  'white_check_mark': '✅',
  'arrow_right': '➡️',
  'arrow_left': '⬅️',
  'arrow_forward': '▶️',
  'arrow_backward': '◀️',
  'arrow_right_hook': '↪️',
  'leftwards_arrow_with_hook': '↩️',
  'red_circle': '🔴',
  'boom': '💥',
  'collision': '💥',
  'copyright': '©️',
  'thought_balloon': '💭',
  'recycle': '♻️',
  
  // Nature
  'cherry_blossom': '🌸',
  'rose': '🌹',
  'scream': '😱',
  
  // Body parts
  'eyes': '👀',
  'tongue': '👅',
  
  // Misc
  'poop': '💩',
  'poo': '💩',
  'shit': '💩',
  'hankey': '💩',
  'innocent': '😇',
  'kissing_closed_eyes': '😚',
  'stuck_out_tongue': '😛',
  'disappointed_relieved': '😥',
  'confounded': '😖',
  'raising_hand': '🙋',
  'no_good': '🙅',
  'ok_woman': '🙆',
  'information_desk_person': '💁',
  'man_tipping_hand': '💁‍♂️',
  'woman_tipping_hand': '💁‍♀️',
  'man_gesturing_no': '🙅‍♂️',
  'woman_gesturing_no': '🙅‍♀️',
  'man_gesturing_ok': '🙆‍♂️',
  'woman_gesturing_ok': '🙆‍♀️',
  'man_raising_hand': '🙋‍♂️',
  'woman_raising_hand': '🙋‍♀️',
  
  // Common variations and aliases
  'slightly_smiling_face': '🙂',
  'upside_down_face': '🙃',
  'thinking_face': '🤔',
  'shrug': '🤷',
  'facepalm': '🤦',
  'man_shrugging': '🤷‍♂️',
  'woman_shrugging': '🤷‍♀️',
  'man_facepalming': '🤦‍♂️',
  'woman_facepalming': '🤦‍♀️',
  'hugging_face': '🤗',
  'money_mouth_face': '🤑',
  'nerd_face': '🤓',
  'face_with_rolling_eyes': '🙄',
  'zipper_mouth_face': '🤐',
  'nauseated_face': '🤢',
  'vomiting_face': '🤮',
  'sneezing_face': '🤧',
  'lying_face': '🤥',
  'drooling_face': '🤤',
  'sleeping_face': '😴',
};

/**
 * Convert emoji shortcodes (like :thumbsup: or :joy:) to Unicode emoji characters
 */
export function convertEmojiShortcodes(text: string): string {
  if (!text || typeof text !== 'string') {
    return text;
  }

  return text.replace(/:([a-zA-Z0-9_+-]+):/g, (match, shortcode) => {
    const emoji = emojiMap[shortcode.toLowerCase()];
    return emoji || match; // Return the emoji if found, otherwise return the original text
  });
}

/**
 * Check if a string contains emoji shortcodes
 */
export function hasEmojiShortcodes(text: string): boolean {
  if (!text || typeof text !== 'string') {
    return false;
  }
  
  return /:([a-zA-Z0-9_+-]+):/.test(text);
}

/**
 * Get available emoji shortcodes
 */
export function getAvailableEmojis(): string[] {
  return Object.keys(emojiMap).sort();
}

/**
 * Get emoji for a specific shortcode
 */
export function getEmoji(shortcode: string): string | null {
  return emojiMap[shortcode.toLowerCase()] || null;
} 