@stakekit/widget 0.0.287 → 0.0.289

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/bundle/Result-D66k67e4.js +3 -0
  2. package/dist/bundle/Schema-CnO1Nnkx.js +2 -0
  3. package/dist/bundle/{cardano-connector-Cg1NVNSz.js → cardano-connector-BdmhtPwK.js} +1 -1
  4. package/dist/{website/assets/configured-chains-C5lih9lm.js → bundle/configured-chains-BVaAJPl7.js} +1 -1
  5. package/dist/bundle/{cosmos-connector-meta-B3hXlZyj.js → cosmos-connector-meta-CsjY5xv_.js} +1 -1
  6. package/dist/bundle/{current-value-stream-sEIwrVMJ.js → current-value-stream-BphKxe9G.js} +1 -1
  7. package/dist/bundle/{esm-B8ixy8Ti.js → esm-BioWy-zm.js} +1 -1
  8. package/dist/bundle/index.bundle.css +1 -1
  9. package/dist/bundle/index.bundle.js +132 -100
  10. package/dist/bundle/{ledger-connector-ScKbHFK2.js → ledger-connector-BeFXqMQm.js} +2 -2
  11. package/dist/bundle/{network-DRjEa3NO.js → network-BR2dx0lQ.js} +1 -1
  12. package/dist/bundle/{polkadot-ledger-transaction-CSI9csNM.js → polkadot-ledger-transaction-CCpzhicj.js} +1 -1
  13. package/dist/bundle/{safe-connector-BuI_vM2N.js → safe-connector-BW8tBAGV.js} +1 -1
  14. package/dist/bundle/{solana-connector-BXIkWGi1.js → solana-connector-CEoNnJWx.js} +1 -1
  15. package/dist/bundle/{stellar-connector-D5G2p6aO.js → stellar-connector-C3GFN35d.js} +1 -1
  16. package/dist/bundle/{substrate-connector-AJ6EWjQP.js → substrate-connector-B7COXHL7.js} +1 -1
  17. package/dist/{website/assets/ton-connector-DWz2WVCw.js → bundle/ton-connector-DnPSYtXm.js} +1 -1
  18. package/dist/bundle/transaction-3CLRKFvX.js +1 -0
  19. package/dist/{website/assets/transaction-BJ3RmuAw.js → bundle/transaction-BDuN1rLk.js} +2 -2
  20. package/dist/bundle/{transaction-NX-vBbnh.js → transaction-DU8AaOQz.js} +1 -1
  21. package/dist/bundle/{tron-connector-nZfhLwx4.js → tron-connector-iA7bb0__.js} +1 -1
  22. package/dist/bundle/{utils-CfBIlQsz.js → utils-llPzGe7v.js} +1 -1
  23. package/dist/bundle/wagmi-connect-result-DOu6hDDM.js +11 -0
  24. package/dist/bundle/{wallet-errors-Bvwwydi9.js → wallet-errors-MrbcJr3I.js} +1 -1
  25. package/dist/bundle/{wallet-manager-C-MB05Qs.js → wallet-manager-D2AeCPRs.js} +2 -2
  26. package/dist/package/{Result-Cem4lYBf.js → Result-BA6lrqKV.js} +117 -49
  27. package/dist/package/{Schema-DFoi51wt.js → Schema-CUut1r-H.js} +1135 -1310
  28. package/dist/package/{cardano-connector-B9UToMFP.js → cardano-connector-ApyBIRYL.js} +3 -3
  29. package/dist/package/{configured-chains-BfQ8ESmR.js → configured-chains-CeRB7Tdy.js} +1 -1
  30. package/dist/package/{cosmos-connector-meta-UMFrkViG.js → cosmos-connector-meta-NNACISY5.js} +1 -1
  31. package/dist/package/{current-value-stream-BPaLLDf4.js → current-value-stream-Cs2IFPhP.js} +1 -1
  32. package/dist/package/{esm-89IrCtWy.js → esm-3BtHXmV9.js} +1 -1
  33. package/dist/package/index.package.css +31 -10
  34. package/dist/package/index.package.js +8695 -3962
  35. package/dist/package/{ledger-connector-B8D8xJOD.js → ledger-connector-ebEnv7IA.js} +9 -9
  36. package/dist/package/{network-DiYap-9L.js → network-Df21Fcdz.js} +1 -1
  37. package/dist/package/{polkadot-ledger-transaction-Bi14PyTF.js → polkadot-ledger-transaction-Cq_ImU8s.js} +1 -1
  38. package/dist/package/{safe-connector-lVCS_bS5.js → safe-connector-CMgopygU.js} +4 -4
  39. package/dist/package/{solana-connector-P-TqgNNC.js → solana-connector-B2Rf5Tyj.js} +3 -3
  40. package/dist/package/{stellar-connector-BMB2Cql4.js → stellar-connector-DdzqZgoG.js} +4 -4
  41. package/dist/package/{substrate-connector-a7SNpKjf.js → substrate-connector-DO7OAvZ9.js} +2 -2
  42. package/dist/package/{ton-connector-CMzOI2bi.js → ton-connector-CUtYVysK.js} +5 -5
  43. package/dist/package/{transaction-CmOScFm6.js → transaction-BjGgdyu0.js} +5 -5
  44. package/dist/package/{transaction-Do9wZHM8.js → transaction-MMiSjtGI.js} +1 -1
  45. package/dist/package/{transaction-C1e6h8J1.js → transaction-fIZimEky.js} +1 -1
  46. package/dist/package/{tron-connector-PLpMhB65.js → tron-connector-DT1NdAaP.js} +2 -2
  47. package/dist/package/{wagmi-connect-result-BJ91_jis.js → wagmi-connect-result-Bh6qH5iI.js} +593 -462
  48. package/dist/package/{wallet-errors-B4cGcGNy.js → wallet-errors-BMdJQ_kv.js} +1 -1
  49. package/dist/package/{wallet-manager-BsDss9DQ.js → wallet-manager-BbL7EBi6.js} +5 -5
  50. package/dist/types/domain/network/network.d.ts +2 -2
  51. package/dist/types/generated/api/legacy-schema.d.ts +3503 -1952
  52. package/dist/types/generated/api/yield-schema.d.ts +1491 -1114
  53. package/dist/types/public-api/types.d.ts +2 -2
  54. package/dist/website/assets/Result-D66k67e4.js +3 -0
  55. package/dist/website/assets/Schema-CnO1Nnkx.js +2 -0
  56. package/dist/website/assets/{cardano-connector-JluaLQJr.js → cardano-connector-DkgQsbib.js} +1 -1
  57. package/dist/{bundle/configured-chains-C5lih9lm.js → website/assets/configured-chains-BVaAJPl7.js} +1 -1
  58. package/dist/website/assets/{cosmos-connector-meta-B3hXlZyj.js → cosmos-connector-meta-CsjY5xv_.js} +1 -1
  59. package/dist/website/assets/{current-value-stream-sEIwrVMJ.js → current-value-stream-BphKxe9G.js} +1 -1
  60. package/dist/website/assets/{esm-DmRWC3up.js → esm-DJUTv1_r.js} +1 -1
  61. package/dist/website/assets/index-BYTj9y8r.js +592 -0
  62. package/dist/website/assets/{index-CYwddl65.css → index-m2lpHJ_u.css} +1 -1
  63. package/dist/website/assets/{ledger-connector-zHWvy_21.js → ledger-connector-CMFH1Z0M.js} +3 -3
  64. package/dist/website/assets/{network-DRjEa3NO.js → network-BR2dx0lQ.js} +1 -1
  65. package/dist/website/assets/{polkadot-ledger-transaction-CSI9csNM.js → polkadot-ledger-transaction-CCpzhicj.js} +1 -1
  66. package/dist/website/assets/{safe-connector-B_IWbdsx.js → safe-connector-BDc3OqKV.js} +1 -1
  67. package/dist/website/assets/{solana-connector-DUrUEFXI.js → solana-connector-Ij-Dm1HM.js} +1 -1
  68. package/dist/website/assets/{stellar-connector-D5G2p6aO.js → stellar-connector-C3GFN35d.js} +1 -1
  69. package/dist/website/assets/{substrate-connector-DxgYUQY4.js → substrate-connector-B-LTNtpz.js} +1 -1
  70. package/dist/{bundle/ton-connector-DWz2WVCw.js → website/assets/ton-connector-DnPSYtXm.js} +1 -1
  71. package/dist/{bundle/transaction-BJ3RmuAw.js → website/assets/transaction-BDuN1rLk.js} +2 -2
  72. package/dist/website/assets/{transaction-BIBBEBi6.js → transaction-Cth5mVGJ.js} +1 -1
  73. package/dist/website/assets/transaction-peV0IJTV.js +1 -0
  74. package/dist/website/assets/{tron-connector-C3nKPxdx.js → tron-connector-D_NeRPfc.js} +1 -1
  75. package/dist/website/assets/{utils-DVCp0qSW.js → utils-DOZR2zEE.js} +1 -1
  76. package/dist/website/assets/wagmi-connect-result-DOu6hDDM.js +11 -0
  77. package/dist/website/assets/{wallet-errors-Bvwwydi9.js → wallet-errors-MrbcJr3I.js} +1 -1
  78. package/dist/website/assets/{wallet-manager-9-XcN6SR.js → wallet-manager-DGQAWJIz.js} +3 -3
  79. package/dist/website/index.html +13 -13
  80. package/package.json +12 -11
  81. package/dist/bundle/Result-3MQjLy1V.js +0 -3
  82. package/dist/bundle/Schema-DgreXIef.js +0 -2
  83. package/dist/bundle/transaction-BnkP6nIP.js +0 -1
  84. package/dist/bundle/wagmi-connect-result-CqXaJhOa.js +0 -11
  85. package/dist/website/assets/Result-3MQjLy1V.js +0 -3
  86. package/dist/website/assets/Schema-DgreXIef.js +0 -2
  87. package/dist/website/assets/index-CbH5OQ2T.js +0 -560
  88. package/dist/website/assets/transaction-Sqg4_vo7.js +0 -1
  89. package/dist/website/assets/wagmi-connect-result-CqXaJhOa.js +0 -11
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { A as constEmptyAnnotations, At as isNotUndefined, B as isCause, Bt as constNull, C as TaggedError$1, Ct as hasProperty, D as causeEmpty, E as causeAnnotate, F as evaluate, G as isInterruptReason, Gt as dual, H as isEffect$1, Ht as constUndefined, I as exitDie, It as isTagged, J as withFiber$1, K as makePrimitive, L as exitFail, M as contAll, N as contE, O as causeFail, Ot as isIterable, P as done$2, Q as internalCall, Qt as pipeArguments, R as exitFailCause, S as StackTraceKey, St as symbol$1, T as args, Tt as isBoolean, U as isExit$1, Ut as constVoid, V as isDone$1, Vt as constTrue, W as isFailReason$1, Wt as constant, X as assignProperty, Y as assignProperties, Z as SingleShotGen, Zt as Class$1, _ as Fail, _t as hash, a as isFailure$1, b as PipeInspectableProto, bt as string, d as succeed$6, ft as equals$1, g as ExitTypeId, gt as combine, h as Error$2, it as format, j as contA, jt as isNumber, k as causeFromReasons, lt as currentFiberTypeId, m as Done, mt as symbol, nt as toJson, ot as formatJson, p as CauseImpl, q as makePrimitiveProto, qt as identity, rt as toStringUnknown, s as isSuccess$1, t as fail$6, tt as NodeInspectSymbol, u as match$3, v as InterruptorStackTrace$1, vt as number, w as Yield, x as ReasonBase, xt as structure, y as NoSuchElementError$1, yt as random, z as exitSucceed, zt as constFalse } from "./Result-Cem4lYBf.js";
3
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/Effectable.js
2
+ import { $ as internalCall, A as causeFromReasons, At as isIterable, B as exitSucceed, C as TaggedError$1, Ct as structure, D as causeDie, Dt as isBoolean, E as causeAnnotate, F as done$2, G as isFailReason$1, Gt as constUndefined, H as isDone$1, Ht as constFalse, I as evaluate, J as makePrimitiveProto, Jt as dual, K as isInterruptReason, Kt as constVoid, L as exitDie, M as contA, N as contAll, Nt as isNotUndefined, O as causeEmpty, P as contE, Pt as isNumber, Q as SingleShotGen, R as exitFail, S as StackTraceKey, St as string, T as args, Tt as hasProperty, U as isEffect$1, Ut as constNull, V as isCause, W as isExit$1, Wt as constTrue, X as assignProperties, Xt as identity, Y as withFiber$1, Z as assignProperty, _ as Fail, a as isFailure$1, at as toJson, b as PipeInspectableProto, bt as number, d as succeed$6, en as Class$1, et as getStackTraceLimit, ft as currentFiberTypeId, g as ExitTypeId, gt as symbol, h as Error$2, ht as equals$1, it as NodeInspectSymbol, j as constEmptyAnnotations, k as causeFail, lt as formatJson, m as Done, ot as toStringUnknown, p as CauseImpl, q as makePrimitive, qt as constant, s as isSuccess$1, st as format, t as fail$6, tn as pipeArguments, tt as setStackTraceLimit, u as match$3, v as InterruptorStackTrace$1, vt as combine, w as Yield, wt as symbol$1, x as ReasonBase, xt as random, y as NoSuchElementError$1, yt as hash, z as exitFailCause, zt as isTagged } from "./Result-BA6lrqKV.js";
3
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/Effectable.js
4
4
  /**
5
5
  * Create a low-level `Effect` prototype.
6
6
  *
@@ -15,6 +15,7 @@ import { A as constEmptyAnnotations, At as isNotUndefined, B as isCause, Bt as c
15
15
  * When the effect is evaluated, it calls `evaluate` with the current fiber.
16
16
  *
17
17
  * @see {@link Class} for a class-based approach to defining custom Effect values
18
+ * @see {@link Mixin} for wrapping an existing class constructor
18
19
  *
19
20
  * @category prototypes
20
21
  * @since 4.0.0
@@ -24,7 +25,7 @@ var Prototype = (options) => makePrimitiveProto({
24
25
  [evaluate]: options.evaluate
25
26
  });
26
27
  //#endregion
27
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/Equivalence.js
28
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/Equivalence.js
28
29
  /**
29
30
  * Creates a custom equivalence relation with an optimized reference equality check.
30
31
  *
@@ -198,11 +199,11 @@ function Array_(item) {
198
199
  });
199
200
  }
200
201
  //#endregion
201
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/internal/option.js
202
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/internal/option.js
202
203
  /**
203
204
  * @since 2.0.0
204
205
  */
