@deslop/stash 0.1.1076 → 0.1.1079

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env -S node --max-old-space-size=16384 --heapsnapshot-near-heap-limit=3 --report-on-fatalerror
2
- import { $ as CloseEvent, $a as exit, $c as makeUnsafe$4, $d as identity, $i as shutdown, $l as lastNonEmpty, $n as value$2, $o as runForkWith, $r as flattenIterable, $s as trimEnd, $t as decodeEffect, $u as fromNullishOr, A as withDefault, Aa as all, Ac as mergeAll, Ad as NodeInspectSymbol, Ai as suspend$1, Al as dedupeAdjacentWith, An as withDecodingDefaultKey, Ar as toEncoded, As as zipWith, At as Json, Au as format$2, B as constEof, Bc as closeUnsafe, Bd as isNotNullish, Bl as flatMap$1, Bn as fromIterable$2, Bo as orDie, Br as FileSystem, Bs as isEmpty$2, Bt as Redacted, Bu as getOrUndefined$1, C as Redacted$1, Ca as ipv4ToOctets, Cc as buildWithMemoMap, Cd as contE, Ci as runCollect, Cl as Error$1, Cn as toCodecJson, Co as logFatal, Cr as mapOrSame, Cs as void_, Ct as Defect, Cu as isFailure, D as option, Da as isUnicast, Dc as empty$13, Dd as setStackTraceLimit, Di as runLast, Dl as appendAll, Dn as toType, Do as map$1, Dr as resolveDescription, Ds as withLogSpan, Du as match$3, E as map$8, Ea as isPrivate, Ec as effectDiscard, Ed as getStackTraceLimit, En as toJsonSchemaDocument, Eo as makeSpanScoped, Er as replaceChecks, Es as withFiberSucceed, Et as Exit$1, Eu as map$5, F as json$1, Fa as asSome, Fc as unwrap$2, Fd as equals, Fi as unwrap$1, Fl as filter$4, Fn as empty$7, Fo as onError, Fr as formatIso, Ft as NonEmptyArray, Fu as Reference, G as isWrapper, Ga as catchTag, Gc as CurrentLogAnnotations, Gd as compose$1, Gl as groupBy, Gn as fromRecordUnsafe, Go as provideService, Gr as decodeText, Gs as repeat$1, Gt as Tuple, Gu as merge$1, H as constPong, Hc as make$32, Hd as isObject, Hi as pipeTo, Hl as get$6, Hn as CurrentRedactedNames, Ho as promise, Hr as catchTags$1, Hs as length, Ht as Struct, Hu as getUnsafe, I as layerJson, Ia as asVoid, Ic as Scope, Id as hash, Ii as last$2, Il as filterMap, In as fromInput, Io as onExit, Ir as now, Is as Random$2, It as Null, Iu as Service, J as isStreamSchema, Ja as context$1, Jc as TracerTimingEnabled, Jd as constUndefined, Ji as failCause$2, Jl as isArrayNonEmpty, Jn as remove$3, Jo as repeat, Jr as ensuring, Js as slice$2, Jt as Uint8Array$2, Ju as exists, K as ClientAbort$1, Ka as catchTags, Kc as CurrentLogSpans, Kd as constFalse, Ki as collect, Kl as head, Kn as isRedactedName, Ko as provideServiceEffect, Kr as die$3, Ks as replace$1, Kt as URL$3, Ku as all$1, L as layerSchemaBinary, La as cached, Lc as addFinalizer, Ld as hasProperty, Ll as findFirst, Ln as setAll$1, Lo as onExitPrimitive, Lr as toEpochMillis, Ls as camelToSnake, Lt as NullOr, Lu as add$1, M as withRun, Ma as annotateCurrentSpan, Mc as provideMerge, Md as toStringUnknown, Mi as tap, Ml as empty$11, Mn as omit, Mo as matchCauseEffectEager, Mr as transform$1, Mt as Literals, Mu as parts, Na as annotateLogs, Nc as succeed$2, Nd as format$1, Ni as toReadableStreamEffect, Nl as ensure, Nn as getReferenceKey, No as matchEffect, Nr as transformOptional, Nt as MutableJson, Nu as seconds, O as succeed$5, Oa as unixPathAddress, Oc as launch, Od as BaseProto, Oi as scan, Ol as contains$1, On as withConstructorDefault, Oo as mapEager, Or as resolveIdentifier, Os as withParentSpan, Ot as Finite, Ou as succeed, P as RpcSerialization, Pa as as$1, Pc as succeedContext, Pd as redact, Pl as every, Pn as encodeUnknownEffect, Po as never, Pr as encode, Ps as catchDone, Pt as Never, Q as makeCollectorUnsafe, Qa as ensuring$1, Qc as isDeferred, Qd as flow, Qi as offerUnsafe, Ql as last$1, Qn as make$37, Qo as runFork, Qr as flatMap$3, Qs as trim, Qt as Unknown, Qu as flatten, R as RequestId, Ra as callback, Rc as addFinalizerExit, Rd as isIterable, Ri as fromTransform, Rl as findFirstIndex, Rn as fromIterable$3, Ro as onInterrupt, Rr as defaultFormatter, Rs as endsWith, Rt as Number$2, S as Port, Sa as ipv4FromString, Sc as CurrentMemoMap, Sd as contA, Si as run$3, Sl as nativeTracer, Sn as tag, Sr as isOptional, Ss as useSpan, St as DateTimeUtcFromString, Su as getOrElse$1, T as URL$4, Ta as isLoopback, Tc as effectContext, Td as assignProperty, Ti as runForEachArray, Tl as TaggedError, Tn as toEncoded$1, To as logWarning, Tr as optionalKey$1, Ts as withFiber, Tt as Error$2, Tu as isSuccess, U as ServerClient, Ua as catchIf, Uc as makeUnsafe$2, Ud as isTagged, Ui as make$31, Ul as getSomes, Un as empty$8, Uo as provide$2, Ur as catch_$1, Us as match$2, Ut as TaggedError$1, Uu as make$36, Va as catchDefect, Vc as forkUnsafe$1, Vd as isNotUndefined, Vl as fromIterable$1, Vn as get$7, Vo as orElseSucceed, Vr as catchReason$1, Vs as isNonEmpty$1, Vt as String$1, Vu as getOrUndefinedUnsafe, W as exitSchema, Wa as catchReason, Wc as provide$1, Wd as isUndefined, Wi as makeUnsafe$6, Wl as getUnsafe$1, Wn as fromInput$1, Wo as provideContext, Wr as concat, Ws as padStart, Wu as makeUnsafe$3, X as spanName, Xc as doneUnsafe, Xd as constant, Xi as offer, Xl as isReadonlyArrayNonEmpty, Xn as setAll, Xo as retry, Xr as failCause$3, Xs as startsWith, Xt as UndefinedOr, Xu as flatMap$2, Y as spanAttributes, Ya as contextWith, Yc as _await, Yd as constVoid, Yi as make$33, Yl as isReadonlyArrayEmpty, Yn as set$1, Yo as result$1, Yr as fail$2, Ys as split, Yt as Uint8ArrayFromBase64, Yu as filter$5, Z as Collector, Za as die$2, Zc as into, Zd as dual, Zi as offerAll, Zl as join$1, Zn as isRedacted, Zr as filter$6, Zs as toLowerCase, Zt as Union, Zu as flatMapNullishOr, _a as mebibytes, _d as combine$1, _i as mkUint8Array, _l as DisablePropagation, _n as make$35, _o as interrupt, _r as PropertySignature, _s as try_, _t as ArraySchema, _u as headUnsafe, a as ImageType, aa as makeUnsafe$5, ac as StackTrace, ad as isSome, ai as fromQueue, al as isFailure$1, an as encodeSync, ao as fn$1, ar as fromReadable, as as succeed$1, at as fromWebSocket, au as reverse, b as layer$11, ba as inetAddressFromIpString, bc as prettyErrors, bd as Prototype, bi as pipeThroughChannel, bl as externalSpan, bn as optional$1, bo as log, br as decodeTo$1, bs as updateContext, bt as Class$1, bu as failVoid, c as NotesError, ca as interrupt$2, cc as die$1, cd as map$3, ci as limitBytes, cn as fromJsonString, cr as toUint8Array$1, cs as sync, ct as DecodeError, cu as take$1, d as layer$13, da as interruptAs, dc as filterInterruptors, dd as orElse$2, di as mapArray, dl as fiberEnterUninterruptibleUnsafe, dn as isInt, do as forkScoped, dr as ChildProcessSpawner, ds as tapError, dt as HttpClientError, du as get$8, ec as max$1, ed as fromUndefinedOr, ef as pipe, ei as fromArray, el as die, en as decodeSync, eo as fail$1, er as empty$9, es as runSync, eu as map$4, f as make$39, fa as runIn, fd as orElseSome, fi as mapArrayEffect, fl as forkUnsafe, fn as isMaxLength, fo as fromOption, fr as Arrays, fs as timeout, fu as has$3, g as layer$12, ga as gibibytes, gc as hasInterruptsOnly, gd as String$3, gi as mkString, gn as isSchemaError$1, gr as Objects, gs as tryPromise, gt as Any, gu as empty$12, ha as fromInputUnsafe, hc as hasInterrupts, hd as Number$1, hi as mergeAll$1, hl as reportCauseUnsafe, hn as isSchema, ho as ignore$1, hr as Literal$2, hs as transposeOption, ht as TransportError, hu as toEntries, i as FileType, ia as unbounded, id as isNone, ii as fromPubSub, il as isExit, in as encodeEffect, io as flatMapEager, ir as toSetCookieHeaders, is as serviceOption, iu as reduce, ja as andThen, jc as provide, jd as toJson, ji as takeUntil, jl as drop, jn as isSchemaError, jo as matchCauseEffect, jr as passthrough, jt as Literal$1, ju as millis, k as unwrap$3, ka as acquireRelease, kc as merge$3, kd as Class, ki as succeed$3, kl as dedupe, kn as withDecodingDefault, ko as mapError, kr as string, ks as withSpan, kt as Int, ku as try_$1, l as Organization, la as interruptAll, ld as match$1, li as map$2, ll as effectIsExit, ln as is$4, lo as forkChild, lr as fromWritable, ls as tap$1, lt as EmptyBodyError, lu as takeRight, ma as fromInput$2, mc as hasDies, md as toArray$1, mi as mapError$1, ml as onExitUnsafe, mn as isPattern, mo as gen, mr as FilterGroup, ms as timeoutOrElse, mt as StatusCodeError, mu as map$7, n as Capture, na as takeAll, nd as getOrNull, ni as fromEffect, nl as failCause$1, nn as decodeUnknownEffect, no as filterOrFail, nr as isEmpty$1, ns as scoped, nu as of, o as Note, oa as await_, oc as annotate, od as liftPredicate, oi as fromReadableStream, ol as isSuccess$1, on as encodeTo, oo as fnUntraced, or as pipeThroughDuplex, os as succeedNone, ou as some$2, p as runMain, pa as badArgument, pc as fromReasons, pd as some$1, pi as mapEffect, pl as makeSpanUnsafe, pn as isMinLength, po as fromResult, pr as Filter, ps as timeoutOption, pt as InvalidUrlError, pu as keys, q as getStreamSchemas, qa as catch_, qd as constTrue, qi as end$1, ql as headNonEmpty, qn as merge$2, qo as raceFirst, qr as empty$10, qs as replaceAll, qt as URLFromString, qu as contains$2, r as Extraction, ra as publishUnsafe, rc as Clock, rd as getOrUndefined, ri as fromIterable, rl as interrupt$1, rn as decodeUnknownOption, ro as flatMap, rr as parseHeader, rs as service, rt as SocketOpenError, ru as prepend$2, s as NoteId, sa as getCurrent, sc as combine, sd as liftThrowable, si as groupedWithin, sl as succeed$4, sn as encodeUnknownEffect$1, so as forEach, sr as toArrayBuffer, ss as suspend, su as sort, t as RpcContracts, ta as take, tc as parse$10, td as getOrElse, tf as pipeArguments, tl as fail$3, tn as decodeTo, to as failCause, tr as fromSetCookie, ts as scope, tt as SocketError, ua as interruptAllAs, uc as fail$4, ud as none, ui as mapAccum, ul as fiberEnterInterruptibleUnsafe, un as isGreaterThanOrEqualTo, ur as make$34, us as tapCause, ut as EncodeError, uu as assignProperty$1, va as zero, vc as isNoSuchElementError, vd as flip, vi as onEnd, vl as ParentSpan, vn as makeFilter, vo as interruptible, vr as Suspend, vs as uninterruptible, vt as Boolean$2, vu as make$38, w as String$2, wa as isLinkLocal, wc as effect, wi as runForEach, wl as TaggedClass, wo as logInfo, wr as null_, ws as whileLoop, wt as Duration, wu as isResult, xa as ipFromString, xc as squash, xd as PipeInspectableProto, xi as provideService$1, xl as make$40, xn as optionalKey, xo as logDebug, xr as isNever, xs as updateService, xt as DateTimeUtc, xu as fromOption$1, ya as formatUrlUnsafe, yc as makeDieReason, yd as mapInput, yi as orDie$1, yl as Tracer, yn as mutable, yo as isEffect, yr as Union$1, ys as uninterruptibleMask, yu as fail, z as ResponseDefectEncoded, za as catchCause, zc as close, zd as isNotNull, zi as map$6, zn as has$4, zo as option$1, zr as Path, zs as includes, zt as Record, zu as get$5 } from "./contracts-DgOSCO2p.mjs";
2
+ import { $ as CloseEvent, $c as close, $d as isNotUndefined, $i as offer, $n as setAll, $o as orDie, $r as failCause$3, $s as includes, $t as decodeEffect, $u as getOrUndefinedUnsafe, A as withDefault, Aa as formatIp, Ac as hasInterruptsOnly, Ad as flip, Ai as runLast, An as withDecodingDefaultKey, Ao as interrupt, Ar as resolveDescription, As as try_, At as Json, Au as empty$12, B as constEof, Ba as isUnicast, Bc as effectDiscard, Bd as BaseProto, Bn as unwrap$1, Bo as map$1, Br as toEpochMillis, Bs as withFiberSucceed, Bt as Redacted, Bu as succeed, C as Redacted$1, Ca as DnsError, Cd as orElse$2, Ci as pipeThroughChannel, Cl as effectIsExit, Cn as toCodecJson, Cr as decodeTo$1, Cs as tapCause, Ct as Defect, Cu as takeRight, D as option, Da as domainNameFromStringUnsafe, Dc as fromReasons, Dd as Number$1, Di as runForEach, Dl as makeSpanUnsafe, Dn as toType, Do as gen, Dr as null_, Ds as timeoutOrElse, Du as keys, E as map$7, Ea as nameServerFromInput, Ed as toArray$1, Ei as runCollect, El as forkUnsafe, En as toJsonSchemaDocument, Eo as fromResult, Er as mapOrSame, Es as timeoutOption, Et as Exit$1, Eu as has$3, F as json$1, Fa as ipv4ToOctets, Fc as squash, Fd as contE, Fi as tap, Fl as make$41, Fn as CurrentRedactedNames$1, Fr as transform$1, Fs as useSpan, Ft as NonEmptyArray, Fu as fromOption$1, G as isWrapper, Ga as annotateCurrentSpan, Gc as provide, Gd as format$1, Gi as pipeTo, Gl as drop, Gn as CurrentRedactedNames, Go as matchCauseEffectEager, Gr as catchTags$1, Gt as Tuple, Gu as seconds, H as constPong, Ha as acquireRelease, Hc as launch, Hd as NodeInspectSymbol, Hi as map$5, Hl as contains$1, Hn as has$4, Ho as mapError, Hr as Path, Hs as withParentSpan, Ht as Struct, Hu as format$2, I as layerJson, Ia as isInetAddressV6, Ic as CurrentMemoMap, Ii as toReadableStreamEffect, Il as nativeTracer, In as empty$7, Io as logFatal, Ir as transformOptional, Is as void_, It as Null, Iu as isFailure, J as isStreamSchema, Ja as asSome, Jc as succeedContext, Jd as hash, Jl as every, Jn as fromRecordUnsafe, Jo as onError, Jr as decodeText, Js as catchDone, Jt as Uint8Array$2, Ju as Service, K as ClientAbort$1, Ka as annotateLogs, Kc as provideMerge, Kd as redact, Ki as make$32, Kl as empty$11, Kn as empty$8, Ko as matchEffect, Kr as catch_$1, Kt as URL$3, Ku as toMillis, L as layerSchemaBinary, La as isLinkLocal, Lc as buildWithMemoMap, Ld as assignProperty, Ll as Error$1, Ln as fromInput, Lo as logInfo, Lr as encode, Ls as when$2, Lt as NullOr, Lu as isResult, M as withRun, Ma as inetAddressFromIpString, Mc as isNoSuchElementError, Md as Prototype, Mi as succeed$3, Ml as ParentSpan, Mn as omit, Mo as isEffect, Mr as string, Ms as uninterruptibleMask, Mt as Literals, Mu as make$40, Na as ipFromString, Nc as makeDieReason, Nd as PipeInspectableProto, Ni as suspend$1, Nl as Tracer, Nn as getReferenceKey, No as log, Nr as toEncoded, Ns as updateContext, Nt as MutableJson, Nu as fail, O as succeed$5, Oa as NetAddressError, Oc as hasDies, Od as String$3, Oi as runForEachArray, Ol as onExitUnsafe, On as withConstructorDefault, Oo as ignore$1, Or as optionalKey$1, Os as transposeOption, Ot as Finite, Ou as map$6, P as RpcSerialization, Pa as ipFromStringUnsafe, Pc as prettyErrors, Pd as contA, Pi as takeUntil, Pl as externalSpan, Pn as encodeUnknownEffect, Po as logDebug, Pr as passthrough, Ps as updateService, Pt as Never, Pu as failVoid, Q as makeCollectorUnsafe, Qa as catchCause, Qc as addFinalizerExit, Qd as isNotNullish, Qi as make$34, Ql as findFirstIndex, Qn as set$1, Qo as option$1, Qr as fail$2, Qs as endsWith, Qt as Unknown, Qu as getOrUndefined$1, R as RequestId, Ra as isLoopback, Rc as effect, Rd as getStackTraceLimit, Ri as unwrap$2, Rl as TaggedClass, Rn as redactUrl, Ro as logWarning, Rr as formatIso, Rs as whileLoop, Rt as Number$2, Ru as isSuccess, S as Port, Sa as Dns, Sc as die$1, Sd as none, Si as orDie$1, Sn as tag, So as forkChild, Sr as Union$1, Ss as tap$1, St as DateTimeUtcFromString, Su as take$1, T as URL$4, Ta as makeRecordUnsafe, Tc as filterInterruptors, Td as some$1, Ti as run$3, Tl as fiberEnterUninterruptibleUnsafe, Tn as toEncoded$1, To as fromOption, Tr as isOptional, Ts as timeout, Tt as Error$2, Tu as get$8, U as ServerClient, Ua as all, Uc as merge$3, Ud as toJson, Ul as dedupe, Un as fromIterable$2, Ur as FileSystem, Us as withSpan, Ut as TaggedError$1, Uu as millis, Va as unixPathAddress, Vc as empty$13, Vd as Class, Vi as fromTransform, Vl as appendAll, Vn as fromIterable$3, Vo as mapEager, Vr as defaultFormatter, Vs as withLogSpan, Vt as String$1, Vu as try_$1, W as exitSchema, Wa as andThen, Wc as mergeAll, Wd as toStringUnknown, Wl as dedupeAdjacentWith, Wn as get$7, Wo as matchCauseEffect, Wr as catchReason$1, Ws as zipWith, Wu as parts, X as spanName, Xa as cached, Xc as Scope, Xd as isIterable, Xi as end$1, Xl as filterMap, Xn as merge$2, Xo as onExitPrimitive, Xr as empty$10, Xs as Random$2, Xt as UndefinedOr, Y as spanAttributes, Ya as asVoid, Yc as unwrap$3, Yd as hasProperty, Yi as collect, Yl as filter$4, Yn as isRedactedName, Yo as onExit, Yr as die$3, Yt as Uint8ArrayFromBase64, Yu as add$1, Z as Collector, Za as callback, Zc as addFinalizer, Zd as isNotNull, Zi as failCause$2, Zl as findFirst, Zn as remove$3, Zo as onInterrupt, Zr as ensuring, Zs as camelToSnake, Zt as Union, Zu as get$5, _a as fromInput$2, _c as Clock, _d as isSome, _i as mapError$1, _l as interrupt$1, _n as make$37, _o as flatMapEager, _r as FilterGroup, _s as serviceOption, _t as ArraySchema, _u as prepend$2, a as ImageType, aa as takeAll, ac as repeat$1, ad as contains$2, af as constTrue, ai as fromEffect, al as CurrentLogAnnotations, an as encodeSync, ao as catchTags, ar as isEmpty$1, as as provideServiceEffect, at as fromWebSocket, au as groupBy, b as layer$12, ba as mebibytes, bc as annotate, bd as map$4, bi as mkUint8Array, bl as isSuccess$1, bn as optional$1, bo as forEach, br as PropertySignature, bs as suspend, bt as Class$1, bu as some$2, c as NotesError, ca as makeUnsafe$5, cc as slice$2, cd as flatMap$2, cf as constant, ci as fromQueue, cl as TracerTimingEnabled, cn as fromJsonString, co as contextWith, cr as fromReadable, cs as result$1, ct as DecodeError, cu as isArrayNonEmpty, d as layer$14, da as interrupt$2, dc as toLowerCase, dd as fromNullishOr, df as identity, di as limitBytes, dl as into, dn as isInt, do as ensuring$1, dr as toUint8Array$1, ds as runFork, dt as HttpClientError, du as join$1, ea as offerAll, ec as isEmpty$2, ed as getUnsafe, ef as isObject, ei as filter$6, el as closeUnsafe, en as decodeSync, eo as catchDefect, er as isRedacted, es as orElseSucceed, eu as flatMap$1, f as make$42, fa as interruptAll, fc as trim, fd as fromUndefinedOr, ff as pipe, fi as map$2, fl as isDeferred, fn as isMaxLength, fo as exit, fr as fromWritable, fs as runForkWith, fu as last$1, g as layer$13, ga as badArgument, gd as isNone, gi as mapEffect, gl as failCause$1, gn as isSchemaError$1, go as flatMap, gr as Filter, gs as service, gt as Any, gu as of, ha as runIn, hc as parse$10, hd as getOrUndefined, hi as mapArrayEffect, hl as fail$3, hn as isSchema, ho as filterOrFail, hr as Arrays, hs as scoped, ht as TransportError, i as FileType, ia as take, ic as padStart, id as all$1, if as constFalse, il as provide$1, in as encodeEffect, io as catchTag, ir as fromSetCookie, is as provideService, iu as getUnsafe$1, ja as formatUrlUnsafe, jd as mapInput, ji as scan, jl as DisablePropagation, jn as isSchemaError, jo as interruptible, jr as resolveIdentifier, js as uninterruptible, jt as Literal$1, ju as headUnsafe, k as unwrap$4, ka as formatInet, kc as hasInterrupts, kd as combine$1, kl as reportCauseUnsafe, kn as withDecodingDefault, kr as replaceChecks, ks as tryPromise, kt as Int, ku as toEntries, l as Organization, la as await_, lc as split, ld as flatMapNullishOr, lf as dual, li as fromReadableStream, ll as _await, ln as is$4, lr as pipeThroughDuplex, ls as retry, lt as EmptyBodyError, lu as isReadonlyArrayEmpty, ma as interruptAs, mc as max$1, md as getOrNull, mi as mapArray, ml as die, mn as isPattern, mo as failCause, mr as ChildProcessSpawner, ms as scope, mt as StatusCodeError, mu as map$3, n as Capture, na as shutdown, nc as length, nd as makeUnsafe$3, nf as isUndefined, ni as flattenIterable, nl as make$33, nn as decodeUnknownEffect, no as catchIf, nr as value$2, ns as provide$2, nu as get$6, o as Note, oa as publishUnsafe, oc as replace$1, od as exists, of as constUndefined, oi as fromIterable, ol as CurrentLogSpans, on as encodeTo, oo as catch_, or as parseHeader, os as raceFirst, ou as head, p as runMain, pa as interruptAllAs, pc as trimEnd, pd as getOrElse, pf as pipeArguments, pi as mapAccum, pl as makeUnsafe$4, pn as isMinLength, po as fail$1, pr as make$36, ps as runSync, pt as InvalidUrlError, pu as lastNonEmpty, q as getStreamSchemas, qa as as$1, qc as succeed$2, qd as equals, qi as makeUnsafe$6, ql as ensure, qn as fromInput$1, qo as never, qr as concat, qt as URLFromString, qu as Reference, r as Extraction, rc as match$2, rd as merge$1, rf as compose$1, ri as fromArray, rl as makeUnsafe$2, rn as decodeUnknownOption, ro as catchReason, rr as empty$9, rs as provideContext, rt as SocketOpenError, ru as getSomes, s as NoteId, sa as unbounded, sc as replaceAll, sd as filter$5, sf as constVoid, si as fromPubSub, sn as encodeUnknownEffect$1, so as context$1, sr as toSetCookieHeaders, ss as repeat, su as headNonEmpty, t as RpcContracts, ta as offerUnsafe, tc as isNonEmpty$1, td as make$38, tf as isTagged, ti as flatMap$3, tl as forkUnsafe$1, tn as decodeTo, tr as make$39, ts as promise, tt as SocketError, tu as fromIterable$1, ua as getCurrent, uc as startsWith, ud as flatten, uf as flow, ui as groupedWithin, ul as doneUnsafe, un as isGreaterThanOrEqualTo, uo as die$2, ur as toArrayBuffer, ut as EncodeError, uu as isReadonlyArrayNonEmpty, va as fromInputUnsafe, vd as liftPredicate, vi as mergeAll$1, vl as isExit, vn as makeFilter, vo as fn$1, vr as Literal$2, vs as succeed$1, vt as Boolean$2, vu as reduce, w as String$2, wa as make$35, wc as fail$4, wd as orElseSome, wi as provideService$1, wl as fiberEnterInterruptibleUnsafe, wo as forkScoped, wr as isNever, ws as tapError, wt as Duration, wu as assignProperty$1, xa as zero, xc as combine, xd as match$1, xi as onEnd, xl as succeed$4, xn as optionalKey, xr as Suspend, xs as sync, xt as DateTimeUtc, xu as sort, ya as gibibytes, yc as StackTrace, yd as liftThrowable, yi as mkString, yl as isFailure$1, yn as mutable, yo as fnUntraced, yr as Objects, ys as succeedNone, yu as reverse, z as ResponseDefectEncoded, za as isPrivate, zc as effectContext, zd as setStackTraceLimit, zi as last$2, zl as TaggedError, zn as setAll$1, zo as makeSpanScoped, zr as now, zs as withFiber, zt as Record, zu as match$3 } from "./contracts-Cc_B2S3-.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import { Duplex, Readable, pipeline } from "node:stream";
5
5
  import * as Http from "node:http";
@@ -13,13 +13,13 @@ import * as NodeStreamP from "node:stream/promises";
13
13
  import { pipeline as pipeline$1 } from "node:stream/promises";
14
14
  import * as Zlib from "node:zlib";
15
15
  import { fileURLToPath } from "node:url";
16
+ import * as NodeDns from "node:dns";
16
17
  import fs, * as fs$1 from "fs";
17
18
  import path, * as path$1 from "path";
18
19
  import { createRequire as createRequire$1 } from "module";
19
20
  import { Tensor } from "onnxruntime-common";
20
21
  import { pipeline as pipeline$2 } from "stream/promises";
21
22
  import sharp from "sharp";
22
- import { lookup } from "node:dns/promises";
23
23
  import { DatabaseSync } from "node:sqlite";
24
24
  //#region \0rolldown/runtime.js
25
25
  var __create = Object.create;
@@ -63,7 +63,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
63
63
  var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp$1({}, "__esModule", { value: true }), mod);
64
64
  var __require$1 = /* #__PURE__ */ (() => createRequire(import.meta.url))();
65
65
  //#endregion
66
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/Filter.js
66
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Filter.js
67
67
  /**
68
68
  * Converts a Filter into a predicate function.
69
69
  *
@@ -126,7 +126,7 @@ const compose = /*#__PURE__*/ dual(2, (left, right) => (input) => {
126
126
  return right(leftOut.success);
127
127
  });
128
128
  //#endregion
129
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/MutableHashMap.js
129
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/MutableHashMap.js
130
130
  const TypeId$19 = "~effect/MutableHashMap";
131
131
  const MutableHashMapProto = {
132
132
  [TypeId$19]: TypeId$19,
@@ -493,7 +493,7 @@ const snapshotUnsafe = (context) => {
493
493
  }));
494
494
  };
495
495
  //#endregion
496
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/HttpBody.js
496
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/HttpBody.js
497
497
  const TypeId$18 = "~effect/http/HttpBody";
498
498
  const HttpBodyErrorTypeId = "~effect/http/HttpBody/HttpBodyError";
499
499
  /**
@@ -638,9 +638,9 @@ var Uint8Array$1 = class extends Proto$10 {
638
638
  * @since 4.0.0
639
639
  */
640
640
  const uint8Array$1 = (body, contentType) => new Uint8Array$1(body, contentType ?? "application/octet-stream", body.length);
641
- const encoder = /*#__PURE__*/ new TextEncoder();
641
+ const encoder$1 = /*#__PURE__*/ new TextEncoder();
642
642
  const buffer$1 = globalThis.Buffer;
