export type ArtworkTone = 'neutral' | 'accent' | 'secondary'

const hashSeed = (seed: string): number => {
  let hash = 0
  for (let index = 0; index < seed.length; index += 1) {
    hash = (hash << 5) - hash + seed.charCodeAt(index)
    hash |= 0
  }
  return Math.abs(hash)
}

const artworkTones: ArtworkTone[] = ['neutral', 'accent', 'secondary']

export const artworkTone = (seed: string): ArtworkTone =>
  artworkTones[hashSeed(seed) % artworkTones.length] ?? 'neutral'
