/**
 * Create scheme colors.
 * @function task.worker._schemeColors
 * @param {number} hue
 * @param {string} scheme
 * @param {string} variation
 * @see {@link http://github.com/c0bra/color-scheme-js | color-scheme-js}
 * @protected
 * @ignore
 */
var lib = require('../../lib'),
    string = lib.string,
    capitalize = string.capitalize;
exports = module.exports = function (hue, scheme, variation) {
    var ColorScheme = require('color-scheme');
    var colors = [];
    new ColorScheme()
        .from_hue(Number(hue))
        .scheme(scheme)
        .variation(variation)
        .colors()
        .forEach(function (color) {
            var data = colors.pop() || [];
            if (data.length == 4) {
                colors.push(data);
                data = [];
            }
            data.push('#' + color);
            colors.push(data);
        });
    while (colors.length < exports._colorCount) {
        colors = [].concat(colors).concat(colors.reverse());
    }
    while (colors.length > exports._colorCount) {
        colors.pop()
    }
    return require('./_color_categories')
        .map(function (category, i) {
            return {
                Category: capitalize(category),
                category: category,
                color: colors[i][0],
                colorDark: colors[i][1],
                colorLight: colors[i][2],
                colorSoft: colors[i][3]
            }
        })
        .sort(function (a, b) {
            return a.category.localeCompare(b.category);
        });
};
exports._colorCount = 16;