import {hsluvToHex as hsluv} from 'hsluv';

export interface LoveVariant {
  name: 'dark' | 'light';
  colors: {
    foreground1: string;
    foreground2: string;
    background1: string;
    background2: string;
    accents: string[];
    grays: string[];
  };
}

export function generateLove(): LoveVariant[] {
  // Create Love with its 2 variants.
  const love: LoveVariant[] = [
    {
      name: 'dark',
      colors: {
        foreground1: hsluv([275, 100, 95]).toUpperCase(),
        foreground2: hsluv([275, 100, 90]).toUpperCase(),
        background1: hsluv([275, 40, 10]).toUpperCase(),
        background2: hsluv([275, 40, 15]).toUpperCase(),
        accents: [],
        grays: []
      }
    },
    {
      name: 'light',
      colors: {
        foreground1: hsluv([275, 40, 10]).toUpperCase(),
        foreground2: hsluv([275, 40, 15]).toUpperCase(),
        background1: hsluv([275, 100, 95]).toUpperCase(),
        background2: hsluv([275, 100, 90]).toUpperCase(),
        accents: [],
        grays: []
      }
    }
  ];

  // Generate the accent and gray colors.
  const accentCount = 10;
  const grayCount = 3;
  for (let index = 0; index < accentCount; index++) {
    // Dark accents.
    love[0].colors.accents.push(
      hsluv([index * (360 / accentCount), 90, 75]).toUpperCase()
    );

    // Light accents.
    love[1].colors.accents.push(
      hsluv([index * (360 / accentCount), 90, 30]).toUpperCase()
    );

    if (index < grayCount) {
      // Dark grays.
      love[0].colors.grays.push(
        hsluv([0, 0, 100 - (index + 1) * 10]).toUpperCase()
      );

      // Light grays.
      love[1].colors.grays.push(hsluv([0, 0, (index + 1) * 10]).toUpperCase());
    }
  }

  return love;
}
