tyneq 1.0.0 → 1.0.2

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.
Files changed (52) hide show
  1. package/README.md +67 -1
  2. package/dist/{TyneqCachedTerminalOperator.d.ts → TyneqCachedTerminalOperator-BrW77zIy.d.ts} +328 -173
  3. package/dist/{TyneqCachedTerminalOperator.d.cts → TyneqCachedTerminalOperator-EaNiNt61.d.cts} +328 -173
  4. package/dist/chunk-5R4AALC7.js +680 -0
  5. package/dist/chunk-C5PBY3ZU.cjs +46 -0
  6. package/dist/chunk-OWKUE3AC.cjs +680 -0
  7. package/dist/chunk-PCBN5AFG.js +46 -0
  8. package/dist/chunk-VJAICXA6.cjs +3788 -0
  9. package/dist/chunk-ZP6WMZCK.js +3788 -0
  10. package/dist/core-C54TSmgW.d.cts +1390 -0
  11. package/dist/core-C54TSmgW.d.ts +1390 -0
  12. package/dist/index.cjs +638 -843
  13. package/dist/index.d.cts +405 -605
  14. package/dist/index.d.ts +405 -605
  15. package/dist/index.js +630 -781
  16. package/dist/plugin/index.cjs +51 -24
  17. package/dist/plugin/index.d.cts +35 -38
  18. package/dist/plugin/index.d.ts +35 -38
  19. package/dist/plugin/index.js +51 -2
  20. package/dist/utility/index.cjs +18 -9
  21. package/dist/utility/index.d.cts +312 -2
  22. package/dist/utility/index.d.ts +312 -2
  23. package/dist/utility/index.js +18 -3
  24. package/package.json +5 -5
  25. package/dist/Lazy.cjs +0 -762
  26. package/dist/Lazy.cjs.map +0 -1
  27. package/dist/Lazy.js +0 -691
  28. package/dist/Lazy.js.map +0 -1
  29. package/dist/TyneqCachedTerminalOperator.cjs +0 -4950
  30. package/dist/TyneqCachedTerminalOperator.cjs.map +0 -1
  31. package/dist/TyneqCachedTerminalOperator.d.cts.map +0 -1
  32. package/dist/TyneqCachedTerminalOperator.d.ts.map +0 -1
  33. package/dist/TyneqCachedTerminalOperator.js +0 -4741
  34. package/dist/TyneqCachedTerminalOperator.js.map +0 -1
  35. package/dist/ValidationBuilder.cjs +0 -80
  36. package/dist/ValidationBuilder.cjs.map +0 -1
  37. package/dist/ValidationBuilder.d.cts +0 -319
  38. package/dist/ValidationBuilder.d.cts.map +0 -1
  39. package/dist/ValidationBuilder.d.ts +0 -319
  40. package/dist/ValidationBuilder.d.ts.map +0 -1
  41. package/dist/ValidationBuilder.js +0 -69
  42. package/dist/ValidationBuilder.js.map +0 -1
  43. package/dist/core.d.cts +0 -1393
  44. package/dist/core.d.cts.map +0 -1
  45. package/dist/core.d.ts +0 -1393
  46. package/dist/core.d.ts.map +0 -1
  47. package/dist/index.cjs.map +0 -1
  48. package/dist/index.d.cts.map +0 -1
  49. package/dist/index.d.ts.map +0 -1
  50. package/dist/index.js.map +0 -1
  51. package/dist/plugin/index.d.cts.map +0 -1
  52. package/dist/plugin/index.d.ts.map +0 -1
