@kitman-sh/cli 0.9.0 → 0.10.53

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 (37) hide show
  1. package/dist/chunk-11p4wf6n.js +3551 -0
  2. package/dist/chunk-1mc9vgcr.js +39 -0
  3. package/dist/chunk-30397r95.js +30 -0
  4. package/dist/chunk-3bj7sc3v.js +389 -0
  5. package/dist/chunk-6vns3ej0.js +23 -0
  6. package/dist/chunk-7thnf14y.js +936 -0
  7. package/dist/chunk-arvwar2c.js +141 -0
  8. package/dist/chunk-b6thzgc9.js +32 -0
  9. package/dist/{chunk-8bvf4fh4.js → chunk-ctasxxz5.js} +26 -11
  10. package/dist/{chunk-5gjpv3ax.js → chunk-dzh9e6n2.js} +824 -651
  11. package/dist/{chunk-snn0e1qb.js → chunk-eg8f5ncv.js} +7 -3
  12. package/dist/chunk-g5bs3f6z.js +173 -0
  13. package/dist/chunk-jafetf7z.js +109 -0
  14. package/dist/chunk-jagzz148.js +527 -0
  15. package/dist/{chunk-1d4316hp.js → chunk-jfvq7s24.js} +38 -25
  16. package/dist/chunk-mbctzx7e.js +11436 -0
  17. package/dist/chunk-mej2bx5n.js +100 -0
  18. package/dist/chunk-p6spvbwq.js +6305 -0
  19. package/dist/chunk-pp1p3g6e.js +133 -0
  20. package/dist/chunk-r8p3nxcp.js +231 -0
  21. package/dist/chunk-txwt6r25.js +1731 -0
  22. package/dist/chunk-v290mf51.js +5242 -0
  23. package/dist/chunk-vjmz23rs.js +13 -0
  24. package/dist/chunk-vyv0p5eq.js +3183 -0
  25. package/dist/chunk-wh1pa2aa.js +15322 -0
  26. package/dist/chunk-x0b92bjb.js +222 -0
  27. package/dist/{chunk-8z5b6fpd.js → chunk-x9dhxfts.js} +216 -152
  28. package/dist/chunk-z821b2gp.js +164 -0
  29. package/dist/index.js +13 -5738
  30. package/dist/opencode-reader.main.ts +4 -0
  31. package/package.json +6 -5
  32. package/dist/chunk-3gxahgnq.js +0 -28495
  33. package/dist/chunk-ehzbtavj.js +0 -247
  34. package/dist/chunk-f5z8tgss.js +0 -1214
  35. package/dist/chunk-kdb1cbnx.js +0 -1273
  36. package/dist/chunk-ke1w0hx7.js +0 -5771
  37. package/dist/chunk-z6hc4ew9.js +0 -13
