functype 0.53.0 → 0.54.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{a as e,i as t,n,r,t as i}from"../full-interfaces-DXMfSObi.js";export{n as CATEGORIES,i as FULL_INTERFACES,r as INTERFACES,t as TYPES,e as VERSION};
1
+ import{a as e,i as t,n,r,t as i}from"../full-interfaces-CFqhF0Y6.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{Dt as e,J as t,yt as n}from"../src-DagovFT3.js";import{a as r,i,n as a,r as o,t as s}from"../full-interfaces-DXMfSObi.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(`
2
+ import{Dt as e,J as t,yt as n}from"../src-BhBVtHJY.js";import{a as r,i,n as a,r as o,t as s}from"../full-interfaces-CFqhF0Y6.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 { a as EmptyListError, c as LeftError, d as isDoCapable, f as unwrap, i as DoGenerator, ir as Doable, l as LeftErrorType, n as Do, o as FailureError, r as DoAsync, rr as DoResult, s as FailureErrorType, t as $, u as NoneError } from "../index-Di7IFeuy.js";
1
+ import { a as EmptyListError, c as LeftError, d as isDoCapable, f as unwrap, i as DoGenerator, ir as Doable, l as LeftErrorType, n as Do, o as FailureError, r as DoAsync, rr as DoResult, s as FailureErrorType, t as $, u as NoneError } from "../index-DN9rYP81.js";
2
2
  export { $, Do, DoAsync, DoGenerator, DoResult, Doable, EmptyListError, FailureError, FailureErrorType, LeftError, LeftErrorType, NoneError, isDoCapable, unwrap };
package/dist/do/index.js CHANGED
@@ -1 +1 @@
1
- import{F as e,I as t,L as n,M as r,N as i,P as a,R as o,j as s,z as c}from"../src-DagovFT3.js";export{s as $,r as Do,i as DoAsync,a as EmptyListError,e as FailureError,t as LeftError,n as NoneError,o as isDoCapable,c as unwrap};
1
+ import{F as e,I as t,L as n,M as r,N as i,P as a,R as o,j as s,z as c}from"../src-BhBVtHJY.js";export{s as $,r as Do,i as DoAsync,a as EmptyListError,e as FailureError,t as LeftError,n as NoneError,o as isDoCapable,c as unwrap};
@@ -1,2 +1,2 @@
1
- import { S as tryCatchAsync, _ as TypeCheckLeft, b as isRight, g as TestEither, h as Right, m as Left, p as Either, v as TypeCheckRight, x as tryCatch, y as isLeft } from "../index-Di7IFeuy.js";
1
+ import { S as tryCatchAsync, _ as TypeCheckLeft, b as isRight, g as TestEither, h as Right, m as Left, p as Either, v as TypeCheckRight, x as tryCatch, y as isLeft } from "../index-DN9rYP81.js";
2
2
  export { Either, Left, Right, TestEither, TypeCheckLeft, TypeCheckRight, isLeft, isRight, tryCatch, tryCatchAsync };
@@ -1 +1 @@
1
- import{_t as e,dt as t,ft as n,gt as r,ht as i,mt as a,pt as o,ut as s,vt as c}from"../src-DagovFT3.js";export{s as Either,t as Left,n as Right,o as TypeCheckLeft,a as TypeCheckRight,i as isLeft,r as isRight,e as tryCatch,c as tryCatchAsync};
1
+ import{_t as e,dt as t,ft as n,gt as r,ht as i,mt as a,pt as o,ut as s,vt as c}from"../src-BhBVtHJY.js";export{s as Either,t as Left,n as Right,o as TypeCheckLeft,a as TypeCheckRight,i as isLeft,r as isRight,e as tryCatch,c as tryCatchAsync};
@@ -1,4 +1,4 @@
1
- const e=`0.53.0`,t={Option:{description:`Safe nullable handling - Some<T> or None`,interfaces:[`Functor`,`Monad`,`Foldable`,`Extractable`,`Matchable`,`Serializable`,`Traversable`],methods:{create:[`Option(v)`,`Option.none()`,`Some(v)`,`None()`],transform:[`.map(f)`,`.flatMap(f)`,`.filter(p)`,`.ap(ff)`],extract:[`.fold(n, s)`,`.orElse(d)`,`.orThrow()`,`.orNull()`,`.match({Some, None})`],check:[`.isSome`,`.isNone`,`.isDefined`,`.isEmpty`]}},Either:{description:`Error handling with Left (error) or Right (success)`,interfaces:[`Functor`,`Monad`,`Foldable`,`Traversable`,`PromiseLike`],methods:{create:[`Right(v)`,`Left(e)`,`Either.right(v)`,`Either.left(e)`],transform:[`.map(f)`,`.flatMap(f)`,`.mapLeft(f)`,`.swap()`],extract:[`.fold(l, r)`,`.orElse(d)`,`.orThrow()`,`.match({Left, Right})`],check:[`.isRight`,`.isLeft`]}},Try:{description:`Wrap operations that may throw - Success<T> or Failure`,interfaces:[`Functor`,`Monad`,`Foldable`,`Extractable`,`Matchable`,`Serializable`,`Traversable`],methods:{create:[`Try(() => expr)`,`Try.success(v)`,`Try.failure(e)`,`Try.fromPromise(p)`],transform:[`.map(f)`,`.flatMap(f)`,`.recover(f)`,`.recoverWith(f)`],extract:[`.fold(f, s)`,`.orElse(d)`,`.orThrow()`,`.toOption()`,`.toEither()`],check:[`.isSuccess`,`.isFailure`]}},List:{description:`Immutable array with functional operations`,interfaces:[`Functor`,`Monad`,`Foldable`,`Collection`,`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`,`.nonEmpty`,`.size`,`.contains(v)`],other:[`.groupBy(f)`,`.partition(p)`,`.span(p)`]}},Set:{description:`Immutable set of unique values`,interfaces:[`Functor`,`Foldable`,`Collection`,`Serializable`,`Traversable`],methods:{create:[`Set([...])`,`Set.of(...)`,`Set.empty()`],transform:[`.map(f)`,`.filter(p)`,`.union(s)`,`.intersection(s)`,`.difference(s)`,`.add(v)`],extract:[`.fold(z, f)`,`.toArray()`],check:[`.has(v)`,`.isEmpty`,`.size`]}},Obj:{description:`Immutable object wrapper with fluent operations`,interfaces:[`KVTraversable`,`Foldable`,`Matchable`,`Extractable`,`Serializable`,`Reshapeable`,`Doable`],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:[`KVTraversable`,`Collection`,`Serializable`],methods:{create:[`Map([[k, v], ...])`,`Map.of([k, v], ...)`,`Map.empty()`],transform:[`.set(k, v)`,`.delete(k)`,`.map(f)`,`.filter(p)`,`.add(k, v)`],extract:[`.get(k)`,`.keys()`,`.values()`,`.entries()`,`.fold(z, f)`],check:[`.has(k)`,`.isEmpty`,`.size`]}},Lazy:{description:`Deferred computation with memoization`,interfaces:[`Functor`,`Monad`,`Foldable`,`Extractable`,`Serializable`,`Traversable`],methods:{create:[`Lazy(() => expr)`],transform:[`.map(f)`,`.flatMap(f)`],extract:[`.fold(n, s)`,`.orElse(d)`,`.orThrow()`,`.get()`],check:[`.isEvaluated`]}},LazyList:{description:`Lazy sequences for large/infinite data`,interfaces:[`Functor`,`Monad`,`Iterable`],methods:{create:[`LazyList.from(iter)`,`LazyList.range(start, end)`,`LazyList.infinite(f)`],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`,`.toArray()`],check:[`.isEmpty`]}},Task:{description:`Async operations with cancellation and progress tracking. Returns TaskOutcome<T> (Ok/Err) which implements Functor, AsyncMonad, Foldable, Extractable, Serializable`,interfaces:[],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)`],transform:[`.map(f)`,`.flatMap(f)`,`.mapError(f)`,`.recover(v)`,`.recoverWith(f)`],extract:[`.fold(onErr, onOk)`,`.match({Ok, Err})`,`.orElse(v)`,`.orThrow()`,`.toEither()`,`.toOption()`],other:[`Task.cancellable(fn)`,`Task.withProgress(fn, onProgress)`,`Task.race(tasks, timeout?)`,`Task.getErrorChain(error)`,`Task.formatErrorChain(error)`]}},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.fromOption(o)`,`IO.fromTry(t)`],transform:[`.map(f)`,`.flatMap(f)`,`.tap(f)`,`.mapError(f)`,`.recover(v)`,`.recoverWith(f)`],extract:[`.run()`,`.runOrThrow()`,`.runSync()`,`.runSyncOrThrow()`,`.runExit()`,`.runOption()`,`.runTry()`,`.fold(onErr, onOk)`,`.match({failure, success})`],check:[],other:[`.catchTag(tag, f)`,`.catchAll(f)`,`.retry(n)`,`.retryWithDelay(n, ms)`,`.timeout(ms)`,`.delay(ms)`,`.zip(io)`,`.pipe(f)`,`IO.all([...])`,`IO.race([...])`,`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()`]}},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:[`Typeable`,`Valuable`,`Iterable`],methods:{create:[`Tuple([a, b, ...])`,`Tuple.of(a, b, ...)`],extract:[`.first`,`.second`,`.toArray()`],transform:[`.map(f)`]}},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>> with typed errors and auto content-type detection`,interfaces:[],methods:{create:[`Http.get<T>(url)`,`Http.post<T>(url, opts)`,`Http.put<T>(url, opts)`,`Http.patch<T>(url, opts)`,`Http.delete<T>(url, opts)`,`Http.request<T>(opts)`,`Http.client(config)`],transform:[`.map(f)`,`.flatMap(f)`,`.retry(n)`,`.retryWithDelay(n, ms)`,`.timeout(ms)`],extract:[`.run()`,`.runOrThrow()`,`.runOption()`,`.runTry()`],check:[],other:[`.catchTag(tag, handler)`,`.catchAll(handler)`,`.mapError(f)`,`.recover(fallback)`]}},HttpError:{description:`Three-variant ADT for HTTP failures: NetworkError | HttpStatusError | DecodeError`,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 })`]}}},n={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`,`.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`]}},r={Core:[`Option`,`Either`,`Try`,`Obj`],Collection:[`List`,`Set`,`Map`,`LazyList`,`Tuple`,`Stack`],Effect:[`IO`,`Task`,`Http`,`HttpError`],Utility:[`Lazy`,`Cond`,`Match`,`Brand`,`ValidatedBrand`]},i={Option:`export interface Option<T extends Type> extends Functype<T, "Some" | "None">, Promisable<T>, Doable<T>, Reshapeable<T> {
1
+ const e=`0.54.0`,t={Option:{description:`Safe nullable handling - Some<T> or None`,interfaces:[`Functor`,`Monad`,`Foldable`,`Extractable`,`Matchable`,`Serializable`,`Traversable`],methods:{create:[`Option(v)`,`Option.none()`,`Some(v)`,`None()`],transform:[`.map(f)`,`.flatMap(f)`,`.filter(p)`,`.ap(ff)`],extract:[`.fold(n, s)`,`.orElse(d)`,`.orThrow()`,`.orNull()`,`.match({Some, None})`],check:[`.isSome`,`.isNone`,`.isDefined`,`.isEmpty`]}},Either:{description:`Error handling with Left (error) or Right (success)`,interfaces:[`Functor`,`Monad`,`Foldable`,`Traversable`,`PromiseLike`],methods:{create:[`Right(v)`,`Left(e)`,`Either.right(v)`,`Either.left(e)`],transform:[`.map(f)`,`.flatMap(f)`,`.mapLeft(f)`,`.swap()`],extract:[`.fold(l, r)`,`.orElse(d)`,`.orThrow()`,`.match({Left, Right})`],check:[`.isRight`,`.isLeft`]}},Try:{description:`Wrap operations that may throw - Success<T> or Failure`,interfaces:[`Functor`,`Monad`,`Foldable`,`Extractable`,`Matchable`,`Serializable`,`Traversable`],methods:{create:[`Try(() => expr)`,`Try.success(v)`,`Try.failure(e)`,`Try.fromPromise(p)`],transform:[`.map(f)`,`.flatMap(f)`,`.recover(f)`,`.recoverWith(f)`],extract:[`.fold(f, s)`,`.orElse(d)`,`.orThrow()`,`.toOption()`,`.toEither()`],check:[`.isSuccess`,`.isFailure`]}},List:{description:`Immutable array with functional operations`,interfaces:[`Functor`,`Monad`,`Foldable`,`Collection`,`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`,`.nonEmpty`,`.size`,`.contains(v)`],other:[`.groupBy(f)`,`.partition(p)`,`.span(p)`]}},Set:{description:`Immutable set of unique values`,interfaces:[`Functor`,`Foldable`,`Collection`,`Serializable`,`Traversable`],methods:{create:[`Set([...])`,`Set.of(...)`,`Set.empty()`],transform:[`.map(f)`,`.filter(p)`,`.union(s)`,`.intersection(s)`,`.difference(s)`,`.add(v)`],extract:[`.fold(z, f)`,`.toArray()`],check:[`.has(v)`,`.isEmpty`,`.size`]}},Obj:{description:`Immutable object wrapper with fluent operations`,interfaces:[`KVTraversable`,`Foldable`,`Matchable`,`Extractable`,`Serializable`,`Reshapeable`,`Doable`],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:[`KVTraversable`,`Collection`,`Serializable`],methods:{create:[`Map([[k, v], ...])`,`Map.of([k, v], ...)`,`Map.empty()`],transform:[`.set(k, v)`,`.delete(k)`,`.map(f)`,`.filter(p)`,`.add(k, v)`],extract:[`.get(k)`,`.keys()`,`.values()`,`.entries()`,`.fold(z, f)`],check:[`.has(k)`,`.isEmpty`,`.size`]}},Lazy:{description:`Deferred computation with memoization`,interfaces:[`Functor`,`Monad`,`Foldable`,`Extractable`,`Serializable`,`Traversable`],methods:{create:[`Lazy(() => expr)`],transform:[`.map(f)`,`.flatMap(f)`],extract:[`.fold(n, s)`,`.orElse(d)`,`.orThrow()`,`.get()`],check:[`.isEvaluated`]}},LazyList:{description:`Lazy sequences for large/infinite data`,interfaces:[`Functor`,`Monad`,`Iterable`],methods:{create:[`LazyList.from(iter)`,`LazyList.range(start, end)`,`LazyList.infinite(f)`],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`,`.toArray()`],check:[`.isEmpty`]}},Task:{description:`Async operations with cancellation and progress tracking. Returns TaskOutcome<T> (Ok/Err) which implements Functor, AsyncMonad, Foldable, Extractable, Serializable`,interfaces:[],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)`],transform:[`.map(f)`,`.flatMap(f)`,`.mapError(f)`,`.recover(v)`,`.recoverWith(f)`],extract:[`.fold(onErr, onOk)`,`.match({Ok, Err})`,`.orElse(v)`,`.orThrow()`,`.toEither()`,`.toOption()`],other:[`Task.cancellable(fn)`,`Task.withProgress(fn, onProgress)`,`Task.race(tasks, timeout?)`,`Task.getErrorChain(error)`,`Task.formatErrorChain(error)`]}},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.fromOption(o)`,`IO.fromTry(t)`],transform:[`.map(f)`,`.flatMap(f)`,`.tap(f)`,`.mapError(f)`,`.recover(v)`,`.recoverWith(f)`],extract:[`.run()`,`.runOrThrow()`,`.runSync()`,`.runSyncOrThrow()`,`.runExit()`,`.runOption()`,`.runTry()`,`.fold(onErr, onOk)`,`.match({failure, success})`],check:[],other:[`.catchTag(tag, f)`,`.catchAll(f)`,`.retry(n)`,`.retryWithDelay(n, ms)`,`.timeout(ms)`,`.delay(ms)`,`.zip(io)`,`.pipe(f)`,`IO.all([...])`,`IO.race([...])`,`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()`]}},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:[`Typeable`,`Valuable`,`Iterable`],methods:{create:[`Tuple([a, b, ...])`,`Tuple.of(a, b, ...)`],extract:[`.first`,`.second`,`.toArray()`],transform:[`.map(f)`]}},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<unknown>> by default. Provide a validate function to get typed responses (BYOV: bring your own validator). Works with Zod, TypeBox, Valibot, or manual validators.`,interfaces:[],methods:{create:[`Http.get(url, { validate }?)`,`Http.post(url, { body, validate }?)`,`Http.put(url, { body, validate }?)`,`Http.patch(url, { body, validate }?)`,`Http.delete(url, { validate }?)`,`Http.request({ url, validate })`,`Http.client(config)`],transform:[`.map(f)`,`.flatMap(f)`,`.retry(n)`,`.retryWithDelay(n, ms)`,`.timeout(ms)`],extract:[`.run()`,`.runOrThrow()`,`.runOption()`,`.runTry()`],check:[],other:[`.catchTag(tag, handler)`,`.catchAll(handler)`,`.mapError(f)`,`.recover(fallback)`]}},HttpError:{description:`Three-variant ADT for HTTP failures: NetworkError | HttpStatusError | DecodeError`,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 })`]}}},n={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`,`.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`]}},r={Core:[`Option`,`Either`,`Try`,`Obj`],Collection:[`List`,`Set`,`Map`,`LazyList`,`Tuple`,`Stack`],Effect:[`IO`,`Task`,`Http`,`HttpError`],Utility:[`Lazy`,`Cond`,`Match`,`Brand`,`ValidatedBrand`]},i={Option:`export interface Option<T extends Type> extends Functype<T, "Some" | "None">, Promisable<T>, Doable<T>, Reshapeable<T> {
2
2
  /** The contained value (undefined for None) */
3
3
  readonly value: T | undefined
4
4
  /** Whether this Option contains no value */
@@ -3222,19 +3222,21 @@ declare const HttpError: {
3222
3222
  //#endregion
3223
3223
  //#region src/fetch/HttpRequest.d.ts
3224
3224
  type ParseMode = "json" | "text" | "blob" | "arrayBuffer" | "raw";
3225
- interface HttpRequestOptions {
3225
+ interface HttpRequestOptions<T = unknown> {
3226
3226
  readonly url: string;
3227
3227
  readonly method: HttpMethod;
3228
3228
  readonly headers?: Record<string, string>;
3229
3229
  readonly body?: unknown;
3230
3230
  readonly signal?: AbortSignal;
3231
3231
  readonly parseAs?: ParseMode;
3232
+ readonly validate?: (data: unknown) => T;
3232
3233
  }
3233
- interface HttpMethodOptions {
3234
+ interface HttpMethodOptions<T = unknown> {
3234
3235
  readonly headers?: Record<string, string>;
3235
3236
  readonly body?: unknown;
3236
3237
  readonly signal?: AbortSignal;
3237
3238
  readonly parseAs?: ParseMode;
3239
+ readonly validate?: (data: unknown) => T;
3238
3240
  }
3239
3241
  interface HttpResponse<T> {
3240
3242
  readonly data: T;
@@ -3245,24 +3247,24 @@ interface HttpResponse<T> {
3245
3247
  //#endregion
3246
3248
  //#region src/fetch/Http.d.ts
3247
3249
  type HttpMethods = {
3248
- readonly request: <T>(options: HttpRequestOptions) => IO<never, HttpError, HttpResponse<T>>;
3249
- readonly get: <T>(url: string, options?: HttpMethodOptions) => IO<never, HttpError, HttpResponse<T>>;
3250
- readonly post: <T>(url: string, options?: HttpMethodOptions) => IO<never, HttpError, HttpResponse<T>>;
3251
- readonly put: <T>(url: string, options?: HttpMethodOptions) => IO<never, HttpError, HttpResponse<T>>;
3252
- readonly patch: <T>(url: string, options?: HttpMethodOptions) => IO<never, HttpError, HttpResponse<T>>;
3253
- readonly delete: <T>(url: string, options?: HttpMethodOptions) => IO<never, HttpError, HttpResponse<T>>;
3250
+ readonly request: <T = unknown>(options: HttpRequestOptions<T>) => IO<never, HttpError, HttpResponse<T>>;
3251
+ readonly get: <T = unknown>(url: string, options?: HttpMethodOptions<T>) => IO<never, HttpError, HttpResponse<T>>;
3252
+ readonly post: <T = unknown>(url: string, options?: HttpMethodOptions<T>) => IO<never, HttpError, HttpResponse<T>>;
3253
+ readonly put: <T = unknown>(url: string, options?: HttpMethodOptions<T>) => IO<never, HttpError, HttpResponse<T>>;
3254
+ readonly patch: <T = unknown>(url: string, options?: HttpMethodOptions<T>) => IO<never, HttpError, HttpResponse<T>>;
3255
+ readonly delete: <T = unknown>(url: string, options?: HttpMethodOptions<T>) => IO<never, HttpError, HttpResponse<T>>;
3254
3256
  readonly head: (url: string, options?: HttpMethodOptions) => IO<never, HttpError, HttpResponse<void>>;
3255
3257
  readonly options: (url: string, options?: HttpMethodOptions) => IO<never, HttpError, HttpResponse<void>>;
3256
3258
  };
3257
3259
  declare const Http: {
3258
3260
  readonly _tag: "Http";
3259
3261
  } & {
3260
- request: <T>(options: HttpRequestOptions) => IO<never, HttpError, HttpResponse<T>>;
3261
- get: <T>(url: string, options?: HttpMethodOptions) => IO<never, HttpError, HttpResponse<T>>;
3262
- post: <T>(url: string, options?: HttpMethodOptions) => IO<never, HttpError, HttpResponse<T>>;
3263
- put: <T>(url: string, options?: HttpMethodOptions) => IO<never, HttpError, HttpResponse<T>>;
3264
- patch: <T>(url: string, options?: HttpMethodOptions) => IO<never, HttpError, HttpResponse<T>>;
3265
- delete: <T>(url: string, options?: HttpMethodOptions) => IO<never, HttpError, HttpResponse<T>>;
3262
+ request: <T = unknown>(options: HttpRequestOptions<T>) => IO<never, HttpError, HttpResponse<T>>;
3263
+ get: <T = unknown>(url: string, options?: HttpMethodOptions<T>) => IO<never, HttpError, HttpResponse<T>>;
3264
+ post: <T = unknown>(url: string, options?: HttpMethodOptions<T>) => IO<never, HttpError, HttpResponse<T>>;
3265
+ put: <T = unknown>(url: string, options?: HttpMethodOptions<T>) => IO<never, HttpError, HttpResponse<T>>;
3266
+ patch: <T = unknown>(url: string, options?: HttpMethodOptions<T>) => IO<never, HttpError, HttpResponse<T>>;
3267
+ delete: <T = unknown>(url: string, options?: HttpMethodOptions<T>) => IO<never, HttpError, HttpResponse<T>>;
3266
3268
  head: (url: string, options?: HttpMethodOptions) => IO<never, HttpError, HttpResponse<void>>;
3267
3269
  options: (url: string, options?: HttpMethodOptions) => IO<never, HttpError, HttpResponse<void>>;
3268
3270
  client: (config: HttpClientConfig) => HttpMethods;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
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-BJIRbUKB.js";
2
- import { $ as Identity, $n as ContainerOps, $t as TaskErrorInfo, A as OptionConstructor, An as Companion, At as LayerError, B as fromBinary, Bn as PositiveNumber, Bt as FieldValidation, C as Functype, Cn as Base, Ct as IO, D as List, Dn as CompanionMethods, Dt as TimeoutError, E as Collection, En as Cond, Et as Task, F as Set, Fn as IntegerNumber, Ft as Context, G as Matchable, Gn as Try, Gt as ErrorCode, H as fromYAML, Hn as UrlString, Ht as Validation, I as SerializationResult, In as NonEmptyString, It as ContextServices, J as ESMapType, Jn as Applicative, Jt as TypedError, K as MatchableUtils, Kn as TypeNames, Kt as ErrorMessage, L as createCustomSerializer, Ln as NonNegativeNumber, Lt as HasService, M as Stack, Mn as BoundedString, Mt as LayerOutput, N as Valuable, Nn as EmailAddress, Nt as Exit, O as None, On as InstanceType, Ot as UIO, P as ValuableParams, Pn as ISO8601Date, Pt as ExitTag, Q as Lazy, Qn as CollectionOps, Qt as ErrorWithTaskInfo, R as createSerializationCompanion, Rn as PatternString, Rt as Tag, S as tryCatchAsync, Sn as ThrowableType, St as TestContext, T as FunctypeCollection, Tn as UntypedMatch, Tt as RIO, U as Ref, Un as ValidatedBrand, Ut as ValidationRule, V as fromJSON, Vn as UUID, Vt as FormValidation, W as Obj, Wn as ValidatedBrandCompanion, Wt as Validator, X as KVTraversable, Xn as Functor, Xt as ErrorChainElement, Y as Map, Yn as AsyncMonad, Yt as TypedErrorContext, Z as Traversable, Zn as Monad, Zt as ErrorFormatterOptions, _ as TypeCheckLeft, _n as TaskSuccess, _t as NetworkError, a as EmptyListError, an as CancellationToken, ar as ParseError, at as TryKind, b as isRight, bn as NAME, bt as TestClock, c as LeftError, cn as Ok, ct as Http, d as isDoCapable, dn as Task$1, dt as HttpResponse, en as createErrorSerializer, er as LazyList, et as EitherKind, f as unwrap, fn as TaskFailure, ft as ParseMode, g as TestEither, gn as TaskResult, gt as HttpStatusError, h as Right, hn as TaskParams, ht as HttpMethod, i as DoGenerator, in as Async, ir as Doable, it as OptionKind, j as Some, jn as BoundedNumber, jt as LayerInput, k as Option, kn as isCompanion, kt as Layer, l as LeftErrorType, ln as Sync, lt as HttpMethodOptions, m as Left, mn as TaskOutcome, mt as HttpError, n as Do, nn as formatStackTrace, nr as isExtractable, nt as Kind, o as FailureError, on as CancellationTokenSource, ot as UniversalContainer, p as Either, pn as TaskMetadata, pt as DecodeError, q as ESMap, qn as Promisable, qt as ErrorStatus, r as DoAsync, rn as safeStringify, rr as DoResult, rt as ListKind, s as FailureErrorType, sn as Err, st as FoldableUtils, t as $, tn as formatError, tr as Extractable, tt as HKT, u as NoneError, un as TaggedThrowable, ut as HttpRequestOptions, v as TypeCheckRight, vn as createCancellationTokenSource, vt as HttpClient, w as FunctypeBase, wn as Match, wt as InterruptedError, x as tryCatch, xn as Throwable, xt as TestClockTag, y as isLeft, yn as isTaggedThrowable, yt as HttpClientConfig, z as createSerializer, zn as PositiveInteger, zt as TagService } from "./index-Di7IFeuy.js";
2
+ import { $ as Identity, $n as ContainerOps, $t as TaskErrorInfo, A as OptionConstructor, An as Companion, At as LayerError, B as fromBinary, Bn as PositiveNumber, Bt as FieldValidation, C as Functype, Cn as Base, Ct as IO, D as List, Dn as CompanionMethods, Dt as TimeoutError, E as Collection, En as Cond, Et as Task, F as Set, Fn as IntegerNumber, Ft as Context, G as Matchable, Gn as Try, Gt as ErrorCode, H as fromYAML, Hn as UrlString, Ht as Validation, I as SerializationResult, In as NonEmptyString, It as ContextServices, J as ESMapType, Jn as Applicative, Jt as TypedError, K as MatchableUtils, Kn as TypeNames, Kt as ErrorMessage, L as createCustomSerializer, Ln as NonNegativeNumber, Lt as HasService, M as Stack, Mn as BoundedString, Mt as LayerOutput, N as Valuable, Nn as EmailAddress, Nt as Exit, O as None, On as InstanceType, Ot as UIO, P as ValuableParams, Pn as ISO8601Date, Pt as ExitTag, Q as Lazy, Qn as CollectionOps, Qt as ErrorWithTaskInfo, R as createSerializationCompanion, Rn as PatternString, Rt as Tag, S as tryCatchAsync, Sn as ThrowableType, St as TestContext, T as FunctypeCollection, Tn as UntypedMatch, Tt as RIO, U as Ref, Un as ValidatedBrand, Ut as ValidationRule, V as fromJSON, Vn as UUID, Vt as FormValidation, W as Obj, Wn as ValidatedBrandCompanion, Wt as Validator, X as KVTraversable, Xn as Functor, Xt as ErrorChainElement, Y as Map, Yn as AsyncMonad, Yt as TypedErrorContext, Z as Traversable, Zn as Monad, Zt as ErrorFormatterOptions, _ as TypeCheckLeft, _n as TaskSuccess, _t as NetworkError, a as EmptyListError, an as CancellationToken, ar as ParseError, at as TryKind, b as isRight, bn as NAME, bt as TestClock, c as LeftError, cn as Ok, ct as Http, d as isDoCapable, dn as Task$1, dt as HttpResponse, en as createErrorSerializer, er as LazyList, et as EitherKind, f as unwrap, fn as TaskFailure, ft as ParseMode, g as TestEither, gn as TaskResult, gt as HttpStatusError, h as Right, hn as TaskParams, ht as HttpMethod, i as DoGenerator, in as Async, ir as Doable, it as OptionKind, j as Some, jn as BoundedNumber, jt as LayerInput, k as Option, kn as isCompanion, kt as Layer, l as LeftErrorType, ln as Sync, lt as HttpMethodOptions, m as Left, mn as TaskOutcome, mt as HttpError, n as Do, nn as formatStackTrace, nr as isExtractable, nt as Kind, o as FailureError, on as CancellationTokenSource, ot as UniversalContainer, p as Either, pn as TaskMetadata, pt as DecodeError, q as ESMap, qn as Promisable, qt as ErrorStatus, r as DoAsync, rn as safeStringify, rr as DoResult, rt as ListKind, s as FailureErrorType, sn as Err, st as FoldableUtils, t as $, tn as formatError, tr as Extractable, tt as HKT, u as NoneError, un as TaggedThrowable, ut as HttpRequestOptions, v as TypeCheckRight, vn as createCancellationTokenSource, vt as HttpClient, w as FunctypeBase, wn as Match, wt as InterruptedError, x as tryCatch, xn as Throwable, xt as TestClockTag, y as isLeft, yn as isTaggedThrowable, yt as HttpClientConfig, z as createSerializer, zn as PositiveInteger, zt as TagService } from "./index-DN9rYP81.js";
3
3
  import { a as isTypeable, c as Pipe, i as TypeableParams, l as Foldable, n as ExtractTag, o as Serializable, r as Typeable, s as SerializationMethods, t as Tuple, u as Type } from "./Tuple-DwyoW0ZP.js";
4
4
  export { $, Applicative, Async, AsyncMonad, Base, BoundedNumber, BoundedString, Brand, BrandedBoolean, BrandedBoolean as BrandedBooleanType, BrandedNumber, BrandedNumber as BrandedNumberType, BrandedString, BrandedString as BrandedStringType, CancellationToken, CancellationTokenSource, Collection, CollectionOps, Companion, CompanionMethods, Cond, ContainerOps, Context, Context as ContextType, ContextServices, DecodeError, Do, DoAsync, DoGenerator, DoResult, Doable, ESMap, ESMapType, Either, EitherKind, EmailAddress, EmptyListError, Err, ErrorChainElement, ErrorCode, ErrorFormatterOptions, ErrorMessage, ErrorStatus, ErrorWithTaskInfo, Exit, Exit as ExitType, ExitTag, ExtractBrand, ExtractTag, Extractable, FailureError, FailureErrorType, FieldValidation, Foldable, FoldableUtils, FormValidation, Functor, Functype, FunctypeBase, FunctypeCollection, HKT, HasService, Http, HttpClient, HttpClientConfig, HttpError, HttpError as HttpErrors, HttpMethod, HttpMethodOptions, HttpRequestOptions, HttpResponse, HttpStatusError, IO, IO as IOType, Task as IOTask, ISO8601Date, Identity, InstanceType, IntegerNumber, InterruptedError, KVTraversable, Kind, Layer, Layer as LayerType, LayerError, LayerInput, LayerOutput, Lazy, Lazy as LazyType, LazyList, Left, LeftError, LeftErrorType, List, ListKind, Map, Match, Matchable, MatchableUtils, Monad, NAME, NetworkError, NonEmptyString, NonNegativeNumber, None, NoneError, Obj, Ok, Option, OptionConstructor, OptionKind, ParseError, ParseMode, PatternString, Pipe, PositiveInteger, PositiveNumber, Promisable, RIO, Ref, Ref as RefType, Right, Serializable, SerializationMethods, SerializationResult, Set, Some, Stack, Sync, Tag, Tag as TagType, TagService, TaggedThrowable, Task$1 as Task, TaskErrorInfo, TaskFailure, TaskMetadata, TaskOutcome, TaskParams, TaskResult, TaskSuccess, TestClock, TestClock as TestClockType, TestClockTag, TestContext, TestContext as TestContextType, TestEither, Throwable, ThrowableType, TimeoutError, Traversable, Try, TryKind, Tuple, Type, TypeCheckLeft, TypeCheckRight, TypeNames, Typeable, TypeableParams, TypedError, TypedErrorContext, UIO, UUID, UniversalContainer, UntypedMatch, Unwrap, UrlString, ValidatedBrand, ValidatedBrand as ValidatedBrandType, ValidatedBrandCompanion, Validation, ValidationRule, Validator, Valuable, ValuableParams, createBrander, createCancellationTokenSource, createCustomSerializer, createErrorSerializer, createSerializationCompanion, createSerializer, formatError, formatStackTrace, fromBinary, fromJSON, fromYAML, hasBrand, isCompanion, isDoCapable, isExtractable, isLeft, isRight, isTaggedThrowable, isTypeable, safeStringify, tryCatch, tryCatchAsync, unwrap, unwrapBrand };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{Brand as e,BrandedBoolean as t,BrandedNumber as n,BrandedString as r,createBrander as i,hasBrand as a,unwrap as o}from"./branded/index.js";import{$ as s,A as c,At as l,B as u,C as d,Ct as f,D as p,Dt as m,E as h,Et as g,F as _,Ft as v,G as y,H as b,I as x,It as S,J as C,K as w,L as T,M as E,Mt as D,N as O,Nt as k,O as A,Ot as j,P as M,Pt as N,Q as P,R as F,S as I,St as L,T as R,Tt as z,U as B,V,W as H,X as U,Y as W,Z as G,_ as K,_t as q,a as J,at as Y,b as X,bt as Z,c as Q,ct as $,d as ee,dt as te,et as ne,f as re,ft as ie,g as ae,gt as oe,h as se,ht as ce,i as le,it as ue,j as de,jt as fe,k as pe,kt as me,l as he,lt as ge,m as _e,mt as ve,n as ye,nt as be,o as xe,ot as Se,p as Ce,pt as we,q as Te,r as Ee,rt as De,s as Oe,st as ke,t as Ae,tt as je,u as Me,ut as Ne,v as Pe,vt as Fe,w as Ie,wt as Le,x as Re,xt as ze,y as Be,yt as Ve,z as He}from"./src-DagovFT3.js";import{r as Ue,t as We}from"./Tuple-DY00RBep.js";export{de as $,Te as Base,G as BoundedNumber,P as BoundedString,e as Brand,t as BrandedBoolean,n as BrandedNumber,r as BrandedString,Ue as Companion,W as Cond,d as Context,E as Do,O as DoAsync,xe as ESMap,Ne as Either,s as EmailAddress,M as EmptyListError,u as Err,I as Exit,_ as FailureError,Me as FoldableUtils,he as HKT,ee as Http,Ce as HttpClient,re as HttpErrors,Be as IO,ne as ISO8601Date,Q as Identity,je as IntegerNumber,X as InterruptedError,Pe as Layer,Oe as Lazy,f as LazyList,te as Left,x as LeftError,Ve as List,J as Map,C as Match,le as MatchableUtils,y as NAME,be as NonEmptyString,De as NonNegativeNumber,g as None,T as NoneError,Ee as Obj,V as Ok,m as Option,j as OptionConstructor,S as ParseError,ue as PatternString,Y as PositiveInteger,Se as PositiveNumber,Le as Ref,ie as Right,z as Set,me as Some,ye as Stack,K as Tag,b as Task,_e as TestClock,se as TestClockTag,ae as TestContext,w as Throwable,Re as TimeoutError,L as Try,We as Tuple,we as TypeCheckLeft,ve as TypeCheckRight,Z as Typeable,h as TypedError,ke as UUID,$ as UrlString,ge as ValidatedBrand,R as Validation,Ae as Valuable,i as createBrander,B as createCancellationTokenSource,l as createCustomSerializer,p as createErrorSerializer,fe as createSerializationCompanion,D as createSerializer,A as formatError,pe as formatStackTrace,k as fromBinary,N as fromJSON,v as fromYAML,a as hasBrand,U as isCompanion,F as isDoCapable,Ie as isExtractable,ce as isLeft,oe as isRight,H as isTaggedThrowable,ze as isTypeable,c as safeStringify,q as tryCatch,Fe as tryCatchAsync,He as unwrap,o as unwrapBrand};
1
+ import{Brand as e,BrandedBoolean as t,BrandedNumber as n,BrandedString as r,createBrander as i,hasBrand as a,unwrap as o}from"./branded/index.js";import{$ as s,A as c,At as l,B as u,C as d,Ct as f,D as p,Dt as m,E as h,Et as g,F as _,Ft as v,G as y,H as b,I as x,It as S,J as C,K as w,L as T,M as E,Mt as D,N as O,Nt as k,O as A,Ot as j,P as M,Pt as N,Q as P,R as F,S as I,St as L,T as R,Tt as z,U as B,V,W as H,X as U,Y as W,Z as G,_ as K,_t as q,a as J,at as Y,b as X,bt as Z,c as Q,ct as $,d as ee,dt as te,et as ne,f as re,ft as ie,g as ae,gt as oe,h as se,ht as ce,i as le,it as ue,j as de,jt as fe,k as pe,kt as me,l as he,lt as ge,m as _e,mt as ve,n as ye,nt as be,o as xe,ot as Se,p as Ce,pt as we,q as Te,r as Ee,rt as De,s as Oe,st as ke,t as Ae,tt as je,u as Me,ut as Ne,v as Pe,vt as Fe,w as Ie,wt as Le,x as Re,xt as ze,y as Be,yt as Ve,z as He}from"./src-BhBVtHJY.js";import{r as Ue,t as We}from"./Tuple-DY00RBep.js";export{de as $,Te as Base,G as BoundedNumber,P as BoundedString,e as Brand,t as BrandedBoolean,n as BrandedNumber,r as BrandedString,Ue as Companion,W as Cond,d as Context,E as Do,O as DoAsync,xe as ESMap,Ne as Either,s as EmailAddress,M as EmptyListError,u as Err,I as Exit,_ as FailureError,Me as FoldableUtils,he as HKT,ee as Http,Ce as HttpClient,re as HttpErrors,Be as IO,ne as ISO8601Date,Q as Identity,je as IntegerNumber,X as InterruptedError,Pe as Layer,Oe as Lazy,f as LazyList,te as Left,x as LeftError,Ve as List,J as Map,C as Match,le as MatchableUtils,y as NAME,be as NonEmptyString,De as NonNegativeNumber,g as None,T as NoneError,Ee as Obj,V as Ok,m as Option,j as OptionConstructor,S as ParseError,ue as PatternString,Y as PositiveInteger,Se as PositiveNumber,Le as Ref,ie as Right,z as Set,me as Some,ye as Stack,K as Tag,b as Task,_e as TestClock,se as TestClockTag,ae as TestContext,w as Throwable,Re as TimeoutError,L as Try,We as Tuple,we as TypeCheckLeft,ve as TypeCheckRight,Z as Typeable,h as TypedError,ke as UUID,$ as UrlString,ge as ValidatedBrand,R as Validation,Ae as Valuable,i as createBrander,B as createCancellationTokenSource,l as createCustomSerializer,p as createErrorSerializer,fe as createSerializationCompanion,D as createSerializer,A as formatError,pe as formatStackTrace,k as fromBinary,N as fromJSON,v as fromYAML,a as hasBrand,U as isCompanion,F as isDoCapable,Ie as isExtractable,ce as isLeft,oe as isRight,H as isTaggedThrowable,ze as isTypeable,c as safeStringify,q as tryCatch,Fe as tryCatchAsync,He as unwrap,o as unwrapBrand};
@@ -1,2 +1,2 @@
1
- import { D as List } from "../index-Di7IFeuy.js";
1
+ import { D as List } from "../index-DN9rYP81.js";
2
2
  export { List };
@@ -1 +1 @@
1
- import{yt as e}from"../src-DagovFT3.js";export{e as List};
1
+ import{yt as e}from"../src-BhBVtHJY.js";export{e as List};
@@ -1,2 +1,2 @@
1
- import { Y as Map } from "../index-Di7IFeuy.js";
1
+ import { Y as Map } from "../index-DN9rYP81.js";
2
2
  export { Map };
package/dist/map/index.js CHANGED
@@ -1 +1 @@
1
- import{a as e}from"../src-DagovFT3.js";export{e as Map};
1
+ import{a as e}from"../src-BhBVtHJY.js";export{e as Map};
@@ -1,2 +1,2 @@
1
- import { A as OptionConstructor, O as None, j as Some, k as Option } from "../index-Di7IFeuy.js";
1
+ import { A as OptionConstructor, O as None, j as Some, k as Option } from "../index-DN9rYP81.js";
2
2
  export { None, Option, OptionConstructor, Some };
@@ -1 +1 @@
1
- import{Dt as e,Et as t,Ot as n,kt as r}from"../src-DagovFT3.js";export{t as None,e as Option,n as OptionConstructor,r as Some};
1
+ import{Dt as e,Et as t,Ot as n,kt as r}from"../src-BhBVtHJY.js";export{t as None,e as Option,n as OptionConstructor,r as Some};
@@ -1,2 +1,2 @@
1
- import { F as Set } from "../index-Di7IFeuy.js";
1
+ import { F as Set } from "../index-DN9rYP81.js";
2
2
  export { Set };
package/dist/set/index.js CHANGED
@@ -1 +1 @@
1
- import{Tt as e}from"../src-DagovFT3.js";export{e as Set};
1
+ import{Tt as e}from"../src-BhBVtHJY.js";export{e as Set};
@@ -13,7 +13,7 @@ import{Brand as e}from"./branded/index.js";import{i as t,n,r,t as i}from"./Tuple
13
13
  `);return[t[0],...t.slice(1).map(e=>e.trim())].join(`
14
14
  `)}function _t(e,t){let n={...mt,...t},r=e instanceof Error?e:Xe.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=gt(e.stack).split(`
15
15
  `).slice(1),i=n.maxStackFrames??mt.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${ht(e)}`:`\n\nContext:\n${ht(e)}`;a+=t}}return a}function vt(){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?gt(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?gt(e.stack):void 0})))}catch{}return Object.getOwnPropertyNames(t).forEach(e=>{n[e]||(n[e]=t[e])}),n}}const j=(e,n,r,i)=>t(Xe.apply(n,r,{name:e,description:n}),{code:e,message:n,status:yt(e),context:r,timestamp:new Date().toISOString(),traceId:i?.traceId}),yt=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],M=Object.assign(j,{validation:(e,t,n)=>j(`VALIDATION_FAILED`,`Validation failed: ${e} ${n}`,{field:e,value:t,rule:n}),network:(e,t,n)=>j(`NETWORK_ERROR`,`Network error: ${t} ${e}${n?` (${n})`:``}`,{url:e,method:t,statusCode:n}),auth:(e,t)=>j(`AUTH_REQUIRED`,`Authentication required: ${e}${t?` (role: ${t})`:``}`,{resource:e,requiredRole:t}),notFound:(e,t)=>j(`NOT_FOUND`,`Not found: ${e} with id ${t}`,{resource:e,id:t}),permission:(e,t,n)=>j(`PERMISSION_DENIED`,`Permission denied: cannot ${e} ${t}`,{action:e,resource:t,userId:n}),rateLimit:(e,t,n)=>j(`RATE_LIMITED`,`Rate limit exceeded: ${e} requests per ${t}`,{limit:e,window:t,retryAfter:n}),internal:e=>j(`INTERNAL_ERROR`,`Internal server error: ${e}`,{errorId:e,timestamp:new Date().toISOString()}),badRequest:(e,t)=>j(`BAD_REQUEST`,`Bad request: ${e}`,{reason:e,expected:t}),conflict:(e,t)=>j(`CONFLICT`,`Conflict: ${e} already exists with value ${t}`,{resource:e,conflictingValue:t}),timeout:(e,t)=>j(`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}),N={rule:e=>t=>{if(e===`email`)return typeof t!=`string`||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)?T(M.validation(`value`,t,`must be a valid email`)):w(t);if(e===`url`)try{return new URL(String(t)),w(t)}catch{return T(M.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(M.validation(`value`,t,`must be a valid UUID`)):w(t);if(e===`required`)return t==null||t===``?T(M.validation(`value`,t,`is required`)):w(t);if(e===`numeric`)return typeof t!=`number`&&!/^\d+$/.test(String(t))?T(M.validation(`value`,t,`must be numeric`)):w(t);if(e===`alpha`)return typeof t!=`string`||!/^[a-zA-Z]+$/.test(t)?T(M.validation(`value`,t,`must contain only letters`)):w(t);if(e===`alphanumeric`)return typeof t!=`string`||!/^[a-zA-Z0-9]+$/.test(t)?T(M.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(M.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(M.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(M.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(M.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(M.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(M.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(M.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(M.validation(`value`,t,`must be a valid date`)):w(t)}if(e===`future`){let e=new Date(String(t));return isNaN(e.getTime())||e<=new Date?T(M.validation(`value`,t,`must be a future date`)):w(t)}if(e===`past`){let e=new Date(String(t));return isNaN(e.getTime())||e>=new Date?T(M.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(M.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=M.validation(i,e,t.context.rule);n.push(r)}else r[i]=o.orThrow()}return n.length>0?T(C(n)):w(r)}},bt={...N,validators:{email:N.rule(`email`),url:N.rule(`url`),uuid:N.rule(`uuid`),required:N.rule(`required`),numeric:N.rule(`numeric`),positiveNumber:N.combine(N.rule(`numeric`),N.rule(`min:0`)),nonEmptyString:N.combine(N.rule(`required`),N.custom(e=>typeof e==`string`&&e.trim().length>0,`must not be empty`))}},xt=t(N.rule,bt);function St(e){return typeof e==`object`&&!!e&&`orThrow`in e&&typeof e.orThrow==`function`}function Ct(e){return St(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 wt=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),wt(r)},merge(t){let n=new Map(e);for(let[e,r]of t.services)n.set(e,r);return wt(n)},get size(){return e.size},toString(){return`Context(${Array.from(e.keys()).join(`, `)})`}}),P={empty:()=>wt(new Map),make:(e,t)=>{let n=new Map;return n.set(e.id,t),wt(n)},isContext:e=>typeof e==`object`&&!!e&&e._tag===`Context`},F=e=>({[Symbol.toStringTag]:`Exit`,_tag:`Success`,isSuccess(){return!0},isFailure(){return!1},isInterrupted(){return!1},map(t){return F(t(e))},mapError(t){return F(e)},mapBoth(t,n){return F(n(e))},flatMap(t){return t(e)},fold(t,n,r){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(${n(e)})`},toJSON(){return{_tag:`Success`,value:e}}}),Tt=e=>({[Symbol.toStringTag]:`Exit`,_tag:`Failure`,isSuccess(){return!1},isFailure(){return!0},isInterrupted(){return!1},map(t){return Tt(e)},mapError(t){return Tt(t(e))},mapBoth(t,n){return Tt(t(e))},flatMap(t){return Tt(e)},fold(t,n,r){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(${n(e)})`},toJSON(){return{_tag:`Failure`,error:e}}}),Et=e=>({[Symbol.toStringTag]:`Exit`,_tag:`Interrupted`,isSuccess(){return!1},isFailure(){return!1},isInterrupted(){return!0},map(t){return Et(e)},mapError(t){return Et(e)},mapBoth(t,n){return Et(e)},flatMap(t){return Et(e)},fold(t,n,r){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}}}),I=r(e=>F(e),{succeed:e=>F(e),fail:e=>Tt(e),interrupt:e=>Et(e),interrupted:()=>Et(`interrupted`),isSuccess:e=>e.isSuccess(),isFailure:e=>e.isFailure(),isInterrupted:e=>e.isInterrupted(),fromEither:e=>e.isRight()?F(e.value):Tt(e.value),fromOption:(e,t)=>e.isSome()?F(e.value):Tt(t()),zip:(e,t)=>e.isInterrupted()?e:t.isInterrupted()?t:e.isFailure()?e:t.isFailure()?t:F([e.orThrow(),t.orThrow()]),all:e=>{let t=[];for(let n of e){if(n.isInterrupted()||n.isFailure())return n;t.push(n.orThrow())}return F(t)}}),L=e=>e;var Dt=class extends Error{constructor(e,t){super(t??`Effect timed out after ${e}ms`),this.duration=e,this._tag=`TimeoutError`,this.name=`TimeoutError`}},Ot=class extends Error{constructor(e){super(e??`Effect was interrupted`),this._tag=`InterruptedError`,this.name=`InterruptedError`}};const R=e=>{let t={[Symbol.toStringTag]:`IO`,_effect:e,map(e){return R(L({_tag:`Map`,effect:t,f:e}))},flatMap(e){return R(L({_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 R(L({_tag:`MapError`,effect:t,f:e}))},tapError(e){return t.mapError(t=>(e(t),t))},recover(e){return R(L({_tag:`Recover`,effect:t,fallback:e}))},recoverWith(e){return R(L({_tag:`RecoverWith`,effect:t,f:e}))},fold(e,n){return R(L({_tag:`Fold`,effect:t,onFailure:e,onSuccess:n}))},match(e){return t.fold(e.failure,e.success)},catchTag(e,n){return R(L({_tag:`RecoverWith`,effect:t,f:t=>typeof t==`object`&&t&&`_tag`in t&&t._tag===e?L(n(t)):L(V.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(()=>V.sleep(n).flatMap(()=>t.retryWithDelay(e-1,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 R(L({_tag:`ProvideContext`,effect:t,context:e}))},provideService(e,n){return R(L({_tag:`ProvideContext`,effect:t,context:P.make(e,n)}))},provideLayer(e){return L(L(V.async(async()=>{let t=P.empty();return await e.build(L(t))})).flatMap(e=>R(L({_tag:`ProvideContext`,effect:t,context:e}))))},async run(){let e=await B(this._effect);return e.isSuccess()?w(e.orThrow()):T(e.isFailure()?e.toValue().error:new Ot)},async runOrThrow(){let e=await B(this._effect);if(e.isSuccess())return e.orThrow();throw e.isFailure()?e.toValue().error:new Ot},runSync(){try{return w(z(this._effect))}catch(e){return T(e)}},runSyncOrThrow(){return z(this._effect)},async runExit(){return B(this._effect)},async runOption(){let e=await B(this._effect);return e.isSuccess()?d(e.orThrow()):p()},async runTry(){let e=await B(this._effect);if(e.isSuccess())return L(x(()=>e.orThrow()));let t=e.isFailure()?e.toValue().error:Error(`Effect was interrupted`);return L(x(()=>{throw t}))},pipe(e){return e(t)},delay(e){return L(V.async(()=>new Promise(t=>setTimeout(t,e))).flatMap(()=>t))},timeout(e){return R(L({_tag:`Timeout`,effect:t,duration:e}))},timeoutTo(e,n){return L(t.timeout(e).recover(L(n)))},toString(){return`IO(${n(e._tag)})`},toJSON(){return{_tag:`IO`,effect:e._tag}},*[Symbol.iterator](){return yield t}};return t},z=(e,t=P.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=z(e.effect._effect,t);return e.f(n)}case`FlatMap`:{let n=z(e.effect._effect,t);return z(e.f(n)._effect,t)}case`MapError`:try{return z(e.effect._effect,t)}catch(t){throw e.f(t)}case`Recover`:try{return z(e.effect._effect,t)}catch{return e.fallback}case`RecoverWith`:try{return z(e.effect._effect,t)}catch(n){return z(e.f(n)._effect,t)}case`Fold`:try{let n=z(e.effect._effect,t);return e.onSuccess(n)}catch(t){return 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 z(e.effect._effect,n)}case`Interrupt`:throw new Ot;case`Bracket`:{let n=z(e.acquire._effect,t);try{return z(e.use(n)._effect,t)}finally{z(e.release(n)._effect,t)}}case`Race`:throw Error(`Cannot run race effect synchronously`);case`Timeout`:throw Error(`Cannot run timeout effect synchronously`)}},B=async(e,t=P.empty())=>{try{switch(e._tag){case`Succeed`:return L(I.succeed(e.value));case`Fail`:return L(I.fail(e.error));case`Die`:throw e.defect;case`Sync`:return L(I.succeed(e.thunk()));case`Async`:{let t=await e.thunk();return L(I.succeed(t))}case`Auto`:{let t=e.thunk();return t instanceof Promise?L(I.succeed(await t)):L(I.succeed(t))}case`Map`:{let n=await B(e.effect._effect,t);return n.isSuccess()?L(I.succeed(e.f(n.orThrow()))):L(n)}case`FlatMap`:{let n=await B(e.effect._effect,t);return n.isSuccess()?B(e.f(n.orThrow())._effect,t):L(n)}case`MapError`:{let n=await B(e.effect._effect,t);return n.isSuccess()?L(n):n.isFailure()?L(I.fail(e.f(n.toValue().error))):L(n)}case`Recover`:{let n=await B(e.effect._effect,t);return n.isSuccess()?n:I.succeed(e.fallback)}case`RecoverWith`:{let n=await B(e.effect._effect,t);return n.isSuccess()?n:n.isFailure()?B(e.f(n.toValue().error)._effect,t):n}case`Fold`:{let n=await B(e.effect._effect,t);return n.isSuccess()?I.succeed(e.onSuccess(n.orThrow())):n.isFailure()?I.succeed(e.onFailure(n.toValue().error)):n}case`Service`:{let n=t.get(e.tag);return n.isNone()?I.fail(Error(`Service not found: ${e.tag.id}`)):I.succeed(n.orThrow())}case`ProvideContext`:{let n=t.merge(e.context);return B(e.effect._effect,n)}case`Interrupt`:return I.interrupted();case`Bracket`:{let n=await B(e.acquire._effect,t);if(!n.isSuccess())return n;let r=n.orThrow();try{return await B(e.use(r)._effect,t)}finally{await B(e.release(r)._effect,t)}}case`Race`:return e.effects.length===0?I.fail(Error(`No effects to race`)):await Promise.race(e.effects.map(e=>B(e._effect,t)));case`Timeout`:{let n=new Promise(t=>setTimeout(()=>t(I.fail(new Dt(e.duration))),e.duration)),r=B(e.effect._effect,t);return Promise.race([r,n])}}}catch(e){return I.fail(e)}},V={sync:e=>R({_tag:`Sync`,thunk:e}),succeed:e=>R({_tag:`Succeed`,value:e}),fail:e=>R({_tag:`Fail`,error:e}),die:e=>R({_tag:`Die`,defect:e}),async:e=>R(L({_tag:`Async`,thunk:e})),tryPromise:e=>R({_tag:`Async`,thunk:e.try}).mapError(e.catch),tryCatch:(e,t)=>V.sync(()=>{try{return e()}catch(e){throw t(e)}}),liftSync:e=>(...t)=>V.sync(()=>e(...t)),liftPromise:e=>(...t)=>V.async(()=>e(...t)),fromEither:e=>L(e.isRight()?V.succeed(e.value):V.fail(e.value)),fromOption:e=>L(e.isSome()?V.succeed(e.value):V.fail(void 0)),fromOptionOrFail:(e,t)=>L(e.isSome()?V.succeed(e.value):V.fail(t())),fromTry:e=>L(e.isSuccess()?V.succeed(e.orThrow()):V.fail(e.error)),fromResult:e=>L(e.error?V.fail(e.error):V.succeed(m(e.data))),tryAsync:(e,t,n)=>n?.aborted?L(V.fail(t(n.reason??new DOMException(`Aborted`,`AbortError`)))):V.async(()=>e(n)).mapError(t),asyncResult:(e,t,n)=>{let r=n?.dataKey??`data`,i=n?.errorKey??`error`;return V.tryAsync(t=>e(t),t,n?.signal).flatMap(e=>V.fromResult({data:e[r],error:e[i]}))},service:e=>R({_tag:`Service`,tag:e}),serviceWith:(e,t)=>V.service(e).map(t),serviceWithIO:(e,t)=>V.service(e).flatMap(t),withServices:(e,t)=>{let n=Object.entries(e);if(n.length===0)return L(R({_tag:`Auto`,thunk:()=>t({})}));let r=L(V.succeed({}));return L(n.reduce((e,[t,n])=>L(e.flatMap(e=>V.service(n).map(n=>({...e,[t]:n})))),r).flatMap(e=>R({_tag:`Auto`,thunk:()=>t(e)})))},all:e=>{if(e.length===0)return L(V.succeed([]));let t=L(V.succeed([]));return L(e.reduce((e,t)=>e.flatMap(e=>t.map(t=>[...e,t])),t))},firstSuccessOf:e=>e.length===0?L(V.fail(Error(`No effects provided`))):e.reduce((e,t)=>e.recoverWith(()=>t)),sleep:e=>L(V.async(()=>new Promise(t=>setTimeout(t,e)))),never:()=>L(V.async(()=>new Promise(()=>{}))),get unit(){return L(R({_tag:`Succeed`,value:void 0}))},fromNullable:e=>L(e==null?V.fail(void 0):V.succeed(e)),interrupt:()=>R({_tag:`Interrupt`}),bracket:(e,t,n)=>R({_tag:`Bracket`,acquire:e,use:t,release:n}),acquireRelease:(e,t,n)=>V.bracket(e,t,n),race:e=>R({_tag:`Race`,effects:e}),any:e=>e.length===0?L(V.fail(Error(`No effects provided`))):e.reduce((e,t)=>e.recoverWith(()=>t)),forEach:(e,t)=>{if(e.length===0)return L(V.succeed([]));let n=L(V.succeed([]));return L(e.reduce((e,n)=>e.flatMap(e=>t(n).map(t=>[...e,t])),n))},forEachPar:(e,t)=>V.forEach(e,t),timeout:(e,t)=>R(L({_tag:`Timeout`,effect:e,duration:t})),gen:e=>L(V.sync(()=>{let t=e(),n=e=>{let r=t.next(e);return r.done?L(V.succeed(r.value)):L(r.value.flatMap(e=>n(e)))};return n(void 0)}).flatMap(e=>e)),get Do(){return kt(V.succeed({}))}},kt=e=>({effect:e,bind(t,n){return kt(e.flatMap(e=>n(e).map(n=>({...e,[t]:n}))))},let(t,n){return kt(e.map(e=>({...e,[t]:n(e)})))},map(t){return e.map(t)},flatMap(t){return e.flatMap(t)},tap(t){return kt(e.tap(t))},tapEffect(t){return kt(e.tapEffect(t))},done(){return e}}),H=r(e=>R(L({_tag:`Auto`,thunk:e})),V),U=(e,t)=>({_tag:`Layer`,build:e,provideToAndMerge(t){return U(async n=>{let r=await e(n),i=n.merge(r),a=await t.build(i);return r.merge(a)})},merge(t){return U(async n=>{let[r,i]=await Promise.all([e(n),t.build(n)]);return r.merge(i)})},map(t){return U(async n=>t(await e(n)))},toString(){return`Layer(${t??`anonymous`})`}}),At={succeed:(e,t)=>U(()=>Promise.resolve(P.make(e,t)),e.id),effect:(e,t)=>U(async()=>{let n=await t();return P.make(e,n)},e.id),sync:(e,t)=>U(()=>Promise.resolve(P.make(e,t())),e.id),fromService:(e,t,n)=>U(r=>{let i=r.unsafeGet(t);return Promise.resolve(P.make(e,n(i)))},e.id),fromServiceEffect:(e,t,n)=>U(async r=>{let i=await n(r.unsafeGet(t));return P.make(e,i)},e.id),fromContext:e=>U(()=>Promise.resolve(e)),empty:()=>U(()=>Promise.resolve(P.empty()),`empty`),mergeAll:(...e)=>U(async t=>(await Promise.all(e.map(e=>e.build(t)))).reduce((e,t)=>e.merge(t),P.empty()))},jt=e=>({id:e,_tag:`Tag`,toString(){return`Tag(${e})`}}),Mt=()=>{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})})}}},W=jt(`TestClock`),Nt={make:Mt,tag:W,test:async e=>e(Mt()),get:H.service(W),advance:e=>H.serviceWithIO(W,t=>H.async(()=>t.advance(e))),setTime:e=>H.serviceWithIO(W,t=>H.async(()=>t.setTime(e))),runAll:H.serviceWithIO(W,e=>H.async(()=>e.runAll())),context:()=>{let e=Mt();return{clock:e,context:P.make(W,e)}}},Pt={make:()=>{let e=Mt(),t=P.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=Mt();return Pt.make().withService(W,e)}},Ft=jt(`HttpClient`),It={},Lt=r({},{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)}}}),Rt=(e,t)=>!e||t.startsWith(`http://`)||t.startsWith(`https://`)?t:`${e.endsWith(`/`)?e.slice(0,-1):e}${t.startsWith(`/`)?t:`/${t}`}`,zt=e=>e==null?{serialized:void 0,contentType:void 0}:typeof e==`string`?{serialized:e,contentType:void 0}:typeof e==`object`||Array.isArray(e)?{serialized:JSON.stringify(e),contentType:`application/json`}:{serialized:String(e),contentType:void 0},Bt=e=>{let t=e.get(`content-type`)??``;return t.includes(`application/json`)?`json`:t.startsWith(`text/`)?`text`:`raw`},Vt=async(e,t,n,r)=>{let i=t??Bt(e.headers),a;switch(i){case`json`:{let t=await e.text();try{a=JSON.parse(t)}catch(e){throw Lt.decodeError(n,r,t,e)}break}case`text`:a=await e.text();break;case`blob`:a=await e.blob();break;case`arrayBuffer`:a=await e.arrayBuffer();break;case`raw`:a=e;break}return{data:a,status:e.status,statusText:e.statusText,headers:e.headers}},G=(e,t)=>{let n=Rt(e.baseUrl,t.url),{serialized:r,contentType:i}=zt(t.body),a={...e.defaultHeaders,...t.headers,...i?{"Content-Type":i}:{}};return H.tryAsync(i=>(e.fetch??globalThis.fetch)(n,{method:t.method,headers:a,body:r,signal:t.signal??i}).then(async e=>{if(!e.ok){let r=await e.text().catch(()=>``);throw Lt.httpStatusError(n,t.method,e.status,e.statusText,r)}return Vt(e,t.parseAs,n,t.method)}),e=>typeof e==`object`&&e&&`_tag`in e?e:Lt.networkError(n,t.method,e))},K=e=>G(It,e),Ht=r({},{request:K,get:(e,t)=>K({...t,url:e,method:`GET`}),post:(e,t)=>K({...t,url:e,method:`POST`}),put:(e,t)=>K({...t,url:e,method:`PUT`}),patch:(e,t)=>K({...t,url:e,method:`PATCH`}),delete:(e,t)=>K({...t,url:e,method:`DELETE`}),head:(e,t)=>K({...t,url:e,method:`HEAD`,parseAs:`raw`}),options:(e,t)=>K({...t,url:e,method:`OPTIONS`,parseAs:`raw`}),client:e=>({request:t=>G(e,t),get:(t,n)=>G(e,{...n,url:t,method:`GET`}),post:(t,n)=>G(e,{...n,url:t,method:`POST`}),put:(t,n)=>G(e,{...n,url:t,method:`PUT`}),patch:(t,n)=>G(e,{...n,url:t,method:`PATCH`}),delete:(t,n)=>G(e,{...n,url:t,method:`DELETE`}),head:(t,n)=>G(e,{...n,url:t,method:`HEAD`,parseAs:`raw`}),options:(t,n)=>G(e,{...n,url:t,method:`OPTIONS`,parseAs:`raw`})})}),Ut={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)},q=e=>typeof e==`object`&&!!e&&(e._tag===`Some`||e._tag===`None`),J=e=>typeof e==`object`&&!!e&&e._tag===`List`,Wt=e=>typeof e==`object`&&!!e&&(e._tag===`Left`||e._tag===`Right`),Gt=e=>typeof e==`object`&&!!e&&(e._tag===`Success`||e._tag===`Failure`),Y=()=>{let e=(e,t)=>{if(q(e)||J(e)||Wt(e)||Gt(e))return e.map(e=>t(e));throw Error(`Unsupported functor type: ${JSON.stringify(e)}`)},t=e=>{if(q(e))return e.orThrow();if(J(e)){let t=e.toArray();if(t.length>0&&J(t[0])){let e=[];for(let n of t)J(n)&&e.push(...n.toArray());return C(e)}return e.flatten()}if(Wt(e))return e.isRight()?e.fold(()=>null,e=>e):e;if(Gt(e))return e.isSuccess()?e.orThrow():e;throw Error(`Unsupported functor type for flatten: ${JSON.stringify(e)}`)},n=(e,t)=>{if(q(e)||J(e)||Wt(e)||Gt(e))return e.flatMap(e=>t(e));throw Error(`Unsupported functor type for flatMap: ${JSON.stringify(e)}`)},r=(e,t)=>{if(q(e)&&q(t)||J(e)&&J(t)||Wt(e)&&Wt(t)||Gt(e)&&Gt(t))return e.flatMap(e=>t.map(t=>e(t)));throw Error(`Unsupported functor type for ap: ${JSON.stringify(e)}`)},i=e=>{if(q(e)){let t=e;if(t.isEmpty)return C([m.none()]);let n=t.orThrow();if(J(n))return n.map(e=>m(e));throw Error(`Unsupported inner container type for sequence`)}if(J(e)){let t=e.toArray();if(t.length===0)return m.none();let n=t[0];if(q(n)){for(let e of t)if(e.isEmpty)return m.none();return m(C(t.map(e=>e.orThrow())))}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`}},Kt=Y();Y.map=(e,t)=>Kt.map(e,t),Y.flatten=e=>Kt.flatten(e),Y.flatMap=(e,t)=>Kt.flatMap(e,t),Y.ap=(e,t)=>Kt.ap(e,t),Y.sequence=e=>Kt.sequence(e),Y.traverse=(e,t)=>Kt.traverse(e,t),Y.isOption=q,Y.isList=J,Y.isEither=Wt,Y.isTry=Gt;const qt=e=>({id:e,isSame:t=>t.id===e}),Jt=r(qt,{of:e=>qt(e),pure:e=>qt(e)}),Yt=e=>{let t=!1,r,i,a=!1,o=()=>{if(!t)try{r=e(),t=!0}catch(e){throw i=e,a=!0,t=!0,e}if(a)throw i;return r};return{[Symbol.toStringTag]:`Lazy`,_tag:`Lazy`,get isEvaluated(){return t},orElse:e=>{try{return o()}catch{return e}},orNull:()=>{try{return o()}catch{return null}},orThrow:e=>{try{return o()}catch(t){throw e??t}},or:e=>X(()=>{try{return o()}catch{return e.orThrow()}}),orUndefined:()=>{try{return o()}catch{return}},map:e=>X(()=>e(o())),ap:e=>X(()=>e.orThrow()(o())),mapAsync:async e=>{let t=await e(o());return X(()=>t)},flatMap:e=>X(()=>e(o()).orThrow()),flatMapAsync:async e=>{let t=await e(o());return X(()=>t.orThrow())},filter:e=>X(()=>{let t=o();return e(t)?d(t):p}),recover:e=>X(()=>{try{return o()}catch(t){return e(t)}}),recoverWith:e=>X(()=>{try{return o()}catch(t){return e(t).orThrow()}}),toOption:()=>{try{return d(o())}catch{return p}},toEither:()=>{try{return w(o())}catch(e){return T(e)}},toEitherWith:e=>{try{return w(o())}catch(t){return T(e(t))}},toTry:()=>x(()=>o()),tap:e=>X(()=>{let t=o();return e(t),t}),tapError:e=>X(()=>{try{return o()}catch(t){throw e(t),t}}),fold:e=>e(o()),foldWith:(e,t)=>{try{return t(o())}catch(t){return e(t)}},foldLeft:e=>t=>t(e,o()),foldRight:e=>t=>t(o(),e),match:e=>e.Lazy(o()),toString:()=>t&&!a?`Lazy(${n(r)})`:t&&a?`Lazy(<error: ${i instanceof Error?i.message:String(i)}>)`:`Lazy(<not evaluated>)`,toValue:()=>t&&!a?{_tag:`Lazy`,evaluated:!0,value:r}:{_tag:`Lazy`,evaluated:!1},get size(){try{return o(),1}catch{return 0}},get isEmpty(){try{return o(),!1}catch{return!0}},contains:e=>{try{return o()===e}catch{return!1}},reduce:e=>o(),reduceRight:e=>o(),count:e=>{try{return e(o())?1:0}catch{return 0}},find:e=>{try{let t=o();return e(t)?d(t):p}catch{return p}},exists:e=>{try{return e(o())}catch{return!1}},forEach:e=>{try{e(o())}catch{}},pipe:e=>e(o()),serialize:()=>({toJSON:()=>JSON.stringify(t&&!a?{_tag:`Lazy`,evaluated:!0,value:r}:{_tag:`Lazy`,evaluated:!1}),toYAML:()=>t&&!a?`_tag: Lazy\nevaluated: true\nvalue: ${n(r)}`:`_tag: Lazy
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${ht(e)}`:`\n\nContext:\n${ht(e)}`;a+=t}}return a}function vt(){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?gt(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?gt(e.stack):void 0})))}catch{}return Object.getOwnPropertyNames(t).forEach(e=>{n[e]||(n[e]=t[e])}),n}}const j=(e,n,r,i)=>t(Xe.apply(n,r,{name:e,description:n}),{code:e,message:n,status:yt(e),context:r,timestamp:new Date().toISOString(),traceId:i?.traceId}),yt=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],M=Object.assign(j,{validation:(e,t,n)=>j(`VALIDATION_FAILED`,`Validation failed: ${e} ${n}`,{field:e,value:t,rule:n}),network:(e,t,n)=>j(`NETWORK_ERROR`,`Network error: ${t} ${e}${n?` (${n})`:``}`,{url:e,method:t,statusCode:n}),auth:(e,t)=>j(`AUTH_REQUIRED`,`Authentication required: ${e}${t?` (role: ${t})`:``}`,{resource:e,requiredRole:t}),notFound:(e,t)=>j(`NOT_FOUND`,`Not found: ${e} with id ${t}`,{resource:e,id:t}),permission:(e,t,n)=>j(`PERMISSION_DENIED`,`Permission denied: cannot ${e} ${t}`,{action:e,resource:t,userId:n}),rateLimit:(e,t,n)=>j(`RATE_LIMITED`,`Rate limit exceeded: ${e} requests per ${t}`,{limit:e,window:t,retryAfter:n}),internal:e=>j(`INTERNAL_ERROR`,`Internal server error: ${e}`,{errorId:e,timestamp:new Date().toISOString()}),badRequest:(e,t)=>j(`BAD_REQUEST`,`Bad request: ${e}`,{reason:e,expected:t}),conflict:(e,t)=>j(`CONFLICT`,`Conflict: ${e} already exists with value ${t}`,{resource:e,conflictingValue:t}),timeout:(e,t)=>j(`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}),N={rule:e=>t=>{if(e===`email`)return typeof t!=`string`||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)?T(M.validation(`value`,t,`must be a valid email`)):w(t);if(e===`url`)try{return new URL(String(t)),w(t)}catch{return T(M.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(M.validation(`value`,t,`must be a valid UUID`)):w(t);if(e===`required`)return t==null||t===``?T(M.validation(`value`,t,`is required`)):w(t);if(e===`numeric`)return typeof t!=`number`&&!/^\d+$/.test(String(t))?T(M.validation(`value`,t,`must be numeric`)):w(t);if(e===`alpha`)return typeof t!=`string`||!/^[a-zA-Z]+$/.test(t)?T(M.validation(`value`,t,`must contain only letters`)):w(t);if(e===`alphanumeric`)return typeof t!=`string`||!/^[a-zA-Z0-9]+$/.test(t)?T(M.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(M.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(M.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(M.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(M.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(M.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(M.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(M.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(M.validation(`value`,t,`must be a valid date`)):w(t)}if(e===`future`){let e=new Date(String(t));return isNaN(e.getTime())||e<=new Date?T(M.validation(`value`,t,`must be a future date`)):w(t)}if(e===`past`){let e=new Date(String(t));return isNaN(e.getTime())||e>=new Date?T(M.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(M.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=M.validation(i,e,t.context.rule);n.push(r)}else r[i]=o.orThrow()}return n.length>0?T(C(n)):w(r)}},bt={...N,validators:{email:N.rule(`email`),url:N.rule(`url`),uuid:N.rule(`uuid`),required:N.rule(`required`),numeric:N.rule(`numeric`),positiveNumber:N.combine(N.rule(`numeric`),N.rule(`min:0`)),nonEmptyString:N.combine(N.rule(`required`),N.custom(e=>typeof e==`string`&&e.trim().length>0,`must not be empty`))}},xt=t(N.rule,bt);function St(e){return typeof e==`object`&&!!e&&`orThrow`in e&&typeof e.orThrow==`function`}function Ct(e){return St(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 wt=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),wt(r)},merge(t){let n=new Map(e);for(let[e,r]of t.services)n.set(e,r);return wt(n)},get size(){return e.size},toString(){return`Context(${Array.from(e.keys()).join(`, `)})`}}),P={empty:()=>wt(new Map),make:(e,t)=>{let n=new Map;return n.set(e.id,t),wt(n)},isContext:e=>typeof e==`object`&&!!e&&e._tag===`Context`},F=e=>({[Symbol.toStringTag]:`Exit`,_tag:`Success`,isSuccess(){return!0},isFailure(){return!1},isInterrupted(){return!1},map(t){return F(t(e))},mapError(t){return F(e)},mapBoth(t,n){return F(n(e))},flatMap(t){return t(e)},fold(t,n,r){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(${n(e)})`},toJSON(){return{_tag:`Success`,value:e}}}),Tt=e=>({[Symbol.toStringTag]:`Exit`,_tag:`Failure`,isSuccess(){return!1},isFailure(){return!0},isInterrupted(){return!1},map(t){return Tt(e)},mapError(t){return Tt(t(e))},mapBoth(t,n){return Tt(t(e))},flatMap(t){return Tt(e)},fold(t,n,r){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(${n(e)})`},toJSON(){return{_tag:`Failure`,error:e}}}),Et=e=>({[Symbol.toStringTag]:`Exit`,_tag:`Interrupted`,isSuccess(){return!1},isFailure(){return!1},isInterrupted(){return!0},map(t){return Et(e)},mapError(t){return Et(e)},mapBoth(t,n){return Et(e)},flatMap(t){return Et(e)},fold(t,n,r){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}}}),I=r(e=>F(e),{succeed:e=>F(e),fail:e=>Tt(e),interrupt:e=>Et(e),interrupted:()=>Et(`interrupted`),isSuccess:e=>e.isSuccess(),isFailure:e=>e.isFailure(),isInterrupted:e=>e.isInterrupted(),fromEither:e=>e.isRight()?F(e.value):Tt(e.value),fromOption:(e,t)=>e.isSome()?F(e.value):Tt(t()),zip:(e,t)=>e.isInterrupted()?e:t.isInterrupted()?t:e.isFailure()?e:t.isFailure()?t:F([e.orThrow(),t.orThrow()]),all:e=>{let t=[];for(let n of e){if(n.isInterrupted()||n.isFailure())return n;t.push(n.orThrow())}return F(t)}}),L=e=>e;var Dt=class extends Error{constructor(e,t){super(t??`Effect timed out after ${e}ms`),this.duration=e,this._tag=`TimeoutError`,this.name=`TimeoutError`}},Ot=class extends Error{constructor(e){super(e??`Effect was interrupted`),this._tag=`InterruptedError`,this.name=`InterruptedError`}};const R=e=>{let t={[Symbol.toStringTag]:`IO`,_effect:e,map(e){return R(L({_tag:`Map`,effect:t,f:e}))},flatMap(e){return R(L({_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 R(L({_tag:`MapError`,effect:t,f:e}))},tapError(e){return t.mapError(t=>(e(t),t))},recover(e){return R(L({_tag:`Recover`,effect:t,fallback:e}))},recoverWith(e){return R(L({_tag:`RecoverWith`,effect:t,f:e}))},fold(e,n){return R(L({_tag:`Fold`,effect:t,onFailure:e,onSuccess:n}))},match(e){return t.fold(e.failure,e.success)},catchTag(e,n){return R(L({_tag:`RecoverWith`,effect:t,f:t=>typeof t==`object`&&t&&`_tag`in t&&t._tag===e?L(n(t)):L(V.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(()=>V.sleep(n).flatMap(()=>t.retryWithDelay(e-1,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 R(L({_tag:`ProvideContext`,effect:t,context:e}))},provideService(e,n){return R(L({_tag:`ProvideContext`,effect:t,context:P.make(e,n)}))},provideLayer(e){return L(L(V.async(async()=>{let t=P.empty();return await e.build(L(t))})).flatMap(e=>R(L({_tag:`ProvideContext`,effect:t,context:e}))))},async run(){let e=await B(this._effect);return e.isSuccess()?w(e.orThrow()):T(e.isFailure()?e.toValue().error:new Ot)},async runOrThrow(){let e=await B(this._effect);if(e.isSuccess())return e.orThrow();throw e.isFailure()?e.toValue().error:new Ot},runSync(){try{return w(z(this._effect))}catch(e){return T(e)}},runSyncOrThrow(){return z(this._effect)},async runExit(){return B(this._effect)},async runOption(){let e=await B(this._effect);return e.isSuccess()?d(e.orThrow()):p()},async runTry(){let e=await B(this._effect);if(e.isSuccess())return L(x(()=>e.orThrow()));let t=e.isFailure()?e.toValue().error:Error(`Effect was interrupted`);return L(x(()=>{throw t}))},pipe(e){return e(t)},delay(e){return L(V.async(()=>new Promise(t=>setTimeout(t,e))).flatMap(()=>t))},timeout(e){return R(L({_tag:`Timeout`,effect:t,duration:e}))},timeoutTo(e,n){return L(t.timeout(e).recover(L(n)))},toString(){return`IO(${n(e._tag)})`},toJSON(){return{_tag:`IO`,effect:e._tag}},*[Symbol.iterator](){return yield t}};return t},z=(e,t=P.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=z(e.effect._effect,t);return e.f(n)}case`FlatMap`:{let n=z(e.effect._effect,t);return z(e.f(n)._effect,t)}case`MapError`:try{return z(e.effect._effect,t)}catch(t){throw e.f(t)}case`Recover`:try{return z(e.effect._effect,t)}catch{return e.fallback}case`RecoverWith`:try{return z(e.effect._effect,t)}catch(n){return z(e.f(n)._effect,t)}case`Fold`:try{let n=z(e.effect._effect,t);return e.onSuccess(n)}catch(t){return 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 z(e.effect._effect,n)}case`Interrupt`:throw new Ot;case`Bracket`:{let n=z(e.acquire._effect,t);try{return z(e.use(n)._effect,t)}finally{z(e.release(n)._effect,t)}}case`Race`:throw Error(`Cannot run race effect synchronously`);case`Timeout`:throw Error(`Cannot run timeout effect synchronously`)}},B=async(e,t=P.empty())=>{try{switch(e._tag){case`Succeed`:return L(I.succeed(e.value));case`Fail`:return L(I.fail(e.error));case`Die`:throw e.defect;case`Sync`:return L(I.succeed(e.thunk()));case`Async`:{let t=await e.thunk();return L(I.succeed(t))}case`Auto`:{let t=e.thunk();return t instanceof Promise?L(I.succeed(await t)):L(I.succeed(t))}case`Map`:{let n=await B(e.effect._effect,t);return n.isSuccess()?L(I.succeed(e.f(n.orThrow()))):L(n)}case`FlatMap`:{let n=await B(e.effect._effect,t);return n.isSuccess()?B(e.f(n.orThrow())._effect,t):L(n)}case`MapError`:{let n=await B(e.effect._effect,t);return n.isSuccess()?L(n):n.isFailure()?L(I.fail(e.f(n.toValue().error))):L(n)}case`Recover`:{let n=await B(e.effect._effect,t);return n.isSuccess()?n:I.succeed(e.fallback)}case`RecoverWith`:{let n=await B(e.effect._effect,t);return n.isSuccess()?n:n.isFailure()?B(e.f(n.toValue().error)._effect,t):n}case`Fold`:{let n=await B(e.effect._effect,t);return n.isSuccess()?I.succeed(e.onSuccess(n.orThrow())):n.isFailure()?I.succeed(e.onFailure(n.toValue().error)):n}case`Service`:{let n=t.get(e.tag);return n.isNone()?I.fail(Error(`Service not found: ${e.tag.id}`)):I.succeed(n.orThrow())}case`ProvideContext`:{let n=t.merge(e.context);return B(e.effect._effect,n)}case`Interrupt`:return I.interrupted();case`Bracket`:{let n=await B(e.acquire._effect,t);if(!n.isSuccess())return n;let r=n.orThrow();try{return await B(e.use(r)._effect,t)}finally{await B(e.release(r)._effect,t)}}case`Race`:return e.effects.length===0?I.fail(Error(`No effects to race`)):await Promise.race(e.effects.map(e=>B(e._effect,t)));case`Timeout`:{let n=new Promise(t=>setTimeout(()=>t(I.fail(new Dt(e.duration))),e.duration)),r=B(e.effect._effect,t);return Promise.race([r,n])}}}catch(e){return I.fail(e)}},V={sync:e=>R({_tag:`Sync`,thunk:e}),succeed:e=>R({_tag:`Succeed`,value:e}),fail:e=>R({_tag:`Fail`,error:e}),die:e=>R({_tag:`Die`,defect:e}),async:e=>R(L({_tag:`Async`,thunk:e})),tryPromise:e=>R({_tag:`Async`,thunk:e.try}).mapError(e.catch),tryCatch:(e,t)=>V.sync(()=>{try{return e()}catch(e){throw t(e)}}),liftSync:e=>(...t)=>V.sync(()=>e(...t)),liftPromise:e=>(...t)=>V.async(()=>e(...t)),fromEither:e=>L(e.isRight()?V.succeed(e.value):V.fail(e.value)),fromOption:e=>L(e.isSome()?V.succeed(e.value):V.fail(void 0)),fromOptionOrFail:(e,t)=>L(e.isSome()?V.succeed(e.value):V.fail(t())),fromTry:e=>L(e.isSuccess()?V.succeed(e.orThrow()):V.fail(e.error)),fromResult:e=>L(e.error?V.fail(e.error):V.succeed(m(e.data))),tryAsync:(e,t,n)=>n?.aborted?L(V.fail(t(n.reason??new DOMException(`Aborted`,`AbortError`)))):V.async(()=>e(n)).mapError(t),asyncResult:(e,t,n)=>{let r=n?.dataKey??`data`,i=n?.errorKey??`error`;return V.tryAsync(t=>e(t),t,n?.signal).flatMap(e=>V.fromResult({data:e[r],error:e[i]}))},service:e=>R({_tag:`Service`,tag:e}),serviceWith:(e,t)=>V.service(e).map(t),serviceWithIO:(e,t)=>V.service(e).flatMap(t),withServices:(e,t)=>{let n=Object.entries(e);if(n.length===0)return L(R({_tag:`Auto`,thunk:()=>t({})}));let r=L(V.succeed({}));return L(n.reduce((e,[t,n])=>L(e.flatMap(e=>V.service(n).map(n=>({...e,[t]:n})))),r).flatMap(e=>R({_tag:`Auto`,thunk:()=>t(e)})))},all:e=>{if(e.length===0)return L(V.succeed([]));let t=L(V.succeed([]));return L(e.reduce((e,t)=>e.flatMap(e=>t.map(t=>[...e,t])),t))},firstSuccessOf:e=>e.length===0?L(V.fail(Error(`No effects provided`))):e.reduce((e,t)=>e.recoverWith(()=>t)),sleep:e=>L(V.async(()=>new Promise(t=>setTimeout(t,e)))),never:()=>L(V.async(()=>new Promise(()=>{}))),get unit(){return L(R({_tag:`Succeed`,value:void 0}))},fromNullable:e=>L(e==null?V.fail(void 0):V.succeed(e)),interrupt:()=>R({_tag:`Interrupt`}),bracket:(e,t,n)=>R({_tag:`Bracket`,acquire:e,use:t,release:n}),acquireRelease:(e,t,n)=>V.bracket(e,t,n),race:e=>R({_tag:`Race`,effects:e}),any:e=>e.length===0?L(V.fail(Error(`No effects provided`))):e.reduce((e,t)=>e.recoverWith(()=>t)),forEach:(e,t)=>{if(e.length===0)return L(V.succeed([]));let n=L(V.succeed([]));return L(e.reduce((e,n)=>e.flatMap(e=>t(n).map(t=>[...e,t])),n))},forEachPar:(e,t)=>V.forEach(e,t),timeout:(e,t)=>R(L({_tag:`Timeout`,effect:e,duration:t})),gen:e=>L(V.sync(()=>{let t=e(),n=e=>{let r=t.next(e);return r.done?L(V.succeed(r.value)):L(r.value.flatMap(e=>n(e)))};return n(void 0)}).flatMap(e=>e)),get Do(){return kt(V.succeed({}))}},kt=e=>({effect:e,bind(t,n){return kt(e.flatMap(e=>n(e).map(n=>({...e,[t]:n}))))},let(t,n){return kt(e.map(e=>({...e,[t]:n(e)})))},map(t){return e.map(t)},flatMap(t){return e.flatMap(t)},tap(t){return kt(e.tap(t))},tapEffect(t){return kt(e.tapEffect(t))},done(){return e}}),H=r(e=>R(L({_tag:`Auto`,thunk:e})),V),U=(e,t)=>({_tag:`Layer`,build:e,provideToAndMerge(t){return U(async n=>{let r=await e(n),i=n.merge(r),a=await t.build(i);return r.merge(a)})},merge(t){return U(async n=>{let[r,i]=await Promise.all([e(n),t.build(n)]);return r.merge(i)})},map(t){return U(async n=>t(await e(n)))},toString(){return`Layer(${t??`anonymous`})`}}),At={succeed:(e,t)=>U(()=>Promise.resolve(P.make(e,t)),e.id),effect:(e,t)=>U(async()=>{let n=await t();return P.make(e,n)},e.id),sync:(e,t)=>U(()=>Promise.resolve(P.make(e,t())),e.id),fromService:(e,t,n)=>U(r=>{let i=r.unsafeGet(t);return Promise.resolve(P.make(e,n(i)))},e.id),fromServiceEffect:(e,t,n)=>U(async r=>{let i=await n(r.unsafeGet(t));return P.make(e,i)},e.id),fromContext:e=>U(()=>Promise.resolve(e)),empty:()=>U(()=>Promise.resolve(P.empty()),`empty`),mergeAll:(...e)=>U(async t=>(await Promise.all(e.map(e=>e.build(t)))).reduce((e,t)=>e.merge(t),P.empty()))},jt=e=>({id:e,_tag:`Tag`,toString(){return`Tag(${e})`}}),Mt=()=>{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})})}}},W=jt(`TestClock`),Nt={make:Mt,tag:W,test:async e=>e(Mt()),get:H.service(W),advance:e=>H.serviceWithIO(W,t=>H.async(()=>t.advance(e))),setTime:e=>H.serviceWithIO(W,t=>H.async(()=>t.setTime(e))),runAll:H.serviceWithIO(W,e=>H.async(()=>e.runAll())),context:()=>{let e=Mt();return{clock:e,context:P.make(W,e)}}},Pt={make:()=>{let e=Mt(),t=P.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=Mt();return Pt.make().withService(W,e)}},Ft=jt(`HttpClient`),It={},Lt=r({},{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)}}}),Rt=(e,t)=>!e||t.startsWith(`http://`)||t.startsWith(`https://`)?t:`${e.endsWith(`/`)?e.slice(0,-1):e}${t.startsWith(`/`)?t:`/${t}`}`,zt=e=>e==null?{serialized:void 0,contentType:void 0}:typeof e==`string`?{serialized:e,contentType:void 0}:typeof e==`object`||Array.isArray(e)?{serialized:JSON.stringify(e),contentType:`application/json`}:{serialized:String(e),contentType:void 0},Bt=e=>{let t=e.get(`content-type`)??``;return t.includes(`application/json`)?`json`:t.startsWith(`text/`)?`text`:`raw`},Vt=async(e,t,n,r,i)=>{let a=t??Bt(e.headers),o,s={};switch(a){case`json`:{let t=await e.text();s.value=t;try{o=JSON.parse(t)}catch(e){throw Lt.decodeError(n,r,t,e)}break}case`text`:o=await e.text(),s.value=o;break;case`blob`:o=await e.blob();break;case`arrayBuffer`:o=await e.arrayBuffer();break;case`raw`:o=e;break}return{data:i?(()=>{try{return i(o)}catch(e){let t=s.value??(typeof o==`string`?o:JSON.stringify(o));throw Lt.decodeError(n,r,t,e)}})():o,status:e.status,statusText:e.statusText,headers:e.headers}},G=(e,t)=>{let n=Rt(e.baseUrl,t.url),{serialized:r,contentType:i}=zt(t.body),a={...e.defaultHeaders,...t.headers,...i?{"Content-Type":i}:{}};return H.tryAsync(i=>(e.fetch??globalThis.fetch)(n,{method:t.method,headers:a,body:r,signal:t.signal??i}).then(async e=>{if(!e.ok){let r=await e.text().catch(()=>``);throw Lt.httpStatusError(n,t.method,e.status,e.statusText,r)}return Vt(e,t.parseAs,n,t.method,t.validate)}),e=>typeof e==`object`&&e&&`_tag`in e?e:Lt.networkError(n,t.method,e))},K=e=>G(It,e),Ht=r({},{request:K,get:(e,t)=>K({...t,url:e,method:`GET`}),post:(e,t)=>K({...t,url:e,method:`POST`}),put:(e,t)=>K({...t,url:e,method:`PUT`}),patch:(e,t)=>K({...t,url:e,method:`PATCH`}),delete:(e,t)=>K({...t,url:e,method:`DELETE`}),head:(e,t)=>K({...t,url:e,method:`HEAD`,parseAs:`raw`}),options:(e,t)=>K({...t,url:e,method:`OPTIONS`,parseAs:`raw`}),client:e=>({request:t=>G(e,t),get:(t,n)=>G(e,{...n,url:t,method:`GET`}),post:(t,n)=>G(e,{...n,url:t,method:`POST`}),put:(t,n)=>G(e,{...n,url:t,method:`PUT`}),patch:(t,n)=>G(e,{...n,url:t,method:`PATCH`}),delete:(t,n)=>G(e,{...n,url:t,method:`DELETE`}),head:(t,n)=>G(e,{...n,url:t,method:`HEAD`,parseAs:`raw`}),options:(t,n)=>G(e,{...n,url:t,method:`OPTIONS`,parseAs:`raw`})})}),Ut={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)},q=e=>typeof e==`object`&&!!e&&(e._tag===`Some`||e._tag===`None`),J=e=>typeof e==`object`&&!!e&&e._tag===`List`,Wt=e=>typeof e==`object`&&!!e&&(e._tag===`Left`||e._tag===`Right`),Gt=e=>typeof e==`object`&&!!e&&(e._tag===`Success`||e._tag===`Failure`),Y=()=>{let e=(e,t)=>{if(q(e)||J(e)||Wt(e)||Gt(e))return e.map(e=>t(e));throw Error(`Unsupported functor type: ${JSON.stringify(e)}`)},t=e=>{if(q(e))return e.orThrow();if(J(e)){let t=e.toArray();if(t.length>0&&J(t[0])){let e=[];for(let n of t)J(n)&&e.push(...n.toArray());return C(e)}return e.flatten()}if(Wt(e))return e.isRight()?e.fold(()=>null,e=>e):e;if(Gt(e))return e.isSuccess()?e.orThrow():e;throw Error(`Unsupported functor type for flatten: ${JSON.stringify(e)}`)},n=(e,t)=>{if(q(e)||J(e)||Wt(e)||Gt(e))return e.flatMap(e=>t(e));throw Error(`Unsupported functor type for flatMap: ${JSON.stringify(e)}`)},r=(e,t)=>{if(q(e)&&q(t)||J(e)&&J(t)||Wt(e)&&Wt(t)||Gt(e)&&Gt(t))return e.flatMap(e=>t.map(t=>e(t)));throw Error(`Unsupported functor type for ap: ${JSON.stringify(e)}`)},i=e=>{if(q(e)){let t=e;if(t.isEmpty)return C([m.none()]);let n=t.orThrow();if(J(n))return n.map(e=>m(e));throw Error(`Unsupported inner container type for sequence`)}if(J(e)){let t=e.toArray();if(t.length===0)return m.none();let n=t[0];if(q(n)){for(let e of t)if(e.isEmpty)return m.none();return m(C(t.map(e=>e.orThrow())))}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`}},Kt=Y();Y.map=(e,t)=>Kt.map(e,t),Y.flatten=e=>Kt.flatten(e),Y.flatMap=(e,t)=>Kt.flatMap(e,t),Y.ap=(e,t)=>Kt.ap(e,t),Y.sequence=e=>Kt.sequence(e),Y.traverse=(e,t)=>Kt.traverse(e,t),Y.isOption=q,Y.isList=J,Y.isEither=Wt,Y.isTry=Gt;const qt=e=>({id:e,isSame:t=>t.id===e}),Jt=r(qt,{of:e=>qt(e),pure:e=>qt(e)}),Yt=e=>{let t=!1,r,i,a=!1,o=()=>{if(!t)try{r=e(),t=!0}catch(e){throw i=e,a=!0,t=!0,e}if(a)throw i;return r};return{[Symbol.toStringTag]:`Lazy`,_tag:`Lazy`,get isEvaluated(){return t},orElse:e=>{try{return o()}catch{return e}},orNull:()=>{try{return o()}catch{return null}},orThrow:e=>{try{return o()}catch(t){throw e??t}},or:e=>X(()=>{try{return o()}catch{return e.orThrow()}}),orUndefined:()=>{try{return o()}catch{return}},map:e=>X(()=>e(o())),ap:e=>X(()=>e.orThrow()(o())),mapAsync:async e=>{let t=await e(o());return X(()=>t)},flatMap:e=>X(()=>e(o()).orThrow()),flatMapAsync:async e=>{let t=await e(o());return X(()=>t.orThrow())},filter:e=>X(()=>{let t=o();return e(t)?d(t):p}),recover:e=>X(()=>{try{return o()}catch(t){return e(t)}}),recoverWith:e=>X(()=>{try{return o()}catch(t){return e(t).orThrow()}}),toOption:()=>{try{return d(o())}catch{return p}},toEither:()=>{try{return w(o())}catch(e){return T(e)}},toEitherWith:e=>{try{return w(o())}catch(t){return T(e(t))}},toTry:()=>x(()=>o()),tap:e=>X(()=>{let t=o();return e(t),t}),tapError:e=>X(()=>{try{return o()}catch(t){throw e(t),t}}),fold:e=>e(o()),foldWith:(e,t)=>{try{return t(o())}catch(t){return e(t)}},foldLeft:e=>t=>t(e,o()),foldRight:e=>t=>t(o(),e),match:e=>e.Lazy(o()),toString:()=>t&&!a?`Lazy(${n(r)})`:t&&a?`Lazy(<error: ${i instanceof Error?i.message:String(i)}>)`:`Lazy(<not evaluated>)`,toValue:()=>t&&!a?{_tag:`Lazy`,evaluated:!0,value:r}:{_tag:`Lazy`,evaluated:!1},get size(){try{return o(),1}catch{return 0}},get isEmpty(){try{return o(),!1}catch{return!0}},contains:e=>{try{return o()===e}catch{return!1}},reduce:e=>o(),reduceRight:e=>o(),count:e=>{try{return e(o())?1:0}catch{return 0}},find:e=>{try{let t=o();return e(t)?d(t):p}catch{return p}},exists:e=>{try{return e(o())}catch{return!1}},forEach:e=>{try{e(o())}catch{}},pipe:e=>e(o()),serialize:()=>({toJSON:()=>JSON.stringify(t&&!a?{_tag:`Lazy`,evaluated:!0,value:r}:{_tag:`Lazy`,evaluated:!1}),toYAML:()=>t&&!a?`_tag: Lazy\nevaluated: true\nvalue: ${n(r)}`:`_tag: Lazy
17
17
  evaluated: false`,toBinary:()=>Buffer.from(JSON.stringify(t&&!a?{_tag:`Lazy`,evaluated:!0,value:r}:{_tag:`Lazy`,evaluated:!1})).toString(`base64`)}),typeable:`Lazy`}},X=r(Yt,{of:e=>Yt(e),fromValue:e=>Yt(()=>e),fromOption:(e,t)=>Yt(()=>e._tag===`Some`?e.value:t()),fromTry:e=>Yt(()=>e.orThrow()),fromEither:e=>Yt(()=>e.fold(e=>{throw e},e=>e)),fromPromise:e=>Yt(()=>{throw Error(`Promise not yet resolved. Use await on the promise before creating Lazy.`)}),fail:e=>Yt(()=>{throw e})}),Xt=Map,Z=e=>{let t={values:new Xt(e)},n=()=>Array.from(t.values.entries()).map(([e,t])=>i([e,t])),r=e=>Z(new Xt(t.values).set(e.toArray()[0],e.toArray()[1]).entries()),a=e=>{let n=new Xt(t.values);return n.delete(e)?Z(n.entries()):Z(t.values.entries())},s=e=>{let n=e.toArray();return t.values.get(n[0])===n[1]},c=()=>t.values.size,l=e=>Z(Array.from(t.values.entries()).map(([t,n])=>[t,e(n)])),u=e=>Z(Z(t.values.entries()).toList().flatMap(e).toArray()),ee=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 Z(n)},d=async e=>{let n=new Xt;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 Z(n.entries())},f=e=>C(n()).reduce(e),p=e=>C(n()).reduceRight(e),te=e=>t=>C(n()).foldLeft(e)(t),ne=e=>t=>C(n()).foldRight(e)(t),h=e=>m(t.values.get(e)),g=(e,n)=>m(t.values.get(e)).orElse(n),re=()=>t.values.size===0,ie=(e,n)=>m(t.values.get(e)).or(n),ae=(e,t)=>C(n()).fold(e,t),se=()=>C(n()),_=()=>oe(n()),ce=()=>`Map(${n().toString()})`,le=e=>re()?e.Empty():e.NonEmpty(n());return{[Symbol.toStringTag]:`FunctypeMap`,_tag:`Map`,[Symbol.iterator]:()=>t.values.entries(),add:r,remove:a,contains:s,get size(){return c()},map:l,ap:ee,flatMap:u,flatMapAsync:d,reduce:f,reduceRight:p,foldLeft:te,foldRight:ne,fold:ae,match:le,get:h,getOrElse:g,get isEmpty(){return re()},orElse:ie,toList:se,toSet:_,toString:ce,toValue:()=>({_tag:`Map`,value:Array.from(t.values.entries())}),pipe:e=>e(Array.from(t.values.entries())),serialize:()=>o(`Map`,Array.from(t.values.entries()))}},Zt=e=>Z(e),Qt=Z([]),$t={empty:()=>Qt,of:(...e)=>Z(e),fromJSON:e=>en(JSON.parse(e).value),fromYAML:e=>{let t=e.split(`
18
18
  `)[1]?.split(`: `)[1];return en(t?JSON.parse(t):[])},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return $t.fromJSON(t)}},en=r(Zt,$t),tn={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])=>i([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)?1:0,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(${n(e)})`,toValue:()=>({_tag:`Obj`,value:e}),pipe:t=>t(e),serialize:()=>o(`Obj`,e),doUnwrap(){return{ok:!0,value:e}}}),nn=e=>Q(e),rn={of:e=>Q(e),empty:()=>Q({}),fromJSON:e=>Q(JSON.parse(e).value),fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return rn.fromJSON(t)}},an=r(nn,rn),$=(e=[])=>{let t=[...e],r=()=>t.length,i=()=>t.length===0,a=e=>t.includes(e),o=e=>{if(t.length===0)throw Error(`Cannot reduce an empty stack`);return t.reduce(e)},s=e=>{if(t.length===0)throw Error(`Cannot reduce an empty stack`);return t.reduceRight(e)},c=e=>$([...t,e]),l=()=>{if(i())return[$([]),m(null)];let e=[...t],n=e.pop();return[$(e),m(n)]},u=()=>i()?m(null):m(t[t.length-1]),ee=e=>$(t.map(e)),d=e=>i()?$([]):t.reduce((t,n)=>e(n).toArray().reduce((e,t)=>e.push(t),t),$([])),f=e=>{let n=[];return t.forEach(t=>{e.toArray().forEach(e=>{n.push(e(t))})}),$(n)},p=async e=>i()?$([]):(await Promise.all(t.map(async t=>await e(t)))).reduce((e,t)=>t.toArray().reduce((e,t)=>e.push(t),e),$([])),te=()=>C(t),ne=()=>[...t],h=()=>`Stack(${t.join(`, `)})`,g=(e,n)=>t.reduce(n,e),re=e=>n=>t.reduce(n,e),ie=e=>n=>t.reduceRight((e,t)=>n(t,e),e),ae=e=>i()?e.Empty():e.NonEmpty([...t]);return{[Symbol.toStringTag]:`Stack`,_tag:`Stack`,get size(){return r()},get isEmpty(){return i()},contains:a,reduce:o,reduceRight:s,push:c,pop:l,peek:u,map:ee,flatMap:d,ap:f,flatMapAsync:p,toList:te,toArray:ne,toString:h,fold:g,foldLeft:re,foldRight:ie,match:ae,toValue:()=>({_tag:`Stack`,value:t}),pipe:e=>e([...t]),serialize:()=>({toJSON:()=>JSON.stringify({_tag:`Stack`,value:t}),toYAML:()=>`_tag: Stack\nvalue: ${n(t)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:`Stack`,value:t})).toString(`base64`)})}},on=(e=[])=>$(e),sn={empty:()=>$([]),of:e=>$([e]),fromJSON:e=>cn(JSON.parse(e).value),fromYAML:e=>{let t=e.split(`
19
19
  `)[1]?.split(`: `)[1];return cn(t?JSON.parse(t):[])},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return sn.fromJSON(t)}},cn=r(on,sn);function ln(e){let t=pe({_tag:e._tag,impl:e.impl});return{...t,toValue:()=>({_tag:t._tag,value:e.value})}}export{Pe as $,ht as A,s as At,O as B,P as C,ue as Ct,vt as D,m as Dt,M as E,p as Et,pt as F,l as Ft,Ye as G,A as H,dt as I,a as It,qe as J,Xe as K,ut as L,it as M,o as Mt,ot as N,u as Nt,_t as O,te as Ot,ft as P,c as Pt,ze as Q,st as R,I as S,x as St,xt as T,oe as Tt,$e as U,k as V,Ze as W,Ve as X,We as Y,Re as Z,jt as _,Se as _t,en as a,Me as at,Ot as b,pe as bt,Jt as c,Fe as ct,Ht as d,T as dt,Le as et,Lt as f,w as ft,Pt as g,be as gt,W as h,xe as ht,tn as i,Be as it,lt as j,ee as jt,gt as k,d as kt,Y as l,E as lt,Nt as m,Ce as mt,cn as n,Ne as nt,Xt as o,ke as ot,Ft as p,we as pt,Je as q,an as r,Ae as rt,X as s,Ie as st,ln as t,je as tt,Ut as u,Oe as ut,At as v,Te as vt,Ct as w,_ as wt,Dt as x,me as xt,H as y,C as yt,ct as z};
@@ -1,2 +1,2 @@
1
- import { Gn as Try, Kn as TypeNames } from "../index-Di7IFeuy.js";
1
+ import { Gn as Try, Kn as TypeNames } from "../index-DN9rYP81.js";
2
2
  export { Try, TypeNames };
package/dist/try/index.js CHANGED
@@ -1 +1 @@
1
- import{St as e}from"../src-DagovFT3.js";export{e as Try};
1
+ import{St as e}from"../src-BhBVtHJY.js";export{e as Try};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functype",
3
- "version": "0.53.0",
3
+ "version": "0.54.0",
4
4
  "type": "module",
5
5
  "description": "A functional programming library for TypeScript, using immutable data structures and type classes",
6
6
  "author": "jordan.burke@gmail.com",