const getSprite = (() => { const stripForm = ["flabebe", "floette", "florges", "vivillon", "basculin", "furfrou", "magearna"]; return pokemon => { pokemon = pokemon .replace("-alola", "-alolan") .replace("-galar", "-galarian") .replace("darmanitan-galarian", "darmanitan-galarian-standard"); if (stripForm.find(s => pokemon.includes(s))) { pokemon = pokemon.replace(/-.*$/, ""); } return `https://img.pokemondb.net/sprites/sword-shield/icon/${pokemon}.png`; } })(); const renderPokemonTileCluster = (area, totalSize, { mu, nu }, scores) => { const textColor = getContrastingTextColor(hex2rgb(mu.hex)); return String.raw`
${(100 * scores.size / totalSize).toFixed(2)}% ${mu.hex}
σ = ${scores.sigma.toFixed(2)}
δ = ${scores.delta.toFixed(2)}
M = ${scores.manhattan.toFixed(2)}
Ч = ${scores.ch.toFixed(2)}
Θ = ${scores.bigTheta.toFixed(2)}°
θ = ${scores.theta.toFixed(2)}°
ϕ = ${scores.phi.toFixed(2)}°
ℓ = ${scores.lightnessDiff.toFixed(2)}

μ = (${mu.vector[0].toFixed(2)},
${mu.vector[1].toFixed(2)},
${mu.vector[2].toFixed(2)})
I = ${scores.inertia.toFixed(2)}
ℒ = ${scores.lightness.toFixed(2)}
ν = (${nu[0].toFixed(2)},
${nu[1].toFixed(2)},
${nu[2].toFixed(2)})
V = ${scores.muNuAngle.toFixed(2)}°
N = ${scores.size}px
` }; const clusterToggles = {}; const renderPokemonTile = (kind, name, { total: { mu, nu, size }, clusters }, scores) => { const clusterToggleId = `${name}-${kind}-pkmn-expand-toggle`; const textColor = getContrastingTextColor(hex2rgb(mu.hex)); return String.raw`
${name.split("-").map(part => part.charAt(0).toUpperCase() + part.substr(1)).join(" ")}
${mu.hex}
σ = ${scores.total.sigma.toFixed(2)} δ = ${scores.total.delta.toFixed(2)} M = ${scores.total.manhattan.toFixed(2)} Ч = ${scores.total.ch.toFixed(2)}
Θ = ${scores.total.bigTheta.toFixed(2)}° θ = ${scores.total.theta.toFixed(2)}° ϕ = ${scores.total.phi.toFixed(2)}° ℓ = ${scores.total.lightnessDiff.toFixed(2)}

μ = (${mu.vector.map(c => c.toFixed(2)).join(", ")}) I = ${scores.total.inertia.toFixed(2)} ℒ = ${scores.total.lightness.toFixed(2)}
ν = (${nu.map(c => c.toFixed(2)).join(", ")}) V = ${scores.total.muNuAngle.toFixed(2)}° N = ${size}px
${clusters.map((c, i) => renderPokemonTileCluster(`cls${i+1}`, size, c, scores.clusters[i])).join("\n")}
` };