import { BaseAggregatorClass } from './baseAggregatorClass.js';
export class DistinctAggregator extends BaseAggregatorClass {
    constructor(field) {
        super(field);
        this._distinctValues = [];
        this._type = 'distinct';
    }
    init(_item, isTreeAggregator = false) {
        this._distinctValues = [];
        this._isInitialized = true;
        if (isTreeAggregator) {
            throw new Error('[Slickgrid-Universal] CloneAggregator is not currently supported for use with Tree Data');
        }
    }
    accumulate(item) {
        const val = item && item.hasOwnProperty(this._field) ? item[this._field] : undefined;
        if (this._distinctValues.indexOf(val) === -1 && val !== undefined) {
            this._distinctValues.push(val);
        }
    }
    storeResult(groupTotals) {
        if (!groupTotals || groupTotals[this._type] === undefined) {
            groupTotals[this._type] = {};
        }
        groupTotals[this._type][this._field] = this._distinctValues;
    }
}
//# sourceMappingURL=distinctAggregator.js.map