/**
 * Shortens a whisky category label by removing redundant common terms.
 * Example: "Single Malt Scotch Whisky" -> "Single Malt"
 */
export const shortenCategory = (label: string): string => {
    if (!label) return '';

    const replacements: [string, string][] = [
        ['Single Malt Scotch Whisky', 'Single Malt'],
        ['Blended Malt Scotch Whisky', 'Blended Malt'],
        ['Single Grain Scotch Whisky', 'Single Grain'],
        ['Blended Scotch Whisky', 'Blended'],
        ['Kentucky Straight Bourbon Whiskey', 'Bourbon'],
        ['Straight Bourbon Whiskey', 'Bourbon'],
        ['Tennessee Whiskey', 'Tennessee'],
        ['Japanese Whisky', 'Japanese'],
        ['Irish Whiskey', 'Irish'],
        ['Canadian Whisky', 'Canadian'],
        ['American Whiskey', 'American'],
        ['Rye Whiskey', 'Rye'],
    ];

    for (const [full, short] of replacements) {
        if (label === full) return short;
    }

    return label
        .replace(/ Scotch Whisky/gi, '')
        .replace(/ Scotch/gi, '')
        .replace(/ Whisky/gi, '')
        .replace(/ Whiskey/gi, '')
        .trim();
};
