import decomposeColor from './decomposeColor';
import recomposeColor from './recomposeColor';
export default function hslToRgb(color) {
    const { type: decomposedColorType, values } = decomposeColor(color);
    const h = values[0];
    const s = values[1] / 100;
    const l = values[2] / 100;
    const a = s * Math.min(l, 1 - l);
    const f = (n, k = (n + h / 30) % 12) => l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
    let type = 'rgb';
    const rgb = [Math.round(f(0) * 255), Math.round(f(8) * 255), Math.round(f(4) * 255)];
    if (decomposedColorType === 'hsla') {
        type += 'a';
        rgb.push(values[3]);
    }
    return recomposeColor({ type, values: rgb });
}
