import MaterColor from 'matercolors';

import type { ColorPalette } from 'matercolors';

export const generatePalette = (color?: string) => {
	if (color) {
		try {
			const { palette } = new MaterColor(color);

			if (palette) {
				return {
					main: palette.primary['A400'],
					light: palette.primary[300],
					dark: palette.primary[700],
					...palette.primary,
				} as MaterialPalette;
			}
		} catch (error: unknown) {
			console.warn(error);
		}
	}

	return {} as MaterialPalette;
};

export interface MaterialPalette extends ColorPalette {
	main: string;
	light: string;
	dark: string;
}
