@aerovato/operator-helper 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -323,13 +323,13 @@ var require_directives = __commonJS((exports) => {
323
323
  onError5(0, "%YAML directive should contain exactly one part");
324
324
  return false;
325
325
  }
326
- const [version2] = parts;
327
- if (version2 === "1.1" || version2 === "1.2") {
328
- this.yaml.version = version2;
326
+ const [version] = parts;
327
+ if (version === "1.1" || version === "1.2") {
328
+ this.yaml.version = version;
329
329
  return true;
330
330
  } else {
331
- const isValid = /^\d+\.\d+$/.test(version2);
332
- onError5(6, `Unsupported YAML version ${version2}`, isValid);
331
+ const isValid = /^\d+\.\d+$/.test(version);
332
+ onError5(6, `Unsupported YAML version ${version}`, isValid);
333
333
  return false;
334
334
  }
335
335
  }
@@ -726,8 +726,8 @@ var require_createNode = __commonJS((exports) => {
726
726
  var defaultTagPrefix = "tag:yaml.org,2002:";
727
727
  function findTagObject(value, tagName, tags) {
728
728
  if (tagName) {
729
- const match6 = tags.filter((t) => t.tag === tagName);
730
- const tagObj = match6.find((t) => !t.format) ?? match6[0];
729
+ const match7 = tags.filter((t) => t.tag === tagName);
730
+ const tagObj = match7.find((t) => !t.format) ?? match7[0];
731
731
  if (!tagObj)
732
732
  throw new Error(`Tag ${tagName} not found`);
733
733
  return tagObj;
@@ -1407,21 +1407,21 @@ var require_stringify = __commonJS((exports) => {
1407
1407
  }
1408
1408
  function getTagObject(tags, item) {
1409
1409
  if (item.tag) {
1410
- const match6 = tags.filter((t) => t.tag === item.tag);
1411
- if (match6.length > 0)
1412
- return match6.find((t) => t.format === item.format) ?? match6[0];
1410
+ const match7 = tags.filter((t) => t.tag === item.tag);
1411
+ if (match7.length > 0)
1412
+ return match7.find((t) => t.format === item.format) ?? match7[0];
1413
1413
  }
1414
1414
  let tagObj = undefined;
1415
1415
  let obj;
1416
1416
  if (identity3.isScalar(item)) {
1417
1417
  obj = item.value;
1418
- let match6 = tags.filter((t) => t.identify?.(obj));
1419
- if (match6.length > 1) {
1420
- const testMatch = match6.filter((t) => t.test);
1418
+ let match7 = tags.filter((t) => t.identify?.(obj));
1419
+ if (match7.length > 1) {
1420
+ const testMatch = match7.filter((t) => t.test);
1421
1421
  if (testMatch.length > 0)
1422
- match6 = testMatch;
1422
+ match7 = testMatch;
1423
1423
  }
1424
- tagObj = match6.find((t) => t.format === item.format) ?? match6.find((t) => !t.format);
1424
+ tagObj = match7.find((t) => t.format === item.format) ?? match7.find((t) => !t.format);
1425
1425
  } else {
1426
1426
  obj = item;
1427
1427
  tagObj = tags.find((t) => t.nodeClass && obj instanceof t.nodeClass);
@@ -2945,13 +2945,13 @@ var require_timestamp = __commonJS((exports) => {
2945
2945
  tag: "tag:yaml.org,2002:timestamp",
2946
2946
  test: RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})" + "(?:" + "(?:t|T|[ \\t]+)" + "([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)" + "(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?" + ")?$"),
2947
2947
  resolve(str) {
2948
- const match6 = str.match(timestamp.test);
2949
- if (!match6)
2948
+ const match7 = str.match(timestamp.test);
2949
+ if (!match7)
2950
2950
  throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");
2951
- const [, year, month, day, hour, minute, second] = match6.map(Number);
2952
- const millisec = match6[7] ? Number((match6[7] + "00").substr(1, 3)) : 0;
2951
+ const [, year, month, day, hour, minute, second] = match7.map(Number);
2952
+ const millisec = match7[7] ? Number((match7[7] + "00").substr(1, 3)) : 0;
2953
2953
  let date = Date.UTC(year, month - 1, day, hour || 0, minute || 0, second || 0, millisec);
2954
- const tz = match6[8];
2954
+ const tz = match7[8];
2955
2955
  if (tz && tz !== "Z") {
2956
2956
  let d = parseSexagesimal(tz, false);
2957
2957
  if (Math.abs(d) < 30)
@@ -3248,14 +3248,14 @@ var require_Document = __commonJS((exports) => {
3248
3248
  version: "1.2"
3249
3249
  }, options);
3250
3250
  this.options = opt;
3251
- let { version: version2 } = opt;
3251
+ let { version } = opt;
3252
3252
  if (options?._directives) {
3253
3253
  this.directives = options._directives.atDocument();
3254
3254
  if (this.directives.yaml.explicit)
3255
- version2 = this.directives.yaml.version;
3255
+ version = this.directives.yaml.version;
3256
3256
  } else
3257
- this.directives = new directives.Directives({ version: version2 });
3258
- this.setSchema(version2, options);
3257
+ this.directives = new directives.Directives({ version });
3258
+ this.setSchema(version, options);
3259
3259
  this.contents = value === undefined ? null : this.createNode(value, _replacer, options);
3260
3260
  }
3261
3261
  clone() {
@@ -3371,11 +3371,11 @@ var require_Document = __commonJS((exports) => {
3371
3371
  this.contents.setIn(path, value);
3372
3372
  }
3373
3373
  }
3374
- setSchema(version2, options = {}) {
3375
- if (typeof version2 === "number")
3376
- version2 = String(version2);
3374
+ setSchema(version, options = {}) {
3375
+ if (typeof version === "number")
3376
+ version = String(version);
3377
3377
  let opt;
3378
- switch (version2) {
3378
+ switch (version) {
3379
3379
  case "1.1":
3380
3380
  if (this.directives)
3381
3381
  this.directives.yaml.version = "1.1";
@@ -3386,9 +3386,9 @@ var require_Document = __commonJS((exports) => {
3386
3386
  case "1.2":
3387
3387
  case "next":
3388
3388
  if (this.directives)
3389
- this.directives.yaml.version = version2;
3389
+ this.directives.yaml.version = version;
3390
3390
  else
3391
- this.directives = new directives.Directives({ version: version2 });
3391
+ this.directives = new directives.Directives({ version });
3392
3392
  opt = { resolveKnownTags: true, schema: "core" };
3393
3393
  break;
3394
3394
  case null:
@@ -3397,7 +3397,7 @@ var require_Document = __commonJS((exports) => {
3397
3397
  opt = null;
3398
3398
  break;
3399
3399
  default: {
3400
- const sv = JSON.stringify(version2);
3400
+ const sv = JSON.stringify(version);
3401
3401
  throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${sv}`);
3402
3402
  }
3403
3403
  }
@@ -4431,15 +4431,15 @@ var require_resolve_flow_scalar = __commonJS((exports) => {
4431
4431
  first = /(.*?)[ \t]*\r?\n/sy;
4432
4432
  line = /[ \t]*(.*?)[ \t]*\r?\n/sy;
4433
4433
  }
4434
- let match6 = first.exec(source);
4435
- if (!match6)
4434
+ let match7 = first.exec(source);
4435
+ if (!match7)
4436
4436
  return source;
4437
- let res = match6[1];
4437
+ let res = match7[1];
4438
4438
  let sep = " ";
4439
4439
  let pos = first.lastIndex;
4440
4440
  line.lastIndex = pos;
4441
- while (match6 = line.exec(source)) {
4442
- if (match6[1] === "") {
4441
+ while (match7 = line.exec(source)) {
4442
+ if (match7[1] === "") {
4443
4443
  if (sep === `
4444
4444
  `)
4445
4445
  res += sep;
@@ -4447,15 +4447,15 @@ var require_resolve_flow_scalar = __commonJS((exports) => {
4447
4447
  sep = `
4448
4448
  `;
4449
4449
  } else {
4450
- res += sep + match6[1];
4450
+ res += sep + match7[1];
4451
4451
  sep = " ";
4452
4452
  }
4453
4453
  pos = line.lastIndex;
4454
4454
  }
4455
4455
  const last = /[ \t]*(.*)/sy;
4456
4456
  last.lastIndex = pos;
4457
- match6 = last.exec(source);
4458
- return res + sep + (match6?.[1] ?? "");
4457
+ match7 = last.exec(source);
4458
+ return res + sep + (match7?.[1] ?? "");
4459
4459
  }
4460
4460
  function doubleQuotedValue(source, onError5) {
4461
4461
  let res = "";
@@ -7522,10 +7522,10 @@ var require_supports_colors = __commonJS((exports, module) => {
7522
7522
  return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
7523
7523
  }
7524
7524
  if ("TERM_PROGRAM" in env) {
7525
- var version2 = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
7525
+ var version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
7526
7526
  switch (env.TERM_PROGRAM) {
7527
7527
  case "iTerm.app":
7528
- return version2 >= 3 ? 3 : 2;
7528
+ return version >= 3 ? 3 : 2;
7529
7529
  case "Hyper":
7530
7530
  return 3;
7531
7531
  case "Apple_Terminal":
@@ -7959,8 +7959,8 @@ var require_colors = __commonJS((exports, module) => {
7959
7959
  var code = ansiStyles[nestedStyles[i]];
7960
7960
  str = code.open + str.replace(code.closeRe, code.open) + code.close;
7961
7961
  if (newLinesPresent) {
7962
- str = str.replace(newLineRegex, function(match6) {
7963
- return code.close + match6 + code.open;
7962
+ str = str.replace(newLineRegex, function(match7) {
7963
+ return code.close + match7 + code.open;
7964
7964
  });
7965
7965
  }
7966
7966
  }
@@ -8672,14 +8672,14 @@ var require_table = __commonJS((exports, module) => {
8672
8672
 
8673
8673
  // src/index.ts
8674
8674
  import { homedir } from "node:os";
8675
- // ../../node_modules/.bun/@effect+platform-node@4.0.0-beta.98+421eccb9593286ba/node_modules/@effect/platform-node/dist/NodeChildProcessSpawner.js
8675
+ // ../../node_modules/.bun/@effect+platform-node@4.0.0-beta.107+a2edc8a872f58f99/node_modules/@effect/platform-node/dist/NodeChildProcessSpawner.js
8676
8676
  var exports_NodeChildProcessSpawner = {};
8677
8677
  __export(exports_NodeChildProcessSpawner, {
8678
8678
  layer: () => layer2,
8679
8679
  flattenCommand: () => flattenCommand
8680
8680
  });
8681
8681
 
8682
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Pipeable.js
8682
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Pipeable.js
8683
8683
  var pipeArguments = (self, args) => {
8684
8684
  switch (args.length) {
8685
8685
  case 0:
@@ -8722,7 +8722,7 @@ var Class = /* @__PURE__ */ function() {
8722
8722
  return PipeableBase;
8723
8723
  }();
8724
8724
 
8725
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Function.js
8725
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Function.js
8726
8726
  var dual = function(arity, body) {
8727
8727
  if (typeof arity === "function") {
8728
8728
  return function() {
@@ -8813,7 +8813,7 @@ function flow(ab, bc, cd, de, ef, fg, gh, hi, ij) {
8813
8813
  return;
8814
8814
  }
8815
8815
 
8816
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/internal/equal.js
8816
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/internal/equal.js
8817
8817
  var getAllObjectKeys = (obj) => {
8818
8818
  const keys = new Set(Reflect.ownKeys(obj));
8819
8819
  if (obj.constructor === Object)
@@ -8837,7 +8837,7 @@ var getAllObjectKeys = (obj) => {
8837
8837
  };
8838
8838
  var byReferenceInstances = /* @__PURE__ */ new WeakSet;
8839
8839
 
8840
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Predicate.js
8840
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Predicate.js
8841
8841
  function isString(input) {
8842
8842
  return typeof input === "string";
8843
8843
  }
@@ -8865,7 +8865,7 @@ function isIterable(input) {
8865
8865
  return hasProperty(input, Symbol.iterator) || isString(input);
8866
8866
  }
8867
8867
 
8868
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Hash.js
8868
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Hash.js
8869
8869
  var symbol = "~effect/interfaces/Hash";
8870
8870
  var hash = (self) => {
8871
8871
  switch (typeof self) {
@@ -8886,6 +8886,9 @@ var hash = (self) => {
8886
8886
  if (self === null) {
8887
8887
  return string("null");
8888
8888
  } else if (self instanceof Date) {
8889
+ if (Number.isNaN(self.getTime())) {
8890
+ return string("Invalid Date");
8891
+ }
8889
8892
  return string(self.toISOString());
8890
8893
  } else if (self instanceof RegExp) {
8891
8894
  return string(self.toString());
@@ -8901,6 +8904,8 @@ var hash = (self) => {
8901
8904
  return self[symbol]();
8902
8905
  } else if (typeof self === "function") {
8903
8906
  return random(self);
8907
+ } else if (self instanceof DataView) {
8908
+ return array(new Uint8Array(self.buffer, self.byteOffset, self.byteLength));
8904
8909
  } else if (Array.isArray(self) || ArrayBuffer.isView(self)) {
8905
8910
  return array(self);
8906
8911
  } else if (self instanceof Map) {
@@ -8984,7 +8989,7 @@ function withVisitedTracking(obj, fn) {
8984
8989
  return result;
8985
8990
  }
8986
8991
 
8987
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Equal.js
8992
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Equal.js
8988
8993
  var symbol2 = "~effect/interfaces/Equal";
8989
8994
  function equals() {
8990
8995
  if (arguments.length === 1) {
@@ -9036,7 +9041,9 @@ function compareObjects(self, that) {
9036
9041
  } else if (self instanceof Date) {
9037
9042
  if (!(that instanceof Date))
9038
9043
  return false;
9039
- return self.toISOString() === that.toISOString();
9044
+ const selfTime = self.getTime();
9045
+ const thatTime = that.getTime();
9046
+ return selfTime === thatTime || Number.isNaN(selfTime) && Number.isNaN(thatTime);
9040
9047
  } else if (self instanceof RegExp) {
9041
9048
  if (!(that instanceof RegExp))
9042
9049
  return false;
@@ -9059,9 +9066,14 @@ function compareObjects(self, that) {
9059
9066
  }
9060
9067
  return compareArrays(self, that);
9061
9068
  } else if (ArrayBuffer.isView(self)) {
9062
- if (!ArrayBuffer.isView(that) || self.byteLength !== that.byteLength) {
9069
+ const selfIsDataView = self instanceof DataView;
9070
+ if (!ArrayBuffer.isView(that) || self.byteLength !== that.byteLength || selfIsDataView !== that instanceof DataView) {
9063
9071
  return false;
9064
9072
  }
9073
+ if (selfIsDataView) {
9074
+ const thatDataView = that;
9075
+ return compareTypedArrays(new Uint8Array(self.buffer, self.byteOffset, self.byteLength), new Uint8Array(thatDataView.buffer, thatDataView.byteOffset, thatDataView.byteLength));
9076
+ }
9065
9077
  return compareTypedArrays(self, that);
9066
9078
  } else if (self instanceof Map) {
9067
9079
  if (!(that instanceof Map) || self.size !== that.size) {
@@ -9130,10 +9142,14 @@ function compareRecords(self, that) {
9130
9142
  }
9131
9143
  function makeCompareMap(keyEquivalence, valueEquivalence) {
9132
9144
  return function compareMaps(self, that) {
9145
+ const thatEntries = Array.from(that);
9133
9146
  for (const [selfKey, selfValue] of self) {
9134
9147
  let found = false;
9135
- for (const [thatKey, thatValue] of that) {
9148
+ for (let i = 0;i < thatEntries.length; i++) {
9149
+ const [thatKey, thatValue] = thatEntries[i];
9136
9150
  if (keyEquivalence(selfKey, thatKey) && valueEquivalence(selfValue, thatValue)) {
9151
+ thatEntries[i] = thatEntries[thatEntries.length - 1];
9152
+ thatEntries.pop();
9137
9153
  found = true;
9138
9154
  break;
9139
9155
  }
@@ -9148,10 +9164,14 @@ function makeCompareMap(keyEquivalence, valueEquivalence) {
9148
9164
  var compareMaps = /* @__PURE__ */ makeCompareMap(compareBoth, compareBoth);
9149
9165
  function makeCompareSet(equivalence) {
9150
9166
  return function compareSets(self, that) {
9167
+ const thatValues = Array.from(that);
9151
9168
  for (const selfValue of self) {
9152
9169
  let found = false;
9153
- for (const thatValue of that) {
9170
+ for (let i = 0;i < thatValues.length; i++) {
9171
+ const thatValue = thatValues[i];
9154
9172
  if (equivalence(selfValue, thatValue)) {
9173
+ thatValues[i] = thatValues[thatValues.length - 1];
9174
+ thatValues.pop();
9155
9175
  found = true;
9156
9176
  break;
9157
9177
  }
@@ -9171,7 +9191,7 @@ var byReferenceUnsafe = (obj) => {
9171
9191
  return obj;
9172
9192
  };
9173
9193
 
9174
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Redactable.js
9194
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Redactable.js
9175
9195
  var symbolRedactable = /* @__PURE__ */ Symbol.for("~effect/Redactable");
9176
9196
  var isRedactable = (u) => hasProperty(u, symbolRedactable);
9177
9197
  function redact(u) {
@@ -9183,18 +9203,21 @@ function getRedacted(redactable) {
9183
9203
  return redactable[symbolRedactable](globalThis[currentFiberTypeId]?.context ?? emptyContext);
9184
9204
  }
9185
9205
  var currentFiberTypeId = "~effect/Fiber/currentFiber";
9206
+ var emptyMap = /* @__PURE__ */ new Map;
9186
9207
  var emptyContext = {
9187
9208
  "~effect/Context": {},
9188
- mapUnsafe: /* @__PURE__ */ new Map,
9209
+ base: emptyMap,
9210
+ depth: 0,
9211
+ mapUnsafe: emptyMap,
9189
9212
  pipe() {
9190
9213
  return pipeArguments(this, arguments);
9191
9214
  }
9192
9215
  };
9193
9216
 
9194
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Formatter.js
9217
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Formatter.js
9195
9218
  function format(input, options) {
9196
9219
  const space = options?.space ?? 0;
9197
- const seen = new WeakSet;
9220
+ const ancestors = new WeakSet;
9198
9221
  const gap = !space ? "" : typeof space === "number" ? " ".repeat(space) : space;
9199
9222
  const ind = (d) => gap.repeat(d);
9200
9223
  const wrap = (v, body) => {
@@ -9210,16 +9233,15 @@ function format(input, options) {
9210
9233
  };
9211
9234
  function recur(v, d = 0) {
9212
9235
  if (Array.isArray(v)) {
9213
- if (seen.has(v))
9236
+ if (ancestors.has(v))
9214
9237
  return CIRCULAR;
9215
- seen.add(v);
9216
- if (!gap || v.length <= 1)
9217
- return `[${v.map((x) => recur(x, d)).join(",")}]`;
9218
- const inner = v.map((x) => recur(x, d + 1)).join(`,
9219
- ` + ind(d + 1));
9220
- return `[
9221
- ${ind(d + 1)}${inner}
9238
+ ancestors.add(v);
9239
+ const output = !gap || v.length <= 1 ? `[${v.map((x) => recur(x, d)).join(",")}]` : `[
9240
+ ${ind(d + 1)}${v.map((x) => recur(x, d + 1)).join(`,
9241
+ ` + ind(d + 1))}
9222
9242
  ${ind(d)}]`;
9243
+ ancestors.delete(v);
9244
+ return output;
9223
9245
  }
9224
9246
  if (v instanceof Date)
9225
9247
  return formatDate(v);
@@ -9237,24 +9259,29 @@ ${ind(d)}]`;
9237
9259
  if (typeof v === "bigint")
9238
9260
  return String(v) + "n";
9239
9261
  if (typeof v === "object" || typeof v === "function") {
9240
- if (seen.has(v))
9262
+ if (ancestors.has(v))
9241
9263
  return CIRCULAR;
9242
- seen.add(v);
9243
- if (symbolRedactable in v)
9244
- return format(getRedacted(v));
9245
- if (Symbol.iterator in v) {
9246
- return `${v.constructor.name}(${recur(Array.from(v), d)})`;
9247
- }
9248
- const keys = ownKeys(v);
9249
- if (!gap || keys.length <= 1) {
9250
- const body2 = `{${keys.map((k) => `${formatPropertyKey(k)}:${recur(v[k], d)}`).join(",")}}`;
9251
- return wrap(v, body2);
9252
- }
9253
- const body = `{
9264
+ ancestors.add(v);
9265
+ let output;
9266
+ if (symbolRedactable in v) {
9267
+ output = format(getRedacted(v));
9268
+ } else if (Symbol.iterator in v) {
9269
+ output = `${v.constructor.name}(${recur(Array.from(v), d)})`;
9270
+ } else {
9271
+ const keys = ownKeys(v);
9272
+ if (!gap || keys.length <= 1) {
9273
+ const body = `{${keys.map((k) => `${formatPropertyKey(k)}:${recur(v[k], d)}`).join(",")}}`;
9274
+ output = wrap(v, body);
9275
+ } else {
9276
+ const body = `{
9254
9277
  ${keys.map((k) => `${ind(d + 1)}${formatPropertyKey(k)}: ${recur(v[k], d + 1)}`).join(`,
9255
9278
  `)}
9256
9279
  ${ind(d)}}`;
9257
- return wrap(v, body);
9280
+ output = wrap(v, body);
9281
+ }
9282
+ }
9283
+ ancestors.delete(v);
9284
+ return output;
9258
9285
  }
9259
9286
  return String(v);
9260
9287
  }
@@ -9294,10 +9321,10 @@ function formatJson(input, options) {
9294
9321
  }
9295
9322
  ancestors.push(redacted);
9296
9323
  return redacted;
9297
- }, options?.space);
9324
+ }, options?.space) ?? "null";
9298
9325
  }
9299
9326
 
9300
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Inspectable.js
9327
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Inspectable.js
9301
9328
  var NodeInspectSymbol = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
9302
9329
  var toJson = (input) => {
9303
9330
  try {
@@ -9335,7 +9362,7 @@ var BaseProto = {
9335
9362
  }
9336
9363
  };
9337
9364
 
9338
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Utils.js
9365
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Utils.js
9339
9366
  class SingleShotGen {
9340
9367
  called = false;
9341
9368
  self;
@@ -9374,7 +9401,28 @@ var pickInternalCall = () => {
9374
9401
  };
9375
9402
  var internalCall = /* @__PURE__ */ pickInternalCall();
9376
9403
 
9377
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/internal/core.js
9404
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/internal/record.js
9405
+ function assignProperty(self, key, value) {
9406
+ if (key === "__proto__") {
9407
+ Object.defineProperty(self, key, {
9408
+ value,
9409
+ writable: true,
9410
+ enumerable: true,
9411
+ configurable: true
9412
+ });
9413
+ } else {
9414
+ self[key] = value;
9415
+ }
9416
+ }
9417
+ function assignProperties(self, source) {
9418
+ for (const key of Reflect.ownKeys(source)) {
9419
+ if (Object.prototype.propertyIsEnumerable.call(source, key)) {
9420
+ assignProperty(self, key, source[key]);
9421
+ }
9422
+ }
9423
+ }
9424
+
9425
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/internal/core.js
9378
9426
  var EffectTypeId = `~effect/Effect`;
9379
9427
  var ExitTypeId = `~effect/Exit`;
9380
9428
  var effectVariance = {
@@ -9596,12 +9644,12 @@ var makePrimitive = (options) => {
9596
9644
  };
9597
9645
  var makeExit = (options) => {
9598
9646
  const Proto = {
9599
- ...makePrimitiveProto(options),
9600
9647
  [ExitTypeId]: ExitTypeId,
9601
9648
  _tag: options.op,
9602
9649
  get [options.prop]() {
9603
9650
  return this[args];
9604
9651
  },
9652
+ ...makePrimitiveProto(options),
9605
9653
  toString() {
9606
9654
  return `${options.op}(${format(this[args])})`;
9607
9655
  },
@@ -9655,7 +9703,7 @@ var exitFailCause = /* @__PURE__ */ makeExit({
9655
9703
  while (fiber.interruptible && fiber._interruptedCause && cont) {
9656
9704
  cont = fiber.getCont(contE);
9657
9705
  }
9658
- return cont ? cont[contE](cause, fiber, annotated ? undefined : this) : fiber.yieldWith(annotated ? this : exitFailCause(cause));
9706
+ return cont ? cont[contE](cause, fiber, annotated ? undefined : this) : fiber.yieldWith(annotated ? exitFailCause(cause) : this);
9659
9707
  }
9660
9708
  });
9661
9709
  var exitFail = (e) => exitFailCause(causeFail(e));
@@ -9688,7 +9736,7 @@ var Error2 = /* @__PURE__ */ function() {
9688
9736
  cause: args2.cause
9689
9737
  } : undefined);
9690
9738
  if (args2) {
9691
- Object.assign(this, args2);
9739
+ assignProperties(this, args2);
9692
9740
  Object.defineProperty(this, plainArgsSymbol, {
9693
9741
  value: args2,
9694
9742
  enumerable: false
@@ -9745,7 +9793,7 @@ var done = (value) => {
9745
9793
  return exitFail(Done(value));
9746
9794
  };
9747
9795
 
9748
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Reducer.js
9796
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Reducer.js
9749
9797
  function make(combine2, initialValue, combineAll) {
9750
9798
  return {
9751
9799
  combine: combine2,
@@ -9760,13 +9808,13 @@ function make(combine2, initialValue, combineAll) {
9760
9808
  };
9761
9809
  }
9762
9810
 
9763
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Equivalence.js
9811
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Equivalence.js
9764
9812
  var make2 = (isEquivalent) => (self, that) => self === that || isEquivalent(self, that);
9765
9813
 
9766
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/internal/array.js
9814
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/internal/array.js
9767
9815
  var isArrayNonEmpty = (self) => self.length > 0;
9768
9816
 
9769
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/internal/doNotation.js
9817
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/internal/doNotation.js
9770
9818
  var let_ = (map) => dual(3, (self, name, f) => map(self, (a) => ({
9771
9819
  ...a,
9772
9820
  [name]: f(a)
@@ -9779,7 +9827,7 @@ var bind = (map, flatMap) => dual(3, (self, name, f) => flatMap(self, (a) => map
9779
9827
  [name]: b
9780
9828
  }))));
9781
9829
 
9782
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Option.js
9830
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Option.js
9783
9831
  var exports_Option = {};
9784
9832
  __export(exports_Option, {
9785
9833
  zipWith: () => zipWith,
@@ -9844,14 +9892,14 @@ __export(exports_Option, {
9844
9892
  Do: () => Do
9845
9893
  });
9846
9894
 
9847
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Combiner.js
9895
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Combiner.js
9848
9896
  function make3(combine2) {
9849
9897
  return {
9850
9898
  combine: combine2
9851
9899
  };
9852
9900
  }
9853
9901
 
9854
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/internal/option.js
9902
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/internal/option.js
9855
9903
  var TypeId = "~effect/data/Option";
9856
9904
  var CommonProto = {
9857
9905
  [TypeId]: {
@@ -9917,7 +9965,7 @@ var some = (value) => {
9917
9965
  return a;
9918
9966
  };
9919
9967
 
9920
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/internal/result.js
9968
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/internal/result.js
9921
9969
  var TypeId2 = "~effect/data/Result";
9922
9970
  var CommonProto2 = {
9923
9971
  [TypeId2]: {
@@ -9986,7 +10034,7 @@ var getFailure = (self) => isSuccess(self) ? none : some(self.failure);
9986
10034
  var getSuccess = (self) => isFailure(self) ? none : some(self.success);
9987
10035
  var fromOption = /* @__PURE__ */ dual(2, (self, onNone) => isNone(self) ? fail(onNone()) : succeed(self.value));
9988
10036
 
9989
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Order.js
10037
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Order.js
9990
10038
  function make4(compare) {
9991
10039
  return (self, that) => self === that ? 0 : compare(self, that);
9992
10040
  }
@@ -10002,7 +10050,7 @@ var Number2 = /* @__PURE__ */ make4((self, that) => {
10002
10050
  var mapInput = /* @__PURE__ */ dual(2, (self, f) => make4((b1, b2) => self(f(b1), f(b2))));
10003
10051
  var isGreaterThan = (O) => dual(2, (self, that) => O(self, that) === 1);
10004
10052
 
10005
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Option.js
10053
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Option.js
10006
10054
  var none2 = () => none;
10007
10055
  var some2 = some;
10008
10056
  var isOption2 = isOption;
@@ -10100,7 +10148,7 @@ var all = (input) => {
10100
10148
  if (isNone2(o)) {
10101
10149
  return none2();
10102
10150
  }
10103
- out[key] = o.value;
10151
+ assignProperty(out, key, o.value);
10104
10152
  }
10105
10153
  return some2(out);
10106
10154
  };
@@ -10184,7 +10232,7 @@ function makeReducerFailFast(reducer) {
10184
10232
  });
10185
10233
  }
10186
10234
 
10187
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Result.js
10235
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Result.js
10188
10236
  var exports_Result = {};
10189
10237
  __export(exports_Result, {
10190
10238
  void: () => void_2,
@@ -10259,8 +10307,8 @@ var mapBoth = /* @__PURE__ */ dual(2, (self, {
10259
10307
  onFailure,
10260
10308
  onSuccess
10261
10309
  }) => isFailure2(self) ? fail2(onFailure(self.failure)) : succeed2(onSuccess(self.success)));
10262
- var mapError = /* @__PURE__ */ dual(2, (self, f) => isFailure2(self) ? fail2(f(self.failure)) : succeed2(self.success));
10263
- var map2 = /* @__PURE__ */ dual(2, (self, f) => isSuccess2(self) ? succeed2(f(self.success)) : fail2(self.failure));
10310
+ var mapError = /* @__PURE__ */ dual(2, (self, f) => isFailure2(self) ? fail2(f(self.failure)) : self);
10311
+ var map2 = /* @__PURE__ */ dual(2, (self, f) => isSuccess2(self) ? succeed2(f(self.success)) : self);
10264
10312
  var match2 = /* @__PURE__ */ dual(2, (self, {
10265
10313
  onFailure,
10266
10314
  onSuccess
@@ -10304,7 +10352,7 @@ var all2 = (input) => {
10304
10352
  if (isFailure2(e)) {
10305
10353
  return e;
10306
10354
  }
10307
- out[key] = e.success;
10355
+ assignProperty(out, key, e.success);
10308
10356
  }
10309
10357
  return succeed2(out);
10310
10358
  };
@@ -10339,7 +10387,7 @@ var tap2 = /* @__PURE__ */ dual(2, (self, f) => {
10339
10387
  return self;
10340
10388
  });
10341
10389
 
10342
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Iterable.js
10390
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Iterable.js
10343
10391
  var makeBy = (f, options) => {
10344
10392
  const max = options?.length !== undefined ? Math.max(1, Math.floor(options.length)) : Infinity;
10345
10393
  return {
@@ -10391,19 +10439,20 @@ var flatten2 = (self) => ({
10391
10439
  const outerIterator = self[Symbol.iterator]();
10392
10440
  let innerIterator;
10393
10441
  function next() {
10394
- if (innerIterator === undefined) {
10395
- const next2 = outerIterator.next();
10396
- if (next2.done) {
10397
- return next2;
10442
+ while (true) {
10443
+ if (innerIterator === undefined) {
10444
+ const next2 = outerIterator.next();
10445
+ if (next2.done) {
10446
+ return next2;
10447
+ }
10448
+ innerIterator = next2.value[Symbol.iterator]();
10449
+ }
10450
+ const result = innerIterator.next();
10451
+ if (!result.done) {
10452
+ return result;
10398
10453
  }
10399
- innerIterator = next2.value[Symbol.iterator]();
10400
- }
10401
- const result = innerIterator.next();
10402
- if (result.done) {
10403
10454
  innerIterator = undefined;
10404
- return next();
10405
10455
  }
10406
- return result;
10407
10456
  }
10408
10457
  return {
10409
10458
  next
@@ -10435,7 +10484,7 @@ var filter2 = /* @__PURE__ */ dual(2, (self, predicate) => ({
10435
10484
  }
10436
10485
  }));
10437
10486
 
10438
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Array.js
10487
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Array.js
10439
10488
  var Array2 = globalThis.Array;
10440
10489
  var allocate = (n) => new Array2(n);
10441
10490
  var makeBy2 = /* @__PURE__ */ dual(2, (n, f) => {
@@ -10453,7 +10502,7 @@ var isArray = Array2.isArray;
10453
10502
  var isArrayNonEmpty2 = isArrayNonEmpty;
10454
10503
  var isReadonlyArrayNonEmpty = isArrayNonEmpty;
10455
10504
  function isOutOfBounds(i, as2) {
10456
- return i < 0 || i >= as2.length;
10505
+ return !Number.isFinite(i) || i < 0 || i >= as2.length;
10457
10506
  }
10458
10507
  var getUnsafe = /* @__PURE__ */ dual(2, (self, index) => {
10459
10508
  const i = Math.floor(index);
@@ -10462,27 +10511,35 @@ var getUnsafe = /* @__PURE__ */ dual(2, (self, index) => {
10462
10511
  }
10463
10512
  return self[i];
10464
10513
  });
10465
- var headNonEmpty = /* @__PURE__ */ getUnsafe(0);
10466
10514
  var lastNonEmpty = (self) => self[self.length - 1];
10467
- var tailNonEmpty = (self) => self.slice(1);
10468
10515
  var sort = /* @__PURE__ */ dual(2, (self, O) => {
10469
10516
  const out = Array2.from(self);
10470
10517
  out.sort(O);
10471
10518
  return out;
10472
10519
  });
10473
- var unionWith = /* @__PURE__ */ dual(3, (self, that, isEquivalent) => {
10520
+ var hashBucketsAdd = (buckets, value) => {
10521
+ const hash2 = hash(value);
10522
+ const bucket = buckets.get(hash2);
10523
+ if (bucket === undefined) {
10524
+ buckets.set(hash2, [value]);
10525
+ return true;
10526
+ }
10527
+ for (const previous of bucket) {
10528
+ if (equals(previous, value)) {
10529
+ return false;
10530
+ }
10531
+ }
10532
+ bucket.push(value);
10533
+ return true;
10534
+ };
10535
+ var union = /* @__PURE__ */ dual(2, (self, that) => {
10474
10536
  const a = fromIterable2(self);
10475
10537
  const b = fromIterable2(that);
10476
10538
  if (isReadonlyArrayNonEmpty(a)) {
10477
- if (isReadonlyArrayNonEmpty(b)) {
10478
- const dedupe = dedupeWith(isEquivalent);
10479
- return dedupe(appendAll(a, b));
10480
- }
10481
- return a;
10539
+ return isReadonlyArrayNonEmpty(b) ? dedupe(appendAll(a, b)) : a;
10482
10540
  }
10483
10541
  return b;
10484
10542
  });
10485
- var union = /* @__PURE__ */ dual(2, (self, that) => unionWith(self, that, asEquivalence()));
10486
10543
  var empty = () => [];
10487
10544
  var of = (a) => [a];
10488
10545
  var map3 = /* @__PURE__ */ dual(2, (self, f) => self.map(f));
@@ -10510,27 +10567,26 @@ var partition = /* @__PURE__ */ dual(2, (self, f) => {
10510
10567
  }
10511
10568
  return [excluded, satisfying];
10512
10569
  });
10513
- var dedupeWith = /* @__PURE__ */ dual(2, (self, isEquivalent) => {
10570
+ var dedupe = (self) => {
10514
10571
  const input = fromIterable2(self);
10515
- if (isReadonlyArrayNonEmpty(input)) {
10516
- const out = [headNonEmpty(input)];
10517
- const rest = tailNonEmpty(input);
10518
- for (const r of rest) {
10519
- if (out.every((a) => !isEquivalent(r, a))) {
10520
- out.push(r);
10521
- }
10572
+ if (input.length < 2) {
10573
+ return [...input];
10574
+ }
10575
+ const buckets = new Map;
10576
+ const out = [];
10577
+ for (const value of input) {
10578
+ if (hashBucketsAdd(buckets, value)) {
10579
+ out.push(value);
10522
10580
  }
10523
- return out;
10524
10581
  }
10525
- return [];
10526
- });
10582
+ return out;
10583
+ };
10527
10584
 
10528
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Context.js
10585
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Context.js
10529
10586
  var exports_Context = {};
10530
10587
  __export(exports_Context, {
10531
10588
  pick: () => pick,
10532
10589
  omit: () => omit,
10533
- mutate: () => mutate,
10534
10590
  mergeAll: () => mergeAll,
10535
10591
  merge: () => merge2,
10536
10592
  makeUnsafe: () => makeUnsafe,
@@ -10538,8 +10594,9 @@ __export(exports_Context, {
10538
10594
  isReference: () => isReference,
10539
10595
  isKey: () => isKey,
10540
10596
  isContext: () => isContext,
10597
+ hasSameCache: () => hasSameCache,
10541
10598
  getUnsafe: () => getUnsafe2,
10542
- getReferenceUnsafe: () => getReferenceUnsafe,
10599
+ getOrUndefinedUnsafe: () => getOrUndefinedUnsafe,
10543
10600
  getOrUndefined: () => getOrUndefined3,
10544
10601
  getOrElse: () => getOrElse3,
10545
10602
  getOption: () => getOption,
@@ -10552,61 +10609,33 @@ __export(exports_Context, {
10552
10609
  Reference: () => Reference
10553
10610
  });
10554
10611
 
10555
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Effectable.js
10612
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Effectable.js
10556
10613
  var Prototype2 = (options) => makePrimitiveProto({
10557
10614
  op: options.label,
10558
10615
  [evaluate]: options.evaluate
10559
10616
  });
10560
10617
 
10561
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/internal/stackTraceLimit.js
10562
- var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
10563
- var ObjectPrototypeHasOwnProperty = Object.prototype.hasOwnProperty;
10564
- var ObjectIsExtensible = Object.isExtensible;
10565
- var isStackTraceLimitWritable = () => {
10566
- const desc = ObjectGetOwnPropertyDescriptor(Error, "stackTraceLimit");
10567
- if (desc === undefined) {
10568
- return ObjectIsExtensible(Error);
10569
- }
10570
- return ObjectPrototypeHasOwnProperty.call(desc, "writable") ? desc.writable === true : desc.set !== undefined;
10571
- };
10572
- var canWriteStackTraceLimit = /* @__PURE__ */ isStackTraceLimitWritable();
10573
- var getStackTraceLimit = () => Error.stackTraceLimit;
10574
- var setStackTraceLimit = (value) => {
10575
- if (canWriteStackTraceLimit) {
10576
- Error.stackTraceLimit = value;
10577
- }
10578
- };
10579
-
10580
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Context.js
10618
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Context.js
10581
10619
  var ServiceTypeId = "~effect/Context/Service";
10582
10620
  var Service = function() {
10583
- const prevLimit = getStackTraceLimit();
10584
- setStackTraceLimit(2);
10585
- const err = new Error;
10586
- setStackTraceLimit(prevLimit);
10587
10621
  function KeyClass() {}
10588
10622
  const self = KeyClass;
10589
10623
  Object.setPrototypeOf(self, ServiceProto);
10590
- Object.defineProperty(self, "stack", {
10591
- get() {
10592
- return err.stack;
10593
- }
10594
- });
10595
- if (arguments.length > 0) {
10596
- self.key = arguments[0];
10597
- if (arguments[1]?.defaultValue) {
10624
+ const init = (key, options) => {
10625
+ self.key = key;
10626
+ if (options?.defaultValue) {
10598
10627
  self[ReferenceTypeId] = ReferenceTypeId;
10599
- self.defaultValue = arguments[1].defaultValue;
10628
+ self.defaultValue = options.defaultValue;
10600
10629
  }
10601
- return self;
10602
- }
10603
- return function(key, options) {
10604
- self.key = key;
10605
10630
  if (options?.make) {
10606
10631
  self.make = options.make;
10607
10632
  }
10633
+ if (options?.fiberCached) {
10634
+ cacheKeys.add(key);
10635
+ }
10608
10636
  return self;
10609
10637
  };
10638
+ return arguments.length > 0 ? init(arguments[0], arguments[1]) : init;
10610
10639
  };
10611
10640
  var ServiceProto = {
10612
10641
  [ServiceTypeId]: ServiceTypeId,
@@ -10619,8 +10648,7 @@ var ServiceProto = {
10619
10648
  toJSON() {
10620
10649
  return {
10621
10650
  _id: "Service",
10622
- key: this.key,
10623
- stack: this.stack
10651
+ key: this.key
10624
10652
  };
10625
10653
  },
10626
10654
  of(self) {
@@ -10636,19 +10664,67 @@ var ServiceProto = {
10636
10664
  return withFiber((fiber) => exitSucceed(f(get(fiber.context, this))));
10637
10665
  }
10638
10666
  };
10667
+ var cacheKeys = /* @__PURE__ */ new Set;
10639
10668
  var ReferenceTypeId = "~effect/Context/Reference";
10640
10669
  var TypeId3 = "~effect/Context";
10641
- var makeUnsafe = (mapUnsafe) => {
10670
+ var MaxDepth = 8;
10671
+ var FlattenAfterBaseHits = 8;
10672
+ var makeImpl = (cacheRoot, base, overlay, depth) => {
10642
10673
  const self = Object.create(Proto);
10643
- self.mapUnsafe = mapUnsafe;
10644
- self.mutable = false;
10674
+ self.cacheRoot = cacheRoot ?? self;
10675
+ self.base = base;
10676
+ self.overlay = overlay;
10677
+ self.depth = depth;
10678
+ self._flat = undefined;
10679
+ self.baseHits = 0;
10645
10680
  return self;
10646
10681
  };
10682
+ var applyOverlays = (map4, overlay) => {
10683
+ if (!overlay)
10684
+ return;
10685
+ applyOverlays(map4, overlay.parent);
10686
+ map4.set(overlay.key, overlay.value);
10687
+ };
10688
+ var flatten3 = (self) => {
10689
+ if (self._flat)
10690
+ return self._flat;
10691
+ if (!self.overlay)
10692
+ return self._flat = self.base;
10693
+ const map4 = new Map(self.base);
10694
+ applyOverlays(map4, self.overlay);
10695
+ return self._flat = map4;
10696
+ };
10697
+ var withFlat = (self, f) => {
10698
+ const map4 = new Map(self.mapUnsafe);
10699
+ f(map4);
10700
+ return makeUnsafe(map4);
10701
+ };
10702
+ var notFound = /* @__PURE__ */ Symbol();
10703
+ var lookup = (self, key) => {
10704
+ const impl = self;
10705
+ for (let overlay = impl.overlay;overlay; overlay = overlay.parent) {
10706
+ if (overlay.key === key)
10707
+ return overlay.value;
10708
+ }
10709
+ const value = impl.base.get(key);
10710
+ if (value === undefined && !impl.base.has(key))
10711
+ return notFound;
10712
+ if (impl.overlay && ++impl.baseHits >= FlattenAfterBaseHits) {
10713
+ impl.base = flatten3(impl);
10714
+ impl.overlay = undefined;
10715
+ impl.depth = 0;
10716
+ }
10717
+ return value;
10718
+ };
10719
+ var makeUnsafe = (mapUnsafe) => makeImpl(undefined, mapUnsafe, undefined, 0);
10647
10720
  var Proto = {
10648
10721
  ...PipeInspectableProto,
10649
10722
  [TypeId3]: {
10650
10723
  _Services: (_) => _
10651
10724
  },
10725
+ get mapUnsafe() {
10726
+ return flatten3(this);
10727
+ },
10652
10728
  toJSON() {
10653
10729
  return {
10654
10730
  _id: "Context",
@@ -10659,12 +10735,15 @@ var Proto = {
10659
10735
  };
10660
10736
  },
10661
10737
  [symbol2](that) {
10662
- if (!isContext(that) || this.mapUnsafe.size !== that.mapUnsafe.size)
10738
+ if (!isContext(that))
10739
+ return false;
10740
+ const self = this.mapUnsafe;
10741
+ const other = that.mapUnsafe;
10742
+ if (self.size !== other.size)
10663
10743
  return false;
10664
- for (const k of this.mapUnsafe.keys()) {
10665
- if (!that.mapUnsafe.has(k) || !equals(this.mapUnsafe.get(k), that.mapUnsafe.get(k))) {
10744
+ for (const [key, value] of self) {
10745
+ if (!other.has(key) || !equals(value, other.get(key)))
10666
10746
  return false;
10667
- }
10668
10747
  }
10669
10748
  return true;
10670
10749
  },
@@ -10672,44 +10751,49 @@ var Proto = {
10672
10751
  return number(this.mapUnsafe.size);
10673
10752
  }
10674
10753
  };
10754
+ var hasSameCache = (self, that) => self.cacheRoot === that.cacheRoot;
10675
10755
  var isContext = (u) => hasProperty(u, TypeId3);
10676
10756
  var isKey = (u) => hasProperty(u, ServiceTypeId);
10677
- var isReference = (u) => hasProperty(u, ReferenceTypeId);
10757
+ var isReference = (u) => !!u[ReferenceTypeId];
10678
10758
  var empty2 = () => emptyContext2;
10679
10759
  var emptyContext2 = /* @__PURE__ */ makeUnsafe(/* @__PURE__ */ new Map);
10680
10760
  var make5 = (key, service) => makeUnsafe(new Map([[key.key, service]]));
10681
- var add = /* @__PURE__ */ dual(3, (self, key, service) => withMapUnsafe(self, (map4) => {
10682
- map4.set(key.key, service);
10683
- }));
10684
- var addOrOmit = /* @__PURE__ */ dual(3, (self, key, service) => withMapUnsafe(self, (map4) => {
10685
- if (service._tag === "None") {
10686
- map4.delete(key.key);
10687
- } else {
10688
- map4.set(key.key, service.value);
10689
- }
10690
- }));
10761
+ var add = /* @__PURE__ */ dual(3, (self, key, service) => {
10762
+ const impl = self;
10763
+ const cacheRoot = cacheKeys.has(key.key) ? undefined : impl.cacheRoot;
10764
+ if (impl.depth >= MaxDepth) {
10765
+ const map4 = new Map(impl.mapUnsafe);
10766
+ map4.set(key.key, service);
10767
+ return makeImpl(cacheRoot, map4, undefined, 0);
10768
+ }
10769
+ return makeImpl(cacheRoot, impl.base, {
10770
+ key: key.key,
10771
+ value: service,
10772
+ parent: impl.overlay
10773
+ }, impl.depth + 1);
10774
+ });
10775
+ var addOrOmit = /* @__PURE__ */ dual(3, (self, key, service) => service._tag === "None" ? omit(key)(self) : add(self, key, service.value));
10691
10776
  var getOrElse3 = /* @__PURE__ */ dual(3, (self, key, orElse3) => {
10692
- if (self.mapUnsafe.has(key.key)) {
10693
- return self.mapUnsafe.get(key.key);
10694
- }
10777
+ const value = lookup(self, key.key);
10778
+ if (value !== notFound)
10779
+ return value;
10695
10780
  return isReference(key) ? getDefaultValue(key) : orElse3();
10696
10781
  });
10697
- var getOrUndefined3 = /* @__PURE__ */ dual(2, (self, key) => self.mapUnsafe.get(key.key));
10782
+ var getOrUndefined3 = /* @__PURE__ */ dual(2, (self, key) => getOrUndefinedUnsafe(self, key.key));
10783
+ var getOrUndefinedUnsafe = (self, key) => {
10784
+ const value = lookup(self, key);
10785
+ return value === notFound ? undefined : value;
10786
+ };
10698
10787
  var getUnsafe2 = /* @__PURE__ */ dual(2, (self, service) => {
10699
- if (!self.mapUnsafe.has(service.key)) {
10700
- if (ReferenceTypeId in service)
10788
+ const value = lookup(self, service.key);
10789
+ if (value === notFound) {
10790
+ if (isReference(service))
10701
10791
  return getDefaultValue(service);
10702
10792
  throw serviceNotFoundError(service);
10703
10793
  }
10704
- return self.mapUnsafe.get(service.key);
10794
+ return value;
10705
10795
  });
10706
10796
  var get = getUnsafe2;
10707
- var getReferenceUnsafe = (self, service) => {
10708
- if (!self.mapUnsafe.has(service.key)) {
10709
- return getDefaultValue(service);
10710
- }
10711
- return self.mapUnsafe.get(service.key);
10712
- };
10713
10797
  var defaultValueCacheKey = "~effect/Context/defaultValue";
10714
10798
  var getDefaultValue = (ref) => {
10715
10799
  if (defaultValueCacheKey in ref) {
@@ -10719,16 +10803,6 @@ var getDefaultValue = (ref) => {
10719
10803
  };
10720
10804
  var serviceNotFoundError = (service) => {
10721
10805
  const error = new Error(`Service not found${service.key ? `: ${String(service.key)}` : ""}`);
10722
- if (service.stack) {
10723
- const lines = service.stack.split(`
10724
- `);
10725
- if (lines.length > 2) {
10726
- const afterAt = lines[2].match(/at (.*)/);
10727
- if (afterAt) {
10728
- error.message = error.message + ` (defined at ${afterAt[1]})`;
10729
- }
10730
- }
10731
- }
10732
10806
  if (error.stack) {
10733
10807
  const lines = error.stack.split(`
10734
10808
  `);
@@ -10739,9 +10813,9 @@ var serviceNotFoundError = (service) => {
10739
10813
  return error;
10740
10814
  };
10741
10815
  var getOption = /* @__PURE__ */ dual(2, (self, service) => {
10742
- if (self.mapUnsafe.has(service.key)) {
10743
- return some2(self.mapUnsafe.get(service.key));
10744
- }
10816
+ const value = lookup(self, service.key);
10817
+ if (value !== notFound)
10818
+ return some2(value);
10745
10819
  return isReference(service) ? some2(getDefaultValue(service)) : none2();
10746
10820
  });
10747
10821
  var merge2 = /* @__PURE__ */ dual(2, (self, that) => {
@@ -10749,9 +10823,7 @@ var merge2 = /* @__PURE__ */ dual(2, (self, that) => {
10749
10823
  return that;
10750
10824
  if (that.mapUnsafe.size === 0)
10751
10825
  return self;
10752
- return withMapUnsafe(self, (map4) => {
10753
- that.mapUnsafe.forEach((value, key) => map4.set(key, value));
10754
- });
10826
+ return withFlat(self, (map4) => that.mapUnsafe.forEach((value, key) => map4.set(key, value)));
10755
10827
  });
10756
10828
  var mergeAll = (...ctxs) => {
10757
10829
  const map4 = new Map;
@@ -10762,45 +10834,40 @@ var mergeAll = (...ctxs) => {
10762
10834
  }
10763
10835
  return makeUnsafe(map4);
10764
10836
  };
10765
- var pick = (...services) => (self) => withMapUnsafe(self, (map4) => {
10766
- const keySet = new Set(services.map((key) => key.key));
10767
- map4.forEach((_, key) => {
10768
- if (keySet.has(key))
10769
- return;
10770
- map4.delete(key);
10771
- });
10772
- });
10773
- var omit = (...keys) => (self) => withMapUnsafe(self, (map4) => {
10837
+ var pick = (...services) => (self) => {
10838
+ const keep = new Set(services.map((key) => key.key));
10839
+ return withFlat(self, (map4) => map4.forEach((_, key) => {
10840
+ if (!keep.has(key))
10841
+ map4.delete(key);
10842
+ }));
10843
+ };
10844
+ var omit = (...keys) => (self) => withFlat(self, (map4) => {
10774
10845
  for (let i = 0;i < keys.length; i++) {
10775
10846
  map4.delete(keys[i].key);
10776
10847
  }
10777
10848
  });
10778
- var mutate = /* @__PURE__ */ dual(2, (self, f) => {
10779
- const next = makeUnsafe(new Map(self.mapUnsafe));
10780
- next.mutable = true;
10781
- const result = f(next);
10782
- result.mutable = false;
10783
- return result;
10784
- });
10785
- var withMapUnsafe = (self, f) => {
10786
- if (self.mutable) {
10787
- f(self.mapUnsafe);
10788
- return self;
10789
- }
10790
- const map4 = new Map(self.mapUnsafe);
10791
- f(map4);
10792
- return makeUnsafe(map4);
10793
- };
10794
10849
  var Reference = Service;
10795
10850
 
10796
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Duration.js
10851
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Duration.js
10797
10852
  var TypeId4 = "~effect/time/Duration";
10798
10853
  var bigint0 = /* @__PURE__ */ BigInt(0);
10799
10854
  var bigint1 = /* @__PURE__ */ BigInt(1);
10855
+ var bigint2 = /* @__PURE__ */ BigInt(2);
10856
+ var bigint10 = /* @__PURE__ */ BigInt(10);
10800
10857
  var bigint1e3 = /* @__PURE__ */ BigInt(1000);
10801
10858
  var roundTiesAwayFromZero = (input) => BigInt(input < 0 ? Math.ceil(input - 0.5) : Math.floor(input + 0.5));
10802
10859
  var roundMillisToNanos = (millis) => roundTiesAwayFromZero(millis * 1e6);
10803
- var parseNanos = (input, scale) => input.includes(".") ? roundTiesAwayFromZero(Number(input) * Number(scale)) : BigInt(input) * scale;
10860
+ var parseNanos = (input, scale) => {
10861
+ const decimalIndex = input.indexOf(".");
10862
+ if (decimalIndex === -1)
10863
+ return BigInt(input) * scale;
10864
+ const isNegative = input[0] === "-";
10865
+ const fractional = input.slice(decimalIndex + 1);
10866
+ const fractionalScale = bigint10 ** BigInt(fractional.length);
10867
+ const scaled = (BigInt(input.slice(isNegative ? 1 : 0, decimalIndex)) * fractionalScale + BigInt(fractional)) * scale;
10868
+ const rounded = scaled / fractionalScale + (scaled % fractionalScale * bigint2 >= fractionalScale ? bigint1 : bigint0);
10869
+ return isNegative ? -rounded : rounded;
10870
+ };
10804
10871
  var DURATION_REGEXP = /^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/;
10805
10872
  var fromInputUnsafe = (input) => {
10806
10873
  switch (typeof input) {
@@ -10905,7 +10972,16 @@ var negativeInfinityDurationValue = {
10905
10972
  var DurationProto = {
10906
10973
  [TypeId4]: TypeId4,
10907
10974
  [symbol]() {
10908
- return structure(this.value);
10975
+ switch (this.value._tag) {
10976
+ case "Millis": {
10977
+ const nanos = this.value.millis * 1e6;
10978
+ return Number.isFinite(nanos) ? hash(roundTiesAwayFromZero(nanos)) : number(this.value.millis);
10979
+ }
10980
+ case "Nanos":
10981
+ return hash(this.value.nanos);
10982
+ default:
10983
+ return structure(this.value);
10984
+ }
10909
10985
  },
10910
10986
  [symbol2](that) {
10911
10987
  return isDuration(that) && equals2(this, that);
@@ -11065,7 +11141,7 @@ var subtract = /* @__PURE__ */ dual(2, (self, that) => matchPair(self, that, {
11065
11141
  }));
11066
11142
  var equals2 = /* @__PURE__ */ dual(2, (self, that) => Equivalence(self, that));
11067
11143
 
11068
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Filter.js
11144
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Filter.js
11069
11145
  var composePassthrough = /* @__PURE__ */ dual(2, (left, right) => (input) => {
11070
11146
  const leftOut = left(input);
11071
11147
  if (isFailure2(leftOut))
@@ -11076,8 +11152,9 @@ var composePassthrough = /* @__PURE__ */ dual(2, (left, right) => (input) => {
11076
11152
  return rightOut;
11077
11153
  });
11078
11154
 
11079
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Scheduler.js
11155
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Scheduler.js
11080
11156
  var Scheduler = /* @__PURE__ */ Reference("effect/Scheduler", {
11157
+ fiberCached: true,
11081
11158
  defaultValue: () => new MixedScheduler
11082
11159
  });
11083
11160
  var setImmediate = "setImmediate" in globalThis ? (f) => {
@@ -11087,6 +11164,16 @@ var setImmediate = "setImmediate" in globalThis ? (f) => {
11087
11164
  const timer = setTimeout(f, 0);
11088
11165
  return () => clearTimeout(timer);
11089
11166
  };
11167
+ var setMicrotask = (f) => {
11168
+ let cancelled = false;
11169
+ queueMicrotask(() => {
11170
+ if (!cancelled)
11171
+ f();
11172
+ });
11173
+ return () => {
11174
+ cancelled = true;
11175
+ };
11176
+ };
11090
11177
 
11091
11178
  class PriorityBuckets {
11092
11179
  buckets = [];
@@ -11118,9 +11205,9 @@ class PriorityBuckets {
11118
11205
  class MixedScheduler {
11119
11206
  executionMode;
11120
11207
  setImmediate;
11121
- constructor(executionMode = "async", setImmediateFn = setImmediate) {
11208
+ constructor(executionMode = "async", setImmediateFn) {
11122
11209
  this.executionMode = executionMode;
11123
- this.setImmediate = setImmediateFn;
11210
+ this.setImmediate = setImmediateFn ?? (executionMode === "sync" ? setMicrotask : setImmediate);
11124
11211
  }
11125
11212
  shouldYield(fiber) {
11126
11213
  return fiber.currentOpCount >= fiber.maxOpsBeforeYield;
@@ -11167,16 +11254,20 @@ class MixedSchedulerDispatcher {
11167
11254
  }
11168
11255
  }
11169
11256
  var MaxOpsBeforeYield = /* @__PURE__ */ Reference("effect/Scheduler/MaxOpsBeforeYield", {
11257
+ fiberCached: true,
11170
11258
  defaultValue: () => 2048
11171
11259
  });
11172
11260
  var PreventSchedulerYield = /* @__PURE__ */ Reference("effect/Scheduler/PreventSchedulerYield", {
11261
+ fiberCached: true,
11173
11262
  defaultValue: () => false
11174
11263
  });
11175
11264
 
11176
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Tracer.js
11265
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Tracer.js
11177
11266
  var ParentSpanKey = "effect/Tracer/ParentSpan";
11178
11267
 
11179
- class ParentSpan extends (/* @__PURE__ */ Service()(ParentSpanKey)) {
11268
+ class ParentSpan extends (/* @__PURE__ */ Service()(ParentSpanKey, {
11269
+ fiberCached: true
11270
+ })) {
11180
11271
  }
11181
11272
  var make7 = (options) => options;
11182
11273
  var DisablePropagation = /* @__PURE__ */ Reference("effect/Tracer/DisablePropagation", {
@@ -11190,6 +11281,7 @@ var MinimumTraceLevel = /* @__PURE__ */ Reference("effect/Tracer/MinimumTraceLev
11190
11281
  });
11191
11282
  var TracerKey = "effect/Tracer";
11192
11283
  var Tracer = /* @__PURE__ */ Reference(TracerKey, {
11284
+ fiberCached: true,
11193
11285
  defaultValue: () => make7({
11194
11286
  span: (options) => new NativeSpan(options)
11195
11287
  })
@@ -11255,17 +11347,15 @@ var randomHexString = /* @__PURE__ */ function() {
11255
11347
  };
11256
11348
  }();
11257
11349
 
11258
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/internal/metric.js
11350
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/internal/metric.js
11259
11351
  var FiberRuntimeMetricsKey = "effect/observability/Metric/FiberRuntimeMetricsKey";
11260
11352
 
11261
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/internal/references.js
11262
- var CurrentConcurrency = /* @__PURE__ */ Reference("effect/References/CurrentConcurrency", {
11263
- defaultValue: () => "unbounded"
11264
- });
11353
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/internal/references.js
11265
11354
  var CurrentErrorReporters = /* @__PURE__ */ Reference("effect/ErrorReporter/CurrentErrorReporters", {
11266
11355
  defaultValue: () => new Set
11267
11356
  });
11268
11357
  var CurrentStackFrame = /* @__PURE__ */ Reference("effect/References/CurrentStackFrame", {
11358
+ fiberCached: true,
11269
11359
  defaultValue: constUndefined
11270
11360
  });
11271
11361
  var TracerEnabled = /* @__PURE__ */ Reference("effect/References/TracerEnabled", {
@@ -11284,16 +11374,34 @@ var CurrentLogAnnotations = /* @__PURE__ */ Reference("effect/References/Current
11284
11374
  defaultValue: () => ({})
11285
11375
  });
11286
11376
  var CurrentLogLevel = /* @__PURE__ */ Reference("effect/References/CurrentLogLevel", {
11377
+ fiberCached: true,
11287
11378
  defaultValue: () => "Info"
11288
11379
  });
11289
11380
  var MinimumLogLevel = /* @__PURE__ */ Reference("effect/References/MinimumLogLevel", {
11381
+ fiberCached: true,
11290
11382
  defaultValue: () => "Info"
11291
11383
  });
11292
11384
  var CurrentLogSpans = /* @__PURE__ */ Reference("effect/References/CurrentLogSpans", {
11293
11385
  defaultValue: () => []
11294
11386
  });
11295
11387
 
11296
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/internal/tracer.js
11388
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/internal/stackTraceLimit.js
11389
+ var isStackTraceLimitWritable = () => {
11390
+ const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
11391
+ if (desc === undefined) {
11392
+ return Object.isExtensible(Error);
11393
+ }
11394
+ return Object.hasOwn(desc, "writable") ? desc.writable === true : desc.set !== undefined;
11395
+ };
11396
+ var canWriteStackTraceLimit = /* @__PURE__ */ isStackTraceLimitWritable();
11397
+ var getStackTraceLimit = () => Error.stackTraceLimit;
11398
+ var setStackTraceLimit = (value) => {
11399
+ if (canWriteStackTraceLimit) {
11400
+ Error.stackTraceLimit = value;
11401
+ }
11402
+ };
11403
+
11404
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/internal/tracer.js
11297
11405
  var addSpanStackTrace = (options) => {
11298
11406
  if (options?.captureStackTrace === false) {
11299
11407
  return options;
@@ -11327,10 +11435,7 @@ var makeStackCleaner = (line) => (stack) => {
11327
11435
  };
11328
11436
  var spanCleaner = /* @__PURE__ */ makeStackCleaner(3);
11329
11437
 
11330
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/internal/version.js
11331
- var version = "dev";
11332
-
11333
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/internal/effect.js
11438
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/internal/effect.js
11334
11439
  class Interrupt extends ReasonBase {
11335
11440
  fiberId;
11336
11441
  constructor(fiberId, annotations = constEmptyAnnotations) {
@@ -11567,7 +11672,7 @@ ${prefix}}`;
11567
11672
  }
11568
11673
  return stack;
11569
11674
  };
11570
- var FiberTypeId = `~effect/Fiber/${version}`;
11675
+ var FiberTypeId = "~effect/Fiber";
11571
11676
  var fiberVariance = {
11572
11677
  _A: identity,
11573
11678
  _E: identity
@@ -11583,7 +11688,6 @@ class FiberImpl {
11583
11688
  this.setContext(context);
11584
11689
  this.id = ++fiberIdStore.id;
11585
11690
  this.currentOpCount = 0;
11586
- this.currentLoopCount = 0;
11587
11691
  this.interruptible = interruptible;
11588
11692
  this._stack = [];
11589
11693
  this._observers = [];
@@ -11591,20 +11695,22 @@ class FiberImpl {
11591
11695
  this._children = undefined;
11592
11696
  this._interruptedCause = undefined;
11593
11697
  this._yielded = undefined;
11698
+ this._running = false;
11699
+ this._deferredInterrupt = false;
11594
11700
  this.runtimeMetrics?.recordFiberStart(this.context);
11595
11701
  }
11596
11702
  [FiberTypeId];
11597
11703
  id;
11598
11704
  interruptible;
11599
11705
  currentOpCount;
11600
- currentLoopCount;
11601
11706
  _stack;
11602
11707
  _observers;
11603
11708
  _exit;
11604
- _currentExit;
11605
11709
  _children;
11606
11710
  _interruptedCause;
11607
11711
  _yielded;
11712
+ _running;
11713
+ _deferredInterrupt;
11608
11714
  context;
11609
11715
  currentScheduler;
11610
11716
  currentTracerContext;
@@ -11620,7 +11726,7 @@ class FiberImpl {
11620
11726
  return this._dispatcher ??= this.currentScheduler.makeDispatcher();
11621
11727
  }
11622
11728
  getRef(ref) {
11623
- return getReferenceUnsafe(this.context, ref);
11729
+ return get(this.context, ref);
11624
11730
  }
11625
11731
  addObserver(cb) {
11626
11732
  if (this._exit) {
@@ -11648,7 +11754,11 @@ class FiberImpl {
11648
11754
  }
11649
11755
  this._interruptedCause = this._interruptedCause ? causeCombine(this._interruptedCause, cause) : cause;
11650
11756
  if (this.interruptible) {
11651
- this.evaluate(failCause(this._interruptedCause));
11757
+ if (this._running) {
11758
+ this._deferredInterrupt = true;
11759
+ } else {
11760
+ this.evaluate(failCause(this._interruptedCause));
11761
+ }
11652
11762
  }
11653
11763
  }
11654
11764
  pollUnsafe() {
@@ -11676,16 +11786,24 @@ class FiberImpl {
11676
11786
  this._observers[i](exit);
11677
11787
  }
11678
11788
  this._observers.length = 0;
11789
+ this._stack.length = 0;
11790
+ this._children = undefined;
11791
+ this.context = empty2();
11679
11792
  }
11680
11793
  runLoop(effect) {
11681
11794
  const prevFiber = globalThis[currentFiberTypeId];
11682
11795
  globalThis[currentFiberTypeId] = this;
11796
+ const prevRunning = this._running;
11797
+ this._running = true;
11683
11798
  let yielding = false;
11684
11799
  let current = effect;
11685
11800
  this.currentOpCount = 0;
11686
- const currentLoop = ++this.currentLoopCount;
11687
11801
  try {
11688
11802
  while (true) {
11803
+ if (this._deferredInterrupt) {
11804
+ this._deferredInterrupt = false;
11805
+ current = failCause(this._interruptedCause);
11806
+ }
11689
11807
  this.currentOpCount++;
11690
11808
  if (!yielding && !this.currentPreventYield && this.currentScheduler.shouldYield(this)) {
11691
11809
  yielding = true;
@@ -11693,13 +11811,16 @@ class FiberImpl {
11693
11811
  current = flatMap3(yieldNow, () => prev);
11694
11812
  }
11695
11813
  current = this.currentTracerContext ? this.currentTracerContext(current, this) : current[evaluate](this);
11696
- if (currentLoop !== this.currentLoopCount) {
11697
- return Yield;
11698
- } else if (current === Yield) {
11814
+ if (current === Yield) {
11699
11815
  const yielded = this._yielded;
11700
11816
  if (ExitTypeId in yielded) {
11817
+ this._deferredInterrupt = false;
11701
11818
  this._yielded = undefined;
11702
11819
  return yielded;
11820
+ } else if (this._deferredInterrupt) {
11821
+ this._yielded = undefined;
11822
+ yielded();
11823
+ continue;
11703
11824
  }
11704
11825
  return Yield;
11705
11826
  }
@@ -11710,10 +11831,15 @@ class FiberImpl {
11710
11831
  }
11711
11832
  return this.runLoop(exitDie(error));
11712
11833
  } finally {
11834
+ this._running = prevRunning;
11713
11835
  globalThis[currentFiberTypeId] = prevFiber;
11714
11836
  }
11715
11837
  }
11716
11838
  getCont(symbol3) {
11839
+ if (this._deferredInterrupt) {
11840
+ this._deferredInterrupt = false;
11841
+ return deferredInterruptCont;
11842
+ }
11717
11843
  while (true) {
11718
11844
  const op = this._stack.pop();
11719
11845
  if (!op)
@@ -11738,26 +11864,37 @@ class FiberImpl {
11738
11864
  return pipeArguments(this, arguments);
11739
11865
  }
11740
11866
  setContext(context) {
11867
+ const previous = this.context;
11741
11868
  this.context = context;
11869
+ if (previous !== undefined && hasSameCache(previous, context))
11870
+ return;
11742
11871
  const scheduler = this.getRef(Scheduler);
11743
11872
  if (scheduler !== this.currentScheduler) {
11744
11873
  this.currentScheduler = scheduler;
11745
11874
  this._dispatcher = undefined;
11746
11875
  }
11747
- this.currentSpan = context.mapUnsafe.get(ParentSpanKey);
11876
+ this.currentSpan = getOrUndefinedUnsafe(context, ParentSpanKey);
11748
11877
  this.currentLogLevel = this.getRef(CurrentLogLevel);
11749
11878
  this.minimumLogLevel = this.getRef(MinimumLogLevel);
11750
- this.currentStackFrame = context.mapUnsafe.get(CurrentStackFrame.key);
11879
+ this.currentStackFrame = this.getRef(CurrentStackFrame);
11751
11880
  this.maxOpsBeforeYield = this.getRef(MaxOpsBeforeYield);
11752
11881
  this.currentPreventYield = this.getRef(PreventSchedulerYield);
11753
- this.runtimeMetrics = context.mapUnsafe.get(FiberRuntimeMetricsKey);
11754
- const currentTracer = context.mapUnsafe.get(TracerKey);
11882
+ this.runtimeMetrics = getOrUndefinedUnsafe(context, FiberRuntimeMetricsKey);
11883
+ const currentTracer = getOrUndefinedUnsafe(context, TracerKey);
11755
11884
  this.currentTracerContext = currentTracer ? currentTracer["context"] : undefined;
11756
11885
  }
11757
11886
  get currentSpanLocal() {
11758
11887
  return this.currentSpan?._tag === "Span" ? this.currentSpan : undefined;
11759
11888
  }
11760
11889
  }
11890
+ var deferredInterruptCont = {
11891
+ [contA](_value, fiber) {
11892
+ return failCause(fiber._interruptedCause);
11893
+ },
11894
+ [contE](_cause, fiber) {
11895
+ return failCause(fiber._interruptedCause);
11896
+ }
11897
+ };
11761
11898
  var fiberMiddleware = {
11762
11899
  interruptChildren: undefined
11763
11900
  };
@@ -11765,7 +11902,7 @@ var fiberStackAnnotations = (fiber) => {
11765
11902
  if (!fiber.currentStackFrame)
11766
11903
  return;
11767
11904
  const annotations = new Map;
11768
- annotations.set(StackTraceKey.key, fiber.currentStackFrame);
11905
+ annotations.set(InterruptorStackTrace.key, fiber.currentStackFrame);
11769
11906
  return makeUnsafe(annotations);
11770
11907
  };
11771
11908
  var fiberInterruptChildren = (fiber) => {
@@ -11841,6 +11978,10 @@ var fiberJoinAll = (self) => callback((resume) => {
11841
11978
  }
11842
11979
  }));
11843
11980
  }
11981
+ return sync(() => {
11982
+ failed = true;
11983
+ cancels.forEach((cancel) => cancel());
11984
+ });
11844
11985
  });
11845
11986
  var fiberInterrupt = (self) => withFiber((fiber) => fiberInterruptAs(self, fiber.id));
11846
11987
  var fiberInterruptAs = /* @__PURE__ */ dual((args2) => hasProperty(args2[0], FiberTypeId), (self, fiberId, annotations) => withFiber((parent) => {
@@ -11851,10 +11992,12 @@ var fiberInterruptAs = /* @__PURE__ */ dual((args2) => hasProperty(args2[0], Fib
11851
11992
  }));
11852
11993
  var fiberInterruptAll = (fibers) => withFiber((parent) => {
11853
11994
  const annotations = fiberStackAnnotations(parent);
11995
+ let fiberArr = empty();
11854
11996
  for (const fiber of fibers) {
11855
11997
  fiber.interruptUnsafe(parent.id, annotations);
11998
+ fiberArr.push(fiber);
11856
11999
  }
11857
- return asVoid2(fiberAwaitAll(fibers));
12000
+ return asVoid2(fiberAwaitAll(fiberArr));
11858
12001
  });
11859
12002
  var succeed3 = exitSucceed;
11860
12003
  var failCause = exitFailCause;
@@ -12215,7 +12358,7 @@ var flatMapEager = /* @__PURE__ */ dual(2, (self, f) => {
12215
12358
  }
12216
12359
  return flatMap3(self, f);
12217
12360
  });
12218
- var flatten3 = (self) => flatMap3(self, identity);
12361
+ var flatten4 = (self) => flatMap3(self, identity);
12219
12362
  var map4 = /* @__PURE__ */ dual(2, (self, f) => flatMap3(self, (a) => succeed3(internalCall(() => f(a)))));
12220
12363
  var mapEager = /* @__PURE__ */ dual(2, (self, f) => effectIsExit(self) ? exitMap(self, f) : map4(self, f));
12221
12364
  var mapErrorEager = /* @__PURE__ */ dual(2, (self, f) => effectIsExit(self) ? exitMapError(self, f) : mapError2(self, f));
@@ -12254,6 +12397,7 @@ var exitMapBoth = /* @__PURE__ */ dual(2, (self, options) => {
12254
12397
  return exitFail(options.onFailure(error.success));
12255
12398
  });
12256
12399
  var exitZipRight = /* @__PURE__ */ dual(2, (self, that) => exitIsSuccess(self) ? that : self);
12400
+ var exitMatch = /* @__PURE__ */ dual(2, (self, options) => exitIsSuccess(self) ? options.onSuccess(self.value) : options.onFailure(self.cause));
12257
12401
  var exitAsVoidAll = (exits) => {
12258
12402
  const failures = [];
12259
12403
  for (const exit of exits) {
@@ -12284,6 +12428,24 @@ var updateService = /* @__PURE__ */ dual(3, (self, service2, f) => updateContext
12284
12428
  return s;
12285
12429
  return add(s, service2, next);
12286
12430
  }));
12431
+ var updateServiceScoped = (service2, update, options) => uninterruptible(withFiber((fiber2) => {
12432
+ const original = getUnsafe2(fiber2.context, service2);
12433
+ const updated = update(original);
12434
+ fiber2.setContext(add(fiber2.context, service2, updated));
12435
+ return scopeAddFinalizerExit(getUnsafe2(fiber2.context, scopeTag), (_) => {
12436
+ const current = getUnsafe2(fiber2.context, service2);
12437
+ let next;
12438
+ if (options?.reset === undefined) {
12439
+ if (current !== updated)
12440
+ return void_3;
12441
+ next = original;
12442
+ } else {
12443
+ next = options.reset(original, updated, current);
12444
+ }
12445
+ fiber2.setContext(add(fiber2.context, service2, next));
12446
+ return void_3;
12447
+ });
12448
+ }));
12287
12449
  var context = () => getContext;
12288
12450
  var getContext = /* @__PURE__ */ withFiber((fiber2) => succeed3(fiber2.context));
12289
12451
  var contextWith = (f) => withFiber((fiber2) => f(fiber2.context));
@@ -12306,7 +12468,6 @@ var provideServiceImpl = (self, service2, implementation) => updateContext(self,
12306
12468
  return add(s, service2, implementation);
12307
12469
  });
12308
12470
  var provideServiceEffect = /* @__PURE__ */ dual(3, (self, service2, acquire) => flatMap3(acquire, (implementation) => provideService(self, service2, implementation)));
12309
- var withConcurrency = /* @__PURE__ */ provideService(CurrentConcurrency);
12310
12471
  var zip = /* @__PURE__ */ dual((args2) => isEffect(args2[1]), (self, that, options) => zipWith2(self, that, (a, a2) => [a, a2], options));
12311
12472
  var zipWith2 = /* @__PURE__ */ dual((args2) => isEffect(args2[1]), (self, that, f, options) => options?.concurrent ? map4(all3([self, that], {
12312
12473
  concurrency: 2
@@ -12556,8 +12717,8 @@ var timeout = /* @__PURE__ */ dual(2, (self, duration) => timeoutOrElse(self, {
12556
12717
  }));
12557
12718
  var timeoutOption = /* @__PURE__ */ dual(2, (self, duration) => raceFirst(asSome(self), as2(sleep(duration), none2())));
12558
12719
  var timed = (self) => clockWith((clock) => {
12559
- const start = clock.currentTimeNanosUnsafe();
12560
- return map4(self, (a) => [nanos(clock.currentTimeNanosUnsafe() - start), a]);
12720
+ const start = clock.monotonicTimeNanosUnsafe();
12721
+ return map4(self, (a) => [nanos(clock.monotonicTimeNanosUnsafe() - start), a]);
12561
12722
  });
12562
12723
  var ScopeTypeId = "~effect/Scope";
12563
12724
  var ScopeCloseableTypeId = "~effect/Scope/Closeable";
@@ -12767,14 +12928,16 @@ var setInterruptible = /* @__PURE__ */ makePrimitive({
12767
12928
  });
12768
12929
  var setInterruptibleTrue = /* @__PURE__ */ setInterruptible(true);
12769
12930
  var setInterruptibleFalse = /* @__PURE__ */ setInterruptible(false);
12770
- var interruptible = (self) => withFiber((fiber2) => {
12771
- if (fiber2.interruptible)
12772
- return self;
12931
+ var setFiberInterruptible = (fiber2) => {
12773
12932
  fiber2.interruptible = true;
12774
12933
  fiber2._stack.push(setInterruptibleFalse);
12775
12934
  if (fiber2._interruptedCause)
12776
12935
  return failCause(fiber2._interruptedCause);
12777
- return self;
12936
+ };
12937
+ var interruptible = (self) => withFiber((fiber2) => {
12938
+ if (fiber2.interruptible)
12939
+ return self;
12940
+ return setFiberInterruptible(fiber2) ?? self;
12778
12941
  });
12779
12942
  var uninterruptibleMask = (f) => withFiber((fiber2) => {
12780
12943
  if (!fiber2.interruptible)
@@ -12786,9 +12949,9 @@ var uninterruptibleMask = (f) => withFiber((fiber2) => {
12786
12949
  var interruptibleMask = (f) => withFiber((fiber2) => {
12787
12950
  if (fiber2.interruptible)
12788
12951
  return f(identity);
12789
- fiber2.interruptible = true;
12790
- fiber2._stack.push(setInterruptibleFalse);
12791
- return f(uninterruptible);
12952
+ const interrupted = setFiberInterruptible(fiber2);
12953
+ const effect = f(uninterruptible);
12954
+ return interrupted ?? effect;
12792
12955
  });
12793
12956
  var abortSignal = /* @__PURE__ */ map4(/* @__PURE__ */ acquireRelease(/* @__PURE__ */ sync(() => new AbortController), (controller) => sync(() => controller.abort())), (_) => _.signal);
12794
12957
  var all3 = (arg, options) => {
@@ -12800,7 +12963,7 @@ var all3 = (arg, options) => {
12800
12963
  return suspend(() => {
12801
12964
  const out = {};
12802
12965
  return as2(forEach(Object.entries(arg), ([key, effect]) => map4(options?.mode === "result" ? result(effect) : effect, (value) => {
12803
- out[key] = value;
12966
+ assignProperty(out, key, value);
12804
12967
  }), {
12805
12968
  discard: true,
12806
12969
  concurrency: options?.concurrency
@@ -12808,6 +12971,23 @@ var all3 = (arg, options) => {
12808
12971
  });
12809
12972
  };
12810
12973
  var partition2 = /* @__PURE__ */ dual((args2) => isIterable(args2[0]) && !isEffect(args2[0]), (elements, f, options) => map4(forEach(elements, (a, i) => result(f(a, i)), options), (results) => partition(results, identity)));
12974
+ var reduce = /* @__PURE__ */ dual(3, (elements, zero2, f) => {
12975
+ const arr = fromIterable2(elements);
12976
+ if (arr.length === 0)
12977
+ return sync(zero2);
12978
+ return suspend(() => {
12979
+ let index = 0;
12980
+ let state = zero2();
12981
+ return map4(whileLoop({
12982
+ while: () => index < arr.length,
12983
+ body: () => f(state, arr[index], index),
12984
+ step(next) {
12985
+ state = next;
12986
+ index++;
12987
+ }
12988
+ }), () => state);
12989
+ });
12990
+ });
12811
12991
  var validate = /* @__PURE__ */ dual((args2) => isIterable(args2[0]) && !isEffect(args2[0]), (elements, f, options) => flatMap3(partition2(elements, f, {
12812
12992
  concurrency: options?.concurrency
12813
12993
  }), ([excluded, satisfying]) => {
@@ -12870,8 +13050,8 @@ var whileLoop = /* @__PURE__ */ makePrimitive({
12870
13050
  return exitVoid;
12871
13051
  }
12872
13052
  });
12873
- var forEach = /* @__PURE__ */ dual((args2) => typeof args2[1] === "function", (iterable, f, options) => withFiber((parent) => {
12874
- const concurrencyOption = options?.concurrency === "inherit" ? parent.getRef(CurrentConcurrency) : options?.concurrency ?? 1;
13053
+ var forEach = /* @__PURE__ */ dual((args2) => typeof args2[1] === "function", (iterable, f, options) => suspend(() => {
13054
+ const concurrencyOption = options?.concurrency ?? 1;
12875
13055
  const concurrency = concurrencyOption === "unbounded" ? Number.POSITIVE_INFINITY : Math.max(1, concurrencyOption);
12876
13056
  if (concurrency === 1) {
12877
13057
  return forEachSequential(iterable, f, options);
@@ -12908,10 +13088,25 @@ var forEachSequential = (iterable, f, options) => suspend(() => {
12908
13088
  var iterateEagerImpl = (options) => {
12909
13089
  const onItem = options.onItem;
12910
13090
  const step = options.step;
13091
+ const runSequential = (state, items, index, end) => {
13092
+ for (;index < end; index++) {
13093
+ const item = items[index];
13094
+ const effect = onItem(state, item, index);
13095
+ if (!effectIsExit(effect)) {
13096
+ return flatMap3(exit(effect), (itemExit) => step(state, item, itemExit, index) ?? runSequential(state, items, index + 1, end) ?? void_3);
13097
+ }
13098
+ const terminal = step(state, item, effect, index);
13099
+ if (terminal)
13100
+ return terminal._tag === "Failure" ? terminal : undefined;
13101
+ }
13102
+ };
12911
13103
  return (state, items, opts) => {
12912
- let index = opts?.start ?? 0;
13104
+ let index = 0;
12913
13105
  const end = opts?.end ?? items.length;
12914
13106
  const concurrency = opts?.concurrency ?? 1;
13107
+ if (concurrency === 1) {
13108
+ return runSequential(state, items, 0, end);
13109
+ }
12915
13110
  const orderedStep = opts?.orderedStep === true && concurrency > 1;
12916
13111
  let done2 = false;
12917
13112
  let parentFiber;
@@ -12922,6 +13117,13 @@ var iterateEagerImpl = (options) => {
12922
13117
  let effect;
12923
13118
  let nextIndex = index;
12924
13119
  const exits = orderedStep ? new Array(end) : undefined;
13120
+ const failDefect = (error) => {
13121
+ const defect = exitDie(error);
13122
+ terminal = defect;
13123
+ done2 = true;
13124
+ interrupted = true;
13125
+ return fibers && fibers.size > 0 ? flatMap3(uninterruptible(fiberInterruptAll(Array.from(fibers))), () => defect) : defect;
13126
+ };
12925
13127
  const runStep = (item, exit2, currentIndex) => {
12926
13128
  if (!orderedStep)
12927
13129
  return step(state, item, exit2, currentIndex);
@@ -12948,18 +13150,18 @@ var iterateEagerImpl = (options) => {
12948
13150
  terminal = runStep(item, eff, index);
12949
13151
  if (terminal)
12950
13152
  break;
12951
- } else if (concurrency === 1) {
12952
- return flatMap3(exit(eff), (exit2) => {
12953
- terminal = runStep(item, exit2, index);
12954
- index++;
12955
- return terminal ?? go() ?? void_3;
12956
- });
12957
13153
  } else if (!parentFiber) {
12958
13154
  return callback((cb) => {
12959
13155
  parentFiber = getCurrentFiber();
13156
+ fibers = new Set;
12960
13157
  effect = eff;
12961
13158
  resume = cb;
12962
- const result2 = go();
13159
+ let result2;
13160
+ try {
13161
+ result2 = go();
13162
+ } catch (error) {
13163
+ return cb(failDefect(error));
13164
+ }
12963
13165
  if (result2)
12964
13166
  return cb(result2);
12965
13167
  return suspend(() => {
@@ -12977,38 +13179,39 @@ var iterateEagerImpl = (options) => {
12977
13179
  break;
12978
13180
  continue;
12979
13181
  }
12980
- if (fibers)
12981
- fibers.add(fiber2);
12982
- else
12983
- fibers = new Set([fiber2]);
13182
+ fibers.add(fiber2);
12984
13183
  const currentIndex = index;
12985
13184
  fiber2.addObserver((exit2) => {
12986
13185
  fibers.delete(fiber2);
12987
- if (terminal) {
12988
- if (!interrupted && exit2._tag === "Failure") {
12989
- for (const reason of exit2.cause.reasons) {
12990
- if (reason._tag === "Interrupt")
12991
- continue;
12992
- else if (terminal._tag === "Failure") {
12993
- terminal.cause.reasons.push(reason);
12994
- } else {
12995
- terminal = exitFailCause(causeFromReasons([reason]));
13186
+ try {
13187
+ if (terminal) {
13188
+ if (!interrupted && exit2._tag === "Failure") {
13189
+ for (const reason of exit2.cause.reasons) {
13190
+ if (reason._tag === "Interrupt")
13191
+ continue;
13192
+ else if (terminal._tag === "Failure") {
13193
+ terminal.cause.reasons.push(reason);
13194
+ } else {
13195
+ terminal = exitFailCause(causeFromReasons([reason]));
13196
+ }
12996
13197
  }
12997
13198
  }
13199
+ } else {
13200
+ const result2 = runStep(item, exit2, currentIndex);
13201
+ if (result2) {
13202
+ terminal = result2._tag === "Failure" ? exitFailCause(causeFromReasons(result2.cause.reasons.slice())) : result2;
13203
+ go();
13204
+ }
12998
13205
  }
12999
- } else {
13000
- const result2 = runStep(item, exit2, currentIndex);
13001
- if (result2) {
13002
- terminal = result2._tag === "Failure" ? exitFailCause(causeFromReasons(result2.cause.reasons.slice())) : result2;
13003
- go();
13206
+ if (paused) {
13207
+ const eff2 = go();
13208
+ if (eff2)
13209
+ resume(eff2);
13210
+ } else if (done2 && fibers.size === 0) {
13211
+ resume(terminal ?? void_3);
13004
13212
  }
13005
- }
13006
- if (paused) {
13007
- const eff2 = go();
13008
- if (eff2)
13009
- resume(eff2);
13010
- } else if (done2 && fibers.size === 0) {
13011
- resume(terminal ?? void_3);
13213
+ } catch (error) {
13214
+ resume(failDefect(error));
13012
13215
  }
13013
13216
  });
13014
13217
  if (fibers.size < concurrency)
@@ -13106,28 +13309,29 @@ var forkChild = /* @__PURE__ */ dual((args2) => isEffect(args2[0]), (self, optio
13106
13309
  return succeed3(forkUnsafe(fiber2, self, options?.startImmediately, false, options?.uninterruptible ?? false));
13107
13310
  }));
13108
13311
  var forkUnsafe = (parent, effect, immediate = false, daemon = false, uninterruptible2 = false) => {
13109
- const interruptible2 = uninterruptible2 === "inherit" ? parent.interruptible : !uninterruptible2;
13110
- const child = new FiberImpl(parent.context, interruptible2);
13312
+ const parentRuntime = parent;
13313
+ const interruptible2 = uninterruptible2 === "inherit" ? parentRuntime.interruptible : !uninterruptible2;
13314
+ const child = new FiberImpl(parentRuntime.context, interruptible2);
13111
13315
  if (immediate) {
13112
13316
  child.evaluate(effect);
13113
13317
  } else {
13114
- parent.currentDispatcher.scheduleTask(() => child.evaluate(effect), 0);
13318
+ parentRuntime.currentDispatcher.scheduleTask(() => child.evaluate(effect), 0);
13115
13319
  }
13116
13320
  if (!daemon && !child._exit) {
13117
- parent.children().add(child);
13118
- child.addObserver(() => parent._children.delete(child));
13321
+ parentRuntime.children().add(child);
13322
+ child.addObserver(() => parentRuntime._children.delete(child));
13119
13323
  }
13120
13324
  return child;
13121
13325
  };
13122
13326
  var forkDetach = /* @__PURE__ */ dual((args2) => isEffect(args2[0]), (self, options) => withFiber((fiber2) => succeed3(forkUnsafe(fiber2, self, options?.startImmediately, true, options?.uninterruptible))));
13123
13327
  var awaitAllChildren = (self) => withFiber((fiber2) => {
13124
- const initialChildren = fiber2._children && fromIterable2(fiber2._children);
13328
+ const initialChildren = fiber2._children && new Set(fiber2._children);
13125
13329
  return onExit(self, (_) => {
13126
13330
  let children = fiber2._children;
13127
13331
  if (children === undefined || children.size === 0) {
13128
13332
  return void_3;
13129
13333
  } else if (initialChildren) {
13130
- children = filter2(children, (child) => !initialChildren.includes(child));
13334
+ children = filter2(children, (child) => !initialChildren.has(child));
13131
13335
  }
13132
13336
  return asVoid2(fiberAwaitAll(children));
13133
13337
  });
@@ -13223,7 +13427,7 @@ var runSyncExitWith = (context2) => {
13223
13427
  const fiber2 = runFork2(effect, {
13224
13428
  scheduler
13225
13429
  });
13226
- fiber2.currentDispatcher?.flush();
13430
+ fiber2._dispatcher?.flush();
13227
13431
  return fiber2._exit ?? exitDie(new AsyncFiberError(fiber2));
13228
13432
  };
13229
13433
  };
@@ -13243,27 +13447,43 @@ var succeedFalse = /* @__PURE__ */ succeed3(false);
13243
13447
 
13244
13448
  class Latch {
13245
13449
  waiters = [];
13246
- scheduled = false;
13450
+ scheduled = undefined;
13247
13451
  _isOpen;
13248
13452
  constructor(isOpen) {
13249
13453
  this._isOpen = isOpen;
13250
13454
  }
13251
13455
  scheduleUnsafe(fiber2) {
13252
- if (this.scheduled || this.waiters.length === 0) {
13456
+ if (this.waiters.length === 0) {
13253
13457
  return succeedTrue;
13254
13458
  }
13255
- this.scheduled = true;
13256
- fiber2.currentDispatcher.scheduleTask(this.flushWaiters, 0);
13459
+ if (this.scheduled === undefined) {
13460
+ this.scheduled = this.waiters;
13461
+ fiber2.currentDispatcher.scheduleTask(this.flushScheduled, 0);
13462
+ } else {
13463
+ for (let i = 0;i < this.waiters.length; i++) {
13464
+ this.scheduled.push(this.waiters[i]);
13465
+ }
13466
+ }
13467
+ this.waiters = [];
13257
13468
  return succeedTrue;
13258
13469
  }
13259
- flushWaiters = () => {
13260
- this.scheduled = false;
13470
+ flushScheduled = () => {
13471
+ if (this.scheduled === undefined)
13472
+ return;
13473
+ const waiters = this.scheduled;
13474
+ this.scheduled = undefined;
13475
+ for (let i = 0;i < waiters.length; i++) {
13476
+ waiters[i](exitVoid);
13477
+ }
13478
+ };
13479
+ flushWaiters() {
13261
13480
  const waiters = this.waiters;
13262
13481
  this.waiters = [];
13482
+ this.flushScheduled();
13263
13483
  for (let i = 0;i < waiters.length; i++) {
13264
13484
  waiters[i](exitVoid);
13265
13485
  }
13266
- };
13486
+ }
13267
13487
  open = /* @__PURE__ */ withFiber((fiber2) => {
13268
13488
  if (this._isOpen)
13269
13489
  return succeedFalse;
@@ -13284,9 +13504,14 @@ class Latch {
13284
13504
  }
13285
13505
  this.waiters.push(resume);
13286
13506
  return sync(() => {
13287
- const index = this.waiters.indexOf(resume);
13507
+ let index = this.waiters.indexOf(resume);
13288
13508
  if (index !== -1) {
13289
13509
  this.waiters.splice(index, 1);
13510
+ } else if (this.scheduled !== undefined) {
13511
+ index = this.scheduled.indexOf(resume);
13512
+ if (index !== -1) {
13513
+ this.scheduled.splice(index, 1);
13514
+ }
13290
13515
  }
13291
13516
  });
13292
13517
  });
@@ -13420,11 +13645,8 @@ var useSpan = (name, ...args2) => {
13420
13645
  return withFiber((fiber2) => {
13421
13646
  const span = makeSpanUnsafe(fiber2, name, options);
13422
13647
  const clock = fiber2.getRef(ClockRef);
13423
- return onExit(internalCall(() => evaluate2(span)), (exit2) => sync(() => {
13424
- if (span.status._tag === "Ended")
13425
- return;
13426
- span.end(clock.currentTimeNanosUnsafe(), exit2);
13427
- }));
13648
+ const timingEnabled = fiber2.getRef(TracerTimingEnabled);
13649
+ return onExit(internalCall(() => evaluate2(span)), (exit2) => endSpan(span, exit2, clock, timingEnabled));
13428
13650
  });
13429
13651
  };
13430
13652
  var provideParentSpan = /* @__PURE__ */ provideService(ParentSpan);
@@ -13455,13 +13677,16 @@ var withSpan = function() {
13455
13677
  return (self, ...args2) => useSpan(name, fnArg ? fnArg(...args2) : options, (span) => withParentSpan(self, span, traceOptions));
13456
13678
  };
13457
13679
  var annotateSpans = /* @__PURE__ */ dual((args2) => isEffect(args2[0]), (effect, ...args2) => updateService(effect, TracerSpanAnnotations, (annotations) => {
13458
- const newAnnotations = {
13680
+ const newAnnotations = args2.length === 1 ? {
13681
+ ...annotations,
13682
+ ...args2[0]
13683
+ } : {
13459
13684
  ...annotations
13460
13685
  };
13461
13686
  if (args2.length === 1) {
13462
- Object.assign(newAnnotations, args2[0]);
13687
+ return newAnnotations;
13463
13688
  } else {
13464
- newAnnotations[args2[0]] = args2[1];
13689
+ assignProperty(newAnnotations, args2[0], args2[1]);
13465
13690
  }
13466
13691
  return newAnnotations;
13467
13692
  }));
@@ -13494,9 +13719,13 @@ class ClockImpl {
13494
13719
  }
13495
13720
  currentTimeMillis = /* @__PURE__ */ sync(() => this.currentTimeMillisUnsafe());
13496
13721
  currentTimeNanosUnsafe() {
13497
- return processOrPerformanceNow();
13722
+ return wallTimeNanos();
13498
13723
  }
13499
13724
  currentTimeNanos = /* @__PURE__ */ sync(() => this.currentTimeNanosUnsafe());
13725
+ monotonicTimeNanosUnsafe() {
13726
+ return monotonicNowNanos();
13727
+ }
13728
+ monotonicTimeNanos = /* @__PURE__ */ sync(() => this.monotonicTimeNanosUnsafe());
13500
13729
  sleep(duration) {
13501
13730
  return this.sleepMillis(toMillis(duration));
13502
13731
  }
@@ -13512,24 +13741,41 @@ class ClockImpl {
13512
13741
  });
13513
13742
  }
13514
13743
  }
13515
- var performanceNowNanos = /* @__PURE__ */ function() {
13516
- const bigint1e6 = /* @__PURE__ */ BigInt(1e6);
13517
- if (typeof performance === "undefined" || typeof performance.now === "undefined") {
13518
- return () => BigInt(Date.now()) * bigint1e6;
13744
+ var nanosPerMilli = /* @__PURE__ */ BigInt(1e6);
13745
+ var monotonicNowNanos = /* @__PURE__ */ function() {
13746
+ const processHrtime = globalThis.process?.hrtime;
13747
+ if (typeof processHrtime?.bigint === "function") {
13748
+ return () => processHrtime.bigint();
13519
13749
  }
13520
- let origin;
13750
+ if (typeof performance !== "undefined" && typeof performance.now === "function") {
13751
+ return () => BigInt(Math.round(performance.now() * 1e6));
13752
+ }
13753
+ let previous = /* @__PURE__ */ BigInt(0);
13521
13754
  return () => {
13522
- origin ??= BigInt(Date.now()) * bigint1e6 - BigInt(Math.round(performance.now() * 1e6));
13523
- return origin + BigInt(Math.round(performance.now() * 1e6));
13755
+ const current = BigInt(Date.now()) * nanosPerMilli;
13756
+ if (current > previous) {
13757
+ previous = current;
13758
+ }
13759
+ return previous;
13524
13760
  };
13525
13761
  }();
13526
- var processOrPerformanceNow = /* @__PURE__ */ function() {
13527
- const processHrtime = typeof process === "object" && "hrtime" in process && typeof process.hrtime.bigint === "function" ? process.hrtime : undefined;
13528
- if (!processHrtime) {
13529
- return performanceNowNanos;
13530
- }
13531
- const origin = /* @__PURE__ */ BigInt(/* @__PURE__ */ Date.now()) * /* @__PURE__ */ BigInt(1e6) - /* @__PURE__ */ processHrtime.bigint();
13532
- return () => origin + processHrtime.bigint();
13762
+ var wallTimeNanos = /* @__PURE__ */ function() {
13763
+ const reanchorThresholdNanos = /* @__PURE__ */ BigInt(1e9);
13764
+ let origin;
13765
+ return () => {
13766
+ const monotonic = monotonicNowNanos();
13767
+ const wall = BigInt(Date.now()) * nanosPerMilli;
13768
+ if (origin === undefined) {
13769
+ origin = wall - monotonic;
13770
+ } else {
13771
+ const projected = origin + monotonic;
13772
+ const skew = wall > projected ? wall - projected : projected - wall;
13773
+ if (skew > reanchorThresholdNanos) {
13774
+ origin = wall - monotonic;
13775
+ }
13776
+ }
13777
+ return origin + monotonic;
13778
+ };
13533
13779
  }();
13534
13780
  var clockWith = (f) => withFiber((fiber2) => f(fiber2.getRef(ClockRef)));
13535
13781
  var sleep = (duration) => clockWith((clock) => clock.sleep(fromInputUnsafe(duration)));
@@ -13612,7 +13858,7 @@ var annotateLogsScoped = function() {
13612
13858
  };
13613
13859
  for (let i = 0;i < entries.length; i++) {
13614
13860
  const [key, value] = entries[i];
13615
- next[key] = value;
13861
+ assignProperty(next, key, value);
13616
13862
  }
13617
13863
  fiber2.setContext(add(fiber2.context, CurrentLogAnnotations, next));
13618
13864
  return scopeAddFinalizerExit(getUnsafe2(fiber2.context, scopeTag), (_) => {
@@ -13624,8 +13870,8 @@ var annotateLogsScoped = function() {
13624
13870
  const [key, value] = entries[i];
13625
13871
  if (current[key] !== value)
13626
13872
  continue;
13627
- if (key in prev) {
13628
- next2[key] = prev[key];
13873
+ if (Object.hasOwn(prev, key)) {
13874
+ assignProperty(next2, key, prev[key]);
13629
13875
  } else {
13630
13876
  delete next2[key];
13631
13877
  }
@@ -13755,7 +14001,7 @@ var tracerLogger = /* @__PURE__ */ loggerMake(({
13755
14001
  return;
13756
14002
  const attributes = {};
13757
14003
  for (const [key, value] of Object.entries(annotations)) {
13758
- attributes[key] = value;
14004
+ assignProperty(attributes, key, value);
13759
14005
  }
13760
14006
  attributes["effect.fiberId"] = fiber2.id;
13761
14007
  attributes["effect.logLevel"] = logLevel.toUpperCase();
@@ -13786,7 +14032,7 @@ var reportCauseUnsafe = (fiber2, cause, defectsOnly) => {
13786
14032
  reporters.forEach((reporter) => reporter.report(opts));
13787
14033
  };
13788
14034
 
13789
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Deferred.js
14035
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Deferred.js
13790
14036
  var TypeId5 = "~effect/Deferred";
13791
14037
  var DeferredProto = {
13792
14038
  [TypeId5]: {
@@ -13832,7 +14078,7 @@ var doneUnsafe = (self, effect) => {
13832
14078
  return true;
13833
14079
  };
13834
14080
 
13835
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Effect.js
14081
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Effect.js
13836
14082
  var exports_Effect = {};
13837
14083
  __export(exports_Effect, {
13838
14084
  zipWith: () => zipWith3,
@@ -13850,12 +14096,12 @@ __export(exports_Effect, {
13850
14096
  withFiber: () => withFiber2,
13851
14097
  withExecutionPlan: () => withExecutionPlan2,
13852
14098
  withErrorReporting: () => withErrorReporting2,
13853
- withConcurrency: () => withConcurrency2,
13854
14099
  whileLoop: () => whileLoop2,
13855
14100
  when: () => when2,
13856
14101
  void: () => void_5,
13857
14102
  validate: () => validate2,
13858
14103
  useSpan: () => useSpan2,
14104
+ updateServiceScoped: () => updateServiceScoped2,
13859
14105
  updateService: () => updateService3,
13860
14106
  updateContext: () => updateContext2,
13861
14107
  unwrapReason: () => unwrapReason2,
@@ -13925,6 +14171,7 @@ __export(exports_Effect, {
13925
14171
  replicate: () => replicate2,
13926
14172
  repeatOrElse: () => repeatOrElse2,
13927
14173
  repeat: () => repeat3,
14174
+ reduce: () => reduce2,
13928
14175
  raceFirst: () => raceFirst2,
13929
14176
  raceAllFirst: () => raceAllFirst2,
13930
14177
  raceAll: () => raceAll2,
@@ -13953,7 +14200,7 @@ __export(exports_Effect, {
13953
14200
  matchCauseEffect: () => matchCauseEffect2,
13954
14201
  matchCauseEager: () => matchCauseEager2,
13955
14202
  matchCause: () => matchCause2,
13956
- match: () => match5,
14203
+ match: () => match6,
13957
14204
  mapErrorEager: () => mapErrorEager2,
13958
14205
  mapError: () => mapError3,
13959
14206
  mapEager: () => mapEager2,
@@ -13994,7 +14241,7 @@ __export(exports_Effect, {
13994
14241
  fnUntraced: () => fnUntraced2,
13995
14242
  fn: () => fn2,
13996
14243
  flip: () => flip3,
13997
- flatten: () => flatten4,
14244
+ flatten: () => flatten5,
13998
14245
  flatMapEager: () => flatMapEager2,
13999
14246
  flatMap: () => flatMap5,
14000
14247
  firstSuccessOf: () => firstSuccessOf2,
@@ -14017,7 +14264,7 @@ __export(exports_Effect, {
14017
14264
  eventually: () => eventually2,
14018
14265
  ensuring: () => ensuring2,
14019
14266
  effectify: () => effectify,
14020
- die: () => die3,
14267
+ die: () => die4,
14021
14268
  delay: () => delay2,
14022
14269
  currentSpan: () => currentSpan2,
14023
14270
  currentParentSpan: () => currentParentSpan2,
@@ -14063,17 +14310,19 @@ __export(exports_Effect, {
14063
14310
  Do: () => Do4
14064
14311
  });
14065
14312
 
14066
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Exit.js
14313
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Exit.js
14067
14314
  var isExit2 = isExit;
14068
14315
  var succeed4 = exitSucceed;
14069
14316
  var failCause3 = exitFailCause;
14070
14317
  var fail4 = exitFail;
14318
+ var die2 = exitDie;
14071
14319
  var interrupt2 = exitInterrupt;
14072
14320
  var void_4 = exitVoid;
14073
14321
  var isSuccess4 = exitIsSuccess;
14074
14322
  var isFailure4 = exitIsFailure;
14323
+ var match5 = exitMatch;
14075
14324
 
14076
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Layer.js
14325
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Layer.js
14077
14326
  var exports_Layer = {};
14078
14327
  __export(exports_Layer, {
14079
14328
  withSpan: () => withSpan2,
@@ -14122,13 +14371,13 @@ __export(exports_Layer, {
14122
14371
  CurrentMemoMap: () => CurrentMemoMap
14123
14372
  });
14124
14373
 
14125
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/References.js
14374
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/References.js
14126
14375
  var CurrentLogAnnotations2 = CurrentLogAnnotations;
14127
14376
  var CurrentLogSpans2 = CurrentLogSpans;
14128
14377
  var CurrentStackFrame2 = CurrentStackFrame;
14129
14378
  var TracerTimingEnabled2 = TracerTimingEnabled;
14130
14379
 
14131
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Scope.js
14380
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Scope.js
14132
14381
  var Scope = scopeTag;
14133
14382
  var makeUnsafe3 = scopeMakeUnsafe;
14134
14383
  var provide = provideScope;
@@ -14137,7 +14386,7 @@ var addFinalizer2 = scopeAddFinalizer;
14137
14386
  var forkUnsafe2 = scopeForkUnsafe;
14138
14387
  var close = scopeClose;
14139
14388
 
14140
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Layer.js
14389
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Layer.js
14141
14390
  var TypeId6 = "~effect/Layer";
14142
14391
  var MemoMapTypeId = "~effect/Layer/MemoMap";
14143
14392
  var memoMapReuse = (entry, scope2) => {
@@ -14207,11 +14456,13 @@ class MemoMapImpl {
14207
14456
  return this.parent?.get(layer, scope2);
14208
14457
  }
14209
14458
  getOrElseMemoize(layer, scope2, build) {
14210
- const existing = this.get(layer, scope2);
14211
- if (existing) {
14212
- return existing;
14213
- }
14214
- return memoMapBuild(this, layer, scope2, build);
14459
+ return suspend(() => {
14460
+ const existing = this.get(layer, scope2);
14461
+ if (existing) {
14462
+ return existing;
14463
+ }
14464
+ return memoMapBuild(this, layer, scope2, build);
14465
+ });
14215
14466
  }
14216
14467
  }
14217
14468
  var makeMemoMapUnsafe = () => new MemoMapImpl;
@@ -14365,7 +14616,7 @@ var provideSpanStackFrame2 = (name, stack) => {
14365
14616
  }));
14366
14617
  };
14367
14618
 
14368
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/ExecutionPlan.js
14619
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/ExecutionPlan.js
14369
14620
  var TypeId7 = "~effect/ExecutionPlan";
14370
14621
  var Proto2 = {
14371
14622
  [TypeId7]: TypeId7,
@@ -14392,9 +14643,9 @@ var CurrentMetadata = /* @__PURE__ */ Reference("effect/ExecutionPlan/CurrentMet
14392
14643
  })
14393
14644
  });
14394
14645
 
14395
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Cause.js
14646
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Cause.js
14396
14647
  var fail5 = causeFail;
14397
- var die2 = causeDie;
14648
+ var die3 = causeDie;
14398
14649
  var hasInterruptsOnly2 = hasInterruptsOnly;
14399
14650
  var squash = causeSquash;
14400
14651
  var hasFails2 = hasFails;
@@ -14405,7 +14656,7 @@ var done3 = done;
14405
14656
  var ExceededCapacityError2 = ExceededCapacityError;
14406
14657
  var UnknownError2 = UnknownError;
14407
14658
 
14408
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Data.js
14659
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Data.js
14409
14660
  var exports_Data = {};
14410
14661
  __export(exports_Data, {
14411
14662
  taggedEnum: () => taggedEnum,
@@ -14418,7 +14669,7 @@ var Class2 = class extends Class {
14418
14669
  constructor(props) {
14419
14670
  super();
14420
14671
  if (props) {
14421
- Object.assign(this, props);
14672
+ assignProperties(this, props);
14422
14673
  }
14423
14674
  }
14424
14675
  };
@@ -14452,21 +14703,21 @@ function taggedMatch() {
14452
14703
  var Error3 = Error2;
14453
14704
  var TaggedError2 = TaggedError;
14454
14705
 
14455
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Clock.js
14706
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Clock.js
14456
14707
  var Clock = ClockRef;
14457
14708
 
14458
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Number.js
14709
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Number.js
14459
14710
  var Number3 = globalThis.Number;
14460
14711
  var nextPow2 = (n) => {
14461
14712
  const nextPow = Math.ceil(Math.log(n) / Math.log(2));
14462
14713
  return Math.max(Math.pow(2, nextPow), 2);
14463
14714
  };
14464
14715
 
14465
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/String.js
14716
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/String.js
14466
14717
  var String2 = globalThis.String;
14467
14718
  var isString2 = isString;
14468
14719
 
14469
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Pull.js
14720
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Pull.js
14470
14721
  var catchDone = /* @__PURE__ */ dual(2, (effect2, f) => catchCauseFilter(effect2, filterDoneLeftover, (l) => f(l)));
14471
14722
  var isDoneCause = (cause) => cause.reasons.some(isDoneFailure);
14472
14723
  var isDoneFailure = (failure) => failure._tag === "Fail" && isDone3(failure.error);
@@ -14484,7 +14735,7 @@ var matchEffect2 = /* @__PURE__ */ dual(2, (self, options) => matchCauseEffect(s
14484
14735
  }
14485
14736
  }));
14486
14737
 
14487
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Schedule.js
14738
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Schedule.js
14488
14739
  var TypeId8 = "~effect/Schedule";
14489
14740
  var CurrentMetadata2 = /* @__PURE__ */ Reference("effect/Schedule/CurrentMetadata", {
14490
14741
  defaultValue: /* @__PURE__ */ constant({
@@ -14578,11 +14829,11 @@ var while_ = /* @__PURE__ */ dual(2, (self, predicate) => fromStep(map4(toStep(s
14578
14829
  })));
14579
14830
  var forever3 = /* @__PURE__ */ spaced(zero);
14580
14831
 
14581
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/internal/layer.js
14832
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/internal/layer.js
14582
14833
  var provideLayer = (self, layer, options) => scopedWith((scope2) => flatMap3(options?.local ? buildWithMemoMap(layer, makeMemoMapUnsafe(), scope2) : buildWithScope(layer, scope2), (context2) => provideContext(self, context2)));
14583
14834
  var provide3 = /* @__PURE__ */ dual((args2) => isEffect(args2[0]), (self, source, options) => isContext(source) ? provideContext(self, source) : provideLayer(self, Array.isArray(source) ? mergeAll2(...source) : source, options));
14584
14835
 
14585
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/internal/schedule.js
14836
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/internal/schedule.js
14586
14837
  var repeatOrElse = /* @__PURE__ */ dual(3, (self, schedule, orElse3) => flatMap3(toStepWithMetadata(schedule), (step) => {
14587
14838
  let meta = CurrentMetadata2.defaultValue();
14588
14839
  return catch_(forever2(tap3(flatMap3(suspend(() => provideService(self, CurrentMetadata2, meta)), step), (meta_) => sync(() => {
@@ -14653,8 +14904,52 @@ var buildFromOptions = (options) => {
14653
14904
  return schedule;
14654
14905
  };
14655
14906
 
14656
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/internal/executionPlan.js
14657
- var withExecutionPlan = /* @__PURE__ */ dual(2, (self, plan) => suspend(() => {
14907
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/internal/executionPlan.js
14908
+ var makeEventEmitter = (onEvent, currentMetadata) => {
14909
+ let lastStepIndex = -1;
14910
+ let stepAttempt = 0;
14911
+ const emit = (event) => ignoreCause(onEvent(event));
14912
+ return {
14913
+ begin: clockWith((clock) => suspend(() => {
14914
+ const meta = currentMetadata();
14915
+ if (meta.stepIndex !== lastStepIndex) {
14916
+ lastStepIndex = meta.stepIndex;
14917
+ stepAttempt = 0;
14918
+ }
14919
+ stepAttempt++;
14920
+ const state = {
14921
+ attempt: meta.attempt,
14922
+ stepAttempt,
14923
+ stepIndex: meta.stepIndex,
14924
+ startNanos: clock.monotonicTimeNanosUnsafe()
14925
+ };
14926
+ return as2(emit({
14927
+ _tag: "AttemptStart",
14928
+ attempt: state.attempt,
14929
+ stepAttempt: state.stepAttempt,
14930
+ stepIndex: state.stepIndex
14931
+ }), state);
14932
+ })),
14933
+ end: (state, exit2) => clockWith((clock) => {
14934
+ const duration = nanos(clock.monotonicTimeNanosUnsafe() - state.startNanos);
14935
+ return emit(exit2._tag === "Success" ? {
14936
+ _tag: "AttemptSuccess",
14937
+ attempt: state.attempt,
14938
+ stepAttempt: state.stepAttempt,
14939
+ stepIndex: state.stepIndex,
14940
+ duration
14941
+ } : {
14942
+ _tag: "AttemptFailure",
14943
+ attempt: state.attempt,
14944
+ stepAttempt: state.stepAttempt,
14945
+ stepIndex: state.stepIndex,
14946
+ duration,
14947
+ cause: exit2.cause
14948
+ });
14949
+ })
14950
+ };
14951
+ };
14952
+ var withExecutionPlan = /* @__PURE__ */ dual((args2) => isEffect(args2[0]), (self, plan, options) => suspend(() => {
14658
14953
  let i = 0;
14659
14954
  let meta = {
14660
14955
  attempt: 0,
@@ -14667,12 +14962,14 @@ var withExecutionPlan = /* @__PURE__ */ dual(2, (self, plan) => suspend(() => {
14667
14962
  };
14668
14963
  return meta;
14669
14964
  }));
14965
+ const emitter = options?.onEvent === undefined ? undefined : makeEventEmitter(options.onEvent, () => meta);
14966
+ const instrument = emitter === undefined ? identity : (attempt) => uninterruptibleMask((restore) => flatMap3(emitter.begin, (state) => onExit(restore(attempt), (exit2) => emitter.end(state, exit2))));
14670
14967
  let result2;
14671
14968
  return flatMap3(whileLoop({
14672
14969
  while: () => i < plan.steps.length && (result2 === undefined || isFailure2(result2)),
14673
14970
  body() {
14674
14971
  const step = plan.steps[i];
14675
- let nextEffect = provideMeta(provide3(self, step.provide));
14972
+ let nextEffect = provideMeta(instrument(provide3(self, step.provide)));
14676
14973
  if (result2) {
14677
14974
  let attempted = false;
14678
14975
  const wrapped = nextEffect;
@@ -14713,7 +15010,7 @@ var scheduleFromStep = (step, first) => {
14713
15010
  };
14714
15011
  var scheduleOnce = /* @__PURE__ */ recurs(1);
14715
15012
 
14716
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Request.js
15013
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Request.js
14717
15014
  var TypeId9 = "~effect/Request";
14718
15015
  var requestVariance = /* @__PURE__ */ byReferenceUnsafe({
14719
15016
  _E: (_) => _,
@@ -14726,7 +15023,7 @@ var RequestPrototype = {
14726
15023
  };
14727
15024
  var makeEntry = (options) => options;
14728
15025
 
14729
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/internal/request.js
15026
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/internal/request.js
14730
15027
  var request = /* @__PURE__ */ dual(2, (self, resolver) => {
14731
15028
  const withResolver = (resolver2) => callback((resume) => {
14732
15029
  const entry = addEntry(resolver2, self, resume, getCurrentFiber());
@@ -14842,7 +15139,7 @@ function runBatch(batch) {
14842
15139
  return batch.run;
14843
15140
  }
14844
15141
 
14845
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Metric.js
15142
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Metric.js
14846
15143
  var CurrentMetricAttributesKey = "effect/Metric/CurrentMetricAttributes";
14847
15144
  var CurrentMetricAttributes = /* @__PURE__ */ Reference(CurrentMetricAttributesKey, {
14848
15145
  defaultValue: () => ({})
@@ -14999,7 +15296,7 @@ class HistogramMetric extends Metric$ {
14999
15296
  let count = 0;
15000
15297
  let sum2 = 0;
15001
15298
  let min2 = Number.MAX_VALUE;
15002
- let max2 = Number.MIN_VALUE;
15299
+ let max2 = -Number.MAX_VALUE;
15003
15300
  map3(sort(bounds, Number2), (n, i) => {
15004
15301
  boundaries[i] = n;
15005
15302
  });
@@ -15076,7 +15373,7 @@ class SummaryMetric extends Metric$ {
15076
15373
  let count = 0;
15077
15374
  let sum2 = 0;
15078
15375
  let min2 = Number.MAX_VALUE;
15079
- let max2 = Number.MIN_VALUE;
15376
+ let max2 = -Number.MAX_VALUE;
15080
15377
  const snapshot = (now) => {
15081
15378
  const builder = [];
15082
15379
  let i = 0;
@@ -15154,10 +15451,7 @@ function makeHooks(get2, update2, modify) {
15154
15451
  };
15155
15452
  }
15156
15453
  function serializeAttributes(attributes) {
15157
- return serializeEntries(Array.isArray(attributes) ? attributes : Object.entries(attributes));
15158
- }
15159
- function serializeEntries(entries) {
15160
- return entries.map(([key, value]) => `${key}=${value}`).join(",");
15454
+ return JSON.stringify(Array.isArray(attributes) ? attributes : Object.entries(attributes));
15161
15455
  }
15162
15456
  function mergeAttributes(self, other) {
15163
15457
  return {
@@ -15168,18 +15462,19 @@ function mergeAttributes(self, other) {
15168
15462
  function attributesToRecord(attributes) {
15169
15463
  if (isNotUndefined(attributes) && Array.isArray(attributes)) {
15170
15464
  return attributes.reduce((acc, [key, value]) => {
15171
- acc[key] = value;
15465
+ assignProperty(acc, key, value);
15172
15466
  return acc;
15173
15467
  }, {});
15174
15468
  }
15175
15469
  return attributes;
15176
15470
  }
15177
15471
 
15178
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Effect.js
15472
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Effect.js
15179
15473
  var TypeId11 = EffectTypeId;
15180
15474
  var isEffect2 = isEffect;
15181
15475
  var all4 = all3;
15182
15476
  var partition3 = partition2;
15477
+ var reduce2 = reduce;
15183
15478
  var validate2 = validate;
15184
15479
  var findFirst2 = findFirst;
15185
15480
  var findFirstFilter2 = findFirstFilter;
@@ -15205,7 +15500,7 @@ var fail6 = fail3;
15205
15500
  var failSync2 = failSync;
15206
15501
  var failCause4 = failCause;
15207
15502
  var failCauseSync2 = failCauseSync;
15208
- var die3 = die;
15503
+ var die4 = die;
15209
15504
  var try_3 = try_2;
15210
15505
  var yieldNow2 = yieldNow;
15211
15506
  var yieldNowWith2 = yieldNowWith;
@@ -15215,7 +15510,7 @@ var fromOption4 = fromOption3;
15215
15510
  var transposeOption3 = transposeOption2;
15216
15511
  var fromNullishOr4 = fromNullishOr3;
15217
15512
  var flatMap5 = flatMap3;
15218
- var flatten4 = flatten3;
15513
+ var flatten5 = flatten4;
15219
15514
  var andThen4 = andThen3;
15220
15515
  var tap5 = tap3;
15221
15516
  var result2 = result;
@@ -15278,7 +15573,7 @@ var filterMapOrElse2 = filterMapOrElse;
15278
15573
  var filterOrFail3 = filterOrFail2;
15279
15574
  var filterMapOrFail2 = filterMapOrFail;
15280
15575
  var when2 = when;
15281
- var match5 = match4;
15576
+ var match6 = match4;
15282
15577
  var matchEager2 = matchEager;
15283
15578
  var matchCause2 = matchCause;
15284
15579
  var matchCauseEager2 = matchCauseEager;
@@ -15296,9 +15591,9 @@ var service2 = service;
15296
15591
  var serviceOption2 = serviceOption;
15297
15592
  var updateContext2 = updateContext;
15298
15593
  var updateService3 = updateService;
15594
+ var updateServiceScoped2 = updateServiceScoped;
15299
15595
  var provideService2 = provideService;
15300
15596
  var provideServiceEffect2 = provideServiceEffect;
15301
- var withConcurrency2 = withConcurrency;
15302
15597
  var scope2 = scope;
15303
15598
  var scoped2 = scoped;
15304
15599
  var scopedWith2 = scopedWith;
@@ -15382,13 +15677,16 @@ var logDebug = /* @__PURE__ */ logWithLevel("Debug");
15382
15677
  var logTrace = /* @__PURE__ */ logWithLevel("Trace");
15383
15678
  var withLogger = /* @__PURE__ */ dual(2, (effect2, logger) => updateService(effect2, CurrentLoggers, (loggers) => new Set([...loggers, logger])));
15384
15679
  var annotateLogs = /* @__PURE__ */ dual((args2) => isEffect2(args2[0]), (effect2, ...args2) => updateService(effect2, CurrentLogAnnotations2, (annotations) => {
15385
- const newAnnotations = {
15680
+ const newAnnotations = args2.length === 1 ? {
15681
+ ...annotations,
15682
+ ...args2[0]
15683
+ } : {
15386
15684
  ...annotations
15387
15685
  };
15388
15686
  if (args2.length === 1) {
15389
- Object.assign(newAnnotations, args2[0]);
15687
+ return newAnnotations;
15390
15688
  } else {
15391
- newAnnotations[args2[0]] = args2[1];
15689
+ assignProperty(newAnnotations, args2[0], args2[1]);
15392
15690
  }
15393
15691
  return newAnnotations;
15394
15692
  }));
@@ -15414,9 +15712,9 @@ var trackDefects = /* @__PURE__ */ dual((args2) => isEffect2(args2[0]), (self, m
15414
15712
  return update(metric, input);
15415
15713
  }));
15416
15714
  var trackDuration = /* @__PURE__ */ dual((args2) => isEffect2(args2[0]), (self, metric, f) => clockWith2((clock) => {
15417
- const startTime = clock.currentTimeNanosUnsafe();
15715
+ const startTime = clock.monotonicTimeNanosUnsafe();
15418
15716
  return onExit2(self, () => {
15419
- const endTime = clock.currentTimeNanosUnsafe();
15717
+ const endTime = clock.monotonicTimeNanosUnsafe();
15420
15718
  const duration = subtract(fromInputUnsafe(endTime), fromInputUnsafe(startTime));
15421
15719
  const input = f === undefined ? duration : internalCall(() => f(duration));
15422
15720
  return update(metric, input);
@@ -15456,9 +15754,9 @@ var tx = (effect2) => withFiber2((fiber3) => {
15456
15754
  });
15457
15755
  var isTransactionConsistent = (state) => {
15458
15756
  for (const [ref, {
15459
- version: version2
15757
+ version
15460
15758
  }] of state.journal) {
15461
- if (ref.version !== version2) {
15759
+ if (ref.version !== version) {
15462
15760
  return false;
15463
15761
  }
15464
15762
  }
@@ -15515,7 +15813,7 @@ var effectify = (fn3, onError3, onSyncError) => (...args2) => callback2((resume)
15515
15813
  }
15516
15814
  });
15517
15815
  } catch (err) {
15518
- resume(onSyncError ? fail6(onSyncError(err, args2)) : die3(err));
15816
+ resume(onSyncError ? fail6(onSyncError(err, args2)) : die4(err));
15519
15817
  }
15520
15818
  });
15521
15819
  var satisfiesSuccessType2 = () => (effect2) => effect2;
@@ -15528,7 +15826,7 @@ var flatMapEager2 = flatMapEager;
15528
15826
  var catchEager2 = catchEager;
15529
15827
  var fnUntracedEager2 = fnUntracedEager;
15530
15828
 
15531
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/FileSystem.js
15829
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/FileSystem.js
15532
15830
  var exports_FileSystem = {};
15533
15831
  __export(exports_FileSystem, {
15534
15832
  makeNoop: () => makeNoop,
@@ -15543,20 +15841,10 @@ __export(exports_FileSystem, {
15543
15841
  KiB: () => KiB,
15544
15842
  GiB: () => GiB,
15545
15843
  FileTypeId: () => FileTypeId,
15546
- FileSystem: () => FileSystem,
15547
- FileDescriptor: () => FileDescriptor
15844
+ FileSystem: () => FileSystem
15548
15845
  });
15549
15846
 
15550
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Brand.js
15551
- function nominal() {
15552
- return Object.assign((input) => input, {
15553
- option: (input) => some2(input),
15554
- result: (input) => succeed2(input),
15555
- is: (_) => true
15556
- });
15557
- }
15558
-
15559
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/PlatformError.js
15847
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/PlatformError.js
15560
15848
  var exports_PlatformError = {};
15561
15849
  __export(exports_PlatformError, {
15562
15850
  systemError: () => systemError,
@@ -15600,21 +15888,44 @@ class PlatformError extends (/* @__PURE__ */ TaggedError2("PlatformError")) {
15600
15888
  var systemError = (options) => new PlatformError(new SystemError(options));
15601
15889
  var badArgument = (options) => new PlatformError(new BadArgument(options));
15602
15890
 
15603
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Fiber.js
15604
- var TypeId13 = `~effect/Fiber/${version}`;
15891
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Fiber.js
15892
+ var await_ = fiberAwait;
15605
15893
  var join = fiberJoin;
15606
15894
  var joinAll = fiberJoinAll;
15607
15895
  var interrupt4 = fiberInterrupt;
15608
15896
  var getCurrent = getCurrentFiber;
15609
15897
  var runIn = fiberRunIn;
15610
15898
 
15611
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Latch.js
15899
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Latch.js
15612
15900
  var makeUnsafe4 = makeLatchUnsafe;
15613
15901
  var make8 = makeLatch;
15614
15902
 
15615
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/MutableList.js
15903
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/MutableRef.js
15904
+ var TypeId13 = "~effect/MutableRef";
15905
+ var MutableRefProto = {
15906
+ [TypeId13]: TypeId13,
15907
+ ...PipeInspectableProto,
15908
+ toJSON() {
15909
+ return {
15910
+ _id: "MutableRef",
15911
+ current: toJson(this.current)
15912
+ };
15913
+ }
15914
+ };
15915
+ var make9 = (value) => {
15916
+ const ref = Object.create(MutableRefProto);
15917
+ ref.current = value;
15918
+ return ref;
15919
+ };
15920
+ var get2 = (self) => self.current;
15921
+ var set = /* @__PURE__ */ dual(2, (self, value) => {
15922
+ self.current = value;
15923
+ return self;
15924
+ });
15925
+
15926
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/MutableList.js
15616
15927
  var Empty = /* @__PURE__ */ Symbol.for("effect/MutableList/Empty");
15617
- var make9 = () => ({
15928
+ var make10 = () => ({
15618
15929
  head: undefined,
15619
15930
  tail: undefined,
15620
15931
  length: 0
@@ -15642,6 +15953,8 @@ var prepend = (self, message) => {
15642
15953
  offset: 0,
15643
15954
  next: self.head
15644
15955
  };
15956
+ if (!self.tail)
15957
+ self.tail = self.head;
15645
15958
  self.length++;
15646
15959
  };
15647
15960
  var appendAll2 = (self, messages) => appendAllUnsafe(self, fromIterable2(messages), !Array.isArray(messages));
@@ -15741,6 +16054,8 @@ var take = (self) => {
15741
16054
  return message;
15742
16055
  };
15743
16056
  var toArrayN = (self, n) => {
16057
+ if (n <= 0)
16058
+ return [];
15744
16059
  const length = Math.min(n, self.length);
15745
16060
  const out = new Array(length);
15746
16061
  let index = 0;
@@ -15766,6 +16081,10 @@ var filter6 = (self, f) => {
15766
16081
  }
15767
16082
  chunk = chunk.next;
15768
16083
  }
16084
+ if (array2.length === 0) {
16085
+ clear(self);
16086
+ return;
16087
+ }
15769
16088
  self.head = self.tail = {
15770
16089
  array: array2,
15771
16090
  mutable: true,
@@ -15776,33 +16095,10 @@ var filter6 = (self, f) => {
15776
16095
  };
15777
16096
  var remove = (self, value) => filter6(self, (v) => v !== value);
15778
16097
 
15779
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/MutableRef.js
15780
- var TypeId14 = "~effect/MutableRef";
15781
- var MutableRefProto = {
15782
- [TypeId14]: TypeId14,
15783
- ...PipeInspectableProto,
15784
- toJSON() {
15785
- return {
15786
- _id: "MutableRef",
15787
- current: toJson(this.current)
15788
- };
15789
- }
15790
- };
15791
- var make10 = (value) => {
15792
- const ref = Object.create(MutableRefProto);
15793
- ref.current = value;
15794
- return ref;
15795
- };
15796
- var get2 = (self) => self.current;
15797
- var set = /* @__PURE__ */ dual(2, (self, value) => {
15798
- self.current = value;
15799
- return self;
15800
- });
15801
-
15802
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/PubSub.js
15803
- var TypeId15 = "~effect/PubSub";
16098
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/PubSub.js
16099
+ var TypeId14 = "~effect/PubSub";
15804
16100
  var SubscriptionTypeId = "~effect/PubSub/Subscription";
15805
- var make11 = (options) => sync3(() => makePubSubUnsafe(options.atomicPubSub(), new Map, makeUnsafe3(), makeUnsafe4(false), make10(false), options.strategy()));
16101
+ var make11 = (options) => sync3(() => makePubSubUnsafe(options.atomicPubSub(), new Map, makeUnsafe3(), makeUnsafe4(false), make9(false), options.strategy()));
15806
16102
  var bounded = (capacity) => make11({
15807
16103
  atomicPubSub: () => makeAtomicBounded(capacity),
15808
16104
  strategy: () => new BackPressureStrategy
@@ -15873,6 +16169,7 @@ var unsubscribe = (self) => uninterruptible2(withFiber2((state) => {
15873
16169
  }).pipe(tap5(() => sync3(() => {
15874
16170
  self.subscribers.delete(self.subscription);
15875
16171
  self.subscription.unsubscribe();
16172
+ self.replayWindow.close();
15876
16173
  self.strategy.onPubSubEmptySpaceUnsafe(self.pubsub, self.subscribers);
15877
16174
  })), when2(self.shutdownHook.open), asVoid3);
15878
16175
  }));
@@ -15941,10 +16238,11 @@ var removeSubscribers = (subscribers, subscription, pollers) => {
15941
16238
  subscribers.delete(subscription);
15942
16239
  }
15943
16240
  };
15944
- var makeSubscriptionUnsafe = (pubsub, subscribers, strategy) => new SubscriptionImpl(pubsub, subscribers, pubsub.subscribe(), make9(), makeUnsafe4(false), make10(false), strategy, pubsub.replayWindow());
16241
+ var makeSubscriptionUnsafe = (pubsub, subscribers, strategy) => new SubscriptionImpl(pubsub, subscribers, pubsub.subscribe(), make10(), makeUnsafe4(false), make9(false), strategy, pubsub.replayWindow());
15945
16242
 
15946
16243
  class BoundedPubSubArb {
15947
16244
  array;
16245
+ replayIndices;
15948
16246
  publisherIndex = 0;
15949
16247
  subscribers;
15950
16248
  subscriberCount = 0;
@@ -15957,6 +16255,9 @@ class BoundedPubSubArb {
15957
16255
  this.array = Array.from({
15958
16256
  length: capacity
15959
16257
  });
16258
+ this.replayIndices = replayBuffer ? Array.from({
16259
+ length: capacity
16260
+ }) : [];
15960
16261
  this.subscribers = Array.from({
15961
16262
  length: capacity
15962
16263
  });
@@ -15977,15 +16278,16 @@ class BoundedPubSubArb {
15977
16278
  if (this.isFull()) {
15978
16279
  return false;
15979
16280
  }
16281
+ const replayIndex = this.replayBuffer?.offer(value);
15980
16282
  if (this.subscriberCount !== 0) {
15981
16283
  const index = this.publisherIndex % this.capacity;
15982
16284
  this.array[index] = value;
16285
+ if (replayIndex !== undefined) {
16286
+ this.replayIndices[index] = replayIndex;
16287
+ }
15983
16288
  this.subscribers[index] = this.subscriberCount;
15984
16289
  this.publisherIndex += 1;
15985
16290
  }
15986
- if (this.replayBuffer) {
15987
- this.replayBuffer.offer(value);
15988
- }
15989
16291
  return true;
15990
16292
  }
15991
16293
  publishAll(elements) {
@@ -16009,23 +16311,23 @@ class BoundedPubSubArb {
16009
16311
  const a = chunk[iteratorIndex++];
16010
16312
  const index = this.publisherIndex % this.capacity;
16011
16313
  this.array[index] = a;
16314
+ const replayIndex = this.replayBuffer?.offer(a);
16315
+ if (replayIndex !== undefined) {
16316
+ this.replayIndices[index] = replayIndex;
16317
+ }
16012
16318
  this.subscribers[index] = this.subscriberCount;
16013
16319
  this.publisherIndex += 1;
16014
- if (this.replayBuffer) {
16015
- this.replayBuffer.offer(a);
16016
- }
16017
16320
  }
16018
16321
  return chunk.slice(iteratorIndex);
16019
16322
  }
16020
16323
  slide() {
16021
16324
  if (this.subscribersIndex !== this.publisherIndex) {
16022
16325
  const index = this.subscribersIndex % this.capacity;
16326
+ const value = this.array[index];
16023
16327
  this.array[index] = AbsentValue;
16024
16328
  this.subscribers[index] = 0;
16025
16329
  this.subscribersIndex += 1;
16026
- }
16027
- if (this.replayBuffer) {
16028
- this.replayBuffer.slide();
16330
+ this.replayBuffer?.slide(value, this.replayIndices[index]);
16029
16331
  }
16030
16332
  }
16031
16333
  subscribe() {
@@ -16115,6 +16417,7 @@ class BoundedPubSubArbSubscription {
16115
16417
 
16116
16418
  class BoundedPubSubPow2 {
16117
16419
  array;
16420
+ replayIndices;
16118
16421
  mask;
16119
16422
  publisherIndex = 0;
16120
16423
  subscribers;
@@ -16128,6 +16431,9 @@ class BoundedPubSubPow2 {
16128
16431
  this.array = Array.from({
16129
16432
  length: capacity
16130
16433
  });
16434
+ this.replayIndices = replayBuffer ? Array.from({
16435
+ length: capacity
16436
+ }) : [];
16131
16437
  this.mask = capacity - 1;
16132
16438
  this.subscribers = Array.from({
16133
16439
  length: capacity
@@ -16149,15 +16455,16 @@ class BoundedPubSubPow2 {
16149
16455
  if (this.isFull()) {
16150
16456
  return false;
16151
16457
  }
16458
+ const replayIndex = this.replayBuffer?.offer(value);
16152
16459
  if (this.subscriberCount !== 0) {
16153
16460
  const index = this.publisherIndex & this.mask;
16154
16461
  this.array[index] = value;
16462
+ if (replayIndex !== undefined) {
16463
+ this.replayIndices[index] = replayIndex;
16464
+ }
16155
16465
  this.subscribers[index] = this.subscriberCount;
16156
16466
  this.publisherIndex += 1;
16157
16467
  }
16158
- if (this.replayBuffer) {
16159
- this.replayBuffer.offer(value);
16160
- }
16161
16468
  return true;
16162
16469
  }
16163
16470
  publishAll(elements) {
@@ -16181,23 +16488,23 @@ class BoundedPubSubPow2 {
16181
16488
  const elem = chunk[iteratorIndex++];
16182
16489
  const index = this.publisherIndex & this.mask;
16183
16490
  this.array[index] = elem;
16491
+ const replayIndex = this.replayBuffer?.offer(elem);
16492
+ if (replayIndex !== undefined) {
16493
+ this.replayIndices[index] = replayIndex;
16494
+ }
16184
16495
  this.subscribers[index] = this.subscriberCount;
16185
16496
  this.publisherIndex += 1;
16186
- if (this.replayBuffer) {
16187
- this.replayBuffer.offer(elem);
16188
- }
16189
16497
  }
16190
16498
  return chunk.slice(iteratorIndex);
16191
16499
  }
16192
16500
  slide() {
16193
16501
  if (this.subscribersIndex !== this.publisherIndex) {
16194
16502
  const index = this.subscribersIndex & this.mask;
16503
+ const value = this.array[index];
16195
16504
  this.array[index] = AbsentValue;
16196
16505
  this.subscribers[index] = 0;
16197
16506
  this.subscribersIndex += 1;
16198
- }
16199
- if (this.replayBuffer) {
16200
- this.replayBuffer.slide();
16507
+ this.replayBuffer?.slide(value, this.replayIndices[index]);
16201
16508
  }
16202
16509
  }
16203
16510
  subscribe() {
@@ -16290,6 +16597,7 @@ class BoundedPubSubSingle {
16290
16597
  subscriberCount = 0;
16291
16598
  subscribers = 0;
16292
16599
  value = AbsentValue;
16600
+ replayIndex = 0;
16293
16601
  capacity = 1;
16294
16602
  replayBuffer;
16295
16603
  constructor(replayBuffer) {
@@ -16314,14 +16622,15 @@ class BoundedPubSubSingle {
16314
16622
  if (this.isFull()) {
16315
16623
  return false;
16316
16624
  }
16625
+ const replayIndex = this.replayBuffer?.offer(value);
16317
16626
  if (this.subscriberCount !== 0) {
16318
16627
  this.value = value;
16628
+ if (replayIndex !== undefined) {
16629
+ this.replayIndex = replayIndex;
16630
+ }
16319
16631
  this.subscribers = this.subscriberCount;
16320
16632
  this.publisherIndex += 1;
16321
16633
  }
16322
- if (this.replayBuffer) {
16323
- this.replayBuffer.offer(value);
16324
- }
16325
16634
  return true;
16326
16635
  }
16327
16636
  publishAll(elements) {
@@ -16343,11 +16652,10 @@ class BoundedPubSubSingle {
16343
16652
  }
16344
16653
  slide() {
16345
16654
  if (this.isFull()) {
16655
+ const value = this.value;
16346
16656
  this.subscribers = 0;
16347
16657
  this.value = AbsentValue;
16348
- }
16349
- if (this.replayBuffer) {
16350
- this.replayBuffer.slide();
16658
+ this.replayBuffer?.slide(value, this.replayIndex);
16351
16659
  }
16352
16660
  }
16353
16661
  subscribe() {
@@ -16412,6 +16720,7 @@ class BoundedPubSubSingleSubscription {
16412
16720
  class UnboundedPubSub {
16413
16721
  publisherHead = {
16414
16722
  value: AbsentValue,
16723
+ replayIndex: undefined,
16415
16724
  subscribers: 0,
16416
16725
  next: null
16417
16726
  };
@@ -16436,19 +16745,19 @@ class UnboundedPubSub {
16436
16745
  return this.publisherIndex - this.subscribersIndex;
16437
16746
  }
16438
16747
  publish(value) {
16748
+ const replayIndex = this.replayBuffer?.offer(value);
16439
16749
  const subscribers = this.publisherTail.subscribers;
16440
16750
  if (subscribers !== 0) {
16441
- this.publisherTail.next = {
16751
+ const node = {
16442
16752
  value,
16753
+ replayIndex,
16443
16754
  subscribers,
16444
16755
  next: null
16445
16756
  };
16757
+ this.publisherTail.next = node;
16446
16758
  this.publisherTail = this.publisherTail.next;
16447
16759
  this.publisherIndex += 1;
16448
16760
  }
16449
- if (this.replayBuffer) {
16450
- this.replayBuffer.offer(value);
16451
- }
16452
16761
  return true;
16453
16762
  }
16454
16763
  publishAll(elements) {
@@ -16463,12 +16772,12 @@ class UnboundedPubSub {
16463
16772
  }
16464
16773
  slide() {
16465
16774
  if (this.publisherHead !== this.publisherTail) {
16775
+ const node = this.publisherHead.next;
16776
+ const value = node.value;
16466
16777
  this.publisherHead = this.publisherHead.next;
16467
16778
  this.publisherHead.value = AbsentValue;
16468
16779
  this.subscribersIndex += 1;
16469
- }
16470
- if (this.replayBuffer) {
16471
- this.replayBuffer.slide();
16780
+ this.replayBuffer?.slide(value, node.replayIndex);
16472
16781
  }
16473
16782
  }
16474
16783
  subscribe() {
@@ -16603,7 +16912,7 @@ class SubscriptionImpl {
16603
16912
  }
16604
16913
 
16605
16914
  class PubSubImpl {
16606
- [TypeId15] = {
16915
+ [TypeId14] = {
16607
16916
  _A: identity
16608
16917
  };
16609
16918
  pubsub;
@@ -16632,7 +16941,7 @@ var ensureCapacity = (capacity) => {
16632
16941
  };
16633
16942
 
16634
16943
  class BackPressureStrategy {
16635
- publishers = /* @__PURE__ */ make9();
16944
+ publishers = /* @__PURE__ */ make10();
16636
16945
  get shutdown() {
16637
16946
  return withFiber2((fiber3) => forEach2(takeAll(this.publishers), ([_, deferred, last]) => last ? interruptWith(deferred, fiber3.id) : void_5, {
16638
16947
  concurrency: "unbounded",
@@ -16781,21 +17090,31 @@ class ReplayBuffer {
16781
17090
  capacity;
16782
17091
  head = {
16783
17092
  value: AbsentValue,
17093
+ index: 0,
16784
17094
  next: null
16785
17095
  };
16786
17096
  tail = this.head;
17097
+ slideValues = [];
16787
17098
  size = 0;
16788
17099
  index = 0;
17100
+ publisherIndex = 0;
16789
17101
  constructor(capacity) {
16790
17102
  this.capacity = capacity;
16791
17103
  }
16792
- slide() {
17104
+ slide(value, publisherIndex) {
17105
+ this.slideValues[this.index % this.capacity] = {
17106
+ value,
17107
+ index: publisherIndex
17108
+ };
16793
17109
  this.index++;
16794
17110
  }
16795
17111
  offer(a) {
17112
+ const index = this.publisherIndex++;
16796
17113
  this.tail.value = a;
17114
+ this.tail.index = index;
16797
17115
  this.tail.next = {
16798
17116
  value: AbsentValue,
17117
+ index: 0,
16799
17118
  next: null
16800
17119
  };
16801
17120
  this.tail = this.tail.next;
@@ -16804,6 +17123,7 @@ class ReplayBuffer {
16804
17123
  } else {
16805
17124
  this.size += 1;
16806
17125
  }
17126
+ return index;
16807
17127
  }
16808
17128
  offerAll(as4) {
16809
17129
  for (const a of as4) {
@@ -16813,47 +17133,65 @@ class ReplayBuffer {
16813
17133
  }
16814
17134
 
16815
17135
  class ReplayWindowImpl {
16816
- head;
16817
- index;
16818
- remaining;
16819
17136
  buffer;
17137
+ values;
17138
+ index = 0;
17139
+ remaining;
17140
+ slideIndex;
17141
+ newestIndex = -1;
16820
17142
  constructor(buffer) {
16821
17143
  this.buffer = buffer;
16822
- this.index = buffer.index;
16823
17144
  this.remaining = buffer.size;
16824
- this.head = buffer.head;
16825
- }
16826
- fastForward() {
16827
- while (this.index < this.buffer.index) {
16828
- this.head = this.head.next;
16829
- this.index++;
17145
+ this.slideIndex = buffer.index;
17146
+ this.values = new Array(this.remaining);
17147
+ let node = buffer.head;
17148
+ for (let i = 0;i < this.remaining; i++) {
17149
+ this.values[i] = node.value;
17150
+ this.newestIndex = node.index;
17151
+ node = node.next;
17152
+ }
17153
+ }
17154
+ close() {
17155
+ this.values.length = 0;
17156
+ this.remaining = 0;
17157
+ }
17158
+ sync() {
17159
+ const slides = this.buffer.index - this.slideIndex;
17160
+ if (slides === 0 || this.remaining === 0) {
17161
+ return;
17162
+ }
17163
+ const count = Math.min(slides, this.buffer.capacity);
17164
+ const start = this.buffer.index - count;
17165
+ for (let i = 0;i < count; i++) {
17166
+ const entry = this.buffer.slideValues[(start + i) % this.buffer.capacity];
17167
+ if (entry.index > this.newestIndex) {
17168
+ this.index = (this.index + 1) % this.values.length;
17169
+ this.values[(this.index + this.remaining - 1) % this.values.length] = entry.value;
17170
+ this.newestIndex = entry.index;
17171
+ }
16830
17172
  }
17173
+ this.slideIndex = this.buffer.index;
16831
17174
  }
16832
17175
  take() {
16833
17176
  if (this.remaining === 0) {
16834
17177
  return;
16835
- } else if (this.index < this.buffer.index) {
16836
- this.fastForward();
16837
17178
  }
17179
+ this.sync();
17180
+ const value = this.values[this.index];
17181
+ this.values[this.index] = AbsentValue;
17182
+ this.index = (this.index + 1) % this.values.length;
16838
17183
  this.remaining--;
16839
- const value = this.head.value;
16840
- this.head = this.head.next;
17184
+ if (this.remaining === 0) {
17185
+ this.close();
17186
+ }
16841
17187
  return value;
16842
17188
  }
16843
17189
  takeN(n) {
16844
- if (this.remaining === 0) {
16845
- return [];
16846
- } else if (this.index < this.buffer.index) {
16847
- this.fastForward();
16848
- }
16849
17190
  const len = Math.min(n, this.remaining);
16850
17191
  const items = new Array(len);
16851
17192
  for (let i = 0;i < len; i++) {
16852
- const value = this.head.value;
16853
- this.head = this.head.next;
16854
- items[i] = value;
17193
+ items[i] = this.take();
16855
17194
  }
16856
- this.remaining -= len;
16857
17195
  return items;
16858
17196
  }
16859
17197
  takeAll() {
@@ -16866,11 +17204,14 @@ var emptyReplayWindow = {
16866
17204
  return;
16867
17205
  },
16868
17206
  takeN: () => [],
16869
- takeAll: () => []
17207
+ takeAll: () => [],
17208
+ close: () => {
17209
+ return;
17210
+ }
16870
17211
  };
16871
17212
 
16872
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Queue.js
16873
- var TypeId16 = "~effect/Queue";
17213
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Queue.js
17214
+ var TypeId15 = "~effect/Queue";
16874
17215
  var EnqueueTypeId = "~effect/Queue/Enqueue";
16875
17216
  var DequeueTypeId = "~effect/Queue/Dequeue";
16876
17217
  var variance = {
@@ -16878,7 +17219,7 @@ var variance = {
16878
17219
  _E: identity
16879
17220
  };
16880
17221
  var QueueProto = {
16881
- [TypeId16]: variance,
17222
+ [TypeId15]: variance,
16882
17223
  [EnqueueTypeId]: variance,
16883
17224
  [DequeueTypeId]: variance,
16884
17225
  ...PipeInspectableProto,
@@ -16895,7 +17236,7 @@ var make12 = (options) => withFiber((fiber3) => {
16895
17236
  self.dispatcher = fiber3.currentDispatcher;
16896
17237
  self.capacity = options?.capacity ?? Number.POSITIVE_INFINITY;
16897
17238
  self.strategy = options?.strategy ?? "suspend";
16898
- self.messages = make9();
17239
+ self.messages = make10();
16899
17240
  self.scheduleRunning = false;
16900
17241
  self.state = {
16901
17242
  _tag: "Open",
@@ -17196,8 +17537,22 @@ var finalize = (self, exit3) => {
17196
17537
  openState.awaiters.clear();
17197
17538
  };
17198
17539
 
17199
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Semaphore.js
17540
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Semaphore.js
17200
17541
  var makeUnsafe5 = (permits) => new SemaphoreImpl(permits);
17542
+ var waitForPermits = (self, n, effect2) => callback((resume) => {
17543
+ if (self.free >= n)
17544
+ return resume(effect2);
17545
+ const observer = () => {
17546
+ if (self.free < n)
17547
+ return;
17548
+ self.waiters.delete(observer);
17549
+ resume(effect2);
17550
+ };
17551
+ self.waiters.add(observer);
17552
+ return sync(() => {
17553
+ self.waiters.delete(observer);
17554
+ });
17555
+ });
17201
17556
 
17202
17557
  class SemaphoreImpl {
17203
17558
  waiters = /* @__PURE__ */ new Set;
@@ -17212,63 +17567,64 @@ class SemaphoreImpl {
17212
17567
  take(n) {
17213
17568
  const take4 = suspend(() => {
17214
17569
  if (this.free < n) {
17215
- return callback((resume) => {
17216
- if (this.free >= n)
17217
- return resume(take4);
17218
- const observer = () => {
17219
- if (this.free < n)
17220
- return;
17221
- this.waiters.delete(observer);
17222
- resume(take4);
17223
- };
17224
- this.waiters.add(observer);
17225
- return sync(() => {
17226
- this.waiters.delete(observer);
17227
- });
17228
- });
17570
+ return waitForPermits(this, n, take4);
17229
17571
  }
17230
17572
  this.taken += n;
17231
17573
  return succeed3(n);
17232
17574
  });
17233
17575
  return take4;
17234
17576
  }
17235
- updateTakenUnsafe(fiber3, f) {
17236
- this.taken = f(this.taken);
17577
+ takeIfAvailable(n) {
17578
+ return suspend(() => {
17579
+ if (this.free < n)
17580
+ return succeed3(false);
17581
+ this.taken += n;
17582
+ return succeed3(true);
17583
+ });
17584
+ }
17585
+ releaseUnsafe(fiber3, n) {
17586
+ this.taken -= n;
17237
17587
  if (this.waiters.size > 0) {
17238
17588
  fiber3.currentDispatcher.scheduleTask(() => {
17239
- const iter = this.waiters.values();
17240
- let item = iter.next();
17241
- while (item.done === false && this.free > 0) {
17242
- item.value();
17243
- item = iter.next();
17589
+ for (const observer of this.waiters) {
17590
+ if (this.free <= 0)
17591
+ break;
17592
+ observer();
17244
17593
  }
17245
17594
  }, 0);
17246
17595
  }
17247
17596
  return this.free;
17248
17597
  }
17249
- updateTaken(f) {
17250
- return withFiber((fiber3) => succeed3(this.updateTakenUnsafe(fiber3, f)));
17251
- }
17252
17598
  resize(permits) {
17253
17599
  return withFiber((fiber3) => {
17254
17600
  this.permits = permits;
17255
17601
  if (this.free < 0)
17256
17602
  return void_3;
17257
- this.updateTakenUnsafe(fiber3, (taken) => taken);
17603
+ this.releaseUnsafe(fiber3, 0);
17258
17604
  return void_3;
17259
17605
  });
17260
17606
  }
17261
17607
  release(n) {
17262
- return this.updateTaken((taken) => taken - n);
17608
+ return withFiber((fiber3) => succeed3(this.releaseUnsafe(fiber3, n)));
17263
17609
  }
17264
17610
  get releaseAll() {
17265
- return this.updateTaken((_) => 0);
17611
+ return withFiber((fiber3) => succeed3(this.releaseUnsafe(fiber3, this.taken)));
17266
17612
  }
17267
17613
  withPermits(n) {
17268
- return (self) => uninterruptibleMask((restore) => flatMap3(restore(this.take(n)), (permits) => onExitPrimitive(restore(self), () => {
17269
- this.updateTakenUnsafe(getCurrentFiber(), (taken) => taken - permits);
17270
- return;
17271
- }, true)));
17614
+ return (self) => uninterruptibleMask((restore) => {
17615
+ const acquire = suspend(() => {
17616
+ if (this.free < n) {
17617
+ const wait = waitForPermits(this, n, void_3);
17618
+ return flatMap3(restore(wait), () => acquire);
17619
+ }
17620
+ this.taken += n;
17621
+ return onExitPrimitive(restore(self), () => {
17622
+ this.releaseUnsafe(getCurrentFiber(), n);
17623
+ return;
17624
+ }, true);
17625
+ });
17626
+ return acquire;
17627
+ });
17272
17628
  }
17273
17629
  withPermit = /* @__PURE__ */ this.withPermits(1);
17274
17630
  withPermitsIfAvailable(n) {
@@ -17277,21 +17633,21 @@ class SemaphoreImpl {
17277
17633
  return succeedNone2;
17278
17634
  this.taken += n;
17279
17635
  return onExitPrimitive(restore(asSome(self)), () => {
17280
- this.updateTakenUnsafe(getCurrentFiber(), (taken) => taken - n);
17636
+ this.releaseUnsafe(getCurrentFiber(), n);
17281
17637
  return;
17282
17638
  }, true);
17283
17639
  });
17284
17640
  }
17285
17641
  }
17286
17642
 
17287
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Take.js
17643
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Take.js
17288
17644
  var toPull = (take4) => isExit2(take4) ? isSuccess4(take4) ? done3(take4.value) : take4 : succeed6(take4);
17289
17645
 
17290
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Channel.js
17291
- var TypeId17 = "~effect/Channel";
17292
- var isChannel = (u) => hasProperty(u, TypeId17);
17646
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Channel.js
17647
+ var TypeId16 = "~effect/Channel";
17648
+ var isChannel = (u) => hasProperty(u, TypeId16);
17293
17649
  var ChannelProto = {
17294
- [TypeId17]: {
17650
+ [TypeId16]: {
17295
17651
  _Env: identity,
17296
17652
  _InErr: identity,
17297
17653
  _InElem: identity,
@@ -17365,7 +17721,7 @@ var fail7 = (error) => fromPull(succeed6(fail6(error)));
17365
17721
  var failSync3 = (evaluate2) => fromPull(failSync2(evaluate2));
17366
17722
  var failCause6 = (cause) => fromPull(failCause4(cause));
17367
17723
  var failCauseSync3 = (evaluate2) => fromPull(failCauseSync2(evaluate2));
17368
- var die4 = (defect) => failCause6(die2(defect));
17724
+ var die5 = (defect) => failCause6(die3(defect));
17369
17725
  var fromEffect = (effect2) => fromPull(sync3(() => {
17370
17726
  let done4 = false;
17371
17727
  return suspend3(() => {
@@ -17381,6 +17737,35 @@ var fromQueueArray = (queue) => fromPull(succeed6(takeAll3(queue)));
17381
17737
  var fromSubscriptionArray = (subscription) => fromPull(succeed6(onInterrupt2(takeAll2(subscription), () => done3())));
17382
17738
  var fromPubSubArray = (pubsub) => unwrap2(map5(subscribe(pubsub), fromSubscriptionArray));
17383
17739
  var fromPubSubTake = (pubsub) => unwrap2(map5(subscribe(pubsub), (sub) => fromEffectTake(take2(sub))));
17740
+ var fromReadableStream = (options) => fromTransform((_, scope3) => readableStreamToPullUnsafe({
17741
+ scope: scope3,
17742
+ readable: options.evaluate(),
17743
+ onError: options.onError,
17744
+ releaseLockOnEnd: options.releaseLockOnEnd
17745
+ }));
17746
+ var readableStreamToPullUnsafe = (options) => {
17747
+ const reader = options.readable.getReader();
17748
+ const exit3 = options.exit ?? make9(undefined);
17749
+ const pull = suspend3(() => {
17750
+ if (exit3.current)
17751
+ return exit3.current;
17752
+ return matchCauseEffect2(tryPromise2({
17753
+ try: () => reader.read(),
17754
+ catch: options.onError
17755
+ }), {
17756
+ onFailure: (cause) => exit3.current ?? failCause4(cause),
17757
+ onSuccess: ({
17758
+ done: done4,
17759
+ value
17760
+ }) => {
17761
+ if (exit3.current)
17762
+ return exit3.current;
17763
+ return done4 ? done3() : succeed6(of(value));
17764
+ }
17765
+ });
17766
+ });
17767
+ return as3(addFinalizer2(options.scope, options.releaseLockOnEnd ? sync3(() => reader.releaseLock()) : promise2(() => reader.cancel().catch(constVoid))), pull);
17768
+ };
17384
17769
  var fromAsyncIterable = (iterable, onError3) => fromTransform(fnUntraced2(function* (_, scope3) {
17385
17770
  const iter = iterable[Symbol.asyncIterator]();
17386
17771
  if (iter.return) {
@@ -17428,7 +17813,7 @@ var mapEffectConcurrent = (self, f, options) => fromTransformBracket(fnUntraced2
17428
17813
  } else {
17429
17814
  const effects = yield* bounded2(concurrencyN - 2);
17430
17815
  yield* addFinalizer2(forkedScope, shutdown2(queue));
17431
- yield* take3(effects).pipe(flatten4, flatMap5((value) => offer(queue, value)), forever4({
17816
+ yield* take3(effects).pipe(flatten5, flatMap5((value) => offer(queue, value)), forever4({
17432
17817
  disableYield: true
17433
17818
  }), catchCause3((cause) => failCause5(queue, cause)), forkIn2(forkedScope));
17434
17819
  let errorCause;
@@ -17704,7 +18089,7 @@ var catchReasons3 = /* @__PURE__ */ dual((args2) => isChannel(args2[0]), (self,
17704
18089
  });
17705
18090
  });
17706
18091
  var mapError4 = /* @__PURE__ */ dual(2, (self, f) => catch_4(self, (err) => fail7(f(err))));
17707
- var orDie4 = (self) => catch_4(self, die4);
18092
+ var orDie4 = (self) => catch_4(self, die5);
17708
18093
  var ignore3 = /* @__PURE__ */ dual((args2) => isChannel(args2[0]), (self, options) => {
17709
18094
  if (!options?.log) {
17710
18095
  return catch_4(self, () => empty4);
@@ -17756,9 +18141,16 @@ var mergeAll3 = /* @__PURE__ */ dual(2, (channels, {
17756
18141
  const pull = yield* toTransform(channels)(upstream, scope3);
17757
18142
  yield* gen4(function* () {
17758
18143
  while (true) {
17759
- if (semaphore)
17760
- yield* semaphore.take(1);
17761
- const channel = yield* pull;
18144
+ let pullFiber;
18145
+ if (semaphore) {
18146
+ if (fibers.size < concurrencyN) {
18147
+ yield* semaphore.take(1);
18148
+ } else {
18149
+ pullFiber = yield* forkChild2(pull);
18150
+ yield* raceFirst2(semaphore.take(1), andThen4(join(pullFiber), never2));
18151
+ }
18152
+ }
18153
+ const channel = pullFiber === undefined ? yield* pull : yield* join(pullFiber);
17762
18154
  const childScope = forkUnsafe2(forkedScope);
17763
18155
  const childPull = yield* toTransform(channel)(upstream, childScope);
17764
18156
  while (fibers.size >= concurrencyN) {
@@ -17787,7 +18179,13 @@ var mergeAll3 = /* @__PURE__ */ dual(2, (channels, {
17787
18179
  doneLatch.closeUnsafe();
17788
18180
  fibers.add(fiber3);
17789
18181
  }
17790
- }).pipe(catchCause3((cause) => doneLatch.whenOpen(failCause5(queue, cause))), forkIn2(forkedScope));
18182
+ }).pipe(catchCause3((cause) => {
18183
+ const halt = filterDone(cause);
18184
+ if (isSuccess2(halt)) {
18185
+ return doneLatch.whenOpen(failCause5(queue, cause));
18186
+ }
18187
+ return failCause5(queue, cause);
18188
+ }), forkIn2(forkedScope));
17791
18189
  return take3(queue);
17792
18190
  })));
17793
18191
  var merge4 = /* @__PURE__ */ dual((args2) => isChannel(args2[0]) && isChannel(args2[1]), (left, right, options) => fromTransformBracket(fnUntraced2(function* (upstream, _scope, forkedScope) {
@@ -17904,8 +18302,8 @@ var splitLines = () => fromTransform((upstream, _scope) => sync3(() => {
17904
18302
  }));
17905
18303
  var pipeTo = /* @__PURE__ */ dual(2, (self, that) => fromTransform((upstream, scope3) => flatMap5(toTransform(self)(upstream, scope3), (upstream2) => toTransform(that)(upstream2, scope3))));
17906
18304
  var pipeToOrFail = /* @__PURE__ */ dual(2, (self, that) => fromTransform((upstream, scope3) => flatMap5(toTransform(self)(upstream, scope3), (upstream2) => {
17907
- const upstreamPull = catchCause3(upstream2, (cause) => isDoneCause(cause) ? failCause4(cause) : die3(Done2(cause)));
17908
- return map5(toTransform(that)(upstreamPull, scope3), (pull) => catchDefect2(pull, (defect) => isDone3(defect) ? failCause4(defect.value) : die3(defect)));
18305
+ const upstreamPull = catchCause3(upstream2, (cause) => isDoneCause(cause) ? failCause4(cause) : die4(Done2(cause)));
18306
+ return map5(toTransform(that)(upstreamPull, scope3), (pull) => catchDefect2(pull, (defect) => isDone3(defect) ? failCause4(defect.value) : die4(defect)));
17909
18307
  })));
17910
18308
  var unwrap2 = (channel) => fromTransform((upstream, scope3) => {
17911
18309
  let pull;
@@ -17945,12 +18343,16 @@ var interruptWhen = /* @__PURE__ */ dual(2, (self, effect2) => merge4(self, from
17945
18343
  }));
17946
18344
  var haltWhen = /* @__PURE__ */ dual(2, (self, effect2) => fromTransformBracket(fnUntraced2(function* (upstream, scope3, forkedScope) {
17947
18345
  const pull = yield* toTransform(self)(upstream, scope3);
17948
- let haltCause = undefined;
17949
- yield* effect2.pipe(catchCause3((cause) => {
17950
- haltCause = cause;
17951
- return void_5;
17952
- }), forkIn2(forkedScope));
17953
- return suspend3(() => haltCause ? failCause4(haltCause) : pull);
18346
+ const fiber3 = yield* forkIn2(effect2, forkedScope, {
18347
+ startImmediately: true
18348
+ });
18349
+ return suspend3(() => {
18350
+ const exit3 = fiber3.pollUnsafe();
18351
+ return exit3 === undefined ? pull : match5(exit3, {
18352
+ onFailure: failCause4,
18353
+ onSuccess: done3
18354
+ });
18355
+ });
17954
18356
  })));
17955
18357
  var onError3 = /* @__PURE__ */ dual(2, (self, finalizer) => onExit3(self, (exit3) => isFailure4(exit3) ? finalizer(exit3.cause) : void_5));
17956
18358
  var onExit3 = /* @__PURE__ */ dual(2, (self, finalizer) => fromTransformBracket((upstream, scope3, forkedScope) => addFinalizerExit(forkedScope, finalizer).pipe(andThen4(toTransform(self)(upstream, scope3)))));
@@ -18002,6 +18404,28 @@ var runForEach = /* @__PURE__ */ dual(2, (self, f) => runWith(self, (pull) => fo
18002
18404
  var runForEachWhile = /* @__PURE__ */ dual(2, (self, f) => runWith(self, (pull) => pull.pipe(flatMap5(f), flatMap5((cont) => cont ? void_5 : done3()), forever4({
18003
18405
  disableYield: true
18004
18406
  }))));
18407
+ var mkUint8Array = (self) => map5(runFold(self, () => ({
18408
+ bytes: 0,
18409
+ arrays: []
18410
+ }), (acc, chunk) => {
18411
+ for (let i = 0;i < chunk.length; i++) {
18412
+ acc.bytes += chunk[i].length;
18413
+ acc.arrays.push(chunk[i]);
18414
+ }
18415
+ return acc;
18416
+ }), ({
18417
+ arrays,
18418
+ bytes
18419
+ }) => {
18420
+ const result3 = new Uint8Array(bytes);
18421
+ let offset = 0;
18422
+ for (let i = 0;i < arrays.length; i++) {
18423
+ const array2 = arrays[i];
18424
+ result3.set(array2, offset);
18425
+ offset += array2.length;
18426
+ }
18427
+ return result3;
18428
+ });
18005
18429
  var runHead = (self) => suspend3(() => {
18006
18430
  let head = none2();
18007
18431
  return runWith(self, (pull) => pull.pipe(asSome2, flatMap5((head_) => {
@@ -18080,15 +18504,15 @@ var toPubSubTake = /* @__PURE__ */ dual(2, /* @__PURE__ */ fnUntraced2(function*
18080
18504
  return pubsub;
18081
18505
  }));
18082
18506
 
18083
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/internal/stream.js
18084
- var TypeId18 = "~effect/Stream";
18507
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/internal/stream.js
18508
+ var TypeId17 = "~effect/Stream";
18085
18509
  var streamVariance = {
18086
18510
  _R: identity,
18087
18511
  _E: identity,
18088
18512
  _A: identity
18089
18513
  };
18090
18514
  var StreamProto = {
18091
- [TypeId18]: streamVariance,
18515
+ [TypeId17]: streamVariance,
18092
18516
  pipe() {
18093
18517
  return pipeArguments(this, arguments);
18094
18518
  }
@@ -18099,8 +18523,8 @@ var fromChannel = (channel) => {
18099
18523
  return self;
18100
18524
  };
18101
18525
 
18102
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Sink.js
18103
- var TypeId19 = "~effect/Sink";
18526
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Sink.js
18527
+ var TypeId18 = "~effect/Sink";
18104
18528
  var endVoid = /* @__PURE__ */ succeed6([undefined]);
18105
18529
  var sinkVariance = {
18106
18530
  _A: identity,
@@ -18110,12 +18534,12 @@ var sinkVariance = {
18110
18534
  _R: identity
18111
18535
  };
18112
18536
  var SinkProto = {
18113
- [TypeId19]: sinkVariance,
18537
+ [TypeId18]: sinkVariance,
18114
18538
  pipe() {
18115
18539
  return pipeArguments(this, arguments);
18116
18540
  }
18117
18541
  };
18118
- var isSink = (u) => hasProperty(u, TypeId19);
18542
+ var isSink = (u) => hasProperty(u, TypeId18);
18119
18543
  var fromChannel2 = (channel) => fromTransform2((upstream, scope3) => toTransform(channel)(upstream, scope3).pipe(flatMap5(forever4({
18120
18544
  disableYield: true
18121
18545
  })), catchDone(succeed6)));
@@ -18166,7 +18590,7 @@ var forEachArray = (f) => fromTransform2((upstream) => upstream.pipe(flatMap5(f)
18166
18590
  }), catchDone(() => endVoid)));
18167
18591
  var unwrap3 = (effect2) => fromChannel2(unwrap2(map5(effect2, toChannel)));
18168
18592
 
18169
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Stream.js
18593
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Stream.js
18170
18594
  var exports_Stream = {};
18171
18595
  __export(exports_Stream, {
18172
18596
  zipWithPreviousAndNext: () => zipWithPreviousAndNext,
@@ -18279,8 +18703,9 @@ __export(exports_Stream, {
18279
18703
  onError: () => onError4,
18280
18704
  onEnd: () => onEnd2,
18281
18705
  never: () => never4,
18282
- mkUint8Array: () => mkUint8Array,
18706
+ mkUint8Array: () => mkUint8Array2,
18283
18707
  mkString: () => mkString,
18708
+ mkArrayBuffer: () => mkArrayBuffer,
18284
18709
  mergeRight: () => mergeRight,
18285
18710
  mergeResult: () => mergeResult,
18286
18711
  mergeLeft: () => mergeLeft,
@@ -18298,6 +18723,7 @@ __export(exports_Stream, {
18298
18723
  mapAccum: () => mapAccum2,
18299
18724
  map: () => map7,
18300
18725
  make: () => make16,
18726
+ limitBytes: () => limitBytes,
18301
18727
  let: () => let_6,
18302
18728
  iterate: () => iterate,
18303
18729
  isStream: () => isStream,
@@ -18316,7 +18742,7 @@ __export(exports_Stream, {
18316
18742
  groupAdjacentBy: () => groupAdjacentBy,
18317
18743
  fromSubscription: () => fromSubscription,
18318
18744
  fromSchedule: () => fromSchedule,
18319
- fromReadableStream: () => fromReadableStream,
18745
+ fromReadableStream: () => fromReadableStream2,
18320
18746
  fromQueue: () => fromQueue,
18321
18747
  fromPull: () => fromPull2,
18322
18748
  fromPubSubTake: () => fromPubSubTake2,
@@ -18340,7 +18766,7 @@ __export(exports_Stream, {
18340
18766
  flattenIterable: () => flattenIterable,
18341
18767
  flattenEffect: () => flattenEffect,
18342
18768
  flattenArray: () => flattenArray2,
18343
- flatten: () => flatten5,
18769
+ flatten: () => flatten6,
18344
18770
  flatMap: () => flatMap7,
18345
18771
  filterMapEffect: () => filterMapEffect3,
18346
18772
  filterMap: () => filterMap4,
@@ -18362,7 +18788,7 @@ __export(exports_Stream, {
18362
18788
  drop: () => drop,
18363
18789
  drainFork: () => drainFork,
18364
18790
  drain: () => drain3,
18365
- die: () => die5,
18791
+ die: () => die6,
18366
18792
  decodeText: () => decodeText,
18367
18793
  debounce: () => debounce,
18368
18794
  crossWith: () => crossWith,
@@ -18396,15 +18822,15 @@ __export(exports_Stream, {
18396
18822
  aggregateWithin: () => aggregateWithin,
18397
18823
  aggregate: () => aggregate,
18398
18824
  accumulate: () => accumulate,
18399
- TypeId: () => TypeId23,
18825
+ TypeId: () => TypeId22,
18400
18826
  Do: () => Do5,
18401
18827
  DefaultChunkSize: () => DefaultChunkSize2
18402
18828
  });
18403
18829
 
18404
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/MutableHashMap.js
18405
- var TypeId20 = "~effect/collections/MutableHashMap";
18830
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/MutableHashMap.js
18831
+ var TypeId19 = "~effect/collections/MutableHashMap";
18406
18832
  var MutableHashMapProto = {
18407
- [TypeId20]: TypeId20,
18833
+ [TypeId19]: TypeId19,
18408
18834
  [Symbol.iterator]() {
18409
18835
  return this.backing[Symbol.iterator]();
18410
18836
  },
@@ -18524,10 +18950,10 @@ var clear2 = (self) => {
18524
18950
  };
18525
18951
  var size = (self) => self.backing.size;
18526
18952
 
18527
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/RcMap.js
18528
- var TypeId21 = "~effect/RcMap";
18953
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/RcMap.js
18954
+ var TypeId20 = "~effect/RcMap";
18529
18955
  var makeUnsafe6 = (options) => ({
18530
- [TypeId21]: TypeId21,
18956
+ [TypeId20]: TypeId20,
18531
18957
  lookup: options.lookup,
18532
18958
  context: options.context,
18533
18959
  scope: options.scope,
@@ -18643,8 +19069,8 @@ var touch = /* @__PURE__ */ dual(2, (self, key) => clockWith2((clock) => {
18643
19069
  return void_5;
18644
19070
  }));
18645
19071
 
18646
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/internal/rcRef.js
18647
- var TypeId22 = "~effect/RcRef";
19072
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/internal/rcRef.js
19073
+ var TypeId21 = "~effect/RcRef";
18648
19074
  var stateEmpty = {
18649
19075
  _tag: "Empty"
18650
19076
  };
@@ -18657,7 +19083,7 @@ var variance2 = {
18657
19083
  };
18658
19084
 
18659
19085
  class RcRefImpl {
18660
- [TypeId22] = variance2;
19086
+ [TypeId21] = variance2;
18661
19087
  pipe() {
18662
19088
  return pipeArguments(this, arguments);
18663
19089
  }
@@ -18684,7 +19110,7 @@ var make14 = (options) => withFiber2((fiber3) => {
18684
19110
  return close2;
18685
19111
  }), ref);
18686
19112
  });
18687
- var getState = (self) => uninterruptibleMask2((restore) => {
19113
+ var getState = (self) => uninterruptibleMask2(function loop(restore) {
18688
19114
  switch (self.state._tag) {
18689
19115
  case "Closed": {
18690
19116
  return interrupt3;
@@ -18695,18 +19121,23 @@ var getState = (self) => uninterruptibleMask2((restore) => {
18695
19121
  }
18696
19122
  case "Empty": {
18697
19123
  const scope3 = makeUnsafe3();
18698
- return self.semaphore.withPermits(1)(restore(provideContext2(self.acquire, add(self.context, Scope, scope3))).pipe(map5((value) => {
18699
- const state = {
18700
- _tag: "Acquired",
18701
- value,
18702
- scope: scope3,
18703
- fiber: undefined,
18704
- refCount: 1,
18705
- invalidated: false
18706
- };
18707
- self.state = state;
18708
- return state;
18709
- })));
19124
+ return self.semaphore.withPermit(suspend3(() => {
19125
+ if (self.state._tag !== "Empty") {
19126
+ return loop(restore);
19127
+ }
19128
+ return restore(provideContext2(self.acquire, add(self.context, Scope, scope3))).pipe(map5((value) => {
19129
+ const state = {
19130
+ _tag: "Acquired",
19131
+ value,
19132
+ scope: scope3,
19133
+ fiber: undefined,
19134
+ refCount: 1,
19135
+ invalidated: false
19136
+ };
19137
+ self.state = state;
19138
+ return state;
19139
+ }), onExit2((exit3) => isFailure4(exit3) ? close(scope3, exit3) : void_5));
19140
+ }));
18710
19141
  }
18711
19142
  }
18712
19143
  });
@@ -18742,13 +19173,13 @@ var get5 = /* @__PURE__ */ fnUntraced2(function* (self_) {
18742
19173
  return state.value;
18743
19174
  });
18744
19175
 
18745
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/RcRef.js
19176
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/RcRef.js
18746
19177
  var make15 = make14;
18747
19178
  var get6 = get5;
18748
19179
 
18749
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Stream.js
18750
- var TypeId23 = "~effect/Stream";
18751
- var isStream = (u) => hasProperty(u, TypeId23);
19180
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Stream.js
19181
+ var TypeId22 = "~effect/Stream";
19182
+ var isStream = (u) => hasProperty(u, TypeId22);
18752
19183
  var DefaultChunkSize2 = DefaultChunkSize;
18753
19184
  var fromChannel3 = fromChannel;
18754
19185
  var fromEffect2 = (effect2) => fromChannel3(fromEffect(map5(effect2, of)));
@@ -18797,7 +19228,7 @@ var suspend5 = (stream) => fromChannel3(suspend4(() => stream().channel));
18797
19228
  var fail9 = (error) => fromChannel3(fail7(error));
18798
19229
  var failSync4 = (evaluate2) => fromChannel3(failSync3(evaluate2));
18799
19230
  var failCause7 = (cause) => fromChannel3(failCause6(cause));
18800
- var die5 = (defect) => fromChannel3(die4(defect));
19231
+ var die6 = (defect) => fromChannel3(die5(defect));
18801
19232
  var failCauseSync4 = (evaluate2) => fromChannel3(failCauseSync3(evaluate2));
18802
19233
  var fromIteratorSucceed = (iterator, maxChunkSize) => fromChannel3(fromIteratorArray(() => iterator, maxChunkSize));
18803
19234
  var fromIterable3 = (iterable, options) => Array.isArray(iterable) && options?.chunkSize === undefined ? fromArray2(iterable) : fromChannel3(fromIterableArray(iterable, options?.chunkSize));
@@ -18809,17 +19240,7 @@ var fromArrays = (...arrays) => fromChannel3(fromArray(filter3(arrays, isReadonl
18809
19240
  var fromQueue = (queue) => fromChannel3(fromQueueArray(queue));
18810
19241
  var fromPubSub = (pubsub) => fromChannel3(fromPubSubArray(pubsub));
18811
19242
  var fromPubSubTake2 = (pubsub) => fromChannel3(fromPubSubTake(pubsub));
18812
- var fromReadableStream = (options) => fromChannel3(fromTransform(fnUntraced2(function* (_, scope3) {
18813
- const reader = options.evaluate().getReader();
18814
- yield* addFinalizer2(scope3, options.releaseLockOnEnd ? sync3(() => reader.releaseLock()) : promise2(() => reader.cancel().catch(constVoid)));
18815
- return flatMap5(tryPromise2({
18816
- try: () => reader.read(),
18817
- catch: (reason) => options.onError(reason)
18818
- }), ({
18819
- done: done4,
18820
- value
18821
- }) => done4 ? done3() : succeed6(of(value)));
18822
- })));
19243
+ var fromReadableStream2 = (options) => fromChannel3(fromReadableStream(options));
18823
19244
  var fromAsyncIterable2 = (iterable, onError4) => fromChannel3(fromAsyncIterableArray(iterable, onError4));
18824
19245
  var fromSchedule = (schedule3) => fromPull2(map5(toStepWithSleep(schedule3), (step) => catchDone(map5(step(undefined), of), () => done3())));
18825
19246
  var fromSubscription = (pubsub) => fromChannel3(fromSubscriptionArray(pubsub));
@@ -18860,15 +19281,16 @@ var paginate = (s, f) => fromPull2(sync3(() => {
18860
19281
  }));
18861
19282
  var iterate = (value, next) => unfold(value, (a) => succeed6([a, next(a)]));
18862
19283
  var range2 = (min2, max2, chunkSize = DefaultChunkSize) => min2 > max2 ? empty6 : fromPull2(sync3(() => {
19284
+ const size2 = Math.max(1, chunkSize);
18863
19285
  let start = min2;
18864
19286
  let done4 = false;
18865
19287
  return suspend3(() => {
18866
19288
  if (done4)
18867
19289
  return done3();
18868
19290
  const remaining = max2 - start + 1;
18869
- if (remaining > chunkSize) {
18870
- const chunk2 = range(start, start + chunkSize - 1);
18871
- start += chunkSize;
19291
+ if (remaining > size2) {
19292
+ const chunk2 = range(start, start + size2 - 1);
19293
+ start += size2;
18872
19294
  return succeed6(chunk2);
18873
19295
  }
18874
19296
  const chunk = range(start, start + remaining - 1);
@@ -18939,7 +19361,7 @@ var tapSink = /* @__PURE__ */ dual(2, (self, sink) => transformPullBracket(self,
18939
19361
  })));
18940
19362
  var flatMap7 = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, f, options) => self.channel.pipe(flattenArray, flatMap6((a) => f(a).channel, options), fromChannel3));
18941
19363
  var switchMap2 = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, f, options) => self.channel.pipe(flattenArray, switchMap((a) => f(a).channel, options), fromChannel3));
18942
- var flatten5 = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, options) => flatMap7(self, identity, options));
19364
+ var flatten6 = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, options) => flatMap7(self, identity, options));
18943
19365
  var flattenArray2 = (self) => fromChannel3(flattenArray(self.channel));
18944
19366
  var drain3 = (self) => fromChannel3(drain(self.channel));
18945
19367
  var drainFork = /* @__PURE__ */ dual(2, (self, that) => mergeEffect2(self, runDrain2(that)));
@@ -18981,7 +19403,7 @@ var timeoutOrElse3 = /* @__PURE__ */ dual(2, (self, options) => {
18981
19403
  const remaining = deadline - clock.currentTimeMillisUnsafe();
18982
19404
  if (remaining > 0)
18983
19405
  continue;
18984
- return yield* die3(timeoutSymbol);
19406
+ return yield* die4(timeoutSymbol);
18985
19407
  }
18986
19408
  })), {
18987
19409
  haltStrategy: "left"
@@ -19010,14 +19432,14 @@ var repeatElements = /* @__PURE__ */ dual(2, (self, schedule4) => fromChannel3(f
19010
19432
  var forever6 = (self) => fromChannel3(forever5(self.channel));
19011
19433
  var flattenIterable = (self) => flatMap7(self, fromIterable3);
19012
19434
  var flattenTake2 = (self) => self.channel.pipe(flattenArray, flattenTake, fromChannel3);
19013
- var concat = /* @__PURE__ */ dual(2, (self, that) => flatten5(fromArray2([self, that])));
19435
+ var concat = /* @__PURE__ */ dual(2, (self, that) => flatten6(fromArray2([self, that])));
19014
19436
  var prepend2 = /* @__PURE__ */ dual(2, (self, values) => concat(fromIterable3(values), self));
19015
19437
  var merge5 = /* @__PURE__ */ dual((args2) => isStream(args2[0]) && isStream(args2[1]), (self, that, options) => fromChannel3(merge4(toChannel2(self), toChannel2(that), options)));
19016
19438
  var mergeEffect2 = /* @__PURE__ */ dual(2, (self, effect2) => self.channel.pipe(mergeEffect(effect2), fromChannel3));
19017
19439
  var mergeResult = /* @__PURE__ */ dual(2, (self, that) => merge5(map7(self, succeed2), map7(that, fail2)));
19018
19440
  var mergeLeft = /* @__PURE__ */ dual(2, (left, right) => mergeEffect2(left, runDrain2(right)));
19019
19441
  var mergeRight = /* @__PURE__ */ dual(2, (left, right) => mergeEffect2(right, runDrain2(left)));
19020
- var mergeAll4 = /* @__PURE__ */ dual(2, (streams, options) => flatten5(fromIterable3(streams), options));
19442
+ var mergeAll4 = /* @__PURE__ */ dual(2, (streams, options) => flatten6(fromIterable3(streams), options));
19021
19443
  var cross = /* @__PURE__ */ dual(2, (left, right) => crossWith(left, right, (l, r) => [l, r]));
19022
19444
  var crossWith = /* @__PURE__ */ dual(3, (left, right, f) => flatMap7(left, (l) => map7(right, (r) => f(l, r))));
19023
19445
  var zipWith4 = /* @__PURE__ */ dual(3, (left, right, f) => zipWithArray(left, right, zipArrays(f)));
@@ -19262,7 +19684,7 @@ var catchTags3 = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, case
19262
19684
  });
19263
19685
  var catchReason4 = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, errorTag, reasonTag, f, orElse3) => fromChannel3(catchReason3(toChannel2(self), errorTag, reasonTag, (reason, error) => f(reason, error).channel, orElse3 && ((reason, error) => orElse3(reason, error).channel))));
19264
19686
  var catchReasons4 = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, errorTag, cases, orElse3) => {
19265
- const handlers = {};
19687
+ const handlers = Object.create(null);
19266
19688
  for (const key of Object.keys(cases)) {
19267
19689
  const handler = cases[key];
19268
19690
  handlers[key] = (reason, error) => handler(reason, error).channel;
@@ -19279,6 +19701,14 @@ var orDie5 = (self) => fromChannel3(orDie4(self.channel));
19279
19701
  var ignore4 = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, options) => fromChannel3(ignore3(self.channel, options)));
19280
19702
  var ignoreCause4 = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, options) => fromChannel3(ignoreCause3(self.channel, options)));
19281
19703
  var retry4 = /* @__PURE__ */ dual(2, (self, policy) => fromChannel3(retry3(self.channel, policy)));
19704
+ var retryWithoutReset = (self, schedule4) => unwrap4(map5(toStepWithMetadata(schedule4), (step) => {
19705
+ let meta = CurrentMetadata2.defaultValue();
19706
+ const loop = () => catch_5(provideServiceEffect4(self, CurrentMetadata2, sync3(() => meta)), (error) => unwrap4(catchDone(map5(step(error), (meta_) => {
19707
+ meta = meta_;
19708
+ return unwrap4(as3(yieldNow2, loop()));
19709
+ }), () => succeed6(fail9(error)))));
19710
+ return loop();
19711
+ }));
19282
19712
  var withExecutionPlan3 = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, policy, options) => suspend5(() => {
19283
19713
  const preventFallbackOnPartialStream = options?.preventFallbackOnPartialStream ?? false;
19284
19714
  let i = 0;
@@ -19293,13 +19723,24 @@ var withExecutionPlan3 = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (se
19293
19723
  };
19294
19724
  return meta;
19295
19725
  }));
19726
+ const emitter = options?.onEvent === undefined ? undefined : makeEventEmitter(options.onEvent, () => meta);
19727
+ let attemptState;
19728
+ const instrument = emitter === undefined ? identity : (attempt) => onExit4(onStart2(attempt, map5(emitter.begin, (state) => {
19729
+ attemptState = state;
19730
+ })), (exit3) => suspend3(() => {
19731
+ if (attemptState === undefined)
19732
+ return void_5;
19733
+ const state = attemptState;
19734
+ attemptState = undefined;
19735
+ return emitter.end(state, exit3);
19736
+ }));
19296
19737
  let lastError = none2();
19297
19738
  const loop = suspend5(() => {
19298
19739
  const step = policy.steps[i];
19299
19740
  if (!step) {
19300
19741
  return fail9(getOrThrow(lastError));
19301
19742
  }
19302
- let nextStream = provideMeta(provide6(self, step.provide));
19743
+ let nextStream = provideMeta(instrument(provide6(self, step.provide)));
19303
19744
  let receivedElements = false;
19304
19745
  if (isSome2(lastError)) {
19305
19746
  const error = lastError.value;
@@ -19311,10 +19752,10 @@ var withExecutionPlan3 = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (se
19311
19752
  attempted = true;
19312
19753
  return fail9(error);
19313
19754
  });
19314
- nextStream = retry4(nextStream, scheduleFromStep(step, false));
19755
+ nextStream = retryWithoutReset(nextStream, scheduleFromStep(step, false));
19315
19756
  } else {
19316
19757
  const schedule4 = scheduleFromStep(step, true);
19317
- nextStream = schedule4 ? retry4(nextStream, schedule4) : nextStream;
19758
+ nextStream = schedule4 ? retryWithoutReset(nextStream, schedule4) : nextStream;
19318
19759
  }
19319
19760
  return catch_5(preventFallbackOnPartialStream ? onFirst2(nextStream, (_) => {
19320
19761
  receivedElements = true;
@@ -19331,7 +19772,21 @@ var withExecutionPlan3 = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (se
19331
19772
  return loop;
19332
19773
  }));
19333
19774
  var take5 = /* @__PURE__ */ dual(2, (self, n) => n < 1 ? empty6 : takeUntil(self, (_, i) => i === n - 1));
19334
- var takeRight = /* @__PURE__ */ dual(2, (self, n) => mapAccumArray(self, make9, (list, arr) => {
19775
+ var limitBytes = /* @__PURE__ */ dual(3, (self, bytes, onLimitReached) => suspend5(() => {
19776
+ const limit = BigInt(bytes);
19777
+ let size2 = BigInt(0);
19778
+ let limitReached = false;
19779
+ return concat(takeWhile(self, (chunk) => {
19780
+ const nextSize = size2 + BigInt(chunk.length);
19781
+ if (nextSize > limit) {
19782
+ limitReached = true;
19783
+ return false;
19784
+ }
19785
+ size2 = nextSize;
19786
+ return true;
19787
+ }), suspend5(() => limitReached ? onLimitReached() : empty6));
19788
+ }));
19789
+ var takeRight = /* @__PURE__ */ dual(2, (self, n) => mapAccumArray(self, make10, (list, arr) => {
19335
19790
  appendAll2(list, arr);
19336
19791
  if (list.length > n) {
19337
19792
  takeNVoid(list, list.length - n);
@@ -19466,7 +19921,7 @@ var dropRight = /* @__PURE__ */ dual(2, (self, n) => {
19466
19921
  if (n <= 0)
19467
19922
  return self;
19468
19923
  return transformPull2(self, (pull, _scope) => sync3(() => {
19469
- const list = make9();
19924
+ const list = make10();
19470
19925
  const emit = flatMap5(pull, (arr) => {
19471
19926
  appendAllUnsafe(list, arr);
19472
19927
  const toTake = list.length - n;
@@ -19523,11 +19978,17 @@ var rechunk = /* @__PURE__ */ dual(2, (self, target) => {
19523
19978
  var sliding2 = /* @__PURE__ */ dual(2, (self, chunkSize) => slidingSize(self, chunkSize, 1));
19524
19979
  var slidingSize = /* @__PURE__ */ dual(3, (self, chunkSize, stepSize) => transformPull2(self, (upstream, _scope) => sync3(() => {
19525
19980
  let cause = null;
19526
- const list = make9();
19981
+ const list = make10();
19527
19982
  let emitted = false;
19983
+ let skip = 0;
19528
19984
  const pull = matchCauseEffect2(upstream, {
19529
19985
  onSuccess(arr) {
19530
19986
  appendAllUnsafe(list, arr);
19987
+ if (skip > 0) {
19988
+ const length = list.length;
19989
+ takeNVoid(list, skip);
19990
+ skip = Math.max(0, skip - length);
19991
+ }
19531
19992
  if (list.length < chunkSize)
19532
19993
  return pull;
19533
19994
  emitted = true;
@@ -19537,10 +19998,12 @@ var slidingSize = /* @__PURE__ */ dual(3, (self, chunkSize, stepSize) => transfo
19537
19998
  chunks2.push(takeN(list, chunkSize));
19538
19999
  } else {
19539
20000
  chunks2.push(toArrayN(list, chunkSize));
19540
- if (chunkSize === 1) {
20001
+ if (chunkSize === 1 && stepSize <= 0) {
19541
20002
  take(list);
19542
20003
  } else {
20004
+ const length = list.length;
19543
20005
  takeNVoid(list, stepSize);
20006
+ skip = Math.max(0, stepSize - length);
19544
20007
  }
19545
20008
  }
19546
20009
  }
@@ -19608,7 +20071,7 @@ var mapAccumEffect = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self,
19608
20071
  return isReadonlyArrayNonEmpty(arr) ? of(arr) : emptyArr;
19609
20072
  }
19610
20073
  } : undefined), fromChannel3));
19611
- var mapAccumArrayEffect = /* @__PURE__ */ dual((args2) => isStream(args2), (self, initial, f, options) => self.channel.pipe(mapAccum(initial, (state, a) => map5(f(state, a), ([state2, values]) => [state2, isReadonlyArrayNonEmpty(values) ? of(values) : emptyArr]), options?.onHalt ? {
20074
+ var mapAccumArrayEffect = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, initial, f, options) => self.channel.pipe(mapAccum(initial, (state, a) => map5(f(state, a), ([state2, values]) => [state2, isReadonlyArrayNonEmpty(values) ? of(values) : emptyArr]), options?.onHalt ? {
19612
20075
  onHalt(state) {
19613
20076
  const arr = options.onHalt(state);
19614
20077
  return isReadonlyArrayNonEmpty(arr) ? of(arr) : emptyArr;
@@ -19874,9 +20337,10 @@ var aggregateWithin = /* @__PURE__ */ dual(3, (self, sink, schedule4) => fromCha
19874
20337
  let leftover;
19875
20338
  let sinkHasInput = false;
19876
20339
  const step = yield* toStepWithSleep(schedule4);
19877
- const stepToBuffer = suspend3(function loop() {
19878
- return step(lastOutput).pipe(flatMap5(() => !sinkHasInput ? loop() : offer(buffer3, scheduleStep)), flatMap5(() => never2), catchDone(() => done3()));
20340
+ const stepLoop = suspend3(function loop() {
20341
+ return flatMap5(step(lastOutput), () => !sinkHasInput ? loop() : offer(buffer3, scheduleStep));
19879
20342
  });
20343
+ const stepToBuffer = stepLoop.pipe(flatMap5(() => never2), catchDone(() => done3()));
19880
20344
  const pullFromBuffer = take3(buffer3).pipe(flatMap5((arr) => {
19881
20345
  if (arr === scheduleStep) {
19882
20346
  return done3();
@@ -20134,28 +20598,8 @@ var runForEachArray = /* @__PURE__ */ dual(2, (self, f) => runForEach(self.chann
20134
20598
  var runDrain2 = (self) => runDrain(self.channel);
20135
20599
  var toPull3 = (self) => toPull2(self.channel);
20136
20600
  var mkString = (self) => runFold(self.channel, () => "", (acc, chunk) => acc + chunk.join(""));
20137
- var mkUint8Array = (self) => map5(runFold(self.channel, () => ({
20138
- bytes: 0,
20139
- arrays: []
20140
- }), (acc, chunk) => {
20141
- for (let i = 0;i < chunk.length; i++) {
20142
- acc.bytes += chunk[i].length;
20143
- acc.arrays.push(chunk[i]);
20144
- }
20145
- return acc;
20146
- }), ({
20147
- arrays,
20148
- bytes
20149
- }) => {
20150
- const result4 = new Uint8Array(bytes);
20151
- let offset = 0;
20152
- for (let i = 0;i < arrays.length; i++) {
20153
- const array2 = arrays[i];
20154
- result4.set(array2, offset);
20155
- offset += array2.length;
20156
- }
20157
- return result4;
20158
- });
20601
+ var mkArrayBuffer = (self) => map5(mkUint8Array(self.channel), (bytes) => bytes.buffer);
20602
+ var mkUint8Array2 = (self) => mkUint8Array(self.channel);
20159
20603
  var toReadableStreamWith = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, context3, options) => {
20160
20604
  let currentResolve = undefined;
20161
20605
  let fiber3 = undefined;
@@ -20196,36 +20640,66 @@ var toReadableStreamEffect = /* @__PURE__ */ dual((args2) => isStream(args2[0]),
20196
20640
  var toAsyncIterableWith = /* @__PURE__ */ dual(2, (self, context3) => ({
20197
20641
  [Symbol.asyncIterator]() {
20198
20642
  const runPromise3 = runPromiseWith2(context3);
20199
- const runPromiseExit3 = runPromiseExitWith2(context3);
20643
+ const runFork3 = runForkWith2(context3);
20200
20644
  const scope3 = makeUnsafe3();
20201
20645
  let pull;
20202
20646
  let currentIter;
20647
+ let currentFiber;
20648
+ let closePromise;
20649
+ const close2 = (exit3) => {
20650
+ if (closePromise)
20651
+ return closePromise;
20652
+ const fiber3 = currentFiber;
20653
+ closePromise = runPromise3(as3(andThen4(fiber3 ? interrupt4(fiber3) : void_5, close(scope3, exit3)), {
20654
+ done: true,
20655
+ value: undefined
20656
+ }));
20657
+ return closePromise;
20658
+ };
20659
+ const closeAndReportError = async (exit3) => {
20660
+ try {
20661
+ await close2(exit3);
20662
+ } catch (error) {
20663
+ await runPromise3(logError("Suppressed error while closing Stream async iterator", error));
20664
+ }
20665
+ };
20203
20666
  return {
20204
20667
  async next() {
20668
+ if (closePromise)
20669
+ return closePromise;
20205
20670
  if (currentIter) {
20206
20671
  const next = currentIter.next();
20207
20672
  if (!next.done)
20208
20673
  return next;
20209
20674
  currentIter = undefined;
20210
20675
  }
20211
- pull ??= await runPromise3(toPullScoped(self.channel, scope3));
20212
- const exit3 = await runPromiseExit3(pull);
20676
+ const fiber3 = runFork3(pull ?? flatMap5(toPullScoped(self.channel, scope3), (nextPull) => {
20677
+ pull = nextPull;
20678
+ return nextPull;
20679
+ }));
20680
+ currentFiber = fiber3;
20681
+ const exit3 = await runPromise3(await_(fiber3));
20682
+ if (currentFiber === fiber3) {
20683
+ currentFiber = undefined;
20684
+ }
20213
20685
  if (isSuccess4(exit3)) {
20214
20686
  currentIter = exit3.value[Symbol.iterator]();
20215
20687
  return currentIter.next();
20216
20688
  } else if (isDoneCause(exit3.cause)) {
20217
- return {
20218
- done: true,
20219
- value: undefined
20220
- };
20689
+ return close2(void_4);
20690
+ }
20691
+ if (closePromise && hasInterruptsOnly2(exit3.cause)) {
20692
+ return closePromise;
20221
20693
  }
20694
+ await closeAndReportError(exit3);
20222
20695
  throw squash(exit3.cause);
20223
20696
  },
20224
- return(_) {
20225
- return runPromise3(as3(close(scope3, void_4), {
20226
- done: true,
20227
- value: undefined
20228
- }));
20697
+ return() {
20698
+ return close2(void_4);
20699
+ },
20700
+ async throw(error) {
20701
+ await closeAndReportError(die2(error));
20702
+ throw error;
20229
20703
  }
20230
20704
  };
20231
20705
  }
@@ -20238,8 +20712,8 @@ var toPubSubTake2 = /* @__PURE__ */ dual(2, (self, options) => toPubSubTake(self
20238
20712
  var toQueue = /* @__PURE__ */ dual(2, (self, options) => toQueueArray(self.channel, options));
20239
20713
  var runIntoQueue = /* @__PURE__ */ dual(2, (self, queue) => runIntoQueueArray(self.channel, queue));
20240
20714
 
20241
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/FileSystem.js
20242
- var TypeId24 = "~effect/platform/FileSystem";
20715
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/FileSystem.js
20716
+ var TypeId23 = "~effect/platform/FileSystem";
20243
20717
  var Size = (bytes) => typeof bytes === "bigint" ? bytes : BigInt(bytes);
20244
20718
  var KiB = (n) => Size(n * 1024);
20245
20719
  var MiB = (n) => Size(n * 1024 * 1024);
@@ -20251,7 +20725,7 @@ var PiB = (n) => Size(BigInt(n) * bigintPiB);
20251
20725
  var FileSystem = /* @__PURE__ */ Service("effect/platform/FileSystem");
20252
20726
  var make17 = (impl) => FileSystem.of({
20253
20727
  ...impl,
20254
- [TypeId24]: TypeId24,
20728
+ [TypeId23]: TypeId23,
20255
20729
  exists: (path) => pipe(impl.access(path), as3(true), catchTag3("PlatformError", (e) => e.reason._tag === "NotFound" ? succeed6(false) : fail6(e))),
20256
20730
  readFileString: (path, encoding) => flatMap5(impl.readFile(path), (_) => try_3({
20257
20731
  try: () => new TextDecoder(encoding).decode(_),
@@ -20300,7 +20774,7 @@ var make17 = (impl) => FileSystem.of({
20300
20774
  })
20301
20775
  }), (_) => impl.writeFile(path, _, options))
20302
20776
  });
20303
- var notFound = (method, path) => systemError({
20777
+ var notFound2 = (method, path) => systemError({
20304
20778
  module: "FileSystem",
20305
20779
  method,
20306
20780
  _tag: "NotFound",
@@ -20308,115 +20782,114 @@ var notFound = (method, path) => systemError({
20308
20782
  pathOrDescriptor: path
20309
20783
  });
20310
20784
  var makeNoop = (fileSystem) => FileSystem.of({
20311
- [TypeId24]: TypeId24,
20785
+ [TypeId23]: TypeId23,
20312
20786
  access(path) {
20313
- return fail6(notFound("access", path));
20787
+ return fail6(notFound2("access", path));
20314
20788
  },
20315
20789
  chmod(path) {
20316
- return fail6(notFound("chmod", path));
20790
+ return fail6(notFound2("chmod", path));
20317
20791
  },
20318
20792
  chown(path) {
20319
- return fail6(notFound("chown", path));
20793
+ return fail6(notFound2("chown", path));
20320
20794
  },
20321
20795
  copy(path) {
20322
- return fail6(notFound("copy", path));
20796
+ return fail6(notFound2("copy", path));
20323
20797
  },
20324
20798
  copyFile(path) {
20325
- return fail6(notFound("copyFile", path));
20799
+ return fail6(notFound2("copyFile", path));
20326
20800
  },
20327
20801
  glob(pattern) {
20328
- return fail6(notFound("glob", pattern));
20802
+ return fail6(notFound2("glob", pattern));
20329
20803
  },
20330
20804
  exists() {
20331
20805
  return succeed6(false);
20332
20806
  },
20333
20807
  link(path) {
20334
- return fail6(notFound("link", path));
20808
+ return fail6(notFound2("link", path));
20335
20809
  },
20336
20810
  makeDirectory() {
20337
- return die3("not implemented");
20811
+ return die4("not implemented");
20338
20812
  },
20339
20813
  makeTempDirectory() {
20340
- return die3("not implemented");
20814
+ return die4("not implemented");
20341
20815
  },
20342
20816
  makeTempDirectoryScoped() {
20343
- return die3("not implemented");
20817
+ return die4("not implemented");
20344
20818
  },
20345
20819
  makeTempFile() {
20346
- return die3("not implemented");
20820
+ return die4("not implemented");
20347
20821
  },
20348
20822
  makeTempFileScoped() {
20349
- return die3("not implemented");
20823
+ return die4("not implemented");
20350
20824
  },
20351
20825
  open(path) {
20352
- return fail6(notFound("open", path));
20826
+ return fail6(notFound2("open", path));
20353
20827
  },
20354
20828
  readDirectory(path) {
20355
- return fail6(notFound("readDirectory", path));
20829
+ return fail6(notFound2("readDirectory", path));
20356
20830
  },
20357
20831
  readFile(path) {
20358
- return fail6(notFound("readFile", path));
20832
+ return fail6(notFound2("readFile", path));
20359
20833
  },
20360
20834
  readFileString(path) {
20361
- return fail6(notFound("readFileString", path));
20835
+ return fail6(notFound2("readFileString", path));
20362
20836
  },
20363
20837
  readLink(path) {
20364
- return fail6(notFound("readLink", path));
20838
+ return fail6(notFound2("readLink", path));
20365
20839
  },
20366
20840
  realPath(path) {
20367
- return fail6(notFound("realPath", path));
20841
+ return fail6(notFound2("realPath", path));
20368
20842
  },
20369
20843
  remove() {
20370
20844
  return void_5;
20371
20845
  },
20372
20846
  rename(oldPath) {
20373
- return fail6(notFound("rename", oldPath));
20847
+ return fail6(notFound2("rename", oldPath));
20374
20848
  },
20375
20849
  sink(path) {
20376
- return fail8(notFound("sink", path));
20850
+ return fail8(notFound2("sink", path));
20377
20851
  },
20378
20852
  stat(path) {
20379
- return fail6(notFound("stat", path));
20853
+ return fail6(notFound2("stat", path));
20380
20854
  },
20381
20855
  stream(path) {
20382
- return fail9(notFound("stream", path));
20856
+ return fail9(notFound2("stream", path));
20383
20857
  },
20384
20858
  symlink(fromPath) {
20385
- return fail6(notFound("symlink", fromPath));
20859
+ return fail6(notFound2("symlink", fromPath));
20386
20860
  },
20387
20861
  truncate(path) {
20388
- return fail6(notFound("truncate", path));
20862
+ return fail6(notFound2("truncate", path));
20389
20863
  },
20390
20864
  utimes(path) {
20391
- return fail6(notFound("utimes", path));
20865
+ return fail6(notFound2("utimes", path));
20392
20866
  },
20393
20867
  watch(path) {
20394
- return fail9(notFound("watch", path));
20868
+ return fail9(notFound2("watch", path));
20395
20869
  },
20396
20870
  writeFile(path) {
20397
- return fail6(notFound("writeFile", path));
20871
+ return fail6(notFound2("writeFile", path));
20398
20872
  },
20399
20873
  writeFileString(path) {
20400
- return fail6(notFound("writeFileString", path));
20874
+ return fail6(notFound2("writeFileString", path));
20401
20875
  },
20402
20876
  ...fileSystem
20403
20877
  });
20404
20878
  var layerNoop = (fileSystem) => succeed5(FileSystem)(makeNoop(fileSystem));
20405
20879
  var FileTypeId = "~effect/platform/FileSystem/File";
20406
20880
  var isFile = (u) => hasProperty(u, FileTypeId);
20407
- var FileDescriptor = /* @__PURE__ */ nominal();
20408
20881
 
20409
20882
  class WatchBackend extends (/* @__PURE__ */ Service()("effect/platform/FileSystem/WatchBackend")) {
20410
20883
  }
20411
20884
 
20412
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Path.js
20885
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Path.js
20413
20886
  var exports_Path = {};
20414
20887
  __export(exports_Path, {
20415
20888
  layer: () => layer,
20416
- TypeId: () => TypeId25,
20889
+ TypeId: () => TypeId24,
20417
20890
  Path: () => Path
20418
20891
  });
20419
- var TypeId25 = "~effect/platform/Path";
20892
+ var TypeId24 = "~effect/platform/Path";
20420
20893
  var Path = /* @__PURE__ */ Service("effect/Path");
20421
20894
  function normalizeStringPosix(path, allowAboveRoot) {
20422
20895
  let res = "";
@@ -20593,7 +21066,7 @@ function encodePathChars(filepath) {
20593
21066
  return filepath;
20594
21067
  }
20595
21068
  var posixImpl = /* @__PURE__ */ Path.of({
20596
- [TypeId25]: TypeId25,
21069
+ [TypeId24]: TypeId24,
20597
21070
  resolve,
20598
21071
  normalize(path) {
20599
21072
  if (path.length === 0)
@@ -20900,7 +21373,7 @@ var posixImpl = /* @__PURE__ */ Path.of({
20900
21373
  });
20901
21374
  var layer = /* @__PURE__ */ succeed5(Path)(posixImpl);
20902
21375
 
20903
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/unstable/process/ChildProcess.js
21376
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/unstable/process/ChildProcess.js
20904
21377
  var exports_ChildProcess = {};
20905
21378
  __export(exports_ChildProcess, {
20906
21379
  setEnv: () => setEnv,
@@ -20915,7 +21388,7 @@ __export(exports_ChildProcess, {
20915
21388
  fdName: () => fdName
20916
21389
  });
20917
21390
 
20918
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/unstable/process/ChildProcessSpawner.js
21391
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/unstable/process/ChildProcessSpawner.js
20919
21392
  var exports_ChildProcessSpawner = {};
20920
21393
  __export(exports_ChildProcessSpawner, {
20921
21394
  makeHandle: () => makeHandle,
@@ -20924,6 +21397,17 @@ __export(exports_ChildProcessSpawner, {
20924
21397
  ExitCode: () => ExitCode,
20925
21398
  ChildProcessSpawner: () => ChildProcessSpawner
20926
21399
  });
21400
+
21401
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Brand.js
21402
+ function nominal() {
21403
+ return Object.assign((input) => input, {
21404
+ option: (input) => some2(input),
21405
+ result: (input) => succeed2(input),
21406
+ is: (_) => true
21407
+ });
21408
+ }
21409
+
21410
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/unstable/process/ChildProcessSpawner.js
20927
21411
  var ExitCode = /* @__PURE__ */ nominal();
20928
21412
  var ProcessId = /* @__PURE__ */ nominal();
20929
21413
  var HandleTypeId = "~effect/ChildProcessSpawner/ChildProcessHandle";
@@ -20937,7 +21421,9 @@ var HandleProto = {
20937
21421
  };
20938
21422
  }
20939
21423
  };
20940
- var makeHandle = (params) => Object.assign(Object.create(HandleProto), params);
21424
+ var makeHandle = (params) => Object.setPrototypeOf({
21425
+ ...params
21426
+ }, HandleProto);
20941
21427
  var make18 = (spawn) => {
20942
21428
  const streamString = (command, options) => spawn(command).pipe(map5((handle) => decodeText(options?.includeStderr === true ? handle.all : handle.stdout)), unwrap4);
20943
21429
  const streamLines = (command, options) => splitLines2(streamString(command, options));
@@ -20954,8 +21440,8 @@ var make18 = (spawn) => {
20954
21440
  class ChildProcessSpawner extends (/* @__PURE__ */ Service()("effect/process/ChildProcessSpawner")) {
20955
21441
  }
20956
21442
 
20957
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/unstable/process/ChildProcess.js
20958
- var TypeId26 = "~effect/unstable/process/ChildProcess";
21443
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/unstable/process/ChildProcess.js
21444
+ var TypeId25 = "~effect/unstable/process/ChildProcess";
20959
21445
  var Proto3 = {
20960
21446
  .../* @__PURE__ */ Prototype2({
20961
21447
  label: "Command",
@@ -20963,9 +21449,9 @@ var Proto3 = {
20963
21449
  return getUnsafe2(fiber3.context, ChildProcessSpawner).spawn(this);
20964
21450
  }
20965
21451
  }),
20966
- [TypeId26]: TypeId26
21452
+ [TypeId25]: TypeId25
20967
21453
  };
20968
- var isCommand = (u) => hasProperty(u, TypeId26);
21454
+ var isCommand = (u) => hasProperty(u, TypeId25);
20969
21455
  var isStandardCommand = (command) => command._tag === "StandardCommand";
20970
21456
  var isPipedCommand = (command) => command._tag === "PipedCommand";
20971
21457
  var makeStandardCommand = (command, args2, options) => Object.assign(Object.create(Proto3), {
@@ -21067,10 +21553,10 @@ var setEnv = /* @__PURE__ */ dual(2, (self, env) => {
21067
21553
  });
21068
21554
  var isTemplateString = (u) => Array.isArray(u) && ("raw" in u) && Array.isArray(u.raw);
21069
21555
  var parseFdName = (name) => {
21070
- const match6 = /^fd(\d+)$/.exec(name);
21071
- if (match6 === null)
21556
+ const match7 = /^fd(\d+)$/.exec(name);
21557
+ if (match7 === null)
21072
21558
  return;
21073
- const fd = parseInt(match6[1], 10);
21559
+ const fd = parseInt(match7[1], 10);
21074
21560
  return fd >= 3 ? fd : undefined;
21075
21561
  };
21076
21562
  var fdName = (fd) => `fd${fd}`;
@@ -21155,11 +21641,22 @@ var splitByWhitespaces = (template, rawTemplate) => {
21155
21641
  };
21156
21642
  var concatTokens = (prevTokens, nextTokens, isSeparated) => isSeparated || prevTokens.length === 0 || nextTokens.length === 0 ? [...prevTokens, ...nextTokens] : [...prevTokens.slice(0, -1), `${prevTokens.at(-1)}${nextTokens.at(0)}`, ...nextTokens.slice(1)];
21157
21643
 
21158
- // ../../node_modules/.bun/@effect+platform-node-shared@4.0.0-beta.98+74997d64abff4185/node_modules/@effect/platform-node-shared/dist/NodeChildProcessSpawner.js
21644
+ // ../../node_modules/.bun/@effect+platform-node-shared@4.0.0-beta.107+572e5a9a9ccc3c07/node_modules/@effect/platform-node-shared/dist/NodeChildProcessSpawner.js
21159
21645
  import * as NodeChildProcess from "node:child_process";
21160
21646
  import { PassThrough } from "node:stream";
21161
21647
 
21162
- // ../../node_modules/.bun/@effect+platform-node-shared@4.0.0-beta.98+74997d64abff4185/node_modules/@effect/platform-node-shared/dist/internal/utils.js
21648
+ // ../../node_modules/.bun/@effect+platform-node-shared@4.0.0-beta.107+572e5a9a9ccc3c07/node_modules/@effect/platform-node-shared/dist/internal/nodeChildProcessSpawner.js
21649
+ var buildSpawnOptions = (options, base, platform) => {
21650
+ const detached = options.detached ?? platform !== "win32";
21651
+ return {
21652
+ ...base,
21653
+ detached,
21654
+ shell: options.shell,
21655
+ windowsHide: options.windowsHide ?? !detached
21656
+ };
21657
+ };
21658
+
21659
+ // ../../node_modules/.bun/@effect+platform-node-shared@4.0.0-beta.107+572e5a9a9ccc3c07/node_modules/@effect/platform-node-shared/dist/internal/utils.js
21163
21660
  var handleErrnoException = (module, method) => (err, [path]) => {
21164
21661
  let reason = "Unknown";
21165
21662
  switch (err.code) {
@@ -21195,7 +21692,7 @@ var handleErrnoException = (module, method) => (err, [path]) => {
21195
21692
  });
21196
21693
  };
21197
21694
 
21198
- // ../../node_modules/.bun/@effect+platform-node-shared@4.0.0-beta.98+74997d64abff4185/node_modules/@effect/platform-node-shared/dist/NodeSink.js
21695
+ // ../../node_modules/.bun/@effect+platform-node-shared@4.0.0-beta.107+572e5a9a9ccc3c07/node_modules/@effect/platform-node-shared/dist/NodeSink.js
21199
21696
  var fromWritable = (options) => fromChannel2(mapDone(fromWritableChannel(options), (_) => [_]));
21200
21697
  var fromWritableChannel = (options) => fromTransform((pull) => {
21201
21698
  const writable = options.evaluate();
@@ -21235,7 +21732,7 @@ var pullIntoWritable = (options) => options.pull.pipe(flatMap5((chunk) => {
21235
21732
  });
21236
21733
  }) : identity);
21237
21734
 
21238
- // ../../node_modules/.bun/@effect+platform-node-shared@4.0.0-beta.98+74997d64abff4185/node_modules/@effect/platform-node-shared/dist/NodeStream.js
21735
+ // ../../node_modules/.bun/@effect+platform-node-shared@4.0.0-beta.107+572e5a9a9ccc3c07/node_modules/@effect/platform-node-shared/dist/NodeStream.js
21239
21736
  var fromReadable = (options) => fromChannel3(fromReadableChannel(options));
21240
21737
  var fromReadableChannel = (options) => fromTransform((_, scope3) => readableToPullUnsafe({
21241
21738
  scope: scope3,
@@ -21247,7 +21744,7 @@ var fromReadableChannel = (options) => fromTransform((_, scope3) => readableToPu
21247
21744
  var readableToPullUnsafe = (options) => {
21248
21745
  const readable = options.readable;
21249
21746
  const closeOnDone = options.closeOnDone ?? true;
21250
- const exit3 = options.exit ?? make10(undefined);
21747
+ const exit3 = options.exit ?? make9(undefined);
21251
21748
  const latch = makeUnsafe4(false);
21252
21749
  function onReadable() {
21253
21750
  latch.openUnsafe();
@@ -21295,7 +21792,7 @@ var readableToPullUnsafe = (options) => {
21295
21792
  };
21296
21793
  var defaultOnError = (error) => new UnknownError2(error);
21297
21794
 
21298
- // ../../node_modules/.bun/@effect+platform-node-shared@4.0.0-beta.98+74997d64abff4185/node_modules/@effect/platform-node-shared/dist/NodeChildProcessSpawner.js
21795
+ // ../../node_modules/.bun/@effect+platform-node-shared@4.0.0-beta.107+572e5a9a9ccc3c07/node_modules/@effect/platform-node-shared/dist/NodeChildProcessSpawner.js
21299
21796
  var toError = (error) => error instanceof globalThis.Error ? error : new globalThis.Error(String(error));
21300
21797
  var toPlatformError = (method, error, command) => {
21301
21798
  const {
@@ -21307,6 +21804,9 @@ var toPlatformError = (method, error, command) => {
21307
21804
  }, "");
21308
21805
  return handleErrnoException("ChildProcess", method)(error, [commandStr]);
21309
21806
  };
21807
+ var taskkill = (childProcess, onExit5 = () => {}) => NodeChildProcess.execFile("taskkill", ["/pid", String(childProcess.pid), "/T", "/F"], {
21808
+ windowsHide: true
21809
+ }, onExit5);
21310
21810
  var make21 = /* @__PURE__ */ gen4(function* () {
21311
21811
  const fs = yield* FileSystem;
21312
21812
  const path = yield* Path;
@@ -21525,7 +22025,7 @@ var make21 = /* @__PURE__ */ gen4(function* () {
21525
22025
  const killProcessGroup = (command, childProcess, signal) => {
21526
22026
  if (globalThis.process.platform === "win32") {
21527
22027
  return callback2((resume) => {
21528
- NodeChildProcess.exec(`taskkill /pid ${childProcess.pid} /T /F`, (error) => {
22028
+ taskkill(childProcess, (error) => {
21529
22029
  if (error) {
21530
22030
  resume(fail6(toPlatformError("kill", toError(error), command)));
21531
22031
  } else {
@@ -21543,7 +22043,7 @@ var make21 = /* @__PURE__ */ gen4(function* () {
21543
22043
  };
21544
22044
  const killProcessGroupOnExit = (childProcess, signal) => {
21545
22045
  if (globalThis.process.platform === "win32") {
21546
- NodeChildProcess.exec(`taskkill /pid ${childProcess.pid} /T /F`, () => {});
22046
+ taskkill(childProcess);
21547
22047
  return;
21548
22048
  }
21549
22049
  try {
@@ -21594,13 +22094,11 @@ var make21 = /* @__PURE__ */ gen4(function* () {
21594
22094
  const cwd = yield* resolveWorkingDirectory(cmd.options);
21595
22095
  const env = resolveEnvironment(cmd.options);
21596
22096
  const stdio = buildStdioArray(stdinConfig, stdoutConfig, stderrConfig, resolvedAdditionalFds);
21597
- const [childProcess, exitSignal] = yield* acquireRelease2(spawn2(cmd, {
22097
+ const [childProcess, exitSignal] = yield* acquireRelease2(spawn2(cmd, buildSpawnOptions(cmd.options, {
21598
22098
  cwd,
21599
22099
  env,
21600
- stdio,
21601
- detached: cmd.options.detached ?? process.platform !== "win32",
21602
- shell: cmd.options.shell
21603
- }), fnUntraced2(function* ([childProcess2, exitSignal2]) {
22100
+ stdio
22101
+ }, process.platform)), fnUntraced2(function* ([childProcess2, exitSignal2]) {
21604
22102
  const exited = yield* isDone2(exitSignal2);
21605
22103
  const killWithTimeout = withTimeout(childProcess2, cmd, cmd.options);
21606
22104
  if (exited) {
@@ -21613,7 +22111,7 @@ var make21 = /* @__PURE__ */ gen4(function* () {
21613
22111
  if (!isReferenced) {
21614
22112
  return yield* void_5;
21615
22113
  }
21616
- return yield* killWithTimeout((command, childProcess3, signal) => catch_3(killProcessGroup(command, childProcess3, signal), () => killProcess(command, childProcess3, signal))).pipe(andThen4(_await(exitSignal2)), ignore2);
22114
+ return yield* killWithTimeout((command, childProcess3, signal) => killProcessGroup(command, childProcess3, signal).pipe(catch_3(() => killProcess(command, childProcess3, signal)), andThen4(_await(exitSignal2)))).pipe(ignore2);
21617
22115
  }));
21618
22116
  const pid = ProcessId(childProcess.pid);
21619
22117
  childProcess.on("exit", (code) => {
@@ -21654,7 +22152,7 @@ var make21 = /* @__PURE__ */ gen4(function* () {
21654
22152
  });
21655
22153
  const kill = (options) => {
21656
22154
  const killWithTimeout = withTimeout(childProcess, cmd, options);
21657
- return killWithTimeout((command, childProcess2, signal) => catch_3(killProcessGroup(command, childProcess2, signal), () => killProcess(command, childProcess2, signal))).pipe(andThen4(_await(exitSignal)), asVoid3);
22155
+ return killWithTimeout((command, childProcess2, signal) => killProcessGroup(command, childProcess2, signal).pipe(catch_3(() => killProcess(command, childProcess2, signal)), andThen4(_await(exitSignal)))).pipe(asVoid3);
21658
22156
  };
21659
22157
  return makeHandle({
21660
22158
  pid,
@@ -21718,6 +22216,9 @@ var make21 = /* @__PURE__ */ gen4(function* () {
21718
22216
  }
21719
22217
  }
21720
22218
  const handle = handles[handles.length - 1];
22219
+ const kill = (options) => forEach2([...handles].reverse(), (handle2) => ignore2(handle2.kill(options)), {
22220
+ discard: true
22221
+ });
21721
22222
  const unref = gen4(function* () {
21722
22223
  const rerefs = [];
21723
22224
  for (const handle2 of handles) {
@@ -21731,7 +22232,7 @@ var make21 = /* @__PURE__ */ gen4(function* () {
21731
22232
  pid: handle.pid,
21732
22233
  exitCode: handle.exitCode,
21733
22234
  isRunning: handle.isRunning,
21734
- kill: handle.kill,
22235
+ kill,
21735
22236
  stdin: handle.stdin,
21736
22237
  stdout: handle.stdout,
21737
22238
  stderr: handle.stderr,
@@ -21749,21 +22250,21 @@ var layer2 = /* @__PURE__ */ effect(ChildProcessSpawner, make21);
21749
22250
  var flattenCommand = (command) => {
21750
22251
  const commands = [];
21751
22252
  const pipeOptions = [];
21752
- const flatten6 = (cmd) => {
22253
+ const flatten7 = (cmd) => {
21753
22254
  switch (cmd._tag) {
21754
22255
  case "StandardCommand": {
21755
22256
  commands.push(cmd);
21756
22257
  break;
21757
22258
  }
21758
22259
  case "PipedCommand": {
21759
- flatten6(cmd.left);
22260
+ flatten7(cmd.left);
21760
22261
  pipeOptions.push(cmd.options);
21761
- flatten6(cmd.right);
22262
+ flatten7(cmd.right);
21762
22263
  break;
21763
22264
  }
21764
22265
  }
21765
22266
  };
21766
- flatten6(command);
22267
+ flatten7(command);
21767
22268
  if (commands.length === 0) {
21768
22269
  throw new Error("flattenCommand produced empty commands array");
21769
22270
  }
@@ -21774,13 +22275,13 @@ var flattenCommand = (command) => {
21774
22275
  pipeOptions
21775
22276
  };
21776
22277
  };
21777
- // ../../node_modules/.bun/@effect+platform-node@4.0.0-beta.98+421eccb9593286ba/node_modules/@effect/platform-node/dist/NodeFileSystem.js
22278
+ // ../../node_modules/.bun/@effect+platform-node@4.0.0-beta.107+a2edc8a872f58f99/node_modules/@effect/platform-node/dist/NodeFileSystem.js
21778
22279
  var exports_NodeFileSystem = {};
21779
22280
  __export(exports_NodeFileSystem, {
21780
22281
  layer: () => layer4
21781
22282
  });
21782
22283
 
21783
- // ../../node_modules/.bun/@effect+platform-node-shared@4.0.0-beta.98+74997d64abff4185/node_modules/@effect/platform-node-shared/dist/NodeFileSystem.js
22284
+ // ../../node_modules/.bun/@effect+platform-node-shared@4.0.0-beta.107+572e5a9a9ccc3c07/node_modules/@effect/platform-node-shared/dist/NodeFileSystem.js
21784
22285
  import * as Crypto from "node:crypto";
21785
22286
  import * as NFS from "node:fs";
21786
22287
  import * as OS from "node:os";
@@ -21868,7 +22369,7 @@ var makeTempDirectoryScoped = /* @__PURE__ */ (() => {
21868
22369
  var openFactory = (method) => {
21869
22370
  const nodeOpen = effectify(NFS.open, handleErrnoException("FileSystem", method), handleBadArgument(method));
21870
22371
  const nodeClose = effectify(NFS.close, handleErrnoException("FileSystem", method), handleBadArgument(method));
21871
- return (path, options) => pipe(acquireRelease2(nodeOpen(path, options?.flag ?? "r", options?.mode), (fd) => orDie3(nodeClose(fd))), map5((fd) => makeFile(FileDescriptor(fd), options?.flag?.startsWith("a") ?? false)));
22372
+ return (path, options) => pipe(acquireRelease2(nodeOpen(path, options?.flag ?? "r", options?.mode), (fd) => orDie3(nodeClose(fd))), map5((fd) => makeFile(fd, options?.flag?.startsWith("a") ?? false)));
21872
22373
  };
21873
22374
  var open2 = /* @__PURE__ */ openFactory("open");
21874
22375
  var makeFile = /* @__PURE__ */ (() => {
@@ -21906,7 +22407,7 @@ var makeFile = /* @__PURE__ */ (() => {
21906
22407
  } else if (from === "current") {
21907
22408
  this.position = this.position + offsetSize;
21908
22409
  }
21909
- return this.position;
22410
+ return Size(this.position);
21910
22411
  });
21911
22412
  }
21912
22413
  read(buffer3) {
@@ -22073,9 +22574,9 @@ var utimes2 = /* @__PURE__ */ (() => {
22073
22574
  const nodeUtimes = /* @__PURE__ */ effectify(NFS.utimes, /* @__PURE__ */ handleErrnoException("FileSystem", "utime"), /* @__PURE__ */ handleBadArgument("utime"));
22074
22575
  return (path, atime, mtime) => nodeUtimes(path, atime, mtime);
22075
22576
  })();
22076
- var watchNode = (path) => callback3((queue) => acquireRelease2(sync3(() => {
22577
+ var watchNode = (path, options) => callback3((queue) => acquireRelease2(sync3(() => {
22077
22578
  const watcher = NFS.watch(path, {
22078
- recursive: true
22579
+ recursive: options?.recursive ?? false
22079
22580
  }, (event, path2) => {
22080
22581
  if (!path2)
22081
22582
  return;
@@ -22116,7 +22617,7 @@ var watchNode = (path) => callback3((queue) => acquireRelease2(sync3(() => {
22116
22617
  });
22117
22618
  return watcher;
22118
22619
  }), (watcher) => sync3(() => watcher.close())));
22119
- var watch2 = (backend, path) => stat2(path).pipe(map5((stat3) => backend.pipe(flatMap((_) => _.register(path, stat3)), getOrElse(() => watchNode(path)))), unwrap4);
22620
+ var watch2 = (backend, path, options) => stat2(path).pipe(map5((stat3) => backend.pipe(flatMap((_) => _.register(path, stat3, options)), getOrElse(() => watchNode(path, options)))), unwrap4);
22120
22621
  var writeFile2 = (path, data, options) => callback2((resume, signal) => {
22121
22622
  try {
22122
22623
  NFS.writeFile(path, data, {
@@ -22158,16 +22659,16 @@ var makeFileSystem = /* @__PURE__ */ map5(/* @__PURE__ */ serviceOption2(WatchBa
22158
22659
  symlink: symlink2,
22159
22660
  truncate: truncate2,
22160
22661
  utimes: utimes2,
22161
- watch(path) {
22162
- return watch2(backend, path);
22662
+ watch(path, options) {
22663
+ return watch2(backend, path, options);
22163
22664
  },
22164
22665
  writeFile: writeFile2
22165
22666
  }));
22166
22667
  var layer3 = /* @__PURE__ */ effect(FileSystem)(makeFileSystem);
22167
22668
 
22168
- // ../../node_modules/.bun/@effect+platform-node@4.0.0-beta.98+421eccb9593286ba/node_modules/@effect/platform-node/dist/NodeFileSystem.js
22669
+ // ../../node_modules/.bun/@effect+platform-node@4.0.0-beta.107+a2edc8a872f58f99/node_modules/@effect/platform-node/dist/NodeFileSystem.js
22169
22670
  var layer4 = layer3;
22170
- // ../../node_modules/.bun/@effect+platform-node@4.0.0-beta.98+421eccb9593286ba/node_modules/@effect/platform-node/dist/NodePath.js
22671
+ // ../../node_modules/.bun/@effect+platform-node@4.0.0-beta.107+a2edc8a872f58f99/node_modules/@effect/platform-node/dist/NodePath.js
22171
22672
  var exports_NodePath = {};
22172
22673
  __export(exports_NodePath, {
22173
22674
  layerWin32: () => layerWin322,
@@ -22175,55 +22676,58 @@ __export(exports_NodePath, {
22175
22676
  layer: () => layer6
22176
22677
  });
22177
22678
 
22178
- // ../../node_modules/.bun/@effect+platform-node-shared@4.0.0-beta.98+74997d64abff4185/node_modules/@effect/platform-node-shared/dist/NodePath.js
22679
+ // ../../node_modules/.bun/@effect+platform-node-shared@4.0.0-beta.107+572e5a9a9ccc3c07/node_modules/@effect/platform-node-shared/dist/NodePath.js
22179
22680
  import * as NodePath from "node:path";
22180
22681
  import * as NodeUrl from "node:url";
22181
- var fromFileUrl2 = (url) => try_3({
22182
- try: () => NodeUrl.fileURLToPath(url),
22183
- catch: (cause) => new BadArgument({
22184
- module: "Path",
22185
- method: "fromFileUrl",
22186
- cause
22187
- })
22188
- });
22189
- var toFileUrl2 = (path) => try_3({
22190
- try: () => NodeUrl.pathToFileURL(path),
22191
- catch: (cause) => new BadArgument({
22192
- module: "Path",
22193
- method: "toFileUrl",
22194
- cause
22682
+ var fileUrlOps = (windows) => ({
22683
+ fromFileUrl: (url) => try_3({
22684
+ try: () => NodeUrl.fileURLToPath(url, {
22685
+ windows
22686
+ }),
22687
+ catch: (cause) => new BadArgument({
22688
+ module: "Path",
22689
+ method: "fromFileUrl",
22690
+ cause
22691
+ })
22692
+ }),
22693
+ toFileUrl: (path) => try_3({
22694
+ try: () => NodeUrl.pathToFileURL(path, {
22695
+ windows
22696
+ }),
22697
+ catch: (cause) => new BadArgument({
22698
+ module: "Path",
22699
+ method: "toFileUrl",
22700
+ cause
22701
+ })
22195
22702
  })
22196
22703
  });
22197
22704
  var layerPosix = /* @__PURE__ */ succeed5(Path)({
22198
- [TypeId25]: TypeId25,
22705
+ [TypeId24]: TypeId24,
22199
22706
  ...NodePath.posix,
22200
- fromFileUrl: fromFileUrl2,
22201
- toFileUrl: toFileUrl2
22707
+ .../* @__PURE__ */ fileUrlOps(false)
22202
22708
  });
22203
22709
  var layerWin32 = /* @__PURE__ */ succeed5(Path)({
22204
- [TypeId25]: TypeId25,
22710
+ [TypeId24]: TypeId24,
22205
22711
  ...NodePath.win32,
22206
- fromFileUrl: fromFileUrl2,
22207
- toFileUrl: toFileUrl2
22712
+ .../* @__PURE__ */ fileUrlOps(true)
22208
22713
  });
22209
22714
  var layer5 = /* @__PURE__ */ succeed5(Path)({
22210
- [TypeId25]: TypeId25,
22715
+ [TypeId24]: TypeId24,
22211
22716
  ...NodePath,
22212
- fromFileUrl: fromFileUrl2,
22213
- toFileUrl: toFileUrl2
22717
+ .../* @__PURE__ */ fileUrlOps(undefined)
22214
22718
  });
22215
22719
 
22216
- // ../../node_modules/.bun/@effect+platform-node@4.0.0-beta.98+421eccb9593286ba/node_modules/@effect/platform-node/dist/NodePath.js
22720
+ // ../../node_modules/.bun/@effect+platform-node@4.0.0-beta.107+a2edc8a872f58f99/node_modules/@effect/platform-node/dist/NodePath.js
22217
22721
  var layer6 = layer5;
22218
22722
  var layerPosix2 = layerPosix;
22219
22723
  var layerWin322 = layerWin32;
22220
- // ../../node_modules/.bun/@effect+platform-node@4.0.0-beta.98+421eccb9593286ba/node_modules/@effect/platform-node/dist/NodeRuntime.js
22724
+ // ../../node_modules/.bun/@effect+platform-node@4.0.0-beta.107+a2edc8a872f58f99/node_modules/@effect/platform-node/dist/NodeRuntime.js
22221
22725
  var exports_NodeRuntime = {};
22222
22726
  __export(exports_NodeRuntime, {
22223
22727
  runMain: () => runMain2
22224
22728
  });
22225
22729
 
22226
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Runtime.js
22730
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Runtime.js
22227
22731
  var defaultTeardown = (exit3, onExit5) => {
22228
22732
  if (isSuccess4(exit3))
22229
22733
  return onExit5(0);
@@ -22271,7 +22775,7 @@ var getErrorReported = (u) => {
22271
22775
  return true;
22272
22776
  };
22273
22777
 
22274
- // ../../node_modules/.bun/@effect+platform-node-shared@4.0.0-beta.98+74997d64abff4185/node_modules/@effect/platform-node-shared/dist/NodeRuntime.js
22778
+ // ../../node_modules/.bun/@effect+platform-node-shared@4.0.0-beta.107+572e5a9a9ccc3c07/node_modules/@effect/platform-node-shared/dist/NodeRuntime.js
22275
22779
  var runMain = /* @__PURE__ */ makeRunMain(({
22276
22780
  fiber: fiber3,
22277
22781
  teardown
@@ -22294,9 +22798,9 @@ var runMain = /* @__PURE__ */ makeRunMain(({
22294
22798
  process.on("SIGTERM", onSigint);
22295
22799
  });
22296
22800
 
22297
- // ../../node_modules/.bun/@effect+platform-node@4.0.0-beta.98+421eccb9593286ba/node_modules/@effect/platform-node/dist/NodeRuntime.js
22801
+ // ../../node_modules/.bun/@effect+platform-node@4.0.0-beta.107+a2edc8a872f58f99/node_modules/@effect/platform-node/dist/NodeRuntime.js
22298
22802
  var runMain2 = runMain;
22299
- // ../../node_modules/.bun/effect@4.0.0-beta.98/node_modules/effect/dist/Console.js
22803
+ // ../../node_modules/.bun/effect@4.0.0-beta.107/node_modules/effect/dist/Console.js
22300
22804
  var exports_Console = {};
22301
22805
  __export(exports_Console, {
22302
22806
  withTime: () => withTime,
@@ -22395,23 +22899,24 @@ var withTime = /* @__PURE__ */ dual((args2) => isEffect(args2[0]), (self, label)
22395
22899
  // package.json
22396
22900
  var package_default = {
22397
22901
  name: "@aerovato/operator-helper",
22398
- version: "1.0.0",
22902
+ version: "1.0.1",
22399
22903
  description: "Installation and setup CLI for Operator Memory",
22400
22904
  license: "BSD-3-Clause",
22401
22905
  author: "Aerovato Research",
22402
- homepage: "https://github.com/aerovato/operator#readme",
22906
+ homepage: "https://github.com/aerovato/operator-memory#readme",
22403
22907
  bugs: {
22404
- url: "https://github.com/aerovato/operator/issues"
22908
+ url: "https://github.com/aerovato/operator-memory/issues"
22405
22909
  },
22406
22910
  repository: {
22407
22911
  type: "git",
22408
- url: "git+https://github.com/aerovato/operator.git",
22912
+ url: "git+https://github.com/aerovato/operator-memory.git",
22409
22913
  directory: "packages/helper"
22410
22914
  },
22411
22915
  dependencies: {
22412
- "@effect/platform-node": "4.0.0-beta.98",
22916
+ "@effect/platform-node": "4.0.0-beta.107",
22917
+ "@effect/platform-node-shared": "4.0.0-beta.107",
22413
22918
  "cli-table3": "^0.6.5",
22414
- effect: "4.0.0-beta.98",
22919
+ effect: "4.0.0-beta.107",
22415
22920
  yaml: "^2.9.0"
22416
22921
  },
22417
22922
  bin: {
@@ -22735,7 +23240,22 @@ var PROJECT_SHARED_README_TEMPLATE = `# Operator Memory
22735
23240
 
22736
23241
  This directory holds project knowledge and instructions used by Operator Memory. Operator Memory turns agent work into lasting project knowledge—instructions, specifications, codebase indexes, and related documents agents own and maintain.
22737
23242
 
22738
- Learn more: https://github.com/aerovato/operator
23243
+ ##### Learn more: https://github.com/aerovato/operator-memory
23244
+
23245
+ ---
23246
+
23247
+ Install now:
23248
+
23249
+ \`\`\`
23250
+ # With NPM
23251
+ npm install --global @aerovato/operator-helper
23252
+
23253
+ # With Bun
23254
+ bun add --global --minimum-release-age 0 @aerovato/operator-helper@latest
23255
+
23256
+ # Install OpenCode plugin
23257
+ operator-helper install opencode
23258
+ \`\`\`
22739
23259
  `;
22740
23260
 
22741
23261
  // src/templates/project/setup.ts
@@ -23378,7 +23898,7 @@ var installOpenCode = exports_Effect.fn("installOpenCode")(function* (context3)
23378
23898
  const fileSystem = yield* exports_FileSystem.FileSystem;
23379
23899
  const path = yield* exports_Path.Path;
23380
23900
  const spawner = yield* exports_ChildProcessSpawner.ChildProcessSpawner;
23381
- const cacheRoot = process.platform === "win32" ? process.env.LOCALAPPDATA ?? path.join(context3.home, "AppData", "Local") : process.env.XDG_CACHE_HOME ?? path.join(context3.home, ".cache");
23901
+ const cacheRoot = process.env.XDG_CACHE_HOME || path.join(context3.home, ".cache");
23382
23902
  const isCacheRemoved = yield* fileSystem.remove(path.join(cacheRoot, "opencode", "packages", "@aerovato", "operator-opencode@latest"), {
23383
23903
  recursive: true,
23384
23904
  force: true
@@ -24120,10 +24640,10 @@ function isNewerVersion(current, latest) {
24120
24640
  return false;
24121
24641
  }
24122
24642
  function parseVersion(value) {
24123
- const match6 = /^(\d+)\.(\d+)\.(\d+)/.exec(value);
24124
- if (match6 === null)
24643
+ const match7 = /^(\d+)\.(\d+)\.(\d+)/.exec(value);
24644
+ if (match7 === null)
24125
24645
  return null;
24126
- return [Number(match6[1]), Number(match6[2]), Number(match6[3])];
24646
+ return [Number(match7[1]), Number(match7[2]), Number(match7[3])];
24127
24647
  }
24128
24648
 
24129
24649
  // src/cli.ts
@@ -24229,4 +24749,4 @@ var main = exports_Effect.gen(function* () {
24229
24749
  }).pipe(exports_Effect.provide(LiveLayers));
24230
24750
  exports_NodeRuntime.runMain(main);
24231
24751
 
24232
- //# debugId=0884F2498EA99A6764756E2164756E21
24752
+ //# debugId=AE02583E7563EEEA64756E2164756E21