ambral 0.4.0 → 0.5.0

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 (2) hide show
  1. package/dist/ambral.js +2290 -491
  2. package/package.json +1 -1
package/dist/ambral.js CHANGED
@@ -215,6 +215,7 @@ var constFalse = /* @__PURE__ */ constant(false);
215
215
  var constNull = /* @__PURE__ */ constant(null);
216
216
  var constUndefined = /* @__PURE__ */ constant(undefined);
217
217
  var constVoid = constUndefined;
218
+ var compose = /* @__PURE__ */ dual(2, (ab, bc) => (a) => bc(ab(a)));
218
219
  function pipe(a, ...args) {
219
220
  return pipeArguments(a, args);
220
221
  }
@@ -360,7 +361,7 @@ __export(exports_Predicate, {
360
361
  hasProperty: () => hasProperty,
361
362
  every: () => every,
362
363
  eqv: () => eqv,
363
- compose: () => compose,
364
+ compose: () => compose2,
364
365
  and: () => and,
365
366
  Tuple: () => Tuple,
366
367
  Struct: () => Struct
@@ -457,7 +458,7 @@ function isPromiseLike(input) {
457
458
  function isRegExp(input) {
458
459
  return input instanceof RegExp;
459
460
  }
460
- var compose = /* @__PURE__ */ dual(2, (ab, bc) => (a) => ab(a) && bc(a));
461
+ var compose2 = /* @__PURE__ */ dual(2, (ab, bc) => (a) => ab(a) && bc(a));
461
462
  function Tuple(elements) {
462
463
  return (as) => {
463
464
  for (let i = 0;i < elements.length; i++) {
@@ -4783,6 +4784,13 @@ class ParentSpan extends (/* @__PURE__ */ Service()(ParentSpanKey, {
4783
4784
  })) {
4784
4785
  }
4785
4786
  var make9 = (options) => options;
4787
+ var externalSpan = (options) => ({
4788
+ _tag: "ExternalSpan",
4789
+ spanId: options.spanId,
4790
+ traceId: options.traceId,
4791
+ sampled: options.sampled ?? true,
4792
+ annotations: options.annotations ?? empty()
4793
+ });
4786
4794
  var DisablePropagation = /* @__PURE__ */ Reference("effect/Tracer/DisablePropagation", {
4787
4795
  defaultValue: constFalse
4788
4796
  });
@@ -6681,6 +6689,12 @@ var fiberEnterUninterruptibleUnsafe = (fiber2) => {
6681
6689
  impl.interruptible = false;
6682
6690
  impl._stack.push(setInterruptibleTrue);
6683
6691
  };
6692
+ var fiberEnterInterruptibleUnsafe = (fiber2) => {
6693
+ const impl = fiber2;
6694
+ if (impl.interruptible)
6695
+ return;
6696
+ return setFiberInterruptible(impl);
6697
+ };
6684
6698
  var interruptible = (self) => withFiber((fiber2) => {
6685
6699
  if (fiber2.interruptible)
6686
6700
  return self;
@@ -8260,6 +8274,7 @@ var addFinalizer2 = scopeAddFinalizer;
8260
8274
  var fork = scopeFork;
8261
8275
  var forkUnsafe2 = scopeForkUnsafe;
8262
8276
  var close = scopeClose;
8277
+ var closeUnsafe = scopeCloseUnsafe;
8263
8278
 
8264
8279
  // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/Layer.js
8265
8280
  var TypeId7 = "~effect/Layer";
@@ -18148,7 +18163,7 @@ var runGetter = (self, input, options) => {
18148
18163
  };
18149
18164
  var makeGetter = (fields) => Object.assign(Object.create(Prototype), fields);
18150
18165
  var composeOptionalEffect = (first, second) => transformOptionalEffect((input, options) => flatMapEager2(runGetter(first, input, options), (output) => runGetter(second, output, options)));
18151
- var compose2 = /* @__PURE__ */ dual(2, (self, other) => {
18166
+ var compose3 = /* @__PURE__ */ dual(2, (self, other) => {
18152
18167
  if (self._tag === "Passthrough")
18153
18168
  return other;
18154
18169
  if (other._tag === "Passthrough")
@@ -18753,7 +18768,7 @@ var Transformation = class extends Class {
18753
18768
  return new Transformation(this.encode, this.decode);
18754
18769
  }
18755
18770
  };
18756
- var composeTransformation = /* @__PURE__ */ dual(2, (self, other) => new Transformation(compose2(self.decode, other.decode), compose2(other.encode, self.encode)));
18771
+ var composeTransformation = /* @__PURE__ */ dual(2, (self, other) => new Transformation(compose3(self.decode, other.decode), compose3(other.encode, self.encode)));
18757
18772
  function isTransformation(u) {
18758
18773
  return hasProperty(u, TypeId31) && u[TypeId31] === TypeId31;
18759
18774
  }
@@ -28094,7 +28109,7 @@ class CheckNode {
28094
28109
  this.get = (s) => runChecks(checks, s);
28095
28110
  }
28096
28111
  }
28097
- function compose3(a, b) {
28112
+ function compose4(a, b) {
28098
28113
  if (a.length === 0)
28099
28114
  return b;
28100
28115
  if (b.length === 0)
@@ -28133,13 +28148,13 @@ class OptionalImpl {
28133
28148
  return (s) => getOrElse3(flatMap2(this.getResult(s), (a) => this.replaceResult(f(a), s)), () => s);
28134
28149
  }
28135
28150
  compose(that) {
28136
- return make41(compose3(this.node, that.node));
28151
+ return make41(compose4(this.node, that.node));
28137
28152
  }
28138
28153
  key(key) {
28139
- return make41(compose3(this.node, [new PathNode([key])]));
28154
+ return make41(compose4(this.node, [new PathNode([key])]));
28140
28155
  }
28141
28156
  optionalKey(key) {
28142
- return make41(compose3(this.node, primitiveNode("Lens", (s) => s[key], (a, s) => {
28157
+ return make41(compose4(this.node, primitiveNode("Lens", (s) => s[key], (a, s) => {
28143
28158
  const copy5 = cloneShallow(s);
28144
28159
  if (a === undefined) {
28145
28160
  if (Array.isArray(copy5) && (typeof key === "number" || typeof key === "string" && isCanonicalArrayIndex(key))) {
@@ -28154,20 +28169,20 @@ class OptionalImpl {
28154
28169
  })));
28155
28170
  }
28156
28171
  check(...checks) {
28157
- return make41(compose3(this.node, [new CheckNode(checks)]));
28172
+ return make41(compose4(this.node, [new CheckNode(checks)]));
28158
28173
  }
28159
28174
  refine(refinement, annotations2) {
28160
- return make41(compose3(this.node, [new CheckNode([makeFilterByGuard(refinement, annotations2)])]));
28175
+ return make41(compose4(this.node, [new CheckNode([makeFilterByGuard(refinement, annotations2)])]));
28161
28176
  }
28162
28177
  tag(tag) {
28163
28178
  const err = fail2(new InvalidValue({
28164
28179
  expected: `${JSON.stringify(tag)} tag`
28165
28180
  }));
28166
- return make41(compose3(this.node, primitiveNode("Prism", (s) => s._tag === tag ? succeed2(s) : err, identity)));
28181
+ return make41(compose4(this.node, primitiveNode("Prism", (s) => s._tag === tag ? succeed2(s) : err, identity)));
28167
28182
  }
28168
28183
  at(key, ..._rest) {
28169
28184
  const err = fail2(new Pointer([key], new MissingKey(undefined)));
28170
- return make41(compose3(this.node, primitiveNode("Optional", (s) => Object.hasOwn(s, key) ? succeed2(s[key]) : err, (a, s) => {
28185
+ return make41(compose4(this.node, primitiveNode("Optional", (s) => Object.hasOwn(s, key) ? succeed2(s[key]) : err, (a, s) => {
28171
28186
  if (Object.hasOwn(s, key)) {
28172
28187
  const copy5 = cloneShallow(s);
28173
28188
  assignProperty(copy5, key, a);
@@ -28845,6 +28860,22 @@ var formatInet = (self) => {
28845
28860
  const host = formatHost(self);
28846
28861
  return isInetAddressV4(self) ? `${host}:${self.port}` : `[${host}]:${self.port}`;
28847
28862
  };
28863
+ var formatUrlHost = (self) => isIpv4Address(self) ? formatIp(self) : `[${formatIp(self)}]`;
28864
+ var toUrl = (self, scheme = "http") => {
28865
+ if (self._tag === "InetAddressV6" && self.scopeId !== 0) {
28866
+ return addressError(self, "scoped IPv6 addresses are not supported by WHATWG URLs");
28867
+ }
28868
+ return try_({
28869
+ try: () => new URL(`${scheme}://${isInetAddress(self) ? formatInet(self) : formatUrlHost(self)}`),
28870
+ catch: (cause) => new NetAddressError({
28871
+ input: self,
28872
+ message: "failed to construct URL",
28873
+ cause
28874
+ })
28875
+ });
28876
+ };
28877
+ var formatUrl = (self, scheme = "http") => isUnixPathAddress(self) ? succeed2(formatUnixPath(self)) : map2(toUrl(self, scheme), (url) => `${url.protocol}//${url.host}`);
28878
+ var formatUrlUnsafe = (self, scheme = "http") => getOrThrow2(formatUrl(self, scheme));
28848
28879
  var UnixPathProto = {
28849
28880
  ...BaseProto,
28850
28881
  _tag: "UnixPathAddress",
@@ -28867,6 +28898,7 @@ var unixPathAddress = (path) => {
28867
28898
  self.path = path;
28868
28899
  return Object.freeze(self);
28869
28900
  };
28901
+ var formatUnixPath = (self) => `unix://${self.path}`;
28870
28902
 
28871
28903
  // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/net/Host.js
28872
28904
  var TypeId43 = "~effect/net/Host";
@@ -33627,7 +33659,7 @@ function Array3(value3, pathOrOptions, options) {
33627
33659
  const separator = resolvedOptions?.separator ?? ",";
33628
33660
  const arrayString = String7.pipe(decodeTo2(toCodecStringTree2(array2), {
33629
33661
  decode: split3(resolvedOptions),
33630
- encode: compose2(passthrough2({
33662
+ encode: compose3(passthrough2({
33631
33663
  strict: false
33632
33664
  }), transform((input) => input.join(separator)))
33633
33665
  }));
@@ -33639,7 +33671,7 @@ function Record4(key, value3, pathOrOptions, options) {
33639
33671
  const split4 = splitKeyValue2(hasPath ? options : pathOrOptions);
33640
33672
  const recordString = String7.pipe(decodeTo2(toCodecStringTree2(record2), {
33641
33673
  decode: split4.decode,
33642
- encode: compose2(passthrough2({
33674
+ encode: compose3(passthrough2({
33643
33675
  strict: false
33644
33676
  }), split4.encode)
33645
33677
  }));
@@ -34801,7 +34833,7 @@ __export(exports_HttpClientRequest, {
34801
34833
  trace: () => trace2,
34802
34834
  toWebResult: () => toWebResult,
34803
34835
  toWeb: () => toWeb,
34804
- toUrl: () => toUrl,
34836
+ toUrl: () => toUrl2,
34805
34837
  setUrlParams: () => setUrlParams,
34806
34838
  setUrlParam: () => setUrlParam,
34807
34839
  setUrl: () => setUrl,
@@ -35028,7 +35060,7 @@ var bodyFormData = /* @__PURE__ */ dual(2, (self, body) => setBody(self, formDat
35028
35060
  var bodyFormDataRecord = /* @__PURE__ */ dual(2, (self, entries3) => setBody(self, formDataRecord(entries3)));
35029
35061
  var bodyStream = /* @__PURE__ */ dual((args2) => isHttpClientRequest(args2[0]), (self, body, options2) => setBody(self, stream(body, options2?.contentType, options2?.contentLength)));
35030
35062
  var bodyFile = /* @__PURE__ */ dual((args2) => isHttpClientRequest(args2[0]), (self, path, options2) => map9(file(path, options2), (body) => setBody(self, body)));
35031
- function toUrl(self) {
35063
+ function toUrl2(self) {
35032
35064
  const r = make50(self.url, self.urlParams, getOrUndefined(self.hash));
35033
35065
  if (isSuccess2(r)) {
35034
35066
  return some3(r.success);
@@ -35187,7 +35219,7 @@ class WebHttpClientResponse extends Class2 {
35187
35219
  get url() {
35188
35220
  if (this.source.url)
35189
35221
  return this.source.url.split("#")[0];
35190
- const url = toUrl(this.request);
35222
+ const url = toUrl2(this.request);
35191
35223
  if (isNone2(url))
35192
35224
  return "";
35193
35225
  url.value.hash = "";
@@ -35295,6 +35327,70 @@ var toHeaders = (span3) => fromRecordUnsafe({
35295
35327
  })}`,
35296
35328
  traceparent: `00-${span3.traceId}-${span3.spanId}-${span3.sampled ? "01" : "00"}`
35297
35329
  });
35330
+ var fromHeaders = (headers) => {
35331
+ let span3 = w3c(headers);
35332
+ if (isSome2(span3)) {
35333
+ return span3;
35334
+ }
35335
+ span3 = b3(headers);
35336
+ if (isSome2(span3)) {
35337
+ return span3;
35338
+ }
35339
+ return xb3(headers);
35340
+ };
35341
+ var b3 = (headers) => {
35342
+ if (!("b3" in headers)) {
35343
+ return none2();
35344
+ }
35345
+ const parts2 = headers["b3"].split("-");
35346
+ if (parts2.length < 2 || isB3Ids(parts2[0], parts2[1]) === false) {
35347
+ return none2();
35348
+ }
35349
+ return some3(externalSpan({
35350
+ traceId: parts2[0],
35351
+ spanId: parts2[1],
35352
+ sampled: parts2[2] ? parts2[2] === "1" || parts2[2] === "d" : true
35353
+ }));
35354
+ };
35355
+ var xb3 = (headers) => {
35356
+ if (!headers["x-b3-traceid"] || !headers["x-b3-spanid"] || isB3Ids(headers["x-b3-traceid"], headers["x-b3-spanid"]) === false) {
35357
+ return none2();
35358
+ }
35359
+ return some3(externalSpan({
35360
+ traceId: headers["x-b3-traceid"],
35361
+ spanId: headers["x-b3-spanid"],
35362
+ sampled: headers["x-b3-flags"] === "1" || (headers["x-b3-sampled"] ? headers["x-b3-sampled"] === "1" || headers["x-b3-sampled"] === "true" : true)
35363
+ }));
35364
+ };
35365
+ var w3cTraceId = /^[0-9a-f]{32}$/i;
35366
+ var w3cSpanId = /^[0-9a-f]{16}$/i;
35367
+ var b3TraceId = /^(?:[0-9a-f]{16}|[0-9a-f]{32})$/i;
35368
+ var isB3Ids = (traceId, spanId) => b3TraceId.test(traceId) && w3cSpanId.test(spanId);
35369
+ var w3c = (headers) => {
35370
+ if (!headers["traceparent"]) {
35371
+ return none2();
35372
+ }
35373
+ const parts2 = headers["traceparent"].split("-");
35374
+ if (parts2.length !== 4) {
35375
+ return none2();
35376
+ }
35377
+ const [version, traceId, spanId, flags] = parts2;
35378
+ switch (version) {
35379
+ case "00": {
35380
+ if (w3cTraceId.test(traceId) === false || w3cSpanId.test(spanId) === false || traceId === "00000000000000000000000000000000" || spanId === "0000000000000000") {
35381
+ return none2();
35382
+ }
35383
+ return some3(externalSpan({
35384
+ traceId,
35385
+ spanId,
35386
+ sampled: (parseInt(flags, 16) & 1) === 1
35387
+ }));
35388
+ }
35389
+ default: {
35390
+ return none2();
35391
+ }
35392
+ }
35393
+ };
35298
35394
 
35299
35395
  // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/http/internal/tracing.js
35300
35396
  var defaultPorts = {
@@ -35909,155 +36005,859 @@ var fetch = /* @__PURE__ */ make52((request3, url, signal, fiber3) => {
35909
36005
  return send(undefined);
35910
36006
  });
35911
36007
  var layer14 = /* @__PURE__ */ layerMergedContext(/* @__PURE__ */ succeed6(fetch));
35912
- // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/http/HttpServerRequest.js
35913
- var exports_HttpServerRequest = {};
35914
- __export(exports_HttpServerRequest, {
35915
- upgradeChannel: () => upgradeChannel,
35916
- toWebResult: () => toWebResult2,
35917
- toWeb: () => toWeb3,
35918
- toURL: () => toURL,
35919
- toClientRequest: () => toClientRequest,
35920
- searchParamsFromURL: () => searchParamsFromURL,
35921
- schemaSearchParams: () => schemaSearchParams,
35922
- schemaHeaders: () => schemaHeaders,
35923
- schemaCookies: () => schemaCookies,
35924
- schemaBodyUrlParams: () => schemaBodyUrlParams2,
35925
- schemaBodyMultipart: () => schemaBodyMultipart,
35926
- schemaBodyJson: () => schemaBodyJson3,
35927
- schemaBodyFormJson: () => schemaBodyFormJson,
35928
- schemaBodyForm: () => schemaBodyForm,
35929
- fromWeb: () => fromWeb4,
35930
- fromClientRequest: () => fromClientRequest,
35931
- TypeId: () => TypeId60,
35932
- ParsedSearchParams: () => ParsedSearchParams,
35933
- MaxBodySize: () => MaxBodySize,
35934
- HttpServerRequest: () => HttpServerRequest
35935
- });
35936
-
35937
- // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/socket/Socket.js
35938
- var encoder5 = /* @__PURE__ */ new TextEncoder;
35939
- var readerBytes = (self) => map9(self.reader, ({
35940
- pull
35941
- }) => map9(pull, (chunk) => {
35942
- for (let i = 0;i < chunk.length; i++) {
35943
- if (typeof chunk[i] === "string") {
35944
- const out = new Array(chunk.length);
35945
- for (let j = 0;j < chunk.length; j++) {
35946
- const item = chunk[j];
35947
- out[j] = typeof item === "string" ? encoder5.encode(item) : item;
36008
+ // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/http/HttpRouter.js
36009
+ var exports_HttpRouter = {};
36010
+ __export(exports_HttpRouter, {
36011
+ use: () => use,
36012
+ toWebHandler: () => toWebHandler,
36013
+ toHttpEffect: () => toHttpEffect,
36014
+ serve: () => serve2,
36015
+ schemaPathParams: () => schemaPathParams,
36016
+ schemaParams: () => schemaParams,
36017
+ schemaNoBody: () => schemaNoBody,
36018
+ schemaJson: () => schemaJson3,
36019
+ route: () => route,
36020
+ provideRequest: () => provideRequest,
36021
+ prefixRoute: () => prefixRoute,
36022
+ prefixPath: () => prefixPath,
36023
+ params: () => params,
36024
+ middleware: () => middleware,
36025
+ make: () => make61,
36026
+ layer: () => layer15,
36027
+ disableLogger: () => disableLogger,
36028
+ cors: () => cors2,
36029
+ addAll: () => addAll,
36030
+ add: () => add5,
36031
+ RouterConfig: () => RouterConfig,
36032
+ RouteContext: () => RouteContext,
36033
+ HttpRouter: () => HttpRouter
36034
+ });
36035
+
36036
+ // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/http/FindMyWay/internal/queryString.js
36037
+ var plusRegex = /\+/g;
36038
+ var Empty3 = function() {};
36039
+ Empty3.prototype = /* @__PURE__ */ Object.create(null);
36040
+ function parse2(input) {
36041
+ const result6 = new Empty3;
36042
+ if (typeof input !== "string") {
36043
+ return result6;
36044
+ }
36045
+ const inputLength = input.length;
36046
+ let key = "";
36047
+ let value5 = "";
36048
+ let startingIndex = -1;
36049
+ let equalityIndex = -1;
36050
+ let shouldDecodeKey = false;
36051
+ let shouldDecodeValue = false;
36052
+ let keyHasPlus = false;
36053
+ let valueHasPlus = false;
36054
+ let hasBothKeyValuePair = false;
36055
+ let c = 0;
36056
+ for (let i = 0;i < inputLength + 1; i++) {
36057
+ c = i !== inputLength ? input.charCodeAt(i) : 38;
36058
+ if (c === 38) {
36059
+ hasBothKeyValuePair = equalityIndex > startingIndex;
36060
+ if (!hasBothKeyValuePair) {
36061
+ equalityIndex = i;
36062
+ }
36063
+ key = input.slice(startingIndex + 1, equalityIndex);
36064
+ if (hasBothKeyValuePair || key.length > 0) {
36065
+ if (keyHasPlus) {
36066
+ key = key.replace(plusRegex, " ");
36067
+ }
36068
+ if (shouldDecodeKey) {
36069
+ try {
36070
+ key = decodeURIComponent(key) || key;
36071
+ } catch {}
36072
+ }
36073
+ if (hasBothKeyValuePair) {
36074
+ value5 = input.slice(equalityIndex + 1, i);
36075
+ if (valueHasPlus) {
36076
+ value5 = value5.replace(plusRegex, " ");
36077
+ }
36078
+ if (shouldDecodeValue) {
36079
+ try {
36080
+ value5 = decodeURIComponent(value5) || value5;
36081
+ } catch {}
36082
+ }
36083
+ }
36084
+ const currentValue = result6[key];
36085
+ if (currentValue === undefined) {
36086
+ result6[key] = value5;
36087
+ } else {
36088
+ if (currentValue.pop) {
36089
+ currentValue.push(value5);
36090
+ } else {
36091
+ result6[key] = [currentValue, value5];
36092
+ }
36093
+ }
36094
+ }
36095
+ value5 = "";
36096
+ startingIndex = i;
36097
+ equalityIndex = i;
36098
+ shouldDecodeKey = false;
36099
+ shouldDecodeValue = false;
36100
+ keyHasPlus = false;
36101
+ valueHasPlus = false;
36102
+ } else if (c === 61) {
36103
+ if (equalityIndex <= startingIndex) {
36104
+ equalityIndex = i;
36105
+ } else {
36106
+ shouldDecodeValue = true;
36107
+ }
36108
+ } else if (c === 43) {
36109
+ if (equalityIndex > startingIndex) {
36110
+ valueHasPlus = true;
36111
+ } else {
36112
+ keyHasPlus = true;
36113
+ }
36114
+ } else if (c === 37) {
36115
+ if (equalityIndex > startingIndex) {
36116
+ shouldDecodeValue = true;
36117
+ } else {
36118
+ shouldDecodeKey = true;
35948
36119
  }
35949
- return out;
35950
36120
  }
35951
36121
  }
35952
- return chunk;
35953
- }));
35954
- var CloseEventTypeId = "~effect/socket/Socket/CloseEvent";
35955
- var isCloseEvent = (u) => hasProperty(u, CloseEventTypeId);
35956
- var SocketErrorTypeId = "~effect/socket/Socket/SocketError";
35957
- var isSocketError = (u) => hasProperty(u, SocketErrorTypeId);
35958
-
35959
- class SocketReadError extends (/* @__PURE__ */ Error4("effect/socket/Socket/SocketReadError")({
35960
- _tag: /* @__PURE__ */ tag("SocketReadError"),
35961
- cause: /* @__PURE__ */ Defect()
35962
- })) {
35963
- message = `An error occurred during Read`;
36122
+ return result6;
35964
36123
  }
35965
36124
 
35966
- class SocketWriteError extends (/* @__PURE__ */ Error4("effect/socket/Socket/SocketWriteError")({
35967
- _tag: /* @__PURE__ */ tag("SocketWriteError"),
35968
- cause: /* @__PURE__ */ Defect()
35969
- })) {
35970
- message = `An error occurred during Write`;
36125
+ // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/http/FindMyWay/internal/router.js
36126
+ var FULL_PATH_REGEXP = /^https?:\/\/.*?\//;
36127
+ var OPTIONAL_PARAM_REGEXP = /(\/:[^/()]*?)\?(\/?)/;
36128
+ var emptyParamsArray = [];
36129
+ var CLEAN_SINGLE_PARAM_REGEXP = /^[^:*(]*\/:[^/:*(.-]+$/;
36130
+ var isCleanSingleTrailingParam = (path) => CLEAN_SINGLE_PARAM_REGEXP.test(path);
36131
+ var make53 = (options3 = {}) => new RouterImpl(options3);
36132
+
36133
+ class RouterImpl {
36134
+ constructor(options3 = {}) {
36135
+ this.options = {
36136
+ ignoreTrailingSlash: true,
36137
+ ignoreDuplicateSlashes: true,
36138
+ caseSensitive: false,
36139
+ maxParamLength: 100,
36140
+ ...options3
36141
+ };
36142
+ }
36143
+ options;
36144
+ routes = [];
36145
+ trees = /* @__PURE__ */ Object.create(null);
36146
+ staticRoutes = /* @__PURE__ */ Object.create(null);
36147
+ singleParamRoutes = /* @__PURE__ */ Object.create(null);
36148
+ singleParamDisabled = /* @__PURE__ */ Object.create(null);
36149
+ brothersNodesStack = [];
36150
+ singleParamArray = [""];
36151
+ on(method, path, handler) {
36152
+ const optionalParamMatch = path.match(OPTIONAL_PARAM_REGEXP);
36153
+ if (optionalParamMatch && optionalParamMatch.index !== undefined) {
36154
+ assert2(path.length === optionalParamMatch.index + optionalParamMatch[0].length, "Optional Parameter needs to be the last parameter of the path");
36155
+ const pathFull = path.replace(OPTIONAL_PARAM_REGEXP, "$1$2");
36156
+ const pathOptional = path.replace(OPTIONAL_PARAM_REGEXP, "$2") || "/";
36157
+ this.on(method, pathFull, handler);
36158
+ this.on(method, pathOptional, handler);
36159
+ return;
36160
+ }
36161
+ if (this.options.ignoreDuplicateSlashes) {
36162
+ path = removeDuplicateSlashes(path);
36163
+ }
36164
+ if (this.options.ignoreTrailingSlash) {
36165
+ path = trimLastSlash(path);
36166
+ }
36167
+ const methods = typeof method === "string" ? [method] : method;
36168
+ for (const method2 of methods) {
36169
+ this._on(method2, path, handler);
36170
+ }
36171
+ }
36172
+ all(path, handler) {
36173
+ this.on(httpMethods, path, handler);
36174
+ }
36175
+ _on(method, path, handler) {
36176
+ if (this.trees[method] === undefined) {
36177
+ this.trees[method] = new StaticNode("/");
36178
+ }
36179
+ let pattern = path;
36180
+ if (pattern === "*" && this.trees[method].prefix.length !== 0) {
36181
+ const currentRoot = this.trees[method];
36182
+ this.trees[method] = new StaticNode("");
36183
+ this.trees[method].staticChildren["/"] = currentRoot;
36184
+ }
36185
+ let parentNodePathIndex = this.trees[method].prefix.length;
36186
+ let currentNode = this.trees[method];
36187
+ const params = [];
36188
+ for (let i = 0;i <= pattern.length; i++) {
36189
+ if (pattern.charCodeAt(i) === 58 && pattern.charCodeAt(i + 1) === 58) {
36190
+ i++;
36191
+ continue;
36192
+ }
36193
+ const isParametricNode = pattern.charCodeAt(i) === 58 && pattern.charCodeAt(i + 1) !== 58;
36194
+ const isWildcardNode = pattern.charCodeAt(i) === 42;
36195
+ if (isParametricNode || isWildcardNode || i === pattern.length && i !== parentNodePathIndex) {
36196
+ let staticNodePath = pattern.slice(parentNodePathIndex, i);
36197
+ if (!this.options.caseSensitive) {
36198
+ staticNodePath = staticNodePath.toLowerCase();
36199
+ }
36200
+ staticNodePath = staticNodePath.split("::").join(":");
36201
+ staticNodePath = staticNodePath.split("%").join("%25");
36202
+ currentNode = currentNode.createStaticChild(staticNodePath);
36203
+ }
36204
+ if (isParametricNode) {
36205
+ let isRegexNode = false;
36206
+ let isParamSafe = true;
36207
+ let backtrack = "";
36208
+ const regexps = [];
36209
+ let nodePatternParts = "";
36210
+ let lastParamStartIndex = i + 1;
36211
+ for (let j = lastParamStartIndex;; j++) {
36212
+ const charCode = pattern.charCodeAt(j);
36213
+ const isRegexParam = charCode === 40;
36214
+ const isStaticPart = charCode === 45 || charCode === 46;
36215
+ const isEndOfNode = charCode === 47 || j === pattern.length;
36216
+ if (isRegexParam || isStaticPart || isEndOfNode) {
36217
+ const paramName = pattern.slice(lastParamStartIndex, j);
36218
+ params.push(paramName);
36219
+ isRegexNode = isRegexNode || isRegexParam || isStaticPart;
36220
+ if (isRegexParam) {
36221
+ const endOfRegexIndex = getClosingParenthensePosition(pattern, j);
36222
+ const regexString = pattern.slice(j, endOfRegexIndex + 1);
36223
+ regexps.push(trimRegExpStartAndEnd(regexString));
36224
+ j = endOfRegexIndex + 1;
36225
+ isParamSafe = true;
36226
+ } else {
36227
+ regexps.push(isParamSafe ? "(.*?)" : `(${backtrack}|(?:(?!${backtrack}).)*)`);
36228
+ isParamSafe = false;
36229
+ }
36230
+ const staticPartStartIndex = j;
36231
+ for (;j < pattern.length; j++) {
36232
+ const charCode2 = pattern.charCodeAt(j);
36233
+ if (charCode2 === 47)
36234
+ break;
36235
+ if (charCode2 === 58) {
36236
+ const nextCharCode = pattern.charCodeAt(j + 1);
36237
+ if (nextCharCode === 58)
36238
+ j++;
36239
+ else
36240
+ break;
36241
+ }
36242
+ }
36243
+ let staticPart = pattern.slice(staticPartStartIndex, j);
36244
+ if (staticPart) {
36245
+ staticPart = staticPart.split("::").join(":");
36246
+ staticPart = staticPart.split("%").join("%25");
36247
+ regexps.push(backtrack = escapeRegExp(staticPart));
36248
+ }
36249
+ lastParamStartIndex = j + 1;
36250
+ nodePatternParts += "()" + staticPart;
36251
+ if (isEndOfNode || pattern.charCodeAt(j) === 47 || j === pattern.length) {
36252
+ const nodePattern = isRegexNode ? nodePatternParts : staticPart;
36253
+ const nodePath = pattern.slice(i, j);
36254
+ pattern = pattern.slice(0, i + 1) + nodePattern + pattern.slice(j);
36255
+ i += nodePattern.length;
36256
+ const regex = isRegexNode ? new RegExp("^" + regexps.join("") + "$") : undefined;
36257
+ currentNode = currentNode.createParametricChild(regex, staticPart, nodePath);
36258
+ parentNodePathIndex = i + 1;
36259
+ break;
36260
+ }
36261
+ }
36262
+ }
36263
+ } else if (isWildcardNode) {
36264
+ params.push("*");
36265
+ currentNode = currentNode.createWildcardChild();
36266
+ parentNodePathIndex = i + 1;
36267
+ if (i !== pattern.length - 1) {
36268
+ throw new Error("Wildcard must be the last character in the route");
36269
+ }
36270
+ }
36271
+ }
36272
+ if (!this.options.caseSensitive) {
36273
+ pattern = pattern.toLowerCase();
36274
+ }
36275
+ if (pattern === "*") {
36276
+ pattern = "/*";
36277
+ }
36278
+ for (const existRoute of this.routes) {
36279
+ if (existRoute.method === method && existRoute.pattern === pattern) {
36280
+ throw new Error(`Method '${method}' already declared for route '${pattern}'`);
36281
+ }
36282
+ }
36283
+ const route = {
36284
+ method,
36285
+ path,
36286
+ pattern,
36287
+ params,
36288
+ handler
36289
+ };
36290
+ this.routes.push(route);
36291
+ currentNode.addRoute(route);
36292
+ if (params.length === 0) {
36293
+ const staticKey = pattern.split("::").join(":").split("%").join("%25");
36294
+ const store = this.staticRoutes[method] ??= new Map;
36295
+ if (!store.has(staticKey)) {
36296
+ store.set(staticKey, currentNode.handlerStorage.unconstrainedHandler);
36297
+ }
36298
+ } else if (isCleanSingleTrailingParam(path)) {
36299
+ if (this.singleParamDisabled[method] !== true) {
36300
+ let prefix3 = path.slice(0, path.indexOf(":"));
36301
+ if (!this.options.caseSensitive) {
36302
+ prefix3 = prefix3.toLowerCase();
36303
+ }
36304
+ prefix3 = prefix3.split("%").join("%25");
36305
+ const store = this.singleParamRoutes[method] ??= new Map;
36306
+ if (!store.has(prefix3)) {
36307
+ store.set(prefix3, currentNode.handlerStorage.unconstrainedHandler);
36308
+ }
36309
+ }
36310
+ } else if (/[(*]|[^/]:|:[^/]*[-.]/.test(path)) {
36311
+ this.singleParamDisabled[method] = true;
36312
+ delete this.singleParamRoutes[method];
36313
+ }
36314
+ }
36315
+ has(method, path) {
36316
+ const node = this.trees[method];
36317
+ if (node === undefined) {
36318
+ return false;
36319
+ }
36320
+ const staticNode = node.getStaticChild(path);
36321
+ if (staticNode === undefined) {
36322
+ return false;
36323
+ }
36324
+ return staticNode.isLeafNode;
36325
+ }
36326
+ find(method, path) {
36327
+ let currentNode = this.trees[method];
36328
+ if (currentNode === undefined)
36329
+ return;
36330
+ let querystring = "";
36331
+ let shouldDecodeParam = false;
36332
+ let clean = path.charCodeAt(0) === 47 && (path.length === 1 || path.charCodeAt(path.length - 1) !== 47);
36333
+ if (clean) {
36334
+ for (let i = 1;i < path.length; i++) {
36335
+ const code = path.charCodeAt(i);
36336
+ if (code === 37 || code === 63 || code === 59 || code === 35 || code >= 65 && code <= 90 || code === 47 && path.charCodeAt(i - 1) === 47) {
36337
+ clean = false;
36338
+ break;
36339
+ }
36340
+ }
36341
+ }
36342
+ if (!clean) {
36343
+ if (path.charCodeAt(0) !== 47) {
36344
+ path = path.replace(FULL_PATH_REGEXP, "/");
36345
+ }
36346
+ let sanitizedUrl;
36347
+ try {
36348
+ sanitizedUrl = safeDecodeURI(path);
36349
+ path = sanitizedUrl.path;
36350
+ querystring = sanitizedUrl.querystring;
36351
+ shouldDecodeParam = sanitizedUrl.shouldDecodeParam;
36352
+ } catch (error2) {
36353
+ return;
36354
+ }
36355
+ if (this.options.ignoreDuplicateSlashes) {
36356
+ path = removeDuplicateSlashes(path);
36357
+ }
36358
+ if (this.options.ignoreTrailingSlash) {
36359
+ path = trimLastSlash(path);
36360
+ }
36361
+ }
36362
+ const originPath = path;
36363
+ if (!clean && this.options.caseSensitive === false) {
36364
+ path = path.toLowerCase();
36365
+ }
36366
+ const maxParamLength = this.options.maxParamLength;
36367
+ const staticStore = this.staticRoutes[method];
36368
+ if (staticStore !== undefined) {
36369
+ const handle = staticStore.get(path);
36370
+ if (handle !== undefined) {
36371
+ return {
36372
+ handler: handle.handler,
36373
+ params: handle.createParams(emptyParamsArray),
36374
+ searchParams: parse2(querystring)
36375
+ };
36376
+ }
36377
+ }
36378
+ const singleParamStore = this.singleParamRoutes[method];
36379
+ if (singleParamStore !== undefined) {
36380
+ const prefixLength = path.lastIndexOf("/") + 1;
36381
+ const handle = singleParamStore.get(path.slice(0, prefixLength));
36382
+ if (handle !== undefined && path.length > prefixLength) {
36383
+ let param = originPath.slice(prefixLength);
36384
+ if (shouldDecodeParam) {
36385
+ param = safeDecodeURIComponent(param);
36386
+ }
36387
+ if (param.length <= maxParamLength) {
36388
+ this.singleParamArray[0] = param;
36389
+ return {
36390
+ handler: handle.handler,
36391
+ params: handle.createParams(this.singleParamArray),
36392
+ searchParams: parse2(querystring)
36393
+ };
36394
+ }
36395
+ }
36396
+ }
36397
+ let pathIndex = currentNode.prefix.length;
36398
+ const params = [];
36399
+ const pathLen = path.length;
36400
+ const brothersNodesStack = this.brothersNodesStack;
36401
+ brothersNodesStack.length = 0;
36402
+ while (true) {
36403
+ if (pathIndex === pathLen && currentNode.isLeafNode) {
36404
+ const handle = currentNode.handlerStorage?.find();
36405
+ if (handle !== undefined) {
36406
+ return {
36407
+ handler: handle.handler,
36408
+ params: handle.createParams(params),
36409
+ searchParams: parse2(querystring)
36410
+ };
36411
+ }
36412
+ }
36413
+ let node = currentNode.getNextNode(path, pathIndex, brothersNodesStack, params.length);
36414
+ if (node === undefined) {
36415
+ if (brothersNodesStack.length === 0) {
36416
+ return;
36417
+ }
36418
+ const brotherNodeState = brothersNodesStack.pop();
36419
+ pathIndex = brotherNodeState.brotherPathIndex;
36420
+ params.splice(brotherNodeState.paramsCount);
36421
+ node = brotherNodeState.brotherNode;
36422
+ }
36423
+ currentNode = node;
36424
+ while (true) {
36425
+ if (currentNode._tag === "StaticNode") {
36426
+ pathIndex += currentNode.prefix.length;
36427
+ break;
36428
+ }
36429
+ if (currentNode._tag === "WildcardNode") {
36430
+ let param2 = originPath.slice(pathIndex);
36431
+ if (shouldDecodeParam) {
36432
+ param2 = safeDecodeURIComponent(param2);
36433
+ }
36434
+ params.push(param2);
36435
+ pathIndex = pathLen;
36436
+ break;
36437
+ }
36438
+ let paramEndIndex = originPath.indexOf("/", pathIndex);
36439
+ if (paramEndIndex === -1) {
36440
+ paramEndIndex = pathLen;
36441
+ }
36442
+ let param = originPath.slice(pathIndex, paramEndIndex);
36443
+ if (shouldDecodeParam) {
36444
+ param = safeDecodeURIComponent(param);
36445
+ }
36446
+ if (currentNode.regex !== undefined) {
36447
+ const matchedParameters = currentNode.regex.exec(param);
36448
+ if (matchedParameters === null) {
36449
+ if (brothersNodesStack.length === 0) {
36450
+ return;
36451
+ }
36452
+ const brotherNodeState = brothersNodesStack.pop();
36453
+ pathIndex = brotherNodeState.brotherPathIndex;
36454
+ params.splice(brotherNodeState.paramsCount);
36455
+ currentNode = brotherNodeState.brotherNode;
36456
+ continue;
36457
+ }
36458
+ let maxParamLengthExceeded = false;
36459
+ for (let i = 1;i < matchedParameters.length; i++) {
36460
+ const matchedParam = matchedParameters[i] ?? "";
36461
+ if (matchedParam.length > maxParamLength) {
36462
+ maxParamLengthExceeded = true;
36463
+ break;
36464
+ }
36465
+ }
36466
+ if (maxParamLengthExceeded) {
36467
+ if (brothersNodesStack.length === 0) {
36468
+ return;
36469
+ }
36470
+ const brotherNodeState = brothersNodesStack.pop();
36471
+ pathIndex = brotherNodeState.brotherPathIndex;
36472
+ params.splice(brotherNodeState.paramsCount);
36473
+ currentNode = brotherNodeState.brotherNode;
36474
+ continue;
36475
+ }
36476
+ for (let i = 1;i < matchedParameters.length; i++) {
36477
+ params.push(matchedParameters[i] ?? "");
36478
+ }
36479
+ } else {
36480
+ if (param.length > maxParamLength) {
36481
+ if (brothersNodesStack.length === 0) {
36482
+ return;
36483
+ }
36484
+ const brotherNodeState = brothersNodesStack.pop();
36485
+ pathIndex = brotherNodeState.brotherPathIndex;
36486
+ params.splice(brotherNodeState.paramsCount);
36487
+ currentNode = brotherNodeState.brotherNode;
36488
+ continue;
36489
+ }
36490
+ params.push(param);
36491
+ }
36492
+ pathIndex = paramEndIndex;
36493
+ break;
36494
+ }
36495
+ }
36496
+ }
35971
36497
  }
35972
36498
 
35973
- class SocketOpenError extends (/* @__PURE__ */ Error4("effect/socket/Socket/SocketOpenError")({
35974
- _tag: /* @__PURE__ */ tag("SocketOpenError"),
35975
- kind: /* @__PURE__ */ Literals(["Unknown", "Timeout"]),
35976
- cause: /* @__PURE__ */ Defect()
35977
- })) {
35978
- get message() {
35979
- return this.kind === "Timeout" ? `timeout waiting for "open"` : `An error occurred during Open`;
36499
+ class HandlerStorage {
36500
+ handlers = [];
36501
+ unconstrainedHandler;
36502
+ find() {
36503
+ return this.unconstrainedHandler;
36504
+ }
36505
+ add(route) {
36506
+ const handler = {
36507
+ params: route.params,
36508
+ handler: route.handler,
36509
+ createParams: makeCreateParams(route.params)
36510
+ };
36511
+ this.handlers.push(handler);
36512
+ this.unconstrainedHandler = this.handlers[0];
35980
36513
  }
35981
36514
  }
35982
36515
 
35983
- class SocketUpgradeError extends (/* @__PURE__ */ Error4("effect/socket/Socket/SocketUpgradeError")({
35984
- _tag: /* @__PURE__ */ tag("SocketUpgradeError"),
35985
- cause: /* @__PURE__ */ optional2(/* @__PURE__ */ Defect())
35986
- })) {
35987
- static unsupported = () => fail6(new SocketError({
35988
- reason: new SocketUpgradeError({})
35989
- }));
35990
- get message() {
35991
- return this.cause === undefined ? `Socket does not support TLS upgrade` : `An error occurred during TLS upgrade`;
36516
+ class NodeBase {
36517
+ isLeafNode = false;
36518
+ routes;
36519
+ handlerStorage;
36520
+ addRoute(route) {
36521
+ if (this.routes === undefined) {
36522
+ this.routes = [route];
36523
+ } else {
36524
+ this.routes.push(route);
36525
+ }
36526
+ if (this.handlerStorage === undefined) {
36527
+ this.handlerStorage = new HandlerStorage;
36528
+ }
36529
+ this.isLeafNode = true;
36530
+ this.handlerStorage.add(route);
35992
36531
  }
35993
36532
  }
35994
36533
 
35995
- class SocketCloseError extends (/* @__PURE__ */ Error4("effect/socket/Socket/SocketCloseError")({
35996
- _tag: /* @__PURE__ */ tag("SocketCloseError"),
35997
- code: Int,
35998
- closeReason: /* @__PURE__ */ optional2(String7)
35999
- })) {
36000
- get message() {
36001
- if (this.closeReason) {
36002
- return `${this.code}: ${this.closeReason}`;
36534
+ class ParentNode extends NodeBase {
36535
+ staticChildren = /* @__PURE__ */ Object.create(null);
36536
+ findStaticMatchingChild(path, pathIndex) {
36537
+ const staticChild = this.staticChildren[path.charAt(pathIndex)];
36538
+ if (staticChild === undefined || !staticChild.matchPrefix(path, pathIndex)) {
36539
+ return;
36003
36540
  }
36004
- return `${this.code}`;
36541
+ return staticChild;
36542
+ }
36543
+ getStaticChild(path, pathIndex = 0) {
36544
+ if (path.length === pathIndex) {
36545
+ return this;
36546
+ }
36547
+ const staticChild = this.findStaticMatchingChild(path, pathIndex);
36548
+ if (staticChild === undefined) {
36549
+ return;
36550
+ }
36551
+ return staticChild.getStaticChild(path, pathIndex + staticChild.prefix.length);
36552
+ }
36553
+ createStaticChild(path) {
36554
+ if (path.length === 0) {
36555
+ return this;
36556
+ }
36557
+ let staticChild = this.staticChildren[path.charAt(0)];
36558
+ if (staticChild) {
36559
+ let i = 1;
36560
+ for (;i < staticChild.prefix.length; i++) {
36561
+ if (path.charCodeAt(i) !== staticChild.prefix.charCodeAt(i)) {
36562
+ staticChild = staticChild.split(this, i);
36563
+ break;
36564
+ }
36565
+ }
36566
+ return staticChild.createStaticChild(path.slice(i));
36567
+ }
36568
+ const label = path.charAt(0);
36569
+ this.staticChildren[label] = new StaticNode(path);
36570
+ return this.staticChildren[label];
36005
36571
  }
36006
36572
  }
36007
- var SocketErrorReason = /* @__PURE__ */ Union2([SocketReadError, SocketWriteError, SocketOpenError, SocketUpgradeError, SocketCloseError]);
36008
36573
 
36009
- class SocketError extends (/* @__PURE__ */ TaggedError3(SocketErrorTypeId)("SocketError", {
36010
- _tag: /* @__PURE__ */ tag("SocketError"),
36011
- reason: SocketErrorReason
36012
- })) {
36013
- constructor(props) {
36014
- if ("cause" in props.reason) {
36015
- super({
36016
- ...props,
36017
- cause: props.reason.cause
36018
- });
36574
+ class StaticNode extends ParentNode {
36575
+ _tag = "StaticNode";
36576
+ constructor(prefix3) {
36577
+ super();
36578
+ this.setPrefix(prefix3);
36579
+ }
36580
+ prefix;
36581
+ matchPrefix;
36582
+ parametricChildren = [];
36583
+ wildcardChild;
36584
+ setPrefix(prefix3) {
36585
+ this.prefix = prefix3;
36586
+ if (prefix3.length === 1) {
36587
+ this.matchPrefix = (_path, _pathIndex) => true;
36019
36588
  } else {
36020
- super(props);
36589
+ const tail2 = prefix3.slice(1);
36590
+ this.matchPrefix = (path, pathIndex) => path.startsWith(tail2, pathIndex + 1);
36021
36591
  }
36022
36592
  }
36023
- [SocketErrorTypeId] = SocketErrorTypeId;
36024
- static is(u) {
36025
- return isSocketError(u);
36593
+ getParametricChild(regex) {
36594
+ if (regex === undefined) {
36595
+ return this.parametricChildren.find((child) => child.isRegex === false);
36596
+ }
36597
+ const source = regex.source;
36598
+ return this.parametricChildren.find((child) => {
36599
+ if (child.regex === undefined) {
36600
+ return false;
36601
+ }
36602
+ return child.regex.source === source;
36603
+ });
36026
36604
  }
36027
- message = this.reason.message;
36028
- }
36029
- var writeChunk = (writer, chunk) => {
36030
- for (let i = 0;i < chunk.length; i++) {
36031
- if (isCloseEvent(chunk[i])) {
36032
- return gen4(function* () {
36033
- for (let index2 = 0;index2 <= i; index2++) {
36034
- yield* writer.write(chunk[index2]);
36035
- }
36605
+ createParametricChild(regex, staticSuffix, nodePath) {
36606
+ let child = this.getParametricChild(regex);
36607
+ if (child !== undefined) {
36608
+ child.nodePaths.add(nodePath);
36609
+ return child;
36610
+ }
36611
+ child = new ParametricNode(regex, staticSuffix, nodePath);
36612
+ this.parametricChildren.push(child);
36613
+ this.parametricChildren.sort((child1, child2) => {
36614
+ if (!child1.isRegex)
36615
+ return 1;
36616
+ if (!child2.isRegex)
36617
+ return -1;
36618
+ if (child1.staticSuffix === undefined)
36619
+ return 1;
36620
+ if (child2.staticSuffix === undefined)
36621
+ return -1;
36622
+ if (child2.staticSuffix.endsWith(child1.staticSuffix))
36623
+ return 1;
36624
+ if (child1.staticSuffix.endsWith(child2.staticSuffix))
36625
+ return -1;
36626
+ return 0;
36627
+ });
36628
+ return child;
36629
+ }
36630
+ createWildcardChild() {
36631
+ if (this.wildcardChild === undefined) {
36632
+ this.wildcardChild = new WildcardNode;
36633
+ }
36634
+ return this.wildcardChild;
36635
+ }
36636
+ split(parentNode, length2) {
36637
+ const parentPrefix = this.prefix.slice(0, length2);
36638
+ const childPrefix = this.prefix.slice(length2);
36639
+ this.setPrefix(childPrefix);
36640
+ const staticNode = new StaticNode(parentPrefix);
36641
+ staticNode.staticChildren[childPrefix.charAt(0)] = this;
36642
+ parentNode.staticChildren[parentPrefix.charAt(0)] = staticNode;
36643
+ return staticNode;
36644
+ }
36645
+ getNextNode(path, pathIndex, nodeStack, paramsCount) {
36646
+ let node = this.findStaticMatchingChild(path, pathIndex);
36647
+ let parametricBrotherNodeIndex = 0;
36648
+ if (node === undefined) {
36649
+ if (this.parametricChildren.length === 0) {
36650
+ return this.wildcardChild;
36651
+ }
36652
+ node = this.parametricChildren[0];
36653
+ parametricBrotherNodeIndex = 1;
36654
+ }
36655
+ if (this.wildcardChild !== undefined) {
36656
+ nodeStack.push({
36657
+ paramsCount,
36658
+ brotherPathIndex: pathIndex,
36659
+ brotherNode: this.wildcardChild
36036
36660
  });
36037
36661
  }
36662
+ for (let i = this.parametricChildren.length - 1;i >= parametricBrotherNodeIndex; i--) {
36663
+ nodeStack.push({
36664
+ paramsCount,
36665
+ brotherPathIndex: pathIndex,
36666
+ brotherNode: this.parametricChildren[i]
36667
+ });
36668
+ }
36669
+ return node;
36670
+ }
36671
+ }
36672
+
36673
+ class ParametricNode extends ParentNode {
36674
+ _tag = "ParametricNode";
36675
+ regex;
36676
+ staticSuffix;
36677
+ constructor(regex, staticSuffix, nodePath) {
36678
+ super();
36679
+ this.regex = regex;
36680
+ this.staticSuffix = staticSuffix;
36681
+ this.isRegex = !!regex;
36682
+ this.nodePaths = new Set([nodePath]);
36683
+ }
36684
+ isRegex;
36685
+ nodePaths;
36686
+ getNextNode(path, pathIndex) {
36687
+ return this.findStaticMatchingChild(path, pathIndex);
36688
+ }
36689
+ }
36690
+
36691
+ class WildcardNode extends NodeBase {
36692
+ _tag = "WildcardNode";
36693
+ getNextNode(_path, _pathIndex, _nodeStack, _paramsCount) {
36694
+ return;
36695
+ }
36696
+ }
36697
+ var assert2 = (condition, message) => {
36698
+ if (!condition) {
36699
+ throw new Error(message);
36038
36700
  }
36039
- return writer.writeAll(chunk);
36040
36701
  };
36041
- var toChannelWithReader = (self, reader) => fromTransform(fnUntraced2(function* (upstream, scope3) {
36042
- const readScope = yield* fork(scope3);
36043
- const pull = yield* provide(reader, readScope);
36044
- const writeScope = yield* fork(scope3);
36045
- const writer = yield* provide(self.writer, writeScope);
36046
- let writeFailure;
36047
- yield* upstream.pipe(flatMap6((chunk) => writeChunk(writer, chunk)), forever4({
36048
- disableYield: true
36049
- }), catchCauseFilter2(filterNoDone, (cause) => suspend3(() => {
36050
- writeFailure = cause;
36051
- return close(readScope, void_4);
36052
- })), ensuring2(close(writeScope, void_4)), forkIn2(scope3));
36053
- return catchCause3(suspend3(() => writeFailure !== undefined ? failCause4(writeFailure) : pull), (cause) => failCause4(writeFailure ?? cause));
36054
- }));
36055
- var toChannel3 = (self) => toChannelWithReader(self, readerBytes(self));
36056
- var toChannelWith = () => (self) => toChannel3(self);
36057
- var defaultHighWaterMark = 64 * 1024;
36702
+ function removeDuplicateSlashes(path) {
36703
+ if (path.indexOf("//") === -1) {
36704
+ return path;
36705
+ }
36706
+ return path.replace(/\/\/+/g, "/");
36707
+ }
36708
+ function trimLastSlash(path) {
36709
+ if (path.length > 1 && path.charCodeAt(path.length - 1) === 47) {
36710
+ return path.slice(0, -1);
36711
+ }
36712
+ return path;
36713
+ }
36714
+ function makeCreateParams(params) {
36715
+ const len = params.length;
36716
+ if (len === 0) {
36717
+ return () => Object.create(null);
36718
+ }
36719
+ return function(paramsArray) {
36720
+ const paramsObject = Object.create(null);
36721
+ for (let i = 0;i < len; i++) {
36722
+ paramsObject[params[i]] = paramsArray[i];
36723
+ }
36724
+ return paramsObject;
36725
+ };
36726
+ }
36727
+ function getClosingParenthensePosition(path, idx) {
36728
+ let parentheses = 1;
36729
+ while (idx < path.length) {
36730
+ idx++;
36731
+ if (path[idx] === "\\") {
36732
+ idx++;
36733
+ continue;
36734
+ }
36735
+ if (path[idx] === ")") {
36736
+ parentheses--;
36737
+ } else if (path[idx] === "(") {
36738
+ parentheses++;
36739
+ }
36740
+ if (!parentheses)
36741
+ return idx;
36742
+ }
36743
+ throw new TypeError('Invalid regexp expression in "' + path + '"');
36744
+ }
36745
+ function trimRegExpStartAndEnd(regexString) {
36746
+ if (regexString.charCodeAt(1) === 94) {
36747
+ regexString = regexString.slice(0, 1) + regexString.slice(2);
36748
+ }
36749
+ if (regexString.charCodeAt(regexString.length - 2) === 36) {
36750
+ regexString = regexString.slice(0, regexString.length - 2) + regexString.slice(regexString.length - 1);
36751
+ }
36752
+ return regexString;
36753
+ }
36754
+ function escapeRegExp(string4) {
36755
+ return string4.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
36756
+ }
36757
+ function decodeComponentChar(highCharCode, lowCharCode) {
36758
+ if (highCharCode === 50) {
36759
+ if (lowCharCode === 53)
36760
+ return "%";
36761
+ if (lowCharCode === 51)
36762
+ return "#";
36763
+ if (lowCharCode === 52)
36764
+ return "$";
36765
+ if (lowCharCode === 54)
36766
+ return "&";
36767
+ if (lowCharCode === 66)
36768
+ return "+";
36769
+ if (lowCharCode === 98)
36770
+ return "+";
36771
+ if (lowCharCode === 67)
36772
+ return ",";
36773
+ if (lowCharCode === 99)
36774
+ return ",";
36775
+ if (lowCharCode === 70)
36776
+ return "/";
36777
+ if (lowCharCode === 102)
36778
+ return "/";
36779
+ return;
36780
+ }
36781
+ if (highCharCode === 51) {
36782
+ if (lowCharCode === 65)
36783
+ return ":";
36784
+ if (lowCharCode === 97)
36785
+ return ":";
36786
+ if (lowCharCode === 66)
36787
+ return ";";
36788
+ if (lowCharCode === 98)
36789
+ return ";";
36790
+ if (lowCharCode === 68)
36791
+ return "=";
36792
+ if (lowCharCode === 100)
36793
+ return "=";
36794
+ if (lowCharCode === 70)
36795
+ return "?";
36796
+ if (lowCharCode === 102)
36797
+ return "?";
36798
+ return;
36799
+ }
36800
+ if (highCharCode === 52 && lowCharCode === 48) {
36801
+ return "@";
36802
+ }
36803
+ return;
36804
+ }
36805
+ function safeDecodeURI(path) {
36806
+ let shouldDecode = false;
36807
+ let shouldDecodeParam = false;
36808
+ let querystring = "";
36809
+ for (let i = 1;i < path.length; i++) {
36810
+ const charCode = path.charCodeAt(i);
36811
+ if (charCode === 37) {
36812
+ const highCharCode = path.charCodeAt(i + 1);
36813
+ const lowCharCode = path.charCodeAt(i + 2);
36814
+ if (decodeComponentChar(highCharCode, lowCharCode) === undefined) {
36815
+ shouldDecode = true;
36816
+ } else {
36817
+ shouldDecodeParam = true;
36818
+ if (highCharCode === 50 && lowCharCode === 53) {
36819
+ shouldDecode = true;
36820
+ path = path.slice(0, i + 1) + "25" + path.slice(i + 1);
36821
+ i += 2;
36822
+ }
36823
+ i += 2;
36824
+ }
36825
+ } else if (charCode === 63 || charCode === 59 || charCode === 35) {
36826
+ querystring = path.slice(i + 1);
36827
+ path = path.slice(0, i);
36828
+ break;
36829
+ }
36830
+ }
36831
+ const decodedPath = shouldDecode ? decodeURI(path) : path;
36832
+ return {
36833
+ path: decodedPath,
36834
+ querystring,
36835
+ shouldDecodeParam
36836
+ };
36837
+ }
36838
+ function safeDecodeURIComponent(uriComponent) {
36839
+ const startIndex = uriComponent.indexOf("%");
36840
+ if (startIndex === -1)
36841
+ return uriComponent;
36842
+ let decoded = "";
36843
+ let lastIndex = startIndex;
36844
+ for (let i = startIndex;i < uriComponent.length; i++) {
36845
+ if (uriComponent.charCodeAt(i) === 37) {
36846
+ if (i + 2 >= uriComponent.length)
36847
+ break;
36848
+ const highCharCode = uriComponent.charCodeAt(i + 1);
36849
+ const lowCharCode = uriComponent.charCodeAt(i + 2);
36850
+ const decodedChar = decodeComponentChar(highCharCode, lowCharCode);
36851
+ decoded += uriComponent.slice(lastIndex, i) + decodedChar;
36852
+ lastIndex = i + 3;
36853
+ }
36854
+ }
36855
+ return uriComponent.slice(0, startIndex) + decoded + uriComponent.slice(lastIndex);
36856
+ }
36857
+ var httpMethods = ["ACL", "BIND", "CHECKOUT", "CONNECT", "COPY", "DELETE", "GET", "HEAD", "LINK", "LOCK", "M-SEARCH", "MERGE", "MKACTIVITY", "MKCALENDAR", "MKCOL", "MOVE", "NOTIFY", "OPTIONS", "PATCH", "POST", "PROPFIND", "PROPPATCH", "PURGE", "PUT", "QUERY", "REBIND", "REPORT", "SEARCH", "SOURCE", "SUBSCRIBE", "TRACE", "UNBIND", "UNLINK", "UNLOCK", "UNSUBSCRIBE"];
36058
36858
 
36059
- // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/ErrorReporter.js
36060
- var ignore5 = "~effect/ErrorReporter/ignore";
36859
+ // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/http/FindMyWay.js
36860
+ var make54 = make53;
36061
36861
 
36062
36862
  // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/http/HttpServerResponse.js
36063
36863
  var exports_HttpServerResponse = {};
@@ -36101,12 +36901,15 @@ __export(exports_HttpServerResponse, {
36101
36901
  empty: () => empty17
36102
36902
  });
36103
36903
 
36904
+ // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/ErrorReporter.js
36905
+ var ignore5 = "~effect/ErrorReporter/ignore";
36906
+
36104
36907
  // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/http/internal/headers.js
36105
36908
  var Proto14 = /* @__PURE__ */ Object.getPrototypeOf(empty13);
36106
36909
  var emptyMutableUnsafe = () => Object.create(Proto14);
36107
36910
 
36108
36911
  // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/http/Template.js
36109
- function make53(strings, ...args2) {
36912
+ function make55(strings, ...args2) {
36110
36913
  const argsLength = args2.length;
36111
36914
  const values4 = new Array(argsLength);
36112
36915
  const effects = [];
@@ -36252,7 +37055,7 @@ var html = (strings, ...args2) => {
36252
37055
  contentType: "text/html"
36253
37056
  });
36254
37057
  }
36255
- return map9(make53(strings, ...args2), (_) => text2(_, {
37058
+ return map9(make55(strings, ...args2), (_) => text2(_, {
36256
37059
  contentType: "text/html"
36257
37060
  }));
36258
37061
  };
@@ -36502,7 +37305,7 @@ class ServerHttpClientResponse extends Class2 {
36502
37305
  get url() {
36503
37306
  if (this.request === empty16)
36504
37307
  return "";
36505
- const url = toUrl(this.request);
37308
+ const url = toUrl2(this.request);
36506
37309
  if (isNone2(url))
36507
37310
  return "";
36508
37311
  url.value.hash = "";
@@ -36726,8 +37529,45 @@ var fromWeb3 = (response) => {
36726
37529
  return self;
36727
37530
  };
36728
37531
 
37532
+ // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/http/internal/compression.js
37533
+ var varyWith = (headers, dimension) => {
37534
+ const vary = headers["vary"];
37535
+ if (vary === undefined) {
37536
+ return dimension;
37537
+ }
37538
+ const members = vary.split(",").map((member) => member.trim().toLowerCase());
37539
+ return members.includes("*") || members.includes(dimension.toLowerCase()) ? vary : `${vary}, ${dimension}`;
37540
+ };
37541
+
36729
37542
  // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/http/HttpServerRespondable.js
36730
37543
  var symbol5 = "~effect/http/HttpServerRespondable";
37544
+ var isRespondable = (u) => hasProperty(u, symbol5);
37545
+ var badRequest = /* @__PURE__ */ empty17({
37546
+ status: 400
37547
+ });
37548
+ var notFound3 = /* @__PURE__ */ empty17({
37549
+ status: 404
37550
+ });
37551
+ var toResponseOrElse = (u, orElse6) => {
37552
+ if (isHttpServerResponse(u)) {
37553
+ return succeed6(u);
37554
+ } else if (isRespondable(u)) {
37555
+ return catchCause3(u[symbol5](), () => succeed6(orElse6));
37556
+ } else if (isSchemaError(u)) {
37557
+ return succeed6(badRequest);
37558
+ } else if (isNoSuchElementError2(u)) {
37559
+ return succeed6(notFound3);
37560
+ }
37561
+ return succeed6(orElse6);
37562
+ };
37563
+ var toResponseOrElseDefect = (u, orElse6) => {
37564
+ if (isHttpServerResponse(u)) {
37565
+ return succeed6(u);
37566
+ } else if (isRespondable(u)) {
37567
+ return catchCause3(u[symbol5](), () => succeed6(orElse6));
37568
+ }
37569
+ return succeed6(orElse6);
37570
+ };
36731
37571
 
36732
37572
  // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/http/HttpServerError.js
36733
37573
  var TypeId58 = "~effect/http/HttpServerError";
@@ -36775,10 +37615,257 @@ class RequestParseError extends (/* @__PURE__ */ TaggedError2("RequestParseError
36775
37615
  return formatRequestMessage(this._tag, this.description, this.methodAndUrl);
36776
37616
  }
36777
37617
  }
37618
+
37619
+ class RouteNotFound extends (/* @__PURE__ */ TaggedError2("RouteNotFound")) {
37620
+ [symbol5]() {
37621
+ return succeed6(empty17({
37622
+ status: 404
37623
+ }));
37624
+ }
37625
+ [ignore5] = true;
37626
+ get methodAndUrl() {
37627
+ return `${this.request.method} ${this.request.url}`;
37628
+ }
37629
+ get message() {
37630
+ return formatRequestMessage(this._tag, this.description, this.methodAndUrl);
37631
+ }
37632
+ }
37633
+ class ResponseError extends (/* @__PURE__ */ TaggedError2("ResponseError")) {
37634
+ [symbol5]() {
37635
+ return succeed6(empty17({
37636
+ status: 500
37637
+ }));
37638
+ }
37639
+ get methodAndUrl() {
37640
+ return `${this.request.method} ${this.request.url}`;
37641
+ }
37642
+ get message() {
37643
+ const info2 = `${this._tag} (${this.response.status} ${this.methodAndUrl})`;
37644
+ return this.description ? `${info2}: ${this.description}` : info2;
37645
+ }
37646
+ }
37647
+ class ClientAbort extends (/* @__PURE__ */ Service()("effect/http/HttpServerError/ClientAbort")) {
37648
+ static annotation = /* @__PURE__ */ this.context(true).pipe(/* @__PURE__ */ add(StackTrace, {
37649
+ name: "ClientAbort",
37650
+ stack: constUndefined,
37651
+ parent: undefined
37652
+ }));
37653
+ }
36778
37654
  var formatRequestMessage = (reason, description, info2) => {
36779
37655
  const prefix3 = `${reason} (${info2})`;
36780
37656
  return description ? `${prefix3}: ${description}` : prefix3;
36781
37657
  };
37658
+ var causeResponse = (cause) => {
37659
+ let response;
37660
+ let effect2 = succeedInternalServerError;
37661
+ const failures = [];
37662
+ let interrupts = [];
37663
+ let isClientInterrupt = false;
37664
+ for (let i = 0;i < cause.reasons.length; i++) {
37665
+ const reason = cause.reasons[i];
37666
+ switch (reason._tag) {
37667
+ case "Fail": {
37668
+ effect2 = toResponseOrElse(reason.error, internalServerError);
37669
+ failures.push(reason);
37670
+ break;
37671
+ }
37672
+ case "Die": {
37673
+ if (isHttpServerResponse(reason.defect)) {
37674
+ response = reason.defect;
37675
+ } else {
37676
+ effect2 = toResponseOrElseDefect(reason.defect, internalServerError);
37677
+ failures.push(reason);
37678
+ }
37679
+ break;
37680
+ }
37681
+ case "Interrupt": {
37682
+ isClientInterrupt = reason.annotations.has(ClientAbort.key);
37683
+ if (failures.length > 0)
37684
+ break;
37685
+ interrupts.push(reason);
37686
+ break;
37687
+ }
37688
+ }
37689
+ }
37690
+ if (response) {
37691
+ return succeed6([response, fromReasons(failures)]);
37692
+ } else if (interrupts.length > 0 && failures.length === 0) {
37693
+ failures.push(...interrupts);
37694
+ effect2 = isClientInterrupt ? clientAbortError : serverAbortError;
37695
+ }
37696
+ return mapEager2(effect2, (response2) => {
37697
+ failures.push(makeDieReason(response2));
37698
+ return [response2, fromReasons(failures)];
37699
+ });
37700
+ };
37701
+ var causeResponseStripped = (cause) => {
37702
+ let response;
37703
+ const failures = cause.reasons.filter((f) => {
37704
+ if (f._tag === "Die" && isHttpServerResponse(f.defect)) {
37705
+ response = f.defect;
37706
+ return false;
37707
+ }
37708
+ return true;
37709
+ });
37710
+ return [response ?? internalServerError, failures.length > 0 ? some3(fromReasons(failures)) : none2()];
37711
+ };
37712
+ var internalServerError = /* @__PURE__ */ empty17({
37713
+ status: 500
37714
+ });
37715
+ var succeedInternalServerError = /* @__PURE__ */ succeed6(internalServerError);
37716
+ var clientAbortError = /* @__PURE__ */ succeed6(/* @__PURE__ */ empty17({
37717
+ status: 499
37718
+ }));
37719
+ var serverAbortError = /* @__PURE__ */ succeed6(/* @__PURE__ */ empty17({
37720
+ status: 503
37721
+ }));
37722
+
37723
+ // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/http/HttpServerRequest.js
37724
+ var exports_HttpServerRequest = {};
37725
+ __export(exports_HttpServerRequest, {
37726
+ upgradeChannel: () => upgradeChannel,
37727
+ toWebResult: () => toWebResult2,
37728
+ toWeb: () => toWeb3,
37729
+ toURL: () => toURL,
37730
+ toClientRequest: () => toClientRequest,
37731
+ searchParamsFromURL: () => searchParamsFromURL,
37732
+ schemaSearchParams: () => schemaSearchParams,
37733
+ schemaHeaders: () => schemaHeaders,
37734
+ schemaCookies: () => schemaCookies,
37735
+ schemaBodyUrlParams: () => schemaBodyUrlParams2,
37736
+ schemaBodyMultipart: () => schemaBodyMultipart,
37737
+ schemaBodyJson: () => schemaBodyJson3,
37738
+ schemaBodyFormJson: () => schemaBodyFormJson,
37739
+ schemaBodyForm: () => schemaBodyForm,
37740
+ fromWeb: () => fromWeb4,
37741
+ fromClientRequest: () => fromClientRequest,
37742
+ TypeId: () => TypeId60,
37743
+ ParsedSearchParams: () => ParsedSearchParams,
37744
+ MaxBodySize: () => MaxBodySize,
37745
+ HttpServerRequest: () => HttpServerRequest
37746
+ });
37747
+
37748
+ // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/socket/Socket.js
37749
+ var encoder5 = /* @__PURE__ */ new TextEncoder;
37750
+ var readerBytes = (self) => map9(self.reader, ({
37751
+ pull
37752
+ }) => map9(pull, (chunk) => {
37753
+ for (let i = 0;i < chunk.length; i++) {
37754
+ if (typeof chunk[i] === "string") {
37755
+ const out = new Array(chunk.length);
37756
+ for (let j = 0;j < chunk.length; j++) {
37757
+ const item = chunk[j];
37758
+ out[j] = typeof item === "string" ? encoder5.encode(item) : item;
37759
+ }
37760
+ return out;
37761
+ }
37762
+ }
37763
+ return chunk;
37764
+ }));
37765
+ var CloseEventTypeId = "~effect/socket/Socket/CloseEvent";
37766
+ var isCloseEvent = (u) => hasProperty(u, CloseEventTypeId);
37767
+ var SocketErrorTypeId = "~effect/socket/Socket/SocketError";
37768
+ var isSocketError = (u) => hasProperty(u, SocketErrorTypeId);
37769
+
37770
+ class SocketReadError extends (/* @__PURE__ */ Error4("effect/socket/Socket/SocketReadError")({
37771
+ _tag: /* @__PURE__ */ tag("SocketReadError"),
37772
+ cause: /* @__PURE__ */ Defect()
37773
+ })) {
37774
+ message = `An error occurred during Read`;
37775
+ }
37776
+
37777
+ class SocketWriteError extends (/* @__PURE__ */ Error4("effect/socket/Socket/SocketWriteError")({
37778
+ _tag: /* @__PURE__ */ tag("SocketWriteError"),
37779
+ cause: /* @__PURE__ */ Defect()
37780
+ })) {
37781
+ message = `An error occurred during Write`;
37782
+ }
37783
+
37784
+ class SocketOpenError extends (/* @__PURE__ */ Error4("effect/socket/Socket/SocketOpenError")({
37785
+ _tag: /* @__PURE__ */ tag("SocketOpenError"),
37786
+ kind: /* @__PURE__ */ Literals(["Unknown", "Timeout"]),
37787
+ cause: /* @__PURE__ */ Defect()
37788
+ })) {
37789
+ get message() {
37790
+ return this.kind === "Timeout" ? `timeout waiting for "open"` : `An error occurred during Open`;
37791
+ }
37792
+ }
37793
+
37794
+ class SocketUpgradeError extends (/* @__PURE__ */ Error4("effect/socket/Socket/SocketUpgradeError")({
37795
+ _tag: /* @__PURE__ */ tag("SocketUpgradeError"),
37796
+ cause: /* @__PURE__ */ optional2(/* @__PURE__ */ Defect())
37797
+ })) {
37798
+ static unsupported = () => fail6(new SocketError({
37799
+ reason: new SocketUpgradeError({})
37800
+ }));
37801
+ get message() {
37802
+ return this.cause === undefined ? `Socket does not support TLS upgrade` : `An error occurred during TLS upgrade`;
37803
+ }
37804
+ }
37805
+
37806
+ class SocketCloseError extends (/* @__PURE__ */ Error4("effect/socket/Socket/SocketCloseError")({
37807
+ _tag: /* @__PURE__ */ tag("SocketCloseError"),
37808
+ code: Int,
37809
+ closeReason: /* @__PURE__ */ optional2(String7)
37810
+ })) {
37811
+ get message() {
37812
+ if (this.closeReason) {
37813
+ return `${this.code}: ${this.closeReason}`;
37814
+ }
37815
+ return `${this.code}`;
37816
+ }
37817
+ }
37818
+ var SocketErrorReason = /* @__PURE__ */ Union2([SocketReadError, SocketWriteError, SocketOpenError, SocketUpgradeError, SocketCloseError]);
37819
+
37820
+ class SocketError extends (/* @__PURE__ */ TaggedError3(SocketErrorTypeId)("SocketError", {
37821
+ _tag: /* @__PURE__ */ tag("SocketError"),
37822
+ reason: SocketErrorReason
37823
+ })) {
37824
+ constructor(props) {
37825
+ if ("cause" in props.reason) {
37826
+ super({
37827
+ ...props,
37828
+ cause: props.reason.cause
37829
+ });
37830
+ } else {
37831
+ super(props);
37832
+ }
37833
+ }
37834
+ [SocketErrorTypeId] = SocketErrorTypeId;
37835
+ static is(u) {
37836
+ return isSocketError(u);
37837
+ }
37838
+ message = this.reason.message;
37839
+ }
37840
+ var writeChunk = (writer, chunk) => {
37841
+ for (let i = 0;i < chunk.length; i++) {
37842
+ if (isCloseEvent(chunk[i])) {
37843
+ return gen4(function* () {
37844
+ for (let index2 = 0;index2 <= i; index2++) {
37845
+ yield* writer.write(chunk[index2]);
37846
+ }
37847
+ });
37848
+ }
37849
+ }
37850
+ return writer.writeAll(chunk);
37851
+ };
37852
+ var toChannelWithReader = (self, reader) => fromTransform(fnUntraced2(function* (upstream, scope3) {
37853
+ const readScope = yield* fork(scope3);
37854
+ const pull = yield* provide(reader, readScope);
37855
+ const writeScope = yield* fork(scope3);
37856
+ const writer = yield* provide(self.writer, writeScope);
37857
+ let writeFailure;
37858
+ yield* upstream.pipe(flatMap6((chunk) => writeChunk(writer, chunk)), forever4({
37859
+ disableYield: true
37860
+ }), catchCauseFilter2(filterNoDone, (cause) => suspend3(() => {
37861
+ writeFailure = cause;
37862
+ return close(readScope, void_4);
37863
+ })), ensuring2(close(writeScope, void_4)), forkIn2(scope3));
37864
+ return catchCause3(suspend3(() => writeFailure !== undefined ? failCause4(writeFailure) : pull), (cause) => failCause4(writeFailure ?? cause));
37865
+ }));
37866
+ var toChannel3 = (self) => toChannelWithReader(self, readerBytes(self));
37867
+ var toChannelWith = () => (self) => toChannel3(self);
37868
+ var defaultHighWaterMark = 64 * 1024;
36782
37869
 
36783
37870
  // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/http/MultipartParser/internal/contentType.js
36784
37871
  var paramRE = /; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u{10ffff}]|\\[\v\u0020-\u{10ffff}])*"|[!#$%&'*+.^\w`|~-]+) */gu;
@@ -36789,7 +37876,7 @@ var defaultContentType = {
36789
37876
  value: "",
36790
37877
  parameters: /* @__PURE__ */ Object.create(null)
36791
37878
  };
36792
- function parse2(header, withoutSlash = false) {
37879
+ function parse3(header, withoutSlash = false) {
36793
37880
  if (typeof header !== "string") {
36794
37881
  return defaultContentType;
36795
37882
  }
@@ -36854,7 +37941,7 @@ for (let i = 32;i <= 126; i++) {
36854
37941
  for (let i = 128;i <= 255; i++) {
36855
37942
  constValueChars[i] = 1;
36856
37943
  }
36857
- function make54() {
37944
+ function make56() {
36858
37945
  const decoder4 = new TextDecoder;
36859
37946
  const state = {
36860
37947
  state: State.key,
@@ -37057,7 +38144,7 @@ function makeState(needle_) {
37057
38144
  matchIndex: 0
37058
38145
  };
37059
38146
  }
37060
- function make55(needle, callback4, seed, minimumChunkLength) {
38147
+ function make57(needle, callback4, seed, minimumChunkLength) {
37061
38148
  const state = makeState(needle);
37062
38149
  const minChunkLength = minimumChunkLength ?? state.needleLength;
37063
38150
  if (seed !== undefined) {
@@ -37191,12 +38278,12 @@ function defaultIsFile(info2) {
37191
38278
  return info2.filename !== undefined || info2.contentType === "application/octet-stream";
37192
38279
  }
37193
38280
  function parseBoundary(headers) {
37194
- const contentType = parse2(headers["content-type"]);
38281
+ const contentType = parse3(headers["content-type"]);
37195
38282
  return contentType.parameters.boundary;
37196
38283
  }
37197
38284
  function noopOnChunk(_chunk) {}
37198
38285
  var toLimit = (input) => input === Infinity ? Infinity : Number(fromInputUnsafe2(input));
37199
- function make56({
38286
+ function make58({
37200
38287
  headers,
37201
38288
  onFile: onPart,
37202
38289
  onField,
@@ -37248,8 +38335,8 @@ function make56({
37248
38335
  }
37249
38336
  onError5(error2);
37250
38337
  }
37251
- const headerParser = make54();
37252
- const split4 = make55(`\r
38338
+ const headerParser = make56();
38339
+ const split4 = make57(`\r
37253
38340
  --${boundary}`, function(index2, chunk) {
37254
38341
  if (state.stopped) {
37255
38342
  return;
@@ -37306,8 +38393,8 @@ function make56({
37306
38393
  error: result6
37307
38394
  });
37308
38395
  }
37309
- const contentType = parse2(result6.headers["content-type"]);
37310
- const contentDisposition = parse2(result6.headers["content-disposition"], true);
38396
+ const contentType = parse3(result6.headers["content-type"]);
38397
+ const contentDisposition = parse3(result6.headers["content-disposition"], true);
37311
38398
  if (contentDisposition.value === "form-data" && !("name" in contentDisposition.parameters)) {
37312
38399
  skipBody();
37313
38400
  return onError5(errInvalidDisposition);
@@ -37402,7 +38489,7 @@ function decodeField(info2, value5) {
37402
38489
  }
37403
38490
 
37404
38491
  // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/http/MultipartParser.js
37405
- var make57 = make56;
38492
+ var make59 = make58;
37406
38493
  var defaultIsFile2 = defaultIsFile;
37407
38494
  var decodeField2 = decodeField;
37408
38495
 
@@ -37465,7 +38552,7 @@ var makeChannel = (headers) => fromTransform((upstream) => map9(makeConfig(heade
37465
38552
  let partsBuffer = [];
37466
38553
  let exit3 = none2();
37467
38554
  let ended = false;
37468
- const parser = make57({
38555
+ const parser = make59({
37469
38556
  ...config,
37470
38557
  onField(info2, value5) {
37471
38558
  partsBuffer.push(new FieldImpl(info2.name, info2.contentType, decodeField2(info2, value5)));
@@ -37716,20 +38803,20 @@ var searchParamsFromURL = (url) => {
37716
38803
  };
37717
38804
  var upgradeChannel = () => HttpServerRequest.pipe(flatMap6((_) => _.upgrade), map9(toChannelWith()), unwrap2);
37718
38805
  var schemaCookies = (schema2, options3) => {
37719
- const parse3 = decodeUnknownEffect2(schema2);
37720
- return flatMap6(HttpServerRequest, (req) => parse3(req.cookies, options3));
38806
+ const parse4 = decodeUnknownEffect2(schema2);
38807
+ return flatMap6(HttpServerRequest, (req) => parse4(req.cookies, options3));
37721
38808
  };
37722
38809
  var schemaHeaders = (schema2, options3) => {
37723
- const parse3 = decodeUnknownEffect2(schema2);
37724
- return flatMap6(HttpServerRequest, (req) => parse3(req.headers, options3));
38810
+ const parse4 = decodeUnknownEffect2(schema2);
38811
+ return flatMap6(HttpServerRequest, (req) => parse4(req.headers, options3));
37725
38812
  };
37726
38813
  var schemaSearchParams = (schema2, options3) => {
37727
- const parse3 = decodeUnknownEffect2(schema2);
37728
- return flatMap6(ParsedSearchParams, (params) => parse3(params, options3));
38814
+ const parse4 = decodeUnknownEffect2(schema2);
38815
+ return flatMap6(ParsedSearchParams, (params) => parse4(params, options3));
37729
38816
  };
37730
38817
  var schemaBodyJson3 = (schema2, options3) => {
37731
- const parse3 = schemaBodyJson2(schema2, options3);
37732
- return flatMap6(HttpServerRequest, parse3);
38818
+ const parse4 = schemaBodyJson2(schema2, options3);
38819
+ return flatMap6(HttpServerRequest, parse4);
37733
38820
  };
37734
38821
  var isMultipart = (request3) => request3.headers["content-type"]?.toLowerCase().includes("multipart/form-data") === true || getFormDataBody(request3) !== undefined;
37735
38822
  var schemaBodyForm = (schema2, options3) => {
@@ -37743,12 +38830,12 @@ var schemaBodyForm = (schema2, options3) => {
37743
38830
  });
37744
38831
  };
37745
38832
  var schemaBodyUrlParams2 = (schema2, options3) => {
37746
- const parse3 = schemaBodyUrlParams(schema2, options3);
37747
- return flatMap6(HttpServerRequest, parse3);
38833
+ const parse4 = schemaBodyUrlParams(schema2, options3);
38834
+ return flatMap6(HttpServerRequest, parse4);
37748
38835
  };
37749
38836
  var schemaBodyMultipart = (schema2, options3) => {
37750
- const parse3 = schemaPersisted(schema2);
37751
- return HttpServerRequest.pipe(flatMap6((_) => _.multipart), flatMap6((_) => parse3(_, options3)));
38837
+ const parse4 = schemaPersisted(schema2);
38838
+ return HttpServerRequest.pipe(flatMap6((_) => _.multipart), flatMap6((_) => parse4(_, options3)));
37752
38839
  };
37753
38840
  var schemaBodyFormJson = (schema2, options3) => {
37754
38841
  const parseMultipart = schemaJson2(schema2, options3);
@@ -37768,7 +38855,7 @@ var schemaBodyFormJson = (schema2, options3) => {
37768
38855
  };
37769
38856
  };
37770
38857
  var fromClientRequest = (request3) => {
37771
- const url = match(toUrl(request3), {
38858
+ const url = match(toUrl2(request3), {
37772
38859
  onNone: () => request3.url,
37773
38860
  onSome: (url2) => url2.toString()
37774
38861
  });
@@ -38229,6 +39316,743 @@ var toWeb3 = (self, options3) => contextWith2((context3) => fromResult2(toWebRes
38229
39316
  context: context3,
38230
39317
  signal: options3?.signal
38231
39318
  })));
39319
+
39320
+ // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/http/internal/preResponseHandler.js
39321
+ var requestPreResponseHandlers = /* @__PURE__ */ new WeakMap;
39322
+ var appendPreResponseHandlerUnsafe = (request3, handler) => {
39323
+ const prev = requestPreResponseHandlers.get(request3.source);
39324
+ const next3 = prev ? (request4, response) => flatMap6(prev(request4, response), (response2) => handler(request4, response2)) : handler;
39325
+ requestPreResponseHandlers.set(request3.source, next3);
39326
+ };
39327
+
39328
+ // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/http/HttpMiddleware.js
39329
+ var make60 = (middleware) => middleware;
39330
+ var loggerDisabledRequests = /* @__PURE__ */ new WeakSet;
39331
+ var stripSearchAndHash = (url) => {
39332
+ const queryIndex = url.indexOf("?");
39333
+ const hashIndex = url.indexOf("#");
39334
+ if (queryIndex === -1) {
39335
+ return hashIndex === -1 ? url : url.slice(0, hashIndex);
39336
+ }
39337
+ if (hashIndex === -1) {
39338
+ return url.slice(0, queryIndex);
39339
+ }
39340
+ return url.slice(0, Math.min(queryIndex, hashIndex));
39341
+ };
39342
+ var withLoggerDisabled = (self) => withFiber2((fiber3) => {
39343
+ const request3 = getUnsafe(fiber3.context, HttpServerRequest);
39344
+ loggerDisabledRequests.add(request3.source);
39345
+ return self;
39346
+ });
39347
+ var TracerDisabledWhen2 = /* @__PURE__ */ Reference("effect/http/HttpMiddleware/TracerDisabledWhen", {
39348
+ defaultValue: () => constFalse
39349
+ });
39350
+ var SpanNameGenerator2 = /* @__PURE__ */ Reference("@effect/platform/HttpMiddleware/SpanNameGenerator", {
39351
+ defaultValue: () => (request3) => request3.method
39352
+ });
39353
+ var TracerHeaderFilter2 = /* @__PURE__ */ Reference("effect/http/HttpMiddleware/TracerHeaderFilter", {
39354
+ defaultValue: () => constFalse
39355
+ });
39356
+ var logger = /* @__PURE__ */ make60((httpApp) => withFiber2((fiber3) => {
39357
+ const request3 = getUnsafe(fiber3.context, HttpServerRequest);
39358
+ const path = stripSearchAndHash(request3.url);
39359
+ return withLogSpan(flatMap6(exit2(httpApp), (exit3) => {
39360
+ if (loggerDisabledRequests.has(request3.source)) {
39361
+ return exit3;
39362
+ } else if (exit3._tag === "Failure") {
39363
+ const [response, cause] = causeResponseStripped(exit3.cause);
39364
+ const message = isSome2(cause) && !cause.value.reasons.every((reason) => reason._tag === "Interrupt" && reason.annotations.has(ClientAbort.key)) ? cause.value : "Sent HTTP response";
39365
+ return andThen4(annotateLogs(log(message), {
39366
+ "http.method": request3.method,
39367
+ "http.url": path,
39368
+ "http.status": response.status
39369
+ }), exit3);
39370
+ }
39371
+ return andThen4(annotateLogs(log("Sent HTTP response"), {
39372
+ "http.method": request3.method,
39373
+ "http.url": path,
39374
+ "http.status": exit3.value.status
39375
+ }), exit3);
39376
+ }), "http.span");
39377
+ }));
39378
+ var isTracerDisabledUnsafe = (fiber3, request3) => !fiber3.cache.tracerEnabled || fiber3.getRef(TracerDisabledWhen2)(request3);
39379
+ var responseSpanExit = (request3, response) => {
39380
+ if (!(response.status >= 500 && response.status < 600)) {
39381
+ return succeed4(response);
39382
+ }
39383
+ const stackTraceLimit = getStackTraceLimit();
39384
+ setStackTraceLimit(0);
39385
+ try {
39386
+ return fail5(new HttpServerError({
39387
+ reason: new ResponseError({
39388
+ request: request3,
39389
+ response
39390
+ })
39391
+ }));
39392
+ } finally {
39393
+ setStackTraceLimit(stackTraceLimit);
39394
+ }
39395
+ };
39396
+ var tracer3 = /* @__PURE__ */ make60((httpApp) => withFiber2((fiber3) => {
39397
+ const request3 = getUnsafe(fiber3.context, HttpServerRequest);
39398
+ if (isTracerDisabledUnsafe(fiber3, request3)) {
39399
+ return httpApp;
39400
+ }
39401
+ const nameGenerator = fiber3.getRef(SpanNameGenerator2);
39402
+ const span3 = makeSpanUnsafe(fiber3, nameGenerator(request3), {
39403
+ parent: getOrUndefined(fromHeaders(request3.headers)),
39404
+ kind: "server"
39405
+ });
39406
+ const prevServices = fiber3.context;
39407
+ fiber3.setContext(add(fiber3.context, ParentSpan, span3));
39408
+ onExitUnsafe(fiber3, (exit3) => {
39409
+ fiber3.setContext(prevServices);
39410
+ const endTime = fiber3.getRef(Clock).currentTimeNanosUnsafe();
39411
+ if (isSuccess4(exit3) && (!span3.sampled || fiber3.getRef(Tracer) === nativeTracer)) {
39412
+ span3.end(endTime, responseSpanExit(request3, exit3.value));
39413
+ return;
39414
+ }
39415
+ const redactedHeaderNames = fiber3.getRef(CurrentRedactedNames);
39416
+ const headerFilter = fiber3.getRef(TracerHeaderFilter2);
39417
+ fiber3.currentDispatcher.scheduleTask(() => {
39418
+ let response;
39419
+ let spanExit;
39420
+ if (isFailure4(exit3)) {
39421
+ const [failureResponse, cause] = causeResponseStripped(exit3.cause);
39422
+ response = failureResponse;
39423
+ spanExit = isSome2(cause) && (response.status >= 500 || hasInterrupts2(cause.value)) ? failCause2(cause.value) : responseSpanExit(request3, response);
39424
+ } else {
39425
+ response = exit3.value;
39426
+ spanExit = responseSpanExit(request3, response);
39427
+ }
39428
+ if (span3.sampled) {
39429
+ span3.attribute("http.request.method", request3.method);
39430
+ const url = toURL(request3);
39431
+ if (isSome2(url)) {
39432
+ if (!request3.url.startsWith("/") && (url.value.username !== "" || url.value.password !== "")) {
39433
+ url.value.username = "REDACTED";
39434
+ url.value.password = "REDACTED";
39435
+ }
39436
+ addUrlAttributes(span3, url.value);
39437
+ }
39438
+ if (request3.headers["user-agent"] !== undefined) {
39439
+ span3.attribute("user_agent.original", request3.headers["user-agent"]);
39440
+ }
39441
+ addHeaderAttributes(span3, "request", request3.headers, headerFilter, redactedHeaderNames);
39442
+ if (isSome2(request3.remoteAddress)) {
39443
+ span3.attribute("client.address", request3.remoteAddress.value);
39444
+ }
39445
+ span3.attribute("http.response.status_code", response.status);
39446
+ addHeaderAttributes(span3, "response", response.headers, headerFilter, redactedHeaderNames);
39447
+ }
39448
+ span3.end(endTime, spanExit);
39449
+ }, 0);
39450
+ return;
39451
+ });
39452
+ return httpApp;
39453
+ }));
39454
+ var cors = (options3) => {
39455
+ const opts = {
39456
+ allowedOrigins: options3?.allowedOrigins ?? [],
39457
+ allowedMethods: options3?.allowedMethods ?? ["GET", "HEAD", "PUT", "PATCH", "POST", "DELETE"],
39458
+ allowedHeaders: options3?.allowedHeaders ?? [],
39459
+ exposedHeaders: options3?.exposedHeaders ?? [],
39460
+ credentials: options3?.credentials ?? false,
39461
+ maxAge: options3?.maxAge
39462
+ };
39463
+ const isAllowedOrigin = typeof opts.allowedOrigins === "function" ? opts.allowedOrigins : (origin) => opts.allowedOrigins.includes(origin);
39464
+ const allowOrigin = typeof opts.allowedOrigins === "function" || opts.allowedOrigins.length > 1 ? (originHeader) => {
39465
+ if (!isAllowedOrigin(originHeader))
39466
+ return {
39467
+ vary: "Origin"
39468
+ };
39469
+ return {
39470
+ "access-control-allow-origin": originHeader,
39471
+ vary: "Origin"
39472
+ };
39473
+ } : opts.allowedOrigins.length === 0 ? constant({
39474
+ "access-control-allow-origin": "*"
39475
+ }) : constant({
39476
+ "access-control-allow-origin": opts.allowedOrigins[0],
39477
+ vary: "Origin"
39478
+ });
39479
+ const allowMethods = opts.allowedMethods.length > 0 ? {
39480
+ "access-control-allow-methods": opts.allowedMethods.join(", ")
39481
+ } : undefined;
39482
+ const allowCredentials = opts.credentials ? {
39483
+ "access-control-allow-credentials": "true"
39484
+ } : undefined;
39485
+ const allowHeaders = (accessControlRequestHeaders) => {
39486
+ if (opts.allowedHeaders.length === 0 && accessControlRequestHeaders) {
39487
+ return {
39488
+ vary: "Access-Control-Request-Headers",
39489
+ "access-control-allow-headers": accessControlRequestHeaders
39490
+ };
39491
+ }
39492
+ if (opts.allowedHeaders) {
39493
+ return {
39494
+ "access-control-allow-headers": opts.allowedHeaders.join(",")
39495
+ };
39496
+ }
39497
+ return;
39498
+ };
39499
+ const exposeHeaders = opts.exposedHeaders.length > 0 ? {
39500
+ "access-control-expose-headers": opts.exposedHeaders.join(",")
39501
+ } : undefined;
39502
+ const maxAge = opts.maxAge ? {
39503
+ "access-control-max-age": opts.maxAge.toString()
39504
+ } : undefined;
39505
+ const headersFromRequest = (request3) => {
39506
+ const origin = request3.headers["origin"];
39507
+ return fromRecordUnsafe({
39508
+ ...allowOrigin(origin),
39509
+ ...allowCredentials,
39510
+ ...exposeHeaders
39511
+ });
39512
+ };
39513
+ const headersFromRequestOptions = (request3) => {
39514
+ const origin = request3.headers["origin"];
39515
+ const accessControlRequestHeaders = request3.headers["access-control-request-headers"];
39516
+ const headers = fromRecordUnsafe({
39517
+ ...allowOrigin(origin),
39518
+ ...allowCredentials,
39519
+ ...exposeHeaders,
39520
+ ...allowMethods,
39521
+ ...maxAge
39522
+ });
39523
+ const accessControlHeaders = allowHeaders(accessControlRequestHeaders);
39524
+ if (accessControlHeaders === undefined)
39525
+ return headers;
39526
+ const vary = accessControlHeaders["vary"];
39527
+ return setAll2(headers, vary === undefined ? accessControlHeaders : {
39528
+ ...accessControlHeaders,
39529
+ vary: varyWith(headers, vary)
39530
+ });
39531
+ };
39532
+ const preResponseHandler = (request3, response) => {
39533
+ const headers = headersFromRequest(request3);
39534
+ return succeed6(setHeaders2(response, headers["vary"] === undefined ? headers : set6(headers, "vary", varyWith(response.headers, "Origin"))));
39535
+ };
39536
+ return (httpApp) => withFiber2((fiber3) => {
39537
+ const request3 = getUnsafe(fiber3.context, HttpServerRequest);
39538
+ if (request3.method === "OPTIONS") {
39539
+ return succeed6(empty17({
39540
+ status: 204,
39541
+ headers: headersFromRequestOptions(request3)
39542
+ }));
39543
+ }
39544
+ appendPreResponseHandlerUnsafe(request3, preResponseHandler);
39545
+ return httpApp;
39546
+ });
39547
+ };
39548
+
39549
+ // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/http/HttpEffect.js
39550
+ var toHandled = (self, handleResponse, middleware) => {
39551
+ const handleCause = (frame, cause) => {
39552
+ frame.cause = cause;
39553
+ const request3 = frame.request;
39554
+ return flatMapEager2(causeResponse(cause), ([response, cause2]) => {
39555
+ const fiber3 = getCurrent();
39556
+ reportCauseUnsafe(fiber3, cause2);
39557
+ const handler = requestPreResponseHandlers.get(request3.source);
39558
+ const cont = cause2.reasons.length === 0 ? succeed6(response) : failCause4(cause2);
39559
+ if (handler === undefined) {
39560
+ request3[handledSymbol] = true;
39561
+ return flatMapEager2(handleResponse(request3, response), () => cont);
39562
+ }
39563
+ return flatMapEager2(flatMapEager2(handler(request3, response), (response2) => {
39564
+ request3[handledSymbol] = true;
39565
+ return handleResponse(request3, response2);
39566
+ }), () => cont);
39567
+ });
39568
+ };
39569
+ const sendResponse = (request3, response) => {
39570
+ const handler = requestPreResponseHandlers.get(request3.source);
39571
+ if (handler === undefined) {
39572
+ request3[handledSymbol] = true;
39573
+ return mapEager2(handleResponse(request3, response), (sent) => isHttpServerResponse(sent) ? sent : response);
39574
+ }
39575
+ return flatMapEager2(handler(request3, response), (sentResponse) => {
39576
+ request3[handledSymbol] = true;
39577
+ return mapEager2(handleResponse(request3, sentResponse), (sent) => isHttpServerResponse(sent) ? sent : response);
39578
+ });
39579
+ };
39580
+ const withMiddleware = (frame) => {
39581
+ const request3 = frame.request;
39582
+ const responded = matchCauseEffect2(self, {
39583
+ onSuccess: (response) => sendResponse(request3, response),
39584
+ onFailure: (cause) => handleCause(frame, cause)
39585
+ });
39586
+ return middleware === undefined ? responded : matchCauseEffect2(tracer3(middleware(responded)), {
39587
+ onFailure(cause) {
39588
+ reportCauseUnsafe(getCurrent(), cause);
39589
+ if (handledSymbol in request3)
39590
+ return void_5;
39591
+ return matchCauseEffectEager2(causeResponse(cause), {
39592
+ onFailure(_) {
39593
+ return handleResponse(request3, empty17({
39594
+ status: 500
39595
+ }));
39596
+ },
39597
+ onSuccess([response]) {
39598
+ return handleResponse(request3, response);
39599
+ }
39600
+ });
39601
+ },
39602
+ onSuccess(response) {
39603
+ return handledSymbol in request3 ? void_5 : handleResponse(request3, response);
39604
+ }
39605
+ });
39606
+ };
39607
+ const traced = (frame) => tracer3(withMiddleware(frame));
39608
+ const finishAfter = (frame, fiber3, effect2) => onExitPrimitive2(effect2, (exit3) => {
39609
+ fiber3.setContext(frame.prev);
39610
+ if (scopeEjected in frame.scope)
39611
+ return;
39612
+ return closeUnsafe(frame.scope, frame.cause === undefined ? exit3 : failCause2(frame.cause));
39613
+ }, true);
39614
+
39615
+ class RequestFrame {
39616
+ scope;
39617
+ prev;
39618
+ request;
39619
+ cause;
39620
+ constructor(scope3, prev, request3) {
39621
+ this.scope = scope3;
39622
+ this.prev = prev;
39623
+ this.request = request3;
39624
+ }
39625
+ [contA](response, fiber3) {
39626
+ const sent = sendResponse(this.request, response);
39627
+ if (effectIsExit(sent) && sent._tag === "Success") {
39628
+ fiber3.setContext(this.prev);
39629
+ if (scopeEjected in this.scope)
39630
+ return sent;
39631
+ const closed = closeUnsafe(this.scope, sent);
39632
+ return closed === undefined ? sent : flatMap6(closed, () => sent);
39633
+ }
39634
+ return finishAfter(this, fiber3, sent);
39635
+ }
39636
+ [contE](cause, fiber3) {
39637
+ return finishAfter(this, fiber3, handleCause(this, cause));
39638
+ }
39639
+ }
39640
+ return withFiber2((fiber3) => {
39641
+ fiberEnterUninterruptibleUnsafe(fiber3);
39642
+ const scope3 = makeUnsafe3();
39643
+ const frame = new RequestFrame(scope3, fiber3.context, getUnsafe(fiber3.context, HttpServerRequest));
39644
+ fiber3.setContext(add(frame.prev, Scope, scope3));
39645
+ const currentTracer = fiber3.cache.tracer;
39646
+ if (middleware === undefined && (currentTracer === undefined || currentTracer === nativeTracer || isTracerDisabledUnsafe(fiber3, frame.request))) {
39647
+ fiber3._stack.push(frame);
39648
+ return self;
39649
+ }
39650
+ return finishAfter(frame, fiber3, middleware === undefined ? traced(frame) : withMiddleware(frame));
39651
+ });
39652
+ };
39653
+ var handledSymbol = /* @__PURE__ */ Symbol.for("effect/http/HttpEffect/handled");
39654
+ var scopeDisableClose = (scope3) => {
39655
+ scope3[scopeEjected] = true;
39656
+ };
39657
+ var scopeTransferToStream = (response) => {
39658
+ if (response.body._tag !== "Stream") {
39659
+ return response;
39660
+ }
39661
+ const fiber3 = getCurrent();
39662
+ const scope3 = getUnsafe(fiber3.context, Scope);
39663
+ scopeDisableClose(scope3);
39664
+ return setBodyKeepHeaders(response, stream(onExit4(response.body.stream, (exit3) => close(scope3, exit3)), response.body.contentType, response.body.contentLength));
39665
+ };
39666
+ var scopeEjected = /* @__PURE__ */ Symbol.for("effect/http/HttpEffect/scopeEjected");
39667
+ var toWebHandlerWith = (context3) => (self, middleware) => {
39668
+ const resolveSymbol = Symbol.for("@effect/platform/HttpApp/resolve");
39669
+ const httpApp = toHandled(self, (request3, response) => {
39670
+ const withoutBody = request3.method === "HEAD";
39671
+ if (!omitsBody(response, withoutBody)) {
39672
+ response = scopeTransferToStream(response);
39673
+ }
39674
+ request3[resolveSymbol](toWeb2(response, {
39675
+ withoutBody,
39676
+ context: context3
39677
+ }));
39678
+ return void_5;
39679
+ }, middleware);
39680
+ return (request3, _context) => new Promise((resolve7) => {
39681
+ let reqContext = context3;
39682
+ if (isContext(_context)) {
39683
+ for (const [key, value5] of _context.mapUnsafe) {
39684
+ reqContext = addUnsafe(reqContext, key, value5);
39685
+ }
39686
+ }
39687
+ const httpServerRequest = fromWeb4(request3);
39688
+ reqContext = add(reqContext, HttpServerRequest, httpServerRequest);
39689
+ httpServerRequest[resolveSymbol] = resolve7;
39690
+ const fiber3 = runForkWith2(reqContext)(httpApp);
39691
+ if (fiber3.pollUnsafe() === undefined) {
39692
+ request3.signal?.addEventListener("abort", () => {
39693
+ fiber3.interruptUnsafe(undefined, ClientAbort.annotation);
39694
+ }, {
39695
+ once: true
39696
+ });
39697
+ }
39698
+ });
39699
+ };
39700
+ var toWebHandlerLayerWith = (layer15, options3) => {
39701
+ const scope3 = makeUnsafe3();
39702
+ const dispose = () => runPromise2(close(scope3, void_4));
39703
+ let handlerCache;
39704
+ const handlerPromise = runPromise2(gen4(function* () {
39705
+ const context3 = yield* options3.memoMap ? buildWithMemoMap(layer15, options3.memoMap, scope3) : buildWithScope(layer15, scope3);
39706
+ return handlerCache = toWebHandlerWith(context3)(yield* options3.toHandler(context3), options3.middleware);
39707
+ }));
39708
+ handlerPromise.catch(constVoid);
39709
+ function handler(request3, context3) {
39710
+ if (handlerCache) {
39711
+ return handlerCache(request3, context3);
39712
+ }
39713
+ return handlerPromise.then((f) => f(request3, context3));
39714
+ }
39715
+ return {
39716
+ dispose,
39717
+ handler
39718
+ };
39719
+ };
39720
+
39721
+ // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/http/HttpServer.js
39722
+ class HttpServer extends (/* @__PURE__ */ Service()("effect/http/HttpServer")) {
39723
+ }
39724
+ var serve = /* @__PURE__ */ dual((args2) => isEffect2(args2[0]), (effect2, middleware) => effectDiscard(HttpServer.use((server) => server.serve(effect2, middleware))));
39725
+ var formatAddress = formatUrlUnsafe;
39726
+ var addressFormattedWith = (f) => flatMap6(HttpServer, (server) => f(formatAddress(server.address)));
39727
+ var logAddress = /* @__PURE__ */ addressFormattedWith((_) => log(`Listening on ${_}`));
39728
+ var withLogAddress = (layer15) => effectDiscard(logAddress).pipe(provideMerge(layer15));
39729
+
39730
+ // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/http/HttpRouter.js
39731
+ var TypeId61 = "~effect/http/HttpRouter";
39732
+ var HttpRouter = /* @__PURE__ */ Service("effect/http/HttpRouter");
39733
+ var make61 = /* @__PURE__ */ gen4(function* () {
39734
+ const router = make54(yield* RouterConfig);
39735
+ const middleware = new Set;
39736
+ const addAll = (routes) => contextWith2((context3) => {
39737
+ const middleware2 = getMiddleware(context3);
39738
+ const applyMiddleware = (effect2) => {
39739
+ for (let i = 0;i < middleware2.length; i++) {
39740
+ effect2 = middleware2[i](effect2);
39741
+ }
39742
+ return effect2;
39743
+ };
39744
+ for (let i = 0;i < routes.length; i++) {
39745
+ const route = middleware2.length === 0 ? routes[i] : makeRoute({
39746
+ ...routes[i],
39747
+ handler: applyMiddleware(routes[i].handler)
39748
+ });
39749
+ if (route.method === "*") {
39750
+ if (route.path.endsWith("/*")) {
39751
+ router.all(route.path, route);
39752
+ router.all(route.path.slice(0, -2), route);
39753
+ } else {
39754
+ router.all(route.path, route);
39755
+ }
39756
+ } else {
39757
+ if (route.path.endsWith("/*")) {
39758
+ router.on(route.method, route.path, route);
39759
+ router.on(route.method, route.path.slice(0, -2), route);
39760
+ } else {
39761
+ router.on(route.method, route.path, route);
39762
+ }
39763
+ }
39764
+ }
39765
+ return void_5;
39766
+ });
39767
+ return HttpRouter.of({
39768
+ [TypeId61]: TypeId61,
39769
+ prefixed(prefix3) {
39770
+ prefix3 = removeTrailingSlash(prefix3);
39771
+ return HttpRouter.of({
39772
+ ...this,
39773
+ prefixed: (newPrefix) => this.prefixed(prefixPath(newPrefix, prefix3)),
39774
+ addAll: (routes) => addAll(routes.map(prefixRoute(prefix3))),
39775
+ add: (method, path, handler, options3) => addAll([makeRoute({
39776
+ method,
39777
+ path: prefixPath(path, prefix3),
39778
+ handler: isHttpServerResponse(handler) ? succeed6(handler) : isEffect2(handler) ? handler : flatMap6(HttpServerRequest, handler),
39779
+ uninterruptible: options3?.uninterruptible ?? false,
39780
+ prefix: prefix3
39781
+ })])
39782
+ });
39783
+ },
39784
+ addAll,
39785
+ add: (method, path, handler, options3) => addAll([route(method, path, handler, options3)]),
39786
+ addGlobalMiddleware: (middleware_) => sync3(() => {
39787
+ middleware.add(middleware_);
39788
+ }),
39789
+ asHttpEffect() {
39790
+ let handler = withFiber2((fiber3) => {
39791
+ let context3 = fiber3.context;
39792
+ const request3 = getUnsafe(context3, HttpServerRequest);
39793
+ let result6 = router.find(request3.method, request3.url);
39794
+ if (result6 === undefined && request3.method === "HEAD") {
39795
+ result6 = router.find("GET", request3.url);
39796
+ }
39797
+ if (result6 === undefined) {
39798
+ return fail6(new HttpServerError({
39799
+ reason: new RouteNotFound({
39800
+ request: request3
39801
+ })
39802
+ }));
39803
+ }
39804
+ const route = result6.handler;
39805
+ if (isSome2(route.prefix)) {
39806
+ context3 = add(context3, HttpServerRequest, sliceRequestUrl(request3, route.prefix.value));
39807
+ }
39808
+ context3 = add(context3, ParsedSearchParams, result6.searchParams);
39809
+ context3 = add(context3, RouteContext, {
39810
+ route,
39811
+ params: result6.params
39812
+ });
39813
+ if (fiber3.getRef(Tracer) !== nativeTracer) {
39814
+ const span3 = getOrUndefined2(context3, ParentSpan);
39815
+ if (span3 !== undefined && span3._tag === "Span" && span3.sampled) {
39816
+ span3.attribute("http.route", route.path);
39817
+ }
39818
+ }
39819
+ fiber3.setContext(context3);
39820
+ if (!route.uninterruptible) {
39821
+ const interrupted = fiberEnterInterruptibleUnsafe(fiber3);
39822
+ if (interrupted !== undefined)
39823
+ return interrupted;
39824
+ }
39825
+ return route.handler;
39826
+ });
39827
+ if (middleware.size === 0)
39828
+ return handler;
39829
+ for (const fn5 of reverse(middleware)) {
39830
+ handler = fn5(handler);
39831
+ }
39832
+ return handler;
39833
+ }
39834
+ });
39835
+ });
39836
+ function sliceRequestUrl(request3, prefix3) {
39837
+ const prefexLen = prefix3.length;
39838
+ return request3.modify({
39839
+ url: request3.url.length <= prefexLen ? "/" : request3.url.slice(prefexLen)
39840
+ });
39841
+ }
39842
+ var RouterConfig = /* @__PURE__ */ Reference("effect/http/HttpRouter/RouterConfig", {
39843
+ defaultValue: () => ({})
39844
+ });
39845
+
39846
+ class RouteContext extends (/* @__PURE__ */ Service()("effect/http/HttpRouter/RouteContext")) {
39847
+ }
39848
+ var params = /* @__PURE__ */ withFiberSucceed2((fiber3) => getUnsafe(fiber3.context, RouteContext).params);
39849
+ var schemaJson3 = (schema2, options3) => {
39850
+ const parse4 = decodeUnknownEffect2(schema2);
39851
+ const parseBody = schemaBodyJson2(Unknown2, options3);
39852
+ return contextWith2((context3) => {
39853
+ const request3 = get(context3, HttpServerRequest);
39854
+ const searchParams = get(context3, ParsedSearchParams);
39855
+ const routeContext = get(context3, RouteContext);
39856
+ return flatMap6(parseBody(request3), (body) => parse4({
39857
+ method: request3.method,
39858
+ url: request3.url,
39859
+ headers: request3.headers,
39860
+ cookies: request3.cookies,
39861
+ pathParams: routeContext.params,
39862
+ searchParams,
39863
+ body
39864
+ }, options3));
39865
+ });
39866
+ };
39867
+ var schemaNoBody = (schema2, options3) => {
39868
+ const parse4 = decodeUnknownEffect2(schema2);
39869
+ return contextWith2((context3) => {
39870
+ const request3 = get(context3, HttpServerRequest);
39871
+ const searchParams = get(context3, ParsedSearchParams);
39872
+ const routeContext = get(context3, RouteContext);
39873
+ return parse4({
39874
+ method: request3.method,
39875
+ url: request3.url,
39876
+ headers: request3.headers,
39877
+ cookies: request3.cookies,
39878
+ pathParams: routeContext.params,
39879
+ searchParams
39880
+ }, options3);
39881
+ });
39882
+ };
39883
+ var schemaParams = (schema2, options3) => {
39884
+ const parse4 = decodeUnknownEffect2(schema2);
39885
+ return contextWith2((context3) => {
39886
+ const searchParams = get(context3, ParsedSearchParams);
39887
+ const routeContext = get(context3, RouteContext);
39888
+ return parse4({
39889
+ ...searchParams,
39890
+ ...routeContext.params
39891
+ }, options3);
39892
+ });
39893
+ };
39894
+ var schemaPathParams = (schema2, options3) => {
39895
+ const parse4 = decodeUnknownEffect2(schema2);
39896
+ return flatMap6(params, (_) => parse4(_, options3));
39897
+ };
39898
+ var use = (f) => effectDiscard(flatMap6(HttpRouter, f));
39899
+ var add5 = (method, path, handler, options3) => use((router) => router.add(method, path, handler, options3));
39900
+ var addAll = (routes, options3) => effectDiscard(gen4(function* () {
39901
+ const toAdd = isEffect2(routes) ? yield* routes : routes;
39902
+ let router = yield* HttpRouter;
39903
+ if (options3?.prefix) {
39904
+ router = router.prefixed(options3.prefix);
39905
+ }
39906
+ yield* router.addAll(toAdd);
39907
+ }));
39908
+ var layer15 = /* @__PURE__ */ effect(HttpRouter)(make61);
39909
+ var toHttpEffect = (appLayer) => contextWith2((context3) => {
39910
+ const scope3 = get(context3, Scope);
39911
+ const memoMap = CurrentMemoMap.forkOrCreate(context3);
39912
+ return map9(buildWithMemoMap(provideMerge(appLayer, layer15), memoMap, scope3), (context4) => {
39913
+ const router = get(context4, HttpRouter);
39914
+ return router.asHttpEffect();
39915
+ });
39916
+ });
39917
+ var RouteTypeId = "~effect/http/HttpRouter/Route";
39918
+ var makeRoute = (options3) => ({
39919
+ ...options3,
39920
+ uninterruptible: options3.uninterruptible ?? false,
39921
+ prefix: typeof options3.prefix === "string" ? some3(options3.prefix) : options3.prefix ?? none2(),
39922
+ [RouteTypeId]: RouteTypeId
39923
+ });
39924
+ var route = (method, path, handler, options3) => makeRoute({
39925
+ ...options3,
39926
+ method,
39927
+ path,
39928
+ handler: isHttpServerResponse(handler) ? succeed6(handler) : isEffect2(handler) ? handler : flatMap6(HttpServerRequest, handler),
39929
+ uninterruptible: options3?.uninterruptible ?? false
39930
+ });
39931
+ var removeTrailingSlash = (path) => path.endsWith("/") ? path.slice(0, -1) : path;
39932
+ var prefixPath = /* @__PURE__ */ dual(2, (self, prefix3) => {
39933
+ prefix3 = removeTrailingSlash(prefix3);
39934
+ if (self === "*")
39935
+ return `${prefix3}/*`;
39936
+ else if (self === "/")
39937
+ return prefix3;
39938
+ return prefix3 + self;
39939
+ });
39940
+ var prefixRoute = /* @__PURE__ */ dual(2, (self, prefix3) => makeRoute({
39941
+ ...self,
39942
+ path: prefixPath(self.path, prefix3),
39943
+ prefix: match(self.prefix, {
39944
+ onNone: () => removeTrailingSlash(prefix3),
39945
+ onSome: (existingPrefix) => prefixPath(existingPrefix, prefix3)
39946
+ })
39947
+ }));
39948
+ var MiddlewareTypeId = "~effect/http/HttpRouter/Middleware";
39949
+ var middleware = function() {
39950
+ if (arguments.length === 0) {
39951
+ return makeMiddleware;
39952
+ }
39953
+ return makeMiddleware(arguments[0], arguments[1]);
39954
+ };
39955
+ var makeMiddleware = (middleware2, options3) => options3?.global ? effectDiscard(gen4(function* () {
39956
+ const router = yield* HttpRouter;
39957
+ const fn5 = isEffect2(middleware2) ? yield* middleware2 : middleware2;
39958
+ yield* router.addGlobalMiddleware(fn5);
39959
+ })) : new MiddlewareImpl(isEffect2(middleware2) ? effectContext(map9(middleware2, (fn5) => makeUnsafe(new Map([[fnContextKey, fn5]])))) : succeedContext(makeUnsafe(new Map([[fnContextKey, middleware2]]))));
39960
+ var middlewareId = 0;
39961
+ var fnContextKey = "effect/http/HttpRouter/MiddlewareFn";
39962
+
39963
+ class MiddlewareImpl {
39964
+ [MiddlewareTypeId] = {};
39965
+ layerFn;
39966
+ dependencies;
39967
+ constructor(layerFn, dependencies) {
39968
+ this.layerFn = layerFn;
39969
+ this.dependencies = dependencies;
39970
+ const contextKey = `effect/http/HttpRouter/Middleware-${++middlewareId}`;
39971
+ this.layer = effectContext(gen4({
39972
+ self: this
39973
+ }, function* () {
39974
+ const context3 = yield* context2();
39975
+ const stack = [getOrUndefinedUnsafe(context3, fnContextKey)];
39976
+ if (this.dependencies) {
39977
+ const memoMap = yield* CurrentMemoMap;
39978
+ const scope3 = get(context3, Scope);
39979
+ const depsContext = yield* buildWithMemoMap(this.dependencies, memoMap, scope3);
39980
+ stack.push(...getMiddleware(depsContext));
39981
+ }
39982
+ return makeUnsafe(new Map([[contextKey, stack]]));
39983
+ })).pipe(provide2(this.layerFn));
39984
+ }
39985
+ layer;
39986
+ combine(other) {
39987
+ return new MiddlewareImpl(this.layerFn, this.dependencies ? provideMerge(this.dependencies, other.layer) : other.layer);
39988
+ }
39989
+ }
39990
+ var middlewareCache = /* @__PURE__ */ new WeakMap;
39991
+ var getMiddleware = (context3) => {
39992
+ let arr = middlewareCache.get(context3);
39993
+ if (arr)
39994
+ return arr;
39995
+ const topLevel = empty3();
39996
+ let maxLength = 0;
39997
+ for (const [key, value5] of context3.mapUnsafe) {
39998
+ if (key.startsWith("effect/http/HttpRouter/Middleware-")) {
39999
+ topLevel.push(value5);
40000
+ if (value5.length > maxLength) {
40001
+ maxLength = value5.length;
40002
+ }
40003
+ }
40004
+ }
40005
+ if (topLevel.length === 0) {
40006
+ arr = [];
40007
+ } else {
40008
+ const middleware2 = new Set;
40009
+ for (let i = maxLength - 1;i >= 0; i--) {
40010
+ for (const arr2 of topLevel) {
40011
+ if (i < arr2.length) {
40012
+ middleware2.add(arr2[i]);
40013
+ }
40014
+ }
40015
+ }
40016
+ arr = fromIterable2(middleware2).reverse();
40017
+ }
40018
+ middlewareCache.set(context3, arr);
40019
+ return arr;
40020
+ };
40021
+ var cors2 = (options3) => middleware(cors(options3), {
40022
+ global: true
40023
+ });
40024
+ var disableLogger = middleware(withLoggerDisabled).layer;
40025
+ var provideRequest = (layer16) => (self) => provide2(self, middleware()(gen4(function* () {
40026
+ const services = yield* build(layer16);
40027
+ return (effect2) => provideContext2(effect2, services);
40028
+ })).layer);
40029
+ var serve2 = (appLayer, options3) => {
40030
+ let middleware2 = options3?.middleware;
40031
+ if (options3?.disableLogger !== true) {
40032
+ middleware2 = middleware2 ? compose(middleware2, logger) : logger;
40033
+ }
40034
+ const layerWithRouter = provideMerge(appLayer, options3?.routerConfig ? provide2(layer15, succeed5(RouterConfig)(options3.routerConfig)) : layer15);
40035
+ return contextWith2((context3) => {
40036
+ const memoMap = CurrentMemoMap.forkOrCreate(context3);
40037
+ return buildWithMemoMap(layerWithRouter, memoMap, get(context3, Scope));
40038
+ }).pipe(map9((context3) => {
40039
+ const router = get(context3, HttpRouter);
40040
+ const handler = router.asHttpEffect();
40041
+ return merge3(middleware2 ? serve(handler, middleware2) : serve(handler), succeedContext(context3));
40042
+ }), unwrap, options3?.disableListenLog ? identity : withLogAddress);
40043
+ };
40044
+ var toWebHandler = (appLayer, options3) => {
40045
+ let middleware2 = options3?.middleware;
40046
+ if (options3?.disableLogger !== true) {
40047
+ middleware2 = middleware2 ? compose(middleware2, logger) : logger;
40048
+ }
40049
+ const RouterLayer = options3?.routerConfig ? provide2(layer15, succeed5(RouterConfig)(options3.routerConfig)) : layer15;
40050
+ return toWebHandlerLayerWith(provideMerge(appLayer, RouterLayer), {
40051
+ toHandler: (s) => succeed6(get(s, HttpRouter).asHttpEffect()),
40052
+ middleware: middleware2,
40053
+ memoMap: options3?.memoMap
40054
+ });
40055
+ };
38232
40056
  // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/cli/Argument.js
38233
40057
  var exports_Argument = {};
38234
40058
  __export(exports_Argument, {
@@ -38281,15 +40105,15 @@ __export(exports_CliError, {
38281
40105
  InvalidValue: () => InvalidValue2,
38282
40106
  DuplicateOption: () => DuplicateOption
38283
40107
  });
38284
- var TypeId61 = "~effect/cli/CliError";
38285
- var isCliError = (u) => hasProperty(u, TypeId61);
40108
+ var TypeId62 = "~effect/cli/CliError";
40109
+ var isCliError = (u) => hasProperty(u, TypeId62);
38286
40110
 
38287
- class UnrecognizedOption extends (/* @__PURE__ */ TaggedError3(`${TypeId61}/UnrecognizedOption`)("UnrecognizedOption", {
40111
+ class UnrecognizedOption extends (/* @__PURE__ */ TaggedError3(`${TypeId62}/UnrecognizedOption`)("UnrecognizedOption", {
38288
40112
  option: String7,
38289
40113
  command: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(String7)),
38290
40114
  suggestions: /* @__PURE__ */ ArraySchema(String7)
38291
40115
  })) {
38292
- [TypeId61] = TypeId61;
40116
+ [TypeId62] = TypeId62;
38293
40117
  get message() {
38294
40118
  const suggestionText = this.suggestions.length > 0 ? `
38295
40119
 
@@ -38301,52 +40125,52 @@ class UnrecognizedOption extends (/* @__PURE__ */ TaggedError3(`${TypeId61}/Unre
38301
40125
  }
38302
40126
  }
38303
40127
 
38304
- class DuplicateOption extends (/* @__PURE__ */ TaggedError3(`${TypeId61}/DuplicateOption`)("DuplicateOption", {
40128
+ class DuplicateOption extends (/* @__PURE__ */ TaggedError3(`${TypeId62}/DuplicateOption`)("DuplicateOption", {
38305
40129
  option: String7,
38306
40130
  parentCommand: String7,
38307
40131
  childCommand: String7
38308
40132
  })) {
38309
- [TypeId61] = TypeId61;
40133
+ [TypeId62] = TypeId62;
38310
40134
  get message() {
38311
40135
  return `Duplicate flag name "${this.option}" in parent command "${this.parentCommand}" and subcommand "${this.childCommand}". ` + `Parent will always claim this flag (Mode A semantics). Consider renaming one of them to avoid confusion.`;
38312
40136
  }
38313
40137
  }
38314
40138
 
38315
- class MissingOption extends (/* @__PURE__ */ TaggedError3(`${TypeId61}/MissingOption`)("MissingOption", {
40139
+ class MissingOption extends (/* @__PURE__ */ TaggedError3(`${TypeId62}/MissingOption`)("MissingOption", {
38316
40140
  option: String7
38317
40141
  })) {
38318
- [TypeId61] = TypeId61;
40142
+ [TypeId62] = TypeId62;
38319
40143
  get message() {
38320
40144
  return `Missing required flag: --${this.option}`;
38321
40145
  }
38322
40146
  }
38323
40147
 
38324
- class MissingArgument extends (/* @__PURE__ */ TaggedError3(`${TypeId61}/MissingArgument`)("MissingArgument", {
40148
+ class MissingArgument extends (/* @__PURE__ */ TaggedError3(`${TypeId62}/MissingArgument`)("MissingArgument", {
38325
40149
  argument: String7
38326
40150
  })) {
38327
- [TypeId61] = TypeId61;
40151
+ [TypeId62] = TypeId62;
38328
40152
  get message() {
38329
40153
  return `Missing required argument: ${this.argument}`;
38330
40154
  }
38331
40155
  }
38332
40156
 
38333
- class UnexpectedArgument extends (/* @__PURE__ */ TaggedError3(`${TypeId61}/UnexpectedArgument`)("UnexpectedArgument", {
40157
+ class UnexpectedArgument extends (/* @__PURE__ */ TaggedError3(`${TypeId62}/UnexpectedArgument`)("UnexpectedArgument", {
38334
40158
  arguments: /* @__PURE__ */ ArraySchema(String7)
38335
40159
  })) {
38336
- [TypeId61] = TypeId61;
40160
+ [TypeId62] = TypeId62;
38337
40161
  get message() {
38338
40162
  const label = this.arguments.length === 1 ? "argument" : "arguments";
38339
40163
  return `Unexpected positional ${label}: ${this.arguments.map((value5) => JSON.stringify(value5)).join(", ")}`;
38340
40164
  }
38341
40165
  }
38342
40166
 
38343
- class InvalidValue2 extends (/* @__PURE__ */ TaggedError3(`${TypeId61}/InvalidValue`)("InvalidValue", {
40167
+ class InvalidValue2 extends (/* @__PURE__ */ TaggedError3(`${TypeId62}/InvalidValue`)("InvalidValue", {
38344
40168
  option: String7,
38345
40169
  value: String7,
38346
40170
  expected: String7,
38347
40171
  kind: /* @__PURE__ */ Union2([/* @__PURE__ */ Literal2("flag"), /* @__PURE__ */ Literal2("argument")])
38348
40172
  })) {
38349
- [TypeId61] = TypeId61;
40173
+ [TypeId62] = TypeId62;
38350
40174
  get message() {
38351
40175
  const expectation = this.expected.startsWith("Expected ") || this.expected.startsWith("Expected:") ? this.expected : `Expected: ${this.expected}`;
38352
40176
  if (this.kind === "argument") {
@@ -38359,12 +40183,12 @@ class InvalidValue2 extends (/* @__PURE__ */ TaggedError3(`${TypeId61}/InvalidVa
38359
40183
  }
38360
40184
  }
38361
40185
 
38362
- class UnknownSubcommand extends (/* @__PURE__ */ TaggedError3(`${TypeId61}/UnknownSubcommand`)("UnknownSubcommand", {
40186
+ class UnknownSubcommand extends (/* @__PURE__ */ TaggedError3(`${TypeId62}/UnknownSubcommand`)("UnknownSubcommand", {
38363
40187
  subcommand: String7,
38364
40188
  parent: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(String7)),
38365
40189
  suggestions: /* @__PURE__ */ ArraySchema(String7)
38366
40190
  })) {
38367
- [TypeId61] = TypeId61;
40191
+ [TypeId62] = TypeId62;
38368
40192
  get message() {
38369
40193
  const suggestionText = this.suggestions.length > 0 ? `
38370
40194
 
@@ -38375,11 +40199,11 @@ class UnknownSubcommand extends (/* @__PURE__ */ TaggedError3(`${TypeId61}/Unkno
38375
40199
  }
38376
40200
  }
38377
40201
 
38378
- class UserError extends (/* @__PURE__ */ TaggedError3(`${TypeId61}/UserError`)("UserError", {
40202
+ class UserError extends (/* @__PURE__ */ TaggedError3(`${TypeId62}/UserError`)("UserError", {
38379
40203
  cause: /* @__PURE__ */ Defect(),
38380
40204
  userMessage: /* @__PURE__ */ optionalKey2(String7)
38381
40205
  })) {
38382
- [TypeId61] = TypeId61;
40206
+ [TypeId62] = TypeId62;
38383
40207
  [errorReported] = true;
38384
40208
  get message() {
38385
40209
  if (this.userMessage)
@@ -38393,11 +40217,11 @@ class UserError extends (/* @__PURE__ */ TaggedError3(`${TypeId61}/UserError`)("
38393
40217
  }
38394
40218
  var NonShowHelpErrors = /* @__PURE__ */ Union2([UnrecognizedOption, DuplicateOption, MissingOption, MissingArgument, UnexpectedArgument, InvalidValue2, UnknownSubcommand, UserError]);
38395
40219
 
38396
- class ShowHelp extends (/* @__PURE__ */ TaggedError3(`${TypeId61}/ShowHelp`)("ShowHelp", {
40220
+ class ShowHelp extends (/* @__PURE__ */ TaggedError3(`${TypeId62}/ShowHelp`)("ShowHelp", {
38397
40221
  commandPath: /* @__PURE__ */ ArraySchema(String7),
38398
40222
  errors: /* @__PURE__ */ ArraySchema(NonShowHelpErrors)
38399
40223
  })) {
38400
- [TypeId61] = TypeId61;
40224
+ [TypeId62] = TypeId62;
38401
40225
  [errorExitCode] = this.errors.length ? 1 : 0;
38402
40226
  [errorReported] = false;
38403
40227
  get message() {
@@ -38450,7 +40274,7 @@ var unquote = (input) => {
38450
40274
  }
38451
40275
  return output.trim();
38452
40276
  };
38453
- var parse3 = (input) => {
40277
+ var parse4 = (input) => {
38454
40278
  const output = Object.create(null);
38455
40279
  let current = output;
38456
40280
  const sectionPattern = /^\[([^\]]*)\]\s*$/;
@@ -38958,12 +40782,12 @@ class TomlParser {
38958
40782
  throw new SyntaxError(`${message} at line ${this.line}, column ${this.column}`);
38959
40783
  }
38960
40784
  }
38961
- var parse4 = (input) => new TomlParser(input.replace(/^\uFEFF/, "")).parse();
40785
+ var parse5 = (input) => new TomlParser(input.replace(/^\uFEFF/, "")).parse();
38962
40786
 
38963
40787
  // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/encoding/Yaml.js
38964
40788
  var exports_Yaml = {};
38965
40789
  __export(exports_Yaml, {
38966
- parse: () => parse5
40790
+ parse: () => parse6
38967
40791
  });
38968
40792
  var hasOwn3 = Object.prototype.hasOwnProperty;
38969
40793
  var setProperty = (record3, key, value5) => {
@@ -39521,7 +41345,7 @@ class YamlParser {
39521
41345
  throw new SyntaxError(`${message} at line ${line.number}`);
39522
41346
  }
39523
41347
  }
39524
- var parse5 = (input) => {
41348
+ var parse6 = (input) => {
39525
41349
  const source = input.replace(/^\uFEFF/, "").replace(/\r\n?/g, `
39526
41350
  `);
39527
41351
  const lines = source.split(`
@@ -39541,18 +41365,18 @@ var parse5 = (input) => {
39541
41365
  };
39542
41366
 
39543
41367
  // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/cli/Primitive.js
39544
- var TypeId62 = "~effect/cli/Primitive";
41368
+ var TypeId63 = "~effect/cli/Primitive";
39545
41369
  var Proto16 = {
39546
- [TypeId62]: {
41370
+ [TypeId63]: {
39547
41371
  _A: identity
39548
41372
  }
39549
41373
  };
39550
41374
  var isTrueLiteral = /* @__PURE__ */ is2(TrueLiterals);
39551
41375
  var isFalseLiteral = /* @__PURE__ */ is2(FalseLiterals);
39552
41376
  var isBoolean3 = (p) => p._tag === "Boolean";
39553
- var makePrimitive2 = (tag4, parse6) => Object.assign(Object.create(Proto16), {
41377
+ var makePrimitive2 = (tag4, parse7) => Object.assign(Object.create(Proto16), {
39554
41378
  _tag: tag4,
39555
- parse: parse6
41379
+ parse: parse7
39556
41380
  });
39557
41381
  var makeSchemaPrimitive = (tag4, schema2) => {
39558
41382
  const toCodecStringTree3 = toCodecStringTree2(schema2);
@@ -39618,11 +41442,11 @@ var FileText = /* @__PURE__ */ makePrimitive2("FileText", /* @__PURE__ */ fnUntr
39618
41442
  return content;
39619
41443
  }));
39620
41444
  var fileParsers = {
39621
- ini: (content) => parse3(content),
41445
+ ini: (content) => parse4(content),
39622
41446
  json: (content) => JSON.parse(content),
39623
- toml: (content) => parse4(content),
39624
- yml: (content) => parse5(content),
39625
- yaml: (content) => parse5(content)
41447
+ toml: (content) => parse5(content),
41448
+ yml: (content) => parse6(content),
41449
+ yaml: (content) => parse6(content)
39626
41450
  };
39627
41451
  var FileParse = (options3) => {
39628
41452
  return makePrimitive2("FileParse", fnUntraced2(function* (filePath) {
@@ -39764,8 +41588,8 @@ var eraseLines = (rows) => {
39764
41588
  };
39765
41589
 
39766
41590
  // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/cli/Prompt.js
39767
- var TypeId63 = "~effect/cli/Prompt";
39768
- var isPrompt = (u) => hasProperty(u, TypeId63);
41591
+ var TypeId64 = "~effect/cli/Prompt";
41592
+ var isPrompt = (u) => hasProperty(u, TypeId64);
39769
41593
  var defaultTheme = {
39770
41594
  prefix: "?",
39771
41595
  arrowUp: "↑",
@@ -40011,7 +41835,7 @@ var proto = {
40011
41835
  return run3(this);
40012
41836
  }
40013
41837
  }),
40014
- [TypeId63]: {
41838
+ [TypeId64]: {
40015
41839
  _Output: (_) => _
40016
41840
  }
40017
41841
  };
@@ -40408,11 +42232,11 @@ class DatePart {
40408
42232
  date;
40409
42233
  parts;
40410
42234
  locales;
40411
- constructor(params) {
40412
- this.token = params.token;
40413
- this.locales = params.locales;
40414
- this.date = params.date || new globalThis.Date;
40415
- this.parts = params.parts || [this];
42235
+ constructor(params2) {
42236
+ this.token = params2.token;
42237
+ this.locales = params2.locales;
42238
+ this.date = params2.date || new globalThis.Date;
42239
+ this.parts = params2.parts || [this];
40416
42240
  }
40417
42241
  isToken() {
40418
42242
  return false;
@@ -41422,28 +43246,28 @@ var entriesToDisplay = (cursor, total, maxVisible) => {
41422
43246
  };
41423
43247
 
41424
43248
  // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/cli/Param.js
41425
- var TypeId64 = "~effect/cli/Param";
43249
+ var TypeId65 = "~effect/cli/Param";
41426
43250
  var argumentKind = "argument";
41427
43251
  var flagKind = "flag";
41428
43252
  var Proto17 = {
41429
- [TypeId64]: {
43253
+ [TypeId65]: {
41430
43254
  _A: identity
41431
43255
  },
41432
43256
  pipe() {
41433
43257
  return pipeArguments(this, arguments);
41434
43258
  }
41435
43259
  };
41436
- var isParam = (u) => hasProperty(u, TypeId64);
43260
+ var isParam = (u) => hasProperty(u, TypeId65);
41437
43261
  var isFlagParam = (single) => single.kind === "flag";
41438
- var makeSingle2 = (params) => {
41439
- const parse6 = (args2) => params.kind === argumentKind ? parsePositional(params.name, params.primitiveType, args2) : parseFlag(params.name, params.primitiveType, args2);
43262
+ var makeSingle2 = (params2) => {
43263
+ const parse7 = (args2) => params2.kind === argumentKind ? parsePositional(params2.name, params2.primitiveType, args2) : parseFlag(params2.name, params2.primitiveType, args2);
41440
43264
  return Object.setPrototypeOf({
41441
43265
  _tag: "Single",
41442
- ...params,
41443
- description: params.description ?? none2(),
41444
- aliases: params.aliases ?? [],
41445
- hidden: params.hidden ?? false,
41446
- parse: parse6
43266
+ ...params2,
43267
+ description: params2.description ?? none2(),
43268
+ aliases: params2.aliases ?? [],
43269
+ hidden: params2.hidden ?? false,
43270
+ parse: parse7
41447
43271
  }, Proto17);
41448
43272
  };
41449
43273
  var String12 = (kind, name) => makeSingle2({
@@ -41546,13 +43370,13 @@ var withHidden = (self) => transformSingle(self, (single) => makeSingle2({
41546
43370
  hidden: true
41547
43371
  }));
41548
43372
  var map17 = /* @__PURE__ */ dual(2, (self, f) => {
41549
- const parse6 = (args2) => map9(self.parse(args2), ([operands, value5]) => [operands, f(value5)]);
43373
+ const parse7 = (args2) => map9(self.parse(args2), ([operands, value5]) => [operands, f(value5)]);
41550
43374
  return Object.assign(Object.create(Proto17), {
41551
43375
  _tag: "Map",
41552
43376
  kind: self.kind,
41553
43377
  param: self,
41554
43378
  f,
41555
- parse: parse6
43379
+ parse: parse7
41556
43380
  });
41557
43381
  });
41558
43382
  var transform5 = (self, f, alternatives = []) => {
@@ -41566,10 +43390,10 @@ var transform5 = (self, f, alternatives = []) => {
41566
43390
  parse: f(self.parse, alternativeParsers)
41567
43391
  });
41568
43392
  };
41569
- var mapEffect4 = /* @__PURE__ */ dual(2, (self, f) => transform5(self, (parse6) => (args2) => flatMap6(parse6(args2), ([leftover, a]) => f(a).pipe(map9((b) => [leftover, b])))));
43393
+ var mapEffect4 = /* @__PURE__ */ dual(2, (self, f) => transform5(self, (parse7) => (args2) => flatMap6(parse7(args2), ([leftover, a]) => f(a).pipe(map9((b) => [leftover, b])))));
41570
43394
  var mapTryCatch = /* @__PURE__ */ dual(3, (self, f, onError5) => {
41571
43395
  const single = getUnderlyingSingleOrThrow(self);
41572
- return transform5(self, (parse6) => (args2) => flatMap6(parse6(args2), ([leftover, a]) => try_3({
43396
+ return transform5(self, (parse7) => (args2) => flatMap6(parse7(args2), ([leftover, a]) => try_3({
41573
43397
  try: () => f(a),
41574
43398
  catch: (error2) => onError5(error2)
41575
43399
  }).pipe(mapError4((error2) => new InvalidValue2({
@@ -41580,7 +43404,7 @@ var mapTryCatch = /* @__PURE__ */ dual(3, (self, f, onError5) => {
41580
43404
  })), map9((b) => [leftover, b]))));
41581
43405
  });
41582
43406
  var optional3 = (param) => {
41583
- const parse6 = (args2) => param.parse(args2).pipe(map9(([leftover, value5]) => [leftover, some3(value5)]), catchTags2({
43407
+ const parse7 = (args2) => param.parse(args2).pipe(map9(([leftover, value5]) => [leftover, some3(value5)]), catchTags2({
41584
43408
  MissingOption: () => succeed6([args2.arguments, none2()]),
41585
43409
  MissingArgument: () => succeed6([args2.arguments, none2()])
41586
43410
  }));
@@ -41588,7 +43412,7 @@ var optional3 = (param) => {
41588
43412
  _tag: "Optional",
41589
43413
  kind: param.kind,
41590
43414
  param,
41591
- parse: parse6
43415
+ parse: parse7
41592
43416
  });
41593
43417
  };
41594
43418
  var withDefault4 = /* @__PURE__ */ dual(2, (self, defaultValue) => {
@@ -41611,15 +43435,15 @@ var withFallbackConfig = /* @__PURE__ */ dual(2, (self, config) => {
41611
43435
  onNone: () => fail6(error2),
41612
43436
  onSome: (value5) => succeed6([args2.arguments, value5])
41613
43437
  })));
41614
- return transform5(self, (parse6) => (args2) => parse6(args2).pipe(catchTag3(["MissingOption", "MissingArgument"], (error2) => runConfig(error2, args2))));
43438
+ return transform5(self, (parse7) => (args2) => parse7(args2).pipe(catchTag3(["MissingOption", "MissingArgument"], (error2) => runConfig(error2, args2))));
41615
43439
  });
41616
43440
  var withFallbackPrompt = /* @__PURE__ */ dual(2, (self, prompt) => {
41617
43441
  const runPrompt = (error2, args2) => flatMap6(isPrompt(prompt) ? succeed6(prompt) : prompt, run3).pipe(map9((value5) => [args2.arguments, value5]), catchTag3("QuitError", () => fail6(error2)));
41618
- return transform5(self, (parse6) => (args2) => parse6(args2).pipe(catchTag3(["MissingOption", "MissingArgument"], (error2) => runPrompt(error2, args2))));
43442
+ return transform5(self, (parse7) => (args2) => parse7(args2).pipe(catchTag3(["MissingOption", "MissingArgument"], (error2) => runPrompt(error2, args2))));
41619
43443
  });
41620
43444
  var variadic = (self, options3) => {
41621
43445
  const single = getUnderlyingSingleOrThrow(self);
41622
- const parse6 = (args2) => {
43446
+ const parse7 = (args2) => {
41623
43447
  if (single.kind === "argument") {
41624
43448
  return parsePositionalVariadic(self, single, args2, options3);
41625
43449
  } else {
@@ -41632,7 +43456,7 @@ var variadic = (self, options3) => {
41632
43456
  param: self,
41633
43457
  min: fromUndefinedOr(options3?.min),
41634
43458
  max: fromUndefinedOr(options3?.max),
41635
- parse: parse6
43459
+ parse: parse7
41636
43460
  });
41637
43461
  };
41638
43462
  var between5 = /* @__PURE__ */ dual(3, (self, min9, max9) => {
@@ -41693,9 +43517,9 @@ var withSchema = /* @__PURE__ */ dual(2, (self, schema2) => {
41693
43517
  });
41694
43518
  }));
41695
43519
  });
41696
- var orElse6 = /* @__PURE__ */ dual(2, (self, orElse7) => transform5(self, (parse6, alternatives) => (args2) => catch_3(parse6(args2), () => alternatives[0]()(args2)), [orElse7]));
43520
+ var orElse6 = /* @__PURE__ */ dual(2, (self, orElse7) => transform5(self, (parse7, alternatives) => (args2) => catch_3(parse7(args2), () => alternatives[0]()(args2)), [orElse7]));
41697
43521
  var orElseResult2 = /* @__PURE__ */ dual(2, (self, orElse7) => {
41698
- return transform5(self, (parse6, alternatives) => (args2) => catch_3(map9(parse6(args2), ([leftover, value5]) => [leftover, succeed2(value5)]), () => map9(alternatives[0]()(args2), ([leftover, value5]) => [leftover, fail2(value5)])), [orElse7]);
43522
+ return transform5(self, (parse7, alternatives) => (args2) => catch_3(map9(parse7(args2), ([leftover, value5]) => [leftover, succeed2(value5)]), () => map9(alternatives[0]()(args2), ([leftover, value5]) => [leftover, fail2(value5)])), [orElse7]);
41699
43523
  });
41700
43524
  var parsePositional = /* @__PURE__ */ fnUntraced2(function* (name, primitiveType, args2) {
41701
43525
  if (args2.arguments.length === 0) {
@@ -41910,7 +43734,7 @@ __export(exports_Command, {
41910
43734
  provideEffectDiscard: () => provideEffectDiscard,
41911
43735
  provideEffect: () => provideEffect,
41912
43736
  provide: () => provide7,
41913
- make: () => make58,
43737
+ make: () => make62,
41914
43738
  isCommand: () => isCommand2,
41915
43739
  annotateMerge: () => annotateMerge,
41916
43740
  annotate: () => annotate5
@@ -43147,7 +44971,7 @@ var parseConfig = (config) => {
43147
44971
  const orderedParams = [];
43148
44972
  const flags = [];
43149
44973
  const args2 = [];
43150
- function parse6(config2) {
44974
+ function parse7(config2) {
43151
44975
  const tree = Object.create(null);
43152
44976
  for (const key of Object.keys(config2)) {
43153
44977
  tree[key] = parseValue(config2[key]);
@@ -43175,7 +44999,7 @@ var parseConfig = (config) => {
43175
44999
  } else {
43176
45000
  return {
43177
45001
  _tag: "Nested",
43178
- tree: parse6(value5)
45002
+ tree: parse7(value5)
43179
45003
  };
43180
45004
  }
43181
45005
  }
@@ -43184,7 +45008,7 @@ var parseConfig = (config) => {
43184
45008
  flags,
43185
45009
  arguments: args2,
43186
45010
  orderedParams,
43187
- tree: parse6(config)
45011
+ tree: parse7(config)
43188
45012
  };
43189
45013
  };
43190
45014
  var emptyConfig = /* @__PURE__ */ parseConfig({});
@@ -43243,7 +45067,7 @@ var reconstructTree = (tree, results2) => {
43243
45067
  };
43244
45068
 
43245
45069
  // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/cli/internal/command.js
43246
- var TypeId65 = "~effect/cli/Command";
45070
+ var TypeId66 = "~effect/cli/Command";
43247
45071
  var toImpl2 = (self) => self;
43248
45072
  var Proto18 = {
43249
45073
  .../* @__PURE__ */ Prototype2({
@@ -43256,7 +45080,7 @@ var Proto18 = {
43256
45080
  var makeCommand = (options3) => {
43257
45081
  const config = options3.config;
43258
45082
  const contextConfig = options3.contextConfig ?? emptyConfig;
43259
- const service4 = options3.service ?? Service(`${TypeId65}/${options3.name}`);
45083
+ const service4 = options3.service ?? Service(`${TypeId66}/${options3.name}`);
43260
45084
  const annotations2 = options3.annotations ?? empty();
43261
45085
  const globalFlags = options3.globalFlags ?? [];
43262
45086
  const subcommands = options3.subcommands ?? [];
@@ -43264,7 +45088,7 @@ var makeCommand = (options3) => {
43264
45088
  commandPath,
43265
45089
  errors: []
43266
45090
  }));
43267
- const parse6 = options3.parse ?? makeParser(config);
45091
+ const parse7 = options3.parse ?? makeParser(config);
43268
45092
  const parseContext = options3.parseContext ?? makeParser(contextConfig, {
43269
45093
  allowLeftovers: true
43270
45094
  });
@@ -43335,7 +45159,7 @@ var makeCommand = (options3) => {
43335
45159
  };
43336
45160
  };
43337
45161
  return Object.assign(Object.create(Proto18), {
43338
- [TypeId65]: TypeId65,
45162
+ [TypeId66]: TypeId66,
43339
45163
  name: options3.name,
43340
45164
  examples: options3.examples ?? [],
43341
45165
  annotations: annotations2,
@@ -43345,7 +45169,7 @@ var makeCommand = (options3) => {
43345
45169
  config,
43346
45170
  contextConfig,
43347
45171
  service: service4,
43348
- parse: parse6,
45172
+ parse: parse7,
43349
45173
  parseContext,
43350
45174
  handle,
43351
45175
  buildHelpDoc,
@@ -43393,10 +45217,10 @@ var makeParser = (cfg, options3) => fnUntraced2(function* (input) {
43393
45217
  }
43394
45218
  return reconstructTree(cfg.tree, values4);
43395
45219
  });
43396
- var parseParams = /* @__PURE__ */ fnUntraced2(function* (parsedArgs, params) {
45220
+ var parseParams = /* @__PURE__ */ fnUntraced2(function* (parsedArgs, params2) {
43397
45221
  const results2 = [];
43398
45222
  let currentArguments = parsedArgs.arguments;
43399
- for (const option6 of params) {
45223
+ for (const option6 of params2) {
43400
45224
  const [remainingArguments, parsed] = yield* option6.parse({
43401
45225
  flags: parsedArgs.flags,
43402
45226
  arguments: currentArguments
@@ -43919,9 +45743,9 @@ var makeCursor = (tokens) => {
43919
45743
  rest: () => tokens.slice(i)
43920
45744
  };
43921
45745
  };
43922
- var createFlagRegistry = (params) => {
45746
+ var createFlagRegistry = (params2) => {
43923
45747
  const index2 = new Map;
43924
- for (const param of params) {
45748
+ for (const param of params2) {
43925
45749
  if (index2.has(param.name)) {
43926
45750
  throw new Error(`Duplicate flag name "${param.name}" in command definition`);
43927
45751
  }
@@ -43934,7 +45758,7 @@ var createFlagRegistry = (params) => {
43934
45758
  }
43935
45759
  }
43936
45760
  return {
43937
- params,
45761
+ params: params2,
43938
45762
  index: index2
43939
45763
  };
43940
45764
  };
@@ -43957,9 +45781,9 @@ var buildSubcommandIndex = (subcommands) => {
43957
45781
  }
43958
45782
  return index2;
43959
45783
  };
43960
- var createEmptyFlagMap = (params) => Object.fromEntries(params.map((p) => [p.name, []]));
43961
- var createFlagAccumulator = (params) => {
43962
- const map20 = createEmptyFlagMap(params);
45784
+ var createEmptyFlagMap = (params2) => Object.fromEntries(params2.map((p) => [p.name, []]));
45785
+ var createFlagAccumulator = (params2) => {
45786
+ const map20 = createEmptyFlagMap(params2);
43963
45787
  return {
43964
45788
  add: (name, raw3) => {
43965
45789
  if (raw3 !== undefined)
@@ -44227,10 +46051,10 @@ var consumeGlobalFlags = (tokens, command, registry) => {
44227
46051
  errors
44228
46052
  };
44229
46053
  };
44230
- var createUnrecognizedFlagError = (token, params, commandPath) => {
46054
+ var createUnrecognizedFlagError = (token, params2, commandPath) => {
44231
46055
  const printable = token._tag === "LongOption" ? `--${token.name}` : `-${token.flag}`;
44232
46056
  const validNames = [];
44233
- for (const p of params) {
46057
+ for (const p of params2) {
44234
46058
  if (p.hidden)
44235
46059
  continue;
44236
46060
  validNames.push(p.name);
@@ -44581,8 +46405,8 @@ var wrapCommand = (commandLine) => {
44581
46405
  var formatShellArg = (arg) => /^[A-Za-z0-9_./:@%+=,-]+$/.test(arg) ? arg : `'${arg.replaceAll("'", `'"'"'`)}'`;
44582
46406
 
44583
46407
  // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/cli/Command.js
44584
- var isCommand2 = (u) => hasProperty(u, TypeId65);
44585
- var make58 = (name, config, handler) => {
46408
+ var isCommand2 = (u) => hasProperty(u, TypeId66);
46409
+ var make62 = (name, config, handler) => {
44586
46410
  const parsedConfig = parseConfig(config ?? {});
44587
46411
  return makeCommand({
44588
46412
  name,
@@ -44645,7 +46469,7 @@ var withSubcommands = /* @__PURE__ */ dual(2, (self, subcommands) => {
44645
46469
  const impl = toImpl2(self);
44646
46470
  const byName = new Map(normalized.flat.map((s) => [s.name, toImpl2(s)]));
44647
46471
  const SubcommandStateSymbol = Symbol("effect/cli/SubcommandState");
44648
- const parse6 = fnUntraced2(function* (raw3) {
46472
+ const parse7 = fnUntraced2(function* (raw3) {
44649
46473
  if (isNone2(raw3.subcommand)) {
44650
46474
  return yield* impl.parse(raw3);
44651
46475
  }
@@ -44691,7 +46515,7 @@ var withSubcommands = /* @__PURE__ */ dual(2, (self, subcommands) => {
44691
46515
  examples: impl.examples,
44692
46516
  service: impl.service,
44693
46517
  subcommands: normalized.groups,
44694
- parse: parse6,
46518
+ parse: parse7,
44695
46519
  parseContext: impl.parseContext,
44696
46520
  handle
44697
46521
  });
@@ -44710,7 +46534,7 @@ var withSharedFlags = /* @__PURE__ */ dual(2, (self, sharedFlags) => {
44710
46534
  const parseShared = makeParser(sharedConfig, {
44711
46535
  allowLeftovers: true
44712
46536
  });
44713
- const parse6 = fnUntraced2(function* (raw3) {
46537
+ const parse7 = fnUntraced2(function* (raw3) {
44714
46538
  const base = yield* impl.parse(raw3);
44715
46539
  const shared = yield* parseShared(raw3);
44716
46540
  return {
@@ -44740,7 +46564,7 @@ var withSharedFlags = /* @__PURE__ */ dual(2, (self, sharedFlags) => {
44740
46564
  examples: impl.examples,
44741
46565
  service: impl.service,
44742
46566
  subcommands: impl.subcommands,
44743
- parse: parse6,
46567
+ parse: parse7,
44744
46568
  parseContext,
44745
46569
  handle
44746
46570
  });
@@ -44794,7 +46618,7 @@ var mapHandler = (self, f) => {
44794
46618
  handle: (input, path) => f(impl.handle(input, path), input)
44795
46619
  });
44796
46620
  };
44797
- var provide7 = /* @__PURE__ */ dual((args2) => isCommand2(args2[0]), (self, layer15, options3) => mapHandler(self, (handler, input) => provide4(handler, typeof layer15 === "function" ? layer15(input) : layer15, options3)));
46621
+ var provide7 = /* @__PURE__ */ dual((args2) => isCommand2(args2[0]), (self, layer16, options3) => mapHandler(self, (handler, input) => provide4(handler, typeof layer16 === "function" ? layer16(input) : layer16, options3)));
44798
46622
  var provideSync = /* @__PURE__ */ dual(3, (self, service4, implementation) => mapHandler(self, (handler, input) => provideService2(handler, service4, typeof implementation === "function" ? implementation(input) : implementation)));
44799
46623
  var provideEffect = /* @__PURE__ */ dual(3, (self, service4, effect2) => mapHandler(self, (handler, input) => provideServiceEffect2(handler, service4, typeof effect2 === "function" ? effect2(input) : effect2)));
44800
46624
  var provideEffectDiscard = /* @__PURE__ */ dual(2, (self, effect2) => mapHandler(self, (handler, input) => andThen4(typeof effect2 === "function" ? effect2(input) : effect2, handler)));
@@ -44961,7 +46785,7 @@ var runWith2 = (command, config) => {
44961
46785
  // package.json
44962
46786
  var package_default = {
44963
46787
  name: "ambral",
44964
- version: "0.4.0",
46788
+ version: "0.5.0",
44965
46789
  license: "UNLICENSED",
44966
46790
  type: "module",
44967
46791
  description: "The `ambral` command: signs in through the browser, then calls the platform API as that person.",
@@ -45039,7 +46863,7 @@ __export(exports_AuthApi, {
45039
46863
  var exports_HttpApi = {};
45040
46864
  __export(exports_HttpApi, {
45041
46865
  reflect: () => reflect,
45042
- make: () => make60,
46866
+ make: () => make64,
45043
46867
  isHttpApi: () => isHttpApi,
45044
46868
  getSlotParseOptions: () => getSlotParseOptions,
45045
46869
  SuccessParseOptions: () => SuccessParseOptions,
@@ -45060,7 +46884,7 @@ __export(exports_HttpApiEndpoint, {
45060
46884
  post: () => post3,
45061
46885
  patch: () => patch3,
45062
46886
  options: () => options3,
45063
- make: () => make59,
46887
+ make: () => make63,
45064
46888
  isHttpApiEndpoint: () => isHttpApiEndpoint,
45065
46889
  head: () => head6,
45066
46890
  getSuccessSchemas: () => getSuccessSchemas,
@@ -45070,100 +46894,6 @@ __export(exports_HttpApiEndpoint, {
45070
46894
  delete: () => del3
45071
46895
  });
45072
46896
 
45073
- // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/http/HttpMiddleware.js
45074
- var loggerDisabledRequests = /* @__PURE__ */ new WeakSet;
45075
- var withLoggerDisabled = (self) => withFiber2((fiber3) => {
45076
- const request3 = getUnsafe(fiber3.context, HttpServerRequest);
45077
- loggerDisabledRequests.add(request3.source);
45078
- return self;
45079
- });
45080
-
45081
- // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/http/HttpRouter.js
45082
- var HttpRouter2 = /* @__PURE__ */ Service("effect/http/HttpRouter");
45083
- var removeTrailingSlash = (path) => path.endsWith("/") ? path.slice(0, -1) : path;
45084
- var prefixPath = /* @__PURE__ */ dual(2, (self, prefix3) => {
45085
- prefix3 = removeTrailingSlash(prefix3);
45086
- if (self === "*")
45087
- return `${prefix3}/*`;
45088
- else if (self === "/")
45089
- return prefix3;
45090
- return prefix3 + self;
45091
- });
45092
- var MiddlewareTypeId = "~effect/http/HttpRouter/Middleware";
45093
- var middleware = function() {
45094
- if (arguments.length === 0) {
45095
- return makeMiddleware;
45096
- }
45097
- return makeMiddleware(arguments[0], arguments[1]);
45098
- };
45099
- var makeMiddleware = (middleware2, options3) => options3?.global ? effectDiscard(gen4(function* () {
45100
- const router = yield* HttpRouter2;
45101
- const fn5 = isEffect2(middleware2) ? yield* middleware2 : middleware2;
45102
- yield* router.addGlobalMiddleware(fn5);
45103
- })) : new MiddlewareImpl(isEffect2(middleware2) ? effectContext(map9(middleware2, (fn5) => makeUnsafe(new Map([[fnContextKey, fn5]])))) : succeedContext(makeUnsafe(new Map([[fnContextKey, middleware2]]))));
45104
- var middlewareId = 0;
45105
- var fnContextKey = "effect/http/HttpRouter/MiddlewareFn";
45106
-
45107
- class MiddlewareImpl {
45108
- [MiddlewareTypeId] = {};
45109
- layerFn;
45110
- dependencies;
45111
- constructor(layerFn, dependencies) {
45112
- this.layerFn = layerFn;
45113
- this.dependencies = dependencies;
45114
- const contextKey = `effect/http/HttpRouter/Middleware-${++middlewareId}`;
45115
- this.layer = effectContext(gen4({
45116
- self: this
45117
- }, function* () {
45118
- const context3 = yield* context2();
45119
- const stack = [getOrUndefinedUnsafe(context3, fnContextKey)];
45120
- if (this.dependencies) {
45121
- const memoMap = yield* CurrentMemoMap;
45122
- const scope3 = get(context3, Scope);
45123
- const depsContext = yield* buildWithMemoMap(this.dependencies, memoMap, scope3);
45124
- stack.push(...getMiddleware(depsContext));
45125
- }
45126
- return makeUnsafe(new Map([[contextKey, stack]]));
45127
- })).pipe(provide2(this.layerFn));
45128
- }
45129
- layer;
45130
- combine(other) {
45131
- return new MiddlewareImpl(this.layerFn, this.dependencies ? provideMerge(this.dependencies, other.layer) : other.layer);
45132
- }
45133
- }
45134
- var middlewareCache = /* @__PURE__ */ new WeakMap;
45135
- var getMiddleware = (context3) => {
45136
- let arr = middlewareCache.get(context3);
45137
- if (arr)
45138
- return arr;
45139
- const topLevel = empty3();
45140
- let maxLength = 0;
45141
- for (const [key, value5] of context3.mapUnsafe) {
45142
- if (key.startsWith("effect/http/HttpRouter/Middleware-")) {
45143
- topLevel.push(value5);
45144
- if (value5.length > maxLength) {
45145
- maxLength = value5.length;
45146
- }
45147
- }
45148
- }
45149
- if (topLevel.length === 0) {
45150
- arr = [];
45151
- } else {
45152
- const middleware2 = new Set;
45153
- for (let i = maxLength - 1;i >= 0; i--) {
45154
- for (const arr2 of topLevel) {
45155
- if (i < arr2.length) {
45156
- middleware2.add(arr2[i]);
45157
- }
45158
- }
45159
- }
45160
- arr = fromIterable2(middleware2).reverse();
45161
- }
45162
- middlewareCache.set(context3, arr);
45163
- return arr;
45164
- };
45165
- var disableLogger = middleware(withLoggerDisabled).layer;
45166
-
45167
46897
  // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/http-api/HttpApiSchema.js
45168
46898
  var exports_HttpApiSchema = {};
45169
46899
  __export(exports_HttpApiSchema, {
@@ -45200,7 +46930,7 @@ __export(exports_HttpApiSchema, {
45200
46930
  NoContent: () => NoContent,
45201
46931
  MultipartTypeId: () => MultipartTypeId,
45202
46932
  MultipartStreamTypeId: () => MultipartStreamTypeId,
45203
- Empty: () => Empty3,
46933
+ Empty: () => Empty4,
45204
46934
  Created: () => Created,
45205
46935
  Accepted: () => Accepted
45206
46936
  });
@@ -45499,10 +47229,10 @@ function status(code) {
45499
47229
  httpApiStatus: statusCode
45500
47230
  });
45501
47231
  }
45502
- var Empty3 = (code) => Void2.pipe(status(code));
45503
- var NoContent = /* @__PURE__ */ Empty3(204);
45504
- var Created = /* @__PURE__ */ Empty3(201);
45505
- var Accepted = /* @__PURE__ */ Empty3(202);
47232
+ var Empty4 = (code) => Void2.pipe(status(code));
47233
+ var NoContent = /* @__PURE__ */ Empty4(204);
47234
+ var Created = /* @__PURE__ */ Empty4(201);
47235
+ var Accepted = /* @__PURE__ */ Empty4(202);
45506
47236
  function asNoContent(options3) {
45507
47237
  return (self) => {
45508
47238
  return Void2.pipe(decodeTo2(toType2(self), transform2({
@@ -45735,8 +47465,8 @@ function normalize3(contentType) {
45735
47465
  }
45736
47466
 
45737
47467
  // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/http-api/HttpApiEndpoint.js
45738
- var TypeId66 = "~effect/http-api/HttpApiEndpoint";
45739
- var isHttpApiEndpoint = (u) => hasProperty(u, TypeId66);
47468
+ var TypeId67 = "~effect/http-api/HttpApiEndpoint";
47469
+ var isHttpApiEndpoint = (u) => hasProperty(u, TypeId67);
45740
47470
  function getPayloadSchemas(endpoint) {
45741
47471
  const result6 = [];
45742
47472
  for (const {
@@ -45762,7 +47492,7 @@ function getErrorSchemas(endpoint) {
45762
47492
  return Array.from(schemas);
45763
47493
  }
45764
47494
  var Proto19 = {
45765
- [TypeId66]: TypeId66,
47495
+ [TypeId67]: TypeId67,
45766
47496
  pipe() {
45767
47497
  return pipeArguments(this, arguments);
45768
47498
  },
@@ -45810,7 +47540,7 @@ function makeProto2(options3) {
45810
47540
  Object.setPrototypeOf(HttpApiEndpoint, Proto19);
45811
47541
  return Object.assign(HttpApiEndpoint, options3);
45812
47542
  }
45813
- var make59 = (method) => (identifier2, path, options3) => {
47543
+ var make63 = (method) => (identifier2, path, options3) => {
45814
47544
  const disableCodecs = options3?.disableCodecs ?? false;
45815
47545
  const transformStringTree = disableCodecs ? identity : toCodecStringTree2;
45816
47546
  return makeProto2({
@@ -45828,12 +47558,12 @@ var make59 = (method) => (identifier2, path, options3) => {
45828
47558
  disableCodecs
45829
47559
  });
45830
47560
  };
45831
- function ensureStruct(params, transform6) {
45832
- if (params === undefined)
47561
+ function ensureStruct(params2, transform6) {
47562
+ if (params2 === undefined)
45833
47563
  return;
45834
- if (isSchema(params))
45835
- return transform6(params);
45836
- return transform6(Struct4(params));
47564
+ if (isSchema(params2))
47565
+ return transform6(params2);
47566
+ return transform6(Struct4(params2));
45837
47567
  }
45838
47568
  function getPayload(payload, method, disableCodecs) {
45839
47569
  const result6 = new Map;
@@ -46059,20 +47789,20 @@ function transformPayload(schema2, method) {
46059
47789
  return schema2;
46060
47790
  }
46061
47791
  }
46062
- var get17 = /* @__PURE__ */ make59("GET");
46063
- var query3 = /* @__PURE__ */ make59("QUERY");
46064
- var post3 = /* @__PURE__ */ make59("POST");
46065
- var put3 = /* @__PURE__ */ make59("PUT");
46066
- var patch3 = /* @__PURE__ */ make59("PATCH");
46067
- var del3 = /* @__PURE__ */ make59("DELETE");
46068
- var head6 = /* @__PURE__ */ make59("HEAD");
46069
- var options3 = /* @__PURE__ */ make59("OPTIONS");
47792
+ var get17 = /* @__PURE__ */ make63("GET");
47793
+ var query3 = /* @__PURE__ */ make63("QUERY");
47794
+ var post3 = /* @__PURE__ */ make63("POST");
47795
+ var put3 = /* @__PURE__ */ make63("PUT");
47796
+ var patch3 = /* @__PURE__ */ make63("PATCH");
47797
+ var del3 = /* @__PURE__ */ make63("DELETE");
47798
+ var head6 = /* @__PURE__ */ make63("HEAD");
47799
+ var options3 = /* @__PURE__ */ make63("OPTIONS");
46070
47800
 
46071
47801
  // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/http-api/HttpApi.js
46072
- var TypeId67 = "~effect/http-api/HttpApi";
46073
- var isHttpApi = (u) => hasProperty(u, TypeId67);
47802
+ var TypeId68 = "~effect/http-api/HttpApi";
47803
+ var isHttpApi = (u) => hasProperty(u, TypeId68);
46074
47804
  var Proto20 = {
46075
- [TypeId67]: TypeId67,
47805
+ [TypeId68]: TypeId68,
46076
47806
  pipe() {
46077
47807
  return pipeArguments(this, arguments);
46078
47808
  },
@@ -46136,7 +47866,7 @@ var makeProto3 = (options4) => {
46136
47866
  Object.setPrototypeOf(HttpApi, Proto20);
46137
47867
  return Object.assign(HttpApi, options4);
46138
47868
  };
46139
- var make60 = (identifier2) => makeProto3({
47869
+ var make64 = (identifier2) => makeProto3({
46140
47870
  identifier: identifier2,
46141
47871
  groups: {},
46142
47872
  annotations: empty()
@@ -46169,9 +47899,9 @@ var reflect = (self, options4) => {
46169
47899
  };
46170
47900
  var extractResponseContent = (schemas, getStatus) => {
46171
47901
  const map20 = new Map;
46172
- schemas.forEach(add5);
47902
+ schemas.forEach(add6);
46173
47903
  return map20;
46174
- function add5(schema2) {
47904
+ function add6(schema2) {
46175
47905
  const body = isWithHeaders(schema2) ? schema2.schema : schema2;
46176
47906
  if (isStreamSchema(body))
46177
47907
  return;
@@ -46225,7 +47955,7 @@ __export(exports_HttpApiClient, {
46225
47955
  urlBuilder: () => urlBuilder,
46226
47956
  makeWith: () => makeWith3,
46227
47957
  makeClient: () => makeClient,
46228
- make: () => make61,
47958
+ make: () => make65,
46229
47959
  group: () => group3,
46230
47960
  endpoint: () => endpoint
46231
47961
  });
@@ -46325,8 +48055,8 @@ var makeClient = (api, options4) => gen4(function* () {
46325
48055
  let httpRequest = make51(endpoint.method)(endpoint.path);
46326
48056
  if (request3 !== undefined) {
46327
48057
  if (encodeParams !== undefined) {
46328
- const params = yield* encodeParams(request3.params);
46329
- httpRequest = setUrl(httpRequest, makeUrl(params));
48058
+ const params2 = yield* encodeParams(request3.params);
48059
+ httpRequest = setUrl(httpRequest, makeUrl(params2));
46330
48060
  }
46331
48061
  if (encodePayload !== undefined) {
46332
48062
  if (hasBody(endpoint.method)) {
@@ -46365,7 +48095,7 @@ var makeClient = (api, options4) => gen4(function* () {
46365
48095
  }
46366
48096
  });
46367
48097
  });
46368
- var make61 = (api, options4) => flatMap6(HttpClient, (httpClient) => makeWith3(api, {
48098
+ var make65 = (api, options4) => flatMap6(HttpClient, (httpClient) => makeWith3(api, {
46369
48099
  ...options4,
46370
48100
  httpClient: options4?.transformClient ? options4.transformClient(httpClient) : httpClient
46371
48101
  }));
@@ -46440,8 +48170,8 @@ var urlBuilder = (api, options4) => {
46440
48170
  const encodeParams = endpoint2.params === undefined ? undefined : encodeSync2(endpoint2.params, parseOptions.params);
46441
48171
  const encodeQuery = endpoint2.query === undefined ? undefined : encodeSync2(endpoint2.query, parseOptions.query);
46442
48172
  const endpointBuilder = (request3) => {
46443
- const params = request3?.params;
46444
- const path = params === undefined ? endpoint2.path : makeUrl(encodeParams === undefined ? params : encodeParams(params));
48173
+ const params2 = request3?.params;
48174
+ const path = params2 === undefined ? endpoint2.path : makeUrl(encodeParams === undefined ? params2 : encodeParams(params2));
46445
48175
  const queryInput = request3?.query === undefined ? undefined : encodeQuery === undefined ? request3.query : encodeQuery(request3.query);
46446
48176
  const urlParams3 = queryInput === undefined ? empty14 : fromInput4(queryInput);
46447
48177
  if (options4?.baseUrl === undefined) {
@@ -46467,12 +48197,12 @@ var compilePath = (path, schema2) => {
46467
48197
  return (_) => path;
46468
48198
  }
46469
48199
  const paramNames = getParamNames(schema2);
46470
- return (params) => {
48200
+ return (params2) => {
46471
48201
  return path.replace(paramsRegExp, (match11, slash, key, optional6) => {
46472
48202
  if (paramNames !== undefined && !paramNames.has(key)) {
46473
48203
  return match11;
46474
48204
  }
46475
- const value5 = params[key];
48205
+ const value5 = params2[key];
46476
48206
  if (value5 === undefined) {
46477
48207
  if (optional6 !== undefined) {
46478
48208
  return "";
@@ -46767,13 +48497,13 @@ function getEncodePayloadSchemaFromBody(schema2, method) {
46767
48497
  // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/http-api/HttpApiGroup.js
46768
48498
  var exports_HttpApiGroup = {};
46769
48499
  __export(exports_HttpApiGroup, {
46770
- make: () => make62,
48500
+ make: () => make66,
46771
48501
  isHttpApiGroup: () => isHttpApiGroup
46772
48502
  });
46773
- var TypeId68 = "~effect/http-api/HttpApiGroup";
46774
- var isHttpApiGroup = (u) => hasProperty(u, TypeId68);
48503
+ var TypeId69 = "~effect/http-api/HttpApiGroup";
48504
+ var isHttpApiGroup = (u) => hasProperty(u, TypeId69);
46775
48505
  var Proto21 = {
46776
- [TypeId68]: TypeId68,
48506
+ [TypeId69]: TypeId69,
46777
48507
  add(...toAdd) {
46778
48508
  const endpoints = {
46779
48509
  ...this.endpoints
@@ -46838,7 +48568,7 @@ var makeProto4 = (options4) => {
46838
48568
  HttpApiGroup.key = `effect/http-api/HttpApiGroup/${options4.identifier}`;
46839
48569
  return Object.assign(HttpApiGroup, options4);
46840
48570
  };
46841
- var make62 = (identifier2, options4) => makeProto4({
48571
+ var make66 = (identifier2, options4) => makeProto4({
46842
48572
  identifier: identifier2,
46843
48573
  topLevel: options4?.topLevel ?? false,
46844
48574
  endpoints: {},
@@ -46884,7 +48614,7 @@ class HttpApiSchemaError extends (/* @__PURE__ */ TaggedClass("HttpApiSchemaErro
46884
48614
  }
46885
48615
 
46886
48616
  // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/http-api/HttpApiMiddleware.js
46887
- var TypeId69 = "~effect/http-api/HttpApiMiddleware";
48617
+ var TypeId70 = "~effect/http-api/HttpApiMiddleware";
46888
48618
  var SecurityTypeId = "~effect/http-api/HttpApiMiddleware/Security";
46889
48619
  var isSecurity = (u) => hasProperty(u, SecurityTypeId);
46890
48620
  var Service2 = () => (id2, options4) => {
@@ -46904,7 +48634,7 @@ var Service2 = () => (id2, options4) => {
46904
48634
  return creationError?.stack;
46905
48635
  }
46906
48636
  });
46907
- self[TypeId69] = TypeId69;
48637
+ self[TypeId70] = TypeId70;
46908
48638
  self.error = getError(options4?.error);
46909
48639
  self.requiredForClient = options4?.requiredForClient ?? false;
46910
48640
  if (options4?.security !== undefined) {
@@ -46937,9 +48667,9 @@ __export(exports_HttpApiSecurity, {
46937
48667
  annotateMerge: () => annotateMerge2,
46938
48668
  annotate: () => annotate6
46939
48669
  });
46940
- var TypeId70 = "~effect/http-api/HttpApiSecurity";
48670
+ var TypeId71 = "~effect/http-api/HttpApiSecurity";
46941
48671
  var Proto22 = {
46942
- [TypeId70]: TypeId70,
48672
+ [TypeId71]: TypeId71,
46943
48673
  pipe() {
46944
48674
  return pipeArguments(this, arguments);
46945
48675
  }
@@ -47751,7 +49481,7 @@ var exports_SqlClient = {};
47751
49481
  __export(exports_SqlClient, {
47752
49482
  makeWithTransaction: () => makeWithTransaction,
47753
49483
  makeSqliteAcquirers: () => makeSqliteAcquirers,
47754
- make: () => make64,
49484
+ make: () => make68,
47755
49485
  TransactionConnection: () => TransactionConnection,
47756
49486
  SqlClient: () => SqlClient,
47757
49487
  SafeIntegers: () => SafeIntegers
@@ -47761,7 +49491,7 @@ __export(exports_SqlClient, {
47761
49491
  var Reactivity = /* @__PURE__ */ Service("effect/reactivity/Reactivity");
47762
49492
 
47763
49493
  // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/sql/SqlError.js
47764
- var TypeId71 = "~effect/sql/SqlError";
49494
+ var TypeId72 = "~effect/sql/SqlError";
47765
49495
  var ReasonTypeId2 = "~effect/sql/SqlError/Reason";
47766
49496
  var ReasonFields = {
47767
49497
  cause: /* @__PURE__ */ Defect(),
@@ -47854,7 +49584,7 @@ var SqlErrorReason = /* @__PURE__ */ Union2([ConnectionError, AuthenticationErro
47854
49584
  class SqlError extends (/* @__PURE__ */ TaggedError3("effect/sql/SqlError")("SqlError", {
47855
49585
  reason: SqlErrorReason
47856
49586
  })) {
47857
- [TypeId71] = TypeId71;
49587
+ [TypeId72] = TypeId72;
47858
49588
  cause = this.reason;
47859
49589
  get message() {
47860
49590
  return this.reason.message || this.reason._tag;
@@ -47877,10 +49607,10 @@ var SpanPropagationEnabled = /* @__PURE__ */ Reference("effect/sql/SpanPropagati
47877
49607
  defaultValue: () => false
47878
49608
  });
47879
49609
  var isFragment = (u) => hasProperty(u, FragmentTypeId);
47880
- var literal = (value5, params) => ({
49610
+ var literal = (value5, params2) => ({
47881
49611
  _tag: "Literal",
47882
49612
  value: value5,
47883
- params
49613
+ params: params2
47884
49614
  });
47885
49615
  var identifier2 = (value5) => ({
47886
49616
  _tag: "Identifier",
@@ -47926,7 +49656,7 @@ var recordUpdateHelperSingle = (value5, omit4) => Object.assign(Object.create(Re
47926
49656
  omit: omit4,
47927
49657
  returningIdentifier: undefined
47928
49658
  });
47929
- var make63 = (acquirer, compiler2, spanAttributes, transformRows, borrower) => {
49659
+ var make67 = (acquirer, compiler2, spanAttributes, transformRows, borrower) => {
47930
49660
  const cache2 = transformRows === undefined ? constructorCache.noTransforms : constructorCache.transforms;
47931
49661
  if (cache2.has(acquirer)) {
47932
49662
  return cache2.get(acquirer);
@@ -47939,8 +49669,8 @@ var make63 = (acquirer, compiler2, spanAttributes, transformRows, borrower) => {
47939
49669
  }
47940
49670
  throw "absurd";
47941
49671
  }, {
47942
- unsafe(sql, params) {
47943
- return makeUnsafe11([literal(sql, params)], acquirer, compiler2, spanAttributes, transformRows, borrower);
49672
+ unsafe(sql, params2) {
49673
+ return makeUnsafe11([literal(sql, params2)], acquirer, compiler2, spanAttributes, transformRows, borrower);
47944
49674
  },
47945
49675
  literal(sql) {
47946
49676
  return fragment([literal(sql)]);
@@ -48077,46 +49807,46 @@ var StatementProto = {
48077
49807
  },
48078
49808
  withConnectionSpan(operation, f, withoutTransform, span3) {
48079
49809
  return withStatement(this, span3, (statement2, fiber3) => {
48080
- const [sql, params] = statement2.compile(withoutTransform);
49810
+ const [sql, params2] = statement2.compile(withoutTransform);
48081
49811
  for (const [key, value5] of this.spanAttributes) {
48082
49812
  span3.attribute(key, value5);
48083
49813
  }
48084
49814
  span3.attribute(ATTR_SQL_METHOD, operation);
48085
49815
  span3.attribute(ATTR_DB_QUERY_TEXT, sql);
48086
- const execute2 = this.borrower === undefined ? scoped2(flatMap6(this.acquirer, (_) => f(_, sql, params))) : this.borrower((connection) => f(connection, sql, params));
49816
+ const execute2 = this.borrower === undefined ? scoped2(flatMap6(this.acquirer, (_) => f(_, sql, params2))) : this.borrower((connection) => f(connection, sql, params2));
48087
49817
  return fiber3.cache.tracerEnabled && fiber3.getRef(SpanPropagationEnabled) ? provideService2(execute2, ParentSpan, span3) : execute2;
48088
49818
  });
48089
49819
  },
48090
49820
  get withoutTransform() {
48091
- return this.withConnection("executeWithoutTransform", (connection, sql, params) => connection.execute(sql, params, undefined), true);
49821
+ return this.withConnection("executeWithoutTransform", (connection, sql, params2) => connection.execute(sql, params2, undefined), true);
48092
49822
  },
48093
49823
  get raw() {
48094
- return this.withConnection("executeRaw", (connection, sql, params) => connection.executeRaw(sql, params), true);
49824
+ return this.withConnection("executeRaw", (connection, sql, params2) => connection.executeRaw(sql, params2), true);
48095
49825
  },
48096
49826
  get stream() {
48097
49827
  const self = this;
48098
49828
  return unwrap4(flatMap6(makeSpanScoped2(spanName(self.spanAttributes), {
48099
49829
  kind: "client"
48100
49830
  }), (span3) => withStatement(self, span3, (statement2, fiber3) => {
48101
- const [sql, params] = statement2.compile();
49831
+ const [sql, params2] = statement2.compile();
48102
49832
  for (const [key, value5] of self.spanAttributes) {
48103
49833
  span3.attribute(key, value5);
48104
49834
  }
48105
49835
  span3.attribute(ATTR_SQL_METHOD, "executeStream");
48106
49836
  span3.attribute(ATTR_DB_QUERY_TEXT, sql);
48107
- const acquire = map9(self.acquirer, (_) => _.executeStream(sql, params, self.transformRows));
49837
+ const acquire = map9(self.acquirer, (_) => _.executeStream(sql, params2, self.transformRows));
48108
49838
  return fiber3.cache.tracerEnabled && fiber3.getRef(SpanPropagationEnabled) ? succeed6(provideService4(unwrap4(acquire), ParentSpan, span3)) : acquire;
48109
49839
  })));
48110
49840
  },
48111
49841
  get values() {
48112
- return this.withConnection("executeValues", (connection, sql, params) => connection.executeValues(sql, params));
49842
+ return this.withConnection("executeValues", (connection, sql, params2) => connection.executeValues(sql, params2));
48113
49843
  },
48114
49844
  get valuesUnprepared() {
48115
- return this.withConnection("executeValuesUnprepared", (connection, sql, params) => connection.executeValuesUnprepared(sql, params));
49845
+ return this.withConnection("executeValuesUnprepared", (connection, sql, params2) => connection.executeValuesUnprepared(sql, params2));
48116
49846
  },
48117
49847
  get unprepared() {
48118
49848
  const self = this;
48119
- return self.withConnection("executeUnprepared", (connection, sql, params) => connection.executeUnprepared(sql, params, self.transformRows));
49849
+ return self.withConnection("executeUnprepared", (connection, sql, params2) => connection.executeUnprepared(sql, params2, self.transformRows));
48120
49850
  },
48121
49851
  .../* @__PURE__ */ Prototype2({
48122
49852
  label: "Statement",
@@ -48126,19 +49856,19 @@ var StatementProto = {
48126
49856
  });
48127
49857
  const clock = fiber3.getRef(Clock);
48128
49858
  const timingEnabled = fiber3.getRef(TracerTimingEnabled2);
48129
- return onExit2(this.withConnectionSpan("execute", (connection, sql, params) => connection.execute(sql, params, this.transformRows), false, span3), (exit3) => endSpan(span3, exit3, clock, timingEnabled));
49859
+ return onExit2(this.withConnectionSpan("execute", (connection, sql, params2) => connection.execute(sql, params2, this.transformRows), false, span3), (exit3) => endSpan(span3, exit3, clock, timingEnabled));
48130
49860
  }
48131
49861
  }),
48132
49862
  compile(withoutTransform) {
48133
49863
  return this.compiler.compile(this, withoutTransform ?? false);
48134
49864
  },
48135
49865
  toJSON() {
48136
- const [sql, params] = this.compile();
49866
+ const [sql, params2] = this.compile();
48137
49867
  return {
48138
49868
  _id: "Statement",
48139
49869
  segments: this.segments,
48140
49870
  sql,
48141
- params
49871
+ params: params2
48142
49872
  };
48143
49873
  }
48144
49874
  };
@@ -48147,7 +49877,7 @@ var withStatement = (self, span3, f) => withFiber2((fiber3) => {
48147
49877
  if (transform6 === undefined) {
48148
49878
  return f(self, fiber3);
48149
49879
  }
48150
- return flatMap6(transform6(self, make63(self.acquirer, self.compiler, self.spanAttributes, self.transformRows, self.borrower), fiber3, span3), (statement2) => f(statement2, fiber3));
49880
+ return flatMap6(transform6(self, make67(self.acquirer, self.compiler, self.spanAttributes, self.transformRows, self.borrower), fiber3, span3), (statement2) => f(statement2, fiber3));
48151
49881
  });
48152
49882
  var isSegment = (u) => {
48153
49883
  if (!hasProperty(u, "_tag")) {
@@ -48184,11 +49914,11 @@ function in_() {
48184
49914
  var neverFragment = /* @__PURE__ */ fragment([/* @__PURE__ */ literal("1=0")]);
48185
49915
 
48186
49916
  // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/sql/SqlClient.js
48187
- var TypeId72 = "~effect/sql/SqlClient";
49917
+ var TypeId73 = "~effect/sql/SqlClient";
48188
49918
  var SqlClient = /* @__PURE__ */ Service("effect/sql/SqlClient");
48189
49919
  var clientIdCounter = 0;
48190
49920
  var transactionSemaphoreIdCounter = 0;
48191
- var make64 = /* @__PURE__ */ fnUntraced2(function* (options4) {
49921
+ var make68 = /* @__PURE__ */ fnUntraced2(function* (options4) {
48192
49922
  const transactionService = options4.transactionService ?? TransactionConnection(clientIdCounter++);
48193
49923
  const getConnection = flatMap6(serviceOption2(transactionService), match({
48194
49924
  onNone: () => options4.acquirer,
@@ -48219,8 +49949,8 @@ var make64 = /* @__PURE__ */ fnUntraced2(function* (options4) {
48219
49949
  onNone: () => options4.borrower(f),
48220
49950
  onSome: ([conn]) => f(conn)
48221
49951
  }));
48222
- const client = Object.assign(make63(getConnection, options4.compiler, options4.spanAttributes, options4.transformRows, borrower), {
48223
- [TypeId72]: TypeId72,
49952
+ const client = Object.assign(make67(getConnection, options4.compiler, options4.spanAttributes, options4.transformRows, borrower), {
49953
+ [TypeId73]: TypeId73,
48224
49954
  safe: undefined,
48225
49955
  withTransaction,
48226
49956
  transactionService,
@@ -48229,7 +49959,7 @@ var make64 = /* @__PURE__ */ fnUntraced2(function* (options4) {
48229
49959
  if (options4.transformRows === undefined) {
48230
49960
  return this;
48231
49961
  }
48232
- const statement2 = make63(getConnection, options4.compiler.withoutTransform, options4.spanAttributes, undefined, borrower);
49962
+ const statement2 = make67(getConnection, options4.compiler.withoutTransform, options4.spanAttributes, undefined, borrower);
48233
49963
  const client2 = Object.assign(statement2, {
48234
49964
  ...this,
48235
49965
  ...statement2
@@ -49229,6 +50959,75 @@ class Device extends exports_HttpApiGroup.make("device").add(exports_HttpApiEndp
49229
50959
 
49230
50960
  class Api extends exports_HttpApi.make("auth").add(Session).add(Device).prefix("/api/auth") {
49231
50961
  }
50962
+ // ../core/src/Api/CliVersion.ts
50963
+ var exports_CliVersion = {};
50964
+ __export(exports_CliVersion, {
50965
+ supported: () => supported,
50966
+ standing: () => standing,
50967
+ refuses: () => refuses,
50968
+ minimumHeader: () => minimumHeader,
50969
+ minimum: () => minimum,
50970
+ layer: () => layer16,
50971
+ header: () => header,
50972
+ Version: () => Version4,
50973
+ Outdated: () => Outdated
50974
+ });
50975
+
50976
+ // ../core/src/Semver.ts
50977
+ var exports_Semver = {};
50978
+ __export(exports_Semver, {
50979
+ precedence: () => precedence,
50980
+ parse: () => parse7,
50981
+ isRelease: () => isRelease
50982
+ });
50983
+ var SEMVER = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z.-]+)?$/;
50984
+ var parse7 = (version) => exports_Option.map(exports_Option.fromNullishOr(SEMVER.exec(version)), ([, major, minor, patch4, pre]) => ({
50985
+ major: Number(major),
50986
+ minor: Number(minor),
50987
+ patch: Number(patch4),
50988
+ pre: pre?.split(".").map((identifier3) => /^\d+$/.test(identifier3) ? Number(identifier3) : identifier3)
50989
+ }));
50990
+ var identifiers = exports_Order.make((self, that) => exports_Predicate.isNumber(self) && exports_Predicate.isNumber(that) ? exports_Order.Number(self, that) : exports_Predicate.isNumber(self) ? -1 : exports_Predicate.isNumber(that) ? 1 : exports_Order.String(self, that));
50991
+ var preReleases = exports_Order.make((self, that) => self === undefined ? 1 : that === undefined ? -1 : exports_Order.Array(identifiers)(self, that));
50992
+ var precedence = exports_Order.Struct({
50993
+ major: exports_Order.Number,
50994
+ minor: exports_Order.Number,
50995
+ patch: exports_Order.Number,
50996
+ pre: preReleases
50997
+ });
50998
+ var isRelease = (version) => version.pre === undefined;
50999
+
51000
+ // ../core/src/Api/CliVersion.ts
51001
+ var header = "ambral-cli-version";
51002
+ var minimumHeader = "ambral-cli-minimum";
51003
+ var Version4 = exports_Schema.String.check(exports_Schema.makeFilter((version) => exports_Option.isSome(parse7(version)) || "a semantic version")).pipe(exports_Schema.brand("CliVersion")).annotate({ identifier: "CliVersion" });
51004
+ var minimum = undefined;
51005
+
51006
+ class Outdated extends exports_Schema.TaggedError()("CliOutdated", {
51007
+ minimum: Version4
51008
+ }, { httpApiStatus: 426 }) {
51009
+ }
51010
+ var isOlder = (version, than) => exports_Option.exists(parse7(than), (oldest) => exports_Order.isLessThan(precedence)(version, oldest));
51011
+ var refuses = (oldest, sent) => oldest !== undefined && sent !== undefined && exports_Option.exists(parse7(sent), (version) => isOlder(version, oldest));
51012
+ var releases = (published) => published.flatMap((name) => exports_Option.match(exports_Option.filter(parse7(name), isRelease), {
51013
+ onNone: () => [],
51014
+ onSome: (version) => [{ name: Version4.make(name), version }]
51015
+ })).toSorted((self, that) => precedence(self.version, that.version));
51016
+ var supported = (oldest, published) => releases(published).filter(({ version }) => oldest === undefined || !isOlder(version, oldest)).map(({ name }) => name);
51017
+ var standing = (version, published) => {
51018
+ const newest = releases(published).at(-1);
51019
+ const order = newest === undefined ? 1 : precedence(exports_Option.getOrThrow(parse7(version)), newest.version);
51020
+ return order > 0 ? "unreleased" : order === 0 ? "released" : "behind";
51021
+ };
51022
+ var layer16 = (oldest) => exports_HttpRouter.middleware()((httpEffect) => exports_Effect.gen(function* () {
51023
+ const request3 = yield* exports_HttpServerRequest.HttpServerRequest;
51024
+ if (oldest === undefined || !refuses(oldest, request3.headers[header]))
51025
+ return yield* httpEffect;
51026
+ return yield* exports_HttpServerResponse.schemaJson(Outdated)(new Outdated({ minimum: oldest }), {
51027
+ status: 426,
51028
+ headers: { [minimumHeader]: oldest }
51029
+ }).pipe(exports_Effect.orDie);
51030
+ })).layer;
49232
51031
  // ../core/src/ApiKey/ApiKey.ts
49233
51032
  var exports_ApiKey = {};
49234
51033
  __export(exports_ApiKey, {
@@ -49284,7 +51083,7 @@ var rotrBH = (h, l, s) => h << 64 - s | l >>> s - 32;
49284
51083
  var rotrBL = (h, l, s) => h >>> s - 32 | l << 64 - s;
49285
51084
  var rotr32H = (_h, l) => l;
49286
51085
  var rotr32L = (h, _l) => h;
49287
- function add5(Ah, Al, Bh, Bl) {
51086
+ function add6(Ah, Al, Bh, Bl) {
49288
51087
  const l = (Al >>> 0) + (Bl >>> 0);
49289
51088
  return { h: Ah + Bh + (l / 2 ** 32 | 0) | 0, l: l | 0 };
49290
51089
  }
@@ -49683,7 +51482,7 @@ __export(exports_KeyValueStore, {
49683
51482
  toSchemaStore: () => toSchemaStore,
49684
51483
  prefix: () => prefix3,
49685
51484
  makeStringOnly: () => makeStringOnly,
49686
- make: () => make65,
51485
+ make: () => make69,
49687
51486
  layerStorage: () => layerStorage,
49688
51487
  layerSql: () => layerSql,
49689
51488
  layerMemory: () => layerMemory,
@@ -49691,15 +51490,15 @@ __export(exports_KeyValueStore, {
49691
51490
  KeyValueStoreError: () => KeyValueStoreError,
49692
51491
  KeyValueStore: () => KeyValueStore
49693
51492
  });
49694
- var TypeId73 = "~effect/persistence/KeyValueStore";
51493
+ var TypeId74 = "~effect/persistence/KeyValueStore";
49695
51494
  var ErrorTypeId = "~effect/persistence/KeyValueStore/KeyValueStoreError";
49696
51495
 
49697
51496
  class KeyValueStoreError extends (/* @__PURE__ */ TaggedError2("KeyValueStoreError")) {
49698
51497
  [ErrorTypeId] = ErrorTypeId;
49699
51498
  }
49700
51499
  var KeyValueStore = /* @__PURE__ */ Service("effect/persistence/KeyValueStore");
49701
- var make65 = (options4) => KeyValueStore.of({
49702
- [TypeId73]: TypeId73,
51500
+ var make69 = (options4) => KeyValueStore.of({
51501
+ [TypeId74]: TypeId74,
49703
51502
  has: (key) => map9(options4.get(key), isNotUndefined),
49704
51503
  isEmpty: map9(options4.size, (size8) => size8 === 0),
49705
51504
  modify: (key, f) => flatMap6(options4.get(key), (o) => {
@@ -49720,7 +51519,7 @@ var make65 = (options4) => KeyValueStore.of({
49720
51519
  });
49721
51520
  var makeStringOnly = (options4) => {
49722
51521
  const encoder6 = new TextEncoder;
49723
- return make65({
51522
+ return make69({
49724
51523
  ...options4,
49725
51524
  getUint8Array: (key) => options4.get(key).pipe(map9(map20((value5) => match2(decode2(value5), {
49726
51525
  onFailure: () => encoder6.encode(value5),
@@ -49742,7 +51541,7 @@ var prefix3 = /* @__PURE__ */ dual(2, (self, prefix4) => ({
49742
51541
  var layerMemory = /* @__PURE__ */ sync2(KeyValueStore)(() => {
49743
51542
  const store = new Map;
49744
51543
  const encoder6 = new TextEncoder;
49745
- return make65({
51544
+ return make69({
49746
51545
  get: (key) => sync3(() => {
49747
51546
  const value5 = store.get(key);
49748
51547
  return value5 === undefined ? undefined : typeof value5 === "string" ? value5 : encode2(value5);
@@ -49770,7 +51569,7 @@ var layerFileSystem = (directory) => effect(KeyValueStore)(gen4(function* () {
49770
51569
  recursive: true
49771
51570
  });
49772
51571
  }
49773
- return make65({
51572
+ return make69({
49774
51573
  get: (key) => withKeyPath("get", key, (path2) => catchTag3(fs.readFileString(path2), "PlatformError", (cause) => cause.reason._tag === "NotFound" ? undefined_2 : fail6(new KeyValueStoreError({
49775
51574
  method: "get",
49776
51575
  key,
@@ -49880,7 +51679,7 @@ var layerSql = (options4 = {}) => effect(KeyValueStore)(gen4(function* () {
49880
51679
  const decoder4 = new TextDecoder;
49881
51680
  const ValueTypeString = 0;
49882
51681
  const ValueTypeUint8Array = 1;
49883
- return make65({
51682
+ return make69({
49884
51683
  get: (key) => sql`SELECT value, value_type FROM ${table2} WHERE id = ${key}`.pipe(mapError4((cause) => new KeyValueStoreError({
49885
51684
  method: "get",
49886
51685
  key,
@@ -50738,7 +52537,7 @@ function G1b(a, b, c, d, msg, x) {
50738
52537
  let xh = Dh ^ Ah, xl = Dl ^ Al;
50739
52538
  Dh = rotr32H(xh, xl);
50740
52539
  Dl = rotr32L(xh, xl);
50741
- ({ h: Ch, l: Cl } = add5(Ch, Cl, Dh, Dl));
52540
+ ({ h: Ch, l: Cl } = add6(Ch, Cl, Dh, Dl));
50742
52541
  xh = Bh ^ Ch;
50743
52542
  xl = Bl ^ Cl;
50744
52543
  Bh = rotrSH(xh, xl, 24);
@@ -50764,7 +52563,7 @@ function G2b(a, b, c, d, msg, x) {
50764
52563
  let xh = Dh ^ Ah, xl = Dl ^ Al;
50765
52564
  Dh = rotrSH(xh, xl, 16);
50766
52565
  Dl = rotrSL(xh, xl, 16);
50767
- ({ h: Ch, l: Cl } = add5(Ch, Cl, Dh, Dl));
52566
+ ({ h: Ch, l: Cl } = add6(Ch, Cl, Dh, Dl));
50768
52567
  xh = Bh ^ Ch;
50769
52568
  xl = Bl ^ Cl;
50770
52569
  Bh = rotrBH(xh, xl, 63);
@@ -52733,7 +54532,7 @@ var exports_Workload = {};
52733
54532
  __export(exports_Workload, {
52734
54533
  routeOf: () => routeOf,
52735
54534
  movesRoute: () => movesRoute,
52736
- make: () => make66,
54535
+ make: () => make70,
52737
54536
  list: () => list5,
52738
54537
  get: () => get23,
52739
54538
  create: () => create,
@@ -53151,7 +54950,7 @@ var applyChange = (pool, change2) => exports_Match.valueTags(change2, {
53151
54950
  }
53152
54951
  });
53153
54952
  var movesRoute = (before, after) => before.primary !== after.primary || before.baseline !== after.baseline;
53154
- var make66 = (org, input, id2) => ({
54953
+ var make70 = (org, input, id2) => ({
53155
54954
  id: id2,
53156
54955
  org,
53157
54956
  name: input.name,
@@ -53225,7 +55024,7 @@ var republish = exports_Effect.fnUntraced(function* (org, name) {
53225
55024
  var create = exports_Effect.fn("Workload.create")(function* (org, input, actor) {
53226
55025
  const sql = yield* exports_SqlClient.SqlClient;
53227
55026
  const routes = yield* RoutePublisher;
53228
- const workload = make66(org, input, WorkloadId.make(yield* uuid));
55027
+ const workload = make70(org, input, WorkloadId.make(yield* uuid));
53229
55028
  const changeId = ChangeId.make(yield* uuid);
53230
55029
  yield* exports_Effect.annotateCurrentSpan({ org, workload: input.name, workloadId: workload.id });
53231
55030
  const at = yield* now3;
@@ -53452,7 +55251,7 @@ var generate6 = exports_Effect.fn("ApiKey.generate")(function* (kind, deployed)
53452
55251
  var start2 = (key2) => Start.make(key2.slice(0, key2.length - KEY_LENGTH + START_LENGTH));
53453
55252
  var decodePlaintext = exports_Schema.decodeUnknownResult(Plaintext2);
53454
55253
  var fromAuthorization = (authorization) => {
53455
- const match11 = exports_Option.flatMapNullishOr(authorization, (header) => /^Bearer[ \t]+(\S+)[ \t]*$/i.exec(header)?.[1]);
55254
+ const match11 = exports_Option.flatMapNullishOr(authorization, (header2) => /^Bearer[ \t]+(\S+)[ \t]*$/i.exec(header2)?.[1]);
53456
55255
  if (exports_Option.isNone(match11))
53457
55256
  return exports_Result.fail("missing");
53458
55257
  return exports_Result.mapError(decodePlaintext(match11.value), () => "invalid");
@@ -53796,7 +55595,7 @@ var JudgeCall = exports_Schema.Struct({
53796
55595
  request: JudgeRequest,
53797
55596
  response: JudgeResponse
53798
55597
  }).annotate({ identifier: "JudgeCall" });
53799
- var make67 = (name, model, messages, completion, parsed) => {
55598
+ var make71 = (name, model, messages, completion, parsed) => {
53800
55599
  const usage = completion.call.usage;
53801
55600
  return {
53802
55601
  name,
@@ -54076,13 +55875,13 @@ var summarize = (scores) => {
54076
55875
  };
54077
55876
 
54078
55877
  // ../../node_modules/.bun/effect@4.0.3/node_modules/effect/dist/ai/Tool.js
54079
- var TypeId74 = "~effect/ai/Tool";
55878
+ var TypeId75 = "~effect/ai/Tool";
54080
55879
  var ProviderDefinedTypeId = "~effect/ai/Tool/ProviderDefined";
54081
55880
  var DynamicTypeId = "~effect/ai/Tool/Dynamic";
54082
55881
  var isProviderDefined = (u) => hasProperty(u, ProviderDefinedTypeId);
54083
55882
  var clone = (self, overrides) => Object.assign(Object.create(Object.getPrototypeOf(self)), self, overrides);
54084
55883
  var Proto23 = {
54085
- [TypeId74]: {
55884
+ [TypeId75]: {
54086
55885
  _Requirements: identity
54087
55886
  },
54088
55887
  pipe() {
@@ -54650,12 +56449,12 @@ function mergeLowerBound(schema2, key3, value5) {
54650
56449
  schema2[key3] = value5;
54651
56450
  return;
54652
56451
  }
54653
- const minimum = typeof schema2.minimum === "number" ? schema2.minimum : undefined;
56452
+ const minimum2 = typeof schema2.minimum === "number" ? schema2.minimum : undefined;
54654
56453
  const exclusiveMinimum = typeof schema2.exclusiveMinimum === "number" ? schema2.exclusiveMinimum : undefined;
54655
56454
  let current;
54656
- if (minimum !== undefined)
56455
+ if (minimum2 !== undefined)
54657
56456
  current = {
54658
- value: minimum,
56457
+ value: minimum2,
54659
56458
  exclusive: false
54660
56459
  };
54661
56460
  if (exclusiveMinimum !== undefined && (current === undefined || exclusiveMinimum >= current.value)) {
@@ -55325,7 +57124,7 @@ var verdictOf = exports_Effect.fnUntraced(function* (org, run6, name, model, ver
55325
57124
  const failed = (reason) => (cause) => new VerifierError({ reason, scorer: name, cause });
55326
57125
  const completion = yield* produce(model, prompt, org);
55327
57126
  const read5 = verdicts.read(completion.reply.content ?? "");
55328
- const call = yield* write3(org, run6, make67(name, model.id, prompt.messages, completion, exports_Result.getOrUndefined(read5)?.answer ?? null)).pipe(exports_Effect.mapError(failed("Unavailable")));
57127
+ const call = yield* write3(org, run6, make71(name, model.id, prompt.messages, completion, exports_Result.getOrUndefined(read5)?.answer ?? null)).pipe(exports_Effect.mapError(failed("Unavailable")));
55329
57128
  const { recorded } = yield* exports_Effect.fromResult(read5).pipe(exports_Effect.mapError(failed("Failed")));
55330
57129
  return { recorded, call };
55331
57130
  });
@@ -55383,7 +57182,7 @@ var trajectoryJudge = exports_Layer.effect(Judge, exports_Effect.gen(function* (
55383
57182
  }, exports_Effect.provideContext(services))
55384
57183
  });
55385
57184
  }));
55386
- var layer15 = exports_Layer.merge(verifiers, trajectoryJudge);
57185
+ var layer17 = exports_Layer.merge(verifiers, trajectoryJudge);
55387
57186
 
55388
57187
  // ../core/src/Scoring/ReplayEnv.ts
55389
57188
  var SAMPLE_EXPECTED = `{ type: "sample", k: n }`;
@@ -55646,15 +57445,15 @@ var uncounted = (config) => {
55646
57445
  const scoredBy = exports_Record.keys(EpisodeScorerConfigs.fields).filter((name) => rewards[name] !== null);
55647
57446
  if (scoredBy.length > 0 && rewards.replies === null) {
55648
57447
  const by = `the trace scores only by \`episode.rewards\` (${scoredBy.map((name) => `\`${name}\``).join(", ")})`;
55649
- const add6 = metrics.replies === null ? "add `episode.rewards.replies` to count it" : "move `replies` from `episode.metrics` to `episode.rewards` to count it";
57448
+ const add7 = metrics.replies === null ? "add `episode.rewards.replies` to count it" : "move `replies` from `episode.metrics` to `episode.rewards` to count it";
55650
57449
  return [
55651
57450
  ...scorers.map(({ movesToMetrics, path }) => ({
55652
57451
  path,
55653
- message: `Counts toward each reply's score, but ${by}; ${add6}` + (movesToMetrics ? ", or move it to `metrics` to record it." : ".")
57452
+ message: `Counts toward each reply's score, but ${by}; ${add7}` + (movesToMetrics ? ", or move it to `metrics` to record it." : ".")
55654
57453
  })),
55655
57454
  ...config.required.map((_, i) => ({
55656
57455
  path: ["required", i],
55657
- message: `Zeroes the score of a reply where it fails, but ${by}; ${add6}.`
57456
+ message: `Zeroes the score of a reply where it fails, but ${by}; ${add7}.`
55658
57457
  }))
55659
57458
  ];
55660
57459
  }
@@ -58115,7 +59914,7 @@ var PUBLIC_APP = "https://app.ambral.ai";
58115
59914
 
58116
59915
  class Target extends exports_Context.Service()("ambral/Target") {
58117
59916
  }
58118
- var layer16 = exports_Layer.effect(Target, exports_Effect.gen(function* () {
59917
+ var layer18 = exports_Layer.effect(Target, exports_Effect.gen(function* () {
58119
59918
  const url = yield* exports_Config.URL("AMBRAL_URL").pipe(exports_Config.withDefault(new URL(PUBLIC_APP)));
58120
59919
  return Target.of({ url: new URL(url.origin) });
58121
59920
  }));
@@ -58147,7 +59946,7 @@ class Credentials extends exports_Context.Service()("ambral/Login/Credentials")
58147
59946
  }
58148
59947
  var DIRECTORY_MODE = 448;
58149
59948
  var FILE_MODE = 384;
58150
- var layer17 = exports_Layer.effect(Credentials, exports_Effect.gen(function* () {
59949
+ var layer19 = exports_Layer.effect(Credentials, exports_Effect.gen(function* () {
58151
59950
  const fs = yield* exports_FileSystem.FileSystem;
58152
59951
  const path = yield* exports_Path.Path;
58153
59952
  const { url } = yield* Target;
@@ -58183,9 +59982,10 @@ class Ambral extends exports_Context.Service()("ambral/Ambral") {
58183
59982
 
58184
59983
  class SignIn2 extends exports_Context.Service()("ambral/SignIn") {
58185
59984
  }
59985
+ var versioned = exports_Effect.map(exports_Effect.service(exports_HttpClient.HttpClient), exports_HttpClient.mapRequest(exports_HttpClientRequest.setHeader(exports_CliVersion.header, package_default.version)));
58186
59986
  var as5 = exports_Effect.fn("Ambral.as")(function* (token) {
58187
59987
  const { url } = yield* Target;
58188
- const httpClient = exports_HttpClient.mapRequest(yield* exports_HttpClient.HttpClient, exports_HttpClientRequest.bearerToken(token));
59988
+ const httpClient = exports_HttpClient.mapRequest(yield* versioned, exports_HttpClientRequest.bearerToken(token));
58189
59989
  const withBearer = exports_Effect.provideService(exports_HttpClient.HttpClient, httpClient);
58190
59990
  return Ambral.of({
58191
59991
  platform: yield* exports_HttpApiClient.make(exports_PlatformApi.Api, { baseUrl: url }).pipe(exports_Effect.provide(exports_Auth.layerClient), withBearer),
@@ -58197,10 +59997,10 @@ var signedIn = exports_Layer.effect(Ambral, exports_Effect.gen(function* () {
58197
59997
  if (token === undefined)
58198
59998
  return yield* new NotSignedIn({ address: (yield* Target).url.origin });
58199
59999
  return yield* as5(token);
58200
- })).pipe(exports_Layer.provideMerge(layer17), exports_Layer.provideMerge(layer16));
60000
+ })).pipe(exports_Layer.provideMerge(layer19), exports_Layer.provideMerge(layer18));
58201
60001
  var signedOut = exports_Layer.effect(SignIn2, exports_Effect.gen(function* () {
58202
60002
  const { url } = yield* Target;
58203
- return (yield* exports_HttpApiClient.make(exports_AuthApi.Api, { baseUrl: url }).pipe(exports_Effect.provide(exports_Auth.layerClient))).device;
60003
+ return (yield* exports_HttpApiClient.make(exports_AuthApi.Api, { baseUrl: url }).pipe(exports_Effect.provide(exports_Auth.layerClient), exports_Effect.provideService(exports_HttpClient.HttpClient, yield* versioned))).device;
58204
60004
  }));
58205
60005
 
58206
60006
  // src/Output.ts
@@ -58222,13 +60022,22 @@ var sessionEnded = (cause) => {
58222
60022
  const failure = exports_Cause.squash(cause);
58223
60023
  return exports_Schema.is(exports_Auth.Unauthorized)(failure) || exports_HttpClientError.isHttpClientError(failure) && failure.response?.status === 401;
58224
60024
  };
60025
+ var oldestServed = (cause) => {
60026
+ const failure = exports_Cause.squash(cause);
60027
+ return exports_HttpClientError.isHttpClientError(failure) && failure.response?.status === 426 ? exports_Schema.decodeOption(exports_CliVersion.Version)(failure.response.headers[exports_CliVersion.minimumHeader]) : exports_Option.none();
60028
+ };
58225
60029
  var renderFailure = (expected2, advise, cause, json6, address) => {
58226
60030
  const squashed = exports_Cause.squash(cause);
58227
- const failure = sessionEnded(cause) ? new NotSignedIn({ address }) : exports_Schema.is(expected2)(squashed) ? squashed : new Unexpected({
60031
+ const oldest = oldestServed(cause);
60032
+ const failure = sessionEnded(cause) ? new NotSignedIn({ address }) : exports_Option.isSome(oldest) ? new exports_CliVersion.Outdated({ minimum: oldest.value }) : exports_Schema.is(expected2)(squashed) ? squashed : new Unexpected({
58228
60033
  message: exports_Option.exists(exports_Cause.findErrorOption(cause), exports_Schema.isSchemaError) ? "The server answered in a form this CLI doesn't read. Update ambral." : exports_Predicate.isError(squashed) ? squashed.message : String(squashed)
58229
60034
  });
58230
60035
  const { message, remedy } = exports_Schema.is(expected2)(failure) ? advise(failure) : { message: failure.message, remedy: null };
58231
- const error2 = { ...exports_Schema.encodeSync(exports_Schema.Union([expected2, NotSignedIn, Unexpected]))(failure), message, remedy };
60036
+ const error2 = {
60037
+ ...exports_Schema.encodeSync(exports_Schema.Union([expected2, NotSignedIn, exports_CliVersion.Outdated, Unexpected]))(failure),
60038
+ message,
60039
+ remedy
60040
+ };
58232
60041
  return json6 ? JSON.stringify({ error: error2 }, null, 2) : remedy === null ? message : `${message}
58233
60042
  ${remedy}`;
58234
60043
  };
@@ -58288,7 +60097,7 @@ var root = exports_Effect.gen(function* () {
58288
60097
  const working = (yield* exports_Path.Path).resolve(yield* WorkingDirectory);
58289
60098
  return (yield* rootFrom(working)) ?? working;
58290
60099
  });
58291
- var layer18 = exports_Layer.effect(ProjectLink, exports_Effect.gen(function* () {
60100
+ var layer20 = exports_Layer.effect(ProjectLink, exports_Effect.gen(function* () {
58292
60101
  const fs = yield* exports_FileSystem.FileSystem;
58293
60102
  const path = yield* exports_Path.Path;
58294
60103
  const { url } = yield* Target;
@@ -58375,7 +60184,7 @@ var current = exports_Effect.gen(function* () {
58375
60184
  return yield* exports_Array.findFirst(all6, (membership) => membership.org === link4.org).pipe(exports_Effect.fromOption, exports_Effect.mapError(() => new NotLinked({ stale: link4.slug, memberships: all6 })));
58376
60185
  });
58377
60186
  var acting = exports_Effect.filterOrElse(current, exports_Predicate.isNotUndefined, () => exports_Effect.flatMap(memberships2, (all6) => exports_Effect.fail(new NotLinked({ memberships: all6 }))));
58378
- var inProject = layer18.pipe(exports_Layer.provideMerge(signedIn));
60187
+ var inProject = layer20.pipe(exports_Layer.provideMerge(signedIn));
58379
60188
  var Listed = exports_Schema.Struct({ membership: exports_OrgAccess.Membership, linked: exports_Schema.Boolean });
58380
60189
  var listed3 = {
58381
60190
  schema: exports_Schema.Array(Listed),
@@ -58401,7 +60210,7 @@ var list11 = exports_Command.make("list", {}, () => exports_Effect.gen(function*
58401
60210
  const link4 = yield* (yield* ProjectLink).get;
58402
60211
  yield* print(listed3, all6.map((membership) => ({ membership, linked: membership.org === link4?.org })));
58403
60212
  })).pipe(exports_Command.provide(inProject), exports_Command.withDescription("List your orgs, with your role and each org's status"));
58404
- var use = exports_Command.make("use", {
60213
+ var use2 = exports_Command.make("use", {
58405
60214
  slug: exports_Argument.String("slug").pipe(exports_Argument.withDescription("The org's slug, as `ambral orgs list` shows it"), exports_Argument.withSchema(exports_OrgAccess.Slug))
58406
60215
  }, ({ slug }) => exports_Effect.gen(function* () {
58407
60216
  const membership = yield* bySlug(slug);
@@ -58419,7 +60228,7 @@ var create4 = exports_Command.make("create", {
58419
60228
  project: unlinked ? yield* project2.set(exports_Struct.pick(membership, ["org", "slug"])) : undefined
58420
60229
  });
58421
60230
  })).pipe(exports_Command.provide(inProject), exports_Command.withDescription("Create an org you own; links this project to it if it isn't linked yet"));
58422
- var orgs = exports_Command.make("orgs").pipe(exports_Command.withDescription("List your orgs, create one, and link this project to one"), exports_Command.withSubcommands([list11, use, create4]));
60231
+ var orgs = exports_Command.make("orgs").pipe(exports_Command.withDescription("List your orgs, create one, and link this project to one"), exports_Command.withSubcommands([list11, use2, create4]));
58423
60232
 
58424
60233
  // src/Keys/Keys.ts
58425
60234
  var listed4 = {
@@ -58514,7 +60323,7 @@ var SignedOut2 = {
58514
60323
  schema: exports_Schema.Struct({ address: exports_Schema.String }),
58515
60324
  text: ({ address }) => `Signed out of ${address}.`
58516
60325
  };
58517
- var signingIn = exports_Layer.mergeAll(signedOut, layer17).pipe(exports_Layer.provideMerge(layer16));
60326
+ var signingIn = exports_Layer.mergeAll(signedOut, layer19).pipe(exports_Layer.provideMerge(layer18));
58518
60327
  var readable = exports_Effect.flatMap(Credentials, ({ get: get27 }) => get27.pipe(exports_Effect.catchIf((error2) => error2.reason === "unreadable", () => exports_Effect.succeed({}))));
58519
60328
  var start4 = exports_Effect.gen(function* () {
58520
60329
  const signIn = yield* SignIn2;
@@ -58848,8 +60657,8 @@ var warn2 = exports_Effect.fnUntraced(function* (config2) {
58848
60657
  });
58849
60658
  var toScore = (address) => "Set how it's scored: pick a preset from `ambral tasksets scoring preset`, write it to a file with " + "`ambral tasksets scoring preset <name> > <file>`, edit the file, then " + `\`ambral tasksets scoring set ${encodeAddress2(address)} --file <file>\`.`;
58850
60659
  var encodeConfig2 = exports_Schema.encodeSync(exports_Env.EnvConfig);
58851
- var annotated = (header, config2) => [
58852
- ...header.map((line) => `# ${line}`),
60660
+ var annotated = (header2, config2) => [
60661
+ ...header2.map((line) => `# ${line}`),
58853
60662
  "# Every key is explained above it; a key whose comment gives a default may be left out. Each judge's `model` is",
58854
60663
  "# one from `ambral models list`.",
58855
60664
  "#",
@@ -58861,7 +60670,7 @@ var listed6 = {
58861
60670
  text: (presets2) => [
58862
60671
  table2([
58863
60672
  ["PRESET", "USE IT WHEN"],
58864
- ...presets2.map(({ name, use: use2, judge }) => [name, judge ? `${use2} Takes --judge <model>.` : use2])
60673
+ ...presets2.map(({ name, use: use3, judge }) => [name, judge ? `${use3} Takes --judge <model>.` : use3])
58865
60674
  ]),
58866
60675
  "",
58867
60676
  "Write one to a file to edit: `ambral tasksets scoring preset <name> > <file>`."
@@ -58931,11 +60740,11 @@ var set9 = exports_Command.make("set", {
58931
60740
  const config2 = yield* exports_Effect.fromResult(file3);
58932
60741
  const { platform: platform2 } = yield* Ambral;
58933
60742
  const { org } = yield* acting;
58934
- const params = { org, workload: taskset.workload, taskset: taskset.taskset };
60743
+ const params2 = { org, workload: taskset.workload, taskset: taskset.taskset };
58935
60744
  if (check4)
58936
- yield* print(checked, yield* platform2.tasksets.checkScoring({ params, payload: config2 }));
60745
+ yield* print(checked, yield* platform2.tasksets.checkScoring({ params: params2, payload: config2 }));
58937
60746
  else
58938
- yield* print(saved(taskset), yield* platform2.tasksets.putScoring({ params, payload: config2 }));
60747
+ yield* print(saved(taskset), yield* platform2.tasksets.putScoring({ params: params2, payload: config2 }));
58939
60748
  yield* warn2(config2);
58940
60749
  })).pipe(exports_Command.provide(inProject), exports_Command.withDescription("Save a scoring config as a taskset's next version, after checking it. A config with mistakes prints each, at " + "its field, and saves nothing"), exports_Command.withExamples([
58941
60750
  {
@@ -59156,13 +60965,13 @@ var failedLines = ({ failed: failed2 }) => failed2.length === 0 ? [] : [
59156
60965
  ];
59157
60966
  var readoutText = (readout2) => {
59158
60967
  const { run: run7 } = readout2;
59159
- const header = `Run ${run7.id} · ${encodeAddress2(run7.taskset)} · ${scoringOf(run7)} · ${run7.status} · ` + progressOf(readout2);
60968
+ const header2 = `Run ${run7.id} · ${encodeAddress2(run7.taskset)} · ${scoringOf(run7)} · ${run7.status} · ` + progressOf(readout2);
59160
60969
  if (run7.status === "running")
59161
- return `${header}
60970
+ return `${header2}
59162
60971
  Read it again with \`ambral runs show ${run7.id}\`.`;
59163
60972
  const columns = columnsOf(readout2.subjects);
59164
60973
  return [
59165
- header,
60974
+ header2,
59166
60975
  "",
59167
60976
  table2([
59168
60977
  ["", ...columns.map(({ subject }) => subjectName(subject))],
@@ -60250,24 +62059,9 @@ ${markdown}`;
60250
62059
  }, exports_Effect.orDie);
60251
62060
  var Stamped = exports_Schema.Struct({ metadata: exports_Schema.Struct({ version: exports_Schema.String }) });
60252
62061
  var versionOf = (text3) => partsOf(text3).pipe(exports_Option.flatMap(({ yaml }) => exports_Option.liftThrowable(exports_Yaml.parse)(yaml)), exports_Option.flatMap(exports_Schema.decodeUnknownOption(Stamped)), exports_Option.map(({ metadata }) => metadata.version));
60253
- var SEMVER = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z.-]+)?$/;
60254
- var semverOf = (version) => exports_Option.map(exports_Option.fromNullishOr(SEMVER.exec(version)), ([, major, minor, patch4, pre]) => ({
60255
- major: Number(major),
60256
- minor: Number(minor),
60257
- patch: Number(patch4),
60258
- pre: pre?.split(".").map((identifier3) => /^\d+$/.test(identifier3) ? Number(identifier3) : identifier3)
60259
- }));
60260
- var identifiers = exports_Order.make((self, that) => exports_Predicate.isNumber(self) && exports_Predicate.isNumber(that) ? exports_Order.Number(self, that) : exports_Predicate.isNumber(self) ? -1 : exports_Predicate.isNumber(that) ? 1 : exports_Order.String(self, that));
60261
- var preReleases = exports_Order.make((self, that) => self === undefined ? 1 : that === undefined ? -1 : exports_Order.Array(identifiers)(self, that));
60262
- var precedence = exports_Order.Struct({
60263
- major: exports_Order.Number,
60264
- minor: exports_Order.Number,
60265
- patch: exports_Order.Number,
60266
- pre: preReleases
60267
- });
60268
- var isStale = (text3, current2) => exports_Option.match(exports_Option.all([exports_Option.flatMap(versionOf(text3), semverOf), semverOf(current2)]), {
62062
+ var isStale = (text3, current2) => exports_Option.match(exports_Option.all([exports_Option.flatMap(versionOf(text3), exports_Semver.parse), exports_Semver.parse(current2)]), {
60269
62063
  onNone: () => false,
60270
- onSome: ([installed, running]) => exports_Order.isLessThan(precedence)(installed, running)
62064
+ onSome: ([installed, running]) => exports_Order.isLessThan(exports_Semver.precedence)(installed, running)
60271
62065
  });
60272
62066
  var failures2 = {
60273
62067
  check: "Couldn't check for the folder",
@@ -60365,6 +62159,7 @@ var hint = exports_Layer.effectDiscard(exports_Effect.gen(function* () {
60365
62159
  // src/Remedies.ts
60366
62160
  var Failures = exports_Schema.Union([
60367
62161
  NotSignedIn,
62162
+ exports_CliVersion.Outdated,
60368
62163
  CredentialsError,
60369
62164
  NoPendingSignIn,
60370
62165
  SignInDenied,
@@ -60439,6 +62234,10 @@ var branchOf2 = exports_Schema.encodeSync(exports_TraceReading.Ref);
60439
62234
  var subjectName2 = exports_Schema.encodeSync(exports_Run.Subject);
60440
62235
  var advise = (failure) => exports_Match.valueTags(failure, {
60441
62236
  NotSignedIn: ({ message }) => ({ message, remedy: "Run `ambral login`." }),
62237
+ CliOutdated: ({ minimum: minimum2 }) => ({
62238
+ message: `This ambral (v${package_default.version}) is older than the server serves: it needs v${minimum2} or later.`,
62239
+ remedy: "Update it with `npm install --global ambral@latest`, or run it as `npx ambral@latest`."
62240
+ }),
60442
62241
  CredentialsError: ({ message, reason }) => ({
60443
62242
  message,
60444
62243
  remedy: reason === "unreadable" ? "Delete it and run `ambral login`." : null
@@ -60680,7 +62479,7 @@ var one2 = {
60680
62479
  table2([
60681
62480
  ["BASE URL", connection.baseUrl],
60682
62481
  ["MODEL", connection.model],
60683
- ...connection.headers.map((header) => [header.name, header.value ?? header.description])
62482
+ ...connection.headers.map((header2) => [header2.name, header2.value ?? header2.description])
60684
62483
  ]),
60685
62484
  "",
60686
62485
  `Check that its sessions are recorded with \`ambral traces list ${workload.name}\`.`
@@ -60733,7 +62532,7 @@ var get30 = exports_Command.make("get", { name: nameArgument }, ({ name }) => ex
60733
62532
  const { org } = yield* acting;
60734
62533
  yield* print(one2, yield* platform2.workloads.get({ params: { org, workload: name } }));
60735
62534
  })).pipe(exports_Command.provide(inProject), exports_Command.withDescription("Show a workload: its primary model, its pool, and how an agent connects to it through the Gateway"), exports_Command.withExamples([{ command: "ambral workloads get support-agent --json", description: "As JSON" }]));
60736
- var add6 = exports_Command.make("add", { name: nameArgument, model: modelArgument }, ({ name, model }) => exports_Effect.gen(function* () {
62535
+ var add7 = exports_Command.make("add", { name: nameArgument, model: modelArgument }, ({ name, model }) => exports_Effect.gen(function* () {
60737
62536
  const { platform: platform2 } = yield* Ambral;
60738
62537
  const { org } = yield* acting;
60739
62538
  yield* print(changed(name), yield* platform2.workloads.addToPool({ params: { org, workload: name, model } }));
@@ -60760,7 +62559,7 @@ var setPrimary = exports_Command.make("set-primary", { name: nameArgument, model
60760
62559
  description: "Roll back to the model it served before"
60761
62560
  }
60762
62561
  ]));
60763
- var pool = exports_Command.make("pool").pipe(exports_Command.withDescription("Add models to a workload's pool, or remove them"), exports_Command.withSubcommands([add6, remove11]));
62562
+ var pool = exports_Command.make("pool").pipe(exports_Command.withDescription("Add models to a workload's pool, or remove them"), exports_Command.withSubcommands([add7, remove11]));
60764
62563
  var workloads = exports_Command.make("workloads").pipe(exports_Command.withDescription("Create, list and show the org's workloads, change their model pools, and choose the model that serves each"), exports_Command.withSubcommands([create6, list17, get30, setPrimary, pool]));
60765
62564
 
60766
62565
  // src/Cli.ts
@@ -60776,7 +62575,7 @@ var ambral = exports_Command.make("ambral").pipe(exports_Command.withDescription
60776
62575
  runs,
60777
62576
  keys5,
60778
62577
  skill
60779
- ]), exports_Command.provide(reporting(Failures, advise).pipe(exports_Layer.provide(layer16), exports_Layer.provideMerge(hint))), exports_Command.withGlobalFlags([Json3, Org2]));
62578
+ ]), exports_Command.provide(reporting(Failures, advise).pipe(exports_Layer.provide(layer18), exports_Layer.provideMerge(hint))), exports_Command.withGlobalFlags([Json3, Org2]));
60780
62579
  var main = exports_Command.run(ambral, { version: package_default.version }).pipe(exports_Effect.catchTag("ShowHelp", (help) => help.errors.length === 0 ? exports_Effect.void : exports_Effect.fail(help)));
60781
62580
 
60782
62581
  // src/bin.ts