"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.group = void 0;
var util_1 = require("@antv/util");
/** @ignore */
function group(data, fields, appendConditions) {
    if (appendConditions === void 0) { appendConditions = {}; }
    if (!fields) {
        return [data];
    }
    var groups = (0, util_1.groupToMap)(data, fields);
    var array = [];
    if (fields.length === 1 && appendConditions[fields[0]]) {
        var values = appendConditions[fields[0]];
        for (var _i = 0, values_1 = values; _i < values_1.length; _i++) {
            var value = values_1[_i];
            var arr = groups["_" + value];
            if (arr) {
                // 可能存在用户设置 values ，但是数据中没有对应的字段，则这时候 arr 就为 null
                array.push(arr);
            }
        }
    }
    else {
        for (var k in groups) {
            if (groups.hasOwnProperty(k)) {
                var eachGroup = groups[k];
                array.push(eachGroup);
            }
        }
    }
    return array;
}
exports.group = group;
//# sourceMappingURL=group-data.js.map