@deslop/stash 0.1.1090 → 0.1.1092

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 constPong, $a as isPrivate, $c as isNoSuchElementError, $d as combine$1, $i as last$2, $l as DisablePropagation, $n as unwrap$1, $o as makeSpanScoped, $r as toEpochMillis, $s as withFiber, $t as String$1, $u as make$44, A as layer$10, Aa as badArgument, Ac as split, Ad as exists, Af as constUndefined, Ai as mapError$1, Al as TracerTimingEnabled, An as make$41, Ao as flatMap, Ar as FilterGroup, As as serviceOption, At as Boolean$2, Au as headNonEmpty, B as unwrap$4, Ba as nameServerFromInput, Bc as StackTrace, Bd as isNone, Bi as runForEach, Bl as isExit, Bn as toType, Bo as fromResult, Br as null_, Bs as timeoutOption, Bt as Finite, Bu as prepend$2, C as runMain, Ca as await_, Cc as length, Cd as getOrUndefinedUnsafe, Cf as isObject, Ci as groupedWithin, Cl as forkUnsafe$1, Cn as isGreaterThanOrEqualTo, Cr as toArrayBuffer, Cs as retry, Cu as flatMap$2, Da as interruptAllAs, Dc as replace$1, Dd as merge$1, Df as compose$1, Di as mapArray, Dl as CurrentLogAnnotations, Dn as isPattern, Do as fail$1, Dr as ChildProcessSpawner, Ds as runSync, Dt as isHttpClientError, Du as getUnsafe$1, E as layer$11, Ea as interruptAll, Ec as repeat$1, Ed as makeUnsafe$3, Ef as or$1, Ei as mapAccum, El as provide$1, En as isMinLength, Eo as exit, Er as make$40, Es as runForkWith, Et as TransportError, Eu as getSomes, F as String$2, Fa as zero, Fc as max$2, Fd as fromNullishOr, Ff as identity, Fi as orDie$1, Fl as makeUnsafe$4, Fn as tag, Fo as forever$1, Fr as Union$1, Fs as sync, Ft as Defect, Fu as last$1, G as RpcSerialization, Ga as formatUrlUnsafe, Gc as fail$4, Gd as match$1, Gi as succeed$3, Gl as effectIsExit, Gn as omit, Go as interruptible, Gr as string, Gs as uninterruptible, Gt as MutableJson, Gu as take$1, Ha as NetAddressError, Hc as combine, Hd as liftPredicate, Hl as isSuccess$1, Hn as withDecodingDefault, Ho as ignore$1, Hr as replaceChecks, Hs as transposeOption, Ht as Json, Hu as reverse, I as URL$1, Ia as Dns, Ic as parse$10, Id as fromUndefinedOr, If as pipe, Ii as pipeThroughChannel, Il as die, In as toCodecJson, Io as forkChild, Ir as decodeTo$1, Is as tap$1, It as Duration, Iu as lastNonEmpty, J as layerSchemaBinary, Ja as ipFromStringUnsafe, Jc as fromReasons, Jd as orElseSome, Ji as tap$2, Jl as forkUnsafe, Jn as CurrentRedactedNames$1, Jo as logDebug, Jr as transform$1, Js as updateService, Jt as Null, Ju as keys, K as json$1, Ka as inetAddressFromIpString, Kc as filterInterruptors, Kd as none, Ki as suspend$1, Kl as fiberEnterInterruptibleUnsafe, Kn as getReferenceKey, Ko as isEffect, Kr as toEncoded, Ks as uninterruptibleMask, Kt as Never, Ku as takeRight, L as option, La as DnsError, Ld as getOrElse, Lf as pipeArguments, Li as provideService$1, Ll as fail$3, Lo as forkIn, Lr as isNever, Ls as tapCause, Lt as Error$2, Lu as map$3, M as Port, Ma as fromInputUnsafe, Mc as toLowerCase, Md as flatMap$1, Mf as constant, Mi as mkString, Ml as doneUnsafe, Mn as mutable, Mo as fn$1, Mr as Objects, Ms as succeed$1, Mt as Class$1, Mu as isReadonlyArrayEmpty, N as Record, Na as gibibytes, Nc as trim, Nd as flatMapNullishOr, Nf as dual, Ni as mkUint8Array, Nl as into, Nn as optional$1, No as fnUntraced, Nr as PropertySignature, Ns as succeedNone, Nt as DateTimeUtc, Nu as isReadonlyArrayNonEmpty, Oa as interruptAs, Oc as replaceAll, Od as all$1, Of as constFalse, Oi as mapArrayEffect, Ol as CurrentLogSpans, On as isSchema, Oo as failCause, Or as Arrays, Os as scope, Ot as Any, Ou as groupBy, P as Redacted$1, Pa as mebibytes, Pc as trimEnd, Pd as flatten, Pf as flow, Pi as onEnd, Pl as isDeferred, Pn as optionalKey, Po as forEach, Pr as Suspend, Ps as suspend, Pt as DateTimeUtcFromString, Pu as join$1, Qa as isLoopback, Qd as String$3, Qi as unwrap$2, Qn as setAll$1, Qo as logWarning, Qr as now, Qs as whileLoop, Qt as Redacted, Qu as headUnsafe, R as schema, Ra as make$37, Rc as Clock, Rd as getOrNull, Ri as run$3, Rl as failCause$1, Rn as toEncoded$1, Ro as forkScoped, Rr as isOptional, Rs as tapError$1, Rt as Exit$1, S as make$38, Sa as makeUnsafe$5, Sc as isNonEmpty, Sd as getOrUndefined$1, Sf as isNotUndefined, Si as fromReadableStream, Sl as closeUnsafe, Sn as is$4, So as contextWith, Sr as pipeThroughDuplex, Ss as result$1, St as HttpClientError, Ta as interrupt$2, Tc as padStart, Td as make$42, Tf as isUndefined, Ti as map$2, Tl as makeUnsafe$2, Tn as isMaxLength, To as ensuring$1, Tr as fromWritable, Ts as runFork, Tt as StatusCodeError, Tu as get$6, U as withRun, Ua as formatInet, Uc as die$1, Ud as liftThrowable, Ui as runLast, Ul as succeed$4, Un as withDecodingDefaultKey, Ur as resolveDescription, Us as tryPromise, Ut as Literal$1, Uu as some$2, V as withDefault, Va as domainNameFromStringUnsafe, Vc as annotate, Vd as isSome, Vi as runForEachArray, Vl as isFailure$1, Vn as withConstructorDefault, Vo as gen, Vr as optionalKey$1, Vs as timeoutOrElse, Vt as Int, Vu as reduce, Wa as formatIp, Wd as map$4, Wi as scan, Wn as isSchemaError, Wo as interrupt, Wr as resolveIdentifier, Ws as try_, Wt as Literals, Wu as sort, X as ResponseDefectEncoded, Xa as isInetAddressV6, Xc as hasInterrupts, Xd as toArray$1, Xi as toReadableStreamEffect, Xl as onExitUnsafe, Xn as fromInput, Xo as logFatal, Xr as encode, Xs as void_, Xt as Number$2, Xu as toEntries, Y as RequestId, Ya as ipv4ToOctets, Yc as hasDies, Yd as some$1, Yi as toReadableStream, Yl as makeSpanUnsafe, Yn as empty$7, Yr as transformOptional, Ys as useSpan, Yt as NullOr, Yu as map$6, Z as constEof, Za as isLinkLocal, Zc as hasInterruptsOnly, Zd as Number$1, Zl as reportCauseUnsafe, Zn as redactUrl, Zo as logInfo, Zr as formatIso, Zs as when$2, Zt as Record$1, Zu as empty$12, _ as Organization, _c as Random$2, _d as Reference, _f as hash, _l as unwrap$3, _n as encodeEffect, _o as catchReason, _r as fromSetCookie, _s as provideContext, _u as every, a as FxConversation, aa as pipeTo, ac as zipWith, ad as isSuccess, af as contE, ai as catch_$1, al as buildWithMemoMap, an as URL$2, ao as annotateCurrentSpan, ar as empty$8, as as matchCauseEffectEager, at as isStreamSchema, au as random$1, ba as publishUnsafe, bc as includes, bf as isNotNull, bi as fromPubSub, bl as addFinalizerExit, bn as encodeUnknownEffect$1, bo as catch_, br as toSetCookieHeaders, bs as raceFirst, bt as EmptyBodyError, bu as findFirst, c as GitHubIssue, cc as forever, cd as try_$1, cf as getStackTraceLimit, ci as die$3, cl as effectDiscard, cn as Uint8ArrayFromBase64, co as asSome, cr as isRedactedName, cs as onError, ct as Collector, cu as TaggedError, d as ImageType, da as failCause$2, dd as max$1, df as Class, di as fail$2, dl as mergeAll, dn as Unknown, do as callback, dr as set$1, ds as onInterrupt, du as contains$2, ec as withFiberSucceed, ed as fail, ef as flip, ei as defaultFormatter, el as isTimeoutError, en as StringFromUriComponent, eo as isUnicast, er as fromIterable$3, es as map$1, et as ServerClient, eu as ParentSpan, f as Note, fa as make$36, fc as passthrough, fd as millis, ff as NodeInspectSymbol, fi as failCause$3, fl as provide, fn as decodeEffect, fo as catchCause, fr as setAll, fs as option$1, ft as SocketError, fu as dedupe, g as OEmbed, ga as shutdown, gd as zero$1, gf as equals, gi as fromArray, gl as sync$1, gn as decodeUnknownOption, go as catchIf, gr as empty$9, gs as provide$2, gt as fromWebSocket, gu as ensure, h as NotesError, ha as offerUnsafe, hc as catchDone, hd as toMillis, hf as redact, hi as flattenIterable, hl as succeedContext, hn as decodeUnknownEffect, hr as value$2, hs as promise, hu as empty$11, i as FileType, ic as withTracerEnabled, id as isResult, if as contA, ii as catchTags$1, il as CurrentMemoMap, in as Tuple, io as andThen, ir as CurrentRedactedNames, is as matchCauseEffect, it as getStreamSchemas, iu as nativeTracer, ja as fromInput$2, jc as startsWith, jd as filter$5, jf as constVoid, ji as mergeAll$1, jl as _await, jn as makeFilter, jo as flatMapEager, jr as Literal$2, js as sleep, ju as isArrayNonEmpty, ka as runIn, kc as slice$2, kd as contains$1, kf as constTrue, ki as mapEffect, kn as isSchemaError$1, ko as filterOrFail, kr as Filter, ks as scoped, kt as ArraySchema, ku as head, l as GitHubReadme, la as collect, lc as fromStep, ld as format$2, lf as setStackTraceLimit, li as empty$10, ll as launch, ln as UndefinedOr, lo as asVoid, lr as merge$2, ls as onExit, lt as makeCollectorUnsafe, m as NoteJson, ma as offerAll, mc as toStep, md as seconds, mf as format$1, mi as flatMap$3, ml as succeed$2, mn as decodeTo, mo as catchDefect, mr as make$43, ms as orElseSucceed, mt as SocketOpenError, mu as drop, n as Capture, na as map$5, nc as withParentSpan, nd as fromOption$1, nf as Prototype, ni as FileSystem, nl as prettyErrors, nn as TaggedError$1, no as acquireRelease, nr as fromIterable$2, ns as mapError, nt as isWrapper, nu as externalSpan, o as FxStatus, oa as make$34, oc as addDelay, od as match$3, oi as concat, ol as effect, on as URLFromString, oo as annotateLogs, or as fromInput$1, os as matchEffect, ot as spanAttributes, ou as Error$1, p as NoteId, pa as offer, pd as parts, pf as toJson, pi as filter$6, pl as provideMerge, pn as decodeSync, pr as isRedacted, ps as orDie, pu as dedupeAdjacentWith, q as layerJson$1, qa as ipFromString, qd as orElse$2, qi as takeUntil, ql as fiberEnterUninterruptibleUnsafe, qn as encodeUnknownEffect, qo as log, qr as passthrough$1, qs as updateContext, qt as NonEmptyArray, qu as has$3, r as Extraction, rc as withSpan, rd as isFailure, rf as PipeInspectableProto, ri as catchReason$1, rl as squash, ro as all, rr as get$7, rt as ClientAbort$1, ru as make$39, s as GitHubComment, sa as makeUnsafe$6, sd as succeed, sf as assignProperty, si as decodeText, sl as effectContext, sn as Uint8Array$2, so as as$1, sr as fromRecordUnsafe, ss as never, st as spanName, su as TaggedClass, t as RpcContracts, ta as fromTransform, tc as withLogSpan, td as failVoid, tf as mapInput, ti as Path, tl as makeDieReason, tn as Struct, to as unixPathAddress, tr as has$4, ts as mapEager, tt as exitSchema, tu as Tracer, u as GitHubRepo, ua as end$1, uc as isSchedule, ud as fromInputUnsafe$1, uf as BaseProto, ui as ensuring, ul as merge$3, un as Union, uo as cached, ur as remove$3, us as onExitPrimitive, ut as CloseEvent, uu as appendAll, v as Reader, va as take, vc as camelToSnake, vd as Service, vf as hasProperty, vi as fromEffect, vl as Scope, vn as encodeSync, vo as catchTag, vr as isEmpty$1, vs as provideService, vu as filter$4, wa as getCurrent, wc as match$2, wd as getUnsafe, wf as isTagged, wi as limitBytes, wl as make$35, wn as isInt, wo as die$2, wr as toUint8Array$1, wt as InvalidUrlError, wu as fromIterable$1, x as layer$12, xa as unbounded, xc as isEmpty$2, xd as get$5, xf as isNotNullish, xi as fromQueue, xl as close, xn as fromJsonString, xo as context, xr as fromReadable, xs as repeat, xt as EncodeError, xu as findFirstIndex, y as TikTokPage, ya as takeAll, yc as endsWith, yd as add$1, yf as isIterable, yi as fromIterable, yl as addFinalizer, yn as encodeTo, yo as catchTags, yr as parseHeader, ys as provideServiceEffect, yt as DecodeError, yu as filterMap, z as succeed$5, za as makeRecordUnsafe, zd as getOrUndefined, zi as runCollect, zl as interrupt$1, zn as toJsonSchemaDocument, zo as fromOption, zr as mapOrSame, zs as timeout, zu as of } from "./contracts-CdQiWFv_.mjs";
2
+ import { $ as succeed$5, $a as interruptAs, $c as replaceAll, $d as get$6, $f as isNotNullish, $i as mapError$1, $l as make$38, $n as toJsonSchemaDocument, $o as failCause, $r as Objects, $s as scope, $u as fromIterable$1, A as SignInParams, Aa as makeUnsafe$8, Ac as zipWith, Ad as failVoid, Af as String$3, Ai as decodeText, Al as squash, An as decodeUnknownOption, Ao as annotateCurrentSpan, Ar as setAll, As as matchCauseEffectEager, At as fromWebSocket, Au as Tracer, Bc as catchDone, Bd as format$2, Bf as getStackTraceLimit, Bl as provide$1, Bn as isMinLength, Br as setUnsafe$2, Bs as promise, Bt as TransportError, Bu as contains$1, C as AuthError, Cc as whileLoop, Cd as keys, Cf as match$1, Ci as defaultFormatter, Cl as hasInterrupts, Cn as UndefinedOr, Co as isLoopback, Cr as fromInput$1, Cs as logWarning, Ct as makeCollectorUnsafe, Cu as forkUnsafe, D as OAuthTokenError, Dc as withParentSpan, Dd as headUnsafe, Df as some$1, Di as catchTags$1, Dl as isTimeoutError, Dn as decodeSync, Do as acquireRelease, Dr as merge$2, Ds as mapError, E as OAuthFlow, Ec as withLogSpan, Ed as empty$12, Ef as orElseSome, Ei as catchReason$1, El as isNoSuchElementError, En as decodeEffect, Eo as unixPathAddress, Er as isRedactedName, Es as mapEager, Et as SocketError, Eu as reportCauseUnsafe, F as runMain, Fa as make$39, Fc as isSchedule, Fd as isSuccess, Ff as PipeInspectableProto, Fi as failCause$3, Fl as effectContext, Fn as fromJsonString, Fo as cached, Fr as empty$9, Fs as onExitPrimitive, Ft as EncodeError, Fu as Error$1, G as Port, Ga as make$36, Gc as includes, Gd as parts, Gf as toJson, Gi as fromReadableStream, Gl as unwrap$3, Gn as makeFilter, Go as catch_, Gr as toUint8Array$1, Gs as raceFirst, Gu as ensure, H as layer$10, Ha as takeAll, Hc as Random$2, Hd as max$1, Hf as BaseProto, Hi as fromIterable, Hl as succeed$2, Hn as isSchema, Ho as catchReason, Hr as fromReadable, Hs as provideContext, Ht as Any, Hu as dedupeAdjacentWith, Ia as offer, Id as match$3, If as contA, Ii as filter$6, Il as effectDiscard, In as is$4, Io as callback, Ir as expireCookieUnsafe$1, Is as onInterrupt, It as HttpClientError, Iu as TaggedClass, J as String$2, Ja as await_, Jc as length, Jd as zero$1, Jf as equals, Ji as map$2, Jl as addFinalizerExit, Jn as optionalKey, Jr as ChildProcessSpawner, Js as retry, Jt as DateTimeUtcFromString, Ju as filterMap, K as Record, Ka as set$2, Kc as isEmpty$2, Kd as seconds, Kf as format$1, Ki as groupedWithin, Kl as Scope, Kn as mutable, Ko as context, Kr as fromWritable, Ks as repeat, Kt as Class$1, Ku as every, La as offerAll, Lc as passthrough, Ld as succeed, Lf as contE, Li as flatMap$3, Ll as launch, Ln as isGreaterThanOrEqualTo, Lo as catchCause, Lr as fromSetCookie, Ls as option$1, Lu as TaggedError, Ma as collect, Md as getSuccess, Mf as flip, Mi as empty$10, Ml as buildWithMemoMap, Mn as encodeSync, Mo as as$1, Mr as make$46, Ms as never, Mu as make$43, N as layer$12, Na as end$1, Nc as forever, Nd as isFailure, Nf as mapInput, Ni as ensuring, Nl as buildWithScope, Nn as encodeTo, No as asSome, Nr as value$2, Ns as onError, Nt as DecodeError, Nu as nativeTracer, O as OAuthTokenResponse, Oa as pipeTo, Oc as withSpan, Od as make$47, Of as toArray$1, Oi as catch_$1, Ol as makeDieReason, On as decodeTo, Oo as all$1, Or as remove$3, Ot as SocketOpenError, Ou as DisablePropagation, P as make$42, Pa as failCause$2, Pc as fromStep, Pd as isResult, Pf as Prototype, Pi as fail$2, Pl as effect, Pn as encodeUnknownEffect$1, Po as asVoid, Pr as stringOrRedacted, Ps as onExit, Pt as EmptyBodyError, Pu as random$1, Q as schema, Qa as interruptAllAs, Qc as replace$1, Qf as isNotNull, Qi as mapEffect, Ql as forkUnsafe$1, Qn as toEncoded$1, Qo as fail$1, Qr as Literal$2, Qs as runSync, Qt as Exit$1, Qu as flatMap$2, R as layer$11, Ra as offerUnsafe, Rc as spaced, Rd as try_$1, Ri as flattenIterable, Rl as merge$3, Rn as isInt, Rr as isEmpty$1, Rs as orDie, Rt as InvalidUrlError, S as RpcAuth, Sa as last$2, Sc as when$2, Sd as has$4, Sf as map$5, Si as toEpochMillis, Sl as hasDies, Sn as Uint8ArrayFromBase64, So as isLinkLocal, Sr as empty$8, Ss as logInfo, St as Collector, Su as fiberEnterUninterruptibleUnsafe, T as GitHubUser, Ta as map$4, Tc as withFiberSucceed, Td as toEntries, Tf as orElse$2, Ti as FileSystem, Tn as Unknown, To as isUnicast, Tr as get$7, Ts as map$1, Tu as onExitUnsafe, U as Crypto, Ua as publishUnsafe, Uc as camelToSnake, Ud as millis, Uf as Class, Ui as fromPubSub, Ul as succeedContext, Un as isSchemaError$1, Uo as catchTag, Ur as pipeThroughDuplex, Us as provideService, Ut as ArraySchema, Uu as drop, Va as take, Vd as fromInputUnsafe$1, Vf as setStackTraceLimit, Vi as fromEffect, Vl as provideMerge, Vn as isPattern, Vo as catchIf, Vr as toSetCookieHeaders, Vs as provide$3, Vt as isHttpClientError, Vu as dedupe, W as Array$1, Wa as unbounded, Wc as endsWith, Wd as minutes, Wf as NodeInspectSymbol, Wi as fromQueue, Wl as sync$1, Wn as make$45, Wo as catchTags, Wr as toArrayBuffer, Ws as provideServiceEffect, Wt as Boolean$2, Wu as empty$11, X as all, Xa as interrupt$2, Xc as padStart, Xd as Service, Xf as hasProperty, Xi as mapArray, Xl as closeUnsafe, Xn as toCodecJson, Xo as ensuring$1, Xr as Filter, Xs as runFork, Xt as Duration, Xu as findFirstIndex, Y as URL$1, Ya as getCurrent, Yc as match$2, Yd as Reference, Yf as hash, Yi as mapAccum, Yl as close, Yn as tag, Yo as die$2, Yr as Arrays, Yt as Defect, Yu as findFirst, Z as option, Za as interruptAll, Zc as repeat$1, Zd as add$1, Zf as isIterable, Zi as mapArrayEffect, Zl as fork, Zo as exit, Zr as FilterGroup, Zs as runForkWith, Zt as Error$2, _ as Organization, _a as tap$2, _c as uninterruptibleMask, _d as reverse, _f as getOrUndefined, _i as decode$3, _o as inetAddressFromIpString, _r as empty$13, _s as isEffect, _t as ClientAbort$1, _u as isSuccess$1, a as FxConversation, aa as pipeThroughChannel, ac as suspend, ad as headNonEmpty, af as merge$1, ai as isOptional, al as trimEnd, an as MutableJson, ao as mebibytes, ap as compose$1, ar as omit, as as forEach, at as RpcSerialization, au as TracerTimingEnabled, b as AUTH_URL, bc as useSpan, bd as take$1, bf as liftPredicate, bi as formatIso, bn as URLFromString, bo as ipv4ToOctets, br as set$4, bt as spanAttributes, bu as effectIsExit, c as GitHubIssue, ca as runCollect, cc as tapCause, cd as isReadonlyArrayNonEmpty, cf as exists, ci as optionalKey$1, cn as Null, co as DnsError, cp as constUndefined, cr as CurrentRedactedNames$1, cs as forkIn, ct as layerSchemaBinary, cu as into, d as ImageType, dc as timeoutOption, dd as lastNonEmpty, df as flatMapNullishOr, di as resolveIdentifier, dn as Record$1, do as nameServerFromInput, dp as dual, dr as redactUrl, ds as fromResult, dt as constEof, du as die, ea as mergeAll$1, ec as scoped, ed as get$8, ef as getOrUndefined$1, ei as PropertySignature, el as slice$2, en as Finite, eo as runIn, ep as isNotUndefined, er as toType, es as filterOrFail, et as unwrap$4, eu as makeUnsafe$4, f as Note, fa as runLast, fc as timeoutOrElse, fd as map$3, ff as flatten, fi as string, fl as IllegalArgumentError, fn as Redacted$1, fo as domainNameFromStringUnsafe, fp as flow, fr as setAll$1, fs as gen, fu as fail$3, g as OEmbed, ga as takeUntil, gc as uninterruptible, gd as reduce, gf as getOrNull, gi as transformOptional, gl as die$1, gn as TaggedError$1, go as formatUrlUnsafe, gr as has$3, gs as interruptible, gt as isWrapper, gu as isFailure$1, h as NotesError, ha as suspend$1, hc as try_, hd as prepend$2, hf as getOrElse, hi as transform$1, hl as combine, hn as Struct, ho as formatIp, hp as pipeArguments, hr as fromIterable$2, hs as interrupt, ht as exitSchema, hu as isExit, i as FileType, ia as orDie$1, ic as succeedNone, id as head, if as makeUnsafe$5, ii as isNever, il as trim, in as Literals, io as gibibytes, ip as or$1, ir as isSchemaError, is as fnUntraced, j as Verification, jc as addDelay, jd as fromOption$1, jf as combine$1, ji as die$3, jl as CurrentMemoMap, jn as encodeEffect, jo as annotateLogs, jr as isRedacted, js as matchEffect, ju as externalSpan, k as Session, ka as make$37, kc as withTracerEnabled, kd as fail, kf as Number$1, ki as concat, kl as prettyErrors, kn as decodeUnknownEffect, ko as andThen, kr as set$3, ks as matchCauseEffect, ku as ParentSpan, l as GitHubReadme, la as runForEach, lc as tapError$1, ld as join$1, lf as filter$4, li as replaceChecks, ll as Clock, ln as NullOr, lo as make$40, lp as constVoid, lr as empty$7, ls as forkScoped, lt as RequestId, lu as isDeferred, m as NoteJson, ma as succeed$3, mc as tryPromise, md as of, mf as fromUndefinedOr, mi as passthrough$1, ml as annotate, mn as StringFromUriComponent, mo as formatInet, mp as pipe, mr as unwrap$1, mt as ServerClient, mu as interrupt$1, n as Capture, na as mkUint8Array, nc as sleep, nd as getUnsafe$2, nf as getUnsafe$1, ni as Union$1, nl as startsWith, nn as Json, no as fromInput$2, np as isTagged, nr as withDecodingDefault, ns as flatMapEager, nu as CurrentLogAnnotations, o as FxStatus, oa as provideService$1, oc as sync, od as isArrayNonEmpty, of as all$2, oi as mapOrSame, ol as max$2, on as Never, oo as zero, op as constFalse, or as getReferenceKey, os as forever$1, ot as json$1, ou as _await, p as NoteId, pa as scan, pc as transposeOption, pf as fromNullishOr, pi as toEncoded, pl as StackTrace, pn as String$1, po as NetAddressError, pp as identity, pr as toString$2, ps as ignore$1, pt as constPong, pu as failCause$1, q as Redacted, qa as makeUnsafe$7, qc as isNonEmpty, qd as toMillis, qf as redact, qi as limitBytes, ql as addFinalizer, qn as optional$1, qo as contextWith, qr as make$44, qs as result$1, qt as DateTimeUtc, qu as filter$5, r as Extraction, ra as onEnd, rc as succeed$1, rd as groupBy, rf as make$41, ri as decodeTo$1, rl as toLowerCase, rn as Literal$1, ro as fromInputUnsafe, rp as isUndefined, rr as withDecodingDefaultKey, rs as fn$1, rt as withRun, ru as CurrentLogSpans, s as GitHubComment, sa as run$3, sc as tap$1, sd as isReadonlyArrayEmpty, sf as contains$2, si as null_, sl as parse$10, sn as NonEmptyArray, so as Dns, sp as constTrue, sr as encodeUnknownEffect, ss as forkChild, st as layerJson$1, su as doneUnsafe, t as RpcContracts, ta as mkString, tc as serviceOption, td as getSomes, tf as getOrUndefinedUnsafe, ti as Suspend, tl as split, tn as Int, to as badArgument, tp as isObject, tr as withConstructorDefault, ts as flatMap, tt as withDefault, tu as provide$2, u as GitHubRepo, ua as runForEachArray, uc as timeout, ud as last$1, uf as flatMap$1, ui as resolveDescription, ul as currentTimeMillis, un as Number$2, uo as makeRecordUnsafe, up as constant, ur as fromInput, us as fromOption, ut as ResponseDefectEncoded, uu as makeUnsafe$6, v as Reader, va as toReadableStream, vc as updateContext, vd as some$2, vf as isNone, vi as encode, vl as fail$4, vn as Tuple, vo as ipFromString, vr as fromIterable$3, vs as log, vt as getStreamSchemas, vu as succeed$4, w as CallbackParams, wa as fromTransform, wc as withFiber, wd as map$6, wf as none, wi as Path, wl as hasInterruptsOnly, wn as Union, wo as isPrivate, wr as fromRecordUnsafe, ws as makeSpanScoped, wt as CloseEvent, wu as makeSpanUnsafe, x as CurrentUser, xa as unwrap$2, xc as void_, xd as takeRight, xf as liftThrowable, xi as now, xl as fromReasons, xn as Uint8Array$2, xo as isInetAddressV6, xr as CurrentRedactedNames, xs as logFatal, xt as spanName, xu as fiberEnterInterruptibleUnsafe, y as TikTokPage, ya as toReadableStreamEffect, yc as updateService, yd as sort, yf as isSome, yi as encode$1, yl as filterInterruptors, yn as URL$2, yo as ipFromStringUnsafe, yr as get$9, ys as logDebug, yt as isStreamSchema, za as shutdown, zc as toStep, zd as days, zf as assignProperty, zi as fromArray, zl as mergeAll, zn as isMaxLength, zo as catchDefect, zr as parseHeader, zs as orElseSucceed, zt as StatusCodeError, zu as appendAll } from "./contracts-nyOWldn4.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";
@@ -117,9 +117,9 @@ const compose = /*#__PURE__*/ dual(2, (left, right) => (input) => {
117
117
  });