643
- const encodeText = buffer$1 !== void 0 ? (body) => buffer$1.from(body, "utf8") : (body) => encoder.encode(body);
643
+ const encodeText = buffer$1 !== void 0 ? (body) => buffer$1.from(body, "utf8") : (body) => encoder$1.encode(body);
644
644
  /**
645
645
  * Creates a UTF-8 encoded text HTTP body.
646
646
  *
@@ -655,7 +655,7 @@ const encodeText = buffer$1 !== void 0 ? (body) => buffer$1.from(body, "utf8") :
655
655
  const text$3 = (body, contentType) => {
656
656
  if (typeof body !== "string") body = body === void 0 ? "" : String(body);
657
657
  if (buffer$1 !== void 0) return new Uint8Array$1(void 0, contentType ?? "text/plain", buffer$1.byteLength(body, "utf8"), body);
658
- const bytes = encoder.encode(body);
658
+ const bytes = encoder$1.encode(body);
659
659
  return new Uint8Array$1(bytes, contentType ?? "text/plain", bytes.length, body);
660
660
  };
661
661
  /**
@@ -785,7 +785,7 @@ var Stream = class extends Proto$10 {
785
785
  */
786
786
  const stream$3 = (body, contentType, contentLength) => new Stream(body, contentType ?? "application/octet-stream", contentLength);
787
787
  //#endregion
788
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/HttpMethod.js
788
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/HttpMethod.js
789
789
  /**
790
790
  * Provides tuples mapping each supported HTTP method to its short
791
791
  * request-constructor name.
@@ -811,7 +811,7 @@ const allShort = [
811
811
  ["QUERY", "query"]
812
812
  ];
813
813
  //#endregion
814
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/internal/httpBody.js
814
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/internal/httpBody.js
815
815
  /**
816
816
  * @internal
817
817
  */
@@ -821,7 +821,7 @@ const updateHeaders = (headers, body) => {
821
821
  return body.contentLength === void 0 ? remove$3(headers, "content-length") : set$1(headers, "content-length", body.contentLength.toString());
822
822
  };
823
823
  //#endregion
824
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/Url.js
824
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/Url.js
825
825
  /**
826
826
  * Error returned when constructing a `URL` fails.
827
827
  *
@@ -841,12 +841,12 @@ var UrlError = class extends (/*#__PURE__*/ TaggedError("UrlError")) {};
841
841
  * @category constructors
842
842
  * @since 4.0.0
843
843
  */
