package com.futbollibre.tv.util import androidx.annotation.DrawableRes import com.futbollibre.tv.R import java.text.Normalizer object LeagueArt { @DrawableRes fun logoResId(category: String?): Int { return when (resolveKey(category)) { LeagueKey.CHAMPIONS -> R.drawable.league_uefa_champions LeagueKey.LIBERTADORES -> R.drawable.league_copa_libertadores LeagueKey.LIGA_PROFESIONAL -> R.drawable.league_liga_profesional LeagueKey.CONCACAF -> R.drawable.league_concacaf_champions LeagueKey.BETPLAY -> R.drawable.league_liga_betplay LeagueKey.BRASILEIRAO -> R.drawable.league_brasileirao LeagueKey.COPA_ARGENTINA -> R.drawable.league_copa_argentina LeagueKey.DEFAULT -> R.drawable.ic_channel_default } } @DrawableRes fun backgroundResId(category: String?): Int { return when (resolveKey(category)) { LeagueKey.CHAMPIONS -> R.drawable.bg_league_champions LeagueKey.LIBERTADORES -> R.drawable.bg_league_libertadores LeagueKey.LIGA_PROFESIONAL -> R.drawable.bg_league_liga_profesional LeagueKey.CONCACAF -> R.drawable.bg_league_concacaf LeagueKey.BETPLAY -> R.drawable.bg_league_betplay LeagueKey.BRASILEIRAO -> R.drawable.bg_league_brasileirao LeagueKey.COPA_ARGENTINA -> R.drawable.bg_league_copa_argentina LeagueKey.DEFAULT -> R.drawable.bg_agenda_default } } private fun resolveKey(category: String?): LeagueKey { val normalized = normalize(category) return when { "champions league" in normalized -> LeagueKey.CHAMPIONS "copa libertadores" in normalized -> LeagueKey.LIBERTADORES "liga profesional" in normalized -> LeagueKey.LIGA_PROFESIONAL "concacaf champions" in normalized -> LeagueKey.CONCACAF "betplay" in normalized -> LeagueKey.BETPLAY "brasileirao" in normalized -> LeagueKey.BRASILEIRAO "copa argentina" in normalized -> LeagueKey.COPA_ARGENTINA else -> LeagueKey.DEFAULT } } private fun normalize(value: String?): String { if (value.isNullOrBlank()) { return "" } return Normalizer.normalize(value.lowercase(), Normalizer.Form.NFD) .replace(Regex("\\p{Mn}+"), "") } private enum class LeagueKey { CHAMPIONS, LIBERTADORES, LIGA_PROFESIONAL, CONCACAF, BETPLAY, BRASILEIRAO, COPA_ARGENTINA, DEFAULT } }