118
118
  //#endregion
119
119
  //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/MutableHashMap.js
120
- const TypeId$19 = "~effect/MutableHashMap";
120
+ const TypeId$20 = "~effect/MutableHashMap";
121
121
  const MutableHashMapProto = {
122
- [TypeId$19]: TypeId$19,
122
+ [TypeId$20]: TypeId$20,
123
123
  [Symbol.iterator]() {
124
124
  return this.backing[Symbol.iterator]();
125
125
  },
@@ -210,7 +210,7 @@ const empty$6 = () => {
210
210
  * @category getters
211
211
  * @since 2.0.0
212
212
  */
213
- const get$4 = /*#__PURE__*/ dual(2, (self, key) => {
213
+ const get$5 = /*#__PURE__*/ dual(2, (self, key) => {
214
214
  if (self.backing.has(key)) return some$1(self.backing.get(key));
215
215
  else if (isSimpleKey(key)) return none();
216
216
  const hash$2 = hash(key);
@@ -288,7 +288,7 @@ const getFromBucket = (self, bucket, key) => {
288
288
  * @category predicates
289
289
  * @since 2.0.0
290
290
  */
291
- const has$1 = /*#__PURE__*/ dual(2, (self, key) => isSome(get$4(self, key)));
291
+ const has$1 = /*#__PURE__*/ dual(2, (self, key) => isSome(get$5(self, key)));
292
292
  /**
293
293
  * Sets a key-value pair in the MutableHashMap, mutating the map in place.
294
294
  * If the key already exists, its value is updated.
@@ -329,7 +329,7 @@ const has$1 = /*#__PURE__*/ dual(2, (self, key) => isSome(get$4(self, key)));
329
329
  * @category mutations
330
330
  * @since 2.0.0
331
331
  */
332
- const set = /*#__PURE__*/ dual(3, (self, key, value) => {
332
+ const set$1 = /*#__PURE__*/ dual(3, (self, key, value) => {
333
333
  if (self.backing.has(key) || isSimpleKey(key)) {
334
334
  self.backing.set(key, value);
335
335
  return self;
@@ -414,8 +414,153 @@ const remove$2 = /*#__PURE__*/ dual(2, (self, key_) => {
414
414
  return self;
415
415
  });
416
416
  //#endregion
417
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Ref.js
418
+ /**
419
+ * Stores fiber-safe mutable state inside Effect programs.
420
+ *
421
+ * A `Ref<A>` holds one value and exposes reads, writes, and atomic
422
+ * transformations as effects, so state changes compose with Effect's
423
+ * concurrency model. This module includes constructors, safe and unsafe reads,
424
+ * set and get-and-set helpers, update and modify helpers, and conditional
425
+ * update variants that leave the value unchanged when an `Option.none` result
426
+ * is returned.
427
+ *
428
+ * @stability stable
429
+ * @since 2.0.0
430
+ */
431
+ const RefProto = {
432
+ ["~effect/Ref"]: { _A: identity },
433
+ ...PipeInspectableProto,
434
+ toJSON() {
435
+ return {
436
+ _id: "Ref",
437
+ ref: this.ref
438
+ };
439
+ }
440
+ };
441
+ /**
442
+ * Creates a new Ref with the specified initial value (unsafe version).
443
+ *
444
+ * **When to use**
445
+ *
446
+ * Use when you need immediate synchronous construction and can guarantee
447
+ * that creating the `Ref` outside of `Effect` is safe.
448
+ *
449
+ * **Gotchas**
450
+ *
451
+ * Prefer `Ref.make` for Effect-wrapped creation in Effect programs.
452
+ *
453
+ * **Example** (Creating a ref unsafely)
454
+ *
455
+ * ```ts import.meta.vitest
456
+ * import { Ref } from "effect"
457
+ *
458
+ * const counter = Ref.makeUnsafe(0)
459
+ * Ref.getUnsafe(counter) // => 0
460
+ * ```
461
+ *
462
+ * @stability stable
463
+ * @category constructors
464
+ * @since 4.0.0
465
+ */
466
+ const makeUnsafe$3 = (value) => {
467
+ const self = Object.create(RefProto);
468
+ self.ref = make$36(value);
469
+ return self;
470
+ };
471
+ /**
472
+ * Creates a new Ref with the specified initial value.
473
+ *
474
+ * **When to use**
475
+ *
476
+ * Use to create a `Ref` for shared mutable state inside an Effect program.
477
+ *
478
+ * **Example** (Creating a ref)
479
+ *
480
+ * ```ts import.meta.vitest
481
+ * import { Effect, Ref } from "effect"
482
+ *
483
+ * const program = Effect.gen(function*() {
484
+ * const ref = yield* Ref.make(42)
485
+ * return yield* Ref.get(ref)
486
+ * })
487
+ *
488
+ * await Effect.runPromise(program) // => 42
489
+ * ```
490
+ *
491
+ * @see {@link makeUnsafe} for synchronous construction outside Effect code
492
+ *
493
+ * @stability stable
494
+ * @category constructors
495
+ * @since 2.0.0
496
+ */
497
+ const make$35 = (value) => sync(() => makeUnsafe$3(value));
498
+ /**
499
+ * Gets the current value of the Ref.
500
+ *
501
+ * **When to use**
502
+ *
503
+ * Use to read the current `Ref` value without changing it.
504
+ *
505
+ * **Example** (Getting the current value)
506
+ *
507
+ * ```ts import.meta.vitest
508
+ * import { Effect, Ref } from "effect"
509
+ *
510
+ * const program = Effect.gen(function*() {
511
+ * const ref = yield* Ref.make(42)
512
+ * return yield* Ref.get(ref)
513
+ * })
514
+ *
515
+ * await Effect.runPromise(program) // => 42
516
+ * ```
517
+ *
518
+ * @see {@link set} for replacing the current value
519
+ *
520
+ * @stability stable
521
+ * @category getters
522
+ * @since 2.0.0
523
+ */
524
+ const get$4 = (self) => sync(() => self.ref.current);
525
+ /**
526
+ * Sets the value of the Ref to the specified value.
527
+ *
528
+ * **When to use**
529
+ *
530
+ * Use to replace the current `Ref` value with a known value.
531
+ *
532
+ * **Example** (Setting a value)
533
+ *
534
+ * ```ts import.meta.vitest
535
+ * import { Effect, Ref } from "effect"
536
+ *
537
+ * const program = Effect.gen(function*() {
538
+ * const ref = yield* Ref.make(0)
539
+ * yield* Ref.set(ref, 42)
540
+ * return yield* Ref.get(ref)
541
+ * })
542
+ *
543
+ * const program2 = Effect.gen(function*() {
544
+ * const ref = yield* Ref.make(0)
545
+ * yield* Ref.set(ref, 100)
546
+ * return yield* Ref.get(ref)
547
+ * })
548
+ *
549
+ * await Effect.runPromise(program) // => 42
550
+ * await Effect.runPromise(program2) // => 100
551
+ * ```
552
+ *
553
+ * @see {@link getAndSet} for setting while returning the previous value
554
+ * @see {@link setAndGet} for setting while returning the new value
555
+ *
556
+ * @stability stable
557
+ * @category mutations
558
+ * @since 2.0.0
559
+ */
560
+ const set = /*#__PURE__*/ dual(2, (self, value) => sync(() => set$2(self.ref, value)));
561
+ //#endregion
417
562
  //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/HttpBody.js
418
- const TypeId$18 = "~effect/http/HttpBody";
563
+ const TypeId$19 = "~effect/http/HttpBody";
419
564
  const HttpBodyErrorTypeId = "~effect/http/HttpBody/HttpBodyError";
420
565
  /**
421
566
  * Error produced while constructing an HTTP body from JSON or schema-encoded input.
@@ -433,10 +578,10 @@ var HttpBodyError = class extends (/*#__PURE__*/ TaggedError("HttpBodyError")) {
433
578
  */
434
579
  [HttpBodyErrorTypeId] = HttpBodyErrorTypeId;
435
580
  };
436
- var Proto$10 = class {
437
- [TypeId$18];
581
+ var Proto$11 = class {
582
+ [TypeId$19];
438
583
  constructor() {
439
- this[TypeId$18] = TypeId$18;
584
+ this[TypeId$19] = TypeId$19;
440
585
  }
441
586
  [NodeInspectSymbol]() {
442
587
  return this.toJSON();
@@ -452,7 +597,7 @@ var Proto$10 = class {
452
597
  * @category models
453
598
  * @since 4.0.0
454
599
  */
455
- var Empty$1 = class extends Proto$10 {
600
+ var Empty$1 = class extends Proto$11 {
456
601
  _tag = "Empty";
457
602
  toJSON() {
458
603
  return {
@@ -480,7 +625,7 @@ const empty$5 = /*#__PURE__*/ new Empty$1();
480
625
  * @category models
481
626
  * @since 4.0.0
482
627
  */
483
- var Raw = class extends Proto$10 {
628
+ var Raw = class extends Proto$11 {
484
629
  _tag = "Raw";
485
630
  body;
486
631
  contentType;
@@ -520,7 +665,7 @@ const raw$1 = (body, options) => new Raw(body, options?.contentType, options?.co
520
665
  * @category models
521
666
  * @since 4.0.0
522
667
  */
523
- var Uint8Array$1 = class extends Proto$10 {
668
+ var Uint8Array$1 = class extends Proto$11 {
524
669
  _tag = "Uint8Array";
525
670
  contentType;
526
671
  contentLength;
@@ -631,6 +776,14 @@ const jsonSchema = (schema, options) => {
631
776
  })), flatMap((body) => json(body, contentType)));
632
777
  };
633
778
  /**
779
+ * Creates an `application/x-www-form-urlencoded` HTTP body from `UrlParams`.
780
+ *
781
+ * @stability unstable
782
+ * @category constructors
783
+ * @since 4.0.0
784
+ */
785
+ const urlParams = (urlParams, contentType) => text$3(toString$2(fromInput(urlParams)), contentType ?? "application/x-www-form-urlencoded");
786
+ /**
634
787
  * HTTP body variant backed by Web `FormData`.
635
788
  *
636
789
  * **Details**
@@ -641,7 +794,7 @@ const jsonSchema = (schema, options) => {
641
794
  * @category models
642
795
  * @since 4.0.0
643
796
  */
644
- var FormData$1 = class extends Proto$10 {
797
+ var FormData$1 = class extends Proto$11 {
645
798
  _tag = "FormData";
646
799
  contentType = void 0;
647
800
  contentLength = void 0;
@@ -673,7 +826,7 @@ const formData = (body) => new FormData$1(body);
673
826
  * @category models
674
827
  * @since 4.0.0
675
828
  */
676
- var Stream = class extends Proto$10 {
829
+ var Stream = class extends Proto$11 {
677
830
  _tag = "Stream";
678
831
  stream;
679
832
  contentType;
@@ -763,12 +916,23 @@ const compressBody$1 = (body, algorithm, options) => {
763
916
  */
764
917
  const updateHeaders = (headers, body) => {
765
918
  if (body._tag === "Empty" || body._tag === "FormData") return remove$3(remove$3(headers, "content-type"), "content-length");
766
- headers = body.contentType === void 0 ? remove$3(headers, "content-type") : set$1(headers, "content-type", body.contentType);
767
- return body.contentLength === void 0 ? remove$3(headers, "content-length") : set$1(headers, "content-length", body.contentLength.toString());
919
+ headers = body.contentType === void 0 ? remove$3(headers, "content-type") : set$3(headers, "content-type", body.contentType);
920
+ return body.contentLength === void 0 ? remove$3(headers, "content-length") : set$3(headers, "content-length", body.contentLength.toString());
768
921
  };
769
922
  //#endregion
770
923
  //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/Url.js
771
924
  /**
925
+ * Parses and edits platform `URL` values.
926
+ *
927
+ * The HTTP modules use the standard `URL` object as their URL representation.
928
+ * This module adds safe parsing and helpers that return updated copies when
929
+ * changing credentials, host, path, protocol, query, or hash parts. Query
930
+ * strings can also be read or updated through `UrlParams`.
931
+ *
932
+ * @stability unstable
933
+ * @since 4.0.0
934
+ */
935
+ /**
772
936
  * Error returned when constructing a `URL` fails.
773
937
  *
774
938
  * @stability unstable
@@ -787,7 +951,7 @@ var UrlError = class extends (/*#__PURE__*/ TaggedError("UrlError")) {};
787
951
  * @category constructors
788
952
  * @since 4.0.0
789
953
  */
790
- const make$33 = (url, params, hash) => try_$1({
954
+ const make$34 = (url, params, hash) => try_$1({
791
955
  try: () => {
792
956
  const urlInstance = new URL(url, baseUrl());
793
957
  for (let i = 0; i < params.params.length; i++) {
@@ -802,9 +966,54 @@ const make$33 = (url, params, hash) => try_$1({
802
966
  const baseUrl = () => {
803
967
  if ("location" in globalThis && globalThis.location !== void 0 && globalThis.location.origin !== void 0 && globalThis.location.pathname !== void 0) return location.origin + location.pathname;
804
968
  };
969
+ /**
970
+ * Parses a URL string safely into a `URL` object, returning a `Result` type for
971
+ * error handling.
972
+ *
973
+ * **Details**
974
+ *
975
+ * This function converts a string into a `URL` object, enabling safe URL
976
+ * parsing with built-in error handling. If the string is invalid or fails to
977
+ * parse, this function does not throw an error; instead, it wraps the error in
978
+ * a `IllegalArgumentError` and returns it as the `Failure` value of an
979
+ * `Result`. The `Success` value contains the successfully parsed `URL`.
980
+ *
981
+ * An optional `base` parameter can be provided to resolve relative URLs. If
982
+ * specified, the function interprets the input `url` as relative to this
983
+ * `base`. This is especially useful when dealing with URLs that might not be
984
+ * fully qualified.
985
+ *
986
+ * **Example** (Parsing absolute and relative URLs)
987
+ *
988
+ * ```ts import.meta.vitest
989
+ * import { Result } from "effect"
990
+ * import { Url } from "effect/http"
991
+ *
992
+ * // Parse an absolute URL
993
+ * //
994
+ * // ┌─── Result<URL, IllegalArgumentError>
995
+ * // ▼
996
+ * const parsed = Url.fromString("https://example.com/path")
997
+ *
998
+ * Result.map(parsed, (url) => url.toString()) // => Result.succeed("https://example.com/path")
999
+ *
1000
+ * // Parse a relative URL with a base
1001
+ * const relativeParsed = Url.fromString("/relative-path", "https://example.com")
1002
+ *
1003
+ * Result.map(relativeParsed, (url) => url.toString()) // => Result.succeed("https://example.com/relative-path")
1004
+ * ```
1005
+ *
1006
+ * @stability unstable
1007
+ * @category constructors
1008
+ * @since 4.0.0
1009
+ */
1010
+ const fromString = (url, base) => try_$1({
1011
+ try: () => new URL(url, base),
1012
+ catch: () => new IllegalArgumentError(`Invalid URL: "${url}"${base !== void 0 ? ` with base "${base}"` : ""}`)
1013
+ });
805
1014
  //#endregion
806
1015
  //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/HttpClientRequest.js
807
- const TypeId$17 = "~effect/http/HttpClientRequest";
1016
+ const TypeId$18 = "~effect/http/HttpClientRequest";
808
1017
  /**
809
1018
  * Returns `true` when a value is an `HttpClientRequest`.
810
1019
  *
@@ -812,9 +1021,9 @@ const TypeId$17 = "~effect/http/HttpClientRequest";
812
1021
  * @category guards
813
1022
  * @since 4.0.0
814
1023
  */
815
- const isHttpClientRequest = (u) => hasProperty(u, TypeId$17);
816
- const Proto$9 = {
817
- [TypeId$17]: TypeId$17,
1024
+ const isHttpClientRequest = (u) => hasProperty(u, TypeId$18);
1025
+ const Proto$10 = {
1026
+ [TypeId$18]: TypeId$18,
818
1027
  ...BaseProto,
819
1028
  toJSON() {
820
1029
  return {
@@ -839,7 +1048,7 @@ const Proto$9 = {
839
1048
  * @since 4.0.0
840
1049
  */
841
1050
  function makeWith$1(method, url, urlParams, hash, headers, body) {
842
- const self = Object.create(Proto$9);
1051
+ const self = Object.create(Proto$10);
843
1052
  self.method = method;
844
1053
  self.url = url;
845
1054
  self.urlParams = urlParams;
@@ -863,7 +1072,7 @@ const empty$4 = /*#__PURE__*/ makeWith$1("GET", "", empty$7, /*#__PURE__*/ none(
863
1072
  * @category constructors
864
1073
  * @since 4.0.0
865
1074
  */
866
- const make$32 = (method) => (url, options) => modify(empty$4, {
1075
+ const make$33 = (method) => (url, options) => modify(empty$4, {
867
1076
  method,
868
1077
  url,
869
1078
  ...options ?? void 0
@@ -875,7 +1084,7 @@ const make$32 = (method) => (url, options) => modify(empty$4, {
875
1084
  * @category constructors
876
1085
  * @since 4.0.0
877
1086
  */
878
- const get$3 = /*#__PURE__*/ make$32("GET");
1087
+ const get$3 = /*#__PURE__*/ make$33("GET");
879
1088
  /**
880
1089
  * Creates a `POST` request for the specified URL.
881
1090
  *
@@ -883,8 +1092,8 @@ const get$3 = /*#__PURE__*/ make$32("GET");
883
1092
  * @category constructors
884
1093
  * @since 4.0.0
885
1094
  */
886
- const post = /*#__PURE__*/ make$32("POST");
887
- const del = /*#__PURE__*/ make$32("DELETE");
1095
+ const post = /*#__PURE__*/ make$33("POST");
1096
+ const del = /*#__PURE__*/ make$33("DELETE");
888
1097
  /**
889
1098
  * Applies request options to an `HttpClientRequest`, returning a new request.
890
1099
  *
@@ -919,7 +1128,7 @@ const setMethod = /*#__PURE__*/ dual(2, (self, method) => makeWith$1(method, sel
919
1128
  * @category combinators
920
1129
  * @since 4.0.0
921
1130
  */
922
- const setHeader$1 = /*#__PURE__*/ dual(3, (self, key, value) => makeWith$1(self.method, self.url, self.urlParams, self.hash, set$1(self.headers, key, value), self.body));
1131
+ const setHeader$1 = /*#__PURE__*/ dual(3, (self, key, value) => makeWith$1(self.method, self.url, self.urlParams, self.hash, set$3(self.headers, key, value), self.body));
923
1132
  /**
924
1133
  * Sets multiple request headers from an input collection, replacing existing values with matching names.
925
1134
  *
@@ -929,6 +1138,14 @@ const setHeader$1 = /*#__PURE__*/ dual(3, (self, key, value) => makeWith$1(self.
929
1138
  */
930
1139
  const setHeaders$1 = /*#__PURE__*/ dual(2, (self, input) => makeWith$1(self.method, self.url, self.urlParams, self.hash, setAll(self.headers, input), self.body));
931
1140
  /**
1141
+ * Sets the `Authorization` header using a bearer token.
1142
+ *
1143
+ * @stability unstable
1144
+ * @category combinators
1145
+ * @since 4.0.0
1146
+ */
1147
+ const bearerToken = /*#__PURE__*/ dual(2, (self, token) => setHeader$1(self, "Authorization", `Bearer ${stringOrRedacted(token)}`));
1148
+ /**
932
1149
  * Sets the `Accept` header to the specified media type.
933
1150
  *
934
1151
  * @stability unstable
@@ -1055,6 +1272,14 @@ const compressBody = /*#__PURE__*/ dual((args) => isHttpClientRequest(args[0]),
1055
1272
  */
1056
1273
  const bodyJsonUnsafe = /*#__PURE__*/ dual(2, (self, body) => setBody$1(self, jsonUnsafe(body)));
1057
1274
  /**
1275
+ * Sets an `application/x-www-form-urlencoded` request body from URL parameter input.
1276
+ *
1277
+ * @stability unstable
1278
+ * @category combinators
1279
+ * @since 4.0.0
1280
+ */
1281
+ const bodyUrlParams = /*#__PURE__*/ dual(2, (self, input) => setBody$1(self, urlParams(fromInput(input))));
1282
+ /**
1058
1283
  * Sets a `FormData` request body.
1059
1284
  *
1060
1285
  * @stability unstable
@@ -1070,7 +1295,7 @@ const bodyFormData = /*#__PURE__*/ dual(2, (self, body) => setBody$1(self, formD
1070
1295
  * @since 4.0.0
1071
1296
  */
1072
1297
  function toUrl(self) {
1073
- const r = make$33(self.url, self.urlParams, getOrUndefined(self.hash));
1298
+ const r = make$34(self.url, self.urlParams, getOrUndefined(self.hash));
1074
1299
  if (isSuccess(r)) return some$1(r.success);
1075
1300
  return none();
1076
1301
  }
@@ -1083,7 +1308,7 @@ function toUrl(self) {
1083
1308
  * @category type IDs
1084
1309
  * @since 4.0.0
1085
1310
  */
1086
- const TypeId$16 = "~effect/http/HttpIncomingMessage";
1311
+ const TypeId$17 = "~effect/http/HttpIncomingMessage";
1087
1312
  /**
1088
1313
  * Creates a decoder that reads an incoming message's JSON body and decodes it with the supplied schema.
1089
1314
  *
@@ -1149,7 +1374,7 @@ const inspect = (self, that) => {
1149
1374
  * @category type IDs
1150
1375
  * @since 4.0.0
1151
1376
  */
1152
- const TypeId$15 = "~effect/http/HttpClientResponse";
1377
+ const TypeId$16 = "~effect/http/HttpClientResponse";
1153
1378
  /**
1154
1379
  * Wraps a Web `Response` and its original `HttpClientRequest` as an `HttpClientResponse`.
1155
1380
  *
@@ -1187,16 +1412,16 @@ const filterStatusOk$1 = (self) => self.status >= 200 && self.status < 300 ? suc
1187
1412
  description: "non 2xx status code"
1188
1413
  }) }));
1189
1414
  var WebHttpClientResponse = class extends Class {
1415
+ [TypeId$17];
1190
1416
  [TypeId$16];
1191
- [TypeId$15];
1192
1417
  request;
1193
1418
  source;
1194
1419
  constructor(request, source) {
1195
1420
  super();
1196
1421
  this.request = request;
1197
1422
  this.source = source;
1423
+ this[TypeId$17] = TypeId$17;
1198
1424
  this[TypeId$16] = TypeId$16;
1199
- this[TypeId$15] = TypeId$15;
1200
1425
  }
1201
1426
  toJSON() {
1202
1427
  return inspect(this, {
@@ -1459,7 +1684,7 @@ const addHeaderAttributes = (span, phase, headers, filter, redactedNames) => {
1459
1684
  };
1460
1685
  //#endregion
1461
1686
  //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/HttpClient.js
1462
- const TypeId$14 = "~effect/http/HttpClient";
1687
+ const TypeId$15 = "~effect/http/HttpClient";
1463
1688
  /**
1464
1689
  * Service tag for the default outgoing HTTP client service.
1465
1690
  *
@@ -1510,7 +1735,7 @@ const filterStatusOk = /*#__PURE__*/ transformResponse(/*#__PURE__*/ flatMap(fil
1510
1735
  * @since 4.0.0
1511
1736
  */
1512
1737
  const makeWith = (postprocess, preprocess) => {
1513
- const self = Object.create(Proto$8);
1738
+ const self = Object.create(Proto$9);
1514
1739
  self.preprocess = preprocess;
1515
1740
  self.postprocess = postprocess;
1516
1741
  self.execute = function(request) {
@@ -1518,8 +1743,8 @@ const makeWith = (postprocess, preprocess) => {
1518
1743
  };
1519
1744
  return self;
1520
1745
  };
1521
- const Proto$8 = {
1522
- [TypeId$14]: TypeId$14,
1746
+ const Proto$9 = {
1747
+ [TypeId$15]: TypeId$15,
1523
1748
  pipe() {
1524
1749
  return pipeArguments(this, arguments);
1525
1750
  },
@@ -1528,7 +1753,7 @@ const Proto$8 = {
1528
1753
  return { _id: "effect/HttpClient" };
1529
1754
  },
1530
1755
  .../*#__PURE__*/ Object.fromEntries(/*#__PURE__*/ allShort.map(([fullMethod, method]) => [method, function(url, options) {
1531
- return this.execute(make$32(fullMethod)(url, options));
1756
+ return this.execute(make$33(fullMethod)(url, options));
1532
1757
  }]))
1533
1758
  };
1534
1759
  /**
@@ -1542,10 +1767,10 @@ const Proto$8 = {
1542
1767
  * @category constructors
1543
1768
  * @since 4.0.0
1544
1769
  */
1545
- const make$31 = (f) => makeWith((effect) => flatMap(effect, (request) => withFiber((fiber) => {
1770
+ const make$32 = (f) => makeWith((effect) => flatMap(effect, (request) => withFiber((fiber) => {
1546
1771
  const scopedController = scopedRequests.get(request);
1547
1772
  const controller = scopedController ?? new AbortController();
1548
- const urlResult = make$33(request.url, request.urlParams, getOrUndefined(request.hash));
1773
+ const urlResult = make$34(request.url, request.urlParams, getOrUndefined(request.hash));
1549
1774
  if (isFailure(urlResult)) return fail$1(new HttpClientError({ reason: new InvalidUrlError({
1550
1775
  request,
1551
1776
  cause: urlResult.failure
@@ -1772,8 +1997,8 @@ var InterruptibleResponse = class {
1772
1997
  this.original = original;
1773
1998
  this.controller = controller;
1774
1999
  }
1775
- [TypeId$15] = TypeId$15;
1776
2000
  [TypeId$16] = TypeId$16;
2001
+ [TypeId$17] = TypeId$17;
1777
2002
  applyInterrupt(effect) {
1778
2003
  return suspend(() => {
1779
2004
  responseRegistry.unregister(this.original);
@@ -1924,7 +2149,7 @@ const isCleanSingleTrailingParam = (path) => CLEAN_SINGLE_PARAM_REGEXP.test(path
1924
2149
  /**
1925
2150
  * @internal
1926
2151
  */
1927
- const make$30 = (options = {}) => new RouterImpl(options);
2152
+ const make$31 = (options = {}) => new RouterImpl(options);
1928
2153
  var RouterImpl = class {
1929
2154
  constructor(options = {}) {
1930
2155
  this.options = {
@@ -2543,7 +2768,7 @@ const httpMethods = [
2543
2768
  * @category constructors
2544
2769
  * @since 4.0.0
2545
2770
  */
2546
- const make$29 = make$30;
2771
+ const make$30 = make$31;
2547
2772
  //#endregion
2548
2773
  //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/Etag.js
2549
2774
  /**
@@ -2685,14 +2910,14 @@ const layerWeak = /*#__PURE__*/ succeed$2(Generator)({
2685
2910
  const ignore = "~effect/ErrorReporter/ignore";
2686
2911
  //#endregion
2687
2912
  //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/internal/headers.js
2688
- const Proto$7 = /*#__PURE__*/ Object.getPrototypeOf(empty$8);
2913
+ const Proto$8 = /*#__PURE__*/ Object.getPrototypeOf(empty$8);
2689
2914
  /**
2690
2915
  * @internal
2691
2916
  */
2692
- const emptyMutableUnsafe = () => Object.create(Proto$7);
2917
+ const emptyMutableUnsafe = () => Object.create(Proto$8);
2693
2918
  //#endregion
2694
2919
  //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/HttpServerResponse.js
2695
- const TypeId$13 = "~effect/http/HttpServerResponse";
2920
+ const TypeId$14 = "~effect/http/HttpServerResponse";
2696
2921
  /**
2697
2922
  * Returns `true` when the supplied value is an `HttpServerResponse`.
2698
2923
  *
@@ -2700,7 +2925,7 @@ const TypeId$13 = "~effect/http/HttpServerResponse";
2700
2925
  * @category guards
2701
2926
  * @since 4.0.0
2702
2927
  */
2703
- const isHttpServerResponse = (u) => hasProperty(u, TypeId$13);
2928
+ const isHttpServerResponse = (u) => hasProperty(u, TypeId$14);
2704
2929
  /**
2705
2930
  * Creates an empty HTTP response.
2706
2931
  *
@@ -2719,6 +2944,27 @@ const empty$3 = (options) => makeResponse$1({
2719
2944
  cookies: options?.cookies
2720
2945
  });
2721
2946
  /**
2947
+ * Creates a redirect response with a `Location` header.
2948
+ *
2949
+ * **Details**
2950
+ *
2951
+ * The default status is `302`; custom headers are merged with the generated
2952
+ * `Location` header.
2953
+ *
2954
+ * @stability unstable
2955
+ * @category constructors
2956
+ * @since 4.0.0
2957
+ */
2958
+ const redirect = (location, options) => {
2959
+ const headers = fromRecordUnsafe({ location: location.toString() });
2960
+ return makeResponse$1({
2961
+ status: options?.status ?? 302,
2962
+ statusText: options?.statusText,
2963
+ headers: options?.headers ? merge$2(headers, fromInput$1(options.headers)) : headers,
2964
+ cookies: options?.cookies ?? empty$9
2965
+ });
2966
+ };
2967
+ /**
2722
2968
  * Creates an HTTP response whose body is a `Uint8Array`.
2723
2969
  *
2724
2970
  * @stability unstable
@@ -2834,7 +3080,7 @@ const stream$1 = (body, options) => {
2834
3080
  * @category combinators
2835
3081
  * @since 4.0.0
2836
3082
  */
2837
- const setHeader = /*#__PURE__*/ dual(3, (self, key, value) => makeResponse$1(self, set$1(self.headers, key, value)));
3083
+ const setHeader = /*#__PURE__*/ dual(3, (self, key, value) => makeResponse$1(self, set$3(self.headers, key, value)));
2838
3084
  /**
2839
3085
  * Returns a response with the specified header removed.
2840
3086
  *
@@ -2855,6 +3101,40 @@ const removeHeader = /*#__PURE__*/ dual(2, (self, key) => makeResponse$1({
2855
3101
  */
2856
3102
  const setHeaders = /*#__PURE__*/ dual(2, (self, input) => makeResponse$1(self, setAll(self.headers, input)));
2857
3103
  /**
3104
+ * Sets a cookie on an `HttpServerResponse`, throwing if the cookie cannot be
3105
+ * encoded.
3106
+ *
3107
+ * **When to use**
3108
+ *
3109
+ * Use when you need to set one trusted cookie and want encoding failures to
3110
+ * throw instead of being represented as `CookiesError` failures.
3111
+ *
3112
+ * @stability unstable
3113
+ * @category combinators
3114
+ * @since 4.0.0
3115
+ */
3116
+ const setCookieUnsafe = /*#__PURE__*/ dual((args) => isHttpServerResponse(args[0]), (self, name, value, options) => makeResponse$1({
3117
+ ...self,
3118
+ cookies: setUnsafe$2(self.cookies, name, value, options)
3119
+ }));
3120
+ /**
3121
+ * Sets an expired cookie on an `HttpServerResponse`, throwing if the expiration cookie
3122
+ * cannot be encoded.
3123
+ *
3124
+ * **When to use**
3125
+ *
3126
+ * Use when you need to expire one trusted cookie and want encoding failures to
3127
+ * throw instead of being represented as `CookiesError` failures.
3128
+ *
3129
+ * @stability unstable
3130
+ * @category combinators
3131
+ * @since 4.0.0
3132
+ */
3133
+ const expireCookieUnsafe = /*#__PURE__*/ dual((args) => isHttpServerResponse(args[0]), (self, name, options) => makeResponse$1({
3134
+ ...self,
3135
+ cookies: expireCookieUnsafe$1(self.cookies, name, options)
3136
+ }));
3137
+ /**
2858
3138
  * Replaces the body of an `HttpServerResponse`.
2859
3139
  *
2860
3140
  * **Details**
@@ -2870,9 +3150,9 @@ const setBody = /*#__PURE__*/ dual(2, (self, body) => makeResponse$1({
2870
3150
  ...self,
2871
3151
  body
2872
3152
  }, updateHeaders(self.headers, body)));
2873
- const Proto$6 = {
3153
+ const Proto$7 = {
2874
3154
  ...PipeInspectableProto,
2875
- [TypeId$13]: TypeId$13,
3155
+ [TypeId$14]: TypeId$14,
2876
3156
  [ignore]: true,
2877
3157
  toJSON() {
2878
3158
  return {
@@ -2886,7 +3166,7 @@ const Proto$6 = {
2886
3166
  }
2887
3167
  };
2888
3168
  const makeResponse$1 = (options, ownedHeaders) => {
2889
- const self = Object.create(Proto$6);
3169
+ const self = Object.create(Proto$7);
2890
3170
  self.status = options.status;
2891
3171
  self.statusText = options.statusText;
2892
3172
  self.cookies = options.cookies ?? empty$9;
@@ -3504,7 +3784,7 @@ var HttpPlatform = class extends (/*#__PURE__*/ Service()("effect/http/HttpPlatf
3504
3784
  * @category constructors
3505
3785
  * @since 4.0.0
3506
3786
  */
3507
- const make$28 = /*#__PURE__*/ fnUntraced(function* (impl) {
3787
+ const make$29 = /*#__PURE__*/ fnUntraced(function* (impl) {
3508
3788
  const fs = yield* FileSystem;
3509
3789
  const etagGen = yield* Generator;
3510
3790
  return HttpPlatform.of({
@@ -3521,7 +3801,7 @@ const make$28 = /*#__PURE__*/ fnUntraced(function* (impl) {
3521
3801
  const limit = bytesToRead === void 0 ? void 0 : offset + contentLength;
3522
3802
  const start = yield* fileResponseNumber(offset, "offset");
3523
3803
  const end = limit === void 0 ? void 0 : yield* fileResponseNumber(limit, "end");
3524
- const headers = set$1(optionHeaders(options), "etag", toString$1(etag));
3804
+ const headers = set$3(optionHeaders(options), "etag", toString$1(etag));
3525
3805
  if (isSome(info.mtime)) headers["last-modified"] = info.mtime.value.toUTCString();
3526
3806
  return impl.fileResponse(path, options?.status ?? 200, options?.statusText, headers, start, end, contentLength);
3527
3807
  }),
@@ -3538,7 +3818,7 @@ const make$28 = /*#__PURE__*/ fnUntraced(function* (impl) {
3538
3818
  });
3539
3819
  const optionHeaders = (options) => {
3540
3820
  const headers = options?.headers ? fromInput$1(options.headers) : empty$8;
3541
- return options?.contentType ? set$1(headers, "content-type", options.contentType) : headers;
3821
+ return options?.contentType ? set$3(headers, "content-type", options.contentType) : headers;
3542
3822
  };
3543
3823
  const fileResponseSize = (input, field) => {
3544
3824
  const size = fromInput$2(input);
@@ -3656,7 +3936,7 @@ const toResponseOrElseDefect = (u, orElse) => {
3656
3936
  * @stability unstable
3657
3937
  * @since 4.0.0
3658
3938
  */
3659
- const TypeId$12 = "~effect/http/HttpServerError";
3939
+ const TypeId$13 = "~effect/http/HttpServerError";
3660
3940
  /**
3661
3941
  * Tagged error for failures that occur while handling an HTTP server request.
3662
3942
  *
@@ -3678,7 +3958,7 @@ var HttpServerError = class extends (/*#__PURE__*/ TaggedError("HttpServerError"
3678
3958
  });
3679
3959
  else super(props);
3680
3960
  }
3681
- [TypeId$12] = TypeId$12;
3961
+ [TypeId$13] = TypeId$13;
3682
3962
  stack = `${this.name}: ${this.message}`;
3683
3963
  get request() {
3684
3964
  return this.reason.request;
@@ -3992,7 +4272,7 @@ const constValueChars = /*#__PURE__*/ new Uint8Array(256);
3992
4272
  constValueChars[9] = 1;
3993
4273
  for (let i = 32; i <= 126; i++) constValueChars[i] = 1;
3994
4274
  for (let i = 128; i <= 255; i++) constValueChars[i] = 1;
3995
- function make$27() {
4275
+ function make$28() {
3996
4276
  const decoder = new TextDecoder();
3997
4277
  const state = {
3998
4278
  state: State$4.key,
@@ -4169,7 +4449,7 @@ function makeState(needle_) {
4169
4449
  matchIndex: 0
4170
4450
  };
4171
4451
  }
4172
- function make$26(needle, callback, seed, minimumChunkLength) {
4452
+ function make$27(needle, callback, seed, minimumChunkLength) {
4173
4453
  const state = makeState(needle);
4174
4454
  const minChunkLength = minimumChunkLength ?? state.needleLength;
4175
4455
  if (seed !== void 0) {
@@ -4281,7 +4561,7 @@ function parseBoundary(headers) {
4281
4561
  }
4282
4562
  function noopOnChunk(_chunk) {}
4283
4563
  const toLimit = (input) => input === Infinity ? Infinity : Number(fromInputUnsafe(input));
4284
- function make$25({ headers, onFile: onPart, onField, onError, onDone, isFile = defaultIsFile$1, maxParts = Infinity, maxTotalSize: maxTotalSizeInput = Infinity, maxPartSize: maxPartSizeInput = Infinity, maxFieldSize: maxFieldSizeInput = 1048576 }) {
4564
+ function make$26({ headers, onFile: onPart, onField, onError, onDone, isFile = defaultIsFile$1, maxParts = Infinity, maxTotalSize: maxTotalSizeInput = Infinity, maxPartSize: maxPartSizeInput = Infinity, maxFieldSize: maxFieldSizeInput = 1048576 }) {
4285
4565
  const maxTotalSize = toLimit(maxTotalSizeInput);
4286
4566
  const maxPartSize = toLimit(maxPartSizeInput);
4287
4567
  const maxFieldSize = toLimit(maxFieldSizeInput);
@@ -4318,8 +4598,8 @@ function make$25({ headers, onFile: onPart, onField, onError, onDone, isFile = d
4318
4598
  if (state.state === State$3.body && state.isFile) state.onChunk(null);
4319
4599
  onError(error);
4320
4600
  }
4321
- const headerParser = make$27();
4322
- const split = make$26(`\r\n--${boundary}`, function(index, chunk) {
4601
+ const headerParser = make$28();
4602
+ const split = make$27(`\r\n--${boundary}`, function(index, chunk) {
4323
4603
  if (state.stopped) return;
4324
4604
  if (index === 0) {
4325
4605
  skipBody();
@@ -4451,7 +4731,7 @@ function decodeField$1(info, value) {
4451
4731
  * @category constructors
4452
4732
  * @since 4.0.0
4453
4733
  */
4454
- const make$24 = make$25;
4734
+ const make$25 = make$26;
4455
4735
  /**
4456
4736
  * Determines whether a multipart part should be treated as a file.
4457
4737
  *
@@ -4490,7 +4770,7 @@ const decodeField = decodeField$1;
4490
4770
  * @category type IDs
4491
4771
  * @since 4.0.0
4492
4772
  */
4493
- const TypeId$11 = "~effect/http/Multipart";
4773
+ const TypeId$12 = "~effect/http/Multipart";
4494
4774
  const MultipartErrorTypeId = "~effect/http/Multipart/MultipartError";
4495
4775
  const toMultipartError = (cause) => isMultipartError(cause) ? cause : MultipartError.fromReason("InternalError", cause);
4496
4776
  /**
@@ -4594,7 +4874,7 @@ const isMultipartError = (u) => hasProperty(u, MultipartErrorTypeId);
4594
4874
  * @since 4.0.0
4595
4875
  */
4596
4876
  const makeConfig = (headers) => withFiber((fiber) => {
4597
- const mimeTypes = get$5(fiber.context, FieldMimeTypes);
4877
+ const mimeTypes = get$6(fiber.context, FieldMimeTypes);
4598
4878
  return succeed$1({
4599
4879
  headers,
4600
4880
  maxParts: fiber.getRef(MaxParts),
@@ -4605,10 +4885,10 @@ const makeConfig = (headers) => withFiber((fiber) => {
4605
4885
  });
4606
4886
  });
4607
4887
  var PartBase$1 = class extends Class {
4608
- [TypeId$11];
4888
+ [TypeId$12];
4609
4889
  constructor() {
4610
4890
  super();
4611
- this[TypeId$11] = TypeId$11;
4891
+ this[TypeId$12] = TypeId$12;
4612
4892
  }
4613
4893
  };
4614
4894
  const defaultWriteFile = (path, file) => flatMap(FileSystem, (fs) => mapError(run$3(file.content, fs.sink(path)), toMultipartError));
@@ -4749,7 +5029,7 @@ const FieldMimeTypes = /*#__PURE__*/ Reference("effect/http/Multipart/FieldMimeT
4749
5029
  * @category type IDs
4750
5030
  * @since 4.0.0
4751
5031
  */
4752
- const TypeId$10 = "~effect/http/HttpServerRequest";
5032
+ const TypeId$11 = "~effect/http/HttpServerRequest";
4753
5033
  /**
4754
5034
  * Service tag for the active server-side HTTP request.
4755
5035
  *
@@ -4782,6 +5062,17 @@ const HttpServerRequest = /*#__PURE__*/ Service("effect/http/HttpServerRequest")
4782
5062
  */
4783
5063
  var ParsedSearchParams = class extends (/*#__PURE__*/ Service()("effect/http/ParsedSearchParams")) {};
4784
5064
  /**
5065
+ * Decodes a schema from the parsed search parameters of the current request.
5066
+ *
5067
+ * @stability unstable
5068
+ * @category schemas
5069
+ * @since 4.0.0
5070
+ */
5071
+ const schemaSearchParams = (schema, options) => {
5072
+ const parse = decodeUnknownEffect(schema);
5073
+ return flatMap(ParsedSearchParams, (params) => parse(params, options));
5074
+ };
5075
+ /**
4785
5076
  * Reads the current request body as JSON and decodes it with the supplied schema.
4786
5077
  *
4787
5078
  * **Details**
@@ -4834,7 +5125,7 @@ const requestPreResponseHandlers = /*#__PURE__*/ new WeakMap();
4834
5125
  * @category constructors
4835
5126
  * @since 4.0.0
4836
5127
  */
4837
- const make$23 = (middleware) => middleware;
5128
+ const make$24 = (middleware) => middleware;
4838
5129
  const loggerDisabledRequests = /*#__PURE__*/ new WeakSet();
4839
5130
  const stripSearchAndHash = (url) => {
4840
5131
  const queryIndex = url.indexOf("?");
@@ -4851,7 +5142,7 @@ const stripSearchAndHash = (url) => {
4851
5142
  * @since 4.0.0
4852
5143
  */
4853
5144
  const withLoggerDisabled = (self) => withFiber((fiber) => {
4854
- const request = getUnsafe(fiber.context, HttpServerRequest);
5145
+ const request = getUnsafe$1(fiber.context, HttpServerRequest);
4855
5146
  loggerDisabledRequests.add(request.source);
4856
5147
  return self;
4857
5148
  });
@@ -4895,8 +5186,8 @@ const TracerHeaderFilter = /*#__PURE__*/ Reference("effect/http/HttpMiddleware/T
4895
5186
  * @category logging
4896
5187
  * @since 4.0.0
4897
5188
  */
4898
- const logger$1 = /*#__PURE__*/ make$23((httpApp) => withFiber((fiber) => {
4899
- const request = getUnsafe(fiber.context, HttpServerRequest);
5189
+ const logger$1 = /*#__PURE__*/ make$24((httpApp) => withFiber((fiber) => {
5190
+ const request = getUnsafe$1(fiber.context, HttpServerRequest);
4900
5191
  const path = stripSearchAndHash(request.url);
4901
5192
  return withLogSpan(flatMap(exit(httpApp), (exit) => {
4902
5193
  if (loggerDisabledRequests.has(request.source)) return exit;
@@ -4940,8 +5231,8 @@ const responseSpanExit = (request, response) => {
4940
5231
  * @category tracing
4941
5232
  * @since 4.0.0
4942
5233
  */
4943
- const tracer = /*#__PURE__*/ make$23((httpApp) => withFiber((fiber) => {
4944
- const request = getUnsafe(fiber.context, HttpServerRequest);
5234
+ const tracer = /*#__PURE__*/ make$24((httpApp) => withFiber((fiber) => {
5235
+ const request = getUnsafe$1(fiber.context, HttpServerRequest);
4945
5236
  if (isTracerDisabledUnsafe(fiber, request)) return httpApp;
4946
5237
  const nameGenerator = fiber.getRef(SpanNameGenerator);
4947
5238
  const span = makeSpanUnsafe(fiber, nameGenerator(request), {
@@ -5082,8 +5373,8 @@ const toHandled = (self, handleResponse, middleware) => {
5082
5373
  }
5083
5374
  return withFiber((fiber) => {
5084
5375
  fiberEnterUninterruptibleUnsafe(fiber);
5085
- const scope = makeUnsafe$2();
5086
- const frame = new RequestFrame(scope, fiber.context, getUnsafe(fiber.context, HttpServerRequest));
5376
+ const scope = makeUnsafe$4();
5377
+ const frame = new RequestFrame(scope, fiber.context, getUnsafe$1(fiber.context, HttpServerRequest));
5087
5378
  fiber.setContext(add$1(frame.prev, Scope, scope));
5088
5379
  const currentTracer = fiber.cache.tracer;
5089
5380
  if (middleware === void 0 && (currentTracer === void 0 || currentTracer === nativeTracer || isTracerDisabledUnsafe(fiber, frame.request))) {
@@ -5130,7 +5421,7 @@ var HttpServer = class extends (/*#__PURE__*/ Service()("effect/http/HttpServer"
5130
5421
  * @category constructors
5131
5422
  * @since 4.0.0
5132
5423
  */
5133
- const make$22 = (options) => options;
5424
+ const make$23 = (options) => options;
5134
5425
  /**
5135
5426
  * Creates a layer that starts serving an HTTP response effect with the current
5136
5427
  * `HttpServer`.
@@ -5198,7 +5489,7 @@ const withLogAddress = (layer) => effectDiscard(logAddress).pipe(provideMerge(la
5198
5489
  * @stability unstable
5199
5490
  * @since 4.0.0
5200
5491
  */
5201
- const TypeId$9 = "~effect/http/HttpRouter";
5492
+ const TypeId$10 = "~effect/http/HttpRouter";
5202
5493
  /**
5203
5494
  * Service tag for the HTTP router used while constructing an HTTP application.
5204
5495
  * Route and middleware layers require this service to register themselves with
@@ -5221,10 +5512,10 @@ const HttpRouter = /*#__PURE__*/ Service("effect/http/HttpRouter");
5221
5512
  * @category constructors
5222
5513
  * @since 4.0.0
5223
5514
  */
5224
- const make$21 = /*#__PURE__*/ gen(function* () {
5515
+ const make$22 = /*#__PURE__*/ gen(function* () {
5225
5516
  const config = yield* RouterConfig;
5226
5517
  const ignoreDuplicateSlashes = config.ignoreDuplicateSlashes ?? true;
5227
- const router = make$29(config);
5518
+ const router = make$30(config);
5228
5519
  const middleware = /* @__PURE__ */ new Set();
5229
5520
  const addAll = (routes) => contextWith((context) => {
5230
5521
  const middleware = getMiddleware(context);
@@ -5254,7 +5545,7 @@ const make$21 = /*#__PURE__*/ gen(function* () {
5254
5545
  return void_;
5255
5546
  });
5256
5547
  return HttpRouter.of({
5257
- [TypeId$9]: TypeId$9,
5548
+ [TypeId$10]: TypeId$10,
5258
5549
  prefixed(prefix) {
5259
5550
  prefix = removeTrailingSlash(prefix);
5260
5551
  return HttpRouter.of({
@@ -5278,7 +5569,7 @@ const make$21 = /*#__PURE__*/ gen(function* () {
5278
5569
  asHttpEffect() {
5279
5570
  let handler = withFiber((fiber) => {
5280
5571
  let context = fiber.context;
5281
- const request = getUnsafe(context, HttpServerRequest);
5572
+ const request = getUnsafe$1(context, HttpServerRequest);
5282
5573
  let result = router.find(request.method, request.url);
5283
5574
  if (result === void 0 && request.method === "HEAD") result = router.find("GET", request.url);
5284
5575
  if (result === void 0) return fail$1(new HttpServerError({ reason: new RouteNotFound({ request }) }));
@@ -5373,7 +5664,7 @@ var RouteContext = class extends (/*#__PURE__*/ Service()("effect/http/HttpRoute
5373
5664
  * @category getters
5374
5665
  * @since 4.0.0
5375
5666
  */
5376
- const params = /*#__PURE__*/ withFiberSucceed((fiber) => getUnsafe(fiber.context, RouteContext).params);
5667
+ const params = /*#__PURE__*/ withFiberSucceed((fiber) => getUnsafe$1(fiber.context, RouteContext).params);
5377
5668
  /**
5378
5669
  * Decodes a schema from the path parameters captured for the current matched
5379
5670
  * route.
@@ -5431,7 +5722,7 @@ const use = (f) => effectDiscard(flatMap(HttpRouter, f));
5431
5722
  * @category layers
5432
5723
  * @since 4.0.0
5433
5724
  */
5434
- const layer$8 = /*#__PURE__*/ effect(HttpRouter)(make$21);
5725
+ const layer$8 = /*#__PURE__*/ effect(HttpRouter)(make$22);
5435
5726
  const RouteTypeId = "~effect/http/HttpRouter/Route";
5436
5727
  const makeRoute = (options) => ({
5437
5728
  ...options,
@@ -5555,7 +5846,7 @@ const makeMiddleware = (middleware, options) => options?.global ? effectDiscard(
5555
5846
  const router = yield* HttpRouter;
5556
5847
  const fn = isEffect(middleware) ? yield* middleware : middleware;
5557
5848
  yield* router.addGlobalMiddleware(fn);
5558
- })) : new MiddlewareImpl(isEffect(middleware) ? effectContext(map$1(middleware, (fn) => makeUnsafe$3(/* @__PURE__ */ new Map([[fnContextKey, fn]])))) : succeedContext(makeUnsafe$3(/* @__PURE__ */ new Map([[fnContextKey, middleware]]))));
5849
+ })) : new MiddlewareImpl(isEffect(middleware) ? effectContext(map$1(middleware, (fn) => makeUnsafe$5(/* @__PURE__ */ new Map([[fnContextKey, fn]])))) : succeedContext(makeUnsafe$5(/* @__PURE__ */ new Map([[fnContextKey, middleware]]))));
5559
5850
  let middlewareId = 0;
5560
5851
  const fnContextKey = "effect/http/HttpRouter/MiddlewareFn";
5561
5852
  var MiddlewareImpl = class MiddlewareImpl {
@@ -5571,12 +5862,12 @@ var MiddlewareImpl = class MiddlewareImpl {
5571
5862
  const stack = [getOrUndefinedUnsafe(context$2, fnContextKey)];
5572
5863
  if (this.dependencies) {
5573
5864
  const memoMap = yield* CurrentMemoMap;
5574
- const scope = get$5(context$2, Scope);
5865
+ const scope = get$6(context$2, Scope);
5575
5866
  const depsContext = yield* buildWithMemoMap(this.dependencies, memoMap, scope);
5576
5867
  stack.push(...getMiddleware(depsContext));
5577
5868
  }
5578
- return makeUnsafe$3(/* @__PURE__ */ new Map([[contextKey, stack]]));
5579
- })).pipe(provide(this.layerFn));
5869
+ return makeUnsafe$5(/* @__PURE__ */ new Map([[contextKey, stack]]));
5870
+ })).pipe(provide$1(this.layerFn));
5580
5871
  }
5581
5872
  layer;
5582
5873
  combine(other) {
@@ -5623,12 +5914,12 @@ const getMiddleware = (context) => {
5623
5914
  const serve = (appLayer, options) => {
5624
5915
  let middleware = options?.middleware;
5625
5916
  if (options?.disableLogger !== true) middleware = middleware ? compose$1(middleware, logger$1) : logger$1;
5626
- const layerWithRouter = provideMerge(appLayer, options?.routerConfig ? provide(layer$8, succeed$2(RouterConfig)(options.routerConfig)) : layer$8);
5917
+ const layerWithRouter = provideMerge(appLayer, options?.routerConfig ? provide$1(layer$8, succeed$2(RouterConfig)(options.routerConfig)) : layer$8);
5627
5918
  return contextWith((context) => {
5628
5919
  const memoMap = CurrentMemoMap.forkOrCreate(context);
5629
- return buildWithMemoMap(layerWithRouter, memoMap, get$5(context, Scope));
5920
+ return buildWithMemoMap(layerWithRouter, memoMap, get$6(context, Scope));
5630
5921
  }).pipe(map$1((context) => {
5631
- const handler = get$5(context, HttpRouter).asHttpEffect();
5922
+ const handler = get$6(context, HttpRouter).asHttpEffect();
5632
5923
  return merge$3(middleware ? serve$1(handler, middleware) : serve$1(handler), succeedContext(context));
5633
5924
  }), unwrap$3, options?.disableListenLog ? identity : withLogAddress);
5634
5925
  };
@@ -5645,7 +5936,7 @@ const serve = (appLayer, options) => {
5645
5936
  * @stability stable
5646
5937
  * @since 2.0.0
5647
5938
  */
5648
- const TypeId$8 = "~effect/FiberSet";
5939
+ const TypeId$9 = "~effect/FiberSet";
5649
5940
  /**
5650
5941
  * Checks whether a value is a FiberSet.
5651
5942
  *
@@ -5668,9 +5959,9 @@ const TypeId$8 = "~effect/FiberSet";
5668
5959
  * @category guards
5669
5960
  * @since 2.0.0
5670
5961
  */
5671
- const isFiberSet = (u) => hasProperty(u, TypeId$8);
5672
- const Proto$5 = {
5673
- [TypeId$8]: TypeId$8,
5962
+ const isFiberSet = (u) => hasProperty(u, TypeId$9);
5963
+ const Proto$6 = {
5964
+ [TypeId$9]: TypeId$9,
5674
5965
  [Symbol.iterator]() {
5675
5966
  if (this.state._tag === "Closed") return empty$12();
5676
5967
  return this.state.backing[Symbol.iterator]();
@@ -5683,8 +5974,8 @@ const Proto$5 = {
5683
5974
  };
5684
5975
  }
5685
5976
  };
5686
- const makeUnsafe$1 = (backing, deferred) => {
5687
- const self = Object.create(Proto$5);
5977
+ const makeUnsafe$2 = (backing, deferred) => {
5978
+ const self = Object.create(Proto$6);
5688
5979
  self.state = {
5689
5980
  _tag: "Open",
5690
5981
  backing
@@ -5728,7 +6019,7 @@ const makeUnsafe$1 = (backing, deferred) => {
5728
6019
  * @category constructors
5729
6020
  * @since 2.0.0
5730
6021
  */
5731
- const make$20 = () => acquireRelease(sync(() => makeUnsafe$1(/* @__PURE__ */ new Set(), makeUnsafe$4())), (set) => suspend(() => {
6022
+ const make$21 = () => acquireRelease(sync(() => makeUnsafe$2(/* @__PURE__ */ new Set(), makeUnsafe$6())), (set) => suspend(() => {
5732
6023
  const state = set.state;
5733
6024
  if (state._tag === "Closed") return void_;
5734
6025
  set.state = { _tag: "Closed" };
@@ -5999,12 +6290,12 @@ const makeNoSerialization = /*#__PURE__*/ fnUntraced(function* (group, options)
5999
6290
  const concurrency = options.concurrency ?? "unbounded";
6000
6291
  const disableFatalDefects = options.disableFatalDefects ?? false;
6001
6292
  const services = yield* context();
6002
- const scope = get$5(services, Scope);
6293
+ const scope = get$6(services, Scope);
6003
6294
  const trackFiber = runIn(forkUnsafe$1(scope, "parallel"));
6004
- const concurrencySemaphore = concurrency === "unbounded" ? void 0 : yield* make$34(concurrency);
6295
+ const concurrencySemaphore = concurrency === "unbounded" ? void 0 : yield* make$37(concurrency);
6005
6296
  const clients = /* @__PURE__ */ new Map();
6006
6297
  let isShutdown = false;
6007
- const shutdownLatch = makeUnsafe$5(false);
6298
+ const shutdownLatch = makeUnsafe$7(false);
6008
6299
  yield* addFinalizer(scope, withFiber((parent) => {
6009
6300
  isShutdown = true;
6010
6301
  for (const client of clients.values()) {
@@ -6106,7 +6397,7 @@ const makeNoSerialization = /*#__PURE__*/ fnUntraced(function* (group, options)
6106
6397
  }) : streamOrEffect;
6107
6398
  const withMiddleware = rpc.middlewares.size === 0 ? handler : isStream ? flatMap(exit(applyMiddleware(services, handler, metadata)), (exit) => writeFailure ? failCause(writeFailure) : exit) : applyMiddleware(services, handler, metadata);
6108
6399
  let responded = false;
6109
- const scope = makeUnsafe$2();
6400
+ const scope = makeUnsafe$4();
6110
6401
  let deferred = void 0;
6111
6402
  let effect = onExit(withMiddleware, (exit) => {
6112
6403
  responded = true;
@@ -6196,7 +6487,7 @@ const makeNoSerialization = /*#__PURE__*/ fnUntraced(function* (group, options)
6196
6487
  client.latches ??= /* @__PURE__ */ new Map();
6197
6488
  latch = client.latches.get(request.id);
6198
6489
  if (!latch) {
6199
- latch = makeUnsafe$5(false);
6490
+ latch = makeUnsafe$7(false);
6200
6491
  client.latches.set(request.id, latch);
6201
6492
  }
6202
6493
  }
@@ -6269,7 +6560,7 @@ const handlerContext = (entry, fiberContext) => {
6269
6560
  return merged;
6270
6561
  };
6271
6562
  const applyMiddleware = (context, handler, options) => {
6272
- for (const service of options.rpc.middlewares) handler = getUnsafe(context, service)(handler, options);
6563
+ for (const service of options.rpc.middlewares) handler = getUnsafe$1(context, service)(handler, options);
6273
6564
  return handler;
6274
6565
  };
6275
6566
  /**
@@ -6281,11 +6572,11 @@ const applyMiddleware = (context, handler, options) => {
6281
6572
  * @category running
6282
6573
  * @since 4.0.0
6283
6574
  */
6284
- const make$19 = /*#__PURE__*/ fnUntraced(function* (group, options) {
6575
+ const make$20 = /*#__PURE__*/ fnUntraced(function* (group, options) {
6285
6576
  const { codecFor, disconnects, end, run, send, supportsAck, supportsSpanPropagation, supportsTransferables } = yield* Protocol;
6286
6577
  const { encodeDefectUnsafe, encodeUnknownRequestExit } = defectCodecs(codecFor);
6287
6578
  const services = yield* context();
6288
- const scope = yield* make$35();
6579
+ const scope = yield* make$38();
6289
6580
  const server = yield* makeNoSerialization(group, {
6290
6581
  ...options,
6291
6582
  disableClientAcks: !supportsAck,
@@ -6311,7 +6602,7 @@ const make$19 = /*#__PURE__*/ fnUntraced(function* (group, options) {
6311
6602
  return end(response.clientId);
6312
6603
  }
6313
6604
  }
6314
- }).pipe(provide$1(scope));
6605
+ }).pipe(provide$2(scope));
6315
6606
  yield* forkChild(whileLoop({
6316
6607
  while: constTrue,
6317
6608
  body: constant(flatMap(take(disconnects), (clientId) => {
@@ -6428,7 +6719,7 @@ const make$19 = /*#__PURE__*/ fnUntraced(function* (group, options) {
6428
6719
  * @category layers
6429
6720
  * @since 4.0.0
6430
6721
  */
6431
- const layer$7 = (group, options) => effectDiscard(forkScoped(make$19(group, options)));
6722
+ const layer$7 = (group, options) => effectDiscard(forkScoped(make$20(group, options)));
6432
6723
  /**
6433
6724
  * Creates a RPC server that registers a HTTP route with a `HttpRouter`.
6434
6725
  *
@@ -6441,7 +6732,7 @@ const layer$7 = (group, options) => effectDiscard(forkScoped(make$19(group, opti
6441
6732
  * @category layers
6442
6733
  * @since 4.0.0
6443
6734
  */
6444
- const layerHttp = (options) => layer$7(options.group, options).pipe(provide(options.protocol === "http" ? layerProtocolHttp(options) : layerProtocolWebsocket(options)));
6735
+ const layerHttp = (options) => layer$7(options.group, options).pipe(provide$1(options.protocol === "http" ? layerProtocolHttp(options) : layerProtocolWebsocket(options)));
6445
6736
  /**
6446
6737
  * Defines the service interface for an RPC server transport, responsible for receiving
6447
6738
  * encoded client messages, sending encoded responses, tracking clients, and
@@ -6522,7 +6813,7 @@ const makeProtocolWithHttpEffect = /*#__PURE__*/ fnUntraced(function* (options =
6522
6813
  const { encodeDefectUnsafe } = defectCodecs(serialization.codecFor);
6523
6814
  const includesFraming = serialization.includesFraming;
6524
6815
  const isBinary = !serialization.contentType.includes("json");
6525
- const disconnects = yield* make$36();
6816
+ const disconnects = yield* make$39();
6526
6817
  let writeRequest;
6527
6818
  let clientId = 0;
6528
6819
  const clients = /* @__PURE__ */ new Map();
@@ -6530,12 +6821,12 @@ const makeProtocolWithHttpEffect = /*#__PURE__*/ fnUntraced(function* (options =
6530
6821
  const encoder = new TextEncoder();
6531
6822
  const httpEffect = gen(function* () {
6532
6823
  const fiber = getCurrent();
6533
- const request = getUnsafe(fiber.context, HttpServerRequest);
6534
- const scope = getUnsafe(fiber.context, Scope);
6824
+ const request = getUnsafe$1(fiber.context, HttpServerRequest);
6825
+ const scope = getUnsafe$1(fiber.context, Scope);
6535
6826
  const requestHeaders = Object.entries(request.headers);
6536
6827
  const data = yield* orDie(isBinary ? map$1(request.arrayBuffer, (buf) => new Uint8Array(buf)) : request.text);
6537
6828
  const id = clientId++;
6538
- const queue = yield* make$36({ capacity: includesFraming && options.streamBufferSize !== "unbounded" ? options.streamBufferSize ?? 16 : void 0 });
6829
+ const queue = yield* make$39({ capacity: includesFraming && options.streamBufferSize !== "unbounded" ? options.streamBufferSize ?? 16 : void 0 });
6539
6830
  const parser = serialization.makeUnsafe();
6540
6831
  const requestIds = [];
6541
6832
  const offer$1 = (data) => typeof data === "string" ? offer(queue, encoder.encode(data)) : offer(queue, data);
@@ -6652,7 +6943,7 @@ const layerProtocolHttp = (options) => {
6652
6943
  const makeSocketProtocol = /*#__PURE__*/ gen(function* () {
6653
6944
  const serialization = yield* RpcSerialization;
6654
6945
  const { encodeDefectUnsafe } = defectCodecs(serialization.codecFor);
6655
- const disconnects = yield* make$36();
6946
+ const disconnects = yield* make$39();
6656
6947
  let clientId = 0;
6657
6948
  const clients = /* @__PURE__ */ new Map();
6658
6949
  const clientIds = /* @__PURE__ */ new Set();
@@ -6744,7 +7035,7 @@ const makeSocketProtocol = /*#__PURE__*/ gen(function* () {
6744
7035
  * @stability stable
6745
7036
  * @since 2.0.0
6746
7037
  */
6747
- const TypeId$7 = "~effect/FiberMap";
7038
+ const TypeId$8 = "~effect/FiberMap";
6748
7039
  /**
6749
7040
  * Returns `true` if a value is a `FiberMap`.
6750
7041
  *
@@ -6771,9 +7062,9 @@ const TypeId$7 = "~effect/FiberMap";
6771
7062
  * @category guards
6772
7063
  * @since 2.0.0
6773
7064
  */
6774
- const isFiberMap = (u) => hasProperty(u, TypeId$7);
6775
- const Proto$4 = {
6776
- [TypeId$7]: TypeId$7,
7065
+ const isFiberMap = (u) => hasProperty(u, TypeId$8);
7066
+ const Proto$5 = {
7067
+ [TypeId$8]: TypeId$8,
6777
7068
  [Symbol.iterator]() {
6778
7069
  if (this.state._tag === "Closed") return empty$12();
6779
7070
  return this.state.backing[Symbol.iterator]();
@@ -6786,8 +7077,8 @@ const Proto$4 = {
6786
7077
  };
6787
7078
  }
6788
7079
  };
6789
- const makeUnsafe = (backing, deferred) => {
6790
- const self = Object.create(Proto$4);
7080
+ const makeUnsafe$1 = (backing, deferred) => {
7081
+ const self = Object.create(Proto$5);
6791
7082
  self.state = {
6792
7083
  _tag: "Open",
6793
7084
  backing
@@ -6831,7 +7122,7 @@ const makeUnsafe = (backing, deferred) => {
6831
7122
  * @category constructors
6832
7123
  * @since 2.0.0
6833
7124
  */
6834
- const make$18 = () => acquireRelease(sync(() => makeUnsafe(empty$6(), makeUnsafe$4())), (map) => suspend(() => {
7125
+ const make$19 = () => acquireRelease(sync(() => makeUnsafe$1(empty$6(), makeUnsafe$6())), (map) => suspend(() => {
6835
7126
  const state = map.state;
6836
7127
  if (state._tag === "Closed") return void_;
6837
7128
  map.state = { _tag: "Closed" };
@@ -6887,7 +7178,7 @@ const setUnsafe$1 = /*#__PURE__*/ dual((args) => isFiberMap(args[0]), (self, key
6887
7178
  fiber.interruptUnsafe(internalFiberId);
6888
7179
  return;
6889
7180
  }
6890
- const previous = get$4(self.state.backing, key);
7181
+ const previous = get$5(self.state.backing, key);
6891
7182
  if (previous._tag === "Some") {
6892
7183
  if (previous.value === fiber) return;
6893
7184
  else if (options?.onlyIfMissing === true) {
@@ -6895,11 +7186,11 @@ const setUnsafe$1 = /*#__PURE__*/ dual((args) => isFiberMap(args[0]), (self, key
6895
7186
  return;
6896
7187
  }
6897
7188
  }
6898
- set(self.state.backing, key, fiber);
7189
+ set$1(self.state.backing, key, fiber);
6899
7190
  if (previous._tag === "Some") previous.value.interruptUnsafe(internalFiberId);
6900
7191
  fiber.addObserver((exit) => {
6901
7192
  if (self.state._tag === "Closed") return;
6902
- const current = get$4(self.state.backing, key);
7193
+ const current = get$5(self.state.backing, key);
6903
7194
  if (isSome(current) && fiber === current.value) remove$2(self.state.backing, key);
6904
7195
  if (isFailure$1(exit) && (options?.propagateInterruption === true ? !isInternalInterruption(exit.cause) : !hasInterruptsOnly(exit.cause))) doneUnsafe(self.deferred, exit);
6905
7196
  });
@@ -6964,7 +7255,7 @@ const hasUnsafe = /*#__PURE__*/ dual(2, (self, key) => self.state._tag === "Clos
6964
7255
  */
6965
7256
  const remove$1 = /*#__PURE__*/ dual(2, (self, key) => suspend(() => {
6966
7257
  if (self.state._tag === "Closed") return void_;
6967
- const fiber = get$4(self.state.backing, key);
7258
+ const fiber = get$5(self.state.backing, key);
6968
7259
  if (fiber._tag === "None") return void_;
6969
7260
  return interruptAs(fiber.value, internalFiberId);
6970
7261
  }));
@@ -10658,13 +10949,13 @@ var NodeHttpIncomingMessage = class extends Class {
10658
10949
  *
10659
10950
  * @since 4.0.0
10660
10951
  */
10661
- [TypeId$16];
10952
+ [TypeId$17];
10662
10953
  source;
10663
10954
  onError;
10664
10955
  remoteAddressOverride;
10665
10956
  constructor(source, onError, remoteAddressOverride) {
10666
10957
  super();
10667
- this[TypeId$16] = TypeId$16;
10958
+ this[TypeId$17] = TypeId$17;
10668
10959
  this.source = source;
10669
10960
  this.onError = onError;
10670
10961
  this.remoteAddressOverride = remoteAddressOverride;
@@ -10791,7 +11082,7 @@ var RequestInit = class extends (/*#__PURE__*/ Service()("effect/http/FetchHttpC
10791
11082
  * @category layers
10792
11083
  * @since 4.0.0
10793
11084
  */
10794
- const layer$6 = /*#__PURE__*/ layerMergedContext(/*#__PURE__*/ succeed$1(/* @__PURE__ */ make$31((request, url, signal, fiber) => {
11085
+ const layer$6 = /*#__PURE__*/ layerMergedContext(/*#__PURE__*/ succeed$1(/* @__PURE__ */ make$32((request, url, signal, fiber) => {
10795
11086
  const fetch = fiber.getRef(Fetch);
10796
11087
  const options = getOrUndefined$1(fiber.context, RequestInit) ?? {};
10797
11088
  let headers = options.headers ? merge$2(fromInput$1(options.headers), request.headers) : request.headers;
@@ -10859,7 +11150,7 @@ const layerAgentOptions = /*#__PURE__*/ flow(makeAgent, /*#__PURE__*/ effect(Htt
10859
11150
  */
10860
11151
  const makeNodeHttp = /*#__PURE__*/ gen(function* () {
10861
11152
  const agent = yield* HttpAgent;
10862
- return make$31((request, url, signal) => {
11153
+ return make$32((request, url, signal) => {
10863
11154
  const nodeRequest = url.protocol === "https:" ? Https.request(url, {
10864
11155
  agent: agent.https,
10865
11156
  method: request.method,
@@ -10947,7 +11238,7 @@ const waitForFinish = (nodeRequest, request) => callback((resume) => {
10947
11238
  });
10948
11239
  });
10949
11240
  var NodeHttpResponse = class extends NodeHttpIncomingMessage {
10950
- [TypeId$15];
11241
+ [TypeId$16];
10951
11242
  request;
10952
11243
  url;
10953
11244
  constructor(request, source, url) {
@@ -10956,7 +11247,7 @@ var NodeHttpResponse = class extends NodeHttpIncomingMessage {
10956
11247
  response: this,
10957
11248
  cause
10958
11249
  }) }));
10959
- this[TypeId$15] = TypeId$15;
11250
+ this[TypeId$16] = TypeId$16;
10960
11251
  this.request = request;
10961
11252
  this.url = url;
10962
11253
  }
@@ -11067,7 +11358,7 @@ const compress = (data, algorithm, options) => callback((resume) => {
11067
11358
  * @category constructors
11068
11359
  * @since 4.0.0
11069
11360
  */
11070
- const make$17 = (fallback) => ({
11361
+ const make$18 = (fallback) => ({
11071
11362
  algorithms: fallback.algorithms,
11072
11363
  compressResponse(response, algorithm, options) {
11073
11364
  const body = response.body;
@@ -11154,9 +11445,9 @@ const compressedBody = (response, body) => removeHeader(setBody(response, body),
11154
11445
  * @category constructors
11155
11446
  * @since 4.0.0
11156
11447
  */
11157
- const make$16 = /*#__PURE__*/ make$28({
11448
+ const make$17 = /*#__PURE__*/ make$29({
11158
11449
  platform: "node",
11159
- compression: /* @__PURE__ */ make$17({
11450
+ compression: /* @__PURE__ */ make$18({
11160
11451
  algorithms,
11161
11452
  compressResponse(response, algorithm, options) {
11162
11453
  const body = response.body;
@@ -11211,7 +11502,7 @@ const make$16 = /*#__PURE__*/ make$28({
11211
11502
  * @category layers
11212
11503
  * @since 4.0.0
11213
11504
  */
11214
- const layer$5 = /*#__PURE__*/ pipe(/*#__PURE__*/ effect(HttpPlatform)(make$16), /*#__PURE__*/ provide(layer$10), /*#__PURE__*/ provide(layer$9));
11505
+ const layer$5 = /*#__PURE__*/ pipe(/*#__PURE__*/ effect(HttpPlatform)(make$17), /*#__PURE__*/ provide$1(layer$10), /*#__PURE__*/ provide$1(layer$9));
11215
11506
  //#endregion
11216
11507
  //#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
11217
11508
  /**
@@ -11229,7 +11520,7 @@ var MultipartStream = class extends Duplex {
11229
11520
  super({ readableObjectMode: true });
11230
11521
  let currentError;
11231
11522
  let currentFile;
11232
- this._parser = make$24({
11523
+ this._parser = make$25({
11233
11524
  ...config,
11234
11525
  onField: (info, value) => {
11235
11526
  if (currentError !== void 0) return;
@@ -11292,7 +11583,7 @@ var MultipartStream = class extends Duplex {
11292
11583
  * @category constructors
11293
11584
  * @since 4.0.0
11294
11585
  */
11295
- const make$15 = (config) => new MultipartStream(config);
11586
+ const make$16 = (config) => new MultipartStream(config);
11296
11587
  /**
11297
11588
  * A readable stream containing a parsed multipart file.
11298
11589
  *
@@ -11341,7 +11632,7 @@ var FileStream = class extends Readable {
11341
11632
  */
11342
11633
  const stream = (source, headers) => makeConfig(headers).pipe(map$1((config) => fromReadable({
11343
11634
  evaluate() {
11344
- const parser = make$15(config);
11635
+ const parser = make$16(config);
11345
11636
  source.pipe(parser);
11346
11637
  return parser;
11347
11638
  },
@@ -11361,10 +11652,10 @@ const persisted = (source, headers) => toPersisted(stream(source, headers), (pat
11361
11652
  }));
11362
11653
  const convertPart = (part) => part._tag === "Field" ? new FieldImpl(part.info, part.value) : new FileImpl(part);
11363
11654
  var PartBase = class extends Class {
11364
- [TypeId$11];
11655
+ [TypeId$12];
11365
11656
  constructor() {
11366
11657
  super();
11367
- this[TypeId$11] = TypeId$11;
11658
+ this[TypeId$12] = TypeId$12;
11368
11659
  }
11369
11660
  };
11370
11661
  var FieldImpl = class extends PartBase {
@@ -11455,7 +11746,7 @@ function convertError(cause) {
11455
11746
  * @category constructors
11456
11747
  * @since 4.0.0
11457
11748
  */
11458
- const make$14 = /*#__PURE__*/ fnUntraced(function* (evaluate, options) {
11749
+ const make$15 = /*#__PURE__*/ fnUntraced(function* (evaluate, options) {
11459
11750
  const scope$2 = yield* scope;
11460
11751
  const server = evaluate();
11461
11752
  const shutdown = yield* callback((resume) => {
@@ -11487,8 +11778,8 @@ const make$14 = /*#__PURE__*/ fnUntraced(function* (evaluate, options) {
11487
11778
  noServer: true
11488
11779
  })), (wss) => callback((resume) => {
11489
11780
  wss.close(() => resume(void_));
11490
- })).pipe(provide$1(scope$2), cached);
11491
- return make$22({
11781
+ })).pipe(provide$2(scope$2), cached);
11782
+ return make$23({
11492
11783
  address: boundAddress,
11493
11784
  serve: fnUntraced(function* (httpApp, middleware) {
11494
11785
  const serveScope = yield* scope;
@@ -11583,7 +11874,7 @@ const makeUpgradeHandler = (lazyWss, httpEffect, options) => {
11583
11874
  });
11584
11875
  };
11585
11876
  var ServerRequestImpl = class ServerRequestImpl extends NodeHttpIncomingMessage {
11586
- [TypeId$10];
11877
+ [TypeId$11];
11587
11878
  response;
11588
11879
  upgradeEffect;
11589
11880
  upgraded = false;
@@ -11594,7 +11885,7 @@ var ServerRequestImpl = class ServerRequestImpl extends NodeHttpIncomingMessage
11594
11885
  request: this,
11595
11886
  cause
11596
11887
  }) }), remoteAddressOverride);
11597
- this[TypeId$10] = TypeId$10;
11888
+ this[TypeId$11] = TypeId$11;
11598
11889
  this.response = response;
11599
11890
  this.upgradeEffect = upgradeEffect;
11600
11891
  this.url = url;
@@ -11666,7 +11957,7 @@ const layerHttpServices = /*#__PURE__*/ mergeAll(layer$5, layerWeak, layer$11);
11666
11957
  * @category layers
11667
11958
  * @since 4.0.0
11668
11959
  */
11669
- const layerConfig = (evaluate, options) => mergeAll(effect(HttpServer)(flatMap(unwrap$4(options), (options) => make$14(evaluate, options))), layerHttpServices);
11960
+ const layerConfig = (evaluate, options) => mergeAll(effect(HttpServer)(flatMap(unwrap$4(options), (options) => make$15(evaluate, options))), layerHttpServices);
11670
11961
  const closeCode = (exit) => isSuccess$1(exit) ? 1e3 : hasInterruptsOnly(exit.cause) ? 1001 : 1011;
11671
11962
  const upgradedResponse = /*#__PURE__*/ empty$3({ status: 101 });
11672
11963
  const handleResponse = (request, response) => {
@@ -11747,7 +12038,7 @@ const handleResponse = (request, response) => {
11747
12038
  });
11748
12039
  case "Stream": {
11749
12040
  nodeResponse.writeHead(response.status, response.statusText, headers);
11750
- const drainLatch = makeUnsafe$5();
12041
+ const drainLatch = makeUnsafe$7();
11751
12042
  nodeResponse.on("drain", () => drainLatch.openUnsafe());
11752
12043
  return body.stream.pipe(orDie$1, runForEachArray((array) => {
11753
12044
  const chunk = array.length > 1 ? Buffer.concat(array) : array[0];
@@ -12096,7 +12387,7 @@ const utf8Strings = (record) => {
12096
12387
  */
12097
12388
  const layer$4 = /*#__PURE__*/ effect(Dns, /*#__PURE__*/ orDie(/*#__PURE__*/ (/* @__PURE__ */ fnUntraced(function* (options) {
12098
12389
  const resolve = yield* resolver(options);
12099
- return make$37({
12390
+ return make$40({
12100
12391
  lookup,
12101
12392
  resolve: (name, type) => map$1(resolve(name, type), map$3(utf8Strings))
12102
12393
  });
@@ -12494,6 +12785,110 @@ const when = when$1;
12494
12785
  */
12495
12786
  const orElse = orElse$1;
12496
12787
  //#endregion
12788
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/SynchronizedRef.js
12789
+ /**
12790
+ * Stores mutable state whose updates run one at a time.
12791
+ *
12792
+ * A `SynchronizedRef<A>` behaves like a `Ref<A>` for reading and simple state
12793
+ * storage, but update and modify operations are serialized so each change sees
12794
+ * a consistent current value. This is especially useful when the next value is
12795
+ * computed by an effect, because the effectful transition is still protected
12796
+ * from concurrent updates. This module includes constructors, reads, writes,
12797
+ * updates, partial updates, and effectful update helpers.
12798
+ *
12799
+ * @stability stable
12800
+ * @since 2.0.0
12801
+ */
12802
+ const TypeId$6 = "~effect/SynchronizedRef";
12803
+ const Proto$4 = {
12804
+ ...PipeInspectableProto,
12805
+ [TypeId$6]: TypeId$6,
12806
+ toJSON() {
12807
+ return {
12808
+ _id: "SynchronizedRef",
12809
+ value: this.backing.ref.current
12810
+ };
12811
+ }
12812
+ };
12813
+ /**
12814
+ * Creates a `SynchronizedRef` synchronously from an initial value.
12815
+ *
12816
+ * **When to use**
12817
+ *
12818
+ * Use when you need synchronous `SynchronizedRef` construction outside an
12819
+ * Effect workflow.
12820
+ *
12821
+ * @stability stable
12822
+ * @category constructors
12823
+ * @since 4.0.0
12824
+ */
12825
+ const makeUnsafe = (value) => {
12826
+ const self = Object.create(Proto$4);
12827
+ self.semaphore = makeUnsafe$8(1);
12828
+ self.backing = makeUnsafe$3(value);
12829
+ return self;
12830
+ };
12831
+ /**
12832
+ * Creates a `SynchronizedRef` from an initial value, wrapped in an `Effect`.
12833
+ *
12834
+ * **When to use**
12835
+ *
12836
+ * Use to create a `SynchronizedRef` inside an Effect program when later updates
12837
+ * may run effects and must be serialized.
12838
+ *
12839
+ * **Details**
12840
+ *
12841
+ * The returned effect constructs a fresh `SynchronizedRef` by delegating to
12842
+ * `makeUnsafe` when the effect is evaluated.
12843
+ *
12844
+ * @see {@link makeUnsafe} for synchronous construction when the caller controls safe initialization
12845
+ * @see {@link Ref.make} for a plain `Ref` when updates do not need effectful synchronization
12846
+ *
12847
+ * @stability stable
12848
+ * @category constructors
12849
+ * @since 2.0.0
12850
+ */
12851
+ const make$13 = (value) => sync(() => makeUnsafe(value));
12852
+ /**
12853
+ * Reads the current value synchronously, bypassing the `Effect` API and the
12854
+ * ref's semaphore.
12855
+ *
12856
+ * **When to use**
12857
+ *
12858
+ * Use when you need immediate synchronous access to a `SynchronizedRef` value
12859
+ * in low-level code that can safely read outside an `Effect`.
12860
+ *
12861
+ * @see {@link get} for the Effect-wrapped read when composing inside Effect programs
12862
+ *
12863
+ * @stability stable
12864
+ * @category getters
12865
+ * @since 4.0.0
12866
+ */
12867
+ const getUnsafe = (self) => self.backing.ref.current;
12868
+ /**
12869
+ * Runs an effectful modification atomically while holding the ref's semaphore,
12870
+ * stores the new value if the effect succeeds, and returns the computed result.
12871
+ *
12872
+ * **When to use**
12873
+ *
12874
+ * Use to effectfully compute both a separate return value and the next stored
12875
+ * `SynchronizedRef` value in one serialized update.
12876
+ *
12877
+ * @see {@link modify} for the pure variant
12878
+ * @see {@link updateEffect} for effectfully storing a new value without a separate result
12879
+ *
12880
+ * @stability stable
12881
+ * @category mutations
12882
+ * @since 2.0.0
12883
+ */
12884
+ const modifyEffect$1 = /*#__PURE__*/ dual(2, (self, f) => self.semaphore.withPermit(suspend(() => {
12885
+ const value = getUnsafe(self);
12886
+ return map$1(f(value), ([b, a]) => {
12887
+ self.backing.ref.current = a;
12888
+ return b;
12889
+ });
12890
+ })));
12891
+ //#endregion
12497
12892
  //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/SubscriptionRef.js
12498
12893
  /**
12499
12894
  * Stores mutable state and publishes changes as a stream.
@@ -12540,7 +12935,7 @@ const Proto$3 = {
12540
12935
  */
12541
12936
  const make$12 = (value) => map$1(unbounded({ replay: 1 }), (pubsub) => {
12542
12937
  const self = Object.create(Proto$3);
12543
- self.semaphore = makeUnsafe$6(1);
12938
+ self.semaphore = makeUnsafe$8(1);
12544
12939
  self.value = value;
12545
12940
  self.pubsub = pubsub;
12546
12941
  publishUnsafe(self.pubsub, value);
@@ -12977,6 +13372,495 @@ const evaluateConditionalRequest = (request, response) => {
12977
13372
  if (ifModifiedSince !== void 0 && isNotModifiedSince(ifModifiedSince, response.headers["last-modified"])) return notModifiedResponse(response);
12978
13373
  };
12979
13374
  //#endregion
13375
+ //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/encoding/Sse.js
13376
+ const SseErrorTypeId = "~effect/encoding/Sse/SseError";
13377
+ /**
13378
+ * Error reason raised when pending Server-Sent Events state exceeds the
13379
+ * configured maximum size.
13380
+ *
13381
+ * @stability unstable
13382
+ * @category errors
13383
+ * @since 4.0.0
13384
+ */
13385
+ var EventTooLarge = class extends (/*#__PURE__*/ TaggedError("EventTooLarge")) {
13386
+ get message() {
13387
+ return `Pending SSE event exceeded the maximum size of ${this.maxEventSize}`;
13388
+ }
13389
+ };
13390
+ /**
13391
+ * Error raised when decoding a Server-Sent Events stream fails.
13392
+ *
13393
+ * @stability unstable
13394
+ * @category errors
13395
+ * @since 4.0.0
13396
+ */
13397
+ var SseError = class extends (/*#__PURE__*/ TaggedError("SseError")) {
13398
+ /**
13399
+ * Marks this value as an SSE decoding error.
13400
+ *
13401
+ * @stability unstable
13402
+ * @since 4.0.0
13403
+ */
13404
+ [SseErrorTypeId] = SseErrorTypeId;
13405
+ /**
13406
+ * Delegates the public message to the underlying SSE error reason.
13407
+ *
13408
+ * @stability unstable
13409
+ * @since 4.0.0
13410
+ */
13411
+ get message() {
13412
+ return this.reason.message;
13413
+ }
13414
+ };
13415
+ const defaultMaxEventSize = 10485760;
13416
+ /**
13417
+ * Creates a channel that parses Server-Sent Events text chunks into `Event` values.
13418
+ *
13419
+ * **Details**
13420
+ *
13421
+ * SSE `retry` directives are emitted as `Retry` failures so callers can
13422
+ * reconnect with the requested delay.
13423
+ *
13424
+ * @stability unstable
13425
+ * @category decoding
13426
+ * @since 4.0.0
13427
+ */
13428
+ const decode$1 = (options) => fromTransform((upstream, _scope) => sync(() => {
13429
+ let buffer = [];
13430
+ let retry;
13431
+ const parser = makeParser((event) => {
13432
+ if (event._tag === "Retry") retry = event;
13433
+ else buffer.push(event);
13434
+ }, options);
13435
+ const pump = flatMap(upstream, (arr) => {
13436
+ for (let i = 0; i < arr.length; i++) {
13437
+ const error = parser.feed(arr[i]);
13438
+ if (error !== void 0) return fail$1(error);
13439
+ }
13440
+ return void_;
13441
+ });
13442
+ return suspend(function loop() {
13443
+ if (isArrayNonEmpty(buffer)) {
13444
+ const out = buffer;
13445
+ buffer = [];
13446
+ return succeed$1(out);
13447
+ } else if (retry) return fail$1(retry);
13448
+ return flatMap(pump, loop);
13449
+ });
13450
+ }));
13451
+ /**
13452
+ * Creates an SSE decoder channel that decodes each parsed event with a schema.
13453
+ *
13454
+ * **Details**
13455
+ *
13456
+ * The schema receives `{ event, data, id? }`, with string `data`. Absent IDs are
13457
+ * omitted, even with default options: use `Schema.optional(Schema.String)`, not
13458
+ * `Schema.UndefinedOr(Schema.String)`, to accept events without an ID.
13459
+ *
13460
+ * With `onExcessProperty: "error"`, declare `event` (default: `"message"`) and
13461
+ * `id` if the stream carries IDs, including inherited IDs.
13462
+ *
13463
+ * @stability unstable
13464
+ * @category decoding
13465
+ * @since 4.0.0
13466
+ */
13467
+ const decodeSchema = (schema, options, parseOptions) => pipeTo(decode$1(options), decode$2(Event$1.pipe(decodeTo(schema, transformEvent)), parseOptions)());
13468
+ /**
13469
+ * Creates an SSE decoder channel that JSON-decodes each event `data` field with a schema.
13470
+ *
13471
+ * **Details**
13472
+ *
13473
+ * The output preserves the SSE `event` name and optional `id` while replacing
13474
+ * `data` with the decoded value.
13475
+ *
13476
+ * @stability unstable
13477
+ * @category decoding
13478
+ * @since 4.0.0
13479
+ */
13480
+ const decodeDataSchema = (schema, options) => {
13481
+ const eventSchema = Struct({
13482
+ ...EventEncoded.fields,
13483
+ data: fromJsonString(schema)
13484
+ });
13485
+ return pipeTo(decode$1(options), map$4(decode$2(eventSchema)(), map$3((event) => ({
13486
+ ...event,
13487
+ id: event.id
13488
+ }))));
13489
+ };
13490
+ /**
13491
+ * Creates a stateful Server-Sent Events parser.
13492
+ *
13493
+ * **Details**
13494
+ *
13495
+ * Call `feed` with text chunks to parse `Event` and `Retry` values through the
13496
+ * callback, and call `reset` to clear any buffered event state. `feed` returns
13497
+ * an `SseError` if the pending event exceeds `maxEventSize`.
13498
+ *
13499
+ * @stability unstable
13500
+ * @category decoding
13501
+ * @since 4.0.0
13502
+ */
13503
+ function makeParser(onParse, options) {
13504
+ const maxEventSize = options?.maxEventSize ?? defaultMaxEventSize;
13505
+ const dispatchEmptyNamedEvents = options?.dispatchEmptyNamedEvents === true;
13506
+ let isFirstChunk;
13507
+ let pending;
13508
+ let pendingLength;
13509
+ let discardTrailingNewline;
13510
+ let generation = 0;
13511
+ let lastEventId;
13512
+ let eventName;
13513
+ let data;
13514
+ reset();
13515
+ return {
13516
+ feed,
13517
+ reset
13518
+ };
13519
+ function reset() {
13520
+ generation++;
13521
+ isFirstChunk = true;
13522
+ pending = [];
13523
+ pendingLength = 0;
13524
+ discardTrailingNewline = false;
13525
+ lastEventId = void 0;
13526
+ eventName = void 0;
13527
+ data = "";
13528
+ }
13529
+ function feed(chunk) {
13530
+ if (isFirstChunk && chunk.startsWith(BOM)) chunk = chunk.slice(BOM.length);
13531
+ isFirstChunk = false;
13532
+ const length = chunk.length;
13533
+ const currentGeneration = generation;
13534
+ let position = 0;
13535
+ while (position < length) {
13536
+ if (discardTrailingNewline) {
13537
+ discardTrailingNewline = false;
13538
+ if (chunk.charCodeAt(position) === LF) {
13539
+ ++position;
13540
+ continue;
13541
+ }
13542
+ }
13543
+ let lineEnd = position;
13544
+ while (lineEnd < length) {
13545
+ const code = chunk.charCodeAt(lineEnd);
13546
+ if (code === CR || code === LF) break;
13547
+ ++lineEnd;
13548
+ }
13549
+ if (lineEnd === length) {
13550
+ pending.push(chunk.slice(position));
13551
+ pendingLength += length - position;
13552
+ break;
13553
+ }
13554
+ discardTrailingNewline = chunk.charCodeAt(lineEnd) === CR;
13555
+ let line = chunk.slice(position, lineEnd);
13556
+ if (pending.length > 0) {
13557
+ pending.push(line);
13558
+ line = pending.join("");
13559
+ pending = [];
13560
+ pendingLength = 0;
13561
+ }
13562
+ parseLine(line);
13563
+ if (generation !== currentGeneration) return;
13564
+ position = lineEnd + 1;
13565
+ }
13566
+ if (pendingLength + data.length > maxEventSize) {
13567
+ const error = new SseError({ reason: new EventTooLarge({ maxEventSize }) });
13568
+ reset();
13569
+ return error;
13570
+ }
13571
+ }
13572
+ function parseLine(line) {
13573
+ if (line.length === 0) {
13574
+ const named = eventName !== void 0 && eventName !== "";
13575
+ const event = eventName || "message";
13576
+ const eventData = data;
13577
+ eventName = void 0;
13578
+ data = "";
13579
+ if (eventData.length > 0 || dispatchEmptyNamedEvents && named) onParse({
13580
+ _tag: "Event",
13581
+ id: lastEventId,
13582
+ event,
13583
+ data: eventData.slice(0, -1)
13584
+ });
13585
+ return;
13586
+ }
13587
+ const colon = line.indexOf(":");
13588
+ let field = line;
13589
+ let value = "";
13590
+ if (colon >= 0) {
13591
+ field = line.slice(0, colon);
13592
+ value = line.slice(line.charCodeAt(colon + 1) === SPACE ? colon + 2 : colon + 1);
13593
+ }
13594
+ if (field === "data") data += value + "\n";
13595
+ else if (field === "event") eventName = value;
13596
+ else if (field === "id" && !value.includes("\0")) lastEventId = value;
13597
+ else if (field === "retry" && /^\d+$/.test(value)) onParse(new Retry({
13598
+ duration: millis(parseInt(value, 10)),
13599
+ lastEventId
13600
+ }));
13601
+ }
13602
+ }
13603
+ const BOM = "";
13604
+ const LF = 10;
13605
+ const CR = 13;
13606
+ const SPACE = 32;
13607
+ /**
13608
+ * Schema for the untagged Server-Sent Events payload shape containing an optional `id`, `event`, and string `data` fields.
13609
+ *
13610
+ * @stability unstable
13611
+ * @category models
13612
+ * @since 4.0.0
13613
+ */
13614
+ const EventEncoded = /*#__PURE__*/ Struct({
13615
+ id: /*#__PURE__*/ optional$1(String$1),
13616
+ event: String$1,
13617
+ data: String$1
13618
+ });
13619
+ /**
13620
+ * Schema for the tagged Server-Sent Events message model that adds `_tag: "Event"` to the event name, optional event ID, and string data payload.
13621
+ *
13622
+ * @stability unstable
13623
+ * @category models
13624
+ * @since 4.0.0
13625
+ */
13626
+ const Event$1 = /*#__PURE__*/ Struct({
13627
+ _tag: /*#__PURE__*/ tag("Event"),
13628
+ id: /*#__PURE__*/ UndefinedOr(String$1),
13629
+ event: String$1,
13630
+ data: String$1
13631
+ });
13632
+ /**
13633
+ * Schema for transforming untagged SSE event payloads into tagged `Event`
13634
+ * models.
13635
+ *
13636
+ * @stability unstable
13637
+ * @category models
13638
+ * @since 4.0.0
13639
+ */
13640
+ const transformEvent = /*#__PURE__*/ transform$1({
13641
+ decode: (event) => event.id === void 0 ? {
13642
+ event: event.event,
13643
+ data: event.data
13644
+ } : {
13645
+ id: event.id,
13646
+ event: event.event,
13647
+ data: event.data
13648
+ },
13649
+ encode: (event) => ({
13650
+ _tag: "Event",
13651
+ id: event.id,
13652
+ event: event.event ?? "message",
13653
+ data: event.data
13654
+ })
13655
+ });
13656
+ const RetryTypeId = "~effect/encoding/Sse/Retry";
13657
+ /**
13658
+ * Represents a Server-Sent Events retry directive.
13659
+ *
13660
+ * **Details**
13661
+ *
13662
+ * Decoders surface this value as a failure to request reconnection after
13663
+ * `duration`; encoders serialize an upstream `Retry` failure as a `retry:` line.
13664
+ *
13665
+ * @stability unstable
13666
+ * @category models
13667
+ * @since 4.0.0
13668
+ */
13669
+ var Retry = class Retry extends (/*#__PURE__*/ TaggedClass("Retry")) {
13670
+ /**
13671
+ * Marks this value as an SSE retry directive for runtime guards.
13672
+ *
13673
+ * @stability unstable
13674
+ * @since 4.0.0
13675
+ */
13676
+ [RetryTypeId] = RetryTypeId;
13677
+ /**
13678
+ * Returns `true` when the value is an SSE retry directive.
13679
+ *
13680
+ * @stability unstable
13681
+ * @since 4.0.0
13682
+ */
13683
+ static is(u) {
13684
+ return hasProperty(u, RetryTypeId);
13685
+ }
13686
+ /**
13687
+ * Separates SSE retry directives from regular event values.
13688
+ *
13689
+ * @stability unstable
13690
+ * @since 4.0.0
13691
+ */
13692
+ static filter(u) {
13693
+ return Retry.is(u) ? succeed(u) : fail(u);
13694
+ }
13695
+ };
13696
+ //#endregion
13697
+ //#region ../../packages/auth/src/service.ts
13698
+ const SESSION_COOKIE = "__Secure-session";
13699
+ const OAUTH_COOKIE = "__Host-oauth";
13700
+ const COOKIE = {
13701
+ httpOnly: true,
13702
+ path: "/",
13703
+ sameSite: "lax",
13704
+ secure: true
13705
+ };
13706
+ const SESSION_DURATION = days(365);
13707
+ const OAUTH_DURATION = minutes(10);
13708
+ Uint8Array.from([
13709
+ 48,
13710
+ 46,
13711
+ 2,
13712
+ 1,
13713
+ 0,
13714
+ 48,
13715
+ 5,
13716
+ 6,
13717
+ 3,
13718
+ 43,
13719
+ 101,
13720
+ 112,
13721
+ 4,
13722
+ 34,
13723
+ 4,
13724
+ 32
13725
+ ]);
13726
+ all({
13727
+ clientId: String$2("GITHUB_CLIENT_ID"),
13728
+ clientSecret: Redacted("GITHUB_CLIENT_SECRET"),
13729
+ users: Array$1(Int, "GITHUB_USERS")
13730
+ });
13731
+ function bytes(text) {
13732
+ return new TextEncoder().encode(text);
13733
+ }
13734
+ function rejected(message) {
13735
+ return mapError((cause) => AuthError.make({
13736
+ cause,
13737
+ message
13738
+ }));
13739
+ }
13740
+ function respond(message, handler) {
13741
+ return catch_(handler, (cause) => as$1(logWarning(message, cause), text$2(message, { status: match(is$4(AuthError)(cause), {
13742
+ onFalse: () => 500,
13743
+ onTrue: () => 401
13744
+ }) })));
13745
+ }
13746
+ function userFrom(auth, headers) {
13747
+ return pipe(get$7(headers, "authorization"), filter$4(startsWith("Bearer ")), map$5(replace$1("Bearer ", "")), orElse$2(() => pipe(get$7(headers, "cookie"), flatMapNullishOr((cookie) => parseHeader(cookie)[SESSION_COOKIE]))), fromOption, rejected("Sign in first"), flatMap((token) => auth.verify(token)));
13748
+ }
13749
+ function provide(auth) {
13750
+ return pipe(make$41(Auth, auth), add$1(RpcAuth, RpcAuth.of((effect, request) => flatMap(userFrom(auth, request.headers), (user) => provideService(effect, CurrentUser, user)))));
13751
+ }
13752
+ function verifyWith(current) {
13753
+ return fn$1("Auth.verify")(function* (token) {
13754
+ const { publicKey, users } = yield* current;
13755
+ const parts = split(token, ".");
13756
+ const signature = yield* pipe(get$8(parts, 1), flatMap$1((part) => getSuccess(decode$3(part))), fromOption);
13757
+ if (!(yield* tryPromise(() => crypto.subtle.verify("Ed25519", publicKey, new Uint8Array(signature), bytes(headNonEmpty(parts)))))) return yield* AuthError.make({ message: "The session signature is invalid" });
13758
+ const session = yield* decodeEffect(Session)(headNonEmpty(parts));
13759
+ if (session.expiresAt <= (yield* currentTimeMillis)) return yield* AuthError.make({ message: "The session expired" });
13760
+ if (!has$3(users, session.user.id)) return yield* AuthError.make({ message: `${session.user.id} is not on the allow list` });
13761
+ return session.user;
13762
+ }, rejected("Sign in first"));
13763
+ }
13764
+ const SameOrigin = middleware((httpEffect) => gen(function* () {
13765
+ const request = yield* HttpServerRequest;
13766
+ const scheme = match(exists(get$7(request.headers, "x-forwarded-proto"), (proto) => proto === "https" || proto === "wss"), {
13767
+ onFalse: () => "http",
13768
+ onTrue: () => "https"
13769
+ });
13770
+ if (exists(get$7(request.headers, "origin"), (origin) => origin !== `${scheme}://${request.headers["host"] ?? ""}`)) return text$2("The request comes from another origin", { status: 403 });
13771
+ return yield* httpEffect;
13772
+ }), { global: true });
13773
+ function parentDomain(request) {
13774
+ return pipe(toURL(request), map$5((url) => pipe(url.hostname, split("."), drop(1), join$1("."))), filter$4(isNonEmpty));
13775
+ }
13776
+ function callbackUrl(request) {
13777
+ return pipe(toURL(request), map$5((url) => new URL("/auth/github/callback", url).href), fromOption);
13778
+ }
13779
+ fnUntraced(function* (issuer, config, redirects) {
13780
+ const router = yield* HttpRouter;
13781
+ const random = yield* Crypto;
13782
+ const client = filterStatusOk(yield* HttpClient);
13783
+ yield* router.add("GET", "/auth/github", respond("Cannot start the GitHub sign-in", gen(function* () {
13784
+ const request = yield* HttpServerRequest;
13785
+ const query = yield* pipe(schemaSearchParams(SignInParams), rejected("The redirect is invalid"));
13786
+ const domain = parentDomain(request);
13787
+ if (exists(fromUndefinedOr(query.redirect), (redirect) => !contains$1(redirects, redirect) && !exists(getSuccess(fromString(redirect)), (url) => url.protocol === "https:" && exists(domain, (parent) => endsWith(`.${parent}`)(`.${url.hostname}`))))) return yield* AuthError.make({ message: "The redirect is not allowed" });
13788
+ const state = encode(yield* random.randomBytes(32));
13789
+ const verifier = encode(yield* random.randomBytes(32));
13790
+ const authorize = toString$2(fromInput({
13791
+ client_id: config.clientId,
13792
+ code_challenge: encode(yield* random.digest("SHA-256", bytes(verifier))),
13793
+ code_challenge_method: "S256",
13794
+ redirect_uri: yield* callbackUrl(request),
13795
+ response_type: "code",
13796
+ state
13797
+ }));
13798
+ return setCookieUnsafe(redirect(`https://github.com/login/oauth/authorize?${authorize}`), OAUTH_COOKIE, yield* encodeEffect(OAuthFlow)({
13799
+ ...query,
13800
+ state,
13801
+ verifier
13802
+ }), {
13803
+ ...COOKIE,
13804
+ maxAge: OAUTH_DURATION
13805
+ });
13806
+ })));
13807
+ yield* router.add("GET", "/auth/github/callback", respond("The GitHub sign-in failed", gen(function* () {
13808
+ const request = yield* HttpServerRequest;
13809
+ const params = yield* pipe(schemaSearchParams(CallbackParams), rejected("GitHub sent no code"));
13810
+ const flow = yield* pipe(decodeUnknownEffect(OAuthFlow)(request.cookies[OAUTH_COOKIE]), rejected("The sign-in expired"));
13811
+ if (flow.state !== params.state) return yield* AuthError.make({ message: "The sign-in state does not match" });
13812
+ const token = yield* pipe(post("https://github.com/login/oauth/access_token"), acceptJson, bodyUrlParams({
13813
+ client_id: config.clientId,
13814
+ client_secret: value$2(config.clientSecret),
13815
+ code: params.code,
13816
+ code_verifier: flow.verifier,
13817
+ grant_type: "authorization_code",
13818
+ redirect_uri: yield* callbackUrl(request)
13819
+ }), (exchange) => client.execute(exchange), flatMap(schemaBodyJson$1(OAuthTokenResponse)));
13820
+ if (is$4(OAuthTokenError)(token)) return yield* AuthError.make({ message: `GitHub rejected the code: ${token.error}` });
13821
+ const githubUser = yield* pipe(get$3("https://api.github.com/user"), bearerToken(token.access_token), setHeaders$1({
13822
+ accept: "application/vnd.github+json",
13823
+ "user-agent": "@deslop/auth"
13824
+ }), (lookup) => client.execute(lookup), flatMap(schemaBodyJson$1(GitHubUser)));
13825
+ const session = yield* issuer.issue({
13826
+ id: `github:${githubUser.id}`,
13827
+ name: githubUser.login
13828
+ });
13829
+ const redirect$1 = flow.redirect ?? "/";
13830
+ if (contains$1(redirects, redirect$1)) return expireCookieUnsafe(redirect(`${redirect$1}?${toString$2(fromInput({ token: session }))}`), OAUTH_COOKIE, COOKIE);
13831
+ return setCookieUnsafe(expireCookieUnsafe(redirect(redirect$1), OAUTH_COOKIE, COOKIE), SESSION_COOKIE, session, {
13832
+ ...COOKIE,
13833
+ domain: getOrUndefined(parentDomain(request)),
13834
+ maxAge: SESSION_DURATION
13835
+ });
13836
+ })));
13837
+ });
13838
+ var Auth = class Auth extends Service()("@deslop/auth/service/Auth") {
13839
+ static layer = merge$3(SameOrigin, effectContext(gen(function* () {
13840
+ const client = filterStatusOk(yield* HttpClient);
13841
+ const url = yield* pipe(String$2("AUTH_URL"), withDefault(AUTH_URL));
13842
+ const read = pipe(client.get(`${url}/auth/keys`), flatMap(schemaBodyJson$1(Verification)), flatMap((verification) => map$1(pipe(fromResult(decode$3(verification.key)), flatMap((key) => tryPromise(() => crypto.subtle.importKey("raw", new Uint8Array(key), { name: "Ed25519" }, false, ["verify"])))), (publicKey) => ({
13843
+ publicKey,
13844
+ users: fromIterable$2(verification.users)
13845
+ }))), timeout("10 seconds"));
13846
+ const current = yield* make$35(yield* pipe(read, tapError$1((cause) => logWarning(`Cannot read the auth keys from ${url}`, cause)), retry(spaced("5 seconds"))));
13847
+ yield* pipe(read, flatMap((verification) => set(current, verification)), ignore$1({
13848
+ log: "Warn",
13849
+ message: `Cannot refresh the auth keys from ${url}`
13850
+ }), repeat(spaced("1 minute")), forkScoped);
13851
+ return provide(Auth.of({ verify: verifyWith(get$4(current)) }));
13852
+ })));
13853
+ };
13854
+ Service()("@deslop/auth/service/Issuer");
13855
+ const HttpAuth = middleware()(gen(function* () {
13856
+ const auth = yield* Auth;
13857
+ return (httpEffect) => gen(function* () {
13858
+ const user = yield* result$1(userFrom(auth, (yield* HttpServerRequest).headers));
13859
+ if (isFailure(user)) return yield* as$1(logWarning("Sign in first", user.failure), text$2("Sign in first", { status: 401 }));
13860
+ return yield* provideService(httpEffect, CurrentUser, user.success);
13861
+ });
13862
+ }));
13863
+ //#endregion
12980
13864
  //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/observability/OtlpExporter.js
12981
13865
  /**
12982
13866
  * Shared batch exporter for OTLP/HTTP observability modules.
@@ -13078,18 +13962,18 @@ const layerFlusher = /*#__PURE__*/ sync$1(Flusher, () => {
13078
13962
  */
13079
13963
  const make$10 = /*#__PURE__*/ fnUntraced(function* (options) {
13080
13964
  const services = yield* context();
13081
- const clock = get$5(services, Clock);
13082
- const scope = get$5(services, Scope);
13965
+ const clock = get$6(services, Clock);
13966
+ const scope = get$6(services, Scope);
13083
13967
  const exportInterval = max$1(fromInputUnsafe$1(options.exportInterval), zero$1);
13084
13968
  let disabledUntil = void 0;
13085
- const client = get$5(services, HttpClient).pipe(tap((response) => ignore$1(response.arrayBuffer)), tapError((error) => error.response ? ignore$1(error.response.arrayBuffer) : void_), filterStatusOk, transformResponse(provideService(TracerPropagationEnabled, false)), retryTransient({
13969
+ const client = get$6(services, HttpClient).pipe(tap((response) => ignore$1(response.arrayBuffer)), tapError((error) => error.response ? ignore$1(error.response.arrayBuffer) : void_), filterStatusOk, transformResponse(provideService(TracerPropagationEnabled, false)), retryTransient({
13086
13970
  schedule: policy,
13087
13971
  times: 3
13088
13972
  }));
13089
13973
  const exporterUserAgent = `OTel-OTLP-Exporter-JavaScript-Effect-${options.label}/${getCurrentVersion()}`;
13090
13974
  const userHeaders = fromInput$1(options.headers);
13091
13975
  const userAgent = userHeaders["user-agent"];
13092
- const headers = set$1(userHeaders, "user-agent", userAgent ? `${userAgent} ${exporterUserAgent}` : exporterUserAgent);
13976
+ const headers = set$3(userHeaders, "user-agent", userAgent ? `${userAgent} ${exporterUserAgent}` : exporterUserAgent);
13093
13977
  const request = post(options.url, { headers });
13094
13978
  let buffer = [];
13095
13979
  const runExport = suspend(() => {
@@ -13110,7 +13994,7 @@ const make$10 = /*#__PURE__*/ fnUntraced(function* (options) {
13110
13994
  package: "@effect/opentelemetry",
13111
13995
  module: options.label
13112
13996
  }));
13113
- const exportFibers = yield* make$20();
13997
+ const exportFibers = yield* make$21();
13114
13998
  const runExportFork = yield* runtime(exportFibers)();
13115
13999
  yield* (yield* Flusher).register(runExport);
13116
14000
  yield* addFinalizer(scope, suspend(() => {
@@ -13325,7 +14209,7 @@ const make$8 = /*#__PURE__*/ fnUntraced(function* (options) {
13325
14209
  excludeLogSpans: options.excludeLogSpans ?? false,
13326
14210
  clock: yield* Clock
13327
14211
  };
13328
- return make$38((options) => {
14212
+ return make$42((options) => {
13329
14213
  exporter.push(makeLogRecord(options, opts));
13330
14214
  });
13331
14215
  });
@@ -13450,7 +14334,7 @@ const layer$1 = /*#__PURE__*/ flow(/* @__PURE__ */ fnUntraced(function* (options
13450
14334
  if (!span.sampled) return;
13451
14335
  exporter.push(makeOtlpSpan(span));
13452
14336
  }
13453
- return make$39({
14337
+ return make$43({
13454
14338
  span(options) {
13455
14339
  return new SpanImpl(options, exportFn);
13456
14340
  },
@@ -13619,7 +14503,7 @@ function layerOtlp(serviceName, url) {
13619
14503
  }), layer$2({
13620
14504
  resource,
13621
14505
  url: new URL("/v1/logs", url).href
13622
- })), provide([layerJson, layer$6]));
14506
+ })), provide$1([layerJson, layer$6]));
13623
14507
  }
13624
14508
  //#endregion
13625
14509
  //#region ../../packages/runtime/src/server.ts
@@ -43302,33 +44186,33 @@ function clock(seconds$1) {
43302
44186
  function captionTranscript(input) {
43303
44187
  const cues = pipe(input.vtt, replaceAll(/\r\n?/gu, "\n"), split("\n\n"), flatMap$2((block) => {
43304
44188
  const lines = split(block, "\n");
43305
- return pipe(findFirstIndex(lines, includes("-->")), map$4((index) => {
43306
- 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));
44189
+ return pipe(findFirstIndex(lines, includes("-->")), map$5((index) => {
44190
+ const times = map$3(pipe(getUnsafe$2(lines, index), split(" --> ")), (time) => reduce(pipe(time, split(" "), headNonEmpty, split(":"), map$3(parse$10), getSomes), 0, (total, part) => total * 60 + part));
43307
44191
  return map$3(drop(lines, index + 1), (line) => ({
43308
44192
  end: lastNonEmpty(times),
43309
44193
  start: headNonEmpty(times),
43310
44194
  text: pipe(line, replaceAll(/<[^>]+>/gu, ""), replaceAll("&nbsp;", " "), replaceAll("&lt;", "<"), replaceAll("&gt;", ">"), replaceAll("&amp;", "&"), trim)
43311
44195
  }));
43312
44196
  }), getOrElse(empty$11));
43313
- }), filter$4((cue) => isNonEmpty(cue.text)));
43314
- return join$1(map$3(filter$4(cues, (cue, index) => pipe(get$6(cues, index - 1), match$1({
44197
+ }), filter$5((cue) => isNonEmpty(cue.text)));
44198
+ return join$1(map$3(filter$5(cues, (cue, index) => pipe(get$8(cues, index - 1), match$1({
43315
44199
  onNone: () => true,
43316
44200
  onSome: (previous) => input.authored || previous.text !== cue.text || previous.end < cue.start
43317
44201
  }))), (cue) => `[${clock(cue.start)}] ${cue.text}\n`), "");
43318
44202
  }
43319
44203
  const spoken = replace$1(/^\[[^\]]+\] /u, "");
43320
44204
  function speechOnly(transcript) {
43321
- const lines = pipe(split(transcript, "\n"), filter$4(isNonEmpty), dedupeAdjacentWith((left, right) => spoken(left) === spoken(right)), filter$4((line) => {
44205
+ const lines = pipe(split(transcript, "\n"), filter$5(isNonEmpty), dedupeAdjacentWith((left, right) => spoken(left) === spoken(right)), filter$5((line) => {
43322
44206
  const words = wordsOf(spoken(line));
43323
44207
  return isReadonlyArrayNonEmpty(words) && dedupe(words).length * 3 > words.length;
43324
44208
  }));
43325
44209
  const words = flatMap$2(lines, (line) => wordsOf(spoken(line)));
43326
- const seconds = pipe(last$1(lines), flatMap$1(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));
44210
+ const seconds = pipe(last$1(lines), flatMap$1(match$2(/^\[(\d+):(\d+)\]/u)), map$5((match) => [match[1] ?? "0", match[2] ?? "0"]), map$5((parts) => reduce(getSomes(map$3(parts, parse$10)), 0, (total, part) => total * 60 + part)), getOrElse(() => 0));
43327
44211
  if (words.length < 8 || words.length * 60 < 40 * max$2(seconds, 15)) return none();
43328
44212
  return some$1(join$1(map$3(lines, (line) => `${line}\n`), ""));
43329
44213
  }
43330
44214
  function wordsOf(text) {
43331
- return pipe(text, toLowerCase, split(/[^\p{L}\p{N}']+/u), filter$4(isNonEmpty));
44215
+ return pipe(text, toLowerCase, split(/[^\p{L}\p{N}']+/u), filter$5(isNonEmpty));
43332
44216
  }
43333
44217
  //#endregion
43334
44218
  //#region src/services/media/schema.ts
@@ -43360,11 +44244,11 @@ const Transcription = Struct({ chunks: ArraySchema(Struct({
43360
44244
  const MAX_WHISPER_SECONDS = 7200;
43361
44245
  const BLOCKED_ANSWER = /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;
43362
44246
  const run = fnUntraced(function* (command, args) {
43363
- const handle = yield* make$40(command, args, {
44247
+ const handle = yield* make$44(command, args, {
43364
44248
  stderr: "pipe",
43365
44249
  stdout: "pipe"
43366
44250
  });
43367
- return yield* all({
44251
+ return yield* all$1({
43368
44252
  exitCode: handle.exitCode,
43369
44253
  stderr: mkString(decodeText(handle.stderr)),
43370
44254
  stdout: mkUint8Array(handle.stdout)
@@ -43376,7 +44260,7 @@ var Media = class Media extends Service()("@deslop/stash/services/media/service/
43376
44260
  const path = yield* Path;
43377
44261
  const spawner = yield* ChildProcessSpawner;
43378
44262
  const cache = path.join(yield* pipe(String$2("XDG_CACHE_HOME"), withDefault(path.join(yield* String$2("HOME"), ".cache"))), "deslop", "media");
43379
- const whisper = yield* make$34(1);
44263
+ const whisper = yield* make$37(1);
43380
44264
  const ytDlpArgs = [
43381
44265
  "--js-runtimes",
43382
44266
  "node",
@@ -43436,8 +44320,8 @@ var Media = class Media extends Service()("@deslop/stash/services/media/service/
43436
44320
  }
43437
44321
  if (samples.length < 16e3) return none();
43438
44322
  env.cacheDir = path.join(cache, "models");
43439
- const spoken = map$4(input.language, (language) => pipe(language, split("-"), headNonEmpty));
43440
- const english = contains$1(spoken, "en");
44323
+ const spoken = map$5(input.language, (language) => pipe(language, split("-"), headNonEmpty));
44324
+ const english = contains$2(spoken, "en");
43441
44325
  const model = match(english, {
43442
44326
  onFalse: () => "onnx-community/whisper-small",
43443
44327
  onTrue: () => "onnx-community/whisper-small.en"
@@ -43462,7 +44346,7 @@ var Media = class Media extends Service()("@deslop/stash/services/media/service/
43462
44346
  });
43463
44347
  const transcribe = fnUntraced(function* (link, media) {
43464
44348
  const work = yield* fs.makeTempDirectoryScoped({ prefix: "deslop-media-" });
43465
- const language = pipe(fromNullishOr(media.automatic_captions), flatMap$1((captions) => findFirst(keys(captions), endsWith("-orig"))), map$4(replace$1(/-orig$/u, "")), orElse$2(() => fromNullishOr(media.language)), getOrElse(() => "en"));
44349
+ const language = pipe(fromNullishOr(media.automatic_captions), flatMap$1((captions) => findFirst(keys(captions), endsWith("-orig"))), map$5(replace$1(/-orig$/u, "")), orElse$2(() => fromNullishOr(media.language)), getOrElse(() => "en"));
43466
44350
  yield* fetch([
43467
44351
  ...ytDlpArgs,
43468
44352
  "--skip-download",
@@ -43479,8 +44363,8 @@ var Media = class Media extends Service()("@deslop/stash/services/media/service/
43479
44363
  link
43480
44364
  ]);
43481
44365
  const captions = `captions.${language}.vtt`;
43482
- if (contains$2(yield* fs.readDirectory(work), captions)) return some$1(captionTranscript({
43483
- authored: exists(fromNullishOr(media.subtitles), (subtitles) => has$3(subtitles, language)),
44366
+ if (contains$1(yield* fs.readDirectory(work), captions)) return some$1(captionTranscript({
44367
+ authored: exists(fromNullishOr(media.subtitles), (subtitles) => has$4(subtitles, language)),
43484
44368
  vtt: yield* fs.readFileString(path.join(work, captions))
43485
44369
  }));
43486
44370
  if (!exists(fromNullishOr(media.duration), (seconds) => seconds <= MAX_WHISPER_SECONDS)) {
@@ -43516,7 +44400,7 @@ var Media = class Media extends Service()("@deslop/stash/services/media/service/
43516
44400
  "csv=p=0",
43517
44401
  video
43518
44402
  ]);
43519
- const seconds = pipe(trim(new TextDecoder().decode(probe.stdout)), parse$10, filter$5((value) => value > 0), getOrElse(() => 6));
44403
+ const seconds = pipe(trim(new TextDecoder().decode(probe.stdout)), parse$10, filter$4((value) => value > 0), getOrElse(() => 6));
43520
44404
  const sampled = yield* run("ffmpeg", [
43521
44405
  "-v",
43522
44406
  "error",
@@ -43531,7 +44415,7 @@ var Media = class Media extends Service()("@deslop/stash/services/media/service/
43531
44415
  path.join(work, "frame-%02d.jpg")
43532
44416
  ]);
43533
44417
  if (sampled.exitCode !== 0) return yield* MediaError.make({ message: `ffmpeg cannot sample the video: ${sampled.stderr}` });
43534
- return yield* forEach(sort(filter$4(yield* fs.readDirectory(work), startsWith("frame-")), String$3), (file) => fs.readFile(path.join(work, file)), { concurrency: "unbounded" });
44418
+ return yield* forEach(sort(filter$5(yield* fs.readDirectory(work), startsWith("frame-")), String$3), (file) => fs.readFile(path.join(work, file)), { concurrency: "unbounded" });
43535
44419
  });
43536
44420
  return Media.of({
43537
44421
  fileFrames: fn$1("Media.fileFrames")(function* (file) {
@@ -43576,14 +44460,14 @@ var Media = class Media extends Service()("@deslop/stash/services/media/service/
43576
44460
  if (media._type === "playlist") return yield* MediaError.make({ message: "The link holds several videos." });
43577
44461
  const details = pipe([
43578
44462
  fromNullishOr(media.uploader),
43579
- map$4(fromNullishOr(media.upload_date), replace$1(/^(\d{4})(\d{2})(\d{2})$/u, "$1-$2-$3")),
43580
- map$4(fromNullishOr(media.duration), clock)
43581
- ], getSomes, filter$4(isNonEmpty));
44463
+ map$5(fromNullishOr(media.upload_date), replace$1(/^(\d{4})(\d{2})(\d{2})$/u, "$1-$2-$3")),
44464
+ map$5(fromNullishOr(media.duration), clock)
44465
+ ], getSomes, filter$5(isNonEmpty));
43582
44466
  return {
43583
44467
  info: join$1(getSomes([
43584
44468
  some$1(`# ${media.title}\n\n${join$1(details, ", ")}\n${link}`),
43585
- pipe(fromNullishOr(media.description), filter$5(isNonEmpty), map$4((description) => `## Description\n\n${description}`)),
43586
- map$4(fromNullishOr(media.chapters), (chapters) => `## Chapters\n\n${join$1(map$3(chapters, (chapter) => `- [${clock(chapter.start_time)}] ${chapter.title}`), "\n")}`)
44469
+ pipe(fromNullishOr(media.description), filter$4(isNonEmpty), map$5((description) => `## Description\n\n${description}`)),
44470
+ map$5(fromNullishOr(media.chapters), (chapters) => `## Chapters\n\n${join$1(map$3(chapters, (chapter) => `- [${clock(chapter.start_time)}] ${chapter.title}`), "\n")}`)
43587
44471
  ]), "\n\n"),
43588
44472
  transcript: withProcesses(scoped(transcribe(link, media)))
43589
44473
  };
@@ -90112,18 +90996,18 @@ function withoutTrailingPunctuation(link) {
90112
90996
  }
90113
90997
  function canonicalUrl(link) {
90114
90998
  const url = new URL(link);
90115
- if (contains$2(X_HOSTS, url.hostname)) url.hostname = "x.com";
90999
+ if (contains$1(X_HOSTS, url.hostname)) url.hostname = "x.com";
90116
91000
  if (sourceFor(url.href) === "Website") for (const key of TRACKING_PARAMETERS) url.searchParams.delete(key);
90117
91001
  else url.search = "";
90118
91002
  url.hash = "";
90119
91003
  return url.href;
90120
91004
  }
90121
91005
  function captureUrl(text) {
90122
- return pipe(match$2(URL_PATTERN)(text), flatMap$1(head), map$4(withoutTrailingPunctuation), flatMap$1(liftThrowable(canonicalUrl)), getOrUndefined);
91006
+ return pipe(match$2(URL_PATTERN)(text), flatMap$1(head), map$5(withoutTrailingPunctuation), flatMap$1(liftThrowable(canonicalUrl)), getOrUndefined);
90123
91007
  }
90124
91008
  function sourceFor(url) {
90125
91009
  const host = new URL(url).hostname;
90126
- if (contains$2(X_HOSTS, host) || host === "t.co") return "X";
91010
+ if (contains$1(X_HOSTS, host) || host === "t.co") return "X";
90127
91011
  if (host === "tiktok.com" || endsWith(".tiktok.com")(host)) return "TikTok";
90128
91012
  return "Website";
90129
91013
  }
@@ -90142,7 +91026,7 @@ function plainText(text) {
90142
91026
  return pipe(text, replaceAll(/\s+/gu, " "), trim);
90143
91027
  }
90144
91028
  function normalizeTags(tags) {
90145
- return pipe(tags, map$3((tag) => pipe(tag, toLowerCase, plainText, replace$1(/^#+/u, ""), replaceAll(" ", "-"))), filter$4(isNonEmpty), dedupe);
91029
+ return pipe(tags, map$3((tag) => pipe(tag, toLowerCase, plainText, replace$1(/^#+/u, ""), replaceAll(" ", "-"))), filter$5(isNonEmpty), dedupe);
90146
91030
  }
90147
91031
  function tagCounts(notes) {
90148
91032
  return pipe(flatMap$2(notes, (note) => note.tags), groupBy((tag) => tag), toEntries, map$3((entry) => ({
@@ -90151,20 +91035,20 @@ function tagCounts(notes) {
90151
91035
  })), sort(combine$1(mapInput(flip(Number$1), (entry) => entry.count), mapInput(String$3, (entry) => entry.tag))));
90152
91036
  }
90153
91037
  function diff(previous, next) {
90154
- const before = fromIterable$2(map$3(previous, (note) => [note.id, note]));
90155
- const ids = fromIterable$3(map$3(next, (note) => note.id));
91038
+ const before = fromIterable$3(map$3(previous, (note) => [note.id, note]));
91039
+ const ids = fromIterable$2(map$3(next, (note) => note.id));
90156
91040
  return {
90157
- removed: filter$4(map$3(previous, (note) => note.id), (id) => !has$4(ids, id)),
90158
- upserted: filter$4(next, (note) => !exists(get$7(before, note.id), (old) => old === note))
91041
+ removed: filter$5(map$3(previous, (note) => note.id), (id) => !has$3(ids, id)),
91042
+ upserted: filter$5(next, (note) => !exists(get$9(before, note.id), (old) => old === note))
90159
91043
  };
90160
91044
  }
90161
91045
  function findNotes(notes, query) {
90162
- const words = pipe(query, toLowerCase, split(/\s+/u), filter$4(isNonEmpty));
90163
- const tags = pipe(words, filter$4(startsWith("#")), map$3(slice$2(1)), filter$4(isNonEmpty));
90164
- const terms = filter$4(words, (word) => !startsWith("#")(word));
91046
+ const words = pipe(query, toLowerCase, split(/\s+/u), filter$5(isNonEmpty));
91047
+ const tags = pipe(words, filter$5(startsWith("#")), map$3(slice$2(1)), filter$5(isNonEmpty));
91048
+ const terms = filter$5(words, (word) => !startsWith("#")(word));
90165
91049
  if (isReadonlyArrayEmpty(words)) return notes;
90166
- return filter$4(notes, (note) => {
90167
- if (!every(tags, (tag) => contains$2(note.tags, tag))) return false;
91050
+ return filter$5(notes, (note) => {
91051
+ if (!every(tags, (tag) => contains$1(note.tags, tag))) return false;
90168
91052
  const haystack = pipe([
90169
91053
  note.title,
90170
91054
  note.summary,
@@ -90177,7 +91061,7 @@ function findNotes(notes, query) {
90177
91061
  note.transcript,
90178
91062
  note.url,
90179
91063
  ...note.tags
90180
- ], filter$4(isNotUndefined), join$1(" "), toLowerCase);
91064
+ ], filter$5(isNotUndefined), join$1(" "), toLowerCase);
90181
91065
  return every(terms, (term) => includes(term)(haystack));
90182
91066
  });
90183
91067
  }
@@ -90231,7 +91115,7 @@ const load = fnUntraced(function* (url, read) {
90231
91115
  if (!every(addresses, isPublic)) return yield* NotesError.make({ message: "The link points to a private network." });
90232
91116
  const address = formatIp(headNonEmpty(addresses));
90233
91117
  const session = `${yield* nextIntBetween(1e7, 99999999)}`;
90234
- const proxy = map$4(yield* Exit, (exit) => sticky(exit, session));
91118
+ const proxy = map$5(yield* Exit, (exit) => sticky(exit, session));
90235
91119
  return yield* pipe(get$2(url, { headers: {
90236
91120
  accept: "text/html,application/json,image/*",
90237
91121
  "accept-language": "en-US,en;q=0.9",
@@ -90241,7 +91125,7 @@ const load = fnUntraced(function* (url, read) {
90241
91125
  location: response.headers["location"],
90242
91126
  status: response.status,
90243
91127
  type: response.headers["content-type"] ?? ""
90244
- }))), scoped, provide$2(pipe(layerNodeHttpNoAgent, provide(match$1(proxy, {
91128
+ }))), scoped, provide$3(pipe(layerNodeHttpNoAgent, provide$1(match$1(proxy, {
90245
91129
  onNone: () => layerAgentOptions({
90246
91130
  autoSelectFamily: false,
90247
91131
  lookup: (_hostname, _options, callback) => callback(null, address, 4)
@@ -90258,7 +91142,7 @@ const load = fnUntraced(function* (url, read) {
90258
91142
  });
90259
91143
  const follow = fnUntraced(function* (url, read, hops) {
90260
91144
  const proxied = isSome(yield* Exit);
90261
- const answer = yield* pipe(load(url, read), filterOrFail((found) => !proxied || !contains$2([
91145
+ const answer = yield* pipe(load(url, read), filterOrFail((found) => !proxied || !contains$1([
90262
91146
  403,
90263
91147
  429,
90264
91148
  500,
@@ -90284,14 +91168,14 @@ const follow = fnUntraced(function* (url, read, hops) {
90284
91168
  })
90285
91169
  });
90286
91170
  });
90287
- const decode$1 = fnUntraced(function* (schema, url) {
91171
+ const decode = fnUntraced(function* (schema, url) {
90288
91172
  return yield* pipe(decodeEffect(fromJsonString(schema))((yield* follow(url, api, 0)).body), mapError((cause) => NotesError.make({
90289
91173
  cause,
90290
91174
  message: "The source answered in an unknown format."
90291
91175
  })));
90292
91176
  });
90293
91177
  const resolve = fnUntraced(function* (url, hops) {
90294
- if (!contains$2([
91178
+ if (!contains$1([
90295
91179
  "vm.tiktok.com",
90296
91180
  "vt.tiktok.com",
90297
91181
  "t.co"
@@ -90304,7 +91188,7 @@ function canonical(url) {
90304
91188
  return captureUrl(url.href) ?? url.href;
90305
91189
  }
90306
91190
  const fromOEmbed = fnUntraced(function* (endpoint, url, title) {
90307
- const embed = yield* decode$1(OEmbed, new URL(`${endpoint}${encodeURIComponent(url.href)}`));
91191
+ const embed = yield* decode(OEmbed, new URL(`${endpoint}${encodeURIComponent(url.href)}`));
90308
91192
  return Extraction.make({
90309
91193
  author: fromUndefinedOr(embed.author_name),
90310
91194
  image: fromNullishOr(embed.thumbnail_url),
@@ -90314,7 +91198,7 @@ const fromOEmbed = fnUntraced(function* (endpoint, url, title) {
90314
91198
  });
90315
91199
  });
90316
91200
  const xOEmbed = fnUntraced(function* (url) {
90317
- const embed = yield* decode$1(OEmbed, new URL(`https://publish.x.com/oembed?omit_script=true&dnt=true&url=${encodeURIComponent(url.href)}`));
91201
+ const embed = yield* decode(OEmbed, new URL(`https://publish.x.com/oembed?omit_script=true&dnt=true&url=${encodeURIComponent(url.href)}`));
90318
91202
  return Extraction.make({
90319
91203
  author: fromUndefinedOr(embed.author_name),
90320
91204
  image: none(),
@@ -90326,7 +91210,7 @@ const xOEmbed = fnUntraced(function* (url) {
90326
91210
  function articleText(article) {
90327
91211
  const lines = filterMap(article.content.blocks, (block) => {
90328
91212
  const attached = pipe(block.entityRanges, filterMap((range) => fromOption$1(pipe(findFirst(article.content.entityMap, (entity) => entity.key === `${range.key}`), flatMapNullishOr((entity) => entity.value.data.markdown ?? entity.value.data.url)), () => void 0)));
90329
- const text = pipe([trim(block.text), ...attached], filter$4(isNonEmpty), join$1(" "));
91213
+ const text = pipe([trim(block.text), ...attached], filter$5(isNonEmpty), join$1(" "));
90330
91214
  if (isEmpty$2(text)) return failVoid;
90331
91215
  return succeed(pipe(value(block.type), when("header-one", () => `# ${text}`), when("header-two", () => `## ${text}`), when("header-three", () => `### ${text}`), when("unordered-list-item", () => `- ${text}`), when("ordered-list-item", () => `1. ${text}`), when("blockquote", () => `> ${text}`), orElse(() => text)));
90332
91216
  });
@@ -90337,27 +91221,27 @@ function said(post) {
90337
91221
  return pipe([`**${post.author.name} (@${post.author.screen_name})**: ${plainText(post.text)}`, match$1(fromNullishOr(post.article), {
90338
91222
  onNone: () => "",
90339
91223
  onSome: articleText
90340
- })], filter$4(isNonEmpty), join$1("\n\n"));
91224
+ })], filter$5(isNonEmpty), join$1("\n\n"));
90341
91225
  }
90342
91226
  function section(title, posts) {
90343
91227
  if (isReadonlyArrayEmpty(posts)) return "";
90344
91228
  return `## ${title}\n\n${join$1(map$3(posts, said), "\n\n")}`;
90345
91229
  }
90346
91230
  const xThread = fnUntraced(function* (url) {
90347
- const id = yield* pipe(match$2(/\/status\/(\d+)/u)(url.pathname), flatMap$1((match) => get$6(match, 1)), fromOption, mapError(() => NotesError.make({ message: "The link names no post." })));
90348
- const conversation = yield* decode$1(FxConversation, new URL(`https://api.fxtwitter.com/2/conversation/${id}`));
91231
+ const id = yield* pipe(match$2(/\/status\/(\d+)/u)(url.pathname), flatMap$1((match) => get$8(match, 1)), fromOption, mapError(() => NotesError.make({ message: "The link names no post." })));
91232
+ const conversation = yield* decode(FxConversation, new URL(`https://api.fxtwitter.com/2/conversation/${id}`));
90349
91233
  const status = conversation.status;
90350
91234
  const quote = fromNullishOr(status.quote);
90351
91235
  const media = flatMap$2([status, ...toArray$1(quote)], (post) => post.media?.all ?? []);
90352
91236
  const replies = conversation.replies ?? [];
90353
- const linked = yield* forEach(pipe(status.raw_text?.facets ?? [], filterMap((facet) => fromOption$1(pipe(fromNullishOr(facet.replacement), flatMap$1(match$2(/(?:x|twitter)\.com\/[^/]+\/status\/(\d+)/u)), flatMap$1((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)), { concurrency: "unbounded" });
91237
+ const linked = yield* forEach(pipe(status.raw_text?.facets ?? [], filterMap((facet) => fromOption$1(pipe(fromNullishOr(facet.replacement), flatMap$1(match$2(/(?:x|twitter)\.com\/[^/]+\/status\/(\d+)/u)), flatMap$1((match) => get$8(match, 1))), () => void 0)), filter$5((linkedId) => linkedId !== status.id && !exists(quote, (post) => post.id === linkedId)), dedupe, take$1(5)), (linkedId) => option$1(map$1(decode(FxStatus, new URL(`https://api.fxtwitter.com/2/status/${linkedId}`)), (found) => found.status)), { concurrency: "unbounded" });
90354
91238
  return Extraction.make({
90355
91239
  author: some$1(status.author.name),
90356
- image: map$4(head(media), (item) => item.thumbnail_url ?? item.url),
91240
+ image: map$5(head(media), (item) => item.thumbnail_url ?? item.url),
90357
91241
  text: pipe([
90358
- section("Earlier in the conversation", sort(filter$4(conversation.thread ?? [], (post) => post.id !== status.id), byTime)),
91242
+ section("Earlier in the conversation", sort(filter$5(conversation.thread ?? [], (post) => post.id !== status.id), byTime)),
90359
91243
  plainText(status.text),
90360
- ...pipe(filter$4(replies, (post) => post.author.id === status.author.id), sort(byTime), map$3((post) => plainText(post.text))),
91244
+ ...pipe(filter$5(replies, (post) => post.author.id === status.author.id), sort(byTime), map$3((post) => plainText(post.text))),
90361
91245
  match$1(quote, {
90362
91246
  onNone: () => "",
90363
91247
  onSome: (post) => `Quoting ${said(post)}`
@@ -90367,8 +91251,8 @@ const xThread = fnUntraced(function* (url) {
90367
91251
  onSome: articleText
90368
91252
  }),
90369
91253
  section("Linked posts", getSomes(linked)),
90370
- section("Replies", take$1(filter$4(replies, (post) => post.author.id !== status.author.id), 30))
90371
- ], filter$4(isNonEmpty), join$1("\n\n")),
91254
+ section("Replies", take$1(filter$5(replies, (post) => post.author.id !== status.author.id), 30))
91255
+ ], filter$5(isNonEmpty), join$1("\n\n")),
90372
91256
  title: `${status.author.name} on X`,
90373
91257
  url: canonical(url),
90374
91258
  ...pipe(findFirst(media, (item) => item.type === "video" || item.type === "gif"), match$1({
@@ -90388,43 +91272,43 @@ const tikTokPhotos = fnUntraced(function* (url) {
90388
91272
  author: some$1(item.author.nickname),
90389
91273
  image: head(images),
90390
91274
  slides: drop(images, 1),
90391
- text: pipe([item.imagePost.title, item.desc], filter$4(isNotUndefined), map$3(plainText), filter$4(isNonEmpty), join$1("\n")),
91275
+ text: pipe([item.imagePost.title, item.desc], filter$5(isNotUndefined), map$3(plainText), filter$5(isNonEmpty), join$1("\n")),
90392
91276
  title: `${item.author.nickname} on TikTok`,
90393
91277
  url: canonical(url)
90394
91278
  });
90395
91279
  });
90396
91280
  const issue = fnUntraced(function* (url, repository, number) {
90397
- const found = yield* decode$1(GitHubIssue, new URL(`https://api.github.com/repos/${repository}/issues/${number}`));
90398
- const comments = yield* decode$1(ArraySchema(GitHubComment), new URL(`https://api.github.com/repos/${repository}/issues/${number}/comments?per_page=100`));
91281
+ const found = yield* decode(GitHubIssue, new URL(`https://api.github.com/repos/${repository}/issues/${number}`));
91282
+ const comments = yield* decode(ArraySchema(GitHubComment), new URL(`https://api.github.com/repos/${repository}/issues/${number}/comments?per_page=100`));
90399
91283
  return Extraction.make({
90400
91284
  author: some$1(found.user.login),
90401
91285
  image: some$1(`https://opengraph.githubassets.com/1/${repository}/issues/${number}`),
90402
- text: pipe([found, ...comments], map$3((post) => map$4(fromNullishOr(post.body), (body) => `**${post.user.login}**: ${body}`)), getSomes, prepend$2(`# ${found.title} (${found.state})`), join$1("\n\n")),
91286
+ text: pipe([found, ...comments], map$3((post) => map$5(fromNullishOr(post.body), (body) => `**${post.user.login}**: ${body}`)), getSomes, prepend$2(`# ${found.title} (${found.state})`), join$1("\n\n")),
90403
91287
  title: found.title,
90404
91288
  url: canonical(url)
90405
91289
  });
90406
91290
  });
90407
91291
  const repository = fnUntraced(function* (url, name) {
90408
- const found = yield* decode$1(GitHubRepo, new URL(`https://api.github.com/repos/${name}`));
90409
- const readme = yield* pipe(decode$1(GitHubReadme, new URL(`https://api.github.com/repos/${name}/readme`)), flatMap((file) => follow(new URL(file.download_url), api, 0)), map$1((file) => file.body), option$1);
91292
+ const found = yield* decode(GitHubRepo, new URL(`https://api.github.com/repos/${name}`));
91293
+ const readme = yield* pipe(decode(GitHubReadme, new URL(`https://api.github.com/repos/${name}/readme`)), flatMap((file) => follow(new URL(file.download_url), api, 0)), map$1((file) => file.body), option$1);
90410
91294
  return Extraction.make({
90411
91295
  author: some$1(found.owner.login),
90412
91296
  image: some$1(`https://opengraph.githubassets.com/1/${name}`),
90413
91297
  text: pipe([
90414
91298
  fromNullishOr(found.description),
90415
- pipe(fromNullishOr(found.topics), filter$5(isReadonlyArrayNonEmpty), map$4((topics) => `Topics: ${join$1(topics, ", ")}`)),
91299
+ pipe(fromNullishOr(found.topics), filter$4(isReadonlyArrayNonEmpty), map$5((topics) => `Topics: ${join$1(topics, ", ")}`)),
90416
91300
  fromNullishOr(found.homepage),
90417
91301
  readme
90418
- ], getSomes, filter$4(isNonEmpty), join$1("\n\n")),
91302
+ ], getSomes, filter$5(isNonEmpty), join$1("\n\n")),
90419
91303
  title: found.full_name,
90420
91304
  url: canonical(url)
90421
91305
  });
90422
91306
  });
90423
91307
  const gitHub = fnUntraced(function* (url) {
90424
- const path = filter$4(split(url.pathname, "/"), isNonEmpty);
91308
+ const path = filter$5(split(url.pathname, "/"), isNonEmpty);
90425
91309
  const name = join$1(take$1(path, 2), "/");
90426
91310
  if (path.length === 2) return yield* repository(url, name);
90427
- return yield* pipe(all$1([get$6(path, 2), get$6(path, 3)]), filter$5((parts) => parts[0] === "issues" || parts[0] === "pull"), match$1({
91311
+ return yield* pipe(all$2([get$8(path, 2), get$8(path, 3)]), filter$4((parts) => parts[0] === "issues" || parts[0] === "pull"), match$1({
90428
91312
  onNone: () => fail$1(NotesError.make({ message: "The GitHub page is neither a repository nor an issue." })),
90429
91313
  onSome: (parts) => issue(url, name, parts[1])
90430
91314
  }));
@@ -90440,7 +91324,7 @@ function markdown($, node, base) {
90440
91324
  "h4",
90441
91325
  "h5",
90442
91326
  "h6"
90443
- ], (heading) => heading === node.tagName), map$4((index) => `\n\n${repeat$1(index + 1)("#")} ${trim(inner)}\n\n`), getOrElse(() => element($, {
91327
+ ], (heading) => heading === node.tagName), map$5((index) => `\n\n${repeat$1(index + 1)("#")} ${trim(inner)}\n\n`), getOrElse(() => element($, {
90444
91328
  base,
90445
91329
  inner,
90446
91330
  node,
@@ -90455,10 +91339,10 @@ function element($, input) {
90455
91339
  onTrue: () => `${$(input.node).index() + 1}.`
90456
91340
  });
90457
91341
  return `\n${repeat$1($(input.node).parents("ul, ol").length - 1)(" ")}${marker} ${text}`;
90458
- }), when("pre", () => `\n\n\`\`\`\n${$(input.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($(input.node).attr("href")), flatMap$1(liftThrowable((href) => new URL(href, input.base))), filter$5((link) => (link.protocol === "https:" || link.protocol === "http:") && isNonEmpty(text)), match$1({
91342
+ }), when("pre", () => `\n\n\`\`\`\n${$(input.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($(input.node).attr("href")), flatMap$1(liftThrowable((href) => new URL(href, input.base))), filter$4((link) => (link.protocol === "https:" || link.protocol === "http:") && isNonEmpty(text)), match$1({
90459
91343
  onNone: () => input.inner,
90460
91344
  onSome: (link) => `[${text}](${link.href})`
90461
- }))), when((name) => contains$2(BLOCK_TAGS, name), () => `\n\n${text}\n\n`), orElse(() => input.inner));
91345
+ }))), when((name) => contains$1(BLOCK_TAGS, name), () => `\n\n${text}\n\n`), orElse(() => input.inner));
90462
91346
  }
90463
91347
  function pageText(html, url) {
90464
91348
  const $ = load$1(html);
@@ -90474,15 +91358,15 @@ function pageText(html, url) {
90474
91358
  onTrue: () => part
90475
91359
  })), join$1("```"), trim);
90476
91360
  return Extraction.make({
90477
- author: pipe(fromUndefinedOr($("meta[property=\"og:site_name\"]").attr("content")), map$4(plainText), filter$5(isNonEmpty), orElseSome(() => url.hostname)),
91361
+ author: pipe(fromUndefinedOr($("meta[property=\"og:site_name\"]").attr("content")), map$5(plainText), filter$4(isNonEmpty), orElseSome(() => url.hostname)),
90478
91362
  image: pipe(fromNullishOr($("meta[property=\"og:image\"]").attr("content") ?? $("meta[name=\"twitter:image\"]").attr("content")), flatMap$1(liftThrowable((image) => new URL(image, url).href))),
90479
- text: pipe([map$4(fromUndefinedOr(description), plainText), some$1(body)], getSomes, filter$4(isNonEmpty), join$1("\n\n")),
91363
+ text: pipe([map$5(fromUndefinedOr(description), plainText), some$1(body)], getSomes, filter$5(isNonEmpty), join$1("\n\n")),
90480
91364
  title: plainText($("meta[property=\"og:title\"]").attr("content") ?? $("title").first().text()),
90481
91365
  url: canonical(url)
90482
91366
  });
90483
91367
  }
90484
91368
  const reader = fnUntraced(function* (url) {
90485
- const answer = yield* pipe(decode$1(Reader, new URL(`https://r.jina.ai/${url.href}`)), timeLimit("30 seconds", "The reader took too long."));
91369
+ const answer = yield* pipe(decode(Reader, new URL(`https://r.jina.ai/${url.href}`)), timeLimit("30 seconds", "The reader took too long."));
90486
91370
  if (CHALLENGE.test(answer.data.content) || isEmpty$2(trim(answer.data.content))) return yield* NotesError.make({ message: "The site blocks automated reading." });
90487
91371
  return Extraction.make({
90488
91372
  author: some$1(url.hostname),
@@ -90535,7 +91419,7 @@ var Sources = class Sources extends Service()("@deslop/stash/services/notes/lib/
90535
91419
  try: () => new URL(link)
90536
91420
  });
90537
91421
  const image = yield* follow(url, readBytes, 0);
90538
- 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." })));
91422
+ const type = yield* pipe(image.type, split(";"), head, map$5(trim), filter$4(is$4(ImageType)), fromOption, mapError(() => NotesError.make({ message: "The preview is not a JPEG, PNG, WebP or GIF image." })));
90539
91423
  return {
90540
91424
  bytes: image.body,
90541
91425
  type
@@ -90548,328 +91432,6 @@ var Sources = class Sources extends Service()("@deslop/stash/services/notes/lib/
90548
91432
  }));
90549
91433
  };
90550
91434
  //#endregion
90551
- //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/encoding/Sse.js
90552
- const SseErrorTypeId = "~effect/encoding/Sse/SseError";
90553
- /**
90554
- * Error reason raised when pending Server-Sent Events state exceeds the
90555
- * configured maximum size.
90556
- *
90557
- * @stability unstable
90558
- * @category errors
90559
- * @since 4.0.0
90560
- */
90561
- var EventTooLarge = class extends (/*#__PURE__*/ TaggedError("EventTooLarge")) {
90562
- get message() {
90563
- return `Pending SSE event exceeded the maximum size of ${this.maxEventSize}`;
90564
- }
90565
- };
90566
- /**
90567
- * Error raised when decoding a Server-Sent Events stream fails.
90568
- *
90569
- * @stability unstable
90570
- * @category errors
90571
- * @since 4.0.0
90572
- */
90573
- var SseError = class extends (/*#__PURE__*/ TaggedError("SseError")) {
90574
- /**
90575
- * Marks this value as an SSE decoding error.
90576
- *
90577
- * @stability unstable
90578
- * @since 4.0.0
90579
- */
90580
- [SseErrorTypeId] = SseErrorTypeId;
90581
- /**
90582
- * Delegates the public message to the underlying SSE error reason.
90583
- *
90584
- * @stability unstable
90585
- * @since 4.0.0
90586
- */
90587
- get message() {
90588
- return this.reason.message;
90589
- }
90590
- };
90591
- const defaultMaxEventSize = 10485760;
90592
- /**
90593
- * Creates a channel that parses Server-Sent Events text chunks into `Event` values.
90594
- *
90595
- * **Details**
90596
- *
90597
- * SSE `retry` directives are emitted as `Retry` failures so callers can
90598
- * reconnect with the requested delay.
90599
- *
90600
- * @stability unstable
90601
- * @category decoding
90602
- * @since 4.0.0
90603
- */
90604
- const decode = (options) => fromTransform((upstream, _scope) => sync(() => {
90605
- let buffer = [];
90606
- let retry;
90607
- const parser = makeParser((event) => {
90608
- if (event._tag === "Retry") retry = event;
90609
- else buffer.push(event);
90610
- }, options);
90611
- const pump = flatMap(upstream, (arr) => {
90612
- for (let i = 0; i < arr.length; i++) {
90613
- const error = parser.feed(arr[i]);
90614
- if (error !== void 0) return fail$1(error);
90615
- }
90616
- return void_;
90617
- });
90618
- return suspend(function loop() {
90619
- if (isArrayNonEmpty(buffer)) {
90620
- const out = buffer;
90621
- buffer = [];
90622
- return succeed$1(out);
90623
- } else if (retry) return fail$1(retry);
90624
- return flatMap(pump, loop);
90625
- });
90626
- }));
90627
- /**
90628
- * Creates an SSE decoder channel that decodes each parsed event with a schema.
90629
- *
90630
- * **Details**
90631
- *
90632
- * The schema receives `{ event, data, id? }`, with string `data`. Absent IDs are
90633
- * omitted, even with default options: use `Schema.optional(Schema.String)`, not
90634
- * `Schema.UndefinedOr(Schema.String)`, to accept events without an ID.
90635
- *
90636
- * With `onExcessProperty: "error"`, declare `event` (default: `"message"`) and
90637
- * `id` if the stream carries IDs, including inherited IDs.
90638
- *
90639
- * @stability unstable
90640
- * @category decoding
90641
- * @since 4.0.0
90642
- */
90643
- const decodeSchema = (schema, options, parseOptions) => pipeTo(decode(options), decode$2(Event$1.pipe(decodeTo(schema, transformEvent)), parseOptions)());
90644
- /**
90645
- * Creates an SSE decoder channel that JSON-decodes each event `data` field with a schema.
90646
- *
90647
- * **Details**
90648
- *
90649
- * The output preserves the SSE `event` name and optional `id` while replacing
90650
- * `data` with the decoded value.
90651
- *
90652
- * @stability unstable
90653
- * @category decoding
90654
- * @since 4.0.0
90655
- */
90656
- const decodeDataSchema = (schema, options) => {
90657
- const eventSchema = Struct({
90658
- ...EventEncoded.fields,
90659
- data: fromJsonString(schema)
90660
- });
90661
- return pipeTo(decode(options), map$5(decode$2(eventSchema)(), map$3((event) => ({
90662
- ...event,
90663
- id: event.id
90664
- }))));
90665
- };
90666
- /**
90667
- * Creates a stateful Server-Sent Events parser.
90668
- *
90669
- * **Details**
90670
- *
90671
- * Call `feed` with text chunks to parse `Event` and `Retry` values through the
90672
- * callback, and call `reset` to clear any buffered event state. `feed` returns
90673
- * an `SseError` if the pending event exceeds `maxEventSize`.
90674
- *
90675
- * @stability unstable
90676
- * @category decoding
90677
- * @since 4.0.0
90678
- */
90679
- function makeParser(onParse, options) {
90680
- const maxEventSize = options?.maxEventSize ?? defaultMaxEventSize;
90681
- const dispatchEmptyNamedEvents = options?.dispatchEmptyNamedEvents === true;
90682
- let isFirstChunk;
90683
- let pending;
90684
- let pendingLength;
90685
- let discardTrailingNewline;
90686
- let generation = 0;
90687
- let lastEventId;
90688
- let eventName;
90689
- let data;
90690
- reset();
90691
- return {
90692
- feed,
90693
- reset
90694
- };
90695
- function reset() {
90696
- generation++;
90697
- isFirstChunk = true;
90698
- pending = [];
90699
- pendingLength = 0;
90700
- discardTrailingNewline = false;
90701
- lastEventId = void 0;
90702
- eventName = void 0;
90703
- data = "";
90704
- }
90705
- function feed(chunk) {
90706
- if (isFirstChunk && chunk.startsWith(BOM)) chunk = chunk.slice(BOM.length);
90707
- isFirstChunk = false;
90708
- const length = chunk.length;
90709
- const currentGeneration = generation;
90710
- let position = 0;
90711
- while (position < length) {
90712
- if (discardTrailingNewline) {
90713
- discardTrailingNewline = false;
90714
- if (chunk.charCodeAt(position) === LF) {
90715
- ++position;
90716
- continue;
90717
- }
90718
- }
90719
- let lineEnd = position;
90720
- while (lineEnd < length) {
90721
- const code = chunk.charCodeAt(lineEnd);
90722
- if (code === CR || code === LF) break;
90723
- ++lineEnd;
90724
- }
90725
- if (lineEnd === length) {
90726
- pending.push(chunk.slice(position));
90727
- pendingLength += length - position;
90728
- break;
90729
- }
90730
- discardTrailingNewline = chunk.charCodeAt(lineEnd) === CR;
90731
- let line = chunk.slice(position, lineEnd);
90732
- if (pending.length > 0) {
90733
- pending.push(line);
90734
- line = pending.join("");
90735
- pending = [];
90736
- pendingLength = 0;
90737
- }
90738
- parseLine(line);
90739
- if (generation !== currentGeneration) return;
90740
- position = lineEnd + 1;
90741
- }
90742
- if (pendingLength + data.length > maxEventSize) {
90743
- const error = new SseError({ reason: new EventTooLarge({ maxEventSize }) });
90744
- reset();
90745
- return error;
90746
- }
90747
- }
90748
- function parseLine(line) {
90749
- if (line.length === 0) {
90750
- const named = eventName !== void 0 && eventName !== "";
90751
- const event = eventName || "message";
90752
- const eventData = data;
90753
- eventName = void 0;
90754
- data = "";
90755
- if (eventData.length > 0 || dispatchEmptyNamedEvents && named) onParse({
90756
- _tag: "Event",
90757
- id: lastEventId,
90758
- event,
90759
- data: eventData.slice(0, -1)
90760
- });
90761
- return;
90762
- }
90763
- const colon = line.indexOf(":");
90764
- let field = line;
90765
- let value = "";
90766
- if (colon >= 0) {
90767
- field = line.slice(0, colon);
90768
- value = line.slice(line.charCodeAt(colon + 1) === SPACE ? colon + 2 : colon + 1);
90769
- }
90770
- if (field === "data") data += value + "\n";
90771
- else if (field === "event") eventName = value;
90772
- else if (field === "id" && !value.includes("\0")) lastEventId = value;
90773
- else if (field === "retry" && /^\d+$/.test(value)) onParse(new Retry({
90774
- duration: millis(parseInt(value, 10)),
90775
- lastEventId
90776
- }));
90777
- }
90778
- }
90779
- const BOM = "";
90780
- const LF = 10;
90781
- const CR = 13;
90782
- const SPACE = 32;
90783
- /**
90784
- * Schema for the untagged Server-Sent Events payload shape containing an optional `id`, `event`, and string `data` fields.
90785
- *
90786
- * @stability unstable
90787
- * @category models
90788
- * @since 4.0.0
90789
- */
90790
- const EventEncoded = /*#__PURE__*/ Struct({
90791
- id: /*#__PURE__*/ optional$1(String$1),
90792
- event: String$1,
90793
- data: String$1
90794
- });
90795
- /**
90796
- * Schema for the tagged Server-Sent Events message model that adds `_tag: "Event"` to the event name, optional event ID, and string data payload.
90797
- *
90798
- * @stability unstable
90799
- * @category models
90800
- * @since 4.0.0
90801
- */
90802
- const Event$1 = /*#__PURE__*/ Struct({
90803
- _tag: /*#__PURE__*/ tag("Event"),
90804
- id: /*#__PURE__*/ UndefinedOr(String$1),
90805
- event: String$1,
90806
- data: String$1
90807
- });
90808
- /**
90809
- * Schema for transforming untagged SSE event payloads into tagged `Event`
90810
- * models.
90811
- *
90812
- * @stability unstable
90813
- * @category models
90814
- * @since 4.0.0
90815
- */
90816
- const transformEvent = /*#__PURE__*/ transform$1({
90817
- decode: (event) => event.id === void 0 ? {
90818
- event: event.event,
90819
- data: event.data
90820
- } : {
90821
- id: event.id,
90822
- event: event.event,
90823
- data: event.data
90824
- },
90825
- encode: (event) => ({
90826
- _tag: "Event",
90827
- id: event.id,
90828
- event: event.event ?? "message",
90829
- data: event.data
90830
- })
90831
- });
90832
- const RetryTypeId = "~effect/encoding/Sse/Retry";
90833
- /**
90834
- * Represents a Server-Sent Events retry directive.
90835
- *
90836
- * **Details**
90837
- *
90838
- * Decoders surface this value as a failure to request reconnection after
90839
- * `duration`; encoders serialize an upstream `Retry` failure as a `retry:` line.
90840
- *
90841
- * @stability unstable
90842
- * @category models
90843
- * @since 4.0.0
90844
- */
90845
- var Retry = class Retry extends (/*#__PURE__*/ TaggedClass("Retry")) {
90846
- /**
90847
- * Marks this value as an SSE retry directive for runtime guards.
90848
- *
90849
- * @stability unstable
90850
- * @since 4.0.0
90851
- */
90852
- [RetryTypeId] = RetryTypeId;
90853
- /**
90854
- * Returns `true` when the value is an SSE retry directive.
90855
- *
90856
- * @stability unstable
90857
- * @since 4.0.0
90858
- */
90859
- static is(u) {
90860
- return hasProperty(u, RetryTypeId);
90861
- }
90862
- /**
90863
- * Separates SSE retry directives from regular event values.
90864
- *
90865
- * @stability unstable
90866
- * @since 4.0.0
90867
- */
90868
- static filter(u) {
90869
- return Retry.is(u) ? succeed(u) : fail(u);
90870
- }
90871
- };
90872
- //#endregion
90873
91435
  //#region ../../node_modules/.pnpm/@effect+ai-anthropic@4.0.5_effect@4.0.5/node_modules/@effect/ai-anthropic/dist/AnthropicConfig.js
90874
91436
  /**
90875
91437
  * The `AnthropicConfig` module lets a workflow temporarily customize the HTTP
@@ -94399,9 +94961,9 @@ const HttpRequestDetails$1 = /*#__PURE__*/ Struct({
94399
94961
  "QUERY"
94400
94962
  ]),
94401
94963
  url: String$1,
94402
- urlParams: ArraySchema(Tuple([String$1, Union([String$1, Redacted(String$1)])])),
94964
+ urlParams: ArraySchema(Tuple([String$1, Union([String$1, Redacted$1(String$1)])])),
94403
94965
  hash: optional$1(String$1),
94404
- headers: Record$1(String$1, Union([String$1, Redacted(String$1)]))
94966
+ headers: Record$1(String$1, Union([String$1, Redacted$1(String$1)]))
94405
94967
  }).annotate({ identifier: "HttpRequestDetails" });
94406
94968
  /**
94407
94969
  * Schema for HTTP responses from an AI provider.
@@ -94427,7 +94989,7 @@ const HttpRequestDetails$1 = /*#__PURE__*/ Struct({
94427
94989
  */
94428
94990
  const HttpResponseDetails$1 = /*#__PURE__*/ Struct({
94429
94991
  status: Int,
94430
- headers: Record$1(String$1, Union([String$1, Redacted(String$1)]))
94992
+ headers: Record$1(String$1, Union([String$1, Redacted$1(String$1)]))
94431
94993
  }).annotate({ identifier: "HttpResponseDetails" });
94432
94994
  const ReasonTypeId = "~effect/ai/AiError/Reason";
94433
94995
  const providerMetadataWithDefaults = () => ProviderMetadata$1.pipe(withConstructorDefault(succeed$1({})), withDecodingDefault(succeed$1({})));
@@ -96473,7 +97035,7 @@ const Strict = /*#__PURE__*/ Reference("effect/ai/Tool/Strict", { defaultValue:
96473
97035
  * @category getters
96474
97036
  * @since 4.0.0
96475
97037
  */
96476
- const getStrictMode = (tool) => get$5(tool.annotations, Strict);
97038
+ const getStrictMode = (tool) => get$6(tool.annotations, Strict);
96477
97039
  const suspectProtoRx = /"__proto__"\s*:/;
96478
97040
  const suspectConstructorRx = /"constructor"\s*:/;
96479
97041
  function _parse(text) {
@@ -96593,7 +97155,7 @@ function toCodec(schema) {
96593
97155
  const encoded = toEncoded(jsonCodec.ast);
96594
97156
  const from = transform(encoded);
96595
97157
  if (from === encoded) return jsonCodec.ast === schema.ast ? schema : jsonCodec;
96596
- return make$41(decodeTo$1(from, jsonCodec.ast, passthrough$1()));
97158
+ return make$45(decodeTo$1(from, jsonCodec.ast, passthrough$1()));
96597
97159
  }
96598
97160
  function transform(root) {
96599
97161
  let cache;
@@ -96723,7 +97285,7 @@ function compilerAnnotations(annotations) {
96723
97285
  }
96724
97286
  function optionalToNullable(type) {
96725
97287
  return decodeTo$1(new Union$1([type, null_]), optionalKey$1(type), transformOptional({
96726
- decode: filter$5(isNotNull),
97288
+ decode: filter$4(isNotNull),
96727
97289
  encode: orElseSome(() => null)
96728
97290
  }));
96729
97291
  }
@@ -97530,7 +98092,7 @@ const fromResponseParts = (parts) => {
97530
98092
  break;
97531
98093
  case "file":
97532
98094
  assistantParts.push(makePart$1("file", {
97533
- data: encode(part.data),
98095
+ data: encode$1(part.data),
97534
98096
  mediaType: part.mediaType,
97535
98097
  options: part.metadata
97536
98098
  }));
@@ -98341,7 +98903,7 @@ const TypeId$1 = "~effect/ai/Toolkit";
98341
98903
  * @since 4.0.0
98342
98904
  */
98343
98905
  const FailureOrigin = /*#__PURE__*/ Reference("effect/ai/Toolkit/FailureOrigin", { defaultValue: () => "result" });
98344
- const failureCause = (error, origin) => annotate(fail$4(error), make$42(FailureOrigin, origin));
98906
+ const failureCause = (error, origin) => annotate(fail$4(error), make$41(FailureOrigin, origin));
98345
98907
  const Proto = {
98346
98908
  .../*#__PURE__*/ Prototype({
98347
98909
  label: "Toolkit",
@@ -98413,7 +98975,7 @@ const Proto = {
98413
98975
  })));
98414
98976
  }
98415
98977
  const decodedParams = decodedParamsResult.success;
98416
- const queue = yield* make$36();
98978
+ const queue = yield* make$39();
98417
98979
  const context = {
98418
98980
  toolCallId,
98419
98981
  preliminary: (result) => asVoid(offer(queue, {
@@ -98479,7 +99041,7 @@ const Proto = {
98479
99041
  context: services
98480
99042
  });
98481
99043
  }
98482
- return makeUnsafe$3(context$1);
99044
+ return makeUnsafe$5(context$1);
98483
99045
  });
98484
99046
  },
98485
99047
  toLayer(build) {
@@ -99090,11 +99652,11 @@ const make$1 = /*#__PURE__*/ fnUntraced(function* (params) {
99090
99652
  return void_;
99091
99653
  }) : identity)));
99092
99654
  }
99093
- const queue = yield* make$36();
99655
+ const queue = yield* make$39();
99094
99656
  const deferredFinishParts = [];
99095
99657
  if (preResolvedStreamParts.length > 0) yield* offerAll(queue, preResolvedStreamParts);
99096
- const toolCallFibers = yield* make$20();
99097
- const toolCallSemaphore = concurrency === "unbounded" ? void 0 : yield* make$34(concurrency);
99658
+ const toolCallFibers = yield* make$21();
99659
+ const toolCallSemaphore = concurrency === "unbounded" ? void 0 : yield* make$37(concurrency);
99098
99660
  const pendingToolCalls = /* @__PURE__ */ new Map();
99099
99661
  const bufferedToolCalls = [];
99100
99662
  const handleToolCall = fnUntraced(function* (part) {
@@ -99703,7 +100265,7 @@ const prepareMessages = /*#__PURE__*/ fnUntraced(function* ({ betas, capabilitie
99703
100265
  } : {
99704
100266
  type: "base64",
99705
100267
  media_type: mediaType,
99706
- data: typeof part.data === "string" ? part.data.replace(/^data:[^;]+;base64,/, "") : encode(part.data)
100268
+ data: typeof part.data === "string" ? part.data.replace(/^data:[^;]+;base64,/, "") : encode$1(part.data)
99707
100269
  };
99708
100270
  content.push({
99709
100271
  type: "image",
@@ -99720,7 +100282,7 @@ const prepareMessages = /*#__PURE__*/ fnUntraced(function* ({ betas, capabilitie
99720
100282
  } : part.mediaType === "application/pdf" ? {
99721
100283
  type: "base64",
99722
100284
  media_type: "application/pdf",
99723
- data: typeof part.data === "string" ? part.data : encode(part.data)
100285
+ data: typeof part.data === "string" ? part.data : encode$1(part.data)
99724
100286
  } : {
99725
100287
  type: "text",
99726
100288
  media_type: "text/plain",
@@ -101203,7 +101765,7 @@ const INSTRUCTIONS = pipe([
101203
101765
  ], join$1(" "));
101204
101766
  var Organizer = class Organizer extends Service()("@deslop/stash/services/notes/lib/organization/Organizer") {
101205
101767
  static layer = effect(this, gen(function* () {
101206
- const key = yield* option(Redacted$1("ANTHROPIC_API_KEY"));
101768
+ const key = yield* option(Redacted("ANTHROPIC_API_KEY"));
101207
101769
  const model = yield* pipe(make({
101208
101770
  config: {
101209
101771
  max_tokens: 32e3,
@@ -101222,7 +101784,7 @@ var Organizer = class Organizer extends Service()("@deslop/stash/services/notes/
101222
101784
  `Link title: ${input.note.title}`,
101223
101785
  `Saved text: ${input.note.text}`,
101224
101786
  `Link content: ${slice$2(0, 15e4)(input.note.content)}`,
101225
- `Video transcript: ${pipe(fromUndefinedOr(input.note.transcript), map$4(slice$2(0, 15e4)), getOrElse(() => "none"))}`
101787
+ `Video transcript: ${pipe(fromUndefinedOr(input.note.transcript), map$5(slice$2(0, 15e4)), getOrElse(() => "none"))}`
101226
101788
  ], "\n");
101227
101789
  const response = yield* model.generateObject({
101228
101790
  prompt: [{
@@ -101246,7 +101808,7 @@ var Organizer = class Organizer extends Service()("@deslop/stash/services/notes/
101246
101808
  tags: normalizeTags(response.value.tags)
101247
101809
  };
101248
101810
  }, timeout("5 minutes"), mapError((cause) => pipe(liftPredicate(cause, is$4(NotesError)), getOrElse(() => NotesError.make({
101249
- cause: make$43(cause),
101811
+ cause: make$46(cause),
101250
101812
  message: "AI tagging failed; the note is saved as it is."
101251
101813
  }))))) });
101252
101814
  }));
@@ -101291,7 +101853,7 @@ const openStore = fnUntraced(function* (path) {
101291
101853
  //#region src/services/notes/service.ts
101292
101854
  function withWords(note, text) {
101293
101855
  const known = pipe(note.text, toLowerCase, split(/\s+/u));
101294
- const added = pipe(commentFor(text), split(" "), filter$4((word) => isNonEmpty(word) && !contains$2(known, toLowerCase(word))));
101856
+ const added = pipe(commentFor(text), split(" "), filter$5((word) => isNonEmpty(word) && !contains$1(known, toLowerCase(word))));
101295
101857
  if (isReadonlyArrayEmpty(added)) return note;
101296
101858
  return {
101297
101859
  ...note,
@@ -101315,17 +101877,16 @@ function optional(message, fallback) {
101315
101877
  return (effect) => pipe(effect, tapError$1((error) => logWarning(message, error)), orElseSucceed(fallback));
101316
101878
  }
101317
101879
  var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/Notes") {
101318
- static layer = effect(this, gen(function* () {
101880
+ static layer = (directory) => effect(this, gen(function* () {
101319
101881
  const fs = yield* FileSystem;
101320
101882
  const path = yield* Path;
101321
101883
  const sources = yield* Sources;
101322
101884
  const media = yield* Media;
101323
101885
  const organizer = yield* Organizer;
101324
- const directory = yield* pipe(String$2("STASH_DATA_DIR"), withDefault(path.join(yield* String$2("HOME"), ".deslop", "stash")));
101325
101886
  const images = path.join(directory, "images");
101326
101887
  const files = path.join(directory, "files");
101327
- const reading = yield* make$34(2);
101328
- const runs = yield* make$18();
101888
+ const reading = yield* make$37(2);
101889
+ const runs = yield* make$19();
101329
101890
  const storageFailed = mapError((cause) => NotesError.make({
101330
101891
  cause,
101331
101892
  message: "The notes database or files could not be read or written."
@@ -101348,7 +101909,7 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
101348
101909
  }));
101349
101910
  }
101350
101911
  function updateNote(id, change) {
101351
- return transact((current) => make$44(void 0, changeNote(current, id, change)));
101912
+ return transact((current) => make$47(void 0, changeNote(current, id, change)));
101352
101913
  }
101353
101914
  function findNote(id) {
101354
101915
  return map$1(get$1(state), (notes) => findFirst(notes, (note) => note.id === id));
@@ -101395,7 +101956,7 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
101395
101956
  }));
101396
101957
  }
101397
101958
  const keepImages = fnUntraced(function* (note, page) {
101398
- yield* pipe(forEach(toArray$1(filter$5(page.image, () => note.image === void 0)), (image) => flatMap(sources.image(image), (bytes) => storeImage(note.id, bytes)), {
101959
+ yield* pipe(forEach(toArray$1(filter$4(page.image, () => note.image === void 0)), (image) => flatMap(sources.image(image), (bytes) => storeImage(note.id, bytes)), {
101399
101960
  concurrency: "unbounded",
101400
101961
  discard: true
101401
101962
  }), ignore$1({
@@ -101417,7 +101978,7 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
101417
101978
  }),
101418
101979
  onSuccess: (page) => ({
101419
101980
  ...omit(item, ["issue"]),
101420
- ...match$1(filter$5(page.author, isNonEmpty), {
101981
+ ...match$1(filter$4(page.author, isNonEmpty), {
101421
101982
  onNone: () => ({}),
101422
101983
  onSome: (author) => ({ author })
101423
101984
  }),
@@ -101442,9 +102003,9 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
101442
102003
  onSuccess: (page) => page.video ?? page.url
101443
102004
  });
101444
102005
  const read = yield* pipe(media.read(video), asSome, optional("The video could not be read", none));
101445
- 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));
102006
+ const transcript = yield* pipe(filter$4(read, () => note.transcript === void 0), map$5((details) => pipe(details.transcript, optional("No transcript", none))), transposeOption, map$1(flatten));
101446
102007
  yield* updateNote(note.id, (item) => ({
101447
- ...match$1(filter$5(read, () => sourceFor(url) !== "X" || isFailure(extraction)), {
102008
+ ...match$1(filter$4(read, () => sourceFor(url) !== "X" || isFailure(extraction)), {
101448
102009
  onNone: () => item,
101449
102010
  onSome: (details) => ({
101450
102011
  ...omit(item, ["issue"]),
@@ -101500,7 +102061,7 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
101500
102061
  onTrue: () => void_
101501
102062
  })), (effect) => run$1(runs, note.id, effect), asVoid);
101502
102063
  }
101503
- yield* forEach(filter$4(yield* get$1(state), (note) => note.status === "organizing"), start, {
102064
+ yield* forEach(filter$5(yield* get$1(state), (note) => note.status === "organizing"), start, {
101504
102065
  concurrency: 1,
101505
102066
  discard: true
101506
102067
  });
@@ -101541,8 +102102,8 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
101541
102102
  text: ""
101542
102103
  });
101543
102104
  const earlier = yield* transact((current) => match$1(findFirst(current, (item) => item.id === input.id), {
101544
- onNone: () => make$44(none(), prepend$2(current, note)),
101545
- onSome: (item) => make$44(some$1(item), current)
102105
+ onNone: () => make$47(none(), prepend$2(current, note)),
102106
+ onSome: (item) => make$47(some$1(item), current)
101546
102107
  }));
101547
102108
  return yield* match$1(earlier, {
101548
102109
  onNone: () => as$1(start(note), note),
@@ -101553,7 +102114,7 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
101553
102114
  capture: fn$1("Notes.capture")(function* (input) {
101554
102115
  const text = trim(input.text);
101555
102116
  if (isEmpty$2(text)) return yield* NotesError.make({ message: "Paste a link or write a note." });
101556
- const url = yield* pipe(fromUndefinedOr(captureUrl(text)), map$4((link) => orElseSucceed(sources.resolve(link), () => link)), transposeOption);
102117
+ const url = yield* pipe(fromUndefinedOr(captureUrl(text)), map$5((link) => orElseSucceed(sources.resolve(link), () => link)), transposeOption);
101557
102118
  const createdAt = toEpochMillis(yield* now);
101558
102119
  const saved = yield* transact((current) => match$1(findFirst(current, (note) => note.id === input.id || exists(url, (link) => note.url === link)), {
101559
102120
  onNone: () => {
@@ -101575,18 +102136,18 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
101575
102136
  onSome: (link) => ({ url: link })
101576
102137
  })
101577
102138
  });
101578
- return make$44({
102139
+ return make$47({
101579
102140
  fresh: true,
101580
102141
  note
101581
102142
  }, prepend$2(current, note));
101582
102143
  },
101583
102144
  onSome: (note) => {
101584
102145
  const merged = withWords(note, text);
101585
- if (note.id === input.id || merged === note) return make$44({
102146
+ if (note.id === input.id || merged === note) return make$47({
101586
102147
  fresh: false,
101587
102148
  note
101588
102149
  }, current);
101589
- return make$44({
102150
+ return make$47({
101590
102151
  fresh: false,
101591
102152
  note: merged
101592
102153
  }, changeNote(current, note.id, () => merged));
@@ -101630,22 +102191,22 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
101630
102191
  regenerate: fn$1("Notes.regenerate")(function* (input) {
101631
102192
  yield* remove$1(runs, input.id);
101632
102193
  const reset = yield* transact((current) => match$1(findFirst(current, (note) => note.id === input.id), {
101633
- onNone: () => make$44(none(), current),
102194
+ onNone: () => make$47(none(), current),
101634
102195
  onSome: (found) => {
101635
102196
  const next = {
101636
102197
  ...omit(found, ["issue", "transcript"]),
101637
102198
  status: "organizing"
101638
102199
  };
101639
- return make$44(some$1(next), changeNote(current, input.id, () => next));
102200
+ return make$47(some$1(next), changeNote(current, input.id, () => next));
101640
102201
  }
101641
102202
  }));
101642
102203
  yield* pipe(fromOption(reset), missing, flatMap(start));
101643
102204
  }),
101644
102205
  remove: fn$1("Notes.remove")(function* (input) {
101645
102206
  yield* remove$1(runs, input.id);
101646
- yield* transact((current) => make$44(void 0, match(some$2(current, (note) => note.id === input.id), {
102207
+ yield* transact((current) => make$47(void 0, match(some$2(current, (note) => note.id === input.id), {
101647
102208
  onFalse: () => current,
101648
- onTrue: () => filter$4(current, (note) => note.id !== input.id)
102209
+ onTrue: () => filter$5(current, (note) => note.id !== input.id)
101649
102210
  })));
101650
102211
  yield* pipe(fs.remove(path.join(images, input.id), { force: true }), storageFailed);
101651
102212
  yield* pipe(fs.remove(path.join(files, input.id), { force: true }), storageFailed);
@@ -101656,49 +102217,82 @@ var Notes = class Notes extends Service()("@deslop/stash/services/notes/service/
101656
102217
  });
101657
102218
  }));
101658
102219
  };
102220
+ var UserNotes = class UserNotes extends Service()("@deslop/stash/services/notes/service/UserNotes") {
102221
+ static layer = effect(this, gen(function* () {
102222
+ const fs = yield* FileSystem;
102223
+ const path = yield* Path;
102224
+ const directory = yield* pipe(String$2("STASH_DATA_DIR"), withDefault(path.join(yield* String$2("HOME"), ".deslop", "stash")));
102225
+ const users = yield* pipe(fs.makeDirectory(directory, {
102226
+ mode: 448,
102227
+ recursive: true
102228
+ }), andThen(fs.readDirectory(directory)), mapError((cause) => NotesError.make({
102229
+ cause,
102230
+ message: "The notes folder could not be read."
102231
+ })));
102232
+ const scope = yield* Scope;
102233
+ const services = succeedContext(yield* context());
102234
+ const loaded = yield* make$13(empty$13());
102235
+ const build = fnUntraced(function* (user) {
102236
+ const owned = yield* fork(scope);
102237
+ const context = yield* pipe(buildWithScope(pipe(Notes.layer(path.join(directory, user)), provide$1(services)), owned), onError((cause) => close(owned, failCause$1(cause))));
102238
+ return get$6(context, Notes);
102239
+ });
102240
+ function load(user) {
102241
+ return modifyEffect$1(loaded, (current) => match$1(get$9(current, user), {
102242
+ onNone: () => map$1(build(user), (notes) => make$47(notes, set$4(current, user, notes))),
102243
+ onSome: (notes) => succeed$1(make$47(notes, current))
102244
+ }));
102245
+ }
102246
+ yield* forEach(users, load, {
102247
+ concurrency: 1,
102248
+ discard: true
102249
+ });
102250
+ return UserNotes.of({ current: flatMap(CurrentUser, (user) => load(user.id)) });
102251
+ }));
102252
+ };
101659
102253
  //#endregion
101660
102254
  //#region src/rpcs/handlers.ts
101661
102255
  const RpcHandlers = RpcContracts.toLayer(gen(function* () {
101662
- const notes = yield* Notes;
102256
+ const notes = (yield* UserNotes).current;
101663
102257
  return RpcContracts.of({
101664
- "notes.capture": notes.capture,
101665
- "notes.get": notes.get,
101666
- "notes.regenerate": notes.regenerate,
101667
- "notes.remove": notes.remove,
101668
- "notes.search": notes.search,
101669
- "notes.watch": () => notes.events
102258
+ "notes.capture": (input) => flatMap(notes, (service) => service.capture(input)),
102259
+ "notes.get": (input) => flatMap(notes, (service) => service.get(input)),
102260
+ "notes.regenerate": (input) => flatMap(notes, (service) => service.regenerate(input)),
102261
+ "notes.remove": (input) => flatMap(notes, (service) => service.remove(input)),
102262
+ "notes.search": (input) => flatMap(notes, (service) => service.search(input)),
102263
+ "notes.watch": () => unwrap$2(map$1(notes, (service) => service.events))
101670
102264
  });
101671
102265
  }));
101672
102266
  //#endregion
101673
102267
  //#region src/main.server.ts
101674
102268
  const noteIdParam = schemaPathParams(Struct({ id: NoteId }));
101675
- const routes = use((router) => gen(function* () {
101676
- const notes = yield* Notes;
102269
+ const routes = pipe(use((router) => gen(function* () {
102270
+ const userNotes = (yield* UserNotes).current;
101677
102271
  yield* router.add("POST", "/api/capture", gen(function* () {
101678
- return yield* schemaJson(Note)(yield* notes.capture(yield* schemaBodyJson(Capture)));
102272
+ return yield* schemaJson(Note)(yield* (yield* userNotes).capture(yield* schemaBodyJson(Capture)));
101679
102273
  }));
101680
102274
  yield* router.add("POST", "/api/files/:id", gen(function* () {
101681
102275
  const request = yield* HttpServerRequest;
101682
102276
  const type = yield* decodeUnknownEffect(FileType)(pipe(request.headers["content-type"] ?? "", split(";"), headNonEmpty, trim));
101683
- return yield* schemaJson(Note)(yield* notes.captureFile({
102277
+ return yield* schemaJson(Note)(yield* (yield* userNotes).captureFile({
101684
102278
  body: request.stream,
101685
102279
  id: (yield* noteIdParam).id,
101686
102280
  type
101687
102281
  }));
101688
102282
  }));
101689
102283
  yield* router.add("GET", "/api/images/:id", gen(function* () {
101690
- const image = yield* notes.image((yield* noteIdParam).id);
102284
+ const image = yield* (yield* userNotes).image((yield* noteIdParam).id);
101691
102285
  return uint8Array(image.bytes, {
101692
102286
  contentType: image.type,
101693
102287
  headers: { "cache-control": "private, max-age=31536000, immutable" }
101694
102288
  });
101695
102289
  }));
101696
- }));
102290
+ })), provide$1(HttpAuth.layer));
101697
102291
  const rpc = pipe(layerHttp({
101698
102292
  group: RpcContracts,
101699
102293
  path: "/api/rpc",
101700
102294
  protocol: "websocket"
101701
- }), provide(RpcHandlers), provide(layerJson$1));
101702
- runMain(pipe(serve(merge$3(rpc, routes), { disableLogger: true }), provide(Notes.layer), provide(mergeAll(Sources.layer, Media.layer, Organizer.layer)), provide(mergeAll(layer$4, layer$6, layer$11)), provide(layer("@deslop/stash")), provide(layerNodeHttpServer), launch));
102295
+ }), provide$1(RpcHandlers), provide$1(layerJson$1));
102296
+ runMain(pipe(serve(pipe(merge$3(rpc, routes), provide$1(Auth.layer)), { disableLogger: true }), provide$1(UserNotes.layer), provide$1(mergeAll(Sources.layer, Media.layer, Organizer.layer)), provide$1(mergeAll(layer$4, layer$6, layer$11)), provide$1(layer("@deslop/stash")), provide$1(layerNodeHttpServer), launch));
101703
102297
  //#endregion
101704
102298
  export {};