@getodk/xpath 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { c as commonjsGlobal, U as UpsertableMap, e as expressionParser, g as getAugmentedNamespace, a as getDefaultExportFromCjs } from './expressionParser-BbqMYp75.js';
1
+ import { c as commonjsGlobal, U as UpsertableMap, e as expressionParser, g as getAugmentedNamespace, a as getDefaultExportFromCjs } from './expressionParser-BRkDdCO9.js';
2
2
 
3
3
  function _mergeNamespaces(n, m) {
4
4
  for (var i = 0; i < m.length; i++) {
@@ -8044,6 +8044,33 @@ function requireSet () {
8044
8044
  if (hasRequiredSet) return set;
8045
8045
  hasRequiredSet = 1;
8046
8046
 
8047
+ var __awaiter = commonjsGlobal && commonjsGlobal.__awaiter || function (thisArg, _arguments, P, generator) {
8048
+ function adopt(value) {
8049
+ return value instanceof P ? value : new P(function (resolve) {
8050
+ resolve(value);
8051
+ });
8052
+ }
8053
+ return new (P || (P = Promise))(function (resolve, reject) {
8054
+ function fulfilled(value) {
8055
+ try {
8056
+ step(generator.next(value));
8057
+ } catch (e) {
8058
+ reject(e);
8059
+ }
8060
+ }
8061
+ function rejected(value) {
8062
+ try {
8063
+ step(generator["throw"](value));
8064
+ } catch (e) {
8065
+ reject(e);
8066
+ }
8067
+ }
8068
+ function step(result) {
8069
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
8070
+ }
8071
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8072
+ });
8073
+ };
8047
8074
  var __generator = commonjsGlobal && commonjsGlobal.__generator || function (thisArg, body) {
8048
8075
  var _ = {
8049
8076
  label: 0,
@@ -8259,7 +8286,7 @@ function requireSet () {
8259
8286
  Object.defineProperty(set, "__esModule", {
8260
8287
  value: true
8261
8288
  });
8262
- set.unionAsync = set.union = set.symmetricDifferenceAsync = set.symmetricDifference = set.partialIntersectionAsync = set.partialIntersection = set.intersectionAsync = set.intersection = set.distinctAsync = set.distinct = void 0;
8289
+ set.cartesianProductAsync = set.cartesianProduct = set.unionAsync = set.union = set.symmetricDifferenceAsync = set.symmetricDifference = set.partialIntersectionAsync = set.partialIntersection = set.intersectionAsync = set.intersection = set.distinctAsync = set.distinct = void 0;
8263
8290
  var transform_1 = requireTransform();
8264
8291
  var tools_1 = requireTools();
8265
8292
  var single_1 = requireSingle();
@@ -9074,6 +9101,241 @@ function requireSet () {
9074
9101
  });
9075
9102
  }
9076
9103
  set.unionAsync = unionAsync;
9104
+ /**
9105
+ * Iterates cartesian product of given iterables.
9106
+ *
9107
+ * @param iterables
9108
+ */
9109
+ function cartesianProduct() {
9110
+ var _i, _a, _b, item, e_17_1, arrays, toIterate, toIterate_1, toIterate_1_1, item, e_18_1;
9111
+ var e_17, _c, e_18, _d;
9112
+ var iterables = [];
9113
+ for (_i = 0; _i < arguments.length; _i++) {
9114
+ iterables[_i] = arguments[_i];
9115
+ }
9116
+ return __generator(this, function (_e) {
9117
+ switch (_e.label) {
9118
+ case 0:
9119
+ if (iterables.length === 0) {
9120
+ return [2 /*return*/];
9121
+ }
9122
+ if (!(iterables.length === 1)) return [3 /*break*/, 9];
9123
+ _e.label = 1;
9124
+ case 1:
9125
+ _e.trys.push([1, 6, 7, 8]);
9126
+ _a = __values((0, transform_1.toIterable)(iterables[0])), _b = _a.next();
9127
+ _e.label = 2;
9128
+ case 2:
9129
+ if (!!_b.done) return [3 /*break*/, 5];
9130
+ item = _b.value;
9131
+ return [4 /*yield*/, [item]];
9132
+ case 3:
9133
+ _e.sent();
9134
+ _e.label = 4;
9135
+ case 4:
9136
+ _b = _a.next();
9137
+ return [3 /*break*/, 2];
9138
+ case 5:
9139
+ return [3 /*break*/, 8];
9140
+ case 6:
9141
+ e_17_1 = _e.sent();
9142
+ e_17 = {
9143
+ error: e_17_1
9144
+ };
9145
+ return [3 /*break*/, 8];
9146
+ case 7:
9147
+ try {
9148
+ if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
9149
+ } finally {
9150
+ if (e_17) throw e_17.error;
9151
+ }
9152
+ return [7 /*endfinally*/];
9153
+ case 8:
9154
+ return [2 /*return*/];
9155
+ case 9:
9156
+ arrays = (0, transform_1.toArray)((0, single_1.map)(iterables, function (iterable) {
9157
+ return (0, transform_1.toArray)(iterable);
9158
+ }));
9159
+ toIterate = arrays.reduce(function (acc, set) {
9160
+ return acc.flatMap(function (x) {
9161
+ return set.map(function (y) {
9162
+ return __spreadArray(__spreadArray([], __read(x), false), [y], false);
9163
+ });
9164
+ });
9165
+ }, [[]]);
9166
+ _e.label = 10;
9167
+ case 10:
9168
+ _e.trys.push([10, 15, 16, 17]);
9169
+ toIterate_1 = __values(toIterate), toIterate_1_1 = toIterate_1.next();
9170
+ _e.label = 11;
9171
+ case 11:
9172
+ if (!!toIterate_1_1.done) return [3 /*break*/, 14];
9173
+ item = toIterate_1_1.value;
9174
+ return [4 /*yield*/, item];
9175
+ case 12:
9176
+ _e.sent();
9177
+ _e.label = 13;
9178
+ case 13:
9179
+ toIterate_1_1 = toIterate_1.next();
9180
+ return [3 /*break*/, 11];
9181
+ case 14:
9182
+ return [3 /*break*/, 17];
9183
+ case 15:
9184
+ e_18_1 = _e.sent();
9185
+ e_18 = {
9186
+ error: e_18_1
9187
+ };
9188
+ return [3 /*break*/, 17];
9189
+ case 16:
9190
+ try {
9191
+ if (toIterate_1_1 && !toIterate_1_1.done && (_d = toIterate_1.return)) _d.call(toIterate_1);
9192
+ } finally {
9193
+ if (e_18) throw e_18.error;
9194
+ }
9195
+ return [7 /*endfinally*/];
9196
+ case 17:
9197
+ return [2 /*return*/];
9198
+ }
9199
+ });
9200
+ }
9201
+ set.cartesianProduct = cartesianProduct;
9202
+ /**
9203
+ * Iterates cartesian product of given async iterables.
9204
+ *
9205
+ * @param iterables
9206
+ */
9207
+ function cartesianProductAsync() {
9208
+ var iterables = [];
9209
+ for (var _i = 0; _i < arguments.length; _i++) {
9210
+ iterables[_i] = arguments[_i];
9211
+ }
9212
+ return __asyncGenerator(this, arguments, function cartesianProductAsync_1() {
9213
+ var _a, _b, _c, item, e_19_1, arrays, toIterate, toIterate_2, toIterate_2_1, item, e_20_1;
9214
+ var e_20, _d;
9215
+ var _this = this;
9216
+ var _e, e_19, _f, _g;
9217
+ return __generator(this, function (_h) {
9218
+ switch (_h.label) {
9219
+ case 0:
9220
+ if (!(iterables.length === 0)) return [3 /*break*/, 2];
9221
+ return [4 /*yield*/, __await(void 0)];
9222
+ case 1:
9223
+ return [2 /*return*/, _h.sent()];
9224
+ case 2:
9225
+ if (!(iterables.length === 1)) return [3 /*break*/, 20];
9226
+ _h.label = 3;
9227
+ case 3:
9228
+ _h.trys.push([3, 12, 13, 18]);
9229
+ _a = true, _b = __asyncValues((0, transform_1.toAsyncIterable)(iterables[0]));
9230
+ _h.label = 4;
9231
+ case 4:
9232
+ return [4 /*yield*/, __await(_b.next())];
9233
+ case 5:
9234
+ if (!(_c = _h.sent(), _e = _c.done, !_e)) return [3 /*break*/, 11];
9235
+ _g = _c.value;
9236
+ _a = false;
9237
+ _h.label = 6;
9238
+ case 6:
9239
+ _h.trys.push([6,, 9, 10]);
9240
+ item = _g;
9241
+ return [4 /*yield*/, __await([item])];
9242
+ case 7:
9243
+ return [4 /*yield*/, _h.sent()];
9244
+ case 8:
9245
+ _h.sent();
9246
+ return [3 /*break*/, 10];
9247
+ case 9:
9248
+ _a = true;
9249
+ return [7 /*endfinally*/];
9250
+ case 10:
9251
+ return [3 /*break*/, 4];
9252
+ case 11:
9253
+ return [3 /*break*/, 18];
9254
+ case 12:
9255
+ e_19_1 = _h.sent();
9256
+ e_19 = {
9257
+ error: e_19_1
9258
+ };
9259
+ return [3 /*break*/, 18];
9260
+ case 13:
9261
+ _h.trys.push([13,, 16, 17]);
9262
+ if (!(!_a && !_e && (_f = _b.return))) return [3 /*break*/, 15];
9263
+ return [4 /*yield*/, __await(_f.call(_b))];
9264
+ case 14:
9265
+ _h.sent();
9266
+ _h.label = 15;
9267
+ case 15:
9268
+ return [3 /*break*/, 17];
9269
+ case 16:
9270
+ if (e_19) throw e_19.error;
9271
+ return [7 /*endfinally*/];
9272
+ case 17:
9273
+ return [7 /*endfinally*/];
9274
+ case 18:
9275
+ return [4 /*yield*/, __await(void 0)];
9276
+ case 19:
9277
+ return [2 /*return*/, _h.sent()];
9278
+ case 20:
9279
+ return [4 /*yield*/, __await((0, transform_1.toArrayAsync)((0, single_1.mapAsync)(iterables, function (iterable) {
9280
+ return __awaiter(_this, void 0, void 0, function () {
9281
+ return __generator(this, function (_a) {
9282
+ switch (_a.label) {
9283
+ case 0:
9284
+ return [4 /*yield*/, (0, transform_1.toArrayAsync)(iterable)];
9285
+ case 1:
9286
+ return [2 /*return*/, _a.sent()];
9287
+ }
9288
+ });
9289
+ });
9290
+ })))];
9291
+ case 21:
9292
+ arrays = _h.sent();
9293
+ toIterate = arrays.reduce(function (acc, set) {
9294
+ return acc.flatMap(function (x) {
9295
+ return set.map(function (y) {
9296
+ return __spreadArray(__spreadArray([], __read(x), false), [y], false);
9297
+ });
9298
+ });
9299
+ }, [[]]);
9300
+ _h.label = 22;
9301
+ case 22:
9302
+ _h.trys.push([22, 28, 29, 30]);
9303
+ toIterate_2 = __values(toIterate), toIterate_2_1 = toIterate_2.next();
9304
+ _h.label = 23;
9305
+ case 23:
9306
+ if (!!toIterate_2_1.done) return [3 /*break*/, 27];
9307
+ item = toIterate_2_1.value;
9308
+ return [4 /*yield*/, __await(item)];
9309
+ case 24:
9310
+ return [4 /*yield*/, _h.sent()];
9311
+ case 25:
9312
+ _h.sent();
9313
+ _h.label = 26;
9314
+ case 26:
9315
+ toIterate_2_1 = toIterate_2.next();
9316
+ return [3 /*break*/, 23];
9317
+ case 27:
9318
+ return [3 /*break*/, 30];
9319
+ case 28:
9320
+ e_20_1 = _h.sent();
9321
+ e_20 = {
9322
+ error: e_20_1
9323
+ };
9324
+ return [3 /*break*/, 30];
9325
+ case 29:
9326
+ try {
9327
+ if (toIterate_2_1 && !toIterate_2_1.done && (_d = toIterate_2.return)) _d.call(toIterate_2);
9328
+ } finally {
9329
+ if (e_20) throw e_20.error;
9330
+ }
9331
+ return [7 /*endfinally*/];
9332
+ case 30:
9333
+ return [2 /*return*/];
9334
+ }
9335
+ });
9336
+ });
9337
+ }
9338
+ set.cartesianProductAsync = cartesianProductAsync;
9077
9339
  return set;
9078
9340
  }
9079
9341
 
@@ -12117,6 +12379,415 @@ function requireSingle () {
12117
12379
  return single;
12118
12380
  }
12119
12381
 
12382
+ var infinite = {};
12383
+
12384
+ var hasRequiredInfinite;
12385
+
12386
+ function requireInfinite () {
12387
+ if (hasRequiredInfinite) return infinite;
12388
+ hasRequiredInfinite = 1;
12389
+
12390
+ var __generator = commonjsGlobal && commonjsGlobal.__generator || function (thisArg, body) {
12391
+ var _ = {
12392
+ label: 0,
12393
+ sent: function () {
12394
+ if (t[0] & 1) throw t[1];
12395
+ return t[1];
12396
+ },
12397
+ trys: [],
12398
+ ops: []
12399
+ },
12400
+ f,
12401
+ y,
12402
+ t,
12403
+ g;
12404
+ return g = {
12405
+ next: verb(0),
12406
+ "throw": verb(1),
12407
+ "return": verb(2)
12408
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
12409
+ return this;
12410
+ }), g;
12411
+ function verb(n) {
12412
+ return function (v) {
12413
+ return step([n, v]);
12414
+ };
12415
+ }
12416
+ function step(op) {
12417
+ if (f) throw new TypeError("Generator is already executing.");
12418
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
12419
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
12420
+ if (y = 0, t) op = [op[0] & 2, t.value];
12421
+ switch (op[0]) {
12422
+ case 0:
12423
+ case 1:
12424
+ t = op;
12425
+ break;
12426
+ case 4:
12427
+ _.label++;
12428
+ return {
12429
+ value: op[1],
12430
+ done: false
12431
+ };
12432
+ case 5:
12433
+ _.label++;
12434
+ y = op[1];
12435
+ op = [0];
12436
+ continue;
12437
+ case 7:
12438
+ op = _.ops.pop();
12439
+ _.trys.pop();
12440
+ continue;
12441
+ default:
12442
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
12443
+ _ = 0;
12444
+ continue;
12445
+ }
12446
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
12447
+ _.label = op[1];
12448
+ break;
12449
+ }
12450
+ if (op[0] === 6 && _.label < t[1]) {
12451
+ _.label = t[1];
12452
+ t = op;
12453
+ break;
12454
+ }
12455
+ if (t && _.label < t[2]) {
12456
+ _.label = t[2];
12457
+ _.ops.push(op);
12458
+ break;
12459
+ }
12460
+ if (t[2]) _.ops.pop();
12461
+ _.trys.pop();
12462
+ continue;
12463
+ }
12464
+ op = body.call(thisArg, _);
12465
+ } catch (e) {
12466
+ op = [6, e];
12467
+ y = 0;
12468
+ } finally {
12469
+ f = t = 0;
12470
+ }
12471
+ if (op[0] & 5) throw op[1];
12472
+ return {
12473
+ value: op[0] ? op[1] : void 0,
12474
+ done: true
12475
+ };
12476
+ }
12477
+ };
12478
+ var __asyncValues = commonjsGlobal && commonjsGlobal.__asyncValues || function (o) {
12479
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
12480
+ var m = o[Symbol.asyncIterator],
12481
+ i;
12482
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () {
12483
+ return this;
12484
+ }, i);
12485
+ function verb(n) {
12486
+ i[n] = o[n] && function (v) {
12487
+ return new Promise(function (resolve, reject) {
12488
+ v = o[n](v), settle(resolve, reject, v.done, v.value);
12489
+ });
12490
+ };
12491
+ }
12492
+ function settle(resolve, reject, d, v) {
12493
+ Promise.resolve(v).then(function (v) {
12494
+ resolve({
12495
+ value: v,
12496
+ done: d
12497
+ });
12498
+ }, reject);
12499
+ }
12500
+ };
12501
+ var __await = commonjsGlobal && commonjsGlobal.__await || function (v) {
12502
+ return this instanceof __await ? (this.v = v, this) : new __await(v);
12503
+ };
12504
+ var __asyncDelegator = commonjsGlobal && commonjsGlobal.__asyncDelegator || function (o) {
12505
+ var i, p;
12506
+ return i = {}, verb("next"), verb("throw", function (e) {
12507
+ throw e;
12508
+ }), verb("return"), i[Symbol.iterator] = function () {
12509
+ return this;
12510
+ }, i;
12511
+ function verb(n, f) {
12512
+ i[n] = o[n] ? function (v) {
12513
+ return (p = !p) ? {
12514
+ value: __await(o[n](v)),
12515
+ done: n === "return"
12516
+ } : f ? f(v) : v;
12517
+ } : f;
12518
+ }
12519
+ };
12520
+ var __asyncGenerator = commonjsGlobal && commonjsGlobal.__asyncGenerator || function (thisArg, _arguments, generator) {
12521
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
12522
+ var g = generator.apply(thisArg, _arguments || []),
12523
+ i,
12524
+ q = [];
12525
+ return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () {
12526
+ return this;
12527
+ }, i;
12528
+ function verb(n) {
12529
+ if (g[n]) i[n] = function (v) {
12530
+ return new Promise(function (a, b) {
12531
+ q.push([n, v, a, b]) > 1 || resume(n, v);
12532
+ });
12533
+ };
12534
+ }
12535
+ function resume(n, v) {
12536
+ try {
12537
+ step(g[n](v));
12538
+ } catch (e) {
12539
+ settle(q[0][3], e);
12540
+ }
12541
+ }
12542
+ function step(r) {
12543
+ r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
12544
+ }
12545
+ function fulfill(value) {
12546
+ resume("next", value);
12547
+ }
12548
+ function reject(value) {
12549
+ resume("throw", value);
12550
+ }
12551
+ function settle(f, v) {
12552
+ if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]);
12553
+ }
12554
+ };
12555
+ var __read = commonjsGlobal && commonjsGlobal.__read || function (o, n) {
12556
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
12557
+ if (!m) return o;
12558
+ var i = m.call(o),
12559
+ r,
12560
+ ar = [],
12561
+ e;
12562
+ try {
12563
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
12564
+ } catch (error) {
12565
+ e = {
12566
+ error: error
12567
+ };
12568
+ } finally {
12569
+ try {
12570
+ if (r && !r.done && (m = i["return"])) m.call(i);
12571
+ } finally {
12572
+ if (e) throw e.error;
12573
+ }
12574
+ }
12575
+ return ar;
12576
+ };
12577
+ var __spreadArray = commonjsGlobal && commonjsGlobal.__spreadArray || function (to, from, pack) {
12578
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
12579
+ if (ar || !(i in from)) {
12580
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
12581
+ ar[i] = from[i];
12582
+ }
12583
+ }
12584
+ return to.concat(ar || Array.prototype.slice.call(from));
12585
+ };
12586
+ var __values = commonjsGlobal && commonjsGlobal.__values || function (o) {
12587
+ var s = typeof Symbol === "function" && Symbol.iterator,
12588
+ m = s && o[s],
12589
+ i = 0;
12590
+ if (m) return m.call(o);
12591
+ if (o && typeof o.length === "number") return {
12592
+ next: function () {
12593
+ if (o && i >= o.length) o = void 0;
12594
+ return {
12595
+ value: o && o[i++],
12596
+ done: !o
12597
+ };
12598
+ }
12599
+ };
12600
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12601
+ };
12602
+ Object.defineProperty(infinite, "__esModule", {
12603
+ value: true
12604
+ });
12605
+ infinite.repeat = infinite.cycleAsync = infinite.cycle = infinite.count = void 0;
12606
+ var transform_1 = requireTransform();
12607
+ /**
12608
+ * Count sequentially forever
12609
+ *
12610
+ * @param start (optional, default 1)
12611
+ * @param step (optional, default 1)
12612
+ */
12613
+ function count(start, step) {
12614
+ var i;
12615
+ if (start === void 0) {
12616
+ start = 1;
12617
+ }
12618
+ if (step === void 0) {
12619
+ step = 1;
12620
+ }
12621
+ return __generator(this, function (_a) {
12622
+ switch (_a.label) {
12623
+ case 0:
12624
+ i = start;
12625
+ _a.label = 1;
12626
+ case 1:
12627
+ return [4 /*yield*/, i];
12628
+ case 2:
12629
+ _a.sent();
12630
+ _a.label = 3;
12631
+ case 3:
12632
+ i += step;
12633
+ return [3 /*break*/, 1];
12634
+ case 4:
12635
+ return [2 /*return*/];
12636
+ }
12637
+ });
12638
+ }
12639
+ infinite.count = count;
12640
+ /**
12641
+ * Cycle through the elements of a collection sequentially forever
12642
+ *
12643
+ * @param iterable
12644
+ */
12645
+ function cycle(iterable) {
12646
+ var data, data_1, data_1_1, datum, e_1_1;
12647
+ var e_1, _a;
12648
+ return __generator(this, function (_b) {
12649
+ switch (_b.label) {
12650
+ case 0:
12651
+ data = __spreadArray([], __read((0, transform_1.toIterable)(iterable)), false);
12652
+ if (data.length === 0) {
12653
+ return [2 /*return*/];
12654
+ }
12655
+ _b.label = 1;
12656
+ case 1:
12657
+ _b.label = 2;
12658
+ case 2:
12659
+ _b.trys.push([2, 7, 8, 9]);
12660
+ data_1 = (e_1 = void 0, __values(data)), data_1_1 = data_1.next();
12661
+ _b.label = 3;
12662
+ case 3:
12663
+ if (!!data_1_1.done) return [3 /*break*/, 6];
12664
+ datum = data_1_1.value;
12665
+ return [4 /*yield*/, datum];
12666
+ case 4:
12667
+ _b.sent();
12668
+ _b.label = 5;
12669
+ case 5:
12670
+ data_1_1 = data_1.next();
12671
+ return [3 /*break*/, 3];
12672
+ case 6:
12673
+ return [3 /*break*/, 9];
12674
+ case 7:
12675
+ e_1_1 = _b.sent();
12676
+ e_1 = {
12677
+ error: e_1_1
12678
+ };
12679
+ return [3 /*break*/, 9];
12680
+ case 8:
12681
+ try {
12682
+ if (data_1_1 && !data_1_1.done && (_a = data_1.return)) _a.call(data_1);
12683
+ } finally {
12684
+ if (e_1) throw e_1.error;
12685
+ }
12686
+ return [7 /*endfinally*/];
12687
+ case 9:
12688
+ return [3 /*break*/, 1];
12689
+ case 10:
12690
+ return [2 /*return*/];
12691
+ }
12692
+ });
12693
+ }
12694
+ infinite.cycle = cycle;
12695
+ /**
12696
+ * Cycle through the elements of a async iterable sequentially forever
12697
+ *
12698
+ * @param iterable
12699
+ */
12700
+ function cycleAsync(iterable) {
12701
+ return __asyncGenerator(this, arguments, function cycleAsync_1() {
12702
+ var data, _a, _b, _c, datum, e_2_1;
12703
+ var _d, e_2, _e, _f;
12704
+ return __generator(this, function (_g) {
12705
+ switch (_g.label) {
12706
+ case 0:
12707
+ data = [];
12708
+ _g.label = 1;
12709
+ case 1:
12710
+ _g.trys.push([1, 10, 11, 16]);
12711
+ _a = true, _b = __asyncValues((0, transform_1.toAsyncIterable)(iterable));
12712
+ _g.label = 2;
12713
+ case 2:
12714
+ return [4 /*yield*/, __await(_b.next())];
12715
+ case 3:
12716
+ if (!(_c = _g.sent(), _d = _c.done, !_d)) return [3 /*break*/, 9];
12717
+ _f = _c.value;
12718
+ _a = false;
12719
+ _g.label = 4;
12720
+ case 4:
12721
+ _g.trys.push([4,, 7, 8]);
12722
+ datum = _f;
12723
+ data.push(datum);
12724
+ return [4 /*yield*/, __await(datum)];
12725
+ case 5:
12726
+ return [4 /*yield*/, _g.sent()];
12727
+ case 6:
12728
+ _g.sent();
12729
+ return [3 /*break*/, 8];
12730
+ case 7:
12731
+ _a = true;
12732
+ return [7 /*endfinally*/];
12733
+ case 8:
12734
+ return [3 /*break*/, 2];
12735
+ case 9:
12736
+ return [3 /*break*/, 16];
12737
+ case 10:
12738
+ e_2_1 = _g.sent();
12739
+ e_2 = {
12740
+ error: e_2_1
12741
+ };
12742
+ return [3 /*break*/, 16];
12743
+ case 11:
12744
+ _g.trys.push([11,, 14, 15]);
12745
+ if (!(!_a && !_d && (_e = _b.return))) return [3 /*break*/, 13];
12746
+ return [4 /*yield*/, __await(_e.call(_b))];
12747
+ case 12:
12748
+ _g.sent();
12749
+ _g.label = 13;
12750
+ case 13:
12751
+ return [3 /*break*/, 15];
12752
+ case 14:
12753
+ if (e_2) throw e_2.error;
12754
+ return [7 /*endfinally*/];
12755
+ case 15:
12756
+ return [7 /*endfinally*/];
12757
+ case 16:
12758
+ return [5 /*yield**/, __values(__asyncDelegator(__asyncValues(cycle(data))))];
12759
+ case 17:
12760
+ return [4 /*yield*/, __await.apply(void 0, [_g.sent()])];
12761
+ case 18:
12762
+ _g.sent();
12763
+ return [2 /*return*/];
12764
+ }
12765
+ });
12766
+ });
12767
+ }
12768
+ infinite.cycleAsync = cycleAsync;
12769
+ /**
12770
+ * Repeat an item forever
12771
+ *
12772
+ * @param item
12773
+ */
12774
+ function repeat(item) {
12775
+ return __generator(this, function (_a) {
12776
+ switch (_a.label) {
12777
+ case 0:
12778
+ return [4 /*yield*/, item];
12779
+ case 1:
12780
+ _a.sent();
12781
+ return [3 /*break*/, 0];
12782
+ case 2:
12783
+ return [2 /*return*/];
12784
+ }
12785
+ });
12786
+ }
12787
+ infinite.repeat = repeat;
12788
+ return infinite;
12789
+ }
12790
+
12120
12791
  var math = {};
