"use strict";
var regexp_util_1 = require("regexp-util");
function unicode(categories) {
    var keys = Object.keys(categories);
    if (keys.length === 0) {
        throw new Error("Expected at least one category, but received 0.");
    }
    if (keys.some(function (key) {
        var sub_categories = categories[key];
        return sub_categories === undefined || sub_categories.length === 0;
    })) {
        throw new Error("Expected at least one sub category, but received 0.");
    }
    var charsets = keys.map(function (key) {
        var sub_categories = categories[key];
        var sub_charsets = sub_categories.map(function (x) { return get_charset(key, x); });
        return (_a = new regexp_util_1.Charset()).union.apply(_a, sub_charsets);
        var _a;
    });
    return charsets.reduce(function (a, b) { return a.intersect(b); });
}
function get_charset(category, sub_category) {
    return (_a = new regexp_util_1.Charset()).union.apply(_a, require("./data.generated/" + category + "/" + sub_category));
    var _a;
}
module.exports = unicode;