844
- const make$30 = (url, params, hash) => try_$1({
844
+ const make$31 = (url, params, hash) => try_$1({
845
845
  try: () => {
846
846
  const urlInstance = new URL(url, baseUrl());
847
847
  for (let i = 0; i < params.params.length; i++) {
848
848
  const [key, value] = params.params[i];
849
- if (value !== void 0) urlInstance.searchParams.append(key, value);
849
+ if (value !== void 0) urlInstance.searchParams.append(key, unwrap$1(value));
850
850
  }
851
851
  if (hash !== void 0) urlInstance.hash = hash;
852
852
  return urlInstance;
@@ -857,7 +857,7 @@ const baseUrl = () => {
857
857
  if ("location" in globalThis && globalThis.location !== void 0 && globalThis.location.origin !== void 0 && globalThis.location.pathname !== void 0) return location.origin + location.pathname;
858
858
  };
859
859
  //#endregion
860
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/HttpClientRequest.js
860
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/HttpClientRequest.js
861
861
  const TypeId$17 = "~effect/http/HttpClientRequest";
862
862
  const Proto$9 = {
863
863
  [TypeId$17]: TypeId$17,
@@ -866,7 +866,7 @@ const Proto$9 = {
866
866
  return {
867
867
  _id: "HttpClientRequest",
868
868
  method: this.method,
869
- url: this.url,
869
+ url: redactUrl(this.url),
870
870
  urlParams: this.urlParams,
871
871
  hash: this.hash,
872
872
  headers: redact(this.headers),
@@ -909,7 +909,7 @@ const empty$4 = /*#__PURE__*/ makeWith$1("GET", "", empty$7, /*#__PURE__*/ none(
909
909
  * @category constructors
910
910
  * @since 4.0.0
911
911
  */
912
- const make$29 = (method) => (url, options) => modify(empty$4, {
912
+ const make$30 = (method) => (url, options) => modify(empty$4, {
913
913
  method,
914
914
  url,
915
915
  ...options ?? void 0
@@ -921,7 +921,7 @@ const make$29 = (method) => (url, options) => modify(empty$4, {
921
921
  * @category constructors
922
922
  * @since 4.0.0
923
923
  */
924
- const get$3 = /*#__PURE__*/ make$29("GET");
924
+ const get$3 = /*#__PURE__*/ make$30("GET");
925
925
  /**
926
926
  * Creates a `POST` request for the specified URL.
927
927
  *
@@ -929,8 +929,8 @@ const get$3 = /*#__PURE__*/ make$29("GET");
929
929
  * @category constructors
930
930
  * @since 4.0.0
931
931
  */
932
- const post = /*#__PURE__*/ make$29("POST");
933
- const del = /*#__PURE__*/ make$29("DELETE");
932
+ const post = /*#__PURE__*/ make$30("POST");
933
+ const del = /*#__PURE__*/ make$30("DELETE");
934
934
  /**
935
935
  * Applies request options to an `HttpClientRequest`, returning a new request.
936
936
  *
@@ -1081,12 +1081,12 @@ const bodyFormData = /*#__PURE__*/ dual(2, (self, body) => setBody$1(self, formD
1081
1081
  * @since 4.0.0
1082
1082
  */
1083
1083
  function toUrl(self) {
1084
- const r = make$30(self.url, self.urlParams, getOrUndefined(self.hash));
1084
+ const r = make$31(self.url, self.urlParams, getOrUndefined(self.hash));
1085
1085
  if (isSuccess(r)) return some$1(r.success);
1086
1086
  return none();
1087
1087
  }
1088
1088
  //#endregion
1089
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/HttpIncomingMessage.js
1089
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/HttpIncomingMessage.js
1090
1090
  /**
1091
1091
  * Type identifier for `HttpIncomingMessage` values.
1092
1092
  *
@@ -1140,7 +1140,7 @@ const inspect$1 = (self, that) => {
1140
1140
  return obj;
1141
1141
  };
1142
1142
  //#endregion
1143
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/HttpClientResponse.js
1143
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/HttpClientResponse.js
1144
1144
  /**
1145
1145
  * Represents responses returned by the Effect HTTP client.
1146
1146
  *
@@ -1304,7 +1304,7 @@ var WebHttpClientResponse = class extends Class {
1304
1304
  }
1305
1305
  };
1306
1306
  //#endregion
1307
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/HttpTraceContext.js
1307
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/HttpTraceContext.js
1308
1308
  /**
1309
1309
  * HTTP propagation helpers for Effect tracing context.
1310
1310
  *
@@ -1333,7 +1333,7 @@ const toHeaders = (span) => fromRecordUnsafe({
1333
1333
  onNone: () => "",
1334
1334
  onSome: (parent) => `-${parent.spanId}`
1335
1335
  })}`,
1336
- traceparent: `00-${span.traceId}-${span.spanId}-${span.sampled ? "01" : "00"}`
1336
+ traceparent: `00-${span.traceId.padStart(32, "0")}-${span.spanId}-${span.sampled ? "01" : "00"}`
1337
1337
  });
1338
1338
  /**
1339
1339
  * Decodes an external span safely from HTTP trace propagation headers.
@@ -1428,7 +1428,7 @@ const w3c = (headers) => {
1428
1428
  }
1429
1429
  };
1430
1430
  //#endregion
1431
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/internal/tracing.js
1431
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/internal/tracing.js
1432
1432
  const defaultPorts = {
1433
1433
  "http:": 80,
1434
1434
  "https:": 443,
@@ -1436,13 +1436,13 @@ const defaultPorts = {
1436
1436
  "wss:": 443
1437
1437
  };
1438
1438
  /**
1439
- * Records the `url.*` and `server.*` attributes for a request URL.
1439
+ * Records `url.*` and `server.*` attributes with URL redaction.
1440
1440
  *
1441
1441
  * @internal
1442
1442
  */
1443
- const addUrlAttributes = (span, url) => {
1444
- const query = url.search.slice(1);
1445
- span.attribute("url.full", url.toString());
1443
+ const addUrlAttributes = (span, url, redactedNames) => {
1444
+ const query = redactUrl(url.search, redactedNames).slice(1);
1445
+ span.attribute("url.full", redactUrl(url.href, redactedNames));
1446
1446
  span.attribute("url.path", url.pathname);
1447
1447
  if (query !== "") span.attribute("url.query", query);
1448
1448
  span.attribute("url.scheme", url.protocol.slice(0, -1));
@@ -1452,6 +1452,15 @@ const addUrlAttributes = (span, url) => {
1452
1452
  if (port !== void 0) span.attribute("server.port", port);
1453
1453
  }
1454
1454
  };
1455
+ /**
1456
+ * Adds the names of `Redacted` parameters to the redacted names.
1457
+ *
1458
+ * @internal
1459
+ */
1460
+ const redactedNames = (urlParams, redactedNames) => {
1461
+ const keys = urlParams.params.filter(([, value]) => typeof value !== "string").map(([key]) => key);
1462
+ return keys.length === 0 ? redactedNames : [...redactedNames, ...new URLSearchParams(keys.map((key) => [key, ""])).keys()];
1463
+ };
1455
1464
  /** @internal */
1456
1465
  const addHeaderAttributes = (span, phase, headers, filter, redactedNames) => {
1457
1466
  for (const name in headers) {
@@ -1460,7 +1469,7 @@ const addHeaderAttributes = (span, phase, headers, filter, redactedNames) => {
1460
1469
  }
1461
1470
  };
1462
1471
  //#endregion
1463
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/HttpClient.js
1472
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/HttpClient.js
1464
1473
  const TypeId$14 = "~effect/http/HttpClient";
1465
1474
  /**
1466
1475
  * Service tag for the default outgoing HTTP client service.
@@ -1530,7 +1539,7 @@ const Proto$8 = {
1530
1539
  return { _id: "effect/HttpClient" };
1531
1540
  },
1532
1541
  .../*#__PURE__*/ Object.fromEntries(/*#__PURE__*/ allShort.map(([fullMethod, method]) => [method, function(url, options) {
1533
- return this.execute(make$29(fullMethod)(url, options));
1542
+ return this.execute(make$30(fullMethod)(url, options));
1534
1543
  }]))
1535
1544
  };
1536
1545
  /**
@@ -1544,10 +1553,10 @@ const Proto$8 = {
1544
1553
  * @category constructors
1545
1554
  * @since 4.0.0
1546
1555
  */
1547
- const make$28 = (f) => makeWith((effect) => flatMap(effect, (request) => withFiber((fiber) => {
1556
+ const make$29 = (f) => makeWith((effect) => flatMap(effect, (request) => withFiber((fiber) => {
1548
1557
  const scopedController = scopedRequests.get(request);
1549
1558
  const controller = scopedController ?? new AbortController();
1550
- const urlResult = make$30(request.url, request.urlParams, getOrUndefined(request.hash));
1559
+ const urlResult = make$31(request.url, request.urlParams, getOrUndefined(request.hash));
1551
1560
  if (isFailure(urlResult)) return fail$1(new HttpClientError({ reason: new InvalidUrlError({
1552
1561
  request,
1553
1562
  cause: urlResult.failure
@@ -1570,7 +1579,7 @@ const make$28 = (f) => makeWith((effect) => flatMap(effect, (request) => withFib
1570
1579
  return useSpan(fiber.getRef(SpanNameGenerator$1)(request), { kind: "client" }, (span) => {
1571
1580
  span.attribute("http.request.method", request.method);
1572
1581
  const redactedHeaderNames = fiber.getRef(CurrentRedactedNames);
1573
- addUrlAttributes(span, url);
1582
+ addUrlAttributes(span, url, redactedNames(request.urlParams, fiber.getRef(CurrentRedactedNames$1)));
1574
1583
  const headerFilter = fiber.getRef(TracerHeaderFilter$1);
1575
1584
  addHeaderAttributes(span, "request", request.headers, headerFilter, redactedHeaderNames);
1576
1585
  request = fiber.getRef(TracerPropagationEnabled) ? setHeaders$1(request, toHeaders(span)) : request;
@@ -1639,6 +1648,18 @@ const TracerHeaderFilter$1 = /*#__PURE__*/ Reference("effect/http/HttpClient/Tra
1639
1648
  /**
1640
1649
  * Context reference that controls whether outgoing client spans are propagated to request headers.
1641
1650
  *
1651
+ * **Details**
1652
+ *
1653
+ * When this is `true`, the client writes the compact B3 `b3` header and the
1654
+ * W3C `traceparent` header. The default is on. The client span is still
1655
+ * created when this is `false`.
1656
+ *
1657
+ * **Gotchas**
1658
+ *
1659
+ * A browser preflight fails when the target does not list `b3` and
1660
+ * `traceparent` in `Access-Control-Allow-Headers`. Set this to `false` for
1661
+ * those requests.
1662
+ *
1642
1663
  * @stability unstable
1643
1664
  * @category services
1644
1665
  * @since 4.0.0
@@ -1761,7 +1782,7 @@ var InterruptibleResponse = class {
1761
1782
  }
1762
1783
  };
1763
1784
  //#endregion
1764
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/FindMyWay/internal/queryString.js
1785
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/FindMyWay/internal/queryString.js
1765
1786
  /**
1766
1787
  * @since 1.0.0
1767
1788
  */
@@ -1830,7 +1851,7 @@ function parse$9(input) {
1830
1851
  return result;
1831
1852
  }
1832
1853
  //#endregion
1833
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/FindMyWay/internal/router.js
1854
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/FindMyWay/internal/router.js
1834
1855
  const FULL_PATH_REGEXP = /^https?:\/\/.*?\//;
1835
1856
  const OPTIONAL_PARAM_REGEXP = /(\/:[^/()]*?)\?(\/?)/;
1836
1857
  const emptyParamsArray = [];
@@ -1839,7 +1860,7 @@ const isCleanSingleTrailingParam = (path) => CLEAN_SINGLE_PARAM_REGEXP.test(path
1839
1860
  /**
1840
1861
  * @internal
1841
1862
  */
1842
- const make$27 = (options = {}) => new RouterImpl(options);
1863
+ const make$28 = (options = {}) => new RouterImpl(options);
1843
1864
  var RouterImpl = class {
1844
1865
  constructor(options = {}) {
1845
1866
  this.options = {
@@ -2312,6 +2333,7 @@ function makeCreateParams(params) {
2312
2333
  return paramsObject;
2313
2334
  };
2314
2335
  }
2336
+ /** @internal */
2315
2337
  function getClosingParenthensePosition(path, idx) {
2316
2338
  let parentheses = 1;
2317
2339
  while (idx < path.length) {
@@ -2443,7 +2465,7 @@ const httpMethods = [
2443
2465
  "UNSUBSCRIBE"
2444
2466
  ];
2445
2467
  //#endregion
2446
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/FindMyWay.js
2468
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/FindMyWay.js
2447
2469
  /**
2448
2470
  * A radix-tree HTTP router used by the unstable HTTP routing modules.
2449
2471
  *
@@ -2457,9 +2479,9 @@ const httpMethods = [
2457
2479
  * @category constructors
2458
2480
  * @since 4.0.0
2459
2481
  */
2460
- const make$26 = make$27;
2482
+ const make$27 = make$28;
2461
2483
  //#endregion
2462
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/Etag.js
2484
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/Etag.js
2463
2485
  /**
2464
2486
  * HTTP entity tag values and metadata-based generator layers.
2465
2487
  *
@@ -2524,7 +2546,7 @@ const fromFileWeb = (file) => {
2524
2546
  * @category layers
2525
2547
  * @since 4.0.0
2526
2548
  */
2527
- const layer$10 = /*#__PURE__*/ succeed$2(Generator)({
2549
+ const layer$11 = /*#__PURE__*/ succeed$2(Generator)({
2528
2550
  fromFileInfo(info) {
2529
2551
  return sync(() => ({
2530
2552
  _tag: "Strong",
@@ -2560,7 +2582,7 @@ const layerWeak = /*#__PURE__*/ succeed$2(Generator)({
2560
2582
  }
2561
2583
  });
2562
2584
  //#endregion
2563
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/ErrorReporter.js
2585
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/ErrorReporter.js
2564
2586
  /**
2565
2587
  * Defines the runtime property key used to mark an object error as ignored by error
2566
2588
  * reporting.
@@ -2598,14 +2620,14 @@ const layerWeak = /*#__PURE__*/ succeed$2(Generator)({
2598
2620
  */
2599
2621
  const ignore = "~effect/ErrorReporter/ignore";
2600
2622
  //#endregion
2601
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/internal/headers.js
2623
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/internal/headers.js
2602
2624
  const Proto$7 = /*#__PURE__*/ Object.getPrototypeOf(empty$8);
2603
2625
  /**
2604
2626
  * @internal
2605
2627
  */
2606
2628
  const emptyMutableUnsafe = () => Object.create(Proto$7);
2607
2629
  //#endregion
2608
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/HttpServerResponse.js
2630
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/HttpServerResponse.js
2609
2631
  const TypeId$13 = "~effect/http/HttpServerResponse";
2610
2632
  /**
2611
2633
  * Returns `true` when the supplied value is an `HttpServerResponse`.
@@ -2815,7 +2837,7 @@ const makeResponse$1 = (options, ownedHeaders) => {
2815
2837
  return self;
2816
2838
  };
2817
2839
  //#endregion
2818
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/internal/compression.js
2840
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/internal/compression.js
2819
2841
  /**
2820
2842
  * @internal
2821
2843
  */
@@ -2844,7 +2866,7 @@ const wrapCompression = (impl) => ({
2844
2866
  }
2845
2867
  });
2846
2868
  //#endregion
2847
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/internal/mimeTypes.js
2869
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/internal/mimeTypes.js
2848
2870
  /**
2849
2871
  * Standard MIME type data copied from mime 4.1.0.
2850
2872
  *
@@ -3342,7 +3364,7 @@ const types$1 = {
3342
3364
  };
3343
3365
  Object.freeze(types$1);
3344
3366
  //#endregion
3345
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/Mime.js
3367
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/Mime.js
3346
3368
  /**
3347
3369
  * Standard MIME type lookup.
3348
3370
  *
@@ -3390,7 +3412,7 @@ const getType = (path) => {
3390
3412
  return fromUndefinedOr(getTables().extensionToType.get(extension));
3391
3413
  };
3392
3414
  //#endregion
3393
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/HttpPlatform.js
3415
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/HttpPlatform.js
3394
3416
  /**
3395
3417
  * Platform-specific support for serving files as HTTP server responses.
3396
3418
  *
@@ -3418,7 +3440,7 @@ var HttpPlatform = class extends (/*#__PURE__*/ Service()("effect/http/HttpPlatf
3418
3440
  * @category constructors
3419
3441
  * @since 4.0.0
3420
3442
  */
3421
- const make$25 = /*#__PURE__*/ fnUntraced(function* (impl) {
3443
+ const make$26 = /*#__PURE__*/ fnUntraced(function* (impl) {
3422
3444
  const fs = yield* FileSystem;
3423
3445
  const etagGen = yield* Generator;
3424
3446
  return HttpPlatform.of({
@@ -3471,7 +3493,7 @@ const fileResponseNumber = (value, field) => {
3471
3493
  }));
3472
3494
  };
3473
3495
  //#endregion
3474
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/HttpServerRespondable.js
3496
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/HttpServerRespondable.js
3475
3497
  /**
3476
3498
  * Converts supported values into HTTP server responses.
3477
3499
  *
@@ -3556,7 +3578,7 @@ const toResponseOrElseDefect = (u, orElse) => {
3556
3578
  return succeed$1(orElse);
3557
3579
  };
3558
3580
  //#endregion
3559
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/HttpServerError.js
3581
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/HttpServerError.js
3560
3582
  /**
3561
3583
  * Describes failures raised while handling HTTP server requests.
3562
3584
  *
@@ -3632,7 +3654,7 @@ var RequestParseError = class extends (/*#__PURE__*/ TaggedError("RequestParseEr
3632
3654
  return succeed$1(empty$3({ status: 400 }));
3633
3655
  }
3634
3656
  get methodAndUrl() {
3635
- return `${this.request.method} ${this.request.url}`;
3657
+ return formatMethodAndUrl(this.request);
3636
3658
  }
3637
3659
  get message() {
3638
3660
  return formatRequestMessage(this._tag, this.description, this.methodAndUrl);
@@ -3656,7 +3678,7 @@ var RouteNotFound = class extends (/*#__PURE__*/ TaggedError("RouteNotFound")) {
3656
3678
  }
3657
3679
  [ignore] = true;
3658
3680
  get methodAndUrl() {
3659
- return `${this.request.method} ${this.request.url}`;
3681
+ return formatMethodAndUrl(this.request);
3660
3682
  }
3661
3683
  get message() {
3662
3684
  return formatRequestMessage(this._tag, this.description, this.methodAndUrl);
@@ -3684,7 +3706,7 @@ var InternalError = class extends (/*#__PURE__*/ TaggedError("InternalError")) {
3684
3706
  return succeed$1(empty$3({ status: 500 }));
3685
3707
  }
3686
3708
  get methodAndUrl() {
3687
- return `${this.request.method} ${this.request.url}`;
3709
+ return formatMethodAndUrl(this.request);
3688
3710
  }
3689
3711
  get message() {
3690
3712
  return formatRequestMessage(this._tag, this.description, this.methodAndUrl);
@@ -3707,7 +3729,7 @@ var ResponseError = class extends (/*#__PURE__*/ TaggedError("ResponseError")) {
3707
3729
  return succeed$1(empty$3({ status: 500 }));
3708
3730
  }
3709
3731
  get methodAndUrl() {
3710
- return `${this.request.method} ${this.request.url}`;
3732
+ return formatMethodAndUrl(this.request);
3711
3733
  }
3712
3734
  get message() {
3713
3735
  const info = `${this._tag} (${this.response.status} ${this.methodAndUrl})`;
@@ -3742,6 +3764,7 @@ var ClientAbort = class extends (/*#__PURE__*/ Service()("effect/http/HttpServer
3742
3764
  parent: void 0
3743
3765
  }));
3744
3766
  };
3767
+ const formatMethodAndUrl = (request) => `${request.method} ${redactUrl(request.url)}`;
3745
3768
  const formatRequestMessage = (reason, description, info) => {
3746
3769
  const prefix = `${reason} (${info})`;
3747
3770
  return description ? `${prefix}: ${description}` : prefix;
@@ -3825,7 +3848,7 @@ const succeedInternalServerError = /*#__PURE__*/ succeed$1(internalServerError);
3825
3848
  const clientAbortError = /*#__PURE__*/ succeed$1(/*#__PURE__*/ empty$3({ status: 499 }));
3826
3849
  const serverAbortError = /*#__PURE__*/ succeed$1(/*#__PURE__*/ empty$3({ status: 503 }));
3827
3850
  //#endregion
3828
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/MultipartParser/internal/contentType.js
3851
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/MultipartParser/internal/contentType.js
3829
3852
  /**
3830
3853
  * RegExp to match *( ";" parameter ) in RFC 7231 sec 3.1.1.1
3831
3854
  *
@@ -3890,7 +3913,7 @@ function parse$8(header, withoutSlash = false) {
3890
3913
  return result;
3891
3914
  }
3892
3915
  //#endregion
3893
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/MultipartParser/internal/headers.js
3916
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/MultipartParser/internal/headers.js
3894
3917
  const constMaxPairs = 100;
3895
3918
  const constMaxSize = 16384;
3896
3919
  const State$4 = {
@@ -3905,7 +3928,7 @@ const constValueChars = /*#__PURE__*/ new Uint8Array(256);
3905
3928
  constValueChars[9] = 1;
3906
3929
  for (let i = 32; i <= 126; i++) constValueChars[i] = 1;
3907
3930
  for (let i = 128; i <= 255; i++) constValueChars[i] = 1;
3908
- function make$24() {
3931
+ function make$25() {
3909
3932
  const decoder = new TextDecoder();
3910
3933
  const state = {
3911
3934
  state: State$4.key,
@@ -4062,7 +4085,7 @@ function make$24() {
4062
4085
  };
4063
4086
  }
4064
4087
  //#endregion
4065
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/MultipartParser/internal/search.js
4088
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/MultipartParser/internal/search.js
4066
4089
  function makeState(needle_) {
4067
4090
  const needle = new TextEncoder().encode(needle_);
4068
4091
  const needleLength = needle.length;
@@ -4082,7 +4105,7 @@ function makeState(needle_) {
4082
4105
  matchIndex: 0
4083
4106
  };
4084
4107
  }
4085
- function make$23(needle, callback, seed, minimumChunkLength) {
4108
+ function make$24(needle, callback, seed, minimumChunkLength) {
4086
4109
  const state = makeState(needle);
4087
4110
  const minChunkLength = minimumChunkLength ?? state.needleLength;
4088
4111
  if (seed !== void 0) {
@@ -4162,7 +4185,7 @@ function make$23(needle, callback, seed, minimumChunkLength) {
4162
4185
  };
4163
4186
  }
4164
4187
  //#endregion
4165
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/MultipartParser/internal/multipart.js
4188
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/MultipartParser/internal/multipart.js
4166
4189
  const State$3 = {
4167
4190
  headers: 0,
4168
4191
  body: 1
@@ -4194,7 +4217,7 @@ function parseBoundary(headers) {
4194
4217
  }
4195
4218
  function noopOnChunk(_chunk) {}
4196
4219
  const toLimit = (input) => input === Infinity ? Infinity : Number(fromInputUnsafe(input));
4197
- function make$22({ headers, onFile: onPart, onField, onError, onDone, isFile = defaultIsFile$1, maxParts = Infinity, maxTotalSize: maxTotalSizeInput = Infinity, maxPartSize: maxPartSizeInput = Infinity, maxFieldSize: maxFieldSizeInput = 1048576 }) {
4220
+ function make$23({ headers, onFile: onPart, onField, onError, onDone, isFile = defaultIsFile$1, maxParts = Infinity, maxTotalSize: maxTotalSizeInput = Infinity, maxPartSize: maxPartSizeInput = Infinity, maxFieldSize: maxFieldSizeInput = 1048576 }) {
4198
4221
  const maxTotalSize = toLimit(maxTotalSizeInput);
4199
4222
  const maxPartSize = toLimit(maxPartSizeInput);
4200
4223
  const maxFieldSize = toLimit(maxFieldSizeInput);
@@ -4231,8 +4254,8 @@ function make$22({ headers, onFile: onPart, onField, onError, onDone, isFile = d
4231
4254
  if (state.state === State$3.body && state.isFile) state.onChunk(null);
4232
4255
  onError(error);
4233
4256
  }
4234
- const headerParser = make$24();
4235
- const split = make$23(`\r\n--${boundary}`, function(index, chunk) {
4257
+ const headerParser = make$25();
4258
+ const split = make$24(`\r\n--${boundary}`, function(index, chunk) {
4236
4259
  if (state.stopped) return;
4237
4260
  if (index === 0) {
4238
4261
  skipBody();
@@ -4356,7 +4379,7 @@ function decodeField$1(info, value) {
4356
4379
  return getDecoder(info.contentTypeParameters.charset ?? "utf-8").decode(value);
4357
4380
  }
4358
4381
  //#endregion
4359
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/MultipartParser.js
4382
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/MultipartParser.js
4360
4383
  /**
4361
4384
  * Creates a streaming multipart parser.
4362
4385
  *
@@ -4364,7 +4387,7 @@ function decodeField$1(info, value) {
4364
4387
  * @category constructors
4365
4388
  * @since 4.0.0
4366
4389
  */
4367
- const make$21 = make$22;
4390
+ const make$22 = make$23;
4368
4391
  /**
4369
4392
  * Determines whether a multipart part should be treated as a file.
4370
4393
  *
@@ -4382,7 +4405,7 @@ const defaultIsFile = defaultIsFile$1;
4382
4405
  */
4383
4406
  const decodeField = decodeField$1;
4384
4407
  //#endregion
4385
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/Multipart.js
4408
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/Multipart.js
4386
4409
  /**
4387
4410
  * Parses and persists HTTP `multipart/form-data` request bodies.
4388
4411
  *
@@ -4654,7 +4677,7 @@ const MaxFileSize = /*#__PURE__*/ Reference("effect/http/Multipart/MaxFileSize",
4654
4677
  */
4655
4678
  const FieldMimeTypes = /*#__PURE__*/ Reference("effect/http/Multipart/FieldMimeTypes", { defaultValue: /*#__PURE__*/ constant(["application/json"]) });
4656
4679
  //#endregion
4657
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/HttpServerRequest.js
4680
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/HttpServerRequest.js
4658
4681
  /**
4659
4682
  * Runtime type identifier for `HttpServerRequest` values.
4660
4683
  *
@@ -4733,26 +4756,13 @@ const toURL = (self) => {
4733
4756
  }
4734
4757
  };
4735
4758
  //#endregion
4736
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/internal/preResponseHandler.js
4759
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/internal/preResponseHandler.js
4737
4760
  /**
4738
4761
  * @internal
4739
4762
  */
4740
4763
  const requestPreResponseHandlers = /*#__PURE__*/ new WeakMap();
4741
4764
  //#endregion
4742
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/HttpMiddleware.js
4743
- /**
4744
- * Wraps HTTP server apps with request and response behavior.
4745
- *
4746
- * A middleware is a function from one HTTP server app effect to another. The app
4747
- * runs with the current `HttpServerRequest` in its context, so middleware can
4748
- * inspect or rewrite the request, provide request-scoped services, attach hooks
4749
- * before the response is sent, or observe the app exit. This module includes
4750
- * middleware for response logging, server tracing, forwarded proxy headers,
4751
- * parsed search parameters, and CORS response headers.
4752
- *
4753
- * @stability unstable
4754
- * @since 4.0.0
4755
- */
4765
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/HttpMiddleware.js
4756
4766
  /**
4757
4767
  * Defines an `HttpMiddleware` while preserving its precise type.
4758
4768
  *
@@ -4760,7 +4770,7 @@ const requestPreResponseHandlers = /*#__PURE__*/ new WeakMap();
4760
4770
  * @category constructors
4761
4771
  * @since 4.0.0
4762
4772
  */
4763
- const make$20 = (middleware) => middleware;
4773
+ const make$21 = (middleware) => middleware;
4764
4774
  const loggerDisabledRequests = /*#__PURE__*/ new WeakSet();
4765
4775
  const stripSearchAndHash = (url) => {
4766
4776
  const queryIndex = url.indexOf("?");
@@ -4821,7 +4831,7 @@ const TracerHeaderFilter = /*#__PURE__*/ Reference("effect/http/HttpMiddleware/T
4821
4831
  * @category logging
4822
4832
  * @since 4.0.0
4823
4833
  */
4824
- const logger$1 = /*#__PURE__*/ make$20((httpApp) => withFiber((fiber) => {
4834
+ const logger$1 = /*#__PURE__*/ make$21((httpApp) => withFiber((fiber) => {
4825
4835
  const request = getUnsafe(fiber.context, HttpServerRequest);
4826
4836
  const path = stripSearchAndHash(request.url);
4827
4837
  return withLogSpan(flatMap(exit(httpApp), (exit) => {
@@ -4866,7 +4876,7 @@ const responseSpanExit = (request, response) => {
4866
4876
  * @category tracing
4867
4877
  * @since 4.0.0
4868
4878
  */
4869
- const tracer = /*#__PURE__*/ make$20((httpApp) => withFiber((fiber) => {
4879
+ const tracer = /*#__PURE__*/ make$21((httpApp) => withFiber((fiber) => {
4870
4880
  const request = getUnsafe(fiber.context, HttpServerRequest);
4871
4881
  if (isTracerDisabledUnsafe(fiber, request)) return httpApp;
4872
4882
  const nameGenerator = fiber.getRef(SpanNameGenerator);
@@ -4898,13 +4908,7 @@ const tracer = /*#__PURE__*/ make$20((httpApp) => withFiber((fiber) => {
4898
4908
  if (span.sampled) {
4899
4909
  span.attribute("http.request.method", request.method);
4900
4910
  const url = toURL(request);
4901
- if (isSome(url)) {
4902
- if (!request.url.startsWith("/") && (url.value.username !== "" || url.value.password !== "")) {
4903
- url.value.username = "REDACTED";
4904
- url.value.password = "REDACTED";
4905
- }
4906
- addUrlAttributes(span, url.value);
4907
- }
4911
+ if (isSome(url)) addUrlAttributes(span, url.value, fiber.getRef(CurrentRedactedNames$1));
4908
4912
  if (request.headers["user-agent"] !== void 0) span.attribute("user_agent.original", request.headers["user-agent"]);
4909
4913
  addHeaderAttributes(span, "request", request.headers, headerFilter, redactedHeaderNames);
4910
4914
  if (isSome(request.remoteAddress)) span.attribute("client.address", request.remoteAddress.value);
@@ -4916,7 +4920,7 @@ const tracer = /*#__PURE__*/ make$20((httpApp) => withFiber((fiber) => {
4916
4920
  return httpApp;
4917
4921
  }));
4918
4922
  //#endregion
4919
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/HttpEffect.js
4923
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/HttpEffect.js
4920
4924
  /**
4921
4925
  * Runs an HTTP server effect, sends the produced response with the supplied handler, and converts failures into HTTP responses.
4922
4926
  * On handler failure, the request scope closes with the original cause.
@@ -5028,7 +5032,7 @@ const toHandled = (self, handleResponse, middleware) => {
5028
5032
  const handledSymbol = /*#__PURE__*/ Symbol.for("effect/http/HttpEffect/handled");
5029
5033
  const scopeEjected = /*#__PURE__*/ Symbol.for("effect/http/HttpEffect/scopeEjected");
5030
5034
  //#endregion
5031
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/HttpServer.js
5035
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/HttpServer.js
5032
5036
  /**
5033
5037
  * Service for serving Effect HTTP responses on a concrete HTTP server.
5034
5038
  *
@@ -5062,7 +5066,7 @@ var HttpServer = class extends (/*#__PURE__*/ Service()("effect/http/HttpServer"
5062
5066
  * @category constructors
5063
5067
  * @since 4.0.0
5064
5068
  */
5065
- const make$19 = (options) => options;
5069
+ const make$20 = (options) => options;
5066
5070
  /**
5067
5071
  * Creates a layer that starts serving an HTTP response effect with the current
5068
5072
  * `HttpServer`.
@@ -5117,7 +5121,7 @@ const logAddress = /*#__PURE__*/ addressFormattedWith((_) => log(`Listening on $
5117
5121
  */
5118
5122
  const withLogAddress = (layer) => effectDiscard(logAddress).pipe(provideMerge(layer));
5119
5123
  //#endregion
5120
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/HttpRouter.js
5124
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/HttpRouter.js
5121
5125
  /**
5122
5126
  * Builds server-side routers for Effect HTTP applications.
5123
5127
  *
@@ -5153,8 +5157,10 @@ const HttpRouter = /*#__PURE__*/ Service("effect/http/HttpRouter");
5153
5157
  * @category constructors
5154
5158
  * @since 4.0.0
5155
5159
  */
5156
- const make$18 = /*#__PURE__*/ gen(function* () {
5157
- const router = make$26(yield* RouterConfig);
5160
+ const make$19 = /*#__PURE__*/ gen(function* () {
5161
+ const config = yield* RouterConfig;
5162
+ const ignoreDuplicateSlashes = config.ignoreDuplicateSlashes ?? true;
5163
+ const router = make$27(config);
5158
5164
  const middleware = /* @__PURE__ */ new Set();
5159
5165
  const addAll = (routes) => contextWith((context) => {
5160
5166
  const middleware = getMiddleware(context);
@@ -5167,15 +5173,19 @@ const make$18 = /*#__PURE__*/ gen(function* () {
5167
5173
  ...routes[i],
5168
5174
  handler: applyMiddleware(routes[i].handler)
5169
5175
  });
5176
+ const handler = {
5177
+ route,
5178
+ prefixSegments: isSome(route.prefix) ? countSegments(route.prefix.value, ignoreDuplicateSlashes) : void 0
5179
+ };
5170
5180
  if (route.method === "*") {
5171
5181
  if (route.path.endsWith("/*")) {
5172
- router.all(route.path, route);
5173
- router.all(route.path.slice(0, -2), route);
5174
- } else router.all(route.path, route);
5182
+ router.all(route.path, handler);
5183
+ router.all(route.path.slice(0, -2), handler);
5184
+ } else router.all(route.path, handler);
5175
5185
  } else if (route.path.endsWith("/*")) {
5176
- router.on(route.method, route.path, route);
5177
- router.on(route.method, route.path.slice(0, -2), route);
5178
- } else router.on(route.method, route.path, route);
5186
+ router.on(route.method, route.path, handler);
5187
+ router.on(route.method, route.path.slice(0, -2), handler);
5188
+ } else router.on(route.method, route.path, handler);
5179
5189
  }
5180
5190
  return void_;
5181
5191
  });
@@ -5208,8 +5218,8 @@ const make$18 = /*#__PURE__*/ gen(function* () {
5208
5218
  let result = router.find(request.method, request.url);
5209
5219
  if (result === void 0 && request.method === "HEAD") result = router.find("GET", request.url);
5210
5220
  if (result === void 0) return fail$1(new HttpServerError({ reason: new RouteNotFound({ request }) }));
5211
- const route = result.handler;
5212
- if (isSome(route.prefix)) context = add$1(context, HttpServerRequest, sliceRequestUrl(request, route.prefix.value));
5221
+ const { route, prefixSegments } = result.handler;
5222
+ if (prefixSegments !== void 0) context = add$1(context, HttpServerRequest, sliceRequestUrl(request, prefixSegments, ignoreDuplicateSlashes));
5213
5223
  context = add$1(context, ParsedSearchParams, result.searchParams);
5214
5224
  context = add$1(context, RouteContext, {
5215
5225
  route,
@@ -5232,9 +5242,34 @@ const make$18 = /*#__PURE__*/ gen(function* () {
5232
5242
  }
5233
5243
  });
5234
5244
  });
5235
- function sliceRequestUrl(request, prefix) {
5236
- const prefexLen = prefix.length;
5237
- return request.modify({ url: request.url.length <= prefexLen ? "/" : request.url.slice(prefexLen) });
5245
+ function sliceRequestUrl(request, prefixSegments, ignoreDuplicateSlashes) {
5246
+ const url = request.url;
5247
+ let index = 0;
5248
+ for (let segments = prefixSegments; segments > 0; segments--) {
5249
+ if (ignoreDuplicateSlashes) while (url[index] === "/") index++;
5250
+ else if (url[index] === "/") index++;
5251
+ while (index < url.length && !"/?;#".includes(url[index])) index++;
5252
+ }
5253
+ return request.modify({ url: index < url.length ? url.slice(index) : "/" });
5254
+ }
5255
+ function countSegments(prefix, ignoreDuplicateSlashes) {
5256
+ let count = 0;
5257
+ let inParamName = false;
5258
+ for (let i = 0; i < prefix.length; i++) {
5259
+ const char = prefix[i];
5260
+ if (char === "/") {
5261
+ if (!ignoreDuplicateSlashes || prefix[i - 1] !== "/") count++;
5262
+ inParamName = false;
5263
+ } else if (char === ":") {
5264
+ if (prefix[i + 1] === ":") i++;
5265
+ else inParamName = true;
5266
+ } else if (char === "-" || char === ".") inParamName = false;
5267
+ else if (char === "(" && inParamName) {
5268
+ i = getClosingParenthensePosition(prefix, i);
5269
+ inParamName = false;
5270
+ }
5271
+ }
5272
+ return count;
5238
5273
  }
5239
5274
  /**
5240
5275
  * Context reference for low-level router configuration.
@@ -5332,7 +5367,7 @@ const use = (f) => effectDiscard(flatMap(HttpRouter, f));
5332
5367
  * @category layers
5333
5368
  * @since 4.0.0
5334
5369
  */
5335
- const layer$9 = /*#__PURE__*/ effect(HttpRouter)(make$18);
5370
+ const layer$10 = /*#__PURE__*/ effect(HttpRouter)(make$19);
5336
5371
  const RouteTypeId = "~effect/http/HttpRouter/Route";
5337
5372
  const makeRoute = (options) => ({
5338
5373
  ...options,
@@ -5524,17 +5559,17 @@ const getMiddleware = (context) => {
5524
5559
  const serve = (appLayer, options) => {
5525
5560
  let middleware = options?.middleware;
5526
5561
  if (options?.disableLogger !== true) middleware = middleware ? compose$1(middleware, logger$1) : logger$1;
5527
- const layerWithRouter = provideMerge(appLayer, options?.routerConfig ? provide(layer$9, succeed$2(RouterConfig)(options.routerConfig)) : layer$9);
5562
+ const layerWithRouter = provideMerge(appLayer, options?.routerConfig ? provide(layer$10, succeed$2(RouterConfig)(options.routerConfig)) : layer$10);
5528
5563
  return contextWith((context) => {
5529
5564
  const memoMap = CurrentMemoMap.forkOrCreate(context);
5530
5565
  return buildWithMemoMap(layerWithRouter, memoMap, get$5(context, Scope));
5531
5566
  }).pipe(map$1((context) => {
5532
5567
  const handler = get$5(context, HttpRouter).asHttpEffect();
5533
5568
  return merge$3(middleware ? serve$1(handler, middleware) : serve$1(handler), succeedContext(context));
5534
- }), unwrap$2, options?.disableListenLog ? identity : withLogAddress);
5569
+ }), unwrap$3, options?.disableListenLog ? identity : withLogAddress);
5535
5570
  };
5536
5571
  //#endregion
5537
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/FiberSet.js
5572
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/FiberSet.js
5538
5573
  /**
5539
5574
  * Manages many fibers together inside one scope.
5540
5575
  *
@@ -5629,7 +5664,7 @@ const makeUnsafe$1 = (backing, deferred) => {
5629
5664
  * @category constructors
5630
5665
  * @since 2.0.0
5631
5666
  */
5632
- const make$17 = () => acquireRelease(sync(() => makeUnsafe$1(/* @__PURE__ */ new Set(), makeUnsafe$4())), (set) => suspend(() => {
5667
+ const make$18 = () => acquireRelease(sync(() => makeUnsafe$1(/* @__PURE__ */ new Set(), makeUnsafe$4())), (set) => suspend(() => {
5633
5668
  const state = set.state;
5634
5669
  if (state._tag === "Closed") return void_;
5635
5670
  set.state = { _tag: "Closed" };
@@ -5834,7 +5869,7 @@ const awaitEmpty = (self) => whileLoop({
5834
5869
  step: constVoid
5835
5870
  });
5836
5871
  //#endregion
5837
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/rpc/RpcServer.js
5872
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/rpc/RpcServer.js
5838
5873
  /**
5839
5874
  * Creates an RPC server for an already-decoded message channel, running
5840
5875
  * handlers for a group and sending decoded server responses through
@@ -5860,7 +5895,7 @@ const makeNoSerialization = /*#__PURE__*/ fnUntraced(function* (group, options)
5860
5895
  const services = yield* context$1();
5861
5896
  const scope = get$5(services, Scope);
5862
5897
  const trackFiber = runIn(forkUnsafe$1(scope, "parallel"));
5863
- const concurrencySemaphore = concurrency === "unbounded" ? void 0 : yield* make$31(concurrency);
5898
+ const concurrencySemaphore = concurrency === "unbounded" ? void 0 : yield* make$32(concurrency);
5864
5899
  const clients = /* @__PURE__ */ new Map();
5865
5900
  let isShutdown = false;
5866
5901
  const shutdownLatch = makeUnsafe$5(false);
@@ -6140,11 +6175,11 @@ const applyMiddleware = (context, handler, options) => {
6140
6175
  * @category running
6141
6176
  * @since 4.0.0
6142
6177
  */
6143
- const make$16 = /*#__PURE__*/ fnUntraced(function* (group, options) {
6178
+ const make$17 = /*#__PURE__*/ fnUntraced(function* (group, options) {
6144
6179
  const { codecFor, disconnects, end, run, send, supportsAck, supportsSpanPropagation, supportsTransferables } = yield* Protocol;
6145
6180
  const { encodeDefectUnsafe, encodeUnknownRequestExit } = defectCodecs(codecFor);
6146
6181
  const services = yield* context$1();
6147
- const scope = yield* make$32();
6182
+ const scope = yield* make$33();
6148
6183
  const server = yield* makeNoSerialization(group, {
6149
6184
  ...options,
6150
6185
  disableClientAcks: !supportsAck,
@@ -6287,7 +6322,7 @@ const make$16 = /*#__PURE__*/ fnUntraced(function* (group, options) {
6287
6322
  * @category layers
6288
6323
  * @since 4.0.0
6289
6324
  */
6290
- const layer$8 = (group, options) => effectDiscard(forkScoped(make$16(group, options)));
6325
+ const layer$9 = (group, options) => effectDiscard(forkScoped(make$17(group, options)));
6291
6326
  /**
6292
6327
  * Creates a RPC server that registers a HTTP route with a `HttpRouter`.
6293
6328
  *
@@ -6300,7 +6335,7 @@ const layer$8 = (group, options) => effectDiscard(forkScoped(make$16(group, opti
6300
6335
  * @category layers
6301
6336
  * @since 4.0.0
6302
6337
  */
6303
- const layerHttp = (options) => layer$8(options.group, options).pipe(provide(options.protocol === "http" ? layerProtocolHttp(options) : layerProtocolWebsocket(options)));
6338
+ const layerHttp = (options) => layer$9(options.group, options).pipe(provide(options.protocol === "http" ? layerProtocolHttp(options) : layerProtocolWebsocket(options)));
6304
6339
  /**
6305
6340
  * Defines the service interface for an RPC server transport, responsible for receiving
6306
6341
  * encoded client messages, sending encoded responses, tracking clients, and
@@ -6381,7 +6416,7 @@ const makeProtocolWithHttpEffect = /*#__PURE__*/ fnUntraced(function* (options =
6381
6416
  const { encodeDefectUnsafe } = defectCodecs(serialization.codecFor);
6382
6417
  const includesFraming = serialization.includesFraming;
6383
6418
  const isBinary = !serialization.contentType.includes("json");
6384
- const disconnects = yield* make$33();
6419
+ const disconnects = yield* make$34();
6385
6420
  let writeRequest;
6386
6421
  let clientId = 0;
6387
6422
  const clients = /* @__PURE__ */ new Map();
@@ -6394,7 +6429,7 @@ const makeProtocolWithHttpEffect = /*#__PURE__*/ fnUntraced(function* (options =
6394
6429
  const requestHeaders = Object.entries(request.headers);
6395
6430
  const data = yield* orDie(isBinary ? map$1(request.arrayBuffer, (buf) => new Uint8Array(buf)) : request.text);
6396
6431
  const id = clientId++;
6397
- const queue = yield* make$33({ capacity: includesFraming && options.streamBufferSize !== "unbounded" ? options.streamBufferSize ?? 16 : void 0 });
6432
+ const queue = yield* make$34({ capacity: includesFraming && options.streamBufferSize !== "unbounded" ? options.streamBufferSize ?? 16 : void 0 });
6398
6433
  const parser = serialization.makeUnsafe();
6399
6434
  const requestIds = [];
6400
6435
  const offer$1 = (data) => typeof data === "string" ? offer(queue, encoder.encode(data)) : offer(queue, data);
@@ -6511,7 +6546,7 @@ const layerProtocolHttp = (options) => {
6511
6546
  const makeSocketProtocol = /*#__PURE__*/ gen(function* () {
6512
6547
  const serialization = yield* RpcSerialization;
6513
6548
  const { encodeDefectUnsafe } = defectCodecs(serialization.codecFor);
6514
- const disconnects = yield* make$33();
6549
+ const disconnects = yield* make$34();
6515
6550
  let clientId = 0;
6516
6551
  const clients = /* @__PURE__ */ new Map();
6517
6552
  const clientIds = /* @__PURE__ */ new Set();
@@ -6590,7 +6625,7 @@ const makeSocketProtocol = /*#__PURE__*/ gen(function* () {
6590
6625
  };
6591
6626
  });
6592
6627
  //#endregion
6593
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/FiberMap.js
6628
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/FiberMap.js
6594
6629
  /**
6595
6630
  * Manages fibers by key inside a scope.
6596
6631
  *
@@ -6690,7 +6725,7 @@ const makeUnsafe = (backing, deferred) => {
6690
6725
  * @category constructors
6691
6726
  * @since 2.0.0
6692
6727
  */
6693
- const make$15 = () => acquireRelease(sync(() => makeUnsafe(empty$6(), makeUnsafe$4())), (map) => suspend(() => {
6728
+ const make$16 = () => acquireRelease(sync(() => makeUnsafe(empty$6(), makeUnsafe$4())), (map) => suspend(() => {
6694
6729
  const state = map.state;
6695
6730
  if (state._tag === "Closed") return void_;
6696
6731
  map.state = { _tag: "Closed" };
@@ -10478,7 +10513,7 @@ require_subprotocol();
10478
10513
  require_websocket$1();
10479
10514
  var import_websocket_server = /* @__PURE__ */ __toESM(require_websocket_server(), 1);
10480
10515
  //#endregion
10481
- //#region ../../node_modules/.pnpm/@effect+platform-node@4.0.4_effect@4.0.4_redis@6.3.0_@opentelemetry+api@1.9.1_/node_modules/@effect/platform-node/dist/NodeHttpIncomingMessage.js
10516
+ //#region ../../node_modules/.pnpm/@effect+platform-node@4.0.5_effect@4.0.5_redis@6.3.0_@opentelemetry+api@1.9.1_/node_modules/@effect/platform-node/dist/NodeHttpIncomingMessage.js
10482
10517
  /**
10483
10518
  * Adapter base for exposing Node `http.IncomingMessage` values as Effect HTTP
10484
10519
  * incoming messages.
@@ -10576,7 +10611,7 @@ var NodeHttpIncomingMessage = class extends Class {
10576
10611
  }
10577
10612
  };
10578
10613
  //#endregion
10579
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/FetchHttpClient.js
10614
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/FetchHttpClient.js
10580
10615
  /**
10581
10616
  * Fetch-based implementation of the Effect HTTP client service.
10582
10617
  *
@@ -10636,18 +10671,21 @@ var RequestInit = class extends (/*#__PURE__*/ Service()("effect/http/FetchHttpC
10636
10671
  * **Gotchas**
10637
10672
  *
10638
10673
  * Fetch behavior comes from the runtime's implementation, so CORS, cookies,
10639
- * redirects, abort handling, and streaming support can vary by platform. Stream
10640
- * request bodies are sent as Web streams with `duplex: "half"`, and any
10641
- * `content-length` header is removed before calling `fetch`.
10674
+ * redirects, abort handling, and streaming support can vary by platform. Trace
10675
+ * propagation is on by default, and a browser preflight fails unless the
10676
+ * target allows `b3` and `traceparent`. Stream request bodies are sent as Web
10677
+ * streams with `duplex: "half"`, and any `content-length` header is removed
10678
+ * before calling `fetch`.
10642
10679
  *
10643
10680
  * @see {@link Fetch} for supplying the fetch implementation used by this layer
10644
10681
  * @see {@link RequestInit} for default `RequestInit` options applied before request-specific fields
10682
+ * @see {@link HttpClient.TracerPropagationEnabled} for leaving `b3` and `traceparent` off a browser request
10645
10683
  *
10646
10684
  * @stability unstable
10647
10685
  * @category layers
10648
10686
  * @since 4.0.0
10649
10687
  */
10650
- const layer$7 = /*#__PURE__*/ layerMergedContext(/*#__PURE__*/ succeed$1(/* @__PURE__ */ make$28((request, url, signal, fiber) => {
10688
+ const layer$8 = /*#__PURE__*/ layerMergedContext(/*#__PURE__*/ succeed$1(/* @__PURE__ */ make$29((request, url, signal, fiber) => {
10651
10689
  const fetch = fiber.getRef(Fetch);
10652
10690
  const options = getOrUndefined$1(fiber.context, RequestInit) ?? {};
10653
10691
  let headers = options.headers ? merge$2(fromInput$1(options.headers), request.headers) : request.headers;
@@ -10715,7 +10753,7 @@ const layerAgentOptions = /*#__PURE__*/ flow(makeAgent, /*#__PURE__*/ effect(Htt
10715
10753
  */
10716
10754
  const makeNodeHttp = /*#__PURE__*/ gen(function* () {
10717
10755
  const agent = yield* HttpAgent;
10718
- return make$28((request, url, signal) => {
10756
+ return make$29((request, url, signal) => {
10719
10757
  const nodeRequest = url.protocol === "https:" ? Https.request(url, {
10720
10758
  agent: agent.https,
10721
10759
  method: request.method,
@@ -10857,7 +10895,7 @@ var NodeHttpResponse = class extends NodeHttpIncomingMessage {
10857
10895
  */
10858
10896
  const layerNodeHttpNoAgent = /*#__PURE__*/ layerMergedContext(makeNodeHttp);
10859
10897
  //#endregion
10860
- //#region ../../node_modules/.pnpm/@effect+platform-node-shared@4.0.4_effect@4.0.4/node_modules/@effect/platform-node-shared/dist/NodeHttpCompression.js
10898
+ //#region ../../node_modules/.pnpm/@effect+platform-node-shared@4.0.5_effect@4.0.5/node_modules/@effect/platform-node-shared/dist/NodeHttpCompression.js
10861
10899
  /**
10862
10900
  * HTTP response compression backed by `node:zlib`, shared by the Node.js, Bun,
10863
10901
  * and Deno platforms.
@@ -10923,7 +10961,7 @@ const compress = (data, algorithm, options) => callback((resume) => {
10923
10961
  * @category constructors
10924
10962
  * @since 4.0.0
10925
10963
  */
10926
- const make$14 = (fallback) => ({
10964
+ const make$15 = (fallback) => ({
10927
10965
  algorithms: fallback.algorithms,
10928
10966
  compressResponse(response, algorithm, options) {
10929
10967
  const body = response.body;
@@ -10960,7 +10998,7 @@ const compressTransform = (algorithm, options) => {
10960
10998
  }
10961
10999
  };
10962
11000
  //#endregion
10963
- //#region ../../node_modules/.pnpm/@effect+platform-node@4.0.4_effect@4.0.4_redis@6.3.0_@opentelemetry+api@1.9.1_/node_modules/@effect/platform-node/dist/NodeHttpPlatform.js
11001
+ //#region ../../node_modules/.pnpm/@effect+platform-node@4.0.5_effect@4.0.5_redis@6.3.0_@opentelemetry+api@1.9.1_/node_modules/@effect/platform-node/dist/NodeHttpPlatform.js
10964
11002
  /**
10965
11003
  * Node.js implementation of the Effect HTTP platform service.
10966
11004
  *
@@ -11010,9 +11048,9 @@ const compressedBody = (response, body) => removeHeader(setBody(response, body),
11010
11048
  * @category constructors
11011
11049
  * @since 4.0.0
11012
11050
  */
11013
- const make$13 = /*#__PURE__*/ make$25({
11051
+ const make$14 = /*#__PURE__*/ make$26({
11014
11052
  platform: "node",
11015
- compression: /* @__PURE__ */ make$14({
11053
+ compression: /* @__PURE__ */ make$15({
11016
11054
  algorithms,
11017
11055
  compressResponse(response, algorithm, options) {
11018
11056
  const body = response.body;
@@ -11067,9 +11105,9 @@ const make$13 = /*#__PURE__*/ make$25({
11067
11105
  * @category layers
11068
11106
  * @since 4.0.0
11069
11107
  */
11070
- const layer$6 = /*#__PURE__*/ pipe(/*#__PURE__*/ effect(HttpPlatform)(make$13), /*#__PURE__*/ provide(layer$11), /*#__PURE__*/ provide(layer$10));
11108
+ const layer$7 = /*#__PURE__*/ pipe(/*#__PURE__*/ effect(HttpPlatform)(make$14), /*#__PURE__*/ provide(layer$12), /*#__PURE__*/ provide(layer$11));
11071
11109
  //#endregion
11072
- //#region ../../node_modules/.pnpm/@effect+platform-node@4.0.4_effect@4.0.4_redis@6.3.0_@opentelemetry+api@1.9.1_/node_modules/@effect/platform-node/dist/NodeMultipartParser.js
11110
+ //#region ../../node_modules/.pnpm/@effect+platform-node@4.0.5_effect@4.0.5_redis@6.3.0_@opentelemetry+api@1.9.1_/node_modules/@effect/platform-node/dist/NodeMultipartParser.js
11073
11111
  /**
11074
11112
  * A Node.js duplex stream that parses multipart input.
11075
11113
  *
@@ -11085,7 +11123,7 @@ var MultipartStream = class extends Duplex {
11085
11123
  super({ readableObjectMode: true });
11086
11124
  let currentError;
11087
11125
  let currentFile;
11088
- this._parser = make$21({
11126
+ this._parser = make$22({
11089
11127
  ...config,
11090
11128
  onField: (info, value) => {
11091
11129
  if (currentError !== void 0) return;
@@ -11148,7 +11186,7 @@ var MultipartStream = class extends Duplex {
11148
11186
  * @category constructors
11149
11187
  * @since 4.0.0
11150
11188
  */
11151
- const make$12 = (config) => new MultipartStream(config);
11189
+ const make$13 = (config) => new MultipartStream(config);
11152
11190
  /**
11153
11191
  * A readable stream containing a parsed multipart file.
11154
11192
  *
@@ -11172,7 +11210,7 @@ var FileStream = class extends Readable {
11172
11210
  }
11173
11211
  };
11174
11212
  //#endregion
11175
- //#region ../../node_modules/.pnpm/@effect+platform-node@4.0.4_effect@4.0.4_redis@6.3.0_@opentelemetry+api@1.9.1_/node_modules/@effect/platform-node/dist/NodeMultipart.js
11213
+ //#region ../../node_modules/.pnpm/@effect+platform-node@4.0.5_effect@4.0.5_redis@6.3.0_@opentelemetry+api@1.9.1_/node_modules/@effect/platform-node/dist/NodeMultipart.js
11176
11214
  /**
11177
11215
  * Node.js multipart parsing for HTTP `multipart/form-data` request bodies.
11178
11216
  *
@@ -11197,12 +11235,12 @@ var FileStream = class extends Readable {
11197
11235
  */
11198
11236
  const stream$1 = (source, headers) => makeConfig(headers).pipe(map$1((config) => fromReadable({
11199
11237
  evaluate() {
11200
- const parser = make$12(config);
11238
+ const parser = make$13(config);
11201
11239
  source.pipe(parser);
11202
11240
  return parser;
11203
11241
  },
11204
11242
  onError: (error) => convertError(error)
11205
- })), unwrap$1, map$2(convertPart));
11243
+ })), unwrap$2, map$2(convertPart));
11206
11244
  /**
11207
11245
  * Parses multipart data from a Node readable request body and persists file
11208
11246
  * parts using the current `FileSystem`, `Path`, and `Scope` services.
@@ -11286,7 +11324,7 @@ function convertError(cause) {
11286
11324
  }
11287
11325
  }
11288
11326
  //#endregion
11289
- //#region ../../node_modules/.pnpm/@effect+platform-node@4.0.4_effect@4.0.4_redis@6.3.0_@opentelemetry+api@1.9.1_/node_modules/@effect/platform-node/dist/NodeHttpServer.js
11327
+ //#region ../../node_modules/.pnpm/@effect+platform-node@4.0.5_effect@4.0.5_redis@6.3.0_@opentelemetry+api@1.9.1_/node_modules/@effect/platform-node/dist/NodeHttpServer.js
11290
11328
  /**
11291
11329
  * Node.js implementation of the Effect `HttpServer`.
11292
11330
  *
@@ -11311,8 +11349,8 @@ function convertError(cause) {
11311
11349
  * @category constructors
11312
11350
  * @since 4.0.0
11313
11351
  */
11314
- const make$11 = /*#__PURE__*/ fnUntraced(function* (evaluate, options) {
11315
- const scope$1 = yield* scope;
11352
+ const make$12 = /*#__PURE__*/ fnUntraced(function* (evaluate, options) {
11353
+ const scope$2 = yield* scope;
11316
11354
  const server = evaluate();
11317
11355
  const shutdown = yield* callback((resume) => {
11318
11356
  if (!server.listening) return resume(void_);
@@ -11325,7 +11363,7 @@ const make$11 = /*#__PURE__*/ fnUntraced(function* (evaluate, options) {
11325
11363
  duration: options.gracefulShutdownTimeout ?? seconds(20),
11326
11364
  orElse: () => void_
11327
11365
  });
11328
- yield* addFinalizer(scope$1, shutdown);
11366
+ yield* addFinalizer(scope$2, shutdown);
11329
11367
  yield* callback((resume) => {
11330
11368
  function onError(cause) {
11331
11369
  resume(fail$1(new ServeError({ cause })));
@@ -11343,19 +11381,19 @@ const make$11 = /*#__PURE__*/ fnUntraced(function* (evaluate, options) {
11343
11381
  noServer: true
11344
11382
  })), (wss) => callback((resume) => {
11345
11383
  wss.close(() => resume(void_));
11346
- })).pipe(provide$1(scope$1), cached);
11347
- return make$19({
11384
+ })).pipe(provide$1(scope$2), cached);
11385
+ return make$20({
11348
11386
  address: boundAddress,
11349
11387
  serve: fnUntraced(function* (httpApp, middleware) {
11350
11388
  const serveScope = yield* scope;
11351
- const scope$2 = forkUnsafe$1(serveScope, "parallel");
11389
+ const scope$1 = forkUnsafe$1(serveScope, "parallel");
11352
11390
  const handler = yield* makeHandler(httpApp, {
11353
11391
  middleware,
11354
- scope: scope$2
11392
+ scope: scope$1
11355
11393
  });
11356
11394
  const upgradeHandler = yield* makeUpgradeHandler(wss, httpApp, {
11357
11395
  middleware,
11358
- scope: scope$2
11396
+ scope: scope$1
11359
11397
  });
11360
11398
  yield* addFinalizerExit(serveScope, () => ensuring$1(preemptiveShutdown, sync(() => {
11361
11399
  server.off("request", handler);
@@ -11494,13 +11532,13 @@ var ServerRequestImpl = class ServerRequestImpl extends NodeHttpIncomingMessage
11494
11532
  }) }));
11495
11533
  }
11496
11534
  toString() {
11497
- return `ServerRequest(${this.method} ${this.url})`;
11535
+ return `ServerRequest(${this.method} ${redactUrl(this.url)})`;
11498
11536
  }
11499
11537
  toJSON() {
11500
11538
  return inspect$1(this, {
11501
11539
  _id: "HttpServerRequest",
11502
11540
  method: this.method,
11503
- url: this.originalUrl
11541
+ url: redactUrl(this.originalUrl)
11504
11542
  });
11505
11543
  }
11506
11544
  };
@@ -11512,7 +11550,7 @@ var ServerRequestImpl = class ServerRequestImpl extends NodeHttpIncomingMessage
11512
11550
  * @category layers
11513
11551
  * @since 4.0.0
11514
11552
  */
11515
- const layerHttpServices = /*#__PURE__*/ mergeAll(layer$6, layerWeak, layer$12);
11553
+ const layerHttpServices = /*#__PURE__*/ mergeAll(layer$7, layerWeak, layer$13);
11516
11554
  /**
11517
11555
  * Provides a Node `HttpServer` together with the Node HTTP platform, ETag,
11518
11556
  * and core Node platform services, reading the listen and shutdown options from
@@ -11522,7 +11560,7 @@ const layerHttpServices = /*#__PURE__*/ mergeAll(layer$6, layerWeak, layer$12);
11522
11560
  * @category layers
11523
11561
  * @since 4.0.0
11524
11562
  */
11525
- const layerConfig = (evaluate, options) => mergeAll(effect(HttpServer)(flatMap(unwrap$3(options), (options) => make$11(evaluate, options))), layerHttpServices);
11563
+ const layerConfig = (evaluate, options) => mergeAll(effect(HttpServer)(flatMap(unwrap$4(options), (options) => make$12(evaluate, options))), layerHttpServices);
11526
11564
  const closeCode = (exit) => isSuccess$1(exit) ? 1e3 : hasInterruptsOnly(exit.cause) ? 1001 : 1011;
11527
11565
  const upgradedResponse = /*#__PURE__*/ empty$3({ status: 101 });
11528
11566
  const handleResponse = (request, response) => {
@@ -11629,6 +11667,335 @@ const handleCause = (nodeResponse, originalResponse) => (originalCause) => flatM
11629
11667
  return failCause(headersSent ? combine(originalCause, die$1(originalResponse)) : cause);
11630
11668
  });
11631
11669
  //#endregion
11670
+ //#region ../../node_modules/.pnpm/@effect+platform-node-shared@4.0.5_effect@4.0.5/node_modules/@effect/platform-node-shared/dist/NodeDns.js
11671
+ /**
11672
+ * Node.js implementation of Effect's `Dns` service.
11673
+ *
11674
+ * Address lookups use the operating system resolver through `dns.lookup`,
11675
+ * including the hosts file. Record queries and reverse lookups share one
11676
+ * `dns.Resolver`. Interruption discards a query's result but cannot cancel
11677
+ * that query; closing the scope cancels all pending queries.
11678
+ *
11679
+ * Unrepresentable records, such as invalid `Host.DomainName` values, are
11680
+ * skipped. If every record is skipped, the query fails with `InvalidResponse`.
11681
+ * `make` decodes Node.js's Latin-1 TXT and CAA strings as UTF-8. TLSA queries
11682
+ * need Node.js 22.15 or 23.9 and later, and fail with `Unsupported` on runtimes
11683
+ * without `resolveTlsa`. Other runtimes reuse `lookup`, `resolver`, and the
11684
+ * conversion helpers to build their services.
11685
+ *
11686
+ * @stability experimental
11687
+ * @since 4.0.0
11688
+ */
11689
+ const reasons = {
11690
+ ENOTFOUND: "NotFound",
11691
+ ENODATA: "NotFound",
11692
+ ETIMEOUT: "Timeout",
11693
+ EAI_AGAIN: "Temporary",
11694
+ EAI_FAIL: "Refused",
11695
+ ESERVFAIL: "ServerFailure",
11696
+ EREFUSED: "Refused",
11697
+ ECONNREFUSED: "Refused",
11698
+ EBADNAME: "BadName",
11699
+ ENONAME: "BadName",
11700
+ EBADFAMILY: "BadName",
11701
+ EBADQUERY: "BadName",
11702
+ EFORMERR: "InvalidResponse",
11703
+ EBADRESP: "InvalidResponse",
11704
+ ENOTIMP: "Unsupported"
11705
+ };
11706
+ /**
11707
+ * Converts a failure of `node:dns` or of Bun's DNS functions to a
11708
+ * `Dns.DnsError`, choosing the reason from the error's `code`.
11709
+ *
11710
+ * **Details**
11711
+ *
11712
+ * Bun prefixes c-ares codes with `DNS_`, such as `DNS_ENOTFOUND`; the prefix is
11713
+ * ignored. Errors without a known code get the reason `Unknown`.
11714
+ *
11715
+ * @stability experimental
11716
+ * @category converting
11717
+ * @since 4.0.0
11718
+ */
11719
+ const dnsErrorFromCause = (cause, method, hostname, recordType) => {
11720
+ const code = typeof cause === "object" && cause !== null && "code" in cause ? String(cause.code).replace(/^DNS_/, "") : void 0;
11721
+ return new DnsError({
11722
+ reason: (code !== void 0 ? reasons[code] : void 0) ?? "Unknown",
11723
+ method,
11724
+ hostname,
11725
+ recordType,
11726
+ cause
11727
+ });
11728
+ };
11729
+ const absoluteName = (name) => {
11730
+ if (name.endsWith(".")) {
11731
+ let backslashes = 0;
11732
+ for (let i = name.length - 2; i >= 0 && name[i] === "\\"; i--) backslashes++;
11733
+ if (backslashes % 2 === 0) return name;
11734
+ }
11735
+ return `${name}.`;
11736
+ };
11737
+ /**
11738
+ * Converts a name returned by a resolver to a fully qualified
11739
+ * `Host.DomainName`, throwing when it is not a valid domain name.
11740
+ *
11741
+ * @stability experimental
11742
+ * @category converting
11743
+ * @since 4.0.0
11744
+ */
11745
+ const domainNameFromResolverUnsafe = (name) => domainNameFromStringUnsafe(absoluteName(name));
11746
+ const decoder = /*#__PURE__*/ new TextDecoder();
11747
+ const encoder = /*#__PURE__*/ new TextEncoder();
11748
+ const nameParts = /\\(\d{3})|\\(.)|[^\\]+|\\/gsu;
11749
+ /**
11750
+ * Converts a name returned by a resolver to fully qualified text, for names
11751
+ * that need not be host names, such as PTR targets and SOA mailboxes.
11752
+ *
11753
+ * **Details**
11754
+ *
11755
+ * Resolvers write bytes as `\DDD` escapes, c-ares in decimal (`radix` 10) and
11756
+ * `Deno.resolveDns` in octal (`radix` 8), and escape special characters with
11757
+ * a backslash, such as `\.` for a dot inside a label or `\(` for a
11758
+ * parenthesis. Decoding the bytes as UTF-8 and removing the escapes gives the
11759
+ * text of the name, keeping only the `\.` and `\\` escapes.
11760
+ *
11761
+ * @stability experimental
11762
+ * @category converting
11763
+ * @since 4.0.0
11764
+ */
11765
+ const nameTextFromResolver = (name, radix = 10) => {
11766
+ if (!name.includes("\\")) return absoluteName(name);
11767
+ const bytes = [];
11768
+ for (const [part, digits, escaped] of name.matchAll(nameParts)) if (digits !== void 0) {
11769
+ const byte = Number.parseInt(digits, radix);
11770
+ if (byte === 46 || byte === 92) bytes.push(92);
11771
+ bytes.push(byte);
11772
+ } else if (escaped !== void 0) {
11773
+ if (escaped === "." || escaped === "\\") bytes.push(92);
11774
+ bytes.push(...encoder.encode(escaped));
11775
+ } else bytes.push(...encoder.encode(part));
11776
+ return absoluteName(decoder.decode(Uint8Array.from(bytes)));
11777
+ };
11778
+ /**
11779
+ * Converts a number of seconds that a resolver reports as a signed 32-bit
11780
+ * integer, such as the SOA refresh, retry, and expire intervals, to a
11781
+ * `Duration`.
11782
+ *
11783
+ * @stability experimental
11784
+ * @category converting
11785
+ * @since 4.0.0
11786
+ */
11787
+ const secondsFromInt32 = (value) => seconds(value >>> 0);
11788
+ /**
11789
+ * Decodes a string that holds one byte per character as UTF-8.
11790
+ *
11791
+ * **Details**
11792
+ *
11793
+ * Node.js and `Deno.resolveDns` decode each byte of TXT and CAA character
11794
+ * strings as one Latin-1 character; decoding the bytes as UTF-8 matches other
11795
+ * runtimes. Strings with only ASCII characters are returned unchanged.
11796
+ *
11797
+ * @stability experimental
11798
+ * @category converting
11799
+ * @since 4.0.0
11800
+ */
11801
+ const utf8FromLatin1 = (value) => /[^\x00-\x7f]/.test(value) ? decoder.decode(Uint8Array.from(value, (character) => character.charCodeAt(0))) : value;
11802
+ /**
11803
+ * Converts the entries of a resolver's answer to a query for `name` to records
11804
+ * of a record type, skipping entries whose data cannot be represented, such as
11805
+ * names that are not valid `Host.DomainName` values.
11806
+ *
11807
+ * **Details**
11808
+ *
11809
+ * When the answer has entries but every one is skipped, the conversion fails
11810
+ * with an `InvalidResponse` error whose cause is the first entry's failure,
11811
+ * rather than returning no records, which would be reported as `NotFound`.
11812
+ *
11813
+ * @stability experimental
11814
+ * @category converting
11815
+ * @since 4.0.0
11816
+ */
11817
+ const recordsFromResolver = (name, type, entries, fields) => {
11818
+ const records = [];
11819
+ let skipped;
11820
+ for (const entry of entries) {
11821
+ const result = try_$1(() => makeRecordUnsafe(type, fields(entry)));
11822
+ if (isSuccess(result)) records.push(result.success);
11823
+ else skipped ??= result;
11824
+ }
11825
+ return records.length === 0 && skipped !== void 0 ? fail(new DnsError({
11826
+ reason: "InvalidResponse",
11827
+ method: "resolve",
11828
+ hostname: name,
11829
+ recordType: type,
11830
+ cause: skipped.failure
11831
+ })) : succeed(records);
11832
+ };
11833
+ const queries = {
11834
+ A: async (resolver, name) => recordsFromResolver(name, "A", await resolver.resolve4(name), (address) => ({ address: ipFromStringUnsafe(address) })),
11835
+ AAAA: async (resolver, name) => recordsFromResolver(name, "AAAA", await resolver.resolve6(name), (address) => ({ address: ipFromStringUnsafe(address) })),
11836
+ CAA: async (resolver, name) => recordsFromResolver(name, "CAA", await resolver.resolveCaa(name), (caa) => {
11837
+ const tag = Object.keys(caa).find((key) => key !== "critical" && key !== "type");
11838
+ if (tag === void 0) throw new Error("CAA record without a property tag");
11839
+ return {
11840
+ critical: (caa.critical & 128) !== 0,
11841
+ tag,
11842
+ value: String(caa[tag])
11843
+ };
11844
+ }),
11845
+ CNAME: async (resolver, name) => recordsFromResolver(name, "CNAME", await resolver.resolveCname(name), (target) => ({ target: domainNameFromResolverUnsafe(target) })),
11846
+ MX: async (resolver, name) => recordsFromResolver(name, "MX", await resolver.resolveMx(name), (mx) => ({
11847
+ exchange: domainNameFromResolverUnsafe(mx.exchange),
11848
+ priority: mx.priority
11849
+ })),
11850
+ NAPTR: async (resolver, name) => recordsFromResolver(name, "NAPTR", await resolver.resolveNaptr(name), (naptr) => ({
11851
+ order: naptr.order,
11852
+ preference: naptr.preference,
11853
+ flags: naptr.flags,
11854
+ service: naptr.service,
11855
+ regexp: naptr.regexp,
11856
+ replacement: domainNameFromResolverUnsafe(naptr.replacement)
11857
+ })),
11858
+ NS: async (resolver, name) => recordsFromResolver(name, "NS", await resolver.resolveNs(name), (host) => ({ host: domainNameFromResolverUnsafe(host) })),
11859
+ PTR: async (resolver, name) => recordsFromResolver(name, "PTR", await resolver.resolvePtr(name), (host) => ({ host: nameTextFromResolver(host) })),
11860
+ SOA: async (resolver, name) => recordsFromResolver(name, "SOA", [await resolver.resolveSoa(name)], (soa) => ({
11861
+ primary: domainNameFromResolverUnsafe(soa.nsname),
11862
+ admin: nameTextFromResolver(soa.hostmaster),
11863
+ serial: soa.serial,
11864
+ refresh: secondsFromInt32(soa.refresh),
11865
+ retry: secondsFromInt32(soa.retry),
11866
+ expire: secondsFromInt32(soa.expire),
11867
+ minimum: seconds(soa.minttl)
11868
+ })),
11869
+ SRV: async (resolver, name) => recordsFromResolver(name, "SRV", await resolver.resolveSrv(name), (srv) => ({
11870
+ target: domainNameFromResolverUnsafe(srv.name),
11871
+ port: srv.port,
11872
+ priority: srv.priority,
11873
+ weight: srv.weight
11874
+ })),
11875
+ TLSA: async (resolver, name) => typeof resolver.resolveTlsa === "function" ? recordsFromResolver(name, "TLSA", await resolver.resolveTlsa(name), (tlsa) => ({
11876
+ certUsage: tlsa.certUsage,
11877
+ selector: tlsa.selector,
11878
+ matchingType: tlsa.match,
11879
+ data: new Uint8Array(tlsa.data)
11880
+ })) : fail(new DnsError({
11881
+ reason: "Unsupported",
11882
+ method: "resolve",
11883
+ hostname: name,
11884
+ recordType: "TLSA"
11885
+ })),
11886
+ TXT: async (resolver, name) => recordsFromResolver(name, "TXT", await resolver.resolveTxt(name), (chunks) => ({ chunks }))
11887
+ };
11888
+ /**
11889
+ * Converts an IP family to the numeric family used by `dns.lookup`, with `0`
11890
+ * for addresses of either family.
11891
+ *
11892
+ * @stability experimental
11893
+ * @category converting
11894
+ * @since 4.0.0
11895
+ */
11896
+ const toFamily = (family) => family === "IPv4" ? 4 : family === "IPv6" ? 6 : 0;
11897
+ const stripZone = (address) => {
11898
+ const separator = address.indexOf("%");
11899
+ return separator === -1 ? address : address.slice(0, separator);
11900
+ };
11901
+ /**
11902
+ * Converts the entries returned by an address lookup, such as `dns.lookup`
11903
+ * with `all: true`, to IP addresses, keeping their order.
11904
+ *
11905
+ * **Details**
11906
+ *
11907
+ * IPv6 zones are dropped, and addresses that cannot be parsed are skipped.
11908
+ *
11909
+ * @stability experimental
11910
+ * @category converting
11911
+ * @since 4.0.0
11912
+ */
11913
+ const addressesFromLookup = (entries) => filterMap(entries, (entry) => try_$1(() => ipFromStringUnsafe(stripZone(entry.address))));
11914
+ /**
11915
+ * Looks up the addresses of a host name with `dns.lookup`, keeping the order
11916
+ * returned by the operating system resolver.
11917
+ *
11918
+ * @stability experimental
11919
+ * @category resolving
11920
+ * @since 4.0.0
11921
+ */
11922
+ const lookup$1 = (host, family) => tryPromise({
11923
+ try: () => NodeDns.promises.lookup(host, {
11924
+ all: true,
11925
+ family: toFamily(family),
11926
+ order: "verbatim",
11927
+ verbatim: true
11928
+ }),
11929
+ catch: (cause) => dnsErrorFromCause(cause, "lookup", host)
11930
+ }).pipe(map$1(addressesFromLookup));
11931
+ const resolverInt = (value) => value >= 1 ? Math.min(value, 2 ** 31 - 1) : 1;
11932
+ /**
11933
+ * Creates a function that queries DNS records with the runtime's `node:dns`
11934
+ * module.
11935
+ *
11936
+ * **Details**
11937
+ *
11938
+ * All queries share one `dns.Resolver`, which is cancelled when the scope
11939
+ * closes. Names in records are fully qualified, and TXT and CAA character
11940
+ * strings are returned as the runtime decodes them, without the UTF-8
11941
+ * correction that `make` applies for Node.js. Records are converted with
11942
+ * `recordsFromResolver`.
11943
+ *
11944
+ * @stability experimental
11945
+ * @category constructors
11946
+ * @since 4.0.0
11947
+ */
11948
+ const resolver = /*#__PURE__*/ fnUntraced(function* (options) {
11949
+ const resolverOptions = {
11950
+ ...options?.timeout !== void 0 && { timeout: resolverInt(Math.ceil(toMillis(options.timeout))) },
11951
+ ...options?.tries !== void 0 && { tries: resolverInt(Math.floor(options.tries)) }
11952
+ };
11953
+ const nameServers = [];
11954
+ for (const input of options?.nameServers ?? []) {
11955
+ const server = yield* fromResult(nameServerFromInput(input));
11956
+ if (isInetAddressV6(server) && server.scopeId !== 0) return yield* new NetAddressError({
11957
+ input,
11958
+ message: "IPv6 name servers with a scope ID are not supported"
11959
+ });
11960
+ nameServers.push(server);
11961
+ }
11962
+ const resolver = yield* acquireRelease(sync(() => {
11963
+ const resolver = new NodeDns.promises.Resolver(resolverOptions);
11964
+ if (nameServers.length > 0) resolver.setServers(nameServers.map(formatInet));
11965
+ return resolver;
11966
+ }), (resolver) => sync(() => resolver.cancel()));
11967
+ return (name, type) => tryPromise({
11968
+ try: () => queries[type](resolver, name),
11969
+ catch: (cause) => dnsErrorFromCause(cause, "resolve", name, type)
11970
+ }).pipe(flatMap(fromResult));
11971
+ });
11972
+ const utf8Strings = (record) => {
11973
+ switch (record._tag) {
11974
+ case "TXT": return makeRecordUnsafe("TXT", { chunks: map$3(record.chunks, utf8FromLatin1) });
11975
+ case "CAA": return makeRecordUnsafe("CAA", {
11976
+ critical: record.critical,
11977
+ tag: record.tag,
11978
+ value: utf8FromLatin1(record.value)
11979
+ });
11980
+ default: return record;
11981
+ }
11982
+ };
11983
+ /**
11984
+ * Layer that provides the Node.js `Dns` service using the system resolver
11985
+ * configuration.
11986
+ *
11987
+ * @stability experimental
11988
+ * @category layers
11989
+ * @since 4.0.0
11990
+ */
11991
+ const layer$6 = /*#__PURE__*/ effect(Dns, /*#__PURE__*/ orDie(/*#__PURE__*/ (/* @__PURE__ */ fnUntraced(function* (options) {
11992
+ const resolve = yield* resolver(options);
11993
+ return make$35({
11994
+ lookup: lookup$1,
11995
+ resolve: (name, type) => map$1(resolve(name, type), map$3(utf8Strings))
11996
+ });
11997
+ }))()));
11998
+ //#endregion
11632
11999
  //#region ../../node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/esm/version.js
11633
12000
  var VERSION$2;
11634
12001
  var init_version$1 = __esmMin((() => {
@@ -13141,7 +13508,7 @@ var init_esm$2 = __esmMin((() => {
13141
13508
  };
13142
13509
  }));
13143
13510
  //#endregion
13144
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/Random.js
13511
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Random.js
13145
13512
  /**
13146
13513
  * Represents a service for generating pseudo-random numbers.
13147
13514
  *
@@ -13265,7 +13632,7 @@ globalThis.Boolean;
13265
13632
  */
13266
13633
  const match = /*#__PURE__*/ dual(2, (value, options) => value ? options.onTrue() : options.onFalse());
13267
13634
  //#endregion
13268
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/ChannelSchema.js
13635
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/ChannelSchema.js
13269
13636
  /**
13270
13637
  * Creates a channel that decodes non-empty chunks from the schema's encoded
13271
13638
  * representation into schema values.
@@ -13382,7 +13749,7 @@ const result = (self) => {
13382
13749
  };
13383
13750
  };
13384
13751
  //#endregion
13385
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/Match.js
13752
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Match.js
13386
13753
  /**
13387
13754
  * Builds pattern matchers for TypeScript values.
13388
13755
  *
@@ -13533,7 +13900,7 @@ const when = when$1;
13533
13900
  */
13534
13901
  const orElse = orElse$1;
13535
13902
  //#endregion
13536
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/SubscriptionRef.js
13903
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/SubscriptionRef.js
13537
13904
  /**
13538
13905
  * Stores mutable state and publishes changes as a stream.
13539
13906
  *
@@ -13685,14 +14052,17 @@ const modifyEffect = /*#__PURE__*/ dual(2, (self, modify) => self.semaphore.with
13685
14052
  return b;
13686
14053
  }))));
13687
14054
  //#endregion
13688
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/Version.js
14055
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/internal/version.js
14056
+ init_esm$2();
14057
+ //#endregion
14058
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Version.js
13689
14059
  /**
13690
14060
  * The `effect` package version used in telemetry headers, resources, and scopes.
13691
14061
  *
13692
14062
  * @stability unstable
13693
14063
  * @since 4.0.2
13694
14064
  */
13695
- let currentVersion = "4.0.4";
14065
+ let currentVersion = "4.0.5";
13696
14066
  /**
13697
14067
  * Returns the current version of the `effect` package.
13698
14068
  *
@@ -13706,7 +14076,7 @@ let currentVersion = "4.0.4";
13706
14076
  */
13707
14077
  const getCurrentVersion = () => currentVersion;
13708
14078
  //#endregion
13709
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/http/HttpStaticServer.js
14079
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/HttpStaticServer.js
13710
14080
  /**
13711
14081
  * Serves static files for Effect HTTP applications.
13712
14082
  *
@@ -13960,12 +14330,8 @@ const resolveFilePath = (path, root, url) => {
13960
14330
  return;
13961
14331
  }
13962
14332
  if (decodedPath.includes("\0")) return;
13963
- const normalizedPath = path.normalize(decodedPath.startsWith("/") ? decodedPath.slice(1) : decodedPath);
13964
- if (normalizedPath === ".." || normalizedPath.startsWith(`..${path.sep}`)) return;
13965
- const resolvedPath = path.join(root, normalizedPath);
13966
- const rootPrefix = root.endsWith(path.sep) ? root : `${root}${path.sep}`;
13967
- if (resolvedPath !== root && !resolvedPath.startsWith(rootPrefix)) return;
13968
- return resolvedPath;
14333
+ const relativePath = decodedPath.replace(path.sep === "\\" ? /^[/\\]+/ : /^\/+/, "");
14334
+ return getOrUndefined(path.resolveWithin(root, relativePath));
13969
14335
  };
13970
14336
  const toRouteNotFoundError = (request) => new HttpServerError({ reason: new RouteNotFound({ request }) });
13971
14337
  const toInternalServerError = (request, cause) => new HttpServerError({ reason: new InternalError({
@@ -43685,16 +44051,16 @@ function clock(seconds$1) {
43685
44051
  function captionTranscript(input) {
43686
44052
  const cues = pipe(input.vtt, replace$1(/\r\n?/gu, "\n"), split("\n\n"), flatMap$1((block) => {
43687
44053
  const lines = split(block, "\n");
43688
- return pipe(findFirstIndex(lines, includes("-->")), map$3((index) => {
43689
- const times = map$4(pipe(getUnsafe$1(lines, index), split(" --> ")), (time) => reduce(pipe(time, split(" "), headNonEmpty, split(":"), map$4(parse$10), getSomes), 0, (total, part) => total * 60 + part));
43690
- return map$4(drop(lines, index + 1), (line) => ({
44054
+ return pipe(findFirstIndex(lines, includes("-->")), map$4((index) => {
44055
+ const times = map$3(pipe(getUnsafe$1(lines, index), split(" --> ")), (time) => reduce(pipe(time, split(" "), headNonEmpty, split(":"), map$3(parse$10), getSomes), 0, (total, part) => total * 60 + part));
44056
+ return map$3(drop(lines, index + 1), (line) => ({
43691
44057
  end: lastNonEmpty(times),
43692
44058
  start: headNonEmpty(times),
43693
44059
  text: pipe(line, replace$1(/<[^>]+>/gu, ""), replace$1(/&nbsp;/gu, " "), replace$1(/&lt;/gu, "<"), replace$1(/&gt;/gu, ">"), replace$1(/&amp;/gu, "&"), trim)
43694
44060
  }));
43695
44061
  }), getOrElse(empty$11));
43696
44062
  }), filter$4((cue) => isNonEmpty$1(cue.text)));
43697
- return join$1(map$4(filter$4(cues, (cue, index) => pipe(get$6(cues, index - 1), match$1({
44063
+ return join$1(map$3(filter$4(cues, (cue, index) => pipe(get$6(cues, index - 1), match$1({
43698
44064
  onNone: () => true,
43699
44065
  onSome: (previous) => input.authored || previous.text !== cue.text || previous.end < cue.start
43700
44066
  }))), (cue) => `[${clock(cue.start)}] ${cue.text}\n`), "");
@@ -43705,12 +44071,11 @@ function speechOnly(transcript) {
43705
44071
  return isReadonlyArrayNonEmpty(words) && dedupe(words).length * 3 > words.length;
43706
44072
  }));
43707
44073
  const words = flatMap$1(lines, (line) => wordsOf(spoken(line)));
43708
- const seconds = pipe(last$1(lines), flatMap$2(match$2(/^\[(\d+):(\d+)\]/u)), map$3((match) => [match[1] ?? "0", match[2] ?? "0"]), map$3((parts) => reduce(getSomes(map$4(parts, parse$10)), 0, (total, part) => total * 60 + part)), getOrElse(() => 0));
43709
- return words.length >= 8 && words.length * 60 >= 40 * max$1(seconds, 15) ? some$1(join$1(map$4(lines, (line) => `${line}\n`), "")) : none();
43710
- }
43711
- function spoken(line) {
43712
- return replace$1(/^\[[^\]]+\] /u, "")(line);
44074
+ const seconds = pipe(last$1(lines), flatMap$2(match$2(/^\[(\d+):(\d+)\]/u)), map$4((match) => [match[1] ?? "0", match[2] ?? "0"]), map$4((parts) => reduce(getSomes(map$3(parts, parse$10)), 0, (total, part) => total * 60 + part)), getOrElse(() => 0));
44075
+ if (words.length < 8 || words.length * 60 < 40 * max$1(seconds, 15)) return none();
44076
+ return some$1(join$1(map$3(lines, (line) => `${line}\n`), ""));
43713
44077
  }
44078
+ const spoken = replace$1(/^\[[^\]]+\] /u, "");
43714
44079
  function wordsOf(text) {
43715
44080
  return pipe(text, toLowerCase, split(/[^\p{L}\p{N}']+/u), filter$4(isNonEmpty$1));
43716
44081
  }
@@ -43744,7 +44109,7 @@ const Transcription = Struct({ chunks: ArraySchema(Struct({
43744
44109
  const maxWhisperSeconds = 7200;
43745
44110
  const blockedAnswer = /not a bot|requir(?:es|ing) login|login required|CONNECT tunnel failed|ProxyError|HTTP Error (?:403|429|5\d\d)|Requested format is not available|timed out/iu;
43746
44111
  const run = fnUntraced(function* (command, args) {
43747
- const handle = yield* make$34(command, args, {
44112
+ const handle = yield* make$36(command, args, {
43748
44113
  stderr: "pipe",
43749
44114
  stdout: "pipe"
43750
44115
  });
@@ -43760,7 +44125,7 @@ var Media = class Media extends Service()("@deslop/stash/services/media/service/
43760
44125
  const path = yield* Path;
43761
44126
  const spawner = yield* ChildProcessSpawner;
43762
44127
  const cache = path.join(yield* pipe(String$2("XDG_CACHE_HOME"), withDefault(path.join(yield* String$2("HOME"), ".cache"))), "deslop", "media");
43763
- const whisper = yield* make$31(1);
44128
+ const whisper = yield* make$32(1);
43764
44129
  const ytDlpArgs = [
43765
44130
  "--js-runtimes",
43766
44131
  "node",
@@ -43782,19 +44147,22 @@ var Media = class Media extends Service()("@deslop/stash/services/media/service/
43782
44147
  }));
43783
44148
  });
43784
44149
  return yield* repeat(attempt, {
43785
- times: isSome(exit) ? 2 : 0,
44150
+ times: match(isSome(exit), {
44151
+ onFalse: () => 0,
44152
+ onTrue: () => 2
44153
+ }),
43786
44154
  while: (result) => result.exitCode !== 0 && isSome(match$2(blockedAnswer)(result.stderr))
43787
44155
  });
43788
44156
  });
43789
44157
  function withProcesses(effect) {
43790
- return pipe(effect, provideService(ChildProcessSpawner, spawner), mapError((cause) => is$4(MediaError)(cause) ? cause : MediaError.make({
44158
+ return pipe(effect, provideService(ChildProcessSpawner, spawner), mapError((cause) => pipe(liftPredicate(cause, is$4(MediaError)), getOrElse(() => MediaError.make({
43791
44159
  cause,
43792
44160
  message: "Cannot extract the media"
43793
- })));
44161
+ })))));
43794
44162
  }
43795
44163
  const transcribe = fnUntraced(function* (link, media) {
43796
44164
  const work = yield* fs.makeTempDirectoryScoped({ prefix: "deslop-media-" });
43797
- const language = pipe(fromNullishOr(media.automatic_captions), flatMap$2((captions) => findFirst(keys(captions), endsWith("-orig"))), map$3(replace$1(/-orig$/u, "")), orElse$2(() => fromNullishOr(media.language)), getOrElse(() => "en"));
44165
+ const language = pipe(fromNullishOr(media.automatic_captions), flatMap$2((captions) => findFirst(keys(captions), endsWith("-orig"))), map$4(replace$1(/-orig$/u, "")), orElse$2(() => fromNullishOr(media.language)), getOrElse(() => "en"));
43798
44166
  yield* fetch([
43799
44167
  ...ytDlpArgs,
43800
44168
  "--skip-download",
@@ -43864,7 +44232,7 @@ var Media = class Media extends Service()("@deslop/stash/services/media/service/
43864
44232
  }
43865
44233
  if (samples.length < 16e3) return none();
43866
44234
  env.cacheDir = path.join(cache, "models");
43867
- const spoken = map$3(input.language, (language) => pipe(language, split("-"), headNonEmpty));
44235
+ const spoken = map$4(input.language, (language) => pipe(language, split("-"), headNonEmpty));
43868
44236
  const english = contains$2(spoken, "en");
43869
44237
  const model = match(english, {
43870
44238
  onFalse: () => "onnx-community/whisper-small",
@@ -43886,7 +44254,7 @@ var Media = class Media extends Service()("@deslop/stash/services/media/service/
43886
44254
  stride_length_s: 5
43887
44255
  })));
43888
44256
  })));
43889
- return speechOnly(join$1(map$4(transcription.chunks, (chunk) => `[${clock(chunk.timestamp[0])}] ${trim(chunk.text)}\n`), ""));
44257
+ return speechOnly(join$1(map$3(transcription.chunks, (chunk) => `[${clock(chunk.timestamp[0])}] ${trim(chunk.text)}\n`), ""));
43890
44258
  });
43891
44259
  const sample = fnUntraced(function* (video, work) {
43892
44260
  const probe = yield* run("ffprobe", [
@@ -43959,13 +44327,13 @@ var Media = class Media extends Service()("@deslop/stash/services/media/service/
43959
44327
  const details = filter$4([
43960
44328
  media.uploader ?? "",
43961
44329
  pipe(media.upload_date ?? "", replace$1(/^(\d{4})(\d{2})(\d{2})$/u, "$1-$2-$3")),
43962
- pipe(fromNullishOr(media.duration), map$3(clock), getOrElse(() => ""))
44330
+ pipe(fromNullishOr(media.duration), map$4(clock), getOrElse(() => ""))
43963
44331
  ], isNonEmpty$1);
43964
44332
  return {
43965
44333
  info: join$1(getSomes([
43966
44334
  some$1(`# ${media.title}\n\n${join$1(details, ", ")}\n${link}`),
43967
- pipe(fromNullishOr(media.description), filter$5(isNonEmpty$1), map$3((description) => `## Description\n\n${description}`)),
43968
- map$3(fromNullishOr(media.chapters), (chapters) => `## Chapters\n\n${join$1(map$4(chapters, (chapter) => `- [${clock(chapter.start_time)}] ${chapter.title}`), "\n")}`)
44335
+ pipe(fromNullishOr(media.description), filter$5(isNonEmpty$1), map$4((description) => `## Description\n\n${description}`)),
44336
+ map$4(fromNullishOr(media.chapters), (chapters) => `## Chapters\n\n${join$1(map$3(chapters, (chapter) => `- [${clock(chapter.start_time)}] ${chapter.title}`), "\n")}`)
43969
44337
  ]), "\n\n"),
43970
44338
  transcript: withProcesses(scoped(transcribe(link, media)))
43971
44339
  };
@@ -80767,7 +81135,7 @@ var require_dump = /* @__PURE__ */ __commonJSMin(((exports, module) => {
80767
81135
  //#region ../../node_modules/.pnpm/undici@7.30.0/node_modules/undici/lib/interceptor/dns.js
80768
81136
  var require_dns = /* @__PURE__ */ __commonJSMin(((exports, module) => {
80769
81137
  const { isIP } = __require$1("node:net");
80770
- const { lookup: lookup$1 } = __require$1("node:dns");
81138
+ const { lookup } = __require$1("node:dns");
80771
81139
  const DecoratorHandler = require_decorator_handler();
80772
81140
  const { InvalidArgumentError, InformationalError } = require_errors();
80773
81141
  const maxInt = Math.pow(2, 31) - 1;
@@ -80904,7 +81272,7 @@ var require_dns = /* @__PURE__ */ __commonJSMin(((exports, module) => {
80904
81272
  }
80905
81273
  }
80906
81274
  #defaultLookup(origin, opts, cb) {
80907
- lookup$1(origin.hostname, {
81275
+ lookup(origin.hostname, {
80908
81276
  all: true,
80909
81277
  family: this.dualStack === false ? this.affinity : 0,
80910
81278
  order: "ipv4first"
@@ -90503,10 +90871,9 @@ function canonicalUrl(link) {
90503
90871
  return url.href;
90504
90872
  }
90505
90873
  function captureUrl(text) {
90506
- return pipe(match$2(urlPattern)(text), flatMap$2(head), map$3(withoutTrailingPunctuation), flatMap$2(liftThrowable(canonicalUrl)), getOrNull);
90874
+ return pipe(match$2(urlPattern)(text), flatMap$2(head), map$4(withoutTrailingPunctuation), flatMap$2(liftThrowable(canonicalUrl)), getOrUndefined);
90507
90875
  }
90508
90876
  function sourceFor(url) {
90509
- if (url === null) return "Note";
90510
90877
  const host = new URL(url).hostname;
90511
90878
  if (contains$1(xHosts, host) || host === "t.co") return "X";
90512
90879
  if (host === "tiktok.com" || endsWith(".tiktok.com")(host)) return "TikTok";
@@ -90527,25 +90894,25 @@ function plainText(text) {
90527
90894
  return pipe(text, replace$1(/\s+/gu, " "), trim);
90528
90895
  }
90529
90896
  function normalizeTags(tags) {
90530
- return pipe(tags, map$4((tag) => pipe(tag, toLowerCase, plainText, replace$1(/^#+/u, ""), replace$1(/ /gu, "-"))), filter$4(isNonEmpty$1), dedupe);
90897
+ return pipe(tags, map$3((tag) => pipe(tag, toLowerCase, plainText, replace$1(/^#+/u, ""), replace$1(/ /gu, "-"))), filter$4(isNonEmpty$1), dedupe);
90531
90898
  }
90532
90899
  function tagCounts(notes) {
90533
- return pipe(flatMap$1(notes, (note) => note.tags), groupBy((tag) => tag), toEntries, map$4((entry) => ({
90900
+ return pipe(flatMap$1(notes, (note) => note.tags), groupBy((tag) => tag), toEntries, map$3((entry) => ({
90534
90901
  count: entry[1].length,
90535
90902
  tag: entry[0]
90536
90903
  })), sort(combine$1(mapInput(flip(Number$1), (entry) => entry.count), mapInput(String$3, (entry) => entry.tag))));
90537
90904
  }
90538
90905
  function diff(previous, next) {
90539
- const before = fromIterable$2(map$4(previous, (note) => [note.id, note]));
90540
- const ids = fromIterable$3(map$4(next, (note) => note.id));
90906
+ const before = fromIterable$2(map$3(previous, (note) => [note.id, note]));
90907
+ const ids = fromIterable$3(map$3(next, (note) => note.id));
90541
90908
  return {
90542
- removed: filter$4(map$4(previous, (note) => note.id), (id) => !has$4(ids, id)),
90909
+ removed: filter$4(map$3(previous, (note) => note.id), (id) => !has$4(ids, id)),
90543
90910
  upserted: filter$4(next, (note) => !exists(get$7(before, note.id), (old) => old === note))
90544
90911
  };
90545
90912
  }
90546
90913
  function findNotes(notes, query) {
90547
90914
  const words = pipe(query, toLowerCase, split(/\s+/u), filter$4(isNonEmpty$1));
90548
- const tags = pipe(words, filter$4(startsWith("#")), map$4(slice$2(1)), filter$4(isNonEmpty$1));
90915
+ const tags = pipe(words, filter$4(startsWith("#")), map$3(slice$2(1)), filter$4(isNonEmpty$1));
90549
90916
  const terms = filter$4(words, (word) => !startsWith("#")(word));
90550
90917
  if (isReadonlyArrayEmpty(words)) return notes;
90551
90918
  return filter$4(notes, (note) => {
@@ -90678,27 +91045,19 @@ function readBytes(response) {
90678
91045
  }
90679
91046
  const load = fnUntraced(function* (url, read) {
90680
91047
  if (url.protocol !== "https:" && url.protocol !== "http:" || isNonEmpty$1(url.username) || isSuccess(ipFromString(url.hostname)) || !includes(".")(url.hostname)) return yield* NotesError.make({ message: "Only public web links can be read." });
90681
- const resolved = yield* tryPromise({
90682
- catch: (cause) => NotesError.make({
90683
- cause,
90684
- message: "The link host could not be found."
90685
- }),
90686
- try: () => lookup(url.hostname, {
90687
- all: true,
90688
- family: 4
90689
- })
90690
- });
90691
- const addresses = map$4(resolved, (entry) => entry.address);
90692
- const allPublic = every(addresses, (address) => pipe(ipv4FromString(address), map$5(isPublic), getOrElse$1(() => false)));
90693
- if (!isReadonlyArrayNonEmpty(addresses) || !allPublic) return yield* NotesError.make({ message: "The link points to a private network." });
90694
- const address = headNonEmpty(addresses);
91048
+ const addresses = yield* pipe((yield* Dns).lookup(url.hostname, { family: "IPv4" }), mapError((cause) => NotesError.make({
91049
+ cause,
91050
+ message: "The link host could not be found."
91051
+ })));
91052
+ if (!every(addresses, isPublic)) return yield* NotesError.make({ message: "The link points to a private network." });
91053
+ const address = formatIp(headNonEmpty(addresses));
90695
91054
  const session = `${yield* nextIntBetween(1e7, 99999999)}`;
90696
- const proxy = map$3(yield* Exit, (exit) => sticky(exit, session));
91055
+ const proxy = map$4(yield* Exit, (exit) => sticky(exit, session));
90697
91056
  return yield* pipe(get$2(url, { headers: {
90698
91057
  accept: "text/html,application/json,image/*",
90699
91058
  "accept-language": "en-US,en;q=0.9",
90700
91059
  "user-agent": "Mozilla/5.0 (compatible; DeslopNotes/1.0)"
90701
- } }), flatMap((response) => map$1(response.status === 200 ? asSome(read(response)) : succeed$1(none()), (body) => ({
91060
+ } }), flatMap((response) => map$1(when$2(read(response), succeed$1(response.status === 200)), (body) => ({
90702
91061
  body,
90703
91062
  location: response.headers["location"],
90704
91063
  status: response.status,
@@ -90713,10 +91072,10 @@ const load = fnUntraced(function* (url, read) {
90713
91072
  HTTPS_PROXY: exit,
90714
91073
  NODE_ENV: "production"
90715
91074
  } })
90716
- }))))), provideService(TracerDisabledWhen$1, () => true), mapError((cause) => is$4(NotesError)(cause) ? cause : NotesError.make({
91075
+ }))))), provideService(TracerDisabledWhen$1, () => true), mapError((cause) => pipe(liftPredicate(cause, is$4(NotesError)), getOrElse(() => NotesError.make({
90717
91076
  cause,
90718
91077
  message: unreachable
90719
- })));
91078
+ })))));
90720
91079
  });
90721
91080
  const blockedStatuses = [
90722
91081
  403,
@@ -90729,7 +91088,10 @@ const unreachable = "The link could not be loaded.";
90729
91088
  const follow = fnUntraced(function* (url, read, hops) {
90730
91089
  const proxied = isSome(yield* Exit);
90731
91090
  const answer = yield* pipe(load(url, read), filterOrFail((found) => !proxied || !contains$1(blockedStatuses, found.status), () => NotesError.make({ message: unreachable })), timeLimit("15 seconds", unreachable), retry({
90732
- times: proxied ? 2 : 0,
91091
+ times: match(proxied, {
91092
+ onFalse: () => 0,
91093
+ onTrue: () => 2
91094
+ }),
90733
91095
  while: (error) => error.message === unreachable
90734
91096
  }));
90735
91097
  if (answer.status >= 300 && answer.status < 400 && answer.location !== void 0) {
@@ -90798,7 +91160,7 @@ function said(post) {
90798
91160
  }
90799
91161
  function section(title, posts) {
90800
91162
  if (isReadonlyArrayEmpty(posts)) return "";
90801
- return `## ${title}\n\n${join$1(map$4(posts, said), "\n\n")}`;
91163
+ return `## ${title}\n\n${join$1(map$3(posts, said), "\n\n")}`;
90802
91164
  }
90803
91165
  const xThread = fnUntraced(function* (url) {
90804
91166
  const id = yield* pipe(match$2(/\/status\/(\d+)/u)(url.pathname), flatMap$2((match) => get$6(match, 1)), fromOption, mapError(() => NotesError.make({ message: "The link names no post." })));
@@ -90810,11 +91172,11 @@ const xThread = fnUntraced(function* (url) {
90810
91172
  const linked = yield* forEach(pipe(status.raw_text?.facets ?? [], filterMap((facet) => fromOption$1(pipe(fromNullishOr(facet.replacement), flatMap$2(match$2(/(?:x|twitter)\.com\/[^/]+\/status\/(\d+)/u)), flatMap$2((match) => get$6(match, 1))), () => void 0)), filter$4((linkedId) => linkedId !== status.id && !exists(quote, (post) => post.id === linkedId)), dedupe, take$1(5)), (linkedId) => option$1(map$1(decode$1(FxStatus, new URL(`https://api.fxtwitter.com/2/status/${linkedId}`)), (found) => found.status)));
90811
91173
  return Extraction.make({
90812
91174
  author: status.author.name,
90813
- image: map$3(head(media), (item) => item.thumbnail_url ?? item.url),
91175
+ image: map$4(head(media), (item) => item.thumbnail_url ?? item.url),
90814
91176
  text: pipe([
90815
91177
  section("Earlier in the conversation", sort(filter$4(conversation.thread ?? [], (post) => post.id !== status.id), byTime)),
90816
91178
  plainText(status.text),
90817
- ...pipe(filter$4(replies, (post) => post.author.id === status.author.id), sort(byTime), map$4((post) => plainText(post.text))),
91179
+ ...pipe(filter$4(replies, (post) => post.author.id === status.author.id), sort(byTime), map$3((post) => plainText(post.text))),
90818
91180
  match$1(quote, {
90819
91181
  onNone: () => "",
90820
91182
  onSome: (post) => `Quoting ${said(post)}`
@@ -90845,7 +91207,7 @@ const tikTokPhotos = fnUntraced(function* (url) {
90845
91207
  author: item.author.nickname,
90846
91208
  image: head(images),
90847
91209
  slides: drop(images, 1),
90848
- text: pipe([item.imagePost.title ?? "", item.desc], map$4(plainText), filter$4(isNonEmpty$1), join$1("\n")),
91210
+ text: pipe([item.imagePost.title ?? "", item.desc], map$3(plainText), filter$4(isNonEmpty$1), join$1("\n")),
90849
91211
  title: `${item.author.nickname} on TikTok`,
90850
91212
  url: canonical(url)
90851
91213
  });
@@ -90859,7 +91221,7 @@ const issue = fnUntraced(function* (url, repository, number) {
90859
91221
  text: pipe([
90860
91222
  `# ${found.title} (${found.state})`,
90861
91223
  `**${found.user.login}**: ${found.body ?? ""}`,
90862
- ...map$4(comments, (comment) => `**${comment.user.login}**: ${comment.body ?? ""}`)
91224
+ ...map$3(comments, (comment) => `**${comment.user.login}**: ${comment.body ?? ""}`)
90863
91225
  ], join$1("\n\n")),
90864
91226
  title: found.title,
90865
91227
  url: canonical(url)
@@ -90918,9 +91280,9 @@ const blockTags = [
90918
91280
  ];
90919
91281
  function markdown($, node, base) {
90920
91282
  if (node.nodeType === 3) return replace$1(/\s+/gu, " ")(node.data);
90921
- if (!("tagName" in node)) return "";
90922
- const inner = pipe($(node).contents().toArray(), map$4((child) => markdown($, child, base)), join$1(""));
90923
- return pipe(get$8(headings, node.tagName), map$3((level) => `\n\n${repeat$1(level)("#")} ${trim(inner)}\n\n`), getOrElse(() => element($, {
91283
+ if (!hasProperty(node, "tagName")) return "";
91284
+ const inner = pipe($(node).contents().toArray(), map$3((child) => markdown($, child, base)), join$1(""));
91285
+ return pipe(get$8(headings, node.tagName), map$4((level) => `\n\n${repeat$1(level)("#")} ${trim(inner)}\n\n`), getOrElse(() => element($, {
90924
91286
  base,
90925
91287
  inner,
90926
91288
  node,
@@ -90931,7 +91293,10 @@ function element($, input) {
90931
91293
  const node = input.node;
90932
91294
  const text = trim(input.inner);
90933
91295
  return pipe(value(input.tag), when("li", () => {
90934
- const marker = $(node).parent().is("ol") ? `${$(node).index() + 1}.` : "-";
91296
+ const marker = match($(node).parent().is("ol"), {
91297
+ onFalse: () => "-",
91298
+ onTrue: () => `${$(node).index() + 1}.`
91299
+ });
90935
91300
  return `\n${repeat$1($(node).parents("ul, ol").length - 1)(" ")}${marker} ${text}`;
90936
91301
  }), when("pre", () => `\n\n\`\`\`\n${$(node).text()}\n\`\`\`\n\n`), when("code", () => `\`${text}\``), when("br", () => "\n"), when("tr", () => `\n${text}`), when((name) => name === "td" || name === "th", () => `${text} | `), when("a", () => pipe(fromNullishOr($(node).attr("href")), flatMap$2(liftThrowable((href) => new URL(href, input.base))), filter$5((link) => (link.protocol === "https:" || link.protocol === "http:") && isNonEmpty$1(text)), match$1({
90937
91302
  onNone: () => input.inner,
@@ -90946,8 +91311,11 @@ function pageText(html, url) {
90946
91311
  "article",
90947
91312
  "main",
90948
91313
  "[role=\"main\"]"
90949
- ], map$4((selector) => $(selector).first()), findFirst((found) => length(plainText(found.text())) >= 200), getOrElse(() => $("body")));
90950
- const body = pipe(join$1(map$4(root.toArray(), (node) => markdown($, node, url)), ""), split("```"), map$4((part, index) => index % 2 === 1 ? part : pipe(part, split("\n"), map$4((line) => replace$1(/^ (?=\S)/u, "")(trimEnd(line))), join$1("\n"), replace$1(/\n{3,}/gu, "\n\n"))), join$1("```"), trim);
91314
+ ], map$3((selector) => $(selector).first()), findFirst((found) => length(plainText(found.text())) >= 200), getOrElse(() => $("body")));
91315
+ const body = pipe(join$1(map$3(root.toArray(), (node) => markdown($, node, url)), ""), split("```"), map$3((part, index) => match(index % 2 === 1, {
91316
+ onFalse: () => pipe(part, split("\n"), map$3((line) => replace$1(/^ (?=\S)/u, "")(trimEnd(line))), join$1("\n"), replace$1(/\n{3,}/gu, "\n\n")),
91317
+ onTrue: () => part
91318
+ })), join$1("```"), trim);
90951
91319
  return Extraction.make({
90952
91320
  author: plainText($("meta[property=\"og:site_name\"]").attr("content") ?? url.hostname),
90953
91321
  image: pipe(fromNullishOr($("meta[property=\"og:image\"]").attr("content") ?? $("meta[name=\"twitter:image\"]").attr("content")), flatMap$2(liftThrowable((image) => new URL(image, url).href))),
@@ -90983,13 +91351,16 @@ const readPage = fnUntraced(function* (url) {
90983
91351
  });
90984
91352
  var Sources = class Sources extends Service()("@deslop/stash/services/notes/lib/extraction/Sources") {
90985
91353
  static layer = effect(this, gen(function* () {
90986
- const through = provideService(Exit, yield* sourceProxy);
91354
+ const through = flow(provideService(Exit, yield* sourceProxy), provideService(Dns, yield* Dns));
90987
91355
  return Sources.of({
90988
91356
  extract: fn$1("Sources.extract")(function* (link) {
90989
91357
  const url = yield* resolve(new URL(link), 0);
90990
91358
  const source = sourceFor(url.href);
90991
91359
  if (source === "TikTok" && includes("/photo/")(url.pathname)) return yield* retry(tikTokPhotos(url), {
90992
- times: isSome(yield* Exit) ? 2 : 0,
91360
+ times: match(isSome(yield* Exit), {
91361
+ onFalse: () => 0,
91362
+ onTrue: () => 2
91363
+ }),
90993
91364
  while: (error) => error.message === "The TikTok photo post is unreadable."
90994
91365
  });
90995
91366
  if (source === "TikTok") return yield* fromOEmbed("https://www.tiktok.com/oembed?url=", url, (embed) => `${embed.author_name ?? "A video"} on TikTok`);
@@ -91007,7 +91378,7 @@ var Sources = class Sources extends Service()("@deslop/stash/services/notes/lib/
91007
91378
  try: () => new URL(link)
91008
91379
  });
91009
91380
  const image = yield* follow(url, readBytes, 0);
91010
- const type = yield* pipe(image.type, split(";"), head, map$3(trim), filter$5(is$4(ImageType)), fromOption, mapError(() => NotesError.make({ message: "The preview is not a JPEG, PNG, WebP or GIF image." })));
91381
+ const type = yield* pipe(image.type, split(";"), head, map$4(trim), filter$5(is$4(ImageType)), fromOption, mapError(() => NotesError.make({ message: "The preview is not a JPEG, PNG, WebP or GIF image." })));
91011
91382
  return {
91012
91383
  bytes: image.body,
91013
91384
  type
@@ -91020,7 +91391,7 @@ var Sources = class Sources extends Service()("@deslop/stash/services/notes/lib/
91020
91391
  }));
91021
91392
  };
91022
91393
  //#endregion
91023
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/encoding/Sse.js
91394
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/encoding/Sse.js
91024
91395
  const SseErrorTypeId = "~effect/encoding/Sse/SseError";
91025
91396
  /**
91026
91397
  * Error reason raised when pending Server-Sent Events state exceeds the
@@ -91130,7 +91501,7 @@ const decodeDataSchema = (schema, options) => {
91130
91501
  ...EventEncoded.fields,
91131
91502
  data: fromJsonString(schema)
91132
91503
  });
91133
- return pipeTo(decode(options), map$6(decode$2(eventSchema)(), map$4((event) => ({
91504
+ return pipeTo(decode(options), map$5(decode$2(eventSchema)(), map$3((event) => ({
91134
91505
  ...event,
91135
91506
  id: event.id
91136
91507
  }))));
@@ -91342,7 +91713,7 @@ var Retry = class Retry extends (/*#__PURE__*/ TaggedClass("Retry")) {
91342
91713
  }
91343
91714
  };
91344
91715
  //#endregion
91345
- //#region ../../node_modules/.pnpm/@effect+ai-anthropic@4.0.4_effect@4.0.4/node_modules/@effect/ai-anthropic/dist/AnthropicConfig.js
91716
+ //#region ../../node_modules/.pnpm/@effect+ai-anthropic@4.0.5_effect@4.0.5/node_modules/@effect/ai-anthropic/dist/AnthropicConfig.js
91346
91717
  /**
91347
91718
  * The `AnthropicConfig` module lets a workflow temporarily customize the HTTP
91348
91719
  * client used by generated Anthropic requests. It is used by
@@ -91375,7 +91746,7 @@ var AnthropicConfig = class AnthropicConfig extends (/*#__PURE__*/ Service()("@e
91375
91746
  static getOrUndefined = /*#__PURE__*/ map$1(/*#__PURE__*/ context$1(), /*#__PURE__*/ getOrUndefined$1(AnthropicConfig));
91376
91747
  };
91377
91748
  //#endregion
91378
- //#region ../../node_modules/.pnpm/@effect+ai-anthropic@4.0.4_effect@4.0.4/node_modules/@effect/ai-anthropic/dist/Generated.js
91749
+ //#region ../../node_modules/.pnpm/@effect+ai-anthropic@4.0.5_effect@4.0.5/node_modules/@effect/ai-anthropic/dist/Generated.js
91379
91750
  /**
91380
91751
  * @stability unstable
91381
91752
  * @since 4.0.0
@@ -94376,7 +94747,7 @@ const make$8 = (httpClient, options = {}) => {
94376
94747
  const withOptionalResponse = config?.includeResponse ? (response) => map$1(f(response), (a) => [a, response]) : (response) => f(response);
94377
94748
  return options?.transformClient ? (request) => flatMap(flatMap(options.transformClient(httpClient), (client) => client.execute(request)), withOptionalResponse) : (request) => flatMap(httpClient.execute(request), withOptionalResponse);
94378
94749
  };
94379
- const binaryRequest = (request) => filterStatusOk(httpClient).execute(request).pipe(map$1((response) => response.stream), unwrap$1);
94750
+ const binaryRequest = (request) => filterStatusOk(httpClient).execute(request).pipe(map$1((response) => response.stream), unwrap$2);
94380
94751
  const decodeSuccess = (schema) => (response) => schemaBodyJson$1(schema)(response);
94381
94752
  const decodeError = (tag, schema) => (response) => flatMap(schemaBodyJson$1(schema)(response), (cause) => fail$1(AnthropicClientError(tag, cause, response)));
94382
94753
  return {
@@ -94821,7 +95192,7 @@ const AnthropicClientError = (tag, cause, response) => new AnthropicClientErrorI
94821
95192
  request: response.request
94822
95193
  });
94823
95194
  //#endregion
94824
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/ai/AiError.js
95195
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/ai/AiError.js
94825
95196
  /**
94826
95197
  * Defines shared errors for AI operations.
94827
95198
  *
@@ -94871,7 +95242,7 @@ const HttpRequestDetails$1 = /*#__PURE__*/ Struct({
94871
95242
  "QUERY"
94872
95243
  ]),
94873
95244
  url: String$1,
94874
- urlParams: ArraySchema(Tuple([String$1, String$1])),
95245
+ urlParams: ArraySchema(Tuple([String$1, Union([String$1, Redacted(String$1)])])),
94875
95246
  hash: optional$1(String$1),
94876
95247
  headers: Record(String$1, Union([String$1, Redacted(String$1)]))
94877
95248
  }).annotate({ identifier: "HttpRequestDetails" });
@@ -96196,7 +96567,7 @@ const isAiErrorReason = (u) => hasProperty(u, ReasonTypeId);
96196
96567
  */
96197
96568
  const make$7 = (params) => new AiError(params);
96198
96569
  //#endregion
96199
- //#region ../../node_modules/.pnpm/@effect+ai-anthropic@4.0.4_effect@4.0.4/node_modules/@effect/ai-anthropic/dist/internal/errors.js
96570
+ //#region ../../node_modules/.pnpm/@effect+ai-anthropic@4.0.5_effect@4.0.5/node_modules/@effect/ai-anthropic/dist/internal/errors.js
96200
96571
  /** @internal */
96201
96572
  const AnthropicErrorBody = /*#__PURE__*/ Struct({
96202
96573
  type: /*#__PURE__*/ Literal$1("error"),
@@ -96434,7 +96805,7 @@ const mapStatusCodeToReason = ({ status, headers, message, metadata, http }) =>
96434
96805
  }
96435
96806
  };
96436
96807
  //#endregion
96437
- //#region ../../node_modules/.pnpm/@effect+ai-anthropic@4.0.4_effect@4.0.4/node_modules/@effect/ai-anthropic/dist/AnthropicClient.js
96808
+ //#region ../../node_modules/.pnpm/@effect+ai-anthropic@4.0.5_effect@4.0.5/node_modules/@effect/ai-anthropic/dist/AnthropicClient.js
96438
96809
  /**
96439
96810
  * Service tag for the Anthropic client.
96440
96811
  *
@@ -96496,7 +96867,7 @@ const make$6 = /*#__PURE__*/ fnUntraced(function* (options) {
96496
96867
  return client;
96497
96868
  }) });
96498
96869
  const httpClientOk = filterStatusOk(httpClient);
96499
- const streamRequest = (schema) => (request) => httpClientOk.execute(request).pipe(map$1((response) => response.stream), unwrap$1, decodeText, pipeThroughChannel(decodeSchema(schema)));
96870
+ const streamRequest = (schema) => (request) => httpClientOk.execute(request).pipe(map$1((response) => response.stream), unwrap$2, decodeText, pipeThroughChannel(decodeSchema(schema)));
96500
96871
  const createMessage = (options) => client.betaMessagesPost({
96501
96872
  ...options,
96502
96873
  config: { includeResponse: true }
@@ -96545,7 +96916,7 @@ const make$6 = /*#__PURE__*/ fnUntraced(function* (options) {
96545
96916
  });
96546
96917
  }, withRedactedHeaders);
96547
96918
  //#endregion
96548
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/ai/Tool.js
96919
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/ai/Tool.js
96549
96920
  /**
96550
96921
  * Definitions and helpers for tools that AI models can request during a
96551
96922
  * workflow.
@@ -97032,7 +97403,7 @@ function isEmptyParamsRecord(indexSignature) {
97032
97403
  return indexSignature.parameter === string && isNever(indexSignature.type);
97033
97404
  }
97034
97405
  //#endregion
97035
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/ai/internal/structured-output.js
97406
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/ai/internal/structured-output.js
97036
97407
  const REST_PROPERTY_NAME = "__rest__";
97037
97408
  const TAIL_PROPERTY_PREFIX = "__tail_";
97038
97409
  const RECORD_DESCRIPTION = "Object encoded as array of [key, value] pairs. Apply object constraints to the decoded object";
@@ -97065,7 +97436,7 @@ function toCodec(schema) {
97065
97436
  const encoded = toEncoded(jsonCodec.ast);
97066
97437
  const from = transform(encoded);
97067
97438
  if (from === encoded) return jsonCodec.ast === schema.ast ? schema : jsonCodec;
97068
- return make$35(decodeTo$1(from, jsonCodec.ast, passthrough()));
97439
+ return make$37(decodeTo$1(from, jsonCodec.ast, passthrough()));
97069
97440
  }
97070
97441
  function transform(root) {
97071
97442
  let cache;
@@ -97299,7 +97670,7 @@ function isJsonSchema(input) {
97299
97670
  return typeof input === "object" && input !== null && !Array.isArray(input);
97300
97671
  }
97301
97672
  //#endregion
97302
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/ai/AnthropicStructuredOutput.js
97673
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/ai/AnthropicStructuredOutput.js
97303
97674
  /**
97304
97675
  * Converts a `Schema.Codec` to Anthropic structured-output JSON Schema and a
97305
97676
  * matching codec for model output.
@@ -97345,7 +97716,7 @@ function toCodecAnthropic(schema) {
97345
97716
  if (hasReferenceCycle(unresolvedDocument.schema, unresolvedDocument.definitions)) throw new Error("AnthropicStructuredOutput: Recursive schemas are not supported");
97346
97717
  const document = resolveTopLevelReference(unresolvedDocument);
97347
97718
  const jsonSchema = rewriteAnthropic(document.schema);
97348
- if (Object.keys(document.definitions).length > 0) jsonSchema.$defs = map$7(document.definitions, rewriteAnthropic);
97719
+ if (Object.keys(document.definitions).length > 0) jsonSchema.$defs = map$6(document.definitions, rewriteAnthropic);
97349
97720
  return {
97350
97721
  codec,
97351
97722
  jsonSchema
@@ -97432,7 +97803,7 @@ const formats = /*#__PURE__*/ new Set([
97432
97803
  "uuid"
97433
97804
  ]);
97434
97805
  //#endregion
97435
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/ai/IdGenerator.js
97806
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/ai/IdGenerator.js
97436
97807
  /**
97437
97808
  * Service tag for AI identifier generation services.
97438
97809
  *
@@ -97526,7 +97897,7 @@ const makeGenerator = ({ alphabet = DEFAULT_ALPHABET, prefix, separator = DEFAUL
97526
97897
  */
97527
97898
  const defaultIdGenerator = { generateId: /*#__PURE__*/ makeGenerator({ prefix: "id" }) };
97528
97899
  //#endregion
97529
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/ai/internal/codec-transformer.js
97900
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/ai/internal/codec-transformer.js
97530
97901
  const makeDefaultCodecTransformer = (toJsonSchemaDocument) => {
97531
97902
  return (codec) => {
97532
97903
  const document = resolveTopLevelReference(toJsonSchemaDocument(codec));
@@ -97543,7 +97914,7 @@ const makeDefaultCodecTransformer = (toJsonSchemaDocument) => {
97543
97914
  */
97544
97915
  const defaultCodecTransformer$1 = /*#__PURE__*/ makeDefaultCodecTransformer(toJsonSchemaDocument);
97545
97916
  //#endregion
97546
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/ai/Prompt.js
97917
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/ai/Prompt.js
97547
97918
  /**
97548
97919
  * Defines prompts sent to AI language models.
97549
97920
  *
@@ -98043,7 +98414,7 @@ const fromResponseParts = (parts) => {
98043
98414
  return makePrompt(messages);
98044
98415
  };
98045
98416
  //#endregion
98046
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/ai/Response.js
98417
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/ai/Response.js
98047
98418
  const PartTypeId = "~effect/ai/Response/Part";
98048
98419
  const toolPartSchemaCache = /*#__PURE__*/ new WeakMap();
98049
98420
  const toolPartSchemas = (tool) => {
@@ -98595,7 +98966,7 @@ const ErrorPart = /*#__PURE__*/ Struct({
98595
98966
  error: Unknown
98596
98967
  }).annotate({ identifier: "ErrorPart" });
98597
98968
  //#endregion
98598
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/ai/ResponseIdTracker.js
98969
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/ai/ResponseIdTracker.js
98599
98970
  /**
98600
98971
  * Track provider response IDs for incremental language model calls.
98601
98972
  *
@@ -98624,7 +98995,7 @@ const ErrorPart = /*#__PURE__*/ Struct({
98624
98995
  */
98625
98996
  var ResponseIdTracker = class extends (/*#__PURE__*/ Service()("effect/ai/ResponseIdTracker")) {};
98626
98997
  //#endregion
98627
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/ai/Telemetry.js
98998
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/ai/Telemetry.js
98628
98999
  /**
98629
99000
  * Adds OpenTelemetry GenAI attributes to Effect AI spans.
98630
99001
  *
@@ -98754,7 +99125,7 @@ const addGenAIAnnotations$1 = /*#__PURE__*/ dual(2, (span, options) => {
98754
99125
  */
98755
99126
  var CurrentSpanTransformer = class extends (/*#__PURE__*/ Service()("effect/ai/Telemetry/CurrentSpanTransformer")) {};
98756
99127
  //#endregion
98757
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/ai/Toolkit.js
99128
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/ai/Toolkit.js
98758
99129
  /**
98759
99130
  * Groups AI tools together with their handlers.
98760
99131
  *
@@ -98813,7 +99184,7 @@ const TypeId$1 = "~effect/ai/Toolkit";
98813
99184
  * @since 4.0.0
98814
99185
  */
98815
99186
  const FailureOrigin = /*#__PURE__*/ Reference("effect/ai/Toolkit/FailureOrigin", { defaultValue: () => "result" });
98816
- const failureCause = (error, origin) => annotate(fail$4(error), make$36(FailureOrigin, origin));
99187
+ const failureCause = (error, origin) => annotate(fail$4(error), make$38(FailureOrigin, origin));
98817
99188
  const Proto = {
98818
99189
  .../*#__PURE__*/ Prototype({
98819
99190
  label: "Toolkit",
@@ -98885,7 +99256,7 @@ const Proto = {
98885
99256
  })));
98886
99257
  }
98887
99258
  const decodedParams = decodedParamsResult.success;
98888
- const queue = yield* make$33();
99259
+ const queue = yield* make$34();
98889
99260
  const context = {
98890
99261
  toolCallId,
98891
99262
  preliminary: (result) => asVoid(offer(queue, {
@@ -99027,7 +99398,7 @@ const empty = /*#__PURE__*/ makeProto({});
99027
99398
  */
99028
99399
  const make$4 = (...tools) => makeProto(resolveInput(...tools));
99029
99400
  //#endregion
99030
- //#region ../../node_modules/.pnpm/effect@4.0.4/node_modules/effect/dist/ai/LanguageModel.js
99401
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/ai/LanguageModel.js
99031
99402
  /**
99032
99403
  * Service key for text generation, structured output, and tool calls.
99033
99404
  *
@@ -99251,6 +99622,8 @@ const make$3 = /*#__PURE__*/ fnUntraced(function* (params) {
99251
99622
  const parentSpanTransformer = yield* serviceOption(CurrentSpanTransformer);
99252
99623
  const getSpanTransformer = serviceOption(CurrentSpanTransformer).pipe(map$1(orElse$2(() => parentSpanTransformer)));
99253
99624
  const idGenerator = yield* serviceOption(IdGenerator).pipe(map$1(getOrElse(() => defaultIdGenerator)));
99625
+ const contentDecoderFor = makeResponseDecoder((toolkit, deferred) => decodeEffect(mutable(ArraySchema(withUndeclaredToolCalls(Part(toolkit), deferred)))));
99626
+ const streamDecoderFor = makeResponseDecoder((toolkit, deferred) => decodeEffect(NonEmptyArray(withUndeclaredToolCalls(StreamPart(toolkit), deferred))));
99254
99627
  const generateText = (options) => useSpan("LanguageModel.generateText", { kind: "client" }, fnUntraced(function* (span) {
99255
99628
  const spanTransformer = yield* getSpanTransformer;
99256
99629
  const providerOptions = {
@@ -99331,7 +99704,7 @@ const make$3 = /*#__PURE__*/ fnUntraced(function* (params) {
99331
99704
  response: content
99332
99705
  });
99333
99706
  })));
99334
- }, unwrap$1, mapError$1((error) => isSchemaError$1(error) ? make$7({
99707
+ }, unwrap$2, mapError$1((error) => isSchemaError$1(error) ? make$7({
99335
99708
  module: "LanguageModel",
99336
99709
  method: "streamText",
99337
99710
  reason: InvalidOutputError.fromSchemaError(error)
@@ -99355,7 +99728,7 @@ const make$3 = /*#__PURE__*/ fnUntraced(function* (params) {
99355
99728
  };
99356
99729
  return requestOptions.incrementalPrompt ? params.generateText(requestOptions).pipe(catchReason("AiError", "InvalidRequestError", (_) => params.generateText(fallbackOptions))) : params.generateText(requestOptions);
99357
99730
  };
99358
- const { approved, denied } = collectToolApprovals(providerOptions.prompt.content, { excludeResolved: true });
99731
+ const { approved: allResolved, denied: allDenied, pendingApproved: approved, pendingDenied: denied } = collectToolApprovals(providerOptions.prompt.content);
99359
99732
  const hasPendingApprovals = approved.length > 0 || denied.length > 0;
99360
99733
  if (isUndefined(options.toolkit)) {
99361
99734
  if (hasPendingApprovals) return yield* make$7({
@@ -99417,10 +99790,7 @@ const make$3 = /*#__PURE__*/ fnUntraced(function* (params) {
99417
99790
  preResolvedResults = [...approvedResults, ...deniedResults];
99418
99791
  if (preResolvedResults.length > 0) providerOptions.prompt = fromMessages([...providerOptions.prompt.content, ...fromResponseParts(preResolvedResults).content]);
99419
99792
  }
99420
- {
99421
- const { approved: allResolved, denied: allDenied } = collectToolApprovals(providerOptions.prompt.content);
99422
- if (allResolved.length > 0 || allDenied.length > 0) providerOptions.prompt = stripResolvedApprovals(providerOptions.prompt, allResolved, allDenied);
99423
- }
99793
+ if (allResolved.length > 0 || allDenied.length > 0) providerOptions.prompt = stripResolvedApprovals(providerOptions.prompt, allResolved, allDenied);
99424
99794
  providerOptions.tools = typeof toolChoice === "object" && "oneOf" in toolChoice ? Object.values(toolkit.tools).filter((tool) => toolChoice.oneOf.includes(tool.name)) : Object.values(toolkit.tools);
99425
99795
  providerOptions.toolChoice = toolChoice;
99426
99796
  if (tracker) {
@@ -99430,10 +99800,10 @@ const make$3 = /*#__PURE__*/ fnUntraced(function* (params) {
99430
99800
  providerOptions.incrementalPrompt = prepared.value.prompt;
99431
99801
  }
99432
99802
  }
99433
- const ResponseSchema = mutable(ArraySchema(withUndeclaredToolCalls(Part(options.disableToolCallResolution === true && !deferToolCallValidation ? makeToolkitWithEncodedParameters(toolkit) : makeToolkitWithOpaqueParameters(toolkit)), deferToolCallValidation)));
99803
+ const decodeContent = contentDecoderFor(toolkit, options.disableToolCallResolution === true && !deferToolCallValidation, deferToolCallValidation);
99434
99804
  if (options.disableToolCallResolution === true) {
99435
99805
  const rawContent = yield* generateWithNonIncrementalFallback();
99436
- const content = yield* decodeEffect(ResponseSchema)(rawContent);
99806
+ const content = yield* decodeContent(rawContent);
99437
99807
  if (deferToolCallValidation) yield* validateProviderExecutedToolCalls(makeToolkitWithEncodedParameters(toolkit), rawContent);
99438
99808
  if (tracker) {
99439
99809
  const responseMetadata = content.find((part) => part.type === "response-metadata");
@@ -99442,7 +99812,7 @@ const make$3 = /*#__PURE__*/ fnUntraced(function* (params) {
99442
99812
  return [...preResolvedResults, ...content];
99443
99813
  }
99444
99814
  const rawContent = yield* generateWithNonIncrementalFallback();
99445
- const content = yield* decodeEffect(ResponseSchema)(rawContent);
99815
+ const content = yield* decodeContent(rawContent);
99446
99816
  yield* validateProviderExecutedToolCalls(toolkit, rawContent);
99447
99817
  const incompleteFinishReason = findIncompleteFinishReason(rawContent);
99448
99818
  const toolResults = incompleteFinishReason !== void 0 ? rawContent.filter((part) => part.type === "tool-call" && part.providerExecuted !== true && toolkit.tools[part.name] !== void 0).map((part) => makeInterruptedToolResult(part, incompleteFinishReason)) : yield* resolveToolCalls(rawContent, toolkit, providerOptions.prompt.content, concurrency).pipe(filter$6((result) => result.type === "tool-approval-request" || result.preliminary === false), runCollect);
@@ -99478,7 +99848,7 @@ const make$3 = /*#__PURE__*/ fnUntraced(function* (params) {
99478
99848
  if (part.type !== "response-metadata") emitted = true;
99479
99849
  })), catchReason$1("AiError", "InvalidRequestError", (_, error) => emitted ? fail$2(error) : params.streamText(fallbackOptions))) : params.streamText(requestOptions);
99480
99850
  };
99481
- const { approved: pendingApproved, denied: pendingDenied } = collectToolApprovals(providerOptions.prompt.content, { excludeResolved: true });
99851
+ const { approved: allResolved, denied: allDenied, pendingApproved, pendingDenied } = collectToolApprovals(providerOptions.prompt.content);
99482
99852
  const hasPendingApprovals = pendingApproved.length > 0 || pendingDenied.length > 0;
99483
99853
  if (isUndefined(options.toolkit)) {
99484
99854
  if (hasPendingApprovals) return yield* make$7({
@@ -99545,7 +99915,6 @@ const make$3 = /*#__PURE__*/ fnUntraced(function* (params) {
99545
99915
  isFailure: r.isFailure
99546
99916
  }));
99547
99917
  }
99548
- const { approved: allResolved, denied: allDenied } = collectToolApprovals(providerOptions.prompt.content);
99549
99918
  if (allResolved.length > 0 || allDenied.length > 0) providerOptions.prompt = stripResolvedApprovals(providerOptions.prompt, allResolved, allDenied);
99550
99919
  providerOptions.tools = typeof toolChoice === "object" && "oneOf" in toolChoice ? Object.values(toolkit.tools).filter((tool) => toolChoice.oneOf.includes(tool.name)) : Object.values(toolkit.tools);
99551
99920
  providerOptions.toolChoice = toolChoice;
@@ -99556,8 +99925,7 @@ const make$3 = /*#__PURE__*/ fnUntraced(function* (params) {
99556
99925
  providerOptions.incrementalPrompt = prepared.value.prompt;
99557
99926
  }
99558
99927
  }
99559
- const ResponseSchema = NonEmptyArray(withUndeclaredToolCalls(StreamPart(options.disableToolCallResolution === true && !deferToolCallValidation ? makeToolkitWithEncodedParameters(toolkit) : makeToolkitWithOpaqueParameters(toolkit)), deferToolCallValidation));
99560
- const decodeParts = decodeEffect(ResponseSchema);
99928
+ const decodeParts = streamDecoderFor(toolkit, options.disableToolCallResolution === true && !deferToolCallValidation, deferToolCallValidation);
99561
99929
  if (options.disableToolCallResolution === true) {
99562
99930
  const encodedToolkit = deferToolCallValidation ? makeToolkitWithEncodedParameters(toolkit) : void 0;
99563
99931
  return streamWithNonIncrementalFallback().pipe(mapArrayEffect((parts) => decodeParts(parts).pipe(encodedToolkit ? tap$1(() => validateProviderExecutedToolCalls(encodedToolkit, parts)) : identity, tracker ? tap$1((decodedParts) => {
@@ -99565,11 +99933,11 @@ const make$3 = /*#__PURE__*/ fnUntraced(function* (params) {
99565
99933
  return void_;
99566
99934
  }) : identity)));
99567
99935
  }
99568
- const queue = yield* make$33();
99936
+ const queue = yield* make$34();
99569
99937
  const deferredFinishParts = [];
99570
99938
  if (preResolvedStreamParts.length > 0) yield* offerAll(queue, preResolvedStreamParts);
99571
- const toolCallFibers = yield* make$17();
99572
- const toolCallSemaphore = concurrency === "unbounded" ? void 0 : yield* make$31(concurrency);
99939
+ const toolCallFibers = yield* make$18();
99940
+ const toolCallSemaphore = concurrency === "unbounded" ? void 0 : yield* make$32(concurrency);
99573
99941
  const pendingToolCalls = /* @__PURE__ */ new Map();
99574
99942
  const bufferedToolCalls = [];
99575
99943
  const handleToolCall = fnUntraced(function* (part) {
@@ -99585,7 +99953,7 @@ const make$3 = /*#__PURE__*/ fnUntraced(function* (params) {
99585
99953
  pendingToolCalls.delete(part.id);
99586
99954
  return;
99587
99955
  }
99588
- yield* toolkit.handle(part.name, part.params, part.id).pipe(unwrap$1, runForEach((result) => {
99956
+ yield* toolkit.handle(part.name, part.params, part.id).pipe(unwrap$2, runForEach((result) => {
99589
99957
  const toolResultPart = makePart("tool-result", {
99590
99958
  id: part.id,
99591
99959
  name: part.name,
@@ -99641,7 +100009,7 @@ const make$3 = /*#__PURE__*/ fnUntraced(function* (params) {
99641
100009
  streamText
99642
100010
  });
99643
100011
  });
99644
- const collectToolApprovals = (messages, options) => {
100012
+ const collectToolApprovals = (messages) => {
99645
100013
  const requests = /* @__PURE__ */ new Map();
99646
100014
  const responses = [];
99647
100015
  const toolCallsById = /* @__PURE__ */ new Map();
@@ -99665,22 +100033,30 @@ const collectToolApprovals = (messages, options) => {
99665
100033
  }
99666
100034
  const approved = [];
99667
100035
  const denied = [];
100036
+ const pendingApproved = [];
100037
+ const pendingDenied = [];
99668
100038
  for (const response of responses) {
99669
100039
  const request = requests.get(response.approvalId);
99670
100040
  if (isNotUndefined(request)) {
99671
- if (options?.excludeResolved && toolResultIds.has(request.toolCallId)) continue;
99672
100041
  const result = {
99673
100042
  ...response,
99674
100043
  toolCallId: request.toolCallId,
99675
100044
  toolCall: toolCallsById.get(request.toolCallId)
99676
100045
  };
99677
- if (response.approved) approved.push(result);
99678
- else denied.push(result);
100046
+ if (response.approved) {
100047
+ approved.push(result);
100048
+ if (!toolResultIds.has(request.toolCallId)) pendingApproved.push(result);
100049
+ } else {
100050
+ denied.push(result);
100051
+ if (!toolResultIds.has(request.toolCallId)) pendingDenied.push(result);
100052
+ }
99679
100053
  }
99680
100054
  }
99681
100055
  return {
99682
100056
  approved,
99683
- denied
100057
+ denied,
100058
+ pendingApproved,
100059
+ pendingDenied
99684
100060
  };
99685
100061
  };
99686
100062
  /**
@@ -99825,7 +100201,7 @@ const resolveToolCalls = (content, toolkit, messages, concurrency) => {
99825
100201
  preliminary: false
99826
100202
  }));
99827
100203
  }
99828
- if (approvedToolCallIds.has(toolCall.id)) return toolkit.handle(toolCall.name, toolCall.params, toolCall.id).pipe(unwrap$1, map$2((result) => makePart("tool-result", {
100204
+ if (approvedToolCallIds.has(toolCall.id)) return toolkit.handle(toolCall.name, toolCall.params, toolCall.id).pipe(unwrap$2, map$2((result) => makePart("tool-result", {
99829
100205
  id: toolCall.id,
99830
100206
  name: toolCall.name,
99831
100207
  providerExecuted: false,
@@ -99841,7 +100217,7 @@ const resolveToolCalls = (content, toolkit, messages, concurrency) => {
99841
100217
  toolCallId: toolCall.id
99842
100218
  }));
99843
100219
  }
99844
- return toolkit.handle(toolCall.name, toolCall.params, toolCall.id).pipe(unwrap$1, map$2((result) => makePart("tool-result", {
100220
+ return toolkit.handle(toolCall.name, toolCall.params, toolCall.id).pipe(unwrap$2, map$2((result) => makePart("tool-result", {
99845
100221
  id: toolCall.id,
99846
100222
  name: toolCall.name,
99847
100223
  providerExecuted: false,
@@ -99850,9 +100226,23 @@ const resolveToolCalls = (content, toolkit, messages, concurrency) => {
99850
100226
  isFailure: result.isFailure,
99851
100227
  preliminary: result.preliminary
99852
100228
  })));
99853
- }).pipe(unwrap$1));
100229
+ }).pipe(unwrap$2));
99854
100230
  return mergeAll$1(streams, { concurrency });
99855
100231
  };
100232
+ const makeResponseDecoder = (make) => {
100233
+ let cached;
100234
+ return (toolkit, encoded, deferred) => {
100235
+ const key = [encoded, deferred];
100236
+ for (const tool of Object.values(toolkit.tools)) key.push(tool.name, tool.parametersSchema, tool.successSchema, tool.failureSchema);
100237
+ if (cached !== void 0 && cached.key.length === key.length && cached.key.every((part, i) => part === key[i])) return cached.decode;
100238
+ const decode = make(encoded ? makeToolkitWithEncodedParameters(toolkit) : makeToolkitWithOpaqueParameters(toolkit), deferred);
100239
+ cached = {
100240
+ key,
100241
+ decode
100242
+ };
100243
+ return decode;
100244
+ };
100245
+ };
99856
100246
  const parameterModeTools = /*#__PURE__*/ new WeakMap();
99857
100247
  const withParameterMode = (tool, mode) => {
99858
100248
  let tools = parameterModeTools.get(tool);
@@ -99918,7 +100308,7 @@ const applySpanTransformer = (transformer, response, options) => {
99918
100308
  });
99919
100309
  };
99920
100310
  //#endregion
99921
- //#region ../../node_modules/.pnpm/@effect+ai-anthropic@4.0.4_effect@4.0.4/node_modules/@effect/ai-anthropic/dist/AnthropicTelemetry.js
100311
+ //#region ../../node_modules/.pnpm/@effect+ai-anthropic@4.0.5_effect@4.0.5/node_modules/@effect/ai-anthropic/dist/AnthropicTelemetry.js
99922
100312
  /**
99923
100313
  * The `AnthropicTelemetry` module defines Anthropic-specific telemetry
99924
100314
  * attributes and a helper for adding them to a tracing span. It keeps the
@@ -99955,7 +100345,7 @@ const addGenAIAnnotations = /*#__PURE__*/ dual(2, (span, options) => {
99955
100345
  }
99956
100346
  });
99957
100347
  //#endregion
99958
- //#region ../../node_modules/.pnpm/@effect+ai-anthropic@4.0.4_effect@4.0.4/node_modules/@effect/ai-anthropic/dist/internal/utilities.js
100348
+ //#region ../../node_modules/.pnpm/@effect+ai-anthropic@4.0.5_effect@4.0.5/node_modules/@effect/ai-anthropic/dist/internal/utilities.js
99959
100349
  const finishReasonMap = {
99960
100350
  end_turn: "stop",
99961
100351
  max_tokens: "length",
@@ -99972,7 +100362,7 @@ const resolveFinishReason = (finishReason, isJsonResponse = false) => {
99972
100362
  return reason;
99973
100363
  };
99974
100364
  //#endregion
99975
- //#region ../../node_modules/.pnpm/@effect+ai-anthropic@4.0.4_effect@4.0.4/node_modules/@effect/ai-anthropic/dist/AnthropicLanguageModel.js
100365
+ //#region ../../node_modules/.pnpm/@effect+ai-anthropic@4.0.5_effect@4.0.5/node_modules/@effect/ai-anthropic/dist/AnthropicLanguageModel.js
99976
100366
  /**
99977
100367
  * The `AnthropicLanguageModel` module provides the Anthropic implementation of
99978
100368
  * Effect AI's `LanguageModel` service. It translates Effect AI prompts, tools,
@@ -100107,7 +100497,7 @@ const make$2 = /*#__PURE__*/ fnUntraced(function* ({ model, config: providerConf
100107
100497
  options,
100108
100498
  toolNameMapper
100109
100499
  });
100110
- }, (effect, options) => effect.pipe(unwrap$1, map$2((response) => {
100500
+ }, (effect, options) => effect.pipe(unwrap$2, map$2((response) => {
100111
100501
  annotateStreamResponse(options.span, response);
100112
100502
  return response;
100113
100503
  })))
@@ -101682,7 +102072,7 @@ var Organizer = class Organizer extends Service()("@deslop/stash/services/notes/
101682
102072
  content: join$1(instructions, " "),
101683
102073
  role: "system"
101684
102074
  }, {
101685
- content: [...map$4(input.images, (image) => ({
102075
+ content: [...map$3(input.images, (image) => ({
101686
102076
  data: image.bytes,
101687
102077
  mediaType: image.type,
101688
102078
  type: "file"
@@ -101698,10 +102088,10 @@ var Organizer = class Organizer extends Service()("@deslop/stash/services/notes/
101698
102088
  ...response.value,
101699
102089
  tags: normalizeTags(response.value.tags)
101700
102090
  };
101701
- }, timeout("5 minutes"), mapError((cause) => is$4(NotesError)(cause) ? cause : NotesError.make({
101702
- cause: make$37(cause),
102091
+ }, timeout("5 minutes"), mapError((cause) => pipe(liftPredicate(cause, is$4(NotesError)), getOrElse(() => NotesError.make({
102092
+ cause: make$39(cause),
101703
102093
  message: "AI tagging failed; the note is saved as it is."
101704
- }))) });
102094
+ }))))) });
101705
102095
  }));
101706
102096
  };
101707
102097
  //#endregion
@@ -101746,7 +102136,8 @@ const openStore = fnUntraced(function* (path) {
101746
102136
  function withWords(note, text) {
101747
102137
  const known = pipe(note.text, toLowerCase, split(/\s+/u));
101748
102138
  const added = pipe(commentFor(text), split(" "), filter$4((word) => isNonEmpty$1(word) && !contains$1(known, toLowerCase(word))));
101749
- return isReadonlyArrayEmpty(added) ? note : {
102139
+ if (isReadonlyArrayEmpty(added)) return note;
102140
+ return {
101750
102141
  ...note,
101751
102142
  text: `${note.text}\n${join$1(added, " ")}`
101752
102143
  };
@@ -101757,8 +102148,12 @@ function still(bytes) {
101757
102148
  type: "image/jpeg"
101758
102149
  };
101759
102150
  }
101760
- function isVideo(type) {
101761
- return startsWith("video/")(type);
102151
+ const isVideo = startsWith("video/");
102152
+ function changeNote(notes, id, change) {
102153
+ return map$3(notes, (note) => match(note.id === id, {
102154
+ onFalse: () => note,
102155
+ onTrue: () => change(note)
102156
+ }));
101762
102157
  }
101763
102158
  function optional(message, fallback) {
101764
102159
  return (effect) => pipe(effect, tapError((error) => logWarning(message, error)), orElseSucceed(fallback));
@@ -101776,8 +102171,8 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
101776
102171
  const directory = yield* pipe(String$2("STASH_DATA_DIR"), withDefault(path.join(yield* String$2("HOME"), ".deslop", "stash")));
101777
102172
  const images = path.join(directory, "images");
101778
102173
  const files = path.join(directory, "files");
101779
- const reading = yield* make$31(2);
101780
- const runs = yield* make$15();
102174
+ const reading = yield* make$32(2);
102175
+ const runs = yield* make$16();
101781
102176
  const storageFailed = mapError((cause) => NotesError.make({
101782
102177
  cause,
101783
102178
  message: "The notes database or files could not be read or written."
@@ -101800,7 +102195,7 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
101800
102195
  }));
101801
102196
  }
101802
102197
  function updateNote(id, change) {
101803
- return transact((current) => make$38(void 0, map$4(current, (note) => note.id === id ? change(note) : note)));
102198
+ return transact((current) => make$40(void 0, changeNote(current, id, change)));
101804
102199
  }
101805
102200
  function findNote(id) {
101806
102201
  return map$1(get$1(state), (notes) => findFirst(notes, (note) => note.id === id));
@@ -101820,13 +102215,16 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
101820
102215
  }))), optional("The preview could not be read", empty$11)), ...stills];
101821
102216
  if (isEmpty$2(note.content) && isEmpty$2(note.transcript ?? "") && isEmpty$2(commentFor(note.text)) && isReadonlyArrayEmpty(pictures)) return yield* updateNote(id, (item) => ({
101822
102217
  ...item,
101823
- issue: isEmpty$2(item.issue) ? "Nothing to read at this link." : item.issue,
102218
+ issue: match(isEmpty$2(item.issue), {
102219
+ onFalse: () => item.issue,
102220
+ onTrue: () => "Nothing to read at this link."
102221
+ }),
101824
102222
  status: "failed"
101825
102223
  }));
101826
102224
  const outcome = yield* result$1(organizer.organize({
101827
102225
  images: pictures,
101828
102226
  note,
101829
- tags: map$4(tagCounts(yield* get$1(state)), (entry) => entry.tag)
102227
+ tags: map$3(tagCounts(yield* get$1(state)), (entry) => entry.tag)
101830
102228
  }));
101831
102229
  yield* updateNote(id, (item) => match$3(outcome, {
101832
102230
  onFailure: (error) => ({
@@ -101857,14 +102255,20 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
101857
102255
  yield* updateNote(note.id, (item) => match$3(extraction, {
101858
102256
  onFailure: (error) => ({
101859
102257
  ...item,
101860
- issue: isEmpty$2(item.content) ? error.message : item.issue
102258
+ issue: match(isEmpty$2(item.content), {
102259
+ onFalse: () => item.issue,
102260
+ onTrue: () => error.message
102261
+ })
101861
102262
  }),
101862
102263
  onSuccess: (page) => ({
101863
102264
  ...item,
101864
102265
  author: page.author,
101865
102266
  content: page.text,
101866
102267
  issue: "",
101867
- title: isNonEmpty$1(page.title) && item.title === item.url ? page.title : item.title
102268
+ title: match(isNonEmpty$1(page.title) && item.title === item.url, {
102269
+ onFalse: () => item.title,
102270
+ onTrue: () => page.title
102271
+ })
101868
102272
  })
101869
102273
  }));
101870
102274
  const slides = yield* match$3(extraction, {
@@ -101881,7 +102285,7 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
101881
102285
  onSuccess: (page) => page.video ?? page.url
101882
102286
  });
101883
102287
  const read = yield* pipe(media.read(video), asSome, optional("The video could not be read", none));
101884
- const transcript = yield* pipe(filter$5(read, () => note.transcript === void 0), map$3((details) => pipe(details.transcript, optional("No transcript", none))), transposeOption, map$1(flatten));
102288
+ const transcript = yield* pipe(filter$5(read, () => note.transcript === void 0), map$4((details) => pipe(details.transcript, optional("No transcript", none))), transposeOption, map$1(flatten));
101885
102289
  yield* updateNote(note.id, (item) => ({
101886
102290
  ...item,
101887
102291
  ...match$1(filter$5(read, () => sourceFor(url) !== "X" || isFailure(extraction)), {
@@ -101896,7 +102300,7 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
101896
102300
  onSome: (text) => ({ transcript: text })
101897
102301
  })
101898
102302
  }));
101899
- yield* tag(note.id, [...slides, ...map$4(yield* pipe(media.frames(video), optional("No video frames", empty$11)), still)]);
102303
+ yield* tag(note.id, [...slides, ...map$3(yield* pipe(media.frames(video), optional("No video frames", empty$11)), still)]);
101900
102304
  });
101901
102305
  const organizeFile = fnUntraced(function* (note, type) {
101902
102306
  if (!isVideo(type)) return yield* tag(note.id, []);
@@ -101913,7 +102317,7 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
101913
102317
  transcript: text
101914
102318
  }))
101915
102319
  });
101916
- yield* tag(note.id, map$4(drop(stills, 1), still));
102320
+ yield* tag(note.id, map$3(drop(stills, 1), still));
101917
102321
  });
101918
102322
  function start(note) {
101919
102323
  return pipe(match$1(fromNullishOr(note.file), {
@@ -101922,25 +102326,33 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
101922
102326
  onSome: (link) => reading.withPermit(organizeLink(note, link))
101923
102327
  }),
101924
102328
  onSome: (type) => reading.withPermit(organizeFile(note, type))
101925
- }), tapCause((cause) => hasInterruptsOnly(cause) ? void_ : pipe(updateNote(note.id, (item) => item.status === "organizing" ? {
101926
- ...item,
101927
- issue: "Tagging stopped before it finished.",
101928
- status: "failed"
101929
- } : item), skip("A stopped tagging run could not be recorded"))), (effect) => run$1(runs, note.id, effect), asVoid);
102329
+ }), tapCause((cause) => match(hasInterruptsOnly(cause), {
102330
+ onFalse: () => pipe(updateNote(note.id, (item) => match(item.status === "organizing", {
102331
+ onFalse: () => item,
102332
+ onTrue: () => ({
102333
+ ...item,
102334
+ issue: "Tagging stopped before it finished.",
102335
+ status: "failed"
102336
+ })
102337
+ })), skip("A stopped tagging run could not be recorded")),
102338
+ onTrue: () => void_
102339
+ })), (effect) => run$1(runs, note.id, effect), asVoid);
101930
102340
  }
101931
102341
  yield* forEach(filter$4(yield* get$1(state), (note) => note.status === "organizing"), start, { discard: true });
101932
102342
  const missing = mapError(() => NotesError.make({ message: "This note no longer exists." }));
101933
102343
  const receive = fnUntraced(function* (input) {
101934
- const video = isVideo(input.type);
101935
- const stored = path.join(video ? files : images, input.id);
102344
+ const stored = path.join(match(isVideo(input.type), {
102345
+ onFalse: () => images,
102346
+ onTrue: () => files
102347
+ }), input.id);
101936
102348
  const partial = `${stored}.${yield* nextIntBetween(0, 1e9)}.partial`;
101937
102349
  yield* pipe(input.body, mapError$1((cause) => NotesError.make({
101938
102350
  cause,
101939
102351
  message: "The upload broke off."
101940
- })), limitBytes(gibibytes(1), () => fail$2(NotesError.make({ message: "The file is larger than 1 GiB." }))), run$3(fs.sink(partial, { mode: 384 })), mapError((cause) => is$4(NotesError)(cause) ? cause : NotesError.make({
102352
+ })), limitBytes(gibibytes(1), () => fail$2(NotesError.make({ message: "The file is larger than 1 GiB." }))), run$3(fs.sink(partial, { mode: 384 })), catchTag("PlatformError", (cause) => fail$1(NotesError.make({
101941
102353
  cause,
101942
102354
  message: "The upload could not be written."
101943
- })), onError(() => pipe(fs.remove(partial, { force: true }), skip("A broken upload stays on disk"))));
102355
+ }))), onError(() => pipe(fs.remove(partial, { force: true }), skip("A broken upload stays on disk"))));
101944
102356
  yield* pipe(fs.rename(partial, stored), storageFailed);
101945
102357
  const note = Note.make({
101946
102358
  author: "",
@@ -101948,19 +102360,24 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
101948
102360
  createdAt: toEpochMillis(yield* now),
101949
102361
  file: input.type,
101950
102362
  id: input.id,
101951
- ...video ? {} : { image: input.type === "image/png" ? "image/png" : "image/jpeg" },
102363
+ ...pipe(liftPredicate(input.type, is$4(ImageType)), match$1({
102364
+ onNone: () => ({ title: "video" }),
102365
+ onSome: (image) => ({
102366
+ image,
102367
+ title: "image"
102368
+ })
102369
+ })),
101952
102370
  issue: "",
101953
102371
  source: "Note",
101954
102372
  status: "organizing",
101955
102373
  summary: "",
101956
102374
  tags: [],
101957
102375
  text: "",
101958
- title: video ? "video" : "image",
101959
102376
  url: null
101960
102377
  });
101961
102378
  const earlier = yield* transact((current) => match$1(findFirst(current, (item) => item.id === input.id), {
101962
- onNone: () => make$38(none(), prepend$2(current, note)),
101963
- onSome: (item) => make$38(some$1(item), current)
102379
+ onNone: () => make$40(none(), prepend$2(current, note)),
102380
+ onSome: (item) => make$40(some$1(item), current)
101964
102381
  }));
101965
102382
  return yield* match$1(earlier, {
101966
102383
  onNone: () => as$1(start(note), note),
@@ -101971,9 +102388,9 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
101971
102388
  capture: fn$1("Notes.capture")(function* (input) {
101972
102389
  const text = trim(input.text);
101973
102390
  if (isEmpty$2(text)) return yield* NotesError.make({ message: "Paste a link or write a note." });
101974
- const url = yield* pipe(fromNullishOr(captureUrl(text)), map$3((link) => orElseSucceed(sources.resolve(link), () => link)), transposeOption, map$1(getOrNull));
102391
+ const url = yield* pipe(fromUndefinedOr(captureUrl(text)), map$4((link) => orElseSucceed(sources.resolve(link), () => link)), transposeOption);
101975
102392
  const createdAt = toEpochMillis(yield* now);
101976
- const saved = yield* transact((current) => match$1(findFirst(current, (note) => note.id === input.id || url !== null && note.url === url), {
102393
+ const saved = yield* transact((current) => match$1(findFirst(current, (note) => note.id === input.id || exists(url, (link) => note.url === link)), {
101977
102394
  onNone: () => {
101978
102395
  const note = Note.make({
101979
102396
  author: "",
@@ -101981,29 +102398,32 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
101981
102398
  createdAt,
101982
102399
  id: input.id,
101983
102400
  issue: "",
101984
- source: sourceFor(url),
102401
+ source: match$1(url, {
102402
+ onNone: () => "Note",
102403
+ onSome: sourceFor
102404
+ }),
101985
102405
  status: "organizing",
101986
102406
  summary: "",
101987
102407
  tags: [],
101988
102408
  text,
101989
- title: pipe(liftPredicate(commentFor(text), isNonEmpty$1), getOrElse(() => url ?? text), slice$2(0, 200)),
101990
- url
102409
+ title: pipe(liftPredicate(commentFor(text), isNonEmpty$1), orElse$2(() => url), getOrElse(() => text), slice$2(0, 200)),
102410
+ url: getOrNull(url)
101991
102411
  });
101992
- return make$38({
102412
+ return make$40({
101993
102413
  fresh: true,
101994
102414
  note
101995
102415
  }, prepend$2(current, note));
101996
102416
  },
101997
102417
  onSome: (note) => {
101998
102418
  const merged = withWords(note, text);
101999
- if (note.id === input.id || merged === note) return make$38({
102419
+ if (note.id === input.id || merged === note) return make$40({
102000
102420
  fresh: false,
102001
102421
  note
102002
102422
  }, current);
102003
- return make$38({
102423
+ return make$40({
102004
102424
  fresh: false,
102005
102425
  note: merged
102006
- }, map$4(current, (item) => item.id === note.id ? merged : item));
102426
+ }, changeNote(current, note.id, () => merged));
102007
102427
  }
102008
102428
  }));
102009
102429
  if (saved.fresh) yield* start(saved.note);
@@ -102017,18 +102437,18 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
102017
102437
  }),
102018
102438
  changes: changes(state),
102019
102439
  events: pipe(changes(state), groupedWithin(1e4, "400 millis"), flatMap$3((group) => fromIterable(takeRight(group, 1))), mapAccum(() => none(), (previous, current) => [some$1(current), match$1(previous, {
102020
- onNone: () => [{
102440
+ onNone: () => of({
102021
102441
  removed: [],
102022
102442
  reset: true,
102023
102443
  upserted: current
102024
- }],
102444
+ }),
102025
102445
  onSome: (before) => {
102026
102446
  const changes = diff(before, current);
102027
102447
  if (isReadonlyArrayEmpty(changes.upserted) && isReadonlyArrayEmpty(changes.removed)) return [];
102028
- return [{
102448
+ return of({
102029
102449
  ...changes,
102030
102450
  reset: false
102031
- }];
102451
+ });
102032
102452
  }
102033
102453
  })])),
102034
102454
  get: fn$1("Notes.get")(function* (input) {
@@ -102044,26 +102464,29 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
102044
102464
  regenerate: fn$1("Notes.regenerate")(function* (input) {
102045
102465
  yield* remove$1(runs, input.id);
102046
102466
  const reset = yield* transact((current) => match$1(findFirst(current, (note) => note.id === input.id), {
102047
- onNone: () => make$38(none(), current),
102467
+ onNone: () => make$40(none(), current),
102048
102468
  onSome: (found) => {
102049
102469
  const next = {
102050
102470
  ...omit(found, ["transcript"]),
102051
102471
  issue: "",
102052
102472
  status: "organizing"
102053
102473
  };
102054
- return make$38(some$1(next), map$4(current, (note) => note.id === input.id ? next : note));
102474
+ return make$40(some$1(next), changeNote(current, input.id, () => next));
102055
102475
  }
102056
102476
  }));
102057
102477
  yield* pipe(fromOption(reset), missing, flatMap(start));
102058
102478
  }),
102059
102479
  remove: fn$1("Notes.remove")(function* (input) {
102060
102480
  yield* remove$1(runs, input.id);
102061
- yield* transact((current) => make$38(void 0, some$2(current, (note) => note.id === input.id) ? filter$4(current, (note) => note.id !== input.id) : current));
102481
+ yield* transact((current) => make$40(void 0, match(some$2(current, (note) => note.id === input.id), {
102482
+ onFalse: () => current,
102483
+ onTrue: () => filter$4(current, (note) => note.id !== input.id)
102484
+ })));
102062
102485
  yield* pipe(fs.remove(path.join(images, input.id), { force: true }), storageFailed);
102063
102486
  yield* pipe(fs.remove(path.join(files, input.id), { force: true }), storageFailed);
102064
102487
  }),
102065
102488
  search: fn$1("Notes.search")(function* (input) {
102066
- return map$4(findNotes(yield* get$1(state), input.query), (note) => note.id);
102489
+ return map$3(findNotes(yield* get$1(state), input.query), (note) => note.id);
102067
102490
  })
102068
102491
  });
102069
102492
  }));
@@ -109192,7 +109615,7 @@ var require_NodeTracerProvider = /* @__PURE__ */ __commonJSMin(((exports) => {
109192
109615
  exports.NodeTracerProvider = NodeTracerProvider;
109193
109616
  }));
109194
109617
  //#endregion
109195
- //#region ../../node_modules/.pnpm/@effect+opentelemetry@4.0.4_@opentelemetry+api-logs@0.223.0_@opentelemetry+api@1.9.1_@o_c8ed6614f4c4ddb3333dab53d79cf411/node_modules/@effect/opentelemetry/dist/internal/utilities.js
109618
+ //#region ../../node_modules/.pnpm/@effect+opentelemetry@4.0.5_@opentelemetry+api-logs@0.223.0_@opentelemetry+api@1.9.1_@o_6d79f1568002de7903ea176598692d9a/node_modules/@effect/opentelemetry/dist/internal/utilities.js
109196
109619
  var import_src$6 = (/* @__PURE__ */ __commonJSMin(((exports) => {
109197
109620
  Object.defineProperty(exports, "__esModule", { value: true });
109198
109621
  exports.TraceIdRatioBasedSampler = exports.SimpleSpanProcessor = exports.SamplingDecision = exports.RandomIdGenerator = exports.ParentBasedSampler = exports.NoopSpanProcessor = exports.InMemorySpanExporter = exports.ConsoleSpanExporter = exports.BatchSpanProcessor = exports.BasicTracerProvider = exports.AlwaysOnSampler = exports.AlwaysOffSampler = exports.NodeTracerProvider = void 0;
@@ -110845,7 +111268,7 @@ var require_src$4 = /* @__PURE__ */ __commonJSMin(((exports) => {
110845
111268
  });
110846
111269
  }));
110847
111270
  //#endregion
110848
- //#region ../../node_modules/.pnpm/@effect+opentelemetry@4.0.4_@opentelemetry+api-logs@0.223.0_@opentelemetry+api@1.9.1_@o_c8ed6614f4c4ddb3333dab53d79cf411/node_modules/@effect/opentelemetry/dist/internal/attributes.js
111271
+ //#region ../../node_modules/.pnpm/@effect+opentelemetry@4.0.5_@opentelemetry+api-logs@0.223.0_@opentelemetry+api@1.9.1_@o_6d79f1568002de7903ea176598692d9a/node_modules/@effect/opentelemetry/dist/internal/attributes.js
110849
111272
  var import_src$8 = require_src$5();
110850
111273
  var import_src$9 = /* @__PURE__ */ __toESM(require_src$4(), 1);
110851
111274
  const bigint1e9 = /*#__PURE__*/ BigInt(1e9);
@@ -110871,7 +111294,262 @@ const isHomogeneousPrimitiveArray = (array) => {
110871
111294
  return (array.length === 0 || type === "string" || type === "number" || type === "boolean") && array.every((item) => typeof item === type);
110872
111295
  };
110873
111296
  //#endregion
110874
- //#region ../../node_modules/.pnpm/@effect+opentelemetry@4.0.4_@opentelemetry+api-logs@0.223.0_@opentelemetry+api@1.9.1_@o_c8ed6614f4c4ddb3333dab53d79cf411/node_modules/@effect/opentelemetry/dist/Resource.js
111297
+ //#region ../../node_modules/.pnpm/@effect+opentelemetry@4.0.5_@opentelemetry+api-logs@0.223.0_@opentelemetry+api@1.9.1_@o_6d79f1568002de7903ea176598692d9a/node_modules/@effect/opentelemetry/dist/OtelTracer.js
111298
+ /**
111299
+ * Bridges Effect tracing into OpenTelemetry by installing an Effect `Tracer`
111300
+ * that creates OpenTelemetry spans, records attributes, events, links, errors,
111301
+ * and status, and keeps OpenTelemetry context active while traced effects run.
111302
+ * Use this module when an application already has an OpenTelemetry
111303
+ * `TracerProvider`, or when the Node and Web SDK layers should expose Effect
111304
+ * spans to OTLP, console, or other OpenTelemetry-compatible exporters.
111305
+ *
111306
+ * The layer constructors wire Effect's tracer service to either the global
111307
+ * OpenTelemetry tracer provider or an explicitly provided `OtelTracer`. This
111308
+ * module does not create exporters or span processors by itself, so spans are
111309
+ * exported only when the provider has been configured by the application or by
111310
+ * the Node/Web SDK layers. Effect parents take precedence over active
111311
+ * OpenTelemetry spans. Use `Effect.withParentSpan` to inherit Effect-installed
111312
+ * ambient spans.
111313
+ * `makeExternalSpan` and `withSpanContext` continue incoming remote traces.
111314
+ * Preserve `traceFlags` and `traceState` when building external spans; otherwise
111315
+ * sampling defaults to sampled and trace state cannot be propagated.
111316
+ *
111317
+ * @stability unstable
111318
+ * @since 4.0.0
111319
+ */
111320
+ /**
111321
+ * Context service containing the OpenTelemetry `Tracer` used to create spans for Effect tracing.
111322
+ *
111323
+ * @stability unstable
111324
+ * @category services
111325
+ * @since 4.0.0
111326
+ */
111327
+ var OtelTracer = class extends (/*#__PURE__*/ Service()("@effect/opentelemetry/Tracer")) {};
111328
+ /**
111329
+ * Context service containing the OpenTelemetry `TracerProvider` used to obtain tracers.
111330
+ *
111331
+ * @stability unstable
111332
+ * @category services
111333
+ * @since 4.0.0
111334
+ */
111335
+ var OtelTracerProvider = class extends (/*#__PURE__*/ Service()("@effect/opentelemetry/Tracer/OtelTracerProvider")) {};
111336
+ /**
111337
+ * Context service containing OpenTelemetry trace flags used when constructing external span contexts.
111338
+ *
111339
+ * @stability unstable
111340
+ * @category services
111341
+ * @since 4.0.0
111342
+ */
111343
+ var OtelTraceFlags = class extends (/*#__PURE__*/ Service()("@effect/opentelemetry/Tracer/OtelTraceFlags")) {};
111344
+ /**
111345
+ * Context service containing OpenTelemetry trace state used when constructing external span contexts.
111346
+ *
111347
+ * @stability unstable
111348
+ * @category services
111349
+ * @since 4.0.0
111350
+ */
111351
+ var OtelTraceState = class extends (/*#__PURE__*/ Service()("@effect/opentelemetry/Tracer/OtelTraceState")) {};
111352
+ /**
111353
+ * Creates an Effect `Tracer` implementation backed by the configured OpenTelemetry tracer.
111354
+ *
111355
+ * @stability unstable
111356
+ * @category constructors
111357
+ * @since 4.0.0
111358
+ */
111359
+ const make$1 = /*#__PURE__*/ map$1(/*#__PURE__*/ service(OtelTracer), (tracer) => make$41({
111360
+ span(options) {
111361
+ return new OtelSpan(context, trace, tracer, options);
111362
+ },
111363
+ context(primitive, fiber) {
111364
+ const currentSpan = getPropagatedSpan(fiber.cache.span);
111365
+ if (currentSpan === void 0) return primitive["~effect/Effect/evaluate"](fiber);
111366
+ const context$2 = populateContext(context.active(), currentSpan);
111367
+ return context.with(context$2.setValue(EffectSpanKey, trace.getSpan(context$2)), () => primitive["~effect/Effect/evaluate"](fiber));
111368
+ }
111369
+ }));
111370
+ /**
111371
+ * Layer that creates an OpenTelemetry tracer from the provided tracer provider,
111372
+ * using `effect` and the current Effect version as the instrumentation scope.
111373
+ *
111374
+ * @stability unstable
111375
+ * @category layers
111376
+ * @since 4.0.0
111377
+ */
111378
+ const layerTracer = /*#__PURE__*/ effect(OtelTracer, /*#__PURE__*/ gen(function* () {
111379
+ return (yield* OtelTracerProvider).getTracer("effect", getCurrentVersion());
111380
+ }));
111381
+ /**
111382
+ * Layer that creates an OpenTelemetry tracer from a provider, then installs it as the Effect tracer.
111383
+ *
111384
+ * **When to use**
111385
+ *
111386
+ * Use when you already provide an `OtelTracerProvider` and want Effect spans
111387
+ * backed by a tracer derived from it.
111388
+ *
111389
+ * @see {@link layerTracer} for creating only the OpenTelemetry tracer service
111390
+ * @see {@link layerGlobal} for installing the Effect tracer from the global provider
111391
+ * @see {@link layerWithoutOtelTracer} for installing an already-provided `OtelTracer`
111392
+ *
111393
+ * @stability unstable
111394
+ * @category layers
111395
+ * @since 4.0.0
111396
+ */
111397
+ const layer$4 = /*#__PURE__*/ (/* @__PURE__ */ effect(Tracer, make$1)).pipe(/*#__PURE__*/ provideMerge(layerTracer));
111398
+ const OtelSpanTypeId = "~@effect/opentelemetry/OtelTracer/OtelSpan";
111399
+ const kindMap = {
111400
+ "internal": SpanKind.INTERNAL,
111401
+ "client": SpanKind.CLIENT,
111402
+ "server": SpanKind.SERVER,
111403
+ "producer": SpanKind.PRODUCER,
111404
+ "consumer": SpanKind.CONSUMER
111405
+ };
111406
+ /** @internal */
111407
+ var OtelSpan = class {
111408
+ [OtelSpanTypeId];
111409
+ _tag = "Span";
111410
+ name;
111411
+ kind;
111412
+ annotations;
111413
+ links;
111414
+ span;
111415
+ spanId;
111416
+ traceId;
111417
+ attributes = /*#__PURE__*/ new Map();
111418
+ sampled;
111419
+ parent;
111420
+ status;
111421
+ constructor(contextApi, traceApi, tracer, options) {
111422
+ this[OtelSpanTypeId] = OtelSpanTypeId;
111423
+ this.name = options.name;
111424
+ this.annotations = options.annotations;
111425
+ this.links = options.links;
111426
+ this.kind = options.kind;
111427
+ const active = contextApi.active();
111428
+ const fromActive = options.root !== true && isNone(options.parent);
111429
+ this.parent = fromActive ? getOtelParent(traceApi, active, options.annotations) : options.parent;
111430
+ this.span = tracer.startSpan(options.name, {
111431
+ startTime: nanosToHrTime(options.startTime),
111432
+ links: options.links.length > 0 ? options.links.map((link) => ({
111433
+ context: makeSpanContext(link.span),
111434
+ attributes: recordToAttributes(link.attributes)
111435
+ })) : void 0,
111436
+ kind: kindMap[this.kind]
111437
+ }, isNone(this.parent) ? trace.deleteSpan(active) : fromActive && !overridesTraceContext(options.annotations) ? active : populateContext(active, this.parent.value, options.annotations));
111438
+ const spanContext = this.span.spanContext();
111439
+ this.spanId = spanContext.spanId;
111440
+ this.traceId = spanContext.traceId;
111441
+ this.status = {
111442
+ _tag: "Started",
111443
+ startTime: options.startTime
111444
+ };
111445
+ this.sampled = isSampled(spanContext.traceFlags);
111446
+ }
111447
+ attribute(key, value) {
111448
+ this.span.setAttribute(key, unknownToAttributeValue(value));
111449
+ this.attributes.set(key, value);
111450
+ }
111451
+ addLinks(links) {
111452
+ this.links.push(...links);
111453
+ this.span.addLinks(links.map((link) => ({
111454
+ context: makeSpanContext(link.span),
111455
+ attributes: recordToAttributes(link.attributes)
111456
+ })));
111457
+ }
111458
+ end(endTime, exit) {
111459
+ const hrTime = nanosToHrTime(endTime);
111460
+ this.status = {
111461
+ _tag: "Ended",
111462
+ endTime,
111463
+ exit,
111464
+ startTime: this.status.startTime
111465
+ };
111466
+ if (exit._tag === "Success") this.span.setStatus({ code: SpanStatusCode.OK });
111467
+ else if (hasInterruptsOnly(exit.cause)) this.span.setAttribute("effect.fiber.interrupted", true);
111468
+ else {
111469
+ const errors = prettyErrors(exit.cause, { includeCauseInStack: true });
111470
+ if (errors.length > 0) {
111471
+ for (const error of errors) this.span.recordException(error, hrTime);
111472
+ this.span.setStatus({
111473
+ code: SpanStatusCode.ERROR,
111474
+ message: errors[0].message
111475
+ });
111476
+ } else this.span.setStatus({ code: SpanStatusCode.OK });
111477
+ }
111478
+ this.span.end(hrTime);
111479
+ }
111480
+ event(name, startTime, attributes) {
111481
+ this.span.addEvent(name, attributes ? recordToAttributes(attributes) : void 0, nanosToHrTime(startTime));
111482
+ }
111483
+ };
111484
+ const isSampled = (traceFlags) => (traceFlags & TraceFlags.SAMPLED) === TraceFlags.SAMPLED;
111485
+ var OtelParentSpanContext = class extends (/*#__PURE__*/ Service()("@effect/opentelemetry/Tracer/OtelParentSpanContext")) {};
111486
+ const EffectSpanKey = /*#__PURE__*/ createContextKey("@effect/opentelemetry/OtelTracer/EffectSpan");
111487
+ const getOtelParent = (tracer, context, annotations) => {
111488
+ const otelSpan = tracer.getSpan(context);
111489
+ if (otelSpan === void 0 || otelSpan === context.getValue(EffectSpanKey)) return none();
111490
+ const otelParent = otelSpan.spanContext();
111491
+ if (!tracer.isSpanContextValid(otelParent)) return none();
111492
+ return some$1(externalSpan({
111493
+ spanId: otelParent.spanId,
111494
+ traceId: otelParent.traceId,
111495
+ sampled: isSampled(otelParent.traceFlags),
111496
+ annotations: add$1(annotations, OtelParentSpanContext, otelParent)
111497
+ }));
111498
+ };
111499
+ const overridesTraceContext = (annotations) => getOrUndefined$1(annotations, OtelTraceFlags) !== void 0 || getOrUndefined$1(annotations, OtelTraceState) !== void 0;
111500
+ const makeSpanContext = (span, annotations) => {
111501
+ const otelParent = getOrUndefined$1(span.annotations, OtelParentSpanContext);
111502
+ if (otelParent !== void 0) {
111503
+ if (annotations === void 0) return otelParent;
111504
+ const traceFlags = extractTraceService(span, annotations, OtelTraceFlags);
111505
+ const traceState = extractTraceService(span, annotations, OtelTraceState);
111506
+ return {
111507
+ traceId: otelParent.traceId,
111508
+ spanId: otelParent.spanId,
111509
+ isRemote: otelParent.isRemote,
111510
+ traceFlags: traceFlags ?? otelParent.traceFlags,
111511
+ traceState: traceState ?? otelParent.traceState
111512
+ };
111513
+ }
111514
+ const traceFlags = makeTraceFlags(span, annotations);
111515
+ const traceState = makeTraceState(span, annotations);
111516
+ return {
111517
+ spanId: span.spanId,
111518
+ traceId: span.traceId,
111519
+ isRemote: span._tag === "ExternalSpan",
111520
+ traceFlags,
111521
+ traceState
111522
+ };
111523
+ };
111524
+ const makeTraceFlags = (span, annotations) => {
111525
+ let traceFlags;
111526
+ if (isNotUndefined(annotations)) {
111527
+ traceFlags = extractTraceService(span, annotations, OtelTraceFlags);
111528
+ if (isUndefined(traceFlags)) traceFlags = getOrUndefined$1(span.annotations, OtelTraceFlags);
111529
+ }
111530
+ return traceFlags ?? (span.sampled ? TraceFlags.SAMPLED : TraceFlags.NONE);
111531
+ };
111532
+ const makeTraceState = (span, annotations) => {
111533
+ let traceState;
111534
+ if (isNotUndefined(annotations)) {
111535
+ traceState = extractTraceService(span, annotations, OtelTraceState);
111536
+ if (isUndefined(traceState)) traceState = getOrUndefined$1(span.annotations, OtelTraceState);
111537
+ }
111538
+ return traceState;
111539
+ };
111540
+ const extractTraceService = (parent, annotations, service) => {
111541
+ const instance = getOrUndefined$1(annotations, service);
111542
+ if (isNotUndefined(instance)) return instance;
111543
+ return getOrUndefined$1(parent.annotations, service);
111544
+ };
111545
+ const getPropagatedSpan = (span) => {
111546
+ while (span !== void 0 && get$5(span.annotations, DisablePropagation)) span = span._tag === "Span" ? getOrUndefined(span.parent) : void 0;
111547
+ return span;
111548
+ };
111549
+ /** @internal */
111550
+ const populateContext = (context, span, annotations) => span instanceof OtelSpan ? trace.setSpan(context, span.span) : trace.setSpanContext(context, makeSpanContext(span, annotations));
111551
+ //#endregion
111552
+ //#region ../../node_modules/.pnpm/@effect+opentelemetry@4.0.5_@opentelemetry+api-logs@0.223.0_@opentelemetry+api@1.9.1_@o_6d79f1568002de7903ea176598692d9a/node_modules/@effect/opentelemetry/dist/Resource.js
110875
111553
  var import_src$10 = /* @__PURE__ */ __toESM(require_src$8(), 1);
110876
111554
  init_esm$1();
110877
111555
  /**
@@ -110932,7 +111610,7 @@ const configToAttributes = (options) => {
110932
111610
  */
110933
111611
  const layerFromEnv = (additionalAttributes) => effect(Resource, gen(function* () {
110934
111612
  const serviceName = yield* option(String$2("OTEL_SERVICE_NAME"));
110935
- const attributes = yield* String$2("OTEL_RESOURCE_ATTRIBUTES").pipe(withDefault(""), map$8((s) => {
111613
+ const attributes = yield* String$2("OTEL_RESOURCE_ATTRIBUTES").pipe(withDefault(""), map$7((s) => {
110936
111614
  const attrs = s.split(",");
110937
111615
  return reduce(attrs, {}, (acc, attr) => {
110938
111616
  const parts = attr.split("=");
@@ -110949,19 +111627,8 @@ const layerFromEnv = (additionalAttributes) => effect(Resource, gen(function* ()
110949
111627
  });
110950
111628
  }).pipe(orDie));
110951
111629
  //#endregion
110952
- //#region ../../node_modules/.pnpm/@effect+opentelemetry@4.0.4_@opentelemetry+api-logs@0.223.0_@opentelemetry+api@1.9.1_@o_c8ed6614f4c4ddb3333dab53d79cf411/node_modules/@effect/opentelemetry/dist/OtelLogger.js
110953
- /**
110954
- * Connects Effect logging to the OpenTelemetry Logs SDK.
110955
- *
110956
- * This module turns Effect log events into OpenTelemetry log records. It maps
110957
- * Effect log levels to OpenTelemetry severity numbers, provides the
110958
- * `OtelLoggerProvider` service, creates an Effect `Logger` with `make`, and
110959
- * offers layers for installing that logger or creating a scoped SDK
110960
- * `LoggerProvider` from one or more `LogRecordProcessor`s.
110961
- *
110962
- * @stability unstable
110963
- * @since 4.0.0
110964
- */
111630
+ //#region ../../node_modules/.pnpm/@effect+opentelemetry@4.0.5_@opentelemetry+api-logs@0.223.0_@opentelemetry+api@1.9.1_@o_6d79f1568002de7903ea176598692d9a/node_modules/@effect/opentelemetry/dist/OtelLogger.js
111631
+ init_esm$2();
110965
111632
  /**
110966
111633
  * Context service containing the OpenTelemetry `LoggerProvider` used to emit Effect log records.
110967
111634
  *
@@ -111003,15 +111670,17 @@ const logLevelToSeverityNumber = (level) => {
111003
111670
  * @category constructors
111004
111671
  * @since 4.0.0
111005
111672
  */
111006
- const make$1 = /*#__PURE__*/ gen(function* () {
111673
+ const make = /*#__PURE__*/ gen(function* () {
111007
111674
  const loggerProvider = yield* OtelLoggerProvider;
111008
111675
  const clock = yield* Clock;
111009
111676
  const otelLogger = loggerProvider.getLogger("effect", getCurrentVersion());
111010
- return make$39((options) => {
111677
+ return make$42((options) => {
111011
111678
  const attributes = {};
111012
111679
  for (const [key, value] of Object.entries(options.fiber.getRef(CurrentLogAnnotations))) assignProperty$1(attributes, key, unknownToAttributeValue(value));
111013
111680
  attributes["effect.fiberId"] = options.fiber.id;
111014
111681
  const span = getOrUndefined$1(options.fiber.context, ParentSpan);
111682
+ const activeContext = context.active();
111683
+ const logContext = isNotUndefined(span) ? populateContext(activeContext, span, span.annotations) : activeContext;
111015
111684
  if (isNotUndefined(span)) {
111016
111685
  attributes.spanId = span.spanId;
111017
111686
  attributes.traceId = span.traceId;
@@ -111031,7 +111700,8 @@ const make$1 = /*#__PURE__*/ gen(function* () {
111031
111700
  severityNumber: logLevelToSeverityNumber(options.logLevel),
111032
111701
  timestamp: options.date,
111033
111702
  observedTimestamp: nanosToHrTime(clock.currentTimeNanosUnsafe()),
111034
- attributes
111703
+ attributes,
111704
+ context: logContext
111035
111705
  });
111036
111706
  });
111037
111707
  });
@@ -111056,7 +111726,7 @@ const make$1 = /*#__PURE__*/ gen(function* () {
111056
111726
  * @category layers
111057
111727
  * @since 4.0.0
111058
111728
  */
111059
- const layer$4 = (options) => layer$13([make$1], { mergeWithExisting: options.mergeWithExisting ?? true });
111729
+ const layer$3 = (options) => layer$14([make], { mergeWithExisting: options.mergeWithExisting ?? true });
111060
111730
  /**
111061
111731
  * Creates a scoped OpenTelemetry logger provider from one or more log record processors, using the current `Resource` and flushing and shutting down the provider when the layer is released.
111062
111732
  *
@@ -114867,7 +115537,7 @@ var require_src$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
114867
115537
  });
114868
115538
  }));
114869
115539
  //#endregion
114870
- //#region ../../node_modules/.pnpm/@effect+opentelemetry@4.0.4_@opentelemetry+api-logs@0.223.0_@opentelemetry+api@1.9.1_@o_c8ed6614f4c4ddb3333dab53d79cf411/node_modules/@effect/opentelemetry/dist/internal/metrics.js
115540
+ //#region ../../node_modules/.pnpm/@effect+opentelemetry@4.0.5_@opentelemetry+api-logs@0.223.0_@opentelemetry+api@1.9.1_@o_6d79f1568002de7903ea176598692d9a/node_modules/@effect/opentelemetry/dist/internal/metrics.js
114871
115541
  init_esm$2();
114872
115542
  var import_src$7 = require_src$3();
114873
115543
  const sdkName = "@effect/opentelemetry/Metrics";
@@ -115222,7 +115892,7 @@ const determineValueType = (state) => {
115222
115892
  return ValueType.DOUBLE;
115223
115893
  };
115224
115894
  //#endregion
115225
- //#region ../../node_modules/.pnpm/@effect+opentelemetry@4.0.4_@opentelemetry+api-logs@0.223.0_@opentelemetry+api@1.9.1_@o_c8ed6614f4c4ddb3333dab53d79cf411/node_modules/@effect/opentelemetry/dist/OtelMetrics.js
115895
+ //#region ../../node_modules/.pnpm/@effect+opentelemetry@4.0.5_@opentelemetry+api-logs@0.223.0_@opentelemetry+api@1.9.1_@o_6d79f1568002de7903ea176598692d9a/node_modules/@effect/opentelemetry/dist/OtelMetrics.js
115226
115896
  /**
115227
115897
  * Creates an OpenTelemetry metric producer from Effect metrics.
115228
115898
  *
@@ -115303,242 +115973,9 @@ const registerProducer = (self, metricReader, options) => acquireRelease(sync(()
115303
115973
  * @category layers
115304
115974
  * @since 4.0.0
115305
115975
  */
115306
- const layer$3 = (evaluate, options) => effectDiscard(flatMap(makeProducer(options?.temporality), (producer) => registerProducer(producer, evaluate, options)));
115307
- //#endregion
115308
- //#region ../../node_modules/.pnpm/@effect+opentelemetry@4.0.4_@opentelemetry+api-logs@0.223.0_@opentelemetry+api@1.9.1_@o_c8ed6614f4c4ddb3333dab53d79cf411/node_modules/@effect/opentelemetry/dist/OtelTracer.js
115309
- init_esm$2();
115310
- /**
115311
- * Context service containing the OpenTelemetry `Tracer` used to create spans for Effect tracing.
115312
- *
115313
- * @stability unstable
115314
- * @category services
115315
- * @since 4.0.0
115316
- */
115317
- var OtelTracer = class extends (/*#__PURE__*/ Service()("@effect/opentelemetry/Tracer")) {};
115318
- /**
115319
- * Context service containing the OpenTelemetry `TracerProvider` used to obtain tracers.
115320
- *
115321
- * @stability unstable
115322
- * @category services
115323
- * @since 4.0.0
115324
- */
115325
- var OtelTracerProvider = class extends (/*#__PURE__*/ Service()("@effect/opentelemetry/Tracer/OtelTracerProvider")) {};
115326
- /**
115327
- * Context service containing OpenTelemetry trace flags used when constructing external span contexts.
115328
- *
115329
- * @stability unstable
115330
- * @category services
115331
- * @since 4.0.0
115332
- */
115333
- var OtelTraceFlags = class extends (/*#__PURE__*/ Service()("@effect/opentelemetry/Tracer/OtelTraceFlags")) {};
115334
- /**
115335
- * Context service containing OpenTelemetry trace state used when constructing external span contexts.
115336
- *
115337
- * @stability unstable
115338
- * @category services
115339
- * @since 4.0.0
115340
- */
115341
- var OtelTraceState = class extends (/*#__PURE__*/ Service()("@effect/opentelemetry/Tracer/OtelTraceState")) {};
115342
- /**
115343
- * Creates an Effect `Tracer` implementation backed by the configured OpenTelemetry tracer.
115344
- *
115345
- * @stability unstable
115346
- * @category constructors
115347
- * @since 4.0.0
115348
- */
115349
- const make = /*#__PURE__*/ map$1(/*#__PURE__*/ service(OtelTracer), (tracer) => make$40({
115350
- span(options) {
115351
- return new OtelSpan(context, trace, tracer, options);
115352
- },
115353
- context(primitive, fiber) {
115354
- const currentSpan = getPropagatedSpan(fiber.cache.span);
115355
- if (currentSpan === void 0) return primitive["~effect/Effect/evaluate"](fiber);
115356
- const context$2 = populateContext(context.active(), currentSpan);
115357
- return context.with(context$2.setValue(EffectSpanKey, trace.getSpan(context$2)), () => primitive["~effect/Effect/evaluate"](fiber));
115358
- }
115359
- }));
115360
- /**
115361
- * Layer that creates an OpenTelemetry tracer from the provided tracer provider,
115362
- * using `effect` and the current Effect version as the instrumentation scope.
115363
- *
115364
- * @stability unstable
115365
- * @category layers
115366
- * @since 4.0.0
115367
- */
115368
- const layerTracer = /*#__PURE__*/ effect(OtelTracer, /*#__PURE__*/ gen(function* () {
115369
- return (yield* OtelTracerProvider).getTracer("effect", getCurrentVersion());
115370
- }));
115371
- /**
115372
- * Layer that creates an OpenTelemetry tracer from a provider, then installs it as the Effect tracer.
115373
- *
115374
- * **When to use**
115375
- *
115376
- * Use when you already provide an `OtelTracerProvider` and want Effect spans
115377
- * backed by a tracer derived from it.
115378
- *
115379
- * @see {@link layerTracer} for creating only the OpenTelemetry tracer service
115380
- * @see {@link layerGlobal} for installing the Effect tracer from the global provider
115381
- * @see {@link layerWithoutOtelTracer} for installing an already-provided `OtelTracer`
115382
- *
115383
- * @stability unstable
115384
- * @category layers
115385
- * @since 4.0.0
115386
- */
115387
- const layer$2 = /*#__PURE__*/ (/* @__PURE__ */ effect(Tracer, make)).pipe(/*#__PURE__*/ provideMerge(layerTracer));
115388
- const OtelSpanTypeId = "~@effect/opentelemetry/OtelTracer/OtelSpan";
115389
- const kindMap = {
115390
- "internal": SpanKind.INTERNAL,
115391
- "client": SpanKind.CLIENT,
115392
- "server": SpanKind.SERVER,
115393
- "producer": SpanKind.PRODUCER,
115394
- "consumer": SpanKind.CONSUMER
115395
- };
115396
- /** @internal */
115397
- var OtelSpan = class {
115398
- [OtelSpanTypeId];
115399
- _tag = "Span";
115400
- name;
115401
- kind;
115402
- annotations;
115403
- links;
115404
- span;
115405
- spanId;
115406
- traceId;
115407
- attributes = /*#__PURE__*/ new Map();
115408
- sampled;
115409
- parent;
115410
- status;
115411
- constructor(contextApi, traceApi, tracer, options) {
115412
- this[OtelSpanTypeId] = OtelSpanTypeId;
115413
- this.name = options.name;
115414
- this.annotations = options.annotations;
115415
- this.links = options.links;
115416
- this.kind = options.kind;
115417
- const active = contextApi.active();
115418
- const fromActive = options.root !== true && isNone(options.parent);
115419
- this.parent = fromActive ? getOtelParent(traceApi, active, options.annotations) : options.parent;
115420
- this.span = tracer.startSpan(options.name, {
115421
- startTime: nanosToHrTime(options.startTime),
115422
- links: options.links.length > 0 ? options.links.map((link) => ({
115423
- context: makeSpanContext(link.span),
115424
- attributes: recordToAttributes(link.attributes)
115425
- })) : void 0,
115426
- kind: kindMap[this.kind]
115427
- }, isNone(this.parent) ? trace.deleteSpan(active) : fromActive && !overridesTraceContext(options.annotations) ? active : populateContext(active, this.parent.value, options.annotations));
115428
- const spanContext = this.span.spanContext();
115429
- this.spanId = spanContext.spanId;
115430
- this.traceId = spanContext.traceId;
115431
- this.status = {
115432
- _tag: "Started",
115433
- startTime: options.startTime
115434
- };
115435
- this.sampled = isSampled(spanContext.traceFlags);
115436
- }
115437
- attribute(key, value) {
115438
- this.span.setAttribute(key, unknownToAttributeValue(value));
115439
- this.attributes.set(key, value);
115440
- }
115441
- addLinks(links) {
115442
- this.links.push(...links);
115443
- this.span.addLinks(links.map((link) => ({
115444
- context: makeSpanContext(link.span),
115445
- attributes: recordToAttributes(link.attributes)
115446
- })));
115447
- }
115448
- end(endTime, exit) {
115449
- const hrTime = nanosToHrTime(endTime);
115450
- this.status = {
115451
- _tag: "Ended",
115452
- endTime,
115453
- exit,
115454
- startTime: this.status.startTime
115455
- };
115456
- if (exit._tag === "Success") this.span.setStatus({ code: SpanStatusCode.OK });
115457
- else if (hasInterruptsOnly(exit.cause)) this.span.setAttribute("effect.fiber.interrupted", true);
115458
- else {
115459
- const errors = prettyErrors(exit.cause, { includeCauseInStack: true });
115460
- if (errors.length > 0) {
115461
- for (const error of errors) this.span.recordException(error, hrTime);
115462
- this.span.setStatus({
115463
- code: SpanStatusCode.ERROR,
115464
- message: errors[0].message
115465
- });
115466
- } else this.span.setStatus({ code: SpanStatusCode.OK });
115467
- }
115468
- this.span.end(hrTime);
115469
- }
115470
- event(name, startTime, attributes) {
115471
- this.span.addEvent(name, attributes ? recordToAttributes(attributes) : void 0, nanosToHrTime(startTime));
115472
- }
115473
- };
115474
- const isSampled = (traceFlags) => (traceFlags & TraceFlags.SAMPLED) === TraceFlags.SAMPLED;
115475
- var OtelParentSpanContext = class extends (/*#__PURE__*/ Service()("@effect/opentelemetry/Tracer/OtelParentSpanContext")) {};
115476
- const EffectSpanKey = /*#__PURE__*/ createContextKey("@effect/opentelemetry/OtelTracer/EffectSpan");
115477
- const getOtelParent = (tracer, context, annotations) => {
115478
- const otelSpan = tracer.getSpan(context);
115479
- if (otelSpan === void 0 || otelSpan === context.getValue(EffectSpanKey)) return none();
115480
- const otelParent = otelSpan.spanContext();
115481
- if (!tracer.isSpanContextValid(otelParent)) return none();
115482
- return some$1(externalSpan({
115483
- spanId: otelParent.spanId,
115484
- traceId: otelParent.traceId,
115485
- sampled: isSampled(otelParent.traceFlags),
115486
- annotations: add$1(annotations, OtelParentSpanContext, otelParent)
115487
- }));
115488
- };
115489
- const overridesTraceContext = (annotations) => getOrUndefined$1(annotations, OtelTraceFlags) !== void 0 || getOrUndefined$1(annotations, OtelTraceState) !== void 0;
115490
- const makeSpanContext = (span, annotations) => {
115491
- const otelParent = getOrUndefined$1(span.annotations, OtelParentSpanContext);
115492
- if (otelParent !== void 0) {
115493
- if (annotations === void 0) return otelParent;
115494
- const traceFlags = extractTraceService(span, annotations, OtelTraceFlags);
115495
- const traceState = extractTraceService(span, annotations, OtelTraceState);
115496
- return {
115497
- traceId: otelParent.traceId,
115498
- spanId: otelParent.spanId,
115499
- isRemote: otelParent.isRemote,
115500
- traceFlags: traceFlags ?? otelParent.traceFlags,
115501
- traceState: traceState ?? otelParent.traceState
115502
- };
115503
- }
115504
- const traceFlags = makeTraceFlags(span, annotations);
115505
- const traceState = makeTraceState(span, annotations);
115506
- return {
115507
- spanId: span.spanId,
115508
- traceId: span.traceId,
115509
- isRemote: span._tag === "ExternalSpan",
115510
- traceFlags,
115511
- traceState
115512
- };
115513
- };
115514
- const makeTraceFlags = (span, annotations) => {
115515
- let traceFlags;
115516
- if (isNotUndefined(annotations)) {
115517
- traceFlags = extractTraceService(span, annotations, OtelTraceFlags);
115518
- if (isUndefined(traceFlags)) traceFlags = getOrUndefined$1(span.annotations, OtelTraceFlags);
115519
- }
115520
- return traceFlags ?? (span.sampled ? TraceFlags.SAMPLED : TraceFlags.NONE);
115521
- };
115522
- const makeTraceState = (span, annotations) => {
115523
- let traceState;
115524
- if (isNotUndefined(annotations)) {
115525
- traceState = extractTraceService(span, annotations, OtelTraceState);
115526
- if (isUndefined(traceState)) traceState = getOrUndefined$1(span.annotations, OtelTraceState);
115527
- }
115528
- return traceState;
115529
- };
115530
- const extractTraceService = (parent, annotations, service) => {
115531
- const instance = getOrUndefined$1(annotations, service);
115532
- if (isNotUndefined(instance)) return instance;
115533
- return getOrUndefined$1(parent.annotations, service);
115534
- };
115535
- const getPropagatedSpan = (span) => {
115536
- while (span !== void 0 && get$5(span.annotations, DisablePropagation)) span = span._tag === "Span" ? getOrUndefined(span.parent) : void 0;
115537
- return span;
115538
- };
115539
- const populateContext = (context, span, annotations) => span instanceof OtelSpan ? trace.setSpan(context, span.span) : trace.setSpanContext(context, makeSpanContext(span, annotations));
115976
+ const layer$2 = (evaluate, options) => effectDiscard(flatMap(makeProducer(options?.temporality), (producer) => registerProducer(producer, evaluate, options)));
115540
115977
  //#endregion
115541
- //#region ../../node_modules/.pnpm/@effect+opentelemetry@4.0.4_@opentelemetry+api-logs@0.223.0_@opentelemetry+api@1.9.1_@o_c8ed6614f4c4ddb3333dab53d79cf411/node_modules/@effect/opentelemetry/dist/NodeSdk.js
115978
+ //#region ../../node_modules/.pnpm/@effect+opentelemetry@4.0.5_@opentelemetry+api-logs@0.223.0_@opentelemetry+api@1.9.1_@o_6d79f1568002de7903ea176598692d9a/node_modules/@effect/opentelemetry/dist/NodeSdk.js
115542
115979
  /**
115543
115980
  * Creates a scoped Node OpenTelemetry tracer provider from one or more span processors and shuts it down when the layer is released.
115544
115981
  *
@@ -115580,18 +116017,18 @@ const layerTracerProvider = (processor, config) => effect(OtelTracerProvider, ge
115580
116017
  * @category layers
115581
116018
  * @since 4.0.0
115582
116019
  */
115583
- const layer$1 = (evaluate) => unwrap$2(gen(function* () {
116020
+ const layer$1 = (evaluate) => unwrap$3(gen(function* () {
115584
116021
  const config = yield* isEffect(evaluate) ? evaluate : sync(evaluate);
115585
116022
  const ResourceLayer = layerFromEnv(config.resource && configToAttributes(config.resource));
115586
- const TracerLayer = isNonEmpty(config.spanProcessor) ? provide(layer$2, layerTracerProvider(config.spanProcessor, {
116023
+ const TracerLayer = isNonEmpty(config.spanProcessor) ? provide(layer$4, layerTracerProvider(config.spanProcessor, {
115587
116024
  ...config.tracerConfig,
115588
116025
  shutdownTimeout: config.shutdownTimeout
115589
116026
  })) : empty$13;
115590
- const MetricsLayer = isNonEmpty(config.metricReader) ? layer$3(constant(config.metricReader), {
116027
+ const MetricsLayer = isNonEmpty(config.metricReader) ? layer$2(constant(config.metricReader), {
115591
116028
  shutdownTimeout: config.shutdownTimeout,
115592
116029
  temporality: config.metricTemporality
115593
116030
  }) : empty$13;
115594
- const LoggerLayer = isNonEmpty(config.logRecordProcessor) ? provide(layer$4({ mergeWithExisting: config.loggerMergeWithExisting }), layerLoggerProvider(config.logRecordProcessor, {
116031
+ const LoggerLayer = isNonEmpty(config.logRecordProcessor) ? provide(layer$3({ mergeWithExisting: config.loggerMergeWithExisting }), layerLoggerProvider(config.logRecordProcessor, {
115595
116032
  ...config.loggerProviderConfig,
115596
116033
  shutdownTimeout: config.shutdownTimeout
115597
116034
  })) : empty$13;
@@ -118985,7 +119422,7 @@ var import_src = require_src$1();
118985
119422
  var import_src$1 = require_src();
118986
119423
  var import_index_shim = require_index_shim();
118987
119424
  function layer(applicationName) {
118988
- return mergeAll(unwrap$2(map$1(pipe(URL$4("VITE_OTEL_URL"), withDefault(new URL("http://localhost:4318"))), (url) => layer$1(() => ({
119425
+ return mergeAll(unwrap$3(map$1(pipe(URL$4("VITE_OTEL_URL"), withDefault(new URL("http://localhost:4318"))), (url) => layer$1(() => ({
118989
119426
  logRecordProcessor: new import_src$9.BatchLogRecordProcessor({ exporter: new import_src.OTLPLogExporter({ url: new URL("/v1/logs", url).href }) }),
118990
119427
  resource: { serviceName: `${applicationName}-server` },
118991
119428
  spanProcessor: new import_index_shim.BatchSpanProcessor(new import_src$1.OTLPTraceExporter({ url: new URL("/v1/traces", url).href }))
@@ -119031,6 +119468,6 @@ const rpc = pipe(layerHttp({
119031
119468
  path: "/api/rpc",
119032
119469
  protocol: "websocket"
119033
119470
  }), provide(RpcHandlers), provide(layerJson));
119034
- runMain(pipe(serve(merge$3(rpc, routes), { disableLogger: true }), provide(Notes.layer), provide(mergeAll(Sources.layer, Media.layer, Organizer.layer)), provide(merge$3(layer$7, layer$12)), provide(layer("@deslop/stash")), provide(layerNodeHttpServer), launch));
119471
+ runMain(pipe(serve(merge$3(rpc, routes), { disableLogger: true }), provide(Notes.layer), provide(mergeAll(Sources.layer, Media.layer, Organizer.layer)), provide(mergeAll(layer$6, layer$8, layer$13)), provide(layer("@deslop/stash")), provide(layerNodeHttpServer), launch));
119035
119472
  //#endregion
119036
119473
  export { __toCommonJS as a, __require$1 as i, init_esm$2 as n, __commonJSMin as r, esm_exports$3 as t };