functype 1.25.1 → 1.26.1
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/README.md +3 -0
- package/dist/cli/exports.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/conditional/index.d.ts +1 -1
- package/dist/conditional/index.js +1 -1
- package/dist/core/task/index.d.ts +1 -1
- package/dist/core/task/index.js +1 -1
- package/dist/decoder/index.d.ts +1 -1
- package/dist/decoder/index.js +1 -1
- package/dist/do/index.d.ts +1 -1
- package/dist/do/index.js +1 -1
- package/dist/either/index.d.ts +1 -1
- package/dist/either/index.js +1 -1
- package/dist/fetch/index.d.ts +1 -1
- package/dist/fetch/index.js +1 -1
- package/dist/{full-interfaces-B8gUV1qj.js → full-interfaces-M_MSvdEs.js} +48 -1
- package/dist/functype/index.d.ts +1 -1
- package/dist/{index-C5IrHYtk.d.ts → index-CjqFFy4s.d.ts} +58 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/io/index.d.ts +1 -1
- package/dist/io/index.js +1 -1
- package/dist/lazy/index.d.ts +1 -1
- package/dist/lazy/index.js +1 -1
- package/dist/list/index.d.ts +1 -1
- package/dist/list/index.js +1 -1
- package/dist/map/index.d.ts +1 -1
- package/dist/map/index.js +1 -1
- package/dist/obj/index.d.ts +1 -1
- package/dist/obj/index.js +1 -1
- package/dist/option/index.d.ts +1 -1
- package/dist/option/index.js +1 -1
- package/dist/serialization/index.d.ts +1 -1
- package/dist/set/index.d.ts +1 -1
- package/dist/set/index.js +1 -1
- package/dist/{src-DskkjCdD.js → src-DaOliT66.js} +14 -14
- package/dist/try/index.d.ts +1 -1
- package/dist/try/index.js +1 -1
- package/dist/typeclass/index.d.ts +2 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -687,6 +687,9 @@ list.find((x) => x > 3) // Some(4)
|
|
|
687
687
|
opt.exists((x) => x === 42) // true
|
|
688
688
|
list.exists((x) => x === 3) // true
|
|
689
689
|
|
|
690
|
+
opt.every((x) => x > 40) // true (and true for None: nothing to fail)
|
|
691
|
+
list.every((x) => x > 0) // true (and true for an empty List)
|
|
692
|
+
|
|
690
693
|
opt.forEach(console.log) // Logs: 42
|
|
691
694
|
list.forEach(console.log) // Logs: 1, 2, 3, 4, 5
|
|
692
695
|
```
|
package/dist/cli/exports.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,i as t,n,r,t as i}from"../full-interfaces-
|
|
1
|
+
import{a as e,i as t,n,r,t as i}from"../full-interfaces-M_MSvdEs.js";export{n as CATEGORIES,i as FULL_INTERFACES,r as INTERFACES,t as TYPES,e as VERSION};
|
package/dist/cli/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{Mt as e,et as t,wt as n}from"../src-
|
|
2
|
+
import{Mt as e,et as t,wt as n}from"../src-DaOliT66.js";import{a as r,i,n as a,r as o,t as s}from"../full-interfaces-M_MSvdEs.js";const c=()=>{let t=n([`functype ${r} - Scala-inspired FP for TypeScript`,``]);return n(Object.entries(a)).foldLeft(t)((t,[r,a])=>{let o=t.add(r.toUpperCase());return n(a).foldLeft(o)((t,n)=>e(i[n]).fold(()=>t,e=>{let r=e.interfaces.length>0?` [${e.interfaces.join(`, `)}]`:``;return t.add(` ${n}${r}`).add(` ${e.description}`)})).add(``)}).concat(n([`Use: npx functype <Type> for details`,`Use: npx functype interfaces for interface reference`])).toArray().join(`
|
|
3
3
|
`)},l=(t,r)=>{let i=r.interfaces.length>0?` [${r.interfaces.join(`, `)}]`:``,a=n([`create`,`transform`,`extract`,`check`,`other`]),o=n([`${t}<T>${i}`,``,r.description,``]);return a.foldLeft(o)((t,i)=>e(r.methods[i]).filter(e=>e.length>0).fold(()=>t,e=>{let r=t.add(i.toUpperCase());return n(e).foldLeft(r)((e,t)=>e.add(` ${t}`)).add(``)})).toArray().join(`
|
|
4
4
|
`).trimEnd()},u=()=>{let e=n([`INTERFACES`,``]);return n(Object.entries(o)).foldLeft(e)((e,[t,r])=>{let i=r.extends?` extends ${r.extends}`:``,a=e.add(`${t}<A>${i}`).add(` ${r.description}`);return n(r.methods).foldLeft(a)((e,t)=>e.add(` ${t}`)).add(``)}).toArray().join(`
|
|
5
5
|
`).trimEnd()},d=e=>JSON.stringify(e,null,2),f=()=>({version:r,categories:a,types:i}),p=t=>e(i[t]).map(e=>({name:t,data:e})).or(n(Object.entries(i)).find(([e])=>e.toLowerCase()===t.toLowerCase()).map(([e,t])=>({name:e,data:t}))).orUndefined(),m=()=>Object.keys(i),h=()=>o,g=e=>{let t=n(e.slice(2));return{flags:{json:t.contains(`--json`),full:t.contains(`--full`),help:t.exists(e=>e===`--help`||e===`-h`)},args:t.filter(e=>!e.startsWith(`--`)&&e!==`-h`)}},_=t=>e(s[t]).or(n(Object.entries(s)).find(([e])=>e.toLowerCase()===t.toLowerCase()).map(([,e])=>e)),v=()=>{let e=n([`FULL INTERFACE DEFINITIONS`,`=`.repeat(60),``]);return n(Object.entries(s)).foldLeft(e)((e,[t,r])=>e.concat(n([`// ${t}`,r,``,`-`.repeat(60),``]))).toArray().join(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ir as Cond, n as UntypedMatch, t as Match } from "../index-CjqFFy4s.js";
|
|
2
2
|
export { Cond, Match, UntypedMatch };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{et as e,tt as t}from"../src-
|
|
1
|
+
import{et as e,tt as t}from"../src-DaOliT66.js";export{t as Cond,e as Match};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $t as Sync, Jt as Async, Qt as Ok, Xt as CancellationTokenSource, Yt as CancellationToken, Zt as Err, an as TaskParams, cn as createCancellationTokenSource, en as TaggedThrowable, in as TaskOutcome, ln as isTaggedThrowable, nn as TaskFailure, on as TaskResult, rn as TaskMetadata, sn as TaskSuccess, tn as Task } from "../../index-
|
|
1
|
+
import { $t as Sync, Jt as Async, Qt as Ok, Xt as CancellationTokenSource, Yt as CancellationToken, Zt as Err, an as TaskParams, cn as createCancellationTokenSource, en as TaggedThrowable, in as TaskOutcome, ln as isTaggedThrowable, nn as TaskFailure, on as TaskResult, rn as TaskMetadata, sn as TaskSuccess, tn as Task } from "../../index-CjqFFy4s.js";
|
|
2
2
|
export { Async, CancellationToken, CancellationTokenSource, Err, Ok, Sync, TaggedThrowable, Task, TaskFailure, TaskMetadata, TaskOutcome, TaskParams, TaskResult, TaskSuccess, createCancellationTokenSource, isTaggedThrowable };
|
package/dist/core/task/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{J as e,K as t,X as n,Y as r,q as i}from"../../src-
|
|
1
|
+
import{J as e,K as t,X as n,Y as r,q as i}from"../../src-DaOliT66.js";export{t as Err,i as Ok,e as Task,r as createCancellationTokenSource,n as isTaggedThrowable};
|
package/dist/decoder/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Gt as DecoderError, Kt as DecoderErrorComposite, Ut as Decoder, Wt as Encoder, qt as DecoderErrorLeaf } from "../index-
|
|
1
|
+
import { Gt as DecoderError, Kt as DecoderErrorComposite, Ut as Decoder, Wt as Encoder, qt as DecoderErrorLeaf } from "../index-CjqFFy4s.js";
|
|
2
2
|
export { Decoder, DecoderError, type DecoderErrorComposite, type DecoderErrorLeaf, type Encoder };
|
package/dist/decoder/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{H as e,U as t}from"../src-
|
|
1
|
+
import{H as e,U as t}from"../src-DaOliT66.js";export{e as Decoder,t as DecoderError};
|
package/dist/do/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Bt as NoneError, Ft as EmptyListError, Ht as unwrap, It as FailureError, Lt as FailureErrorType, Mt as Do,
|
|
1
|
+
import { Bt as NoneError, Fr as Doable, Ft as EmptyListError, Ht as unwrap, It as FailureError, Lt as FailureErrorType, Mt as Do, Nt as DoAsync, Pr as DoResult, Pt as DoGenerator, Rt as LeftError, Vt as isDoCapable, jt as $, zt as LeftErrorType } from "../index-CjqFFy4s.js";
|
|
2
2
|
export { $, Do, DoAsync, DoGenerator, type DoResult, type Doable, EmptyListError, FailureError, FailureErrorType, LeftError, LeftErrorType, NoneError, isDoCapable, unwrap };
|
package/dist/do/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,F as t,I as n,L as r,N as i,P as a,R as o,V as s,z as c}from"../src-
|
|
1
|
+
import{B as e,F as t,I as n,L as r,N as i,P as a,R as o,V as s,z as c}from"../src-DaOliT66.js";export{i as $,a as Do,t as DoAsync,n as EmptyListError,r as FailureError,o as LeftError,c as NoneError,e as isDoCapable,s as unwrap};
|
package/dist/either/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _r as tryCatchAsync, ar as Either, cr as LeftOf, dr as TestEither, fr as TypeCheckLeft, gr as tryCatch, hr as isRight, lr as Right, mr as isLeft, or as EitherBase, pr as TypeCheckRight, sr as Left, ur as RightOf } from "../index-
|
|
1
|
+
import { _r as tryCatchAsync, ar as Either, cr as LeftOf, dr as TestEither, fr as TypeCheckLeft, gr as tryCatch, hr as isRight, lr as Right, mr as isLeft, or as EitherBase, pr as TypeCheckRight, sr as Left, ur as RightOf } from "../index-CjqFFy4s.js";
|
|
2
2
|
export { Either, EitherBase, Left, LeftOf, Right, RightOf, TestEither, TypeCheckLeft, TypeCheckRight, isLeft, isRight, tryCatch, tryCatchAsync };
|
package/dist/either/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Ct as e,St as t,_t as n,bt as r,gt as i,ht as a,vt as o,xt as s,yt as c}from"../src-
|
|
1
|
+
import{Ct as e,St as t,_t as n,bt as r,gt as i,ht as a,vt as o,xt as s,yt as c}from"../src-DaOliT66.js";export{a as Either,i as Left,n as Right,o as TypeCheckLeft,c as TypeCheckRight,r as isLeft,s as isRight,t as tryCatch,e as tryCatchAsync};
|
package/dist/fetch/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as Http, B as HttpError, F as HttpRequestOptions, H as HttpStatusError, I as HttpRequestView, L as HttpResponse, M as HttpClientConfig, N as HttpMethodOptions, P as HttpQueryParams, R as ParseMode, U as NetworkError, V as HttpMethod, W as ResponseDecodeError, j as HttpClient, z as DecodeError } from "../index-
|
|
1
|
+
import { A as Http, B as HttpError, F as HttpRequestOptions, H as HttpStatusError, I as HttpRequestView, L as HttpResponse, M as HttpClientConfig, N as HttpMethodOptions, P as HttpQueryParams, R as ParseMode, U as NetworkError, V as HttpMethod, W as ResponseDecodeError, j as HttpClient, z as DecodeError } from "../index-CjqFFy4s.js";
|
|
2
2
|
export { type DecodeError, Http, HttpClient, type HttpClientConfig, HttpError, HttpError as HttpErrors, type HttpMethod, type HttpMethodOptions, type HttpQueryParams, type HttpRequestOptions, type HttpRequestView, type HttpResponse, type HttpStatusError, type NetworkError, type ParseMode, type ResponseDecodeError };
|
package/dist/fetch/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,f as t,p as n}from"../src-
|
|
1
|
+
import{d as e,f as t,p as n}from"../src-DaOliT66.js";export{e as Http,n as HttpClient,t as HttpError,t as HttpErrors};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var e=`1.25.1`;const t={Option:[`Applicative`,`AsyncMonad`,`Doable`,`Extractable`,`Foldable`,`Functor`,`Matchable`,`Monad`,`Promisable`,`Reshapeable`,`Serializable`,`Traversable`],Either:[`Applicative`,`AsyncMonad`,`Doable`,`Extractable`,`Foldable`,`Functor`,`Monad`,`Promisable`,`Reshapeable`,`Serializable`],Try:[`Applicative`,`AsyncMonad`,`Doable`,`Extractable`,`Foldable`,`Functor`,`Monad`,`Promisable`,`Reshapeable`,`Serializable`],List:[`Collection`,`Doable`,`Iterable`,`Reshapeable`],Set:[`Collection`,`Iterable`],Map:[`Collection`,`Foldable`,`Iterable`,`KVTraversable`,`Serializable`],Obj:[`Doable`,`Promisable`,`Reshapeable`],Lazy:[`Applicative`,`AsyncMonad`,`Extractable`,`Foldable`,`Functor`,`Monad`,`Serializable`,`Traversable`],LazyList:[`Foldable`,`Serializable`],Tuple:[`Foldable`,`Serializable`],Task:[`Applicative`,`AsyncMonad`,`Doable`,`Extractable`,`Foldable`,`Functor`,`Monad`,`Promisable`,`Serializable`,`Traversable`]},n=e,r=(e,...n)=>Array.from(/* @__PURE__ */ new Set([...t[e],...n])).sort(),i={Option:{description:`Safe nullable handling - Some<T> or None`,interfaces:r(`Option`),methods:{create:[`Option(v)`,`Option.none()`,`Some(v)`,`None()`],transform:[`.map(f)`,`.flatMap(f)`,`.filter(p)`,`.ap(ff)`],extract:[`.fold(n, s)`,`.foldAsync(n, s)`,`.orElse(d)`,`.orThrow(err | () => Error)`,`.expect(() => never)`,`.orNull()`,`.match({Some, None})`,`.toEither(left | () => left)`,`.toList()`,`.toArray()`],check:[`.isSome()`,`.isNone()`,`.isEmpty`],other:[`Option.sequence(arr)`,`Option.traverse(arr, f)`]}},Either:{description:`Error handling with Left (error) or Right (success)`,interfaces:r(`Either`,`Traversable`),methods:{create:[`Right(v)`,`Left(e)`,`Either.right(v)`,`Either.left(e)`,`Either.void()`],transform:[`.map(f)`,`.flatMap(f)`,`.mapLeft(f)`,`.swap()`],extract:[`.fold(l, r)`,`.foldAsync(l, r)`,`.orElse(d)`,`.orThrow(err | (left) => Error)`,`.expect((l) => never)`,`.match({Left, Right})`],check:[`.isRight()`,`.isLeft()`],other:[`Either.sequence(arr)`,`Either.traverse(arr, f)`,`Either.traverseAsync(items, f, {concurrency?}) // in order by default, stops at first Left`,`Either.fromNullable(v, e)`]}},Try:{description:`Wrap operations that may throw - Success<T> or Failure`,interfaces:r(`Try`,`Matchable`,`Traversable`),methods:{create:[`Try(() => expr)`,`Try.success(v)`,`Try.failure(e)`,`Try.fromPromise(p)`,`Try.async(() => Promise<T>)`],transform:[`.map(f)`,`.flatMap(f)`,`.recover(f)`,`.recoverWith(f)`],extract:[`.fold(f, s)`,`.foldAsync(f, s)`,`.orElse(d)`,`.orThrow(err | (error) => Error)`,`.expect((e) => never)`,`.toOption()`,`.toEither(left | (err) => left)`,`.toList()`,`.toArray()`],check:[`.isSuccess()`,`.isFailure()`],other:[`Try.sequence(arr)`,`Try.traverse(arr, f)`]}},List:{description:`Immutable array with functional operations`,interfaces:r(`List`,`Functor`,`Monad`,`Foldable`,`Serializable`,`Traversable`),methods:{create:[`List([...])`,`List.of(...)`,`List.empty()`],transform:[`.map(f)`,`.flatMap(f)`,`.filter(p)`,`.take(n)`,`.takeWhile(p)`,`.takeRight(n)`,`.drop(n)`,`.dropWhile(p)`,`.concat(list)`,`.reverse()`,`.distinct()`,`.sorted()`,`.sortBy(f)`,`.zip(list)`,`.zipWithIndex()`,`.prepend(v)`,`.slice(s, e)`],extract:[`.fold(z, f)`,`.reduce(f)`,`.head`,`.headOption`,`.tail`,`.last`,`.lastOption`,`.init`,`.indexOf(v)`,`.toArray()`],check:[`.isEmpty`,`.size`,`.contains(v)`,`.exists(p)`,`.every(p)`],other:[`.groupBy(f)`,`.partition(p)`,`.span(p)`,`.mapAsync(f, {concurrency?}) // in order by default`,`.flatMapAsync(f, {concurrency?})`]}},Set:{description:`Immutable set of unique values`,interfaces:r(`Set`,`Functor`,`Foldable`,`Serializable`,`Traversable`),methods:{create:[`Set([...])`,`Set.of(...)`,`Set.empty()`],transform:[`.map(f)`,`.flatMap(f)`,`.filter(p)`,`.filterNot(p)`,`.add(v)`,`.remove(v)`,`.union(other)`,`.intersection(other)`,`.difference(other)`,`.symmetricDifference(other)`,`.mapAsync(f, {concurrency?}) // in order by default`],extract:[`.fold(z, f)`,`.toArray()`],check:[`.has(v)`,`.isEmpty`,`.size`,`.exists(p)`,`.every(p)`,`.isSubsetOf(other)`,`.isSupersetOf(other)`,`.isDisjointFrom(other)`],other:[`import { Set } from "functype" // its own name; the built-in is globalThis.Set`]}},Obj:{description:`Immutable object wrapper with fluent operations`,interfaces:r(`Obj`,`KVTraversable`,`Foldable`,`Matchable`,`Extractable`,`Serializable`),methods:{create:[`Obj({...})`,`Obj.of({...})`,`Obj.empty()`],transform:[`.set(k, v)`,`.assign(partial)`,`.merge(obj)`,`.when(cond, partial)`,`.omit(...keys)`,`.pick(...keys)`,`.map(f)`,`.flatMap(f)`],extract:[`.get(k)`,`.value()`,`.keys()`,`.values()`,`.entries()`,`.fold(n, s)`,`.match({Obj})`],check:[`.has(k)`,`.isEmpty`,`.size`]}},Map:{description:`Immutable key-value store`,interfaces:r(`Map`),methods:{create:[`Map([[k, v], ...])`,`Map.of([k, v], ...)`,`Map.empty()`,`Map.fromJSON(json)`,`Map.fromYAML(yaml)`,`Map.fromBinary(b)`],transform:[`.add(Tuple([k, v]))`,`.remove(k)`,`.map(f)`,`.flatMap(f)`,`.ap(ff)`,`.flatMapAsync(f)`],extract:[`.get(k) // Option<V>`,`.keys() // List<K>`,`.values() // List<V>`,`.getOrElse(k, d)`,`.orElse(k, Option<V>)`,`.fold(z, f)`,`.foldLeft(z)(f)`,`.foldRight(z)(f)`,`.match({Empty, NonEmpty})`,`.toList()`,`.toSet()`,`[...map] // iterate [k, v] pairs`],check:[`.has(k) // key only`,`.contains(Tuple([k, v])) // === on the value`,`.isEmpty`,`.size`],other:[`import { Map } from "functype" // its own name; the built-in is globalThis.Map`]}},Lazy:{description:"Deferred computation with memoization. Note: `serialize()` and `toValue()` FORCE the thunk (visible side effect) since a closure cannot be JSON-serialized — there is no representable 'unevaluated post-serialize' state. Thunk failures are captured via SerializedError and rethrown on access after fromJSON.",interfaces:r(`Lazy`),methods:{create:[`Lazy(() => expr)`,`Lazy.fromValue(value) — wrap a non-deferred value`,`Lazy.evaluated(value) — reads as 'already-forced'; used by fromJSON`,`Lazy.fail(error) — Lazy that throws on access`],transform:[`.map(f)`,`.flatMap(f)`],extract:[`.fold(f)`,`.foldWith(onFailure, onSuccess)`,`.orElse(d)`,`.orNull()`,`.orThrow()`,`.toJSON()`,`Lazy.fromJSON(json)`],check:[`.isEvaluated`]}},LazyList:{description:`Lazy sequences for large/infinite data`,interfaces:r(`LazyList`,`Functor`,`Monad`,`Iterable`),methods:{create:[`LazyList(iterable)`,`LazyList.from(a, b, ...)`,`LazyList.of(a, b, ...)`,`LazyList.range(start, end)`,`LazyList.iterate(seed, f)`,`LazyList.generate(f)`,`LazyList.fromJSON(json)`],transform:[`.map(f)`,`.filter(p)`,`.take(n)`,`.takeRight(n)`,`.drop(n)`,`.takeWhile(p)`,`.dropWhile(p)`,`.concat(ll)`,`.reverse()`,`.distinct()`,`.zip(ll)`,`.zipWithIndex()`],extract:[`.head`,`.headOption`,`.tail`,`.last`,`.lastOption`,`.init`,`.find(p)`,`.toArray()`,`.toJSON()`],check:[`.some(p)`,`.every(p)`,`.count()`]}},Task:{description:`Async operations with cancellation and progress tracking. Returns TaskOutcome<T> (Ok/Err) which implements Functor, AsyncMonad, Foldable, Extractable, Serializable`,interfaces:r(`Task`),methods:{create:[`Task(params).Async(fn, errFn)`,`Task(params).Sync(fn, errFn)`,`Task.ok(value)`,`Task.err(error)`,`Task.fromEither(either)`,`Task.fromTry(try)`,`Task.fromPromise(fn)`,`Task.fromNodeCallback(fn)`,`Task.fromJSON(json) — reconstruct from serialize() output`],transform:[`.map(f)`,`.flatMap(f)`,`.mapError(f)`,`.recover(v)`,`.recoverWith(f)`],extract:[`.fold(onErr, onOk)`,`.match({Ok, Err})`,`.orElse(v)`,`.orThrow()`,`.toEither()`,`.toOption()`,`.toJSON()`],other:[`Task.cancellable(fn)`,`Task.withProgress(fn, onProgress)`,`Task.race(tasks, timeout?)`,`Task.getErrorChain(error)`,`Task.formatErrorChain(error)`]}},TaskOutcome:{description:`Result of a Task execution — Ok<T> or Err<T>. Implements Functor, AsyncMonad, Foldable, Extractable, Serializable. Construct via Ok(v) / Err(e) or as the resolved value of Task(...).Sync() / Task(...).Async().`,interfaces:[`AsyncMonad`,`Extractable`,`Foldable`,`Functor`,`Serializable`],methods:{create:[`Ok(value)`,`Err(error)`,`Task.ok(value)`,`Task.err(error)`],transform:[`.map(f)`,`.flatMap(f)`,`.mapError(f)`,`.recover(v)`,`.recoverWith(f)`,`.mapAsync(f)`,`.flatMapAsync(f)`],extract:[`.fold(onErr, onOk)`,`.match({Ok, Err})`,`.orElse(v)`,`.orThrow()`,`.toEither()`,`.toOption()`,`.toJSON()`],check:[`.isOk()`,`.isErr()`,`.isSuccess()`,`.isFailure()`]}},TaskResult:{description:"Type alias for `Promise<TaskOutcome<T>>`. Returned by Task(params).Async(...) and adapter functions like Fs.readFile, Process.exec. Await it to get the inner TaskOutcome; chain Promise methods on the outside, TaskOutcome methods after the await.",interfaces:[],methods:{create:[`Task(params).Async(fn, errFn) → TaskResult<T>`,`Task.fromPromise(fn) → (...args) => TaskResult<U>`],other:[`await taskResult → TaskOutcome<T>`,`// then use any TaskOutcome method (.fold, .map, .toEither, ...)`]}},Exit:{description:`Outcome of running an IO effect — Success | Failure | Die | Interrupted, returned by .runExit(). Die carries a defect: a value that is not an E. Either has no branch for one, so .run() cannot show it.`,interfaces:[],methods:{create:[`Exit.succeed(v)`,`Exit.fail(e)`,`Exit.die(defect)`,`Exit.interrupt(fiberId)`,`Exit.interrupted()`],transform:[`.map(f)`,`.mapError(f)`,`.mapBoth(onErr, onOk)`,`.flatMap(f)`],extract:[`.fold(onFailure, onSuccess, onInterrupted?, onDie?)`,`.match({Success, Failure, Interrupted, Die?})`,`.orThrow()`,`.orElse(v)`,`.toOption()`,`.toEither()`,`.toValue()`],check:[`.isSuccess()`,`.isFailure()`,`.isDie()`,`.isInterrupted()`],other:[`Exit.zip(a, b)`,`Exit.all(exits)`,`Exit.fromEither(e)`,`Exit.fromOption(o, onNone)`,`// after a guard: .value / .error / .defect / .fiberId`,`// onDie / Die are optional and fall back to the failure handler`,`// defects stay recoverable: .recover/.recoverWith/.fold/.mapError treat Die as Failure`]}},IO:{description:`Lazy effect type with typed errors and dependency injection`,interfaces:[`Functor`,`Monad`,`Foldable`,`Matchable`],methods:{create:[`IO(() => v)`,`IO.succeed(v)`,`IO.fail(e)`,`IO.sync(f)`,`IO.async(f)`,`IO.tryPromise({try, catch})`,`IO.fromEither(e)`,`IO.fromPromiseEither(f, onReject?)`,`IO.fromOption(o)`,`IO.fromTry(t)`,`IO.die(defect)`],transform:[`.map(f)`,`.flatMap(f)`,`.tap(f)`,`.mapError(f)`,`.recover(v)`,`.recoverWith(f)`],extract:[`.run() // Either<E,A> — a defect or interruption arrives in the Left, raw`,`.runOrThrow()`,`.runSync()`,`.runSyncOrThrow()`,`.runExit() // Exit<E,A> — the only terminal that distinguishes Failure/Die/Interrupted`,`.runCancellable() // { result, cancel }`,`.runExit({ signal }) // Interrupted on abort, E unchanged`,`.runOption()`,`.runTry()`,`.fold(onErr, onOk)`,`.match({failure, success})`],check:[],other:[`.catchTag(tag, f)`,`.catchAll(f)`,`.retry(n)`,`.retryWithDelay(n, ms)`,`.retryWhile({ n, while, delayMs? })`,`.retryWithBackoff({ n, baseMs, maxMs?, factor?, jitter?, while? })`,`.repeatUntil(done, { max, delayMs? })`,`.repeatWhile(cont, { max, delayMs? })`,`.timeout(ms)`,`.interruptOn(signal) // stops at the next step once the AbortSignal fires; E gains InterruptedError`,`IO.async((signal?) => fetch(url, { signal })) // thunk gets the run's AbortSignal inside a region`,`.delay(ms)`,`.zip(io)`,`.pipe(f)`,`IO.all([...], { concurrency? }) // in order by default; first failure interrupts the rest`,`IO.forEach(items, f, { concurrency? })`,`IO.race([...])`,`IO.iterate(seed, step, done, { max? })`,`IO.bracket(acquire, use, release)`,`IO.gen(function*() {...})`,`IO.Do.bind().map()`,`IO.service(Tag)`,`.provideService(Tag, impl)`,`.provideLayer(layer)`]}},Cond:{description:`Conditional expression builder - replace if-else chains`,interfaces:[],methods:{create:[`Cond<T>()`],other:[`.case(pred, result)`,`.otherwise(result)`,`.eval()`]}},Match:{description:`Pattern matching - replace switch statements`,interfaces:[],methods:{create:[`Match(value)`],other:[`.case(pattern, result)`,`.when(pred, result)`,`.default(result)`,`.done()`]}},Brand:{description:`Nominal typing without runtime overhead`,interfaces:[],methods:{create:[`Brand<K, T>(value)`],extract:[`.unwrap()`,`.toString()`]}},Wire:{description:`Serialization-boundary marker for a row, collection or nullable field at DB / HTTP / JSONB boundaries. Zero runtime, assignable both ways with T. prefer-list and prefer-option skip everything inside it. A collection is Wire<ReadonlyArray<Row>>.`,interfaces:[],methods:{create:[`type UserRow = Wire<{ email: string | null }>`,`type Rows = Wire<ReadonlyArray<Row>>`,`email: Wire<string | null>`],other:[`List(rows).filter(...) // convert to List for transformation`,`Option(row.email) // convert to Option`]}},ValidatedBrand:{description:`Branded types with runtime validation`,interfaces:[],methods:{create:[`ValidatedBrand(validator)`,`.of(v)`,`.from(v)`,`.unsafeOf(v)`],check:[`.is(v)`],other:[`.refine(validator)`]}},Tuple:{description:`Fixed-size typed array`,interfaces:r(`Tuple`,`Typeable`,`Valuable`,`Iterable`),methods:{create:[`Tuple([a, b, ...])`,`Tuple.of(a, b, ...)`,`Tuple.fromJSON(json)`],extract:[`.get(i)`,`.length`,`.toArray()`,`.toJSON()`],transform:[`.map(f)`]}},Identity:{description:`The identity monad: wraps a value with no extra effect. Useful as a neutral container in generic code.`,interfaces:[],methods:{create:[`Identity(value)`,`Identity.of(value)`,`Identity.pure(value)`],extract:[`.id`],other:[`.isSame(other)`]}},Ref:{description:`Mutable reference cell for controlled, local mutability. Invariant in A by design (a mutable cell can't be widened).`,interfaces:[],methods:{create:[`Ref(initial)`,`Ref.of(initial)`],extract:[`.get()`],transform:[`.set(a)`,`.update(f)`,`.modify(f) // returns B, stores A`],other:[`.getAndSet(a)`,`.updateAndGet(f)`,`.getAndUpdate(f)`,`.compareAndSet(expected, next)`]}},Do:{description:`Generator do-notation across Option, Either, List and Try (DoAsync for promises). Short-circuits on None/Left/Failure/empty List.`,interfaces:[],methods:{create:[`Do(function* () { const a = yield* $(opt); return a })`,`DoAsync(async function* () { … })`],other:[`$(monad) // unwrap inside Do`,`isDoCapable(value)`,`unwrap(monad)`]}},invariant:{description:`One-line bug check: invariant(cond, msg) throws a tagged InvariantViolation when cond is falsy and narrows cond after it. For programmer errors only; expected failures return Either.`,interfaces:[],methods:{create:[`invariant(row, "upsert returned no row")`,"invariant(n >= 0, () => `bad step ${n}`) // lazy message"],other:[`InvariantViolation(msg) // throw directly for an unreachable branch`]}},TracedOption:{description:`Opt-in Option wrapper that emits one TraceEvent per combinator to an injected Tracer, then delegates. For code-path introspection.`,interfaces:[],methods:{create:[`TracedOption(option, tracer, spanId, seq?)`],transform:[`.map(f, label?)`,`.flatMap(f, label?)`,`.filter(p, label?)`],extract:[`.fold(onNone, onSome, label?)`,`.orElse(default, label?)`,`.unwrap() // back to Option`]}},Tracer:{description:`One-method trace sink consumed by TracedOption. Type-only, like Logger; declare your own Tag for injection.`,interfaces:[],methods:{create:[`const tracer: Tracer = { emit: (e: TraceEvent) => … }`],other:[`TraceEvent: { spanId, seq, op, tag, inTag, outTag?, label?, meta? }`]}},Stack:{description:`Immutable LIFO stack`,interfaces:[`Foldable`,`Collection`,`Serializable`,`Traversable`],methods:{create:[`Stack()`,`Stack.of(...)`],transform:[`.push(v)`,`.pop()`],extract:[`.peek()`,`.toArray()`],check:[`.isEmpty`,`.size`]}},Http:{description:"HTTP fetch wrapper returning IO<never, HttpError, HttpResponse<T>>. Pass `decode: Decoder<T>` (Either-returning) for typed responses; the deprecated `validate: (data) => T` field is still accepted for throw-pattern back-compat. Request bodies auto-flatten functype ADTs to primitives; `flatten: false` preserves tagged emission for functype-to-functype services. Per-call `params` (HttpQueryParams) appends query strings with proper encoding. Http.client accepts `beforeRequest` and `afterResponse` (both effectful IO transformers). `afterResponse` runs on the success path only — error handling belongs in .catchTag. Composes via .tap/.map/.flatMap/.catchTag/.retry/.retryWhile/.retryWithBackoff/.timeout.",interfaces:[],methods:{create:[`Http.get(url, { decode, params }?)`,`Http.post(url, { body, decode, params }?)`,`Http.put(url, { body, decode, params }?)`,`Http.patch(url, { body, decode, params }?)`,`Http.delete(url, { decode, params }?)`,`Http.request({ url, decode, params })`,`Http.client({ baseUrl, defaultHeaders, fetch, beforeRequest, afterResponse })`],transform:[`.tap(f)`,`.map(f)`,`.flatMap(f)`,`.mapError(f)`,`.retry(n)`,`.retryWithDelay(n, ms)`,`.retryWhile({ n, while, delayMs? })`,`.retryWithBackoff({ n, baseMs, maxMs?, factor?, jitter?, while? })`,`.timeout(ms)`],extract:[`.run()`,`.runOrThrow()`,`.runOption()`,`.runTry()`,`.runExit()`,`.runCancellable()`],check:[],other:[`.catchTag(tag, handler)`,`.catchAll(handler)`,`.recover(fallback)`,`decode: Decoder<T> (Either-returning, structural failures preserved)`,`validate: (data) => T (deprecated, throws — for back-compat / Zod .parse)`,`flatten: boolean (default true; false preserves tagged emission)`,`encode: Encoder<TReq> = (value) => JSONValue (custom wire shape; overrides flatten)`,`params: HttpQueryParams (scalar | array; undefined/null dropped; percent-encoded)`,`beforeRequest: (req) => IO<never, HttpError, HttpRequestView>`,`afterResponse: (HttpResponse<unknown>) => IO<never, HttpError, HttpResponse<unknown>> — success path only; refresh-on-401 uses .catchTag`]}},HttpError:{description:`Three-variant ADT for HTTP failures: NetworkError | HttpStatusError | DecodeError (also exported as ResponseDecodeError alias)`,interfaces:[],methods:{create:[`HttpError.networkError(url, method, cause)`,`HttpError.httpStatusError(url, method, status, statusText, body)`,`HttpError.decodeError(url, method, body, cause)`],check:[`HttpError.isNetworkError(e)`,`HttpError.isHttpStatusError(e)`,`HttpError.isDecodeError(e)`],other:[`HttpError.match(error, { NetworkError, HttpStatusError, DecodeError })`]}},Decoder:{description:"Either-returning decoder contract: `Decoder<A> = (raw: unknown) => Either<DecoderError, A>`. Bundled combinators for primitives + functype ADTs (Option/Either/List/Map, null-bias). `Decoder.tagged.*` round-trips the `{_tag, value}` shape for functype-to-functype services.",interfaces:[],methods:{create:[`Decoder.string / .number / .boolean / .unknown / .nullable(inner)`,`Decoder.fromThrowing(parse) // adapt a throwing parser such as Zod's schema.parse`,`Decoder.option(inner)`,`Decoder.either.envelope({ok, err})`,`Decoder.either.discriminated({tag, leftTag, rightTag}, l, r)`,`Decoder.list(inner) / .array(inner) / .map(inner)`,`Decoder.object({k: Decoder<V>, ...}) — accumulates field failures into Composite`,`Decoder.tagged.option/either/try/list/map/obj(inner?) — round-trips {_tag, value}`],other:[`Pluggable by construction: any (raw) => Either<DecoderError, T> IS a Decoder<T>`,`Composes across sources: Decoder.object({a: Decoder.fromZod(s), b: Decoder.option(myAjv)})`]}},DecoderError:{description:"Recursive ADT for decoder failures: Leaf | Composite. Children mirror the input tree so multi-field failures preserve structural paths. Distinct from `HttpError.DecodeError` — this is the inner structural cause that the HTTP wrapper carries.",interfaces:[],methods:{create:[`DecoderError.leaf(path, message, cause?)`,`DecoderError.composite(path, children: List<DecoderError>)`],check:[`DecoderError.isLeaf(e)`,`DecoderError.isComposite(e)`],other:[`DecoderError.match(e, { Leaf, Composite })`,`DecoderError.prepend(segment, e) — used by combinators to attribute child failures`,`DecoderError.flatten(e): List<{path, message}> — collect leaves`,`DecoderError.format(e): string — render tree as multi-line`]}},Serialization:{description:"Universal `@functype`-marked JSON serialization. `deserialize` walks parsed JSON and reconstructs any functype value found — no type argument needed. Lenient: plain JSON passes through. Strict on unknown markers (defends against Effect/fp-ts `_tag` collision). 1.2.1 adds `toEnvelope`/`fromEnvelope` for nesting inside structured serializers (SuperJSON, DBOS), and `deserializeStrict` for boundaries that require functype on the wire.",interfaces:[],methods:{create:[],transform:[`Serialization.serialize(value: unknown): string — lenient JSON codec`,`Serialization.deserialize(json: string): Try<unknown> — lenient; pass-through for unmarked JSON`,`Serialization.deserializeStrict(json: string): Try<unknown> — Failure if no @functype marker at top level`,`Serialization.toEnvelope(value: unknown): JSONValue — parsed JSON shape (1.2.2 tightened from unknown)`,`Serialization.fromEnvelope(envelope: unknown): Try<unknown> — inverse of toEnvelope; input stays permissive (Postel's law)`,`Serialization.JSONValue — exported recursive type for the envelope shape`],check:[`Serialization.isFunctypeValue(v): v is Serializable<unknown>`],other:[`Plain JSON passthrough: non-functype data walks through unchanged (use deserializeStrict to reject)`,`Strict policy on unknown markers: unknown @functype marker → Try.Failure`,`Dispatch table covers all 12 Serializable types (Option, Either, Try, List, Set, Map, Obj, Stack, Tuple, LazyList, Lazy, Task)`,`Algebraic square: serialize ≡ JSON.stringify ∘ toEnvelope; deserialize ≡ fromEnvelope ∘ JSON.parse`,`No DBOS / SuperJSON facade — consumers wire host serializer in ~8 lines via toEnvelope/fromEnvelope`]}},SerializedError:{description:"Canonical Error projection used by Try.Failure, Task.Err, Lazy-with-thrown-thunk. Round-trips name + message + stack + cause chain. `e.name === 'TypeError'` survives; `instanceof TypeError` does NOT.",interfaces:[],methods:{create:[`serializeError(err: unknown): SerializedError`,`deserializeError(s: SerializedError | string): Error`],other:[`Shape: { name: string; message: string; stack?: string; cause?: SerializedError | string }`,`Non-Error throwables (strings, plain objects) projected under name: 'NonErrorThrowable'`,`Cause chain is recursive — arbitrary nesting depth survives`]}},Logger:{description:`Minimal 4-method logging interface every functype-* package targets. Type-only, no runtime. Impls live in consumers: consoleBootLogger (functype-os/config), DirectLogger (functype-log/direct). Tracer is type-only on the same terms; Clock/Random are not added.`,interfaces:[],methods:{create:[`interface Logger { debug, info, warn, error: (msg, meta?) => void }`,`import type { Logger } from "functype"`],check:[],other:[`All 4 methods MANDATORY (no defensive logger.debug?.() at call sites)`,`Signature: (message: string, metadata?: Record<string, unknown>) => void`,`DirectLogger from functype-log/direct structurally satisfies Logger (superset shape)`,`IO-shaped Logger from functype-log does NOT satisfy core Logger (methods return IO<>, not void) — bridge via toDirectLogger(ioLogger)`,`Used by: bootDiagnostics({ logger? }) in functype-os/config`]}},TypedError:{description:`Code-tagged structured error ADT (extends Throwable); TypedError.validation(...) feeds accumulating validation.`,interfaces:[],methods:{create:[`TypedError.validation(field, value, rule) → TypedError<"VALIDATION_FAILED">`,`TypedError.badRequest(reason, expected?)`,`TypedError.notFound(resource, id)`,`TypedError.auth(resource, requiredRole?)`,`TypedError.permission(action, resource, userId?)`,`TypedError.conflict(resource, value) / .rateLimit(limit, window, retryAfter?)`,`TypedError.timeout(ms, operation) / .network(url, method, status?) / .internal(errorId)`],check:[`TypedError.isTypedError(v)`,`TypedError.hasCode(e, code)`],other:[`Fields: .code, .message, .status (HTTP), .context, .timestamp, .traceId?`,`VALIDATION_FAILED context shape: { field, value, rule }`]}},Validation:{description:`Error-accumulating validation (functype's Validated role) — FormValidation<T> collects all field errors, not fail-fast.`,interfaces:[],methods:{create:[`Validation.rule<T>('min:18' | 'email' | 'required' | 'in:a,b' | ...)`,`Validation.combine(...validators) / Validation.custom(predicate, message)`,`Validation.validators.email / .url / .uuid / .required / .numeric / .positiveNumber / .nonEmptyString`],transform:[`Validation.form(schema, data) → FormValidation<T> (accumulates all field errors)`,`Validator<T> = (value: unknown) => Either<TypedError<'VALIDATION_FAILED'>, T>`],other:[`FormValidation<T> = Either<List<TypedError<"VALIDATION_FAILED">>, T> — functype's "Validated" accumulating result type`,`form() is flat/per-field: for cross-field (lo < hi) or dynamic-key (weights.*) checks, hand-accumulate into a List<TypedError> and return the FormValidation shape`]}}},a={Functor:{description:`Transform contained values`,methods:[`.map<B>(f: A => B): Functor<B>`]},Applicative:{extends:`Functor`,description:`Apply wrapped functions`,methods:[`.ap<B>(ff: Applicative<A => B>): Applicative<B>`]},Monad:{extends:`Applicative`,description:`Chain operations returning wrapped values`,methods:[`.flatMap<B>(f: A => Monad<B>): Monad<B>`]},Foldable:{description:`Extract via pattern matching`,methods:[`.fold<B>(empty: () => B, f: A => B): B`,`.foldLeft<B>(z: B, op: (B, A) => B): B`,`.foldRight<B>(z: B, op: (A, B) => B): B`]},Extractable:{description:`Get contained value with fallback`,methods:[`.orElse(d: T): T`,`.orThrow(e?: Error): T`,`.expect(handler: (e?) => never): T`,`.orNull(): T | null`,`.orUndefined(): T | undefined`]},Matchable:{description:`Pattern match on type variants`,methods:[`.match<R>(patterns: Record<Tag, Handler>): R`]},Traversable:{description:`Iterate and check contents`,methods:[`.size: number`,`.isEmpty: boolean`,`.contains(v: A): boolean`,`.reduce<B>(f, init): B`]},Collection:{description:`Collection operations`,methods:[`.toArray(): A[]`,`.forEach(f: A => void): void`]},Serializable:{description:`Convert to string formats`,methods:[`.serialize().toJSON(): string`,`.serialize().toYAML(): string`]}},o={Core:[`Option`,`Either`,`Try`,`Obj`,`Identity`],Collection:[`List`,`Set`,`Map`,`LazyList`,`Tuple`,`Stack`],Effect:[`IO`,`Exit`,`Task`,`TaskOutcome`,`TaskResult`,`Http`,`HttpError`,`Decoder`,`DecoderError`],Utility:[`Lazy`,`Cond`,`Match`,`Do`,`Ref`,`Brand`,`ValidatedBrand`,`Wire`,`invariant`,`TracedOption`],Validation:[`TypedError`,`Validation`],Serialization:[`Serialization`,`SerializedError`],Service:[`Logger`,`Tracer`]},s={Option:`export interface Option<out T extends Type>
|
|
1
|
+
var e=`1.26.1`;const t={Option:[`Applicative`,`AsyncMonad`,`Doable`,`Extractable`,`Foldable`,`Functor`,`Matchable`,`Monad`,`Promisable`,`Reshapeable`,`Serializable`,`Traversable`],Either:[`Applicative`,`AsyncMonad`,`Doable`,`Extractable`,`Foldable`,`Functor`,`Monad`,`Promisable`,`Reshapeable`,`Serializable`],Try:[`Applicative`,`AsyncMonad`,`Doable`,`Extractable`,`Foldable`,`Functor`,`Monad`,`Promisable`,`Reshapeable`,`Serializable`],List:[`Collection`,`Doable`,`Iterable`,`Reshapeable`],Set:[`Collection`,`Iterable`],Map:[`Collection`,`Foldable`,`Iterable`,`KVTraversable`,`Serializable`],Obj:[`Doable`,`Promisable`,`Reshapeable`],Lazy:[`Applicative`,`AsyncMonad`,`Extractable`,`Foldable`,`Functor`,`Monad`,`Serializable`,`Traversable`],LazyList:[`Foldable`,`Serializable`],Tuple:[`Foldable`,`Serializable`],Task:[`Applicative`,`AsyncMonad`,`Doable`,`Extractable`,`Foldable`,`Functor`,`Monad`,`Promisable`,`Serializable`,`Traversable`]},n=e,r=(e,...n)=>Array.from(/* @__PURE__ */ new Set([...t[e],...n])).sort(),i={Option:{description:`Safe nullable handling - Some<T> or None`,interfaces:r(`Option`),methods:{create:[`Option(v)`,`Option.none()`,`Some(v)`,`None()`],transform:[`.map(f)`,`.flatMap(f)`,`.filter(p)`,`.ap(ff)`],extract:[`.fold(n, s)`,`.foldAsync(n, s)`,`.orElse(d)`,`.orThrow(err | () => Error)`,`.expect(() => never)`,`.orNull()`,`.match({Some, None})`,`.toEither(left | () => left)`,`.toList()`,`.toArray()`],check:[`.isSome()`,`.isNone()`,`.isEmpty`,`.exists(p)`,`.every(p)`],other:[`Option.sequence(arr)`,`Option.traverse(arr, f)`]}},Either:{description:`Error handling with Left (error) or Right (success)`,interfaces:r(`Either`,`Traversable`),methods:{create:[`Right(v)`,`Left(e)`,`Either.right(v)`,`Either.left(e)`,`Either.void()`],transform:[`.map(f)`,`.flatMap(f)`,`.mapLeft(f)`,`.swap()`],extract:[`.fold(l, r)`,`.foldAsync(l, r)`,`.orElse(d)`,`.orThrow(err | (left) => Error)`,`.expect((l) => never)`,`.match({Left, Right})`],check:[`.isRight()`,`.isLeft()`,`.exists(p)`,`.every(p)`],other:[`Either.sequence(arr)`,`Either.traverse(arr, f)`,`Either.traverseAsync(items, f, {concurrency?}) // in order by default, stops at first Left`,`Either.fromNullable(v, e)`]}},Try:{description:`Wrap operations that may throw - Success<T> or Failure`,interfaces:r(`Try`,`Matchable`,`Traversable`),methods:{create:[`Try(() => expr)`,`Try.success(v)`,`Try.failure(e)`,`Try.fromPromise(p)`,`Try.async(() => Promise<T>)`],transform:[`.map(f)`,`.flatMap(f)`,`.recover(f)`,`.recoverWith(f)`],extract:[`.fold(f, s)`,`.foldAsync(f, s)`,`.orElse(d)`,`.orThrow(err | (error) => Error)`,`.expect((e) => never)`,`.toOption()`,`.toEither(left | (err) => left)`,`.toList()`,`.toArray()`],check:[`.isSuccess()`,`.isFailure()`,`.exists(p)`,`.every(p)`],other:[`Try.sequence(arr)`,`Try.traverse(arr, f)`]}},List:{description:`Immutable array with functional operations`,interfaces:r(`List`,`Functor`,`Monad`,`Foldable`,`Serializable`,`Traversable`),methods:{create:[`List([...])`,`List.of(...)`,`List.empty()`],transform:[`.map(f)`,`.flatMap(f)`,`.filter(p)`,`.take(n)`,`.takeWhile(p)`,`.takeRight(n)`,`.drop(n)`,`.dropRight(n)`,`.dropWhile(p)`,`.flatten()`,`.concat(list)`,`.reverse()`,`.distinct()`,`.sorted()`,`.sortBy(f)`,`.zip(list)`,`.zipWithIndex()`,`.prepend(v)`,`.slice(s, e)`],extract:[`.fold(z, f)`,`.reduce(f)`,`.head`,`.headOption`,`.tail`,`.last`,`.lastOption`,`.init`,`.indexOf(v)`,`.toArray()`],check:[`.isEmpty`,`.size`,`.contains(v)`,`.exists(p)`,`.every(p)`],other:[`.groupBy(f)`,`.partition(p)`,`.span(p)`,`.mapAsync(f, {concurrency?}) // in order by default`,`.flatMapAsync(f, {concurrency?})`]}},Set:{description:`Immutable set of unique values`,interfaces:r(`Set`,`Functor`,`Foldable`,`Serializable`,`Traversable`),methods:{create:[`Set([...])`,`Set.of(...)`,`Set.empty()`],transform:[`.map(f)`,`.flatMap(f)`,`.filter(p)`,`.filterNot(p)`,`.add(v)`,`.remove(v)`,`.union(other)`,`.intersection(other)`,`.difference(other)`,`.symmetricDifference(other)`,`.mapAsync(f, {concurrency?}) // in order by default`],extract:[`.fold(z, f)`,`.toArray()`],check:[`.has(v)`,`.isEmpty`,`.size`,`.exists(p)`,`.every(p)`,`.isSubsetOf(other)`,`.isSupersetOf(other)`,`.isDisjointFrom(other)`],other:[`import { Set } from "functype" // its own name; the built-in is globalThis.Set`]}},Obj:{description:`Immutable object wrapper with fluent operations`,interfaces:r(`Obj`,`KVTraversable`,`Foldable`,`Matchable`,`Extractable`,`Serializable`),methods:{create:[`Obj({...})`,`Obj.of({...})`,`Obj.empty()`],transform:[`.set(k, v)`,`.assign(partial)`,`.merge(obj)`,`.when(cond, partial)`,`.omit(...keys)`,`.pick(...keys)`,`.map(f)`,`.flatMap(f)`],extract:[`.get(k)`,`.value()`,`.keys()`,`.values()`,`.entries()`,`.fold(n, s)`,`.match({Obj})`],check:[`.has(k)`,`.isEmpty`,`.size`]}},Map:{description:`Immutable key-value store`,interfaces:r(`Map`),methods:{create:[`Map([[k, v], ...])`,`Map.of([k, v], ...)`,`Map.empty()`,`Map.fromJSON(json)`,`Map.fromYAML(yaml)`,`Map.fromBinary(b)`],transform:[`.add(Tuple([k, v]))`,`.remove(k)`,`.map(f)`,`.flatMap(f)`,`.ap(ff)`,`.flatMapAsync(f)`],extract:[`.get(k) // Option<V>`,`.keys() // List<K>`,`.values() // List<V>`,`.getOrElse(k, d)`,`.orElse(k, Option<V>)`,`.fold(z, f)`,`.foldLeft(z)(f)`,`.foldRight(z)(f)`,`.match({Empty, NonEmpty})`,`.toList()`,`.toSet()`,`[...map] // iterate [k, v] pairs`],check:[`.has(k) // key only`,`.contains(Tuple([k, v])) // === on the value`,`.isEmpty`,`.size`],other:[`import { Map } from "functype" // its own name; the built-in is globalThis.Map`]}},Lazy:{description:"Deferred computation with memoization. Note: `serialize()` and `toValue()` FORCE the thunk (visible side effect) since a closure cannot be JSON-serialized — there is no representable 'unevaluated post-serialize' state. Thunk failures are captured via SerializedError and rethrown on access after fromJSON.",interfaces:r(`Lazy`),methods:{create:[`Lazy(() => expr)`,`Lazy.fromValue(value) — wrap a non-deferred value`,`Lazy.evaluated(value) — reads as 'already-forced'; used by fromJSON`,`Lazy.fail(error) — Lazy that throws on access`],transform:[`.map(f)`,`.flatMap(f)`],extract:[`.fold(f)`,`.foldWith(onFailure, onSuccess)`,`.orElse(d)`,`.orNull()`,`.orThrow()`,`.toJSON()`,`Lazy.fromJSON(json)`],check:[`.isEvaluated`]}},LazyList:{description:`Lazy sequences for large/infinite data`,interfaces:r(`LazyList`,`Functor`,`Monad`,`Iterable`),methods:{create:[`LazyList(iterable)`,`LazyList.from(a, b, ...)`,`LazyList.of(a, b, ...)`,`LazyList.range(start, end)`,`LazyList.iterate(seed, f)`,`LazyList.generate(f)`,`LazyList.fromJSON(json)`],transform:[`.map(f)`,`.filter(p)`,`.take(n)`,`.takeRight(n)`,`.drop(n)`,`.takeWhile(p)`,`.dropWhile(p)`,`.concat(ll)`,`.reverse()`,`.distinct()`,`.zip(ll)`,`.zipWithIndex()`],extract:[`.head`,`.headOption`,`.tail`,`.last`,`.lastOption`,`.init`,`.find(p)`,`.toArray()`,`.toJSON()`],check:[`.some(p)`,`.every(p)`,`.count()`]}},Task:{description:`Async operations with cancellation and progress tracking. Returns TaskOutcome<T> (Ok/Err) which implements Functor, AsyncMonad, Foldable, Extractable, Serializable`,interfaces:r(`Task`),methods:{create:[`Task(params).Async(fn, errFn)`,`Task(params).Sync(fn, errFn)`,`Task.ok(value)`,`Task.err(error)`,`Task.fromEither(either)`,`Task.fromTry(try)`,`Task.fromPromise(fn)`,`Task.fromNodeCallback(fn)`,`Task.fromJSON(json) — reconstruct from serialize() output`],transform:[`.map(f)`,`.flatMap(f)`,`.mapError(f)`,`.recover(v)`,`.recoverWith(f)`],extract:[`.fold(onErr, onOk)`,`.match({Ok, Err})`,`.orElse(v)`,`.orThrow()`,`.toEither()`,`.toOption()`,`.toJSON()`],other:[`Task.cancellable(fn)`,`Task.withProgress(fn, onProgress)`,`Task.race(tasks, timeout?)`,`Task.getErrorChain(error)`,`Task.formatErrorChain(error)`]}},TaskOutcome:{description:`Result of a Task execution — Ok<T> or Err<T>. Implements Functor, AsyncMonad, Foldable, Extractable, Serializable. Construct via Ok(v) / Err(e) or as the resolved value of Task(...).Sync() / Task(...).Async().`,interfaces:[`AsyncMonad`,`Extractable`,`Foldable`,`Functor`,`Serializable`],methods:{create:[`Ok(value)`,`Err(error)`,`Task.ok(value)`,`Task.err(error)`],transform:[`.map(f)`,`.flatMap(f)`,`.mapError(f)`,`.recover(v)`,`.recoverWith(f)`,`.mapAsync(f)`,`.flatMapAsync(f)`],extract:[`.fold(onErr, onOk)`,`.match({Ok, Err})`,`.orElse(v)`,`.orThrow()`,`.toEither()`,`.toOption()`,`.toJSON()`],check:[`.isOk()`,`.isErr()`,`.isSuccess()`,`.isFailure()`]}},TaskResult:{description:"Type alias for `Promise<TaskOutcome<T>>`. Returned by Task(params).Async(...) and adapter functions like Fs.readFile, Process.exec. Await it to get the inner TaskOutcome; chain Promise methods on the outside, TaskOutcome methods after the await.",interfaces:[],methods:{create:[`Task(params).Async(fn, errFn) → TaskResult<T>`,`Task.fromPromise(fn) → (...args) => TaskResult<U>`],other:[`await taskResult → TaskOutcome<T>`,`// then use any TaskOutcome method (.fold, .map, .toEither, ...)`]}},Exit:{description:`Outcome of running an IO effect — Success | Failure | Die | Interrupted, returned by .runExit(). Die carries a defect: a value that is not an E. Either has no branch for one, so .run() cannot show it.`,interfaces:[],methods:{create:[`Exit.succeed(v)`,`Exit.fail(e)`,`Exit.die(defect)`,`Exit.interrupt(fiberId)`,`Exit.interrupted()`],transform:[`.map(f)`,`.mapError(f)`,`.mapBoth(onErr, onOk)`,`.flatMap(f)`],extract:[`.fold(onFailure, onSuccess, onInterrupted?, onDie?)`,`.match({Success, Failure, Interrupted, Die?})`,`.orThrow()`,`.orElse(v)`,`.toOption()`,`.toEither()`,`.toValue()`],check:[`.isSuccess()`,`.isFailure()`,`.isDie()`,`.isInterrupted()`],other:[`Exit.zip(a, b)`,`Exit.all(exits)`,`Exit.fromEither(e)`,`Exit.fromOption(o, onNone)`,`// after a guard: .value / .error / .defect / .fiberId`,`// onDie / Die are optional and fall back to the failure handler`,`// defects stay recoverable: .recover/.recoverWith/.fold/.mapError treat Die as Failure`]}},IO:{description:`Lazy effect type with typed errors and dependency injection`,interfaces:[`Functor`,`Monad`,`Foldable`,`Matchable`],methods:{create:[`IO(() => v)`,`IO.succeed(v)`,`IO.fail(e)`,`IO.sync(f)`,`IO.async(f)`,`IO.tryPromise({try, catch})`,`IO.fromEither(e)`,`IO.fromPromiseEither(f, onReject?)`,`IO.fromOption(o)`,`IO.fromTry(t)`,`IO.die(defect)`],transform:[`.map(f)`,`.flatMap(f)`,`.tap(f)`,`.mapError(f)`,`.recover(v)`,`.recoverWith(f)`],extract:[`.run() // Either<E,A> — a defect or interruption arrives in the Left, raw`,`.runOrThrow()`,`.runSync()`,`.runSyncOrThrow()`,`.runExit() // Exit<E,A> — the only terminal that distinguishes Failure/Die/Interrupted`,`.runCancellable() // { result, cancel }`,`.runExit({ signal }) // Interrupted on abort, E unchanged`,`.runOption()`,`.runTry()`,`.fold(onErr, onOk)`,`.match({failure, success})`],check:[],other:[`.catchTag(tag, f)`,`.catchAll(f)`,`.retry(n)`,`.retryWithDelay(n, ms)`,`.retryWhile({ n, while, delayMs? })`,`.retryWithBackoff({ n, baseMs, maxMs?, factor?, jitter?, while? })`,`.repeatUntil(done, { max, delayMs? })`,`.repeatWhile(cont, { max, delayMs? })`,`.timeout(ms)`,`.interruptOn(signal) // stops at the next step once the AbortSignal fires; E gains InterruptedError`,`IO.async((signal?) => fetch(url, { signal })) // thunk gets the run's AbortSignal inside a region`,`.delay(ms)`,`.zip(io)`,`.pipe(f)`,`IO.all([...], { concurrency? }) // in order by default; first failure interrupts the rest`,`IO.forEach(items, f, { concurrency? })`,`IO.race([...])`,`IO.iterate(seed, step, done, { max? })`,`IO.bracket(acquire, use, release)`,`IO.gen(function*() {...})`,`IO.Do.bind().map()`,`IO.service(Tag)`,`.provideService(Tag, impl)`,`.provideLayer(layer)`]}},Cond:{description:`Conditional expression builder - replace if-else chains`,interfaces:[],methods:{create:[`Cond<T>()`],other:[`.case(pred, result)`,`.otherwise(result)`,`.eval()`]}},Match:{description:`Pattern matching - replace switch statements`,interfaces:[],methods:{create:[`Match(value)`],other:[`.case(pattern, result)`,`.when(pred, result)`,`.default(result)`,`.done()`]}},Brand:{description:`Nominal typing without runtime overhead`,interfaces:[],methods:{create:[`Brand<K, T>(value)`],extract:[`.unwrap()`,`.toString()`]}},Wire:{description:`Serialization-boundary marker for a row, collection or nullable field at DB / HTTP / JSONB boundaries. Zero runtime, assignable both ways with T. prefer-list and prefer-option skip everything inside it. A collection is Wire<ReadonlyArray<Row>>.`,interfaces:[],methods:{create:[`type UserRow = Wire<{ email: string | null }>`,`type Rows = Wire<ReadonlyArray<Row>>`,`email: Wire<string | null>`],other:[`List(rows).filter(...) // convert to List for transformation`,`Option(row.email) // convert to Option`]}},ValidatedBrand:{description:`Branded types with runtime validation`,interfaces:[],methods:{create:[`ValidatedBrand(validator)`,`.of(v)`,`.from(v)`,`.unsafeOf(v)`],check:[`.is(v)`],other:[`.refine(validator)`]}},Tuple:{description:`Fixed-size typed array`,interfaces:r(`Tuple`,`Typeable`,`Valuable`,`Iterable`),methods:{create:[`Tuple([a, b, ...])`,`Tuple.of(a, b, ...)`,`Tuple.fromJSON(json)`],extract:[`.get(i)`,`.length`,`.toArray()`,`.toJSON()`],transform:[`.map(f)`]}},Identity:{description:`The identity monad: wraps a value with no extra effect. Useful as a neutral container in generic code.`,interfaces:[],methods:{create:[`Identity(value)`,`Identity.of(value)`,`Identity.pure(value)`],extract:[`.id`],other:[`.isSame(other)`]}},Ref:{description:`Mutable reference cell for controlled, local mutability. Invariant in A by design (a mutable cell can't be widened).`,interfaces:[],methods:{create:[`Ref(initial)`,`Ref.of(initial)`],extract:[`.get()`],transform:[`.set(a)`,`.update(f)`,`.modify(f) // returns B, stores A`],other:[`.getAndSet(a)`,`.updateAndGet(f)`,`.getAndUpdate(f)`,`.compareAndSet(expected, next)`]}},Do:{description:`Generator do-notation across Option, Either, List and Try (DoAsync for promises). Short-circuits on None/Left/Failure/empty List.`,interfaces:[],methods:{create:[`Do(function* () { const a = yield* $(opt); return a })`,`DoAsync(async function* () { … })`],other:[`$(monad) // unwrap inside Do`,`isDoCapable(value)`,`unwrap(monad)`]}},invariant:{description:`One-line bug check: invariant(cond, msg) throws a tagged InvariantViolation when cond is falsy and narrows cond after it. For programmer errors only; expected failures return Either.`,interfaces:[],methods:{create:[`invariant(row, "upsert returned no row")`,"invariant(n >= 0, () => `bad step ${n}`) // lazy message"],other:[`InvariantViolation(msg) // throw directly for an unreachable branch`]}},TracedOption:{description:`Opt-in Option wrapper that emits one TraceEvent per combinator to an injected Tracer, then delegates. For code-path introspection.`,interfaces:[],methods:{create:[`TracedOption(option, tracer, spanId, seq?)`],transform:[`.map(f, label?)`,`.flatMap(f, label?)`,`.filter(p, label?)`],extract:[`.fold(onNone, onSome, label?)`,`.orElse(default, label?)`,`.unwrap() // back to Option`]}},Tracer:{description:`One-method trace sink consumed by TracedOption. Type-only, like Logger; declare your own Tag for injection.`,interfaces:[],methods:{create:[`const tracer: Tracer = { emit: (e: TraceEvent) => … }`],other:[`TraceEvent: { spanId, seq, op, tag, inTag, outTag?, label?, meta? }`]}},Stack:{description:`Immutable LIFO stack`,interfaces:[`Foldable`,`Collection`,`Serializable`,`Traversable`],methods:{create:[`Stack()`,`Stack.of(...)`],transform:[`.push(v)`,`.pop()`],extract:[`.peek()`,`.toArray()`],check:[`.isEmpty`,`.size`]}},Http:{description:"HTTP fetch wrapper returning IO<never, HttpError, HttpResponse<T>>. Pass `decode: Decoder<T>` (Either-returning) for typed responses; the deprecated `validate: (data) => T` field is still accepted for throw-pattern back-compat. Request bodies auto-flatten functype ADTs to primitives; `flatten: false` preserves tagged emission for functype-to-functype services. Per-call `params` (HttpQueryParams) appends query strings with proper encoding. Http.client accepts `beforeRequest` and `afterResponse` (both effectful IO transformers). `afterResponse` runs on the success path only — error handling belongs in .catchTag. Composes via .tap/.map/.flatMap/.catchTag/.retry/.retryWhile/.retryWithBackoff/.timeout.",interfaces:[],methods:{create:[`Http.get(url, { decode, params }?)`,`Http.post(url, { body, decode, params }?)`,`Http.put(url, { body, decode, params }?)`,`Http.patch(url, { body, decode, params }?)`,`Http.delete(url, { decode, params }?)`,`Http.request({ url, decode, params })`,`Http.client({ baseUrl, defaultHeaders, fetch, beforeRequest, afterResponse })`],transform:[`.tap(f)`,`.map(f)`,`.flatMap(f)`,`.mapError(f)`,`.retry(n)`,`.retryWithDelay(n, ms)`,`.retryWhile({ n, while, delayMs? })`,`.retryWithBackoff({ n, baseMs, maxMs?, factor?, jitter?, while? })`,`.timeout(ms)`],extract:[`.run()`,`.runOrThrow()`,`.runOption()`,`.runTry()`,`.runExit()`,`.runCancellable()`],check:[],other:[`.catchTag(tag, handler)`,`.catchAll(handler)`,`.recover(fallback)`,`decode: Decoder<T> (Either-returning, structural failures preserved)`,`validate: (data) => T (deprecated, throws — for back-compat / Zod .parse)`,`flatten: boolean (default true; false preserves tagged emission)`,`encode: Encoder<TReq> = (value) => JSONValue (custom wire shape; overrides flatten)`,`params: HttpQueryParams (scalar | array; undefined/null dropped; percent-encoded)`,`beforeRequest: (req) => IO<never, HttpError, HttpRequestView>`,`afterResponse: (HttpResponse<unknown>) => IO<never, HttpError, HttpResponse<unknown>> — success path only; refresh-on-401 uses .catchTag`]}},HttpError:{description:`Three-variant ADT for HTTP failures: NetworkError | HttpStatusError | DecodeError (also exported as ResponseDecodeError alias)`,interfaces:[],methods:{create:[`HttpError.networkError(url, method, cause)`,`HttpError.httpStatusError(url, method, status, statusText, body)`,`HttpError.decodeError(url, method, body, cause)`],check:[`HttpError.isNetworkError(e)`,`HttpError.isHttpStatusError(e)`,`HttpError.isDecodeError(e)`],other:[`HttpError.match(error, { NetworkError, HttpStatusError, DecodeError })`]}},Decoder:{description:"Either-returning decoder contract: `Decoder<A> = (raw: unknown) => Either<DecoderError, A>`. Bundled combinators for primitives + functype ADTs (Option/Either/List/Map, null-bias). `Decoder.tagged.*` round-trips the `{_tag, value}` shape for functype-to-functype services.",interfaces:[],methods:{create:[`Decoder.string / .number / .boolean / .unknown / .nullable(inner)`,`Decoder.fromThrowing(parse) // adapt a throwing parser such as Zod's schema.parse`,`Decoder.option(inner)`,`Decoder.either.envelope({ok, err})`,`Decoder.either.discriminated({tag, leftTag, rightTag}, l, r)`,`Decoder.list(inner) / .array(inner) / .map(inner)`,`Decoder.object({k: Decoder<V>, ...}) — accumulates field failures into Composite`,`Decoder.tagged.option/either/try/list/map/obj(inner?) — round-trips {_tag, value}`],other:[`Pluggable by construction: any (raw) => Either<DecoderError, T> IS a Decoder<T>`,`Composes across sources: Decoder.object({a: Decoder.fromZod(s), b: Decoder.option(myAjv)})`]}},DecoderError:{description:"Recursive ADT for decoder failures: Leaf | Composite. Children mirror the input tree so multi-field failures preserve structural paths. Distinct from `HttpError.DecodeError` — this is the inner structural cause that the HTTP wrapper carries.",interfaces:[],methods:{create:[`DecoderError.leaf(path, message, cause?)`,`DecoderError.composite(path, children: List<DecoderError>)`],check:[`DecoderError.isLeaf(e)`,`DecoderError.isComposite(e)`],other:[`DecoderError.match(e, { Leaf, Composite })`,`DecoderError.prepend(segment, e) — used by combinators to attribute child failures`,`DecoderError.flatten(e): List<{path, message}> — collect leaves`,`DecoderError.format(e): string — render tree as multi-line`]}},Serialization:{description:"Universal `@functype`-marked JSON serialization. `deserialize` walks parsed JSON and reconstructs any functype value found — no type argument needed. Lenient: plain JSON passes through. Strict on unknown markers (defends against Effect/fp-ts `_tag` collision). 1.2.1 adds `toEnvelope`/`fromEnvelope` for nesting inside structured serializers (SuperJSON, DBOS), and `deserializeStrict` for boundaries that require functype on the wire.",interfaces:[],methods:{create:[],transform:[`Serialization.serialize(value: unknown): string — lenient JSON codec`,`Serialization.deserialize(json: string): Try<unknown> — lenient; pass-through for unmarked JSON`,`Serialization.deserializeStrict(json: string): Try<unknown> — Failure if no @functype marker at top level`,`Serialization.toEnvelope(value: unknown): JSONValue — parsed JSON shape (1.2.2 tightened from unknown)`,`Serialization.fromEnvelope(envelope: unknown): Try<unknown> — inverse of toEnvelope; input stays permissive (Postel's law)`,`Serialization.JSONValue — exported recursive type for the envelope shape`],check:[`Serialization.isFunctypeValue(v): v is Serializable<unknown>`],other:[`Plain JSON passthrough: non-functype data walks through unchanged (use deserializeStrict to reject)`,`Strict policy on unknown markers: unknown @functype marker → Try.Failure`,`Dispatch table covers all 12 Serializable types (Option, Either, Try, List, Set, Map, Obj, Stack, Tuple, LazyList, Lazy, Task)`,`Algebraic square: serialize ≡ JSON.stringify ∘ toEnvelope; deserialize ≡ fromEnvelope ∘ JSON.parse`,`No DBOS / SuperJSON facade — consumers wire host serializer in ~8 lines via toEnvelope/fromEnvelope`]}},SerializedError:{description:"Canonical Error projection used by Try.Failure, Task.Err, Lazy-with-thrown-thunk. Round-trips name + message + stack + cause chain. `e.name === 'TypeError'` survives; `instanceof TypeError` does NOT.",interfaces:[],methods:{create:[`serializeError(err: unknown): SerializedError`,`deserializeError(s: SerializedError | string): Error`],other:[`Shape: { name: string; message: string; stack?: string; cause?: SerializedError | string }`,`Non-Error throwables (strings, plain objects) projected under name: 'NonErrorThrowable'`,`Cause chain is recursive — arbitrary nesting depth survives`]}},Logger:{description:`Minimal 4-method logging interface every functype-* package targets. Type-only, no runtime. Impls live in consumers: consoleBootLogger (functype-os/config), DirectLogger (functype-log/direct). Tracer is type-only on the same terms; Clock/Random are not added.`,interfaces:[],methods:{create:[`interface Logger { debug, info, warn, error: (msg, meta?) => void }`,`import type { Logger } from "functype"`],check:[],other:[`All 4 methods MANDATORY (no defensive logger.debug?.() at call sites)`,`Signature: (message: string, metadata?: Record<string, unknown>) => void`,`DirectLogger from functype-log/direct structurally satisfies Logger (superset shape)`,`IO-shaped Logger from functype-log does NOT satisfy core Logger (methods return IO<>, not void) — bridge via toDirectLogger(ioLogger)`,`Used by: bootDiagnostics({ logger? }) in functype-os/config`]}},TypedError:{description:`Code-tagged structured error ADT (extends Throwable); TypedError.validation(...) feeds accumulating validation.`,interfaces:[],methods:{create:[`TypedError.validation(field, value, rule) → TypedError<"VALIDATION_FAILED">`,`TypedError.badRequest(reason, expected?)`,`TypedError.notFound(resource, id)`,`TypedError.auth(resource, requiredRole?)`,`TypedError.permission(action, resource, userId?)`,`TypedError.conflict(resource, value) / .rateLimit(limit, window, retryAfter?)`,`TypedError.timeout(ms, operation) / .network(url, method, status?) / .internal(errorId)`],check:[`TypedError.isTypedError(v)`,`TypedError.hasCode(e, code)`],other:[`Fields: .code, .message, .status (HTTP), .context, .timestamp, .traceId?`,`VALIDATION_FAILED context shape: { field, value, rule }`]}},Validation:{description:`Error-accumulating validation (functype's Validated role) — FormValidation<T> collects all field errors, not fail-fast.`,interfaces:[],methods:{create:[`Validation.rule<T>('min:18' | 'email' | 'required' | 'in:a,b' | ...)`,`Validation.combine(...validators) / Validation.custom(predicate, message)`,`Validation.validators.email / .url / .uuid / .required / .numeric / .positiveNumber / .nonEmptyString`],transform:[`Validation.form(schema, data) → FormValidation<T> (accumulates all field errors)`,`Validator<T> = (value: unknown) => Either<TypedError<'VALIDATION_FAILED'>, T>`],other:[`FormValidation<T> = Either<List<TypedError<"VALIDATION_FAILED">>, T> — functype's "Validated" accumulating result type`,`form() is flat/per-field: for cross-field (lo < hi) or dynamic-key (weights.*) checks, hand-accumulate into a List<TypedError> and return the FormValidation shape`]}}},a={Functor:{description:`Transform contained values`,methods:[`.map<B>(f: A => B): Functor<B>`]},Applicative:{extends:`Functor`,description:`Apply wrapped functions`,methods:[`.ap<B>(ff: Applicative<A => B>): Applicative<B>`]},Monad:{extends:`Applicative`,description:`Chain operations returning wrapped values`,methods:[`.flatMap<B>(f: A => Monad<B>): Monad<B>`]},Foldable:{description:`Extract via pattern matching`,methods:[`.fold<B>(empty: () => B, f: A => B): B`,`.foldLeft<B>(z: B, op: (B, A) => B): B`,`.foldRight<B>(z: B, op: (A, B) => B): B`]},Extractable:{description:`Get contained value with fallback`,methods:[`.orElse(d: T): T`,`.orThrow(e?: Error): T`,`.expect(handler: (e?) => never): T`,`.orNull(): T | null`,`.orUndefined(): T | undefined`]},Matchable:{description:`Pattern match on type variants`,methods:[`.match<R>(patterns: Record<Tag, Handler>): R`]},Traversable:{description:`Iterate and check contents`,methods:[`.size: number`,`.isEmpty: boolean`,`.contains(v: A): boolean`,`.reduce<B>(f, init): B`]},Collection:{description:`Collection operations`,methods:[`.toArray(): A[]`,`.forEach(f: A => void): void`]},Serializable:{description:`Convert to string formats`,methods:[`.serialize().toJSON(): string`,`.serialize().toYAML(): string`]}},o={Core:[`Option`,`Either`,`Try`,`Obj`,`Identity`],Collection:[`List`,`Set`,`Map`,`LazyList`,`Tuple`,`Stack`],Effect:[`IO`,`Exit`,`Task`,`TaskOutcome`,`TaskResult`,`Http`,`HttpError`,`Decoder`,`DecoderError`],Utility:[`Lazy`,`Cond`,`Match`,`Do`,`Ref`,`Brand`,`ValidatedBrand`,`Wire`,`invariant`,`TracedOption`],Validation:[`TypedError`,`Validation`],Serialization:[`Serialization`,`SerializedError`],Service:[`Logger`,`Tracer`]},s={Option:`export interface Option<out T extends Type>
|
|
2
2
|
extends Functype<T, "Some" | "None">, Promisable<T>, Doable<T>, Reshapeable<T> {
|
|
3
3
|
/** The contained value (undefined for None) */
|
|
4
4
|
readonly value: T | undefined
|
|
@@ -114,6 +114,18 @@ var e=`1.25.1`;const t={Option:[`Applicative`,`AsyncMonad`,`Doable`,`Extractable
|
|
|
114
114
|
* @returns true if this Option contains the value, false otherwise
|
|
115
115
|
*/
|
|
116
116
|
contains(value: T): boolean
|
|
117
|
+
/**
|
|
118
|
+
* Tests whether the value, if there is one, satisfies the predicate. The dual of \`exists\`, and
|
|
119
|
+
* Scala's \`forall\`: \`None\` gives \`true\`, the same way \`[].every(p)\` does.
|
|
120
|
+
* @param p - The predicate to test the value with
|
|
121
|
+
* @returns \`true\` for None, otherwise \`p(value)\`
|
|
122
|
+
* @example
|
|
123
|
+
* \`\`\`typescript
|
|
124
|
+
* Option("abc").every((s) => s.length > 2) // true
|
|
125
|
+
* Option<string>(undefined).every((s) => s.length > 2) // true: nothing to fail
|
|
126
|
+
* \`\`\`
|
|
127
|
+
*/
|
|
128
|
+
every(p: (a: T) => boolean): boolean
|
|
117
129
|
/**
|
|
118
130
|
* Converts this Option to a List.
|
|
119
131
|
* @returns A List containing the value if Some, or empty List if None
|
|
@@ -241,6 +253,7 @@ const RightConstructor = <L extends Type, R extends Type>(value: R): RightOf<L,
|
|
|
241
253
|
serialize: () => createSerializer("Either", "Right", value),
|
|
242
254
|
contains: (v: R) => value === v,
|
|
243
255
|
exists: (p: (a: R) => boolean) => p(value),
|
|
256
|
+
every: (p: (a: R) => boolean) => p(value),
|
|
244
257
|
forEach: (f: (a: R) => void) => f(value),
|
|
245
258
|
// Implement Doable interface for Do-notation
|
|
246
259
|
doUnwrap(): DoResult<R> {
|
|
@@ -488,6 +501,22 @@ export interface RightOf<out L extends Type, out R extends Type> extends EitherB
|
|
|
488
501
|
take: (n: number) => List<A>
|
|
489
502
|
takeWhile: (p: (a: A) => boolean) => List<A>
|
|
490
503
|
takeRight: (n: number) => List<A>
|
|
504
|
+
/** Drop the first \`n\` elements. \`n\` of 0 or less drops nothing. */
|
|
505
|
+
drop: (n: number) => List<A>
|
|
506
|
+
/** Drop the last \`n\` elements. \`n\` of 0 or less drops nothing. */
|
|
507
|
+
dropRight: (n: number) => List<A>
|
|
508
|
+
/** Drop elements while \`p\` holds. Gives an empty List when every element matches. */
|
|
509
|
+
dropWhile: (p: (a: A) => boolean) => List<A>
|
|
510
|
+
/**
|
|
511
|
+
* Spread each element that's an array or another non-string iterable (List, Set, ...) into the result,
|
|
512
|
+
* one level deep, keeping other elements, strings included, as they are.
|
|
513
|
+
* @example
|
|
514
|
+
* \`\`\`typescript
|
|
515
|
+
* List([[1, 2], [3]]).flatten() // List([1, 2, 3])
|
|
516
|
+
* List([List([1]), List([2])]).flatten() // List([1, 2])
|
|
517
|
+
* \`\`\`
|
|
518
|
+
*/
|
|
519
|
+
flatten<B = Flattened<A>>(): List<B>
|
|
491
520
|
get last(): A | undefined
|
|
492
521
|
get lastOption(): Option<A>
|
|
493
522
|
get tail(): List<A>
|
|
@@ -549,6 +578,24 @@ export interface RightOf<out L extends Type, out R extends Type> extends EitherB
|
|
|
549
578
|
mapAsync: <B>(f: (a: A) => PromiseLike<B>, options?: ConcurrencyOptions) => Promise<Set<B>>
|
|
550
579
|
filter: (p: (a: A) => boolean) => Set<A>
|
|
551
580
|
filterNot: (p: (a: A) => boolean) => Set<A>
|
|
581
|
+
// Positional methods follow insertion order. Override them to return Set instead of FunctypeCollection.
|
|
582
|
+
/** Keep the first \`n\` elements. \`n\` of 0 or less keeps none. */
|
|
583
|
+
take: (n: number) => Set<A>
|
|
584
|
+
takeWhile: (p: (a: A) => boolean) => Set<A>
|
|
585
|
+
/** Keep the last \`n\` elements. \`n\` of 0 or less keeps none. */
|
|
586
|
+
takeRight: (n: number) => Set<A>
|
|
587
|
+
/** Drop the first \`n\` elements. \`n\` of 0 or less drops nothing. */
|
|
588
|
+
drop: (n: number) => Set<A>
|
|
589
|
+
/** Drop the last \`n\` elements. \`n\` of 0 or less drops nothing. */
|
|
590
|
+
dropRight: (n: number) => Set<A>
|
|
591
|
+
dropWhile: (p: (a: A) => boolean) => Set<A>
|
|
592
|
+
get tail(): Set<A>
|
|
593
|
+
get init(): Set<A>
|
|
594
|
+
/**
|
|
595
|
+
* Spread each element that's an array or another non-string iterable into the result, one level deep,
|
|
596
|
+
* keeping other elements, strings included, as they are.
|
|
597
|
+
*/
|
|
598
|
+
flatten<B = Flattened<A>>(): Set<B>
|
|
552
599
|
fold: <B>(initial: B, fn: (acc: B, a: A) => B) => B
|
|
553
600
|
toList: () => List<A>
|
|
554
601
|
toSet: () => Set<A>
|
package/dist/functype/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { An as FunctypeBase, Mr as ConcurrencyOptions, On as FunctypeSum, jn as FunctypeCollection,
|
|
1
|
+
import { An as FunctypeBase, Mr as Concurrency, Nr as ConcurrencyOptions, On as FunctypeSum, jn as FunctypeCollection, kn as Functype } from "../index-CjqFFy4s.js";
|
|
2
2
|
export { type Concurrency, type ConcurrencyOptions, Functype, FunctypeBase, FunctypeCollection, FunctypeSum };
|
|
@@ -369,6 +369,12 @@ interface CollectionOps<out A extends Type, Self> {
|
|
|
369
369
|
*/
|
|
370
370
|
toArray<B = A>(): B[];
|
|
371
371
|
}
|
|
372
|
+
/**
|
|
373
|
+
* What `flatten` yields for one element: an iterable's items, and anything else, including a string, as
|
|
374
|
+
* itself. That matches the runtime, which spreads arrays and other non-string iterables. Languages
|
|
375
|
+
* disagree on strings: Scala and Python split them into characters, JavaScript's `flat` keeps them whole.
|
|
376
|
+
*/
|
|
377
|
+
type Flattened<A> = A extends string ? A : A extends Iterable<infer B> ? B : A;
|
|
372
378
|
//#endregion
|
|
373
379
|
//#region src/typeclass/Functor.d.ts
|
|
374
380
|
/**
|
|
@@ -1563,6 +1569,22 @@ interface List<out A> extends FunctypeCollection<A, "List">, Doable<A>, Reshapea
|
|
|
1563
1569
|
take: (n: number) => List<A>;
|
|
1564
1570
|
takeWhile: (p: (a: A) => boolean) => List<A>;
|
|
1565
1571
|
takeRight: (n: number) => List<A>;
|
|
1572
|
+
/** Drop the first `n` elements. `n` of 0 or less drops nothing. */
|
|
1573
|
+
drop: (n: number) => List<A>;
|
|
1574
|
+
/** Drop the last `n` elements. `n` of 0 or less drops nothing. */
|
|
1575
|
+
dropRight: (n: number) => List<A>;
|
|
1576
|
+
/** Drop elements while `p` holds. Gives an empty List when every element matches. */
|
|
1577
|
+
dropWhile: (p: (a: A) => boolean) => List<A>;
|
|
1578
|
+
/**
|
|
1579
|
+
* Spread each element that's an array or another non-string iterable (List, Set, ...) into the result,
|
|
1580
|
+
* one level deep, keeping other elements, strings included, as they are.
|
|
1581
|
+
* @example
|
|
1582
|
+
* ```typescript
|
|
1583
|
+
* List([[1, 2], [3]]).flatten() // List([1, 2, 3])
|
|
1584
|
+
* List([List([1]), List([2])]).flatten() // List([1, 2])
|
|
1585
|
+
* ```
|
|
1586
|
+
*/
|
|
1587
|
+
flatten<B = Flattened<A>>(): List<B>;
|
|
1566
1588
|
get last(): A | undefined;
|
|
1567
1589
|
get lastOption(): Option<A>;
|
|
1568
1590
|
get tail(): List<A>;
|
|
@@ -1668,6 +1690,23 @@ interface Set<out A> extends FunctypeCollection<A, "Set">, Collection<A> {
|
|
|
1668
1690
|
mapAsync: <B>(f: (a: A) => PromiseLike<B>, options?: ConcurrencyOptions) => Promise<Set<B>>;
|
|
1669
1691
|
filter: (p: (a: A) => boolean) => Set<A>;
|
|
1670
1692
|
filterNot: (p: (a: A) => boolean) => Set<A>;
|
|
1693
|
+
/** Keep the first `n` elements. `n` of 0 or less keeps none. */
|
|
1694
|
+
take: (n: number) => Set<A>;
|
|
1695
|
+
takeWhile: (p: (a: A) => boolean) => Set<A>;
|
|
1696
|
+
/** Keep the last `n` elements. `n` of 0 or less keeps none. */
|
|
1697
|
+
takeRight: (n: number) => Set<A>;
|
|
1698
|
+
/** Drop the first `n` elements. `n` of 0 or less drops nothing. */
|
|
1699
|
+
drop: (n: number) => Set<A>;
|
|
1700
|
+
/** Drop the last `n` elements. `n` of 0 or less drops nothing. */
|
|
1701
|
+
dropRight: (n: number) => Set<A>;
|
|
1702
|
+
dropWhile: (p: (a: A) => boolean) => Set<A>;
|
|
1703
|
+
get tail(): Set<A>;
|
|
1704
|
+
get init(): Set<A>;
|
|
1705
|
+
/**
|
|
1706
|
+
* Spread each element that's an array or another non-string iterable into the result, one level deep,
|
|
1707
|
+
* keeping other elements, strings included, as they are.
|
|
1708
|
+
*/
|
|
1709
|
+
flatten<B = Flattened<A>>(): Set<B>;
|
|
1671
1710
|
fold: <B>(initial: B, fn: (acc: B, a: A) => B) => B;
|
|
1672
1711
|
toList: () => List<A>;
|
|
1673
1712
|
toSet: () => Set<A>;
|
|
@@ -1852,7 +1891,7 @@ interface FunctypeCollection<A, Tag extends string = string> extends Omit<Functy
|
|
|
1852
1891
|
* lighter `IterableOnce[+A]`.
|
|
1853
1892
|
*
|
|
1854
1893
|
* Only the covariance-safe subset of `ContainerOps` is included inline: `contains`,
|
|
1855
|
-
* `exists`, and `forEach` all place A only in contravariant (callback input) position.
|
|
1894
|
+
* `exists`, `every` and `forEach` all place A only in contravariant (callback input) position.
|
|
1856
1895
|
* `find` (returns `Option<A>`) and `count` are intentionally omitted — if a sum type
|
|
1857
1896
|
* needs them it can declare them directly.
|
|
1858
1897
|
*
|
|
@@ -1864,6 +1903,11 @@ interface FunctypeSum<A extends Type, Tag extends string = string> extends Async
|
|
|
1864
1903
|
readonly [Symbol.toStringTag]: string;
|
|
1865
1904
|
contains(value: A): boolean;
|
|
1866
1905
|
exists(p: (a: A) => boolean): boolean;
|
|
1906
|
+
/**
|
|
1907
|
+
* Tests whether the success value, if there is one, satisfies the predicate. The dual of
|
|
1908
|
+
* `exists`, and Scala's `forall`: with no success value it gives `true`, as `[].every(p)` does.
|
|
1909
|
+
*/
|
|
1910
|
+
every(p: (a: A) => boolean): boolean;
|
|
1867
1911
|
forEach(f: (a: A) => void): void;
|
|
1868
1912
|
}
|
|
1869
1913
|
//#endregion
|
|
@@ -6150,6 +6194,18 @@ interface Option<out T extends Type> extends Functype<T, "Some" | "None">, Promi
|
|
|
6150
6194
|
* @returns true if this Option contains the value, false otherwise
|
|
6151
6195
|
*/
|
|
6152
6196
|
contains(value: T): boolean;
|
|
6197
|
+
/**
|
|
6198
|
+
* Tests whether the value, if there is one, satisfies the predicate. The dual of `exists`, and
|
|
6199
|
+
* Scala's `forall`: `None` gives `true`, the same way `[].every(p)` does.
|
|
6200
|
+
* @param p - The predicate to test the value with
|
|
6201
|
+
* @returns `true` for None, otherwise `p(value)`
|
|
6202
|
+
* @example
|
|
6203
|
+
* ```typescript
|
|
6204
|
+
* Option("abc").every((s) => s.length > 2) // true
|
|
6205
|
+
* Option<string>(undefined).every((s) => s.length > 2) // true: nothing to fail
|
|
6206
|
+
* ```
|
|
6207
|
+
*/
|
|
6208
|
+
every(p: (a: T) => boolean): boolean;
|
|
6153
6209
|
/**
|
|
6154
6210
|
* Converts this Option to a List.
|
|
6155
6211
|
* @returns A List containing the value if Some, or empty List if None
|
|
@@ -6574,4 +6630,4 @@ declare const Match: (<T extends Type>(value: T) => UntypedMatch<T>) & {
|
|
|
6574
6630
|
};
|
|
6575
6631
|
};
|
|
6576
6632
|
//#endregion
|
|
6577
|
-
export { TimeoutError as $, fromYAML as $n, Sync as $t, Http as A, FunctypeBase as An,
|
|
6633
|
+
export { TimeoutError as $, fromYAML as $n, Sync as $t, Http as A, FunctypeBase as An, isExtractable as Ar, safeStringify as At, HttpError as B, TypeNames as Bn, NoneError as Bt, HKT as C, PositiveNumber as Cn, AsyncMonad as Cr, ErrorChainElement as Ct, TryKind as D, ValidatedBrandCompanion as Dn, ContainerOps as Dr, createErrorSerializer as Dt, OptionKind as E, ValidatedBrand as En, CollectionOps as Er, TaskErrorInfo as Et, HttpRequestOptions as F, Collection as Fn, Doable as Fr, EmptyListError as Ft, TestClock as G, SerializationResult as Gn, DecoderError as Gt, HttpStatusError as H, Serialization_d_exports as Hn, unwrap as Ht, HttpRequestView as I, Set as In, Cond as Ir, FailureError as It, IO as J, createSerializer as Jn, Async as Jt, TestClockTag as K, createCustomSerializer as Kn, DecoderErrorComposite as Kt, HttpResponse as L, List as Ln, FailureErrorType as Lt, HttpClientConfig as M, Traversable as Mn, Concurrency as Mr, Do as Mt, HttpMethodOptions as N, Matchable as Nn, ConcurrencyOptions as Nr, DoAsync as Nt, UniversalContainer as O, FunctypeSum as On, Flattened as Or, formatError as Ot, HttpQueryParams as P, MatchableUtils as Pn, DoResult as Pr, DoGenerator as Pt, Task as Q, fromJSON as Qn, Ok as Qt, ParseMode as R, Reshapeable as Rn, LeftError as Rt, EitherKind as S, PositiveInteger as Sn, Applicative as Sr, TypedErrorContext as St, ListKind as T, UrlString as Tn, Monad as Tr, ErrorWithTaskInfo as Tt, NetworkError as U, FUNCTYPE_MARKER as Un, Decoder as Ut, HttpMethod as V, JSONValue as Vn, isDoCapable as Vt, ResponseDecodeError as W, FunctypeEnvelope as Wn, Encoder as Wt, RIO as X, envelope as Xn, CancellationTokenSource as Xt, InterruptedError as Y, createTaggedSerializer as Yn, CancellationToken as Yt, RepeatExhausted as Z, fromBinary as Zn, Err as Zt, ESMapType as _, ISO8601Date as _n, tryCatchAsync as _r, Validator as _t, OptionConstructor as a, TaskParams as an, Either as ar, LayerOutput as at, Lazy as b, NonNegativeNumber as bn, reduceWiden as br, ErrorStatus as bt, Tracer as c, createCancellationTokenSource as cn, LeftOf as cr, Context as ct, Stack as d, Throwable as dn, TestEither as dr, Tag as dt, TaggedThrowable as en, taggedEnvelope as er, UIO as et, Valuable as f, ThrowableType as fn, TypeCheckLeft as fr, TagService as ft, ESMap as g, EmailAddress as gn, tryCatch as gr, ValidationRule as gt, Obj as h, BoundedString as hn, isRight as hr, Validation as ht, Option as i, TaskOutcome as in, LazyList as ir, LayerInput as it, HttpClient as j, FunctypeCollection as jn, ParseError as jr, $ as jt, FoldableUtils as k, Functype as kn, Extractable as kr, formatStackTrace as kt, TraceEvent as l, isTaggedThrowable as ln, Right as lr, ContextServices as lt, Ref as m, BoundedNumber as mn, isLeft as mr, FormValidation as mt, UntypedMatch as n, TaskFailure as nn, deserializeError as nr, Layer as nt, Some as o, TaskResult as on, EitherBase as or, Exit as ot, ValuableParams as p, Base as pn, TypeCheckRight as pr, FieldValidation as pt, TestContext as q, createSerializationCompanion as qn, DecoderErrorLeaf as qt, None as r, TaskMetadata as rn, serializeError as rr, LayerError as rt, TracedOption as s, TaskSuccess as sn, Left as sr, ExitTag as st, Match as t, Task$1 as tn, SerializedError as tr, UnsupportedSyncOperationError as tt, TraceOp as u, NAME as un, RightOf as ur, HasService as ut, Map$1 as v, IntegerNumber as vn, Widen as vr, ErrorCode as vt, Kind as w, UUID as wn, Functor as wr, ErrorFormatterOptions as wt, Identity as x, PatternString as xn, Promisable as xr, TypedError as xt, KVTraversable as y, NonEmptyString as yn, reduceRightWiden as yr, ErrorMessage as yt, DecodeError as z, Try as zn, LeftErrorType as zt };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as ExtractBrand, c as hasBrand, i as BrandedString, l as unwrapBrand, n as BrandedBoolean, o as Unwrap, r as BrandedNumber, s as createBrander, t as Brand } from "./Brand-bfnGXuum.js";
|
|
2
2
|
import { i as Companion, n as InstanceType, r as isCompanion, t as CompanionMethods } from "./CompanionTypes-Cc90cQ4P.js";
|
|
3
3
|
import { a as isTypeable, c as SerializationMethods, d as Type, i as TypeableParams, l as Pipe, n as ExtractTag, o as Serializable, r as Typeable, s as SerializableEnvelope, t as Tuple, u as Foldable } from "./Tuple-B8KM-H8Y.js";
|
|
4
|
-
import { $ as TimeoutError, $n as fromYAML, $t as Sync, A as Http, An as FunctypeBase, Ar as
|
|
4
|
+
import { $ as TimeoutError, $n as fromYAML, $t as Sync, A as Http, An as FunctypeBase, Ar as isExtractable, At as safeStringify, B as HttpError, Bn as TypeNames, Bt as NoneError, C as HKT, Cn as PositiveNumber, Cr as AsyncMonad, Ct as ErrorChainElement, D as TryKind, Dn as ValidatedBrandCompanion, Dr as ContainerOps, Dt as createErrorSerializer, E as OptionKind, En as ValidatedBrand, Er as CollectionOps, Et as TaskErrorInfo, F as HttpRequestOptions, Fn as Collection, Fr as Doable, Ft as EmptyListError, G as TestClock, Gn as SerializationResult, Gt as DecoderError, H as HttpStatusError, Hn as Serialization_d_exports, Ht as unwrap, I as HttpRequestView, In as Set, Ir as Cond, It as FailureError, J as IO, Jn as createSerializer, Jt as Async, K as TestClockTag, Kn as createCustomSerializer, Kt as DecoderErrorComposite, L as HttpResponse, Ln as List, Lt as FailureErrorType, M as HttpClientConfig, Mn as Traversable, Mr as Concurrency, Mt as Do, N as HttpMethodOptions, Nn as Matchable, Nr as ConcurrencyOptions, Nt as DoAsync, O as UniversalContainer, On as FunctypeSum, Or as Flattened, Ot as formatError, P as HttpQueryParams, Pn as MatchableUtils, Pr as DoResult, Pt as DoGenerator, Q as Task, Qn as fromJSON, Qt as Ok, R as ParseMode, Rn as Reshapeable, Rt as LeftError, S as EitherKind, Sn as PositiveInteger, Sr as Applicative, St as TypedErrorContext, T as ListKind, Tn as UrlString, Tr as Monad, Tt as ErrorWithTaskInfo, U as NetworkError, Un as FUNCTYPE_MARKER, Ut as Decoder, V as HttpMethod, Vn as JSONValue, Vt as isDoCapable, W as ResponseDecodeError, Wn as FunctypeEnvelope, Wt as Encoder, X as RIO, Xn as envelope, Xt as CancellationTokenSource, Y as InterruptedError, Yn as createTaggedSerializer, Yt as CancellationToken, Z as RepeatExhausted, Zn as fromBinary, Zt as Err, _ as ESMapType, _n as ISO8601Date, _r as tryCatchAsync, _t as Validator, a as OptionConstructor, an as TaskParams, ar as Either, at as LayerOutput, b as Lazy, bn as NonNegativeNumber, br as reduceWiden, bt as ErrorStatus, c as Tracer, cn as createCancellationTokenSource, cr as LeftOf, ct as Context, d as Stack, dn as Throwable, dr as TestEither, dt as Tag, en as TaggedThrowable, er as taggedEnvelope, et as UIO, f as Valuable, fn as ThrowableType, fr as TypeCheckLeft, ft as TagService, g as ESMap, gn as EmailAddress, gr as tryCatch, gt as ValidationRule, h as Obj, hn as BoundedString, hr as isRight, ht as Validation, i as Option, in as TaskOutcome, ir as LazyList, it as LayerInput, j as HttpClient, jn as FunctypeCollection, jr as ParseError, jt as $, k as FoldableUtils, kn as Functype, kr as Extractable, kt as formatStackTrace, l as TraceEvent, ln as isTaggedThrowable, lr as Right, lt as ContextServices, m as Ref, mn as BoundedNumber, mr as isLeft, mt as FormValidation, n as UntypedMatch, nn as TaskFailure, nr as deserializeError, nt as Layer, o as Some, on as TaskResult, or as EitherBase, ot as Exit, p as ValuableParams, pn as Base, pr as TypeCheckRight, pt as FieldValidation, q as TestContext, qn as createSerializationCompanion, qt as DecoderErrorLeaf, r as None, rn as TaskMetadata, rr as serializeError, rt as LayerError, s as TracedOption, sn as TaskSuccess, sr as Left, st as ExitTag, t as Match, tn as Task$1, tr as SerializedError, tt as UnsupportedSyncOperationError, u as TraceOp, un as NAME, ur as RightOf, ut as HasService, v as Map, vn as IntegerNumber, vr as Widen, vt as ErrorCode, w as Kind, wn as UUID, wr as Functor, wt as ErrorFormatterOptions, x as Identity, xn as PatternString, xr as Promisable, xt as TypedError, y as KVTraversable, yn as NonEmptyString, yr as reduceRightWiden, yt as ErrorMessage, z as DecodeError, zn as Try, zt as LeftErrorType } from "./index-CjqFFy4s.js";
|
|
5
5
|
import { n as invariant, t as InvariantViolation } from "./Invariant-DEan-SxV.js";
|
|
6
6
|
import { t as Logger } from "./Logger-BmprRS8v.js";
|
|
7
7
|
import { n as WireMark, t as Wire } from "./Wire-3hvw0Ogg.js";
|
|
8
|
-
export { $, type Applicative, Async, type AsyncMonad, Base, BoundedNumber, BoundedString, Brand, BrandedBoolean, type BrandedBoolean as BrandedBooleanType, BrandedNumber, type BrandedNumber as BrandedNumberType, BrandedString, type BrandedString as BrandedStringType, CancellationToken, CancellationTokenSource, Collection, type CollectionOps, Companion, CompanionMethods, type Concurrency, type ConcurrencyOptions, Cond, type ContainerOps, Context, type Context as ContextType, type ContextServices, type DecodeError, Decoder, DecoderError, type DecoderErrorComposite, type DecoderErrorLeaf, Do, DoAsync, DoGenerator, type DoResult, type Doable, ESMap, ESMapType, Either, EitherBase, EitherKind, EmailAddress, EmptyListError, type Encoder, Err, ErrorChainElement, ErrorCode, ErrorFormatterOptions, ErrorMessage, ErrorStatus, ErrorWithTaskInfo, Exit, type Exit as ExitType, type ExitTag, type ExtractBrand, ExtractTag, type Extractable, FUNCTYPE_MARKER, FailureError, FailureErrorType, FieldValidation, Foldable, FoldableUtils, FormValidation, type Functor, Functype, FunctypeBase, FunctypeCollection, FunctypeEnvelope, FunctypeSum, HKT, type HasService, Http, HttpClient, type HttpClientConfig, HttpError, HttpError as HttpErrors, type HttpMethod, type HttpMethodOptions, type HttpQueryParams, type HttpRequestOptions, type HttpRequestView, type HttpResponse, type HttpStatusError, IO, type IO as IOType, type Task as IOTask, ISO8601Date, Identity, InstanceType, IntegerNumber, InterruptedError, InvariantViolation, type JSONValue, KVTraversable, Kind, Layer, type Layer as LayerType, type LayerError, type LayerInput, type LayerOutput, Lazy, type Lazy as LazyType, LazyList, Left, LeftError, LeftErrorType, LeftOf, List, ListKind, type Logger, Map, Match, type Matchable, MatchableUtils, type Monad, NAME, type NetworkError, NonEmptyString, NonNegativeNumber, None, NoneError, Obj, Ok, Option, OptionConstructor, OptionKind, ParseError, type ParseMode, PatternString, Pipe, PositiveInteger, PositiveNumber, type Promisable, type RIO, Ref, type Ref as RefType, RepeatExhausted, type Reshapeable, type ResponseDecodeError, Right, RightOf, Serializable, SerializableEnvelope, Serialization_d_exports as Serialization, SerializationMethods, SerializationResult, SerializedError, Set, Some, Stack, Sync, Tag, type Tag as TagType, type TagService, TaggedThrowable, Task$1 as Task, TaskErrorInfo, TaskFailure, TaskMetadata, TaskOutcome, TaskParams, TaskResult, TaskSuccess, TestClock, type TestClock as TestClockType, TestClockTag, TestContext, type TestContext as TestContextType, TestEither, Throwable, ThrowableType, TimeoutError, type TraceEvent, type TraceOp, TracedOption, type Tracer, Traversable, Try, TryKind, Tuple, Type, TypeCheckLeft, TypeCheckRight, TypeNames, Typeable, TypeableParams, TypedError, TypedErrorContext, type UIO, UUID, UniversalContainer, UnsupportedSyncOperationError, UntypedMatch, type Unwrap, UrlString, ValidatedBrand, type ValidatedBrand as ValidatedBrandType, type ValidatedBrandCompanion, Validation, ValidationRule, Validator, Valuable, ValuableParams, type Widen, type Wire, type WireMark, createBrander, createCancellationTokenSource, createCustomSerializer, createErrorSerializer, createSerializationCompanion, createSerializer, createTaggedSerializer, deserializeError, envelope, formatError, formatStackTrace, fromBinary, fromJSON, fromYAML, hasBrand, invariant, isCompanion, isDoCapable, isExtractable, isLeft, isRight, isTaggedThrowable, isTypeable, reduceRightWiden, reduceWiden, safeStringify, serializeError, taggedEnvelope, tryCatch, tryCatchAsync, unwrap, unwrapBrand };
|
|
8
|
+
export { $, type Applicative, Async, type AsyncMonad, Base, BoundedNumber, BoundedString, Brand, BrandedBoolean, type BrandedBoolean as BrandedBooleanType, BrandedNumber, type BrandedNumber as BrandedNumberType, BrandedString, type BrandedString as BrandedStringType, CancellationToken, CancellationTokenSource, Collection, type CollectionOps, Companion, CompanionMethods, type Concurrency, type ConcurrencyOptions, Cond, type ContainerOps, Context, type Context as ContextType, type ContextServices, type DecodeError, Decoder, DecoderError, type DecoderErrorComposite, type DecoderErrorLeaf, Do, DoAsync, DoGenerator, type DoResult, type Doable, ESMap, ESMapType, Either, EitherBase, EitherKind, EmailAddress, EmptyListError, type Encoder, Err, ErrorChainElement, ErrorCode, ErrorFormatterOptions, ErrorMessage, ErrorStatus, ErrorWithTaskInfo, Exit, type Exit as ExitType, type ExitTag, type ExtractBrand, ExtractTag, type Extractable, FUNCTYPE_MARKER, FailureError, FailureErrorType, FieldValidation, type Flattened, Foldable, FoldableUtils, FormValidation, type Functor, Functype, FunctypeBase, FunctypeCollection, FunctypeEnvelope, FunctypeSum, HKT, type HasService, Http, HttpClient, type HttpClientConfig, HttpError, HttpError as HttpErrors, type HttpMethod, type HttpMethodOptions, type HttpQueryParams, type HttpRequestOptions, type HttpRequestView, type HttpResponse, type HttpStatusError, IO, type IO as IOType, type Task as IOTask, ISO8601Date, Identity, InstanceType, IntegerNumber, InterruptedError, InvariantViolation, type JSONValue, KVTraversable, Kind, Layer, type Layer as LayerType, type LayerError, type LayerInput, type LayerOutput, Lazy, type Lazy as LazyType, LazyList, Left, LeftError, LeftErrorType, LeftOf, List, ListKind, type Logger, Map, Match, type Matchable, MatchableUtils, type Monad, NAME, type NetworkError, NonEmptyString, NonNegativeNumber, None, NoneError, Obj, Ok, Option, OptionConstructor, OptionKind, ParseError, type ParseMode, PatternString, Pipe, PositiveInteger, PositiveNumber, type Promisable, type RIO, Ref, type Ref as RefType, RepeatExhausted, type Reshapeable, type ResponseDecodeError, Right, RightOf, Serializable, SerializableEnvelope, Serialization_d_exports as Serialization, SerializationMethods, SerializationResult, SerializedError, Set, Some, Stack, Sync, Tag, type Tag as TagType, type TagService, TaggedThrowable, Task$1 as Task, TaskErrorInfo, TaskFailure, TaskMetadata, TaskOutcome, TaskParams, TaskResult, TaskSuccess, TestClock, type TestClock as TestClockType, TestClockTag, TestContext, type TestContext as TestContextType, TestEither, Throwable, ThrowableType, TimeoutError, type TraceEvent, type TraceOp, TracedOption, type Tracer, Traversable, Try, TryKind, Tuple, Type, TypeCheckLeft, TypeCheckRight, TypeNames, Typeable, TypeableParams, TypedError, TypedErrorContext, type UIO, UUID, UniversalContainer, UnsupportedSyncOperationError, UntypedMatch, type Unwrap, UrlString, ValidatedBrand, type ValidatedBrand as ValidatedBrandType, type ValidatedBrandCompanion, Validation, ValidationRule, Validator, Valuable, ValuableParams, type Widen, type Wire, type WireMark, createBrander, createCancellationTokenSource, createCustomSerializer, createErrorSerializer, createSerializationCompanion, createSerializer, createTaggedSerializer, deserializeError, envelope, formatError, formatStackTrace, fromBinary, fromJSON, fromYAML, hasBrand, invariant, isCompanion, isDoCapable, isExtractable, isLeft, isRight, isTaggedThrowable, isTypeable, reduceRightWiden, reduceWiden, safeStringify, serializeError, taggedEnvelope, tryCatch, tryCatchAsync, unwrap, unwrapBrand };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Brand as ee,BrandedBoolean as te,BrandedNumber as ne,BrandedString as e,createBrander as t,hasBrand as n,unwrap as r}from"./branded/index.js";import{$ as i,A as a,At as o,B as s,C as c,Ct as l,D as u,Dt as d,E as f,Et as p,F as m,Ft as h,G as g,H as _,I as v,J as y,K as b,L as x,M as S,Mt as C,N as w,Nt as T,O as E,Ot as D,P as O,Pt as k,Q as A,R as j,S as M,St as N,T as P,Tt as F,U as I,V as L,W as R,X as z,Y as B,Z as V,_ as H,_t as U,a as W,at as G,b as K,bt as q,c as J,ct as Y,d as X,dt as Z,et as re,f as Q,ft as ie,g as ae,gt as oe,h as se,ht as ce,i as le,it as $,j as ue,jt as de,k as fe,kt as pe,l as me,lt as he,m as ge,mt as _e,n as ve,nt as ye,o as be,ot as xe,p as Se,pt as Ce,q as we,r as Te,rt as Ee,s as De,st as Oe,t as ke,tt as Ae,u as je,ut as Me,v as Ne,vt as Pe,w as Fe,wt as Ie,x as Le,xt as Re,y as ze,yt as Be,z as Ve}from"./src-
|
|
1
|
+
import{Brand as ee,BrandedBoolean as te,BrandedNumber as ne,BrandedString as e,createBrander as t,hasBrand as n,unwrap as r}from"./branded/index.js";import{$ as i,A as a,At as o,B as s,C as c,Ct as l,D as u,Dt as d,E as f,Et as p,F as m,Ft as h,G as g,H as _,I as v,J as y,K as b,L as x,M as S,Mt as C,N as w,Nt as T,O as E,Ot as D,P as O,Pt as k,Q as A,R as j,S as M,St as N,T as P,Tt as F,U as I,V as L,W as R,X as z,Y as B,Z as V,_ as H,_t as U,a as W,at as G,b as K,bt as q,c as J,ct as Y,d as X,dt as Z,et as re,f as Q,ft as ie,g as ae,gt as oe,h as se,ht as ce,i as le,it as $,j as ue,jt as de,k as fe,kt as pe,l as me,lt as he,m as ge,mt as _e,n as ve,nt as ye,o as be,ot as xe,p as Se,pt as Ce,q as we,r as Te,rt as Ee,s as De,st as Oe,t as ke,tt as Ae,u as je,ut as Me,v as Ne,vt as Pe,w as Fe,wt as Ie,x as Le,xt as Re,y as ze,yt as Be,z as Ve}from"./src-DaOliT66.js";import{t as He}from"./Companion-DiOMBHDG.js";import{a as Ue,c as We,d as Ge,f as Ke,i as qe,l as Je,n as Ye,o as Xe,r as Ze,s as Qe,t as $e,u as et}from"./serialization-BThDTD74.js";import{n as tt,t as nt}from"./typeclass-C61yDVYd.js";import{t as rt}from"./CompanionTypes-BVqO7Kc2.js";import{Tuple as it}from"./tuple/index.js";import{InvariantViolation as at,invariant as ot}from"./invariant/index.js";export{w as $,i as Base,ye as BoundedNumber,Ee as BoundedString,ee as Brand,te as BrandedBoolean,ne as BrandedNumber,e as BrandedString,He as Companion,Ae as Cond,P as Context,_ as Decoder,I as DecoderError,O as Do,m as DoAsync,g as ESMap,ce as Either,$ as EmailAddress,v as EmptyListError,b as Err,Fe as Exit,$e as FUNCTYPE_MARKER,x as FailureError,je as FoldableUtils,me as HKT,X as Http,Se as HttpClient,Q as HttpError,Q as HttpErrors,ze as IO,G as ISO8601Date,J as Identity,xe as IntegerNumber,K as InterruptedError,at as InvariantViolation,Ne as Layer,De as Lazy,D as LazyList,oe as Left,j as LeftError,Ie as List,R as Map,re as Match,be as MatchableUtils,V as NAME,Oe as NonEmptyString,Y as NonNegativeNumber,de as None,Ve as NoneError,W as Obj,we as Ok,C as Option,T as OptionConstructor,h as ParseError,he as PatternString,Me as PositiveInteger,Z as PositiveNumber,pe as Ref,Le as RepeatExhausted,U as Right,Te as Serialization,o as Set,k as Some,le as Stack,H as Tag,y as Task,ge as TestClock,se as TestClockTag,ae as TestContext,A as Throwable,M as TimeoutError,ve as TracedOption,d as Try,it as Tuple,Pe as TypeCheckLeft,Be as TypeCheckRight,F as Typeable,E as TypedError,ie as UUID,c as UnsupportedSyncOperationError,Ce as UrlString,_e as ValidatedBrand,u as Validation,ke as Valuable,t as createBrander,B as createCancellationTokenSource,Ye as createCustomSerializer,fe as createErrorSerializer,Ze as createSerializationCompanion,qe as createSerializer,Ue as createTaggedSerializer,Ge as deserializeError,Xe as envelope,a as formatError,ue as formatStackTrace,Qe as fromBinary,We as fromJSON,Je as fromYAML,n as hasBrand,ot as invariant,rt as isCompanion,s as isDoCapable,f as isExtractable,q as isLeft,Re as isRight,z as isTaggedThrowable,p as isTypeable,nt as reduceRightWiden,tt as reduceWiden,S as safeStringify,Ke as serializeError,et as taggedEnvelope,N as tryCatch,l as tryCatchAsync,L as unwrap,r as unwrapBrand};
|
package/dist/io/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as TimeoutError, G as TestClock, J as IO, K as TestClockTag, Q as Task, X as RIO, Y as InterruptedError, Z as RepeatExhausted, at as LayerOutput, ct as Context, dt as Tag, et as UIO, ft as TagService, it as LayerInput, lt as ContextServices, nt as Layer, ot as Exit, q as TestContext, rt as LayerError, st as ExitTag, tt as UnsupportedSyncOperationError, ut as HasService } from "../index-
|
|
1
|
+
import { $ as TimeoutError, G as TestClock, J as IO, K as TestClockTag, Q as Task, X as RIO, Y as InterruptedError, Z as RepeatExhausted, at as LayerOutput, ct as Context, dt as Tag, et as UIO, ft as TagService, it as LayerInput, lt as ContextServices, nt as Layer, ot as Exit, q as TestContext, rt as LayerError, st as ExitTag, tt as UnsupportedSyncOperationError, ut as HasService } from "../index-CjqFFy4s.js";
|
|
2
2
|
export { Context, type Context as ContextType, type ContextServices, Exit, type Exit as ExitType, type ExitTag, type HasService, IO, type IO as IOType, type Task as IOTask, InterruptedError, Layer, type Layer as LayerType, type LayerError, type LayerInput, type LayerOutput, type RIO, RepeatExhausted, Tag, type Tag as TagType, type TagService, TestClock, type TestClock as TestClockType, TestClockTag, TestContext, type TestContext as TestContextType, TimeoutError, type UIO, UnsupportedSyncOperationError };
|
package/dist/io/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,S as t,T as n,_ as r,b as i,g as a,h as o,m as s,v as c,w as l,x as u,y as d}from"../src-
|
|
1
|
+
import{C as e,S as t,T as n,_ as r,b as i,g as a,h as o,m as s,v as c,w as l,x as u,y as d}from"../src-DaOliT66.js";export{n as Context,l as Exit,d as IO,i as InterruptedError,c as Layer,u as RepeatExhausted,r as Tag,s as TestClock,o as TestClockTag,a as TestContext,t as TimeoutError,e as UnsupportedSyncOperationError};
|
package/dist/lazy/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { b as Lazy } from "../index-
|
|
1
|
+
import { b as Lazy } from "../index-CjqFFy4s.js";
|
|
2
2
|
export { Lazy, type Lazy as LazyType };
|
package/dist/lazy/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e}from"../src-
|
|
1
|
+
import{s as e}from"../src-DaOliT66.js";export{e as Lazy};
|
package/dist/list/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Ln as List } from "../index-
|
|
1
|
+
import { Ln as List } from "../index-CjqFFy4s.js";
|
|
2
2
|
export { List };
|
package/dist/list/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{wt as e}from"../src-
|
|
1
|
+
import{wt as e}from"../src-DaOliT66.js";export{e as List};
|
package/dist/map/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { v as Map } from "../index-
|
|
1
|
+
import { v as Map } from "../index-CjqFFy4s.js";
|
|
2
2
|
export { Map };
|
package/dist/map/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{W as e}from"../src-
|
|
1
|
+
import{W as e}from"../src-DaOliT66.js";export{e as Map};
|
package/dist/obj/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { h as Obj } from "../index-
|
|
1
|
+
import { h as Obj } from "../index-CjqFFy4s.js";
|
|
2
2
|
export { Obj };
|
package/dist/obj/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"../src-
|
|
1
|
+
import{a as e}from"../src-DaOliT66.js";export{e as Obj};
|
package/dist/option/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as OptionConstructor, i as Option, o as Some, r as None } from "../index-
|
|
1
|
+
import { a as OptionConstructor, i as Option, o as Some, r as None } from "../index-CjqFFy4s.js";
|
|
2
2
|
export { None, Option, OptionConstructor, Some };
|
package/dist/option/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Mt as e,Nt as t,Pt as n,jt as r}from"../src-
|
|
1
|
+
import{Mt as e,Nt as t,Pt as n,jt as r}from"../src-DaOliT66.js";export{r as None,e as Option,t as OptionConstructor,n as Some};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $n as fromYAML, Gn as SerializationResult, Jn as createSerializer, Kn as createCustomSerializer, Qn as fromJSON, Un as FUNCTYPE_MARKER, Vn as JSONValue, Wn as FunctypeEnvelope, Xn as envelope, Yn as createTaggedSerializer, Zn as fromBinary, er as taggedEnvelope, nr as deserializeError, qn as createSerializationCompanion, rr as serializeError, tr as SerializedError } from "../index-
|
|
1
|
+
import { $n as fromYAML, Gn as SerializationResult, Jn as createSerializer, Kn as createCustomSerializer, Qn as fromJSON, Un as FUNCTYPE_MARKER, Vn as JSONValue, Wn as FunctypeEnvelope, Xn as envelope, Yn as createTaggedSerializer, Zn as fromBinary, er as taggedEnvelope, nr as deserializeError, qn as createSerializationCompanion, rr as serializeError, tr as SerializedError } from "../index-CjqFFy4s.js";
|
|
2
2
|
export { FUNCTYPE_MARKER, FunctypeEnvelope, type JSONValue, SerializationResult, SerializedError, createCustomSerializer, createSerializationCompanion, createSerializer, createTaggedSerializer, deserializeError, envelope, fromBinary, fromJSON, fromYAML, serializeError, taggedEnvelope };
|
package/dist/set/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { In as Set } from "../index-
|
|
1
|
+
import { In as Set } from "../index-CjqFFy4s.js";
|
|
2
2
|
export { Set };
|
package/dist/set/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{At as e}from"../src-
|
|
1
|
+
import{At as e}from"../src-DaOliT66.js";export{e as Set};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import{t as e}from"./rolldown-runtime-DK3Fl9T5.js";import{Brand as t}from"./branded/index.js";import{mergeObjects as n}from"./util/index.js";import{t as r}from"./Companion-DiOMBHDG.js";import{a as i,d as a,f as o,h as s,i as c,m as l,p as u,t as ee}from"./serialization-BThDTD74.js";import{n as te,t as ne}from"./typeclass-C61yDVYd.js";import{Tuple as re}from"./tuple/index.js";const ie=e=>{let t=Error(e);return t.name=`ParseError`,t},ae=(e,t)=>{if(e===`unbounded`)return t;if(!Number.isInteger(e)||e<1)throw RangeError(`concurrency must be a positive integer or "unbounded", got ${String(e)}`);return Math.min(e,t)},oe=async(e,t,n,r=()=>!1)=>{let i=Array.from(e),a=[],o={next:0,stopped:!1},s=async()=>{if(o.stopped||o.next>=i.length)return;let e=o.next;o.next=e+1;try{let n=await t(i[e]);a[e]={value:n},r(n)&&(o.stopped=!0)}catch(e){throw o.stopped=!0,e}return s()};return await Promise.all(Array.from({length:ae(n,i.length)},s)),a.flatMap(e=>[e.value])},d=e=>({[Symbol.toStringTag]:`Option`,_tag:`Some`,value:e,isEmpty:!1,isSome(){return!0},isNone(){return!1},orElse:t=>e,orThrow:()=>e,expect:t=>e,or:t=>d(e),orNull:()=>e,orUndefined:()=>e,map:t=>d(t(e)),ap:t=>t._tag===`Some`&&t.value?d(t.value(e)):f,filter(t){return t(e)?d(e):f},count:t=>+!!t(e),find:t=>t(e)?d(e):f,exists:t=>t(e),forEach:t=>t(e),fold:(t,n)=>n(e),foldAsync:async(t,n)=>n(e),match:t=>t.Some(e),flatMap:t=>t(e),flatMapAsync:async t=>await t(e),reduce:t=>e,reduceRight:t=>e,foldLeft:t=>n=>n(t,e),foldRight:t=>n=>n(e,t),contains:t=>t===e,toList:()=>C([e]),toArray:()=>[e],size:1,toOption:()=>d(e),toEither:t=>w(e),toTry:()=>x(()=>e),toPromise:()=>Promise.resolve(e),toString:()=>`Some(${l(e)})`,toValue:()=>({_tag:`Some`,value:e}),toJSON:()=>({"@functype":`Option`,_tag:`Some`,value:e}),pipe:t=>t(e),serialize:()=>c(`Option`,`Some`,e),doUnwrap(){return{ok:!0,value:e}}}),f={[Symbol.toStringTag]:`Option`,_tag:`None`,value:void 0,isEmpty:!0,isSome(){return!1},isNone(){return!0},orElse:e=>e,orThrow(e){throw e===void 0?/* @__PURE__ */ Error(`Cannot extract value from None`):typeof e==`function`?e():e},expect(e){return e()},or:e=>e,orNull:()=>null,orUndefined:()=>void 0,map:e=>f,ap:e=>f,filter(e){return f},count:e=>0,find:e=>f,exists:e=>!1,forEach:e=>{},flatMap:e=>f,flatMapAsync:e=>Promise.resolve(f),reduce:e=>{throw Error(`Cannot reduce an empty Option`)},reduceRight:e=>{throw Error(`Cannot reduceRight an empty Option`)},fold:(e,t)=>e(),foldAsync:async(e,t)=>e(),match:e=>e.None(),foldLeft:e=>()=>e,foldRight:e=>()=>e,contains:()=>!1,toList:()=>C([]),toArray:()=>[],size:0,toOption:()=>f,toEither:e=>T(typeof e==`function`?e():e),toTry:()=>x(()=>{throw Error(`None`)}),toPromise:()=>Promise.reject(/* @__PURE__ */ Error(`Cannot convert None to Promise`)),toString:()=>`None`,toValue:()=>({_tag:`None`,value:void 0}),toJSON:()=>({"@functype":`Option`,_tag:`None`,value:null}),pipe:e=>e(void 0),serialize:()=>c(`Option`,`None`,null),doUnwrap(){return{ok:!1,empty:!0}}},p=()=>f,se=e=>e==null?p():d(e),ce={from:e=>m(e),none:()=>p(),isSome:e=>e.isSome(),isNone:e=>e.isNone(),fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`Option`)throw Error(`Option.fromJSON: expected @functype="Option", got ${JSON.stringify(t[`@functype`])}`);return t._tag===`Some`?d(t.value):p()},fromYAML:e=>{let t=e.split(`
|
|
2
|
-
`),n=t[0]?.split(`: `)[1],r=t[1]?.split(`: `)[1];if(!n||!r)return p();let i=r===`null`?null:JSON.parse(r);return n===`Some`?d(i):p()},fromBinary:e=>{let t=s(e);return ce.fromJSON(t)},sequence:e=>e.reduce((e,t)=>e.isEmpty||t.isEmpty?p():d([...e.value,t.value]),d([])),traverse:(e,t)=>e.reduce((e,n,r)=>e.flatMap(e=>t(n,r).map(t=>[...e,t])),d([]))},m=r(se,ce),h=globalThis.Set,g=e=>{let t=new h(e),n={[Symbol.toStringTag]:`FunctypeSet`,_tag:`Set`,[Symbol.iterator]:()=>t[Symbol.iterator](),add:e=>g([...t,e]),remove:e=>{let n=new h(t);return n.delete(e),g(n)},contains:e=>t.has(e),has:e=>t.has(e),union:e=>g([...t,...e]),intersection:e=>{let n=new h(e);return g([...t].filter(e=>n.has(e)))},difference:e=>{let n=new h(e);return g([...t].filter(e=>!n.has(e)))},symmetricDifference:e=>{let n=[...new h(e)],r=new h(n);return g([...[...t].filter(e=>!r.has(e)),...n.filter(e=>!t.has(e))])},isSubsetOf:e=>{let n=new h(e);return[...t].every(e=>n.has(e))},isSupersetOf:e=>{for(let n of e)if(!t.has(n))return!1;return!0},isDisjointFrom:e=>{for(let n of e)if(t.has(n))return!1;return!0},map:e=>g(Array.from(t).map(e)),ap:e=>{let n=new h;for(let r of t)for(let t of e)n.add(t(r));return g(n)},flatMap:e=>{let n=new h;for(let r of t)for(let t of e(r))n.add(t);return g(n)},mapAsync:async(e,n)=>g(await oe(t,e,n?.concurrency??1)),flatMapAsync:async(e,n)=>{let r=await oe(t,e,n?.concurrency??1);return g(r.flatMap(e=>Array.from(e)))},fold:(e,n)=>{let r=e;for(let e of t)r=n(r,e);return r},foldLeft:e=>n=>{let r=e;for(let e of t)r=n(r,e);return r},foldRight:e=>n=>Array.from(t).reduceRight((e,t)=>n(t,e),e),get size(){return t.size},get isEmpty(){return t.size===0},reduce:e=>{let n=Array.from(t);if(n.length===0)throw Error(`Cannot reduce empty Set`);return te(n,e)},reduceRight:e=>{let n=Array.from(t);if(n.length===0)throw Error(`Cannot reduceRight empty Set`);return ne(n,e)},count:e=>{let n=0;for(let r of t)e(r)&&n++;return n},find:e=>{for(let n of t)if(e(n))return m(n);return m(null)},exists:e=>{for(let n of t)if(e(n))return!0;return!1},every:e=>{for(let n of t)if(!e(n))return!1;return!0},forEach:e=>{t.forEach(e)},filter:e=>{let n=new h;for(let r of t)e(r)&&n.add(r);return g(n)},filterNot:e=>{let n=new h;for(let r of t)e(r)||n.add(r);return g(n)},drop:e=>g(Array.from(t).slice(e)),dropRight:e=>
|
|
3
|
-
`)[1]?.split(`: `)[1];if(!t)return fe([]);let n=JSON.parse(t);return fe(n)},fromBinary:e=>{let t=s(e);return de.fromJSON(t)}},fe=r(le,de),pe=e=>{let t=e;return{get(){return t},set(e){t=e},update(e){t=e(t)},getAndSet(e){let n=t;return t=e,n},updateAndGet(e){return t=e(t),t},getAndUpdate(e){let n=t;return t=e(t),n},compareAndSet(e,n){return t===e&&(t=n,!0)},modify(e){let[n,r]=e(t);return t=n,r}}},_=r(pe,{of:e=>pe(e)}),me=(e=0)=>{let t=_(e),n=e;return{get:()=>t.get(),set:e=>t.set(e),increment:()=>t.updateAndGet(e=>e+1),decrement:()=>t.updateAndGet(e=>e-1),reset:()=>t.set(n),compareAndSet:(e,n)=>t.compareAndSet(e,n)}},he=()=>{let e=_([]);return{add:t=>e.update(e=>[...e,t]),addAll:t=>e.update(e=>[...e,...t]),build:()=>e.get(),clear:()=>e.set([]),size:()=>e.get().length}},v=e=>{let t={[Symbol.toStringTag]:`LazyList`,_tag:`LazyList`,[Symbol.iterator]:()=>e[Symbol.iterator](),map:t=>v((function*(){for(let n of e)yield t(n)})()),flatMap:t=>v((function*(){for(let n of e)yield*t(n)})()),filter:t=>v((function*(){for(let n of e)t(n)&&(yield n)})()),take:t=>v((function*(){let n=me(0);for(let r of e){if(n.get()>=t)break;yield r,n.increment()}})()),drop:t=>v((function*(){let n=me(0);for(let r of e)n.get()>=t&&(yield r),n.increment()})()),takeWhile:t=>v((function*(){for(let n of e){if(!t(n))break;yield n}})()),dropWhile:t=>v((function*(){let n=_(!0);for(let r of e)n.get()&&t(r)||(n.set(!1),yield r)})()),concat:t=>v((function*(){yield*e,yield*t})()),zip:t=>v((function*(){let n=e[Symbol.iterator](),r=t[Symbol.iterator]();for(;;){let e=n.next(),t=r.next();if(e.done||t.done)break;yield[e.value,t.value]}})()),toList:()=>C(Array.from(e)),toArray:()=>Array.from(e),forEach:t=>{for(let n of e)t(n)},reduce:(t,n)=>{let r=_(n);for(let n of e)r.set(t(r.get(),n));return r.get()},find:t=>{for(let n of e)if(t(n))return m(n);return m.none()},some:t=>{for(let n of e)if(t(n))return!0;return!1},every:t=>{for(let n of e)if(!t(n))return!1;return!0},count:()=>{let t=me(0);for(let n of e)t.increment();return t.get()},get head(){let t=e[Symbol.iterator]().next();return t.done?void 0:t.value},get headOption(){let t=e[Symbol.iterator]().next();return t.done?m.none():m(t.value)},get last(){let t;for(let n of e)t=n;return t},get lastOption(){let t=_(void 0),n=_(!1);for(let r of e)t.set(r),n.set(!0);return n.get()?m(t.get()):m.none()},get tail(){return v((function*(){let t=e[Symbol.iterator]();t.next();let n=t.next();for(;!n.done;)yield n.value,n=t.next()})())},get init(){let t=Array.from(e);return v(t.length===0?[]:t.slice(0,-1))},takeRight:t=>{let n=Array.from(e);return v(t<=0?[]:n.slice(-t))},reverse:()=>v(Array.from(e).reverse()),distinct:()=>v((function*(){let t=new globalThis.Set;for(let n of e)t.has(n)||(t.add(n),yield n)})()),zipWithIndex:()=>v((function*(){let t=me(0);for(let n of e)yield[n,t.get()],t.increment()})()),fold:(t,n)=>{let r=t;for(let t of e)r=n(r,t);return r},foldLeft:t=>n=>{let r=_(t);for(let t of e)r.set(n(r.get(),t));return r.get()},foldRight:t=>n=>Array.from(e).reduceRight((e,t)=>n(t,e),t),pipe:e=>e(t),serialize:()=>c(`LazyList`,Array.from(e)),toJSON:()=>({"@functype":`LazyList`,_tag:`LazyList`,value:Array.from(e)}),toString:()=>{let t=[],n=me(0),r=_(!1);for(let i of e)if(n.get()<10)t.push(i),n.increment();else{r.set(!0);break}let i=t.map(e=>String(e)).join(`, `);return r.get()?`LazyList(${i}, ...)`:`LazyList(${i})`}};return t},ge=r(e=>v(e),{empty:()=>v([]),of:(...e)=>v(e),from:(...e)=>v(e),fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`LazyList`)throw Error(`LazyList.fromJSON: expected @functype="LazyList", got ${JSON.stringify(t[`@functype`])}`);return v(t.value)},iterate:(e,t)=>v((function*(){let n=_(e);for(;;)yield n.get(),n.set(t(n.get()))})()),generate:e=>v((function*(){for(;;)yield e()})()),range:(e,t,n=1)=>v((function*(){if(n===0)throw Error(`Step cannot be zero`);let r=_(e);if(n>0)for(;r.get()<t;)yield r.get(),r.set(r.get()+n);else for(;r.get()>t;)yield r.get(),r.set(r.get()+n)})()),repeat:(e,t)=>v((function*(){if(t===void 0)for(;;)yield e;else{let n=me(0);for(;n.get()<t;)yield e,n.increment()}})()),cycle:e=>v((function*(){let t=Array.from(e);if(t.length!==0)for(;;)yield*t})())}),y=e=>({[Symbol.toStringTag]:`Try`,_tag:`Success`,error:void 0,isSuccess(){return!0},isFailure(){return!1},orElse:t=>e,orThrow:()=>e,expect:t=>e,or:t=>y(e),orNull:()=>e,orUndefined:()=>e,toEither:t=>w(e),map:t=>x(()=>t(e)),ap:t=>t.map(t=>t(e)),flatMap:t=>t(e),flatMapAsync:async t=>t(e),fold:(t,n)=>n(e),foldAsync:async(t,n)=>n(e),match:t=>t.Success(e),recover:t=>y(e),recoverWith:t=>y(e),filterOrElse:(t,n)=>{try{return t(e)?y(e):b(n(e))}catch(e){return b(e instanceof Error?e:Error(String(e)))}},foldLeft:t=>n=>n(t,e),foldRight:t=>n=>n(e,t),toString:()=>`Success(${l(e)})`,toPromise:()=>Promise.resolve(e),toValue:()=>({_tag:`Success`,value:e}),toJSON:()=>({"@functype":`Try`,_tag:`Success`,value:e}),toOption:()=>d(e),toList:()=>C([e]),toArray:()=>[e],toTry:()=>y(e),pipe:t=>t(e),serialize:()=>c(`Try`,`Success`,e),contains:t=>e===t,exists:t=>t(e),forEach:t=>t(e),doUnwrap(){return{ok:!0,value:e}}}),b=e=>({[Symbol.toStringTag]:`Try`,_tag:`Failure`,error:e,isSuccess(){return!1},isFailure(){return!0},orElse:e=>e,orThrow:t=>{throw t===void 0?e:typeof t==`function`?t(e):t},expect:t=>t(e),or:e=>e,orNull:()=>null,orUndefined:()=>void 0,toEither:t=>T(typeof t==`function`?t(e):t),map:t=>b(e),ap:t=>b(e),flatMap:t=>b(e),flatMapAsync:t=>Promise.resolve(b(e)),fold:(t,n)=>t(e),foldAsync:async(t,n)=>t(e),match:t=>t.Failure(e),recover:t=>x(()=>t(e)),recoverWith:t=>{try{return t(e)}catch(e){return b(e instanceof Error?e:Error(String(e)))}},filterOrElse:(t,n)=>b(e),foldLeft:e=>t=>e,foldRight:e=>t=>e,toString:()=>`Failure(${l(e)})`,toPromise:()=>Promise.reject(e),toValue:()=>({_tag:`Failure`,value:e}),toJSON:()=>({"@functype":`Try`,_tag:`Failure`,error:o(e)}),toOption:()=>m(null),toList:()=>C([]),toArray:()=>[],toTry:()=>b(e),pipe:t=>{throw e},serialize:()=>i(`Try`,`Failure`,{error:o(e)}),contains:e=>!1,exists:e=>!1,forEach:e=>{},doUnwrap(){return{ok:!1,empty:!1,error:e}}}),_e=e=>{try{return y(e())}catch(e){return b(e instanceof Error?e:Error(String(e)))}},ve={success:e=>y(e),failure:e=>b(typeof e==`string`?Error(e):e),fromPromise:e=>e.then(e=>y(e)).catch(e=>b(e instanceof Error?e:Error(String(e)))),async:e=>{try{return e().then(e=>y(e)).catch(e=>b(e instanceof Error?e:Error(String(e))))}catch(e){return Promise.resolve(b(e instanceof Error?e:Error(String(e))))}},isSuccess:e=>e.isSuccess(),isFailure:e=>e.isFailure(),fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`Try`)throw Error(`Try.fromJSON: expected @functype="Try", got ${JSON.stringify(t[`@functype`])}`);if(t._tag===`Success`)return y(t.value);if(t.error!==void 0&&typeof t.error==`object`)return b(a(t.error));let n=Error(typeof t.error==`string`?t.error:``);return t.stack&&(n.stack=t.stack),b(n)},fromYAML:e=>{let t=e.split(`
|
|
4
|
-
`),n=t[0]?.split(`: `)[1];if(!n)return b(/* @__PURE__ */ Error(`Invalid YAML format for Try`));if(n===`Success`){let e=t[1]?.split(`: `)[1];if(!e)return b(/* @__PURE__ */ Error(`Invalid YAML format for Try Success`));let n=JSON.parse(e);return y(n)}{let e=t[1]?.split(`: `)[1];if(!e)return b(/* @__PURE__ */ Error(`Invalid YAML format for Try Failure`));let n=t[2]?.split(`: `),r=n&&n.length>1?n.slice(1).join(`: `):void 0,i=Error(e);return r&&(i.stack=r),b(i)}},fromBinary:e=>{let t=s(e);return ve.fromJSON(t)},sequence:e=>x(()=>e.map(e=>e.orThrow())),traverse:(e,t)=>x(()=>e.map((e,n)=>t(e,n).orThrow()))},x=r(_e,ve);function ye({_tag:e,impl:t}){return{...t,_tag:e}}function be(e,t){return!e||typeof e!=`object`||!(`_tag`in e)?!1:!t||e._tag===t}const S=e=>{let t=Array.from(e??[]),n={[Symbol.toStringTag]:`List`,_tag:`List`,[Symbol.iterator]:()=>t[Symbol.iterator](),get size(){return t.length},get length(){return t.length},map:e=>S(t.map(e)),ap:e=>S(t.flatMap(t=>Array.from(e).map(e=>e(t)))),flatMap:e=>S(t.flatMap(t=>Array.from(e(t)))),flatMapAsync:async(e,n)=>{let r=await oe(t,e,n?.concurrency??`unbounded`);return S(r.flatMap(e=>Array.from(e)))},mapAsync:async(e,n)=>S(await oe(t,e,n?.concurrency??1)),forEach:e=>t.forEach(e),contains:e=>t.includes(e),count:e=>t.filter(e).length,exists:e=>t.some(e),every:e=>t.every(e),filter:e=>S(t.filter(e)),filterNot:e=>S(t.filter(t=>!e(t))),filterType:e=>S(t.filter(t=>be(t,e))),find:(e,n)=>{let r=t.find(t=>e(t)&&(!n||be(t,n)));return m(r)},get head(){return t[0]},get headOption(){return t.length>0?m(t[0]):p()},get isEmpty(){return t.length===0},toArray:()=>[...t],reduce:e=>te(t,e),reduceRight:e=>ne(t,e),fold:(e,n)=>t.reduce(n,e),foldLeft:e=>n=>t.reduce(n,e),foldRight:e=>n=>t.reduceRight((e,t)=>n(t,e),e),match:e=>t.length===0?e.Empty():e.NonEmpty([...t]),remove:e=>S(t.filter(t=>t!==e)),removeAt:e=>e<0||e>=t.length?n:S([...t.slice(0,e),...t.slice(e+1)]),add:e=>S([...t,e]),get:e=>m(t[e]),concat:e=>S([...t,...e.toArray()]),take:e=>S(t.slice(0,Math.max(0,e))),takeWhile:e=>{let n=[];for(let r of t){if(!e(r))break;n.push(r)}return S(n)},takeRight:e=>S(e<=0?[]:t.slice(-e)),get last(){return t[t.length-1]},get lastOption(){return t.length>0?m(t[t.length-1]):p()},get tail(){return S(t.slice(1))},get init(){return S(t.length===0?[]:t.slice(0,-1))},reverse:()=>S([...t].reverse()),indexOf:e=>t.indexOf(e),prepend:e=>S([e,...t]),distinct:()=>{let e=new globalThis.Set,n=[];for(let r of t)e.has(r)||(e.add(r),n.push(r));return S(n)},sorted:e=>S([...t].sort(e)),sortBy:(e,n)=>S([...t].sort((t,r)=>{let i=e(t),a=e(r);return n?n(i,a):i<a?-1:+(i>a)})),zip:e=>{let n=e.toArray(),r=Math.min(t.length,n.length),i=[];for(let e=0;e<r;e++)i.push([t[e],n[e]]);return S(i)},zipWithIndex:()=>S(t.map((e,t)=>[e,t])),groupBy:e=>{let n=new globalThis.Map;for(let r of t){let t=e(r),i=n.get(t)??[];i.push(r),n.set(t,i)}let r=new globalThis.Map;for(let[e,t]of n)r.set(e,S(t));return r},partition:e=>{let n=[],r=[];for(let i of t)e(i)?n.push(i):r.push(i);return[S(n),S(r)]},span:e=>{let n=t.findIndex(t=>!e(t));return n===-1?[S([...t]),S([])]:[S(t.slice(0,n)),S(t.slice(n))]},slice:(e,n)=>S(t.slice(e,n)),drop:e=>S(t.slice(e)),dropRight:e=>S(t.slice(0
|
|
5
|
-
`)[1]?.split(`: `)[1];if(!t)return C([]);let n=JSON.parse(t);return C(n)},fromBinary:e=>{let t=s(e);return
|
|
6
|
-
`),n=t[0]?.split(`: `)[1],r=t[1]?.split(`: `)[1];if(!n||!r)throw Error(`Invalid YAML format for Either`);let i=JSON.parse(r);return n===`Right`?w(i):T(i)},fromBinary:e=>{let t=s(e);return Ne.fromJSON(t)}},Pe=r(Me,Ne);function E(e,n){return{brand:e,validate:n,of:r=>n(r)?m(t(e,r)):m.none(),from:r=>n(r)?w(t(e,r)):T(`Invalid ${e}: validation failed`),unsafeOf:r=>{if(!n(r))throw Error(`Invalid ${e}: validation failed`);return t(e,r)},is:e=>{try{return n(e)}catch{return!1}},unwrap:e=>e,refine:(e,t)=>E(e,e=>n(e)&&t(e))}}const Fe=E(`PositiveNumber`,e=>e>0),Ie=E(`NonNegativeNumber`,e=>e>=0),Le=E(`IntegerNumber`,e=>Number.isInteger(e)),Re=Fe.refine(`PositiveInteger`,e=>Number.isInteger(e)),ze=E(`NonEmptyString`,e=>e.length>0),Be=E(`EmailAddress`,e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)),Ve=E(`UrlString`,e=>{try{return new URL(e),!0}catch{return!1}}),He=E(`UUID`,e=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)),Ue=E(`ISO8601Date`,e=>!isNaN(Date.parse(e))&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(e));function We(e,t,n){return E(e,e=>e>=t&&e<=n)}function Ge(e,t,n){return E(e,e=>e.length>=t&&e.length<=n)}function Ke(e,t){return E(e,e=>t.test(e))}const qe=e=>{let t=e=>typeof e==`function`?e():e,n={when:(r,i)=>e.resolved?n:r?qe({resolved:!0,value:t(i)}):n,elseWhen:(r,i)=>e.resolved?n:r?qe({resolved:!0,value:t(i)}):n,else:n=>e.resolved?e.value:t(n),orThrow:()=>{if(!e.resolved)throw Error(`Conditional expression has no matching condition`);return e.value}};return n},Je=()=>qe({resolved:!1}),Ye=r(Je,{of:()=>Je(),match:e=>t=>{let n=t[e];if(n===void 0)throw Error(`No case defined for value: ${String(e)}`);return typeof n==`function`?n():n},lazy:()=>{let e={resolved:!1},t={when:(n,r)=>(e.resolved||n()&&(e.resolved=!0,e.value=r()),t),elseWhen:(n,r)=>(e.resolved||n()&&(e.resolved=!0,e.value=r()),t),else:t=>e.resolved?e.value:t()};return t}}),Xe=(e,t)=>t===e?!0:typeof t==`function`?t(e):t&&typeof t==`object`&&`_`in t?t._(e):typeof t==`object`&&t&&typeof e==`object`&&e?Object.entries(t).every(([t,n])=>{let r=e[t];return Xe(r,n)}):!1,D=e=>{let t=(e,t)=>typeof e==`function`?e(t):e,n=()=>{for(let{pattern:n,result:r}of e.patterns)if(Xe(e.value,n))return{matched:!0,result:t(r,e.value)};return{matched:!1}},r={case:(n,i)=>e.resolved?r:Xe(e.value,n)?D({value:e.value,resolved:!0,result:t(i,e.value),patterns:[]}):D({...e,patterns:[...e.patterns,{pattern:n,result:i}]}),caseValue:(t,n)=>{if(e.resolved)return r;if(e.value===t){let t=typeof n==`function`?n():n;return D({value:e.value,resolved:!0,result:t,patterns:[]})}return r},caseValues:(t,n)=>{if(e.resolved)return r;if(t.includes(e.value)){let t=typeof n==`function`?n():n;return D({value:e.value,resolved:!0,result:t,patterns:[]})}return r},when:(e,t)=>r.case(e,t),caseAny:(n,i)=>{if(e.resolved)return r;for(let r of n)if(Xe(e.value,r))return D({value:e.value,resolved:!0,result:t(i,e.value),patterns:[]});return D({...e,patterns:[...e.patterns,...n.map(e=>({pattern:e,result:i}))]})},default:n=>e.resolved?e.result:t(n,e.value),exhaustive:()=>{if(e.resolved)return e.result;let t=n();if(!t.matched)throw Error(`Non-exhaustive match. No pattern matched value: ${JSON.stringify(e.value)}`);return t.result},orThrow:t=>{if(e.resolved)return e.result;let r=n();if(!r.matched)throw Error(t??`No matching pattern for value: ${JSON.stringify(e.value)}`);return r.result},toOption:()=>{if(e.resolved)return m(e.result);let t=n();return t.matched?m(t.result):m.none()}};return r},Ze=e=>{let t=(e,t)=>typeof e==`function`?e(t):e;return{case:(n,r)=>{let i={value:e,resolved:!1,patterns:[{pattern:n,result:r}]};return Xe(e,n)?D({...i,resolved:!0,result:t(r,e)}):D(i)},caseValue:(t,n)=>{if(e===t){let t=typeof n==`function`?n():n;return D({value:e,resolved:!0,result:t,patterns:[]})}return D({value:e,resolved:!1,patterns:[]})},caseValues:(t,n)=>{if(t.includes(e)){let t=typeof n==`function`?n():n;return D({value:e,resolved:!0,result:t,patterns:[]})}return D({value:e,resolved:!1,patterns:[]})},when:(n,r)=>{let i={value:e,resolved:!1,patterns:[{pattern:n,result:r}]};return n(e)?D({...i,resolved:!0,result:t(r,e)}):D(i)},caseAny:(n,r)=>{for(let i of n)if(Xe(e,i))return D({value:e,resolved:!0,result:t(r,e),patterns:n.map(e=>({pattern:e,result:r}))});return D({value:e,resolved:!1,patterns:n.map(e=>({pattern:e,result:r}))})}}},Qe=r(e=>Ze(e),{exhaustive:e=>t=>{let n=e[t];if(n===void 0)throw Error(`No case defined for value: ${String(t)}`);return n},partial:e=>({withDefault:t=>n=>{let r=e[n];return r===void 0?typeof t==`function`?t(n):t:typeof r==`function`?r(n):r}}),withGuards:e=>({withDefault:t=>n=>{for(let[t,r]of e)if(t(n))return typeof r==`function`?r(n):r;return typeof t==`function`?t(n):t}}),struct:()=>{let e=[],t={case:(n,r)=>(e.push({pattern:n,handler:r}),t),build:()=>t=>{for(let{pattern:n,handler:r}of e)if(Xe(t,n))return r(t);throw Error(`No matching pattern for value: ${JSON.stringify(t)}`)}};return t},builder:()=>{let e=[],t,n={case:(t,r)=>(e.push({pattern:t,result:r}),n),when:(t,r)=>(e.push({pattern:t,result:r}),n),default:n=>(t=n,{build:()=>n=>{for(let{pattern:t,result:r}of e)if(Xe(n,t))return typeof r==`function`?r(n):r;if(t!==void 0)return typeof t==`function`?t(n):t;throw Error(`No matching pattern for value: ${JSON.stringify(n)}`)}})};return n}});function $e(e,t){return{...ye({_tag:e,impl:t}),toString(){return`${e}()`},doUnwrap(){if(`isSome`in t&&`isNone`in t){if(typeof t.isSome==`function`&&t.isSome()&&`get`in t&&typeof t.get==`function`)return{ok:!0,value:t.get()};if(typeof t.isNone==`function`&&t.isNone())return{ok:!1,empty:!0}}if(`isLeft`in t&&`isRight`in t){if(typeof t.isRight==`function`&&t.isRight()&&`value`in t)return{ok:!0,value:t.value};if(typeof t.isLeft==`function`&&t.isLeft()&&`value`in t)return{ok:!1,empty:!1,error:t.value}}if(`isSuccess`in t&&`isFailure`in t){if(typeof t.isSuccess==`function`&&t.isSuccess()&&`get`in t&&typeof t.get==`function`)return{ok:!0,value:t.get()};if(typeof t.isFailure==`function`&&t.isFailure()&&`getError`in t&&typeof t.getError==`function`)return{ok:!1,empty:!1,error:t.getError()}}if(`isEmpty`in t&&`head`in t){if(typeof t.isEmpty==`function`&&t.isEmpty())return{ok:!1,empty:!0};if(typeof t.head==`function`)return{ok:!0,value:t.head()};if(`head`in t)return{ok:!0,value:t.head}}return{ok:!0,value:t}}}}const et=`Throwable`;var tt=class e extends Error{constructor(e,t){super(e,{cause:t?.cause}),this._tag=et,this.name=t?.taskInfo?.name??`Throwable`,Object.defineProperties(this,{_tag:{value:et,writable:!1,configurable:!1},data:{value:t?.data,writable:!1,configurable:!1},taskInfo:{value:t?.taskInfo,writable:!1,configurable:!1},name:{value:t?.taskInfo?.name??`Throwable`,writable:!1,configurable:!1}}),t?.cause&&Object.defineProperty(this,"cause",{value:t.cause,writable:!1,configurable:!1}),t?.stack?this.stack=t.stack:Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}static apply(t,n,r){if(t instanceof Error){let i=new e(t.message,{data:n,cause:t.cause??void 0,stack:t.stack??void 0,taskInfo:r});for(let e of Object.keys(t))if(!(e in i)){let n=i;n[e]=t[e]}return i}if(t&&typeof t==`object`){let i=t,a=typeof i.message==`string`?i.message:typeof i.error==`string`?i.error:`Object error: ${JSON.stringify(i,Object.getOwnPropertyNames(i).filter(e=>i[e]!==void 0))}`,o=new e(a,{data:n??i,taskInfo:r});for(let e of Object.keys(i))if(!(e in o)){let t=o;t[e]=i[e]}return o}if(typeof t==`function`){let i=t.name??`anonymous function`,a=t.toString().substring(0,100)+(t.toString().length>100?`...`:``);return new e(`Function error: ${i}`,{data:n??{functionType:typeof t,functionName:i,functionString:a},taskInfo:r})}let i=typeof t,a=t===null?`null`:t===void 0?`undefined`:String(t);if(i===`number`){let a=t,o=Number.isNaN(a)?`Number error: NaN`:Number.isFinite(a)?`Number error: ${a}`:`Number error: ${a>0?`Infinity`:`-Infinity`}`;return new e(o,{data:n??{errorType:i,errorValue:a,originalError:t},taskInfo:r})}if(i===`bigint`)return new e(`BigInt error: ${t}n`,{data:n??{errorType:i,errorValue:String(t),originalError:t},taskInfo:r});if(i===`boolean`)return new e(`Boolean error: ${t}`,{data:n??{errorType:i,errorValue:t,originalError:t},taskInfo:r});if(i===`symbol`){let a=t.description??`unnamed symbol`;return new e(`Symbol error: Symbol(${a})`,{data:n??{errorType:i,symbolDescription:a,originalError:t},taskInfo:r})}let o=typeof t==`string`?t:`${i.charAt(0).toUpperCase()+i.slice(1)} error: ${a}`;return new e(o,{data:n??{errorType:i,errorValue:a,originalError:t},taskInfo:r})}};function nt(e){return e instanceof Error&&typeof e==`object`&&e._tag===`Throwable`}const rt=(e,t)=>{if(e.isRight())return k(e.orThrow(),t);if(e.isLeft())return O(e.fold(e=>e,()=>/* @__PURE__ */ Error(`Unexpected right value`)),void 0,t);throw Error(`Unrecognized task outcome`)},O=(e,t,n)=>{let r={name:n?.name??`Task`,description:n?.description??``},a=tt.apply(e,t,r),s={...$e(`Err`,{error:a,meta:r}),[Symbol.toStringTag]:`TaskOutcome`,_tag:`Err`,_meta:r,value:void 0,error:a,isSuccess(){return!1},isFailure(){return!0},isOk(){return!1},isErr(){return!0},map:e=>O(a,t,n),flatMap:e=>O(a,t,n),ap:e=>O(a,t,n),mapAsync:e=>Promise.resolve(O(a,t,n)),flatMapAsync:e=>Promise.resolve(O(a,t,n)),mapError:e=>O(e(a),t,n),recover:e=>k(e,n),recoverWith:e=>k(e(a),n),orThrow:e=>{throw e??a},orElse:e=>e,or:e=>e,orNull:()=>null,orUndefined:()=>void 0,toEither:()=>T(a),toTry:()=>x(()=>{throw a}),toOption:()=>p(),toList:()=>C([]),fold:(e,t)=>e(a),match:e=>e.Err(a),foldLeft:e=>t=>e,foldRight:e=>t=>e,size:0,isEmpty:!0,contains:e=>!1,reduce:e=>{throw Error(`Cannot reduce empty Err`)},reduceRight:e=>{throw Error(`Cannot reduceRight empty Err`)},count:e=>0,find:e=>p(),exists:e=>!1,forEach:e=>{},toPromise:()=>Promise.reject(a),doUnwrap(){return{ok:!1,empty:!1,error:a}},toJSON:()=>({"@functype":`Task`,_tag:`Err`,error:o(a)}),serialize:()=>i(`Task`,`Err`,{error:o(a)}),pipe:e=>e(s)};return s},k=(e,t)=>{let n={name:t?.name??`Task`,description:t?.description??``},r={...$e(`Ok`,{value:e,meta:n}),[Symbol.toStringTag]:`TaskOutcome`,_tag:`Ok`,_meta:n,value:e,error:void 0,isSuccess(){return!0},isFailure(){return!1},isOk(){return!0},isErr(){return!1},map:n=>k(n(e),t),flatMap:n=>{let r=n(e);return r&&typeof r==`object`&&`isLeft`in r&&`isRight`in r?rt(r,t):r},ap:n=>n.isOk()?k(n.value(e),t):O(n.error,void 0,t),mapAsync:async n=>k(await n(e),t),flatMapAsync:async t=>await t(e),mapError:n=>k(e,t),recover:n=>k(e,t),recoverWith:n=>k(e,t),orThrow:t=>e,orElse:t=>e,or:n=>k(e,t),orNull:()=>e,orUndefined:()=>e,toEither:()=>w(e),toTry:()=>x(()=>e),toOption:()=>d(e),toList:()=>C([e]),fold:(t,n)=>n(e),match:t=>t.Ok(e),foldLeft:t=>n=>n(t,e),foldRight:t=>n=>n(e,t),size:1,isEmpty:!1,contains:t=>e===t,reduce:t=>e,reduceRight:t=>e,count:t=>+!!t(e),find:t=>t(e)?d(e):p(),exists:t=>t(e),forEach:t=>t(e),toPromise:()=>Promise.resolve(e),doUnwrap(){return{ok:!0,value:e}},toJSON:()=>({"@functype":`Task`,_tag:`Ok`,value:e}),serialize:()=>c(`Task`,`Ok`,e),pipe:e=>e(r)};return r},it=()=>{let e=new AbortController,t=he();return{token:{get isCancelled(){return e.signal.aborted},get signal(){return e.signal},onCancel(n){e.signal.aborted?n():t.add(n)}},cancel(){e.signal.aborted||(e.abort(),t.build().forEach(e=>{try{e()}catch(e){console.error(`Error in cancellation callback:`,e)}}))}}},at=e=>{let t=e?.name??`Task`,n=e?.description??``,r={Async:(e,r=e=>e,i=()=>{},a)=>new Promise(o=>{(async()=>{let s=_(!1),c=_(null),l=_(()=>{});if(a){if(a.isCancelled){try{await i()}catch(e){o(O(e,void 0,{name:t,description:n}));return}o(O(/* @__PURE__ */ Error(`Task was cancelled before execution started`),void 0,{name:t,description:n}));return}a.onCancel(()=>{s.set(!0),c.set(/* @__PURE__ */ Error(`Task was cancelled during execution`))}),l.set(()=>{})}try{let r=await e();try{await i()}catch(e){o(O(e,void 0,{name:t,description:n}));return}if(s.get()){c.get()?o(O(c.get(),void 0,{name:t,description:n})):o(O(/* @__PURE__ */ Error(`Task was cancelled during execution`),void 0,{name:t,description:n}));return}if(r&&typeof r==`object`&&`_tag`in r){let e=r;e._tag===`Ok`||e._tag===`Err`?o(e):o(k(r,{name:t,description:n}))}else o(k(r,{name:t,description:n}))}catch(e){try{await i()}catch(e){o(O(e,void 0,{name:t,description:n}));return}if(s.get()){c.get()?o(O(c.get(),void 0,{name:t,description:n})):o(O(/* @__PURE__ */ Error(`Task was cancelled during execution`),void 0,{name:t,description:n}));return}try{if(e instanceof Error&&nt(e)){let i=/* @__PURE__ */ Error(`${t}: ${e.message}`),a=tt.apply(i,void 0,{name:t,description:n});Object.defineProperty(a,"cause",{value:e,writable:!1,configurable:!1}),Promise.resolve().then(()=>{try{r(e)}catch(e){console.error(`Error in error handler:`,e)}}),o(O(a,void 0,{name:t,description:n}))}else{let i=await r(e);if(i&&typeof i==`object`&&`_tag`in i){let e=i;e._tag===`Ok`||e._tag===`Err`?o(e):o(O(i,void 0,{name:t,description:n}))}else o(O(i,void 0,{name:t,description:n}))}}catch(e){o(O(e,void 0,{name:t,description:n}))}}finally{l.get()()}})().catch(e=>o(O(e,void 0,{name:t,description:n})))}),Sync:(e,r=e=>e,i=()=>{})=>{try{return k(e(),{name:t,description:n})}catch(e){return O(r(e),void 0,{name:t,description:n})}finally{i()}},AsyncWithProgress:(e,t,n=e=>e,i=()=>{},a)=>{let o=e=>{let n=Math.max(0,Math.min(100,e));n<=100&&t(n)};return r.Async(()=>e(o),n,i,a)}};return{...$e(`Task`,r),_type:`Task`}},ot={success:(e,t)=>k(e,t),fail:(e,t,n)=>O(e,t,n),ok:(e,t)=>k(e,t),err:(e,t,n)=>O(e,t,n),fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`Task`)throw Error(`Task.fromJSON: expected @functype="Task", got ${JSON.stringify(t[`@functype`])}`);if(t._tag===`Ok`)return k(t.value);if(t._tag===`Err`){let e=t.error!==void 0&&typeof t.error==`object`?a(t.error):Error(typeof t.error==`string`?t.error:`Unknown Task error`);return O(e)}throw Error(`Task.fromJSON: unrecognized _tag ${JSON.stringify(t._tag)}`)},fromEither:(e,t)=>rt(e,t),fromTry:(e,t)=>e.isSuccess()?k(e.orThrow(),t):O(e.fold(e=>e,()=>/* @__PURE__ */ Error(`Unexpected success`)),void 0,t),getErrorChain:e=>{if(!e)return[];let t=he();t.add(e);let n=_(e);for(;n.get()&&n.get().cause;){let{cause:e}=n.get();if(e)t.add(e),n.set(e);else break;if(t.size()>100)break}return t.build()},formatErrorChain:(e,t)=>{let n=ot.getErrorChain(e),r=t?.separator??`
|
|
1
|
+
import{t as e}from"./rolldown-runtime-DK3Fl9T5.js";import{Brand as t}from"./branded/index.js";import{mergeObjects as n}from"./util/index.js";import{t as r}from"./Companion-DiOMBHDG.js";import{a as i,d as a,f as o,h as s,i as c,m as l,p as u,t as ee}from"./serialization-BThDTD74.js";import{n as te,t as ne}from"./typeclass-C61yDVYd.js";import{Tuple as re}from"./tuple/index.js";const ie=e=>{let t=Error(e);return t.name=`ParseError`,t},ae=(e,t)=>{if(e===`unbounded`)return t;if(!Number.isInteger(e)||e<1)throw RangeError(`concurrency must be a positive integer or "unbounded", got ${String(e)}`);return Math.min(e,t)},oe=async(e,t,n,r=()=>!1)=>{let i=Array.from(e),a=[],o={next:0,stopped:!1},s=async()=>{if(o.stopped||o.next>=i.length)return;let e=o.next;o.next=e+1;try{let n=await t(i[e]);a[e]={value:n},r(n)&&(o.stopped=!0)}catch(e){throw o.stopped=!0,e}return s()};return await Promise.all(Array.from({length:ae(n,i.length)},s)),a.flatMap(e=>[e.value])},d=e=>({[Symbol.toStringTag]:`Option`,_tag:`Some`,value:e,isEmpty:!1,isSome(){return!0},isNone(){return!1},orElse:t=>e,orThrow:()=>e,expect:t=>e,or:t=>d(e),orNull:()=>e,orUndefined:()=>e,map:t=>d(t(e)),ap:t=>t._tag===`Some`&&t.value?d(t.value(e)):f,filter(t){return t(e)?d(e):f},count:t=>+!!t(e),find:t=>t(e)?d(e):f,exists:t=>t(e),every:t=>t(e),forEach:t=>t(e),fold:(t,n)=>n(e),foldAsync:async(t,n)=>n(e),match:t=>t.Some(e),flatMap:t=>t(e),flatMapAsync:async t=>await t(e),reduce:t=>e,reduceRight:t=>e,foldLeft:t=>n=>n(t,e),foldRight:t=>n=>n(e,t),contains:t=>t===e,toList:()=>C([e]),toArray:()=>[e],size:1,toOption:()=>d(e),toEither:t=>w(e),toTry:()=>x(()=>e),toPromise:()=>Promise.resolve(e),toString:()=>`Some(${l(e)})`,toValue:()=>({_tag:`Some`,value:e}),toJSON:()=>({"@functype":`Option`,_tag:`Some`,value:e}),pipe:t=>t(e),serialize:()=>c(`Option`,`Some`,e),doUnwrap(){return{ok:!0,value:e}}}),f={[Symbol.toStringTag]:`Option`,_tag:`None`,value:void 0,isEmpty:!0,isSome(){return!1},isNone(){return!0},orElse:e=>e,orThrow(e){throw e===void 0?/* @__PURE__ */ Error(`Cannot extract value from None`):typeof e==`function`?e():e},expect(e){return e()},or:e=>e,orNull:()=>null,orUndefined:()=>void 0,map:e=>f,ap:e=>f,filter(e){return f},count:e=>0,find:e=>f,exists:e=>!1,every:e=>!0,forEach:e=>{},flatMap:e=>f,flatMapAsync:e=>Promise.resolve(f),reduce:e=>{throw Error(`Cannot reduce an empty Option`)},reduceRight:e=>{throw Error(`Cannot reduceRight an empty Option`)},fold:(e,t)=>e(),foldAsync:async(e,t)=>e(),match:e=>e.None(),foldLeft:e=>()=>e,foldRight:e=>()=>e,contains:()=>!1,toList:()=>C([]),toArray:()=>[],size:0,toOption:()=>f,toEither:e=>T(typeof e==`function`?e():e),toTry:()=>x(()=>{throw Error(`None`)}),toPromise:()=>Promise.reject(/* @__PURE__ */ Error(`Cannot convert None to Promise`)),toString:()=>`None`,toValue:()=>({_tag:`None`,value:void 0}),toJSON:()=>({"@functype":`Option`,_tag:`None`,value:null}),pipe:e=>e(void 0),serialize:()=>c(`Option`,`None`,null),doUnwrap(){return{ok:!1,empty:!0}}},p=()=>f,se=e=>e==null?p():d(e),ce={from:e=>m(e),none:()=>p(),isSome:e=>e.isSome(),isNone:e=>e.isNone(),fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`Option`)throw Error(`Option.fromJSON: expected @functype="Option", got ${JSON.stringify(t[`@functype`])}`);return t._tag===`Some`?d(t.value):p()},fromYAML:e=>{let t=e.split(`
|
|
2
|
+
`),n=t[0]?.split(`: `)[1],r=t[1]?.split(`: `)[1];if(!n||!r)return p();let i=r===`null`?null:JSON.parse(r);return n===`Some`?d(i):p()},fromBinary:e=>{let t=s(e);return ce.fromJSON(t)},sequence:e=>e.reduce((e,t)=>e.isEmpty||t.isEmpty?p():d([...e.value,t.value]),d([])),traverse:(e,t)=>e.reduce((e,n,r)=>e.flatMap(e=>t(n,r).map(t=>[...e,t])),d([]))},m=r(se,ce),h=globalThis.Set,g=e=>{let t=new h(e),n={[Symbol.toStringTag]:`FunctypeSet`,_tag:`Set`,[Symbol.iterator]:()=>t[Symbol.iterator](),add:e=>g([...t,e]),remove:e=>{let n=new h(t);return n.delete(e),g(n)},contains:e=>t.has(e),has:e=>t.has(e),union:e=>g([...t,...e]),intersection:e=>{let n=new h(e);return g([...t].filter(e=>n.has(e)))},difference:e=>{let n=new h(e);return g([...t].filter(e=>!n.has(e)))},symmetricDifference:e=>{let n=[...new h(e)],r=new h(n);return g([...[...t].filter(e=>!r.has(e)),...n.filter(e=>!t.has(e))])},isSubsetOf:e=>{let n=new h(e);return[...t].every(e=>n.has(e))},isSupersetOf:e=>{for(let n of e)if(!t.has(n))return!1;return!0},isDisjointFrom:e=>{for(let n of e)if(t.has(n))return!1;return!0},map:e=>g(Array.from(t).map(e)),ap:e=>{let n=new h;for(let r of t)for(let t of e)n.add(t(r));return g(n)},flatMap:e=>{let n=new h;for(let r of t)for(let t of e(r))n.add(t);return g(n)},mapAsync:async(e,n)=>g(await oe(t,e,n?.concurrency??1)),flatMapAsync:async(e,n)=>{let r=await oe(t,e,n?.concurrency??1);return g(r.flatMap(e=>Array.from(e)))},fold:(e,n)=>{let r=e;for(let e of t)r=n(r,e);return r},foldLeft:e=>n=>{let r=e;for(let e of t)r=n(r,e);return r},foldRight:e=>n=>Array.from(t).reduceRight((e,t)=>n(t,e),e),get size(){return t.size},get isEmpty(){return t.size===0},reduce:e=>{let n=Array.from(t);if(n.length===0)throw Error(`Cannot reduce empty Set`);return te(n,e)},reduceRight:e=>{let n=Array.from(t);if(n.length===0)throw Error(`Cannot reduceRight empty Set`);return ne(n,e)},count:e=>{let n=0;for(let r of t)e(r)&&n++;return n},find:e=>{for(let n of t)if(e(n))return m(n);return m(null)},exists:e=>{for(let n of t)if(e(n))return!0;return!1},every:e=>{for(let n of t)if(!e(n))return!1;return!0},forEach:e=>{t.forEach(e)},filter:e=>{let n=new h;for(let r of t)e(r)&&n.add(r);return g(n)},filterNot:e=>{let n=new h;for(let r of t)e(r)||n.add(r);return g(n)},drop:e=>g(Array.from(t).slice(Math.max(0,e))),dropRight:e=>{let n=Array.from(t);return g(e>0?n.slice(0,Math.max(0,n.length-Math.trunc(e))):n)},dropWhile:e=>{let n=Array.from(t),r=n.findIndex(t=>!e(t));return g(r===-1?[]:n.slice(r))},flatten:()=>{let e=new h;for(let n of t)if(Array.isArray(n))for(let t of n)e.add(t);else if(n&&typeof n==`object`&&Symbol.iterator in n)for(let t of n)e.add(t);else e.add(n);return g(e)},get head(){return Array.from(t)[0]},get headOption(){let e=Array.from(t)[0];return m(e)},take:e=>g(Array.from(t).slice(0,Math.max(0,e))),takeWhile:e=>{let n=Array.from(t),r=[];for(let t of n){if(!e(t))break;r.push(t)}return g(r)},takeRight:e=>{let n=Array.from(t);return g(e<=0?[]:n.slice(-e))},get last(){let e=Array.from(t);return e[e.length-1]},get lastOption(){let e=Array.from(t);return m(e[e.length-1])},get tail(){return g(Array.from(t).slice(1))},get init(){let e=Array.from(t);return g(e.length===0?[]:e.slice(0,-1))},toList:()=>C(Array.from(t)),toSet:()=>n,toArray:()=>Array.from(t),toString:()=>`Set(${Array.from(t).toString()})`,toValue:()=>({_tag:`Set`,value:Array.from(t)}),toJSON:()=>({"@functype":`Set`,_tag:`Set`,value:Array.from(t)}),pipe:e=>e(Array.from(t)),serialize:()=>c(`Set`,Array.from(t))};return n},le=e=>g(e),ue=g([]),de={empty:()=>ue,of:(...e)=>g(e),fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`Set`)throw Error(`Set.fromJSON: expected @functype="Set", got ${JSON.stringify(t[`@functype`])}`);return fe(t.value)},fromYAML:e=>{let t=e.split(`
|
|
3
|
+
`)[1]?.split(`: `)[1];if(!t)return fe([]);let n=JSON.parse(t);return fe(n)},fromBinary:e=>{let t=s(e);return de.fromJSON(t)}},fe=r(le,de),pe=e=>{let t=e;return{get(){return t},set(e){t=e},update(e){t=e(t)},getAndSet(e){let n=t;return t=e,n},updateAndGet(e){return t=e(t),t},getAndUpdate(e){let n=t;return t=e(t),n},compareAndSet(e,n){return t===e&&(t=n,!0)},modify(e){let[n,r]=e(t);return t=n,r}}},_=r(pe,{of:e=>pe(e)}),me=(e=0)=>{let t=_(e),n=e;return{get:()=>t.get(),set:e=>t.set(e),increment:()=>t.updateAndGet(e=>e+1),decrement:()=>t.updateAndGet(e=>e-1),reset:()=>t.set(n),compareAndSet:(e,n)=>t.compareAndSet(e,n)}},he=()=>{let e=_([]);return{add:t=>e.update(e=>[...e,t]),addAll:t=>e.update(e=>[...e,...t]),build:()=>e.get(),clear:()=>e.set([]),size:()=>e.get().length}},v=e=>{let t={[Symbol.toStringTag]:`LazyList`,_tag:`LazyList`,[Symbol.iterator]:()=>e[Symbol.iterator](),map:t=>v((function*(){for(let n of e)yield t(n)})()),flatMap:t=>v((function*(){for(let n of e)yield*t(n)})()),filter:t=>v((function*(){for(let n of e)t(n)&&(yield n)})()),take:t=>v((function*(){let n=me(0);for(let r of e){if(n.get()>=t)break;yield r,n.increment()}})()),drop:t=>v((function*(){let n=me(0);for(let r of e)n.get()>=t&&(yield r),n.increment()})()),takeWhile:t=>v((function*(){for(let n of e){if(!t(n))break;yield n}})()),dropWhile:t=>v((function*(){let n=_(!0);for(let r of e)n.get()&&t(r)||(n.set(!1),yield r)})()),concat:t=>v((function*(){yield*e,yield*t})()),zip:t=>v((function*(){let n=e[Symbol.iterator](),r=t[Symbol.iterator]();for(;;){let e=n.next(),t=r.next();if(e.done||t.done)break;yield[e.value,t.value]}})()),toList:()=>C(Array.from(e)),toArray:()=>Array.from(e),forEach:t=>{for(let n of e)t(n)},reduce:(t,n)=>{let r=_(n);for(let n of e)r.set(t(r.get(),n));return r.get()},find:t=>{for(let n of e)if(t(n))return m(n);return m.none()},some:t=>{for(let n of e)if(t(n))return!0;return!1},every:t=>{for(let n of e)if(!t(n))return!1;return!0},count:()=>{let t=me(0);for(let n of e)t.increment();return t.get()},get head(){let t=e[Symbol.iterator]().next();return t.done?void 0:t.value},get headOption(){let t=e[Symbol.iterator]().next();return t.done?m.none():m(t.value)},get last(){let t;for(let n of e)t=n;return t},get lastOption(){let t=_(void 0),n=_(!1);for(let r of e)t.set(r),n.set(!0);return n.get()?m(t.get()):m.none()},get tail(){return v((function*(){let t=e[Symbol.iterator]();t.next();let n=t.next();for(;!n.done;)yield n.value,n=t.next()})())},get init(){let t=Array.from(e);return v(t.length===0?[]:t.slice(0,-1))},takeRight:t=>{let n=Array.from(e);return v(t<=0?[]:n.slice(-t))},reverse:()=>v(Array.from(e).reverse()),distinct:()=>v((function*(){let t=new globalThis.Set;for(let n of e)t.has(n)||(t.add(n),yield n)})()),zipWithIndex:()=>v((function*(){let t=me(0);for(let n of e)yield[n,t.get()],t.increment()})()),fold:(t,n)=>{let r=t;for(let t of e)r=n(r,t);return r},foldLeft:t=>n=>{let r=_(t);for(let t of e)r.set(n(r.get(),t));return r.get()},foldRight:t=>n=>Array.from(e).reduceRight((e,t)=>n(t,e),t),pipe:e=>e(t),serialize:()=>c(`LazyList`,Array.from(e)),toJSON:()=>({"@functype":`LazyList`,_tag:`LazyList`,value:Array.from(e)}),toString:()=>{let t=[],n=me(0),r=_(!1);for(let i of e)if(n.get()<10)t.push(i),n.increment();else{r.set(!0);break}let i=t.map(e=>String(e)).join(`, `);return r.get()?`LazyList(${i}, ...)`:`LazyList(${i})`}};return t},ge=r(e=>v(e),{empty:()=>v([]),of:(...e)=>v(e),from:(...e)=>v(e),fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`LazyList`)throw Error(`LazyList.fromJSON: expected @functype="LazyList", got ${JSON.stringify(t[`@functype`])}`);return v(t.value)},iterate:(e,t)=>v((function*(){let n=_(e);for(;;)yield n.get(),n.set(t(n.get()))})()),generate:e=>v((function*(){for(;;)yield e()})()),range:(e,t,n=1)=>v((function*(){if(n===0)throw Error(`Step cannot be zero`);let r=_(e);if(n>0)for(;r.get()<t;)yield r.get(),r.set(r.get()+n);else for(;r.get()>t;)yield r.get(),r.set(r.get()+n)})()),repeat:(e,t)=>v((function*(){if(t===void 0)for(;;)yield e;else{let n=me(0);for(;n.get()<t;)yield e,n.increment()}})()),cycle:e=>v((function*(){let t=Array.from(e);if(t.length!==0)for(;;)yield*t})())}),y=e=>({[Symbol.toStringTag]:`Try`,_tag:`Success`,error:void 0,isSuccess(){return!0},isFailure(){return!1},orElse:t=>e,orThrow:()=>e,expect:t=>e,or:t=>y(e),orNull:()=>e,orUndefined:()=>e,toEither:t=>w(e),map:t=>x(()=>t(e)),ap:t=>t.map(t=>t(e)),flatMap:t=>t(e),flatMapAsync:async t=>t(e),fold:(t,n)=>n(e),foldAsync:async(t,n)=>n(e),match:t=>t.Success(e),recover:t=>y(e),recoverWith:t=>y(e),filterOrElse:(t,n)=>{try{return t(e)?y(e):b(n(e))}catch(e){return b(e instanceof Error?e:Error(String(e)))}},foldLeft:t=>n=>n(t,e),foldRight:t=>n=>n(e,t),toString:()=>`Success(${l(e)})`,toPromise:()=>Promise.resolve(e),toValue:()=>({_tag:`Success`,value:e}),toJSON:()=>({"@functype":`Try`,_tag:`Success`,value:e}),toOption:()=>d(e),toList:()=>C([e]),toArray:()=>[e],toTry:()=>y(e),pipe:t=>t(e),serialize:()=>c(`Try`,`Success`,e),contains:t=>e===t,exists:t=>t(e),every:t=>t(e),forEach:t=>t(e),doUnwrap(){return{ok:!0,value:e}}}),b=e=>({[Symbol.toStringTag]:`Try`,_tag:`Failure`,error:e,isSuccess(){return!1},isFailure(){return!0},orElse:e=>e,orThrow:t=>{throw t===void 0?e:typeof t==`function`?t(e):t},expect:t=>t(e),or:e=>e,orNull:()=>null,orUndefined:()=>void 0,toEither:t=>T(typeof t==`function`?t(e):t),map:t=>b(e),ap:t=>b(e),flatMap:t=>b(e),flatMapAsync:t=>Promise.resolve(b(e)),fold:(t,n)=>t(e),foldAsync:async(t,n)=>t(e),match:t=>t.Failure(e),recover:t=>x(()=>t(e)),recoverWith:t=>{try{return t(e)}catch(e){return b(e instanceof Error?e:Error(String(e)))}},filterOrElse:(t,n)=>b(e),foldLeft:e=>t=>e,foldRight:e=>t=>e,toString:()=>`Failure(${l(e)})`,toPromise:()=>Promise.reject(e),toValue:()=>({_tag:`Failure`,value:e}),toJSON:()=>({"@functype":`Try`,_tag:`Failure`,error:o(e)}),toOption:()=>m(null),toList:()=>C([]),toArray:()=>[],toTry:()=>b(e),pipe:t=>{throw e},serialize:()=>i(`Try`,`Failure`,{error:o(e)}),contains:e=>!1,exists:e=>!1,every:e=>!0,forEach:e=>{},doUnwrap(){return{ok:!1,empty:!1,error:e}}}),_e=e=>{try{return y(e())}catch(e){return b(e instanceof Error?e:Error(String(e)))}},ve={success:e=>y(e),failure:e=>b(typeof e==`string`?Error(e):e),fromPromise:e=>e.then(e=>y(e)).catch(e=>b(e instanceof Error?e:Error(String(e)))),async:e=>{try{return e().then(e=>y(e)).catch(e=>b(e instanceof Error?e:Error(String(e))))}catch(e){return Promise.resolve(b(e instanceof Error?e:Error(String(e))))}},isSuccess:e=>e.isSuccess(),isFailure:e=>e.isFailure(),fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`Try`)throw Error(`Try.fromJSON: expected @functype="Try", got ${JSON.stringify(t[`@functype`])}`);if(t._tag===`Success`)return y(t.value);if(t.error!==void 0&&typeof t.error==`object`)return b(a(t.error));let n=Error(typeof t.error==`string`?t.error:``);return t.stack&&(n.stack=t.stack),b(n)},fromYAML:e=>{let t=e.split(`
|
|
4
|
+
`),n=t[0]?.split(`: `)[1];if(!n)return b(/* @__PURE__ */ Error(`Invalid YAML format for Try`));if(n===`Success`){let e=t[1]?.split(`: `)[1];if(!e)return b(/* @__PURE__ */ Error(`Invalid YAML format for Try Success`));let n=JSON.parse(e);return y(n)}{let e=t[1]?.split(`: `)[1];if(!e)return b(/* @__PURE__ */ Error(`Invalid YAML format for Try Failure`));let n=t[2]?.split(`: `),r=n&&n.length>1?n.slice(1).join(`: `):void 0,i=Error(e);return r&&(i.stack=r),b(i)}},fromBinary:e=>{let t=s(e);return ve.fromJSON(t)},sequence:e=>x(()=>e.map(e=>e.orThrow())),traverse:(e,t)=>x(()=>e.map((e,n)=>t(e,n).orThrow()))},x=r(_e,ve);function ye({_tag:e,impl:t}){return{...t,_tag:e}}function be(e,t){return!e||typeof e!=`object`||!(`_tag`in e)?!1:!t||e._tag===t}const xe=e=>Array.isArray(e)||typeof e==`object`&&!!e&&Symbol.iterator in e,S=e=>{let t=Array.from(e??[]),n={[Symbol.toStringTag]:`List`,_tag:`List`,[Symbol.iterator]:()=>t[Symbol.iterator](),get size(){return t.length},get length(){return t.length},map:e=>S(t.map(e)),ap:e=>S(t.flatMap(t=>Array.from(e).map(e=>e(t)))),flatMap:e=>S(t.flatMap(t=>Array.from(e(t)))),flatMapAsync:async(e,n)=>{let r=await oe(t,e,n?.concurrency??`unbounded`);return S(r.flatMap(e=>Array.from(e)))},mapAsync:async(e,n)=>S(await oe(t,e,n?.concurrency??1)),forEach:e=>t.forEach(e),contains:e=>t.includes(e),count:e=>t.filter(e).length,exists:e=>t.some(e),every:e=>t.every(e),filter:e=>S(t.filter(e)),filterNot:e=>S(t.filter(t=>!e(t))),filterType:e=>S(t.filter(t=>be(t,e))),find:(e,n)=>{let r=t.find(t=>e(t)&&(!n||be(t,n)));return m(r)},get head(){return t[0]},get headOption(){return t.length>0?m(t[0]):p()},get isEmpty(){return t.length===0},toArray:()=>[...t],reduce:e=>te(t,e),reduceRight:e=>ne(t,e),fold:(e,n)=>t.reduce(n,e),foldLeft:e=>n=>t.reduce(n,e),foldRight:e=>n=>t.reduceRight((e,t)=>n(t,e),e),match:e=>t.length===0?e.Empty():e.NonEmpty([...t]),remove:e=>S(t.filter(t=>t!==e)),removeAt:e=>e<0||e>=t.length?n:S([...t.slice(0,e),...t.slice(e+1)]),add:e=>S([...t,e]),get:e=>m(t[e]),concat:e=>S([...t,...e.toArray()]),take:e=>S(t.slice(0,Math.max(0,e))),takeWhile:e=>{let n=[];for(let r of t){if(!e(r))break;n.push(r)}return S(n)},takeRight:e=>S(e<=0?[]:t.slice(-e)),get last(){return t[t.length-1]},get lastOption(){return t.length>0?m(t[t.length-1]):p()},get tail(){return S(t.slice(1))},get init(){return S(t.length===0?[]:t.slice(0,-1))},reverse:()=>S([...t].reverse()),indexOf:e=>t.indexOf(e),prepend:e=>S([e,...t]),distinct:()=>{let e=new globalThis.Set,n=[];for(let r of t)e.has(r)||(e.add(r),n.push(r));return S(n)},sorted:e=>S([...t].sort(e)),sortBy:(e,n)=>S([...t].sort((t,r)=>{let i=e(t),a=e(r);return n?n(i,a):i<a?-1:+(i>a)})),zip:e=>{let n=e.toArray(),r=Math.min(t.length,n.length),i=[];for(let e=0;e<r;e++)i.push([t[e],n[e]]);return S(i)},zipWithIndex:()=>S(t.map((e,t)=>[e,t])),groupBy:e=>{let n=new globalThis.Map;for(let r of t){let t=e(r),i=n.get(t)??[];i.push(r),n.set(t,i)}let r=new globalThis.Map;for(let[e,t]of n)r.set(e,S(t));return r},partition:e=>{let n=[],r=[];for(let i of t)e(i)?n.push(i):r.push(i);return[S(n),S(r)]},span:e=>{let n=t.findIndex(t=>!e(t));return n===-1?[S([...t]),S([])]:[S(t.slice(0,n)),S(t.slice(n))]},slice:(e,n)=>S(t.slice(e,n)),drop:e=>S(t.slice(Math.max(0,e))),dropRight:e=>S(e>0?t.slice(0,Math.max(0,t.length-Math.trunc(e))):t.slice()),dropWhile:e=>{let n=t.findIndex(t=>!e(t));return S(n===-1?[]:t.slice(n))},flatten:()=>S(t.flatMap(e=>xe(e)?[...e]:[e])),toList:()=>n,toSet:()=>fe(t),toOption:()=>t.length>0?m(t[0]):p(),toEither:e=>t.length>0?w(t[0]):T(e),toTry:()=>t.length>0?x(()=>t[0]):x(()=>{throw Error(`Empty list`)}),toString:()=>`List(${u(t)})`,toValue:()=>({_tag:`List`,value:t}),toJSON:()=>({"@functype":`List`,_tag:`List`,value:[...t]}),pipe:e=>e([...t]),serialize:()=>c(`List`,t),doUnwrap(){return t.length===0?{ok:!1,empty:!0}:{ok:!0,value:t[0]}}};return n},Se=e=>S(e),Ce=S([]),we={empty:()=>Ce,of:(...e)=>S(e),fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`List`)throw Error(`List.fromJSON: expected @functype="List", got ${JSON.stringify(t[`@functype`])}`);return C(t.value)},fromYAML:e=>{let t=e.split(`
|
|
5
|
+
`)[1]?.split(`: `)[1];if(!t)return C([]);let n=JSON.parse(t);return C(n)},fromBinary:e=>{let t=s(e);return we.fromJSON(t)}},C=r(Se,we),Te=e=>({[Symbol.toStringTag]:`Either`,_tag:`Right`,value:e,isLeft(){return!1},isRight(){return!0},orElse:t=>e,orThrow:()=>e,expect:t=>e,or:t=>w(e),orNull:()=>e,orUndefined:()=>e,map:t=>w(t(e)),ap:t=>t._tag===`Right`?w(t.value(e)):T(t.value),mapAsync:async t=>w(await t(e)),merge:t=>t.isLeft()?T(t.value):w([e,t.value]),flatMap:t=>t(e),flatMapAsync:async t=>await t(e),toOption:()=>d(e),toList:()=>C([e]),toEither:t=>w(e),toTry:()=>x(()=>e),toJSON(){return{"@functype":`Either`,_tag:`Right`,value:e}},toString:()=>`Right(${l(e)})`,*[Symbol.iterator](){yield e},*yield(){yield e},traverse:t=>{let n=t(e);return n.isLeft()?T(n.value):w([n.value])},tap:t=>(t(e),w(e)),tapLeft:t=>w(e),mapLeft:t=>w(e),filterOrElse:(t,n)=>t(e)?w(e):T(n(e)),bimap:(t,n)=>w(n(e)),fold:(t,n)=>n(e),foldAsync:async(t,n)=>n(e),foldLeft:t=>n=>n(t,e),foldRight:t=>n=>n(e,t),match:t=>t.Right(e),swap:()=>T(e),toPromise:()=>Promise.resolve(e),toValue:()=>({_tag:`Right`,value:e}),pipeEither:(t,n)=>n(e),pipe:t=>t(e),serialize:()=>c(`Either`,`Right`,e),contains:t=>e===t,exists:t=>t(e),every:t=>t(e),forEach:t=>t(e),doUnwrap(){return{ok:!0,value:e}}}),Ee=e=>({[Symbol.toStringTag]:`Either`,_tag:`Left`,value:e,isLeft(){return!0},isRight(){return!1},orElse:e=>e,orThrow:t=>{throw t===void 0?e:typeof t==`function`?t(e):t},expect:t=>t(e),or:e=>e,orNull:()=>null,orUndefined:()=>void 0,map:t=>T(e),ap:t=>T(e),mapAsync:t=>Promise.resolve(T(e)),merge:t=>T(e),flatMap:t=>T(e),flatMapAsync:t=>Promise.resolve(T(e)),toOption:()=>p(),toList:()=>C(),toEither:e=>T(e),toTry:()=>x(()=>{throw Error(String(e))}),toJSON(){return{"@functype":`Either`,_tag:`Left`,value:e}},toString:()=>`Left(${l(e)})`,*[Symbol.iterator](){},*yield(){},traverse:t=>T(e),tap:t=>T(e),tapLeft:t=>(t(e),T(e)),mapLeft:t=>T(t(e)),filterOrElse:(t,n)=>T(e),bimap:(t,n)=>T(t(e)),fold:(t,n)=>t(e),foldAsync:async(t,n)=>t(e),foldLeft:e=>t=>e,foldRight:e=>t=>e,match:t=>t.Left(e),swap:()=>w(e),toPromise:()=>Promise.reject(e),toValue:()=>({_tag:`Left`,value:e}),pipeEither:(t,n)=>t(e),pipe:t=>t(e),serialize:()=>c(`Either`,`Left`,e),contains:e=>!1,exists:e=>!1,every:e=>!0,forEach:e=>{},doUnwrap(){return{ok:!1,empty:!1,error:e}}}),w=e=>Te(e),T=e=>Ee(e),De=e=>e.isRight(),Oe=e=>e.isLeft(),ke=(e,t)=>{try{return w(e())}catch(e){return T(t(e))}},Ae=e=>Te(e);console.assert(Ae);const je=e=>Ee(e);console.assert(je);const Me=async(e,t)=>{try{let t=await e();return w(t)}catch(e){return T(t(e))}},Ne=(e,t)=>t?w(e):T(e),Pe={left:e=>T(e),right:e=>w(e),void:()=>w(void 0),isRight:e=>e.isRight(),isLeft:e=>e.isLeft(),sequence:e=>e.reduce((e,t)=>e.isLeft()?e:t.isLeft()?T(t.value):e.map(e=>[...e,t.value]),w([])),traverse:(e,t)=>e.reduce((e,n,r)=>e.flatMap(e=>t(n,r).map(t=>[...e,t])),w([])),traverseAsync:async(e,t,n)=>{let r=await oe(e,t,n?.concurrency??1,e=>e.isLeft());return Pe.sequence(r)},fromNullable:(e,t)=>e==null?T(t):w(e),fromPredicate:(e,t,n)=>t(e)?w(e):T(n),ap:(e,t)=>e.flatMap(e=>t.map(e)),fromPromise:async(e,t)=>{try{let t=await e;return w(t)}catch(e){return T(t(e))}},fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`Either`)throw Error(`Either.fromJSON: expected @functype="Either", got ${JSON.stringify(t[`@functype`])}`);return t._tag===`Right`?w(t.value):T(t.value)},fromYAML:e=>{let t=e.split(`
|
|
6
|
+
`),n=t[0]?.split(`: `)[1],r=t[1]?.split(`: `)[1];if(!n||!r)throw Error(`Invalid YAML format for Either`);let i=JSON.parse(r);return n===`Right`?w(i):T(i)},fromBinary:e=>{let t=s(e);return Pe.fromJSON(t)}},Fe=r(Ne,Pe);function E(e,n){return{brand:e,validate:n,of:r=>n(r)?m(t(e,r)):m.none(),from:r=>n(r)?w(t(e,r)):T(`Invalid ${e}: validation failed`),unsafeOf:r=>{if(!n(r))throw Error(`Invalid ${e}: validation failed`);return t(e,r)},is:e=>{try{return n(e)}catch{return!1}},unwrap:e=>e,refine:(e,t)=>E(e,e=>n(e)&&t(e))}}const Ie=E(`PositiveNumber`,e=>e>0),Le=E(`NonNegativeNumber`,e=>e>=0),Re=E(`IntegerNumber`,e=>Number.isInteger(e)),ze=Ie.refine(`PositiveInteger`,e=>Number.isInteger(e)),Be=E(`NonEmptyString`,e=>e.length>0),Ve=E(`EmailAddress`,e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)),He=E(`UrlString`,e=>{try{return new URL(e),!0}catch{return!1}}),Ue=E(`UUID`,e=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)),We=E(`ISO8601Date`,e=>!isNaN(Date.parse(e))&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(e));function Ge(e,t,n){return E(e,e=>e>=t&&e<=n)}function Ke(e,t,n){return E(e,e=>e.length>=t&&e.length<=n)}function qe(e,t){return E(e,e=>t.test(e))}const Je=e=>{let t=e=>typeof e==`function`?e():e,n={when:(r,i)=>e.resolved?n:r?Je({resolved:!0,value:t(i)}):n,elseWhen:(r,i)=>e.resolved?n:r?Je({resolved:!0,value:t(i)}):n,else:n=>e.resolved?e.value:t(n),orThrow:()=>{if(!e.resolved)throw Error(`Conditional expression has no matching condition`);return e.value}};return n},Ye=()=>Je({resolved:!1}),Xe=r(Ye,{of:()=>Ye(),match:e=>t=>{let n=t[e];if(n===void 0)throw Error(`No case defined for value: ${String(e)}`);return typeof n==`function`?n():n},lazy:()=>{let e={resolved:!1},t={when:(n,r)=>(e.resolved||n()&&(e.resolved=!0,e.value=r()),t),elseWhen:(n,r)=>(e.resolved||n()&&(e.resolved=!0,e.value=r()),t),else:t=>e.resolved?e.value:t()};return t}}),Ze=(e,t)=>t===e?!0:typeof t==`function`?t(e):t&&typeof t==`object`&&`_`in t?t._(e):typeof t==`object`&&t&&typeof e==`object`&&e?Object.entries(t).every(([t,n])=>{let r=e[t];return Ze(r,n)}):!1,D=e=>{let t=(e,t)=>typeof e==`function`?e(t):e,n=()=>{for(let{pattern:n,result:r}of e.patterns)if(Ze(e.value,n))return{matched:!0,result:t(r,e.value)};return{matched:!1}},r={case:(n,i)=>e.resolved?r:Ze(e.value,n)?D({value:e.value,resolved:!0,result:t(i,e.value),patterns:[]}):D({...e,patterns:[...e.patterns,{pattern:n,result:i}]}),caseValue:(t,n)=>{if(e.resolved)return r;if(e.value===t){let t=typeof n==`function`?n():n;return D({value:e.value,resolved:!0,result:t,patterns:[]})}return r},caseValues:(t,n)=>{if(e.resolved)return r;if(t.includes(e.value)){let t=typeof n==`function`?n():n;return D({value:e.value,resolved:!0,result:t,patterns:[]})}return r},when:(e,t)=>r.case(e,t),caseAny:(n,i)=>{if(e.resolved)return r;for(let r of n)if(Ze(e.value,r))return D({value:e.value,resolved:!0,result:t(i,e.value),patterns:[]});return D({...e,patterns:[...e.patterns,...n.map(e=>({pattern:e,result:i}))]})},default:n=>e.resolved?e.result:t(n,e.value),exhaustive:()=>{if(e.resolved)return e.result;let t=n();if(!t.matched)throw Error(`Non-exhaustive match. No pattern matched value: ${JSON.stringify(e.value)}`);return t.result},orThrow:t=>{if(e.resolved)return e.result;let r=n();if(!r.matched)throw Error(t??`No matching pattern for value: ${JSON.stringify(e.value)}`);return r.result},toOption:()=>{if(e.resolved)return m(e.result);let t=n();return t.matched?m(t.result):m.none()}};return r},Qe=e=>{let t=(e,t)=>typeof e==`function`?e(t):e;return{case:(n,r)=>{let i={value:e,resolved:!1,patterns:[{pattern:n,result:r}]};return Ze(e,n)?D({...i,resolved:!0,result:t(r,e)}):D(i)},caseValue:(t,n)=>{if(e===t){let t=typeof n==`function`?n():n;return D({value:e,resolved:!0,result:t,patterns:[]})}return D({value:e,resolved:!1,patterns:[]})},caseValues:(t,n)=>{if(t.includes(e)){let t=typeof n==`function`?n():n;return D({value:e,resolved:!0,result:t,patterns:[]})}return D({value:e,resolved:!1,patterns:[]})},when:(n,r)=>{let i={value:e,resolved:!1,patterns:[{pattern:n,result:r}]};return n(e)?D({...i,resolved:!0,result:t(r,e)}):D(i)},caseAny:(n,r)=>{for(let i of n)if(Ze(e,i))return D({value:e,resolved:!0,result:t(r,e),patterns:n.map(e=>({pattern:e,result:r}))});return D({value:e,resolved:!1,patterns:n.map(e=>({pattern:e,result:r}))})}}},$e=r(e=>Qe(e),{exhaustive:e=>t=>{let n=e[t];if(n===void 0)throw Error(`No case defined for value: ${String(t)}`);return n},partial:e=>({withDefault:t=>n=>{let r=e[n];return r===void 0?typeof t==`function`?t(n):t:typeof r==`function`?r(n):r}}),withGuards:e=>({withDefault:t=>n=>{for(let[t,r]of e)if(t(n))return typeof r==`function`?r(n):r;return typeof t==`function`?t(n):t}}),struct:()=>{let e=[],t={case:(n,r)=>(e.push({pattern:n,handler:r}),t),build:()=>t=>{for(let{pattern:n,handler:r}of e)if(Ze(t,n))return r(t);throw Error(`No matching pattern for value: ${JSON.stringify(t)}`)}};return t},builder:()=>{let e=[],t,n={case:(t,r)=>(e.push({pattern:t,result:r}),n),when:(t,r)=>(e.push({pattern:t,result:r}),n),default:n=>(t=n,{build:()=>n=>{for(let{pattern:t,result:r}of e)if(Ze(n,t))return typeof r==`function`?r(n):r;if(t!==void 0)return typeof t==`function`?t(n):t;throw Error(`No matching pattern for value: ${JSON.stringify(n)}`)}})};return n}});function et(e,t){return{...ye({_tag:e,impl:t}),toString(){return`${e}()`},doUnwrap(){if(`isSome`in t&&`isNone`in t){if(typeof t.isSome==`function`&&t.isSome()&&`get`in t&&typeof t.get==`function`)return{ok:!0,value:t.get()};if(typeof t.isNone==`function`&&t.isNone())return{ok:!1,empty:!0}}if(`isLeft`in t&&`isRight`in t){if(typeof t.isRight==`function`&&t.isRight()&&`value`in t)return{ok:!0,value:t.value};if(typeof t.isLeft==`function`&&t.isLeft()&&`value`in t)return{ok:!1,empty:!1,error:t.value}}if(`isSuccess`in t&&`isFailure`in t){if(typeof t.isSuccess==`function`&&t.isSuccess()&&`get`in t&&typeof t.get==`function`)return{ok:!0,value:t.get()};if(typeof t.isFailure==`function`&&t.isFailure()&&`getError`in t&&typeof t.getError==`function`)return{ok:!1,empty:!1,error:t.getError()}}if(`isEmpty`in t&&`head`in t){if(typeof t.isEmpty==`function`&&t.isEmpty())return{ok:!1,empty:!0};if(typeof t.head==`function`)return{ok:!0,value:t.head()};if(`head`in t)return{ok:!0,value:t.head}}return{ok:!0,value:t}}}}const tt=`Throwable`;var nt=class e extends Error{constructor(e,t){super(e,{cause:t?.cause}),this._tag=tt,this.name=t?.taskInfo?.name??`Throwable`,Object.defineProperties(this,{_tag:{value:tt,writable:!1,configurable:!1},data:{value:t?.data,writable:!1,configurable:!1},taskInfo:{value:t?.taskInfo,writable:!1,configurable:!1},name:{value:t?.taskInfo?.name??`Throwable`,writable:!1,configurable:!1}}),t?.cause&&Object.defineProperty(this,"cause",{value:t.cause,writable:!1,configurable:!1}),t?.stack?this.stack=t.stack:Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}static apply(t,n,r){if(t instanceof Error){let i=new e(t.message,{data:n,cause:t.cause??void 0,stack:t.stack??void 0,taskInfo:r});for(let e of Object.keys(t))if(!(e in i)){let n=i;n[e]=t[e]}return i}if(t&&typeof t==`object`){let i=t,a=typeof i.message==`string`?i.message:typeof i.error==`string`?i.error:`Object error: ${JSON.stringify(i,Object.getOwnPropertyNames(i).filter(e=>i[e]!==void 0))}`,o=i.cause instanceof Error?i.cause:void 0,s=new e(a,{data:n??i,cause:o,taskInfo:r});for(let e of Object.keys(i))if(!(e in s)){let t=s;t[e]=i[e]}return s}if(typeof t==`function`){let i=t.name??`anonymous function`,a=t.toString().substring(0,100)+(t.toString().length>100?`...`:``);return new e(`Function error: ${i}`,{data:n??{functionType:typeof t,functionName:i,functionString:a},taskInfo:r})}let i=typeof t,a=t===null?`null`:t===void 0?`undefined`:String(t);if(i===`number`){let a=t,o=Number.isNaN(a)?`Number error: NaN`:Number.isFinite(a)?`Number error: ${a}`:`Number error: ${a>0?`Infinity`:`-Infinity`}`;return new e(o,{data:n??{errorType:i,errorValue:a,originalError:t},taskInfo:r})}if(i===`bigint`)return new e(`BigInt error: ${t}n`,{data:n??{errorType:i,errorValue:String(t),originalError:t},taskInfo:r});if(i===`boolean`)return new e(`Boolean error: ${t}`,{data:n??{errorType:i,errorValue:t,originalError:t},taskInfo:r});if(i===`symbol`){let a=t.description??`unnamed symbol`;return new e(`Symbol error: Symbol(${a})`,{data:n??{errorType:i,symbolDescription:a,originalError:t},taskInfo:r})}let o=typeof t==`string`?t:`${i.charAt(0).toUpperCase()+i.slice(1)} error: ${a}`;return new e(o,{data:n??{errorType:i,errorValue:a,originalError:t},taskInfo:r})}};function rt(e){return e instanceof Error&&typeof e==`object`&&e._tag===`Throwable`}const it=(e,t)=>{if(e.isRight())return k(e.orThrow(),t);if(e.isLeft())return O(e.fold(e=>e,()=>/* @__PURE__ */ Error(`Unexpected right value`)),void 0,t);throw Error(`Unrecognized task outcome`)},O=(e,t,n)=>{let r={name:n?.name??`Task`,description:n?.description??``},a=nt.apply(e,t,r),s={...et(`Err`,{error:a,meta:r}),[Symbol.toStringTag]:`TaskOutcome`,_tag:`Err`,_meta:r,value:void 0,error:a,isSuccess(){return!1},isFailure(){return!0},isOk(){return!1},isErr(){return!0},map:e=>O(a,t,n),flatMap:e=>O(a,t,n),ap:e=>O(a,t,n),mapAsync:e=>Promise.resolve(O(a,t,n)),flatMapAsync:e=>Promise.resolve(O(a,t,n)),mapError:e=>O(e(a),t,n),recover:e=>k(e,n),recoverWith:e=>k(e(a),n),orThrow:e=>{throw e??a},orElse:e=>e,or:e=>e,orNull:()=>null,orUndefined:()=>void 0,toEither:()=>T(a),toTry:()=>x(()=>{throw a}),toOption:()=>p(),toList:()=>C([]),fold:(e,t)=>e(a),match:e=>e.Err(a),foldLeft:e=>t=>e,foldRight:e=>t=>e,size:0,isEmpty:!0,contains:e=>!1,reduce:e=>{throw Error(`Cannot reduce empty Err`)},reduceRight:e=>{throw Error(`Cannot reduceRight empty Err`)},count:e=>0,find:e=>p(),exists:e=>!1,forEach:e=>{},toPromise:()=>Promise.reject(a),doUnwrap(){return{ok:!1,empty:!1,error:a}},toJSON:()=>({"@functype":`Task`,_tag:`Err`,error:o(a)}),serialize:()=>i(`Task`,`Err`,{error:o(a)}),pipe:e=>e(s)};return s},k=(e,t)=>{let n={name:t?.name??`Task`,description:t?.description??``},r={...et(`Ok`,{value:e,meta:n}),[Symbol.toStringTag]:`TaskOutcome`,_tag:`Ok`,_meta:n,value:e,error:void 0,isSuccess(){return!0},isFailure(){return!1},isOk(){return!0},isErr(){return!1},map:n=>k(n(e),t),flatMap:n=>{let r=n(e);return r&&typeof r==`object`&&`isLeft`in r&&`isRight`in r?it(r,t):r},ap:n=>n.isOk()?k(n.value(e),t):O(n.error,void 0,t),mapAsync:async n=>k(await n(e),t),flatMapAsync:async t=>await t(e),mapError:n=>k(e,t),recover:n=>k(e,t),recoverWith:n=>k(e,t),orThrow:t=>e,orElse:t=>e,or:n=>k(e,t),orNull:()=>e,orUndefined:()=>e,toEither:()=>w(e),toTry:()=>x(()=>e),toOption:()=>d(e),toList:()=>C([e]),fold:(t,n)=>n(e),match:t=>t.Ok(e),foldLeft:t=>n=>n(t,e),foldRight:t=>n=>n(e,t),size:1,isEmpty:!1,contains:t=>e===t,reduce:t=>e,reduceRight:t=>e,count:t=>+!!t(e),find:t=>t(e)?d(e):p(),exists:t=>t(e),forEach:t=>t(e),toPromise:()=>Promise.resolve(e),doUnwrap(){return{ok:!0,value:e}},toJSON:()=>({"@functype":`Task`,_tag:`Ok`,value:e}),serialize:()=>c(`Task`,`Ok`,e),pipe:e=>e(r)};return r},at=()=>{let e=new AbortController,t=he();return{token:{get isCancelled(){return e.signal.aborted},get signal(){return e.signal},onCancel(n){e.signal.aborted?n():t.add(n)}},cancel(){e.signal.aborted||(e.abort(),t.build().forEach(e=>{try{e()}catch(e){console.error(`Error in cancellation callback:`,e)}}))}}},ot=e=>{let t=e?.name??`Task`,n=e?.description??``,r={Async:(e,r=e=>e,i=()=>{},a)=>new Promise(o=>{(async()=>{let s=_(!1),c=_(null),l=_(()=>{});if(a){if(a.isCancelled){try{await i()}catch(e){o(O(e,void 0,{name:t,description:n}));return}o(O(/* @__PURE__ */ Error(`Task was cancelled before execution started`),void 0,{name:t,description:n}));return}a.onCancel(()=>{s.set(!0),c.set(/* @__PURE__ */ Error(`Task was cancelled during execution`))}),l.set(()=>{})}try{let r=await e();try{await i()}catch(e){o(O(e,void 0,{name:t,description:n}));return}if(s.get()){c.get()?o(O(c.get(),void 0,{name:t,description:n})):o(O(/* @__PURE__ */ Error(`Task was cancelled during execution`),void 0,{name:t,description:n}));return}if(r&&typeof r==`object`&&`_tag`in r){let e=r;e._tag===`Ok`||e._tag===`Err`?o(e):o(k(r,{name:t,description:n}))}else o(k(r,{name:t,description:n}))}catch(e){try{await i()}catch(e){o(O(e,void 0,{name:t,description:n}));return}if(s.get()){c.get()?o(O(c.get(),void 0,{name:t,description:n})):o(O(/* @__PURE__ */ Error(`Task was cancelled during execution`),void 0,{name:t,description:n}));return}try{if(e instanceof Error&&rt(e)){let i=/* @__PURE__ */ Error(`${t}: ${e.message}`),a=nt.apply(i,void 0,{name:t,description:n});Object.defineProperty(a,"cause",{value:e,writable:!1,configurable:!1}),Promise.resolve().then(()=>{try{r(e)}catch(e){console.error(`Error in error handler:`,e)}}),o(O(a,void 0,{name:t,description:n}))}else{let i=await r(e);if(i&&typeof i==`object`&&`_tag`in i){let e=i;e._tag===`Ok`||e._tag===`Err`?o(e):o(O(i,void 0,{name:t,description:n}))}else o(O(i,void 0,{name:t,description:n}))}}catch(e){o(O(e,void 0,{name:t,description:n}))}}finally{l.get()()}})().catch(e=>o(O(e,void 0,{name:t,description:n})))}),Sync:(e,r=e=>e,i=()=>{})=>{try{return k(e(),{name:t,description:n})}catch(e){return O(r(e),void 0,{name:t,description:n})}finally{i()}},AsyncWithProgress:(e,t,n=e=>e,i=()=>{},a)=>{let o=e=>{let n=Math.max(0,Math.min(100,e));n<=100&&t(n)};return r.Async(()=>e(o),n,i,a)}};return{...et(`Task`,r),_type:`Task`}},st={success:(e,t)=>k(e,t),fail:(e,t,n)=>O(e,t,n),ok:(e,t)=>k(e,t),err:(e,t,n)=>O(e,t,n),fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`Task`)throw Error(`Task.fromJSON: expected @functype="Task", got ${JSON.stringify(t[`@functype`])}`);if(t._tag===`Ok`)return k(t.value);if(t._tag===`Err`){let e=t.error!==void 0&&typeof t.error==`object`?a(t.error):Error(typeof t.error==`string`?t.error:`Unknown Task error`);return O(e)}throw Error(`Task.fromJSON: unrecognized _tag ${JSON.stringify(t._tag)}`)},fromEither:(e,t)=>it(e,t),fromTry:(e,t)=>e.isSuccess()?k(e.orThrow(),t):O(e.fold(e=>e,()=>/* @__PURE__ */ Error(`Unexpected success`)),void 0,t),getErrorChain:e=>{if(!e)return[];let t=he();t.add(e);let n=_(e);for(;n.get()&&n.get().cause;){let{cause:e}=n.get();if(e)t.add(e),n.set(e);else break;if(t.size()>100)break}return t.build()},formatErrorChain:(e,t)=>{let n=st.getErrorChain(e),r=t?.separator??`
|
|
7
7
|
`;return n.map((e,n)=>{if(!e)return`${n>0?`↳ `:``}Unknown error`;let{taskInfo:r}=e,i=t?.includeTasks&&r?.name?`[${r.name}] `:``,a=e.message??`No message`,o=_(`${n>0?`↳ `:``}${i}${a}`);return t?.includeStackTrace&&e.stack&&o.set(`${o.get()}\n${e.stack.split(`
|
|
8
8
|
`).slice(1).join(`
|
|
9
|
-
`)}`),o.get()}).join(r)},fromPromise:(e,t)=>(...n)=>A(t??{name:`PromiseTask`,description:`Task from Promise`}).Async(()=>e(...n),e=>e),toPromise:e=>new Promise((t,n)=>{e.isSuccess()?t(e.orThrow()):n(e.error)}),race:(e,t,n)=>{let r={name:n?.name??`TaskRace`,description:n?.description??`Race between multiple tasks`};return A(r).Async(async()=>{let n=he();e.forEach(e=>n.add(e));let r=_(void 0);if(typeof t==`number`&&t>0){let e=new Promise((e,n)=>{r.set(setTimeout(()=>{n(/* @__PURE__ */ Error(`Task race timed out after ${t}ms`))},t))});n.add(e)}try{return await new Promise((e,t)=>{n.build().forEach(n=>{n.then(n=>{if(n&&typeof n==`object`&&`_tag`in n){let r=n;r._tag===`Ok`?e(r.orThrow()):r._tag===`Err`?t(r.error):e(n)}else e(n)},e=>t(e))})})}finally{r.get()&&clearTimeout(r.get())}},e=>e)},fromNodeCallback:(e,t)=>{let n={name:t?.name??`NodeCallbackTask`,description:t?.description??`Task from Node.js callback function`};return(...t)=>A(n).Async(()=>new Promise((n,r)=>{try{e(...t,(e,t)=>{e?r(e):n(t)})}catch(e){r(e)}}),e=>e)},createCancellationTokenSource:
|
|
10
|
-
`)[1]?.split(`: `)[1];if(!t)return
|
|
11
|
-
`),
|
|
12
|
-
`,includeData:!1,maxStackFrames:3,title:`Error`,colors:!1};function
|
|
9
|
+
`)}`),o.get()}).join(r)},fromPromise:(e,t)=>(...n)=>A(t??{name:`PromiseTask`,description:`Task from Promise`}).Async(()=>e(...n),e=>e),toPromise:e=>new Promise((t,n)=>{e.isSuccess()?t(e.orThrow()):n(e.error)}),race:(e,t,n)=>{let r={name:n?.name??`TaskRace`,description:n?.description??`Race between multiple tasks`};return A(r).Async(async()=>{let n=he();e.forEach(e=>n.add(e));let r=_(void 0);if(typeof t==`number`&&t>0){let e=new Promise((e,n)=>{r.set(setTimeout(()=>{n(/* @__PURE__ */ Error(`Task race timed out after ${t}ms`))},t))});n.add(e)}try{return await new Promise((e,t)=>{n.build().forEach(n=>{n.then(n=>{if(n&&typeof n==`object`&&`_tag`in n){let r=n;r._tag===`Ok`?e(r.orThrow()):r._tag===`Err`?t(r.error):e(n)}else e(n)},e=>t(e))})})}finally{r.get()&&clearTimeout(r.get())}},e=>e)},fromNodeCallback:(e,t)=>{let n={name:t?.name??`NodeCallbackTask`,description:t?.description??`Task from Node.js callback function`};return(...t)=>A(n).Async(()=>new Promise((n,r)=>{try{e(...t,(e,t)=>{e?r(e):n(t)})}catch(e){r(e)}}),e=>e)},createCancellationTokenSource:at,cancellable:(e,t)=>{let n=at();return{task:A(t).Async(()=>e(n.token),e=>e,()=>{},n.token),cancel:()=>n.cancel()}},withProgress:(e,t=()=>{},n)=>{let r=at(),i=_(0),a=e=>{i.set(Math.max(0,Math.min(100,e))),t(i.get())};return{task:A(n).Async(()=>e(a,r.token),e=>e,()=>{},r.token),cancel:()=>r.cancel(),currentProgress:()=>i.get()}}},A=r(ot,st),ct=Map,j=e=>{let t={values:new ct(e)},n=()=>Array.from(t.values.entries()).map(([e,t])=>re([e,t])),r=e=>j(new ct(t.values).set(e.toArray()[0],e.toArray()[1]).entries()),i=e=>{let n=new ct(t.values);return n.delete(e)?j(n.entries()):j(t.values.entries())},a=e=>{if(!e||typeof e.toArray!=`function`)return!1;let n=e.toArray();return t.values.get(n[0])===n[1]},o=()=>t.values.size,s=e=>j(Array.from(t.values.entries()).map(([t,n])=>[t,e(n)])),l=e=>{let n=j(t.values.entries()).toList();return j(n.flatMap(e).toArray())},u=e=>{let n=[];for(let[r,i]of t.values.entries()){let t=e.get(r);t._tag===`Some`&&t.value&&n.push([r,t.value(i)])}return j(n)},ee=async e=>{let n=new ct;for(let[r,i]of t.values.entries()){let t=await e(i);for(let e of t.toList()){let[t,r]=e.toArray();n.set(t,r)}}return j(n.entries())},te=e=>C(n()).reduce(e),ne=e=>C(n()).reduceRight(e),ie=e=>t=>C(n()).foldLeft(e)(t),ae=e=>t=>C(n()).foldRight(e)(t),oe=e=>m(t.values.get(e)),d=e=>t.values.has(e),f=()=>C(Array.from(t.values.keys())),p=()=>C(Array.from(t.values.values())),se=(e,n)=>m(t.values.get(e)).orElse(n),ce=()=>t.values.size===0,h=(e,n)=>m(t.values.get(e)).or(n),g=(e,t)=>C(n()).fold(e,t),le=()=>C(n()),ue=()=>fe(n()),de=()=>`Map(${n().toString()})`,pe=e=>ce()?e.Empty():e.NonEmpty(n());return{[Symbol.toStringTag]:`FunctypeMap`,_tag:`Map`,[Symbol.iterator]:()=>t.values.entries(),add:r,remove:i,contains:a,get size(){return o()},map:s,ap:u,flatMap:l,flatMapAsync:ee,reduce:te,reduceRight:ne,foldLeft:ie,foldRight:ae,fold:g,match:pe,get:oe,has:d,keys:f,values:p,getOrElse:se,get isEmpty(){return ce()},orElse:h,toList:le,toSet:ue,toString:de,toValue:()=>({_tag:`Map`,value:Array.from(t.values.entries())}),toJSON:()=>({"@functype":`Map`,_tag:`Map`,value:Array.from(t.values.entries())}),pipe:e=>e(Array.from(t.values.entries())),serialize:()=>c(`Map`,Array.from(t.values.entries()))}},lt=e=>j(e),ut=j([]),dt={empty:()=>ut,of:(...e)=>j(e),fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`Map`)throw Error(`Map.fromJSON: expected @functype="Map", got ${JSON.stringify(t[`@functype`])}`);return ft(t.value)},fromYAML:e=>{let t=e.split(`
|
|
10
|
+
`)[1]?.split(`: `)[1];if(!t)return ft([]);let n=JSON.parse(t);return ft(n)},fromBinary:e=>{let t=s(e);return dt.fromJSON(t)}},ft=r(lt,dt),pt=(e,t,n)=>({_tag:`Leaf`,path:e,message:t,cause:n}),mt=(e,t)=>({_tag:`Composite`,path:e,children:t}),ht=e=>e._tag===`Leaf`,gt=e=>e._tag===`Composite`,_t=(e,t)=>e._tag===`Leaf`?t.Leaf(e):t.Composite(e),vt=(e,t)=>t._tag===`Leaf`?{...t,path:[e,...t.path]}:{...t,children:C(t.children.toArray().map(t=>vt(e,t)))},yt=e=>e._tag===`Leaf`?C([{path:e.path,message:e.message}]):C(e.children.toArray().flatMap(e=>yt(e).toArray())),bt=e=>yt(e).toArray().map(({path:e,message:t})=>`${xt(e)}: ${t}`).join(`
|
|
11
|
+
`),xt=e=>e.length===0?`(root)`:e.reduce((e,t)=>t.startsWith(`[`)&&t.endsWith(`]`)?`${e}${t}`:e===``?t:`${e}.${t}`,``),M=r({_tag:`DecoderError`},{leaf:pt,composite:mt,isLeaf:ht,isComposite:gt,match:_t,prepend:vt,flatten:yt,format:bt}),St=e=>typeof e==`string`?w(e):T(M.leaf([],`expected string`,{received:e})),Ct=e=>typeof e==`number`?w(e):T(M.leaf([],`expected number`,{received:e})),wt=e=>typeof e==`boolean`?w(e):T(M.leaf([],`expected boolean`,{received:e})),Tt=e=>w(e),Et=e=>t=>{try{return w(e(t))}catch(e){return T(M.leaf([],e instanceof Error?e.message:String(e),e))}},Dt=e=>t=>t==null?w(null):e(t),Ot=e=>t=>t==null?w(p()):e(t).fold(e=>T(e),e=>w(d(e))),kt={envelope:e=>t=>{if(typeof t!=`object`||!t)return T(M.leaf([],`expected envelope object {ok|err}`,{received:t}));let n=t;return`ok`in n?e.ok(n.ok).fold(e=>T(M.prepend(`ok`,e)),e=>w(w(e))):`err`in n?e.err(n.err).fold(e=>T(M.prepend(`err`,e)),e=>w(T(e))):T(M.leaf([],`expected envelope to have 'ok' or 'err' key`,{received:t}))},discriminated:(e,t,n)=>r=>{if(typeof r!=`object`||!r)return T(M.leaf([],`expected object with '${e.tag}' tag`,{received:r}));let i=r[e.tag];return i===e.rightTag?n(r).fold(e=>T(e),e=>w(w(e))):i===e.leftTag?t(r).fold(e=>T(e),e=>w(T(e))):T(M.leaf([],`expected '${e.tag}' to be '${e.rightTag}' or '${e.leftTag}'`,{received:i}))}},At=e=>t=>{if(!Array.isArray(t))return T(M.leaf([],`expected array`,{received:t}));let n=[],r=[];return t.forEach((t,i)=>{e(t).fold(e=>{n.push(M.prepend(`[${i}]`,e))},e=>{r.push(e)})}),Pt(n,()=>C(r))},jt=e=>t=>{if(!Array.isArray(t))return T(M.leaf([],`expected array`,{received:t}));let n=[],r=[];return t.forEach((t,i)=>{e(t).fold(e=>{n.push(M.prepend(`[${i}]`,e))},e=>{r.push(e)})}),Pt(n,()=>r)},Mt=e=>t=>{if(typeof t!=`object`||!t||Array.isArray(t))return T(M.leaf([],`expected object (for Map)`,{received:t}));let n=t,r=[],i=[];for(let t of Object.keys(n))e(n[t]).fold(e=>{r.push(M.prepend(t,e))},e=>{i.push([t,e])});return Pt(r,()=>ft(i))},Nt=e=>t=>{if(typeof t!=`object`||!t||Array.isArray(t))return T(M.leaf([],`expected object`,{received:t}));let n=t,r=[],i={};for(let t in e)e[t](n[t]).fold(e=>{r.push(M.prepend(t,e))},e=>{i[t]=e});return Pt(r,()=>i)},Pt=(e,t)=>e.length===0?w(t()):e.length===1?T(e[0]):T(M.composite([],C(e))),Ft={string:St,number:Ct,boolean:wt,unknown:Tt,fromThrowing:Et,nullable:Dt,option:Ot,either:kt,list:At,array:jt,map:Mt,object:Nt},It=(e,t)=>M.prepend(e,t),Lt=(e,t,n)=>M.prepend(e,M.prepend(`[${t}]`,n)),Rt={option:e=>t=>{if(typeof t!=`object`||!t)return T(M.leaf([],`expected tagged Option object`,{received:t}));let n=t;return n._tag===`None`?w(p()):n._tag===`Some`?e(n.value).fold(e=>T(It(`value`,e)),e=>w(d(e))):T(M.leaf([`_tag`],`expected 'Some' or 'None'`,{received:n._tag}))},either:(e,t)=>n=>{if(typeof n!=`object`||!n)return T(M.leaf([],`expected tagged Either object`,{received:n}));let r=n;return r._tag===`Right`?t(r.value).fold(e=>T(It(`value`,e)),e=>w(w(e))):r._tag===`Left`?e(r.value).fold(e=>T(It(`value`,e)),e=>w(T(e))):T(M.leaf([`_tag`],`expected 'Left' or 'Right'`,{received:r._tag}))},try:e=>t=>{if(typeof t!=`object`||!t)return T(M.leaf([],`expected tagged Try object`,{received:t}));let n=t;if(n._tag===`Success`)return e(n.value).fold(e=>T(It(`value`,e)),e=>w(x.success(e)));if(n._tag===`Failure`){let e=typeof n.error==`string`?n.error:`unknown error`,t=Error(e);return typeof n.stack==`string`&&(t.stack=n.stack),w(x.failure(t))}return T(M.leaf([`_tag`],`expected 'Success' or 'Failure'`,{received:n._tag}))},list:e=>t=>{if(typeof t!=`object`||!t)return T(M.leaf([],`expected tagged List object`,{received:t}));let n=t;if(n._tag!==`List`)return T(M.leaf([`_tag`],`expected 'List'`,{received:n._tag}));if(!Array.isArray(n.value))return T(M.leaf([`value`],`expected array`,{received:n.value}));let r=[],i=[];return n.value.forEach((t,n)=>{e(t).fold(e=>{r.push(Lt(`value`,n,e))},e=>{i.push(e)})}),r.length===0?w(C(i)):r.length===1?T(r[0]):T(M.composite([],C(r)))},map:e=>t=>{if(typeof t!=`object`||!t)return T(M.leaf([],`expected tagged Map object`,{received:t}));let n=t;if(n._tag!==`Map`)return T(M.leaf([`_tag`],`expected 'Map'`,{received:n._tag}));if(!Array.isArray(n.value))return T(M.leaf([`value`],`expected entries array`,{received:n.value}));let r=[],i=[];return n.value.forEach((t,n)=>{if(!Array.isArray(t)||t.length!==2){r.push(M.leaf([`value`,`[${n}]`],`expected [key, value] tuple`,{received:t}));return}let[a,o]=t;if(typeof a!=`string`){r.push(M.leaf([`value`,`[${n}]`,`[0]`],`expected string key`,{received:a}));return}e(o).fold(e=>{r.push(M.prepend(`value`,M.prepend(`[${n}]`,M.prepend(`[1]`,e))))},e=>{i.push([a,e])})}),r.length===0?w(ft(i)):r.length===1?T(r[0]):T(M.composite([],C(r)))},obj:e=>t=>{if(typeof t!=`object`||!t)return T(M.leaf([],`expected tagged Obj object`,{received:t}));let n=t;if(n._tag!==`Obj`)return T(M.leaf([`_tag`],`expected 'Obj'`,{received:n._tag}));if(typeof n.value!=`object`||n.value===null)return T(M.leaf([`value`],`expected object`,{received:n.value}));let r=n.value,i=[],a={};for(let t in e)e[t](r[t]).fold(e=>{i.push(M.prepend(`value`,M.prepend(t,e)))},e=>{a[t]=e});return i.length===0?w(a):i.length===1?T(i[0]):T(M.composite([],C(i)))}},zt=r({_tag:`Decoder`},{...Ft,tagged:Rt});function Bt(e){if(!e||typeof e!=`object`||!(`_tag`in e))return`unknown`;switch(e._tag){case`Some`:case`None`:return`Option`;case`Left`:case`Right`:return`Either`;case`List`:return`List`;case`Success`:case`Failure`:return`Try`;default:return`unknown`}}const Vt={Option:{of:e=>m(e),empty:()=>m.none()},Either:{of:e=>w(e),empty:e=>T(e)},List:{of:e=>C([e]),empty:()=>C([])},Try:{of:e=>x(()=>e),empty:e=>x(()=>{throw e??/* @__PURE__ */ Error(`Try failed`)})}};function Ht(e){let t=e(),n=null,r;function i(a){let o=t.next(a);if(o.done)return r?r.of(o.value):C([o.value]);let s=o.value;if(typeof s!=`object`||!s)throw Error(`Do-notation error: All yielded values must be monadic. Use yield* $(Option(value)), yield* $(Right(value)), etc. Raw values should be assigned directly without yielding.`);if(!n&&`_tag`in s&&(n=Bt(s),n!==`unknown`&&n in Vt&&(r=Vt[n]),n===`List`))return Ut(e);if(`doUnwrap`in s){let e=s.doUnwrap();if(!e.ok){if(!r)return C([]);if(!e.empty&&`error`in e){if(n===`Either`)return r.empty(e.error);if(n===`Try`)return r.empty(e.error instanceof Error?e.error:Error(String(e.error)))}return r.empty()}return i(e.value)}throw Error(`Do-notation error: All yielded values must be monadic. Use yield* $(Option(value)), yield* $(Right(value)), etc. Raw values should be assigned directly without yielding.`)}return i()}function Ut(e){function t(e){if(typeof e!=`object`||!e||!(`doUnwrap`in e))return[e];let t=e;if(`toArray`in t){let e=t.toArray();return e.length===0?[]:e}let n=t.doUnwrap();return n.ok?[n.value]:[]}function n(r){let i=e(),a=[],o=[],s=0;function c(e){let l=i.next(e);if(l.done){a.push(l.value);return}if(s<r.length){let e=r[s];o.push(e),s++,c(e);return}let u=t(l.value);if(u.length!==0){if(u.length>1){let e=u.flatMap(e=>n([...o,e]));a.push(...e)}else o.push(u[0]),s++,c(u[0])}}return c(void 0),a}let r=n([]);return C(r)}async function Wt(e){let t=e(),n=null,r;async function i(e){let a=await t.next(e);if(a.done)return r?r.of(a.value):C([a.value]);let o=await Promise.resolve(a.value);if(typeof o!=`object`||!o)return i(o);if(!n&&`_tag`in o&&(n=Bt(o),n!==`unknown`&&n in Vt&&(r=Vt[n])),`doUnwrap`in o){let e=o.doUnwrap();if(!e.ok){if(!r)return C([]);if(!e.empty&&`error`in e){if(n===`Either`)return r.empty(e.error);if(n===`Try`)return r.empty(e.error instanceof Error?e.error:Error(String(e.error)))}return r.empty()}return i(e.value)}return i(o)}return i()}function Gt(e){return typeof e==`object`&&!!e&&`doUnwrap`in e&&typeof e.doUnwrap==`function`}function Kt(e){let t=e.doUnwrap();if(t.ok)return t.value;throw`error`in t?t.error:Error(`Cannot unwrap empty monad`)}function*qt(e){return yield e}const Jt=(e=`Cannot unwrap None in Do-notation`)=>{let t=Error(e),n=Object.create(Error.prototype);return n.message=t.message,n.stack=t.stack,n.name=`NoneError`,n},Yt=(e,t=`Cannot unwrap Left in Do-notation`)=>{let n=Error(t),r=Object.create(Error.prototype);return r.message=n.message,r.stack=n.stack,r.name=`LeftError`,r.value=e,r},Xt=(e=`Cannot unwrap empty List in Do-notation`)=>{let t=Error(e),n=Object.create(Error.prototype);return n.message=t.message,n.stack=t.stack,n.name=`EmptyListError`,n},Zt=(e,t=`Cannot unwrap Failure in Do-notation`)=>{let n=Error(t),r=Object.create(Error.prototype);return r.message=n.message,r.stack=n.stack,r.name=`FailureError`,r.cause=e,r},Qt={includeTasks:!0,includeStackTrace:!1,separator:`
|
|
12
|
+
`,includeData:!1,maxStackFrames:3,title:`Error`,colors:!1};function $t(e){let t=/* @__PURE__ */ new WeakSet;return JSON.stringify(e,(e,n)=>{if(typeof n==`bigint`)return`${n.toString()}n`;if(typeof n==`object`&&n){if(t.has(n))return`[Circular Reference]`;t.add(n)}return e===`stack`&&typeof n==`string`?en(n):n},2)}function en(e){if(e===void 0||e===``)return``;let t=e.split(`
|
|
13
13
|
`);return[t[0],...t.slice(1).map(e=>e.trim())].join(`
|
|
14
|
-
`)}function
|
|
15
|
-
`).slice(1),i=n.maxStackFrames??
|
|
16
|
-
`);o+=`\n${a}`,t.length>i&&(o+=`\n${r} ${n.colors?`\x1B[90m`:``}...${t.length-i} more stack frames${n.colors?`\x1B[0m`:``}`)}return o}).join(n.separator)}`;if(n.includeData){let{data:e}=r;if(e){let t=n.colors?`\n\n\x1b[33mContext:\x1b[0m\n${Qt(e)}`:`\n\nContext:\n${Qt(e)}`;a+=t}}return a}function tn(){return function(e){if(!e)return e;let t=e instanceof Error?e:Error(String(e)),n={message:t.message,name:t.name||`Error`,stack:t.stack?$t(t.stack):void 0};if(t.taskInfo&&(n.taskInfo=t.taskInfo),t.data&&(n.data=t.data),typeof A?.getErrorChain==`function`)try{let e=A.getErrorChain(t);e.length>1&&(n.errorChain=A.formatErrorChain(t,{includeTasks:!0}),n.structuredErrorChain=e.map(e=>({message:e.message,name:e.name,taskInfo:e.taskInfo,stack:e.stack?$t(e.stack):void 0})))}catch{}return Object.getOwnPropertyNames(t).forEach(e=>{if(!n[e]){let r=t[e];n[e]=r}}),n}}const N=(e,t,r,i)=>{let a=tt.apply(t,r,{name:e,description:t});return n(a,{code:e,message:t,status:nn(e),context:r,timestamp:(/* @__PURE__ */ new Date()).toISOString(),traceId:i?.traceId})},nn=e=>({VALIDATION_FAILED:400,BAD_REQUEST:400,AUTH_REQUIRED:401,PERMISSION_DENIED:403,NOT_FOUND:404,TIMEOUT:408,CONFLICT:409,RATE_LIMITED:429,INTERNAL_ERROR:500,NETWORK_ERROR:503})[e],P=Object.assign(N,{validation:(e,t,n)=>N(`VALIDATION_FAILED`,`Validation failed: ${e} ${n}`,{field:e,value:t,rule:n}),network:(e,t,n)=>N(`NETWORK_ERROR`,`Network error: ${t} ${e}${n?` (${n})`:``}`,{url:e,method:t,statusCode:n}),auth:(e,t)=>N(`AUTH_REQUIRED`,`Authentication required: ${e}${t?` (role: ${t})`:``}`,{resource:e,requiredRole:t}),notFound:(e,t)=>N(`NOT_FOUND`,`Not found: ${e} with id ${t}`,{resource:e,id:t}),permission:(e,t,n)=>N(`PERMISSION_DENIED`,`Permission denied: cannot ${e} ${t}`,{action:e,resource:t,userId:n}),rateLimit:(e,t,n)=>N(`RATE_LIMITED`,`Rate limit exceeded: ${e} requests per ${t}`,{limit:e,window:t,retryAfter:n}),internal:e=>N(`INTERNAL_ERROR`,`Internal server error: ${e}`,{errorId:e,timestamp:(/* @__PURE__ */ new Date()).toISOString()}),badRequest:(e,t)=>N(`BAD_REQUEST`,`Bad request: ${e}`,{reason:e,expected:t}),conflict:(e,t)=>N(`CONFLICT`,`Conflict: ${e} already exists with value ${t}`,{resource:e,conflictingValue:t}),timeout:(e,t)=>N(`TIMEOUT`,`Request timeout: ${t} exceeded ${e}ms`,{duration:e,operation:t}),isTypedError:e=>typeof e==`object`&&!!e&&`code`in e&&`message`in e&&`status`in e&&`context`in e&&`_tag`in e&&e._tag===`Throwable`,hasCode:(e,t)=>e.code===t}),F={rule:e=>t=>{if(e===`email`)return typeof t!=`string`||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)?T(P.validation(`value`,t,`must be a valid email`)):w(t);if(e===`url`)try{return new URL(String(t)),w(t)}catch{return T(P.validation(`value`,t,`must be a valid URL`))}if(e===`uuid`)return typeof t!=`string`||!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)?T(P.validation(`value`,t,`must be a valid UUID`)):w(t);if(e===`required`)return t==null||t===``?T(P.validation(`value`,t,`is required`)):w(t);if(e===`numeric`)return typeof t!=`number`&&!/^\d+$/.test(String(t))?T(P.validation(`value`,t,`must be numeric`)):w(t);if(e===`alpha`)return typeof t!=`string`||!/^[a-zA-Z]+$/.test(t)?T(P.validation(`value`,t,`must contain only letters`)):w(t);if(e===`alphanumeric`)return typeof t!=`string`||!/^[a-zA-Z0-9]+$/.test(t)?T(P.validation(`value`,t,`must be alphanumeric`)):w(t);if(e.startsWith(`min:`)){let n=Number(e.split(`:`)[1]),r=Number(t);return isNaN(r)||r<n?T(P.validation(`value`,t,`must be at least ${n}`)):w(t)}if(e.startsWith(`max:`)){let n=Number(e.split(`:`)[1]),r=Number(t);return isNaN(r)||r>n?T(P.validation(`value`,t,`must be at most ${n}`)):w(t)}if(e.startsWith(`minLength:`)){let n=Number(e.split(`:`)[1]);return String(t).length<n?T(P.validation(`value`,t,`must be at least ${n} characters`)):w(t)}if(e.startsWith(`maxLength:`)){let n=Number(e.split(`:`)[1]);return String(t).length>n?T(P.validation(`value`,t,`must be at most ${n} characters`)):w(t)}if(e.startsWith(`pattern:`)){let n=e.substring(8);return new RegExp(n).test(String(t))?w(t):T(P.validation(`value`,t,`must match pattern ${n}`))}if(e.startsWith(`in:`)){let n=e.substring(3).split(`,`);return n.includes(String(t))?w(t):T(P.validation(`value`,t,`must be one of: ${n.join(`, `)}`))}if(e.startsWith(`notIn:`)){let n=e.substring(6).split(`,`);return n.includes(String(t))?T(P.validation(`value`,t,`must not be one of: ${n.join(`, `)}`)):w(t)}if(e===`date`){let e=new Date(String(t));return isNaN(e.getTime())?T(P.validation(`value`,t,`must be a valid date`)):w(t)}if(e===`future`){let e=new Date(String(t));return isNaN(e.getTime())||e<=/* @__PURE__ */ new Date?T(P.validation(`value`,t,`must be a future date`)):w(t)}if(e===`past`){let e=new Date(String(t));return isNaN(e.getTime())||e>=/* @__PURE__ */ new Date?T(P.validation(`value`,t,`must be a past date`)):w(t)}return w(t)},combine:(...e)=>t=>{for(let n of e){let e=n(t);if(e.isLeft())return e}return w(t)},custom:(e,t)=>n=>e(n)?w(n):T(P.validation(`value`,n,t)),form:(e,t)=>{let n=[],r={};for(let[i,a]of Object.entries(e)){let e=t[i],o=a(e);if(o.isLeft()){let t=o.fold(e=>e,()=>{throw Error(`Should not be left`)}),r=P.validation(i,e,t.context.rule);n.push(r)}else r[i]=o.orThrow()}return n.length>0?T(C(n)):w(r)}},rn={...F,validators:{email:F.rule(`email`),url:F.rule(`url`),uuid:F.rule(`uuid`),required:F.rule(`required`),numeric:F.rule(`numeric`),positiveNumber:F.combine(F.rule(`numeric`),F.rule(`min:0`)),nonEmptyString:F.combine(F.rule(`required`),F.custom(e=>typeof e==`string`&&e.trim().length>0,`must not be empty`))}},an=n(F.rule,rn);function on(e){return typeof e==`object`&&!!e&&`orThrow`in e&&typeof e.orThrow==`function`}function sn(e){return on(e)&&`orElse`in e&&typeof e.orElse==`function`&&`or`in e&&typeof e.or==`function`&&`orNull`in e&&typeof e.orNull==`function`&&`orUndefined`in e&&typeof e.orUndefined==`function`}const cn=e=>({_tag:`Context`,services:e,get(t){let n=e.get(t.id);return n===void 0?p():d(n)},unsafeGet(t){let n=e.get(t.id);if(n===void 0)throw Error(`Service not found: ${t.id}`);return n},has(t){return e.has(t.id)},add(t,n){let r=new Map(e);return r.set(t.id,n),cn(r)},merge(t){let n=new Map(e);for(let[e,r]of t.services)n.set(e,r);return cn(n)},get size(){return e.size},toString(){return`Context(${Array.from(e.keys()).join(`, `)})`}}),I={empty:()=>cn(/* @__PURE__ */ new Map),make:(e,t)=>{let n=/* @__PURE__ */ new Map;return n.set(e.id,t),cn(n)},isContext:e=>typeof e==`object`&&!!e&&e._tag===`Context`},L=e=>({[Symbol.toStringTag]:`Exit`,_tag:`Success`,value:e,isSuccess(){return!0},isFailure(){return!1},isDie(){return!1},isInterrupted(){return!1},map(t){return L(t(e))},mapError(t){return L(e)},mapBoth(t,n){return L(n(e))},flatMap(t){return t(e)},fold(t,n,r,i){return n(e)},match(t){return t.Success(e)},orThrow(){return e},orElse(t){return e},toOption(){return d(e)},toEither(){return w(e)},toValue(){return{_tag:`Success`,value:e}},toString(){return`Exit.Success(${u(e)})`},toJSON(){return{_tag:`Success`,value:e}}}),ln=e=>({[Symbol.toStringTag]:`Exit`,_tag:`Failure`,error:e,isSuccess(){return!1},isFailure(){return!0},isDie(){return!1},isInterrupted(){return!1},map(t){return ln(e)},mapError(t){return ln(t(e))},mapBoth(t,n){return ln(t(e))},flatMap(t){return ln(e)},fold(t,n,r,i){return t(e)},match(t){return t.Failure(e)},orThrow(){throw e},orElse(e){return e},toOption(){return p()},toEither(){return T(e)},toValue(){return{_tag:`Failure`,error:e}},toString(){return`Exit.Failure(${u(e)})`},toJSON(){return{_tag:`Failure`,error:e}}}),un=e=>({[Symbol.toStringTag]:`Exit`,_tag:`Die`,defect:e,isSuccess(){return!1},isFailure(){return!1},isDie(){return!0},isInterrupted(){return!1},map(t){return un(e)},mapError(t){return un(e)},mapBoth(t,n){return un(e)},flatMap(t){return un(e)},fold(t,n,r,i){return i?i(e):t(e)},match(t){return t.Die?t.Die(e):t.Failure(e)},orThrow(){throw e},orElse(e){return e},toOption(){return p()},toEither(){return T(e)},toValue(){return{_tag:`Die`,defect:e}},toString(){return`Exit.Die(${u(e)})`},toJSON(){return{_tag:`Die`,defect:e}}}),dn=e=>({[Symbol.toStringTag]:`Exit`,_tag:`Interrupted`,fiberId:e,isSuccess(){return!1},isFailure(){return!1},isDie(){return!1},isInterrupted(){return!0},map(t){return dn(e)},mapError(t){return dn(e)},mapBoth(t,n){return dn(e)},flatMap(t){return dn(e)},fold(t,n,r,i){if(r)return r(e);throw Error(`Effect was interrupted: ${e}`)},match(t){return t.Interrupted(e)},orThrow(){throw Error(`Effect was interrupted: ${e}`)},orElse(e){return e},toOption(){return p()},toEither(){throw Error(`Cannot convert Interrupted Exit to Either: ${e}`)},toValue(){return{_tag:`Interrupted`,fiberId:e}},toString(){return`Exit.Interrupted(${e})`},toJSON(){return{_tag:`Interrupted`,fiberId:e}}}),R=r(e=>L(e),{succeed:e=>L(e),fail:e=>ln(e),die:e=>un(e),interrupt:e=>dn(e),interrupted:()=>dn(`interrupted`),isSuccess:e=>e.isSuccess(),isFailure:e=>e.isFailure(),isDie:e=>e.isDie(),isInterrupted:e=>e.isInterrupted(),fromEither:e=>e.isRight()?L(e.value):ln(e.value),fromOption:(e,t)=>e.isSome()?L(e.value):ln(t()),zip:(e,t)=>e.isInterrupted()?e:t.isInterrupted()?t:e.isDie()?e:t.isDie()?t:e.isFailure()?e:t.isFailure()?t:L([e.orThrow(),t.orThrow()]),all:e=>{let t=[];for(let n of e){if(n.isInterrupted()||n.isDie()||n.isFailure())return n;t.push(n.orThrow())}return L(t)}}),fn=e=>{let t=e.filter(e=>e!==void 0),[n]=t;if(n!==void 0&&t.length===1)return{signal:n,dispose:()=>{}};let r=new AbortController,i=t.find(e=>e.aborted);if(i)return r.abort(i.reason),{signal:r.signal,dispose:()=>{}};let a=t.map(e=>{let t=()=>r.abort(e.reason);return e.addEventListener(`abort`,t,{once:!0}),()=>e.removeEventListener(`abort`,t)});return{signal:r.signal,dispose:()=>a.forEach(e=>e())}},z=e=>e;var pn=class extends Error{constructor(e,t){super(t??`Effect timed out after ${e}ms`),this.duration=e,this._tag=`TimeoutError`,this.name=`TimeoutError`}},mn=class extends Error{constructor(e){super(e??`Effect was interrupted`),this._tag=`InterruptedError`,this.name=`InterruptedError`}static is(e){return typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`InterruptedError`}},hn=class extends Error{constructor(e){super(`Cannot run ${e} effect synchronously — use run()/runExit() instead`),this.operation=e,this._tag=`UnsupportedSyncOperationError`,this.name=`UnsupportedSyncOperationError`}},gn=class extends Error{constructor(e,t,n){super(n??`Repeat exhausted after ${e} iterations`),this.max=e,this.lastValue=t,this._tag=`RepeatExhausted`,this.name=`RepeatExhausted`}static is(e){return typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`RepeatExhausted`}};const _n=Symbol.for(`functype/IO/effect`),B=e=>e[_n],V=e=>{let t={[Symbol.toStringTag]:`IO`,[_n]:e,map(e){return V(z({_tag:`Map`,effect:t,f:e}))},flatMap(e){return V(z({_tag:`FlatMap`,effect:t,f:e}))},tap(e){return t.map(t=>(e(t),t))},tapEffect(e){return t.flatMap(t=>e(t).map(()=>t))},mapError(e){return V(z({_tag:`MapError`,effect:t,f:e}))},tapError(e){return t.mapError(t=>(e(t),t))},recover(e){return V(z({_tag:`Recover`,effect:t,fallback:e}))},recoverWith(e){return V(z({_tag:`RecoverWith`,effect:t,f:e}))},fold(e,n){return V(z({_tag:`Fold`,effect:t,onFailure:e,onSuccess:n}))},match(e){return t.fold(e.failure,e.success)},catchTag(e,n){return V(z({_tag:`RecoverWith`,effect:t,f:t=>typeof t==`object`&&t&&`_tag`in t&&t._tag===e?z(n(t)):z(W.fail(t))}))},catchAll(e){return t.recoverWith(e)},retry(e){return e<=0?t:t.recoverWith(()=>t.retry(e-1))},retryWithDelay(e,n){return e<=0?t:t.recoverWith(()=>W.sleep(n).flatMap(()=>t.retryWithDelay(e-1,n)))},retryWhile(e){let n=(r,i)=>t.recoverWith(t=>{if(r<=0||!e.while(t,i))return z(W.fail(t));let a=n(r-1,i+1);return e.delayMs===void 0?a:z(W.sleep(e.delayMs).flatMap(()=>a))});return n(e.n,1)},retryWithBackoff(e){let n=e.factor??2,r=e.maxMs??3e4,i=e.jitter??!0,a=e.while??(()=>!0),o=(s,c)=>t.recoverWith(t=>{if(s<=0||!a(t,c))return z(W.fail(t));let l=Math.min(r,e.baseMs*n**(c-1)),u=i?l*(.5+Math.random()*.5):l,ee=o(s-1,c+1);return z(W.sleep(u).flatMap(()=>ee))});return o(e.n,1)},repeatUntil(e,n){if(n.max<=0)return z(W.fail(new gn(n.max)));let r=i=>t.flatMap(t=>{if(e(t))return z(W.succeed(t));if(i<=1)return z(W.fail(new gn(n.max,t)));let a=r(i-1);return n.delayMs===void 0?a:z(W.sleep(n.delayMs).flatMap(()=>a))});return r(n.max)},repeatWhile(e,n){return t.repeatUntil(t=>!e(t),n)},zipRight(e){return t.flatMap(()=>e)},zipLeft(e){return t.flatMap(t=>e.map(()=>t))},zip(e){return t.flatMap(t=>e.map(e=>[t,e]))},flatten(){return this.flatMap(e=>e)},provideContext(e){return V(z({_tag:`ProvideContext`,effect:t,context:e}))},provideService(e,n){let r=I.make(e,n);return V(z({_tag:`ProvideContext`,effect:t,context:r}))},provideLayer(e){let n=z(W.async(async()=>{let t=I.empty();return await e.build(z(t))}));return z(n.flatMap(e=>V(z({_tag:`ProvideContext`,effect:t,context:e}))))},async run(){let e=await U(B(this));if(e.isSuccess())return w(e.orThrow());let t=Sn(e);return T(t?t.value:new mn)},async runOrThrow(){let e=await U(B(this));if(e.isSuccess())return e.orThrow();let t=Sn(e);throw t?t.value:new mn},runSync(){try{return w(H(B(this)))}catch(e){return T(e)}},runSyncOrThrow(){return H(B(this))},async runExit(e){let t=e?.signal;if(!t)return U(B(this));let n=await U(B(this),void 0,t);return t.aborted&&n.isFailure()?R.interrupted():n},async runOption(){let e=await U(B(this));return e.isSuccess()?d(e.orThrow()):p()},async runTry(){let e=await U(B(this));if(e.isSuccess())return z(x(()=>e.orThrow()));let t=Sn(e),n=t?t.value:/* @__PURE__ */ Error(`Effect was interrupted`);return z(x(()=>{throw n}))},runCancellable(){let e=new AbortController;return{result:this.interruptOn(e.signal).run(),cancel:()=>e.abort()}},pipe(e){return e(t)},delay(e){return z(W.async(()=>new Promise(t=>setTimeout(t,e))).flatMap(()=>t))},timeout(e){return V(z({_tag:`Timeout`,effect:t,duration:e}))},timeoutTo(e,n){return z(t.timeout(e).recover(z(n)))},interruptOn(e){return V(z({_tag:`InterruptWhen`,effect:t,signal:e}))},toString(){return`IO(${u(e._tag)})`},toJSON(){return{_tag:`IO`,effect:e._tag}},*[Symbol.iterator](){return yield t}};return t},vn=e=>{if(xn(e)||e instanceof hn)throw e},yn=/* @__PURE__ */ new WeakSet,bn=()=>{let e=new mn;return yn.add(e),e},xn=e=>e instanceof mn&&!yn.has(e),Sn=e=>{let t=e.toValue();if(t._tag===`Failure`)return{value:t.error};if(t._tag===`Die`)return{value:t.defect}},H=(e,t=I.empty())=>{switch(e._tag){case`Succeed`:return e.value;case`Fail`:throw e.error;case`Die`:throw e.defect;case`Sync`:return e.thunk();case`Async`:throw Error(`Cannot run async effect synchronously`);case`Auto`:{let t=e.thunk();if(t instanceof Promise)throw Error(`Cannot run async effect synchronously`);return t}case`Map`:{let n=H(B(e.effect),t);return e.f(n)}case`FlatMap`:{let n=H(B(e.effect),t),r=e.f(n);return H(B(r),t)}case`MapError`:try{return H(B(e.effect),t)}catch(t){throw vn(t),e.f(t)}case`Recover`:try{return H(B(e.effect),t)}catch(t){return vn(t),e.fallback}case`RecoverWith`:try{return z(H(B(e.effect),t))}catch(n){vn(n);let r=e.f(n);return H(B(r),t)}case`Fold`:try{let n=H(B(e.effect),t);return e.onSuccess(n)}catch(t){return vn(t),e.onFailure(t)}case`Service`:{let n=t.get(e.tag);if(n.isNone())throw Error(`Service not found: ${e.tag.id}`);return n.orThrow()}case`ProvideContext`:{let n=t.merge(e.context);return H(B(e.effect),n)}case`Interrupt`:throw new mn;case`Bracket`:{let n=H(B(e.acquire),t);try{return H(B(e.use(n)),t)}finally{H(B(e.release(n)),t)}}case`BracketExit`:{let n=H(B(e.acquire),t),r;try{let i=H(B(e.use(n)),t);return r=z(R.succeed(i)),i}catch(e){throw r=xn(e)?z(R.interrupted()):e instanceof hn?z(R.die(e)):z(R.fail(e)),e}finally{H(B(e.release(n,r)),t)}}case`All`:return z(e.effects.map(e=>H(B(e),t)));case`Race`:throw new hn(`race`);case`Timeout`:throw new hn(`timeout`);case`InterruptWhen`:if(e.signal.aborted)throw bn();try{return H(B(e.effect),t)}catch(e){throw xn(e)?bn():e}}},Cn=(e,t)=>{if(t)return e.isDie()?z(e):R.interrupted()},wn=(e,t,n)=>e.isSuccess()||e.isDie()?e:n?R.interrupted():e.isInterrupted()||t.aborted?R.fail(new mn):e,U=async(e,t=I.empty(),n)=>{if(n?.aborted)return R.interrupted();let r=()=>n?.aborted??!1;try{switch(e._tag){case`Succeed`:return z(R.succeed(e.value));case`Fail`:return z(R.fail(e.error));case`Die`:return z(R.die(e.defect));case`Sync`:return z(R.succeed(e.thunk()));case`Async`:try{let t=await e.thunk(n);return z(R.succeed(t))}catch(e){return z(R.fail(e))}case`Auto`:try{let t=e.thunk();return t instanceof Promise?z(R.succeed(await t)):z(R.succeed(t))}catch(e){return z(R.fail(e))}case`Map`:{let i=await U(B(e.effect),t,n);return i.isSuccess()?r()?R.interrupted():z(R.succeed(e.f(i.orThrow()))):z(i)}case`FlatMap`:{let i=await U(B(e.effect),t,n);if(!i.isSuccess())return z(i);if(r())return R.interrupted();let a=e.f(i.orThrow());return U(B(a),t,n)}case`MapError`:{let i=await U(B(e.effect),t,n),a=Sn(i);return a?Cn(i,r())||z(R.fail(e.f(a.value))):z(i)}case`Recover`:{let i=await U(B(e.effect),t,n);return Sn(i)?Cn(i,r())??R.succeed(e.fallback):z(i)}case`RecoverWith`:{let i=await U(B(e.effect),t,n),a=Sn(i);if(!a)return z(i);let o=Cn(i,r());if(o)return o;let s=e.f(a.value);return U(B(s),t,n)}case`Fold`:{let i=await U(B(e.effect),t,n),a=Sn(i);return a?Cn(i,r())??R.succeed(e.onFailure(a.value)):i.isSuccess()?r()?R.interrupted():R.succeed(e.onSuccess(i.orThrow())):i}case`Service`:{let n=t.get(e.tag);return n.isNone()?R.fail(/* @__PURE__ */ Error(`Service not found: ${e.tag.id}`)):R.succeed(n.orThrow())}case`ProvideContext`:{let r=t.merge(e.context);return U(B(e.effect),r,n)}case`Interrupt`:return R.interrupted();case`Bracket`:{let i=await U(B(e.acquire),t);if(!i.isSuccess())return i;let a=i.orThrow();try{return r()?R.interrupted():await U(B(e.use(a)),t,n)}finally{await U(B(e.release(a)),t)}}case`BracketExit`:{let i=await U(B(e.acquire),t);if(!i.isSuccess())return i;let a=i.orThrow(),o=r()?R.interrupted():await U(B(e.use(a)),t,n);return await U(B(e.release(a,o)),t),o}case`Race`:return e.effects.length===0?R.fail(/* @__PURE__ */ Error(`No effects to race`)):await Promise.race(e.effects.map(e=>U(B(e),t,n)));case`Timeout`:{let r,i=new Promise(t=>{r=setTimeout(()=>t(R.fail(new pn(e.duration))),e.duration)}),a=U(B(e.effect),t,n);try{return await Promise.race([a,i])}finally{clearTimeout(r)}}case`InterruptWhen`:{let{signal:i}=e,a=fn([n,i]);try{let n=await U(B(e.effect),t,a.signal);return z(wn(n,i,r()))}finally{a.dispose()}}case`All`:return z(await Tn(e.effects,e.concurrency,t,n))}}catch(e){return R.die(e)}},Tn=(e,t,n,r)=>{if(e.length===0)return Promise.resolve(R.succeed([]));let i=new AbortController,a=fn([r,i.signal]),o=Array(e.length),s={next:0,succeeded:0,settled:!1};return new Promise(r=>{let c=e=>{s.settled=!0,e.isSuccess()||i.abort(),a.dispose(),r(e)},l=()=>{if(s.settled||s.next>=e.length)return;let t=s.next;s.next=t+1,U(B(e[t]),n,a.signal).then(n=>{if(!s.settled){if(!n.isSuccess()){c(z(n));return}o[t]=n.orThrow(),s.succeeded+=1,s.succeeded===e.length?c(R.succeed(o)):l()}})};Array.from({length:ae(t,e.length)}).forEach(l)})},W={sync:e=>V({_tag:`Sync`,thunk:e}),succeed:e=>V({_tag:`Succeed`,value:e}),fail:e=>V({_tag:`Fail`,error:e}),die:e=>V({_tag:`Die`,defect:e}),async:e=>V(z({_tag:`Async`,thunk:e})),tryPromise:e=>V({_tag:`Async`,thunk:e.try}).mapError(e.catch),tryCatch:(e,t)=>W.sync(()=>{try{return e()}catch(e){throw t(e)}}),liftSync:e=>(...t)=>W.sync(()=>e(...t)),liftPromise:e=>(...t)=>W.async(()=>e(...t)),fromEither:e=>z(e.isRight()?W.succeed(e.value):W.fail(e.value)),fromPromiseEither:(e,t)=>{let n=W.async(async()=>e());return(t?n.mapError(t):n.recoverWith(e=>W.die(e))).flatMap(e=>W.fromEither(e))},fromOption:e=>z(e.isSome()?W.succeed(e.value):W.fail(void 0)),fromOptionOrFail:(e,t)=>z(e.isSome()?W.succeed(e.value):W.fail(t())),fromTry:e=>z(e.isSuccess()?W.succeed(e.orThrow()):W.fail(e.error)),fromResult:e=>z(e.error?W.fail(e.error):W.succeed(m(e.data))),tryAsync:(e,t,n)=>n?.aborted?z(W.fail(t(n.reason??new DOMException(`Aborted`,`AbortError`)))):W.async(t=>{if(!n)return e(t);if(!t)return e(n);let r=fn([n,t]);try{return e(r.signal).finally(r.dispose)}catch(e){throw r.dispose(),e}}).mapError(t),asyncResult:(e,t,n)=>{let r=n?.dataKey??`data`,i=n?.errorKey??`error`;return W.tryAsync(t=>e(t),t,n?.signal).flatMap(e=>W.fromResult({data:e[r],error:e[i]}))},service:e=>V({_tag:`Service`,tag:e}),serviceWith:(e,t)=>W.service(e).map(t),serviceWithIO:(e,t)=>W.service(e).flatMap(t),withServices:(e,t)=>{let n=Object.entries(e);if(n.length===0)return z(V({_tag:`Auto`,thunk:()=>t({})}));let r=z(W.succeed({})),i=n.reduce((e,[t,n])=>z(e.flatMap(e=>W.service(n).map(n=>({...e,[t]:n})))),r);return z(i.flatMap(e=>V({_tag:`Auto`,thunk:()=>t(e)})))},all:(e,t)=>{let n=t?.concurrency??1;if(ae(n,1),n!==1&&e.length>1)return V(z({_tag:`All`,effects:e,concurrency:n}));if(e.length===0)return z(W.succeed([]));let r=z(W.succeed([]));return z(e.reduce((e,t)=>e.flatMap(e=>t.map(t=>[...e,t])),r))},firstSuccessOf:e=>e.length===0?z(W.fail(/* @__PURE__ */ Error(`No effects provided`))):e.reduce((e,t)=>e.recoverWith(()=>t)),sleep:e=>z(W.async(()=>new Promise(t=>setTimeout(t,e)))),iterate:(e,t,n,r)=>{let i=r?.max??1e4,a=(e,r)=>n(e)?z(W.succeed(e)):r<=0?z(W.fail(new gn(i,e))):t(e).flatMap(e=>a(e,r-1));return a(e,i)},never:()=>z(W.async(()=>new Promise(()=>{}))),get unit(){return z(V({_tag:`Succeed`,value:void 0}))},fromNullable:e=>z(e==null?W.fail(void 0):W.succeed(e)),interrupt:()=>V({_tag:`Interrupt`}),bracket:(e,t,n)=>V({_tag:`Bracket`,acquire:e,use:t,release:n}),acquireRelease:(e,t,n)=>W.bracket(e,t,n),bracketExit:(e,t,n)=>V({_tag:`BracketExit`,acquire:e,use:t,release:n}),race:e=>V({_tag:`Race`,effects:e}),any:e=>e.length===0?z(W.fail(/* @__PURE__ */ Error(`No effects provided`))):e.reduce((e,t)=>e.recoverWith(()=>t)),forEach:(e,t,n)=>{let r=n?.concurrency??1;if(ae(r,1),r!==1)return W.unit.flatMap(()=>W.all(e.map(t),n));if(e.length===0)return z(W.succeed([]));let i=z(W.succeed([]));return z(e.reduce((e,n)=>e.flatMap(e=>t(n).map(t=>[...e,t])),i))},forEachPar:(e,t)=>W.forEach(e,t),timeout:(e,t)=>V(z({_tag:`Timeout`,effect:e,duration:t})),gen:e=>z(W.sync(()=>{let t=e(),n=e=>{let r=t.next(e);return r.done?z(W.succeed(r.value)):z(r.value.flatMap(e=>n(e)))};return n(void 0)}).flatMap(e=>e)),get Do(){return En(W.succeed({}))}},En=e=>({effect:e,bind(t,n){let r=e.flatMap(e=>n(e).map(n=>({...e,[t]:n})));return En(r)},let(t,n){let r=e.map(e=>({...e,[t]:n(e)}));return En(r)},map(t){return e.map(t)},flatMap(t){return e.flatMap(t)},tap(t){return En(e.tap(t))},tapEffect(t){return En(e.tapEffect(t))},done(){return e}}),G=r(e=>V(z({_tag:`Auto`,thunk:e})),W),K=(e,t)=>({_tag:`Layer`,build:e,provideToAndMerge(t){return K(async n=>{let r=await e(n),i=n.merge(r),a=await t.build(i);return r.merge(a)})},merge(t){return K(async n=>{let[r,i]=await Promise.all([e(n),t.build(n)]);return r.merge(i)})},map(t){return K(async n=>t(await e(n)))},toString(){return`Layer(${t??`anonymous`})`}}),Dn={succeed:(e,t)=>K(()=>Promise.resolve(I.make(e,t)),e.id),effect:(e,t)=>K(async()=>{let n=await t();return I.make(e,n)},e.id),sync:(e,t)=>K(()=>Promise.resolve(I.make(e,t())),e.id),fromService:(e,t,n)=>K(r=>{let i=r.unsafeGet(t);return Promise.resolve(I.make(e,n(i)))},e.id),fromServiceEffect:(e,t,n)=>K(async r=>{let i=await n(r.unsafeGet(t));return I.make(e,i)},e.id),fromContext:e=>K(()=>Promise.resolve(e)),empty:()=>K(()=>Promise.resolve(I.empty()),`empty`),mergeAll:(...e)=>K(async t=>(await Promise.all(e.map(e=>e.build(t)))).reduce((e,t)=>e.merge(t),I.empty()))},On=e=>({id:e,_tag:`Tag`,toString(){return`Tag(${e})`}}),kn=()=>{let e=0,t=[],n=async()=>{for(t.sort((e,t)=>e.time-t.time);t.length>0&&t[0]!==void 0&&t[0].time<=e;){let e=t.shift();e&&(e.resolve(),await Promise.resolve())}};return{get currentTime(){return e},async advance(t){e+=t,await n()},async setTime(t){e=t,await n()},async runAll(){if(t.length>0){let n=t[t.length-1];n&&(e=n.time)}await n()},get pendingCount(){return t.length},sleep(n){return new Promise(r=>{t.push({time:e+n,resolve:r})})}}},An=On(`TestClock`),jn={make:kn,tag:An,test:async e=>e(kn()),get get(){return G.service(An)},advance:e=>G.serviceWithIO(An,t=>G.async(()=>t.advance(e))),setTime:e=>G.serviceWithIO(An,t=>G.async(()=>t.setTime(e))),get runAll(){return G.serviceWithIO(An,e=>G.async(()=>e.runAll()))},context:()=>{let e=kn();return{clock:e,context:I.make(An,e)}}},Mn={make:()=>{let e=kn(),t=I.empty(),n={get context(){return t},get clock(){return e},withService(e,r){return t=t.add(e,r),n},async run(e){return e.provideContext(t).runOrThrow()}};return n},withClock:()=>{let e=kn();return Mn.make().withService(An,e)}},Nn=On(`HttpClient`),Pn={},Fn=r({_tag:`HttpError`},{networkError:(e,t,n)=>({_tag:`NetworkError`,url:e,method:t,cause:n}),httpStatusError:(e,t,n,r,i)=>({_tag:`HttpStatusError`,url:e,method:t,status:n,statusText:r,body:i}),decodeError:(e,t,n,r)=>({_tag:`DecodeError`,url:e,method:t,body:n,cause:r}),isNetworkError:e=>e._tag===`NetworkError`,isHttpStatusError:e=>e._tag===`HttpStatusError`,isDecodeError:e=>e._tag===`DecodeError`,match:(e,t)=>{switch(e._tag){case`NetworkError`:return t.NetworkError(e);case`HttpStatusError`:return t.HttpStatusError(e);case`DecodeError`:return t.DecodeError(e)}}}),In=(e,t)=>!e||t.startsWith(`http://`)||t.startsWith(`https://`)?t:`${e.endsWith(`/`)?e.slice(0,-1):e}${t.startsWith(`/`)?t:`/${t}`}`,Ln=(e,t)=>{let n=new URLSearchParams;for(let e of Object.keys(t)){let r=t[e];if(r!=null){if(Array.isArray(r))for(let t of r)n.append(e,String(t));else n.append(e,String(r))}}let r=n.toString();return r?`${e}${e.includes(`?`)?`&`:`?`}${r}`:e},Rn=(e,t,n)=>{let r=In(e,t);return n?Ln(r,n):r},zn=(e,t)=>e[Symbol.toStringTag]===t,q=(e,t)=>{if(typeof e!=`object`||!e||e instanceof Date||e instanceof RegExp||typeof Buffer<`u`&&e instanceof Buffer)return e;if(zn(e,`Option`)){let n=e;return t===`tagged`?n._tag===`None`?{_tag:`None`,value:null}:{_tag:`Some`,value:q(n.value,t)}:n._tag===`None`?null:q(n.value,t)}if(zn(e,`Either`)){let n=e;if(t===`tagged`)return{_tag:n._tag,value:q(n.value,t)};if(n._tag===`Left`)throw Error(`Cannot serialize a Left in a request body — Either's failure path should not cross the wire as data. Resolve the Left before sending, or omit the field. (Left value: ${JSON.stringify(n.value)})`);return q(n.value,t)}if(zn(e,`Try`)){let n=e;if(t===`tagged`){if(n._tag===`Failure`){let e=n.error??/* @__PURE__ */ Error(`unknown`);return{_tag:`Failure`,error:e.message,stack:e.stack}}return{_tag:`Success`,value:q(n.value,t)}}if(n._tag===`Failure`)throw n.error??/* @__PURE__ */ Error(`Cannot serialize a Try Failure in a request body`);return q(n.value,t)}if(zn(e,`List`)){let n=e.toArray().map(e=>q(e,t));return t===`tagged`?{_tag:`List`,value:n}:n}if(zn(e,`FunctypeMap`)){let n=e.toValue().value;if(t===`tagged`)return{_tag:`Map`,value:n.map(([e,n])=>[e,q(n,t)])};let r={};for(let[e,i]of n){if(typeof e!=`string`)throw Error(`Cannot serialize Map with non-string keys to JSON (key: ${String(e)})`);r[e]=q(i,t)}return r}if(Array.isArray(e))return e.map(e=>q(e,t));let n={};for(let r of Object.keys(e))n[r]=q(e[r],t);return n},Bn=(e,t,n)=>{if(e==null)return{serialized:void 0,contentType:void 0};if(n)return{serialized:JSON.stringify(n(e)),contentType:`application/json`};if(typeof e==`string`)return{serialized:e,contentType:void 0};if(typeof e==`object`||Array.isArray(e)){let n=q(e,t?`primitive`:`tagged`);return{serialized:JSON.stringify(n),contentType:`application/json`}}return{serialized:String(e),contentType:void 0}},Vn=e=>{let t=e.get(`content-type`)??``;return t.includes(`application/json`)?`json`:t.startsWith(`text/`)?`text`:`raw`},Hn=async(e,t,n,r,i,a)=>{let o=t??Vn(e.headers),s,c={};switch(o){case`json`:{let t=await e.text();c.value=t;try{s=JSON.parse(t)}catch(e){throw Fn.decodeError(n,r,t,e)}break}case`text`:s=await e.text(),c.value=s;break;case`blob`:s=await e.blob();break;case`arrayBuffer`:s=await e.arrayBuffer();break;case`raw`:s=e}let l;if(i){let e=i(s);if(e.isLeft()){let t=c.value??(typeof s==`string`?s:JSON.stringify(s));throw Fn.decodeError(n,r,t,e.value)}l=e.value}else if(a)try{l=a(s)}catch(e){let t=c.value??(typeof s==`string`?s:JSON.stringify(s));throw Fn.decodeError(n,r,t,e)}else l=s;return{data:l,status:e.status,statusText:e.statusText,headers:e.headers}},J=(e,t)=>{let n={url:Rn(e.baseUrl,t.url,t.params),method:t.method,headers:{...e.defaultHeaders,...t.headers},body:t.body,signal:t.signal,parseAs:t.parseAs,flatten:t.flatten};return(e.beforeRequest?e.beforeRequest(n):G.succeed(n)).flatMap(n=>{let r=n.flatten??!0,i=(()=>{try{return{ok:!0,value:Bn(n.body,r,t.encode)}}catch(e){return{ok:!1,cause:e}}})();if(!i.ok)return G.fail(Fn.networkError(n.url,n.method,i.cause));let{serialized:a,contentType:o}=i.value,s={...n.headers,...o?{"Content-Type":o}:{}},c=G.tryAsync(r=>(e.fetch??globalThis.fetch)(n.url,{method:n.method,headers:s,body:a,signal:n.signal??r}).then(async e=>{if(!e.ok){let t=await e.text().catch(()=>``);throw Fn.httpStatusError(n.url,n.method,e.status,e.statusText,t)}return Hn(e,n.parseAs,n.url,n.method,t.decode,t.validate)}),e=>typeof e==`object`&&e&&`_tag`in e?e:Fn.networkError(n.url,n.method,e));return e.afterResponse?c.flatMap(t=>e.afterResponse(t).map(e=>e)):c})},Un=e=>J(Pn,e),Wn=r({_tag:`Http`},{request:Un,get:(e,t)=>Un({...t,url:e,method:`GET`}),post:(e,t)=>Un({...t,url:e,method:`POST`}),put:(e,t)=>Un({...t,url:e,method:`PUT`}),patch:(e,t)=>Un({...t,url:e,method:`PATCH`}),delete:(e,t)=>Un({...t,url:e,method:`DELETE`}),head:(e,t)=>Un({...t,url:e,method:`HEAD`,parseAs:`raw`}),options:(e,t)=>Un({...t,url:e,method:`OPTIONS`,parseAs:`raw`}),client:e=>({request:t=>J(e,t),get:(t,n)=>J(e,{...n,url:t,method:`GET`}),post:(t,n)=>J(e,{...n,url:t,method:`POST`}),put:(t,n)=>J(e,{...n,url:t,method:`PUT`}),patch:(t,n)=>J(e,{...n,url:t,method:`PATCH`}),delete:(t,n)=>J(e,{...n,url:t,method:`DELETE`}),head:(t,n)=>J(e,{...n,url:t,method:`HEAD`,parseAs:`raw`}),options:(t,n)=>J(e,{...n,url:t,method:`OPTIONS`,parseAs:`raw`})})}),Gn={toOption:e=>e.fold(()=>p(),e=>d(e)),toList:e=>e.fold(()=>C([]),e=>C([e])),toEither:(e,t)=>e.fold(()=>T(t),e=>w(e)),isEmpty:e=>e.fold(()=>!0,()=>!1),size:e=>e.fold(()=>0,()=>1)},Kn=e=>typeof e==`object`&&!!e&&(e._tag===`Some`||e._tag===`None`),Y=e=>typeof e==`object`&&!!e&&e._tag===`List`,qn=e=>typeof e==`object`&&!!e&&(e._tag===`Left`||e._tag===`Right`),Jn=e=>typeof e==`object`&&!!e&&(e._tag===`Success`||e._tag===`Failure`),X=()=>{let e=(e,t)=>{if(Kn(e)||Y(e)||qn(e)||Jn(e))return e.map(e=>t(e));throw Error(`Unsupported functor type: ${JSON.stringify(e)}`)},t=e=>{if(Kn(e))return e.orThrow();if(Y(e)){let t=e.toArray();if(t.length>0&&Y(t[0])){let e=[];for(let n of t)Y(n)&&e.push(...n.toArray());return C(e)}return e.flatten()}if(qn(e))return e.isRight()?e.fold(()=>null,e=>e):e;if(Jn(e))return e.isSuccess()?e.orThrow():e;throw Error(`Unsupported functor type for flatten: ${JSON.stringify(e)}`)},n=(e,t)=>{if(Kn(e)||Y(e)||qn(e)||Jn(e))return e.flatMap(e=>t(e));throw Error(`Unsupported functor type for flatMap: ${JSON.stringify(e)}`)},r=(e,t)=>{if(Kn(e)&&Kn(t)||Y(e)&&Y(t)||qn(e)&&qn(t)||Jn(e)&&Jn(t))return e.flatMap(e=>t.map(t=>e(t)));throw Error(`Unsupported functor type for ap: ${JSON.stringify(e)}`)},i=e=>{if(Kn(e)){let t=e;if(t.isEmpty)return C([m.none()]);let n=t.orThrow();if(Y(n))return n.map(e=>m(e));throw Error(`Unsupported inner container type for sequence`)}if(Y(e)){let t=e.toArray();if(t.length===0)return m.none();let n=t[0];if(Kn(n)){for(let e of t)if(e.isEmpty)return m.none();let e=t.map(e=>e.orThrow());return m(C(e))}throw Error(`Unsupported inner container type for sequence`)}throw Error(`Unsupported outer container type for sequence: ${JSON.stringify(e)}`)};return{_tag:`HKT`,map:e,flatten:t,flatMap:n,ap:r,sequence:i,traverse:(t,n)=>i(e(t,e=>n(e))),_type:`HKT`}},Yn=X();X.map=(e,t)=>Yn.map(e,t),X.flatten=e=>Yn.flatten(e),X.flatMap=(e,t)=>Yn.flatMap(e,t),X.ap=(e,t)=>Yn.ap(e,t),X.sequence=e=>Yn.sequence(e),X.traverse=(e,t)=>Yn.traverse(e,t),X.isOption=Kn,X.isList=Y,X.isEither=qn,X.isTry=Jn;const Xn=e=>({id:e,isSame:t=>t.id===e}),Zn=r(Xn,{of:e=>Xn(e),pure:e=>Xn(e)}),Qn=e=>{let t=!1,n,r,a=!1,s=()=>{if(!t)try{n=e(),t=!0}catch(e){throw r=e,a=!0,t=!0,e}if(a)throw r;return n};return{[Symbol.toStringTag]:`Lazy`,_tag:`Lazy`,get isEvaluated(){return t},orElse:e=>{try{return s()}catch{return e}},orNull:()=>{try{return s()}catch{return null}},orThrow:e=>{try{return s()}catch(t){throw e??t}},or:e=>Z(()=>{try{return s()}catch{return e.orThrow()}}),orUndefined:()=>{try{return s()}catch{return}},map:e=>Z(()=>e(s())),ap:e=>Z(()=>e.orThrow()(s())),mapAsync:async e=>{let t=await e(s());return Z(()=>t)},flatMap:e=>Z(()=>e(s()).orThrow()),flatMapAsync:async e=>{let t=await e(s());return Z(()=>t.orThrow())},filter:e=>Z(()=>{let t=s();return e(t)?d(t):p}),recover:e=>Z(()=>{try{return s()}catch(t){return e(t)}}),recoverWith:e=>Z(()=>{try{return s()}catch(t){return e(t).orThrow()}}),toOption:()=>{try{return d(s())}catch{return p}},toEither:()=>{try{return w(s())}catch(e){return T(e)}},toEitherWith:e=>{try{return w(s())}catch(t){return T(e(t))}},toTry:()=>x(()=>s()),tap:e=>Z(()=>{let t=s();return e(t),t}),tapError:e=>Z(()=>{try{return s()}catch(t){throw e(t),t}}),fold:e=>e(s()),foldWith:(e,t)=>{try{return t(s())}catch(t){return e(t)}},foldLeft:e=>t=>t(e,s()),foldRight:e=>t=>t(s(),e),match:e=>e.Lazy(s()),toString:()=>t&&!a?`Lazy(${u(n)})`:t&&a?`Lazy(<error: ${r instanceof Error?r.message:String(r)}>)`:`Lazy(<not evaluated>)`,toValue:()=>{try{return{_tag:`Lazy`,value:s()}}catch(e){return{_tag:`Lazy`,error:e instanceof Error?e:Error(String(e))}}},get size(){try{return s(),1}catch{return 0}},get isEmpty(){try{return s(),!1}catch{return!0}},contains:e=>{try{return s()===e}catch{return!1}},reduce:e=>s(),reduceRight:e=>s(),count:e=>{try{return+!!e(s())}catch{return 0}},find:e=>{try{let t=s();return e(t)?d(t):p}catch{return p}},exists:e=>{try{return e(s())}catch{return!1}},forEach:e=>{try{e(s())}catch{}},pipe:e=>e(s()),toJSON:()=>{try{return{"@functype":`Lazy`,_tag:`Lazy`,value:s()}}catch(e){return{"@functype":`Lazy`,_tag:`Lazy`,error:o(e)}}},serialize:()=>{try{return c(`Lazy`,s())}catch(e){return i(`Lazy`,`Lazy`,{error:o(e)})}},typeable:`Lazy`}},$n={of:e=>Qn(e),fromValue:e=>Qn(()=>e),fromOption:(e,t)=>Qn(()=>e._tag===`Some`?e.value:t()),fromTry:e=>Qn(()=>e.orThrow()),fromEither:e=>Qn(()=>e.fold(e=>{throw e},e=>e)),fromPromise:e=>Qn(()=>{throw Error(`Promise not yet resolved. Use await on the promise before creating Lazy.`)}),fail:e=>Qn(()=>{throw e}),evaluated:e=>Qn(()=>e),fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`Lazy`)throw Error(`Lazy.fromJSON: expected @functype="Lazy", got ${JSON.stringify(t[`@functype`])}`);if(t.error!==void 0){let e=typeof t.error==`object`?a(t.error):Error(t.error);return $n.fail(e)}return $n.evaluated(t.value)}},Z=r(Qn,$n),er={default:e=>t=>e(t),when:(e,t)=>n=>e(n)?t(n):void 0},Q=e=>({[Symbol.toStringTag]:`Obj`,_tag:`Obj`,data:e,get:t=>m(e[t]),set:(t,n)=>Q({...e,[t]:n}),assign:t=>Q({...e,...t}),merge:t=>Q({...e,...t}),when:(t,n)=>(typeof t==`function`?t():t)?Q({...e,...n}):Q(e),omit:(...t)=>{let n={...e};for(let e of t)delete n[e];return Q(n)},pick:(...t)=>{let n={};for(let r of t)r in e&&(n[r]=e[r]);return Q(n)},keys:()=>C(Object.keys(e)),values:()=>C(Object.values(e)),entries:()=>C(Object.entries(e).map(([e,t])=>re([e,t]))),has:t=>t in e,value:()=>e,get isEmpty(){return Object.keys(e).length===0},get size(){return Object.keys(e).length},map:t=>Q(t(e)),flatMap:t=>t(e),flatMapAsync:async t=>await t(e),ap:t=>{let n=t.data;return Q(n(e))},fold:(t,n)=>Object.keys(e).length===0?t():n(e),match:t=>t.Obj(e),foldLeft:t=>n=>n(t,e),foldRight:t=>n=>n(e,t),count:t=>+!!t(e),find:t=>t(e)?m(e):m(void 0),exists:t=>t(e),forEach:t=>t(e),reduce:t=>e,reduceRight:t=>e,contains:t=>JSON.stringify(e)===JSON.stringify(t),orElse:t=>e,orThrow:t=>e,or:t=>Q(e),orNull:()=>e,orUndefined:()=>e,toOption:()=>m(e),toEither:t=>w(e),toList:()=>C([e]),toTry:()=>x(()=>e),toPromise:()=>Promise.resolve(e),toString:()=>`Obj(${u(e)})`,toValue:()=>({_tag:`Obj`,value:e}),toJSON:()=>({"@functype":`Obj`,_tag:`Obj`,value:e}),pipe:t=>t(e),serialize:()=>c(`Obj`,e),doUnwrap(){return{ok:!0,value:e}}}),tr=e=>Q(e),nr={of:e=>Q(e),empty:()=>Q({}),fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`Obj`)throw Error(`Obj.fromJSON: expected @functype="Obj", got ${JSON.stringify(t[`@functype`])}`);return Q(t.value)},fromBinary:e=>{let t=s(e);return nr.fromJSON(t)}},rr=r(tr,nr),$=(e=[])=>{let t=[...e],n=()=>t.length,r=()=>t.length===0,i=e=>t.includes(e),a=e=>{if(t.length===0)throw Error(`Cannot reduce an empty stack`);return te(t,e)},o=e=>{if(t.length===0)throw Error(`Cannot reduce an empty stack`);return ne(t,e)},s=e=>$([...t,e]),l=()=>{if(r())return[$([]),m(null)];let e=[...t],n=e.pop();return[$(e),m(n)]},u=()=>r()?m(null):m(t[t.length-1]),ee=e=>$(t.map(e)),re=e=>r()?$([]):t.reduce((t,n)=>e(n).toArray().reduce((e,t)=>e.push(t),t),$([])),ie=e=>{let n=[];return t.forEach(t=>{e.toArray().forEach(e=>{n.push(e(t))})}),$(n)},ae=async e=>r()?$([]):(await Promise.all(t.map(async t=>await e(t)))).reduce((e,t)=>t.toArray().reduce((e,t)=>e.push(t),e),$([])),oe=()=>C(t),d=()=>[...t],f=()=>`Stack(${t.join(`, `)})`,p=(e,n)=>t.reduce(n,e),se=e=>n=>t.reduce(n,e),ce=e=>n=>t.reduceRight((e,t)=>n(t,e),e),h=e=>r()?e.Empty():e.NonEmpty([...t]);return{[Symbol.toStringTag]:`Stack`,_tag:`Stack`,get size(){return n()},get isEmpty(){return r()},contains:i,reduce:a,reduceRight:o,push:s,pop:l,peek:u,map:ee,flatMap:re,ap:ie,flatMapAsync:ae,toList:oe,toArray:d,toString:f,fold:p,foldLeft:se,foldRight:ce,match:h,toValue:()=>({_tag:`Stack`,value:t}),toJSON:()=>({"@functype":`Stack`,_tag:`Stack`,value:[...t]}),pipe:e=>e([...t]),serialize:()=>c(`Stack`,t)}},ir=(e=[])=>$(e),ar={empty:()=>$([]),of:(...e)=>$(e),fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`Stack`)throw Error(`Stack.fromJSON: expected @functype="Stack", got ${JSON.stringify(t[`@functype`])}`);return or(t.value)},fromYAML:e=>{let t=e.split(`
|
|
17
|
-
`)[1]?.split(`: `)[1];if(!t)return
|
|
14
|
+
`)}function tn(e,t){let n={...Qt,...t},r=e instanceof Error?e:nt.apply(e),i=A?.getErrorChain?A.getErrorChain(r):[r],a=`${n.colors?`\x1b[31m${n.title}:\x1b[0m ${r.message}`:`${n.title}: ${r.message}`}\n\n${i.map((e,t)=>{let r=` `.repeat(t),i=t>0?`↳ `:``,{taskInfo:a}=e,o=`${r}${i}${n.includeTasks&&a?.name?n.colors?`\x1b[36m[${a.name}]\x1b[0m `:`[${a.name}] `:``}${e.message}`;if(n.includeStackTrace&&e.stack){let t=en(e.stack).split(`
|
|
15
|
+
`).slice(1),i=n.maxStackFrames??Qt.maxStackFrames??3,a=t.slice(0,i).map(e=>`${r} ${n.colors?`\x1B[90m`:``}${e}${n.colors?`\x1B[0m`:``}`).join(`
|
|
16
|
+
`);o+=`\n${a}`,t.length>i&&(o+=`\n${r} ${n.colors?`\x1B[90m`:``}...${t.length-i} more stack frames${n.colors?`\x1B[0m`:``}`)}return o}).join(n.separator)}`;if(n.includeData){let{data:e}=r;if(e){let t=n.colors?`\n\n\x1b[33mContext:\x1b[0m\n${$t(e)}`:`\n\nContext:\n${$t(e)}`;a+=t}}return a}function nn(){return function(e){if(!e)return e;let t=e instanceof Error?e:Error(String(e)),n={message:t.message,name:t.name||`Error`,stack:t.stack?en(t.stack):void 0};if(t.taskInfo&&(n.taskInfo=t.taskInfo),t.data&&(n.data=t.data),typeof A?.getErrorChain==`function`)try{let e=A.getErrorChain(t);e.length>1&&(n.errorChain=A.formatErrorChain(t,{includeTasks:!0}),n.structuredErrorChain=e.map(e=>({message:e.message,name:e.name,taskInfo:e.taskInfo,stack:e.stack?en(e.stack):void 0})))}catch{}return Object.getOwnPropertyNames(t).forEach(e=>{if(!n[e]){let r=t[e];n[e]=r}}),n}}const N=(e,t,r,i)=>{let a=nt.apply(t,r,{name:e,description:t});return n(a,{code:e,message:t,status:rn(e),context:r,timestamp:(/* @__PURE__ */ new Date()).toISOString(),traceId:i?.traceId})},rn=e=>({VALIDATION_FAILED:400,BAD_REQUEST:400,AUTH_REQUIRED:401,PERMISSION_DENIED:403,NOT_FOUND:404,TIMEOUT:408,CONFLICT:409,RATE_LIMITED:429,INTERNAL_ERROR:500,NETWORK_ERROR:503})[e],P=Object.assign(N,{validation:(e,t,n)=>N(`VALIDATION_FAILED`,`Validation failed: ${e} ${n}`,{field:e,value:t,rule:n}),network:(e,t,n)=>N(`NETWORK_ERROR`,`Network error: ${t} ${e}${n?` (${n})`:``}`,{url:e,method:t,statusCode:n}),auth:(e,t)=>N(`AUTH_REQUIRED`,`Authentication required: ${e}${t?` (role: ${t})`:``}`,{resource:e,requiredRole:t}),notFound:(e,t)=>N(`NOT_FOUND`,`Not found: ${e} with id ${t}`,{resource:e,id:t}),permission:(e,t,n)=>N(`PERMISSION_DENIED`,`Permission denied: cannot ${e} ${t}`,{action:e,resource:t,userId:n}),rateLimit:(e,t,n)=>N(`RATE_LIMITED`,`Rate limit exceeded: ${e} requests per ${t}`,{limit:e,window:t,retryAfter:n}),internal:e=>N(`INTERNAL_ERROR`,`Internal server error: ${e}`,{errorId:e,timestamp:(/* @__PURE__ */ new Date()).toISOString()}),badRequest:(e,t)=>N(`BAD_REQUEST`,`Bad request: ${e}`,{reason:e,expected:t}),conflict:(e,t)=>N(`CONFLICT`,`Conflict: ${e} already exists with value ${t}`,{resource:e,conflictingValue:t}),timeout:(e,t)=>N(`TIMEOUT`,`Request timeout: ${t} exceeded ${e}ms`,{duration:e,operation:t}),isTypedError:e=>typeof e==`object`&&!!e&&`code`in e&&`message`in e&&`status`in e&&`context`in e&&`_tag`in e&&e._tag===`Throwable`,hasCode:(e,t)=>e.code===t}),F={rule:e=>t=>{if(e===`email`)return typeof t!=`string`||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)?T(P.validation(`value`,t,`must be a valid email`)):w(t);if(e===`url`)try{return new URL(String(t)),w(t)}catch{return T(P.validation(`value`,t,`must be a valid URL`))}if(e===`uuid`)return typeof t!=`string`||!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)?T(P.validation(`value`,t,`must be a valid UUID`)):w(t);if(e===`required`)return t==null||t===``?T(P.validation(`value`,t,`is required`)):w(t);if(e===`numeric`)return typeof t!=`number`&&!/^\d+$/.test(String(t))?T(P.validation(`value`,t,`must be numeric`)):w(t);if(e===`alpha`)return typeof t!=`string`||!/^[a-zA-Z]+$/.test(t)?T(P.validation(`value`,t,`must contain only letters`)):w(t);if(e===`alphanumeric`)return typeof t!=`string`||!/^[a-zA-Z0-9]+$/.test(t)?T(P.validation(`value`,t,`must be alphanumeric`)):w(t);if(e.startsWith(`min:`)){let n=Number(e.split(`:`)[1]),r=Number(t);return isNaN(r)||r<n?T(P.validation(`value`,t,`must be at least ${n}`)):w(t)}if(e.startsWith(`max:`)){let n=Number(e.split(`:`)[1]),r=Number(t);return isNaN(r)||r>n?T(P.validation(`value`,t,`must be at most ${n}`)):w(t)}if(e.startsWith(`minLength:`)){let n=Number(e.split(`:`)[1]);return String(t).length<n?T(P.validation(`value`,t,`must be at least ${n} characters`)):w(t)}if(e.startsWith(`maxLength:`)){let n=Number(e.split(`:`)[1]);return String(t).length>n?T(P.validation(`value`,t,`must be at most ${n} characters`)):w(t)}if(e.startsWith(`pattern:`)){let n=e.substring(8);return new RegExp(n).test(String(t))?w(t):T(P.validation(`value`,t,`must match pattern ${n}`))}if(e.startsWith(`in:`)){let n=e.substring(3).split(`,`);return n.includes(String(t))?w(t):T(P.validation(`value`,t,`must be one of: ${n.join(`, `)}`))}if(e.startsWith(`notIn:`)){let n=e.substring(6).split(`,`);return n.includes(String(t))?T(P.validation(`value`,t,`must not be one of: ${n.join(`, `)}`)):w(t)}if(e===`date`){let e=new Date(String(t));return isNaN(e.getTime())?T(P.validation(`value`,t,`must be a valid date`)):w(t)}if(e===`future`){let e=new Date(String(t));return isNaN(e.getTime())||e<=/* @__PURE__ */ new Date?T(P.validation(`value`,t,`must be a future date`)):w(t)}if(e===`past`){let e=new Date(String(t));return isNaN(e.getTime())||e>=/* @__PURE__ */ new Date?T(P.validation(`value`,t,`must be a past date`)):w(t)}return w(t)},combine:(...e)=>t=>{for(let n of e){let e=n(t);if(e.isLeft())return e}return w(t)},custom:(e,t)=>n=>e(n)?w(n):T(P.validation(`value`,n,t)),form:(e,t)=>{let n=[],r={};for(let[i,a]of Object.entries(e)){let e=t[i],o=a(e);if(o.isLeft()){let t=o.fold(e=>e,()=>{throw Error(`Should not be left`)}),r=P.validation(i,e,t.context.rule);n.push(r)}else r[i]=o.orThrow()}return n.length>0?T(C(n)):w(r)}},an={...F,validators:{email:F.rule(`email`),url:F.rule(`url`),uuid:F.rule(`uuid`),required:F.rule(`required`),numeric:F.rule(`numeric`),positiveNumber:F.combine(F.rule(`numeric`),F.rule(`min:0`)),nonEmptyString:F.combine(F.rule(`required`),F.custom(e=>typeof e==`string`&&e.trim().length>0,`must not be empty`))}},on=n(F.rule,an);function sn(e){return typeof e==`object`&&!!e&&`orThrow`in e&&typeof e.orThrow==`function`}function cn(e){return sn(e)&&`orElse`in e&&typeof e.orElse==`function`&&`or`in e&&typeof e.or==`function`&&`orNull`in e&&typeof e.orNull==`function`&&`orUndefined`in e&&typeof e.orUndefined==`function`}const ln=e=>({_tag:`Context`,services:e,get(t){let n=e.get(t.id);return n===void 0?p():d(n)},unsafeGet(t){let n=e.get(t.id);if(n===void 0)throw Error(`Service not found: ${t.id}`);return n},has(t){return e.has(t.id)},add(t,n){let r=new Map(e);return r.set(t.id,n),ln(r)},merge(t){let n=new Map(e);for(let[e,r]of t.services)n.set(e,r);return ln(n)},get size(){return e.size},toString(){return`Context(${Array.from(e.keys()).join(`, `)})`}}),I={empty:()=>ln(/* @__PURE__ */ new Map),make:(e,t)=>{let n=/* @__PURE__ */ new Map;return n.set(e.id,t),ln(n)},isContext:e=>typeof e==`object`&&!!e&&e._tag===`Context`},L=e=>({[Symbol.toStringTag]:`Exit`,_tag:`Success`,value:e,isSuccess(){return!0},isFailure(){return!1},isDie(){return!1},isInterrupted(){return!1},map(t){return L(t(e))},mapError(t){return L(e)},mapBoth(t,n){return L(n(e))},flatMap(t){return t(e)},fold(t,n,r,i){return n(e)},match(t){return t.Success(e)},orThrow(){return e},orElse(t){return e},toOption(){return d(e)},toEither(){return w(e)},toValue(){return{_tag:`Success`,value:e}},toString(){return`Exit.Success(${u(e)})`},toJSON(){return{_tag:`Success`,value:e}}}),un=e=>({[Symbol.toStringTag]:`Exit`,_tag:`Failure`,error:e,isSuccess(){return!1},isFailure(){return!0},isDie(){return!1},isInterrupted(){return!1},map(t){return un(e)},mapError(t){return un(t(e))},mapBoth(t,n){return un(t(e))},flatMap(t){return un(e)},fold(t,n,r,i){return t(e)},match(t){return t.Failure(e)},orThrow(){throw e},orElse(e){return e},toOption(){return p()},toEither(){return T(e)},toValue(){return{_tag:`Failure`,error:e}},toString(){return`Exit.Failure(${u(e)})`},toJSON(){return{_tag:`Failure`,error:e}}}),dn=e=>({[Symbol.toStringTag]:`Exit`,_tag:`Die`,defect:e,isSuccess(){return!1},isFailure(){return!1},isDie(){return!0},isInterrupted(){return!1},map(t){return dn(e)},mapError(t){return dn(e)},mapBoth(t,n){return dn(e)},flatMap(t){return dn(e)},fold(t,n,r,i){return i?i(e):t(e)},match(t){return t.Die?t.Die(e):t.Failure(e)},orThrow(){throw e},orElse(e){return e},toOption(){return p()},toEither(){return T(e)},toValue(){return{_tag:`Die`,defect:e}},toString(){return`Exit.Die(${u(e)})`},toJSON(){return{_tag:`Die`,defect:e}}}),fn=e=>({[Symbol.toStringTag]:`Exit`,_tag:`Interrupted`,fiberId:e,isSuccess(){return!1},isFailure(){return!1},isDie(){return!1},isInterrupted(){return!0},map(t){return fn(e)},mapError(t){return fn(e)},mapBoth(t,n){return fn(e)},flatMap(t){return fn(e)},fold(t,n,r,i){if(r)return r(e);throw Error(`Effect was interrupted: ${e}`)},match(t){return t.Interrupted(e)},orThrow(){throw Error(`Effect was interrupted: ${e}`)},orElse(e){return e},toOption(){return p()},toEither(){throw Error(`Cannot convert Interrupted Exit to Either: ${e}`)},toValue(){return{_tag:`Interrupted`,fiberId:e}},toString(){return`Exit.Interrupted(${e})`},toJSON(){return{_tag:`Interrupted`,fiberId:e}}}),R=r(e=>L(e),{succeed:e=>L(e),fail:e=>un(e),die:e=>dn(e),interrupt:e=>fn(e),interrupted:()=>fn(`interrupted`),isSuccess:e=>e.isSuccess(),isFailure:e=>e.isFailure(),isDie:e=>e.isDie(),isInterrupted:e=>e.isInterrupted(),fromEither:e=>e.isRight()?L(e.value):un(e.value),fromOption:(e,t)=>e.isSome()?L(e.value):un(t()),zip:(e,t)=>e.isInterrupted()?e:t.isInterrupted()?t:e.isDie()?e:t.isDie()?t:e.isFailure()?e:t.isFailure()?t:L([e.orThrow(),t.orThrow()]),all:e=>{let t=[];for(let n of e){if(n.isInterrupted()||n.isDie()||n.isFailure())return n;t.push(n.orThrow())}return L(t)}}),pn=e=>{let t=e.filter(e=>e!==void 0),[n]=t;if(n!==void 0&&t.length===1)return{signal:n,dispose:()=>{}};let r=new AbortController,i=t.find(e=>e.aborted);if(i)return r.abort(i.reason),{signal:r.signal,dispose:()=>{}};let a=t.map(e=>{let t=()=>r.abort(e.reason);return e.addEventListener(`abort`,t,{once:!0}),()=>e.removeEventListener(`abort`,t)});return{signal:r.signal,dispose:()=>a.forEach(e=>e())}},z=e=>e;var mn=class extends Error{constructor(e,t){super(t??`Effect timed out after ${e}ms`),this.duration=e,this._tag=`TimeoutError`,this.name=`TimeoutError`}},hn=class extends Error{constructor(e){super(e??`Effect was interrupted`),this._tag=`InterruptedError`,this.name=`InterruptedError`}static is(e){return typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`InterruptedError`}},gn=class extends Error{constructor(e){super(`Cannot run ${e} effect synchronously — use run()/runExit() instead`),this.operation=e,this._tag=`UnsupportedSyncOperationError`,this.name=`UnsupportedSyncOperationError`}},_n=class extends Error{constructor(e,t,n){super(n??`Repeat exhausted after ${e} iterations`),this.max=e,this.lastValue=t,this._tag=`RepeatExhausted`,this.name=`RepeatExhausted`}static is(e){return typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`RepeatExhausted`}};const vn=Symbol.for(`functype/IO/effect`),B=e=>e[vn],V=e=>{let t={[Symbol.toStringTag]:`IO`,[vn]:e,map(e){return V(z({_tag:`Map`,effect:t,f:e}))},flatMap(e){return V(z({_tag:`FlatMap`,effect:t,f:e}))},tap(e){return t.map(t=>(e(t),t))},tapEffect(e){return t.flatMap(t=>e(t).map(()=>t))},mapError(e){return V(z({_tag:`MapError`,effect:t,f:e}))},tapError(e){return t.mapError(t=>(e(t),t))},recover(e){return V(z({_tag:`Recover`,effect:t,fallback:e}))},recoverWith(e){return V(z({_tag:`RecoverWith`,effect:t,f:e}))},fold(e,n){return V(z({_tag:`Fold`,effect:t,onFailure:e,onSuccess:n}))},match(e){return t.fold(e.failure,e.success)},catchTag(e,n){return V(z({_tag:`RecoverWith`,effect:t,f:t=>typeof t==`object`&&t&&`_tag`in t&&t._tag===e?z(n(t)):z(W.fail(t))}))},catchAll(e){return t.recoverWith(e)},retry(e){return e<=0?t:t.recoverWith(()=>t.retry(e-1))},retryWithDelay(e,n){return e<=0?t:t.recoverWith(()=>W.sleep(n).flatMap(()=>t.retryWithDelay(e-1,n)))},retryWhile(e){let n=(r,i)=>t.recoverWith(t=>{if(r<=0||!e.while(t,i))return z(W.fail(t));let a=n(r-1,i+1);return e.delayMs===void 0?a:z(W.sleep(e.delayMs).flatMap(()=>a))});return n(e.n,1)},retryWithBackoff(e){let n=e.factor??2,r=e.maxMs??3e4,i=e.jitter??!0,a=e.while??(()=>!0),o=(s,c)=>t.recoverWith(t=>{if(s<=0||!a(t,c))return z(W.fail(t));let l=Math.min(r,e.baseMs*n**(c-1)),u=i?l*(.5+Math.random()*.5):l,ee=o(s-1,c+1);return z(W.sleep(u).flatMap(()=>ee))});return o(e.n,1)},repeatUntil(e,n){if(n.max<=0)return z(W.fail(new _n(n.max)));let r=i=>t.flatMap(t=>{if(e(t))return z(W.succeed(t));if(i<=1)return z(W.fail(new _n(n.max,t)));let a=r(i-1);return n.delayMs===void 0?a:z(W.sleep(n.delayMs).flatMap(()=>a))});return r(n.max)},repeatWhile(e,n){return t.repeatUntil(t=>!e(t),n)},zipRight(e){return t.flatMap(()=>e)},zipLeft(e){return t.flatMap(t=>e.map(()=>t))},zip(e){return t.flatMap(t=>e.map(e=>[t,e]))},flatten(){return this.flatMap(e=>e)},provideContext(e){return V(z({_tag:`ProvideContext`,effect:t,context:e}))},provideService(e,n){let r=I.make(e,n);return V(z({_tag:`ProvideContext`,effect:t,context:r}))},provideLayer(e){let n=z(W.async(async()=>{let t=I.empty();return await e.build(z(t))}));return z(n.flatMap(e=>V(z({_tag:`ProvideContext`,effect:t,context:e}))))},async run(){let e=await U(B(this));if(e.isSuccess())return w(e.orThrow());let t=Cn(e);return T(t?t.value:new hn)},async runOrThrow(){let e=await U(B(this));if(e.isSuccess())return e.orThrow();let t=Cn(e);throw t?t.value:new hn},runSync(){try{return w(H(B(this)))}catch(e){return T(e)}},runSyncOrThrow(){return H(B(this))},async runExit(e){let t=e?.signal;if(!t)return U(B(this));let n=await U(B(this),void 0,t);return t.aborted&&n.isFailure()?R.interrupted():n},async runOption(){let e=await U(B(this));return e.isSuccess()?d(e.orThrow()):p()},async runTry(){let e=await U(B(this));if(e.isSuccess())return z(x(()=>e.orThrow()));let t=Cn(e),n=t?t.value:/* @__PURE__ */ Error(`Effect was interrupted`);return z(x(()=>{throw n}))},runCancellable(){let e=new AbortController;return{result:this.interruptOn(e.signal).run(),cancel:()=>e.abort()}},pipe(e){return e(t)},delay(e){return z(W.async(()=>new Promise(t=>setTimeout(t,e))).flatMap(()=>t))},timeout(e){return V(z({_tag:`Timeout`,effect:t,duration:e}))},timeoutTo(e,n){return z(t.timeout(e).recover(z(n)))},interruptOn(e){return V(z({_tag:`InterruptWhen`,effect:t,signal:e}))},toString(){return`IO(${u(e._tag)})`},toJSON(){return{_tag:`IO`,effect:e._tag}},*[Symbol.iterator](){return yield t}};return t},yn=e=>{if(Sn(e)||e instanceof gn)throw e},bn=/* @__PURE__ */ new WeakSet,xn=()=>{let e=new hn;return bn.add(e),e},Sn=e=>e instanceof hn&&!bn.has(e),Cn=e=>{let t=e.toValue();if(t._tag===`Failure`)return{value:t.error};if(t._tag===`Die`)return{value:t.defect}},H=(e,t=I.empty())=>{switch(e._tag){case`Succeed`:return e.value;case`Fail`:throw e.error;case`Die`:throw e.defect;case`Sync`:return e.thunk();case`Async`:throw Error(`Cannot run async effect synchronously`);case`Auto`:{let t=e.thunk();if(t instanceof Promise)throw Error(`Cannot run async effect synchronously`);return t}case`Map`:{let n=H(B(e.effect),t);return e.f(n)}case`FlatMap`:{let n=H(B(e.effect),t),r=e.f(n);return H(B(r),t)}case`MapError`:try{return H(B(e.effect),t)}catch(t){throw yn(t),e.f(t)}case`Recover`:try{return H(B(e.effect),t)}catch(t){return yn(t),e.fallback}case`RecoverWith`:try{return z(H(B(e.effect),t))}catch(n){yn(n);let r=e.f(n);return H(B(r),t)}case`Fold`:try{let n=H(B(e.effect),t);return e.onSuccess(n)}catch(t){return yn(t),e.onFailure(t)}case`Service`:{let n=t.get(e.tag);if(n.isNone())throw Error(`Service not found: ${e.tag.id}`);return n.orThrow()}case`ProvideContext`:{let n=t.merge(e.context);return H(B(e.effect),n)}case`Interrupt`:throw new hn;case`Bracket`:{let n=H(B(e.acquire),t);try{return H(B(e.use(n)),t)}finally{H(B(e.release(n)),t)}}case`BracketExit`:{let n=H(B(e.acquire),t),r;try{let i=H(B(e.use(n)),t);return r=z(R.succeed(i)),i}catch(e){throw r=Sn(e)?z(R.interrupted()):e instanceof gn?z(R.die(e)):z(R.fail(e)),e}finally{H(B(e.release(n,r)),t)}}case`All`:return z(e.effects.map(e=>H(B(e),t)));case`Race`:throw new gn(`race`);case`Timeout`:throw new gn(`timeout`);case`InterruptWhen`:if(e.signal.aborted)throw xn();try{return H(B(e.effect),t)}catch(e){throw Sn(e)?xn():e}}},wn=(e,t)=>{if(t)return e.isDie()?z(e):R.interrupted()},Tn=(e,t,n)=>e.isSuccess()||e.isDie()?e:n?R.interrupted():e.isInterrupted()||t.aborted?R.fail(new hn):e,U=async(e,t=I.empty(),n)=>{if(n?.aborted)return R.interrupted();let r=()=>n?.aborted??!1;try{switch(e._tag){case`Succeed`:return z(R.succeed(e.value));case`Fail`:return z(R.fail(e.error));case`Die`:return z(R.die(e.defect));case`Sync`:return z(R.succeed(e.thunk()));case`Async`:try{let t=await e.thunk(n);return z(R.succeed(t))}catch(e){return z(R.fail(e))}case`Auto`:try{let t=e.thunk();return t instanceof Promise?z(R.succeed(await t)):z(R.succeed(t))}catch(e){return z(R.fail(e))}case`Map`:{let i=await U(B(e.effect),t,n);return i.isSuccess()?r()?R.interrupted():z(R.succeed(e.f(i.orThrow()))):z(i)}case`FlatMap`:{let i=await U(B(e.effect),t,n);if(!i.isSuccess())return z(i);if(r())return R.interrupted();let a=e.f(i.orThrow());return U(B(a),t,n)}case`MapError`:{let i=await U(B(e.effect),t,n),a=Cn(i);return a?wn(i,r())||z(R.fail(e.f(a.value))):z(i)}case`Recover`:{let i=await U(B(e.effect),t,n);return Cn(i)?wn(i,r())??R.succeed(e.fallback):z(i)}case`RecoverWith`:{let i=await U(B(e.effect),t,n),a=Cn(i);if(!a)return z(i);let o=wn(i,r());if(o)return o;let s=e.f(a.value);return U(B(s),t,n)}case`Fold`:{let i=await U(B(e.effect),t,n),a=Cn(i);return a?wn(i,r())??R.succeed(e.onFailure(a.value)):i.isSuccess()?r()?R.interrupted():R.succeed(e.onSuccess(i.orThrow())):i}case`Service`:{let n=t.get(e.tag);return n.isNone()?R.fail(/* @__PURE__ */ Error(`Service not found: ${e.tag.id}`)):R.succeed(n.orThrow())}case`ProvideContext`:{let r=t.merge(e.context);return U(B(e.effect),r,n)}case`Interrupt`:return R.interrupted();case`Bracket`:{let i=await U(B(e.acquire),t);if(!i.isSuccess())return i;let a=i.orThrow();try{return r()?R.interrupted():await U(B(e.use(a)),t,n)}finally{await U(B(e.release(a)),t)}}case`BracketExit`:{let i=await U(B(e.acquire),t);if(!i.isSuccess())return i;let a=i.orThrow(),o=r()?R.interrupted():await U(B(e.use(a)),t,n);return await U(B(e.release(a,o)),t),o}case`Race`:return e.effects.length===0?R.fail(/* @__PURE__ */ Error(`No effects to race`)):await Promise.race(e.effects.map(e=>U(B(e),t,n)));case`Timeout`:{let r,i=new Promise(t=>{r=setTimeout(()=>t(R.fail(new mn(e.duration))),e.duration)}),a=U(B(e.effect),t,n);try{return await Promise.race([a,i])}finally{clearTimeout(r)}}case`InterruptWhen`:{let{signal:i}=e,a=pn([n,i]);try{let n=await U(B(e.effect),t,a.signal);return z(Tn(n,i,r()))}finally{a.dispose()}}case`All`:return z(await En(e.effects,e.concurrency,t,n))}}catch(e){return R.die(e)}},En=(e,t,n,r)=>{if(e.length===0)return Promise.resolve(R.succeed([]));let i=new AbortController,a=pn([r,i.signal]),o=Array(e.length),s={next:0,succeeded:0,settled:!1};return new Promise(r=>{let c=e=>{s.settled=!0,e.isSuccess()||i.abort(),a.dispose(),r(e)},l=()=>{if(s.settled||s.next>=e.length)return;let t=s.next;s.next=t+1,U(B(e[t]),n,a.signal).then(n=>{if(!s.settled){if(!n.isSuccess()){c(z(n));return}o[t]=n.orThrow(),s.succeeded+=1,s.succeeded===e.length?c(R.succeed(o)):l()}})};Array.from({length:ae(t,e.length)}).forEach(l)})},W={sync:e=>V({_tag:`Sync`,thunk:e}),succeed:e=>V({_tag:`Succeed`,value:e}),fail:e=>V({_tag:`Fail`,error:e}),die:e=>V({_tag:`Die`,defect:e}),async:e=>V(z({_tag:`Async`,thunk:e})),tryPromise:e=>V({_tag:`Async`,thunk:e.try}).mapError(e.catch),tryCatch:(e,t)=>W.sync(()=>{try{return e()}catch(e){throw t(e)}}),liftSync:e=>(...t)=>W.sync(()=>e(...t)),liftPromise:e=>(...t)=>W.async(()=>e(...t)),fromEither:e=>z(e.isRight()?W.succeed(e.value):W.fail(e.value)),fromPromiseEither:(e,t)=>{let n=W.async(async()=>e());return(t?n.mapError(t):n.recoverWith(e=>W.die(e))).flatMap(e=>W.fromEither(e))},fromOption:e=>z(e.isSome()?W.succeed(e.value):W.fail(void 0)),fromOptionOrFail:(e,t)=>z(e.isSome()?W.succeed(e.value):W.fail(t())),fromTry:e=>z(e.isSuccess()?W.succeed(e.orThrow()):W.fail(e.error)),fromResult:e=>z(e.error?W.fail(e.error):W.succeed(m(e.data))),tryAsync:(e,t,n)=>n?.aborted?z(W.fail(t(n.reason??new DOMException(`Aborted`,`AbortError`)))):W.async(t=>{if(!n)return e(t);if(!t)return e(n);let r=pn([n,t]);try{return e(r.signal).finally(r.dispose)}catch(e){throw r.dispose(),e}}).mapError(t),asyncResult:(e,t,n)=>{let r=n?.dataKey??`data`,i=n?.errorKey??`error`;return W.tryAsync(t=>e(t),t,n?.signal).flatMap(e=>W.fromResult({data:e[r],error:e[i]}))},service:e=>V({_tag:`Service`,tag:e}),serviceWith:(e,t)=>W.service(e).map(t),serviceWithIO:(e,t)=>W.service(e).flatMap(t),withServices:(e,t)=>{let n=Object.entries(e);if(n.length===0)return z(V({_tag:`Auto`,thunk:()=>t({})}));let r=z(W.succeed({})),i=n.reduce((e,[t,n])=>z(e.flatMap(e=>W.service(n).map(n=>({...e,[t]:n})))),r);return z(i.flatMap(e=>V({_tag:`Auto`,thunk:()=>t(e)})))},all:(e,t)=>{let n=t?.concurrency??1;if(ae(n,1),n!==1&&e.length>1)return V(z({_tag:`All`,effects:e,concurrency:n}));if(e.length===0)return z(W.succeed([]));let r=z(W.succeed([]));return z(e.reduce((e,t)=>e.flatMap(e=>t.map(t=>[...e,t])),r))},firstSuccessOf:e=>e.length===0?z(W.fail(/* @__PURE__ */ Error(`No effects provided`))):e.reduce((e,t)=>e.recoverWith(()=>t)),sleep:e=>z(W.async(()=>new Promise(t=>setTimeout(t,e)))),iterate:(e,t,n,r)=>{let i=r?.max??1e4,a=(e,r)=>n(e)?z(W.succeed(e)):r<=0?z(W.fail(new _n(i,e))):t(e).flatMap(e=>a(e,r-1));return a(e,i)},never:()=>z(W.async(()=>new Promise(()=>{}))),get unit(){return z(V({_tag:`Succeed`,value:void 0}))},fromNullable:e=>z(e==null?W.fail(void 0):W.succeed(e)),interrupt:()=>V({_tag:`Interrupt`}),bracket:(e,t,n)=>V({_tag:`Bracket`,acquire:e,use:t,release:n}),acquireRelease:(e,t,n)=>W.bracket(e,t,n),bracketExit:(e,t,n)=>V({_tag:`BracketExit`,acquire:e,use:t,release:n}),race:e=>V({_tag:`Race`,effects:e}),any:e=>e.length===0?z(W.fail(/* @__PURE__ */ Error(`No effects provided`))):e.reduce((e,t)=>e.recoverWith(()=>t)),forEach:(e,t,n)=>{let r=n?.concurrency??1;if(ae(r,1),r!==1)return W.unit.flatMap(()=>W.all(e.map(t),n));if(e.length===0)return z(W.succeed([]));let i=z(W.succeed([]));return z(e.reduce((e,n)=>e.flatMap(e=>t(n).map(t=>[...e,t])),i))},forEachPar:(e,t)=>W.forEach(e,t),timeout:(e,t)=>V(z({_tag:`Timeout`,effect:e,duration:t})),gen:e=>z(W.sync(()=>{let t=e(),n=e=>{let r=t.next(e);return r.done?z(W.succeed(r.value)):z(r.value.flatMap(e=>n(e)))};return n(void 0)}).flatMap(e=>e)),get Do(){return Dn(W.succeed({}))}},Dn=e=>({effect:e,bind(t,n){let r=e.flatMap(e=>n(e).map(n=>({...e,[t]:n})));return Dn(r)},let(t,n){let r=e.map(e=>({...e,[t]:n(e)}));return Dn(r)},map(t){return e.map(t)},flatMap(t){return e.flatMap(t)},tap(t){return Dn(e.tap(t))},tapEffect(t){return Dn(e.tapEffect(t))},done(){return e}}),G=r(e=>V(z({_tag:`Auto`,thunk:e})),W),K=(e,t)=>({_tag:`Layer`,build:e,provideToAndMerge(t){return K(async n=>{let r=await e(n),i=n.merge(r),a=await t.build(i);return r.merge(a)})},merge(t){return K(async n=>{let[r,i]=await Promise.all([e(n),t.build(n)]);return r.merge(i)})},map(t){return K(async n=>t(await e(n)))},toString(){return`Layer(${t??`anonymous`})`}}),On={succeed:(e,t)=>K(()=>Promise.resolve(I.make(e,t)),e.id),effect:(e,t)=>K(async()=>{let n=await t();return I.make(e,n)},e.id),sync:(e,t)=>K(()=>Promise.resolve(I.make(e,t())),e.id),fromService:(e,t,n)=>K(r=>{let i=r.unsafeGet(t);return Promise.resolve(I.make(e,n(i)))},e.id),fromServiceEffect:(e,t,n)=>K(async r=>{let i=await n(r.unsafeGet(t));return I.make(e,i)},e.id),fromContext:e=>K(()=>Promise.resolve(e)),empty:()=>K(()=>Promise.resolve(I.empty()),`empty`),mergeAll:(...e)=>K(async t=>(await Promise.all(e.map(e=>e.build(t)))).reduce((e,t)=>e.merge(t),I.empty()))},kn=e=>({id:e,_tag:`Tag`,toString(){return`Tag(${e})`}}),An=()=>{let e=0,t=[],n=async()=>{for(t.sort((e,t)=>e.time-t.time);t.length>0&&t[0]!==void 0&&t[0].time<=e;){let e=t.shift();e&&(e.resolve(),await Promise.resolve())}};return{get currentTime(){return e},async advance(t){e+=t,await n()},async setTime(t){e=t,await n()},async runAll(){if(t.length>0){let n=t[t.length-1];n&&(e=n.time)}await n()},get pendingCount(){return t.length},sleep(n){return new Promise(r=>{t.push({time:e+n,resolve:r})})}}},jn=kn(`TestClock`),Mn={make:An,tag:jn,test:async e=>e(An()),get get(){return G.service(jn)},advance:e=>G.serviceWithIO(jn,t=>G.async(()=>t.advance(e))),setTime:e=>G.serviceWithIO(jn,t=>G.async(()=>t.setTime(e))),get runAll(){return G.serviceWithIO(jn,e=>G.async(()=>e.runAll()))},context:()=>{let e=An();return{clock:e,context:I.make(jn,e)}}},Nn={make:()=>{let e=An(),t=I.empty(),n={get context(){return t},get clock(){return e},withService(e,r){return t=t.add(e,r),n},async run(e){return e.provideContext(t).runOrThrow()}};return n},withClock:()=>{let e=An();return Nn.make().withService(jn,e)}},Pn=kn(`HttpClient`),Fn={},In=r({_tag:`HttpError`},{networkError:(e,t,n)=>({_tag:`NetworkError`,url:e,method:t,cause:n}),httpStatusError:(e,t,n,r,i)=>({_tag:`HttpStatusError`,url:e,method:t,status:n,statusText:r,body:i}),decodeError:(e,t,n,r)=>({_tag:`DecodeError`,url:e,method:t,body:n,cause:r}),isNetworkError:e=>e._tag===`NetworkError`,isHttpStatusError:e=>e._tag===`HttpStatusError`,isDecodeError:e=>e._tag===`DecodeError`,match:(e,t)=>{switch(e._tag){case`NetworkError`:return t.NetworkError(e);case`HttpStatusError`:return t.HttpStatusError(e);case`DecodeError`:return t.DecodeError(e)}}}),Ln=(e,t)=>!e||t.startsWith(`http://`)||t.startsWith(`https://`)?t:`${e.endsWith(`/`)?e.slice(0,-1):e}${t.startsWith(`/`)?t:`/${t}`}`,Rn=(e,t)=>{let n=new URLSearchParams;for(let e of Object.keys(t)){let r=t[e];if(r!=null){if(Array.isArray(r))for(let t of r)n.append(e,String(t));else n.append(e,String(r))}}let r=n.toString();return r?`${e}${e.includes(`?`)?`&`:`?`}${r}`:e},zn=(e,t,n)=>{let r=Ln(e,t);return n?Rn(r,n):r},Bn=(e,t)=>e[Symbol.toStringTag]===t,q=(e,t)=>{if(typeof e!=`object`||!e||e instanceof Date||e instanceof RegExp||typeof Buffer<`u`&&e instanceof Buffer)return e;if(Bn(e,`Option`)){let n=e;return t===`tagged`?n._tag===`None`?{_tag:`None`,value:null}:{_tag:`Some`,value:q(n.value,t)}:n._tag===`None`?null:q(n.value,t)}if(Bn(e,`Either`)){let n=e;if(t===`tagged`)return{_tag:n._tag,value:q(n.value,t)};if(n._tag===`Left`)throw Error(`Cannot serialize a Left in a request body — Either's failure path should not cross the wire as data. Resolve the Left before sending, or omit the field. (Left value: ${JSON.stringify(n.value)})`);return q(n.value,t)}if(Bn(e,`Try`)){let n=e;if(t===`tagged`){if(n._tag===`Failure`){let e=n.error??/* @__PURE__ */ Error(`unknown`);return{_tag:`Failure`,error:e.message,stack:e.stack}}return{_tag:`Success`,value:q(n.value,t)}}if(n._tag===`Failure`)throw n.error??/* @__PURE__ */ Error(`Cannot serialize a Try Failure in a request body`);return q(n.value,t)}if(Bn(e,`List`)){let n=e.toArray().map(e=>q(e,t));return t===`tagged`?{_tag:`List`,value:n}:n}if(Bn(e,`FunctypeMap`)){let n=e.toValue().value;if(t===`tagged`)return{_tag:`Map`,value:n.map(([e,n])=>[e,q(n,t)])};let r={};for(let[e,i]of n){if(typeof e!=`string`)throw Error(`Cannot serialize Map with non-string keys to JSON (key: ${String(e)})`);r[e]=q(i,t)}return r}if(Array.isArray(e))return e.map(e=>q(e,t));let n={};for(let r of Object.keys(e))n[r]=q(e[r],t);return n},Vn=(e,t,n)=>{if(e==null)return{serialized:void 0,contentType:void 0};if(n)return{serialized:JSON.stringify(n(e)),contentType:`application/json`};if(typeof e==`string`)return{serialized:e,contentType:void 0};if(typeof e==`object`||Array.isArray(e)){let n=q(e,t?`primitive`:`tagged`);return{serialized:JSON.stringify(n),contentType:`application/json`}}return{serialized:String(e),contentType:void 0}},Hn=e=>{let t=e.get(`content-type`)??``;return t.includes(`application/json`)?`json`:t.startsWith(`text/`)?`text`:`raw`},Un=async(e,t,n,r,i,a)=>{let o=t??Hn(e.headers),s,c={};switch(o){case`json`:{let t=await e.text();c.value=t;try{s=JSON.parse(t)}catch(e){throw In.decodeError(n,r,t,e)}break}case`text`:s=await e.text(),c.value=s;break;case`blob`:s=await e.blob();break;case`arrayBuffer`:s=await e.arrayBuffer();break;case`raw`:s=e}let l;if(i){let e=i(s);if(e.isLeft()){let t=c.value??(typeof s==`string`?s:JSON.stringify(s));throw In.decodeError(n,r,t,e.value)}l=e.value}else if(a)try{l=a(s)}catch(e){let t=c.value??(typeof s==`string`?s:JSON.stringify(s));throw In.decodeError(n,r,t,e)}else l=s;return{data:l,status:e.status,statusText:e.statusText,headers:e.headers}},J=(e,t)=>{let n={url:zn(e.baseUrl,t.url,t.params),method:t.method,headers:{...e.defaultHeaders,...t.headers},body:t.body,signal:t.signal,parseAs:t.parseAs,flatten:t.flatten};return(e.beforeRequest?e.beforeRequest(n):G.succeed(n)).flatMap(n=>{let r=n.flatten??!0,i=(()=>{try{return{ok:!0,value:Vn(n.body,r,t.encode)}}catch(e){return{ok:!1,cause:e}}})();if(!i.ok)return G.fail(In.networkError(n.url,n.method,i.cause));let{serialized:a,contentType:o}=i.value,s={...n.headers,...o?{"Content-Type":o}:{}},c=G.tryAsync(r=>(e.fetch??globalThis.fetch)(n.url,{method:n.method,headers:s,body:a,signal:n.signal??r}).then(async e=>{if(!e.ok){let t=await e.text().catch(()=>``);throw In.httpStatusError(n.url,n.method,e.status,e.statusText,t)}return Un(e,n.parseAs,n.url,n.method,t.decode,t.validate)}),e=>typeof e==`object`&&e&&`_tag`in e?e:In.networkError(n.url,n.method,e));return e.afterResponse?c.flatMap(t=>e.afterResponse(t).map(e=>e)):c})},Wn=e=>J(Fn,e),Gn=r({_tag:`Http`},{request:Wn,get:(e,t)=>Wn({...t,url:e,method:`GET`}),post:(e,t)=>Wn({...t,url:e,method:`POST`}),put:(e,t)=>Wn({...t,url:e,method:`PUT`}),patch:(e,t)=>Wn({...t,url:e,method:`PATCH`}),delete:(e,t)=>Wn({...t,url:e,method:`DELETE`}),head:(e,t)=>Wn({...t,url:e,method:`HEAD`,parseAs:`raw`}),options:(e,t)=>Wn({...t,url:e,method:`OPTIONS`,parseAs:`raw`}),client:e=>({request:t=>J(e,t),get:(t,n)=>J(e,{...n,url:t,method:`GET`}),post:(t,n)=>J(e,{...n,url:t,method:`POST`}),put:(t,n)=>J(e,{...n,url:t,method:`PUT`}),patch:(t,n)=>J(e,{...n,url:t,method:`PATCH`}),delete:(t,n)=>J(e,{...n,url:t,method:`DELETE`}),head:(t,n)=>J(e,{...n,url:t,method:`HEAD`,parseAs:`raw`}),options:(t,n)=>J(e,{...n,url:t,method:`OPTIONS`,parseAs:`raw`})})}),Kn={toOption:e=>e.fold(()=>p(),e=>d(e)),toList:e=>e.fold(()=>C([]),e=>C([e])),toEither:(e,t)=>e.fold(()=>T(t),e=>w(e)),isEmpty:e=>e.fold(()=>!0,()=>!1),size:e=>e.fold(()=>0,()=>1)},qn=e=>typeof e==`object`&&!!e&&(e._tag===`Some`||e._tag===`None`),Y=e=>typeof e==`object`&&!!e&&e._tag===`List`,Jn=e=>typeof e==`object`&&!!e&&(e._tag===`Left`||e._tag===`Right`),Yn=e=>typeof e==`object`&&!!e&&(e._tag===`Success`||e._tag===`Failure`),X=()=>{let e=(e,t)=>{if(qn(e)||Y(e)||Jn(e)||Yn(e))return e.map(e=>t(e));throw Error(`Unsupported functor type: ${JSON.stringify(e)}`)},t=e=>{if(qn(e))return e.orThrow();if(Y(e)){let t=e.toArray();if(t.length>0&&Y(t[0])){let e=[];for(let n of t)Y(n)&&e.push(...n.toArray());return C(e)}return e.flatten()}if(Jn(e))return e.isRight()?e.fold(()=>null,e=>e):e;if(Yn(e))return e.isSuccess()?e.orThrow():e;throw Error(`Unsupported functor type for flatten: ${JSON.stringify(e)}`)},n=(e,t)=>{if(qn(e)||Y(e)||Jn(e)||Yn(e))return e.flatMap(e=>t(e));throw Error(`Unsupported functor type for flatMap: ${JSON.stringify(e)}`)},r=(e,t)=>{if(qn(e)&&qn(t)||Y(e)&&Y(t)||Jn(e)&&Jn(t)||Yn(e)&&Yn(t))return e.flatMap(e=>t.map(t=>e(t)));throw Error(`Unsupported functor type for ap: ${JSON.stringify(e)}`)},i=e=>{if(qn(e)){let t=e;if(t.isEmpty)return C([m.none()]);let n=t.orThrow();if(Y(n))return n.map(e=>m(e));throw Error(`Unsupported inner container type for sequence`)}if(Y(e)){let t=e.toArray();if(t.length===0)return m.none();let n=t[0];if(qn(n)){for(let e of t)if(e.isEmpty)return m.none();let e=t.map(e=>e.orThrow());return m(C(e))}throw Error(`Unsupported inner container type for sequence`)}throw Error(`Unsupported outer container type for sequence: ${JSON.stringify(e)}`)};return{_tag:`HKT`,map:e,flatten:t,flatMap:n,ap:r,sequence:i,traverse:(t,n)=>i(e(t,e=>n(e))),_type:`HKT`}},Xn=X();X.map=(e,t)=>Xn.map(e,t),X.flatten=e=>Xn.flatten(e),X.flatMap=(e,t)=>Xn.flatMap(e,t),X.ap=(e,t)=>Xn.ap(e,t),X.sequence=e=>Xn.sequence(e),X.traverse=(e,t)=>Xn.traverse(e,t),X.isOption=qn,X.isList=Y,X.isEither=Jn,X.isTry=Yn;const Zn=e=>({id:e,isSame:t=>t.id===e}),Qn=r(Zn,{of:e=>Zn(e),pure:e=>Zn(e)}),$n=e=>{let t=!1,n,r,a=!1,s=()=>{if(!t)try{n=e(),t=!0}catch(e){throw r=e,a=!0,t=!0,e}if(a)throw r;return n};return{[Symbol.toStringTag]:`Lazy`,_tag:`Lazy`,get isEvaluated(){return t},orElse:e=>{try{return s()}catch{return e}},orNull:()=>{try{return s()}catch{return null}},orThrow:e=>{try{return s()}catch(t){throw e??t}},or:e=>Z(()=>{try{return s()}catch{return e.orThrow()}}),orUndefined:()=>{try{return s()}catch{return}},map:e=>Z(()=>e(s())),ap:e=>Z(()=>e.orThrow()(s())),mapAsync:async e=>{let t=await e(s());return Z(()=>t)},flatMap:e=>Z(()=>e(s()).orThrow()),flatMapAsync:async e=>{let t=await e(s());return Z(()=>t.orThrow())},filter:e=>Z(()=>{let t=s();return e(t)?d(t):p}),recover:e=>Z(()=>{try{return s()}catch(t){return e(t)}}),recoverWith:e=>Z(()=>{try{return s()}catch(t){return e(t).orThrow()}}),toOption:()=>{try{return d(s())}catch{return p}},toEither:()=>{try{return w(s())}catch(e){return T(e)}},toEitherWith:e=>{try{return w(s())}catch(t){return T(e(t))}},toTry:()=>x(()=>s()),tap:e=>Z(()=>{let t=s();return e(t),t}),tapError:e=>Z(()=>{try{return s()}catch(t){throw e(t),t}}),fold:e=>e(s()),foldWith:(e,t)=>{try{return t(s())}catch(t){return e(t)}},foldLeft:e=>t=>t(e,s()),foldRight:e=>t=>t(s(),e),match:e=>e.Lazy(s()),toString:()=>t&&!a?`Lazy(${u(n)})`:t&&a?`Lazy(<error: ${r instanceof Error?r.message:String(r)}>)`:`Lazy(<not evaluated>)`,toValue:()=>{try{return{_tag:`Lazy`,value:s()}}catch(e){return{_tag:`Lazy`,error:e instanceof Error?e:Error(String(e))}}},get size(){try{return s(),1}catch{return 0}},get isEmpty(){try{return s(),!1}catch{return!0}},contains:e=>{try{return s()===e}catch{return!1}},reduce:e=>s(),reduceRight:e=>s(),count:e=>{try{return+!!e(s())}catch{return 0}},find:e=>{try{let t=s();return e(t)?d(t):p}catch{return p}},exists:e=>{try{return e(s())}catch{return!1}},forEach:e=>{try{e(s())}catch{}},pipe:e=>e(s()),toJSON:()=>{try{return{"@functype":`Lazy`,_tag:`Lazy`,value:s()}}catch(e){return{"@functype":`Lazy`,_tag:`Lazy`,error:o(e)}}},serialize:()=>{try{return c(`Lazy`,s())}catch(e){return i(`Lazy`,`Lazy`,{error:o(e)})}},typeable:`Lazy`}},er={of:e=>$n(e),fromValue:e=>$n(()=>e),fromOption:(e,t)=>$n(()=>e._tag===`Some`?e.value:t()),fromTry:e=>$n(()=>e.orThrow()),fromEither:e=>$n(()=>e.fold(e=>{throw e},e=>e)),fromPromise:e=>$n(()=>{throw Error(`Promise not yet resolved. Use await on the promise before creating Lazy.`)}),fail:e=>$n(()=>{throw e}),evaluated:e=>$n(()=>e),fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`Lazy`)throw Error(`Lazy.fromJSON: expected @functype="Lazy", got ${JSON.stringify(t[`@functype`])}`);if(t.error!==void 0){let e=typeof t.error==`object`?a(t.error):Error(t.error);return er.fail(e)}return er.evaluated(t.value)}},Z=r($n,er),tr={default:e=>t=>e(t),when:(e,t)=>n=>e(n)?t(n):void 0},Q=e=>({[Symbol.toStringTag]:`Obj`,_tag:`Obj`,data:e,get:t=>m(e[t]),set:(t,n)=>Q({...e,[t]:n}),assign:t=>Q({...e,...t}),merge:t=>Q({...e,...t}),when:(t,n)=>(typeof t==`function`?t():t)?Q({...e,...n}):Q(e),omit:(...t)=>{let n={...e};for(let e of t)delete n[e];return Q(n)},pick:(...t)=>{let n={};for(let r of t)r in e&&(n[r]=e[r]);return Q(n)},keys:()=>C(Object.keys(e)),values:()=>C(Object.values(e)),entries:()=>C(Object.entries(e).map(([e,t])=>re([e,t]))),has:t=>t in e,value:()=>e,get isEmpty(){return Object.keys(e).length===0},get size(){return Object.keys(e).length},map:t=>Q(t(e)),flatMap:t=>t(e),flatMapAsync:async t=>await t(e),ap:t=>{let n=t.data;return Q(n(e))},fold:(t,n)=>Object.keys(e).length===0?t():n(e),match:t=>t.Obj(e),foldLeft:t=>n=>n(t,e),foldRight:t=>n=>n(e,t),count:t=>+!!t(e),find:t=>t(e)?m(e):m(void 0),exists:t=>t(e),forEach:t=>t(e),reduce:t=>e,reduceRight:t=>e,contains:t=>JSON.stringify(e)===JSON.stringify(t),orElse:t=>e,orThrow:t=>e,or:t=>Q(e),orNull:()=>e,orUndefined:()=>e,toOption:()=>m(e),toEither:t=>w(e),toList:()=>C([e]),toTry:()=>x(()=>e),toPromise:()=>Promise.resolve(e),toString:()=>`Obj(${u(e)})`,toValue:()=>({_tag:`Obj`,value:e}),toJSON:()=>({"@functype":`Obj`,_tag:`Obj`,value:e}),pipe:t=>t(e),serialize:()=>c(`Obj`,e),doUnwrap(){return{ok:!0,value:e}}}),nr=e=>Q(e),rr={of:e=>Q(e),empty:()=>Q({}),fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`Obj`)throw Error(`Obj.fromJSON: expected @functype="Obj", got ${JSON.stringify(t[`@functype`])}`);return Q(t.value)},fromBinary:e=>{let t=s(e);return rr.fromJSON(t)}},ir=r(nr,rr),$=(e=[])=>{let t=[...e],n=()=>t.length,r=()=>t.length===0,i=e=>t.includes(e),a=e=>{if(t.length===0)throw Error(`Cannot reduce an empty stack`);return te(t,e)},o=e=>{if(t.length===0)throw Error(`Cannot reduce an empty stack`);return ne(t,e)},s=e=>$([...t,e]),l=()=>{if(r())return[$([]),m(null)];let e=[...t],n=e.pop();return[$(e),m(n)]},u=()=>r()?m(null):m(t[t.length-1]),ee=e=>$(t.map(e)),re=e=>r()?$([]):t.reduce((t,n)=>e(n).toArray().reduce((e,t)=>e.push(t),t),$([])),ie=e=>{let n=[];return t.forEach(t=>{e.toArray().forEach(e=>{n.push(e(t))})}),$(n)},ae=async e=>r()?$([]):(await Promise.all(t.map(async t=>await e(t)))).reduce((e,t)=>t.toArray().reduce((e,t)=>e.push(t),e),$([])),oe=()=>C(t),d=()=>[...t],f=()=>`Stack(${t.join(`, `)})`,p=(e,n)=>t.reduce(n,e),se=e=>n=>t.reduce(n,e),ce=e=>n=>t.reduceRight((e,t)=>n(t,e),e),h=e=>r()?e.Empty():e.NonEmpty([...t]);return{[Symbol.toStringTag]:`Stack`,_tag:`Stack`,get size(){return n()},get isEmpty(){return r()},contains:i,reduce:a,reduceRight:o,push:s,pop:l,peek:u,map:ee,flatMap:re,ap:ie,flatMapAsync:ae,toList:oe,toArray:d,toString:f,fold:p,foldLeft:se,foldRight:ce,match:h,toValue:()=>({_tag:`Stack`,value:t}),toJSON:()=>({"@functype":`Stack`,_tag:`Stack`,value:[...t]}),pipe:e=>e([...t]),serialize:()=>c(`Stack`,t)}},ar=(e=[])=>$(e),or={empty:()=>$([]),of:(...e)=>$(e),fromJSON:e=>{let t=JSON.parse(e);if(t[`@functype`]!==void 0&&t[`@functype`]!==`Stack`)throw Error(`Stack.fromJSON: expected @functype="Stack", got ${JSON.stringify(t[`@functype`])}`);return sr(t.value)},fromYAML:e=>{let t=e.split(`
|
|
17
|
+
`)[1]?.split(`: `)[1];if(!t)return sr([]);let n=JSON.parse(t);return sr(n)},fromBinary:e=>{let t=s(e);return or.fromJSON(t)}},sr=r(ar,or);var cr=/* @__PURE__ */ e({deserialize:()=>mr,deserializeStrict:()=>hr,fromEnvelope:()=>vr,isFunctypeValue:()=>yr,serialize:()=>gr,toEnvelope:()=>_r});let lr;const ur=()=>(lr===void 0&&(lr={Option:e=>e._tag===`Some`?d(e.value):p(),Either:e=>e._tag===`Right`?w(e.value):T(e.value),Try:e=>{if(e._tag===`Success`)return x.success(e.value);let t=e.error!==void 0&&typeof e.error==`object`?a(e.error):Error(typeof e.error==`string`?e.error:``);return x.failure(t)},List:e=>C(e.value),Set:e=>fe(e.value),Map:e=>ft(e.value),Obj:e=>ir(e.value),Stack:e=>sr(e.value),Tuple:e=>re(e.value),LazyList:e=>ge(e.value),Lazy:e=>{if(e.error!==void 0){let t=typeof e.error==`object`?a(e.error):Error(e.error);return Z.fail(t)}return Z.evaluated(e.value)},Task:e=>{if(e._tag===`Ok`)return A.ok(e.value);let t=e.error!==void 0&&typeof e.error==`object`?a(e.error):Error(typeof e.error==`string`?e.error:`Unknown Task error`);return A.err(t)}}),lr),dr=e=>typeof e==`object`&&!!e&&!Array.isArray(e),fr=e=>dr(e)&&typeof e[`@functype`]==`string`,pr=e=>{if(Array.isArray(e))return e.map(pr);if(fr(e)){let t=e[ee],n=ur()[t];if(n===void 0)throw Error(`Serialization.deserialize: unknown @functype marker ${JSON.stringify(t)}`);let r={};for(let t of Object.keys(e))r[t]=pr(e[t]);return n(r)}if(dr(e)){let t={};for(let n of Object.keys(e))t[n]=pr(e[n]);return t}return e},mr=e=>x(()=>pr(JSON.parse(e))),hr=e=>x(()=>{let t=JSON.parse(e);if(!fr(t))throw Error(`Serialization.deserializeStrict: input is not a functype envelope (no @functype marker at the top level)`);return pr(t)}),gr=e=>JSON.stringify(e??null),_r=e=>JSON.parse(JSON.stringify(e??null)),vr=e=>x(()=>pr(e)),yr=e=>typeof e==`object`&&!!e&&typeof e.serialize==`function`&&typeof e._tag==`string`;function br(e){return e._tag}function xr(e){return String(e[Symbol.toStringTag])}function Sr(e,t,n,r=0){function i(i,a,o,s){return t.emit({spanId:n,seq:r,op:i,tag:xr(e),inTag:br(e),...a!==void 0&&{outTag:a},...o!==void 0&&{label:o},...s!==void 0&&{meta:s}}),r+1}return{map(r,a){let o=e.map(r);return Sr(o,t,n,i(`map`,br(o),a))},flatMap(r,a){let o=e.flatMap(r);return Sr(o,t,n,i(`flatMap`,br(o),a))},filter(r,a){let o=e.filter(r),s=br(o)!==`None`;return Sr(o,t,n,i(`filter`,br(o),a,{kept:s}))},fold(t,n,r){return i(`fold`,void 0,r),e.fold(t,n)},orElse(t,n){return i(`orElse`,void 0,n,{usedDefault:br(e)===`None`}),e.orElse(t)},unwrap(){return i(`unwrap`,void 0,void 0),e}}}function Cr(e){let t=ye({_tag:e._tag,impl:e.impl});return{...t,toValue:()=>({_tag:t._tag,value:e.value})}}export{et as $,tn as A,fe as At,Gt as B,gn as C,Me as Ct,on as D,x as Dt,cn as E,be as Et,Wt as F,ie as Ft,ct as G,zt as H,Xt as I,A as J,O as K,Zt as L,$t as M,m as Mt,qt as N,se as Nt,P as O,ge as Ot,Ht as P,d as Pt,nt as Q,Yt as R,mn as S,ke as St,I as T,ye as Tt,M as U,Kt as V,ft as W,rt as X,at as Y,tt as Z,kn as _,w as _t,ir as a,We as at,hn as b,Oe as bt,Qn as c,Le as ct,Gn as d,Ie as dt,$e as et,In as f,Ue as ft,Nn as g,T as gt,jn as h,Fe as ht,sr as i,Ve as it,en as j,p as jt,nn as k,_ as kt,X as l,qe as lt,Mn as m,E as mt,Sr as n,Ge as nt,tr as o,Re as ot,Pn as p,He as pt,k as q,cr as r,Ke as rt,Z as s,Be as st,Cr as t,Xe as tt,Kn as u,ze as ut,On as v,je as vt,R as w,C as wt,_n as x,De as xt,G as y,Ae as yt,Jt as z};
|
package/dist/try/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Bn as TypeNames, zn as Try } from "../index-
|
|
1
|
+
import { Bn as TypeNames, zn as Try } from "../index-CjqFFy4s.js";
|
|
2
2
|
export { Try, TypeNames };
|
package/dist/try/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Dt as e}from"../src-
|
|
1
|
+
import{Dt as e}from"../src-DaOliT66.js";export{e as Try};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Cr as AsyncMonad, Dr as ContainerOps, Er as CollectionOps, Sr as Applicative, Tr as Monad, br as reduceWiden, vr as Widen, wr as Functor, xr as Promisable, yr as reduceRightWiden } from "../index-
|
|
2
|
-
export { type Applicative, type AsyncMonad, type CollectionOps, type ContainerOps, type Functor, type Monad, type Promisable, type Widen, reduceRightWiden, reduceWiden };
|
|
1
|
+
import { Cr as AsyncMonad, Dr as ContainerOps, Er as CollectionOps, Or as Flattened, Sr as Applicative, Tr as Monad, br as reduceWiden, vr as Widen, wr as Functor, xr as Promisable, yr as reduceRightWiden } from "../index-CjqFFy4s.js";
|
|
2
|
+
export { type Applicative, type AsyncMonad, type CollectionOps, type ContainerOps, type Flattened, type Functor, type Monad, type Promisable, type Widen, reduceRightWiden, reduceWiden };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functype",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.26.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A functional programming library for TypeScript, using immutable data structures and type classes",
|
|
6
6
|
"keywords": [
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"@eslint/compat": "^2.1.1",
|
|
36
36
|
"@eslint/eslintrc": "^3.3.7",
|
|
37
37
|
"@types/node": "~24.19.1",
|
|
38
|
-
"eslint-config-functype": "2.
|
|
38
|
+
"eslint-config-functype": "2.126.1",
|
|
39
39
|
"eslint-plugin-functional": "^10.0.1",
|
|
40
40
|
"fast-check": "^4.10.2",
|
|
41
41
|
"globals": "^17.13.0",
|
|
42
|
-
"ts-builds": "^
|
|
42
|
+
"ts-builds": "^4.5.0",
|
|
43
43
|
"tsdown": "^0.23.0",
|
|
44
44
|
"tsx": "^4.23.15",
|
|
45
45
|
"typedoc": "^0.28.20",
|