import { cond, identity, map, pipe, replace, splitEvery, T, toString, } from "ramda";
export const normalizeHex = pipe(toString, replace(/[^0-9a-f]/gi, ""), cond([
    [(str) => str.length < 6, (str) => str[0] + str[0] + str[1] + str[1] + str[2] + str[2]],
    [T, identity],
]));
export const colorLuminance = (hex, lum = 0) => {
    const hexNormalized = normalizeHex(hex);
    // convert to decimal and change luminosity
    const rgb = pipe(
    // point-free version generates ts error
    (str) => splitEvery(2, str), map(pipe((str) => parseInt(str, 16), (nr) => Math.round(Math.min(Math.max(0, nr + (nr * lum)), 255)).toString(16), (str) => `00${str}`.substr(str.length))), (x) => x.join(""))(hexNormalized);
    return `#${rgb}`;
};
//# sourceMappingURL=color-luminance.js.map