"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Variations = void 0; class Variations { constructor(vds) { this._indicies = []; this._lengths = []; this._items = 1; this._counter = 0; this._map = new Map(); this._variationDefinitions = vds; this._items = 1; vds.forEach(vd => { this._indicies.push(0); let length = -1; for (let it in vd) { if (length != -1 || !vd.hasOwnProperty(it)) { continue; } length = vd[it].length; } this._lengths.push(length); this._items *= length; }); console.log("Found items:", this._items); this._grabCurrentMap(); } _grabCurrentMap() { this._map.clear(); for (let i = 0; i < this._indicies.length; i++) { this._grabItems(i); } } get hasItems() { return this._counter <= this._items; } get items() { return this._items; } get counter() { return this._counter; } nextItem() { this._counter++; this._incrementCounter(0); this._grabCurrentMap(); // RJLog.log( this._counter, this._indicies, this.currentMap ); } _incrementCounter(position) { let value = this._indicies[position]; if (value == (this._lengths[position] - 1)) { this._indicies[position] = 0; this._incrementCounter(position + 1); } else { this._indicies[position]++; } } _grabItems(index) { let counter = this._indicies[index]; let vd = this._variationDefinitions[index]; let map = this._map; for (let it in vd) { if (!vd.hasOwnProperty(it)) { continue; } let key = it; let values = vd[it]; map.set(key, values[counter]); } } get currentMap() { return this._map; } } exports.Variations = Variations; //# sourceMappingURL=Variations.js.map