205
- var TypeId$11 = "~effect/data/Option";
206
+ var TypeId$11 = "~effect/Option";
206
207
  var CommonProto = {
207
208
  [TypeId$11]: { _A: (_) => _ },
208
209
  ...PipeInspectableProto,
@@ -262,13 +263,14 @@ var isSome$1 = (fa) => fa._tag === "Some";
262
263
  /** @internal */
263
264
  var none$1 = /*#__PURE__*/ Object.create(NoneProto);
264
265
  /** @internal */
265
- var some$1 = (value) => {
266
- const a = Object.create(SomeProto);
267
- a.value = value;
268
- return a;
266
+ var SomeImpl = function(value) {
267
+ this.value = value;
269
268
  };
269
+ SomeImpl.prototype = SomeProto;
270
+ /** @internal */
271
+ var some$1 = (value) => new SomeImpl(value);
270
272
  //#endregion
271
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/Order.js
273
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/Order.js
272
274
  /**
273
275
  * Defines comparison functions for ordered values.
274
276
  *
@@ -632,7 +634,7 @@ var min$1 = (O) => dual(2, (self, that) => self === that || O(self, that) < 1 ?
632
634
  */
633
635
  var max$1 = (O) => dual(2, (self, that) => self === that || O(self, that) > -1 ? self : that);
634
636
  //#endregion
635
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/Option.js
637
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/Option.js
636
638
  /**
637
639
  * Creates an `Option` representing the absence of a value.
638
640
  *
@@ -1147,7 +1149,7 @@ var filter$6 = /*#__PURE__*/ dual(2, (self, predicate) => isNone(self) ? none()
1147
1149
  */
1148
1150
  var exists = /*#__PURE__*/ dual(2, (self, refinement) => isNone(self) ? false : refinement(self.value));
1149
1151
  //#endregion
1150
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/Context.js
1152
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/Context.js
1151
1153
  /**
1152
1154
  * Runtime type identifier attached to `Context` service keys and used by
1153
1155
  * `isKey` to recognize them.
@@ -1744,14 +1746,29 @@ var mergeAll$1 = (...ctxs) => {
1744
1746
  */
1745
1747
  var Reference = Service;
1746
1748
  //#endregion
1747
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/internal/array.js
1749
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/internal/array.js
1748
1750
  /**
1749
1751
  * @since 2.0.0
1750
1752
  */
1751
1753
  /** @internal */
1752
1754
  var isArrayNonEmpty$1 = (self) => self.length > 0;
1753
1755
  //#endregion
1754
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/Iterable.js
1756
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/internal/count.js
1757
+ /**
1758
+ * Normalizes a collection count to a non-negative integer. `NaN` and
1759
+ * non-positive values become `0`; positive infinity is preserved.
1760
+ *
1761
+ * @internal
1762
+ */
1763
+ var normalize = (n) => n > 0 ? Math.floor(n) : 0;
1764
+ /**
1765
+ * Normalizes a collection count to an integer greater than or equal to `1`.
1766
+ *
1767
+ * @internal
1768
+ */
1769
+ var normalizeNonEmpty = (n) => Math.max(1, normalize(n));
1770
+ //#endregion
1771
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/Iterable.js
1755
1772
  /**
1756
1773
  * Gets the first element of an `Iterable` without returning an `Option`.
1757
1774
  *
@@ -1872,18 +1889,7 @@ var constEmptyIterator = { next() {
1872
1889
  */
1873
1890
  var empty$3 = () => constEmpty;
1874
1891
  //#endregion
1875
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/Array.js
1876
- /**
1877
- * Works with JavaScript arrays, readonly arrays, and non-empty arrays.
1878
- *
1879
- * The helpers cover common collection work such as creating arrays, reading
1880
- * elements, transforming values, sorting, grouping, splitting, combining, and
1881
- * reducing many values to one result. Helpers that change contents return new
1882
- * arrays and preserve non-empty array types when the result is guaranteed to
1883
- * contain values.
1884
- *
1885
- * @since 2.0.0
1886
- */
1892
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/Array.js
1887
1893
  /**
1888
1894
  * Exposes the global array constructor.
1889
1895
  *
@@ -2338,6 +2344,10 @@ var chop = /*#__PURE__*/ dual(2, (self, f) => {
2338
2344
  * Use when downstream code requires the left side of the split to contain at
2339
2345
  * least one element.
2340
2346
  *
2347
+ * **Details**
2348
+ *
2349
+ * `n` is rounded down and clamped to `[1, length]`. `NaN` is treated as `1`.
2350
+ *
2341
2351
  * **Example** (Splitting a non-empty array)
2342
2352
  *
2343
2353
  * ```ts import.meta.vitest
@@ -2352,7 +2362,7 @@ var chop = /*#__PURE__*/ dual(2, (self, f) => {
2352
2362
  * @since 4.0.0
2353
2363
  */
2354
2364
  var splitAtNonEmpty = /*#__PURE__*/ dual(2, (self, n) => {
2355
- const _n = Math.max(1, Math.floor(n));
2365
+ const _n = normalizeNonEmpty(n);
2356
2366
  return _n >= self.length ? [copy(self), []] : [prepend$1(self.slice(1, _n), headNonEmpty(self)), self.slice(_n)];
2357
2367
  });
2358
2368
  /**
@@ -2397,8 +2407,10 @@ var copy = (self) => self.slice();
2397
2407
  *
2398
2408
  * **Details**
2399
2409
  *
2400
- * `chunksOf(n)([])` is `[]`, not `[[]]`. Each chunk is a `NonEmptyArray`, and
2401
- * the outer return type preserves `NonEmptyArray`.
2410
+ * `n` is rounded down and normalized to at least `1`; `NaN` and non-positive
2411
+ * values therefore produce singleton chunks. `chunksOf(n)([])` is `[]`, not
2412
+ * `[[]]`. Each chunk is a `NonEmptyArray`, and the outer return type preserves
2413
+ * `NonEmptyArray`.
2402
2414
  *
2403
2415
  * **Example** (Chunking an array)
2404
2416
  *
@@ -2419,42 +2431,6 @@ var chunksOf = /*#__PURE__*/ dual(2, (self, n) => {
2419
2431
  if (isReadonlyArrayNonEmpty(input)) return chop(input, splitAtNonEmpty(n));
2420
2432
  return [];
2421
2433
  });
2422
- var hashBucketsAdd = (buckets, value) => {
2423
- const hash$1 = hash(value);
2424
- const bucket = buckets.get(hash$1);
2425
- if (bucket === void 0) {
2426
- buckets.set(hash$1, [value]);
2427
- return true;
2428
- }
2429
- for (const previous of bucket) if (equals$1(previous, value)) return false;
2430
- bucket.push(value);
2431
- return true;
2432
- };
2433
- /**
2434
- * Computes the union of two arrays, removing duplicates using
2435
- * `Equal.equivalence()`.
2436
- *
2437
- * **Example** (Computing array unions)
2438
- *
2439
- * ```ts import.meta.vitest
2440
- * import { Array } from "effect"
2441
- *
2442
- * Array.union([1, 2], [2, 3]) // => [1, 2, 3]
2443
- * ```
2444
- *
2445
- * @see {@link unionWith} — use custom equality
2446
- * @see {@link intersection} — elements in both arrays
2447
- * @see {@link difference} — elements only in the first array
2448
- *
2449
- * @category set operations
2450
- * @since 2.0.0
2451
- */
2452
- var union = /*#__PURE__*/ dual(2, (self, that) => {
2453
- const a = fromIterable(self);
2454
- const b = fromIterable(that);
2455
- if (isReadonlyArrayNonEmpty(a)) return isReadonlyArrayNonEmpty(b) ? dedupe(appendAll$1(a, b)) : a;
2456
- return b;
2457
- });
2458
2434
  /**
2459
2435
  * Creates an empty array.
2460
2436
  *
@@ -2706,40 +2682,9 @@ var dedupeWith = /*#__PURE__*/ dual(2, (self, isEquivalent) => {
2706
2682
  }
2707
2683
  return [];
2708
2684
  });
2709
- /**
2710
- * Removes duplicates using `Equal.equivalence()`, preserving the order of the
2711
- * first occurrence.
2712
- *
2713
- * **When to use**
2714
- *
2715
- * Use to remove repeated values from an iterable when Effect's default equality
2716
- * is the right comparison, preserving the first occurrence.
2717
- *
2718
- * **Example** (Removing duplicates)
2719
- *
2720
- * ```ts import.meta.vitest
2721
- * import { Array } from "effect"
2722
- *
2723
- * Array.dedupe([1, 2, 1, 3, 2, 4]) // => [1, 2, 3, 4]
2724
- * ```
2725
- *
2726
- * @see {@link dedupeWith} — use custom equality
2727
- * @see {@link dedupeAdjacent} — only dedupes consecutive elements
2728
- *
2729
- * @category deduplication
2730
- * @since 2.0.0
2731
- */
2732
- var dedupe = (self) => {
2733
- const input = fromIterable(self);
2734
- if (input.length < 2) return [...input];
2735
- const buckets = /* @__PURE__ */ new Map();
2736
- const out = [];
2737
- for (const value of input) if (hashBucketsAdd(buckets, value)) out.push(value);
2738
- return out;
2739
- };
2740
2685
  //#endregion
2741
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/Duration.js
2742
- var TypeId$9 = "~effect/time/Duration";
2686
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/Duration.js
2687
+ var TypeId$9 = "~effect/Duration";
2743
2688
  var bigint0$1 = /*#__PURE__*/ BigInt(0);
2744
2689
  var bigint1 = /*#__PURE__*/ BigInt(1);
2745
2690
  var bigint2 = /*#__PURE__*/ BigInt(2);
@@ -3432,7 +3377,7 @@ var isLessThanOrEqualTo = /*#__PURE__*/ isLessThanOrEqualTo$1(Order);
3432
3377
  */
3433
3378
  var equals = /*#__PURE__*/ dual(2, (self, that) => Equivalence(self, that));
3434
3379
  //#endregion
3435
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/Filter.js
3380
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/Filter.js
3436
3381
  /**
3437
3382
  * Converts a Filter into a predicate function.
3438
3383
  *
@@ -3511,7 +3456,7 @@ var toOption = (self) => (input) => {
3511
3456
  return isFailure$1(result) ? none() : some(result.success);
3512
3457
  };
3513
3458
  //#endregion
3514
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/Scheduler.js
3459
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/Scheduler.js
3515
3460
  /**
3516
3461
  * Controls how runnable Effect fiber tasks are dispatched.
3517
3462
  *
@@ -3543,13 +3488,6 @@ var Scheduler = /*#__PURE__*/ Reference("effect/Scheduler", {
3543
3488
  fiberCached: true,
3544
3489
  defaultValue: () => new MixedScheduler()
3545
3490
  });
3546
- var setImmediate = "setImmediate" in globalThis ? (f) => {
3547
- const timer = globalThis.setImmediate(f);
3548
- return () => globalThis.clearImmediate(timer);
3549
- } : (f) => {
3550
- const timer = setTimeout(f, 0);
3551
- return () => clearTimeout(timer);
3552
- };
3553
3491
  var setMicrotask = (f) => {
3554
3492
  let cancelled = false;
3555
3493
  Promise.resolve().then(() => {
@@ -3559,6 +3497,20 @@ var setMicrotask = (f) => {
3559
3497
  cancelled = true;
3560
3498
  };
3561
3499
  };
3500
+ var setTimer = "setImmediate" in globalThis ? (f) => {
3501
+ const timer = globalThis.setImmediate(f);
3502
+ return () => globalThis.clearImmediate(timer);
3503
+ } : (f) => {
3504
+ const timer = setTimeout(f, 0);
3505
+ return () => clearTimeout(timer);
3506
+ };
3507
+ var setImmediate = (f) => {
3508
+ try {
3509
+ return setTimer(f);
3510
+ } catch {
3511
+ return setMicrotask(f);
3512
+ }
3513
+ };
3562
3514
  var PriorityBuckets = class {
3563
3515
  buckets = [];
3564
3516
  scheduleTask(task, priority) {
@@ -3617,7 +3569,7 @@ var MixedScheduler = class {
3617
3569
  * @since 2.0.0
3618
3570
  */
3619
3571
  shouldYield(fiber) {
3620
- return fiber.currentOpCount >= fiber.maxOpsBeforeYield;
3572
+ return fiber.currentOpCount >= fiber.cache.maxOpsBeforeYield;
3621
3573
  }
3622
3574
  /**
3623
3575
  * Creates a dispatcher that schedules work through this scheduler.
@@ -3727,7 +3679,7 @@ var PreventSchedulerYield = /*#__PURE__*/ Reference("effect/Scheduler/PreventSch
3727
3679
  defaultValue: () => false
3728
3680
  });
3729
3681
  //#endregion
3730
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/Data.js
3682
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/Data.js
3731
3683
  /**
3732
3684
  * Provides a base class for immutable data types.
3733
3685
  *
@@ -3884,7 +3836,7 @@ var Error$1 = Error$2;
3884
3836
  */
3885
3837
  var TaggedError = TaggedError$1;
3886
3838
  //#endregion
3887
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/Encoding.js
3839
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/Encoding.js
3888
3840
  /**
3889
3841
  * Encoding and decoding helpers for Base64, Base64Url, and hexadecimal text.
3890
3842
  * The functions convert between strings, UTF-8 text, and `Uint8Array` bytes.
@@ -3913,7 +3865,7 @@ var TaggedError = TaggedError$1;
3913
3865
  * @category type IDs
3914
3866
  * @since 4.0.0
3915
3867
  */
3916
- var EncodingErrorTypeId = "~effect/encoding/EncodingError";
3868
+ var EncodingErrorTypeId = "~effect/Encoding/EncodingError";
3917
3869
  /**
3918
3870
  * Error returned when an encoding or decoding operation cannot process its
3919
3871
  * input.
@@ -4043,6 +3995,8 @@ var decodeBase64 = (str) => {
4043
3995
  * Generates a random lowercase hexadecimal string, optimized for lengths that
4044
3996
  * are multiples of 8.
4045
3997
  *
3998
+ * **Details**
3999
+ *
4046
4000
  * `length` is not validated. The function generates `length >>> 3` random
4047
4001
  * 8-character words, so non-negative lengths below `2 ** 32` are rounded down
4048
4002
  * to a multiple of 8 and other values follow JavaScript's unsigned 32-bit
@@ -4056,12 +4010,33 @@ var decodeBase64 = (str) => {
4056
4010
  * @since 4.0.0
4057
4011
  */
4058
4012
  var randomHex = (length) => {
4059
- let result = "";
4060
- for (let i = length >>> 3; i > 0; i--) {
4061
- const word = Math.random() * 4294967296 >>> 0;
4062
- result += byteToHex[word >>> 24] + byteToHex[word >>> 16 & 255] + byteToHex[word >>> 8 & 255] + byteToHex[word & 255];
4013
+ switch (length) {
4014
+ case 16: return randomHex16();
4015
+ case 32: return randomHex32();
4016
+ default: {
4017
+ let result = "";
4018
+ for (let i = length >>> 3; i > 0; i--) result += randomHex8();
4019
+ return result;
4020
+ }
4063
4021
  }
4064
- return result;
4022
+ };
4023
+ var hexCharCodes = /*#__PURE__*/ Uint8Array.from("0123456789abcdef", (c) => c.charCodeAt(0));
4024
+ var randomWord = () => Math.random() * 4294967296 >>> 0;
4025
+ var randomHex8 = () => {
4026
+ const a = randomWord();
4027
+ return String.fromCharCode(hexCharCodes[a >>> 28], hexCharCodes[a >>> 24 & 15], hexCharCodes[a >>> 20 & 15], hexCharCodes[a >>> 16 & 15], hexCharCodes[a >>> 12 & 15], hexCharCodes[a >>> 8 & 15], hexCharCodes[a >>> 4 & 15], hexCharCodes[a & 15]);
4028
+ };
4029
+ var randomHex16 = () => {
4030
+ const a = randomWord();
4031
+ const b = randomWord();
4032
+ return String.fromCharCode(hexCharCodes[a >>> 28], hexCharCodes[a >>> 24 & 15], hexCharCodes[a >>> 20 & 15], hexCharCodes[a >>> 16 & 15], hexCharCodes[a >>> 12 & 15], hexCharCodes[a >>> 8 & 15], hexCharCodes[a >>> 4 & 15], hexCharCodes[a & 15], hexCharCodes[b >>> 28], hexCharCodes[b >>> 24 & 15], hexCharCodes[b >>> 20 & 15], hexCharCodes[b >>> 16 & 15], hexCharCodes[b >>> 12 & 15], hexCharCodes[b >>> 8 & 15], hexCharCodes[b >>> 4 & 15], hexCharCodes[b & 15]);
4033
+ };
4034
+ var randomHex32 = () => {
4035
+ const a = randomWord();
4036
+ const b = randomWord();
4037
+ const c = randomWord();
4038
+ const d = randomWord();
4039
+ return String.fromCharCode(hexCharCodes[a >>> 28], hexCharCodes[a >>> 24 & 15], hexCharCodes[a >>> 20 & 15], hexCharCodes[a >>> 16 & 15], hexCharCodes[a >>> 12 & 15], hexCharCodes[a >>> 8 & 15], hexCharCodes[a >>> 4 & 15], hexCharCodes[a & 15], hexCharCodes[b >>> 28], hexCharCodes[b >>> 24 & 15], hexCharCodes[b >>> 20 & 15], hexCharCodes[b >>> 16 & 15], hexCharCodes[b >>> 12 & 15], hexCharCodes[b >>> 8 & 15], hexCharCodes[b >>> 4 & 15], hexCharCodes[b & 15], hexCharCodes[c >>> 28], hexCharCodes[c >>> 24 & 15], hexCharCodes[c >>> 20 & 15], hexCharCodes[c >>> 16 & 15], hexCharCodes[c >>> 12 & 15], hexCharCodes[c >>> 8 & 15], hexCharCodes[c >>> 4 & 15], hexCharCodes[c & 15], hexCharCodes[d >>> 28], hexCharCodes[d >>> 24 & 15], hexCharCodes[d >>> 20 & 15], hexCharCodes[d >>> 16 & 15], hexCharCodes[d >>> 12 & 15], hexCharCodes[d >>> 8 & 15], hexCharCodes[d >>> 4 & 15], hexCharCodes[d & 15]);
4065
4040
  };
4066
4041
  var encoder = /*#__PURE__*/ new TextEncoder();
4067
4042
  var stripCrlf = (str) => str.replace(/[\n\r]/g, "");
@@ -4285,10 +4260,8 @@ var base64codes = [
4285
4260
  50,
4286
4261
  51
4287
4262
  ];
4288
- var byteToHex = [];
4289
- for (let i = 0; i < 256; i++) byteToHex.push(i.toString(16).padStart(2, "0"));
4290
4263
  //#endregion
4291
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/Tracer.js
4264
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/Tracer.js
4292
4265
  /**
4293
4266
  * Defines the low-level tracing model used by Effect.
4294
4267
  *
@@ -4475,18 +4448,34 @@ var TracerKey = "effect/Tracer";
4475
4448
  */
4476
4449
  var Tracer = /*#__PURE__*/ Reference(TracerKey, {
4477
4450
  fiberCached: true,
4478
- defaultValue: () => make$9({ span: (options) => new NativeSpan(options) })
4451
+ defaultValue: () => nativeTracer
4479
4452
  });
4480
4453
  /**
4454
+ * The default `Tracer` implementation backing the `Tracer` reference. It
4455
+ * creates in-memory `NativeSpan` instances and does not export them anywhere.
4456
+ *
4457
+ * **Details**
4458
+ *
4459
+ * Runtime code can compare the active tracer against `nativeTracer` to detect
4460
+ * that no tracing backend is installed and skip work that only a backend could
4461
+ * observe, such as recording span attributes.
4462
+ *
4463
+ * @category references
4464
+ * @since 4.0.0
4465
+ */
4466
+ var nativeTracer = /*#__PURE__*/ make$9({ span: (options) => new NativeSpan(options) });
4467
+ /**
4481
4468
  * Default in-memory `Span` implementation used by the native tracer. It
4482
4469
  * generates span and trace identifiers, stores attributes, events, and links,
4483
4470
  * and records `Started` or `Ended` status.
4484
4471
  *
4485
4472
  * **Details**
4486
4473
  *
4487
- * The constructor initializes the span with `Started` status, inherits the
4488
- * parent trace id or generates a new one, and always generates a new span id.
4489
- * Attributes, events, links, and status are then mutated through `Span` methods.
4474
+ * The constructor initializes the span with `Started` status. Trace and span
4475
+ * identifiers, the attribute map, and the event list are created lazily on
4476
+ * first access, so spans that are never inspected allocate as little as
4477
+ * possible. Attributes, events, links, and status are mutated through `Span`
4478
+ * methods.
4490
4479
  *
4491
4480
  * @see {@link Span} for the interface implemented by native spans
4492
4481
  *
@@ -4495,8 +4484,6 @@ var Tracer = /*#__PURE__*/ Reference(TracerKey, {
4495
4484
  */
4496
4485
  var NativeSpan = class {
4497
4486
  _tag = "Span";
4498
- spanId;
4499
- traceId = "native";
4500
4487
  sampled;
4501
4488
  name;
4502
4489
  parent;
@@ -4505,8 +4492,10 @@ var NativeSpan = class {
4505
4492
  startTime;
4506
4493
  kind;
4507
4494
  status;
4508
- attributes;
4509
- events = [];
4495
+ _traceId = void 0;
4496
+ _spanId = void 0;
4497
+ _attributes = void 0;
4498
+ _events = void 0;
4510
4499
  constructor(options) {
4511
4500
  this.name = options.name;
4512
4501
  this.parent = options.parent;
@@ -4519,9 +4508,18 @@ var NativeSpan = class {
4519
4508
  _tag: "Started",
4520
4509
  startTime: options.startTime
4521
4510
  };
4522
- this.attributes = /* @__PURE__ */ new Map();
4523
- this.traceId = getOrUndefined$1(options.parent)?.traceId ?? randomHex(32);
4524
- this.spanId = randomHex(16);
4511
+ }
4512
+ get traceId() {
4513
+ return this._traceId ??= getOrUndefined$1(this.parent)?.traceId ?? randomHex(32);
4514
+ }
4515
+ get spanId() {
4516
+ return this._spanId ??= randomHex(16);
4517
+ }
4518
+ get attributes() {
4519
+ return this._attributes ??= /* @__PURE__ */ new Map();
4520
+ }
4521
+ get events() {
4522
+ return this._events ??= [];
4525
4523
  }
4526
4524
  end(endTime, exit) {
4527
4525
  this.status = {
@@ -4546,18 +4544,21 @@ var NativeSpan = class {
4546
4544
  }
4547
4545
  };
4548
4546
  //#endregion
4549
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/internal/metric.js
4547
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/internal/metric.js
4550
4548
  /** @internal */
4551
- var FiberRuntimeMetricsKey = "effect/observability/Metric/FiberRuntimeMetricsKey";
4549
+ var FiberRuntimeMetricsKey = "effect/Metric/FiberRuntimeMetrics";
4552
4550
  //#endregion
4553
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/internal/references.js
4551
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/internal/references.js
4554
4552
  /** @internal */
4555
4553
  var CurrentStackFrame = /*#__PURE__*/ Reference("effect/References/CurrentStackFrame", {
4556
4554
  fiberCached: true,
4557
4555
  defaultValue: constUndefined
4558
4556
  });
4559
4557
  /** @internal */
4560
- var TracerEnabled = /*#__PURE__*/ Reference("effect/References/TracerEnabled", { defaultValue: constTrue });
4558
+ var TracerEnabled = /*#__PURE__*/ Reference("effect/References/TracerEnabled", {
4559
+ fiberCached: true,
4560
+ defaultValue: constTrue
4561
+ });
4561
4562
  /** @internal */
4562
4563
  var TracerTimingEnabled = /*#__PURE__*/ Reference("effect/References/TracerTimingEnabled", { defaultValue: constTrue });
4563
4564
  /** @internal */
@@ -4579,44 +4580,16 @@ var MinimumLogLevel = /*#__PURE__*/ Reference("effect/References/MinimumLogLevel
4579
4580
  /** @internal */
4580
4581
  var CurrentLogSpans = /*#__PURE__*/ Reference("effect/References/CurrentLogSpans", { defaultValue: () => [] });
4581
4582
  //#endregion
4582
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/internal/stackTraceLimit.js
4583
- /**
4584
- * Check if `Error.stackTraceLimit` is writable.
4585
- * Returns `false` if the property is frozen, non-writable, or `Error` is non-extensible.
4586
- *
4587
- * @internal
4588
- */
4589
- var isStackTraceLimitWritable = () => {
4590
- const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
4591
- if (desc === void 0) return Object.isExtensible(Error);
4592
- return Object.hasOwn(desc, "writable") ? desc.writable === true : desc.set !== void 0;
4593
- };
4594
- var canWriteStackTraceLimit = /*#__PURE__*/ isStackTraceLimitWritable();
4595
- /**
4596
- * Get the current `Error.stackTraceLimit` value.
4597
- * Returns `undefined` if the property doesn't exist.
4598
- *
4599
- * @internal
4600
- */
4601
- var getStackTraceLimit = () => Error.stackTraceLimit;
4602
- /**
4603
- * Safely set `Error.stackTraceLimit` if possible, otherwise no-op.
4604
- *
4605
- * Accepts `undefined` so a value read via {@link getStackTraceLimit} can be
4606
- * restored faithfully.
4607
- *
4608
- * @internal
4609
- */
4610
- var setStackTraceLimit = (value) => {
4611
- if (canWriteStackTraceLimit) Error.stackTraceLimit = value;
4612
- };
4613
- //#endregion
4614
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/internal/tracer.js
4583
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/internal/tracer.js
4615
4584
  /** @internal */
4616
4585
  var addSpanStackTrace = (options) => {
4617
4586
  if (options?.captureStackTrace === false) return options;
4618
4587
  else if (options?.captureStackTrace !== void 0 && typeof options.captureStackTrace !== "boolean") return options;
4619
4588
  const limit = getStackTraceLimit();
4589
+ if (limit === 0 && options?.captureStackTrace !== true) return {
4590
+ ...options,
4591
+ captureStackTrace: false
4592
+ };
4620
4593
  setStackTraceLimit(3);
4621
4594
  const traceError = /* @__PURE__ */ new Error();
4622
4595
  setStackTraceLimit(limit);
@@ -4641,10 +4614,9 @@ var makeStackCleaner = (line) => (stack) => {
4641
4614
  };
4642
4615
  var spanCleaner = /*#__PURE__*/ makeStackCleaner(3);
4643
4616
  //#endregion
4644
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/internal/effect.js
4617
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/internal/effect.js
4645
4618
  /** @internal */
4646
4619
  var Interrupt = class extends ReasonBase {
4647
- fiberId;
4648
4620
  constructor(fiberId, annotations = constEmptyAnnotations) {
4649
4621
  super("Interrupt", annotations, "Interrupted");
4650
4622
  this.fiberId = fiberId;
@@ -4697,11 +4669,24 @@ var causeFilterInterruptors = (self) => {
4697
4669
  };
4698
4670
  /** @internal */
4699
4671
  var hasInterruptsOnly$1 = (self) => self.reasons.length > 0 && self.reasons.every(isInterruptReason);
4672
+ var dedupeReasons = (self, that) => {
4673
+ const buckets = /* @__PURE__ */ new Map();
4674
+ const out = [];
4675
+ for (const reason of self.concat(that)) {
4676
+ const hash$1 = hash(reason);
4677
+ const bucket = buckets.get(hash$1);
4678
+ if (bucket === void 0) buckets.set(hash$1, [reason]);
4679
+ else if (bucket.some((previous) => equals$1(previous, reason))) continue;
4680
+ else bucket.push(reason);
4681
+ out.push(reason);
4682
+ }
4683
+ return out;
4684
+ };
4700
4685
  /** @internal */
4701
4686
  var causeCombine = /*#__PURE__*/ dual(2, (self, that) => {
4702
4687
  if (self.reasons.length === 0) return that;
4703
4688
  else if (that.reasons.length === 0) return self;
4704
- const newCause = new CauseImpl(union(self.reasons, that.reasons));
4689
+ const newCause = new CauseImpl(dedupeReasons(self.reasons, that.reasons));
4705
4690
  return equals$1(self, newCause) ? self : newCause;
4706
4691
  });
4707
4692
  /** @internal */
@@ -4740,7 +4725,7 @@ var causePrettyErrors = (self, options) => {
4740
4725
  const interrupts = [];
4741
4726
  if (self.reasons.length === 0) return errors;
4742
4727
  const prevStackLimit = getStackTraceLimit();
4743
- setStackTraceLimit(1);
4728
+ if (prevStackLimit !== 0) setStackTraceLimit(1);
4744
4729
  for (const failure of self.reasons) {
4745
4730
  if (failure._tag === "Interrupt") {
4746
4731
  interrupts.push(failure);
@@ -4757,7 +4742,7 @@ var causePrettyErrors = (self, options) => {
4757
4742
  error.stack = `${error.name}: ${error.message}`;
4758
4743
  errors.push(causePrettyError(error, interrupts[0].annotations, options));
4759
4744
  }
4760
- setStackTraceLimit(prevStackLimit);
4745
+ if (prevStackLimit !== 0) setStackTraceLimit(prevStackLimit);
4761
4746
  return errors;
4762
4747
  };
4763
4748
  /** @internal */
@@ -4858,14 +4843,15 @@ var FiberImpl = class {
4858
4843
  this.currentOpCount = 0;
4859
4844
  this.interruptible = interruptible;
4860
4845
  this._stack = [];
4861
- this._observers = [];
4846
+ this._observers = void 0;
4862
4847
  this._exit = void 0;
4863
4848
  this._children = void 0;
4864
4849
  this._interruptedCause = void 0;
4865
4850
  this._yielded = void 0;
4866
4851
  this._running = false;
4867
4852
  this._deferredInterrupt = false;
4868
- this.runtimeMetrics?.recordFiberStart(this.context);
4853
+ this._parent = void 0;
4854
+ this.cache.runtimeMetrics?.recordFiberStart(this.context);
4869
4855
  }
4870
4856
  [FiberTypeId];
4871
4857
  id;
@@ -4879,19 +4865,12 @@ var FiberImpl = class {
4879
4865
  _yielded;
4880
4866
  _running;
4881
4867
  _deferredInterrupt;
4868
+ _parent;
4882
4869
  context;
4883
- currentScheduler;
4884
- currentTracerContext;
4885
- currentSpan;
4886
- currentLogLevel;
4887
- minimumLogLevel;
4888
- currentStackFrame;
4889
- runtimeMetrics;
4890
- maxOpsBeforeYield;
4891
- currentPreventYield;
4870
+ cache;
4892
4871
  _dispatcher = void 0;
4893
4872
  get currentDispatcher() {
4894
- return this._dispatcher ??= this.currentScheduler.makeDispatcher();
4873
+ return this._dispatcher ??= this.cache.scheduler.makeDispatcher();
4895
4874
  }
4896
4875
  getRef(ref) {
4897
4876
  return get$4(this.context, ref);
@@ -4901,9 +4880,10 @@ var FiberImpl = class {
4901
4880
  cb(this._exit);
4902
4881
  return constVoid;
4903
4882
  }
4904
- this._observers.push(cb);
4883
+ if (this._observers === void 0) this._observers = [cb];
4884
+ else this._observers.push(cb);
4905
4885
  return () => {
4906
- if (this._exit) return;
4886
+ if (this._exit || this._observers === void 0) return;
4907
4887
  const index = this._observers.indexOf(cb);
4908
4888
  if (index >= 0) this._observers.splice(index, 1);
4909
4889
  };
@@ -4911,7 +4891,7 @@ var FiberImpl = class {
4911
4891
  interruptUnsafe(fiberId, annotations) {
4912
4892
  if (this._exit) return;
4913
4893
  let cause = causeInterrupt(fiberId);
4914
- if (this.currentStackFrame) cause = causeAnnotate(cause, make$11(StackTraceKey, this.currentStackFrame));
4894
+ if (this.cache.stackFrame) cause = causeAnnotate(cause, make$11(StackTraceKey, this.cache.stackFrame));
4915
4895
  if (annotations) cause = causeAnnotate(cause, annotations);
4916
4896
  this._interruptedCause = this._interruptedCause ? causeCombine(this._interruptedCause, cause) : cause;
4917
4897
  if (this.interruptible) {
@@ -4934,9 +4914,16 @@ var FiberImpl = class {
4934
4914
  const interruptChildren = fiberMiddleware.interruptChildren && fiberMiddleware.interruptChildren(this);
4935
4915
  if (interruptChildren !== void 0) return this.evaluate(flatMap$1(interruptChildren, () => exit));
4936
4916
  this._exit = exit;
4937
- this.runtimeMetrics?.recordFiberEnd(this.context, this._exit);
4938
- for (let i = 0; i < this._observers.length; i++) this._observers[i](exit);
4939
- this._observers.length = 0;
4917
+ this.cache.runtimeMetrics?.recordFiberEnd(this.context, this._exit);
4918
+ if (this._parent) {
4919
+ this._parent._children?.delete(this);
4920
+ this._parent = void 0;
4921
+ }
4922
+ if (this._observers !== void 0) {
4923
+ const observers = this._observers;
4924
+ this._observers = void 0;
4925
+ for (let i = 0; i < observers.length; i++) observers[i](exit);
4926
+ }
4940
4927
  this._stack.length = 0;
4941
4928
  this._children = void 0;
4942
4929
  this.context = empty$4();
@@ -4956,12 +4943,13 @@ var FiberImpl = class {
4956
4943
  current = failCause$5(this._interruptedCause);
4957
4944
  }
4958
4945
  this.currentOpCount++;
4959
- if (!yielding && !this.currentPreventYield && this.currentScheduler.shouldYield(this)) {
4946
+ const cache = this.cache;
4947
+ if (!yielding && !cache.preventYield && cache.scheduler.shouldYield(this)) {
4960
4948
  yielding = true;
4961
4949
  const prev = current;
4962
4950
  current = flatMap$1(yieldNow$1, () => prev);
4963
4951
  }
4964
- current = this.currentTracerContext ? this.currentTracerContext(current, this) : current[evaluate](this);
4952
+ current = cache.tracerContext ? cache.tracerContext(current, this) : current[evaluate](this);
4965
4953
  if (current === Yield) {
4966
4954
  const yielded = this._yielded;
4967
4955
  if (ExitTypeId in yielded) {
@@ -4992,10 +4980,13 @@ var FiberImpl = class {
4992
4980
  while (true) {
4993
4981
  const op = this._stack.pop();
4994
4982
  if (!op) return void 0;
4995
- const cont = op[contAll] && op[contAll](this);
4996
- if (cont) {
4997
- cont[symbol] = cont;
4998
- return cont;
4983
+ const all = op[contAll];
4984
+ if (all !== void 0) {
4985
+ const cont = all.call(op, this);
4986
+ if (cont) {
4987
+ cont[symbol] = cont;
4988
+ return cont;
4989
+ }
4999
4990
  }
5000
4991
  if (op[symbol]) return op;
5001
4992
  }
@@ -5014,25 +5005,32 @@ var FiberImpl = class {
5014
5005
  const previous = this.context;
5015
5006
  this.context = context;
5016
5007
  if (previous !== void 0 && hasSameCache(previous, context)) return;
5017
- const scheduler = this.getRef(Scheduler);
5018
- if (scheduler !== this.currentScheduler) {
5019
- this.currentScheduler = scheduler;
5020
- this._dispatcher = void 0;
5021
- }
5022
- this.currentSpan = getOrUndefinedUnsafe(context, ParentSpanKey);
5023
- this.currentLogLevel = this.getRef(CurrentLogLevel);
5024
- this.minimumLogLevel = this.getRef(MinimumLogLevel);
5025
- this.currentStackFrame = this.getRef(CurrentStackFrame);
5026
- this.maxOpsBeforeYield = this.getRef(MaxOpsBeforeYield);
5027
- this.currentPreventYield = this.getRef(PreventSchedulerYield);
5028
- this.runtimeMetrics = getOrUndefinedUnsafe(context, FiberRuntimeMetricsKey);
5029
- const currentTracer = getOrUndefinedUnsafe(context, TracerKey);
5030
- this.currentTracerContext = currentTracer ? currentTracer["context"] : void 0;
5008
+ const root = context.cacheRoot;
5009
+ const cache = root._fiberCache ??= makeFiberContextCache(context);
5010
+ if (this.cache !== void 0 && this.cache.scheduler !== cache.scheduler) this._dispatcher = void 0;
5011
+ this.cache = cache;
5031
5012
  }
5032
5013
  get currentSpanLocal() {
5033
- return this.currentSpan?._tag === "Span" ? this.currentSpan : void 0;
5014
+ const span = this.cache.span;
5015
+ return span?._tag === "Span" ? span : void 0;
5034
5016
  }
5035
5017
  };
5018
+ var makeFiberContextCache = (context) => {
5019
+ const currentTracer = getOrUndefinedUnsafe(context, TracerKey);
5020
+ return {
5021
+ scheduler: get$4(context, Scheduler),
5022
+ tracer: currentTracer,
5023
+ tracerContext: currentTracer ? currentTracer["context"] : void 0,
5024
+ tracerEnabled: get$4(context, TracerEnabled),
5025
+ span: getOrUndefinedUnsafe(context, ParentSpanKey),
5026
+ logLevel: get$4(context, CurrentLogLevel),
5027
+ minimumLogLevel: get$4(context, MinimumLogLevel),
5028
+ stackFrame: get$4(context, CurrentStackFrame),
5029
+ runtimeMetrics: getOrUndefinedUnsafe(context, FiberRuntimeMetricsKey),
5030
+ maxOpsBeforeYield: get$4(context, MaxOpsBeforeYield),
5031
+ preventYield: get$4(context, PreventSchedulerYield)
5032
+ };
5033
+ };
5036
5034
  var deferredInterruptCont = {
5037
5035
  [contA](_value, fiber) {
5038
5036
  return failCause$5(fiber._interruptedCause);
@@ -5043,9 +5041,9 @@ var deferredInterruptCont = {
5043
5041
  };
5044
5042
  var fiberMiddleware = { interruptChildren: void 0 };
5045
5043
  var fiberStackAnnotations = (fiber) => {
5046
- if (!fiber.currentStackFrame) return void 0;
5044
+ if (!fiber.cache.stackFrame) return void 0;
5047
5045
  const annotations = /* @__PURE__ */ new Map();
5048
- annotations.set(InterruptorStackTrace$1.key, fiber.currentStackFrame);
5046
+ annotations.set(InterruptorStackTrace$1.key, fiber.cache.stackFrame);
5049
5047
  return makeUnsafe$4(annotations);
5050
5048
  };
5051
5049
  var fiberInterruptChildren = (fiber) => {
@@ -5229,34 +5227,43 @@ var tryPromise$1 = (options) => {
5229
5227
  };
5230
5228
  /** @internal */
5231
5229
  var withFiberId = (f) => withFiber$1((fiber) => f(fiber.id));
5232
- var callbackOptions = /*#__PURE__*/ makePrimitive({
5233
- op: "Async",
5234
- single: false,
5235
- [evaluate](fiber) {
5236
- const register = internalCall(() => this[args][0].bind(fiber.currentScheduler));
5237
- let resumed = false;
5238
- let yielded = false;
5239
- const controller = this[args][1] ? new AbortController() : void 0;
5240
- const onCancel = register((effect) => {
5241
- if (resumed) return;
5242
- resumed = true;
5243
- if (yielded) fiber.evaluate(effect);
5244
- else yielded = effect;
5245
- }, controller?.signal);
5246
- if (yielded !== false) return yielded;
5247
- yielded = true;
5248
- fiber._yielded = () => {
5249
- resumed = true;
5250
- };
5251
- if (controller === void 0 && onCancel === void 0) return Yield;
5252
- fiber._stack.push(asyncFinalizer(() => {
5253
- resumed = true;
5254
- controller?.abort();
5255
- return onCancel ?? exitVoid;
5256
- }));
5257
- return Yield;
5258
- }
5259
- });
5230
+ var callbackOptions = /*#__PURE__*/ function() {
5231
+ const Proto = /*#__PURE__*/ makePrimitiveProto({
5232
+ op: "Async",
5233
+ [evaluate](fiber) {
5234
+ const register = internalCall(() => this.register.bind(fiber.cache.scheduler));
5235
+ let resumed = false;
5236
+ let yielded = false;
5237
+ const controller = this.withSignal ? new AbortController() : void 0;
5238
+ const onCancel = register((effect) => {
5239
+ if (resumed) return;
5240
+ resumed = true;
5241
+ if (yielded) fiber.evaluate(effect);
5242
+ else yielded = effect;
5243
+ }, controller?.signal);
5244
+ if (yielded !== false) return yielded;
5245
+ yielded = true;
5246
+ fiber._yielded = () => {
5247
+ resumed = true;
5248
+ };
5249
+ if (controller === void 0 && onCancel === void 0) return Yield;
5250
+ fiber._stack.push(asyncFinalizer(() => {
5251
+ resumed = true;
5252
+ controller?.abort();
5253
+ return onCancel ?? exitVoid;
5254
+ }));
5255
+ return Yield;
5256
+ }
5257
+ });
5258
+ const AsyncImpl = function(register, withSignal) {
5259
+ this.register = register;
5260
+ this.withSignal = withSignal;
5261
+ };
5262
+ AsyncImpl.prototype = Proto;
5263
+ return function(register, withSignal) {
5264
+ return new AsyncImpl(register, withSignal);
5265
+ };
5266
+ }();
5260
5267
  var asyncFinalizer = /*#__PURE__*/ makePrimitive({
5261
5268
  op: "AsyncFinalizer",
5262
5269
  [contAll](fiber) {
@@ -5274,7 +5281,14 @@ var callback$2 = (register) => callbackOptions(register, register.length >= 2);
5274
5281
  /** @internal */
5275
5282
  var never$3 = /*#__PURE__*/ callback$2(constVoid);
5276
5283
  /** @internal */
5277
- var gen$1 = (...args) => suspend$3(() => fromIteratorUnsafe(args.length === 1 ? args[0]() : args[1].call(args[0].self)));
5284
+ var gen$1 = (...args) => {
5285
+ if (args.length === 1) {
5286
+ const body = args[0];
5287
+ return suspend$3(() => fromIteratorUnsafe(body()));
5288
+ }
5289
+ const [options, body] = args;
5290
+ return suspend$3(() => fromIteratorUnsafe(body.call(options.self)));
5291
+ };
5278
5292
  /** @internal */
5279
5293
  var fnUntraced$1 = (body, ...pipeables) => {
5280
5294
  const fn = pipeables.length === 0 ? function() {
@@ -5297,9 +5311,12 @@ var fn$1 = function() {
5297
5311
  const name = nameFirst ? arguments[0] : "Effect.fn";
5298
5312
  const spanOptions = nameFirst ? arguments[1] : void 0;
5299
5313
  const prevLimit = getStackTraceLimit();
5300
- setStackTraceLimit(2);
5301
- const defError = new globalThis.Error();
5302
- setStackTraceLimit(prevLimit);
5314
+ let defError;
5315
+ if (prevLimit !== 0) {
5316
+ setStackTraceLimit(2);
5317
+ defError = new globalThis.Error();
5318
+ setStackTraceLimit(prevLimit);
5319
+ }
5303
5320
  if (nameFirst) return (body, ...pipeables) => makeFn(name, body, defError, pipeables, nameFirst, spanOptions);
5304
5321
  return makeFn(name, arguments[0], defError, Array.prototype.slice.call(arguments, 1), nameFirst, spanOptions);
5305
5322
  };
@@ -5313,15 +5330,18 @@ var makeFn = (name, bodyOrOptions, defError, pipeables, addSpan, spanOptions) =>
5313
5330
  for (let i = 0; i < pipeables.length; i++) result = pipeables[i](result, ...args);
5314
5331
  if (!isEffect$1(result)) return result;
5315
5332
  const prevLimit = getStackTraceLimit();
5316
- setStackTraceLimit(2);
5317
- const callError = new globalThis.Error();
5318
- setStackTraceLimit(prevLimit);
5333
+ let callError;
5334
+ if (prevLimit !== 0) {
5335
+ setStackTraceLimit(2);
5336
+ callError = new globalThis.Error();
5337
+ setStackTraceLimit(prevLimit);
5338
+ }
5319
5339
  return updateService(addSpan ? useSpan$1(name, spanOptions, (span) => provideParentSpan(result, span)) : result, CurrentStackFrame, (prev) => ({
5320
5340
  name,
5321
- stack: fnStackCleaner(() => callError.stack),
5341
+ stack: callError ? fnStackCleaner(() => callError.stack) : constUndefined,
5322
5342
  parent: {
5323
5343
  name: `${name} (definition)`,
5324
- stack: fnStackCleaner(() => defError.stack),
5344
+ stack: defError ? fnStackCleaner(() => defError.stack) : constUndefined,
5325
5345
  parent: prev
5326
5346
  }
5327
5347
  }));
@@ -5332,7 +5352,7 @@ var fnUntracedEager$1 = (body, ...pipeables) => defineFunctionLength(body.length
5332
5352
  return fromIteratorEagerUnsafe(() => body.apply(this, arguments));
5333
5353
  } : function() {
5334
5354
  let effect = fromIteratorEagerUnsafe(() => body.apply(this, arguments));
5335
- for (const pipeable of pipeables) effect = pipeable(effect);
5355
+ for (const pipeable of pipeables) effect = pipeable(effect, ...arguments);
5336
5356
  return effect;
5337
5357
  });
5338
5358
  var fromIteratorEagerUnsafe = (evaluate) => {
@@ -5361,38 +5381,81 @@ var fromIteratorEagerUnsafe = (evaluate) => {
5361
5381
  return die$1(error);
5362
5382
  }
5363
5383
  };
5364
- var fromIteratorUnsafe = /*#__PURE__*/ makePrimitive({
5365
- op: "Iterator",
5366
- single: false,
5367
- [contA](value, fiber) {
5368
- const iter = this[args][0];
5369
- while (true) {
5370
- const state = iter.next(value);
5371
- if (state.done) return succeed$5(state.value);
5372
- if (!effectIsExit(state.value)) {
5373
- fiber._stack.push(this);
5374
- return state.value;
5375
- } else if (state.value._tag === "Failure") return state.value;
5376
- value = state.value.value;
5384
+ var fromIteratorUnsafe = /*#__PURE__*/ function() {
5385
+ const Proto = /*#__PURE__*/ makePrimitiveProto({
5386
+ op: "Iterator",
5387
+ [contA](value, fiber) {
5388
+ const iter = this.iterator;
5389
+ while (true) {
5390
+ const state = iter.next(value);
5391
+ if (state.done) return succeed$5(state.value);
5392
+ if (!effectIsExit(state.value)) {
5393
+ fiber._stack.push(this);
5394
+ return state.value;
5395
+ } else if (state.value._tag === "Failure") return state.value;
5396
+ value = state.value.value;
5397
+ }
5398
+ },
5399
+ [evaluate](fiber) {
5400
+ return this[contA](this.initial, fiber);
5377
5401
  }
5378
- },
5379
- [evaluate](fiber) {
5380
- return this[contA](this[args][1], fiber);
5381
- }
5382
- });
5402
+ });
5403
+ const IteratorImpl = function(iterator, initial) {
5404
+ this.iterator = iterator;
5405
+ this.initial = initial;
5406
+ };
5407
+ IteratorImpl.prototype = Proto;
5408
+ return function(iterator, initial) {
5409
+ return new IteratorImpl(iterator, initial);
5410
+ };
5411
+ }();
5383
5412
  /** @internal */
5384
- var as$1 = /*#__PURE__*/ dual(2, (self, value) => {
5385
- const b = succeed$5(value);
5386
- return flatMap$1(self, (_) => b);
5413
+ var as$1 = /*#__PURE__*/ dual(2, (self, value) => new ContImpl(self, returnPayload, succeed$5(value)));
5414
+ var evaluateCont = function(fiber) {
5415
+ fiber._stack.push(this);
5416
+ return this[args];
5417
+ };
5418
+ var OnSuccessProto = /*#__PURE__*/ makePrimitiveProto({
5419
+ op: "OnSuccess",
5420
+ [evaluate]: evaluateCont
5387
5421
  });
5422
+ var OnSuccessImpl = function(self, f) {
5423
+ this[args] = self;
5424
+ this[contA] = f;
5425
+ };
5426
+ OnSuccessImpl.prototype = OnSuccessProto;
5427
+ var ContImpl = function(self, cont, payload) {
5428
+ this[args] = self;
5429
+ this[contA] = cont;
5430
+ this.payload = payload;
5431
+ };
5432
+ ContImpl.prototype = OnSuccessProto;
5433
+ var returnPayload = function() {
5434
+ return this.payload;
5435
+ };
5436
+ var mapCont = function(value) {
5437
+ const f = this.payload;
5438
+ return succeed$5(internalCall(() => f(value)));
5439
+ };
5440
+ var andThenCont = function(value) {
5441
+ const f = this.payload;
5442
+ return internalCall(() => f(value));
5443
+ };
5444
+ var tapCont = function(value) {
5445
+ const f = this.payload;
5446
+ return new ContImpl(internalCall(() => f(value)), returnPayload, exitSucceed(value));
5447
+ };
5448
+ var tapEffectCont = function(value) {
5449
+ return new ContImpl(this.payload, returnPayload, exitSucceed(value));
5450
+ };
5388
5451
  /** @internal */
5389
5452
  var asSome$1 = (self) => map$4(self, some);
5390
5453
  /** @internal */
5391
- var andThen$1 = /*#__PURE__*/ dual(2, (self, f) => flatMap$1(self, (a) => isEffect$1(f) ? f : internalCall(() => f(a))));
5454
+ var andThen$1 = /*#__PURE__*/ dual(2, (self, f) => new ContImpl(self, isEffect$1(f) ? returnPayload : andThenCont, f));
5392
5455
  /** @internal */
5393
- var tap$2 = /*#__PURE__*/ dual(2, (self, f) => flatMap$1(self, (a) => as$1(isEffect$1(f) ? f : internalCall(() => f(a)), a)));
5456
+ var tap$2 = /*#__PURE__*/ dual(2, (self, f) => new ContImpl(self, isEffect$1(f) ? tapEffectCont : tapCont, f));
5394
5457
  /** @internal */
5395
- var asVoid$1 = (self) => flatMap$1(self, (_) => exitVoid);
5458
+ var asVoid$1 = (self) => new ContImpl(self, returnPayload, exitVoid);
5396
5459
  /** @internal */
5397
5460
  var raceAll = (all, options) => withFiber$1((parent) => callback$2((resume) => {
5398
5461
  const effects = fromIterable(all);
@@ -5460,21 +5523,9 @@ var race$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[1]), (self, that, opti
5460
5523
  /** @internal */
5461
5524
  var raceFirst$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[1]), (self, that, options) => raceAllFirst([self, that], options));
5462
5525
  /** @internal */
5463
- var flatMap$1 = /*#__PURE__*/ dual(2, (self, f) => {
5464
- const onSuccess = Object.create(OnSuccessProto);
5465
- onSuccess[args] = self;
5466
- onSuccess[contA] = f.length !== 1 ? (a) => f(a) : f;
5467
- return onSuccess;
5468
- });
5469
- var OnSuccessProto = /*#__PURE__*/ makePrimitiveProto({
5470
- op: "OnSuccess",
5471
- [evaluate](fiber) {
5472
- fiber._stack.push(this);
5473
- return this[args];
5474
- }
5475
- });
5526
+ var flatMap$1 = /*#__PURE__*/ dual(2, (self, f) => new OnSuccessImpl(self, f.length !== 1 ? (a) => f(a) : f));
5476
5527
  /** @internal */
5477
- var effectIsExit = (effect) => ExitTypeId in effect;
5528
+ var effectIsExit = (effect) => effect[ExitTypeId] !== void 0;
5478
5529
  /** @internal */
5479
5530
  var flatMapEager$1 = /*#__PURE__*/ dual(2, (self, f) => {
5480
5531
  if (effectIsExit(self)) return self._tag === "Success" ? f(self.value) : self;
@@ -5483,7 +5534,7 @@ var flatMapEager$1 = /*#__PURE__*/ dual(2, (self, f) => {
5483
5534
  /** @internal */
5484
5535
  var flatten$1 = (self) => flatMap$1(self, identity);
5485
5536
  /** @internal */
5486
- var map$4 = /*#__PURE__*/ dual(2, (self, f) => flatMap$1(self, (a) => succeed$5(internalCall(() => f(a)))));
5537
+ var map$4 = /*#__PURE__*/ dual(2, (self, f) => new ContImpl(self, mapCont, f));
5487
5538
  /** @internal */
5488
5539
  var mapEager$1 = /*#__PURE__*/ dual(2, (self, f) => effectIsExit(self) ? exitMap(self, f) : map$4(self, f));
5489
5540
  /** @internal */
@@ -5569,6 +5620,7 @@ var provideService$1 = function() {
5569
5620
  return dual(3, (self, service, impl) => provideServiceImpl(self, service, impl)).apply(this, arguments);
5570
5621
  };
5571
5622
  var provideServiceImpl = (self, service, implementation) => updateContext$1(self, add(service, implementation));
5623
+ /** @internal */
5572
5624
  var filterOrFail$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, predicate, orFailWith) => filterOrElse(self, predicate, orFailWith ? (a) => fail$5(orFailWith(a)) : () => fail$5(new NoSuchElementError$1())));
5573
5625
  /** @internal */
5574
5626
  var when$1 = /*#__PURE__*/ dual(2, (self, condition) => flatMap$1(condition, (pass) => pass ? asSome$1(self) : succeedNone$1));
@@ -5579,19 +5631,16 @@ var forever$2 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, options
5579
5631
  step: constVoid
5580
5632
  }));
5581
5633
  /** @internal */
5582
- var catchCause$3 = /*#__PURE__*/ dual(2, (self, f) => {
5583
- const onFailure = Object.create(OnFailureProto);
5584
- onFailure[args] = self;
5585
- onFailure[contE] = f.length !== 1 ? (cause) => f(cause) : f;
5586
- return onFailure;
5587
- });
5634
+ var catchCause$3 = /*#__PURE__*/ dual(2, (self, f) => new OnFailureImpl(self, f.length !== 1 ? (cause) => f(cause) : f));
5588
5635
  var OnFailureProto = /*#__PURE__*/ makePrimitiveProto({
5589
5636
  op: "OnFailure",
5590
- [evaluate](fiber) {
5591
- fiber._stack.push(this);
5592
- return this[args];
5593
- }
5637
+ [evaluate]: evaluateCont
5594
5638
  });
5639
+ var OnFailureImpl = function(self, f) {
5640
+ this[args] = self;
5641
+ this[contE] = f;
5642
+ };
5643
+ OnFailureImpl.prototype = OnFailureProto;
5595
5644
  /** @internal */
5596
5645
  var catchCauseFilter$1 = /*#__PURE__*/ dual(3, (self, filter, f) => catchCause$3(self, (cause) => {
5597
5646
  const eb = filter(cause);
@@ -5620,6 +5669,7 @@ var catchTag$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, k, f,
5620
5669
  });
5621
5670
  /** @internal */
5622
5671
  var mapError$3 = /*#__PURE__*/ dual(2, (self, f) => catch_$2(self, (error) => failSync(() => f(error))));
5672
+ /** @internal */
5623
5673
  var mapBoth = /*#__PURE__*/ dual(2, (self, options) => matchEffect$2(self, {
5624
5674
  onFailure: (e) => failSync(() => options.onFailure(e)),
5625
5675
  onSuccess: (a) => sync$1(() => options.onSuccess(a))
@@ -5649,20 +5699,17 @@ var result$1 = (self) => matchEager(self, {
5649
5699
  onSuccess: succeed$6
5650
5700
  });
5651
5701
  /** @internal */
5652
- var matchCauseEffect$1 = /*#__PURE__*/ dual(2, (self, options) => {
5653
- const primitive = Object.create(OnSuccessAndFailureProto);
5654
- primitive[args] = self;
5655
- primitive[contA] = options.onSuccess.length !== 1 ? (a) => options.onSuccess(a) : options.onSuccess;
5656
- primitive[contE] = options.onFailure.length !== 1 ? (cause) => options.onFailure(cause) : options.onFailure;
5657
- return primitive;
5658
- });
5702
+ var matchCauseEffect$1 = /*#__PURE__*/ dual(2, (self, options) => new OnSuccessAndFailureImpl(self, options.onSuccess.length !== 1 ? (a) => options.onSuccess(a) : options.onSuccess, options.onFailure.length !== 1 ? (cause) => options.onFailure(cause) : options.onFailure));
5659
5703
  var OnSuccessAndFailureProto = /*#__PURE__*/ makePrimitiveProto({
5660
5704
  op: "OnSuccessAndFailure",
5661
- [evaluate](fiber) {
5662
- fiber._stack.push(this);
5663
- return this[args];
5664
- }
5705
+ [evaluate]: evaluateCont
5665
5706
  });
5707
+ var OnSuccessAndFailureImpl = function(self, onSuccess, onFailure) {
5708
+ this[args] = self;
5709
+ this[contA] = onSuccess;
5710
+ this[contE] = onFailure;
5711
+ };
5712
+ OnSuccessAndFailureImpl.prototype = OnSuccessAndFailureProto;
5666
5713
  /** @internal */
5667
5714
  var matchEffect$2 = /*#__PURE__*/ dual(2, (self, options) => matchCauseEffect$1(self, {
5668
5715
  onFailure: (cause) => {
@@ -5817,30 +5864,40 @@ var acquireRelease$1 = (acquire, release, options) => contextWith$1((context) =>
5817
5864
  /** @internal */
5818
5865
  var addFinalizer$2 = (finalizer) => flatMap$1(scope$1, (scope) => contextWith$1((context) => scopeAddFinalizerExit(scope, (exit) => provideContext$1(finalizer(exit), context))));
5819
5866
  /** @internal */
5820
- var onExitPrimitive = /*#__PURE__*/ makePrimitive({
5821
- op: "OnExit",
5822
- single: false,
5823
- [evaluate](fiber) {
5824
- fiber._stack.push(this);
5825
- return this[args][0];
5826
- },
5827
- [contAll](fiber) {
5828
- if (fiber.interruptible && this[args][2] !== true) {
5829
- fiber._stack.push(setInterruptibleTrue);
5830
- fiber.interruptible = false;
5867
+ var onExitPrimitive = /*#__PURE__*/ function() {
5868
+ const Proto = /*#__PURE__*/ makePrimitiveProto({
5869
+ op: "OnExit",
5870
+ [evaluate](fiber) {
5871
+ fiber._stack.push(this);
5872
+ return this.effect;
5873
+ },
5874
+ [contAll](fiber) {
5875
+ if (fiber.interruptible && this.interruptible !== true) {
5876
+ fiber._stack.push(setInterruptibleTrue);
5877
+ fiber.interruptible = false;
5878
+ }
5879
+ },
5880
+ [contA](value, _, exit) {
5881
+ exit ??= exitSucceed(value);
5882
+ const eff = this.onExit(exit);
5883
+ return eff ? flatMap$1(eff, (_) => exit) : exit;
5884
+ },
5885
+ [contE](cause, _, exit) {
5886
+ exit ??= exitFailCause(cause);
5887
+ const eff = this.onExit(exit);
5888
+ return eff ? flatMap$1(combineFinalizerCause(exit, eff), (_) => exit) : exit;
5831
5889
  }
5832
- },
5833
- [contA](value, _, exit) {
5834
- exit ??= exitSucceed(value);
5835
- const eff = this[args][1](exit);
5836
- return eff ? flatMap$1(eff, (_) => exit) : exit;
5837
- },
5838
- [contE](cause, _, exit) {
5839
- exit ??= exitFailCause(cause);
5840
- const eff = this[args][1](exit);
5841
- return eff ? flatMap$1(combineFinalizerCause(exit, eff), (_) => exit) : exit;
5842
- }
5843
- });
5890
+ });
5891
+ const OnExitImpl = function(effect, onExit, interruptible) {
5892
+ this.effect = effect;
5893
+ this.onExit = onExit;
5894
+ this.interruptible = interruptible;
5895
+ };
5896
+ OnExitImpl.prototype = Proto;
5897
+ return function(effect, onExit, interruptible) {
5898
+ return new OnExitImpl(effect, onExit, interruptible);
5899
+ };
5900
+ }();
5844
5901
  /** @internal */
5845
5902
  var onExit$2 = /*#__PURE__*/ dual(2, onExitPrimitive);
5846
5903
  /** @internal */
@@ -5862,8 +5919,7 @@ var onErrorFilter = /*#__PURE__*/ dual(3, (self, filter, f) => onExit$2(self, (e
5862
5919
  var onInterrupt$1 = /*#__PURE__*/ dual(2, (self, finalizer) => onErrorFilter(causeFilterInterruptors, finalizer)(self));
5863
5920
  /** @internal */
5864
5921
  var cachedInvalidateWithTTL = /*#__PURE__*/ dual(2, (self, ttl) => sync$1(() => {
5865
- const ttlMillis = toMillis(fromInputUnsafe(ttl));
5866
- const isFinite = Number.isFinite(ttlMillis);
5922
+ const ttlMillis = typeof ttl === "function" ? (exit) => toMillis(fromInputUnsafe(ttl(exit))) : constant(toMillis(fromInputUnsafe(ttl)));
5867
5923
  const latch = makeLatchUnsafe(false);
5868
5924
  let expiresAt = 0;
5869
5925
  let running = false;
@@ -5871,16 +5927,24 @@ var cachedInvalidateWithTTL = /*#__PURE__*/ dual(2, (self, ttl) => sync$1(() =>
5871
5927
  const wait = flatMap$1(latch.await, () => exit);
5872
5928
  return [withFiber$1((fiber) => {
5873
5929
  const clock = fiber.getRef(ClockRef);
5874
- const now = isFinite ? clock.currentTimeMillisUnsafe() : 0;
5930
+ const now = expiresAt === Infinity ? 0 : clock.currentTimeMillisUnsafe();
5875
5931
  if (running || now < expiresAt) return exit ?? wait;
5876
5932
  running = true;
5877
5933
  latch.closeUnsafe();
5878
5934
  exit = void 0;
5879
5935
  return onExit$2(self, (exit_) => sync$1(() => {
5880
- running = false;
5881
- expiresAt = clock.currentTimeMillisUnsafe() + ttlMillis;
5882
- exit = exit_;
5883
- latch.openUnsafe();
5936
+ try {
5937
+ const duration = ttlMillis(exit_);
5938
+ expiresAt = clock.currentTimeMillisUnsafe() + duration;
5939
+ exit = exit_;
5940
+ } catch (error) {
5941
+ const cause = causeDie(error);
5942
+ exit = exitFailCause(exitIsFailure(exit_) ? causeCombine(exit_.cause, cause) : cause);
5943
+ throw error;
5944
+ } finally {
5945
+ running = false;
5946
+ latch.openUnsafe();
5947
+ }
5884
5948
  }));
5885
5949
  }), sync$1(() => {
5886
5950
  expiresAt = 0;
@@ -5891,7 +5955,21 @@ var cachedInvalidateWithTTL = /*#__PURE__*/ dual(2, (self, ttl) => sync$1(() =>
5891
5955
  /** @internal */
5892
5956
  var cachedWithTTL$1 = /*#__PURE__*/ dual(2, (self, timeToLive) => map$4(cachedInvalidateWithTTL(self, timeToLive), (tuple) => tuple[0]));
5893
5957
  /** @internal */
5894
- var cached$1 = (self) => cachedWithTTL$1(self, infinity);
5958
+ var cached$1 = (self) => sync$1(() => {
5959
+ const latch = makeLatchUnsafe(false);
5960
+ let started = false;
5961
+ let exit;
5962
+ const wait = flatMap$1(latch.await, () => exit);
5963
+ return suspend$3(() => {
5964
+ if (exit !== void 0) return exit;
5965
+ if (started) return wait;
5966
+ started = true;
5967
+ return onExit$2(self, (result) => sync$1(() => {
5968
+ exit = result;
5969
+ latch.openUnsafe();
5970
+ }));
5971
+ });
5972
+ });
5895
5973
  /** @internal */
5896
5974
  var interrupt$4 = /*#__PURE__*/ withFiber$1((fiber) => failCause$5(causeInterrupt(fiber.id)));
5897
5975
  /** @internal */
@@ -5962,8 +6040,7 @@ var whileLoop$1 = /*#__PURE__*/ makePrimitive({
5962
6040
  });
5963
6041
  /** @internal */
5964
6042
  var forEach$1 = /*#__PURE__*/ dual((args) => typeof args[1] === "function", (iterable, f, options) => suspend$3(() => {
5965
- const concurrencyOption = options?.concurrency ?? 1;
5966
- const concurrency = concurrencyOption === "unbounded" ? Number.POSITIVE_INFINITY : Math.max(1, concurrencyOption);
6043
+ const concurrency = resolveConcurrency(options?.concurrency);
5967
6044
  if (concurrency === 1) return forEachSequential(iterable, f, options);
5968
6045
  const items = fromIterable(iterable);
5969
6046
  let length = items.length;
@@ -5989,10 +6066,13 @@ var forEachSequential = (iterable, f, options) => suspend$3(() => {
5989
6066
  }
5990
6067
  }), out);
5991
6068
  });
5992
- var iterateEagerImpl = (options) => {
6069
+ /** @internal */
6070
+ var resolveConcurrency = (concurrency) => concurrency === "unbounded" ? Number.POSITIVE_INFINITY : Math.max(1, concurrency ?? 1);
6071
+ /** @internal */
6072
+ var iterateEager = () => (options) => {
5993
6073
  const onItem = options.onItem;
5994
6074
  const step = options.step;
5995
- const runSequential = (state, items, index, end) => {
6075
+ const runSequential = (state, items, index = 0, end = items.length) => {
5996
6076
  for (; index < end; index++) {
5997
6077
  const item = items[index];
5998
6078
  const effect = onItem(state, item, index);
@@ -6001,12 +6081,15 @@ var iterateEagerImpl = (options) => {
6001
6081
  if (terminal) return terminal._tag === "Failure" ? terminal : void 0;
6002
6082
  }
6003
6083
  };
6084
+ return runSequential;
6085
+ };
6086
+ var iterateConcurrentImpl = (options) => {
6087
+ const onItem = options.onItem;
6088
+ const step = options.step;
6004
6089
  return (state, items, opts) => {
6005
6090
  let index = 0;
6006
- const end = opts?.end ?? items.length;
6007
- const concurrency = opts?.concurrency ?? 1;
6008
- if (concurrency === 1) return runSequential(state, items, 0, end);
6009
- const orderedStep = opts?.orderedStep === true;
6091
+ const end = opts.end ?? items.length;
6092
+ const concurrency = opts.concurrency;
6010
6093
  let done = false;
6011
6094
  let parentFiber;
6012
6095
  let fibers;
@@ -6014,8 +6097,6 @@ var iterateEagerImpl = (options) => {
6014
6097
  let interrupted = false;
6015
6098
  let terminal;
6016
6099
  let effect;
6017
- let nextIndex = index;
6018
- const exits = orderedStep ? new Array(end) : void 0;
6019
6100
  const failDefect = (error) => {
6020
6101
  const defect = exitDie(error);
6021
6102
  terminal = defect;
@@ -6023,26 +6104,13 @@ var iterateEagerImpl = (options) => {
6023
6104
  interrupted = true;
6024
6105
  return fibers && fibers.size > 0 ? flatMap$1(uninterruptible$1(fiberInterruptAll(Array.from(fibers))), () => defect) : defect;
6025
6106
  };
6026
- const runStep = (item, exit, currentIndex) => {
6027
- if (!orderedStep) return step(state, item, exit, currentIndex);
6028
- if (terminal) return terminal;
6029
- exits[currentIndex] = exit;
6030
- while (nextIndex < end) {
6031
- const nextExit = exits[nextIndex];
6032
- if (nextExit === void 0) return;
6033
- exits[nextIndex] = void 0;
6034
- const index = nextIndex++;
6035
- const result = step(state, items[index], nextExit, index);
6036
- if (result) return result;
6037
- }
6038
- };
6039
6107
  const go = () => {
6040
6108
  let paused = false;
6041
6109
  for (; !terminal && index < end; index++) {
6042
6110
  const item = items[index];
6043
6111
  const eff = effect ?? onItem(state, item, index);
6044
6112
  if (effectIsExit(eff)) {
6045
- terminal = runStep(item, eff, index);
6113
+ terminal = step(state, item, eff, index);
6046
6114
  if (terminal) break;
6047
6115
  } else if (!parentFiber) return callback$2((cb) => {
6048
6116
  parentFiber = getCurrentFiber();
@@ -6066,7 +6134,7 @@ var iterateEagerImpl = (options) => {
6066
6134
  effect = void 0;
6067
6135
  const fiber = forkUnsafe$1(parentFiber, eff, true, true, "inherit");
6068
6136
  if (fiber._exit) {
6069
- terminal = runStep(item, fiber._exit, index);
6137
+ terminal = step(state, item, fiber._exit, index);
6070
6138
  if (terminal) break;
6071
6139
  continue;
6072
6140
  }
@@ -6080,7 +6148,7 @@ var iterateEagerImpl = (options) => {
6080
6148
  else if (terminal._tag === "Failure") terminal.cause.reasons.push(reason);
6081
6149
  else terminal = exitFailCause(causeFromReasons([reason]));
6082
6150
  } else {
6083
- const result = runStep(item, exit, currentIndex);
6151
+ const result = step(state, item, exit, currentIndex);
6084
6152
  if (result) {
6085
6153
  terminal = result._tag === "Failure" ? exitFailCause(causeFromReasons(result.cause.reasons.slice())) : result;
6086
6154
  go();
@@ -6117,8 +6185,8 @@ var iterateEagerImpl = (options) => {
6117
6185
  };
6118
6186
  };
6119
6187
  /** @internal */
6120
- var iterateEager = () => iterateEagerImpl;
6121
- var forEachConcurrent = /*#__PURE__*/ iterateEagerImpl({
6188
+ var iterateConcurrent = () => (options) => iterateConcurrentImpl(options);
6189
+ var forEachConcurrent = /*#__PURE__*/ iterateConcurrentImpl({
6122
6190
  onItem(state, item, index) {
6123
6191
  return state.f(item, index);
6124
6192
  },
@@ -6127,6 +6195,7 @@ var forEachConcurrent = /*#__PURE__*/ iterateEagerImpl({
6127
6195
  else if (state.out) state.out[index] = exit.value;
6128
6196
  }
6129
6197
  });
6198
+ /** @internal */
6130
6199
  var filterOrElse = /*#__PURE__*/ dual(3, (self, predicate, orElse) => flatMap$1(self, (a) => predicate(a) ? succeed$5(a) : orElse(a)));
6131
6200
  /** @internal */
6132
6201
  var filter$4 = /*#__PURE__*/ dual((args) => isIterable(args[0]) && !isEffect$1(args[0]), (elements, predicate, options) => suspend$3(() => {
@@ -6159,7 +6228,7 @@ var forkUnsafe$1 = (parent, effect, immediate = false, daemon = false, uninterru
6159
6228
  else parentRuntime.currentDispatcher.scheduleTask(() => child.evaluate(effect), 0);
6160
6229
  if (!daemon && !child._exit) {
6161
6230
  parentRuntime.children().add(child);
6162
- child.addObserver(() => parentRuntime._children.delete(child));
6231
+ child._parent = parentRuntime;
6163
6232
  }
6164
6233
  return child;
6165
6234
  };
@@ -6365,7 +6434,7 @@ var filterDisablePropagation = (span) => {
6365
6434
  /** @internal */
6366
6435
  var makeSpanUnsafe = (fiber, name, options) => {
6367
6436
  const disablePropagation = !fiber.getRef(TracerEnabled) || options?.annotations && get$4(options.annotations, DisablePropagation);
6368
- const parent = options?.parent !== void 0 ? some(options.parent) : options?.root ? none() : filterDisablePropagation(fiber.currentSpan);
6437
+ const parent = options?.parent !== void 0 ? some(options.parent) : options?.root ? none() : filterDisablePropagation(fiber.cache.span);
6369
6438
  let span;
6370
6439
  if (disablePropagation) span = noopSpan({
6371
6440
  name,
@@ -6385,7 +6454,7 @@ var makeSpanUnsafe = (fiber, name, options) => {
6385
6454
  parent,
6386
6455
  annotations: options?.annotations ?? empty$4(),
6387
6456
  links,
6388
- startTime: timingEnabled ? clock.currentTimeNanosUnsafe() : BigInt(0),
6457
+ startTime: timingEnabled ? clock.currentTimeNanosUnsafe() : bigint0,
6389
6458
  kind: options?.kind ?? "internal",
6390
6459
  root: options?.root ?? isNone(parent),
6391
6460
  sampled: options?.sampled ?? (isSome(parent) && parent.value.sampled === false ? false : !isLogLevelGreaterThan(fiber.getRef(MinimumTraceLevel), level))
@@ -6416,7 +6485,7 @@ var useSpan$1 = (name, ...args) => {
6416
6485
  const span = makeSpanUnsafe(fiber, name, options);
6417
6486
  const clock = fiber.getRef(ClockRef);
6418
6487
  const timingEnabled = fiber.getRef(TracerTimingEnabled);
6419
- return onExit$2(internalCall(() => evaluate(span)), (exit) => endSpan(span, exit, clock, timingEnabled));
6488
+ return onExit$2(suspend$3(() => internalCall(() => evaluate(span))), (exit) => endSpan(span, exit, clock, timingEnabled));
6420
6489
  });
6421
6490
  };
6422
6491
  var provideParentSpan = /*#__PURE__*/ provideService$1(ParentSpan);
@@ -6547,7 +6616,7 @@ var UnknownError = class extends TaggedError$1("UnknownError") {
6547
6616
  }
6548
6617
  };
6549
6618
  /** @internal */
6550
- var ConsoleRef = /*#__PURE__*/ Reference("effect/Console/CurrentConsole", { defaultValue: () => globalThis.console });
6619
+ var ConsoleRef = /*#__PURE__*/ Reference("effect/Console", { defaultValue: () => globalThis.console });
6551
6620
  /** @internal */
6552
6621
  var logLevelToOrder = (level) => {
6553
6622
  switch (level) {
@@ -6564,7 +6633,7 @@ var logLevelToOrder = (level) => {
6564
6633
  /** @internal */
6565
6634
  var isLogLevelGreaterThan = /*#__PURE__*/ isGreaterThan(/* @__PURE__ */ mapInput(Number$2, logLevelToOrder));
6566
6635
  /** @internal */
6567
- var CurrentLoggers = /*#__PURE__*/ Reference("effect/Loggers/CurrentLoggers", { defaultValue: () => /* @__PURE__ */ new Set([defaultLogger, tracerLogger]) });
6636
+ var CurrentLoggers = /*#__PURE__*/ Reference("effect/Logger/CurrentLoggers", { defaultValue: () => /* @__PURE__ */ new Set([defaultLogger, tracerLogger]) });
6568
6637
  /** @internal */
6569
6638
  var LogToStderr = /*#__PURE__*/ Reference("effect/Logger/LogToStderr", { defaultValue: constFalse });
6570
6639
  var LoggerProto = {
@@ -6611,8 +6680,8 @@ var logWithLevel = (level) => (...message) => {
6611
6680
  }
6612
6681
  if (cause === void 0) cause = causeEmpty;
6613
6682
  return withFiber$1((fiber) => {
6614
- const logLevel = level ?? fiber.currentLogLevel;
6615
- if (isLogLevelGreaterThan(fiber.minimumLogLevel, logLevel)) return void_$2;
6683
+ const logLevel = level ?? fiber.cache.logLevel;
6684
+ if (isLogLevelGreaterThan(fiber.cache.minimumLogLevel, logLevel)) return void_$2;
6616
6685
  const clock = fiber.getRef(ClockRef);
6617
6686
  const loggers = fiber.getRef(CurrentLoggers);
6618
6687
  if (loggers.size > 0) {
@@ -6659,7 +6728,7 @@ var defaultLogger = /*#__PURE__*/ loggerMake(({ cause, date, fiber, logLevel, me
6659
6728
  var tracerLogger = /*#__PURE__*/ loggerMake(({ cause, fiber, logLevel, message }) => {
6660
6729
  const clock = fiber.getRef(ClockRef);
6661
6730
  const annotations = fiber.getRef(CurrentLogAnnotations$1);
6662
- const span = fiber.currentSpan;
6731
+ const span = fiber.cache.span;
6663
6732
  if (span === void 0 || span._tag === "ExternalSpan") return;
6664
6733
  const attributes = {};
6665
6734
  for (const [key, value] of Object.entries(annotations)) assignProperty(attributes, key, value);
@@ -6675,7 +6744,7 @@ function interruptChildrenPatch() {
6675
6744
  /** @internal */
6676
6745
  var undefined_$1 = /*#__PURE__*/ succeed$5(void 0);
6677
6746
  //#endregion
6678
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/Cause.js
6747
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/Cause.js
6679
6748
  /**
6680
6749
  * Records the full reason an `Effect` failed.
6681
6750
  *
@@ -7084,7 +7153,7 @@ var IllegalArgumentError = IllegalArgumentError$1;
7084
7153
  Service()("effect/Cause/StackTrace");
7085
7154
  Service()("effect/Cause/InterruptorStackTrace");
7086
7155
  //#endregion
7087
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/Exit.js
7156
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/Exit.js
7088
7157
  /**
7089
7158
  * Checks whether an unknown value is an Exit.
7090
7159
  *
@@ -7290,6 +7359,11 @@ var DeferredProto = {
7290
7359
  return pipeArguments(this, arguments);
7291
7360
  }
7292
7361
  };
7362
+ var DeferredImpl = function() {
7363
+ this.resumes = void 0;
7364
+ this.effect = void 0;
7365
+ };
7366
+ DeferredImpl.prototype = DeferredProto;
7293
7367
  /**
7294
7368
  * Creates an empty `Deferred` synchronously outside the `Effect` runtime.
7295
7369
  *
@@ -7310,12 +7384,7 @@ var DeferredProto = {
7310
7384
  * @category unsafe
7311
7385
  * @since 4.0.0
7312
7386
  */
7313
- var makeUnsafe$3 = () => {
7314
- const self = Object.create(DeferredProto);
7315
- self.resumes = void 0;
7316
- self.effect = void 0;
7317
- return self;
7318
- };
7387
+ var makeUnsafe$3 = () => new DeferredImpl();
7319
7388
  /**
7320
7389
  * Creates a new `Deferred`.
7321
7390
  *
@@ -7560,7 +7629,7 @@ var doneUnsafe = (self, effect) => {
7560
7629
  */
7561
7630
  var into = /*#__PURE__*/ dual(2, (self, deferred) => uninterruptibleMask$1((restore) => flatMap$1(exit$1(restore(self)), (exit) => done(deferred, exit))));
7562
7631
  //#endregion
7563
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/References.js
7632
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/References.js
7564
7633
  /**
7565
7634
  * Context reference for managing log annotations that are automatically added to all log entries.
7566
7635
  * These annotations provide contextual metadata that appears in every log message.
@@ -7621,7 +7690,7 @@ var into = /*#__PURE__*/ dual(2, (self, deferred) => uninterruptibleMask$1((rest
7621
7690
  */
7622
7691
  var CurrentLogAnnotations = CurrentLogAnnotations$1;
7623
7692
  //#endregion
7624
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/Scope.js
7693
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/Scope.js
7625
7694
  /**
7626
7695
  * Controls how long resources stay open.
7627
7696
  *
@@ -7867,7 +7936,7 @@ var forkUnsafe = scopeForkUnsafe;
7867
7936
  */
7868
7937
  var close = scopeClose;
7869
7938
  //#endregion
7870
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/Clock.js
7939
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/Clock.js
7871
7940
  /**
7872
7941
  * Context reference for the active time service in the environment.
7873
7942
  *
@@ -7971,7 +8040,7 @@ var nextPow2 = (n) => {
7971
8040
  return Math.max(Math.pow(2, nextPow), 2);
7972
8041
  };
7973
8042
  //#endregion
7974
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/Pull.js
8043
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/Pull.js
7975
8044
  /**
7976
8045
  * Models one low-level pull step for stream-like consumers.
7977
8046
  *
@@ -8141,7 +8210,7 @@ var matchEffect$1 = /*#__PURE__*/ dual(2, (self, options) => matchCauseEffect$1(
8141
8210
  }
8142
8211
  }));
8143
8212
  //#endregion
8144
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/Schedule.js
8213
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/Schedule.js
8145
8214
  var TypeId$7 = "~effect/Schedule";
8146
8215
  /**
8147
8216
  * Context reference containing metadata for the currently running schedule step.
@@ -8574,7 +8643,7 @@ var while_ = /*#__PURE__*/ dual(2, (self, predicate) => fromStep(map$4(toStep(se
8574
8643
  */
8575
8644
  var forever$1 = /*#__PURE__*/ spaced(zero);
8576
8645
  //#endregion
8577
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/internal/schedule.js
8646
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/internal/schedule.js
8578
8647
  /** @internal */
8579
8648
  var repeatOrElse = /*#__PURE__*/ dual(3, (self, schedule, orElse) => flatMap$1(toStepWithMetadata(schedule), (step) => {
8580
8649
  let meta = CurrentMetadata.defaultValue();
@@ -8619,7 +8688,7 @@ var buildFromOptions = (options) => {
8619
8688
  return schedule;
8620
8689
  };
8621
8690
  //#endregion
8622
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/Effect.js
8691
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/Effect.js
8623
8692
  /**
8624
8693
  * Checks whether a value is an `Effect`.
8625
8694
  *
@@ -11094,6 +11163,8 @@ var onError = onError$1;
11094
11163
  * Ensures that a cleanup function runs whether this effect succeeds, fails, or
11095
11164
  * is interrupted.
11096
11165
  *
11166
+ * **Details**
11167
+ *
11097
11168
  * If both the effect and the cleanup function fail, the two causes are merged.
11098
11169
  *
11099
11170
  * **Example** (Observing every exit)
@@ -11171,8 +11242,8 @@ var onExit$1 = onExit$2;
11171
11242
  */
11172
11243
  var cached = cached$1;
11173
11244
  /**
11174
- * Returns an effect that caches its result for a specified `Duration`,
11175
- * known as "timeToLive" (TTL).
11245
+ * Returns an effect that caches its result for a fixed duration or a duration
11246
+ * computed from its `Exit`, known as "timeToLive" (TTL).
11176
11247
  *
11177
11248
  * **When to use**
11178
11249
  *
@@ -11191,6 +11262,17 @@ var cached = cached$1;
11191
11262
  * After the specified duration has passed, the cache expires, and the effect
11192
11263
  * will be recomputed upon the next evaluation.
11193
11264
  *
11265
+ * `timeToLive` accepts a `Duration.Input` or a function from `Exit<A, E>` to
11266
+ * `Duration.Input`. The function runs once after each fresh computation,
11267
+ * including failures, so successes and failures can have different TTLs. It
11268
+ * does not run when the cache is created or when a cached result is reused.
11269
+ * The callback also receives interruption exits, which are cached for the
11270
+ * returned duration.
11271
+ *
11272
+ * The TTL starts when the computation completes. Concurrent callers share the
11273
+ * pending computation. A zero TTL expires immediately, and an infinite TTL
11274
+ * keeps the result indefinitely.
11275
+ *
11194
11276
  * **Example** (Memoizing an effect with TTL)
11195
11277
  *
11196
11278
  * ```ts import.meta.vitest
@@ -11215,6 +11297,26 @@ var cached = cached$1;
11215
11297
  * output // => ["expensive task...", "result 1", "result 1", "result 1"]
11216
11298
  * ```
11217
11299
  *
11300
+ * **Example** (Caching successes while retrying failures)
11301
+ *
11302
+ * ```ts import.meta.vitest
11303
+ * import { Effect, Exit } from "effect"
11304
+ *
11305
+ * let attempts = 0
11306
+ * const task = Effect.suspend(() =>
11307
+ * ++attempts === 1 ? Effect.fail("temporary failure") : Effect.succeed(42)
11308
+ * )
11309
+ * const program = Effect.gen(function*() {
11310
+ * const cached = yield* task.pipe(
11311
+ * Effect.cachedWithTTL((exit) => Exit.isSuccess(exit) ? "1 hour" : 0)
11312
+ * )
11313
+ * yield* Effect.exit(cached)
11314
+ * return yield* cached
11315
+ * })
11316
+ *
11317
+ * Effect.runSync(program) // => 42
11318
+ * ```
11319
+ *
11218
11320
  * @see {@link cached} for a similar function that caches the result
11219
11321
  * indefinitely.
11220
11322
  * @see {@link cachedInvalidateWithTTL} for a similar function that includes an
@@ -12484,7 +12586,7 @@ var catchEager = catchEager$1;
12484
12586
  */
12485
12587
  var fnUntracedEager = fnUntracedEager$1;
12486
12588
  //#endregion
12487
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/Fiber.js
12589
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/Fiber.js
12488
12590
  /**
12489
12591
  * Joins a fiber, blocking until it completes. If the fiber succeeds,
12490
12592
  * returns its value. If it fails, the error is propagated.
@@ -12680,7 +12782,7 @@ var getCurrent = getCurrentFiber;
12680
12782
  */
12681
12783
  var runIn = fiberRunIn;
12682
12784
  //#endregion
12683
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/Latch.js
12785
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/Latch.js
12684
12786
  /**
12685
12787
  * Creates a `Latch` synchronously, outside of `Effect`.
12686
12788
  *
@@ -12751,7 +12853,7 @@ var makeUnsafe$1 = makeLatchUnsafe;
12751
12853
  */
12752
12854
  var make$7 = makeLatch;
12753
12855
  //#endregion
12754
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/MutableRef.js
12856
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/MutableRef.js
12755
12857
  var TypeId$6 = "~effect/MutableRef";
12756
12858
  var MutableRefProto = {
12757
12859
  [TypeId$6]: TypeId$6,
@@ -12892,7 +12994,7 @@ var set = /*#__PURE__*/ dual(2, (self, value) => {
12892
12994
  return self;
12893
12995
  });
12894
12996
  //#endregion
12895
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/MutableList.js
12997
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/MutableList.js
12896
12998
  /**
12897
12999
  * Mutable lists for collecting ordered values and draining them from the front.
12898
13000
  * A `MutableList<A>` can append values to the end, prepend values to the
@@ -13114,6 +13216,11 @@ var clear = (self) => {
13114
13216
  * The taken elements are removed from the list. This operation is optimized for performance
13115
13217
  * and includes zero-copy optimizations when possible.
13116
13218
  *
13219
+ * **Details**
13220
+ *
13221
+ * Finite fractional values of `n` are rounded down. `NaN` and non-positive
13222
+ * values leave the list unchanged and return an empty array.
13223
+ *
13117
13224
  * **Example** (Taking batches)
13118
13225
  *
13119
13226
  * ```ts import.meta.vitest
@@ -13131,6 +13238,7 @@ var clear = (self) => {
13131
13238
  * @since 4.0.0
13132
13239
  */
13133
13240
  var takeN = (self, n) => {
13241
+ n = normalize(n);
13134
13242
  if (n <= 0 || !self.head) return [];
13135
13243
  n = Math.min(n, self.length);
13136
13244
  if (n === self.length && self.head?.offset === 0 && !self.head.next) {
@@ -13286,7 +13394,7 @@ var filter$2 = (self, f) => {
13286
13394
  */
13287
13395
  var remove = (self, value) => filter$2(self, (v) => v !== value);
13288
13396
  //#endregion
13289
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/PubSub.js
13397
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/PubSub.js
13290
13398
  /**
13291
13399
  * Broadcasts values from publishers to many subscribers.
13292
13400
  *
@@ -13962,6 +14070,7 @@ var BoundedPubSubArbSubscription = class {
13962
14070
  return Empty;
13963
14071
  }
13964
14072
  pollUpTo(n) {
14073
+ n = normalize(n);
13965
14074
  if (this.unsubscribed) return [];
13966
14075
  this.subscriberIndex = Math.max(this.subscriberIndex, this.self.subscribersIndex);
13967
14076
  const size = this.self.publisherIndex - this.subscriberIndex;
@@ -14113,6 +14222,7 @@ var BoundedPubSubPow2Subscription = class {
14113
14222
  return Empty;
14114
14223
  }
14115
14224
  pollUpTo(n) {
14225
+ n = normalize(n);
14116
14226
  if (this.unsubscribed) return [];
14117
14227
  this.subscriberIndex = Math.max(this.subscriberIndex, this.self.subscribersIndex);
14118
14228
  const size = this.self.publisherIndex - this.subscriberIndex;
@@ -14230,22 +14340,18 @@ var BoundedPubSubSingleSubscription = class {
14230
14340
  const elem = this.self.value;
14231
14341
  this.self.subscribers -= 1;
14232
14342
  if (this.self.subscribers === 0) this.self.value = AbsentValue;
14233
- this.subscriberIndex += 1;
14343
+ this.subscriberIndex = this.self.publisherIndex;
14234
14344
  return elem;
14235
14345
  }
14236
14346
  pollUpTo(n) {
14237
- if (this.isEmpty() || n < 1) return [];
14238
- const a = this.self.value;
14239
- this.self.subscribers -= 1;
14240
- if (this.self.subscribers === 0) this.self.value = AbsentValue;
14241
- this.subscriberIndex += 1;
14242
- return [a];
14347
+ if (normalize(n) < 1 || this.isEmpty()) return [];
14348
+ return [this.poll()];
14243
14349
  }
14244
14350
  unsubscribe() {
14245
14351
  if (!this.unsubscribed) {
14246
14352
  this.unsubscribed = true;
14247
14353
  this.self.subscriberCount -= 1;
14248
- if (this.subscriberIndex !== this.self.publisherIndex) {
14354
+ if (this.self.subscribers !== 0 && this.subscriberIndex !== this.self.publisherIndex) {
14249
14355
  this.self.subscribers -= 1;
14250
14356
  if (this.self.subscribers === 0) this.self.value = AbsentValue;
14251
14357
  }
@@ -14367,6 +14473,7 @@ var UnboundedPubSubSubscription = class {
14367
14473
  return polled;
14368
14474
  }
14369
14475
  pollUpTo(n) {
14476
+ n = normalize(n);
14370
14477
  const builder = [];
14371
14478
  let i = 0;
14372
14479
  while (i !== n) {
@@ -14789,6 +14896,7 @@ var ReplayWindowImpl = class {
14789
14896
  return value;
14790
14897
  }
14791
14898
  takeN(n) {
14899
+ n = normalize(n);
14792
14900
  const len = Math.min(n, this.remaining);
14793
14901
  const items = new Array(len);
14794
14902
  for (let i = 0; i < len; i++) items[i] = this.take();
@@ -14806,7 +14914,7 @@ var emptyReplayWindow = {
14806
14914
  close: () => void 0
14807
14915
  };
14808
14916
  //#endregion
14809
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/Queue.js
14917
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/Queue.js
14810
14918
  /**
14811
14919
  * Passes values asynchronously between fibers.
14812
14920
  *
@@ -15385,9 +15493,10 @@ var takeAll = (self) => takeBetween(self, 1, Number.POSITIVE_INFINITY);
15385
15493
  * **Details**
15386
15494
  *
15387
15495
  * The operation waits when fewer than the required minimum messages are
15388
- * available. It returns at most `max` messages. If the queue completes or fails
15389
- * before the minimum can be satisfied, the effect fails with the queue's
15390
- * terminal error.
15496
+ * available. It returns at most `max` messages. Finite fractional bounds are
15497
+ * rounded down, while `NaN` and non-positive bounds are treated as `0`. If the
15498
+ * queue completes or fails before the minimum can be satisfied, the effect
15499
+ * fails with the queue's terminal error.
15391
15500
  *
15392
15501
  * **Example** (Taking a bounded batch of values)
15393
15502
  *
@@ -15417,7 +15526,11 @@ var takeAll = (self) => takeBetween(self, 1, Number.POSITIVE_INFINITY);
15417
15526
  * @category taking
15418
15527
  * @since 2.0.0
15419
15528
  */
15420
- var takeBetween = (self, min, max) => suspend$3(() => takeBetweenUnsafe(self, min, max) ?? andThen$1(awaitTake(self), takeBetween(self, 1, max)));
15529
+ var takeBetween = (self, min, max) => {
15530
+ min = normalize(min);
15531
+ max = normalize(max);
15532
+ return suspend$3(() => takeBetweenUnsafe(self, min, max) ?? andThen$1(awaitTake(self), takeBetween(self, 1, max)));
15533
+ };
15421
15534
  /**
15422
15535
  * Takes a single message from the queue, or wait for a message to be
15423
15536
  * available.
@@ -15508,10 +15621,7 @@ var takeUnsafe = (self) => {
15508
15621
  releaseCapacity(self);
15509
15622
  return exitSucceed(message);
15510
15623
  } else if (self.capacity <= 0 && self.state.offers.size > 0) {
15511
- self.capacity = 1;
15512
- releaseCapacity(self);
15513
- self.capacity = 0;
15514
- const message = take$3(self.messages);
15624
+ const message = takeOfferUnsafe(self.state.offers);
15515
15625
  releaseCapacity(self);
15516
15626
  return exitSucceed(message);
15517
15627
  }
@@ -15570,7 +15680,6 @@ var exitTrue = /*#__PURE__*/ exitSucceed(true);
15570
15680
  var exitFailDone = /*#__PURE__*/ exitFail(/*#__PURE__*/ Done());
15571
15681
  var exitInterrupt = /*#__PURE__*/ exitInterrupt$1();
15572
15682
  var releaseTakers = (self) => {
15573
- self.scheduleRunning = false;
15574
15683
  if (self.state._tag === "Done" || self.state.takers.size === 0) return;
15575
15684
  for (const taker of self.state.takers) {
15576
15685
  self.state.takers.delete(taker);
@@ -15581,16 +15690,16 @@ var releaseTakers = (self) => {
15581
15690
  var scheduleReleaseTaker = (self) => {
15582
15691
  if (self.scheduleRunning || self.state._tag === "Done" || self.state.takers.size === 0) return;
15583
15692
  self.scheduleRunning = true;
15584
- self.dispatcher.scheduleTask(() => releaseTakers(self), 0);
15693
+ self.dispatcher.scheduleTask(() => {
15694
+ self.scheduleRunning = false;
15695
+ releaseTakers(self);
15696
+ }, 0);
15585
15697
  };
15586
15698
  var takeBetweenUnsafe = (self, min, max) => {
15587
15699
  if (self.state._tag === "Done") return self.state.exit;
15588
15700
  else if (max <= 0 || min <= 0) return exitSucceed([]);
15589
- else if (self.capacity <= 0 && self.state.offers.size > 0) {
15590
- self.capacity = 1;
15591
- releaseCapacity(self);
15592
- self.capacity = 0;
15593
- const messages = [take$3(self.messages)];
15701
+ else if (self.capacity <= 0 && self.messages.length === 0 && self.state.offers.size > 0) {
15702
+ const messages = [takeOfferUnsafe(self.state.offers)];
15594
15703
  releaseCapacity(self);
15595
15704
  return exitSucceed(messages);
15596
15705
  }
@@ -15630,6 +15739,20 @@ var offerRemainingArray = (self, remaining) => {
15630
15739
  });
15631
15740
  });
15632
15741
  };
15742
+ var takeOfferUnsafe = (offers) => {
15743
+ const entry = offers.values().next().value;
15744
+ if (entry._tag === "Single") {
15745
+ offers.delete(entry);
15746
+ entry.resume(exitTrue);
15747
+ return entry.message;
15748
+ }
15749
+ const message = entry.remaining[entry.offset++];
15750
+ if (entry.offset === entry.remaining.length) {
15751
+ offers.delete(entry);
15752
+ entry.resume(exitSucceed([]));
15753
+ }
15754
+ return message;
15755
+ };
15633
15756
  var releaseCapacity = (self) => {
15634
15757
  if (self.state._tag === "Done") return isDoneCause(self.state.exit.cause);
15635
15758
  else if (self.state.offers.size === 0) {
@@ -15639,21 +15762,22 @@ var releaseCapacity = (self) => {
15639
15762
  }
15640
15763
  return false;
15641
15764
  }
15642
- let n = self.capacity - self.messages.length;
15643
- for (const entry of self.state.offers) if (n === 0) break;
15644
- else if (entry._tag === "Single") {
15645
- append(self.messages, entry.message);
15646
- n--;
15647
- entry.resume(exitTrue);
15648
- self.state.offers.delete(entry);
15649
- } else {
15650
- for (; entry.offset < entry.remaining.length; entry.offset++) {
15651
- if (n === 0) return false;
15652
- append(self.messages, entry.remaining[entry.offset]);
15653
- n--;
15765
+ for (const entry of self.state.offers) {
15766
+ let n = self.capacity - self.messages.length;
15767
+ if (n <= 0) break;
15768
+ else if (entry._tag === "Single") {
15769
+ append(self.messages, entry.message);
15770
+ self.state.offers.delete(entry);
15771
+ entry.resume(exitTrue);
15772
+ } else {
15773
+ for (; entry.offset < entry.remaining.length; entry.offset++) {
15774
+ if (n === 0) return false;
15775
+ append(self.messages, entry.remaining[entry.offset]);
15776
+ n--;
15777
+ }
15778
+ self.state.offers.delete(entry);
15779
+ entry.resume(exitSucceed([]));
15654
15780
  }
15655
- entry.resume(exitSucceed([]));
15656
- self.state.offers.delete(entry);
15657
15781
  }
15658
15782
  return false;
15659
15783
  };
@@ -15677,7 +15801,7 @@ var finalize = (self, exit) => {
15677
15801
  openState.awaiters.clear();
15678
15802
  };
15679
15803
  //#endregion
15680
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/Semaphore.js
15804
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/Semaphore.js
15681
15805
  /**
15682
15806
  * Creates a `Semaphore` synchronously with the specified total
15683
15807
  * number of permits.
@@ -15838,7 +15962,7 @@ var SemaphoreImpl = class {
15838
15962
  */
15839
15963
  var make$2 = (permits) => sync$1(() => new SemaphoreImpl(permits));
15840
15964
  //#endregion
15841
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/Take.js
15965
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/Take.js
15842
15966
  /**
15843
15967
  * Converts a `Take` into a `Pull`, succeeding with value batches, failing with
15844
15968
  * failure exits, and translating successful exits into pull completion.
@@ -15853,7 +15977,7 @@ var make$2 = (permits) => sync$1(() => new SemaphoreImpl(permits));
15853
15977
  */
15854
15978
  var toPull$2 = (take) => isExit(take) ? isSuccess(take) ? done$1(take.value) : take : succeed$2(take);
15855
15979
  //#endregion
15856
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/Channel.js
15980
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/Channel.js
15857
15981
  /**
15858
15982
  * Provides low-level building blocks for streaming data through Effect.
15859
15983
  *
@@ -17378,27 +17502,26 @@ var toPubSubTake$1 = /*#__PURE__*/ dual(2, /*#__PURE__*/ fnUntraced(function* (s
17378
17502
  return pubsub;
17379
17503
  }));
17380
17504
  //#endregion
17381
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/internal/stream.js
17505
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/internal/stream.js
17382
17506
  var TypeId$2 = "~effect/Stream";
17383
17507
  var streamVariance = {
17384
17508
  _R: identity,
17385
17509
  _E: identity,
17386
17510
  _A: identity
17387
17511
  };
17388
- var StreamProto = {
17512
+ var Stream = function(channel) {
17513
+ this.channel = channel;
17514
+ };
17515
+ Stream.prototype = {
17389
17516
  [TypeId$2]: streamVariance,
17390
17517
  pipe() {
17391
17518
  return pipeArguments(this, arguments);
17392
17519
  }
17393
17520
  };
17394
17521
  /** @internal */
17395
- var fromChannel$1 = (channel) => {
17396
- const self = Object.create(StreamProto);
17397
- self.channel = channel;
17398
- return self;
17399
- };
17522
+ var fromChannel$1 = (channel) => new Stream(channel);
17400
17523
  //#endregion
17401
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/internal/rcRef.js
17524
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/internal/rcRef.js
17402
17525
  var TypeId$1 = "~effect/RcRef";
17403
17526
  var stateEmpty = { _tag: "Empty" };
17404
17527
  var stateClosed = { _tag: "Closed" };
@@ -17445,7 +17568,8 @@ var getState = (self) => uninterruptibleMask(function loop(restore) {
17445
17568
  const scope = makeUnsafe$2();
17446
17569
  return self.semaphore.withPermit(suspend$2(() => {
17447
17570
  if (self.state._tag !== "Empty") return loop(restore);
17448
- return restore(provideContext(self.acquire, add(self.context, Scope, scope))).pipe(map$2((value) => {
17571
+ return restore(provideContext(self.acquire, add(self.context, Scope, scope))).pipe(flatMap((value) => {
17572
+ if (self.state._tag === "Closed") return interrupt$1;
17449
17573
  const state = {
17450
17574
  _tag: "Acquired",
17451
17575
  value,
@@ -17455,7 +17579,7 @@ var getState = (self) => uninterruptibleMask(function loop(restore) {
17455
17579
  invalidated: false
17456
17580
  };
17457
17581
  self.state = state;
17458
- return state;
17582
+ return succeed$2(state);
17459
17583
  }), onExit$1((exit) => isFailure(exit) ? close(scope, exit) : void_));
17460
17584
  }));
17461
17585
  }
@@ -17470,13 +17594,12 @@ var get$1 = /*#__PURE__*/ fnUntraced(function* (self_) {
17470
17594
  yield* addFinalizerExit(scope$3, () => {
17471
17595
  state.refCount--;
17472
17596
  if (state.refCount > 0) return void_;
17473
- if (self.idleTimeToLive === void 0) {
17474
- self.state = stateEmpty;
17597
+ if (self.idleTimeToLive === void 0 || state.invalidated) {
17598
+ if (self.state === state) self.state = stateEmpty;
17475
17599
  return close(state.scope, void_$1);
17476
- } else if (state.invalidated) return close(state.scope, void_$1);
17477
- else if (!isFinite$1) return void_;
17600
+ } else if (!isFinite$1) return void_;
17478
17601
  state.fiber = sleep(self.idleTimeToLive).pipe(flatMap(() => {
17479
- if (self.state._tag === "Acquired" && self.state.refCount === 0) {
17602
+ if (self.state === state && state.refCount === 0) {
17480
17603
  self.state = stateEmpty;
17481
17604
  return close(state.scope, void_$1);
17482
17605
  }
@@ -17489,7 +17612,7 @@ var get$1 = /*#__PURE__*/ fnUntraced(function* (self_) {
17489
17612
  return state.value;
17490
17613
  });
17491
17614
  //#endregion
17492
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/RcRef.js
17615
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/RcRef.js
17493
17616
  /**
17494
17617
  * Creates an `RcRef` from an acquire effect.
17495
17618
  *
@@ -17583,7 +17706,7 @@ var make = make$1;
17583
17706
  */
17584
17707
  var get = get$1;
17585
17708
  //#endregion
17586
- //#region ../../node_modules/.pnpm/effect@4.0.0-rc.112/node_modules/effect/dist/Stream.js
17709
+ //#region ../../node_modules/.pnpm/effect@4.0.0-rc.115/node_modules/effect/dist/Stream.js
17587
17710
  /**
17588
17711
  * Describes effectful sources that emit values over time.
17589
17712
  *
@@ -18368,7 +18491,12 @@ var catchCause = /*#__PURE__*/ dual(2, (self, f) => self.channel.pipe(catchCause
18368
18491
  */
18369
18492
  var mapError = /*#__PURE__*/ dual(2, (self, f) => fromChannel(mapError$1(self.channel, f)));
18370
18493
  /**
18371
- * Takes the first `n` elements from this stream, returning `Stream.empty` when `n < 1`.
18494
+ * Takes the first `n` elements from this stream.
18495
+ *
18496
+ * **Details**
18497
+ *
18498
+ * Finite fractional values of `n` are rounded down. `NaN` and non-positive
18499
+ * values return `Stream.empty` without evaluating the source stream.
18372
18500
  *
18373
18501
  * **Example** (Taking values from the left)
18374
18502
  *
@@ -18389,7 +18517,10 @@ var mapError = /*#__PURE__*/ dual(2, (self, f) => fromChannel(mapError$1(self.ch
18389
18517
  * @category filtering
18390
18518
  * @since 2.0.0
18391
18519
  */
18392
- var take = /*#__PURE__*/ dual(2, (self, n) => n < 1 ? empty : takeUntil(self, (_, i) => i === n - 1));
18520
+ var take = /*#__PURE__*/ dual(2, (self, n) => {
18521
+ const count = normalize(n);
18522
+ return count === 0 ? empty : takeUntil(self, (_, i) => i === count - 1);
18523
+ });
18393
18524
  /**
18394
18525
  * Takes elements until the predicate matches.
18395
18526
  *
@@ -19015,4 +19146,4 @@ var wagmiConnectResult = (withCapabilities, accounts, chainId) => ({
19015
19146
  chainId
19016
19147
  });
19017
19148
  //#endregion
19018
- export { shutdown$1 as $, merge$1 as $i, upTo as $n, encodeBase64 as $r, mapEager as $t, share as A, filter$5 as Ai, succeedSome as An, isFailReason as Ar, fail$2 as At, zipLatestAll as B, isReadonlyArrayNonEmpty as Bi, updateContext as Bn, onExit$2 as Br, forever as Bt, mapError as C, isLessThanOrEqualTo$1 as Ca, toSeconds as Ci, runSyncWith as Cn, NoSuchElementError as Cr, catchTag as Ct, runForEach as D, strictEqual as Da, chunksOf as Di, sleep as Dn, hasInterrupts as Dr, die as Dt, runDrain as E, make$13 as Ea, appendAll$1 as Ei, service as En, findErrorOption as Er, contextWith as Et, tap as F, get$3 as Fi, tryPromise as Fn, effectIsExit as Fr, flatMapEager as Ft, failCauseUnsafe as G, Reference as Gi, withParentSpan as Gn, succeed$5 as Gr, gen as Gt, make$2 as H, makeEquivalence as Hi, void_ as Hn, provideContext$1 as Hr, forkIn as Ht, toPull as I, getSomes as Ii, try_ as In, flatMap$1 as Ir, fn as It, offerUnsafe as J, empty$4 as Ji, exponential as Jn, void_$2 as Jr, isEffect as Jt, make$3 as K, Service as Ki, withSpan as Kn, suspend$3 as Kr, ignore as Kt, toQueue as L, head as Li, undefined_ as Ln, forEach$1 as Lr, fnUntraced as Lt, suspend as M, findFirst as Mi, sync as Mn, map$3 as Mr, failCauseSync as Mt, switchMap as N, flatMap$2 as Ni, tap$1 as Nn, squash as Nr, filterOrFail as Nt, runForEachArray as O, dedupeWith as Oi, succeed$2 as On, hasInterruptsOnly as Or, ensuring$2 as Ot, take as P, fromIterable as Pi, tapError as Pn, andThen$1 as Pr, flatMap as Pt, publishUnsafe as Q, make$11 as Qi, spaced as Qn, decodeBase64 as Qr, mapBothEager as Qt, toReadableStreamEffect as R, headNonEmpty as Ri, uninterruptible as Rn, iterateEager as Rr, fnUntracedEager as Rt, mapEffect as S, isLessThan$1 as Sa, toMinutes as Si, runSyncExit as Sn, IllegalArgumentError as Sr, catchIf as St, paginate as T, Tuple as Ta, append$1 as Ti, scopedWith as Tn, filterInterruptors as Tr, context as Tt, makeUnsafe as U, map$5 as Ui, whileLoop as Un, provideService$1 as Ur, forkScoped as Ut, toPullScoped as V, lastNonEmpty as Vi, useSpan as Vn, orDie$1 as Vr, forkDetach as Vt, dropping as W, empty$3 as Wi, withFiber as Wn, scopeAddFinalizerExit as Wr, fromResult as Wt, take$1 as X, getOrUndefined as Xi, modifyDelay as Xn, setStackTraceLimit as Xr, logWarning as Xt, shutdown as Y, get$4 as Yi, isSchedule as Yn, getStackTraceLimit as Yr, logError as Yt, publish as Z, getUnsafe$1 as Zi, passthrough as Zn, DisablePropagation as Zr, map$2 as Zt, fromReadableStream as _, BigInt$1 as _a, minutes as _i, runCallbackWith as _n, isExit as _r, cached as _t, changes as a, fromNullishOr as aa, Scheduler as ai, onError as an, forkUnsafe as ar, interruptAll as at, isStream as b, isGreaterThan as ba, toHours as bi, runPromiseExit as bn, succeed$4 as br, catchCause$2 as bt, empty as c, getOrThrowWith as ca, toPredicate as ci, orDie as cn, _await as cr, runIn as ct, filter as d, isSome as da, hours as di, provideService as dn, into as dr, all as dt, mergeAll$1 as ea, Class as ei, mapError$2 as en, isDoneCause as er, unbounded as et, filterEffect as f, liftThrowable as fa, isFinite as fi, race as fn, make$8 as fr, andThen as ft, fromQueue as g, some as ga, min as gi, retry as gn, failCause$4 as gr, asVoid as gt, fromPubSub as h, none as ha, millis as hi, result as hn, fail$3 as hr, asSome as ht, catchCause as i, flatMapNullishOr as ia, MixedScheduler as ii, never$2 as in, close as ir, interrupt as it, succeed as j, filterMap as ji, suspend$2 as jn, isTimeoutError as jr, failCause$2 as jt, runHead as k, empty$2 as ki, succeedNone as kn, interrupt$3 as kr, exit as kt, ensuring as l, getOrUndefined$1 as la, days as li, orElseSucceed as ln, done as lr, acquireRelease as lt, fromEffectSchedule as m, match$2 as ma, max as mi, repeat as mn, succeed$3 as mr, as as mt, createConnector as n, filter$6 as na, TaggedClass as ni, matchCauseEffect as nn, Scope as nr, set as nt, changesWith as o, getOrElse as oa, compose as oi, onExit$1 as on, makeUnsafe$2 as or, join as ot, fromEffect as p, map$6 as pa, isLessThan as pi, raceFirst as pn, makeUnsafe$3 as pr, annotateLogs as pt, offer as q, add as qi, yieldNow as qn, sync$1 as qr, interrupt$1 as qt, callback as r, flatMap$3 as ra, TaggedError as ri, matchEffect as rn, addFinalizer$1 as rr, getCurrent as rt, debounce as s, getOrNull as sa, has as si, onInterrupt as sn, provide as sr, joinAll as st, wagmiConnectResult as t, exists as ta, Error$1 as ti, mapErrorEager as tn, currentTimeMillis as tr, make$6 as tt, fail as u, isNone as ua, fromInputUnsafe as ui, promise as un, doneUnsafe as ur, addFinalizer as ut, fromSchedule as v, Date$1 as va, seconds as vi, runFork as vn, isFailure as vr, cachedWithTTL as vt, never as w, make$12 as wa, zero as wi, scope as wn, fail$4 as wr, catch_$1 as wt, map as x, isGreaterThanOrEqualTo as xa, toMillis as xi, runSync as xn, void_$1 as xr, catchEager as xt, interruptWhen as y, Number$2 as ya, toDays as yi, runForkWith as yn, isSuccess as yr, callback$1 as yt, unwrap as z, isArrayNonEmpty as zi, uninterruptibleMask as zn, map$4 as zr, forEach as zt };
19149
+ export { shutdown$1 as $, merge$1 as $i, upTo as $n, encodeBase64 as $r, mapEager as $t, share as A, filter$5 as Ai, succeedSome as An, isFailReason as Ar, fail$2 as At, zipLatestAll as B, isReadonlyArrayNonEmpty as Bi, updateContext as Bn, map$4 as Br, forever as Bt, mapError as C, isLessThanOrEqualTo$1 as Ca, toSeconds as Ci, runSyncWith as Cn, NoSuchElementError as Cr, catchTag as Ct, runForEach as D, strictEqual as Da, chunksOf as Di, sleep as Dn, hasInterrupts as Dr, die as Dt, runDrain as E, make$13 as Ea, appendAll$1 as Ei, service as En, findErrorOption as Er, contextWith as Et, tap as F, get$3 as Fi, tryPromise as Fn, effectIsExit as Fr, flatMapEager as Ft, failCauseUnsafe as G, Reference as Gi, withParentSpan as Gn, resolveConcurrency as Gr, gen as Gt, make$2 as H, makeEquivalence as Hi, void_ as Hn, orDie$1 as Hr, forkIn as Ht, toPull as I, getSomes as Ii, try_ as In, flatMap$1 as Ir, fn as It, offerUnsafe as J, empty$4 as Ji, exponential as Jn, suspend$3 as Jr, isEffect as Jt, make$3 as K, Service as Ki, withSpan as Kn, scopeAddFinalizerExit as Kr, ignore as Kt, toQueue as L, head as Li, undefined_ as Ln, forEach$1 as Lr, fnUntraced as Lt, suspend as M, findFirst as Mi, sync as Mn, map$3 as Mr, failCauseSync as Mt, switchMap as N, flatMap$2 as Ni, tap$1 as Nn, squash as Nr, filterOrFail as Nt, runForEachArray as O, dedupeWith as Oi, succeed$2 as On, hasInterruptsOnly as Or, ensuring$2 as Ot, take as P, fromIterable as Pi, tapError as Pn, andThen$1 as Pr, flatMap as Pt, publishUnsafe as Q, make$11 as Qi, spaced as Qn, decodeBase64 as Qr, mapBothEager as Qt, toReadableStreamEffect as R, headNonEmpty as Ri, uninterruptible as Rn, iterateConcurrent as Rr, fnUntracedEager as Rt, mapEffect as S, isLessThan$1 as Sa, toMinutes as Si, runSyncExit as Sn, IllegalArgumentError as Sr, catchIf as St, paginate as T, Tuple as Ta, append$1 as Ti, scopedWith as Tn, filterInterruptors as Tr, context as Tt, makeUnsafe as U, map$5 as Ui, whileLoop as Un, provideContext$1 as Ur, forkScoped as Ut, toPullScoped as V, lastNonEmpty as Vi, useSpan as Vn, onExit$2 as Vr, forkDetach as Vt, dropping as W, empty$3 as Wi, withFiber as Wn, provideService$1 as Wr, fromResult as Wt, take$1 as X, getOrUndefined as Xi, modifyDelay as Xn, void_$2 as Xr, logWarning as Xt, shutdown as Y, get$4 as Yi, isSchedule as Yn, sync$1 as Yr, logError as Yt, publish as Z, getUnsafe$1 as Zi, passthrough as Zn, DisablePropagation as Zr, map$2 as Zt, fromReadableStream as _, BigInt$1 as _a, minutes as _i, runCallbackWith as _n, isExit as _r, cached as _t, changes as a, fromNullishOr as aa, Scheduler as ai, onError as an, forkUnsafe as ar, interruptAll as at, isStream as b, isGreaterThan as ba, toHours as bi, runPromiseExit as bn, succeed$4 as br, catchCause$2 as bt, empty as c, getOrThrowWith as ca, toPredicate as ci, orDie as cn, _await as cr, runIn as ct, filter as d, isSome as da, hours as di, provideService as dn, into as dr, all as dt, mergeAll$1 as ea, Class as ei, mapError$2 as en, isDoneCause as er, unbounded as et, filterEffect as f, liftThrowable as fa, isFinite as fi, race as fn, make$8 as fr, andThen as ft, fromQueue as g, some as ga, min as gi, retry as gn, failCause$4 as gr, asVoid as gt, fromPubSub as h, none as ha, millis as hi, result as hn, fail$3 as hr, asSome as ht, catchCause as i, flatMapNullishOr as ia, MixedScheduler as ii, never$2 as in, close as ir, interrupt as it, succeed as j, filterMap as ji, suspend$2 as jn, isTimeoutError as jr, failCause$2 as jt, runHead as k, empty$2 as ki, succeedNone as kn, interrupt$3 as kr, exit as kt, ensuring as l, getOrUndefined$1 as la, days as li, orElseSucceed as ln, done as lr, acquireRelease as lt, fromEffectSchedule as m, match$2 as ma, max as mi, repeat as mn, succeed$3 as mr, as as mt, createConnector as n, filter$6 as na, TaggedClass as ni, matchCauseEffect as nn, Scope as nr, set as nt, changesWith as o, getOrElse as oa, compose as oi, onExit$1 as on, makeUnsafe$2 as or, join as ot, fromEffect as p, map$6 as pa, isLessThan as pi, raceFirst as pn, makeUnsafe$3 as pr, annotateLogs as pt, offer as q, add as qi, yieldNow as qn, succeed$5 as qr, interrupt$1 as qt, callback as r, flatMap$3 as ra, TaggedError as ri, matchEffect as rn, addFinalizer$1 as rr, getCurrent as rt, debounce as s, getOrNull as sa, has as si, onInterrupt as sn, provide as sr, joinAll as st, wagmiConnectResult as t, exists as ta, Error$1 as ti, mapErrorEager as tn, currentTimeMillis as tr, make$6 as tt, fail as u, isNone as ua, fromInputUnsafe as ui, promise as un, doneUnsafe as ur, addFinalizer as ut, fromSchedule as v, Date$1 as va, seconds as vi, runFork as vn, isFailure as vr, cachedWithTTL as vt, never as w, make$12 as wa, zero as wi, scope as wn, fail$4 as wr, catch_$1 as wt, map as x, isGreaterThanOrEqualTo as xa, toMillis as xi, runSync as xn, void_$1 as xr, catchEager as xt, interruptWhen as y, Number$2 as ya, toDays as yi, runForkWith as yn, isSuccess as yr, callback$1 as yt, unwrap as z, isArrayNonEmpty as zi, uninterruptibleMask as zn, iterateEager as zr, forEach as zt };