@@ -0,0 +1,3788 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+ var _chunkOWKUE3ACcjs = require('./chunk-OWKUE3AC.cjs');
13
+
14
+ // src/core/enumerators/TyneqBaseEnumerator.ts
15
+ var TyneqBaseEnumerator = class {
16
+ constructor() {
17
+ this._initialized = false;
18
+ this._completed = false;
19
+ }
20
+ /** Advances the iterator, calling `initialize()` on first call. Idempotent after completion. */
21
+ next() {
22
+ if (this._completed) {
23
+ return this.done();
24
+ }
25
+ if (!this._initialized) {
26
+ this.initialize();
27
+ this._initialized = true;
28
+ }
29
+ const result = this.handleNext();
30
+ if (result.done) {
31
+ if (!this._completed) {
32
+ this.dispose();
33
+ this._completed = true;
34
+ }
35
+ return this.done();
36
+ }
37
+ return result;
38
+ }
39
+ /** Terminates iteration early, disposes resources, and marks completed. Idempotent. */
40
+ return(value) {
41
+ if (!this._completed) {
42
+ this.dispose(value);
43
+ this._completed = true;
44
+ }
45
+ return this.done();
46
+ }
47
+ /** Called once before the first `handleNext()` invocation. Override to set up state. */
48
+ initialize() {
49
+ }
50
+ /** Wraps `value` in a non-done `IteratorResult`. */
51
+ yield(value) {
52
+ return { done: false, value };
53
+ }
54
+ /** Returns a done `IteratorResult`. */
55
+ done() {
56
+ return { done: true, value: void 0 };
57
+ }
58
+ /**
59
+ * Marks the enumerator completed and yields `value` as the final element.
60
+ *
61
+ * @remarks
62
+ * Use when the last element must be emitted together with completion in one step.
63
+ */
64
+ doneWithYield(value) {
65
+ this.dispose();
66
+ this._completed = true;
67
+ return this.yield(value);
68
+ }
69
+ /**
70
+ * Disposes resources, marks completed, and returns a done result.
71
+ *
72
+ * @remarks
73
+ * Use inside `handleNext()` to terminate iteration before the source is exhausted.
74
+ */
75
+ earlyComplete(reason) {
76
+ this.dispose(reason);
77
+ this._completed = true;
78
+ return this.done();
79
+ }
80
+ /** Calls `disposeSource()` then `disposeAdditional()`. */
81
+ dispose(value) {
82
+ this.disposeSource();
83
+ this.disposeAdditional(value);
84
+ }
85
+ /** Override to dispose the upstream source enumerator. */
86
+ disposeSource() {
87
+ }
88
+ /**
89
+ * Override to release any additional resources.
90
+ *
91
+ * @remarks
92
+ * Called after `disposeSource()`. `value` is the return value passed to `return()`.
93
+ * Must be idempotent and must not throw.
94
+ */
95
+ disposeAdditional(_value) {
96
+ }
97
+ };
98
+
99
+ // src/core/TyneqComparer.ts
100
+ var TyneqComparer = class {
101
+ constructor() {
102
+ }
103
+ /**
104
+ * Natural-order comparer using `<` and `>`.
105
+ *
106
+ * @remarks
107
+ * Works correctly for numbers, strings, dates, and any type that supports the relational operators.
108
+ *
109
+ * @returns Negative if `a < b`, positive if `a > b`, `0` if equal.
110
+ */
111
+ static defaultComparer(a, b) {
112
+ return a > b ? 1 : a < b ? -1 : 0;
113
+ }
114
+ /** Strict equality comparer using `===`. */
115
+ static defaultEqualityComparer(a, b) {
116
+ return a === b;
117
+ }
118
+ /**
119
+ * Returns a comparer that reverses the order of `comparer`.
120
+ *
121
+ * @remarks
122
+ * Use this to invert any custom comparer - for example, to sort by a locale-aware comparer
123
+ * in descending order without rewriting it.
124
+ *
125
+ * @example
126
+ * ```ts
127
+ * const desc = TyneqComparer.reverse(TyneqComparer.createLocaleComparer("en"));
128
+ * seq.orderBy((s) => s, desc);
129
+ * ```
130
+ */
131
+ static reverse(comparer) {
132
+ return (a, b) => comparer(b, a);
133
+ }
134
+ /**
135
+ * Returns a locale-aware string comparer backed by `Intl.Collator`.
136
+ *
137
+ * @remarks
138
+ * Pass a `locale` and optional `options` for deterministic cross-environment ordering.
139
+ * Without arguments the comparer uses the runtime locale, which may vary across environments.
140
+ *
141
+ * @example
142
+ * ```ts
143
+ * seq.orderBy((s) => s, TyneqComparer.createLocaleComparer("en"));
144
+ * ```
145
+ *
146
+ * @param locale - BCP 47 language tag(s) passed to `Intl.Collator`.
147
+ * @param options - `Intl.CollatorOptions` passed to `Intl.Collator`.
148
+ *
149
+ * @see {@link caseInsensitiveComparer} for a locale-independent case-insensitive ordering comparer.
150
+ */
151
+ static createLocaleComparer(locale, options) {
152
+ const collator = new Intl.Collator(locale, options);
153
+ return (a, b) => collator.compare(a, b);
154
+ }
155
+ /**
156
+ * Case-insensitive string equality comparer.
157
+ *
158
+ * @remarks
159
+ * Converts both values to lower-case with `toLowerCase()` before comparing with `===`.
160
+ * Locale-independent: results are consistent across environments.
161
+ *
162
+ * Use {@link createLocaleComparer} with `{ sensitivity: "base" }` for locale-aware
163
+ * case-insensitive equality.
164
+ *
165
+ * @see {@link caseInsensitiveComparer} for the ordering (negative/zero/positive) counterpart.
166
+ */
167
+ static caseInsensitiveEqualityComparer(a, b) {
168
+ return a.toLowerCase() === b.toLowerCase();
169
+ }
170
+ /**
171
+ * Case-insensitive ordering comparer.
172
+ *
173
+ * @remarks
174
+ * Converts both values to lower-case with `toLowerCase()` and compares with `<` / `>`.
175
+ * Locale-independent: results are consistent across environments and match
176
+ * {@link caseInsensitiveEqualityComparer} - strings that compare equal here return `true`
177
+ * there, and vice versa.
178
+ *
179
+ * Use {@link createLocaleComparer} when you need locale-aware case-insensitive ordering.
180
+ *
181
+ * @example
182
+ * ```ts
183
+ * seq.orderBy((s) => s, TyneqComparer.caseInsensitiveComparer)
184
+ * ```
185
+ *
186
+ * @see {@link caseInsensitiveEqualityComparer} for the boolean equality counterpart.
187
+ * @see {@link createLocaleComparer} for locale-aware ordering.
188
+ */
189
+ static caseInsensitiveComparer(a, b) {
190
+ const la = a.toLowerCase();
191
+ const lb = b.toLowerCase();
192
+ return la > lb ? 1 : la < lb ? -1 : 0;
193
+ }
194
+ };
195
+
196
+ // src/types/queryplan.ts
197
+ var tyneqQueryNode = /* @__PURE__ */ Symbol("tyneq.queryNode");
198
+ function isSourceNode(node) {
199
+ return node.category === "source";
200
+ }
201
+
202
+ // src/queryplan/QueryNode.ts
203
+ var QueryNode = class {
204
+ constructor(operatorName, args, source2, category, sourceKind) {
205
+ this.operatorName = operatorName;
206
+ this.args = args;
207
+ this.source = source2;
208
+ this.category = category;
209
+ this.sourceKind = sourceKind;
210
+ }
211
+ accept(visitor) {
212
+ return visitor.visit(this);
213
+ }
214
+ };
215
+
216
+ // src/core/errors/PluginError.ts
217
+ var PluginError = class extends _chunkOWKUE3ACcjs.TyneqError {
218
+ constructor(message, decoratorName, targetName, inner) {
219
+ super(message, { inner });
220
+ this.decoratorName = decoratorName;
221
+ this.targetName = targetName;
222
+ }
223
+ };
224
+
225
+ // src/plugin/decorators/builtin.ts
226
+ var builtinMeta = /* @__PURE__ */ Symbol("tyneq.builtinMetadata");
227
+ function builtin(options) {
228
+ return function(value, context) {
229
+ value[builtinMeta] = {
230
+ name: context.name,
231
+ kind: options.kind
232
+ };
233
+ return value;
234
+ };
235
+ }
236
+
237
+ // src/core/errors/RegistryError.ts
238
+ var RegistryError = class extends _chunkOWKUE3ACcjs.TyneqError {
239
+ constructor(message, operatorName, kind, conflict, inner) {
240
+ super(message, { inner });
241
+ this.operatorName = operatorName;
242
+ this.kind = kind;
243
+ this.conflictingKind = conflict == null ? void 0 : conflict.kind;
244
+ this.conflictingSource = conflict == null ? void 0 : conflict.source;
245
+ }
246
+ };
247
+
248
+ // src/core/registry/TyneqOperatorRegistry.ts
249
+ var OperatorRegistry = class {
250
+ /**
251
+ * Registers an operator entry and patches the method onto `entry.metadata.targetClass.prototype`.
252
+ *
253
+ * @throws {RegistryError} When an operator with the same name is already registered on the same targetClass.
254
+ */
255
+ static register(input) {
256
+ const { name } = input.metadata;
257
+ if (input.metadata.targetClass === void 0) {
258
+ throw new RegistryError(
259
+ `Cannot register "${name}": targetClass is required for prototype-patching operators. Use registerSource() for source operators.`,
260
+ name,
261
+ input.metadata.kind
262
+ );
263
+ }
264
+ const targetMap = this._operators.get(name);
265
+ if (targetMap == null ? void 0 : targetMap.has(input.metadata.targetClass)) {
266
+ const existing = targetMap.get(input.metadata.targetClass).metadata;
267
+ throw new RegistryError(
268
+ `Cannot register "${name}" (${input.metadata.kind}) on ${input.metadata.targetClass.name}: already registered as "${existing.kind}" from source "${existing.source}".`,
269
+ name,
270
+ input.metadata.kind,
271
+ { kind: existing.kind, source: existing.source }
272
+ );
273
+ }
274
+ for (const guard of this._registrationGuards) {
275
+ guard(input);
276
+ }
277
+ if (!this._operators.has(name)) {
278
+ this._operators.set(name, /* @__PURE__ */ new Map());
279
+ }
280
+ this._operators.get(name).set(input.metadata.targetClass, input);
281
+ input.metadata.targetClass.prototype[name] = input.impl;
282
+ for (const hook of this._registrationHooks) {
283
+ hook(input);
284
+ }
285
+ }
286
+ /**
287
+ * Removes an operator registration and deletes the prototype method for external operators.
288
+ *
289
+ * Checks the instance operator namespace first, then the source namespace.
290
+ *
291
+ * @returns `true` if the operator was found and removed; `false` if no operator with that name existed.
292
+ * @remarks
293
+ * Internal operators (source `"internal"`) are not removed from the prototype - only
294
+ * their registry entry is deleted.
295
+ *
296
+ * For targeted removal use {@link unregisterOperator} or {@link unregisterSource}.
297
+ */
298
+ static unregister(name) {
299
+ if (this._operators.has(name)) {
300
+ const targetMap = this._operators.get(name);
301
+ for (const [targetClass, entry] of targetMap) {
302
+ if (entry.metadata.source !== "internal" && targetClass !== void 0) {
303
+ delete targetClass.prototype[name];
304
+ }
305
+ }
306
+ this._operators.delete(name);
307
+ return true;
308
+ }
309
+ if (this._sources.has(name)) {
310
+ this._sources.delete(name);
311
+ return true;
312
+ }
313
+ return false;
314
+ }
315
+ /**
316
+ * Removes a specific instance operator registration for a given (name, targetClass) pair
317
+ * and deletes the prototype method for external operators.
318
+ *
319
+ * @returns `true` if the entry was found and removed; `false` otherwise.
320
+ */
321
+ static unregisterOperator(name, targetClass) {
322
+ const targetMap = this._operators.get(name);
323
+ if (!(targetMap == null ? void 0 : targetMap.has(targetClass))) {
324
+ return false;
325
+ }
326
+ const entry = targetMap.get(targetClass);
327
+ if (entry.metadata.source !== "internal") {
328
+ delete targetClass.prototype[name];
329
+ }
330
+ targetMap.delete(targetClass);
331
+ if (targetMap.size === 0) {
332
+ this._operators.delete(name);
333
+ }
334
+ return true;
335
+ }
336
+ /**
337
+ * Removes a source factory registration.
338
+ *
339
+ * @returns `true` if the source was found and removed; `false` otherwise.
340
+ */
341
+ static unregisterSource(name) {
342
+ return this._sources.delete(name);
343
+ }
344
+ /**
345
+ * Registers a hook called after every successful operator registration (both namespaces).
346
+ *
347
+ * @returns A function that removes the hook when called.
348
+ */
349
+ static onRegister(hook) {
350
+ this._registrationHooks.push(hook);
351
+ return () => {
352
+ const i = this._registrationHooks.indexOf(hook);
353
+ if (i !== -1) this._registrationHooks.splice(i, 1);
354
+ };
355
+ }
356
+ /**
357
+ * Registers a guard called before every registration (both namespaces).
358
+ * Throw from the guard to reject the registration.
359
+ *
360
+ * @returns A function that removes the guard when called.
361
+ */
362
+ static addGuard(guard) {
363
+ this._registrationGuards.push(guard);
364
+ return () => {
365
+ const i = this._registrationGuards.indexOf(guard);
366
+ if (i !== -1) this._registrationGuards.splice(i, 1);
367
+ };
368
+ }
369
+ /**
370
+ * Returns `true` if a name exists in either the source or instance operator namespace.
371
+ * Use {@link hasSource} or {@link hasOperator} for namespace-specific checks.
372
+ */
373
+ static has(name) {
374
+ return this._sources.has(name) || this._operators.has(name);
375
+ }
376
+ /**
377
+ * Returns `true` if a source factory with `name` is registered.
378
+ */
379
+ static hasSource(name) {
380
+ return this._sources.has(name);
381
+ }
382
+ /**
383
+ * Returns `true` if an instance operator with `name` is registered.
384
+ * When `targetClass` is provided, checks only that specific (name, targetClass) pair.
385
+ * When omitted, returns `true` if any target has an operator with that name.
386
+ */
387
+ static hasOperator(name, targetClass) {
388
+ var _a6, _b3;
389
+ if (targetClass !== void 0) {
390
+ return (_b3 = (_a6 = this._operators.get(name)) == null ? void 0 : _a6.has(targetClass)) != null ? _b3 : false;
391
+ }
392
+ return this._operators.has(name);
393
+ }
394
+ /**
395
+ * Returns the operator entry for `name` from either namespace, or `undefined` if not found.
396
+ * Checks the instance operator namespace first, then the source namespace.
397
+ * For namespace-specific retrieval use {@link getSource} or {@link getOperator}.
398
+ */
399
+ static get(name) {
400
+ const targetMap = this._operators.get(name);
401
+ if (targetMap !== void 0) {
402
+ return targetMap.values().next().value;
403
+ }
404
+ return this._sources.get(name);
405
+ }
406
+ /**
407
+ * Returns the source factory entry for `name`, or `undefined` if not registered.
408
+ */
409
+ static getSource(name) {
410
+ return this._sources.get(name);
411
+ }
412
+ /**
413
+ * Returns the instance operator entry for `name` on `targetClass`, or `undefined`.
414
+ * When `targetClass` is omitted, returns the first entry found across all targets.
415
+ */
416
+ static getOperator(name, targetClass) {
417
+ const targetMap = this._operators.get(name);
418
+ if (targetMap === void 0) {
419
+ return void 0;
420
+ }
421
+ if (targetClass !== void 0) {
422
+ return targetMap.get(targetClass);
423
+ }
424
+ return targetMap.values().next().value;
425
+ }
426
+ /**
427
+ * Returns the metadata for `name` from either namespace, or `undefined` if not found.
428
+ * Checks instance operators first, then sources.
429
+ */
430
+ static getMetadata(name) {
431
+ var _a6;
432
+ return (_a6 = this.get(name)) == null ? void 0 : _a6.metadata;
433
+ }
434
+ /**
435
+ * Returns metadata for all registered operators and source factories.
436
+ * Use {@link listOperators} or {@link listSources} for namespace-specific lists.
437
+ */
438
+ static list() {
439
+ return [...this.listSources(), ...this.listOperators()];
440
+ }
441
+ /**
442
+ * Returns metadata for all registered source factories.
443
+ */
444
+ static listSources() {
445
+ return [...this._sources.values()].map((e) => e.metadata);
446
+ }
447
+ /**
448
+ * Returns metadata for all registered instance operators.
449
+ * When `targetClass` is provided, returns only entries for that specific target class.
450
+ */
451
+ static listOperators(targetClass) {
452
+ const all = [];
453
+ for (const targetMap of this._operators.values()) {
454
+ if (targetClass !== void 0) {
455
+ const entry = targetMap.get(targetClass);
456
+ if (entry !== void 0) {
457
+ all.push(entry.metadata);
458
+ }
459
+ } else {
460
+ for (const entry of targetMap.values()) {
461
+ all.push(entry.metadata);
462
+ }
463
+ }
464
+ }
465
+ return all;
466
+ }
467
+ /** Returns metadata for all operators of `kind` across both namespaces. */
468
+ static listByKind(kind) {
469
+ return this.list().filter((m) => m.kind === kind);
470
+ }
471
+ /** Returns metadata for all operators from `source` across both namespaces. */
472
+ static listBySource(source2) {
473
+ return this.list().filter((m) => m.source === source2);
474
+ }
475
+ /** Returns the total number of registered operators across both namespaces. */
476
+ static count() {
477
+ let operatorCount = 0;
478
+ for (const targetMap of this._operators.values()) {
479
+ operatorCount += targetMap.size;
480
+ }
481
+ return this._sources.size + operatorCount;
482
+ }
483
+ /**
484
+ * Registers a source operator (a static factory, not a prototype method).
485
+ *
486
+ * @remarks
487
+ * Source operators differ from prototype operators in two ways:
488
+ * - They are called with `null` as `this` - they have no instance.
489
+ * - They are looked up by the compiler via {@link getSource} rather than
490
+ * being patched onto a prototype.
491
+ *
492
+ * The entry is stored in the source namespace and is never patched onto any prototype.
493
+ * Registration guards run for `"external"` sources (same policy as {@link register}).
494
+ * Guards are skipped for `"internal"` sources (same policy used for internal builtins).
495
+ *
496
+ * Third-party source operators registered here are automatically compiled by
497
+ * `QueryPlanCompiler` without any changes to the compiler.
498
+ *
499
+ * @param name - The operator name, matching the `operatorName` on the `QueryPlanNode`.
500
+ * @param factory - The factory function; receives the node args in order, `this` is `null`.
501
+ * @param source - Whether this is a built-in or external source operator. Defaults to `"external"`.
502
+ *
503
+ * @example
504
+ * ```ts
505
+ * import { OperatorRegistry } from "tyneq/plugin";
506
+ * import { Tyneq } from "tyneq";
507
+ *
508
+ * OperatorRegistry.registerSource("fibonacci", (count) => {
509
+ * // return a Tyneq sequence of fibonacci numbers
510
+ * });
511
+ * ```
512
+ *
513
+ * @group Classes
514
+ */
515
+ static registerSource(name, factory, source2 = "external") {
516
+ if (this._sources.has(name)) {
517
+ const existing = this._sources.get(name).metadata;
518
+ throw new RegistryError(
519
+ `Cannot register source "${name}": already registered as "${existing.kind}" from source "${existing.source}".`,
520
+ name,
521
+ "source",
522
+ { kind: existing.kind, source: existing.source }
523
+ );
524
+ }
525
+ const entry = {
526
+ metadata: OperatorMetadata.source(name, source2),
527
+ impl: function(...args) {
528
+ return factory(...args);
529
+ }
530
+ };
531
+ if (source2 !== "internal") {
532
+ for (const guard of this._registrationGuards) {
533
+ guard(entry);
534
+ }
535
+ }
536
+ this._sources.set(name, entry);
537
+ for (const hook of this._registrationHooks) {
538
+ hook(entry);
539
+ }
540
+ }
541
+ /**
542
+ * Records a built-in operator in the instance operator namespace without patching the prototype.
543
+ * Built-in operators already live as direct methods on their target class.
544
+ *
545
+ * @remarks
546
+ * Registration guards are intentionally skipped - builtins are internal and
547
+ * trusted; guards exist to validate external plugin registrations only.
548
+ *
549
+ * @internal
550
+ */
551
+ static registerBuiltin(name, kind, targetClass) {
552
+ const targetMap = this._operators.get(name);
553
+ if (targetMap == null ? void 0 : targetMap.has(targetClass)) {
554
+ const existing = targetMap.get(targetClass).metadata;
555
+ throw new RegistryError(
556
+ `Cannot register builtin "${name}" (${kind}) on ${targetClass.name}: already registered as "${existing.kind}" from source "${existing.source}".`,
557
+ name,
558
+ kind,
559
+ { kind: existing.kind, source: existing.source }
560
+ );
561
+ }
562
+ const lazyMethod = new (0, _chunkOWKUE3ACcjs.Lazy)(() => {
563
+ var _a6;
564
+ return (_a6 = _chunkOWKUE3ACcjs.reflect.call(void 0, targetClass.prototype).tryGetMethod(name)) == null ? void 0 : _a6.value;
565
+ });
566
+ const lazyMetadata = new (0, _chunkOWKUE3ACcjs.Lazy)(() => new OperatorMetadata(name, kind, "internal", targetClass));
567
+ const entry = {
568
+ get metadata() {
569
+ return lazyMetadata.value;
570
+ },
571
+ impl: function(...args) {
572
+ const method = lazyMethod.value;
573
+ if (!method) {
574
+ throw new RegistryError(
575
+ `Cannot invoke builtin "${name}" (${kind}): method not found on prototype. Ensure the method exists on the target class before registering.`,
576
+ name,
577
+ kind
578
+ );
579
+ }
580
+ return method.apply(this, args);
581
+ }
582
+ };
583
+ if (!this._operators.has(name)) {
584
+ this._operators.set(name, /* @__PURE__ */ new Map());
585
+ }
586
+ this._operators.get(name).set(targetClass, entry);
587
+ for (const hook of this._registrationHooks) {
588
+ hook(entry);
589
+ }
590
+ }
591
+ };
592
+ OperatorRegistry._sources = /* @__PURE__ */ new Map();
593
+ OperatorRegistry._operators = /* @__PURE__ */ new Map();
594
+ OperatorRegistry._registrationHooks = [];
595
+ OperatorRegistry._registrationGuards = [];
596
+
597
+ // src/plugin/decorators/sequence.ts
598
+ function sequence(target, _context) {
599
+ var _a6;
600
+ for (const key of Object.getOwnPropertyNames(target.prototype)) {
601
+ const method = (_a6 = _chunkOWKUE3ACcjs.reflect.call(void 0, target.prototype).tryGetMethod(key)) == null ? void 0 : _a6.value;
602
+ if (method && builtinMeta in method) {
603
+ const metadata = method[builtinMeta];
604
+ OperatorRegistry.registerBuiltin(metadata.name, metadata.kind, target);
605
+ }
606
+ }
607
+ }
608
+
609
+ // src/core/TyneqEnumerableCore.ts
610
+ var _pipe_dec, _memoize_dec, _orderByDescending_dec, _orderBy_dec, _a, _TyneqEnumerableCore_decorators, _init;
611
+ _TyneqEnumerableCore_decorators = [sequence];
612
+ var TyneqEnumerableCore = class {
613
+ constructor() {
614
+ _chunkOWKUE3ACcjs.__runInitializers.call(void 0, _init, 5, this);
615
+ }
616
+ [(_a = Symbol.iterator, _orderBy_dec = [builtin({ kind: "buffer" })], _orderByDescending_dec = [builtin({ kind: "buffer" })], _memoize_dec = [builtin({ kind: "cache" })], _pipe_dec = [builtin({ kind: "extension" })], _a)]() {
617
+ return this.getEnumerator();
618
+ }
619
+ orderBy(keySelector, comparer) {
620
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ keySelector });
621
+ const orderByArgs = comparer !== void 0 ? [keySelector, comparer] : [keySelector];
622
+ return this.createOrderedEnumerable(
623
+ keySelector,
624
+ comparer != null ? comparer : TyneqComparer.defaultComparer,
625
+ false,
626
+ this.createNode("orderBy", "buffer", orderByArgs)
627
+ );
628
+ }
629
+ orderByDescending(keySelector, comparer) {
630
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ keySelector });
631
+ const orderByDescArgs = comparer !== void 0 ? [keySelector, comparer] : [keySelector];
632
+ return this.createOrderedEnumerable(
633
+ keySelector,
634
+ comparer != null ? comparer : TyneqComparer.defaultComparer,
635
+ true,
636
+ this.createNode("orderByDescending", "buffer", orderByDescArgs)
637
+ );
638
+ }
639
+ memoize() {
640
+ return this.createCachedEnumerable(this, this.createNode("memoize", "buffer"));
641
+ }
642
+ pipe(factory) {
643
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ factory });
644
+ const self = this;
645
+ return this.createSequence(
646
+ () => factory(self),
647
+ this.createNode("pipe", "streaming", [factory])
648
+ );
649
+ }
650
+ /**
651
+ * Helper that creates a new sequence with the provided enumerator factory and query node.
652
+ * @param factory The factory function that produces an enumerator for the new sequence.
653
+ * @param node The query plan node associated with the new sequence.
654
+ * @returns A new TyneqSequence instance.
655
+ */
656
+ createSequence(factory, node) {
657
+ return this.createEnumerable({ getEnumerator: factory }, node);
658
+ }
659
+ /**
660
+ * Helper for creating a query node with the current sequence's node as its parent.
661
+ * @param name The name of the query node.
662
+ * @param category The category of the operator.
663
+ * @param args The arguments for the query node.
664
+ * @returns A new QueryNode instance.
665
+ */
666
+ createNode(name, category, args = []) {
667
+ return new QueryNode(name, args, this[tyneqQueryNode], category);
668
+ }
669
+ };
670
+ _init = _chunkOWKUE3ACcjs.__decoratorStart.call(void 0, null);
671
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init, 1, "orderBy", _orderBy_dec, TyneqEnumerableCore);
672
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init, 1, "orderByDescending", _orderByDescending_dec, TyneqEnumerableCore);
673
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init, 1, "memoize", _memoize_dec, TyneqEnumerableCore);
674
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init, 1, "pipe", _pipe_dec, TyneqEnumerableCore);
675
+ TyneqEnumerableCore = _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init, 0, "TyneqEnumerableCore", _TyneqEnumerableCore_decorators, TyneqEnumerableCore);
676
+ _chunkOWKUE3ACcjs.__runInitializers.call(void 0, _init, 1, TyneqEnumerableCore);
677
+
678
+ // src/core/terminal/TyneqTerminalOperator.ts
679
+ var TyneqTerminalOperator = class {
680
+ constructor(source2) {
681
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ source: source2 });
682
+ this.source = source2;
683
+ }
684
+ };
685
+
686
+ // src/operators/aggregate.ts
687
+ var AggregateOperator = class extends TyneqTerminalOperator {
688
+ constructor(source2, seed, func, resultSelector) {
689
+ super(source2);
690
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ func });
691
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ resultSelector });
692
+ this.seed = seed;
693
+ this.func = func;
694
+ this.resultSelector = resultSelector;
695
+ }
696
+ process() {
697
+ let accumulate = this.seed;
698
+ for (const item of this.source) {
699
+ accumulate = this.func(accumulate, item);
700
+ }
701
+ return this.resultSelector(accumulate);
702
+ }
703
+ };
704
+
705
+ // src/operators/all.ts
706
+ var AllOperator = class extends TyneqTerminalOperator {
707
+ constructor(source2, predicate) {
708
+ super(source2);
709
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ predicate });
710
+ this.predicate = predicate;
711
+ }
712
+ process() {
713
+ let index = 0;
714
+ for (const item of this.source) {
715
+ if (!this.predicate(item, index++)) {
716
+ return false;
717
+ }
718
+ }
719
+ return true;
720
+ }
721
+ };
722
+
723
+ // src/operators/any.ts
724
+ var AnyOperator = class extends TyneqTerminalOperator {
725
+ constructor(source2, predicate) {
726
+ super(source2);
727
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ predicate });
728
+ this.predicate = predicate;
729
+ }
730
+ process() {
731
+ let index = 0;
732
+ for (const item of this.source) {
733
+ if (this.predicate(item, index++)) {
734
+ return true;
735
+ }
736
+ }
737
+ return false;
738
+ }
739
+ };
740
+
741
+ // src/operators/average.ts
742
+ var AverageOperator = class extends TyneqTerminalOperator {
743
+ constructor(source2, selector) {
744
+ super(source2);
745
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ selector });
746
+ this.selector = selector;
747
+ }
748
+ process() {
749
+ let count = 0;
750
+ let sum = 0;
751
+ for (const item of this.source) {
752
+ sum += this.selector(item);
753
+ count++;
754
+ }
755
+ return count === 0 ? 0 : sum / count;
756
+ }
757
+ };
758
+
759
+ // src/operators/consume.ts
760
+ var ConsumeOperator = class extends TyneqTerminalOperator {
761
+ constructor(source2) {
762
+ super(source2);
763
+ }
764
+ process() {
765
+ for (const _ of this.source) {
766
+ }
767
+ }
768
+ };
769
+
770
+ // src/operators/contains.ts
771
+ var ContainsOperator = class extends TyneqTerminalOperator {
772
+ constructor(source2, value, equalityComparer) {
773
+ super(source2);
774
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotNull({ equalityComparer });
775
+ this.value = value;
776
+ this.equalityComparer = equalityComparer != null ? equalityComparer : TyneqComparer.defaultEqualityComparer;
777
+ }
778
+ process() {
779
+ for (const item of this.source) {
780
+ if (this.equalityComparer(item, this.value)) {
781
+ return true;
782
+ }
783
+ }
784
+ return false;
785
+ }
786
+ };
787
+
788
+ // src/operators/count.ts
789
+ var CountOperator = class extends TyneqTerminalOperator {
790
+ constructor(source2) {
791
+ super(source2);
792
+ }
793
+ process() {
794
+ if (Array.isArray(this.source)) {
795
+ return this.source.length;
796
+ }
797
+ let count = 0;
798
+ for (const _ of this.source) {
799
+ count++;
800
+ }
801
+ return count;
802
+ }
803
+ };
804
+
805
+ // src/operators/countBy.ts
806
+ var CountByOperator = class extends TyneqTerminalOperator {
807
+ constructor(source2, predicate) {
808
+ super(source2);
809
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ predicate });
810
+ this.predicate = predicate;
811
+ }
812
+ process() {
813
+ let count = 0;
814
+ let index = 0;
815
+ for (const item of this.source) {
816
+ if (this.predicate(item, index++)) {
817
+ count++;
818
+ }
819
+ }
820
+ return count;
821
+ }
822
+ };
823
+
824
+ // src/operators/elementAt.ts
825
+ var ElementAtOperator = class extends TyneqTerminalOperator {
826
+ constructor(source2, index) {
827
+ super(source2);
828
+ this.index = index;
829
+ }
830
+ process() {
831
+ const index = this.index;
832
+ let currentIndex = 0;
833
+ for (const element of this.source) {
834
+ if (currentIndex === index) {
835
+ return element;
836
+ }
837
+ currentIndex++;
838
+ }
839
+ throw new (0, _chunkOWKUE3ACcjs.ArgumentOutOfRangeError)(_chunkOWKUE3ACcjs.nameof.call(void 0, { index })[0]);
840
+ }
841
+ };
842
+
843
+ // src/operators/elementAtOrDefault.ts
844
+ var ElementAtOrDefaultOperator = class extends TyneqTerminalOperator {
845
+ constructor(source2, index, defaultValue) {
846
+ super(source2);
847
+ this.index = index;
848
+ this.defaultValue = defaultValue;
849
+ }
850
+ process() {
851
+ const index = this.index;
852
+ let currentIndex = 0;
853
+ for (const element of this.source) {
854
+ if (currentIndex === index) {
855
+ return element;
856
+ }
857
+ currentIndex++;
858
+ }
859
+ return this.defaultValue;
860
+ }
861
+ };
862
+
863
+ // src/core/errors/InvalidOperationError.ts
864
+ var InvalidOperationError = class extends _chunkOWKUE3ACcjs.TyneqError {
865
+ constructor(message = "The operation is invalid in the current state.", inner) {
866
+ super(message, { inner });
867
+ }
868
+ };
869
+
870
+ // src/operators/first.ts
871
+ var FirstOperator = class extends TyneqTerminalOperator {
872
+ constructor(source2, predicate) {
873
+ super(source2);
874
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ predicate });
875
+ this.predicate = predicate;
876
+ }
877
+ process() {
878
+ let index = 0;
879
+ for (const element of this.source) {
880
+ if (this.predicate(element, index++)) {
881
+ return element;
882
+ }
883
+ }
884
+ throw new InvalidOperationError("Sequence contains no matching element");
885
+ }
886
+ };
887
+
888
+ // src/operators/firstOrDefault.ts
889
+ var FirstOrDefaultOperator = class extends TyneqTerminalOperator {
890
+ constructor(source2, predicate, defaultValue) {
891
+ super(source2);
892
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ predicate });
893
+ this.predicate = predicate;
894
+ this.defaultValue = defaultValue;
895
+ }
896
+ process() {
897
+ let index = 0;
898
+ for (const element of this.source) {
899
+ if (this.predicate(element, index++)) {
900
+ return element;
901
+ }
902
+ }
903
+ return this.defaultValue;
904
+ }
905
+ };
906
+
907
+ // src/operators/indexOf.ts
908
+ var IndexOfOperator = class extends TyneqTerminalOperator {
909
+ constructor(source2, predicate, startIndex = 0) {
910
+ super(source2);
911
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ predicate });
912
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNonNegative({ startIndex });
913
+ this.predicate = predicate;
914
+ this.startIndex = startIndex;
915
+ }
916
+ process() {
917
+ let index = -1;
918
+ for (const item of this.source) {
919
+ index++;
920
+ if (index < this.startIndex) {
921
+ continue;
922
+ }
923
+ if (this.predicate(item, index)) {
924
+ return index;
925
+ }
926
+ }
927
+ return -1;
928
+ }
929
+ };
930
+
931
+ // src/utility/EnumeratorUtility.ts
932
+ var EnumeratorUtility = class {
933
+ constructor() {
934
+ }
935
+ /**
936
+ * Calls `enumerator.return()` if it exists, swallowing any error.
937
+ * Safe to call on `null` or `undefined`.
938
+ */
939
+ static tryDispose(enumerator) {
940
+ var _a6;
941
+ try {
942
+ (_a6 = enumerator == null ? void 0 : enumerator.return) == null ? void 0 : _a6.call(enumerator);
943
+ } catch (e) {
944
+ }
945
+ }
946
+ /** Wraps an `Enumerator<T>` in a minimal `Iterable<T>` adapter (no buffering). */
947
+ static toIterable(enumerator) {
948
+ return {
949
+ [Symbol.iterator]: () => enumerator
950
+ };
951
+ }
952
+ /** Gets an `Enumerator<T>` from any `Iterable<T>`. */
953
+ static fromIterable(iterable) {
954
+ return iterable[Symbol.iterator]();
955
+ }
956
+ /**
957
+ * Advances the enumerator by one position and returns `true` if that position was done.
958
+ *
959
+ * **Warning:** this calls `next()` and irrevocably consumes one element.
960
+ * If the enumerator is not exhausted, the yielded element is discarded.
961
+ * Only call this when advancing past the current position is intentional.
962
+ */
963
+ static checkAndConsume(enumerator) {
964
+ return enumerator.next().done === true;
965
+ }
966
+ };
967
+
968
+ // src/operators/isNullOrEmpty.ts
969
+ var IsNullOrEmptyOperator = class extends TyneqTerminalOperator {
970
+ constructor(source2) {
971
+ super(source2);
972
+ }
973
+ process() {
974
+ const iterator = this.source[Symbol.iterator]();
975
+ const first = iterator.next();
976
+ EnumeratorUtility.tryDispose(iterator);
977
+ return first.done === true || first.value === null || first.value === void 0;
978
+ }
979
+ };
980
+
981
+ // src/operators/last.ts
982
+ var LastOperator = class extends TyneqTerminalOperator {
983
+ constructor(source2, predicate) {
984
+ super(source2);
985
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ predicate });
986
+ this.predicate = predicate;
987
+ }
988
+ process() {
989
+ let lastMatchingElement = null;
990
+ let found = false;
991
+ let index = 0;
992
+ for (const element of this.source) {
993
+ if (this.predicate(element, index++)) {
994
+ lastMatchingElement = element;
995
+ found = true;
996
+ }
997
+ }
998
+ if (!found) {
999
+ throw new InvalidOperationError("Sequence contains no matching element");
1000
+ }
1001
+ return lastMatchingElement;
1002
+ }
1003
+ };
1004
+
1005
+ // src/operators/lastOrDefault.ts
1006
+ var LastOrDefaultOperator = class extends TyneqTerminalOperator {
1007
+ constructor(source2, predicate, defaultValue) {
1008
+ super(source2);
1009
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ predicate });
1010
+ this.predicate = predicate;
1011
+ this.defaultValue = defaultValue;
1012
+ }
1013
+ process() {
1014
+ let lastMatchingElement = null;
1015
+ let found = false;
1016
+ let index = 0;
1017
+ for (const element of this.source) {
1018
+ if (this.predicate(element, index++)) {
1019
+ lastMatchingElement = element;
1020
+ found = true;
1021
+ }
1022
+ }
1023
+ if (!found) {
1024
+ return this.defaultValue;
1025
+ }
1026
+ return lastMatchingElement;
1027
+ }
1028
+ };
1029
+
1030
+ // src/core/errors/SequenceContainsNoElementsError.ts
1031
+ var SequenceContainsNoElementsError = class extends InvalidOperationError {
1032
+ constructor(operatorName, inner) {
1033
+ const message = operatorName ? `Sequence contains no elements (in "${operatorName}").` : "Sequence contains no elements.";
1034
+ super(message, inner);
1035
+ this.operatorName = operatorName;
1036
+ }
1037
+ };
1038
+
1039
+ // src/operators/extremum.ts
1040
+ var ExtremumOperator = class extends TyneqTerminalOperator {
1041
+ constructor(source2, direction, operatorName, comparer) {
1042
+ super(source2);
1043
+ this.comparer = comparer != null ? comparer : TyneqComparer.defaultComparer;
1044
+ this.direction = direction;
1045
+ this.operatorName = operatorName;
1046
+ }
1047
+ process() {
1048
+ let best = null;
1049
+ let hasElement = false;
1050
+ for (const element of this.source) {
1051
+ if (!hasElement || this.comparer(element, best) * this.direction > 0) {
1052
+ best = element;
1053
+ hasElement = true;
1054
+ }
1055
+ }
1056
+ if (!hasElement) {
1057
+ throw new SequenceContainsNoElementsError(this.operatorName);
1058
+ }
1059
+ return best;
1060
+ }
1061
+ };
1062
+ var ExtremumByOperator = class extends TyneqTerminalOperator {
1063
+ constructor(source2, keySelector, direction, operatorName, comparer) {
1064
+ super(source2);
1065
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ keySelector });
1066
+ this.comparer = comparer != null ? comparer : TyneqComparer.defaultComparer;
1067
+ this.keySelector = keySelector;
1068
+ this.direction = direction;
1069
+ this.operatorName = operatorName;
1070
+ }
1071
+ process() {
1072
+ let bestElement = null;
1073
+ let bestKey = null;
1074
+ let hasElement = false;
1075
+ for (const element of this.source) {
1076
+ const key = this.keySelector(element);
1077
+ if (!hasElement || this.comparer(key, bestKey) * this.direction > 0) {
1078
+ bestElement = element;
1079
+ bestKey = key;
1080
+ hasElement = true;
1081
+ }
1082
+ }
1083
+ if (!hasElement) {
1084
+ throw new SequenceContainsNoElementsError(this.operatorName);
1085
+ }
1086
+ return bestElement;
1087
+ }
1088
+ };
1089
+
1090
+ // src/operators/minMax.ts
1091
+ var MinMaxOperator = class extends TyneqTerminalOperator {
1092
+ constructor(source2, comparer) {
1093
+ super(source2);
1094
+ this.comparer = comparer != null ? comparer : TyneqComparer.defaultComparer;
1095
+ }
1096
+ process() {
1097
+ let min;
1098
+ let max;
1099
+ let hasElements = false;
1100
+ for (const item of this.source) {
1101
+ if (!hasElements) {
1102
+ min = item;
1103
+ max = item;
1104
+ hasElements = true;
1105
+ } else {
1106
+ if (this.comparer(item, min) < 0) min = item;
1107
+ if (this.comparer(item, max) > 0) max = item;
1108
+ }
1109
+ }
1110
+ if (!hasElements) {
1111
+ throw new SequenceContainsNoElementsError("minMax");
1112
+ }
1113
+ return { min, max };
1114
+ }
1115
+ };
1116
+
1117
+ // src/operators/sequenceEqual.ts
1118
+ var SequenceEqualOperator = class extends TyneqTerminalOperator {
1119
+ constructor(source2, other, equalityComparer) {
1120
+ super(source2);
1121
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ other });
1122
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotNull({ equalityComparer });
1123
+ this.equalityComparer = equalityComparer != null ? equalityComparer : TyneqComparer.defaultEqualityComparer;
1124
+ this.other = other;
1125
+ }
1126
+ process() {
1127
+ const sourceIterator = this.source[Symbol.iterator]();
1128
+ const otherIterator = this.other[Symbol.iterator]();
1129
+ while (true) {
1130
+ const sourceNext = sourceIterator.next();
1131
+ const otherNext = otherIterator.next();
1132
+ if (sourceNext.done && otherNext.done) {
1133
+ break;
1134
+ }
1135
+ if (sourceNext.done !== otherNext.done) {
1136
+ return false;
1137
+ }
1138
+ if (!this.equalityComparer(sourceNext.value, otherNext.value)) {
1139
+ return false;
1140
+ }
1141
+ }
1142
+ return true;
1143
+ }
1144
+ };
1145
+
1146
+ // src/operators/single.ts
1147
+ var SingleOperator = class extends TyneqTerminalOperator {
1148
+ constructor(source2, predicate) {
1149
+ super(source2);
1150
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ predicate });
1151
+ this.predicate = predicate;
1152
+ }
1153
+ process() {
1154
+ let found = false;
1155
+ let single = null;
1156
+ let index = 0;
1157
+ for (const element of this.source) {
1158
+ if (this.predicate(element, index++)) {
1159
+ if (found) {
1160
+ throw new InvalidOperationError("Sequence contains more than one matching element");
1161
+ }
1162
+ found = true;
1163
+ single = element;
1164
+ }
1165
+ }
1166
+ if (!found) {
1167
+ throw new InvalidOperationError("Sequence contains no matching element");
1168
+ }
1169
+ return single;
1170
+ }
1171
+ };
1172
+
1173
+ // src/operators/singleOrDefault.ts
1174
+ var SingleOrDefaultOperator = class extends TyneqTerminalOperator {
1175
+ constructor(source2, predicate, defaultValue) {
1176
+ super(source2);
1177
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ predicate });
1178
+ this.predicate = predicate;
1179
+ this.defaultValue = defaultValue;
1180
+ }
1181
+ process() {
1182
+ let found = false;
1183
+ let single = null;
1184
+ let index = 0;
1185
+ for (const element of this.source) {
1186
+ if (this.predicate(element, index++)) {
1187
+ if (found) {
1188
+ throw new InvalidOperationError("Sequence contains more than one matching element");
1189
+ }
1190
+ found = true;
1191
+ single = element;
1192
+ }
1193
+ }
1194
+ if (!found) {
1195
+ return this.defaultValue;
1196
+ }
1197
+ return single;
1198
+ }
1199
+ };
1200
+
1201
+ // src/operators/endsWith.ts
1202
+ var EndsWithOperator = class extends TyneqTerminalOperator {
1203
+ constructor(source2, sequence2, equalityComparer) {
1204
+ super(source2);
1205
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ sequence: sequence2 });
1206
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkIterable({ sequence: sequence2 });
1207
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotNull({ equalityComparer });
1208
+ this.sequence = sequence2;
1209
+ this.equalityComparer = equalityComparer != null ? equalityComparer : TyneqComparer.defaultEqualityComparer;
1210
+ }
1211
+ process() {
1212
+ const suffixElements = Array.from(this.sequence);
1213
+ if (suffixElements.length === 0) {
1214
+ return true;
1215
+ }
1216
+ const bufferResult = this.fillCircularBuffer(this.source, suffixElements.length);
1217
+ if (bufferResult === null) {
1218
+ return false;
1219
+ }
1220
+ const { buffer, readIndex } = bufferResult;
1221
+ for (let i = 0; i < suffixElements.length; i++) {
1222
+ if (!this.equalityComparer(buffer[(readIndex + i) % buffer.length], suffixElements[i])) {
1223
+ return false;
1224
+ }
1225
+ }
1226
+ return true;
1227
+ }
1228
+ fillCircularBuffer(elements, windowSize) {
1229
+ const buffer = new Array(windowSize);
1230
+ let writeIndex = 0;
1231
+ for (const item of elements) {
1232
+ buffer[writeIndex % windowSize] = item;
1233
+ writeIndex++;
1234
+ }
1235
+ if (writeIndex < windowSize) {
1236
+ return null;
1237
+ }
1238
+ return { buffer, readIndex: writeIndex % windowSize };
1239
+ }
1240
+ };
1241
+
1242
+ // src/operators/startsWith.ts
1243
+ var StartsWithOperator = class extends TyneqTerminalOperator {
1244
+ constructor(source2, sequence2, equalityComparer) {
1245
+ super(source2);
1246
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ sequence: sequence2 });
1247
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkIterable({ sequence: sequence2 });
1248
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotNull({ equalityComparer });
1249
+ this.sequence = sequence2;
1250
+ this.equalityComparer = equalityComparer != null ? equalityComparer : TyneqComparer.defaultEqualityComparer;
1251
+ }
1252
+ process() {
1253
+ const sourceEnumerator = this.source[Symbol.iterator]();
1254
+ const sequenceEnumerator = this.sequence[Symbol.iterator]();
1255
+ while (true) {
1256
+ const { value: sourceValue, done: sourceDone } = sourceEnumerator.next();
1257
+ const { value: sequenceValue, done: sequenceDone } = sequenceEnumerator.next();
1258
+ if (sequenceDone) {
1259
+ return true;
1260
+ }
1261
+ if (sourceDone || !this.equalityComparer(sourceValue, sequenceValue)) {
1262
+ return false;
1263
+ }
1264
+ }
1265
+ }
1266
+ };
1267
+
1268
+ // src/operators/sum.ts
1269
+ var SumOperator = class extends TyneqTerminalOperator {
1270
+ constructor(source2, selector) {
1271
+ super(source2);
1272
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ selector });
1273
+ this.selector = selector;
1274
+ }
1275
+ process() {
1276
+ let sum = 0;
1277
+ for (const item of this.source) {
1278
+ sum += this.selector(item);
1279
+ }
1280
+ return sum;
1281
+ }
1282
+ };
1283
+
1284
+ // src/operators/toArray.ts
1285
+ var ToArrayOperator = class extends TyneqTerminalOperator {
1286
+ constructor(source2) {
1287
+ super(source2);
1288
+ }
1289
+ process() {
1290
+ return Array.from(this.source);
1291
+ }
1292
+ };
1293
+
1294
+ // src/operators/toAsync.ts
1295
+ var ToAsyncOperator = class extends TyneqTerminalOperator {
1296
+ constructor(source2) {
1297
+ super(source2);
1298
+ }
1299
+ process() {
1300
+ const source2 = this.source;
1301
+ return {
1302
+ [Symbol.asyncIterator]() {
1303
+ return _chunkOWKUE3ACcjs.__asyncGenerator.call(void 0, this, null, function* () {
1304
+ for (const item of source2) {
1305
+ yield item;
1306
+ }
1307
+ });
1308
+ }
1309
+ };
1310
+ }
1311
+ };
1312
+
1313
+ // src/operators/toMap.ts
1314
+ var ToMapOperator = class extends TyneqTerminalOperator {
1315
+ constructor(source2, selector) {
1316
+ super(source2);
1317
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ selector });
1318
+ this.selector = selector;
1319
+ }
1320
+ process() {
1321
+ return new Map(Array.from(this.source, (item) => {
1322
+ const pair = this.selector(item);
1323
+ return this.transformPairToTuple(pair);
1324
+ }));
1325
+ }
1326
+ transformPairToTuple(pair) {
1327
+ return [pair.key, pair.value];
1328
+ }
1329
+ };
1330
+
1331
+ // src/operators/toRecord.ts
1332
+ var ToRecordOperator = class extends TyneqTerminalOperator {
1333
+ constructor(source2, selector) {
1334
+ super(source2);
1335
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ selector });
1336
+ this.selector = selector;
1337
+ }
1338
+ process() {
1339
+ const result = {};
1340
+ for (const item of this.source) {
1341
+ const pair = this.selector(item);
1342
+ result[pair.key] = pair.value;
1343
+ }
1344
+ return result;
1345
+ }
1346
+ };
1347
+
1348
+ // src/operators/toSet.ts
1349
+ var ToSetOperator = class extends TyneqTerminalOperator {
1350
+ constructor(source2) {
1351
+ super(source2);
1352
+ }
1353
+ process() {
1354
+ return new Set(this.source);
1355
+ }
1356
+ };
1357
+
1358
+ // src/core/enumerators/TyneqEnumerator.ts
1359
+ var TyneqEnumerator = class extends TyneqBaseEnumerator {
1360
+ constructor(sourceEnumerator) {
1361
+ super();
1362
+ this.sourceDisposed = false;
1363
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ sourceEnumerator });
1364
+ this.sourceEnumerator = sourceEnumerator;
1365
+ }
1366
+ disposeSource() {
1367
+ if (this.sourceDisposed) {
1368
+ return;
1369
+ }
1370
+ this.sourceDisposed = true;
1371
+ EnumeratorUtility.tryDispose(this.sourceEnumerator);
1372
+ }
1373
+ };
1374
+
1375
+ // src/enumerators/streaming/append.ts
1376
+ var AppendEnumerator = class extends TyneqEnumerator {
1377
+ constructor(sourceEnumerator, item) {
1378
+ super(sourceEnumerator);
1379
+ this.isSourceDone = false;
1380
+ this.appended = false;
1381
+ this.item = item;
1382
+ }
1383
+ handleNext() {
1384
+ if (!this.isSourceDone) {
1385
+ const sourceNext = this.sourceEnumerator.next();
1386
+ if (!sourceNext.done) {
1387
+ return this.yield(sourceNext.value);
1388
+ }
1389
+ this.isSourceDone = true;
1390
+ }
1391
+ if (!this.appended) {
1392
+ this.appended = true;
1393
+ return this.yield(this.item);
1394
+ }
1395
+ return this.done();
1396
+ }
1397
+ };
1398
+
1399
+ // src/enumerators/streaming/chunk.ts
1400
+ var ChunkEnumerator = class extends TyneqEnumerator {
1401
+ constructor(sourceEnumerator, size) {
1402
+ super(sourceEnumerator);
1403
+ this.currentChunk = [];
1404
+ this.size = size;
1405
+ }
1406
+ handleNext() {
1407
+ while (this.currentChunk.length < this.size) {
1408
+ const next = this.sourceEnumerator.next();
1409
+ if (next.done) break;
1410
+ this.currentChunk.push(next.value);
1411
+ }
1412
+ if (this.currentChunk.length === 0) {
1413
+ return this.done();
1414
+ }
1415
+ const chunk = this.currentChunk;
1416
+ this.currentChunk = [];
1417
+ return this.yield(chunk);
1418
+ }
1419
+ };
1420
+
1421
+ // src/enumerators/streaming/concat.ts
1422
+ var ConcatEnumerator = class extends TyneqEnumerator {
1423
+ constructor(sourceEnumerator, other) {
1424
+ super(sourceEnumerator);
1425
+ this.isSourceDone = false;
1426
+ this.otherEnumerator = other[Symbol.iterator]();
1427
+ }
1428
+ disposeAdditional() {
1429
+ EnumeratorUtility.tryDispose(this.otherEnumerator);
1430
+ }
1431
+ handleNext() {
1432
+ if (!this.isSourceDone) {
1433
+ const next2 = this.sourceEnumerator.next();
1434
+ if (!next2.done) {
1435
+ return this.yield(next2.value);
1436
+ }
1437
+ this.isSourceDone = true;
1438
+ }
1439
+ const next = this.otherEnumerator.next();
1440
+ if (!next.done) {
1441
+ return this.yield(next.value);
1442
+ }
1443
+ return this.done();
1444
+ }
1445
+ };
1446
+
1447
+ // src/enumerators/streaming/flatten.ts
1448
+ var FlattenEnumerator = class extends TyneqEnumerator {
1449
+ constructor(sourceEnumerator) {
1450
+ super(sourceEnumerator);
1451
+ this.innerEnumerator = null;
1452
+ }
1453
+ handleNext() {
1454
+ while (true) {
1455
+ if (this.innerEnumerator !== null) {
1456
+ const innerNext = this.innerEnumerator.next();
1457
+ if (!innerNext.done) {
1458
+ return this.yield(innerNext.value);
1459
+ }
1460
+ this.innerEnumerator = null;
1461
+ }
1462
+ const sourceNext = this.sourceEnumerator.next();
1463
+ if (sourceNext.done) {
1464
+ return this.done();
1465
+ }
1466
+ this.innerEnumerator = sourceNext.value[Symbol.iterator]();
1467
+ }
1468
+ }
1469
+ };
1470
+
1471
+ // src/enumerators/streaming/defaultIfEmpty.ts
1472
+ var DefaultIfEmptyEnumerator = class extends TyneqEnumerator {
1473
+ constructor(sourceEnumerator, defaultValue) {
1474
+ super(sourceEnumerator);
1475
+ this.sourceDone = false;
1476
+ this.hasYieldedAny = false;
1477
+ this.defaultYielded = false;
1478
+ this.defaultValue = defaultValue;
1479
+ }
1480
+ handleNext() {
1481
+ if (!this.sourceDone) {
1482
+ const next = this.sourceEnumerator.next();
1483
+ if (!next.done) {
1484
+ this.hasYieldedAny = true;
1485
+ return this.yield(next.value);
1486
+ }
1487
+ this.sourceDone = true;
1488
+ }
1489
+ if (!this.hasYieldedAny && !this.defaultYielded) {
1490
+ this.defaultYielded = true;
1491
+ return this.doneWithYield(this.defaultValue);
1492
+ }
1493
+ return this.done();
1494
+ }
1495
+ };
1496
+
1497
+ // src/enumerators/streaming/ofType.ts
1498
+ var OfTypeEnumerator = class extends TyneqEnumerator {
1499
+ constructor(sourceEnumerator, guard) {
1500
+ super(sourceEnumerator);
1501
+ this.guard = guard;
1502
+ }
1503
+ handleNext() {
1504
+ while (true) {
1505
+ const { value, done } = this.sourceEnumerator.next();
1506
+ if (done) {
1507
+ return this.done();
1508
+ }
1509
+ if (this.guard(value)) {
1510
+ return this.yield(value);
1511
+ }
1512
+ }
1513
+ }
1514
+ };
1515
+
1516
+ // src/enumerators/streaming/pairwise.ts
1517
+ var PairwiseEnumerator = class extends TyneqEnumerator {
1518
+ constructor(sourceEnumerator) {
1519
+ super(sourceEnumerator);
1520
+ this.hasPrevious = false;
1521
+ }
1522
+ handleNext() {
1523
+ while (true) {
1524
+ const next = this.sourceEnumerator.next();
1525
+ if (next.done) {
1526
+ return this.done();
1527
+ }
1528
+ if (!this.hasPrevious) {
1529
+ this.previous = next.value;
1530
+ this.hasPrevious = true;
1531
+ continue;
1532
+ }
1533
+ const pair = [this.previous, next.value];
1534
+ this.previous = next.value;
1535
+ return this.yield(pair);
1536
+ }
1537
+ }
1538
+ };
1539
+
1540
+ // src/enumerators/streaming/populate.ts
1541
+ var PopulateEnumerator = class extends TyneqEnumerator {
1542
+ constructor(sourceEnumerator, value) {
1543
+ super(sourceEnumerator);
1544
+ this.value = value;
1545
+ }
1546
+ handleNext() {
1547
+ while (true) {
1548
+ const { done } = this.sourceEnumerator.next();
1549
+ if (done) {
1550
+ return this.done();
1551
+ }
1552
+ return this.yield(this.value);
1553
+ }
1554
+ }
1555
+ };
1556
+
1557
+ // src/enumerators/streaming/prepend.ts
1558
+ var PrependEnumerator = class extends TyneqEnumerator {
1559
+ constructor(sourceEnumerator, item) {
1560
+ super(sourceEnumerator);
1561
+ this.prepended = false;
1562
+ this.item = item;
1563
+ }
1564
+ handleNext() {
1565
+ if (!this.prepended) {
1566
+ this.prepended = true;
1567
+ return this.yield(this.item);
1568
+ }
1569
+ const nextItem = this.sourceEnumerator.next();
1570
+ if (!nextItem.done) {
1571
+ return this.yield(nextItem.value);
1572
+ }
1573
+ return this.done();
1574
+ }
1575
+ };
1576
+
1577
+ // src/enumerators/streaming/scan.ts
1578
+ var ScanEnumerator = class extends TyneqEnumerator {
1579
+ constructor(sourceEnumerator, seed, accumulator) {
1580
+ super(sourceEnumerator);
1581
+ this.current = seed;
1582
+ this.accumulator = accumulator;
1583
+ }
1584
+ handleNext() {
1585
+ const { value, done } = this.sourceEnumerator.next();
1586
+ if (done) {
1587
+ return this.done();
1588
+ }
1589
+ this.current = this.accumulator(this.current, value);
1590
+ return this.yield(this.current);
1591
+ }
1592
+ };
1593
+
1594
+ // src/enumerators/streaming/select.ts
1595
+ var SelectEnumerator = class extends TyneqEnumerator {
1596
+ constructor(sourceEnumerator, selector) {
1597
+ super(sourceEnumerator);
1598
+ this.index = 0;
1599
+ this.selector = selector;
1600
+ }
1601
+ handleNext() {
1602
+ const next = this.sourceEnumerator.next();
1603
+ if (next.done) {
1604
+ return this.done();
1605
+ }
1606
+ return this.yield(this.selector(next.value, this.index++));
1607
+ }
1608
+ };
1609
+
1610
+ // src/enumerators/streaming/selectMany.ts
1611
+ var SelectManyEnumerator = class extends TyneqEnumerator {
1612
+ constructor(sourceEnumerator, selector) {
1613
+ super(sourceEnumerator);
1614
+ this.innerEnumerator = null;
1615
+ this.selector = selector;
1616
+ }
1617
+ handleNext() {
1618
+ while (true) {
1619
+ if (this.innerEnumerator !== null) {
1620
+ const innerNext = this.innerEnumerator.next();
1621
+ if (!innerNext.done) {
1622
+ return this.yield(innerNext.value);
1623
+ }
1624
+ this.innerEnumerator = null;
1625
+ }
1626
+ const sourceNext = this.sourceEnumerator.next();
1627
+ if (sourceNext.done) {
1628
+ return this.done();
1629
+ }
1630
+ this.innerEnumerator = this.selector(sourceNext.value)[Symbol.iterator]();
1631
+ }
1632
+ }
1633
+ };
1634
+
1635
+ // src/enumerators/streaming/repeatSequence.ts
1636
+ var RepeatSequenceEnumerator = class extends TyneqEnumerator {
1637
+ constructor(sourceEnumerator, source2, count) {
1638
+ super(sourceEnumerator);
1639
+ this.repetition = 0;
1640
+ this.source = source2;
1641
+ this.count = count;
1642
+ this.currentEnumerator = sourceEnumerator;
1643
+ }
1644
+ disposeAdditional() {
1645
+ if (this.currentEnumerator !== this.sourceEnumerator) {
1646
+ EnumeratorUtility.tryDispose(this.currentEnumerator);
1647
+ }
1648
+ }
1649
+ handleNext() {
1650
+ while (this.repetition < this.count) {
1651
+ const next = this.currentEnumerator.next();
1652
+ if (!next.done) {
1653
+ return this.yield(next.value);
1654
+ }
1655
+ this.repetition++;
1656
+ if (this.repetition < this.count) {
1657
+ const fresh = this.source[Symbol.iterator]();
1658
+ const probe = fresh.next();
1659
+ if (probe.done) {
1660
+ this.repetition = this.count;
1661
+ return this.done();
1662
+ }
1663
+ this.currentEnumerator = fresh;
1664
+ return this.yield(probe.value);
1665
+ }
1666
+ }
1667
+ return this.done();
1668
+ }
1669
+ };
1670
+
1671
+ // src/enumerators/streaming/skip.ts
1672
+ var SkipEnumerator = class extends TyneqEnumerator {
1673
+ constructor(sourceEnumerator, count) {
1674
+ super(sourceEnumerator);
1675
+ this.skipped = false;
1676
+ this.count = count;
1677
+ }
1678
+ handleNext() {
1679
+ if (!this.skipped) {
1680
+ let skippedCount = 0;
1681
+ while (skippedCount < this.count) {
1682
+ const sourceNext2 = this.sourceEnumerator.next();
1683
+ if (sourceNext2.done) {
1684
+ return this.done();
1685
+ }
1686
+ skippedCount++;
1687
+ }
1688
+ this.skipped = true;
1689
+ }
1690
+ const sourceNext = this.sourceEnumerator.next();
1691
+ if (sourceNext.done) {
1692
+ return this.done();
1693
+ }
1694
+ return this.yield(sourceNext.value);
1695
+ }
1696
+ };
1697
+
1698
+ // src/enumerators/streaming/skipLast.ts
1699
+ var SkipLastEnumerator = class extends TyneqEnumerator {
1700
+ constructor(sourceEnumerator, count) {
1701
+ super(sourceEnumerator);
1702
+ this.writeIndex = 0;
1703
+ this.filledCount = 0;
1704
+ this.count = count;
1705
+ this.buffer = new Array(this.count);
1706
+ }
1707
+ handleNext() {
1708
+ if (this.count === 0) {
1709
+ const current = this.sourceEnumerator.next();
1710
+ if (current.done) {
1711
+ return this.done();
1712
+ } else {
1713
+ return this.yield(current.value);
1714
+ }
1715
+ }
1716
+ while (true) {
1717
+ const current = this.sourceEnumerator.next();
1718
+ if (current.done) {
1719
+ return this.done();
1720
+ }
1721
+ if (this.filledCount < this.count) {
1722
+ this.buffer[this.writeIndex] = current.value;
1723
+ this.writeIndex = (this.writeIndex + 1) % this.count;
1724
+ this.filledCount++;
1725
+ continue;
1726
+ }
1727
+ const oldest = this.buffer[this.writeIndex];
1728
+ this.buffer[this.writeIndex] = current.value;
1729
+ this.writeIndex = (this.writeIndex + 1) % this.count;
1730
+ return this.yield(oldest);
1731
+ }
1732
+ }
1733
+ };
1734
+
1735
+ // src/enumerators/streaming/skipUntil.ts
1736
+ var SkipUntilEnumerator = class extends TyneqEnumerator {
1737
+ constructor(sourceEnumerator, predicate) {
1738
+ super(sourceEnumerator);
1739
+ this.index = 0;
1740
+ this.triggered = false;
1741
+ this.predicate = predicate;
1742
+ }
1743
+ handleNext() {
1744
+ while (true) {
1745
+ const next = this.sourceEnumerator.next();
1746
+ if (next.done) {
1747
+ return this.done();
1748
+ }
1749
+ if (!this.triggered) {
1750
+ this.triggered = this.predicate(next.value, this.index++);
1751
+ }
1752
+ if (this.triggered) {
1753
+ return this.yield(next.value);
1754
+ }
1755
+ }
1756
+ }
1757
+ };
1758
+
1759
+ // src/enumerators/streaming/skipWhile.ts
1760
+ var SkipWhileEnumerator = class extends TyneqEnumerator {
1761
+ constructor(sourceEnumerator, predicate) {
1762
+ super(sourceEnumerator);
1763
+ this.index = 0;
1764
+ this.isSkipping = true;
1765
+ this.predicate = predicate;
1766
+ }
1767
+ handleNext() {
1768
+ while (true) {
1769
+ const next = this.sourceEnumerator.next();
1770
+ if (next.done) {
1771
+ return this.done();
1772
+ }
1773
+ this.isSkipping = this.isSkipping && this.predicate(next.value, this.index++);
1774
+ if (!this.isSkipping) {
1775
+ return this.yield(next.value);
1776
+ }
1777
+ }
1778
+ }
1779
+ };
1780
+
1781
+ // src/enumerators/streaming/slice.ts
1782
+ var SliceEnumerator = class extends TyneqEnumerator {
1783
+ constructor(sourceEnumerator, start, end) {
1784
+ super(sourceEnumerator);
1785
+ this.index = 0;
1786
+ this.started = false;
1787
+ this.start = start;
1788
+ this.end = end;
1789
+ }
1790
+ handleNext() {
1791
+ if (!this.started) {
1792
+ this.started = true;
1793
+ while (this.index < this.start) {
1794
+ if (this.sourceEnumerator.next().done) {
1795
+ return this.done();
1796
+ }
1797
+ this.index++;
1798
+ }
1799
+ }
1800
+ if (this.index >= this.end) {
1801
+ return this.earlyComplete();
1802
+ }
1803
+ const next = this.sourceEnumerator.next();
1804
+ if (next.done) {
1805
+ return this.done();
1806
+ }
1807
+ this.index++;
1808
+ return this.yield(next.value);
1809
+ }
1810
+ };
1811
+
1812
+ // src/enumerators/streaming/split.ts
1813
+ var SplitEnumerator = class extends TyneqEnumerator {
1814
+ constructor(sourceEnumerator, splitOn) {
1815
+ super(sourceEnumerator);
1816
+ this.splitOn = splitOn;
1817
+ }
1818
+ handleNext() {
1819
+ const currentSplit = [];
1820
+ while (true) {
1821
+ const { value, done } = this.sourceEnumerator.next();
1822
+ if (done) {
1823
+ if (currentSplit.length > 0) {
1824
+ return this.doneWithYield(currentSplit);
1825
+ }
1826
+ return this.done();
1827
+ }
1828
+ if (this.splitOn(value)) {
1829
+ if (currentSplit.length > 0) {
1830
+ return this.yield(currentSplit);
1831
+ }
1832
+ } else {
1833
+ currentSplit.push(value);
1834
+ }
1835
+ }
1836
+ }
1837
+ };
1838
+
1839
+ // src/enumerators/streaming/take.ts
1840
+ var TakeEnumerator = class extends TyneqEnumerator {
1841
+ constructor(sourceEnumerator, count) {
1842
+ super(sourceEnumerator);
1843
+ this.takenCount = 0;
1844
+ this.count = count;
1845
+ }
1846
+ handleNext() {
1847
+ if (this.takenCount >= this.count) {
1848
+ return this.earlyComplete();
1849
+ }
1850
+ const result = this.sourceEnumerator.next();
1851
+ if (result.done) {
1852
+ return this.done();
1853
+ }
1854
+ this.takenCount++;
1855
+ return this.yield(result.value);
1856
+ }
1857
+ };
1858
+
1859
+ // src/enumerators/streaming/takeUntil.ts
1860
+ var TakeUntilEnumerator = class extends TyneqEnumerator {
1861
+ constructor(sourceEnumerator, predicate) {
1862
+ super(sourceEnumerator);
1863
+ this.index = 0;
1864
+ this.predicate = predicate;
1865
+ }
1866
+ handleNext() {
1867
+ const next = this.sourceEnumerator.next();
1868
+ if (next.done) {
1869
+ return this.done();
1870
+ }
1871
+ if (this.predicate(next.value, this.index++)) {
1872
+ return this.earlyComplete();
1873
+ }
1874
+ return this.yield(next.value);
1875
+ }
1876
+ };
1877
+
1878
+ // src/enumerators/streaming/takeWhile.ts
1879
+ var TakeWhileEnumerator = class extends TyneqEnumerator {
1880
+ constructor(sourceEnumerator, predicate) {
1881
+ super(sourceEnumerator);
1882
+ this.index = 0;
1883
+ this.predicate = predicate;
1884
+ }
1885
+ handleNext() {
1886
+ const result = this.sourceEnumerator.next();
1887
+ if (result.done) {
1888
+ return this.done();
1889
+ }
1890
+ if (this.predicate(result.value, this.index++)) {
1891
+ return this.yield(result.value);
1892
+ }
1893
+ return this.earlyComplete();
1894
+ }
1895
+ };
1896
+
1897
+ // src/enumerators/streaming/tap.ts
1898
+ var TapEnumerator = class extends TyneqEnumerator {
1899
+ constructor(sourceEnumerator, action) {
1900
+ super(sourceEnumerator);
1901
+ this.index = 0;
1902
+ this.action = action;
1903
+ }
1904
+ handleNext() {
1905
+ const next = this.sourceEnumerator.next();
1906
+ if (next.done) {
1907
+ return this.done();
1908
+ }
1909
+ this.action(next.value, this.index++);
1910
+ return this.yield(next.value);
1911
+ }
1912
+ };
1913
+
1914
+ // src/enumerators/streaming/tapIf.ts
1915
+ var TapIfEnumerator = class extends TyneqEnumerator {
1916
+ constructor(sourceEnumerator, action, predicate) {
1917
+ super(sourceEnumerator);
1918
+ this.index = 0;
1919
+ this.action = action;
1920
+ this.predicate = predicate;
1921
+ }
1922
+ handleNext() {
1923
+ const next = this.sourceEnumerator.next();
1924
+ if (next.done) {
1925
+ return this.done();
1926
+ }
1927
+ if (this.predicate()) {
1928
+ this.action(next.value, this.index);
1929
+ }
1930
+ this.index++;
1931
+ return this.yield(next.value);
1932
+ }
1933
+ };
1934
+
1935
+ // src/enumerators/streaming/throttle.ts
1936
+ var ThrottleEnumerator = class extends TyneqEnumerator {
1937
+ constructor(sourceEnumerator, count) {
1938
+ super(sourceEnumerator);
1939
+ this.index = -1;
1940
+ this.count = count;
1941
+ }
1942
+ handleNext() {
1943
+ while (true) {
1944
+ const { value, done } = this.sourceEnumerator.next();
1945
+ if (done) {
1946
+ return this.done();
1947
+ }
1948
+ this.index++;
1949
+ if (this.index % this.count === 0) {
1950
+ return this.yield(value);
1951
+ }
1952
+ }
1953
+ }
1954
+ };
1955
+
1956
+ // src/enumerators/streaming/where.ts
1957
+ var WhereEnumerator = class extends TyneqEnumerator {
1958
+ constructor(sourceEnumerator, predicate) {
1959
+ super(sourceEnumerator);
1960
+ this.index = 0;
1961
+ this.predicate = predicate;
1962
+ }
1963
+ handleNext() {
1964
+ while (true) {
1965
+ const { value, done } = this.sourceEnumerator.next();
1966
+ if (done) {
1967
+ return this.done();
1968
+ }
1969
+ if (this.predicate(value, this.index++)) {
1970
+ return this.yield(value);
1971
+ }
1972
+ }
1973
+ }
1974
+ };
1975
+
1976
+ // src/enumerators/streaming/window.ts
1977
+ var WindowEnumerator = class extends TyneqEnumerator {
1978
+ constructor(sourceEnumerator, size, step) {
1979
+ super(sourceEnumerator);
1980
+ this.buffer = [];
1981
+ this.started = false;
1982
+ this.size = size;
1983
+ this.step = step;
1984
+ }
1985
+ handleNext() {
1986
+ if (!this.started) {
1987
+ this.started = true;
1988
+ while (this.buffer.length < this.size) {
1989
+ const next = this.sourceEnumerator.next();
1990
+ if (next.done) {
1991
+ return this.done();
1992
+ }
1993
+ this.buffer.push(next.value);
1994
+ }
1995
+ return this.yield(this.buffer.slice());
1996
+ }
1997
+ if (this.step <= this.size) {
1998
+ this.buffer = this.buffer.slice(this.step);
1999
+ } else {
2000
+ this.buffer = [];
2001
+ const toSkip = this.step - this.size;
2002
+ for (let i = 0; i < toSkip; i++) {
2003
+ if (this.sourceEnumerator.next().done) {
2004
+ return this.done();
2005
+ }
2006
+ }
2007
+ }
2008
+ while (this.buffer.length < this.size) {
2009
+ const next = this.sourceEnumerator.next();
2010
+ if (next.done) {
2011
+ return this.done();
2012
+ }
2013
+ this.buffer.push(next.value);
2014
+ }
2015
+ return this.yield(this.buffer.slice());
2016
+ }
2017
+ };
2018
+
2019
+ // src/enumerators/streaming/zip.ts
2020
+ var ZipEnumerator = class extends TyneqEnumerator {
2021
+ constructor(sourceEnumerator, other, selector) {
2022
+ super(sourceEnumerator);
2023
+ this.otherEnumerator = other[Symbol.iterator]();
2024
+ this.selector = selector;
2025
+ }
2026
+ handleNext() {
2027
+ const first = this.sourceEnumerator.next();
2028
+ if (first.done) {
2029
+ this.disposeAdditional();
2030
+ return this.done();
2031
+ }
2032
+ const second = this.otherEnumerator.next();
2033
+ if (second.done) {
2034
+ return this.earlyComplete();
2035
+ }
2036
+ return this.yield(this.selector(first.value, second.value));
2037
+ }
2038
+ disposeAdditional() {
2039
+ EnumeratorUtility.tryDispose(this.otherEnumerator);
2040
+ }
2041
+ };
2042
+
2043
+ // src/enumerators/buffer/backsert.ts
2044
+ var BacksertEnumerator = class extends TyneqEnumerator {
2045
+ constructor(sourceEnumerator, backIndex, other) {
2046
+ super(sourceEnumerator);
2047
+ this.buffer = [];
2048
+ this.current = 0;
2049
+ this.backIndex = backIndex;
2050
+ this.other = other;
2051
+ }
2052
+ initialize() {
2053
+ const source2 = Array.from(EnumeratorUtility.toIterable(this.sourceEnumerator));
2054
+ const other = Array.from(this.other);
2055
+ const insertionIndex = Math.max(0, source2.length - this.backIndex);
2056
+ this.buffer = [
2057
+ ...source2.slice(0, insertionIndex),
2058
+ ...other,
2059
+ ...source2.slice(insertionIndex)
2060
+ ];
2061
+ this.current = 0;
2062
+ }
2063
+ handleNext() {
2064
+ if (this.current >= this.buffer.length) {
2065
+ return this.done();
2066
+ }
2067
+ return this.yield(this.buffer[this.current++]);
2068
+ }
2069
+ };
2070
+
2071
+ // src/enumerators/buffer/distinct.ts
2072
+ var DistinctEnumerator = class extends TyneqEnumerator {
2073
+ constructor(sourceEnumerator) {
2074
+ super(sourceEnumerator);
2075
+ this.seenValues = /* @__PURE__ */ new Set();
2076
+ }
2077
+ handleNext() {
2078
+ while (true) {
2079
+ const { done, value } = this.sourceEnumerator.next();
2080
+ if (done) {
2081
+ return this.done();
2082
+ }
2083
+ if (!this.seenValues.has(value)) {
2084
+ this.seenValues.add(value);
2085
+ return this.yield(value);
2086
+ }
2087
+ }
2088
+ }
2089
+ };
2090
+
2091
+ // src/enumerators/buffer/distinctBy.ts
2092
+ var DistinctByEnumerator = class extends TyneqEnumerator {
2093
+ constructor(sourceEnumerator, keySelector) {
2094
+ super(sourceEnumerator);
2095
+ this.seenValues = /* @__PURE__ */ new Set();
2096
+ this.keySelector = keySelector;
2097
+ }
2098
+ handleNext() {
2099
+ while (true) {
2100
+ const { done, value } = this.sourceEnumerator.next();
2101
+ if (done) {
2102
+ return this.done();
2103
+ }
2104
+ const key = this.keySelector(value);
2105
+ if (!this.seenValues.has(key)) {
2106
+ this.seenValues.add(key);
2107
+ return this.yield(value);
2108
+ }
2109
+ }
2110
+ }
2111
+ };
2112
+
2113
+ // src/enumerators/buffer/except.ts
2114
+ var ExceptEnumerator = class extends TyneqEnumerator {
2115
+ constructor(sourceEnumerator, excludedValues) {
2116
+ super(sourceEnumerator);
2117
+ this.excludeSet = /* @__PURE__ */ new Set();
2118
+ this.excludedValues = excludedValues;
2119
+ }
2120
+ initialize() {
2121
+ this.excludeSet = new Set(this.excludedValues);
2122
+ }
2123
+ handleNext() {
2124
+ while (true) {
2125
+ const { done, value } = this.sourceEnumerator.next();
2126
+ if (done) {
2127
+ return this.done();
2128
+ }
2129
+ if (!this.excludeSet.has(value)) {
2130
+ this.excludeSet.add(value);
2131
+ return this.yield(value);
2132
+ }
2133
+ }
2134
+ }
2135
+ };
2136
+
2137
+ // src/enumerators/buffer/exceptBy.ts
2138
+ var ExceptByEnumerator = class extends TyneqEnumerator {
2139
+ constructor(sourceEnumerator, excludedKeys, keySelector) {
2140
+ super(sourceEnumerator);
2141
+ this.excludeSet = /* @__PURE__ */ new Set();
2142
+ this.excludedKeys = excludedKeys;
2143
+ this.keySelector = keySelector;
2144
+ }
2145
+ initialize() {
2146
+ this.excludeSet = new Set(this.excludedKeys);
2147
+ }
2148
+ handleNext() {
2149
+ while (true) {
2150
+ const { done, value } = this.sourceEnumerator.next();
2151
+ if (done) {
2152
+ return this.done();
2153
+ }
2154
+ const key = this.keySelector(value);
2155
+ if (!this.excludeSet.has(key)) {
2156
+ this.excludeSet.add(key);
2157
+ return this.yield(value);
2158
+ }
2159
+ }
2160
+ }
2161
+ };
2162
+
2163
+ // src/utility/DefaultingMap.ts
2164
+ var DefaultingMap = class extends Map {
2165
+ /** Returns the value for `key`, or initialises and stores it via `initValue()` if absent. */
2166
+ getOrInit(key, initValue) {
2167
+ if (!this.has(key)) {
2168
+ this.set(key, initValue());
2169
+ }
2170
+ return this.get(key);
2171
+ }
2172
+ /** Sets `key` to `initValue` if absent; otherwise replaces the current value with `updateValue(current)`. */
2173
+ setOrUpdate(key, updateValue, initValue) {
2174
+ if (!this.has(key)) {
2175
+ this.set(key, initValue);
2176
+ return;
2177
+ }
2178
+ this.set(key, updateValue(this.get(key)));
2179
+ }
2180
+ };
2181
+
2182
+ // src/enumerators/buffer/groupBy.ts
2183
+ var GroupByEnumerator = class extends TyneqEnumerator {
2184
+ constructor(sourceEnumerator, keySelector, valueSelector, resultSelector, groupFactory) {
2185
+ super(sourceEnumerator);
2186
+ this.lookup = new DefaultingMap();
2187
+ this.keySelector = keySelector;
2188
+ this.valueSelector = valueSelector;
2189
+ this.resultSelector = resultSelector;
2190
+ this.groupFactory = groupFactory;
2191
+ }
2192
+ initialize() {
2193
+ while (true) {
2194
+ const { done, value } = this.sourceEnumerator.next();
2195
+ if (done) {
2196
+ break;
2197
+ }
2198
+ const key = this.keySelector(value);
2199
+ const mappedValue = this.valueSelector(value);
2200
+ const group = this.lookup.getOrInit(key, () => []);
2201
+ group.push(mappedValue);
2202
+ }
2203
+ this.lookupEnumerator = this.lookup.entries();
2204
+ }
2205
+ handleNext() {
2206
+ if (this.lookupEnumerator === void 0) {
2207
+ return this.done();
2208
+ }
2209
+ const { done, value } = this.lookupEnumerator.next();
2210
+ if (done) {
2211
+ return this.done();
2212
+ }
2213
+ const [key, values] = value;
2214
+ const result = this.resultSelector(key, this.groupFactory(values));
2215
+ return this.yield(result);
2216
+ }
2217
+ };
2218
+
2219
+ // src/enumerators/buffer/groupJoin.ts
2220
+ var GroupJoinEnumerator = class extends TyneqEnumerator {
2221
+ constructor(sourceEnumerator, innerSource, outerKeySelector, innerKeySelector, resultSelector, groupFactory) {
2222
+ super(sourceEnumerator);
2223
+ this.innerLookup = new DefaultingMap();
2224
+ this.innerSource = innerSource;
2225
+ this.outerKeySelector = outerKeySelector;
2226
+ this.innerKeySelector = innerKeySelector;
2227
+ this.resultSelector = resultSelector;
2228
+ this.groupFactory = groupFactory;
2229
+ }
2230
+ initialize() {
2231
+ for (const innerItem of this.innerSource) {
2232
+ const key = this.innerKeySelector(innerItem);
2233
+ const bucket = this.innerLookup.getOrInit(key, () => []);
2234
+ bucket.push(innerItem);
2235
+ }
2236
+ }
2237
+ handleNext() {
2238
+ var _a6;
2239
+ const { done, value: outerItem } = this.sourceEnumerator.next();
2240
+ if (done) {
2241
+ return this.done();
2242
+ }
2243
+ const outerKey = this.outerKeySelector(outerItem);
2244
+ const innerItems = (_a6 = this.innerLookup.get(outerKey)) != null ? _a6 : [];
2245
+ const resultItem = this.resultSelector(outerItem, this.groupFactory(innerItems));
2246
+ return this.yield(resultItem);
2247
+ }
2248
+ };
2249
+
2250
+ // src/enumerators/buffer/intersect.ts
2251
+ var IntersectEnumerator = class extends TyneqEnumerator {
2252
+ constructor(sourceEnumerator, otherValues) {
2253
+ super(sourceEnumerator);
2254
+ this.intersectionValues = /* @__PURE__ */ new Set();
2255
+ this.bufferedValues = /* @__PURE__ */ new Set();
2256
+ this.otherValues = otherValues;
2257
+ }
2258
+ initialize() {
2259
+ this.intersectionValues = new Set(this.otherValues);
2260
+ }
2261
+ handleNext() {
2262
+ while (true) {
2263
+ const { done, value } = this.sourceEnumerator.next();
2264
+ if (done) {
2265
+ return this.done();
2266
+ }
2267
+ if (this.intersectionValues.has(value) && !this.bufferedValues.has(value)) {
2268
+ this.bufferedValues.add(value);
2269
+ return this.yield(value);
2270
+ }
2271
+ }
2272
+ }
2273
+ };
2274
+
2275
+ // src/enumerators/buffer/intersectBy.ts
2276
+ var IntersectByEnumerator = class extends TyneqEnumerator {
2277
+ constructor(sourceEnumerator, otherValues, keySelector) {
2278
+ super(sourceEnumerator);
2279
+ this.intersectionKeys = /* @__PURE__ */ new Set();
2280
+ this.bufferedKeys = /* @__PURE__ */ new Set();
2281
+ this.otherValues = otherValues;
2282
+ this.keySelector = keySelector;
2283
+ }
2284
+ initialize() {
2285
+ this.intersectionKeys = new Set(this.otherValues);
2286
+ }
2287
+ handleNext() {
2288
+ while (true) {
2289
+ const { done, value } = this.sourceEnumerator.next();
2290
+ if (done) {
2291
+ return this.done();
2292
+ }
2293
+ const key = this.keySelector(value);
2294
+ if (this.intersectionKeys.has(key) && !this.bufferedKeys.has(key)) {
2295
+ this.bufferedKeys.add(key);
2296
+ return this.yield(value);
2297
+ }
2298
+ }
2299
+ }
2300
+ };
2301
+
2302
+ // src/enumerators/buffer/join.ts
2303
+ var JoinEnumerator = class extends TyneqEnumerator {
2304
+ constructor(sourceEnumerator, innerSource, outerKeySelector, innerKeySelector, resultSelector) {
2305
+ super(sourceEnumerator);
2306
+ this.innerLookup = new DefaultingMap();
2307
+ this.pendingMatches = null;
2308
+ this.pendingIndex = 0;
2309
+ this.innerSource = innerSource;
2310
+ this.outerKeySelector = outerKeySelector;
2311
+ this.innerKeySelector = innerKeySelector;
2312
+ this.resultSelector = resultSelector;
2313
+ }
2314
+ initialize() {
2315
+ for (const innerItem of this.innerSource) {
2316
+ const key = this.innerKeySelector(innerItem);
2317
+ const bucket = this.innerLookup.getOrInit(key, () => []);
2318
+ bucket.push(innerItem);
2319
+ }
2320
+ }
2321
+ handleNext() {
2322
+ while (true) {
2323
+ if (this.pendingMatches !== null) {
2324
+ if (this.pendingIndex < this.pendingMatches.length) {
2325
+ return this.yield(this.resultSelector(this.pendingOuter, this.pendingMatches[this.pendingIndex++]));
2326
+ }
2327
+ this.pendingMatches = null;
2328
+ }
2329
+ const nextOuter = this.sourceEnumerator.next();
2330
+ if (nextOuter.done) {
2331
+ return this.done();
2332
+ }
2333
+ const outerItem = nextOuter.value;
2334
+ const outerKey = this.outerKeySelector(outerItem);
2335
+ const innerItems = this.innerLookup.get(outerKey);
2336
+ if (innerItems === void 0 || innerItems.length === 0) {
2337
+ continue;
2338
+ }
2339
+ this.pendingOuter = outerItem;
2340
+ this.pendingMatches = innerItems;
2341
+ this.pendingIndex = 0;
2342
+ }
2343
+ }
2344
+ };
2345
+
2346
+ // src/enumerators/buffer/reverse.ts
2347
+ var ReverseEnumerator = class extends TyneqEnumerator {
2348
+ constructor(sourceEnumerator) {
2349
+ super(sourceEnumerator);
2350
+ this.buffer = [];
2351
+ this.index = -1;
2352
+ }
2353
+ initialize() {
2354
+ while (true) {
2355
+ const { done, value } = this.sourceEnumerator.next();
2356
+ if (done) {
2357
+ this.index = this.buffer.length - 1;
2358
+ break;
2359
+ }
2360
+ this.buffer.push(value);
2361
+ }
2362
+ }
2363
+ handleNext() {
2364
+ if (this.index < 0) {
2365
+ return this.done();
2366
+ }
2367
+ return this.yield(this.buffer[this.index--]);
2368
+ }
2369
+ };
2370
+
2371
+ // src/enumerators/buffer/shuffle.ts
2372
+ var ShuffleEnumerator = class extends TyneqEnumerator {
2373
+ constructor(sourceEnumerator) {
2374
+ super(sourceEnumerator);
2375
+ this.buffer = [];
2376
+ this.currentIndex = 0;
2377
+ }
2378
+ initialize() {
2379
+ const buffer = Array.from(this.toIterable(this.sourceEnumerator));
2380
+ this.shuffle(buffer);
2381
+ this.buffer = buffer;
2382
+ }
2383
+ handleNext() {
2384
+ if (this.buffer.length <= this.currentIndex) {
2385
+ return this.done();
2386
+ }
2387
+ const result = this.buffer[this.currentIndex];
2388
+ this.currentIndex++;
2389
+ return this.yield(result);
2390
+ }
2391
+ shuffle(array) {
2392
+ for (let i = array.length - 1; i > 0; i--) {
2393
+ const j = Math.floor(Math.random() * (i + 1));
2394
+ [array[i], array[j]] = [array[j], array[i]];
2395
+ }
2396
+ return array;
2397
+ }
2398
+ toIterable(sourceEnumerator) {
2399
+ return {
2400
+ [Symbol.iterator]: () => sourceEnumerator
2401
+ };
2402
+ }
2403
+ };
2404
+
2405
+ // src/enumerators/buffer/union.ts
2406
+ var UnionEnumerator = class extends TyneqEnumerator {
2407
+ constructor(sourceEnumerator, otherValues) {
2408
+ super(sourceEnumerator);
2409
+ this.bufferedValues = /* @__PURE__ */ new Set();
2410
+ this.isSourceDone = false;
2411
+ this.otherValues = otherValues;
2412
+ this.currentEnumerator = this.sourceEnumerator;
2413
+ }
2414
+ handleNext() {
2415
+ while (true) {
2416
+ const { done, value } = this.currentEnumerator.next();
2417
+ if (done) {
2418
+ if (this.isSourceDone) {
2419
+ return this.done();
2420
+ }
2421
+ this.isSourceDone = true;
2422
+ this.currentEnumerator = this.otherValues[Symbol.iterator]();
2423
+ continue;
2424
+ }
2425
+ if (!this.bufferedValues.has(value)) {
2426
+ this.bufferedValues.add(value);
2427
+ return this.yield(value);
2428
+ }
2429
+ }
2430
+ }
2431
+ };
2432
+
2433
+ // src/enumerators/buffer/unionBy.ts
2434
+ var UnionByEnumerator = class extends TyneqEnumerator {
2435
+ constructor(sourceEnumerator, otherValues, keySelector) {
2436
+ super(sourceEnumerator);
2437
+ this.bufferedKeys = /* @__PURE__ */ new Set();
2438
+ this.isSourceDone = false;
2439
+ this.otherValues = otherValues;
2440
+ this.currentEnumerator = this.sourceEnumerator;
2441
+ this.keySelector = keySelector;
2442
+ }
2443
+ handleNext() {
2444
+ while (true) {
2445
+ const { done, value } = this.currentEnumerator.next();
2446
+ if (done) {
2447
+ if (this.isSourceDone) {
2448
+ return this.done();
2449
+ }
2450
+ this.isSourceDone = true;
2451
+ this.currentEnumerator = this.otherValues[Symbol.iterator]();
2452
+ continue;
2453
+ }
2454
+ const key = this.keySelector(value);
2455
+ if (!this.bufferedKeys.has(key)) {
2456
+ this.bufferedKeys.add(key);
2457
+ return this.yield(value);
2458
+ }
2459
+ }
2460
+ }
2461
+ };
2462
+
2463
+ // src/enumerators/buffer/permutations.ts
2464
+ var PermutationsEnumerator = class extends TyneqEnumerator {
2465
+ constructor() {
2466
+ super(...arguments);
2467
+ this.buffer = [];
2468
+ this.c = [];
2469
+ this.n = 0;
2470
+ this.i = -1;
2471
+ }
2472
+ initialize() {
2473
+ this.buffer = Array.from(EnumeratorUtility.toIterable(this.sourceEnumerator));
2474
+ this.n = this.buffer.length;
2475
+ this.c = new Array(this.n).fill(0);
2476
+ }
2477
+ handleNext() {
2478
+ if (this.i === -1) {
2479
+ this.i = 1;
2480
+ return this.yield([...this.buffer]);
2481
+ }
2482
+ while (this.i < this.n) {
2483
+ if (this.c[this.i] < this.i) {
2484
+ const swapIndex = this.i % 2 === 0 ? 0 : this.c[this.i];
2485
+ [this.buffer[swapIndex], this.buffer[this.i]] = [this.buffer[this.i], this.buffer[swapIndex]];
2486
+ this.c[this.i]++;
2487
+ this.i = 1;
2488
+ return this.yield([...this.buffer]);
2489
+ } else {
2490
+ this.c[this.i] = 0;
2491
+ this.i++;
2492
+ }
2493
+ }
2494
+ return this.done();
2495
+ }
2496
+ };
2497
+
2498
+ // src/core/TyneqEnumerableBase.ts
2499
+ var _unionBy_dec, _union_dec, _shuffle_dec, _reverse_dec, _permutations_dec, _join_dec, _intersectBy_dec, _intersect_dec, _groupJoin_dec, _groupBy_dec, _exceptBy_dec, _except_dec, _distinctBy_dec, _distinct_dec, _backsert_dec, _zip_dec, _where_dec, _throttle_dec, _tapIf_dec, _tap_dec, _takeWhile_dec, _takeUntil_dec, _take_dec, _split_dec, _slice_dec, _skipWhile_dec, _skipUntil_dec, _skipLast_dec, _skip_dec, _repeat_dec, _window_dec, _selectMany_dec, _select_dec, _scan_dec, _prepend_dec, _populate_dec, _pairwise_dec, _flatten_dec, _defaultIfEmpty_dec, _concat_dec, _chunk_dec, _append_dec, _ofType_dec, _toSet_dec, _toRecord_dec, _toMap_dec, _toAsync_dec, _toArray_dec, _sum_dec, _startsWith_dec, _endsWith_dec, _singleOrDefault_dec, _single_dec, _sequenceEqual_dec, _minMax_dec, _minBy_dec, _min_dec, _maxBy_dec, _max_dec, _lastOrDefault_dec, _last_dec, _isNullOrEmpty_dec, _indexOf_dec, _firstOrDefault_dec, _first_dec, _elementAtOrDefault_dec, _elementAt_dec, _countBy_dec, _count_dec, _contains_dec, _consume_dec, _average_dec, _any_dec, _all_dec, _aggregate_dec, _a2, _TyneqEnumerableBase_decorators, _init2;
2500
+ _TyneqEnumerableBase_decorators = [sequence];
2501
+ var TyneqEnumerableBase = class extends (_a2 = TyneqEnumerableCore, _aggregate_dec = [builtin({ kind: "terminal" })], _all_dec = [builtin({ kind: "terminal" })], _any_dec = [builtin({ kind: "terminal" })], _average_dec = [builtin({ kind: "terminal" })], _consume_dec = [builtin({ kind: "terminal" })], _contains_dec = [builtin({ kind: "terminal" })], _count_dec = [builtin({ kind: "terminal" })], _countBy_dec = [builtin({ kind: "terminal" })], _elementAt_dec = [builtin({ kind: "terminal" })], _elementAtOrDefault_dec = [builtin({ kind: "terminal" })], _first_dec = [builtin({ kind: "terminal" })], _firstOrDefault_dec = [builtin({ kind: "terminal" })], _indexOf_dec = [builtin({ kind: "terminal" })], _isNullOrEmpty_dec = [builtin({ kind: "terminal" })], _last_dec = [builtin({ kind: "terminal" })], _lastOrDefault_dec = [builtin({ kind: "terminal" })], _max_dec = [builtin({ kind: "terminal" })], _maxBy_dec = [builtin({ kind: "terminal" })], _min_dec = [builtin({ kind: "terminal" })], _minBy_dec = [builtin({ kind: "terminal" })], _minMax_dec = [builtin({ kind: "terminal" })], _sequenceEqual_dec = [builtin({ kind: "terminal" })], _single_dec = [builtin({ kind: "terminal" })], _singleOrDefault_dec = [builtin({ kind: "terminal" })], _endsWith_dec = [builtin({ kind: "terminal" })], _startsWith_dec = [builtin({ kind: "terminal" })], _sum_dec = [builtin({ kind: "terminal" })], _toArray_dec = [builtin({ kind: "terminal" })], _toAsync_dec = [builtin({ kind: "terminal" })], _toMap_dec = [builtin({ kind: "terminal" })], _toRecord_dec = [builtin({ kind: "terminal" })], _toSet_dec = [builtin({ kind: "terminal" })], _ofType_dec = [builtin({ kind: "streaming" })], _append_dec = [builtin({ kind: "streaming" })], _chunk_dec = [builtin({ kind: "streaming" })], _concat_dec = [builtin({ kind: "streaming" })], _defaultIfEmpty_dec = [builtin({ kind: "streaming" })], _flatten_dec = [builtin({ kind: "streaming" })], _pairwise_dec = [builtin({ kind: "streaming" })], _populate_dec = [builtin({ kind: "streaming" })], _prepend_dec = [builtin({ kind: "streaming" })], _scan_dec = [builtin({ kind: "streaming" })], _select_dec = [builtin({ kind: "streaming" })], _selectMany_dec = [builtin({ kind: "streaming" })], _window_dec = [builtin({ kind: "streaming" })], _repeat_dec = [builtin({ kind: "streaming" })], _skip_dec = [builtin({ kind: "streaming" })], _skipLast_dec = [builtin({ kind: "streaming" })], _skipUntil_dec = [builtin({ kind: "streaming" })], _skipWhile_dec = [builtin({ kind: "streaming" })], _slice_dec = [builtin({ kind: "streaming" })], _split_dec = [builtin({ kind: "streaming" })], _take_dec = [builtin({ kind: "streaming" })], _takeUntil_dec = [builtin({ kind: "streaming" })], _takeWhile_dec = [builtin({ kind: "streaming" })], _tap_dec = [builtin({ kind: "streaming" })], _tapIf_dec = [builtin({ kind: "streaming" })], _throttle_dec = [builtin({ kind: "streaming" })], _where_dec = [builtin({ kind: "streaming" })], _zip_dec = [builtin({ kind: "streaming" })], _backsert_dec = [builtin({ kind: "buffer" })], _distinct_dec = [builtin({ kind: "buffer" })], _distinctBy_dec = [builtin({ kind: "buffer" })], _except_dec = [builtin({ kind: "buffer" })], _exceptBy_dec = [builtin({ kind: "buffer" })], _groupBy_dec = [builtin({ kind: "buffer" })], _groupJoin_dec = [builtin({ kind: "buffer" })], _intersect_dec = [builtin({ kind: "buffer" })], _intersectBy_dec = [builtin({ kind: "buffer" })], _join_dec = [builtin({ kind: "buffer" })], _permutations_dec = [builtin({ kind: "buffer" })], _reverse_dec = [builtin({ kind: "buffer" })], _shuffle_dec = [builtin({ kind: "buffer" })], _union_dec = [builtin({ kind: "buffer" })], _unionBy_dec = [builtin({ kind: "buffer" })], _a2) {
2502
+ constructor() {
2503
+ super(...arguments);
2504
+ _chunkOWKUE3ACcjs.__runInitializers.call(void 0, _init2, 5, this);
2505
+ }
2506
+ aggregate(seed, func, resultSelector) {
2507
+ return new AggregateOperator(this, seed, func, resultSelector).process();
2508
+ }
2509
+ all(predicate) {
2510
+ return new AllOperator(this, predicate).process();
2511
+ }
2512
+ any(predicate) {
2513
+ return new AnyOperator(this, predicate).process();
2514
+ }
2515
+ average(selector) {
2516
+ return new AverageOperator(this, selector).process();
2517
+ }
2518
+ consume() {
2519
+ new ConsumeOperator(this).process();
2520
+ }
2521
+ contains(value, equalityComparer) {
2522
+ return new ContainsOperator(this, value, equalityComparer).process();
2523
+ }
2524
+ count() {
2525
+ return new CountOperator(this).process();
2526
+ }
2527
+ countBy(predicate) {
2528
+ return new CountByOperator(this, predicate).process();
2529
+ }
2530
+ elementAt(index) {
2531
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkSafeInteger({ index });
2532
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNonNegative({ index });
2533
+ return new ElementAtOperator(this, index).process();
2534
+ }
2535
+ elementAtOrDefault(index, defaultValue) {
2536
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkSafeInteger({ index });
2537
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNonNegative({ index });
2538
+ return new ElementAtOrDefaultOperator(this, index, defaultValue).process();
2539
+ }
2540
+ first(predicate) {
2541
+ return new FirstOperator(this, predicate).process();
2542
+ }
2543
+ firstOrDefault(predicate, defaultValue) {
2544
+ return new FirstOrDefaultOperator(this, predicate, defaultValue).process();
2545
+ }
2546
+ indexOf(predicate, startIndex = 0) {
2547
+ return new IndexOfOperator(this, predicate, startIndex).process();
2548
+ }
2549
+ isNullOrEmpty() {
2550
+ return new IsNullOrEmptyOperator(this).process();
2551
+ }
2552
+ last(predicate) {
2553
+ return new LastOperator(this, predicate).process();
2554
+ }
2555
+ lastOrDefault(predicate, defaultValue) {
2556
+ return new LastOrDefaultOperator(this, predicate, defaultValue).process();
2557
+ }
2558
+ max(comparer) {
2559
+ return new ExtremumOperator(this, 1, "max", comparer).process();
2560
+ }
2561
+ maxBy(keySelector, comparer) {
2562
+ return new ExtremumByOperator(this, keySelector, 1, "maxBy", comparer).process();
2563
+ }
2564
+ min(comparer) {
2565
+ return new ExtremumOperator(this, -1, "min", comparer).process();
2566
+ }
2567
+ minBy(keySelector, comparer) {
2568
+ return new ExtremumByOperator(this, keySelector, -1, "minBy", comparer).process();
2569
+ }
2570
+ minMax(comparer) {
2571
+ return new MinMaxOperator(this, comparer).process();
2572
+ }
2573
+ sequenceEqual(other, equalityComparer) {
2574
+ return new SequenceEqualOperator(this, other, equalityComparer).process();
2575
+ }
2576
+ single(predicate) {
2577
+ return new SingleOperator(this, predicate).process();
2578
+ }
2579
+ singleOrDefault(predicate, defaultValue) {
2580
+ return new SingleOrDefaultOperator(this, predicate, defaultValue).process();
2581
+ }
2582
+ endsWith(sequence2, equalityComparer) {
2583
+ return new EndsWithOperator(this, sequence2, equalityComparer).process();
2584
+ }
2585
+ startsWith(sequence2, equalityComparer) {
2586
+ return new StartsWithOperator(this, sequence2, equalityComparer).process();
2587
+ }
2588
+ sum(selector) {
2589
+ return new SumOperator(this, selector).process();
2590
+ }
2591
+ toArray() {
2592
+ return new ToArrayOperator(this).process();
2593
+ }
2594
+ toAsync() {
2595
+ return new ToAsyncOperator(this).process();
2596
+ }
2597
+ toMap(selector) {
2598
+ return new ToMapOperator(this, selector).process();
2599
+ }
2600
+ toRecord(selector) {
2601
+ return new ToRecordOperator(this, selector).process();
2602
+ }
2603
+ toSet() {
2604
+ return new ToSetOperator(this).process();
2605
+ }
2606
+ ofType(guard) {
2607
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ guard });
2608
+ return this.createSequence(
2609
+ () => new OfTypeEnumerator(this.getEnumerator(), guard),
2610
+ this.createNode("ofType", "streaming", [guard])
2611
+ );
2612
+ }
2613
+ append(item) {
2614
+ return this.createSequence(
2615
+ () => new AppendEnumerator(this.getEnumerator(), item),
2616
+ this.createNode("append", "streaming", [item])
2617
+ );
2618
+ }
2619
+ chunk(size) {
2620
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkSafeInteger({ size });
2621
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkPositive({ size });
2622
+ return this.createSequence(
2623
+ () => new ChunkEnumerator(this.getEnumerator(), size),
2624
+ this.createNode("chunk", "streaming", [size])
2625
+ );
2626
+ }
2627
+ concat(other) {
2628
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ other });
2629
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkIterable({ other });
2630
+ return this.createSequence(
2631
+ () => new ConcatEnumerator(this.getEnumerator(), other),
2632
+ this.createNode("concat", "streaming", [other])
2633
+ );
2634
+ }
2635
+ defaultIfEmpty(defaultValue) {
2636
+ return this.createSequence(
2637
+ () => new DefaultIfEmptyEnumerator(this.getEnumerator(), defaultValue),
2638
+ this.createNode("defaultIfEmpty", "streaming", [defaultValue])
2639
+ );
2640
+ }
2641
+ flatten() {
2642
+ const self = this;
2643
+ return self.createSequence(
2644
+ () => new FlattenEnumerator(self.getEnumerator()),
2645
+ self.createNode("flatten", "streaming")
2646
+ );
2647
+ }
2648
+ pairwise() {
2649
+ return this.createSequence(
2650
+ () => new PairwiseEnumerator(this.getEnumerator()),
2651
+ this.createNode("pairwise", "streaming")
2652
+ );
2653
+ }
2654
+ populate(value) {
2655
+ return this.createSequence(
2656
+ () => new PopulateEnumerator(this.getEnumerator(), value),
2657
+ this.createNode("populate", "streaming", [value])
2658
+ );
2659
+ }
2660
+ prepend(item) {
2661
+ return this.createSequence(
2662
+ () => new PrependEnumerator(this.getEnumerator(), item),
2663
+ this.createNode("prepend", "streaming", [item])
2664
+ );
2665
+ }
2666
+ scan(seed, accumulator) {
2667
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ accumulator });
2668
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkFunction({ accumulator });
2669
+ return this.createSequence(
2670
+ () => new ScanEnumerator(this.getEnumerator(), seed, accumulator),
2671
+ this.createNode("scan", "streaming", [seed, accumulator])
2672
+ );
2673
+ }
2674
+ select(selector) {
2675
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ selector });
2676
+ return this.createSequence(
2677
+ () => new SelectEnumerator(this.getEnumerator(), selector),
2678
+ this.createNode("select", "streaming", [selector])
2679
+ );
2680
+ }
2681
+ selectMany(selector) {
2682
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ selector });
2683
+ return this.createSequence(
2684
+ () => new SelectManyEnumerator(this.getEnumerator(), selector),
2685
+ this.createNode("selectMany", "streaming", [selector])
2686
+ );
2687
+ }
2688
+ window(size, step = 1) {
2689
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkSafeInteger({ size });
2690
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkPositive({ size });
2691
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkSafeInteger({ step });
2692
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkPositive({ step });
2693
+ return this.createSequence(
2694
+ () => new WindowEnumerator(this.getEnumerator(), size, step),
2695
+ this.createNode("window", "streaming", [size, step])
2696
+ );
2697
+ }
2698
+ repeat(count) {
2699
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNonNegative({ count });
2700
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkInteger({ count });
2701
+ return this.createSequence(
2702
+ () => new RepeatSequenceEnumerator(this.getEnumerator(), this, count),
2703
+ this.createNode("repeat", "streaming", [count])
2704
+ );
2705
+ }
2706
+ skip(count) {
2707
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkSafeInteger({ count });
2708
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNonNegative({ count });
2709
+ return this.createSequence(
2710
+ () => new SkipEnumerator(this.getEnumerator(), count),
2711
+ this.createNode("skip", "streaming", [count])
2712
+ );
2713
+ }
2714
+ skipLast(count) {
2715
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkSafeInteger({ count });
2716
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNonNegative({ count });
2717
+ return this.createSequence(
2718
+ () => new SkipLastEnumerator(this.getEnumerator(), count),
2719
+ this.createNode("skipLast", "streaming", [count])
2720
+ );
2721
+ }
2722
+ skipUntil(predicate) {
2723
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ predicate });
2724
+ return this.createSequence(
2725
+ () => new SkipUntilEnumerator(this.getEnumerator(), predicate),
2726
+ this.createNode("skipUntil", "streaming", [predicate])
2727
+ );
2728
+ }
2729
+ skipWhile(predicate) {
2730
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ predicate });
2731
+ return this.createSequence(
2732
+ () => new SkipWhileEnumerator(this.getEnumerator(), predicate),
2733
+ this.createNode("skipWhile", "streaming", [predicate])
2734
+ );
2735
+ }
2736
+ slice(start, end) {
2737
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNonNegative({ start });
2738
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkSafeInteger({ start });
2739
+ if (end !== void 0) {
2740
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNonNegative({ end });
2741
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkSafeInteger({ end });
2742
+ if (end < start) {
2743
+ throw new (0, _chunkOWKUE3ACcjs.ArgumentOutOfRangeError)("end", "`end` must be greater than or equal to `start`.");
2744
+ }
2745
+ }
2746
+ const resolvedEnd = end != null ? end : Number.MAX_SAFE_INTEGER;
2747
+ return this.createSequence(
2748
+ () => new SliceEnumerator(this.getEnumerator(), start, resolvedEnd),
2749
+ this.createNode("slice", "streaming", [start, end])
2750
+ );
2751
+ }
2752
+ split(splitOn) {
2753
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ splitOn });
2754
+ return this.createSequence(
2755
+ () => new SplitEnumerator(this.getEnumerator(), splitOn),
2756
+ this.createNode("split", "streaming", [splitOn])
2757
+ );
2758
+ }
2759
+ take(count) {
2760
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkSafeInteger({ count });
2761
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNonNegative({ count });
2762
+ return this.createSequence(
2763
+ () => new TakeEnumerator(this.getEnumerator(), count),
2764
+ this.createNode("take", "streaming", [count])
2765
+ );
2766
+ }
2767
+ takeUntil(predicate) {
2768
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ predicate });
2769
+ return this.createSequence(
2770
+ () => new TakeUntilEnumerator(this.getEnumerator(), predicate),
2771
+ this.createNode("takeUntil", "streaming", [predicate])
2772
+ );
2773
+ }
2774
+ takeWhile(predicate) {
2775
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ predicate });
2776
+ return this.createSequence(
2777
+ () => new TakeWhileEnumerator(this.getEnumerator(), predicate),
2778
+ this.createNode("takeWhile", "streaming", [predicate])
2779
+ );
2780
+ }
2781
+ tap(action) {
2782
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ action });
2783
+ return this.createSequence(
2784
+ () => new TapEnumerator(this.getEnumerator(), action),
2785
+ this.createNode("tap", "streaming", [action])
2786
+ );
2787
+ }
2788
+ tapIf(action, predicate) {
2789
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ action });
2790
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ predicate });
2791
+ return this.createSequence(
2792
+ () => new TapIfEnumerator(this.getEnumerator(), action, predicate),
2793
+ this.createNode("tapIf", "streaming", [action, predicate])
2794
+ );
2795
+ }
2796
+ throttle(count) {
2797
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkSafeInteger({ count });
2798
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkPositive({ count });
2799
+ return this.createSequence(
2800
+ () => new ThrottleEnumerator(this.getEnumerator(), count),
2801
+ this.createNode("throttle", "streaming", [count])
2802
+ );
2803
+ }
2804
+ where(predicate) {
2805
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ predicate });
2806
+ return this.createSequence(
2807
+ () => new WhereEnumerator(this.getEnumerator(), predicate),
2808
+ this.createNode("where", "streaming", [predicate])
2809
+ );
2810
+ }
2811
+ zip(other, selector) {
2812
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ other });
2813
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkIterable({ other });
2814
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ selector });
2815
+ return this.createSequence(
2816
+ () => new ZipEnumerator(this.getEnumerator(), other, selector),
2817
+ this.createNode("zip", "streaming", [other, selector])
2818
+ );
2819
+ }
2820
+ backsert(index, other) {
2821
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ other });
2822
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkSafeInteger({ index });
2823
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNonNegative({ index });
2824
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkIterable({ other });
2825
+ return this.createSequence(
2826
+ () => new BacksertEnumerator(this.getEnumerator(), index, other),
2827
+ this.createNode("backsert", "buffer", [index, other])
2828
+ );
2829
+ }
2830
+ distinct() {
2831
+ return this.createSequence(
2832
+ () => new DistinctEnumerator(this.getEnumerator()),
2833
+ this.createNode("distinct", "buffer")
2834
+ );
2835
+ }
2836
+ distinctBy(keySelector) {
2837
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ keySelector });
2838
+ return this.createSequence(
2839
+ () => new DistinctByEnumerator(this.getEnumerator(), keySelector),
2840
+ this.createNode("distinctBy", "buffer", [keySelector])
2841
+ );
2842
+ }
2843
+ except(excludedValues) {
2844
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ excludedValues });
2845
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkIterable({ excludedValues });
2846
+ return this.createSequence(
2847
+ () => new ExceptEnumerator(this.getEnumerator(), excludedValues),
2848
+ this.createNode("except", "buffer", [excludedValues])
2849
+ );
2850
+ }
2851
+ exceptBy(excludedKeys, keySelector) {
2852
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ excludedKeys });
2853
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkIterable({ excludedKeys });
2854
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ keySelector });
2855
+ return this.createSequence(
2856
+ () => new ExceptByEnumerator(this.getEnumerator(), excludedKeys, keySelector),
2857
+ this.createNode("exceptBy", "buffer", [excludedKeys, keySelector])
2858
+ );
2859
+ }
2860
+ groupBy(keySelector, valueSelector, resultSelector) {
2861
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ keySelector });
2862
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ valueSelector });
2863
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ resultSelector });
2864
+ const groupFactory = (values) => this.createEnumerable({ getEnumerator: () => values[Symbol.iterator]() }, null);
2865
+ return this.createSequence(
2866
+ () => new GroupByEnumerator(
2867
+ this.getEnumerator(),
2868
+ keySelector,
2869
+ valueSelector,
2870
+ resultSelector,
2871
+ groupFactory
2872
+ ),
2873
+ this.createNode("groupBy", "buffer", [keySelector, valueSelector, resultSelector])
2874
+ );
2875
+ }
2876
+ groupJoin(inner, outerKeySelector, innerKeySelector, resultSelector) {
2877
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ inner });
2878
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkIterable({ inner });
2879
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ outerKeySelector });
2880
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ innerKeySelector });
2881
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ resultSelector });
2882
+ const groupFactory = (values) => this.createEnumerable({ getEnumerator: () => values[Symbol.iterator]() }, null);
2883
+ return this.createSequence(
2884
+ () => new GroupJoinEnumerator(
2885
+ this.getEnumerator(),
2886
+ inner,
2887
+ outerKeySelector,
2888
+ innerKeySelector,
2889
+ resultSelector,
2890
+ groupFactory
2891
+ ),
2892
+ this.createNode("groupJoin", "buffer", [inner, outerKeySelector, innerKeySelector, resultSelector])
2893
+ );
2894
+ }
2895
+ intersect(intersectedValues) {
2896
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ intersectedValues });
2897
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkIterable({ intersectedValues });
2898
+ return this.createSequence(
2899
+ () => new IntersectEnumerator(this.getEnumerator(), intersectedValues),
2900
+ this.createNode("intersect", "buffer", [intersectedValues])
2901
+ );
2902
+ }
2903
+ intersectBy(intersectedKeys, keySelector) {
2904
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ intersectedKeys });
2905
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkIterable({ intersectedKeys });
2906
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ keySelector });
2907
+ return this.createSequence(
2908
+ () => new IntersectByEnumerator(this.getEnumerator(), intersectedKeys, keySelector),
2909
+ this.createNode("intersectBy", "buffer", [intersectedKeys, keySelector])
2910
+ );
2911
+ }
2912
+ join(inner, outerKeySelector, innerKeySelector, resultSelector) {
2913
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ inner });
2914
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkIterable({ inner });
2915
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ outerKeySelector });
2916
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ innerKeySelector });
2917
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ resultSelector });
2918
+ return this.createSequence(
2919
+ () => new JoinEnumerator(
2920
+ this.getEnumerator(),
2921
+ inner,
2922
+ outerKeySelector,
2923
+ innerKeySelector,
2924
+ resultSelector
2925
+ ),
2926
+ this.createNode("join", "buffer", [inner, outerKeySelector, innerKeySelector, resultSelector])
2927
+ );
2928
+ }
2929
+ permutations() {
2930
+ return this.createSequence(
2931
+ () => new PermutationsEnumerator(this.getEnumerator()),
2932
+ this.createNode("permutations", "buffer")
2933
+ );
2934
+ }
2935
+ reverse() {
2936
+ return this.createSequence(
2937
+ () => new ReverseEnumerator(this.getEnumerator()),
2938
+ this.createNode("reverse", "buffer")
2939
+ );
2940
+ }
2941
+ shuffle() {
2942
+ return this.createSequence(
2943
+ () => new ShuffleEnumerator(this.getEnumerator()),
2944
+ this.createNode("shuffle", "buffer")
2945
+ );
2946
+ }
2947
+ union(otherValues) {
2948
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ otherValues });
2949
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkIterable({ otherValues });
2950
+ return this.createSequence(
2951
+ () => new UnionEnumerator(this.getEnumerator(), otherValues),
2952
+ this.createNode("union", "buffer", [otherValues])
2953
+ );
2954
+ }
2955
+ unionBy(otherValues, keySelector) {
2956
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ otherValues });
2957
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkIterable({ otherValues });
2958
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ keySelector });
2959
+ return this.createSequence(
2960
+ () => new UnionByEnumerator(this.getEnumerator(), otherValues, keySelector),
2961
+ this.createNode("unionBy", "buffer", [otherValues, keySelector])
2962
+ );
2963
+ }
2964
+ };
2965
+ _init2 = _chunkOWKUE3ACcjs.__decoratorStart.call(void 0, _a2);
2966
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "aggregate", _aggregate_dec, TyneqEnumerableBase);
2967
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "all", _all_dec, TyneqEnumerableBase);
2968
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "any", _any_dec, TyneqEnumerableBase);
2969
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "average", _average_dec, TyneqEnumerableBase);
2970
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "consume", _consume_dec, TyneqEnumerableBase);
2971
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "contains", _contains_dec, TyneqEnumerableBase);
2972
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "count", _count_dec, TyneqEnumerableBase);
2973
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "countBy", _countBy_dec, TyneqEnumerableBase);
2974
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "elementAt", _elementAt_dec, TyneqEnumerableBase);
2975
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "elementAtOrDefault", _elementAtOrDefault_dec, TyneqEnumerableBase);
2976
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "first", _first_dec, TyneqEnumerableBase);
2977
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "firstOrDefault", _firstOrDefault_dec, TyneqEnumerableBase);
2978
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "indexOf", _indexOf_dec, TyneqEnumerableBase);
2979
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "isNullOrEmpty", _isNullOrEmpty_dec, TyneqEnumerableBase);
2980
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "last", _last_dec, TyneqEnumerableBase);
2981
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "lastOrDefault", _lastOrDefault_dec, TyneqEnumerableBase);
2982
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "max", _max_dec, TyneqEnumerableBase);
2983
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "maxBy", _maxBy_dec, TyneqEnumerableBase);
2984
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "min", _min_dec, TyneqEnumerableBase);
2985
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "minBy", _minBy_dec, TyneqEnumerableBase);
2986
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "minMax", _minMax_dec, TyneqEnumerableBase);
2987
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "sequenceEqual", _sequenceEqual_dec, TyneqEnumerableBase);
2988
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "single", _single_dec, TyneqEnumerableBase);
2989
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "singleOrDefault", _singleOrDefault_dec, TyneqEnumerableBase);
2990
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "endsWith", _endsWith_dec, TyneqEnumerableBase);
2991
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "startsWith", _startsWith_dec, TyneqEnumerableBase);
2992
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "sum", _sum_dec, TyneqEnumerableBase);
2993
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "toArray", _toArray_dec, TyneqEnumerableBase);
2994
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "toAsync", _toAsync_dec, TyneqEnumerableBase);
2995
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "toMap", _toMap_dec, TyneqEnumerableBase);
2996
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "toRecord", _toRecord_dec, TyneqEnumerableBase);
2997
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "toSet", _toSet_dec, TyneqEnumerableBase);
2998
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "ofType", _ofType_dec, TyneqEnumerableBase);
2999
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "append", _append_dec, TyneqEnumerableBase);
3000
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "chunk", _chunk_dec, TyneqEnumerableBase);
3001
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "concat", _concat_dec, TyneqEnumerableBase);
3002
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "defaultIfEmpty", _defaultIfEmpty_dec, TyneqEnumerableBase);
3003
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "flatten", _flatten_dec, TyneqEnumerableBase);
3004
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "pairwise", _pairwise_dec, TyneqEnumerableBase);
3005
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "populate", _populate_dec, TyneqEnumerableBase);
3006
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "prepend", _prepend_dec, TyneqEnumerableBase);
3007
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "scan", _scan_dec, TyneqEnumerableBase);
3008
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "select", _select_dec, TyneqEnumerableBase);
3009
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "selectMany", _selectMany_dec, TyneqEnumerableBase);
3010
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "window", _window_dec, TyneqEnumerableBase);
3011
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "repeat", _repeat_dec, TyneqEnumerableBase);
3012
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "skip", _skip_dec, TyneqEnumerableBase);
3013
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "skipLast", _skipLast_dec, TyneqEnumerableBase);
3014
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "skipUntil", _skipUntil_dec, TyneqEnumerableBase);
3015
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "skipWhile", _skipWhile_dec, TyneqEnumerableBase);
3016
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "slice", _slice_dec, TyneqEnumerableBase);
3017
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "split", _split_dec, TyneqEnumerableBase);
3018
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "take", _take_dec, TyneqEnumerableBase);
3019
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "takeUntil", _takeUntil_dec, TyneqEnumerableBase);
3020
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "takeWhile", _takeWhile_dec, TyneqEnumerableBase);
3021
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "tap", _tap_dec, TyneqEnumerableBase);
3022
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "tapIf", _tapIf_dec, TyneqEnumerableBase);
3023
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "throttle", _throttle_dec, TyneqEnumerableBase);
3024
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "where", _where_dec, TyneqEnumerableBase);
3025
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "zip", _zip_dec, TyneqEnumerableBase);
3026
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "backsert", _backsert_dec, TyneqEnumerableBase);
3027
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "distinct", _distinct_dec, TyneqEnumerableBase);
3028
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "distinctBy", _distinctBy_dec, TyneqEnumerableBase);
3029
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "except", _except_dec, TyneqEnumerableBase);
3030
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "exceptBy", _exceptBy_dec, TyneqEnumerableBase);
3031
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "groupBy", _groupBy_dec, TyneqEnumerableBase);
3032
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "groupJoin", _groupJoin_dec, TyneqEnumerableBase);
3033
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "intersect", _intersect_dec, TyneqEnumerableBase);
3034
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "intersectBy", _intersectBy_dec, TyneqEnumerableBase);
3035
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "join", _join_dec, TyneqEnumerableBase);
3036
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "permutations", _permutations_dec, TyneqEnumerableBase);
3037
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "reverse", _reverse_dec, TyneqEnumerableBase);
3038
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "shuffle", _shuffle_dec, TyneqEnumerableBase);
3039
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "union", _union_dec, TyneqEnumerableBase);
3040
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 1, "unionBy", _unionBy_dec, TyneqEnumerableBase);
3041
+ TyneqEnumerableBase = _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init2, 0, "TyneqEnumerableBase", _TyneqEnumerableBase_decorators, TyneqEnumerableBase);
3042
+ _chunkOWKUE3ACcjs.__runInitializers.call(void 0, _init2, 1, TyneqEnumerableBase);
3043
+
3044
+ // src/core/OperatorMetadata.ts
3045
+ var OperatorMetadata = class _OperatorMetadata {
3046
+ constructor(name, kind, source2 = "external", targetClass, extensions = {}) {
3047
+ this.name = name;
3048
+ this.kind = kind;
3049
+ this.source = source2;
3050
+ this.targetClass = arguments.length < 4 ? TyneqEnumerableBase : targetClass;
3051
+ this.extensions = extensions;
3052
+ }
3053
+ /**
3054
+ * Creates metadata for a source operator.
3055
+ *
3056
+ * @remarks
3057
+ * `targetClass` is always `undefined` for source operators - they are static
3058
+ * factories with no prototype and are never patched onto a class instance.
3059
+ */
3060
+ static source(name, src = "external") {
3061
+ return new _OperatorMetadata(name, "source", src, void 0);
3062
+ }
3063
+ /** Creates metadata for a streaming operator. Defaults targetClass to TyneqEnumerableBase. */
3064
+ static streaming(name, targetClass = TyneqEnumerableBase, source2, extensions) {
3065
+ return new _OperatorMetadata(name, "streaming", source2 != null ? source2 : "external", targetClass, extensions);
3066
+ }
3067
+ /** Creates metadata for a buffering operator. Defaults targetClass to TyneqEnumerableBase. */
3068
+ static buffer(name, targetClass = TyneqEnumerableBase, source2, extensions) {
3069
+ return new _OperatorMetadata(name, "buffer", source2 != null ? source2 : "external", targetClass, extensions);
3070
+ }
3071
+ /** Creates metadata for a terminal operator. Defaults targetClass to TyneqEnumerableBase. */
3072
+ static terminal(name, targetClass = TyneqEnumerableBase, source2, extensions) {
3073
+ return new _OperatorMetadata(name, "terminal", source2 != null ? source2 : "external", targetClass, extensions);
3074
+ }
3075
+ /**
3076
+ * Creates metadata for a streaming or buffer operator determined at runtime.
3077
+ *
3078
+ * @remarks
3079
+ * Use when the category is a variable rather than a compile-time literal --
3080
+ * for example in `@operator` and `@orderedOperator` whose `category` parameter
3081
+ * is provided by the caller. For compile-time-known categories prefer the
3082
+ * dedicated {@link streaming} / {@link buffer} / {@link terminal} statics.
3083
+ *
3084
+ * Only `"streaming"` and `"buffer"` are valid; passing `"terminal"` or `"source"` throws.
3085
+ */
3086
+ static forCategory(category, name, targetClass = TyneqEnumerableBase, source2, extensions) {
3087
+ if (category === "streaming") {
3088
+ return _OperatorMetadata.streaming(name, targetClass, source2, extensions);
3089
+ }
3090
+ if (category === "buffer") {
3091
+ return _OperatorMetadata.buffer(name, targetClass, source2, extensions);
3092
+ }
3093
+ throw new PluginError(
3094
+ `OperatorMetadata.forCategory: unsupported category "${category}". Use .terminal() or .source() directly.`,
3095
+ "forCategory",
3096
+ name
3097
+ );
3098
+ }
3099
+ };
3100
+
3101
+ // src/core/ordering/BaseEnumerableSorter.ts
3102
+ var BaseEnumerableSorter = class {
3103
+ /**
3104
+ * Returns a stable sorted index map for `source[0..count-1]`.
3105
+ *
3106
+ * @returns An array of indices sorted by the key order defined by this sorter chain.
3107
+ */
3108
+ sort(source2, count) {
3109
+ this.computeKeys([...source2], count);
3110
+ const indexMap = Array.from({ length: count }, (_, i) => i);
3111
+ indexMap.sort((a, b) => this.compareKeys(a, b));
3112
+ return indexMap;
3113
+ }
3114
+ };
3115
+
3116
+ // src/core/ordering/TyneqEnumerableSorter.ts
3117
+ var TyneqEnumerableSorter = class extends BaseEnumerableSorter {
3118
+ constructor(keySelector, comparer, descending, next) {
3119
+ super();
3120
+ this.keys = [];
3121
+ this.next = null;
3122
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ keySelector });
3123
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ comparer });
3124
+ this.keySelector = keySelector;
3125
+ this.comparer = comparer;
3126
+ this.descending = descending ? -1 : 1;
3127
+ this.next = next != null ? next : null;
3128
+ }
3129
+ computeKeys(source2, count) {
3130
+ var _a6;
3131
+ this.keys = new Array(count);
3132
+ for (let i = 0; i < count; i++) {
3133
+ this.keys[i] = this.keySelector(source2[i]);
3134
+ }
3135
+ (_a6 = this.next) == null ? void 0 : _a6.computeKeys(source2, count);
3136
+ }
3137
+ compareKeys(i, j) {
3138
+ const result = this.comparer(this.keys[i], this.keys[j]) * this.descending;
3139
+ if (result !== 0) {
3140
+ return result;
3141
+ }
3142
+ if (this.next === null) {
3143
+ return this.stabilityCompare(i, j);
3144
+ }
3145
+ return this.next.compareKeys(i, j);
3146
+ }
3147
+ stabilityCompare(i, j) {
3148
+ return i - j;
3149
+ }
3150
+ };
3151
+
3152
+ // src/enumerators/buffer/memoize.ts
3153
+ var MemoizeEnumerator = class extends TyneqBaseEnumerator {
3154
+ constructor(cachedEnumerable) {
3155
+ super();
3156
+ this.index = 0;
3157
+ this.cachedEnumerable = cachedEnumerable;
3158
+ }
3159
+ disposeSource() {
3160
+ }
3161
+ handleNext() {
3162
+ const result = this.cachedEnumerable.tryGetAtFromCache(this.index);
3163
+ if (!result.has) {
3164
+ return this.done();
3165
+ }
3166
+ this.index++;
3167
+ return this.yield(result.value);
3168
+ }
3169
+ };
3170
+
3171
+ // src/core/TyneqCachedEnumerable.ts
3172
+ var _refresh_dec, _a3, _b, _TyneqCachedEnumerable_decorators, _init3;
3173
+ _TyneqCachedEnumerable_decorators = [sequence];
3174
+ var _TyneqCachedEnumerable = class _TyneqCachedEnumerable extends (_b = TyneqEnumerableBase, _a3 = tyneqQueryNode, _refresh_dec = [builtin({ kind: "cache" })], _b) {
3175
+ constructor(source2, node) {
3176
+ super();
3177
+ _chunkOWKUE3ACcjs.__runInitializers.call(void 0, _init3, 5, this);
3178
+ this.source = void 0;
3179
+ this.cache = [];
3180
+ this.done = false;
3181
+ this.sourceEnumerator = null;
3182
+ this[_a3] = void 0;
3183
+ this.source = source2;
3184
+ this[tyneqQueryNode] = node != null ? node : null;
3185
+ }
3186
+ getEnumerator() {
3187
+ return new MemoizeEnumerator(this);
3188
+ }
3189
+ refresh() {
3190
+ var _a6, _b3;
3191
+ this.cache = [];
3192
+ this.done = false;
3193
+ (_b3 = (_a6 = this.sourceEnumerator) == null ? void 0 : _a6.return) == null ? void 0 : _b3.call(_a6);
3194
+ this.sourceEnumerator = null;
3195
+ return this;
3196
+ }
3197
+ tryGetAtFromCache(index) {
3198
+ var _a6, _b3;
3199
+ if (index < this.cache.length) {
3200
+ return { has: true, value: this.cache[index] };
3201
+ }
3202
+ if (this.done) {
3203
+ return { has: false };
3204
+ }
3205
+ if (this.sourceEnumerator === null) {
3206
+ this.sourceEnumerator = this.source.getEnumerator();
3207
+ }
3208
+ const next = this.sourceEnumerator.next();
3209
+ if (!next.done) {
3210
+ const value = next.value;
3211
+ this.cache.push(value);
3212
+ return { has: true, value };
3213
+ }
3214
+ this.done = true;
3215
+ (_b3 = (_a6 = this.sourceEnumerator).return) == null ? void 0 : _b3.call(_a6);
3216
+ this.sourceEnumerator = null;
3217
+ return { has: false };
3218
+ }
3219
+ createEnumerable(factory, node) {
3220
+ return new TyneqEnumerable(factory, node);
3221
+ }
3222
+ createOrderedEnumerable(keySelector, comparer, descending, node) {
3223
+ return new TyneqOrderedEnumerable(
3224
+ this,
3225
+ keySelector,
3226
+ comparer,
3227
+ descending,
3228
+ void 0,
3229
+ node
3230
+ );
3231
+ }
3232
+ createCachedEnumerable(source2, node) {
3233
+ return new _TyneqCachedEnumerable(source2, node);
3234
+ }
3235
+ };
3236
+ _init3 = _chunkOWKUE3ACcjs.__decoratorStart.call(void 0, _b);
3237
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init3, 1, "refresh", _refresh_dec, _TyneqCachedEnumerable);
3238
+ _TyneqCachedEnumerable = _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init3, 0, "TyneqCachedEnumerable", _TyneqCachedEnumerable_decorators, _TyneqCachedEnumerable);
3239
+ _chunkOWKUE3ACcjs.__runInitializers.call(void 0, _init3, 1, _TyneqCachedEnumerable);
3240
+ var TyneqCachedEnumerable = _TyneqCachedEnumerable;
3241
+
3242
+ // src/core/TyneqEnumerable.ts
3243
+ var _a4;
3244
+ var TyneqEnumerable = class _TyneqEnumerable extends (_a4 = TyneqEnumerableBase, tyneqQueryNode, _a4) {
3245
+ constructor(enumeratorFactory, node) {
3246
+ super();
3247
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ enumeratorFactory });
3248
+ this.enumeratorFactory = enumeratorFactory;
3249
+ this[tyneqQueryNode] = node != null ? node : null;
3250
+ }
3251
+ getEnumerator() {
3252
+ return this.enumeratorFactory.getEnumerator();
3253
+ }
3254
+ createEnumerable(factory, node) {
3255
+ return new _TyneqEnumerable(factory, node);
3256
+ }
3257
+ createOrderedEnumerable(keySelector, comparer, descending, node) {
3258
+ return new TyneqOrderedEnumerable(
3259
+ this,
3260
+ keySelector,
3261
+ comparer,
3262
+ descending,
3263
+ void 0,
3264
+ node
3265
+ );
3266
+ }
3267
+ createCachedEnumerable(source2, node) {
3268
+ return new TyneqCachedEnumerable(source2, node);
3269
+ }
3270
+ };
3271
+
3272
+ // src/enumerators/buffer/orderBy.ts
3273
+ var OrderByEnumerator = class extends TyneqBaseEnumerator {
3274
+ constructor(orderedEnumerable) {
3275
+ super();
3276
+ this.buffer = [];
3277
+ this.indexMap = [];
3278
+ this.currentIndex = 0;
3279
+ this.orderedEnumerable = orderedEnumerable;
3280
+ }
3281
+ initialize() {
3282
+ this.buffer = Array.from(this.orderedEnumerable.source);
3283
+ const sorter = this.getSorter(this.orderedEnumerable);
3284
+ this.indexMap = sorter.sort(this.buffer, this.buffer.length);
3285
+ }
3286
+ handleNext() {
3287
+ if (this.currentIndex >= this.indexMap.length) {
3288
+ return this.done();
3289
+ }
3290
+ const index = this.indexMap[this.currentIndex++];
3291
+ return this.yield(this.buffer[index]);
3292
+ }
3293
+ getSorter(base) {
3294
+ let sorter = null;
3295
+ for (let enumerable = base; enumerable !== null; enumerable = enumerable.parent) {
3296
+ sorter = enumerable.getSorter(sorter);
3297
+ }
3298
+ return sorter;
3299
+ }
3300
+ };
3301
+
3302
+ // src/core/ordering/TyneqOrderedEnumerable.ts
3303
+ var ASC_TO_DESC = {
3304
+ "orderBy": "orderByDescending",
3305
+ "thenBy": "thenByDescending"
3306
+ };
3307
+ var DESC_TO_ASC = {
3308
+ "orderByDescending": "orderBy",
3309
+ "thenByDescending": "thenBy"
3310
+ };
3311
+ var _thenByDescending_dec, _thenBy_dec, _a5, _b2, _TyneqOrderedEnumerable_decorators, _init4;
3312
+ _TyneqOrderedEnumerable_decorators = [sequence];
3313
+ var _TyneqOrderedEnumerable = class _TyneqOrderedEnumerable extends (_b2 = TyneqEnumerableBase, _a5 = tyneqQueryNode, _thenBy_dec = [builtin({ kind: "buffer" })], _thenByDescending_dec = [builtin({ kind: "buffer" })], _b2) {
3314
+ constructor(source2, keySelector, comparer, descending, parent, node) {
3315
+ super();
3316
+ _chunkOWKUE3ACcjs.__runInitializers.call(void 0, _init4, 5, this);
3317
+ this.keySelector = void 0;
3318
+ this.comparer = void 0;
3319
+ this.descending = void 0;
3320
+ this.source = void 0;
3321
+ this.parent = void 0;
3322
+ this[_a5] = void 0;
3323
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ source: source2 });
3324
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ keySelector });
3325
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ comparer });
3326
+ this.source = source2;
3327
+ this.keySelector = keySelector;
3328
+ this.comparer = comparer;
3329
+ this.descending = descending;
3330
+ this.parent = parent != null ? parent : null;
3331
+ this[tyneqQueryNode] = node != null ? node : null;
3332
+ }
3333
+ asc() {
3334
+ var _a6, _b3;
3335
+ if (!this.descending) {
3336
+ return this;
3337
+ }
3338
+ const currentNode = this[tyneqQueryNode];
3339
+ const node = currentNode ? new QueryNode((_a6 = DESC_TO_ASC[currentNode.operatorName]) != null ? _a6 : currentNode.operatorName, currentNode.args, currentNode.source, currentNode.category, currentNode.sourceKind) : null;
3340
+ return new _TyneqOrderedEnumerable(
3341
+ this.source,
3342
+ this.keySelector,
3343
+ this.comparer,
3344
+ false,
3345
+ (_b3 = this.parent) != null ? _b3 : void 0,
3346
+ node
3347
+ );
3348
+ }
3349
+ desc() {
3350
+ var _a6, _b3;
3351
+ if (this.descending) {
3352
+ return this;
3353
+ }
3354
+ const currentNode = this[tyneqQueryNode];
3355
+ const node = currentNode ? new QueryNode((_a6 = ASC_TO_DESC[currentNode.operatorName]) != null ? _a6 : currentNode.operatorName, currentNode.args, currentNode.source, currentNode.category, currentNode.sourceKind) : null;
3356
+ return new _TyneqOrderedEnumerable(
3357
+ this.source,
3358
+ this.keySelector,
3359
+ this.comparer,
3360
+ true,
3361
+ (_b3 = this.parent) != null ? _b3 : void 0,
3362
+ node
3363
+ );
3364
+ }
3365
+ getEnumerator() {
3366
+ return new OrderByEnumerator(this);
3367
+ }
3368
+ getSorter(next) {
3369
+ return new TyneqEnumerableSorter(
3370
+ this.keySelector,
3371
+ this.comparer,
3372
+ this.descending,
3373
+ next != null ? next : void 0
3374
+ );
3375
+ }
3376
+ thenBy(keySelector, comparer) {
3377
+ const thenByArgs = comparer !== void 0 ? [keySelector, comparer] : [keySelector];
3378
+ const node = new QueryNode("thenBy", thenByArgs, this[tyneqQueryNode], "buffer");
3379
+ return new _TyneqOrderedEnumerable(
3380
+ this.source,
3381
+ keySelector,
3382
+ comparer != null ? comparer : TyneqComparer.defaultComparer,
3383
+ false,
3384
+ this,
3385
+ node
3386
+ );
3387
+ }
3388
+ thenByDescending(keySelector, comparer) {
3389
+ const thenByDescArgs = comparer !== void 0 ? [keySelector, comparer] : [keySelector];
3390
+ const node = new QueryNode("thenByDescending", thenByDescArgs, this[tyneqQueryNode], "buffer");
3391
+ return new _TyneqOrderedEnumerable(
3392
+ this.source,
3393
+ keySelector,
3394
+ comparer != null ? comparer : TyneqComparer.defaultComparer,
3395
+ true,
3396
+ this,
3397
+ node
3398
+ );
3399
+ }
3400
+ createEnumerable(factory, node) {
3401
+ return new TyneqEnumerable(factory, node);
3402
+ }
3403
+ createOrderedEnumerable(keySelector, comparer, descending, node) {
3404
+ return new _TyneqOrderedEnumerable(
3405
+ this.source,
3406
+ keySelector,
3407
+ comparer,
3408
+ descending,
3409
+ this,
3410
+ node
3411
+ );
3412
+ }
3413
+ createCachedEnumerable(source2, node) {
3414
+ return new TyneqCachedEnumerable(source2, node);
3415
+ }
3416
+ };
3417
+ _init4 = _chunkOWKUE3ACcjs.__decoratorStart.call(void 0, _b2);
3418
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init4, 1, "thenBy", _thenBy_dec, _TyneqOrderedEnumerable);
3419
+ _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init4, 1, "thenByDescending", _thenByDescending_dec, _TyneqOrderedEnumerable);
3420
+ _TyneqOrderedEnumerable = _chunkOWKUE3ACcjs.__decorateElement.call(void 0, _init4, 0, "TyneqOrderedEnumerable", _TyneqOrderedEnumerable_decorators, _TyneqOrderedEnumerable);
3421
+ _chunkOWKUE3ACcjs.__runInitializers.call(void 0, _init4, 1, _TyneqOrderedEnumerable);
3422
+ var TyneqOrderedEnumerable = _TyneqOrderedEnumerable;
3423
+
3424
+ // src/plugin/decorators/source.ts
3425
+ function source(options = {}) {
3426
+ return function(method, context) {
3427
+ var _a6, _b3;
3428
+ const operatorName = (_a6 = options.name) != null ? _a6 : context.name;
3429
+ const operatorSource = (_b3 = options.source) != null ? _b3 : "external";
3430
+ OperatorRegistry.registerSource(operatorName, method, operatorSource);
3431
+ };
3432
+ }
3433
+
3434
+ // src/plugin/RegistrationUtility.ts
3435
+ var RegistrationUtility = class _RegistrationUtility {
3436
+ constructor() {
3437
+ }
3438
+ /**
3439
+ * Builds a new sequence from an enumerator factory and registers a query plan node.
3440
+ *
3441
+ * @remarks
3442
+ * Every standard (non-terminal, non-ordered, non-cached) operator `impl` follows
3443
+ * the same pattern: get the `SequenceFactory` view of `this`, create a `QueryNode`,
3444
+ * then call `factory.createEnumerable(enumeratorFactory, node)`. This method
3445
+ * centralises that pattern so decorator and factory `impl` bodies stay minimal.
3446
+ *
3447
+ * @param sequence - The current sequence (`this` inside an `impl` function).
3448
+ * @param name - Operator name, used as the query node label.
3449
+ * @param userArgs - Arguments passed by the caller, captured in the query node.
3450
+ * @param category - Operator category for the query node.
3451
+ * @param enumeratorFactory - The factory that produces the new enumerator.
3452
+ */
3453
+ static buildEnumerable(sequence2, name, userArgs, category, enumeratorFactory) {
3454
+ const factory = _RegistrationUtility.asSequenceFactory(sequence2);
3455
+ const node = new QueryNode(name, userArgs, factory[tyneqQueryNode], category);
3456
+ return factory.createEnumerable(enumeratorFactory, node);
3457
+ }
3458
+ /**
3459
+ * Creates a `QueryPlanNode` for an operator, linked to the upstream node on `sequence`.
3460
+ *
3461
+ * @remarks
3462
+ * Used by `createOrderedOperator` and `createCachedOperator`, which hand the node
3463
+ * directly to their own factory function (because those factories construct the result
3464
+ * sequence themselves rather than delegating to `createEnumerable`).
3465
+ *
3466
+ * @param sequence - The current sequence (`this` inside an `impl` function).
3467
+ * @param name - Operator name, used as the query node label.
3468
+ * @param userArgs - Arguments passed by the caller, captured in the query node.
3469
+ * @param category - Operator category for the query node.
3470
+ */
3471
+ static buildQueryNode(sequence2, name, userArgs, category) {
3472
+ const factory = _RegistrationUtility.asSequenceFactory(sequence2);
3473
+ return new QueryNode(name, userArgs, factory[tyneqQueryNode], category);
3474
+ }
3475
+ /**
3476
+ * Narrows a `TyneqEnumerableBase` to its `SequenceFactory` view.
3477
+ *
3478
+ * @remarks
3479
+ * The double-cast (`as unknown as SequenceFactory`) is required because
3480
+ * `createEnumerable` and `createCachedEnumerable` are `protected` on the
3481
+ * class hierarchy. `SequenceFactory` is a structural interface that describes
3482
+ * the same shape, allowing registration-time closures to call factory methods
3483
+ * without changing their access modifier. This is a known architectural trade-off
3484
+ * documented in `tasks/lessons.md` under "Architecture Decisions".
3485
+ */
3486
+ static asSequenceFactory(sequence2) {
3487
+ return sequence2;
3488
+ }
3489
+ };
3490
+
3491
+ // src/plugin/decorators/operator.ts
3492
+ function operator(name, category, validate) {
3493
+ return function(target, _context) {
3494
+ if (!_chunkOWKUE3ACcjs.reflect.call(void 0, target.prototype).hasMethod("handleNext")) {
3495
+ throw new PluginError(
3496
+ `@operator("${name}"): class "${target.name}" must define a protected handleNext(): IteratorResult<T> method. Ensure the class extends TyneqEnumerator<TInput, TOutput>.`,
3497
+ "operator",
3498
+ target.name
3499
+ );
3500
+ }
3501
+ OperatorRegistry.register({
3502
+ metadata: OperatorMetadata.forCategory(category, name, TyneqEnumerableBase),
3503
+ impl: function(...userArgs) {
3504
+ validate == null ? void 0 : validate(...userArgs);
3505
+ const base = this;
3506
+ return RegistrationUtility.buildEnumerable(this, name, userArgs, category, {
3507
+ getEnumerator() {
3508
+ return new target(base.getEnumerator(), ...userArgs);
3509
+ }
3510
+ });
3511
+ }
3512
+ });
3513
+ return target;
3514
+ };
3515
+ }
3516
+
3517
+ // src/plugin/decorators/orderedOperator.ts
3518
+ function orderedOperator(name, category, validate) {
3519
+ return function(target, _context) {
3520
+ if (!_chunkOWKUE3ACcjs.reflect.call(void 0, target.prototype).hasMethod("handleNext")) {
3521
+ throw new PluginError(
3522
+ `@orderedOperator("${name}"): class "${target.name}" must define a protected handleNext(): IteratorResult<T> method. Ensure the class extends TyneqOrderedEnumerator<T>.`,
3523
+ "orderedOperator",
3524
+ target.name
3525
+ );
3526
+ }
3527
+ OperatorRegistry.register({
3528
+ metadata: OperatorMetadata.forCategory(category, name, TyneqOrderedEnumerable),
3529
+ impl: function(...userArgs) {
3530
+ validate == null ? void 0 : validate(...userArgs);
3531
+ const base = this;
3532
+ return RegistrationUtility.buildEnumerable(this, name, userArgs, category, {
3533
+ getEnumerator: () => new target(base, ...userArgs)
3534
+ });
3535
+ }
3536
+ });
3537
+ return target;
3538
+ };
3539
+ }
3540
+
3541
+ // src/plugin/decorators/cachedOperator.ts
3542
+ function cachedOperator(name, category, validate) {
3543
+ return function(target, _context) {
3544
+ if (!_chunkOWKUE3ACcjs.reflect.call(void 0, target.prototype).hasMethod("handleNext")) {
3545
+ throw new PluginError(
3546
+ `@cachedOperator("${name}"): class "${target.name}" must define a protected handleNext(): IteratorResult<T> method. Ensure the class extends TyneqCachedEnumerator<T>.`,
3547
+ "cachedOperator",
3548
+ target.name
3549
+ );
3550
+ }
3551
+ OperatorRegistry.register({
3552
+ metadata: OperatorMetadata.forCategory(category, name, TyneqCachedEnumerable),
3553
+ impl: function(...userArgs) {
3554
+ validate == null ? void 0 : validate(...userArgs);
3555
+ const base = this;
3556
+ return RegistrationUtility.buildEnumerable(this, name, userArgs, category, {
3557
+ getEnumerator: () => new target(base, ...userArgs)
3558
+ });
3559
+ }
3560
+ });
3561
+ return target;
3562
+ };
3563
+ }
3564
+
3565
+ // src/plugin/decorators/terminal.ts
3566
+ function terminal(name, validate) {
3567
+ return function(target, _context) {
3568
+ if (!_chunkOWKUE3ACcjs.reflect.call(void 0, target.prototype).hasMethod("process")) {
3569
+ throw new PluginError(
3570
+ `@terminal("${name}"): class "${target.name}" must define a public process(): TResult method. Ensure the class extends TyneqTerminalOperator<TSource, TResult>.`,
3571
+ "terminal",
3572
+ target.name
3573
+ );
3574
+ }
3575
+ OperatorRegistry.register({
3576
+ metadata: OperatorMetadata.terminal(name, TyneqEnumerableBase),
3577
+ impl: function(...userArgs) {
3578
+ validate == null ? void 0 : validate(...userArgs);
3579
+ return new target(this, ...userArgs).process();
3580
+ }
3581
+ });
3582
+ return target;
3583
+ };
3584
+ }
3585
+
3586
+ // src/plugin/decorators/orderedTerminal.ts
3587
+ function orderedTerminal(name, validate) {
3588
+ return function(target, _context) {
3589
+ OperatorRegistry.register({
3590
+ metadata: OperatorMetadata.terminal(name, TyneqOrderedEnumerable),
3591
+ impl: function(...userArgs) {
3592
+ validate == null ? void 0 : validate(...userArgs);
3593
+ const source2 = this;
3594
+ return new target(source2, ...userArgs).process();
3595
+ }
3596
+ });
3597
+ return target;
3598
+ };
3599
+ }
3600
+
3601
+ // src/plugin/decorators/cachedTerminal.ts
3602
+ function cachedTerminal(name, validate) {
3603
+ return function(target, _context) {
3604
+ OperatorRegistry.register({
3605
+ metadata: OperatorMetadata.terminal(name, TyneqCachedEnumerable),
3606
+ impl: function(...userArgs) {
3607
+ validate == null ? void 0 : validate(...userArgs);
3608
+ const source2 = this;
3609
+ return new target(source2, ...userArgs).process();
3610
+ }
3611
+ });
3612
+ return target;
3613
+ };
3614
+ }
3615
+
3616
+ // src/plugin/registration/createOperator.ts
3617
+ function createOperator(config) {
3618
+ OperatorRegistry.register({
3619
+ metadata: OperatorMetadata.forCategory(config.category, config.name, TyneqEnumerableBase, config.source),
3620
+ impl: function(...args) {
3621
+ var _a6;
3622
+ (_a6 = config.validate) == null ? void 0 : _a6.call(config, ...args);
3623
+ return RegistrationUtility.buildEnumerable(
3624
+ this,
3625
+ config.name,
3626
+ args,
3627
+ config.category,
3628
+ config.factory(this, ...args)
3629
+ );
3630
+ }
3631
+ });
3632
+ }
3633
+
3634
+ // src/plugin/registration/createGeneratorOperator.ts
3635
+ function createGeneratorOperator(config) {
3636
+ var _a6;
3637
+ const category = (_a6 = config.category) != null ? _a6 : "streaming";
3638
+ OperatorRegistry.register({
3639
+ metadata: OperatorMetadata.forCategory(category, config.name, TyneqEnumerableBase, config.source),
3640
+ impl: function(...args) {
3641
+ var _a7;
3642
+ (_a7 = config.validate) == null ? void 0 : _a7.call(config, ...args);
3643
+ const source2 = this;
3644
+ return RegistrationUtility.buildEnumerable(this, config.name, args, category, {
3645
+ // IterableIterator<T> is structurally compatible with Enumerator<T>
3646
+ getEnumerator: () => config.generator(source2, ...args)
3647
+ });
3648
+ }
3649
+ });
3650
+ }
3651
+
3652
+ // src/plugin/registration/createOrderedOperator.ts
3653
+ function createOrderedOperator(config) {
3654
+ OperatorRegistry.register({
3655
+ metadata: OperatorMetadata.forCategory(config.category, config.name, TyneqOrderedEnumerable, config.source),
3656
+ impl: function(...userArgs) {
3657
+ var _a6;
3658
+ (_a6 = config.validate) == null ? void 0 : _a6.call(config, ...userArgs);
3659
+ const source2 = this;
3660
+ const node = RegistrationUtility.buildQueryNode(this, config.name, userArgs, config.category);
3661
+ return config.factory(source2, node, ...userArgs);
3662
+ }
3663
+ });
3664
+ }
3665
+
3666
+ // src/plugin/registration/createCachedOperator.ts
3667
+ function createCachedOperator(config) {
3668
+ OperatorRegistry.register({
3669
+ metadata: OperatorMetadata.forCategory(config.category, config.name, TyneqCachedEnumerable, config.source),
3670
+ impl: function(...userArgs) {
3671
+ var _a6;
3672
+ (_a6 = config.validate) == null ? void 0 : _a6.call(config, ...userArgs);
3673
+ const source2 = this;
3674
+ const node = RegistrationUtility.buildQueryNode(this, config.name, userArgs, config.category);
3675
+ return config.factory(source2, node, ...userArgs);
3676
+ }
3677
+ });
3678
+ }
3679
+
3680
+ // src/plugin/registration/createTerminalOperator.ts
3681
+ function createTerminalOperator(config) {
3682
+ OperatorRegistry.register({
3683
+ metadata: OperatorMetadata.terminal(config.name, TyneqEnumerableBase, config.source),
3684
+ impl: function(...args) {
3685
+ var _a6;
3686
+ (_a6 = config.validate) == null ? void 0 : _a6.call(config, ...args);
3687
+ return config.execute(this, ...args);
3688
+ }
3689
+ });
3690
+ }
3691
+
3692
+ // src/plugin/registration/createOrderedTerminalOperator.ts
3693
+ function createOrderedTerminalOperator(config) {
3694
+ OperatorRegistry.register({
3695
+ metadata: OperatorMetadata.terminal(config.name, TyneqOrderedEnumerable, config.source),
3696
+ impl: function(...args) {
3697
+ var _a6;
3698
+ (_a6 = config.validate) == null ? void 0 : _a6.call(config, ...args);
3699
+ return config.execute(this, ...args);
3700
+ }
3701
+ });
3702
+ }
3703
+
3704
+ // src/plugin/registration/createCachedTerminalOperator.ts
3705
+ function createCachedTerminalOperator(config) {
3706
+ OperatorRegistry.register({
3707
+ metadata: OperatorMetadata.terminal(config.name, TyneqCachedEnumerable, config.source),
3708
+ impl: function(...args) {
3709
+ var _a6;
3710
+ (_a6 = config.validate) == null ? void 0 : _a6.call(config, ...args);
3711
+ return config.execute(this, ...args);
3712
+ }
3713
+ });
3714
+ }
3715
+
3716
+ // src/core/enumerators/TyneqOrderedEnumerator.ts
3717
+ var TyneqOrderedEnumerator = class extends TyneqBaseEnumerator {
3718
+ constructor(orderedSource) {
3719
+ super();
3720
+ this.orderedSource = orderedSource;
3721
+ }
3722
+ disposeSource() {
3723
+ }
3724
+ };
3725
+
3726
+ // src/core/enumerators/TyneqCachedEnumerator.ts
3727
+ var TyneqCachedEnumerator = class extends TyneqBaseEnumerator {
3728
+ constructor(cachedSource) {
3729
+ super();
3730
+ this.cachedSource = cachedSource;
3731
+ }
3732
+ disposeSource() {
3733
+ }
3734
+ };
3735
+
3736
+ // src/core/terminal/TyneqOrderedTerminalOperator.ts
3737
+ var TyneqOrderedTerminalOperator = class {
3738
+ constructor(source2) {
3739
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ source: source2 });
3740
+ this.source = source2;
3741
+ }
3742
+ };
3743
+
3744
+ // src/core/terminal/TyneqCachedTerminalOperator.ts
3745
+ var TyneqCachedTerminalOperator = class {
3746
+ constructor(source2) {
3747
+ _chunkOWKUE3ACcjs.ArgumentUtility.checkNotOptional({ source: source2 });
3748
+ this.source = source2;
3749
+ }
3750
+ };
3751
+
3752
+
3753
+
3754
+
3755
+
3756
+
3757
+
3758
+
3759
+
3760
+
3761
+
3762
+
3763
+
3764
+
3765
+
3766
+
3767
+
3768
+
3769
+
3770
+
3771
+
3772
+
3773
+
3774
+
3775
+
3776
+
3777
+
3778
+
3779
+
3780
+
3781
+
3782
+
3783
+
3784
+
3785
+
3786
+
3787
+
3788
+ exports.TyneqBaseEnumerator = TyneqBaseEnumerator; exports.TyneqComparer = TyneqComparer; exports.tyneqQueryNode = tyneqQueryNode; exports.isSourceNode = isSourceNode; exports.QueryNode = QueryNode; exports.PluginError = PluginError; exports.OperatorMetadata = OperatorMetadata; exports.RegistryError = RegistryError; exports.OperatorRegistry = OperatorRegistry; exports.TyneqTerminalOperator = TyneqTerminalOperator; exports.InvalidOperationError = InvalidOperationError; exports.EnumeratorUtility = EnumeratorUtility; exports.SequenceContainsNoElementsError = SequenceContainsNoElementsError; exports.TyneqEnumerator = TyneqEnumerator; exports.TyneqOrderedEnumerable = TyneqOrderedEnumerable; exports.TyneqCachedEnumerable = TyneqCachedEnumerable; exports.TyneqEnumerable = TyneqEnumerable; exports.source = source; exports.operator = operator; exports.orderedOperator = orderedOperator; exports.cachedOperator = cachedOperator; exports.terminal = terminal; exports.orderedTerminal = orderedTerminal; exports.cachedTerminal = cachedTerminal; exports.createOperator = createOperator; exports.createGeneratorOperator = createGeneratorOperator; exports.createOrderedOperator = createOrderedOperator; exports.createCachedOperator = createCachedOperator; exports.createTerminalOperator = createTerminalOperator; exports.createOrderedTerminalOperator = createOrderedTerminalOperator; exports.createCachedTerminalOperator = createCachedTerminalOperator; exports.TyneqOrderedEnumerator = TyneqOrderedEnumerator; exports.TyneqCachedEnumerator = TyneqCachedEnumerator; exports.TyneqOrderedTerminalOperator = TyneqOrderedTerminalOperator; exports.TyneqCachedTerminalOperator = TyneqCachedTerminalOperator;