@athrio/loom 0.0.3 → 0.0.5

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.
@@ -3829,8 +3829,8 @@ var Combiner_exports = /* @__PURE__ */ __exportAll({
3829
3829
  intercalate: () => intercalate,
3830
3830
  last: () => last$3,
3831
3831
  make: () => make$74,
3832
- max: () => max$9,
3833
- min: () => min$9
3832
+ max: () => max$10,
3833
+ min: () => min$10
3834
3834
  });
3835
3835
  /**
3836
3836
  * Creates a `Combiner` from a binary function.
@@ -3926,7 +3926,7 @@ function flip$6(combiner) {
3926
3926
  * @category constructors
3927
3927
  * @since 4.0.0
3928
3928
  */
3929
- function min$9(order) {
3929
+ function min$10(order) {
3930
3930
  return make$74((self, that) => order(self, that) === -1 ? self : that);
3931
3931
  }
3932
3932
  /**
@@ -3961,7 +3961,7 @@ function min$9(order) {
3961
3961
  * @category constructors
3962
3962
  * @since 4.0.0
3963
3963
  */
3964
- function max$9(order) {
3964
+ function max$10(order) {
3965
3965
  return make$74((self, that) => order(self, that) === 1 ? self : that);
3966
3966
  }
3967
3967
  /**
@@ -5343,8 +5343,8 @@ var Order_exports = /* @__PURE__ */ __exportAll({
5343
5343
  make: () => make$73,
5344
5344
  makeReducer: () => makeReducer$5,
5345
5345
  mapInput: () => mapInput$4,
5346
- max: () => max$8,
5347
- min: () => min$8
5346
+ max: () => max$9,
5347
+ min: () => min$9
5348
5348
  });
5349
5349
  /**
5350
5350
  * Creates a new `Order` instance from a comparison function.
@@ -5979,7 +5979,7 @@ var isGreaterThanOrEqualTo$8 = (O) => dual(2, (self, that) => O(self, that) !==
5979
5979
  * @category comparisons
5980
5980
  * @since 2.0.0
5981
5981
  */
5982
- var min$8 = (O) => dual(2, (self, that) => self === that || O(self, that) < 1 ? self : that);
5982
+ var min$9 = (O) => dual(2, (self, that) => self === that || O(self, that) < 1 ? self : that);
5983
5983
  /**
5984
5984
  * Returns the maximum of two values according to the given order. If they are equal, returns the first argument.
5985
5985
  *
@@ -6010,7 +6010,7 @@ var min$8 = (O) => dual(2, (self, that) => self === that || O(self, that) < 1 ?
6010
6010
  * @category comparisons
6011
6011
  * @since 2.0.0
6012
6012
  */
6013
- var max$8 = (O) => dual(2, (self, that) => self === that || O(self, that) > -1 ? self : that);
6013
+ var max$9 = (O) => dual(2, (self, that) => self === that || O(self, that) > -1 ? self : that);
6014
6014
  /**
6015
6015
  * Restricts a value between a minimum and a maximum according to the given order.
6016
6016
  *
@@ -6044,7 +6044,7 @@ var max$8 = (O) => dual(2, (self, that) => self === that || O(self, that) > -1 ?
6044
6044
  * @category comparisons
6045
6045
  * @since 2.0.0
6046
6046
  */
6047
- var clamp$7 = (O) => dual(2, (self, options) => min$8(O)(options.maximum, max$8(O)(options.minimum, self)));
6047
+ var clamp$7 = (O) => dual(2, (self, options) => min$9(O)(options.maximum, max$9(O)(options.minimum, self)));
6048
6048
  /**
6049
6049
  * Checks whether a value is between a minimum and a maximum (inclusive) according to the given order.
6050
6050
  *
@@ -10209,15 +10209,15 @@ var Iterable_exports = /* @__PURE__ */ __exportAll({
10209
10209
  prepend: () => prepend$5,
10210
10210
  prependAll: () => prependAll$4,
10211
10211
  range: () => range$3,
10212
- reduce: () => reduce$13,
10212
+ reduce: () => reduce$12,
10213
10213
  repeat: () => repeat$5,
10214
10214
  replicate: () => replicate$3,
10215
10215
  scan: () => scan$3,
10216
10216
  size: () => size$22,
10217
10217
  some: () => some$12,
10218
- take: () => take$13,
10218
+ take: () => take$12,
10219
10219
  takeWhile: () => takeWhile$4,
10220
- unfold: () => unfold$3,
10220
+ unfold: () => unfold$2,
10221
10221
  zip: () => zip$6,
10222
10222
  zipWith: () => zipWith$6
10223
10223
  });
@@ -10722,7 +10722,7 @@ var headUnsafe$1 = (self) => {
10722
10722
  * @category getters
10723
10723
  * @since 2.0.0
10724
10724
  */
10725
- var take$13 = /*#__PURE__*/ dual(2, (self, n) => ({ [Symbol.iterator]() {
10725
+ var take$12 = /*#__PURE__*/ dual(2, (self, n) => ({ [Symbol.iterator]() {
10726
10726
  let i = 0;
10727
10727
  const iterator = self[Symbol.iterator]();
10728
10728
  return { next() {
@@ -12059,7 +12059,7 @@ var some$12 = /*#__PURE__*/ dual(2, (self, predicate) => {
12059
12059
  * @category constructors
12060
12060
  * @since 2.0.0
12061
12061
  */
12062
- var unfold$3 = (b, f) => ({ [Symbol.iterator]() {
12062
+ var unfold$2 = (b, f) => ({ [Symbol.iterator]() {
12063
12063
  let next = b;
12064
12064
  return { next() {
12065
12065
  const ab = f(next);
@@ -12168,7 +12168,7 @@ var forEach$11 = /*#__PURE__*/ dual(2, (self, f) => {
12168
12168
  * @category folding
12169
12169
  * @since 2.0.0
12170
12170
  */
12171
- var reduce$13 = /*#__PURE__*/ dual(3, (self, b, f) => {
12171
+ var reduce$12 = /*#__PURE__*/ dual(3, (self, b, f) => {
12172
12172
  if (Array.isArray(self)) return self.reduce(f, b);
12173
12173
  let i = 0;
12174
12174
  let result = b;
@@ -12439,7 +12439,7 @@ var Record_exports = /* @__PURE__ */ __exportAll({
12439
12439
  modify: () => modify$15,
12440
12440
  partition: () => partition$5,
12441
12441
  pop: () => pop,
12442
- reduce: () => reduce$12,
12442
+ reduce: () => reduce$11,
12443
12443
  remove: () => remove$15,
12444
12444
  replace: () => replace$3,
12445
12445
  separate: () => separate$2,
@@ -13181,7 +13181,7 @@ var isSubrecord = /*#__PURE__*/ isSubrecordBy(/*#__PURE__*/ asEquivalence());
13181
13181
  * @category folding
13182
13182
  * @since 2.0.0
13183
13183
  */
13184
- var reduce$12 = /*#__PURE__*/ dual(3, (self, zero, f) => {
13184
+ var reduce$11 = /*#__PURE__*/ dual(3, (self, zero, f) => {
13185
13185
  let out = zero;
13186
13186
  for (const key of keys$10(self)) out = f(out, self[key], key);
13187
13187
  return out;
@@ -13522,8 +13522,8 @@ var Array_exports = /* @__PURE__ */ __exportAll({
13522
13522
  match: () => match$11,
13523
13523
  matchLeft: () => matchLeft,
13524
13524
  matchRight: () => matchRight,
13525
- max: () => max$7,
13526
- min: () => min$7,
13525
+ max: () => max$8,
13526
+ min: () => min$8,
13527
13527
  modify: () => modify$14,
13528
13528
  modifyHeadNonEmpty: () => modifyHeadNonEmpty,
13529
13529
  modifyLastNonEmpty: () => modifyLastNonEmpty,
@@ -13533,7 +13533,7 @@ var Array_exports = /* @__PURE__ */ __exportAll({
13533
13533
  prepend: () => prepend$4,
13534
13534
  prependAll: () => prependAll$3,
13535
13535
  range: () => range$2,
13536
- reduce: () => reduce$11,
13536
+ reduce: () => reduce$10,
13537
13537
  reduceRight: () => reduceRight$1,
13538
13538
  remove: () => remove$14,
13539
13539
  replace: () => replace$2,
@@ -13556,12 +13556,12 @@ var Array_exports = /* @__PURE__ */ __exportAll({
13556
13556
  splitWhere: () => splitWhere$1,
13557
13557
  tail: () => tail$1,
13558
13558
  tailNonEmpty: () => tailNonEmpty$1,
13559
- take: () => take$12,
13559
+ take: () => take$11,
13560
13560
  takeRight: () => takeRight$3,
13561
13561
  takeWhile: () => takeWhile$3,
13562
13562
  takeWhileFilter: () => takeWhileFilter$2,
13563
13563
  unappend: () => unappend,
13564
- unfold: () => unfold$2,
13564
+ unfold: () => unfold$1,
13565
13565
  union: () => union$8,
13566
13566
  unionWith: () => unionWith,
13567
13567
  unprepend: () => unprepend$1,
@@ -14606,7 +14606,7 @@ var initNonEmpty = (self) => self.slice(0, -1);
14606
14606
  * @category getters
14607
14607
  * @since 2.0.0
14608
14608
  */
14609
- var take$12 = /*#__PURE__*/ dual(2, (self, n) => {
14609
+ var take$11 = /*#__PURE__*/ dual(2, (self, n) => {
14610
14610
  const input = fromIterable$15(self);
14611
14611
  return input.slice(0, clamp$6(n, input));
14612
14612
  });
@@ -15828,7 +15828,7 @@ var copy$1 = (self) => self.slice();
15828
15828
  * @since 3.8.4
15829
15829
  */
15830
15830
  var pad$1 = /*#__PURE__*/ dual(3, (self, n, fill) => {
15831
- if (self.length >= n) return take$12(self, n);
15831
+ if (self.length >= n) return take$11(self, n);
15832
15832
  return appendAll$3(self, makeBy$1(n - self.length, () => fill));
15833
15833
  });
15834
15834
  /**
@@ -16551,7 +16551,7 @@ var separate$1 = /*#__PURE__*/ partition$4(identity$1);
16551
16551
  * @category folding
16552
16552
  * @since 2.0.0
16553
16553
  */
16554
- var reduce$11 = /*#__PURE__*/ dual(3, (self, b, f) => fromIterable$15(self).reduce((b, a, i) => f(b, a, i), b));
16554
+ var reduce$10 = /*#__PURE__*/ dual(3, (self, b, f) => fromIterable$15(self).reduce((b, a, i) => f(b, a, i), b));
16555
16555
  /**
16556
16556
  * Folds an iterable from right to left into a single value.
16557
16557
  *
@@ -16825,7 +16825,7 @@ var extend = /*#__PURE__*/ dual(2, (self, f) => self.map((_, i, as) => f(as.slic
16825
16825
  * @category elements
16826
16826
  * @since 2.0.0
16827
16827
  */
16828
- var min$7 = /*#__PURE__*/ dual(2, (self, O) => self.reduce(min$8(O)));
16828
+ var min$8 = /*#__PURE__*/ dual(2, (self, O) => self.reduce(min$9(O)));
16829
16829
  /**
16830
16830
  * Returns the maximum element of a non-empty array according to the given
16831
16831
  * `Order`.
@@ -16844,7 +16844,7 @@ var min$7 = /*#__PURE__*/ dual(2, (self, O) => self.reduce(min$8(O)));
16844
16844
  * @category elements
16845
16845
  * @since 2.0.0
16846
16846
  */
16847
- var max$7 = /*#__PURE__*/ dual(2, (self, O) => self.reduce(max$8(O)));
16847
+ var max$8 = /*#__PURE__*/ dual(2, (self, O) => self.reduce(max$9(O)));
16848
16848
  /**
16849
16849
  * Builds an array by repeatedly applying a function to a seed value. The
16850
16850
  * function returns `Option.some([element, nextSeed])` to continue, or
@@ -16865,7 +16865,7 @@ var max$7 = /*#__PURE__*/ dual(2, (self, O) => self.reduce(max$8(O)));
16865
16865
  * @category constructors
16866
16866
  * @since 2.0.0
16867
16867
  */
16868
- var unfold$2 = (b, f) => {
16868
+ var unfold$1 = (b, f) => {
16869
16869
  const out = [];
16870
16870
  let next = b;
16871
16871
  while (true) {
@@ -17376,8 +17376,8 @@ var BigDecimal_exports = /* @__PURE__ */ __exportAll({
17376
17376
  isZero: () => isZero$1,
17377
17377
  make: () => make$70,
17378
17378
  makeNormalizedUnsafe: () => makeNormalizedUnsafe,
17379
- max: () => max$6,
17380
- min: () => min$6,
17379
+ max: () => max$7,
17380
+ min: () => min$7,
17381
17381
  multiply: () => multiply$2,
17382
17382
  multiplyAll: () => multiplyAll$2,
17383
17383
  negate: () => negate$1,
@@ -18121,7 +18121,7 @@ var clamp$5 = /*#__PURE__*/ clamp$7(Order$8);
18121
18121
  * @category math
18122
18122
  * @since 2.0.0
18123
18123
  */
18124
- var min$6 = /*#__PURE__*/ min$8(Order$8);
18124
+ var min$7 = /*#__PURE__*/ min$9(Order$8);
18125
18125
  /**
18126
18126
  * Returns the maximum between two `BigDecimal`s.
18127
18127
  *
@@ -18146,7 +18146,7 @@ var min$6 = /*#__PURE__*/ min$8(Order$8);
18146
18146
  * @category math
18147
18147
  * @since 2.0.0
18148
18148
  */
18149
- var max$6 = /*#__PURE__*/ max$8(Order$8);
18149
+ var max$7 = /*#__PURE__*/ max$9(Order$8);
18150
18150
  /**
18151
18151
  * Determines the sign of a given `BigDecimal`.
18152
18152
  *
@@ -18962,8 +18962,8 @@ var BigInt_exports = /* @__PURE__ */ __exportAll({
18962
18962
  isLessThan: () => isLessThan$6,
18963
18963
  isLessThanOrEqualTo: () => isLessThanOrEqualTo$6,
18964
18964
  lcm: () => lcm,
18965
- max: () => max$5,
18966
- min: () => min$5,
18965
+ max: () => max$6,
18966
+ min: () => min$6,
18967
18967
  multiply: () => multiply$1,
18968
18968
  multiplyAll: () => multiplyAll$1,
18969
18969
  remainder: () => remainder$1,
@@ -19413,7 +19413,7 @@ var clamp$4 = /*#__PURE__*/ clamp$7(Order$7);
19413
19413
  * @category math
19414
19414
  * @since 2.0.0
19415
19415
  */
19416
- var min$5 = /*#__PURE__*/ min$8(Order$7);
19416
+ var min$6 = /*#__PURE__*/ min$9(Order$7);
19417
19417
  /**
19418
19418
  * Returns the maximum between two `bigint`s.
19419
19419
  *
@@ -19435,7 +19435,7 @@ var min$5 = /*#__PURE__*/ min$8(Order$7);
19435
19435
  * @category math
19436
19436
  * @since 2.0.0
19437
19437
  */
19438
- var max$5 = /*#__PURE__*/ max$8(Order$7);
19438
+ var max$6 = /*#__PURE__*/ max$9(Order$7);
19439
19439
  /**
19440
19440
  * Determines the sign of a given `bigint`.
19441
19441
  *
@@ -19853,7 +19853,7 @@ var ReducerMultiply$1 = /*#__PURE__*/ make$76((a, b) => a * b, bigint1$1, (colle
19853
19853
  * @category math
19854
19854
  * @since 4.0.0
19855
19855
  */
19856
- var CombinerMax$1 = /*#__PURE__*/ max$9(Order$7);
19856
+ var CombinerMax$1 = /*#__PURE__*/ max$10(Order$7);
19857
19857
  /**
19858
19858
  * Combiner that returns the minimum `bigint`.
19859
19859
  *
@@ -19867,7 +19867,7 @@ var CombinerMax$1 = /*#__PURE__*/ max$9(Order$7);
19867
19867
  * @category math
19868
19868
  * @since 4.0.0
19869
19869
  */
19870
- var CombinerMin$1 = /*#__PURE__*/ min$9(Order$7);
19870
+ var CombinerMin$1 = /*#__PURE__*/ min$10(Order$7);
19871
19871
  //#endregion
19872
19872
  //#region ../../node_modules/effect/dist/Boolean.js
19873
19873
  /**
@@ -21316,10 +21316,10 @@ var Duration_exports = /* @__PURE__ */ __exportAll({
21316
21316
  isZero: () => isZero,
21317
21317
  match: () => match$9,
21318
21318
  matchPair: () => matchPair,
21319
- max: () => max$4,
21319
+ max: () => max$5,
21320
21320
  micros: () => micros,
21321
21321
  millis: () => millis,
21322
- min: () => min$4,
21322
+ min: () => min$5,
21323
21323
  minutes: () => minutes,
21324
21324
  nanos: () => nanos,
21325
21325
  negate: () => negate,
@@ -22229,7 +22229,7 @@ var Equivalence$6 = (self, that) => matchPair(self, that, {
22229
22229
  * @category ordering
22230
22230
  * @since 2.0.0
22231
22231
  */
22232
- var min$4 = /*#__PURE__*/ min$8(Order$5);
22232
+ var min$5 = /*#__PURE__*/ min$9(Order$5);
22233
22233
  /**
22234
22234
  * Returns the larger of two Durations.
22235
22235
  *
@@ -22245,7 +22245,7 @@ var min$4 = /*#__PURE__*/ min$8(Order$5);
22245
22245
  * @category ordering
22246
22246
  * @since 2.0.0
22247
22247
  */
22248
- var max$4 = /*#__PURE__*/ max$8(Order$5);
22248
+ var max$5 = /*#__PURE__*/ max$9(Order$5);
22249
22249
  /**
22250
22250
  * Returns a `Duration` constrained between a minimum and maximum value.
22251
22251
  *
@@ -22689,7 +22689,7 @@ var ReducerSum$1 = /*#__PURE__*/ make$76(sum$2, zero);
22689
22689
  * @category math
22690
22690
  * @since 4.0.0
22691
22691
  */
22692
- var CombinerMax = /*#__PURE__*/ max$9(Order$5);
22692
+ var CombinerMax = /*#__PURE__*/ max$10(Order$5);
22693
22693
  /**
22694
22694
  * Combiner that returns the minimum `Duration`.
22695
22695
  *
@@ -22703,7 +22703,7 @@ var CombinerMax = /*#__PURE__*/ max$9(Order$5);
22703
22703
  * @category math
22704
22704
  * @since 4.0.0
22705
22705
  */
22706
- var CombinerMin = /*#__PURE__*/ min$9(Order$5);
22706
+ var CombinerMin = /*#__PURE__*/ min$10(Order$5);
22707
22707
  //#endregion
22708
22708
  //#region ../../node_modules/effect/dist/Filter.js
22709
22709
  var Filter_exports = /* @__PURE__ */ __exportAll({
@@ -24821,6 +24821,8 @@ var getContext = /*#__PURE__*/ withFiber$1((fiber) => succeed$11(fiber.context))
24821
24821
  /** @internal */
24822
24822
  var contextWith$2 = (f) => withFiber$1((fiber) => f(fiber.context));
24823
24823
  /** @internal */
24824
+ var setContext$1 = /*#__PURE__*/ dual(2, (self, context) => updateContext$3(self, constant$2(context)));
24825
+ /** @internal */
24824
24826
  var provideContext$4 = /*#__PURE__*/ dual(2, (self, context) => {
24825
24827
  if (effectIsExit(self)) return self;
24826
24828
  return updateContext$3(self, merge$5(context));
@@ -30320,8 +30322,8 @@ var Layer_exports = /* @__PURE__ */ __exportAll({
30320
30322
  parentSpan: () => parentSpan,
30321
30323
  provide: () => provide$5,
30322
30324
  provideMerge: () => provideMerge,
30323
- satisfiesErrorType: () => satisfiesErrorType$2,
30324
- satisfiesServicesType: () => satisfiesServicesType$2,
30325
+ satisfiesErrorType: () => satisfiesErrorType$1,
30326
+ satisfiesServicesType: () => satisfiesServicesType$1,
30325
30327
  satisfiesSuccessType: () => satisfiesSuccessType$1,
30326
30328
  span: () => span$2,
30327
30329
  succeed: () => succeed$8,
@@ -30606,8 +30608,11 @@ var forkMemoMap = (parent) => sync$6(() => forkMemoMapUnsafe(parent));
30606
30608
  * @category models
30607
30609
  * @since 3.13.0
30608
30610
  */
30609
- var CurrentMemoMap = class extends Service$1()("effect/Layer/CurrentMemoMap") {
30610
- static getOrCreate = /*#__PURE__*/ getOrElse(this, makeMemoMapUnsafe);
30611
+ var CurrentMemoMap = class CurrentMemoMap extends Service$1()("effect/Layer/CurrentMemoMap") {
30612
+ static forkOrCreate(self) {
30613
+ const current = getOrUndefined(self, CurrentMemoMap);
30614
+ return current ? forkMemoMapUnsafe(current) : makeMemoMapUnsafe();
30615
+ }
30611
30616
  };
30612
30617
  /**
30613
30618
  * Builds a layer into an `Effect` value, using the specified `MemoMap` to memoize
@@ -30689,7 +30694,7 @@ var buildWithMemoMap = /*#__PURE__*/ dual(3, (self, memoMap, scope) => provideSe
30689
30694
  * @category destructors
30690
30695
  * @since 2.0.0
30691
30696
  */
30692
- var build = (self) => withFiber$1((fiber) => buildWithMemoMap(self, CurrentMemoMap.getOrCreate(fiber.context), getUnsafe$11(fiber.context, Scope)));
30697
+ var build = (self) => withFiber$1((fiber) => buildWithMemoMap(self, CurrentMemoMap.forkOrCreate(fiber.context), getUnsafe$11(fiber.context, Scope)));
30693
30698
  /**
30694
30699
  * Builds a layer using an explicit scope.
30695
30700
  *
@@ -30737,7 +30742,7 @@ var build = (self) => withFiber$1((fiber) => buildWithMemoMap(self, CurrentMemoM
30737
30742
  * @category destructors
30738
30743
  * @since 2.0.0
30739
30744
  */
30740
- var buildWithScope = /*#__PURE__*/ dual(2, (self, scope) => withFiber$1((fiber) => buildWithMemoMap(self, CurrentMemoMap.getOrCreate(fiber.context), scope)));
30745
+ var buildWithScope = /*#__PURE__*/ dual(2, (self, scope) => withFiber$1((fiber) => buildWithMemoMap(self, CurrentMemoMap.forkOrCreate(fiber.context), scope)));
30741
30746
  /**
30742
30747
  * Constructs a layer that provides a single service from an already available
30743
30748
  * value.
@@ -31936,7 +31941,7 @@ var satisfiesSuccessType$1 = () => (layer) => layer;
31936
31941
  * @category utility types
31937
31942
  * @since 4.0.0
31938
31943
  */
31939
- var satisfiesErrorType$2 = () => (layer) => layer;
31944
+ var satisfiesErrorType$1 = () => (layer) => layer;
31940
31945
  /**
31941
31946
  * Ensures that a layer's requirements type extends a given type `R`.
31942
31947
  *
@@ -31968,7 +31973,7 @@ var satisfiesErrorType$2 = () => (layer) => layer;
31968
31973
  * @category utility types
31969
31974
  * @since 4.0.0
31970
31975
  */
31971
- var satisfiesServicesType$2 = () => (layer) => layer;
31976
+ var satisfiesServicesType$1 = () => (layer) => layer;
31972
31977
  /**
31973
31978
  * Constructs a new `Layer` which creates a span and registers it as the current
31974
31979
  * parent span.
@@ -33030,9 +33035,9 @@ var setZoneNamedUnsafe$1 = /*#__PURE__*/ dual(isDateTimeArgs, (self, zoneId, opt
33030
33035
  /** @internal */
33031
33036
  var distance$1 = /*#__PURE__*/ dual(2, (self, other) => millis(toEpochMillis$1(other) - toEpochMillis$1(self)));
33032
33037
  /** @internal */
33033
- var min$3 = /*#__PURE__*/ min$8(Order$4);
33038
+ var min$4 = /*#__PURE__*/ min$9(Order$4);
33034
33039
  /** @internal */
33035
- var max$3 = /*#__PURE__*/ max$8(Order$4);
33040
+ var max$4 = /*#__PURE__*/ max$9(Order$4);
33036
33041
  /** @internal */
33037
33042
  var isGreaterThan$4 = /*#__PURE__*/ isGreaterThan$8(Order$4);
33038
33043
  /** @internal */
@@ -33389,8 +33394,8 @@ var Number_exports = /* @__PURE__ */ __exportAll({
33389
33394
  isLessThan: () => isLessThan$3,
33390
33395
  isLessThanOrEqualTo: () => isLessThanOrEqualTo$3,
33391
33396
  isNumber: () => isNumber$1,
33392
- max: () => max$2,
33393
- min: () => min$2,
33397
+ max: () => max$3,
33398
+ min: () => min$3,
33394
33399
  multiply: () => multiply,
33395
33400
  multiplyAll: () => multiplyAll,
33396
33401
  nextPow2: () => nextPow2,
@@ -33820,7 +33825,7 @@ var clamp$1 = /*#__PURE__*/ clamp$7(Order$3);
33820
33825
  * @category math
33821
33826
  * @since 2.0.0
33822
33827
  */
33823
- var min$2 = /*#__PURE__*/ min$8(Order$3);
33828
+ var min$3 = /*#__PURE__*/ min$9(Order$3);
33824
33829
  /**
33825
33830
  * Returns the maximum between two `number`s.
33826
33831
  *
@@ -33842,7 +33847,7 @@ var min$2 = /*#__PURE__*/ min$8(Order$3);
33842
33847
  * @category math
33843
33848
  * @since 2.0.0
33844
33849
  */
33845
- var max$2 = /*#__PURE__*/ max$8(Order$3);
33850
+ var max$3 = /*#__PURE__*/ max$9(Order$3);
33846
33851
  /**
33847
33852
  * Determines the sign of a given `number`.
33848
33853
  *
@@ -35411,7 +35416,7 @@ var CronProto = {
35411
35416
  return isCron(that) && equals(this, that);
35412
35417
  },
35413
35418
  [symbol$5]() {
35414
- return pipe(hash$1(this.tz), combine$5(array$2(fromIterable$15(this.seconds))), combine$5(array$2(fromIterable$15(this.minutes))), combine$5(array$2(fromIterable$15(this.hours))), combine$5(array$2(fromIterable$15(this.days))), combine$5(array$2(fromIterable$15(this.months))), combine$5(array$2(fromIterable$15(this.weekdays))));
35419
+ return pipe(hash$1(this.tz), combine$5(hash$1(this.and)), combine$5(array$2(fromIterable$15(this.seconds))), combine$5(array$2(fromIterable$15(this.minutes))), combine$5(array$2(fromIterable$15(this.hours))), combine$5(array$2(fromIterable$15(this.days))), combine$5(array$2(fromIterable$15(this.months))), combine$5(array$2(fromIterable$15(this.weekdays))));
35415
35420
  },
35416
35421
  toObject() {
35417
35422
  return {
@@ -35488,7 +35493,9 @@ var isCron = (u) => hasProperty(u, TypeId$58);
35488
35493
  *
35489
35494
  * Constructs a cron schedule by specifying which seconds, minutes, hours,
35490
35495
  * days, months, and weekdays the schedule should match. Empty arrays mean
35491
- * "match all" for that time unit.
35496
+ * "match all" for that time unit. When both days and weekdays are restricted,
35497
+ * the default matches either field; set `and: true` to require both fields to
35498
+ * match.
35492
35499
  *
35493
35500
  * **Example** (Creating schedules from constraints)
35494
35501
  *
@@ -35591,6 +35598,7 @@ var make$61 = (values) => {
35591
35598
  o.days = new Set(sort$1(values.days, Order$3));
35592
35599
  o.months = new Set(sort$1(values.months, Order$3));
35593
35600
  o.weekdays = new Set(sort$1(values.weekdays, Order$3));
35601
+ o.and = values.and === true;
35594
35602
  o.tz = fromUndefinedOr(values.tz);
35595
35603
  const seconds = Array.from(o.seconds);
35596
35604
  const minutes = Array.from(o.minutes);
@@ -35764,7 +35772,7 @@ var isCronParseError = (u) => hasProperty(u, CronParseErrorTypeId);
35764
35772
  * @since 2.0.0
35765
35773
  */
35766
35774
  var parse$1 = (cron, tz) => {
35767
- const segments = cron.split(" ").filter(isNonEmpty$5);
35775
+ const segments = cron.trim().split(/\s+/).filter(isNonEmpty$5);
35768
35776
  if (segments.length !== 5 && segments.length !== 6) return fail$14(new CronParseError({
35769
35777
  message: `Invalid number of segments in cron expression`,
35770
35778
  input: cron
@@ -35782,7 +35790,16 @@ var parse$1 = (cron, tz) => {
35782
35790
  days: parseSegment(days, dayOptions),
35783
35791
  months: parseSegment(months, monthOptions),
35784
35792
  weekdays: parseSegment(weekdays, weekdayOptions)
35785
- }).pipe(map$28(make$61));
35793
+ }).pipe(map$28(({ tz, seconds, minutes, hours, days, months, weekdays }) => make$61({
35794
+ tz,
35795
+ seconds: seconds.values,
35796
+ minutes: minutes.values,
35797
+ hours: hours.values,
35798
+ days: days.values,
35799
+ months: months.values,
35800
+ weekdays: weekdays.values,
35801
+ and: (days.wildcard || weekdays.wildcard) && days.values.size !== 0 && weekdays.values.size !== 0
35802
+ })));
35786
35803
  };
35787
35804
  /**
35788
35805
  * Parses a cron expression into a `Cron` instance, throwing on failure.
@@ -35856,6 +35873,7 @@ var match$4 = (cron, date) => {
35856
35873
  if (cron.hours.size !== 0 && !cron.hours.has(parts.hour)) return false;
35857
35874
  if (cron.months.size !== 0 && !cron.months.has(parts.month)) return false;
35858
35875
  if (cron.days.size === 0 && cron.weekdays.size === 0) return true;
35876
+ if (cron.and) return (cron.days.size === 0 || cron.days.has(parts.day)) && (cron.weekdays.size === 0 || cron.weekdays.has(parts.weekDay));
35859
35877
  if (cron.weekdays.size === 0) return cron.days.has(parts.day);
35860
35878
  if (cron.days.size === 0) return cron.weekdays.has(parts.weekDay);
35861
35879
  return cron.days.has(parts.day) || cron.weekdays.has(parts.weekDay);
@@ -35989,7 +36007,16 @@ var stepCron = (cron, now, direction) => {
35989
36007
  continue;
35990
36008
  }
35991
36009
  }
35992
- if (cron.weekdays.size !== 0 || cron.days.size !== 0) {
36010
+ if (cron.weekdays.size !== 0 || cron.days.size !== 0) if (cron.and) {
36011
+ const matchesDay = cron.days.size === 0 || cron.days.has(current.getUTCDate());
36012
+ const matchesWeekday = cron.weekdays.size === 0 || cron.weekdays.has(current.getUTCDay());
36013
+ if (!matchesDay || !matchesWeekday) {
36014
+ current.setUTCDate(current.getUTCDate() + tick);
36015
+ current.setUTCHours(boundary.hour, boundary.minute, boundary.second);
36016
+ adjustDst(current);
36017
+ continue;
36018
+ }
36019
+ } else {
35993
36020
  let a = reverse ? -Infinity : Infinity;
35994
36021
  let b = reverse ? -Infinity : Infinity;
35995
36022
  if (cron.weekdays.size !== 0) {
@@ -36018,9 +36045,9 @@ var stepCron = (cron, now, direction) => {
36018
36045
  const currentMonth = current.getUTCMonth() + 1;
36019
36046
  const nextMonth = table.month[currentMonth];
36020
36047
  const clampBoundaryDay = (targetMonthIndex) => {
36021
- if (cron.days.size !== 0) return boundary.day;
36048
+ if (cron.days.size !== 0 && cron.weekdays.size === 0) return boundary.day;
36022
36049
  const maxDayInMonth = daysInMonth(new Date(Date.UTC(current.getUTCFullYear(), targetMonthIndex + 1, 0)));
36023
- return Math.min(boundary.day, maxDayInMonth);
36050
+ return reverse ? maxDayInMonth : 1;
36024
36051
  };
36025
36052
  if (nextMonth === void 0) {
36026
36053
  current.setUTCFullYear(current.getUTCFullYear() + tick);
@@ -36121,7 +36148,7 @@ var sequence = function* (cron, now) {
36121
36148
  * @category instances
36122
36149
  * @since 2.0.0
36123
36150
  */
36124
- var Equivalence$2 = /*#__PURE__*/ make$75((self, that) => restrictionsEquals(self.seconds, that.seconds) && restrictionsEquals(self.minutes, that.minutes) && restrictionsEquals(self.hours, that.hours) && restrictionsEquals(self.days, that.days) && restrictionsEquals(self.months, that.months) && restrictionsEquals(self.weekdays, that.weekdays));
36151
+ var Equivalence$2 = /*#__PURE__*/ make$75((self, that) => self.and === that.and && restrictionsEquals(self.seconds, that.seconds) && restrictionsEquals(self.minutes, that.minutes) && restrictionsEquals(self.hours, that.hours) && restrictionsEquals(self.days, that.days) && restrictionsEquals(self.months, that.months) && restrictionsEquals(self.weekdays, that.weekdays));
36125
36152
  var restrictionsArrayEquals = /*#__PURE__*/ Array_$1(/*#__PURE__*/ strictEqual());
36126
36153
  var restrictionsEquals = (self, that) => restrictionsArrayEquals(fromIterable$15(self), fromIterable$15(that));
36127
36154
  /**
@@ -36204,7 +36231,8 @@ var monthOptions = {
36204
36231
  };
36205
36232
  var weekdayOptions = {
36206
36233
  min: 0,
36207
- max: 6,
36234
+ max: 7,
36235
+ normalize: (value) => value === 7 ? 0 : value,
36208
36236
  aliases: {
36209
36237
  sun: 0,
36210
36238
  mon: 1,
@@ -36216,12 +36244,17 @@ var weekdayOptions = {
36216
36244
  }
36217
36245
  };
36218
36246
  var parseSegment = (input, options) => {
36219
- const capacity = options.max - options.min + 1;
36220
36247
  const values = /* @__PURE__ */ new Set();
36221
36248
  const fields = input.split(",");
36222
- for (const field of fields) {
36223
- const [raw, step] = splitStep(field);
36224
- if (raw === "*" && step === void 0) return succeed$12(/* @__PURE__ */ new Set());
36249
+ const first = splitStep(fields[0]);
36250
+ const wildcard = first[0] === "*";
36251
+ const normalize = options.normalize ?? ((value) => value);
36252
+ const add = wildcard && (first[1] === void 0 || first[1] === 1) ? constVoid : (value) => {
36253
+ values.add(normalize(value));
36254
+ };
36255
+ for (let index = 0; index < fields.length; index++) {
36256
+ const field = fields[index];
36257
+ const [raw, step] = index === 0 ? first : splitStep(field);
36225
36258
  if (step !== void 0) {
36226
36259
  if (!Number.isInteger(step)) return fail$14(new CronParseError({
36227
36260
  message: `Expected step value to be a positive integer`,
@@ -36236,8 +36269,10 @@ var parseSegment = (input, options) => {
36236
36269
  input
36237
36270
  }));
36238
36271
  }
36239
- if (raw === "*") for (let i = options.min; i <= options.max; i += step ?? 1) values.add(i);
36240
- else {
36272
+ if (raw === "*") {
36273
+ if (index === 0 && (step === void 0 || step === 1)) continue;
36274
+ for (let i = options.min; i <= options.max; i += step ?? 1) add(i);
36275
+ } else {
36241
36276
  const [left, right] = splitRange(raw, options.aliases);
36242
36277
  if (!Number.isInteger(left)) return fail$14(new CronParseError({
36243
36278
  message: `Expected a positive integer`,
@@ -36247,7 +36282,7 @@ var parseSegment = (input, options) => {
36247
36282
  message: `Expected a value between ${options.min} and ${options.max}`,
36248
36283
  input
36249
36284
  }));
36250
- if (right === void 0) values.add(left);
36285
+ if (right === void 0) for (let i = left; i <= (step === void 0 ? left : options.max); i += step ?? 1) add(i);
36251
36286
  else {
36252
36287
  if (!Number.isInteger(right)) return fail$14(new CronParseError({
36253
36288
  message: `Expected a positive integer`,
@@ -36261,16 +36296,21 @@ var parseSegment = (input, options) => {
36261
36296
  message: `Invalid value range`,
36262
36297
  input
36263
36298
  }));
36264
- for (let i = left; i <= right; i += step ?? 1) values.add(i);
36299
+ for (let i = left; i <= right; i += step ?? 1) add(i);
36265
36300
  }
36266
36301
  }
36267
- if (values.size >= capacity) return succeed$12(/* @__PURE__ */ new Set());
36268
36302
  }
36269
- return succeed$12(values);
36303
+ return succeed$12({
36304
+ values,
36305
+ wildcard
36306
+ });
36270
36307
  };
36271
36308
  var splitStep = (input) => {
36272
36309
  const separator = input.indexOf("/");
36273
- if (separator !== -1) return [input.slice(0, separator), Number(input.slice(separator + 1))];
36310
+ if (separator !== -1) {
36311
+ const step = input.slice(separator + 1);
36312
+ return [input.slice(0, separator), decimalRegex.test(step) ? Number(step) : NaN];
36313
+ }
36274
36314
  return [input, void 0];
36275
36315
  };
36276
36316
  var splitRange = (input, aliases) => {
@@ -36279,8 +36319,9 @@ var splitRange = (input, aliases) => {
36279
36319
  return [aliasOrValue(input, aliases), void 0];
36280
36320
  };
36281
36321
  function aliasOrValue(field, aliases) {
36282
- return aliases?.[field.toLocaleLowerCase()] ?? Number(field);
36322
+ return aliases?.[field.toLocaleLowerCase()] ?? (decimalRegex.test(field) ? Number(field) : NaN);
36283
36323
  }
36324
+ var decimalRegex = /^\d+$/;
36284
36325
  //#endregion
36285
36326
  //#region ../../node_modules/effect/dist/internal/random.js
36286
36327
  /** @internal */
@@ -36499,37 +36540,14 @@ var matchEffect$1 = /*#__PURE__*/ dual(2, (self, options) => matchCauseEffect$1(
36499
36540
  }));
36500
36541
  //#endregion
36501
36542
  //#region ../../node_modules/effect/dist/Schedule.js
36502
- /**
36503
- * Describes policies for retrying, repeating, and pacing Effect programs.
36504
- *
36505
- * A `Schedule<Output, Input, Error, Env>` is stepped with an input value. Each
36506
- * step either stops or produces an output together with the delay before the
36507
- * next step. Schedules are used by retry, repeat, stream, and channel APIs to
36508
- * decide when work should continue, how long to wait, and when to stop.
36509
- *
36510
- * @since 2.0.0
36511
- */
36512
36543
  var Schedule_exports = /* @__PURE__ */ __exportAll({
36513
36544
  CurrentMetadata: () => CurrentMetadata,
36514
36545
  addDelay: () => addDelay,
36515
36546
  andThen: () => andThen$1,
36516
36547
  andThenResult: () => andThenResult,
36517
- both: () => both,
36518
- bothLeft: () => bothLeft,
36519
- bothRight: () => bothRight,
36520
- bothWith: () => bothWith,
36521
- collectInputs: () => collectInputs,
36522
- collectOutputs: () => collectOutputs,
36523
- collectWhile: () => collectWhile,
36524
36548
  cron: () => cron,
36525
- delays: () => delays,
36526
36549
  duration: () => duration$1,
36527
36550
  during: () => during,
36528
- either: () => either,
36529
- eitherLeft: () => eitherLeft,
36530
- eitherRight: () => eitherRight,
36531
- eitherWith: () => eitherWith,
36532
- elapsed: () => elapsed,
36533
36551
  exponential: () => exponential,
36534
36552
  fibonacci: () => fibonacci,
36535
36553
  fixed: () => fixed,
@@ -36540,24 +36558,18 @@ var Schedule_exports = /* @__PURE__ */ __exportAll({
36540
36558
  isSchedule: () => isSchedule,
36541
36559
  jittered: () => jittered,
36542
36560
  map: () => map$20,
36561
+ max: () => max$2,
36562
+ min: () => min$2,
36543
36563
  modifyDelay: () => modifyDelay,
36544
36564
  passthrough: () => passthrough$2,
36545
36565
  recurs: () => recurs,
36546
- reduce: () => reduce$10,
36547
- satisfiesErrorType: () => satisfiesErrorType$1,
36548
- satisfiesInputType: () => satisfiesInputType,
36549
- satisfiesOutputType: () => satisfiesOutputType,
36550
- satisfiesServicesType: () => satisfiesServicesType$1,
36551
36566
  setInputType: () => setInputType,
36552
36567
  spaced: () => spaced,
36553
- take: () => take$11,
36554
36568
  tap: () => tap$3,
36555
- tapInput: () => tapInput,
36556
- tapOutput: () => tapOutput,
36557
36569
  toStep: () => toStep,
36558
36570
  toStepWithMetadata: () => toStepWithMetadata,
36559
36571
  toStepWithSleep: () => toStepWithSleep,
36560
- unfold: () => unfold$1,
36572
+ upTo: () => upTo,
36561
36573
  while: () => while_,
36562
36574
  windowed: () => windowed
36563
36575
  });
@@ -36700,7 +36712,7 @@ var fromStepWithMetadata = (step) => fromStep(map$23(step, (f) => {
36700
36712
  * import { Effect, Schedule } from "effect"
36701
36713
  *
36702
36714
  * // Extract step function from an existing schedule
36703
- * const schedule = Schedule.exponential("100 millis").pipe(Schedule.take(3))
36715
+ * const schedule = Schedule.exponential("100 millis").pipe(Schedule.upTo({ times: 3 }))
36704
36716
  *
36705
36717
  * const program = Effect.gen(function*() {
36706
36718
  * const stepFn = yield* Schedule.toStep(schedule)
@@ -36760,7 +36772,7 @@ var toStepWithMetadata = (schedule) => clockWith$2((clock) => map$23(toStep(sche
36760
36772
  * import { Effect, Schedule } from "effect"
36761
36773
  *
36762
36774
  * // Convert schedule to step function with automatic sleeping
36763
- * const schedule = Schedule.spaced("1 second").pipe(Schedule.take(3))
36775
+ * const schedule = Schedule.spaced("1 second").pipe(Schedule.upTo({ times: 3 }))
36764
36776
  *
36765
36777
  * const program = Effect.gen(function*() {
36766
36778
  * const stepWithSleep = yield* Schedule.toStepWithSleep(schedule)
@@ -36793,10 +36805,10 @@ var toStepWithSleep = (schedule) => map$23(toStepWithMetadata(schedule), (step)
36793
36805
  *
36794
36806
  * class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
36795
36807
  *
36796
- * // Add a deterministic extra delay based on the schedule output
36808
+ * // Add a deterministic extra delay based on the schedule metadata
36797
36809
  * const delayedSchedule = Schedule.addDelay(
36798
- * Schedule.exponential("100 millis").pipe(Schedule.take(5)),
36799
- * (output) =>
36810
+ * Schedule.exponential("100 millis").pipe(Schedule.upTo({ times: 5 })),
36811
+ * ({ output }) =>
36800
36812
  * Effect.succeed(Duration.millis(Duration.toMillis(output) * 0.25))
36801
36813
  * )
36802
36814
  *
@@ -36804,7 +36816,7 @@ var toStepWithSleep = (schedule) => map$23(toStepWithMetadata(schedule), (step)
36804
36816
  * yield* Effect.repeat(
36805
36817
  * Effect.succeed("delayed task"),
36806
36818
  * delayedSchedule.pipe(
36807
- * Schedule.tapOutput((delay) =>
36819
+ * Schedule.tap(({ output: delay }) =>
36808
36820
  * Console.log(`Base delay: ${delay}`)
36809
36821
  * )
36810
36822
  * )
@@ -36814,7 +36826,7 @@ var toStepWithSleep = (schedule) => map$23(toStepWithMetadata(schedule), (step)
36814
36826
  * // Add adaptive delay based on execution count
36815
36827
  * const adaptiveSchedule = Schedule.addDelay(
36816
36828
  * Schedule.recurs(6),
36817
- * (executionCount) =>
36829
+ * ({ output: executionCount }) =>
36818
36830
  * // Increase delay as execution count grows
36819
36831
  * Effect.succeed(Duration.millis(executionCount * 200))
36820
36832
  * )
@@ -36826,7 +36838,7 @@ var toStepWithSleep = (schedule) => map$23(toStepWithMetadata(schedule), (step)
36826
36838
  * return "adaptive"
36827
36839
  * }),
36828
36840
  * adaptiveSchedule.pipe(
36829
- * Schedule.tapOutput((count) =>
36841
+ * Schedule.tap(({ output: count }) =>
36830
36842
  * Console.log(`Execution ${count + 1} with adaptive delay`)
36831
36843
  * )
36832
36844
  * )
@@ -36837,8 +36849,8 @@ var toStepWithSleep = (schedule) => map$23(toStepWithMetadata(schedule), (step)
36837
36849
  * const loadByExecution = [1, 3, 2, 4] as const
36838
36850
  *
36839
36851
  * const dynamicSchedule = Schedule.addDelay(
36840
- * Schedule.spaced("1 second").pipe(Schedule.take(4)),
36841
- * (executionNumber) => {
36852
+ * Schedule.spaced("1 second").pipe(Schedule.upTo({ times: 4 })),
36853
+ * ({ output: executionNumber }) => {
36842
36854
  * const load = loadByExecution[executionNumber] ?? 1
36843
36855
  * return Effect.succeed(Duration.millis(load * 100))
36844
36856
  * }
@@ -36856,7 +36868,7 @@ var toStepWithSleep = (schedule) => map$23(toStepWithMetadata(schedule), (step)
36856
36868
  *
36857
36869
  * // Combine with retry for progressive backoff
36858
36870
  * const progressiveRetrySchedule = Schedule.addDelay(
36859
- * Schedule.exponential("50 millis").pipe(Schedule.take(4)),
36871
+ * Schedule.exponential("50 millis").pipe(Schedule.upTo({ times: 4 })),
36860
36872
  * () => Effect.succeed(Duration.millis(100)) // Fixed additional delay
36861
36873
  * )
36862
36874
  *
@@ -36881,7 +36893,7 @@ var toStepWithSleep = (schedule) => map$23(toStepWithMetadata(schedule), (step)
36881
36893
  * @category delays & timeouts
36882
36894
  * @since 2.0.0
36883
36895
  */
36884
- var addDelay = /*#__PURE__*/ dual(2, (self, f) => modifyDelay(self, (output, delay) => map$23(f(output), (d) => sum$2(fromInputUnsafe(d), fromInputUnsafe(delay)))));
36896
+ var addDelay = /*#__PURE__*/ dual(2, (self, f) => modifyDelay(self, (metadata) => map$23(f(metadata), (d) => sum$2(fromInputUnsafe(d), metadata.duration))));
36885
36897
  /**
36886
36898
  * Returns a schedule that runs `self` to completion, then runs `other`, and
36887
36899
  * merges their outputs.
@@ -36895,10 +36907,10 @@ var addDelay = /*#__PURE__*/ dual(2, (self, f) => modifyDelay(self, (output, del
36895
36907
  *
36896
36908
  * // First retry 3 times quickly, then switch to slower retries
36897
36909
  * const quickRetries = Schedule.exponential("100 millis").pipe(
36898
- * Schedule.take(3)
36910
+ * Schedule.upTo({ times: 3 })
36899
36911
  * )
36900
36912
  * const slowRetries = Schedule.exponential("1 second").pipe(
36901
- * Schedule.take(2)
36913
+ * Schedule.upTo({ times: 2 })
36902
36914
  * )
36903
36915
  *
36904
36916
  * const combinedRetries = Schedule.andThen(quickRetries, slowRetries)
@@ -36922,7 +36934,7 @@ var addDelay = /*#__PURE__*/ dual(2, (self, f) => modifyDelay(self, (output, del
36922
36934
  * @category sequencing
36923
36935
  * @since 2.0.0
36924
36936
  */
36925
- var andThen$1 = /*#__PURE__*/ dual(2, (self, other) => map$20(andThenResult(self, other), (result) => succeed$11(merge$6(result))));
36937
+ var andThen$1 = /*#__PURE__*/ dual(2, (self, other) => map$20(andThenResult(self, other), ({ output }) => succeed$11(merge$6(output))));
36926
36938
  /**
36927
36939
  * Returns a schedule that runs `self` to completion, then runs `other`, and
36928
36940
  * preserves which schedule produced each output.
@@ -36940,8 +36952,8 @@ var andThen$1 = /*#__PURE__*/ dual(2, (self, other) => map$20(andThenResult(self
36940
36952
  *
36941
36953
  * // Track which phase of the schedule we're in
36942
36954
  * const phaseTracker = Schedule.andThenResult(
36943
- * Schedule.exponential("100 millis").pipe(Schedule.take(2)),
36944
- * Schedule.spaced("500 millis").pipe(Schedule.take(2))
36955
+ * Schedule.exponential("100 millis").pipe(Schedule.upTo({ times: 2 })),
36956
+ * Schedule.spaced("500 millis").pipe(Schedule.upTo({ times: 2 }))
36945
36957
  * )
36946
36958
  *
36947
36959
  * const program = Effect.gen(function*() {
@@ -36951,7 +36963,7 @@ var andThen$1 = /*#__PURE__*/ dual(2, (self, other) => map$20(andThenResult(self
36951
36963
  * return "task-result"
36952
36964
  * }),
36953
36965
  * phaseTracker.pipe(
36954
- * Schedule.tapOutput((result) =>
36966
+ * Schedule.tap(({ output: result }) =>
36955
36967
  * Result.match(result, {
36956
36968
  * onFailure: (phase1Output) => Console.log(`Phase 1: ${phase1Output}`),
36957
36969
  * onSuccess: (phase2Output) => Console.log(`Phase 2: ${phase2Output}`)
@@ -36968,8 +36980,8 @@ var andThen$1 = /*#__PURE__*/ dual(2, (self, other) => map$20(andThenResult(self
36968
36980
  var andThenResult = /*#__PURE__*/ dual(2, (self, other) => fromStep(sync$6(() => {
36969
36981
  let currentSide = 0;
36970
36982
  let currentStep;
36971
- const left = map$20(self, fail$14);
36972
- const right = map$20(other, succeed$12);
36983
+ const left = map$20(self, ({ output }) => fail$14(output));
36984
+ const right = map$20(other, ({ output }) => succeed$12(output));
36973
36985
  return function recur(now, input) {
36974
36986
  if (currentStep) return currentStep(now, input);
36975
36987
  return toStep(currentSide === 0 ? left : right).pipe(flatMap$9((step) => {
@@ -36987,366 +36999,68 @@ var andThenResult = /*#__PURE__*/ dual(2, (self, other) => fromStep(sync$6(() =>
36987
36999
  };
36988
37000
  })));
36989
37001
  /**
36990
- * Combines two `Schedule`s by recurring if both of the two schedules want
36991
- * to recur, using the maximum of the two durations between recurrences and
36992
- * outputting a tuple of the outputs of both schedules.
37002
+ * Combines schedules by recurring while all schedules want to recur, using the
37003
+ * maximum delay between recurrences and outputting that maximum delay.
36993
37004
  *
36994
37005
  * **When to use**
36995
37006
  *
36996
- * Use when the combined schedule should continue only while both schedules still recur.
37007
+ * Use when a combined policy should continue only while every schedule still
37008
+ * recurs, and should wait for the slowest schedule between recurrences.
36997
37009
  *
36998
- * **Example** (Combining time and attempt limits)
37010
+ * **Example** (Combining retry schedules by their maximum delay)
36999
37011
  *
37000
37012
  * ```ts
37001
37013
  * import { Console, Data, Effect, Schedule } from "effect"
37002
37014
  *
37003
37015
  * class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
37004
37016
  *
37005
- * // Both schedules must want to continue for the combined schedule to continue
37006
- * const timeLimit = Schedule.spaced("1 second").pipe(Schedule.take(5)) // max 5 times
37007
- * const attemptLimit = Schedule.recurs(3) // max 3 attempts
37008
- *
37009
- * // Continues only while BOTH schedules want to continue (intersection/AND logic)
37010
- * const bothSchedule = Schedule.both(timeLimit, attemptLimit)
37011
- * // Outputs: [time_result, attempt_count] tuple
37017
+ * const retrySchedule = Schedule.max([
37018
+ * Schedule.fixed("5 seconds"),
37019
+ * Schedule.exponential("5 seconds"),
37020
+ * Schedule.spaced("10 seconds")
37021
+ * ])
37012
37022
  *
37013
37023
  * const program = Effect.gen(function*() {
37014
- * const results = yield* Effect.repeat(
37015
- * Effect.gen(function*() {
37016
- * yield* Console.log("Task executed")
37017
- * return "task completed"
37018
- * }),
37019
- * bothSchedule.pipe(
37020
- * Schedule.tapOutput(([timeResult, attemptResult]) =>
37021
- * Console.log(`Time: ${timeResult}, Attempts: ${attemptResult}`)
37022
- * )
37023
- * )
37024
- * )
37025
- *
37026
- * yield* Console.log("Completed all executions")
37027
- * })
37028
- *
37029
- * // Both with different delay strategies - uses maximum delay
37030
- * const fastSchedule = Schedule.fixed("500 millis").pipe(Schedule.take(4))
37031
- * const slowSchedule = Schedule.spaced("2 seconds").pipe(Schedule.take(6))
37032
- *
37033
- * // Will use the slower (maximum) delay and stop when first schedule exhausts
37034
- * const conservativeSchedule = Schedule.both(fastSchedule, slowSchedule)
37035
- *
37036
- * const retryProgram = Effect.gen(function*() {
37037
37024
  * let attempt = 0
37038
37025
  *
37039
- * const result = yield* Effect.retry(
37026
+ * yield* Effect.retry(
37040
37027
  * Effect.gen(function*() {
37041
37028
  * attempt++
37042
37029
  * yield* Console.log(`Retry attempt ${attempt}`)
37043
- *
37044
37030
  * if (attempt < 3) {
37045
37031
  * return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
37046
37032
  * }
37047
- *
37048
- * return `Success on attempt ${attempt}`
37049
- * }),
37050
- * conservativeSchedule
37051
- * )
37052
- *
37053
- * yield* Console.log(`Final result: ${result}`)
37054
- * })
37055
- *
37056
- * // Both provides intersection semantics (AND logic)
37057
- * // Compare with either which provides union semantics (OR logic)
37058
- * ```
37059
- *
37060
- * @see {@link either} for continuing while either schedule still recurs
37061
- *
37062
- * @category combining
37063
- * @since 2.0.0
37064
- */
37065
- var both = /*#__PURE__*/ dual(2, (self, other) => bothWith(self, other, (left, right) => [left, right]));
37066
- /**
37067
- * Combines two `Schedule`s by recurring if both of the two schedules want
37068
- * to recur, using the maximum of the two durations between recurrences and
37069
- * outputting the result of the left schedule (i.e. `self`).
37070
- *
37071
- * **When to use**
37072
- *
37073
- * Use when two schedules must both allow recurrence and only the left schedule's
37074
- * output is needed.
37075
- *
37076
- * **Example** (Combining schedules and keeping the left output)
37077
- *
37078
- * ```ts
37079
- * import { Console, Effect, Schedule } from "effect"
37080
- *
37081
- * // Combine two schedules, keeping left output
37082
- * const leftSchedule = Schedule.exponential("100 millis").pipe(
37083
- * Schedule.map(() => Effect.succeed("left-result"))
37084
- * )
37085
- * const rightSchedule = Schedule.spaced("50 millis")
37086
- *
37087
- * const combined = Schedule.bothLeft(leftSchedule, rightSchedule)
37088
- *
37089
- * const program = Effect.gen(function*() {
37090
- * yield* Effect.repeat(
37091
- * Effect.gen(function*() {
37092
- * yield* Console.log("Task executed")
37093
- * return "task-done"
37094
- * }),
37095
- * combined.pipe(Schedule.take(3))
37096
- * )
37097
- * })
37098
- * ```
37099
- *
37100
- * @category combining
37101
- * @since 2.0.0
37102
- */
37103
- var bothLeft = /*#__PURE__*/ dual(2, (self, other) => bothWith(self, other, (output) => output));
37104
- /**
37105
- * Combines two `Schedule`s by recurring if both of the two schedules want
37106
- * to recur, using the maximum of the two durations between recurrences and
37107
- * outputting the result of the right schedule (i.e. `other`).
37108
- *
37109
- * **When to use**
37110
- *
37111
- * Use when two schedules must both allow recurrence and only the right
37112
- * schedule's output is needed.
37113
- *
37114
- * **Example** (Combining schedules and keeping the right output)
37115
- *
37116
- * ```ts
37117
- * import { Console, Effect, Schedule } from "effect"
37118
- *
37119
- * // Combine two schedules, keeping right output
37120
- * const leftSchedule = Schedule.exponential("100 millis").pipe(
37121
- * Schedule.map(() => Effect.succeed("left-result"))
37122
- * )
37123
- * const rightSchedule = Schedule.spaced("50 millis").pipe(
37124
- * Schedule.map(() => Effect.succeed("right-result"))
37125
- * )
37126
- *
37127
- * const combined = Schedule.bothRight(leftSchedule, rightSchedule)
37128
- *
37129
- * const program = Effect.gen(function*() {
37130
- * yield* Effect.repeat(
37131
- * Effect.gen(function*() {
37132
- * yield* Console.log("Task executed")
37133
- * return "task-done"
37134
- * }),
37135
- * combined.pipe(Schedule.take(3))
37136
- * )
37137
- * })
37138
- * ```
37139
- *
37140
- * @category combining
37141
- * @since 2.0.0
37142
- */
37143
- var bothRight = /*#__PURE__*/ dual(2, (self, other) => bothWith(self, other, (_, output) => output));
37144
- /**
37145
- * Combines two `Schedule`s by recurring if both of the two schedules want
37146
- * to recur, using the maximum of the two durations between recurrences and
37147
- * outputting the result of the combination of both schedule outputs using the
37148
- * specified `combine` function.
37149
- *
37150
- * **When to use**
37151
- *
37152
- * Use when two schedules must both allow recurrence and their outputs should be
37153
- * combined into a custom value.
37154
- *
37155
- * **Example** (Combining schedule outputs)
37156
- *
37157
- * ```ts
37158
- * import { Console, Effect, Schedule } from "effect"
37159
- *
37160
- * // Combine two schedules with custom output combination
37161
- * const leftSchedule = Schedule.exponential("100 millis").pipe(
37162
- * Schedule.map(() => Effect.succeed("left"))
37163
- * )
37164
- * const rightSchedule = Schedule.spaced("50 millis").pipe(
37165
- * Schedule.map(() => Effect.succeed("right"))
37166
- * )
37167
- *
37168
- * const combined = Schedule.bothWith(
37169
- * leftSchedule,
37170
- * rightSchedule,
37171
- * (left, right) => `${left}-${right}`
37172
- * )
37173
- *
37174
- * const program = Effect.gen(function*() {
37175
- * yield* Effect.repeat(
37176
- * Effect.gen(function*() {
37177
- * yield* Console.log("Task executed")
37178
- * return "task-result"
37033
+ * return "success"
37179
37034
  * }),
37180
- * combined.pipe(Schedule.take(3))
37035
+ * retrySchedule.pipe(
37036
+ * Schedule.tap(({ output: duration }) =>
37037
+ * Console.log(`Waiting for the slowest schedule: ${duration}`)
37038
+ * )
37039
+ * )
37181
37040
  * )
37182
37041
  * })
37183
37042
  * ```
37184
37043
  *
37185
37044
  * @category combining
37186
- * @since 2.0.0
37187
- */
37188
- var bothWith = /*#__PURE__*/ dual(3, (self, other, combine) => fromStep(map$23(zip$3(toStep(self), toStep(other)), ([stepLeft, stepRight]) => (now, input) => matchEffect$1(stepLeft(now, input), {
37189
- onSuccess: (leftResult) => stepRight(now, input).pipe(map$23((rightResult) => [combine(leftResult[0], rightResult[0]), max$4(leftResult[1], rightResult[1])]), catchDone((rightDone) => done$2(combine(leftResult[0], rightDone)))),
37190
- onDone: (leftDone) => stepRight(now, input).pipe(flatMap$9((rightResult) => done$2(combine(leftDone, rightResult[0]))), catchDone((rightDone) => done$2(combine(leftDone, rightDone)))),
37191
- onFailure: failCause$9
37192
- }))));
37193
- /**
37194
- * Returns a new `Schedule` that follows `self` and outputs the inputs seen so
37195
- * far as an array.
37196
- *
37197
- * **Details**
37198
- *
37199
- * This does not make the schedule run forever. The collected schedule stops
37200
- * when `self` stops and fails when `self` fails.
37201
- *
37202
- * **Example** (Collecting schedule inputs)
37203
- *
37204
- * ```ts
37205
- * import { Console, Effect, Schedule } from "effect"
37206
- *
37207
- * // Collect all inputs passed to the schedule
37208
- * const inputCollector = Schedule.collectInputs(
37209
- * Schedule.spaced("100 millis")
37210
- * )
37211
- *
37212
- * const program = Effect.gen(function*() {
37213
- * let counter = 0
37214
- * yield* Effect.repeat(
37215
- * Effect.gen(function*() {
37216
- * counter++
37217
- * yield* Console.log(`Iteration ${counter}`)
37218
- * return `result-${counter}`
37219
- * }),
37220
- * inputCollector.pipe(Schedule.take(4))
37221
- * )
37222
- * })
37223
- * ```
37224
- *
37225
- * @category collecting
37226
- * @since 4.0.0
37227
- */
37228
- var collectInputs = (self) => collectWhile(passthrough$2(self), () => succeed$11(true));
37229
- /**
37230
- * Returns a new `Schedule` that follows `self` and outputs the schedule outputs
37231
- * seen so far as an array.
37232
- *
37233
- * **Details**
37234
- *
37235
- * This does not make the schedule run forever. The collected schedule stops
37236
- * when `self` stops and fails when `self` fails.
37237
- *
37238
- * **Example** (Collecting schedule outputs)
37239
- *
37240
- * ```ts
37241
- * import { Console, Effect, Schedule } from "effect"
37242
- *
37243
- * // Collect all outputs from the schedule
37244
- * const outputCollector = Schedule.collectOutputs(
37245
- * Schedule.recurs(4)
37246
- * )
37247
- *
37248
- * const program = Effect.gen(function*() {
37249
- * yield* Effect.repeat(
37250
- * Effect.gen(function*() {
37251
- * yield* Console.log("Task executed")
37252
- * return "task-result"
37253
- * }),
37254
- * outputCollector.pipe(Schedule.take(4))
37255
- * )
37256
- * })
37257
- * ```
37258
- *
37259
- * @category collecting
37260
37045
  * @since 4.0.0
37261
37046
  */
37262
- var collectOutputs = (self) => collectWhile(self, () => succeed$11(true));
37263
- /**
37264
- * Returns a new `Schedule` that recurs as long as the specified `predicate`
37265
- * returns `true`, collecting all outputs of the schedule into an array.
37266
- *
37267
- * **Example** (Collecting outputs while a condition holds)
37268
- *
37269
- * ```ts
37270
- * import { Console, Effect, Schedule } from "effect"
37271
- *
37272
- * // Collect outputs while condition is met
37273
- * const collectWhileSmall = Schedule.collectWhile(
37274
- * Schedule.exponential("100 millis"),
37275
- * (metadata) =>
37276
- * Effect.succeed(metadata.attempt <= 5 && metadata.elapsed < 2000)
37277
- * )
37278
- *
37279
- * const conditionalProgram = Effect.gen(function*() {
37280
- * let attempt = 0
37281
- *
37282
- * const attempts = yield* Effect.repeat(
37283
- * Effect.gen(function*() {
37284
- * attempt++
37285
- * yield* Console.log(`Retry attempt ${attempt}`)
37286
- * return `attempt-${attempt}`
37287
- * }),
37288
- * collectWhileSmall
37289
- * )
37290
- *
37291
- * yield* Console.log(`Collected attempts: [${attempts.join(", ")}]`)
37292
- * })
37293
- *
37294
- * // Collect with effectful predicate
37295
- * const collectWithCheck = Schedule.collectWhile(
37296
- * Schedule.fixed("1 second"),
37297
- * (metadata) =>
37298
- * Effect.gen(function*() {
37299
- * const shouldContinue = metadata.attempt < 5
37300
- * yield* Console.log(
37301
- * `Check ${metadata.attempt}: continue = ${shouldContinue}`
37302
- * )
37303
- * return shouldContinue
37304
- * })
37305
- * )
37306
- *
37307
- * const effectfulProgram = Effect.gen(function*() {
37308
- * const results = yield* Effect.repeat(
37309
- * Effect.succeed("checked"),
37310
- * collectWithCheck
37311
- * )
37312
- *
37313
- * yield* Console.log(`Final collection: ${results.length} items`)
37314
- * })
37315
- *
37316
- * // Collect samples with condition
37317
- * const samples = [12, 18, 24, 30, 36]
37318
- *
37319
- * const collectSamples = Schedule.collectWhile(
37320
- * Schedule.spaced("200 millis"),
37321
- * (metadata) =>
37322
- * Effect.succeed(metadata.attempt <= 5 && metadata.elapsed < 2000)
37323
- * )
37324
- *
37325
- * const samplingProgram = Effect.gen(function*() {
37326
- * let index = 0
37327
- * const collected = yield* Effect.repeat(
37328
- * Effect.gen(function*() {
37329
- * const sample = samples[index++]
37330
- * yield* Console.log(`Sample: ${sample}`)
37331
- * return sample
37332
- * }),
37333
- * collectSamples
37334
- * )
37335
- *
37336
- * const average = collected.reduce((sum, s) => sum + s, 0) / collected.length
37337
- * yield* Console.log(
37338
- * `Collected ${collected.length} samples, average: ${average.toFixed(1)}`
37339
- * )
37340
- * })
37341
- * ```
37342
- *
37343
- * @category collecting
37344
- * @since 2.0.0
37345
- */
37346
- var collectWhile = /*#__PURE__*/ dual(2, (self, predicate) => reduce$10(while_(self, predicate), () => [], (outputs, output) => {
37347
- outputs.push(output);
37348
- return outputs;
37349
- }));
37047
+ var max$2 = (schedules) => fromStep(map$23(all$3(schedules.map(toStep)), (steps) => (now, input) => flatMap$9(forEach$9(steps, (step) => matchEffect$1(step(now, input), {
37048
+ onSuccess: (result) => succeed$11(result[1]),
37049
+ onDone: () => undefined_$2,
37050
+ onFailure: failCause$9
37051
+ })), (results) => {
37052
+ const duration = maxDuration(results);
37053
+ if (duration === void 0) return done$2(zero);
37054
+ return succeed$11([duration, duration]);
37055
+ })));
37056
+ var maxDuration = (results) => {
37057
+ let max = results[0];
37058
+ for (let i = 1; i < results.length; i++) {
37059
+ max = results[i] && max && max$5(max, results[i]);
37060
+ if (max === void 0) break;
37061
+ }
37062
+ return max;
37063
+ };
37350
37064
  /**
37351
37065
  * Returns a new `Schedule` that recurs on the specified `Cron` schedule and
37352
37066
  * outputs the duration between recurrences.
@@ -37368,8 +37082,8 @@ var collectWhile = /*#__PURE__*/ dual(2, (self, predicate) => reduce$10(while_(s
37368
37082
  * return "minute"
37369
37083
  * }),
37370
37084
  * everyMinute.pipe(
37371
- * Schedule.take(3), // Run only 3 times for demo
37372
- * Schedule.tapOutput((duration) =>
37085
+ * Schedule.upTo({ times: 3 }), // Run only 3 times for demo
37086
+ * Schedule.tap(({ output: duration }) =>
37373
37087
  * Console.log(`Next execution in: ${duration}`)
37374
37088
  * )
37375
37089
  * )
@@ -37389,7 +37103,7 @@ var collectWhile = /*#__PURE__*/ dual(2, (self, predicate) => reduce$10(while_(s
37389
37103
  * return "backup-done"
37390
37104
  * }),
37391
37105
  * dailyBackup.pipe(
37392
- * Schedule.take(2) // Run 2 times for demo
37106
+ * Schedule.upTo({ times: 2 }) // Run 2 times for demo
37393
37107
  * )
37394
37108
  * )
37395
37109
  * })
@@ -37408,7 +37122,7 @@ var collectWhile = /*#__PURE__*/ dual(2, (self, predicate) => reduce$10(while_(s
37408
37122
  * yield* Console.log(`Report generated: ${JSON.stringify(report)}`)
37409
37123
  * return report
37410
37124
  * }),
37411
- * weeklyReport.pipe(Schedule.take(1))
37125
+ * weeklyReport.pipe(Schedule.upTo({ times: 1 }))
37412
37126
  * )
37413
37127
  * })
37414
37128
  *
@@ -37427,7 +37141,7 @@ var collectWhile = /*#__PURE__*/ dual(2, (self, predicate) => reduce$10(while_(s
37427
37141
  * return status
37428
37142
  * }),
37429
37143
  * businessHoursCheck.pipe(
37430
- * Schedule.take(4) // Demo with 4 checks
37144
+ * Schedule.upTo({ times: 4 }) // Demo with 4 checks
37431
37145
  * )
37432
37146
  * )
37433
37147
  * })
@@ -37443,13 +37157,13 @@ var collectWhile = /*#__PURE__*/ dual(2, (self, predicate) => reduce$10(while_(s
37443
37157
  * yield* Console.log(`Processed ${invoiceCount} invoices`)
37444
37158
  * return { count: invoiceCount, batch: "2024-01-a" }
37445
37159
  * }),
37446
- * monthlyInvoice.pipe(Schedule.take(1))
37160
+ * monthlyInvoice.pipe(Schedule.upTo({ times: 1 }))
37447
37161
  * )
37448
37162
  * })
37449
37163
  *
37450
37164
  * // Complex cron with error handling
37451
37165
  * const complexCron = Schedule.cron("0 2,4,6 * * *").pipe(
37452
- * Schedule.tapOutput((duration) =>
37166
+ * Schedule.tap(({ output: duration }) =>
37453
37167
  * Console.log(`Scheduled to run again in ${duration}`)
37454
37168
  * )
37455
37169
  * )
@@ -37466,7 +37180,7 @@ var collectWhile = /*#__PURE__*/ dual(2, (self, predicate) => reduce$10(while_(s
37466
37180
  * }
37467
37181
  * return "success"
37468
37182
  * }),
37469
- * complexCron.pipe(Schedule.take(3))
37183
+ * complexCron.pipe(Schedule.upTo({ times: 3 }))
37470
37184
  * ).pipe(
37471
37185
  * Effect.catch((error: unknown) =>
37472
37186
  * Console.log(`Cron task error: ${String(error)}`)
@@ -37479,97 +37193,15 @@ var collectWhile = /*#__PURE__*/ dual(2, (self, predicate) => reduce$10(while_(s
37479
37193
  * @since 2.0.0
37480
37194
  */
37481
37195
  var cron = (expression, tz) => {
37482
- return fromStep(map$23(fromResult$1(isCron(expression) ? succeed$12(expression) : parse$1(expression, tz)), (cron) => (now, _) => sync$6(() => {
37483
- const duration = millis(next$1(cron, now).getTime() - now);
37484
- return [duration, duration];
37485
- })));
37196
+ return fromStep(map$23(fromResult$1(isCron(expression) ? succeed$12(expression) : parse$1(expression, tz)), (cron) => (now, _) => {
37197
+ if (now === Number.POSITIVE_INFINITY) return done$2(zero);
37198
+ return sync$6(() => {
37199
+ const duration = millis(next$1(cron, now).getTime() - now);
37200
+ return [duration, duration];
37201
+ });
37202
+ }));
37486
37203
  };
37487
37204
  /**
37488
- * Returns a new schedule that outputs the delay between each occurrence.
37489
- *
37490
- * **Example** (Extracting schedule delays)
37491
- *
37492
- * ```ts
37493
- * import { Console, Effect, Schedule } from "effect"
37494
- *
37495
- * // Extract delays from an exponential backoff schedule
37496
- * const exponentialDelays = Schedule.delays(
37497
- * Schedule.exponential("100 millis").pipe(Schedule.take(5))
37498
- * )
37499
- *
37500
- * const delayProgram = Effect.gen(function*() {
37501
- * yield* Effect.repeat(
37502
- * Effect.gen(function*() {
37503
- * yield* Console.log("Task executed")
37504
- * return "task result"
37505
- * }),
37506
- * exponentialDelays.pipe(
37507
- * Schedule.tapOutput((delay) =>
37508
- * Console.log(`Waiting ${delay} before next execution`)
37509
- * )
37510
- * )
37511
- * )
37512
- * })
37513
- *
37514
- * // Monitor delays from a Fibonacci schedule
37515
- * const fibonacciDelays = Schedule.delays(
37516
- * Schedule.fibonacci("200 millis").pipe(Schedule.take(8))
37517
- * )
37518
- *
37519
- * const fibDelayProgram = Effect.gen(function*() {
37520
- * yield* Effect.repeat(
37521
- * Console.log("Fibonacci task"),
37522
- * fibonacciDelays.pipe(
37523
- * Schedule.tapOutput((delay) => Console.log(`Fibonacci delay: ${delay}`))
37524
- * )
37525
- * )
37526
- * })
37527
- *
37528
- * // Extract delays for analysis or logging
37529
- * const analyzeDelays = Schedule.delays(
37530
- * Schedule.spaced("1 second").pipe(Schedule.take(3))
37531
- * ).pipe(
37532
- * Schedule.tapOutput((delay) =>
37533
- * Effect.gen(function*() {
37534
- * yield* Console.log(`Recorded delay: ${delay}`)
37535
- * // In real applications, might send to metrics system
37536
- * })
37537
- * )
37538
- * )
37539
- *
37540
- * // Combine delays with other schedules for complex timing
37541
- * const adaptiveSchedule = Schedule.unfold(100, (delay) => Effect.succeed(delay * 1.5)).pipe(
37542
- * Schedule.take(6)
37543
- * )
37544
- *
37545
- * const adaptiveDelays = Schedule.delays(adaptiveSchedule)
37546
- *
37547
- * const adaptiveProgram = Effect.gen(function*() {
37548
- * yield* Effect.repeat(
37549
- * Effect.gen(function*() {
37550
- * yield* Console.log("Adaptive task execution")
37551
- * return "completed"
37552
- * }),
37553
- * adaptiveDelays.pipe(
37554
- * Schedule.tapOutput((delay) => Console.log(`Adaptive delay: ${delay}`))
37555
- * )
37556
- * )
37557
- * })
37558
- *
37559
- * // Use delays to implement custom timing logic
37560
- * const customTimingSchedule = Schedule.delays(
37561
- * Schedule.exponential("50 millis").pipe(Schedule.take(4))
37562
- * ).pipe(
37563
- * Schedule.map((delay) => Effect.succeed(`Next execution in ${delay}`)),
37564
- * Schedule.tapOutput((message) => Console.log(message))
37565
- * )
37566
- * ```
37567
- *
37568
- * @category constructors
37569
- * @since 2.0.0
37570
- */
37571
- var delays = (self) => fromStep(map$23(toStep(self), (step) => (now, input) => catchDone(map$23(step(now, input), ([_, duration]) => [duration, duration]), (_) => done$2(zero))));
37572
- /**
37573
37205
  * Returns a schedule that recurs once after the specified duration.
37574
37206
  *
37575
37207
  * **When to use**
@@ -37627,7 +37259,7 @@ var duration$1 = (durationInput) => {
37627
37259
  * return "task done"
37628
37260
  * }),
37629
37261
  * fiveSecondSchedule.pipe(
37630
- * Schedule.tapOutput((elapsedDuration) =>
37262
+ * Schedule.tap(({ output: elapsedDuration }) =>
37631
37263
  * Console.log(`Total elapsed: ${elapsedDuration}`)
37632
37264
  * )
37633
37265
  * )
@@ -37637,10 +37269,11 @@ var duration$1 = (durationInput) => {
37637
37269
  * })
37638
37270
  *
37639
37271
  * // Combine with other schedules for time-bounded execution
37640
- * const timeAndCountLimited = Schedule.spaced("1 second").pipe(
37641
- * Schedule.both(Schedule.during("10 seconds")), // Stop after 10 seconds OR
37642
- * Schedule.both(Schedule.recurs(15)) // 15 attempts, whichever comes first
37643
- * )
37272
+ * const timeAndCountLimited = Schedule.max([
37273
+ * Schedule.spaced("1 second"),
37274
+ * Schedule.during("10 seconds"), // Stop after 10 seconds OR
37275
+ * Schedule.recurs(15) // 15 attempts, whichever comes first
37276
+ * ])
37644
37277
  *
37645
37278
  * // Burst execution within time window
37646
37279
  * const burstWindow = Schedule.during("3 seconds")
@@ -37660,9 +37293,10 @@ var duration$1 = (durationInput) => {
37660
37293
  * })
37661
37294
  *
37662
37295
  * // Timed retry window - retry for up to 30 seconds
37663
- * const timedRetry = Schedule.exponential("200 millis").pipe(
37664
- * Schedule.both(Schedule.during("30 seconds"))
37665
- * )
37296
+ * const timedRetry = Schedule.max([
37297
+ * Schedule.exponential("200 millis"),
37298
+ * Schedule.during("30 seconds")
37299
+ * ])
37666
37300
  *
37667
37301
  * const retryProgram = Effect.gen(function*() {
37668
37302
  * let attempt = 0
@@ -37692,160 +37326,52 @@ var duration$1 = (durationInput) => {
37692
37326
  * @category constructors
37693
37327
  * @since 4.0.0
37694
37328
  */
37695
- var during = (duration) => while_(elapsed, ({ output }) => succeed$11(isLessThanOrEqualTo$5(output, fromInputUnsafe(duration))));
37329
+ var during = (duration) => {
37330
+ const durationMillis = toMillis(duration);
37331
+ return fromStepWithMetadata(succeed$11((meta) => {
37332
+ const elapsed = millis(meta.elapsed);
37333
+ return meta.elapsed > durationMillis ? succeed$11([elapsed, zero]) : done$2(elapsed);
37334
+ }));
37335
+ };
37696
37336
  /**
37697
- * Combines two `Schedule`s by recurring if either of the two schedules wants
37698
- * to recur, using the minimum of the two durations between recurrences and
37699
- * outputting a tuple of the outputs of both schedules.
37337
+ * Combines schedules by recurring while at least one schedule wants to recur,
37338
+ * using the minimum delay between recurrences and outputting that minimum delay.
37700
37339
  *
37701
37340
  * **When to use**
37702
37341
  *
37703
- * Use when the combined schedule should continue while at least one schedule still recurs.
37342
+ * Use when a combined policy should continue while any schedule still recurs,
37343
+ * and should wait for the fastest schedule between recurrences.
37704
37344
  *
37705
- * **Example** (Combining schedules with either semantics)
37345
+ * **Example** (Combining retry schedules by their minimum delay)
37706
37346
  *
37707
37347
  * ```ts
37708
37348
  * import { Console, Data, Effect, Schedule } from "effect"
37709
37349
  *
37710
37350
  * class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
37711
37351
  *
37712
- * // Either continues as long as at least one schedule wants to continue
37713
- * const timeBasedSchedule = Schedule.spaced("2 seconds").pipe(Schedule.take(3))
37714
- * const countBasedSchedule = Schedule.recurs(5)
37715
- *
37716
- * // Continues until both schedules are exhausted (either still wants to recur)
37717
- * const eitherSchedule = Schedule.either(timeBasedSchedule, countBasedSchedule)
37718
- * // Outputs: [time_result, count_result] tuple
37352
+ * const retrySchedule = Schedule.min([
37353
+ * Schedule.fixed("5 seconds"),
37354
+ * Schedule.exponential("5 seconds"),
37355
+ * Schedule.spaced("10 seconds")
37356
+ * ])
37719
37357
  *
37720
37358
  * const program = Effect.gen(function*() {
37721
- * const results = yield* Effect.repeat(
37722
- * Effect.gen(function*() {
37723
- * yield* Console.log("Task executed")
37724
- * return "task completed"
37725
- * }),
37726
- * eitherSchedule.pipe(
37727
- * Schedule.tapOutput(([timeResult, countResult]) =>
37728
- * Console.log(`Time: ${timeResult}, Count: ${countResult}`)
37729
- * )
37730
- * )
37731
- * )
37732
- *
37733
- * yield* Console.log(`Total executions: ${results.length}`)
37734
- * })
37735
- *
37736
- * // Either with different delay strategies
37737
- * const aggressiveRetry = Schedule.exponential("100 millis").pipe(
37738
- * Schedule.take(3)
37739
- * )
37740
- * const fallbackRetry = Schedule.fixed("5 seconds").pipe(Schedule.take(2))
37741
- *
37742
- * // Will use the more aggressive retry until it's exhausted, then fallback
37743
- * const combinedRetry = Schedule.either(aggressiveRetry, fallbackRetry)
37744
- *
37745
- * const retryProgram = Effect.gen(function*() {
37746
37359
  * let attempt = 0
37747
37360
  *
37748
- * const result = yield* Effect.retry(
37361
+ * yield* Effect.retry(
37749
37362
  * Effect.gen(function*() {
37750
37363
  * attempt++
37751
37364
  * yield* Console.log(`Retry attempt ${attempt}`)
37752
- *
37753
- * if (attempt < 6) {
37365
+ * if (attempt < 3) {
37754
37366
  * return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
37755
37367
  * }
37756
- *
37757
- * return `Success on attempt ${attempt}`
37758
- * }),
37759
- * combinedRetry
37760
- * )
37761
- *
37762
- * yield* Console.log(`Final result: ${result}`)
37763
- * })
37764
- *
37765
- * // Either provides union semantics (OR logic)
37766
- * // Compare with both, which provides intersection semantics (AND logic)
37767
- * ```
37768
- *
37769
- * @see {@link both} for continuing only while both schedules still recur
37770
- *
37771
- * @category combining
37772
- * @since 2.0.0
37773
- */
37774
- var either = /*#__PURE__*/ dual(2, (self, other) => eitherWith(self, other, (left, right) => [left, right]));
37775
- /**
37776
- * Combines two `Schedule`s by recurring if either of the two schedules wants
37777
- * to recur, using the minimum of the two durations between recurrences and
37778
- * outputting the result of the left schedule (i.e. `self`).
37779
- *
37780
- * **When to use**
37781
- *
37782
- * Use when either schedule may keep recurrence going and only the left
37783
- * schedule's output is needed.
37784
- *
37785
- * **Example** (Combining either schedules and keeping the left output)
37786
- *
37787
- * ```ts
37788
- * import { Console, Effect, Schedule } from "effect"
37789
- *
37790
- * // Combine two schedules with either semantics, keeping left output
37791
- * const primarySchedule = Schedule.exponential("100 millis").pipe(
37792
- * Schedule.map(() => Effect.succeed("primary-result")),
37793
- * Schedule.take(2)
37794
- * )
37795
- * const backupSchedule = Schedule.spaced("500 millis").pipe(
37796
- * Schedule.map(() => Effect.succeed("backup-result"))
37797
- * )
37798
- *
37799
- * const combined = Schedule.eitherLeft(primarySchedule, backupSchedule)
37800
- *
37801
- * const program = Effect.gen(function*() {
37802
- * yield* Effect.repeat(
37803
- * Effect.gen(function*() {
37804
- * yield* Console.log("Task executed")
37805
- * return "task-done"
37806
- * }),
37807
- * combined.pipe(Schedule.take(5))
37808
- * )
37809
- * })
37810
- * ```
37811
- *
37812
- * @category combining
37813
- * @since 4.0.0
37814
- */
37815
- var eitherLeft = /*#__PURE__*/ dual(2, (self, other) => eitherWith(self, other, (output) => output));
37816
- /**
37817
- * Combines two `Schedule`s by recurring if either of the two schedules wants
37818
- * to recur, using the minimum of the two durations between recurrences and
37819
- * outputting the result of the right schedule (i.e. `other`).
37820
- *
37821
- * **When to use**
37822
- *
37823
- * Use when either schedule may keep recurrence going and only the right
37824
- * schedule's output is needed.
37825
- *
37826
- * **Example** (Combining either schedules and keeping the right output)
37827
- *
37828
- * ```ts
37829
- * import { Console, Effect, Schedule } from "effect"
37830
- *
37831
- * // Combine two schedules with either semantics, keeping right output
37832
- * const primarySchedule = Schedule.exponential("100 millis").pipe(
37833
- * Schedule.map(() => Effect.succeed("primary-result")),
37834
- * Schedule.take(2)
37835
- * )
37836
- * const backupSchedule = Schedule.spaced("500 millis").pipe(
37837
- * Schedule.map(() => Effect.succeed("backup-result"))
37838
- * )
37839
- *
37840
- * const combined = Schedule.eitherRight(primarySchedule, backupSchedule)
37841
- *
37842
- * const program = Effect.gen(function*() {
37843
- * yield* Effect.repeat(
37844
- * Effect.gen(function*() {
37845
- * yield* Console.log("Task executed")
37846
- * return "task-done"
37368
+ * return "success"
37847
37369
  * }),
37848
- * combined.pipe(Schedule.take(5))
37370
+ * retrySchedule.pipe(
37371
+ * Schedule.tap(({ output: duration }) =>
37372
+ * Console.log(`Waiting for the fastest schedule: ${duration}`)
37373
+ * )
37374
+ * )
37849
37375
  * )
37850
37376
  * })
37851
37377
  * ```
@@ -37853,89 +37379,23 @@ var eitherLeft = /*#__PURE__*/ dual(2, (self, other) => eitherWith(self, other,
37853
37379
  * @category combining
37854
37380
  * @since 4.0.0
37855
37381
  */
37856
- var eitherRight = /*#__PURE__*/ dual(2, (self, other) => eitherWith(self, other, (_, output) => output));
37857
- /**
37858
- * Combines two `Schedule`s by recurring if either of the two schedules wants
37859
- * to recur, using the minimum of the two durations between recurrences and
37860
- * outputting the result of the combination of both schedule outputs using the
37861
- * specified `combine` function.
37862
- *
37863
- * **When to use**
37864
- *
37865
- * Use when either schedule may keep recurrence going and their outputs should be
37866
- * combined into a custom value.
37867
- *
37868
- * **Example** (Combining either schedule outputs)
37869
- *
37870
- * ```ts
37871
- * import { Console, Effect, Schedule } from "effect"
37872
- *
37873
- * // Combine schedules with either semantics and custom combination
37874
- * const primarySchedule = Schedule.exponential("100 millis").pipe(
37875
- * Schedule.map(() => Effect.succeed("primary")),
37876
- * Schedule.take(2)
37877
- * )
37878
- * const fallbackSchedule = Schedule.spaced("500 millis").pipe(
37879
- * Schedule.map(() => Effect.succeed("fallback"))
37880
- * )
37881
- *
37882
- * const combined = Schedule.eitherWith(
37883
- * primarySchedule,
37884
- * fallbackSchedule,
37885
- * (primary, fallback) => `${primary}+${fallback}`
37886
- * )
37887
- *
37888
- * const program = Effect.gen(function*() {
37889
- * yield* Effect.repeat(
37890
- * Effect.gen(function*() {
37891
- * yield* Console.log("Task executed")
37892
- * return "task-result"
37893
- * }),
37894
- * combined.pipe(Schedule.take(5))
37895
- * )
37896
- * })
37897
- * ```
37898
- *
37899
- * @category combining
37900
- * @since 2.0.0
37901
- */
37902
- var eitherWith = /*#__PURE__*/ dual(3, (self, other, combine) => fromStep(map$23(zip$3(toStep(self), toStep(other)), ([stepLeft, stepRight]) => (now, input) => matchEffect$1(stepLeft(now, input), {
37903
- onSuccess: (leftResult) => stepRight(now, input).pipe(map$23((rightResult) => [combine(leftResult[0], rightResult[0]), min$4(leftResult[1], rightResult[1])]), catchDone((rightDone) => succeed$11([combine(leftResult[0], rightDone), leftResult[1]]))),
37904
- onFailure: failCause$9,
37905
- onDone: (leftDone) => stepRight(now, input).pipe(map$23((rightResult) => [combine(leftDone, rightResult[0]), rightResult[1]]), catchDone((rightDone) => done$2(combine(leftDone, rightDone))))
37906
- }))));
37907
- /**
37908
- * Schedule that always recurs and returns the total elapsed duration since the
37909
- * first recurrence.
37910
- *
37911
- * **Details**
37912
- *
37913
- * This schedule never stops and outputs the cumulative time that has passed since the schedule
37914
- * started executing. Useful for tracking execution time or implementing time-based logic.
37915
- *
37916
- * **Example** (Measuring elapsed schedule time)
37917
- *
37918
- * ```ts
37919
- * import { Console, Duration, Effect, Schedule } from "effect"
37920
- *
37921
- * const program = Effect.gen(function*() {
37922
- * yield* Effect.repeat(
37923
- * Console.log("Running task..."),
37924
- * Schedule.spaced("1 second").pipe(
37925
- * Schedule.both(Schedule.elapsed),
37926
- * Schedule.tapOutput(([count, duration]) =>
37927
- * Console.log(`Run ${count}, elapsed: ${Duration.toMillis(duration)}ms`)
37928
- * ),
37929
- * Schedule.take(5)
37930
- * )
37931
- * )
37932
- * })
37933
- * ```
37934
- *
37935
- * @category constructors
37936
- * @since 2.0.0
37937
- */
37938
- var elapsed = /*#__PURE__*/ fromStepWithMetadata(/*#__PURE__*/ succeed$11((meta) => succeed$11([millis(meta.elapsed), zero])));
37382
+ var min$2 = (schedules) => fromStep(map$23(all$3(schedules.map(toStep)), (steps) => (now, input) => flatMap$9(forEach$9(steps, (step) => matchEffect$1(step(now, input), {
37383
+ onSuccess: (result) => succeed$11(result[1]),
37384
+ onDone: () => undefined_$2,
37385
+ onFailure: failCause$9
37386
+ })), (results) => {
37387
+ const duration = minDuration(results);
37388
+ if (duration === void 0) return done$2(zero);
37389
+ return succeed$11([duration, duration]);
37390
+ })));
37391
+ var minDuration = (results) => {
37392
+ let min = void 0;
37393
+ for (let i = 0; i < results.length; i++) {
37394
+ const duration = results[i];
37395
+ if (duration !== void 0) min = min === void 0 ? duration : min$5(min, duration);
37396
+ }
37397
+ return min;
37398
+ };
37939
37399
  /**
37940
37400
  * Schedule that always recurs, but will wait a certain amount between
37941
37401
  * repetitions, given by `base * factor.pow(n)`, where `n` is the number of
@@ -37957,9 +37417,10 @@ var elapsed = /*#__PURE__*/ fromStepWithMetadata(/*#__PURE__*/ succeed$11((meta)
37957
37417
  * // Delays: 200ms, 300ms, 450ms, 675ms, 1012ms, ...
37958
37418
  *
37959
37419
  * // Retry with exponential backoff (limited to 5 attempts)
37960
- * const retryPolicy = Schedule.exponential("50 millis").pipe(
37961
- * Schedule.both(Schedule.recurs(5))
37962
- * )
37420
+ * const retryPolicy = Schedule.max([
37421
+ * Schedule.exponential("50 millis"),
37422
+ * Schedule.recurs(5)
37423
+ * ])
37963
37424
  *
37964
37425
  * const program = Effect.gen(function*() {
37965
37426
  * let attempt = 0
@@ -38023,9 +37484,11 @@ var exponential = (base, factor = 2) => {
38023
37484
  *
38024
37485
  * return `Success on attempt ${attempt}`
38025
37486
  * }),
38026
- * Schedule.fibonacci("50 millis").pipe(
38027
- * Schedule.both(Schedule.recurs(6)), // Maximum 6 retries
38028
- * Schedule.tapOutput((delay) => Console.log(`Next retry in ${delay}`))
37487
+ * Schedule.max([
37488
+ * Schedule.fibonacci("50 millis"),
37489
+ * Schedule.recurs(6) // Maximum 6 retries
37490
+ * ]).pipe(
37491
+ * Schedule.tap(({ output: delay }) => Console.log(`Next retry in ${delay}`))
38029
37492
  * )
38030
37493
  * )
38031
37494
  *
@@ -38039,7 +37502,7 @@ var exponential = (base, factor = 2) => {
38039
37502
  * }).pipe(
38040
37503
  * Effect.repeat(
38041
37504
  * Schedule.fibonacci("200 millis").pipe(
38042
- * Schedule.take(8) // First 8 heartbeats
37505
+ * Schedule.upTo({ times: 8 }) // First 8 heartbeats
38043
37506
  * )
38044
37507
  * )
38045
37508
  * )
@@ -38105,7 +37568,7 @@ var fibonacci = (one) => {
38105
37568
  * yield* Effect.sleep("200 millis") // simulate health check work
38106
37569
  * return "healthy"
38107
37570
  * }).pipe(
38108
- * Effect.repeat(Schedule.fixed("2 seconds").pipe(Schedule.take(5)))
37571
+ * Effect.repeat(Schedule.fixed("2 seconds").pipe(Schedule.upTo({ times: 5 })))
38109
37572
  * )
38110
37573
  *
38111
37574
  * // Difference between fixed and spaced:
@@ -38122,12 +37585,12 @@ var fibonacci = (one) => {
38122
37585
  * // Fixed schedule: if task takes 1.5s but interval is 1s,
38123
37586
  * // next execution happens immediately (no pile-up)
38124
37587
  * const fixedSchedule = longRunningTask.pipe(
38125
- * Effect.repeat(Schedule.fixed("1 second").pipe(Schedule.take(3)))
37588
+ * Effect.repeat(Schedule.fixed("1 second").pipe(Schedule.upTo({ times: 3 })))
38126
37589
  * )
38127
37590
  *
38128
37591
  * // Comparing with spaced (waits 1s AFTER each task)
38129
37592
  * const spacedSchedule = longRunningTask.pipe(
38130
- * Effect.repeat(Schedule.spaced("1 second").pipe(Schedule.take(3)))
37593
+ * Effect.repeat(Schedule.spaced("1 second").pipe(Schedule.upTo({ times: 3 })))
38131
37594
  * )
38132
37595
  *
38133
37596
  * const program = Effect.gen(function*() {
@@ -38165,8 +37628,14 @@ var fixed = (interval) => {
38165
37628
  }));
38166
37629
  };
38167
37630
  /**
38168
- * Returns a new `Schedule` that maps the output of this schedule using the
38169
- * specified function.
37631
+ * Returns a new `Schedule` that maps each schedule decision to a new output
37632
+ * using the full schedule metadata.
37633
+ *
37634
+ * **Details**
37635
+ *
37636
+ * The callback receives the schedule input, output, selected delay duration,
37637
+ * current attempt, and elapsed timing information. Return either a plain value
37638
+ * or an `Effect` that produces the new output.
38170
37639
  *
38171
37640
  * **Example** (Mapping schedule outputs)
38172
37641
  *
@@ -38175,17 +37644,17 @@ var fixed = (interval) => {
38175
37644
  *
38176
37645
  * // Transform schedule output from number to string
38177
37646
  * const countSchedule = Schedule.recurs(5).pipe(
38178
- * Schedule.map((count) => Effect.succeed(`Execution #${count + 1}`))
37647
+ * Schedule.map(({ output: count }) => Effect.succeed(`Execution #${count + 1}`))
38179
37648
  * )
38180
37649
  *
38181
37650
  * // Map schedule delays to human-readable format
38182
37651
  * const readableDelays = Schedule.exponential("100 millis").pipe(
38183
- * Schedule.map((duration) => Effect.succeed(`Next retry in ${duration}`))
37652
+ * Schedule.map(({ output: delay }) => Effect.succeed(`Next retry in ${delay}`))
38184
37653
  * )
38185
37654
  *
38186
37655
  * // Transform numeric output to structured data
38187
37656
  * const structuredSchedule = Schedule.spaced("1 second").pipe(
38188
- * Schedule.map((recurrence) => Effect.succeed({
37657
+ * Schedule.map(({ output: recurrence }) => Effect.succeed({
38189
37658
  * iteration: recurrence + 1,
38190
37659
  * phase: recurrence < 5 ? "warmup" as const : "steady" as const
38191
37660
  * }))
@@ -38195,8 +37664,8 @@ var fixed = (interval) => {
38195
37664
  * const results = yield* Effect.repeat(
38196
37665
  * Effect.succeed("task completed"),
38197
37666
  * structuredSchedule.pipe(
38198
- * Schedule.take(8),
38199
- * Schedule.tapOutput((info) =>
37667
+ * Schedule.upTo({ times: 8 }),
37668
+ * Schedule.tap(({ output: info }) =>
38200
37669
  * Console.log(
38201
37670
  * `${info.phase} phase - iteration ${info.iteration}`
38202
37671
  * )
@@ -38209,7 +37678,7 @@ var fixed = (interval) => {
38209
37678
  *
38210
37679
  * // Map with effectful transformation
38211
37680
  * const effectfulMap = Schedule.fixed("2 seconds").pipe(
38212
- * Schedule.map((count) =>
37681
+ * Schedule.map(({ output: count }) =>
38213
37682
  * Effect.gen(function*() {
38214
37683
  * yield* Console.log(`Processing count: ${count}`)
38215
37684
  * return count * 10
@@ -38217,45 +37686,55 @@ var fixed = (interval) => {
38217
37686
  * )
38218
37687
  * )
38219
37688
  *
38220
- * // Combine mapping with other schedule operations
37689
+ * // Use timing metadata in the mapped output
38221
37690
  * const complexSchedule = Schedule.fibonacci("100 millis").pipe(
38222
- * Schedule.map((delay) => Effect.succeed(`Delay: ${delay}`))
37691
+ * Schedule.map(({ output: delay, attempt }) =>
37692
+ * Effect.succeed(`Attempt ${attempt} delay: ${delay}`)
37693
+ * )
38223
37694
  * )
38224
37695
  * ```
38225
37696
  *
38226
37697
  * @category mapping
38227
37698
  * @since 2.0.0
38228
37699
  */
38229
- var map$20 = /*#__PURE__*/ dual(2, (self, f) => {
38230
- const handle = matchEffect$1({
37700
+ var map$20 = /*#__PURE__*/ dual(2, (self, f) => fromStep(map$23(toStep(self), (step) => {
37701
+ const meta = metadataFn();
37702
+ return (now, input) => matchEffect$1(step(now, input), {
38231
37703
  onSuccess: ([output, duration]) => {
38232
- const result = f(output);
37704
+ const result = f({
37705
+ ...meta(now, input),
37706
+ output,
37707
+ duration
37708
+ });
38233
37709
  if (!isEffect$1(result)) return succeed$11([result, duration]);
38234
37710
  return map$23(result, (output) => [output, duration]);
38235
37711
  },
38236
37712
  onFailure: failCause$9,
38237
37713
  onDone: (output) => {
38238
- const result = f(output);
37714
+ const result = f({
37715
+ ...meta(now, input),
37716
+ output,
37717
+ duration: zero
37718
+ });
38239
37719
  if (!isEffect$1(result)) return done$2(result);
38240
37720
  return flatMap$9(result, done$2);
38241
37721
  }
38242
37722
  });
38243
- return fromStep(map$23(toStep(self), (step) => (now, input) => handle(step(now, input))));
38244
- });
37723
+ })));
38245
37724
  /**
38246
37725
  * Returns a new `Schedule` that modifies the delay of the next recurrence
38247
37726
  * of the schedule using the specified effectful function.
38248
37727
  *
38249
- * **Example** (Modifying delays from schedule output)
37728
+ * **Example** (Modifying delays from schedule metadata)
38250
37729
  *
38251
37730
  * ```ts
38252
37731
  * import { Console, Duration, Effect, Schedule } from "effect"
38253
37732
  *
38254
37733
  * // Modify delays based on output - increase delay on high iteration counts
38255
37734
  * const adaptiveDelay = Schedule.recurs(10).pipe(
38256
- * Schedule.modifyDelay((output, delay) => {
37735
+ * Schedule.modifyDelay(({ output, duration }) => {
38257
37736
  * // Double the delay if we're seeing high iteration counts
38258
- * return Effect.succeed(output > 5 ? Duration.times(delay, 2) : delay)
37737
+ * return Effect.succeed(output > 5 ? Duration.times(duration, 2) : duration)
38259
37738
  * })
38260
37739
  * )
38261
37740
  *
@@ -38267,7 +37746,7 @@ var map$20 = /*#__PURE__*/ dual(2, (self, f) => {
38267
37746
  * yield* Console.log(`Attempt ${counter}`)
38268
37747
  * return counter
38269
37748
  * }),
38270
- * adaptiveDelay.pipe(Schedule.take(8))
37749
+ * adaptiveDelay.pipe(Schedule.upTo({ times: 8 }))
38271
37750
  * )
38272
37751
  * })
38273
37752
  * ```
@@ -38275,7 +37754,14 @@ var map$20 = /*#__PURE__*/ dual(2, (self, f) => {
38275
37754
  * @category delays & timeouts
38276
37755
  * @since 2.0.0
38277
37756
  */
38278
- var modifyDelay = /*#__PURE__*/ dual(2, (self, f) => fromStep(map$23(toStep(self), (step) => (now, input) => flatMap$9(step(now, input), ([output, delay]) => map$23(f(output, delay), (delay) => [output, fromInputUnsafe(delay)])))));
37757
+ var modifyDelay = /*#__PURE__*/ dual(2, (self, f) => fromStep(map$23(toStep(self), (step) => {
37758
+ const meta = metadataFn();
37759
+ return (now, input) => flatMap$9(step(now, input), ([output, duration]) => map$23(f({
37760
+ ...meta(now, input),
37761
+ output,
37762
+ duration
37763
+ }), (replacement) => [output, fromInputUnsafe(replacement)]));
37764
+ })));
38279
37765
  /**
38280
37766
  * Returns a new `Schedule` that randomly adjusts each recurrence delay.
38281
37767
  *
@@ -38293,8 +37779,8 @@ var modifyDelay = /*#__PURE__*/ dual(2, (self, f) => fromStep(map$23(toStep(self
38293
37779
  * @category delays & timeouts
38294
37780
  * @since 2.0.0
38295
37781
  */
38296
- var jittered = (self) => modifyDelay(self, (_, delay) => map$23(randomNext, (random) => {
38297
- const millis$1 = toMillis(fromInputUnsafe(delay));
37782
+ var jittered = (self) => modifyDelay(self, ({ duration }) => map$23(randomNext, (random) => {
37783
+ const millis$1 = toMillis(duration);
38298
37784
  return millis(millis$1 * .8 * (1 - random) + millis$1 * 1.2 * random);
38299
37785
  }));
38300
37786
  /**
@@ -38307,7 +37793,7 @@ var jittered = (self) => modifyDelay(self, (_, delay) => map$23(randomNext, (ran
38307
37793
  *
38308
37794
  * // Create a schedule that outputs the inputs instead of original outputs
38309
37795
  * const inputSchedule = Schedule.passthrough(
38310
- * Schedule.exponential("100 millis").pipe(Schedule.take(3))
37796
+ * Schedule.exponential("100 millis").pipe(Schedule.upTo({ times: 3 }))
38311
37797
  * )
38312
37798
  *
38313
37799
  * const program = Effect.gen(function*() {
@@ -38377,9 +37863,10 @@ var passthrough$2 = (self) => fromStep(map$23(toStep(self), (step) => (now, inpu
38377
37863
  * })
38378
37864
  *
38379
37865
  * // Combining recurs with other schedules for sophisticated retry logic
38380
- * const complexRetry = Schedule.exponential("100 millis").pipe(
38381
- * Schedule.both(Schedule.recurs(3)) // At most 3 retries
38382
- * )
37866
+ * const complexRetry = Schedule.max([
37867
+ * Schedule.exponential("100 millis"),
37868
+ * Schedule.recurs(3) // At most 3 retries
37869
+ * ])
38383
37870
  *
38384
37871
  * // Allow ten recurrences after the initial run
38385
37872
  * const tenRecurrences = Effect.gen(function*() {
@@ -38391,150 +37878,17 @@ var passthrough$2 = (self) => fromStep(map$23(toStep(self), (step) => (now, inpu
38391
37878
  *
38392
37879
  * // The schedule outputs the current recurrence count (0-based)
38393
37880
  * const countingSchedule = Schedule.recurs(3).pipe(
38394
- * Schedule.tapOutput((count) => Console.log(`Execution #${count + 1}`))
37881
+ * Schedule.tap(({ output: count }) => Console.log(`Execution #${count + 1}`))
38395
37882
  * )
38396
37883
  * ```
38397
37884
  *
38398
- * @see {@link take} for limiting an existing schedule
37885
+ * @see {@link upTo} for limiting an existing schedule
38399
37886
  *
38400
37887
  * @category constructors
38401
37888
  * @since 2.0.0
38402
37889
  */
38403
37890
  var recurs = (times) => while_(forever$3, ({ attempt }) => succeed$11(attempt <= times));
38404
37891
  /**
38405
- * Returns a new `Schedule` that combines the outputs of the provided schedule
38406
- * using the specified effectful `combine` function and starting from the
38407
- * specified `initial` state.
38408
- *
38409
- * **Example** (Reducing schedule outputs)
38410
- *
38411
- * ```ts
38412
- * import { Console, Effect, Schedule } from "effect"
38413
- *
38414
- * // Sum up execution counts from a counter schedule
38415
- * const sumSchedule = Schedule.reduce(
38416
- * Schedule.recurs(5),
38417
- * () => 0, // Initial sum
38418
- * (sum, count) => Effect.succeed(sum + count) // Add each count to the sum
38419
- * )
38420
- *
38421
- * const sumProgram = Effect.gen(function*() {
38422
- * const finalSum = yield* Effect.repeat(
38423
- * Effect.gen(function*() {
38424
- * yield* Console.log("Task executed")
38425
- * return "task"
38426
- * }),
38427
- * sumSchedule.pipe(
38428
- * Schedule.tapOutput((sum) => Console.log(`Running sum: ${sum}`))
38429
- * )
38430
- * )
38431
- *
38432
- * yield* Console.log(`Final sum: ${finalSum}`)
38433
- * })
38434
- *
38435
- * // Build a history of execution counts
38436
- * const historySchedule = Schedule.reduce(
38437
- * Schedule.spaced("1 second").pipe(Schedule.take(4)),
38438
- * () => [] as Array<number>, // Initial empty array
38439
- * (history, executionNumber) => Effect.succeed([...history, executionNumber])
38440
- * )
38441
- *
38442
- * const historyProgram = Effect.gen(function*() {
38443
- * const timeline = yield* Effect.repeat(
38444
- * Effect.gen(function*() {
38445
- * yield* Console.log("Recording execution...")
38446
- * return "recorded"
38447
- * }),
38448
- * historySchedule
38449
- * )
38450
- *
38451
- * yield* Console.log(
38452
- * `Execution timeline: ${timeline.join(", ")}`
38453
- * )
38454
- * })
38455
- *
38456
- * // Accumulate metrics with effectful combination
38457
- * const metricsAccumulator = Schedule.reduce(
38458
- * Schedule.recurs(6),
38459
- * () => ({ total: 0, count: 0, max: 0 }),
38460
- * (metrics, executionCount) => Effect.succeed({
38461
- * total: metrics.total + executionCount + 1,
38462
- * count: metrics.count + 1,
38463
- * max: Math.max(metrics.max, executionCount + 1)
38464
- * })
38465
- * )
38466
- *
38467
- * const metricsProgram = Effect.gen(function*() {
38468
- * const finalMetrics = yield* Effect.repeat(
38469
- * Effect.gen(function*() {
38470
- * yield* Console.log("Processing...")
38471
- * return "processed"
38472
- * }),
38473
- * metricsAccumulator
38474
- * )
38475
- *
38476
- * const average = finalMetrics.total / finalMetrics.count
38477
- * yield* Console.log(`Final metrics: ${finalMetrics.count} executions`)
38478
- * yield* Console.log(
38479
- * `Average delay: ${average.toFixed(1)}ms, Max delay: ${finalMetrics.max}ms`
38480
- * )
38481
- * })
38482
- *
38483
- * // Build configuration state over time
38484
- * const configBuilder = Schedule.reduce(
38485
- * Schedule.fixed("500 millis").pipe(Schedule.take(3)),
38486
- * () => ({ retries: 1, timeout: 1000, backoff: 100 }),
38487
- * (config, executionNumber) => Effect.succeed({
38488
- * retries: config.retries + 1,
38489
- * timeout: config.timeout * 1.5,
38490
- * backoff: Math.min(config.backoff * 2, 5000)
38491
- * })
38492
- * )
38493
- *
38494
- * const configProgram = Effect.gen(function*() {
38495
- * const finalConfig = yield* Effect.repeat(
38496
- * Effect.gen(function*() {
38497
- * yield* Console.log("Updating configuration...")
38498
- * return "updated"
38499
- * }),
38500
- * configBuilder.pipe(
38501
- * Schedule.tapOutput((config) =>
38502
- * Console.log(
38503
- * `Config: retries=${config.retries}, timeout=${config.timeout}ms`
38504
- * )
38505
- * )
38506
- * )
38507
- * )
38508
- *
38509
- * yield* Console.log(`Final config: ${JSON.stringify(finalConfig)}`)
38510
- * })
38511
- * ```
38512
- *
38513
- * @category folding
38514
- * @since 2.0.0
38515
- */
38516
- var reduce$10 = /*#__PURE__*/ dual(3, (self, initial, combine) => fromStep(map$23(toStep(self), (step) => {
38517
- let state = initial();
38518
- return (now, input) => matchEffect$1(step(now, input), {
38519
- onSuccess([output, delay]) {
38520
- const next = combine(state, output);
38521
- if (!isEffect$1(next)) {
38522
- state = next;
38523
- return succeed$11([next, delay]);
38524
- }
38525
- return map$23(next, (nextState) => {
38526
- state = nextState;
38527
- return [nextState, delay];
38528
- });
38529
- },
38530
- onFailure: failCause$9,
38531
- onDone(output) {
38532
- const next = combine(state, output);
38533
- return isEffect$1(next) ? flatMap$9(next, done$2) : done$2(next);
38534
- }
38535
- });
38536
- })));
38537
- /**
38538
37892
  * Returns a schedule that recurs continuously, each repetition spaced the
38539
37893
  * specified duration from the last run.
38540
37894
  *
@@ -38564,14 +37918,15 @@ var reduce$10 = /*#__PURE__*/ dual(3, (self, initial, combine) => fromStep(map$2
38564
37918
  * return "Task completed"
38565
37919
  * }).pipe(
38566
37920
  * Effect.repeat(
38567
- * Schedule.spaced("1 second").pipe(Schedule.take(5))
37921
+ * Schedule.spaced("1 second").pipe(Schedule.upTo({ times: 5 }))
38568
37922
  * )
38569
37923
  * )
38570
37924
  *
38571
37925
  * // Simple spaced schedule with limited repetitions
38572
- * const limitedSpaced = Schedule.spaced("100 millis").pipe(
38573
- * Schedule.both(Schedule.recurs(5)) // at most 5 times
38574
- * )
37926
+ * const limitedSpaced = Schedule.max([
37927
+ * Schedule.spaced("100 millis"),
37928
+ * Schedule.recurs(5) // at most 5 times
37929
+ * ])
38575
37930
  *
38576
37931
  * const program = Effect.gen(function*() {
38577
37932
  * yield* Console.log("Starting spaced execution...")
@@ -38610,7 +37965,7 @@ var spaced = (duration) => {
38610
37965
  * import { Console, Effect, Schedule } from "effect"
38611
37966
  *
38612
37967
  * const monitoredSchedule = Schedule.exponential("100 millis").pipe(
38613
- * Schedule.take(5),
37968
+ * Schedule.upTo({ times: 5 }),
38614
37969
  * Schedule.tap((metadata) =>
38615
37970
  * Console.log(
38616
37971
  * `Attempt ${metadata.attempt} produced ${metadata.output} ` +
@@ -38637,235 +37992,27 @@ var tap$3 = /*#__PURE__*/ dual(2, (self, f) => fromStep(map$23(toStep(self), (st
38637
37992
  }));
38638
37993
  })));
38639
37994
  /**
38640
- * Returns a new `Schedule` that allows execution of an effectful function for
38641
- * every input to the schedule, but does not alter the inputs and outputs of
38642
- * the schedule.
38643
- *
38644
- * **Example** (Tapping retry inputs)
38645
- *
38646
- * ```ts
38647
- * import { Console, Data, Effect, Schedule } from "effect"
38648
- *
38649
- * class RetryError extends Data.TaggedError("RetryError")<{ readonly message: string }> {}
38650
- *
38651
- * // Log retry errors for debugging
38652
- * const errorLoggingSchedule = Schedule.exponential("100 millis").pipe(
38653
- * Schedule.take(3),
38654
- * Schedule.tapInput((error: RetryError) =>
38655
- * Console.log(`Retry triggered by error: ${String(error)}`)
38656
- * )
38657
- * )
38658
- *
38659
- * const retryProgram = Effect.gen(function*() {
38660
- * let attempt = 0
38661
- *
38662
- * const result = yield* Effect.retry(
38663
- * Effect.gen(function*() {
38664
- * attempt++
38665
- * if (attempt < 4) {
38666
- * return yield* Effect.fail(new RetryError({ message: `Network timeout on attempt ${attempt}` }))
38667
- * }
38668
- * return `Success on attempt ${attempt}`
38669
- * }),
38670
- * errorLoggingSchedule
38671
- * )
38672
- *
38673
- * yield* Console.log(`Final result: ${result}`)
38674
- * })
38675
- *
38676
- * // Monitor input frequency for metrics
38677
- * const inputMonitoringSchedule = Schedule.spaced("1 second").pipe(
38678
- * Schedule.take(5),
38679
- * Schedule.tapInput((input: unknown) =>
38680
- * Effect.gen(function*() {
38681
- * yield* Console.log(`Input type: ${typeof input}`)
38682
- * // In real applications, might send metrics to monitoring system
38683
- * })
38684
- * )
38685
- * )
38686
- *
38687
- * // Input validation with side effects
38688
- * const validatingSchedule = Schedule.fixed("500 millis").pipe(
38689
- * Schedule.take(4),
38690
- * Schedule.tapInput((input: any) =>
38691
- * Effect.gen(function*() {
38692
- * if (typeof input === "object" && input !== null) {
38693
- * yield* Console.log(`Valid object input: ${JSON.stringify(input)}`)
38694
- * } else {
38695
- * yield* Console.log(`Warning: Non-object input received: ${input}`)
38696
- * }
38697
- * })
38698
- * )
38699
- * )
38700
- *
38701
- * const validationProgram = Effect.gen(function*() {
38702
- * let count = 0
38703
- *
38704
- * yield* Effect.repeat(
38705
- * Effect.gen(function*() {
38706
- * count++
38707
- * yield* Console.log("Task with validation")
38708
- * return { data: `sample-${count}` }
38709
- * }),
38710
- * validatingSchedule
38711
- * )
38712
- * })
38713
- *
38714
- * // Conditional alerting based on input
38715
- * const alertingSchedule = Schedule.exponential("200 millis").pipe(
38716
- * Schedule.take(6),
38717
- * Schedule.tapInput((error: RetryError) =>
38718
- * Effect.gen(function*() {
38719
- * if (String(error).includes("critical")) {
38720
- * yield* Console.log(`Critical error: ${String(error)}`)
38721
- * // In real applications, might trigger alerts or notifications
38722
- * } else {
38723
- * yield* Console.log(`Regular error: ${String(error)}`)
38724
- * }
38725
- * })
38726
- * )
38727
- * )
38728
- *
38729
- * const alertProgram = Effect.gen(function*() {
38730
- * let attempt = 0
38731
- *
38732
- * yield* Effect.retry(
38733
- * Effect.gen(function*() {
38734
- * attempt++
38735
- * const isCritical = attempt === 3
38736
- * const errorType = isCritical
38737
- * ? "critical database failure"
38738
- * : "temporary network issue"
38739
- * return yield* Effect.fail(new RetryError({ message: errorType }))
38740
- * }),
38741
- * alertingSchedule
38742
- * ).pipe(
38743
- * Effect.catch((error: unknown) =>
38744
- * Console.log(`All retries exhausted: ${String(error)}`)
38745
- * )
38746
- * )
38747
- * })
38748
- *
38749
- * // Chain multiple input taps for different purposes
38750
- * const comprehensiveSchedule = Schedule.fibonacci("100 millis").pipe(
38751
- * Schedule.take(5),
38752
- * Schedule.tapInput((error: RetryError) =>
38753
- * Console.log(`Error occurred: ${error._tag}`)
38754
- * ),
38755
- * Schedule.tapInput((error: RetryError) =>
38756
- * String(error).length > 20
38757
- * ? Console.log("Long error message detected")
38758
- * : Effect.void
38759
- * )
38760
- * )
38761
- * ```
38762
- *
38763
- * @category sequencing
38764
- * @since 2.0.0
38765
- */
38766
- var tapInput = /*#__PURE__*/ dual(2, (self, f) => fromStep(map$23(toStep(self), (step) => (now, input) => andThen$2(f(input), step(now, input)))));
38767
- /**
38768
- * Returns a new `Schedule` that allows execution of an effectful function for
38769
- * every output of the schedule, but does not alter the inputs and outputs of
38770
- * the schedule.
38771
- *
38772
- * **Example** (Tapping schedule outputs)
38773
- *
38774
- * ```ts
38775
- * import { Console, Data, Effect, Schedule } from "effect"
38776
- *
38777
- * class RetryAttemptError extends Data.TaggedError("RetryAttemptError")<{ readonly message: string }> {}
38778
- *
38779
- * // Log schedule outputs for debugging/monitoring
38780
- * const monitoredSchedule = Schedule.exponential("100 millis").pipe(
38781
- * Schedule.take(5),
38782
- * Schedule.tapOutput((delay) => Console.log(`Next delay will be: ${delay}`))
38783
- * )
38784
- *
38785
- * const retryProgram = Effect.gen(function*() {
38786
- * let attempt = 0
38787
- *
38788
- * const result = yield* Effect.retry(
38789
- * Effect.gen(function*() {
38790
- * attempt++
38791
- * if (attempt < 4) {
38792
- * return yield* Effect.fail(new RetryAttemptError({ message: `Attempt ${attempt} failed` }))
38793
- * }
38794
- * return `Success on attempt ${attempt}`
38795
- * }),
38796
- * monitoredSchedule
38797
- * )
38798
- *
38799
- * yield* Console.log(`Final result: ${result}`)
38800
- * })
38801
- *
38802
- * // Tap output for metrics collection
38803
- * const metricsSchedule = Schedule.spaced("1 second").pipe(
38804
- * Schedule.take(10),
38805
- * Schedule.tapOutput((executionCount) =>
38806
- * Effect.gen(function*() {
38807
- * // Simulate metrics collection
38808
- * yield* Console.log(`Recording metric: execution_count=${executionCount}`)
38809
- * // In real code, this might send to monitoring system
38810
- * })
38811
- * )
38812
- * )
38813
- *
38814
- * // Tap output with conditional side effects
38815
- * const alertingSchedule = Schedule.fibonacci("200 millis").pipe(
38816
- * Schedule.take(8),
38817
- * Schedule.tapOutput((delay) =>
38818
- * Effect.gen(function*() {
38819
- * const delayMs = delay.toString()
38820
- * if (delayMs.includes("1000")) { // Alert on delays >= 1 second
38821
- * yield* Console.log(`High delay detected: ${delay}`)
38822
- * }
38823
- * })
38824
- * )
38825
- * )
38826
- *
38827
- * const healthCheckProgram = Effect.gen(function*() {
38828
- * yield* Effect.repeat(
38829
- * Effect.gen(function*() {
38830
- * yield* Console.log("Performing health check...")
38831
- * return "healthy"
38832
- * }),
38833
- * alertingSchedule
38834
- * )
38835
- * })
38836
- *
38837
- * // Chain multiple taps for different purposes
38838
- * const comprehensiveSchedule = Schedule.fixed("500 millis").pipe(
38839
- * Schedule.take(6),
38840
- * Schedule.tapOutput((count) => Console.log(`Execution ${count + 1}`)),
38841
- * Schedule.tapOutput((count) =>
38842
- * count % 3 === 0
38843
- * ? Console.log("Checkpoint reached")
38844
- * : Effect.void
38845
- * )
38846
- * )
38847
- * ```
38848
- *
38849
- * @category sequencing
38850
- * @since 2.0.0
38851
- */
38852
- var tapOutput = /*#__PURE__*/ dual(2, (self, f) => fromStep(map$23(toStep(self), (step) => (now, input) => tap$5(step(now, input), ([output]) => f(output)))));
38853
- /**
38854
- * Returns a new `Schedule` that takes at most the specified number of outputs
38855
- * from the schedule. Once the specified number of outputs is reached, the
38856
- * schedule will stop.
37995
+ * Returns a new `Schedule` that limits an existing schedule by elapsed
37996
+ * duration, number of outputs, or both.
38857
37997
  *
38858
37998
  * **When to use**
38859
37999
  *
38860
- * Use to limit an existing schedule while preserving its output and delay behavior.
38000
+ * Use to bound an existing schedule while preserving its output and delay
38001
+ * behavior. When both `duration` and `times` are specified, the schedule
38002
+ * stops as soon as either limit is reached.
38861
38003
  *
38862
38004
  * **Gotchas**
38863
38005
  *
38864
- * `take(n)` limits schedule outputs. When used with repeat or retry, the
38865
- * effect is evaluated once before the schedule is stepped, so the total number
38866
- * of evaluations can be one greater than the number of outputs taken.
38006
+ * The `times` option limits schedule outputs. When used with repeat or retry,
38007
+ * the effect is evaluated once before the schedule is stepped, so the total
38008
+ * number of evaluations can be one greater than the configured number of
38009
+ * outputs.
38010
+ *
38011
+ * The `duration` option is based on the elapsed time observed by the schedule
38012
+ * step. Long-running effects can cause the duration limit to be detected on the
38013
+ * following schedule step.
38867
38014
  *
38868
- * **Example** (Taking a limited number of recurrences)
38015
+ * **Example** (Limiting by duration and recurrence count)
38869
38016
  *
38870
38017
  * ```ts
38871
38018
  * import { Console, Data, Effect, Schedule } from "effect"
@@ -38874,7 +38021,7 @@ var tapOutput = /*#__PURE__*/ dual(2, (self, f) => fromStep(map$23(toStep(self),
38874
38021
  *
38875
38022
  * // Limit an infinite schedule to five recurrences
38876
38023
  * const limitedHeartbeat = Schedule.spaced("1 second").pipe(
38877
- * Schedule.take(5) // Will stop after 5 schedule outputs
38024
+ * Schedule.upTo({ times: 5 })
38878
38025
  * )
38879
38026
  *
38880
38027
  * const heartbeatProgram = Effect.gen(function*() {
@@ -38889,9 +38036,12 @@ var tapOutput = /*#__PURE__*/ dual(2, (self, f) => fromStep(map$23(toStep(self),
38889
38036
  * yield* Console.log("Heartbeat sequence completed")
38890
38037
  * })
38891
38038
  *
38892
- * // Limit retry attempts to a specific number
38039
+ * // Limit retry attempts by both count and elapsed time
38893
38040
  * const limitedRetry = Schedule.exponential("100 millis").pipe(
38894
- * Schedule.take(3) // At most 3 retry attempts
38041
+ * Schedule.upTo({
38042
+ * duration: "5 seconds",
38043
+ * times: 3
38044
+ * })
38895
38045
  * )
38896
38046
  *
38897
38047
  * const retryProgram = Effect.gen(function*() {
@@ -38918,136 +38068,19 @@ var tapOutput = /*#__PURE__*/ dual(2, (self, f) => fromStep(map$23(toStep(self),
38918
38068
  * )
38919
38069
  * )
38920
38070
  *
38921
- * // Combine take with other schedule operations
38922
- * const samplingSchedule = Schedule.fixed("500 millis").pipe(
38923
- * Schedule.take(10), // Take at most 10 schedule outputs
38924
- * Schedule.map((count) => Effect.succeed(`Sample #${count + 1}`))
38071
+ * // Empty options leave the schedule unchanged
38072
+ * const unchanged = Schedule.fixed("500 millis").pipe(
38073
+ * Schedule.upTo({})
38925
38074
  * )
38926
- *
38927
- * const samplingProgram = Effect.gen(function*() {
38928
- * yield* Effect.repeat(
38929
- * Effect.gen(function*() {
38930
- * const value = "sample"
38931
- * yield* Console.log(`Sampled value: ${value}`)
38932
- * return value
38933
- * }),
38934
- * samplingSchedule.pipe(
38935
- * Schedule.tapOutput((label) => Console.log(`Completed: ${label}`))
38936
- * )
38937
- * )
38938
- * })
38939
38075
  * ```
38940
38076
  *
38941
- * @see {@link recurs} for creating a count-limited schedule
38942
- *
38943
- * @category taking
38077
+ * @category filtering
38944
38078
  * @since 4.0.0
38945
38079
  */
38946
- var take$11 = /*#__PURE__*/ dual(2, (self, n) => while_(self, ({ attempt }) => succeed$11(attempt <= n)));
38947
- /**
38948
- * Creates a schedule that unfolds a state by repeatedly applying a function,
38949
- * outputting the current state and computing the next state.
38950
- *
38951
- * **Example** (Unfolding schedule state)
38952
- *
38953
- * ```ts
38954
- * import { Console, Effect, Schedule } from "effect"
38955
- *
38956
- * // Counter schedule that increments by 1 each time
38957
- * const counterSchedule = Schedule.unfold(0, (n) => Effect.succeed(n + 1))
38958
- * // Outputs: 0, 1, 2, 3, 4, 5, ...
38959
- *
38960
- * const countingProgram = Effect.gen(function*() {
38961
- * yield* Effect.repeat(
38962
- * Effect.gen(function*() {
38963
- * yield* Console.log("Task executed")
38964
- * return "done"
38965
- * }),
38966
- * counterSchedule.pipe(
38967
- * Schedule.take(5),
38968
- * Schedule.tapOutput((count) => Console.log(`Count: ${count}`))
38969
- * )
38970
- * )
38971
- * })
38972
- *
38973
- * // Fibonacci sequence schedule
38974
- * const fibonacciSchedule = Schedule.unfold(
38975
- * [0, 1] as [number, number],
38976
- * ([a, b]) => Effect.succeed([b, a + b] as [number, number])
38977
- * )
38978
- * // Outputs: [0,1], [1,1], [1,2], [2,3], [3,5], [5,8], ...
38979
- *
38980
- * const fibProgram = Effect.gen(function*() {
38981
- * yield* Effect.repeat(
38982
- * Console.log("Fibonacci step"),
38983
- * fibonacciSchedule.pipe(
38984
- * Schedule.take(8),
38985
- * Schedule.tapOutput(([a, b]) => Console.log(`Fib: ${a}, next: ${b}`))
38986
- * )
38987
- * )
38988
- * })
38989
- *
38990
- * // Effectful unfold - exponential backoff with state
38991
- * const exponentialState = Schedule.unfold(
38992
- * 100,
38993
- * (delayMs) =>
38994
- * Effect.gen(function*() {
38995
- * yield* Console.log(`Current delay: ${delayMs}ms`)
38996
- * return Math.min(delayMs * 2, 5000) // Cap at 5 seconds
38997
- * })
38998
- * )
38999
- *
39000
- * // Deterministic delay adjustment schedule
39001
- * const adjustedDelaySchedule = Schedule.unfold(
39002
- * { delay: 1000, adjustment: 100 },
39003
- * ({ delay, adjustment }) =>
39004
- * Effect.gen(function*() {
39005
- * const nextDelay = Math.max(100, delay + adjustment)
39006
- * yield* Console.log(`Adjusted delay: ${nextDelay}ms`)
39007
- * return { delay: nextDelay, adjustment: adjustment * -1 }
39008
- * })
39009
- * )
39010
- *
39011
- * // State machine schedule
39012
- * type State = "init" | "warming" | "active" | "cooling"
39013
- * const stateMachineSchedule = Schedule.unfold("init" as State, (state) => {
39014
- * switch (state) {
39015
- * case "init":
39016
- * return Effect.succeed("warming" as State)
39017
- * case "warming":
39018
- * return Effect.succeed("active" as State)
39019
- * case "active":
39020
- * return Effect.succeed("cooling" as State)
39021
- * case "cooling":
39022
- * return Effect.succeed("active" as State)
39023
- * }
39024
- * })
39025
- *
39026
- * const stateMachineProgram = Effect.gen(function*() {
39027
- * yield* Effect.repeat(
39028
- * Effect.gen(function*() {
39029
- * yield* Console.log("State machine step")
39030
- * return "step"
39031
- * }),
39032
- * stateMachineSchedule.pipe(
39033
- * Schedule.take(10),
39034
- * Schedule.tapOutput((state) => Console.log(`State: ${state}`))
39035
- * )
39036
- * )
39037
- * })
39038
- * ```
39039
- *
39040
- * @category constructors
39041
- * @since 2.0.0
39042
- */
39043
- var unfold$1 = (initial, next) => fromStep(sync$6(() => {
39044
- let state = initial;
39045
- return constant$2(map$23(suspend$6(() => next(state)), (nextState) => {
39046
- const prev = state;
39047
- state = nextState;
39048
- return [prev, zero];
39049
- }));
39050
- }));
38080
+ var upTo = /*#__PURE__*/ dual(2, (self, options) => {
38081
+ const duration = options.duration === void 0 ? void 0 : fromInputUnsafe(options.duration);
38082
+ return while_(self, ({ attempt, elapsed }) => succeed$11((options.times === void 0 || attempt <= options.times) && (duration === void 0 || isLessThanOrEqualTo$5(millis(elapsed), duration))));
38083
+ });
39051
38084
  var while_ = /*#__PURE__*/ dual(2, (self, predicate) => fromStep(map$23(toStep(self), (step) => {
39052
38085
  const meta = metadataFn();
39053
38086
  return (now, input) => flatMap$9(step(now, input), (result) => {
@@ -39089,7 +38122,7 @@ var while_ = /*#__PURE__*/ dual(2, (self, predicate) => fromStep(map$23(toStep(s
39089
38122
  * yield* Console.log("Window task executed")
39090
38123
  * return "window-task"
39091
38124
  * }),
39092
- * windowSchedule.pipe(Schedule.take(4))
38125
+ * windowSchedule.pipe(Schedule.upTo({ times: 4 }))
39093
38126
  * )
39094
38127
  * })
39095
38128
  * ```
@@ -39123,7 +38156,7 @@ var windowed = (interval) => {
39123
38156
  * yield* Console.log("Running forever...")
39124
38157
  * return "continuous-task"
39125
38158
  * }),
39126
- * infiniteSchedule.pipe(Schedule.take(5)) // Limit for demo
38159
+ * infiniteSchedule.pipe(Schedule.upTo({ times: 5 })) // Limit for demo
39127
38160
  * )
39128
38161
  * })
39129
38162
  * ```
@@ -39135,37 +38168,6 @@ var forever$3 = /*#__PURE__*/ spaced(zero);
39135
38168
  var constIdentity = /*#__PURE__*/ fromStep(/*#__PURE__*/ succeed$11((_now, input) => succeed$11([input, zero])));
39136
38169
  var identity_ = () => constIdentity;
39137
38170
  /**
39138
- * Ensures that a schedule's input type extends a given type `T`.
39139
- *
39140
- * **When to use**
39141
- *
39142
- * Use when you need a generic helper to prove that an existing schedule can
39143
- * consume a required input type without changing runtime behavior.
39144
- *
39145
- * **Example** (Constraining schedule input types)
39146
- *
39147
- * ```ts
39148
- * import { Schedule } from "effect"
39149
- *
39150
- * declare const StringInputSchedule: Schedule.Schedule<number, string>
39151
- * declare const NumberInputSchedule: Schedule.Schedule<number, number>
39152
- *
39153
- * const satisfiesStringInput = Schedule.satisfiesInputType<string>()
39154
- *
39155
- * // This works because the schedule input type is string.
39156
- * const validSchedule = satisfiesStringInput(StringInputSchedule)
39157
- *
39158
- * // This would cause a TypeScript compilation error:
39159
- * // const invalidSchedule = satisfiesStringInput(NumberInputSchedule)
39160
- * ```
39161
- *
39162
- * @see {@link setInputType} for adapting an input-agnostic schedule
39163
- *
39164
- * @category utility types
39165
- * @since 4.0.0
39166
- */
39167
- var satisfiesInputType = () => (self) => self;
39168
- /**
39169
38171
  * Sets the input type of the provided schedule without altering its behavior.
39170
38172
  *
39171
38173
  * **When to use**
@@ -39187,108 +38189,10 @@ var satisfiesInputType = () => (self) => self;
39187
38189
  * )
39188
38190
  * ```
39189
38191
  *
39190
- * @see {@link satisfiesInputType} for checking an existing input type
39191
- *
39192
38192
  * @category utility types
39193
38193
  * @since 4.0.0
39194
38194
  */
39195
38195
  var setInputType = () => (self) => self;
39196
- /**
39197
- * Ensures that a schedule's output type extends a given type `T`.
39198
- *
39199
- * **Details**
39200
- *
39201
- * This helper is checked at compile time and does not change the schedule's
39202
- * runtime behavior.
39203
- *
39204
- * **Example** (Constraining schedule output types)
39205
- *
39206
- * ```ts
39207
- * import { Schedule } from "effect"
39208
- *
39209
- * declare const StringOutputSchedule: Schedule.Schedule<string>
39210
- * declare const NumberOutputSchedule: Schedule.Schedule<number>
39211
- *
39212
- * const satisfiesStringOutput = Schedule.satisfiesOutputType<string>()
39213
- *
39214
- * // This works because the schedule output type is string.
39215
- * const validSchedule = satisfiesStringOutput(StringOutputSchedule)
39216
- *
39217
- * // This would cause a TypeScript compilation error:
39218
- * // const invalidSchedule = satisfiesStringOutput(NumberOutputSchedule)
39219
- * ```
39220
- *
39221
- * @category utility types
39222
- * @since 4.0.0
39223
- */
39224
- var satisfiesOutputType = () => (self) => self;
39225
- /**
39226
- * Ensures that a schedule's error type extends a given type `T`.
39227
- *
39228
- * **Details**
39229
- *
39230
- * This helper is checked at compile time and does not change the schedule's
39231
- * runtime behavior.
39232
- *
39233
- * **Example** (Constraining schedule error types)
39234
- *
39235
- * ```ts
39236
- * import { Data, Schedule } from "effect"
39237
- *
39238
- * // Create a custom error using Data.TaggedError
39239
- * class CustomError extends Data.TaggedError("CustomError")<{
39240
- * message: string
39241
- * }> {}
39242
- *
39243
- * declare const CustomErrorSchedule: Schedule.Schedule<number, unknown, CustomError>
39244
- * declare const StringErrorSchedule: Schedule.Schedule<number, unknown, string>
39245
- *
39246
- * const satisfiesCustomError = Schedule.satisfiesErrorType<CustomError>()
39247
- *
39248
- * // This works because the schedule error type is CustomError.
39249
- * const validSchedule = satisfiesCustomError(CustomErrorSchedule)
39250
- *
39251
- * // This would cause a TypeScript compilation error:
39252
- * // const invalidSchedule = satisfiesCustomError(StringErrorSchedule)
39253
- * ```
39254
- *
39255
- * @category utility types
39256
- * @since 4.0.0
39257
- */
39258
- var satisfiesErrorType$1 = () => (self) => self;
39259
- /**
39260
- * Ensures that a schedule's context type extends a given type `T`.
39261
- *
39262
- * **Details**
39263
- *
39264
- * This helper is checked at compile time and does not change the schedule's
39265
- * runtime behavior.
39266
- *
39267
- * **Example** (Constraining schedule service types)
39268
- *
39269
- * ```ts
39270
- * import { Schedule } from "effect"
39271
- *
39272
- * interface Logger {
39273
- * readonly log: (message: string) => void
39274
- * }
39275
- *
39276
- * declare const LoggerSchedule: Schedule.Schedule<number, unknown, never, Logger>
39277
- * declare const NumberSchedule: Schedule.Schedule<number, unknown, never, number>
39278
- *
39279
- * const satisfiesLogger = Schedule.satisfiesServicesType<Logger>()
39280
- *
39281
- * // This works because the schedule context type is Logger.
39282
- * const validSchedule = satisfiesLogger(LoggerSchedule)
39283
- *
39284
- * // This would cause a TypeScript compilation error:
39285
- * // const invalidSchedule = satisfiesLogger(NumberSchedule)
39286
- * ```
39287
- *
39288
- * @category utility types
39289
- * @since 4.0.0
39290
- */
39291
- var satisfiesServicesType$1 = () => (self) => self;
39292
38196
  //#endregion
39293
38197
  //#region ../../node_modules/effect/dist/internal/layer.js
39294
38198
  var provideLayer = (self, layer, options) => scopedWith$1((scope) => flatMap$9(options?.local ? buildWithMemoMap(layer, makeMemoMapUnsafe(), scope) : buildWithScope(layer, scope), (context) => provideContext$4(self, context)));
@@ -42104,6 +41008,7 @@ var Effect_exports = /* @__PURE__ */ __exportAll({
42104
41008
  scopedWith: () => scopedWith,
42105
41009
  service: () => service$1,
42106
41010
  serviceOption: () => serviceOption$1,
41011
+ setContext: () => setContext,
42107
41012
  sleep: () => sleep,
42108
41013
  spanAnnotations: () => spanAnnotations,
42109
41014
  spanLinks: () => spanLinks,
@@ -46257,6 +45162,49 @@ var provide$3 = provide$4;
46257
45162
  */
46258
45163
  var provideContext$3 = provideContext$4;
46259
45164
  /**
45165
+ * Runs an effect with the provided context as its complete environment.
45166
+ *
45167
+ * **When to use**
45168
+ *
45169
+ * Use when you already have a `Context` containing every service required by
45170
+ * the effect and want the wrapped effect to run with exactly that context.
45171
+ *
45172
+ * **Gotchas**
45173
+ *
45174
+ * `setContext` replaces the current context for the wrapped effect. Services
45175
+ * from an outer context are not inherited unless they are also present in the
45176
+ * context passed to `setContext`.
45177
+ *
45178
+ * **Example** (Running with a complete context)
45179
+ *
45180
+ * ```ts
45181
+ * import { Context, Effect } from "effect"
45182
+ *
45183
+ * class Config extends Context.Service<Config, {
45184
+ * readonly greeting: string
45185
+ * }>()("Config") {}
45186
+ *
45187
+ * const program = Effect.gen(function*() {
45188
+ * const config = yield* Effect.service(Config)
45189
+ * return `${config.greeting}, World!`
45190
+ * })
45191
+ *
45192
+ * const context = Context.make(Config, { greeting: "Hello" })
45193
+ *
45194
+ * const runnable = Effect.setContext(program, context)
45195
+ *
45196
+ * Effect.runPromise(runnable).then(console.log)
45197
+ * // Output: "Hello, World!"
45198
+ * ```
45199
+ *
45200
+ * @see {@link provideContext} for partially satisfying an effect's context requirements.
45201
+ * @see {@link updateContext} for deriving the required context from the current one.
45202
+ *
45203
+ * @category environment
45204
+ * @since 4.0.0
45205
+ */
45206
+ var setContext = setContext$1;
45207
+ /**
46260
45208
  * Accesses a service from the context.
46261
45209
  *
46262
45210
  * **Example** (Accessing a required service)
@@ -52376,7 +51324,7 @@ var distance = distance$1;
52376
51324
  * @category comparisons
52377
51325
  * @since 3.6.0
52378
51326
  */
52379
- var min$1 = min$3;
51327
+ var min$1 = min$4;
52380
51328
  /**
52381
51329
  * Returns the later of two `DateTime` values.
52382
51330
  *
@@ -52395,7 +51343,7 @@ var min$1 = min$3;
52395
51343
  * @category comparisons
52396
51344
  * @since 3.6.0
52397
51345
  */
52398
- var max$1 = max$3;
51346
+ var max$1 = max$4;
52399
51347
  /**
52400
51348
  * Checks whether the first `DateTime` is after the second `DateTime`.
52401
51349
  *
@@ -56298,6 +55246,7 @@ var SchemaTransformation_exports = /* @__PURE__ */ __exportAll({
56298
55246
  bigDecimalFromString: () => bigDecimalFromString,
56299
55247
  bigintFromString: () => bigintFromString,
56300
55248
  capitalize: () => capitalize,
55249
+ dateFromMillis: () => dateFromMillis,
56301
55250
  dateFromString: () => dateFromString,
56302
55251
  dateTimeUtcFromString: () => dateTimeUtcFromString,
56303
55252
  dateTimeZonedFromString: () => dateTimeZonedFromString,
@@ -56993,7 +55942,7 @@ var bigintFromString = /*#__PURE__*/ new Transformation(/*#__PURE__*/ BigInt$3()
56993
55942
  * )
56994
55943
  * ```
56995
55944
  *
56996
- * @see {@link numberFromString}
55945
+ * @see {@link dateFromMillis}
56997
55946
  * @see {@link dateTimeUtcFromString}
56998
55947
  *
56999
55948
  * @category Coercions
@@ -57001,6 +55950,42 @@ var bigintFromString = /*#__PURE__*/ new Transformation(/*#__PURE__*/ BigInt$3()
57001
55950
  */
57002
55951
  var dateFromString = /*#__PURE__*/ new Transformation(/*#__PURE__*/ Date$2(), /*#__PURE__*/ transform$1(formatDate));
57003
55952
  /**
55953
+ * Decodes epoch milliseconds into a `Date` and encodes a `Date` back to epoch
55954
+ * milliseconds.
55955
+ *
55956
+ * **When to use**
55957
+ *
55958
+ * Use when you need a schema transformation for numeric timestamps represented
55959
+ * as milliseconds since the Unix epoch.
55960
+ *
55961
+ * **Details**
55962
+ *
55963
+ * Decoding creates a `Date` from the number like `new Date(ms)`. Encoding
55964
+ * returns the `Date` timestamp like `date.getTime()`.
55965
+ *
55966
+ * **Gotchas**
55967
+ *
55968
+ * This transformation does not validate date validity. `NaN`, `Infinity`, and
55969
+ * `-Infinity` decode to invalid `Date` instances.
55970
+ *
55971
+ * **Example** (Converting milliseconds to a Date)
55972
+ *
55973
+ * ```ts
55974
+ * import { Schema, SchemaTransformation } from "effect"
55975
+ *
55976
+ * const schema = Schema.Number.pipe(
55977
+ * Schema.decodeTo(Schema.Date, SchemaTransformation.dateFromMillis)
55978
+ * )
55979
+ * ```
55980
+ *
55981
+ * @see {@link dateFromString}
55982
+ * @see {@link SchemaGetter.dateTimeUtcFromInput}
55983
+ *
55984
+ * @category Coercions
55985
+ * @since 4.0.0
55986
+ */
55987
+ var dateFromMillis = /*#__PURE__*/ new Transformation(/*#__PURE__*/ Date$2(), /*#__PURE__*/ transform$1((date) => date.getTime()));
55988
+ /**
57004
55989
  * Decodes a `string` into a `Duration` and encodes a `Duration` back to a
57005
55990
  * parseable `string`.
57006
55991
  *
@@ -57773,8 +56758,8 @@ var timeZoneFromString = /*#__PURE__*/ transformOrFail({
57773
56758
  * UTC, and fails with `InvalidValue` when parsing fails. Encode uses
57774
56759
  * `DateTime.formatIso`.
57775
56760
  *
57776
- * @see {@link dateTimeZonedFromString} for ISO strings that should preserve zoned date-time information
57777
56761
  * @see {@link dateFromString} for decoding into JavaScript `Date`
56762
+ * @see {@link dateTimeZonedFromString} for ISO strings that should preserve zoned date-time information
57778
56763
  *
57779
56764
  * @category transforming
57780
56765
  * @since 4.0.0
@@ -64841,7 +63826,7 @@ var join$5 = join$6;
64841
63826
  * @category folding
64842
63827
  * @since 2.0.0
64843
63828
  */
64844
- var reduce$9 = reduce$11;
63829
+ var reduce$9 = reduce$10;
64845
63830
  /**
64846
63831
  * Reduces the elements of a chunk from right to left.
64847
63832
  *
@@ -83248,17 +82233,39 @@ var ChainArbitrary = class extends Arbitrary {
83248
82233
  }
83249
82234
  };
83250
82235
  /** @internal */
82236
+ function mapperWithCloneIfNeeded(v, mapper) {
82237
+ const sourceValue = v.value;
82238
+ const mappedValue = mapper(sourceValue);
82239
+ if (v.hasToBeCloned && (typeof mappedValue === "object" && mappedValue !== null || typeof mappedValue === "function") && Object.isExtensible(mappedValue) && !hasCloneMethod(mappedValue)) Object.defineProperty(mappedValue, cloneMethod, { get: () => () => mapperWithCloneIfNeeded(v, mapper)[0] });
82240
+ return [mappedValue, sourceValue];
82241
+ }
82242
+ /** @internal */
82243
+ function valueMapper(v, mapper) {
82244
+ const [mappedValue, sourceValue] = mapperWithCloneIfNeeded(v, mapper);
82245
+ return new Value(mappedValue, {
82246
+ originalValue: sourceValue,
82247
+ originalContext: v.context
82248
+ });
82249
+ }
82250
+ /** @internal */
83251
82251
  var MapArbitrary = class extends Arbitrary {
83252
82252
  constructor(arb, mapper, unmapper) {
83253
82253
  super();
83254
82254
  this.arb = arb;
83255
82255
  this.mapper = mapper;
83256
82256
  this.unmapper = unmapper;
83257
- this.bindValueMapper = (v) => this.valueMapper(v);
82257
+ this.bindValueMapper = (v) => valueMapper(v, mapper);
83258
82258
  }
83259
82259
  generate(mrng, biasFactor) {
83260
82260
  const g = this.arb.generate(mrng, biasFactor);
83261
- return this.valueMapper(g);
82261
+ if (!g.hasToBeCloned) {
82262
+ const sourceValue = g.value;
82263
+ return new Value(this.mapper(sourceValue), {
82264
+ originalValue: sourceValue,
82265
+ originalContext: g.context
82266
+ });
82267
+ }
82268
+ return valueMapper(g, this.mapper);
83262
82269
  }
83263
82270
  canShrinkWithoutContext(value) {
83264
82271
  if (this.unmapper !== void 0) try {
@@ -83277,19 +82284,6 @@ var MapArbitrary = class extends Arbitrary {
83277
82284
  }
83278
82285
  return Stream.nil();
83279
82286
  }
83280
- mapperWithCloneIfNeeded(v) {
83281
- const sourceValue = v.value;
83282
- const mappedValue = this.mapper(sourceValue);
83283
- if (v.hasToBeCloned && (typeof mappedValue === "object" && mappedValue !== null || typeof mappedValue === "function") && Object.isExtensible(mappedValue) && !hasCloneMethod(mappedValue)) Object.defineProperty(mappedValue, cloneMethod, { get: () => () => this.mapperWithCloneIfNeeded(v)[0] });
83284
- return [mappedValue, sourceValue];
83285
- }
83286
- valueMapper(v) {
83287
- const [mappedValue, sourceValue] = this.mapperWithCloneIfNeeded(v);
83288
- return new Value(mappedValue, {
83289
- originalValue: sourceValue,
83290
- originalContext: v.context
83291
- });
83292
- }
83293
82287
  isSafeContext(context) {
83294
82288
  return context !== null && context !== void 0 && typeof context === "object" && "originalValue" in context && "originalContext" in context;
83295
82289
  }
@@ -83815,40 +82809,39 @@ function makeLazy(producer) {
83815
82809
  var safeArrayIsArray$4 = Array.isArray;
83816
82810
  var safeObjectDefineProperty$3 = Object.defineProperty;
83817
82811
  /** @internal */
83818
- function tupleMakeItCloneable(vs, values) {
82812
+ function tupleMakeItCloneable(vs, ctxs, values) {
83819
82813
  return safeObjectDefineProperty$3(vs, cloneMethod, { value: () => {
83820
82814
  const cloned = [];
83821
- for (let idx = 0; idx !== values.length; ++idx) safePush(cloned, values[idx].value);
83822
- tupleMakeItCloneable(cloned, values);
82815
+ for (let idx = 0; idx !== values.length; ++idx) {
82816
+ let current = values[idx];
82817
+ if (current === void 0) current = new Value(vs[idx], ctxs[idx]);
82818
+ safePush(cloned, current.value);
82819
+ }
82820
+ tupleMakeItCloneable(cloned, ctxs, values);
83823
82821
  return cloned;
83824
82822
  } });
83825
82823
  }
83826
82824
  /** @internal */
83827
- function tupleWrapper(values) {
83828
- let cloneable = false;
83829
- const vs = [];
83830
- const ctxs = [];
83831
- for (let idx = 0; idx !== values.length; ++idx) {
83832
- const v = values[idx];
83833
- cloneable = cloneable || v.hasToBeCloned;
83834
- safePush(vs, v.value);
83835
- safePush(ctxs, v.context);
83836
- }
83837
- if (cloneable) tupleMakeItCloneable(vs, values);
83838
- return new Value(vs, ctxs);
83839
- }
83840
- /** @internal */
83841
82825
  function tupleShrink(arbs, value, context) {
83842
82826
  const shrinks = [];
83843
82827
  const safeContext = safeArrayIsArray$4(context) ? context : [];
83844
82828
  for (let idx = 0; idx !== arbs.length; ++idx) safePush(shrinks, makeLazy(() => arbs[idx].shrink(value[idx], safeContext[idx]).map((v) => {
83845
- const nextValues = safeMap(value, (v, idx) => new Value(cloneIfNeeded(v), safeContext[idx]));
83846
- return [
83847
- ...safeSlice(nextValues, 0, idx),
83848
- v,
83849
- ...safeSlice(nextValues, idx + 1)
83850
- ];
83851
- }).map(tupleWrapper)));
82829
+ let cloneable = false;
82830
+ const vs = [];
82831
+ const ctxs = [];
82832
+ const mapped = [];
82833
+ for (let nestedIdx = 0; nestedIdx !== arbs.length; ++nestedIdx) {
82834
+ const nestedV = nestedIdx === idx ? v : new Value(cloneIfNeeded(value[nestedIdx]), safeContext[nestedIdx]);
82835
+ if (nestedV.hasToBeCloned) {
82836
+ cloneable = true;
82837
+ mapped[nestedIdx] = nestedV;
82838
+ }
82839
+ safePush(vs, nestedV.value);
82840
+ safePush(ctxs, nestedV.context);
82841
+ }
82842
+ if (cloneable) tupleMakeItCloneable(vs, ctxs, mapped);
82843
+ return new Value(vs, ctxs);
82844
+ })));
83852
82845
  return Stream.nil().join(...shrinks);
83853
82846
  }
83854
82847
  /** @internal */
@@ -83862,9 +82855,21 @@ var TupleArbitrary = class extends Arbitrary {
83862
82855
  }
83863
82856
  }
83864
82857
  generate(mrng, biasFactor) {
82858
+ let cloneable = false;
82859
+ const vs = [];
82860
+ const ctxs = [];
83865
82861
  const mapped = [];
83866
- for (let idx = 0; idx !== this.arbs.length; ++idx) safePush(mapped, this.arbs[idx].generate(mrng, biasFactor));
83867
- return tupleWrapper(mapped);
82862
+ for (let idx = 0; idx !== this.arbs.length; ++idx) {
82863
+ const v = this.arbs[idx].generate(mrng, biasFactor);
82864
+ if (v.hasToBeCloned) {
82865
+ cloneable = true;
82866
+ mapped[idx] = v;
82867
+ }
82868
+ safePush(vs, v.value);
82869
+ safePush(ctxs, v.context);
82870
+ }
82871
+ if (cloneable) tupleMakeItCloneable(vs, ctxs, mapped);
82872
+ return new Value(vs, ctxs);
83868
82873
  }
83869
82874
  canShrinkWithoutContext(value) {
83870
82875
  if (!safeArrayIsArray$4(value) || value.length !== this.arbs.length) return false;
@@ -85066,7 +84071,7 @@ function pathWalk(path, initialProducers, shrink) {
85066
84071
  }
85067
84072
  return values;
85068
84073
  }
85069
- var safeObjectAssign$5 = Object.assign;
84074
+ var safeObjectAssign$6 = Object.assign;
85070
84075
  /** @internal */
85071
84076
  function formatHints(hints) {
85072
84077
  if (hints.length === 1) return `Hint: ${hints[0]}`;
@@ -85187,7 +84192,7 @@ async function asyncDefaultReportMessage(out) {
85187
84192
  function buildError(errorMessage, out) {
85188
84193
  if (out.runConfiguration.includeErrorInReport) throw new SError(errorMessage);
85189
84194
  const error = new SError(errorMessage, { cause: out.errorInstance });
85190
- if (!("cause" in error)) safeObjectAssign$5(error, { cause: out.errorInstance });
84195
+ if (!("cause" in error)) safeObjectAssign$6(error, { cause: out.errorInstance });
85191
84196
  return error;
85192
84197
  }
85193
84198
  /** @internal */
@@ -85349,7 +84354,7 @@ function statistics(generator, classify, params) {
85349
84354
  const longestPercent = data.map((i) => i[1].length).reduce((p, c) => Math.max(p, c), 0);
85350
84355
  for (const item of data) qParams.logger(`${item[0].padEnd(longestName, ".")}..${item[1].padStart(longestPercent, ".")}`);
85351
84356
  }
85352
- var safeObjectAssign$4 = Object.assign;
84357
+ var safeObjectAssign$5 = Object.assign;
85353
84358
  /**
85354
84359
  * An internal builder of values of type {@link GeneratorValue}
85355
84360
  * @internal
@@ -85387,7 +84392,7 @@ function buildGeneratorValue(mrng, biasFactor, computePreBuiltValues, arbitraryC
85387
84392
  const memoedValueFunction = (arb, ...args) => {
85388
84393
  return valueFunction(arbitraryCache(arb, args));
85389
84394
  };
85390
- return new Value(safeObjectAssign$4(memoedValueFunction, {
84395
+ return new Value(safeObjectAssign$5(memoedValueFunction, {
85391
84396
  values() {
85392
84397
  return safeMap(context.history, (c) => c.value);
85393
84398
  },
@@ -85601,33 +84606,27 @@ var IntegerArbitrary = class IntegerArbitrary extends Arbitrary {
85601
84606
  super();
85602
84607
  this.min = min;
85603
84608
  this.max = max;
84609
+ this.ranges = biasNumericRange(min, max, integerLogLike);
85604
84610
  }
85605
84611
  generate(mrng, biasFactor) {
85606
- const range = this.computeGenerateRange(mrng, biasFactor);
84612
+ if (biasFactor === void 0 || mrng.nextInt(1, biasFactor) !== 1) return new Value(mrng.nextInt(this.min, this.max), void 0);
84613
+ const ranges = this.ranges;
84614
+ if (ranges.length === 1) {
84615
+ const range = ranges[0];
84616
+ return new Value(mrng.nextInt(range.min, range.max), void 0);
84617
+ }
84618
+ const id = mrng.nextInt(-2 * (ranges.length - 1), ranges.length - 2);
84619
+ const range = id < 0 ? ranges[0] : ranges[id + 1];
85607
84620
  return new Value(mrng.nextInt(range.min, range.max), void 0);
85608
84621
  }
85609
84622
  canShrinkWithoutContext(value) {
85610
84623
  return typeof value === "number" && safeNumberIsInteger$6(value) && !safeObjectIs$6(value, -0) && this.min <= value && value <= this.max;
85611
84624
  }
85612
84625
  shrink(current, context) {
85613
- if (!IntegerArbitrary.isValidContext(current, context)) return shrinkInteger(current, this.defaultTarget(), true);
84626
+ if (!IntegerArbitrary.isValidContext(current, context)) return shrinkInteger(current, this.min <= 0 && this.max >= 0 ? 0 : this.min < 0 ? this.max : this.min, true);
85614
84627
  if (this.isLastChanceTry(current, context)) return Stream.of(new Value(context, void 0));
85615
84628
  return shrinkInteger(current, context, false);
85616
84629
  }
85617
- defaultTarget() {
85618
- if (this.min <= 0 && this.max >= 0) return 0;
85619
- return this.min < 0 ? this.max : this.min;
85620
- }
85621
- computeGenerateRange(mrng, biasFactor) {
85622
- if (biasFactor === void 0 || mrng.nextInt(1, biasFactor) !== 1) return {
85623
- min: this.min,
85624
- max: this.max
85625
- };
85626
- const ranges = biasNumericRange(this.min, this.max, integerLogLike);
85627
- if (ranges.length === 1) return ranges[0];
85628
- const id = mrng.nextInt(-2 * (ranges.length - 1), ranges.length - 2);
85629
- return id < 0 ? ranges[0] : ranges[id + 1];
85630
- }
85631
84630
  isLastChanceTry(current, context) {
85632
84631
  if (current > 0) return current === context + 1 && current > this.min;
85633
84632
  if (current < 0) return current === context - 1 && current < this.max;
@@ -85706,7 +84705,7 @@ var NoopSlicedGenerator = class {
85706
84705
  }
85707
84706
  };
85708
84707
  var safeMathMin$5 = Math.min;
85709
- var safeMathMax$3 = Math.max;
84708
+ var safeMathMax$2 = Math.max;
85710
84709
  /** @internal */
85711
84710
  var SlicedBasedGenerator = class {
85712
84711
  constructor(arb, mrng, slices, biasFactor) {
@@ -85741,7 +84740,7 @@ var SlicedBasedGenerator = class {
85741
84740
  const rangeBoundaryA = this.mrng.nextInt(0, slice.length - 1);
85742
84741
  const rangeBoundaryB = this.mrng.nextInt(0, slice.length - 1);
85743
84742
  this.nextIndexInSlice = safeMathMin$5(rangeBoundaryA, rangeBoundaryB);
85744
- this.lastIndexInSlice = safeMathMax$3(rangeBoundaryA, rangeBoundaryB);
84743
+ this.lastIndexInSlice = safeMathMax$2(rangeBoundaryA, rangeBoundaryB);
85745
84744
  return new Value(slice[this.nextIndexInSlice++], void 0);
85746
84745
  }
85747
84746
  };
@@ -85761,7 +84760,6 @@ function buildSlicedGenerator(arb, mrng, slices, biasFactor) {
85761
84760
  }
85762
84761
  var safeMathFloor$4 = Math.floor;
85763
84762
  var safeMathLog$1 = Math.log;
85764
- var safeMathMax$2 = Math.max;
85765
84763
  var safeArrayIsArray$2 = Array.isArray;
85766
84764
  /** @internal */
85767
84765
  function biasedMaxLength(minLength, maxLength) {
@@ -85783,6 +84781,7 @@ var ArrayArbitrary = class ArrayArbitrary extends Arbitrary {
85783
84781
  max: maxGeneratedLength
85784
84782
  });
85785
84783
  this.depthContext = getDepthContextFor(depthIdentifier);
84784
+ this.cachedBiasedMaxLength = biasedMaxLength(minLength, maxGeneratedLength);
85786
84785
  }
85787
84786
  preFilter(tab) {
85788
84787
  if (this.setBuilder === void 0) return tab;
@@ -85811,7 +84810,8 @@ var ArrayArbitrary = class ArrayArbitrary extends Arbitrary {
85811
84810
  return s.getData();
85812
84811
  }
85813
84812
  safeGenerateNItemsNoDuplicates(setBuilder, N, mrng, biasFactorItems) {
85814
- const depthImpact = safeMathMax$2(0, N - biasedMaxLength(this.minLength, this.maxGeneratedLength));
84813
+ const depthImpact = N - this.cachedBiasedMaxLength;
84814
+ if (depthImpact <= 0) return this.generateNItemsNoDuplicates(setBuilder, N, mrng, biasFactorItems);
85815
84815
  this.depthContext.depth += depthImpact;
85816
84816
  try {
85817
84817
  return this.generateNItemsNoDuplicates(setBuilder, N, mrng, biasFactorItems);
@@ -85827,7 +84827,8 @@ var ArrayArbitrary = class ArrayArbitrary extends Arbitrary {
85827
84827
  return items;
85828
84828
  }
85829
84829
  safeGenerateNItems(N, mrng, biasFactorItems) {
85830
- const depthImpact = safeMathMax$2(0, N - biasedMaxLength(this.minLength, this.maxGeneratedLength));
84830
+ const depthImpact = N - this.cachedBiasedMaxLength;
84831
+ if (depthImpact <= 0) return this.generateNItems(N, mrng, biasFactorItems);
85831
84832
  this.depthContext.depth += depthImpact;
85832
84833
  try {
85833
84834
  return this.generateNItems(N, mrng, biasFactorItems);
@@ -85855,30 +84856,26 @@ var ArrayArbitrary = class ArrayArbitrary extends Arbitrary {
85855
84856
  });
85856
84857
  }
85857
84858
  generate(mrng, biasFactor) {
85858
- const biasMeta = this.applyBias(mrng, biasFactor);
85859
- const targetSize = biasMeta.size;
85860
- const items = this.setBuilder !== void 0 ? this.safeGenerateNItemsNoDuplicates(this.setBuilder, targetSize, mrng, biasMeta.biasFactorItems) : this.safeGenerateNItems(targetSize, mrng, biasMeta.biasFactorItems);
85861
- return this.wrapper(items, false, void 0, 0);
85862
- }
85863
- applyBias(mrng, biasFactor) {
85864
- if (biasFactor === void 0) return { size: this.lengthArb.generate(mrng, void 0).value };
85865
- if (this.minLength === this.maxGeneratedLength) return {
85866
- size: this.lengthArb.generate(mrng, void 0).value,
85867
- biasFactorItems: biasFactor
85868
- };
85869
- if (mrng.nextInt(1, biasFactor) !== 1) return { size: this.lengthArb.generate(mrng, void 0).value };
85870
- if (mrng.nextInt(1, biasFactor) !== 1 || this.minLength === this.maxGeneratedLength) return {
85871
- size: this.lengthArb.generate(mrng, void 0).value,
85872
- biasFactorItems: biasFactor
85873
- };
85874
- const maxBiasedLength = biasedMaxLength(this.minLength, this.maxGeneratedLength);
85875
- return {
85876
- size: integer({
84859
+ let targetSize;
84860
+ let biasFactorItems;
84861
+ if (biasFactor === void 0) targetSize = this.lengthArb.generate(mrng, void 0).value;
84862
+ else if (this.minLength === this.maxGeneratedLength) {
84863
+ targetSize = this.lengthArb.generate(mrng, void 0).value;
84864
+ biasFactorItems = biasFactor;
84865
+ } else if (mrng.nextInt(1, biasFactor) !== 1) targetSize = this.lengthArb.generate(mrng, void 0).value;
84866
+ else if (mrng.nextInt(1, biasFactor) !== 1) {
84867
+ targetSize = this.lengthArb.generate(mrng, void 0).value;
84868
+ biasFactorItems = biasFactor;
84869
+ } else {
84870
+ const maxBiasedLength = this.cachedBiasedMaxLength;
84871
+ targetSize = integer({
85877
84872
  min: this.minLength,
85878
84873
  max: maxBiasedLength
85879
- }).generate(mrng, void 0).value,
85880
- biasFactorItems: biasFactor
85881
- };
84874
+ }).generate(mrng, void 0).value;
84875
+ biasFactorItems = biasFactor;
84876
+ }
84877
+ const items = this.setBuilder !== void 0 ? this.safeGenerateNItemsNoDuplicates(this.setBuilder, targetSize, mrng, biasFactorItems) : this.safeGenerateNItems(targetSize, mrng, biasFactorItems);
84878
+ return this.wrapper(items, false, void 0, 0);
85882
84879
  }
85883
84880
  canShrinkWithoutContext(value) {
85884
84881
  if (!safeArrayIsArray$2(value) || this.minLength > value.length || value.length > this.maxLength) return false;
@@ -86712,12 +85709,17 @@ var safeReflectOwnKeys = Reflect.ownKeys;
86712
85709
  /** @internal */
86713
85710
  function keyValuePairsToObjectMapper(definition) {
86714
85711
  const obj = definition[1] ? safeObjectCreate$5(null) : {};
86715
- for (const keyValue of definition[0]) safeObjectDefineProperty$2(obj, keyValue[0], {
86716
- enumerable: true,
86717
- configurable: true,
86718
- writable: true,
86719
- value: keyValue[1]
86720
- });
85712
+ const keyValues = definition[0];
85713
+ for (let idx = 0; idx !== keyValues.length; ++idx) {
85714
+ const key = keyValues[idx][0];
85715
+ if (key === "__proto__") safeObjectDefineProperty$2(obj, key, {
85716
+ enumerable: true,
85717
+ configurable: true,
85718
+ writable: true,
85719
+ value: keyValues[idx][1]
85720
+ });
85721
+ else obj[key] = keyValues[idx][1];
85722
+ }
86721
85723
  return obj;
86722
85724
  }
86723
85725
  /** @internal */
@@ -86767,11 +85769,12 @@ var FrequencyArbitrary = class FrequencyArbitrary extends Arbitrary {
86767
85769
  if (currentWeight < 0) throw new Error(`${label} expects weights to be superior or equal to 0`);
86768
85770
  }
86769
85771
  if (totalWeight <= 0) throw new Error(`${label} expects the sum of weights to be strictly superior to 0`);
86770
- return new FrequencyArbitrary(warbs, {
85772
+ const sanitizedConstraints = {
86771
85773
  depthBias: depthBiasFromSizeForArbitrary(constraints.depthSize, constraints.maxDepth !== void 0),
86772
85774
  maxDepth: constraints.maxDepth !== void 0 ? constraints.maxDepth : safePositiveInfinity$7,
86773
85775
  withCrossShrink: !!constraints.withCrossShrink
86774
- }, getDepthContextFor(constraints.depthIdentifier));
85776
+ };
85777
+ return new FrequencyArbitrary(warbs, sanitizedConstraints, getDepthContextFor(constraints.depthIdentifier));
86775
85778
  }
86776
85779
  constructor(warbs, constraints, context) {
86777
85780
  super();
@@ -89233,7 +88236,7 @@ function noShrink(arb) {
89233
88236
  if (stableObjectGetPrototypeOf(arb) === NoShrinkArbitrary.prototype && arb.generate === NoShrinkArbitrary.prototype.generate && arb.canShrinkWithoutContext === NoShrinkArbitrary.prototype.canShrinkWithoutContext && arb.shrink === NoShrinkArbitrary.prototype.shrink) return arb;
89234
88237
  return new NoShrinkArbitrary(arb);
89235
88238
  }
89236
- var safeObjectAssign$3 = Object.assign;
88239
+ var safeObjectAssign$4 = Object.assign;
89237
88240
  var safeObjectKeys$3 = Object.keys;
89238
88241
  /** @internal */
89239
88242
  function buildCompareFunctionArbitrary(cmp) {
@@ -89250,7 +88253,7 @@ function buildCompareFunctionArbitrary(cmp) {
89250
88253
  recorded[`[${reprA},${reprB}]`] = val;
89251
88254
  return val;
89252
88255
  };
89253
- return safeObjectAssign$3(f, {
88256
+ return safeObjectAssign$4(f, {
89254
88257
  toString: () => {
89255
88258
  const seenValues = safeObjectKeys$3(recorded).sort().map((k) => `${k} => ${stringify$2(recorded[k])}`).map((line) => `/* ${escapeForMultilineComments(line)} */`);
89256
88259
  return `function(a, b) {
@@ -89267,7 +88270,7 @@ function buildCompareFunctionArbitrary(cmp) {
89267
88270
  return producer();
89268
88271
  });
89269
88272
  }
89270
- var safeObjectAssign$2 = Object.assign;
88273
+ var safeObjectAssign$3 = Object.assign;
89271
88274
  /**
89272
88275
  * For comparison boolean functions
89273
88276
  *
@@ -89279,11 +88282,11 @@ var safeObjectAssign$2 = Object.assign;
89279
88282
  * @public
89280
88283
  */
89281
88284
  function compareBooleanFunc() {
89282
- return buildCompareFunctionArbitrary(safeObjectAssign$2((hA, hB) => hA < hB, { toString() {
88285
+ return buildCompareFunctionArbitrary(safeObjectAssign$3((hA, hB) => hA < hB, { toString() {
89283
88286
  return "(hA, hB) => hA < hB";
89284
88287
  } }));
89285
88288
  }
89286
- var safeObjectAssign$1 = Object.assign;
88289
+ var safeObjectAssign$2 = Object.assign;
89287
88290
  /**
89288
88291
  * For comparison functions
89289
88292
  *
@@ -89300,7 +88303,7 @@ var safeObjectAssign$1 = Object.assign;
89300
88303
  * @public
89301
88304
  */
89302
88305
  function compareFunc() {
89303
- return buildCompareFunctionArbitrary(safeObjectAssign$1((hA, hB) => hA - hB, { toString() {
88306
+ return buildCompareFunctionArbitrary(safeObjectAssign$2((hA, hB) => hA - hB, { toString() {
89304
88307
  return "(hA, hB) => hA - hB";
89305
88308
  } }));
89306
88309
  }
@@ -89666,7 +88669,7 @@ function initialPoolForEntityGraph(keys, constraints) {
89666
88669
  if (!canHaveAtLeastOneItem(keys, constraints)) throw new SError("Contraints on pool must accept at least one entity, maxLength cannot sum to 0");
89667
88670
  return tuple(...keys.map((key) => array(constant(key), constraints[key]))).map((values) => safeFlat(values)).filter((names) => names.length > 0);
89668
88671
  }
89669
- var safeObjectAssign = Object.assign;
88672
+ var safeObjectAssign$1 = Object.assign;
89670
88673
  var safeObjectCreate$4 = Object.create;
89671
88674
  var safeObjectDefineProperty$1 = Object.defineProperty;
89672
88675
  var safeObjectGetPrototypeOf = Object.getPrototypeOf;
@@ -89691,7 +88694,7 @@ function unlinkedToLinkedEntitiesMapper(unlinkedEntities, producedLinks) {
89691
88694
  const unlinkedEntitiesForName = unlinkedEntities[name];
89692
88695
  const linkedEntitiesForName = [];
89693
88696
  for (const unlinkedEntity of unlinkedEntitiesForName) {
89694
- const linkedEntity = safeObjectAssign(safeObjectCreate$4(safeObjectGetPrototypeOf(unlinkedEntity)), unlinkedEntity);
88697
+ const linkedEntity = safeObjectAssign$1(safeObjectCreate$4(safeObjectGetPrototypeOf(unlinkedEntity)), unlinkedEntity);
89695
88698
  linkedEntitiesForName.push(linkedEntity);
89696
88699
  }
89697
88700
  linkedEntities[name] = linkedEntitiesForName;
@@ -89711,7 +88714,7 @@ function unlinkedToLinkedEntitiesMapper(unlinkedEntities, producedLinks) {
89711
88714
  writable: false,
89712
88715
  value: () => {
89713
88716
  const unlinkedEntity = unlinkedEntities[name][entityIndex];
89714
- const entity = safeObjectAssign(safeObjectCreate$4(safeObjectGetPrototypeOf(unlinkedEntity)), unlinkedEntity);
88717
+ const entity = safeObjectAssign$1(safeObjectCreate$4(safeObjectGetPrototypeOf(unlinkedEntity)), unlinkedEntity);
89715
88718
  for (const prop in entityLinksForInstance) {
89716
88719
  const propValue = entityLinksForInstance[prop];
89717
88720
  entity[prop] = propValue.index === void 0 ? void 0 : typeof propValue.index === "number" ? withReferenceStringifiedValue(propValue.type, propValue.index) : safeMap(propValue.index, (index) => withReferenceStringifiedValue(propValue.type, index));
@@ -89766,6 +88769,7 @@ function buildInversedRelationsMapping(relations) {
89766
88769
  if (inversedRelations.size !== foundInversedRelations) throw new SError(`Some inverse relationships could not be matched with their corresponding forward relationships`);
89767
88770
  return inversedRelations;
89768
88771
  }
88772
+ var safeObjectAssign = Object.assign;
89769
88773
  var safeObjectCreate$3 = Object.create;
89770
88774
  /** @internal */
89771
88775
  function produceLinkUnitaryIndexArbitrary(strategy, currentIndexIfSameType, countInTargetType) {
@@ -89782,128 +88786,200 @@ function produceLinkUnitaryIndexArbitrary(strategy, currentIndexIfSameType, coun
89782
88786
  }
89783
88787
  }
89784
88788
  /** @internal */
89785
- function computeLinkIndex(arity, strategy, currentIndexIfSameType, countInTargetType, currentEntityDepth, mrng, biasFactor) {
88789
+ function buildLinkIndexArbitrary(arity, strategy, currentIndexIfSameType, countInTargetType, currentEntityDepth) {
89786
88790
  const linkArbitrary = produceLinkUnitaryIndexArbitrary(strategy, currentIndexIfSameType, countInTargetType);
89787
88791
  switch (arity) {
89788
88792
  case "0-1": return option$3(linkArbitrary, {
89789
88793
  nil: void 0,
89790
88794
  depthIdentifier: currentEntityDepth
89791
- }).generate(mrng, biasFactor).value;
89792
- case "1": return linkArbitrary.generate(mrng, biasFactor).value;
88795
+ });
88796
+ case "1": return linkArbitrary;
89793
88797
  case "many": {
89794
88798
  let randomUnicity = 0;
89795
- const values = option$3(uniqueArray(linkArbitrary, {
88799
+ return option$3(uniqueArray(linkArbitrary, {
89796
88800
  depthIdentifier: currentEntityDepth,
89797
88801
  selector: (v) => v === countInTargetType ? v + ++randomUnicity : v,
89798
88802
  minLength: 1
89799
88803
  }), {
89800
88804
  nil: [],
89801
88805
  depthIdentifier: currentEntityDepth
89802
- }).generate(mrng, biasFactor).value;
89803
- let offset = 0;
89804
- return safeMap(values, (v) => v === countInTargetType ? v + offset++ : v);
88806
+ }).map((values) => {
88807
+ let offset = 0;
88808
+ return safeMap(values, (v) => v === countInTargetType ? v + offset++ : v);
88809
+ });
89805
88810
  }
89806
88811
  }
89807
88812
  }
89808
88813
  /** @internal */
89809
- var OnTheFlyLinksForEntityGraphArbitrary = class extends Arbitrary {
89810
- constructor(relations, defaultEntities) {
89811
- super();
89812
- this.relations = relations;
89813
- this.defaultEntities = defaultEntities;
89814
- const nonExclusiveEntities = new SSet();
89815
- const exclusiveEntities = new SSet();
89816
- for (const name in relations) {
89817
- const relationsForName = relations[name];
89818
- for (const fieldName in relationsForName) {
89819
- const relation = relationsForName[fieldName];
89820
- if (relation.arity === "inverse") continue;
89821
- if (relation.strategy === "exclusive") {
89822
- if (safeHas(nonExclusiveEntities, relation.type)) throw new SError(`Cannot mix exclusive with other strategies for type ${SString(relation.type)}`);
89823
- safeAdd(exclusiveEntities, relation.type);
89824
- } else {
89825
- if (safeHas(exclusiveEntities, relation.type)) throw new SError(`Cannot mix exclusive with other strategies for type ${SString(relation.type)}`);
89826
- safeAdd(nonExclusiveEntities, relation.type);
89827
- }
89828
- if (relation.strategy === "successor" && relation.type !== name) throw new SError(`Cannot mix types for the strategy successor`);
89829
- if (relation.strategy === "successor" && relation.arity === "1") throw new SError(`Cannot use an arity of 1 for the strategy successor`);
88814
+ function createEmptyLinksInstanceFor(relations, targetType) {
88815
+ const emptyLinksInstance = safeObjectCreate$3(null);
88816
+ const relationsForType = relations[targetType];
88817
+ for (const name in relationsForType) {
88818
+ const relation = relationsForType[name];
88819
+ if (relation.arity === "inverse") emptyLinksInstance[name] = {
88820
+ type: relation.type,
88821
+ index: []
88822
+ };
88823
+ }
88824
+ return emptyLinksInstance;
88825
+ }
88826
+ /** @internal */
88827
+ function assertAcceptableRelations(relations) {
88828
+ const nonExclusiveEntities = new SSet();
88829
+ const exclusiveEntities = new SSet();
88830
+ for (const name in relations) {
88831
+ const relationsForName = relations[name];
88832
+ for (const fieldName in relationsForName) {
88833
+ const relation = relationsForName[fieldName];
88834
+ if (relation.arity === "inverse") continue;
88835
+ if (relation.strategy === "exclusive") {
88836
+ if (safeHas(nonExclusiveEntities, relation.type)) throw new SError(`Cannot mix exclusive with other strategies for type ${SString(relation.type)}`);
88837
+ safeAdd(exclusiveEntities, relation.type);
88838
+ } else {
88839
+ if (safeHas(exclusiveEntities, relation.type)) throw new SError(`Cannot mix exclusive with other strategies for type ${SString(relation.type)}`);
88840
+ safeAdd(nonExclusiveEntities, relation.type);
89830
88841
  }
88842
+ if (relation.strategy === "successor" && relation.type !== name) throw new SError(`Cannot mix types for the strategy successor`);
88843
+ if (relation.strategy === "successor" && relation.arity === "1") throw new SError(`Cannot use an arity of 1 for the strategy successor`);
89831
88844
  }
89832
- this.inversedRelations = buildInversedRelationsMapping(relations);
89833
88845
  }
89834
- createEmptyLinksInstanceFor(targetType) {
89835
- const emptyLinksInstance = safeObjectCreate$3(null);
89836
- const relationsForType = this.relations[targetType];
89837
- for (const name in relationsForType) {
89838
- const relation = relationsForType[name];
89839
- if (relation.arity === "inverse") emptyLinksInstance[name] = {
89840
- type: relation.type,
89841
- index: []
88846
+ }
88847
+ /** @internal */
88848
+ function draftNextProductionState(state, offset) {
88849
+ const { producedLinks, toBeProducedEntities } = state;
88850
+ const nextIndex = state.nextIndex + offset;
88851
+ const newProducedLinks = safeObjectAssign(safeObjectCreate$3(null), producedLinks);
88852
+ function getOrCreateProducedLinksFor(type) {
88853
+ if (newProducedLinks[type] === producedLinks[type]) newProducedLinks[type] = safeSlice(producedLinks[type]);
88854
+ return newProducedLinks[type];
88855
+ }
88856
+ function getOrCreateLinksFor(type, indexInType) {
88857
+ const producedLinksForType = getOrCreateProducedLinksFor(type);
88858
+ if (producedLinksForType[indexInType] === producedLinks[type][indexInType]) producedLinksForType[indexInType] = safeObjectAssign(safeObjectCreate$3(null), producedLinks[type][indexInType]);
88859
+ return producedLinksForType[indexInType];
88860
+ }
88861
+ function getOrCreateRelationFor(type, indexInType, property) {
88862
+ const links = getOrCreateLinksFor(type, indexInType);
88863
+ const originalEntity = producedLinks[type][indexInType];
88864
+ if (originalEntity !== void 0 && links[property] === originalEntity[property]) {
88865
+ const sharedRelation = links[property];
88866
+ links[property] = {
88867
+ type: sharedRelation.type,
88868
+ index: typeof sharedRelation.index === "object" ? safeSlice(sharedRelation.index) : sharedRelation.index
89842
88869
  };
89843
88870
  }
89844
- return emptyLinksInstance;
88871
+ return links[property];
89845
88872
  }
89846
- generate(mrng, biasFactor) {
89847
- const producedLinks = safeObjectCreate$3(null);
89848
- for (const name in this.relations) producedLinks[name] = [];
89849
- const toBeProducedEntities = [];
89850
- for (const name of this.defaultEntities) {
89851
- safePush(toBeProducedEntities, {
89852
- type: name,
89853
- indexInType: producedLinks[name].length,
89854
- depth: 0
88873
+ let newToBeProducedEntities = void 0;
88874
+ const toBeProduced = toBeProducedEntities[nextIndex];
88875
+ return {
88876
+ setOutboundLink: (name, value) => {
88877
+ const currentLinks = getOrCreateLinksFor(toBeProduced.type, toBeProduced.indexInType);
88878
+ currentLinks[name] = value;
88879
+ },
88880
+ enqueueNewEntity: (relations, targetType) => {
88881
+ const producedLinksInTargetType = getOrCreateProducedLinksFor(targetType);
88882
+ const newEntityIndexInType = producedLinksInTargetType.length;
88883
+ if (newToBeProducedEntities === void 0) newToBeProducedEntities = safeSlice(toBeProducedEntities);
88884
+ safePush(newToBeProducedEntities, {
88885
+ type: targetType,
88886
+ indexInType: newEntityIndexInType,
88887
+ depth: toBeProduced.depth + 1
89855
88888
  });
89856
- safePush(producedLinks[name], this.createEmptyLinksInstanceFor(name));
89857
- }
89858
- let lastTreatedEntities = -1;
89859
- while (++lastTreatedEntities < toBeProducedEntities.length) {
89860
- const currentEntity = toBeProducedEntities[lastTreatedEntities];
89861
- const currentRelations = this.relations[currentEntity.type];
89862
- const currentLinks = producedLinks[currentEntity.type][currentEntity.indexInType];
89863
- const currentEntityDepth = createDepthIdentifier();
89864
- currentEntityDepth.depth = currentEntity.depth;
89865
- for (const name in currentRelations) {
89866
- const relation = currentRelations[name];
89867
- if (relation.arity === "inverse") continue;
89868
- const targetType = relation.type;
89869
- const producedLinksInTargetType = producedLinks[targetType];
89870
- const countInTargetType = producedLinksInTargetType.length;
89871
- const linkOrLinks = computeLinkIndex(relation.arity, relation.strategy || "any", targetType === currentEntity.type ? currentEntity.indexInType : void 0, producedLinksInTargetType.length, currentEntityDepth, mrng, biasFactor);
89872
- currentLinks[name] = {
89873
- type: targetType,
89874
- index: linkOrLinks
89875
- };
89876
- const links = linkOrLinks === void 0 ? [] : typeof linkOrLinks === "number" ? [linkOrLinks] : linkOrLinks;
89877
- for (const link of links) {
89878
- if (link >= countInTargetType) {
89879
- safePush(toBeProducedEntities, {
89880
- type: targetType,
89881
- indexInType: link,
89882
- depth: currentEntity.depth + 1
89883
- });
89884
- safePush(producedLinksInTargetType, this.createEmptyLinksInstanceFor(targetType));
89885
- }
89886
- const inversed = safeMapGet(this.inversedRelations, relation);
89887
- if (inversed !== void 0) {
89888
- const knownInversedLinks = producedLinksInTargetType[link][inversed.property].index;
89889
- safePush(knownInversedLinks, currentEntity.indexInType);
89890
- }
89891
- }
89892
- }
89893
- }
89894
- toBeProducedEntities.length = 0;
89895
- return new Value(producedLinks, void 0);
89896
- }
89897
- canShrinkWithoutContext(_value) {
89898
- return false;
88889
+ safePush(producedLinksInTargetType, createEmptyLinksInstanceFor(relations, targetType));
88890
+ return newEntityIndexInType;
88891
+ },
88892
+ appendBackReference: (targetType, indexInType, property) => {
88893
+ const knownInversedLinks = getOrCreateRelationFor(targetType, indexInType, property).index;
88894
+ safePush(knownInversedLinks, toBeProduced.indexInType);
88895
+ },
88896
+ commit: () => ({
88897
+ producedLinks: newProducedLinks,
88898
+ toBeProducedEntities: newToBeProducedEntities !== void 0 ? newToBeProducedEntities : toBeProducedEntities,
88899
+ nextIndex: nextIndex + 1
88900
+ })
88901
+ };
88902
+ }
88903
+ /** @internal */
88904
+ function buildInitialProductionState(relations, defaultEntities) {
88905
+ const producedLinks = safeObjectCreate$3(null);
88906
+ for (const name in relations) producedLinks[name] = [];
88907
+ const toBeProducedEntities = [];
88908
+ for (const name of defaultEntities) {
88909
+ safePush(toBeProducedEntities, {
88910
+ type: name,
88911
+ indexInType: producedLinks[name].length,
88912
+ depth: 0
88913
+ });
88914
+ safePush(producedLinks[name], createEmptyLinksInstanceFor(relations, name));
89899
88915
  }
89900
- shrink(_value, _context) {
89901
- return Stream.nil();
88916
+ return {
88917
+ producedLinks,
88918
+ toBeProducedEntities,
88919
+ nextIndex: 0
88920
+ };
88921
+ }
88922
+ /** @internal */
88923
+ function buildEntityStepArbitrary(relations, inversedRelations, lastState, offset) {
88924
+ const lastProducedLinks = lastState.producedLinks;
88925
+ const currentEntity = lastState.toBeProducedEntities[lastState.nextIndex + offset];
88926
+ const currentRelations = relations[currentEntity.type];
88927
+ const currentEntityDepth = createDepthIdentifier();
88928
+ currentEntityDepth.depth = currentEntity.depth;
88929
+ const subArbitraries = [];
88930
+ const linkContexts = [];
88931
+ for (const name in currentRelations) {
88932
+ const relation = currentRelations[name];
88933
+ if (relation.arity === "inverse") continue;
88934
+ const targetType = relation.type;
88935
+ const countInTargetType = lastProducedLinks[targetType].length;
88936
+ safePush(subArbitraries, buildLinkIndexArbitrary(relation.arity, relation.strategy || "any", targetType === currentEntity.type ? currentEntity.indexInType : void 0, countInTargetType, currentEntityDepth));
88937
+ safePush(linkContexts, {
88938
+ name,
88939
+ relation,
88940
+ sentinelLinkIndex: countInTargetType
88941
+ });
89902
88942
  }
89903
- };
88943
+ if (subArbitraries.length === 0) return;
88944
+ return tuple(...subArbitraries).map((results) => {
88945
+ const state = draftNextProductionState(lastState, offset);
88946
+ for (let resultIndex = 0; resultIndex !== results.length; ++resultIndex) {
88947
+ const linkOrLinks = results[resultIndex];
88948
+ const { name, relation, sentinelLinkIndex } = linkContexts[resultIndex];
88949
+ const effectiveLinks = [];
88950
+ const links = linkOrLinks === void 0 ? [] : typeof linkOrLinks === "number" ? [linkOrLinks] : linkOrLinks;
88951
+ for (const link of links) {
88952
+ let newEntityIndexInType;
88953
+ if (link >= sentinelLinkIndex) newEntityIndexInType = state.enqueueNewEntity(relations, relation.type);
88954
+ else newEntityIndexInType = link;
88955
+ safePush(effectiveLinks, newEntityIndexInType);
88956
+ const inversed = safeMapGet(inversedRelations, relation);
88957
+ if (inversed !== void 0) state.appendBackReference(relation.type, newEntityIndexInType, inversed.property);
88958
+ }
88959
+ state.setOutboundLink(name, {
88960
+ type: relation.type,
88961
+ index: linkOrLinks === void 0 ? void 0 : typeof linkOrLinks === "number" ? effectiveLinks[0] : effectiveLinks
88962
+ });
88963
+ }
88964
+ return state.commit();
88965
+ });
88966
+ }
89904
88967
  /** @internal */
89905
88968
  function onTheFlyLinksForEntityGraph(relations, defaultEntities) {
89906
- return new OnTheFlyLinksForEntityGraphArbitrary(relations, defaultEntities);
88969
+ assertAcceptableRelations(relations);
88970
+ const inversedRelations = buildInversedRelationsMapping(relations);
88971
+ return chainUntil(constant(buildInitialProductionState(relations, defaultEntities)), (state) => {
88972
+ if (state.nextIndex >= state.toBeProducedEntities.length) return;
88973
+ let offset = 0;
88974
+ let next = void 0;
88975
+ while (next === void 0 && state.nextIndex + offset < state.toBeProducedEntities.length) {
88976
+ next = buildEntityStepArbitrary(relations, inversedRelations, state, offset);
88977
+ offset += 1;
88978
+ }
88979
+ return next;
88980
+ }).map((state) => {
88981
+ return state.producedLinks;
88982
+ });
89907
88983
  }
89908
88984
  var safeObjectKeys$1 = Object.keys;
89909
88985
  var safeObjectGetOwnPropertySymbols$1 = Object.getOwnPropertySymbols;
@@ -89927,15 +89003,19 @@ var safeObjectGetOwnPropertySymbols = Object.getOwnPropertySymbols;
89927
89003
  /** @internal */
89928
89004
  function buildValuesAndSeparateKeysToObjectMapper(keys, noKeyValue) {
89929
89005
  return function valuesAndSeparateKeysToObjectMapper(definition) {
89930
- const obj = definition[1] ? safeObjectCreate$2(null) : {};
89006
+ const obj = definition[definition.length - 1] ? safeObjectCreate$2(null) : {};
89931
89007
  for (let idx = 0; idx !== keys.length; ++idx) {
89932
- const valueWrapper = definition[0][idx];
89933
- if (valueWrapper !== noKeyValue) safeObjectDefineProperty(obj, keys[idx], {
89934
- value: valueWrapper,
89935
- configurable: true,
89936
- enumerable: true,
89937
- writable: true
89938
- });
89008
+ const valueWrapper = definition[idx];
89009
+ if (valueWrapper !== noKeyValue) {
89010
+ const key = keys[idx];
89011
+ if (key === "__proto__") safeObjectDefineProperty(obj, key, {
89012
+ value: valueWrapper,
89013
+ configurable: true,
89014
+ enumerable: true,
89015
+ writable: true
89016
+ });
89017
+ else obj[key] = valueWrapper;
89018
+ }
89939
89019
  }
89940
89020
  return obj;
89941
89021
  };
@@ -89961,7 +89041,7 @@ function buildValuesAndSeparateKeysToObjectUnmapper(keys, noKeyValue) {
89961
89041
  const namePropertiesCount = safeObjectGetOwnPropertyNames(value).length;
89962
89042
  const symbolPropertiesCount = safeObjectGetOwnPropertySymbols(value).length;
89963
89043
  if (extractedPropertiesCount !== namePropertiesCount + symbolPropertiesCount) throw new Error("Incompatible instance received: should not contain extra properties");
89964
- return [extractedValues, hasNullPrototype];
89044
+ return [...extractedValues, hasNullPrototype];
89965
89045
  };
89966
89046
  }
89967
89047
  var noKeyValue = Symbol("no-key");
@@ -89975,7 +89055,7 @@ function buildPartialRecordArbitrary(recordModel, requiredKeys, noNullPrototype)
89975
89055
  if (requiredKeys === void 0 || safeIndexOf(requiredKeys, k) !== -1) safePush(arbs, requiredArbitrary);
89976
89056
  else safePush(arbs, option$3(requiredArbitrary, { nil: noKeyValue }));
89977
89057
  }
89978
- return tuple(tuple(...arbs), noNullPrototype ? constant(false) : boolean$3()).map(buildValuesAndSeparateKeysToObjectMapper(keys, noKeyValue), buildValuesAndSeparateKeysToObjectUnmapper(keys, noKeyValue));
89058
+ return tuple(...arbs, noNullPrototype ? constant(false) : boolean$3()).map(buildValuesAndSeparateKeysToObjectMapper(keys, noKeyValue), buildValuesAndSeparateKeysToObjectUnmapper(keys, noKeyValue));
89979
89059
  }
89980
89060
  function record$1(recordModel, constraints) {
89981
89061
  const noNullPrototype = constraints !== void 0 && !!constraints.noNullPrototype;
@@ -91388,7 +90468,9 @@ function webSegment(constraints = {}) {
91388
90468
  }
91389
90469
  /** @internal */
91390
90470
  function segmentsToPathMapper(segments) {
91391
- return safeJoin(safeMap(segments, (v) => `/${v}`), "");
90471
+ let path = "";
90472
+ for (let index = 0; index !== segments.length; ++index) path += "/" + segments[index];
90473
+ return path;
91392
90474
  }
91393
90475
  /** @internal */
91394
90476
  function segmentsToPathUnmapper(value) {
@@ -93379,6 +92461,11 @@ var spaceChars = [..." \r\n\v\f"];
93379
92461
  var newLineChars = [..."\r\n"];
93380
92462
  var terminatorChars = [...""];
93381
92463
  var newLineAndTerminatorChars = [...newLineChars, ...terminatorChars];
92464
+ var wordCharsSet = new SSet(wordChars);
92465
+ var digitCharsSet = new SSet(digitChars);
92466
+ var spaceCharsSet = new SSet(spaceChars);
92467
+ var terminatorCharsSet = new SSet(terminatorChars);
92468
+ var newLineAndTerminatorCharsSet = new SSet(newLineAndTerminatorChars);
93382
92469
  var defaultChar = () => string$4({
93383
92470
  unit: "grapheme-ascii",
93384
92471
  minLength: 1,
@@ -93396,16 +92483,16 @@ function toMatchingArbitrary(astNode, constraints, flags) {
93396
92483
  case "Char":
93397
92484
  if (astNode.kind === "meta") switch (astNode.value) {
93398
92485
  case "\\w": return constantFrom(...wordChars);
93399
- case "\\W": return defaultChar().filter((c) => safeIndexOf(wordChars, c) === -1);
92486
+ case "\\W": return defaultChar().filter((c) => !safeHas(wordCharsSet, c));
93400
92487
  case "\\d": return constantFrom(...digitChars);
93401
- case "\\D": return defaultChar().filter((c) => safeIndexOf(digitChars, c) === -1);
92488
+ case "\\D": return defaultChar().filter((c) => !safeHas(digitCharsSet, c));
93402
92489
  case "\\s": return constantFrom(...spaceChars);
93403
- case "\\S": return defaultChar().filter((c) => safeIndexOf(spaceChars, c) === -1);
92490
+ case "\\S": return defaultChar().filter((c) => !safeHas(spaceCharsSet, c));
93404
92491
  case "\\b":
93405
92492
  case "\\B": throw new SError(`Meta character ${astNode.value} not implemented yet!`);
93406
92493
  case ".": {
93407
- const forbiddenChars = flags.dotAll ? terminatorChars : newLineAndTerminatorChars;
93408
- return defaultChar().filter((c) => safeIndexOf(forbiddenChars, c) === -1);
92494
+ const forbiddenChars = flags.dotAll ? terminatorCharsSet : newLineAndTerminatorCharsSet;
92495
+ return defaultChar().filter((c) => !safeHas(forbiddenChars, c));
93409
92496
  }
93410
92497
  }
93411
92498
  if (astNode.symbol === void 0) throw new SError(`Unexpected undefined symbol received for non-meta Char! Received: ${stringify$2(astNode)}`);
@@ -93438,7 +92525,22 @@ function toMatchingArbitrary(astNode, constraints, flags) {
93438
92525
  }
93439
92526
  }
93440
92527
  case "Quantifier": throw new SError(`Wrongly defined AST tree, Quantifier nodes not supposed to be scanned!`);
93441
- case "Alternative": return tuple(...safeMap(astNode.expressions, (n) => toMatchingArbitrary(n, constraints, flags))).map((vs) => safeJoin(vs, ""));
92528
+ case "Alternative": {
92529
+ const childrenArbitraries = [];
92530
+ let pendingAggregatedValue = "";
92531
+ for (const n of astNode.expressions) if (n.type === "Char" && n.kind !== "meta" && n.symbol !== void 0) pendingAggregatedValue += n.symbol;
92532
+ else if (flags.multiline || n.type !== "Assertion" || n.kind !== "^" && n.kind !== "$") {
92533
+ if (pendingAggregatedValue !== "") {
92534
+ safePush(childrenArbitraries, constant(pendingAggregatedValue));
92535
+ pendingAggregatedValue = "";
92536
+ }
92537
+ safePush(childrenArbitraries, toMatchingArbitrary(n, constraints, flags));
92538
+ }
92539
+ if (pendingAggregatedValue !== "") safePush(childrenArbitraries, constant(pendingAggregatedValue));
92540
+ if (childrenArbitraries.length === 0) return constant("");
92541
+ if (childrenArbitraries.length === 1) return childrenArbitraries[0];
92542
+ return tuple(...childrenArbitraries).map((vs) => safeJoin(vs, ""));
92543
+ }
93442
92544
  case "CharacterClass":
93443
92545
  if (astNode.negative) {
93444
92546
  const childrenArbitraries = safeMap(astNode.expressions, (n) => toMatchingArbitrary(n, constraints, flags));
@@ -93458,7 +92560,19 @@ function toMatchingArbitrary(astNode, constraints, flags) {
93458
92560
  });
93459
92561
  }
93460
92562
  case "Group": return toMatchingArbitrary(astNode.expression, constraints, flags);
93461
- case "Disjunction": return oneof(astNode.left !== null ? toMatchingArbitrary(astNode.left, constraints, flags) : constant(""), astNode.right !== null ? toMatchingArbitrary(astNode.right, constraints, flags) : constant(""));
92563
+ case "Disjunction": {
92564
+ const stack = [astNode.left, astNode.right];
92565
+ const branches = [];
92566
+ for (let i = 0; i !== stack.length; ++i) {
92567
+ const node = stack[i];
92568
+ if (node === null) safePush(branches, constant(""));
92569
+ else if (node.type === "Disjunction") {
92570
+ safePush(stack, node.left);
92571
+ safePush(stack, node.right);
92572
+ } else safePush(branches, toMatchingArbitrary(node, constraints, flags));
92573
+ }
92574
+ return oneof(...branches);
92575
+ }
93462
92576
  case "Assertion":
93463
92577
  if (astNode.kind === "^" || astNode.kind === "$") {
93464
92578
  if (flags.multiline) if (astNode.kind === "^") return oneof(constant(""), tuple(string$4({ unit: defaultChar() }), constantFrom(...newLineChars)).map((t) => `${t[0]}${t[1]}`, (value) => {
@@ -93598,17 +92712,17 @@ function limitShrink(arbitrary, maxShrinks) {
93598
92712
  */
93599
92713
  var __type = "module";
93600
92714
  /**
93601
- * Version of fast-check used by your project (eg.: "4.8.0")
92715
+ * Version of fast-check used by your project (eg.: "4.9.0")
93602
92716
  * @remarks Since 1.22.0
93603
92717
  * @public
93604
92718
  */
93605
- var __version = "4.8.0";
92719
+ var __version = "4.9.0";
93606
92720
  /**
93607
- * Commit hash of the current code (eg.: "c0da76fbcf6470339ad7bb2f0dfcebee06ede56c")
92721
+ * Commit hash of the current code (eg.: "0d3c2547dce556f72413607849377530d18ea283")
93608
92722
  * @remarks Since 2.7.0
93609
92723
  * @public
93610
92724
  */
93611
- var __commitHash = "c0da76fbcf6470339ad7bb2f0dfcebee06ede56c";
92725
+ var __commitHash = "0d3c2547dce556f72413607849377530d18ea283";
93612
92726
  //#endregion
93613
92727
  //#region ../../node_modules/effect/dist/testing/FastCheck.js
93614
92728
  var FastCheck_exports = /* @__PURE__ */ __exportAll({
@@ -93757,6 +92871,7 @@ var Schema_exports = /* @__PURE__ */ __exportAll({
93757
92871
  Chunk: () => Chunk,
93758
92872
  Class: () => Class,
93759
92873
  Date: () => Date$1,
92874
+ DateFromMillis: () => DateFromMillis,
93760
92875
  DateFromString: () => DateFromString,
93761
92876
  DateTimeUtc: () => DateTimeUtc,
93762
92877
  DateTimeUtcFromDate: () => DateTimeUtcFromDate,
@@ -99647,6 +98762,8 @@ var DateString = /*#__PURE__*/ String$1.annotate({ expected: "a string in ISO 86
99647
98762
  * ```
99648
98763
  *
99649
98764
  * @see {@link DateValid} for accepting only valid Date instances
98765
+ * @see {@link DateFromString} for decoding strings into Date instances
98766
+ * @see {@link DateFromMillis} for decoding epoch milliseconds into Date instances
99650
98767
  *
99651
98768
  * @category Date
99652
98769
  * @since 4.0.0
@@ -99682,6 +98799,8 @@ var Date$1 = /*#__PURE__*/ instanceOf$2(globalThis.Date, {
99682
98799
  *
99683
98800
  * Invalid date strings can decode to invalid `Date` instances.
99684
98801
  *
98802
+ * @see {@link DateFromMillis} for decoding epoch milliseconds into Date instances
98803
+ * @see {@link DateTimeUtcFromString} for decoding date-time strings into UTC values
99685
98804
  * @see {@link Date} for accepting Date instances directly
99686
98805
  * @see {@link DateValid} for rejecting invalid Date instances
99687
98806
  *
@@ -99690,6 +98809,34 @@ var Date$1 = /*#__PURE__*/ instanceOf$2(globalThis.Date, {
99690
98809
  */
99691
98810
  var DateFromString = /*#__PURE__*/ DateString.pipe(/*#__PURE__*/ decodeTo(Date$1, dateFromString));
99692
98811
  /**
98812
+ * Schema that decodes epoch milliseconds into a JavaScript `Date`.
98813
+ *
98814
+ * **When to use**
98815
+ *
98816
+ * Use to model numeric millisecond timestamps that decode to JavaScript `Date`
98817
+ * objects and encode back to numbers.
98818
+ *
98819
+ * **Details**
98820
+ *
98821
+ * Decoding:
98822
+ * A number of milliseconds since the Unix epoch is decoded as a `Date`.
98823
+ *
98824
+ * Encoding:
98825
+ * A `Date` is encoded as its millisecond timestamp.
98826
+ *
98827
+ * **Gotchas**
98828
+ *
98829
+ * This schema accepts any number, including `NaN`, `Infinity`, and `-Infinity`.
98830
+ * Those values decode to invalid `Date` instances.
98831
+ *
98832
+ * @see {@link DateFromString} for decoding string-encoded dates
98833
+ * @see {@link DateTimeUtcFromMillis} for decoding epoch milliseconds into UTC values
98834
+ *
98835
+ * @category Date
98836
+ * @since 4.0.0
98837
+ */
98838
+ var DateFromMillis = /*#__PURE__*/ Number$1.pipe(/*#__PURE__*/ decodeTo(Date$1, dateFromMillis));
98839
+ /**
99693
98840
  * Schema for **valid** JavaScript `Date` objects.
99694
98841
  *
99695
98842
  * **Details**
@@ -100701,6 +99848,10 @@ var DateTimeUtcFromDate = /*#__PURE__*/ DateValid.pipe(/*#__PURE__*/ decodeTo(Da
100701
99848
  *
100702
99849
  * - A `DateTime.Utc` is encoded as a UTC ISO 8601 string.
100703
99850
  *
99851
+ * @see {@link DateTimeUtcFromDate} for decoding JavaScript Date values into UTC values
99852
+ * @see {@link DateTimeUtcFromMillis} for decoding epoch milliseconds into UTC values
99853
+ * @see {@link DateFromString} for decoding strings into JavaScript Date instances
99854
+ *
100704
99855
  * @category DateTime
100705
99856
  * @since 4.0.0
100706
99857
  */
@@ -100716,6 +99867,10 @@ var DateTimeUtcFromString = /*#__PURE__*/ String$1.annotate({ expected: "a strin
100716
99867
  * Encoding:
100717
99868
  * - A `DateTime.Utc` is encoded as a number of milliseconds since the Unix epoch.
100718
99869
  *
99870
+ * @see {@link DateTimeUtcFromDate} for decoding JavaScript Date values into UTC values
99871
+ * @see {@link DateTimeUtcFromString} for decoding date-time strings into UTC values
99872
+ * @see {@link DateFromMillis} for decoding epoch milliseconds into JavaScript Date instances
99873
+ *
100719
99874
  * @category DateTime
100720
99875
  * @since 4.0.0
100721
99876
  */
@@ -105362,7 +104517,7 @@ var fromAsyncIterable = (iterable, onError) => fromChannel(fromAsyncIterableArra
105362
104517
  *
105363
104518
  * const program = Effect.gen(function*() {
105364
104519
  * const schedule = Schedule.spaced("50 millis").pipe(
105365
- * Schedule.both(Schedule.recurs(2))
104520
+ * Schedule.upTo({ times: 3 })
105366
104521
  * )
105367
104522
  * const stream = Stream.fromSchedule(schedule)
105368
104523
  * const values = yield* Stream.runCollect(stream)
@@ -112378,6 +111533,9 @@ var makeNoop = (fileSystem) => FileSystem.of({
112378
111533
  copyFile(path) {
112379
111534
  return fail$8(notFound("copyFile", path));
112380
111535
  },
111536
+ glob(pattern) {
111537
+ return fail$8(notFound("glob", pattern));
111538
+ },
112381
111539
  exists() {
112382
111540
  return succeed$6(false);
112383
111541
  },
@@ -113595,6 +112753,16 @@ var layerAdd = (self, options) => effect(ConfigProvider)(gen$1(function* () {
113595
112753
  * Primitive values (`number`, `boolean`, `bigint`) are stringified via
113596
112754
  * `String(...)`.
113597
112755
  *
112756
+ * Literal empty strings are treated as missing values when loaded as values by
112757
+ * default. Pass `{ preserveEmptyStrings: true }` to keep empty strings as
112758
+ * explicit values.
112759
+ *
112760
+ * **Gotchas**
112761
+ *
112762
+ * Object keys and array lengths reflect the original input shape. A leaf value
112763
+ * of `""` is treated as missing when that leaf is loaded, but the parent
112764
+ * container still reports its original keys or length.
112765
+ *
113598
112766
  * **Example** (Providing config from a plain object)
113599
112767
  *
113600
112768
  * ```ts
@@ -113620,10 +112788,11 @@ var layerAdd = (self, options) => effect(ConfigProvider)(gen$1(function* () {
113620
112788
  * @category ConfigProviders
113621
112789
  * @since 4.0.0
113622
112790
  */
113623
- function fromUnknown(root) {
113624
- return make$32((path) => succeed$6(nodeAtJson(root, path)));
112791
+ function fromUnknown(root, options) {
112792
+ const preserveEmptyStrings = options?.preserveEmptyStrings === true;
112793
+ return make$32((path) => succeed$6(nodeAtJson(root, path, preserveEmptyStrings)));
113625
112794
  }
113626
- function nodeAtJson(root, path) {
112795
+ function nodeAtJson(root, path, preserveEmptyStrings) {
113627
112796
  let cur = root;
113628
112797
  for (const seg of path) {
113629
112798
  if (cur === null || cur === void 0) return void 0;
@@ -113640,16 +112809,23 @@ function nodeAtJson(root, path) {
113640
112809
  }
113641
112810
  return;
113642
112811
  }
113643
- return describeUnknown(cur);
112812
+ return describeUnknown(cur, preserveEmptyStrings);
113644
112813
  }
113645
- function describeUnknown(u) {
112814
+ function describeUnknown(u, preserveEmptyStrings) {
113646
112815
  if (u === void 0 || u === null) return void 0;
113647
- if (typeof u === "string") return makeValue(u);
112816
+ if (typeof u === "string") return stringNode(u, preserveEmptyStrings);
113648
112817
  if (typeof u === "number" || typeof u === "boolean" || typeof u === "bigint") return makeValue(String(u));
113649
112818
  if (Array.isArray(u)) return makeArray(u.length);
113650
112819
  if (isObject(u)) return makeRecord(new Set(Object.keys(u)));
113651
112820
  return makeValue(format$5(u));
113652
112821
  }
112822
+ function stringNode(value, preserveEmptyStrings) {
112823
+ const normalized = emptyStringAsMissing(value, preserveEmptyStrings);
112824
+ return normalized === void 0 ? void 0 : makeValue(normalized);
112825
+ }
112826
+ function emptyStringAsMissing(value, preserveEmptyStrings) {
112827
+ return value === "" && !preserveEmptyStrings ? void 0 : value;
112828
+ }
113653
112829
  /**
113654
112830
  * Creates a `ConfigProvider` backed by environment variables.
113655
112831
  *
@@ -113671,6 +112847,11 @@ function describeUnknown(u) {
113671
112847
  * The default environment merges `process.env` and `import.meta.env` (when
113672
112848
  * available). Override by passing `{ env: { ... } }`.
113673
112849
  *
112850
+ * Literal empty strings are treated as missing values when loaded as values by
112851
+ * default. Pass `{ preserveEmptyStrings: true }` to keep empty strings as
112852
+ * explicit values. Child discovery still reflects the environment variable
112853
+ * names present in the source.
112854
+ *
113674
112855
  * Never fails with `SourceError` — all lookups are synchronous.
113675
112856
  *
113676
112857
  * **Example** (Reading from a custom env record)
@@ -113707,26 +112888,26 @@ function fromEnv(options) {
113707
112888
  "PROD": true,
113708
112889
  "SSR": false
113709
112890
  };
112891
+ const preserveEmptyStrings = options?.preserveEmptyStrings === true;
113710
112892
  const trie = buildEnvTrie(env);
113711
- return make$32((path) => succeed$6(nodeAtEnv(trie, env, path)));
112893
+ return make$32((path) => succeed$6(nodeAtEnv(trie, env, path, preserveEmptyStrings)));
113712
112894
  }
113713
112895
  function buildEnvTrie(env) {
113714
- const root = {};
112896
+ const trie = {};
113715
112897
  for (const [name, value] of Object.entries(env)) {
113716
112898
  if (value === void 0) continue;
113717
112899
  const segments = name.split("_");
113718
- let node = root;
112900
+ let node = trie;
113719
112901
  for (const seg of segments) {
113720
112902
  node.children ??= {};
113721
112903
  node = node.children[seg] ??= {};
113722
112904
  }
113723
- node.value = value;
113724
112905
  }
113725
- return root;
112906
+ return trie;
113726
112907
  }
113727
112908
  var NUMERIC_INDEX = /^(0|[1-9][0-9]*)$/;
113728
- function nodeAtEnv(trie, env, path) {
113729
- const leafValue = env[path.map(String).join("_")];
112909
+ function nodeAtEnv(trie, env, path, preserveEmptyStrings) {
112910
+ const leafValue = emptyStringAsMissing(env[path.map(String).join("_")], preserveEmptyStrings);
113730
112911
  const trieNode = trieNodeAt(trie, path);
113731
112912
  const children = trieNode?.children ? Object.keys(trieNode.children) : [];
113732
112913
  if (children.length === 0) return leafValue === void 0 ? void 0 : makeValue(leafValue);
@@ -113756,6 +112937,11 @@ function trieNodeAt(root, path) {
113756
112937
  * and escaped newlines. Variable expansion (for example, `${VAR}`) is disabled
113757
112938
  * by default; enable with `{ expandVariables: true }`.
113758
112939
  *
112940
+ * Literal empty strings are treated as missing values when loaded as values by
112941
+ * default. Pass `{ preserveEmptyStrings: true }` to keep empty strings as
112942
+ * explicit values. Child discovery still reflects the keys present in the
112943
+ * parsed `.env` source.
112944
+ *
113759
112945
  * Parsing is based on the `dotenv` / `dotenv-expand` algorithm.
113760
112946
  *
113761
112947
  * Internally delegates to {@link fromEnv} with the parsed key-value pairs.
@@ -113783,7 +112969,10 @@ function trieNodeAt(root, path) {
113783
112969
  function fromDotEnvContents(lines, options) {
113784
112970
  let env = parseDotEnvContents(lines);
113785
112971
  if (options?.expandVariables) env = dotEnvExpand(env);
113786
- return fromEnv({ env });
112972
+ return fromEnv({
112973
+ env,
112974
+ preserveEmptyStrings: options?.preserveEmptyStrings
112975
+ });
113787
112976
  }
113788
112977
  var DOT_ENV_LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
113789
112978
  function parseDotEnvContents(lines) {
@@ -113806,16 +112995,16 @@ function parseDotEnvContents(lines) {
113806
112995
  }
113807
112996
  function dotEnvExpand(parsed) {
113808
112997
  const newParsed = {};
113809
- for (const configKey in parsed) newParsed[configKey] = interpolate(parsed[configKey], parsed).replace(/\\\$/g, "$");
112998
+ for (const configKey in parsed) newParsed[configKey] = interpolate$1(parsed[configKey], parsed).replace(/\\\$/g, "$");
113810
112999
  return newParsed;
113811
113000
  }
113812
- function interpolate(envValue, parsed) {
113001
+ function interpolate$1(envValue, parsed) {
113813
113002
  const lastUnescapedDollarSignIndex = searchLast(envValue, /(?!(?<=\\))\$/g);
113814
113003
  if (lastUnescapedDollarSignIndex === -1) return envValue;
113815
113004
  const match = envValue.slice(lastUnescapedDollarSignIndex).match(/((?!(?<=\\))\${?([\w]+)(?::-([^}\\]*))?}?)/);
113816
113005
  if (match !== null) {
113817
113006
  const [_, group, variableName, defaultValue] = match;
113818
- return interpolate(envValue.replace(group, defaultValue || parsed[variableName] || ""), parsed);
113007
+ return interpolate$1(envValue.replace(group, defaultValue || parsed[variableName] || ""), parsed);
113819
113008
  }
113820
113009
  return envValue;
113821
113010
  }
@@ -113835,6 +113024,13 @@ function searchLast(str, rgx) {
113835
113024
  *
113836
113025
  * Requires `FileSystem` in the Effect context. Defaults to reading `".env"` in
113837
113026
  * the current directory; override with `{ path: "/custom/.env" }`.
113027
+ * Variable expansion (for example, `${VAR}`) is disabled by default; enable
113028
+ * with `{ expandVariables: true }`.
113029
+ *
113030
+ * Literal empty strings are treated as missing values when loaded as values by
113031
+ * default. Pass `{ preserveEmptyStrings: true }` to keep empty strings as
113032
+ * explicit values. Child discovery still reflects the keys present in the
113033
+ * parsed `.env` source.
113838
113034
  *
113839
113035
  * Returns an `Effect` that resolves to a `ConfigProvider`. Fails with a
113840
113036
  * `PlatformError` if the file cannot be read.
@@ -113853,11 +113049,11 @@ function searchLast(str, rgx) {
113853
113049
  * @see {@link fromDotEnvContents} – parse a `.env` string directly
113854
113050
  * @see {@link fromEnv} – read from the runtime environment
113855
113051
  *
113856
- * @category constructors
113052
+ * @category ConfigProviders
113857
113053
  * @since 4.0.0
113858
113054
  */
113859
113055
  var fromDotEnv = /*#__PURE__*/ fnUntraced(function* (options) {
113860
- return fromEnv({ env: parseDotEnvContents(yield* (yield* FileSystem).readFileString(options?.path ?? ".env")) });
113056
+ return fromDotEnvContents(yield* (yield* FileSystem).readFileString(options?.path ?? ".env"), options);
113861
113057
  });
113862
113058
  /**
113863
113059
  * Creates a `ConfigProvider` that reads configuration from a directory tree
@@ -113870,15 +113066,20 @@ var fromDotEnv = /*#__PURE__*/ fnUntraced(function* (options) {
113870
113066
  *
113871
113067
  * **Details**
113872
113068
  *
113873
- * Resolution tries a regular file first and returns a `Value` node with
113874
- * trimmed file contents. If the file read fails, it tries a directory and
113875
- * returns a `Record` node with immediate child names as keys. If both fail with
113876
- * `NotFound`, it returns `undefined`. Other platform failures return
113069
+ * Resolution tries a regular file first and returns a `Value` node for
113070
+ * non-empty trimmed file contents. If the file read fails, it tries a directory
113071
+ * and returns a `Record` node with immediate child names as keys. If both fail
113072
+ * with `NotFound`, it returns `undefined`. Other platform failures return
113877
113073
  * `SourceError`.
113878
113074
  *
113879
113075
  * Requires `Path` and `FileSystem` in the Effect context. Defaults to root
113880
113076
  * path `/`; override with `{ rootPath: "/etc/config" }`.
113881
113077
  *
113078
+ * Literal empty strings are treated as missing values by default after file
113079
+ * contents are trimmed. Pass `{ preserveEmptyStrings: true }` to keep empty
113080
+ * strings as explicit values. Directory listings still reflect the file names
113081
+ * present on disk.
113082
+ *
113882
113083
  * **Example** (Reading config from a directory)
113883
113084
  *
113884
113085
  * ```ts
@@ -113902,9 +113103,10 @@ var fromDir = /*#__PURE__*/ fnUntraced(function* (options) {
113902
113103
  const platformPath = yield* Path;
113903
113104
  const fs = yield* FileSystem;
113904
113105
  const rootPath = options?.rootPath ?? "/";
113106
+ const preserveEmptyStrings = options?.preserveEmptyStrings === true;
113905
113107
  return make$32((path) => {
113906
113108
  const fullPath = platformPath.join(rootPath, ...path.map(String));
113907
- const asFile = fs.readFileString(fullPath).pipe(map$19((content) => makeValue(content.trim())));
113109
+ const asFile = fs.readFileString(fullPath).pipe(map$19((content) => stringNode(content.trim(), preserveEmptyStrings)));
113908
113110
  const asDirectory = fs.readDirectory(fullPath).pipe(map$19((entries) => makeRecord(new Set(entries.map((entry) => platformPath.basename(entry))))));
113909
113111
  return asFile.pipe(catch_$3((fileCause) => asDirectory.pipe(catch_$3((dirCause) => isNotFound(fileCause) && isNotFound(dirCause) ? succeed$6(void 0) : fail$8(isNotFound(fileCause) ? dirCause : fileCause)))), mapError$3((cause) => new SourceError({
113910
113112
  message: `Failed to read file at ${platformPath.join(rootPath, ...path.map(String))}`,
@@ -121645,7 +120847,7 @@ var TypeId$24 = "~effect/LayerMap";
121645
120847
  */
121646
120848
  var make$24 = /*#__PURE__*/ fnUntraced(function* (lookup, options) {
121647
120849
  const context = yield* context$1();
121648
- const memoMap = CurrentMemoMap.getOrCreate(context);
120850
+ const memoMap = CurrentMemoMap.forkOrCreate(context);
121649
120851
  const rcMap = yield* make$37({
121650
120852
  lookup: (key) => contextWith$1((_) => buildWithMemoMap(lookup(key), memoMap, get$27(_, Scope))),
121651
120853
  idleTimeToLive: options?.idleTimeToLive
@@ -148029,7 +147231,7 @@ var makeTocWeft = (lineText, line, range) => TocWeftSchema.make({
148029
147231
  });
148030
147232
  //#endregion
148031
147233
  //#region ../loom-lang/src/ast/LoomFault.ts
148032
- var { UnclosedDelimiter, EmptyLabel, MalformedLabel, MissingWarpValue, UnresolvedAnchor, AmbiguousAnchor, CrossLanguageAnchor, UnresolvedTocEntry } = taggedEnum();
147234
+ var { UnclosedDelimiter, EmptyLabel, MalformedLabel, MissingWarpValue, UnknownVariable, UnresolvedAnchor, AmbiguousAnchor, CrossLanguageAnchor, UnresolvedTocEntry } = taggedEnum();
148033
147235
  var error = (message) => ({
148034
147236
  severity: "error",
148035
147237
  message
@@ -148049,7 +147251,7 @@ var rule = {
148049
147251
  warpName: "must be a TypeScript identifier",
148050
147252
  anchorName: "may not contain `]`"
148051
147253
  };
148052
- var describe = (fault) => value$1(fault).pipe(tag("UnclosedDelimiter", ({ expected }) => error(`expected closing \`${expected}\``)), tag("EmptyLabel", ({ construct }) => error(`${cap(noun[construct])} cannot be empty.`)), tag("MalformedLabel", ({ construct, value }) => error(`${cap(noun[construct])} ${rule[construct]}; got \`${value}\`.`)), tag("MissingWarpValue", ({ name }) => error(`Warp \`${name}\` has no value; a Warp binds a value, as in \`${name} = …\`.`)), tag("UnresolvedAnchor", ({ name }) => error(`Unresolved anchor: no section named \`${name}\`.`)), tag("AmbiguousAnchor", ({ name, count }) => error(`Ambiguous anchor: ${count} sections are named \`${name}\`. A name anchor resolves one local section; rename to disambiguate.`)), tag("CrossLanguageAnchor", ({ name, host, found }) => error(`Cross-language transclusion: \`${name}\` is ${found}, but this section composes ${host}. A section composes one language.`)), tag("UnresolvedTocEntry", ({ title }) => error(`Unresolved contents entry: no chapter titled \`${title}\`.`)), exhaustive);
147254
+ var describe = (fault) => value$1(fault).pipe(tag("UnclosedDelimiter", ({ expected }) => error(`expected closing \`${expected}\``)), tag("EmptyLabel", ({ construct }) => error(`${cap(noun[construct])} cannot be empty.`)), tag("MalformedLabel", ({ construct, value }) => error(`${cap(noun[construct])} ${rule[construct]}; got \`${value}\`.`)), tag("MissingWarpValue", ({ name }) => error(`Warp \`${name}\` has no value; a Warp binds a value, as in \`${name} = …\`.`)), tag("UnknownVariable", ({ name }) => error(`Unknown variable: no workspace variable named \`${name}\`. Declare it under \`variables:\` in the configuration.`)), tag("UnresolvedAnchor", ({ name }) => error(`Unresolved anchor: no section named \`${name}\`.`)), tag("AmbiguousAnchor", ({ name, count }) => error(`Ambiguous anchor: ${count} sections are named \`${name}\`. A name anchor resolves one local section; rename to disambiguate.`)), tag("CrossLanguageAnchor", ({ name, host, found }) => error(`Cross-language transclusion: \`${name}\` is ${found}, but this section composes ${host}. A section composes one language.`)), tag("UnresolvedTocEntry", ({ title }) => error(`Unresolved contents entry: no chapter titled \`${title}\`.`)), exhaustive);
148053
147255
  var statusOf = (severity) => severity === "info" ? "ok" : severity;
148054
147256
  var faulty = (fault, position) => {
148055
147257
  const note = describe(fault);
@@ -148088,6 +147290,12 @@ var tokeniseFrontmatter = (weft) => {
148088
147290
  if (colon < 0) return bareFrontmatter(weft);
148089
147291
  return buildFrontmatterField(weft, line, trimSpan(lineText.slice(0, colon), base), trimSpan(lineText.slice(colon + 1), base + colon + 1));
148090
147292
  };
147293
+ var frontmatterFields = /* @__PURE__ */ new Set([
147294
+ "Package",
147295
+ "Language",
147296
+ "Status",
147297
+ "Priority"
147298
+ ]);
148091
147299
  var buildFrontmatterField = (weft, line, key, value) => {
148092
147300
  if (key.value.startsWith("Part ") && key.value.includes(", Chapter ")) return belongingField(weft, line, key, value);
148093
147301
  if (key.value.startsWith("Part ")) return FrontmatterWeftSchema.make({
@@ -148097,6 +147305,12 @@ var buildFrontmatterField = (weft, line, key, value) => {
148097
147305
  part: ordinalToken(FrontmatterPartTokenSchema, line, key, "Part "),
148098
147306
  partName: fieldToken(FrontmatterPartNameTokenSchema, line, value)
148099
147307
  });
147308
+ if (key.value === "Part") return FrontmatterWeftSchema.make({
147309
+ position: weft.position,
147310
+ source: weft.source,
147311
+ health: okHealth,
147312
+ partName: fieldToken(FrontmatterPartNameTokenSchema, line, value)
147313
+ });
148100
147314
  if (key.value.startsWith("Chapter ")) return FrontmatterWeftSchema.make({
148101
147315
  position: weft.position,
148102
147316
  source: weft.source,
@@ -148104,7 +147318,13 @@ var buildFrontmatterField = (weft, line, key, value) => {
148104
147318
  chapter: ordinalToken(FrontmatterChapterTokenSchema, line, key, "Chapter "),
148105
147319
  title: fieldToken(FrontmatterTitleTokenSchema, line, value)
148106
147320
  });
148107
- if (key.value === "Package" || key.value === "Language") return FrontmatterWeftSchema.make({
147321
+ if (key.value === "Chapter") return FrontmatterWeftSchema.make({
147322
+ position: weft.position,
147323
+ source: weft.source,
147324
+ health: okHealth,
147325
+ title: fieldToken(FrontmatterTitleTokenSchema, line, value)
147326
+ });
147327
+ if (frontmatterFields.has(key.value)) return FrontmatterWeftSchema.make({
148108
147328
  position: weft.position,
148109
147329
  source: weft.source,
148110
147330
  health: okHealth,
@@ -148926,7 +148146,9 @@ var LoomFrontmatterSchema = loomNode("LoomFrontmatter", {
148926
148146
  chapter: optional(FrontmatterChapterTokenSchema),
148927
148147
  title: optional(FrontmatterTitleTokenSchema),
148928
148148
  package: optional(FrontmatterValueTokenSchema),
148929
- language: optional(FrontmatterValueTokenSchema)
148149
+ language: optional(FrontmatterValueTokenSchema),
148150
+ status: optional(FrontmatterValueTokenSchema),
148151
+ priority: optional(FrontmatterValueTokenSchema)
148930
148152
  });
148931
148153
  var LoomDocumentSchema = loomNode("LoomDocument", {
148932
148154
  frontmatter: optional(LoomFrontmatterSchema),
@@ -148935,7 +148157,7 @@ var LoomDocumentSchema = loomNode("LoomDocument", {
148935
148157
  });
148936
148158
  //#endregion
148937
148159
  //#region ../loom-lang/src/ast/LoomAstBuilder.ts
148938
- var LoomAstBuilder = class extends Service$1()("LoomAstBuilder", { make: succeed$6({ build: (source) => runCollect(source).pipe(map$19((wefts) => makeDocument(reduce$11(groupNodes(wefts), initialDocument, appendToDocument)))) }) }) {
148160
+ var LoomAstBuilder = class extends Service$1()("LoomAstBuilder", { make: succeed$6({ build: (source) => runCollect(source).pipe(map$19((wefts) => makeDocument(reduce$10(groupNodes(wefts), initialDocument, appendToDocument)))) }) }) {
148939
148161
  static {
148940
148162
  this.layer = effect(this, this.make);
148941
148163
  }
@@ -149004,14 +148226,14 @@ var spanFrom = (headingPos, ...groups) => {
149004
148226
  };
149005
148227
  var makeFrontmatter = (wefts) => {
149006
148228
  if (wefts.length === 0) return none$1();
149007
- const partFields = match$13(fromNullishOr$4(wefts.find((w) => w.part !== void 0)), {
148229
+ const partFields = match$13(fromNullishOr$4(wefts.find((w) => w.part !== void 0 || w.partName !== void 0)), {
149008
148230
  onNone: () => ({}),
149009
148231
  onSome: (w) => ({
149010
148232
  part: w.part,
149011
148233
  partName: w.partName
149012
148234
  })
149013
148235
  });
149014
- const chapterFields = match$13(fromNullishOr$4(wefts.find((w) => w.chapter !== void 0)), {
148236
+ const chapterFields = match$13(fromNullishOr$4(wefts.find((w) => w.chapter !== void 0 || w.title !== void 0)), {
149015
148237
  onNone: () => ({}),
149016
148238
  onSome: (w) => ({
149017
148239
  chapter: w.chapter,
@@ -149028,7 +148250,9 @@ var makeFrontmatter = (wefts) => {
149028
148250
  ...partFields,
149029
148251
  ...chapterFields,
149030
148252
  package: getOrUndefined$2(frontmatterField(wefts, "Package")),
149031
- language: getOrUndefined$2(frontmatterField(wefts, "Language"))
148253
+ language: getOrUndefined$2(frontmatterField(wefts, "Language")),
148254
+ status: getOrUndefined$2(frontmatterField(wefts, "Status")),
148255
+ priority: getOrUndefined$2(frontmatterField(wefts, "Priority"))
149032
148256
  }));
149033
148257
  };
149034
148258
  var frontmatterField = (wefts, key) => pipe(fromNullishOr$4(wefts.find((w) => w.key !== void 0 && w.key.value === key)), flatMapNullishOr$2((w) => w.value));
@@ -149138,17 +148362,17 @@ var ProductSchema = Struct({
149138
148362
  });
149139
148363
  //#endregion
149140
148364
  //#region ../loom-lang/src/ast/ProductBuilder.ts
149141
- var ProductBuilder = class extends Service$1()("ProductBuilder", { make: succeed$6({ build: (doc, path, packageLanguage) => sync$3(() => buildProduct(doc, path, packageLanguage)) }) }) {
148365
+ var ProductBuilder = class extends Service$1()("ProductBuilder", { make: succeed$6({ build: (doc, path, packageLanguage, variables = {}) => sync$3(() => buildProduct(doc, path, packageLanguage, variables)) }) }) {
149142
148366
  static {
149143
148367
  this.layer = effect(this, this.make);
149144
148368
  }
149145
148369
  };
149146
- var buildProduct = (doc, modulePath, packageLanguage) => {
148370
+ var buildProduct = (doc, modulePath, packageLanguage, variables = {}) => {
149147
148371
  const fm = fromNullishOr$4(doc.frontmatter);
149148
148372
  const pkg = pipe(fm, flatMapNullishOr$2((f) => f.package), map$29((p) => p.value));
149149
148373
  const lang = pipe(frontmatterLanguage(fm), orElse$6(() => fromNullishOr$4(packageLanguage)), getOrElse$2(() => "plaintext"));
149150
148374
  const index = nameIndex(doc.sections, lang, pkg);
149151
- return pipe(doc.sections, map$24(buildSection(index, lang, modulePath, pkg)), reduce$11(emptyProduct, appendSection));
148375
+ return pipe(doc.sections, map$24(buildSection(index, lang, modulePath, pkg, variables)), reduce$10(emptyProduct, appendSection));
149152
148376
  };
149153
148377
  var emptyProduct = ProductSchema.make({
149154
148378
  code: [],
@@ -149158,7 +148382,6 @@ var appendSection = (product, built) => ProductSchema.make({
149158
148382
  code: [...product.code, built.code],
149159
148383
  files: [...product.files, ...toArray$3(built.file)]
149160
148384
  });
149161
- var reservedLanguage = { config: "yaml" };
149162
148385
  var specifierLanguage = (label, sink, defaultLang, pkg) => {
149163
148386
  const id = label.toLowerCase();
149164
148387
  if (id === "tangle") return match$13(pkg, {
@@ -149166,7 +148389,7 @@ var specifierLanguage = (label, sink, defaultLang, pkg) => {
149166
148389
  onSome: (p) => extensionLanguage(tangleFilePath(p, sink))
149167
148390
  });
149168
148391
  if (id === "toc") return "prose";
149169
- return reservedLanguage[id] ?? id;
148392
+ return id;
149170
148393
  };
149171
148394
  var sectionLanguage$1 = (section, defaultLang, pkg) => {
149172
148395
  const { specifier, sink } = section.heading;
@@ -149178,7 +148401,7 @@ var nameIndex = (sections, defaultLang, pkg) => pipe(sections, map$24((s) => map
149178
148401
  name: sectionNameOf(s),
149179
148402
  pos: title.position,
149180
148403
  language: sectionLanguage$1(s, defaultLang, pkg)
149181
- }])), getSomes, reduce$11(/* @__PURE__ */ new Map(), (index, [title, entry]) => new Map(index).set(title, [...index.get(title) ?? [], entry])));
148404
+ }])), getSomes, reduce$10(/* @__PURE__ */ new Map(), (index, [title, entry]) => new Map(index).set(title, [...index.get(title) ?? [], entry])));
149182
148405
  var frontmatterLanguage = (frontmatter) => pipe(frontmatter, flatMapNullishOr$2((f) => f.language), map$29((l) => l.value.trim().toLowerCase()));
149183
148406
  var languageByExtension = /* @__PURE__ */ new Map([
149184
148407
  ["ts", "typescript"],
@@ -149199,12 +148422,24 @@ var decodeLiteral = (text) => {
149199
148422
  const s = text.trim();
149200
148423
  return /^"(?:\\.|[^"\\])*"$/.test(s) || /^'(?:\\.|[^'\\])*'$/.test(s) ? s.slice(1, -1).replace(/\\(.)/g, (_, c) => c) : text;
149201
148424
  };
149202
- var valueWarps = (warps) => new Map(getSomes(map$24(warps, (w) => w.default ? some$13([w.name.value, {
149203
- text: decodeLiteral(w.default.value),
149204
- pos: w.default.position
149205
- }]) : none$1())));
149206
- var buildSection = (index, defaultLang, modulePath, pkg) => (section) => {
149207
- const code = buildCode(section, valueWarps(section.preamble.flatMap((w) => w.warps)), index, {
148425
+ var variablePattern = /[$][{]([A-Za-z_][A-Za-z0-9_]*)[}]/g;
148426
+ var interpolate = (text, variables) => ({
148427
+ text: text.replace(variablePattern, (whole, name) => name in variables ? variables[name] : whole),
148428
+ missing: pipe(fromIterable$15(text.matchAll(variablePattern)), map$24((match) => match[1]), filter$15((name) => !(name in variables)), head$2)
148429
+ });
148430
+ var valueWarps = (warps, variables) => new Map(getSomes(map$24(warps, (w) => map$29(fromNullishOr$4(w.default), (def) => {
148431
+ const { text, missing } = interpolate(decodeLiteral(def.value), variables);
148432
+ return [w.name.value, {
148433
+ text,
148434
+ pos: def.position,
148435
+ health: match$13(missing, {
148436
+ onNone: () => okHealth,
148437
+ onSome: (name) => faulty(UnknownVariable({ name }), def.position)
148438
+ })
148439
+ }];
148440
+ }))));
148441
+ var buildSection = (index, defaultLang, modulePath, pkg, variables) => (section) => {
148442
+ const code = buildCode(section, valueWarps(section.preamble.flatMap((w) => w.warps), variables), index, {
149208
148443
  path: modulePath,
149209
148444
  name: sectionNameOf(section)
149210
148445
  }, sectionLanguage$1(section, defaultLang, pkg));
@@ -149280,7 +148515,8 @@ var bindAnchor = (index, values, host, modulePath) => (anchor) => {
149280
148515
  const value = values.get(name);
149281
148516
  if (value !== void 0) return FragmentSchema.make({
149282
148517
  text: value.text,
149283
- origin: at
148518
+ origin: at,
148519
+ health: value.health
149284
148520
  });
149285
148521
  return matchLeft(index.get(name) ?? [], {
149286
148522
  onEmpty: () => blankFragment(anchor.position, unresolved(name, at)),
@@ -149347,13 +148583,13 @@ var LoomCorpusAstBuilder = class extends Service$1()("LoomCorpusAstBuilder", { m
149347
148583
  text: "",
149348
148584
  doc: emptyDocument("", err.message)
149349
148585
  })));
149350
- const build = (source, path, delims = defaultAnchorDelims, primaryLanguage) => gen$1(function* () {
148586
+ const build = (source, path, delims = defaultAnchorDelims, primaryLanguage, variables = {}) => gen$1(function* () {
149351
148587
  const { text, doc } = yield* parsed(source, path, delims);
149352
148588
  return {
149353
148589
  path,
149354
148590
  text,
149355
148591
  doc,
149356
- product: yield* products.build(doc, path, primaryLanguage)
148592
+ product: yield* products.build(doc, path, primaryLanguage, variables)
149357
148593
  };
149358
148594
  });
149359
148595
  return { build };
@@ -149469,11 +148705,11 @@ Struct({ modules: ReadonlyMap(String$1, Struct({
149469
148705
  doc: LoomDocumentSchema,
149470
148706
  product: ProductSchema
149471
148707
  })) });
149472
- var resolveRelative = (from, rel) => pipe(rel.split("/"), filter$15((seg) => seg !== "" && seg !== "."), reduce$11(from.split("/").slice(0, -1), (acc, seg) => seg === ".." ? acc.slice(0, -1) : [...acc, seg]), join$6("/"));
148708
+ var resolveRelative = (from, rel) => pipe(rel.split("/"), filter$15((seg) => seg !== "" && seg !== "."), reduce$10(from.split("/").slice(0, -1), (acc, seg) => seg === ".." ? acc.slice(0, -1) : [...acc, seg]), join$6("/"));
149473
148709
  var titlesIn = (module) => pipe(module.doc.sections, map$24((section) => map$29(fromNullishOr$4(section.heading.title), (title) => [title.source, {
149474
148710
  module: module.path,
149475
148711
  section
149476
- }])), getSomes, reduce$11(/* @__PURE__ */ new Map(), (index, [title, ref]) => index.has(title) ? index : new Map(index).set(title, ref)));
148712
+ }])), getSomes, reduce$10(/* @__PURE__ */ new Map(), (index, [title, ref]) => index.has(title) ? index : new Map(index).set(title, ref)));
149477
148713
  var titleIndexes = (modules) => new Map(fromIterable$15(modules.values()).map((m) => [m.path, titlesIn(m)]));
149478
148714
  var resolveAnchor = (indexes, from, anchor) => pipe(fromNullishOr$4(indexes.get(anchor.target === void 0 ? from : resolveRelative(from, anchor.target.value))), flatMap$13((index) => fromNullishOr$4(index.get(anchor.name.value))));
149479
148715
  var anchorsOf = (section) => pipe([...section.preamble, ...section.code], flatMap$10((weft) => weft.anchors));
@@ -149559,7 +148795,7 @@ var chapterTitleToken = (module) => orElse$6(fromNullishOr$4(module.doc.frontmat
149559
148795
  var chapterIndex = (modules) => pipe(fromIterable$15(modules.values()), map$24((module) => map$29(chapterTitleToken(module), (title) => [title.source, {
149560
148796
  path: module.path,
149561
148797
  position: title.position
149562
- }])), getSomes, reduce$11(/* @__PURE__ */ new Map(), (index, [title, location]) => index.has(title) ? index : new Map(index).set(title, location)));
148798
+ }])), getSomes, reduce$10(/* @__PURE__ */ new Map(), (index, [title, location]) => index.has(title) ? index : new Map(index).set(title, location)));
149563
148799
  var tocEntriesOf = (module) => flatMap$10(module.doc.sections, (section) => section.entries ?? []);
149564
148800
  var tocEntryTitleAt = (modules, path, offset) => pipe(fromNullishOr$4(modules.get(path)), flatMap$13((module) => findFirst$6(tocEntriesOf(module), (entry) => entry.title !== void 0 && covers(entry.title.position, offset))), flatMap$13((entry) => fromNullishOr$4(entry.title)), map$29((title) => title.value));
149565
148801
  var frontmatterTitleAt = (modules, path, offset) => pipe(fromNullishOr$4(modules.get(path)), flatMap$13((module) => fromNullishOr$4(module.doc.frontmatter?.title)), filter$18((title) => covers(title.position, offset)), map$29((title) => title.value));
@@ -149589,7 +148825,7 @@ var partOpenerIndex = (modules) => pipe(fromIterable$15(modules.values()), map$2
149589
148825
  })), map$29(({ part, partName }) => [part.value, {
149590
148826
  path: module.path,
149591
148827
  position: partName.position
149592
- }]))), getSomes, reduce$11(/* @__PURE__ */ new Map(), (index, [num, location]) => index.has(num) ? index : new Map(index).set(num, location)));
148828
+ }]))), getSomes, reduce$10(/* @__PURE__ */ new Map(), (index, [num, location]) => index.has(num) ? index : new Map(index).set(num, location)));
149593
148829
  var onToken = (token, offset) => match$13(fromNullishOr$4(token), {
149594
148830
  onNone: () => false,
149595
148831
  onSome: (t) => covers(t.position, offset)
@@ -149707,7 +148943,7 @@ var inlineComposed = (modules, seen) => (node) => {
149707
148943
  vc: emptyLeaf,
149708
148944
  trim: false
149709
148945
  };
149710
- return pipe(node.fragments, reduce$11(seed, (acc, part, i) => {
148946
+ return pipe(node.fragments, reduce$10(seed, (acc, part, i) => {
149711
148947
  if (part.type === "Fragment") return {
149712
148948
  vc: concat(acc.vc, build(acc.trim ? trimLeadingBlank(part) : part)),
149713
148949
  trim: false
@@ -149807,7 +149043,7 @@ var fromProse = (modules, path) => match$13(fromNullishOr$4(modules.get(path)),
149807
149043
  return {
149808
149044
  id: "prose",
149809
149045
  languageId: "prose",
149810
- code: pipe(module.doc.sections, flatMap$10((section) => section.code), filter$15(isCodeWeft), reduce$11(module.text, (acc, weft) => {
149046
+ code: pipe(module.doc.sections, flatMap$10((section) => section.code), filter$15(isCodeWeft), reduce$10(module.text, (acc, weft) => {
149811
149047
  const start = weft.position.start.offset;
149812
149048
  const end = weft.position.end.offset;
149813
149049
  return acc.slice(0, start) + acc.slice(start, end).replace(/[^\n]/g, " ") + acc.slice(end);
@@ -149900,25 +149136,25 @@ var AnchorSchema = Struct({
149900
149136
  });
149901
149137
  var LanguageSchema = Struct({ service: optional(String$1) });
149902
149138
  var SettingsSchema = Record$1(String$1, Record$1(String$1, Unknown));
149903
- decodeUnknownOption(Struct({
149904
- languages: Record$1(String$1, LanguageSchema),
149905
- corpus: optional(String$1),
149906
- primary: optional(String$1),
149907
- anchor: optional(AnchorSchema),
149908
- settings: optional(SettingsSchema)
149909
- }));
149139
+ var VariablesSchema = Record$1(String$1, Union([
149140
+ String$1,
149141
+ Number$1,
149142
+ Boolean$2
149143
+ ]));
149910
149144
  var WorkspaceManifestSchema = Struct({
149911
149145
  languages: optional(Record$1(String$1, LanguageSchema)),
149912
149146
  corpus: optional(String$1),
149913
149147
  primary: optional(String$1),
149914
149148
  anchor: optional(AnchorSchema),
149915
- settings: optional(SettingsSchema)
149149
+ settings: optional(SettingsSchema),
149150
+ variables: optional(VariablesSchema)
149916
149151
  });
149917
149152
  var empty = {
149918
149153
  anchor: void 0,
149919
149154
  primary: void 0,
149920
149155
  languages: [],
149921
149156
  settings: {},
149157
+ variables: {},
149922
149158
  services: {},
149923
149159
  packageRoot: void 0,
149924
149160
  workspaceRoot: void 0,
@@ -149942,6 +149178,7 @@ var readManifest = (file) => {
149942
149178
  };
149943
149179
  var serviceFor = (id, language) => language.service ?? `@athrio/loom-service-${id}`;
149944
149180
  var servicesOf = (languages) => Object.fromEntries(Object.entries(languages ?? {}).map(([id, language]) => [id, serviceFor(id, language)]));
149181
+ var variablesOf = (variables) => Object.fromEntries(Object.entries(variables ?? {}).map(([name, value]) => [name, String(value)]));
149945
149182
  var containerRoot = (dir, container, workspace) => {
149946
149183
  if (basename(dir) === container) return dirname(dir);
149947
149184
  const parent = dirname(dir);
@@ -149962,6 +149199,7 @@ var resolveFromManifest = (manifest, workspace, fromPath) => {
149962
149199
  primary: manifest.primary,
149963
149200
  languages: Object.keys(manifest.languages ?? {}),
149964
149201
  settings: manifest.settings ?? {},
149202
+ variables: variablesOf(manifest.variables),
149965
149203
  services: servicesOf(manifest.languages),
149966
149204
  packageRoot: containerRoot(dirname(fromPath), container, workspace),
149967
149205
  workspaceRoot: workspace,
@@ -150001,6 +149239,7 @@ var PackageConfig = class extends Service$1()("PackageConfig", { make: gen$1(fun
150001
149239
  return { resolve: (path) => config.resolve(path).pipe(map$19((c) => ({
150002
149240
  delims: anchorDelimsOf(c.anchor),
150003
149241
  primaryLanguage: c.primary,
149242
+ variables: c.variables,
150004
149243
  packageRoot: c.packageRoot,
150005
149244
  workspaceRoot: c.workspaceRoot,
150006
149245
  corpusDir: c.corpusDir
@@ -150063,7 +149302,9 @@ var WovenPageSchema = Struct({
150063
149302
  var WovenNavEntrySchema = Struct({
150064
149303
  number: String$1,
150065
149304
  title: String$1,
150066
- slug: String$1
149305
+ slug: String$1,
149306
+ status: optional(String$1),
149307
+ priority: optional(String$1)
150067
149308
  });
150068
149309
  var WovenPartSchema = Struct({
150069
149310
  number: String$1,
@@ -150072,9 +149313,160 @@ var WovenPartSchema = Struct({
150072
149313
  });
150073
149314
  var WovenCorpusSchema = Struct({
150074
149315
  nav: ArraySchema(WovenPartSchema),
149316
+ loose: ArraySchema(WovenNavEntrySchema),
150075
149317
  pages: ArraySchema(WovenPageSchema)
150076
149318
  });
150077
149319
  //#endregion
149320
+ //#region ../loom-lang/src/weave/TableOfContentsBuilder.ts
149321
+ var TocChapterSchema = Struct({
149322
+ number: String$1,
149323
+ title: String$1,
149324
+ status: optional(String$1),
149325
+ priority: optional(String$1),
149326
+ path: String$1
149327
+ });
149328
+ var TocPartSchema = Struct({
149329
+ number: String$1,
149330
+ name: String$1,
149331
+ description: String$1,
149332
+ chapters: ArraySchema(TocChapterSchema)
149333
+ });
149334
+ var TableOfContentsSchema = Struct({
149335
+ parts: ArraySchema(TocPartSchema),
149336
+ loose: ArraySchema(TocChapterSchema)
149337
+ });
149338
+ var TableOfContentsBuilder = class extends Service$1()("TableOfContentsBuilder", { make: succeed$6({ build: (corpus) => sync$3(() => buildContents(corpus)) }) }) {
149339
+ static {
149340
+ this.layer = effect(this, this.make);
149341
+ }
149342
+ };
149343
+ var buildContents = (corpus) => {
149344
+ const modules = fromIterable$15(corpus.modules.values());
149345
+ const descriptions = descriptionsFrom(modules);
149346
+ const chapters = getSomes(map$24(modules, chapterDeclOf));
149347
+ const parts = pipe(dedupeParts(getSomes(map$24(modules, partDeclOf))), sort$1(byPart), map$24((decl) => TocPartSchema.make({
149348
+ number: decl.number,
149349
+ name: decl.name,
149350
+ description: getOrElse$2(fromNullishOr$4(descriptions.get(identityOf(decl))), () => ""),
149351
+ chapters: chaptersUnder(chapters, identityOf(decl))
149352
+ })));
149353
+ const loose = pipe(filter$15(chapters, (chapter) => chapter.partId === void 0), map$24(toTocChapter));
149354
+ return TableOfContentsSchema.make({
149355
+ parts,
149356
+ loose
149357
+ });
149358
+ };
149359
+ var partDeclOf = (module) => pipe(fromNullishOr$4(module.doc.frontmatter), flatMap$13((frontmatter) => map$29(fromNullishOr$4(frontmatter.partName), (partName) => ({
149360
+ number: frontmatter.part?.value ?? "",
149361
+ name: partName.value
149362
+ }))));
149363
+ var chapterDeclOf = (module) => pipe(fromNullishOr$4(module.doc.frontmatter), flatMap$13((frontmatter) => map$29(fromNullishOr$4(frontmatter.title), (title) => ({
149364
+ partId: frontmatter.part?.value ?? frontmatter.partName?.value,
149365
+ number: frontmatter.chapter?.value ?? "",
149366
+ title: title.value,
149367
+ status: frontmatter.status?.value,
149368
+ priority: frontmatter.priority?.value,
149369
+ path: module.path
149370
+ }))));
149371
+ var toTocChapter = (chapter) => TocChapterSchema.make({
149372
+ number: chapter.number,
149373
+ title: chapter.title,
149374
+ status: chapter.status,
149375
+ priority: chapter.priority,
149376
+ path: chapter.path
149377
+ });
149378
+ var romanUnits = {
149379
+ I: 1,
149380
+ V: 5,
149381
+ X: 10,
149382
+ L: 50,
149383
+ C: 100,
149384
+ D: 500,
149385
+ M: 1e3
149386
+ };
149387
+ var romanValue = (roman) => {
149388
+ const units = map$24(roman.toUpperCase().split(""), (letter) => romanUnits[letter] ?? 0);
149389
+ return pipe(units, map$24((unit, index) => unit < (units[index + 1] ?? 0) ? -unit : unit), reduce$10(0, (sum, unit) => sum + unit));
149390
+ };
149391
+ var identityOf = (part) => part.number === "" ? part.name : part.number;
149392
+ var dedupeParts = (decls) => reduce$10(decls, [], (kept, decl) => some$10(kept, (seen) => identityOf(seen) === identityOf(decl)) ? kept : [...kept, decl]);
149393
+ var byPart = combineAll([
149394
+ mapInput$4(Number$5, (part) => part.number === "" ? 1 : 0),
149395
+ mapInput$4(Number$5, (part) => part.number === "" ? 0 : romanValue(part.number)),
149396
+ mapInput$4(String$5, (part) => part.name)
149397
+ ]);
149398
+ var byChapter = combineAll([
149399
+ mapInput$4(Number$5, (chapter) => chapter.number === "" ? 1 : 0),
149400
+ mapInput$4(Number$5, (chapter) => chapter.number === "" ? 0 : Number(chapter.number)),
149401
+ mapInput$4(String$5, (chapter) => chapter.title)
149402
+ ]);
149403
+ var chaptersUnder = (chapters, identity) => pipe(filter$15(chapters, (chapter) => chapter.partId === identity), sort$1(byChapter), map$24(toTocChapter));
149404
+ var partLabel = /^Part\s+(\S+)\s*[—–-]\s*/;
149405
+ var bulletMarker = /^\s*[-*]\s+\S/;
149406
+ var partNumberOf = (label) => match$13(fromNullishOr$4(partLabel.exec(label)), {
149407
+ onNone: () => label,
149408
+ onSome: (match) => match[1] ?? label
149409
+ });
149410
+ var bookEntries = (modules) => pipe(findFirst$6(modules, (module) => some$10(module.doc.sections, (section) => section.entries !== void 0)), map$29((module) => flatMap$10(module.doc.sections, (section) => section.entries ?? [])), getOrElse$2(() => []));
149411
+ var lineOf = (entry) => match$13(fromNullishOr$4(entry.part), {
149412
+ onSome: (part) => ({
149413
+ kind: "part",
149414
+ identity: partNumberOf(part.value)
149415
+ }),
149416
+ onNone: () => entry.chapter !== void 0 || bulletMarker.test(entry.source) ? { kind: "chapter" } : { kind: "prose" }
149417
+ });
149418
+ var flushed = (state) => {
149419
+ const description = state.lines.join("\n").trim();
149420
+ return match$13(state.part, {
149421
+ onNone: () => state.found,
149422
+ onSome: (part) => description.length === 0 ? state.found : new Map(state.found).set(part, description)
149423
+ });
149424
+ };
149425
+ var descriptionsFrom = (modules) => {
149426
+ return flushed(reduce$10(bookEntries(modules), {
149427
+ part: none$1(),
149428
+ open: false,
149429
+ lines: [],
149430
+ found: /* @__PURE__ */ new Map()
149431
+ }, (state, entry) => value$1(lineOf(entry)).pipe(when({ kind: "part" }, ({ identity }) => ({
149432
+ part: some$13(identity),
149433
+ open: true,
149434
+ lines: [],
149435
+ found: flushed(state)
149436
+ })), when({ kind: "chapter" }, () => ({
149437
+ ...state,
149438
+ open: false,
149439
+ lines: [],
149440
+ found: flushed(state)
149441
+ })), orElse(() => state.open ? {
149442
+ ...state,
149443
+ lines: [...state.lines, entry.source]
149444
+ } : state))));
149445
+ };
149446
+ var chapterLine = (chapter) => chapter.number === "" ? `- ${chapter.title}` : `${chapter.number}. ${chapter.title}`;
149447
+ var partBlock = (part) => {
149448
+ const heading = part.number === "" ? `### ${part.name}` : `### Part ${part.number} — ${part.name}`;
149449
+ const list = pipe(part.chapters, map$24(chapterLine), join$6("\n"));
149450
+ const description = part.description.trim();
149451
+ return description.length === 0 ? `${heading}\n\n${list}` : `${heading}\n\n${description}\n\n${list}`;
149452
+ };
149453
+ var renderContents = (toc) => pipe(toc.parts, map$24(partBlock), join$6("\n\n"));
149454
+ var tocSectionOf = (module) => findFirst$6(module.doc.sections, (section) => section.entries !== void 0);
149455
+ var spliceToc = (module, section, toc) => {
149456
+ const heading = module.text.slice(section.heading.position.start.offset, section.heading.position.end.offset).trimEnd();
149457
+ const before = module.text.slice(0, section.position.start.offset);
149458
+ const tail = module.text.slice(section.position.end.offset).replace(/^\n+/, "");
149459
+ const rebuilt = `${before}${heading}\n\n${renderContents(toc)}\n`;
149460
+ return tail.length === 0 ? rebuilt : `${rebuilt}\n${tail}`;
149461
+ };
149462
+ var rewriteBook = (corpus, path, toc) => match$13(fromNullishOr$4(corpus.modules.get(path)), {
149463
+ onNone: () => "",
149464
+ onSome: (module) => match$13(tocSectionOf(module), {
149465
+ onNone: () => module.text,
149466
+ onSome: (section) => spliceToc(module, section, toc)
149467
+ })
149468
+ });
149469
+ //#endregion
150078
149470
  //#region ../loom-lang/src/weave/WeaveBuilder.ts
150079
149471
  var WeaveBuilder = class extends Service$1()("WeaveBuilder", { make: succeed$6({ build: (corpus) => sync$3(() => buildCorpus(corpus)) }) }) {
150080
149472
  static {
@@ -150084,11 +149476,14 @@ var WeaveBuilder = class extends Service$1()("WeaveBuilder", { make: succeed$6({
150084
149476
  var buildCorpus = (corpus) => {
150085
149477
  const modules = fromIterable$15(corpus.modules.values());
150086
149478
  const indexes = titleIndexes(corpus.modules);
150087
- const nav = buildNav(modules);
149479
+ const toc = buildContents(corpus);
149480
+ const nav = map$24(toc.parts, wovenPart);
149481
+ const loose = map$24(toc.loose, wovenEntry);
150088
149482
  const partOfSlug = partIndex(nav);
150089
149483
  const pages = getSomes(map$24(modules, (module) => buildPage(module, indexes, partOfSlug)));
150090
149484
  return WovenCorpusSchema.make({
150091
149485
  nav,
149486
+ loose,
150092
149487
  pages
150093
149488
  });
150094
149489
  };
@@ -150096,59 +149491,27 @@ var slugFor = (path) => pipe(path.replace(/\.loom$/, "").split("/"), takeRight$3
150096
149491
  var slugify = (text) => text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
150097
149492
  var isBlankSource = (source) => source.trim().length === 0;
150098
149493
  var sliceContent = (text, span) => text.slice(span.start, span.end).replace(/\s+$/, "");
150099
- var bookEntries = (modules) => pipe(findFirst$6(modules, (m) => some$10(m.doc.sections, (s) => s.entries !== void 0)), map$29((m) => flatMap$10(m.doc.sections, (s) => s.entries ?? [])), getOrElse$2(() => []));
150100
- var chapterSlugs = (modules) => pipe(modules, map$24((m) => map$29(fromNullishOr$4(m.doc.frontmatter?.title), (title) => [title.value, slugFor(m.path)])), getSomes, reduce$11(/* @__PURE__ */ new Map(), (index, [title, slug]) => index.has(title) ? index : new Map(index).set(title, slug)));
150101
- var classifyEntry = (entry) => pipe(fromNullishOr$4(entry.part), map$29((p) => ({
150102
- kind: "part",
150103
- label: p.value
150104
- })), orElse$6(() => map$29(all$5({
150105
- chapter: fromNullishOr$4(entry.chapter),
150106
- title: fromNullishOr$4(entry.title)
150107
- }), ({ chapter, title }) => ({
150108
- kind: "chapter",
150109
- number: chapter.value,
150110
- title: title.value
150111
- }))), getOrElse$2(() => ({ kind: "blank" })));
150112
- var partLabel = /^Part\s+(\S+)\s*[—–-]\s*(.+)$/;
150113
- var parsePart = (label) => match$13(fromNullishOr$4(partLabel.exec(label)), {
150114
- onNone: () => ({
150115
- number: label,
150116
- name: label
150117
- }),
150118
- onSome: (m) => ({
150119
- number: m[1] ?? label,
150120
- name: (m[2] ?? label).trim()
150121
- })
149494
+ var wovenEntry = (chapter) => WovenNavEntrySchema.make({
149495
+ number: chapter.number,
149496
+ title: chapter.title,
149497
+ slug: slugFor(chapter.path),
149498
+ status: chapter.status,
149499
+ priority: chapter.priority
149500
+ });
149501
+ var wovenPart = (part) => WovenPartSchema.make({
149502
+ number: part.number,
149503
+ name: part.name,
149504
+ chapters: map$24(part.chapters, wovenEntry)
150122
149505
  });
150123
- var appendChapter = (parts, chapter) => match$13(last$2(parts), {
150124
- onNone: () => parts,
150125
- onSome: (last) => [...dropRight$2(parts, 1), {
150126
- ...last,
150127
- chapters: [...last.chapters, chapter]
150128
- }]
150129
- });
150130
- var foldEntry = (slugs) => (parts, entry) => value$1(classifyEntry(entry)).pipe(when({ kind: "part" }, ({ label }) => {
150131
- const { number, name } = parsePart(label);
150132
- return [...parts, WovenPartSchema.make({
150133
- number,
150134
- name,
150135
- chapters: []
150136
- })];
150137
- }), when({ kind: "chapter" }, ({ number, title }) => match$13(fromNullishOr$4(slugs.get(title)), {
150138
- onNone: () => parts,
150139
- onSome: (slug) => appendChapter(parts, WovenNavEntrySchema.make({
150140
- number,
150141
- title,
150142
- slug
150143
- }))
150144
- })), orElse(() => parts));
150145
- var buildNav = (modules) => reduce$11(bookEntries(modules), [], foldEntry(chapterSlugs(modules)));
150146
149506
  var partIndex = (nav) => new Map(flatMap$10(nav, (part) => map$24(part.chapters, (chapter) => [chapter.slug, part.name])));
150147
- var buildPage = (module, indexes, partOfSlug) => map$29(fromNullishOr$4(module.doc.frontmatter?.title), (title) => {
149507
+ var isBookRoot = (module) => some$10(module.doc.sections, (section) => section.entries !== void 0);
149508
+ var firstHeadingTitle = (module) => pipe(findFirst$6(module.doc.sections, (section) => section.heading.title !== void 0), flatMap$13((section) => fromNullishOr$4(section.heading.title)), map$29((title) => title.source));
149509
+ var chapterTitleOf = (module) => orElse$6(map$29(fromNullishOr$4(module.doc.frontmatter?.title), (title) => title.value), () => firstHeadingTitle(module));
149510
+ var buildPage = (module, indexes, partOfSlug) => isBookRoot(module) ? none$1() : map$29(chapterTitleOf(module), (title) => {
150148
149511
  const slug = slugFor(module.path);
150149
149512
  return WovenPageSchema.make({
150150
149513
  slug,
150151
- title: title.value,
149514
+ title,
150152
149515
  part: partOfSlug.get(slug),
150153
149516
  blocks: buildBlocks(module, indexes)
150154
149517
  });
@@ -150205,7 +149568,7 @@ var proseBlockOf = (markdown, source) => markdown.trim().length === 0 ? [] : [Pr
150205
149568
  markdown: markdown.trim()
150206
149569
  })];
150207
149570
  var proseBlocks = (markdown, source) => {
150208
- const walked = reduce$11(fromIterable$15(markdown.matchAll(notePattern)), {
149571
+ const walked = reduce$10(fromIterable$15(markdown.matchAll(notePattern)), {
150209
149572
  blocks: [],
150210
149573
  cursor: 0
150211
149574
  }, (acc, match) => {
@@ -150342,7 +149705,7 @@ var toVolar = (vc) => ({
150342
149705
  mappings: map$24(vc.mappings, toCodeMapping),
150343
149706
  embeddedCodes: map$24(vc.embeddedCodes, toVolar)
150344
149707
  });
150345
- var ignoredDir = /* @__PURE__ */ new Set([
149708
+ var ignoredDirs = /* @__PURE__ */ new Set([
150346
149709
  "node_modules",
150347
149710
  ".loom",
150348
149711
  "dist",
@@ -150357,7 +149720,7 @@ var entriesIn = (dir) => {
150357
149720
  };
150358
149721
  var loomsUnder = (dir) => flatMap$10(entriesIn(dir), (entry) => {
150359
149722
  const full = resolve(dir, entry.name);
150360
- return value$1(entry).pipe(when((e) => ignoredDir.has(e.name), () => []), when((e) => e.isDirectory(), () => loomsUnder(full)), when((e) => e.name.endsWith(".loom"), () => [full]), orElse(() => []));
149723
+ return value$1(entry).pipe(when((e) => ignoredDirs.has(e.name), () => []), when((e) => e.isDirectory(), () => loomsUnder(full)), when((e) => e.name.endsWith(".loom"), () => [full]), orElse(() => []));
150361
149724
  });
150362
149725
  var DocumentSource = class extends Service$1()("DocumentSource", { make: succeed$6({
150363
149726
  read: (path) => try_({
@@ -150379,7 +149742,8 @@ var LoomCompiler = class extends Service$1()("LoomCompiler", { make: gen$1(funct
150379
149742
  const memo = yield* LoomMemo;
150380
149743
  const config = yield* PackageConfig;
150381
149744
  const weaver = yield* WeaveBuilder;
150382
- const loadOne = (source, path) => config.resolve(path).pipe(flatMap$7(({ delims, primaryLanguage }) => memo.get(path, builder.build(source, path, delims, primaryLanguage))));
149745
+ const tocBuilder = yield* TableOfContentsBuilder;
149746
+ const loadOne = (source, path) => config.resolve(path).pipe(flatMap$7(({ delims, primaryLanguage, variables }) => memo.get(path, builder.build(source, path, delims, primaryLanguage, variables))));
150383
149747
  const listFrom = (list, entry) => config.resolve(entry).pipe(map$19((settings) => getOrElse$2(fromNullishOr$4(settings.corpusDir), () => dirname(entry))), flatMap$7(list), map$19((found) => dedupe$1([entry, ...found])));
150384
149748
  const corpusPaths = (source, entry) => match$13(source.list, {
150385
149749
  onNone: () => succeed$6([entry]),
@@ -150404,6 +149768,7 @@ var LoomCompiler = class extends Service$1()("LoomCompiler", { make: gen$1(funct
150404
149768
  heading: headingLocationOf(modules, module, file.code.origin.name)
150405
149769
  })))), { concurrency: "unbounded" }).pipe(map$19(flatten$5)))),
150406
149770
  weave: (path) => buildCorpus(documents, path).pipe(flatMap$7((modules) => weaver.build({ modules }))),
149771
+ contents: (path) => buildCorpus(documents, path).pipe(flatMap$7((modules) => tocBuilder.build({ modules }).pipe(map$19((toc) => rewriteBook({ modules }, path, toc))))),
150407
149772
  diagnose: (path) => buildCorpus(documents, path).pipe(map$19((modules) => pipe(fromNullishOr$4(modules.get(path)), match$13({
150408
149773
  onNone: () => [],
150409
149774
  onSome: (module) => [...moduleDiagnostics(module), ...flatMap$10(unresolvedTocEntriesIn({ modules }, module), (title) => faulty(UnresolvedTocEntry({ title: title.value }), title.position).diagnostics)]
@@ -150432,7 +149797,7 @@ var LoomCompiler = class extends Service$1()("LoomCompiler", { make: gen$1(funct
150432
149797
  };
150433
149798
  }) }) {
150434
149799
  static {
150435
- this.layer = effect(this, this.make).pipe(provide$5(mergeAll$2(LoomCorpusAstBuilder.layer, LoomMemo.layer, WeaveBuilder.layer)));
149800
+ this.layer = effect(this, this.make).pipe(provide$5(mergeAll$2(LoomCorpusAstBuilder.layer, LoomMemo.layer, WeaveBuilder.layer, TableOfContentsBuilder.layer)));
150436
149801
  }
150437
149802
  };
150438
149803
  //#endregion
@@ -150488,6 +149853,6 @@ var removeService = (id, dir) => sync$3(() => rmSync(join(storeDir(dir), "node_m
150488
149853
  force: true
150489
149854
  }));
150490
149855
  //#endregion
150491
- export { get$16 as $, filter$15 as $n, ignore$3 as $t, Boolean$1 as A, mergeAll$2 as An, identity$1 as Ar, makeUnsafe$12 as At, make$33 as B, fail$11 as Bn, catchTag$2 as Bt, errorReported as C, try_ as Cn, format$5 as Cr, endUnsafe as Ct, make$30 as D, TaggedError as Dn, isNullish as Dr, offerUnsafe as Dt, Crypto as E, catchDone as En, isNotUndefined as Er, offer$2 as Et, FileDescriptor as F, MinimumLogLevel as Fn, as$1 as Ft, isStream as G, fail$12 as Gn, ensuring$3 as Gt, decodeText as H, Done as Hn, catch_$3 as Ht, FileSystem as I, _await$1 as In, asVoid as It, run$4 as J, empty$20 as Jn, fnUntraced as Jt, merge$1 as K, Reference as Kn, fail$8 as Kt, FileTypeId as L, doneUnsafe as Ln, callback$2 as Lt, TrueValues as M, provideMerge as Mn, pipeArguments as Mr, acquireRelease$1 as Mt, Path as N, succeed$8 as Nn, addFinalizer as Nt, error$1 as O, taggedEnum as On, isUndefined$1 as Or, take$7 as Ot, TypeId$33 as P, addFinalizer$1 as Pn, andThen as Pt, unwrap$1 as Q, dedupe$1 as Qn, gen$1 as Qt, Size as R, isDone$1 as Rn, catchCause$3 as Rt, errorExitCode as S, tryPromise as Sn, BaseProto as Sr, mapDone as St, make$22 as T, void_$1 as Tn, isNotNull as Tr, make$48 as Tt, empty$9 as U, UnknownError as Un, die$3 as Ut, callback as V, succeed$10 as Vn, catchTags$1 as Vt, fromChannel as W, done$2 as Wn, effectify as Wt, splitLines$1 as X, make$69 as Xn, forever$2 as Xt, runCollect as Y, getUnsafe$11 as Yn, forEach$8 as Yt, transduce as Z, Prototype as Zn, forkScoped as Zt, Terminal as _, succeed$6 as _n, map$29 as _r, tag$2 as _t, storeDir as a, match$3 as an, of$2 as ar, badArgument as at, Stdio as b, tap$2 as bn, some$13 as br, get$21 as bt, LoomCompiler as c, orElseSucceed$1 as cn, fail$14 as cr, Defect as ct, PackageConfig as d, provideService$3 as dn, fromNullishOr$4 as dr, String$1 as dt, interrupt$3 as en, fromIterable$15 as er, make$35 as et, LoomConfig as f, raceFirst as fn, fromUndefinedOr as fr, Struct as ft, QuitError as g, serviceOption$1 as gn, isSome as gr, optional as gt, dist_exports as h, scoped$2 as hn, isNone as hr, is$2 as ht, servicePackage as i, mapError$3 as in, match$11 as ir, BadArgument as it, FalseValues as j, provide$5 as jn, pipe as jr, nominal as jt, log as k, effect as kn, dual as kr, make$50 as kt, loomsUnder as l, provide$3 as ln, succeed$12 as lr, ErrorClass as lt, ReadError as m, runFork as mn, getOrUndefined$2 as mr, decodeUnknownEffect as mt, installedServices as n, logWarning as nn, groupBy$1 as nr, fromChannel$1 as nt, workspaceRoot as o, matchEffect as on, reduce$11 as or, systemError as ot, SemanticTokenSchema as p, result$3 as pn, getOrElse$2 as pr, Union as pt, mkString as q, Service$1 as qn, flatMap$7 as qt, removeService as r, map$19 as rn, map$24 as rr, isSink as rt, DocumentSource as s, orDie$2 as sn, sort$1 as sr, ArraySchema as st, addService as t, isEffect as tn, getSomes as tr, drain$1 as tt, stringSnapshot as u, provideContext$3 as un, flatMap$13 as ur, Literal as ut, isQuitError as v, suspend$4 as vn, match$13 as vr, toCodecStringTree as vt, makeRunMain as w, uninterruptible as wn, hasProperty as wr, failCauseUnsafe as wt, make$13 as x, timeoutOrElse$1 as xn, String$5 as xr, fromTransform$1 as xt, make$11 as y, sync$3 as yn, none$1 as yr, fromIterable$10 as yt, WatchBackend as z, makeUnsafe$16 as zn, catchFilter$2 as zt };
149856
+ export { mkString as $, done$2 as $n, ensuring$3 as $t, log as A, timeoutOrElse$1 as An, none$1 as Ar, mapDone as At, WatchBackend as B, provide$5 as Bn, dual as Br, acquireRelease$1 as Bt, errorExitCode as C, runFork as Cn, fromUndefinedOr as Cr, is$2 as Ct, Crypto as D, suspend$4 as Dn, isSome as Dr, fromIterable$10 as Dt, make$22 as E, succeed$6 as En, isNone as Er, toCodecStringTree as Et, TypeId$33 as F, catchDone as Fn, hasProperty as Fr, offerUnsafe as Ft, empty$9 as G, _await$1 as Gn, callback$2 as Gt, callback as H, succeed$8 as Hn, pipe as Hr, andThen as Ht, FileDescriptor as I, TaggedError as In, isNotNull as Ir, take$7 as It, fromEffect$1 as J, makeUnsafe$16 as Jn, catchTag$2 as Jt, filter$5 as K, doneUnsafe as Kn, catchCause$3 as Kt, FileSystem as L, taggedEnum as Ln, isNotUndefined as Lr, make$50 as Lt, FalseValues as M, try_ as Mn, String$5 as Mr, failCauseUnsafe as Mt, TrueValues as N, uninterruptible as Nn, BaseProto as Nr, make$48 as Nt, make$30 as O, sync$3 as On, map$29 as Or, get$21 as Ot, Path as P, void_$1 as Pn, format$5 as Pr, offer$2 as Pt, merge$1 as Q, UnknownError as Qn, effectify as Qt, FileTypeId as R, effect as Rn, isNullish as Rr, makeUnsafe$12 as Rt, make$13 as S, result$3 as Sn, fromNullishOr$4 as Sr, decodeUnknownEffect as St, makeRunMain as T, serviceOption$1 as Tn, getOrUndefined$2 as Tr, tag$2 as Tt, concat$2 as U, addFinalizer$1 as Un, pipeArguments as Ur, as$1 as Ut, make$33 as V, provideMerge as Vn, identity$1 as Vr, addFinalizer as Vt, decodeText as W, MinimumLogLevel as Wn, asVoid as Wt, isStream as X, succeed$10 as Xn, catch_$3 as Xt, groupedWithin as Y, fail$11 as Yn, catchTags$1 as Yt, mapEffect as Z, Done as Zn, die$3 as Zt, QuitError as _, orElseSucceed$1 as _n, fail$14 as _r, ErrorClass as _t, storeDir as a, forkScoped as an, make$69 as ar, transduce as at, make$11 as b, provideService$3 as bn, contains$3 as br, Struct as bt, LoomCompiler as c, interrupt$3 as cn, filter$15 as cr, make$35 as ct, stringSnapshot as d, map$19 as dn, groupBy$1 as dr, isSink as dt, fail$8 as en, fail$12 as er, orDie as et, PackageConfig as f, mapError$3 as fn, map$24 as fr, BadArgument as ft, dist_exports as g, orDie$2 as gn, sort$1 as gr, Defect as gt, ReadError as h, option$4 as hn, reduce$10 as hr, ArraySchema as ht, servicePackage as i, forever$2 as in, getUnsafe$11 as ir, splitLines$1 as it, Boolean$1 as j, tryPromise as jn, some$13 as jr, endUnsafe as jt, error$1 as k, tap$2 as kn, match$13 as kr, fromTransform$1 as kt, ignoredDirs as l, isEffect as ln, fromIterable$15 as lr, drain$1 as lt, SemanticTokenSchema as m, matchEffect as mn, of$2 as mr, systemError as mt, installedServices as n, fnUntraced as nn, Service$1 as nr, runCollect as nt, workspaceRoot as o, gen$1 as on, Prototype as or, unwrap$1 as ot, LoomConfig as p, match$3 as pn, match$11 as pr, badArgument as pt, fromChannel as q, isDone$1 as qn, catchFilter$2 as qt, removeService as r, forEach$8 as rn, empty$20 as rr, runForEach as rt, DocumentSource as s, ignore$3 as sn, dedupe$1 as sr, get$16 as st, addService as t, flatMap$7 as tn, Reference as tr, run$4 as tt, loomsUnder as u, logWarning as un, getSomes as ur, fromChannel$1 as ut, Terminal as v, provide$3 as vn, match$12 as vr, Literal as vt, errorReported as w, scoped$2 as wn, getOrElse$2 as wr, optional as wt, Stdio as x, raceFirst as xn, flatMap$13 as xr, Union as xt, isQuitError as y, provideContext$3 as yn, succeed$12 as yr, String$1 as yt, Size as z, mergeAll$2 as zn, isUndefined$1 as zr, nominal as zt };
150492
149857
 
150493
- //# sourceMappingURL=LoomStore-DPhVqYEz.js.map
149858
+ //# sourceMappingURL=LoomStore-CxUQqaPK.js.map