var path = require('path'),
    fs = require('fs'),
    apeman = require('apeman');

function imageThemes(basedir, subdir) {
    var dirname = apeman.current.lookup(path.join(basedir, subdir));
    if (!dirname) {
        return {}
    }
    return fs.readdirSync(dirname)
        .sort()
        .map(function (filename, i) {
            return {
                filename: path.join(subdir, filename),
                name: path.basename(filename, path.extname(filename)),
                index: i
            };
        });
}

Object.defineProperties(exports, {
    favicon: {
        configurable: true,
        get: function () {
            return imageThemes('clientside/src/img_themes', 'favicon').map(function (data) {
                data.name = data.name.replace('favicon-', '');
                return data;
            });
        }
    },
    startup: {
        configurable: true,
        get: function () {
            return imageThemes('clientside/src/img_themes', 'startup_image').map(function (data) {
                data.name = data.name.replace('startup-image-', '');
                data.width = Number(data.name.split('x').pop()) / 8;
                return data;
            });
        }
    }
});