@@ -0,0 +1,3551 @@
1
+ // @bun
2
+ import {
3
+ pipeArguments,
4
+ dual,
5
+ identity,
6
+ constant,
7
+ constTrue,
8
+ constVoid,
9
+ pipe,
10
+ memoize,
11
+ isNotUndefined,
12
+ hasProperty,
13
+ isTagged,
14
+ toJson,
15
+ assignProperty,
16
+ args,
17
+ evaluate,
18
+ PipeInspectableProto,
19
+ isExit,
20
+ causeFail,
21
+ makePrimitive,
22
+ exitSucceed,
23
+ exitFailCause,
24
+ exitFail,
25
+ withFiber,
26
+ Done,
27
+ Prototype,
28
+ String3,
29
+ mapInput,
30
+ none,
31
+ some,
32
+ isSome,
33
+ match,
34
+ getOrUndefined,
35
+ map4,
36
+ Service2,
37
+ add,
38
+ get4,
39
+ Reference,
40
+ fromInputUnsafe,
41
+ isFinite,
42
+ normalize,
43
+ succeed,
44
+ fail3,
45
+ isFailure,
46
+ isSuccess,
47
+ map5,
48
+ all2,
49
+ fromIterable,
50
+ isArrayNonEmpty,
51
+ isReadonlyArrayNonEmpty,
52
+ isCanonicalArrayIndex,
53
+ getUnsafe2,
54
+ sort,
55
+ of,
56
+ map6,
57
+ Error2,
58
+ TaggedError,
59
+ getCurrentFiber,
60
+ fiberJoin,
61
+ fiberInterrupt,
62
+ succeed2,
63
+ sync,
64
+ suspend2,
65
+ succeedNone,
66
+ void_,
67
+ callback2,
68
+ asSome,
69
+ andThen,
70
+ flatMap2,
71
+ exitInterrupt,
72
+ exitVoid,
73
+ exitZipRight,
74
+ scopeAddFinalizer,
75
+ scope,
76
+ onExitPrimitive,
77
+ onExitUnsafe,
78
+ uninterruptibleMask,
79
+ fiberRunIn,
80
+ makeLatchUnsafe,
81
+ makeLatch,
82
+ succeed3,
83
+ failCause2,
84
+ fail4,
85
+ interrupt2,
86
+ void_2,
87
+ isSuccess2,
88
+ isFailure2,
89
+ asVoidAll,
90
+ makeUnsafe5,
91
+ _await,
92
+ interruptWith,
93
+ doneUnsafe,
94
+ Scope,
95
+ makeUnsafe6,
96
+ provide,
97
+ addFinalizerExit,
98
+ addFinalizer,
99
+ forkUnsafe,
100
+ close,
101
+ isCause,
102
+ isFailReason,
103
+ isDieReason,
104
+ fromReasons,
105
+ die2,
106
+ makeFailReason,
107
+ makeDieReason,
108
+ squash,
109
+ isDone2,
110
+ Done2,
111
+ done,
112
+ reasonAnnotations,
113
+ catchDone,
114
+ isDoneCause,
115
+ filterDone,
116
+ doneExitFromCause,
117
+ matchEffect,
118
+ isEffect,
119
+ all3,
120
+ forEach,
121
+ whileLoop,
122
+ promise,
123
+ tryPromise,
124
+ succeed6,
125
+ suspend3,
126
+ sync2,
127
+ void_3,
128
+ callback3,
129
+ never,
130
+ gen,
131
+ fail7,
132
+ failCause3,
133
+ die3,
134
+ try_2,
135
+ yieldNow,
136
+ withFiber2,
137
+ fromResult,
138
+ flatMap3,
139
+ flatten,
140
+ andThen2,
141
+ tap2,
142
+ option2,
143
+ exit,
144
+ map8,
145
+ as,
146
+ asSome2,
147
+ asVoid,
148
+ zipWith,
149
+ catch_,
150
+ catchTag,
151
+ catchReason,
152
+ catchCause2,
153
+ catchIf,
154
+ mapError2,
155
+ orDie,
156
+ tapError2,
157
+ ignoreCause,
158
+ orElseSucceed,
159
+ sleep,
160
+ raceFirst,
161
+ when,
162
+ matchCauseEffect,
163
+ context,
164
+ contextWith,
165
+ provideContext2,
166
+ scope2,
167
+ scoped,
168
+ scopedWith,
169
+ ensuring2,
170
+ onError,
171
+ onExitPrimitive2,
172
+ onExit,
173
+ interrupt3,
174
+ onInterrupt,
175
+ uninterruptible,
176
+ uninterruptibleMask2,
177
+ forever,
178
+ forkChild,
179
+ forkIn,
180
+ runFork,
181
+ runForkWith,
182
+ runPromise,
183
+ fnUntraced,
184
+ mapEager,
185
+ flatMapEager,
186
+ catchEager,
187
+ Pointer,
188
+ passthrough,
189
+ transformEffect,
190
+ Transformation,
191
+ unknown,
192
+ getIndexSignatureKeys,
193
+ applyToSelfOrLastLinkEncoding,
194
+ decodeTo,
195
+ toEncoded,
196
+ decodeUnknownEffect,
197
+ SchemaError,
198
+ make18,
199
+ String4,
200
+ toCodecStringTree,
201
+ encodeUnknownJsonStringSync
202
+ } from "./chunk-mbctzx7e.js";
203
+
204
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/Iterable.js
205
+ var headUnsafe = (self) => {
206
+ const iterator = self[Symbol.iterator]();
207
+ const result = iterator.next();
208
+ if (result.done)
209
+ throw new Error("headUnsafe: empty iterable");
210
+ return result.value;
211
+ };
212
+ var constEmpty = {
213
+ [Symbol.iterator]() {
214
+ return constEmptyIterator;
215
+ }
216
+ };
217
+ var constEmptyIterator = {
218
+ next() {
219
+ return {
220
+ done: true,
221
+ value: undefined
222
+ };
223
+ }
224
+ };
225
+
226
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/Record.js
227
+ var has = /* @__PURE__ */ dual(2, (self, key) => Object.hasOwn(self, key));
228
+ var map = /* @__PURE__ */ dual(2, (self, f) => {
229
+ const out = {
230
+ ...self
231
+ };
232
+ for (const key of keys(self)) {
233
+ assignProperty(out, key, f(self[key], key));
234
+ }
235
+ return out;
236
+ });
237
+ var keys = (self) => Object.keys(self);
238
+ var isSubrecordBy = (equivalence) => dual(2, (self, that) => {
239
+ for (const key of keys(self)) {
240
+ if (!has(that, key) || !equivalence(self[key], that[key])) {
241
+ return false;
242
+ }
243
+ }
244
+ return true;
245
+ });
246
+ var makeEquivalence = (equivalence) => {
247
+ const is = isSubrecordBy(equivalence);
248
+ return (self, that) => is(self, that) && is(that, self);
249
+ };
250
+
251
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/ByteSize.js
252
+ var bigint0 = /* @__PURE__ */ BigInt(0);
253
+ var bigint1 = /* @__PURE__ */ BigInt(1);
254
+ var decimalBase = /* @__PURE__ */ BigInt(1000);
255
+ var binaryBase = /* @__PURE__ */ BigInt(1024);
256
+ var decimalUnits = [{
257
+ symbol: "B",
258
+ factor: bigint1,
259
+ names: ["B", "byte", "bytes"]
260
+ }, {
261
+ symbol: "kB",
262
+ factor: decimalBase,
263
+ names: ["kB", "kilobyte", "kilobytes"]
264
+ }, {
265
+ symbol: "MB",
266
+ factor: decimalBase ** /* @__PURE__ */ BigInt(2),
267
+ names: ["MB", "megabyte", "megabytes"]
268
+ }, {
269
+ symbol: "GB",
270
+ factor: decimalBase ** /* @__PURE__ */ BigInt(3),
271
+ names: ["GB", "gigabyte", "gigabytes"]
272
+ }, {
273
+ symbol: "TB",
274
+ factor: decimalBase ** /* @__PURE__ */ BigInt(4),
275
+ names: ["TB", "terabyte", "terabytes"]
276
+ }, {
277
+ symbol: "PB",
278
+ factor: decimalBase ** /* @__PURE__ */ BigInt(5),
279
+ names: ["PB", "petabyte", "petabytes"]
280
+ }, {
281
+ symbol: "EB",
282
+ factor: decimalBase ** /* @__PURE__ */ BigInt(6),
283
+ names: ["EB", "exabyte", "exabytes"]
284
+ }, {
285
+ symbol: "ZB",
286
+ factor: decimalBase ** /* @__PURE__ */ BigInt(7),
287
+ names: ["ZB", "zettabyte", "zettabytes"]
288
+ }, {
289
+ symbol: "YB",
290
+ factor: decimalBase ** /* @__PURE__ */ BigInt(8),
291
+ names: ["YB", "yottabyte", "yottabytes"]
292
+ }, {
293
+ symbol: "RB",
294
+ factor: decimalBase ** /* @__PURE__ */ BigInt(9),
295
+ names: ["RB", "ronnabyte", "ronnabytes"]
296
+ }, {
297
+ symbol: "QB",
298
+ factor: decimalBase ** /* @__PURE__ */ BigInt(10),
299
+ names: ["QB", "quettabyte", "quettabytes"]
300
+ }];
301
+ var binaryUnits = [decimalUnits[0], {
302
+ symbol: "KiB",
303
+ factor: binaryBase,
304
+ names: ["KiB", "kibibyte", "kibibytes"]
305
+ }, {
306
+ symbol: "MiB",
307
+ factor: binaryBase ** /* @__PURE__ */ BigInt(2),
308
+ names: ["MiB", "mebibyte", "mebibytes"]
309
+ }, {
310
+ symbol: "GiB",
311
+ factor: binaryBase ** /* @__PURE__ */ BigInt(3),
312
+ names: ["GiB", "gibibyte", "gibibytes"]
313
+ }, {
314
+ symbol: "TiB",
315
+ factor: binaryBase ** /* @__PURE__ */ BigInt(4),
316
+ names: ["TiB", "tebibyte", "tebibytes"]
317
+ }, {
318
+ symbol: "PiB",
319
+ factor: binaryBase ** /* @__PURE__ */ BigInt(5),
320
+ names: ["PiB", "pebibyte", "pebibytes"]
321
+ }, {
322
+ symbol: "EiB",
323
+ factor: binaryBase ** /* @__PURE__ */ BigInt(6),
324
+ names: ["EiB", "exbibyte", "exbibytes"]
325
+ }, {
326
+ symbol: "ZiB",
327
+ factor: binaryBase ** /* @__PURE__ */ BigInt(7),
328
+ names: ["ZiB", "zebibyte", "zebibytes"]
329
+ }, {
330
+ symbol: "YiB",
331
+ factor: binaryBase ** /* @__PURE__ */ BigInt(8),
332
+ names: ["YiB", "yobibyte", "yobibytes"]
333
+ }];
334
+ var allUnits = [...decimalUnits, .../* @__PURE__ */ binaryUnits.slice(1)];
335
+ var unitsByName = /* @__PURE__ */ new Map(/* @__PURE__ */ allUnits.flatMap((unit) => unit.names.map((name) => [name, unit])));
336
+ var make = (value) => value;
337
+ var invalid = (message) => {
338
+ throw new Error(`Invalid ByteSize: ${message}`);
339
+ };
340
+ var fromNumber = (input) => {
341
+ if (!Number.isSafeInteger(input) || input < 0) {
342
+ return invalid(`expected a non-negative safe integer, received ${input}`);
343
+ }
344
+ return make(BigInt(input));
345
+ };
346
+ var maxSafeInteger = /* @__PURE__ */ BigInt(Number.MAX_SAFE_INTEGER);
347
+ var scaleDecimal = (quantity, factor) => {
348
+ const match = /^(\d+)(?:\.(\d+))?(?:e([+-]\d+))?$/.exec(quantity);
349
+ if (match === null)
350
+ return;
351
+ const fraction = match[2] ?? "";
352
+ const numerator = BigInt(match[1] + fraction) * factor;
353
+ const shift = Number(match[3] ?? 0) - fraction.length;
354
+ if (shift >= 0)
355
+ return numerator * BigInt(10) ** BigInt(shift);
356
+ const scale = BigInt(10) ** BigInt(-shift);
357
+ return numerator % scale === bigint0 ? numerator / scale : undefined;
358
+ };
359
+ var fromStringUnsafe = (input) => {
360
+ const match = /^\s*(\d+(?:\.\d+)?)\s*([A-Za-z]+)\s*$/.exec(input);
361
+ if (match === null)
362
+ return invalid(`unsupported syntax ${JSON.stringify(input)}`);
363
+ const unit = unitsByName.get(match[2]);
364
+ if (unit === undefined)
365
+ return invalid(`unsupported unit ${JSON.stringify(match[2])}`);
366
+ const value = scaleDecimal(match[1], unit.factor);
367
+ if (value === undefined)
368
+ return invalid(`${JSON.stringify(input)} does not represent an integral number of bytes`);
369
+ return make(value);
370
+ };
371
+ var fromInputUnsafe2 = (input) => {
372
+ switch (typeof input) {
373
+ case "bigint":
374
+ if (input < bigint0)
375
+ return invalid(`expected a non-negative bigint, received ${input}`);
376
+ return make(input);
377
+ case "number":
378
+ return fromNumber(input);
379
+ case "string":
380
+ return fromStringUnsafe(input);
381
+ }
382
+ return invalid(`unsupported input ${input}`);
383
+ };
384
+ var bytes = (value) => typeof value === "bigint" ? fromInputUnsafe2(value) : fromNumber(value);
385
+
386
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/Fiber.js
387
+ var join = fiberJoin;
388
+ var interrupt = fiberInterrupt;
389
+ var getCurrent = getCurrentFiber;
390
+ var runIn = fiberRunIn;
391
+
392
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/internal/glob.js
393
+ var maxExpansions = 1e4;
394
+ var maxExpandedLength = 2 ** 22;
395
+ var maxBraceDepth = 64;
396
+ var compile = (patterns, dot) => {
397
+ const nodes = [];
398
+ const starts = new Set;
399
+ for (const pattern of patterns) {
400
+ for (const expanded of expandBraces(pattern)) {
401
+ const start = nodes.length;
402
+ if (compilePattern(expanded, nodes)) {
403
+ starts.add(start);
404
+ }
405
+ }
406
+ }
407
+ const initial = closure(nodes, starts);
408
+ return {
409
+ nodes,
410
+ initial,
411
+ dot,
412
+ masks: nodes.length <= 32 ? compileMasks(nodes, initial) : undefined
413
+ };
414
+ };
415
+ var compileMasks = (nodes, initial) => {
416
+ let start = 0;
417
+ for (const state of initial) {
418
+ start |= 1 << state;
419
+ }
420
+ let globstar = 0;
421
+ let end = 0;
422
+ let endFile = 0;
423
+ for (let i = 0;i < nodes.length; i++) {
424
+ const node = nodes[i];
425
+ const bit = 1 << i;
426
+ if (node._tag === "Globstar") {
427
+ globstar |= bit;
428
+ } else if (node._tag === "End") {
429
+ end |= bit;
430
+ if (!node.directoryOnly) {
431
+ endFile |= bit;
432
+ }
433
+ }
434
+ }
435
+ return {
436
+ initial: start,
437
+ globstar,
438
+ end,
439
+ endFile
440
+ };
441
+ };
442
+ var isUnc = (path) => path.startsWith("//") && path[2] !== undefined && path[2] !== "/";
443
+ var compilePattern = (pattern, nodes) => {
444
+ if (pattern === "" || isUnc(pattern)) {
445
+ return false;
446
+ }
447
+ const raw = splitSegments(pattern);
448
+ const globstar = raw.indexOf("**");
449
+ if (globstar !== -1 && raw.some((segment, i) => i > globstar && (segment === "." || segment === ".."))) {
450
+ return false;
451
+ }
452
+ const {
453
+ directory,
454
+ segments
455
+ } = normalize2(raw);
456
+ if (segments.length === 0) {
457
+ return false;
458
+ }
459
+ for (const segment of segments) {
460
+ if (segment !== "**") {
461
+ nodes.push(compileSegment(Array.from(segment)));
462
+ } else if (nodes[nodes.length - 1] !== globstarNode) {
463
+ nodes.push(globstarNode);
464
+ }
465
+ }
466
+ nodes.push({
467
+ _tag: "End",
468
+ directoryOnly: directory
469
+ });
470
+ return true;
471
+ };
472
+ var globstarNode = {
473
+ _tag: "Globstar"
474
+ };
475
+ var splitSegments = (pattern) => {
476
+ const segments = [];
477
+ let start = 0;
478
+ for (let i = 0;i < pattern.length; i++) {
479
+ if (pattern[i] === "\\") {
480
+ i++;
481
+ } else if (pattern[i] === "/") {
482
+ segments.push(pattern.slice(start, i));
483
+ start = i + 1;
484
+ }
485
+ }
486
+ segments.push(pattern.slice(start));
487
+ return segments;
488
+ };
489
+ var drive = /^[A-Za-z]:/;
490
+ var isDrive = (segment) => segment.length === 2 && drive.test(segment);
491
+ var isRoot = (name) => name === "" || name.length === 3 && name[2] === "/" && drive.test(name);
492
+ var isAbsolute = (path) => path.startsWith("/") || path[2] === "/" && drive.test(path);
493
+ var normalize2 = (raw) => {
494
+ const segments = [];
495
+ let i = 0;
496
+ if (raw.length > 1 && (raw[0] === "" || isDrive(raw[0]))) {
497
+ segments.push(raw[0] === "" ? "" : `${raw[0]}/`);
498
+ i = 1;
499
+ }
500
+ let directory = false;
501
+ for (;i < raw.length; i++) {
502
+ const segment = raw[i];
503
+ if (segment === "" || segment === ".") {
504
+ directory = i === raw.length - 1 && segments.length > 0;
505
+ } else {
506
+ segments.push(segment);
507
+ directory = false;
508
+ }
509
+ }
510
+ if (segments.length === 0 && raw.includes(".")) {
511
+ segments.push(".");
512
+ }
513
+ return {
514
+ segments,
515
+ directory
516
+ };
517
+ };
518
+ var compileSegment = (chars) => {
519
+ const tokens = [];
520
+ let literal = "";
521
+ let magic = false;
522
+ let classes = true;
523
+ for (let i = 0;i < chars.length; i++) {
524
+ const char = chars[i];
525
+ if (char === "\\" && i + 1 < chars.length) {
526
+ literal += chars[++i];
527
+ tokens.push({
528
+ _tag: "Char",
529
+ code: chars[i].codePointAt(0)
530
+ });
531
+ } else if (char === "*") {
532
+ magic = true;
533
+ if (tokens[tokens.length - 1]?._tag !== "Star") {
534
+ tokens.push({
535
+ _tag: "Star"
536
+ });
537
+ }
538
+ } else if (char === "?") {
539
+ magic = true;
540
+ tokens.push({
541
+ _tag: "Any"
542
+ });
543
+ } else if (char === "[" && classes) {
544
+ const parsed = parseClass(chars, i);
545
+ if (parsed === undefined) {
546
+ classes = false;
547
+ literal += char;
548
+ tokens.push({
549
+ _tag: "Char",
550
+ code: char.codePointAt(0)
551
+ });
552
+ } else {
553
+ magic = true;
554
+ tokens.push(parsed.token);
555
+ i = parsed.end;
556
+ }
557
+ } else {
558
+ literal += char;
559
+ tokens.push({
560
+ _tag: "Char",
561
+ code: char.codePointAt(0)
562
+ });
563
+ }
564
+ }
565
+ if (!magic) {
566
+ return {
567
+ _tag: "Literal",
568
+ value: literal
569
+ };
570
+ }
571
+ const first = tokens[0];
572
+ return {
573
+ _tag: "Wildcard",
574
+ tokens,
575
+ leadingDot: first._tag === "Char" && first.code === 46,
576
+ affixes: compileAffixes(tokens)
577
+ };
578
+ };
579
+ var compileAffixes = (tokens) => {
580
+ let prefix = "";
581
+ let suffix;
582
+ for (const token of tokens) {
583
+ if (token._tag === "Star" && suffix === undefined) {
584
+ suffix = "";
585
+ } else if (token._tag === "Char" && (token.code < 55296 || token.code > 57343)) {
586
+ const char = String.fromCodePoint(token.code);
587
+ if (suffix === undefined) {
588
+ prefix += char;
589
+ } else {
590
+ suffix += char;
591
+ }
592
+ } else {
593
+ return;
594
+ }
595
+ }
596
+ return suffix === undefined ? undefined : {
597
+ prefix,
598
+ suffix
599
+ };
600
+ };
601
+ var range = (from, to) => [from.codePointAt(0), to.codePointAt(0)];
602
+ var posixClasses = {
603
+ alnum: [.../* @__PURE__ */ range("0", "9"), .../* @__PURE__ */ range("A", "Z"), .../* @__PURE__ */ range("a", "z")],
604
+ alpha: [.../* @__PURE__ */ range("A", "Z"), .../* @__PURE__ */ range("a", "z")],
605
+ blank: [9, 9, 32, 32],
606
+ cntrl: [0, 31, 127, 127],
607
+ digit: /* @__PURE__ */ range("0", "9"),
608
+ graph: [33, 126],
609
+ lower: /* @__PURE__ */ range("a", "z"),
610
+ print: [32, 126],
611
+ punct: [33, 47, 58, 64, 91, 96, 123, 126],
612
+ space: [9, 13, 32, 32],
613
+ upper: /* @__PURE__ */ range("A", "Z"),
614
+ word: [.../* @__PURE__ */ range("0", "9"), .../* @__PURE__ */ range("A", "Z"), 95, 95, .../* @__PURE__ */ range("a", "z")],
615
+ xdigit: [.../* @__PURE__ */ range("0", "9"), .../* @__PURE__ */ range("A", "F"), .../* @__PURE__ */ range("a", "f")]
616
+ };
617
+ var parsePosixClass = (chars, open) => {
618
+ for (let i = open + 2;i < chars.length && i <= open + 8; i++) {
619
+ if (chars[i] === ":" && chars[i + 1] === "]") {
620
+ const ranges = posixClasses[chars.slice(open + 2, i).join("")];
621
+ return ranges === undefined ? undefined : {
622
+ ranges,
623
+ end: i + 1
624
+ };
625
+ }
626
+ }
627
+ return;
628
+ };
629
+ var parseClass = (chars, open) => {
630
+ let i = open + 1;
631
+ const negated = chars[i] === "!" || chars[i] === "^";
632
+ if (negated) {
633
+ i++;
634
+ }
635
+ const ranges = [];
636
+ for (let first = true;i < chars.length; i++, first = false) {
637
+ let char = chars[i];
638
+ if (char === "/") {
639
+ return;
640
+ }
641
+ if (char === "]" && !first) {
642
+ return {
643
+ token: {
644
+ _tag: "Class",
645
+ ranges,
646
+ negated
647
+ },
648
+ end: i
649
+ };
650
+ }
651
+ if (char === "[" && chars[i + 1] === ":") {
652
+ const posix = parsePosixClass(chars, i);
653
+ if (posix !== undefined) {
654
+ ranges.push(...posix.ranges);
655
+ i = posix.end;
656
+ continue;
657
+ }
658
+ }
659
+ if (char === "\\" && i + 1 < chars.length) {
660
+ char = chars[++i];
661
+ }
662
+ if (chars[i + 1] === "-" && i + 2 < chars.length && chars[i + 2] !== "]") {
663
+ let next = i + 2;
664
+ if (chars[next] === "/") {
665
+ return;
666
+ }
667
+ if (chars[next] === "\\" && next + 1 < chars.length) {
668
+ next++;
669
+ }
670
+ ranges.push(...range(char, chars[next]));
671
+ i = next;
672
+ continue;
673
+ }
674
+ ranges.push(...range(char, char));
675
+ }
676
+ return;
677
+ };
678
+ var expandBraces = (pattern) => {
679
+ const chars = Array.from(pattern);
680
+ const groups = matchBraceGroups(chars);
681
+ if (groups.size === 0) {
682
+ return [pattern];
683
+ }
684
+ const sequence = parseBraceSequence(chars, 0, chars.length, groups, 0);
685
+ if (sequence === undefined) {
686
+ return [pattern];
687
+ }
688
+ const count = countExpansions(sequence);
689
+ return count > maxExpansions || count * pattern.length > maxExpandedLength ? [pattern] : expandSequence(sequence);
690
+ };
691
+ var matchBraceGroups = (chars) => {
692
+ const groups = new Map;
693
+ const stack = [];
694
+ let classes = true;
695
+ for (let i = 0;i < chars.length; i++) {
696
+ const char = chars[i];
697
+ if (char === "\\") {
698
+ i++;
699
+ } else if (char === "/") {
700
+ classes = true;
701
+ } else if (char === "[" && classes) {
702
+ const parsed = parseClass(chars, i);
703
+ if (parsed === undefined) {
704
+ classes = false;
705
+ } else {
706
+ i = parsed.end;
707
+ }
708
+ } else if (char === "{") {
709
+ stack.push({
710
+ open: i,
711
+ commas: []
712
+ });
713
+ } else if (char === ",") {
714
+ stack[stack.length - 1]?.commas.push(i);
715
+ } else if (char === "}") {
716
+ const group = stack.pop();
717
+ if (group !== undefined && group.commas.length > 0) {
718
+ groups.set(group.open, {
719
+ commas: group.commas,
720
+ close: i
721
+ });
722
+ }
723
+ }
724
+ }
725
+ return groups;
726
+ };
727
+ var parseBraceSequence = (chars, start, end, groups, depth) => {
728
+ if (depth > maxBraceDepth) {
729
+ return;
730
+ }
731
+ const parts = [];
732
+ let text = "";
733
+ for (let i = start;i < end; i++) {
734
+ const group = groups.get(i);
735
+ if (group === undefined) {
736
+ if (chars[i] === "\\" && i + 1 < end) {
737
+ text += chars[i++];
738
+ }
739
+ text += chars[i];
740
+ continue;
741
+ }
742
+ const alternatives = [];
743
+ let from = i + 1;
744
+ for (const to of [...group.commas, group.close]) {
745
+ const alternative = parseBraceSequence(chars, from, to, groups, depth + 1);
746
+ if (alternative === undefined) {
747
+ return;
748
+ }
749
+ alternatives.push(alternative);
750
+ from = to + 1;
751
+ }
752
+ if (text !== "") {
753
+ parts.push(text);
754
+ text = "";
755
+ }
756
+ parts.push(alternatives);
757
+ i = group.close;
758
+ }
759
+ if (text !== "") {
760
+ parts.push(text);
761
+ }
762
+ return parts;
763
+ };
764
+ var countExpansions = (sequence) => {
765
+ let count = 1;
766
+ for (const part of sequence) {
767
+ if (typeof part !== "string") {
768
+ let sum = 0;
769
+ for (const alternative of part) {
770
+ sum += countExpansions(alternative);
771
+ }
772
+ count *= sum;
773
+ if (count > maxExpansions) {
774
+ return Infinity;
775
+ }
776
+ }
777
+ }
778
+ return count;
779
+ };
780
+ var expandSequence = (sequence) => {
781
+ let out = [""];
782
+ for (const part of sequence) {
783
+ if (typeof part === "string") {
784
+ out = out.map((prefix) => prefix + part);
785
+ } else {
786
+ const alternatives = part.flatMap(expandSequence);
787
+ out = out.flatMap((prefix) => alternatives.map((alternative) => prefix + alternative));
788
+ }
789
+ }
790
+ return out;
791
+ };
792
+ var matchToken = (token, code) => {
793
+ switch (token._tag) {
794
+ case "Char":
795
+ return token.code === code;
796
+ case "Any":
797
+ return true;
798
+ case "Star":
799
+ return false;
800
+ case "Class": {
801
+ let found = false;
802
+ for (let i = 0;i < token.ranges.length && !found; i += 2) {
803
+ found = code >= token.ranges[i] && code <= token.ranges[i + 1];
804
+ }
805
+ return found !== token.negated;
806
+ }
807
+ }
808
+ };
809
+ var width = (code) => code > 65535 ? 2 : 1;
810
+ var matchWildcard = (node, name, dot) => {
811
+ if (name === "." || name === ".." || name.startsWith(".") && !dot && !node.leadingDot) {
812
+ return false;
813
+ }
814
+ if (node.affixes !== undefined) {
815
+ const {
816
+ prefix,
817
+ suffix
818
+ } = node.affixes;
819
+ return name.length >= prefix.length + suffix.length && name.startsWith(prefix) && name.endsWith(suffix);
820
+ }
821
+ const {
822
+ tokens
823
+ } = node;
824
+ let t = 0;
825
+ let c = 0;
826
+ let star = -1;
827
+ let resume = 0;
828
+ while (c < name.length) {
829
+ if (tokens[t]?._tag === "Star") {
830
+ star = t++;
831
+ resume = c;
832
+ continue;
833
+ }
834
+ const code = name.codePointAt(c);
835
+ if (t < tokens.length && matchToken(tokens[t], code)) {
836
+ t++;
837
+ c += width(code);
838
+ } else if (star !== -1) {
839
+ t = star + 1;
840
+ resume += width(name.codePointAt(resume));
841
+ c = resume;
842
+ } else {
843
+ return false;
844
+ }
845
+ }
846
+ while (tokens[t]?._tag === "Star") {
847
+ t++;
848
+ }
849
+ return t === tokens.length;
850
+ };
851
+ var closure = (nodes, states) => {
852
+ for (const state of states) {
853
+ if (nodes[state]._tag === "Globstar") {
854
+ states.add(state + 1);
855
+ }
856
+ }
857
+ return states;
858
+ };
859
+ var step = (compiled, states, name) => {
860
+ const explicit = new Set;
861
+ const viaGlobstar = new Set;
862
+ const root = isRoot(name);
863
+ for (const state of states) {
864
+ const node = compiled.nodes[state];
865
+ switch (node._tag) {
866
+ case "Globstar": {
867
+ if (!root && name !== "." && name !== ".." && (compiled.dot || !name.startsWith("."))) {
868
+ viaGlobstar.add(state);
869
+ }
870
+ break;
871
+ }
872
+ case "Literal": {
873
+ if (node.value === name) {
874
+ explicit.add(state + 1);
875
+ }
876
+ break;
877
+ }
878
+ case "Wildcard": {
879
+ if (!root && matchWildcard(node, name, compiled.dot)) {
880
+ explicit.add(state + 1);
881
+ }
882
+ break;
883
+ }
884
+ }
885
+ }
886
+ return {
887
+ explicit: closure(compiled.nodes, explicit),
888
+ globstar: closure(compiled.nodes, viaGlobstar)
889
+ };
890
+ };
891
+ var union = (step) => {
892
+ if (step.globstar.size === 0) {
893
+ return step.explicit;
894
+ }
895
+ const states = new Set(step.explicit);
896
+ for (const state of step.globstar) {
897
+ states.add(state);
898
+ }
899
+ return states;
900
+ };
901
+ var accepts = (compiled, states, isDirectory) => {
902
+ for (const state of states) {
903
+ const node = compiled.nodes[state];
904
+ if (node._tag === "End" && (isDirectory || !node.directoryOnly)) {
905
+ return true;
906
+ }
907
+ }
908
+ return false;
909
+ };
910
+ var canDescend = (compiled, states) => {
911
+ for (const state of states) {
912
+ if (compiled.nodes[state]._tag !== "End") {
913
+ return true;
914
+ }
915
+ }
916
+ return false;
917
+ };
918
+ var needsDirectory = (compiled, states) => {
919
+ for (const state of states) {
920
+ const node = compiled.nodes[state];
921
+ if (node._tag === "End" && node.directoryOnly) {
922
+ return true;
923
+ }
924
+ }
925
+ return false;
926
+ };
927
+ var join2 = (parent, name) => {
928
+ if (parent === "") {
929
+ return name === "" ? "/" : name;
930
+ }
931
+ return parent.endsWith("/") ? parent + name : `${parent}/${name}`;
932
+ };
933
+ var isMissing = (error) => error.reason._tag === "NotFound" || error.reason._tag === "BadResource";
934
+ var isIgnorable = (error) => isMissing(error) || error.reason._tag === "PermissionDenied";
935
+ var isNotLink = (error) => isIgnorable(error) || error.reason._tag === "Unknown";
936
+ var DIRECTORY_CONCURRENCY = 16;
937
+ var byName = /* @__PURE__ */ mapInput(String3, (entry) => entry.name);
938
+ var make2 = (fs) => (pattern, options) => walk(fs, compile([pattern], options?.dot ?? false), options);
939
+ var walk = /* @__PURE__ */ fnUntraced(function* (fs, compiled, options) {
940
+ if (compiled.initial.size === 0) {
941
+ return [];
942
+ }
943
+ const root = options?.root ?? "";
944
+ const excludes = compile(options?.exclude ?? [], true);
945
+ const excludeNeedsDirectory = excludes.nodes.some((node) => node._tag === "End" && node.directoryOnly);
946
+ const toFsPath = (relative) => isAbsolute(relative) ? relative : relative === "" ? root === "" ? "." : root : join2(root, relative);
947
+ const isUnlisted = (value) => value === "." || value === ".." || isRoot(value);
948
+ const probe = (parent, name, named) => {
949
+ const path = toFsPath(join2(parent, name));
950
+ return fs.stat(path).pipe(map8((info) => info.type), catchReason("PlatformError", "NotFound", () => fs.readLink(path).pipe(as("SymbolicLink"), catchIf(isNotLink, () => succeed6(undefined)))), catchIf(named ? isMissing : isIgnorable, () => succeed6(undefined)), map8((type) => type === undefined ? undefined : {
951
+ name,
952
+ type
953
+ }));
954
+ };
955
+ const entries = (relative, states, named) => {
956
+ const literals = new Set;
957
+ let listed = !named;
958
+ for (const state of states) {
959
+ const node = compiled.nodes[state];
960
+ if (node._tag === "Literal") {
961
+ literals.add(node.value);
962
+ } else if (node._tag !== "End") {
963
+ listed = true;
964
+ }
965
+ }
966
+ const probed = listed ? [...literals].filter(isUnlisted) : [...literals];
967
+ return zipWith(listed ? catchIf(fs.readDirectoryEntries(toFsPath(relative)), named ? isMissing : isIgnorable, () => succeed6([])) : succeed6([]), forEach(probed, (name) => probe(relative, name, named), {
968
+ concurrency: 16
969
+ }), (listing, found) => ({
970
+ entries: sort([...listing, ...found.filter(isNotUndefined)], byName),
971
+ named: named && !listed
972
+ }));
973
+ };
974
+ const visit = ({
975
+ name,
976
+ type
977
+ }, parent, states, excluded) => {
978
+ const result = step(compiled, states, name);
979
+ const next = union(result);
980
+ if (next.size === 0) {
981
+ return;
982
+ }
983
+ const relative = join2(parent, name);
984
+ const nextExcluded = union(step(excludes, excluded, name));
985
+ const descend = canDescend(compiled, next);
986
+ const child = (isDirectory, link) => {
987
+ const accepted = accepts(compiled, next, isDirectory);
988
+ if (!accepted && (!isDirectory || !descend) || accepts(excludes, nextExcluded, isDirectory)) {
989
+ return;
990
+ }
991
+ return {
992
+ relative,
993
+ accepted,
994
+ excluded: nextExcluded,
995
+ next: !isDirectory || !descend ? undefined : !link || result.globstar.size === 0 ? next : canDescend(compiled, result.explicit) ? result.explicit : undefined
996
+ };
997
+ };
998
+ if (!descend && !needsDirectory(compiled, next) && !excludeNeedsDirectory) {
999
+ return child(false, false);
1000
+ }
1001
+ if (type !== "Unknown" && type !== "SymbolicLink") {
1002
+ return child(type === "Directory", false);
1003
+ }
1004
+ const path = toFsPath(relative);
1005
+ return fs.stat(path).pipe(map8((info) => info.type === "Directory"), catchIf(isIgnorable, () => succeed6(false)), flatMap3((isDirectory) => {
1006
+ const resolved = child(isDirectory, type === "SymbolicLink");
1007
+ if (type === "SymbolicLink" || resolved?.next === undefined || result.globstar.size === 0) {
1008
+ return succeed6(resolved);
1009
+ }
1010
+ return fs.readLink(path).pipe(as(child(isDirectory, true)), catchIf(isNotLink, () => succeed6(resolved)));
1011
+ }));
1012
+ };
1013
+ let slots = DIRECTORY_CONCURRENCY;
1014
+ let finishing = false;
1015
+ const failed = makeUnsafe5();
1016
+ const fork = (walk) => walk.pipe(onError((cause) => sync2(() => {
1017
+ if (!finishing) {
1018
+ doneUnsafe(failed, failCause3(cause));
1019
+ }
1020
+ })), ensuring2(sync2(() => {
1021
+ slots++;
1022
+ })), forkChild);
1023
+ const directory = fnUntraced(function* (relative, states, excluded, named) {
1024
+ const listing = yield* entries(relative, states, named);
1025
+ const children = [];
1026
+ const pending = [];
1027
+ for (const entry of listing.entries) {
1028
+ const child = visit(entry, relative, states, excluded);
1029
+ if (isEffect(child)) {
1030
+ const index = children.push(undefined) - 1;
1031
+ pending.push(map8(child, (child) => {
1032
+ children[index] = child;
1033
+ }));
1034
+ } else {
1035
+ children.push(child);
1036
+ }
1037
+ }
1038
+ if (pending.length > 0) {
1039
+ yield* all3(pending, {
1040
+ concurrency: 16,
1041
+ discard: true
1042
+ });
1043
+ }
1044
+ const subtrees = [];
1045
+ for (const child of children) {
1046
+ if (child?.next !== undefined) {
1047
+ const walk = directory(child.relative, child.next, child.excluded, listing.named);
1048
+ if (slots > 0) {
1049
+ slots--;
1050
+ subtrees.push(join(yield* fork(walk)));
1051
+ } else {
1052
+ subtrees.push(succeed6(yield* walk));
1053
+ }
1054
+ }
1055
+ }
1056
+ const out = [];
1057
+ let index = 0;
1058
+ for (const child of children) {
1059
+ if (child === undefined) {
1060
+ continue;
1061
+ }
1062
+ if (child.accepted) {
1063
+ out.push(child.relative);
1064
+ }
1065
+ if (child.next !== undefined) {
1066
+ for (const path of yield* subtrees[index++]) {
1067
+ out.push(path);
1068
+ }
1069
+ }
1070
+ }
1071
+ return out;
1072
+ });
1073
+ return yield* raceFirst(ensuring2(directory("", compiled.initial, excludes.initial, true), sync2(() => {
1074
+ finishing = true;
1075
+ })), _await(failed));
1076
+ });
1077
+
1078
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/PlatformError.js
1079
+ var TypeId = "~effect/PlatformError";
1080
+
1081
+ class BadArgument extends (/* @__PURE__ */ TaggedError("BadArgument")) {
1082
+ get message() {
1083
+ return `${this.module}.${this.method}${this.description ? `: ${this.description}` : ""}`;
1084
+ }
1085
+ }
1086
+
1087
+ class SystemError extends Error2 {
1088
+ get message() {
1089
+ return `${this._tag}: ${this.module}.${this.method}${this.pathOrDescriptor !== undefined ? ` (${this.pathOrDescriptor})` : ""}${this.description ? `: ${this.description}` : ""}`;
1090
+ }
1091
+ }
1092
+
1093
+ class PlatformError extends (/* @__PURE__ */ TaggedError("PlatformError")) {
1094
+ constructor(reason) {
1095
+ if ("cause" in reason) {
1096
+ super({
1097
+ reason,
1098
+ cause: reason.cause
1099
+ });
1100
+ } else {
1101
+ super({
1102
+ reason
1103
+ });
1104
+ }
1105
+ }
1106
+ [TypeId] = TypeId;
1107
+ get message() {
1108
+ return this.reason.message;
1109
+ }
1110
+ }
1111
+ var systemError = (options) => new PlatformError(new SystemError(options));
1112
+ var badArgument = (options) => new PlatformError(new BadArgument(options));
1113
+
1114
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/Latch.js
1115
+ var makeUnsafe2 = makeLatchUnsafe;
1116
+ var make3 = makeLatch;
1117
+
1118
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/MutableRef.js
1119
+ var TypeId2 = "~effect/MutableRef";
1120
+ var MutableRefProto = {
1121
+ [TypeId2]: TypeId2,
1122
+ ...PipeInspectableProto,
1123
+ toJSON() {
1124
+ return {
1125
+ _id: "MutableRef",
1126
+ current: toJson(this.current)
1127
+ };
1128
+ }
1129
+ };
1130
+ var make8 = (value) => {
1131
+ const ref = Object.create(MutableRefProto);
1132
+ ref.current = value;
1133
+ return ref;
1134
+ };
1135
+ var set = /* @__PURE__ */ dual(2, (self, value) => {
1136
+ self.current = value;
1137
+ return self;
1138
+ });
1139
+
1140
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/MutableList.js
1141
+ var Empty = /* @__PURE__ */ Symbol.for("effect/MutableList/Empty");
1142
+ var make4 = () => ({
1143
+ head: undefined,
1144
+ tail: undefined,
1145
+ length: 0
1146
+ });
1147
+ var compactHead = (self) => {
1148
+ const head = self.head;
1149
+ if (head.offset >= 1024 && head === self.tail && head.mutable && (head.array.length - head.offset) * 8 <= head.offset) {
1150
+ self.head = self.tail = {
1151
+ array: head.array.slice(head.offset),
1152
+ mutable: true,
1153
+ offset: 0,
1154
+ next: undefined
1155
+ };
1156
+ }
1157
+ };
1158
+ var emptyBucket = () => ({
1159
+ array: [],
1160
+ mutable: true,
1161
+ offset: 0,
1162
+ next: undefined
1163
+ });
1164
+ var append = (self, message) => {
1165
+ if (!self.tail) {
1166
+ self.head = self.tail = emptyBucket();
1167
+ } else if (!self.tail.mutable) {
1168
+ self.tail.next = emptyBucket();
1169
+ self.tail = self.tail.next;
1170
+ }
1171
+ self.tail.array.push(message);
1172
+ self.length++;
1173
+ };
1174
+ var prepend = (self, message) => {
1175
+ self.head = {
1176
+ array: [message],
1177
+ mutable: true,
1178
+ offset: 0,
1179
+ next: self.head
1180
+ };
1181
+ if (!self.tail)
1182
+ self.tail = self.head;
1183
+ self.length++;
1184
+ };
1185
+ var appendAll = (self, messages) => appendAllUnsafe(self, Array.from(messages), true);
1186
+ var appendAllUnsafe = (self, messages, mutable = false) => {
1187
+ if (messages.length === 0) {
1188
+ return 0;
1189
+ }
1190
+ const chunk = {
1191
+ array: messages,
1192
+ mutable,
1193
+ offset: 0,
1194
+ next: undefined
1195
+ };
1196
+ if (self.head) {
1197
+ self.tail = self.tail.next = chunk;
1198
+ } else {
1199
+ self.head = self.tail = chunk;
1200
+ }
1201
+ self.length += messages.length;
1202
+ return messages.length;
1203
+ };
1204
+ var clear = (self) => {
1205
+ self.head = self.tail = undefined;
1206
+ self.length = 0;
1207
+ };
1208
+ var takeN = (self, n) => {
1209
+ n = normalize(n);
1210
+ if (n <= 0 || !self.head)
1211
+ return [];
1212
+ n = Math.min(n, self.length);
1213
+ if (n === self.length && self.head?.offset === 0 && !self.head.next) {
1214
+ const array = self.head.array;
1215
+ clear(self);
1216
+ return array;
1217
+ }
1218
+ const array = new Array(n);
1219
+ let index = 0;
1220
+ let chunk = self.head;
1221
+ while (chunk) {
1222
+ while (chunk.offset < chunk.array.length) {
1223
+ array[index++] = chunk.array[chunk.offset];
1224
+ if (chunk.mutable)
1225
+ chunk.array[chunk.offset] = undefined;
1226
+ chunk.offset++;
1227
+ if (index === n) {
1228
+ self.head = chunk.offset === chunk.array.length && chunk.next ? chunk.next : chunk;
1229
+ self.length -= n;
1230
+ if (self.length === 0)
1231
+ clear(self);
1232
+ else
1233
+ compactHead(self);
1234
+ return array;
1235
+ }
1236
+ }
1237
+ chunk = chunk.next;
1238
+ }
1239
+ clear(self);
1240
+ return array;
1241
+ };
1242
+ var takeAll = (self) => takeN(self, self.length);
1243
+ var take2 = (self) => {
1244
+ if (!self.head)
1245
+ return Empty;
1246
+ const message = self.head.array[self.head.offset];
1247
+ if (self.head.mutable)
1248
+ self.head.array[self.head.offset] = undefined;
1249
+ self.head.offset++;
1250
+ self.length--;
1251
+ if (self.head.offset === self.head.array.length) {
1252
+ if (self.head.next) {
1253
+ self.head = self.head.next;
1254
+ } else {
1255
+ clear(self);
1256
+ }
1257
+ } else {
1258
+ compactHead(self);
1259
+ }
1260
+ return message;
1261
+ };
1262
+ var filter2 = (self, f) => {
1263
+ const array = [];
1264
+ let chunk = self.head;
1265
+ let index = 0;
1266
+ while (chunk) {
1267
+ for (let i = chunk.offset;i < chunk.array.length; i++) {
1268
+ if (f(chunk.array[i], index++)) {
1269
+ array.push(chunk.array[i]);
1270
+ }
1271
+ }
1272
+ chunk = chunk.next;
1273
+ }
1274
+ if (array.length === 0) {
1275
+ clear(self);
1276
+ return;
1277
+ }
1278
+ self.head = self.tail = {
1279
+ array,
1280
+ mutable: true,
1281
+ offset: 0,
1282
+ next: undefined
1283
+ };
1284
+ self.length = array.length;
1285
+ };
1286
+ var remove = (self, value) => filter2(self, (v) => v !== value);
1287
+
1288
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/PubSub.js
1289
+ var TypeId3 = "~effect/PubSub";
1290
+ var SubscriptionTypeId = "~effect/PubSub/Subscription";
1291
+ var make5 = (options) => sync2(() => makePubSubUnsafe(options.atomicPubSub(), new Map, makeUnsafe6(), makeUnsafe2(false), make8(false), options.strategy(), make8(none())));
1292
+ var unbounded = (options) => make5({
1293
+ atomicPubSub: () => makeAtomicUnbounded(options),
1294
+ strategy: () => new DroppingStrategy
1295
+ });
1296
+ var makeAtomicUnbounded = (options) => {
1297
+ const replay = options?.replay;
1298
+ return new UnboundedPubSub(replay && replay > 0 ? new ReplayBuffer(Math.ceil(replay)) : undefined);
1299
+ };
1300
+ var publishUnsafe = /* @__PURE__ */ dual(2, (self, value) => {
1301
+ if (self.shutdownFlag.current || isSome(self.ended.current))
1302
+ return false;
1303
+ if (self.pubsub.publish(value)) {
1304
+ self.strategy.completeSubscribersUnsafe(self.pubsub, self.subscribers);
1305
+ return true;
1306
+ }
1307
+ return false;
1308
+ });
1309
+ var subscribe = (self) => uninterruptible(contextWith((services) => {
1310
+ const localScope = get4(services, Scope);
1311
+ const scope = forkUnsafe(self.scope);
1312
+ const subscription = makeSubscriptionUnsafe(self.pubsub, self.subscribers, self.strategy, self.ended);
1313
+ return addFinalizer(scope, unsubscribe(subscription)).pipe(andThen2(addFinalizerExit(localScope, (exit) => close(scope, exit))), as(subscription));
1314
+ }));
1315
+ var unsubscribe = (self) => uninterruptible(withFiber2((state) => {
1316
+ set(self.shutdownFlag, true);
1317
+ return forEach(takeAll(self.pollers), (d) => interruptWith(d, state.id), {
1318
+ discard: true,
1319
+ concurrency: "unbounded"
1320
+ }).pipe(tap2(() => sync2(() => {
1321
+ self.subscribers.delete(self.subscription);
1322
+ self.subscription.unsubscribe();
1323
+ self.replayWindow.close();
1324
+ self.strategy.onPubSubEmptySpaceUnsafe(self.pubsub, self.subscribers);
1325
+ })), when(self.shutdownHook.open), asVoid);
1326
+ }));
1327
+ var takeAll2 = (self) => suspend3(function loop(value) {
1328
+ if (self.shutdownFlag.current) {
1329
+ return interrupt3;
1330
+ }
1331
+ let as = self.pollers.length === 0 ? self.subscription.pollUpTo(Number.POSITIVE_INFINITY) : [];
1332
+ if (value) {
1333
+ as = value.concat(as);
1334
+ }
1335
+ self.strategy.onPubSubEmptySpaceUnsafe(self.pubsub, self.subscribers);
1336
+ if (self.replayWindow.remaining > 0) {
1337
+ return succeed6(self.replayWindow.takeAll().concat(as));
1338
+ } else if (!isArrayNonEmpty(as)) {
1339
+ return flatMap3(pollForItem(self), (item) => loop([item]));
1340
+ }
1341
+ return succeed6(as);
1342
+ });
1343
+ var pollForItem = (self) => callback3((resume) => {
1344
+ if (self.shutdownFlag.current)
1345
+ return resume(interrupt3);
1346
+ if (isSome(self.ended.current)) {
1347
+ const message = self.pollers.length === 0 ? self.subscription.poll() : Empty;
1348
+ if (message !== Empty) {
1349
+ self.strategy.onPubSubEmptySpaceUnsafe(self.pubsub, self.subscribers);
1350
+ return resume(succeed6(message));
1351
+ }
1352
+ return resume(succeed6(self.ended.current.value));
1353
+ }
1354
+ const deferred = makeUnsafe5();
1355
+ let set = self.subscribers.get(self.subscription);
1356
+ if (!set) {
1357
+ set = new Set;
1358
+ self.subscribers.set(self.subscription, set);
1359
+ }
1360
+ set.add(self.pollers);
1361
+ append(self.pollers, deferred);
1362
+ self.strategy.completePollersUnsafe(self.pubsub, self.subscribers, self.subscription, self.pollers);
1363
+ if (deferred.effect)
1364
+ return resume(deferred.effect);
1365
+ deferred.resumes = [resume];
1366
+ return sync2(() => remove(self.pollers, deferred));
1367
+ });
1368
+ var AbsentValue = /* @__PURE__ */ Symbol.for("effect/PubSub/AbsentValue");
1369
+ var addSubscribers = (subscribers, subscription, pollers) => {
1370
+ if (!subscribers.has(subscription)) {
1371
+ subscribers.set(subscription, new Set);
1372
+ }
1373
+ const set = subscribers.get(subscription);
1374
+ set.add(pollers);
1375
+ };
1376
+ var removeSubscribers = (subscribers, subscription, pollers) => {
1377
+ if (!subscribers.has(subscription)) {
1378
+ return;
1379
+ }
1380
+ const set = subscribers.get(subscription);
1381
+ set.delete(pollers);
1382
+ if (set.size === 0) {
1383
+ subscribers.delete(subscription);
1384
+ }
1385
+ };
1386
+ var makeSubscriptionUnsafe = (pubsub, subscribers, strategy, ended) => new SubscriptionImpl(pubsub, subscribers, pubsub.subscribe(), make4(), makeUnsafe2(false), make8(false), strategy, pubsub.replayWindow(), ended);
1387
+ class UnboundedPubSub {
1388
+ publisherHead = {
1389
+ value: AbsentValue,
1390
+ replayIndex: undefined,
1391
+ subscribers: 0,
1392
+ next: null
1393
+ };
1394
+ publisherTail = this.publisherHead;
1395
+ publisherIndex = 0;
1396
+ subscribersIndex = 0;
1397
+ capacity = Number.MAX_SAFE_INTEGER;
1398
+ replayBuffer;
1399
+ constructor(replayBuffer) {
1400
+ this.replayBuffer = replayBuffer;
1401
+ }
1402
+ replayWindow() {
1403
+ return this.replayBuffer ? new ReplayWindowImpl(this.replayBuffer) : emptyReplayWindow;
1404
+ }
1405
+ isEmpty() {
1406
+ return this.publisherHead === this.publisherTail;
1407
+ }
1408
+ isFull() {
1409
+ return false;
1410
+ }
1411
+ size() {
1412
+ return this.publisherIndex - this.subscribersIndex;
1413
+ }
1414
+ publish(value) {
1415
+ const replayIndex = this.replayBuffer?.offer(value);
1416
+ const subscribers = this.publisherTail.subscribers;
1417
+ if (subscribers !== 0) {
1418
+ const node = {
1419
+ value,
1420
+ replayIndex,
1421
+ subscribers,
1422
+ next: null
1423
+ };
1424
+ this.publisherTail.next = node;
1425
+ this.publisherTail = this.publisherTail.next;
1426
+ this.publisherIndex += 1;
1427
+ }
1428
+ return true;
1429
+ }
1430
+ publishAll(elements) {
1431
+ if (this.publisherTail.subscribers !== 0) {
1432
+ for (const a of elements) {
1433
+ this.publish(a);
1434
+ }
1435
+ } else if (this.replayBuffer) {
1436
+ this.replayBuffer.offerAll(elements);
1437
+ }
1438
+ return [];
1439
+ }
1440
+ slide() {
1441
+ if (this.publisherHead !== this.publisherTail) {
1442
+ const node = this.publisherHead.next;
1443
+ const value = node.value;
1444
+ this.publisherHead = this.publisherHead.next;
1445
+ this.publisherHead.value = AbsentValue;
1446
+ this.subscribersIndex += 1;
1447
+ this.replayBuffer?.slide(value, node.replayIndex);
1448
+ }
1449
+ }
1450
+ subscribe() {
1451
+ this.publisherTail.subscribers += 1;
1452
+ return new UnboundedPubSubSubscription(this, this.publisherTail, this.publisherIndex, false);
1453
+ }
1454
+ }
1455
+
1456
+ class UnboundedPubSubSubscription {
1457
+ self;
1458
+ subscriberHead;
1459
+ subscriberIndex;
1460
+ unsubscribed;
1461
+ constructor(self, subscriberHead, subscriberIndex, unsubscribed) {
1462
+ this.self = self;
1463
+ this.subscriberHead = subscriberHead;
1464
+ this.subscriberIndex = subscriberIndex;
1465
+ this.unsubscribed = unsubscribed;
1466
+ }
1467
+ isEmpty() {
1468
+ if (this.unsubscribed) {
1469
+ return true;
1470
+ }
1471
+ let empty = true;
1472
+ let loop = true;
1473
+ while (loop) {
1474
+ if (this.subscriberHead === this.self.publisherTail) {
1475
+ loop = false;
1476
+ } else {
1477
+ if (this.subscriberHead.next.value !== AbsentValue) {
1478
+ empty = false;
1479
+ loop = false;
1480
+ } else {
1481
+ this.subscriberHead = this.subscriberHead.next;
1482
+ this.subscriberIndex += 1;
1483
+ }
1484
+ }
1485
+ }
1486
+ return empty;
1487
+ }
1488
+ size() {
1489
+ if (this.unsubscribed) {
1490
+ return 0;
1491
+ }
1492
+ return this.self.publisherIndex - Math.max(this.subscriberIndex, this.self.subscribersIndex);
1493
+ }
1494
+ poll() {
1495
+ if (this.unsubscribed) {
1496
+ return Empty;
1497
+ }
1498
+ let loop = true;
1499
+ let polled = Empty;
1500
+ while (loop) {
1501
+ if (this.subscriberHead === this.self.publisherTail) {
1502
+ loop = false;
1503
+ } else {
1504
+ const elem = this.subscriberHead.next.value;
1505
+ if (elem !== AbsentValue) {
1506
+ polled = elem;
1507
+ this.subscriberHead.subscribers -= 1;
1508
+ if (this.subscriberHead.subscribers === 0) {
1509
+ this.self.publisherHead = this.self.publisherHead.next;
1510
+ this.self.publisherHead.value = AbsentValue;
1511
+ this.self.subscribersIndex += 1;
1512
+ }
1513
+ loop = false;
1514
+ }
1515
+ this.subscriberHead = this.subscriberHead.next;
1516
+ this.subscriberIndex += 1;
1517
+ }
1518
+ }
1519
+ return polled;
1520
+ }
1521
+ pollUpTo(n) {
1522
+ n = normalize(n);
1523
+ const builder = [];
1524
+ let i = 0;
1525
+ while (i !== n) {
1526
+ const a = this.poll();
1527
+ if (a === Empty) {
1528
+ i = n;
1529
+ } else {
1530
+ builder.push(a);
1531
+ i += 1;
1532
+ }
1533
+ }
1534
+ return builder;
1535
+ }
1536
+ unsubscribe() {
1537
+ if (!this.unsubscribed) {
1538
+ this.unsubscribed = true;
1539
+ this.self.publisherTail.subscribers -= 1;
1540
+ while (this.subscriberHead !== this.self.publisherTail) {
1541
+ if (this.subscriberHead.next.value !== AbsentValue) {
1542
+ this.subscriberHead.subscribers -= 1;
1543
+ if (this.subscriberHead.subscribers === 0) {
1544
+ this.self.publisherHead = this.self.publisherHead.next;
1545
+ this.self.publisherHead.value = AbsentValue;
1546
+ this.self.subscribersIndex += 1;
1547
+ }
1548
+ }
1549
+ this.subscriberHead = this.subscriberHead.next;
1550
+ }
1551
+ }
1552
+ }
1553
+ }
1554
+
1555
+ class SubscriptionImpl {
1556
+ [SubscriptionTypeId] = {
1557
+ _A: identity
1558
+ };
1559
+ pubsub;
1560
+ subscribers;
1561
+ subscription;
1562
+ pollers;
1563
+ shutdownHook;
1564
+ shutdownFlag;
1565
+ strategy;
1566
+ replayWindow;
1567
+ ended;
1568
+ constructor(pubsub, subscribers, subscription, pollers, shutdownHook, shutdownFlag, strategy, replayWindow, ended) {
1569
+ this.pubsub = pubsub;
1570
+ this.subscribers = subscribers;
1571
+ this.subscription = subscription;
1572
+ this.pollers = pollers;
1573
+ this.shutdownHook = shutdownHook;
1574
+ this.shutdownFlag = shutdownFlag;
1575
+ this.strategy = strategy;
1576
+ this.replayWindow = replayWindow;
1577
+ this.ended = ended;
1578
+ }
1579
+ pipe() {
1580
+ return pipeArguments(this, arguments);
1581
+ }
1582
+ }
1583
+
1584
+ class PubSubImpl {
1585
+ [TypeId3] = {
1586
+ _A: identity
1587
+ };
1588
+ pubsub;
1589
+ subscribers;
1590
+ scope;
1591
+ shutdownHook;
1592
+ shutdownFlag;
1593
+ strategy;
1594
+ ended;
1595
+ constructor(pubsub, subscribers, scope, shutdownHook, shutdownFlag, strategy, ended) {
1596
+ this.pubsub = pubsub;
1597
+ this.subscribers = subscribers;
1598
+ this.scope = scope;
1599
+ this.shutdownHook = shutdownHook;
1600
+ this.shutdownFlag = shutdownFlag;
1601
+ this.strategy = strategy;
1602
+ this.ended = ended;
1603
+ }
1604
+ pipe() {
1605
+ return pipeArguments(this, arguments);
1606
+ }
1607
+ }
1608
+ var makePubSubUnsafe = (pubsub, subscribers, scope, shutdownHook, shutdownFlag, strategy, ended) => new PubSubImpl(pubsub, subscribers, scope, shutdownHook, shutdownFlag, strategy, ended);
1609
+ class DroppingStrategy {
1610
+ get shutdown() {
1611
+ return void_3;
1612
+ }
1613
+ handleSurplus(_pubsub, _subscribers, _elements, _isShutdown) {
1614
+ return succeed6(false);
1615
+ }
1616
+ onPubSubEmptySpaceUnsafe(_pubsub, _subscribers) {}
1617
+ completePollersUnsafe(pubsub, subscribers, subscription, pollers) {
1618
+ return strategyCompletePollersUnsafe(this, pubsub, subscribers, subscription, pollers);
1619
+ }
1620
+ completeSubscribersUnsafe(pubsub, subscribers) {
1621
+ return strategyCompleteSubscribersUnsafe(this, pubsub, subscribers);
1622
+ }
1623
+ }
1624
+ var strategyCompletePollersUnsafe = (strategy, pubsub, subscribers, subscription, pollers) => {
1625
+ let keepPolling = true;
1626
+ while (keepPolling && !subscription.isEmpty()) {
1627
+ const poller = take2(pollers);
1628
+ if (poller === Empty) {
1629
+ removeSubscribers(subscribers, subscription, pollers);
1630
+ if (pollers.length === 0) {
1631
+ keepPolling = false;
1632
+ } else {
1633
+ addSubscribers(subscribers, subscription, pollers);
1634
+ }
1635
+ } else {
1636
+ const pollResult = subscription.poll();
1637
+ if (pollResult === Empty) {
1638
+ prepend(pollers, poller);
1639
+ } else {
1640
+ doneUnsafe(poller, succeed3(pollResult));
1641
+ strategy.onPubSubEmptySpaceUnsafe(pubsub, subscribers);
1642
+ }
1643
+ }
1644
+ }
1645
+ };
1646
+ var strategyCompleteSubscribersUnsafe = (strategy, pubsub, subscribers) => {
1647
+ for (const [subscription, pollersSet] of subscribers) {
1648
+ for (const pollers of pollersSet) {
1649
+ strategy.completePollersUnsafe(pubsub, subscribers, subscription, pollers);
1650
+ }
1651
+ }
1652
+ };
1653
+
1654
+ class ReplayBuffer {
1655
+ capacity;
1656
+ head = {
1657
+ value: AbsentValue,
1658
+ index: 0,
1659
+ next: null
1660
+ };
1661
+ tail = this.head;
1662
+ slideValues = [];
1663
+ size = 0;
1664
+ index = 0;
1665
+ publisherIndex = 0;
1666
+ constructor(capacity) {
1667
+ this.capacity = capacity;
1668
+ }
1669
+ slide(value, publisherIndex) {
1670
+ this.slideValues[this.index % this.capacity] = {
1671
+ value,
1672
+ index: publisherIndex
1673
+ };
1674
+ this.index++;
1675
+ }
1676
+ offer(a) {
1677
+ const index = this.publisherIndex++;
1678
+ this.tail.value = a;
1679
+ this.tail.index = index;
1680
+ this.tail.next = {
1681
+ value: AbsentValue,
1682
+ index: 0,
1683
+ next: null
1684
+ };
1685
+ this.tail = this.tail.next;
1686
+ if (this.size === this.capacity) {
1687
+ const dropped = this.head;
1688
+ this.head = dropped.next;
1689
+ dropped.next = null;
1690
+ dropped.value = AbsentValue;
1691
+ } else {
1692
+ this.size += 1;
1693
+ }
1694
+ return index;
1695
+ }
1696
+ offerAll(as) {
1697
+ for (const a of as) {
1698
+ this.offer(a);
1699
+ }
1700
+ }
1701
+ }
1702
+
1703
+ class ReplayWindowImpl {
1704
+ buffer;
1705
+ values;
1706
+ index = 0;
1707
+ remaining;
1708
+ slideIndex;
1709
+ newestIndex = -1;
1710
+ constructor(buffer) {
1711
+ this.buffer = buffer;
1712
+ this.remaining = buffer.size;
1713
+ this.slideIndex = buffer.index;
1714
+ this.values = new Array(this.remaining);
1715
+ let node = buffer.head;
1716
+ for (let i = 0;i < this.remaining; i++) {
1717
+ this.values[i] = node.value;
1718
+ this.newestIndex = node.index;
1719
+ node = node.next;
1720
+ }
1721
+ }
1722
+ close() {
1723
+ this.values.length = 0;
1724
+ this.remaining = 0;
1725
+ }
1726
+ sync() {
1727
+ const slides = this.buffer.index - this.slideIndex;
1728
+ if (slides === 0 || this.remaining === 0) {
1729
+ return;
1730
+ }
1731
+ const count = Math.min(slides, this.buffer.capacity);
1732
+ const start = this.buffer.index - count;
1733
+ for (let i = 0;i < count; i++) {
1734
+ const entry = this.buffer.slideValues[(start + i) % this.buffer.capacity];
1735
+ if (entry.index > this.newestIndex) {
1736
+ this.index = (this.index + 1) % this.values.length;
1737
+ this.values[(this.index + this.remaining - 1) % this.values.length] = entry.value;
1738
+ this.newestIndex = entry.index;
1739
+ }
1740
+ }
1741
+ this.slideIndex = this.buffer.index;
1742
+ }
1743
+ take() {
1744
+ if (this.remaining === 0) {
1745
+ return;
1746
+ }
1747
+ this.sync();
1748
+ const value = this.values[this.index];
1749
+ this.values[this.index] = AbsentValue;
1750
+ this.index = (this.index + 1) % this.values.length;
1751
+ this.remaining--;
1752
+ if (this.remaining === 0) {
1753
+ this.close();
1754
+ }
1755
+ return value;
1756
+ }
1757
+ takeN(n) {
1758
+ n = normalize(n);
1759
+ const len = Math.min(n, this.remaining);
1760
+ const items = new Array(len);
1761
+ for (let i = 0;i < len; i++) {
1762
+ items[i] = this.take();
1763
+ }
1764
+ return items;
1765
+ }
1766
+ takeAll() {
1767
+ return this.takeN(this.remaining);
1768
+ }
1769
+ }
1770
+ var emptyReplayWindow = {
1771
+ remaining: 0,
1772
+ take: () => {
1773
+ return;
1774
+ },
1775
+ takeN: () => [],
1776
+ takeAll: () => [],
1777
+ close: () => {
1778
+ return;
1779
+ }
1780
+ };
1781
+
1782
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/Queue.js
1783
+ var TypeId4 = "~effect/Queue";
1784
+ var EnqueueTypeId = "~effect/Queue/Enqueue";
1785
+ var DequeueTypeId = "~effect/Queue/Dequeue";
1786
+ var variance = {
1787
+ _A: identity,
1788
+ _E: identity
1789
+ };
1790
+ var QueueProto = {
1791
+ [TypeId4]: variance,
1792
+ [EnqueueTypeId]: variance,
1793
+ [DequeueTypeId]: variance,
1794
+ ...PipeInspectableProto,
1795
+ toJSON() {
1796
+ return {
1797
+ _id: "effect/Queue",
1798
+ state: this.state._tag,
1799
+ size: sizeUnsafe(this)
1800
+ };
1801
+ }
1802
+ };
1803
+ var make9 = (options) => withFiber((fiber) => {
1804
+ const self = Object.create(QueueProto);
1805
+ self.dispatcher = fiber.currentDispatcher;
1806
+ self.capacity = options?.capacity ?? Number.POSITIVE_INFINITY;
1807
+ self.strategy = options?.strategy ?? "suspend";
1808
+ self.messages = make4();
1809
+ self.scheduleRunning = false;
1810
+ self.state = {
1811
+ _tag: "Open",
1812
+ takers: new Set,
1813
+ offers: new Set,
1814
+ awaiters: new Set
1815
+ };
1816
+ return succeed2(self);
1817
+ });
1818
+ var bounded = (capacity) => make9({
1819
+ capacity
1820
+ });
1821
+ var sliding = (capacity) => make9({
1822
+ capacity,
1823
+ strategy: "sliding"
1824
+ });
1825
+ var unbounded2 = () => make9();
1826
+ var offer = /* @__PURE__ */ dual(2, (self, message) => suspend2(() => offerUnsafe(self, message) ? exitTrue : self.state._tag === "Open" && self.strategy === "suspend" ? offerOrWait(self, message) : exitFalse));
1827
+ var offerUnsafe = (self, message) => {
1828
+ if (self.state._tag !== "Open") {
1829
+ return false;
1830
+ } else if (self.messages.length >= self.capacity) {
1831
+ if (self.strategy === "sliding") {
1832
+ take2(self.messages);
1833
+ append(self.messages, message);
1834
+ return true;
1835
+ } else if (self.capacity <= 0 && self.state.takers.size > 0) {
1836
+ append(self.messages, message);
1837
+ releaseTakers(self);
1838
+ return true;
1839
+ }
1840
+ return false;
1841
+ }
1842
+ append(self.messages, message);
1843
+ scheduleReleaseTaker(self);
1844
+ return true;
1845
+ };
1846
+ var offerAll = /* @__PURE__ */ dual(2, (self, messages) => callback2((resume) => {
1847
+ const remaining = offerAllUnsafe(self, messages);
1848
+ if (remaining.length === 0 || self.strategy === "dropping") {
1849
+ return resume(exitSucceed(remaining));
1850
+ }
1851
+ return waitToOffer(self, {
1852
+ _tag: "Array",
1853
+ remaining,
1854
+ offset: 0,
1855
+ resume
1856
+ });
1857
+ }));
1858
+ var offerAllUnsafe = (self, messages) => {
1859
+ if (self.state._tag !== "Open") {
1860
+ return fromIterable(messages);
1861
+ } else if (self.capacity === Number.POSITIVE_INFINITY || self.strategy === "sliding") {
1862
+ appendAll(self.messages, messages);
1863
+ if (self.strategy === "sliding") {
1864
+ takeN(self.messages, self.messages.length - self.capacity);
1865
+ }
1866
+ scheduleReleaseTaker(self);
1867
+ return [];
1868
+ }
1869
+ const free = self.capacity <= 0 ? self.state.takers.size : self.capacity - self.messages.length;
1870
+ if (free === 0) {
1871
+ return fromIterable(messages);
1872
+ }
1873
+ const remaining = [];
1874
+ let i = 0;
1875
+ for (const message of messages) {
1876
+ if (i < free) {
1877
+ append(self.messages, message);
1878
+ } else {
1879
+ remaining.push(message);
1880
+ }
1881
+ i++;
1882
+ }
1883
+ scheduleReleaseTaker(self);
1884
+ return remaining;
1885
+ };
1886
+ var fail = /* @__PURE__ */ dual(2, (self, error) => failCause(self, causeFail(error)));
1887
+ var failCause = /* @__PURE__ */ dual(2, (self, cause) => sync(() => failCauseUnsafe(self, cause)));
1888
+ var failCauseUnsafe = (self, cause) => {
1889
+ if (self.state._tag !== "Open") {
1890
+ return false;
1891
+ }
1892
+ const exit = exitFailCause(cause);
1893
+ const fail = exitZipRight(exit, exitFailDone);
1894
+ if (self.state.offers.size === 0 && self.messages.length === 0) {
1895
+ finalize(self, fail);
1896
+ return true;
1897
+ }
1898
+ self.state = {
1899
+ ...self.state,
1900
+ _tag: "Closing",
1901
+ exit: fail
1902
+ };
1903
+ scheduleReleaseTaker(self);
1904
+ return true;
1905
+ };
1906
+ var end = (self) => failCause(self, causeFail(Done()));
1907
+ var endUnsafe = (self) => failCauseUnsafe(self, causeFail(Done()));
1908
+ var shutdown = (self) => sync(() => shutdownUnsafe(self));
1909
+ var shutdownUnsafe = (self) => {
1910
+ if (self.state._tag === "Done") {
1911
+ return false;
1912
+ }
1913
+ clear(self.messages);
1914
+ const offers = self.state.offers;
1915
+ finalize(self, self.state._tag === "Open" ? exitInterrupt2 : self.state.exit);
1916
+ for (const entry of offers) {
1917
+ resumeUnoffered(entry);
1918
+ }
1919
+ return true;
1920
+ };
1921
+ var takeAll3 = (self) => takeBetween(self, 1, Number.POSITIVE_INFINITY);
1922
+ var takeBetween = /* @__PURE__ */ dual(3, (self, min, max) => {
1923
+ min = normalize(min);
1924
+ max = normalize(max);
1925
+ return suspendTake(() => takeBetweenUnsafe(self, min, max) ?? andThen(awaitTake(self, () => canTake(self, min)), takeBetween(self, min, max)));
1926
+ });
1927
+ var take = (self) => suspendTake(() => takeUnsafe(self) ?? andThen(awaitTake(self, () => canTake(self, 1)), take(self)));
1928
+ var poll = (self) => suspendTake(() => {
1929
+ const result = takeUnsafe(self);
1930
+ if (result === undefined) {
1931
+ return succeed2(none());
1932
+ }
1933
+ if (result._tag === "Success") {
1934
+ return succeed2(some(result.value));
1935
+ }
1936
+ return succeed2(none());
1937
+ });
1938
+ var takeUnsafe = (self) => {
1939
+ if (self.state._tag === "Done") {
1940
+ return self.state.exit;
1941
+ }
1942
+ if (self.messages.length > 0) {
1943
+ const message = take2(self.messages);
1944
+ releaseCapacity(self);
1945
+ return exitSucceed(message);
1946
+ } else if (self.capacity <= 0 && self.state.offers.size > 0) {
1947
+ const message = takeOfferUnsafe(self.state.offers);
1948
+ releaseCapacity(self);
1949
+ return exitSucceed(message);
1950
+ }
1951
+ return;
1952
+ };
1953
+ var sizeUnsafe = (self) => self.state._tag === "Done" ? 0 : self.messages.length;
1954
+ var exitFalse = /* @__PURE__ */ exitSucceed(false);
1955
+ var exitTrue = /* @__PURE__ */ exitSucceed(true);
1956
+ var exitFailDone = /* @__PURE__ */ exitFail(/* @__PURE__ */ Done());
1957
+ var exitInterrupt2 = /* @__PURE__ */ exitInterrupt();
1958
+ var releaseTakers = (self) => {
1959
+ if (self.state._tag === "Done" || self.state.takers.size === 0) {
1960
+ return;
1961
+ }
1962
+ for (const taker of self.state.takers) {
1963
+ if (!taker.ready())
1964
+ continue;
1965
+ self.state.takers.delete(taker);
1966
+ taker.resume(exitVoid);
1967
+ if (self.messages.length === 0) {
1968
+ break;
1969
+ }
1970
+ }
1971
+ };
1972
+ var scheduleReleaseTaker = (self) => {
1973
+ if (self.scheduleRunning || self.state._tag === "Done" || self.state.takers.size === 0) {
1974
+ return;
1975
+ }
1976
+ self.scheduleRunning = true;
1977
+ self.dispatcher.scheduleTask(() => {
1978
+ self.scheduleRunning = false;
1979
+ releaseTakers(self);
1980
+ }, 0);
1981
+ };
1982
+ var takeBetweenUnsafe = (self, min, max) => {
1983
+ if (self.state._tag === "Done") {
1984
+ return self.state.exit;
1985
+ } else if (max <= 0 || min <= 0) {
1986
+ return exitSucceed([]);
1987
+ } else if (!canTake(self, min)) {
1988
+ return;
1989
+ }
1990
+ const messages = self.messages.length > 0 ? takeN(self.messages, max) : [takeOfferUnsafe(self.state.offers)];
1991
+ releaseCapacity(self);
1992
+ return exitSucceed(messages);
1993
+ };
1994
+ var suspendTake = /* @__PURE__ */ makePrimitive({
1995
+ op: "QueueTake",
1996
+ [evaluate](fiber) {
1997
+ const effect = this[args]();
1998
+ return isExit(effect) ? effect[evaluate](fiber) : effect;
1999
+ }
2000
+ });
2001
+ var canTake = (self, min) => self.messages.length >= (self.state._tag === "Closing" ? 1 : Math.min(min, self.capacity || 1)) || self.capacity <= 0 && self.state._tag !== "Done" && self.state.offers.size > 0;
2002
+ var awaitTake = (self, ready) => callback2((resume) => {
2003
+ if (self.state._tag === "Done")
2004
+ return resume(self.state.exit);
2005
+ if (ready())
2006
+ return resume(exitVoid);
2007
+ const taker = {
2008
+ ready,
2009
+ resume
2010
+ };
2011
+ self.state.takers.add(taker);
2012
+ return sync(() => {
2013
+ if (self.state._tag !== "Done")
2014
+ self.state.takers.delete(taker);
2015
+ });
2016
+ });
2017
+ var offerOrWait = (self, message) => callback2((resume) => offerUnsafe(self, message) ? resume(exitTrue) : waitToOffer(self, {
2018
+ _tag: "Single",
2019
+ message,
2020
+ resume
2021
+ }));
2022
+ var waitToOffer = (self, entry) => {
2023
+ if (self.state._tag !== "Open")
2024
+ return resumeUnoffered(entry);
2025
+ const offers = self.state.offers;
2026
+ offers.add(entry);
2027
+ return sync(() => {
2028
+ if (self.state._tag === "Done")
2029
+ return;
2030
+ offers.delete(entry);
2031
+ if (self.state._tag === "Closing" && offers.size === 0 && self.messages.length === 0) {
2032
+ finalize(self, self.state.exit);
2033
+ }
2034
+ });
2035
+ };
2036
+ var resumeUnoffered = (entry) => entry._tag === "Single" ? entry.resume(exitFalse) : entry.resume(exitSucceed(entry.remaining.slice(entry.offset)));
2037
+ var takeOfferUnsafe = (offers) => {
2038
+ const entry = offers.values().next().value;
2039
+ if (entry._tag === "Single") {
2040
+ offers.delete(entry);
2041
+ entry.resume(exitTrue);
2042
+ return entry.message;
2043
+ }
2044
+ const message = entry.remaining[entry.offset++];
2045
+ if (entry.offset === entry.remaining.length) {
2046
+ offers.delete(entry);
2047
+ entry.resume(exitSucceed([]));
2048
+ }
2049
+ return message;
2050
+ };
2051
+ var releaseCapacity = (self) => {
2052
+ if (self.state._tag === "Done") {
2053
+ return isDoneCause(self.state.exit.cause);
2054
+ } else if (self.state.offers.size === 0) {
2055
+ if (self.state._tag === "Closing" && self.messages.length === 0) {
2056
+ finalize(self, self.state.exit);
2057
+ return isDoneCause(self.state.exit.cause);
2058
+ }
2059
+ return false;
2060
+ }
2061
+ for (const entry of self.state.offers) {
2062
+ let n = self.capacity - self.messages.length;
2063
+ if (n <= 0)
2064
+ break;
2065
+ else if (entry._tag === "Single") {
2066
+ append(self.messages, entry.message);
2067
+ self.state.offers.delete(entry);
2068
+ entry.resume(exitTrue);
2069
+ } else {
2070
+ for (;entry.offset < entry.remaining.length; entry.offset++) {
2071
+ if (n === 0)
2072
+ return false;
2073
+ append(self.messages, entry.remaining[entry.offset]);
2074
+ n--;
2075
+ }
2076
+ self.state.offers.delete(entry);
2077
+ entry.resume(exitSucceed([]));
2078
+ }
2079
+ const state = self.state;
2080
+ if (state._tag === "Done") {
2081
+ return isDoneCause(state.exit.cause);
2082
+ }
2083
+ }
2084
+ return false;
2085
+ };
2086
+ var finalize = (self, exit) => {
2087
+ if (self.state._tag === "Done") {
2088
+ return;
2089
+ }
2090
+ const openState = self.state;
2091
+ self.state = {
2092
+ _tag: "Done",
2093
+ exit
2094
+ };
2095
+ for (const taker of openState.takers) {
2096
+ taker.resume(exit);
2097
+ }
2098
+ openState.takers.clear();
2099
+ for (const awaiter of openState.awaiters) {
2100
+ awaiter(exit);
2101
+ }
2102
+ openState.awaiters.clear();
2103
+ };
2104
+
2105
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/Semaphore.js
2106
+ var makeUnsafe3 = (permits) => new SemaphoreImpl(permits);
2107
+ var firstAvailableWaiter = (self) => {
2108
+ for (const waiter of self.waiters) {
2109
+ if (waiter.permits <= self.free)
2110
+ return waiter;
2111
+ }
2112
+ };
2113
+ var takePermits = (self, n, onAcquire, restore = identity) => withFiber((fiber) => {
2114
+ if (self.free >= n && firstAvailableWaiter(self) === undefined) {
2115
+ self.taken += n;
2116
+ return onAcquire();
2117
+ }
2118
+ const waiter = {
2119
+ permits: n,
2120
+ resume: undefined
2121
+ };
2122
+ const remove = () => {
2123
+ if (self.waiters.delete(waiter))
2124
+ self.releaseUnsafe(fiber, 0);
2125
+ return;
2126
+ };
2127
+ self.waiters.add(waiter);
2128
+ onExitUnsafe(fiber, remove);
2129
+ const wait = restore(callback2((resume) => {
2130
+ if (firstAvailableWaiter(self) === waiter) {
2131
+ resume(void_);
2132
+ } else {
2133
+ waiter.resume = resume;
2134
+ }
2135
+ }));
2136
+ const loop = flatMap2(wait, () => {
2137
+ if (firstAvailableWaiter(self) !== waiter)
2138
+ return loop;
2139
+ self.taken += n;
2140
+ remove();
2141
+ return onAcquire();
2142
+ });
2143
+ return loop;
2144
+ });
2145
+
2146
+ class SemaphoreImpl {
2147
+ waiters = /* @__PURE__ */ new Set;
2148
+ taken = 0;
2149
+ permits;
2150
+ constructor(permits) {
2151
+ this.permits = permits;
2152
+ }
2153
+ get free() {
2154
+ return this.permits - this.taken;
2155
+ }
2156
+ take(n) {
2157
+ return takePermits(this, n, () => succeed2(n));
2158
+ }
2159
+ takeScoped(n) {
2160
+ return uninterruptibleMask((restore) => flatMap2(scope, (scope) => takePermits(this, n, () => scopeAddFinalizer(scope, this.release(n)), restore)));
2161
+ }
2162
+ takeIfAvailable(n) {
2163
+ return suspend2(() => {
2164
+ if (this.free < n)
2165
+ return succeed2(false);
2166
+ this.taken += n;
2167
+ return succeed2(true);
2168
+ });
2169
+ }
2170
+ releaseUnsafe(fiber, n) {
2171
+ this.taken -= n;
2172
+ if (this.waiters.size > 0) {
2173
+ fiber.currentDispatcher.scheduleTask(() => {
2174
+ let remaining = this.free;
2175
+ for (const waiter of Array.from(this.waiters)) {
2176
+ if (!this.waiters.has(waiter) || waiter.permits > remaining)
2177
+ continue;
2178
+ remaining -= waiter.permits;
2179
+ const resume = waiter.resume;
2180
+ waiter.resume = undefined;
2181
+ resume?.(void_);
2182
+ }
2183
+ }, 0);
2184
+ }
2185
+ return this.free;
2186
+ }
2187
+ resize(permits) {
2188
+ return withFiber((fiber) => {
2189
+ this.permits = permits;
2190
+ if (this.free < 0)
2191
+ return void_;
2192
+ this.releaseUnsafe(fiber, 0);
2193
+ return void_;
2194
+ });
2195
+ }
2196
+ release(n) {
2197
+ return withFiber((fiber) => succeed2(this.releaseUnsafe(fiber, n)));
2198
+ }
2199
+ get releaseAll() {
2200
+ return withFiber((fiber) => succeed2(this.releaseUnsafe(fiber, this.taken)));
2201
+ }
2202
+ withPermits(n) {
2203
+ return (self) => uninterruptibleMask((restore) => takePermits(this, n, () => onExitPrimitive(restore(self), () => {
2204
+ this.releaseUnsafe(getCurrentFiber(), n);
2205
+ return;
2206
+ }, true), restore));
2207
+ }
2208
+ withPermit = /* @__PURE__ */ this.withPermits(1);
2209
+ withPermitsIfAvailable(n) {
2210
+ return (self) => uninterruptibleMask((restore) => {
2211
+ if (this.free < n)
2212
+ return succeedNone;
2213
+ this.taken += n;
2214
+ return onExitPrimitive(restore(asSome(self)), () => {
2215
+ this.releaseUnsafe(getCurrentFiber(), n);
2216
+ return;
2217
+ }, true);
2218
+ });
2219
+ }
2220
+ }
2221
+
2222
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/Channel.js
2223
+ var TypeId5 = "~effect/Channel";
2224
+ var isChannel = (u) => hasProperty(u, TypeId5);
2225
+ var ChannelProto = {
2226
+ [TypeId5]: {
2227
+ _Env: identity,
2228
+ _InErr: identity,
2229
+ _InElem: identity,
2230
+ _OutErr: identity,
2231
+ _OutElem: identity
2232
+ },
2233
+ pipe() {
2234
+ return pipeArguments(this, arguments);
2235
+ }
2236
+ };
2237
+ var fromTransform = (transform) => {
2238
+ const self = Object.create(ChannelProto);
2239
+ self.transform = (upstream, scope) => catchCause2(transform(upstream, scope), (cause) => succeed6(failCause3(cause)));
2240
+ return self;
2241
+ };
2242
+ var transformPull = (self, f) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (pull) => f(pull, scope)));
2243
+ var fromPull = (effect) => fromTransform((_, __) => effect);
2244
+ var fromTransformBracket = (f) => fromTransform(fnUntraced(function* (upstream, scope) {
2245
+ const closableScope = forkUnsafe(scope);
2246
+ const onCause = (cause) => close(closableScope, doneExitFromCause(cause));
2247
+ const pull = yield* onError(f(upstream, scope, closableScope), onCause);
2248
+ return onError(pull, onCause);
2249
+ }));
2250
+ var toTransform = (channel) => channel.transform;
2251
+ var asyncQueue = (scope, f, options) => make9({
2252
+ capacity: options?.bufferSize,
2253
+ strategy: options?.strategy
2254
+ }).pipe(tap2((queue) => addFinalizer(scope, shutdown(queue))), tap2((queue) => provide(f(queue), scope).pipe(catchCause2((cause) => failCause(queue, cause)), forkIn(scope, {
2255
+ startImmediately: true
2256
+ }))));
2257
+ var callbackArray = (f, options) => fromTransform((_, scope) => map8(asyncQueue(scope, f, options), takeAll3));
2258
+ var suspend4 = (evaluate) => fromTransform((upstream, scope) => suspend3(() => toTransform(evaluate())(upstream, scope)));
2259
+ var fromIterator = (iterator) => fromPull(sync2(() => {
2260
+ const iter = iterator();
2261
+ return suspend3(() => {
2262
+ const state = iter.next();
2263
+ return state.done ? done(state.value) : succeed6(state.value);
2264
+ });
2265
+ }));
2266
+ var succeed4 = (value) => fromEffect(succeed6(value));
2267
+ var empty = /* @__PURE__ */ fromPull(/* @__PURE__ */ succeed6(/* @__PURE__ */ done()));
2268
+ var fail5 = (error) => fromPull(succeed6(fail7(error)));
2269
+ var failCause4 = (cause) => fromPull(failCause3(cause));
2270
+ var die = (defect) => failCause4(die2(defect));
2271
+ var fromEffect = (effect) => fromPull(sync2(() => {
2272
+ let done2 = false;
2273
+ return suspend3(() => {
2274
+ if (done2)
2275
+ return done();
2276
+ done2 = true;
2277
+ return effect;
2278
+ });
2279
+ }));
2280
+ var fromEffectDrain = (effect) => fromPull(flatMap3(effect, () => done()));
2281
+ var fromQueueArray = (queue) => fromPull(succeed6(takeAll3(queue)));
2282
+ var fromSubscriptionArray = (subscription) => fromPull(succeed6(onInterrupt(takeAll2(subscription), () => done())));
2283
+ var fromPubSubArray = (pubsub) => unwrap2(map8(subscribe(pubsub), fromSubscriptionArray));
2284
+ var fromReadableStream2 = (options) => fromTransform((_, scope) => readableStreamToPullUnsafe({
2285
+ scope,
2286
+ readable: options.evaluate(),
2287
+ onError: options.onError,
2288
+ releaseLockOnEnd: options.releaseLockOnEnd
2289
+ }));
2290
+ var readableStreamToPullUnsafe = (options) => {
2291
+ const reader = options.readable.getReader();
2292
+ const exit = options.exit ?? make8(undefined);
2293
+ const pull = suspend3(() => {
2294
+ if (exit.current)
2295
+ return exit.current;
2296
+ return matchCauseEffect(tryPromise({
2297
+ try: () => reader.read(),
2298
+ catch: options.onError
2299
+ }), {
2300
+ onFailure: (cause) => exit.current ?? failCause3(cause),
2301
+ onSuccess: ({
2302
+ done: done2,
2303
+ value
2304
+ }) => {
2305
+ if (exit.current)
2306
+ return exit.current;
2307
+ return done2 ? done() : succeed6(of(value));
2308
+ }
2309
+ });
2310
+ });
2311
+ return as(addFinalizer(options.scope, options.releaseLockOnEnd ? sync2(() => reader.releaseLock()) : promise(() => reader.cancel().catch((error) => reader.closed.then(() => Promise.reject(error), constVoid))).pipe(ensuring2(sync2(() => reader.releaseLock())))), pull);
2312
+ };
2313
+ var map7 = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => sync2(() => {
2314
+ let i = 0;
2315
+ return map8(pull, (o) => f(o, i++));
2316
+ })));
2317
+ var mapDone = /* @__PURE__ */ dual(2, (self, f) => mapDoneEffect(self, (o) => succeed6(f(o))));
2318
+ var mapDoneEffect = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => succeed6(catchDone(pull, (done2) => flatMap3(f(done2), done)))));
2319
+ var concurrencyIsSequential = (concurrency) => concurrency === undefined || concurrency !== "unbounded" && concurrency <= 1;
2320
+ var mapEffect = /* @__PURE__ */ dual((args) => isChannel(args[0]), (self, f, options) => concurrencyIsSequential(options?.concurrency) ? mapEffectSequential(self, f) : mapEffectConcurrent(self, f, options));
2321
+ var mapEffectSequential = (self, f) => fromTransform((upstream, scope) => {
2322
+ let i = 0;
2323
+ return map8(toTransform(self)(upstream, scope), flatMap3((o) => f(o, i++)));
2324
+ });
2325
+ var mapEffectConcurrent = (self, f, options) => fromTransformBracket(fnUntraced(function* (upstream, scope, forkedScope) {
2326
+ let i = 0;
2327
+ const pull = yield* toTransform(self)(upstream, scope);
2328
+ const concurrencyN = options.concurrency === "unbounded" ? Number.MAX_SAFE_INTEGER : Math.min(options.concurrency, Number.MAX_SAFE_INTEGER);
2329
+ const queue = yield* bounded(0);
2330
+ yield* addFinalizer(forkedScope, shutdown(queue));
2331
+ const runFork = runForkWith(yield* context());
2332
+ const trackFiber = runIn(forkedScope);
2333
+ if (options.unordered) {
2334
+ const semaphore = makeUnsafe3(concurrencyN);
2335
+ const release = constant(semaphore.release(1));
2336
+ const handle = matchCauseEffect({
2337
+ onFailure: (cause) => flatMap3(failCause(queue, cause), release),
2338
+ onSuccess: (value) => flatMap3(offer(queue, value), release)
2339
+ });
2340
+ yield* semaphore.take(1).pipe(flatMap3(() => pull), flatMap3((value) => {
2341
+ const index = i++;
2342
+ trackFiber(runFork(handle(suspend3(() => f(value, index)))));
2343
+ return void_3;
2344
+ }), forever({
2345
+ disableYield: true
2346
+ }), catchCause2((cause) => semaphore.withPermits(concurrencyN - 1)(failCause(queue, cause))), forkIn(forkedScope));
2347
+ } else {
2348
+ const effects = yield* bounded(concurrencyN - 2);
2349
+ yield* addFinalizer(forkedScope, shutdown(effects));
2350
+ yield* take(effects).pipe(flatten, flatMap3((value) => offer(queue, value)), forever({
2351
+ disableYield: true
2352
+ }), catchCause2((cause) => failCause(queue, cause)), forkIn(forkedScope));
2353
+ let errorCause;
2354
+ const onExit = (exit) => {
2355
+ if (exit._tag === "Success")
2356
+ return;
2357
+ errorCause = exit.cause;
2358
+ failCauseUnsafe(queue, exit.cause);
2359
+ };
2360
+ yield* pull.pipe(flatMap3((value) => {
2361
+ if (errorCause)
2362
+ return failCause3(errorCause);
2363
+ const index = i++;
2364
+ const fiber = runFork(suspend3(() => f(value, index)));
2365
+ trackFiber(fiber);
2366
+ fiber.addObserver(onExit);
2367
+ return offer(effects, join(fiber));
2368
+ }), forever({
2369
+ disableYield: true
2370
+ }), catchCause2((cause) => offer(effects, failCause2(cause)).pipe(andThen2(failCause(effects, cause)))), forkIn(forkedScope));
2371
+ }
2372
+ return take(queue);
2373
+ }));
2374
+ var flatMap = /* @__PURE__ */ dual((args) => isChannel(args[0]), (self, f, options) => concurrencyIsSequential(options?.concurrency) ? flatMapSequential(self, f) : flatMapConcurrent(self, f, options));
2375
+ var flatMapSequential = (self, f) => fromTransform((upstream, scope) => map8(toTransform(self)(upstream, scope), (pull) => {
2376
+ let childPull;
2377
+ let childScope;
2378
+ const makePull = flatMap3(pull, (value) => {
2379
+ childScope ??= forkUnsafe(scope);
2380
+ return flatMapEager(toTransform(f(value))(upstream, childScope), (pull) => {
2381
+ childPull = catchHalt(pull);
2382
+ return childPull;
2383
+ });
2384
+ });
2385
+ const catchHalt = catchDone((_) => {
2386
+ childPull = undefined;
2387
+ if (childScope.state._tag === "Empty") {
2388
+ return makePull;
2389
+ }
2390
+ const close2 = close(childScope, void_2);
2391
+ childScope = undefined;
2392
+ return flatMap3(close2, () => makePull);
2393
+ });
2394
+ return suspend3(() => childPull ?? makePull);
2395
+ }));
2396
+ var flatMapConcurrent = (self, f, options) => self.pipe(map7(f), mergeAll(options));
2397
+ var flatten2 = (channels) => flatMap(channels, identity);
2398
+ var flattenArray = (self) => transformPull(self, (pull) => {
2399
+ let array;
2400
+ let index = 0;
2401
+ const pump = suspend3(function loop() {
2402
+ if (array === undefined) {
2403
+ return flatMap3(pull, (array_) => {
2404
+ switch (array_.length) {
2405
+ case 0:
2406
+ return loop();
2407
+ case 1:
2408
+ return succeed6(array_[0]);
2409
+ default: {
2410
+ array = array_;
2411
+ return succeed6(array_[index++]);
2412
+ }
2413
+ }
2414
+ });
2415
+ }
2416
+ const next = array[index++];
2417
+ if (index >= array.length) {
2418
+ array = undefined;
2419
+ index = 0;
2420
+ }
2421
+ return succeed6(next);
2422
+ });
2423
+ return succeed6(pump);
2424
+ });
2425
+ var filterArray = /* @__PURE__ */ dual(2, (self, predicate) => transformPull(self, (pull) => succeed6(flatMap3(pull, function loop(arr) {
2426
+ const passes = [];
2427
+ for (let i = 0;i < arr.length; i++) {
2428
+ if (predicate(arr[i])) {
2429
+ passes.push(arr[i]);
2430
+ }
2431
+ }
2432
+ return isReadonlyArrayNonEmpty(passes) ? succeed6(passes) : flatMap3(pull, loop);
2433
+ }))));
2434
+ var catchCause3 = /* @__PURE__ */ dual(2, (self, f) => fromTransform((upstream, scope) => {
2435
+ let forkedScope = forkUnsafe(scope);
2436
+ return map8(toTransform(self)(upstream, forkedScope), (pull) => {
2437
+ let currentPull = pull.pipe(catchCause2((cause) => {
2438
+ if (isDoneCause(cause)) {
2439
+ return failCause3(cause);
2440
+ }
2441
+ const toClose = forkedScope;
2442
+ forkedScope = forkUnsafe(scope);
2443
+ return close(toClose, failCause2(cause)).pipe(andThen2(toTransform(f(cause))(upstream, forkedScope)), flatMap3((childPull) => {
2444
+ currentPull = childPull;
2445
+ return childPull;
2446
+ }));
2447
+ }));
2448
+ return suspend3(() => currentPull);
2449
+ });
2450
+ }));
2451
+ var tapError3 = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => succeed6(tapError2(pull, (err) => isDone2(err) ? void_3 : asVoid(f(err))))));
2452
+ var mapError3 = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => succeed6(mapError2(pull, (err) => isDone2(err) ? err : f(err)))));
2453
+ var mergeAll = /* @__PURE__ */ dual(2, (channels, {
2454
+ bufferSize = 16,
2455
+ concurrency,
2456
+ switch: switch_ = false
2457
+ }) => fromTransformBracket(fnUntraced(function* (upstream, scope, forkedScope) {
2458
+ const concurrencyN = concurrency === "unbounded" ? Number.MAX_SAFE_INTEGER : Math.max(1, concurrency);
2459
+ const semaphore = switch_ ? undefined : makeUnsafe3(concurrencyN);
2460
+ const doneLatch = yield* make3(true);
2461
+ const fibers = new Map;
2462
+ const queue = yield* bounded(bufferSize);
2463
+ yield* addFinalizer(forkedScope, shutdown(queue));
2464
+ const pull = yield* toTransform(channels)(upstream, scope);
2465
+ yield* gen(function* () {
2466
+ while (true) {
2467
+ let pullFiber;
2468
+ if (semaphore) {
2469
+ if (fibers.size < concurrencyN) {
2470
+ yield* semaphore.take(1);
2471
+ } else {
2472
+ pullFiber = yield* forkChild(pull);
2473
+ yield* raceFirst(semaphore.take(1), andThen2(join(pullFiber), never));
2474
+ }
2475
+ }
2476
+ const channel = pullFiber === undefined ? yield* pull : yield* join(pullFiber);
2477
+ const childScope = forkUnsafe(forkedScope);
2478
+ const childPull = yield* toTransform(channel)(upstream, childScope);
2479
+ while (fibers.size >= concurrencyN) {
2480
+ const [fiber, fiberScope] = headUnsafe(fibers);
2481
+ fibers.delete(fiber);
2482
+ if (fibers.size === 0)
2483
+ yield* doneLatch.open;
2484
+ yield* interrupt(fiber);
2485
+ yield* ignoreCause(close(fiberScope, interrupt2()));
2486
+ }
2487
+ const fiber = yield* childPull.pipe(tap2(() => yieldNow), flatMap3((value) => offer(queue, value)), forever({
2488
+ disableYield: true
2489
+ }), onError(fnUntraced(function* (cause) {
2490
+ const exit2 = doneExitFromCause(cause);
2491
+ const closeExit = yield* exit(close(childScope, exit2));
2492
+ if (!fibers.has(fiber))
2493
+ return;
2494
+ const failure = asVoidAll([exit2, closeExit]);
2495
+ if (isFailure2(failure))
2496
+ yield* failCause(queue, failure.cause);
2497
+ fibers.delete(fiber);
2498
+ if (semaphore)
2499
+ yield* semaphore.release(1);
2500
+ if (fibers.size === 0)
2501
+ yield* doneLatch.open;
2502
+ })), forkChild);
2503
+ doneLatch.closeUnsafe();
2504
+ fibers.set(fiber, childScope);
2505
+ }
2506
+ }).pipe(catchCause2((cause) => {
2507
+ const halt = filterDone(cause);
2508
+ if (isSuccess(halt)) {
2509
+ return doneLatch.whenOpen(failCause(queue, cause));
2510
+ }
2511
+ return failCause(queue, cause);
2512
+ }), forkIn(forkedScope));
2513
+ return take(queue);
2514
+ })));
2515
+ var merge = /* @__PURE__ */ dual((args) => isChannel(args[0]) && isChannel(args[1]), (left, right, options) => fromTransformBracket(fnUntraced(function* (upstream, _scope, forkedScope) {
2516
+ const strategy = options?.haltStrategy ?? "both";
2517
+ const queue = yield* bounded(0);
2518
+ yield* addFinalizer(forkedScope, shutdown(queue));
2519
+ let done = 0;
2520
+ function onExit(side, cause) {
2521
+ done++;
2522
+ if (!isDoneCause(cause)) {
2523
+ return failCause(queue, cause);
2524
+ }
2525
+ switch (strategy) {
2526
+ case "both": {
2527
+ return done === 2 ? failCause(queue, cause) : void_3;
2528
+ }
2529
+ case "left":
2530
+ case "right": {
2531
+ return side === strategy ? failCause(queue, cause) : void_3;
2532
+ }
2533
+ case "either": {
2534
+ return failCause(queue, cause);
2535
+ }
2536
+ }
2537
+ }
2538
+ const runSide = (side, channel, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3((pull) => pull.pipe(flatMap3((value) => offer(queue, value)), forever)), onError((cause) => onExitPrimitive2(doneExitFromCause(cause), (exit) => close(scope, exit)).pipe(matchCauseEffect({
2539
+ onFailure: (cause) => onExit(side, cause),
2540
+ onSuccess: () => onExit(side, cause)
2541
+ }))), forkIn(forkedScope));
2542
+ yield* runSide("left", left, forkUnsafe(forkedScope));
2543
+ yield* runSide("right", right, forkUnsafe(forkedScope));
2544
+ return take(queue);
2545
+ })));
2546
+ var mergeEffect = /* @__PURE__ */ dual(2, (self, effect) => merge(self, fromEffectDrain(effect), {
2547
+ haltStrategy: "left"
2548
+ }));
2549
+ var splitLines2 = () => fromTransform((upstream, _scope) => sync2(() => {
2550
+ let stringBuilder = "";
2551
+ let midCRLF = false;
2552
+ let done2 = none();
2553
+ function splitLinesArray(chunk) {
2554
+ const chunkBuilder = [];
2555
+ function pushLine(segment) {
2556
+ if (stringBuilder.length === 0) {
2557
+ chunkBuilder.push(segment);
2558
+ } else {
2559
+ chunkBuilder.push(stringBuilder + segment);
2560
+ stringBuilder = "";
2561
+ }
2562
+ }
2563
+ for (let i = 0;i < chunk.length; i++) {
2564
+ const str = chunk[i];
2565
+ if (str.length !== 0) {
2566
+ let from = 0;
2567
+ let indexOfCR = str.indexOf("\r");
2568
+ let indexOfLF = str.indexOf(`
2569
+ `);
2570
+ if (midCRLF) {
2571
+ if (indexOfLF === 0) {
2572
+ from = 1;
2573
+ indexOfLF = str.indexOf(`
2574
+ `, from);
2575
+ }
2576
+ midCRLF = false;
2577
+ }
2578
+ while (indexOfCR !== -1 || indexOfLF !== -1) {
2579
+ if (indexOfCR === -1 || indexOfLF !== -1 && indexOfLF < indexOfCR) {
2580
+ pushLine(str.substring(from, indexOfLF));
2581
+ from = indexOfLF + 1;
2582
+ indexOfLF = str.indexOf(`
2583
+ `, from);
2584
+ } else {
2585
+ pushLine(str.substring(from, indexOfCR));
2586
+ if (str.length === indexOfCR + 1) {
2587
+ midCRLF = true;
2588
+ from = str.length;
2589
+ indexOfCR = -1;
2590
+ } else {
2591
+ from = indexOfCR + (indexOfLF === indexOfCR + 1 ? 2 : 1);
2592
+ indexOfCR = str.indexOf("\r", from);
2593
+ indexOfLF = str.indexOf(`
2594
+ `, from);
2595
+ }
2596
+ }
2597
+ }
2598
+ stringBuilder = stringBuilder + str.substring(from);
2599
+ }
2600
+ }
2601
+ return isReadonlyArrayNonEmpty(chunkBuilder) ? chunkBuilder : null;
2602
+ }
2603
+ const pullOrFlush = suspend3(() => {
2604
+ if (done2._tag === "Some") {
2605
+ return done(done2.value);
2606
+ }
2607
+ return matchEffect(upstream, {
2608
+ onSuccess: loop,
2609
+ onFailure: failCause3,
2610
+ onDone: (leftover) => {
2611
+ done2 = some(leftover);
2612
+ if (stringBuilder.length > 0) {
2613
+ const last = stringBuilder;
2614
+ stringBuilder = "";
2615
+ midCRLF = false;
2616
+ return succeed6([last]);
2617
+ }
2618
+ return done(leftover);
2619
+ }
2620
+ });
2621
+ });
2622
+ function loop(chunk) {
2623
+ const lines = splitLinesArray(chunk);
2624
+ return lines !== null ? succeed6(lines) : pullOrFlush;
2625
+ }
2626
+ return pullOrFlush;
2627
+ }));
2628
+ var decodeText2 = (encoding, options) => fromTransform((upstream, _scope) => sync2(() => {
2629
+ const decoder = new TextDecoder(encoding, options);
2630
+ const streamOptions = {
2631
+ stream: true
2632
+ };
2633
+ let pull = upstream.pipe(map8(map6((bytes) => decoder.decode(bytes, streamOptions))), catchDone((leftover) => {
2634
+ pull = done(leftover);
2635
+ const last = decoder.decode();
2636
+ return last.length > 0 ? succeed6(of(last)) : pull;
2637
+ }));
2638
+ return suspend3(() => pull);
2639
+ }));
2640
+ var pipeTo = /* @__PURE__ */ dual(2, (self, that) => fromTransform((upstream, scope) => flatMap3(toTransform(self)(upstream, scope), (upstream) => toTransform(that)(upstream, scope))));
2641
+ var isUpstreamFailure = (reason) => reason._tag === "Die" && isDone2(reason.defect) && isCause(reason.defect.value);
2642
+ var hasUpstreamFailure = (cause) => cause.reasons.some(isUpstreamFailure);
2643
+ var upstreamFailureToDefect = (pull) => catchCause2(pull, (cause) => isDoneCause(cause) ? failCause3(cause) : die3(Done2(cause)));
2644
+ var unwrapUpstreamFailure = (cause) => hasUpstreamFailure(cause) ? fromReasons(cause.reasons.flatMap((reason) => isUpstreamFailure(reason) ? reason.defect.value.reasons : [reason])) : cause;
2645
+ var restoreUpstreamFailure = (effect) => catchCause2(effect, (cause) => failCause3(unwrapUpstreamFailure(cause)));
2646
+ var unwrap2 = (channel) => fromTransform((upstream, scope) => {
2647
+ let pull;
2648
+ return succeed6(suspend3(() => {
2649
+ if (pull)
2650
+ return pull;
2651
+ return channel.pipe(provide(scope), flatMap3((channel) => toTransform(channel)(upstream, scope)), flatMap3((pull_) => pull = pull_));
2652
+ }));
2653
+ });
2654
+ var interruptWhen2 = /* @__PURE__ */ dual(2, (self, effect) => merge(self, fromPull(succeed6(flatMap3(effect, done))), {
2655
+ haltStrategy: "either"
2656
+ }));
2657
+ var onExit2 = /* @__PURE__ */ dual(2, (self, finalizer) => fromTransformBracket((upstream, scope, forkedScope) => addFinalizerExit(forkedScope, finalizer).pipe(andThen2(toTransform(self)(upstream, scope)))));
2658
+ var ensuring3 = /* @__PURE__ */ dual(2, (self, finalizer) => onExit2(self, (_) => finalizer));
2659
+ var runWith = (self, f, onHalt) => suspend3(() => {
2660
+ const scope = makeUnsafe6();
2661
+ const makePull = toTransform(self)(done(), scope);
2662
+ return catchDone(flatMap3(makePull, f), onHalt ? onHalt : succeed6).pipe(onExit((exit) => close(scope, exit)));
2663
+ });
2664
+ var provideContext3 = /* @__PURE__ */ dual(2, (self, context) => fromTransform((upstream, scope) => map8(provideContext2(toTransform(self)(upstream, scope), context), provideContext2(context))));
2665
+ var runDrain2 = (self) => runWith(self, (pull) => forever(pull, {
2666
+ disableYield: true
2667
+ }));
2668
+ var runForEach2 = /* @__PURE__ */ dual(2, (self, f) => runWith(self, (pull) => forever(flatMap3(pull, f), {
2669
+ disableYield: true
2670
+ })));
2671
+ var mkUint8Array = (self) => map8(runFold2(self, () => ({
2672
+ bytes: 0,
2673
+ arrays: []
2674
+ }), (acc, chunk) => {
2675
+ for (let i = 0;i < chunk.length; i++) {
2676
+ acc.bytes += chunk[i].length;
2677
+ acc.arrays.push(chunk[i]);
2678
+ }
2679
+ return acc;
2680
+ }), ({
2681
+ arrays,
2682
+ bytes
2683
+ }) => {
2684
+ const result = new Uint8Array(bytes);
2685
+ let offset = 0;
2686
+ for (let i = 0;i < arrays.length; i++) {
2687
+ const array = arrays[i];
2688
+ result.set(array, offset);
2689
+ offset += array.length;
2690
+ }
2691
+ return result;
2692
+ });
2693
+ var runHead2 = (self) => suspend3(() => {
2694
+ let head = none();
2695
+ return runWith(self, (pull) => pull.pipe(asSome2, flatMap3((head_) => {
2696
+ head = head_;
2697
+ return done();
2698
+ })), () => succeed6(head));
2699
+ });
2700
+ var runFold2 = /* @__PURE__ */ dual(3, (self, initial, f) => suspend3(() => {
2701
+ let state = initial();
2702
+ return runWith(self, (pull) => whileLoop({
2703
+ while: constTrue,
2704
+ body: () => pull,
2705
+ step: (value) => {
2706
+ state = f(state, value);
2707
+ }
2708
+ }), () => succeed6(state));
2709
+ }));
2710
+ var toPullScoped = (self, scope) => toTransform(self)(done(), scope);
2711
+
2712
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/internal/stream.js
2713
+ var TypeId6 = "~effect/Stream";
2714
+ var streamVariance = {
2715
+ _R: identity,
2716
+ _E: identity,
2717
+ _A: identity
2718
+ };
2719
+ var Stream = function(channel) {
2720
+ this.channel = channel;
2721
+ };
2722
+ Stream.prototype = {
2723
+ [TypeId6]: streamVariance,
2724
+ pipe() {
2725
+ return pipeArguments(this, arguments);
2726
+ }
2727
+ };
2728
+ var fromChannel3 = (channel) => new Stream(channel);
2729
+
2730
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/Sink.js
2731
+ var TypeId7 = "~effect/Sink";
2732
+ var endVoid = /* @__PURE__ */ succeed6([undefined]);
2733
+ var sinkVariance = {
2734
+ _A: identity,
2735
+ _In: identity,
2736
+ _L: identity,
2737
+ _E: identity,
2738
+ _R: identity
2739
+ };
2740
+ var SinkProto = {
2741
+ [TypeId7]: sinkVariance,
2742
+ pipe() {
2743
+ return pipeArguments(this, arguments);
2744
+ }
2745
+ };
2746
+ var isSink = (u) => hasProperty(u, TypeId7);
2747
+ var fromChannel = (channel) => fromTransform2((upstream, scope) => toTransform(channel)(upstream, scope).pipe(flatMap3(forever({
2748
+ disableYield: true
2749
+ })), catchDone(succeed6)));
2750
+ var fromTransform2 = (transform) => {
2751
+ const self = Object.create(SinkProto);
2752
+ self.transform = transform;
2753
+ return self;
2754
+ };
2755
+ var toChannel = (self) => fromTransform((upstream, scope) => succeed6(flatMap3(self.transform(upstream, scope), done)));
2756
+ var drain = /* @__PURE__ */ fromTransform2((upstream) => catchDone(forever(upstream, {
2757
+ disableYield: true
2758
+ }), () => endVoid));
2759
+ var forEach2 = (f) => forEachArray(forEach((_) => f(_), {
2760
+ discard: true
2761
+ }));
2762
+ var forEachArray = (f) => fromTransform2((upstream) => upstream.pipe(flatMap3(f), forever({
2763
+ disableYield: true
2764
+ }), catchDone(() => endVoid)));
2765
+ var unwrap3 = (effect) => fromChannel(unwrap2(map8(effect, toChannel)));
2766
+
2767
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/internal/rcRef.js
2768
+ var TypeId8 = "~effect/RcRef";
2769
+ var stateEmpty = {
2770
+ _tag: "Empty"
2771
+ };
2772
+ var stateClosed = {
2773
+ _tag: "Closed"
2774
+ };
2775
+ var variance2 = {
2776
+ _A: identity,
2777
+ _E: identity
2778
+ };
2779
+
2780
+ class RcRefImpl {
2781
+ [TypeId8] = variance2;
2782
+ pipe() {
2783
+ return pipeArguments(this, arguments);
2784
+ }
2785
+ state = stateEmpty;
2786
+ acquire;
2787
+ context;
2788
+ scope;
2789
+ idleTimeToLive;
2790
+ constructor(acquire, context, scope, idleTimeToLive) {
2791
+ this.acquire = acquire;
2792
+ this.context = context;
2793
+ this.scope = scope;
2794
+ this.idleTimeToLive = idleTimeToLive;
2795
+ }
2796
+ }
2797
+ var make6 = (options) => withFiber2((fiber) => {
2798
+ const context = fiber.context;
2799
+ const scope = get4(context, Scope);
2800
+ const ref = new RcRefImpl(options.acquire, context, scope, options.idleTimeToLive !== undefined ? fromInputUnsafe(options.idleTimeToLive) : undefined);
2801
+ return as(addFinalizerExit(scope, () => {
2802
+ const state = ref.state;
2803
+ ref.state = stateClosed;
2804
+ if (state._tag === "Acquired")
2805
+ return close(state.scope, void_2);
2806
+ if (state._tag === "Acquiring")
2807
+ return interrupt(state.fiber);
2808
+ return void_3;
2809
+ }), ref);
2810
+ });
2811
+ var getState = (self, restore) => {
2812
+ switch (self.state._tag) {
2813
+ case "Closed": {
2814
+ return interrupt3;
2815
+ }
2816
+ case "Acquired": {
2817
+ const state = self.state;
2818
+ state.refCount++;
2819
+ return state.fiber ? as(interrupt(state.fiber), state) : succeed6(state);
2820
+ }
2821
+ case "Acquiring": {
2822
+ const state = self.state;
2823
+ state.awaiters++;
2824
+ return awaitAcquiring(self, state, restore);
2825
+ }
2826
+ case "Empty": {
2827
+ const acquiring = {
2828
+ _tag: "Acquiring",
2829
+ fiber: undefined,
2830
+ awaiters: 1,
2831
+ acquired: undefined
2832
+ };
2833
+ self.state = acquiring;
2834
+ const scope = makeUnsafe6();
2835
+ const acquire = provideContext2(self.acquire, add(self.context, Scope, scope)).pipe(flatMap3((value) => {
2836
+ if (self.state !== acquiring) {
2837
+ return interrupt3;
2838
+ }
2839
+ const state = {
2840
+ _tag: "Acquired",
2841
+ value,
2842
+ scope,
2843
+ fiber: undefined,
2844
+ refCount: acquiring.awaiters,
2845
+ invalidated: false
2846
+ };
2847
+ self.state = state;
2848
+ acquiring.acquired = state;
2849
+ return succeed6(state);
2850
+ }), onExit((exit) => {
2851
+ if (isSuccess2(exit))
2852
+ return void_3;
2853
+ if (self.state === acquiring)
2854
+ self.state = stateEmpty;
2855
+ return close(scope, exit);
2856
+ }));
2857
+ acquiring.fiber = runForkWith(getCurrent().context)(acquire);
2858
+ return awaitAcquiring(self, acquiring, restore);
2859
+ }
2860
+ }
2861
+ };
2862
+ var awaitAcquiring = (self, acquiring, restore) => onExit(restore(join(acquiring.fiber)), (exit) => {
2863
+ const acquired = acquiring.acquired;
2864
+ if (acquired !== undefined) {
2865
+ return isFailure2(exit) ? release(self, acquired) : void_3;
2866
+ }
2867
+ if (--acquiring.awaiters > 0 || self.state !== acquiring)
2868
+ return void_3;
2869
+ self.state = stateEmpty;
2870
+ return interrupt(acquiring.fiber);
2871
+ });
2872
+ var get2 = (self_) => {
2873
+ const self = self_;
2874
+ return uninterruptibleMask2((restore) => flatMap3(scope2, (scope) => flatMap3(getState(self, restore), (state) => as(addFinalizerExit(scope, () => release(self, state)), state.value))));
2875
+ };
2876
+ var release = (self, state) => {
2877
+ state.refCount--;
2878
+ if (state.refCount > 0) {
2879
+ return void_3;
2880
+ }
2881
+ const idleTimeToLive = self.idleTimeToLive;
2882
+ if (idleTimeToLive === undefined || state.invalidated) {
2883
+ if (self.state === state) {
2884
+ self.state = stateEmpty;
2885
+ }
2886
+ return close(state.scope, void_2);
2887
+ } else if (!isFinite(idleTimeToLive)) {
2888
+ return void_3;
2889
+ }
2890
+ state.fiber = uninterruptibleMask2((restore) => flatMap3(restore(sleep(idleTimeToLive)), () => {
2891
+ if (self.state === state && state.refCount === 0) {
2892
+ self.state = stateEmpty;
2893
+ return ignoreCause(close(state.scope, void_2), {
2894
+ log: "Unhandled",
2895
+ message: "Unhandled error in RcRef finalizer"
2896
+ });
2897
+ }
2898
+ return void_3;
2899
+ })).pipe(ensuring2(sync2(() => {
2900
+ state.fiber = undefined;
2901
+ })), runForkWith(self.context), runIn(self.scope));
2902
+ return void_3;
2903
+ };
2904
+
2905
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/RcRef.js
2906
+ var make10 = make6;
2907
+ var get3 = get2;
2908
+
2909
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/Stream.js
2910
+ var TypeId9 = "~effect/Stream";
2911
+ var isStream = (u) => hasProperty(u, TypeId9);
2912
+ var fromChannel2 = fromChannel3;
2913
+ var fromPull2 = (pull) => fromChannel2(fromPull(pull));
2914
+ var transformPull2 = (self, f) => fromChannel2(fromTransform((_, scope) => flatMap3(toPullScoped(self.channel, scope), (pull) => f(pull, scope))));
2915
+ var toChannel2 = (stream) => stream.channel;
2916
+ var callback = (f, options) => fromChannel2(callbackArray(f, options));
2917
+ var empty2 = /* @__PURE__ */ fromChannel2(empty);
2918
+ var make11 = (...values) => fromArray2(values);
2919
+ var suspend = (stream) => {
2920
+ const suspended = fromChannel2(suspend4(() => stream().channel));
2921
+ suspendedStreams.set(suspended, stream);
2922
+ return suspended;
2923
+ };
2924
+ var suspendedStreams = /* @__PURE__ */ new WeakMap;
2925
+ var fail2 = (error) => fromChannel2(fail5(error));
2926
+ var die4 = (defect) => fromChannel2(die(defect));
2927
+ var fromArray2 = (array) => isReadonlyArrayNonEmpty(array) ? fromChannel2(succeed4(array)) : empty2;
2928
+ var fromQueue = (queue) => fromChannel2(fromQueueArray(queue));
2929
+ var fromPubSub = (pubsub) => fromChannel2(fromPubSubArray(pubsub));
2930
+ var fromReadableStream = (options) => fromChannel2(fromReadableStream2(options));
2931
+ var unwrap = (effect) => fromChannel2(unwrap2(map8(effect, toChannel2)));
2932
+ var map2 = /* @__PURE__ */ dual(2, (self, f) => suspend(() => {
2933
+ let i = 0;
2934
+ return fromChannel2(map7(self.channel, map6((o) => f(o, i++))));
2935
+ }));
2936
+ var mapEffect2 = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, f, options) => self.channel.pipe(flattenArray, mapEffect(f, options), map7(of), fromChannel2));
2937
+ var tap = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, f, options) => mapEffect2(self, (a) => as(f(a), a), options));
2938
+ var drainFork = /* @__PURE__ */ dual(2, (self, that) => mergeEffect2(self, runDrain(that)));
2939
+ var concat = /* @__PURE__ */ dual(2, (self, that) => {
2940
+ const stream = fromChannel2(flatten2(fromIterator(() => concatChannels(self, that))));
2941
+ concatParts.set(stream, [self, that]);
2942
+ return stream;
2943
+ });
2944
+ var concatParts = /* @__PURE__ */ new WeakMap;
2945
+ function* concatChannels(self, that) {
2946
+ const stack = [that, self];
2947
+ while (stack.length > 0) {
2948
+ const stream = stack.pop();
2949
+ const parts = concatParts.get(stream);
2950
+ if (parts !== undefined) {
2951
+ stack.push(parts[1], parts[0]);
2952
+ continue;
2953
+ }
2954
+ const evaluate = suspendedStreams.get(stream);
2955
+ if (evaluate === undefined) {
2956
+ yield stream.channel;
2957
+ continue;
2958
+ }
2959
+ try {
2960
+ stack.push(evaluate());
2961
+ } catch (defect) {
2962
+ stack.push(die4(defect));
2963
+ }
2964
+ yield empty;
2965
+ }
2966
+ }
2967
+ var merge2 = /* @__PURE__ */ dual((args) => isStream(args[0]) && isStream(args[1]), (self, that, options) => fromChannel2(merge(toChannel2(self), toChannel2(that), options)));
2968
+ var mergeEffect2 = /* @__PURE__ */ dual(2, (self, effect) => self.channel.pipe(mergeEffect(effect), fromChannel2));
2969
+ var filter = /* @__PURE__ */ dual(2, (self, predicate) => fromChannel2(filterArray(toChannel2(self), predicate)));
2970
+ var catchCause = /* @__PURE__ */ dual(2, (self, f) => self.channel.pipe(catchCause3((cause) => f(cause).channel), fromChannel2));
2971
+ var tapError = /* @__PURE__ */ dual(2, (self, f) => self.channel.pipe(tapError3(f), fromChannel2));
2972
+ var mapError = /* @__PURE__ */ dual(2, (self, f) => fromChannel2(mapError3(self.channel, f)));
2973
+ var transduce = /* @__PURE__ */ dual(2, (self, sink) => transformPull2(self, (upstream, scope) => sync2(() => {
2974
+ let done2;
2975
+ let leftover;
2976
+ const upstreamWithLeftover = suspend3(() => {
2977
+ if (leftover !== undefined) {
2978
+ const chunk = leftover;
2979
+ leftover = undefined;
2980
+ return succeed6(chunk);
2981
+ }
2982
+ return upstream;
2983
+ }).pipe(catch_((error) => {
2984
+ done2 = fail4(error);
2985
+ return done();
2986
+ }));
2987
+ const pull = map8(suspend3(() => sink.transform(upstreamWithLeftover, scope)), ([value, leftover_]) => {
2988
+ leftover = leftover_;
2989
+ return of(value);
2990
+ });
2991
+ return suspend3(() => done2 ? done2 : pull);
2992
+ })));
2993
+ var decodeText = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, options) => self.channel.pipe(pipeTo(decodeText2(options?.encoding)), fromChannel2));
2994
+ var encodeText = (self) => suspend(() => {
2995
+ const encoder = new TextEncoder;
2996
+ return map2(self, (chunk) => encoder.encode(chunk));
2997
+ });
2998
+ var splitLines = (self) => self.channel.pipe(pipeTo(splitLines2()), fromChannel2);
2999
+ var interruptWhen = /* @__PURE__ */ dual(2, (self, effect) => fromChannel2(interruptWhen2(self.channel, effect)));
3000
+ var ensuring = /* @__PURE__ */ dual(2, (self, finalizer) => fromChannel2(ensuring3(self.channel, finalizer)));
3001
+ var provideContext = /* @__PURE__ */ dual(2, (self, context) => fromChannel2(provideContext3(self.channel, context)));
3002
+ var run = /* @__PURE__ */ dual(2, (self, sink) => scopedWith((scope) => toPullScoped(self.channel, scope).pipe(flatMap3((upstream) => runSink(sink, upstream, scope)), map8(([a]) => a))));
3003
+ var runSink = (sink, upstream, scope) => restoreUpstreamFailure(sink.transform(upstreamFailureToDefect(upstream), scope));
3004
+ var runCollect = (self) => runFold2(self.channel, () => [], (acc, chunk) => {
3005
+ for (let i = 0;i < chunk.length; i++) {
3006
+ acc.push(chunk[i]);
3007
+ }
3008
+ return acc;
3009
+ });
3010
+ var runFold = /* @__PURE__ */ dual(3, (self, initial, f) => runFold2(self.channel, initial, (acc, arr) => {
3011
+ for (let i = 0;i < arr.length; i++) {
3012
+ acc = f(acc, arr[i]);
3013
+ }
3014
+ return acc;
3015
+ }));
3016
+ var runHead = (self) => map8(runHead2(self.channel), map4(getUnsafe2(0)));
3017
+ var runForEach = /* @__PURE__ */ dual(2, (self, f) => runForEach2(self.channel, (arr) => {
3018
+ let i = 0;
3019
+ return whileLoop({
3020
+ while: () => i < arr.length,
3021
+ body: () => f(arr[i++]),
3022
+ step: constVoid
3023
+ });
3024
+ }));
3025
+ var runDrain = (self) => runDrain2(self.channel);
3026
+ var mkString = (self) => runFold2(self.channel, () => "", (acc, chunk) => acc + chunk.join(""));
3027
+ var mkArrayBuffer = (self) => map8(mkUint8Array(self.channel), (bytes) => bytes.buffer);
3028
+ var toReadableStreamWith = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, context, options) => {
3029
+ let currentResolve = undefined;
3030
+ let fiber = undefined;
3031
+ let cancelled = false;
3032
+ const latch = makeUnsafe2(false);
3033
+ const signal = options?.signal;
3034
+ const onAbort = () => fiber.interruptUnsafe();
3035
+ return new ReadableStream({
3036
+ start(controller) {
3037
+ fiber = runFork(provideContext2(runForEach2(transformPull(self.channel, (pull) => succeed6(latch.whenOpen(pull))), (chunk) => sync2(() => {
3038
+ latch.closeUnsafe();
3039
+ for (let i = 0;i < chunk.length; i++) {
3040
+ controller.enqueue(chunk[i]);
3041
+ }
3042
+ currentResolve();
3043
+ currentResolve = undefined;
3044
+ })), context));
3045
+ fiber.addObserver((exit) => {
3046
+ signal?.removeEventListener("abort", onAbort);
3047
+ if (cancelled)
3048
+ return;
3049
+ if (exit._tag === "Failure" && signal?.aborted !== true) {
3050
+ controller.error(squash(exit.cause));
3051
+ } else {
3052
+ controller.close();
3053
+ }
3054
+ });
3055
+ if (signal !== undefined && fiber.pollUnsafe() === undefined) {
3056
+ if (signal.aborted)
3057
+ onAbort();
3058
+ else
3059
+ signal.addEventListener("abort", onAbort, {
3060
+ once: true
3061
+ });
3062
+ }
3063
+ },
3064
+ pull() {
3065
+ return new Promise((resolve) => {
3066
+ currentResolve = resolve;
3067
+ latch.openUnsafe();
3068
+ });
3069
+ },
3070
+ cancel() {
3071
+ if (!fiber)
3072
+ return;
3073
+ cancelled = true;
3074
+ return runPromise(asVoid(interrupt(fiber)));
3075
+ }
3076
+ }, options?.strategy);
3077
+ });
3078
+ var toReadableStreamEffect = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, options) => map8(context(), (context) => toReadableStreamWith(self, context, options)));
3079
+
3080
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/FileSystem.js
3081
+ var TypeId10 = "~effect/FileSystem";
3082
+ var FileSystem = /* @__PURE__ */ Service2("effect/FileSystem");
3083
+ var make12 = (impl) => FileSystem.of({
3084
+ ...impl,
3085
+ [TypeId10]: TypeId10,
3086
+ glob: make2(impl),
3087
+ exists: (path) => pipe(impl.access(path), as(true), catchTag("PlatformError", (e) => e.reason._tag === "NotFound" ? succeed6(false) : fail7(e))),
3088
+ readFileString: (path, encoding) => flatMap3(impl.readFile(path), (_) => try_2({
3089
+ try: () => new TextDecoder(encoding).decode(_),
3090
+ catch: (cause) => badArgument({
3091
+ module: "FileSystem",
3092
+ method: "readFileString",
3093
+ description: "invalid encoding",
3094
+ cause
3095
+ })
3096
+ })),
3097
+ stream: fnUntraced(function* (path, options) {
3098
+ const file = yield* impl.open(path, {
3099
+ flag: "r"
3100
+ });
3101
+ const offset = options?.offset === undefined ? undefined : fromInputUnsafe2(options.offset);
3102
+ if (offset) {
3103
+ yield* file.seek(offset, "start");
3104
+ }
3105
+ const bytesToRead = options?.bytesToRead === undefined ? undefined : fromInputUnsafe2(options.bytesToRead);
3106
+ let totalBytesRead = BigInt(0);
3107
+ const chunkSize = Number(BigInt(options?.chunkSize ?? 64 * 1024));
3108
+ const readChunk = file.readAlloc(chunkSize);
3109
+ return fromPull2(succeed6(flatMap3(suspend3(() => {
3110
+ if (bytesToRead !== undefined && bytesToRead <= totalBytesRead) {
3111
+ return done();
3112
+ }
3113
+ return bytesToRead !== undefined && bytesToRead - totalBytesRead < chunkSize ? file.readAlloc(Number(bytesToRead - totalBytesRead)) : readChunk;
3114
+ }), match({
3115
+ onNone: () => done(),
3116
+ onSome: (buf) => {
3117
+ totalBytesRead += BigInt(buf.length);
3118
+ return succeed6(of(buf));
3119
+ }
3120
+ }))));
3121
+ }, unwrap),
3122
+ sink: (path, options) => pipe(impl.open(path, {
3123
+ ...options,
3124
+ flag: options?.flag ?? "w"
3125
+ }), map8((file) => forEach2((_) => file.writeAll(_))), unwrap3),
3126
+ writeFileString: (path, data, options) => flatMap3(try_2({
3127
+ try: () => new TextEncoder().encode(data),
3128
+ catch: (cause) => badArgument({
3129
+ module: "FileSystem",
3130
+ method: "writeFileString",
3131
+ description: "could not encode string",
3132
+ cause
3133
+ })
3134
+ }), (_) => impl.writeFile(path, _, options))
3135
+ });
3136
+ var FileTypeId = "~effect/FileSystem/File";
3137
+ class WatchBackend extends (/* @__PURE__ */ Service2()("effect/FileSystem/WatchBackend")) {
3138
+ }
3139
+
3140
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/Path.js
3141
+ var TypeId11 = "~effect/Path";
3142
+ var Path = /* @__PURE__ */ Service2("effect/Path");
3143
+ var make13 = (impl) => Path.of({
3144
+ ...impl,
3145
+ [TypeId11]: TypeId11,
3146
+ resolveWithin(root, input) {
3147
+ if (impl.parse(input).root !== "")
3148
+ return none();
3149
+ const base = impl.resolve(root);
3150
+ const candidate = impl.resolve(base, input);
3151
+ const relative = impl.relative(base, candidate);
3152
+ return relative === ".." || relative.startsWith(`..${impl.sep}`) || impl.isAbsolute(relative) ? none() : some(candidate);
3153
+ }
3154
+ });
3155
+
3156
+ // packages/core/src/embedded-files.ts
3157
+ function embeddedFile(files, name) {
3158
+ const pattern = new RegExp(`^${name}-[a-z0-9]+\\.$`);
3159
+ return files.find((file) => ("name" in file) && pattern.test(String(file.name)));
3160
+ }
3161
+ var extractEmbeddedFile = fnUntraced(function* (directory, file, name) {
3162
+ const fs = yield* FileSystem;
3163
+ const path = yield* Path;
3164
+ const target = path.join(directory, file.name.slice(0, -1), name);
3165
+ const existing = yield* fs.stat(target).pipe(option2);
3166
+ if (isSome(existing) && Number(existing.value.size) === file.size)
3167
+ return target;
3168
+ yield* fs.makeDirectory(path.dirname(target), { recursive: true });
3169
+ const written = path.join(yield* fs.makeTempDirectoryScoped({ directory: path.dirname(target) }), name);
3170
+ yield* fs.writeFile(written, new Uint8Array(yield* promise(() => file.arrayBuffer())));
3171
+ yield* fs.chmod(written, 493);
3172
+ yield* fs.rename(written, target);
3173
+ return target;
3174
+ }, scoped);
3175
+
3176
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/ConfigProvider.js
3177
+ function makeValue(value) {
3178
+ return {
3179
+ _tag: "Value",
3180
+ value
3181
+ };
3182
+ }
3183
+ function makeRecord(keys, value) {
3184
+ return {
3185
+ _tag: "Record",
3186
+ keys,
3187
+ value
3188
+ };
3189
+ }
3190
+ function makeArray(length, value) {
3191
+ return {
3192
+ _tag: "Array",
3193
+ length,
3194
+ value
3195
+ };
3196
+ }
3197
+ var ConfigProvider = /* @__PURE__ */ Reference("effect/ConfigProvider", {
3198
+ defaultValue: () => fromEnv()
3199
+ });
3200
+ var Proto = {
3201
+ ...PipeInspectableProto,
3202
+ toJSON() {
3203
+ return {
3204
+ _id: "ConfigProvider"
3205
+ };
3206
+ }
3207
+ };
3208
+ var identityPath = (path) => path;
3209
+ function makeProvider(load, mapInput) {
3210
+ const self = Object.create(Proto);
3211
+ self.load = load;
3212
+ self.mapInput = mapInput;
3213
+ return self;
3214
+ }
3215
+ function makeSource(get, transform) {
3216
+ return makeProvider((path) => get(transform(path)), (f) => makeSource(get, (path) => f(transform(path))));
3217
+ }
3218
+ function make7(get) {
3219
+ return makeSource(get, identityPath);
3220
+ }
3221
+ function emptyStringAsMissing(value, preserveEmptyStrings) {
3222
+ return value === "" && !preserveEmptyStrings ? undefined : value;
3223
+ }
3224
+ function fromEnvRecord(env, options) {
3225
+ const preserveEmptyStrings = options?.preserveEmptyStrings === true;
3226
+ const trie = buildEnvTrie(env);
3227
+ return make7((path) => succeed6(nodeAtEnv(trie, env, path, preserveEmptyStrings)));
3228
+ }
3229
+ function fromEnv(options) {
3230
+ const env = options?.env ?? {
3231
+ ...globalThis.process?.env,
3232
+ ...import.meta?.env
3233
+ };
3234
+ return fromEnvRecord(env, {
3235
+ preserveEmptyStrings: options?.preserveEmptyStrings
3236
+ });
3237
+ }
3238
+ function buildEnvTrie(env) {
3239
+ const trie = {};
3240
+ for (const [name, value] of Object.entries(env)) {
3241
+ if (value === undefined)
3242
+ continue;
3243
+ const segments = name.split("_");
3244
+ let node = trie;
3245
+ for (const seg of segments) {
3246
+ const children = node.children ??= Object.create(null);
3247
+ node = children[seg] ??= {};
3248
+ }
3249
+ }
3250
+ return trie;
3251
+ }
3252
+ function nodeAtEnv(trie, env, path, preserveEmptyStrings) {
3253
+ const key = path.map(String).join("_");
3254
+ const leafValue = emptyStringAsMissing(Object.hasOwn(env, key) ? env[key] : undefined, preserveEmptyStrings);
3255
+ const trieNode = trieNodeAt(trie, path);
3256
+ const children = trieNode?.children ? Object.keys(trieNode.children) : [];
3257
+ if (children.length === 0) {
3258
+ return leafValue === undefined ? undefined : makeValue(leafValue);
3259
+ }
3260
+ const allNumeric = children.every(isCanonicalArrayIndex);
3261
+ if (allNumeric) {
3262
+ const length = Math.max(...children.map((k) => parseInt(k, 10))) + 1;
3263
+ return makeArray(length, leafValue);
3264
+ }
3265
+ return makeRecord(new Set(children), leafValue);
3266
+ }
3267
+ function trieNodeAt(root, path) {
3268
+ if (path.length === 0)
3269
+ return root;
3270
+ let node = root;
3271
+ for (const seg of path) {
3272
+ node = node?.children?.[String(seg)];
3273
+ if (!node)
3274
+ return;
3275
+ }
3276
+ return node;
3277
+ }
3278
+
3279
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/Config.js
3280
+ var TypeId12 = "~effect/Config";
3281
+ class ConfigError {
3282
+ _tag = "ConfigError";
3283
+ name = "ConfigError";
3284
+ cause;
3285
+ constructor(cause) {
3286
+ this.cause = cause;
3287
+ }
3288
+ get message() {
3289
+ return this.cause.toString();
3290
+ }
3291
+ toString() {
3292
+ return `ConfigError(${this.message})`;
3293
+ }
3294
+ }
3295
+ var Proto2 = {
3296
+ .../* @__PURE__ */ Prototype({
3297
+ label: "Config",
3298
+ evaluate(fiber) {
3299
+ return this.parse(fiber.getRef(ConfigProvider));
3300
+ }
3301
+ }),
3302
+ [TypeId12]: TypeId12,
3303
+ toJSON() {
3304
+ return {
3305
+ _id: "Config"
3306
+ };
3307
+ }
3308
+ };
3309
+ function make14(evaluator) {
3310
+ const self = Object.create(Proto2);
3311
+ self.evaluator = evaluator;
3312
+ self.parse = (provider) => flatMapEager(evaluator(provider, []), fromResult);
3313
+ return self;
3314
+ }
3315
+ var evaluateAt = (self, provider, pathPrefix) => self.evaluator(provider, pathPrefix);
3316
+ var map3 = /* @__PURE__ */ dual(2, (self, f) => {
3317
+ return make14((provider, pathPrefix) => map8(evaluateAt(self, provider, pathPrefix), map5(f)));
3318
+ });
3319
+ function all(arg) {
3320
+ const configs = globalThis.Array.isArray(arg) ? arg : (Symbol.iterator in arg) ? [...arg] : arg;
3321
+ return make14((provider, pathPrefix) => globalThis.Array.isArray(configs) ? mapEager(all3(configs.map((config) => evaluateAt(config, provider, pathPrefix))), all2) : mapEager(all3(map(configs, (config) => evaluateAt(config, provider, pathPrefix))), all2));
3322
+ }
3323
+ var withDefault = /* @__PURE__ */ dual(2, (self, defaultValue) => {
3324
+ return make14((provider, pathPrefix) => mapEager(evaluateAt(self, provider, pathPrefix), (resolution) => isFailure(resolution) ? succeed(defaultValue) : resolution));
3325
+ });
3326
+ var option = (self) => self.pipe(map3(some), withDefault(none()));
3327
+ var isSourceError = (u) => isTagged(u, "SourceError");
3328
+ var cursorToString = () => "<configuration>";
3329
+ var mapReasons = (f) => (self) => catchCause2(self, (cause) => failCause3(fromReasons(cause.reasons.map(f))));
3330
+ var loadCursor = (provider, path) => provider.load(path).pipe(mapReasons((reason) => isFailReason(reason) ? makeDieReason(reason.error).annotate(reasonAnnotations(reason)) : reason), mapEager((node) => ({
3331
+ provider,
3332
+ path,
3333
+ node,
3334
+ toString: cursorToString
3335
+ })));
3336
+ var loadChildCursor = (cursor, segment) => loadCursor(cursor.provider, [...cursor.path, segment]);
3337
+ var decodeFromCursor = (ast, decode) => decodeTo(unknown, ast, new Transformation(transformEffect((input) => decode(input)), passthrough()));
3338
+ var isScalarInput = (ast) => {
3339
+ switch (ast._tag) {
3340
+ case "Union":
3341
+ return ast.types.every(isScalarInput);
3342
+ case "Objects":
3343
+ case "Arrays":
3344
+ case "Suspend":
3345
+ return false;
3346
+ default:
3347
+ return true;
3348
+ }
3349
+ };
3350
+ var hasProviderInput = (ast, node) => {
3351
+ switch (ast._tag) {
3352
+ case "Objects":
3353
+ return node?._tag === "Record";
3354
+ case "Arrays":
3355
+ return node?._tag === "Array";
3356
+ case "Union":
3357
+ return ast.types.some((ast) => hasProviderInput(ast, node));
3358
+ case "Suspend":
3359
+ return hasProviderInput(ast.thunk(), node);
3360
+ default:
3361
+ return node?.value !== undefined;
3362
+ }
3363
+ };
3364
+ var toConfigCursorAST = /* @__PURE__ */ memoize((root) => {
3365
+ const seen = new WeakSet;
3366
+ const recur = applyToSelfOrLastLinkEncoding((ast) => {
3367
+ seen.add(ast);
3368
+ switch (ast._tag) {
3369
+ case "Objects": {
3370
+ const materialize = fnUntraced(function* (cursor) {
3371
+ if (cursor.node?._tag !== "Record") {
3372
+ return;
3373
+ }
3374
+ const node = cursor.node;
3375
+ const keys = new Set;
3376
+ for (const property of ast.propertySignatures) {
3377
+ if (typeof property.name === "string")
3378
+ keys.add(property.name);
3379
+ }
3380
+ if (ast.indexSignatures.length > 0) {
3381
+ const input = {};
3382
+ for (const key of node.keys) {
3383
+ assignProperty(input, key, undefined);
3384
+ }
3385
+ for (const is of ast.indexSignatures) {
3386
+ for (const key of getIndexSignatureKeys(input, is.parameter)) {
3387
+ if (typeof key === "string")
3388
+ keys.add(key);
3389
+ }
3390
+ }
3391
+ }
3392
+ const out = {};
3393
+ for (const key of keys) {
3394
+ const child = yield* loadChildCursor(cursor, key);
3395
+ if (child.node !== undefined)
3396
+ assignProperty(out, key, child);
3397
+ }
3398
+ return out;
3399
+ });
3400
+ return decodeFromCursor(ast.recur(recur, (ast) => ast), materialize);
3401
+ }
3402
+ case "Arrays": {
3403
+ const materialize = fnUntraced(function* (cursor) {
3404
+ if (cursor.node?._tag !== "Array") {
3405
+ return;
3406
+ }
3407
+ const out = [];
3408
+ for (let i = 0;i < cursor.node.length; i++) {
3409
+ out.push(yield* loadChildCursor(cursor, i));
3410
+ }
3411
+ return out;
3412
+ });
3413
+ return decodeFromCursor(ast.recur(recur), materialize);
3414
+ }
3415
+ case "Union":
3416
+ for (const member of ast.types) {
3417
+ recur(member);
3418
+ }
3419
+ if (!isScalarInput(ast))
3420
+ return ast.recur(recur);
3421
+ break;
3422
+ case "Suspend": {
3423
+ const target = ast.thunk();
3424
+ if (!seen.has(target))
3425
+ recur(target);
3426
+ return ast.recur(recur);
3427
+ }
3428
+ case "Declaration":
3429
+ case "Any":
3430
+ throw new globalThis.Error("Config.schema does not support opaque StringTree encodings", {
3431
+ cause: ast
3432
+ });
3433
+ }
3434
+ return decodeFromCursor(ast, (cursor) => succeed6(cursor.node?.value));
3435
+ });
3436
+ return recur(root);
3437
+ });
3438
+ function schema(codec, path) {
3439
+ const codecStringTree = toCodecStringTree(codec);
3440
+ const encodedAst = toEncoded(codecStringTree.ast);
3441
+ const decodeCursor = decodeUnknownEffect(make18(toConfigCursorAST(codecStringTree.ast)));
3442
+ const localPath = typeof path === "string" ? [path] : path ?? [];
3443
+ return make14((provider, pathPrefix) => {
3444
+ const fullPath = [...pathPrefix, ...localPath];
3445
+ return loadCursor(provider, fullPath).pipe(flatMapEager((cursor) => decodeCursor(cursor).pipe(mapEager(succeed), catchEager((issue) => {
3446
+ const error = new ConfigError(new SchemaError(fullPath.length > 0 ? new Pointer(fullPath, issue) : issue));
3447
+ return hasProviderInput(encodedAst, cursor.node) ? fail7(error) : succeed6(fail3(error));
3448
+ }))), mapReasons((reason) => isDieReason(reason) && isSourceError(reason.defect) ? makeFailReason(new ConfigError(reason.defect)).annotate(reasonAnnotations(reason)) : reason));
3449
+ });
3450
+ }
3451
+ function String2(name) {
3452
+ return schema(String4, name);
3453
+ }
3454
+
3455
+ // packages/agent-runtime/src/srt-sandbox.ts
3456
+ import { homedir } from "os";
3457
+ import { fileURLToPath } from "url";
3458
+
3459
+ // packages/agent-runtime/src/env.ts
3460
+ var optionalEnv = (name) => gen(function* () {
3461
+ const value = getOrUndefined(yield* option(String2(name)))?.trim();
3462
+ return value === undefined || value.length === 0 ? undefined : value;
3463
+ }).pipe(orElseSucceed(() => {
3464
+ return;
3465
+ }));
3466
+
3467
+ // packages/agent-runtime/src/srt-sandbox.ts
3468
+ var harnessesUnsupportedInSrt2 = ["codex"];
3469
+ var compiled2 = import.meta.url.startsWith("file:///$bunfs/");
3470
+ var pinnedSrtCommand2 = () => compiled2 ? [process.execPath, "srt"] : [process.execPath, fileURLToPath(import.meta.resolve("@anthropic-ai/sandbox-runtime/dist/cli.js"))];
3471
+ var pinnedSrtStepCommand2 = () => compiled2 ? [process.execPath, "srt-step"] : [process.execPath, fileURLToPath(new URL("./srt-step.main.ts", import.meta.url))];
3472
+ var srtPackageDir = () => fileURLToPath(new URL("../", import.meta.resolve("@anthropic-ai/sandbox-runtime/dist/cli.js")));
3473
+ var runSrtCli2 = () => import("@anthropic-ai/sandbox-runtime/dist/cli.js");
3474
+ var embeddedApplySeccomp = gen(function* () {
3475
+ const file = compiled2 && process.platform === "linux" ? embeddedFile(Bun.embeddedFiles, "apply-seccomp") : undefined;
3476
+ if (file === undefined)
3477
+ return;
3478
+ const path = yield* Path;
3479
+ const cacheHome = yield* String2("XDG_CACHE_HOME").pipe(withDefault(""));
3480
+ return yield* extractEmbeddedFile(path.join(cacheHome === "" ? path.join(homedir(), ".cache") : cacheHome, "kitman"), file, "apply-seccomp");
3481
+ }).pipe(orDie);
3482
+ var globCharacters = /[*?[\]{}]/;
3483
+ var readAllowEntry = (path) => globCharacters.test(path) ? { path, literal: true } : path;
3484
+ var srtSettings2 = (policy, ownFiles = [], unixSockets = []) => policy.network === "open" ? undefined : {
3485
+ network: {
3486
+ allowedDomains: [...policy.network.hosts],
3487
+ deniedDomains: [],
3488
+ strictAllowlist: true,
3489
+ ...unixSockets.length === 0 ? undefined : { allowUnixSockets: [...unixSockets] }
3490
+ },
3491
+ filesystem: {
3492
+ denyRead: [...policy.readDeniedPaths],
3493
+ allowRead: [...policy.readAllowedPaths, ...ownFiles].map(readAllowEntry),
3494
+ allowWrite: [...policy.writablePaths],
3495
+ denyWrite: []
3496
+ }
3497
+ };
3498
+ var srtCacheEnvironment2 = (dir) => ({
3499
+ XDG_CACHE_HOME: dir,
3500
+ npm_config_cache: `${dir}/npm`,
3501
+ BUN_INSTALL_CACHE_DIR: `${dir}/bun`
3502
+ });
3503
+ var srtInheritedEnv2 = [
3504
+ "PATH",
3505
+ "HOME",
3506
+ "USER",
3507
+ "LOGNAME",
3508
+ "SHELL",
3509
+ "TMPDIR",
3510
+ "LANG",
3511
+ "LC_ALL",
3512
+ "LC_CTYPE",
3513
+ "TZ"
3514
+ ];
3515
+ var inheritedEnvironment2 = (names) => map8(forEach(names, (name) => map8(optionalEnv(name), (value) => value === undefined ? [] : [[name, value]])), (entries) => Object.fromEntries(entries.flat()));
3516
+ var shellName = /^[A-Za-z_][A-Za-z0-9_]*$/;
3517
+ var withOnlyEnvironment2 = (names, argv) => [
3518
+ "sh",
3519
+ "-c",
3520
+ `exec env -i ${[...new Set(names)].flatMap((name) => shellName.test(name) ? [`\${${name}+"${name}=$${name}"}`] : []).join(" ")} "$@"`,
3521
+ "sh",
3522
+ ...argv
3523
+ ];
3524
+ var linkTarget = (fs, path) => {
3525
+ const expanded = path === "~" || path.startsWith("~/") ? `${homedir()}${path.slice(1)}` : path;
3526
+ return fs.readLink(expanded).pipe(andThen2(fs.realPath(expanded)), orElseSucceed(() => path));
3527
+ };
3528
+ var writeSrtSettings2 = (policy, unixSockets) => gen(function* () {
3529
+ const fs = yield* FileSystem;
3530
+ const path = yield* Path;
3531
+ const applyPath = yield* embeddedApplySeccomp;
3532
+ const seccomp = applyPath ?? (compiled2 ? undefined : path.join(srtPackageDir(), "vendor"));
3533
+ const readAllowedPaths = yield* forEach(policy.readAllowedPaths, (allowed) => linkTarget(fs, allowed));
3534
+ const settings = srtSettings2({ ...policy, readAllowedPaths }, seccomp === undefined ? [] : [seccomp], unixSockets);
3535
+ if (settings === undefined)
3536
+ return yield* die3(new Error("srt cannot run a Step with an open network"));
3537
+ const dir = yield* fs.makeTempDirectoryScoped({ prefix: "kitman-srt-" });
3538
+ const settingsFile = path.join(dir, "srt-settings.json");
3539
+ yield* fs.writeFileString(settingsFile, encodeUnknownJsonStringSync(applyPath === undefined ? settings : { ...settings, seccomp: { applyPath } }));
3540
+ return { dir, settingsFile };
3541
+ });
3542
+ var srtStepArgv2 = (srtStepCommand, settingsFile, registryFile, argv) => [...srtStepCommand, "--settings", settingsFile, "--secrets", registryFile, "--", ...argv];
3543
+ var srtArgv2 = (srtCommand, settingsFile, argv) => [
3544
+ ...srtCommand,
3545
+ "--settings",
3546
+ settingsFile,
3547
+ "--",
3548
+ ...argv
3549
+ ];
3550
+
3551
+ export { map, makeEquivalence, bytes, join, interrupt, getCurrent, BadArgument, systemError, badArgument, makeUnsafe2, make8, unbounded, publishUnsafe, make9, bounded, sliding, unbounded2, offer, offerUnsafe, offerAll, fail, failCause, failCauseUnsafe, end, endUnsafe, shutdownUnsafe, take, poll, makeUnsafe3, fromTransform, mapDone, isSink, fromChannel, drain, make10, get3, isStream, fromChannel2, callback, empty2, make11, suspend, fail2, fromQueue, fromPubSub, fromReadableStream, unwrap, map2, tap, drainFork, concat, merge2, filter, catchCause, tapError, mapError, transduce, decodeText, encodeText, splitLines, interruptWhen, ensuring, provideContext, run, runCollect, runFold, runHead, runForEach, runDrain, mkString, mkArrayBuffer, toReadableStreamEffect, FileSystem, make12, FileTypeId, WatchBackend, Path, make13, embeddedFile, extractEmbeddedFile, map3, all, withDefault, option, String2, optionalEnv, harnessesUnsupportedInSrt2, compiled2, pinnedSrtCommand2, pinnedSrtStepCommand2, runSrtCli2, srtSettings2, srtCacheEnvironment2, srtInheritedEnv2, inheritedEnvironment2, withOnlyEnvironment2, writeSrtSettings2, srtStepArgv2, srtArgv2 };