jj-octo 0.9.1 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +2 -0
  2. package/dist/jj-octo.js +958 -655
  3. package/package.json +6 -6
package/dist/jj-octo.js CHANGED
@@ -790,6 +790,10 @@ function assignProperty(self, key, value) {
790
790
  }
791
791
  }
792
792
  function assignProperties(self, source) {
793
+ if (!Object.hasOwn(source, "__proto__")) {
794
+ Object.assign(self, source);
795
+ return;
796
+ }
793
797
  for (const key of Reflect.ownKeys(source)) {
794
798
  if (Object.prototype.propertyIsEnumerable.call(source, key)) {
795
799
  assignProperty(self, key, source[key]);
@@ -880,7 +884,7 @@ class CauseImpl {
880
884
  toJSON() {
881
885
  return {
882
886
  _id: "Cause",
883
- failures: this.reasons.map((f) => f.toJSON())
887
+ reasons: this.reasons.map((f) => f.toJSON())
884
888
  };
885
889
  }
886
890
  toString() {
@@ -1821,9 +1825,21 @@ var bigint2 = /* @__PURE__ */ BigInt(2);
1821
1825
  var bigint10 = /* @__PURE__ */ BigInt(10);
1822
1826
  var bigint1e3 = /* @__PURE__ */ BigInt(1000);
1823
1827
  var bigint1e6 = /* @__PURE__ */ BigInt(1e6);
1828
+ var bigint1e9 = /* @__PURE__ */ BigInt(1e9);
1829
+ var bigintNanosPerMinute = /* @__PURE__ */ BigInt(60000000000);
1830
+ var bigintNanosPerHour = /* @__PURE__ */ BigInt(3600000000000);
1831
+ var bigintNanosPerDay = /* @__PURE__ */ BigInt(86400000000000);
1832
+ var bigintNanosPerWeek = /* @__PURE__ */ BigInt(604800000000000);
1824
1833
  var roundTiesAwayFromZero = (input) => BigInt(Math.sign(input) * Math.round(Math.abs(input)));
1825
1834
  var roundMillisToNanos = (millis) => Number.isInteger(millis) ? BigInt(millis) * bigint1e6 : roundTiesAwayFromZero(millis * 1e6);
1826
1835
  var fromNanosNumber = (nanos) => make4(Number.isFinite(nanos) ? roundTiesAwayFromZero(nanos) : nanos);
1836
+ var nanosToUnit = (nanos, divisor) => {
1837
+ const value = Number(nanos);
1838
+ if (Number.isFinite(value))
1839
+ return value / divisor;
1840
+ const scale = BigInt(divisor);
1841
+ return Number(nanos / scale) + Number(nanos % scale) / divisor;
1842
+ };
1827
1843
  var parseNanos = (input, scale) => {
1828
1844
  const decimalIndex = input.indexOf(".");
1829
1845
  if (decimalIndex === -1)
@@ -1839,6 +1855,13 @@ var divideTiesAwayFromZero = (numerator, denominator) => {
1839
1855
  const rounded = absolute / denominator + (absolute % denominator * bigint2 >= denominator ? bigint1 : bigint0);
1840
1856
  return numerator < bigint0 ? -rounded : rounded;
1841
1857
  };
1858
+ var fromMillisString = (input, scale) => {
1859
+ const millis = Number(input) * scale;
1860
+ if (!Number.isFinite(millis))
1861
+ return make4(millis);
1862
+ const nanos = parseNanos(input, BigInt(scale) * bigint1e6);
1863
+ return make4(Number.isInteger(millis) && BigInt(millis) * bigint1e6 === nanos ? millis : nanos);
1864
+ };
1842
1865
  var DURATION_REGEXP = /^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/;
1843
1866
  var fromInputUnsafe = (input) => {
1844
1867
  switch (typeof input) {
@@ -1863,26 +1886,25 @@ var fromInputUnsafe = (input) => {
1863
1886
  if (unit === "micro" || unit === "micros") {
1864
1887
  return nanos(parseNanos(valueStr, bigint1e3));
1865
1888
  }
1866
- const value = Number(valueStr);
1867
1889
  switch (unit) {
1868
1890
  case "milli":
1869
1891
  case "millis":
1870
- return millis(value);
1892
+ return fromMillisString(valueStr, 1);
1871
1893
  case "second":
1872
1894
  case "seconds":
1873
- return seconds(value);
1895
+ return fromMillisString(valueStr, 1000);
1874
1896
  case "minute":
1875
1897
  case "minutes":
1876
- return minutes(value);
1898
+ return fromMillisString(valueStr, 60000);
1877
1899
  case "hour":
1878
1900
  case "hours":
1879
- return hours(value);
1901
+ return fromMillisString(valueStr, 3600000);
1880
1902
  case "day":
1881
1903
  case "days":
1882
- return days(value);
1904
+ return fromMillisString(valueStr, 86400000);
1883
1905
  case "week":
1884
1906
  case "weeks":
1885
- return weeks(value);
1907
+ return fromMillisString(valueStr, 604800000);
1886
1908
  }
1887
1909
  break;
1888
1910
  }
@@ -1904,7 +1926,8 @@ var fromInputUnsafe = (input) => {
1904
1926
  if (input[0] === Infinity || input[1] === Infinity) {
1905
1927
  return infinity;
1906
1928
  }
1907
- return fromNanosNumber(input[0] * 1e9 + input[1]);
1929
+ const nanos = input[0] * 1e9 + input[1];
1930
+ return Number.isFinite(nanos) && Number.isInteger(input[0]) && Number.isInteger(input[1]) ? make4(BigInt(input[0]) * bigint1e9 + BigInt(input[1])) : fromNanosNumber(nanos);
1908
1931
  }
1909
1932
  const obj = input;
1910
1933
  let millis = 0;
@@ -1920,13 +1943,42 @@ var fromInputUnsafe = (input) => {
1920
1943
  millis += obj.seconds * 1000;
1921
1944
  if (obj.milliseconds)
1922
1945
  millis += obj.milliseconds;
1923
- if (!obj.microseconds && !obj.nanoseconds)
1924
- return make4(millis);
1925
- return fromNanosNumber(millis * 1e6 + (obj.microseconds ?? 0) * 1000 + (obj.nanoseconds ?? 0));
1946
+ if (!obj.microseconds && !obj.nanoseconds) {
1947
+ if (!Number.isFinite(millis))
1948
+ return make4(millis);
1949
+ const exact = sumObjectNanos(obj);
1950
+ return exact === undefined || BigInt(millis) * bigint1e6 === exact ? make4(millis) : make4(exact);
1951
+ }
1952
+ const nanos = millis * 1e6 + (obj.microseconds ?? 0) * 1000 + (obj.nanoseconds ?? 0);
1953
+ const exact = Number.isFinite(nanos) ? sumObjectNanos(obj) : undefined;
1954
+ return exact === undefined ? fromNanosNumber(nanos) : make4(exact);
1926
1955
  }
1927
1956
  }
1928
1957
  return invalid(input);
1929
1958
  };
1959
+ var isIntegerOrUnset = (n) => !n || Number.isInteger(n);
1960
+ var sumObjectNanos = (obj) => {
1961
+ if (!isIntegerOrUnset(obj.weeks) || !isIntegerOrUnset(obj.days) || !isIntegerOrUnset(obj.hours) || !isIntegerOrUnset(obj.minutes) || !isIntegerOrUnset(obj.seconds) || !isIntegerOrUnset(obj.milliseconds) || !isIntegerOrUnset(obj.microseconds) || !isIntegerOrUnset(obj.nanoseconds))
1962
+ return;
1963
+ let nanos = bigint0;
1964
+ if (obj.weeks)
1965
+ nanos += BigInt(obj.weeks) * bigintNanosPerWeek;
1966
+ if (obj.days)
1967
+ nanos += BigInt(obj.days) * bigintNanosPerDay;
1968
+ if (obj.hours)
1969
+ nanos += BigInt(obj.hours) * bigintNanosPerHour;
1970
+ if (obj.minutes)
1971
+ nanos += BigInt(obj.minutes) * bigintNanosPerMinute;
1972
+ if (obj.seconds)
1973
+ nanos += BigInt(obj.seconds) * bigint1e9;
1974
+ if (obj.milliseconds)
1975
+ nanos += BigInt(obj.milliseconds) * bigint1e6;
1976
+ if (obj.microseconds)
1977
+ nanos += BigInt(obj.microseconds) * bigint1e3;
1978
+ if (obj.nanoseconds)
1979
+ nanos += BigInt(obj.nanoseconds);
1980
+ return nanos;
1981
+ };
1930
1982
  var invalid = (input) => {
1931
1983
  throw new Error(`Invalid Input: ${input}`);
1932
1984
  };
@@ -2036,13 +2088,9 @@ var negativeInfinity = /* @__PURE__ */ make4(-Infinity);
2036
2088
  var nanos = (nanos) => make4(nanos);
2037
2089
  var millis = (millis) => make4(millis);
2038
2090
  var seconds = (seconds) => make4(seconds * 1000);
2039
- var minutes = (minutes) => make4(minutes * 60000);
2040
- var hours = (hours) => make4(hours * 3600000);
2041
- var days = (days) => make4(days * 86400000);
2042
- var weeks = (weeks) => make4(weeks * 604800000);
2043
2091
  var toMillis = (self) => match4(fromInputUnsafe(self), {
2044
2092
  onMillis: identity,
2045
- onNanos: (nanos) => Number(nanos) / 1e6,
2093
+ onNanos: (nanos) => nanosToUnit(nanos, 1e6),
2046
2094
  onInfinity: () => Infinity,
2047
2095
  onNegativeInfinity: () => -Infinity
2048
2096
  });
@@ -2114,7 +2162,7 @@ var setTimer = "setImmediate" in globalThis ? (f) => {
2114
2162
  const timer = setTimeout(f, 0);
2115
2163
  return () => clearTimeout(timer);
2116
2164
  };
2117
- var setImmediate = (f) => {
2165
+ var setImmediate2 = (f) => {
2118
2166
  try {
2119
2167
  return setTimer(f);
2120
2168
  } catch {
@@ -2154,7 +2202,7 @@ class MixedScheduler {
2154
2202
  setImmediate;
2155
2203
  constructor(executionMode = "async", setImmediateFn) {
2156
2204
  this.executionMode = executionMode;
2157
- this.setImmediate = setImmediateFn ?? (executionMode === "sync" ? setMicrotask : setImmediate);
2205
+ this.setImmediate = setImmediateFn ?? (executionMode === "sync" ? setMicrotask : setImmediate2);
2158
2206
  }
2159
2207
  shouldYield(fiber) {
2160
2208
  return fiber.currentOpCount >= fiber.cache.maxOpsBeforeYield;
@@ -2168,7 +2216,7 @@ class MixedSchedulerDispatcher {
2168
2216
  tasks = /* @__PURE__ */ new PriorityBuckets;
2169
2217
  running = undefined;
2170
2218
  setImmediate;
2171
- constructor(setImmediateFn = setImmediate) {
2219
+ constructor(setImmediateFn = setImmediate2) {
2172
2220
  this.setImmediate = setImmediateFn;
2173
2221
  }
2174
2222
  scheduleTask(task, priority) {
@@ -2458,10 +2506,7 @@ class Interrupt extends ReasonBase {
2458
2506
  }
2459
2507
  }
2460
2508
  var causeInterrupt = (fiberId) => new CauseImpl([new Interrupt(fiberId)]);
2461
- var findFail = (self) => {
2462
- const reason = self.reasons.find(isFailReason);
2463
- return reason ? succeed2(reason) : fail2(self);
2464
- };
2509
+ var hasFails = (self) => self.reasons.some(isFailReason);
2465
2510
  var findError = (self) => {
2466
2511
  for (let i = 0;i < self.reasons.length; i++) {
2467
2512
  const reason = self.reasons[i];
@@ -2472,6 +2517,9 @@ var findError = (self) => {
2472
2517
  return fail2(self);
2473
2518
  };
2474
2519
  var findErrorOption = /* @__PURE__ */ toOption(findError);
2520
+ var hasDies = (self) => self.reasons.some(isDieReason);
2521
+ var causeElectDefects = (self) => hasDies(self) && hasFails(self) ? causeFromReasons(self.reasons.map((reason) => reason._tag === "Fail" && !isDone(reason.error) ? new Die(reason.error, reason.annotations) : reason)) : self;
2522
+ var findRecoverableError = (self) => hasDies(self) ? fail2(causeElectDefects(self)) : findError(self);
2475
2523
  var hasInterrupts = (self) => self.reasons.some(isInterruptReason);
2476
2524
  var causeFilterInterruptors = (self) => {
2477
2525
  let interruptors;
@@ -2546,12 +2594,14 @@ var causePrettyErrors = (self, options) => {
2546
2594
  }
2547
2595
  return errors;
2548
2596
  };
2549
- var causePrettyError = (original, annotations, options) => {
2597
+ var causePrettyError = (original, annotations, options, seen = new Set) => {
2550
2598
  const kind = typeof original;
2551
2599
  let error;
2552
2600
  if (original && kind === "object") {
2601
+ seen.add(original);
2602
+ const cause = original.cause;
2553
2603
  error = new globalThis.Error(causePrettyMessage(original), {
2554
- cause: original.cause ? causePrettyError(original.cause) : undefined
2604
+ cause: cause !== undefined && !seen.has(cause) ? causePrettyError(cause, undefined, undefined, seen) : undefined
2555
2605
  });
2556
2606
  if (typeof original.name === "string") {
2557
2607
  error.name = original.name;
@@ -2762,7 +2812,11 @@ class FiberImpl {
2762
2812
  } else if (this._asyncContext !== undefined) {
2763
2813
  const asyncContext = this._asyncContext;
2764
2814
  this._asyncContext = undefined;
2765
- return asyncContext.runInAsyncScope(this.evaluate, this, effect);
2815
+ try {
2816
+ return asyncContext.runInAsyncScope(this.evaluate, this, effect);
2817
+ } finally {
2818
+ asyncContext.emitDestroy();
2819
+ }
2766
2820
  } else if (this._yielded !== undefined) {
2767
2821
  const yielded = this._yielded;
2768
2822
  this._yielded = undefined;
@@ -3063,7 +3117,6 @@ var tryPromise = (options) => {
3063
3117
  }
3064
3118
  }, f.length !== 0);
3065
3119
  };
3066
- var withFiberId = (f) => withFiber((fiber) => f(fiber.id));
3067
3120
  var callbackOptions = /* @__PURE__ */ function() {
3068
3121
  const Proto = /* @__PURE__ */ makePrimitiveProto({
3069
3122
  op: "Async",
@@ -3084,9 +3137,9 @@ var callbackOptions = /* @__PURE__ */ function() {
3084
3137
  if (yielded !== false)
3085
3138
  return yielded;
3086
3139
  yielded = true;
3087
- fiber._yielded = () => {
3140
+ fiber.yieldWith(() => {
3088
3141
  resumed = true;
3089
- };
3142
+ });
3090
3143
  if (controller === undefined && onCancel === undefined) {
3091
3144
  return Yield;
3092
3145
  }
@@ -3315,9 +3368,9 @@ var catchEager = /* @__PURE__ */ dual(2, (self, f) => {
3315
3368
  if (effectIsExit(self)) {
3316
3369
  if (self._tag === "Success")
3317
3370
  return self;
3318
- const error = findError(self.cause);
3371
+ const error = findRecoverableError(self.cause);
3319
3372
  if (isFailure2(error))
3320
- return self;
3373
+ return exitFailCause(error.failure);
3321
3374
  return f(error.success);
3322
3375
  }
3323
3376
  return catch_(self, f);
@@ -3332,18 +3385,12 @@ var exitMap = /* @__PURE__ */ dual(2, (self, f) => self._tag === "Success" ? exi
3332
3385
  var exitMapError = /* @__PURE__ */ dual(2, (self, f) => {
3333
3386
  if (self._tag === "Success")
3334
3387
  return self;
3335
- const error = findError(self.cause);
3336
- if (isFailure2(error))
3337
- return self;
3338
- return exitFail(f(error.success));
3388
+ return exitFailCause(causeMap(self.cause, f));
3339
3389
  });
3340
3390
  var exitMapBoth = /* @__PURE__ */ dual(2, (self, options) => {
3341
3391
  if (self._tag === "Success")
3342
3392
  return exitSucceed(options.onSuccess(self.value));
3343
- const error = findError(self.cause);
3344
- if (isFailure2(error))
3345
- return self;
3346
- return exitFail(options.onFailure(error.success));
3393
+ return exitFailCause(causeMap(self.cause, options.onFailure));
3347
3394
  });
3348
3395
  var exitZipRight = /* @__PURE__ */ dual(2, (self, that) => exitIsSuccess(self) ? that : self);
3349
3396
  var exitAsVoidAll = (exits) => {
@@ -3410,7 +3457,7 @@ var catchCauseFilter = /* @__PURE__ */ dual(3, (self, filter, f) => catchCause(s
3410
3457
  const eb = filter(cause);
3411
3458
  return isFailure2(eb) ? failCause(eb.failure) : f(eb.success, cause);
3412
3459
  }));
3413
- var catch_ = /* @__PURE__ */ dual(2, (self, f) => catchCauseFilter(self, findError, (e) => f(e)));
3460
+ var catch_ = /* @__PURE__ */ dual(2, (self, f) => catchCauseFilter(self, findRecoverableError, (e) => f(e)));
3414
3461
  var tapCause = /* @__PURE__ */ dual(2, (self, f) => catchCause(self, (cause) => andThen(f(cause), failCause(cause))));
3415
3462
  var tapCauseFilter = /* @__PURE__ */ dual(3, (self, filter, f) => catchCause(self, (cause) => {
3416
3463
  const result = filter(cause);
@@ -3421,7 +3468,7 @@ var tapCauseFilter = /* @__PURE__ */ dual(3, (self, filter, f) => catchCause(sel
3421
3468
  }));
3422
3469
  var tapError = /* @__PURE__ */ dual(2, (self, f) => tapCauseFilter(self, findError, (e) => f(e)));
3423
3470
  var catchIf = /* @__PURE__ */ dual((args) => isEffect(args[0]), (self, predicate, f, orElse) => catchCause(self, (cause) => {
3424
- const error = findError(cause);
3471
+ const error = findRecoverableError(cause);
3425
3472
  if (isFailure2(error))
3426
3473
  return failCause(error.failure);
3427
3474
  if (!predicate(error.success)) {
@@ -3430,7 +3477,7 @@ var catchIf = /* @__PURE__ */ dual((args) => isEffect(args[0]), (self, predicate
3430
3477
  return f(error.success);
3431
3478
  }));
3432
3479
  var catchFilter = /* @__PURE__ */ dual((args) => isEffect(args[0]), (self, filter, f, orElse) => catchCause(self, (cause) => {
3433
- const error = findError(cause);
3480
+ const error = findRecoverableError(cause);
3434
3481
  if (isFailure2(error))
3435
3482
  return failCause(error.failure);
3436
3483
  const result = filter(error.success);
@@ -3450,9 +3497,9 @@ var catchTags = /* @__PURE__ */ dual((args) => isEffect(args[0]), (self, cases,
3450
3497
  return hasProperty(e, "_tag") && isString(e["_tag"]) && keys.includes(e["_tag"]) ? succeed2(e) : fail2(e);
3451
3498
  }, (e) => cases[e["_tag"]](e), orElse);
3452
3499
  });
3453
- var mapError2 = /* @__PURE__ */ dual(2, (self, f) => catch_(self, (error) => failSync(() => f(error))));
3454
- var mapBoth = /* @__PURE__ */ dual(2, (self, options) => matchEffect(self, {
3455
- onFailure: (e) => failSync(() => options.onFailure(e)),
3500
+ var mapError2 = /* @__PURE__ */ dual(2, (self, f) => catchCause(self, (cause) => failCause(causeMap(cause, f))));
3501
+ var mapBoth = /* @__PURE__ */ dual(2, (self, options) => matchCauseEffect(self, {
3502
+ onFailure: (cause) => failCause(causeMap(cause, options.onFailure)),
3456
3503
  onSuccess: (a) => sync(() => options.onSuccess(a))
3457
3504
  }));
3458
3505
  var orDie = (self) => catch_(self, die);
@@ -3467,8 +3514,8 @@ var ignore = /* @__PURE__ */ dual((args) => isEffect(args[0]), (self, options) =
3467
3514
  const logEffect = logWithLevel(options.log === true ? undefined : options.log);
3468
3515
  return matchCauseEffect(self, {
3469
3516
  onFailure(cause) {
3470
- const failure = findFail(cause);
3471
- return isFailure2(failure) ? failCause(failure.failure) : options.message === undefined ? logEffect(cause) : logEffect(options.message, cause);
3517
+ const error = findRecoverableError(cause);
3518
+ return isFailure2(error) ? failCause(error.failure) : options.message === undefined ? logEffect(cause) : logEffect(options.message, cause);
3472
3519
  },
3473
3520
  onSuccess: (_) => void_
3474
3521
  });
@@ -3507,16 +3554,16 @@ var makeMatch = (op, onFailure) => {
3507
3554
  return MatchImpl;
3508
3555
  };
3509
3556
  var MatchImpl = /* @__PURE__ */ makeMatch("Match", function(cause, fiber) {
3510
- const fail = cause.reasons.find(isFailReason);
3511
- if (fail === undefined)
3512
- return failCause(cause);
3557
+ const error = findRecoverableError(cause);
3558
+ if (isFailure2(error))
3559
+ return failCause(error.failure);
3513
3560
  const handlers = this.payload;
3514
- return fiber.succeedWith(continuationMarksStack ? handlers.onFailure(fail.error) : internalCall(() => handlers.onFailure(fail.error)));
3561
+ return fiber.succeedWith(continuationMarksStack ? handlers.onFailure(error.success) : internalCall(() => handlers.onFailure(error.success)));
3515
3562
  });
3516
3563
  var matchEffect = /* @__PURE__ */ dual(2, (self, options) => matchCauseEffect(self, {
3517
3564
  onFailure: (cause) => {
3518
- const fail = cause.reasons.find(isFailReason);
3519
- return fail ? options.onFailure(fail.error) : failCause(cause);
3565
+ const error = findRecoverableError(cause);
3566
+ return isFailure2(error) ? failCause(error.failure) : options.onFailure(error.success);
3520
3567
  },
3521
3568
  onSuccess: options.onSuccess
3522
3569
  }));
@@ -3525,9 +3572,9 @@ var matchEager = /* @__PURE__ */ dual(2, (self, options) => {
3525
3572
  if (effectIsExit(self)) {
3526
3573
  if (self._tag === "Success")
3527
3574
  return exitSucceed(options.onSuccess(self.value));
3528
- const error = findError(self.cause);
3575
+ const error = findRecoverableError(self.cause);
3529
3576
  if (isFailure2(error))
3530
- return self;
3577
+ return exitFailCause(error.failure);
3531
3578
  return exitSucceed(options.onFailure(error.success));
3532
3579
  }
3533
3580
  return match5(self, options);
@@ -3582,17 +3629,17 @@ var runFinalizer = (finalizer, exit_) => {
3582
3629
  return exitDie(defect);
3583
3630
  }
3584
3631
  };
3585
- var combineFinalizerCause = (exit_, finalizer) => exitIsSuccess(exit_) ? finalizer : catchCause(finalizer, (cause) => failCause(causeCombine(exit_.cause, cause)));
3632
+ var combineFinalizerCause = (exit_, finalizer) => exitIsSuccess(exit_) ? finalizer : catchCause(finalizer, (cause) => failCause(causeElectDefects(causeCombine(exit_.cause, cause))));
3586
3633
  var scopeCloseFinalizers = /* @__PURE__ */ fnUntraced(function* (self, finalizers, exit_) {
3587
3634
  let exits = [];
3588
3635
  const fibers = [];
3589
- const arr = Array.from(finalizers.values());
3636
+ const arr = Array.from(finalizers);
3590
3637
  const parent = getCurrentFiber();
3591
3638
  for (let i = arr.length - 1;i >= 0; i--) {
3592
- const finalizer = arr[i];
3639
+ const [key, finalizer] = arr[i];
3593
3640
  if (self.strategy === "sequential") {
3594
3641
  exits.push(yield* exit(runFinalizer(finalizer, exit_)));
3595
- } else {
3642
+ } else if (key !== parent) {
3596
3643
  fibers.push(forkUnsafe(parent, runFinalizer(finalizer, exit_), true, true, "inherit"));
3597
3644
  }
3598
3645
  }
@@ -3751,9 +3798,10 @@ var makeCachedUnsafe = (self, ttlMillis) => {
3751
3798
  const join = (fiber, run) => {
3752
3799
  run.awaiters++;
3753
3800
  onExitUnsafe(fiber, () => {
3754
- if (--run.awaiters > 0 || current !== run)
3801
+ if (--run.awaiters > 0 || run.done)
3755
3802
  return;
3756
- current = undefined;
3803
+ if (current === run)
3804
+ current = undefined;
3757
3805
  return fiberInterrupt(run.fiber);
3758
3806
  });
3759
3807
  return fiberJoin(run.fiber);
@@ -3769,11 +3817,13 @@ var makeCachedUnsafe = (self, ttlMillis) => {
3769
3817
  const clock = fiber.getRef(ClockRef);
3770
3818
  const run = {
3771
3819
  fiber: new FiberImpl(fiber.context),
3772
- awaiters: 0
3820
+ awaiters: 0,
3821
+ done: false
3773
3822
  };
3774
3823
  current = run;
3775
3824
  const joined = join(fiber, run);
3776
3825
  run.fiber.evaluate(onExitPrimitive(self, (exit_) => {
3826
+ run.done = true;
3777
3827
  if (current !== run)
3778
3828
  return;
3779
3829
  current = undefined;
@@ -3785,6 +3835,7 @@ var makeCachedUnsafe = (self, ttlMillis) => {
3785
3835
  }));
3786
3836
  return run.fiber._exit ?? joined;
3787
3837
  }), sync(() => {
3838
+ current = undefined;
3788
3839
  exit = undefined;
3789
3840
  })];
3790
3841
  };
@@ -3839,15 +3890,9 @@ var all2 = (arg, options) => {
3839
3890
  } else if (options?.discard) {
3840
3891
  return options.mode === "result" ? forEach(Object.values(arg), result, options) : forEach(Object.values(arg), identity, options);
3841
3892
  }
3842
- return suspend(() => {
3843
- const out = {};
3844
- return as(forEach(Object.entries(arg), ([key, effect]) => map5(options?.mode === "result" ? result(effect) : effect, (value) => {
3845
- assignProperty(out, key, value);
3846
- }), {
3847
- discard: true,
3848
- concurrency: options?.concurrency
3849
- }), out);
3850
- });
3893
+ return suspend(() => map5(forEach(Object.entries(arg), ([key, effect]) => map5(options?.mode === "result" ? result(effect) : effect, (value) => [key, value]), {
3894
+ concurrency: options?.concurrency
3895
+ }), Object.fromEntries));
3851
3896
  };
3852
3897
  var whileLoop = /* @__PURE__ */ makePrimitive({
3853
3898
  op: "While",
@@ -3986,7 +4031,7 @@ var iterateConcurrentImpl = (options) => {
3986
4031
  const reasons = exit.cause.reasons.filter((reason) => reason._tag !== "Interrupt");
3987
4032
  if (reasons.length > 0) {
3988
4033
  const cause = causeFromReasons(reasons);
3989
- terminal = exitFailCause(terminal._tag === "Failure" ? causeCombine(terminal.cause, cause) : cause);
4034
+ terminal = exitFailCause(terminal._tag === "Failure" ? causeElectDefects(causeCombine(terminal.cause, cause)) : cause);
3990
4035
  }
3991
4036
  }
3992
4037
  } else {
@@ -4065,14 +4110,13 @@ var forkUnsafe = (parent, effect, immediate = false, daemon = false, uninterrupt
4065
4110
  }
4066
4111
  return child;
4067
4112
  };
4113
+ var fiberScopeFinalizer = (fiber) => () => withFiber((current) => current === fiber ? void_ : fiberInterrupt(fiber));
4068
4114
  var forkIn = /* @__PURE__ */ dual((args) => isEffect(args[0]), (self, scope, options) => withFiber((parent) => {
4069
- const fiber = forkUnsafe(parent, self, options?.startImmediately, true, options?.uninterruptible);
4115
+ const fiber = scope.state._tag === "Closed" ? new FiberImpl(parent.context) : forkUnsafe(parent, self, options?.startImmediately, true, options?.uninterruptible);
4070
4116
  if (!fiber._exit) {
4071
4117
  if (scope.state._tag !== "Closed") {
4072
- const key = {};
4073
- const finalizer = () => withFiberId((interruptor) => interruptor === fiber.id ? void_ : fiberInterrupt(fiber));
4074
- scopeAddFinalizerUnsafe(scope, key, finalizer);
4075
- fiber.addObserver(() => scopeRemoveFinalizerUnsafe(scope, key));
4118
+ scopeAddFinalizerUnsafe(scope, fiber, fiberScopeFinalizer(fiber));
4119
+ fiber.addObserver(() => scopeRemoveFinalizerUnsafe(scope, fiber));
4076
4120
  } else {
4077
4121
  fiber.interruptUnsafe(parent.id, fiberStackAnnotations(parent));
4078
4122
  }
@@ -4109,7 +4153,7 @@ var fiberRunIn = /* @__PURE__ */ dual(2, (self, scope) => {
4109
4153
  return self;
4110
4154
  }
4111
4155
  scopeRemoveFinalizerUnsafe(scope, self);
4112
- scopeAddFinalizerUnsafe(scope, self, () => fiberInterrupt(self));
4156
+ scopeAddFinalizerUnsafe(scope, self, fiberScopeFinalizer(self));
4113
4157
  self.addObserver(() => scopeRemoveFinalizerUnsafe(scope, self));
4114
4158
  return self;
4115
4159
  });
@@ -4804,8 +4848,8 @@ var mergeAllEffect = (layers, memoMap, scope) => {
4804
4848
  concurrency: layers.length
4805
4849
  }).pipe(map5((context) => mergeAll(...context)));
4806
4850
  };
4807
- var mergeAll2 = (...layers) => fromBuild((memoMap, scope) => mergeAllEffect(layers, memoMap, scope));
4808
- var provideWith = (self, that, f) => fromBuild((memoMap, scope) => flatMap2(Array.isArray(that) ? mergeAllEffect(that, memoMap, scope) : that.build(memoMap, scope), (context) => self.build(memoMap, scope).pipe(provideContext(context), map5((merged) => f(merged, context)))));
4851
+ var mergeAll2 = (...layers) => fromBuildMemo((memoMap, scope) => mergeAllEffect(layers, memoMap, scope));
4852
+ var provideWith = (self, that, f) => fromBuildMemo((memoMap, scope) => flatMap2(Array.isArray(that) ? mergeAllEffect(that, memoMap, scope) : that.build(memoMap, scope), (context) => self.build(memoMap, scope).pipe(provideContext(context), map5((merged) => f(merged, context)))));
4809
4853
  var provideMerge = /* @__PURE__ */ dual(2, (self, that) => provideWith(self, that, (self, that) => merge(that, self)));
4810
4854
  var flatMap3 = /* @__PURE__ */ dual(2, (self, f) => fromBuild((memoMap, scope) => flatMap2(self.build(memoMap, scope), (context) => f(context).build(memoMap, scope))));
4811
4855
 
@@ -4964,14 +5008,17 @@ var provideLayer = (self, layer, options) => scopedWith((scope) => flatMap2(opti
4964
5008
  var provide2 = /* @__PURE__ */ dual((args) => isEffect(args[0]), (self, source, options) => isContext(source) ? provideContext(self, source) : provideLayer(self, Array.isArray(source) ? mergeAll2(...source) : source, options));
4965
5009
 
4966
5010
  // node_modules/effect/dist/internal/schedule.js
4967
- var findErrorOnly = (cause) => cause.reasons.every(isFailReason) ? findError(cause) : fail2(cause);
4968
5011
  var repeatOrElse = /* @__PURE__ */ dual(3, (self, schedule, orElse) => flatMap2(toStepWithMetadata(schedule), (step) => {
4969
5012
  let meta = CurrentMetadata.defaultValue();
4970
- return catchCauseFilter(catchDone(forever(tap(flatMap2(suspend(() => provideService(self, CurrentMetadata, meta)), step), (meta_) => sync(() => {
4971
- meta = meta_;
4972
- })), {
4973
- disableYield: true
4974
- }), (out) => succeed3(out)), findErrorOnly, (error) => orElse(error, meta.attempt === 0 ? none2() : some2(meta)));
5013
+ const loop = (input) => matchEffect2(step(input), {
5014
+ onSuccess(meta_) {
5015
+ meta = meta_;
5016
+ return flatMap2(provideService(self, CurrentMetadata, meta), loop);
5017
+ },
5018
+ onFailure: failCause,
5019
+ onDone: succeed3
5020
+ });
5021
+ return catchCauseFilter(flatMap2(provideService(self, CurrentMetadata, meta), loop), findRecoverableError, (error) => orElse(error, meta.attempt === 0 ? none2() : some2(meta)));
4975
5022
  }));
4976
5023
  var repeat = /* @__PURE__ */ dual(2, (self, options) => {
4977
5024
  const schedule = typeof options === "function" ? options(identity) : isSchedule(options) ? options : buildFromOptions(options);
@@ -5018,6 +5065,7 @@ var void_3 = void_;
5018
5065
  var callback2 = callback;
5019
5066
  var gen2 = gen;
5020
5067
  var fail6 = fail3;
5068
+ var failSync2 = failSync;
5021
5069
  var failCause3 = failCause;
5022
5070
  var failCauseSync2 = failCauseSync;
5023
5071
  var die3 = die;
@@ -5085,16 +5133,23 @@ var fnUntraced2 = fnUntraced;
5085
5133
  var clockWith2 = clockWith;
5086
5134
  var logError = /* @__PURE__ */ logWithLevel("Error");
5087
5135
  var effectify = (fn, onError, onSyncError) => (...args) => callback2((resume) => {
5136
+ let synchronous = true;
5137
+ let pending;
5088
5138
  try {
5089
5139
  fn(...args, (err, result) => {
5090
- if (err) {
5091
- resume(onError ? suspend2(() => fail6(onError(err, args))) : fail6(err));
5140
+ const effect = err ? onError ? suspend2(() => fail6(onError(err, args))) : fail6(err) : succeed6(result);
5141
+ if (synchronous) {
5142
+ pending ??= effect;
5092
5143
  } else {
5093
- resume(succeed6(result));
5144
+ resume(effect);
5094
5145
  }
5095
5146
  });
5096
5147
  } catch (err) {
5097
- resume(onSyncError ? fail6(onSyncError(err, args)) : die3(err));
5148
+ pending = onSyncError ? fail6(onSyncError(err, args)) : die3(err);
5149
+ }
5150
+ synchronous = false;
5151
+ if (pending) {
5152
+ resume(pending);
5098
5153
  }
5099
5154
  });
5100
5155
  var mapEager2 = mapEager;
@@ -5113,23 +5168,26 @@ var defaultTeardown = (exit, onExit) => {
5113
5168
  return onExit(getErrorExitCode(squash(exit.cause)));
5114
5169
  };
5115
5170
  var makeRunMain = (f) => dual((args) => isEffect2(args[0]), (effect, options) => {
5116
- const fiber = options?.disableErrorReporting === true ? runFork2(effect) : runFork2(tapCause2(effect, (cause) => {
5171
+ const main = options?.disableErrorReporting === true ? effect : tapCause2(effect, (cause) => {
5117
5172
  if (hasInterruptsOnly2(cause))
5118
5173
  return void_3;
5119
5174
  const isReported = getErrorReported(squash(cause));
5120
5175
  return isReported ? logError(cause) : void_3;
5121
- }));
5122
- try {
5123
- const keepAlive = globalThis.setInterval(constVoid, 2147483647);
5124
- fiber.addObserver(() => {
5125
- clearInterval(keepAlive);
5126
- });
5127
- } catch {}
5128
- const teardown = options?.teardown ?? defaultTeardown;
5129
- return f({
5130
- fiber,
5131
- teardown
5132
5176
  });
5177
+ const teardown = options?.teardown ?? defaultTeardown;
5178
+ runFork2(withFiber2((fiber) => {
5179
+ try {
5180
+ const keepAlive = globalThis.setInterval(constVoid, 2147483647);
5181
+ fiber.addObserver(() => {
5182
+ clearInterval(keepAlive);
5183
+ });
5184
+ } catch {}
5185
+ f({
5186
+ fiber,
5187
+ teardown
5188
+ });
5189
+ return main;
5190
+ }));
5133
5191
  });
5134
5192
  var errorExitCode = "~effect/Runtime/errorExitCode";
5135
5193
  var getErrorExitCode = (u) => {
@@ -5774,7 +5832,9 @@ var toTransform = (channel) => channel.transform;
5774
5832
  var asyncQueue = (scope, f, options) => make9({
5775
5833
  capacity: options?.bufferSize,
5776
5834
  strategy: options?.strategy
5777
- }).pipe(tap2((queue) => addFinalizer2(scope, shutdown(queue))), tap2((queue) => provide(f(queue), scope).pipe(catchCause2((cause) => failCause4(queue, cause)), forkIn2(scope))));
5835
+ }).pipe(tap2((queue) => addFinalizer2(scope, shutdown(queue))), tap2((queue) => provide(f(queue), scope).pipe(catchCause2((cause) => failCause4(queue, cause)), forkIn2(scope, {
5836
+ startImmediately: true
5837
+ }))));
5778
5838
  var callbackArray = (f, options) => fromTransform((_, scope) => map7(asyncQueue(scope, f, options), takeAll2));
5779
5839
  var suspend3 = (evaluate) => fromTransform((upstream, scope) => suspend2(() => toTransform(evaluate())(upstream, scope)));
5780
5840
  var succeed7 = (value) => fromEffect(succeed6(value));
@@ -5816,7 +5876,7 @@ var readableStreamToPullUnsafe = (options) => {
5816
5876
  }
5817
5877
  });
5818
5878
  });
5819
- return as2(addFinalizer2(options.scope, options.releaseLockOnEnd ? sync2(() => reader.releaseLock()) : promise2(() => reader.cancel().catch(constVoid))), pull);
5879
+ return as2(addFinalizer2(options.scope, options.releaseLockOnEnd ? sync2(() => reader.releaseLock()) : promise2(() => reader.cancel().catch((error) => reader.closed.then(() => Promise.reject(error), constVoid))).pipe(ensuring2(sync2(() => reader.releaseLock())))), pull);
5820
5880
  };
5821
5881
  var map8 = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => sync2(() => {
5822
5882
  let i = 0;
@@ -5934,6 +5994,18 @@ var splitLines = () => fromTransform((upstream, _scope) => sync2(() => {
5934
5994
  }
5935
5995
  return pullOrFlush;
5936
5996
  }));
5997
+ var decodeText = (encoding, options) => fromTransform((upstream, _scope) => sync2(() => {
5998
+ const decoder = new TextDecoder(encoding, options);
5999
+ const streamOptions = {
6000
+ stream: true
6001
+ };
6002
+ let pull = upstream.pipe(map7(map4((bytes) => decoder.decode(bytes, streamOptions))), catchDone((leftover) => {
6003
+ pull = done2(leftover);
6004
+ const last = decoder.decode();
6005
+ return last.length > 0 ? succeed6(of(last)) : pull;
6006
+ }));
6007
+ return suspend2(() => pull);
6008
+ }));
5937
6009
  var pipeTo = /* @__PURE__ */ dual(2, (self, that) => fromTransform((upstream, scope) => flatMap4(toTransform(self)(upstream, scope), (upstream) => toTransform(that)(upstream, scope))));
5938
6010
  var unwrap2 = (channel) => fromTransform((upstream, scope) => {
5939
6011
  let pull;
@@ -5943,6 +6015,9 @@ var unwrap2 = (channel) => fromTransform((upstream, scope) => {
5943
6015
  return channel.pipe(provide(scope), flatMap4((channel) => toTransform(channel)(upstream, scope)), flatMap4((pull_) => pull = pull_));
5944
6016
  }));
5945
6017
  });
6018
+ var interruptWhen = /* @__PURE__ */ dual(2, (self, effect) => merge2(self, fromPull(succeed6(flatMap4(effect, done2))), {
6019
+ haltStrategy: "either"
6020
+ }));
5946
6021
  var onExit3 = /* @__PURE__ */ dual(2, (self, finalizer) => fromTransformBracket((upstream, scope, forkedScope) => addFinalizerExit(forkedScope, finalizer).pipe(andThen2(toTransform(self)(upstream, scope)))));
5947
6022
  var ensuring3 = /* @__PURE__ */ dual(2, (self, finalizer) => onExit3(self, (_) => finalizer));
5948
6023
  var runWith = (self, f, onHalt) => suspend2(() => {
@@ -6169,7 +6244,12 @@ var toChannel2 = (stream) => stream.channel;
6169
6244
  var callback3 = (f, options) => fromChannel3(callbackArray(f, options));
6170
6245
  var empty4 = /* @__PURE__ */ fromChannel3(empty3);
6171
6246
  var make12 = (...values) => fromArray2(values);
6172
- var suspend4 = (stream) => fromChannel3(suspend3(() => stream().channel));
6247
+ var suspend4 = (stream) => {
6248
+ const suspended = fromChannel3(suspend3(() => stream().channel));
6249
+ suspendedStreams.set(suspended, stream);
6250
+ return suspended;
6251
+ };
6252
+ var suspendedStreams = /* @__PURE__ */ new WeakMap;
6173
6253
  var fail8 = (error) => fromChannel3(fail7(error));
6174
6254
  var fromArray2 = (array) => isReadonlyArrayNonEmpty(array) ? fromChannel3(succeed7(array)) : empty4;
6175
6255
  var fromReadableStream2 = (options) => fromChannel3(fromReadableStream(options));
@@ -6199,17 +6279,13 @@ var transduce = /* @__PURE__ */ dual(2, (self, sink) => transformPull2(self, (up
6199
6279
  });
6200
6280
  return suspend2(() => done ? done : pull);
6201
6281
  })));
6202
- var decodeText = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, options) => suspend4(() => {
6203
- const decoder = new TextDecoder(options?.encoding);
6204
- return map9(self, (chunk) => decoder.decode(chunk, {
6205
- stream: true
6206
- }));
6207
- }));
6282
+ var decodeText2 = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, options) => self.channel.pipe(pipeTo(decodeText(options?.encoding)), fromChannel3));
6208
6283
  var encodeText = (self) => suspend4(() => {
6209
6284
  const encoder = new TextEncoder;
6210
6285
  return map9(self, (chunk) => encoder.encode(chunk));
6211
6286
  });
6212
6287
  var splitLines2 = (self) => self.channel.pipe(pipeTo(splitLines()), fromChannel3);
6288
+ var interruptWhen2 = /* @__PURE__ */ dual(2, (self, effect) => fromChannel3(interruptWhen(self.channel, effect)));
6213
6289
  var ensuring4 = /* @__PURE__ */ dual(2, (self, finalizer) => fromChannel3(ensuring3(self.channel, finalizer)));
6214
6290
  var run = /* @__PURE__ */ dual(2, (self, sink) => scopedWith2((scope) => toPullScoped(self.channel, scope).pipe(flatMap4((upstream) => sink.transform(upstream, scope)), map7(([a]) => a))));
6215
6291
  var runCollect = (self) => runFold(self.channel, () => [], (acc, chunk) => {
@@ -6218,7 +6294,6 @@ var runCollect = (self) => runFold(self.channel, () => [], (acc, chunk) => {
6218
6294
  }
6219
6295
  return acc;
6220
6296
  });
6221
- var runForEachArray = /* @__PURE__ */ dual(2, (self, f) => runForEach(self.channel, f));
6222
6297
  var mkString = (self) => runFold(self.channel, () => "", (acc, chunk) => acc + chunk.join(""));
6223
6298
  var toReadableStreamWith = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, context, options) => {
6224
6299
  let currentResolve = undefined;
@@ -6229,14 +6304,14 @@ var toReadableStreamWith = /* @__PURE__ */ dual((args) => isStream(args[0]), (se
6229
6304
  const onAbort = () => fiber.interruptUnsafe();
6230
6305
  return new ReadableStream({
6231
6306
  start(controller) {
6232
- fiber = runFork2(provideContext2(runForEachArray(self, (chunk) => latch.whenOpen(sync2(() => {
6307
+ fiber = runFork2(provideContext2(runForEach(transformPull(self.channel, (pull) => succeed6(latch.whenOpen(pull))), (chunk) => sync2(() => {
6233
6308
  latch.closeUnsafe();
6234
6309
  for (let i = 0;i < chunk.length; i++) {
6235
6310
  controller.enqueue(chunk[i]);
6236
6311
  }
6237
6312
  currentResolve();
6238
6313
  currentResolve = undefined;
6239
- }))), context));
6314
+ })), context));
6240
6315
  fiber.addObserver((exit) => {
6241
6316
  signal?.removeEventListener("abort", onAbort);
6242
6317
  if (cancelled)
@@ -6546,7 +6621,7 @@ var defaultLeafHook = (issue) => {
6546
6621
  }
6547
6622
  }
6548
6623
  };
6549
- var defaultCheckHook = (issue) => findMessage(issue.issue) ?? findMessage(issue);
6624
+ var defaultCheckHook = (issue) => findMessage(issue) ?? findMessage(issue.issue);
6550
6625
  function formatInput(issue) {
6551
6626
  return hasInput(issue) ? format(issue.input) : undefined;
6552
6627
  }
@@ -6558,6 +6633,13 @@ function getExpectedMessage(expected, issue) {
6558
6633
  const input = formatInput(issue);
6559
6634
  return input === undefined ? `Expected ${expected}` : `Expected ${expected}, got ${input}`;
6560
6635
  }
6636
+ function getFilterMessage(issue, checkHook) {
6637
+ const message = checkHook(issue);
6638
+ if (message !== undefined || issue.issue._tag !== "InvalidValue")
6639
+ return message;
6640
+ const expected = findExpected(issue.issue);
6641
+ return expected === undefined ? getExpectedMessage(formatCheck(issue.filter), issue) : getExpectedMessage(expected, issue.issue);
6642
+ }
6561
6643
  function formatCheck(check) {
6562
6644
  const expected = check.annotations?.expected;
6563
6645
  if (typeof expected === "string")
@@ -6573,44 +6655,33 @@ function makeFormatterDefault() {
6573
6655
  return (issue) => formatIssue(issue, "");
6574
6656
  }
6575
6657
  var defaultFormatter = /* @__PURE__ */ makeFormatterDefault();
6576
- function formatIssue(issue, path) {
6658
+ function formatIssue(issue, path, messageOverride) {
6577
6659
  let message;
6578
6660
  switch (issue._tag) {
6579
- case "Filter": {
6580
- const annotated = defaultCheckHook(issue);
6581
- if (annotated !== undefined) {
6582
- message = annotated;
6583
- } else {
6584
- if (issue.issue._tag !== "InvalidValue") {
6585
- return formatIssue(issue.issue, path);
6586
- }
6587
- const expected = findExpected(issue.issue);
6588
- message = expected === undefined ? getExpectedMessage(formatCheck(issue.filter), issue) : getExpectedMessage(expected, issue.issue);
6589
- }
6590
- break;
6591
- }
6661
+ case "Filter":
6662
+ return formatIssue(issue.issue, path, messageOverride ?? getFilterMessage(issue, defaultCheckHook));
6592
6663
  case "Encoding":
6593
- return formatIssue(issue.issue, path);
6664
+ return formatIssue(issue.issue, path, messageOverride);
6594
6665
  case "Pointer":
6595
- return formatIssue(issue.issue, path + formatPath(issue.path));
6666
+ return formatIssue(issue.issue, path + formatPath(issue.path), messageOverride);
6596
6667
  case "Composite":
6597
6668
  case "AnyOf": {
6598
6669
  if (issue._tag === "Composite" || issue.issues.length > 0) {
6599
- return issue.issues.map((issue) => formatIssue(issue, path)).join(`
6670
+ return issue.issues.map((issue) => formatIssue(issue, path, messageOverride)).join(`
6600
6671
  `);
6601
6672
  }
6602
- message = findMessage(issue) ?? getExpectedMessage(getExpected(issue.ast), issue);
6673
+ message = messageOverride ?? findMessage(issue) ?? getExpectedMessage(getExpected(issue.ast), issue);
6603
6674
  break;
6604
6675
  }
6605
6676
  default:
6606
- message = defaultLeafHook(issue);
6677
+ message = messageOverride ?? defaultLeafHook(issue);
6607
6678
  break;
6608
6679
  }
6609
6680
  return path ? `${message}
6610
6681
  at ${path}` : message;
6611
6682
  }
6612
6683
  function findMessage(issue) {
6613
- if (issue._tag === "Pointer")
6684
+ if (issue._tag === "Pointer" || issue._tag === "Composite")
6614
6685
  return;
6615
6686
  if (issue._tag === "Encoding")
6616
6687
  return findMessage(issue.issue);
@@ -6962,7 +7033,12 @@ var Declaration = class extends ASTNodeImpl {
6962
7033
  return (input, options) => {
6963
7034
  if (input === missing)
6964
7035
  return missingExit;
6965
- return (run ??= this.run(this.typeParameters))(input, this, options);
7036
+ run ??= this.run(this.typeParameters);
7037
+ try {
7038
+ return run(input, this, options);
7039
+ } catch (error) {
7040
+ return die3(error);
7041
+ }
6966
7042
  };
6967
7043
  }
6968
7044
  _rebuild(recur, checks, encodingChecks, run, encodingRun) {
@@ -7187,7 +7263,7 @@ var Arrays = class extends ASTNodeImpl {
7187
7263
  input,
7188
7264
  len,
7189
7265
  tailThreshold: Math.max(elementLen, len - tailLen),
7190
- output: new globalThis.Array(len),
7266
+ output: [],
7191
7267
  issues: undefined,
7192
7268
  options
7193
7269
  };
@@ -7296,7 +7372,7 @@ var wrapPropertyKeyIssue = (s, ast, key, exit) => {
7296
7372
  return fail5(new Composite(ast, [pointer], s.input, s.options));
7297
7373
  }
7298
7374
  };
7299
- var FINITE_PATTERN = "[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?";
7375
+ var FINITE_PATTERN = "[+-]?(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:[Ee][+-]?\\d+)?";
7300
7376
  function getIndexSignatureKeys(input, parameter, options = defaultParseOptions) {
7301
7377
  let stringKeys;
7302
7378
  let symbolKeys;
@@ -7535,9 +7611,15 @@ var Objects = class extends ASTNodeImpl {
7535
7611
  if (indexCount)
7536
7612
  return makeFallback();
7537
7613
  let fallback;
7538
- const resume = (state, index, pending) => {
7614
+ const resume = (snapshot, index, pending) => {
7539
7615
  const property = properties[index];
7540
7616
  return flatMap4(exit2(pending), (exit) => {
7617
+ const state = {
7618
+ ...snapshot,
7619
+ out: {
7620
+ ...snapshot.out
7621
+ }
7622
+ };
7541
7623
  const terminal = stepProperty(state, property, exit);
7542
7624
  if (terminal)
7543
7625
  return terminal;
@@ -7667,9 +7749,6 @@ function struct(fields, checks, annotations) {
7667
7749
  function getAST(self) {
7668
7750
  return self.ast;
7669
7751
  }
7670
- function tuple(elements, checks = undefined) {
7671
- return new Arrays(false, elements.map((e) => e.ast), [], undefined, checks);
7672
- }
7673
7752
  function union(members, options, checks) {
7674
7753
  return new Union(members.map(getAST), options, undefined, checks);
7675
7754
  }
@@ -8588,7 +8667,7 @@ var makeHandle = (params) => Object.setPrototypeOf({
8588
8667
  ...params
8589
8668
  }, HandleProto);
8590
8669
  var make15 = (spawn) => {
8591
- const streamString = (command, options) => spawn(command).pipe(map7((handle) => decodeText(options?.includeStderr === true ? handle.all : handle.stdout)), unwrap4);
8670
+ const streamString = (command, options) => spawn(command).pipe(map7((handle) => decodeText2(options?.includeStderr === true ? handle.all : handle.stdout)), unwrap4);
8592
8671
  const streamLines = (command, options) => splitLines2(streamString(command, options));
8593
8672
  return ChildProcessSpawner.of({
8594
8673
  spawn,
@@ -8757,6 +8836,7 @@ var handleErrnoException = (module, method) => (err, [path]) => {
8757
8836
  reason = "NotFound";
8758
8837
  break;
8759
8838
  case "EACCES":
8839
+ case "EPERM":
8760
8840
  reason = "PermissionDenied";
8761
8841
  break;
8762
8842
  case "EEXIST":
@@ -8785,66 +8865,149 @@ var handleErrnoException = (module, method) => (err, [path]) => {
8785
8865
  });
8786
8866
  };
8787
8867
 
8868
+ // node_modules/@effect/platform-node-shared/dist/NodeSink.js
8869
+ import { finished } from "stream";
8870
+
8871
+ // node_modules/@effect/platform-node-shared/dist/internal/stream.js
8872
+ var destroyStream = (stream, cleanup, onDestroyed) => {
8873
+ if (!("closed" in stream)) {
8874
+ cleanup();
8875
+ onDestroyed?.();
8876
+ return;
8877
+ }
8878
+ const onDone = () => {
8879
+ clearImmediate(immediate);
8880
+ stream.off("error", onDone);
8881
+ stream.off("close", onDone);
8882
+ onDestroyed?.();
8883
+ };
8884
+ const onClosed = () => {
8885
+ if (stream.closed) {
8886
+ onDone();
8887
+ } else {
8888
+ immediate = setImmediate(onClosed);
8889
+ if (!onDestroyed)
8890
+ immediate.unref();
8891
+ }
8892
+ };
8893
+ let immediate = setImmediate(onClosed);
8894
+ if (!onDestroyed)
8895
+ immediate.unref();
8896
+ stream.once("error", onDone);
8897
+ stream.once("close", onDone);
8898
+ cleanup();
8899
+ if (!stream.closed) {
8900
+ stream.destroy();
8901
+ }
8902
+ };
8903
+
8788
8904
  // node_modules/@effect/platform-node-shared/dist/NodeSink.js
8789
8905
  var fromWritable = (options) => fromChannel2(mapDone(fromWritableChannel(options), (_) => [_]));
8790
8906
  var fromWritableChannel = (options) => fromTransform((pull) => {
8791
8907
  const writable = options.evaluate();
8792
- return succeed6(pullIntoWritable({
8908
+ const write = pullIntoWritable({
8793
8909
  ...options,
8794
8910
  writable,
8795
8911
  pull
8796
- }));
8797
- });
8798
- var pullIntoWritable = (options) => options.pull.pipe(flatMap4((chunk) => {
8799
- let i = 0;
8800
- return callback2((resume) => {
8801
- let cancelled = false;
8802
- const loop = () => {
8803
- for (;i < chunk.length; ) {
8804
- if (cancelled) {
8805
- return;
8806
- }
8807
- const success = options.writable.write(chunk[i++], options.encoding);
8808
- if (!success) {
8809
- if (!cancelled) {
8810
- options.writable.once("drain", loop);
8912
+ });
8913
+ return succeed6(options.endOnDone === false ? write : onError2(write, (cause) => isDoneCause(cause) ? void_3 : releaseWritable(writable)));
8914
+ });
8915
+ var releaseWritable = (writable) => callback2((resume) => {
8916
+ const onDestroyed = () => resume(void_3);
8917
+ if (writable.closed) {
8918
+ const cleanup = finished(writable, {
8919
+ readable: false
8920
+ }, () => {
8921
+ cleanup();
8922
+ onDestroyed();
8923
+ });
8924
+ } else {
8925
+ destroyStream(writable, constVoid, onDestroyed);
8926
+ }
8927
+ });
8928
+ var pullIntoWritable = (options) => withFiber2((fiber) => {
8929
+ const dispatcher = fiber.currentDispatcher;
8930
+ const completion = makeUnsafe2();
8931
+ const failure = makeUnsafe2();
8932
+ const onError = (error) => doneUnsafe(failure, failSync2(() => options.onError(error)));
8933
+ let errorEmitted = false;
8934
+ const onStreamError = (error) => {
8935
+ errorEmitted = true;
8936
+ onError(error);
8937
+ };
8938
+ options.writable.on("error", onStreamError);
8939
+ const cleanup = finished(options.writable, {
8940
+ readable: false
8941
+ }, (error) => {
8942
+ if (error) {
8943
+ onError(error);
8944
+ } else {
8945
+ doneUnsafe(completion, void_3);
8946
+ }
8947
+ });
8948
+ return options.pull.pipe(flatMap4((chunk) => {
8949
+ let i = 0;
8950
+ return callback2((resume) => {
8951
+ let cancelled = false;
8952
+ const onFinish = () => dispatcher.scheduleTask(loop, 0);
8953
+ const loop = () => {
8954
+ options.writable.off("drain", loop);
8955
+ options.writable.off("finish", onFinish);
8956
+ for (;i < chunk.length; ) {
8957
+ if (cancelled) {
8958
+ return;
8959
+ }
8960
+ const success = options.writable.write(chunk[i++], options.encoding, (error) => {
8961
+ if (!error)
8962
+ return;
8963
+ if (options.writable.closed) {
8964
+ onError(error);
8965
+ } else {
8966
+ dispatcher.scheduleTask(() => onError(error), 0);
8967
+ }
8968
+ });
8969
+ if (!success) {
8970
+ if (!cancelled) {
8971
+ options.writable.once("drain", loop);
8972
+ options.writable.once("finish", onFinish);
8973
+ }
8974
+ return;
8811
8975
  }
8812
- return;
8813
8976
  }
8814
- }
8815
- if (!cancelled) {
8816
- resume(void_3);
8817
- }
8818
- };
8819
- loop();
8820
- return sync2(() => {
8821
- cancelled = true;
8822
- options.writable.off("drain", loop);
8977
+ if (!cancelled) {
8978
+ resume(void_3);
8979
+ }
8980
+ };
8981
+ loop();
8982
+ return sync2(() => {
8983
+ cancelled = true;
8984
+ options.writable.off("drain", loop);
8985
+ options.writable.off("finish", onFinish);
8986
+ });
8823
8987
  });
8824
- });
8825
- }), forever3({
8826
- disableYield: true
8827
- }), options.endOnDone !== false ? catchDone((_) => {
8828
- if ("closed" in options.writable && options.writable.closed) {
8829
- return done2(_);
8830
- }
8831
- return callback2((resume) => {
8832
- const onFinish = () => resume(done2(_));
8833
- options.writable.once("finish", onFinish);
8988
+ }), forever3({
8989
+ disableYield: true
8990
+ }), options.endOnDone !== false ? catchDone((_) => {
8834
8991
  options.writable.end();
8835
- return sync2(() => {
8836
- options.writable.off("finish", onFinish);
8837
- });
8838
- });
8839
- }) : identity, raceFirst2(callback2((resume) => {
8840
- const onError = (error) => resume(fail6(options.onError(error)));
8841
- options.writable.once("error", onError);
8842
- return sync2(() => {
8843
- options.writable.off("error", onError);
8844
- });
8845
- })));
8992
+ return andThen2(_await(completion), done2(_));
8993
+ }) : identity, raceFirst2(_await(failure)), ensuring2(sync2(() => {
8994
+ cleanup();
8995
+ const removeErrorListener = () => {
8996
+ options.writable.off("error", onStreamError);
8997
+ options.writable.off("error", removeErrorListener);
8998
+ options.writable.off("close", removeErrorListener);
8999
+ };
9000
+ if (options.writable.errored && !options.writable.closed && !errorEmitted) {
9001
+ options.writable.once("error", removeErrorListener);
9002
+ options.writable.once("close", removeErrorListener);
9003
+ } else {
9004
+ removeErrorListener();
9005
+ }
9006
+ })));
9007
+ });
8846
9008
 
8847
9009
  // node_modules/@effect/platform-node-shared/dist/NodeStream.js
9010
+ import { finished as finished2, Readable } from "stream";
8848
9011
  var fromReadable = (options) => fromChannel3(fromReadableChannel(options));
8849
9012
  var fromReadableChannel = (options) => fromTransform((_, scope) => readableToPullUnsafe({
8850
9013
  scope,
@@ -8861,17 +9024,14 @@ var readableToPullUnsafe = (options) => {
8861
9024
  function onReadable() {
8862
9025
  latch.openUnsafe();
8863
9026
  }
8864
- function onError(error) {
8865
- exit.current = fail5(options.onError(error));
8866
- latch.openUnsafe();
8867
- }
8868
- function onEnd() {
8869
- exit.current = fail5(Done2());
8870
- latch.openUnsafe();
8871
- }
8872
9027
  readable.on("readable", onReadable);
8873
- readable.once("error", onError);
8874
- readable.once("end", onEnd);
9028
+ const cleanup = finished2(readable, {
9029
+ readable: true,
9030
+ writable: false
9031
+ }, (error) => {
9032
+ exit.current ??= fail5(error ? options.onError(error) : Done2());
9033
+ latch.openUnsafe();
9034
+ });
8875
9035
  const pull = suspend2(function loop() {
8876
9036
  let item = options.readable.read(options.chunkSize);
8877
9037
  if (item === null) {
@@ -8895,10 +9055,10 @@ var readableToPullUnsafe = (options) => {
8895
9055
  });
8896
9056
  return as2(addFinalizer2(options.scope, sync2(() => {
8897
9057
  readable.off("readable", onReadable);
8898
- readable.off("error", onError);
8899
- readable.off("end", onEnd);
8900
- if (closeOnDone && "closed" in options.readable && !options.readable.closed) {
8901
- options.readable.destroy();
9058
+ if (closeOnDone) {
9059
+ destroyStream(readable, cleanup);
9060
+ } else {
9061
+ cleanup();
8902
9062
  }
8903
9063
  })), pull);
8904
9064
  };
@@ -9223,6 +9383,7 @@ var make17 = /* @__PURE__ */ gen2(function* () {
9223
9383
  const signalGroup = (signal) => killProcessGroup(command, childProcess, signal).pipe(catch_2(() => killProcess(command, childProcess, signal)));
9224
9384
  yield* signalGroup(options?.killSignal ?? "SIGTERM");
9225
9385
  if (isUndefined(options?.forceKillAfter)) {
9386
+ yield* _await(exitSignal);
9226
9387
  yield* awaitProcessExit(childProcess, exitSignal, processGroupGraceMillis);
9227
9388
  } else {
9228
9389
  yield* awaitProcessExit(childProcess, exitSignal, toMillis(options.forceKillAfter));
@@ -9469,10 +9630,14 @@ var ulidString = (timestampMillis, bytes) => {
9469
9630
  };
9470
9631
 
9471
9632
  // node_modules/effect/dist/internal/uuid.js
9472
- var hex = (byte) => byte.toString(16).padStart(2, "0");
9633
+ var hex = /* @__PURE__ */ Array.from({
9634
+ length: 256
9635
+ }, (_, byte) => byte.toString(16).padStart(2, "0"));
9473
9636
  var stringify = (bytes) => {
9474
- const segments = [bytes.subarray(0, 4), bytes.subarray(4, 6), bytes.subarray(6, 8), bytes.subarray(8, 10), bytes.subarray(10, 16)];
9475
- return segments.map((segment) => Array.from(segment, hex).join("")).join("-");
9637
+ if (bytes.length < 16) {
9638
+ return [bytes.subarray(0, 4), bytes.subarray(4, 6), bytes.subarray(6, 8), bytes.subarray(8, 10), bytes.subarray(10, 16)].map((segment) => Array.from(segment, (byte) => hex[byte]).join("")).join("-");
9639
+ }
9640
+ return hex[bytes[0]] + hex[bytes[1]] + hex[bytes[2]] + hex[bytes[3]] + "-" + hex[bytes[4]] + hex[bytes[5]] + "-" + hex[bytes[6]] + hex[bytes[7]] + "-" + hex[bytes[8]] + hex[bytes[9]] + "-" + hex[bytes[10]] + hex[bytes[11]] + hex[bytes[12]] + hex[bytes[13]] + hex[bytes[14]] + hex[bytes[15]];
9476
9641
  };
9477
9642
  var randomBytes = () => globalThis.crypto.getRandomValues(new Uint8Array(16));
9478
9643
  function v4Bytes(bytes = randomBytes()) {
@@ -9933,14 +10098,14 @@ var readLink = /* @__PURE__ */ (() => {
9933
10098
  return (path) => nodeReadLink(path);
9934
10099
  })();
9935
10100
  var realPath = /* @__PURE__ */ (() => {
9936
- const nodeRealPath = /* @__PURE__ */ effectify(NFS.realpath, /* @__PURE__ */ handleErrnoException("FileSystem", "realPath"), /* @__PURE__ */ handleBadArgument("realPath"));
10101
+ const nodeRealPath = /* @__PURE__ */ effectify(process.platform === "win32" ? NFS.realpath.native : NFS.realpath, /* @__PURE__ */ handleErrnoException("FileSystem", "realPath"), /* @__PURE__ */ handleBadArgument("realPath"));
9937
10102
  return (path) => nodeRealPath(path);
9938
10103
  })();
9939
10104
  var rename2 = /* @__PURE__ */ (() => {
9940
10105
  const nodeRename = /* @__PURE__ */ effectify(NFS.rename, /* @__PURE__ */ handleErrnoException("FileSystem", "rename"), /* @__PURE__ */ handleBadArgument("rename"));
9941
10106
  return (oldPath, newPath) => nodeRename(oldPath, newPath);
9942
10107
  })();
9943
- var makeFileInfo = (stat) => try_3({
10108
+ var makeFileInfo = (stat, method = "stat") => try_3({
9944
10109
  try: () => ({
9945
10110
  type: stat.isFile() ? "File" : stat.isDirectory() ? "Directory" : stat.isSymbolicLink() ? "SymbolicLink" : stat.isBlockDevice() ? "BlockDevice" : stat.isCharacterDevice() ? "CharacterDevice" : stat.isFIFO() ? "FIFO" : stat.isSocket() ? "Socket" : "Unknown",
9946
10111
  mtime: fromNullishOr(stat.mtime),
@@ -9957,14 +10122,16 @@ var makeFileInfo = (stat) => try_3({
9957
10122
  blksize: stat.blksize !== undefined ? some2(bytes(stat.blksize)) : none2(),
9958
10123
  blocks: fromNullishOr(stat.blocks)
9959
10124
  }),
9960
- catch: handleBadArgument("stat")
10125
+ catch: handleBadArgument(method)
9961
10126
  });
9962
- var stat2 = /* @__PURE__ */ (() => {
9963
- const nodeStat = /* @__PURE__ */ effectify(NFS.stat, /* @__PURE__ */ handleErrnoException("FileSystem", "stat"), /* @__PURE__ */ handleBadArgument("stat"));
10127
+ var statFactory = (method, nodeStatFn) => {
10128
+ const nodeStat = effectify(nodeStatFn, handleErrnoException("FileSystem", method), handleBadArgument(method));
9964
10129
  return (path) => flatMap4(nodeStat(path, {
9965
10130
  bigint: true
9966
- }), makeFileInfo);
9967
- })();
10131
+ }), (stat) => makeFileInfo(stat, method));
10132
+ };
10133
+ var stat2 = /* @__PURE__ */ statFactory("stat", NFS.stat);
10134
+ var lstat2 = /* @__PURE__ */ statFactory("lstat", NFS.lstat);
9968
10135
  var symlink2 = /* @__PURE__ */ (() => {
9969
10136
  const nodeSymlink = /* @__PURE__ */ effectify(NFS.symlink, /* @__PURE__ */ handleErrnoException("FileSystem", "symlink"), /* @__PURE__ */ handleBadArgument("symlink"));
9970
10137
  return (target, path) => nodeSymlink(target, path);
@@ -10047,6 +10214,7 @@ var makeFileSystem = /* @__PURE__ */ map7(/* @__PURE__ */ serviceOption2(WatchBa
10047
10214
  copyFile: copyFile2,
10048
10215
  glob: glob2,
10049
10216
  link: link2,
10217
+ lstat: lstat2,
10050
10218
  makeDirectory,
10051
10219
  makeTempDirectory,
10052
10220
  makeTempDirectoryScoped,
@@ -10662,6 +10830,16 @@ var CurrentRedactedNames2 = /* @__PURE__ */ Reference("effect/http/UrlParams/Cur
10662
10830
  // node_modules/effect/dist/internal/schema/interpreter.js
10663
10831
  var flatMapTransformation = (result, current, f) => result === sameExit ? f(current) : flatMapEager2(result, f);
10664
10832
  function compileTransformation(transformation) {
10833
+ const apply = compileTransformationUnsafe(transformation);
10834
+ return (result, current, options) => {
10835
+ try {
10836
+ return apply(result, current, options);
10837
+ } catch (error) {
10838
+ return die3(error);
10839
+ }
10840
+ };
10841
+ }
10842
+ function compileTransformationUnsafe(transformation) {
10665
10843
  if (transformation._tag === "Middleware") {
10666
10844
  return (result, current, options) => {
10667
10845
  const transformed = result === sameExit ? transformation.decode(succeed8(toOption2(current)), options) : transformation.decode(mapEager2(result, toOption2), options);
@@ -10737,53 +10915,57 @@ function compile(ast, compile, compileField, base, specialize) {
10737
10915
  let encodingParsers;
10738
10916
  const parseChecks = (input, options) => {
10739
10917
  let result = parser(input, options);
10740
- if (encodingChecks && !options.disableChecks) {
10741
- if (effectIsExit(result)) {
10742
- if (result._tag === "Success") {
10743
- const output = result === sameExit ? input : result[args];
10744
- if (input !== missing && output !== missing) {
10745
- const issues = collectIssues(encodingChecks, input, undefined, ast, options);
10746
- if (issues) {
10747
- result = fail6(new Composite(ast, issues, input, options));
10918
+ try {
10919
+ if (encodingChecks && !options.disableChecks) {
10920
+ if (effectIsExit(result)) {
10921
+ if (result._tag === "Success") {
10922
+ const output = result === sameExit ? input : result[args];
10923
+ if (input !== missing && output !== missing) {
10924
+ const issues = collectIssues(encodingChecks, input, undefined, ast, options);
10925
+ if (issues) {
10926
+ result = fail6(new Composite(ast, issues, input, options));
10927
+ }
10748
10928
  }
10749
10929
  }
10750
- }
10751
- } else {
10752
- result = flatMap4(result, (value) => {
10753
- if (input !== missing && value !== missing) {
10754
- const issues = collectIssues(encodingChecks, input, undefined, ast, options);
10755
- if (issues) {
10756
- return fail6(new Composite(ast, issues, input, options));
10930
+ } else {
10931
+ result = flatMap4(result, (value) => {
10932
+ if (input !== missing && value !== missing) {
10933
+ const issues = collectIssues(encodingChecks, input, undefined, ast, options);
10934
+ if (issues) {
10935
+ return fail6(new Composite(ast, issues, input, options));
10936
+ }
10757
10937
  }
10758
- }
10759
- return succeed6(value);
10760
- });
10761
- }
10762
- }
10763
- if (checks && !options.disableChecks) {
10764
- if (effectIsExit(result)) {
10765
- if (result._tag === "Success") {
10766
- const value = result === sameExit ? input : result[args];
10767
- if (value === missing)
10768
- return result;
10769
- const issues = collectIssues(checks, value, undefined, ast, options);
10770
- if (issues) {
10771
- result = fail6(new Composite(ast, issues, value, options));
10772
- }
10938
+ return succeed6(value);
10939
+ });
10773
10940
  }
10774
- } else {
10775
- result = flatMap4(result, (value) => {
10776
- if (value !== missing) {
10941
+ }
10942
+ if (checks && !options.disableChecks) {
10943
+ if (effectIsExit(result)) {
10944
+ if (result._tag === "Success") {
10945
+ const value = result === sameExit ? input : result[args];
10946
+ if (value === missing)
10947
+ return result;
10777
10948
  const issues = collectIssues(checks, value, undefined, ast, options);
10778
10949
  if (issues) {
10779
- return fail6(new Composite(ast, issues, value, options));
10950
+ result = fail6(new Composite(ast, issues, value, options));
10780
10951
  }
10781
10952
  }
10782
- return succeed6(value);
10783
- });
10953
+ } else {
10954
+ result = flatMap4(result, (value) => {
10955
+ if (value !== missing) {
10956
+ const issues = collectIssues(checks, value, undefined, ast, options);
10957
+ if (issues) {
10958
+ return fail6(new Composite(ast, issues, value, options));
10959
+ }
10960
+ }
10961
+ return succeed6(value);
10962
+ });
10963
+ }
10784
10964
  }
10965
+ return result;
10966
+ } catch (error) {
10967
+ return die3(error);
10785
10968
  }
10786
- return result;
10787
10969
  };
10788
10970
  const parseLocal = specialize === undefined ? parseChecks : specialize(parseChecks);
10789
10971
  if (!links) {
@@ -11155,6 +11337,14 @@ function toCodecJson(schema) {
11155
11337
  });
11156
11338
  }
11157
11339
  var toCodecJsonAST = /* @__PURE__ */ applyToSelfOrLastLinkEncodingIdempotent((ast) => {
11340
+ const owner = getContextOwner(ast);
11341
+ if (owner !== ast) {
11342
+ const fromOwner = toCodecJsonAST(owner);
11343
+ if (fromOwner === owner)
11344
+ return ast;
11345
+ if (fromOwner.encoding === undefined)
11346
+ return replaceContext(fromOwner, ast.context);
11347
+ }
11158
11348
  const out = toCodecJsonASTStep(ast, toCodecJsonAST);
11159
11349
  const context = ast.context;
11160
11350
  if (out === ast || context === undefined)
@@ -11421,18 +11611,6 @@ function makeStruct(ast, fields) {
11421
11611
  function Struct(fields) {
11422
11612
  return makeStruct(struct(fields, undefined), fields);
11423
11613
  }
11424
- function makeTuple(ast, elements) {
11425
- return make26(ast, {
11426
- elements,
11427
- mapElements(f, options) {
11428
- const elements = f(this.elements);
11429
- return makeTuple(tuple(elements, options?.unsafePreserveChecks ? this.ast.checks : undefined), elements);
11430
- }
11431
- });
11432
- }
11433
- function Tuple2(elements) {
11434
- return makeTuple(tuple(elements), elements);
11435
- }
11436
11614
  var ArraySchema = /* @__PURE__ */ lambda((schema) => make26(new Arrays(false, [], [schema.ast]), {
11437
11615
  value: schema
11438
11616
  }));
@@ -11509,32 +11687,24 @@ function link3() {
11509
11687
  };
11510
11688
  }
11511
11689
  var makeFilter2 = makeFilter;
11512
- function isPattern2(regExp, annotations) {
11513
- const source = regExp.source;
11514
- const flags = regExp.flags;
11515
- const canExport = /^[dg]*uy?$/.test(flags);
11516
- const runtimeRegExp = flags === "" ? `new RegExp(${format(source)})` : `new RegExp(${format(source)}, ${format(flags)})`;
11517
- return isPattern(regExp, {
11518
- toJsonSchema: () => canExport ? {
11519
- pattern: flags.endsWith("y") ? `^(?:${source})` : source
11520
- } : [{}, true],
11521
- toCode: () => ({
11522
- runtime: `Schema.isPattern(${runtimeRegExp})`
11523
- }),
11524
- ...annotations
11525
- });
11526
- }
11527
11690
  function isBase64(annotations) {
11528
- const regExp = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
11529
- return isPattern2(regExp, {
11691
+ const pattern = "^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$";
11692
+ const regExp = /^[0-9a-zA-Z+/]*={0,2}$/;
11693
+ return makeFilter2((s) => s.length % 4 === 0 && regExp.test(s), {
11530
11694
  expected: "a base64 encoded string",
11531
11695
  representation: {
11532
11696
  id: "effect/schema/isBase64",
11533
11697
  payload: null
11534
11698
  },
11535
11699
  toJsonSchema: () => ({
11536
- pattern: regExp.source
11700
+ pattern
11537
11701
  }),
11702
+ arbitraryConstraint: {
11703
+ patterns: [{
11704
+ source: pattern,
11705
+ flags: ""
11706
+ }]
11707
+ },
11538
11708
  toCode: () => ({
11539
11709
  runtime: "Schema.isBase64()"
11540
11710
  }),
@@ -11686,47 +11856,6 @@ var File = /* @__PURE__ */ instanceOf(globalThis.File, {
11686
11856
  })
11687
11857
  }))
11688
11858
  });
11689
- var FormData2 = /* @__PURE__ */ instanceOf(globalThis.FormData, {
11690
- representation: {
11691
- id: "effect/schema/FormData",
11692
- payload: null
11693
- },
11694
- toCode: () => ({
11695
- runtime: `Schema.FormData`,
11696
- Type: `globalThis.FormData`
11697
- }),
11698
- expected: "FormData",
11699
- toCodecJson: () => link3()(ArraySchema(Tuple2([String4, Union2([Struct({
11700
- _tag: tag("String"),
11701
- value: String4
11702
- }), Struct({
11703
- _tag: tag("File"),
11704
- value: File
11705
- })])])), transformEffect2({
11706
- decode: (e) => {
11707
- const out = new globalThis.FormData;
11708
- for (const [key, entry] of e) {
11709
- out.append(key, entry.value);
11710
- }
11711
- return succeed6(out);
11712
- },
11713
- encode: (formData) => {
11714
- return succeed6(globalThis.Array.from(formData.entries()).map(([key, value]) => {
11715
- if (typeof value === "string") {
11716
- return [key, {
11717
- _tag: "String",
11718
- value
11719
- }];
11720
- } else {
11721
- return [key, {
11722
- _tag: "File",
11723
- value
11724
- }];
11725
- }
11726
- }));
11727
- }
11728
- }))
11729
- });
11730
11859
  var URLSearchParams2 = /* @__PURE__ */ instanceOf(globalThis.URLSearchParams, {
11731
11860
  representation: {
11732
11861
  id: "effect/schema/URLSearchParams",
@@ -11892,13 +12021,16 @@ function makeClass(Inherited, identifier, struct2, annotations, proto) {
11892
12021
  }
11893
12022
  return out;
11894
12023
  }
11895
- function getClassTransformation(self) {
11896
- return new Transformation(transform((input) => new self(input, {
12024
+ function makeClassTrusted(self, fields) {
12025
+ return new self(fields, {
11897
12026
  "~payload": {
11898
12027
  token: payloadToken,
11899
- value: input
12028
+ value: fields
11900
12029
  }
11901
- })), passthrough2());
12030
+ });
12031
+ }
12032
+ function getClassTransformation(self) {
12033
+ return new Transformation(transform((input) => makeClassTrusted(self, input)), passthrough2());
11902
12034
  }
11903
12035
  function getClassTypeId(identifier) {
11904
12036
  return `~effect/Schema/Class/${identifier}`;
@@ -12006,9 +12138,6 @@ var make28 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu
12006
12138
  readline.emitKeypressEvents(stdin, rl);
12007
12139
  rl.on("line", onLine);
12008
12140
  rl.once("close", onClose);
12009
- if (stdin.isTTY) {
12010
- stdin.setRawMode(true);
12011
- }
12012
12141
  return {
12013
12142
  rl,
12014
12143
  onClose,
@@ -12022,9 +12151,6 @@ var make28 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu
12022
12151
  readlineActive = false;
12023
12152
  rl.off("line", onLine);
12024
12153
  rl.off("close", onClose);
12025
- if (stdin.isTTY) {
12026
- stdin.setRawMode(false);
12027
- }
12028
12154
  rl.close();
12029
12155
  if (inputEnded) {
12030
12156
  endUnsafe(lines);
@@ -12032,6 +12158,14 @@ var make28 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu
12032
12158
  })),
12033
12159
  idleTimeToLive: "10 millis"
12034
12160
  });
12161
+ const setRawMode = (enabled) => sync2(() => {
12162
+ if (stdin.isTTY)
12163
+ stdin.setRawMode(enabled);
12164
+ });
12165
+ const rawModeRef = yield* make11({
12166
+ acquire: acquireRelease2(setRawMode(true), () => setRawMode(false)),
12167
+ idleTimeToLive: "10 millis"
12168
+ });
12035
12169
  const columns = sync2(() => stdout.columns ?? 0);
12036
12170
  const rows = sync2(() => stdout.rows ?? 0);
12037
12171
  const readInput = gen2(function* () {
@@ -12066,6 +12200,7 @@ var make28 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu
12066
12200
  handleEnd();
12067
12201
  } else {
12068
12202
  yield* get3(rlRef);
12203
+ yield* get3(rawModeRef);
12069
12204
  stdin.once("end", handleEnd);
12070
12205
  }
12071
12206
  return queue;
@@ -12304,7 +12439,6 @@ var toConfigCursorAST = /* @__PURE__ */ memoize((root) => {
12304
12439
  seen.add(ast);
12305
12440
  switch (ast._tag) {
12306
12441
  case "Objects": {
12307
- const matchesIndex = ast.indexSignatures.map((is) => _is(is.parameter));
12308
12442
  const materialize = fnUntraced2(function* (cursor) {
12309
12443
  if (cursor.node?._tag !== "Record") {
12310
12444
  return;
@@ -12315,10 +12449,16 @@ var toConfigCursorAST = /* @__PURE__ */ memoize((root) => {
12315
12449
  if (typeof property.name === "string")
12316
12450
  keys.add(property.name);
12317
12451
  }
12318
- if (matchesIndex.length > 0) {
12452
+ if (ast.indexSignatures.length > 0) {
12453
+ const input = {};
12319
12454
  for (const key of node.keys) {
12320
- if (matchesIndex.some((matches) => matches(key)))
12321
- keys.add(key);
12455
+ assignProperty(input, key, undefined);
12456
+ }
12457
+ for (const is of ast.indexSignatures) {
12458
+ for (const key of getIndexSignatureKeys(input, is.parameter)) {
12459
+ if (typeof key === "string")
12460
+ keys.add(key);
12461
+ }
12322
12462
  }
12323
12463
  }
12324
12464
  const out = {};
@@ -12610,6 +12750,12 @@ class UnknownSubcommand extends (/* @__PURE__ */ TaggedError3(`${TypeId33}/Unkno
12610
12750
  }
12611
12751
  }
12612
12752
 
12753
+ class ValidationError extends (/* @__PURE__ */ TaggedError3(`${TypeId33}/ValidationError`)("ValidationError", {
12754
+ message: String4
12755
+ })) {
12756
+ [TypeId33] = TypeId33;
12757
+ }
12758
+
12613
12759
  class UserError extends (/* @__PURE__ */ TaggedError3(`${TypeId33}/UserError`)("UserError", {
12614
12760
  cause: /* @__PURE__ */ Defect(),
12615
12761
  userMessage: /* @__PURE__ */ optionalKey2(String4)
@@ -12626,7 +12772,7 @@ class UserError extends (/* @__PURE__ */ TaggedError3(`${TypeId33}/UserError`)("
12626
12772
  return "An error occurred";
12627
12773
  }
12628
12774
  }
12629
- var NonShowHelpErrors = /* @__PURE__ */ Union2([UnrecognizedOption, DuplicateOption, MissingOption, MissingArgument, UnexpectedArgument, InvalidValue2, UnknownSubcommand, UserError]);
12775
+ var NonShowHelpErrors = /* @__PURE__ */ Union2([UnrecognizedOption, DuplicateOption, MissingOption, MissingArgument, UnexpectedArgument, InvalidValue2, UnknownSubcommand, ValidationError, UserError]);
12630
12776
 
12631
12777
  class ShowHelp extends (/* @__PURE__ */ TaggedError3(`${TypeId33}/ShowHelp`)("ShowHelp", {
12632
12778
  commandPath: /* @__PURE__ */ ArraySchema(String4),
@@ -14712,229 +14858,6 @@ var getParamMetadata = (param) => {
14712
14858
  })
14713
14859
  });
14714
14860
  };
14715
- // node_modules/effect/dist/cli/CliOutput.js
14716
- var Formatter = /* @__PURE__ */ Reference("effect/cli/CliOutput", {
14717
- defaultValue: () => defaultFormatter2()
14718
- });
14719
- var escapeControlCharacters = (text) => text.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g, (character) => `\\x${character.charCodeAt(0).toString(16).padStart(2, "0")}`);
14720
- var defaultFormatter2 = (options) => {
14721
- const useColor = options?.colors ?? detectColors();
14722
- const colors = useColor ? {
14723
- bold: (text) => `\x1B[1m${text}\x1B[0m`,
14724
- dim: (text) => `\x1B[2m${text}\x1B[0m`,
14725
- cyan: (text) => `\x1B[36m${text}\x1B[0m`,
14726
- green: (text) => `\x1B[32m${text}\x1B[0m`,
14727
- blue: (text) => `\x1B[34m${text}\x1B[0m`,
14728
- yellow: (text) => `\x1B[33m${text}\x1B[0m`,
14729
- magenta: (text) => `\x1B[35m${text}\x1B[0m`
14730
- } : {
14731
- bold: (text) => text,
14732
- dim: (text) => text,
14733
- cyan: (text) => text,
14734
- green: (text) => text,
14735
- blue: (text) => text,
14736
- yellow: (text) => text,
14737
- magenta: (text) => text
14738
- };
14739
- const reset = useColor ? "\x1B[0m" : "";
14740
- const red = useColor ? "\x1B[31m" : "";
14741
- const bold = useColor ? "\x1B[1m" : "";
14742
- return {
14743
- formatHelpDoc: (doc) => formatHelpDocImpl(doc, colors),
14744
- formatCliError: (error) => escapeControlCharacters(error.message),
14745
- formatError: (error) => {
14746
- return `
14747
- ${bold}${red}ERROR${reset}
14748
- ${escapeControlCharacters(error.message)}${reset}`;
14749
- },
14750
- formatErrors: (errors) => {
14751
- if (errors.length === 0)
14752
- return "";
14753
- if (errors.length === 1) {
14754
- return `
14755
- ${bold}${red}ERROR${reset}
14756
- ${escapeControlCharacters(errors[0].message)}${reset}`;
14757
- }
14758
- const grouped = new Map;
14759
- for (const error of errors) {
14760
- const tag = error._tag ?? "Error";
14761
- const group = grouped.get(tag) ?? [];
14762
- group.push(error);
14763
- grouped.set(tag, group);
14764
- }
14765
- const sections = [];
14766
- sections.push(`
14767
- ${bold}${red}ERRORS${reset}`);
14768
- for (const [, group] of grouped) {
14769
- for (const error of group) {
14770
- sections.push(` ${escapeControlCharacters(error.message)}${reset}`);
14771
- }
14772
- }
14773
- return sections.join(`
14774
- `);
14775
- },
14776
- formatVersion: (name, version) => `${colors.bold(name)} ${colors.dim("v")}${colors.bold(version)}`
14777
- };
14778
- };
14779
- var stripAnsi = (text) => {
14780
- return text.replace(/\u001B\[[0-9;]*m/g, "");
14781
- };
14782
- var graphemeSegmenter = /* @__PURE__ */ new Intl.Segmenter(undefined, {
14783
- granularity: "grapheme"
14784
- });
14785
- var zeroWidthCodePoints = /[\p{Mark}\p{Control}\p{Default_Ignorable_Code_Point}]/gu;
14786
- var emojiPresentation = /\p{Emoji_Presentation}/u;
14787
- var isFullWidthCodePoint = (codePoint) => {
14788
- if (codePoint < 4352)
14789
- return false;
14790
- return codePoint <= 4447 || codePoint === 9001 || codePoint === 9002 || codePoint >= 11904 && codePoint <= 12350 || codePoint >= 12352 && codePoint <= 42191 || codePoint >= 44032 && codePoint <= 55203 || codePoint >= 63744 && codePoint <= 64255 || codePoint >= 65040 && codePoint <= 65049 || codePoint >= 65072 && codePoint <= 65135 || codePoint >= 65280 && codePoint <= 65376 || codePoint >= 65504 && codePoint <= 65510 || codePoint >= 110592 && codePoint <= 111359 || codePoint >= 127488 && codePoint <= 127569 || codePoint >= 131072 && codePoint <= 262141;
14791
- };
14792
- var graphemeWidth = (grapheme) => {
14793
- const visible = grapheme.replace(zeroWidthCodePoints, "");
14794
- if (visible.length === 0)
14795
- return 0;
14796
- if (emojiPresentation.test(grapheme) || grapheme.includes("\uFE0F"))
14797
- return 2;
14798
- return isFullWidthCodePoint(visible.codePointAt(0)) ? 2 : 1;
14799
- };
14800
- var displayWidth = (text) => {
14801
- let length = 0;
14802
- for (const {
14803
- segment
14804
- } of graphemeSegmenter.segment(stripAnsi(text))) {
14805
- length += graphemeWidth(segment);
14806
- }
14807
- return length;
14808
- };
14809
- var pad = (s, width) => {
14810
- const actualLength = displayWidth(s);
14811
- const padding = Math.max(0, width - actualLength);
14812
- return s + " ".repeat(padding);
14813
- };
14814
- var renderTable = (rows, widthCap) => {
14815
- const maxColumn = Math.max(...rows.map((r) => displayWidth(r.left))) + 4;
14816
- const col = widthCap === undefined ? maxColumn : Math.min(maxColumn, widthCap);
14817
- return rows.map(({
14818
- left,
14819
- right
14820
- }) => ` ${pad(left, Math.max(col, displayWidth(left) + 1))}${right}`).join(`
14821
- `);
14822
- };
14823
- var formatSubcommandName = (name, alias) => alias ? `${name}, ${alias}` : name;
14824
- var formatHelpDocImpl = (doc, colors) => {
14825
- const sections = [];
14826
- if (doc.description) {
14827
- sections.push(colors.bold("DESCRIPTION"));
14828
- sections.push(` ${doc.description}`);
14829
- sections.push("");
14830
- }
14831
- sections.push(colors.bold("USAGE"));
14832
- sections.push(` ${colors.cyan(doc.usage)}`);
14833
- sections.push("");
14834
- if (doc.args && doc.args.length > 0) {
14835
- sections.push(colors.bold("ARGUMENTS"));
14836
- const argRows = doc.args.map((arg) => {
14837
- let name = arg.name;
14838
- if (arg.variadic) {
14839
- name += "...";
14840
- }
14841
- const coloredName = colors.green(name);
14842
- const coloredType = colors.dim(arg.type);
14843
- const nameType = `${coloredName} ${coloredType}`;
14844
- const optionalSuffix = arg.required ? "" : colors.dim(" (optional)");
14845
- const description = getOrElse(arg.description, () => "") + optionalSuffix;
14846
- return {
14847
- left: nameType,
14848
- right: description
14849
- };
14850
- });
14851
- sections.push(renderTable(argRows, 25));
14852
- sections.push("");
14853
- }
14854
- if (doc.flags.length > 0) {
14855
- sections.push(colors.bold("FLAGS"));
14856
- const flagRows = doc.flags.map((flag) => {
14857
- const names = [];
14858
- names.push(colors.green(`--${flag.name}`));
14859
- for (const alias of flag.aliases) {
14860
- names.push(colors.green(alias));
14861
- }
14862
- const namesPart = names.join(", ");
14863
- const typePart = flag.type !== "boolean" ? ` ${colors.dim(flag.type)}` : "";
14864
- return {
14865
- left: namesPart + typePart,
14866
- right: getOrElse(flag.description, () => "")
14867
- };
14868
- });
14869
- sections.push(renderTable(flagRows));
14870
- sections.push("");
14871
- }
14872
- if (doc.globalFlags && doc.globalFlags.length > 0) {
14873
- sections.push(colors.bold("GLOBAL FLAGS"));
14874
- const globalFlagRows = doc.globalFlags.map((flag) => {
14875
- const names = [];
14876
- names.push(colors.green(`--${flag.name}`));
14877
- for (const alias of flag.aliases) {
14878
- names.push(colors.green(alias));
14879
- }
14880
- const namesPart = names.join(", ");
14881
- const typePart = flag.type !== "boolean" ? ` ${colors.dim(flag.type)}` : "";
14882
- return {
14883
- left: namesPart + typePart,
14884
- right: getOrElse(flag.description, () => "")
14885
- };
14886
- });
14887
- sections.push(renderTable(globalFlagRows));
14888
- sections.push("");
14889
- }
14890
- if (doc.subcommands && doc.subcommands.length > 0) {
14891
- const ungrouped = doc.subcommands.find((group) => group.group === undefined);
14892
- if (ungrouped) {
14893
- sections.push(colors.bold("SUBCOMMANDS"));
14894
- sections.push(renderTable(ungrouped.commands.map((sub) => ({
14895
- left: colors.cyan(formatSubcommandName(sub.name, sub.alias)),
14896
- right: sub.shortDescription ?? sub.description
14897
- })), 20));
14898
- if (doc.subcommands.length > 1) {
14899
- sections.push("");
14900
- }
14901
- }
14902
- for (const group of doc.subcommands) {
14903
- if (group.group === undefined)
14904
- continue;
14905
- sections.push(colors.bold(`${group.group}:`));
14906
- sections.push(renderTable(group.commands.map((sub) => ({
14907
- left: colors.cyan(formatSubcommandName(sub.name, sub.alias)),
14908
- right: sub.shortDescription ?? sub.description
14909
- })), 20));
14910
- sections.push("");
14911
- }
14912
- }
14913
- if (doc.examples && doc.examples.length > 0) {
14914
- sections.push(colors.bold("EXAMPLES"));
14915
- let first = true;
14916
- let previousHadDescription = false;
14917
- for (const example of doc.examples) {
14918
- if (example.description) {
14919
- if (!first)
14920
- sections.push("");
14921
- sections.push(` ${colors.dim(`# ${example.description}`)}`);
14922
- } else if (previousHadDescription) {
14923
- sections.push("");
14924
- }
14925
- sections.push(` ${colors.cyan(example.command)}`);
14926
- first = false;
14927
- previousHadDescription = !!example.description;
14928
- }
14929
- sections.push("");
14930
- }
14931
- if (sections[sections.length - 1] === "") {
14932
- sections.pop();
14933
- }
14934
- return sections.join(`
14935
- `);
14936
- };
14937
-
14938
14861
  // node_modules/effect/dist/cli/internal/config.js
14939
14862
  var ConfigInternalTypeId = "~effect/cli/Command/Config/Internal";
14940
14863
  var parseConfig = (config) => {
@@ -15018,6 +14941,7 @@ var makeCommand = (options) => {
15018
14941
  const annotations = options.annotations ?? empty();
15019
14942
  const globalFlags = options.globalFlags ?? [];
15020
14943
  const subcommands = options.subcommands ?? [];
14944
+ const resolveExamples = options.resolveExamples ?? noExamples;
15021
14945
  const handle = (input, commandPath) => isNotUndefined(options.handle) ? options.handle(input, commandPath) : fail6(new ShowHelp({
15022
14946
  commandPath,
15023
14947
  errors: []
@@ -15075,7 +14999,7 @@ var makeCommand = (options) => {
15075
14999
  }))
15076
15000
  });
15077
15001
  }
15078
- const examples = options.examples ?? [];
15002
+ const examples = resolveExamples(commandPath);
15079
15003
  return {
15080
15004
  description: options.description ?? "",
15081
15005
  usage,
@@ -15095,7 +15019,8 @@ var makeCommand = (options) => {
15095
15019
  return Object.assign(Object.create(Proto11), {
15096
15020
  [TypeId37]: TypeId37,
15097
15021
  name: options.name,
15098
- examples: options.examples ?? [],
15022
+ examples: resolveExamples([options.name]),
15023
+ resolveExamples,
15099
15024
  annotations,
15100
15025
  globalFlags,
15101
15026
  subcommands,
@@ -15118,6 +15043,7 @@ var makeCommand = (options) => {
15118
15043
  } : {}
15119
15044
  });
15120
15045
  };
15046
+ var noExamples = () => [];
15121
15047
  var toFlagDoc = (single, metadata) => {
15122
15048
  const formattedAliases = single.aliases.map((alias) => alias.length === 1 ? `-${alias}` : `--${alias}`);
15123
15049
  const type = single.typeName ?? getTypeName(single.primitiveType);
@@ -15299,7 +15225,8 @@ var fromCommand = (cmd, inheritedFlags = []) => {
15299
15225
  aliases: single.aliases,
15300
15226
  description: getOrUndefined(single.description),
15301
15227
  type: toFlagType(single),
15302
- optionalValue: single.optionalValue !== undefined
15228
+ optionalValue: single.optionalValue !== undefined,
15229
+ negation: single.negation
15303
15230
  });
15304
15231
  }
15305
15232
  }
@@ -15344,6 +15271,7 @@ var fromCommand = (cmd, inheritedFlags = []) => {
15344
15271
  };
15345
15272
  };
15346
15273
  var takesSeparateValue = (flag) => flag.type._tag !== "Boolean" && flag.optionalValue !== true;
15274
+ var negatedName = (flag) => flag.type._tag !== "Boolean" || flag.negation === false ? undefined : flag.negation ?? `no-${flag.name}`;
15347
15275
 
15348
15276
  // node_modules/effect/dist/cli/internal/completions/bash.js
15349
15277
  var escapeForBash = (s) => s.replace(/'/g, "'\\''");
@@ -15353,8 +15281,9 @@ var flagNamesForWordlist = (flag) => {
15353
15281
  for (const alias of flag.aliases) {
15354
15282
  names.push(alias.length === 1 ? `-${alias}` : `--${alias}`);
15355
15283
  }
15356
- if (flag.type._tag === "Boolean") {
15357
- names.push(`--no-${flag.name}`);
15284
+ const negation = negatedName(flag);
15285
+ if (negation !== undefined) {
15286
+ names.push(`--${negation}`);
15358
15287
  }
15359
15288
  return names;
15360
15289
  };
@@ -15663,8 +15592,9 @@ var flagContainsOptCondition = (flag) => {
15663
15592
  optArgs.push(alias);
15664
15593
  }
15665
15594
  }
15666
- if (flag.type._tag === "Boolean") {
15667
- optArgs.push(`no-${flag.name}`);
15595
+ const negation = negatedName(flag);
15596
+ if (negation !== undefined) {
15597
+ optArgs.push(negation);
15668
15598
  }
15669
15599
  return `not __fish_contains_opt ${optArgs.join(" ")}`;
15670
15600
  };
@@ -15748,11 +15678,12 @@ var generateCompletions = (executableName, descriptor, parentPath, lines) => {
15748
15678
  parts.push(flagCondArg);
15749
15679
  parts.push(...flagCompletionArgs(flag));
15750
15680
  lines.push(parts.join(" "));
15751
- if (flag.type._tag === "Boolean") {
15681
+ const negation = negatedName(flag);
15682
+ if (negation !== undefined) {
15752
15683
  const negParts = [`complete -c ${executableName}`];
15753
15684
  if (flagCondArg)
15754
15685
  negParts.push(flagCondArg);
15755
- negParts.push(`-l no-${flag.name}`);
15686
+ negParts.push(`-l ${negation}`);
15756
15687
  if (flag.description) {
15757
15688
  negParts.push(`-d '${escapeFishString(`Disable ${flag.name}`)}'`);
15758
15689
  }
@@ -15764,7 +15695,7 @@ var generateCompletions = (executableName, descriptor, parentPath, lines) => {
15764
15695
  const bareBase = condition ? `${condition}; and ${notDash}` : notDash;
15765
15696
  for (const flag of descriptor.flags) {
15766
15697
  const bareCondition = `${bareBase}; and ${flagContainsOptCondition(flag)}`;
15767
- const isBoolean = flag.type._tag === "Boolean";
15698
+ const negation = negatedName(flag);
15768
15699
  const parts = [`complete -c ${executableName}`];
15769
15700
  parts.push(`-n '${bareCondition}'`);
15770
15701
  parts.push(`-f -a '--${flag.name}'`);
@@ -15772,10 +15703,10 @@ var generateCompletions = (executableName, descriptor, parentPath, lines) => {
15772
15703
  parts.push(`-d '${escapeFishString(flag.description)}'`);
15773
15704
  }
15774
15705
  lines.push(parts.join(" "));
15775
- if (isBoolean) {
15706
+ if (negation !== undefined) {
15776
15707
  const negParts = [`complete -c ${executableName}`];
15777
15708
  negParts.push(`-n '${bareCondition}'`);
15778
- negParts.push(`-f -a '--no-${flag.name}'`);
15709
+ negParts.push(`-f -a '--${negation}'`);
15779
15710
  if (flag.description) {
15780
15711
  negParts.push(`-d '${escapeFishString(`Disable ${flag.name}`)}'`);
15781
15712
  }
@@ -15841,7 +15772,10 @@ var psOptional = (s) => s ? quotePs(s) : "$null";
15841
15772
  var sanitize = (s) => s.replace(/[^a-zA-Z0-9_]/g, "_");
15842
15773
  var flagForms = (flag) => [`--${flag.name}`, ...flag.aliases.map((alias) => alias.length === 1 ? `-${alias}` : `--${alias}`)];
15843
15774
  var valueFields = (type) => `values = ${psArray(type._tag === "Choice" ? type.values : [])}; ` + `pathType = ${type._tag === "Path" ? quotePs(type.pathType) : "$null"}`;
15844
- var flagEntry = (flag) => `@{ name = ${quotePs(flag.name)}; forms = ${psArray(flagForms(flag))}; ` + `takesValue = $${flag.type._tag !== "Boolean"}; ` + (flag.optionalValue === true ? `optionalValue = $true; ` : "") + `${valueFields(flag.type)}; ` + `description = ${psOptional(flag.description)} }`;
15775
+ var flagEntry = (flag) => {
15776
+ const negation = negatedName(flag);
15777
+ return `@{ name = ${quotePs(flag.name)}; forms = ${psArray(flagForms(flag))}; ` + `takesValue = $${flag.type._tag !== "Boolean"}; ` + (negation === undefined ? "" : `negation = ${quotePs(`--${negation}`)}; `) + (flag.optionalValue === true ? `optionalValue = $true; ` : "") + `${valueFields(flag.type)}; ` + `description = ${psOptional(flag.description)} }`;
15778
+ };
15845
15779
  var argumentEntry = (argument) => `@{ name = ${quotePs(argument.name)}; variadic = $${argument.variadic}; ${valueFields(argument.type)}; ` + `description = ${psOptional(argument.description)} }`;
15846
15780
  var pushList = (lines, field, entries) => {
15847
15781
  if (entries.length === 0) {
@@ -15916,10 +15850,10 @@ var completer = (dataName) => String.raw` param($wordToComplete, $commandAst, $
15916
15850
  foreach ($form in $flag.forms) {
15917
15851
  & $add $form 'ParameterName' $flag.description $typed ''
15918
15852
  }
15919
- if (-not $flag.takesValue) {
15853
+ if ($flag.negation) {
15920
15854
  $tooltip = $null
15921
15855
  if ($flag.description) { $tooltip = 'Disable ' + $flag.name }
15922
- & $add ('--no-' + $flag.name) 'ParameterName' $tooltip $typed ''
15856
+ & $add $flag.negation 'ParameterName' $tooltip $typed ''
15923
15857
  }
15924
15858
  }
15925
15859
  }
@@ -15990,14 +15924,19 @@ var completer = (dataName) => String.raw` param($wordToComplete, $commandAst, $
15990
15924
  foreach ($form in $forms) {
15991
15925
  $pending = $null
15992
15926
  $flag = $lookup[$form]
15993
- if ($null -eq $flag) {
15994
- if ($form.StartsWith('--no-')) {
15995
- $name = $form.Substring(5)
15996
- $flag = $lookup['--' + $name]
15997
- if ($null -ne $flag -and -not $flag.takesValue -and $flag.name -ceq $name) { $used[$name] = $true }
15927
+ # As in the CLI parser, a negation wins over an alias but not over a
15928
+ # canonical name.
15929
+ if ($null -eq $flag -or $form -cne ('--' + $flag.name)) {
15930
+ $negated = $null
15931
+ foreach ($candidate in $context.flags) {
15932
+ if ($candidate.negation -ceq $form) { $negated = $candidate }
15933
+ }
15934
+ if ($null -ne $negated) {
15935
+ $used[$negated.name] = $true
15936
+ continue
15998
15937
  }
15999
- continue
16000
15938
  }
15939
+ if ($null -eq $flag) { continue }
16001
15940
  $used[$flag.name] = $true
16002
15941
  # A flag with an optional value only takes a value attached with '='.
16003
15942
  if (-not $hasValue -and -not $flag.optionalValue) { $pending = $flag }
@@ -16088,8 +16027,9 @@ var allForms = (flag) => {
16088
16027
  for (const alias of flag.aliases) {
16089
16028
  forms.push(alias.length === 1 ? `-${alias}` : `--${alias}`);
16090
16029
  }
16091
- if (flag.type._tag === "Boolean") {
16092
- forms.push(`--no-${flag.name}`);
16030
+ const negation = negatedName(flag);
16031
+ if (negation !== undefined) {
16032
+ forms.push(`--${negation}`);
16093
16033
  }
16094
16034
  return forms;
16095
16035
  };
@@ -16133,9 +16073,10 @@ var flagSpecs = (flag) => {
16133
16073
  const prefix = alias.length === 1 ? "-" : "--";
16134
16074
  specs.push(`'${excl}${prefix}${alias}${valueSuffix}${desc}${action}'`);
16135
16075
  }
16136
- if (flag.type._tag === "Boolean") {
16076
+ const negation = negatedName(flag);
16077
+ if (negation !== undefined) {
16137
16078
  const negDesc = flag.description ? `[${escapeZshExplanation(`Disable ${flag.name}`)}]` : "";
16138
- specs.push(`'${excl}--no-${flag.name}${negDesc}'`);
16079
+ specs.push(`'${excl}--${negation}${negDesc}'`);
16139
16080
  }
16140
16081
  return specs;
16141
16082
  };
@@ -16271,6 +16212,265 @@ var withMetavar2 = /* @__PURE__ */ dual(2, (self, metavar) => withMetavar(self,
16271
16212
  var optional4 = (param) => optional3(param);
16272
16213
  var withDefault5 = withDefault4;
16273
16214
 
16215
+ // node_modules/effect/dist/cli/CliOutput.js
16216
+ var Formatter = /* @__PURE__ */ Reference("effect/cli/CliOutput", {
16217
+ defaultValue: () => defaultFormatter2()
16218
+ });
16219
+ var escapeControlCharacters = (text) => text.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g, (character) => `\\x${character.charCodeAt(0).toString(16).padStart(2, "0")}`);
16220
+ var defaultFormatter2 = (options) => {
16221
+ const useColor = options?.colors ?? detectColors();
16222
+ const colors = useColor ? {
16223
+ bold: (text) => `\x1B[1m${text}\x1B[0m`,
16224
+ dim: (text) => `\x1B[2m${text}\x1B[0m`,
16225
+ cyan: (text) => `\x1B[36m${text}\x1B[0m`,
16226
+ green: (text) => `\x1B[32m${text}\x1B[0m`,
16227
+ blue: (text) => `\x1B[34m${text}\x1B[0m`,
16228
+ yellow: (text) => `\x1B[33m${text}\x1B[0m`,
16229
+ magenta: (text) => `\x1B[35m${text}\x1B[0m`
16230
+ } : {
16231
+ bold: (text) => text,
16232
+ dim: (text) => text,
16233
+ cyan: (text) => text,
16234
+ green: (text) => text,
16235
+ blue: (text) => text,
16236
+ yellow: (text) => text,
16237
+ magenta: (text) => text
16238
+ };
16239
+ const reset = useColor ? "\x1B[0m" : "";
16240
+ const red = useColor ? "\x1B[31m" : "";
16241
+ const bold = useColor ? "\x1B[1m" : "";
16242
+ return {
16243
+ formatHelpDoc: (doc) => formatHelpDocImpl(doc, colors),
16244
+ formatCliError: (error) => escapeControlCharacters(error.message),
16245
+ formatError: (error) => {
16246
+ return `
16247
+ ${bold}${red}ERROR${reset}
16248
+ ${escapeControlCharacters(error.message)}${reset}`;
16249
+ },
16250
+ formatErrors: (errors) => {
16251
+ if (errors.length === 0)
16252
+ return "";
16253
+ if (errors.length === 1) {
16254
+ return `
16255
+ ${bold}${red}ERROR${reset}
16256
+ ${escapeControlCharacters(errors[0].message)}${reset}`;
16257
+ }
16258
+ const grouped = new Map;
16259
+ for (const error of errors) {
16260
+ const tag = error._tag ?? "Error";
16261
+ const group = grouped.get(tag) ?? [];
16262
+ group.push(error);
16263
+ grouped.set(tag, group);
16264
+ }
16265
+ const sections = [];
16266
+ sections.push(`
16267
+ ${bold}${red}ERRORS${reset}`);
16268
+ for (const [, group] of grouped) {
16269
+ for (const error of group) {
16270
+ sections.push(` ${escapeControlCharacters(error.message)}${reset}`);
16271
+ }
16272
+ }
16273
+ return sections.join(`
16274
+ `);
16275
+ },
16276
+ formatVersion: (name, version) => `${colors.bold(name)} ${colors.dim("v")}${colors.bold(version)}`
16277
+ };
16278
+ };
16279
+ var stripAnsi = (text) => {
16280
+ return text.replace(/\u001B\[[0-9;]*m/g, "");
16281
+ };
16282
+ var graphemeSegmenter = /* @__PURE__ */ new Intl.Segmenter(undefined, {
16283
+ granularity: "grapheme"
16284
+ });
16285
+ var zeroWidthCodePoints = /[\p{Mark}\p{Control}\p{Default_Ignorable_Code_Point}]/gu;
16286
+ var emojiPresentation = /\p{Emoji_Presentation}/u;
16287
+ var isFullWidthCodePoint = (codePoint) => {
16288
+ if (codePoint < 4352)
16289
+ return false;
16290
+ return codePoint <= 4447 || codePoint === 9001 || codePoint === 9002 || codePoint >= 11904 && codePoint <= 12350 || codePoint >= 12352 && codePoint <= 42191 || codePoint >= 44032 && codePoint <= 55203 || codePoint >= 63744 && codePoint <= 64255 || codePoint >= 65040 && codePoint <= 65049 || codePoint >= 65072 && codePoint <= 65135 || codePoint >= 65280 && codePoint <= 65376 || codePoint >= 65504 && codePoint <= 65510 || codePoint >= 110592 && codePoint <= 111359 || codePoint >= 127488 && codePoint <= 127569 || codePoint >= 131072 && codePoint <= 262141;
16291
+ };
16292
+ var graphemeWidth = (grapheme) => {
16293
+ const visible = grapheme.replace(zeroWidthCodePoints, "");
16294
+ if (visible.length === 0)
16295
+ return 0;
16296
+ if (emojiPresentation.test(grapheme) || grapheme.includes("\uFE0F"))
16297
+ return 2;
16298
+ return isFullWidthCodePoint(visible.codePointAt(0)) ? 2 : 1;
16299
+ };
16300
+ var displayWidth = (text) => {
16301
+ let length = 0;
16302
+ for (const {
16303
+ segment
16304
+ } of graphemeSegmenter.segment(stripAnsi(text))) {
16305
+ length += graphemeWidth(segment);
16306
+ }
16307
+ return length;
16308
+ };
16309
+ var pad = (s, width) => {
16310
+ const actualLength = displayWidth(s);
16311
+ const padding = Math.max(0, width - actualLength);
16312
+ return s + " ".repeat(padding);
16313
+ };
16314
+ var renderTable = (rows, widthCap) => {
16315
+ const maxColumn = Math.max(...rows.map((r) => displayWidth(r.left))) + 4;
16316
+ const col = widthCap === undefined ? maxColumn : Math.min(maxColumn, widthCap);
16317
+ return rows.map(({
16318
+ left,
16319
+ right
16320
+ }) => ` ${pad(left, Math.max(col, displayWidth(left) + 1))}${right}`).join(`
16321
+ `);
16322
+ };
16323
+ var formatSubcommandName = (name, alias) => alias ? `${name}, ${alias}` : name;
16324
+ var formatHelpDocImpl = (doc, colors) => {
16325
+ const sections = [];
16326
+ if (doc.description) {
16327
+ sections.push(colors.bold("DESCRIPTION"));
16328
+ sections.push(` ${doc.description}`);
16329
+ sections.push("");
16330
+ }
16331
+ sections.push(colors.bold("USAGE"));
16332
+ sections.push(` ${colors.cyan(doc.usage)}`);
16333
+ sections.push("");
16334
+ if (doc.args && doc.args.length > 0) {
16335
+ sections.push(colors.bold("ARGUMENTS"));
16336
+ const argRows = doc.args.map((arg) => {
16337
+ let name = arg.name;
16338
+ if (arg.variadic) {
16339
+ name += "...";
16340
+ }
16341
+ const coloredName = colors.green(name);
16342
+ const coloredType = colors.dim(arg.type);
16343
+ const nameType = `${coloredName} ${coloredType}`;
16344
+ const optionalSuffix = arg.required ? "" : colors.dim(" (optional)");
16345
+ const description = getOrElse(arg.description, () => "") + optionalSuffix;
16346
+ return {
16347
+ left: nameType,
16348
+ right: description
16349
+ };
16350
+ });
16351
+ sections.push(renderTable(argRows, 25));
16352
+ sections.push("");
16353
+ }
16354
+ if (doc.flags.length > 0) {
16355
+ sections.push(colors.bold("FLAGS"));
16356
+ const flagRows = doc.flags.map((flag) => {
16357
+ const names = [];
16358
+ names.push(colors.green(`--${flag.name}`));
16359
+ for (const alias of flag.aliases) {
16360
+ names.push(colors.green(alias));
16361
+ }
16362
+ const namesPart = names.join(", ");
16363
+ const typePart = flag.type !== "boolean" ? ` ${colors.dim(flag.type)}` : "";
16364
+ return {
16365
+ left: namesPart + typePart,
16366
+ right: getOrElse(flag.description, () => "")
16367
+ };
16368
+ });
16369
+ sections.push(renderTable(flagRows));
16370
+ sections.push("");
16371
+ }
16372
+ if (doc.globalFlags && doc.globalFlags.length > 0) {
16373
+ sections.push(colors.bold("GLOBAL FLAGS"));
16374
+ const globalFlagRows = doc.globalFlags.map((flag) => {
16375
+ const names = [];
16376
+ names.push(colors.green(`--${flag.name}`));
16377
+ for (const alias of flag.aliases) {
16378
+ names.push(colors.green(alias));
16379
+ }
16380
+ const namesPart = names.join(", ");
16381
+ const typePart = flag.type !== "boolean" ? ` ${colors.dim(flag.type)}` : "";
16382
+ return {
16383
+ left: namesPart + typePart,
16384
+ right: getOrElse(flag.description, () => "")
16385
+ };
16386
+ });
16387
+ sections.push(renderTable(globalFlagRows));
16388
+ sections.push("");
16389
+ }
16390
+ if (doc.subcommands && doc.subcommands.length > 0) {
16391
+ const ungrouped = doc.subcommands.find((group) => group.group === undefined);
16392
+ if (ungrouped) {
16393
+ sections.push(colors.bold("SUBCOMMANDS"));
16394
+ sections.push(renderTable(ungrouped.commands.map((sub) => ({
16395
+ left: colors.cyan(formatSubcommandName(sub.name, sub.alias)),
16396
+ right: sub.shortDescription ?? sub.description
16397
+ })), 20));
16398
+ if (doc.subcommands.length > 1) {
16399
+ sections.push("");
16400
+ }
16401
+ }
16402
+ for (const group of doc.subcommands) {
16403
+ if (group.group === undefined)
16404
+ continue;
16405
+ sections.push(colors.bold(`${group.group}:`));
16406
+ sections.push(renderTable(group.commands.map((sub) => ({
16407
+ left: colors.cyan(formatSubcommandName(sub.name, sub.alias)),
16408
+ right: sub.shortDescription ?? sub.description
16409
+ })), 20));
16410
+ sections.push("");
16411
+ }
16412
+ }
16413
+ if (doc.examples && doc.examples.length > 0) {
16414
+ sections.push(colors.bold("EXAMPLES"));
16415
+ let first = true;
16416
+ let previousHadDescription = false;
16417
+ for (const example of doc.examples) {
16418
+ if (example.description) {
16419
+ if (!first)
16420
+ sections.push("");
16421
+ sections.push(` ${colors.dim(`# ${example.description}`)}`);
16422
+ } else if (previousHadDescription) {
16423
+ sections.push("");
16424
+ }
16425
+ sections.push(` ${colors.cyan(example.command)}`);
16426
+ first = false;
16427
+ previousHadDescription = !!example.description;
16428
+ }
16429
+ sections.push("");
16430
+ }
16431
+ if (sections[sections.length - 1] === "") {
16432
+ sections.pop();
16433
+ }
16434
+ return sections.join(`
16435
+ `);
16436
+ };
16437
+
16438
+ // node_modules/effect/dist/cli/TerminalCapabilities.js
16439
+ var TerminalCapabilities = /* @__PURE__ */ Reference("effect/cli/TerminalCapabilities", {
16440
+ defaultValue: () => fromProcess()
16441
+ });
16442
+ var isPresent = (value) => value !== undefined && value.length > 0;
16443
+ var isForcingColor = (value) => isPresent(value) && value !== "0" && value.toLowerCase() !== "false";
16444
+ var detect = (input) => {
16445
+ if (input.term === "dumb") {
16446
+ return {
16447
+ canColor: false,
16448
+ canAnimate: false,
16449
+ canPrompt: false
16450
+ };
16451
+ }
16452
+ return {
16453
+ canColor: !isPresent(input.noColor) && (isForcingColor(input.forceColor) || input.stdoutIsTerminal),
16454
+ canAnimate: input.stdoutIsTerminal,
16455
+ canPrompt: input.stdinIsTerminal && input.stdoutIsTerminal
16456
+ };
16457
+ };
16458
+ var fromProcess = () => {
16459
+ const process2 = globalThis.process;
16460
+ return detect({
16461
+ noColor: process2?.env?.NO_COLOR,
16462
+ forceColor: process2?.env?.FORCE_COLOR,
16463
+ term: process2?.env?.TERM,
16464
+ stdinIsTerminal: process2?.stdin?.isTTY === true,
16465
+ stdoutIsTerminal: process2?.stdout?.isTTY === true
16466
+ });
16467
+ };
16468
+
16469
+ // node_modules/effect/dist/cli/internal/formatter.js
16470
+ var resolveFormatter = /* @__PURE__ */ contextWith2((context) => succeed6(getOrUndefined2(context, Formatter) ?? defaultFormatter2({
16471
+ colors: get(context, TerminalCapabilities).canColor
16472
+ })));
16473
+
16274
16474
  // node_modules/effect/dist/cli/internal/help.js
16275
16475
  var dedupeGlobalFlags = (flags) => {
16276
16476
  const seen = new Set;
@@ -16400,7 +16600,7 @@ var Help = /* @__PURE__ */ Action2({
16400
16600
  command,
16401
16601
  commandPath
16402
16602
  }) {
16403
- const formatter = yield* Formatter;
16603
+ const formatter = yield* resolveFormatter;
16404
16604
  const helpDoc = yield* getHelpForCommandPath(command, commandPath, builtIns);
16405
16605
  yield* log(formatter.formatHelpDoc(helpDoc));
16406
16606
  })
@@ -16411,7 +16611,7 @@ var Version = /* @__PURE__ */ Action2({
16411
16611
  command,
16412
16612
  version
16413
16613
  }) {
16414
- const formatter = yield* Formatter;
16614
+ const formatter = yield* resolveFormatter;
16415
16615
  yield* log(formatter.formatVersion(command.name, version));
16416
16616
  })
16417
16617
  });
@@ -16475,13 +16675,20 @@ var lexTokens = (args) => {
16475
16675
  const equalIndex = arg.indexOf("=");
16476
16676
  if (equalIndex !== -1) {
16477
16677
  const name = arg.slice(2, equalIndex);
16478
- const value = arg.slice(equalIndex + 1);
16479
- tokens.push({
16480
- _tag: "LongOption",
16481
- name,
16482
- raw: arg,
16483
- value
16484
- });
16678
+ if (name === "") {
16679
+ tokens.push({
16680
+ _tag: "Value",
16681
+ value: arg
16682
+ });
16683
+ } else {
16684
+ const value = arg.slice(equalIndex + 1);
16685
+ tokens.push({
16686
+ _tag: "LongOption",
16687
+ name,
16688
+ raw: arg,
16689
+ value
16690
+ });
16691
+ }
16485
16692
  } else {
16486
16693
  tokens.push({
16487
16694
  _tag: "LongOption",
@@ -16493,13 +16700,20 @@ var lexTokens = (args) => {
16493
16700
  const flags = arg.slice(1);
16494
16701
  const equalIndex = flags.indexOf("=");
16495
16702
  if (equalIndex !== -1) {
16496
- const flag = flags.slice(0, equalIndex);
16497
- const value = flags.slice(equalIndex + 1);
16703
+ const chars = Array.from(flags.slice(0, equalIndex));
16704
+ const flag = chars.pop() ?? "";
16705
+ for (const ch of chars) {
16706
+ tokens.push({
16707
+ _tag: "ShortOption",
16708
+ flag: ch,
16709
+ raw: `-${ch}`
16710
+ });
16711
+ }
16498
16712
  tokens.push({
16499
16713
  _tag: "ShortOption",
16500
16714
  flag,
16501
16715
  raw: `-${flag}`,
16502
- value
16716
+ value: flags.slice(equalIndex + 1)
16503
16717
  });
16504
16718
  } else {
16505
16719
  for (const ch of flags) {
@@ -16610,8 +16824,10 @@ var makeCursor = (tokens) => {
16610
16824
  rest: () => tokens.slice(i)
16611
16825
  };
16612
16826
  };
16827
+ var negatedName2 = (param) => !isBoolean2(param.primitiveType) || param.negation === false ? undefined : param.negation ?? `no-${param.name}`;
16613
16828
  var createFlagRegistry = (params) => {
16614
16829
  const index = new Map;
16830
+ const negations = new Map;
16615
16831
  for (const param of params) {
16616
16832
  if (index.has(param.name)) {
16617
16833
  throw new Error(`Duplicate flag name "${param.name}" in command definition`);
@@ -16623,10 +16839,18 @@ var createFlagRegistry = (params) => {
16623
16839
  }
16624
16840
  index.set(alias, param);
16625
16841
  }
16842
+ const negation = negatedName2(param);
16843
+ if (negation !== undefined) {
16844
+ if (negations.has(negation)) {
16845
+ throw new Error(`Duplicate negation "${negation}" in command definition (conflicts with "${negations.get(negation).name}")`);
16846
+ }
16847
+ negations.set(negation, param);
16848
+ }
16626
16849
  }
16627
16850
  return {
16628
16851
  params,
16629
- index
16852
+ index,
16853
+ negations
16630
16854
  };
16631
16855
  };
16632
16856
  var buildSubcommandIndex = (subcommands) => {
@@ -16680,15 +16904,12 @@ var resolveFlag = (token, registry) => {
16680
16904
  negated: false
16681
16905
  };
16682
16906
  }
16683
- if (token._tag === "LongOption" && token.name.startsWith("no-")) {
16684
- const canonicalName = token.name.slice(3);
16685
- const param = registry.index.get(canonicalName);
16686
- if (param && param.name === canonicalName && isBoolean2(param.primitiveType)) {
16687
- return {
16688
- param,
16689
- negated: true
16690
- };
16691
- }
16907
+ const negated = token._tag === "LongOption" ? registry.negations.get(token.name) : undefined;
16908
+ if (negated) {
16909
+ return {
16910
+ param: negated,
16911
+ negated: true
16912
+ };
16692
16913
  }
16693
16914
  if (direct) {
16694
16915
  return {
@@ -16932,8 +17153,9 @@ var createUnrecognizedFlagError = (token, params, commandPath) => {
16932
17153
  if (p.hidden)
16933
17154
  continue;
16934
17155
  validNames.push(p.name);
16935
- if (isBoolean2(p.primitiveType)) {
16936
- validNames.push(`no-${p.name}`);
17156
+ const negation = negatedName2(p);
17157
+ if (negation !== undefined) {
17158
+ validNames.push(negation);
16937
17159
  }
16938
17160
  for (const alias of p.aliases) {
16939
17161
  validNames.push(alias);
@@ -17382,7 +17604,7 @@ var withSubcommands = /* @__PURE__ */ dual(2, (self, subcommands) => {
17382
17604
  unlisted: impl.unlisted,
17383
17605
  annotations: impl.annotations,
17384
17606
  globalFlags: impl.globalFlags,
17385
- examples: impl.examples,
17607
+ resolveExamples: impl.resolveExamples,
17386
17608
  service: impl.service,
17387
17609
  subcommands: normalized.groups,
17388
17610
  parse,
@@ -17430,7 +17652,7 @@ var showHelp = (command, error2, renderErrors) => gen2(function* () {
17430
17652
  const {
17431
17653
  builtIns
17432
17654
  } = yield* CliConfig;
17433
- const formatter = yield* Formatter;
17655
+ const formatter = yield* resolveFormatter;
17434
17656
  const helpDoc = yield* getHelpForCommandPath(command, error2.commandPath, builtIns);
17435
17657
  yield* log(formatter.formatHelpDoc(helpDoc));
17436
17658
  if (renderErrors && error2.errors.length > 0) {
@@ -17438,7 +17660,7 @@ var showHelp = (command, error2, renderErrors) => gen2(function* () {
17438
17660
  }
17439
17661
  });
17440
17662
  var showUserError = (error2) => gen2(function* () {
17441
- const formatter = yield* Formatter;
17663
+ const formatter = yield* resolveFormatter;
17442
17664
  yield* error(formatter.formatError(error2));
17443
17665
  error2[errorReported] = false;
17444
17666
  });
@@ -17736,7 +17958,12 @@ var make33 = (url, params, hash) => try_({
17736
17958
  });
17737
17959
  var baseUrl = () => {
17738
17960
  if ("location" in globalThis && globalThis.location !== undefined && globalThis.location.origin !== undefined && globalThis.location.pathname !== undefined) {
17739
- return location.origin + location.pathname;
17961
+ const base = location.origin + location.pathname;
17962
+ try {
17963
+ return new URL(base).href;
17964
+ } catch {
17965
+ return;
17966
+ }
17740
17967
  }
17741
17968
  return;
17742
17969
  };
@@ -17860,28 +18087,17 @@ var schemaBodyJson = (schema, options) => {
17860
18087
  return (self) => decodeJson === undefined ? flatMap4(self.json, (u) => decode(u, options)) : flatMap4(self.text, (body) => body === "" ? flatMap4(self.json, (u) => decode(u, options)) : decodeJson(body, options));
17861
18088
  };
17862
18089
  var inspect = (self, that) => {
17863
- const contentType = self.headers["content-type"] ?? "";
17864
- let body;
17865
- if (contentType.includes("application/json")) {
17866
- try {
17867
- body = runSync2(self.json);
17868
- } catch (_) {}
17869
- } else if (contentType.includes("text/") || contentType.includes("urlencoded")) {
17870
- try {
17871
- body = runSync2(self.text);
17872
- } catch (_) {}
17873
- }
17874
- const obj = {
18090
+ return {
17875
18091
  ...that,
17876
18092
  headers: redact(self.headers),
17877
18093
  remoteAddress: self.remoteAddress
17878
18094
  };
17879
- if (body !== undefined) {
17880
- obj.body = body;
17881
- }
17882
- return obj;
17883
18095
  };
17884
18096
 
18097
+ // node_modules/effect/dist/http/internal/webResponse.js
18098
+ var WebSourceSymbol = "~effect/http/HttpClientResponse/WebSource";
18099
+ var getWebSource = (self) => self[WebSourceSymbol]?.();
18100
+
17885
18101
  // node_modules/effect/dist/http/HttpClientResponse.js
17886
18102
  var TypeId42 = "~effect/http/HttpClientResponse";
17887
18103
  var fromWeb = (request, source) => new WebHttpClientResponse(request, source);
@@ -17929,6 +18145,9 @@ class WebHttpClientResponse extends Class2 {
17929
18145
  get remoteAddress() {
17930
18146
  return none2();
17931
18147
  }
18148
+ [WebSourceSymbol]() {
18149
+ return this.source;
18150
+ }
17932
18151
  get stream() {
17933
18152
  return this.source.body ? fromReadableStream2({
17934
18153
  evaluate: () => this.source.body,
@@ -18005,6 +18224,15 @@ class WebHttpClientResponse extends Class2 {
18005
18224
  }).pipe(cached2, runSync2);
18006
18225
  return this.arrayBufferBody;
18007
18226
  }
18227
+ get upgrade() {
18228
+ return fail6(new HttpClientError({
18229
+ reason: new StatusCodeError({
18230
+ request: this.request,
18231
+ response: this,
18232
+ description: "fetch cannot hand over the connection of an HTTP upgrade"
18233
+ })
18234
+ }));
18235
+ }
18008
18236
  pipe() {
18009
18237
  return pipeArguments(this, arguments);
18010
18238
  }
@@ -18179,7 +18407,9 @@ var layerMergedContext = (effect2) => effect(HttpClient)(contextWith2((context)
18179
18407
  var responseRegistry = /* @__PURE__ */ (() => {
18180
18408
  if ("FinalizationRegistry" in globalThis && globalThis.FinalizationRegistry) {
18181
18409
  const registry = /* @__PURE__ */ new FinalizationRegistry((controller) => {
18182
- controller.abort();
18410
+ try {
18411
+ controller.abort();
18412
+ } catch {}
18183
18413
  });
18184
18414
  return {
18185
18415
  register(response, controller) {
@@ -18256,6 +18486,15 @@ class InterruptibleResponse {
18256
18486
  get arrayBuffer() {
18257
18487
  return this.applyInterrupt(this.original.arrayBuffer);
18258
18488
  }
18489
+ get upgrade() {
18490
+ return this.applyInterrupt(this.original.upgrade);
18491
+ }
18492
+ [WebSourceSymbol]() {
18493
+ const source = getWebSource(this.original);
18494
+ if (source !== undefined)
18495
+ responseRegistry.unregister(this.original);
18496
+ return source;
18497
+ }
18259
18498
  get stream() {
18260
18499
  return suspend4(() => {
18261
18500
  responseRegistry.unregister(this.original);
@@ -18283,12 +18522,22 @@ var Fetch = /* @__PURE__ */ Reference("effect/http/FetchHttpClient/Fetch", {
18283
18522
  class RequestInit extends (/* @__PURE__ */ Service()("effect/http/FetchHttpClient/RequestInit")) {
18284
18523
  }
18285
18524
  var fetch = /* @__PURE__ */ make35((request, url, signal, fiber) => {
18525
+ if (request.headers.upgrade !== undefined) {
18526
+ return fail6(new HttpClientError({
18527
+ reason: new TransportError({
18528
+ request,
18529
+ description: "fetch cannot send an HTTP upgrade request"
18530
+ })
18531
+ }));
18532
+ }
18286
18533
  const fetch = fiber.getRef(Fetch);
18287
18534
  const options = getOrUndefined2(fiber.context, RequestInit) ?? {};
18288
18535
  let headers = options.headers ? merge4(fromInput(options.headers), request.headers) : request.headers;
18289
18536
  if (headers["content-length"]) {
18290
18537
  headers = remove3(headers, "content-length");
18291
18538
  }
18539
+ let uploadController;
18540
+ const stopUpload = sync2(() => uploadController?.abort());
18292
18541
  const send = (body) => map7(tryPromise2({
18293
18542
  try: () => fetch(url, {
18294
18543
  ...options,
@@ -18296,7 +18545,7 @@ var fetch = /* @__PURE__ */ make35((request, url, signal, fiber) => {
18296
18545
  headers,
18297
18546
  body,
18298
18547
  duplex: typeof ReadableStream !== "undefined" && body instanceof ReadableStream ? "half" : undefined,
18299
- signal
18548
+ signal: uploadController ? AbortSignal.any([signal, uploadController.signal]) : signal
18300
18549
  }),
18301
18550
  catch: (cause) => new HttpClientError({
18302
18551
  reason: new TransportError({
@@ -18304,15 +18553,43 @@ var fetch = /* @__PURE__ */ make35((request, url, signal, fiber) => {
18304
18553
  cause
18305
18554
  })
18306
18555
  })
18307
- }), (response) => fromWeb(request, response));
18556
+ }), (response) => {
18557
+ const original = fromWeb(request, response);
18558
+ if (!uploadController)
18559
+ return original;
18560
+ if (response.body === null)
18561
+ uploadController.abort();
18562
+ return Object.create(original, {
18563
+ ...Object.fromEntries(["arrayBuffer", "text", "json", "formData", "urlParamsBody"].map((key) => [key, {
18564
+ get: () => ensuring2(original[key], stopUpload)
18565
+ }])),
18566
+ stream: {
18567
+ get: () => ensuring4(original.stream, stopUpload)
18568
+ }
18569
+ });
18570
+ }).pipe(onError2(() => stopUpload));
18308
18571
  switch (request.body._tag) {
18309
18572
  case "Raw":
18310
18573
  case "Uint8Array":
18311
18574
  return send(request.body.body);
18312
18575
  case "FormData":
18313
18576
  return send(request.body.formData);
18314
- case "Stream":
18315
- return flatMap4(toReadableStreamEffect(request.body.stream), send);
18577
+ case "Stream": {
18578
+ uploadController = new AbortController;
18579
+ const uploadSignal = AbortSignal.any([signal, uploadController.signal]);
18580
+ const stopped = callback2((resume) => {
18581
+ const onAbort = () => resume(interrupt2);
18582
+ if (uploadSignal.aborted) {
18583
+ onAbort();
18584
+ return;
18585
+ }
18586
+ uploadSignal.addEventListener("abort", onAbort, {
18587
+ once: true
18588
+ });
18589
+ return sync2(() => uploadSignal.removeEventListener("abort", onAbort));
18590
+ });
18591
+ return flatMap4(toReadableStreamEffect(interruptWhen2(request.body.stream, stopped)), send);
18592
+ }
18316
18593
  }
18317
18594
  return send(undefined);
18318
18595
  });
@@ -18320,7 +18597,7 @@ var layer14 = /* @__PURE__ */ layerMergedContext(/* @__PURE__ */ succeed6(fetch)
18320
18597
  // package.json
18321
18598
  var package_default = {
18322
18599
  name: "jj-octo",
18323
- version: "0.9.1",
18600
+ version: "0.9.2",
18324
18601
  description: "A jj subcommand for GitHub that supports stacked pull requests and works in Claude Code cloud sessions",
18325
18602
  license: "MIT",
18326
18603
  repository: {
@@ -18352,20 +18629,20 @@ var package_default = {
18352
18629
  test: "bun run build && bun run compile && bun test ./src"
18353
18630
  },
18354
18631
  devDependencies: {
18355
- "@effect/platform-bun": "4.0.5",
18632
+ "@effect/platform-bun": "4.0.6",
18356
18633
  "@octokit/openapi-types": "29.0.1",
18357
18634
  "@tsconfig/strictest": "2.0.8",
18358
- "@types/bun": "1.4.3",
18359
- effect: "4.0.5",
18635
+ "@types/bun": "1.4.4",
18636
+ effect: "4.0.6",
18360
18637
  oxfmt: "0.74.0",
18361
18638
  oxlint: "1.89.0",
18362
- "oxlint-tsgolint": "7.0.2004",
18639
+ "oxlint-tsgolint": "7.0.2005",
18363
18640
  typescript: "7.0.2"
18364
18641
  },
18365
18642
  engines: {
18366
18643
  bun: ">=1.4.0"
18367
18644
  },
18368
- packageManager: "bun@1.4.3"
18645
+ packageManager: "bun@1.4.4"
18369
18646
  };
18370
18647
 
18371
18648
  // src/cli/command.ts
@@ -18407,8 +18684,8 @@ var gitLayer = ({ cwd, env } = {}) => effect(Git, gen2(function* () {
18407
18684
  "github"
18408
18685
  ], { cwd: directory }));
18409
18686
  const [text, stderr, code] = yield* all3([
18410
- mkString(decodeText(handle.stdout)),
18411
- mkString(decodeText(handle.stderr)),
18687
+ mkString(decodeText2(handle.stdout)),
18688
+ mkString(decodeText2(handle.stderr)),
18412
18689
  handle.exitCode
18413
18690
  ], { concurrency: "unbounded" });
18414
18691
  if (code > 127) {
@@ -18419,8 +18696,8 @@ var gitLayer = ({ cwd, env } = {}) => effect(Git, gen2(function* () {
18419
18696
  read: (args) => scoped2(gen2(function* () {
18420
18697
  const handle = yield* spawner.spawn(make16("git", args, { cwd, env, extendEnv: true }));
18421
18698
  const [stdout, stderr, code] = yield* all3([
18422
- mkString(decodeText(handle.stdout)),
18423
- mkString(decodeText(handle.stderr)),
18699
+ mkString(decodeText2(handle.stdout)),
18700
+ mkString(decodeText2(handle.stderr)),
18424
18701
  handle.exitCode
18425
18702
  ], { concurrency: "unbounded" });
18426
18703
  return code === 0 ? stdout : yield* new GitFailed({
@@ -18464,8 +18741,8 @@ var jjLayer = ({ cwd, env, printed } = {}) => effect(Jj, gen2(function* () {
18464
18741
  const captured = (args) => scoped2(gen2(function* () {
18465
18742
  const handle = yield* spawner.spawn(make16("jj", args, location2));
18466
18743
  return yield* all3([
18467
- mkString(decodeText(handle.stdout)),
18468
- mkString(decodeText(handle.stderr)),
18744
+ mkString(decodeText2(handle.stdout)),
18745
+ mkString(decodeText2(handle.stderr)),
18469
18746
  handle.exitCode
18470
18747
  ], { concurrency: "unbounded" });
18471
18748
  })).pipe(catchTag2("PlatformError", (error) => fail6(failed(args, error.message))));
@@ -18537,14 +18814,27 @@ var parseDescription = (json) => {
18537
18814
  const parsed = JSON.parse(json);
18538
18815
  return typeof parsed === "string" ? parsed : "";
18539
18816
  };
18540
- var readLog = (revset, template) => gen2(function* () {
18817
+ var readLog = (revset, template, { ignoreWorkingCopy = false } = {}) => gen2(function* () {
18541
18818
  const jj = yield* Jj;
18542
- return yield* jj.read(["log", "--no-graph", "--reversed", "-r", revset, "-T", template]);
18819
+ return yield* jj.read([
18820
+ "log",
18821
+ ...ignoreWorkingCopy ? ["--ignore-working-copy"] : [],
18822
+ "--no-graph",
18823
+ "--reversed",
18824
+ "-r",
18825
+ revset,
18826
+ "-T",
18827
+ template
18828
+ ]);
18543
18829
  });
18544
- var logLines = (revset, template) => readLog(revset, template).pipe(map7(lines2));
18830
+ var logLines = (revset, template, options) => readLog(revset, template, options).pipe(map7(lines2));
18545
18831
  var changesIn = (revset) => logLines(revset, String.raw`change_id.shortest(8) ++ " " ++ description.first_line() ++ "\n"`);
18546
18832
  var commitsAt = (revset) => logLines(revset, String.raw`commit_id ++ "\n"`);
18547
18833
  var changeIdsAt = (revset) => logLines(revset, String.raw`change_id ++ "\n"`);
18834
+ var lineCountsAt = (commitIds) => logLines(anyOf(commitIds), String.raw`commit_id ++ "\t" ++ diff.stat().total_added() ++ "\t" ++ diff.stat().total_removed() ++ "\n"`, { ignoreWorkingCopy: true }).pipe(map7((logged) => new Map(logged.flatMap((line) => {
18835
+ const [commitId = "", added = "", removed = ""] = line.split("\t");
18836
+ return /^\d+$/u.test(added) && /^\d+$/u.test(removed) ? [[commitId, { added: Number(added), removed: Number(removed) }]] : [];
18837
+ }))));
18548
18838
  var bookmarksAt = (revset) => gen2(function* () {
18549
18839
  const jj = yield* Jj;
18550
18840
  const template = String.raw`if(!remote, name ++ "\n")`;
@@ -19099,20 +19389,33 @@ var COPY_REPORT = {
19099
19389
  "The Claude app shows them as links, which paste into Slack as links."
19100
19390
  ].join(" ")
19101
19391
  };
19102
- var markdownLinks = (pullRequests) => pullRequests.map(({ number, state, title, url }) => `${EMOJI[state]} [#${number} ${title}](${url})`).join(`
19392
+ var lineCounts = ({ added, removed }) => `+${added}/-${removed}`;
19393
+ var markdownLinks = (pullRequests) => pullRequests.map((pullRequest) => `${EMOJI[pullRequest.state]} [#${pullRequest.number} ${pullRequest.title}](${pullRequest.url}) ${lineCounts(pullRequest)}`).join(`
19103
19394
  `);
19104
- var htmlLinks = (pullRequests) => `<meta charset="utf-8">${pullRequests.map(({ number, state, title, url }) => `${EMOJI[state]} <a href="${Bun.escapeHTML(url)}">#${number} ${Bun.escapeHTML(title)}</a>`).join("<br>")}`;
19395
+ var htmlLinks = (pullRequests) => `<meta charset="utf-8">${pullRequests.map((pullRequest) => `${EMOJI[pullRequest.state]} <a href="${Bun.escapeHTML(pullRequest.url)}">#${pullRequest.number} ${Bun.escapeHTML(pullRequest.title)}</a> ${lineCounts(pullRequest)}`).join("<br>")}`;
19105
19396
  var pullRequestOf = (pullRequests, commitId, pushed) => fromNullishOr(pullRequests.find(({ state }) => OPEN[state]) ?? pullRequests.find(({ head }) => head === commitId || head === pushed));
19106
19397
  var stackPullRequests = (revision) => gen2(function* () {
19107
19398
  const github = yield* GitHub;
19108
19399
  const stack = yield* stackChanges(revision);
19109
- const [targets, found] = yield* all3([
19400
+ const [targets, counts, found] = yield* all3([
19110
19401
  bookmarkTargets,
19402
+ lineCountsAt(stack.map(({ commitId }) => commitId)),
19111
19403
  forEach2(stack, ({ bookmark }) => github.pullRequestsFrom(bookmark), {
19112
19404
  concurrency: "unbounded"
19113
19405
  })
19114
19406
  ], { concurrency: "unbounded" });
19115
- return stack.flatMap(({ bookmark, commitId }, index) => toArray(pullRequestOf(found[index] ?? [], commitId, targets.get(bookmark)?.origin))).toReversed();
19407
+ const linked = [];
19408
+ for (const [index, { bookmark, commitId }] of stack.entries()) {
19409
+ const pullRequest = pullRequestOf(found[index] ?? [], commitId, targets.get(bookmark)?.origin);
19410
+ const changed = counts.get(commitId);
19411
+ if (isSome2(pullRequest)) {
19412
+ if (changed === undefined) {
19413
+ return yield* new JjFailed({ message: `jj printed no line counts for ${commitId}` });
19414
+ }
19415
+ linked.push({ ...pullRequest.value, ...changed });
19416
+ }
19417
+ }
19418
+ return linked.toReversed();
19116
19419
  });
19117
19420
  var links = ({
19118
19421
  copy,
@@ -19130,7 +19433,7 @@ var links = ({
19130
19433
  var linksCommand = make32("links", {
19131
19434
  copy: Boolean6("copy").pipe(withDefault5(false), withDescription2("Also copy the links to the clipboard, as links that Slack pastes, or in a Claude Code cloud session say how to give them to the user")),
19132
19435
  revision: revisionFlag("A change of the stack to list")
19133
- }, (options) => asUserError(links(options).pipe(provide3([GitHubFromOrigin, ClipboardLive])))).pipe(withHelp("Print the stack's pull requests as Markdown links", "Prints one line per pull request, top first: \uD83D\uDCDD for a draft, \uD83D\uDC40 for one ready for review, \uD83C\uDFC1 for a merged one and \uD83D\uDEAB for one closed unmerged, then a Markdown link showing its number and title.", "A change's pull request is the open one from its branch, or else the newest closed one whose head is the change or the commit pushed for it. A change with no pull request is left out, as is one that `sync` abandoned because its pull request merged. Fails where no change has one.", "With `--copy`, also puts the links on the clipboard as HTML, which Slack and other apps paste as links. That runs `osascript` on macOS, which also copies the Markdown as plain text, and `wl-copy` or `xclip` on Linux, which copy the HTML alone.", "In a Claude Code cloud session, where `CLAUDE_CODE_REMOTE` is `true`, `--copy` copies nothing. It tells the agent to put the Markdown in its reply, which the Claude app shows as links that paste into Slack.", "Fails if the changes aren't a chain, if one has conflicts, or if one doesn't have exactly one bookmark, as `log` does. Changes nothing, locally or on GitHub."));
19436
+ }, (options) => asUserError(links(options).pipe(provide3([GitHubFromOrigin, ClipboardLive])))).pipe(withHelp("Print the stack's pull requests as Markdown links", "Prints one line per pull request, top first: \uD83D\uDCDD for a draft, \uD83D\uDC40 for one ready for review, \uD83C\uDFC1 for a merged one and \uD83D\uDEAB for one closed unmerged, then a Markdown link showing its number and title, then the lines its change adds and removes, as `+123/-45`.", "A change's pull request is the open one from its branch, or else the newest closed one whose head is the change or the commit pushed for it. A change with no pull request is left out, as is one that `sync` abandoned because its pull request merged. Fails where no change has one.", "With `--copy`, also puts the links on the clipboard as HTML, which Slack and other apps paste as links. That runs `osascript` on macOS, which also copies the Markdown as plain text, and `wl-copy` or `xclip` on Linux, which copy the HTML alone.", "In a Claude Code cloud session, where `CLAUDE_CODE_REMOTE` is `true`, `--copy` copies nothing. It tells the agent to put the Markdown in its reply, which the Claude app shows as links that paste into Slack.", "Fails if the changes aren't a chain, if one has conflicts, or if one doesn't have exactly one bookmark, as `log` does. Changes nothing, locally or on GitHub."));
19134
19437
 
19135
19438
  // src/cli/gh/log.ts
19136
19439
  var logLines2 = (entries) => {