import { audioPath } from "./path.js";
const spriteClassBase = "pokesprite pokemon ";
let favorites = [
	{ className: "bulbasaur" },
	{ className: "ivysaur" },
	{ className: "venusaur" },
	{ className: "charmander" },
	{ className: "charmeleon" },
	{ className: "charizard" },
	{ className: "squirtle" },
	{ className: "wartortle" },
	{ className: "blastoise" },
	{ className: "beedrill" },
	{ className: "pikachu" },
	{ className: "raichu" },
	{ className: "sandslash" },
	{ className: "nidoran-f", title: "Female Nidoran" },
	{ className: "nidorina" },
	{ className: "nidoqueen" },
	{ className: "nidoran-m", title: "Male Nidoran" },
	{ className: "nidorino" },
	{ className: "nidoking" },
	{ className: "vulpix" },
	{ className: "ninetales" },
	{ className: "meowth" },
	{ className: "growlithe" },
	{ className: "arcanine" },
	{ className: "slowpoke" },
	{ className: "magnemite" },
	{ className: "magneton" },
	{ className: "dewgong" },
	{ className: "shellder" },
	{ className: "gastly" },
	{ className: "haunter" },
	{ className: "gengar" },
	{ className: "drowzee" },
	{ className: "cubone" },
	{ className: "rhydon" },
	{ className: "kangaskhan" },
	{ className: "lapras" },
	{ className: "eevee" },
	{ className: "vaporeon" },
	{ className: "jolteon" },
	{ className: "flareon" },
	{ className: "porygon" },
	{ className: "omanyte" },
	{ className: "dratini" },
	{ className: "dragonair" },
	{ className: "dragonite" },
	{ className: "mewtwo" },
	{ className: "mew" },
	{ className: "cyndaquil" },
	{ className: "quilava" },
	{ className: "typhlosion" },
	{ className: "totodile" },
	{ className: "croconaw" },
	{ className: "feraligatr" },
	{ className: "furret" },
	{ className: "ledian" },
	{ className: "spinarak" },
	{ className: "pichu" },
	{ className: "togepi" },
	{ className: "togetic" },
	{ className: "natu" },
	{ className: "xatu" },
	{ className: "mareep" },
	{ className: "flaaffy" },
	{ className: "ampharos" },
	{ className: "bellossom" },
	{ className: "marill" },
	{ className: "azumarill" },
	{ className: "hoppip" },
	{ className: "aipom" },
	{ className: "wooper" },
	{ className: "quagsire" },
	{ className: "espeon" },
	{ className: "umbreon" },
	{ className: "murkrow" },
	{ className: "misdreavus" },
	{ className: "girafarig" },
	{ className: "wobbuffet" },
	{ className: "dunsparce" },
	{ className: "scizor" },
	{ className: "shuckle" },
	{ className: "sneasel" },
	{ className: "teddiursa" },
	{ className: "slugma" },
	{ className: "corsola" },
	{ className: "delibird" },
	{ className: "skarmory" },
	{ className: "houndour" },
	{ className: "houndoom" },
	{ className: "phanpy" },
	{ className: "porygon2" },
	{ className: "smeargle" },
	{ className: "miltank" },
	{ className: "suicune" },
	{ className: "tyranitar" },
	{ className: "lugia" },
	{ className: "ho-oh" },
	{ className: "celebi" },
	{ className: "treecko" },
	{ className: "grovyle" },
	{ className: "sceptile" },
	{ className: "torchic" },
	{ className: "blaziken" },
	{ className: "mudkip" },
	{ className: "swampert" },
	{ className: "poochyena" },
	{ className: "mightyena" },
	{ className: "zigzagoon" },
	{ className: "wurmple" },
	{ className: "nuzleaf" },
	{ className: "ralts" },
	{ className: "kirlia" },
	{ className: "gardevoir" },
	{ className: "breloom" },
	{ className: "slakoth" },
	{ className: "azurill" },
	{ className: "skitty" },
	{ className: "delcatty" },
	{ className: "sableye" },
	{ className: "mawile" },
	{ className: "aron" },
	{ className: "aggron" },
	{ className: "plusle" },
	{ className: "minun" },
	{ className: "roselia" },
	{ className: "numel" },
	{ className: "spinda" },
	{ className: "trapinch" },
	{ className: "vibrava" },
	{ className: "flygon" },
	{ className: "altaria" },
	{ className: "zangoose" },
	{ className: "seviper" },
	{ className: "lunatone" },
	{ className: "solrock" },
	{ className: "milotic" },
	{ className: "kecleon" },
	{ className: "banette" },
	{ className: "absol" },
	{ className: "wynaut" },
	{ className: "spheal" },
	{ className: "salamence" },
	{ className: "latias" },
	{ className: "latios" },
	{ className: "rayquaza" },
	{ className: "jirachi" },
	{ className: "turtwig" },
	{ className: "torterra" },
	{ className: "piplup" },
	{ className: "shinx" },
	{ className: "luxio" },
	{ className: "luxray" },
	{ className: "roserade" },
	{ className: "buizel" },
	{ className: "floatzel" },
	{ className: "gastrodon" },
	{ className: "ambipom" },
	{ className: "buneary" },
	{ className: "lopunny" },
	{ className: "mismagius" },
	{ className: "honchkrow" },
	{ className: "glameow" },
	{ className: "purugly" },
	{ className: "garchomp" },
	{ className: "riolu" },
	{ className: "lucario" },
	{ className: "croagunk" },
	{ className: "weavile" },
	{ className: "togekiss" },
	{ className: "leafeon" },
	{ className: "glaceon" },
	{ className: "porygon-z", title: "Porygon-Z" },
	{ className: "gallade" },
	{ className: "froslass" },
	{ className: "uxie" },
	{ className: "mesprit" },
	{ className: "azelf" },
	{ className: "giratina" },
	{ className: "cresselia" },
	{ className: "manaphy" },
	{ className: "shaymin-land", title: "Land Forme Shaymin" },
	{ className: "shaymin-sky", title: "Sky Forme Shaymin" },
	{ className: "arceus" },
	{ className: "victini" },
	{ className: "snivy" },
	{ className: "servine" },
	{ className: "serperior" },
	{ className: "tepig" },
	{ className: "oshawott" },
	{ className: "dewott" },
	{ className: "samurott" },
	{ className: "purrloin" },
	{ className: "liepard" },
	{ className: "panpour" },
	{ className: "simipour" },
	{ className: "drilbur" },
	{ className: "excadrill" },
	{ className: "audino" },
	{ className: "sewaddle" },
	{ className: "swadloon" },
	{ className: "leavanny" },
	{ className: "scolipede" },
	{ className: "cottonee" },
	{ className: "whimsicott" },
	{ className: "petilil" },
	{ className: "lilligant" },
	{ className: "maractus" },
	{ className: "scraggy" },
	{ className: "scrafty" },
	{ className: "archen" },
	{ className: "archeops" },
	{ className: "zorua" },
	{ className: "zoroark" },
	{ className: "minccino" },
	{ className: "cinccino" },
	{ className: "solosis" },
	{ className: "duosion" },
	{ className: "reuniclus" },
	{ className: "ducklett" },
	{ className: "deerling" },
	{ className: "emolga" },
	{ className: "joltik" },
	{ className: "haxorus" },
	{ className: "shelmet" },
	{ className: "mienfoo" },
	{ className: "mienshao" },
	{ className: "deino" },
	{ className: "zweilous" },
	{ className: "volcarona" },
	{ className: "cobalion" },
	{ className: "virizion" },
	{ className: "reshiram" },
	{ className: "zekrom" },
	{ className: "keldeo" },
	{ className: "meloetta" },
	{ className: "venusaur-mega", title: "Mega Venusaur" },
	{ className: "charizard-mega-x", title: "Mega Charizard X" },
	{ className: "charizard-mega-y", title: "Mega Charizard Y" },
	{ className: "blastoise-mega", title: "Mega Blastoise" },
	{ className: "beedrill-mega", title: "Mega Beedrill" },
	{ className: "kangaskhan-mega", title: "Mega Kangaskhan" },
	{ className: "mewtwo-mega-x", title: "Mega Mewtwo X" },
	{ className: "mewtwo-mega-y", title: "Mega Mewtwo Y" },
	{ className: "ampharos-mega", title: "Mega Ampharos" },
	{ className: "scizor-mega", title: "Mega Scizor" },
	{ className: "houndoom-mega", title: "Mega Houndoom" },
	{ className: "tyranitar-mega", title: "Mega Tyranitar" },
	{ className: "sceptile-mega", title: "Mega Sceptile" },
	{ className: "blaziken-mega", title: "Mega Blaziken" },
	{ className: "swampert-mega", title: "Mega Swampert" },
	{ className: "gardevoir-mega", title: "Mega Gardevoir" },
	{ className: "sableye-mega", title: "Mega Sableye" },
	{ className: "aggron-mega", title: "Mega Aggron" },
	{ className: "altaria-mega", title: "Mega Altaria" },
	{ className: "banette-mega", title: "Mega Banette" },
	{ className: "absol-mega", title: "Mega Absol" },
	{ className: "salamence-mega", title: "Mega Salamence" },
	{ className: "lopunny-mega", title: "Mega Lopunny" },
	{ className: "garchomp-mega", title: "Mega Garchomp" },
	{ className: "lucario-mega", title: "Mega Lucario" },
	{ className: "gallade-mega", title: "Mega Gallade" },
	{ className: "audino-mega", title: "Mega Audino" },
	{ className: "chespin" },
	{ className: "quilladin" },
	{ className: "chesnaught" },
	{ className: "fennekin" },
	{ className: "braixen" },
	{ className: "delphox" },
	{ className: "froakie" },
	{ className: "frogadier" },
	{ className: "greninja" },
	{ className: "pancham" },
	{ className: "furfrou" },
	{ className: "espurr" },
	{ className: "meowstic" },
	{ className: "meowstic-female", title: "Female Meowstic" },
	{ className: "helioptile" },
	{ className: "heliolisk" },
	{ className: "aurorus" },
	{ className: "sylveon" },
	{ className: "hawlucha" },
	{ className: "goomy" },
	{ className: "sliggoo" },
	{ className: "goodra" },
	{ className: "phantump" },
	{ className: "noibat" },
	{ className: "noivern" },
	{ className: "xerneas" },
	{ className: "yveltal" },
	{ className: "rowlet" },
	{ className: "dartrix" },
	{ className: "decidueye" },
	{ className: "litten" },
	{ className: "torracat" },
	{ className: "popplio" },
	{ className: "brionne" },
	{ className: "primarina" },
	{ className: "pikipek" },
	{ className: "ribombee" },
	{ className: "rockruff" },
	{ className: "lycanroc" },
	{ className: "lycanroc-dusk", title: "Dusk Form Lycanroc" },
	{ className: "lycanroc-midnight", title: "Midnight Form Lycanroc" },
	{ className: "mareanie" },
	{ className: "toxapex" },
	{ className: "fomantis" },
	{ className: "lurantis" },
	{ className: "salandit" },
	{ className: "salazzle" },
	{ className: "stufful" },
	{ className: "bewear" },
	{ className: "steenee" },
	{ className: "tsareena" },
	{ className: "pyukumuku" },
	{ className: "komala" },
	{ className: "mimikyu" },
	{ className: "jangmo-o" },
	{ className: "kommo-o" },
	{ className: "tapu-lele" },
	{ className: "cosmog" },
	{ className: "solgaleo" },
	{ className: "lunala" },
	{ className: "celesteela" },
	{ className: "marshadow" },
	{ className: "poipole" },
	{ className: "zeraora" },
	{ className: "grookey" },
	{ className: "scorbunny" },
	{ className: "raboot" },
	{ className: "cinderace" },
	{ className: "sobble" },
	{ className: "drizzile" },
	{ className: "inteleon" },
	{ className: "corviknight" },
	{ className: "nickit" },
	{ className: "thievul" },
	{ className: "wooloo" },
	{ className: "yamper" },
	{ className: "hatterene" },
	{ className: "impidimp" },
	{ className: "obstagoon" },
	{ className: "alcremie" },
	{ className: "falinks" },
	{ className: "snom" },
	{ className: "indeedee" },
	{ className: "indeedee-female", title: "Female Indeedee" },
	{ className: "dragapult" },
];

function capitalizeFirstLetter(string) {
	return string.charAt(0).toUpperCase() + string.slice(1);
}

function getClassName(favorite) {
	return favorite.title ? favorite.title : favorite.className;
}

function getRandomUniquePkmn(pkmnArray, count) {
	const uniquePkmn = new Set();
	const totalPkmn = pkmnArray.length;
	while (uniquePkmn.size < count && uniquePkmn.size < totalPkmn) {
		const randomIndex = Math.floor(Math.random() * totalPkmn);
		uniquePkmn.add(pkmnArray[randomIndex]);
	}
	return Array.from(uniquePkmn).slice(0, count);
}

const party = getRandomUniquePkmn(favorites, 6);
const pkmnList = document.getElementById("pkmn");

party.forEach((pkmnData) => {
	const listItem = document.createElement("li");
	const critter = document.createElement("span");
	critter.className = `${spriteClassBase}${pkmnData.className}`;
	critter.title = capitalizeFirstLetter(getClassName(pkmnData));
	listItem.appendChild(critter);
	critter.addEventListener("mouseover", () => {
		const select = document.createElement("audio");
		select.src = `${audioPath}select.ogg`;
		select.play();
	});

	pkmnList.appendChild(listItem);
});