12121
12792
 
12122
12793
  var hasRequiredMath;
@@ -13275,11 +13946,12 @@ function requireReduce () {
13275
13946
  Object.defineProperty(reduce$1, "__esModule", {
13276
13947
  value: true
13277
13948
  });
13278
- reduce$1.toFirstAndLastAsync = reduce$1.toFirstAndLast = reduce$1.toLastAsync = reduce$1.toLast = reduce$1.toFirstAsync = reduce$1.toFirst = reduce$1.toCountAsync = reduce$1.toCount = reduce$1.toProductAsync = reduce$1.toProduct = reduce$1.toSumAsync = reduce$1.toSum = reduce$1.toMinMaxAsync = reduce$1.toMinMax = reduce$1.toMinAsync = reduce$1.toMin = reduce$1.toMaxAsync = reduce$1.toMax = reduce$1.toAverageAsync = reduce$1.toAverage = reduce$1.toValueAsync = reduce$1.toValue = void 0;
13949
+ reduce$1.toFirstAndLastAsync = reduce$1.toFirstAndLast = reduce$1.toLastAsync = reduce$1.toLast = reduce$1.toFirstAsync = reduce$1.toFirst = reduce$1.toCountAsync = reduce$1.toCount = reduce$1.toProductAsync = reduce$1.toProduct = reduce$1.toSumAsync = reduce$1.toSum = reduce$1.toRangeAsync = reduce$1.toRange = reduce$1.toMinMaxAsync = reduce$1.toMinMax = reduce$1.toMinAsync = reduce$1.toMin = reduce$1.toMaxAsync = reduce$1.toMax = reduce$1.toAverageAsync = reduce$1.toAverage = reduce$1.toValueAsync = reduce$1.toValue = void 0;
13279
13950
  var transform_1 = requireTransform();
13280
13951
  var exceptions_1 = exceptions;
13281
13952
  var summary_1 = requireSummary();
13282
13953
  var tools_1 = requireTools();
13954
+ var single_1 = requireSingle();
13283
13955
  /**
13284
13956
  * Reduces iterable source like `array.reduce()` function.
13285
13957
  *
@@ -13645,6 +14317,46 @@ function requireReduce () {
13645
14317
  });
13646
14318
  }
13647
14319
  reduce$1.toMinMaxAsync = toMinMaxAsync;
14320
+ /**
14321
+ * Reduces given collection to its range.
14322
+ *
14323
+ * Returns 0 if given collection is empty.
14324
+ *
14325
+ * @param numbers
14326
+ */
14327
+ function toRange(numbers) {
14328
+ var _a = __read(toMinMax((0, single_1.map)(numbers, function (n) {
14329
+ return Number(n);
14330
+ })), 2),
14331
+ min = _a[0],
14332
+ max = _a[1];
14333
+ return (max !== null && max !== void 0 ? max : 0) - (min !== null && min !== void 0 ? min : 0);
14334
+ }
14335
+ reduce$1.toRange = toRange;
14336
+ /**
14337
+ * Reduces given async collection to its range.
14338
+ *
14339
+ * Returns 0 if given async collection is empty.
14340
+ *
14341
+ * @param numbers
14342
+ */
14343
+ function toRangeAsync(numbers) {
14344
+ return __awaiter(this, void 0, void 0, function () {
14345
+ var _a, min, max;
14346
+ return __generator(this, function (_b) {
14347
+ switch (_b.label) {
14348
+ case 0:
14349
+ return [4 /*yield*/, toMinMaxAsync((0, single_1.mapAsync)(numbers, function (n) {
14350
+ return Number(n);
14351
+ }))];
14352
+ case 1:
14353
+ _a = __read.apply(void 0, [_b.sent(), 2]), min = _a[0], max = _a[1];
14354
+ return [2 /*return*/, (max !== null && max !== void 0 ? max : 0) - (min !== null && min !== void 0 ? min : 0)];
14355
+ }
14356
+ });
14357
+ });
14358
+ }
14359
+ reduce$1.toRangeAsync = toRangeAsync;
13648
14360
  /**
13649
14361
  * Reduces given collection to the sum of its items.
13650
14362
  *
@@ -14214,6 +14926,7 @@ function requireStream () {
14214
14926
  var set_1 = requireSet();
14215
14927
  var reduce_1 = requireReduce();
14216
14928
  var summary_1 = requireSummary();
14929
+ var index_1 = requireLib();
14217
14930
  /**
14218
14931
  * Provides fluent interface for working with iterables.
14219
14932
  */
@@ -14240,6 +14953,43 @@ function requireStream () {
14240
14953
  Stream.ofEmpty = function () {
14241
14954
  return new Stream([]);
14242
14955
  };
14956
+ /**
14957
+ * Creates iterable instance with fluent interface from infinite count iterable.
14958
+ *
14959
+ * @param start (optional, default 1)
14960
+ * @param step (optional, default 1)
14961
+ *
14962
+ * @see infinite.count
14963
+ */
14964
+ Stream.ofCount = function (start, step) {
14965
+ if (start === void 0) {
14966
+ start = 1;
14967
+ }
14968
+ if (step === void 0) {
14969
+ step = 1;
14970
+ }
14971
+ return new Stream(index_1.infinite.count(start, step));
14972
+ };
14973
+ /**
14974
+ * Creates iterable instance with fluent interface from infinite collection items repeating.
14975
+ *
14976
+ * @param iterable
14977
+ *
14978
+ * @see infinite.cycle
14979
+ */
14980
+ Stream.ofCycle = function (iterable) {
14981
+ return new Stream(index_1.infinite.cycle(iterable));
14982
+ };
14983
+ /**
14984
+ * Creates iterable instance with fluent interface from infinite item repeating.
14985
+ *
14986
+ * @param item
14987
+ *
14988
+ * @see infinite.repeat
14989
+ */
14990
+ Stream.ofRepeat = function (item) {
14991
+ return new Stream(index_1.infinite.repeat(item));
14992
+ };
14243
14993
  /**
14244
14994
  * Iterate stream collection with another iterable collections simultaneously.
14245
14995
  *
@@ -14718,6 +15468,21 @@ function requireStream () {
14718
15468
  this.data = set_1.union.apply(void 0, __spreadArray([this.data], __read(iterables), false));
14719
15469
  return this;
14720
15470
  };
15471
+ /**
15472
+ * Iterates cartesian product of iterable source and given iterables.
15473
+ *
15474
+ * @param iterables
15475
+ *
15476
+ * @see set.cartesianProduct
15477
+ */
15478
+ Stream.prototype.cartesianProductWith = function () {
15479
+ var iterables = [];
15480
+ for (var _i = 0; _i < arguments.length; _i++) {
15481
+ iterables[_i] = arguments[_i];
15482
+ }
15483
+ this.data = set_1.cartesianProduct.apply(void 0, __spreadArray([this.data], __read(iterables), false));
15484
+ return this;
15485
+ };
14721
15486
  /**
14722
15487
  * Peek at each element between other Stream operations to do some action without modifying the stream.
14723
15488
  *
@@ -14887,6 +15652,16 @@ function requireStream () {
14887
15652
  Stream.prototype.toProduct = function () {
14888
15653
  return (0, reduce_1.toProduct)(this);
14889
15654
  };
15655
+ /**
15656
+ * Reduces given collection to its range.
15657
+ *
15658
+ * Returns 0 if given collection is empty.
15659
+ *
15660
+ * @see reduce.toRange
15661
+ */
15662
+ Stream.prototype.toRange = function () {
15663
+ return (0, reduce_1.toRange)(this);
15664
+ };
14890
15665
  /**
14891
15666
  * Returns true if all elements of stream match the predicate function.
14892
15667
  *
@@ -15323,6 +16098,7 @@ function requireAsyncStream () {
15323
16098
  var set_1 = requireSet();
15324
16099
  var reduce_1 = requireReduce();
15325
16100
  var summary_1 = requireSummary();
16101
+ var index_1 = requireLib();
15326
16102
  /**
15327
16103
  * Provides fluent interface for working with async iterables.
15328
16104
  */
@@ -15349,6 +16125,37 @@ function requireAsyncStream () {
15349
16125
  AsyncStream.ofEmpty = function () {
15350
16126
  return new AsyncStream((0, transform_1.toAsyncIterable)([]));
15351
16127
  };
16128
+ /**
16129
+ * Creates iterable instance with fluent interface from infinite count iterable.
16130
+ *
16131
+ * @param start (optional, default 1)
16132
+ * @param step (optional, default 1)
16133
+ */
16134
+ AsyncStream.ofCount = function (start, step) {
16135
+ if (start === void 0) {
16136
+ start = 1;
16137
+ }
16138
+ if (step === void 0) {
16139
+ step = 1;
16140
+ }
16141
+ return new AsyncStream((0, transform_1.toAsyncIterable)(index_1.infinite.count(start, step)));
16142
+ };
16143
+ /**
16144
+ * Creates iterable instance with fluent interface from infinite collection items repeating.
16145
+ *
16146
+ * @param iterable
16147
+ */
16148
+ AsyncStream.ofCycle = function (iterable) {
16149
+ return new AsyncStream(index_1.infinite.cycleAsync(iterable));
16150
+ };
16151
+ /**
16152
+ * Creates iterable instance with fluent interface from infinite item repeating.
16153
+ *
16154
+ * @param item
16155
+ */
16156
+ AsyncStream.ofRepeat = function (item) {
16157
+ return new AsyncStream((0, transform_1.toAsyncIterable)(index_1.infinite.repeat(item)));
16158
+ };
15352
16159
  /**
15353
16160
  * Iterate stream collection with another iterable collections simultaneously.
15354
16161
  *
@@ -15827,6 +16634,21 @@ function requireAsyncStream () {
15827
16634
  this.data = set_1.unionAsync.apply(void 0, __spreadArray([this.data], __read(iterables), false));
15828
16635
  return this;
15829
16636
  };
16637
+ /**
16638
+ * Iterates cartesian product of iterable source and given iterables.
16639
+ *
16640
+ * @param iterables
16641
+ *
16642
+ * @see set.cartesianProductAsync
16643
+ */
16644
+ AsyncStream.prototype.cartesianProductWith = function () {
16645
+ var iterables = [];
16646
+ for (var _i = 0; _i < arguments.length; _i++) {
16647
+ iterables[_i] = arguments[_i];
16648
+ }
16649
+ this.data = set_1.cartesianProductAsync.apply(void 0, __spreadArray([this.data], __read(iterables), false));
16650
+ return this;
16651
+ };
15830
16652
  /**
15831
16653
  * Peek at each element between other Stream operations to do some action without modifying the stream.
15832
16654
  *
@@ -16134,6 +16956,25 @@ function requireAsyncStream () {
16134
16956
  });
16135
16957
  });
16136
16958
  };
16959
+ /**
16960
+ * Reduces given collection to its range.
16961
+ *
16962
+ * Returns 0 if given collection is empty.
16963
+ *
16964
+ * @see reduce.toRangeAsync
16965
+ */
16966
+ AsyncStream.prototype.toRange = function () {
16967
+ return __awaiter(this, void 0, void 0, function () {
16968
+ return __generator(this, function (_a) {
16969
+ switch (_a.label) {
16970
+ case 0:
16971
+ return [4 /*yield*/, (0, reduce_1.toRangeAsync)(this)];
16972
+ case 1:
16973
+ return [2 /*return*/, _a.sent()];
16974
+ }
16975
+ });
16976
+ });
16977
+ };
16137
16978
  /**
16138
16979
  * Returns true if all elements of stream match the predicate function.
16139
16980
  *
@@ -16207,7 +17048,7 @@ function requireAsyncStream () {
16207
17048
  *
16208
17049
  * @see summary.exactlyNAsync
16209
17050
  */
16210
- AsyncStream.prototype.exactlyNAsync = function (n, predicate) {
17051
+ AsyncStream.prototype.exactlyN = function (n, predicate) {
16211
17052
  return __awaiter(this, void 0, void 0, function () {
16212
17053
  return __generator(this, function (_a) {
16213
17054
  return [2 /*return*/, (0, summary_1.exactlyNAsync)(this, n, predicate)];
@@ -16477,8 +17318,9 @@ function requireLib () {
16477
17318
  Object.defineProperty(exports, "__esModule", {
16478
17319
  value: true
16479
17320
  });
16480
- exports.LengthError = exports.InvalidArgumentError = exports.AsyncStream = exports.Stream = exports.transform = exports.summary = exports.reduce = exports.set = exports.multi = exports.math = exports.single = void 0;
17321
+ exports.LengthError = exports.InvalidArgumentError = exports.AsyncStream = exports.Stream = exports.transform = exports.summary = exports.reduce = exports.set = exports.multi = exports.math = exports.infinite = exports.single = void 0;
16481
17322
  var single_1 = requireSingle();
17323
+ var infinite_1 = requireInfinite();
16482
17324
  var math_1 = requireMath();
16483
17325
  var multi_1 = requireMulti();
16484
17326
  var set_1 = requireSet();
@@ -16552,6 +17394,12 @@ function requireLib () {
16552
17394
  takeWhileAsync: single_1.takeWhileAsync,
16553
17395
  valuesAsync: single_1.valuesAsync
16554
17396
  };
17397
+ exports.infinite = {
17398
+ count: infinite_1.count,
17399
+ cycle: infinite_1.cycle,
17400
+ cycleAsync: infinite_1.cycleAsync,
17401
+ repeat: infinite_1.repeat
17402
+ };
16555
17403
  exports.math = {
16556
17404
  runningAverage: math_1.runningAverage,
16557
17405
  runningDifference: math_1.runningDifference,
@@ -16584,11 +17432,13 @@ function requireLib () {
16584
17432
  partialIntersection: set_1.partialIntersection,
16585
17433
  symmetricDifference: set_1.symmetricDifference,
16586
17434
  union: set_1.union,
17435
+ cartesianProduct: set_1.cartesianProduct,
16587
17436
  distinctAsync: set_1.distinctAsync,
16588
17437
  intersectionAsync: set_1.intersectionAsync,
16589
17438
  partialIntersectionAsync: set_1.partialIntersectionAsync,
16590
17439
  symmetricDifferenceAsync: set_1.symmetricDifferenceAsync,
16591
- unionAsync: set_1.unionAsync
17440
+ unionAsync: set_1.unionAsync,
17441
+ cartesianProductAsync: set_1.cartesianProductAsync
16592
17442
  };
16593
17443
  exports.reduce = {
16594
17444
  toAverage: reduce_1.toAverage,
@@ -16600,6 +17450,7 @@ function requireLib () {
16600
17450
  toMin: reduce_1.toMin,
16601
17451
  toMinMax: reduce_1.toMinMax,
16602
17452
  toProduct: reduce_1.toProduct,
17453
+ toRange: reduce_1.toRange,
16603
17454
  toSum: reduce_1.toSum,
16604
17455
  toValue: reduce_1.toValue,
16605
17456
  toAverageAsync: reduce_1.toAverageAsync,
@@ -16611,6 +17462,7 @@ function requireLib () {
16611
17462
  toMinAsync: reduce_1.toMinAsync,
16612
17463
  toMinMaxAsync: reduce_1.toMinMaxAsync,
16613
17464
  toProductAsync: reduce_1.toProductAsync,
17465
+ toRangeAsync: reduce_1.toRangeAsync,
16614
17466
  toSumAsync: reduce_1.toSumAsync,
16615
17467
  toValueAsync: reduce_1.toValueAsync
16616
17468
  };
@@ -20588,7 +21440,7 @@ function* toIterableIterator(iter) {
20588
21440
  }
20589
21441
  }
20590
21442
  }
20591
- const map = (fn) => (
21443
+ const map$1 = (fn) => (
20592
21444
  // eslint-disable-next-line @typescript-eslint/no-shadow -- naming the function is helpful in stack traces/debugging
20593
21445
  function* map2(iterable) {
20594
21446
  for (const item of toIterableIterator(iterable)) {
@@ -21170,7 +22022,7 @@ class LocationPathEvaluation {
21170
22022
  }
21171
22023
  }
21172
22024
  *following(step) {
21173
- const contextNodes = map((node) => node.ownerElement ?? node)(
22025
+ const contextNodes = map$1((node) => node.ownerElement ?? node)(
21174
22026
  this.contextNodes
21175
22027
  );
21176
22028
  const treeWalker = this.getTreeWalker(step);
@@ -21763,8 +22615,8 @@ undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator)
21763
22615
  step((generator = generator.apply(thisArg, _arguments || [])).next());
21764
22616
  });
21765
22617
  };
21766
- var __await$1 = undefined && undefined.__await || function (v) {
21767
- return this instanceof __await$1 ? (this.v = v, this) : new __await$1(v);
22618
+ var __await$2 = undefined && undefined.__await || function (v) {
22619
+ return this instanceof __await$2 ? (this.v = v, this) : new __await$2(v);
21768
22620
  };
21769
22621
  undefined && undefined.__asyncGenerator || function (thisArg, _arguments, generator) {
21770
22622
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
@@ -21789,7 +22641,7 @@ undefined && undefined.__asyncGenerator || function (thisArg, _arguments, genera
21789
22641
  }
21790
22642
  }
21791
22643
  function step(r) {
21792
- r.value instanceof __await$1 ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
22644
+ r.value instanceof __await$2 ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
21793
22645
  }
21794
22646
  function fulfill(value) {
21795
22647
  resume("next", value);
@@ -21839,7 +22691,7 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
21839
22691
  step((generator = generator.apply(thisArg, _arguments || [])).next());
21840
22692
  });
21841
22693
  };
21842
- var __asyncValues = undefined && undefined.__asyncValues || function (o) {
22694
+ var __asyncValues$1 = undefined && undefined.__asyncValues || function (o) {
21843
22695
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
21844
22696
  var m = o[Symbol.asyncIterator],
21845
22697
  i;
@@ -21888,7 +22740,7 @@ function toValueAsync(data, reducer, initialValue) {
21888
22740
  return __awaiter(this, void 0, void 0, function* () {
21889
22741
  let carry = initialValue;
21890
22742
  try {
21891
- for (var _d = true, _e = __asyncValues(toAsyncIterable(data)), _f; _f = yield _e.next(), _a = _f.done, !_a;) {
22743
+ for (var _d = true, _e = __asyncValues$1(toAsyncIterable(data)), _f; _f = yield _e.next(), _a = _f.done, !_a;) {
21892
22744
  _c = _f.value;
21893
22745
  _d = false;
21894
22746
  try {
@@ -22076,6 +22928,30 @@ function toMinMaxAsync(data, compareBy) {
22076
22928
  }), [undefined, undefined]);
22077
22929
  });
22078
22930
  }
22931
+ /**
22932
+ * Reduces given collection to its range.
22933
+ *
22934
+ * Returns 0 if given collection is empty.
22935
+ *
22936
+ * @param numbers
22937
+ */
22938
+ function toRange(numbers) {
22939
+ const [min, max] = toMinMax(map(numbers, n => Number(n)));
22940
+ return (max !== null && max !== void 0 ? max : 0) - (min !== null && min !== void 0 ? min : 0);
22941
+ }
22942
+ /**
22943
+ * Reduces given async collection to its range.
22944
+ *
22945
+ * Returns 0 if given async collection is empty.
22946
+ *
22947
+ * @param numbers
22948
+ */
22949
+ function toRangeAsync(numbers) {
22950
+ return __awaiter(this, void 0, void 0, function* () {
22951
+ const [min, max] = yield toMinMaxAsync(mapAsync(numbers, n => Number(n)));
22952
+ return (max !== null && max !== void 0 ? max : 0) - (min !== null && min !== void 0 ? min : 0);
22953
+ });
22954
+ }
22079
22955
  /**
22080
22956
  * Reduces given collection to the sum of its items.
22081
22957
  *
@@ -22175,7 +23051,7 @@ function toFirstAsync(data) {
22175
23051
  var _a, e_2, _b, _c;
22176
23052
  return __awaiter(this, void 0, void 0, function* () {
22177
23053
  try {
22178
- for (var _d = true, _e = __asyncValues(toAsyncIterable(data)), _f; _f = yield _e.next(), _a = _f.done, !_a;) {
23054
+ for (var _d = true, _e = __asyncValues$1(toAsyncIterable(data)), _f; _f = yield _e.next(), _a = _f.done, !_a;) {
22179
23055
  _c = _f.value;
22180
23056
  _d = false;
22181
23057
  try {
@@ -22231,7 +23107,7 @@ function toLastAsync(data) {
22231
23107
  let isEmpty = true;
22232
23108
  let result;
22233
23109
  try {
22234
- for (var _d = true, _e = __asyncValues(toAsyncIterable(data)), _f; _f = yield _e.next(), _a = _f.done, !_a;) {
23110
+ for (var _d = true, _e = __asyncValues$1(toAsyncIterable(data)), _f; _f = yield _e.next(), _a = _f.done, !_a;) {
22235
23111
  _c = _f.value;
22236
23112
  _d = false;
22237
23113
  try {
@@ -22293,7 +23169,7 @@ function toFirstAndLastAsync(data) {
22293
23169
  let first = NoValueMonad;
22294
23170
  let last = NoValueMonad;
22295
23171
  try {
22296
- for (var _d = true, _e = __asyncValues(toAsyncIterable(data)), _f; _f = yield _e.next(), _a = _f.done, !_a;) {
23172
+ for (var _d = true, _e = __asyncValues$1(toAsyncIterable(data)), _f; _f = yield _e.next(), _a = _f.done, !_a;) {
22297
23173
  _c = _f.value;
22298
23174
  _d = false;
22299
23175
  try {
@@ -22443,10 +23319,10 @@ undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator)
22443
23319
  step((generator = generator.apply(thisArg, _arguments || [])).next());
22444
23320
  });
22445
23321
  };
22446
- var __await = undefined && undefined.__await || function (v) {
22447
- return this instanceof __await ? (this.v = v, this) : new __await(v);
23322
+ var __await$1 = undefined && undefined.__await || function (v) {
23323
+ return this instanceof __await$1 ? (this.v = v, this) : new __await$1(v);
22448
23324
  };
22449
- var __asyncGenerator = undefined && undefined.__asyncGenerator || function (thisArg, _arguments, generator) {
23325
+ var __asyncGenerator$1 = undefined && undefined.__asyncGenerator || function (thisArg, _arguments, generator) {
22450
23326
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
22451
23327
  var g = generator.apply(thisArg, _arguments || []),
22452
23328
  i,
@@ -22469,7 +23345,7 @@ var __asyncGenerator = undefined && undefined.__asyncGenerator || function (this
22469
23345
  }
22470
23346
  }
22471
23347
  function step(r) {
22472
- r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
23348
+ r.value instanceof __await$1 ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
22473
23349
  }
22474
23350
  function fulfill(value) {
22475
23351
  resume("next", value);
@@ -22547,13 +23423,13 @@ function toAsyncIterable(collection) {
22547
23423
  if (isIterator(collection)) {
22548
23424
  return {
22549
23425
  [Symbol.asyncIterator]() {
22550
- return __asyncGenerator(this, arguments, function* _a() {
23426
+ return __asyncGenerator$1(this, arguments, function* _a() {
22551
23427
  while (true) {
22552
- const res = yield __await(collection.next());
23428
+ const res = yield __await$1(collection.next());
22553
23429
  if (res.done) {
22554
- return yield __await(void 0);
23430
+ return yield __await$1(void 0);
22555
23431
  }
22556
- yield yield __await(res.value);
23432
+ yield yield __await$1(res.value);
22557
23433
  }
22558
23434
  });
22559
23435
  }
@@ -22565,9 +23441,9 @@ function toAsyncIterable(collection) {
22565
23441
  if (isIterable(collection)) {
22566
23442
  return {
22567
23443
  [Symbol.asyncIterator]() {
22568
- return __asyncGenerator(this, arguments, function* _a() {
23444
+ return __asyncGenerator$1(this, arguments, function* _a() {
22569
23445
  for (const value of collection) {
22570
- yield yield __await(value);
23446
+ yield yield __await$1(value);
22571
23447
  }
22572
23448
  });
22573
23449
  }
@@ -22576,6 +23452,114 @@ function toAsyncIterable(collection) {
22576
23452
  throw new InvalidArgumentError("Given collection is not async iterable or iterator.");
22577
23453
  }
22578
23454
 
23455
+ var __asyncValues = undefined && undefined.__asyncValues || function (o) {
23456
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
23457
+ var m = o[Symbol.asyncIterator],
23458
+ i;
23459
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () {
23460
+ return this;
23461
+ }, i);
23462
+ function verb(n) {
23463
+ i[n] = o[n] && function (v) {
23464
+ return new Promise(function (resolve, reject) {
23465
+ v = o[n](v), settle(resolve, reject, v.done, v.value);
23466
+ });
23467
+ };
23468
+ }
23469
+ function settle(resolve, reject, d, v) {
23470
+ Promise.resolve(v).then(function (v) {
23471
+ resolve({
23472
+ value: v,
23473
+ done: d
23474
+ });
23475
+ }, reject);
23476
+ }
23477
+ };
23478
+ var __await = undefined && undefined.__await || function (v) {
23479
+ return this instanceof __await ? (this.v = v, this) : new __await(v);
23480
+ };
23481
+ var __asyncGenerator = undefined && undefined.__asyncGenerator || function (thisArg, _arguments, generator) {
23482
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
23483
+ var g = generator.apply(thisArg, _arguments || []),
23484
+ i,
23485
+ q = [];
23486
+ return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () {
23487
+ return this;
23488
+ }, i;
23489
+ function verb(n) {
23490
+ if (g[n]) i[n] = function (v) {
23491
+ return new Promise(function (a, b) {
23492
+ q.push([n, v, a, b]) > 1 || resume(n, v);
23493
+ });
23494
+ };
23495
+ }
23496
+ function resume(n, v) {
23497
+ try {
23498
+ step(g[n](v));
23499
+ } catch (e) {
23500
+ settle(q[0][3], e);
23501
+ }
23502
+ }
23503
+ function step(r) {
23504
+ r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
23505
+ }
23506
+ function fulfill(value) {
23507
+ resume("next", value);
23508
+ }
23509
+ function reject(value) {
23510
+ resume("throw", value);
23511
+ }
23512
+ function settle(f, v) {
23513
+ if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]);
23514
+ }
23515
+ };
23516
+ /**
23517
+ * Map a function onto every element of the iteration.
23518
+ *
23519
+ * @param data
23520
+ * @param mapper
23521
+ */
23522
+ function* map(data, mapper) {
23523
+ for (const datum of toIterable(data)) {
23524
+ yield mapper(datum);
23525
+ }
23526
+ }
23527
+ /**
23528
+ * Map a function onto every element of the iteration for async collections.
23529
+ *
23530
+ * Mapper may be also async.
23531
+ *
23532
+ * @param data
23533
+ * @param mapper
23534
+ */
23535
+ function mapAsync(data, mapper) {
23536
+ return __asyncGenerator(this, arguments, function* mapAsync_1() {
23537
+ var _a, e_1, _b, _c;
23538
+ try {
23539
+ for (var _d = true, _e = __asyncValues(toAsyncIterable(data)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a;) {
23540
+ _c = _f.value;
23541
+ _d = false;
23542
+ try {
23543
+ const datum = _c;
23544
+ yield yield __await(yield __await(mapper(datum)));
23545
+ } finally {
23546
+ _d = true;
23547
+ }
23548
+ }
23549
+ } catch (e_1_1) {
23550
+ e_1 = {
23551
+ error: e_1_1
23552
+ };
23553
+ } finally {
23554
+ try {
23555
+ if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
23556
+ } finally {
23557
+ if (e_1) throw e_1.error;
23558
+ }
23559
+ }
23560
+ });
23561
+ }
23562
+
22579
23563
  const reduce = {
22580
23564
  toAverage,
22581
23565
  toCount: toCount$1,
@@ -22586,6 +23570,7 @@ const reduce = {
22586
23570
  toMin,
22587
23571
  toMinMax,
22588
23572
  toProduct,
23573
+ toRange,
22589
23574
  toSum,
22590
23575
  toValue,
22591
23576
  toAverageAsync,
@@ -22597,6 +23582,7 @@ const reduce = {
22597
23582
  toMinAsync,
22598
23583
  toMinMaxAsync,
22599
23584
  toProductAsync,
23585
+ toRangeAsync,
22600
23586
  toSumAsync,
22601
23587
  toValueAsync
22602
23588
  };
@@ -25060,6 +26046,100 @@ const countNonEmpty = new NumberFunction(
25060
26046
  return result;
25061
26047
  }
25062
26048
  );
26049
+ const assertArgument = (index, arg) => {
26050
+ if (arg == null) {
26051
+ throw new Error(`Argument ${index + 1} expected`);
26052
+ }
26053
+ };
26054
+ const assertIsLocationPathEvaluation = (evaluation) => {
26055
+ if (!(evaluation instanceof LocationPathEvaluation)) {
26056
+ throw new Error("Expected a node-set result");
26057
+ }
26058
+ };
26059
+ const evaluateArgumentToFilterableNodes = (context, arg) => {
26060
+ const evaluation = arg.evaluate(context);
26061
+ assertIsLocationPathEvaluation(evaluation);
26062
+ return Array.from(evaluation.contextNodes);
26063
+ };
26064
+ const compareContainmentDepth = ({ repeats: a }, { repeats: b }) => {
26065
+ for (const repeatA of a) {
26066
+ for (const repeatB of b) {
26067
+ if (repeatA.contains(repeatB)) {
26068
+ return -1;
26069
+ }
26070
+ if (repeatB.contains(repeatA)) {
26071
+ return 1;
26072
+ }
26073
+ }
26074
+ }
26075
+ if (a.length === 0 || b.length === 0) {
26076
+ return 0;
26077
+ }
26078
+ return 0;
26079
+ };
26080
+ const indexedRepeat = new NodeSetFunction(
26081
+ "indexed-repeat",
26082
+ [
26083
+ // spec: arg
26084
+ { arityType: "required", typeHint: "node" },
26085
+ // spec: repeat1
26086
+ { arityType: "required", typeHint: "node" },
26087
+ // spec: index1
26088
+ { arityType: "required", typeHint: "number" },
26089
+ // spec: repeatN=0 -> repeat2
26090
+ { arityType: "optional", typeHint: "node" },
26091
+ // spec: indexN=0 -> index2
26092
+ { arityType: "optional", typeHint: "number" },
26093
+ // spec: repeatN=1 -> repeat3
26094
+ { arityType: "optional", typeHint: "node" },
26095
+ // spec: indexN=1 -> index3
26096
+ { arityType: "optional", typeHint: "number" },
26097
+ // Go beyond spec? Why the heck not! It's clearly a variadic design.
26098
+ { arityType: "variadic", typeHint: "any" }
26099
+ ],
26100
+ (context, args) => {
26101
+ const target = args[0];
26102
+ let pairs = [];
26103
+ for (let i = 1; i < args.length; i += 2) {
26104
+ const repeatsArg = args[i];
26105
+ const positionArg = args[i + 1];
26106
+ assertArgument(i, repeatsArg);
26107
+ assertArgument(i + 1, positionArg);
26108
+ const position2 = positionArg.evaluate(context).toNumber();
26109
+ if (Number.isNaN(position2)) {
26110
+ return [];
26111
+ }
26112
+ const repeats = evaluateArgumentToFilterableNodes(context, repeatsArg);
26113
+ if (repeats.length === 0) {
26114
+ return [];
26115
+ }
26116
+ pairs.push({
26117
+ repeats,
26118
+ position: position2
26119
+ });
26120
+ }
26121
+ pairs = pairs.sort(compareContainmentDepth);
26122
+ let repeatContextNode;
26123
+ for (const [index, pair] of pairs.entries()) {
26124
+ const { position: position2 } = pair;
26125
+ let { repeats } = pair;
26126
+ if (index > 0) {
26127
+ repeats = pair.repeats.filter((repeat) => {
26128
+ return repeatContextNode.contains(repeat);
26129
+ });
26130
+ }
26131
+ const positionedRepeat = repeats[position2 - 1];
26132
+ if (positionedRepeat == null) {
26133
+ return [];
26134
+ }
26135
+ repeatContextNode = positionedRepeat;
26136
+ }
26137
+ const targetNodes = evaluateArgumentToFilterableNodes(context, target);
26138
+ return targetNodes.filter((targetNode) => {
26139
+ return repeatContextNode.contains(targetNode);
26140
+ });
26141
+ }
26142
+ );
25063
26143
  const identifiedInstanceLookup = new ScopedElementLookup(":scope > instance[id]", "instance[id]");
25064
26144
  const instancesCache = new UpsertableWeakMap();
25065
26145
  const getInstanceElementByID = (modelElement, id) => {
@@ -25158,6 +26238,7 @@ const randomize = new NodeSetFunction(
25158
26238
  const nodeset = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
25159
26239
  __proto__: null,
25160
26240
  countNonEmpty,
26241
+ indexedRepeat,
25161
26242
  instance,
25162
26243
  once,
25163
26244
  position,