'use strict';

var hex = require('./hex.js');
var hsla = require('./hsla.js');
var rgba = require('./rgba.js');

const color = {
    test: (v) => rgba.rgba.test(v) || hex.hex.test(v) || hsla.hsla.test(v),
    parse: (v) => {
        if (rgba.rgba.test(v)) {
            return rgba.rgba.parse(v);
        }
        else if (hsla.hsla.test(v)) {
            return hsla.hsla.parse(v);
        }
        else {
            return hex.hex.parse(v);
        }
    },
    transform: (v) => {
        return typeof v === "string"
            ? v
            : v.hasOwnProperty("red")
                ? rgba.rgba.transform(v)
                : hsla.hsla.transform(v);
    },
    getAnimatableNone: (v) => {
        const parsed = color.parse(v);
        parsed.alpha = 0;
        return color.transform(parsed);
    },
};

exports.color = color;
